diff options
Diffstat (limited to 'src/transport')
-rw-r--r-- | src/transport/gnunet-service-transport_clients.c | 3 | ||||
-rw-r--r-- | src/transport/gnunet-transport.c | 25 | ||||
-rw-r--r-- | src/transport/transport_api_monitoring.c | 36 |
3 files changed, 50 insertions, 14 deletions
diff --git a/src/transport/gnunet-service-transport_clients.c b/src/transport/gnunet-service-transport_clients.c index fb848d0af..aefe581c7 100644 --- a/src/transport/gnunet-service-transport_clients.c +++ b/src/transport/gnunet-service-transport_clients.c | |||
@@ -1219,13 +1219,12 @@ clients_handle_monitor_validation (void *cls, struct GNUNET_SERVER_Client *clien | |||
1219 | 1219 | ||
1220 | if (GNUNET_YES != ntohl (msg->one_shot)) | 1220 | if (GNUNET_YES != ntohl (msg->one_shot)) |
1221 | { | 1221 | { |
1222 | GNUNET_break (0); | ||
1223 | setup_val_monitoring_client (client, &msg->peer); | 1222 | setup_val_monitoring_client (client, &msg->peer); |
1224 | } | 1223 | } |
1225 | else | 1224 | else |
1226 | { | 1225 | { |
1227 | GNUNET_SERVER_transmit_context_append_data (tc, NULL, 0, | 1226 | GNUNET_SERVER_transmit_context_append_data (tc, NULL, 0, |
1228 | GNUNET_MESSAGE_TYPE_TRANSPORT_MONITOR_PEER_RESPONSE); | 1227 | GNUNET_MESSAGE_TYPE_TRANSPORT_MONITOR_VALIDATION_RESPONSE); |
1229 | } | 1228 | } |
1230 | GNUNET_SERVER_transmit_context_run (tc, GNUNET_TIME_UNIT_FOREVER_REL); | 1229 | GNUNET_SERVER_transmit_context_run (tc, GNUNET_TIME_UNIT_FOREVER_REL); |
1231 | } | 1230 | } |
diff --git a/src/transport/gnunet-transport.c b/src/transport/gnunet-transport.c index 8311c1d72..56df0fbf6 100644 --- a/src/transport/gnunet-transport.c +++ b/src/transport/gnunet-transport.c | |||
@@ -114,6 +114,11 @@ static int monitor_connects; | |||
114 | static int monitor_connections; | 114 | static int monitor_connections; |
115 | 115 | ||
116 | /** | 116 | /** |
117 | * Option -f. | ||
118 | */ | ||
119 | static int monitor_validation; | ||
120 | |||
121 | /** | ||
117 | * Option -C. | 122 | * Option -C. |
118 | */ | 123 | */ |
119 | static int try_connect; | 124 | static int try_connect; |
@@ -498,8 +503,9 @@ process_validation_string (void *cls, const char *address) | |||
498 | s_next = GNUNET_strdup(GNUNET_STRINGS_absolute_time_to_string (vc->next_validation)); | 503 | s_next = GNUNET_strdup(GNUNET_STRINGS_absolute_time_to_string (vc->next_validation)); |
499 | 504 | ||
500 | FPRINTF (stdout, | 505 | FPRINTF (stdout, |
501 | _("Peer `%s' %s `%s'\n\t%s%s\n\t%s%s\n\t%s%s\n"), | 506 | _("Peer `%s' %s %s\n\t%s%s\n\t%s%s\n\t%s%s\n"), |
502 | GNUNET_i2s (&vc->id), address, GNUNET_TRANSPORT_vs2s (vc->state), | 507 | GNUNET_i2s (&vc->id), address, |
508 | (monitor_validation) ? GNUNET_TRANSPORT_vs2s (vc->state) : "", | ||
503 | "Valid until : ", s_valid, | 509 | "Valid until : ", s_valid, |
504 | "Last validation: ",s_last, | 510 | "Last validation: ",s_last, |
505 | "Next validation: ", s_next); | 511 | "Next validation: ", s_next); |
@@ -1135,7 +1141,8 @@ testservice_task (void *cls, int result) | |||
1135 | } | 1141 | } |
1136 | 1142 | ||
1137 | counter = benchmark_send + benchmark_receive + iterate_connections | 1143 | counter = benchmark_send + benchmark_receive + iterate_connections |
1138 | + monitor_connections + monitor_connects + try_connect + iterate_validation; | 1144 | + monitor_connections + monitor_connects + try_connect |
1145 | + iterate_validation + monitor_validation; | ||
1139 | 1146 | ||
1140 | if (1 < counter) | 1147 | if (1 < counter) |
1141 | { | 1148 | { |
@@ -1246,9 +1253,16 @@ testservice_task (void *cls, int result) | |||
1246 | } | 1253 | } |
1247 | else if (iterate_validation) /* -d: Print information about validations */ | 1254 | else if (iterate_validation) /* -d: Print information about validations */ |
1248 | { | 1255 | { |
1249 | vic = GNUNET_TRANSPORT_monitor_validation_entries (cfg, (NULL == cpid) ? NULL : &pid, | 1256 | vic = GNUNET_TRANSPORT_monitor_validation_entries (cfg, |
1257 | (NULL == cpid) ? NULL : &pid, | ||
1250 | GNUNET_YES, TIMEOUT, &process_validation_cb, (void *) cfg); | 1258 | GNUNET_YES, TIMEOUT, &process_validation_cb, (void *) cfg); |
1251 | } | 1259 | } |
1260 | else if (monitor_validation) /* -f: Print information about validations continuously */ | ||
1261 | { | ||
1262 | vic = GNUNET_TRANSPORT_monitor_validation_entries (cfg, | ||
1263 | (NULL == cpid) ? NULL : &pid, | ||
1264 | GNUNET_NO, TIMEOUT, &process_validation_cb, (void *) cfg); | ||
1265 | } | ||
1252 | else if (monitor_connects) /* -e : Monitor (dis)connect events continuously */ | 1266 | else if (monitor_connects) /* -e : Monitor (dis)connect events continuously */ |
1253 | { | 1267 | { |
1254 | monitor_connect_counter = 0; | 1268 | monitor_connect_counter = 0; |
@@ -1312,6 +1326,9 @@ main (int argc, char * const *argv) | |||
1312 | { 'd', "validation", NULL, | 1326 | { 'd', "validation", NULL, |
1313 | gettext_noop ("print information for all pending validations "), | 1327 | gettext_noop ("print information for all pending validations "), |
1314 | 0, &GNUNET_GETOPT_set_one, &iterate_validation }, | 1328 | 0, &GNUNET_GETOPT_set_one, &iterate_validation }, |
1329 | { 'f', "monitorvalidation", NULL, | ||
1330 | gettext_noop ("print information for all pending validations continously"), | ||
1331 | 0, &GNUNET_GETOPT_set_one, &monitor_validation }, | ||
1315 | { 'i', "information", NULL, | 1332 | { 'i', "information", NULL, |
1316 | gettext_noop ("provide information about all current connections (once)"), | 1333 | gettext_noop ("provide information about all current connections (once)"), |
1317 | 0, &GNUNET_GETOPT_set_one, &iterate_connections }, | 1334 | 0, &GNUNET_GETOPT_set_one, &iterate_connections }, |
diff --git a/src/transport/transport_api_monitoring.c b/src/transport/transport_api_monitoring.c index 9d74eb114..af5988151 100644 --- a/src/transport/transport_api_monitoring.c +++ b/src/transport/transport_api_monitoring.c | |||
@@ -240,6 +240,8 @@ GNUNET_TRANSPORT_vs2s (enum GNUNET_TRANSPORT_ValidationState state) | |||
240 | { | 240 | { |
241 | switch (state) | 241 | switch (state) |
242 | { | 242 | { |
243 | case GNUNET_TRANSPORT_VS_NONE: | ||
244 | return "NEW"; | ||
243 | case GNUNET_TRANSPORT_VS_NEW: | 245 | case GNUNET_TRANSPORT_VS_NEW: |
244 | return "NEW"; | 246 | return "NEW"; |
245 | case GNUNET_TRANSPORT_VS_REMOVE: | 247 | case GNUNET_TRANSPORT_VS_REMOVE: |
@@ -309,7 +311,7 @@ send_val_mon_request (struct GNUNET_TRANSPORT_ValidationMonitoringContext *val_c | |||
309 | { | 311 | { |
310 | struct ValidationMonitorMessage msg; | 312 | struct ValidationMonitorMessage msg; |
311 | 313 | ||
312 | msg.header.size = htons (sizeof (struct PeerMonitorMessage)); | 314 | msg.header.size = htons (sizeof (struct ValidationMonitorMessage)); |
313 | msg.header.type = htons (GNUNET_MESSAGE_TYPE_TRANSPORT_MONITOR_VALIDATION_REQUEST); | 315 | msg.header.type = htons (GNUNET_MESSAGE_TYPE_TRANSPORT_MONITOR_VALIDATION_REQUEST); |
314 | msg.one_shot = htonl (val_ctx->one_shot); | 316 | msg.one_shot = htonl (val_ctx->one_shot); |
315 | msg.peer = val_ctx->peer; | 317 | msg.peer = val_ctx->peer; |
@@ -322,7 +324,6 @@ send_val_mon_request (struct GNUNET_TRANSPORT_ValidationMonitoringContext *val_c | |||
322 | val_ctx)); | 324 | val_ctx)); |
323 | } | 325 | } |
324 | 326 | ||
325 | |||
326 | /** | 327 | /** |
327 | * Task run to re-establish the connection. | 328 | * Task run to re-establish the connection. |
328 | * | 329 | * |
@@ -330,8 +331,8 @@ send_val_mon_request (struct GNUNET_TRANSPORT_ValidationMonitoringContext *val_c | |||
330 | * @param tc scheduler context, unused | 331 | * @param tc scheduler context, unused |
331 | */ | 332 | */ |
332 | static void | 333 | static void |
333 | do_connect (void *cls, | 334 | do_peer_connect (void *cls, |
334 | const struct GNUNET_SCHEDULER_TaskContext *tc) | 335 | const struct GNUNET_SCHEDULER_TaskContext *tc) |
335 | { | 336 | { |
336 | struct GNUNET_TRANSPORT_PeerMonitoringContext *pal_ctx = cls; | 337 | struct GNUNET_TRANSPORT_PeerMonitoringContext *pal_ctx = cls; |
337 | 338 | ||
@@ -355,10 +356,29 @@ reconnect_peer_ctx (struct GNUNET_TRANSPORT_PeerMonitoringContext *pal_ctx) | |||
355 | pal_ctx->client = NULL; | 356 | pal_ctx->client = NULL; |
356 | pal_ctx->backoff = GNUNET_TIME_STD_BACKOFF (pal_ctx->backoff); | 357 | pal_ctx->backoff = GNUNET_TIME_STD_BACKOFF (pal_ctx->backoff); |
357 | pal_ctx->reconnect_task = GNUNET_SCHEDULER_add_delayed (pal_ctx->backoff, | 358 | pal_ctx->reconnect_task = GNUNET_SCHEDULER_add_delayed (pal_ctx->backoff, |
358 | &do_connect, | 359 | &do_peer_connect, |
359 | pal_ctx); | 360 | pal_ctx); |
360 | } | 361 | } |
361 | 362 | ||
363 | |||
364 | /** | ||
365 | * Task run to re-establish the connection. | ||
366 | * | ||
367 | * @param cls our 'struct GNUNET_TRANSPORT_PeerAddressLookupContext*' | ||
368 | * @param tc scheduler context, unused | ||
369 | */ | ||
370 | static void | ||
371 | do_val_connect (void *cls, | ||
372 | const struct GNUNET_SCHEDULER_TaskContext *tc) | ||
373 | { | ||
374 | struct GNUNET_TRANSPORT_ValidationMonitoringContext *val_ctx = cls; | ||
375 | |||
376 | val_ctx->reconnect_task = GNUNET_SCHEDULER_NO_TASK; | ||
377 | val_ctx->client = GNUNET_CLIENT_connect ("transport", val_ctx->cfg); | ||
378 | GNUNET_assert (NULL != val_ctx->client); | ||
379 | send_val_mon_request (val_ctx); | ||
380 | } | ||
381 | |||
362 | /** | 382 | /** |
363 | * Cut the existing connection and reconnect. | 383 | * Cut the existing connection and reconnect. |
364 | * | 384 | * |
@@ -372,7 +392,7 @@ reconnect_val_ctx (struct GNUNET_TRANSPORT_ValidationMonitoringContext *val_ctx) | |||
372 | val_ctx->client = NULL; | 392 | val_ctx->client = NULL; |
373 | val_ctx->backoff = GNUNET_TIME_STD_BACKOFF (val_ctx->backoff); | 393 | val_ctx->backoff = GNUNET_TIME_STD_BACKOFF (val_ctx->backoff); |
374 | val_ctx->reconnect_task = GNUNET_SCHEDULER_add_delayed (val_ctx->backoff, | 394 | val_ctx->reconnect_task = GNUNET_SCHEDULER_add_delayed (val_ctx->backoff, |
375 | &do_connect, | 395 | &do_val_connect, |
376 | val_ctx); | 396 | val_ctx); |
377 | } | 397 | } |
378 | 398 | ||
@@ -397,7 +417,6 @@ val_response_processor (void *cls, const struct GNUNET_MessageHeader *msg) | |||
397 | 417 | ||
398 | if (msg == NULL) | 418 | if (msg == NULL) |
399 | { | 419 | { |
400 | GNUNET_break (0); | ||
401 | if (val_ctx->one_shot) | 420 | if (val_ctx->one_shot) |
402 | { | 421 | { |
403 | /* Disconnect */ | 422 | /* Disconnect */ |
@@ -415,6 +434,7 @@ val_response_processor (void *cls, const struct GNUNET_MessageHeader *msg) | |||
415 | size = ntohs (msg->size); | 434 | size = ntohs (msg->size); |
416 | GNUNET_break (ntohs (msg->type) == | 435 | GNUNET_break (ntohs (msg->type) == |
417 | GNUNET_MESSAGE_TYPE_TRANSPORT_MONITOR_VALIDATION_RESPONSE); | 436 | GNUNET_MESSAGE_TYPE_TRANSPORT_MONITOR_VALIDATION_RESPONSE); |
437 | |||
418 | if (size == sizeof (struct GNUNET_MessageHeader)) | 438 | if (size == sizeof (struct GNUNET_MessageHeader)) |
419 | { | 439 | { |
420 | /* Done! */ | 440 | /* Done! */ |
@@ -548,7 +568,7 @@ peer_response_processor (void *cls, const struct GNUNET_MessageHeader *msg) | |||
548 | uint16_t size; | 568 | uint16_t size; |
549 | size_t alen; | 569 | size_t alen; |
550 | size_t tlen; | 570 | size_t tlen; |
551 | GNUNET_break (0); | 571 | |
552 | if (msg == NULL) | 572 | if (msg == NULL) |
553 | { | 573 | { |
554 | if (pal_ctx->one_shot) | 574 | if (pal_ctx->one_shot) |