aboutsummaryrefslogtreecommitdiff
path: root/src/transport/gnunet-transport.c
diff options
context:
space:
mode:
Diffstat (limited to 'src/transport/gnunet-transport.c')
-rw-r--r--src/transport/gnunet-transport.c573
1 files changed, 342 insertions, 231 deletions
diff --git a/src/transport/gnunet-transport.c b/src/transport/gnunet-transport.c
index 2f6604bdf..80a3e2d15 100644
--- a/src/transport/gnunet-transport.c
+++ b/src/transport/gnunet-transport.c
@@ -1,6 +1,6 @@
1/* 1/*
2 This file is part of GNUnet. 2 This file is part of GNUnet.
3 (C) 2011 Christian Grothoff (and other contributing authors) 3 (C) 2011-2014 Christian Grothoff (and other contributing authors)
4 4
5 GNUnet is free software; you can redistribute it and/or modify 5 GNUnet is free software; you can redistribute it and/or modify
6 it under the terms of the GNU General Public License as published 6 it under the terms of the GNU General Public License as published
@@ -27,7 +27,6 @@
27 * This utility can be used to test if a transport mechanism for 27 * This utility can be used to test if a transport mechanism for
28 * GNUnet is properly configured. 28 * GNUnet is properly configured.
29 */ 29 */
30
31#include "platform.h" 30#include "platform.h"
32#include "gnunet_util_lib.h" 31#include "gnunet_util_lib.h"
33#include "gnunet_resolver_service.h" 32#include "gnunet_resolver_service.h"
@@ -43,6 +42,132 @@
43#define RESOLUTION_TIMEOUT GNUNET_TIME_relative_multiply (GNUNET_TIME_UNIT_SECONDS, 30) 42#define RESOLUTION_TIMEOUT GNUNET_TIME_relative_multiply (GNUNET_TIME_UNIT_SECONDS, 30)
44#define OP_TIMEOUT GNUNET_TIME_relative_multiply (GNUNET_TIME_UNIT_SECONDS, 30) 43#define OP_TIMEOUT GNUNET_TIME_relative_multiply (GNUNET_TIME_UNIT_SECONDS, 30)
45 44
45
46struct ValidationResolutionContext
47{
48 struct ValidationResolutionContext *next;
49
50 struct ValidationResolutionContext *prev;
51
52 struct GNUNET_PeerIdentity id;
53
54 struct GNUNET_HELLO_Address *addrcp;
55
56 struct GNUNET_TIME_Absolute last_validation;
57
58 struct GNUNET_TIME_Absolute valid_until;
59
60 struct GNUNET_TIME_Absolute next_validation;
61
62 enum GNUNET_TRANSPORT_ValidationState state;
63
64 struct GNUNET_TRANSPORT_AddressToStringContext *asc;
65
66 char *transport;
67
68 int printed;
69};
70
71
72struct MonitoredPeer
73{
74 enum GNUNET_TRANSPORT_PeerState state;
75
76 struct GNUNET_TIME_Absolute state_timeout;
77
78 struct GNUNET_HELLO_Address *address;
79};
80
81
82struct PeerResolutionContext
83{
84 struct PeerResolutionContext *next;
85 struct PeerResolutionContext *prev;
86 struct GNUNET_PeerIdentity id;
87 struct GNUNET_HELLO_Address *addrcp;
88 struct GNUNET_TRANSPORT_AddressToStringContext *asc;
89 enum GNUNET_TRANSPORT_PeerState state;
90 struct GNUNET_TIME_Absolute state_timeout;
91 char *transport;
92 int printed;
93};
94
95
96/**
97 * Context for a plugin test.
98 */
99struct TestContext
100{
101 /**
102 * Previous in DLL
103 */
104 struct TestContext *prev;
105
106 /**
107 * Next in DLL
108 */
109 struct TestContext *next;
110
111 /**
112 * Handle to the active NAT test.
113 */
114 struct GNUNET_NAT_Test *tst;
115
116 /**
117 * Task identifier for the timeout.
118 */
119 GNUNET_SCHEDULER_TaskIdentifier tsk;
120
121 /**
122 * Name of plugin under test.
123 */
124 char *name;
125
126 /**
127 * Bound port
128 */
129 unsigned long long bnd_port;
130
131 /**
132 * Advertised ports
133 */
134 unsigned long long adv_port;
135
136};
137
138
139/**
140 *
141 */
142enum TestResult
143{
144 /**
145 * NAT returned success
146 */
147 NAT_TEST_SUCCESS = GNUNET_OK,
148
149 /**
150 * NAT returned failure
151 */
152 NAT_TEST_FAIL = GNUNET_NO,
153
154 /**
155 * NAT returned failure while running test
156 */
157 NAT_TEST_INTERNAL_FAIL = GNUNET_SYSERR,
158
159 /**
160 * We could not start the test
161 */
162 NAT_TEST_FAILED_TO_START = 2,
163
164 /**
165 * We had a timeout while running the test
166 */
167 NAT_TEST_TIMEOUT = 3
168};
169
170
46/** 171/**
47 * Benchmarking block size in KB 172 * Benchmarking block size in KB
48 */ 173 */
@@ -66,7 +191,7 @@ static struct GNUNET_CONFIGURATION_Handle *cfg;
66/** 191/**
67 * Try_connect handle 192 * Try_connect handle
68 */ 193 */
69struct GNUNET_TRANSPORT_TryConnectHandle * tc_handle; 194struct GNUNET_TRANSPORT_TryConnectHandle *tc_handle;
70 195
71/** 196/**
72 * Option -s. 197 * Option -s.
@@ -173,6 +298,9 @@ static struct GNUNET_CONTAINER_MultiPeerMap *monitored_peers;
173 */ 298 */
174static struct GNUNET_TRANSPORT_PeerMonitoringContext *pic; 299static struct GNUNET_TRANSPORT_PeerMonitoringContext *pic;
175 300
301/**
302 *
303 */
176static struct GNUNET_TRANSPORT_ValidationMonitoringContext *vic; 304static struct GNUNET_TRANSPORT_ValidationMonitoringContext *vic;
177 305
178/** 306/**
@@ -221,93 +349,13 @@ struct TestContext *head;
221 */ 349 */
222struct TestContext *tail; 350struct TestContext *tail;
223 351
224/**
225 * Context for a plugin test.
226 */
227struct TestContext
228{
229 /**
230 * Previous in DLL
231 */
232 struct TestContext *prev;
233
234 /**
235 * Next in DLL
236 */
237 struct TestContext *next;
238
239 /**
240 * Handle to the active NAT test.
241 */
242 struct GNUNET_NAT_Test *tst;
243
244 /**
245 * Task identifier for the timeout.
246 */
247 GNUNET_SCHEDULER_TaskIdentifier tsk;
248
249 /**
250 * Name of plugin under test.
251 */
252 char *name;
253
254 /**
255 * Bound port
256 */
257 unsigned long long bnd_port;
258
259 /**
260 * Advertised ports
261 */
262 unsigned long long adv_port;
263
264};
265
266enum TestResult
267{
268 /* NAT returned success */
269 NAT_TEST_SUCCESS = GNUNET_OK,
270
271 /* NAT returned failure */
272 NAT_TEST_FAIL = GNUNET_NO,
273
274 /* NAT returned failure while running test */
275 NAT_TEST_INTERNAL_FAIL = GNUNET_SYSERR,
276
277 /* We could not start the test */
278 NAT_TEST_FAILED_TO_START = 2,
279
280 /* We had a timeout while running the test */
281 NAT_TEST_TIMEOUT = 3,
282};
283
284static struct ValidationResolutionContext *vc_head; 352static struct ValidationResolutionContext *vc_head;
285static struct ValidationResolutionContext *vc_tail;
286 353
287struct ValidationResolutionContext 354static struct ValidationResolutionContext *vc_tail;
288{
289 struct ValidationResolutionContext *next;
290 struct ValidationResolutionContext *prev;
291
292 struct GNUNET_PeerIdentity id;
293 struct GNUNET_HELLO_Address *addrcp;
294 struct GNUNET_TIME_Absolute last_validation;
295 struct GNUNET_TIME_Absolute valid_until;
296 struct GNUNET_TIME_Absolute next_validation;
297 enum GNUNET_TRANSPORT_ValidationState state;
298
299 struct GNUNET_TRANSPORT_AddressToStringContext *asc;
300 355
301 char *transport; 356static struct PeerResolutionContext *rc_head;
302 int printed;
303};
304 357
305struct MonitoredPeer 358static struct PeerResolutionContext *rc_tail;
306{
307 enum GNUNET_TRANSPORT_PeerState state;
308 struct GNUNET_TIME_Absolute state_timeout;
309 struct GNUNET_HELLO_Address *address;
310};
311 359
312 360
313static int 361static int
@@ -317,8 +365,10 @@ destroy_it (void *cls,
317{ 365{
318 struct MonitoredPeer *m = value; 366 struct MonitoredPeer *m = value;
319 367
320 GNUNET_assert (GNUNET_OK == GNUNET_CONTAINER_multipeermap_remove (monitored_peers, 368 GNUNET_assert (GNUNET_OK ==
321 key, value)); 369 GNUNET_CONTAINER_multipeermap_remove (monitored_peers,
370 key,
371 value));
322 GNUNET_free_non_null (m->address); 372 GNUNET_free_non_null (m->address);
323 GNUNET_free (value); 373 GNUNET_free (value);
324 return GNUNET_OK; 374 return GNUNET_OK;
@@ -329,15 +379,17 @@ destroy_it (void *cls,
329 * Task run in monitor mode when the user presses CTRL-C to abort. 379 * Task run in monitor mode when the user presses CTRL-C to abort.
330 * Stops monitoring activity. 380 * Stops monitoring activity.
331 * 381 *
332 * @param cls the 'struct GNUNET_TRANSPORT_PeerIterateContext *' 382 * @param cls NULL
333 * @param tc scheduler context 383 * @param tc scheduler context
334 */ 384 */
335static void 385static void
336shutdown_task (void *cls, const struct GNUNET_SCHEDULER_TaskContext *tc) 386shutdown_task (void *cls,
387 const struct GNUNET_SCHEDULER_TaskContext *tc)
337{ 388{
338 struct GNUNET_TIME_Relative duration; 389 struct GNUNET_TIME_Relative duration;
339 struct ValidationResolutionContext *cur; 390 struct ValidationResolutionContext *cur;
340 struct ValidationResolutionContext *next; 391 struct ValidationResolutionContext *next;
392
341 end = GNUNET_SCHEDULER_NO_TASK; 393 end = GNUNET_SCHEDULER_NO_TASK;
342 if (GNUNET_SCHEDULER_NO_TASK != op_timeout) 394 if (GNUNET_SCHEDULER_NO_TASK != op_timeout)
343 { 395 {
@@ -385,18 +437,20 @@ shutdown_task (void *cls, const struct GNUNET_SCHEDULER_TaskContext *tc)
385 if (benchmark_send) 437 if (benchmark_send)
386 { 438 {
387 duration = GNUNET_TIME_absolute_get_duration (start_time); 439 duration = GNUNET_TIME_absolute_get_duration (start_time);
388 FPRINTF (stdout, _("Transmitted %llu bytes/s (%llu bytes in %s)\n"), 440 FPRINTF (stdout,
389 1000LL * 1000LL * traffic_sent / (1 + duration.rel_value_us), 441 _("Transmitted %llu bytes/s (%llu bytes in %s)\n"),
390 traffic_sent, 442 1000LL * 1000LL * traffic_sent / (1 + duration.rel_value_us),
391 GNUNET_STRINGS_relative_time_to_string (duration, GNUNET_YES)); 443 traffic_sent,
444 GNUNET_STRINGS_relative_time_to_string (duration, GNUNET_YES));
392 } 445 }
393 if (benchmark_receive) 446 if (benchmark_receive)
394 { 447 {
395 duration = GNUNET_TIME_absolute_get_duration (start_time); 448 duration = GNUNET_TIME_absolute_get_duration (start_time);
396 FPRINTF (stdout, _("Received %llu bytes/s (%llu bytes in %s)\n"), 449 FPRINTF (stdout,
397 1000LL * 1000LL * traffic_received / (1 + duration.rel_value_us), 450 _("Received %llu bytes/s (%llu bytes in %s)\n"),
398 traffic_received, 451 1000LL * 1000LL * traffic_received / (1 + duration.rel_value_us),
399 GNUNET_STRINGS_relative_time_to_string (duration, GNUNET_YES)); 452 traffic_received,
453 GNUNET_STRINGS_relative_time_to_string (duration, GNUNET_YES));
400 } 454 }
401 455
402 if (NULL != monitored_peers) 456 if (NULL != monitored_peers)
@@ -407,36 +461,22 @@ shutdown_task (void *cls, const struct GNUNET_SCHEDULER_TaskContext *tc)
407 } 461 }
408} 462}
409 463
410static struct PeerResolutionContext *rc_head;
411static struct PeerResolutionContext *rc_tail;
412
413struct PeerResolutionContext
414{
415 struct PeerResolutionContext *next;
416 struct PeerResolutionContext *prev;
417 struct GNUNET_PeerIdentity id;
418 struct GNUNET_HELLO_Address *addrcp;
419 struct GNUNET_TRANSPORT_AddressToStringContext *asc;
420 enum GNUNET_TRANSPORT_PeerState state;
421 struct GNUNET_TIME_Absolute state_timeout;
422 char *transport;
423 int printed;
424};
425
426
427 464
428static void 465static void
429operation_timeout (void *cls, const struct GNUNET_SCHEDULER_TaskContext *tc) 466operation_timeout (void *cls,
467 const struct GNUNET_SCHEDULER_TaskContext *tc)
430{ 468{
431 struct PeerResolutionContext *cur; 469 struct PeerResolutionContext *cur;
432 struct PeerResolutionContext *next; 470 struct PeerResolutionContext *next;
433 op_timeout = GNUNET_SCHEDULER_NO_TASK; 471 op_timeout = GNUNET_SCHEDULER_NO_TASK;
434 if ((try_connect) || (benchmark_send) || (benchmark_receive)) 472 if ((try_connect) || (benchmark_send) || (benchmark_receive))
435 { 473 {
436 FPRINTF (stdout, _("Failed to connect to `%s'\n"), GNUNET_i2s_full (&pid)); 474 FPRINTF (stdout,
475 _("Failed to connect to `%s'\n"),
476 GNUNET_i2s_full (&pid));
437 if (GNUNET_SCHEDULER_NO_TASK != end) 477 if (GNUNET_SCHEDULER_NO_TASK != end)
438 GNUNET_SCHEDULER_cancel (end); 478 GNUNET_SCHEDULER_cancel (end);
439 end = GNUNET_SCHEDULER_add_now (&shutdown_task, NULL ); 479 end = GNUNET_SCHEDULER_add_now (&shutdown_task, NULL);
440 ret = 1; 480 ret = 1;
441 return; 481 return;
442 } 482 }
@@ -446,8 +486,9 @@ operation_timeout (void *cls, const struct GNUNET_SCHEDULER_TaskContext *tc)
446 while (NULL != (cur = next)) 486 while (NULL != (cur = next))
447 { 487 {
448 next = cur->next; 488 next = cur->next;
449 FPRINTF (stdout, _("Failed to resolve address for peer `%s'\n"), 489 FPRINTF (stdout,
450 GNUNET_i2s (&cur->addrcp->peer)); 490 _("Failed to resolve address for peer `%s'\n"),
491 GNUNET_i2s (&cur->addrcp->peer));
451 492
452 GNUNET_CONTAINER_DLL_remove(rc_head, rc_tail, cur); 493 GNUNET_CONTAINER_DLL_remove(rc_head, rc_tail, cur);
453 GNUNET_TRANSPORT_address_to_string_cancel (cur->asc); 494 GNUNET_TRANSPORT_address_to_string_cancel (cur->asc);
@@ -456,19 +497,22 @@ operation_timeout (void *cls, const struct GNUNET_SCHEDULER_TaskContext *tc)
456 GNUNET_free(cur); 497 GNUNET_free(cur);
457 498
458 } 499 }
459 FPRINTF (stdout, "%s", _("Failed to list connections, timeout occured\n") ); 500 FPRINTF (stdout,
501 "%s",
502 _("Failed to list connections, timeout occured\n"));
460 if (GNUNET_SCHEDULER_NO_TASK != end) 503 if (GNUNET_SCHEDULER_NO_TASK != end)
461 GNUNET_SCHEDULER_cancel (end); 504 GNUNET_SCHEDULER_cancel (end);
462 end = GNUNET_SCHEDULER_add_now (&shutdown_task, NULL ); 505 end = GNUNET_SCHEDULER_add_now (&shutdown_task, NULL);
463 ret = 1; 506 ret = 1;
464 return; 507 return;
465 } 508 }
466
467} 509}
468 510
511
469static void 512static void
470run_nat_test (); 513run_nat_test ();
471 514
515
472/** 516/**
473 * Display the result of the test. 517 * Display the result of the test.
474 * 518 *
@@ -476,28 +520,34 @@ run_nat_test ();
476 * @param result #GNUNET_YES on success 520 * @param result #GNUNET_YES on success
477 */ 521 */
478static void 522static void
479display_test_result (struct TestContext *tc, enum TestResult result) 523display_test_result (struct TestContext *tc,
524 enum TestResult result)
480{ 525{
481 switch (result) { 526 switch (result) {
482 case NAT_TEST_FAIL: 527 case NAT_TEST_FAIL:
483 FPRINTF (stderr, _("Configuration for plugin `%s' did not work!\n"), 528 FPRINTF (stderr,
484 tc->name); 529 _("Configuration for plugin `%s' did not work!\n"),
530 tc->name);
485 break; 531 break;
486 case NAT_TEST_SUCCESS: 532 case NAT_TEST_SUCCESS:
487 FPRINTF (stderr, _("Configuration for plugin `%s' did work!\n"), 533 FPRINTF (stderr,
488 tc->name); 534 _("Configuration for plugin `%s' did work!\n"),
535 tc->name);
489 break; 536 break;
490 case NAT_TEST_INTERNAL_FAIL: 537 case NAT_TEST_INTERNAL_FAIL:
491 FPRINTF (stderr, _("Internal NAT error while running test for plugin `%s'\n"), 538 FPRINTF (stderr,
492 tc->name); 539 _("Internal NAT error while running test for plugin `%s'\n"),
540 tc->name);
493 break; 541 break;
494 case NAT_TEST_FAILED_TO_START: 542 case NAT_TEST_FAILED_TO_START:
495 FPRINTF (stderr, _("Failed to start NAT test for plugin `%s'\n"), 543 FPRINTF (stderr,
496 tc->name); 544 _("Failed to start NAT test for plugin `%s'\n"),
545 tc->name);
497 break; 546 break;
498 case NAT_TEST_TIMEOUT: 547 case NAT_TEST_TIMEOUT:
499 FPRINTF (stderr, _("Timeout while waiting for result of NAT test for plugin `%s'\n"), 548 FPRINTF (stderr,
500 tc->name); 549 _("Timeout while waiting for result of NAT test for plugin `%s'\n"),
550 tc->name);
501 break; 551 break;
502 default: 552 default:
503 break; 553 break;
@@ -505,11 +555,15 @@ display_test_result (struct TestContext *tc, enum TestResult result)
505 555
506 if (GNUNET_YES != result) 556 if (GNUNET_YES != result)
507 { 557 {
508 FPRINTF (stderr, "Configuration for plugin `%s' did not work!\n", tc->name); 558 FPRINTF (stderr,
559 _("Configuration for plugin `%s' did not work!\n"),
560 tc->name);
509 } 561 }
510 else 562 else
511 { 563 {
512 FPRINTF (stderr, "Configuration for plugin `%s' is working!\n", tc->name); 564 FPRINTF (stderr,
565 _("Configuration for plugin `%s' is working!\n"),
566 tc->name);
513 } 567 }
514 if (GNUNET_SCHEDULER_NO_TASK != tc->tsk) 568 if (GNUNET_SCHEDULER_NO_TASK != tc->tsk)
515 { 569 {
@@ -528,7 +582,8 @@ display_test_result (struct TestContext *tc, enum TestResult result)
528 582
529 if ((NULL == head) && (NULL != resolver)) 583 if ((NULL == head) && (NULL != resolver))
530 { 584 {
531 GNUNET_break(0 == GNUNET_OS_process_kill (resolver, GNUNET_TERM_SIG)); 585 GNUNET_break (0 == GNUNET_OS_process_kill (resolver,
586 GNUNET_TERM_SIG));
532 GNUNET_OS_process_destroy (resolver); 587 GNUNET_OS_process_destroy (resolver);
533 resolver = NULL; 588 resolver = NULL;
534 } 589 }
@@ -545,12 +600,26 @@ display_test_result (struct TestContext *tc, enum TestResult result)
545 * @param emsg error message, NULL on success 600 * @param emsg error message, NULL on success
546 */ 601 */
547static void 602static void
548result_callback (void *cls, enum GNUNET_NAT_StatusCode result) 603result_callback (void *cls,
604 enum GNUNET_NAT_StatusCode result)
549{ 605{
550 struct TestContext *tc = cls; 606 struct TestContext *tc = cls;
607
551 display_test_result (tc, result); 608 display_test_result (tc, result);
552} 609}
553 610
611
612/**
613 * Resolve address we got a validation state for to a string.
614 *
615 * @param id peer identity the address is for
616 * @param address the address itself
617 * @param numeric #GNUNET_YES to disable DNS, #GNUNET_NO to try reverse lookup
618 * @param last_validation when was the address validated last
619 * @param valid_until until when is the address valid
620 * @param next_validation when will we try to revalidate the address next
621 * @param state where are we in the validation state machine
622 */
554static void 623static void
555resolve_validation_address (const struct GNUNET_PeerIdentity *id, 624resolve_validation_address (const struct GNUNET_PeerIdentity *id,
556 const struct GNUNET_HELLO_Address *address, 625 const struct GNUNET_HELLO_Address *address,
@@ -561,7 +630,6 @@ resolve_validation_address (const struct GNUNET_PeerIdentity *id,
561 enum GNUNET_TRANSPORT_ValidationState state); 630 enum GNUNET_TRANSPORT_ValidationState state);
562 631
563 632
564
565/** 633/**
566 * Function to call with a textual representation of an address. This 634 * Function to call with a textual representation of an address. This
567 * function will be called several times with different possible 635 * function will be called several times with different possible
@@ -631,7 +699,7 @@ process_validation_string (void *cls,
631 GNUNET_assert (address_resolutions > 0); 699 GNUNET_assert (address_resolutions > 0);
632 address_resolutions--; 700 address_resolutions--;
633 if ( (GNUNET_SYSERR == res) && 701 if ( (GNUNET_SYSERR == res) &&
634 (GNUNET_NO == vc->printed) ) 702 (GNUNET_NO == vc->printed))
635 { 703 {
636 if (numeric == GNUNET_NO) 704 if (numeric == GNUNET_NO)
637 { 705 {
@@ -678,7 +746,17 @@ process_validation_string (void *cls,
678} 746}
679 747
680 748
681 749/**
750 * Resolve address we got a validation state for to a string.
751 *
752 * @param id peer identity the address is for
753 * @param address the address itself
754 * @param numeric #GNUNET_YES to disable DNS, #GNUNET_NO to try reverse lookup
755 * @param last_validation when was the address validated last
756 * @param valid_until until when is the address valid
757 * @param next_validation when will we try to revalidate the address next
758 * @param state where are we in the validation state machine
759 */
682static void 760static void
683resolve_validation_address (const struct GNUNET_PeerIdentity *id, 761resolve_validation_address (const struct GNUNET_PeerIdentity *id,
684 const struct GNUNET_HELLO_Address *address, 762 const struct GNUNET_HELLO_Address *address,
@@ -713,6 +791,17 @@ resolve_validation_address (const struct GNUNET_PeerIdentity *id,
713} 791}
714 792
715 793
794/**
795 * Resolve address we got a validation state for to a string.
796 *
797 * @param cls NULL
798 * @param peer peer identity the address is for
799 * @param address the address itself
800 * @param last_validation when was the address validated last
801 * @param valid_until until when is the address valid
802 * @param next_validation when will we try to revalidate the address next
803 * @param state where are we in the validation state machine
804 */
716static void 805static void
717process_validation_cb (void *cls, 806process_validation_cb (void *cls,
718 const struct GNUNET_PeerIdentity *peer, 807 const struct GNUNET_PeerIdentity *peer,
@@ -736,7 +825,7 @@ process_validation_cb (void *cls,
736 vic = NULL; 825 vic = NULL;
737 if (GNUNET_SCHEDULER_NO_TASK != end) 826 if (GNUNET_SCHEDULER_NO_TASK != end)
738 GNUNET_SCHEDULER_cancel (end); 827 GNUNET_SCHEDULER_cancel (end);
739 end = GNUNET_SCHEDULER_add_now (&shutdown_task, NULL ); 828 end = GNUNET_SCHEDULER_add_now (&shutdown_task, NULL);
740 return; 829 return;
741 } 830 }
742 if ((NULL == peer) || (NULL == address)) 831 if ((NULL == peer) || (NULL == address))
@@ -745,12 +834,16 @@ process_validation_cb (void *cls,
745 vic = NULL; 834 vic = NULL;
746 if (GNUNET_SCHEDULER_NO_TASK != end) 835 if (GNUNET_SCHEDULER_NO_TASK != end)
747 GNUNET_SCHEDULER_cancel (end); 836 GNUNET_SCHEDULER_cancel (end);
748 end = GNUNET_SCHEDULER_add_now (&shutdown_task, NULL ); 837 end = GNUNET_SCHEDULER_add_now (&shutdown_task, NULL);
749 return; 838 return;
750 } 839 }
751 resolve_validation_address (peer, address, 840 resolve_validation_address (peer,
752 numeric, last_validation, 841 address,
753 valid_until, next_validation, state); 842 numeric,
843 last_validation,
844 valid_until,
845 next_validation,
846 state);
754} 847}
755 848
756 849
@@ -758,8 +851,10 @@ static void
758run_nat_test () 851run_nat_test ()
759{ 852{
760 GNUNET_log (GNUNET_ERROR_TYPE_INFO, 853 GNUNET_log (GNUNET_ERROR_TYPE_INFO,
761 "Running test for plugin `%s' using bind port %u and advertised port %u \n", 854 "Running test for plugin `%s' using bind port %u and advertised port %u \n",
762 head->name, (uint16_t) head->bnd_port, (uint16_t) head->adv_port); 855 head->name,
856 (uint16_t) head->bnd_port,
857 (uint16_t) head->adv_port);
763 858
764 head->tst = GNUNET_NAT_test_start (cfg, 859 head->tst = GNUNET_NAT_test_start (cfg,
765 (0 == strcasecmp (head->name, "udp")) ? GNUNET_NO : GNUNET_YES, 860 (0 == strcasecmp (head->name, "udp")) ? GNUNET_NO : GNUNET_YES,
@@ -790,7 +885,7 @@ do_test_configuration (const struct GNUNET_CONFIGURATION_Handle *cfg)
790 &plugins)) 885 &plugins))
791 { 886 {
792 FPRINTF (stderr, "%s", _ 887 FPRINTF (stderr, "%s", _
793 ("No transport plugins configured, peer will never communicate\n") ); 888 ("No transport plugins configured, peer will never communicate\n"));
794 ret = 4; 889 ret = 4;
795 return; 890 return;
796 } 891 }
@@ -826,7 +921,7 @@ do_test_configuration (const struct GNUNET_CONFIGURATION_Handle *cfg)
826 GNUNET_OS_INHERIT_STD_OUT_AND_ERR, 921 GNUNET_OS_INHERIT_STD_OUT_AND_ERR,
827 NULL, NULL, NULL, 922 NULL, NULL, NULL,
828 binary, 923 binary,
829 "gnunet-service-resolver", NULL ); 924 "gnunet-service-resolver", NULL);
830 if (NULL == resolver) 925 if (NULL == resolver)
831 { 926 {
832 FPRINTF (stderr, _("Failed to start resolver!\n")); 927 FPRINTF (stderr, _("Failed to start resolver!\n"));
@@ -839,6 +934,7 @@ do_test_configuration (const struct GNUNET_CONFIGURATION_Handle *cfg)
839 } 934 }
840} 935}
841 936
937
842/** 938/**
843 * Function called to notify a client about the socket 939 * Function called to notify a client about the socket
844 * begin ready to queue more data. @a buf will be 940 * begin ready to queue more data. @a buf will be
@@ -851,7 +947,9 @@ do_test_configuration (const struct GNUNET_CONFIGURATION_Handle *cfg)
851 * @return number of bytes written to @a buf 947 * @return number of bytes written to @a buf
852 */ 948 */
853static size_t 949static size_t
854transmit_data (void *cls, size_t size, void *buf) 950transmit_data (void *cls,
951 size_t size,
952 void *buf)
855{ 953{
856 struct GNUNET_MessageHeader *m = buf; 954 struct GNUNET_MessageHeader *m = buf;
857 955
@@ -870,7 +968,7 @@ transmit_data (void *cls, size_t size, void *buf)
870 th = GNUNET_TRANSPORT_notify_transmit_ready (handle, &pid, 968 th = GNUNET_TRANSPORT_notify_transmit_ready (handle, &pid,
871 BLOCKSIZE * 1024, 969 BLOCKSIZE * 1024,
872 GNUNET_TIME_UNIT_FOREVER_REL, 970 GNUNET_TIME_UNIT_FOREVER_REL,
873 &transmit_data, NULL ); 971 &transmit_data, NULL);
874 if (verbosity > 0) 972 if (verbosity > 0)
875 FPRINTF (stdout, _("Transmitting %u bytes to %s\n"), (unsigned int) size, 973 FPRINTF (stdout, _("Transmitting %u bytes to %s\n"), (unsigned int) size,
876 GNUNET_i2s (&pid)); 974 GNUNET_i2s (&pid));
@@ -886,7 +984,8 @@ transmit_data (void *cls, size_t size, void *buf)
886 * @param peer the peer that connected 984 * @param peer the peer that connected
887 */ 985 */
888static void 986static void
889notify_connect (void *cls, const struct GNUNET_PeerIdentity *peer) 987notify_connect (void *cls,
988 const struct GNUNET_PeerIdentity *peer)
890{ 989{
891 if (0 != memcmp (&pid, peer, sizeof(struct GNUNET_PeerIdentity))) 990 if (0 != memcmp (&pid, peer, sizeof(struct GNUNET_PeerIdentity)))
892 return; 991 return;
@@ -906,7 +1005,7 @@ notify_connect (void *cls, const struct GNUNET_PeerIdentity *peer)
906 1005
907 if (GNUNET_SCHEDULER_NO_TASK != end) 1006 if (GNUNET_SCHEDULER_NO_TASK != end)
908 GNUNET_SCHEDULER_cancel (end); 1007 GNUNET_SCHEDULER_cancel (end);
909 end = GNUNET_SCHEDULER_add_now (&shutdown_task, NULL ); 1008 end = GNUNET_SCHEDULER_add_now (&shutdown_task, NULL);
910 return; 1009 return;
911 } 1010 }
912 if (benchmark_send) 1011 if (benchmark_send)
@@ -933,6 +1032,7 @@ notify_connect (void *cls, const struct GNUNET_PeerIdentity *peer)
933 } 1032 }
934} 1033}
935 1034
1035
936/** 1036/**
937 * Function called to notify transport users that another 1037 * Function called to notify transport users that another
938 * peer disconnected from us. 1038 * peer disconnected from us.
@@ -962,7 +1062,7 @@ notify_disconnect (void *cls,
962 1062
963 if (GNUNET_SCHEDULER_NO_TASK != end) 1063 if (GNUNET_SCHEDULER_NO_TASK != end)
964 GNUNET_SCHEDULER_cancel (end); 1064 GNUNET_SCHEDULER_cancel (end);
965 end = GNUNET_SCHEDULER_add_now (&shutdown_task, NULL ); 1065 end = GNUNET_SCHEDULER_add_now (&shutdown_task, NULL);
966 return; 1066 return;
967 } 1067 }
968 1068
@@ -981,6 +1081,7 @@ notify_disconnect (void *cls,
981 } 1081 }
982} 1082}
983 1083
1084
984/** 1085/**
985 * Function called to notify transport users that another 1086 * Function called to notify transport users that another
986 * peer connected to us. 1087 * peer connected to us.
@@ -1078,7 +1179,7 @@ print_info (const struct GNUNET_PeerIdentity *id,
1078{ 1179{
1079 1180
1080 if ( ((GNUNET_YES == iterate_connections) && (GNUNET_YES == iterate_all)) || 1181 if ( ((GNUNET_YES == iterate_connections) && (GNUNET_YES == iterate_all)) ||
1081 (GNUNET_YES == monitor_connections) ) 1182 (GNUNET_YES == monitor_connections))
1082 { 1183 {
1083 FPRINTF (stdout, 1184 FPRINTF (stdout,
1084 _("Peer `%s': %s %s in state `%s' until %s\n"), 1185 _("Peer `%s': %s %s in state `%s' until %s\n"),
@@ -1089,7 +1190,7 @@ print_info (const struct GNUNET_PeerIdentity *id,
1089 GNUNET_STRINGS_absolute_time_to_string (state_timeout)); 1190 GNUNET_STRINGS_absolute_time_to_string (state_timeout));
1090 } 1191 }
1091 else if ( (GNUNET_YES == iterate_connections) && 1192 else if ( (GNUNET_YES == iterate_connections) &&
1092 (GNUNET_TRANSPORT_is_connected(state)) ) 1193 (GNUNET_TRANSPORT_is_connected(state)))
1093 { 1194 {
1094 /* Only connected peers, skip state */ 1195 /* Only connected peers, skip state */
1095 FPRINTF (stdout, 1196 FPRINTF (stdout,
@@ -1198,7 +1299,7 @@ process_peer_string (void *cls,
1198 op_timeout = GNUNET_SCHEDULER_NO_TASK; 1299 op_timeout = GNUNET_SCHEDULER_NO_TASK;
1199 } 1300 }
1200 ret = 0; 1301 ret = 0;
1201 end = GNUNET_SCHEDULER_add_now (&shutdown_task, NULL ); 1302 end = GNUNET_SCHEDULER_add_now (&shutdown_task, NULL);
1202 } 1303 }
1203} 1304}
1204 1305
@@ -1256,12 +1357,12 @@ process_peer_iteration_cb (void *cls,
1256 pic = NULL; 1357 pic = NULL;
1257 if (GNUNET_SCHEDULER_NO_TASK != end) 1358 if (GNUNET_SCHEDULER_NO_TASK != end)
1258 GNUNET_SCHEDULER_cancel (end); 1359 GNUNET_SCHEDULER_cancel (end);
1259 end = GNUNET_SCHEDULER_add_now (&shutdown_task, NULL ); 1360 end = GNUNET_SCHEDULER_add_now (&shutdown_task, NULL);
1260 return; 1361 return;
1261 } 1362 }
1262 1363
1263 if ( (GNUNET_NO == iterate_all) && 1364 if ( (GNUNET_NO == iterate_all) &&
1264 (GNUNET_NO == GNUNET_TRANSPORT_is_connected(state)) ) 1365 (GNUNET_NO == GNUNET_TRANSPORT_is_connected(state)))
1265 return; /* Display only connected peers */ 1366 return; /* Display only connected peers */
1266 1367
1267 if (GNUNET_SCHEDULER_NO_TASK != op_timeout) 1368 if (GNUNET_SCHEDULER_NO_TASK != op_timeout)
@@ -1326,12 +1427,12 @@ process_peer_monitoring_cb (void *cls,
1326 { 1427 {
1327 if ( (m->state == state) && 1428 if ( (m->state == state) &&
1328 (m->state_timeout.abs_value_us == state_timeout.abs_value_us) && 1429 (m->state_timeout.abs_value_us == state_timeout.abs_value_us) &&
1329 ((NULL == address) && (NULL == m->address)) ) 1430 ((NULL == address) && (NULL == m->address)))
1330 { 1431 {
1331 return; /* No real change */ 1432 return; /* No real change */
1332 } 1433 }
1333 if ( (m->state == state) && ((NULL != address) && (NULL != m->address)) && 1434 if ( (m->state == state) && ((NULL != address) && (NULL != m->address)) &&
1334 (0 == GNUNET_HELLO_address_cmp(m->address, address)) ) 1435 (0 == GNUNET_HELLO_address_cmp(m->address, address)))
1335 return; /* No real change */ 1436 return; /* No real change */
1336 } 1437 }
1337 1438
@@ -1374,16 +1475,16 @@ try_connect_cb (void *cls,
1374 retries++; 1475 retries++;
1375 if (retries < 10) 1476 if (retries < 10)
1376 tc_handle = GNUNET_TRANSPORT_try_connect (handle, &pid, try_connect_cb, 1477 tc_handle = GNUNET_TRANSPORT_try_connect (handle, &pid, try_connect_cb,
1377 NULL ); 1478 NULL);
1378 else 1479 else
1379 { 1480 {
1380 FPRINTF (stderr, 1481 FPRINTF (stderr,
1381 "%s", 1482 "%s",
1382 _("Failed to send connect request to transport service\n") ); 1483 _("Failed to send connect request to transport service\n"));
1383 if (GNUNET_SCHEDULER_NO_TASK != end) 1484 if (GNUNET_SCHEDULER_NO_TASK != end)
1384 GNUNET_SCHEDULER_cancel (end); 1485 GNUNET_SCHEDULER_cancel (end);
1385 ret = 1; 1486 ret = 1;
1386 end = GNUNET_SCHEDULER_add_now (&shutdown_task, NULL ); 1487 end = GNUNET_SCHEDULER_add_now (&shutdown_task, NULL);
1387 return; 1488 return;
1388 } 1489 }
1389} 1490}
@@ -1402,15 +1503,15 @@ try_disconnect_cb (void *cls,
1402 retries++; 1503 retries++;
1403 if (retries < 10) 1504 if (retries < 10)
1404 tc_handle = GNUNET_TRANSPORT_try_disconnect (handle, &pid, try_disconnect_cb, 1505 tc_handle = GNUNET_TRANSPORT_try_disconnect (handle, &pid, try_disconnect_cb,
1405 NULL ); 1506 NULL);
1406 else 1507 else
1407 { 1508 {
1408 FPRINTF (stderr, "%s", 1509 FPRINTF (stderr, "%s",
1409 _("Failed to send connect request to transport service\n") ); 1510 _("Failed to send connect request to transport service\n"));
1410 if (GNUNET_SCHEDULER_NO_TASK != end) 1511 if (GNUNET_SCHEDULER_NO_TASK != end)
1411 GNUNET_SCHEDULER_cancel (end); 1512 GNUNET_SCHEDULER_cancel (end);
1412 ret = 1; 1513 ret = 1;
1413 end = GNUNET_SCHEDULER_add_now (&shutdown_task, NULL ); 1514 end = GNUNET_SCHEDULER_add_now (&shutdown_task, NULL);
1414 return; 1515 return;
1415 } 1516 }
1416} 1517}
@@ -1478,21 +1579,21 @@ testservice_task (void *cls, int result)
1478 &notify_connect, &notify_disconnect); 1579 &notify_connect, &notify_disconnect);
1479 if (NULL == handle) 1580 if (NULL == handle)
1480 { 1581 {
1481 FPRINTF (stderr, "%s", _("Failed to connect to transport service\n") ); 1582 FPRINTF (stderr, "%s", _("Failed to connect to transport service\n"));
1482 ret = 1; 1583 ret = 1;
1483 return; 1584 return;
1484 } 1585 }
1485 tc_handle = GNUNET_TRANSPORT_try_connect (handle, &pid, try_connect_cb, 1586 tc_handle = GNUNET_TRANSPORT_try_connect (handle, &pid, try_connect_cb,
1486 NULL ); 1587 NULL);
1487 if (NULL == tc_handle) 1588 if (NULL == tc_handle)
1488 { 1589 {
1489 FPRINTF (stderr, "%s", 1590 FPRINTF (stderr, "%s",
1490 _("Failed to send request to transport service\n") ); 1591 _("Failed to send request to transport service\n"));
1491 ret = 1; 1592 ret = 1;
1492 return; 1593 return;
1493 } 1594 }
1494 op_timeout = GNUNET_SCHEDULER_add_delayed (OP_TIMEOUT, &operation_timeout, 1595 op_timeout = GNUNET_SCHEDULER_add_delayed (OP_TIMEOUT, &operation_timeout,
1495 NULL ); 1596 NULL);
1496 1597
1497 } 1598 }
1498 else if (try_disconnect) /* -D: Disconnect from peer */ 1599 else if (try_disconnect) /* -D: Disconnect from peer */
@@ -1508,21 +1609,21 @@ testservice_task (void *cls, int result)
1508 &notify_connect, &notify_disconnect); 1609 &notify_connect, &notify_disconnect);
1509 if (NULL == handle) 1610 if (NULL == handle)
1510 { 1611 {
1511 FPRINTF (stderr, "%s", _("Failed to connect to transport service\n") ); 1612 FPRINTF (stderr, "%s", _("Failed to connect to transport service\n"));
1512 ret = 1; 1613 ret = 1;
1513 return; 1614 return;
1514 } 1615 }
1515 tc_handle = GNUNET_TRANSPORT_try_disconnect (handle, &pid, try_disconnect_cb, 1616 tc_handle = GNUNET_TRANSPORT_try_disconnect (handle, &pid, try_disconnect_cb,
1516 NULL ); 1617 NULL);
1517 if (NULL == tc_handle) 1618 if (NULL == tc_handle)
1518 { 1619 {
1519 FPRINTF (stderr, "%s", 1620 FPRINTF (stderr, "%s",
1520 _("Failed to send request to transport service\n") ); 1621 _("Failed to send request to transport service\n"));
1521 ret = 1; 1622 ret = 1;
1522 return; 1623 return;
1523 } 1624 }
1524 op_timeout = GNUNET_SCHEDULER_add_delayed (OP_TIMEOUT, &operation_timeout, 1625 op_timeout = GNUNET_SCHEDULER_add_delayed (OP_TIMEOUT, &operation_timeout,
1525 NULL ); 1626 NULL);
1526 1627
1527 } 1628 }
1528 else if (benchmark_send) /* -s: Benchmark sending */ 1629 else if (benchmark_send) /* -s: Benchmark sending */
@@ -1538,35 +1639,35 @@ testservice_task (void *cls, int result)
1538 &notify_connect, &notify_disconnect); 1639 &notify_connect, &notify_disconnect);
1539 if (NULL == handle) 1640 if (NULL == handle)
1540 { 1641 {
1541 FPRINTF (stderr, "%s", _("Failed to connect to transport service\n") ); 1642 FPRINTF (stderr, "%s", _("Failed to connect to transport service\n"));
1542 ret = 1; 1643 ret = 1;
1543 return; 1644 return;
1544 } 1645 }
1545 tc_handle = GNUNET_TRANSPORT_try_connect (handle, &pid, try_connect_cb, 1646 tc_handle = GNUNET_TRANSPORT_try_connect (handle, &pid, try_connect_cb,
1546 NULL ); 1647 NULL);
1547 if (NULL == tc_handle) 1648 if (NULL == tc_handle)
1548 { 1649 {
1549 FPRINTF (stderr, "%s", 1650 FPRINTF (stderr, "%s",
1550 _("Failed to send request to transport service\n") ); 1651 _("Failed to send request to transport service\n"));
1551 ret = 1; 1652 ret = 1;
1552 return; 1653 return;
1553 } 1654 }
1554 start_time = GNUNET_TIME_absolute_get (); 1655 start_time = GNUNET_TIME_absolute_get ();
1555 op_timeout = GNUNET_SCHEDULER_add_delayed (OP_TIMEOUT, &operation_timeout, 1656 op_timeout = GNUNET_SCHEDULER_add_delayed (OP_TIMEOUT, &operation_timeout,
1556 NULL ); 1657 NULL);
1557 } 1658 }
1558 else if (benchmark_receive) /* -b: Benchmark receiving */ 1659 else if (benchmark_receive) /* -b: Benchmark receiving */
1559 { 1660 {
1560 handle = GNUNET_TRANSPORT_connect (cfg, NULL, NULL, &notify_receive, NULL, 1661 handle = GNUNET_TRANSPORT_connect (cfg, NULL, NULL, &notify_receive, NULL,
1561 NULL ); 1662 NULL);
1562 if (NULL == handle) 1663 if (NULL == handle)
1563 { 1664 {
1564 FPRINTF (stderr, "%s", _("Failed to connect to transport service\n") ); 1665 FPRINTF (stderr, "%s", _("Failed to connect to transport service\n"));
1565 ret = 1; 1666 ret = 1;
1566 return; 1667 return;
1567 } 1668 }
1568 if (verbosity > 0) 1669 if (verbosity > 0)
1569 FPRINTF (stdout, "%s", _("Starting to receive benchmark data\n") ); 1670 FPRINTF (stdout, "%s", _("Starting to receive benchmark data\n"));
1570 start_time = GNUNET_TIME_absolute_get (); 1671 start_time = GNUNET_TIME_absolute_get ();
1571 1672
1572 } 1673 }
@@ -1576,7 +1677,7 @@ testservice_task (void *cls, int result)
1576 pic = GNUNET_TRANSPORT_monitor_peers (cfg, (NULL == cpid) ? NULL : &pid, 1677 pic = GNUNET_TRANSPORT_monitor_peers (cfg, (NULL == cpid) ? NULL : &pid,
1577 GNUNET_YES, TIMEOUT, &process_peer_iteration_cb, (void *) cfg); 1678 GNUNET_YES, TIMEOUT, &process_peer_iteration_cb, (void *) cfg);
1578 op_timeout = GNUNET_SCHEDULER_add_delayed (OP_TIMEOUT, &operation_timeout, 1679 op_timeout = GNUNET_SCHEDULER_add_delayed (OP_TIMEOUT, &operation_timeout,
1579 NULL ); 1680 NULL);
1580 } 1681 }
1581 else if (monitor_connections) /* -m: List information about peers continuously */ 1682 else if (monitor_connections) /* -m: List information about peers continuously */
1582 { 1683 {
@@ -1605,7 +1706,7 @@ testservice_task (void *cls, int result)
1605 &monitor_notify_disconnect); 1706 &monitor_notify_disconnect);
1606 if (NULL == handle) 1707 if (NULL == handle)
1607 { 1708 {
1608 FPRINTF (stderr, "%s", _("Failed to connect to transport service\n") ); 1709 FPRINTF (stderr, "%s", _("Failed to connect to transport service\n"));
1609 ret = 1; 1710 ret = 1;
1610 return; 1711 return;
1611 } 1712 }
@@ -1618,10 +1719,12 @@ testservice_task (void *cls, int result)
1618 } 1719 }
1619 1720
1620 end = GNUNET_SCHEDULER_add_delayed (GNUNET_TIME_UNIT_FOREVER_REL, 1721 end = GNUNET_SCHEDULER_add_delayed (GNUNET_TIME_UNIT_FOREVER_REL,
1621 &shutdown_task, NULL ); 1722 &shutdown_task,
1723 NULL);
1622 1724
1623} 1725}
1624 1726
1727
1625/** 1728/**
1626 * Main function that will be run by the scheduler. 1729 * Main function that will be run by the scheduler.
1627 * 1730 *
@@ -1631,8 +1734,10 @@ testservice_task (void *cls, int result)
1631 * @param mycfg configuration 1734 * @param mycfg configuration
1632 */ 1735 */
1633static void 1736static void
1634run (void *cls, char * const *args, const char *cfgfile, 1737run (void *cls,
1635 const struct GNUNET_CONFIGURATION_Handle *mycfg) 1738 char * const *args,
1739 const char *cfgfile,
1740 const struct GNUNET_CONFIGURATION_Handle *mycfg)
1636{ 1741{
1637 cfg = (struct GNUNET_CONFIGURATION_Handle *) mycfg; 1742 cfg = (struct GNUNET_CONFIGURATION_Handle *) mycfg;
1638 if (test_configuration) 1743 if (test_configuration)
@@ -1648,53 +1753,59 @@ int
1648main (int argc, char * const *argv) 1753main (int argc, char * const *argv)
1649{ 1754{
1650 int res; 1755 int res;
1651 static const struct GNUNET_GETOPT_CommandLineOption options[] = 1756 static const struct GNUNET_GETOPT_CommandLineOption options[] = {
1652 { 1757 { 'a', "all", NULL,
1653 { 'a', "all", NULL, 1758 gettext_noop ("print information for all peers (instead of only connected peers)"),
1654 gettext_noop ("print information for all peers (instead of only connected peers )"), 1759 0, &GNUNET_GETOPT_set_one, &iterate_all },
1655 0, &GNUNET_GETOPT_set_one, &iterate_all }, 1760 { 'b', "benchmark", NULL,
1656 { 'b', "benchmark", NULL, 1761 gettext_noop ("measure how fast we are receiving data from all peers (until CTRL-C)"),
1657 gettext_noop ("measure how fast we are receiving data from all peers (until CTRL-C)"), 1762 0, &GNUNET_GETOPT_set_one, &benchmark_receive },
1658 0, &GNUNET_GETOPT_set_one, &benchmark_receive }, 1763 { 'C', "connect",
1659 { 'C', "connect", 1764 NULL, gettext_noop ("connect to a peer"), 0,
1660 NULL, gettext_noop ("connect to a peer"), 0, 1765 &GNUNET_GETOPT_set_one, &try_connect },
1661 &GNUNET_GETOPT_set_one, &try_connect }, 1766 { 'D', "disconnect",
1662 { 'D', "disconnect", 1767 NULL, gettext_noop ("disconnect to a peer"), 0,
1663 NULL, gettext_noop ("disconnect to a peer"), 0, 1768 &GNUNET_GETOPT_set_one, &try_disconnect },
1664 &GNUNET_GETOPT_set_one, &try_disconnect }, 1769 { 'd', "validation", NULL,
1665 { 'd', "validation", NULL, 1770 gettext_noop ("print information for all pending validations "),
1666 gettext_noop ("print information for all pending validations "), 1771 0, &GNUNET_GETOPT_set_one, &iterate_validation },
1667 0, &GNUNET_GETOPT_set_one, &iterate_validation }, 1772 { 'f', "monitorvalidation", NULL,
1668 { 'f', "monitorvalidation", NULL, 1773 gettext_noop ("print information for all pending validations continously"),
1669 gettext_noop ("print information for all pending validations continously"), 1774 0, &GNUNET_GETOPT_set_one, &monitor_validation },
1670 0, &GNUNET_GETOPT_set_one, &monitor_validation }, 1775 { 'i', "information", NULL,
1671 { 'i', "information", NULL, 1776 gettext_noop ("provide information about all current connections (once)"),
1672 gettext_noop ("provide information about all current connections (once)"), 1777 0, &GNUNET_GETOPT_set_one, &iterate_connections },
1673 0, &GNUNET_GETOPT_set_one, &iterate_connections }, 1778 { 'm', "monitor", NULL,
1674 { 'm', "monitor", NULL, 1779 gettext_noop ("provide information about all current connections (continuously)"),
1675 gettext_noop ("provide information about all current connections (continuously)"), 1780 0, &GNUNET_GETOPT_set_one, &monitor_connections },
1676 0, &GNUNET_GETOPT_set_one, &monitor_connections }, 1781 { 'e', "events", NULL,
1677 { 'e', "events", NULL, 1782 gettext_noop ("provide information about all connects and disconnect events (continuously)"),
1678 gettext_noop ("provide information about all connects and disconnect events (continuously)"), 1783 0, &GNUNET_GETOPT_set_one, &monitor_connects },
1679 0, &GNUNET_GETOPT_set_one, &monitor_connects }, { 'n', "numeric", 1784 { 'n', "numeric",
1680 NULL, gettext_noop ("do not resolve hostnames"), 0, 1785 NULL, gettext_noop ("do not resolve hostnames"), 0,
1681 &GNUNET_GETOPT_set_one, &numeric }, { 'p', "peer", "PEER", 1786 &GNUNET_GETOPT_set_one, &numeric },
1682 gettext_noop ("peer identity"), 1, &GNUNET_GETOPT_set_string, 1787 { 'p', "peer", "PEER",
1683 &cpid }, { 's', "send", NULL, gettext_noop 1788 gettext_noop ("peer identity"), 1, &GNUNET_GETOPT_set_string,
1684 ("send data for benchmarking to the other peer (until CTRL-C)"), 0, 1789 &cpid },
1685 &GNUNET_GETOPT_set_one, &benchmark_send }, 1790 { 's', "send", NULL, gettext_noop
1686 { 't', "test", NULL, 1791 ("send data for benchmarking to the other peer (until CTRL-C)"), 0,
1687 gettext_noop ("test transport configuration (involves external server)"), 1792 &GNUNET_GETOPT_set_one, &benchmark_send },
1688 0, &GNUNET_GETOPT_set_one, &test_configuration }, 1793 { 't', "test", NULL,
1689 GNUNET_GETOPT_OPTION_VERBOSE (&verbosity), 1794 gettext_noop ("test transport configuration (involves external server)"),
1690 GNUNET_GETOPT_OPTION_END }; 1795 0, &GNUNET_GETOPT_set_one, &test_configuration },
1796 GNUNET_GETOPT_OPTION_VERBOSE (&verbosity),
1797 GNUNET_GETOPT_OPTION_END
1798 };
1691 1799
1692 if (GNUNET_OK != GNUNET_STRINGS_get_utf8_args (argc, argv, &argc, &argv)) 1800 if (GNUNET_OK != GNUNET_STRINGS_get_utf8_args (argc, argv, &argc, &argv))
1693 return 2; 1801 return 2;
1694 1802
1695 res = GNUNET_PROGRAM_run (argc, argv, "gnunet-transport", gettext_noop 1803 res = GNUNET_PROGRAM_run (argc, argv,
1696 ("Direct access to transport service."), options, &run, NULL ); 1804 "gnunet-transport",
1697 GNUNET_free((void * ) argv); 1805 gettext_noop ("Direct access to transport service."),
1806 options,
1807 &run, NULL);
1808 GNUNET_free((void *) argv);
1698 if (GNUNET_OK == res) 1809 if (GNUNET_OK == res)
1699 return ret; 1810 return ret;
1700 return 1; 1811 return 1;