diff options
author | Nathan S. Evans <evans@in.tum.de> | 2010-06-09 15:32:33 +0000 |
---|---|---|
committer | Nathan S. Evans <evans@in.tum.de> | 2010-06-09 15:32:33 +0000 |
commit | 8346f8d77f92715907e537352abeea84382bd176 (patch) | |
tree | 7be49727db5209ce379bfde5510d98c490176b3c /src/transport/plugin_transport_udp.c | |
parent | 063a4d7093e93ac2d5bcaa3b0b0f3deabbe4f391 (diff) | |
download | gnunet-8346f8d77f92715907e537352abeea84382bd176.tar.gz gnunet-8346f8d77f92715907e537352abeea84382bd176.zip |
first implementation of NAT punching for TCP transport plugin... doubt that it works, but testcases that do NOT use NAT still work. not to be viewed by anyone.
Diffstat (limited to 'src/transport/plugin_transport_udp.c')
-rw-r--r-- | src/transport/plugin_transport_udp.c | 39 |
1 files changed, 6 insertions, 33 deletions
diff --git a/src/transport/plugin_transport_udp.c b/src/transport/plugin_transport_udp.c index f36f587ad..10bbf2972 100644 --- a/src/transport/plugin_transport_udp.c +++ b/src/transport/plugin_transport_udp.c | |||
@@ -1296,15 +1296,14 @@ udp_transport_server_start (void *cls) | |||
1296 | socklen_t addrlen; | 1296 | socklen_t addrlen; |
1297 | int sockets_created; | 1297 | int sockets_created; |
1298 | 1298 | ||
1299 | /* Pipe to read from started processes stdout (on read end) */ | ||
1300 | plugin->server_stdout = GNUNET_DISK_pipe(GNUNET_YES); | ||
1301 | |||
1302 | sockets_created = 0; | 1299 | sockets_created = 0; |
1303 | if (plugin->server_stdout == NULL) | ||
1304 | return sockets_created; | ||
1305 | 1300 | ||
1306 | if (plugin->behind_nat == GNUNET_YES) | 1301 | if (plugin->behind_nat == GNUNET_YES) |
1307 | { | 1302 | { |
1303 | /* Pipe to read from started processes stdout (on read end) */ | ||
1304 | plugin->server_stdout = GNUNET_DISK_pipe(GNUNET_YES); | ||
1305 | if (plugin->server_stdout == NULL) | ||
1306 | return sockets_created; | ||
1308 | #if DEBUG_UDP_NAT | 1307 | #if DEBUG_UDP_NAT |
1309 | GNUNET_log_from (GNUNET_ERROR_TYPE_DEBUG, | 1308 | GNUNET_log_from (GNUNET_ERROR_TYPE_DEBUG, |
1310 | "udp", | 1309 | "udp", |
@@ -1410,32 +1409,6 @@ udp_transport_server_start (void *cls) | |||
1410 | 1409 | ||
1411 | 1410 | ||
1412 | /** | 1411 | /** |
1413 | * Check if the given port is plausible (must be either | ||
1414 | * our listen port or our advertised port). If it is | ||
1415 | * neither, we return one of these two ports at random. | ||
1416 | * | ||
1417 | * @return either in_port or a more plausible port | ||
1418 | */ | ||
1419 | static uint16_t | ||
1420 | check_port (struct Plugin *plugin, uint16_t in_port) | ||
1421 | { | ||
1422 | |||
1423 | /* FIXME: remember what ports we are using to better respond to this */ | ||
1424 | return in_port; | ||
1425 | /* | ||
1426 | for (i = plugin->starting_port; i < plugin->num_ports + plugin->starting_port; i++) | ||
1427 | { | ||
1428 | if (in_port == i) | ||
1429 | return in_port; | ||
1430 | } | ||
1431 | |||
1432 | return GNUNET_CRYPTO_random_u32 (GNUNET_CRYPTO_QUALITY_WEAK, | ||
1433 | plugin->num_ports) + plugin->starting_port; | ||
1434 | */ | ||
1435 | } | ||
1436 | |||
1437 | |||
1438 | /** | ||
1439 | * Another peer has suggested an address for this peer and transport | 1412 | * Another peer has suggested an address for this peer and transport |
1440 | * plugin. Check that this could be a valid address. This function | 1413 | * plugin. Check that this could be a valid address. This function |
1441 | * is not expected to 'validate' the address in the sense of trying to | 1414 | * is not expected to 'validate' the address in the sense of trying to |
@@ -1468,12 +1441,12 @@ udp_check_address (void *cls, void *addr, size_t addrlen) | |||
1468 | if (addrlen == sizeof (struct sockaddr_in)) | 1441 | if (addrlen == sizeof (struct sockaddr_in)) |
1469 | { | 1442 | { |
1470 | v4 = (struct sockaddr_in *) buf; | 1443 | v4 = (struct sockaddr_in *) buf; |
1471 | v4->sin_port = htons (check_port (plugin, ntohs (v4->sin_port))); | 1444 | v4->sin_port = htons (plugin->port); |
1472 | } | 1445 | } |
1473 | else | 1446 | else |
1474 | { | 1447 | { |
1475 | v6 = (struct sockaddr_in6 *) buf; | 1448 | v6 = (struct sockaddr_in6 *) buf; |
1476 | v6->sin6_port = htons (check_port (plugin, ntohs (v6->sin6_port))); | 1449 | v6->sin6_port = htons (plugin->port); |
1477 | } | 1450 | } |
1478 | 1451 | ||
1479 | #if DEBUG_UDP_NAT | 1452 | #if DEBUG_UDP_NAT |