gnunet-svn
[Top][All Lists]
Advanced

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

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


From: gnunet
Subject: [GNUnet-SVN] r17799 - gnunet/src/vpn
Date: Wed, 26 Oct 2011 17:40:02 +0200

Author: toelke
Date: 2011-10-26 17:40:02 +0200 (Wed, 26 Oct 2011)
New Revision: 17799

Modified:
   gnunet/src/vpn/gnunet-daemon-vpn-helper.c
   gnunet/src/vpn/gnunet-daemon-vpn.c
   gnunet/src/vpn/gnunet-daemon-vpn.h
Log:
save at the tunnel whether this is an ipv4 or ipv6 connection

Modified: gnunet/src/vpn/gnunet-daemon-vpn-helper.c
===================================================================
--- gnunet/src/vpn/gnunet-daemon-vpn-helper.c   2011-10-26 15:15:30 UTC (rev 
17798)
+++ gnunet/src/vpn/gnunet-daemon-vpn-helper.c   2011-10-26 15:40:02 UTC (rev 
17799)
@@ -152,6 +152,15 @@
 
 /*}}}*/
 
+void
+initialize_tunnel_state(struct GNUNET_MESH_Tunnel* tunnel, int addrlen, struct 
GNUNET_MESH_TransmitHandle* th)
+{
+  struct tunnel_state* ts = GNUNET_malloc(sizeof *ts);
+  ts->addrlen = addrlen;
+  ts->th = th;
+  GNUNET_MESH_tunnel_set_data(tunnel, ts);
+}
+
 /**
  * Send an dns-answer-packet to the helper
  */
@@ -424,6 +433,7 @@
                                                       send_pkt_to_peer, NULL,
                                                       cls);
             me->tunnel = *cls;
+            initialize_tunnel_state(me->tunnel, 16, NULL);
           }
           else if (NULL != cls)
           {
@@ -471,6 +481,7 @@
                                                           send_pkt_to_peer,
                                                           NULL, cls);
             me->tunnel = *cls;
+            initialize_tunnel_state(me->tunnel, 16, NULL);
             if (GNUNET_APPLICATION_TYPE_INTERNET_UDP_GATEWAY == app_type)
               udp_tunnel = *cls;
             else if (GNUNET_APPLICATION_TYPE_INTERNET_TCP_GATEWAY == app_type)
@@ -627,6 +638,7 @@
                                                         send_pkt_to_peer, NULL,
                                                         cls);
               me->tunnel = *cls;
+              initialize_tunnel_state(me->tunnel, 4, NULL);
             }
             else if (NULL != cls)
             {
@@ -670,6 +682,7 @@
                                                             send_pkt_to_peer,
                                                             NULL, cls);
               me->tunnel = *cls;
+              initialize_tunnel_state(me->tunnel, 4, NULL);
             }
             else if (NULL != cls)
             {

Modified: gnunet/src/vpn/gnunet-daemon-vpn.c
===================================================================
--- gnunet/src/vpn/gnunet-daemon-vpn.c  2011-10-26 15:15:30 UTC (rev 17798)
+++ gnunet/src/vpn/gnunet-daemon-vpn.c  2011-10-26 15:40:02 UTC (rev 17799)
@@ -282,7 +282,8 @@
 {
   struct GNUNET_MESH_Tunnel **tunnel = cls;
 
-  GNUNET_MESH_tunnel_set_data (*tunnel, NULL);
+  struct tunnel_state *ts = GNUNET_MESH_tunnel_get_data(*tunnel);
+  ts->th = NULL;
 
   if (NULL != buf)
     {
@@ -310,7 +311,7 @@
     GNUNET_MESH_tunnel_set_head (*tunnel, head);
     GNUNET_MESH_tunnel_set_tail (*tunnel, tail);
 
-    struct GNUNET_MESH_TransmitHandle *th =
+    ts->th =
         GNUNET_MESH_notify_transmit_ready (*tunnel,
                                            GNUNET_NO,
                                            42,
@@ -322,7 +323,6 @@
                                            element->cls);
 
     /* save the handle */
-    GNUNET_MESH_tunnel_set_data (*tunnel, th);
     GNUNET_free (element);
   }
   GNUNET_free (cls);
@@ -355,9 +355,10 @@
   GNUNET_assert (NULL != tunnel);
   GNUNET_assert (NULL != *tunnel);
 
-  if (NULL == GNUNET_MESH_tunnel_get_data (*tunnel))
+  struct tunnel_state *ts = GNUNET_MESH_tunnel_get_data(*tunnel);
+  if (NULL == ts->th)
   {
-    struct GNUNET_MESH_TransmitHandle *th =
+    ts->th =
         GNUNET_MESH_notify_transmit_ready (*tunnel,
                                            GNUNET_NO,
                                            42,
@@ -368,8 +369,6 @@
                                            ntohs (hdr->size),
                                            send_pkt_to_peer_notify_callback,
                                            cls);
-
-    GNUNET_MESH_tunnel_set_data (*tunnel, th);
   }
   else
   {
@@ -882,8 +881,9 @@
   struct remote_addr *s = (struct remote_addr *) desc;
   struct udp_pkt *pkt = (struct udp_pkt *) (desc + 1);
   const struct GNUNET_PeerIdentity *other = GNUNET_MESH_get_peer (tunnel);
+  struct tunnel_state *ts = GNUNET_MESH_tunnel_get_data(tunnel);
 
-  if (16 == s->addrlen)
+  if (16 == ts->addrlen)
   {
     size_t size =
         sizeof (struct ip6_udp) + ntohs (pkt->len) - 1 -
@@ -1063,6 +1063,7 @@
   struct remote_addr *s = (struct remote_addr *) desc;
   struct tcp_pkt *pkt = (struct tcp_pkt *) (desc + 1);
   const struct GNUNET_PeerIdentity *other = GNUNET_MESH_get_peer (tunnel);
+  struct tunnel_state *ts = GNUNET_MESH_tunnel_get_data(tunnel);
 
   size_t pktlen =
       ntohs (message->size) - sizeof (struct GNUNET_MessageHeader) -
@@ -1071,7 +1072,7 @@
   GNUNET_log(GNUNET_ERROR_TYPE_DEBUG, "Received TCP-Packet back, addrlen = 
%d\n", s->addrlen);
 
   if (ntohs(message->type) == GNUNET_MESSAGE_TYPE_VPN_SERVICE_TCP_BACK ||
-      s->addrlen == 16)
+      ts->addrlen == 16)
   {
     size_t size = pktlen + sizeof (struct ip6_tcp) - 1;
 

Modified: gnunet/src/vpn/gnunet-daemon-vpn.h
===================================================================
--- gnunet/src/vpn/gnunet-daemon-vpn.h  2011-10-26 15:15:30 UTC (rev 17798)
+++ gnunet/src/vpn/gnunet-daemon-vpn.h  2011-10-26 15:40:02 UTC (rev 17799)
@@ -129,4 +129,10 @@
   char proto;
 };
 
+struct tunnel_state
+{
+  struct GNUNET_MESH_TransmitHandle *th;
+  int addrlen;
+};
+
 #endif /* end of include guard: GNUNET-DAEMON-VPN_H */




reply via email to

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