aboutsummaryrefslogtreecommitdiff
path: root/src/ats
diff options
context:
space:
mode:
authorChristian Grothoff <christian@grothoff.org>2014-06-16 10:10:59 +0000
committerChristian Grothoff <christian@grothoff.org>2014-06-16 10:10:59 +0000
commit1eef01cd60f92a3d77061d655c0217bd6f9ffce4 (patch)
treedb83ba950eb0ece1efb9b682e379ccd1d0dd4b72 /src/ats
parentc1d89ed3cf92fa2492a5639e725aadd74742f135 (diff)
downloadgnunet-1eef01cd60f92a3d77061d655c0217bd6f9ffce4.tar.gz
gnunet-1eef01cd60f92a3d77061d655c0217bd6f9ffce4.zip
notify performance monitors about destroyed addresses (for #3406)
Diffstat (limited to 'src/ats')
-rw-r--r--src/ats/ats_api_performance.c30
-rw-r--r--src/ats/gnunet-service-ats_addresses.c203
-rw-r--r--src/ats/gnunet-service-ats_performance.c58
-rw-r--r--src/ats/gnunet-service-ats_performance.h19
-rw-r--r--src/ats/test_ats_api_performance_list_all_addresses.c3
-rw-r--r--src/ats/test_ats_solver_add_address.c6
-rw-r--r--src/ats/test_ats_solver_alternative_after_delete_address.c6
7 files changed, 198 insertions, 127 deletions
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 */
562static void 562static void
563process_ats_message (void *cls, const struct GNUNET_MessageHeader *msg) 563process_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 */
655struct GNUNET_ATS_PerformanceHandle * 656struct 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
849void 851void
850GNUNET_ATS_performance_list_addresses_cancel (struct GNUNET_ATS_AddressListHandle *handle) 852GNUNET_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 */
343const 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 */
352static unsigned int 359static unsigned int
353disassemble_ats_information (struct ATS_Address *dest, 360disassemble_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 */
511struct CompareAddressContext 522struct 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 */
612struct ATS_Address * 624struct ATS_Address *
613find_equivalent_address (struct GAS_Addresses_Handle *handle, 625find_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
644static struct ATS_Address * 657static struct ATS_Address *
645find_exact_address (struct GAS_Addresses_Handle *handle, 658find_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 */
677const double * 695const double *
678get_preferences_cb (void *cls, const struct GNUNET_PeerIdentity *id) 696get_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 */
734void 756void
735GAS_addresses_add (struct GAS_Addresses_Handle *handle, 757GAS_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 */
918void 944void
919GAS_addresses_update (struct GAS_Addresses_Handle *handle, 945GAS_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
269peerinfo_it (void *cls, 275peerinfo_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 */
429static void 436static void
430req_addr_peerinfo_it (void *cls, 437req_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 */
517void 523void
518GAS_handle_request_address_list (void *cls, struct GNUNET_SERVER_Client *client, 524GAS_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
568GAS_handle_performance_update (struct GNUNET_PeerIdentity *peer, 575GAS_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 */
619void 632void
620GAS_handle_reservation_request (void *cls, struct GNUNET_SERVER_Client *client, 633GAS_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 */
142void 145void
143GAS_handle_preference_feedback (void *cls, 146GAS_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
148void 151void
149GAS_handle_monitor (void *cls, 152GAS_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