aboutsummaryrefslogtreecommitdiff
path: root/src/ats/gnunet-service-ats_performance.c
diff options
context:
space:
mode:
authorChristian Grothoff <christian@grothoff.org>2014-06-16 09:34:22 +0000
committerChristian Grothoff <christian@grothoff.org>2014-06-16 09:34:22 +0000
commitc1d89ed3cf92fa2492a5639e725aadd74742f135 (patch)
tree2c3b364f98947d36151e148eba8978f98b960da4 /src/ats/gnunet-service-ats_performance.c
parentc345e101fd271feb03c311d0ec1837fc6cf179f3 (diff)
downloadgnunet-c1d89ed3cf92fa2492a5639e725aadd74742f135.tar.gz
gnunet-c1d89ed3cf92fa2492a5639e725aadd74742f135.zip
do not use session_id in GAS_performance_notify_all_clients, needs to be 'active'; also indentation/doxygen
Diffstat (limited to 'src/ats/gnunet-service-ats_performance.c')
-rw-r--r--src/ats/gnunet-service-ats_performance.c191
1 files changed, 129 insertions, 62 deletions
diff --git a/src/ats/gnunet-service-ats_performance.c b/src/ats/gnunet-service-ats_performance.c
index 5a1d8cc66..2171ba697 100644
--- a/src/ats/gnunet-service-ats_performance.c
+++ b/src/ats/gnunet-service-ats_performance.c
@@ -114,6 +114,7 @@ find_client (struct GNUNET_SERVER_Client *client)
114 return NULL; 114 return NULL;
115} 115}
116 116
117
117/** 118/**
118 * Unregister a client (which may have been a performance client, 119 * Unregister a client (which may have been a performance client,
119 * but this is not assured). 120 * but this is not assured).
@@ -133,6 +134,7 @@ GAS_performance_remove_client (struct GNUNET_SERVER_Client *client)
133 GNUNET_free (pc); 134 GNUNET_free (pc);
134} 135}
135 136
137
136/** 138/**
137 * Transmit the given performance information to all performance 139 * Transmit the given performance information to all performance
138 * clients. 140 * clients.
@@ -152,7 +154,8 @@ void
152GAS_performance_notify_client (struct PerformanceClient *pc, 154GAS_performance_notify_client (struct PerformanceClient *pc,
153 const struct GNUNET_PeerIdentity *peer, 155 const struct GNUNET_PeerIdentity *peer,
154 const char *plugin_name, 156 const char *plugin_name,
155 const void *plugin_addr, size_t plugin_addr_len, 157 const void *plugin_addr,
158 size_t plugin_addr_len,
156 int active, 159 int active,
157 const struct GNUNET_ATS_Information *atsi, 160 const struct GNUNET_ATS_Information *atsi,
158 uint32_t atsi_count, 161 uint32_t atsi_count,
@@ -195,7 +198,9 @@ GAS_performance_notify_client (struct PerformanceClient *pc,
195 addrp = (char *) &atsp[atsi_count]; 198 addrp = (char *) &atsp[atsi_count];
196 memcpy (addrp, plugin_addr, plugin_addr_len); 199 memcpy (addrp, plugin_addr, plugin_addr_len);
197 strcpy (&addrp[plugin_addr_len], plugin_name); 200 strcpy (&addrp[plugin_addr_len], plugin_name);
198 GNUNET_SERVER_notification_context_unicast (nc, pc->client, &msg->header, 201 GNUNET_SERVER_notification_context_unicast (nc,
202 pc->client,
203 &msg->header,
199 GNUNET_YES); 204 GNUNET_YES);
200} 205}
201 206
@@ -207,23 +212,23 @@ GAS_performance_notify_client (struct PerformanceClient *pc,
207 * @param peer peer for which this is an address suggestion 212 * @param peer peer for which this is an address suggestion
208 * @param plugin_name 0-termintated string specifying the transport plugin 213 * @param plugin_name 0-termintated string specifying the transport plugin
209 * @param plugin_addr binary address for the plugin to use 214 * @param plugin_addr binary address for the plugin to use
210 * @param plugin_addr_len number of bytes in plugin_addr 215 * @param plugin_addr_len number of bytes in @a plugin_addr
211 * @param active is this address active 216 * @param active is this address active
212 * @param atsi performance data for the address 217 * @param atsi performance data for the address
213 * @param atsi_count number of performance records in 'ats' 218 * @param atsi_count number of performance records in @a atsi
214 * @param bandwidth_out assigned outbound bandwidth 219 * @param bandwidth_out assigned outbound bandwidth
215 * @param bandwidth_in assigned inbound bandwidth 220 * @param bandwidth_in assigned inbound bandwidth
216 */ 221 */
217void 222void
218GAS_performance_notify_all_clients (const struct GNUNET_PeerIdentity *peer, 223GAS_performance_notify_all_clients (const struct GNUNET_PeerIdentity *peer,
219 const char *plugin_name, 224 const char *plugin_name,
220 const void *plugin_addr, size_t plugin_addr_len, 225 const void *plugin_addr,
226 size_t plugin_addr_len,
221 int active, 227 int active,
222 const struct GNUNET_ATS_Information *atsi, 228 const struct GNUNET_ATS_Information *atsi,
223 uint32_t atsi_count, 229 uint32_t atsi_count,
224 struct GNUNET_BANDWIDTH_Value32NBO 230 struct GNUNET_BANDWIDTH_Value32NBO bandwidth_out,
225 bandwidth_out, 231 struct GNUNET_BANDWIDTH_Value32NBO bandwidth_in)
226 struct GNUNET_BANDWIDTH_Value32NBO bandwidth_in)
227{ 232{
228 struct PerformanceClient *pc; 233 struct PerformanceClient *pc;
229 234
@@ -232,7 +237,9 @@ GAS_performance_notify_all_clients (const struct GNUNET_PeerIdentity *peer,
232 { 237 {
233 GAS_performance_notify_client (pc, 238 GAS_performance_notify_client (pc,
234 peer, 239 peer,
235 plugin_name, plugin_addr, plugin_addr_len, 240 plugin_name,
241 plugin_addr,
242 plugin_addr_len,
236 active, 243 active,
237 atsi, atsi_count, 244 atsi, atsi_count,
238 bandwidth_out, bandwidth_in); 245 bandwidth_out, bandwidth_in);
@@ -243,6 +250,21 @@ GAS_performance_notify_all_clients (const struct GNUNET_PeerIdentity *peer,
243} 250}
244 251
245 252
253
254/**
255 * Iterator for called from #GAS_addresses_get_peer_info()
256 *
257 * @param p_it_cls closure with the `struct PerformanceClient *`
258 * @param id the peer id
259 * @param plugin_name plugin name
260 * @param plugin_addr address
261 * @param plugin_addr_len length of @a plugin_addr
262 * @param address_active is address actively used
263 * @param atsi ats performance information
264 * @param atsi_count number of ats performance elements in @a atsi
265 * @param bandwidth_out current outbound bandwidth assigned to address
266 * @param bandwidth_in current inbound bandwidth assigned to address
267 */
246static void 268static void
247peerinfo_it (void *cls, 269peerinfo_it (void *cls,
248 const struct GNUNET_PeerIdentity *id, 270 const struct GNUNET_PeerIdentity *id,
@@ -251,15 +273,14 @@ peerinfo_it (void *cls,
251 const int active, 273 const int active,
252 const struct GNUNET_ATS_Information *atsi, 274 const struct GNUNET_ATS_Information *atsi,
253 uint32_t atsi_count, 275 uint32_t atsi_count,
254 struct GNUNET_BANDWIDTH_Value32NBO 276 struct GNUNET_BANDWIDTH_Value32NBO bandwidth_out,
255 bandwidth_out,
256 struct GNUNET_BANDWIDTH_Value32NBO bandwidth_in) 277 struct GNUNET_BANDWIDTH_Value32NBO bandwidth_in)
257{ 278{
258 struct PerformanceClient *pc = cls; 279 struct PerformanceClient *pc = cls;
280
259 GNUNET_assert (NULL != pc); 281 GNUNET_assert (NULL != pc);
260 if (NULL == id) 282 if (NULL == id)
261 return; 283 return;
262
263 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, 284 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
264 "Callback for peer `%s' plugin `%s' BW out %u, BW in %u \n", 285 "Callback for peer `%s' plugin `%s' BW out %u, BW in %u \n",
265 GNUNET_i2s (id), 286 GNUNET_i2s (id),
@@ -278,7 +299,7 @@ peerinfo_it (void *cls,
278 299
279 300
280/** 301/**
281 * Iterator for GAS_performance_add_client 302 * Iterator for #GAS_performance_add_client()
282 * 303 *
283 * @param cls the client requesting information 304 * @param cls the client requesting information
284 * @param id result 305 * @param id result
@@ -288,13 +309,18 @@ peer_it (void *cls,
288 const struct GNUNET_PeerIdentity *id) 309 const struct GNUNET_PeerIdentity *id)
289{ 310{
290 struct PerformanceClient *pc = cls; 311 struct PerformanceClient *pc = cls;
312
291 if (NULL != id) 313 if (NULL != id)
292 { 314 {
293 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Callback for peer `%s'\n", GNUNET_i2s (id)); 315 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
294 GAS_addresses_get_peer_info (GSA_addresses, id, &peerinfo_it, pc); 316 "Callback for peer `%s'\n",
317 GNUNET_i2s (id));
318 GAS_addresses_get_peer_info (GSA_addresses, id,
319 &peerinfo_it, pc);
295 } 320 }
296} 321}
297 322
323
298/** 324/**
299 * Register a new performance client. 325 * Register a new performance client.
300 * 326 *
@@ -312,27 +338,33 @@ GAS_performance_add_client (struct GNUNET_SERVER_Client *client,
312 pc->client = client; 338 pc->client = client;
313 pc->flag = flag; 339 pc->flag = flag;
314 340
315 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Adding performance client %s PIC\n", 341 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
316 (flag == START_FLAG_PERFORMANCE_WITH_PIC) ? "with" : "without"); 342 "Adding performance client %s PIC\n",
343 (flag == START_FLAG_PERFORMANCE_WITH_PIC) ? "with" : "without");
317 344
318 GNUNET_SERVER_notification_context_add (nc, client); 345 GNUNET_SERVER_notification_context_add (nc, client);
319 GNUNET_CONTAINER_DLL_insert (pc_head, pc_tail, pc); 346 GNUNET_CONTAINER_DLL_insert (pc_head, pc_tail, pc);
320 347
321 /* Send information about clients */ 348 /* Send information about clients */
322 GAS_addresses_iterate_peers (GSA_addresses, &peer_it, pc); 349 GAS_addresses_iterate_peers (GSA_addresses,
350 &peer_it,
351 pc);
323} 352}
324 353
325 354
326static void transmit_req_addr (struct AddressIteration *ai, 355/**
327 const struct GNUNET_PeerIdentity *id, 356 * FIXME.
328 const char *plugin_name, 357 */
329 const void *plugin_addr, size_t plugin_addr_len, 358static void
330 const int active, 359transmit_req_addr (struct AddressIteration *ai,
331 const struct GNUNET_ATS_Information *atsi, 360 const struct GNUNET_PeerIdentity *id,
332 uint32_t atsi_count, 361 const char *plugin_name,
333 struct GNUNET_BANDWIDTH_Value32NBO 362 const void *plugin_addr, size_t plugin_addr_len,
334 bandwidth_out, 363 const int active,
335 struct GNUNET_BANDWIDTH_Value32NBO bandwidth_in) 364 const struct GNUNET_ATS_Information *atsi,
365 uint32_t atsi_count,
366 struct GNUNET_BANDWIDTH_Value32NBO bandwidth_out,
367 struct GNUNET_BANDWIDTH_Value32NBO bandwidth_in)
336 368
337{ 369{
338 struct GNUNET_ATS_Information *atsp; 370 struct GNUNET_ATS_Information *atsp;
@@ -379,6 +411,21 @@ static void transmit_req_addr (struct AddressIteration *ai,
379 GNUNET_NO); 411 GNUNET_NO);
380} 412}
381 413
414
415/**
416 * Iterator for #GAS_addresses_get_peer_info()
417 *
418 * @param p_it_cls closure with our `struct AddressIteration *`
419 * @param id the peer id
420 * @param plugin_name plugin name
421 * @param plugin_addr address
422 * @param plugin_addr_len length of @a plugin_addr
423 * @param address_active is address actively used
424 * @param atsi ats performance information
425 * @param atsi_count number of ats performance elements in @a atsi
426 * @param bandwidth_out current outbound bandwidth assigned to address
427 * @param bandwidth_in current inbound bandwidth assigned to address
428 */
382static void 429static void
383req_addr_peerinfo_it (void *cls, 430req_addr_peerinfo_it (void *cls,
384 const struct GNUNET_PeerIdentity *id, 431 const struct GNUNET_PeerIdentity *id,
@@ -400,9 +447,9 @@ req_addr_peerinfo_it (void *cls,
400 447
401 if ((NULL == id) && (NULL == plugin_name) && (NULL == plugin_addr)) 448 if ((NULL == id) && (NULL == plugin_name) && (NULL == plugin_addr))
402 { 449 {
403 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, 450 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
404 "Address iteration done\n"); 451 "Address iteration done\n");
405 return; 452 return;
406 } 453 }
407 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, 454 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
408 "Callback for %s peer `%s' plugin `%s' BW out %u, BW in %u\n", 455 "Callback for %s peer `%s' plugin `%s' BW out %u, BW in %u\n",
@@ -437,23 +484,26 @@ req_addr_peerinfo_it (void *cls,
437/** 484/**
438 * Iterator for GAS_handle_request_address_list 485 * Iterator for GAS_handle_request_address_list
439 * 486 *
440 * @param cls the client requesting information 487 * @param cls the client requesting information, a `struct AddressIteration *`
441 * @param id result 488 * @param id result
442 */ 489 */
443static void 490static void
444req_addr_peer_it (void *cls, 491req_addr_peer_it (void *cls,
445 const struct GNUNET_PeerIdentity *id) 492 const struct GNUNET_PeerIdentity *id)
446{ 493{
447 struct AddressIteration *ai = cls; 494 struct AddressIteration *ai = cls;
448 if (NULL != id) 495
449 { 496 if (NULL == id)
450 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Callback for peer `%s'\n", GNUNET_i2s (id));
451 GAS_addresses_get_peer_info (GSA_addresses, id, &req_addr_peerinfo_it, ai);
452 }
453 else
454 { 497 {
455 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Peer iteration done\n"); 498 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
499 "Peer iteration done\n");
500 return;
456 } 501 }
502 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
503 "Callback for peer `%s'\n",
504 GNUNET_i2s (id));
505 GAS_addresses_get_peer_info (GSA_addresses, id,
506 &req_addr_peerinfo_it, ai);
457} 507}
458 508
459 509
@@ -474,13 +524,13 @@ GAS_handle_request_address_list (void *cls, struct GNUNET_SERVER_Client *client,
474 struct GNUNET_PeerIdentity allzeros; 524 struct GNUNET_PeerIdentity allzeros;
475 struct GNUNET_BANDWIDTH_Value32NBO bandwidth_zero; 525 struct GNUNET_BANDWIDTH_Value32NBO bandwidth_zero;
476 526
477 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Received `%s' message\n", 527 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
528 "Received `%s' message\n",
478 "ADDRESSLIST_REQUEST"); 529 "ADDRESSLIST_REQUEST");
479
480 if (NULL == (pc = find_client(client))) 530 if (NULL == (pc = find_client(client)))
481 { 531 {
482 GNUNET_break (0); 532 GNUNET_break (0);
483 return; 533 return;
484 } 534 }
485 535
486 ai.all = ntohl (alrm->all); 536 ai.all = ntohl (alrm->all);
@@ -489,28 +539,40 @@ GAS_handle_request_address_list (void *cls, struct GNUNET_SERVER_Client *client,
489 539
490 memset (&allzeros, '\0', sizeof (struct GNUNET_PeerIdentity)); 540 memset (&allzeros, '\0', sizeof (struct GNUNET_PeerIdentity));
491 bandwidth_zero.value__ = htonl (0); 541 bandwidth_zero.value__ = htonl (0);
492 if (0 == memcmp (&alrm->peer, &allzeros, sizeof (struct GNUNET_PeerIdentity))) 542 if (0 == memcmp (&alrm->peer,
543 &allzeros,
544 sizeof (struct GNUNET_PeerIdentity)))
493 { 545 {
494 /* Return addresses for all peers */ 546 /* Return addresses for all peers */
495 GAS_addresses_iterate_peers (GSA_addresses, &req_addr_peer_it, &ai); 547 GAS_addresses_iterate_peers (GSA_addresses, &req_addr_peer_it, &ai);
496 transmit_req_addr (&ai, NULL, NULL, NULL, 0, GNUNET_NO, NULL, 0, bandwidth_zero, bandwidth_zero); 548 transmit_req_addr (&ai, NULL, NULL, NULL, 0, GNUNET_NO, NULL, 0,
549 bandwidth_zero, bandwidth_zero);
497 } 550 }
498 else 551 else
499 { 552 {
500 /* Return addresses for a specific peer */ 553 /* Return addresses for a specific peer */
501 GAS_addresses_get_peer_info (GSA_addresses, &alrm->peer, &req_addr_peerinfo_it, &ai); 554 GAS_addresses_get_peer_info (GSA_addresses,
502 transmit_req_addr (&ai, NULL, NULL, NULL, 0, GNUNET_NO, NULL, 0, bandwidth_zero, bandwidth_zero); 555 &alrm->peer,
556 &req_addr_peerinfo_it, &ai);
557 transmit_req_addr (&ai, NULL, NULL, NULL, 0, GNUNET_NO, NULL, 0,
558 bandwidth_zero, bandwidth_zero);
503 } 559 }
504 GNUNET_SERVER_receive_done (client, GNUNET_OK); 560 GNUNET_SERVER_receive_done (client, GNUNET_OK);
505} 561}
506 562
507 563
564/**
565 * FIXME.
566 */
508void 567void
509GAS_handle_performance_update (struct GNUNET_PeerIdentity *peer, 568GAS_handle_performance_update (struct GNUNET_PeerIdentity *peer,
510 const char *plugin_name, const void *plugin_addr, size_t plugin_addr_len, 569 const char *plugin_name,
511 const int active, struct GNUNET_ATS_Information *ats, uint32_t ats_count, 570 const void *plugin_addr, size_t plugin_addr_len,
512 struct GNUNET_BANDWIDTH_Value32NBO bandwidth_out, 571 const int active,
513 struct GNUNET_BANDWIDTH_Value32NBO bandwidth_in) 572 struct GNUNET_ATS_Information *ats,
573 uint32_t ats_count,
574 struct GNUNET_BANDWIDTH_Value32NBO bandwidth_out,
575 struct GNUNET_BANDWIDTH_Value32NBO bandwidth_in)
514{ 576{
515 /* Notify here */ 577 /* Notify here */
516 GAS_performance_notify_all_clients (peer, plugin_name, plugin_addr, 578 GAS_performance_notify_all_clients (peer, plugin_name, plugin_addr,
@@ -571,7 +633,8 @@ GAS_handle_reservation_request (void *cls, struct GNUNET_SERVER_Client *client,
571 GNUNET_SERVER_receive_done (client, GNUNET_SYSERR); 633 GNUNET_SERVER_receive_done (client, GNUNET_SYSERR);
572 return; 634 return;
573 } 635 }
574 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Received `%s' message\n", 636 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
637 "Received `%s' message\n",
575 "RESERVATION_REQUEST"); 638 "RESERVATION_REQUEST");
576 amount = (int32_t) ntohl (msg->amount); 639 amount = (int32_t) ntohl (msg->amount);
577 res_delay = GAS_reservations_reserve (&msg->peer, amount); 640 res_delay = GAS_reservations_reserve (&msg->peer, amount);
@@ -582,7 +645,8 @@ GAS_handle_reservation_request (void *cls, struct GNUNET_SERVER_Client *client,
582 result.amount = htonl (amount); 645 result.amount = htonl (amount);
583 result.peer = msg->peer; 646 result.peer = msg->peer;
584 result.res_delay = GNUNET_TIME_relative_hton (res_delay); 647 result.res_delay = GNUNET_TIME_relative_hton (res_delay);
585 GNUNET_STATISTICS_update (GSA_stats, "# reservation requests processed", 1, 648 GNUNET_STATISTICS_update (GSA_stats,
649 "# reservation requests processed", 1,
586 GNUNET_NO); 650 GNUNET_NO);
587 GNUNET_SERVER_notification_context_unicast (nc, client, &result.header, 651 GNUNET_SERVER_notification_context_unicast (nc, client, &result.header,
588 GNUNET_NO); 652 GNUNET_NO);
@@ -627,7 +691,8 @@ GAS_handle_preference_change (void *cls,
627 GNUNET_SERVER_receive_done (client, GNUNET_SYSERR); 691 GNUNET_SERVER_receive_done (client, GNUNET_SYSERR);
628 return; 692 return;
629 } 693 }
630 GNUNET_STATISTICS_update (GSA_stats, "# preference change requests processed", 694 GNUNET_STATISTICS_update (GSA_stats,
695 "# preference change requests processed",
631 1, GNUNET_NO); 696 1, GNUNET_NO);
632 pi = (const struct PreferenceInformation *) &msg[1]; 697 pi = (const struct PreferenceInformation *) &msg[1];
633 for (i = 0; i < nump; i++) 698 for (i = 0; i < nump; i++)
@@ -659,7 +724,8 @@ GAS_handle_preference_feedback (void *cls,
659 uint32_t nump; 724 uint32_t nump;
660 uint32_t i; 725 uint32_t i;
661 726
662 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Received `%s' message\n", 727 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
728 "Received `%s' message\n",
663 "PREFERENCE_FEEDBACK"); 729 "PREFERENCE_FEEDBACK");
664 msize = ntohs (message->size); 730 msize = ntohs (message->size);
665 if (msize < sizeof (struct FeedbackPreferenceMessage)) 731 if (msize < sizeof (struct FeedbackPreferenceMessage))
@@ -678,7 +744,8 @@ GAS_handle_preference_feedback (void *cls,
678 GNUNET_SERVER_receive_done (client, GNUNET_SYSERR); 744 GNUNET_SERVER_receive_done (client, GNUNET_SYSERR);
679 return; 745 return;
680 } 746 }
681 GNUNET_STATISTICS_update (GSA_stats, "# preference feedbacks requests processed", 747 GNUNET_STATISTICS_update (GSA_stats,
748 "# preference feedbacks requests processed",
682 1, GNUNET_NO); 749 1, GNUNET_NO);
683 pi = (const struct PreferenceInformation *) &msg[1]; 750 pi = (const struct PreferenceInformation *) &msg[1];
684 for (i = 0; i < nump; i++) 751 for (i = 0; i < nump; i++)