diff options
author | Christian Grothoff <christian@grothoff.org> | 2014-06-16 09:34:22 +0000 |
---|---|---|
committer | Christian Grothoff <christian@grothoff.org> | 2014-06-16 09:34:22 +0000 |
commit | c1d89ed3cf92fa2492a5639e725aadd74742f135 (patch) | |
tree | 2c3b364f98947d36151e148eba8978f98b960da4 /src/ats | |
parent | c345e101fd271feb03c311d0ec1837fc6cf179f3 (diff) | |
download | gnunet-c1d89ed3cf92fa2492a5639e725aadd74742f135.tar.gz gnunet-c1d89ed3cf92fa2492a5639e725aadd74742f135.zip |
do not use session_id in GAS_performance_notify_all_clients, needs to be 'active'; also indentation/doxygen
Diffstat (limited to 'src/ats')
-rw-r--r-- | src/ats/gnunet-service-ats_addresses.c | 317 | ||||
-rw-r--r-- | src/ats/gnunet-service-ats_addresses.h | 5 | ||||
-rw-r--r-- | src/ats/gnunet-service-ats_performance.c | 191 | ||||
-rw-r--r-- | src/ats/gnunet-service-ats_performance.h | 40 | ||||
-rw-r--r-- | src/ats/gnunet-service-ats_scheduling.h | 4 |
5 files changed, 346 insertions, 211 deletions
diff --git a/src/ats/gnunet-service-ats_addresses.c b/src/ats/gnunet-service-ats_addresses.c index 98340e86a..ca8afecd9 100644 --- a/src/ats/gnunet-service-ats_addresses.c +++ b/src/ats/gnunet-service-ats_addresses.c | |||
@@ -465,6 +465,7 @@ free_address (struct ATS_Address *addr) | |||
465 | GNUNET_free(addr); | 465 | GNUNET_free(addr); |
466 | } | 466 | } |
467 | 467 | ||
468 | |||
468 | /** | 469 | /** |
469 | * Create a ATS_address with the given information | 470 | * Create a ATS_address with the given information |
470 | * | 471 | * |
@@ -473,16 +474,16 @@ free_address (struct ATS_Address *addr) | |||
473 | * @param plugin_addr address | 474 | * @param plugin_addr address |
474 | * @param plugin_addr_len address length | 475 | * @param plugin_addr_len address length |
475 | * @param local_address_info additional local info for the address | 476 | * @param local_address_info additional local info for the address |
476 | * @param session_id session | 477 | * @param session_id session identifier, can be 0 |
477 | * @return the ATS_Address | 478 | * @return the ATS_Address |
478 | */ | 479 | */ |
479 | static struct ATS_Address * | 480 | static struct ATS_Address * |
480 | create_address (const struct GNUNET_PeerIdentity *peer, | 481 | create_address (const struct GNUNET_PeerIdentity *peer, |
481 | const char *plugin_name, | 482 | const char *plugin_name, |
482 | const void *plugin_addr, | 483 | const void *plugin_addr, |
483 | size_t plugin_addr_len, | 484 | size_t plugin_addr_len, |
484 | uint32_t local_address_info, | 485 | uint32_t local_address_info, |
485 | uint32_t session_id) | 486 | uint32_t session_id) |
486 | { | 487 | { |
487 | struct ATS_Address *aa = NULL; | 488 | struct ATS_Address *aa = NULL; |
488 | int c1; | 489 | int c1; |
@@ -496,13 +497,6 @@ create_address (const struct GNUNET_PeerIdentity *peer, | |||
496 | aa->plugin = GNUNET_strdup (plugin_name); | 497 | aa->plugin = GNUNET_strdup (plugin_name); |
497 | aa->session_id = session_id; | 498 | aa->session_id = session_id; |
498 | aa->local_address_info = local_address_info; | 499 | aa->local_address_info = local_address_info; |
499 | aa->active = GNUNET_NO; | ||
500 | aa->used = GNUNET_NO; | ||
501 | aa->solver_information = NULL; | ||
502 | aa->atsi = NULL; | ||
503 | aa->atsi_count = 0; | ||
504 | aa->assigned_bw_in = GNUNET_BANDWIDTH_value_init (0); | ||
505 | aa->assigned_bw_out = GNUNET_BANDWIDTH_value_init (0); | ||
506 | 500 | ||
507 | for (c1 = 0; c1 < GNUNET_ATS_QualityPropertiesCount; c1++) | 501 | for (c1 = 0; c1 < GNUNET_ATS_QualityPropertiesCount; c1++) |
508 | { | 502 | { |
@@ -787,29 +781,39 @@ GAS_addresses_add (struct GAS_Addresses_Handle *handle, | |||
787 | new_address, | 781 | new_address, |
788 | GNUNET_CONTAINER_MULTIHASHMAPOPTION_MULTIPLE)); | 782 | GNUNET_CONTAINER_MULTIHASHMAPOPTION_MULTIPLE)); |
789 | 783 | ||
790 | GNUNET_STATISTICS_set (handle->stat, "# addresses", | 784 | GNUNET_STATISTICS_set (handle->stat, |
791 | GNUNET_CONTAINER_multipeermap_size (handle->addresses), GNUNET_NO); | 785 | "# addresses", |
786 | GNUNET_CONTAINER_multipeermap_size (handle->addresses), | ||
787 | GNUNET_NO); | ||
792 | 788 | ||
793 | GNUNET_log(GNUNET_ERROR_TYPE_INFO, | 789 | GNUNET_log (GNUNET_ERROR_TYPE_INFO, |
794 | "Adding new address %p for peer `%s', length %u, session id %u, %s\n", | 790 | "Adding new address %p for peer `%s', length %u, session id %u, %s\n", |
795 | new_address, | 791 | new_address, |
796 | GNUNET_i2s (peer), | 792 | GNUNET_i2s (peer), |
797 | plugin_addr_len, session_id, | 793 | plugin_addr_len, |
798 | GNUNET_ATS_print_network_type (addr_net)); | 794 | session_id, |
795 | GNUNET_ATS_print_network_type (addr_net)); | ||
799 | 796 | ||
800 | /* Tell solver about new address */ | 797 | /* Tell solver about new address */ |
801 | handle->env.sf.s_add (handle->solver, new_address, addr_net); | 798 | handle->env.sf.s_add (handle->solver, new_address, addr_net); |
802 | 799 | ||
803 | handle->env.sf.s_bulk_start (handle->solver); | 800 | handle->env.sf.s_bulk_start (handle->solver); |
804 | GAS_normalization_normalize_property (handle->addresses, new_address, atsi, | 801 | GAS_normalization_normalize_property (handle->addresses, |
805 | atsi_count); | 802 | new_address, |
803 | atsi, | ||
804 | atsi_count); | ||
806 | handle->env.sf.s_bulk_stop (handle->solver); | 805 | handle->env.sf.s_bulk_stop (handle->solver); |
807 | 806 | ||
808 | /* Notify performance clients about new address */ | 807 | /* Notify performance clients about new address */ |
809 | GAS_performance_notify_all_clients (&new_address->peer, new_address->plugin, | 808 | GAS_performance_notify_all_clients (&new_address->peer, |
810 | new_address->addr, new_address->addr_len, new_address->session_id, | 809 | new_address->plugin, |
811 | new_address->atsi, new_address->atsi_count, | 810 | new_address->addr, |
812 | new_address->assigned_bw_out, new_address->assigned_bw_in); | 811 | new_address->addr_len, |
812 | new_address->active, | ||
813 | new_address->atsi, | ||
814 | new_address->atsi_count, | ||
815 | new_address->assigned_bw_out, | ||
816 | new_address->assigned_bw_in); | ||
813 | return; | 817 | return; |
814 | } | 818 | } |
815 | 819 | ||
@@ -845,10 +849,14 @@ GAS_addresses_add (struct GAS_Addresses_Handle *handle, | |||
845 | { | 849 | { |
846 | /* Notify performance clients about properties */ | 850 | /* Notify performance clients about properties */ |
847 | GAS_performance_notify_all_clients (&existing_address->peer, | 851 | GAS_performance_notify_all_clients (&existing_address->peer, |
848 | existing_address->plugin, existing_address->addr, | 852 | existing_address->plugin, |
849 | existing_address->addr_len, existing_address->session_id, | 853 | existing_address->addr, |
850 | existing_address->atsi, existing_address->atsi_count, | 854 | existing_address->addr_len, |
851 | existing_address->assigned_bw_out, existing_address->assigned_bw_in); | 855 | existing_address->active, |
856 | existing_address->atsi, | ||
857 | existing_address->atsi_count, | ||
858 | existing_address->assigned_bw_out, | ||
859 | existing_address->assigned_bw_in); | ||
852 | 860 | ||
853 | for (c1 = 0; c1 < atsi_delta_count; c1++) | 861 | for (c1 = 0; c1 < atsi_delta_count; c1++) |
854 | { | 862 | { |
@@ -909,14 +917,14 @@ GAS_addresses_add (struct GAS_Addresses_Handle *handle, | |||
909 | */ | 917 | */ |
910 | void | 918 | void |
911 | GAS_addresses_update (struct GAS_Addresses_Handle *handle, | 919 | GAS_addresses_update (struct GAS_Addresses_Handle *handle, |
912 | const struct GNUNET_PeerIdentity *peer, | 920 | const struct GNUNET_PeerIdentity *peer, |
913 | const char *plugin_name, | 921 | const char *plugin_name, |
914 | const void *plugin_addr, | 922 | const void *plugin_addr, |
915 | size_t plugin_addr_len, | 923 | size_t plugin_addr_len, |
916 | uint32_t local_address_info, | 924 | uint32_t local_address_info, |
917 | uint32_t session_id, | 925 | uint32_t session_id, |
918 | const struct GNUNET_ATS_Information *atsi, | 926 | const struct GNUNET_ATS_Information *atsi, |
919 | uint32_t atsi_count) | 927 | uint32_t atsi_count) |
920 | { | 928 | { |
921 | struct ATS_Address *aa; | 929 | struct ATS_Address *aa; |
922 | struct GNUNET_ATS_Information *atsi_delta; | 930 | struct GNUNET_ATS_Information *atsi_delta; |
@@ -937,8 +945,10 @@ GAS_addresses_update (struct GAS_Addresses_Handle *handle, | |||
937 | if (NULL == aa->solver_information) | 945 | if (NULL == aa->solver_information) |
938 | return; | 946 | return; |
939 | 947 | ||
940 | GNUNET_log(GNUNET_ERROR_TYPE_DEBUG, "Received `%s' for peer `%s' address \n", | 948 | GNUNET_log(GNUNET_ERROR_TYPE_DEBUG, |
941 | "ADDRESS UPDATE", GNUNET_i2s (peer), aa); | 949 | "Received `%s' for peer `%s' address \n", |
950 | "ADDRESS UPDATE", | ||
951 | GNUNET_i2s (peer), aa); | ||
942 | 952 | ||
943 | /* Update address */ | 953 | /* Update address */ |
944 | aa->t_last_activity = GNUNET_TIME_absolute_get(); | 954 | aa->t_last_activity = GNUNET_TIME_absolute_get(); |
@@ -947,15 +957,19 @@ GAS_addresses_update (struct GAS_Addresses_Handle *handle, | |||
947 | /* Session changed */ | 957 | /* Session changed */ |
948 | prev_session = aa->session_id; | 958 | prev_session = aa->session_id; |
949 | aa->session_id = session_id; | 959 | aa->session_id = session_id; |
950 | handle->env.sf.s_address_update_session (handle->solver, aa, prev_session, | 960 | handle->env.sf.s_address_update_session (handle->solver, |
951 | aa->session_id); | 961 | aa, |
962 | prev_session, | ||
963 | aa->session_id); | ||
952 | } | 964 | } |
953 | 965 | ||
954 | atsi_delta = NULL; | 966 | atsi_delta = NULL; |
955 | atsi_delta_count = 0; | 967 | atsi_delta_count = 0; |
956 | if (GNUNET_YES | 968 | if (GNUNET_YES == |
957 | == disassemble_ats_information (aa, atsi, atsi_count, &atsi_delta, | 969 | disassemble_ats_information (aa, atsi, |
958 | &atsi_delta_count)) | 970 | atsi_count, |
971 | &atsi_delta, | ||
972 | &atsi_delta_count)) | ||
959 | { | 973 | { |
960 | /* ATS properties changed */ | 974 | /* ATS properties changed */ |
961 | for (c1 = 0; c1 < atsi_delta_count; c1++) | 975 | for (c1 = 0; c1 < atsi_delta_count; c1++) |
@@ -970,31 +984,49 @@ GAS_addresses_update (struct GAS_Addresses_Handle *handle, | |||
970 | } | 984 | } |
971 | 985 | ||
972 | /* Notify performance clients about updated address */ | 986 | /* Notify performance clients about updated address */ |
973 | GAS_performance_notify_all_clients (&aa->peer, aa->plugin, aa->addr, | 987 | GAS_performance_notify_all_clients (&aa->peer, |
974 | aa->addr_len, aa->session_id, aa->atsi, aa->atsi_count, | 988 | aa->plugin, |
975 | aa->assigned_bw_out, aa->assigned_bw_in); | 989 | aa->addr, |
976 | 990 | aa->addr_len, | |
991 | aa->active, | ||
992 | aa->atsi, | ||
993 | aa->atsi_count, | ||
994 | aa->assigned_bw_out, | ||
995 | aa->assigned_bw_in); | ||
977 | handle->env.sf.s_bulk_start (handle->solver); | 996 | handle->env.sf.s_bulk_start (handle->solver); |
978 | GAS_normalization_normalize_property (handle->addresses, aa, atsi, | 997 | GAS_normalization_normalize_property (handle->addresses, |
979 | atsi_count); | 998 | aa, |
999 | atsi, | ||
1000 | atsi_count); | ||
980 | handle->env.sf.s_bulk_stop (handle->solver); | 1001 | handle->env.sf.s_bulk_stop (handle->solver); |
981 | } | 1002 | } |
982 | GNUNET_free_non_null(atsi_delta); | 1003 | GNUNET_free_non_null (atsi_delta); |
983 | } | 1004 | } |
984 | 1005 | ||
1006 | |||
1007 | /** | ||
1008 | * Closure for #destroy_by_session_id(). | ||
1009 | */ | ||
985 | struct DestroyContext | 1010 | struct DestroyContext |
986 | { | 1011 | { |
1012 | /** | ||
1013 | * FIXME. | ||
1014 | */ | ||
987 | struct ATS_Address *aa; | 1015 | struct ATS_Address *aa; |
988 | 1016 | ||
1017 | /** | ||
1018 | * FIXME. | ||
1019 | */ | ||
989 | struct GAS_Addresses_Handle *handle; | 1020 | struct GAS_Addresses_Handle *handle; |
990 | 1021 | ||
991 | /** | 1022 | /** |
992 | * GNUNET_NO : full address | 1023 | * #GNUNET_NO : full address |
993 | * GNUNET_YES : just session | 1024 | * #GNUNET_YES : just session |
994 | */ | 1025 | */ |
995 | int result; | 1026 | int result; |
996 | }; | 1027 | }; |
997 | 1028 | ||
1029 | |||
998 | /** | 1030 | /** |
999 | * Delete an address | 1031 | * Delete an address |
1000 | * | 1032 | * |
@@ -1004,8 +1036,8 @@ struct DestroyContext | |||
1004 | * | 1036 | * |
1005 | * @param cls unused | 1037 | * @param cls unused |
1006 | * @param key unused | 1038 | * @param key unused |
1007 | * @param value the 'struct ATS_Address' | 1039 | * @param value the `struct ATS_Address *` |
1008 | * @return GNUNET_OK (continue to iterate) | 1040 | * @return #GNUNET_OK (continue to iterate) |
1009 | */ | 1041 | */ |
1010 | static int | 1042 | static int |
1011 | destroy_by_session_id (void *cls, | 1043 | destroy_by_session_id (void *cls, |
@@ -1028,15 +1060,17 @@ destroy_by_session_id (void *cls, | |||
1028 | && (0 == memcmp (des->addr, aa->addr, aa->addr_len))) | 1060 | && (0 == memcmp (des->addr, aa->addr, aa->addr_len))) |
1029 | { | 1061 | { |
1030 | 1062 | ||
1031 | GNUNET_log(GNUNET_ERROR_TYPE_INFO, | 1063 | GNUNET_log (GNUNET_ERROR_TYPE_INFO, |
1032 | "Deleting full address for peer `%s' session %u %p\n", | 1064 | "Deleting full address for peer `%s' session %u %p\n", |
1033 | GNUNET_i2s (&aa->peer), aa->session_id, aa); | 1065 | GNUNET_i2s (&aa->peer), |
1066 | aa->session_id, | ||
1067 | aa); | ||
1034 | 1068 | ||
1035 | /* Notify solver about deletion */ | 1069 | /* Notify solver about deletion */ |
1036 | GNUNET_assert( | 1070 | GNUNET_assert (GNUNET_YES == |
1037 | GNUNET_YES == GNUNET_CONTAINER_multipeermap_remove (handle->addresses, | 1071 | GNUNET_CONTAINER_multipeermap_remove (handle->addresses, |
1038 | &aa->peer, | 1072 | &aa->peer, |
1039 | aa)); | 1073 | aa)); |
1040 | handle->env.sf.s_del (handle->solver, aa, GNUNET_NO); | 1074 | handle->env.sf.s_del (handle->solver, aa, GNUNET_NO); |
1041 | free_address (aa); | 1075 | free_address (aa); |
1042 | dc->result = GNUNET_NO; | 1076 | dc->result = GNUNET_NO; |
@@ -1051,24 +1085,27 @@ destroy_by_session_id (void *cls, | |||
1051 | 1085 | ||
1052 | if ((aa->session_id != 0) && (0 != strcmp (des->plugin, aa->plugin))) | 1086 | if ((aa->session_id != 0) && (0 != strcmp (des->plugin, aa->plugin))) |
1053 | { | 1087 | { |
1054 | GNUNET_log(GNUNET_ERROR_TYPE_ERROR, | 1088 | GNUNET_log (GNUNET_ERROR_TYPE_ERROR, |
1055 | "Different plugins during removal: `%s' vs `%s' \n", des->plugin, | 1089 | "Different plugins during removal: `%s' vs `%s' \n", |
1056 | aa->plugin); | 1090 | des->plugin, |
1057 | GNUNET_break(0); | 1091 | aa->plugin); |
1092 | GNUNET_break (0); | ||
1058 | return GNUNET_OK; | 1093 | return GNUNET_OK; |
1059 | } | 1094 | } |
1060 | if (GNUNET_HELLO_ADDRESS_INFO_INBOUND == | 1095 | if (GNUNET_HELLO_ADDRESS_INFO_INBOUND == |
1061 | (aa->local_address_info && GNUNET_HELLO_ADDRESS_INFO_INBOUND)) | 1096 | (aa->local_address_info && GNUNET_HELLO_ADDRESS_INFO_INBOUND)) |
1062 | { | 1097 | { |
1063 | /* Inbound connection died, delete full address */ | 1098 | /* Inbound connection died, delete full address */ |
1064 | GNUNET_log(GNUNET_ERROR_TYPE_INFO, | 1099 | GNUNET_log (GNUNET_ERROR_TYPE_INFO, |
1065 | "Deleting inbound address for peer `%s': `%s' session %u\n", | 1100 | "Deleting inbound address for peer `%s': `%s' session %u\n", |
1066 | GNUNET_i2s (&aa->peer), aa->plugin, aa->session_id); | 1101 | GNUNET_i2s (&aa->peer), |
1102 | aa->plugin, | ||
1103 | aa->session_id); | ||
1067 | 1104 | ||
1068 | /* Notify solver about deletion */ | 1105 | /* Notify solver about deletion */ |
1069 | GNUNET_assert( | 1106 | GNUNET_assert(GNUNET_YES == |
1070 | GNUNET_YES == GNUNET_CONTAINER_multipeermap_remove (handle->addresses, | 1107 | GNUNET_CONTAINER_multipeermap_remove (handle->addresses, |
1071 | &aa->peer, aa)); | 1108 | &aa->peer, aa)); |
1072 | handle->env.sf.s_del (handle->solver, aa, GNUNET_NO); | 1109 | handle->env.sf.s_del (handle->solver, aa, GNUNET_NO); |
1073 | free_address (aa); | 1110 | free_address (aa); |
1074 | dc->result = GNUNET_NO; | 1111 | dc->result = GNUNET_NO; |
@@ -1078,8 +1115,9 @@ destroy_by_session_id (void *cls, | |||
1078 | { | 1115 | { |
1079 | /* Session died */ | 1116 | /* Session died */ |
1080 | GNUNET_log(GNUNET_ERROR_TYPE_INFO, | 1117 | GNUNET_log(GNUNET_ERROR_TYPE_INFO, |
1081 | "Deleting session for peer `%s': `%s' %u\n", GNUNET_i2s (&aa->peer), | 1118 | "Deleting session for peer `%s': `%s' %u\n", |
1082 | aa->plugin, aa->session_id); | 1119 | GNUNET_i2s (&aa->peer), |
1120 | aa->plugin, aa->session_id); | ||
1083 | /* Notify solver to delete session */ | 1121 | /* Notify solver to delete session */ |
1084 | handle->env.sf.s_del (handle->solver, aa, GNUNET_YES); | 1122 | handle->env.sf.s_del (handle->solver, aa, GNUNET_YES); |
1085 | aa->session_id = 0; | 1123 | aa->session_id = 0; |
@@ -1104,15 +1142,16 @@ destroy_by_session_id (void *cls, | |||
1104 | */ | 1142 | */ |
1105 | void | 1143 | void |
1106 | GAS_addresses_destroy (struct GAS_Addresses_Handle *handle, | 1144 | GAS_addresses_destroy (struct GAS_Addresses_Handle *handle, |
1107 | const struct GNUNET_PeerIdentity *peer, | 1145 | const struct GNUNET_PeerIdentity *peer, |
1108 | const char *plugin_name, | 1146 | const char *plugin_name, |
1109 | const void *plugin_addr, | 1147 | const void *plugin_addr, |
1110 | size_t plugin_addr_len, | 1148 | size_t plugin_addr_len, |
1111 | uint32_t local_address_info, | 1149 | uint32_t local_address_info, |
1112 | uint32_t session_id) | 1150 | uint32_t session_id) |
1113 | { | 1151 | { |
1114 | struct ATS_Address *ea; | 1152 | struct ATS_Address *ea; |
1115 | struct DestroyContext dc; | 1153 | struct DestroyContext dc; |
1154 | |||
1116 | if (GNUNET_NO == handle->running) | 1155 | if (GNUNET_NO == handle->running) |
1117 | return; | 1156 | return; |
1118 | 1157 | ||
@@ -1122,36 +1161,45 @@ GAS_addresses_destroy (struct GAS_Addresses_Handle *handle, | |||
1122 | if (ea == NULL ) | 1161 | if (ea == NULL ) |
1123 | { | 1162 | { |
1124 | GNUNET_log(GNUNET_ERROR_TYPE_DEBUG, | 1163 | GNUNET_log(GNUNET_ERROR_TYPE_DEBUG, |
1125 | "Tried to destroy unknown address for peer `%s' `%s' session id %u\n", | 1164 | "Tried to destroy unknown address for peer `%s' `%s' session id %u\n", |
1126 | GNUNET_i2s (peer), plugin_name, session_id); | 1165 | GNUNET_i2s (peer), |
1166 | plugin_name, | ||
1167 | session_id); | ||
1127 | return; | 1168 | return; |
1128 | } | 1169 | } |
1129 | 1170 | ||
1130 | GNUNET_log(GNUNET_ERROR_TYPE_DEBUG, | 1171 | GNUNET_log(GNUNET_ERROR_TYPE_DEBUG, |
1131 | "Received `%s' for peer `%s' address %p session %u\n", "ADDRESS DESTROY", | 1172 | "Received `%s' for peer `%s' address %p session %u\n", "ADDRESS DESTROY", |
1132 | GNUNET_i2s (peer), ea, session_id); | 1173 | GNUNET_i2s (peer), |
1174 | ea, | ||
1175 | session_id); | ||
1133 | 1176 | ||
1134 | GNUNET_break(0 < strlen (plugin_name)); | 1177 | GNUNET_break(0 < strlen (plugin_name)); |
1135 | dc.handle = handle; | 1178 | dc.handle = handle; |
1136 | dc.aa = create_address (peer, plugin_name, plugin_addr, plugin_addr_len, | 1179 | dc.aa = create_address (peer, |
1137 | local_address_info, session_id); | 1180 | plugin_name, |
1138 | 1181 | plugin_addr, | |
1182 | plugin_addr_len, | ||
1183 | local_address_info, session_id); | ||
1139 | GNUNET_CONTAINER_multipeermap_get_multiple (handle->addresses, | 1184 | GNUNET_CONTAINER_multipeermap_get_multiple (handle->addresses, |
1140 | peer, | 1185 | peer, |
1141 | &destroy_by_session_id, &dc); | 1186 | &destroy_by_session_id, &dc); |
1142 | GNUNET_STATISTICS_set (handle->stat, "# addresses", | 1187 | GNUNET_STATISTICS_set (handle->stat, |
1143 | GNUNET_CONTAINER_multipeermap_size (handle->addresses), GNUNET_NO); | 1188 | "# addresses", |
1189 | GNUNET_CONTAINER_multipeermap_size (handle->addresses), | ||
1190 | GNUNET_NO); | ||
1144 | free_address (dc.aa); | 1191 | free_address (dc.aa); |
1145 | } | 1192 | } |
1146 | 1193 | ||
1194 | |||
1147 | /** | 1195 | /** |
1148 | * Notification about active use of an address. | 1196 | * Notification about active use of an address. |
1149 | * in_use == GNUNET_YES: | 1197 | * in_use == #GNUNET_YES: |
1150 | * This address is used to maintain an active connection with a peer. | 1198 | * This address is used to maintain an active connection with a peer. |
1151 | * in_use == GNUNET_NO: | 1199 | * in_use == #GNUNET_NO: |
1152 | * This address is no longer used to maintain an active connection with a peer. | 1200 | * This address is no longer used to maintain an active connection with a peer. |
1153 | * | 1201 | * |
1154 | * Note: can only be called with in_use == GNUNET_NO if called with GNUNET_YES | 1202 | * Note: can only be called with in_use == #GNUNET_NO if called with #GNUNET_YES |
1155 | * before | 1203 | * before |
1156 | * | 1204 | * |
1157 | * @param handle the address handle to use | 1205 | * @param handle the address handle to use |
@@ -1161,52 +1209,64 @@ GAS_addresses_destroy (struct GAS_Addresses_Handle *handle, | |||
1161 | * @param plugin_addr_len length of the plugin address | 1209 | * @param plugin_addr_len length of the plugin address |
1162 | * @param local_address_info the local address for the address | 1210 | * @param local_address_info the local address for the address |
1163 | * @param session_id session id, can be 0 | 1211 | * @param session_id session id, can be 0 |
1164 | * @param in_use GNUNET_YES if GNUNET_NO | 1212 | * @param in_use #GNUNET_YES if #GNUNET_NO FIXME |
1165 | * @return GNUNET_SYSERR on failure (address unknown ...) | 1213 | * @return #GNUNET_SYSERR on failure (address unknown ...) |
1166 | */ | 1214 | */ |
1167 | int | 1215 | int |
1168 | GAS_addresses_in_use (struct GAS_Addresses_Handle *handle, | 1216 | GAS_addresses_in_use (struct GAS_Addresses_Handle *handle, |
1169 | const struct GNUNET_PeerIdentity *peer, const char *plugin_name, | 1217 | const struct GNUNET_PeerIdentity *peer, |
1170 | const void *plugin_addr, size_t plugin_addr_len, | 1218 | const char *plugin_name, |
1171 | uint32_t local_address_info, | 1219 | const void *plugin_addr, |
1172 | uint32_t session_id, | 1220 | size_t plugin_addr_len, |
1173 | int in_use) | 1221 | uint32_t local_address_info, |
1222 | uint32_t session_id, | ||
1223 | int in_use) | ||
1174 | { | 1224 | { |
1175 | struct ATS_Address *ea; | 1225 | struct ATS_Address *ea; |
1176 | GNUNET_log(GNUNET_ERROR_TYPE_DEBUG, "Received `%s' for peer `%s'\n", | ||
1177 | "ADDRESS IN USE", GNUNET_i2s (peer)); | ||
1178 | 1226 | ||
1227 | GNUNET_log(GNUNET_ERROR_TYPE_DEBUG, | ||
1228 | "Received `%s' for peer `%s'\n", | ||
1229 | "ADDRESS IN USE", | ||
1230 | GNUNET_i2s (peer)); | ||
1179 | if (GNUNET_NO == handle->running) | 1231 | if (GNUNET_NO == handle->running) |
1180 | return GNUNET_SYSERR; | 1232 | return GNUNET_SYSERR; |
1181 | 1233 | ea = find_exact_address (handle, | |
1182 | ea = find_exact_address (handle, peer, plugin_name, plugin_addr, | 1234 | peer, plugin_name, |
1183 | plugin_addr_len, local_address_info, session_id); | 1235 | plugin_addr, |
1236 | plugin_addr_len, | ||
1237 | local_address_info, | ||
1238 | session_id); | ||
1184 | if (NULL == ea) | 1239 | if (NULL == ea) |
1185 | { | 1240 | { |
1186 | GNUNET_log(GNUNET_ERROR_TYPE_WARNING, | 1241 | GNUNET_log (GNUNET_ERROR_TYPE_WARNING, |
1187 | "Trying to set unknown address `%s' `%s' `%u' to %s \n", | 1242 | "Trying to set unknown address `%s' `%s' `%u' to %s \n", |
1188 | GNUNET_i2s (peer), plugin_name, session_id, | 1243 | GNUNET_i2s (peer), |
1189 | (GNUNET_NO == in_use) ? "NO" : "YES"); | 1244 | plugin_name, |
1190 | GNUNET_break(0); | 1245 | session_id, |
1246 | (GNUNET_NO == in_use) ? "NO" : "YES"); | ||
1247 | GNUNET_break (0); | ||
1191 | return GNUNET_SYSERR; | 1248 | return GNUNET_SYSERR; |
1192 | } | 1249 | } |
1193 | if (ea->used == in_use) | 1250 | if (ea->used == in_use) |
1194 | { | 1251 | { |
1195 | GNUNET_break(0); | 1252 | GNUNET_break (0); |
1196 | GNUNET_log(GNUNET_ERROR_TYPE_WARNING, | 1253 | GNUNET_log(GNUNET_ERROR_TYPE_WARNING, |
1197 | "Address in use called multiple times for peer `%s': %s -> %s \n", | 1254 | "Address in use called multiple times for peer `%s': %s -> %s \n", |
1198 | GNUNET_i2s (peer), (GNUNET_NO == ea->used) ? "NO" : "YES", | 1255 | GNUNET_i2s (peer), |
1199 | (GNUNET_NO == in_use) ? "NO" : "YES"); | 1256 | (GNUNET_NO == ea->used) ? "NO" : "YES", |
1257 | (GNUNET_NO == in_use) ? "NO" : "YES"); | ||
1200 | return GNUNET_SYSERR; | 1258 | return GNUNET_SYSERR; |
1201 | } | 1259 | } |
1202 | |||
1203 | /* Tell solver about update */ | 1260 | /* Tell solver about update */ |
1204 | ea->used = in_use; | 1261 | ea->used = in_use; |
1205 | ea->t_last_activity = GNUNET_TIME_absolute_get(); | 1262 | ea->t_last_activity = GNUNET_TIME_absolute_get(); |
1206 | handle->env.sf.s_address_update_inuse (handle->solver, ea, ea->used); | 1263 | handle->env.sf.s_address_update_inuse (handle->solver, |
1264 | ea, | ||
1265 | ea->used); | ||
1207 | return GNUNET_OK; | 1266 | return GNUNET_OK; |
1208 | } | 1267 | } |
1209 | 1268 | ||
1269 | |||
1210 | /** | 1270 | /** |
1211 | * Cancel address suggestions for a peer | 1271 | * Cancel address suggestions for a peer |
1212 | * | 1272 | * |
@@ -1744,6 +1804,7 @@ load_quotas (const struct GNUNET_CONFIGURATION_Handle *cfg, | |||
1744 | return GNUNET_ATS_NetworkTypeCount; | 1804 | return GNUNET_ATS_NetworkTypeCount; |
1745 | } | 1805 | } |
1746 | 1806 | ||
1807 | |||
1747 | /** | 1808 | /** |
1748 | * Callback for solver to notify about assignment changes | 1809 | * Callback for solver to notify about assignment changes |
1749 | * | 1810 | * |
@@ -1751,22 +1812,28 @@ load_quotas (const struct GNUNET_CONFIGURATION_Handle *cfg, | |||
1751 | * @param address the address with changes | 1812 | * @param address the address with changes |
1752 | */ | 1813 | */ |
1753 | static void | 1814 | static void |
1754 | bandwidth_changed_cb (void *cls, struct ATS_Address *address) | 1815 | bandwidth_changed_cb (void *cls, |
1816 | struct ATS_Address *address) | ||
1755 | { | 1817 | { |
1756 | struct GAS_Addresses_Handle *handle = cls; | 1818 | struct GAS_Addresses_Handle *handle = cls; |
1757 | struct GAS_Addresses_Suggestion_Requests *cur; | 1819 | struct GAS_Addresses_Suggestion_Requests *cur; |
1758 | 1820 | ||
1759 | GNUNET_assert(handle != NULL); | 1821 | GNUNET_assert(handle != NULL); |
1760 | GNUNET_assert(address != NULL); | 1822 | GNUNET_assert(address != NULL); |
1761 | 1823 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, | |
1762 | GNUNET_log(GNUNET_ERROR_TYPE_DEBUG, | 1824 | "Bandwidth assignment changed for peer %s \n", |
1763 | "Bandwidth assignment changed for peer %s \n", | 1825 | GNUNET_i2s (&address->peer)); |
1764 | GNUNET_i2s (&address->peer)); | ||
1765 | 1826 | ||
1766 | /* Notify performance clients about changes to address */ | 1827 | /* Notify performance clients about changes to address */ |
1767 | GAS_performance_notify_all_clients (&address->peer, address->plugin, | 1828 | GAS_performance_notify_all_clients (&address->peer, |
1768 | address->addr, address->addr_len, address->session_id, address->atsi, | 1829 | address->plugin, |
1769 | address->atsi_count, address->assigned_bw_out, address->assigned_bw_in); | 1830 | address->addr, |
1831 | address->addr_len, | ||
1832 | address->active, | ||
1833 | address->atsi, | ||
1834 | address->atsi_count, | ||
1835 | address->assigned_bw_out, | ||
1836 | address->assigned_bw_in); | ||
1770 | cur = handle->pending_requests_head; | 1837 | cur = handle->pending_requests_head; |
1771 | while (NULL != cur) | 1838 | while (NULL != cur) |
1772 | { | 1839 | { |
diff --git a/src/ats/gnunet-service-ats_addresses.h b/src/ats/gnunet-service-ats_addresses.h index 7ed609eaf..d6e8b0e10 100644 --- a/src/ats/gnunet-service-ats_addresses.h +++ b/src/ats/gnunet-service-ats_addresses.h | |||
@@ -287,6 +287,7 @@ struct GAS_NormalizationInfo | |||
287 | double norm; | 287 | double norm; |
288 | }; | 288 | }; |
289 | 289 | ||
290 | |||
290 | /** | 291 | /** |
291 | * Address with additional information | 292 | * Address with additional information |
292 | */ | 293 | */ |
@@ -308,7 +309,7 @@ struct ATS_Address | |||
308 | struct GNUNET_PeerIdentity peer; | 309 | struct GNUNET_PeerIdentity peer; |
309 | 310 | ||
310 | /** | 311 | /** |
311 | * Session ID, 0 if no session is given | 312 | * Session ID, can be 0 |
312 | */ | 313 | */ |
313 | uint32_t session_id; | 314 | uint32_t session_id; |
314 | 315 | ||
@@ -433,7 +434,7 @@ GAS_addresses_done (struct GAS_Addresses_Handle *handle); | |||
433 | * @param plugin_addr plugin address | 434 | * @param plugin_addr plugin address |
434 | * @param plugin_addr_len length of the plugin address | 435 | * @param plugin_addr_len length of the plugin address |
435 | * @param local_address_info the local address for the address | 436 | * @param local_address_info the local address for the address |
436 | * @param session_id session id, can be 0 | 437 | * @param session_id session id, can be 0. |
437 | * @param atsi performance information for this address | 438 | * @param atsi performance information for this address |
438 | * @param atsi_count number of performance information contained in @a atsi | 439 | * @param atsi_count number of performance information contained in @a atsi |
439 | */ | 440 | */ |
diff --git a/src/ats/gnunet-service-ats_performance.c b/src/ats/gnunet-service-ats_performance.c index 5a1d8cc66..2171ba697 100644 --- a/src/ats/gnunet-service-ats_performance.c +++ b/src/ats/gnunet-service-ats_performance.c | |||
@@ -114,6 +114,7 @@ find_client (struct GNUNET_SERVER_Client *client) | |||
114 | return NULL; | 114 | return NULL; |
115 | } | 115 | } |
116 | 116 | ||
117 | |||
117 | /** | 118 | /** |
118 | * Unregister a client (which may have been a performance client, | 119 | * Unregister a client (which may have been a performance client, |
119 | * but this is not assured). | 120 | * but this is not assured). |
@@ -133,6 +134,7 @@ GAS_performance_remove_client (struct GNUNET_SERVER_Client *client) | |||
133 | GNUNET_free (pc); | 134 | GNUNET_free (pc); |
134 | } | 135 | } |
135 | 136 | ||
137 | |||
136 | /** | 138 | /** |
137 | * Transmit the given performance information to all performance | 139 | * Transmit the given performance information to all performance |
138 | * clients. | 140 | * clients. |
@@ -152,7 +154,8 @@ void | |||
152 | GAS_performance_notify_client (struct PerformanceClient *pc, | 154 | GAS_performance_notify_client (struct PerformanceClient *pc, |
153 | const struct GNUNET_PeerIdentity *peer, | 155 | const struct GNUNET_PeerIdentity *peer, |
154 | const char *plugin_name, | 156 | const char *plugin_name, |
155 | const void *plugin_addr, size_t plugin_addr_len, | 157 | const void *plugin_addr, |
158 | size_t plugin_addr_len, | ||
156 | int active, | 159 | int active, |
157 | const struct GNUNET_ATS_Information *atsi, | 160 | const struct GNUNET_ATS_Information *atsi, |
158 | uint32_t atsi_count, | 161 | uint32_t atsi_count, |
@@ -195,7 +198,9 @@ GAS_performance_notify_client (struct PerformanceClient *pc, | |||
195 | addrp = (char *) &atsp[atsi_count]; | 198 | addrp = (char *) &atsp[atsi_count]; |
196 | memcpy (addrp, plugin_addr, plugin_addr_len); | 199 | memcpy (addrp, plugin_addr, plugin_addr_len); |
197 | strcpy (&addrp[plugin_addr_len], plugin_name); | 200 | strcpy (&addrp[plugin_addr_len], plugin_name); |
198 | GNUNET_SERVER_notification_context_unicast (nc, pc->client, &msg->header, | 201 | GNUNET_SERVER_notification_context_unicast (nc, |
202 | pc->client, | ||
203 | &msg->header, | ||
199 | GNUNET_YES); | 204 | GNUNET_YES); |
200 | } | 205 | } |
201 | 206 | ||
@@ -207,23 +212,23 @@ GAS_performance_notify_client (struct PerformanceClient *pc, | |||
207 | * @param peer peer for which this is an address suggestion | 212 | * @param peer peer for which this is an address suggestion |
208 | * @param plugin_name 0-termintated string specifying the transport plugin | 213 | * @param plugin_name 0-termintated string specifying the transport plugin |
209 | * @param plugin_addr binary address for the plugin to use | 214 | * @param plugin_addr binary address for the plugin to use |
210 | * @param plugin_addr_len number of bytes in plugin_addr | 215 | * @param plugin_addr_len number of bytes in @a plugin_addr |
211 | * @param active is this address active | 216 | * @param active is this address active |
212 | * @param atsi performance data for the address | 217 | * @param atsi performance data for the address |
213 | * @param atsi_count number of performance records in 'ats' | 218 | * @param atsi_count number of performance records in @a atsi |
214 | * @param bandwidth_out assigned outbound bandwidth | 219 | * @param bandwidth_out assigned outbound bandwidth |
215 | * @param bandwidth_in assigned inbound bandwidth | 220 | * @param bandwidth_in assigned inbound bandwidth |
216 | */ | 221 | */ |
217 | void | 222 | void |
218 | GAS_performance_notify_all_clients (const struct GNUNET_PeerIdentity *peer, | 223 | GAS_performance_notify_all_clients (const struct GNUNET_PeerIdentity *peer, |
219 | const char *plugin_name, | 224 | const char *plugin_name, |
220 | const void *plugin_addr, size_t plugin_addr_len, | 225 | const void *plugin_addr, |
226 | size_t plugin_addr_len, | ||
221 | int active, | 227 | int active, |
222 | const struct GNUNET_ATS_Information *atsi, | 228 | const struct GNUNET_ATS_Information *atsi, |
223 | uint32_t atsi_count, | 229 | uint32_t atsi_count, |
224 | struct GNUNET_BANDWIDTH_Value32NBO | 230 | struct GNUNET_BANDWIDTH_Value32NBO bandwidth_out, |
225 | bandwidth_out, | 231 | struct GNUNET_BANDWIDTH_Value32NBO bandwidth_in) |
226 | struct GNUNET_BANDWIDTH_Value32NBO bandwidth_in) | ||
227 | { | 232 | { |
228 | struct PerformanceClient *pc; | 233 | struct PerformanceClient *pc; |
229 | 234 | ||
@@ -232,7 +237,9 @@ GAS_performance_notify_all_clients (const struct GNUNET_PeerIdentity *peer, | |||
232 | { | 237 | { |
233 | GAS_performance_notify_client (pc, | 238 | GAS_performance_notify_client (pc, |
234 | peer, | 239 | peer, |
235 | plugin_name, plugin_addr, plugin_addr_len, | 240 | plugin_name, |
241 | plugin_addr, | ||
242 | plugin_addr_len, | ||
236 | active, | 243 | active, |
237 | atsi, atsi_count, | 244 | atsi, atsi_count, |
238 | bandwidth_out, bandwidth_in); | 245 | bandwidth_out, bandwidth_in); |
@@ -243,6 +250,21 @@ GAS_performance_notify_all_clients (const struct GNUNET_PeerIdentity *peer, | |||
243 | } | 250 | } |
244 | 251 | ||
245 | 252 | ||
253 | |||
254 | /** | ||
255 | * Iterator for called from #GAS_addresses_get_peer_info() | ||
256 | * | ||
257 | * @param p_it_cls closure with the `struct PerformanceClient *` | ||
258 | * @param id the peer id | ||
259 | * @param plugin_name plugin name | ||
260 | * @param plugin_addr address | ||
261 | * @param plugin_addr_len length of @a plugin_addr | ||
262 | * @param address_active is address actively used | ||
263 | * @param atsi ats performance information | ||
264 | * @param atsi_count number of ats performance elements in @a atsi | ||
265 | * @param bandwidth_out current outbound bandwidth assigned to address | ||
266 | * @param bandwidth_in current inbound bandwidth assigned to address | ||
267 | */ | ||
246 | static void | 268 | static void |
247 | peerinfo_it (void *cls, | 269 | peerinfo_it (void *cls, |
248 | const struct GNUNET_PeerIdentity *id, | 270 | const struct GNUNET_PeerIdentity *id, |
@@ -251,15 +273,14 @@ peerinfo_it (void *cls, | |||
251 | const int active, | 273 | const int active, |
252 | const struct GNUNET_ATS_Information *atsi, | 274 | const struct GNUNET_ATS_Information *atsi, |
253 | uint32_t atsi_count, | 275 | uint32_t atsi_count, |
254 | struct GNUNET_BANDWIDTH_Value32NBO | 276 | struct GNUNET_BANDWIDTH_Value32NBO bandwidth_out, |
255 | bandwidth_out, | ||
256 | struct GNUNET_BANDWIDTH_Value32NBO bandwidth_in) | 277 | struct GNUNET_BANDWIDTH_Value32NBO bandwidth_in) |
257 | { | 278 | { |
258 | struct PerformanceClient *pc = cls; | 279 | struct PerformanceClient *pc = cls; |
280 | |||
259 | GNUNET_assert (NULL != pc); | 281 | GNUNET_assert (NULL != pc); |
260 | if (NULL == id) | 282 | if (NULL == id) |
261 | return; | 283 | return; |
262 | |||
263 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, | 284 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, |
264 | "Callback for peer `%s' plugin `%s' BW out %u, BW in %u \n", | 285 | "Callback for peer `%s' plugin `%s' BW out %u, BW in %u \n", |
265 | GNUNET_i2s (id), | 286 | GNUNET_i2s (id), |
@@ -278,7 +299,7 @@ peerinfo_it (void *cls, | |||
278 | 299 | ||
279 | 300 | ||
280 | /** | 301 | /** |
281 | * Iterator for GAS_performance_add_client | 302 | * Iterator for #GAS_performance_add_client() |
282 | * | 303 | * |
283 | * @param cls the client requesting information | 304 | * @param cls the client requesting information |
284 | * @param id result | 305 | * @param id result |
@@ -288,13 +309,18 @@ peer_it (void *cls, | |||
288 | const struct GNUNET_PeerIdentity *id) | 309 | const struct GNUNET_PeerIdentity *id) |
289 | { | 310 | { |
290 | struct PerformanceClient *pc = cls; | 311 | struct PerformanceClient *pc = cls; |
312 | |||
291 | if (NULL != id) | 313 | if (NULL != id) |
292 | { | 314 | { |
293 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Callback for peer `%s'\n", GNUNET_i2s (id)); | 315 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, |
294 | GAS_addresses_get_peer_info (GSA_addresses, id, &peerinfo_it, pc); | 316 | "Callback for peer `%s'\n", |
317 | GNUNET_i2s (id)); | ||
318 | GAS_addresses_get_peer_info (GSA_addresses, id, | ||
319 | &peerinfo_it, pc); | ||
295 | } | 320 | } |
296 | } | 321 | } |
297 | 322 | ||
323 | |||
298 | /** | 324 | /** |
299 | * Register a new performance client. | 325 | * Register a new performance client. |
300 | * | 326 | * |
@@ -312,27 +338,33 @@ GAS_performance_add_client (struct GNUNET_SERVER_Client *client, | |||
312 | pc->client = client; | 338 | pc->client = client; |
313 | pc->flag = flag; | 339 | pc->flag = flag; |
314 | 340 | ||
315 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Adding performance client %s PIC\n", | 341 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, |
316 | (flag == START_FLAG_PERFORMANCE_WITH_PIC) ? "with" : "without"); | 342 | "Adding performance client %s PIC\n", |
343 | (flag == START_FLAG_PERFORMANCE_WITH_PIC) ? "with" : "without"); | ||
317 | 344 | ||
318 | GNUNET_SERVER_notification_context_add (nc, client); | 345 | GNUNET_SERVER_notification_context_add (nc, client); |
319 | GNUNET_CONTAINER_DLL_insert (pc_head, pc_tail, pc); | 346 | GNUNET_CONTAINER_DLL_insert (pc_head, pc_tail, pc); |
320 | 347 | ||
321 | /* Send information about clients */ | 348 | /* Send information about clients */ |
322 | GAS_addresses_iterate_peers (GSA_addresses, &peer_it, pc); | 349 | GAS_addresses_iterate_peers (GSA_addresses, |
350 | &peer_it, | ||
351 | pc); | ||
323 | } | 352 | } |
324 | 353 | ||
325 | 354 | ||
326 | static void transmit_req_addr (struct AddressIteration *ai, | 355 | /** |
327 | const struct GNUNET_PeerIdentity *id, | 356 | * FIXME. |
328 | const char *plugin_name, | 357 | */ |
329 | const void *plugin_addr, size_t plugin_addr_len, | 358 | static void |
330 | const int active, | 359 | transmit_req_addr (struct AddressIteration *ai, |
331 | const struct GNUNET_ATS_Information *atsi, | 360 | const struct GNUNET_PeerIdentity *id, |
332 | uint32_t atsi_count, | 361 | const char *plugin_name, |
333 | struct GNUNET_BANDWIDTH_Value32NBO | 362 | const void *plugin_addr, size_t plugin_addr_len, |
334 | bandwidth_out, | 363 | const int active, |
335 | struct GNUNET_BANDWIDTH_Value32NBO bandwidth_in) | 364 | const struct GNUNET_ATS_Information *atsi, |
365 | uint32_t atsi_count, | ||
366 | struct GNUNET_BANDWIDTH_Value32NBO bandwidth_out, | ||
367 | struct GNUNET_BANDWIDTH_Value32NBO bandwidth_in) | ||
336 | 368 | ||
337 | { | 369 | { |
338 | struct GNUNET_ATS_Information *atsp; | 370 | struct GNUNET_ATS_Information *atsp; |
@@ -379,6 +411,21 @@ static void transmit_req_addr (struct AddressIteration *ai, | |||
379 | GNUNET_NO); | 411 | GNUNET_NO); |
380 | } | 412 | } |
381 | 413 | ||
414 | |||
415 | /** | ||
416 | * Iterator for #GAS_addresses_get_peer_info() | ||
417 | * | ||
418 | * @param p_it_cls closure with our `struct AddressIteration *` | ||
419 | * @param id the peer id | ||
420 | * @param plugin_name plugin name | ||
421 | * @param plugin_addr address | ||
422 | * @param plugin_addr_len length of @a plugin_addr | ||
423 | * @param address_active is address actively used | ||
424 | * @param atsi ats performance information | ||
425 | * @param atsi_count number of ats performance elements in @a atsi | ||
426 | * @param bandwidth_out current outbound bandwidth assigned to address | ||
427 | * @param bandwidth_in current inbound bandwidth assigned to address | ||
428 | */ | ||
382 | static void | 429 | static void |
383 | req_addr_peerinfo_it (void *cls, | 430 | req_addr_peerinfo_it (void *cls, |
384 | const struct GNUNET_PeerIdentity *id, | 431 | const struct GNUNET_PeerIdentity *id, |
@@ -400,9 +447,9 @@ req_addr_peerinfo_it (void *cls, | |||
400 | 447 | ||
401 | if ((NULL == id) && (NULL == plugin_name) && (NULL == plugin_addr)) | 448 | if ((NULL == id) && (NULL == plugin_name) && (NULL == plugin_addr)) |
402 | { | 449 | { |
403 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, | 450 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, |
404 | "Address iteration done\n"); | 451 | "Address iteration done\n"); |
405 | return; | 452 | return; |
406 | } | 453 | } |
407 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, | 454 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, |
408 | "Callback for %s peer `%s' plugin `%s' BW out %u, BW in %u\n", | 455 | "Callback for %s peer `%s' plugin `%s' BW out %u, BW in %u\n", |
@@ -437,23 +484,26 @@ req_addr_peerinfo_it (void *cls, | |||
437 | /** | 484 | /** |
438 | * Iterator for GAS_handle_request_address_list | 485 | * Iterator for GAS_handle_request_address_list |
439 | * | 486 | * |
440 | * @param cls the client requesting information | 487 | * @param cls the client requesting information, a `struct AddressIteration *` |
441 | * @param id result | 488 | * @param id result |
442 | */ | 489 | */ |
443 | static void | 490 | static void |
444 | req_addr_peer_it (void *cls, | 491 | req_addr_peer_it (void *cls, |
445 | const struct GNUNET_PeerIdentity *id) | 492 | const struct GNUNET_PeerIdentity *id) |
446 | { | 493 | { |
447 | struct AddressIteration *ai = cls; | 494 | struct AddressIteration *ai = cls; |
448 | if (NULL != id) | 495 | |
449 | { | 496 | if (NULL == id) |
450 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Callback for peer `%s'\n", GNUNET_i2s (id)); | ||
451 | GAS_addresses_get_peer_info (GSA_addresses, id, &req_addr_peerinfo_it, ai); | ||
452 | } | ||
453 | else | ||
454 | { | 497 | { |
455 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Peer iteration done\n"); | 498 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, |
499 | "Peer iteration done\n"); | ||
500 | return; | ||
456 | } | 501 | } |
502 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, | ||
503 | "Callback for peer `%s'\n", | ||
504 | GNUNET_i2s (id)); | ||
505 | GAS_addresses_get_peer_info (GSA_addresses, id, | ||
506 | &req_addr_peerinfo_it, ai); | ||
457 | } | 507 | } |
458 | 508 | ||
459 | 509 | ||
@@ -474,13 +524,13 @@ GAS_handle_request_address_list (void *cls, struct GNUNET_SERVER_Client *client, | |||
474 | struct GNUNET_PeerIdentity allzeros; | 524 | struct GNUNET_PeerIdentity allzeros; |
475 | struct GNUNET_BANDWIDTH_Value32NBO bandwidth_zero; | 525 | struct GNUNET_BANDWIDTH_Value32NBO bandwidth_zero; |
476 | 526 | ||
477 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Received `%s' message\n", | 527 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, |
528 | "Received `%s' message\n", | ||
478 | "ADDRESSLIST_REQUEST"); | 529 | "ADDRESSLIST_REQUEST"); |
479 | |||
480 | if (NULL == (pc = find_client(client))) | 530 | if (NULL == (pc = find_client(client))) |
481 | { | 531 | { |
482 | GNUNET_break (0); | 532 | GNUNET_break (0); |
483 | return; | 533 | return; |
484 | } | 534 | } |
485 | 535 | ||
486 | ai.all = ntohl (alrm->all); | 536 | ai.all = ntohl (alrm->all); |
@@ -489,28 +539,40 @@ GAS_handle_request_address_list (void *cls, struct GNUNET_SERVER_Client *client, | |||
489 | 539 | ||
490 | memset (&allzeros, '\0', sizeof (struct GNUNET_PeerIdentity)); | 540 | memset (&allzeros, '\0', sizeof (struct GNUNET_PeerIdentity)); |
491 | bandwidth_zero.value__ = htonl (0); | 541 | bandwidth_zero.value__ = htonl (0); |
492 | if (0 == memcmp (&alrm->peer, &allzeros, sizeof (struct GNUNET_PeerIdentity))) | 542 | if (0 == memcmp (&alrm->peer, |
543 | &allzeros, | ||
544 | sizeof (struct GNUNET_PeerIdentity))) | ||
493 | { | 545 | { |
494 | /* Return addresses for all peers */ | 546 | /* Return addresses for all peers */ |
495 | GAS_addresses_iterate_peers (GSA_addresses, &req_addr_peer_it, &ai); | 547 | GAS_addresses_iterate_peers (GSA_addresses, &req_addr_peer_it, &ai); |
496 | transmit_req_addr (&ai, NULL, NULL, NULL, 0, GNUNET_NO, NULL, 0, bandwidth_zero, bandwidth_zero); | 548 | transmit_req_addr (&ai, NULL, NULL, NULL, 0, GNUNET_NO, NULL, 0, |
549 | bandwidth_zero, bandwidth_zero); | ||
497 | } | 550 | } |
498 | else | 551 | else |
499 | { | 552 | { |
500 | /* Return addresses for a specific peer */ | 553 | /* Return addresses for a specific peer */ |
501 | GAS_addresses_get_peer_info (GSA_addresses, &alrm->peer, &req_addr_peerinfo_it, &ai); | 554 | GAS_addresses_get_peer_info (GSA_addresses, |
502 | transmit_req_addr (&ai, NULL, NULL, NULL, 0, GNUNET_NO, NULL, 0, bandwidth_zero, bandwidth_zero); | 555 | &alrm->peer, |
556 | &req_addr_peerinfo_it, &ai); | ||
557 | transmit_req_addr (&ai, NULL, NULL, NULL, 0, GNUNET_NO, NULL, 0, | ||
558 | bandwidth_zero, bandwidth_zero); | ||
503 | } | 559 | } |
504 | GNUNET_SERVER_receive_done (client, GNUNET_OK); | 560 | GNUNET_SERVER_receive_done (client, GNUNET_OK); |
505 | } | 561 | } |
506 | 562 | ||
507 | 563 | ||
564 | /** | ||
565 | * FIXME. | ||
566 | */ | ||
508 | void | 567 | void |
509 | GAS_handle_performance_update (struct GNUNET_PeerIdentity *peer, | 568 | GAS_handle_performance_update (struct GNUNET_PeerIdentity *peer, |
510 | const char *plugin_name, const void *plugin_addr, size_t plugin_addr_len, | 569 | const char *plugin_name, |
511 | const int active, struct GNUNET_ATS_Information *ats, uint32_t ats_count, | 570 | const void *plugin_addr, size_t plugin_addr_len, |
512 | struct GNUNET_BANDWIDTH_Value32NBO bandwidth_out, | 571 | const int active, |
513 | struct GNUNET_BANDWIDTH_Value32NBO bandwidth_in) | 572 | struct GNUNET_ATS_Information *ats, |
573 | uint32_t ats_count, | ||
574 | struct GNUNET_BANDWIDTH_Value32NBO bandwidth_out, | ||
575 | struct GNUNET_BANDWIDTH_Value32NBO bandwidth_in) | ||
514 | { | 576 | { |
515 | /* Notify here */ | 577 | /* Notify here */ |
516 | GAS_performance_notify_all_clients (peer, plugin_name, plugin_addr, | 578 | GAS_performance_notify_all_clients (peer, plugin_name, plugin_addr, |
@@ -571,7 +633,8 @@ GAS_handle_reservation_request (void *cls, struct GNUNET_SERVER_Client *client, | |||
571 | GNUNET_SERVER_receive_done (client, GNUNET_SYSERR); | 633 | GNUNET_SERVER_receive_done (client, GNUNET_SYSERR); |
572 | return; | 634 | return; |
573 | } | 635 | } |
574 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Received `%s' message\n", | 636 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, |
637 | "Received `%s' message\n", | ||
575 | "RESERVATION_REQUEST"); | 638 | "RESERVATION_REQUEST"); |
576 | amount = (int32_t) ntohl (msg->amount); | 639 | amount = (int32_t) ntohl (msg->amount); |
577 | res_delay = GAS_reservations_reserve (&msg->peer, amount); | 640 | res_delay = GAS_reservations_reserve (&msg->peer, amount); |
@@ -582,7 +645,8 @@ GAS_handle_reservation_request (void *cls, struct GNUNET_SERVER_Client *client, | |||
582 | result.amount = htonl (amount); | 645 | result.amount = htonl (amount); |
583 | result.peer = msg->peer; | 646 | result.peer = msg->peer; |
584 | result.res_delay = GNUNET_TIME_relative_hton (res_delay); | 647 | result.res_delay = GNUNET_TIME_relative_hton (res_delay); |
585 | GNUNET_STATISTICS_update (GSA_stats, "# reservation requests processed", 1, | 648 | GNUNET_STATISTICS_update (GSA_stats, |
649 | "# reservation requests processed", 1, | ||
586 | GNUNET_NO); | 650 | GNUNET_NO); |
587 | GNUNET_SERVER_notification_context_unicast (nc, client, &result.header, | 651 | GNUNET_SERVER_notification_context_unicast (nc, client, &result.header, |
588 | GNUNET_NO); | 652 | GNUNET_NO); |
@@ -627,7 +691,8 @@ GAS_handle_preference_change (void *cls, | |||
627 | GNUNET_SERVER_receive_done (client, GNUNET_SYSERR); | 691 | GNUNET_SERVER_receive_done (client, GNUNET_SYSERR); |
628 | return; | 692 | return; |
629 | } | 693 | } |
630 | GNUNET_STATISTICS_update (GSA_stats, "# preference change requests processed", | 694 | GNUNET_STATISTICS_update (GSA_stats, |
695 | "# preference change requests processed", | ||
631 | 1, GNUNET_NO); | 696 | 1, GNUNET_NO); |
632 | pi = (const struct PreferenceInformation *) &msg[1]; | 697 | pi = (const struct PreferenceInformation *) &msg[1]; |
633 | for (i = 0; i < nump; i++) | 698 | for (i = 0; i < nump; i++) |
@@ -659,7 +724,8 @@ GAS_handle_preference_feedback (void *cls, | |||
659 | uint32_t nump; | 724 | uint32_t nump; |
660 | uint32_t i; | 725 | uint32_t i; |
661 | 726 | ||
662 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Received `%s' message\n", | 727 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, |
728 | "Received `%s' message\n", | ||
663 | "PREFERENCE_FEEDBACK"); | 729 | "PREFERENCE_FEEDBACK"); |
664 | msize = ntohs (message->size); | 730 | msize = ntohs (message->size); |
665 | if (msize < sizeof (struct FeedbackPreferenceMessage)) | 731 | if (msize < sizeof (struct FeedbackPreferenceMessage)) |
@@ -678,7 +744,8 @@ GAS_handle_preference_feedback (void *cls, | |||
678 | GNUNET_SERVER_receive_done (client, GNUNET_SYSERR); | 744 | GNUNET_SERVER_receive_done (client, GNUNET_SYSERR); |
679 | return; | 745 | return; |
680 | } | 746 | } |
681 | GNUNET_STATISTICS_update (GSA_stats, "# preference feedbacks requests processed", | 747 | GNUNET_STATISTICS_update (GSA_stats, |
748 | "# preference feedbacks requests processed", | ||
682 | 1, GNUNET_NO); | 749 | 1, GNUNET_NO); |
683 | pi = (const struct PreferenceInformation *) &msg[1]; | 750 | pi = (const struct PreferenceInformation *) &msg[1]; |
684 | for (i = 0; i < nump; i++) | 751 | for (i = 0; i < nump; i++) |
diff --git a/src/ats/gnunet-service-ats_performance.h b/src/ats/gnunet-service-ats_performance.h index 1a96c8819..da4263fe8 100644 --- a/src/ats/gnunet-service-ats_performance.h +++ b/src/ats/gnunet-service-ats_performance.h | |||
@@ -52,18 +52,19 @@ void | |||
52 | GAS_performance_remove_client (struct GNUNET_SERVER_Client *client); | 52 | GAS_performance_remove_client (struct GNUNET_SERVER_Client *client); |
53 | 53 | ||
54 | 54 | ||
55 | /** | ||
56 | * FIXME. | ||
57 | */ | ||
55 | void | 58 | void |
56 | GAS_handle_performance_update (struct GNUNET_PeerIdentity *peer, | 59 | GAS_handle_performance_update (struct GNUNET_PeerIdentity *peer, |
57 | const char *plugin_name, | 60 | const char *plugin_name, |
58 | const void *plugin_addr, | 61 | const void *plugin_addr, |
59 | size_t plugin_addr_len, | 62 | size_t plugin_addr_len, |
60 | const int active, | 63 | const int active, |
61 | struct GNUNET_ATS_Information *ats, | 64 | struct GNUNET_ATS_Information *ats, |
62 | uint32_t ats_count, | 65 | uint32_t ats_count, |
63 | struct GNUNET_BANDWIDTH_Value32NBO | 66 | struct GNUNET_BANDWIDTH_Value32NBO bandwidth_out, |
64 | bandwidth_out, | 67 | struct GNUNET_BANDWIDTH_Value32NBO bandwidth_in); |
65 | struct GNUNET_BANDWIDTH_Value32NBO | ||
66 | bandwidth_in); | ||
67 | 68 | ||
68 | 69 | ||
69 | 70 | ||
@@ -77,21 +78,20 @@ GAS_handle_performance_update (struct GNUNET_PeerIdentity *peer, | |||
77 | * @param plugin_addr_len number of bytes in plugin_addr | 78 | * @param plugin_addr_len number of bytes in plugin_addr |
78 | * @param active is this address active | 79 | * @param active is this address active |
79 | * @param atsi performance data for the address | 80 | * @param atsi performance data for the address |
80 | * @param atsi_count number of performance records in 'ats' | 81 | * @param atsi_count number of performance records in @a atsi |
81 | * @param bandwidth_out assigned outbound bandwidth | 82 | * @param bandwidth_out assigned outbound bandwidth |
82 | * @param bandwidth_in assigned inbound bandwidth | 83 | * @param bandwidth_in assigned inbound bandwidth |
83 | */ | 84 | */ |
84 | void | 85 | void |
85 | GAS_performance_notify_all_clients (const struct GNUNET_PeerIdentity *peer, | 86 | GAS_performance_notify_all_clients (const struct GNUNET_PeerIdentity *peer, |
86 | const char *plugin_name, | 87 | const char *plugin_name, |
87 | const void *plugin_addr, size_t plugin_addr_len, | 88 | const void *plugin_addr, |
88 | const int active, | 89 | size_t plugin_addr_len, |
89 | const struct GNUNET_ATS_Information *atsi, | 90 | const int active, |
90 | uint32_t atsi_count, | 91 | const struct GNUNET_ATS_Information *atsi, |
91 | struct GNUNET_BANDWIDTH_Value32NBO | 92 | uint32_t atsi_count, |
92 | bandwidth_out, | 93 | struct GNUNET_BANDWIDTH_Value32NBO bandwidth_out, |
93 | struct GNUNET_BANDWIDTH_Value32NBO | 94 | struct GNUNET_BANDWIDTH_Value32NBO bandwidth_in); |
94 | bandwidth_in); | ||
95 | 95 | ||
96 | 96 | ||
97 | /** | 97 | /** |
diff --git a/src/ats/gnunet-service-ats_scheduling.h b/src/ats/gnunet-service-ats_scheduling.h index f8b7000bd..b6540e115 100644 --- a/src/ats/gnunet-service-ats_scheduling.h +++ b/src/ats/gnunet-service-ats_scheduling.h | |||
@@ -70,11 +70,11 @@ GAS_handle_reset_backoff (void *cls, | |||
70 | * @param peer peer for which this is an address suggestion | 70 | * @param peer peer for which this is an address suggestion |
71 | * @param plugin_name 0-termintated string specifying the transport plugin | 71 | * @param plugin_name 0-termintated string specifying the transport plugin |
72 | * @param plugin_addr binary address for the plugin to use | 72 | * @param plugin_addr binary address for the plugin to use |
73 | * @param plugin_addr_len number of bytes in plugin_addr | 73 | * @param plugin_addr_len number of bytes in @a plugin_addr |
74 | * @param session_id session ID to use | 74 | * @param session_id session ID to use |
75 | * @param local_address_info the local address for the address | 75 | * @param local_address_info the local address for the address |
76 | * @param atsi performance data for the address | 76 | * @param atsi performance data for the address |
77 | * @param atsi_count number of performance records in 'ats' | 77 | * @param atsi_count number of performance records in @a atsi |
78 | * @param bandwidth_out assigned outbound bandwidth | 78 | * @param bandwidth_out assigned outbound bandwidth |
79 | * @param bandwidth_in assigned inbound bandwidth | 79 | * @param bandwidth_in assigned inbound bandwidth |
80 | */ | 80 | */ |