gnunet-svn
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[GNUnet-SVN] r6431 - GNUnet/src/applications/vpn


From: gnunet
Subject: [GNUnet-SVN] r6431 - GNUnet/src/applications/vpn
Date: Sun, 24 Feb 2008 00:49:35 -0700 (MST)

Author: grothoff
Date: 2008-02-24 00:49:35 -0700 (Sun, 24 Feb 2008)
New Revision: 6431

Modified:
   GNUnet/src/applications/vpn/cs.c
   GNUnet/src/applications/vpn/cs.h
   GNUnet/src/applications/vpn/p2p.c
   GNUnet/src/applications/vpn/p2p.h
   GNUnet/src/applications/vpn/vpn.c
   GNUnet/src/applications/vpn/vpn.h
Log:
more code clean up

Modified: GNUnet/src/applications/vpn/cs.c
===================================================================
--- GNUnet/src/applications/vpn/cs.c    2008-02-24 07:36:20 UTC (rev 6430)
+++ GNUnet/src/applications/vpn/cs.c    2008-02-24 07:49:35 UTC (rev 6431)
@@ -37,13 +37,14 @@
  * send given string to client 
  */
 static void
-cprintf (struct GNUNET_ClientHandle *c, unsigned short t, const char *format, 
...)
+cprintf (struct GNUNET_ClientHandle *c, unsigned short t, const char *format,
+         ...)
 {
-  va_list args;  
+  va_list args;
   int size;
   GNUNET_MessageHeader *b;
 
-  size = GNUNET_MAX_BUFFER_SIZE - sizeof(GNUNET_MessageHeader) - 8;
+  size = GNUNET_MAX_BUFFER_SIZE - sizeof (GNUNET_MessageHeader) - 8;
   b = GNUNET_malloc (sizeof (GNUNET_MessageHeader) + size);
   va_start (args, format);
   size = VSNPRINTF ((char *) &b[1], size, format, args);
@@ -64,20 +65,21 @@
 static void
 id2ip (struct GNUNET_ClientHandle *cx, const GNUNET_PeerIdentity * them)
 {
-  cprintf (cx, 
-          GNUNET_CS_PROTO_VPN_REPLY, 
-          "fd%02x:%02x%02x:%02x%02x", 
-          (them->hashPubKey.bits[0] >> 8) & 0xff,
-          (them->hashPubKey.bits[0] >> 0) & 0xff,
-          (them->hashPubKey.bits[1] >> 8) & 0xff,
-          (them->hashPubKey.bits[1] >> 0) & 0xff,
-          (them->hashPubKey.bits[2] >> 8) & 0xff);
+  cprintf (cx,
+           GNUNET_CS_PROTO_VPN_REPLY,
+           "fd%02x:%02x%02x:%02x%02x",
+           (them->hashPubKey.bits[0] >> 8) & 0xff,
+           (them->hashPubKey.bits[0] >> 0) & 0xff,
+           (them->hashPubKey.bits[1] >> 8) & 0xff,
+           (them->hashPubKey.bits[1] >> 0) & 0xff,
+           (them->hashPubKey.bits[2] >> 8) & 0xff);
 }
 
 
 /** The console client is used to admin/debug vpn */
 static int
-cs_handle_vpn_tunnels (struct GNUNET_ClientHandle *c, const 
GNUNET_MessageHeader * message)
+cs_handle_vpn_tunnels (struct GNUNET_ClientHandle *c,
+                       const GNUNET_MessageHeader * message)
 {
   int i;
 
@@ -88,9 +90,9 @@
     {
       id2ip (c, &(store1 + i)->peer);
       cprintf (c, GNUNET_CS_PROTO_VPN_REPLY,
-              "::/48 gnu%d active=%s routeentry=%d\n", (store1 + i)->id,
-              (store1 + i)->active ? _("Yes") : _("No"),
-              (store1 + i)->route_entry);
+               "::/48 gnu%d active=%s routeentry=%d\n", (store1 + i)->id,
+               (store1 + i)->active ? _("Yes") : _("No"),
+               (store1 + i)->route_entry);
     }
   cprintf (c, GNUNET_CS_PROTO_VPN_TUNNELS, "%d Tunnels\n", entries1);
   GNUNET_mutex_unlock (lock);
@@ -98,7 +100,8 @@
 }
 
 static int
-cs_handle_vpn_routes(struct GNUNET_ClientHandle *c, const GNUNET_MessageHeader 
* message)
+cs_handle_vpn_routes (struct GNUNET_ClientHandle *c,
+                      const GNUNET_MessageHeader * message)
 {
   int i;
   GNUNET_PeerIdentity id;
@@ -109,25 +112,26 @@
       identity->getPeerIdentity (&(route_store + i)->owner, &id);
       id2ip (c, &id);
       if ((route_store + i)->hops == 0)
-       {
-         cprintf (c, GNUNET_CS_PROTO_VPN_REPLY,
-                  "::/48 hops 0 (This Node)\n");
-       }
+        {
+          cprintf (c, GNUNET_CS_PROTO_VPN_REPLY,
+                   "::/48 hops 0 (This Node)\n");
+        }
       else
-       {
-         cprintf (c, GNUNET_CS_PROTO_VPN_REPLY,
-                  "::/48 hops %d tunnel gnu%d\n",
-                  (route_store + i)->hops,
-                  (store1 + ((route_store + i)->tunnel))->id);
-       }
+        {
+          cprintf (c, GNUNET_CS_PROTO_VPN_REPLY,
+                   "::/48 hops %d tunnel gnu%d\n",
+                   (route_store + i)->hops,
+                   (store1 + ((route_store + i)->tunnel))->id);
+        }
     }
   cprintf (c, GNUNET_CS_PROTO_VPN_ROUTES, "%d Routes\n", route_entries);
   GNUNET_mutex_unlock (lock);
   return GNUNET_OK;
 }
 
