diff options
Diffstat (limited to 'src/nat-auto/gnunet-nat-auto.c')
-rw-r--r-- | src/nat-auto/gnunet-nat-auto.c | 71 |
1 files changed, 12 insertions, 59 deletions
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 }, |