[pisa-src] r1223 - in trunk: include/conmgr.h libpisa/conmgr.c pisasd/sdtun.c test/sendvrfyreq.c

  • From: Thomas Jansen <mithi@xxxxxxxxx>
  • To: pisa-src@xxxxxxxxxxxxx
  • Date: Mon, 19 Oct 2009 11:28:25 +0200

Author: tjansen
Date: Mon Oct 19 11:28:25 2009
New Revision: 1223

Log:
Deprecated more preauth code.

Modified:
   trunk/include/conmgr.h
   trunk/libpisa/conmgr.c
   trunk/pisasd/sdtun.c
   trunk/test/sendvrfyreq.c

Modified: trunk/include/conmgr.h
==============================================================================
--- trunk/include/conmgr.h      Mon Oct 19 10:44:08 2009        (r1222)
+++ trunk/include/conmgr.h      Mon Oct 19 11:28:25 2009        (r1223)
@@ -35,14 +35,18 @@
  */
 
 typedef struct {
+#ifdef REMOVE_PREAUTH_CODE
        /** File descriptor of our pseudo tunnel device */
        int fd_pstunc;
+#endif /* REMOVE_PREAUTH_CODE  */
 
        /** The IPv4 address used on the client side of the socket. */
        struct in_addr ipv4;
 
+#ifdef REMOVE_PREAUTH_CODE
        /** Core information of the token verify procedure */
        pisa_vrfyinfo vrfyinfo;
+#endif /* REMOVE_PREAUTH_CODE  */
 
        /** Control port of the connection */
        int control_port;
@@ -69,7 +73,9 @@
 
        /** Hash handles for the different keys. Provided by uthash.h. */
        UT_hash_handle hh;
+#ifdef REMOVE_PREAUTH_CODE
        UT_hash_handle hh_pstun;
+#endif /* REMOVE_PREAUTH_CODE  */
        UT_hash_handle hh_ipv4;
 
        /** Connection type: e.g. relay, service or legacy-router */
@@ -105,30 +111,44 @@
 typedef struct pisa_conmgr_list {
        pisa_conmgr_entry* hash_ipv6;
        pisa_conmgr_entry* hash_ipv4;
+#ifdef REMOVE_PREAUTH_CODE
        pisa_conmgr_entry* hash_pstun;
+#endif /* REMOVE_PREAUTH_CODE  */
        pisa_conmgr_connection_remove_callback connection_remove_callback;
 } pisa_conmgr_list;
 
 struct pisa_nat_list;
 
 pisa_conmgr_list *pisa_conmgr_init(pisa_conmgr_connection_remove_callback 
callback);
+#ifdef REMOVE_PREAUTH_CODE
 void pisa_conmgr_init_pstun(pisa_conmgr_list *conlist);
+#endif /* REMOVE_PREAUTH_CODE  */
 void pisa_conmgr_cleanup(pisa_conmgr_list **conlist, struct pisa_nat_list 
*natlist);
+#ifdef REMOVE_PREAUTH_CODE
 void pisa_conmgr_cleanup_pstun(pisa_conmgr_list **conlist);
+#endif /* REMOVE_PREAUTH_CODE  */
 
 pisa_conmgr_entry* pisa_conmgr_add(pisa_conmgr_list *conlist, const struct 
in6_addr* client_addr, int ctrl_port);
+#ifdef REMOVE_PREAUTH_CODE
 pisa_conmgr_entry* pisa_conmgr_add_pstun(pisa_conmgr_list *conlist, const 
struct sockaddr_in6* client_addr);
+#endif /* REMOVE_PREAUTH_CODE  */
 void pisa_conmgr_connected(pisa_conmgr_list *conlist, pisa_conmgr_entry* 
entry, unsigned short data_port, struct in_addr *client_ipv4);
 void pisa_conmgr_remove(pisa_conmgr_list *conlist, struct pisa_nat_list 
*natlist, pisa_conmgr_entry* entry);
+#ifdef REMOVE_PREAUTH_CODE
 void pisa_conmgr_remove_pstun(pisa_conmgr_list *conlist, pisa_conmgr_entry* 
entry);
+#endif /* REMOVE_PREAUTH_CODE  */
 
 pisa_conmgr_entry* pisa_conmgr_findby_address(pisa_conmgr_list *conlist, const 
struct in6_addr* addr);
 pisa_conmgr_entry* pisa_conmgr_findby_clientip(pisa_conmgr_list *conlist, 
const struct in_addr *client_ipv4);
+#ifdef REMOVE_PREAUTH_CODE
 pisa_conmgr_entry* pisa_conmgr_findby_address_pstun(pisa_conmgr_list *conlist, 
const struct in6_addr* sin6_addr);
+#endif /* REMOVE_PREAUTH_CODE */
 
 void pisa_conmgr_iterate(pisa_conmgr_list *conlist, conmgr_callback cb, void* 
data);
 void pisa_conmgr_iterate_connected(pisa_conmgr_list *conlist, conmgr_callback 
cb, void* data);
+#ifdef REMOVE_PREAUTH_CODE
 void pisa_conmgr_iterate_pstun(pisa_conmgr_list *conlist, conmgr_callback cb, 
void* data);
+#endif /* REMOVE_PREAUTH_CODE */
 
 void pisa_conmgr_build_sockaddr_control(pisa_conmgr_entry* entry, struct 
sockaddr_in6* addr);
 void pisa_conmgr_build_sockaddr_data(pisa_conmgr_entry* entry, struct 
sockaddr_in6* addr);

Modified: trunk/libpisa/conmgr.c
==============================================================================
--- trunk/libpisa/conmgr.c      Mon Oct 19 10:44:08 2009        (r1222)
+++ trunk/libpisa/conmgr.c      Mon Oct 19 11:28:25 2009        (r1223)
@@ -44,6 +44,7 @@
        free(entry);
 }
 