-static int 
-cs_handle_vpn_realised(struct GNUNET_ClientHandle *c, const 
GNUNET_MessageHeader * message)
+static int
+cs_handle_vpn_realised (struct GNUNET_ClientHandle *c,
+                        const GNUNET_MessageHeader * message)
 {
   int i;
   GNUNET_PeerIdentity id;
@@ -138,26 +142,27 @@
       identity->getPeerIdentity (&(realised_store + i)->owner, &id);
       id2ip (c, &id);
       if ((realised_store + i)->hops == 0)
-       {
-         cprintf (c, GNUNET_CS_PROTO_VPN_REPLY,
-                  "::/48 hops 0 (This Node)\n");
-       }
+        {
+          cprintf (c, GNUNET_CS_PROTO_VPN_REPLY,
+                   "::/48 hops 0 (This Node)\n");
+        }
       else
-       {
-         cprintf (c, GNUNET_CS_PROTO_VPN_REPLY,
-                  "::/48 hops %d tunnel gnu%d\n",
-                  (realised_store + i)->hops,
-                  (store1 + ((realised_store + i)->tunnel))->id);
-       }
+        {
+          cprintf (c, GNUNET_CS_PROTO_VPN_REPLY,
+                   "::/48 hops %d tunnel gnu%d\n",
+                   (realised_store + i)->hops,
+                   (store1 + ((realised_store + i)->tunnel))->id);
+        }
     }
   cprintf (c, GNUNET_CS_PROTO_VPN_REALISED, "%d Realised\n",
-          realised_entries);
+           realised_entries);
   GNUNET_mutex_unlock (lock);
   return GNUNET_OK;
 }
 
-static int 
-cs_handle_vpn_reset(struct GNUNET_ClientHandle *c, const GNUNET_MessageHeader 
* message)
+static int
+cs_handle_vpn_reset (struct GNUNET_ClientHandle *c,
+                     const GNUNET_MessageHeader * message)
 {
   int i;
   GNUNET_MessageHeader *rgp;
@@ -174,22 +179,22 @@
       rgp->size = htons (sizeof (GNUNET_MessageHeader) + sizeof (int));
       *((int *) (rgp + 1)) = htonl ((store1 + i)->route_entry);
       cprintf (c, GNUNET_CS_PROTO_VPN_REPLY,
-              "Request level %d from peer %d ",
-              (store1 + i)->route_entry, i);
+               "Request level %d from peer %d ",
+               (store1 + i)->route_entry, i);
       id2ip (c, &((store1 + i)->peer));
       cprintf (c, GNUNET_CS_PROTO_VPN_REPLY, "\n");
       coreAPI->unicast (&((store1 + i)->peer), rgp,
-                       GNUNET_EXTREME_PRIORITY, 60);
+                        GNUNET_EXTREME_PRIORITY, 60);
       GNUNET_free (rgp);
     }
   GNUNET_mutex_unlock (lock);
-  cprintf (c, GNUNET_CS_PROTO_VPN_RESET,
-          "Rebuilding routing tables done\n");
+  cprintf (c, GNUNET_CS_PROTO_VPN_RESET, "Rebuilding routing tables done\n");
   return GNUNET_OK;
 }
 
-static int 
-cs_handle_vpn_trust(struct GNUNET_ClientHandle *c, const GNUNET_MessageHeader 
* message)
+static int
+cs_handle_vpn_trust (struct GNUNET_ClientHandle *c,
+                     const GNUNET_MessageHeader * message)
 {
   int i;
 
@@ -197,23 +202,25 @@
   for (i = 0; i < entries1; i++)
     {
       if ((store1 + i)->active == GNUNET_YES)
-       {
-         cprintf (c, GNUNET_CS_PROTO_VPN_REPLY, "Uprating peer ");
-         id2ip (c, &(store1 + i)->peer);
-         cprintf (c, GNUNET_CS_PROTO_VPN_REPLY, " with credit %d\n",
-                  identity->changeHostTrust (&(store1 + i)->peer, 1000));
-       }
+        {
+          cprintf (c, GNUNET_CS_PROTO_VPN_REPLY, "Uprating peer ");
+          id2ip (c, &(store1 + i)->peer);
+          cprintf (c, GNUNET_CS_PROTO_VPN_REPLY, " with credit %d\n",
+                   identity->changeHostTrust (&(store1 + i)->peer, 1000));
+        }
     }
   cprintf (c, GNUNET_CS_PROTO_VPN_TRUST,
-          "Gave credit to active nodes of %d nodes...\n", entries1);
+           "Gave credit to active nodes of %d nodes...\n", entries1);
   GNUNET_mutex_unlock (lock);
   return GNUNET_OK;
 }
 
-static int 
-cs_handle_vpn_add(struct GNUNET_ClientHandle *c, const GNUNET_MessageHeader * 
message)
+static int
+cs_handle_vpn_add (struct GNUNET_ClientHandle *c,
+                   const GNUNET_MessageHeader * message)
 {
-  unsigned int parameter = ntohs (message->size) - sizeof 
(GNUNET_MessageHeader);
+  unsigned int parameter =
+    ntohs (message->size) - sizeof (GNUNET_MessageHeader);
   const char *ccmd = (const char *) &message[1];
   GNUNET_MessageHeader *rgp;
   GNUNET_PeerIdentity id;
@@ -226,86 +233,98 @@
   *(parm + parameter) = 0;
   if (GNUNET_OK != GNUNET_enc_to_hash (parm, &(id.hashPubKey)))
     {
-      GNUNET_free(parm);
+      GNUNET_free (parm);
       return GNUNET_SYSERR;
-    }    
+    }
   GNUNET_free (parm);
   if (0)
     {
       /* this does not seem to work, strangeness with threads and 
capabilities? */
-      GNUNET_mutex_lock(lock);
-      checkensure_peer(&id, NULL);
-      GNUNET_mutex_unlock(lock);
-    }  
+      GNUNET_mutex_lock (lock);
+      checkensure_peer (&id, NULL);
+      GNUNET_mutex_unlock (lock);
+    }
   /* get it off the local blacklist */
