gnunet-svn
[Top][All Lists]
Advanced

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

[GNUnet-SVN] r14143 - gnunet/src/vpn


From: gnunet
Subject: [GNUnet-SVN] r14143 - gnunet/src/vpn
Date: Mon, 10 Jan 2011 22:41:47 +0100

Author: toelke
Date: 2011-01-10 22:41:47 +0100 (Mon, 10 Jan 2011)
New Revision: 14143

Modified:
   gnunet/src/vpn/Makefile.am
   gnunet/src/vpn/gnunet-daemon-exit.c
   gnunet/src/vpn/gnunet-daemon-vpn-dns.c
   gnunet/src/vpn/gnunet-daemon-vpn-helper.c
   gnunet/src/vpn/gnunet-daemon-vpn.c
   gnunet/src/vpn/gnunet-daemon-vpn.h
Log:
let -vpn and -exit use mesh instead of core

Modified: gnunet/src/vpn/Makefile.am
===================================================================
--- gnunet/src/vpn/Makefile.am  2011-01-10 21:41:44 UTC (rev 14142)
+++ gnunet/src/vpn/Makefile.am  2011-01-10 21:41:47 UTC (rev 14143)
@@ -43,6 +43,7 @@
   $(top_builddir)/src/core/libgnunetcore.la \
   $(top_builddir)/src/statistics/libgnunetstatistics.la \
   $(top_builddir)/src/util/libgnunetutil.la \
+  $(top_builddir)/src/mesh/libgnunetmesh.la \
   $(GN_LIBINTL)
 
 gnunet_service_dns_SOURCES = \
@@ -62,6 +63,7 @@
   $(top_builddir)/src/core/libgnunetcore.la \
   $(top_builddir)/src/statistics/libgnunetstatistics.la \
   $(top_builddir)/src/util/libgnunetutil.la \
+  $(top_builddir)/src/mesh/libgnunetmesh.la \
   $(GN_LIBINTL)
 
 #check_PROGRAMS = \

Modified: gnunet/src/vpn/gnunet-daemon-exit.c
===================================================================
--- gnunet/src/vpn/gnunet-daemon-exit.c 2011-01-10 21:41:44 UTC (rev 14142)
+++ gnunet/src/vpn/gnunet-daemon-exit.c 2011-01-10 21:41:47 UTC (rev 14143)
@@ -27,7 +27,7 @@
 #include <gnunet_common.h>
 #include <gnunet_program_lib.h>
 #include <gnunet_protocols.h>
-#include <gnunet_core_service.h>
+#include <gnunet_mesh_service.h>
 #include <gnunet_constants.h>
 
 #include "gnunet-vpn-packet.h"
@@ -38,9 +38,9 @@
 static int ret;
 
 /**
- * The handle to core
+ * The handle to mesh
  */
-static struct GNUNET_CORE_Handle *core_handle;
+static struct GNUNET_MESH_Handle *mesh_handle;
 
 /**
  * This hashmap contains the mapping from peer, service-descriptor,
@@ -54,6 +54,7 @@
 struct udp_state
 {
   struct GNUNET_PeerIdentity peer;
+  struct GNUNET_MESH_Tunnel *tunnel;
   GNUNET_HashCode desc;
   short spt;
   short dpt;
@@ -75,10 +76,10 @@
 cleanup(void* cls, const struct GNUNET_SCHEDULER_TaskContext* tskctx) {
     GNUNET_assert (0 != (tskctx->reason & GNUNET_SCHEDULER_REASON_SHUTDOWN));
 
-    if (core_handle != NULL)
+    if (mesh_handle != NULL)
       {
-       GNUNET_CORE_disconnect(core_handle);
-       core_handle = NULL;
+       GNUNET_MESH_disconnect(mesh_handle);
+       mesh_handle = NULL;
       }
 }
 
@@ -137,9 +138,10 @@
   memcpy (desc, &data->state.desc, sizeof (GNUNET_HashCode));
   memcpy (pkt + 1, buf, len);
 
-  GNUNET_CORE_notify_transmit_ready (core_handle, 42,
+  GNUNET_MESH_notify_transmit_ready (data->state.tunnel, 42,
+                                    GNUNET_NO,
                                     
GNUNET_TIME_relative_divide(GNUNET_CONSTANTS_MAX_CORK_DELAY, 2),
-                                    &data->state.peer, len_pkt,
+                                    len_pkt,
                                     send_udp_service, hdr);
 
 out:
@@ -169,13 +171,16 @@
 
 }
 
+/** 
+ * The messages are one GNUNET_HashCode for the service, followed by a struct 
udp_pkt
+ */
 static int