+#ifdef REMOVE_PREAUTH_CODE
 /**
  * Destructor for pisa_conmgr_entry instances. Every pisa_conmgr_entry
  * instance which isn't used any more should be freed with a
@@ -55,6 +56,7 @@
        close(entry->fd_pstunc);
        free(entry);
 }
+#endif /* REMOVE_PREAUTH_CODE */
 
 /**
  * This must be called before any other call to the pisa_conmgr module.
@@ -72,6 +74,7 @@
        return conlist;
 }
 
+#ifdef REMOVE_PREAUTH_CODE
 /**
  * This must be called before any other call to the pisa_conmgr module.
  * Will initialize internal state and data structurs.
@@ -82,6 +85,7 @@
 {
        assert(conlist->hash_pstun == NULL);
 }
+#endif /* REMOVE_PREAUTH_CODE */
 
 /**
  * Clean up and free all memory occupied by the pisa_conmgr module.
@@ -95,6 +99,7 @@
        *conlist = NULL;
 }
 
+#ifdef REMOVE_PREAUTH_CODE
 /**
  * Clean up and free all memory occupied by the pisa_conmgr module.
  * @sa pisa_conmgr_init_pstun
@@ -106,6 +111,7 @@
        free(*conlist);
        *conlist = NULL;
 }
+#endif /* REMOVE_PREAUTH_CODE */
 
 /**
  * Set connection data we get only during connection establishment.
@@ -151,6 +157,7 @@
        return entry;
 }
 
+#ifdef REMOVE_PREAUTH_CODE
 /**
  * Add a new association to the pisa_conmgr module.
  * @param client_addr IPv4 address to be associated with the socket
@@ -177,6 +184,7 @@
 #endif
        return entry;
 }
+#endif /* REMOVE_PREAUTH_CODE */
 
 /**
  * Remove given entry from internal set of associations
@@ -201,6 +209,7 @@
        pisa_conmgr_free(entry);
 }
 
+#ifdef REMOVE_PREAUTH_CODE
 /**
  * Remove given entry from internal set of associations
  * @param entry Pointer to the association to be removed
@@ -210,6 +219,7 @@
        HASH_DELETE(hh_pstun, conlist->hash_pstun, entry);
        pisa_conmgr_free_pstun(entry);
 }
+#endif /* REMOVE_PREAUTH_CODE */
 
 /**
  * Find the association to a given HIT
@@ -235,6 +245,7 @@
        return ret;
 }
 
+#ifdef REMOVE_PREAUTH_CODE
 /**
  * Find the association to a given HIT
  * @param addr the hit we want to find the associated socket for
@@ -246,6 +257,7 @@
        HASH_FIND(hh_pstun, conlist->hash_pstun, sin6_addr, sizeof(struct 
in6_addr), ret);
        return ret;
 }
+#endif /* REMOVE_PREAUTH_CODE */
 
 /**
  * Higher order function: the callback is called for every
@@ -282,6 +294,7 @@
                        cb(data, it);
 }
 
+#ifdef REMOVE_PREAUTH_CODE
 /**
  * Higher order function: the callback is called for every
  * element of our internal association list. Data is passed
@@ -298,6 +311,7 @@
        for (it = conlist->hash_pstun; it != NULL; it = it->hh_pstun.next)
                cb(data, it);
 }
+#endif /* REMOVE_PREAUTH_CODE */
 
 /**
  * Build a sockaddr_in6 address from an entry with a given port. Used by the

Modified: trunk/pisasd/sdtun.c
==============================================================================
--- trunk/pisasd/sdtun.c        Mon Oct 19 10:44:08 2009        (r1222)
+++ trunk/pisasd/sdtun.c        Mon Oct 19 11:28:25 2009        (r1223)
@@ -212,6 +212,7 @@
        }
 }
 
+#ifdef REMOVE_PREAUTH_CODE
 /**
  * main logic for an incoming message from an unassociated ipv6 address.
  * if the address is in the list of known hits, the client will be added
@@ -428,3 +429,4 @@
 }
 
 #endif
+#endif /* REMOVE_PREAUTH_CODE */

