2 This file is part of GNUnet.
3 (C) 2010,2011 Christian Grothoff (and other contributing authors)
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.
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.
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., 59 Temple Place - Suite 330,
18 Boston, MA 02111-1307, USA.
21 * @file ats/ats_api_performance.c
22 * @brief automatic transport selection and outbound bandwidth determination
23 * @author Christian Grothoff
24 * @author Matthias Wachs
27 #include "gnunet_ats_service.h"
32 * Message in linked list we should send to the ATS service. The
33 * actual binary message follows this struct.
41 struct PendingMessage *next;
46 struct PendingMessage *prev;
49 * Size of the message.
54 * Is this the 'ATS_START' message?
61 * Linked list of pending reservations.
63 struct GNUNET_ATS_ReservationContext
69 struct GNUNET_ATS_ReservationContext *next;
74 struct GNUNET_ATS_ReservationContext *prev;
79 struct GNUNET_PeerIdentity peer;
87 * Function to call on result.
89 GNUNET_ATS_ReservationCallback rcb;
97 * Do we need to undo this reservation if it succeeded? Set to
98 * GNUNET_YES if a reservation is cancelled. (at that point, 'info'
99 * is also set to NULL; however, info will ALSO be NULL for the
100 * reservation context that is created to undo the original request,
101 * so 'info' being NULL cannot be used to check if undo is
109 * Linked list of pending reservations.
111 struct GNUNET_ATS_AddressListHandle
117 struct GNUNET_ATS_AddressListHandle *next;
122 struct GNUNET_ATS_AddressListHandle *prev;
127 struct GNUNET_ATS_PerformanceHandle *ph;
132 GNUNET_ATS_AddressInformationCallback cb;
142 struct GNUNET_PeerIdentity peer;
145 * Return all or specific peer only
150 * Return all or used address only
155 * Request multiplexing
163 * ATS Handle to obtain and/or modify performance information.
165 struct GNUNET_ATS_PerformanceHandle
171 const struct GNUNET_CONFIGURATION_Handle *cfg;
174 * Callback to invoke when an address has performance changes.
176 GNUNET_ATS_AddressInformationCallback addr_info_cb;
179 * Closure for 'addr_info_cb'.
181 void *addr_info_cb_cls;
184 * Connection to ATS service.
186 struct GNUNET_CLIENT_Connection *client;
189 * Head of list of messages for the ATS service.
191 struct PendingMessage *pending_head;
194 * Tail of list of messages for the ATS service
196 struct PendingMessage *pending_tail;
199 * Head of linked list of pending reservation requests.
201 struct GNUNET_ATS_ReservationContext *reservation_head;
204 * Tail of linked list of pending reservation requests.
206 struct GNUNET_ATS_ReservationContext *reservation_tail;
209 * Head of linked list of pending address list requests.
211 struct GNUNET_ATS_AddressListHandle *addresslist_head;
214 * Tail of linked list of pending address list requests.
216 struct GNUNET_ATS_AddressListHandle *addresslist_tail;
220 * Current request for transmission to ATS.
222 struct GNUNET_CLIENT_TransmitHandle *th;
225 * Task to trigger reconnect.
227 GNUNET_SCHEDULER_TaskIdentifier task;
230 * Monitor request multiplexing
235 * Request multiplexing
242 * Re-establish the connection to the ATS service.
244 * @param ph handle to use to re-connect.
247 reconnect (struct GNUNET_ATS_PerformanceHandle *ph);
251 * Re-establish the connection to the ATS service.
253 * @param cls handle to use to re-connect.
254 * @param tc scheduler context
257 reconnect_task (void *cls, const struct GNUNET_SCHEDULER_TaskContext *tc)
259 struct GNUNET_ATS_PerformanceHandle *ph = cls;
261 ph->task = GNUNET_SCHEDULER_NO_TASK;
267 * Transmit messages from the message queue to the service
268 * (if there are any, and if we are not already trying).
270 * @param ph handle to use
273 do_transmit (struct GNUNET_ATS_PerformanceHandle *ph);
277 * We can now transmit a message to ATS. Do it.
279 * @param cls the 'struct GNUNET_ATS_SchedulingHandle'
280 * @param size number of bytes we can transmit to ATS
281 * @param buf where to copy the messages
282 * @return number of bytes copied into buf
285 transmit_message_to_ats (void *cls, size_t size, void *buf)
287 struct GNUNET_ATS_PerformanceHandle *ph = cls;
288 struct PendingMessage *p;
295 while ((NULL != (p = ph->pending_head)) && (p->size <= size))
297 memcpy (&cbuf[ret], &p[1], p->size);
300 GNUNET_CONTAINER_DLL_remove (ph->pending_head, ph->pending_tail, p);
309 * Transmit messages from the message queue to the service
310 * (if there are any, and if we are not already trying).
312 * @param ph handle to use
315 do_transmit (struct GNUNET_ATS_PerformanceHandle *ph)
317 struct PendingMessage *p;
321 if (NULL == (p = ph->pending_head))
323 if (NULL == ph->client)
324 return; /* currently reconnecting */
326 GNUNET_CLIENT_notify_transmit_ready (ph->client, p->size,
327 GNUNET_TIME_UNIT_FOREVER_REL,
328 GNUNET_YES, &transmit_message_to_ats,
334 * We received a peer information message. Validate and process it.
336 * @param ph our context with the callback
337 * @param msg the message
338 * @return GNUNET_OK if the message was well-formed
341 process_pi_message (struct GNUNET_ATS_PerformanceHandle *ph,
342 const struct GNUNET_MessageHeader *msg)
344 const struct PeerInformationMessage *pi;
345 const struct GNUNET_ATS_Information *atsi;
346 const char *plugin_address;
347 const char *plugin_name;
348 struct GNUNET_HELLO_Address address;
349 uint16_t plugin_address_length;
350 uint16_t plugin_name_length;
354 if (ntohs (msg->size) < sizeof (struct PeerInformationMessage))
357 return GNUNET_SYSERR;
360 pi = (const struct PeerInformationMessage *) msg;
361 ats_count = ntohl (pi->ats_count);
362 plugin_address_length = ntohs (pi->address_length);
363 plugin_name_length = ntohs (pi->plugin_name_length);
364 addr_active = ntohl (pi->address_active);
365 atsi = (const struct GNUNET_ATS_Information *) &pi[1];
366 plugin_address = (const char *) &atsi[ats_count];
367 plugin_name = &plugin_address[plugin_address_length];
368 if ((plugin_address_length + plugin_name_length +
369 ats_count * sizeof (struct GNUNET_ATS_Information) +
370 sizeof (struct PeerInformationMessage) != ntohs (msg->size)) ||
372 GNUNET_SERVER_MAX_MESSAGE_SIZE / sizeof (struct GNUNET_ATS_Information))
373 || (plugin_name[plugin_name_length - 1] != '\0'))
376 return GNUNET_SYSERR;
379 if (NULL != ph->addr_info_cb)
381 address.peer = pi->peer;
382 address.address = plugin_address;
383 address.address_length = plugin_address_length;
384 address.transport_name = plugin_name;
386 ph->addr_info_cb (ph->addr_info_cb_cls, &address, addr_active, pi->bandwidth_out, pi->bandwidth_in,
394 * We received a reservation result message. Validate and process it.
396 * @param ph our context with the callback
397 * @param msg the message
398 * @return GNUNET_OK if the message was well-formed
401 process_rr_message (struct GNUNET_ATS_PerformanceHandle *ph,
402 const struct GNUNET_MessageHeader *msg)
404 const struct ReservationResultMessage *rr;
405 struct GNUNET_ATS_ReservationContext *rc;
408 if (ntohs (msg->size) < sizeof (struct ReservationResultMessage))
411 return GNUNET_SYSERR;
413 rr = (const struct ReservationResultMessage *) msg;
414 amount = ntohl (rr->amount);
415 rc = ph->reservation_head;
416 if (0 != memcmp (&rr->peer, &rc->peer, sizeof (struct GNUNET_PeerIdentity)))
419 return GNUNET_SYSERR;
421 GNUNET_CONTAINER_DLL_remove (ph->reservation_head, ph->reservation_tail, rc);
422 if ((amount == 0) || (rc->rcb != NULL))
424 /* tell client if not cancelled */
426 rc->rcb (rc->rcb_cls, &rr->peer, amount,
427 GNUNET_TIME_relative_ntoh (rr->res_delay));
431 /* amount non-zero, but client cancelled, consider undo! */
432 if (GNUNET_YES != rc->undo)
435 return GNUNET_OK; /* do not try to undo failed undos or negative amounts */
438 (void) GNUNET_ATS_reserve_bandwidth (ph, &rr->peer, -amount, NULL, NULL);
444 * We received a reservation result message. Validate and process it.
446 * @param ph our context with the callback
447 * @param msg the message
448 * @return GNUNET_OK if the message was well-formed
451 process_ar_message (struct GNUNET_ATS_PerformanceHandle *ph,
452 const struct GNUNET_MessageHeader *msg)
454 const struct PeerInformationMessage *pi;
455 struct GNUNET_ATS_AddressListHandle *alh;
456 struct GNUNET_ATS_AddressListHandle *next;
457 const struct GNUNET_ATS_Information *atsi;
458 const char *plugin_address;
459 const char *plugin_name;
460 struct GNUNET_HELLO_Address address;
461 struct GNUNET_PeerIdentity allzeros;
462 struct GNUNET_BANDWIDTH_Value32NBO bandwidth_zero;
463 uint16_t plugin_address_length;
464 uint16_t plugin_name_length;
469 if (ntohs (msg->size) < sizeof (struct PeerInformationMessage))
472 return GNUNET_SYSERR;
474 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
475 _("Received %s message\n"), "ATS_ADDRESSLIST_RESPONSE");
477 pi = (const struct PeerInformationMessage *) msg;
479 ats_count = ntohl (pi->ats_count);
480 active = ntohl (pi->address_active);
481 plugin_address_length = ntohs (pi->address_length);
482 plugin_name_length = ntohs (pi->plugin_name_length);
483 atsi = (const struct GNUNET_ATS_Information *) &pi[1];
484 plugin_address = (const char *) &atsi[ats_count];
485 plugin_name = &plugin_address[plugin_address_length];
486 if ((plugin_address_length + plugin_name_length +
487 ats_count * sizeof (struct GNUNET_ATS_Information) +
488 sizeof (struct PeerInformationMessage) != ntohs (msg->size)) ||
490 GNUNET_SERVER_MAX_MESSAGE_SIZE / sizeof (struct GNUNET_ATS_Information))
491 || (plugin_name[plugin_name_length - 1] != '\0'))
494 return GNUNET_SYSERR;
497 next = ph->addresslist_head;
498 while (NULL != (alh = next))
507 return GNUNET_SYSERR;
510 memset (&allzeros, '\0', sizeof (allzeros));
511 if ((0 == memcmp (&allzeros, &pi->peer, sizeof (allzeros))) &&
512 (0 == plugin_name_length) &&
513 (0 == plugin_address_length) &&
517 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
518 _("Received last message for %s \n"), "ATS_ADDRESSLIST_RESPONSE");
519 bandwidth_zero.value__ = htonl (0);
521 alh->cb (ph->addr_info_cb_cls,
524 bandwidth_zero, bandwidth_zero,
526 GNUNET_CONTAINER_DLL_remove (ph->addresslist_head, ph->addresslist_tail, alh);
531 address.peer = pi->peer;
532 address.address = plugin_address;
533 address.address_length = plugin_address_length;
534 address.transport_name = plugin_name;
536 if ((GNUNET_YES == alh->all_addresses) || (GNUNET_YES == active))
539 alh->cb (ph->addr_info_cb_cls,
542 pi->bandwidth_out, pi->bandwidth_in,
550 * Type of a function to call when we receive a message
553 * @param cls the 'struct GNUNET_ATS_SchedulingHandle'
554 * @param msg message received, NULL on timeout or fatal error
557 process_ats_message (void *cls, const struct GNUNET_MessageHeader *msg)
559 struct GNUNET_ATS_PerformanceHandle *ph = cls;
563 switch (ntohs (msg->type))
565 case GNUNET_MESSAGE_TYPE_ATS_PEER_INFORMATION:
566 if (GNUNET_OK != process_pi_message (ph, msg))
569 case GNUNET_MESSAGE_TYPE_ATS_RESERVATION_RESULT:
570 if (GNUNET_OK != process_rr_message (ph, msg))
573 case GNUNET_MESSAGE_TYPE_ATS_ADDRESSLIST_RESPONSE:
574 if (GNUNET_OK != process_ar_message (ph, msg))
581 GNUNET_CLIENT_receive (ph->client, &process_ats_message, ph,
582 GNUNET_TIME_UNIT_FOREVER_REL);
587 GNUNET_CLIENT_notify_transmit_ready_cancel (ph->th);
590 GNUNET_CLIENT_disconnect (ph->client);
593 GNUNET_SCHEDULER_add_delayed (GNUNET_TIME_UNIT_SECONDS, &reconnect_task,
599 * Re-establish the connection to the ATS service.
601 * @param ph handle to use to re-connect.
604 reconnect (struct GNUNET_ATS_PerformanceHandle *ph)
606 struct PendingMessage *p;
607 struct ClientStartMessage *init;
609 GNUNET_assert (NULL == ph->client);
610 ph->client = GNUNET_CLIENT_connect ("ats", ph->cfg);
611 GNUNET_assert (NULL != ph->client);
612 GNUNET_CLIENT_receive (ph->client, &process_ats_message, ph,
613 GNUNET_TIME_UNIT_FOREVER_REL);
614 if ((NULL == (p = ph->pending_head)) || (GNUNET_YES != p->is_init))
616 p = GNUNET_malloc (sizeof (struct PendingMessage) +
617 sizeof (struct ClientStartMessage));
618 p->size = sizeof (struct ClientStartMessage);
619 p->is_init = GNUNET_YES;
620 init = (struct ClientStartMessage *) &p[1];
621 init->header.type = htons (GNUNET_MESSAGE_TYPE_ATS_START);
622 init->header.size = htons (sizeof (struct ClientStartMessage));
624 htonl ((NULL ==ph->addr_info_cb) ?
625 START_FLAG_PERFORMANCE_NO_PIC : START_FLAG_PERFORMANCE_WITH_PIC);
626 GNUNET_CONTAINER_DLL_insert (ph->pending_head, ph->pending_tail, p);
634 * Get handle to access performance API of the ATS subsystem.
636 * @param cfg configuration to use
637 * @param addr_info_cb callback called when performance characteristics for
639 * @param addr_info_cb_cls closure for infocb
640 * @return ats performance context
642 struct GNUNET_ATS_PerformanceHandle *
643 GNUNET_ATS_performance_init (const struct GNUNET_CONFIGURATION_Handle *cfg,
644 GNUNET_ATS_AddressInformationCallback addr_info_cb,
645 void *addr_info_cb_cls)
647 struct GNUNET_ATS_PerformanceHandle *ph;
649 ph = GNUNET_malloc (sizeof (struct GNUNET_ATS_PerformanceHandle));
651 ph->addr_info_cb = addr_info_cb;
652 ph->addr_info_cb_cls = addr_info_cb_cls;
659 * Client is done using the ATS performance subsystem, release resources.
664 GNUNET_ATS_performance_done (struct GNUNET_ATS_PerformanceHandle *ph)
666 struct PendingMessage *p;
667 struct GNUNET_ATS_ReservationContext *rc;
668 struct GNUNET_ATS_AddressListHandle *alh;
670 while (NULL != (p = ph->pending_head))
672 GNUNET_CONTAINER_DLL_remove (ph->pending_head, ph->pending_tail, p);
675 while (NULL != (alh = ph->addresslist_head))
677 GNUNET_CONTAINER_DLL_remove (ph->addresslist_head, ph->addresslist_tail,
681 while (NULL != (rc = ph->reservation_head))
683 GNUNET_CONTAINER_DLL_remove (ph->reservation_head, ph->reservation_tail,
685 GNUNET_break (NULL == rc->rcb);
689 if (GNUNET_SCHEDULER_NO_TASK != ph->task)
691 GNUNET_SCHEDULER_cancel (ph->task);
692 ph->task = GNUNET_SCHEDULER_NO_TASK;
694 if (NULL != ph->client)
696 GNUNET_CLIENT_disconnect (ph->client);
704 * Reserve inbound bandwidth from the given peer. ATS will look at
705 * the current amount of traffic we receive from the peer and ensure
706 * that the peer could add 'amount' of data to its stream.
708 * @param ph performance handle
709 * @param peer identifies the peer
710 * @param amount reserve N bytes for receiving, negative
711 * amounts can be used to undo a (recent) reservation;
712 * @param rcb function to call with the resulting reservation information
713 * @param rcb_cls closure for info
714 * @return NULL on error
715 * @deprecated will be replaced soon
717 struct GNUNET_ATS_ReservationContext *
718 GNUNET_ATS_reserve_bandwidth (struct GNUNET_ATS_PerformanceHandle *ph,
719 const struct GNUNET_PeerIdentity *peer,
721 GNUNET_ATS_ReservationCallback rcb, void *rcb_cls)
723 struct GNUNET_ATS_ReservationContext *rc;
724 struct PendingMessage *p;
725 struct ReservationRequestMessage *m;
727 rc = GNUNET_malloc (sizeof (struct GNUNET_ATS_ReservationContext));
731 rc->rcb_cls = rcb_cls;
732 if ((rcb != NULL) && (amount > 0))
733 rc->undo = GNUNET_YES;
734 GNUNET_CONTAINER_DLL_insert_tail (ph->reservation_head, ph->reservation_tail,
737 p = GNUNET_malloc (sizeof (struct PendingMessage) +
738 sizeof (struct ReservationRequestMessage));
739 p->size = sizeof (struct ReservationRequestMessage);
740 p->is_init = GNUNET_NO;
741 m = (struct ReservationRequestMessage *) &p[1];
742 m->header.type = htons (GNUNET_MESSAGE_TYPE_ATS_RESERVATION_REQUEST);
743 m->header.size = htons (sizeof (struct ReservationRequestMessage));
744 m->amount = htonl (amount);
746 GNUNET_CONTAINER_DLL_insert_tail (ph->pending_head, ph->pending_tail, p);
753 * Cancel request for reserving bandwidth.
755 * @param rc context returned by the original GNUNET_ATS_reserve_bandwidth call
758 GNUNET_ATS_reserve_bandwidth_cancel (struct GNUNET_ATS_ReservationContext *rc)
764 * Get information about addresses known to the ATS subsystem.
766 * @param handle the performance handle to use
767 * @param peer peer idm can be NULL for all peers
768 * @param all GNUNET_YES to get information about all addresses or GNUNET_NO to
769 * get only address currently used
770 * @param infocb callback to call with the addresses,
771 * will callback with address == NULL when done
772 * @param infocb_cls closure for infocb
773 * @return ats performance context
775 struct GNUNET_ATS_AddressListHandle*
776 GNUNET_ATS_performance_list_addresses (struct GNUNET_ATS_PerformanceHandle *handle,
777 const struct GNUNET_PeerIdentity *peer,
779 GNUNET_ATS_AddressInformationCallback infocb,
782 struct GNUNET_ATS_AddressListHandle *alh;
783 struct PendingMessage *p;
784 struct AddressListRequestMessage *m;
786 GNUNET_assert (NULL != handle);
790 alh = GNUNET_malloc (sizeof (struct GNUNET_ATS_AddressListHandle));
791 alh->id = handle->id;
794 alh->cb_cls = infocb_cls;
796 alh->all_addresses = all;
798 alh->all_peers = GNUNET_YES;
801 alh->all_peers = GNUNET_NO;
805 GNUNET_CONTAINER_DLL_insert (handle->addresslist_head, handle->addresslist_tail, alh);
807 p = GNUNET_malloc (sizeof (struct PendingMessage) +
808 sizeof (struct AddressListRequestMessage));
809 p->size = sizeof (struct AddressListRequestMessage);
810 m = (struct AddressListRequestMessage *) &p[1];
811 m->header.type = htons (GNUNET_MESSAGE_TYPE_ATS_ADDRESSLIST_REQUEST);
812 m->header.size = htons (sizeof (struct AddressListRequestMessage));
813 m->all = htonl (all);
814 m->id = htonl (alh->id);
819 memset (&m->peer, '\0', sizeof (struct GNUNET_PeerIdentity));
821 GNUNET_CONTAINER_DLL_insert_tail (handle->pending_head, handle->pending_tail, p);
823 do_transmit (handle);
830 * Cancel a pending address listing operation
832 * @param handle the GNUNET_ATS_AddressListHandle handle to cancel
835 GNUNET_ATS_performance_list_addresses_cancel (struct GNUNET_ATS_AddressListHandle *handle)
837 GNUNET_assert (NULL != handle);
839 GNUNET_CONTAINER_DLL_remove (handle->ph->addresslist_head, handle->ph->addresslist_tail, handle);
840 GNUNET_free (handle);
845 * Convert a GNUNET_ATS_PreferenceType to a string
847 * @param type the preference type
848 * @return a string or NULL if invalid
851 GNUNET_ATS_print_preference_type (uint32_t type)
853 char *prefs[GNUNET_ATS_PreferenceCount] = GNUNET_ATS_PreferenceTypeString;
854 if (type < GNUNET_ATS_PreferenceCount)
861 * Change preferences for the given peer. Preference changes are forgotten if peers
864 * @param ph performance handle
865 * @param peer identifies the peer
866 * @param ... 0-terminated specification of the desired changes
869 GNUNET_ATS_performance_change_preference (struct GNUNET_ATS_PerformanceHandle *ph,
870 const struct GNUNET_PeerIdentity *peer, ...)
872 struct PendingMessage *p;
873 struct ChangePreferenceMessage *m;
876 struct PreferenceInformation *pi;
878 enum GNUNET_ATS_PreferenceKind kind;
882 while (GNUNET_ATS_PREFERENCE_END !=
883 (kind = va_arg (ap, enum GNUNET_ATS_PreferenceKind)))
887 case GNUNET_ATS_PREFERENCE_BANDWIDTH:
889 (void) va_arg (ap, double);
892 case GNUNET_ATS_PREFERENCE_LATENCY:
894 (void) va_arg (ap, double);
903 count * sizeof (struct PreferenceInformation) +
904 sizeof (struct ChangePreferenceMessage);
905 p = GNUNET_malloc (sizeof (struct PendingMessage) + msize);
907 p->is_init = GNUNET_NO;
908 m = (struct ChangePreferenceMessage *) &p[1];
909 m->header.type = htons (GNUNET_MESSAGE_TYPE_ATS_PREFERENCE_CHANGE);
910 m->header.size = htons (msize);
911 m->num_preferences = htonl (count);
913 pi = (struct PreferenceInformation *) &m[1];
916 while (GNUNET_ATS_PREFERENCE_END !=
917 (kind = va_arg (ap, enum GNUNET_ATS_PreferenceKind)))
919 pi[count].preference_kind = htonl (kind);
922 case GNUNET_ATS_PREFERENCE_BANDWIDTH:
923 pi[count].preference_value = (float) va_arg (ap, double);
927 case GNUNET_ATS_PREFERENCE_LATENCY:
928 pi[count].preference_value = (float) va_arg (ap, double);
937 GNUNET_CONTAINER_DLL_insert_tail (ph->pending_head, ph->pending_tail, p);
942 * Send feedback to ATS on how good a the requirements for a peer and a
943 * preference is satisfied by ATS
945 * @param ph performance handle
946 * @param scope the time interval this valid for: [now - scope .. now]
947 * @param peer identifies the peer
948 * @param ... 0-terminated specification of the desired changes
951 GNUNET_ATS_performance_give_feedback (struct GNUNET_ATS_PerformanceHandle *ph,
952 const struct GNUNET_PeerIdentity *peer,
953 const struct GNUNET_TIME_Relative scope, ...)
955 struct PendingMessage *p;
956 struct FeedbackPreferenceMessage *m;
959 struct PreferenceInformation *pi;
961 enum GNUNET_ATS_PreferenceKind kind;
964 va_start (ap, scope);
965 while (GNUNET_ATS_PREFERENCE_END !=
966 (kind = va_arg (ap, enum GNUNET_ATS_PreferenceKind)))
970 case GNUNET_ATS_PREFERENCE_BANDWIDTH:
972 (void) va_arg (ap, double);
975 case GNUNET_ATS_PREFERENCE_LATENCY:
977 (void) va_arg (ap, double);
986 count * sizeof (struct PreferenceInformation) +
987 sizeof (struct FeedbackPreferenceMessage);
988 p = GNUNET_malloc (sizeof (struct PendingMessage) + msize);
990 p->is_init = GNUNET_NO;
991 m = (struct FeedbackPreferenceMessage *) &p[1];
992 m->header.type = htons (GNUNET_MESSAGE_TYPE_ATS_PREFERENCE_FEEDBACK);
993 m->header.size = htons (msize);
994 m->scope = GNUNET_TIME_relative_hton (scope);
995 m->num_feedback = htonl (count);
997 pi = (struct PreferenceInformation *) &m[1];
999 va_start (ap, scope);
1000 while (GNUNET_ATS_PREFERENCE_END !=
1001 (kind = va_arg (ap, enum GNUNET_ATS_PreferenceKind)))
1003 pi[count].preference_kind = htonl (kind);
1006 case GNUNET_ATS_PREFERENCE_BANDWIDTH:
1007 pi[count].preference_value = (float) va_arg (ap, double);
1011 case GNUNET_ATS_PREFERENCE_LATENCY:
1012 pi[count].preference_value = (float) va_arg (ap, double);
1021 GNUNET_CONTAINER_DLL_insert_tail (ph->pending_head, ph->pending_tail, p);
1025 /* end of ats_api_performance.c */