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"
31 * Message in linked list we should send to the ATS service. The
32 * actual binary message follows this struct.
40 struct PendingMessage *next;
45 struct PendingMessage *prev;
48 * Size of the message.
53 * Is this the 'ATS_START' message?
60 * Linked list of pending reservations.
62 struct GNUNET_ATS_ReservationContext
68 struct GNUNET_ATS_ReservationContext *next;
73 struct GNUNET_ATS_ReservationContext *prev;
78 struct GNUNET_PeerIdentity peer;
86 * Function to call on result.
88 GNUNET_ATS_ReservationCallback rcb;
96 * Do we need to undo this reservation if it succeeded? Set to
97 * #GNUNET_YES if a reservation is cancelled. (at that point, 'info'
98 * is also set to NULL; however, info will ALSO be NULL for the
99 * reservation context that is created to undo the original request,
100 * so 'info' being NULL cannot be used to check if undo is
108 * Linked list of pending reservations.
110 struct GNUNET_ATS_AddressListHandle
116 struct GNUNET_ATS_AddressListHandle *next;
121 struct GNUNET_ATS_AddressListHandle *prev;
126 struct GNUNET_ATS_PerformanceHandle *ph;
131 GNUNET_ATS_AddressInformationCallback cb;
134 * Callback closure for @e cb
141 struct GNUNET_PeerIdentity peer;
144 * Return all or specific peer only
149 * Return all or used address only
154 * Request multiplexing
161 * ATS Handle to obtain and/or modify performance information.
163 struct GNUNET_ATS_PerformanceHandle
169 const struct GNUNET_CONFIGURATION_Handle *cfg;
172 * Callback to invoke when an address has performance changes.
174 GNUNET_ATS_AddressInformationCallback addr_info_cb;
177 * Closure for @e addr_info_cb.
179 void *addr_info_cb_cls;
182 * Connection to ATS service.
184 struct GNUNET_CLIENT_Connection *client;
187 * Head of list of messages for the ATS service.
189 struct PendingMessage *pending_head;
192 * Tail of list of messages for the ATS service
194 struct PendingMessage *pending_tail;
197 * Head of linked list of pending reservation requests.
199 struct GNUNET_ATS_ReservationContext *reservation_head;
202 * Tail of linked list of pending reservation requests.
204 struct GNUNET_ATS_ReservationContext *reservation_tail;
207 * Head of linked list of pending address list requests.
209 struct GNUNET_ATS_AddressListHandle *addresslist_head;
212 * Tail of linked list of pending address list requests.
214 struct GNUNET_ATS_AddressListHandle *addresslist_tail;
217 * Current request for transmission to ATS.
219 struct GNUNET_CLIENT_TransmitHandle *th;
222 * Task to trigger reconnect.
224 GNUNET_SCHEDULER_TaskIdentifier task;
227 * Monitor request multiplexing
232 * Request multiplexing
238 * Re-establish the connection to the ATS service.
240 * @param ph handle to use to re-connect.
243 reconnect (struct GNUNET_ATS_PerformanceHandle *ph);
247 * Re-establish the connection to the ATS service.
249 * @param cls handle to use to re-connect.
250 * @param tc scheduler context
253 reconnect_task (void *cls,
254 const struct GNUNET_SCHEDULER_TaskContext *tc)
256 struct GNUNET_ATS_PerformanceHandle *ph = cls;
258 ph->task = GNUNET_SCHEDULER_NO_TASK;
264 * Transmit messages from the message queue to the service
265 * (if there are any, and if we are not already trying).
267 * @param ph handle to use
270 do_transmit (struct GNUNET_ATS_PerformanceHandle *ph);
274 * Type of a function to call when we receive a message
277 * @param cls the `struct GNUNET_ATS_SchedulingHandle`
278 * @param msg message received, NULL on timeout or fatal error
281 process_ats_message (void *cls,
282 const struct GNUNET_MessageHeader *msg);
286 * We can now transmit a message to ATS. Do it.
288 * @param cls the `struct GNUNET_ATS_PerformanceHandle`
289 * @param size number of bytes we can transmit to ATS
290 * @param buf where to copy the messages
291 * @return number of bytes copied into @a buf
294 transmit_message_to_ats (void *cls,
298 struct GNUNET_ATS_PerformanceHandle *ph = cls;
299 struct PendingMessage *p;
306 while ((NULL != (p = ph->pending_head)) && (p->size <= size))
308 memcpy (&cbuf[ret], &p[1], p->size);
311 GNUNET_CONTAINER_DLL_remove (ph->pending_head,
322 * Transmit messages from the message queue to the service
323 * (if there are any, and if we are not already trying).
325 * @param ph handle to use
328 do_transmit (struct GNUNET_ATS_PerformanceHandle *ph)
330 struct PendingMessage *p;
334 if (NULL == (p = ph->pending_head))
336 if (NULL == ph->client)
337 return; /* currently reconnecting */
338 ph->th = GNUNET_CLIENT_notify_transmit_ready (ph->client,
340 GNUNET_TIME_UNIT_FOREVER_REL,
342 &transmit_message_to_ats, ph);
347 * We received a peer information message. Validate and process it.
349 * @param ph our context with the callback
350 * @param msg the message
351 * @return #GNUNET_OK if the message was well-formed
354 process_pi_message (struct GNUNET_ATS_PerformanceHandle *ph,
355 const struct GNUNET_MessageHeader *msg)
357 const struct PeerInformationMessage *pi;
358 const struct GNUNET_ATS_Information *atsi;
359 const char *plugin_address;
360 const char *plugin_name;
361 struct GNUNET_HELLO_Address address;
362 uint16_t plugin_address_length;
363 uint16_t plugin_name_length;
367 if (ntohs (msg->size) < sizeof(struct PeerInformationMessage))
370 return GNUNET_SYSERR;
373 pi = (const struct PeerInformationMessage *) msg;
374 ats_count = ntohl (pi->ats_count);
375 plugin_address_length = ntohs (pi->address_length);
376 plugin_name_length = ntohs (pi->plugin_name_length);
377 addr_active = (int) ntohl (pi->address_active);
378 atsi = (const struct GNUNET_ATS_Information *) &pi[1];
379 plugin_address = (const char *) &atsi[ats_count];
380 plugin_name = &plugin_address[plugin_address_length];
381 if ((plugin_address_length + plugin_name_length
382 + ats_count * sizeof(struct GNUNET_ATS_Information)
383 + sizeof(struct PeerInformationMessage) != ntohs (msg->size))
385 > GNUNET_SERVER_MAX_MESSAGE_SIZE
386 / sizeof(struct GNUNET_ATS_Information))
387 || (plugin_name[plugin_name_length - 1] != '\0'))
390 return GNUNET_SYSERR;
393 if (NULL != ph->addr_info_cb)
395 address.peer = pi->peer;
396 address.address = plugin_address;
397 address.address_length = plugin_address_length;
398 address.transport_name = plugin_name;
399 ph->addr_info_cb (ph->addr_info_cb_cls,
411 * We received a reservation result message. Validate and process it.
413 * @param ph our context with the callback
414 * @param msg the message
415 * @return #GNUNET_OK if the message was well-formed
418 process_rr_message (struct GNUNET_ATS_PerformanceHandle *ph,
419 const struct GNUNET_MessageHeader *msg)
421 const struct ReservationResultMessage *rr;
422 struct GNUNET_ATS_ReservationContext *rc;
425 if (ntohs (msg->size) < sizeof(struct ReservationResultMessage))
428 return GNUNET_SYSERR;
430 rr = (const struct ReservationResultMessage *) msg;
431 amount = ntohl (rr->amount);
432 rc = ph->reservation_head;
433 if (0 != memcmp (&rr->peer, &rc->peer, sizeof(struct GNUNET_PeerIdentity)))
436 return GNUNET_SYSERR;
438 GNUNET_CONTAINER_DLL_remove (ph->reservation_head,
439 ph->reservation_tail,
441 if ( (0 == amount) ||
444 /* tell client if not cancelled */
445 if (rc->rcb != NULL )
446 rc->rcb (rc->rcb_cls,
449 GNUNET_TIME_relative_ntoh (rr->res_delay));
453 /* amount non-zero, but client cancelled, consider undo! */
454 if (GNUNET_YES != rc->undo)
457 return GNUNET_OK; /* do not try to undo failed undos or negative amounts */
460 (void) GNUNET_ATS_reserve_bandwidth (ph,
469 * We received a reservation result message. Validate and process it.
471 * @param ph our context with the callback
472 * @param msg the message
473 * @return #GNUNET_OK if the message was well-formed
476 process_ar_message (struct GNUNET_ATS_PerformanceHandle *ph,
477 const struct GNUNET_MessageHeader *msg)
479 const struct PeerInformationMessage *pi;
480 struct GNUNET_ATS_AddressListHandle *alh;
481 struct GNUNET_ATS_AddressListHandle *next;
482 const struct GNUNET_ATS_Information *atsi;
483 const char *plugin_address;
484 const char *plugin_name;
485 struct GNUNET_HELLO_Address address;
486 struct GNUNET_PeerIdentity allzeros;
487 struct GNUNET_BANDWIDTH_Value32NBO bandwidth_zero;
488 uint16_t plugin_address_length;
489 uint16_t plugin_name_length;
494 if (ntohs (msg->size) < sizeof(struct PeerInformationMessage))
497 return GNUNET_SYSERR;
499 pi = (const struct PeerInformationMessage *) msg;
501 ats_count = ntohl (pi->ats_count);
502 active = ntohl (pi->address_active);
503 plugin_address_length = ntohs (pi->address_length);
504 plugin_name_length = ntohs (pi->plugin_name_length);
505 atsi = (const struct GNUNET_ATS_Information *) &pi[1];
506 plugin_address = (const char *) &atsi[ats_count];
507 plugin_name = &plugin_address[plugin_address_length];
508 if ( (plugin_address_length + plugin_name_length
509 + ats_count * sizeof(struct GNUNET_ATS_Information)
510 + sizeof (struct PeerInformationMessage) != ntohs (msg->size)) ||
511 (ats_count > GNUNET_SERVER_MAX_MESSAGE_SIZE
512 / sizeof(struct GNUNET_ATS_Information)) ||
513 (plugin_name[plugin_name_length - 1] != '\0') )
516 return GNUNET_SYSERR;
518 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
519 "Received %s message for peer %s and plugin %s\n",
520 "ATS_ADDRESSLIST_RESPONSE",
521 GNUNET_i2s (&pi->peer),
524 next = ph->addresslist_head;
525 while (NULL != (alh = next))
534 return GNUNET_SYSERR;
537 memset (&allzeros, '\0', sizeof (allzeros));
538 if ( (0 == memcmp (&allzeros, &pi->peer, sizeof(allzeros))) &&
539 (0 == plugin_name_length) &&
540 (0 == plugin_address_length) &&
544 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
545 "Received last message for %s\n",
546 "ATS_ADDRESSLIST_RESPONSE");
547 bandwidth_zero.value__ = htonl (0);
548 GNUNET_CONTAINER_DLL_remove (ph->addresslist_head,
549 ph->addresslist_tail,
552 alh->cb (ph->addr_info_cb_cls,
562 address.peer = pi->peer;
563 address.address = plugin_address;
564 address.address_length = plugin_address_length;
565 address.transport_name = plugin_name;
566 if ( ( (GNUNET_YES == alh->all_addresses) ||
567 (GNUNET_YES == active) ) &&
569 alh->cb (ph->addr_info_cb_cls,
580 * Type of a function to call when we receive a message
583 * @param cls the 'struct GNUNET_ATS_SchedulingHandle'
584 * @param msg message received, NULL on timeout or fatal error
587 process_ats_message (void *cls,
588 const struct GNUNET_MessageHeader *msg)
590 struct GNUNET_ATS_PerformanceHandle *ph = cls;
594 switch (ntohs (msg->type))
596 case GNUNET_MESSAGE_TYPE_ATS_PEER_INFORMATION:
597 if (GNUNET_OK != process_pi_message (ph, msg))
600 case GNUNET_MESSAGE_TYPE_ATS_RESERVATION_RESULT:
601 if (GNUNET_OK != process_rr_message (ph, msg))
604 case GNUNET_MESSAGE_TYPE_ATS_ADDRESSLIST_RESPONSE:
605 if (GNUNET_OK != process_ar_message (ph, msg))
612 GNUNET_CLIENT_receive (ph->client,
613 &process_ats_message,
615 GNUNET_TIME_UNIT_FOREVER_REL);
619 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
623 GNUNET_CLIENT_notify_transmit_ready_cancel (ph->th);
626 GNUNET_CLIENT_disconnect (ph->client);
628 if (NULL != ph->addr_info_cb)
630 /* Indicate reconnect */
631 ph->addr_info_cb (ph->addr_info_cb_cls,
634 GNUNET_BANDWIDTH_value_init (0),
635 GNUNET_BANDWIDTH_value_init (0),
638 ph->task = GNUNET_SCHEDULER_add_delayed (GNUNET_TIME_UNIT_SECONDS,
639 &reconnect_task, ph);
644 * Re-establish the connection to the ATS service.
646 * @param ph handle to use to re-connect.
649 reconnect (struct GNUNET_ATS_PerformanceHandle *ph)
651 struct PendingMessage *p;
652 struct ClientStartMessage *init;
654 GNUNET_assert (NULL == ph->client);
655 ph->client = GNUNET_CLIENT_connect ("ats",
657 GNUNET_assert (NULL != ph->client);
658 GNUNET_CLIENT_receive (ph->client,
659 &process_ats_message,
661 GNUNET_TIME_UNIT_FOREVER_REL);
662 if ((NULL == (p = ph->pending_head)) || (GNUNET_YES != p->is_init))
664 p = GNUNET_malloc (sizeof (struct PendingMessage) +
665 sizeof (struct ClientStartMessage));
666 p->size = sizeof(struct ClientStartMessage);
667 p->is_init = GNUNET_YES;
668 init = (struct ClientStartMessage *) &p[1];
669 init->header.type = htons (GNUNET_MESSAGE_TYPE_ATS_START);
670 init->header.size = htons (sizeof(struct ClientStartMessage));
671 init->start_flag = htonl ( (NULL == ph->addr_info_cb)
672 ? START_FLAG_PERFORMANCE_NO_PIC
673 : START_FLAG_PERFORMANCE_WITH_PIC);
674 GNUNET_CONTAINER_DLL_insert (ph->pending_head,
683 * Get handle to access performance API of the ATS subsystem.
685 * @param cfg configuration to use
686 * @param addr_info_cb callback called when performance characteristics for
688 * @param addr_info_cb_cls closure for @a addr_info_cb
689 * @return ats performance context
691 struct GNUNET_ATS_PerformanceHandle *
692 GNUNET_ATS_performance_init (const struct GNUNET_CONFIGURATION_Handle *cfg,
693 GNUNET_ATS_AddressInformationCallback addr_info_cb,
694 void *addr_info_cb_cls)
696 struct GNUNET_ATS_PerformanceHandle *ph;
698 ph = GNUNET_new (struct GNUNET_ATS_PerformanceHandle);
700 ph->addr_info_cb = addr_info_cb;
701 ph->addr_info_cb_cls = addr_info_cb_cls;
709 * Client is done using the ATS performance subsystem, release resources.
714 GNUNET_ATS_performance_done (struct GNUNET_ATS_PerformanceHandle *ph)
716 struct PendingMessage *p;
717 struct GNUNET_ATS_ReservationContext *rc;
718 struct GNUNET_ATS_AddressListHandle *alh;
720 while (NULL != (p = ph->pending_head))
722 GNUNET_CONTAINER_DLL_remove (ph->pending_head,
727 while (NULL != (alh = ph->addresslist_head))
729 GNUNET_CONTAINER_DLL_remove (ph->addresslist_head,
730 ph->addresslist_tail,
734 while (NULL != (rc = ph->reservation_head))
736 GNUNET_CONTAINER_DLL_remove (ph->reservation_head,
737 ph->reservation_tail,
739 GNUNET_break (NULL == rc->rcb);
743 if (GNUNET_SCHEDULER_NO_TASK != ph->task)
745 GNUNET_SCHEDULER_cancel (ph->task);
746 ph->task = GNUNET_SCHEDULER_NO_TASK;
748 if (NULL != ph->client)
750 GNUNET_CLIENT_disconnect (ph->client);
758 * Reserve inbound bandwidth from the given peer. ATS will look at
759 * the current amount of traffic we receive from the peer and ensure
760 * that the peer could add 'amount' of data to its stream.
762 * @param ph performance handle
763 * @param peer identifies the peer
764 * @param amount reserve N bytes for receiving, negative
765 * amounts can be used to undo a (recent) reservation;
766 * @param rcb function to call with the resulting reservation information
767 * @param rcb_cls closure for @a rcb
768 * @return NULL on error
769 * @deprecated will be replaced soon
771 struct GNUNET_ATS_ReservationContext *
772 GNUNET_ATS_reserve_bandwidth (struct GNUNET_ATS_PerformanceHandle *ph,
773 const struct GNUNET_PeerIdentity *peer,
775 GNUNET_ATS_ReservationCallback rcb, void *rcb_cls)
777 struct GNUNET_ATS_ReservationContext *rc;
778 struct PendingMessage *p;
779 struct ReservationRequestMessage *m;
781 rc = GNUNET_new (struct GNUNET_ATS_ReservationContext);
785 rc->rcb_cls = rcb_cls;
786 if ( (NULL != rcb) &&
788 rc->undo = GNUNET_YES;
789 GNUNET_CONTAINER_DLL_insert_tail (ph->reservation_head,
790 ph->reservation_tail,
793 p = GNUNET_malloc (sizeof (struct PendingMessage) +
794 sizeof (struct ReservationRequestMessage));
795 p->size = sizeof(struct ReservationRequestMessage);
796 p->is_init = GNUNET_NO;
797 m = (struct ReservationRequestMessage *) &p[1];
798 m->header.type = htons (GNUNET_MESSAGE_TYPE_ATS_RESERVATION_REQUEST);
799 m->header.size = htons (sizeof(struct ReservationRequestMessage));
800 m->amount = htonl (amount);
802 GNUNET_CONTAINER_DLL_insert_tail (ph->pending_head,
811 * Cancel request for reserving bandwidth.
813 * @param rc context returned by the original GNUNET_ATS_reserve_bandwidth call
816 GNUNET_ATS_reserve_bandwidth_cancel (struct GNUNET_ATS_ReservationContext *rc)
823 * Get information about addresses known to the ATS subsystem.
825 * @param handle the performance handle to use
826 * @param peer peer idm can be NULL for all peers
827 * @param all #GNUNET_YES to get information about all addresses or #GNUNET_NO to
828 * get only address currently used
829 * @param infocb callback to call with the addresses,
830 * will callback with address == NULL when done
831 * @param infocb_cls closure for @a infocb
832 * @return ats performance context
834 struct GNUNET_ATS_AddressListHandle*
835 GNUNET_ATS_performance_list_addresses (struct GNUNET_ATS_PerformanceHandle *handle,
836 const struct GNUNET_PeerIdentity *peer,
838 GNUNET_ATS_AddressInformationCallback infocb,
841 struct GNUNET_ATS_AddressListHandle *alh;
842 struct PendingMessage *p;
843 struct AddressListRequestMessage *m;
847 alh = GNUNET_new (struct GNUNET_ATS_AddressListHandle);
848 alh->id = handle->id;
851 alh->cb_cls = infocb_cls;
853 alh->all_addresses = all;
856 alh->all_peers = GNUNET_YES;
860 alh->all_peers = GNUNET_NO;
863 GNUNET_CONTAINER_DLL_insert (handle->addresslist_head,
864 handle->addresslist_tail,
867 p = GNUNET_malloc (sizeof (struct PendingMessage) +
868 sizeof (struct AddressListRequestMessage));
869 p->size = sizeof (struct AddressListRequestMessage);
870 m = (struct AddressListRequestMessage *) &p[1];
871 m->header.type = htons (GNUNET_MESSAGE_TYPE_ATS_ADDRESSLIST_REQUEST);
872 m->header.size = htons (sizeof(struct AddressListRequestMessage));
873 m->all = htonl (all);
874 m->id = htonl (alh->id);
877 GNUNET_CONTAINER_DLL_insert_tail (handle->pending_head,
878 handle->pending_tail,
880 do_transmit (handle);
887 * Cancel a pending address listing operation
889 * @param handle the handle of the request to cancel
892 GNUNET_ATS_performance_list_addresses_cancel (struct GNUNET_ATS_AddressListHandle *handle)
894 GNUNET_CONTAINER_DLL_remove (handle->ph->addresslist_head,
895 handle->ph->addresslist_tail,
897 GNUNET_free (handle);
902 * Convert a `enum GNUNET_ATS_PreferenceType` to a string
904 * @param type the preference type
905 * @return a string or NULL if invalid
908 GNUNET_ATS_print_preference_type (uint32_t type)
910 char *prefs[GNUNET_ATS_PreferenceCount] = GNUNET_ATS_PreferenceTypeString;
911 if (type < GNUNET_ATS_PreferenceCount)
918 * Change preferences for the given peer. Preference changes are forgotten if peers
921 * @param ph performance handle
922 * @param peer identifies the peer
923 * @param ... 0-terminated specification of the desired changes
926 GNUNET_ATS_performance_change_preference (struct GNUNET_ATS_PerformanceHandle *ph,
927 const struct GNUNET_PeerIdentity *peer, ...)
929 struct PendingMessage *p;
930 struct ChangePreferenceMessage *m;
933 struct PreferenceInformation *pi;
935 enum GNUNET_ATS_PreferenceKind kind;
939 while (GNUNET_ATS_PREFERENCE_END != (kind =
940 va_arg (ap, enum GNUNET_ATS_PreferenceKind) ))
944 case GNUNET_ATS_PREFERENCE_BANDWIDTH:
946 (void) va_arg (ap, double);
949 case GNUNET_ATS_PREFERENCE_LATENCY:
951 (void) va_arg (ap, double);
959 msize = count * sizeof(struct PreferenceInformation)
960 + sizeof(struct ChangePreferenceMessage);
961 p = GNUNET_malloc (sizeof (struct PendingMessage) + msize);
963 p->is_init = GNUNET_NO;
964 m = (struct ChangePreferenceMessage *) &p[1];
965 m->header.type = htons (GNUNET_MESSAGE_TYPE_ATS_PREFERENCE_CHANGE);
966 m->header.size = htons (msize);
967 m->num_preferences = htonl (count);
969 pi = (struct PreferenceInformation *) &m[1];
972 while (GNUNET_ATS_PREFERENCE_END != (kind =
973 va_arg (ap, enum GNUNET_ATS_PreferenceKind) ))
975 pi[count].preference_kind = htonl (kind);
978 case GNUNET_ATS_PREFERENCE_BANDWIDTH:
979 pi[count].preference_value = (float) va_arg (ap, double);
983 case GNUNET_ATS_PREFERENCE_LATENCY:
984 pi[count].preference_value = (float) va_arg (ap, double);
993 GNUNET_CONTAINER_DLL_insert_tail(ph->pending_head, ph->pending_tail, p);
999 * Send feedback to ATS on how good a the requirements for a peer and a
1000 * preference is satisfied by ATS
1002 * @param ph performance handle
1003 * @param scope the time interval this valid for: [now - scope .. now]
1004 * @param peer identifies the peer
1005 * @param ... 0-terminated specification of the desired changes
1008 GNUNET_ATS_performance_give_feedback (struct GNUNET_ATS_PerformanceHandle *ph,
1009 const struct GNUNET_PeerIdentity *peer,
1010 const struct GNUNET_TIME_Relative scope, ...)
1012 struct PendingMessage *p;
1013 struct FeedbackPreferenceMessage *m;
1016 struct PreferenceInformation *pi;
1018 enum GNUNET_ATS_PreferenceKind kind;
1021 va_start(ap, scope);
1022 while (GNUNET_ATS_PREFERENCE_END != (kind =
1023 va_arg (ap, enum GNUNET_ATS_PreferenceKind) ))
1027 case GNUNET_ATS_PREFERENCE_BANDWIDTH:
1029 (void) va_arg (ap, double);
1031 case GNUNET_ATS_PREFERENCE_LATENCY:
1033 (void) va_arg (ap, double);
1040 msize = count * sizeof(struct PreferenceInformation)
1041 + sizeof(struct FeedbackPreferenceMessage);
1042 p = GNUNET_malloc (sizeof (struct PendingMessage) + msize);
1044 p->is_init = GNUNET_NO;
1045 m = (struct FeedbackPreferenceMessage *) &p[1];
1046 m->header.type = htons (GNUNET_MESSAGE_TYPE_ATS_PREFERENCE_FEEDBACK);
1047 m->header.size = htons (msize);
1048 m->scope = GNUNET_TIME_relative_hton (scope);
1049 m->num_feedback = htonl (count);
1051 pi = (struct PreferenceInformation *) &m[1];
1053 va_start(ap, scope);
1054 while (GNUNET_ATS_PREFERENCE_END != (kind =
1055 va_arg (ap, enum GNUNET_ATS_PreferenceKind) ))
1057 pi[count].preference_kind = htonl (kind);
1060 case GNUNET_ATS_PREFERENCE_BANDWIDTH:
1061 pi[count].preference_value = (float) va_arg (ap, double);
1065 case GNUNET_ATS_PREFERENCE_LATENCY:
1066 pi[count].preference_value = (float) va_arg (ap, double);
1075 GNUNET_CONTAINER_DLL_insert_tail (ph->pending_head,
1081 /* end of ats_api_performance.c */