Author: grothoff Date: 2008-02-24 00:24:56 -0700 (Sun, 24 Feb 2008) New Revision: 6428
Modified: GNUnet/src/applications/vpn/cs.c GNUnet/src/applications/vpn/cs.h GNUnet/src/applications/vpn/helper.c GNUnet/src/applications/vpn/helper.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 06:56:04 UTC (rev 6427) +++ GNUnet/src/applications/vpn/cs.c 2008-02-24 07:24:56 UTC (rev 6428) @@ -21,221 +21,308 @@ /** * @file applications/vpn/cs.c * @author Michael John Wensley - * @brief tunnel RFC 4193 in GNUnet + * @author Christian Grothoff (code clean up) + * @brief methods for interaction with gnunet-vpn tool * * TODO: - * - split up into individual handlers - * - export only initialization and shutdown - * methods taking coreAPI - * - eliminate useless locking + * - define structs for some of the messages + * => eliminate mallocs! + * - clean up cprintf */ #include "vpn.h" #include "cs.h" #include "helper.h" -/** The console client is used to admin/debug vpn */ -int -csHandle (struct GNUNET_ClientHandle *c, const GNUNET_MessageHeader * message) + +/** + * send given string to client + */ +static void +cprintf (struct GNUNET_ClientHandle *c, int t, const char *format, ...) { - GNUNET_MessageHeader *rgp = NULL; - int i; - GNUNET_PeerIdentity id; - int parameter = ntohs (message->size) - sizeof (GNUNET_MessageHeader); - char *ccmd = (char *) (message + 1); - char *parm; + va_list args; + int r = -1; + int size = 100; + GNUNET_MessageHeader *b; - /* issued command from client */ - if (ntohs (message->type) == GNUNET_CS_PROTO_VPN_MSG) + GNUNET_GE_ASSERT (NULL, c != NULL); + + b = GNUNET_malloc (sizeof (GNUNET_MessageHeader) + size); + while (1) { - if (ntohs (message->size) == 0) - return GNUNET_OK; - } - if (ntohs (message->type) == GNUNET_CS_PROTO_VPN_TUNNELS) - { - GNUNET_mutex_lock (lock); - id2ip (c, coreAPI->myIdentity); - cprintf (c, GNUNET_CS_PROTO_VPN_REPLY, "::/48 This Node\n"); - for (i = 0; i < entries1; i++) + va_start (args, format); + r = VSNPRINTF ((char *) (b + 1), size, format, args); + va_end (args); + if (r > -1 && r < size) + break; + if (r > -1) { - 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); + size = r + 1; } - cprintf (c, GNUNET_CS_PROTO_VPN_TUNNELS, "%d Tunnels\n", entries1); - GNUNET_mutex_unlock (lock); - } - if (ntohs (message->type) == GNUNET_CS_PROTO_VPN_ROUTES) - { - GNUNET_mutex_lock (lock); - for (i = 0; i < route_entries; i++) + else { - 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"); - } - 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); - } + size *= 2; } - cprintf (c, GNUNET_CS_PROTO_VPN_ROUTES, "%d Routes\n", route_entries); - GNUNET_mutex_unlock (lock); + b = GNUNET_realloc (b, sizeof (GNUNET_MessageHeader) + size); } - if (ntohs (message->type) == GNUNET_CS_PROTO_VPN_REALISED) + b->type = htons (t); + b->size = htons (sizeof (GNUNET_MessageHeader) + strlen ((char *) (b + 1))); + coreAPI->cs_send_to_client (c, b, GNUNET_YES); + GNUNET_free (b); +} + + +/** + * Convert a PeerIdentify into a "random" RFC4193 prefix + * actually we make the first 40 bits of the GNUNET_hash into the prefix! + */ +static void +id2ip (struct GNUNET_ClientHandle *cx, const GNUNET_PeerIdentity * them) +{ + unsigned char a, b, c, d, e; + a = (them->hashPubKey.bits[0] >> 8) & 0xff; + b = (them->hashPubKey.bits[0] >> 0) & 0xff; + c = (them->hashPubKey.bits[1] >> 8) & 0xff; + d = (them->hashPubKey.bits[1] >> 0) & 0xff; + e = (them->hashPubKey.bits[2] >> 8) & 0xff; + cprintf (cx, GNUNET_CS_PROTO_VPN_REPLY, "fd%02x:%02x%02x:%02x%02x", a, b, c, + d, e); +} + + +/** The console client is used to admin/debug vpn */ +static int +cs_handle_vpn_tunnels (struct GNUNET_ClientHandle *c, const GNUNET_MessageHeader * message) +{ + int i; + + GNUNET_mutex_lock (lock); + id2ip (c, coreAPI->myIdentity); + cprintf (c, GNUNET_CS_PROTO_VPN_REPLY, "::/48 This Node\n"); + for (i = 0; i < entries1; i++) { - GNUNET_mutex_lock (lock); - for (i = 0; i < realised_entries; i++) - { - 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"); - } - 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_REALISED, "%d Realised\n", - realised_entries); - GNUNET_mutex_unlock (lock); + 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); } - if (ntohs (message->type) == GNUNET_CS_PROTO_VPN_RESET) + cprintf (c, GNUNET_CS_PROTO_VPN_TUNNELS, "%d Tunnels\n", entries1); + GNUNET_mutex_unlock (lock); + return GNUNET_OK; +} + +static int +cs_handle_vpn_routes(struct GNUNET_ClientHandle *c, const GNUNET_MessageHeader * message) +{ + int i; + GNUNET_PeerIdentity id; + + GNUNET_mutex_lock (lock); + for (i = 0; i < route_entries; i++) { - GNUNET_mutex_lock (lock); - init_router (); - for (i = 0; i < entries1; i++) - { - (store1 + i)->route_entry = 0; - /* lets send it to everyone - expect response only from VPN enabled nodes tho :-) */ -/* if ((store1+i)->active == GNUNET_YES) { */ - rgp = GNUNET_malloc (sizeof (GNUNET_MessageHeader) + sizeof (int)); - if (rgp == NULL) - { - break; - } - rgp->type = htons (GNUNET_P2P_PROTO_AIP_GETROUTE); - 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); - id2ip (c, &((store1 + i)->peer)); - cprintf (c, GNUNET_CS_PROTO_VPN_REPLY, "\n"); - coreAPI->unicast (&((store1 + i)->peer), rgp, - GNUNET_EXTREME_PRIORITY, 60); - GNUNET_free (rgp); -/* } */ - } - GNUNET_mutex_unlock (lock); - cprintf (c, GNUNET_CS_PROTO_VPN_RESET, - "Rebuilding routing tables done\n"); + 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"); + } + 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); + } } - if (ntohs (message->type) == GNUNET_CS_PROTO_VPN_TRUST) + 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) +{ + int i; + GNUNET_PeerIdentity id; + + GNUNET_mutex_lock (lock); + for (i = 0; i < realised_entries; i++) { - GNUNET_mutex_lock (lock); - 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_TRUST, - "Gave credit to active nodes of %d nodes...\n", entries1); - GNUNET_mutex_unlock (lock); + 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"); + } + 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); + } } - if (ntohs (message->type) == GNUNET_CS_PROTO_VPN_ADD) + cprintf (c, GNUNET_CS_PROTO_VPN_REALISED, "%d Realised\n", + realised_entries); + GNUNET_mutex_unlock (lock); + return GNUNET_OK; +} + +static int +cs_handle_vpn_reset(struct GNUNET_ClientHandle *c, const GNUNET_MessageHeader * message) +{ + int i; + GNUNET_MessageHeader *rgp; + + GNUNET_mutex_lock (lock); + init_router (); + for (i = 0; i < entries1; i++) { - if (parameter > 0) - { - if ((parm = GNUNET_malloc (parameter + 1)) != NULL) - { - strncpy (parm, ccmd, parameter); - *(parm + parameter) = 0; - cprintf (c, GNUNET_CS_PROTO_VPN_REPLY, "Connect "); - if (GNUNET_OK == GNUNET_enc_to_hash (parm, &(id.hashPubKey))) - { - id2ip (c, &id); + (store1 + i)->route_entry = 0; + /* lets send it to everyone - expect response only from VPN enabled nodes tho :-) */ + /* if ((store1+i)->active != GNUNET_YES) continue; */ + 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)) = htonl ((store1 + i)->route_entry); + cprintf (c, GNUNET_CS_PROTO_VPN_REPLY, + "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_free (rgp); + } + GNUNET_mutex_unlock (lock); + cprintf (c, GNUNET_CS_PROTO_VPN_RESET, + "Rebuilding routing tables done\n"); + return GNUNET_OK; +} - /* this does not seem to work, strangeness with threads and capabilities? - * GNUNET_mutex_lock(lock); - * checkensure_peer(&id, NULL); - * GNUNET_mutex_unlock(lock); - */ +static int +cs_handle_vpn_trust(struct GNUNET_ClientHandle *c, const GNUNET_MessageHeader * message) +{ + int i; - /* get it off the local blacklist */ - identity->whitelistHost (&id); + GNUNET_mutex_lock (lock); + 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_TRUST, + "Gave credit to active nodes of %d nodes...\n", entries1); + GNUNET_mutex_unlock (lock); + return GNUNET_OK; +} - switch (session->tryConnect (&id)) - { - case GNUNET_YES: - cprintf (c, GNUNET_CS_PROTO_VPN_REPLY, - " already connected.\n"); - break; - case GNUNET_NO: - cprintf (c, GNUNET_CS_PROTO_VPN_REPLY, - " schedule connection.\n"); - break; - case GNUNET_SYSERR: - cprintf (c, GNUNET_CS_PROTO_VPN_REPLY, - " core refused.\n"); - break; - default: - cprintf (c, GNUNET_CS_PROTO_VPN_REPLY, - " misc error.\n"); - break; - } +static int +cs_handle_vpn_add(struct GNUNET_ClientHandle *c, const GNUNET_MessageHeader * message) +{ + unsigned int parameter = ntohs (message->size) - sizeof (GNUNET_MessageHeader); + const char *ccmd = (const char *) &message[1]; + GNUNET_MessageHeader *rgp; + GNUNET_PeerIdentity id; + char *parm; - /* req route level 0 - rgp = GNUNET_malloc(sizeof(GNUNET_MessageHeader) + sizeof(int)); - if (rgp != NULL) { - 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); - cprintf(c, " Sent"); - GNUNET_free(rgp); - } */ + if (parameter == 0) + return GNUNET_SYSERR; + parm = GNUNET_malloc (parameter + 1); + strncpy (parm, ccmd, parameter); + *(parm + parameter) = 0; + if (GNUNET_OK != GNUNET_enc_to_hash (parm, &(id.hashPubKey))) + { + 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); + } + /* get it off the local blacklist */ + 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"); + break; + case GNUNET_NO: + cprintf (c, GNUNET_CS_PROTO_VPN_REPLY, + " schedule connection.\n"); + break; + case GNUNET_SYSERR: + cprintf (c, GNUNET_CS_PROTO_VPN_REPLY, + " core refused.\n"); + break; + default: + 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); + } + cprintf (c, GNUNET_CS_PROTO_VPN_ADD, "\n"); + return GNUNET_OK; +} - cprintf (c, GNUNET_CS_PROTO_VPN_ADD, "\n"); - } - else - { - cprintf (c, GNUNET_CS_PROTO_VPN_ADD, - "Could not decode PeerId %s from parameter.\n", - parm); - } - GNUNET_free (parm); - } - else - { - cprintf (c, GNUNET_CS_PROTO_VPN_ADD, - "Could not allocate for key.\n"); - } - } - else - { - cprintf (c, GNUNET_CS_PROTO_VPN_ADD, "Require key for parameter\n"); - } - } +int GNUNET_VPN_cs_handler_init(GNUNET_CoreAPIForPlugins * capi) +{ + if (GNUNET_SYSERR == + 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)) + return GNUNET_SYSERR; + if (GNUNET_SYSERR == + 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)) + return GNUNET_SYSERR; + if (GNUNET_SYSERR == + 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)) + return GNUNET_SYSERR; return GNUNET_OK; } + +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); + return GNUNET_OK; +} + +/* end of cs.c */ Modified: GNUnet/src/applications/vpn/cs.h =================================================================== --- GNUnet/src/applications/vpn/cs.h 2008-02-24 06:56:04 UTC (rev 6427) +++ GNUnet/src/applications/vpn/cs.h 2008-02-24 07:24:56 UTC (rev 6428) @@ -28,8 +28,8 @@ #include "gnunet_core.h" -/** The console client is used to admin/debug vpn */ -int csHandle (struct GNUNET_ClientHandle *c, - const GNUNET_MessageHeader * message); +int GNUNET_VPN_cs_handler_init(GNUNET_CoreAPIForPlugins * capi); +int GNUNET_VPN_cs_handler_done(void); + #endif Modified: GNUnet/src/applications/vpn/helper.c =================================================================== --- GNUnet/src/applications/vpn/helper.c 2008-02-24 06:56:04 UTC (rev 6427) +++ GNUnet/src/applications/vpn/helper.c 2008-02-24 07:24:56 UTC (rev 6428) @@ -25,69 +25,14 @@ * * TODO: * - use better naming conventions - * - clean up cprintf * - elimiante isEqualP and isEqual */ #include "helper.h" -/** - * send given string to client - */ -void -cprintf (struct GNUNET_ClientHandle *c, int t, const char *format, ...) -{ - va_list args; - int r = -1; - int size = 100; - GNUNET_MessageHeader *b; - GNUNET_GE_ASSERT (NULL, c != NULL); - b = GNUNET_malloc (sizeof (GNUNET_MessageHeader) + size); - while (1) - { - va_start (args, format); - r = VSNPRINTF ((char *) (b + 1), size, format, args); - va_end (args); - if (r > -1 && r < size) - break; - if (r > -1) - { - size = r + 1; - } - else - { - size *= 2; - } - b = GNUNET_realloc (b, sizeof (GNUNET_MessageHeader) + size); - } - b->type = htons (t); - b->size = htons (sizeof (GNUNET_MessageHeader) + strlen ((char *) (b + 1))); - coreAPI->cs_send_to_client (c, b, GNUNET_YES); - GNUNET_free (b); -} - - -/** - * Convert a PeerIdentify into a "random" RFC4193 prefix - * actually we make the first 40 bits of the GNUNET_hash into the prefix! - */ -void -id2ip (struct GNUNET_ClientHandle *cx, const GNUNET_PeerIdentity * them) -{ - unsigned char a, b, c, d, e; - a = (them->hashPubKey.bits[0] >> 8) & 0xff; - b = (them->hashPubKey.bits[0] >> 0) & 0xff; - c = (them->hashPubKey.bits[1] >> 8) & 0xff; - d = (them->hashPubKey.bits[1] >> 0) & 0xff; - e = (them->hashPubKey.bits[2] >> 8) & 0xff; - cprintf (cx, GNUNET_CS_PROTO_VPN_REPLY, "fd%02x:%02x%02x:%02x%02x", a, b, c, - d, e); -} - - /** Test if two GNUNET_RSA_PublicKey are equal or not */ int isEqualP (const GNUNET_RSA_PublicKey * first, Modified: GNUnet/src/applications/vpn/helper.h =================================================================== --- GNUnet/src/applications/vpn/helper.h 2008-02-24 06:56:04 UTC (rev 6427) +++ GNUnet/src/applications/vpn/helper.h 2008-02-24 07:24:56 UTC (rev 6428) @@ -29,18 +29,6 @@ #include "gnunet_core.h" #include "vpn.h" -/** - * send given string to client - */ -void cprintf (struct GNUNET_ClientHandle *c, int t, const char *format, ...); - -/** - * Convert a PeerIdentify into a "random" RFC4193 prefix - * actually we make the first 40 bits of the GNUNET_hash into the prefix! - */ -void id2ip (struct GNUNET_ClientHandle *cx, const GNUNET_PeerIdentity * them); - - /** Test if two GNUNET_RSA_PublicKey are equal or not */ int isEqualP (const GNUNET_RSA_PublicKey * first, Modified: GNUnet/src/applications/vpn/vpn.c =================================================================== --- GNUnet/src/applications/vpn/vpn.c 2008-02-24 06:56:04 UTC (rev 6427) +++ GNUnet/src/applications/vpn/vpn.c 2008-02-24 07:24:56 UTC (rev 6428) @@ -492,7 +492,7 @@ * See if we already got a TUN/TAP open for the given GNUnet peer. if not, make one, stick * GNUNET_PeerIdentity and the filehandle and name of the TUN/TAP in an array so we remember we did it. */ -static void +void checkensure_peer (const GNUNET_PeerIdentity * them, void *callerinfo) { int i; @@ -1193,30 +1193,7 @@ if (GNUNET_SYSERR == capi->registerHandler (GNUNET_P2P_PROTO_HANG_UP, &handlep2pMSG)) return GNUNET_SYSERR; - if (GNUNET_SYSERR == - capi->registerClientHandler (GNUNET_CS_PROTO_VPN_MSG, &csHandle)) - return GNUNET_SYSERR; - if (GNUNET_SYSERR == - capi->registerClientHandler (GNUNET_CS_PROTO_VPN_TUNNELS, &csHandle)) - return GNUNET_SYSERR; - if (GNUNET_SYSERR == - capi->registerClientHandler (GNUNET_CS_PROTO_VPN_ROUTES, &csHandle)) - return GNUNET_SYSERR; - if (GNUNET_SYSERR == - capi->registerClientHandler (GNUNET_CS_PROTO_VPN_REALISED, &csHandle)) - return GNUNET_SYSERR; - if (GNUNET_SYSERR == - capi->registerClientHandler (GNUNET_CS_PROTO_VPN_RESET, &csHandle)) - return GNUNET_SYSERR; - if (GNUNET_SYSERR == - capi->registerClientHandler (GNUNET_CS_PROTO_VPN_ADD, &csHandle)) - return GNUNET_SYSERR; - if (GNUNET_SYSERR == - capi->registerClientHandler (GNUNET_CS_PROTO_VPN_TRUST, &csHandle)) - return GNUNET_SYSERR; - if (GNUNET_SYSERR == - capi->registerClientHandler (GNUNET_CS_PROTO_VPN_REPLY, &csHandle)) - return GNUNET_SYSERR; + GNUNET_VPN_cs_handler_init(capi); identity = coreAPI->request_service ("identity"); GNUNET_GE_ASSERT (ectx, identity != NULL); @@ -1271,14 +1248,7 @@ coreAPI->unregisterHandler (GNUNET_P2P_PROTO_AIP_ROUTES, &handlep2pMSG); coreAPI->unregisterHandler (GNUNET_P2P_PROTO_PONG, &handlep2pMSG); coreAPI->unregisterHandler (GNUNET_P2P_PROTO_HANG_UP, &handlep2pMSG); - coreAPI->unregisterClientHandler (GNUNET_CS_PROTO_VPN_MSG, &csHandle); - coreAPI->unregisterClientHandler (GNUNET_CS_PROTO_VPN_TUNNELS, &csHandle); - coreAPI->unregisterClientHandler (GNUNET_CS_PROTO_VPN_ROUTES, &csHandle); - coreAPI->unregisterClientHandler (GNUNET_CS_PROTO_VPN_REALISED, &csHandle); - coreAPI->unregisterClientHandler (GNUNET_CS_PROTO_VPN_RESET, &csHandle); - coreAPI->unregisterClientHandler (GNUNET_CS_PROTO_VPN_ADD, &csHandle); - coreAPI->unregisterClientHandler (GNUNET_CS_PROTO_VPN_TRUST, &csHandle); - coreAPI->unregisterClientHandler (GNUNET_CS_PROTO_VPN_REPLY, &csHandle); + 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 06:56:04 UTC (rev 6427) +++ GNUnet/src/applications/vpn/vpn.h 2008-02-24 07:24:56 UTC (rev 6428) @@ -181,5 +181,7 @@ void init_router (void); +void +checkensure_peer (const GNUNET_PeerIdentity * them, void *callerinfo); #endif _______________________________________________ GNUnet-SVN mailing list GNUnet-SVN@gnu.org http://lists.gnu.org/mailman/listinfo/gnunet-svn