diff options
author | Christian Grothoff <christian@grothoff.org> | 2017-01-10 18:50:16 +0100 |
---|---|---|
committer | Christian Grothoff <christian@grothoff.org> | 2017-01-10 18:50:16 +0100 |
commit | 07c8655e1ee8aa603def55b018222f3244235d1e (patch) | |
tree | 705267efc5a1628532ada0786955ab32dfeff0dc | |
parent | ea5a38ca2537d0892049dc3ce64576d2a9bafa97 (diff) | |
download | gnunet-07c8655e1ee8aa603def55b018222f3244235d1e.tar.gz gnunet-07c8655e1ee8aa603def55b018222f3244235d1e.zip |
fix misc compilation issues in nat-auto
-rw-r--r-- | doc/man/gnunet-nat-auto.1 | 26 | ||||
-rw-r--r-- | src/include/gnunet_nat_auto_service.h | 15 | ||||
-rw-r--r-- | src/nat-auto/gnunet-nat-auto.c | 71 | ||||
-rw-r--r-- | src/nat-auto/nat_auto_api_test.c | 120 | ||||
-rw-r--r-- | src/transport/plugin_transport_udp_broadcasting.c | 1 |
5 files changed, 94 insertions, 139 deletions
diff --git a/doc/man/gnunet-nat-auto.1 b/doc/man/gnunet-nat-auto.1 index 310f14d43..249d54da4 100644 --- a/doc/man/gnunet-nat-auto.1 +++ b/doc/man/gnunet-nat-auto.1 | |||
@@ -19,16 +19,12 @@ as attempting auto\-configuration. | |||
19 | Attempt auto\-configuration for NAT traversal. | 19 | Attempt auto\-configuration for NAT traversal. |
20 | 20 | ||
21 | .B | 21 | .B |
22 | .IP "\-b ADDRESS, \-\-bind=ADDRESS" | ||
23 | Assume that the service is (locally) bound to ADDRESS. | ||
24 | |||
25 | .B | ||
26 | .IP "\-c FILENAME, \-\-config=FILENAME" | 22 | .IP "\-c FILENAME, \-\-config=FILENAME" |
27 | Use the configuration file FILENAME. | 23 | Use the configuration file FILENAME. |
28 | 24 | ||
29 | .B | 25 | .B |
30 | .IP "\-e ADDRESS, \-\-external=ADDRESS" | 26 | .IP "\-S NAME, \-\-section=NAME" |
31 | Assume that ADDRESS is the globally visible address of the peer. | 27 | Name of the configuration section with details about the configuration to test. For example "transport-tcp". |
32 | 28 | ||
33 | .IP "\-t, \-\-tcp" | 29 | .IP "\-t, \-\-tcp" |
34 | Use TCP. | 30 | Use TCP. |
@@ -49,11 +45,25 @@ Write configuration to configuration file, useful in combination with autoconfig | |||
49 | Probe and write result to configuration: | 45 | Probe and write result to configuration: |
50 | 46 | ||
51 | # gnunet\-nat\-auto \-aw | 47 | # gnunet\-nat\-auto \-aw |
52 | 48 | ||
49 | |||
50 | \fBTest configuration:\fR | ||
51 | |||
52 | Test TCP configuration: | ||
53 | |||
54 | # gnunet\-nat\-auto -t \-S transport-tcp | ||
55 | |||
56 | Test HTTP configuration: | ||
57 | |||
58 | # gnunet\-nat\-auto -t \-S transport-http | ||
59 | |||
60 | Test UDP configuration: | ||
61 | |||
62 | # gnunet\-nat\-auto -u \-S transport-udp | ||
63 | |||
53 | 64 | ||
54 | .SH BUGS | 65 | .SH BUGS |
55 | Report bugs by using Mantis <https://gnunet.org/bugs/> or by sending electronic mail to <gnunet\-developers@gnu.org> | 66 | Report bugs by using Mantis <https://gnunet.org/bugs/> or by sending electronic mail to <gnunet\-developers@gnu.org> |
56 | 67 | ||
57 | .SH SEE ALSO | 68 | .SH SEE ALSO |
58 | gnunet\-transport(1) gnunet\-nat(1) | 69 | gnunet\-transport(1) gnunet\-nat(1) |
59 | |||
diff --git a/src/include/gnunet_nat_auto_service.h b/src/include/gnunet_nat_auto_service.h index c458dc81a..a369c49e0 100644 --- a/src/include/gnunet_nat_auto_service.h +++ b/src/include/gnunet_nat_auto_service.h | |||
@@ -45,16 +45,12 @@ struct GNUNET_NAT_AUTO_Test; | |||
45 | 45 | ||
46 | 46 | ||
47 | /** | 47 | /** |
48 | * Start testing if NAT traversal works using the given configuration | 48 | * Start testing if NAT traversal works using the given configuration. |
49 | * (IPv4-only). The transport adapters should be down while using | 49 | * The transport adapters should be down while using this function. |
50 | * this function. | ||
51 | * | 50 | * |
52 | * @param cfg configuration for the NAT traversal | 51 | * @param cfg configuration for the NAT traversal |
53 | * @param proto protocol to test, i.e. IPPROTO_TCP or IPPROTO_UDP | 52 | * @param proto protocol to test, i.e. IPPROTO_TCP or IPPROTO_UDP |
54 | * @param bind_ip IPv4 address to bind to | 53 | * @param section_name configuration section to use for configuration |
55 | * @param bnd_port port to bind to, 0 to test connection reversal | ||
56 | * @param extern_ip IPv4 address to externally advertise | ||
57 | * @param extern_port externally advertised port to use | ||
58 | * @param report function to call with the result of the test | 54 | * @param report function to call with the result of the test |
59 | * @param report_cls closure for @a report | 55 | * @param report_cls closure for @a report |
60 | * @return handle to cancel NAT test | 56 | * @return handle to cancel NAT test |
@@ -62,10 +58,7 @@ struct GNUNET_NAT_AUTO_Test; | |||
62 | struct GNUNET_NAT_AUTO_Test * | 58 | struct GNUNET_NAT_AUTO_Test * |
63 | GNUNET_NAT_AUTO_test_start (const struct GNUNET_CONFIGURATION_Handle *cfg, | 59 | GNUNET_NAT_AUTO_test_start (const struct GNUNET_CONFIGURATION_Handle *cfg, |
64 | uint8_t proto, | 60 | uint8_t proto, |
65 | struct in_addr bind_ip, | 61 | const char *section_name, |
66 | uint16_t bnd_port, | ||
67 | struct in_addr extern_ip, | ||
68 | uint16_t extern_port, | ||
69 | GNUNET_NAT_TestCallback report, | 62 | GNUNET_NAT_TestCallback report, |
70 | void *report_cls); | 63 | void *report_cls); |
71 | 64 | ||
diff --git a/src/nat-auto/gnunet-nat-auto.c b/src/nat-auto/gnunet-nat-auto.c index d411c6d75..9ba81eb5f 100644 --- a/src/nat-auto/gnunet-nat-auto.c +++ b/src/nat-auto/gnunet-nat-auto.c | |||
@@ -47,7 +47,7 @@ static int write_cfg; | |||
47 | 47 | ||
48 | /** | 48 | /** |
49 | * Configuration filename. | 49 | * Configuration filename. |
50 | */ | 50 | */ |
51 | static const char *cfg_file; | 51 | static const char *cfg_file; |
52 | 52 | ||
53 | /** | 53 | /** |
@@ -56,16 +56,9 @@ static const char *cfg_file; | |||
56 | static const struct GNUNET_CONFIGURATION_Handle *cfg; | 56 | static const struct GNUNET_CONFIGURATION_Handle *cfg; |
57 | 57 | ||
58 | /** | 58 | /** |
59 | * Address we are bound to (in test), or should bind to | 59 | * Adapter we are supposed to test. |
60 | * (if #do_stun is set). | ||
61 | */ | ||
62 | static char *bind_addr; | ||
63 | |||
64 | /** | ||
65 | * External IP address and port to use for the test. | ||
66 | * If not set, use #bind_addr. | ||
67 | */ | 60 | */ |
68 | static char *extern_addr; | 61 | static char *section_name; |
69 | 62 | ||
70 | /** | 63 | /** |
71 | * Should we run autoconfiguration? | 64 | * Should we run autoconfiguration? |
@@ -122,7 +115,7 @@ auto_conf_iter (void *cls, | |||
122 | const char *value) | 115 | const char *value) |
123 | { | 116 | { |
124 | struct GNUNET_CONFIGURATION_Handle *new_cfg = cls; | 117 | struct GNUNET_CONFIGURATION_Handle *new_cfg = cls; |
125 | 118 | ||
126 | PRINTF ("%s: %s\n", | 119 | PRINTF ("%s: %s\n", |
127 | option, | 120 | option, |
128 | value); | 121 | value); |
@@ -192,7 +185,7 @@ auto_config_cb (void *cls, | |||
192 | /* Apply diff to original configuration and show changes | 185 | /* Apply diff to original configuration and show changes |
193 | to the user */ | 186 | to the user */ |
194 | new_cfg = write_cfg ? GNUNET_CONFIGURATION_dup (cfg) : NULL; | 187 | new_cfg = write_cfg ? GNUNET_CONFIGURATION_dup (cfg) : NULL; |
195 | 188 | ||
196 | if (NULL != diff) | 189 | if (NULL != diff) |
197 | { | 190 | { |
198 | GNUNET_log (GNUNET_ERROR_TYPE_MESSAGE, | 191 | GNUNET_log (GNUNET_ERROR_TYPE_MESSAGE, |
@@ -296,12 +289,9 @@ run (void *cls, | |||
296 | const char *cfgfile, | 289 | const char *cfgfile, |
297 | const struct GNUNET_CONFIGURATION_Handle *c) | 290 | const struct GNUNET_CONFIGURATION_Handle *c) |
298 | { | 291 | { |
299 | struct sockaddr_in bind_sa; | ||
300 | struct sockaddr_in extern_sa; | ||
301 | |||
302 | cfg_file = cfgfile; | 292 | cfg_file = cfgfile; |
303 | cfg = c; | 293 | cfg = c; |
304 | 294 | ||
305 | GNUNET_SCHEDULER_add_shutdown (&do_shutdown, | 295 | GNUNET_SCHEDULER_add_shutdown (&do_shutdown, |
306 | NULL); | 296 | NULL); |
307 | 297 | ||
@@ -327,45 +317,11 @@ run (void *cls, | |||
327 | if (use_udp) | 317 | if (use_udp) |
328 | proto = IPPROTO_UDP; | 318 | proto = IPPROTO_UDP; |
329 | 319 | ||
330 | if (NULL != bind_addr) | 320 | if (NULL != section_name) |
331 | { | ||
332 | if (GNUNET_OK != | ||
333 | GNUNET_STRINGS_to_address_ipv4 (bind_addr, | ||
334 | strlen (bind_addr), | ||
335 | &bind_sa)) | ||
336 | { | ||
337 | GNUNET_log (GNUNET_ERROR_TYPE_MESSAGE, | ||
338 | "Invalid socket address `%s'\n", | ||
339 | bind_addr); | ||
340 | global_ret = 1; | ||
341 | return; | ||
342 | } | ||
343 | } | ||
344 | if (NULL != extern_addr) | ||
345 | { | ||
346 | if (GNUNET_OK != | ||
347 | GNUNET_STRINGS_to_address_ipv4 (extern_addr, | ||
348 | strlen (extern_addr), | ||
349 | &extern_sa)) | ||
350 | { | ||
351 | GNUNET_log (GNUNET_ERROR_TYPE_MESSAGE, | ||
352 | "Invalid socket address `%s'\n", | ||
353 | extern_addr); | ||
354 | global_ret = 1; | ||
355 | return; | ||
356 | } | ||
357 | } | ||
358 | |||
359 | if (NULL != bind_addr) | ||
360 | { | 321 | { |
361 | if (NULL == extern_addr) | ||
362 | extern_sa = bind_sa; | ||
363 | nt = GNUNET_NAT_AUTO_test_start (c, | 322 | nt = GNUNET_NAT_AUTO_test_start (c, |
364 | proto, | 323 | proto, |
365 | bind_sa.sin_addr, | 324 | section_name, |
366 | ntohs (bind_sa.sin_port), | ||
367 | extern_sa.sin_addr, | ||
368 | ntohs (extern_sa.sin_port), | ||
369 | &test_report_cb, | 325 | &test_report_cb, |
370 | NULL); | 326 | NULL); |
371 | } | 327 | } |
@@ -374,7 +330,7 @@ run (void *cls, | |||
374 | 330 | ||
375 | 331 | ||
376 | /** | 332 | /** |
377 | * Main function of gnunet-nat | 333 | * Main function of gnunet-nat-auto |
378 | * | 334 | * |
379 | * @param argc number of command-line arguments | 335 | * @param argc number of command-line arguments |
380 | * @param argv command line | 336 | * @param argv command line |
@@ -388,12 +344,9 @@ main (int argc, | |||
388 | {'a', "auto", NULL, | 344 | {'a', "auto", NULL, |
389 | gettext_noop ("run autoconfiguration"), | 345 | gettext_noop ("run autoconfiguration"), |
390 | GNUNET_NO, &GNUNET_GETOPT_set_one, &do_auto }, | 346 | GNUNET_NO, &GNUNET_GETOPT_set_one, &do_auto }, |
391 | {'b', "bind", "ADDRESS", | 347 | {'S', "section", "NAME", |
392 | gettext_noop ("which IP and port are we bound to"), | 348 | gettext_noop ("section name providing the configuration for the adapter"), |
393 | GNUNET_YES, &GNUNET_GETOPT_set_string, &bind_addr }, | 349 | GNUNET_YES, &GNUNET_GETOPT_set_string, §ion_name }, |
394 | {'e', "external", "ADDRESS", | ||
395 | gettext_noop ("which external IP and port should be used to test"), | ||
396 | GNUNET_YES, &GNUNET_GETOPT_set_string, &extern_addr }, | ||
397 | {'t', "tcp", NULL, | 350 | {'t', "tcp", NULL, |
398 | gettext_noop ("use TCP"), | 351 | gettext_noop ("use TCP"), |
399 | GNUNET_NO, &GNUNET_GETOPT_set_one, &use_tcp }, | 352 | GNUNET_NO, &GNUNET_GETOPT_set_one, &use_tcp }, |
diff --git a/src/nat-auto/nat_auto_api_test.c b/src/nat-auto/nat_auto_api_test.c index 8359e3cb5..fb2bcd679 100644 --- a/src/nat-auto/nat_auto_api_test.c +++ b/src/nat-auto/nat_auto_api_test.c | |||
@@ -24,7 +24,8 @@ | |||
24 | */ | 24 | */ |
25 | #include "platform.h" | 25 | #include "platform.h" |
26 | #include "gnunet_util_lib.h" | 26 | #include "gnunet_util_lib.h" |
27 | #include "gnunet_nat_lib.h" | 27 | #include "gnunet_nat_service.h" |
28 | #include "gnunet_nat_auto_service.h" | ||
28 | #include "nat-auto.h" | 29 | #include "nat-auto.h" |
29 | 30 | ||
30 | #define LOG(kind,...) GNUNET_log_from (kind, "nat", __VA_ARGS__) | 31 | #define LOG(kind,...) GNUNET_log_from (kind, "nat", __VA_ARGS__) |
@@ -153,19 +154,19 @@ struct GNUNET_NAT_AUTO_Test | |||
153 | struct GNUNET_SCHEDULER_Task *ttask; | 154 | struct GNUNET_SCHEDULER_Task *ttask; |
154 | 155 | ||
155 | /** | 156 | /** |
156 | * #GNUNET_YES if we're testing TCP | 157 | * Section name of plugin to test. |
157 | */ | 158 | */ |
158 | int is_tcp; | 159 | char *section_name; |
159 | 160 | ||
160 | /** | 161 | /** |
161 | * Data that should be transmitted or source-port. | 162 | * IPPROTO_TCP or IPPROTO_UDP. |
162 | */ | 163 | */ |
163 | uint16_t data; | 164 | int proto; |
164 | 165 | ||
165 | /** | 166 | /** |
166 | * Advertised port to the other peer. | 167 | * Data that should be transmitted or source-port. |
167 | */ | 168 | */ |
168 | uint16_t adv_port; | 169 | uint16_t data; |
169 | 170 | ||
170 | /** | 171 | /** |
171 | * Status code to be reported to the timeout/status call | 172 | * Status code to be reported to the timeout/status call |
@@ -358,12 +359,14 @@ mq_error_handler (void *cls, | |||
358 | * @param cls closure | 359 | * @param cls closure |
359 | * @param add_remove #GNUNET_YES to mean the new public IP address, #GNUNET_NO to mean | 360 | * @param add_remove #GNUNET_YES to mean the new public IP address, #GNUNET_NO to mean |
360 | * the previous (now invalid) one | 361 | * the previous (now invalid) one |
362 | * @param ac address class the address belongs to | ||
361 | * @param addr either the previous or the new public IP address | 363 | * @param addr either the previous or the new public IP address |
362 | * @param addrlen actual length of the @a addr | 364 | * @param addrlen actual length of the @a addr |
363 | */ | 365 | */ |
364 | static void | 366 | static void |
365 | addr_cb (void *cls, | 367 | addr_cb (void *cls, |
366 | int add_remove, | 368 | int add_remove, |
369 | enum GNUNET_NAT_AddressClass ac, | ||
367 | const struct sockaddr *addr, | 370 | const struct sockaddr *addr, |
368 | socklen_t addrlen) | 371 | socklen_t addrlen) |
369 | { | 372 | { |
@@ -411,58 +414,50 @@ addr_cb (void *cls, | |||
411 | msg->dst_ipv4 = sa->sin_addr.s_addr; | 414 | msg->dst_ipv4 = sa->sin_addr.s_addr; |
412 | msg->dport = sa->sin_port; | 415 | msg->dport = sa->sin_port; |
413 | msg->data = h->data; | 416 | msg->data = h->data; |
414 | msg->is_tcp = htonl ((uint32_t) h->is_tcp); | 417 | msg->is_tcp = htonl ((uint32_t) (h->proto == IPPROTO_TCP)); |
415 | GNUNET_MQ_send (ca->mq, | 418 | GNUNET_MQ_send (ca->mq, |
416 | env); | 419 | env); |
417 | } | 420 | } |
418 | 421 | ||
419 | 422 | ||
420 | /** | 423 | /** |
421 | * Timeout task for a nat test. | 424 | * Calls the report-callback reporting failure. |
422 | * Calls the report-callback with a timeout return value | ||
423 | * | 425 | * |
424 | * Destroys the nat handle after the callback has been processed. | 426 | * Destroys the nat handle after the callback has been processed. |
425 | * | 427 | * |
426 | * @param cls handle to the timed out NAT test | 428 | * @param cls handle to the timed out NAT test |
427 | */ | 429 | */ |
428 | static void | 430 | static void |
429 | do_timeout (void *cls) | 431 | do_fail (void *cls) |
430 | { | 432 | { |
431 | struct GNUNET_NAT_AUTO_Test *nh = cls; | 433 | struct GNUNET_NAT_AUTO_Test *nh = cls; |
432 | 434 | ||
433 | nh->ttask = NULL; | 435 | nh->ttask = NULL; |
434 | nh->report (nh->report_cls, | 436 | nh->report (nh->report_cls, |
435 | (GNUNET_NAT_ERROR_SUCCESS == nh->status) | 437 | nh->status); |
436 | ? GNUNET_NAT_ERROR_TIMEOUT | ||
437 | : nh->status); | ||
438 | } | 438 | } |
439 | 439 | ||
440 | 440 | ||
441 | /** | 441 | /** |
442 | * Start testing if NAT traversal works using the | 442 | * Start testing if NAT traversal works using the given configuration. |
443 | * given configuration (IPv4-only). | 443 | * The transport adapters should be down while using this function. |
444 | * | ||
445 | * ALL failures are reported directly to the report callback | ||
446 | * | 444 | * |
447 | * @param cfg configuration for the NAT traversal | 445 | * @param cfg configuration for the NAT traversal |
448 | * @param is_tcp #GNUNET_YES to test TCP, #GNUNET_NO to test UDP | 446 | * @param proto protocol to test, i.e. IPPROTO_TCP or IPPROTO_UDP |
449 | * @param bnd_port port to bind to, 0 for connection reversal | 447 | * @param section_name configuration section to use for configuration |
450 | * @param adv_port externally advertised port to use | ||
451 | * @param timeout delay after which the test should be aborted | ||
452 | * @param report function to call with the result of the test | 448 | * @param report function to call with the result of the test |
453 | * @param report_cls closure for @a report | 449 | * @param report_cls closure for @a report |
454 | * @return handle to cancel NAT test or NULL. The error is always indicated via the report callback | 450 | * @return handle to cancel NAT test |
455 | */ | 451 | */ |
456 | struct GNUNET_NAT_AUTO_Test * | 452 | struct GNUNET_NAT_AUTO_Test * |
457 | GNUNET_NAT_AUTO_test_start (const struct GNUNET_CONFIGURATION_Handle *cfg, | 453 | GNUNET_NAT_AUTO_test_start (const struct GNUNET_CONFIGURATION_Handle *cfg, |
458 | int is_tcp, | 454 | uint8_t proto, |
459 | uint16_t bnd_port, | 455 | const char *section_name, |
460 | uint16_t adv_port, | 456 | GNUNET_NAT_TestCallback report, |
461 | struct GNUNET_TIME_Relative timeout, | 457 | void *report_cls) |
462 | GNUNET_NAT_TestCallback report, | ||
463 | void *report_cls) | ||
464 | { | 458 | { |
465 | struct GNUNET_NAT_AUTO_Test *nh; | 459 | struct GNUNET_NAT_AUTO_Test *nh; |
460 | unsigned long long bnd_port; | ||
466 | struct sockaddr_in sa; | 461 | struct sockaddr_in sa; |
467 | const struct sockaddr *addrs[] = { | 462 | const struct sockaddr *addrs[] = { |
468 | (const struct sockaddr *) &sa | 463 | (const struct sockaddr *) &sa |
@@ -471,18 +466,30 @@ GNUNET_NAT_AUTO_test_start (const struct GNUNET_CONFIGURATION_Handle *cfg, | |||
471 | sizeof (sa) | 466 | sizeof (sa) |
472 | }; | 467 | }; |
473 | 468 | ||
469 | if ( (GNUNET_OK != | ||
470 | GNUNET_CONFIGURATION_get_value_number (cfg, | ||
471 | section_name, | ||
472 | "PORT", | ||
473 | &bnd_port)) || | ||
474 | (bnd_port > 65535) ) | ||
475 | { | ||
476 | GNUNET_log (GNUNET_ERROR_TYPE_ERROR, | ||
477 | _("Failed to find valid PORT in section `%s'\n"), | ||
478 | section_name); | ||
479 | return NULL; | ||
480 | } | ||
481 | |||
474 | memset (&sa, 0, sizeof (sa)); | 482 | memset (&sa, 0, sizeof (sa)); |
475 | sa.sin_family = AF_INET; | 483 | sa.sin_family = AF_INET; |
476 | sa.sin_port = htons (bnd_port); | 484 | sa.sin_port = htons ((uint16_t) bnd_port); |
477 | #if HAVE_SOCKADDR_IN_SIN_LEN | 485 | #if HAVE_SOCKADDR_IN_SIN_LEN |
478 | sa.sin_len = sizeof (sa); | 486 | sa.sin_len = sizeof (sa); |
479 | #endif | 487 | #endif |
480 | 488 | ||
481 | nh = GNUNET_new (struct GNUNET_NAT_AUTO_Test); | 489 | nh = GNUNET_new (struct GNUNET_NAT_AUTO_Test); |
482 | nh->cfg = cfg; | 490 | nh->cfg = cfg; |
483 | nh->is_tcp = is_tcp; | 491 | nh->proto = proto; |
484 | nh->data = bnd_port; | 492 | nh->section_name = GNUNET_strdup (section_name); |
485 | nh->adv_port = adv_port; | ||
486 | nh->report = report; | 493 | nh->report = report; |
487 | nh->report_cls = report_cls; | 494 | nh->report_cls = report_cls; |
488 | nh->status = GNUNET_NAT_ERROR_SUCCESS; | 495 | nh->status = GNUNET_NAT_ERROR_SUCCESS; |
@@ -490,28 +497,24 @@ GNUNET_NAT_AUTO_test_start (const struct GNUNET_CONFIGURATION_Handle *cfg, | |||
490 | { | 497 | { |
491 | nh->nat | 498 | nh->nat |
492 | = GNUNET_NAT_register (cfg, | 499 | = GNUNET_NAT_register (cfg, |
493 | is_tcp, | 500 | section_name, |
494 | 0, | 501 | proto, |
495 | 0, | 502 | 0, NULL, NULL, |
496 | NULL, | ||
497 | NULL, | ||
498 | &addr_cb, | 503 | &addr_cb, |
499 | &reversal_cb, | 504 | &reversal_cb, |
500 | nh, | 505 | nh); |
501 | NULL); | ||
502 | } | 506 | } |
503 | else | 507 | else |
504 | { | 508 | { |
505 | nh->lsock = | 509 | nh->lsock |
506 | GNUNET_NETWORK_socket_create (AF_INET, | 510 | = GNUNET_NETWORK_socket_create (AF_INET, |
507 | (is_tcp == | 511 | proto, |
508 | GNUNET_YES) ? SOCK_STREAM : SOCK_DGRAM, | ||
509 | 0); | 512 | 0); |
510 | if ((nh->lsock == NULL) || | 513 | if ( (NULL == nh->lsock) || |
511 | (GNUNET_OK != | 514 | (GNUNET_OK != |
512 | GNUNET_NETWORK_socket_bind (nh->lsock, | 515 | GNUNET_NETWORK_socket_bind (nh->lsock, |
513 | (const struct sockaddr *) &sa, | 516 | (const struct sockaddr *) &sa, |
514 | sizeof (sa)))) | 517 | sizeof (sa)))) |
515 | { | 518 | { |
516 | GNUNET_log (GNUNET_ERROR_TYPE_ERROR, | 519 | GNUNET_log (GNUNET_ERROR_TYPE_ERROR, |
517 | _("Failed to create listen socket bound to `%s' for NAT test: %s\n"), | 520 | _("Failed to create listen socket bound to `%s' for NAT test: %s\n"), |
@@ -524,11 +527,11 @@ GNUNET_NAT_AUTO_test_start (const struct GNUNET_CONFIGURATION_Handle *cfg, | |||
524 | nh->lsock = NULL; | 527 | nh->lsock = NULL; |
525 | } | 528 | } |
526 | nh->status = GNUNET_NAT_ERROR_INTERNAL_NETWORK_ERROR; | 529 | nh->status = GNUNET_NAT_ERROR_INTERNAL_NETWORK_ERROR; |
527 | nh->ttask = GNUNET_SCHEDULER_add_now (&do_timeout, | 530 | nh->ttask = GNUNET_SCHEDULER_add_now (&do_fail, |
528 | nh); | 531 | nh); |
529 | return nh; | 532 | return nh; |
530 | } | 533 | } |
531 | if (GNUNET_YES == is_tcp) | 534 | if (IPPROTO_TCP == proto) |
532 | { | 535 | { |
533 | GNUNET_break (GNUNET_OK == | 536 | GNUNET_break (GNUNET_OK == |
534 | GNUNET_NETWORK_socket_listen (nh->lsock, | 537 | GNUNET_NETWORK_socket_listen (nh->lsock, |
@@ -550,17 +553,16 @@ GNUNET_NAT_AUTO_test_start (const struct GNUNET_CONFIGURATION_Handle *cfg, | |||
550 | LOG (GNUNET_ERROR_TYPE_INFO, | 553 | LOG (GNUNET_ERROR_TYPE_INFO, |
551 | "NAT test listens on port %u (%s)\n", | 554 | "NAT test listens on port %u (%s)\n", |
552 | bnd_port, | 555 | bnd_port, |
553 | (GNUNET_YES == is_tcp) ? "tcp" : "udp"); | 556 | (IPPROTO_TCP == proto) ? "tcp" : "udp"); |
554 | nh->nat = GNUNET_NAT_register (cfg, | 557 | nh->nat = GNUNET_NAT_register (cfg, |
555 | is_tcp, | 558 | section_name, |
556 | adv_port, | 559 | proto, |
557 | 1, | 560 | 1, |
558 | addrs, | 561 | addrs, |
559 | addrlens, | 562 | addrlens, |
560 | &addr_cb, | 563 | &addr_cb, |
561 | NULL, | 564 | NULL, |
562 | nh, | 565 | nh); |
563 | NULL); | ||
564 | if (NULL == nh->nat) | 566 | if (NULL == nh->nat) |
565 | { | 567 | { |
566 | LOG (GNUNET_ERROR_TYPE_INFO, | 568 | LOG (GNUNET_ERROR_TYPE_INFO, |
@@ -576,14 +578,11 @@ GNUNET_NAT_AUTO_test_start (const struct GNUNET_CONFIGURATION_Handle *cfg, | |||
576 | nh->lsock = NULL; | 578 | nh->lsock = NULL; |
577 | } | 579 | } |
578 | nh->status = GNUNET_NAT_ERROR_NAT_REGISTER_FAILED; | 580 | nh->status = GNUNET_NAT_ERROR_NAT_REGISTER_FAILED; |
579 | nh->ttask = GNUNET_SCHEDULER_add_now (&do_timeout, | 581 | nh->ttask = GNUNET_SCHEDULER_add_now (&do_fail, |
580 | nh); | 582 | nh); |
581 | return nh; | 583 | return nh; |
582 | } | 584 | } |
583 | } | 585 | } |
584 | nh->ttask = GNUNET_SCHEDULER_add_delayed (timeout, | ||
585 | &do_timeout, | ||
586 | nh); | ||
587 | return nh; | 586 | return nh; |
588 | } | 587 | } |
589 | 588 | ||
@@ -638,6 +637,7 @@ GNUNET_NAT_AUTO_test_stop (struct GNUNET_NAT_AUTO_Test *tst) | |||
638 | GNUNET_NAT_unregister (tst->nat); | 637 | GNUNET_NAT_unregister (tst->nat); |
639 | tst->nat = NULL; | 638 | tst->nat = NULL; |
640 | } | 639 | } |
640 | GNUNET_free (tst->section_name); | ||
641 | GNUNET_free (tst); | 641 | GNUNET_free (tst); |
642 | } | 642 | } |
643 | 643 | ||
diff --git a/src/transport/plugin_transport_udp_broadcasting.c b/src/transport/plugin_transport_udp_broadcasting.c index 8ef001ddb..a440830fd 100644 --- a/src/transport/plugin_transport_udp_broadcasting.c +++ b/src/transport/plugin_transport_udp_broadcasting.c | |||
@@ -29,7 +29,6 @@ | |||
29 | #include "gnunet_hello_lib.h" | 29 | #include "gnunet_hello_lib.h" |
30 | #include "gnunet_util_lib.h" | 30 | #include "gnunet_util_lib.h" |
31 | #include "gnunet_fragmentation_lib.h" | 31 | #include "gnunet_fragmentation_lib.h" |
32 | #include "gnunet_nat_lib.h" | ||
33 | #include "gnunet_protocols.h" | 32 | #include "gnunet_protocols.h" |
34 | #include "gnunet_resolver_service.h" | 33 | #include "gnunet_resolver_service.h" |
35 | #include "gnunet_signatures.h" | 34 | #include "gnunet_signatures.h" |