Author: tjansen Date: Wed Oct 21 12:58:02 2009 New Revision: 1250 Log: Removed deprecated preauth code from pisasd. Deleted: trunk/pisasd/sdmsg.c Modified: trunk/pisasd/Makefile.am trunk/pisasd/sdconf.c trunk/pisasd/sdconf.h trunk/pisasd/sdctx.c trunk/pisasd/sdctx.h trunk/pisasd/sdmain.c trunk/pisasd/sdtun.c Modified: trunk/pisasd/Makefile.am ============================================================================== --- trunk/pisasd/Makefile.am Wed Oct 21 12:55:01 2009 (r1249) +++ trunk/pisasd/Makefile.am Wed Oct 21 12:58:02 2009 (r1250) @@ -22,8 +22,8 @@ endif pisasd_SOURCES = sdmain.c sdclients.c sdconf.c sdctx.c sdderegister.c \ - sdheartbeat.c sdmsg.c sdregister.c sdtun.c pisasdconf.c \ + sdheartbeat.c sdregister.c sdtun.c pisasdconf.c \ sdnat.c pisasdconf_SOURCES = pisaconftool.c pisasdconf.c include_HEADERS = sdclients.h sdconf.h sdctx.h sdderegister.h sdheartbeat.h \ - sdmsg.h sdregister.h sdtun.h pisasdconf.h sdnat.h + sdregister.h sdtun.h pisasdconf.h sdnat.h Modified: trunk/pisasd/sdconf.c ============================================================================== --- trunk/pisasd/sdconf.c Wed Oct 21 12:55:01 2009 (r1249) +++ trunk/pisasd/sdconf.c Wed Oct 21 12:58:02 2009 (r1250) @@ -33,13 +33,6 @@ static void sdconf_read_ifname_eth(sd_conf *sdconf); static void sdconf_read_portnumber_control(sd_conf *sdconf); static void sdconf_read_portnumber_data(sd_conf *sdconf); -#ifdef REMOVE_PREAUTH_CODE -static void sdconf_read_portnumber_pstun(sd_conf *sdconf); -static void sdconf_read_vreqtrg_timeout(sd_conf *sdconf); -static void sdconf_read_vreqtrg_maxretry(sd_conf *sdconf); -static void sdconf_read_bures_timeout(sd_conf *sdconf); -static void sdconf_read_bures_maxretry(sd_conf *sdconf); -#endif /* REMOVE_PREAUTH_CODE */ static void sdconf_read_srv_ipv4(sd_conf *sdconf); static void sdconf_read_dyn_min(sd_conf *sdconf); static void sdconf_read_dyn_max(sd_conf *sdconf); @@ -64,13 +57,6 @@ sdconf->port_control = 0; sdconf->port_data = 0; -#ifdef REMOVE_PREAUTH_CODE - sdconf->port_pstun = 0; - sdconf->vreqtrg_timeout = PISASD_DEFAULT_VREQTRG_TIMEOUT; - sdconf->vreqtrg_maxretry = PISASD_DEFAULT_VREQTRG_MAXRETRY; - sdconf->bures_timeout = PISASD_DEFAULT_BURES_TIMEOUT; - sdconf->bures_maxretry = PISASD_DEFAULT_BURES_MAXRETRY; -#endif /* REMOVE_PREAUTH_CODE */ sdconf->is_relay = 0; memset(&sdconf->nat_up, 0, sizeof(sdconf->nat_up)); @@ -125,13 +111,6 @@ sdconf_read_ifname_eth(sdconf); sdconf_read_portnumber_control(sdconf); sdconf_read_portnumber_data(sdconf); -#ifdef REMOVE_PREAUTH_CODE - sdconf_read_portnumber_pstun(sdconf); - sdconf_read_vreqtrg_timeout(sdconf); - sdconf_read_vreqtrg_maxretry(sdconf); - sdconf_read_bures_timeout(sdconf); - sdconf_read_bures_maxretry(sdconf); -#endif /* REMOVE_PREAUTH_CODE */ sdconf_read_srv_ipv4(sdconf); sdconf_read_dyn_min(sdconf); sdconf_read_dyn_max(sdconf); @@ -236,92 +215,6 @@ } } -#ifdef REMOVE_PREAUTH_CODE -/** - * Read the listening port number from the configuration file. - * - * @param sdconf sd_conf structure where conf settings are stored - */ -static void sdconf_read_portnumber_pstun(sd_conf *sdconf) -{ - /* Determine the appropriate port number for listening connections */ - if (sdconf->port_pstun > MAX_PORTNUM) { - PISA_ERROR("Error: Port number must be %d at most!\n" - "Run with -h to see usage\n", - MAX_PORTNUM); - exit(EXIT_FAILURE); - } else if (sdconf->port_pstun == 0) { - if (!pisa_cfg_get_int_value("port_pstun", &sdconf->port_pstun)) { - PISA_DEBUG("Using the default port number %d\n", - PISASD_DEFAULT_PORTNUM_PSTUN); - sdconf->port_pstun = PISASD_DEFAULT_PORTNUM_PSTUN; - } - } -} - -/** - * Read the verify request trigger timeout from the configuration file. - * - * @param sdconf sd_conf structure where conf settings are stored - */ -static void sdconf_read_vreqtrg_timeout(sd_conf *sdconf) -{ - /* Read config value of verify request trigger timeout */ - if (!pisa_cfg_get_int_value("vreqtrg_timeout", &sdconf->vreqtrg_timeout)) { - PISA_DEBUG("Using the default vreqtrg timeout %d\n", - PISASD_DEFAULT_VREQTRG_TIMEOUT); - sdconf->vreqtrg_timeout = PISASD_DEFAULT_VREQTRG_TIMEOUT; - } -} - -/** - * Read the max trial count of verify request trigger from the - * configuration file. - * - * @param sdconf sd_conf structure where conf settings are stored - */ -static void sdconf_read_vreqtrg_maxretry(sd_conf *sdconf) -{ - /* Read config value of verify request trigger maxretry */ - if (!pisa_cfg_get_int_value("vreqtrg_maxretry", &sdconf->vreqtrg_maxretry)) { - PISA_DEBUG("Using the default bupdate req maxretry %d\n", - PISASD_DEFAULT_VREQTRG_MAXRETRY); - sdconf->vreqtrg_maxretry = PISASD_DEFAULT_VREQTRG_MAXRETRY; - } -} - -/** - * Read the binding update response timeout from the configuration file. - * - * @param sdconf sd_conf structure where conf settings are stored - */ -static void sdconf_read_bures_timeout(sd_conf *sdconf) -{ - /* Read config value of binding update response timeout */ - if (!pisa_cfg_get_int_value("binding_update_response_timeout", &sdconf->bures_timeout)) { - PISA_DEBUG("Using the default bures timeout %d\n", - PISASD_DEFAULT_BURES_TIMEOUT); - sdconf->bures_timeout = PISASD_DEFAULT_BURES_TIMEOUT; - } -} - -/** - * Read the max trial count of binding update response from the - * configuration file. - * - * @param sdconf sd_conf structure where conf settings are stored - */ -static void sdconf_read_bures_maxretry(sd_conf *sdconf) -{ - /* Read config value of binding update response maxretry */ - if (!pisa_cfg_get_int_value("binding_update_response_maxretry", &sdconf->bures_maxretry)) { - PISA_DEBUG("Using the default bupdate req maxretry %d\n", - PISASD_DEFAULT_BURES_MAXRETRY); - sdconf->bures_maxretry = PISASD_DEFAULT_BURES_MAXRETRY; - } -} -#endif /* REMOVE_PREAUTH_CODE */ - /** * Set the global debug level variable * @@ -347,80 +240,6 @@ } } -#ifdef REMOVE_PREAUTH_CODE -/** - * Get the configuration of bootstrap neighbor list from pisasd.conf - * - * @param cb_br callback to add a pair of SSID and IP address of bootstrap - * routers - * @return value length if successful, 0 if failure - */ -int sd_config_get_bootstrap_routers(extractSDBrCallback cb_br) -{ - config_setting_t *conf_list_br = NULL; - int i = 0, len = 0; - config_setting_t *group_elem = NULL; - config_setting_t *ssid = NULL; - config_setting_t *ipaddr = NULL; - config_setting_t *token = NULL; - - conf_list_br = config_lookup(&cfg, "bootstrap_routers"); - - if (!conf_list_br) { - PISA_ERROR("Cannot find bootstrap_neighbors in the config file!\n"); - return 0; - } - - len = config_setting_length(conf_list_br); - - for (i=0;i<len;i++) { - const char* ssid_text = ""; - const char* ipaddr_text = ""; - const char* token_text = ""; - - group_elem = config_setting_get_elem(conf_list_br, i); - if (!group_elem) { - PISA_ERROR("Error while processing config file: on iteration <%d>: group expected!\n", i); - continue; - } - - ssid = config_setting_get_member(group_elem, "ssid"); - - if (!ssid) { - PISA_ERROR("Error while processing config file: found no ssid in group!\n"); - } - - ssid_text = config_setting_get_string(ssid); - - ipaddr = config_setting_get_member(group_elem, "ipaddr"); - if (!ipaddr) { - PISA_ERROR("Error while processing config file: found no ipaddr in group!\n"); - continue; - } - - ipaddr_text = config_setting_get_string(ipaddr); - - token = config_setting_get_member(group_elem, "token"); - if (token) { - token_text = config_setting_get_string(token); - if (!token_text || strlen(token_text) == 0) - token_text = PISA_DEFAULT_TOKEN; - } else { - token_text = PISA_DEFAULT_TOKEN; - } - - if (ssid_text != NULL && strlen(ssid_text) > 0 - && ipaddr_text != NULL && strlen(ipaddr_text) > 0) { - cb_br(ssid_text, ipaddr_text, token_text); - } - else - PISA_ERROR("Warning while processing config file: found empty ipaddr-string.\n"); - } - - return len; -} -#endif /* REMOVE_PREAUTH_CODE */ - /** * Setup the authorized_hosts configuration file before doing any read/write operations. * Modified: trunk/pisasd/sdconf.h ============================================================================== --- trunk/pisasd/sdconf.h Wed Oct 21 12:55:01 2009 (r1249) +++ trunk/pisasd/sdconf.h Wed Oct 21 12:58:02 2009 (r1250) @@ -35,14 +35,6 @@ int port_control; /**< listening port number for control packets */ int port_data; /**< listening port number for data packets */ -#ifdef REMOVE_PREAUTH_CODE - int port_pstun; /**< listening port number for pseudo tunnel packets */ - int vreqtrg_timeout; /**< timeout when sending vreqtrg packets */ - int vreqtrg_maxretry; /**< max retry time when sending vreqtrg packets */ - int bures_timeout; /**< timeout when sending bures packets */ - int bures_maxretry; /**< max retry time when sending bures packets */ -#endif /* REMOVE_PREAUTH_CODE */ - int is_relay; /* 1 if this server is handling relay-connections, default 0 */ char nat_up[NAT_STRING_MAX]; /* string which is executed by system(3) if is_relay at init */ char nat_down[NAT_STRING_MAX]; /* string which is executed by system(3) if is_relay at deinit */ @@ -66,17 +58,4 @@ void sdconf_setup_conffile(sd_conf *sdconf); void sdconf_setup_authorized_hosts_conffile(void); -#ifdef REMOVE_PREAUTH_CODE -/** - * RB Callback for SD - * Will be called for every SD configuration in the config file - * @param ssid SSID in string representation - * @param ipaddr IP address in string representation - * @param token Token in string representation - */ -typedef void (*extractSDBrCallback)(const char *ssid, const char *ipaddr, const char *token); - -int sd_config_get_bootstrap_routers(extractSDBrCallback cb_br); -#endif /* REMOVE_PREAUTH_CODE */ - #endif /* PISA_SDCONF_H */ Modified: trunk/pisasd/sdctx.c ============================================================================== --- trunk/pisasd/sdctx.c Wed Oct 21 12:55:01 2009 (r1249) +++ trunk/pisasd/sdctx.c Wed Oct 21 12:58:02 2009 (r1250) @@ -21,10 +21,6 @@ */ sd_context sd_ctx; -#ifdef REMOVE_PREAUTH_CODE -static void add_conf_to_rlist(const char* ssid, const char *ipaddr, const char *token); -#endif /* REMOVE_PREAUTH_CODE */ - /** * Initialize general context of server daemon. * @@ -33,35 +29,13 @@ */ void sdctx_init(sd_context *sdctx) { -#ifdef REMOVE_PREAUTH_CODE - pisa_ll_init(&sdctx->routers_queue); - pisa_ll_init(&sdctx->clients_list); - - sdctx->rq_offset = 0; -#endif /* REMOVE_PREAUTH_CODE */ - sdctx->is_sd_running = FALSE; -#ifdef REMOVE_PREAUTH_CODE - sdctx->do_tokvrfy = TRUE; -#endif /* REMOVE_PREAUTH_CODE */ sdctx->is_bgrun = FALSE; -#ifdef REMOVE_PREAUTH_CODE - sdctx->is_sending_bures = FALSE; -#endif /* REMOVE_PREAUTH_CODE */ sdctx->tunc = -1; sdctx->tund = -1; -#ifdef REMOVE_PREAUTH_CODE - sdctx->fd_pstunc = -1; - sdctx->fd_pstuns = -1; -#endif /* REMOVE_PREAUTH_CODE */ sdctx->tunnel= -1; sdctx->fd_pisaconf = -1; -#ifdef REMOVE_PREAUTH_CODE - sdctx->vreqtrg_tries_count = 0; - sdctx->bures_tries_count = 0; -#endif /* REMOVE_PREAUTH_CODE */ - sdctx->ctrlhandlers = NULL; sdctx->natlist = NULL; sdctx->conlist = NULL; @@ -78,224 +52,4 @@ */ void sdctx_destroy(sd_context *sdctx) { -#ifdef REMOVE_PREAUTH_CODE - pisa_ll_uninit(&sdctx->routers_queue, pisa_free); - pisa_ll_uninit(&sdctx->clients_list, pisa_free); -#endif /* REMOVE_PREAUTH_CODE */ -} - -#ifdef REMOVE_PREAUTH_CODE -/** - * Get a list of clients. - * - * @return 0 if normal, <0 otherwise. - */ -int sdctx_get_neighbors(void) -{ - /* from the conf file to sd_ctx.routers_queue */ - sd_config_get_bootstrap_routers(add_conf_to_rlist); - - PISA_DEBUG(PL_PREAUTH, "\nDisplaying the handover-ready routers queue...\n"); - show_conf_rnblist(&sd_ctx.routers_queue); - - PISA_DEBUG(PL_PREAUTH, "\n"); - - return 0; } - -/** - * Add test entries to client lists. - * A callback for the config_get_bootstrap_clients() - * - * @param ssid ssid of access point which will be added to the client list - * @param ipaddr IP address of the access point - * @param token Token of the access point - * @return none - */ -static void add_conf_to_rlist(const char* ssid, const char *ipaddr, const char *token) -{ - pisasd_rlist_entry *nnodedata_rq; - - nnodedata_rq = (pisasd_rlist_entry *) PISA_MALLOC(sizeof(pisasd_rlist_entry)); - - memset(nnodedata_rq, 0, sizeof(pisasd_rlist_entry)); - - /* 3 entries for the ready queue: ssid, ipaddr and token */ - PISA_STRNCPY(nnodedata_rq->ssid, ssid, sizeof(nnodedata_rq->ssid)); - convert_string_to_common_ipaddr(&nnodedata_rq->ipaddr, ipaddr); - PISA_STRNCPY(nnodedata_rq->token, token, sizeof(nnodedata_rq->token)); - - pisa_ll_add(&sd_ctx.routers_queue, 0, nnodedata_rq); - - return; -} - -/** - * Show all entries in the handover-ready clients list - * - * @param llist the linked list to be displayed - * @return none - */ -void show_conf_rnblist(pisa_ll *llist) -{ - pisa_ll_node *iter = NULL; - pisasd_rlist_entry *entry; - char pbuffer[INET6_ADDRSTRLEN]={0}; - - while ((iter = pisa_ll_iterate(llist, iter)) != NULL) { - entry = (pisasd_rlist_entry *)iter->ptr; - PISA_DEBUG(PL_PREAUTH, "ENTRY: SSID = %s\n", entry->ssid); - - convert_common_ipaddr_to_string(pbuffer, &entry->ipaddr); - PISA_DEBUG(PL_PREAUTH, "IP address = %s\n", pbuffer); - - PISA_DEBUG(PL_PREAUTH, "ENTRY: token = %s\n", entry->token); - } - - return; -} - -/** - * Add a pair of token and peer IP address to cllist. - * - * @param token [in] token - * @param peer_addr [in] IP address of peer, usually trust relay - * @return the new entry added with input data - */ -pisasd_rlist_entry *pisasd_cllist_add(char *ssid, pisa_common_addr *peer_addr, pisa_token token) -{ - pisasd_rlist_entry *clentry; - - clentry = (pisasd_rlist_entry *) PISA_MALLOC(sizeof(pisasd_rlist_entry)); - - PISA_STRNCPY(clentry->token, token, sizeof(clentry->token)); - PISA_STRNCPY(clentry->ssid, ssid, MAX_SSID); - memcpy(&clentry->ipaddr, peer_addr, sizeof(clentry->ipaddr)); - - /* Now add the generated token on the self_tokens list */ - pisa_ll_add(&sd_ctx.clients_list, 0, clentry); - - return clentry; -} - -/** - * Lookup an entry in a given ready_list, which matches with the given key - * IP address. - * - * @param llist linked list where each entry is looked up - * @param keytoken the key token which lookup each entry with - * @return the cllist_entry if found, NULL otherwise - */ -pisasd_rlist_entry *pisasd_cllist_lookup_token(pisa_ll *llist, const char *keytoken) { - pisa_ll_node *iter = NULL; - pisasd_rlist_entry *entry; - - while ((iter = pisa_ll_iterate(llist, iter)) != NULL) { - entry = (pisasd_rlist_entry *) iter->ptr; - if (strncmp(entry->token, keytoken, sizeof(entry->token)) == 0) { - /* found an entry with keytoken. */ - return entry; - } - } - - return NULL; -} - -/** - * Lookup an entry in a given routers_list, which matches with the given key ssid. - * - * @param llist linked list where each entry is looked up - * @param keyssid the key ssid which lookup each entry with - * @return the rlist_entry if found, NULL otherwise - */ -pisasd_rlist_entry *pisasd_rlist_lookup_ssid(pisa_ll *llist, const char *keyssid) -{ - pisa_ll_node *iter = NULL; - pisasd_rlist_entry *entry; - - while ((iter = pisa_ll_iterate(llist, iter)) != NULL) { - entry = (pisasd_rlist_entry *) iter->ptr; - if (strncasecmp(entry->ssid, keyssid, MAX_SSID) == 0) { - /* found an entry with keyssid. */ - return entry; - } - } - - return NULL; -} - -/** - * Lookup an entry in a given routers_list, which matches with the given key ssid. - * - * @param llist linked list where each entry is looked up - * @param keyssid the key ssid which lookup each entry with - * @param token the token to be updated - * @return the rlist_entry if found, NULL otherwise - */ -pisasd_rlist_entry *pisasd_rlist_update_token(pisa_ll *llist, const char *keyssid, const char *token) -{ - pisa_ll_node *iter = NULL; - pisasd_rlist_entry *entry; - - while ((iter = pisa_ll_iterate(llist, iter)) != NULL) { - entry = (pisasd_rlist_entry *) iter->ptr; - if (strncasecmp(entry->ssid, keyssid, MAX_SSID) == 0) { - /* found an entry with keyssid. */ - PISA_STRNCPY(entry->token, token, sizeof(entry->token)); - return entry; - } - } - - return NULL; -} - -/** - * Lookup an entry in a given routers_list, which matches with the given key - * IP address. - * - * @param llist linked list where each entry is looked up - * @param keyipaddr the key ipaddr which lookup each entry with - * @return the rlist_entry if found, NULL otherwise - */ -pisasd_rlist_entry *pisasd_rlist_lookup_ipaddr(pisa_ll *llist, const char *keyipaddr) { - pisa_ll_node *iter = NULL; - pisasd_rlist_entry *entry; - char pbuffer[INET6_ADDRSTRLEN] = {0}; - - while ((iter = pisa_ll_iterate(llist, iter)) != NULL) { - entry = (pisasd_rlist_entry *) iter->ptr; - convert_common_ipaddr_to_string(pbuffer, &entry->ipaddr); - - if (strncasecmp(pbuffer, keyipaddr, MAX_SSID) == 0) { - /* found an entry with keyipaddr. */ - return entry; - } - } - - return NULL; -} - -/** - * Lookup an entry in a given routers_list, which matches with the given key - * IP address. - * - * @param llist linked list where each entry is looked up - * @param keytoken the key token which lookup each entry with - * @return the rlist_entry if found, NULL otherwise - */ -pisasd_rlist_entry *pisasd_rlist_lookup_token(pisa_ll *llist, const char *keytoken) { - pisa_ll_node *iter = NULL; - pisasd_rlist_entry *entry; - - while ((iter = pisa_ll_iterate(llist, iter)) != NULL) { - entry = (pisasd_rlist_entry *) iter->ptr; - if (strncasecmp((const char *)entry->token, keytoken, PISA_TOKEN_LENGTH) == 0) { - /* found an entry with keytoken. */ - return entry; - } - } - - return NULL; -} - -#endif /* REMOVE_PREAUTH_CODE */ Modified: trunk/pisasd/sdctx.h ============================================================================== --- trunk/pisasd/sdctx.h Wed Oct 21 12:55:01 2009 (r1249) +++ trunk/pisasd/sdctx.h Wed Oct 21 12:58:02 2009 (r1250) @@ -25,43 +25,18 @@ * current server daemon. */ typedef struct sd_context { -#ifdef REMOVE_PREAUTH_CODE - pisa_ll routers_queue; /* a priority queue of handover-ready routers */ - pisa_ll clients_list; /* a priority queue of handover-ready routers */ - - /** - * the current index where the next handover-ready router is to be accessed - */ - int rq_offset; -#endif /* REMOVE_PREAUTH_CODE */ - /** * Flag for the internal packet processing loop. * If it is set as 0, flow will exit from the main loop. */ int is_sd_running; -#ifdef REMOVE_PREAUTH_CODE - /** - * Flag whether to enable token verification procedure. - * If it is set as 1, do the token verification - */ - int do_tokvrfy; -#endif /* REMOVE_PREAUTH_CODE */ - /** * Flag if nd is running in background. * If it is set as 1, nd runs in background. */ int is_bgrun; -#ifdef REMOVE_PREAUTH_CODE - /** - * Flag if sending binding update response packet to my AP - */ - int is_sending_bures; -#endif /* REMOVE_PREAUTH_CODE */ - /** * Sockets for the tunnel device, the tunc and tund sockets */ @@ -74,36 +49,10 @@ */ int fd_pisaconf; -#ifdef REMOVE_PREAUTH_CODE - /** - * File descriptor of the pseudo tunnel client, through which verify - * request/response packets are exchanged with the pisa neighbor daemon. - */ - int fd_pstunc; - - /** - * File descriptor of the pseudo tunnel server, through which verify - * request/response packets are exchanged with the pisa neighbor daemon. - */ - int fd_pstuns; -#endif /* REMOVE_PREAUTH_CODE */ - /** * File descriptor for the pisa tunnel device */ char fd_pisa_tunnel_name[IFNAMSIZ]; -#ifdef REMOVE_PREAUTH_CODE - /** - * The current count value of verify request trigger tries. - */ - int vreqtrg_tries_count; - - /** - * The current count value of binding update tries. - */ - int bures_tries_count; -#endif /* REMOVE_PREAUTH_CODE */ - /** * Control handler functions. */ @@ -133,18 +82,6 @@ extern sd_context sd_ctx; -#ifdef REMOVE_PREAUTH_CODE -/** - * data structure defining a pair of core information about handover-ready - * target routers - */ -typedef struct { - char ssid[MAX_SSID+1]; /**< SSID obtained from peer neighbor */ - pisa_common_addr ipaddr; /**< IP address obtained from peer neighbor */ - char token[PISA_TOKEN_LENGTH+1]; /**< token obtained from peer neighbor */ -} pisasd_rlist_entry; -#endif /* REMOVE_PREAUTH_CODE */ - /** * Function prototypes */ @@ -156,17 +93,4 @@ void sdctx_destroy(sd_context *sdctx); int sdctx_get_neighbors(void); -#ifdef REMOVE_PREAUTH_CODE -void show_conf_cnblist(pisa_ll *llist); -void show_conf_rnblist(pisa_ll *llist); - -pisasd_rlist_entry *pisasd_rlist_lookup_ssid(pisa_ll *llist, const char *keyssid); -pisasd_rlist_entry *pisasd_rlist_lookup_ipaddr(pisa_ll *llist, const char *keyipaddr); -pisasd_rlist_entry *pisasd_rlist_lookup_token(pisa_ll *llist, const char *keytoken); -pisasd_rlist_entry *pisasd_rlist_update_token(pisa_ll *llist, const char *keyssid, const char *token); - -pisasd_rlist_entry *pisasd_cllist_add(char *ssid, pisa_common_addr *peer_addr, pisa_token token); -pisasd_rlist_entry *pisasd_cllist_lookup_token(pisa_ll *llist, const char *keytoken); -#endif /* REMOVE_PREAUTH_CODE */ - #endif /* PISA_SDCTX_H */ Modified: trunk/pisasd/sdmain.c ============================================================================== --- trunk/pisasd/sdmain.c Wed Oct 21 12:55:01 2009 (r1249) +++ trunk/pisasd/sdmain.c Wed Oct 21 12:58:02 2009 (r1250) @@ -49,11 +49,7 @@ # include "pisaperf.h" #endif -#ifdef REMOVE_PREAUTH_CODE -#define OPTS "f:i:p:q:r:a:Vbdvh" -#else #define OPTS "f:i:p:q:a:bdvh" -#endif /* REMOVE_PREAUTH_CODE */ /** * A set of options, including each long option and single-letter option @@ -64,9 +60,6 @@ {"interface", required_argument, NULL, 'i'}, {"ctrlport", required_argument, NULL, 'p'}, {"dataport", required_argument, NULL, 'q'}, -#ifdef REMOVE_PREAUTH_CODE - {"skipverify", no_argument, NULL, 'V'}, -#endif /* REMOVE_PREAUTH_CODE */ {"background", no_argument, NULL, 'b'}, {"debug", no_argument, NULL, 'd'}, {"version", no_argument, NULL, 'v'}, @@ -96,10 +89,6 @@ static void sd_print_version(void); static void sd_reload_confs(pisa_conf_packet *p); static void sd_quit(int quitcode); -#ifdef REMOVE_PREAUTH_CODE -static void sd_handle_sigalarm(int sigcode); -static void sd_start_alarm(void); -#endif /* REMOVE_PREAUTH_CODE */ static void sd_perf_init(void); static void sd_perf_destroy(void); @@ -139,9 +128,6 @@ signal(SIGILL, sd_quit); signal(SIGPIPE, SIG_IGN); signal(SIGBUS, sd_quit); -#ifdef REMOVE_PREAUTH_CODE - signal(SIGALRM, sd_handle_sigalarm); -#endif /* REMOVE_PREAUTH_CODE */ /* Check and create lockfile */ pisa_create_lock_file(PISASD_LOCK_FILE, 0); @@ -189,10 +175,6 @@ /* Make default sockets */ sd_ctx.tunc = pisa_tunnel_open_socket(sd_cfg.port_control); sd_ctx.tund = pisa_tunnel_open_socket(sd_cfg.port_data); -#ifdef REMOVE_PREAUTH_CODE - sd_ctx.fd_pstunc = setup_sock_udp(AF_INET6); - sd_ctx.fd_pstuns = setup_listen_sock_udp(AF_INET6, sd_cfg.port_pstun); -#endif /* REMOVE_PREAUTH_CODE */ sd_ctx.fd_pisaconf = pisa_conf_open_server_socket(PISA_CONF_PORT_SD); /* Enable NAT if this process is a relay server */ @@ -208,23 +190,6 @@ PISA_ERROR("Error opening logfile: " LOG_FILE "\n"); #endif -#ifdef REMOVE_PREAUTH_CODE - /* Get neighbor routers, at the moment just reading them from conf file. - * TODO: make some fancy way to determine neighbors... */ - sdctx_get_neighbors(); - - pisasd_packet_handle_func_set.handle_nereq = pisasd_handle_nereq; - pisasd_packet_handle_func_set.handle_neres = pisasd_handle_neres; - pisasd_packet_handle_func_set.handle_pareq = pisasd_handle_pareq; - pisasd_packet_handle_func_set.handle_pares = pisasd_handle_pares; - pisasd_packet_handle_func_set.handle_bureq = pisasd_handle_bureq; - pisasd_packet_handle_func_set.handle_bures = pisasd_handle_bures; - pisasd_packet_handle_func_set.handle_vrfyreq1 = pisasd_handle_vrfyreq1; - pisasd_packet_handle_func_set.handle_vrfyres1 = pisasd_handle_vrfyres1; - pisasd_packet_handle_func_set.handle_vrfyreq2 = pisasd_handle_vrfyreq2; - pisasd_packet_handle_func_set.handle_vrfyres2 = pisasd_handle_vrfyres2; -#endif /* REMOVE_PREAUTH_CODE */ - /* set handlers for tunnel control packet types */ pisa_ctrlhandler_set(&sd_ctx.ctrlhandlers, PISA_PKTTYPE_TUN_DATA, pisa_recv_data); pisa_ctrlhandler_set(&sd_ctx.ctrlhandlers, PISA_PKTTYPE_TUN_REGISTER, pisa_recv_register); @@ -237,11 +202,6 @@ conf_handle_func_set.debuglevel = pisa_conf_cb_debuglevel; conf_handle_func_set.debugmask = pisa_conf_cb_debugmask; -#ifdef REMOVE_PREAUTH_CODE - /* set the default alarm */ - sd_start_alarm(); -#endif - sd_ctx.conlist = pisa_conmgr_init(NULL); /* create the tunnel device and assign an IP address */ @@ -278,10 +238,6 @@ /* finish all the remaining jobs */ close(sd_ctx.tunc); close(sd_ctx.tund); -#ifdef REMOVE_PREAUTH_CODE - close(sd_ctx.fd_pstunc); - close(sd_ctx.fd_pstuns); -#endif /* REMOVE_PREAUTH_CODE */ close(sd_ctx.tunnel); close(sd_ctx.fd_pisaconf); @@ -337,27 +293,16 @@ FD_ZERO(&readfds); FD_SET(sd_ctx.tunc, &readfds); FD_SET(sd_ctx.tund, &readfds); -#ifdef REMOVE_PREAUTH_CODE - FD_SET(sd_ctx.fd_pstunc, &readfds); /* TODO: why is this here? it's not used below -- Thomas */ - FD_SET(sd_ctx.fd_pstuns, &readfds); -#endif /* REMOVE_PREAUTH_CODE */ FD_SET(sd_ctx.tunnel, &readfds); FD_SET(sd_ctx.fd_pisaconf, &readfds); FD_SET(sd_ctx.scheduler.pipe_main[0], &readfds); -#ifdef REMOVE_PREAUTH_CODE - maxfd = 1 + pisa_maxof(7, sd_ctx.tunc, sd_ctx.tund, - sd_ctx.fd_pstunc, sd_ctx.fd_pstuns, - sd_ctx.tunnel,sd_ctx.tunnel, - sd_ctx.scheduler.pipe_main[0]); -#else /* Performance optimization: Does this really have to be * recalcutated every time? Check again after PREAUTH is * removed. -- Thomas */ maxfd = 1 + pisa_maxof(5, sd_ctx.tunc, sd_ctx.tund, sd_ctx.tunnel,sd_ctx.tunnel, sd_ctx.scheduler.pipe_main[0]); -#endif /* REMOVE_PREAUTH_CODE */ if (select(maxfd + 1, &readfds, NULL, NULL, NULL) > 0) { if (FD_ISSET(sd_ctx.tunc, &readfds)) @@ -366,11 +311,6 @@ if (FD_ISSET(sd_ctx.tund, &readfds)) pisa_sd_copy_from_sock_to_tun(); -#ifdef REMOVE_PREAUTH_CODE - if (FD_ISSET(sd_ctx.fd_pstuns, &readfds)) - pisa_message_pstun(sd_ctx.fd_pstuns); -#endif /* REMOVE_PREAUTH_CODE */ - if (FD_ISSET(sd_ctx.tunnel, &readfds)) pisa_sd_copy_from_tun_to_sock(); @@ -380,10 +320,6 @@ if (FD_ISSET(sd_ctx.scheduler.pipe_main[0], &readfds)) pisa_handle_scheduler(); } - -#ifdef REMOVE_PREAUTH_CODE - sd_start_alarm(); -#endif /* REMOVE_PREAUTH_CODE */ } } @@ -421,16 +357,6 @@ sd_cfg.port_data = atoi(optarg); break; -#ifdef REMOVE_PREAUTH_CODE - case 'r': - sd_cfg.port_pstun = atoi(optarg); - break; - - case 'V': - sd_ctx.do_tokvrfy = FALSE; - break; -#endif /* REMOVE_PREAUTH_CODE */ - case 'b': sd_ctx.is_bgrun = TRUE; break; @@ -473,10 +399,6 @@ "\t-i|--interface <ifname> : Use the given name as the main ethernet interface.\n" "\t-p|--ctrlport <port> : Give a control port number to listen for incoming connections. (default: %d)\n" "\t-q|--dataport <port> : Give a data port number to listen for incoming connections. (default: %d)\n" -#ifdef REMOVE_PREAUTH_CODE - "\t-r|--pstunport <port> : Give a pseudo tunnel port number to listen for incoming connections. (default: %d)\n" - "\t-V|--skipverify : Skip token verification procedure\n" -#endif /* REMOVE_PREAUTH_CODE */ "\t-b|--background : Run in background\n" "\t-d|--debug : Enable Debug mode\n" "\t-v|--version : Print the version number\n" @@ -487,9 +409,6 @@ argv[0], PISASD_DEFAULT_PORTNUM_CONTROL, PISASD_DEFAULT_PORTNUM_DATA, -#ifdef REMOVE_PREAUTH_CODE - PISASD_DEFAULT_PORTNUM_PSTUN, -#endif /* REMOVE_PREAUTH_CODE */ argv[0]); exit(EXIT_FAILURE); @@ -589,48 +508,6 @@ sdconf_read_basic_confs(&sd_cfg); } -#ifdef REMOVE_PREAUTH_CODE -/** - * This handler is executed periodically by SIGALRM. - * - * @param sigcode signal code - */ -static void sd_handle_sigalarm(int sigcode) -{ - PISA_DEBUG(PL_TIMEOUT, "sd_handle_sigalarm is called. (%d)\n", sigcode); - - /* TODO: take also care of bures_maxretry */ - - if (sd_ctx.vreqtrg_tries_count > sd_cfg.vreqtrg_maxretry) { - PISA_INFO("WARNING: reached maximum client request count. Sleeping...\n"); -/* TODO: Rewrite/remove handover/preauth code. Disabled sleep for now. - * -- Thomas - sleep(5); - */ - PISA_INFO("Resetting tries count...\n"); - sd_ctx.vreqtrg_tries_count = 0; - } - - sd_ctx.vreqtrg_tries_count++; - - sd_ctx.is_sending_bures = TRUE; - - /* read basic configurations from pisasd.conf */ - sdconf_read_basic_confs(&sd_cfg); -} - -/** - * Setup alarm - */ -static void sd_start_alarm(void) -{ - alarm(sd_cfg.vreqtrg_timeout); - _PISA_DEBUG(PL_TIMEOUT, "Starting alarm with %d seconds.\n", sd_cfg.vreqtrg_timeout); - - /* TODO: take also care of bures_timeout */ -} -#endif /* PREAUTH */ - /** * Initialize performance measurement data structure */ @@ -657,4 +534,3 @@ pisa_perf_destroy(pisa_perf); #endif } - Modified: trunk/pisasd/sdtun.c ============================================================================== --- trunk/pisasd/sdtun.c Wed Oct 21 12:55:01 2009 (r1249) +++ trunk/pisasd/sdtun.c Wed Oct 21 12:58:02 2009 (r1250) @@ -26,19 +26,6 @@ # include "log.h" #endif -#ifdef CONFIG_PISA_PERFORMANCE -# include "pisaperf.h" -#endif - -#define DEFAULT_BUFF_SIZE 15000 - -#ifdef CONFIG_PISA_PERFORMANCE -static int pisasd_bench_tv_on = FALSE; -static void sd_perf_start_benchmark_tokvrfy(void); -static void sd_perf_stop_benchmark_tokvrfy(void); -static void sd_perf_write_benchmark_tokvrfy(void); -#endif - extern pisa_packet_handle_func_set pisasd_packet_handle_func_set; /** @@ -211,222 +198,3 @@ } } } - -#ifdef REMOVE_PREAUTH_CODE -/** - * main logic for an incoming message from an unassociated ipv6 address. - * if the address is in the list of known hits, the client will be added - * to our internal list... else, an UnkownHit Message will be send. - * consult the client/server communication graphics /tables for details. - * @sa processIncomingMessage - * @param buffer this points to the raw bytes of our incoming message - * @param clientIp the ip from where the incoming message originated. - */ -static void pisa_message_pstun_new_client(char* buffer, struct sockaddr_in6* clientIp) -{ - pisa_hitlist_entry *con; - pisa_conmgr_entry *entry; - pisa_packet *pkt = (pisa_packet *)buffer; - - con = pisa_hitlist_find(sd_cfg.hit_allowed, &clientIp->sin6_addr); - - if (!con) { - PISA_DEBUG(PL_PREAUTH, "Received a HIT that is not allowed:\n"); - dump_ipv6_addr(&clientIp->sin6_addr); - - pisa_send_control_packet_ipv6_type(sd_ctx.tunc, clientIp, PISA_PKTTYPE_TUN_UNKNOWN_HIT); - return; - } - - entry = pisa_conmgr_add_pstun(sd_ctx.conlist, clientIp); - - /* General non-tunnel PISA packets */ - sd_process_pisa_packets_pstun(entry, pkt, clientIp); -} - -/** - * main logic to processs an incoming packet from an ip, for which we have an - * association. - * @sa processIncomingMessage - * @param e our association structure - * @param buffer the raw bytes of our message - * @param len the amount of bytes used in our buffer - */ -static void pisa_message_pstun_known(pisa_conmgr_entry* e, char* buffer,size_t len) -{ - pisa_packet *pkt = (pisa_packet *)buffer; - struct sockaddr_in6 addr = {0}; - - /* General non-tunnel PISA packets */ - pisa_conmgr_build_sockaddr_data(e, &addr); - sd_process_pisa_packets_pstun(e, pkt, &addr); -} - -/** - * main logic for every message, arriving at our local socket. - */ -void pisa_message_pstun(int fd) -{ - char buffer[1024]={0}; - unsigned int addrlen=0; - ssize_t len=0; - - struct sockaddr_in6 from= { - 0 - }; - - addrlen = sizeof (from); - - if ((len=recvfrom (fd, buffer, sizeof (buffer), 0, (struct sockaddr *) &from, &addrlen))==-1) { - PISA_ERROR("server:main:recvfrom"); - return; - } - - if (!is_pisa_packet(buffer)) { - PISA_ERROR("The incoming packet is not from a valid PISA client daemon.\n"); - return; - } - - pisa_conmgr_entry *e=pisa_conmgr_findby_address_pstun(sd_ctx.conlist, &from.sin6_addr); - - if (e==NULL) { /* case 1: data from new client */ - pisa_message_pstun_new_client(buffer,&from); - } else { /* case 2: data from known client */ - time(&e->timeout_heartbeat); - pisa_message_pstun_known(e,buffer,len); - } -} - -/** - * main logic for an incoming message from an unassociated ipv6 address. - * if the address is in the list of known hits, the client will be added - * to our internal list... else, an UnkownHit Message will be send. - * consult the client/server communication graphics /tables for details. - * @sa processIncomingMessage - * @param buffer this points to the raw bytes of our incoming message - * @param clientIp the ip from where the incoming message originated. - */ -void sd_process_pisa_packets_tunc(pisa_packet *pkt, struct sockaddr_in6* clientIp) -{ - pisa_conmgr_entry *entry = NULL; - pisa_tlv_type pkttype = PISA_PKTTYPE_BU_UNKNOWN; - - pkttype = pisa_get_packet_type(pkt); - - PISA_DEBUG(PL_PREAUTH, "Packet type = %d\n", pisa_get_packet_type(pkt)); - - switch (pkttype) { - case PISA_PKTTYPE_BU_REQUEST: - entry = pisa_conmgr_add_pstun(sd_ctx.conlist, clientIp); -#ifdef CONFIG_PISA_PERFORMANCE - sd_perf_start_benchmark_tokvrfy(); -#endif - - pisasd_packet_handle_func_set.handle_bureq(entry, pkt); - break; - - case PISA_PKTTYPE_BU_RESPONSE: - entry = pisa_conmgr_add_pstun(sd_ctx.conlist, clientIp); - pisasd_packet_handle_func_set.handle_bures(entry, pkt); - break; - - case PISA_PKTTYPE_NE_UNKNOWN: - case PISA_PKTTYPE_PA_UNKNOWN: - case PISA_PKTTYPE_BU_UNKNOWN: - /* drop */ - PISA_ERROR("Cannot recognize type of the incoming pisasd packet.\n"); - break; - default: - /* TODO: For now, do nothing. - * But we need to find some way to deal with it. */ - break; - } -} - -/** - * main logic for an incoming message from an unassociated ipv6 address. - * if the address is in the list of known hits, the client will be added - * to our internal list... else, an UnkownHit Message will be send. - * consult the client/server communication graphics /tables for details. - * @sa processIncomingMessage - * @param buffer this points to the raw bytes of our incoming message - * @param clientIp the ip from where the incoming message originated. - */ -void sd_process_pisa_packets_pstun(pisa_conmgr_entry *entry, pisa_packet *pkt, struct sockaddr_in6* clientIp) -{ - pisa_tlv_type pkttype = PISA_PKTTYPE_BU_UNKNOWN; - - pkttype = pisa_get_packet_type(pkt); - - PISA_DEBUG(PL_PREAUTH, "Packet type = %d\n", pisa_get_packet_type(pkt)); - - switch (pkttype) { - case PISA_PKTTYPE_VRFY_REQUEST1: - pisasd_packet_handle_func_set.handle_vrfyreq1(entry, pkt); - break; - - case PISA_PKTTYPE_VRFY_RESPONSE1: - pisasd_packet_handle_func_set.handle_vrfyres1(entry, pkt); - break; - - case PISA_PKTTYPE_VRFY_REQUEST2: - pisasd_packet_handle_func_set.handle_vrfyreq2(entry, pkt); - break; - - case PISA_PKTTYPE_VRFY_RESPONSE2: -#ifdef CONFIG_PISA_PERFORMANCE - sd_perf_stop_benchmark_tokvrfy(); - sd_perf_write_benchmark_tokvrfy(); -#endif - - pisasd_packet_handle_func_set.handle_vrfyres2(entry, pkt); - break; - - case PISA_PKTTYPE_NE_UNKNOWN: - case PISA_PKTTYPE_PA_UNKNOWN: - case PISA_PKTTYPE_BU_UNKNOWN: - /* drop */ - PISA_ERROR("Cannot recognize type of the incoming pisasd packet.\n"); - break; - default: - break; - } -} - -#ifdef CONFIG_PISA_PERFORMANCE - -/** - * Start token verification benchmark - */ -static void sd_perf_start_benchmark_tokvrfy(void) -{ - if (!pisasd_bench_tv_on) { - PISA_DEBUG(PL_PREAUTH, "Starting PERF_TOKEN_VERIFICATION\n"); - pisa_perf_start_benchmark(pisa_perf, PERF_TOKEN_VERIFICATION); - - pisasd_bench_tv_on = TRUE; - } -} - -/** - * Stop token verification benchmark - */ -static void sd_perf_stop_benchmark_tokvrfy(void) -{ - PISA_DEBUG(PL_PREAUTH, "Stopping PERF_TOKEN_VERIFICATION\n"); - pisa_perf_stop_benchmark(pisa_perf, PERF_TOKEN_VERIFICATION); - - pisasd_bench_tv_on = FALSE; -} - -/** - * Write token verification benchmark results - */ -static void sd_perf_write_benchmark_tokvrfy(void) -{ - PISA_DEBUG(PL_PREAUTH, "Writing PERF_TOKEN_VERIFICATION\n"); - pisa_perf_write_benchmark(pisa_perf, PERF_TOKEN_VERIFICATION); -} - -#endif -#endif /* REMOVE_PREAUTH_CODE */