[pisa-src] r1252 - in trunk/pisacd: Makefile.am cdconf.c cdconf.h cdconmgr.c cdconmgr.h cdctx.c cdctx.h cdmain.c cdmsg.c cdmsg.h

  • From: Thomas Jansen <mithi@xxxxxxxxx>
  • To: pisa-src@xxxxxxxxxxxxx
  • Date: Wed, 21 Oct 2009 13:16:11 +0200

Author: tjansen
Date: Wed Oct 21 13:16:11 2009
New Revision: 1252

Log:
Removed deprecated preauth code from pisacd.

Deleted:
   trunk/pisacd/cdconmgr.c
   trunk/pisacd/cdconmgr.h
   trunk/pisacd/cdmsg.c
   trunk/pisacd/cdmsg.h
Modified:
   trunk/pisacd/Makefile.am
   trunk/pisacd/cdconf.c
   trunk/pisacd/cdconf.h
   trunk/pisacd/cdctx.c
   trunk/pisacd/cdctx.h
   trunk/pisacd/cdmain.c

Modified: trunk/pisacd/Makefile.am
==============================================================================
--- trunk/pisacd/Makefile.am    Wed Oct 21 13:00:37 2009        (r1251)
+++ trunk/pisacd/Makefile.am    Wed Oct 21 13:16:11 2009        (r1252)
@@ -21,10 +21,10 @@
   LDFLAGS += @PISA_PERFORMANCE_LIB_STATIC@
 endif
 
-pisacd_SOURCES = cdmain.c cdconf.c cdconmgr.c cdctx.c cdderegister.c \
-                cdheartbeat.c cdmsg.c cdpending.c cdregister.c cdservers.c \
+pisacd_SOURCES = cdmain.c cdconf.c cdctx.c cdderegister.c \
+                cdheartbeat.c cdpending.c cdregister.c cdservers.c \
                 cdtimeout.c cdtun.c pisacdconf.c cdconfhandlers.c
 pisacdconf_SOURCES = pisaconftool.c pisacdconf.c
-include_HEADERS = cdconf.h cdconfhandlers.h cdconmgr.h cdctx.h cdderegister.h \
-                 cdheartbeat.h cdmsg.h cdpending.h cdregister.h cdservers.h \
+include_HEADERS = cdconf.h cdconfhandlers.h cdctx.h cdderegister.h \
+                 cdheartbeat.h cdpending.h cdregister.h cdservers.h \
                  cdtimeout.h cdtun.h pisacdconf.h cdconfhandlers.h 

Modified: trunk/pisacd/cdconf.c
==============================================================================
--- trunk/pisacd/cdconf.c       Wed Oct 21 13:00:37 2009        (r1251)
+++ trunk/pisacd/cdconf.c       Wed Oct 21 13:16:11 2009        (r1252)
@@ -29,18 +29,8 @@
 /* prototypes of static functions */
 static void cdconf_read_debuglevel(cd_conf *cdconf);
 static void cdconf_read_debugtypemask(cd_conf *cdconf);
-#ifdef REMOVE_PREAUTH_CODE
-static void cdconf_read_ifname_wlan(cd_conf *cdconf);
-#endif /* REMOVE_PREAUTH_CODE */
 static void cdconf_read_port_control(cd_conf *cdconf);
 static void cdconf_read_port_data(cd_conf *cdconf);
-#ifdef REMOVE_PREAUTH_CODE
-static void cdconf_read_port_pasrv(cd_conf *cdconf);
-static void cdconf_read_pareq_interval(cd_conf *cdconf);
-static void cdconf_read_pareq_maxretry(cd_conf *cdconf);
-static void cdconf_read_bureq_timeout(cd_conf *cdconf);
-static void cdconf_read_bureq_maxretry(cd_conf *cdconf);
-#endif /* REMOVE_PREAUTH_CODE */
 static void cdconf_read_idle_disconnect_delay(cd_conf *cdconf);
 static void cdconf_read_local_ipv4(cd_conf *cdconf);
 static void cdconf_read_local_netmask(cd_conf *cdconf);
@@ -55,23 +45,11 @@
 {
        memset(cdconf->conffile, 0, sizeof(cdconf->conffile));
        memset(cdconf->debuglevel, 0, sizeof(cdconf->debuglevel));
-#ifdef REMOVE_PREAUTH_CODE
-       memset(cdconf->ifname_wlan, 0, sizeof(cdconf->ifname_wlan));
-#endif /* REMOVE_PREAUTH_CODE */
        memset(&cdconf->ipaddr, 0, sizeof(cdconf->ipaddr));
        memset(&cdconf->local_ipv4, 0, sizeof(cdconf->local_ipv4));
        memset(&cdconf->local_netmask, 0, sizeof(cdconf->local_netmask));
        cdconf->port_control = 0;
        cdconf->port_data = 0;
-#ifdef REMOVE_PREAUTH_CODE
-       cdconf->port_pasrv = 0;
-       cdconf->heartbeat_timeout = PISACD_DEFAULT_HEARTBEAT_TIMEOUT;
-       cdconf->heartbeat_maxretry = PISACD_DEFAULT_HEARTBEAT_MAXRETRY;
-       cdconf->pareq_interval = PISACD_DEFAULT_PAREQ_INTERVAL;
-       cdconf->pareq_maxretry = PISACD_DEFAULT_PAREQ_MAXRETRY;
-       cdconf->bureq_timeout = PISACD_DEFAULT_BUREQ_TIMEOUT;
-       cdconf->bureq_maxretry = PISACD_DEFAULT_BUREQ_MAXRETRY;
-#endif /* REMOVE_PREAUTH_CODE */
        cdconf->idle_disconnect_delay = PISACD_DEFAULT_IDLE_DISCONNECT_DELAY;
 }
 
@@ -114,20 +92,8 @@
        /* Read several configuration from pisacd.conf. */
        cdconf_read_debuglevel(cdconf);
        cdconf_read_debugtypemask(cdconf);
-#ifdef REMOVE_PREAUTH_CODE
-       cdconf_read_ifname_wlan(cdconf);
-#endif /* REMOVE_PREAUTH_CODE */
        cdconf_read_port_control(cdconf);
        cdconf_read_port_data(cdconf);
-#ifdef REMOVE_PREAUTH_CODE
-       cdconf_read_port_pasrv(cdconf);
-/*        cdconf_read_heartbeat_timeout(cdconf);*/
-/*        cdconf_read_heartbeat_maxretry(cdconf);*/
-       cdconf_read_pareq_interval(cdconf);
-       cdconf_read_pareq_maxretry(cdconf);
-       cdconf_read_bureq_timeout(cdconf);
-       cdconf_read_bureq_maxretry(cdconf);
-#endif /* REMOVE_PREAUTH_CODE */
        cdconf_read_idle_disconnect_delay(cdconf);
        cdconf_read_local_ipv4(cdconf);
        cdconf_read_local_netmask(cdconf);
@@ -162,24 +128,6 @@
        pisa_debug_set_type_mask((unsigned long)mask);
 }
 
