aboutsummaryrefslogtreecommitdiff
path: root/src/transport/plugin_transport_tcp.c
diff options
context:
space:
mode:
authorChristian Grothoff <christian@grothoff.org>2017-01-07 17:58:36 +0100
committerChristian Grothoff <christian@grothoff.org>2017-01-07 17:58:36 +0100
commitc3b77fea0f652b7d8f0641696f3a3418864ab135 (patch)
tree57a0320fe248583863e98938d2e5bea4e7b6f68f /src/transport/plugin_transport_tcp.c
parentddadc570d8fd3ce7a4f658adf9a2c9b9d9c0dcba (diff)
downloadgnunet-c3b77fea0f652b7d8f0641696f3a3418864ab135.tar.gz
gnunet-c3b77fea0f652b7d8f0641696f3a3418864ab135.zip
fix calls to test_address, expects a struct sockaddr, not an in_addr
Diffstat (limited to 'src/transport/plugin_transport_tcp.c')
-rw-r--r--src/transport/plugin_transport_tcp.c55
1 files changed, 24 insertions, 31 deletions
diff --git a/src/transport/plugin_transport_tcp.c b/src/transport/plugin_transport_tcp.c
index 605579c18..eca62a8ca 100644
--- a/src/transport/plugin_transport_tcp.c
+++ b/src/transport/plugin_transport_tcp.c
@@ -2413,27 +2413,6 @@ tcp_plugin_address_pretty_printer (void *cls,
2413 2413
2414 2414
2415/** 2415/**
2416 * Check if the given port is plausible (must be either our listen
2417 * port or our advertised port), or any port if we are behind NAT
2418 * and do not have a port open. If it is neither, we return
2419 * #GNUNET_SYSERR.
2420 *
2421 * @param plugin global variables
2422 * @param in_port port number to check
2423 * @return #GNUNET_OK if port is either open_port or adv_port
2424 */
2425static int
2426check_port (struct Plugin *plugin,
2427 uint16_t in_port)
2428{
2429 if ( (in_port == plugin->adv_port) ||
2430 (in_port == plugin->open_port) )
2431 return GNUNET_OK;
2432 return GNUNET_SYSERR;
2433}
2434
2435
2436/**
2437 * Function that will be called to check if a binary address for this 2416 * Function that will be called to check if a binary address for this
2438 * plugin is well-formed and corresponds to an address for THIS peer 2417 * plugin is well-formed and corresponds to an address for THIS peer
2439 * (as per our configuration). Naturally, if absolutely necessary, 2418 * (as per our configuration). Naturally, if absolutely necessary,
@@ -2466,6 +2445,8 @@ tcp_plugin_check_address (void *cls,
2466 2445
2467 if (addrlen == sizeof(struct IPv4TcpAddress)) 2446 if (addrlen == sizeof(struct IPv4TcpAddress))
2468 { 2447 {
2448 struct sockaddr_in s4;
2449
2469 v4 = (const struct IPv4TcpAddress *) addr; 2450 v4 = (const struct IPv4TcpAddress *) addr;
2470 if (0 != memcmp (&v4->options, 2451 if (0 != memcmp (&v4->options,
2471 &plugin->myoptions, 2452 &plugin->myoptions,
@@ -2474,17 +2455,24 @@ tcp_plugin_check_address (void *cls,
2474 GNUNET_break (0); 2455 GNUNET_break (0);
2475 return GNUNET_SYSERR; 2456 return GNUNET_SYSERR;
2476 } 2457 }
2477 if (GNUNET_OK != check_port (plugin, 2458 memset (&s4, 0, sizeof (s4));
2478 ntohs (v4->t4_port))) 2459 s4.sin_family = AF_INET;
2479 return GNUNET_SYSERR; 2460#if HAVE_SOCKADDR_IN_SIN_LEN
2461 s4.sin_len = sizeof (s4);
2462#endif
2463 s4.sin_port = v4->t4_port;
2464 s4.sin_addr.s_addr = v4->ipv4_addr;
2465
2480 if (GNUNET_OK != 2466 if (GNUNET_OK !=
2481 GNUNET_NAT_test_address (plugin->nat, 2467 GNUNET_NAT_test_address (plugin->nat,
2482 &v4->ipv4_addr, 2468 &s4,
2483 sizeof (struct in_addr))) 2469 sizeof (struct sockaddr_in)))
2484 return GNUNET_SYSERR; 2470 return GNUNET_SYSERR;
2485 } 2471 }
2486 else 2472 else
2487 { 2473 {
2474 struct sockaddr_in6 s6;
2475
2488 v6 = (const struct IPv6TcpAddress *) addr; 2476 v6 = (const struct IPv6TcpAddress *) addr;
2489 if (IN6_IS_ADDR_LINKLOCAL (&v6->ipv6_addr)) 2477 if (IN6_IS_ADDR_LINKLOCAL (&v6->ipv6_addr))
2490 { 2478 {
@@ -2498,13 +2486,18 @@ tcp_plugin_check_address (void *cls,
2498 GNUNET_break (0); 2486 GNUNET_break (0);
2499 return GNUNET_SYSERR; 2487 return GNUNET_SYSERR;
2500 } 2488 }
2501 if (GNUNET_OK != check_port (plugin, 2489 memset (&s6, 0, sizeof (s6));
2502 ntohs (v6->t6_port))) 2490 s6.sin6_family = AF_INET6;
2503 return GNUNET_SYSERR; 2491#if HAVE_SOCKADDR_IN_SIN_LEN
2492 s6.sin6_len = sizeof (s6);
2493#endif
2494 s6.sin6_port = v6->t6_port;
2495 s6.sin6_addr = v6->ipv6_addr;
2496
2504 if (GNUNET_OK != 2497 if (GNUNET_OK !=
2505 GNUNET_NAT_test_address (plugin->nat, 2498 GNUNET_NAT_test_address (plugin->nat,
2506 &v6->ipv6_addr, 2499 &s6,
2507 sizeof(struct in6_addr))) 2500 sizeof(struct sockaddr_in6)))
2508 return GNUNET_SYSERR; 2501 return GNUNET_SYSERR;
2509 } 2502 }
2510 return GNUNET_OK; 2503 return GNUNET_OK;