-  identity->whitelistHost (&id);  
+  identity->whitelistHost (&id);
   cprintf (c, GNUNET_CS_PROTO_VPN_REPLY, "Connect ");
   id2ip (c, &id);
   switch (session->tryConnect (&id))
     {
     case GNUNET_YES:
-      cprintf (c, GNUNET_CS_PROTO_VPN_REPLY,
-              " already connected.\n");
+      cprintf (c, GNUNET_CS_PROTO_VPN_REPLY, " already connected.\n");
       break;
     case GNUNET_NO:
-      cprintf (c, GNUNET_CS_PROTO_VPN_REPLY,
-              " schedule connection.\n");
+      cprintf (c, GNUNET_CS_PROTO_VPN_REPLY, " schedule connection.\n");
       break;
     case GNUNET_SYSERR:
-      cprintf (c, GNUNET_CS_PROTO_VPN_REPLY,
-              " core refused.\n");
+      cprintf (c, GNUNET_CS_PROTO_VPN_REPLY, " core refused.\n");
       break;
     default:
-      GNUNET_GE_BREAK(NULL, 0);
+      GNUNET_GE_BREAK (NULL, 0);
       break;
-    }  
+    }
   if (0)
     {
       /* req route level 0 */
-      rgp = GNUNET_malloc(sizeof(GNUNET_MessageHeader) + sizeof(int));
-      rgp->type = htons(GNUNET_P2P_PROTO_AIP_GETROUTE);
-      rgp->size = htons(sizeof(GNUNET_MessageHeader) + sizeof(int));
-      *((int*)&rgp[1]) = 0;
-      coreAPI->unicast(&id, rgp, GNUNET_EXTREME_PRIORITY, 4 * 
GNUNET_CRON_MILLISECONDS);
-      cprintf(c, GNUNET_CS_PROTO_VPN_REPLY, " Sent");
-      GNUNET_free(rgp);
-     }      
+      rgp = GNUNET_malloc (sizeof (GNUNET_MessageHeader) + sizeof (int));
+      rgp->type = htons (GNUNET_P2P_PROTO_AIP_GETROUTE);
+      rgp->size = htons (sizeof (GNUNET_MessageHeader) + sizeof (int));
+      *((int *) &rgp[1]) = 0;
+      coreAPI->unicast (&id, rgp, GNUNET_EXTREME_PRIORITY,
+                        4 * GNUNET_CRON_MILLISECONDS);
+      cprintf (c, GNUNET_CS_PROTO_VPN_REPLY, " Sent");
+      GNUNET_free (rgp);
+    }
   cprintf (c, GNUNET_CS_PROTO_VPN_ADD, "\n");
   return GNUNET_OK;
 }
 
 
-int GNUNET_VPN_cs_handler_init(GNUNET_CoreAPIForPlugins * capi)
+int
+GNUNET_VPN_cs_handler_init (GNUNET_CoreAPIForPlugins * capi)
 {
   if (GNUNET_SYSERR ==
-      capi->registerClientHandler (GNUNET_CS_PROTO_VPN_TUNNELS, 
&cs_handle_vpn_tunnels))
+      capi->registerClientHandler (GNUNET_CS_PROTO_VPN_TUNNELS,
+                                   &cs_handle_vpn_tunnels))
     return GNUNET_SYSERR;
   if (GNUNET_SYSERR ==
-      capi->registerClientHandler (GNUNET_CS_PROTO_VPN_ROUTES, 
&cs_handle_vpn_routes))
+      capi->registerClientHandler (GNUNET_CS_PROTO_VPN_ROUTES,
+                                   &cs_handle_vpn_routes))
     return GNUNET_SYSERR;
   if (GNUNET_SYSERR ==
-      capi->registerClientHandler (GNUNET_CS_PROTO_VPN_REALISED, 
&cs_handle_vpn_realised))
+      capi->registerClientHandler (GNUNET_CS_PROTO_VPN_REALISED,
+                                   &cs_handle_vpn_realised))
     return GNUNET_SYSERR;
   if (GNUNET_SYSERR ==
-      capi->registerClientHandler (GNUNET_CS_PROTO_VPN_RESET, 
&cs_handle_vpn_reset))
+      capi->registerClientHandler (GNUNET_CS_PROTO_VPN_RESET,
+                                   &cs_handle_vpn_reset))
     return GNUNET_SYSERR;
   if (GNUNET_SYSERR ==
-      capi->registerClientHandler (GNUNET_CS_PROTO_VPN_TRUST, 
&cs_handle_vpn_trust))
+      capi->registerClientHandler (GNUNET_CS_PROTO_VPN_TRUST,
+                                   &cs_handle_vpn_trust))
     return GNUNET_SYSERR;
   if (GNUNET_SYSERR ==
-      capi->registerClientHandler (GNUNET_CS_PROTO_VPN_ADD, 
&cs_handle_vpn_add))
+      capi->registerClientHandler (GNUNET_CS_PROTO_VPN_ADD,
+                                   &cs_handle_vpn_add))
     return GNUNET_SYSERR;
   return GNUNET_OK;
 }
 
-int GNUNET_VPN_cs_handler_done()
+int
+GNUNET_VPN_cs_handler_done ()
 {
-  coreAPI->unregisterClientHandler (GNUNET_CS_PROTO_VPN_TUNNELS, 
&cs_handle_vpn_tunnels);
-  coreAPI->unregisterClientHandler (GNUNET_CS_PROTO_VPN_ROUTES, 
&cs_handle_vpn_routes);
-  coreAPI->unregisterClientHandler (GNUNET_CS_PROTO_VPN_REALISED, 
&cs_handle_vpn_realised);
-  coreAPI->unregisterClientHandler (GNUNET_CS_PROTO_VPN_RESET, 
&cs_handle_vpn_reset);
-  coreAPI->unregisterClientHandler (GNUNET_CS_PROTO_VPN_TRUST, 
&cs_handle_vpn_trust);
-  coreAPI->unregisterClientHandler (GNUNET_CS_PROTO_VPN_ADD, 
&cs_handle_vpn_add);
+  coreAPI->unregisterClientHandler (GNUNET_CS_PROTO_VPN_TUNNELS,
+                                    &cs_handle_vpn_tunnels);
+  coreAPI->unregisterClientHandler (GNUNET_CS_PROTO_VPN_ROUTES,
+                                    &cs_handle_vpn_routes);
+  coreAPI->unregisterClientHandler (GNUNET_CS_PROTO_VPN_REALISED,
+                                    &cs_handle_vpn_realised);
+  coreAPI->unregisterClientHandler (GNUNET_CS_PROTO_VPN_RESET,
+                                    &cs_handle_vpn_reset);
+  coreAPI->unregisterClientHandler (GNUNET_CS_PROTO_VPN_TRUST,
+                                    &cs_handle_vpn_trust);
+  coreAPI->unregisterClientHandler (GNUNET_CS_PROTO_VPN_ADD,
+                                    &cs_handle_vpn_add);
   return GNUNET_OK;
 }
 

Modified: GNUnet/src/applications/vpn/cs.h
===================================================================
--- GNUnet/src/applications/vpn/cs.h    2008-02-24 07:36:20 UTC (rev 6430)
+++ GNUnet/src/applications/vpn/cs.h    2008-02-24 07:49:35 UTC (rev 6431)
@@ -28,8 +28,8 @@
 
 #include "gnunet_core.h"
 
-int GNUNET_VPN_cs_handler_init(GNUNET_CoreAPIForPlugins * capi);
+int GNUNET_VPN_cs_handler_init (GNUNET_CoreAPIForPlugins * capi);
 
-int GNUNET_VPN_cs_handler_done(void);
+int GNUNET_VPN_cs_handler_done (void);
 
 #endif

