diff options
author | Christian Grothoff <christian@grothoff.org> | 2016-12-25 19:20:16 +0100 |
---|---|---|
committer | Christian Grothoff <christian@grothoff.org> | 2016-12-25 19:20:16 +0100 |
commit | 9ba4c1d15e6bcb20c47dff1067ab76e86d7c0f8a (patch) | |
tree | 75722fe825a4adb3b2718309b25f07967419c598 /src/nat | |
parent | d39684ffb508e1697abb283413c9bbbee978b49d (diff) | |
download | gnunet-9ba4c1d15e6bcb20c47dff1067ab76e86d7c0f8a.tar.gz gnunet-9ba4c1d15e6bcb20c47dff1067ab76e86d7c0f8a.zip |
notes for next steps with NAT
Diffstat (limited to 'src/nat')
-rw-r--r-- | src/nat/gnunet-nat-server.c | 44 | ||||
-rw-r--r-- | src/nat/gnunet-nat.c | 8 | ||||
-rw-r--r-- | src/nat/gnunet-service-nat.c | 3 |
3 files changed, 33 insertions, 22 deletions
diff --git a/src/nat/gnunet-nat-server.c b/src/nat/gnunet-nat-server.c index 6722deefb..1692a8ef1 100644 --- a/src/nat/gnunet-nat-server.c +++ b/src/nat/gnunet-nat-server.c | |||
@@ -42,8 +42,7 @@ static const struct GNUNET_CONFIGURATION_Handle *cfg; | |||
42 | 42 | ||
43 | 43 | ||
44 | /** | 44 | /** |
45 | * Try contacting the peer using autonomous | 45 | * Try contacting the peer using autonomous NAT traveral method. |
46 | * NAT traveral method. | ||
47 | * | 46 | * |
48 | * @param dst_ipv4 IPv4 address to send the fake ICMP message | 47 | * @param dst_ipv4 IPv4 address to send the fake ICMP message |
49 | * @param dport destination port to include in ICMP message | 48 | * @param dport destination port to include in ICMP message |
@@ -78,7 +77,7 @@ try_anat (uint32_t dst_ipv4, | |||
78 | 77 | ||
79 | 78 | ||
80 | /** | 79 | /** |
81 | * Closure for 'tcp_send'. | 80 | * Closure for #tcp_send. |
82 | */ | 81 | */ |
83 | struct TcpContext | 82 | struct TcpContext |
84 | { | 83 | { |
@@ -98,7 +97,7 @@ struct TcpContext | |||
98 | * Task called by the scheduler once we can do the TCP send | 97 | * Task called by the scheduler once we can do the TCP send |
99 | * (or once we failed to connect...). | 98 | * (or once we failed to connect...). |
100 | * | 99 | * |
101 | * @param cls the 'struct TcpContext' | 100 | * @param cls the `struct TcpContext` |
102 | */ | 101 | */ |
103 | static void | 102 | static void |
104 | tcp_send (void *cls) | 103 | tcp_send (void *cls) |
@@ -182,7 +181,7 @@ try_send_tcp (uint32_t dst_ipv4, | |||
182 | 181 | ||
183 | /** | 182 | /** |
184 | * Try to send @a data to the | 183 | * Try to send @a data to the |
185 | * IP @a dst_ipv4' at port @a dport via UDP. | 184 | * IP @a dst_ipv4 at port @a dport via UDP. |
186 | * | 185 | * |
187 | * @param dst_ipv4 target IP | 186 | * @param dst_ipv4 target IP |
188 | * @param dport target port | 187 | * @param dport target port |
@@ -313,12 +312,13 @@ run (void *cls, | |||
313 | }; | 312 | }; |
314 | 313 | ||
315 | cfg = c; | 314 | cfg = c; |
316 | if ((args[0] == NULL) || (1 != SSCANF (args[0], "%u", &port)) || (0 == port) | 315 | if ( (NULL == args[0]) || |
317 | || (65536 <= port)) | 316 | (1 != SSCANF (args[0], "%u", &port)) || |
317 | (0 == port) || | ||
318 | (65536 <= port) ) | ||
318 | { | 319 | { |
319 | FPRINTF (stderr, | 320 | FPRINTF (stderr, |
320 | _ | 321 | _("Please pass valid port number as the first argument! (got `%s')\n"), |
321 | ("Please pass valid port number as the first argument! (got `%s')\n"), | ||
322 | args[0]); | 322 | args[0]); |
323 | return; | 323 | return; |
324 | } | 324 | } |
@@ -332,10 +332,14 @@ run (void *cls, | |||
332 | in4.sin_len = sizeof (in4); | 332 | in4.sin_len = sizeof (in4); |
333 | in6.sin6_len = sizeof (in6); | 333 | in6.sin6_len = sizeof (in6); |
334 | #endif | 334 | #endif |
335 | server = | 335 | server = GNUNET_SERVER_create (NULL, |
336 | GNUNET_SERVER_create (NULL, NULL, (struct sockaddr * const *) sa, slen, | 336 | NULL, |
337 | GNUNET_TIME_UNIT_SECONDS, GNUNET_YES); | 337 | (struct sockaddr * const *) sa, |
338 | GNUNET_SERVER_add_handlers (server, handlers); | 338 | slen, |
339 | GNUNET_TIME_UNIT_SECONDS, | ||
340 | GNUNET_YES); | ||
341 | GNUNET_SERVER_add_handlers (server, | ||
342 | handlers); | ||
339 | GNUNET_SCHEDULER_add_shutdown (&shutdown_task, | 343 | GNUNET_SCHEDULER_add_shutdown (&shutdown_task, |
340 | NULL); | 344 | NULL); |
341 | } | 345 | } |
@@ -355,13 +359,19 @@ main (int argc, char *const argv[]) | |||
355 | GNUNET_GETOPT_OPTION_END | 359 | GNUNET_GETOPT_OPTION_END |
356 | }; | 360 | }; |
357 | 361 | ||
358 | if (GNUNET_OK != GNUNET_STRINGS_get_utf8_args (argc, argv, &argc, &argv)) | 362 | if (GNUNET_OK != |
363 | GNUNET_STRINGS_get_utf8_args (argc, argv, | ||
364 | &argc, &argv)) | ||
359 | return 2; | 365 | return 2; |
360 | 366 | ||
361 | if (GNUNET_OK != | 367 | if (GNUNET_OK != |
362 | GNUNET_PROGRAM_run (argc, argv, "gnunet-nat-server [options] PORT", | 368 | GNUNET_PROGRAM_run (argc, |
363 | _("GNUnet NAT traversal test helper daemon"), options, | 369 | argv, |
364 | &run, NULL)) | 370 | "gnunet-nat-server [options] PORT", |
371 | _("GNUnet NAT traversal test helper daemon"), | ||
372 | options, | ||
373 | &run, | ||
374 | NULL)) | ||
365 | { | 375 | { |
366 | GNUNET_free ((void*) argv); | 376 | GNUNET_free ((void*) argv); |
367 | return 1; | 377 | return 1; |
diff --git a/src/nat/gnunet-nat.c b/src/nat/gnunet-nat.c index d04a9337a..4d0ed5723 100644 --- a/src/nat/gnunet-nat.c +++ b/src/nat/gnunet-nat.c | |||
@@ -459,7 +459,7 @@ run (void *cls, | |||
459 | struct sockaddr_in extern_sa; | 459 | struct sockaddr_in extern_sa; |
460 | struct sockaddr *local_sa; | 460 | struct sockaddr *local_sa; |
461 | struct sockaddr *remote_sa; | 461 | struct sockaddr *remote_sa; |
462 | size_t local_len; | 462 | socklen_t local_len; |
463 | size_t remote_len; | 463 | size_t remote_len; |
464 | 464 | ||
465 | cfg_file = cfgfile; | 465 | cfg_file = cfgfile; |
@@ -527,9 +527,9 @@ run (void *cls, | |||
527 | } | 527 | } |
528 | if (NULL != local_addr) | 528 | if (NULL != local_addr) |
529 | { | 529 | { |
530 | local_len = GNUNET_STRINGS_parse_socket_addr (local_addr, | 530 | local_len = (socklen_t) GNUNET_STRINGS_parse_socket_addr (local_addr, |
531 | &af, | 531 | &af, |
532 | &local_sa); | 532 | &local_sa); |
533 | if (0 == local_len) | 533 | if (0 == local_len) |
534 | { | 534 | { |
535 | GNUNET_log (GNUNET_ERROR_TYPE_MESSAGE, | 535 | GNUNET_log (GNUNET_ERROR_TYPE_MESSAGE, |
diff --git a/src/nat/gnunet-service-nat.c b/src/nat/gnunet-service-nat.c index 5b5a108eb..762175437 100644 --- a/src/nat/gnunet-service-nat.c +++ b/src/nat/gnunet-service-nat.c | |||
@@ -29,9 +29,10 @@ | |||
29 | * | 29 | * |
30 | * TODO: | 30 | * TODO: |
31 | * - test ICMP based NAT traversal | 31 | * - test ICMP based NAT traversal |
32 | * - implement "more" autoconfig: | ||
33 | * re-work gnunet-nat-server & integrate! | ||
32 | * - implement & test STUN processing to classify NAT; | 34 | * - implement & test STUN processing to classify NAT; |
33 | * basically, open port & try different methods. | 35 | * basically, open port & try different methods. |
34 | * - implement "more" autoconfig | ||
35 | * - implement NEW logic for external IP detection | 36 | * - implement NEW logic for external IP detection |
36 | */ | 37 | */ |
37 | #include "platform.h" | 38 | #include "platform.h" |