Modified: trunk/test/sendvrfyreq.c
==============================================================================
--- trunk/test/sendvrfyreq.c    Mon Oct 19 10:44:08 2009        (r1222)
+++ trunk/test/sendvrfyreq.c    Mon Oct 19 11:28:25 2009        (r1223)
@@ -33,6 +33,7 @@
        {NULL,                  0,                      NULL,   '\0'},
 };
 
+#ifdef REMOVE_PREAUTH_CODE /* remove entire file */
 static pisa_packet *my_build_vrfyreq1_packet(void);
 static int my_pisasd_handle_vrfyres2(void *inentry, pisa_packet *pkt);
 static void print_usage(char **argv);
@@ -40,9 +41,11 @@
 static int read_nonblock(int fd_server, struct sockaddr_in6 *target_server);
 
 float send_interval = DEFAULT_SEND_INTERVAL;
+#endif /* REMOVE_PREAUTH_CODE */
 
 int main(int argc, char *argv[])
 {
+#ifdef REMOVE_PREAUTH_CODE /* remove entire file */
        struct sockaddr_in6 target_client, target_server;
        int fd_client = -1;
        int fd_server = -1;
@@ -156,14 +159,12 @@
 
                vrfyres1_packet = (pisa_packet *)recv_buf;
 
-#ifdef REMOVE_PREAUTH_CODE /* remove entire file */
                if (pisasd_handle_vrfyres1(&entry, vrfyres1_packet) < 0) {
                        _PISA_ERROR("Cannot handle verify response1 packet. 
(%s)\n",
                                strerror(errno));
                        usleep(send_interval * 1000000);
                        continue;
                }
-#endif /* REMOVE_PREAUTH_CODE */
 
                _PISA_DEBUG(PL_GENERIC, "Sent a vrfyreq2 packet.\n");
 
@@ -200,10 +201,12 @@
                        usleep(send_interval * 1000000);
                }
        }
+#endif /* REMOVE_PREAUTH_CODE */
 
        exit(EXIT_SUCCESS);
 }
 
+#ifdef REMOVE_PREAUTH_CODE /* remove entire file */
 static pisa_packet *my_build_vrfyreq1_packet(void)
 {
        pisa_packet *vrfyreq1;
@@ -332,3 +335,4 @@
 
        return retval;
 }
+#endif /* REMOVE_PREAUTH_CODE */

Other related posts:

  • » [pisa-src] r1223 - in trunk: include/conmgr.h libpisa/conmgr.c pisasd/sdtun.c test/sendvrfyreq.c - Thomas Jansen