diff options
-rw-r--r-- | src/ats-tests/ats-testing.c | 52 | ||||
-rw-r--r-- | src/ats-tests/gnunet-solver-eval.c | 1 | ||||
-rw-r--r-- | src/ats-tool/gnunet-ats.c | 43 | ||||
-rw-r--r-- | src/ats/ats_api_performance.c | 30 | ||||
-rw-r--r-- | src/ats/gnunet-service-ats_addresses.c | 203 | ||||
-rw-r--r-- | src/ats/gnunet-service-ats_performance.c | 58 | ||||
-rw-r--r-- | src/ats/gnunet-service-ats_performance.h | 19 | ||||
-rw-r--r-- | src/ats/test_ats_api_performance_list_all_addresses.c | 3 | ||||
-rw-r--r-- | src/ats/test_ats_solver_add_address.c | 6 | ||||
-rw-r--r-- | src/ats/test_ats_solver_alternative_after_delete_address.c | 6 | ||||
-rw-r--r-- | src/dv/gnunet-service-dv.c | 10 | ||||
-rw-r--r-- | src/fs/gnunet-service-fs.c | 2 | ||||
-rw-r--r-- | src/include/gnunet_ats_service.h | 38 | ||||
-rw-r--r-- | src/testbed/gnunet-daemon-latency-logger.c | 28 |
14 files changed, 311 insertions, 188 deletions
diff --git a/src/ats-tests/ats-testing.c b/src/ats-tests/ats-testing.c index 6fda20311..a4016a120 100644 --- a/src/ats-tests/ats-testing.c +++ b/src/ats-tests/ats-testing.c | |||
@@ -541,14 +541,15 @@ do_comm_connect (void *cls, const struct GNUNET_SCHEDULER_TaskContext *tc) | |||
541 | } | 541 | } |
542 | } | 542 | } |
543 | 543 | ||
544 | |||
544 | static void | 545 | static void |
545 | ats_performance_info_cb (void *cls, | 546 | ats_performance_info_cb (void *cls, |
546 | const struct GNUNET_HELLO_Address *address, | 547 | const struct GNUNET_HELLO_Address *address, |
547 | int address_active, | 548 | int address_active, |
548 | struct GNUNET_BANDWIDTH_Value32NBO bandwidth_out, | 549 | struct GNUNET_BANDWIDTH_Value32NBO bandwidth_out, |
549 | struct GNUNET_BANDWIDTH_Value32NBO bandwidth_in, | 550 | struct GNUNET_BANDWIDTH_Value32NBO bandwidth_in, |
550 | const struct GNUNET_ATS_Information *ats, | 551 | const struct GNUNET_ATS_Information *ats, |
551 | uint32_t ats_count) | 552 | uint32_t ats_count) |
552 | { | 553 | { |
553 | struct BenchmarkPeer *me = cls; | 554 | struct BenchmarkPeer *me = cls; |
554 | struct BenchmarkPartner *p; | 555 | struct BenchmarkPartner *p; |
@@ -556,8 +557,6 @@ ats_performance_info_cb (void *cls, | |||
556 | int log; | 557 | int log; |
557 | char *peer_id; | 558 | char *peer_id; |
558 | 559 | ||
559 | |||
560 | |||
561 | p = find_partner (me, &address->peer); | 560 | p = find_partner (me, &address->peer); |
562 | if (NULL == p) | 561 | if (NULL == p) |
563 | { | 562 | { |
@@ -634,8 +633,11 @@ ats_performance_info_cb (void *cls, | |||
634 | } | 633 | } |
635 | } | 634 | } |
636 | if (GNUNET_YES == log) | 635 | if (GNUNET_YES == log) |
637 | top->ats_perf_cb (cls, address, address_active, bandwidth_out, bandwidth_in, | 636 | top->ats_perf_cb (cls, address, |
638 | ats, ats_count); | 637 | address_active, |
638 | bandwidth_out, | ||
639 | bandwidth_in, | ||
640 | ats, ats_count); | ||
639 | GNUNET_free(peer_id); | 641 | GNUNET_free(peer_id); |
640 | } | 642 | } |
641 | 643 | ||
@@ -646,7 +648,9 @@ ats_perf_connect_adapter (void *cls, | |||
646 | { | 648 | { |
647 | struct BenchmarkPeer *me = cls; | 649 | struct BenchmarkPeer *me = cls; |
648 | 650 | ||
649 | me->ats_perf_handle = GNUNET_ATS_performance_init (cfg, ats_performance_info_cb, me); | 651 | me->ats_perf_handle = GNUNET_ATS_performance_init (cfg, |
652 | &ats_performance_info_cb, | ||
653 | me); | ||
650 | if (NULL == me->ats_perf_handle) | 654 | if (NULL == me->ats_perf_handle) |
651 | GNUNET_log(GNUNET_ERROR_TYPE_ERROR, | 655 | GNUNET_log(GNUNET_ERROR_TYPE_ERROR, |
652 | "Failed to create ATS performance handle \n"); | 656 | "Failed to create ATS performance handle \n"); |
@@ -857,6 +861,7 @@ GNUNET_ATS_TEST_get_partner (int src, int dest) | |||
857 | return &top->mps[src].partners[dest]; | 861 | return &top->mps[src].partners[dest]; |
858 | } | 862 | } |
859 | 863 | ||
864 | |||
860 | /** | 865 | /** |
861 | * Create a topology for ats testing | 866 | * Create a topology for ats testing |
862 | * | 867 | * |
@@ -872,15 +877,14 @@ GNUNET_ATS_TEST_get_partner (int src, int dest) | |||
872 | */ | 877 | */ |
873 | void | 878 | void |
874 | GNUNET_ATS_TEST_create_topology (char *name, char *cfg_file, | 879 | GNUNET_ATS_TEST_create_topology (char *name, char *cfg_file, |
875 | unsigned int num_slaves, | 880 | unsigned int num_slaves, |
876 | unsigned int num_masters, | 881 | unsigned int num_masters, |
877 | int test_core, | 882 | int test_core, |
878 | GNUNET_ATS_TEST_TopologySetupDoneCallback done_cb, | 883 | GNUNET_ATS_TEST_TopologySetupDoneCallback done_cb, |
879 | void *done_cb_cls, | 884 | void *done_cb_cls, |
880 | GNUNET_TRANSPORT_ReceiveCallback transport_recv_cb, | 885 | GNUNET_TRANSPORT_ReceiveCallback transport_recv_cb, |
881 | GNUNET_ATS_AddressInformationCallback log_request_cb) | 886 | GNUNET_ATS_AddressInformationCallback log_request_cb) |
882 | { | 887 | { |
883 | |||
884 | static struct GNUNET_CORE_MessageHandler handlers[] = { | 888 | static struct GNUNET_CORE_MessageHandler handlers[] = { |
885 | {&comm_handle_ping, TEST_MESSAGE_TYPE_PING, 0 }, | 889 | {&comm_handle_ping, TEST_MESSAGE_TYPE_PING, 0 }, |
886 | {&comm_handle_pong, TEST_MESSAGE_TYPE_PONG, 0 }, | 890 | {&comm_handle_pong, TEST_MESSAGE_TYPE_PONG, 0 }, |
@@ -894,7 +898,7 @@ GNUNET_ATS_TEST_create_topology (char *name, char *cfg_file, | |||
894 | top->done_cb_cls = done_cb_cls; | 898 | top->done_cb_cls = done_cb_cls; |
895 | top->test_core = test_core; | 899 | top->test_core = test_core; |
896 | top->transport_recv_cb = transport_recv_cb; | 900 | top->transport_recv_cb = transport_recv_cb; |
897 | top->ats_perf_cb = log_request_cb; | 901 | top->ats_perf_cb = &log_request_cb; |
898 | 902 | ||
899 | top->mps = GNUNET_malloc (num_masters * sizeof (struct BenchmarkPeer)); | 903 | top->mps = GNUNET_malloc (num_masters * sizeof (struct BenchmarkPeer)); |
900 | top->sps = GNUNET_malloc (num_slaves * sizeof (struct BenchmarkPeer)); | 904 | top->sps = GNUNET_malloc (num_slaves * sizeof (struct BenchmarkPeer)); |
@@ -905,10 +909,13 @@ GNUNET_ATS_TEST_create_topology (char *name, char *cfg_file, | |||
905 | event_mask |= (1LL << GNUNET_TESTBED_ET_CONNECT); | 909 | event_mask |= (1LL << GNUNET_TESTBED_ET_CONNECT); |
906 | event_mask |= (1LL << GNUNET_TESTBED_ET_OPERATION_FINISHED); | 910 | event_mask |= (1LL << GNUNET_TESTBED_ET_OPERATION_FINISHED); |
907 | (void) GNUNET_TESTBED_test_run (name, cfg_file, | 911 | (void) GNUNET_TESTBED_test_run (name, cfg_file, |
908 | num_slaves + num_masters, event_mask, &controller_event_cb, NULL, | 912 | num_slaves + num_masters, |
909 | &main_run, NULL); | 913 | event_mask, |
914 | &controller_event_cb, NULL, | ||
915 | &main_run, NULL); | ||
910 | } | 916 | } |
911 | 917 | ||
918 | |||
912 | /** | 919 | /** |
913 | * Shutdown topology | 920 | * Shutdown topology |
914 | */ | 921 | */ |
@@ -917,7 +924,6 @@ GNUNET_ATS_TEST_shutdown_topology (void) | |||
917 | { | 924 | { |
918 | if (NULL == top) | 925 | if (NULL == top) |
919 | return; | 926 | return; |
920 | |||
921 | GNUNET_SCHEDULER_shutdown(); | 927 | GNUNET_SCHEDULER_shutdown(); |
922 | } | 928 | } |
923 | 929 | ||
diff --git a/src/ats-tests/gnunet-solver-eval.c b/src/ats-tests/gnunet-solver-eval.c index 91507a7f4..9432f429d 100644 --- a/src/ats-tests/gnunet-solver-eval.c +++ b/src/ats-tests/gnunet-solver-eval.c | |||
@@ -33,7 +33,6 @@ | |||
33 | /** | 33 | /** |
34 | * Experiments | 34 | * Experiments |
35 | */ | 35 | */ |
36 | |||
37 | const char * | 36 | const char * |
38 | print_op (enum OperationType op) | 37 | print_op (enum OperationType op) |
39 | { | 38 | { |
diff --git a/src/ats-tool/gnunet-ats.c b/src/ats-tool/gnunet-ats.c index a1e2df7a6..0c7b19790 100644 --- a/src/ats-tool/gnunet-ats.c +++ b/src/ats-tool/gnunet-ats.c | |||
@@ -438,7 +438,7 @@ transport_addr_to_str_cb (void *cls, | |||
438 | ntohl (pr->bandwidth_out.value__), | 438 | ntohl (pr->bandwidth_out.value__), |
439 | ntohl (pr->bandwidth_in.value__), | 439 | ntohl (pr->bandwidth_in.value__), |
440 | ats_str); | 440 | ats_str); |
441 | GNUNET_free(ats_str); | 441 | GNUNET_free (ats_str); |
442 | } | 442 | } |
443 | 443 | ||
444 | 444 | ||
@@ -490,8 +490,10 @@ find_address_it (void *cls, | |||
490 | * | 490 | * |
491 | * @param cls closure (NULL) | 491 | * @param cls closure (NULL) |
492 | * @param address the address, NULL if ATS service was disconnected | 492 | * @param address the address, NULL if ATS service was disconnected |
493 | * @param address_active is this address actively used to maintain a connection | 493 | * @param active #GNUNET_YES if this address is actively used |
494 | to a peer | 494 | * to maintain a connection to a peer; |
495 | * #GNUNET_NO if the address is not actively used; | ||
496 | * #GNUNET_SYSERR if this address is no longer available for ATS | ||
495 | * @param bandwidth_out assigned outbound bandwidth for the connection | 497 | * @param bandwidth_out assigned outbound bandwidth for the connection |
496 | * @param bandwidth_in assigned inbound bandwidth for the connection | 498 | * @param bandwidth_in assigned inbound bandwidth for the connection |
497 | * @param ats performance data for the address (as far as known) | 499 | * @param ats performance data for the address (as far as known) |
@@ -528,6 +530,34 @@ ats_perf_mon_cb (void *cls, | |||
528 | NULL); | 530 | NULL); |
529 | return; | 531 | return; |
530 | } | 532 | } |
533 | if (GNUNET_SYSERR == active) | ||
534 | { | ||
535 | /* remove address */ | ||
536 | struct AddressFindCtx actx; | ||
537 | |||
538 | actx.src = address; | ||
539 | actx.res = NULL; | ||
540 | GNUNET_CONTAINER_multipeermap_get_multiple (addresses, | ||
541 | &address->peer, | ||
542 | &find_address_it, | ||
543 | &actx); | ||
544 | if (NULL == actx.res) | ||
545 | { | ||
546 | GNUNET_break (0); | ||
547 | return; | ||
548 | } | ||
549 | GNUNET_break (GNUNET_OK == | ||
550 | GNUNET_CONTAINER_multipeermap_remove (addresses, | ||
551 | &address->peer, | ||
552 | actx.res)); | ||
553 | FPRINTF (stderr, | ||
554 | _("Removed address of peer `%s' with plugin `%s'\n"), | ||
555 | GNUNET_i2s (&address->peer), | ||
556 | actx.res->address->transport_name); | ||
557 | GNUNET_HELLO_address_free (actx.res); | ||
558 | GNUNET_free (actx.res); | ||
559 | return; | ||
560 | } | ||
531 | 561 | ||
532 | if (GNUNET_NO == verbose) | 562 | if (GNUNET_NO == verbose) |
533 | { | 563 | { |
@@ -536,7 +566,6 @@ ats_perf_mon_cb (void *cls, | |||
536 | 566 | ||
537 | actx.src = address; | 567 | actx.src = address; |
538 | actx.res = NULL; | 568 | actx.res = NULL; |
539 | |||
540 | GNUNET_CONTAINER_multipeermap_get_multiple (addresses, | 569 | GNUNET_CONTAINER_multipeermap_get_multiple (addresses, |
541 | &address->peer, | 570 | &address->peer, |
542 | &find_address_it, | 571 | &find_address_it, |
@@ -836,7 +865,11 @@ testservice_ats (void *cls, | |||
836 | _("Cannot connect to ATS service, exiting...\n")); | 865 | _("Cannot connect to ATS service, exiting...\n")); |
837 | 866 | ||
838 | alh = GNUNET_ATS_performance_list_addresses (ph, | 867 | alh = GNUNET_ATS_performance_list_addresses (ph, |
839 | (NULL == pid_str) ? NULL : &pid, GNUNET_NO, ats_perf_cb, NULL); | 868 | (NULL == pid_str) |
869 | ? NULL | ||
870 | : &pid, | ||
871 | GNUNET_NO, | ||
872 | &ats_perf_cb, NULL); | ||
840 | if (NULL == alh) | 873 | if (NULL == alh) |
841 | { | 874 | { |
842 | FPRINTF (stderr, | 875 | FPRINTF (stderr, |
diff --git a/src/ats/ats_api_performance.c b/src/ats/ats_api_performance.c index 35dcc558f..ab242a0e9 100644 --- a/src/ats/ats_api_performance.c +++ b/src/ats/ats_api_performance.c | |||
@@ -367,7 +367,7 @@ process_pi_message (struct GNUNET_ATS_PerformanceHandle *ph, | |||
367 | ats_count = ntohl (pi->ats_count); | 367 | ats_count = ntohl (pi->ats_count); |
368 | plugin_address_length = ntohs (pi->address_length); | 368 | plugin_address_length = ntohs (pi->address_length); |
369 | plugin_name_length = ntohs (pi->plugin_name_length); | 369 | plugin_name_length = ntohs (pi->plugin_name_length); |
370 | addr_active = ntohl (pi->address_active); | 370 | addr_active = (int) ntohl (pi->address_active); |
371 | atsi = (const struct GNUNET_ATS_Information *) &pi[1]; | 371 | atsi = (const struct GNUNET_ATS_Information *) &pi[1]; |
372 | plugin_address = (const char *) &atsi[ats_count]; | 372 | plugin_address = (const char *) &atsi[ats_count]; |
373 | plugin_name = &plugin_address[plugin_address_length]; | 373 | plugin_name = &plugin_address[plugin_address_length]; |
@@ -389,7 +389,6 @@ process_pi_message (struct GNUNET_ATS_PerformanceHandle *ph, | |||
389 | address.address = plugin_address; | 389 | address.address = plugin_address; |
390 | address.address_length = plugin_address_length; | 390 | address.address_length = plugin_address_length; |
391 | address.transport_name = plugin_name; | 391 | address.transport_name = plugin_name; |
392 | |||
393 | ph->addr_info_cb (ph->addr_info_cb_cls, | 392 | ph->addr_info_cb (ph->addr_info_cb_cls, |
394 | &address, | 393 | &address, |
395 | addr_active, | 394 | addr_active, |
@@ -482,8 +481,9 @@ process_ar_message (struct GNUNET_ATS_PerformanceHandle *ph, | |||
482 | GNUNET_break(0); | 481 | GNUNET_break(0); |
483 | return GNUNET_SYSERR; | 482 | return GNUNET_SYSERR; |
484 | } | 483 | } |
485 | GNUNET_log(GNUNET_ERROR_TYPE_DEBUG, _("Received %s message\n"), | 484 | GNUNET_log(GNUNET_ERROR_TYPE_DEBUG, |
486 | "ATS_ADDRESSLIST_RESPONSE"); | 485 | _("Received %s message\n"), |
486 | "ATS_ADDRESSLIST_RESPONSE"); | ||
487 | 487 | ||
488 | pi = (const struct PeerInformationMessage *) msg; | 488 | pi = (const struct PeerInformationMessage *) msg; |
489 | id = ntohl (pi->id); | 489 | id = ntohl (pi->id); |
@@ -560,7 +560,8 @@ process_ar_message (struct GNUNET_ATS_PerformanceHandle *ph, | |||
560 | * @param msg message received, NULL on timeout or fatal error | 560 | * @param msg message received, NULL on timeout or fatal error |
561 | */ | 561 | */ |
562 | static void | 562 | static void |
563 | process_ats_message (void *cls, const struct GNUNET_MessageHeader *msg) | 563 | process_ats_message (void *cls, |
564 | const struct GNUNET_MessageHeader *msg) | ||
564 | { | 565 | { |
565 | struct GNUNET_ATS_PerformanceHandle *ph = cls; | 566 | struct GNUNET_ATS_PerformanceHandle *ph = cls; |
566 | 567 | ||
@@ -649,7 +650,7 @@ reconnect (struct GNUNET_ATS_PerformanceHandle *ph) | |||
649 | * @param cfg configuration to use | 650 | * @param cfg configuration to use |
650 | * @param addr_info_cb callback called when performance characteristics for | 651 | * @param addr_info_cb callback called when performance characteristics for |
651 | * an address change | 652 | * an address change |
652 | * @param addr_info_cb_cls closure for infocb | 653 | * @param addr_info_cb_cls closure for @a addr_info_cb |
653 | * @return ats performance context | 654 | * @return ats performance context |
654 | */ | 655 | */ |
655 | struct GNUNET_ATS_PerformanceHandle * | 656 | struct GNUNET_ATS_PerformanceHandle * |
@@ -778,7 +779,7 @@ GNUNET_ATS_reserve_bandwidth_cancel (struct GNUNET_ATS_ReservationContext *rc) | |||
778 | * | 779 | * |
779 | * @param handle the performance handle to use | 780 | * @param handle the performance handle to use |
780 | * @param peer peer idm can be NULL for all peers | 781 | * @param peer peer idm can be NULL for all peers |
781 | * @param all GNUNET_YES to get information about all addresses or GNUNET_NO to | 782 | * @param all #GNUNET_YES to get information about all addresses or #GNUNET_NO to |
782 | * get only address currently used | 783 | * get only address currently used |
783 | * @param infocb callback to call with the addresses, | 784 | * @param infocb callback to call with the addresses, |
784 | * will callback with address == NULL when done | 785 | * will callback with address == NULL when done |
@@ -832,8 +833,9 @@ GNUNET_ATS_performance_list_addresses (struct GNUNET_ATS_PerformanceHandle *hand | |||
832 | { | 833 | { |
833 | memset (&m->peer, '\0', sizeof(struct GNUNET_PeerIdentity)); | 834 | memset (&m->peer, '\0', sizeof(struct GNUNET_PeerIdentity)); |
834 | } | 835 | } |
835 | GNUNET_CONTAINER_DLL_insert_tail(handle->pending_head, handle->pending_tail, | 836 | GNUNET_CONTAINER_DLL_insert_tail(handle->pending_head, |
836 | p); | 837 | handle->pending_tail, |
838 | p); | ||
837 | 839 | ||
838 | do_transmit (handle); | 840 | do_transmit (handle); |
839 | 841 | ||
@@ -849,11 +851,11 @@ GNUNET_ATS_performance_list_addresses (struct GNUNET_ATS_PerformanceHandle *hand | |||
849 | void | 851 | void |
850 | GNUNET_ATS_performance_list_addresses_cancel (struct GNUNET_ATS_AddressListHandle *handle) | 852 | GNUNET_ATS_performance_list_addresses_cancel (struct GNUNET_ATS_AddressListHandle *handle) |
851 | { | 853 | { |
852 | GNUNET_assert(NULL != handle); | 854 | GNUNET_assert (NULL != handle); |
853 | 855 | GNUNET_CONTAINER_DLL_remove (handle->ph->addresslist_head, | |
854 | GNUNET_CONTAINER_DLL_remove(handle->ph->addresslist_head, | 856 | handle->ph->addresslist_tail, |
855 | handle->ph->addresslist_tail, handle); | 857 | handle); |
856 | GNUNET_free(handle); | 858 | GNUNET_free (handle); |
857 | } | 859 | } |
858 | 860 | ||
859 | 861 | ||
diff --git a/src/ats/gnunet-service-ats_addresses.c b/src/ats/gnunet-service-ats_addresses.c index ca8afecd9..93b9514fb 100644 --- a/src/ats/gnunet-service-ats_addresses.c +++ b/src/ats/gnunet-service-ats_addresses.c | |||
@@ -336,6 +336,13 @@ struct GAS_Addresses_Handle | |||
336 | char *plugin; | 336 | char *plugin; |
337 | }; | 337 | }; |
338 | 338 | ||
339 | |||
340 | /** | ||
341 | * Value we pass for zero bandwidth. | ||
342 | */ | ||
343 | const static struct GNUNET_BANDWIDTH_Value32NBO zero_bw; | ||
344 | |||
345 | |||
339 | /** | 346 | /** |
340 | * Disassemble ATS information and update performance information in address | 347 | * Disassemble ATS information and update performance information in address |
341 | * | 348 | * |
@@ -343,23 +350,23 @@ struct GAS_Addresses_Handle | |||
343 | * | 350 | * |
344 | * @param dest destination address | 351 | * @param dest destination address |
345 | * @param update source ATS information | 352 | * @param update source ATS information |
346 | * @param update_count number of ATS information | 353 | * @param update_count number of ATS information in @a update |
347 | * @param delta_dest ats performance information which were updated | 354 | * @param delta_dest ats performance information which were updated |
348 | * including previous value | 355 | * including previous value |
349 | * @param delta_count number of ATS information in the delta | 356 | * @param delta_count number of ATS information in the @a delta_dest |
350 | * @return GNUNET_YES if address was address updated, GNUNET_NO otherwise | 357 | * @return #GNUNET_YES if address was address updated, GNUNET_NO otherwise |
351 | */ | 358 | */ |
352 | static unsigned int | 359 | static unsigned int |
353 | disassemble_ats_information (struct ATS_Address *dest, | 360 | disassemble_ats_information (struct ATS_Address *dest, |
354 | const struct GNUNET_ATS_Information *update, uint32_t update_count, | 361 | const struct GNUNET_ATS_Information *update, |
355 | struct GNUNET_ATS_Information **delta_dest, uint32_t *delta_count) | 362 | uint32_t update_count, |
363 | struct GNUNET_ATS_Information **delta_dest, | ||
364 | uint32_t *delta_count) | ||
356 | { | 365 | { |
357 | |||
358 | int c1; | 366 | int c1; |
359 | int c2; | 367 | int c2; |
360 | int found; | 368 | int found; |
361 | int change; | 369 | int change; |
362 | |||
363 | struct GNUNET_ATS_Information add_atsi[update_count]; | 370 | struct GNUNET_ATS_Information add_atsi[update_count]; |
364 | struct GNUNET_ATS_Information delta_atsi[update_count]; | 371 | struct GNUNET_ATS_Information delta_atsi[update_count]; |
365 | struct GNUNET_ATS_Information *tmp_atsi; | 372 | struct GNUNET_ATS_Information *tmp_atsi; |
@@ -452,6 +459,7 @@ disassemble_ats_information (struct ATS_Address *dest, | |||
452 | return change; | 459 | return change; |
453 | } | 460 | } |
454 | 461 | ||
462 | |||
455 | /** | 463 | /** |
456 | * Free the given address | 464 | * Free the given address |
457 | * | 465 | * |
@@ -504,10 +512,13 @@ create_address (const struct GNUNET_PeerIdentity *peer, | |||
504 | for (c2 = 0; c2 < GAS_normalization_queue_length; c2++) | 512 | for (c2 = 0; c2 < GAS_normalization_queue_length; c2++) |
505 | aa->atsin[c1].atsi_abs[c2] = GNUNET_ATS_VALUE_UNDEFINED; | 513 | aa->atsin[c1].atsi_abs[c2] = GNUNET_ATS_VALUE_UNDEFINED; |
506 | } | 514 | } |
507 | |||
508 | return aa; | 515 | return aa; |
509 | } | 516 | } |
510 | 517 | ||
518 | |||
519 | /** | ||
520 | * Closure for #compare_address_it() | ||
521 | */ | ||
511 | struct CompareAddressContext | 522 | struct CompareAddressContext |
512 | { | 523 | { |
513 | const struct ATS_Address *search; | 524 | const struct ATS_Address *search; |
@@ -599,6 +610,7 @@ compare_address_it (void *cls, | |||
599 | return GNUNET_NO; /* Stop iteration since we have an exact address */ | 610 | return GNUNET_NO; /* Stop iteration since we have an exact address */ |
600 | } | 611 | } |
601 | 612 | ||
613 | |||
602 | /** | 614 | /** |
603 | * Find an existing equivalent address record. | 615 | * Find an existing equivalent address record. |
604 | * Compares by peer identity and network address OR by session ID | 616 | * Compares by peer identity and network address OR by session ID |
@@ -611,7 +623,8 @@ compare_address_it (void *cls, | |||
611 | */ | 623 | */ |
612 | struct ATS_Address * | 624 | struct ATS_Address * |
613 | find_equivalent_address (struct GAS_Addresses_Handle *handle, | 625 | find_equivalent_address (struct GAS_Addresses_Handle *handle, |
614 | const struct GNUNET_PeerIdentity *peer, const struct ATS_Address *addr) | 626 | const struct GNUNET_PeerIdentity *peer, |
627 | const struct ATS_Address *addr) | ||
615 | { | 628 | { |
616 | struct CompareAddressContext cac; | 629 | struct CompareAddressContext cac; |
617 | 630 | ||
@@ -643,29 +656,34 @@ find_equivalent_address (struct GAS_Addresses_Handle *handle, | |||
643 | 656 | ||
644 | static struct ATS_Address * | 657 | static struct ATS_Address * |
645 | find_exact_address (struct GAS_Addresses_Handle *handle, | 658 | find_exact_address (struct GAS_Addresses_Handle *handle, |
646 | const struct GNUNET_PeerIdentity *peer, | 659 | const struct GNUNET_PeerIdentity *peer, |
647 | const char *plugin_name, | 660 | const char *plugin_name, |
648 | const void *plugin_addr, | 661 | const void *plugin_addr, |
649 | size_t plugin_addr_len, | 662 | size_t plugin_addr_len, |
650 | uint32_t local_address_info, | 663 | uint32_t local_address_info, |
651 | uint32_t session_id) | 664 | uint32_t session_id) |
652 | { | 665 | { |
653 | struct ATS_Address *aa; | 666 | struct ATS_Address *aa; |
654 | struct ATS_Address *ea; | 667 | struct ATS_Address *ea; |
655 | 668 | ||
656 | aa = create_address (peer, plugin_name, plugin_addr, plugin_addr_len, | 669 | aa = create_address (peer, |
657 | local_address_info, session_id); | 670 | plugin_name, |
671 | plugin_addr, | ||
672 | plugin_addr_len, | ||
673 | local_address_info, | ||
674 | session_id); | ||
658 | 675 | ||
659 | /* Get existing address or address with session == 0 */ | 676 | /* Get existing address or address with session == 0 */ |
660 | ea = find_equivalent_address (handle, peer, aa); | 677 | ea = find_equivalent_address (handle, peer, aa); |
661 | free_address (aa); | 678 | free_address (aa); |
662 | if (ea == NULL ) | 679 | if (ea == NULL) |
663 | return NULL ; | 680 | return NULL; |
664 | else if (ea->session_id != session_id) | 681 | else if (ea->session_id != session_id) |
665 | return NULL ; | 682 | return NULL; |
666 | return ea; | 683 | return ea; |
667 | } | 684 | } |
668 | 685 | ||
686 | |||
669 | /** | 687 | /** |
670 | * Function allowing the solver to obtain normalized preference | 688 | * Function allowing the solver to obtain normalized preference |
671 | * values from solver | 689 | * values from solver |
@@ -675,11 +693,13 @@ find_exact_address (struct GAS_Addresses_Handle *handle, | |||
675 | * @return array of double values with |GNUNET_ATS_PreferenceCount| elements | 693 | * @return array of double values with |GNUNET_ATS_PreferenceCount| elements |
676 | */ | 694 | */ |
677 | const double * | 695 | const double * |
678 | get_preferences_cb (void *cls, const struct GNUNET_PeerIdentity *id) | 696 | get_preferences_cb (void *cls, |
697 | const struct GNUNET_PeerIdentity *id) | ||
679 | { | 698 | { |
680 | return GAS_normalization_get_preferences_by_peer (id); | 699 | return GAS_normalization_get_preferences_by_peer (id); |
681 | } | 700 | } |
682 | 701 | ||
702 | |||
683 | /** | 703 | /** |
684 | * Function allowing the solver to obtain normalized property | 704 | * Function allowing the solver to obtain normalized property |
685 | * values for an address from solver | 705 | * values for an address from solver |
@@ -694,6 +714,7 @@ get_property_cb (void *cls, const struct ATS_Address *address) | |||
694 | return GAS_normalization_get_properties ((struct ATS_Address *) address); | 714 | return GAS_normalization_get_properties ((struct ATS_Address *) address); |
695 | } | 715 | } |
696 | 716 | ||
717 | |||
697 | /** | 718 | /** |
698 | * Extract an ATS performance info from an address | 719 | * Extract an ATS performance info from an address |
699 | * | 720 | * |
@@ -718,6 +739,7 @@ get_performance_info (struct ATS_Address *address, uint32_t type) | |||
718 | return GNUNET_ATS_VALUE_UNDEFINED; | 739 | return GNUNET_ATS_VALUE_UNDEFINED; |
719 | } | 740 | } |
720 | 741 | ||
742 | |||
721 | /** | 743 | /** |
722 | * Add a new address for a peer. | 744 | * Add a new address for a peer. |
723 | * | 745 | * |
@@ -725,22 +747,22 @@ get_performance_info (struct ATS_Address *address, uint32_t type) | |||
725 | * @param peer peer | 747 | * @param peer peer |
726 | * @param plugin_name transport plugin name | 748 | * @param plugin_name transport plugin name |
727 | * @param plugin_addr plugin address | 749 | * @param plugin_addr plugin address |
728 | * @param plugin_addr_len length of the plugin address | 750 | * @param plugin_addr_len length of the plugin address in @a plugin_addr |
729 | * @param local_address_info the local address for the address | 751 | * @param local_address_info the local address for the address |
730 | * @param session_id session id, can be 0 | 752 | * @param session_id session id, can be 0 |
731 | * @param atsi performance information for this address | 753 | * @param atsi performance information for this address |
732 | * @param atsi_count number of performance information contained | 754 | * @param atsi_count number of performance information contained in @a atsi |
733 | */ | 755 | */ |
734 | void | 756 | void |
735 | GAS_addresses_add (struct GAS_Addresses_Handle *handle, | 757 | GAS_addresses_add (struct GAS_Addresses_Handle *handle, |
736 | const struct GNUNET_PeerIdentity *peer, | 758 | const struct GNUNET_PeerIdentity *peer, |
737 | const char *plugin_name, | 759 | const char *plugin_name, |
738 | const void *plugin_addr, | 760 | const void *plugin_addr, |
739 | size_t plugin_addr_len, | 761 | size_t plugin_addr_len, |
740 | uint32_t local_address_info, | 762 | uint32_t local_address_info, |
741 | uint32_t session_id, | 763 | uint32_t session_id, |
742 | const struct GNUNET_ATS_Information *atsi, | 764 | const struct GNUNET_ATS_Information *atsi, |
743 | uint32_t atsi_count) | 765 | uint32_t atsi_count) |
744 | { | 766 | { |
745 | struct ATS_Address *new_address; | 767 | struct ATS_Address *new_address; |
746 | struct ATS_Address *existing_address; | 768 | struct ATS_Address *existing_address; |
@@ -750,16 +772,19 @@ GAS_addresses_add (struct GAS_Addresses_Handle *handle, | |||
750 | uint32_t previous_session; | 772 | uint32_t previous_session; |
751 | int c1; | 773 | int c1; |
752 | 774 | ||
753 | GNUNET_log(GNUNET_ERROR_TYPE_DEBUG, "Received `%s' for peer `%s'\n", | 775 | GNUNET_log(GNUNET_ERROR_TYPE_DEBUG, |
754 | "ADDRESS ADD", GNUNET_i2s (peer)); | 776 | "Received `%s' for peer `%s'\n", |
777 | "ADDRESS ADD", | ||
778 | GNUNET_i2s (peer)); | ||
755 | 779 | ||
756 | if (GNUNET_NO == handle->running) | 780 | if (GNUNET_NO == handle->running) |
757 | return; | 781 | return; |
758 | 782 | ||
759 | GNUNET_assert(NULL != handle->addresses); | 783 | GNUNET_assert(NULL != handle->addresses); |
760 | 784 | ||
761 | new_address = create_address (peer, plugin_name, plugin_addr, plugin_addr_len, | 785 | new_address = create_address (peer, plugin_name, |
762 | local_address_info, session_id); | 786 | plugin_addr, plugin_addr_len, |
787 | local_address_info, session_id); | ||
763 | atsi_delta = NULL; | 788 | atsi_delta = NULL; |
764 | disassemble_ats_information (new_address, atsi, atsi_count, &atsi_delta, | 789 | disassemble_ats_information (new_address, atsi, atsi_count, &atsi_delta, |
765 | &atsi_delta_count); | 790 | &atsi_delta_count); |
@@ -775,11 +800,11 @@ GAS_addresses_add (struct GAS_Addresses_Handle *handle, | |||
775 | /* Add a new address */ | 800 | /* Add a new address */ |
776 | new_address->t_added = GNUNET_TIME_absolute_get(); | 801 | new_address->t_added = GNUNET_TIME_absolute_get(); |
777 | new_address->t_last_activity = GNUNET_TIME_absolute_get(); | 802 | new_address->t_last_activity = GNUNET_TIME_absolute_get(); |
778 | GNUNET_assert( | 803 | GNUNET_assert(GNUNET_OK == |
779 | GNUNET_OK == GNUNET_CONTAINER_multipeermap_put (handle->addresses, | 804 | GNUNET_CONTAINER_multipeermap_put (handle->addresses, |
780 | peer, | 805 | peer, |
781 | new_address, | 806 | new_address, |
782 | GNUNET_CONTAINER_MULTIHASHMAPOPTION_MULTIPLE)); | 807 | GNUNET_CONTAINER_MULTIHASHMAPOPTION_MULTIPLE)); |
783 | 808 | ||
784 | GNUNET_STATISTICS_set (handle->stat, | 809 | GNUNET_STATISTICS_set (handle->stat, |
785 | "# addresses", | 810 | "# addresses", |
@@ -899,6 +924,7 @@ GAS_addresses_add (struct GAS_Addresses_Handle *handle, | |||
899 | session_id, GNUNET_ATS_print_network_type (addr_net)); | 924 | session_id, GNUNET_ATS_print_network_type (addr_net)); |
900 | } | 925 | } |
901 | 926 | ||
927 | |||
902 | /** | 928 | /** |
903 | * Update an address with a session or performance information for a peer. | 929 | * Update an address with a session or performance information for a peer. |
904 | * | 930 | * |
@@ -913,7 +939,7 @@ GAS_addresses_add (struct GAS_Addresses_Handle *handle, | |||
913 | * @param local_address_info the local address for the address | 939 | * @param local_address_info the local address for the address |
914 | * @param session_id session id, can be 0 | 940 | * @param session_id session id, can be 0 |
915 | * @param atsi performance information for this address | 941 | * @param atsi performance information for this address |
916 | * @param atsi_count number of performance information contained | 942 | * @param atsi_count number of performance information contained in @a atsi |
917 | */ | 943 | */ |
918 | void | 944 | void |
919 | GAS_addresses_update (struct GAS_Addresses_Handle *handle, | 945 | GAS_addresses_update (struct GAS_Addresses_Handle *handle, |
@@ -1049,10 +1075,11 @@ destroy_by_session_id (void *cls, | |||
1049 | const struct ATS_Address *des = dc->aa; | 1075 | const struct ATS_Address *des = dc->aa; |
1050 | struct ATS_Address *aa = value; | 1076 | struct ATS_Address *aa = value; |
1051 | 1077 | ||
1052 | GNUNET_assert( | 1078 | GNUNET_assert(0 == |
1053 | 0 == memcmp (&aa->peer, &des->peer, sizeof(struct GNUNET_PeerIdentity))); | 1079 | memcmp (&aa->peer, |
1054 | 1080 | &des->peer, | |
1055 | if (des->session_id == 0) | 1081 | sizeof (struct GNUNET_PeerIdentity))); |
1082 | if (0 == des->session_id) | ||
1056 | { | 1083 | { |
1057 | /* Session == 0, remove full address */ | 1084 | /* Session == 0, remove full address */ |
1058 | if ((0 == strcmp (des->plugin, aa->plugin)) | 1085 | if ((0 == strcmp (des->plugin, aa->plugin)) |
@@ -1065,13 +1092,20 @@ destroy_by_session_id (void *cls, | |||
1065 | GNUNET_i2s (&aa->peer), | 1092 | GNUNET_i2s (&aa->peer), |
1066 | aa->session_id, | 1093 | aa->session_id, |
1067 | aa); | 1094 | aa); |
1068 | |||
1069 | /* Notify solver about deletion */ | 1095 | /* Notify solver about deletion */ |
1070 | GNUNET_assert (GNUNET_YES == | 1096 | GNUNET_assert (GNUNET_YES == |
1071 | GNUNET_CONTAINER_multipeermap_remove (handle->addresses, | 1097 | GNUNET_CONTAINER_multipeermap_remove (handle->addresses, |
1072 | &aa->peer, | 1098 | &aa->peer, |
1073 | aa)); | 1099 | aa)); |
1074 | handle->env.sf.s_del (handle->solver, aa, GNUNET_NO); | 1100 | handle->env.sf.s_del (handle->solver, aa, GNUNET_NO); |
1101 | GAS_performance_notify_all_clients (&aa->peer, | ||
1102 | aa->plugin, | ||
1103 | aa->addr, | ||
1104 | aa->addr_len, | ||
1105 | GNUNET_SYSERR, | ||
1106 | NULL, 0, | ||
1107 | zero_bw, | ||
1108 | zero_bw); | ||
1075 | free_address (aa); | 1109 | free_address (aa); |
1076 | dc->result = GNUNET_NO; | 1110 | dc->result = GNUNET_NO; |
1077 | return GNUNET_OK; /* Continue iteration */ | 1111 | return GNUNET_OK; /* Continue iteration */ |
@@ -1107,6 +1141,14 @@ destroy_by_session_id (void *cls, | |||
1107 | GNUNET_CONTAINER_multipeermap_remove (handle->addresses, | 1141 | GNUNET_CONTAINER_multipeermap_remove (handle->addresses, |
1108 | &aa->peer, aa)); | 1142 | &aa->peer, aa)); |
1109 | handle->env.sf.s_del (handle->solver, aa, GNUNET_NO); | 1143 | handle->env.sf.s_del (handle->solver, aa, GNUNET_NO); |
1144 | GAS_performance_notify_all_clients (&aa->peer, | ||
1145 | aa->plugin, | ||
1146 | aa->addr, | ||
1147 | aa->addr_len, | ||
1148 | GNUNET_SYSERR, | ||
1149 | NULL, 0, | ||
1150 | zero_bw, | ||
1151 | zero_bw); | ||
1110 | free_address (aa); | 1152 | free_address (aa); |
1111 | dc->result = GNUNET_NO; | 1153 | dc->result = GNUNET_NO; |
1112 | return GNUNET_OK; /* Continue iteration */ | 1154 | return GNUNET_OK; /* Continue iteration */ |
@@ -1114,14 +1156,22 @@ destroy_by_session_id (void *cls, | |||
1114 | else | 1156 | else |
1115 | { | 1157 | { |
1116 | /* Session died */ | 1158 | /* Session died */ |
1117 | GNUNET_log(GNUNET_ERROR_TYPE_INFO, | 1159 | GNUNET_log (GNUNET_ERROR_TYPE_INFO, |
1118 | "Deleting session for peer `%s': `%s' %u\n", | 1160 | "Deleting session for peer `%s': `%s' %u\n", |
1119 | GNUNET_i2s (&aa->peer), | 1161 | GNUNET_i2s (&aa->peer), |
1120 | aa->plugin, aa->session_id); | 1162 | aa->plugin, aa->session_id); |
1121 | /* Notify solver to delete session */ | 1163 | /* Notify solver to delete session */ |
1122 | handle->env.sf.s_del (handle->solver, aa, GNUNET_YES); | 1164 | handle->env.sf.s_del (handle->solver, aa, GNUNET_YES); |
1123 | aa->session_id = 0; | 1165 | aa->session_id = 0; |
1124 | aa->active = GNUNET_NO; | 1166 | aa->active = GNUNET_NO; |
1167 | GAS_performance_notify_all_clients (&aa->peer, | ||
1168 | aa->plugin, | ||
1169 | aa->addr, | ||
1170 | aa->addr_len, | ||
1171 | GNUNET_NO, | ||
1172 | NULL, 0, | ||
1173 | zero_bw, | ||
1174 | zero_bw); | ||
1125 | return GNUNET_OK; | 1175 | return GNUNET_OK; |
1126 | } | 1176 | } |
1127 | } | 1177 | } |
@@ -1136,7 +1186,7 @@ destroy_by_session_id (void *cls, | |||
1136 | * @param peer peer | 1186 | * @param peer peer |
1137 | * @param plugin_name transport plugin name | 1187 | * @param plugin_name transport plugin name |
1138 | * @param plugin_addr plugin address | 1188 | * @param plugin_addr plugin address |
1139 | * @param plugin_addr_len length of the plugin address | 1189 | * @param plugin_addr_len length of the plugin address in @a plugin_addr |
1140 | * @param local_address_info the local address for the address | 1190 | * @param local_address_info the local address for the address |
1141 | * @param session_id session id, can be 0 | 1191 | * @param session_id session id, can be 0 |
1142 | */ | 1192 | */ |
@@ -1156,11 +1206,16 @@ GAS_addresses_destroy (struct GAS_Addresses_Handle *handle, | |||
1156 | return; | 1206 | return; |
1157 | 1207 | ||
1158 | /* Get existing address */ | 1208 | /* Get existing address */ |
1159 | ea = find_exact_address (handle, peer, plugin_name, plugin_addr, | 1209 | ea = find_exact_address (handle, |
1160 | plugin_addr_len, local_address_info, session_id); | 1210 | peer, |
1161 | if (ea == NULL ) | 1211 | plugin_name, |
1212 | plugin_addr, | ||
1213 | plugin_addr_len, | ||
1214 | local_address_info, | ||
1215 | session_id); | ||
1216 | if (NULL == ea) | ||
1162 | { | 1217 | { |
1163 | GNUNET_log(GNUNET_ERROR_TYPE_DEBUG, | 1218 | GNUNET_log(GNUNET_ERROR_TYPE_INFO, |
1164 | "Tried to destroy unknown address for peer `%s' `%s' session id %u\n", | 1219 | "Tried to destroy unknown address for peer `%s' `%s' session id %u\n", |
1165 | GNUNET_i2s (peer), | 1220 | GNUNET_i2s (peer), |
1166 | plugin_name, | 1221 | plugin_name, |
@@ -1168,13 +1223,12 @@ GAS_addresses_destroy (struct GAS_Addresses_Handle *handle, | |||
1168 | return; | 1223 | return; |
1169 | } | 1224 | } |
1170 | 1225 | ||
1171 | GNUNET_log(GNUNET_ERROR_TYPE_DEBUG, | 1226 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, |
1172 | "Received `%s' for peer `%s' address %p session %u\n", "ADDRESS DESTROY", | 1227 | "Received `%s' for peer `%s' address %p session %u\n", "ADDRESS DESTROY", |
1173 | GNUNET_i2s (peer), | 1228 | GNUNET_i2s (peer), |
1174 | ea, | 1229 | ea, |
1175 | session_id); | 1230 | session_id); |
1176 | 1231 | GNUNET_break (0 < strlen (plugin_name)); | |
1177 | GNUNET_break(0 < strlen (plugin_name)); | ||
1178 | dc.handle = handle; | 1232 | dc.handle = handle; |
1179 | dc.aa = create_address (peer, | 1233 | dc.aa = create_address (peer, |
1180 | plugin_name, | 1234 | plugin_name, |
@@ -2037,8 +2091,15 @@ destroy_all_address_it (void *cls, | |||
2037 | /* Notify */ | 2091 | /* Notify */ |
2038 | handle->env.sf.s_del (handle->solver, aa, GNUNET_NO); | 2092 | handle->env.sf.s_del (handle->solver, aa, GNUNET_NO); |
2039 | /* Destroy */ | 2093 | /* Destroy */ |
2094 | GAS_performance_notify_all_clients (&aa->peer, | ||
2095 | aa->plugin, | ||
2096 | aa->addr, | ||
2097 | aa->addr_len, | ||
2098 | GNUNET_NO, | ||
2099 | NULL, 0, | ||
2100 | zero_bw, | ||
2101 | zero_bw); | ||
2040 | free_address (aa); | 2102 | free_address (aa); |
2041 | |||
2042 | return GNUNET_OK; | 2103 | return GNUNET_OK; |
2043 | } | 2104 | } |
2044 | 2105 | ||
@@ -2054,9 +2115,10 @@ GAS_addresses_destroy_all (struct GAS_Addresses_Handle *handle) | |||
2054 | if (GNUNET_NO == handle->running) | 2115 | if (GNUNET_NO == handle->running) |
2055 | return; | 2116 | return; |
2056 | 2117 | ||
2057 | GNUNET_log(GNUNET_ERROR_TYPE_INFO, "Destroying all addresses\n"); | 2118 | GNUNET_log (GNUNET_ERROR_TYPE_INFO, |
2119 | "Destroying all addresses\n"); | ||
2058 | handle->env.sf.s_bulk_start (handle->solver); | 2120 | handle->env.sf.s_bulk_start (handle->solver); |
2059 | if (handle->addresses != NULL ) | 2121 | if (NULL != handle->addresses) |
2060 | GNUNET_CONTAINER_multipeermap_iterate (handle->addresses, | 2122 | GNUNET_CONTAINER_multipeermap_iterate (handle->addresses, |
2061 | &destroy_all_address_it, | 2123 | &destroy_all_address_it, |
2062 | handle); | 2124 | handle); |
@@ -2219,24 +2281,25 @@ GAS_addresses_get_peer_info (struct GAS_Addresses_Handle *handle, | |||
2219 | void *pi_it_cls) | 2281 | void *pi_it_cls) |
2220 | { | 2282 | { |
2221 | struct PeerInfoIteratorContext pi_ctx; | 2283 | struct PeerInfoIteratorContext pi_ctx; |
2222 | struct GNUNET_BANDWIDTH_Value32NBO zero_bw; | ||
2223 | 2284 | ||
2224 | GNUNET_assert(NULL != peer); | 2285 | GNUNET_assert(NULL != peer); |
2225 | GNUNET_assert(NULL != handle->addresses); | 2286 | GNUNET_assert(NULL != handle->addresses); |
2226 | if (NULL == pi_it) | 2287 | if (NULL == pi_it) |
2227 | return; /* does not make sense without callback */ | 2288 | return; /* does not make sense without callback */ |
2228 | 2289 | ||
2229 | zero_bw = GNUNET_BANDWIDTH_value_init (0); | ||
2230 | pi_ctx.it = pi_it; | 2290 | pi_ctx.it = pi_it; |
2231 | pi_ctx.it_cls = pi_it_cls; | 2291 | pi_ctx.it_cls = pi_it_cls; |
2232 | |||
2233 | GNUNET_CONTAINER_multipeermap_get_multiple (handle->addresses, | 2292 | GNUNET_CONTAINER_multipeermap_get_multiple (handle->addresses, |
2234 | peer, | 2293 | peer, |
2235 | &peerinfo_it, &pi_ctx); | 2294 | &peerinfo_it, &pi_ctx); |
2236 | 2295 | ||
2237 | if (NULL != pi_it) | 2296 | if (NULL != pi_it) |
2238 | pi_it (pi_it_cls, NULL, NULL, NULL, 0, GNUNET_NO, NULL, 0, zero_bw, | 2297 | pi_it (pi_it_cls, |
2239 | zero_bw); | 2298 | NULL, NULL, NULL, 0, |
2299 | GNUNET_NO, | ||
2300 | NULL, 0, | ||
2301 | zero_bw, | ||
2302 | zero_bw); | ||
2240 | 2303 | ||
2241 | } | 2304 | } |
2242 | 2305 | ||
diff --git a/src/ats/gnunet-service-ats_performance.c b/src/ats/gnunet-service-ats_performance.c index 2171ba697..16b6404d6 100644 --- a/src/ats/gnunet-service-ats_performance.c +++ b/src/ats/gnunet-service-ats_performance.c | |||
@@ -144,9 +144,12 @@ GAS_performance_remove_client (struct GNUNET_SERVER_Client *client) | |||
144 | * @param plugin_name 0-termintated string specifying the transport plugin | 144 | * @param plugin_name 0-termintated string specifying the transport plugin |
145 | * @param plugin_addr binary address for the plugin to use | 145 | * @param plugin_addr binary address for the plugin to use |
146 | * @param plugin_addr_len number of bytes in plugin_addr | 146 | * @param plugin_addr_len number of bytes in plugin_addr |
147 | * @param active is this address active | 147 | * @param active #GNUNET_YES if this address is actively used |
148 | * to maintain a connection to a peer; | ||
149 | * #GNUNET_NO if the address is not actively used; | ||
150 | * #GNUNET_SYSERR if this address is no longer available for ATS | ||
148 | * @param atsi performance data for the address | 151 | * @param atsi performance data for the address |
149 | * @param atsi_count number of performance records in 'ats' | 152 | * @param atsi_count number of performance records in @a atsi |
150 | * @param bandwidth_out assigned outbound bandwidth | 153 | * @param bandwidth_out assigned outbound bandwidth |
151 | * @param bandwidth_in assigned inbound bandwidth | 154 | * @param bandwidth_in assigned inbound bandwidth |
152 | */ | 155 | */ |
@@ -189,7 +192,7 @@ GAS_performance_notify_client (struct PerformanceClient *pc, | |||
189 | msg->ats_count = htonl (atsi_count); | 192 | msg->ats_count = htonl (atsi_count); |
190 | msg->peer = *peer; | 193 | msg->peer = *peer; |
191 | msg->address_length = htons (plugin_addr_len); | 194 | msg->address_length = htons (plugin_addr_len); |
192 | msg->address_active = ntohl (active); | 195 | msg->address_active = ntohl ((uint32_t) active); |
193 | msg->plugin_name_length = htons (plugin_name_length); | 196 | msg->plugin_name_length = htons (plugin_name_length); |
194 | msg->bandwidth_out = bandwidth_out; | 197 | msg->bandwidth_out = bandwidth_out; |
195 | msg->bandwidth_in = bandwidth_in; | 198 | msg->bandwidth_in = bandwidth_in; |
@@ -213,7 +216,10 @@ GAS_performance_notify_client (struct PerformanceClient *pc, | |||
213 | * @param plugin_name 0-termintated string specifying the transport plugin | 216 | * @param plugin_name 0-termintated string specifying the transport plugin |
214 | * @param plugin_addr binary address for the plugin to use | 217 | * @param plugin_addr binary address for the plugin to use |
215 | * @param plugin_addr_len number of bytes in @a plugin_addr | 218 | * @param plugin_addr_len number of bytes in @a plugin_addr |
216 | * @param active is this address active | 219 | * @param active #GNUNET_YES if this address is actively used |
220 | * to maintain a connection to a peer; | ||
221 | * #GNUNET_NO if the address is not actively used; | ||
222 | * #GNUNET_SYSERR if this address is no longer available for ATS | ||
217 | * @param atsi performance data for the address | 223 | * @param atsi performance data for the address |
218 | * @param atsi_count number of performance records in @a atsi | 224 | * @param atsi_count number of performance records in @a atsi |
219 | * @param bandwidth_out assigned outbound bandwidth | 225 | * @param bandwidth_out assigned outbound bandwidth |
@@ -259,7 +265,7 @@ GAS_performance_notify_all_clients (const struct GNUNET_PeerIdentity *peer, | |||
259 | * @param plugin_name plugin name | 265 | * @param plugin_name plugin name |
260 | * @param plugin_addr address | 266 | * @param plugin_addr address |
261 | * @param plugin_addr_len length of @a plugin_addr | 267 | * @param plugin_addr_len length of @a plugin_addr |
262 | * @param address_active is address actively used | 268 | * @param active is address actively used |
263 | * @param atsi ats performance information | 269 | * @param atsi ats performance information |
264 | * @param atsi_count number of ats performance elements in @a atsi | 270 | * @param atsi_count number of ats performance elements in @a atsi |
265 | * @param bandwidth_out current outbound bandwidth assigned to address | 271 | * @param bandwidth_out current outbound bandwidth assigned to address |
@@ -269,8 +275,9 @@ static void | |||
269 | peerinfo_it (void *cls, | 275 | peerinfo_it (void *cls, |
270 | const struct GNUNET_PeerIdentity *id, | 276 | const struct GNUNET_PeerIdentity *id, |
271 | const char *plugin_name, | 277 | const char *plugin_name, |
272 | const void *plugin_addr, size_t plugin_addr_len, | 278 | const void *plugin_addr, |
273 | const int active, | 279 | size_t plugin_addr_len, |
280 | int active, | ||
274 | const struct GNUNET_ATS_Information *atsi, | 281 | const struct GNUNET_ATS_Information *atsi, |
275 | uint32_t atsi_count, | 282 | uint32_t atsi_count, |
276 | struct GNUNET_BANDWIDTH_Value32NBO bandwidth_out, | 283 | struct GNUNET_BANDWIDTH_Value32NBO bandwidth_out, |
@@ -360,7 +367,7 @@ transmit_req_addr (struct AddressIteration *ai, | |||
360 | const struct GNUNET_PeerIdentity *id, | 367 | const struct GNUNET_PeerIdentity *id, |
361 | const char *plugin_name, | 368 | const char *plugin_name, |
362 | const void *plugin_addr, size_t plugin_addr_len, | 369 | const void *plugin_addr, size_t plugin_addr_len, |
363 | const int active, | 370 | int active, |
364 | const struct GNUNET_ATS_Information *atsi, | 371 | const struct GNUNET_ATS_Information *atsi, |
365 | uint32_t atsi_count, | 372 | uint32_t atsi_count, |
366 | struct GNUNET_BANDWIDTH_Value32NBO bandwidth_out, | 373 | struct GNUNET_BANDWIDTH_Value32NBO bandwidth_out, |
@@ -428,15 +435,14 @@ transmit_req_addr (struct AddressIteration *ai, | |||
428 | */ | 435 | */ |
429 | static void | 436 | static void |
430 | req_addr_peerinfo_it (void *cls, | 437 | req_addr_peerinfo_it (void *cls, |
431 | const struct GNUNET_PeerIdentity *id, | 438 | const struct GNUNET_PeerIdentity *id, |
432 | const char *plugin_name, | 439 | const char *plugin_name, |
433 | const void *plugin_addr, size_t plugin_addr_len, | 440 | const void *plugin_addr, size_t plugin_addr_len, |
434 | const int active, | 441 | int active, |
435 | const struct GNUNET_ATS_Information *atsi, | 442 | const struct GNUNET_ATS_Information *atsi, |
436 | uint32_t atsi_count, | 443 | uint32_t atsi_count, |
437 | struct GNUNET_BANDWIDTH_Value32NBO | 444 | struct GNUNET_BANDWIDTH_Value32NBO bandwidth_out, |
438 | bandwidth_out, | 445 | struct GNUNET_BANDWIDTH_Value32NBO bandwidth_in) |
439 | struct GNUNET_BANDWIDTH_Value32NBO bandwidth_in) | ||
440 | { | 446 | { |
441 | struct AddressIteration *ai = cls; | 447 | struct AddressIteration *ai = cls; |
442 | 448 | ||
@@ -515,7 +521,8 @@ req_addr_peer_it (void *cls, | |||
515 | * @param message the request message | 521 | * @param message the request message |
516 | */ | 522 | */ |
517 | void | 523 | void |
518 | GAS_handle_request_address_list (void *cls, struct GNUNET_SERVER_Client *client, | 524 | GAS_handle_request_address_list (void *cls, |
525 | struct GNUNET_SERVER_Client *client, | ||
519 | const struct GNUNET_MessageHeader *message) | 526 | const struct GNUNET_MessageHeader *message) |
520 | { | 527 | { |
521 | struct PerformanceClient *pc; | 528 | struct PerformanceClient *pc; |
@@ -568,15 +575,21 @@ void | |||
568 | GAS_handle_performance_update (struct GNUNET_PeerIdentity *peer, | 575 | GAS_handle_performance_update (struct GNUNET_PeerIdentity *peer, |
569 | const char *plugin_name, | 576 | const char *plugin_name, |
570 | const void *plugin_addr, size_t plugin_addr_len, | 577 | const void *plugin_addr, size_t plugin_addr_len, |
571 | const int active, | 578 | int active, |
572 | struct GNUNET_ATS_Information *ats, | 579 | struct GNUNET_ATS_Information *ats, |
573 | uint32_t ats_count, | 580 | uint32_t ats_count, |
574 | struct GNUNET_BANDWIDTH_Value32NBO bandwidth_out, | 581 | struct GNUNET_BANDWIDTH_Value32NBO bandwidth_out, |
575 | struct GNUNET_BANDWIDTH_Value32NBO bandwidth_in) | 582 | struct GNUNET_BANDWIDTH_Value32NBO bandwidth_in) |
576 | { | 583 | { |
577 | /* Notify here */ | 584 | /* Notify here */ |
578 | GAS_performance_notify_all_clients (peer, plugin_name, plugin_addr, | 585 | GAS_performance_notify_all_clients (peer, |
579 | plugin_addr_len, active, ats, ats_count, bandwidth_out, bandwidth_in); | 586 | plugin_name, |
587 | plugin_addr, | ||
588 | plugin_addr_len, | ||
589 | active, | ||
590 | ats, ats_count, | ||
591 | bandwidth_out, | ||
592 | bandwidth_in); | ||
580 | 593 | ||
581 | #if 0 | 594 | #if 0 |
582 | struct PerformanceClient *cur; | 595 | struct PerformanceClient *cur; |
@@ -617,7 +630,8 @@ GAS_handle_performance_update (struct GNUNET_PeerIdentity *peer, | |||
617 | * @param message the request message | 630 | * @param message the request message |
618 | */ | 631 | */ |
619 | void | 632 | void |
620 | GAS_handle_reservation_request (void *cls, struct GNUNET_SERVER_Client *client, | 633 | GAS_handle_reservation_request (void *cls, |
634 | struct GNUNET_SERVER_Client *client, | ||
621 | const struct GNUNET_MessageHeader *message) | 635 | const struct GNUNET_MessageHeader *message) |
622 | { | 636 | { |
623 | const struct ReservationRequestMessage *msg = | 637 | const struct ReservationRequestMessage *msg = |
diff --git a/src/ats/gnunet-service-ats_performance.h b/src/ats/gnunet-service-ats_performance.h index da4263fe8..e5364e0e5 100644 --- a/src/ats/gnunet-service-ats_performance.h +++ b/src/ats/gnunet-service-ats_performance.h | |||
@@ -60,7 +60,7 @@ GAS_handle_performance_update (struct GNUNET_PeerIdentity *peer, | |||
60 | const char *plugin_name, | 60 | const char *plugin_name, |
61 | const void *plugin_addr, | 61 | const void *plugin_addr, |
62 | size_t plugin_addr_len, | 62 | size_t plugin_addr_len, |
63 | const int active, | 63 | int active, |
64 | struct GNUNET_ATS_Information *ats, | 64 | struct GNUNET_ATS_Information *ats, |
65 | uint32_t ats_count, | 65 | uint32_t ats_count, |
66 | struct GNUNET_BANDWIDTH_Value32NBO bandwidth_out, | 66 | struct GNUNET_BANDWIDTH_Value32NBO bandwidth_out, |
@@ -75,8 +75,11 @@ GAS_handle_performance_update (struct GNUNET_PeerIdentity *peer, | |||
75 | * @param peer peer for which this is an address suggestion | 75 | * @param peer peer for which this is an address suggestion |
76 | * @param plugin_name 0-termintated string specifying the transport plugin | 76 | * @param plugin_name 0-termintated string specifying the transport plugin |
77 | * @param plugin_addr binary address for the plugin to use | 77 | * @param plugin_addr binary address for the plugin to use |
78 | * @param plugin_addr_len number of bytes in plugin_addr | 78 | * @param plugin_addr_len number of bytes in @a plugin_addr |
79 | * @param active is this address active | 79 | * @param active #GNUNET_YES if this address is actively used |
80 | * to maintain a connection to a peer; | ||
81 | * #GNUNET_NO if the address is not actively used; | ||
82 | * #GNUNET_SYSERR if this address is no longer available for ATS | ||
80 | * @param atsi performance data for the address | 83 | * @param atsi performance data for the address |
81 | * @param atsi_count number of performance records in @a atsi | 84 | * @param atsi_count number of performance records in @a atsi |
82 | * @param bandwidth_out assigned outbound bandwidth | 85 | * @param bandwidth_out assigned outbound bandwidth |
@@ -87,7 +90,7 @@ GAS_performance_notify_all_clients (const struct GNUNET_PeerIdentity *peer, | |||
87 | const char *plugin_name, | 90 | const char *plugin_name, |
88 | const void *plugin_addr, | 91 | const void *plugin_addr, |
89 | size_t plugin_addr_len, | 92 | size_t plugin_addr_len, |
90 | const int active, | 93 | int active, |
91 | const struct GNUNET_ATS_Information *atsi, | 94 | const struct GNUNET_ATS_Information *atsi, |
92 | uint32_t atsi_count, | 95 | uint32_t atsi_count, |
93 | struct GNUNET_BANDWIDTH_Value32NBO bandwidth_out, | 96 | struct GNUNET_BANDWIDTH_Value32NBO bandwidth_out, |
@@ -141,14 +144,14 @@ GAS_handle_preference_change (void *cls, | |||
141 | */ | 144 | */ |
142 | void | 145 | void |
143 | GAS_handle_preference_feedback (void *cls, | 146 | GAS_handle_preference_feedback (void *cls, |
144 | struct GNUNET_SERVER_Client *client, | 147 | struct GNUNET_SERVER_Client *client, |
145 | const struct GNUNET_MessageHeader *message); | 148 | const struct GNUNET_MessageHeader *message); |
146 | 149 | ||
147 | 150 | ||
148 | void | 151 | void |
149 | GAS_handle_monitor (void *cls, | 152 | GAS_handle_monitor (void *cls, |
150 | struct GNUNET_SERVER_Client *client, | 153 | struct GNUNET_SERVER_Client *client, |
151 | const struct GNUNET_MessageHeader *message); | 154 | const struct GNUNET_MessageHeader *message); |
152 | 155 | ||
153 | /** | 156 | /** |
154 | * Initialize performance subsystem. | 157 | * Initialize performance subsystem. |
diff --git a/src/ats/test_ats_api_performance_list_all_addresses.c b/src/ats/test_ats_api_performance_list_all_addresses.c index 4512739e1..e846d0d43 100644 --- a/src/ats/test_ats_api_performance_list_all_addresses.c +++ b/src/ats/test_ats_api_performance_list_all_addresses.c | |||
@@ -103,6 +103,7 @@ ats_perf_cb (void *cls, | |||
103 | uint32_t ats_count) | 103 | uint32_t ats_count) |
104 | { | 104 | { |
105 | static int counter = 0; | 105 | static int counter = 0; |
106 | |||
106 | if (NULL == address) | 107 | if (NULL == address) |
107 | { | 108 | { |
108 | phal = 0; | 109 | phal = 0; |
@@ -140,7 +141,7 @@ stat_cb(void *cls, const char *subsystem, | |||
140 | "Failed to connect to performance API\n"); | 141 | "Failed to connect to performance API\n"); |
141 | GNUNET_SCHEDULER_add_now (end_badly, NULL); | 142 | GNUNET_SCHEDULER_add_now (end_badly, NULL); |
142 | } | 143 | } |
143 | phal = GNUNET_ATS_performance_list_addresses (perf_ats, NULL, GNUNET_YES, ats_perf_cb, NULL); | 144 | phal = GNUNET_ATS_performance_list_addresses (perf_ats, NULL, GNUNET_YES, &ats_perf_cb, NULL); |
144 | } | 145 | } |
145 | return GNUNET_OK; | 146 | return GNUNET_OK; |
146 | } | 147 | } |
diff --git a/src/ats/test_ats_solver_add_address.c b/src/ats/test_ats_solver_add_address.c index 4cc37e812..0c62d5197 100644 --- a/src/ats/test_ats_solver_add_address.c +++ b/src/ats/test_ats_solver_add_address.c | |||
@@ -1,10 +1,4 @@ | |||
1 | /* | 1 | /* |
2 | if (NULL == (perf_ats = GNUNET_ATS_performance_init (cfg, &ats_perf_cb, NULL))) | ||
3 | { | ||
4 | GNUNET_log (GNUNET_ERROR_TYPE_ERROR, | ||
5 | "Failed to connect to performance API\n"); | ||
6 | GNUNET_SCHEDULER_add_now (end_badly, NULL); | ||
7 | } | ||
8 | This file is part of GNUnet. | 2 | This file is part of GNUnet. |
9 | (C) 2010-2013 Christian Grothoff (and other contributing authors) | 3 | (C) 2010-2013 Christian Grothoff (and other contributing authors) |
10 | 4 | ||
diff --git a/src/ats/test_ats_solver_alternative_after_delete_address.c b/src/ats/test_ats_solver_alternative_after_delete_address.c index 8653d7db7..27f34217e 100644 --- a/src/ats/test_ats_solver_alternative_after_delete_address.c +++ b/src/ats/test_ats_solver_alternative_after_delete_address.c | |||
@@ -1,10 +1,4 @@ | |||
1 | /* | 1 | /* |
2 | if (NULL == (perf_ats = GNUNET_ATS_performance_init (cfg, &ats_perf_cb, NULL))) | ||
3 | { | ||
4 | GNUNET_log (GNUNET_ERROR_TYPE_ERROR, | ||
5 | "Failed to connect to performance API\n"); | ||
6 | GNUNET_SCHEDULER_add_now (end_badly, NULL); | ||
7 | } | ||
8 | This file is part of GNUnet. | 2 | This file is part of GNUnet. |
9 | (C) 2010-2013 Christian Grothoff (and other contributing authors) | 3 | (C) 2010-2013 Christian Grothoff (and other contributing authors) |
10 | 4 | ||
diff --git a/src/dv/gnunet-service-dv.c b/src/dv/gnunet-service-dv.c index 67db7072b..abade848f 100644 --- a/src/dv/gnunet-service-dv.c +++ b/src/dv/gnunet-service-dv.c | |||
@@ -1302,7 +1302,10 @@ handle_direct_disconnect (struct DirectNeighbor *neighbor) | |||
1302 | * | 1302 | * |
1303 | * @param cls closure | 1303 | * @param cls closure |
1304 | * @param address the address | 1304 | * @param address the address |
1305 | * @param active is this address in active use | 1305 | * @param active #GNUNET_YES if this address is actively used |
1306 | * to maintain a connection to a peer; | ||
1307 | * #GNUNET_NO if the address is not actively used; | ||
1308 | * #GNUNET_SYSERR if this address is no longer available for ATS | ||
1306 | * @param bandwidth_out assigned outbound bandwidth for the connection | 1309 | * @param bandwidth_out assigned outbound bandwidth for the connection |
1307 | * @param bandwidth_in assigned inbound bandwidth for the connection | 1310 | * @param bandwidth_in assigned inbound bandwidth for the connection |
1308 | * @param ats performance data for the address (as far as known) | 1311 | * @param ats performance data for the address (as far as known) |
@@ -1327,8 +1330,11 @@ handle_ats_update (void *cls, | |||
1327 | return; | 1330 | return; |
1328 | } | 1331 | } |
1329 | 1332 | ||
1330 | if (GNUNET_NO == active) | 1333 | if (GNUNET_YES != active) |
1334 | { | ||
1335 | // FIXME: handle disconnect/inactive case too! | ||
1331 | return; | 1336 | return; |
1337 | } | ||
1332 | distance = get_atsi_distance (ats, ats_count); | 1338 | distance = get_atsi_distance (ats, ats_count); |
1333 | network = get_atsi_network (ats, ats_count); | 1339 | network = get_atsi_network (ats, ats_count); |
1334 | GNUNET_break (GNUNET_ATS_NET_UNSPECIFIED != network); | 1340 | GNUNET_break (GNUNET_ATS_NET_UNSPECIFIED != network); |
diff --git a/src/fs/gnunet-service-fs.c b/src/fs/gnunet-service-fs.c index fd776e7b8..a9be40080 100644 --- a/src/fs/gnunet-service-fs.c +++ b/src/fs/gnunet-service-fs.c | |||
@@ -261,7 +261,7 @@ update_latencies (void *cls, | |||
261 | } | 261 | } |
262 | 262 | ||
263 | if (GNUNET_YES != active) | 263 | if (GNUNET_YES != active) |
264 | return; | 264 | return; |
265 | for (i = 0; i < ats_count; i++) | 265 | for (i = 0; i < ats_count; i++) |
266 | { | 266 | { |
267 | if (GNUNET_ATS_QUALITY_NET_DELAY != ntohl (ats[i].type)) | 267 | if (GNUNET_ATS_QUALITY_NET_DELAY != ntohl (ats[i].type)) |
diff --git a/src/include/gnunet_ats_service.h b/src/include/gnunet_ats_service.h index 18c338c2c..c19fa40b6 100644 --- a/src/include/gnunet_ats_service.h +++ b/src/include/gnunet_ats_service.h | |||
@@ -759,8 +759,10 @@ struct GNUNET_ATS_PerformanceHandle; | |||
759 | * | 759 | * |
760 | * @param cls closure | 760 | * @param cls closure |
761 | * @param address the address, NULL if ATS service was disconnected | 761 | * @param address the address, NULL if ATS service was disconnected |
762 | * @param address_active is this address actively used to maintain a connection | 762 | * @param address_active #GNUNET_YES if this address is actively used |
763 | to a peer | 763 | * to maintain a connection to a peer; |
764 | * #GNUNET_NO if the address is not actively used; | ||
765 | * #GNUNET_SYSERR if this address is no longer available for ATS | ||
764 | * @param bandwidth_out assigned outbound bandwidth for the connection | 766 | * @param bandwidth_out assigned outbound bandwidth for the connection |
765 | * @param bandwidth_in assigned inbound bandwidth for the connection | 767 | * @param bandwidth_in assigned inbound bandwidth for the connection |
766 | * @param ats performance data for the address (as far as known) | 768 | * @param ats performance data for the address (as far as known) |
@@ -768,12 +770,13 @@ struct GNUNET_ATS_PerformanceHandle; | |||
768 | */ | 770 | */ |
769 | typedef void | 771 | typedef void |
770 | (*GNUNET_ATS_AddressInformationCallback) (void *cls, | 772 | (*GNUNET_ATS_AddressInformationCallback) (void *cls, |
771 | const struct GNUNET_HELLO_Address *address, | 773 | const struct GNUNET_HELLO_Address *address, |
772 | int address_active, | 774 | int address_active, |
773 | struct GNUNET_BANDWIDTH_Value32NBO bandwidth_out, | 775 | struct GNUNET_BANDWIDTH_Value32NBO bandwidth_out, |
774 | struct GNUNET_BANDWIDTH_Value32NBO bandwidth_in, | 776 | struct GNUNET_BANDWIDTH_Value32NBO bandwidth_in, |
775 | const struct GNUNET_ATS_Information *ats, | 777 | const struct GNUNET_ATS_Information *ats, |
776 | uint32_t ats_count); | 778 | uint32_t ats_count); |
779 | |||
777 | 780 | ||
778 | /** | 781 | /** |
779 | * Handle for an address listing operation | 782 | * Handle for an address listing operation |
@@ -792,10 +795,11 @@ struct GNUNET_ATS_AddressListHandle; | |||
792 | */ | 795 | */ |
793 | struct GNUNET_ATS_PerformanceHandle * | 796 | struct GNUNET_ATS_PerformanceHandle * |
794 | GNUNET_ATS_performance_init (const struct GNUNET_CONFIGURATION_Handle *cfg, | 797 | GNUNET_ATS_performance_init (const struct GNUNET_CONFIGURATION_Handle *cfg, |
795 | GNUNET_ATS_AddressInformationCallback addr_info_cb, | 798 | GNUNET_ATS_AddressInformationCallback addr_info_cb, |
796 | void *addr_info_cb_cls); | 799 | void *addr_info_cb_cls); |
797 | 800 | ||
798 | 801 | ||
802 | |||
799 | /** | 803 | /** |
800 | * Get information about addresses known to the ATS subsystem. | 804 | * Get information about addresses known to the ATS subsystem. |
801 | * | 805 | * |
@@ -805,14 +809,15 @@ GNUNET_ATS_performance_init (const struct GNUNET_CONFIGURATION_Handle *cfg, | |||
805 | * get only address currently used | 809 | * get only address currently used |
806 | * @param infocb callback to call with the addresses, | 810 | * @param infocb callback to call with the addresses, |
807 | * will callback with address == NULL when done | 811 | * will callback with address == NULL when done |
808 | * @param infocb_cls closure for infocb | 812 | * @param infocb_cls closure for @a infocb |
809 | * @return ats performance context | 813 | * @return ats performance context |
810 | */ | 814 | */ |
811 | struct GNUNET_ATS_AddressListHandle * | 815 | struct GNUNET_ATS_AddressListHandle * |
812 | GNUNET_ATS_performance_list_addresses ( | 816 | GNUNET_ATS_performance_list_addresses (struct GNUNET_ATS_PerformanceHandle *handle, |
813 | struct GNUNET_ATS_PerformanceHandle *handle, | 817 | const struct GNUNET_PeerIdentity *peer, |
814 | const struct GNUNET_PeerIdentity *peer, int all, | 818 | int all, |
815 | GNUNET_ATS_AddressInformationCallback infocb, void *infocb_cls); | 819 | GNUNET_ATS_AddressInformationCallback infocb, |
820 | void *infocb_cls); | ||
816 | 821 | ||
817 | 822 | ||
818 | /** | 823 | /** |
@@ -845,8 +850,9 @@ GNUNET_ATS_performance_done (struct GNUNET_ATS_PerformanceHandle *ph); | |||
845 | */ | 850 | */ |
846 | typedef void | 851 | typedef void |
847 | (*GNUNET_ATS_ReservationCallback) (void *cls, | 852 | (*GNUNET_ATS_ReservationCallback) (void *cls, |
848 | const struct GNUNET_PeerIdentity * peer, int32_t amount, | 853 | const struct GNUNET_PeerIdentity * peer, |
849 | struct GNUNET_TIME_Relative res_delay); | 854 | int32_t amount, |
855 | struct GNUNET_TIME_Relative res_delay); | ||
850 | 856 | ||
851 | 857 | ||
852 | /** | 858 | /** |
diff --git a/src/testbed/gnunet-daemon-latency-logger.c b/src/testbed/gnunet-daemon-latency-logger.c index 774b5dd4d..a33d00e92 100644 --- a/src/testbed/gnunet-daemon-latency-logger.c +++ b/src/testbed/gnunet-daemon-latency-logger.c | |||
@@ -21,7 +21,7 @@ | |||
21 | /** | 21 | /** |
22 | * @file testbed/gnunet-daemon-latency-logger.c | 22 | * @file testbed/gnunet-daemon-latency-logger.c |
23 | * @brief log latency values from neighbour connections into an SQLite database | 23 | * @brief log latency values from neighbour connections into an SQLite database |
24 | * @author Sree Harsha Totakura <sreeharsha@totakura.in> | 24 | * @author Sree Harsha Totakura <sreeharsha@totakura.in> |
25 | */ | 25 | */ |
26 | 26 | ||
27 | #include "platform.h" | 27 | #include "platform.h" |
@@ -71,7 +71,7 @@ struct Entry | |||
71 | * The last known value for latency | 71 | * The last known value for latency |
72 | */ | 72 | */ |
73 | unsigned int latency; | 73 | unsigned int latency; |
74 | 74 | ||
75 | }; | 75 | }; |
76 | 76 | ||
77 | 77 | ||
@@ -119,7 +119,7 @@ free_iterator (void *cls, | |||
119 | { | 119 | { |
120 | struct Entry *e = cls; | 120 | struct Entry *e = cls; |
121 | 121 | ||
122 | GNUNET_assert (GNUNET_YES == | 122 | GNUNET_assert (GNUNET_YES == |
123 | GNUNET_CONTAINER_multipeermap_remove (map, key, e)); | 123 | GNUNET_CONTAINER_multipeermap_remove (map, key, e)); |
124 | GNUNET_free (e); | 124 | GNUNET_free (e); |
125 | return GNUNET_YES; | 125 | return GNUNET_YES; |
@@ -131,7 +131,7 @@ free_iterator (void *cls, | |||
131 | * | 131 | * |
132 | * @param cls NULL | 132 | * @param cls NULL |
133 | * @param tc task context from scheduler | 133 | * @param tc task context from scheduler |
134 | * @return | 134 | * @return |
135 | */ | 135 | */ |
136 | static void | 136 | static void |
137 | do_shutdown (void *cls, const struct GNUNET_SCHEDULER_TaskContext *tc) | 137 | do_shutdown (void *cls, const struct GNUNET_SCHEDULER_TaskContext *tc) |
@@ -148,7 +148,7 @@ do_shutdown (void *cls, const struct GNUNET_SCHEDULER_TaskContext *tc) | |||
148 | db = NULL; | 148 | db = NULL; |
149 | if (NULL != map) | 149 | if (NULL != map) |
150 | { | 150 | { |
151 | GNUNET_assert (GNUNET_SYSERR != | 151 | GNUNET_assert (GNUNET_SYSERR != |
152 | GNUNET_CONTAINER_multipeermap_iterate (map, free_iterator, NULL)); | 152 | GNUNET_CONTAINER_multipeermap_iterate (map, free_iterator, NULL)); |
153 | GNUNET_CONTAINER_multipeermap_destroy (map); | 153 | GNUNET_CONTAINER_multipeermap_destroy (map); |
154 | map = NULL; | 154 | map = NULL; |
@@ -160,8 +160,10 @@ do_shutdown (void *cls, const struct GNUNET_SCHEDULER_TaskContext *tc) | |||
160 | * | 160 | * |
161 | * @param cls closure | 161 | * @param cls closure |
162 | * @param address the address | 162 | * @param address the address |
163 | * @param address_active is this address actively used to maintain a connection | 163 | * @param address_active #GNUNET_YES if this address is actively used |
164 | * to a peer | 164 | * to maintain a connection to a peer; |
165 | * #GNUNET_NO if the address is not actively used; | ||
166 | * #GNUNET_SYSERR if this address is no longer available for ATS | ||
165 | * @param bandwidth_out assigned outbound bandwidth for the connection | 167 | * @param bandwidth_out assigned outbound bandwidth for the connection |
166 | * @param bandwidth_in assigned inbound bandwidth for the connection | 168 | * @param bandwidth_in assigned inbound bandwidth for the connection |
167 | * @param ats performance data for the address (as far as known) | 169 | * @param ats performance data for the address (as far as known) |
@@ -197,7 +199,7 @@ addr_info_cb (void *cls, | |||
197 | } | 199 | } |
198 | 200 | ||
199 | GNUNET_assert (NULL != db); | 201 | GNUNET_assert (NULL != db); |
200 | if (GNUNET_NO == address_active) | 202 | if (GNUNET_YES != address_active) |
201 | return; | 203 | return; |
202 | for (cnt = 0; cnt < ats_count; cnt++) | 204 | for (cnt = 0; cnt < ats_count; cnt++) |
203 | { | 205 | { |
@@ -248,13 +250,13 @@ addr_info_cb (void *cls, | |||
248 | { | 250 | { |
249 | entry = GNUNET_new (struct Entry); | 251 | entry = GNUNET_new (struct Entry); |
250 | entry->id = address->peer; | 252 | entry->id = address->peer; |
251 | GNUNET_CONTAINER_multipeermap_put (map, | 253 | GNUNET_CONTAINER_multipeermap_put (map, |
252 | &entry->id, entry, | 254 | &entry->id, entry, |
253 | GNUNET_CONTAINER_MULTIHASHMAPOPTION_UNIQUE_FAST); | 255 | GNUNET_CONTAINER_MULTIHASHMAPOPTION_UNIQUE_FAST); |
254 | } | 256 | } |
255 | entry->latency = latency; | 257 | entry->latency = latency; |
256 | return; | 258 | return; |
257 | 259 | ||
258 | err_shutdown: | 260 | err_shutdown: |
259 | GNUNET_SCHEDULER_shutdown (); | 261 | GNUNET_SCHEDULER_shutdown (); |
260 | } | 262 | } |
@@ -272,7 +274,7 @@ static void | |||
272 | run (void *cls, char *const *args, const char *cfgfile, | 274 | run (void *cls, char *const *args, const char *cfgfile, |
273 | const struct GNUNET_CONFIGURATION_Handle *c) | 275 | const struct GNUNET_CONFIGURATION_Handle *c) |
274 | { | 276 | { |
275 | const char *query_create = | 277 | const char *query_create = |
276 | "CREATE TABLE ats_info (" | 278 | "CREATE TABLE ats_info (" |
277 | "id TEXT," | 279 | "id TEXT," |
278 | "val INTEGER," | 280 | "val INTEGER," |
@@ -303,9 +305,9 @@ run (void *cls, char *const *args, const char *cfgfile, | |||
303 | DEBUG ("SQLite Error: %d. Perhaps the database `%s' already exits.\n", | 305 | DEBUG ("SQLite Error: %d. Perhaps the database `%s' already exits.\n", |
304 | sqlite3_errcode (db), dbfile); | 306 | sqlite3_errcode (db), dbfile); |
305 | DEBUG ("Opened database %s\n", dbfile); | 307 | DEBUG ("Opened database %s\n", dbfile); |
306 | GNUNET_free (dbfile); | 308 | GNUNET_free (dbfile); |
307 | dbfile = NULL; | 309 | dbfile = NULL; |
308 | ats = GNUNET_ATS_performance_init (c, addr_info_cb, NULL); | 310 | ats = GNUNET_ATS_performance_init (c, &addr_info_cb, NULL); |
309 | map = GNUNET_CONTAINER_multipeermap_create (30, GNUNET_YES); | 311 | map = GNUNET_CONTAINER_multipeermap_create (30, GNUNET_YES); |
310 | shutdown_task = GNUNET_SCHEDULER_add_delayed (GNUNET_TIME_UNIT_FOREVER_REL, | 312 | shutdown_task = GNUNET_SCHEDULER_add_delayed (GNUNET_TIME_UNIT_FOREVER_REL, |
311 | &do_shutdown, NULL); | 313 | &do_shutdown, NULL); |