-#ifdef REMOVE_PREAUTH_CODE
-/**
- * Read the wireless interface name from the configuration file.
- *
- * @param cdconf  cd_conf structure where conf settings are stored
- */
-static void cdconf_read_ifname_wlan(cd_conf *cdconf)
-{
-       /* Determine the appropriate interface name for listening connections */
-       if (*cdconf->ifname_wlan == '\0') {
-               if (!pisa_cfg_get_string_value("interface_wlan", 
cdconf->ifname_wlan, sizeof(cdconf->ifname_wlan))) {
-                       PISA_DEBUG(PL_CONFIG, "Using the default wireless 
interface name %s\n", PISACD_DEFAULT_IFNAME);
-                       PISA_STRNCPY(cdconf->ifname_wlan, 
PISACD_DEFAULT_IFNAME, sizeof(cdconf->ifname_wlan));
-               }
-       }
-}
-#endif /* REMOVE_PREAUTH_CODE */
-
 /**
  * Read the listening control port number from the configuration file.
  *
@@ -222,93 +170,6 @@
        }
 }
 
-#ifdef REMOVE_PREAUTH_CODE
-/**
- * Read the listening port number pasrv from the configuration file.
- *
- * @param cdconf  cd_conf structure where conf settings are stored
- */
-static void cdconf_read_port_pasrv(cd_conf *cdconf)
-{
-       /* Determine the appropriate port number for listening connections */
-       if (cdconf->port_pasrv > 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 (cdconf->port_pasrv == 0) {
-               if (!pisa_cfg_get_int_value("port_pasrv", &cdconf->port_pasrv)) 
{
-                       PISA_DEBUG(PL_CONFIG, "Using the default pasrv port 
number %d\n", PISACD_DEFAULT_PORTNUM_DATA);
-                       cdconf->port_pasrv = PISACD_DEFAULT_PORTNUM_DATA;
-               }
-       }
-}
-#endif /* REMOVE_PREAUTH_CODE */
-
-#ifdef REMOVE_PREAUTH_CODE
-/**
- * Read the pre-authentication request interval from the configuration file.
- *
- * @param cdconf  cd_conf structure where conf settings are stored
- */
-static void cdconf_read_pareq_interval(cd_conf *cdconf)
-{
-       /* Read config value of pre-authentication request interval */
-       if (!pisa_cfg_get_int_value("preauth_request_interval", 
&cdconf->pareq_interval)) {
-               PISA_DEBUG(PL_CONFIG, "Using the default pareq interval %d\n",
-                          PISACD_DEFAULT_PAREQ_INTERVAL);
-               cdconf->pareq_interval = PISACD_DEFAULT_PAREQ_INTERVAL;
-       }
-}
-
-/**
- * Read the max trial count of pre-authentication request from the
- * configuration file.
- *
- * @param cdconf  cd_conf structure where conf settings are stored
- */
-static void cdconf_read_pareq_maxretry(cd_conf *cdconf)
-{
-       /* Read config value of pre-authentication request maxretry */
-       if (!pisa_cfg_get_int_value("preauth_request_maxretry", 
&cdconf->pareq_maxretry)) {
-               PISA_DEBUG(PL_CONFIG, "Using the default preauth req maxretry 
%d\n",
-                          PISACD_DEFAULT_PAREQ_MAXRETRY);
-               cdconf->pareq_maxretry = PISACD_DEFAULT_PAREQ_MAXRETRY;
-       }
-}
-
-/**
- * Read the binding update request timeout from the configuration file.
- *
- * @param cdconf  cd_conf structure where conf settings are stored
- */
-static void cdconf_read_bureq_timeout(cd_conf *cdconf)
-{
-       /* Read config value of binding update request timeout */
-       if (!pisa_cfg_get_int_value("binding_update_request_timeout", 
&cdconf->bureq_timeout)) {
-               PISA_DEBUG(PL_CONFIG, "Using the default bureq timeout %d\n",
-                          PISACD_DEFAULT_BUREQ_TIMEOUT);
-               cdconf->bureq_timeout = PISACD_DEFAULT_BUREQ_TIMEOUT;
-       }
-}
-
-/**
- * Read the max trial count of binding update request from the
- * configuration file.
- *
- * @param cdconf  cd_conf structure where conf settings are stored
- */
-static void cdconf_read_bureq_maxretry(cd_conf *cdconf)
-{
-       /* Read config value of binding update request maxretry */
-       if (!pisa_cfg_get_int_value("binding_update_request_maxretry", 
&cdconf->bureq_maxretry)) {
-               PISA_DEBUG(PL_CONFIG, "Using the default bupdate req maxretry 
%d\n",
-                          PISACD_DEFAULT_BUREQ_MAXRETRY);
-               cdconf->bureq_maxretry = PISACD_DEFAULT_BUREQ_MAXRETRY;
-       }
-}
-#endif /* REMOVE_PREAUTH_CODE */
-
 /**
  * Read the delay before idle connections are deregistered from the
  * configuration file.
@@ -362,57 +223,6 @@
        }
 }
 
-#ifdef REMOVE_PREAUTH_CODE
-/**
- * Set several wlan info based on the interface name in the configuration file.
- *
- * @param cdconf  cd_conf structure where conf settings are stored
- */
-void cdconf_set_wlaninfos(cd_conf *cdconf)
-{
-       char    *essid = NULL;
-       struct in_addr myaddr;
-       pisacd_rlist_entry      *rentry;
-
-       if (pisa_check_ifname(cdconf->ifname_wlan) < 0) {
-               /* If ifname is not configured yet */
-               cdctx_clear_ssid(&cd_ctx);
-               cdctx_clear_apmacaddr(&cd_ctx);
-               memset(&cdconf->ipaddr, 0, sizeof(cdconf->ipaddr));
-
-               return;
-       }
-
-       /* Now ifname is correctly configured */
-
-       /* Get my SSID, which means the SSID of the current AP */
-       essid = pisa_get_essid(cdconf->ifname_wlan);
-       if (essid && *essid) {
-               cdctx_set_ssid(&cd_ctx, essid);
-
-               rentry = pisacd_rlist_lookup_ssid(&cd_ctx.ready_queue, essid);
-
-               if (rentry) {
-                       cdctx_set_apmacaddr(&cd_ctx, rentry->macaddr);
-
-                       cdctx_set_ipaddr(&cd_ctx, &rentry->ipaddr);
-                       _PISA_DEBUG(PL_CONFIG, "my_ap.ipaddr = %s\n", 
inet_ntoa(rentry->ipaddr.sa.sa4));
-               }
-       } else {
-               cdctx_clear_ssid(&cd_ctx);
-               cdctx_clear_apmacaddr(&cd_ctx);
-               cdctx_clear_ipaddr(&cd_ctx);
-       }
-
-       _PISA_DEBUG(PL_CONFIG, "my_ap.ssid = %s\n", cd_ctx.my_ap.ssid);
-       _PISA_DEBUG(PL_CONFIG, "my_ap.macaddr = %s\n", cd_ctx.my_ap.macaddr);
-
-       /* Get my IP address */
-       myaddr.s_addr = pisa_get_ifaddr(cdconf->ifname_wlan);
-       pisa_ipv4_copy(&cdconf->ipaddr, &myaddr);
-}
-#endif /* REMOVE_PREAUTH_CODE */
-
 /**
  * Set the global debug level variable
  *
@@ -437,231 +247,3 @@
                fprintf(stderr, "WARNING: Cannot set log level as debugging\n");
        }
 }
-
-#ifdef REMOVE_PREAUTH_CODE
-/**
- * Get the configuration of bootstrap neighbor list from pisacd.conf
- *
- * @param cb_bcn  callback to add a pair of SSID and channel number of 
bootstrap
- *                candidate neighbors
- * @param cb_brn  callback to add a pair of SSID, IP addr and token of 
bootstrap
- *                handover-ready neighbors
- * @return value length if successful, 0 if failure
- */
-int cd_config_get_bootstrap_neighbors(extractCDCnbCallback cb_bcn, 
extractCDRnbCallback cb_brn)
-{
-       config_setting_t *conf_list_bcn = NULL, *conf_list_brn = NULL;
-       int i = 0, len = 0;
-       int channel = 0;
-       uint8_t quality = 0;
-       config_setting_t *group_elem = NULL;
-
-       config_setting_t *ssid = NULL;
-       config_setting_t *macaddr = NULL;
-       config_setting_t *ipaddr = NULL;
-       config_setting_t *token = NULL;
-
-       config_setting_t *channel_setting = NULL;
-       config_setting_t *quality_setting = NULL;
-
-
-       /* The first part for bootstrap_cands_neighbors */
-
-       conf_list_bcn = config_lookup(&cfg, "bootstrap_cands_neighbors");
-
-       if (!conf_list_bcn) {
-               PISA_ERROR("Cannot find bootstrap_cands_neighbors in the config 
file!\n");
-               return 0;
-       }
-
-       len = config_setting_length(conf_list_bcn);
-
-       for (i=0;i<len;i++) {
-               const char* ssid_text = "";
-               const char* macaddr_text = "";
-
-               group_elem = config_setting_get_elem(conf_list_bcn, 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);
-
-               macaddr = config_setting_get_member(group_elem, "macaddr");
-
-               if (!macaddr) {
-                       PISA_ERROR("Error while processing config file: found 
no macaddr in group!\n");
-               }
-
-               macaddr_text = config_setting_get_string(macaddr);
-
-               channel_setting = config_setting_get_member(group_elem, 
"channel");
-               if (channel_setting) {
-                       channel = config_setting_get_int(channel_setting);
-               }
-
-               quality_setting = config_setting_get_member(group_elem, 
"quality");
-               if (quality_setting) {
-                       quality = config_setting_get_int(quality_setting);
-               }
-
-               if (ssid_text != NULL && strlen(ssid_text) > 0) {
-                       cb_bcn(ssid_text, macaddr_text, channel, quality);
-               }
-               else
-                       PISA_ERROR("Warning while processing config file: found 
empty channel-string.\n");
-       }
-
-
-       /* The second part for bootstrap_ready_neighbors */
-
-       conf_list_brn = config_lookup(&cfg, "bootstrap_ready_neighbors");
-
-       if (!conf_list_brn) {
-               PISA_ERROR("Cannot find bootstrap_ready_neighbors in the config 
file!\n");
-               return 0;
-       }
-
-       len = config_setting_length(conf_list_brn);
-
-       for (i=0;i<len;i++) {
-               const char* ssid_text = "";
-               const char* macaddr_text = "";
-               const char* ipaddr_text = "";
-               const char* token_text = "";
-
-               group_elem = config_setting_get_elem(conf_list_brn, 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);
-
-               macaddr = config_setting_get_member(group_elem, "macaddr");
-
-               if (!macaddr) {
-                       PISA_ERROR("Error while processing config file: found 
no macaddr in group!\n");
-               }
-
-               macaddr_text = config_setting_get_string(macaddr);
-
-               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_brn(ssid_text, macaddr_text, ipaddr_text, 
token_text);
-               }
-               else
-                       PISA_ERROR("Warning while processing config file: found 
empty ipaddr-string.\n");
-       }
-
-       return len;
-}
-
-/**
- * Get the configuration of default AP list from pisacd.conf
- *
- * @param cb_dap  callback to add default access point infos
- * @return value length if successful, 0 if failure
- */
-int cd_config_get_default_ap(extractCDDAPCallback cb_dap)
-{
-       config_setting_t *conf_list_dap = NULL;
-       int i = 0, len = 0;
-       config_setting_t *group_elem = NULL;
-
-       config_setting_t *ssid = NULL;
-       config_setting_t *macaddr = NULL;
-       config_setting_t *ipaddr = NULL;
-       config_setting_t *ndport_setting = NULL;
-
-
-       conf_list_dap = config_lookup(&cfg, "default_ap");
-
-       if (!conf_list_dap) {
-               PISA_ERROR("Cannot find bootstrap_cands_neighbors in the config 
file!\n");
-               return 0;
-       }
-
-       len = config_setting_length(conf_list_dap);
-
-       for (i=0;i<len;i++) {
-               const char* ssid_text = "";
-               const char* macaddr_text = "";
-               const char* ipaddr_text = "";
-               uint16_t ndport = 0;
-
-               group_elem = config_setting_get_elem(conf_list_dap, 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);
-
-               macaddr = config_setting_get_member(group_elem, "macaddr");
-
-               if (!macaddr) {
-                       PISA_ERROR("Error while processing config file: found 
no macaddr in group!\n");
-               }
-
-               macaddr_text = config_setting_get_string(macaddr);
-
-               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);
-
-               ndport_setting = config_setting_get_member(group_elem, 
"ndport");
-               if (ndport_setting) {
-                       ndport = config_setting_get_int(ndport_setting);
-               }
-
-               if (ssid_text != NULL && strlen(ssid_text) > 0) {
-                       cb_dap(ssid_text, macaddr_text, ipaddr_text, ndport);
-               }
-               else
-                       PISA_ERROR("Warning while processing config file: found 
empty ipaddr-string.\n");
-       }
-
-       return len;
-}
-#endif /* REMOVE_PREAUTH_CODE */

Modified: trunk/pisacd/cdconf.h
==============================================================================
--- trunk/pisacd/cdconf.h       Wed Oct 21 13:00:37 2009        (r1251)
+++ trunk/pisacd/cdconf.h       Wed Oct 21 13:16:11 2009        (r1252)
@@ -22,21 +22,9 @@
 typedef struct {
        char conffile[MAX_PATH+1]; /**< configuration file */
        char debuglevel[MAX_DEBUGLEVEL_STR+1];  /**< debug level */
-#ifdef REMOVE_PREAUTH_CODE
-       char ifname_wlan[MAX_IFNAME+1]; /**< main wireless interface name of 
this client. */
-#endif /* REMOVE_PREAUTH_CODE */
        struct in_addr ipaddr; /**< IPv4 address of this client */
        int port_control;       /**< control port number to listen to */
        int port_data;          /**< data port number to listen to */
-#ifdef REMOVE_PREAUTH_CODE
-       int port_pasrv;         /**< port to listen to pre-auth responses */
-       int heartbeat_timeout;  /**< timeout when sending heartbeat packets */
-       int heartbeat_maxretry; /**< max retry time when sending heartbeat 
packets */
-       int pareq_interval;     /**< interval when sending pareq packets */
-       int pareq_maxretry;     /**< max retry time when sending pareq packets 
*/
-       int bureq_timeout;      /**< timeout when sending bureq packets */
-       int bureq_maxretry;     /**< max retry time when sending bureq packets 
*/
-#endif /* REMOVE_PREAUTH_CODE */
        int idle_disconnect_delay; /**< number of seconds to wait before idle 
connections are deregistered */
        struct in_addr local_ipv4;
        struct in_addr local_netmask;
@@ -57,41 +45,5 @@
 
 void cdconf_read_basic_confs(cd_conf *cdconf);
 void cdconf_setup_conffile(cd_conf *cdconf);
-#ifdef REMOVE_PREAUTH_CODE
-void cdconf_set_wlaninfos(cd_conf *cdconf);
-
-/**
- * CNB Callback for CD
- * Will be called for every CD configuration in the config file
- * @param ssid      SSID in string representation
- * @param macaddr   MAC address in string representation
- * @param channel   channel number in integer representation
- * @param quality   quality value of signal to the access point, from 0 to 100
- */
-typedef void (*extractCDCnbCallback)(const char *ssid, const char *macaddr, 
const int channel, const uint8_t quality);
-
-/**
- * RNB Callback for CD
- * Will be called for every CD configuration in the config file
- * @param ssid      SSID in string representation
- * @param macaddr   MAC address in string representation
- * @param ipadr     IP address in string representation
- * @param token     Token in string representation
- */
-typedef void (*extractCDRnbCallback)(const char *ssid, const char *macaddr, 
const char *ipaddr, const char *token);
-
-/**
- * DAP Callback for CD
- * Will be called for every CD configuration in the config file
- * @param ssid      SSID in string representation
- * @param macaddr   MAC address in string representation
- * @param ipadr     IP address in string representation
- * @param ndport  the target port number on the AP where neighbor daemon 
listens
- */
-typedef void (*extractCDDAPCallback)(const char *ssid, const char *macaddr, 
const char *ipaddr, uint16_t ndport);
-
-int cd_config_get_bootstrap_neighbors(extractCDCnbCallback cb_bcn, 
extractCDRnbCallback cb_brn);
-int cd_config_get_default_ap(extractCDDAPCallback cb_dap);
-#endif /* REMOVE_PREAUTH_CODE */
 
 #endif /* PISA_CDCONF_H */

Modified: trunk/pisacd/cdctx.c
==============================================================================
--- trunk/pisacd/cdctx.c        Wed Oct 21 13:00:37 2009        (r1251)
+++ trunk/pisacd/cdctx.c        Wed Oct 21 13:16:11 2009        (r1252)
@@ -21,24 +21,6 @@
  */
 cd_context cd_ctx;
 
-#ifdef REMOVE_PREAUTH_CODE
-static void add_conf_to_cnblist(const char* ssid, const char *macaddr, const 
int channel, const uint8_t quality);
-static void add_conf_to_rnblist(const char* ssid, const char *macaddr, const 
char *ipaddr, const char *token);
-static void add_conf_to_dapinfo(const char* ssid, const char *macaddr, const 
char *ipaddr, const uint16_t ndport);
-
-static int calc_node_priority(const uint8_t quality);
-static inline int is_ap_in_blacklist(const char *ssid);
-
-/**
- * A set of ssid strings to be blacklisted.
- */
-static const char *ssid_blacklist[] = {
-       "eduroam",
-       "eduroam-WPAonly",
-       "mops"
-};
-#endif /* REMOVE_PREAUTH_CODE */
-
 /**
  * Initialize general context of client daemon.
  *
@@ -47,34 +29,11 @@
  */
 void cdctx_init(cd_context *cdctx)
 {
-#ifdef REMOVE_PREAUTH_CODE
-       pisa_ll_init(&cdctx->cands_queue);
-       pisa_ll_init(&cdctx->ready_queue);
-       pisa_ll_init(&cdctx->bulist);
-
-       memset(&cdctx->my_ap, 0, sizeof(cdctx->my_ap));
-
-       cdctx->cq_offset = 0;
-       cdctx->rq_offset = 0;
-#endif /* REMOVE_PREAUTH_CODE */
-
        cdctx->is_cd_running = FALSE;
        cdctx->is_bgrun = FALSE;
-#ifdef REMOVE_PREAUTH_CODE
-       cdctx->is_scanning = FALSE;
-       cdctx->is_sending_pareq = FALSE;
-       cdctx->is_sending_bureq = FALSE;
-#endif /* REMOVE_PREAUTH_CODE */
        cdctx->tunnel = -1;
        cdctx->tunc = -1;
        cdctx->tund = -1;
-#ifdef REMOVE_PREAUTH_CODE
-       cdctx->fd_pacli = -1;
-       cdctx->fd_pasrv = -1;
-
-       cdctx->pareq_tries_count = 0;
-       cdctx->bureq_tries_count = 0;
-#endif /* REMOVE_PREAUTH_CODE */
 
        cdctx->ctrlhandlers = NULL;
        cdctx->natlist = NULL;
@@ -91,564 +50,4 @@
  */
 void cdctx_destroy(cd_context *cdctx)
 {
-#ifdef REMOVE_PREAUTH_CODE
-       pisa_ll_uninit(&cdctx->cands_queue, pisa_free);
-       pisa_ll_uninit(&cdctx->ready_queue, pisa_free);
-       pisa_ll_uninit(&cdctx->bulist, pisa_free);
-#endif /* REMOVE_PREAUTH_CODE */
-}
-
-#ifdef REMOVE_PREAUTH_CODE
-/**
- * Get a list of clients.
- *
- * @return 0 if normal, <0 otherwise.
- */
-int cdctx_get_neighbors(void)
-{
-       /* NOTE: at this point, we assume that we already have a list of
-        * candidate routers in cands_queue. For that, we simply read the list
-        * from a local file.
-        */
-
-       /* from the conf file to cd_ctx.cands_queue */
-       cd_config_get_bootstrap_neighbors(add_conf_to_cnblist, 
add_conf_to_rnblist);
-
-       PISA_DEBUG(PL_PREAUTH, "\nDisplaying the candidates routers 
queue...\n");
-       show_conf_cnblist(&cd_ctx.cands_queue);
-
-       PISA_DEBUG(PL_PREAUTH, "\nDisplaying the handover-ready routers 
queue...\n");
-       show_conf_rnblist(&cd_ctx.ready_queue);
-
-       PISA_DEBUG(PL_PREAUTH, "\n");
-
-       return 0;
-}
-
-/**
- * Get default access point information
- *
- * @return 0 if normal, <0 otherwise.
- */
-void cdctx_get_default_ap(void)
-{
-       struct sockaddr_in sin_defgw;
-       char macaddr[MAX_MACADDR];
-
-       /* 1. If my_ap is already obtained previously, just use it. */
-
-       /* 2. If that cannot be determined, get the default gateway
-        *    from the routing table. */
-       if (cd_ctx.my_ap.ipaddr.s_addr == 0) {
-               if (pisa_get_default_gateway(&sin_defgw) >= 0)
-                       pisa_ipv4_copy(&cd_ctx.my_ap.ipaddr, 
&sin_defgw.sin_addr);
-       }
-
-       /* 3. Obtain MAC address of access point. */
-       if (pisa_get_macaddr(macaddr, cd_cfg.ifname_wlan)) {
-               PISA_STRNCPY(cd_ctx.my_ap.macaddr, macaddr, MAX_MACADDR);
-       }
-
-       /* 4. If it still has not been obtained, use the default one from conf 
file. */
-       if (cd_ctx.my_ap.ipaddr.s_addr == 0) {
-               cd_config_get_default_ap(add_conf_to_dapinfo);
-       }
-
-       if (cd_ctx.my_ap.ndport == 0) {
-               cd_ctx.my_ap.ndport = PISAND_DEFAULT_PORTNUM_NESRV;
-       }
-}
-
-/**
- * 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 macaddr MAC address of the access point
- * @param channel channel number where the neighbor can be scanned
- * @param quality quality value of signal to the access point, from 0 to 100
- * @return none
- */
-static void add_conf_to_cnblist(const char* ssid, const char *macaddr, const 
int channel, const uint8_t quality)
-{
-       pisacd_clist_entry *nnodedata_cq;
-
-       nnodedata_cq = (pisacd_clist_entry *) 
PISA_MALLOC(sizeof(pisacd_clist_entry));
-
-       memset(nnodedata_cq, 0, sizeof(pisacd_clist_entry));
-
-       /* 3 entries for the candidiate queue: ssid, macaddr and channel */
-       PISA_STRNCPY(nnodedata_cq->ssid, ssid, sizeof(nnodedata_cq->ssid));
-       PISA_STRNCPY(nnodedata_cq->macaddr, macaddr, 
sizeof(nnodedata_cq->macaddr));
-
-       nnodedata_cq->channel = channel;
-       nnodedata_cq->quality = quality;
-
-       pisa_ll_add(&cd_ctx.cands_queue, 0, nnodedata_cq);
-
-       return;
-}
-
-/**
- * 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 macaddr MAC address of the access point
- * @param ipaddr  IP address of the access point
- * @param token   Token of the access point
- * @return none
- */
-static void add_conf_to_rnblist(const char* ssid, const char *macaddr, const 
char *ipaddr, const char *token)
-{
-       pisacd_rlist_entry *nnodedata_rq;
-
-       nnodedata_rq = (pisacd_rlist_entry *) 
PISA_MALLOC(sizeof(pisacd_rlist_entry));
-
-       memset(nnodedata_rq, 0, sizeof(pisacd_rlist_entry));
-
-       /* 3 entries for the ready queue: ssid, ipaddr and token */
-       PISA_STRNCPY(nnodedata_rq->ssid, ssid, sizeof(nnodedata_rq->ssid));
-       PISA_STRNCPY(nnodedata_rq->macaddr, macaddr, 
sizeof(nnodedata_rq->macaddr));
-       convert_string_to_common_ipaddr(&nnodedata_rq->ipaddr, ipaddr);
-
-       PISA_STRNCPY(nnodedata_rq->token, token, sizeof(nnodedata_rq->token));
-
-       pisacd_rlist_add_sorted(&cd_ctx.ready_queue, nnodedata_rq);
-
-       return;
-}
-
-/**
- * Add test entries to the default AP info.
- * A callback for the cd_config_get_default_ap()
- *
- * @param ssid    ssid of access point which will be added to the client list
- * @param macaddr MAC address of the access point
- * @param ipaddr  IP address which will be added to the default AP info 
- * @param ndport  the target port number on the AP where neighbor daemon 
listens
- * @return none
- */
-static void add_conf_to_dapinfo(const char* ssid, const char *macaddr, const 
char *ipaddr, const uint16_t ndport)
-{
-       PISA_DEBUG(PL_PREAUTH, "In cd_ctx:\n");
-
-       /* 3 entries for the candidiate queue: ssid, macaddr and ipaddr */
-       if (ssid && *ssid) {
-               PISA_STRNCPY(cd_ctx.my_ap.ssid, ssid, 
sizeof(cd_ctx.my_ap.ssid));
-               PISA_DEBUG(PL_PREAUTH, "ssid = %s\n", cd_ctx.my_ap.ssid);
-       }
-
-       if (macaddr && *macaddr) {
-               PISA_STRNCPY(cd_ctx.my_ap.macaddr, macaddr, 
sizeof(cd_ctx.my_ap.macaddr));
-               PISA_DEBUG(PL_PREAUTH, "macaddr = %s\n", cd_ctx.my_ap.macaddr);
-       }
-
-       if (ipaddr && *ipaddr) {
-               inet_pton(AF_INET, ipaddr, &cd_ctx.my_ap.ipaddr);
-
-               PISA_DEBUG(PL_PREAUTH, "ipaddr = %s\n", ipaddr);
-       }
-
-       if (ndport > 0) {
-               cd_ctx.my_ap.ndport = ndport;
-       }
-       else {
-               cd_ctx.my_ap.ndport = PISAND_DEFAULT_PORTNUM_NESRV;
-       }
-
-       return;
-}
-
-/**
- * Show all entries in the candidate clients list
- *
- * @param llist  the linked list to be displayed
- * @return none
- */
-void show_conf_cnblist(pisa_ll *llist)
-{
-       pisa_ll_node *iter = NULL;
-       pisacd_clist_entry *entry;
-
-       while ((iter = pisa_ll_iterate(llist, iter)) != NULL) {
-               entry = (pisacd_clist_entry *)iter->ptr;
-               PISA_DEBUG(PL_PREAUTH, "ENTRY: SSID = %s\n", entry->ssid);
-               PISA_DEBUG(PL_PREAUTH, "ENTRY: macaddr = %s\n", entry->macaddr);
-               PISA_DEBUG(PL_PREAUTH, "ENTRY: channel = %d\n", entry->channel);
-               PISA_DEBUG(PL_PREAUTH, "ENTRY: quality = %d\n", entry->quality);
-       }
-
-       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;
-       pisacd_rlist_entry *entry;
-       char pbuffer[INET6_ADDRSTRLEN]={0};
-
-       while ((iter = pisa_ll_iterate(llist, iter)) != NULL) {
-               entry = (pisacd_rlist_entry *)iter->ptr;
-               PISA_DEBUG(PL_PREAUTH, "ENTRY: SSID = %s\n", entry->ssid);
-               PISA_DEBUG(PL_PREAUTH, "ENTRY: macaddr = %s\n", entry->macaddr);
-
-               convert_common_ipaddr_to_string(pbuffer, &entry->ipaddr);
-               PISA_DEBUG(PL_PREAUTH, "ENTRY: IP address = %s\n", pbuffer);
-
-               PISA_DEBUG(PL_PREAUTH, "ENTRY: token = %s\n", entry->token);
-               PISA_DEBUG(PL_PREAUTH, "ENTRY: priority = %d\n", 
iter->priority);
-       }
-
-       return;
-}
-
-/**
- * Trigger scanning process to get a list of actual neighbor candidates.
- */
-void cd_trigger_scanning(void)
-{
-       pisa_ll iwreslist;
-       pisa_ll_node *iter = NULL;
-       pisacd_clist_entry *tmpentry, *centry;
-       pisacd_rlist_entry *rentry;
-       iwlist_result *iwres;
-
-       pisa_ll_init(&iwreslist);
-
-       /* start a scanning job to get candidate access points. */
-       pisa_get_iwlist(&iwreslist, cd_cfg.ifname_wlan);
-
-       /* If a scanned neighbor already exists in cands_queue, just update
-        * the existing channel with the new one.
-        * If it doesn't exist, make a new entry and add it to cands_queue.
-        */
-       while ((iter = pisa_ll_iterate(&iwreslist, iter)) != NULL) {
-               iwres = (iwlist_result *)iter->ptr;
-
-               /* Skip adding to lists if the router is in our blacklist.
-                * e.g. eduroam or mops, as they are not for PISA currently. */
-               if (is_ap_in_blacklist(iwres->essid)) {
-                       continue;
-               }
-
-               tmpentry = pisacd_clist_update_chssid(&cd_ctx.cands_queue, 
(const char *)iwres->essid, (const int)iwres->channel, (const int)iwres->qual);
-               if (!tmpentry) {
-                       centry = (pisacd_clist_entry *) 
PISA_MALLOC(sizeof(pisacd_clist_entry));
-
-                       PISA_STRNCPY(centry->ssid, (const char *)iwres->essid, 
sizeof(centry->ssid));
-
-                       PISA_STRNCPY(centry->macaddr, (const char 
*)iwres->apaddr, sizeof(centry->macaddr));
-
-                       centry->channel = iwres->channel;
-                       centry->quality = iwres->qual;
-
-                       /* add a new entry */
-                       pisa_ll_add_last(&cd_ctx.cands_queue, centry);
-               }
-
-               rentry = pisacd_rlist_update_priority(&cd_ctx.ready_queue, 
iwres->essid, calc_node_priority(iwres->qual));
-               if (!rentry) {
-                       /* add also an rentry */
-                       rentry = (pisacd_rlist_entry *) 
PISA_MALLOC(sizeof(pisacd_rlist_entry));
-
-                       memset(rentry, 0, sizeof(pisacd_rlist_entry));
-
-                       PISA_STRNCPY(rentry->ssid, (const char *)iwres->essid, 
sizeof(rentry->ssid));
-                       PISA_STRNCPY(rentry->macaddr, (const char 
*)iwres->apaddr, sizeof(rentry->macaddr));
-                       PISA_STRNCPY(rentry->token, PISA_DEFAULT_TOKEN, 
sizeof(rentry->token));
-
-                       /* add a new entry in sorted order */
-                       pisa_ll_add_sort(&cd_ctx.ready_queue, iwres->qual, 
rentry);
-               }
-       }
-
-       /* FIXME: only for debugging */
-       show_conf_cnblist(&cd_ctx.cands_queue);
-       PISA_DEBUG(PL_PREAUTH, "\n");
-       show_conf_rnblist(&cd_ctx.ready_queue);
-       PISA_DEBUG(PL_PREAUTH, "\n");
-
-       pisa_ll_uninit(&iwreslist, pisa_free);
-}
-
-/**
- * Lookup an entry in a given ready_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 channel  channel number where ssid can be scanned
- * @param quality  link quality of the access point of keyssid
- * @return the clist_entry if found, NULL otherwise
- */
-pisacd_clist_entry *pisacd_clist_update_chssid(pisa_ll *llist, const char 
*keyssid, const int channel, const int quality)
-{
-       pisa_ll_node *iter = NULL;
-       pisacd_clist_entry *entry;
-
-       while ((iter = pisa_ll_iterate(llist, iter)) != NULL) {
-               entry = (pisacd_clist_entry *) iter->ptr;
-               if (strncasecmp(entry->ssid, keyssid, MAX_SSID) == 0) {
-                       /* found an entry with keyssid. */
-                       entry->channel = channel;
-                       entry->quality = quality;
-
-                       return entry;
-               }
-       }
-
-       return NULL;
-}
-
-/**
- * Lookup an entry in a given ready_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 clist_entry if found, NULL otherwise
- */
-pisacd_clist_entry *pisacd_clist_lookup_ssid(pisa_ll *llist, const char 
*keyssid)
-{
-       pisa_ll_node *iter = NULL;
-       pisacd_clist_entry *entry;
-
-       while ((iter = pisa_ll_iterate(llist, iter)) != NULL) {
-               entry = (pisacd_clist_entry *) iter->ptr;
-               if (strncasecmp(entry->ssid, keyssid, MAX_SSID) == 0) {
-                       /* found an entry with keyssid. */
-                       return entry;
-               }
-       }
-
-       return NULL;
-}
-
-/**
- * Add an rlist_entry to the given ready_queue, sorted by the priority value
- * which can be obtained from cands_queue.
- * pisa_ll_add_sort() will be called internally.
- *
- * @param cands_queue  the list of candidate routers
- * @param rentry       an entry to be added to ready_queue
- */
-void pisacd_rlist_add_sorted(pisa_ll *cands_queue, pisacd_rlist_entry *rentry)
-{
-       pisacd_clist_entry *centry;
-       int prio = 0;
-
-       /* 
-        * 1. calculate signal quality of each entry
-        * 2. determine their priority
-        * 3. add it to ready_queue to make it a priority queue sorted by qual.
-        */
-       centry = pisacd_clist_lookup_ssid(cands_queue, rentry->ssid);
-
-       /* If the entry exists already in cands_queue, just get it.
-        * If not, we take this node as the lowest priority, 100.
-        */
-       if (centry) {
-               prio = calc_node_priority(centry->quality);
-       }
-       else {
-               prio = MAX_RLIST_PRIORITY;
-       }
-
-       PISA_DEBUG(PL_PREAUTH, "ssid(%s) priority = %d\n", rentry->ssid, prio);
-
-       pisa_ll_add_sort(&cd_ctx.ready_queue, prio, rentry);
-
-       PISA_DEBUG(PL_PREAUTH, "\n#2 Displaying the handover-ready routers 
queue...\n");
-       show_conf_rnblist(&cd_ctx.ready_queue);
-}
-
-/**
- * Lookup an entry in a given ready_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
- */
-pisacd_rlist_entry *pisacd_rlist_lookup_ssid(pisa_ll *llist, const char 
*keyssid)
-{
-       pisa_ll_node *iter = NULL;
-       pisacd_rlist_entry *entry;
-
-       while ((iter = pisa_ll_iterate(llist, iter)) != NULL) {
-               entry = (pisacd_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 ready_list, which matches with the given key 
ssid.
- * If an entry was found, then update the entry with token, fetch the entry
- * and reinsert to the list in the order of priority.
- *
- * @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
- */
-pisacd_rlist_entry *pisacd_rlist_update_token(pisa_ll *llist, const char 
*keyssid, const char *token)
-{
-       pisa_ll_node *iter = NULL;
-       pisacd_rlist_entry *entry, *tmpentry;
-       int index = 0;
-
-       while ((iter = pisa_ll_iterate(llist, iter)) != NULL) {
-               entry = (pisacd_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));
-
-                       /* copy the entry */
-                       tmpentry = (pisacd_rlist_entry *) 
PISA_MALLOC(sizeof(pisacd_rlist_entry));
-                       memcpy(tmpentry, entry, sizeof(pisacd_rlist_entry));
-
-                       /* delete the entry */
-                       pisa_ll_del(llist, index, pisa_free);
-
-                       /* add the entry again in sorted order */
-                       pisacd_rlist_add_sorted(llist, tmpentry);
-
-                       return entry;
-               }
-               index++;
-       }
-
-       return NULL;
-}
-
-/**
- * Lookup an entry in a given ready_list, which matches with the given key 
ssid.
- * If an entry was found, then update the entry with priority, fetch the entry
- * and reinsert to the list in the order of priority.
- *
- * @param llist    linked list where each entry is looked up
- * @param keyssid  the key ssid which lookup each entry with
- * @param priority the priority to be updated
- * @return the rlist_entry if found, NULL otherwise
- */
-pisacd_rlist_entry *pisacd_rlist_update_priority(pisa_ll *llist, const char 
*keyssid, const int priority)
-{
-       pisa_ll_node *iter = NULL;
-       pisacd_rlist_entry *entry, *tmpentry;
-       int index = 0;
-
-       while ((iter = pisa_ll_iterate(llist, iter)) != NULL) {
-               entry = (pisacd_rlist_entry *) iter->ptr;
-               if (strncasecmp(entry->ssid, keyssid, MAX_SSID) == 0) {
-                       /* found an entry with keyssid. */
-
-                       /* copy the entry */
-                       tmpentry = (pisacd_rlist_entry *) 
PISA_MALLOC(sizeof(pisacd_rlist_entry));
-                       memcpy(tmpentry, entry, sizeof(pisacd_rlist_entry));
-
-                       /* delete the entry */
-                       pisa_ll_del(llist, index, pisa_free);
-
-                       /* add the entry again in sorted order */
-/*                        pisacd_rlist_add_sorted(llist, tmpentry);*/
-                       pisa_ll_add_sort(&cd_ctx.ready_queue, priority, 
tmpentry);
-
-                       return entry;
-               }
-               index++;
-       }
-
-       return NULL;
-}
-
-/**
- * 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 keyipaddr  the key ipaddr which lookup each entry with
- * @return the rlist_entry if found, NULL otherwise
- */
-pisacd_rlist_entry *pisacd_rlist_lookup_ipaddr(pisa_ll *llist, const char 
*keyipaddr)
-{
-       pisa_ll_node *iter = NULL;
-       pisacd_rlist_entry *entry;
-       char pbuffer[INET6_ADDRSTRLEN] = {0};
-
-       while ((iter = pisa_ll_iterate(llist, iter)) != NULL) {
-               entry = (pisacd_rlist_entry *) iter->ptr;
-/*                inet_ntop(AF_INET6, &entry->ipaddr, pbuffer, 
INET6_ADDRSTRLEN);*/
-               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 ready_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 bulist_entry if found, NULL otherwise
- */
-pisacd_bulist_entry *pisacd_bulist_lookup_ssid(pisa_ll *llist, const char 
*keyssid)
-{
-       pisa_ll_node *iter = NULL;
-       pisacd_bulist_entry *entry;
-
-       while ((iter = pisa_ll_iterate(llist, iter)) != NULL) {
-               entry = (pisacd_bulist_entry *) iter->ptr;
-               if (strncasecmp(entry->ssid, keyssid, MAX_SSID) == 0) {
-                       /* found an entry with keyssid. */
-                       return entry;
-               }
-       }
-
-       return NULL;
-}
-
-/**
- * Add an rlist_entry to the given ready_queue, sorted by the priority value
- * which can be obtained from cands_queue.
- * pisa_ll_add_sort() will be called internally.
- *
- * @param quality    a signal quality value from 0 to 100 (100: the highest)
- * @return priority value from 0 to 100 (0: the highest priority)
- */
-static int calc_node_priority(const uint8_t quality)
-{
-       /* TODO: more accurate way of calculating node priority. */
-       return (int)(MAX_QUALITY - quality);
-}
-
-/**
- * Check if the given SSID must be blocked, looking up the blacklist.
- *
- * @param ssid   ssid to be checked
- * @return TRUE if ssid must be blocked, FALSE otherwise.
- */
-static inline int is_ap_in_blacklist(const char *ssid)
-{
-       int i;
-
-       for (i = 0; i < sizeof(ssid_blacklist) / sizeof(char *) ; i++) {
-               if (strncasecmp(ssid, ssid_blacklist[i], 
strlen(ssid_blacklist[i])) == 0)
-                       return TRUE;
-       }
-
-       return FALSE;
 }
-#endif /* REMOVE_PREAUTH_CODE */

Modified: trunk/pisacd/cdctx.h
==============================================================================
--- trunk/pisacd/cdctx.h        Wed Oct 21 13:00:37 2009        (r1251)
+++ trunk/pisacd/cdctx.h        Wed Oct 21 13:16:11 2009        (r1252)
@@ -26,32 +26,6 @@
  * current client daemon.
  */
 typedef struct {
-#ifdef REMOVE_PREAUTH_CODE
-       pisa_ll cands_queue;    /* a queue of candidate client routers */
-       pisa_ll ready_queue;    /* a priority queue of handover-ready routers */
-       pisa_ll bulist; /* a priority queue of handover-ready routers */
-
-       /**
-        * information about the access point where this client is associated
-        */
-       struct access_point {
-               char    ssid[MAX_SSID+1];
-               char    macaddr[MAX_MACADDR+1];
-               struct in_addr ipaddr;
-               uint16_t        ndport;
-       } my_ap;
-
-       /**
-        * the current index where the next candidate router is to be accessed
-        */
-       int cq_offset;
-
-       /**
-        * 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.
@@ -64,23 +38,6 @@
         */
        int is_bgrun;
 
-#ifdef REMOVE_PREAUTH_CODE
-       /**
-        * Flag if scanning candidate neighbor access points
-        */
-       int is_scanning;
-
-       /**
-        * Flag if sending pre-authentication request packet to my AP
-        */
-       int is_sending_pareq;
-
-       /**
-        * Flag if sending binding update request packet to my AP
-        */
-       int is_sending_bureq;
-#endif /* REMOVE_PREAUTH_CODE */
-
        /**
         * Sockets for the tunnel device, the tunc and tund sockets
         */
@@ -94,30 +51,6 @@
         */
        int fd_pisaconf;
 
-#ifdef REMOVE_PREAUTH_CODE
-       /**
-        * The file descriptor of the pre-authentication client socket,
-        * on which outgoing packet is sent to the access router.
-        */
-       int fd_pacli;
-
-       /**
-        * The file descriptor of the pre-authentication client socket,
-        * on which outgoing packet is sent to the access router.
-        */
-       int fd_pasrv;
-
-       /**
-        * The current count value of pre-authentication tries.
-        */
-       int pareq_tries_count;
-
-       /**
-        * The current count value of binding update tries.
-        */
-       int bureq_tries_count;
-#endif /* REMOVE_PREAUTH_CODE */
-
        /**
         * Tunnel interface name.
         */
@@ -146,39 +79,6 @@
 
 extern cd_context cd_ctx;
 
-#ifdef REMOVE_PREAUTH_CODE
-/**
- * data structure defining a pair of core information about candidate routers
- */
-typedef struct {
-       char ssid[MAX_SSID+1];  /**< SSID obtained from peer neighbor */
-       char macaddr[MAX_MACADDR+1];    /**< MAC address of access point */
-       int channel;            /**< channel number of the access point */
-       uint8_t quality;        /**< signal quality to the access point */
-} pisacd_clist_entry;
-
-/**
- * data structure defining a pair of core information about handover-ready
- * client routers
- */
-typedef struct {
-       char ssid[MAX_SSID+1];  /**< SSID obtained from peer neighbor */
-       char macaddr[MAX_MACADDR+1];    /**< MAC address of access point */
-       pisa_common_addr ipaddr;        /**< IP address obtained from peer 
neighbor */
-       char    token[PISA_TOKEN_LENGTH+1];     /**< token obtained from peer 
neighbor */
-} pisacd_rlist_entry;
-
-/**
- * data structure defining a pair of core information about binding update
- * procedure.
- */
-typedef struct {
-       char ssid[MAX_SSID+1];  /**< SSID obtained from peer neighbor */
-       char macaddr[MAX_MACADDR+1];    /**< MAC address of access point */
-       pisa_common_addr ipaddr;        /**< IP address obtained from peer 
neighbor */
-} pisacd_bulist_entry;
-#endif /* REMOVE_PREAUTH_CODE */
-
 /**
  * Function prototypes
  */
@@ -188,55 +88,5 @@
  */
 void cdctx_init(cd_context *cdctx);
 void cdctx_destroy(cd_context *cdctx);
-#ifdef REMOVE_PREAUTH_CODE
-int cdctx_get_neighbors(void);
-void cdctx_get_default_ap(void);
-
-static inline void cdctx_clear_ssid(cd_context *cdctx)
-{
-       memset(cdctx->my_ap.ssid, 0, sizeof(cdctx->my_ap.ssid));
-}
-
-static inline void cdctx_clear_apmacaddr(cd_context *cdctx)
-{
-       memset(cdctx->my_ap.macaddr, 0, sizeof(cdctx->my_ap.macaddr));
-}
-
-static inline void cdctx_clear_ipaddr(cd_context *cdctx)
-{
-       memset(&cdctx->my_ap.ipaddr, 0, sizeof(cdctx->my_ap.ipaddr));
-}
-
-static inline void cdctx_set_ssid(cd_context *cdctx, const char *ssid)
-{
-       PISA_STRNCPY(cdctx->my_ap.ssid, ssid, sizeof(cdctx->my_ap.ssid));
-}
-
-static inline void cdctx_set_apmacaddr(cd_context *cdctx, const char *macaddr)
-{
-       PISA_STRNCPY(cdctx->my_ap.macaddr, macaddr, 
sizeof(cdctx->my_ap.macaddr));
-}
-
-static inline void cdctx_set_ipaddr(cd_context *cdctx, pisa_common_addr 
*ipaddr)
-{
-       pisa_ipv4_copy(&cdctx->my_ap.ipaddr, &ipaddr->sa.sa4);
-}
-
-void show_conf_cnblist(pisa_ll *llist);
-void show_conf_rnblist(pisa_ll *llist);
-
-void cd_trigger_scanning(void);
-
-pisacd_clist_entry *pisacd_clist_update_chssid(pisa_ll *llist, const char 
*keyssid, const int channel, const int quality);
-pisacd_clist_entry *pisacd_clist_lookup_ssid(pisa_ll *llist, const char 
*keyssid);
-
-void pisacd_rlist_add_sorted(pisa_ll *cands_queue, pisacd_rlist_entry *rentry);
-pisacd_rlist_entry *pisacd_rlist_lookup_ssid(pisa_ll *llist, const char 
*keyssid);
-pisacd_rlist_entry *pisacd_rlist_lookup_ipaddr(pisa_ll *llist, const char 
*keyipaddr);
-pisacd_rlist_entry *pisacd_rlist_update_token(pisa_ll *llist, const char 
*keyssid, const char *token);
-pisacd_rlist_entry *pisacd_rlist_update_priority(pisa_ll *llist, const char 
*keyssid, const int priority);
-
-pisacd_bulist_entry *pisacd_bulist_lookup_ssid(pisa_ll *llist, const char 
*keyssid);
-#endif /* REMOVE_PREAUTH_CODE */
 
 #endif /* PISA_CDCTX_H */

Modified: trunk/pisacd/cdmain.c
==============================================================================
--- trunk/pisacd/cdmain.c       Wed Oct 21 13:00:37 2009        (r1251)
+++ trunk/pisacd/cdmain.c       Wed Oct 21 13:16:11 2009        (r1252)
@@ -18,9 +18,7 @@
 #include "tunnel.h"
 #include "util.h"
 #include "cdconf.h"
-#include "cdconmgr.h"
 #include "cdctx.h"
-#include "cdmsg.h"
 #include "cdtun.h"
 #include "cdderegister.h"
 #include "cdheartbeat.h"
@@ -38,25 +36,6 @@
 
 #ifdef CONFIG_PISA_PERFORMANCE
 #include "pisaperf.h"
-#ifdef REMOVE_PREAUTH_CODE
-static int pisacd_bench_all_on = FALSE;
-static int pisacd_bench_pa_on = FALSE;
-static int pisacd_bench_bu_on = FALSE;
-static int pisacd_bench_nc_on = FALSE;
-
-static void cd_perf_start_benchmark_hoverall(void);
-static void cd_perf_stop_benchmark_hoverall(void);
-static void cd_perf_write_benchmark_hoverall(void);
-static void cd_perf_start_benchmark_preauth(void);
-static void cd_perf_stop_benchmark_preauth(void);
-static void cd_perf_write_benchmark_preauth(void);
-static void cd_perf_start_benchmark_bupdate(void);
-static void cd_perf_stop_benchmark_bupdate(void);
-static void cd_perf_write_benchmark_bupdate(void);
-static void cd_perf_start_benchmark_netconf(void);
-static void cd_perf_stop_benchmark_netconf(void);
-static void cd_perf_write_benchmark_netconf(void);
-#endif /* REMOVE_PREAUTH_CODE */
 static void cd_perf_init(void);
 static void cd_perf_destroy(void);
 #endif /* CONFIG_PISA_PERFORMANCE */
@@ -68,9 +47,6 @@
  */
 static const struct option cd_longopts[] = {
        {"config",      required_argument,      NULL,   'f'},
-#ifdef REMOVE_PREAUTH_CODE
-       {"interface",   required_argument,      NULL,   'i'},
-#endif /* REMOVE_PREAUTH_CODE */
        {"port_control",        required_argument,      NULL,   'p'},
        {"port_data",   required_argument,      NULL,   'q'},
        {"background",  required_argument,      NULL,   'b'},
@@ -80,19 +56,6 @@
        {NULL,          0,                      NULL,   '\0'}
 };
 
-#ifdef REMOVE_PREAUTH_CODE
-/**
- * A set of pointers to packet handling functions
- */
-static pisa_packet_handle_func_set pisacd_packet_handle_func_set;
-
-/**
- * Timeout management variables
- */
-static time_t init_pareq_period;
-static time_t currentTime;
-#endif /* REMOVE_PREAUTH_CODE */
-
 /**
  * Prototype declarations of functions.
  */
@@ -100,25 +63,11 @@
 static void cd_deinit(void);
 static inline void cd_do_main(void);
 
-#ifdef REMOVE_PREAUTH_CODE
-static void add_fds_to_fdset(void *data, cdConMgrEntry *entry);
-static inline void send_pareq_to_ap(void);
-static inline void send_bureq_to_tp(void);
-static inline void cd_read_inbound_msgs(int fd);
-static void cd_process_new_client(char *buf, struct sockaddr_in *src_addr);
-static void cd_process_known_client(cdConMgrEntry * entry, char *buf, size_t 
len);
-static inline void cd_check_manage_timeout(void);
-#endif /* REMOVE_PREAUTH_CODE */
-
 static void cd_get_cmdargs(int argc, char **argv);
 static void cd_print_usage(char **argv);
 static void cd_print_version(void);
 static void cd_reload_confs(int quitcode);
 static void cd_quit(int quitcode);
-#ifdef REMOVE_PREAUTH_CODE
-static void cd_handle_sigalarm(int sigcode);
-static void cd_start_alarm(void);
-#endif /* REMOVE_PREAUTH_CODE */
 static inline int cd_get_maxfd(void);
 
 /**
@@ -169,9 +118,6 @@
        signal(SIGHUP, cd_reload_confs);
        signal(SIGPIPE, SIG_IGN);
        signal(SIGBUS, cd_quit);
-#ifdef REMOVE_PREAUTH_CODE
-       signal(SIGALRM, cd_handle_sigalarm);
-#endif /* REMOVE_PREAUTH_CODE */
 
        /* Check and create lockfile */
        pisa_create_lock_file(PISACD_LOCK_FILE, 0);
@@ -216,10 +162,6 @@
 
        /* Make default sockets */
        cd_ctx.tunnel = pisa_tunnel_open_tundev(cd_ctx.ifname_tunnel, IFNAMSIZ);
-#ifdef REMOVE_PREAUTH_CODE
-       cd_ctx.fd_pacli = setup_sock_udp(AF_INET);
-       cd_ctx.fd_pasrv = setup_listen_sock_udp(AF_INET, cd_cfg.port_pasrv);
-#endif /* REMOVE_PREAUTH_CODE */
        cd_ctx.fd_pisaconf = pisa_conf_open_server_socket(PISA_CONF_PORT_CD);
 
        /* open peer sockets targeting the pisa server daemon,
@@ -227,29 +169,6 @@
        cd_ctx.tunc = pisa_tunnel_open_socket(cd_cfg.port_control);
        cd_ctx.tund = pisa_tunnel_open_socket(cd_cfg.port_data);
 
-#ifdef REMOVE_PREAUTH_CODE
-       /* Get neighbor routers, at the moment just reading them from conf file.
-        * TODO: make some fancy way to determine neighbors... */
-       cdctx_get_neighbors();
-
-       /* Set SSID and IP address of CD configuration.
-        * This must be called after getting neighbor routers. */
-       cdconf_set_wlaninfos(&cd_cfg);
-
-       cdctx_get_default_ap();
-
-       pisacd_packet_handle_func_set.handle_nereq = pisacd_handle_nereq;
-       pisacd_packet_handle_func_set.handle_neres = pisacd_handle_neres;
-       pisacd_packet_handle_func_set.handle_pareq = pisacd_handle_pareq;
-       pisacd_packet_handle_func_set.handle_pares = pisacd_handle_pares;
-       pisacd_packet_handle_func_set.handle_bureq = pisacd_handle_bureq;
-       pisacd_packet_handle_func_set.handle_bures = pisacd_handle_bures;
-       pisacd_packet_handle_func_set.handle_vrfyreq1 = pisacd_handle_vrfyreq1;
-       pisacd_packet_handle_func_set.handle_vrfyres1 = pisacd_handle_vrfyres1;
-       pisacd_packet_handle_func_set.handle_vrfyreq2 = pisacd_handle_vrfyreq2;
-       pisacd_packet_handle_func_set.handle_vrfyres2 = pisacd_handle_vrfyres2;
-#endif /* REMOVE_PREAUTH_CODE */
-
        /* set handlers for tunnel control packet types */
        pisa_ctrlhandler_set(&cd_ctx.ctrlhandlers, 
PISA_PKTTYPE_TUN_REGISTER_ACK, pisa_recv_register_ack);
        pisa_ctrlhandler_set(&cd_ctx.ctrlhandlers, 
PISA_PKTTYPE_TUN_DEREGISTER_ACK, pisa_recv_deregister_ack);
@@ -266,14 +185,6 @@
        pisa_conf_read_file("foo", pisa_cdconf_parse);
 */
 
-#ifdef REMOVE_PREAUTH_CODE
-       /* set the default alarm */
-       cd_start_alarm();
-
-       /* We should start sending pareq packets in the beginning. */
-       cd_ctx.is_sending_pareq = TRUE;
-#endif /* REMOVE_PREAUTH_CODE */
-
        /* initialize the connection list */
        cd_ctx.conlist = 
pisa_conmgr_init(pisacd_cleanup_after_removed_connection);
 
@@ -290,9 +201,6 @@
 
        pisa_conmgr_cleanup(&cd_ctx.conlist, cd_ctx.natlist);
 
-#ifdef REMOVE_PREAUTH_CODE
-       alarm(0);
-#endif /* REMOVE_PREAUTH_CODE */
        pisa_tunnel_remove_firewall_rules(cd_ctx.ifname_tunnel);
        pisa_nat_destroy(cd_ctx.natlist);
        cdctx_destroy(&cd_ctx);
@@ -300,10 +208,6 @@
        pisa_arp_cleanup();
        pisa_sched_cleanup(&cd_ctx.scheduler);
 
-#ifdef REMOVE_PREAUTH_CODE
-       close(cd_ctx.fd_pacli);
-       close(cd_ctx.fd_pasrv);
-#endif /* REMOVE_PREAUTH_CODE */
        close(cd_ctx.fd_pisaconf);
        close(cd_ctx.tunc);
        close(cd_ctx.tund);
@@ -344,9 +248,6 @@
        int pending = 0;
        fd_set readfds;
 
-#ifdef REMOVE_PREAUTH_CODE
-       cd_ctx.is_scanning = TRUE;
-#endif /* REMOVE_PREAUTH_CODE */
        cd_ctx.is_cd_running = TRUE;
 
        pisa_servers_add_all();
@@ -354,70 +255,19 @@
        PISA_INFO("\nEntering main loop\n");
 
        while (cd_ctx.is_cd_running || pending) {
-#ifdef REMOVE_PREAUTH_CODE
-               int     start_alarm = FALSE;
-#endif /* REMOVE_PREAUTH_CODE */
-
                /* sockets.tunnel needs to be always included in the reading fd 
list */
                FD_ZERO(&readfds);
                FD_SET(cd_ctx.tunnel, &readfds);
                FD_SET(cd_ctx.tunc, &readfds);
                FD_SET(cd_ctx.tund, &readfds);
-#ifdef REMOVE_PREAUTH_CODE
-               FD_SET(cd_ctx.fd_pacli, &readfds);
-               FD_SET(cd_ctx.fd_pasrv, &readfds);
-#endif /* REMOVE_PREAUTH_CODE */
                FD_SET(cd_ctx.fd_pisaconf, &readfds);
                FD_SET(cd_ctx.scheduler.pipe_main[0], &readfds);
 
-#ifdef REMOVE_PREAUTH_CODE
-               /* Send periodical neighbor exchange requests,
-                * no matter what select() returns. */
-               if (cd_ctx.is_sending_pareq) {
-/*                     PISA_DEBUG(PL_PREAUTH, "Sending pre-authentication 
request to access points.\n");*/
-                       send_pareq_to_ap();
-                       cd_ctx.is_sending_pareq = FALSE;
-                       cd_ctx.pareq_tries_count++;
-/*                                start_alarm = TRUE;*/
-               }
-#endif /* REMOVE_PREAUTH_CODE */
-
-#ifdef REMOVE_PREAUTH_CODE
-               cdConMgrIterateOverEntries(add_fds_to_fdset, (void *)&readfds);
-#endif /* REMOVE_PREAUTH_CODE */
-
                /* TODO this is just a maxof, no need for a separate function.
                 * Inline once PREAUTH is gone. -- Thomas */
                maxfd = cd_get_maxfd();
 
                if ((ret = select(maxfd + 1, &readfds, NULL, NULL, NULL)) <= 0) 
{
-#ifdef REMOVE_PREAUTH_CODE
-                       if (cd_ctx.is_cd_running) {
-                               if (cd_ctx.is_scanning) {
-/*                                     PISA_DEBUG(PL_PREAUTH, 
"Scanning...\n");*/
-                                       cd_trigger_scanning();
-                                       cd_ctx.is_scanning = FALSE;
-                                       start_alarm = TRUE;
-                               }
-
-#if 0
-                               if (cd_ctx.is_sending_pareq) {
-                                       PISA_DEBUG(PL_PREAUTH, "Sending 
pre-authentication request to access point.\n");
-                                       send_pareq_to_ap();
-                                       cd_ctx.is_sending_pareq = FALSE;
-                                       cd_ctx.pareq_tries_count++;
-/*                                     start_alarm = TRUE;*/
-                               }
-#endif
-
-                               if (cd_ctx.is_sending_bureq) {
-/*                                     PISA_DEBUG(PL_PREAUTH, "Sending binding 
update request to access point.\n");*/
-                                       send_bureq_to_tp();
-                                       cd_ctx.is_sending_bureq = FALSE;
-                                       start_alarm = TRUE;
-                               }
-                       }
-#endif /* REMOVE_PREAUTH_CODE */
                } else {
                        if (cd_ctx.is_cd_running) {
                                if (FD_ISSET(cd_ctx.tunnel, &readfds))
@@ -430,304 +280,16 @@
                        if (FD_ISSET(cd_ctx.tunc, &readfds))
                                pisa_ctrlhandler_dispatch(&cd_ctx.ctrlhandlers, 
cd_ctx.tunc);
 
-#ifdef REMOVE_PREAUTH_CODE
-                       if (FD_ISSET(cd_ctx.fd_pasrv, &readfds)) {
-/*                             PISA_DEBUG(PL_PREAUTH, "Reading data from 
fd_pasrv[%d]\n", cd_ctx.fd_pasrv);*/
-                               cd_read_inbound_msgs(cd_ctx.fd_pasrv);
-                               cd_ctx.is_sending_pareq = FALSE;
-                               start_alarm = TRUE;
-                       }
-#endif /* REMOVE_PREAUTH_CODE */
-
                        if (FD_ISSET(cd_ctx.fd_pisaconf, &readfds))
                                pisa_conf_handle_packet(cd_ctx.fd_pisaconf);
 
                        if (FD_ISSET(cd_ctx.scheduler.pipe_main[0], &readfds))
                                pisa_handle_scheduler();
                }
-
-#ifdef REMOVE_PREAUTH_CODE
-               cd_check_manage_timeout();
-#endif /* REMOVE_PREAUTH_CODE */
-
-#ifdef REMOVE_PREAUTH_CODE
-               if (start_alarm && cd_ctx.is_cd_running) {
-/*                        PISA_DEBUG(PL_PREAUTH"Starting alarm...\n");*/
-                       cd_start_alarm();
-               }
-#endif /* REMOVE_PREAUTH_CODE */
-       }
-}
-
-#ifdef REMOVE_PREAUTH_CODE
-/**
- * Callback used to add all file descriptors of our connections to the
- * set of file descriptors.
- *
- * @param data   pointer to a fd_set
- * @param entry  Living connection
- */
-static void add_fds_to_fdset(void *data, cdConMgrEntry *entry)
-{
-       fd_set *set = (fd_set *)data;
-       FD_SET(entry->fd, set);
-}
-
-/**
- * Send pre-authentication request packet to my current access point.
- */
-static inline void send_pareq_to_ap(void)
-{
-       struct sockaddr_in target_addr;
-
-       if (cd_ctx.is_cd_running){
-#ifdef CONFIG_PISA_PERFORMANCE
-               cd_perf_start_benchmark_hoverall();
-               cd_perf_start_benchmark_preauth();
-#endif
-
-               memset(&target_addr, 0, sizeof(struct sockaddr_in));
-
-               /* NOTE: target host must be an access point with a neighbor 
daemon. */
-               target_addr.sin_family = AF_INET;
-               target_addr.sin_port = htons(cd_ctx.my_ap.ndport);
-
-               /* cd_ctx.my_ap.ipaddr is currently being set either in 
pisacd.conf,
-                * or obtained from the default gateway in the routing table. */
-               pisa_ipv4_copy(&target_addr.sin_addr, &cd_ctx.my_ap.ipaddr);
-
-               pisa_send_pareq(cd_ctx.fd_pacli, &target_addr);
        }
 }
 
 /**
- * Send binding update request packet to the trust point server.
- */
-static inline void send_bureq_to_tp(void)
-{
-       struct sockaddr_in6 addr = {0};
-       if (cd_ctx.is_cd_running){
-#ifdef CONFIG_PISA_PERFORMANCE
-               cd_perf_stop_benchmark_preauth();
-               cd_perf_write_benchmark_preauth();
-#endif
-
-               if (cd_cfg.make_tunnel) {
-                       if (cd_ctx.defaultroute) {
-#ifdef CONFIG_PISA_PERFORMANCE
-                               cd_perf_start_benchmark_bupdate();
-#endif
-                               PISA_DEBUG(PL_PREAUTH, "Sending bureq\n");
-                               
pisa_conmgr_build_sockaddr_control(cd_ctx.defaultroute, &addr);
-                               pisa_send_bureq(cd_ctx.tunc, &addr);
-                       }
-               } else {
-                       /* Do handover */
-                       pisacd_perform_handover();
-
-#ifdef CONFIG_PISA_PERFORMANCE
-                       cd_perf_stop_benchmark_hoverall();
-                       cd_perf_write_benchmark_hoverall();
-#endif
-               }
-       }
-}
-
-/**
- * Read function for inbound messages.
- *
- * @param fd   fd where incoming data will be read
- */
-static inline void cd_read_inbound_msgs(int fd)
-{
-       char lbuf[MAX_BUF] = {'\0'};
-       ssize_t len = 0;
-       socklen_t addrlen = 0;
-       cdConMgrEntry *entry;
-       struct sockaddr_in from_addr = {
-               0
-       };
-
-       addrlen = sizeof(from_addr);
-
-       if ((len = recvfrom(fd, lbuf, sizeof(lbuf), 0, (struct sockaddr *) 
&from_addr, &addrlen)) == -1) {
-               PISA_ERROR("Cannot receive message from fd[%d]\n", fd);
-               return;
-       }
-
-       if (!is_pisa_packet(lbuf)) {
-               PISA_ERROR("The incoming packet is not from a valid PISA 
neighbor daemon.\n");
-               return;
-       }
-
-       entry = cdConMgrFindByAddress(&from_addr);
-
-       if (entry == NULL) {
-               PISA_ERROR("New client from %s.\n", 
inet_ntoa(from_addr.sin_addr));
-               cd_process_new_client(lbuf, &from_addr);
-       } else {
-               PISA_ERROR("known client from %s.\n", 
inet_ntoa(from_addr.sin_addr));
-               time(&entry->timeout_heartbeat);
-               cd_process_known_client(entry, lbuf, len);
-       }
-}
-
-/**
- * Process for an incoming message from a new client.
- *
- * @param buf      buffer containing received data
- * @param src_addr IP address of the source host
- */
-static void cd_process_new_client(char *buf, struct sockaddr_in *src_addr)
-{
-       pisa_packet *pkt = (pisa_packet *)buf;
-       pisa_tlv_type pkttype = PISA_PKTTYPE_PA_UNKNOWN;
-       cdConMgrEntry *entry = NULL;
-
-       pkttype = pisa_get_packet_type(pkt);
-
-       switch (pkttype) {
-       case PISA_PKTTYPE_PA_REQUEST:
-               /* TODO: Probably error condition */
-/*                pisacd_packet_handle_func_set.handle_pareq(entry, pkt);*/
-               break;
-
-       case PISA_PKTTYPE_PA_RESPONSE:
-               entry = cdConMgrAdd(src_addr, &cd_cfg.ipaddr);
-#ifdef CONFIG_PISA_PERFORMANCE
-               cd_perf_stop_benchmark_preauth();
-               cd_perf_write_benchmark_preauth();
-#endif
-
-               pisacd_packet_handle_func_set.handle_pares(entry, pkt);
-
-               break;
-
-/*        case PISA_PKTTYPE_PA_TIMEOUT:*/
-               /* TODO: existing entry has been already removed */
-/*                pisacd_packet_handle_func_set.handle_netimeout(entry, pkt);*/
-/*                break;*/
-
-       case PISA_PKTTYPE_BU_RESPONSE:
-               entry = cdConMgrAdd(src_addr, &cd_cfg.ipaddr);
-#ifdef CONFIG_PISA_PERFORMANCE
-               cd_perf_stop_benchmark_bupdate();
-               cd_perf_write_benchmark_bupdate();
-
-               cd_perf_start_benchmark_netconf();
-#endif
-
-               pisacd_packet_handle_func_set.handle_bures(entry, pkt);
-
-#ifdef CONFIG_PISA_PERFORMANCE
-               cd_perf_stop_benchmark_netconf();
-               cd_perf_write_benchmark_netconf();
-
-               cd_perf_stop_benchmark_hoverall();
-               cd_perf_write_benchmark_hoverall();
-#endif
-
-               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 pisacd 
packet.\n");
-               break;
-       default:
-               /* TODO: For now, do nothing.
-                * But we need to find some way to deal with it. */
-               break;
-       }
-}
-
-/**
- * Process for an incoming message from an existing client.
- *
- * @param entry    existing connection manager entry
- * @param buf      buffer containing received data
- * @param len      length of buf
- */
-static void cd_process_known_client(cdConMgrEntry * entry, char *buf, size_t 
len)
-{
-       pisa_packet *pkt = (pisa_packet *)buf;
-       pisa_tlv_type pkttype = PISA_PKTTYPE_PA_UNKNOWN;
-
-       pkttype = pisa_get_packet_type(pkt);
-
-       switch (pkttype) {
-       case PISA_PKTTYPE_PA_REQUEST:
-/*                pisacd_packet_handle_func_set.handle_pareq(entry, pkt);*/
-               break;
-
-       case PISA_PKTTYPE_PA_RESPONSE:
-#ifdef CONFIG_PISA_PERFORMANCE
-               cd_perf_stop_benchmark_preauth();
-               cd_perf_write_benchmark_preauth();
-#endif
-
-               pisacd_packet_handle_func_set.handle_pares(entry, pkt);
-
-               break;
-
-/*        case PISA_PKTTYPE_PA_TIMEOUT:*/
-/*                cdConMgrRemove(entry);*/
-/*                pisacd_packet_handle_func_set.handle_netimeout(entry, pkt);*/
-/*                break;*/
-
-       case PISA_PKTTYPE_BU_RESPONSE:
-#ifdef CONFIG_PISA_PERFORMANCE
-               cd_perf_stop_benchmark_bupdate();
-               cd_perf_write_benchmark_bupdate();
-#endif
-
-               pisacd_packet_handle_func_set.handle_bures(entry, pkt);
-
-#ifdef CONFIG_PISA_PERFORMANCE
-               cd_perf_stop_benchmark_hoverall();
-               cd_perf_write_benchmark_hoverall();
-#endif
-
-               break;
-
-       case PISA_PKTTYPE_NE_UNKNOWN:
-       case PISA_PKTTYPE_PA_UNKNOWN:
-       case PISA_PKTTYPE_BU_UNKNOWN:
-       default:
-               /* drop */
-               PISA_ERROR("Cannot recognize type of the incoming pisacd 
packet.\n");
-               break;
-       }
-}
-
-/**
- * Check and manage timeout variables
- */
-static inline void cd_check_manage_timeout(void)
-{
-       /* Clean up expired connection entries once in waitingPeriod */
-       time(&currentTime);
-
-       if (currentTime - init_pareq_period > cd_cfg.pareq_interval) {
-               if (cd_ctx.pareq_tries_count > cd_cfg.pareq_maxretry) {
-/*                     PISA_INFO("WARNING: reached maximum preauth request 
count. Sleeping...\n");*/
-/* TODO: Rewrite/remove handover/preauth code. Disabled sleep for now.
- * -- Thomas
-                       sleep(5);
-*/
-/*                     PISA_INFO("Resetting tries count...\n");*/
-                       cd_ctx.pareq_tries_count = 0;
-               }
-
-               cd_ctx.is_sending_pareq = TRUE;
-
-               time(&init_pareq_period);
-       }
-}
-#endif /* REMOVE_PREAUTH_CODE */
-
-/**
  * Get command line arguments and parse them.
  *
  * @param argc        number of command arguments
@@ -743,11 +305,6 @@
                case 'f':
                        PISA_STRNCPY(cd_cfg.conffile, optarg, 
sizeof(cd_cfg.conffile));
                        break;
-#ifdef REMOVE_PREAUTH_CODE
-               case 'i':
-                       PISA_STRNCPY(cd_cfg.ifname_wlan, optarg, 
sizeof(cd_cfg.ifname_wlan));
-                       break;
-#endif /* REMOVE_PREAUTH_CODE */
                case 'p':
                        cd_cfg.port_control = atoi(optarg);
                        break;
@@ -922,199 +479,18 @@
        int     tmfd;
 
        tmfd = pisa_maxInt(cd_ctx.tunnel, cd_ctx.fd_pisaconf);
-#ifdef REMOVE_PREAUTH_CODE
-       tmfd = pisa_maxInt(tmfd, cd_ctx.fd_pacli);
-       tmfd = pisa_maxInt(tmfd, cd_ctx.fd_pasrv);
-#endif /* REMOVE_PREAUTH_CODE */
        tmfd = pisa_maxInt(tmfd, cd_ctx.tunc);
        tmfd = pisa_maxInt(tmfd, cd_ctx.tund);
        tmfd = pisa_maxInt(tmfd, cd_ctx.scheduler.pipe_main[0]);
        maxfd = tmfd + 1;
 #else
-#ifdef REMOVE_PREAUTH_CODE
-       maxfd = pisa_maxof(7, cd_ctx.tunnel, cd_ctx.fd_pisaconf,
-               cd_ctx.fd_pacli, cd_ctx.fd_pasrv,
-               cd_ctx.tunc, cd_ctx.tund, cd_ctx.scheduler.pipe_main[0]) + 1;
-#else 
        maxfd = pisa_maxof(5, cd_ctx.tunnel, cd_ctx.fd_pisaconf,
                cd_ctx.tunc, cd_ctx.tund, cd_ctx.scheduler.pipe_main[0]) + 1;
-#endif /* REMOVE_PREAUTH_CODE */
 #endif
 
        return maxfd;
 }
 
-#ifdef REMOVE_PREAUTH_CODE
-/**
- * This handler is executed periodically by SIGALRM.
- *
- * @param sigcode   signal code
- */
-static void cd_handle_sigalarm(int sigcode)
-{
-#if 0
-       if (cd_ctx.pareq_tries_count > cd_cfg.pareq_maxretry) {
-               PISA_INFO("WARNING: reached maximum client request count. 
Sleeping...\n");
-/* TODO: Rewrite/remove handover/preauth code. Do *NOT* use sleep */
-               sleep(5);
-               PISA_INFO("Resetting tries count...\n");
-               cd_ctx.pareq_tries_count = 0;
-       }
-#endif
-
-       /* TODO: take also care of bureq_maxretry */
-
-/*        cd_ctx.pareq_tries_count++;*/
-       cd_ctx.is_scanning = TRUE;
-/*        cd_ctx.is_sending_pareq = TRUE;*/
-       cd_ctx.is_sending_bureq = FALSE;
-
-       /* read basic configurations from pisacd.conf */
-       cdconf_read_basic_confs(&cd_cfg);
-}
-
-/**
- * Setup alarm
- */
-static void cd_start_alarm(void)
-{
-       alarm(PISACD_DEFAULT_ALARM_INTERVAL);
-/*     PISA_DEBUG(PL_PREAUTH, "Starting alarm with %d seconds.\n", 
PISACD_DEFAULT_ALARM_INTERVAL);*/
-}
-
-/**
- * Start the entire handover benchmark
- */
-static void cd_perf_start_benchmark_hoverall(void)
-{
-       if (!pisacd_bench_all_on) {
-               PISA_DEBUG(PL_PREAUTH, "Starting PERF_HANDOVER_ALL\n");
-               pisa_perf_start_benchmark(pisa_perf, PERF_HANDOVER_ALL);
-
-               pisacd_bench_all_on = TRUE;
-       }
-}
-
-/**
- * Stop the entire handover benchmark
- */
-static void cd_perf_stop_benchmark_hoverall(void)
-{
-       PISA_DEBUG(PL_PREAUTH, "Stopping PERF_HANDOVER_ALL\n");
-       pisa_perf_stop_benchmark(pisa_perf, PERF_HANDOVER_ALL);
-
-       pisacd_bench_all_on = FALSE;
-}
-
-/**
- * Write the entire handover benchmark results
- */
-static void cd_perf_write_benchmark_hoverall(void)
-{
-       PISA_DEBUG(PL_PREAUTH, "Writing PERF_HANDOVER_ALL\n");
-       pisa_perf_write_benchmark(pisa_perf, PERF_HANDOVER_ALL);
-}
-
-/**
- * Start pre-authentication benchmark
- */
-static void cd_perf_start_benchmark_preauth(void)
-{
-       if (!pisacd_bench_pa_on) {
-               PISA_DEBUG(PL_PREAUTH, "Starting PERF_PRE_AUTHENTICATION\n");
-               pisa_perf_start_benchmark(pisa_perf, PERF_PRE_AUTHENTICATION);
-
-               pisacd_bench_pa_on = TRUE;
-       }
-}
-
-/**
- * Stop pre-authentication benchmark
- */
-static void cd_perf_stop_benchmark_preauth(void)
-{
-       PISA_DEBUG(PL_PREAUTH, "Stopping PERF_PRE_AUTHENTICATION\n");
-       pisa_perf_stop_benchmark(pisa_perf, PERF_PRE_AUTHENTICATION);
-
-       pisacd_bench_pa_on = FALSE;
-}
-
-/**
- * Write pre-authentication benchmark results
- */
-static void cd_perf_write_benchmark_preauth(void)
-{
-       PISA_DEBUG(PL_PREAUTH, "Writing PERF_PRE_AUTHENTICATION\n");
-       pisa_perf_write_benchmark(pisa_perf, PERF_PRE_AUTHENTICATION);
-}
-
-/**
- * Start binding-update benchmark
- */
-static void cd_perf_start_benchmark_bupdate(void)
-{
-       if (!pisacd_bench_bu_on) {
-               PISA_DEBUG(PL_PREAUTH, "Starting PERF_BINDING_UPDATE\n");
-               pisa_perf_start_benchmark(pisa_perf, PERF_BINDING_UPDATE);
-
-               pisacd_bench_bu_on = TRUE;
-       }
-}
-
-/**
- * Stop binding-update benchmark
- */
-static void cd_perf_stop_benchmark_bupdate(void)
-{
-       PISA_DEBUG(PL_PREAUTH, "Stopping PERF_BINDING_UPDATE\n");
-       pisa_perf_stop_benchmark(pisa_perf, PERF_BINDING_UPDATE);
-
-       pisacd_bench_bu_on = FALSE;
-}
-
-/**
- * Write binding-update benchmark results
- */
-static void cd_perf_write_benchmark_bupdate(void)
-{
-       PISA_DEBUG(PL_PREAUTH, "Writing PERF_BINDING_UPDATE\n");
-       pisa_perf_write_benchmark(pisa_perf, PERF_BINDING_UPDATE);
-}
-
-/**
- * Start network config benchmark
- */
-static void cd_perf_start_benchmark_netconf(void)
-{
-       if (!pisacd_bench_nc_on) {
-               PISA_DEBUG(PL_PREAUTH, "Starting PERF_NETWORK_CONFIG\n");
-               pisa_perf_start_benchmark(pisa_perf, PERF_NETWORK_CONFIG);
-
-               pisacd_bench_nc_on = TRUE;
-       }
-}
-
-/**
- * Stop network config benchmark
- */
-static void cd_perf_stop_benchmark_netconf(void)
-{
-       PISA_DEBUG(PL_PREAUTH, "Stopping PERF_NETWORK_CONFIG\n");
-       pisa_perf_stop_benchmark(pisa_perf, PERF_NETWORK_CONFIG);
-
-       pisacd_bench_nc_on = FALSE;
-}
-
-/**
- * Write network config benchmark results
- */
-static void cd_perf_write_benchmark_netconf(void)
-{
-       PISA_DEBUG(PL_PREAUTH, "Writing PERF_NETWORK_CONFIG\n");
-       pisa_perf_write_benchmark(pisa_perf, PERF_NETWORK_CONFIG);
-}
-#endif /* REMOVE_PREAUTH_CODE */
-
 #ifdef CONFIG_PISA_PERFORMANCE
 
 /**
@@ -1127,13 +503,6 @@
 
        pisa_check_and_create_dir(PISA_DIR_PERF_RESULTS, 
DEFAULT_CONFIG_DIR_MODE);
 
-#ifdef REMOVE_PREAUTH_CODE
-       pisa_perf_set_name(pisa_perf, PERF_HANDOVER_ALL, 
PISA_DIR_PERF_RESULTS"/PERF_handover_all.csv");
-       pisa_perf_set_name(pisa_perf, PERF_PRE_AUTHENTICATION, 
PISA_DIR_PERF_RESULTS"/PERF_pre_authentication.csv");
-       pisa_perf_set_name(pisa_perf, PERF_BINDING_UPDATE, 
PISA_DIR_PERF_RESULTS"/PERF_binding_update.csv");
-       pisa_perf_set_name(pisa_perf, PERF_NETWORK_CONFIG, 
PISA_DIR_PERF_RESULTS"/PERF_network_config.csv");
-#endif /* REMOVE_PREAUTH_CODE */
-
        pisa_perf_open(pisa_perf);
 }
 

Other related posts:

  • » [pisa-src] r1252 - in trunk/pisacd: Makefile.am cdconf.c cdconf.h cdconmgr.c cdconmgr.h cdctx.c cdctx.h cdmain.c cdmsg.c cdmsg.h - Thomas Jansen