aboutsummaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorChristian Grothoff <christian@grothoff.org>2015-01-22 23:04:40 +0000
committerChristian Grothoff <christian@grothoff.org>2015-01-22 23:04:40 +0000
commita57305cef1ec471aea627810955e6f6cec36d847 (patch)
tree475a79a451277b60033a9919fb2499c197cc77ab /src
parent78b8e1c2a54c44992a16b65cdf67fea973e2cad0 (diff)
downloadgnunet-a57305cef1ec471aea627810955e6f6cec36d847.tar.gz
gnunet-a57305cef1ec471aea627810955e6f6cec36d847.zip
use statics instead of singleton struct, simplify internal APIs
Diffstat (limited to 'src')
-rw-r--r--src/ats/gnunet-service-ats.c24
-rw-r--r--src/ats/gnunet-service-ats_addresses.c584
-rw-r--r--src/ats/gnunet-service-ats_addresses.h68
-rw-r--r--src/ats/gnunet-service-ats_performance.c37
-rw-r--r--src/ats/gnunet-service-ats_performance.h3
-rw-r--r--src/ats/gnunet-service-ats_scheduling.c32
-rw-r--r--src/ats/gnunet-service-ats_scheduling.h3
7 files changed, 328 insertions, 423 deletions
diff --git a/src/ats/gnunet-service-ats.c b/src/ats/gnunet-service-ats.c
index 44bb1cebc..edc3b51af 100644
--- a/src/ats/gnunet-service-ats.c
+++ b/src/ats/gnunet-service-ats.c
@@ -43,11 +43,6 @@ struct GNUNET_STATISTICS_Handle *GSA_stats;
43 */ 43 */
44static struct GNUNET_SERVER_Handle *GSA_server; 44static struct GNUNET_SERVER_Handle *GSA_server;
45 45
46/**
47 * Handle to the address state.
48 */
49static struct GAS_Addresses_Handle *GSA_addresses;
50
51 46
52/** 47/**
53 * We have received a `struct ClientStartMessage` from a client. Find 48 * We have received a `struct ClientStartMessage` from a client. Find
@@ -122,7 +117,7 @@ static void
122cleanup_task (void *cls, 117cleanup_task (void *cls,
123 const struct GNUNET_SCHEDULER_TaskContext *tc) 118 const struct GNUNET_SCHEDULER_TaskContext *tc)
124{ 119{
125 GAS_addresses_done (GSA_addresses); 120 GAS_addresses_done ();
126 GAS_scheduling_done (); 121 GAS_scheduling_done ();
127 GAS_performance_done (); 122 GAS_performance_done ();
128 GAS_reservations_done (); 123 GAS_reservations_done ();
@@ -187,9 +182,20 @@ run (void *cls,
187 GSA_server = server; 182 GSA_server = server;
188 GSA_stats = GNUNET_STATISTICS_create ("ats", cfg); 183 GSA_stats = GNUNET_STATISTICS_create ("ats", cfg);
189 GAS_reservations_init (); 184 GAS_reservations_init ();
190 GSA_addresses = GAS_addresses_init (cfg, GSA_stats); 185 if (GNUNET_OK !=
191 GAS_performance_init (server, GSA_addresses); 186 GAS_addresses_init (cfg, GSA_stats))
192 GAS_scheduling_init (server, GSA_addresses); 187 {
188 GNUNET_break (0);
189 GAS_reservations_done ();
190 if (NULL != GSA_stats)
191 {
192 GNUNET_STATISTICS_destroy (GSA_stats, GNUNET_NO);
193 GSA_stats = NULL;
194 }
195 return;
196 }
197 GAS_performance_init (server);
198 GAS_scheduling_init (server);
193 199
194 GNUNET_SERVER_disconnect_notify (server, 200 GNUNET_SERVER_disconnect_notify (server,
195 &client_disconnect_handler, NULL); 201 &client_disconnect_handler, NULL);
diff --git a/src/ats/gnunet-service-ats_addresses.c b/src/ats/gnunet-service-ats_addresses.c
index 73c19173b..d89c9af0d 100644
--- a/src/ats/gnunet-service-ats_addresses.c
+++ b/src/ats/gnunet-service-ats_addresses.c
@@ -272,77 +272,69 @@ struct GAS_Addresses_Preference_Clients
272 272
273 273
274/** 274/**
275 * Handle for ATS address component. 275 *
276 * FIXME: these should probably all be 'static's instead.
277 */ 276 */
278struct GAS_Addresses_Handle 277static struct GNUNET_STATISTICS_Handle *stats;
279{
280 /**
281 *
282 */
283 struct GNUNET_STATISTICS_Handle *stat;
284 278
285 /** 279/**
286 * A multihashmap to store all addresses 280 * A multihashmap to store all addresses
287 */ 281 */
288 struct GNUNET_CONTAINER_MultiPeerMap *addresses; 282static struct GNUNET_CONTAINER_MultiPeerMap *addresses;
289
290 /**
291 * Is ATS addresses running
292 */
293 int running;
294 283
295 /** 284/**
296 * Preferences clients 285 * Is ATS addresses running
297 */ 286 */
298 int pref_clients; 287static int running;
299 288
300 /** 289/**
301 * Configured ATS solver 290 * Preferences clients
302 */ 291 */
303 int ats_mode; 292static int pref_clients;
304 293
305 /** 294/**
306 * Solver handle 295 * Configured ATS solver
307 */ 296 */
308 void *solver; 297static int ats_mode;
309 298
310 /** 299/**
311 * Address suggestion requests DLL head 300 * Solver handle
312 */ 301 */
313 struct GAS_Addresses_Suggestion_Requests *pending_requests_head; 302static void *solver;
314 303
315 /** 304/**
316 * Address suggestion requests DLL tail 305 * Address suggestion requests DLL head
317 */ 306 */
318 struct GAS_Addresses_Suggestion_Requests *pending_requests_tail; 307static struct GAS_Addresses_Suggestion_Requests *pending_requests_head;
319 308
320 /** 309/**
321 * Preference requests DLL head 310 * Address suggestion requests DLL tail
322 */ 311 */
323 struct GAS_Addresses_Preference_Clients *preference_clients_head; 312static struct GAS_Addresses_Suggestion_Requests *pending_requests_tail;
324 313
325 /** 314/**
326 * Preference requests DLL head 315 * Preference requests DLL head
327 */ 316 */
328 struct GAS_Addresses_Preference_Clients *preference_clients_tail; 317static struct GAS_Addresses_Preference_Clients *preference_clients_head;
329 318
330 /** 319/**
331 * Solver functions 320 * Preference requests DLL head
332 */ 321 */
333 struct GNUNET_ATS_PluginEnvironment env; 322static struct GAS_Addresses_Preference_Clients *preference_clients_tail;
334 323
335 /** 324/**
336 * Solver plugin name as string 325 * Solver functions
337 */ 326 */
338 char *plugin; 327static struct GNUNET_ATS_PluginEnvironment env;
339};
340 328
329/**
330 * Solver plugin name as string
331 */
332static char *plugin;
341 333
342/** 334/**
343 * Value we pass for zero bandwidth. 335 * Value we pass for zero bandwidth.
344 */ 336 */
345const static struct GNUNET_BANDWIDTH_Value32NBO zero_bw; 337static const struct GNUNET_BANDWIDTH_Value32NBO zero_bw;
346 338
347 339
348/** 340/**
@@ -618,14 +610,12 @@ compare_address_it (void *cls,
618 * Compares by peer identity and network address OR by session ID 610 * Compares by peer identity and network address OR by session ID
619 * (one of the two must match). 611 * (one of the two must match).
620 * 612 *
621 * @param handle the address handle
622 * @param peer peer to lookup addresses for 613 * @param peer peer to lookup addresses for
623 * @param addr existing address record 614 * @param addr existing address record
624 * @return existing address record, NULL for none 615 * @return existing address record, NULL for none
625 */ 616 */
626struct ATS_Address * 617struct ATS_Address *
627find_equivalent_address (struct GAS_Addresses_Handle *handle, 618find_equivalent_address (const struct GNUNET_PeerIdentity *peer,
628 const struct GNUNET_PeerIdentity *peer,
629 const struct ATS_Address *addr) 619 const struct ATS_Address *addr)
630{ 620{
631 struct CompareAddressContext cac; 621 struct CompareAddressContext cac;
@@ -633,7 +623,7 @@ find_equivalent_address (struct GAS_Addresses_Handle *handle,
633 cac.exact_address = NULL; 623 cac.exact_address = NULL;
634 cac.base_address = NULL; 624 cac.base_address = NULL;
635 cac.search = addr; 625 cac.search = addr;
636 GNUNET_CONTAINER_multipeermap_get_multiple (handle->addresses, 626 GNUNET_CONTAINER_multipeermap_get_multiple (addresses,
637 peer, 627 peer,
638 &compare_address_it, &cac); 628 &compare_address_it, &cac);
639 629
@@ -689,21 +679,19 @@ find_address_cb (void *cls,
689/** 679/**
690 * Find the exact address 680 * Find the exact address
691 * 681 *
692 * @param handle the address handle to use
693 * @param peer peer 682 * @param peer peer
694 * @param session_id session id, can never be 0 683 * @param session_id session id, can never be 0
695 * @return an ATS_address or NULL 684 * @return an ATS_address or NULL
696 */ 685 */
697static struct ATS_Address * 686static struct ATS_Address *
698find_exact_address (struct GAS_Addresses_Handle *handle, 687find_exact_address (const struct GNUNET_PeerIdentity *peer,
699 const struct GNUNET_PeerIdentity *peer,
700 uint32_t session_id) 688 uint32_t session_id)
701{ 689{
702 struct FindAddressContext fac; 690 struct FindAddressContext fac;
703 691
704 fac.exact_address = NULL; 692 fac.exact_address = NULL;
705 fac.session_id = session_id; 693 fac.session_id = session_id;
706 GNUNET_CONTAINER_multipeermap_get_multiple (handle->addresses, 694 GNUNET_CONTAINER_multipeermap_get_multiple (addresses,
707 peer, 695 peer,
708 &find_address_cb, &fac); 696 &find_address_cb, &fac);
709 return fac.exact_address; 697 return fac.exact_address;
@@ -769,7 +757,6 @@ get_performance_info (struct ATS_Address *address, uint32_t type)
769/** 757/**
770 * Add a new address for a peer. 758 * Add a new address for a peer.
771 * 759 *
772 * @param handle the address handle to use
773 * @param peer peer 760 * @param peer peer
774 * @param plugin_name transport plugin name 761 * @param plugin_name transport plugin name
775 * @param plugin_addr plugin address 762 * @param plugin_addr plugin address
@@ -780,8 +767,7 @@ get_performance_info (struct ATS_Address *address, uint32_t type)
780 * @param atsi_count number of performance information contained in @a atsi 767 * @param atsi_count number of performance information contained in @a atsi
781 */ 768 */
782void 769void
783GAS_addresses_add (struct GAS_Addresses_Handle *handle, 770GAS_addresses_add (const struct GNUNET_PeerIdentity *peer,
784 const struct GNUNET_PeerIdentity *peer,
785 const char *plugin_name, 771 const char *plugin_name,
786 const void *plugin_addr, 772 const void *plugin_addr,
787 size_t plugin_addr_len, 773 size_t plugin_addr_len,
@@ -803,10 +789,10 @@ GAS_addresses_add (struct GAS_Addresses_Handle *handle,
803 "ADDRESS ADD", 789 "ADDRESS ADD",
804 GNUNET_i2s (peer)); 790 GNUNET_i2s (peer));
805 791
806 if (GNUNET_NO == handle->running) 792 if (GNUNET_NO == running)
807 return; 793 return;
808 794
809 GNUNET_assert(NULL != handle->addresses); 795 GNUNET_assert(NULL != addresses);
810 796
811 new_address = create_address (peer, plugin_name, 797 new_address = create_address (peer, plugin_name,
812 plugin_addr, plugin_addr_len, 798 plugin_addr, plugin_addr_len,
@@ -820,21 +806,21 @@ GAS_addresses_add (struct GAS_Addresses_Handle *handle,
820 addr_net = GNUNET_ATS_NET_UNSPECIFIED; 806 addr_net = GNUNET_ATS_NET_UNSPECIFIED;
821 807
822 /* Get existing address or address with session == 0 */ 808 /* Get existing address or address with session == 0 */
823 existing_address = find_equivalent_address (handle, peer, new_address); 809 existing_address = find_equivalent_address (peer, new_address);
824 if (NULL == existing_address) 810 if (NULL == existing_address)
825 { 811 {
826 /* Add a new address */ 812 /* Add a new address */
827 new_address->t_added = GNUNET_TIME_absolute_get(); 813 new_address->t_added = GNUNET_TIME_absolute_get();
828 new_address->t_last_activity = GNUNET_TIME_absolute_get(); 814 new_address->t_last_activity = GNUNET_TIME_absolute_get();
829 GNUNET_assert(GNUNET_OK == 815 GNUNET_assert(GNUNET_OK ==
830 GNUNET_CONTAINER_multipeermap_put (handle->addresses, 816 GNUNET_CONTAINER_multipeermap_put (addresses,
831 peer, 817 peer,
832 new_address, 818 new_address,
833 GNUNET_CONTAINER_MULTIHASHMAPOPTION_MULTIPLE)); 819 GNUNET_CONTAINER_MULTIHASHMAPOPTION_MULTIPLE));
834 820
835 GNUNET_STATISTICS_set (handle->stat, 821 GNUNET_STATISTICS_set (stats,
836 "# addresses", 822 "# addresses",
837 GNUNET_CONTAINER_multipeermap_size (handle->addresses), 823 GNUNET_CONTAINER_multipeermap_size (addresses),
838 GNUNET_NO); 824 GNUNET_NO);
839 825
840 GNUNET_log (GNUNET_ERROR_TYPE_INFO, 826 GNUNET_log (GNUNET_ERROR_TYPE_INFO,
@@ -846,14 +832,14 @@ GAS_addresses_add (struct GAS_Addresses_Handle *handle,
846 GNUNET_ATS_print_network_type (addr_net)); 832 GNUNET_ATS_print_network_type (addr_net));
847 833
848 /* Tell solver about new address */ 834 /* Tell solver about new address */
849 handle->env.sf.s_add (handle->solver, new_address, addr_net); 835 env.sf.s_add (solver, new_address, addr_net);
850 836
851 handle->env.sf.s_bulk_start (handle->solver); 837 env.sf.s_bulk_start (solver);
852 GAS_normalization_normalize_property (handle->addresses, 838 GAS_normalization_normalize_property (addresses,
853 new_address, 839 new_address,
854 atsi, 840 atsi,
855 atsi_count); 841 atsi_count);
856 handle->env.sf.s_bulk_stop (handle->solver); 842 env.sf.s_bulk_stop (solver);
857 843
858 /* Notify performance clients about new address */ 844 /* Notify performance clients about new address */
859 GAS_performance_notify_all_clients (&new_address->peer, new_address->plugin, 845 GAS_performance_notify_all_clients (&new_address->peer, new_address->plugin,
@@ -914,7 +900,7 @@ GAS_addresses_add (struct GAS_Addresses_Handle *handle,
914 GNUNET_i2s (peer), existing_address, 900 GNUNET_i2s (peer), existing_address,
915 GNUNET_ATS_print_network_type (addr_net), 901 GNUNET_ATS_print_network_type (addr_net),
916 GNUNET_ATS_print_network_type (ntohl (atsi_delta[c1].value))); 902 GNUNET_ATS_print_network_type (ntohl (atsi_delta[c1].value)));
917 handle->env.sf.s_address_update_network (handle->solver, existing_address, 903 env.sf.s_address_update_network (solver, existing_address,
918 ntohl (atsi_delta[c1].value), 904 ntohl (atsi_delta[c1].value),
919 get_performance_info (existing_address, GNUNET_ATS_NETWORK_TYPE)); 905 get_performance_info (existing_address, GNUNET_ATS_NETWORK_TYPE));
920 addr_net = get_performance_info (existing_address, 906 addr_net = get_performance_info (existing_address,
@@ -922,10 +908,10 @@ GAS_addresses_add (struct GAS_Addresses_Handle *handle,
922 } 908 }
923 } 909 }
924 /* Notify solver about update with atsi information and session */ 910 /* Notify solver about update with atsi information and session */
925 handle->env.sf.s_bulk_start (handle->solver); 911 env.sf.s_bulk_start (solver);
926 GAS_normalization_normalize_property (handle->addresses, existing_address, 912 GAS_normalization_normalize_property (addresses, existing_address,
927 atsi, atsi_count); 913 atsi, atsi_count);
928 handle->env.sf.s_bulk_stop (handle->solver); 914 env.sf.s_bulk_stop (solver);
929 } 915 }
930 GNUNET_free_non_null(atsi_delta); 916 GNUNET_free_non_null(atsi_delta);
931 917
@@ -935,7 +921,7 @@ GAS_addresses_add (struct GAS_Addresses_Handle *handle,
935 921
936 previous_session = existing_address->session_id; 922 previous_session = existing_address->session_id;
937 existing_address->session_id = session_id; 923 existing_address->session_id = session_id;
938 handle->env.sf.s_address_update_session (handle->solver, existing_address, 924 env.sf.s_address_update_session (solver, existing_address,
939 previous_session, session_id); 925 previous_session, session_id);
940 926
941 GNUNET_log(GNUNET_ERROR_TYPE_INFO, 927 GNUNET_log(GNUNET_ERROR_TYPE_INFO,
@@ -948,15 +934,13 @@ GAS_addresses_add (struct GAS_Addresses_Handle *handle,
948/** 934/**
949 * Update an address with new performance information for a peer. 935 * Update an address with new performance information for a peer.
950 * 936 *
951 * @param handle the address handle to use
952 * @param peer peer 937 * @param peer peer
953 * @param session_id session id, never 0 938 * @param session_id session id, never 0
954 * @param atsi performance information for this address 939 * @param atsi performance information for this address
955 * @param atsi_count number of performance information contained in @a atsi 940 * @param atsi_count number of performance information contained in @a atsi
956 */ 941 */
957void 942void
958GAS_addresses_update (struct GAS_Addresses_Handle *handle, 943GAS_addresses_update (const struct GNUNET_PeerIdentity *peer,
959 const struct GNUNET_PeerIdentity *peer,
960 uint32_t session_id, 944 uint32_t session_id,
961 const struct GNUNET_ATS_Information *atsi, 945 const struct GNUNET_ATS_Information *atsi,
962 uint32_t atsi_count) 946 uint32_t atsi_count)
@@ -967,13 +951,12 @@ GAS_addresses_update (struct GAS_Addresses_Handle *handle,
967 uint32_t prev_session; 951 uint32_t prev_session;
968 int c1; 952 int c1;
969 953
970 if (GNUNET_NO == handle->running) 954 if (GNUNET_NO == running)
971 return; 955 return;
972 GNUNET_assert (NULL != handle->addresses); 956 GNUNET_assert (NULL != addresses);
973 957
974 /* Get existing address */ 958 /* Get existing address */
975 aa = find_exact_address (handle, 959 aa = find_exact_address (peer,
976 peer,
977 session_id); 960 session_id);
978 if (NULL == aa) 961 if (NULL == aa)
979 { 962 {
@@ -999,10 +982,10 @@ GAS_addresses_update (struct GAS_Addresses_Handle *handle,
999 /* Session changed */ 982 /* Session changed */
1000 prev_session = aa->session_id; 983 prev_session = aa->session_id;
1001 aa->session_id = session_id; 984 aa->session_id = session_id;
1002 handle->env.sf.s_address_update_session (handle->solver, 985 env.sf.s_address_update_session (solver,
1003 aa, 986 aa,
1004 prev_session, 987 prev_session,
1005 aa->session_id); 988 aa->session_id);
1006 } 989 }
1007 990
1008 atsi_delta = NULL; 991 atsi_delta = NULL;
@@ -1019,7 +1002,7 @@ GAS_addresses_update (struct GAS_Addresses_Handle *handle,
1019 if (GNUNET_ATS_NETWORK_TYPE == ntohl (atsi_delta[c1].type)) 1002 if (GNUNET_ATS_NETWORK_TYPE == ntohl (atsi_delta[c1].type))
1020 { 1003 {
1021 /* Network type changed */ 1004 /* Network type changed */
1022 handle->env.sf.s_address_update_network (handle->solver, aa, 1005 env.sf.s_address_update_network (solver, aa,
1023 ntohl (atsi_delta[c1].value), 1006 ntohl (atsi_delta[c1].value),
1024 get_performance_info (aa, GNUNET_ATS_NETWORK_TYPE)); 1007 get_performance_info (aa, GNUNET_ATS_NETWORK_TYPE));
1025 } 1008 }
@@ -1031,12 +1014,12 @@ GAS_addresses_update (struct GAS_Addresses_Handle *handle,
1031 GNUNET_BANDWIDTH_value_init (aa->assigned_bw_out), 1014 GNUNET_BANDWIDTH_value_init (aa->assigned_bw_out),
1032 GNUNET_BANDWIDTH_value_init (aa->assigned_bw_in)); 1015 GNUNET_BANDWIDTH_value_init (aa->assigned_bw_in));
1033 1016
1034 handle->env.sf.s_bulk_start (handle->solver); 1017 env.sf.s_bulk_start (solver);
1035 GAS_normalization_normalize_property (handle->addresses, 1018 GAS_normalization_normalize_property (addresses,
1036 aa, 1019 aa,
1037 atsi, 1020 atsi,
1038 atsi_count); 1021 atsi_count);
1039 handle->env.sf.s_bulk_stop (handle->solver); 1022 env.sf.s_bulk_stop (solver);
1040 } 1023 }
1041 GNUNET_free_non_null (atsi_delta); 1024 GNUNET_free_non_null (atsi_delta);
1042} 1025}
@@ -1045,23 +1028,20 @@ GAS_addresses_update (struct GAS_Addresses_Handle *handle,
1045/** 1028/**
1046 * Remove an address or just a session for a peer. 1029 * Remove an address or just a session for a peer.
1047 * 1030 *
1048 * @param handle the address handle to use
1049 * @param peer peer 1031 * @param peer peer
1050 * @param session_id session id, can never be 0 1032 * @param session_id session id, can never be 0
1051 */ 1033 */
1052void 1034void
1053GAS_addresses_destroy (struct GAS_Addresses_Handle *handle, 1035GAS_addresses_destroy (const struct GNUNET_PeerIdentity *peer,
1054 const struct GNUNET_PeerIdentity *peer,
1055 uint32_t session_id) 1036 uint32_t session_id)
1056{ 1037{
1057 struct ATS_Address *ea; 1038 struct ATS_Address *ea;
1058 1039
1059 if (GNUNET_NO == handle->running) 1040 if (GNUNET_NO == running)
1060 return; 1041 return;
1061 1042
1062 /* Get existing address */ 1043 /* Get existing address */
1063 ea = find_exact_address (handle, 1044 ea = find_exact_address (peer,
1064 peer,
1065 session_id); 1045 session_id);
1066 if (NULL == ea) 1046 if (NULL == ea)
1067 { 1047 {
@@ -1079,11 +1059,11 @@ GAS_addresses_destroy (struct GAS_Addresses_Handle *handle,
1079 GNUNET_i2s (peer), 1059 GNUNET_i2s (peer),
1080 ea, 1060 ea,
1081 session_id); 1061 session_id);
1082 GNUNET_CONTAINER_multipeermap_remove (handle->addresses, 1062 GNUNET_CONTAINER_multipeermap_remove (addresses,
1083 peer, 1063 peer,
1084 ea); 1064 ea);
1085 1065
1086 handle->env.sf.s_del (handle->solver, ea, GNUNET_NO); 1066 env.sf.s_del (solver, ea, GNUNET_NO);
1087 GAS_performance_notify_all_clients (peer, 1067 GAS_performance_notify_all_clients (peer,
1088 ea->plugin, 1068 ea->plugin,
1089 ea->addr, 1069 ea->addr,
@@ -1093,9 +1073,9 @@ GAS_addresses_destroy (struct GAS_Addresses_Handle *handle,
1093 zero_bw, 1073 zero_bw,
1094 zero_bw); 1074 zero_bw);
1095 free_address (ea); 1075 free_address (ea);
1096 GNUNET_STATISTICS_set (handle->stat, 1076 GNUNET_STATISTICS_set (stats,
1097 "# addresses", 1077 "# addresses",
1098 GNUNET_CONTAINER_multipeermap_size (handle->addresses), 1078 GNUNET_CONTAINER_multipeermap_size (addresses),
1099 GNUNET_NO); 1079 GNUNET_NO);
1100} 1080}
1101 1081
@@ -1110,15 +1090,13 @@ GAS_addresses_destroy (struct GAS_Addresses_Handle *handle,
1110 * Note: can only be called with in_use == #GNUNET_NO if called with #GNUNET_YES 1090 * Note: can only be called with in_use == #GNUNET_NO if called with #GNUNET_YES
1111 * before 1091 * before
1112 * 1092 *
1113 * @param handle the address handle to use
1114 * @param peer peer 1093 * @param peer peer
1115 * @param session_id session id, can be 0 1094 * @param session_id session id, can be 0
1116 * @param in_use #GNUNET_YES if #GNUNET_NO FIXME 1095 * @param in_use #GNUNET_YES if #GNUNET_NO FIXME
1117 * @return #GNUNET_SYSERR on failure (address unknown ...) 1096 * @return #GNUNET_SYSERR on failure (address unknown ...)
1118 */ 1097 */
1119int 1098int
1120GAS_addresses_in_use (struct GAS_Addresses_Handle *handle, 1099GAS_addresses_in_use (const struct GNUNET_PeerIdentity *peer,
1121 const struct GNUNET_PeerIdentity *peer,
1122 uint32_t session_id, 1100 uint32_t session_id,
1123 int in_use) 1101 int in_use)
1124{ 1102{
@@ -1128,10 +1106,9 @@ GAS_addresses_in_use (struct GAS_Addresses_Handle *handle,
1128 "Received `%s' for peer `%s'\n", 1106 "Received `%s' for peer `%s'\n",
1129 "ADDRESS IN USE", 1107 "ADDRESS IN USE",
1130 GNUNET_i2s (peer)); 1108 GNUNET_i2s (peer));
1131 if (GNUNET_NO == handle->running) 1109 if (GNUNET_NO == running)
1132 return GNUNET_SYSERR; 1110 return GNUNET_SYSERR;
1133 ea = find_exact_address (handle, 1111 ea = find_exact_address (peer,
1134 peer,
1135 session_id); 1112 session_id);
1136 if (NULL == ea) 1113 if (NULL == ea)
1137 { 1114 {
@@ -1156,9 +1133,9 @@ GAS_addresses_in_use (struct GAS_Addresses_Handle *handle,
1156 /* Tell solver about update */ 1133 /* Tell solver about update */
1157 ea->used = in_use; 1134 ea->used = in_use;
1158 ea->t_last_activity = GNUNET_TIME_absolute_get(); 1135 ea->t_last_activity = GNUNET_TIME_absolute_get();
1159 handle->env.sf.s_address_update_inuse (handle->solver, 1136 env.sf.s_address_update_inuse (solver,
1160 ea, 1137 ea,
1161 ea->used); 1138 ea->used);
1162 return GNUNET_OK; 1139 return GNUNET_OK;
1163} 1140}
1164 1141
@@ -1166,14 +1143,12 @@ GAS_addresses_in_use (struct GAS_Addresses_Handle *handle,
1166/** 1143/**
1167 * Cancel address suggestions for a peer 1144 * Cancel address suggestions for a peer
1168 * 1145 *
1169 * @param handle the address handle
1170 * @param peer the peer id 1146 * @param peer the peer id
1171 */ 1147 */
1172void 1148void
1173GAS_addresses_request_address_cancel (struct GAS_Addresses_Handle *handle, 1149GAS_addresses_request_address_cancel (const struct GNUNET_PeerIdentity *peer)
1174 const struct GNUNET_PeerIdentity *peer)
1175{ 1150{
1176 struct GAS_Addresses_Suggestion_Requests *cur = handle->pending_requests_head; 1151 struct GAS_Addresses_Suggestion_Requests *cur = pending_requests_head;
1177 1152
1178 GNUNET_log(GNUNET_ERROR_TYPE_DEBUG, 1153 GNUNET_log(GNUNET_ERROR_TYPE_DEBUG,
1179 "Received request: `%s' for peer %s\n", 1154 "Received request: `%s' for peer %s\n",
@@ -1194,13 +1169,13 @@ GAS_addresses_request_address_cancel (struct GAS_Addresses_Handle *handle,
1194 GNUNET_i2s (peer)); 1169 GNUNET_i2s (peer));
1195 return; 1170 return;
1196 } 1171 }
1197 handle->env.sf.s_get_stop (handle->solver, peer); 1172 env.sf.s_get_stop (solver, peer);
1198 GAS_addresses_handle_backoff_reset (handle, peer); 1173 GAS_addresses_handle_backoff_reset (peer);
1199 GNUNET_log(GNUNET_ERROR_TYPE_DEBUG, 1174 GNUNET_log(GNUNET_ERROR_TYPE_DEBUG,
1200 "Removed request pending for peer `%s\n", 1175 "Removed request pending for peer `%s\n",
1201 GNUNET_i2s (peer)); 1176 GNUNET_i2s (peer));
1202 GNUNET_CONTAINER_DLL_remove (handle->pending_requests_head, 1177 GNUNET_CONTAINER_DLL_remove (pending_requests_head,
1203 handle->pending_requests_tail, 1178 pending_requests_tail,
1204 cur); 1179 cur);
1205 GNUNET_free(cur); 1180 GNUNET_free(cur);
1206} 1181}
@@ -1209,14 +1184,12 @@ GAS_addresses_request_address_cancel (struct GAS_Addresses_Handle *handle,
1209/** 1184/**
1210 * Request address suggestions for a peer 1185 * Request address suggestions for a peer
1211 * 1186 *
1212 * @param handle the address handle
1213 * @param peer the peer id 1187 * @param peer the peer id
1214 */ 1188 */
1215void 1189void
1216GAS_addresses_request_address (struct GAS_Addresses_Handle *handle, 1190GAS_addresses_request_address (const struct GNUNET_PeerIdentity *peer)
1217 const struct GNUNET_PeerIdentity *peer)
1218{ 1191{
1219 struct GAS_Addresses_Suggestion_Requests *cur = handle->pending_requests_head; 1192 struct GAS_Addresses_Suggestion_Requests *cur = pending_requests_head;
1220 struct ATS_Address *aa; 1193 struct ATS_Address *aa;
1221 1194
1222 GNUNET_log(GNUNET_ERROR_TYPE_DEBUG, 1195 GNUNET_log(GNUNET_ERROR_TYPE_DEBUG,
@@ -1224,7 +1197,7 @@ GAS_addresses_request_address (struct GAS_Addresses_Handle *handle,
1224 "REQUEST ADDRESS", 1197 "REQUEST ADDRESS",
1225 GNUNET_i2s (peer)); 1198 GNUNET_i2s (peer));
1226 1199
1227 if (GNUNET_NO == handle->running) 1200 if (GNUNET_NO == running)
1228 return; 1201 return;
1229 while (NULL != cur) 1202 while (NULL != cur)
1230 { 1203 {
@@ -1239,11 +1212,13 @@ GAS_addresses_request_address (struct GAS_Addresses_Handle *handle,
1239 GNUNET_log(GNUNET_ERROR_TYPE_DEBUG, 1212 GNUNET_log(GNUNET_ERROR_TYPE_DEBUG,
1240 "Adding new address suggestion request for `%s'\n", 1213 "Adding new address suggestion request for `%s'\n",
1241 GNUNET_i2s (peer)); 1214 GNUNET_i2s (peer));
1242 GNUNET_CONTAINER_DLL_insert(handle->pending_requests_head, handle->pending_requests_tail, cur); 1215 GNUNET_CONTAINER_DLL_insert (pending_requests_head,
1216 pending_requests_tail,
1217 cur);
1243 } 1218 }
1244 1219
1245 /* Get prefered address from solver */ 1220 /* Get prefered address from solver */
1246 aa = (struct ATS_Address *) handle->env.sf.s_get (handle->solver, peer); 1221 aa = (struct ATS_Address *) env.sf.s_get (solver, peer);
1247 if (NULL == aa) 1222 if (NULL == aa)
1248 { 1223 {
1249 GNUNET_log(GNUNET_ERROR_TYPE_INFO, "Cannot suggest address for peer `%s'\n", 1224 GNUNET_log(GNUNET_ERROR_TYPE_INFO, "Cannot suggest address for peer `%s'\n",
@@ -1301,20 +1276,21 @@ reset_address_it (void *cls,
1301 * Suggesting addresses is blocked for ATS_BLOCKING_DELTA. Blocking can be 1276 * Suggesting addresses is blocked for ATS_BLOCKING_DELTA. Blocking can be
1302 * reset using this function 1277 * reset using this function
1303 * 1278 *
1304 * @param handle the address handle
1305 * @param peer the peer id 1279 * @param peer the peer id
1306 */ 1280 */
1307void 1281void
1308GAS_addresses_handle_backoff_reset (struct GAS_Addresses_Handle *handle, 1282GAS_addresses_handle_backoff_reset (const struct GNUNET_PeerIdentity *peer)
1309 const struct GNUNET_PeerIdentity *peer)
1310{ 1283{
1311 GNUNET_log(GNUNET_ERROR_TYPE_DEBUG, "Received `%s' for peer `%s'\n", 1284 GNUNET_log(GNUNET_ERROR_TYPE_DEBUG,
1312 "RESET BACKOFF", GNUNET_i2s (peer)); 1285 "Received `%s' for peer `%s'\n",
1286 "RESET BACKOFF",
1287 GNUNET_i2s (peer));
1313 1288
1314 GNUNET_break( 1289 GNUNET_break(GNUNET_SYSERR !=
1315 GNUNET_SYSERR != GNUNET_CONTAINER_multipeermap_get_multiple (handle->addresses, 1290 GNUNET_CONTAINER_multipeermap_get_multiple (addresses,
1316 peer, 1291 peer,
1317 &reset_address_it, NULL)); 1292 &reset_address_it,
1293 NULL));
1318} 1294}
1319 1295
1320 1296
@@ -1323,13 +1299,13 @@ GAS_addresses_handle_backoff_reset (struct GAS_Addresses_Handle *handle,
1323 * 1299 *
1324 * @param cls the closure 1300 * @param cls the closure
1325 * @param op the operation 1301 * @param op the operation
1326 * @param stat operation status 1302 * @param status operation status
1327 * @param add additional information 1303 * @param add additional information
1328 */ 1304 */
1329static void 1305static void
1330solver_info_cb (void *cls, 1306solver_info_cb (void *cls,
1331 enum GAS_Solver_Operation op, 1307 enum GAS_Solver_Operation op,
1332 enum GAS_Solver_Status stat, 1308 enum GAS_Solver_Status status,
1333 enum GAS_Solver_Additional_Information add) 1309 enum GAS_Solver_Additional_Information add)
1334{ 1310{
1335 char *add_info; 1311 char *add_info;
@@ -1359,56 +1335,56 @@ solver_info_cb (void *cls,
1359 case GAS_OP_SOLVE_START: 1335 case GAS_OP_SOLVE_START:
1360 GNUNET_log(GNUNET_ERROR_TYPE_DEBUG, 1336 GNUNET_log(GNUNET_ERROR_TYPE_DEBUG,
1361 "Solver notifies `%s' with result `%s' `%s'\n", "GAS_OP_SOLVE_START", 1337 "Solver notifies `%s' with result `%s' `%s'\n", "GAS_OP_SOLVE_START",
1362 (GAS_STAT_SUCCESS == stat) ? "SUCCESS" : "FAIL", add_info); 1338 (GAS_STAT_SUCCESS == status) ? "SUCCESS" : "FAIL", add_info);
1363 return; 1339 return;
1364 case GAS_OP_SOLVE_STOP: 1340 case GAS_OP_SOLVE_STOP:
1365 GNUNET_log(GNUNET_ERROR_TYPE_DEBUG, 1341 GNUNET_log(GNUNET_ERROR_TYPE_DEBUG,
1366 "Solver notifies `%s' with result `%s'\n", "GAS_OP_SOLVE_STOP", 1342 "Solver notifies `%s' with result `%s'\n", "GAS_OP_SOLVE_STOP",
1367 (GAS_STAT_SUCCESS == stat) ? "SUCCESS" : "FAIL", add_info); 1343 (GAS_STAT_SUCCESS == status) ? "SUCCESS" : "FAIL", add_info);
1368 return; 1344 return;
1369 1345
1370 case GAS_OP_SOLVE_SETUP_START: 1346 case GAS_OP_SOLVE_SETUP_START:
1371 GNUNET_log(GNUNET_ERROR_TYPE_DEBUG, 1347 GNUNET_log(GNUNET_ERROR_TYPE_DEBUG,
1372 "Solver notifies `%s' with result `%s'\n", "GAS_OP_SOLVE_SETUP_START", 1348 "Solver notifies `%s' with result `%s'\n", "GAS_OP_SOLVE_SETUP_START",
1373 (GAS_STAT_SUCCESS == stat) ? "SUCCESS" : "FAIL"); 1349 (GAS_STAT_SUCCESS == status) ? "SUCCESS" : "FAIL");
1374 return; 1350 return;
1375 1351
1376 case GAS_OP_SOLVE_SETUP_STOP: 1352 case GAS_OP_SOLVE_SETUP_STOP:
1377 GNUNET_log(GNUNET_ERROR_TYPE_DEBUG, 1353 GNUNET_log(GNUNET_ERROR_TYPE_DEBUG,
1378 "Solver notifies `%s' with result `%s'\n", "GAS_OP_SOLVE_SETUP_STOP", 1354 "Solver notifies `%s' with result `%s'\n", "GAS_OP_SOLVE_SETUP_STOP",
1379 (GAS_STAT_SUCCESS == stat) ? "SUCCESS" : "FAIL"); 1355 (GAS_STAT_SUCCESS == status) ? "SUCCESS" : "FAIL");
1380 return; 1356 return;
1381 1357
1382 case GAS_OP_SOLVE_MLP_LP_START: 1358 case GAS_OP_SOLVE_MLP_LP_START:
1383 GNUNET_log(GNUNET_ERROR_TYPE_DEBUG, 1359 GNUNET_log(GNUNET_ERROR_TYPE_DEBUG,
1384 "Solver notifies `%s' with result `%s'\n", "GAS_OP_SOLVE_LP_START", 1360 "Solver notifies `%s' with result `%s'\n", "GAS_OP_SOLVE_LP_START",
1385 (GAS_STAT_SUCCESS == stat) ? "SUCCESS" : "FAIL"); 1361 (GAS_STAT_SUCCESS == status) ? "SUCCESS" : "FAIL");
1386 return; 1362 return;
1387 case GAS_OP_SOLVE_MLP_LP_STOP: 1363 case GAS_OP_SOLVE_MLP_LP_STOP:
1388 GNUNET_log(GNUNET_ERROR_TYPE_DEBUG, 1364 GNUNET_log(GNUNET_ERROR_TYPE_DEBUG,
1389 "Solver notifies `%s' with result `%s'\n", "GAS_OP_SOLVE_LP_STOP", 1365 "Solver notifies `%s' with result `%s'\n", "GAS_OP_SOLVE_LP_STOP",
1390 (GAS_STAT_SUCCESS == stat) ? "SUCCESS" : "FAIL"); 1366 (GAS_STAT_SUCCESS == status) ? "SUCCESS" : "FAIL");
1391 return; 1367 return;
1392 1368
1393 case GAS_OP_SOLVE_MLP_MLP_START: 1369 case GAS_OP_SOLVE_MLP_MLP_START:
1394 GNUNET_log(GNUNET_ERROR_TYPE_DEBUG, 1370 GNUNET_log(GNUNET_ERROR_TYPE_DEBUG,
1395 "Solver notifies `%s' with result `%s'\n", "GAS_OP_SOLVE_MLP_START", 1371 "Solver notifies `%s' with result `%s'\n", "GAS_OP_SOLVE_MLP_START",
1396 (GAS_STAT_SUCCESS == stat) ? "SUCCESS" : "FAIL"); 1372 (GAS_STAT_SUCCESS == status) ? "SUCCESS" : "FAIL");
1397 return; 1373 return;
1398 case GAS_OP_SOLVE_MLP_MLP_STOP: 1374 case GAS_OP_SOLVE_MLP_MLP_STOP:
1399 GNUNET_log(GNUNET_ERROR_TYPE_DEBUG, 1375 GNUNET_log(GNUNET_ERROR_TYPE_DEBUG,
1400 "Solver notifies `%s' with result `%s'\n", "GAS_OP_SOLVE_MLP_STOP", 1376 "Solver notifies `%s' with result `%s'\n", "GAS_OP_SOLVE_MLP_STOP",
1401 (GAS_STAT_SUCCESS == stat) ? "SUCCESS" : "FAIL"); 1377 (GAS_STAT_SUCCESS == status) ? "SUCCESS" : "FAIL");
1402 return; 1378 return;
1403 case GAS_OP_SOLVE_UPDATE_NOTIFICATION_START: 1379 case GAS_OP_SOLVE_UPDATE_NOTIFICATION_START:
1404 GNUNET_log(GNUNET_ERROR_TYPE_DEBUG, 1380 GNUNET_log(GNUNET_ERROR_TYPE_DEBUG,
1405 "Solver notifies `%s' with result `%s'\n", "GAS_OP_SOLVE_UPDATE_NOTIFICATION_START", 1381 "Solver notifies `%s' with result `%s'\n", "GAS_OP_SOLVE_UPDATE_NOTIFICATION_START",
1406 (GAS_STAT_SUCCESS == stat) ? "SUCCESS" : "FAIL"); 1382 (GAS_STAT_SUCCESS == status) ? "SUCCESS" : "FAIL");
1407 return; 1383 return;
1408 case GAS_OP_SOLVE_UPDATE_NOTIFICATION_STOP: 1384 case GAS_OP_SOLVE_UPDATE_NOTIFICATION_STOP:
1409 GNUNET_log(GNUNET_ERROR_TYPE_DEBUG, 1385 GNUNET_log(GNUNET_ERROR_TYPE_DEBUG,
1410 "Solver notifies `%s' with result `%s'\n", "GAS_OP_SOLVE_UPDATE_NOTIFICATION_STOP", 1386 "Solver notifies `%s' with result `%s'\n", "GAS_OP_SOLVE_UPDATE_NOTIFICATION_STOP",
1411 (GAS_STAT_SUCCESS == stat) ? "SUCCESS" : "FAIL"); 1387 (GAS_STAT_SUCCESS == status) ? "SUCCESS" : "FAIL");
1412 return; 1388 return;
1413 default: 1389 default:
1414 break; 1390 break;
@@ -1419,27 +1395,26 @@ solver_info_cb (void *cls,
1419/** 1395/**
1420 * The preference changed for a peer 1396 * The preference changed for a peer
1421 * 1397 *
1422 * @param cls the address handle 1398 * @param cls NULL
1423 * @param peer the peer 1399 * @param peer the peer
1424 * @param kind the ATS kind 1400 * @param kind the ATS kind
1425 * @param pref_rel the new relative preference value 1401 * @param pref_rel the new relative preference value
1426 */ 1402 */
1427static void 1403static void
1428normalized_preference_changed_cb (void *cls, 1404normalized_preference_changed_cb (void *cls,
1429 const struct GNUNET_PeerIdentity *peer, enum GNUNET_ATS_PreferenceKind kind, 1405 const struct GNUNET_PeerIdentity *peer,
1430 double pref_rel) 1406 enum GNUNET_ATS_PreferenceKind kind,
1407 double pref_rel)
1431{ 1408{
1432 GNUNET_assert(NULL != cls);
1433 struct GAS_Addresses_Handle *handle = cls;
1434
1435 /* Tell solver about update */ 1409 /* Tell solver about update */
1436 handle->env.sf.s_pref (handle->solver, peer, kind, pref_rel); 1410 env.sf.s_pref (solver, peer, kind, pref_rel);
1437} 1411}
1438 1412
1413
1439/** 1414/**
1440 * The relative value for a property changed 1415 * The relative value for a property changed
1441 * 1416 *
1442 * @param cls the address handle 1417 * @param cls NULL
1443 * @param address the peer 1418 * @param address the peer
1444 * @param type the ATS type 1419 * @param type the ATS type
1445 * @param prop_rel the new relative preference value 1420 * @param prop_rel the new relative preference value
@@ -1447,29 +1422,30 @@ normalized_preference_changed_cb (void *cls,
1447static void 1422static void
1448normalized_property_changed_cb (void *cls, 1423normalized_property_changed_cb (void *cls,
1449 struct ATS_Address *address, 1424 struct ATS_Address *address,
1450 uint32_t type, double prop_rel) 1425 uint32_t type,
1426 double prop_rel)
1451{ 1427{
1452 struct GAS_Addresses_Handle *ah = cls;
1453
1454 GNUNET_log(GNUNET_ERROR_TYPE_DEBUG, 1428 GNUNET_log(GNUNET_ERROR_TYPE_DEBUG,
1455 "Normalized property %s for peer `%s' changed to %.3f \n", 1429 "Normalized property %s for peer `%s' changed to %.3f \n",
1456 GNUNET_ATS_print_property_type (type), GNUNET_i2s (&address->peer), 1430 GNUNET_ATS_print_property_type (type),
1457 prop_rel); 1431 GNUNET_i2s (&address->peer),
1458 1432 prop_rel);
1459 ah->env.sf.s_address_update_property (ah->solver, address, type, 0, prop_rel); 1433 env.sf.s_address_update_property (solver,
1434 address,
1435 type,
1436 0,
1437 prop_rel);
1460} 1438}
1461 1439
1462 1440
1463static struct GAS_Addresses_Preference_Clients * 1441static struct GAS_Addresses_Preference_Clients *
1464find_preference_client (struct GAS_Addresses_Handle *handle, void *client) 1442find_preference_client (void *client)
1465{ 1443{
1466 struct GAS_Addresses_Preference_Clients *cur; 1444 struct GAS_Addresses_Preference_Clients *cur;
1467 1445
1468 for (cur = handle->preference_clients_head; NULL != cur; cur = cur->next) 1446 for (cur = preference_clients_head; NULL != cur; cur = cur->next)
1469 {
1470 if (cur->client == client) 1447 if (cur->client == client)
1471 return cur; 1448 return cur;
1472 }
1473 return NULL; 1449 return NULL;
1474} 1450}
1475 1451
@@ -1477,25 +1453,24 @@ find_preference_client (struct GAS_Addresses_Handle *handle, void *client)
1477/** 1453/**
1478 * A performance client disconnected 1454 * A performance client disconnected
1479 * 1455 *
1480 * @param handle address handle
1481 * @param client the client 1456 * @param client the client
1482 */ 1457 */
1483void 1458void
1484GAS_addresses_preference_client_disconnect (struct GAS_Addresses_Handle *handle, 1459GAS_addresses_preference_client_disconnect (void *client)
1485 void *client)
1486{ 1460{
1487 struct GAS_Addresses_Preference_Clients *pc; 1461 struct GAS_Addresses_Preference_Clients *pc;
1488 1462
1489 if (NULL != (pc = find_preference_client (handle, client))) 1463 if (NULL != (pc = find_preference_client (client)))
1490 { 1464 {
1491 GNUNET_CONTAINER_DLL_remove (handle->preference_clients_head, 1465 GNUNET_CONTAINER_DLL_remove (preference_clients_head,
1492 handle->preference_clients_tail, pc); 1466 preference_clients_tail,
1467 pc);
1493 GNUNET_free (pc); 1468 GNUNET_free (pc);
1494 GNUNET_assert (handle->pref_clients > 0); 1469 GNUNET_assert (pref_clients > 0);
1495 handle->pref_clients --; 1470 pref_clients --;
1496 GNUNET_STATISTICS_set (handle->stat, 1471 GNUNET_STATISTICS_set (stats,
1497 "# active performance clients", 1472 "# active performance clients",
1498 handle->pref_clients, 1473 pref_clients,
1499 GNUNET_NO); 1474 GNUNET_NO);
1500 } 1475 }
1501 GAS_normalization_preference_client_disconnect (client); 1476 GAS_normalization_preference_client_disconnect (client);
@@ -1505,16 +1480,16 @@ GAS_addresses_preference_client_disconnect (struct GAS_Addresses_Handle *handle,
1505/** 1480/**
1506 * Change the preference for a peer 1481 * Change the preference for a peer
1507 * 1482 *
1508 * @param handle the address handle
1509 * @param client the client sending this request 1483 * @param client the client sending this request
1510 * @param peer the peer id 1484 * @param peer the peer id
1511 * @param kind the preference kind to change 1485 * @param kind the preference kind to change
1512 * @param score_abs the new preference score 1486 * @param score_abs the new preference score
1513 */ 1487 */
1514void 1488void
1515GAS_addresses_preference_change (struct GAS_Addresses_Handle *handle, 1489GAS_addresses_preference_change (void *client,
1516 void *client, const struct GNUNET_PeerIdentity *peer, 1490 const struct GNUNET_PeerIdentity *peer,
1517 enum GNUNET_ATS_PreferenceKind kind, float score_abs) 1491 enum GNUNET_ATS_PreferenceKind kind,
1492 float score_abs)
1518{ 1493{
1519 struct GAS_Addresses_Preference_Clients *pc; 1494 struct GAS_Addresses_Preference_Clients *pc;
1520 1495
@@ -1522,11 +1497,11 @@ GAS_addresses_preference_change (struct GAS_Addresses_Handle *handle,
1522 "Received `%s' for peer `%s' for client %p\n", "CHANGE PREFERENCE", 1497 "Received `%s' for peer `%s' for client %p\n", "CHANGE PREFERENCE",
1523 GNUNET_i2s (peer), client); 1498 GNUNET_i2s (peer), client);
1524 1499
1525 if (GNUNET_NO == handle->running) 1500 if (GNUNET_NO == running)
1526 return; 1501 return;
1527 1502
1528 if (GNUNET_NO == 1503 if (GNUNET_NO ==
1529 GNUNET_CONTAINER_multipeermap_contains (handle->addresses, 1504 GNUNET_CONTAINER_multipeermap_contains (addresses,
1530 peer)) 1505 peer))
1531 { 1506 {
1532 GNUNET_log(GNUNET_ERROR_TYPE_DEBUG, 1507 GNUNET_log(GNUNET_ERROR_TYPE_DEBUG,
@@ -1535,30 +1510,30 @@ GAS_addresses_preference_change (struct GAS_Addresses_Handle *handle,
1535 return; 1510 return;
1536 } 1511 }
1537 1512
1538 if (NULL == find_preference_client (handle, client)) 1513 if (NULL == find_preference_client (client))
1539 { 1514 {
1540 pc = GNUNET_new (struct GAS_Addresses_Preference_Clients); 1515 pc = GNUNET_new (struct GAS_Addresses_Preference_Clients);
1541 pc->client = client; 1516 pc->client = client;
1542 GNUNET_CONTAINER_DLL_insert (handle->preference_clients_head, 1517 GNUNET_CONTAINER_DLL_insert (preference_clients_head,
1543 handle->preference_clients_tail, pc); 1518 preference_clients_tail,
1544 handle->pref_clients ++; 1519 pc);
1545 GNUNET_STATISTICS_set (handle->stat, 1520 pref_clients ++;
1521 GNUNET_STATISTICS_set (stats,
1546 "# active performance clients", 1522 "# active performance clients",
1547 handle->pref_clients, 1523 pref_clients,
1548 GNUNET_NO); 1524 GNUNET_NO);
1549 } 1525 }
1550 1526
1551 handle->env.sf.s_bulk_start (handle->solver); 1527 env.sf.s_bulk_start (solver);
1552 /* Tell normalization about change, normalization will call callback if preference changed */ 1528 /* Tell normalization about change, normalization will call callback if preference changed */
1553 GAS_normalization_normalize_preference (client, peer, kind, score_abs); 1529 GAS_normalization_normalize_preference (client, peer, kind, score_abs);
1554 handle->env.sf.s_bulk_stop (handle->solver); 1530 env.sf.s_bulk_stop (solver);
1555} 1531}
1556 1532
1557 1533
1558/** 1534/**
1559 * Change the preference for a peer 1535 * Change the preference for a peer
1560 * 1536 *
1561 * @param handle the address handle
1562 * @param application the client sending this request 1537 * @param application the client sending this request
1563 * @param peer the peer id 1538 * @param peer the peer id
1564 * @param scope the time interval for this feedback: [now - scope .. now] 1539 * @param scope the time interval for this feedback: [now - scope .. now]
@@ -1566,8 +1541,7 @@ GAS_addresses_preference_change (struct GAS_Addresses_Handle *handle,
1566 * @param score_abs the new preference score 1541 * @param score_abs the new preference score
1567 */ 1542 */
1568void 1543void
1569GAS_addresses_preference_feedback (struct GAS_Addresses_Handle *handle, 1544GAS_addresses_preference_feedback (void *application,
1570 void *application,
1571 const struct GNUNET_PeerIdentity *peer, 1545 const struct GNUNET_PeerIdentity *peer,
1572 const struct GNUNET_TIME_Relative scope, 1546 const struct GNUNET_TIME_Relative scope,
1573 enum GNUNET_ATS_PreferenceKind kind, 1547 enum GNUNET_ATS_PreferenceKind kind,
@@ -1579,11 +1553,11 @@ GAS_addresses_preference_feedback (struct GAS_Addresses_Handle *handle,
1579 GNUNET_i2s (peer), 1553 GNUNET_i2s (peer),
1580 application); 1554 application);
1581 1555
1582 if (GNUNET_NO == handle->running) 1556 if (GNUNET_NO == running)
1583 return; 1557 return;
1584 1558
1585 if (GNUNET_NO == 1559 if (GNUNET_NO ==
1586 GNUNET_CONTAINER_multipeermap_contains (handle->addresses, 1560 GNUNET_CONTAINER_multipeermap_contains (addresses,
1587 peer)) 1561 peer))
1588 { 1562 {
1589 GNUNET_log(GNUNET_ERROR_TYPE_DEBUG, 1563 GNUNET_log(GNUNET_ERROR_TYPE_DEBUG,
@@ -1592,8 +1566,8 @@ GAS_addresses_preference_feedback (struct GAS_Addresses_Handle *handle,
1592 return; 1566 return;
1593 } 1567 }
1594 1568
1595 handle->env.sf.s_feedback (handle->solver, application, peer, scope, kind, 1569 env.sf.s_feedback (solver, application, peer, scope, kind,
1596 score_abs); 1570 score_abs);
1597} 1571}
1598 1572
1599 1573
@@ -1739,18 +1713,16 @@ load_quotas (const struct GNUNET_CONFIGURATION_Handle *cfg,
1739/** 1713/**
1740 * Callback for solver to notify about assignment changes 1714 * Callback for solver to notify about assignment changes
1741 * 1715 *
1742 * @param cls the GAS_Addresses_Handle 1716 * @param cls NULL
1743 * @param address the address with changes 1717 * @param address the address with changes
1744 */ 1718 */
1745static void 1719static void
1746bandwidth_changed_cb (void *cls, struct ATS_Address *address) 1720bandwidth_changed_cb (void *cls, struct ATS_Address *address)
1747{ 1721{
1748 struct GAS_Addresses_Handle *handle = cls;
1749 struct GAS_Addresses_Suggestion_Requests *cur; 1722 struct GAS_Addresses_Suggestion_Requests *cur;
1750 uint32_t diff_out; 1723 uint32_t diff_out;
1751 uint32_t diff_in; 1724 uint32_t diff_in;
1752 1725
1753 GNUNET_assert(handle != NULL);
1754 GNUNET_assert(address != NULL); 1726 GNUNET_assert(address != NULL);
1755 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, 1727 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
1756 "Bandwidth assignment changed for peer %s \n", 1728 "Bandwidth assignment changed for peer %s \n",
@@ -1763,13 +1735,9 @@ bandwidth_changed_cb (void *cls, struct ATS_Address *address)
1763 GNUNET_BANDWIDTH_value_init (address->assigned_bw_out), 1735 GNUNET_BANDWIDTH_value_init (address->assigned_bw_out),
1764 GNUNET_BANDWIDTH_value_init (address->assigned_bw_in)); 1736 GNUNET_BANDWIDTH_value_init (address->assigned_bw_in));
1765 1737
1766 cur = handle->pending_requests_head; 1738 for (cur = pending_requests_head;NULL != cur; cur = cur->next)
1767 while (NULL != cur)
1768 {
1769 if (0 == memcmp (&address->peer, &cur->id, sizeof(cur->id))) 1739 if (0 == memcmp (&address->peer, &cur->id, sizeof(cur->id)))
1770 break; /* we have an address request pending*/ 1740 break; /* we have an address request pending*/
1771 cur = cur->next;
1772 }
1773 if (NULL == cur) 1741 if (NULL == cur)
1774 { 1742 {
1775 GNUNET_log(GNUNET_ERROR_TYPE_INFO, 1743 GNUNET_log(GNUNET_ERROR_TYPE_INFO,
@@ -1823,28 +1791,25 @@ bandwidth_changed_cb (void *cls, struct ATS_Address *address)
1823 * and receives updates when the solver changes the resource allocation. 1791 * and receives updates when the solver changes the resource allocation.
1824 * 1792 *
1825 * @param cfg configuration to use 1793 * @param cfg configuration to use
1826 * @param stats the statistics handle to use 1794 * @param stats_ the statistics handle to use
1827 * @return an address handle 1795 * @return #GNUNET_OK on success, #GNUNET_SYSERR on error (failed to load
1796 * solver plugin)
1828 */ 1797 */
1829struct GAS_Addresses_Handle * 1798int
1830GAS_addresses_init (const struct GNUNET_CONFIGURATION_Handle *cfg, 1799GAS_addresses_init (const struct GNUNET_CONFIGURATION_Handle *cfg,
1831 struct GNUNET_STATISTICS_Handle *stats) 1800 struct GNUNET_STATISTICS_Handle *stats_)
1832{ 1801{
1833 struct GAS_Addresses_Handle *ah;
1834 unsigned long long quotas_in[GNUNET_ATS_NetworkTypeCount]; 1802 unsigned long long quotas_in[GNUNET_ATS_NetworkTypeCount];
1835 unsigned long long quotas_out[GNUNET_ATS_NetworkTypeCount]; 1803 unsigned long long quotas_out[GNUNET_ATS_NetworkTypeCount];
1836 char *mode_str; 1804 char *mode_str;
1837 char *plugin_short; 1805 char *plugin_short;
1838 int c; 1806 int c;
1839 1807
1840 ah = GNUNET_new (struct GAS_Addresses_Handle); 1808 running = GNUNET_NO;
1841 ah->running = GNUNET_NO; 1809 stats = stats_;
1842
1843 ah->stat = stats;
1844 /* Initialize the addresses database */ 1810 /* Initialize the addresses database */
1845 ah->addresses = GNUNET_CONTAINER_multipeermap_create (128, GNUNET_NO); 1811 addresses = GNUNET_CONTAINER_multipeermap_create (128, GNUNET_NO);
1846 ah->pref_clients = 0; 1812 pref_clients = 0;
1847 GNUNET_assert(NULL != ah->addresses);
1848 1813
1849 /* Figure out configured solution method */ 1814 /* Figure out configured solution method */
1850 if (GNUNET_SYSERR == 1815 if (GNUNET_SYSERR ==
@@ -1852,59 +1817,59 @@ GAS_addresses_init (const struct GNUNET_CONFIGURATION_Handle *cfg,
1852 { 1817 {
1853 GNUNET_log(GNUNET_ERROR_TYPE_WARNING, 1818 GNUNET_log(GNUNET_ERROR_TYPE_WARNING,
1854 "No resource assignment method configured, using proportional approach\n"); 1819 "No resource assignment method configured, using proportional approach\n");
1855 ah->ats_mode = MODE_PROPORTIONAL; 1820 ats_mode = MODE_PROPORTIONAL;
1856 } 1821 }
1857 else 1822 else
1858 { 1823 {
1859 for (c = 0; c < strlen (mode_str); c++) 1824 for (c = 0; c < strlen (mode_str); c++)
1860 mode_str[c] = toupper (mode_str[c]); 1825 mode_str[c] = toupper (mode_str[c]);
1861 if (0 == strcmp (mode_str, "PROPORTIONAL")) 1826 if (0 == strcmp (mode_str, "PROPORTIONAL"))
1862 ah->ats_mode = MODE_PROPORTIONAL; 1827 ats_mode = MODE_PROPORTIONAL;
1863 else if (0 == strcmp (mode_str, "MLP")) 1828 else if (0 == strcmp (mode_str, "MLP"))
1864 { 1829 {
1865 ah->ats_mode = MODE_MLP; 1830 ats_mode = MODE_MLP;
1866#if !HAVE_LIBGLPK 1831#if !HAVE_LIBGLPK
1867 GNUNET_log(GNUNET_ERROR_TYPE_ERROR, 1832 GNUNET_log(GNUNET_ERROR_TYPE_ERROR,
1868 "Assignment method `%s' configured, but GLPK is not available, please install \n", 1833 "Assignment method `%s' configured, but GLPK is not available, please install \n",
1869 mode_str); 1834 mode_str);
1870 ah->ats_mode = MODE_PROPORTIONAL; 1835 ats_mode = MODE_PROPORTIONAL;
1871#endif 1836#endif
1872 } 1837 }
1873 else if (0 == strcmp (mode_str, "RIL")) 1838 else if (0 == strcmp (mode_str, "RIL"))
1874 ah->ats_mode = MODE_RIL; 1839 ats_mode = MODE_RIL;
1875 else 1840 else
1876 { 1841 {
1877 GNUNET_log(GNUNET_ERROR_TYPE_ERROR, 1842 GNUNET_log(GNUNET_ERROR_TYPE_ERROR,
1878 "Invalid resource assignment method `%s' configured, using proportional approach\n", 1843 "Invalid resource assignment method `%s' configured, using proportional approach\n",
1879 mode_str); 1844 mode_str);
1880 ah->ats_mode = MODE_PROPORTIONAL; 1845 ats_mode = MODE_PROPORTIONAL;
1881 } 1846 }
1882 GNUNET_free(mode_str); 1847 GNUNET_free(mode_str);
1883 } 1848 }
1884 1849
1885 load_quotas (cfg, quotas_out, quotas_in, GNUNET_ATS_NetworkTypeCount); 1850 load_quotas (cfg, quotas_out, quotas_in, GNUNET_ATS_NetworkTypeCount);
1886 ah->env.info_cb = &solver_info_cb; 1851 env.info_cb = &solver_info_cb;
1887 ah->env.info_cb_cls = ah; 1852 env.info_cb_cls = NULL;
1888 ah->env.bandwidth_changed_cb = &bandwidth_changed_cb; 1853 env.bandwidth_changed_cb = &bandwidth_changed_cb;
1889 ah->env.bw_changed_cb_cls = ah; 1854 env.bw_changed_cb_cls = NULL;
1890 ah->env.get_preferences = &get_preferences_cb; 1855 env.get_preferences = &get_preferences_cb;
1891 ah->env.get_preference_cls = ah; 1856 env.get_preference_cls = NULL;
1892 ah->env.get_property = &get_property_cb; 1857 env.get_property = &get_property_cb;
1893 ah->env.get_property_cls = ah; 1858 env.get_property_cls = NULL;
1894 ah->env.cfg = cfg; 1859 env.cfg = cfg;
1895 ah->env.stats = stats; 1860 env.stats = stats;
1896 ah->env.addresses = ah->addresses; 1861 env.addresses = addresses;
1897 1862
1898 ah->env.network_count = GNUNET_ATS_NetworkTypeCount; 1863 env.network_count = GNUNET_ATS_NetworkTypeCount;
1899 int networks[GNUNET_ATS_NetworkTypeCount] = GNUNET_ATS_NetworkType; 1864 int networks[GNUNET_ATS_NetworkTypeCount] = GNUNET_ATS_NetworkType;
1900 for (c = 0; c < GNUNET_ATS_NetworkTypeCount; c++) 1865 for (c = 0; c < GNUNET_ATS_NetworkTypeCount; c++)
1901 { 1866 {
1902 ah->env.networks[c] = networks[c]; 1867 env.networks[c] = networks[c];
1903 ah->env.out_quota[c] = quotas_out[c]; 1868 env.out_quota[c] = quotas_out[c];
1904 ah->env.in_quota[c] = quotas_in[c]; 1869 env.in_quota[c] = quotas_in[c];
1905 } 1870 }
1906 1871
1907 switch (ah->ats_mode) { 1872 switch (ats_mode) {
1908 case MODE_PROPORTIONAL: 1873 case MODE_PROPORTIONAL:
1909 plugin_short = "proportional"; 1874 plugin_short = "proportional";
1910 break; 1875 break;
@@ -1918,54 +1883,53 @@ GAS_addresses_init (const struct GNUNET_CONFIGURATION_Handle *cfg,
1918 plugin_short = NULL; 1883 plugin_short = NULL;
1919 break; 1884 break;
1920 } 1885 }
1921 GNUNET_asprintf (&ah->plugin, 1886 GNUNET_asprintf (&plugin,
1922 "libgnunet_plugin_ats_%s", 1887 "libgnunet_plugin_ats_%s",
1923 plugin_short); 1888 plugin_short);
1924 GNUNET_log(GNUNET_ERROR_TYPE_INFO, 1889 GNUNET_log(GNUNET_ERROR_TYPE_INFO,
1925 _("Initializing solver `%s '`%s'\n"), 1890 _("Initializing solver `%s '`%s'\n"),
1926 plugin_short, 1891 plugin_short,
1927 ah->plugin); 1892 plugin);
1928 if (NULL == (ah->solver = GNUNET_PLUGIN_load (ah->plugin, &ah->env))) 1893 if (NULL == (solver = GNUNET_PLUGIN_load (plugin, &env)))
1929 { 1894 {
1930 GNUNET_log (GNUNET_ERROR_TYPE_ERROR, 1895 GNUNET_log (GNUNET_ERROR_TYPE_ERROR,
1931 _("Failed to initialize solver `%s'!\n"), 1896 _("Failed to initialize solver `%s'!\n"),
1932 ah->plugin); 1897 plugin);
1933 return NULL; 1898 return GNUNET_SYSERR;
1934 } 1899 }
1935 1900
1936 GNUNET_assert (NULL != ah->env.sf.s_add); 1901 GNUNET_assert (NULL != env.sf.s_add);
1937 GNUNET_assert (NULL != ah->env.sf.s_address_update_inuse); 1902 GNUNET_assert (NULL != env.sf.s_address_update_inuse);
1938 GNUNET_assert (NULL != ah->env.sf.s_address_update_property); 1903 GNUNET_assert (NULL != env.sf.s_address_update_property);
1939 GNUNET_assert (NULL != ah->env.sf.s_address_update_session); 1904 GNUNET_assert (NULL != env.sf.s_address_update_session);
1940 GNUNET_assert (NULL != ah->env.sf.s_address_update_network); 1905 GNUNET_assert (NULL != env.sf.s_address_update_network);
1941 GNUNET_assert (NULL != ah->env.sf.s_get); 1906 GNUNET_assert (NULL != env.sf.s_get);
1942 GNUNET_assert (NULL != ah->env.sf.s_get_stop); 1907 GNUNET_assert (NULL != env.sf.s_get_stop);
1943 GNUNET_assert (NULL != ah->env.sf.s_pref); 1908 GNUNET_assert (NULL != env.sf.s_pref);
1944 GNUNET_assert (NULL != ah->env.sf.s_feedback); 1909 GNUNET_assert (NULL != env.sf.s_feedback);
1945 GNUNET_assert (NULL != ah->env.sf.s_del); 1910 GNUNET_assert (NULL != env.sf.s_del);
1946 GNUNET_assert (NULL != ah->env.sf.s_bulk_start); 1911 GNUNET_assert (NULL != env.sf.s_bulk_start);
1947 GNUNET_assert (NULL != ah->env.sf.s_bulk_stop); 1912 GNUNET_assert (NULL != env.sf.s_bulk_stop);
1948 1913
1949 1914
1950 GAS_normalization_start (&normalized_preference_changed_cb, ah, 1915 GAS_normalization_start (&normalized_preference_changed_cb, NULL,
1951 &normalized_property_changed_cb, ah); 1916 &normalized_property_changed_cb, NULL);
1952 1917
1953 if (NULL == ah->solver) 1918 if (NULL == solver)
1954 { 1919 {
1955 GNUNET_log (GNUNET_ERROR_TYPE_ERROR, 1920 GNUNET_log (GNUNET_ERROR_TYPE_ERROR,
1956 _("Failed to initialize solver!\n")); 1921 _("Failed to initialize solver!\n"));
1957 GNUNET_free(ah); 1922 return GNUNET_SYSERR;
1958 return NULL ;
1959 } 1923 }
1960 /* up and running */ 1924 /* up and running */
1961 ah->running = GNUNET_YES; 1925 running = GNUNET_YES;
1962 1926
1963 GNUNET_STATISTICS_set (ah->stat, 1927 GNUNET_STATISTICS_set (stats,
1964 "# addresses", 1928 "# addresses",
1965 GNUNET_CONTAINER_multipeermap_size (ah->addresses), 1929 GNUNET_CONTAINER_multipeermap_size (addresses),
1966 GNUNET_NO); 1930 GNUNET_NO);
1967 1931
1968 return ah; 1932 return GNUNET_OK;
1969} 1933}
1970 1934
1971 1935
@@ -1982,14 +1946,15 @@ destroy_all_address_it (void *cls,
1982 const struct GNUNET_PeerIdentity *key, 1946 const struct GNUNET_PeerIdentity *key,
1983 void *value) 1947 void *value)
1984{ 1948{
1985 struct GAS_Addresses_Handle *handle = cls;
1986 struct ATS_Address *aa = value; 1949 struct ATS_Address *aa = value;
1987 1950
1988 /* Remove */ 1951 /* Remove */
1989 GNUNET_assert(GNUNET_YES == 1952 GNUNET_assert(GNUNET_YES ==
1990 GNUNET_CONTAINER_multipeermap_remove (handle->addresses, key, value)); 1953 GNUNET_CONTAINER_multipeermap_remove (addresses,
1954 key,
1955 value));
1991 /* Notify */ 1956 /* Notify */
1992 handle->env.sf.s_del (handle->solver, aa, GNUNET_NO); 1957 env.sf.s_del (solver, aa, GNUNET_NO);
1993 /* Destroy */ 1958 /* Destroy */
1994 GAS_performance_notify_all_clients (&aa->peer, 1959 GAS_performance_notify_all_clients (&aa->peer,
1995 aa->plugin, 1960 aa->plugin,
@@ -2006,68 +1971,63 @@ destroy_all_address_it (void *cls,
2006 1971
2007/** 1972/**
2008 * Remove all addresses 1973 * Remove all addresses
2009 *
2010 * @param handle the address handle to use
2011 */ 1974 */
2012void 1975void
2013GAS_addresses_destroy_all (struct GAS_Addresses_Handle *handle) 1976GAS_addresses_destroy_all ()
2014{ 1977{
2015 if (GNUNET_NO == handle->running) 1978 if (GNUNET_NO == running)
2016 return; 1979 return;
2017 1980
2018 GNUNET_log (GNUNET_ERROR_TYPE_INFO, 1981 GNUNET_log (GNUNET_ERROR_TYPE_INFO,
2019 "Destroying all addresses\n"); 1982 "Destroying all addresses\n");
2020 handle->env.sf.s_bulk_start (handle->solver); 1983 env.sf.s_bulk_start (solver);
2021 if (NULL != handle->addresses) 1984 if (NULL != addresses)
2022 GNUNET_CONTAINER_multipeermap_iterate (handle->addresses, 1985 GNUNET_CONTAINER_multipeermap_iterate (addresses,
2023 &destroy_all_address_it, 1986 &destroy_all_address_it,
2024 handle); 1987 NULL);
2025 handle->env.sf.s_bulk_start (handle->solver); 1988 env.sf.s_bulk_start (solver);
2026} 1989}
2027 1990
2028 1991
2029/** 1992/**
2030 * Shutdown address subsystem. 1993 * Shutdown address subsystem.
2031 *
2032 * @param handle the address handle to shutdown
2033 */ 1994 */
2034void 1995void
2035GAS_addresses_done (struct GAS_Addresses_Handle *handle) 1996GAS_addresses_done ()
2036{ 1997{
2037 struct GAS_Addresses_Suggestion_Requests *cur; 1998 struct GAS_Addresses_Suggestion_Requests *cur;
2038 struct GAS_Addresses_Preference_Clients *pcur; 1999 struct GAS_Addresses_Preference_Clients *pcur;
2039 2000
2040 GNUNET_log(GNUNET_ERROR_TYPE_INFO, "Shutting down addresses\n"); 2001 GNUNET_log(GNUNET_ERROR_TYPE_INFO,
2041 GNUNET_assert(NULL != handle); 2002 "Shutting down addresses\n");
2042 GAS_addresses_destroy_all (handle); 2003 GAS_addresses_destroy_all ();
2043 handle->running = GNUNET_NO; 2004 running = GNUNET_NO;
2044 GNUNET_CONTAINER_multipeermap_destroy (handle->addresses); 2005 GNUNET_CONTAINER_multipeermap_destroy (addresses);
2045 handle->addresses = NULL; 2006 addresses = NULL;
2046 while (NULL != (cur = handle->pending_requests_head)) 2007 while (NULL != (cur = pending_requests_head))
2047 { 2008 {
2048 GNUNET_CONTAINER_DLL_remove (handle->pending_requests_head, 2009 GNUNET_CONTAINER_DLL_remove (pending_requests_head,
2049 handle->pending_requests_tail, 2010 pending_requests_tail,
2050 cur); 2011 cur);
2051 GNUNET_free(cur); 2012 GNUNET_free(cur);
2052 } 2013 }
2053 2014
2054 while (NULL != (pcur = handle->preference_clients_head)) 2015 while (NULL != (pcur = preference_clients_head))
2055 { 2016 {
2056 GNUNET_CONTAINER_DLL_remove (handle->preference_clients_head, 2017 GNUNET_CONTAINER_DLL_remove (preference_clients_head,
2057 handle->preference_clients_tail, 2018 preference_clients_tail,
2058 pcur); 2019 pcur);
2059 GNUNET_assert (handle->pref_clients > 0); 2020 GNUNET_assert (pref_clients > 0);
2060 handle->pref_clients --; 2021 pref_clients --;
2061 GNUNET_STATISTICS_set (handle->stat, 2022 GNUNET_STATISTICS_set (stats,
2062 "# active performance clients", 2023 "# active performance clients",
2063 handle->pref_clients, 2024 pref_clients,
2064 GNUNET_NO); 2025 GNUNET_NO);
2065 GNUNET_free (pcur); 2026 GNUNET_free (pcur);
2066 } 2027 }
2067 GNUNET_PLUGIN_unload (handle->plugin, 2028 GNUNET_PLUGIN_unload (plugin,
2068 handle->solver); 2029 solver);
2069 GNUNET_free (handle->plugin); 2030 GNUNET_free (plugin);
2070 GNUNET_free(handle);
2071 /* Stop configured solution method */ 2031 /* Stop configured solution method */
2072 GAS_normalization_stop (); 2032 GAS_normalization_stop ();
2073} 2033}
@@ -2122,14 +2082,12 @@ peerinfo_it (void *cls,
2122/** 2082/**
2123 * Return information all peers currently known to ATS 2083 * Return information all peers currently known to ATS
2124 * 2084 *
2125 * @param handle the address handle to use
2126 * @param peer the respective peer, NULL for 'all' peers 2085 * @param peer the respective peer, NULL for 'all' peers
2127 * @param pi_it the iterator to call for every peer 2086 * @param pi_it the iterator to call for every peer
2128 * @param pi_it_cls the closure for @a pi_it 2087 * @param pi_it_cls the closure for @a pi_it
2129 */ 2088 */
2130void 2089void
2131GAS_addresses_get_peer_info (struct GAS_Addresses_Handle *handle, 2090GAS_addresses_get_peer_info (const struct GNUNET_PeerIdentity *peer,
2132 const struct GNUNET_PeerIdentity *peer,
2133 GNUNET_ATS_PeerInfo_Iterator pi_it, 2091 GNUNET_ATS_PeerInfo_Iterator pi_it,
2134 void *pi_it_cls) 2092 void *pi_it_cls)
2135{ 2093{
@@ -2146,15 +2104,15 @@ GAS_addresses_get_peer_info (struct GAS_Addresses_Handle *handle,
2146 (NULL == peer) 2104 (NULL == peer)
2147 ? "all peers" 2105 ? "all peers"
2148 : GNUNET_i2s (peer), 2106 : GNUNET_i2s (peer),
2149 (unsigned int) GNUNET_CONTAINER_multipeermap_size (handle->addresses)); 2107 (unsigned int) GNUNET_CONTAINER_multipeermap_size (addresses));
2150 pi_ctx.it = pi_it; 2108 pi_ctx.it = pi_it;
2151 pi_ctx.it_cls = pi_it_cls; 2109 pi_ctx.it_cls = pi_it_cls;
2152 if (NULL == peer) 2110 if (NULL == peer)
2153 GNUNET_CONTAINER_multipeermap_iterate (handle->addresses, 2111 GNUNET_CONTAINER_multipeermap_iterate (addresses,
2154 &peerinfo_it, 2112 &peerinfo_it,
2155 &pi_ctx); 2113 &pi_ctx);
2156 else 2114 else
2157 GNUNET_CONTAINER_multipeermap_get_multiple (handle->addresses, 2115 GNUNET_CONTAINER_multipeermap_get_multiple (addresses,
2158 peer, 2116 peer,
2159 &peerinfo_it, &pi_ctx); 2117 &peerinfo_it, &pi_ctx);
2160 pi_it (pi_it_cls, 2118 pi_it (pi_it_cls,
diff --git a/src/ats/gnunet-service-ats_addresses.h b/src/ats/gnunet-service-ats_addresses.h
index ee599721d..2f21ae380 100644
--- a/src/ats/gnunet-service-ats_addresses.h
+++ b/src/ats/gnunet-service-ats_addresses.h
@@ -408,11 +408,6 @@ struct ATS_Address
408 408
409 409
410/** 410/**
411 * Handle for ATS address component
412 */
413struct GAS_Addresses_Handle;
414
415/**
416 * Initialize address subsystem. The addresses subsystem manages the addresses 411 * Initialize address subsystem. The addresses subsystem manages the addresses
417 * known and current performance information. It has a solver component 412 * known and current performance information. It has a solver component
418 * responsible for the resource allocation. It tells the solver about changes 413 * responsible for the resource allocation. It tells the solver about changes
@@ -420,26 +415,24 @@ struct GAS_Addresses_Handle;
420 * 415 *
421 * @param cfg configuration to use 416 * @param cfg configuration to use
422 * @param stats the statistics handle to use 417 * @param stats the statistics handle to use
423 * @return an address handle 418 * @return #GNUNET_OK on success, #GNUNET_SYSERR on error (failed to load
419 * solver plugin)
424 */ 420 */
425struct GAS_Addresses_Handle * 421int
426GAS_addresses_init (const struct GNUNET_CONFIGURATION_Handle *cfg, 422GAS_addresses_init (const struct GNUNET_CONFIGURATION_Handle *cfg,
427 struct GNUNET_STATISTICS_Handle *stats); 423 struct GNUNET_STATISTICS_Handle *stats);
428 424
429 425
430/** 426/**
431 * Shutdown address subsystem. 427 * Shutdown address subsystem.
432 *
433 * @param handle the address handle to shutdown
434 */ 428 */
435void 429void
436GAS_addresses_done (struct GAS_Addresses_Handle *handle); 430GAS_addresses_done (void);
437 431
438 432
439/** 433/**
440 * Add a new address for a peer. 434 * Add a new address for a peer.
441 * 435 *
442 * @param handle the address handle to use
443 * @param peer peer 436 * @param peer peer
444 * @param plugin_name transport plugin name 437 * @param plugin_name transport plugin name
445 * @param plugin_addr plugin address 438 * @param plugin_addr plugin address
@@ -450,8 +443,7 @@ GAS_addresses_done (struct GAS_Addresses_Handle *handle);
450 * @param atsi_count number of performance information contained in @a atsi 443 * @param atsi_count number of performance information contained in @a atsi
451 */ 444 */
452void 445void
453GAS_addresses_add (struct GAS_Addresses_Handle *handle, 446GAS_addresses_add (const struct GNUNET_PeerIdentity *peer,
454 const struct GNUNET_PeerIdentity *peer,
455 const char *plugin_name, 447 const char *plugin_name,
456 const void *plugin_addr, 448 const void *plugin_addr,
457 size_t plugin_addr_len, 449 size_t plugin_addr_len,
@@ -471,15 +463,13 @@ GAS_addresses_add (struct GAS_Addresses_Handle *handle,
471 * Note: can only be called with in_use == #GNUNET_NO if called with #GNUNET_YES 463 * Note: can only be called with in_use == #GNUNET_NO if called with #GNUNET_YES
472 * before 464 * before
473 * 465 *
474 * @param handle the address handle to use
475 * @param peer peer 466 * @param peer peer
476 * @param session_id session id, can never be 0 467 * @param session_id session id, can never be 0
477 * @param in_use #GNUNET_YES if #GNUNET_NO FIXME 468 * @param in_use #GNUNET_YES if #GNUNET_NO FIXME
478 * @return #GNUNET_SYSERR on failure (address unknown ...) 469 * @return #GNUNET_SYSERR on failure (address unknown ...)
479 */ 470 */
480int 471int
481GAS_addresses_in_use (struct GAS_Addresses_Handle *handle, 472GAS_addresses_in_use (const struct GNUNET_PeerIdentity *peer,
482 const struct GNUNET_PeerIdentity *peer,
483 uint32_t session_id, 473 uint32_t session_id,
484 int in_use); 474 int in_use);
485 475
@@ -487,15 +477,13 @@ GAS_addresses_in_use (struct GAS_Addresses_Handle *handle,
487/** 477/**
488 * Update an address with new performance information for a peer. 478 * Update an address with new performance information for a peer.
489 * 479 *
490 * @param handle the address handle to use
491 * @param peer peer 480 * @param peer peer
492 * @param session_id session id, can never be 0 481 * @param session_id session id, can never be 0
493 * @param atsi performance information for this address 482 * @param atsi performance information for this address
494 * @param atsi_count number of performance information contained in @a atsi 483 * @param atsi_count number of performance information contained in @a atsi
495 */ 484 */
496void 485void
497GAS_addresses_update (struct GAS_Addresses_Handle *handle, 486GAS_addresses_update (const struct GNUNET_PeerIdentity *peer,
498 const struct GNUNET_PeerIdentity *peer,
499 uint32_t session_id, 487 uint32_t session_id,
500 const struct GNUNET_ATS_Information *atsi, 488 const struct GNUNET_ATS_Information *atsi,
501 uint32_t atsi_count); 489 uint32_t atsi_count);
@@ -504,45 +492,37 @@ GAS_addresses_update (struct GAS_Addresses_Handle *handle,
504/** 492/**
505 * Remove an address or just a session for a peer. 493 * Remove an address or just a session for a peer.
506 * 494 *
507 * @param handle the address handle to use
508 * @param peer peer 495 * @param peer peer
509 * @param session_id session id, can never be 0 496 * @param session_id session id, can never be 0
510 */ 497 */
511void 498void
512GAS_addresses_destroy (struct GAS_Addresses_Handle *handle, 499GAS_addresses_destroy (const struct GNUNET_PeerIdentity *peer,
513 const struct GNUNET_PeerIdentity *peer,
514 uint32_t session_id); 500 uint32_t session_id);
515 501
516 502
517/** 503/**
518 * Remove all addresses 504 * Remove all addresses
519 *
520 * @param handle the address handle to use
521 */ 505 */
522void 506void
523GAS_addresses_destroy_all (struct GAS_Addresses_Handle *handle); 507GAS_addresses_destroy_all (void);
524 508
525 509
526/** 510/**
527 * Request address suggestions for a peer 511 * Request address suggestions for a peer
528 * 512 *
529 * @param handle the address handle
530 * @param peer the peer id 513 * @param peer the peer id
531 */ 514 */
532void 515void
533GAS_addresses_request_address (struct GAS_Addresses_Handle *handle, 516GAS_addresses_request_address (const struct GNUNET_PeerIdentity *peer);
534 const struct GNUNET_PeerIdentity *peer);
535 517
536 518
537/** 519/**
538 * Cancel address suggestions for a peer 520 * Cancel address suggestions for a peer
539 * 521 *
540 * @param handle the address handle
541 * @param peer the peer id 522 * @param peer the peer id
542 */ 523 */
543void 524void
544GAS_addresses_request_address_cancel (struct GAS_Addresses_Handle *handle, 525GAS_addresses_request_address_cancel (const struct GNUNET_PeerIdentity *peer);
545 const struct GNUNET_PeerIdentity *peer);
546 526
547 527
548/** 528/**
@@ -551,37 +531,31 @@ GAS_addresses_request_address_cancel (struct GAS_Addresses_Handle *handle,
551 * Suggesting addresses is blocked for ATS_BLOCKING_DELTA. Blocking can be 531 * Suggesting addresses is blocked for ATS_BLOCKING_DELTA. Blocking can be
552 * reset using this function 532 * reset using this function
553 * 533 *
554 * @param handle the address handle
555 * @param peer the peer id 534 * @param peer the peer id
556 */ 535 */
557void 536void
558GAS_addresses_handle_backoff_reset (struct GAS_Addresses_Handle *handle, 537GAS_addresses_handle_backoff_reset (const struct GNUNET_PeerIdentity *peer);
559 const struct GNUNET_PeerIdentity *peer);
560 538
561 539
562/** 540/**
563 * A performance client disconnected 541 * A performance client disconnected
564 * 542 *
565 * @param handle address handle 543 * @param client the client; FIXME: type!?
566 * @param client the client
567 */ 544 */
568void 545void
569GAS_addresses_preference_client_disconnect (struct GAS_Addresses_Handle *handle, 546GAS_addresses_preference_client_disconnect (void *client);
570 void *client);
571 547
572 548
573/** 549/**
574 * Change the preference for a peer 550 * Change the preference for a peer
575 * 551 *
576 * @param handle the address handle 552 * @param client the client sending this request; FIXME: type!?
577 * @param client the client sending this request
578 * @param peer the peer id 553 * @param peer the peer id
579 * @param kind the preference kind to change 554 * @param kind the preference kind to change
580 * @param score_abs the new preference score 555 * @param score_abs the new preference score
581 */ 556 */
582void 557void
583GAS_addresses_preference_change (struct GAS_Addresses_Handle *handle, 558GAS_addresses_preference_change (void *client,
584 void *client,
585 const struct GNUNET_PeerIdentity *peer, 559 const struct GNUNET_PeerIdentity *peer,
586 enum GNUNET_ATS_PreferenceKind kind, 560 enum GNUNET_ATS_PreferenceKind kind,
587 float score_abs); 561 float score_abs);
@@ -598,16 +572,14 @@ GAS_addresses_preference_change (struct GAS_Addresses_Handle *handle,
598 * If the application has no feedback for this preference kind the application 572 * If the application has no feedback for this preference kind the application
599 * will not explicitly call. 573 * will not explicitly call.
600 * 574 *
601 * @param handle the address handle 575 * @param application the application sending this request; FIXME: type?
602 * @param application the application sending this request
603 * @param peer the peer id 576 * @param peer the peer id
604 * @param scope the time interval this valid for: [now - scope .. now] 577 * @param scope the time interval this valid for: [now - scope .. now]
605 * @param kind the preference kind this feedback is intended for 578 * @param kind the preference kind this feedback is intended for
606 * @param score_abs the new preference score 579 * @param score_abs the new preference score
607 */ 580 */
608void 581void
609GAS_addresses_preference_feedback (struct GAS_Addresses_Handle *handle, 582GAS_addresses_preference_feedback (void *application,
610 void *application,
611 const struct GNUNET_PeerIdentity *peer, 583 const struct GNUNET_PeerIdentity *peer,
612 const struct GNUNET_TIME_Relative scope, 584 const struct GNUNET_TIME_Relative scope,
613 enum GNUNET_ATS_PreferenceKind kind, 585 enum GNUNET_ATS_PreferenceKind kind,
@@ -644,14 +616,12 @@ typedef void
644/** 616/**
645 * Return information all peers currently known to ATS 617 * Return information all peers currently known to ATS
646 * 618 *
647 * @param handle the address handle to use
648 * @param peer the respective peer 619 * @param peer the respective peer
649 * @param pi_it the iterator to call for every peer 620 * @param pi_it the iterator to call for every peer
650 * @param pi_it_cls the closure for @a pi_it 621 * @param pi_it_cls the closure for @a pi_it
651 */ 622 */
652void 623void
653GAS_addresses_get_peer_info (struct GAS_Addresses_Handle *handle, 624GAS_addresses_get_peer_info (const struct GNUNET_PeerIdentity *peer,
654 const struct GNUNET_PeerIdentity *peer,
655 GNUNET_ATS_PeerInfo_Iterator pi_it, 625 GNUNET_ATS_PeerInfo_Iterator pi_it,
656 void *pi_it_cls); 626 void *pi_it_cls);
657 627
diff --git a/src/ats/gnunet-service-ats_performance.c b/src/ats/gnunet-service-ats_performance.c
index 2e205b982..e0a5cbdae 100644
--- a/src/ats/gnunet-service-ats_performance.c
+++ b/src/ats/gnunet-service-ats_performance.c
@@ -60,11 +60,6 @@ struct PerformanceClient
60 60
61 61
62/** 62/**
63 * Address handle
64 */
65static struct GAS_Addresses_Handle *GSA_addresses;
66
67/**
68 * Head of linked list of all clients to this service. 63 * Head of linked list of all clients to this service.
69 */ 64 */
70static struct PerformanceClient *pc_head; 65static struct PerformanceClient *pc_head;
@@ -113,7 +108,7 @@ GAS_performance_remove_client (struct GNUNET_SERVER_Client *client)
113 if (NULL == pc) 108 if (NULL == pc)
114 return; 109 return;
115 GNUNET_CONTAINER_DLL_remove (pc_head, pc_tail, pc); 110 GNUNET_CONTAINER_DLL_remove (pc_head, pc_tail, pc);
116 GAS_addresses_preference_client_disconnect (GSA_addresses, client); 111 GAS_addresses_preference_client_disconnect (client);
117 GNUNET_free (pc); 112 GNUNET_free (pc);
118} 113}
119 114
@@ -314,8 +309,7 @@ GAS_performance_add_client (struct GNUNET_SERVER_Client *client,
314 GNUNET_CONTAINER_DLL_insert (pc_head, 309 GNUNET_CONTAINER_DLL_insert (pc_head,
315 pc_tail, 310 pc_tail,
316 pc); 311 pc);
317 GAS_addresses_get_peer_info (GSA_addresses, 312 GAS_addresses_get_peer_info (NULL,
318 NULL,
319 &peerinfo_it, 313 &peerinfo_it,
320 pc); 314 pc);
321} 315}
@@ -528,16 +522,14 @@ GAS_handle_request_address_list (void *cls,
528 sizeof (struct GNUNET_PeerIdentity))) 522 sizeof (struct GNUNET_PeerIdentity)))
529 { 523 {
530 /* Return addresses for all peers */ 524 /* Return addresses for all peers */
531 GAS_addresses_get_peer_info (GSA_addresses, 525 GAS_addresses_get_peer_info (NULL,
532 NULL,
533 &req_addr_peerinfo_it, 526 &req_addr_peerinfo_it,
534 &ai); 527 &ai);
535 } 528 }
536 else 529 else
537 { 530 {
538 /* Return addresses for a specific peer */ 531 /* Return addresses for a specific peer */
539 GAS_addresses_get_peer_info (GSA_addresses, 532 GAS_addresses_get_peer_info (&alrm->peer,
540 &alrm->peer,
541 &req_addr_peerinfo_it, 533 &req_addr_peerinfo_it,
542 &ai); 534 &ai);
543 } 535 }
@@ -644,8 +636,7 @@ GAS_handle_preference_change (void *cls,
644 1, GNUNET_NO); 636 1, GNUNET_NO);
645 pi = (const struct PreferenceInformation *) &msg[1]; 637 pi = (const struct PreferenceInformation *) &msg[1];
646 for (i = 0; i < nump; i++) 638 for (i = 0; i < nump; i++)
647 GAS_addresses_preference_change (GSA_addresses, 639 GAS_addresses_preference_change (client,
648 client,
649 &msg->peer, 640 &msg->peer,
650 (enum GNUNET_ATS_PreferenceKind) 641 (enum GNUNET_ATS_PreferenceKind)
651 ntohl (pi[i].preference_kind), 642 ntohl (pi[i].preference_kind),
@@ -697,18 +688,16 @@ GAS_handle_preference_feedback (void *cls,
697 1, GNUNET_NO); 688 1, GNUNET_NO);
698 pi = (const struct PreferenceInformation *) &msg[1]; 689 pi = (const struct PreferenceInformation *) &msg[1];
699 for (i = 0; i < nump; i++) 690 for (i = 0; i < nump; i++)
700 GAS_addresses_preference_feedback (GSA_addresses, 691 GAS_addresses_preference_feedback (client,
701 client, 692 &msg->peer,
702 &msg->peer, 693 GNUNET_TIME_relative_ntoh(msg->scope),
703 GNUNET_TIME_relative_ntoh(msg->scope), 694 (enum GNUNET_ATS_PreferenceKind)
704 (enum GNUNET_ATS_PreferenceKind) 695 ntohl (pi[i].preference_kind),
705 ntohl (pi[i].preference_kind), 696 pi[i].preference_value);
706 pi[i].preference_value);
707 GNUNET_SERVER_receive_done (client, GNUNET_OK); 697 GNUNET_SERVER_receive_done (client, GNUNET_OK);
708} 698}
709 699
710 700
711
712/** 701/**
713 * Initialize performance subsystem. 702 * Initialize performance subsystem.
714 * 703 *
@@ -716,10 +705,8 @@ GAS_handle_preference_feedback (void *cls,
716 * @param addresses the address handle to use 705 * @param addresses the address handle to use
717 */ 706 */
718void 707void
719GAS_performance_init (struct GNUNET_SERVER_Handle *server, 708GAS_performance_init (struct GNUNET_SERVER_Handle *server)
720 struct GAS_Addresses_Handle *addresses)
721{ 709{
722 GSA_addresses = addresses;
723 nc = GNUNET_SERVER_notification_context_create (server, 128); 710 nc = GNUNET_SERVER_notification_context_create (server, 128);
724} 711}
725 712
diff --git a/src/ats/gnunet-service-ats_performance.h b/src/ats/gnunet-service-ats_performance.h
index 471b24751..b1903fe04 100644
--- a/src/ats/gnunet-service-ats_performance.h
+++ b/src/ats/gnunet-service-ats_performance.h
@@ -144,8 +144,7 @@ GAS_handle_monitor (void *cls,
144 * @param addresses the address handle to use 144 * @param addresses the address handle to use
145 */ 145 */
146void 146void
147GAS_performance_init (struct GNUNET_SERVER_Handle *server, 147GAS_performance_init (struct GNUNET_SERVER_Handle *server);
148 struct GAS_Addresses_Handle *GSA_addresses);
149 148
150 149
151/** 150/**
diff --git a/src/ats/gnunet-service-ats_scheduling.c b/src/ats/gnunet-service-ats_scheduling.c
index 90893c08a..c342525f7 100644
--- a/src/ats/gnunet-service-ats_scheduling.c
+++ b/src/ats/gnunet-service-ats_scheduling.c
@@ -41,11 +41,6 @@ static struct GNUNET_SERVER_NotificationContext *nc;
41 */ 41 */
42static struct GNUNET_SERVER_Client *my_client; 42static struct GNUNET_SERVER_Client *my_client;
43 43
44/**
45 * Handle to address subsystem
46 */
47static struct GAS_Addresses_Handle *address_handle;
48
49 44
50/** 45/**
51 * Register a new scheduling client. 46 * Register a new scheduling client.
@@ -79,7 +74,7 @@ GAS_scheduling_remove_client (struct GNUNET_SERVER_Client *client)
79{ 74{
80 if (my_client != client) 75 if (my_client != client)
81 return; 76 return;
82 GAS_addresses_destroy_all (address_handle); 77 GAS_addresses_destroy_all ();
83 my_client = NULL; 78 my_client = NULL;
84} 79}
85 80
@@ -142,7 +137,7 @@ GAS_handle_request_address (void *cls,
142 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Received `%s' message\n", 137 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Received `%s' message\n",
143 "REQUEST_ADDRESS"); 138 "REQUEST_ADDRESS");
144 GNUNET_break (0 == ntohl (msg->reserved)); 139 GNUNET_break (0 == ntohl (msg->reserved));
145 GAS_addresses_request_address (address_handle, &msg->peer); 140 GAS_addresses_request_address (&msg->peer);
146 GNUNET_SERVER_receive_done (client, GNUNET_OK); 141 GNUNET_SERVER_receive_done (client, GNUNET_OK);
147} 142}
148 143
@@ -166,9 +161,7 @@ GAS_handle_request_address_cancel (void *cls,
166 "Received `%s' message\n", 161 "Received `%s' message\n",
167 "REQUEST_ADDRESS_CANCEL"); 162 "REQUEST_ADDRESS_CANCEL");
168 GNUNET_break (0 == ntohl (msg->reserved)); 163 GNUNET_break (0 == ntohl (msg->reserved));
169 164 GAS_addresses_request_address_cancel (&msg->peer);
170 GAS_addresses_request_address_cancel (address_handle, &msg->peer);
171
172 GNUNET_SERVER_receive_done (client, GNUNET_OK); 165 GNUNET_SERVER_receive_done (client, GNUNET_OK);
173} 166}
174 167
@@ -192,7 +185,7 @@ GAS_handle_reset_backoff (void *cls,
192 "Received `%s' message\n", 185 "Received `%s' message\n",
193 "RESET_BACKOFF"); 186 "RESET_BACKOFF");
194 GNUNET_break (0 == ntohl (msg->reserved)); 187 GNUNET_break (0 == ntohl (msg->reserved));
195 GAS_addresses_handle_backoff_reset (address_handle, &msg->peer); 188 GAS_addresses_handle_backoff_reset (&msg->peer);
196 GNUNET_SERVER_receive_done (client, GNUNET_OK); 189 GNUNET_SERVER_receive_done (client, GNUNET_OK);
197} 190}
198 191
@@ -253,8 +246,7 @@ GAS_handle_address_add (void *cls,
253 GNUNET_STATISTICS_update (GSA_stats, 246 GNUNET_STATISTICS_update (GSA_stats,
254 "# addresses created", 1, 247 "# addresses created", 1,
255 GNUNET_NO); 248 GNUNET_NO);
256 GAS_addresses_add (address_handle, 249 GAS_addresses_add (&m->peer,
257 &m->peer,
258 plugin_name, 250 plugin_name,
259 address, 251 address,
260 address_length, 252 address_length,
@@ -309,8 +301,7 @@ GAS_handle_address_update (void *cls,
309 "# address updates received", 301 "# address updates received",
310 1, 302 1,
311 GNUNET_NO); 303 GNUNET_NO);
312 GAS_addresses_update (address_handle, 304 GAS_addresses_update (&m->peer,
313 &m->peer,
314 ntohl (m->session_id), 305 ntohl (m->session_id),
315 atsi, ats_count); 306 atsi, ats_count);
316 GNUNET_SERVER_receive_done (client, GNUNET_OK); 307 GNUNET_SERVER_receive_done (client, GNUNET_OK);
@@ -333,8 +324,7 @@ GAS_handle_address_in_use (void *cls,
333 int res; 324 int res;
334 325
335 m = (const struct AddressUseMessage *) message; 326 m = (const struct AddressUseMessage *) message;
336 res = GAS_addresses_in_use (address_handle, 327 res = GAS_addresses_in_use (&m->peer,
337 &m->peer,
338 ntohl (m->session_id), 328 ntohl (m->session_id),
339 ntohl (m->in_use)); 329 ntohl (m->in_use));
340 if (GNUNET_OK != res) 330 if (GNUNET_OK != res)
@@ -370,8 +360,7 @@ GAS_handle_address_destroyed (void *cls,
370 "# addresses destroyed", 360 "# addresses destroyed",
371 1, 361 1,
372 GNUNET_NO); 362 GNUNET_NO);
373 GAS_addresses_destroy (address_handle, 363 GAS_addresses_destroy (&m->peer,
374 &m->peer,
375 ntohl (m->session_id)); 364 ntohl (m->session_id));
376 srm.header.type = ntohs (GNUNET_MESSAGE_TYPE_ATS_SESSION_RELEASE); 365 srm.header.type = ntohs (GNUNET_MESSAGE_TYPE_ATS_SESSION_RELEASE);
377 srm.header.size = ntohs (sizeof (struct SessionReleaseMessage)); 366 srm.header.size = ntohs (sizeof (struct SessionReleaseMessage));
@@ -392,11 +381,8 @@ GAS_handle_address_destroyed (void *cls,
392 * @param ah the address handle to use 381 * @param ah the address handle to use
393 */ 382 */
394void 383void
395GAS_scheduling_init (struct GNUNET_SERVER_Handle *server, 384GAS_scheduling_init (struct GNUNET_SERVER_Handle *server)
396 struct GAS_Addresses_Handle *ah)
397{ 385{
398 GNUNET_assert (NULL != ah);
399 address_handle = ah;
400 nc = GNUNET_SERVER_notification_context_create (server, 128); 386 nc = GNUNET_SERVER_notification_context_create (server, 128);
401} 387}
402 388
diff --git a/src/ats/gnunet-service-ats_scheduling.h b/src/ats/gnunet-service-ats_scheduling.h
index 9cffd214f..38ade2ae8 100644
--- a/src/ats/gnunet-service-ats_scheduling.h
+++ b/src/ats/gnunet-service-ats_scheduling.h
@@ -164,8 +164,7 @@ GAS_handle_address_destroyed (void *cls,
164 * @param ah the address handle to use 164 * @param ah the address handle to use
165 */ 165 */
166void 166void
167GAS_scheduling_init (struct GNUNET_SERVER_Handle *server, 167GAS_scheduling_init (struct GNUNET_SERVER_Handle *server);
168 struct GAS_Addresses_Handle *ah);
169 168
170 169
171/** 170/**