From c1c6696c6b32012a29a6f77feb71a824f2c767ac Mon Sep 17 00:00:00 2001 From: Matthias Wachs Date: Mon, 27 Feb 2012 15:23:32 +0000 Subject: [PATCH] - improved nat handling --- src/transport/plugin_transport_udp.c | 25 ++++++++++++++++++------- 1 file changed, 18 insertions(+), 7 deletions(-) diff --git a/src/transport/plugin_transport_udp.c b/src/transport/plugin_transport_udp.c index 6f190de20..7141563a2 100644 --- a/src/transport/plugin_transport_udp.c +++ b/src/transport/plugin_transport_udp.c @@ -762,6 +762,8 @@ udp_plugin_get_session (void *cls, { struct Session * s = NULL; struct Plugin * plugin = cls; + struct IPv6UdpAddress * udp_a6; + struct IPv4UdpAddress * udp_a4; GNUNET_assert (plugin != NULL); GNUNET_assert (address != NULL); @@ -775,14 +777,23 @@ udp_plugin_get_session (void *cls, return NULL; } - if ((address->address_length == sizeof (struct IPv4UdpAddress)) && - (plugin->sockv4 == NULL)) - return NULL; - - if ((address->address_length == sizeof (struct IPv6UdpAddress)) && - (plugin->sockv6 == NULL)) - return NULL; + if (address->address_length == sizeof (struct IPv4UdpAddress)) + { + if (plugin->sockv4 == NULL) + return NULL; + udp_a4 = (struct IPv4UdpAddress *) address->address; + if (udp_a4->u4_port == 0) + return NULL; + } + if (address->address_length == sizeof (struct IPv6UdpAddress)) + { + if (plugin->sockv6 == NULL) + return NULL; + udp_a6 = (struct IPv6UdpAddress *) address->address; + if (udp_a6->u6_port == 0) + return NULL; + } /* check if session already exists */ struct SessionCompareContext cctx; -- 2.25.1