}
}
-static void
-nat_add_address (void *cls, int add_remove, const struct sockaddr *addr,
- socklen_t addrlen)
+static void *
+find_address (struct Plugin *plugin, const struct sockaddr *addr, socklen_t addrlen)
{
- struct Plugin *plugin = cls;
+ int af;
struct IPv4HttpAddressWrapper *w_t4 = NULL;
struct IPv6HttpAddressWrapper *w_t6 = NULL;
- int af;
af = addr->sa_family;
switch (af)
break;
w_t4 = w_t4->next;
}
+ return w_t4;
+ break;
+ case AF_INET6:
+ w_t6 = plugin->ipv6_addr_head;
+ struct sockaddr_in6 *a6 = (struct sockaddr_in6 *) addr;
+
+ while (w_t6)
+ {
+ int res = memcmp (&w_t6->addr6.ipv6_addr, &a6->sin6_addr,
+ sizeof (struct in6_addr));
+
+ if (res == 0)
+ {
+ if (a6->sin6_port != w_t6->addr6.u6_port)
+ res = -1;
+ }
+ if (0 == res)
+ break;
+ w_t6 = w_t6->next;
+ }
+ return w_t6;
+ break;
+ default:
+ return NULL;
+ }
+
+
+}
+
+static void
+nat_add_address (void *cls, int add_remove, const struct sockaddr *addr,
+ socklen_t addrlen)
+{
+ struct Plugin *plugin = cls;
+ struct IPv4HttpAddressWrapper *w_t4 = NULL;
+ struct IPv6HttpAddressWrapper *w_t6 = NULL;
+ int af;
+
+ af = addr->sa_family;
+ switch (af)
+ {
+ case AF_INET:
+ w_t4 = find_address (plugin, addr, addrlen);
if (w_t4 == NULL)
{
+ struct sockaddr_in *a4 = (struct sockaddr_in *) addr;
w_t4 = GNUNET_malloc (sizeof (struct IPv4HttpAddressWrapper));
memcpy (&w_t4->addr.ipv4_addr, &a4->sin_addr, sizeof (struct in_addr));
w_t4->addr.u4_port = a4->sin_port;
break;
case AF_INET6:
- w_t6 = plugin->ipv6_addr_head;
- struct sockaddr_in6 *a6 = (struct sockaddr_in6 *) addr;
-
- while (w_t6)
- {
- int res = memcmp (&w_t6->addr6.ipv6_addr, &a6->sin6_addr,
- sizeof (struct in6_addr));
-
- if (res == 0)
- {
- if (a6->sin6_port != w_t6->addr6.u6_port)
- res = -1;
- }
- if (0 == res)
- break;
- w_t6 = w_t6->next;
- }
+ w_t6 = find_address (plugin, addr, addrlen);
if (w_t6 == NULL)
{
w_t6 = GNUNET_malloc (sizeof (struct IPv6HttpAddressWrapper));
-
+ struct sockaddr_in6 *a6 = (struct sockaddr_in6 *) addr;
memcpy (&w_t6->addr6.ipv6_addr, &a6->sin6_addr, sizeof (struct in6_addr));
w_t6->addr6.u6_port = a6->sin6_port;
switch (af)
{
case AF_INET:
- w_t4 = plugin->ipv4_addr_head;
- struct sockaddr_in *a4 = (struct sockaddr_in *) addr;
-
- while (w_t4 != NULL)
- {
- int res = memcmp (&w_t4->addr.ipv4_addr,
- &a4->sin_addr,
- sizeof (struct in_addr));
-
- if (res == 0)
- {
- if (a4->sin_port != w_t4->addr.u4_port)
- res = -1;
- }
-
- if (0 == res)
- break;
- w_t4 = w_t4->next;
- }
- if (w_t4 == NULL)
+ w_t4 = find_address (plugin, addr, addrlen);
return;
#if DEBUG_HTTP
GNUNET_free (w_t4);
break;
case AF_INET6:
- w_t6 = plugin->ipv6_addr_head;
- struct sockaddr_in6 *a6 = (struct sockaddr_in6 *) addr;
-
- while (w_t6)
- {
- int res = memcmp (&w_t6->addr6.ipv6_addr, &a6->sin6_addr,
- sizeof (struct in6_addr));
-
- if (res == 0)
- {
- if (a6->sin6_port != w_t6->addr6.u6_port)
- res = -1;
- }
- if (0 == res)
- break;
- w_t6 = w_t6->next;
- }
+ w_t6 = find_address (plugin, addr, addrlen);
if (w_t6 == NULL)
return;
#if DEBUG_HTTP