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.
264 * @param tc scheduler context
267 reconnect_task (void *cls,
268 const struct GNUNET_SCHEDULER_TaskContext *tc)
270 struct GNUNET_ATS_PerformanceHandle *ph = cls;
278 * Transmit messages from the message queue to the service
279 * (if there are any, and if we are not already trying).
281 * @param ph handle to use
284 do_transmit (struct GNUNET_ATS_PerformanceHandle *ph);
288 * Type of a function to call when we receive a message
291 * @param cls the `struct GNUNET_ATS_SchedulingHandle`
292 * @param msg message received, NULL on timeout or fatal error
295 process_ats_message (void *cls,
296 const struct GNUNET_MessageHeader *msg);
300 * We can now transmit a message to ATS. Do it.
302 * @param cls the `struct GNUNET_ATS_PerformanceHandle`
303 * @param size number of bytes we can transmit to ATS
304 * @param buf where to copy the messages
305 * @return number of bytes copied into @a buf
308 transmit_message_to_ats (void *cls,
312 struct GNUNET_ATS_PerformanceHandle *ph = cls;
313 struct PendingMessage *p;
320 while ((NULL != (p = ph->pending_head)) && (p->size <= size))
322 memcpy (&cbuf[ret], &p[1], p->size);
325 GNUNET_CONTAINER_DLL_remove (ph->pending_head,
331 if (GNUNET_NO == ph->in_receive)
333 ph->in_receive = GNUNET_YES;
334 GNUNET_CLIENT_receive (ph->client,
335 &process_ats_message,
337 GNUNET_TIME_UNIT_FOREVER_REL);
344 * Transmit messages from the message queue to the service
345 * (if there are any, and if we are not already trying).
347 * @param ph handle to use
350 do_transmit (struct GNUNET_ATS_PerformanceHandle *ph)
352 struct PendingMessage *p;
356 if (NULL == (p = ph->pending_head))
358 if (NULL == ph->client)
359 return; /* currently reconnecting */
360 ph->th = GNUNET_CLIENT_notify_transmit_ready (ph->client,
362 GNUNET_TIME_UNIT_FOREVER_REL,
364 &transmit_message_to_ats, ph);
369 * We received a peer information message. Validate and process it.
371 * @param ph our context with the callback
372 * @param msg the message
373 * @return #GNUNET_OK if the message was well-formed
376 process_pi_message (struct GNUNET_ATS_PerformanceHandle *ph,
377 const struct GNUNET_MessageHeader *msg)
379 const struct PeerInformationMessage *pi;
380 const char *plugin_address;
381 const char *plugin_name;
382 struct GNUNET_HELLO_Address address;
383 uint16_t plugin_address_length;
384 uint16_t plugin_name_length;
386 struct GNUNET_ATS_Properties prop;
388 if (ntohs (msg->size) < sizeof(struct PeerInformationMessage))
391 return GNUNET_SYSERR;
393 pi = (const struct PeerInformationMessage *) msg;
394 plugin_address_length = ntohs (pi->address_length);
395 plugin_name_length = ntohs (pi->plugin_name_length);
396 addr_active = (int) ntohl (pi->address_active);
397 plugin_address = (const char *) &pi[1];
398 plugin_name = &plugin_address[plugin_address_length];
399 if ((plugin_address_length + plugin_name_length
400 + sizeof(struct PeerInformationMessage) != ntohs (msg->size))
401 || (plugin_name[plugin_name_length - 1] != '\0'))
404 return GNUNET_SYSERR;
407 if (NULL != ph->addr_info_cb)
409 GNUNET_ATS_properties_ntoh (&prop,
411 address.peer = pi->peer;
412 address.local_info = (enum GNUNET_HELLO_AddressInfo) ntohl (pi->address_local_info);
413 address.address = plugin_address;
414 address.address_length = plugin_address_length;
415 address.transport_name = plugin_name;
416 ph->addr_info_cb (ph->addr_info_cb_cls,
428 * We received a reservation result message. Validate and process it.
430 * @param ph our context with the callback
431 * @param msg the message
432 * @return #GNUNET_OK if the message was well-formed
435 process_rr_message (struct GNUNET_ATS_PerformanceHandle *ph,
436 const struct GNUNET_MessageHeader *msg)
438 const struct ReservationResultMessage *rr;
439 struct GNUNET_ATS_ReservationContext *rc;
442 if (ntohs (msg->size) < sizeof(struct ReservationResultMessage))
445 return GNUNET_SYSERR;
447 rr = (const struct ReservationResultMessage *) msg;
448 amount = ntohl (rr->amount);
449 rc = ph->reservation_head;
450 if (0 != memcmp (&rr->peer, &rc->peer, sizeof(struct GNUNET_PeerIdentity)))
453 return GNUNET_SYSERR;
455 GNUNET_CONTAINER_DLL_remove (ph->reservation_head,
456 ph->reservation_tail,
458 if ( (0 == amount) ||
461 /* tell client if not cancelled */
462 if (rc->rcb != NULL )
463 rc->rcb (rc->rcb_cls,
466 GNUNET_TIME_relative_ntoh (rr->res_delay));
470 /* amount non-zero, but client cancelled, consider undo! */
471 if (GNUNET_YES != rc->undo)
474 return GNUNET_OK; /* do not try to undo failed undos or negative amounts */
477 (void) GNUNET_ATS_reserve_bandwidth (ph,
486 * We received a PeerInformationMessage. Validate and process it.
488 * @param ph our context with the callback
489 * @param msg the message
490 * @return #GNUNET_OK if the message was well-formed
493 process_ar_message (struct GNUNET_ATS_PerformanceHandle *ph,
494 const struct GNUNET_MessageHeader *msg)
496 const struct PeerInformationMessage *pi;
497 struct GNUNET_ATS_AddressListHandle *alh;
498 struct GNUNET_ATS_AddressListHandle *next;
499 const char *plugin_address;
500 const char *plugin_name;
501 struct GNUNET_HELLO_Address address;
502 struct GNUNET_PeerIdentity allzeros;
503 struct GNUNET_BANDWIDTH_Value32NBO bandwidth_zero;
504 struct GNUNET_ATS_Properties prop;
505 uint16_t plugin_address_length;
506 uint16_t plugin_name_length;
510 if (ntohs (msg->size) < sizeof(struct PeerInformationMessage))
513 return GNUNET_SYSERR;
515 pi = (const struct PeerInformationMessage *) msg;
517 active = ntohl (pi->address_active);
518 plugin_address_length = ntohs (pi->address_length);
519 plugin_name_length = ntohs (pi->plugin_name_length);
520 plugin_address = (const char *) &pi[1];
521 plugin_name = &plugin_address[plugin_address_length];
522 if ( (plugin_address_length + plugin_name_length
523 + sizeof (struct PeerInformationMessage) != ntohs (msg->size)) ||
524 (plugin_name[plugin_name_length - 1] != '\0') )
527 return GNUNET_SYSERR;
529 LOG (GNUNET_ERROR_TYPE_DEBUG,
530 "Received ATS_ADDRESSLIST_RESPONSE message for peer %s and plugin %s\n",
531 GNUNET_i2s (&pi->peer),
534 next = ph->addresslist_head;
535 while (NULL != (alh = next))
544 return GNUNET_SYSERR;
547 memset (&allzeros, '\0', sizeof (allzeros));
548 if ( (0 == memcmp (&allzeros, &pi->peer, sizeof(allzeros))) &&
549 (0 == plugin_name_length) &&
550 (0 == plugin_address_length) )
553 LOG (GNUNET_ERROR_TYPE_DEBUG,
554 "Received last message for ATS_ADDRESSLIST_RESPONSE\n");
555 bandwidth_zero.value__ = htonl (0);
556 GNUNET_CONTAINER_DLL_remove (ph->addresslist_head,
557 ph->addresslist_tail,
560 alh->cb (alh->cb_cls,
570 address.peer = pi->peer;
571 address.address = plugin_address;
572 address.address_length = plugin_address_length;
573 address.transport_name = plugin_name;
574 if ( ( (GNUNET_YES == alh->all_addresses) ||
575 (GNUNET_YES == active) ) &&
578 GNUNET_ATS_properties_ntoh (&prop,
580 alh->cb (alh->cb_cls,
592 * Type of a function to call when we receive a message
595 * @param cls the 'struct GNUNET_ATS_SchedulingHandle'
596 * @param msg message received, NULL on timeout or fatal error
599 process_ats_message (void *cls,
600 const struct GNUNET_MessageHeader *msg)
602 struct GNUNET_ATS_PerformanceHandle *ph = cls;
606 switch (ntohs (msg->type))
608 case GNUNET_MESSAGE_TYPE_ATS_PEER_INFORMATION:
609 if (GNUNET_OK != process_pi_message (ph, msg))
615 case GNUNET_MESSAGE_TYPE_ATS_RESERVATION_RESULT:
616 if (GNUNET_OK != process_rr_message (ph, msg))
622 case GNUNET_MESSAGE_TYPE_ATS_ADDRESSLIST_RESPONSE:
623 if (GNUNET_OK != process_ar_message (ph, msg))
633 ph->backoff = GNUNET_TIME_UNIT_ZERO;
634 GNUNET_CLIENT_receive (ph->client,
635 &process_ats_message,
637 GNUNET_TIME_UNIT_FOREVER_REL);
641 LOG (GNUNET_ERROR_TYPE_DEBUG,
645 GNUNET_CLIENT_notify_transmit_ready_cancel (ph->th);
648 if (NULL != ph->client)
650 GNUNET_CLIENT_disconnect (ph->client);
652 ph->in_receive = GNUNET_NO;
653 if (NULL != ph->addr_info_cb)
655 /* Indicate reconnect */
656 ph->addr_info_cb (ph->addr_info_cb_cls,
659 GNUNET_BANDWIDTH_value_init (0),
660 GNUNET_BANDWIDTH_value_init (0),
664 ph->backoff = GNUNET_TIME_STD_BACKOFF (ph->backoff);
665 ph->task = GNUNET_SCHEDULER_add_delayed (ph->backoff,
672 * Re-establish the connection to the ATS service.
674 * @param ph handle to use to re-connect.
677 reconnect (struct GNUNET_ATS_PerformanceHandle *ph)
679 struct PendingMessage *p;
680 struct ClientStartMessage *init;
682 GNUNET_assert (NULL == ph->client);
683 ph->client = GNUNET_CLIENT_connect ("ats",
685 GNUNET_assert (NULL != ph->client);
686 if ((NULL == (p = ph->pending_head)) || (GNUNET_YES != p->is_init))
688 p = GNUNET_malloc (sizeof (struct PendingMessage) +
689 sizeof (struct ClientStartMessage));
690 p->size = sizeof(struct ClientStartMessage);
691 p->is_init = GNUNET_YES;
692 init = (struct ClientStartMessage *) &p[1];
693 init->header.type = htons (GNUNET_MESSAGE_TYPE_ATS_START);
694 init->header.size = htons (sizeof(struct ClientStartMessage));
695 init->start_flag = htonl ( (NULL == ph->addr_info_cb)
696 ? START_FLAG_PERFORMANCE_NO_PIC
697 : START_FLAG_PERFORMANCE_WITH_PIC);
698 GNUNET_CONTAINER_DLL_insert (ph->pending_head,
707 * Get handle to access performance API of the ATS subsystem.
709 * @param cfg configuration to use
710 * @param addr_info_cb callback called when performance characteristics for
712 * @param addr_info_cb_cls closure for @a addr_info_cb
713 * @return ats performance context
715 struct GNUNET_ATS_PerformanceHandle *
716 GNUNET_ATS_performance_init (const struct GNUNET_CONFIGURATION_Handle *cfg,
717 GNUNET_ATS_AddressInformationCallback addr_info_cb,
718 void *addr_info_cb_cls)
720 struct GNUNET_ATS_PerformanceHandle *ph;
722 ph = GNUNET_new (struct GNUNET_ATS_PerformanceHandle);
724 ph->addr_info_cb = addr_info_cb;
725 ph->addr_info_cb_cls = addr_info_cb_cls;
733 * Client is done using the ATS performance subsystem, release resources.
738 GNUNET_ATS_performance_done (struct GNUNET_ATS_PerformanceHandle *ph)
740 struct PendingMessage *p;
741 struct GNUNET_ATS_ReservationContext *rc;
742 struct GNUNET_ATS_AddressListHandle *alh;
744 while (NULL != (p = ph->pending_head))
746 GNUNET_CONTAINER_DLL_remove (ph->pending_head,
751 while (NULL != (alh = ph->addresslist_head))
753 GNUNET_CONTAINER_DLL_remove (ph->addresslist_head,
754 ph->addresslist_tail,
758 while (NULL != (rc = ph->reservation_head))
760 GNUNET_CONTAINER_DLL_remove (ph->reservation_head,
761 ph->reservation_tail,
763 GNUNET_break (NULL == rc->rcb);
767 if (NULL != ph->task)
769 GNUNET_SCHEDULER_cancel (ph->task);
772 if (NULL != ph->client)
774 GNUNET_CLIENT_disconnect (ph->client);
782 * Reserve inbound bandwidth from the given peer. ATS will look at
783 * the current amount of traffic we receive from the peer and ensure
784 * that the peer could add 'amount' of data to its stream.
786 * @param ph performance handle
787 * @param peer identifies the peer
788 * @param amount reserve N bytes for receiving, negative
789 * amounts can be used to undo a (recent) reservation;
790 * @param rcb function to call with the resulting reservation information
791 * @param rcb_cls closure for @a rcb
792 * @return NULL on error
793 * @deprecated will be replaced soon
795 struct GNUNET_ATS_ReservationContext *
796 GNUNET_ATS_reserve_bandwidth (struct GNUNET_ATS_PerformanceHandle *ph,
797 const struct GNUNET_PeerIdentity *peer,
799 GNUNET_ATS_ReservationCallback rcb, void *rcb_cls)
801 struct GNUNET_ATS_ReservationContext *rc;
802 struct PendingMessage *p;
803 struct ReservationRequestMessage *m;
805 rc = GNUNET_new (struct GNUNET_ATS_ReservationContext);
809 rc->rcb_cls = rcb_cls;
810 if ( (NULL != rcb) &&
812 rc->undo = GNUNET_YES;
813 GNUNET_CONTAINER_DLL_insert_tail (ph->reservation_head,
814 ph->reservation_tail,
817 p = GNUNET_malloc (sizeof (struct PendingMessage) +
818 sizeof (struct ReservationRequestMessage));
819 p->size = sizeof(struct ReservationRequestMessage);
820 p->is_init = GNUNET_NO;
821 m = (struct ReservationRequestMessage *) &p[1];
822 m->header.type = htons (GNUNET_MESSAGE_TYPE_ATS_RESERVATION_REQUEST);
823 m->header.size = htons (sizeof(struct ReservationRequestMessage));
824 m->amount = htonl (amount);
826 GNUNET_CONTAINER_DLL_insert_tail (ph->pending_head,
835 * Cancel request for reserving bandwidth.
837 * @param rc context returned by the original GNUNET_ATS_reserve_bandwidth call
840 GNUNET_ATS_reserve_bandwidth_cancel (struct GNUNET_ATS_ReservationContext *rc)
847 * Get information about addresses known to the ATS subsystem.
849 * @param handle the performance handle to use
850 * @param peer peer idm can be NULL for all peers
851 * @param all #GNUNET_YES to get information about all addresses or #GNUNET_NO to
852 * get only address currently used
853 * @param infocb callback to call with the addresses,
854 * will callback with address == NULL when done
855 * @param infocb_cls closure for @a infocb
856 * @return ats performance context
858 struct GNUNET_ATS_AddressListHandle*
859 GNUNET_ATS_performance_list_addresses (struct GNUNET_ATS_PerformanceHandle *handle,
860 const struct GNUNET_PeerIdentity *peer,
862 GNUNET_ATS_AddressInformationCallback infocb,
865 struct GNUNET_ATS_AddressListHandle *alh;
866 struct PendingMessage *p;
867 struct AddressListRequestMessage *m;
871 alh = GNUNET_new (struct GNUNET_ATS_AddressListHandle);
872 alh->id = handle->id;
875 alh->cb_cls = infocb_cls;
877 alh->all_addresses = all;
880 alh->all_peers = GNUNET_YES;
884 alh->all_peers = GNUNET_NO;
887 GNUNET_CONTAINER_DLL_insert (handle->addresslist_head,
888 handle->addresslist_tail,
891 p = GNUNET_malloc (sizeof (struct PendingMessage) +
892 sizeof (struct AddressListRequestMessage));
893 p->size = sizeof (struct AddressListRequestMessage);
894 m = (struct AddressListRequestMessage *) &p[1];
895 m->header.type = htons (GNUNET_MESSAGE_TYPE_ATS_ADDRESSLIST_REQUEST);
896 m->header.size = htons (sizeof(struct AddressListRequestMessage));
897 m->all = htonl (all);
898 m->id = htonl (alh->id);
901 GNUNET_CONTAINER_DLL_insert_tail (handle->pending_head,
902 handle->pending_tail,
904 do_transmit (handle);
911 * Cancel a pending address listing operation
913 * @param handle the handle of the request to cancel
916 GNUNET_ATS_performance_list_addresses_cancel (struct GNUNET_ATS_AddressListHandle *handle)
918 GNUNET_CONTAINER_DLL_remove (handle->ph->addresslist_head,
919 handle->ph->addresslist_tail,
921 GNUNET_free (handle);
926 * Convert a `enum GNUNET_ATS_PreferenceType` to a string
928 * @param type the preference type
929 * @return a string or NULL if invalid
932 GNUNET_ATS_print_preference_type (uint32_t type)
934 const char *prefs[] = GNUNET_ATS_PreferenceTypeString;
936 if (type < GNUNET_ATS_PREFERENCE_END)
943 * Change preferences for the given peer. Preference changes are forgotten if peers
946 * @param ph performance handle
947 * @param peer identifies the peer
948 * @param ... #GNUNET_ATS_PREFERENCE_END-terminated specification of the desired changes
951 GNUNET_ATS_performance_change_preference (struct GNUNET_ATS_PerformanceHandle *ph,
952 const struct GNUNET_PeerIdentity *peer, ...)
954 struct PendingMessage *p;
955 struct ChangePreferenceMessage *m;
958 struct PreferenceInformation *pi;
960 enum GNUNET_ATS_PreferenceKind kind;
964 while (GNUNET_ATS_PREFERENCE_END !=
965 (kind = va_arg (ap, enum GNUNET_ATS_PreferenceKind) ))
969 case GNUNET_ATS_PREFERENCE_BANDWIDTH:
971 (void) va_arg (ap, double);
973 case GNUNET_ATS_PREFERENCE_LATENCY:
975 (void) va_arg (ap, double);
982 msize = count * sizeof(struct PreferenceInformation)
983 + sizeof(struct ChangePreferenceMessage);
984 p = GNUNET_malloc (sizeof (struct PendingMessage) + msize);
986 p->is_init = GNUNET_NO;
987 m = (struct ChangePreferenceMessage *) &p[1];
988 m->header.type = htons (GNUNET_MESSAGE_TYPE_ATS_PREFERENCE_CHANGE);
989 m->header.size = htons (msize);
990 m->num_preferences = htonl (count);
992 pi = (struct PreferenceInformation *) &m[1];
995 while (GNUNET_ATS_PREFERENCE_END != (kind =
996 va_arg (ap, enum GNUNET_ATS_PreferenceKind) ))
998 pi[count].preference_kind = htonl (kind);
1001 case GNUNET_ATS_PREFERENCE_BANDWIDTH:
1002 pi[count].preference_value = (float) va_arg (ap, double);
1006 case GNUNET_ATS_PREFERENCE_LATENCY:
1007 pi[count].preference_value = (float) va_arg (ap, double);
1016 GNUNET_CONTAINER_DLL_insert_tail(ph->pending_head, ph->pending_tail, p);
1022 * Send feedback to ATS on how good a the requirements for a peer and a
1023 * preference is satisfied by ATS
1025 * @param ph performance handle
1026 * @param scope the time interval this valid for: [now - scope .. now]
1027 * @param peer identifies the peer
1028 * @param ... #GNUNET_ATS_PREFERENCE_END-terminated specification of the desired changes
1031 GNUNET_ATS_performance_give_feedback (struct GNUNET_ATS_PerformanceHandle *ph,
1032 const struct GNUNET_PeerIdentity *peer,
1033 const struct GNUNET_TIME_Relative scope, ...)
1035 struct PendingMessage *p;
1036 struct FeedbackPreferenceMessage *m;
1039 struct PreferenceInformation *pi;
1041 enum GNUNET_ATS_PreferenceKind kind;
1044 va_start(ap, scope);
1045 while (GNUNET_ATS_PREFERENCE_END !=
1046 (kind = va_arg (ap, enum GNUNET_ATS_PreferenceKind) ))
1050 case GNUNET_ATS_PREFERENCE_BANDWIDTH:
1052 (void) va_arg (ap, double);
1054 case GNUNET_ATS_PREFERENCE_LATENCY:
1056 (void) va_arg (ap, double);
1063 msize = count * sizeof(struct PreferenceInformation)
1064 + sizeof(struct FeedbackPreferenceMessage);
1065 p = GNUNET_malloc (sizeof (struct PendingMessage) + msize);
1067 p->is_init = GNUNET_NO;
1068 m = (struct FeedbackPreferenceMessage *) &p[1];
1069 m->header.type = htons (GNUNET_MESSAGE_TYPE_ATS_PREFERENCE_FEEDBACK);
1070 m->header.size = htons (msize);
1071 m->scope = GNUNET_TIME_relative_hton (scope);
1072 m->num_feedback = htonl (count);
1074 pi = (struct PreferenceInformation *) &m[1];
1076 va_start(ap, scope);
1077 while (GNUNET_ATS_PREFERENCE_END != (kind =
1078 va_arg (ap, enum GNUNET_ATS_PreferenceKind) ))
1080 pi[count].preference_kind = htonl (kind);
1083 case GNUNET_ATS_PREFERENCE_BANDWIDTH:
1084 pi[count].preference_value = (float) va_arg (ap, double);
1088 case GNUNET_ATS_PREFERENCE_LATENCY:
1089 pi[count].preference_value = (float) va_arg (ap, double);
1098 GNUNET_CONTAINER_DLL_insert_tail (ph->pending_head,
1104 /* end of ats_api_performance.c */