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 * Type of a function to call when we receive a message
280 * @param cls the 'struct GNUNET_ATS_SchedulingHandle'
281 * @param msg message received, NULL on timeout or fatal error
284 process_ats_message (void *cls, const struct GNUNET_MessageHeader *msg);
287 * We can now transmit a message to ATS. Do it.
289 * @param cls the 'struct GNUNET_ATS_SchedulingHandle'
290 * @param size number of bytes we can transmit to ATS
291 * @param buf where to copy the messages
292 * @return number of bytes copied into buf
295 transmit_message_to_ats (void *cls, size_t size, void *buf)
297 struct GNUNET_ATS_PerformanceHandle *ph = cls;
298 struct PendingMessage *p;
305 while ((NULL != (p = ph->pending_head)) && (p->size <= size))
307 memcpy (&cbuf[ret], &p[1], p->size);
310 GNUNET_CONTAINER_DLL_remove (ph->pending_head, ph->pending_tail, p);
319 * Transmit messages from the message queue to the service
320 * (if there are any, and if we are not already trying).
322 * @param ph handle to use
325 do_transmit (struct GNUNET_ATS_PerformanceHandle *ph)
327 struct PendingMessage *p;
331 if (NULL == (p = ph->pending_head))
333 if (NULL == ph->client)
334 return; /* currently reconnecting */
336 GNUNET_CLIENT_notify_transmit_ready (ph->client, p->size,
337 GNUNET_TIME_UNIT_FOREVER_REL,
338 GNUNET_YES, &transmit_message_to_ats,
344 * We received a peer information message. Validate and process it.
346 * @param ph our context with the callback
347 * @param msg the message
348 * @return GNUNET_OK if the message was well-formed
351 process_pi_message (struct GNUNET_ATS_PerformanceHandle *ph,
352 const struct GNUNET_MessageHeader *msg)
354 const struct PeerInformationMessage *pi;
355 const struct GNUNET_ATS_Information *atsi;
356 const char *plugin_address;
357 const char *plugin_name;
358 struct GNUNET_HELLO_Address address;
359 uint16_t plugin_address_length;
360 uint16_t plugin_name_length;
364 if (ntohs (msg->size) < sizeof (struct PeerInformationMessage))
367 return GNUNET_SYSERR;
370 pi = (const struct PeerInformationMessage *) msg;
371 ats_count = ntohl (pi->ats_count);
372 plugin_address_length = ntohs (pi->address_length);
373 plugin_name_length = ntohs (pi->plugin_name_length);
374 addr_active = ntohl (pi->address_active);
375 atsi = (const struct GNUNET_ATS_Information *) &pi[1];
376 plugin_address = (const char *) &atsi[ats_count];
377 plugin_name = &plugin_address[plugin_address_length];
378 if ((plugin_address_length + plugin_name_length +
379 ats_count * sizeof (struct GNUNET_ATS_Information) +
380 sizeof (struct PeerInformationMessage) != ntohs (msg->size)) ||
382 GNUNET_SERVER_MAX_MESSAGE_SIZE / sizeof (struct GNUNET_ATS_Information))
383 || (plugin_name[plugin_name_length - 1] != '\0'))
386 return GNUNET_SYSERR;
389 if (NULL != ph->addr_info_cb)
391 address.peer = pi->peer;
392 address.address = plugin_address;
393 address.address_length = plugin_address_length;
394 address.transport_name = plugin_name;
396 ph->addr_info_cb (ph->addr_info_cb_cls, &address, addr_active, pi->bandwidth_out, pi->bandwidth_in,
404 * We received a reservation result message. Validate and process it.
406 * @param ph our context with the callback
407 * @param msg the message
408 * @return GNUNET_OK if the message was well-formed
411 process_rr_message (struct GNUNET_ATS_PerformanceHandle *ph,
412 const struct GNUNET_MessageHeader *msg)
414 const struct ReservationResultMessage *rr;
415 struct GNUNET_ATS_ReservationContext *rc;
418 if (ntohs (msg->size) < sizeof (struct ReservationResultMessage))
421 return GNUNET_SYSERR;
423 rr = (const struct ReservationResultMessage *) msg;
424 amount = ntohl (rr->amount);
425 rc = ph->reservation_head;
426 if (0 != memcmp (&rr->peer, &rc->peer, sizeof (struct GNUNET_PeerIdentity)))
429 return GNUNET_SYSERR;
431 GNUNET_CONTAINER_DLL_remove (ph->reservation_head, ph->reservation_tail, rc);
432 if ((amount == 0) || (rc->rcb != NULL))
434 /* tell client if not cancelled */
436 rc->rcb (rc->rcb_cls, &rr->peer, amount,
437 GNUNET_TIME_relative_ntoh (rr->res_delay));
441 /* amount non-zero, but client cancelled, consider undo! */
442 if (GNUNET_YES != rc->undo)
445 return GNUNET_OK; /* do not try to undo failed undos or negative amounts */
448 (void) GNUNET_ATS_reserve_bandwidth (ph, &rr->peer, -amount, NULL, NULL);
454 * We received a reservation result message. Validate and process it.
456 * @param ph our context with the callback
457 * @param msg the message
458 * @return GNUNET_OK if the message was well-formed
461 process_ar_message (struct GNUNET_ATS_PerformanceHandle *ph,
462 const struct GNUNET_MessageHeader *msg)
464 const struct PeerInformationMessage *pi;
465 struct GNUNET_ATS_AddressListHandle *alh;
466 struct GNUNET_ATS_AddressListHandle *next;
467 const struct GNUNET_ATS_Information *atsi;
468 const char *plugin_address;
469 const char *plugin_name;
470 struct GNUNET_HELLO_Address address;
471 struct GNUNET_PeerIdentity allzeros;
472 struct GNUNET_BANDWIDTH_Value32NBO bandwidth_zero;
473 uint16_t plugin_address_length;
474 uint16_t plugin_name_length;
479 if (ntohs (msg->size) < sizeof (struct PeerInformationMessage))
482 return GNUNET_SYSERR;
484 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
485 _("Received %s message\n"), "ATS_ADDRESSLIST_RESPONSE");
487 pi = (const struct PeerInformationMessage *) msg;
489 ats_count = ntohl (pi->ats_count);
490 active = ntohl (pi->address_active);
491 plugin_address_length = ntohs (pi->address_length);
492 plugin_name_length = ntohs (pi->plugin_name_length);
493 atsi = (const struct GNUNET_ATS_Information *) &pi[1];
494 plugin_address = (const char *) &atsi[ats_count];
495 plugin_name = &plugin_address[plugin_address_length];
496 if ((plugin_address_length + plugin_name_length +
497 ats_count * sizeof (struct GNUNET_ATS_Information) +
498 sizeof (struct PeerInformationMessage) != ntohs (msg->size)) ||
500 GNUNET_SERVER_MAX_MESSAGE_SIZE / sizeof (struct GNUNET_ATS_Information))
501 || (plugin_name[plugin_name_length - 1] != '\0'))
504 return GNUNET_SYSERR;
507 next = ph->addresslist_head;
508 while (NULL != (alh = next))
517 return GNUNET_SYSERR;
520 memset (&allzeros, '\0', sizeof (allzeros));
521 if ((0 == memcmp (&allzeros, &pi->peer, sizeof (allzeros))) &&
522 (0 == plugin_name_length) &&
523 (0 == plugin_address_length) &&
527 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
528 _("Received last message for %s \n"), "ATS_ADDRESSLIST_RESPONSE");
529 bandwidth_zero.value__ = htonl (0);
531 alh->cb (ph->addr_info_cb_cls,
534 bandwidth_zero, bandwidth_zero,
536 GNUNET_CONTAINER_DLL_remove (ph->addresslist_head, ph->addresslist_tail, alh);
541 address.peer = pi->peer;
542 address.address = plugin_address;
543 address.address_length = plugin_address_length;
544 address.transport_name = plugin_name;
546 if ((GNUNET_YES == alh->all_addresses) || (GNUNET_YES == active))
549 alh->cb (ph->addr_info_cb_cls,
552 pi->bandwidth_out, pi->bandwidth_in,
560 * Type of a function to call when we receive a message
563 * @param cls the 'struct GNUNET_ATS_SchedulingHandle'
564 * @param msg message received, NULL on timeout or fatal error
567 process_ats_message (void *cls, const struct GNUNET_MessageHeader *msg)
569 struct GNUNET_ATS_PerformanceHandle *ph = cls;
573 switch (ntohs (msg->type))
575 case GNUNET_MESSAGE_TYPE_ATS_PEER_INFORMATION:
576 if (GNUNET_OK != process_pi_message (ph, msg))
579 case GNUNET_MESSAGE_TYPE_ATS_RESERVATION_RESULT:
580 if (GNUNET_OK != process_rr_message (ph, msg))
583 case GNUNET_MESSAGE_TYPE_ATS_ADDRESSLIST_RESPONSE:
584 if (GNUNET_OK != process_ar_message (ph, msg))
591 GNUNET_CLIENT_receive (ph->client, &process_ats_message, ph,
592 GNUNET_TIME_UNIT_FOREVER_REL);
597 GNUNET_CLIENT_notify_transmit_ready_cancel (ph->th);
600 GNUNET_CLIENT_disconnect (ph->client);
603 GNUNET_SCHEDULER_add_delayed (GNUNET_TIME_UNIT_SECONDS, &reconnect_task,
609 * Re-establish the connection to the ATS service.
611 * @param ph handle to use to re-connect.
614 reconnect (struct GNUNET_ATS_PerformanceHandle *ph)
616 struct PendingMessage *p;
617 struct ClientStartMessage *init;
619 GNUNET_assert (NULL == ph->client);
620 ph->client = GNUNET_CLIENT_connect ("ats", ph->cfg);
621 GNUNET_assert (NULL != ph->client);
622 GNUNET_CLIENT_receive (ph->client, &process_ats_message, ph,
623 GNUNET_TIME_UNIT_FOREVER_REL);
624 if ((NULL == (p = ph->pending_head)) || (GNUNET_YES != p->is_init))
626 p = GNUNET_malloc (sizeof (struct PendingMessage) +
627 sizeof (struct ClientStartMessage));
628 p->size = sizeof (struct ClientStartMessage);
629 p->is_init = GNUNET_YES;
630 init = (struct ClientStartMessage *) &p[1];
631 init->header.type = htons (GNUNET_MESSAGE_TYPE_ATS_START);
632 init->header.size = htons (sizeof (struct ClientStartMessage));
634 htonl ((NULL ==ph->addr_info_cb) ?
635 START_FLAG_PERFORMANCE_NO_PIC : START_FLAG_PERFORMANCE_WITH_PIC);
636 GNUNET_CONTAINER_DLL_insert (ph->pending_head, ph->pending_tail, p);
644 * Get handle to access performance API of the ATS subsystem.
646 * @param cfg configuration to use
647 * @param addr_info_cb callback called when performance characteristics for
649 * @param addr_info_cb_cls closure for infocb
650 * @return ats performance context
652 struct GNUNET_ATS_PerformanceHandle *
653 GNUNET_ATS_performance_init (const struct GNUNET_CONFIGURATION_Handle *cfg,
654 GNUNET_ATS_AddressInformationCallback addr_info_cb,
655 void *addr_info_cb_cls)
657 struct GNUNET_ATS_PerformanceHandle *ph;
659 ph = GNUNET_malloc (sizeof (struct GNUNET_ATS_PerformanceHandle));
661 ph->addr_info_cb = addr_info_cb;
662 ph->addr_info_cb_cls = addr_info_cb_cls;
669 * Client is done using the ATS performance subsystem, release resources.
674 GNUNET_ATS_performance_done (struct GNUNET_ATS_PerformanceHandle *ph)
676 struct PendingMessage *p;
677 struct GNUNET_ATS_ReservationContext *rc;
678 struct GNUNET_ATS_AddressListHandle *alh;
680 while (NULL != (p = ph->pending_head))
682 GNUNET_CONTAINER_DLL_remove (ph->pending_head, ph->pending_tail, p);
685 while (NULL != (alh = ph->addresslist_head))
687 GNUNET_CONTAINER_DLL_remove (ph->addresslist_head, ph->addresslist_tail,
691 while (NULL != (rc = ph->reservation_head))
693 GNUNET_CONTAINER_DLL_remove (ph->reservation_head, ph->reservation_tail,
695 GNUNET_break (NULL == rc->rcb);
699 if (GNUNET_SCHEDULER_NO_TASK != ph->task)
701 GNUNET_SCHEDULER_cancel (ph->task);
702 ph->task = GNUNET_SCHEDULER_NO_TASK;
704 if (NULL != ph->client)
706 GNUNET_CLIENT_disconnect (ph->client);
714 * Reserve inbound bandwidth from the given peer. ATS will look at
715 * the current amount of traffic we receive from the peer and ensure
716 * that the peer could add 'amount' of data to its stream.
718 * @param ph performance handle
719 * @param peer identifies the peer
720 * @param amount reserve N bytes for receiving, negative
721 * amounts can be used to undo a (recent) reservation;
722 * @param rcb function to call with the resulting reservation information
723 * @param rcb_cls closure for info
724 * @return NULL on error
725 * @deprecated will be replaced soon
727 struct GNUNET_ATS_ReservationContext *
728 GNUNET_ATS_reserve_bandwidth (struct GNUNET_ATS_PerformanceHandle *ph,
729 const struct GNUNET_PeerIdentity *peer,
731 GNUNET_ATS_ReservationCallback rcb, void *rcb_cls)
733 struct GNUNET_ATS_ReservationContext *rc;
734 struct PendingMessage *p;
735 struct ReservationRequestMessage *m;
737 rc = GNUNET_malloc (sizeof (struct GNUNET_ATS_ReservationContext));
741 rc->rcb_cls = rcb_cls;
742 if ((rcb != NULL) && (amount > 0))
743 rc->undo = GNUNET_YES;
744 GNUNET_CONTAINER_DLL_insert_tail (ph->reservation_head, ph->reservation_tail,
747 p = GNUNET_malloc (sizeof (struct PendingMessage) +
748 sizeof (struct ReservationRequestMessage));
749 p->size = sizeof (struct ReservationRequestMessage);
750 p->is_init = GNUNET_NO;
751 m = (struct ReservationRequestMessage *) &p[1];
752 m->header.type = htons (GNUNET_MESSAGE_TYPE_ATS_RESERVATION_REQUEST);
753 m->header.size = htons (sizeof (struct ReservationRequestMessage));
754 m->amount = htonl (amount);
756 GNUNET_CONTAINER_DLL_insert_tail (ph->pending_head, ph->pending_tail, p);
763 * Cancel request for reserving bandwidth.
765 * @param rc context returned by the original GNUNET_ATS_reserve_bandwidth call
768 GNUNET_ATS_reserve_bandwidth_cancel (struct GNUNET_ATS_ReservationContext *rc)
774 * Get information about addresses known to the ATS subsystem.
776 * @param handle the performance handle to use
777 * @param peer peer idm can be NULL for all peers
778 * @param all GNUNET_YES to get information about all addresses or GNUNET_NO to
779 * get only address currently used
780 * @param infocb callback to call with the addresses,
781 * will callback with address == NULL when done
782 * @param infocb_cls closure for infocb
783 * @return ats performance context
785 struct GNUNET_ATS_AddressListHandle*
786 GNUNET_ATS_performance_list_addresses (struct GNUNET_ATS_PerformanceHandle *handle,
787 const struct GNUNET_PeerIdentity *peer,
789 GNUNET_ATS_AddressInformationCallback infocb,
792 struct GNUNET_ATS_AddressListHandle *alh;
793 struct PendingMessage *p;
794 struct AddressListRequestMessage *m;
796 GNUNET_assert (NULL != handle);
800 alh = GNUNET_malloc (sizeof (struct GNUNET_ATS_AddressListHandle));
801 alh->id = handle->id;
804 alh->cb_cls = infocb_cls;
806 alh->all_addresses = all;
808 alh->all_peers = GNUNET_YES;
811 alh->all_peers = GNUNET_NO;
815 GNUNET_CONTAINER_DLL_insert (handle->addresslist_head, handle->addresslist_tail, alh);
817 p = GNUNET_malloc (sizeof (struct PendingMessage) +
818 sizeof (struct AddressListRequestMessage));
819 p->size = sizeof (struct AddressListRequestMessage);
820 m = (struct AddressListRequestMessage *) &p[1];
821 m->header.type = htons (GNUNET_MESSAGE_TYPE_ATS_ADDRESSLIST_REQUEST);
822 m->header.size = htons (sizeof (struct AddressListRequestMessage));
823 m->all = htonl (all);
824 m->id = htonl (alh->id);
829 memset (&m->peer, '\0', sizeof (struct GNUNET_PeerIdentity));
831 GNUNET_CONTAINER_DLL_insert_tail (handle->pending_head, handle->pending_tail, p);
833 do_transmit (handle);
840 * Cancel a pending address listing operation
842 * @param handle the GNUNET_ATS_AddressListHandle handle to cancel
845 GNUNET_ATS_performance_list_addresses_cancel (struct GNUNET_ATS_AddressListHandle *handle)
847 GNUNET_assert (NULL != handle);
849 GNUNET_CONTAINER_DLL_remove (handle->ph->addresslist_head, handle->ph->addresslist_tail, handle);
850 GNUNET_free (handle);
855 * Convert a GNUNET_ATS_PreferenceType to a string
857 * @param type the preference type
858 * @return a string or NULL if invalid
861 GNUNET_ATS_print_preference_type (uint32_t type)
863 char *prefs[GNUNET_ATS_PreferenceCount] = GNUNET_ATS_PreferenceTypeString;
864 if (type < GNUNET_ATS_PreferenceCount)
871 * Change preferences for the given peer. Preference changes are forgotten if peers
874 * @param ph performance handle
875 * @param peer identifies the peer
876 * @param ... 0-terminated specification of the desired changes
879 GNUNET_ATS_performance_change_preference (struct GNUNET_ATS_PerformanceHandle *ph,
880 const struct GNUNET_PeerIdentity *peer, ...)
882 struct PendingMessage *p;
883 struct ChangePreferenceMessage *m;
886 struct PreferenceInformation *pi;
888 enum GNUNET_ATS_PreferenceKind kind;
892 while (GNUNET_ATS_PREFERENCE_END !=
893 (kind = va_arg (ap, enum GNUNET_ATS_PreferenceKind)))
897 case GNUNET_ATS_PREFERENCE_BANDWIDTH:
899 (void) va_arg (ap, double);
902 case GNUNET_ATS_PREFERENCE_LATENCY:
904 (void) va_arg (ap, double);
913 count * sizeof (struct PreferenceInformation) +
914 sizeof (struct ChangePreferenceMessage);
915 p = GNUNET_malloc (sizeof (struct PendingMessage) + msize);
917 p->is_init = GNUNET_NO;
918 m = (struct ChangePreferenceMessage *) &p[1];
919 m->header.type = htons (GNUNET_MESSAGE_TYPE_ATS_PREFERENCE_CHANGE);
920 m->header.size = htons (msize);
921 m->num_preferences = htonl (count);
923 pi = (struct PreferenceInformation *) &m[1];
926 while (GNUNET_ATS_PREFERENCE_END !=
927 (kind = va_arg (ap, enum GNUNET_ATS_PreferenceKind)))
929 pi[count].preference_kind = htonl (kind);
932 case GNUNET_ATS_PREFERENCE_BANDWIDTH:
933 pi[count].preference_value = (float) va_arg (ap, double);
937 case GNUNET_ATS_PREFERENCE_LATENCY:
938 pi[count].preference_value = (float) va_arg (ap, double);
947 GNUNET_CONTAINER_DLL_insert_tail (ph->pending_head, ph->pending_tail, p);
952 * Send feedback to ATS on how good a the requirements for a peer and a
953 * preference is satisfied by ATS
955 * @param ph performance handle
956 * @param scope the time interval this valid for: [now - scope .. now]
957 * @param peer identifies the peer
958 * @param ... 0-terminated specification of the desired changes
961 GNUNET_ATS_performance_give_feedback (struct GNUNET_ATS_PerformanceHandle *ph,
962 const struct GNUNET_PeerIdentity *peer,
963 const struct GNUNET_TIME_Relative scope, ...)
965 struct PendingMessage *p;
966 struct FeedbackPreferenceMessage *m;
969 struct PreferenceInformation *pi;
971 enum GNUNET_ATS_PreferenceKind kind;
974 va_start (ap, scope);
975 while (GNUNET_ATS_PREFERENCE_END !=
976 (kind = va_arg (ap, enum GNUNET_ATS_PreferenceKind)))
980 case GNUNET_ATS_PREFERENCE_BANDWIDTH:
982 (void) va_arg (ap, double);
985 case GNUNET_ATS_PREFERENCE_LATENCY:
987 (void) va_arg (ap, double);
996 count * sizeof (struct PreferenceInformation) +
997 sizeof (struct FeedbackPreferenceMessage);
998 p = GNUNET_malloc (sizeof (struct PendingMessage) + msize);
1000 p->is_init = GNUNET_NO;
1001 m = (struct FeedbackPreferenceMessage *) &p[1];
1002 m->header.type = htons (GNUNET_MESSAGE_TYPE_ATS_PREFERENCE_FEEDBACK);
1003 m->header.size = htons (msize);
1004 m->scope = GNUNET_TIME_relative_hton (scope);
1005 m->num_feedback = htonl (count);
1007 pi = (struct PreferenceInformation *) &m[1];
1009 va_start (ap, scope);
1010 while (GNUNET_ATS_PREFERENCE_END !=
1011 (kind = va_arg (ap, enum GNUNET_ATS_PreferenceKind)))
1013 pi[count].preference_kind = htonl (kind);
1016 case GNUNET_ATS_PREFERENCE_BANDWIDTH:
1017 pi[count].preference_value = (float) va_arg (ap, double);
1021 case GNUNET_ATS_PREFERENCE_LATENCY:
1022 pi[count].preference_value = (float) va_arg (ap, double);
1031 GNUNET_CONTAINER_DLL_insert_tail (ph->pending_head, ph->pending_tail, p);
1035 /* end of ats_api_performance.c */