From 8339fd1d552b72e30c238224678f048ca3d5d12a Mon Sep 17 00:00:00 2001 From: Christian Grothoff Date: Sat, 21 Jan 2012 16:17:23 +0000 Subject: [PATCH] -misc bugfixes for ICMP --- src/exit/gnunet-daemon-exit.c | 21 ++++++++++++--------- 1 file changed, 12 insertions(+), 9 deletions(-) diff --git a/src/exit/gnunet-daemon-exit.c b/src/exit/gnunet-daemon-exit.c index 7201c61cc..dec263b53 100644 --- a/src/exit/gnunet-daemon-exit.c +++ b/src/exit/gnunet-daemon-exit.c @@ -602,7 +602,7 @@ icmp_from_helper (const struct GNUNET_TUN_IcmpHeader *icmp, source_ip, sbuf, sizeof (sbuf)), inet_ntop (af, - source_ip, + destination_ip, dbuf, sizeof (dbuf))); } if (pktlen < sizeof (struct GNUNET_TUN_IcmpHeader)) @@ -721,7 +721,7 @@ icmp_from_helper (const struct GNUNET_TUN_IcmpHeader *icmp, if (NULL == state) { GNUNET_log (GNUNET_ERROR_TYPE_INFO, - _("Packet dropped, have no matching connection information\n")); + _("ICMP Packet dropped, have no matching connection information\n")); return; } mlen = sizeof (struct GNUNET_EXIT_IcmpToVPNMessage) + pktlen - sizeof (struct GNUNET_TUN_IcmpHeader); @@ -779,7 +779,7 @@ udp_from_helper (const struct GNUNET_TUN_UdpHeader *udp, sbuf, sizeof (sbuf)), (unsigned int) ntohs (udp->spt), inet_ntop (af, - source_ip, + destination_ip, dbuf, sizeof (dbuf)), (unsigned int) ntohs (udp->dpt)); } @@ -804,7 +804,7 @@ udp_from_helper (const struct GNUNET_TUN_UdpHeader *udp, if (NULL == state) { GNUNET_log (GNUNET_ERROR_TYPE_INFO, - _("Packet dropped, have no matching connection information\n")); + _("UDP Packet dropped, have no matching connection information\n")); return; } mlen = sizeof (struct GNUNET_EXIT_UdpReplyMessage) + pktlen - sizeof (struct GNUNET_TUN_UdpHeader); @@ -879,7 +879,7 @@ tcp_from_helper (const struct GNUNET_TUN_TcpHeader *tcp, if (NULL == state) { GNUNET_log (GNUNET_ERROR_TYPE_INFO, - _("Packet dropped, have no matching connection information\n")); + _("TCP Packet dropped, have no matching connection information\n")); return; } @@ -1074,9 +1074,12 @@ setup_fresh_address (int af, local_address->proto = (uint8_t) proto; /* default "local" port range is often 32768--61000, so we pick a random value in that range */ - local_address->port - = (uint16_t) 32768 + GNUNET_CRYPTO_random_u32 (GNUNET_CRYPTO_QUALITY_WEAK, - 28232); + if (proto == IPPROTO_ICMP) + local_address->port = 0; + else + local_address->port + = (uint16_t) 32768 + GNUNET_CRYPTO_random_u32 (GNUNET_CRYPTO_QUALITY_WEAK, + 28232); switch (af) { case AF_INET: @@ -1205,7 +1208,7 @@ setup_state_record (struct TunnelState *state) inet_ntop (state->ri.local_address.af, &state->ri.local_address.address, buf, sizeof (buf)), - (unsigned int) state->ri.local_address.port); + (unsigned int) state->ri.local_address.port); } state->state_key = key; GNUNET_assert (GNUNET_OK == -- 2.25.1