gnunet-svn
[Top][All Lists]
Advanced

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

[GNUnet-SVN] r19755 - in gnunet/src: exit vpn


From: gnunet
Subject: [GNUnet-SVN] r19755 - in gnunet/src: exit vpn
Date: Sun, 12 Feb 2012 12:16:39 +0100

Author: grothoff
Date: 2012-02-12 12:16:39 +0100 (Sun, 12 Feb 2012)
New Revision: 19755

Modified:
   gnunet/src/exit/gnunet-daemon-exit.c
   gnunet/src/vpn/gnunet-service-vpn.c
Log:
-ICMPv6 has a different protocol number than ICMPv4, fix code accordingly

Modified: gnunet/src/exit/gnunet-daemon-exit.c
===================================================================
--- gnunet/src/exit/gnunet-daemon-exit.c        2012-02-12 10:53:19 UTC (rev 
19754)
+++ gnunet/src/exit/gnunet-daemon-exit.c        2012-02-12 11:16:39 UTC (rev 
19755)
@@ -395,7 +395,8 @@
   GNUNET_HashCode key;
   struct TunnelState *state;
 
-  if (protocol == IPPROTO_ICMP)
+  if ( ( (af == AF_INET) && (proto == IPPROTO_ICMP) ) ||
+       ( (af == AF_INET6) && (proto == IPPROTO_ICMPV6) ) )
   {
     /* ignore ports */
     destination_port = 0;
@@ -642,10 +643,10 @@
      existing session from the IP data in the ICMP payload */
   source_port = 0;
   destination_port = 0;
-  protocol = IPPROTO_ICMP;
   switch (af)
   {
   case AF_INET:
+    protocol = IPPROTO_ICMP;
     switch (icmp->type)
       {
       case GNUNET_TUN_ICMPTYPE_ECHO_REPLY:
@@ -680,6 +681,7 @@
       }
     break;
   case AF_INET6:
+    protocol = IPPROTO_ICMPV6;
     switch (icmp->type)
       {
       case GNUNET_TUN_ICMPTYPE6_DESTINATION_UNREACHABLE:
@@ -725,6 +727,12 @@
                                destination_ip, 0,
                                NULL);
     break;
+  case IPPROTO_ICMPV6:
+    state = get_redirect_state (af, IPPROTO_ICMPV6,
+                               source_ip, 0,
+                               destination_ip, 0,
+                               NULL);
+    break;
   case IPPROTO_UDP:
     state = get_redirect_state (af, IPPROTO_UDP,
                                source_ip,
@@ -1060,7 +1068,7 @@
                         &pkt6->destination_address, 
                         &pkt6->source_address);
        break;
-      case IPPROTO_ICMP:
+      case IPPROTO_ICMPV6:
        icmp_from_helper ((const struct GNUNET_TUN_IcmpHeader *) &pkt6[1], size,
                          AF_INET6,
                          &pkt6->destination_address, 
@@ -1100,7 +1108,8 @@
   local_address->proto = (uint8_t) proto;
   /* default "local" port range is often 32768--61000,
      so we pick a random value in that range */         
-  if (proto == IPPROTO_ICMP)
+  if ( ( (af == AF_INET) && (proto == IPPROTO_ICMP) ) ||
+       ( (af == AF_INET6) && (proto == IPPROTO_ICMPV6) ) )
     local_address->port = 0;
   else
     local_address->port 
@@ -1871,7 +1880,7 @@
        
        tun->proto = htons (ETH_P_IPV6);
        GNUNET_TUN_initialize_ipv6_header (ipv6,
-                                          IPPROTO_ICMP,
+                                          IPPROTO_ICMPV6,
                                           sizeof (struct 
GNUNET_TUN_IcmpHeader) + payload_length,
                                           &source_address->address.ipv6,
                                           &destination_address->address.ipv6);
@@ -2078,7 +2087,7 @@
     if (NULL == state->heap_node)
     {
       state->ri.remote_address.af = af;
-      state->ri.remote_address.proto = IPPROTO_ICMP;
+      state->ri.remote_address.proto = IPPROTO_ICMPV6;
       setup_state_record (state);
     }
     /* check that ICMP type is something we want to support 

Modified: gnunet/src/vpn/gnunet-service-vpn.c
===================================================================
--- gnunet/src/vpn/gnunet-service-vpn.c 2012-02-12 10:53:19 UTC (rev 19754)
+++ gnunet/src/vpn/gnunet-service-vpn.c 2012-02-12 11:16:39 UTC (rev 19755)
@@ -857,7 +857,7 @@
  *
  * @param destination description of the destination
  * @param af address family on this end (AF_INET or AF_INET6)
- * @param protocol IPPROTO_TCP or IPPROTO_UDP
+ * @param protocol IPPROTO_TCP or IPPROTO_UDP or IPPROTO_ICMP or IPPROTO_ICMPV6
  * @param source_ip source IP used by the sender (struct in_addr or struct 
in6_addr)
  * @param destination_ip destination IP used by the sender (struct in_addr or 
struct in6_addr)
  * @param payload payload of the packet after the IP header
@@ -936,8 +936,14 @@
                               &key);
     }
     break;
-  case IPPROTO_ICMP:
+  case IPPROTO_ICMP:  
+  case IPPROTO_ICMPV6:  
     {
+      if ( (AF_INET == af) ^ (protocol == IPPROTO_ICMP) )
+      {
+       GNUNET_break (0);
+       return;
+      }
       if (payload_length < sizeof (struct GNUNET_TUN_IcmpHeader))
       {
        /* blame kernel? */
@@ -948,7 +954,7 @@
       source_port = 0;
       destination_port = 0;
       get_tunnel_key_from_ips (af,
-                              IPPROTO_ICMP,
+                              protocol,
                               source_ip,
                               0,
                               destination_ip,
@@ -1238,6 +1244,7 @@
      }
     break;
   case IPPROTO_ICMP:
+  case IPPROTO_ICMPV6:
     if (destination->is_service)
     {
       struct GNUNET_EXIT_IcmpServiceMessage *ism;
@@ -1875,7 +1882,7 @@
        tun->flags = htons (0);
        tun->proto = htons (ETH_P_IPV6);
        GNUNET_TUN_initialize_ipv6_header (ipv6,
-                                          IPPROTO_ICMP,
+                                          IPPROTO_ICMPV6,
                                           sizeof (struct 
GNUNET_TUN_IcmpHeader) + mlen,
                                           &ts->destination_ip.v6,
                                           &ts->source_ip.v6);




reply via email to

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