-receive_udp_service (void *cls, const struct GNUNET_PeerIdentity *other,
+receive_udp_service (void *cls,
+                    struct GNUNET_MESH_Tunnel *tunnel,
+                    void **tunnel_ctx,
                     const struct GNUNET_MessageHeader *message,
                     const struct GNUNET_TRANSPORT_ATS_Information *atsi)
 {
-  GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Received UDP-Packet from peer %s\n",
-             GNUNET_i2s (other));
   GNUNET_HashCode *desc = (GNUNET_HashCode *) (message + 1);
   struct udp_pkt *pkt = (struct udp_pkt *) (desc + 1);
 
@@ -191,7 +196,7 @@
   struct udp_state *state = &send->state;
   unsigned int new = GNUNET_NO;
 
-  memcpy (&state->peer, other, sizeof (struct GNUNET_PeerIdentity));
+  state->tunnel = tunnel;
   memcpy (&state->desc, desc, sizeof (GNUNET_HashCode));
   state->spt = ntohs (pkt->spt);
 
@@ -250,21 +255,13 @@
      const char *cfgfile,
      const struct GNUNET_CONFIGURATION_Handle *cfg_)
 {
-  const static struct GNUNET_CORE_MessageHandler handlers[] = {
+  const static struct GNUNET_MESH_MessageHandler handlers[] = {
        {receive_udp_service, GNUNET_MESSAGE_TYPE_SERVICE_UDP, 0},
        {NULL, 0, 0}
   };
-  core_handle = GNUNET_CORE_connect(cfg_,
-                                   42,
+  mesh_handle = GNUNET_MESH_connect(cfg_,
                                    NULL,
-                                   NULL,
-                                   NULL,
-                                   NULL,
-                                   NULL,
-                                   NULL,
-                                   0,
-                                   NULL,
-                                   0,
+                                   NULL, /* FIXME */
                                    handlers);
 
   udp_connections = GNUNET_CONTAINER_multihashmap_create(65536);

Modified: gnunet/src/vpn/gnunet-daemon-vpn-dns.c
===================================================================
--- gnunet/src/vpn/gnunet-daemon-vpn-dns.c      2011-01-10 21:41:44 UTC (rev 
14142)
+++ gnunet/src/vpn/gnunet-daemon-vpn-dns.c      2011-01-10 21:41:47 UTC (rev 
14143)
@@ -27,7 +27,7 @@
 #include <gnunet_common.h>
 #include <gnunet_client_lib.h>
 #include <gnunet_os_lib.h>
-#include <gnunet_core_service.h>
+#include <gnunet_mesh_service.h>
 #include <gnunet_protocols.h>
 #include <gnunet_server_lib.h>
 #include <gnunet_container_lib.h>

Modified: gnunet/src/vpn/gnunet-daemon-vpn-helper.c
===================================================================
--- gnunet/src/vpn/gnunet-daemon-vpn-helper.c   2011-01-10 21:41:44 UTC (rev 
14142)
+++ gnunet/src/vpn/gnunet-daemon-vpn-helper.c   2011-01-10 21:41:47 UTC (rev 
14143)
@@ -27,7 +27,7 @@
 #include <gnunet_common.h>
 #include <gnunet_client_lib.h>
 #include <gnunet_os_lib.h>
-#include <gnunet_core_service.h>
+#include <gnunet_mesh_service.h>
 #include <gnunet_protocols.h>
 #include <gnunet_server_lib.h>
 #include <gnunet_container_lib.h>
@@ -243,18 +243,28 @@
                    (port_in_ports(me->desc.ports, pkt6_udp->udp_hdr.dpt) ||
                     port_in_ports(me->additional_ports, 
pkt6_udp->udp_hdr.dpt)))
                  {
-                   size_t size = sizeof(struct GNUNET_PeerIdentity) + 
sizeof(struct GNUNET_MessageHeader) + sizeof(GNUNET_HashCode) + 
ntohs(pkt6_udp->udp_hdr.len);
-                   struct GNUNET_PeerIdentity *cls = GNUNET_malloc(size);
+                   size_t size = sizeof(struct GNUNET_MESH_Tunnel*) + 
sizeof(struct GNUNET_MessageHeader) + sizeof(GNUNET_HashCode) + 
ntohs(pkt6_udp->udp_hdr.len);
+                   struct GNUNET_MESH_Tunnel **cls = GNUNET_malloc(size);
                    struct GNUNET_MessageHeader *hdr = (struct 
GNUNET_MessageHeader*)(cls+1);
                    GNUNET_HashCode* hc = (GNUNET_HashCode*)(hdr + 1);
-                   memcpy(cls, &me->desc.peer, sizeof(struct 
GNUNET_PeerIdentity));
+
                    memcpy(hc, &me->desc.service_descriptor, 
sizeof(GNUNET_HashCode));
                    memcpy(hc+1, &pkt6_udp->udp_hdr, 
ntohs(pkt6_udp->udp_hdr.len));
-                   GNUNET_CORE_peer_request_connect(core_handle,
-                                       GNUNET_TIME_UNIT_FOREVER_REL,
-                                       (struct 
GNUNET_PeerIdentity*)&me->desc.peer,
-                                       send_udp_to_peer,
-                                       cls);
+
+                   if (me->tunnel == NULL)
+                     {
+                       *cls = GNUNET_MESH_peer_request_connect_all(mesh_handle,
+                                                                   
GNUNET_TIME_UNIT_FOREVER_REL,
+                                                                   1,
+                                                                   (struct 
GNUNET_PeerIdentity*)&me->desc.peer,
+                                                                   
send_udp_to_peer,
+                                                                   NULL,
+                                                                   cls);
+                       me->tunnel = *cls;
+                     }
+                   else
+                     *cls = me->tunnel;
+                     //FIXME: somehow call send_udp_to_peer
                    GNUNET_log(GNUNET_ERROR_TYPE_DEBUG, "Queued to send to peer 
%x\n", *((unsigned int*)&me->desc.peer));
                  }
              }

Modified: gnunet/src/vpn/gnunet-daemon-vpn.c
===================================================================
--- gnunet/src/vpn/gnunet-daemon-vpn.c  2011-01-10 21:41:44 UTC (rev 14142)
+++ gnunet/src/vpn/gnunet-daemon-vpn.c  2011-01-10 21:41:47 UTC (rev 14143)
@@ -32,7 +32,7 @@
 #include "gnunet_common.h"
 #include <gnunet_os_lib.h>
 #include "gnunet_protocols.h"
-#include <gnunet_core_service.h>
+#include <gnunet_mesh_service.h>
 #include "gnunet_client_lib.h"
 #include "gnunet_container_lib.h"
 #include "gnunet_constants.h"
@@ -78,10 +78,10 @@
        dns_connection = NULL;
       }
 
-    if (core_handle != NULL)
+    if (mesh_handle != NULL)
       {
-       GNUNET_CORE_disconnect(core_handle);
-       core_handle = NULL;
+       GNUNET_MESH_disconnect(mesh_handle);
+       mesh_handle = NULL;
       }
 }
 /*}}}*/