Modified: GNUnet/src/applications/vpn/p2p.c
===================================================================
--- GNUnet/src/applications/vpn/p2p.c   2008-02-24 07:36:20 UTC (rev 6430)
+++ GNUnet/src/applications/vpn/p2p.c   2008-02-24 07:49:35 UTC (rev 6431)
@@ -22,9 +22,12 @@
  * @file applications/vpn/p2p.c
  * @author Michael John Wensley
  * @brief handling of P2P messages for VPN
+ *
+ * TODO:
+ * - do not use HANG UP as a shutdown notification; we have a better API now!
+ * - define and use structs for messages 
  */
 #include "vpn.h"
-#include "cs.h"
 #include "p2p.h"
 #include "helper.h"
 
@@ -36,268 +39,328 @@
  * Mainly this routine exchanges the GNUNET_MessageHeader on incoming ipv6 
packets
  * for a TUN/TAP header for writing it to TUNTAP.
  */
-int
-handlep2pMSG (const GNUNET_PeerIdentity * sender,
-              const GNUNET_MessageHeader * gp)
+static int
+p2p_handle_vpn_aip_ip (const GNUNET_PeerIdentity * sender,
+                       const GNUNET_MessageHeader * gp)
 {
   int i = 0, fd;
   char loginfo[100];
 
-  GNUNET_MessageHeader *rgp = NULL;
   char frame[IP_FRAME + sizeof (struct tun_pi)];
   const struct ip6_hdr *fp = (struct ip6_hdr *) (gp + 1);
   struct ip6_hdr *new_fp =
     (struct ip6_hdr *) (((char *) &frame) + sizeof (struct tun_pi));
   struct tun_pi *tp = (struct tun_pi *) (&frame);
 
-  switch (ntohs (gp->type))
+  tp->flags = 0;
+
+  /* better check src/dst IP for anonymity preservation requirements here...
+   * I.e. in fd::/8 and check next header as well.
+   *
+   * Also permit multicast [ RFC 3306 ] ff3x:0030:fdnn:nnnn:nnnn::/96
+   * where x = diameter. n are the random bits from the allocater's IP
+   * (and must match the sender's )
+   * 30 = usual bit length of a sender's node/network-prefix,
+   * we allow longer, and that must match sender if specified.
+   */
+  switch (((struct iphdr *) fp)->version)
     {
-    case GNUNET_P2P_PROTO_AIP_IP:
-      tp->flags = 0;
-
-      /* better check src/dst IP for anonymity preservation requirements 
here...
-       * I.e. in fd::/8 and check next header as well.
-       *
-       * Also permit multicast [ RFC 3306 ] ff3x:0030:fdnn:nnnn:nnnn::/96
-       * where x = diameter. n are the random bits from the allocater's IP
-       * (and must match the sender's )
-       * 30 = usual bit length of a sender's node/network-prefix,
-       * we allow longer, and that must match sender if specified.
-       */
-      switch (((struct iphdr *) fp)->version)
+    case 6:
+      tp->proto = htons (ETH_P_IPV6);
+      if (ntohs (fp->ip6_src.s6_addr16[0]) < 0xFD00)
         {
-        case 6:
-          tp->proto = htons (ETH_P_IPV6);
-          if (ntohs (fp->ip6_src.s6_addr16[0]) < 0xFD00)
-            {
-              GNUNET_GE_LOG (coreAPI->ectx,
-                             GNUNET_GE_DEBUG | GNUNET_GE_DEVELOPER |
-                             GNUNET_GE_REQUEST,
-                             _("VPN IP src not anonymous. drop..\n"));
-              return GNUNET_OK;
-            }
-          if (ntohs (fp->ip6_dst.s6_addr16[0]) < 0xFD00)
-            {
-              GNUNET_GE_LOG (coreAPI->ectx,
-                             GNUNET_GE_DEBUG | GNUNET_GE_DEVELOPER |
-                             GNUNET_GE_REQUEST,
-                             _("VPN IP not anonymous, drop.\n"));
-              return GNUNET_OK;
-            }
-          break;
-        case 4:
-          tp->proto = htons (ETH_P_IP);
           GNUNET_GE_LOG (coreAPI->ectx,
                          GNUNET_GE_DEBUG | GNUNET_GE_DEVELOPER |
                          GNUNET_GE_REQUEST,
-                         _("VPN Received, not anonymous, drop.\n"));
+                         _("VPN IP src not anonymous. drop..\n"));
           return GNUNET_OK;
-        default:
+        }
+      if (ntohs (fp->ip6_dst.s6_addr16[0]) < 0xFD00)
+        {
           GNUNET_GE_LOG (coreAPI->ectx,
-                         GNUNET_GE_ERROR | GNUNET_GE_BULK | GNUNET_GE_USER,
-                         _("VPN Received unknown IP version %d...\n"),
-                         ((struct iphdr *) fp)->version);
+                         GNUNET_GE_DEBUG | GNUNET_GE_DEVELOPER |
+                         GNUNET_GE_REQUEST,
+                         _("VPN IP not anonymous, drop.\n"));
           return GNUNET_OK;
         }
+      break;
+    case 4:
+      tp->proto = htons (ETH_P_IP);
+      GNUNET_GE_LOG (coreAPI->ectx,
+                     GNUNET_GE_DEBUG | GNUNET_GE_DEVELOPER |
+                     GNUNET_GE_REQUEST,
+                     _("VPN Received, not anonymous, drop.\n"));
+      return GNUNET_OK;
+    default:
+      GNUNET_GE_LOG (coreAPI->ectx,
+                     GNUNET_GE_ERROR | GNUNET_GE_BULK | GNUNET_GE_USER,
+                     _("VPN Received unknown IP version %d...\n"),
+                     ((struct iphdr *) fp)->version);
+      return GNUNET_OK;
+    }
 
-      ipinfo (loginfo, fp);
+  ipinfo (loginfo, fp);
 
-      /* do packet memcpy outside of mutex for speed */
-      memcpy (new_fp, fp, ntohs (gp->size) - sizeof (GNUNET_MessageHeader));
+  /* do packet memcpy outside of mutex for speed */
+  memcpy (new_fp, fp, ntohs (gp->size) - sizeof (GNUNET_MessageHeader));
 
