gnunet-svn
[Top][All Lists]
Advanced

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

[GNUnet-SVN] r19285 - gnunet/src/exit


From: gnunet
Subject: [GNUnet-SVN] r19285 - gnunet/src/exit
Date: Fri, 20 Jan 2012 17:29:42 +0100

Author: grothoff
Date: 2012-01-20 17:29:42 +0100 (Fri, 20 Jan 2012)
New Revision: 19285

Modified:
   gnunet/src/exit/gnunet-daemon-exit.c
Log:
-fix off-by-tcp-header size

Modified: gnunet/src/exit/gnunet-daemon-exit.c
===================================================================
--- gnunet/src/exit/gnunet-daemon-exit.c        2012-01-20 16:19:43 UTC (rev 
19284)
+++ gnunet/src/exit/gnunet-daemon-exit.c        2012-01-20 16:29:42 UTC (rev 
19285)
@@ -671,7 +671,8 @@
     char sbuf[INET6_ADDRSTRLEN];
     char dbuf[INET6_ADDRSTRLEN];
     GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
-               "Received TCP packet going from %s:%u to %s:%u\n",
+               "Received TCP packet with %u bytes going from %s:%u to %s:%u\n",
+               pktlen - sizeof (struct GNUNET_TUN_TcpHeader),
                inet_ntop (af,
                           source_ip,
                           sbuf, sizeof (sbuf)),
@@ -765,45 +766,6 @@
   size -= sizeof (struct GNUNET_TUN_Layer2PacketHeader) + sizeof (struct 
GNUNET_MessageHeader);
   switch (ntohs (pkt_tun->proto))
   {
-  case ETH_P_IPV6:
-    {
-      const struct GNUNET_TUN_IPv6Header *pkt6;
-
-      if (size < sizeof (struct GNUNET_TUN_IPv6Header))
-      {
-       /* Kernel to blame? */
-       GNUNET_break (0);
-       return;
-      }
-      pkt6 = (struct GNUNET_TUN_IPv6Header *) &pkt_tun[1];
-      if (size != ntohs (pkt6->payload_length))
-      {
-       /* Kernel to blame? */
-       GNUNET_break (0);
-       return;
-      }
-      size -= sizeof (struct GNUNET_TUN_IPv6Header);
-      switch (pkt6->next_header)
-      {
-      case IPPROTO_UDP:
-       udp_from_helper ((const struct GNUNET_TUN_UdpHeader *) &pkt6[1], size,
-                        AF_INET6,
-                        &pkt6->destination_address, 
-                        &pkt6->source_address);
-       break;
-      case IPPROTO_TCP:
-       tcp_from_helper ((const struct GNUNET_TUN_TcpHeader *) &pkt6[1], size,
-                        AF_INET6,
-                        &pkt6->destination_address, 
-                        &pkt6->source_address);
-       break;
-      default:
-       GNUNET_log (GNUNET_ERROR_TYPE_WARNING,
-                   _("IPv6 packet with unsupported next header received.  
Ignored.\n"));
-       return;
-      }
-    }
-    break;
   case ETH_P_IPV4:
     {
       const struct GNUNET_TUN_IPv4Header *pkt4;
@@ -848,6 +810,45 @@
       }
     }
     break;
+  case ETH_P_IPV6:
+    {
+      const struct GNUNET_TUN_IPv6Header *pkt6;
+
+      if (size < sizeof (struct GNUNET_TUN_IPv6Header))
+      {
+       /* Kernel to blame? */
+       GNUNET_break (0);
+       return;
+      }
+      pkt6 = (struct GNUNET_TUN_IPv6Header *) &pkt_tun[1];
+      if (size != ntohs (pkt6->payload_length))
+      {
+       /* Kernel to blame? */
+       GNUNET_break (0);
+       return;
+      }
+      size -= sizeof (struct GNUNET_TUN_IPv6Header);
+      switch (pkt6->next_header)
+      {
+      case IPPROTO_UDP:
+       udp_from_helper ((const struct GNUNET_TUN_UdpHeader *) &pkt6[1], size,
+                        AF_INET6,
+                        &pkt6->destination_address, 
+                        &pkt6->source_address);
+       break;
+      case IPPROTO_TCP:
+       tcp_from_helper ((const struct GNUNET_TUN_TcpHeader *) &pkt6[1], size,
+                        AF_INET6,
+                        &pkt6->destination_address, 
+                        &pkt6->source_address);
+       break;
+      default:
+       GNUNET_log (GNUNET_ERROR_TYPE_WARNING,
+                   _("IPv6 packet with unsupported next header received.  
Ignored.\n"));
+       return;
+      }
+    }
+    break;
   default:
     GNUNET_log (GNUNET_ERROR_TYPE_WARNING,
                _("Packet from unknown protocol %u received.  Ignored.\n"),
@@ -1248,6 +1249,7 @@
     GNUNET_break (0);
     return;
   }
+  len += sizeof (struct GNUNT_TUN_TcpHeader);
   len += payload_length;
   if (len >= GNUNET_SERVER_MAX_MESSAGE_SIZE)
   {
@@ -1259,7 +1261,7 @@
     struct GNUNET_MessageHeader *hdr;
     struct GNUNET_TUN_Layer2PacketHeader *tun;
     
-    hdr= (struct GNUNET_MessageHeader *) buf;
+    hdr = (struct GNUNET_MessageHeader *) buf;
     hdr->type = htons (GNUNET_MESSAGE_TYPE_VPN_HELPER);
     hdr->size = htons (len);
     tun = (struct GNUNET_TUN_Layer2PacketHeader*) &hdr[1];
@@ -1537,7 +1539,8 @@
   {
     char buf[INET6_ADDRSTRLEN];
     GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
-               "Received additional data from %s for TCP stream to %s:%u\n",
+               "Received additional %u bytes of data from %s for TCP stream to 
%s:%u\n",
+               pkt_len,
                GNUNET_i2s (sender),
                inet_ntop (state->ri.remote_address.af, 
                           &state->ri.remote_address.address,




reply via email to

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