2 This file is part of GNUnet.
3 Copyright (C) 2010,2011 GNUnet e.V.
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., 51 Franklin Street, Fifth Floor,
18 Boston, MA 02110-1301, 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"
31 #define LOG(kind,...) GNUNET_log_from(kind, "ats-performance-api", __VA_ARGS__)
35 * Message in linked list we should send to the ATS service. The
36 * actual binary message follows this struct.
44 struct PendingMessage *next;
49 struct PendingMessage *prev;
52 * Size of the message.
57 * Is this the 'ATS_START' message?
64 * Linked list of pending reservations.
66 struct GNUNET_ATS_ReservationContext
72 struct GNUNET_ATS_ReservationContext *next;
77 struct GNUNET_ATS_ReservationContext *prev;
82 struct GNUNET_PeerIdentity peer;
90 * Function to call on result.
92 GNUNET_ATS_ReservationCallback rcb;
100 * Do we need to undo this reservation if it succeeded? Set to
101 * #GNUNET_YES if a reservation is cancelled. (at that point, 'info'
102 * is also set to NULL; however, info will ALSO be NULL for the
103 * reservation context that is created to undo the original request,
104 * so 'info' being NULL cannot be used to check if undo is
112 * Linked list of pending reservations.
114 struct GNUNET_ATS_AddressListHandle
120 struct GNUNET_ATS_AddressListHandle *next;
125 struct GNUNET_ATS_AddressListHandle *prev;
130 struct GNUNET_ATS_PerformanceHandle *ph;
135 GNUNET_ATS_AddressInformationCallback cb;
138 * Callback closure for @e cb
145 struct GNUNET_PeerIdentity peer;
148 * Return all or specific peer only
153 * Return all or used address only
158 * Request multiplexing
165 * ATS Handle to obtain and/or modify performance information.
167 struct GNUNET_ATS_PerformanceHandle
173 const struct GNUNET_CONFIGURATION_Handle *cfg;
176 * Callback to invoke when an address has performance changes.
178 GNUNET_ATS_AddressInformationCallback addr_info_cb;
181 * Closure for @e addr_info_cb.
183 void *addr_info_cb_cls;
186 * Connection to ATS service.
188 struct GNUNET_CLIENT_Connection *client;
191 * Head of list of messages for the ATS service.
193 struct PendingMessage *pending_head;
196 * Tail of list of messages for the ATS service
198 struct PendingMessage *pending_tail;
201 * Head of linked list of pending reservation requests.
203 struct GNUNET_ATS_ReservationContext *reservation_head;
206 * Tail of linked list of pending reservation requests.
208 struct GNUNET_ATS_ReservationContext *reservation_tail;
211 * Head of linked list of pending address list requests.
213 struct GNUNET_ATS_AddressListHandle *addresslist_head;
216 * Tail of linked list of pending address list requests.
218 struct GNUNET_ATS_AddressListHandle *addresslist_tail;
221 * Current request for transmission to ATS.
223 struct GNUNET_CLIENT_TransmitHandle *th;
226 * Task to trigger reconnect.
228 struct GNUNET_SCHEDULER_Task *task;
231 * Reconnect backoff delay.
233 struct GNUNET_TIME_Relative backoff;
236 * Monitor request multiplexing
241 * Request multiplexing
246 * Is the receive loop active?
252 * Re-establish the connection to the ATS service.
254 * @param ph handle to use to re-connect.
257 reconnect (struct GNUNET_ATS_PerformanceHandle *ph);
261 * Re-establish the connection to the ATS service.
263 * @param cls handle to use to re-connect.
266 reconnect_task (void *cls)
268 struct GNUNET_ATS_PerformanceHandle *ph = cls;
276 * Transmit messages from the message queue to the service
277 * (if there are any, and if we are not already trying).
279 * @param ph handle to use
282 do_transmit (struct GNUNET_ATS_PerformanceHandle *ph);
286 * Type of a function to call when we receive a message
289 * @param cls the `struct GNUNET_ATS_SchedulingHandle`
290 * @param msg message received, NULL on timeout or fatal error
293 process_ats_message (void *cls,
294 const struct GNUNET_MessageHeader *msg);
298 * We can now transmit a message to ATS. Do it.
300 * @param cls the `struct GNUNET_ATS_PerformanceHandle`
301 * @param size number of bytes we can transmit to ATS
302 * @param buf where to copy the messages
303 * @return number of bytes copied into @a buf
306 transmit_message_to_ats (void *cls,
310 struct GNUNET_ATS_PerformanceHandle *ph = cls;
311 struct PendingMessage *p;
318 while ((NULL != (p = ph->pending_head)) && (p->size <= size))
320 memcpy (&cbuf[ret], &p[1], p->size);
323 GNUNET_CONTAINER_DLL_remove (ph->pending_head,
329 if (GNUNET_NO == ph->in_receive)
331 ph->in_receive = GNUNET_YES;
332 GNUNET_CLIENT_receive (ph->client,
333 &process_ats_message,
335 GNUNET_TIME_UNIT_FOREVER_REL);
342 * Transmit messages from the message queue to the service
343 * (if there are any, and if we are not already trying).
345 * @param ph handle to use
348 do_transmit (struct GNUNET_ATS_PerformanceHandle *ph)
350 struct PendingMessage *p;
354 if (NULL == (p = ph->pending_head))
356 if (NULL == ph->client)
357 return; /* currently reconnecting */
358 ph->th = GNUNET_CLIENT_notify_transmit_ready (ph->client,
360 GNUNET_TIME_UNIT_FOREVER_REL,
362 &transmit_message_to_ats, ph);
367 * We received a peer information message. Validate and process it.
369 * @param ph our context with the callback
370 * @param msg the message
371 * @return #GNUNET_OK if the message was well-formed
374 process_pi_message (struct GNUNET_ATS_PerformanceHandle *ph,
375 const struct GNUNET_MessageHeader *msg)
377 const struct PeerInformationMessage *pi;
378 const char *plugin_address;
379 const char *plugin_name;
380 struct GNUNET_HELLO_Address address;
381 uint16_t plugin_address_length;
382 uint16_t plugin_name_length;
384 struct GNUNET_ATS_Properties prop;
386 if (ntohs (msg->size) < sizeof(struct PeerInformationMessage))
389 return GNUNET_SYSERR;
391 pi = (const struct PeerInformationMessage *) msg;
392 plugin_address_length = ntohs (pi->address_length);
393 plugin_name_length = ntohs (pi->plugin_name_length);
394 addr_active = (int) ntohl (pi->address_active);
395 plugin_address = (const char *) &pi[1];
396 plugin_name = &plugin_address[plugin_address_length];
397 if ((plugin_address_length + plugin_name_length
398 + sizeof(struct PeerInformationMessage) != ntohs (msg->size))
399 || (plugin_name[plugin_name_length - 1] != '\0'))
402 return GNUNET_SYSERR;
405 if (NULL != ph->addr_info_cb)
407 GNUNET_ATS_properties_ntoh (&prop,
409 address.peer = pi->peer;
410 address.local_info = (enum GNUNET_HELLO_AddressInfo) ntohl (pi->address_local_info);
411 address.address = plugin_address;
412 address.address_length = plugin_address_length;
413 address.transport_name = plugin_name;
414 ph->addr_info_cb (ph->addr_info_cb_cls,
426 * We received a reservation result message. Validate and process it.
428 * @param ph our context with the callback
429 * @param msg the message
430 * @return #GNUNET_OK if the message was well-formed
433 process_rr_message (struct GNUNET_ATS_PerformanceHandle *ph,
434 const struct GNUNET_MessageHeader *msg)
436 const struct ReservationResultMessage *rr;
437 struct GNUNET_ATS_ReservationContext *rc;
440 if (ntohs (msg->size) < sizeof(struct ReservationResultMessage))
443 return GNUNET_SYSERR;
445 rr = (const struct ReservationResultMessage *) msg;
446 amount = ntohl (rr->amount);
447 rc = ph->reservation_head;
448 if (0 != memcmp (&rr->peer, &rc->peer, sizeof(struct GNUNET_PeerIdentity)))
451 return GNUNET_SYSERR;
453 GNUNET_CONTAINER_DLL_remove (ph->reservation_head,
454 ph->reservation_tail,
456 if ( (0 == amount) ||
459 /* tell client if not cancelled */
460 if (rc->rcb != NULL )
461 rc->rcb (rc->rcb_cls,
464 GNUNET_TIME_relative_ntoh (rr->res_delay));
468 /* amount non-zero, but client cancelled, consider undo! */
469 if (GNUNET_YES != rc->undo)
472 return GNUNET_OK; /* do not try to undo failed undos or negative amounts */
475 (void) GNUNET_ATS_reserve_bandwidth (ph,
484 * We received a PeerInformationMessage. Validate and process it.
486 * @param ph our context with the callback
487 * @param msg the message
488 * @return #GNUNET_OK if the message was well-formed
491 process_ar_message (struct GNUNET_ATS_PerformanceHandle *ph,
492 const struct GNUNET_MessageHeader *msg)
494 const struct PeerInformationMessage *pi;
495 struct GNUNET_ATS_AddressListHandle *alh;
496 struct GNUNET_ATS_AddressListHandle *next;
497 const char *plugin_address;
498 const char *plugin_name;
499 struct GNUNET_HELLO_Address address;
500 struct GNUNET_PeerIdentity allzeros;
501 struct GNUNET_BANDWIDTH_Value32NBO bandwidth_zero;
502 struct GNUNET_ATS_Properties prop;
503 uint16_t plugin_address_length;
504 uint16_t plugin_name_length;
508 if (ntohs (msg->size) < sizeof(struct PeerInformationMessage))
511 return GNUNET_SYSERR;
513 pi = (const struct PeerInformationMessage *) msg;
515 active = ntohl (pi->address_active);
516 plugin_address_length = ntohs (pi->address_length);
517 plugin_name_length = ntohs (pi->plugin_name_length);
518 plugin_address = (const char *) &pi[1];
519 plugin_name = &plugin_address[plugin_address_length];
520 if ( (plugin_address_length + plugin_name_length
521 + sizeof (struct PeerInformationMessage) != ntohs (msg->size)) ||
522 (plugin_name[plugin_name_length - 1] != '\0') )
525 return GNUNET_SYSERR;
527 LOG (GNUNET_ERROR_TYPE_DEBUG,
528 "Received ATS_ADDRESSLIST_RESPONSE message for peer %s and plugin %s\n",
529 GNUNET_i2s (&pi->peer),
532 next = ph->addresslist_head;
533 while (NULL != (alh = next))
542 return GNUNET_SYSERR;
545 memset (&allzeros, '\0', sizeof (allzeros));
546 if ( (0 == memcmp (&allzeros, &pi->peer, sizeof(allzeros))) &&
547 (0 == plugin_name_length) &&
548 (0 == plugin_address_length) )
551 LOG (GNUNET_ERROR_TYPE_DEBUG,
552 "Received last message for ATS_ADDRESSLIST_RESPONSE\n");
553 bandwidth_zero.value__ = htonl (0);
554 GNUNET_CONTAINER_DLL_remove (ph->addresslist_head,
555 ph->addresslist_tail,
558 alh->cb (alh->cb_cls,
568 address.peer = pi->peer;
569 address.address = plugin_address;
570 address.address_length = plugin_address_length;
571 address.transport_name = plugin_name;
572 if ( ( (GNUNET_YES == alh->all_addresses) ||
573 (GNUNET_YES == active) ) &&
576 GNUNET_ATS_properties_ntoh (&prop,
578 alh->cb (alh->cb_cls,
590 * Type of a function to call when we receive a message
593 * @param cls the 'struct GNUNET_ATS_SchedulingHandle'
594 * @param msg message received, NULL on timeout or fatal error
597 process_ats_message (void *cls,
598 const struct GNUNET_MessageHeader *msg)
600 struct GNUNET_ATS_PerformanceHandle *ph = cls;
604 switch (ntohs (msg->type))
606 case GNUNET_MESSAGE_TYPE_ATS_PEER_INFORMATION:
607 if (GNUNET_OK != process_pi_message (ph, msg))
613 case GNUNET_MESSAGE_TYPE_ATS_RESERVATION_RESULT:
614 if (GNUNET_OK != process_rr_message (ph, msg))
620 case GNUNET_MESSAGE_TYPE_ATS_ADDRESSLIST_RESPONSE:
621 if (GNUNET_OK != process_ar_message (ph, msg))
631 ph->backoff = GNUNET_TIME_UNIT_ZERO;
632 GNUNET_CLIENT_receive (ph->client,
633 &process_ats_message,
635 GNUNET_TIME_UNIT_FOREVER_REL);
639 LOG (GNUNET_ERROR_TYPE_DEBUG,
643 GNUNET_CLIENT_notify_transmit_ready_cancel (ph->th);
646 if (NULL != ph->client)
648 GNUNET_CLIENT_disconnect (ph->client);
650 ph->in_receive = GNUNET_NO;
651 if (NULL != ph->addr_info_cb)
653 /* Indicate reconnect */
654 ph->addr_info_cb (ph->addr_info_cb_cls,
657 GNUNET_BANDWIDTH_value_init (0),
658 GNUNET_BANDWIDTH_value_init (0),
662 ph->backoff = GNUNET_TIME_STD_BACKOFF (ph->backoff);
663 ph->task = GNUNET_SCHEDULER_add_delayed (ph->backoff,
670 * Re-establish the connection to the ATS service.
672 * @param ph handle to use to re-connect.
675 reconnect (struct GNUNET_ATS_PerformanceHandle *ph)
677 struct PendingMessage *p;
678 struct ClientStartMessage *init;
680 GNUNET_assert (NULL == ph->client);
681 ph->client = GNUNET_CLIENT_connect ("ats",
683 GNUNET_assert (NULL != ph->client);
684 if ((NULL == (p = ph->pending_head)) || (GNUNET_YES != p->is_init))
686 p = GNUNET_malloc (sizeof (struct PendingMessage) +
687 sizeof (struct ClientStartMessage));
688 p->size = sizeof(struct ClientStartMessage);
689 p->is_init = GNUNET_YES;
690 init = (struct ClientStartMessage *) &p[1];
691 init->header.type = htons (GNUNET_MESSAGE_TYPE_ATS_START);
692 init->header.size = htons (sizeof(struct ClientStartMessage));
693 init->start_flag = htonl ( (NULL == ph->addr_info_cb)
694 ? START_FLAG_PERFORMANCE_NO_PIC
695 : START_FLAG_PERFORMANCE_WITH_PIC);
696 GNUNET_CONTAINER_DLL_insert (ph->pending_head,
705 * Get handle to access performance API of the ATS subsystem.
707 * @param cfg configuration to use
708 * @param addr_info_cb callback called when performance characteristics for
710 * @param addr_info_cb_cls closure for @a addr_info_cb
711 * @return ats performance context
713 struct GNUNET_ATS_PerformanceHandle *
714 GNUNET_ATS_performance_init (const struct GNUNET_CONFIGURATION_Handle *cfg,
715 GNUNET_ATS_AddressInformationCallback addr_info_cb,
716 void *addr_info_cb_cls)
718 struct GNUNET_ATS_PerformanceHandle *ph;
720 ph = GNUNET_new (struct GNUNET_ATS_PerformanceHandle);
722 ph->addr_info_cb = addr_info_cb;
723 ph->addr_info_cb_cls = addr_info_cb_cls;
731 * Client is done using the ATS performance subsystem, release resources.
736 GNUNET_ATS_performance_done (struct GNUNET_ATS_PerformanceHandle *ph)
738 struct PendingMessage *p;
739 struct GNUNET_ATS_ReservationContext *rc;
740 struct GNUNET_ATS_AddressListHandle *alh;
742 while (NULL != (p = ph->pending_head))
744 GNUNET_CONTAINER_DLL_remove (ph->pending_head,
749 while (NULL != (alh = ph->addresslist_head))
751 GNUNET_CONTAINER_DLL_remove (ph->addresslist_head,
752 ph->addresslist_tail,
756 while (NULL != (rc = ph->reservation_head))
758 GNUNET_CONTAINER_DLL_remove (ph->reservation_head,
759 ph->reservation_tail,
761 GNUNET_break (NULL == rc->rcb);
765 if (NULL != ph->task)
767 GNUNET_SCHEDULER_cancel (ph->task);
770 if (NULL != ph->client)
772 GNUNET_CLIENT_disconnect (ph->client);
780 * Reserve inbound bandwidth from the given peer. ATS will look at
781 * the current amount of traffic we receive from the peer and ensure
782 * that the peer could add 'amount' of data to its stream.
784 * @param ph performance handle
785 * @param peer identifies the peer
786 * @param amount reserve N bytes for receiving, negative
787 * amounts can be used to undo a (recent) reservation;
788 * @param rcb function to call with the resulting reservation information
789 * @param rcb_cls closure for @a rcb
790 * @return NULL on error
791 * @deprecated will be replaced soon
793 struct GNUNET_ATS_ReservationContext *
794 GNUNET_ATS_reserve_bandwidth (struct GNUNET_ATS_PerformanceHandle *ph,
795 const struct GNUNET_PeerIdentity *peer,
797 GNUNET_ATS_ReservationCallback rcb, void *rcb_cls)
799 struct GNUNET_ATS_ReservationContext *rc;
800 struct PendingMessage *p;
801 struct ReservationRequestMessage *m;
803 rc = GNUNET_new (struct GNUNET_ATS_ReservationContext);
807 rc->rcb_cls = rcb_cls;
808 if ( (NULL != rcb) &&
810 rc->undo = GNUNET_YES;
811 GNUNET_CONTAINER_DLL_insert_tail (ph->reservation_head,
812 ph->reservation_tail,
815 p = GNUNET_malloc (sizeof (struct PendingMessage) +
816 sizeof (struct ReservationRequestMessage));
817 p->size = sizeof(struct ReservationRequestMessage);
818 p->is_init = GNUNET_NO;
819 m = (struct ReservationRequestMessage *) &p[1];
820 m->header.type = htons (GNUNET_MESSAGE_TYPE_ATS_RESERVATION_REQUEST);
821 m->header.size = htons (sizeof(struct ReservationRequestMessage));
822 m->amount = htonl (amount);
824 GNUNET_CONTAINER_DLL_insert_tail (ph->pending_head,
833 * Cancel request for reserving bandwidth.
835 * @param rc context returned by the original GNUNET_ATS_reserve_bandwidth call
838 GNUNET_ATS_reserve_bandwidth_cancel (struct GNUNET_ATS_ReservationContext *rc)
845 * Get information about addresses known to the ATS subsystem.
847 * @param handle the performance handle to use
848 * @param peer peer idm can be NULL for all peers
849 * @param all #GNUNET_YES to get information about all addresses or #GNUNET_NO to
850 * get only address currently used
851 * @param infocb callback to call with the addresses,
852 * will callback with address == NULL when done
853 * @param infocb_cls closure for @a infocb
854 * @return ats performance context
856 struct GNUNET_ATS_AddressListHandle*
857 GNUNET_ATS_performance_list_addresses (struct GNUNET_ATS_PerformanceHandle *handle,
858 const struct GNUNET_PeerIdentity *peer,
860 GNUNET_ATS_AddressInformationCallback infocb,
863 struct GNUNET_ATS_AddressListHandle *alh;
864 struct PendingMessage *p;
865 struct AddressListRequestMessage *m;
869 alh = GNUNET_new (struct GNUNET_ATS_AddressListHandle);
870 alh->id = handle->id;
873 alh->cb_cls = infocb_cls;
875 alh->all_addresses = all;
878 alh->all_peers = GNUNET_YES;
882 alh->all_peers = GNUNET_NO;
885 GNUNET_CONTAINER_DLL_insert (handle->addresslist_head,
886 handle->addresslist_tail,
889 p = GNUNET_malloc (sizeof (struct PendingMessage) +
890 sizeof (struct AddressListRequestMessage));
891 p->size = sizeof (struct AddressListRequestMessage);
892 m = (struct AddressListRequestMessage *) &p[1];
893 m->header.type = htons (GNUNET_MESSAGE_TYPE_ATS_ADDRESSLIST_REQUEST);
894 m->header.size = htons (sizeof(struct AddressListRequestMessage));
895 m->all = htonl (all);
896 m->id = htonl (alh->id);
899 GNUNET_CONTAINER_DLL_insert_tail (handle->pending_head,
900 handle->pending_tail,
902 do_transmit (handle);
909 * Cancel a pending address listing operation
911 * @param handle the handle of the request to cancel
914 GNUNET_ATS_performance_list_addresses_cancel (struct GNUNET_ATS_AddressListHandle *handle)
916 GNUNET_CONTAINER_DLL_remove (handle->ph->addresslist_head,
917 handle->ph->addresslist_tail,
919 GNUNET_free (handle);
924 * Convert a `enum GNUNET_ATS_PreferenceType` to a string
926 * @param type the preference type
927 * @return a string or NULL if invalid
930 GNUNET_ATS_print_preference_type (uint32_t type)
932 const char *prefs[] = GNUNET_ATS_PreferenceTypeString;
934 if (type < GNUNET_ATS_PREFERENCE_END)
941 * Change preferences for the given peer. Preference changes are forgotten if peers
944 * @param ph performance handle
945 * @param peer identifies the peer
946 * @param ... #GNUNET_ATS_PREFERENCE_END-terminated specification of the desired changes
949 GNUNET_ATS_performance_change_preference (struct GNUNET_ATS_PerformanceHandle *ph,
950 const struct GNUNET_PeerIdentity *peer, ...)
952 struct PendingMessage *p;
953 struct ChangePreferenceMessage *m;
956 struct PreferenceInformation *pi;
958 enum GNUNET_ATS_PreferenceKind kind;
962 while (GNUNET_ATS_PREFERENCE_END !=
963 (kind = va_arg (ap, enum GNUNET_ATS_PreferenceKind) ))
967 case GNUNET_ATS_PREFERENCE_BANDWIDTH:
969 (void) va_arg (ap, double);
971 case GNUNET_ATS_PREFERENCE_LATENCY:
973 (void) va_arg (ap, double);
980 msize = count * sizeof(struct PreferenceInformation)
981 + sizeof(struct ChangePreferenceMessage);
982 p = GNUNET_malloc (sizeof (struct PendingMessage) + msize);
984 p->is_init = GNUNET_NO;
985 m = (struct ChangePreferenceMessage *) &p[1];
986 m->header.type = htons (GNUNET_MESSAGE_TYPE_ATS_PREFERENCE_CHANGE);
987 m->header.size = htons (msize);
988 m->num_preferences = htonl (count);
990 pi = (struct PreferenceInformation *) &m[1];
993 while (GNUNET_ATS_PREFERENCE_END != (kind =
994 va_arg (ap, enum GNUNET_ATS_PreferenceKind) ))
996 pi[count].preference_kind = htonl (kind);
999 case GNUNET_ATS_PREFERENCE_BANDWIDTH:
1000 pi[count].preference_value = (float) va_arg (ap, double);
1004 case GNUNET_ATS_PREFERENCE_LATENCY:
1005 pi[count].preference_value = (float) va_arg (ap, double);
1014 GNUNET_CONTAINER_DLL_insert_tail(ph->pending_head, ph->pending_tail, p);
1020 * Send feedback to ATS on how good a the requirements for a peer and a
1021 * preference is satisfied by ATS
1023 * @param ph performance handle
1024 * @param scope the time interval this valid for: [now - scope .. now]
1025 * @param peer identifies the peer
1026 * @param ... #GNUNET_ATS_PREFERENCE_END-terminated specification of the desired changes
1029 GNUNET_ATS_performance_give_feedback (struct GNUNET_ATS_PerformanceHandle *ph,
1030 const struct GNUNET_PeerIdentity *peer,
1031 const struct GNUNET_TIME_Relative scope, ...)
1033 struct PendingMessage *p;
1034 struct FeedbackPreferenceMessage *m;
1037 struct PreferenceInformation *pi;
1039 enum GNUNET_ATS_PreferenceKind kind;
1042 va_start(ap, scope);
1043 while (GNUNET_ATS_PREFERENCE_END !=
1044 (kind = va_arg (ap, enum GNUNET_ATS_PreferenceKind) ))
1048 case GNUNET_ATS_PREFERENCE_BANDWIDTH:
1050 (void) va_arg (ap, double);
1052 case GNUNET_ATS_PREFERENCE_LATENCY:
1054 (void) va_arg (ap, double);
1061 msize = count * sizeof(struct PreferenceInformation)
1062 + sizeof(struct FeedbackPreferenceMessage);
1063 p = GNUNET_malloc (sizeof (struct PendingMessage) + msize);
1065 p->is_init = GNUNET_NO;
1066 m = (struct FeedbackPreferenceMessage *) &p[1];
1067 m->header.type = htons (GNUNET_MESSAGE_TYPE_ATS_PREFERENCE_FEEDBACK);
1068 m->header.size = htons (msize);
1069 m->scope = GNUNET_TIME_relative_hton (scope);
1070 m->num_feedback = htonl (count);
1072 pi = (struct PreferenceInformation *) &m[1];
1074 va_start(ap, scope);
1075 while (GNUNET_ATS_PREFERENCE_END != (kind =
1076 va_arg (ap, enum GNUNET_ATS_PreferenceKind) ))
1078 pi[count].preference_kind = htonl (kind);
1081 case GNUNET_ATS_PREFERENCE_BANDWIDTH:
1082 pi[count].preference_value = (float) va_arg (ap, double);
1086 case GNUNET_ATS_PREFERENCE_LATENCY:
1087 pi[count].preference_value = (float) va_arg (ap, double);
1096 GNUNET_CONTAINER_DLL_insert_tail (ph->pending_head,
1102 /* end of ats_api_performance.c */