diff options
author | Matthias Wachs <wachs@net.in.tum.de> | 2014-01-15 17:18:11 +0000 |
---|---|---|
committer | Matthias Wachs <wachs@net.in.tum.de> | 2014-01-15 17:18:11 +0000 |
commit | 2368c95a00afc72a8f03ab67bca1ff41328eecdf (patch) | |
tree | 3bcbc29808d7e91c85ca60ac5c998374b458862e /src/transport/gnunet-transport.c | |
parent | b0144a11f14f33ab010fd7cf8c61bdd361f20fd3 (diff) | |
download | gnunet-2368c95a00afc72a8f03ab67bca1ff41328eecdf.tar.gz gnunet-2368c95a00afc72a8f03ab67bca1ff41328eecdf.zip |
transport validation monitoring API (not yet complete) + CLI
+ fix for crash in transport/plugin_transport_udp.c
Diffstat (limited to 'src/transport/gnunet-transport.c')
-rw-r--r-- | src/transport/gnunet-transport.c | 37 |
1 files changed, 34 insertions, 3 deletions
diff --git a/src/transport/gnunet-transport.c b/src/transport/gnunet-transport.c index c2d35cd66..c8408b757 100644 --- a/src/transport/gnunet-transport.c +++ b/src/transport/gnunet-transport.c | |||
@@ -89,6 +89,11 @@ static int benchmark_receive; | |||
89 | static int iterate_connections; | 89 | static int iterate_connections; |
90 | 90 | ||
91 | /** | 91 | /** |
92 | * Option -d. | ||
93 | */ | ||
94 | static int iterate_validation; | ||
95 | |||
96 | /** | ||
92 | * Option -a. | 97 | * Option -a. |
93 | */ | 98 | */ |
94 | static int iterate_all; | 99 | static int iterate_all; |
@@ -156,7 +161,9 @@ static struct GNUNET_CONTAINER_MultiPeerMap *monitored_peers; | |||
156 | /** | 161 | /** |
157 | * | 162 | * |
158 | */ | 163 | */ |
159 | struct GNUNET_TRANSPORT_PeerMonitoringContext *pic; | 164 | static struct GNUNET_TRANSPORT_PeerMonitoringContext *pic; |
165 | |||
166 | static struct GNUNET_TRANSPORT_ValidationMonitoringContext *vic; | ||
160 | 167 | ||
161 | /** | 168 | /** |
162 | * Identity of the peer we transmit to / connect to. | 169 | * Identity of the peer we transmit to / connect to. |
@@ -269,6 +276,11 @@ shutdown_task (void *cls, const struct GNUNET_SCHEDULER_TaskContext *tc) | |||
269 | GNUNET_TRANSPORT_monitor_peers_cancel (pic); | 276 | GNUNET_TRANSPORT_monitor_peers_cancel (pic); |
270 | pic = NULL; | 277 | pic = NULL; |
271 | } | 278 | } |
279 | if (NULL != vic) | ||
280 | { | ||
281 | GNUNET_TRANSPORT_monitor_validation_entries_cancel (vic); | ||
282 | vic = NULL; | ||
283 | } | ||
272 | if (NULL != th) | 284 | if (NULL != th) |
273 | { | 285 | { |
274 | GNUNET_TRANSPORT_notify_transmit_ready_cancel (th); | 286 | GNUNET_TRANSPORT_notify_transmit_ready_cancel (th); |
@@ -430,6 +442,17 @@ fail_timeout (void *cls, const struct GNUNET_SCHEDULER_TaskContext *tc) | |||
430 | display_test_result (tstc, GNUNET_NO); | 442 | display_test_result (tstc, GNUNET_NO); |
431 | } | 443 | } |
432 | 444 | ||
445 | void process_validation_cb (void *cls, | ||
446 | const struct GNUNET_PeerIdentity *peer, | ||
447 | const struct GNUNET_HELLO_Address *address, | ||
448 | struct GNUNET_TIME_Absolute last_validation, | ||
449 | struct GNUNET_TIME_Absolute valid_until, | ||
450 | struct GNUNET_TIME_Absolute next_validation, | ||
451 | enum GNUNET_TRANSPORT_ValidationState state) | ||
452 | { | ||
453 | GNUNET_break (0); | ||
454 | } | ||
455 | |||
433 | /** | 456 | /** |
434 | * Test our plugin's configuration (NAT traversal, etc.). | 457 | * Test our plugin's configuration (NAT traversal, etc.). |
435 | * | 458 | * |
@@ -694,7 +717,7 @@ print_info (const struct GNUNET_PeerIdentity *id, const char *transport, | |||
694 | GNUNET_i2s (id), | 717 | GNUNET_i2s (id), |
695 | (NULL == transport) ? "<none>" : transport, | 718 | (NULL == transport) ? "<none>" : transport, |
696 | (NULL == transport) ? "<none>" : addr, | 719 | (NULL == transport) ? "<none>" : addr, |
697 | GNUNET_TRANSPORT_p2s (state), | 720 | GNUNET_TRANSPORT_ps2s (state), |
698 | GNUNET_STRINGS_absolute_time_to_string (state_timeout)); | 721 | GNUNET_STRINGS_absolute_time_to_string (state_timeout)); |
699 | } | 722 | } |
700 | else | 723 | else |
@@ -951,7 +974,7 @@ testservice_task (void *cls, int result) | |||
951 | } | 974 | } |
952 | 975 | ||
953 | counter = benchmark_send + benchmark_receive + iterate_connections | 976 | counter = benchmark_send + benchmark_receive + iterate_connections |
954 | + monitor_connections + monitor_connects + try_connect; | 977 | + monitor_connections + monitor_connects + try_connect + iterate_validation; |
955 | 978 | ||
956 | if (1 < counter) | 979 | if (1 < counter) |
957 | { | 980 | { |
@@ -1060,6 +1083,11 @@ testservice_task (void *cls, int result) | |||
1060 | pic = GNUNET_TRANSPORT_monitor_peers (cfg, (NULL == cpid) ? NULL : &pid, | 1083 | pic = GNUNET_TRANSPORT_monitor_peers (cfg, (NULL == cpid) ? NULL : &pid, |
1061 | GNUNET_NO, TIMEOUT, &process_peer_monitoring_cb, (void *) cfg); | 1084 | GNUNET_NO, TIMEOUT, &process_peer_monitoring_cb, (void *) cfg); |
1062 | } | 1085 | } |
1086 | else if (iterate_validation) /* -d: Print information about validations */ | ||
1087 | { | ||
1088 | vic = GNUNET_TRANSPORT_monitor_validation_entries (cfg, (NULL == cpid) ? NULL : &pid, | ||
1089 | GNUNET_YES, TIMEOUT, &process_validation_cb, (void *) cfg); | ||
1090 | } | ||
1063 | else if (monitor_connects) /* -e : Monitor (dis)connect events continuously */ | 1091 | else if (monitor_connects) /* -e : Monitor (dis)connect events continuously */ |
1064 | { | 1092 | { |
1065 | monitor_connect_counter = 0; | 1093 | monitor_connect_counter = 0; |
@@ -1120,6 +1148,9 @@ main (int argc, char * const *argv) | |||
1120 | 0, &GNUNET_GETOPT_set_one, &benchmark_receive }, { 'C', "connect", | 1148 | 0, &GNUNET_GETOPT_set_one, &benchmark_receive }, { 'C', "connect", |
1121 | NULL, gettext_noop ("connect to a peer"), 0, | 1149 | NULL, gettext_noop ("connect to a peer"), 0, |
1122 | &GNUNET_GETOPT_set_one, &try_connect }, | 1150 | &GNUNET_GETOPT_set_one, &try_connect }, |
1151 | { 'd', "validation", NULL, | ||
1152 | gettext_noop ("print information for all pending validations "), | ||
1153 | 0, &GNUNET_GETOPT_set_one, &iterate_validation }, | ||
1123 | { 'i', "information", NULL, | 1154 | { 'i', "information", NULL, |
1124 | gettext_noop ("provide information about all current connections (once)"), | 1155 | gettext_noop ("provide information about all current connections (once)"), |
1125 | 0, &GNUNET_GETOPT_set_one, &iterate_connections }, | 1156 | 0, &GNUNET_GETOPT_set_one, &iterate_connections }, |