[pisa-src] r1216 - in trunk/pisasd: sdconf.c sdconf.h sdctx.c sdctx.h sdmain.c

  • From: Thomas Jansen <mithi@xxxxxxxxx>
  • To: pisa-src@xxxxxxxxxxxxx
  • Date: Fri, 16 Oct 2009 13:53:18 +0200

Author: tjansen
Date: Fri Oct 16 13:53:18 2009
New Revision: 1216

Log:
Deprecated more preauth code in pisasd.

Modified:
   trunk/pisasd/sdconf.c
   trunk/pisasd/sdconf.h
   trunk/pisasd/sdctx.c
   trunk/pisasd/sdctx.h
   trunk/pisasd/sdmain.c

Modified: trunk/pisasd/sdconf.c
==============================================================================
--- trunk/pisasd/sdconf.c       Fri Oct 16 13:29:44 2009        (r1215)
+++ trunk/pisasd/sdconf.c       Fri Oct 16 13:53:18 2009        (r1216)
@@ -33,11 +33,13 @@
 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);
@@ -62,11 +64,13 @@
 
        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));
@@ -121,11 +125,13 @@
        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);
@@ -230,6 +236,7 @@
        }
 }
 
+#ifdef REMOVE_PREAUTH_CODE
 /**
  * Read the listening port number from the configuration file.
  *
@@ -313,6 +320,7 @@
                sdconf->bures_maxretry = PISASD_DEFAULT_BURES_MAXRETRY;
        }
 }
+#endif /* REMOVE_PREAUTH_CODE */
 
 /**
  * Set the global debug level variable
@@ -339,6 +347,7 @@
        }
 }
 
+#ifdef REMOVE_PREAUTH_CODE
 /**
  * Get the configuration of bootstrap neighbor list from pisasd.conf
  *
@@ -410,6 +419,7 @@
 
        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       Fri Oct 16 13:29:44 2009        (r1215)
+++ trunk/pisasd/sdconf.h       Fri Oct 16 13:53:18 2009        (r1216)
@@ -34,11 +34,14 @@
 
        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 */
@@ -63,6 +66,7 @@
 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
@@ -73,5 +77,6 @@
 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        Fri Oct 16 13:29:44 2009        (r1215)
+++ trunk/pisasd/sdctx.c        Fri Oct 16 13:53:18 2009        (r1216)
@@ -21,7 +21,9 @@
  */
 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.
@@ -31,24 +33,34 @@
  */
 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;
@@ -66,10 +78,13 @@
  */
 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.
  *
@@ -283,3 +298,4 @@
        return NULL;
 }
 
+#endif /* REMOVE_PREAUTH_CODE */

Modified: trunk/pisasd/sdctx.h
==============================================================================
--- trunk/pisasd/sdctx.h        Fri Oct 16 13:29:44 2009        (r1215)
+++ trunk/pisasd/sdctx.h        Fri Oct 16 13:53:18 2009        (r1216)
@@ -25,6 +25,7 @@
  * 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 */
 
@@ -32,6 +33,7 @@
         * 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.
@@ -39,11 +41,13 @@
         */
        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.
@@ -51,10 +55,12 @@
         */
        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
@@ -68,6 +74,7 @@
         */
        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.
@@ -79,11 +86,13 @@
         * 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.
         */
@@ -93,6 +102,7 @@
         * The current count value of binding update tries.
         */
        int bures_tries_count;
+#endif /* REMOVE_PREAUTH_CODE */
 
        /**
         * Control handler functions.
@@ -123,6 +133,7 @@
 
 extern sd_context sd_ctx;
 
+#ifdef REMOVE_PREAUTH_CODE
 /**
  * data structure defining a pair of core information about handover-ready
  * target routers
@@ -132,6 +143,7 @@
        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
@@ -144,6 +156,7 @@
 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);
 
@@ -154,5 +167,6 @@
 
 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       Fri Oct 16 13:29:44 2009        (r1215)
+++ trunk/pisasd/sdmain.c       Fri Oct 16 13:53:18 2009        (r1216)
@@ -49,7 +49,11 @@
 # 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
@@ -60,7 +64,9 @@
        {"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'},
@@ -183,8 +189,10 @@
        /* 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 */
@@ -200,11 +208,11 @@
                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();
 
-#ifdef REMOVE_PREAUTH_CODE
        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;
@@ -270,8 +278,10 @@
        /* 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);
 
@@ -401,6 +411,7 @@
                                sd_cfg.port_data = atoi(optarg);
                                break;
 
+#ifdef REMOVE_PREAUTH_CODE
                        case 'r':
                                sd_cfg.port_pstun = atoi(optarg);
                                break;
@@ -408,6 +419,7 @@
                        case 'V':
                                sd_ctx.do_tokvrfy = FALSE;
                                break;
+#endif /* REMOVE_PREAUTH_CODE */
 
                        case 'b':
                                sd_ctx.is_bgrun = TRUE;
@@ -451,8 +463,10 @@
                        "\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"
@@ -463,7 +477,9 @@
                        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);

Other related posts:

  • » [pisa-src] r1216 - in trunk/pisasd: sdconf.c sdconf.h sdctx.c sdctx.h sdmain.c - Thomas Jansen