@@ -199,17 +199,18 @@
 
 void
 send_udp_to_peer (void *cls, 
-                 int success)
+                 const struct GNUNET_PeerIdentity *peer,
+                 const struct GNUNET_TRANSPORT_ATS_Information *atsi)
 {
-  struct GNUNET_PeerIdentity *peer = cls;
+  struct GNUNET_MESH_Tunnel **tunnel = cls;
   struct GNUNET_MessageHeader *hdr =
-    (struct GNUNET_MessageHeader *) (peer + 1);
+    (struct GNUNET_MessageHeader *) (tunnel + 1);
   GNUNET_HashCode *hc = (GNUNET_HashCode *) (hdr + 1);
   struct udp_pkt *udp = (struct udp_pkt *) (hc + 1);
-  GNUNET_CORE_notify_transmit_ready (core_handle,
+  GNUNET_MESH_notify_transmit_ready (*tunnel,
+                                    GNUNET_NO,
                                     42,
                                     
GNUNET_TIME_relative_divide(GNUNET_CONSTANTS_MAX_CORK_DELAY, 2),
-                                    peer,
                                     htons (sizeof
                                            (struct GNUNET_MessageHeader) +
                                            sizeof (GNUNET_HashCode) +
@@ -374,13 +375,16 @@
 }
 
 static int
-receive_udp_back (void *cls, const struct GNUNET_PeerIdentity *other,
-            const struct GNUNET_MessageHeader *message,
-            const struct GNUNET_TRANSPORT_ATS_Information *atsi)
+receive_udp_back (void *cls, struct GNUNET_MESH_Tunnel* tunnel,
+                 void **tunnel_ctx,
+                 const struct GNUNET_MessageHeader *message,
+                 const struct GNUNET_TRANSPORT_ATS_Information *atsi)
 {
   GNUNET_HashCode *desc = (GNUNET_HashCode *) (message + 1);
   struct udp_pkt *pkt = (struct udp_pkt *) (desc + 1);
   char addr[16];
+  const struct GNUNET_PeerIdentity* other = GNUNET_MESH_get_peer(tunnel);
+
   new_ip6addr(addr, &other->hashPubKey, desc);
 
   size_t size = sizeof(struct ip6_udp) + ntohs(pkt->len) - 1 - sizeof(struct 
udp_pkt);
@@ -444,11 +448,11 @@
   return GNUNET_OK;
 }
 
-void init_core (void* cls, struct GNUNET_CORE_Handle* server, const struct 
GNUNET_PeerIdentity* my_identity, const struct 
GNUNET_CRYPTO_RsaPublicKeyBinaryEncoded *pubkey) {
-  GNUNET_log(GNUNET_ERROR_TYPE_DEBUG, "Connected to CORE, I am %x\n", 
*((unsigned long*)my_identity));
+void init_mesh (void* cls, struct GNUNET_MESH_Handle* server, const struct 
GNUNET_PeerIdentity* my_identity, const struct 
GNUNET_CRYPTO_RsaPublicKeyBinaryEncoded *pubkey) {
+  GNUNET_log(GNUNET_ERROR_TYPE_DEBUG, "Connected to MESH, I am %x\n", 
*((unsigned long*)my_identity));
 }
 
-void connect_core (void* cls, const struct GNUNET_PeerIdentity* peer, const 
struct GNUNET_TRANSPORT_ATS_Information *atsi) {
+void connect_mesh (void* cls, const struct GNUNET_PeerIdentity* peer, const 
struct GNUNET_TRANSPORT_ATS_Information *atsi) {
   GNUNET_log(GNUNET_ERROR_TYPE_DEBUG, "Connected to peer %x\n", *((unsigned 
long*)peer));
 }
 
@@ -466,21 +470,13 @@
      const char *cfgfile,
      const struct GNUNET_CONFIGURATION_Handle *cfg_)
 {
-    const static struct GNUNET_CORE_MessageHandler handlers[] = {
+    const static struct GNUNET_MESH_MessageHandler handlers[] = {
          {receive_udp_back, GNUNET_MESSAGE_TYPE_SERVICE_UDP_BACK, 0},
          {NULL, 0, 0}
     };
-    core_handle = GNUNET_CORE_connect(cfg_,
-                                     42,
+    mesh_handle = GNUNET_MESH_connect(cfg_,
                                      NULL,
-                                     init_core,
-                                     connect_core,
                                      NULL,
-                                     NULL,
-                                     NULL,
-                                     0,
-                                     NULL,
-                                     0,
                                      handlers);
     mst = GNUNET_SERVER_mst_create(&message_token, NULL);
     cfg = cfg_;

Modified: gnunet/src/vpn/gnunet-daemon-vpn.h
===================================================================
--- gnunet/src/vpn/gnunet-daemon-vpn.h  2011-01-10 21:41:44 UTC (rev 14142)
+++ gnunet/src/vpn/gnunet-daemon-vpn.h  2011-01-10 21:41:47 UTC (rev 14143)
@@ -55,7 +55,9 @@
 unsigned int port_in_ports (uint64_t ports, uint16_t port);
 
 void
-send_udp_to_peer (void *cls, int success);
+send_udp_to_peer (void *cls,
+                 const struct GNUNET_PeerIdentity *peer,
+                 const struct GNUNET_TRANSPORT_ATS_Information *atsi);
 
 /**
  * The configuration to use
@@ -63,9 +65,9 @@
 const struct GNUNET_CONFIGURATION_Handle *cfg;
 
 /**
- * The handle to core
+ * The handle to mesh
  */
-struct GNUNET_CORE_Handle *core_handle;
+struct GNUNET_MESH_Handle *mesh_handle;
 
 /**
  * The hashmap containing the mappings from ipv6-addresses to 
gnunet-descriptors
@@ -74,6 +76,7 @@
 
 struct map_entry {
     struct GNUNET_vpn_service_descriptor desc;
+    struct GNUNET_MESH_Tunnel *tunnel;
     uint16_t namelen;
     uint64_t additional_ports;
     /**




reply via email to

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