aboutsummaryrefslogtreecommitdiff
path: root/src/exit
diff options
context:
space:
mode:
authorChristian Grothoff <christian@grothoff.org>2012-02-12 11:16:39 +0000
committerChristian Grothoff <christian@grothoff.org>2012-02-12 11:16:39 +0000
commit691b149091d9bb9b57bf4a82bb370de72fe96aeb (patch)
tree2dd1557904362f96288fbfaefbcb7480e6ab579d /src/exit
parentd1187599c5b15a1eb206926012e7fbe530f20fe1 (diff)
downloadgnunet-691b149091d9bb9b57bf4a82bb370de72fe96aeb.tar.gz
gnunet-691b149091d9bb9b57bf4a82bb370de72fe96aeb.zip
-ICMPv6 has a different protocol number than ICMPv4, fix code accordingly
Diffstat (limited to 'src/exit')
-rw-r--r--src/exit/gnunet-daemon-exit.c21
1 files changed, 15 insertions, 6 deletions
diff --git a/src/exit/gnunet-daemon-exit.c b/src/exit/gnunet-daemon-exit.c
index 19b465634..7cd207a50 100644
--- a/src/exit/gnunet-daemon-exit.c
+++ b/src/exit/gnunet-daemon-exit.c
@@ -395,7 +395,8 @@ get_redirect_state (int af,
395 GNUNET_HashCode key; 395 GNUNET_HashCode key;
396 struct TunnelState *state; 396 struct TunnelState *state;
397 397
398 if (protocol == IPPROTO_ICMP) 398 if ( ( (af == AF_INET) && (proto == IPPROTO_ICMP) ) ||
399 ( (af == AF_INET6) && (proto == IPPROTO_ICMPV6) ) )
399 { 400 {
400 /* ignore ports */ 401 /* ignore ports */
401 destination_port = 0; 402 destination_port = 0;
@@ -642,10 +643,10 @@ icmp_from_helper (const struct GNUNET_TUN_IcmpHeader *icmp,
642 existing session from the IP data in the ICMP payload */ 643 existing session from the IP data in the ICMP payload */
643 source_port = 0; 644 source_port = 0;
644 destination_port = 0; 645 destination_port = 0;
645 protocol = IPPROTO_ICMP;
646 switch (af) 646 switch (af)
647 { 647 {
648 case AF_INET: 648 case AF_INET:
649 protocol = IPPROTO_ICMP;
649 switch (icmp->type) 650 switch (icmp->type)
650 { 651 {
651 case GNUNET_TUN_ICMPTYPE_ECHO_REPLY: 652 case GNUNET_TUN_ICMPTYPE_ECHO_REPLY:
@@ -680,6 +681,7 @@ icmp_from_helper (const struct GNUNET_TUN_IcmpHeader *icmp,
680 } 681 }
681 break; 682 break;
682 case AF_INET6: 683 case AF_INET6:
684 protocol = IPPROTO_ICMPV6;
683 switch (icmp->type) 685 switch (icmp->type)
684 { 686 {
685 case GNUNET_TUN_ICMPTYPE6_DESTINATION_UNREACHABLE: 687 case GNUNET_TUN_ICMPTYPE6_DESTINATION_UNREACHABLE:
@@ -725,6 +727,12 @@ icmp_from_helper (const struct GNUNET_TUN_IcmpHeader *icmp,
725 destination_ip, 0, 727 destination_ip, 0,
726 NULL); 728 NULL);
727 break; 729 break;
730 case IPPROTO_ICMPV6:
731 state = get_redirect_state (af, IPPROTO_ICMPV6,
732 source_ip, 0,
733 destination_ip, 0,
734 NULL);
735 break;
728 case IPPROTO_UDP: 736 case IPPROTO_UDP:
729 state = get_redirect_state (af, IPPROTO_UDP, 737 state = get_redirect_state (af, IPPROTO_UDP,
730 source_ip, 738 source_ip,
@@ -1060,7 +1068,7 @@ message_token (void *cls GNUNET_UNUSED, void *client GNUNET_UNUSED,
1060 &pkt6->destination_address, 1068 &pkt6->destination_address,
1061 &pkt6->source_address); 1069 &pkt6->source_address);
1062 break; 1070 break;
1063 case IPPROTO_ICMP: 1071 case IPPROTO_ICMPV6:
1064 icmp_from_helper ((const struct GNUNET_TUN_IcmpHeader *) &pkt6[1], size, 1072 icmp_from_helper ((const struct GNUNET_TUN_IcmpHeader *) &pkt6[1], size,
1065 AF_INET6, 1073 AF_INET6,
1066 &pkt6->destination_address, 1074 &pkt6->destination_address,
@@ -1100,7 +1108,8 @@ setup_fresh_address (int af,
1100 local_address->proto = (uint8_t) proto; 1108 local_address->proto = (uint8_t) proto;
1101 /* default "local" port range is often 32768--61000, 1109 /* default "local" port range is often 32768--61000,
1102 so we pick a random value in that range */ 1110 so we pick a random value in that range */
1103 if (proto == IPPROTO_ICMP) 1111 if ( ( (af == AF_INET) && (proto == IPPROTO_ICMP) ) ||
1112 ( (af == AF_INET6) && (proto == IPPROTO_ICMPV6) ) )
1104 local_address->port = 0; 1113 local_address->port = 0;
1105 else 1114 else
1106 local_address->port 1115 local_address->port
@@ -1871,7 +1880,7 @@ send_icmp_packet_via_tun (const struct SocketAddress *destination_address,
1871 1880
1872 tun->proto = htons (ETH_P_IPV6); 1881 tun->proto = htons (ETH_P_IPV6);
1873 GNUNET_TUN_initialize_ipv6_header (ipv6, 1882 GNUNET_TUN_initialize_ipv6_header (ipv6,
1874 IPPROTO_ICMP, 1883 IPPROTO_ICMPV6,
1875 sizeof (struct GNUNET_TUN_IcmpHeader) + payload_length, 1884 sizeof (struct GNUNET_TUN_IcmpHeader) + payload_length,
1876 &source_address->address.ipv6, 1885 &source_address->address.ipv6,
1877 &destination_address->address.ipv6); 1886 &destination_address->address.ipv6);
@@ -2078,7 +2087,7 @@ receive_icmp_remote (void *cls GNUNET_UNUSED, struct GNUNET_MESH_Tunnel *tunnel,
2078 if (NULL == state->heap_node) 2087 if (NULL == state->heap_node)
2079 { 2088 {
2080 state->ri.remote_address.af = af; 2089 state->ri.remote_address.af = af;
2081 state->ri.remote_address.proto = IPPROTO_ICMP; 2090 state->ri.remote_address.proto = IPPROTO_ICMPV6;
2082 setup_state_record (state); 2091 setup_state_record (state);
2083 } 2092 }
2084 /* check that ICMP type is something we want to support 2093 /* check that ICMP type is something we want to support