gnunet-svn
[Top][All Lists]
Advanced

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

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


From: gnunet
Subject: [GNUnet-SVN] r15596 - gnunet/src/vpn
Date: Wed, 15 Jun 2011 09:15:33 +0200

Author: toelke
Date: 2011-06-15 09:15:33 +0200 (Wed, 15 Jun 2011)
New Revision: 15596

Modified:
   gnunet/src/vpn/gnunet-daemon-vpn-helper.c
   gnunet/src/vpn/gnunet-daemon-vpn.c
   gnunet/src/vpn/gnunet-daemon-vpn.h
Log:
handle traffic from remotes hosts coming back to daemon-vpn

Modified: gnunet/src/vpn/gnunet-daemon-vpn-helper.c
===================================================================
--- gnunet/src/vpn/gnunet-daemon-vpn-helper.c   2011-06-15 07:15:33 UTC (rev 
15595)
+++ gnunet/src/vpn/gnunet-daemon-vpn-helper.c   2011-06-15 07:15:33 UTC (rev 
15596)
@@ -45,13 +45,6 @@
 
 struct GNUNET_VPN_HELPER_Handle *helper_handle;
 
-struct remote_addr
-{
-  char addrlen;
-  unsigned char addr[16];
-  char proto;
-};
-
 /**
  * Start the helper-process
  *

Modified: gnunet/src/vpn/gnunet-daemon-vpn.c
===================================================================
--- gnunet/src/vpn/gnunet-daemon-vpn.c  2011-06-15 07:15:33 UTC (rev 15595)
+++ gnunet/src/vpn/gnunet-daemon-vpn.c  2011-06-15 07:15:33 UTC (rev 15596)
@@ -528,6 +528,7 @@
                  const struct GNUNET_TRANSPORT_ATS_Information *atsi)
 {
   GNUNET_HashCode *desc = (GNUNET_HashCode *) (message + 1);
+  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);
 
@@ -537,7 +538,10 @@
 
   GNUNET_assert(pkt6 != NULL);
 
-  new_ip6addr(pkt6->ip6_hdr.sadr, &other->hashPubKey, desc);
+  if (ntohs(message->type) == GNUNET_MESSAGE_TYPE_SERVICE_UDP_BACK)
+    new_ip6addr(pkt6->ip6_hdr.sadr, &other->hashPubKey, desc);
+  else
+    new_ip6addr_remote(pkt6->ip6_hdr.sadr, s->addr, s->addrlen);
 
   GNUNET_log(GNUNET_ERROR_TYPE_DEBUG, "Relaying calc:%d gnu:%d udp:%d 
bytes!\n", size, ntohs(message->size), ntohs(pkt->len));
 
@@ -573,11 +577,14 @@
   GNUNET_free(key);
 
   GNUNET_assert (me != NULL);
-  GNUNET_assert (me->desc.service_type & htonl(GNUNET_DNS_SERVICE_TYPE_UDP));
-  if (!port_in_ports(me->desc.ports, pkt6->udp_hdr.spt) &&
-      !testBit(me->additional_ports, ntohs(pkt6->udp_hdr.spt))) {
-      add_additional_port(me, ntohs(pkt6->udp_hdr.spt));
-  }
+  if (ntohs(message->type) == GNUNET_MESSAGE_TYPE_SERVICE_UDP_BACK)
+    {
+      GNUNET_assert (me->desc.service_type & 
htonl(GNUNET_DNS_SERVICE_TYPE_UDP));
+      if (!port_in_ports(me->desc.ports, pkt6->udp_hdr.spt) &&
+          !testBit(me->additional_ports, ntohs(pkt6->udp_hdr.spt))) {
+          add_additional_port(me, ntohs(pkt6->udp_hdr.spt));
+      }
+    }
 
   pkt6->udp_hdr.crc = 0;
   uint32_t sum = 0;
@@ -604,6 +611,7 @@
                  const struct GNUNET_TRANSPORT_ATS_Information *atsi)
 {
   GNUNET_HashCode *desc = (GNUNET_HashCode *) (message + 1);
+  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);
 
@@ -614,7 +622,10 @@
 
   GNUNET_assert(pkt6 != NULL);
 
-  new_ip6addr(pkt6->ip6_hdr.sadr, &other->hashPubKey, desc);
+  if (ntohs(message->type) == GNUNET_MESSAGE_TYPE_SERVICE_TCP_BACK)
+    new_ip6addr(pkt6->ip6_hdr.sadr, &other->hashPubKey, desc);
+  else
+    new_ip6addr_remote(pkt6->ip6_hdr.sadr, s->addr, s->addrlen);
 
   pkt6->shdr.type = htons(GNUNET_MESSAGE_TYPE_VPN_HELPER);
   pkt6->shdr.size = htons(size);
@@ -648,7 +659,8 @@
   GNUNET_free(key);
 
   GNUNET_assert (me != NULL);
-  GNUNET_assert (me->desc.service_type & htonl(GNUNET_DNS_SERVICE_TYPE_TCP));
+  if (ntohs(message->type) == GNUNET_MESSAGE_TYPE_SERVICE_UDP_BACK)
+    GNUNET_assert (me->desc.service_type & htonl(GNUNET_DNS_SERVICE_TYPE_TCP));
 
   pkt6->tcp_hdr.crc = 0;
   uint32_t sum = 0;
@@ -689,6 +701,8 @@
     const static struct GNUNET_MESH_MessageHandler handlers[] = {
          {receive_udp_back, GNUNET_MESSAGE_TYPE_SERVICE_UDP_BACK, 0},
          {receive_tcp_back, GNUNET_MESSAGE_TYPE_SERVICE_TCP_BACK, 0},
+         {receive_udp_back, GNUNET_MESSAGE_TYPE_REMOTE_UDP_BACK, 0},
+         {receive_tcp_back, GNUNET_MESSAGE_TYPE_REMOTE_TCP_BACK, 0},
          {NULL, 0, 0}
     };
     mesh_handle = GNUNET_MESH_connect(cfg_,

Modified: gnunet/src/vpn/gnunet-daemon-vpn.h
===================================================================
--- gnunet/src/vpn/gnunet-daemon-vpn.h  2011-06-15 07:15:33 UTC (rev 15595)
+++ gnunet/src/vpn/gnunet-daemon-vpn.h  2011-06-15 07:15:33 UTC (rev 15596)
@@ -110,4 +110,11 @@
  */
 int testBit (char *bitArray, unsigned int bitIdx);
 
+struct remote_addr
+{
+  char addrlen;
+  unsigned char addr[16];
+  char proto;
+};
+
 #endif /* end of include guard: GNUNET-DAEMON-VPN_H */




reply via email to

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