diff options
author | Christian Grothoff <christian@grothoff.org> | 2014-06-16 07:58:28 +0000 |
---|---|---|
committer | Christian Grothoff <christian@grothoff.org> | 2014-06-16 07:58:28 +0000 |
commit | 2c8688f023c99960394e066a30a3eed4041f43fb (patch) | |
tree | a5da5beebe1b9104caf2077f3d1998bf67f380ea /src/ats-tool/gnunet-ats.c | |
parent | ca86c832ab602853100a7e0c559aacd162046678 (diff) | |
download | gnunet-2c8688f023c99960394e066a30a3eed4041f43fb.tar.gz gnunet-2c8688f023c99960394e066a30a3eed4041f43fb.zip |
-doxygen, indentation
Diffstat (limited to 'src/ats-tool/gnunet-ats.c')
-rw-r--r-- | src/ats-tool/gnunet-ats.c | 83 |
1 files changed, 51 insertions, 32 deletions
diff --git a/src/ats-tool/gnunet-ats.c b/src/ats-tool/gnunet-ats.c index 7360e4c50..0f6609365 100644 --- a/src/ats-tool/gnunet-ats.c +++ b/src/ats-tool/gnunet-ats.c | |||
@@ -200,7 +200,7 @@ transport_addr_to_str_cb (void *cls, | |||
200 | "Failed to convert address for peer `%s' plugin `%s' length %lu to string \n", | 200 | "Failed to convert address for peer `%s' plugin `%s' length %lu to string \n", |
201 | GNUNET_i2s (&pr->address->peer), | 201 | GNUNET_i2s (&pr->address->peer), |
202 | pr->address->transport_name, | 202 | pr->address->transport_name, |
203 | pr->address->address_length ); | 203 | pr->address->address_length); |
204 | return; | 204 | return; |
205 | } | 205 | } |
206 | 206 | ||
@@ -215,9 +215,9 @@ transport_addr_to_str_cb (void *cls, | |||
215 | if ((GNUNET_YES == receive_done) && (0 == pending)) | 215 | if ((GNUNET_YES == receive_done) && (0 == pending)) |
216 | { | 216 | { |
217 | /* All messages received and no resolutions pending*/ | 217 | /* All messages received and no resolutions pending*/ |
218 | if (end_task != GNUNET_SCHEDULER_NO_TASK ) | 218 | if (end_task != GNUNET_SCHEDULER_NO_TASK) |
219 | GNUNET_SCHEDULER_cancel (end_task); | 219 | GNUNET_SCHEDULER_cancel (end_task); |
220 | end_task = GNUNET_SCHEDULER_add_now (end, NULL ); | 220 | end_task = GNUNET_SCHEDULER_add_now (end, NULL); |
221 | } | 221 | } |
222 | 222 | ||
223 | return; | 223 | return; |
@@ -309,6 +309,19 @@ find_address_it (void *cls, | |||
309 | } | 309 | } |
310 | 310 | ||
311 | 311 | ||
312 | |||
313 | /** | ||
314 | * Signature of a function that is called with QoS information about an address. | ||
315 | * | ||
316 | * @param cls closure (NULL) | ||
317 | * @param address the address, NULL if ATS service was disconnected | ||
318 | * @param address_active is this address actively used to maintain a connection | ||
319 | to a peer | ||
320 | * @param bandwidth_out assigned outbound bandwidth for the connection | ||
321 | * @param bandwidth_in assigned inbound bandwidth for the connection | ||
322 | * @param ats performance data for the address (as far as known) | ||
323 | * @param ats_count number of performance records in @a ats | ||
324 | */ | ||
312 | static void | 325 | static void |
313 | ats_perf_mon_cb(void *cls, | 326 | ats_perf_mon_cb(void *cls, |
314 | const struct GNUNET_HELLO_Address *address, | 327 | const struct GNUNET_HELLO_Address *address, |
@@ -342,15 +355,18 @@ ats_perf_mon_cb(void *cls, | |||
342 | if (GNUNET_NO == verbose) | 355 | if (GNUNET_NO == verbose) |
343 | { | 356 | { |
344 | struct AddressFindCtx actx; | 357 | struct AddressFindCtx actx; |
358 | struct ATSAddress *a; | ||
345 | 359 | ||
346 | actx.src = address; | 360 | actx.src = address; |
347 | actx.res = NULL; | 361 | actx.res = NULL; |
348 | 362 | ||
349 | GNUNET_CONTAINER_multipeermap_iterate (addresses, find_address_it, &actx); | 363 | GNUNET_CONTAINER_multipeermap_iterate (addresses, |
350 | if ((actx.res != NULL)) | 364 | &find_address_it, |
365 | &actx); | ||
366 | if ((NULL != actx.res)) | ||
351 | { | 367 | { |
352 | if ((bandwidth_in.value__ == actx.res->bandwidth_in.value__) && | 368 | if ((bandwidth_in.value__ == actx.res->bandwidth_in.value__) && |
353 | (bandwidth_out.value__ == actx.res->bandwidth_out.value__) ) | 369 | (bandwidth_out.value__ == actx.res->bandwidth_out.value__)) |
354 | { | 370 | { |
355 | return; /* Nothing to do here */ | 371 | return; /* Nothing to do here */ |
356 | } | 372 | } |
@@ -360,12 +376,14 @@ ats_perf_mon_cb(void *cls, | |||
360 | actx.res->bandwidth_out = bandwidth_out; | 376 | actx.res->bandwidth_out = bandwidth_out; |
361 | } | 377 | } |
362 | } | 378 | } |
363 | struct ATSAddress *a = GNUNET_new (struct ATSAddress); | 379 | a = GNUNET_new (struct ATSAddress); |
364 | a->address = GNUNET_HELLO_address_copy(address); | 380 | a->address = GNUNET_HELLO_address_copy(address); |
365 | a->bandwidth_in = bandwidth_in; | 381 | a->bandwidth_in = bandwidth_in; |
366 | a->bandwidth_out = bandwidth_out; | 382 | a->bandwidth_out = bandwidth_out; |
367 | GNUNET_CONTAINER_multipeermap_put (addresses, &address->peer, a, | 383 | GNUNET_CONTAINER_multipeermap_put (addresses, |
368 | GNUNET_CONTAINER_MULTIHASHMAPOPTION_MULTIPLE); | 384 | &address->peer, |
385 | a, | ||
386 | GNUNET_CONTAINER_MULTIHASHMAPOPTION_MULTIPLE); | ||
369 | } | 387 | } |
370 | 388 | ||
371 | pr = GNUNET_malloc (sizeof (struct PendingResolutions) + | 389 | pr = GNUNET_malloc (sizeof (struct PendingResolutions) + |
@@ -379,9 +397,10 @@ ats_perf_mon_cb(void *cls, | |||
379 | pr->bandwidth_in = bandwidth_in; | 397 | pr->bandwidth_in = bandwidth_in; |
380 | pr->bandwidth_out = bandwidth_out; | 398 | pr->bandwidth_out = bandwidth_out; |
381 | pr->tats_ctx = GNUNET_TRANSPORT_address_to_string (cfg, address, | 399 | pr->tats_ctx = GNUNET_TRANSPORT_address_to_string (cfg, address, |
382 | resolve_addresses_numeric, | 400 | resolve_addresses_numeric, |
383 | GNUNET_TIME_relative_multiply (GNUNET_TIME_UNIT_SECONDS, 10), | 401 | GNUNET_TIME_relative_multiply (GNUNET_TIME_UNIT_SECONDS, 10), |
384 | transport_addr_to_str_cb, pr); | 402 | &transport_addr_to_str_cb, |
403 | pr); | ||
385 | GNUNET_CONTAINER_DLL_insert (head, tail, pr); | 404 | GNUNET_CONTAINER_DLL_insert (head, tail, pr); |
386 | results++; | 405 | results++; |
387 | pending++; | 406 | pending++; |
@@ -407,9 +426,9 @@ ats_perf_cb(void *cls, | |||
407 | if (0 == pending) | 426 | if (0 == pending) |
408 | { | 427 | { |
409 | /* All messages received and no resolutions pending*/ | 428 | /* All messages received and no resolutions pending*/ |
410 | if (end_task != GNUNET_SCHEDULER_NO_TASK ) | 429 | if (end_task != GNUNET_SCHEDULER_NO_TASK) |
411 | GNUNET_SCHEDULER_cancel (end_task); | 430 | GNUNET_SCHEDULER_cancel (end_task); |
412 | end_task = GNUNET_SCHEDULER_add_now (end, NULL ); | 431 | end_task = GNUNET_SCHEDULER_add_now (end, NULL); |
413 | } | 432 | } |
414 | return; | 433 | return; |
415 | } | 434 | } |
@@ -550,21 +569,21 @@ testservice_ats(void *cls, int result) | |||
550 | } | 569 | } |
551 | if (op_list_all) | 570 | if (op_list_all) |
552 | { | 571 | { |
553 | ph = GNUNET_ATS_performance_init (cfg, NULL, NULL ); | 572 | ph = GNUNET_ATS_performance_init (cfg, NULL, NULL); |
554 | if (NULL == ph) | 573 | if (NULL == ph) |
555 | { | 574 | { |
556 | fprintf (stderr, | 575 | fprintf (stderr, |
557 | _("Cannot connect to ATS service, exiting...\n") ); | 576 | _("Cannot connect to ATS service, exiting...\n")); |
558 | return; | 577 | return; |
559 | } | 578 | } |
560 | 579 | ||
561 | alh = GNUNET_ATS_performance_list_addresses (ph, | 580 | alh = GNUNET_ATS_performance_list_addresses (ph, |
562 | (NULL == pid_str) ? NULL : &pid, GNUNET_YES, ats_perf_cb, NULL ); | 581 | (NULL == pid_str) ? NULL : &pid, GNUNET_YES, ats_perf_cb, NULL); |
563 | if (NULL == alh) | 582 | if (NULL == alh) |
564 | { | 583 | { |
565 | fprintf (stderr, | 584 | fprintf (stderr, |
566 | _("Cannot issue request to ATS service, exiting...\n") ); | 585 | _("Cannot issue request to ATS service, exiting...\n")); |
567 | end_task = GNUNET_SCHEDULER_add_now (&end, NULL ); | 586 | end_task = GNUNET_SCHEDULER_add_now (&end, NULL); |
568 | return; | 587 | return; |
569 | } | 588 | } |
570 | end_task = GNUNET_SCHEDULER_add_delayed (GNUNET_TIME_UNIT_FOREVER_REL, | 589 | end_task = GNUNET_SCHEDULER_add_delayed (GNUNET_TIME_UNIT_FOREVER_REL, |
@@ -573,18 +592,18 @@ testservice_ats(void *cls, int result) | |||
573 | } | 592 | } |
574 | else if (op_list_used) | 593 | else if (op_list_used) |
575 | { | 594 | { |
576 | ph = GNUNET_ATS_performance_init (cfg, NULL, NULL ); | 595 | ph = GNUNET_ATS_performance_init (cfg, NULL, NULL); |
577 | if (NULL == ph) | 596 | if (NULL == ph) |
578 | fprintf (stderr, | 597 | fprintf (stderr, |
579 | _("Cannot connect to ATS service, exiting...\n") ); | 598 | _("Cannot connect to ATS service, exiting...\n")); |
580 | 599 | ||
581 | alh = GNUNET_ATS_performance_list_addresses (ph, | 600 | alh = GNUNET_ATS_performance_list_addresses (ph, |
582 | (NULL == pid_str) ? NULL : &pid, GNUNET_NO, ats_perf_cb, NULL ); | 601 | (NULL == pid_str) ? NULL : &pid, GNUNET_NO, ats_perf_cb, NULL); |
583 | if (NULL == alh) | 602 | if (NULL == alh) |
584 | { | 603 | { |
585 | fprintf (stderr, | 604 | fprintf (stderr, |
586 | _("Cannot issue request to ATS service, exiting...\n") ); | 605 | _("Cannot issue request to ATS service, exiting...\n")); |
587 | end_task = GNUNET_SCHEDULER_add_now (&end, NULL ); | 606 | end_task = GNUNET_SCHEDULER_add_now (&end, NULL); |
588 | return; | 607 | return; |
589 | } | 608 | } |
590 | end_task = GNUNET_SCHEDULER_add_delayed (GNUNET_TIME_UNIT_FOREVER_REL, | 609 | end_task = GNUNET_SCHEDULER_add_delayed (GNUNET_TIME_UNIT_FOREVER_REL, |
@@ -593,10 +612,10 @@ testservice_ats(void *cls, int result) | |||
593 | } | 612 | } |
594 | else if (op_monitor) | 613 | else if (op_monitor) |
595 | { | 614 | { |
596 | ph = GNUNET_ATS_performance_init (cfg, &ats_perf_mon_cb, NULL ); | 615 | ph = GNUNET_ATS_performance_init (cfg, &ats_perf_mon_cb, NULL); |
597 | if (NULL == ph) | 616 | if (NULL == ph) |
598 | fprintf (stderr, | 617 | fprintf (stderr, |
599 | _("Cannot connect to ATS service, exiting...\n") ); | 618 | _("Cannot connect to ATS service, exiting...\n")); |
600 | end_task = GNUNET_SCHEDULER_add_delayed (GNUNET_TIME_UNIT_FOREVER_REL, | 619 | end_task = GNUNET_SCHEDULER_add_delayed (GNUNET_TIME_UNIT_FOREVER_REL, |
601 | &end, | 620 | &end, |
602 | NULL); | 621 | NULL); |
@@ -607,13 +626,13 @@ testservice_ats(void *cls, int result) | |||
607 | if (NULL == type_str) | 626 | if (NULL == type_str) |
608 | { | 627 | { |
609 | fprintf (stderr, | 628 | fprintf (stderr, |
610 | _("No preference type given!\n") ); | 629 | _("No preference type given!\n")); |
611 | return; | 630 | return; |
612 | } | 631 | } |
613 | if (NULL == pid_str) | 632 | if (NULL == pid_str) |
614 | { | 633 | { |
615 | fprintf (stderr, | 634 | fprintf (stderr, |
616 | _("No peer given!\n") ); | 635 | _("No peer given!\n")); |
617 | return; | 636 | return; |
618 | } | 637 | } |
619 | 638 | ||
@@ -629,15 +648,15 @@ testservice_ats(void *cls, int result) | |||
629 | type = GNUNET_ATS_PREFERENCE_BANDWIDTH; | 648 | type = GNUNET_ATS_PREFERENCE_BANDWIDTH; |
630 | else | 649 | else |
631 | { | 650 | { |
632 | FPRINTF (stderr, "%s", _("Valid type required\n") ); | 651 | FPRINTF (stderr, "%s", _("Valid type required\n")); |
633 | return; | 652 | return; |
634 | } | 653 | } |
635 | 654 | ||
636 | /* set */ | 655 | /* set */ |
637 | ph = GNUNET_ATS_performance_init (cfg, NULL, NULL ); | 656 | ph = GNUNET_ATS_performance_init (cfg, NULL, NULL); |
638 | if (NULL == ph) | 657 | if (NULL == ph) |
639 | fprintf (stderr, | 658 | fprintf (stderr, |
640 | _("Cannot connect to ATS service, exiting...\n") ); | 659 | _("Cannot connect to ATS service, exiting...\n")); |
641 | 660 | ||
642 | GNUNET_ATS_performance_change_preference (ph, &pid, type, (double) value, | 661 | GNUNET_ATS_performance_change_preference (ph, &pid, type, (double) value, |
643 | GNUNET_ATS_PREFERENCE_END); | 662 | GNUNET_ATS_PREFERENCE_END); |
@@ -728,7 +747,7 @@ main(int argc, char * const *argv) | |||
728 | &run, NULL); | 747 | &run, NULL); |
729 | GNUNET_free_non_null(pid_str); | 748 | GNUNET_free_non_null(pid_str); |
730 | GNUNET_free_non_null(type_str); | 749 | GNUNET_free_non_null(type_str); |
731 | GNUNET_free((void * ) argv); | 750 | GNUNET_free((void *) argv); |
732 | 751 | ||
733 | if (GNUNET_OK == res) | 752 | if (GNUNET_OK == res) |
734 | return ret; | 753 | return ret; |