Annotation of embedaddon/coova-chilli/src/redir.h, revision 1.1

1.1     ! misho       1: /* 
        !             2:  * HTTP redirection functions.
        !             3:  * Copyright (C) 2004, 2005 Mondru AB.
        !             4:  * Copyright (c) 2006-2007 David Bird <david@coova.com>
        !             5:  * 
        !             6:  * The contents of this file may be used under the terms of the GNU
        !             7:  * General Public License Version 2, provided that the above copyright
        !             8:  * notice and this permission notice is included in all copies or
        !             9:  * substantial portions of the software.
        !            10:  * 
        !            11:  */
        !            12: 
        !            13: 
        !            14: #ifndef _REDIR_H
        !            15: #define _REDIR_H
        !            16: 
        !            17: #include "dhcp.h"
        !            18: #include "session.h"
        !            19: 
        !            20: #define REDIR_TERM_INIT       0  /* Nothing done yet */
        !            21: #define REDIR_TERM_GETREQ     1  /* Before calling redir_getreq */
        !            22: #define REDIR_TERM_GETSTATE   2  /* Before calling cb_getstate */
        !            23: #define REDIR_TERM_PROCESS    3  /* Started to process request */
        !            24: #define REDIR_TERM_RADIUS     4  /* Calling radius */
        !            25: #define REDIR_TERM_REPLY      5  /* Sending response to client */
        !            26: 
        !            27: #define REDIR_LOGIN           1
        !            28: #define REDIR_PRELOGIN        2
        !            29: #define REDIR_LOGOUT          3
        !            30: #define REDIR_CHALLENGE       4
        !            31: #define REDIR_ABORT           5
        !            32: #define REDIR_ABOUT           6
        !            33: #define REDIR_STATUS          7
        !            34: #define REDIR_SPLASH          8
        !            35: #define REDIR_WWW            20
        !            36: #define REDIR_MSDOWNLOAD     25
        !            37: #define REDIR_ADMIN_CONN     30
        !            38: #define REDIR_ALREADY        50 /* Reply to /logon while allready logged on */
        !            39: #define REDIR_FAILED_REJECT  51 /* Reply to /logon if authentication reject */
        !            40: #define REDIR_FAILED_OTHER   52 /* Reply to /logon if authentication timeout */
        !            41: #define REDIR_SUCCESS        53 /* Reply to /logon if authentication successful */
        !            42: #define REDIR_LOGOFF         54 /* Reply to /logff */
        !            43: #define REDIR_NOTYET         55 /* Reply to /prelogin or any GET request */
        !            44: #define REDIR_ABORT_ACK      56 /* Reply to /abortlogin */
        !            45: #define REDIR_ABORT_NAK      57 /* Reply to /abortlogin */
        !            46: 
        !            47: #define REDIR_FMT_DEFAULT     0
        !            48: #define REDIR_FMT_JSON        1
        !            49: 
        !            50: #define REDIR_MSG_OPT_REDIR   1
        !            51: #define REDIR_MSG_OPT_PARAMS  2
        !            52: 
        !            53: struct redir_conn_t {
        !            54:   /* 
        !            55:    *  Parameters from HTTP request 
        !            56:    */
        !            57:   unsigned short type;                 /* REDIR_LOGOUT, LOGIN, PRELOGIN, CHALLENGE, MSDOWNLOAD */
        !            58:   unsigned char format;                /* REDIR_FMT_DEFAULT, REDIR_FMT_JSON */
        !            59:   char useragent[REDIR_USERAGENTSIZE]; /* Browser User-Agent */
        !            60:   char lang[REDIR_LANGSIZE];           /* Query string parameter for language */
        !            61:   char wwwfile[REDIR_USERNAMESIZE];    /* File request, i.e. PATH_INFO */
        !            62: 
        !            63:   /*
        !            64:    *  Authentication state information
        !            65:    */
        !            66:   int chap; /* 0 if using normal password; 1 if using CHAP */
        !            67:   int response; /* 0: No radius response yet; 1:Reject; 2:Accept; 3:Timeout */
        !            68:   uint8_t chappassword[REDIR_MAXCHAR];
        !            69:   uint8_t password[REDIR_MAXCHAR];
        !            70:   uint8_t chap_ident;
        !            71:   
        !            72:   /* 
        !            73:    *  RADIUS session parameters 
        !            74:    */
        !            75:   struct in_addr nasip;
        !            76:   uint32_t nasport;
        !            77:   uint8_t hismac[PKT_ETH_ALEN];/* His MAC address */
        !            78:   uint8_t ourmac[PKT_ETH_ALEN];/* Our MAC address */
        !            79:   struct in_addr ourip;        /* IP address to listen to */
        !            80:   struct in_addr hisip;        /* Client IP address */
        !            81: 
        !            82:   /*
        !            83:    *  RADIUS Reply-Message
        !            84:    */
        !            85:   char replybuf[RADIUS_ATTR_VLEN+1];
        !            86:   char *reply;
        !            87: 
        !            88:   /*
        !            89:    *  Chilli Session parameters and status
        !            90:    */
        !            91:   struct session_params s_params;
        !            92:   struct session_state s_state;
        !            93: };
        !            94: 
        !            95: struct redir_t {
        !            96:   int fd[2];             /* File descriptors */
        !            97:   int debug;
        !            98:   int msgid;             /* Message Queue */
        !            99:   struct in_addr addr;
        !           100:   int port;
        !           101:   int uiport;
        !           102:   char *url;
        !           103:   char *homepage;
        !           104:   char *secret;
        !           105:   char *ssid;
        !           106:   char *nasmac;
        !           107:   char *nasip;
        !           108:   struct in_addr radiuslisten;
        !           109:   struct in_addr radiusserver0;
        !           110:   struct in_addr radiusserver1;
        !           111:   uint16_t radiusauthport;
        !           112:   uint16_t radiusacctport;
        !           113:   char *radiussecret;
        !           114:   char *radiusnasid;
        !           115:   char* radiuslocationid;
        !           116:   char* radiuslocationname;
        !           117:   char* locationname;
        !           118:   int radiusnasporttype;
        !           119:   int starttime;
        !           120:   int chillixml;     /* Send chilli specific XML along with WISPr */
        !           121:   int no_uamsuccess; /* Do not redirect back to uamserver on success */
        !           122:   int no_uamwispr;   /* Do not have Chilli return WISPr blocks */
        !           123:   int (*cb_getstate) (struct redir_t *redir, struct in_addr *addr,
        !           124:                      struct redir_conn_t *conn);
        !           125: };
        !           126: 
        !           127: struct redir_msg_t {
        !           128:   long mtype;
        !           129:   struct redir_msg_data {
        !           130:     uint16_t opt;
        !           131:     struct in_addr addr;
        !           132:     struct redir_state redir;
        !           133:     struct session_params params;
        !           134:   } mdata;
        !           135: };
        !           136: 
        !           137: 
        !           138: int redir_new(struct redir_t **redir, struct in_addr *addr, int port, int uiport);
        !           139: 
        !           140: int redir_free(struct redir_t *redir);
        !           141: 
        !           142: void redir_set(struct redir_t *redir, int debug);
        !           143: 
        !           144: int redir_accept(struct redir_t *redir, int idx);
        !           145: 
        !           146: int redir_setchallenge(struct redir_t *redir, struct in_addr *addr, uint8_t *challenge);
        !           147: 
        !           148: int redir_set_cb_getstate(struct redir_t *redir,
        !           149:   int (*cb_getstate) (struct redir_t *redir, struct in_addr *addr,
        !           150:                      struct redir_conn_t *conn));
        !           151: 
        !           152: int redir_main(struct redir_t *redir, int infd, int outfd, struct sockaddr_in *address, int isui);
        !           153: 
        !           154: int redir_json_fmt_redir(struct redir_conn_t *conn, bstring json, 
        !           155:                         char *userurl, char *redirurl, uint8_t *hismac);
        !           156: 
        !           157: int redir_json_fmt_session(struct redir_conn_t *conn, bstring json, int init);
        !           158: 
        !           159: #endif /* !_REDIR_H */

FreeBSD-CVSweb <freebsd-cvsweb@FreeBSD.org>