-      GNUNET_mutex_lock (lock);
-      GNUNET_GE_LOG (coreAPI->ectx,
-                     GNUNET_GE_DEBUG | GNUNET_GE_BULK | GNUNET_GE_ADMIN,
-                     _("<- GNUnet(%d) : %s\n"),
-                     ntohs (gp->size) - sizeof (GNUNET_MessageHeader),
-                     loginfo);
-      for (i = 0; i < entries1; i++)
+  GNUNET_mutex_lock (lock);
+  GNUNET_GE_LOG (coreAPI->ectx,
+                 GNUNET_GE_DEBUG | GNUNET_GE_BULK | GNUNET_GE_ADMIN,
+                 _("<- GNUnet(%d) : %s\n"),
+                 ntohs (gp->size) - sizeof (GNUNET_MessageHeader), loginfo);
+  for (i = 0; i < entries1; i++)
+    {
+      if (isEqual (sender, &((store1 + i)->peer)))
         {
-          if (isEqual (sender, &((store1 + i)->peer)))
-            {
-              fd = ((store1 + i)->fd);
+          fd = ((store1 + i)->fd);
 
-              (store1 + i)->active = GNUNET_YES;
+          (store1 + i)->active = GNUNET_YES;
 
-              /* We are only allowed one call to write() per packet.
-               * We need to write packet and packetinfo together in one go.
-               */
-              write (fd, tp,
-                     ntohs (gp->size) + sizeof (struct tun_pi) -
-                     sizeof (GNUNET_MessageHeader));
-              coreAPI->preferTrafficFrom (&((store1 + i)->peer), 1000);
-              GNUNET_mutex_unlock (lock);
-              return GNUNET_OK;
-            }
+          /* We are only allowed one call to write() per packet.
+           * We need to write packet and packetinfo together in one go.
+           */
+          write (fd, tp,
+                 ntohs (gp->size) + sizeof (struct tun_pi) -
+                 sizeof (GNUNET_MessageHeader));
+          coreAPI->preferTrafficFrom (&((store1 + i)->peer), 1000);
+          GNUNET_mutex_unlock (lock);
+          return GNUNET_OK;
         }
-      /* do not normally get here... but checkensure so any future packets 
could be routed... */
-      checkensure_peer (sender, NULL);
-      GNUNET_mutex_unlock (lock);
-      GNUNET_GE_LOG (coreAPI->ectx,
-                     GNUNET_GE_DEBUG | GNUNET_GE_DEVELOPER |
-                     GNUNET_GE_REQUEST,
-                     _
-                     ("Could not write the tunnelled IP to the OS... Did to 
setup a tunnel?\n"));
-      return GNUNET_OK;
-    case GNUNET_P2P_PROTO_PONG:
-      GNUNET_mutex_lock (lock);
-      checkensure_peer (sender, NULL);
-      GNUNET_mutex_unlock (lock);
-      return GNUNET_OK;
-    case GNUNET_P2P_PROTO_HANG_UP:
-      GNUNET_mutex_lock (lock);
-      for (i = 0; i < entries1; i++)
+    }
+  /* do not normally get here... but checkensure so any future packets could 
be routed... */
+  checkensure_peer (sender, NULL);
+  GNUNET_mutex_unlock (lock);
+  GNUNET_GE_LOG (coreAPI->ectx,
+                 GNUNET_GE_DEBUG | GNUNET_GE_DEVELOPER |
+                 GNUNET_GE_REQUEST,
+                 _
+                 ("Could not write the tunnelled IP to the OS... Did to setup 
a tunnel?\n"));
+  return GNUNET_OK;
+}
+
+static int
+p2p_handle_pong (const GNUNET_PeerIdentity * sender,
+                 const GNUNET_MessageHeader * gp)
+{
+  GNUNET_mutex_lock (lock);
+  checkensure_peer (sender, NULL);
+  GNUNET_mutex_unlock (lock);
+  return GNUNET_OK;
+}
+
+/* FIXME: use connection shutdown handler
+   instead -- we may not always get a hangup! */
+static int
+p2p_handle_hang_up (const GNUNET_PeerIdentity * sender,
+                    const GNUNET_MessageHeader * gp)
+{
+  int i;
+
+  GNUNET_mutex_lock (lock);
+  for (i = 0; i < entries1; i++)
+    {
+      if ((((store1 + i)->fd) > 0) && isEqual (sender, &((store1 + i)->peer)))
         {
-          if ((((store1 + i)->fd) > 0) &&
-              isEqual (sender, &((store1 + i)->peer)))
-            {
-              (store1 + i)->active = GNUNET_NO;
-            }
+          (store1 + i)->active = GNUNET_NO;
         }
-      GNUNET_mutex_unlock (lock);
-      return GNUNET_OK;
-    case GNUNET_P2P_PROTO_AIP_GETROUTE:
-        /** peer wants an entry from our routing table */
-      GNUNET_GE_LOG (coreAPI->ectx,
-                     GNUNET_GE_DEBUG | GNUNET_GE_BULK | GNUNET_GE_ADMIN,
-                     _("Receive route request\n"));
-      if (ntohs (gp->size) == (sizeof (GNUNET_MessageHeader) + sizeof (int)))
+    }
+  GNUNET_mutex_unlock (lock);
+  return GNUNET_OK;
+}
+
+static int
+p2p_handle_vpn_aip_getroute (const GNUNET_PeerIdentity * sender,
+                             const GNUNET_MessageHeader * gp)
+{
+  int i;
+  GNUNET_MessageHeader *rgp;
+  const struct ip6_hdr *fp = (struct ip6_hdr *) (gp + 1);
+
+  GNUNET_GE_LOG (coreAPI->ectx,
+                 GNUNET_GE_DEBUG | GNUNET_GE_BULK | GNUNET_GE_ADMIN,
+                 _("Receive route request\n"));
+  if (ntohs (gp->size) == (sizeof (GNUNET_MessageHeader) + sizeof (int)))
+    {
+      i = ntohl (*((int *) fp));
+      GNUNET_mutex_lock (lock);
+      if (i < realised_entries)
         {
-          i = ntohl (*((int *) fp));
-          GNUNET_mutex_lock (lock);
-          if (i < realised_entries)
-            {
-              GNUNET_GE_LOG (coreAPI->ectx,
-                             GNUNET_GE_DEBUG | GNUNET_GE_BULK |
-                             GNUNET_GE_ADMIN,
-                             _("Prepare route announcement level %d\n"), i);
-              rgp =
-                GNUNET_malloc (sizeof (GNUNET_MessageHeader) +
-                               sizeof (transit_route));
-              if (rgp == NULL)
-                {
-                  GNUNET_mutex_unlock (lock);
-                  return GNUNET_OK;
-                }
-              rgp->size =
-                htons (sizeof (GNUNET_MessageHeader) +
-                       sizeof (transit_route));
-              rgp->type = htons (GNUNET_P2P_PROTO_AIP_ROUTE);
-              ((transit_route *) (rgp + 1))->owner =
-                (realised_store + i)->owner;
-              ((transit_route *) (rgp + 1))->hops =
-                htonl ((realised_store + i)->hops);
-              GNUNET_mutex_unlock (lock);
-              GNUNET_GE_LOG (coreAPI->ectx,
-                             GNUNET_GE_DEBUG | GNUNET_GE_BULK |
-                             GNUNET_GE_ADMIN,
-                             _
-                             ("Send route announcement %d with route 
announce\n"),
-                             i);
-              /* it must be delivered if possible, but it can wait longer than 
IP */
-              coreAPI->unicast (sender, rgp, GNUNET_EXTREME_PRIORITY, 15);
-              GNUNET_free (rgp);
-              return GNUNET_OK;
-            }
           GNUNET_GE_LOG (coreAPI->ectx,
-                         GNUNET_GE_DEBUG | GNUNET_GE_BULK | GNUNET_GE_ADMIN,
-                         _("Send outside table info %d\n"), i);
-          rgp = GNUNET_malloc (sizeof (GNUNET_MessageHeader) + sizeof (int));
-          if (rgp == NULL)
-            {
-              GNUNET_mutex_unlock (lock);
-              return GNUNET_OK;
-            }
-          rgp->size = htons (sizeof (GNUNET_MessageHeader) + sizeof (int));
-          rgp->type = htons (GNUNET_P2P_PROTO_AIP_ROUTES);
-          *((int *) (rgp + 1)) = htonl (realised_entries);
+                         GNUNET_GE_DEBUG | GNUNET_GE_BULK |
+                         GNUNET_GE_ADMIN,
+                         _("Prepare route announcement level %d\n"), i);
+          rgp =
+            GNUNET_malloc (sizeof (GNUNET_MessageHeader) +
+                           sizeof (transit_route));
+          rgp->size =
+            htons (sizeof (GNUNET_MessageHeader) + sizeof (transit_route));
+          rgp->type = htons (GNUNET_P2P_PROTO_AIP_ROUTE);
+          ((transit_route *) (rgp + 1))->owner = (realised_store + i)->owner;
+          ((transit_route *) (rgp + 1))->hops =
+            htonl ((realised_store + i)->hops);
           GNUNET_mutex_unlock (lock);
+          GNUNET_GE_LOG (coreAPI->ectx,
+                         GNUNET_GE_DEBUG | GNUNET_GE_BULK |
+                         GNUNET_GE_ADMIN,
+                         _
+                         ("Send route announcement %d with route announce\n"),
+                         i);
+          /* it must be delivered if possible, but it can wait longer than IP 
*/
           coreAPI->unicast (sender, rgp, GNUNET_EXTREME_PRIORITY, 15);
           GNUNET_free (rgp);
           return GNUNET_OK;
         }
+      GNUNET_GE_LOG (coreAPI->ectx,
+                     GNUNET_GE_DEBUG | GNUNET_GE_BULK | GNUNET_GE_ADMIN,
+                     _("Send outside table info %d\n"), i);
+      rgp = GNUNET_malloc (sizeof (GNUNET_MessageHeader) + sizeof (int));
+      rgp->size = htons (sizeof (GNUNET_MessageHeader) + sizeof (int));
+      rgp->type = htons (GNUNET_P2P_PROTO_AIP_ROUTES);
+      *((int *) (rgp + 1)) = htonl (realised_entries);
+      GNUNET_mutex_unlock (lock);
+      coreAPI->unicast (sender, rgp, GNUNET_EXTREME_PRIORITY, 15);
+      GNUNET_free (rgp);
       return GNUNET_OK;
-    case GNUNET_P2P_PROTO_AIP_ROUTE:
+    }
+  return GNUNET_OK;
+}
+
+static int
+p2p_handle_vpn_aip_route (const GNUNET_PeerIdentity * sender,
+                          const GNUNET_MessageHeader * gp)
+{
+  int i;
+  GNUNET_MessageHeader *rgp;
+
+  GNUNET_GE_LOG (coreAPI->ectx,
+                 GNUNET_GE_DEBUG | GNUNET_GE_BULK | GNUNET_GE_ADMIN,
+                 _("Receive route announce.\n"));
+  /** peer sent us a route, insert it into routing table, then req next entry 
*/
+  if (ntohs (gp->size) ==
+      (sizeof (GNUNET_MessageHeader) + sizeof (transit_route)))
+    {
+      GNUNET_mutex_lock (lock);
       GNUNET_GE_LOG (coreAPI->ectx,
                      GNUNET_GE_DEBUG | GNUNET_GE_BULK | GNUNET_GE_ADMIN,
-                     _("Receive route announce.\n"));
-        /** peer sent us a route, insert it into routing table, then req next 
entry */
-      if (ntohs (gp->size) ==
-          (sizeof (GNUNET_MessageHeader) + sizeof (transit_route)))
+                     _("Going to try insert route into local table.\n"));
+      for (i = 0; i < entries1; i++)
         {
-          GNUNET_mutex_lock (lock);
-          GNUNET_GE_LOG (coreAPI->ectx,
-                         GNUNET_GE_DEBUG | GNUNET_GE_BULK | GNUNET_GE_ADMIN,
-                         _("Going to try insert route into local table.\n"));
-          for (i = 0; i < entries1; i++)
+          if (isEqual (sender, &((store1 + i)->peer)))
             {
-              if (isEqual (sender, &((store1 + i)->peer)))
+              (store1 + i)->active = GNUNET_YES;
+              GNUNET_GE_LOG (coreAPI->ectx,
+                             GNUNET_GE_DEBUG | GNUNET_GE_BULK |
+                             GNUNET_GE_ADMIN,
+                             _("Inserting with hops %d\n"),
+                             ntohl (((transit_route *) (gp + 1))->hops));
+              add_route (&(((transit_route *) (gp + 1))->owner),
+                         1 + ntohl (((transit_route *) (gp + 1))->hops), i);
+              if ((store1 + i)->route_entry < GNUNET_VIEW_LIMIT)
                 {
-                  (store1 + i)->active = GNUNET_YES;
+                  (store1 + i)->route_entry++;
+                  rgp =
+                    GNUNET_malloc (sizeof (GNUNET_MessageHeader) +
+                                   sizeof (int));
+                  if (rgp == NULL)
+                    {
+                      GNUNET_mutex_unlock (lock);
+                      return GNUNET_OK;
+                    }
+                  rgp->type = htons (GNUNET_P2P_PROTO_AIP_GETROUTE);
+                  rgp->size =
+                    htons (sizeof (GNUNET_MessageHeader) + sizeof (int));
+                  *((int *) (rgp + 1)) = htonl ((store1 + i)->route_entry);
                   GNUNET_GE_LOG (coreAPI->ectx,
                                  GNUNET_GE_DEBUG | GNUNET_GE_BULK |
                                  GNUNET_GE_ADMIN,
-                                 _("Inserting with hops %d\n"),
-                                 ntohl (((transit_route *) (gp + 1))->hops));
-                  add_route (&(((transit_route *) (gp + 1))->owner),
-                             1 + ntohl (((transit_route *) (gp + 1))->hops),
-                             i);
-                  if ((store1 + i)->route_entry < GNUNET_VIEW_LIMIT)
-                    {
-                      (store1 + i)->route_entry++;
-                      rgp =
-                        GNUNET_malloc (sizeof (GNUNET_MessageHeader) +
-                                       sizeof (int));
-                      if (rgp == NULL)
-                        {
-                          GNUNET_mutex_unlock (lock);
-                          return GNUNET_OK;
-                        }
-                      rgp->type = htons (GNUNET_P2P_PROTO_AIP_GETROUTE);
-                      rgp->size =
-                        htons (sizeof (GNUNET_MessageHeader) + sizeof (int));
-                      *((int *) (rgp + 1)) =
-                        htonl ((store1 + i)->route_entry);
-                      GNUNET_GE_LOG (coreAPI->ectx,
-                                     GNUNET_GE_DEBUG | GNUNET_GE_BULK |
-                                     GNUNET_GE_ADMIN,
-                                     _("Request level %d from peer %d\n"),
-                                     (store1 + i)->route_entry, i);
-                      coreAPI->unicast (&((store1 + i)->peer), rgp,
-                                        GNUNET_EXTREME_PRIORITY, 60);
-                      GNUNET_free (rgp);
-                    }
-                  break;
+                                 _("Request level %d from peer %d\n"),
+                                 (store1 + i)->route_entry, i);
+                  coreAPI->unicast (&((store1 + i)->peer), rgp,
+                                    GNUNET_EXTREME_PRIORITY, 60);
+                  GNUNET_free (rgp);
                 }
+              break;
             }
-          GNUNET_mutex_unlock (lock);
         }
-      return GNUNET_OK;
-    case GNUNET_P2P_PROTO_AIP_ROUTES:
-      if (ntohs (gp->size) == (sizeof (GNUNET_MessageHeader) + sizeof (int)))
-        {
-          /* if this is the last route message, we do route realisation
-           * that is, insert the routes into the operating system.
-           */
-          GNUNET_GE_LOG (coreAPI->ectx,
-                         GNUNET_GE_DEBUG | GNUNET_GE_BULK | GNUNET_GE_ADMIN,
-                         _("Receive table limit on peer reached %d\n"),
-                         ntohl (*((int *) fp)));
-/*             GNUNET_mutex_lock(lock);
-               for (i = 0; i < entries1; i++) {
-                       if (isEqual(sender, &((store1+i)->peer))) {
-                             GNUNET_GE_LOG (coreAPI->ectx,
-                    GNUNET_GE_DEBUG | GNUNET_GE_BULK | GNUNET_GE_ADMIN,
-                    _("Storing table limit %d for peer %d\n"), ntohl( 
*((int*)fp)), i );
-                               (store1+i)->route_limit = ntohl( *((int*)fp));
-                               break;
-                       }
-               }
-               GNUNET_mutex_unlock(lock);
-*/ }
-      return GNUNET_OK;
+      GNUNET_mutex_unlock (lock);
     }
   return GNUNET_OK;
 }
 
+static int
+p2p_handle_vpn_aip_routes (const GNUNET_PeerIdentity * sender,
+                           const GNUNET_MessageHeader * gp)
+{
+  const struct ip6_hdr *fp = (struct ip6_hdr *) (gp + 1);
+
+  if (ntohs (gp->size) == (sizeof (GNUNET_MessageHeader) + sizeof (int)))
+    {
+      /* if this is the last route message, we do route realisation
+       * that is, insert the routes into the operating system.
+       */
+      GNUNET_GE_LOG (coreAPI->ectx,
+                     GNUNET_GE_DEBUG | GNUNET_GE_BULK | GNUNET_GE_ADMIN,
+                     _("Receive table limit on peer reached %d\n"),
+                     ntohl (*((int *) fp)));
+      /*                GNUNET_mutex_lock(lock);
+         for (i = 0; i < entries1; i++) {
+         if (isEqual(sender, &((store1+i)->peer))) {
+         GNUNET_GE_LOG (coreAPI->ectx,
+         GNUNET_GE_DEBUG | GNUNET_GE_BULK | GNUNET_GE_ADMIN,
+         _("Storing table limit %d for peer %d\n"), ntohl( *((int*)fp)), i );
+         (store1+i)->route_limit = ntohl( *((int*)fp));
+         break;
+         }
+         }
+         GNUNET_mutex_unlock(lock);
+       */ }
+  return GNUNET_OK;
+}
+
+
+int
+GNUNET_VPN_p2p_handler_init (GNUNET_CoreAPIForPlugins * capi)
+{
+  if (GNUNET_SYSERR ==
+      capi->registerHandler (GNUNET_P2P_PROTO_AIP_IP, &p2p_handle_vpn_aip_ip))
+    return GNUNET_SYSERR;
+  if (GNUNET_SYSERR ==
+      capi->registerHandler (GNUNET_P2P_PROTO_AIP_GETROUTE,
+                             &p2p_handle_vpn_aip_getroute))
+    return GNUNET_SYSERR;
+  if (GNUNET_SYSERR ==
+      capi->registerHandler (GNUNET_P2P_PROTO_AIP_ROUTE,
+                             &p2p_handle_vpn_aip_route))
+    return GNUNET_SYSERR;
+  if (GNUNET_SYSERR ==
+      capi->registerHandler (GNUNET_P2P_PROTO_AIP_ROUTES,
+                             &p2p_handle_vpn_aip_routes))
+    return GNUNET_SYSERR;
+  if (GNUNET_SYSERR ==
+      capi->registerHandler (GNUNET_P2P_PROTO_PONG, &p2p_handle_pong))
+    return GNUNET_SYSERR;
+  if (GNUNET_SYSERR ==
+      capi->registerHandler (GNUNET_P2P_PROTO_HANG_UP, &p2p_handle_hang_up))
+    return GNUNET_SYSERR;
+  return GNUNET_OK;
+}
+
+int
+GNUNET_VPN_p2p_handler_done ()
+{
+  coreAPI->unregisterHandler (GNUNET_P2P_PROTO_AIP_IP,
+                              &p2p_handle_vpn_aip_ip);
+  coreAPI->unregisterHandler (GNUNET_P2P_PROTO_AIP_GETROUTE,
+                              &p2p_handle_vpn_aip_getroute);
+  coreAPI->unregisterHandler (GNUNET_P2P_PROTO_AIP_ROUTE,
+                              &p2p_handle_vpn_aip_route);
+  coreAPI->unregisterHandler (GNUNET_P2P_PROTO_AIP_ROUTES,
+                              &p2p_handle_vpn_aip_routes);
+  coreAPI->unregisterHandler (GNUNET_P2P_PROTO_PONG, &p2p_handle_pong);
+  coreAPI->unregisterHandler (GNUNET_P2P_PROTO_HANG_UP, &p2p_handle_hang_up);
+  return GNUNET_OK;
+}
+
+
 /* end of p2p.c */

Modified: GNUnet/src/applications/vpn/p2p.h
===================================================================
--- GNUnet/src/applications/vpn/p2p.h   2008-02-24 07:36:20 UTC (rev 6430)
+++ GNUnet/src/applications/vpn/p2p.h   2008-02-24 07:49:35 UTC (rev 6431)
@@ -26,16 +26,8 @@
 #ifndef VPN_P2P_H
 #define VPN_P2P_H
 
-/**
- * Pass IP packet to tap. Which tap depends on what the GNUNET_PeerIdentity is.
- * If we've not seen the peer before, create a new TAP and tell our thread 
about it?
- * else scan the array of TAPS and copy the message into it.
- *
- * Mainly this routine exchanges the GNUNET_MessageHeader on incoming ipv6 
packets
- * for a TUN/TAP header for writing it to TUNTAP.
- */
-int
-handlep2pMSG (const GNUNET_PeerIdentity * sender,
-              const GNUNET_MessageHeader * gp);
+int GNUNET_VPN_p2p_handler_init (GNUNET_CoreAPIForPlugins * capi);
 
+int GNUNET_VPN_p2p_handler_done (void);
+
 #endif

Modified: GNUnet/src/applications/vpn/vpn.c
===================================================================
--- GNUnet/src/applications/vpn/vpn.c   2008-02-24 07:36:20 UTC (rev 6430)
+++ GNUnet/src/applications/vpn/vpn.c   2008-02-24 07:49:35 UTC (rev 6431)
@@ -21,6 +21,7 @@
 /**
  * @file applications/vpn/vpn.c
  * @author Michael John Wensley
+ * @author Christian Grothoff (code cleanup, breaking things)
  * @brief tunnel RFC 4193 in GNUnet
  *
  *
@@ -48,10 +49,9 @@
  *
  * TODO:
  * - consider using linked list for routing tables instead of arrays
- * - split up handlep2pMSG into many individual handlers
  * - find a better solution for /var/lib/gnunet/gnunet.vpn,
  *   at least do not hardwire the path
- * - can we split off P2P and TUN code into
+ * - can we split off TUN code into
  *   individual files without keeping globals?
  * - use PeerIdentities instead of PublicKeys where
  *   possible
@@ -904,25 +904,8 @@
   /* core calls us to receive messages */
   /* get a PONG = peer is online */
   /* get a HANGUP = peer is offline */
-  if (GNUNET_SYSERR ==
-      capi->registerHandler (GNUNET_P2P_PROTO_AIP_IP, &handlep2pMSG))
-    return GNUNET_SYSERR;
-  if (GNUNET_SYSERR ==
-      capi->registerHandler (GNUNET_P2P_PROTO_AIP_GETROUTE, &handlep2pMSG))
-    return GNUNET_SYSERR;
-  if (GNUNET_SYSERR ==
-      capi->registerHandler (GNUNET_P2P_PROTO_AIP_ROUTE, &handlep2pMSG))
-    return GNUNET_SYSERR;
-  if (GNUNET_SYSERR ==
-      capi->registerHandler (GNUNET_P2P_PROTO_AIP_ROUTES, &handlep2pMSG))
-    return GNUNET_SYSERR;
-  if (GNUNET_SYSERR ==
-      capi->registerHandler (GNUNET_P2P_PROTO_PONG, &handlep2pMSG))
-    return GNUNET_SYSERR;
-  if (GNUNET_SYSERR ==
-      capi->registerHandler (GNUNET_P2P_PROTO_HANG_UP, &handlep2pMSG))
-    return GNUNET_SYSERR;
-  GNUNET_VPN_cs_handler_init(capi);
+  GNUNET_VPN_p2p_handler_init (capi);
+  GNUNET_VPN_cs_handler_init (capi);
 
   identity = coreAPI->request_service ("identity");
   GNUNET_GE_ASSERT (ectx, identity != NULL);
@@ -971,13 +954,8 @@
 
   GNUNET_cron_del_job (coreAPI->cron,
                        &realise, 5 * GNUNET_CRON_MINUTES, NULL);
-  coreAPI->unregisterHandler (GNUNET_P2P_PROTO_AIP_IP, &handlep2pMSG);
-  coreAPI->unregisterHandler (GNUNET_P2P_PROTO_AIP_GETROUTE, &handlep2pMSG);
-  coreAPI->unregisterHandler (GNUNET_P2P_PROTO_AIP_ROUTE, &handlep2pMSG);
-  coreAPI->unregisterHandler (GNUNET_P2P_PROTO_AIP_ROUTES, &handlep2pMSG);
-  coreAPI->unregisterHandler (GNUNET_P2P_PROTO_PONG, &handlep2pMSG);
-  coreAPI->unregisterHandler (GNUNET_P2P_PROTO_HANG_UP, &handlep2pMSG);
-  GNUNET_VPN_cs_handler_done();
+  GNUNET_VPN_p2p_handler_done ();
+  GNUNET_VPN_cs_handler_done ();
 
   GNUNET_GE_LOG (ectx, GNUNET_GE_INFO | GNUNET_GE_REQUEST | GNUNET_GE_USER,
                  _("RFC4193 Waiting for tun thread to end\n"));

Modified: GNUnet/src/applications/vpn/vpn.h
===================================================================
--- GNUnet/src/applications/vpn/vpn.h   2008-02-24 07:36:20 UTC (rev 6430)
+++ GNUnet/src/applications/vpn/vpn.h   2008-02-24 07:49:35 UTC (rev 6431)
@@ -181,10 +181,8 @@
 
 void init_router (void);
 
-void
-checkensure_peer (const GNUNET_PeerIdentity * them, void *callerinfo);
+void checkensure_peer (const GNUNET_PeerIdentity * them, void *callerinfo);
 
-void
-add_route (GNUNET_RSA_PublicKey * them, int hops, int tunnel);
+void add_route (GNUNET_RSA_PublicKey * them, int hops, int tunnel);
 
 #endif





reply via email to

[Prev in Thread] Current Thread [Next in Thread]