aboutsummaryrefslogtreecommitdiff
path: root/src/ats
diff options
context:
space:
mode:
authorChristian Grothoff <christian@grothoff.org>2016-09-21 10:56:28 +0000
committerChristian Grothoff <christian@grothoff.org>2016-09-21 10:56:28 +0000
commitd4afc6e37a14fe3257263c377a243c1a22ed9ee5 (patch)
treeccfce6d4f92808372d3e7ebfe9f5372e9f21f50c /src/ats
parent60d02b5b0899f454cb65408bd2ed4c453fa75a3d (diff)
downloadgnunet-d4afc6e37a14fe3257263c377a243c1a22ed9ee5.tar.gz
gnunet-d4afc6e37a14fe3257263c377a243c1a22ed9ee5.zip
migrating more services to new service API
Diffstat (limited to 'src/ats')
-rw-r--r--src/ats/Makefile.am1
-rw-r--r--src/ats/gnunet-service-ats.c456
-rw-r--r--src/ats/gnunet-service-ats_addresses.c70
-rw-r--r--src/ats/gnunet-service-ats_addresses.h13
-rw-r--r--src/ats/gnunet-service-ats_connectivity.c33
-rw-r--r--src/ats/gnunet-service-ats_connectivity.h20
-rw-r--r--src/ats/gnunet-service-ats_feedback.c123
-rw-r--r--src/ats/gnunet-service-ats_feedback.h43
-rw-r--r--src/ats/gnunet-service-ats_performance.c62
-rw-r--r--src/ats/gnunet-service-ats_performance.h4
-rw-r--r--src/ats/gnunet-service-ats_plugins.c2
-rw-r--r--src/ats/gnunet-service-ats_plugins.h2
-rw-r--r--src/ats/gnunet-service-ats_preferences.c42
-rw-r--r--src/ats/gnunet-service-ats_preferences.h12
-rw-r--r--src/ats/gnunet-service-ats_reservations.c49
-rw-r--r--src/ats/gnunet-service-ats_reservations.h9
-rw-r--r--src/ats/gnunet-service-ats_scheduling.c136
-rw-r--r--src/ats/gnunet-service-ats_scheduling.h44
-rw-r--r--src/ats/plugin_ats_mlp.c2
-rw-r--r--src/ats/plugin_ats_proportional.c2
-rw-r--r--src/ats/plugin_ats_ril.c2
21 files changed, 525 insertions, 602 deletions
diff --git a/src/ats/Makefile.am b/src/ats/Makefile.am
index ffe2c9616..aa3612c2d 100644
--- a/src/ats/Makefile.am
+++ b/src/ats/Makefile.am
@@ -83,7 +83,6 @@ gnunet_service_ats_SOURCES = \
83 gnunet-service-ats.c gnunet-service-ats.h \ 83 gnunet-service-ats.c gnunet-service-ats.h \
84 gnunet-service-ats_addresses.c gnunet-service-ats_addresses.h \ 84 gnunet-service-ats_addresses.c gnunet-service-ats_addresses.h \
85 gnunet-service-ats_connectivity.c gnunet-service-ats_connectivity.h \ 85 gnunet-service-ats_connectivity.c gnunet-service-ats_connectivity.h \
86 gnunet-service-ats_feedback.c gnunet-service-ats_feedback.h \
87 gnunet-service-ats_normalization.c gnunet-service-ats_normalization.h \ 86 gnunet-service-ats_normalization.c gnunet-service-ats_normalization.h \
88 gnunet-service-ats_performance.c gnunet-service-ats_performance.h \ 87 gnunet-service-ats_performance.c gnunet-service-ats_performance.h \
89 gnunet-service-ats_plugins.c gnunet-service-ats_plugins.h \ 88 gnunet-service-ats_plugins.c gnunet-service-ats_plugins.h \
diff --git a/src/ats/gnunet-service-ats.c b/src/ats/gnunet-service-ats.c
index 045a5bb67..9762faa51 100644
--- a/src/ats/gnunet-service-ats.c
+++ b/src/ats/gnunet-service-ats.c
@@ -28,7 +28,6 @@
28#include "gnunet-service-ats.h" 28#include "gnunet-service-ats.h"
29#include "gnunet-service-ats_addresses.h" 29#include "gnunet-service-ats_addresses.h"
30#include "gnunet-service-ats_connectivity.h" 30#include "gnunet-service-ats_connectivity.h"
31#include "gnunet-service-ats_feedback.h"
32#include "gnunet-service-ats_normalization.h" 31#include "gnunet-service-ats_normalization.h"
33#include "gnunet-service-ats_performance.h" 32#include "gnunet-service-ats_performance.h"
34#include "gnunet-service-ats_preferences.h" 33#include "gnunet-service-ats_preferences.h"
@@ -42,27 +41,19 @@
42 */ 41 */
43struct GNUNET_STATISTICS_Handle *GSA_stats; 42struct GNUNET_STATISTICS_Handle *GSA_stats;
44 43
45/**
46 * Handle to the ATS server.
47 */
48static struct GNUNET_SERVER_Handle *GSA_server;
49
50 44
51/** 45/**
52 * We have received a `struct ClientStartMessage` from a client. Find 46 * We have received a `struct ClientStartMessage` from a client. Find
53 * out which type of client it is and notify the respective subsystem. 47 * out which type of client it is and notify the respective subsystem.
54 * 48 *
55 * @param cls closure, unused 49 * @param cls handle to the client
56 * @param client handle to the client 50 * @param msg the start message
57 * @param message the start message
58 */ 51 */
59static void 52static void
60handle_ats_start (void *cls, 53handle_ats_start (void *cls,
61 struct GNUNET_SERVER_Client *client, 54 const struct ClientStartMessage *msg)
62 const struct GNUNET_MessageHeader *message)
63{ 55{
64 const struct ClientStartMessage *msg = 56 struct GNUNET_SERVICE_Client *client = cls;
65 (const struct ClientStartMessage *) message;
66 enum StartFlag flag; 57 enum StartFlag flag;
67 58
68 flag = ntohl (msg->start_flag); 59 flag = ntohl (msg->start_flag);
@@ -72,10 +63,10 @@ handle_ats_start (void *cls,
72 switch (flag) 63 switch (flag)
73 { 64 {
74 case START_FLAG_SCHEDULING: 65 case START_FLAG_SCHEDULING:
75 if (GNUNET_OK != GAS_scheduling_add_client (client)) 66 if (GNUNET_OK !=
67 GAS_scheduling_add_client (client))
76 { 68 {
77 GNUNET_SERVER_receive_done (client, 69 GNUNET_SERVICE_client_drop (client);
78 GNUNET_SYSERR);
79 return; 70 return;
80 } 71 }
81 break; 72 break;
@@ -92,12 +83,310 @@ handle_ats_start (void *cls,
92 break; 83 break;
93 default: 84 default:
94 GNUNET_break (0); 85 GNUNET_break (0);
95 GNUNET_SERVER_receive_done (client, 86 GNUNET_SERVICE_client_drop (client);
96 GNUNET_SYSERR);
97 return; 87 return;
98 } 88 }
99 GNUNET_SERVER_receive_done (client, 89 GNUNET_SERVICE_client_continue (client);
100 GNUNET_OK); 90}
91
92
93
94/**
95 * Handle 'reservation request' messages from clients.
96 *
97 * @param cls client that sent the request
98 * @param message the request message
99 */
100static void
101handle_reservation_request (void *cls,
102 const struct ReservationRequestMessage *message)
103{
104 struct GNUNET_SERVICE_Client *client = cls;
105
106 GAS_handle_reservation_request (client,
107 message);
108 GNUNET_SERVICE_client_continue (client);
109}
110
111
112/**
113 * Check 'preference feedback' message is well-formed
114 *
115 * @param cls client that sent the request
116 * @param message the request message
117 * @return #GNUNET_OK if @a message is well-formed
118 */
119static int
120check_feedback (void *cls,
121 const struct FeedbackPreferenceMessage *message)
122{
123 uint16_t msize;
124 uint32_t nump;
125
126 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
127 "Received PREFERENCE_FEEDBACK message\n");
128 msize = ntohs (message->header.size);
129 nump = ntohl (message->num_feedback);
130 if (msize !=
131 sizeof (struct FeedbackPreferenceMessage) +
132 nump * sizeof (struct PreferenceInformation))
133 {
134 GNUNET_break (0);
135 return GNUNET_SYSERR;
136 }
137 return GNUNET_OK;
138}
139
140
141/**
142 * Handle 'preference feedback' messages from clients.
143 *
144 * @param cls client that sent the request
145 * @param msg the request message
146 */
147static void
148handle_feedback (void *cls,
149 const struct FeedbackPreferenceMessage *msg)
150{
151 struct GNUNET_SERVICE_Client *client = cls;
152 const struct PreferenceInformation *pi;
153 uint32_t nump;
154
155 nump = ntohl (msg->num_feedback);
156 if (GNUNET_NO ==
157 GNUNET_CONTAINER_multipeermap_contains (GSA_addresses,
158 &msg->peer))
159 {
160 GNUNET_log(GNUNET_ERROR_TYPE_WARNING,
161 "Received PREFERENCE FEEDBACK for unknown peer `%s'\n",
162 GNUNET_i2s (&msg->peer));
163 GNUNET_SERVICE_client_continue (client);
164 return;
165 }
166
167 GNUNET_STATISTICS_update (GSA_stats,
168 "# preference feedbacks requests processed",
169 1,
170 GNUNET_NO);
171 pi = (const struct PreferenceInformation *) &msg[1];
172 for (uint32_t i = 0; i < nump; i++)
173 {
174 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
175 "Received PREFERENCE FEEDBACK for peer `%s'\n",
176 GNUNET_i2s (&msg->peer));
177 GAS_plugin_notify_feedback (client,
178 &msg->peer,
179 GNUNET_TIME_relative_ntoh (msg->scope),
180 (enum GNUNET_ATS_PreferenceKind) ntohl (pi[i].preference_kind),
181 pi[i].preference_value);
182 }
183 GNUNET_SERVICE_client_continue (client);
184}
185
186
187/**
188 * Handle 'request address list' messages from clients.
189 *
190 * @param cls client that sent the request
191 * @param message the request message
192 */
193static void
194handle_request_address_list (void *cls,
195 const struct AddressListRequestMessage *message)
196{
197 struct GNUNET_SERVICE_Client *client = cls;
198
199 GAS_handle_request_address_list (client,
200 message);
201 GNUNET_SERVICE_client_continue (client);
202}
203
204
205/**
206 * Handle 'request address' messages from clients.
207 *
208 * @param cls client that sent the request
209 * @param message the request message
210 */
211static void
212handle_request_address (void *cls,
213 const struct RequestAddressMessage * message)
214{
215 struct GNUNET_SERVICE_Client *client = cls;
216
217 GAS_handle_request_address (client,
218 message);
219 GNUNET_SERVICE_client_continue (client);
220}
221
222
223/**
224 * Cancel 'request address' messages from clients.
225 *
226 * @param cls client that sent the request
227 * @param message the request message
228 */
229static void
230handle_request_address_cancel (void *cls,
231 const struct RequestAddressMessage *message)
232{
233 struct GNUNET_SERVICE_Client *client = cls;
234
235 GAS_handle_request_address_cancel (client,
236 message);
237 GNUNET_SERVICE_client_continue (client);
238}
239
240
241/**
242 * Handle 'address add' messages from clients.
243 *
244 * @param cls client that sent the request
245 * @param m the request message
246 */
247static int
248check_address_add (void *cls,
249 const struct AddressAddMessage *m)
250{
251 const char *address;
252 const char *plugin_name;
253 uint16_t address_length;
254 uint16_t plugin_name_length;
255 uint16_t size;
256
257 size = ntohs (m->header.size);
258 address_length = ntohs (m->address_length);
259 plugin_name_length = ntohs (m->plugin_name_length);
260 address = (const char *) &m[1];
261 if (plugin_name_length != 0)
262 plugin_name = &address[address_length];
263 else
264 plugin_name = "";
265
266 if ( (address_length + plugin_name_length +
267 sizeof (struct AddressAddMessage) != size) ||
268 ( (plugin_name_length > 0) &&
269 (plugin_name[plugin_name_length - 1] != '\0') ) )
270 {
271 GNUNET_break (0);
272 return GNUNET_SYSERR;
273 }
274 return GNUNET_OK;
275}
276
277
278/**
279 * Handle 'address add' messages from clients.
280 *
281 * @param cls client that sent the request
282 * @param message the request message
283 */
284static void
285handle_address_add (void *cls,
286 const struct AddressAddMessage *message)
287{
288 struct GNUNET_SERVICE_Client *client = cls;
289
290 GAS_handle_address_add (message);
291 GNUNET_SERVICE_client_continue (client);
292}
293
294
295/**
296 * Handle 'address update' messages from clients.
297 *
298 * @param cls client that sent the request
299 * @param message the request message
300 */
301static void
302handle_address_update (void *cls,
303 const struct AddressUpdateMessage *message)
304{
305 struct GNUNET_SERVICE_Client *client = cls;
306
307 GAS_handle_address_update (message);
308 GNUNET_SERVICE_client_continue (client);
309}
310
311
312/**
313 * Handle 'address destroyed' messages from clients.
314 *
315 * @param cls client that sent the request
316 * @param message the request message
317 */
318static void
319handle_address_destroyed (void *cls,
320 const struct AddressDestroyedMessage *message)
321{
322 struct GNUNET_SERVICE_Client *client = cls;
323
324 GAS_handle_address_destroyed (message);
325 GNUNET_SERVICE_client_continue (client);
326}
327
328
329/**
330 * Check that 'change preference' message is well-formed.
331 *
332 * @param cls client that sent the request
333 * @param message the request message
334 * @return #GNUNET_OK if @a message is well-formed
335 */
336static int
337check_preference_change (void *cls,
338 const struct ChangePreferenceMessage *message)
339{
340 uint16_t msize;
341 uint32_t nump;
342
343 msize = ntohs (message->header.size);
344 nump = ntohl (message->num_preferences);
345 if ( (msize !=
346 sizeof (struct ChangePreferenceMessage) +
347 nump * sizeof (struct PreferenceInformation)) ||
348 (UINT16_MAX / sizeof (struct PreferenceInformation) < nump) )
349 {
350 GNUNET_break (0);
351 return GNUNET_SYSERR;
352 }
353 return GNUNET_OK;
354}
355
356
357/**
358 * Handle 'change preference' messages from clients.
359 *
360 * @param cls client that sent the request
361 * @param message the request message
362 */
363static void
364handle_preference_change (void *cls,
365 const struct ChangePreferenceMessage *message)
366{
367 struct GNUNET_SERVICE_Client *client = cls;
368
369 GAS_handle_preference_change (client,
370 message);
371 GNUNET_SERVICE_client_continue (client);
372}
373
374
375/**
376 * A client connected to us. Setup the local client
377 * record.
378 *
379 * @param cls unused
380 * @param client handle of the client
381 * @param mq message queue to talk to @a client
382 * @return @a client
383 */
384static void *
385client_connect_cb (void *cls,
386 struct GNUNET_SERVICE_Client *client,
387 struct GNUNET_MQ_Handle *mq)
388{
389 return client;
101} 390}
102 391
103 392
@@ -107,10 +396,12 @@ handle_ats_start (void *cls,
107 * 396 *
108 * @param cls unused 397 * @param cls unused
109 * @param client handle of the client 398 * @param client handle of the client
399 * @param app_ctx
110 */ 400 */
111static void 401static void
112client_disconnect_handler (void *cls, 402client_disconnect_cb (void *cls,
113 struct GNUNET_SERVER_Client *client) 403 struct GNUNET_SERVICE_Client *client,
404 void *app_ctx)
114{ 405{
115 if (NULL == client) 406 if (NULL == client)
116 return; 407 return;
@@ -134,7 +425,6 @@ cleanup_task (void *cls)
134 GAS_addresses_done (); 425 GAS_addresses_done ();
135 GAS_plugin_done (); 426 GAS_plugin_done ();
136 GAS_normalization_stop (); 427 GAS_normalization_stop ();
137 GAS_scheduling_done ();
138 GAS_performance_done (); 428 GAS_performance_done ();
139 GAS_preference_done (); 429 GAS_preference_done ();
140 GAS_reservations_done (); 430 GAS_reservations_done ();
@@ -150,51 +440,21 @@ cleanup_task (void *cls)
150 * Process template requests. 440 * Process template requests.
151 * 441 *
152 * @param cls closure 442 * @param cls closure
153 * @param server the initialized server
154 * @param cfg configuration to use 443 * @param cfg configuration to use
444 * @param service the initialized service
155 */ 445 */
156static void 446static void
157run (void *cls, 447run (void *cls,
158 struct GNUNET_SERVER_Handle *server, 448 const struct GNUNET_CONFIGURATION_Handle *cfg,
159 const struct GNUNET_CONFIGURATION_Handle *cfg) 449 struct GNUNET_SERVICE_Handle *service)
160{ 450{
161 static const struct GNUNET_SERVER_MessageHandler handlers[] = { 451 GSA_stats = GNUNET_STATISTICS_create ("ats",
162 {&handle_ats_start, NULL, 452 cfg);
163 GNUNET_MESSAGE_TYPE_ATS_START, 453 GAS_reservations_init ();
164 sizeof (struct ClientStartMessage)},
165 {&GAS_handle_request_address, NULL,
166 GNUNET_MESSAGE_TYPE_ATS_REQUEST_ADDRESS,
167 sizeof (struct RequestAddressMessage)},
168 {&GAS_handle_request_address_cancel, NULL,
169 GNUNET_MESSAGE_TYPE_ATS_REQUEST_ADDRESS_CANCEL,
170 sizeof (struct RequestAddressMessage)},
171 {&GAS_handle_request_address_list, NULL,
172 GNUNET_MESSAGE_TYPE_ATS_ADDRESSLIST_REQUEST,
173 sizeof (struct AddressListRequestMessage)},
174 {&GAS_handle_address_add, NULL,
175 GNUNET_MESSAGE_TYPE_ATS_ADDRESS_ADD, 0},
176 {&GAS_handle_address_update, NULL,
177 GNUNET_MESSAGE_TYPE_ATS_ADDRESS_UPDATE,
178 sizeof (struct AddressUpdateMessage) },
179 {&GAS_handle_address_destroyed, NULL,
180 GNUNET_MESSAGE_TYPE_ATS_ADDRESS_DESTROYED,
181 sizeof (struct AddressDestroyedMessage) },
182 {&GAS_handle_reservation_request, NULL,
183 GNUNET_MESSAGE_TYPE_ATS_RESERVATION_REQUEST,
184 sizeof (struct ReservationRequestMessage)},
185 {&GAS_handle_preference_change, NULL,
186 GNUNET_MESSAGE_TYPE_ATS_PREFERENCE_CHANGE, 0},
187 {&GAS_handle_feedback, NULL,
188 GNUNET_MESSAGE_TYPE_ATS_PREFERENCE_FEEDBACK, 0},
189 {NULL, NULL, 0, 0}
190 };
191 GSA_server = server;
192 GSA_stats = GNUNET_STATISTICS_create ("ats", cfg);
193 GAS_reservations_init (server);
194 GAS_connectivity_init (); 454 GAS_connectivity_init ();
195 GAS_preference_init (); 455 GAS_preference_init ();
196 GAS_normalization_start (); 456 GAS_normalization_start ();
197 GAS_addresses_init (server); 457 GAS_addresses_init ();
198 if (GNUNET_OK != 458 if (GNUNET_OK !=
199 GAS_plugin_init (cfg)) 459 GAS_plugin_init (cfg))
200 { 460 {
@@ -206,37 +466,69 @@ run (void *cls,
206 GAS_preference_done (); 466 GAS_preference_done ();
207 if (NULL != GSA_stats) 467 if (NULL != GSA_stats)
208 { 468 {
209 GNUNET_STATISTICS_destroy (GSA_stats, GNUNET_NO); 469 GNUNET_STATISTICS_destroy (GSA_stats,
470 GNUNET_NO);
210 GSA_stats = NULL; 471 GSA_stats = NULL;
211 } 472 }
212 return; 473 return;
213 } 474 }
214 GAS_performance_init (server); 475 GAS_performance_init ();
215 GAS_scheduling_init (server);
216
217 GNUNET_SERVER_disconnect_notify (server,
218 &client_disconnect_handler,
219 NULL);
220 GNUNET_SERVER_add_handlers (server, handlers);
221 GNUNET_SCHEDULER_add_shutdown (&cleanup_task, 476 GNUNET_SCHEDULER_add_shutdown (&cleanup_task,
222 NULL); 477 NULL);
223} 478}
224 479
225 480
226/** 481/**
227 * The main function for the ats service. 482 * Define "main" method using service macro.
228 *
229 * @param argc number of arguments from the command line
230 * @param argv command line arguments
231 * @return 0 ok, 1 on error
232 */ 483 */
233int 484GNUNET_SERVICE_MAIN
234main (int argc, char *const *argv) 485("ats",
235{ 486 GNUNET_SERVICE_OPTION_NONE,
236 return (GNUNET_OK == 487 &run,
237 GNUNET_SERVICE_run (argc, argv, "ats", 488 &client_connect_cb,
238 GNUNET_SERVICE_OPTION_NONE, 489 &client_disconnect_cb,
239 &run, NULL)) ? 0 : 1; 490 NULL,
240} 491 GNUNET_MQ_hd_fixed_size (ats_start,
492 GNUNET_MESSAGE_TYPE_ATS_START,
493 struct ClientStartMessage,
494 NULL),
495 GNUNET_MQ_hd_fixed_size (request_address,
496 GNUNET_MESSAGE_TYPE_ATS_REQUEST_ADDRESS,
497 struct RequestAddressMessage,
498 NULL),
499 GNUNET_MQ_hd_fixed_size (request_address_cancel,
500 GNUNET_MESSAGE_TYPE_ATS_REQUEST_ADDRESS_CANCEL,
501 struct RequestAddressMessage,
502 NULL),
503 GNUNET_MQ_hd_fixed_size (request_address_list,
504 GNUNET_MESSAGE_TYPE_ATS_ADDRESSLIST_REQUEST,
505 struct AddressListRequestMessage,
506 NULL),
507 GNUNET_MQ_hd_var_size (address_add,
508 GNUNET_MESSAGE_TYPE_ATS_ADDRESS_ADD,
509 struct AddressAddMessage,
510 NULL),
511 GNUNET_MQ_hd_fixed_size (address_update,
512 GNUNET_MESSAGE_TYPE_ATS_ADDRESS_UPDATE,
513 struct AddressUpdateMessage,
514 NULL),
515 GNUNET_MQ_hd_fixed_size (address_destroyed,
516 GNUNET_MESSAGE_TYPE_ATS_ADDRESS_DESTROYED,
517 struct AddressDestroyedMessage,
518 NULL),
519 GNUNET_MQ_hd_fixed_size (reservation_request,
520 GNUNET_MESSAGE_TYPE_ATS_RESERVATION_REQUEST,
521 struct ReservationRequestMessage,
522 NULL),
523 GNUNET_MQ_hd_var_size (preference_change,
524 GNUNET_MESSAGE_TYPE_ATS_PREFERENCE_CHANGE,
525 struct ChangePreferenceMessage,
526 NULL),
527 GNUNET_MQ_hd_var_size (feedback,
528 GNUNET_MESSAGE_TYPE_ATS_PREFERENCE_FEEDBACK,
529 struct FeedbackPreferenceMessage,
530 NULL),
531 GNUNET_MQ_handler_end ());
532
241 533
242/* end of gnunet-service-ats.c */ 534/* end of gnunet-service-ats.c */
diff --git a/src/ats/gnunet-service-ats_addresses.c b/src/ats/gnunet-service-ats_addresses.c
index 44a4782d5..1a4a33206 100644
--- a/src/ats/gnunet-service-ats_addresses.c
+++ b/src/ats/gnunet-service-ats_addresses.c
@@ -347,13 +347,13 @@ GAS_addresses_destroy (const struct GNUNET_PeerIdentity *peer,
347 * known and current performance information. It has a solver component 347 * known and current performance information. It has a solver component
348 * responsible for the resource allocation. It tells the solver about changes 348 * responsible for the resource allocation. It tells the solver about changes
349 * and receives updates when the solver changes the resource allocation. 349 * and receives updates when the solver changes the resource allocation.
350 *
351 * @param server handle to our server
352 */ 350 */
353void 351void
354GAS_addresses_init (struct GNUNET_SERVER_Handle *server) 352GAS_addresses_init ()
355{ 353{
356 GSA_addresses = GNUNET_CONTAINER_multipeermap_create (128, GNUNET_NO); 354 GSA_addresses
355 = GNUNET_CONTAINER_multipeermap_create (128,
356 GNUNET_NO);
357 update_addresses_stat (); 357 update_addresses_stat ();
358} 358}
359 359
@@ -515,7 +515,7 @@ struct AddressIteration
515 /** 515 /**
516 * Actual handle to the client. 516 * Actual handle to the client.
517 */ 517 */
518 struct GNUNET_SERVER_Client *client; 518 struct GNUNET_SERVICE_Client *client;
519 519
520 /** 520 /**
521 * Are we sending all addresses, or only those that are active? 521 * Are we sending all addresses, or only those that are active?
@@ -558,30 +558,26 @@ transmit_req_addr (struct AddressIteration *ai,
558 struct GNUNET_BANDWIDTH_Value32NBO bandwidth_in) 558 struct GNUNET_BANDWIDTH_Value32NBO bandwidth_in)
559 559
560{ 560{
561 struct GNUNET_MQ_Envelope *env;
561 struct PeerInformationMessage *msg; 562 struct PeerInformationMessage *msg;
562 char *addrp; 563 char *addrp;
563 size_t plugin_name_length; 564 size_t plugin_name_length;
564 size_t msize; 565 size_t msize;
565 struct GNUNET_SERVER_NotificationContext **uc;
566 struct GNUNET_SERVER_NotificationContext *nc;
567 566
568 if (NULL != plugin_name) 567 if (NULL != plugin_name)
569 plugin_name_length = strlen (plugin_name) + 1; 568 plugin_name_length = strlen (plugin_name) + 1;
570 else 569 else
571 plugin_name_length = 0; 570 plugin_name_length = 0;
572 msize = sizeof (struct PeerInformationMessage) + 571 msize = plugin_addr_len + plugin_name_length;
573 plugin_addr_len + plugin_name_length; 572
574 char buf[msize] GNUNET_ALIGN; 573 GNUNET_assert (sizeof (struct PeerInformationMessage) + msize
575 574 < GNUNET_SERVER_MAX_MESSAGE_SIZE);
576 GNUNET_assert (msize < GNUNET_SERVER_MAX_MESSAGE_SIZE); 575 env = GNUNET_MQ_msg_extra (msg,
577 msg = (struct PeerInformationMessage *) buf; 576 msize,
578 msg->header.size = htons (msize); 577 GNUNET_MESSAGE_TYPE_ATS_ADDRESSLIST_RESPONSE);
579 msg->header.type = htons (GNUNET_MESSAGE_TYPE_ATS_ADDRESSLIST_RESPONSE);
580 msg->id = htonl (ai->id); 578 msg->id = htonl (ai->id);
581 if (NULL != id) 579 if (NULL != id)
582 msg->peer = *id; 580 msg->peer = *id;
583 else
584 memset (&msg->peer, '\0', sizeof (struct GNUNET_PeerIdentity));
585 msg->address_length = htons (plugin_addr_len); 581 msg->address_length = htons (plugin_addr_len);
586 msg->address_active = ntohl (active); 582 msg->address_active = ntohl (active);
587 msg->plugin_name_length = htons (plugin_name_length); 583 msg->plugin_name_length = htons (plugin_name_length);
@@ -590,28 +586,16 @@ transmit_req_addr (struct AddressIteration *ai,
590 if (NULL != prop) 586 if (NULL != prop)
591 GNUNET_ATS_properties_hton (&msg->properties, 587 GNUNET_ATS_properties_hton (&msg->properties,
592 prop); 588 prop);
593 else
594 memset (&msg->properties,
595 0,
596 sizeof (struct GNUNET_ATS_Properties));
597 msg->address_local_info = htonl ((uint32_t) local_address_info); 589 msg->address_local_info = htonl ((uint32_t) local_address_info);
598 addrp = (char *) &msg[1]; 590 addrp = (char *) &msg[1];
599 if (NULL != plugin_addr) 591 GNUNET_memcpy (addrp,
600 GNUNET_memcpy (addrp, plugin_addr, plugin_addr_len); 592 plugin_addr,
593 plugin_addr_len);
601 if (NULL != plugin_name) 594 if (NULL != plugin_name)
602 strcpy (&addrp[plugin_addr_len], plugin_name); 595 strcpy (&addrp[plugin_addr_len],
603 uc = GNUNET_SERVER_client_get_user_context (ai->client, 596 plugin_name);
604 struct GNUNET_SERVER_NotificationContext *); 597 GNUNET_MQ_send (GNUNET_SERVICE_client_get_mq (ai->client),
605 if (NULL == uc) 598 env);
606 {
607 GNUNET_break (0);
608 return;
609 }
610 nc = *uc;
611 GNUNET_SERVER_notification_context_unicast (nc,
612 ai->client,
613 &msg->header,
614 GNUNET_NO);
615} 599}
616 600
617 601
@@ -679,22 +663,18 @@ req_addr_peerinfo_it (void *cls,
679/** 663/**
680 * Handle 'address list request' messages from clients. 664 * Handle 'address list request' messages from clients.
681 * 665 *
682 * @param cls unused, NULL 666 * @param cls client that sent the request
683 * @param client client that sent the request 667 * @param alrm the request message
684 * @param message the request message
685 */ 668 */
686void 669void
687GAS_handle_request_address_list (void *cls, 670GAS_handle_request_address_list (struct GNUNET_SERVICE_Client *client,
688 struct GNUNET_SERVER_Client *client, 671 const struct AddressListRequestMessage *alrm)
689 const struct GNUNET_MessageHeader *message)
690{ 672{
691 struct AddressIteration ai; 673 struct AddressIteration ai;
692 const struct AddressListRequestMessage *alrm;
693 struct GNUNET_PeerIdentity allzeros; 674 struct GNUNET_PeerIdentity allzeros;
694 675
695 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, 676 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
696 "Received ADDRESSLIST_REQUEST message\n"); 677 "Received ADDRESSLIST_REQUEST message\n");
697 alrm = (const struct AddressListRequestMessage *) message;
698 ai.all = ntohl (alrm->all); 678 ai.all = ntohl (alrm->all);
699 ai.id = ntohl (alrm->id); 679 ai.id = ntohl (alrm->id);
700 ai.client = client; 680 ai.client = client;
@@ -728,8 +708,6 @@ GAS_handle_request_address_list (void *cls,
728 GNUNET_HELLO_ADDRESS_INFO_NONE, 708 GNUNET_HELLO_ADDRESS_INFO_NONE,
729 GNUNET_BANDWIDTH_ZERO, 709 GNUNET_BANDWIDTH_ZERO,
730 GNUNET_BANDWIDTH_ZERO); 710 GNUNET_BANDWIDTH_ZERO);
731 GNUNET_SERVER_receive_done (client,
732 GNUNET_OK);
733} 711}
734 712
735 713
diff --git a/src/ats/gnunet-service-ats_addresses.h b/src/ats/gnunet-service-ats_addresses.h
index 274985e66..61de1cd31 100644
--- a/src/ats/gnunet-service-ats_addresses.h
+++ b/src/ats/gnunet-service-ats_addresses.h
@@ -30,6 +30,7 @@
30#include "gnunet_util_lib.h" 30#include "gnunet_util_lib.h"
31#include "gnunet_ats_service.h" 31#include "gnunet_ats_service.h"
32#include "gnunet-service-ats.h" 32#include "gnunet-service-ats.h"
33#include "ats.h"
33 34
34/** 35/**
35 * NOTE: Do not change this documentation. This documentation is based on 36 * NOTE: Do not change this documentation. This documentation is based on
@@ -366,11 +367,9 @@ extern struct GNUNET_CONTAINER_MultiPeerMap *GSA_addresses;
366/** 367/**
367 * Initialize address subsystem. The addresses subsystem manages the addresses 368 * Initialize address subsystem. The addresses subsystem manages the addresses
368 * known and current performance information. 369 * known and current performance information.
369 *
370 * @param server handle to our server
371 */ 370 */
372void 371void
373GAS_addresses_init (struct GNUNET_SERVER_Handle *server); 372GAS_addresses_init (void);
374 373
375 374
376/** 375/**
@@ -475,14 +474,12 @@ GAS_addresses_get_peer_info (const struct GNUNET_PeerIdentity *peer,
475/** 474/**
476 * Handle 'address list request' messages from clients. 475 * Handle 'address list request' messages from clients.
477 * 476 *
478 * @param cls unused, NULL
479 * @param client client that sent the request 477 * @param client client that sent the request
480 * @param message the request message 478 * @param alrm the request message
481 */ 479 */
482void 480void
483GAS_handle_request_address_list (void *cls, 481GAS_handle_request_address_list (struct GNUNET_SERVICE_Client *client,
484 struct GNUNET_SERVER_Client *client, 482 const struct AddressListRequestMessage *alrm);
485 const struct GNUNET_MessageHeader *message);
486 483
487 484
488#endif 485#endif
diff --git a/src/ats/gnunet-service-ats_connectivity.c b/src/ats/gnunet-service-ats_connectivity.c
index 2cf434c70..c47ee03e6 100644
--- a/src/ats/gnunet-service-ats_connectivity.c
+++ b/src/ats/gnunet-service-ats_connectivity.c
@@ -40,7 +40,7 @@ struct ConnectionRequest
40 /** 40 /**
41 * Client that made the request. 41 * Client that made the request.
42 */ 42 */
43 struct GNUNET_SERVER_Client *client; 43 struct GNUNET_SERVICE_Client *client;
44 44
45 /* TODO: allow client to express a 'strength' for this request */ 45 /* TODO: allow client to express a 'strength' for this request */
46}; 46};
@@ -75,17 +75,13 @@ GAS_connectivity_has_peer (void *cls,
75/** 75/**
76 * Handle #GNUNET_MESSAGE_TYPE_ATS_REQUEST_ADDRESS messages from clients. 76 * Handle #GNUNET_MESSAGE_TYPE_ATS_REQUEST_ADDRESS messages from clients.
77 * 77 *
78 * @param cls unused, NULL
79 * @param client client that sent the request 78 * @param client client that sent the request
80 * @param message the request message 79 * @param message the request message
81 */ 80 */
82void 81void
83GAS_handle_request_address (void *cls, 82GAS_handle_request_address (struct GNUNET_SERVICE_Client *client,
84 struct GNUNET_SERVER_Client *client, 83 const struct RequestAddressMessage *msg)
85 const struct GNUNET_MessageHeader *message)
86{ 84{
87 const struct RequestAddressMessage *msg =
88 (const struct RequestAddressMessage *) message;
89 struct ConnectionRequest *cr; 85 struct ConnectionRequest *cr;
90 86
91 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, 87 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
@@ -99,7 +95,6 @@ GAS_handle_request_address (void *cls,
99 cr, 95 cr,
100 GNUNET_CONTAINER_MULTIHASHMAPOPTION_MULTIPLE); 96 GNUNET_CONTAINER_MULTIHASHMAPOPTION_MULTIPLE);
101 GAS_plugin_request_connect_start (&msg->peer); 97 GAS_plugin_request_connect_start (&msg->peer);
102 GNUNET_SERVER_receive_done (client, GNUNET_OK);
103} 98}
104 99
105 100
@@ -117,7 +112,7 @@ free_matching_requests (void *cls,
117 const struct GNUNET_PeerIdentity *pid, 112 const struct GNUNET_PeerIdentity *pid,
118 void *value) 113 void *value)
119{ 114{
120 struct GNUNET_SERVER_Client *client = cls; 115 struct GNUNET_SERVICE_Client *client = cls;
121 struct ConnectionRequest *cr = value; 116 struct ConnectionRequest *cr = value;
122 117
123 if (cr->client == client) 118 if (cr->client == client)
@@ -140,18 +135,13 @@ free_matching_requests (void *cls,
140 * Handle #GNUNET_MESSAGE_TYPE_ATS_REQUEST_ADDRESS_CANCEL messages 135 * Handle #GNUNET_MESSAGE_TYPE_ATS_REQUEST_ADDRESS_CANCEL messages
141 * from clients. 136 * from clients.
142 * 137 *
143 * @param cls unused, NULL 138 * @param client the client that sent the request
144 * @param client client that sent the request 139 * @param msg the request message
145 * @param message the request message
146 */ 140 */
147void 141void
148GAS_handle_request_address_cancel (void *cls, 142GAS_handle_request_address_cancel (struct GNUNET_SERVICE_Client *client,
149 struct GNUNET_SERVER_Client *client, 143 const struct RequestAddressMessage *msg)
150 const struct GNUNET_MessageHeader *message)
151{ 144{
152 const struct RequestAddressMessage *msg =
153 (const struct RequestAddressMessage *) message;
154
155 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, 145 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
156 "Received GNUNET_MESSAGE_TYPE_ATS_REQUEST_ADDRESS_CANCEL message for peer %s\n", 146 "Received GNUNET_MESSAGE_TYPE_ATS_REQUEST_ADDRESS_CANCEL message for peer %s\n",
157 GNUNET_i2s (&msg->peer)); 147 GNUNET_i2s (&msg->peer));
@@ -160,7 +150,6 @@ GAS_handle_request_address_cancel (void *cls,
160 &msg->peer, 150 &msg->peer,
161 &free_matching_requests, 151 &free_matching_requests,
162 client); 152 client);
163 GNUNET_SERVER_receive_done (client, GNUNET_OK);
164} 153}
165 154
166 155
@@ -171,7 +160,7 @@ GAS_handle_request_address_cancel (void *cls,
171 * @param client handle of the (now dead) client 160 * @param client handle of the (now dead) client
172 */ 161 */
173void 162void
174GAS_connectivity_remove_client (struct GNUNET_SERVER_Client *client) 163GAS_connectivity_remove_client (struct GNUNET_SERVICE_Client *client)
175{ 164{
176 GNUNET_CONTAINER_multipeermap_iterate (connection_requests, 165 GNUNET_CONTAINER_multipeermap_iterate (connection_requests,
177 &free_matching_requests, 166 &free_matching_requests,
@@ -185,7 +174,9 @@ GAS_connectivity_remove_client (struct GNUNET_SERVER_Client *client)
185void 174void
186GAS_connectivity_init () 175GAS_connectivity_init ()
187{ 176{
188 connection_requests = GNUNET_CONTAINER_multipeermap_create (32, GNUNET_NO); 177 connection_requests
178 = GNUNET_CONTAINER_multipeermap_create (32,
179 GNUNET_NO);
189} 180}
190 181
191 182
diff --git a/src/ats/gnunet-service-ats_connectivity.h b/src/ats/gnunet-service-ats_connectivity.h
index f10f9de0e..b8f194b36 100644
--- a/src/ats/gnunet-service-ats_connectivity.h
+++ b/src/ats/gnunet-service-ats_connectivity.h
@@ -26,6 +26,8 @@
26#ifndef GNUNET_SERVICE_ATS_CONNECTIVITY_H 26#ifndef GNUNET_SERVICE_ATS_CONNECTIVITY_H
27#define GNUNET_SERVICE_ATS_CONNECTIVITY_H 27#define GNUNET_SERVICE_ATS_CONNECTIVITY_H
28 28
29#include "ats.h"
30
29 31
30/** 32/**
31 * Is the given peer in the list of peers for which we 33 * Is the given peer in the list of peers for which we
@@ -43,27 +45,23 @@ GAS_connectivity_has_peer (void *cls,
43/** 45/**
44 * Handle 'request address' messages from clients. 46 * Handle 'request address' messages from clients.
45 * 47 *
46 * @param cls unused, NULL
47 * @param client client that sent the request 48 * @param client client that sent the request
48 * @param message the request message 49 * @param msg the request message
49 */ 50 */
50void 51void
51GAS_handle_request_address (void *cls, 52GAS_handle_request_address (struct GNUNET_SERVICE_Client *client,
52 struct GNUNET_SERVER_Client *client, 53 const struct RequestAddressMessage *msg);
53 const struct GNUNET_MessageHeader *message);
54 54
55 55
56/** 56/**
57 * Cancel 'request address' messages from clients. 57 * Cancel 'request address' messages from clients.
58 * 58 *
59 * @param cls unused, NULL
60 * @param client client that sent the request 59 * @param client client that sent the request
61 * @param message the request message 60 * @param msg the request message
62 */ 61 */
63void 62void
64GAS_handle_request_address_cancel (void *cls, 63GAS_handle_request_address_cancel (struct GNUNET_SERVICE_Client *client,
65 struct GNUNET_SERVER_Client *client, 64 const struct RequestAddressMessage *msg);
66 const struct GNUNET_MessageHeader *message);
67 65
68 66
69/** 67/**
@@ -73,7 +71,7 @@ GAS_handle_request_address_cancel (void *cls,
73 * @param client handle of the (now dead) client 71 * @param client handle of the (now dead) client
74 */ 72 */
75void 73void
76GAS_connectivity_remove_client (struct GNUNET_SERVER_Client *client); 74GAS_connectivity_remove_client (struct GNUNET_SERVICE_Client *client);
77 75
78 76
79/** 77/**
diff --git a/src/ats/gnunet-service-ats_feedback.c b/src/ats/gnunet-service-ats_feedback.c
deleted file mode 100644
index deb8e3d5d..000000000
--- a/src/ats/gnunet-service-ats_feedback.c
+++ /dev/null
@@ -1,123 +0,0 @@
1/*
2 This file is part of GNUnet.
3 Copyright (C) 2011-2015 GNUnet e.V.
4
5 GNUnet is free software; you can redistribute it and/or modify
6 it under the terms of the GNU General Public License as published
7 by the Free Software Foundation; either version 3, or (at your
8 option) any later version.
9
10 GNUnet is distributed in the hope that it will be useful, but
11 WITHOUT ANY WARRANTY; without even the implied warranty of
12 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
13 General Public License for more details.
14
15 You should have received a copy of the GNU General Public License
16 along with GNUnet; see the file COPYING. If not, write to the
17 Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
18 Boston, MA 02110-1301, USA.
19*/
20/**
21 * @file ats/gnunet-service-ats_feedback.c
22 * @brief ats service, handling of feedback
23 * @author Matthias Wachs
24 * @author Christian Grothoff
25 */
26#include "platform.h"
27#include "gnunet-service-ats_plugins.h"
28#include "gnunet-service-ats_feedback.h"
29#include "ats.h"
30
31
32/**
33 * Change the preference for a peer
34 *
35 * @param application the client sending this request
36 * @param peer the peer id
37 * @param scope the time interval for this feedback: [now - scope .. now]
38 * @param kind the preference kind to change
39 * @param score_abs the new preference score
40 */
41static void
42preference_feedback (struct GNUNET_SERVER_Client *application,
43 const struct GNUNET_PeerIdentity *peer,
44 const struct GNUNET_TIME_Relative scope,
45 enum GNUNET_ATS_PreferenceKind kind,
46 float score_abs)
47{
48 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
49 "Received PREFERENCE FEEDBACK for peer `%s'\n",
50 GNUNET_i2s (peer));
51 GAS_plugin_notify_feedback (application,
52 peer,
53 scope,
54 kind,
55 score_abs);
56}
57
58
59/**
60 * Handle 'preference feedback' messages from clients.
61 *
62 * @param cls unused, NULL
63 * @param client client that sent the request
64 * @param message the request message
65 */
66void
67GAS_handle_feedback (void *cls,
68 struct GNUNET_SERVER_Client *client,
69 const struct GNUNET_MessageHeader *message)
70{
71 const struct FeedbackPreferenceMessage *msg;
72 const struct PreferenceInformation *pi;
73 uint16_t msize;
74 uint32_t nump;
75 uint32_t i;
76
77 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
78 "Received PREFERENCE_FEEDBACK message\n");
79 msize = ntohs (message->size);
80 if (msize < sizeof (struct FeedbackPreferenceMessage))
81 {
82 GNUNET_break (0);
83 GNUNET_SERVER_receive_done (client,
84 GNUNET_SYSERR);
85 return;
86 }
87 msg = (const struct FeedbackPreferenceMessage *) message;
88 nump = ntohl (msg->num_feedback);
89 if (msize !=
90 sizeof (struct FeedbackPreferenceMessage) +
91 nump * sizeof (struct PreferenceInformation))
92 {
93 GNUNET_break (0);
94 GNUNET_SERVER_receive_done (client,
95 GNUNET_SYSERR);
96 return;
97 }
98 if (GNUNET_NO ==
99 GNUNET_CONTAINER_multipeermap_contains (GSA_addresses,
100 &msg->peer))
101 {
102 GNUNET_log(GNUNET_ERROR_TYPE_WARNING,
103 "Received PREFERENCE FEEDBACK for unknown peer `%s'\n",
104 GNUNET_i2s (&msg->peer));
105 return;
106 }
107
108 GNUNET_STATISTICS_update (GSA_stats,
109 "# preference feedbacks requests processed",
110 1,
111 GNUNET_NO);
112 pi = (const struct PreferenceInformation *) &msg[1];
113 for (i = 0; i < nump; i++)
114 preference_feedback (client,
115 &msg->peer,
116 GNUNET_TIME_relative_ntoh(msg->scope),
117 (enum GNUNET_ATS_PreferenceKind) ntohl (pi[i].preference_kind),
118 pi[i].preference_value);
119 GNUNET_SERVER_receive_done (client,
120 GNUNET_OK);
121}
122
123/* end of gnunet-service-ats_feedback.c */
diff --git a/src/ats/gnunet-service-ats_feedback.h b/src/ats/gnunet-service-ats_feedback.h
deleted file mode 100644
index 0ecb5d9b4..000000000
--- a/src/ats/gnunet-service-ats_feedback.h
+++ /dev/null
@@ -1,43 +0,0 @@
1/*
2 This file is part of GNUnet.
3 Copyright (C) 2011-2014 GNUnet e.V.
4
5 GNUnet is free software; you can redistribute it and/or modify
6 it under the terms of the GNU General Public License as published
7 by the Free Software Foundation; either version 3, or (at your
8 option) any later version.
9
10 GNUnet is distributed in the hope that it will be useful, but
11 WITHOUT ANY WARRANTY; without even the implied warranty of
12 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
13 General Public License for more details.
14
15 You should have received a copy of the GNU General Public License
16 along with GNUnet; see the file COPYING. If not, write to the
17 Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
18 Boston, MA 02110-1301, USA.
19 */
20/**
21 * @file ats/gnunet-service-ats_feedback.h
22 * @brief handle client feedback
23 * @author Matthias Wachs
24 * @author Christian Grothoff
25 */
26#ifndef GNUNET_SERVICE_ATS_FEEDBACK_H
27#define GNUNET_SERVICE_ATS_FEEDBACK_H
28
29#include "gnunet_util_lib.h"
30
31/**
32 * Handle 'preference feedback' messages from clients.
33 *
34 * @param cls unused, NULL
35 * @param client client that sent the request
36 * @param message the request message
37 */
38void
39GAS_handle_feedback (void *cls,
40 struct GNUNET_SERVER_Client *client,
41 const struct GNUNET_MessageHeader *message);
42
43#endif
diff --git a/src/ats/gnunet-service-ats_performance.c b/src/ats/gnunet-service-ats_performance.c
index 8702716f9..5252a71bc 100644
--- a/src/ats/gnunet-service-ats_performance.c
+++ b/src/ats/gnunet-service-ats_performance.c
@@ -36,12 +36,12 @@
36/** 36/**
37 * Context for sending messages to performance clients without PIC. 37 * Context for sending messages to performance clients without PIC.
38 */ 38 */
39static struct GNUNET_SERVER_NotificationContext *nc_no_pic; 39static struct GNUNET_NotificationContext *nc_no_pic;
40 40
41/** 41/**
42 * Context for sending messages to performance clients with PIC. 42 * Context for sending messages to performance clients with PIC.
43 */ 43 */
44static struct GNUNET_SERVER_NotificationContext *nc_pic; 44static struct GNUNET_NotificationContext *nc_pic;
45 45
46 46
47/** 47/**
@@ -63,7 +63,7 @@ static struct GNUNET_SERVER_NotificationContext *nc_pic;
63 * @param bandwidth_in assigned inbound bandwidth 63 * @param bandwidth_in assigned inbound bandwidth
64 */ 64 */
65static void 65static void
66notify_client (struct GNUNET_SERVER_Client *client, 66notify_client (struct GNUNET_SERVICE_Client *client,
67 const struct GNUNET_PeerIdentity *peer, 67 const struct GNUNET_PeerIdentity *peer,
68 const char *plugin_name, 68 const char *plugin_name,
69 const void *plugin_addr, 69 const void *plugin_addr,
@@ -81,8 +81,6 @@ notify_client (struct GNUNET_SERVER_Client *client,
81 plugin_addr_len + 81 plugin_addr_len +
82 plugin_name_length; 82 plugin_name_length;
83 char buf[msize] GNUNET_ALIGN; 83 char buf[msize] GNUNET_ALIGN;
84 struct GNUNET_SERVER_NotificationContext **uc;
85 struct GNUNET_SERVER_NotificationContext *nc;
86 char *addrp; 84 char *addrp;
87 85
88 if (NULL != prop) 86 if (NULL != prop)
@@ -111,24 +109,17 @@ notify_client (struct GNUNET_SERVER_Client *client,
111 strcpy (&addrp[plugin_addr_len], plugin_name); 109 strcpy (&addrp[plugin_addr_len], plugin_name);
112 if (NULL == client) 110 if (NULL == client)
113 { 111 {
114 GNUNET_SERVER_notification_context_broadcast (nc_pic, 112 GNUNET_notification_context_broadcast (nc_pic,
115 &msg->header, 113 &msg->header,
116 GNUNET_YES); 114 GNUNET_YES);
117 } 115 }
118 else 116 else
119 { 117 {
120 uc = GNUNET_SERVER_client_get_user_context (client, 118 struct GNUNET_MQ_Envelope *env;
121 struct GNUNET_SERVER_NotificationContext *); 119
122 if (NULL == uc) 120 env = GNUNET_MQ_msg_copy (&msg->header);
123 { 121 GNUNET_MQ_send (GNUNET_SERVICE_client_get_mq (client),
124 GNUNET_break (0); 122 env);
125 return;
126 }
127 nc = *uc;
128 GNUNET_SERVER_notification_context_unicast (nc,
129 client,
130 &msg->header,
131 GNUNET_YES);
132 } 123 }
133} 124}
134 125
@@ -183,7 +174,7 @@ GAS_performance_notify_all_clients (const struct GNUNET_PeerIdentity *peer,
183/** 174/**
184 * Iterator for called from #GAS_addresses_get_peer_info() 175 * Iterator for called from #GAS_addresses_get_peer_info()
185 * 176 *
186 * @param cls closure with the `struct GNUNET_SERVER_Client *` to inform. 177 * @param cls closure with the `struct GNUNET_SERVICE_Client *` to inform.
187 * @param id the peer id 178 * @param id the peer id
188 * @param plugin_name plugin name 179 * @param plugin_name plugin name
189 * @param plugin_addr address 180 * @param plugin_addr address
@@ -206,7 +197,7 @@ peerinfo_it (void *cls,
206 struct GNUNET_BANDWIDTH_Value32NBO bandwidth_out, 197 struct GNUNET_BANDWIDTH_Value32NBO bandwidth_out,
207 struct GNUNET_BANDWIDTH_Value32NBO bandwidth_in) 198 struct GNUNET_BANDWIDTH_Value32NBO bandwidth_in)
208{ 199{
209 struct GNUNET_SERVER_Client *client = cls; 200 struct GNUNET_SERVICE_Client *client = cls;
210 201
211 if (NULL == id) 202 if (NULL == id)
212 return; 203 return;
@@ -237,25 +228,24 @@ peerinfo_it (void *cls,
237 * @param flag flag specifying the type of the client 228 * @param flag flag specifying the type of the client
238 */ 229 */
239void 230void
240GAS_performance_add_client (struct GNUNET_SERVER_Client *client, 231GAS_performance_add_client (struct GNUNET_SERVICE_Client *client,
241 enum StartFlag flag) 232 enum StartFlag flag)
242{ 233{
234 struct GNUNET_MQ_Handle *mq;
235
236 mq = GNUNET_SERVICE_client_get_mq (client);
243 if (START_FLAG_PERFORMANCE_WITH_PIC == flag) 237 if (START_FLAG_PERFORMANCE_WITH_PIC == flag)
244 { 238 {
245 GNUNET_SERVER_notification_context_add (nc_pic, 239 GNUNET_notification_context_add (nc_pic,
246 client); 240 mq);
247 GNUNET_SERVER_client_set_user_context (client,
248 &nc_pic);
249 GAS_addresses_get_peer_info (NULL, 241 GAS_addresses_get_peer_info (NULL,
250 &peerinfo_it, 242 &peerinfo_it,
251 client); 243 client);
252 } 244 }
253 else 245 else
254 { 246 {
255 GNUNET_SERVER_notification_context_add (nc_no_pic, 247 GNUNET_notification_context_add (nc_no_pic,
256 client); 248 mq);
257 GNUNET_SERVER_client_set_user_context (client,
258 &nc_no_pic);
259 } 249 }
260} 250}
261 251
@@ -266,10 +256,10 @@ GAS_performance_add_client (struct GNUNET_SERVER_Client *client,
266 * @param server handle to our server 256 * @param server handle to our server
267 */ 257 */
268void 258void
269GAS_performance_init (struct GNUNET_SERVER_Handle *server) 259GAS_performance_init ()
270{ 260{
271 nc_no_pic = GNUNET_SERVER_notification_context_create (server, 32); 261 nc_no_pic = GNUNET_notification_context_create (32);
272 nc_pic = GNUNET_SERVER_notification_context_create (server, 32); 262 nc_pic = GNUNET_notification_context_create (32);
273} 263}
274 264
275 265
@@ -279,9 +269,9 @@ GAS_performance_init (struct GNUNET_SERVER_Handle *server)
279void 269void
280GAS_performance_done () 270GAS_performance_done ()
281{ 271{
282 GNUNET_SERVER_notification_context_destroy (nc_no_pic); 272 GNUNET_notification_context_destroy (nc_no_pic);
283 nc_no_pic = NULL; 273 nc_no_pic = NULL;
284 GNUNET_SERVER_notification_context_destroy (nc_pic); 274 GNUNET_notification_context_destroy (nc_pic);
285 nc_pic = NULL; 275 nc_pic = NULL;
286} 276}
287 277
diff --git a/src/ats/gnunet-service-ats_performance.h b/src/ats/gnunet-service-ats_performance.h
index bbaa8bc2b..7958a84e5 100644
--- a/src/ats/gnunet-service-ats_performance.h
+++ b/src/ats/gnunet-service-ats_performance.h
@@ -68,7 +68,7 @@ GAS_performance_notify_all_clients (const struct GNUNET_PeerIdentity *peer,
68 * @param flag flag specifying the type of the client 68 * @param flag flag specifying the type of the client
69 */ 69 */
70void 70void
71GAS_performance_add_client (struct GNUNET_SERVER_Client *client, 71GAS_performance_add_client (struct GNUNET_SERVICE_Client *client,
72 enum StartFlag flag); 72 enum StartFlag flag);
73 73
74 74
@@ -79,7 +79,7 @@ GAS_performance_add_client (struct GNUNET_SERVER_Client *client,
79 * @param addresses the address handle to use 79 * @param addresses the address handle to use
80 */ 80 */
81void 81void
82GAS_performance_init (struct GNUNET_SERVER_Handle *server); 82GAS_performance_init (void);
83 83
84 84
85/** 85/**
diff --git a/src/ats/gnunet-service-ats_plugins.c b/src/ats/gnunet-service-ats_plugins.c
index c2388e28b..f70c4cd9b 100644
--- a/src/ats/gnunet-service-ats_plugins.c
+++ b/src/ats/gnunet-service-ats_plugins.c
@@ -510,7 +510,7 @@ GAS_plugin_delete_address (struct ATS_Address *address)
510 * @param score_abs degree of the appreciation 510 * @param score_abs degree of the appreciation
511 */ 511 */
512void 512void
513GAS_plugin_notify_feedback (struct GNUNET_SERVER_Client *application, 513GAS_plugin_notify_feedback (struct GNUNET_SERVICE_Client *application,
514 const struct GNUNET_PeerIdentity *peer, 514 const struct GNUNET_PeerIdentity *peer,
515 const struct GNUNET_TIME_Relative scope, 515 const struct GNUNET_TIME_Relative scope,
516 enum GNUNET_ATS_PreferenceKind kind, 516 enum GNUNET_ATS_PreferenceKind kind,
diff --git a/src/ats/gnunet-service-ats_plugins.h b/src/ats/gnunet-service-ats_plugins.h
index 3f3261767..8b12416c6 100644
--- a/src/ats/gnunet-service-ats_plugins.h
+++ b/src/ats/gnunet-service-ats_plugins.h
@@ -105,7 +105,7 @@ GAS_plugin_delete_address (struct ATS_Address *address);
105 * @param score_abs degree of the appreciation 105 * @param score_abs degree of the appreciation
106 */ 106 */
107void 107void
108GAS_plugin_notify_feedback (struct GNUNET_SERVER_Client *application, 108GAS_plugin_notify_feedback (struct GNUNET_SERVICE_Client *application,
109 const struct GNUNET_PeerIdentity *peer, 109 const struct GNUNET_PeerIdentity *peer,
110 const struct GNUNET_TIME_Relative scope, 110 const struct GNUNET_TIME_Relative scope,
111 enum GNUNET_ATS_PreferenceKind kind, 111 enum GNUNET_ATS_PreferenceKind kind,
diff --git a/src/ats/gnunet-service-ats_preferences.c b/src/ats/gnunet-service-ats_preferences.c
index 64779bbca..9f11dc6a8 100644
--- a/src/ats/gnunet-service-ats_preferences.c
+++ b/src/ats/gnunet-service-ats_preferences.c
@@ -132,7 +132,7 @@ struct PreferenceClient
132 /** 132 /**
133 * Client handle 133 * Client handle
134 */ 134 */
135 struct GNUNET_SERVER_Client *client; 135 struct GNUNET_SERVICE_Client *client;
136 136
137 /** 137 /**
138 * Mapping peer identities to `struct PreferencePeer` entry 138 * Mapping peer identities to `struct PreferencePeer` entry
@@ -553,7 +553,7 @@ update_iterator (void *cls,
553 * @param score_abs the normalized score 553 * @param score_abs the normalized score
554 */ 554 */
555static void 555static void
556update_preference (struct GNUNET_SERVER_Client *client, 556update_preference (struct GNUNET_SERVICE_Client *client,
557 const struct GNUNET_PeerIdentity *peer, 557 const struct GNUNET_PeerIdentity *peer,
558 enum GNUNET_ATS_PreferenceKind kind, 558 enum GNUNET_ATS_PreferenceKind kind,
559 float score_abs) 559 float score_abs)
@@ -646,41 +646,17 @@ update_preference (struct GNUNET_SERVER_Client *client,
646/** 646/**
647 * Handle 'preference change' messages from clients. 647 * Handle 'preference change' messages from clients.
648 * 648 *
649 * @param cls unused, NULL 649 * @param client the client that sent the request
650 * @param client client that sent the request 650 * @param msg the request message
651 * @param message the request message
652 */ 651 */
653void 652void
654GAS_handle_preference_change (void *cls, 653GAS_handle_preference_change (struct GNUNET_SERVICE_Client *client,
655 struct GNUNET_SERVER_Client *client, 654 const struct ChangePreferenceMessage *msg)
656 const struct GNUNET_MessageHeader *message)
657{ 655{
658 const struct ChangePreferenceMessage *msg;
659 const struct PreferenceInformation *pi; 656 const struct PreferenceInformation *pi;
660 uint16_t msize;
661 uint32_t nump; 657 uint32_t nump;
662 uint32_t i;
663 658
664 msize = ntohs (message->size);
665 if (msize < sizeof (struct ChangePreferenceMessage))
666 {
667 GNUNET_break (0);
668 GNUNET_SERVER_receive_done (client,
669 GNUNET_SYSERR);
670 return;
671 }
672 msg = (const struct ChangePreferenceMessage *) message;
673 nump = ntohl (msg->num_preferences); 659 nump = ntohl (msg->num_preferences);
674 if ( (msize !=
675 sizeof (struct ChangePreferenceMessage) +
676 nump * sizeof (struct PreferenceInformation)) ||
677 (UINT16_MAX / sizeof (struct PreferenceInformation) < nump) )
678 {
679 GNUNET_break (0);
680 GNUNET_SERVER_receive_done (client,
681 GNUNET_SYSERR);
682 return;
683 }
684 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, 660 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
685 "Received PREFERENCE_CHANGE message for peer `%s'\n", 661 "Received PREFERENCE_CHANGE message for peer `%s'\n",
686 GNUNET_i2s (&msg->peer)); 662 GNUNET_i2s (&msg->peer));
@@ -690,14 +666,12 @@ GAS_handle_preference_change (void *cls,
690 GNUNET_NO); 666 GNUNET_NO);
691 pi = (const struct PreferenceInformation *) &msg[1]; 667 pi = (const struct PreferenceInformation *) &msg[1];
692 GAS_plugin_solver_lock (); 668 GAS_plugin_solver_lock ();
693 for (i = 0; i < nump; i++) 669 for (uint32_t i = 0; i < nump; i++)
694 update_preference (client, 670 update_preference (client,
695 &msg->peer, 671 &msg->peer,
696 (enum GNUNET_ATS_PreferenceKind) ntohl (pi[i].preference_kind), 672 (enum GNUNET_ATS_PreferenceKind) ntohl (pi[i].preference_kind),
697 pi[i].preference_value); 673 pi[i].preference_value);
698 GAS_plugin_solver_unlock (); 674 GAS_plugin_solver_unlock ();
699 GNUNET_SERVER_receive_done (client,
700 GNUNET_OK);
701} 675}
702 676
703 677
@@ -782,7 +756,7 @@ GAS_preference_get_by_peer (void *cls,
782 * @param client the client 756 * @param client the client
783 */ 757 */
784void 758void
785GAS_preference_client_disconnect (struct GNUNET_SERVER_Client *client) 759GAS_preference_client_disconnect (struct GNUNET_SERVICE_Client *client)
786{ 760{
787 struct PreferenceClient *c_cur; 761 struct PreferenceClient *c_cur;
788 762
diff --git a/src/ats/gnunet-service-ats_preferences.h b/src/ats/gnunet-service-ats_preferences.h
index 3a483d816..fe01aa573 100644
--- a/src/ats/gnunet-service-ats_preferences.h
+++ b/src/ats/gnunet-service-ats_preferences.h
@@ -46,14 +46,12 @@
46/** 46/**
47 * Handle 'preference change' messages from clients. 47 * Handle 'preference change' messages from clients.
48 * 48 *
49 * @param cls unused, NULL 49 * @param client the client that sent the request
50 * @param client client that sent the request 50 * @param msg the request message
51 * @param message the request message
52 */ 51 */
53void 52void
54GAS_handle_preference_change (void *cls, 53GAS_handle_preference_change (struct GNUNET_SERVICE_Client *client,
55 struct GNUNET_SERVER_Client *client, 54 const struct ChangePreferenceMessage *msg);
56 const struct GNUNET_MessageHeader *message);
57 55
58 56
59/** 57/**
@@ -89,7 +87,7 @@ GAS_preference_get_by_peer (void *cls,
89 * @param client the disconnecting client 87 * @param client the disconnecting client
90 */ 88 */
91void 89void
92GAS_preference_client_disconnect (struct GNUNET_SERVER_Client *client); 90GAS_preference_client_disconnect (struct GNUNET_SERVICE_Client *client);
93 91
94 92
95#endif 93#endif
diff --git a/src/ats/gnunet-service-ats_reservations.c b/src/ats/gnunet-service-ats_reservations.c
index 97098c819..95952e96f 100644
--- a/src/ats/gnunet-service-ats_reservations.c
+++ b/src/ats/gnunet-service-ats_reservations.c
@@ -138,63 +138,43 @@ GAS_reservations_set_bandwidth (const struct GNUNET_PeerIdentity *peer,
138/** 138/**
139 * Handle 'reservation request' messages from clients. 139 * Handle 'reservation request' messages from clients.
140 * 140 *
141 * @param cls unused, NULL
142 * @param client client that sent the request 141 * @param client client that sent the request
143 * @param message the request message 142 * @param msg the request message
144 */ 143 */
145void 144void
146GAS_handle_reservation_request (void *cls, 145GAS_handle_reservation_request (struct GNUNET_SERVICE_Client *client,
147 struct GNUNET_SERVER_Client *client, 146 const struct ReservationRequestMessage *msg)
148 const struct GNUNET_MessageHeader *message)
149{ 147{
150 const struct ReservationRequestMessage *msg = 148 struct GNUNET_MQ_Envelope *env;
151 (const struct ReservationRequestMessage *) message; 149 struct ReservationResultMessage *result;
152 struct ReservationResultMessage result;
153 int32_t amount; 150 int32_t amount;
154 struct GNUNET_TIME_Relative res_delay; 151 struct GNUNET_TIME_Relative res_delay;
155 struct GNUNET_SERVER_NotificationContext **uc;
156 struct GNUNET_SERVER_NotificationContext *nc;
157 152
158 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, 153 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
159 "Received RESERVATION_REQUEST message\n"); 154 "Received RESERVATION_REQUEST message\n");
160 uc = GNUNET_SERVER_client_get_user_context (client,
161 struct GNUNET_SERVER_NotificationContext *);
162 if (NULL == uc)
163 {
164 GNUNET_break (0);
165 return;
166 }
167 nc = *uc;
168 amount = (int32_t) ntohl (msg->amount); 155 amount = (int32_t) ntohl (msg->amount);
169 res_delay = reservations_reserve (&msg->peer, amount); 156 res_delay = reservations_reserve (&msg->peer, amount);
170 if (res_delay.rel_value_us > 0) 157 if (res_delay.rel_value_us > 0)
171 amount = 0; 158 amount = 0;
172 result.header.size = htons (sizeof (struct ReservationResultMessage)); 159 env = GNUNET_MQ_msg (result,
173 result.header.type = htons (GNUNET_MESSAGE_TYPE_ATS_RESERVATION_RESULT); 160 GNUNET_MESSAGE_TYPE_ATS_RESERVATION_RESULT);
174 result.amount = htonl (amount); 161 result->amount = htonl (amount);
175 result.peer = msg->peer; 162 result->peer = msg->peer;
176 result.res_delay = GNUNET_TIME_relative_hton (res_delay); 163 result->res_delay = GNUNET_TIME_relative_hton (res_delay);
177 GNUNET_STATISTICS_update (GSA_stats, 164 GNUNET_STATISTICS_update (GSA_stats,
178 "# reservation requests processed", 165 "# reservation requests processed",
179 1, 166 1,
180 GNUNET_NO); 167 GNUNET_NO);
181 168 GNUNET_MQ_send (GNUNET_SERVICE_client_get_mq (client),
182 GNUNET_SERVER_notification_context_unicast (nc, 169 env);
183 client,
184 &result.header,
185 GNUNET_NO);
186 GNUNET_SERVER_receive_done (client,
187 GNUNET_OK);
188} 170}
189 171
190 172
191/** 173/**
192 * Initialize reservations subsystem. 174 * Initialize reservations subsystem.
193 *
194 * @param server handle to our server
195 */ 175 */
196void 176void
197GAS_reservations_init (struct GNUNET_SERVER_Handle *server) 177GAS_reservations_init ()
198{ 178{
199 trackers = GNUNET_CONTAINER_multipeermap_create (128, 179 trackers = GNUNET_CONTAINER_multipeermap_create (128,
200 GNUNET_NO); 180 GNUNET_NO);
@@ -211,7 +191,8 @@ GAS_reservations_init (struct GNUNET_SERVER_Handle *server)
211 */ 191 */
212static int 192static int
213free_tracker (void *cls, 193free_tracker (void *cls,
214 const struct GNUNET_PeerIdentity *key, void *value) 194 const struct GNUNET_PeerIdentity *key,
195 void *value)
215{ 196{
216 struct GNUNET_BANDWIDTH_Tracker *tracker = value; 197 struct GNUNET_BANDWIDTH_Tracker *tracker = value;
217 198
diff --git a/src/ats/gnunet-service-ats_reservations.h b/src/ats/gnunet-service-ats_reservations.h
index cc51e82a5..ec28053b5 100644
--- a/src/ats/gnunet-service-ats_reservations.h
+++ b/src/ats/gnunet-service-ats_reservations.h
@@ -27,6 +27,7 @@
27#define GNUNET_SERVICE_ATS_RESERVATIONS_H 27#define GNUNET_SERVICE_ATS_RESERVATIONS_H
28 28
29#include "gnunet_util_lib.h" 29#include "gnunet_util_lib.h"
30#include "ats.h"
30 31
31 32
32/** 33/**
@@ -46,14 +47,12 @@ GAS_reservations_set_bandwidth (const struct GNUNET_PeerIdentity *peer,
46/** 47/**
47 * Handle 'reservation request' messages from clients. 48 * Handle 'reservation request' messages from clients.
48 * 49 *
49 * @param cls unused, NULL
50 * @param client client that sent the request 50 * @param client client that sent the request
51 * @param message the request message 51 * @param message the request message
52 */ 52 */
53void 53void
54GAS_handle_reservation_request (void *cls, 54GAS_handle_reservation_request (struct GNUNET_SERVICE_Client *client,
55 struct GNUNET_SERVER_Client *client, 55 const struct ReservationRequestMessage *message);
56 const struct GNUNET_MessageHeader *message);
57 56
58 57
59/** 58/**
@@ -62,7 +61,7 @@ GAS_handle_reservation_request (void *cls,
62 * @param server handle to our server 61 * @param server handle to our server
63 */ 62 */
64void 63void
65GAS_reservations_init (struct GNUNET_SERVER_Handle *server); 64GAS_reservations_init (void);
66 65
67 66
68/** 67/**
diff --git a/src/ats/gnunet-service-ats_scheduling.c b/src/ats/gnunet-service-ats_scheduling.c
index f19370f7a..fd7eff8fb 100644
--- a/src/ats/gnunet-service-ats_scheduling.c
+++ b/src/ats/gnunet-service-ats_scheduling.c
@@ -1,6 +1,6 @@
1/* 1/*
2 This file is part of GNUnet. 2 This file is part of GNUnet.
3 Copyright (C) 2011-2014 GNUnet e.V. 3 Copyright (C) 2011-2016 GNUnet e.V.
4 4
5 GNUnet is free software; you can redistribute it and/or modify 5 GNUnet is free software; you can redistribute it and/or modify
6 it under the terms of the GNU General Public License as published 6 it under the terms of the GNU General Public License as published
@@ -29,16 +29,10 @@
29#include "gnunet-service-ats_scheduling.h" 29#include "gnunet-service-ats_scheduling.h"
30#include "ats.h" 30#include "ats.h"
31 31
32
33/**
34 * Context for sending messages to clients.
35 */
36static struct GNUNET_SERVER_NotificationContext *nc;
37
38/** 32/**
39 * Actual handle to the client. 33 * Actual handle to the client.
40 */ 34 */
41static struct GNUNET_SERVER_Client *my_client; 35static struct GNUNET_SERVICE_Client *my_client;
42 36
43 37
44/** 38/**
@@ -48,7 +42,7 @@ static struct GNUNET_SERVER_Client *my_client;
48 * @return #GNUNET_OK on success, #GNUNET_SYSERR on error 42 * @return #GNUNET_OK on success, #GNUNET_SYSERR on error
49 */ 43 */
50int 44int
51GAS_scheduling_add_client (struct GNUNET_SERVER_Client *client) 45GAS_scheduling_add_client (struct GNUNET_SERVICE_Client *client)
52{ 46{
53 if (NULL != my_client) 47 if (NULL != my_client)
54 { 48 {
@@ -57,10 +51,6 @@ GAS_scheduling_add_client (struct GNUNET_SERVER_Client *client)
57 return GNUNET_SYSERR; 51 return GNUNET_SYSERR;
58 } 52 }
59 my_client = client; 53 my_client = client;
60 GNUNET_SERVER_notification_context_add (nc,
61 client);
62 GNUNET_SERVER_client_set_user_context (client,
63 &nc);
64 return GNUNET_OK; 54 return GNUNET_OK;
65} 55}
66 56
@@ -72,7 +62,7 @@ GAS_scheduling_add_client (struct GNUNET_SERVER_Client *client)
72 * @param client handle of the (now dead) client 62 * @param client handle of the (now dead) client
73 */ 63 */
74void 64void
75GAS_scheduling_remove_client (struct GNUNET_SERVER_Client *client) 65GAS_scheduling_remove_client (struct GNUNET_SERVICE_Client *client)
76{ 66{
77 if (my_client != client) 67 if (my_client != client)
78 return; 68 return;
@@ -96,7 +86,8 @@ GAS_scheduling_transmit_address_suggestion (const struct GNUNET_PeerIdentity *pe
96 struct GNUNET_BANDWIDTH_Value32NBO bandwidth_out, 86 struct GNUNET_BANDWIDTH_Value32NBO bandwidth_out,
97 struct GNUNET_BANDWIDTH_Value32NBO bandwidth_in) 87 struct GNUNET_BANDWIDTH_Value32NBO bandwidth_in)
98{ 88{
99 struct AddressSuggestionMessage msg; 89 struct GNUNET_MQ_Envelope *env;
90 struct AddressSuggestionMessage *msg;
100 91
101 if (NULL == my_client) 92 if (NULL == my_client)
102 return; 93 return;
@@ -104,55 +95,39 @@ GAS_scheduling_transmit_address_suggestion (const struct GNUNET_PeerIdentity *pe
104 "# address suggestions made", 95 "# address suggestions made",
105 1, 96 1,
106 GNUNET_NO); 97 GNUNET_NO);
107 msg.header.size = htons (sizeof (struct AddressSuggestionMessage)); 98 env = GNUNET_MQ_msg (msg,
108 msg.header.type = htons (GNUNET_MESSAGE_TYPE_ATS_ADDRESS_SUGGESTION); 99 GNUNET_MESSAGE_TYPE_ATS_ADDRESS_SUGGESTION);
109 msg.peer = *peer; 100 msg->peer = *peer;
110 msg.session_id = htonl (session_id); 101 msg->session_id = htonl (session_id);
111 msg.bandwidth_out = bandwidth_out; 102 msg->bandwidth_out = bandwidth_out;
112 msg.bandwidth_in = bandwidth_in; 103 msg->bandwidth_in = bandwidth_in;
113 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, 104 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
114 "ATS sends quota for peer `%s': (in/out) %u/%u\n", 105 "ATS sends quota for peer `%s': (in/out) %u/%u\n",
115 GNUNET_i2s (peer), 106 GNUNET_i2s (peer),
116 (unsigned int) ntohl (bandwidth_in.value__), 107 (unsigned int) ntohl (bandwidth_in.value__),
117 (unsigned int) ntohl (bandwidth_out.value__)); 108 (unsigned int) ntohl (bandwidth_out.value__));
118 GNUNET_SERVER_notification_context_unicast (nc, 109 GNUNET_MQ_send (GNUNET_SERVICE_client_get_mq (my_client),
119 my_client, 110 env);
120 &msg.header,
121 GNUNET_YES);
122} 111}
123 112
124 113
125/** 114/**
126 * Handle 'address add' messages from clients. 115 * Handle 'address add' messages from clients.
127 * 116 *
128 * @param cls unused, NULL 117 * @param m the request message
129 * @param client client that sent the request
130 * @param message the request message
131 */ 118 */
132void 119void
133GAS_handle_address_add (void *cls, 120GAS_handle_address_add (const struct AddressAddMessage *m)
134 struct GNUNET_SERVER_Client *client,
135 const struct GNUNET_MessageHeader *message)
136{ 121{
137 const struct AddressAddMessage *m;
138 const char *address; 122 const char *address;
139 const char *plugin_name; 123 const char *plugin_name;
140 uint16_t address_length; 124 uint16_t address_length;
141 uint16_t plugin_name_length; 125 uint16_t plugin_name_length;
142 uint16_t size;
143 struct GNUNET_ATS_Properties prop; 126 struct GNUNET_ATS_Properties prop;
144 127
145 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, 128 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
146 "Received `%s' message\n", 129 "Received `%s' message\n",
147 "ADDRESS_ADD"); 130 "ADDRESS_ADD");
148 size = ntohs (message->size);
149 if (size < sizeof (struct AddressAddMessage))
150 {
151 GNUNET_break (0);
152 GNUNET_SERVER_receive_done (client, GNUNET_SYSERR);
153 return;
154 }
155 m = (const struct AddressAddMessage *) message;
156 address_length = ntohs (m->address_length); 131 address_length = ntohs (m->address_length);
157 plugin_name_length = ntohs (m->plugin_name_length); 132 plugin_name_length = ntohs (m->plugin_name_length);
158 address = (const char *) &m[1]; 133 address = (const char *) &m[1];
@@ -160,16 +135,6 @@ GAS_handle_address_add (void *cls,
160 plugin_name = &address[address_length]; 135 plugin_name = &address[address_length];
161 else 136 else
162 plugin_name = ""; 137 plugin_name = "";
163
164 if ((address_length + plugin_name_length +
165 sizeof (struct AddressAddMessage) != ntohs (message->size)) ||
166 ( (plugin_name_length > 0) &&
167 (plugin_name[plugin_name_length - 1] != '\0') ) )
168 {
169 GNUNET_break (0);
170 GNUNET_SERVER_receive_done (client, GNUNET_SYSERR);
171 return;
172 }
173 GNUNET_STATISTICS_update (GSA_stats, 138 GNUNET_STATISTICS_update (GSA_stats,
174 "# addresses created", 139 "# addresses created",
175 1, 140 1,
@@ -184,27 +149,19 @@ GAS_handle_address_add (void *cls,
184 ntohl (m->address_local_info), 149 ntohl (m->address_local_info),
185 ntohl (m->session_id), 150 ntohl (m->session_id),
186 &prop); 151 &prop);
187 GNUNET_SERVER_receive_done (client,
188 GNUNET_OK);
189} 152}
190 153
191 154
192/** 155/**
193 * Handle 'address update' messages from clients. 156 * Handle 'address update' messages from clients.
194 * 157 *
195 * @param cls unused, NULL 158 * @param m the request message
196 * @param client client that sent the request
197 * @param message the request message
198 */ 159 */
199void 160void
200GAS_handle_address_update (void *cls, 161GAS_handle_address_update (const struct AddressUpdateMessage *m)
201 struct GNUNET_SERVER_Client *client,
202 const struct GNUNET_MessageHeader *message)
203{ 162{
204 const struct AddressUpdateMessage *m;
205 struct GNUNET_ATS_Properties prop; 163 struct GNUNET_ATS_Properties prop;
206 164
207 m = (const struct AddressUpdateMessage *) message;
208 GNUNET_STATISTICS_update (GSA_stats, 165 GNUNET_STATISTICS_update (GSA_stats,
209 "# address updates received", 166 "# address updates received",
210 1, 167 1,
@@ -214,27 +171,20 @@ GAS_handle_address_update (void *cls,
214 GAS_addresses_update (&m->peer, 171 GAS_addresses_update (&m->peer,
215 ntohl (m->session_id), 172 ntohl (m->session_id),
216 &prop); 173 &prop);
217 GNUNET_SERVER_receive_done (client,
218 GNUNET_OK);
219} 174}
220 175
221 176
222/** 177/**
223 * Handle 'address destroyed' messages from clients. 178 * Handle 'address destroyed' messages from clients.
224 * 179 *
225 * @param cls unused, NULL 180 * @param m the request message
226 * @param client client that sent the request
227 * @param message the request message
228 */ 181 */
229void 182void
230GAS_handle_address_destroyed (void *cls, 183GAS_handle_address_destroyed (const struct AddressDestroyedMessage *m)
231 struct GNUNET_SERVER_Client *client,
232 const struct GNUNET_MessageHeader *message)
233{ 184{
234 const struct AddressDestroyedMessage *m; 185 struct GNUNET_MQ_Envelope *env;
235 struct GNUNET_ATS_SessionReleaseMessage srm; 186 struct GNUNET_ATS_SessionReleaseMessage *srm;
236 187
237 m = (const struct AddressDestroyedMessage *) message;
238 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, 188 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
239 "Received `%s' message\n", 189 "Received `%s' message\n",
240 "ADDRESS_DESTROYED"); 190 "ADDRESS_DESTROYED");
@@ -244,42 +194,12 @@ GAS_handle_address_destroyed (void *cls,
244 GNUNET_NO); 194 GNUNET_NO);
245 GAS_addresses_destroy (&m->peer, 195 GAS_addresses_destroy (&m->peer,
246 ntohl (m->session_id)); 196 ntohl (m->session_id));
247 srm.header.type = ntohs (GNUNET_MESSAGE_TYPE_ATS_SESSION_RELEASE); 197 env = GNUNET_MQ_msg (srm,
248 srm.header.size = ntohs (sizeof (struct GNUNET_ATS_SessionReleaseMessage)); 198 GNUNET_MESSAGE_TYPE_ATS_SESSION_RELEASE);
249 srm.session_id = m->session_id; 199 srm->session_id = m->session_id;
250 srm.peer = m->peer; 200 srm->peer = m->peer;
251 GNUNET_SERVER_notification_context_unicast (nc, 201 GNUNET_MQ_send (GNUNET_SERVICE_client_get_mq (my_client),
252 client, 202 env);
253 &srm.header,
254 GNUNET_NO);
255 GNUNET_SERVER_receive_done (client, GNUNET_OK);
256}
257
258
259/**
260 * Initialize scheduling subsystem.
261 *
262 * @param server handle to our server
263 */
264void
265GAS_scheduling_init (struct GNUNET_SERVER_Handle *server)
266{
267 nc = GNUNET_SERVER_notification_context_create (server, 128);
268}
269
270
271/**
272 * Shutdown scheduling subsystem.
273 */
274void
275GAS_scheduling_done ()
276{
277 if (NULL != my_client)
278 {
279 my_client = NULL;
280 }
281 GNUNET_SERVER_notification_context_destroy (nc);
282 nc = NULL;
283} 203}
284 204
285 205
diff --git a/src/ats/gnunet-service-ats_scheduling.h b/src/ats/gnunet-service-ats_scheduling.h
index 99dc6084b..26cb2c73a 100644
--- a/src/ats/gnunet-service-ats_scheduling.h
+++ b/src/ats/gnunet-service-ats_scheduling.h
@@ -37,7 +37,7 @@
37 * @return #GNUNET_OK on success, #GNUNET_SYSERR on error 37 * @return #GNUNET_OK on success, #GNUNET_SYSERR on error
38 */ 38 */
39int 39int
40GAS_scheduling_add_client (struct GNUNET_SERVER_Client *client); 40GAS_scheduling_add_client (struct GNUNET_SERVICE_Client *client);
41 41
42 42
43/** 43/**
@@ -47,7 +47,7 @@ GAS_scheduling_add_client (struct GNUNET_SERVER_Client *client);
47 * @param client handle of the (now dead) client 47 * @param client handle of the (now dead) client
48 */ 48 */
49void 49void
50GAS_scheduling_remove_client (struct GNUNET_SERVER_Client *client); 50GAS_scheduling_remove_client (struct GNUNET_SERVICE_Client *client);
51 51
52 52
53/** 53/**
@@ -69,57 +69,29 @@ GAS_scheduling_transmit_address_suggestion (const struct GNUNET_PeerIdentity *pe
69/** 69/**
70 * Handle 'address add' messages from clients. 70 * Handle 'address add' messages from clients.
71 * 71 *
72 * @param cls unused, NULL
73 * @param client client that sent the request 72 * @param client client that sent the request
74 * @param message the request message 73 * @param m the request message
75 */ 74 */
76void 75void
77GAS_handle_address_add (void *cls, 76GAS_handle_address_add (const struct AddressAddMessage *m);
78 struct GNUNET_SERVER_Client *client,
79 const struct GNUNET_MessageHeader *message);
80 77
81 78
82/** 79/**
83 * Handle 'address update' messages from clients. 80 * Handle 'address update' messages from clients.
84 * 81 *
85 * @param cls unused, NULL 82 * @param m the request message
86 * @param client client that sent the request
87 * @param message the request message
88 */ 83 */
89void 84void
90GAS_handle_address_update (void *cls, 85GAS_handle_address_update (const struct AddressUpdateMessage *m);
91 struct GNUNET_SERVER_Client *client,
92 const struct GNUNET_MessageHeader *message);
93 86
94 87
95/** 88/**
96 * Handle 'address destroyed' messages from clients. 89 * Handle 'address destroyed' messages from clients.
97 * 90 *
98 * @param cls unused, NULL 91 * @param m the request message
99 * @param client client that sent the request
100 * @param message the request message
101 */
102void
103GAS_handle_address_destroyed (void *cls,
104 struct GNUNET_SERVER_Client *client,
105 const struct GNUNET_MessageHeader *message);
106
107
108/**
109 * Initialize scheduling subsystem.
110 *
111 * @param server handle to our server
112 * @param ah the address handle to use
113 */
114void
115GAS_scheduling_init (struct GNUNET_SERVER_Handle *server);
116
117
118/**
119 * Shutdown scheduling subsystem.
120 */ 92 */
121void 93void
122GAS_scheduling_done (void); 94GAS_handle_address_destroyed (const struct AddressDestroyedMessage *m);
123 95
124 96
125#endif 97#endif
diff --git a/src/ats/plugin_ats_mlp.c b/src/ats/plugin_ats_mlp.c
index e6a790377..90f99cb5d 100644
--- a/src/ats/plugin_ats_mlp.c
+++ b/src/ats/plugin_ats_mlp.c
@@ -2281,7 +2281,7 @@ GAS_mlp_address_change_preference (void *solver,
2281 */ 2281 */
2282static void 2282static void
2283GAS_mlp_address_preference_feedback (void *solver, 2283GAS_mlp_address_preference_feedback (void *solver,
2284 struct GNUNET_SERVER_Client *application, 2284 struct GNUNET_SERVICE_Client *application,
2285 const struct GNUNET_PeerIdentity *peer, 2285 const struct GNUNET_PeerIdentity *peer,
2286 const struct GNUNET_TIME_Relative scope, 2286 const struct GNUNET_TIME_Relative scope,
2287 enum GNUNET_ATS_PreferenceKind kind, 2287 enum GNUNET_ATS_PreferenceKind kind,
diff --git a/src/ats/plugin_ats_proportional.c b/src/ats/plugin_ats_proportional.c
index 7d55fcad3..9309bc2ea 100644
--- a/src/ats/plugin_ats_proportional.c
+++ b/src/ats/plugin_ats_proportional.c
@@ -879,7 +879,7 @@ GAS_proportional_change_preference (void *solver,
879 */ 879 */
880static void 880static void
881GAS_proportional_feedback (void *solver, 881GAS_proportional_feedback (void *solver,
882 struct GNUNET_SERVER_Client *application, 882 struct GNUNET_SERVICE_Client *application,
883 const struct GNUNET_PeerIdentity *peer, 883 const struct GNUNET_PeerIdentity *peer,
884 const struct GNUNET_TIME_Relative scope, 884 const struct GNUNET_TIME_Relative scope,
885 enum GNUNET_ATS_PreferenceKind kind, 885 enum GNUNET_ATS_PreferenceKind kind,
diff --git a/src/ats/plugin_ats_ril.c b/src/ats/plugin_ats_ril.c
index eac62c440..a3bdf200c 100644
--- a/src/ats/plugin_ats_ril.c
+++ b/src/ats/plugin_ats_ril.c
@@ -2373,7 +2373,7 @@ GAS_ril_address_property_changed (void *solver,
2373 */ 2373 */
2374static void 2374static void
2375GAS_ril_address_preference_feedback (void *solver, 2375GAS_ril_address_preference_feedback (void *solver,
2376 struct GNUNET_SERVER_Client *application, 2376 struct GNUNET_SERVICE_Client *application,
2377 const struct GNUNET_PeerIdentity *peer, 2377 const struct GNUNET_PeerIdentity *peer,
2378 const struct GNUNET_TIME_Relative scope, 2378 const struct GNUNET_TIME_Relative scope,
2379 enum GNUNET_ATS_PreferenceKind kind, 2379 enum GNUNET_ATS_PreferenceKind kind,