- changes
[oweals/gnunet.git] / src / ats / ats_api_performance.c
1 /*
2      This file is part of GNUnet.
3      (C) 2010,2011 Christian Grothoff (and other contributing authors)
4
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.
9
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.
14
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.
19 */
20 /**
21  * @file ats/ats_api_performance.c
22  * @brief automatic transport selection and outbound bandwidth determination
23  * @author Christian Grothoff
24  * @author Matthias Wachs
25   */
26 #include "platform.h"
27 #include "gnunet_ats_service.h"
28 #include "ats.h"
29
30
31 /**
32  * Message in linked list we should send to the ATS service.  The
33  * actual binary message follows this struct.
34  */
35 struct PendingMessage
36 {
37
38   /**
39    * Kept in a DLL.
40    */
41   struct PendingMessage *next;
42
43   /**
44    * Kept in a DLL.
45    */
46   struct PendingMessage *prev;
47
48   /**
49    * Size of the message.
50    */
51   size_t size;
52
53   /**
54    * Is this the 'ATS_START' message?
55    */
56   int is_init;
57 };
58
59
60 /**
61  * Linked list of pending reservations.
62  */
63 struct GNUNET_ATS_ReservationContext
64 {
65
66   /**
67    * Kept in a DLL.
68    */
69   struct GNUNET_ATS_ReservationContext *next;
70
71   /**
72    * Kept in a DLL.
73    */
74   struct GNUNET_ATS_ReservationContext *prev;
75
76   /**
77    * Target peer.
78    */
79   struct GNUNET_PeerIdentity peer;
80
81   /**
82    * Desired reservation
83    */
84   int32_t size;
85
86   /**
87    * Function to call on result.
88    */
89   GNUNET_ATS_ReservationCallback rcb;
90
91   /**
92    * Closure for 'rcb'
93    */
94   void *rcb_cls;
95
96   /**
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
102    * required).
103    */
104   int undo;
105 };
106
107
108 /**
109  * Linked list of pending reservations.
110  */
111 struct GNUNET_ATS_AddressListHandle
112 {
113
114   /**
115    * Kept in a DLL.
116    */
117   struct GNUNET_ATS_AddressListHandle *next;
118
119   /**
120    * Kept in a DLL.
121    */
122   struct GNUNET_ATS_AddressListHandle *prev;
123
124   /**
125    * Performance handle
126    */
127   struct GNUNET_ATS_PerformanceHandle *ph;
128
129   /**
130    * Callback
131    */
132   GNUNET_ATS_PeerInformationCallback cb;
133
134   /**
135    * Callback closure
136    */
137   void *cb_cls;
138
139   /**
140    * Target peer.
141    */
142   struct GNUNET_PeerIdentity peer;
143
144   /**
145    * Return all or specific peer only
146    */
147   int all_peers;
148
149   /**
150    * Return all or used address only
151    */
152   int all_addresses;
153 };
154
155 /**
156  * ATS Handle to obtain and/or modify performance information.
157  */
158 struct GNUNET_ATS_PerformanceHandle
159 {
160
161   /**
162    * Our configuration.
163    */
164   const struct GNUNET_CONFIGURATION_Handle *cfg;
165
166   /**
167    * Callback to invoke on performance changes.
168    */
169   GNUNET_ATS_PeerInformationCallback infocb;
170
171   /**
172    * Closure for 'infocb'.
173    */
174   void *infocb_cls;
175
176   /**
177    * Connection to ATS service.
178    */
179   struct GNUNET_CLIENT_Connection *client;
180
181   /**
182    * Head of list of messages for the ATS service.
183    */
184   struct PendingMessage *pending_head;
185
186   /**
187    * Tail of list of messages for the ATS service
188    */
189   struct PendingMessage *pending_tail;
190
191   /**
192    * Head of linked list of pending reservation requests.
193    */
194   struct GNUNET_ATS_ReservationContext *reservation_head;
195
196   /**
197    * Tail of linked list of pending reservation requests.
198    */
199   struct GNUNET_ATS_ReservationContext *reservation_tail;
200
201   /**
202    * Head of linked list of pending address list requests.
203    */
204   struct GNUNET_ATS_AddressListHandle *addresslist_head;
205
206   /**
207    * Tail of linked list of pending address list requests.
208    */
209   struct GNUNET_ATS_AddressListHandle *addresslist_tail;
210
211   /**
212    * Current request for transmission to ATS.
213    */
214   struct GNUNET_CLIENT_TransmitHandle *th;
215
216   /**
217    * Task to trigger reconnect.
218    */
219   GNUNET_SCHEDULER_TaskIdentifier task;
220
221 };
222
223
224 /**
225  * Re-establish the connection to the ATS service.
226  *
227  * @param ph handle to use to re-connect.
228  */
229 static void
230 reconnect (struct GNUNET_ATS_PerformanceHandle *ph);
231
232
233 /**
234  * Re-establish the connection to the ATS service.
235  *
236  * @param cls handle to use to re-connect.
237  * @param tc scheduler context
238  */
239 static void
240 reconnect_task (void *cls, const struct GNUNET_SCHEDULER_TaskContext *tc)
241 {
242   struct GNUNET_ATS_PerformanceHandle *ph = cls;
243
244   ph->task = GNUNET_SCHEDULER_NO_TASK;
245   reconnect (ph);
246 }
247
248
249 /**
250  * Transmit messages from the message queue to the service
251  * (if there are any, and if we are not already trying).
252  *
253  * @param ph handle to use
254  */
255 static void
256 do_transmit (struct GNUNET_ATS_PerformanceHandle *ph);
257
258
259 /**
260  * We can now transmit a message to ATS. Do it.
261  *
262  * @param cls the 'struct GNUNET_ATS_SchedulingHandle'
263  * @param size number of bytes we can transmit to ATS
264  * @param buf where to copy the messages
265  * @return number of bytes copied into buf
266  */
267 static size_t
268 transmit_message_to_ats (void *cls, size_t size, void *buf)
269 {
270   struct GNUNET_ATS_PerformanceHandle *ph = cls;
271   struct PendingMessage *p;
272   size_t ret;
273   char *cbuf;
274
275   ph->th = NULL;
276   ret = 0;
277   cbuf = buf;
278   while ((NULL != (p = ph->pending_head)) && (p->size <= size))
279   {
280     memcpy (&cbuf[ret], &p[1], p->size);
281     ret += p->size;
282     size -= p->size;
283     GNUNET_CONTAINER_DLL_remove (ph->pending_head, ph->pending_tail, p);
284     GNUNET_free (p);
285   }
286   do_transmit (ph);
287   return ret;
288 }
289
290
291 /**
292  * Transmit messages from the message queue to the service
293  * (if there are any, and if we are not already trying).
294  *
295  * @param ph handle to use
296  */
297 static void
298 do_transmit (struct GNUNET_ATS_PerformanceHandle *ph)
299 {
300   struct PendingMessage *p;
301
302   if (NULL != ph->th)
303     return;
304   if (NULL == (p = ph->pending_head))
305     return;
306   if (NULL == ph->client)
307     return;                     /* currently reconnecting */
308   ph->th =
309       GNUNET_CLIENT_notify_transmit_ready (ph->client, p->size,
310                                            GNUNET_TIME_UNIT_FOREVER_REL,
311                                            GNUNET_YES, &transmit_message_to_ats,
312                                            ph);
313 }
314
315
316 /**
317  * We received a peer information message.  Validate and process it.
318  *
319  * @param ph our context with the callback
320  * @param msg the message
321  * @return GNUNET_OK if the message was well-formed
322  */
323 static int
324 process_pi_message (struct GNUNET_ATS_PerformanceHandle *ph,
325                     const struct GNUNET_MessageHeader *msg)
326 {
327   const struct PeerInformationMessage *pi;
328   const struct GNUNET_ATS_Information *atsi;
329   const char *plugin_address;
330   const char *plugin_name;
331   struct GNUNET_HELLO_Address address;
332   uint16_t plugin_address_length;
333   uint16_t plugin_name_length;
334   uint32_t ats_count;
335
336   if (ntohs (msg->size) < sizeof (struct PeerInformationMessage))
337   {
338     GNUNET_break (0);
339     return GNUNET_SYSERR;
340   }
341   pi = (const struct PeerInformationMessage *) msg;
342   ats_count = ntohl (pi->ats_count);
343   plugin_address_length = ntohs (pi->address_length);
344   plugin_name_length = ntohs (pi->plugin_name_length);
345   atsi = (const struct GNUNET_ATS_Information *) &pi[1];
346   plugin_address = (const char *) &atsi[ats_count];
347   plugin_name = &plugin_address[plugin_address_length];
348   if ((plugin_address_length + plugin_name_length +
349        ats_count * sizeof (struct GNUNET_ATS_Information) +
350        sizeof (struct PeerInformationMessage) != ntohs (msg->size)) ||
351       (ats_count >
352        GNUNET_SERVER_MAX_MESSAGE_SIZE / sizeof (struct GNUNET_ATS_Information))
353       || (plugin_name[plugin_name_length - 1] != '\0'))
354   {
355     GNUNET_break (0);
356     return GNUNET_SYSERR;
357   }
358   if (ph->infocb == NULL)
359   {
360     return GNUNET_OK;
361   }
362   address.peer = pi->peer;
363   address.address = plugin_address;
364   address.address_length = plugin_address_length;
365   address.transport_name = plugin_name;
366   ph->infocb (ph->infocb_cls, &address, pi->bandwidth_out, pi->bandwidth_in,
367               atsi, ats_count);
368   return GNUNET_OK;
369 }
370
371
372 /**
373  * We received a reservation result message.  Validate and process it.
374  *
375  * @param ph our context with the callback
376  * @param msg the message
377  * @return GNUNET_OK if the message was well-formed
378  */
379 static int
380 process_rr_message (struct GNUNET_ATS_PerformanceHandle *ph,
381                     const struct GNUNET_MessageHeader *msg)
382 {
383   const struct ReservationResultMessage *rr;
384   struct GNUNET_ATS_ReservationContext *rc;
385   int32_t amount;
386
387   if (ntohs (msg->size) < sizeof (struct ReservationResultMessage))
388   {
389     GNUNET_break (0);
390     return GNUNET_SYSERR;
391   }
392   rr = (const struct ReservationResultMessage *) msg;
393   amount = ntohl (rr->amount);
394   rc = ph->reservation_head;
395   if (0 != memcmp (&rr->peer, &rc->peer, sizeof (struct GNUNET_PeerIdentity)))
396   {
397     GNUNET_break (0);
398     return GNUNET_SYSERR;
399   }
400   GNUNET_CONTAINER_DLL_remove (ph->reservation_head, ph->reservation_tail, rc);
401   if ((amount == 0) || (rc->rcb != NULL))
402   {
403     /* tell client if not cancelled */
404     if (rc->rcb != NULL)
405       rc->rcb (rc->rcb_cls, &rr->peer, amount,
406                GNUNET_TIME_relative_ntoh (rr->res_delay));
407     GNUNET_free (rc);
408     return GNUNET_OK;
409   }
410   /* amount non-zero, but client cancelled, consider undo! */
411   if (GNUNET_YES != rc->undo)
412   {
413     GNUNET_free (rc);
414     return GNUNET_OK;           /* do not try to undo failed undos or negative amounts */
415   }
416   GNUNET_free (rc);
417   (void) GNUNET_ATS_reserve_bandwidth (ph, &rr->peer, -amount, NULL, NULL);
418   return GNUNET_OK;
419 }
420
421
422 /**
423  * Type of a function to call when we receive a message
424  * from the service.
425  *
426  * @param cls the 'struct GNUNET_ATS_SchedulingHandle'
427  * @param msg message received, NULL on timeout or fatal error
428  */
429 static void
430 process_ats_message (void *cls, const struct GNUNET_MessageHeader *msg)
431 {
432   struct GNUNET_ATS_PerformanceHandle *ph = cls;
433
434   if (NULL == msg)
435     goto reconnect;
436   switch (ntohs (msg->type))
437   {
438   case GNUNET_MESSAGE_TYPE_ATS_PEER_INFORMATION:
439     if (GNUNET_OK != process_pi_message (ph, msg))
440       goto reconnect;
441     break;
442   case GNUNET_MESSAGE_TYPE_ATS_RESERVATION_RESULT:
443     if (GNUNET_OK != process_rr_message (ph, msg))
444       goto reconnect;
445     break;
446   default:
447     GNUNET_break (0);
448     goto reconnect;
449   }
450   GNUNET_CLIENT_receive (ph->client, &process_ats_message, ph,
451                          GNUNET_TIME_UNIT_FOREVER_REL);
452   return;
453 reconnect:
454   if (NULL != ph->th)
455   {
456     GNUNET_CLIENT_notify_transmit_ready_cancel (ph->th);
457     ph->th = NULL;
458   }
459   GNUNET_CLIENT_disconnect (ph->client);
460   ph->client = NULL;
461   ph->task =
462       GNUNET_SCHEDULER_add_delayed (GNUNET_TIME_UNIT_SECONDS, &reconnect_task,
463                                     ph);
464 }
465
466
467 /**
468  * Re-establish the connection to the ATS service.
469  *
470  * @param ph handle to use to re-connect.
471  */
472 static void
473 reconnect (struct GNUNET_ATS_PerformanceHandle *ph)
474 {
475   struct PendingMessage *p;
476   struct ClientStartMessage *init;
477
478   GNUNET_assert (NULL == ph->client);
479   ph->client = GNUNET_CLIENT_connect ("ats", ph->cfg);
480   GNUNET_assert (NULL != ph->client);
481   GNUNET_CLIENT_receive (ph->client, &process_ats_message, ph,
482                          GNUNET_TIME_UNIT_FOREVER_REL);
483   if ((NULL == (p = ph->pending_head)) || (GNUNET_YES != p->is_init))
484   {
485     p = GNUNET_malloc (sizeof (struct PendingMessage) +
486                        sizeof (struct ClientStartMessage));
487     p->size = sizeof (struct ClientStartMessage);
488     p->is_init = GNUNET_YES;
489     init = (struct ClientStartMessage *) &p[1];
490     init->header.type = htons (GNUNET_MESSAGE_TYPE_ATS_START);
491     init->header.size = htons (sizeof (struct ClientStartMessage));
492     init->start_flag =
493         htonl ((ph->infocb ==
494                 NULL) ? START_FLAG_PERFORMANCE_NO_PIC :
495                START_FLAG_PERFORMANCE_WITH_PIC);
496     GNUNET_CONTAINER_DLL_insert (ph->pending_head, ph->pending_tail, p);
497   }
498   do_transmit (ph);
499 }
500
501
502
503 /**
504  * Get handle to access performance API of the ATS subsystem.
505  *
506  * @param cfg configuration to use
507  * @param infocb function to call on allocation changes, can be NULL
508  * @param infocb_cls closure for infocb
509  * @return ats performance context
510  */
511 struct GNUNET_ATS_PerformanceHandle *
512 GNUNET_ATS_performance_init (const struct GNUNET_CONFIGURATION_Handle *cfg,
513                              GNUNET_ATS_PeerInformationCallback infocb,
514                              void *infocb_cls)
515 {
516   struct GNUNET_ATS_PerformanceHandle *ph;
517
518   ph = GNUNET_malloc (sizeof (struct GNUNET_ATS_PerformanceHandle));
519   ph->cfg = cfg;
520   ph->infocb = infocb;
521   ph->infocb_cls = infocb_cls;
522   reconnect (ph);
523   return ph;
524 }
525
526
527 /**
528  * Client is done using the ATS performance subsystem, release resources.
529  *
530  * @param ph handle
531  */
532 void
533 GNUNET_ATS_performance_done (struct GNUNET_ATS_PerformanceHandle *ph)
534 {
535   struct PendingMessage *p;
536   struct GNUNET_ATS_ReservationContext *rc;
537   struct GNUNET_ATS_AddressListHandle *alh;
538
539   while (NULL != (p = ph->pending_head))
540   {
541     GNUNET_CONTAINER_DLL_remove (ph->pending_head, ph->pending_tail, p);
542     GNUNET_free (p);
543   }
544   while (NULL != (alh = ph->addresslist_head))
545   {
546     GNUNET_CONTAINER_DLL_remove (ph->addresslist_head, ph->addresslist_tail,
547                                  alh);
548     GNUNET_free (alh);
549   }
550   while (NULL != (rc = ph->reservation_head))
551   {
552     GNUNET_CONTAINER_DLL_remove (ph->reservation_head, ph->reservation_tail,
553                                  rc);
554     GNUNET_break (NULL == rc->rcb);
555     GNUNET_free (rc);
556   }
557   if (GNUNET_SCHEDULER_NO_TASK != ph->task)
558   {
559     GNUNET_SCHEDULER_cancel (ph->task);
560     ph->task = GNUNET_SCHEDULER_NO_TASK;
561   }
562   if (NULL != ph->client)
563   {
564     GNUNET_CLIENT_disconnect (ph->client);
565     ph->client = NULL;
566   }
567   GNUNET_free (ph);
568 }
569
570
571 /**
572  * Reserve inbound bandwidth from the given peer.  ATS will look at
573  * the current amount of traffic we receive from the peer and ensure
574  * that the peer could add 'amount' of data to its stream.
575  *
576  * @param ph performance handle
577  * @param peer identifies the peer
578  * @param amount reserve N bytes for receiving, negative
579  *                amounts can be used to undo a (recent) reservation;
580  * @param rcb function to call with the resulting reservation information
581  * @param rcb_cls closure for info
582  * @return NULL on error
583  * @deprecated will be replaced soon
584  */
585 struct GNUNET_ATS_ReservationContext *
586 GNUNET_ATS_reserve_bandwidth (struct GNUNET_ATS_PerformanceHandle *ph,
587                               const struct GNUNET_PeerIdentity *peer,
588                               int32_t amount,
589                               GNUNET_ATS_ReservationCallback rcb, void *rcb_cls)
590 {
591   struct GNUNET_ATS_ReservationContext *rc;
592   struct PendingMessage *p;
593   struct ReservationRequestMessage *m;
594
595   rc = GNUNET_malloc (sizeof (struct GNUNET_ATS_ReservationContext));
596   rc->size = amount;
597   rc->peer = *peer;
598   rc->rcb = rcb;
599   rc->rcb_cls = rcb_cls;
600   if ((rcb != NULL) && (amount > 0))
601     rc->undo = GNUNET_YES;
602   GNUNET_CONTAINER_DLL_insert_tail (ph->reservation_head, ph->reservation_tail,
603                                     rc);
604
605   p = GNUNET_malloc (sizeof (struct PendingMessage) +
606                      sizeof (struct ReservationRequestMessage));
607   p->size = sizeof (struct ReservationRequestMessage);
608   p->is_init = GNUNET_NO;
609   m = (struct ReservationRequestMessage *) &p[1];
610   m->header.type = htons (GNUNET_MESSAGE_TYPE_ATS_RESERVATION_REQUEST);
611   m->header.size = htons (sizeof (struct ReservationRequestMessage));
612   m->amount = htonl (amount);
613   m->peer = *peer;
614   GNUNET_CONTAINER_DLL_insert_tail (ph->pending_head, ph->pending_tail, p);
615   do_transmit (ph);
616   return rc;
617 }
618
619
620 /**
621  * Cancel request for reserving bandwidth.
622  *
623  * @param rc context returned by the original GNUNET_ATS_reserve_bandwidth call
624  */
625 void
626 GNUNET_ATS_reserve_bandwidth_cancel (struct GNUNET_ATS_ReservationContext *rc)
627 {
628   rc->rcb = NULL;
629 }
630
631 /**
632  * Get information about addresses known to the ATS subsystem.
633  *
634  * @param cfg configuration to use
635  * @param peer peer idm can be NULL for all peers
636  * @param all GNUNET_YES to get information about all addresses or GNUNET_NO to
637  *        get only address currently used
638  * @param infocb callback to call with the addresses,
639  *        will callback with address == NULL when done
640  * @param infocb_cls closure for infocb
641  * @return ats performance context
642  */
643 struct GNUNET_ATS_AddressListHandle*
644 GNUNET_ATS_performance_list_addresses (struct GNUNET_ATS_PerformanceHandle *handle,
645                                        const struct GNUNET_PeerIdentity *peer,
646                                        int all,
647                                        GNUNET_ATS_PeerInformationCallback infocb,
648                                        void *infocb_cls)
649 {
650   struct GNUNET_ATS_AddressListHandle *alh;
651
652   GNUNET_assert (NULL != handle);
653
654   alh = GNUNET_malloc (sizeof (struct GNUNET_ATS_AddressListHandle));
655   alh->cb = infocb;
656   alh->cb_cls = infocb_cls;
657   alh->ph = handle;
658   alh->all_addresses = all;
659   if (NULL == peer)
660     alh->all_peers = GNUNET_YES;
661   else
662   {
663       alh->all_peers = GNUNET_NO;
664       alh->peer = (*peer);
665   }
666
667   GNUNET_CONTAINER_DLL_insert (handle->addresslist_head, handle->addresslist_tail, alh);
668
669   /* TODO */
670   FPRINTF (stderr, "TBD");
671
672   return alh;
673 }
674
675
676 /**
677  * Cancel a pending address listing operation
678  *
679  * @param handle the GNUNET_ATS_AddressListHandle handle to cancel
680  */
681 void
682 GNUNET_ATS_performance_list_addresses_cancel (struct GNUNET_ATS_AddressListHandle *handle)
683 {
684   GNUNET_assert (NULL != handle);
685
686   GNUNET_CONTAINER_DLL_remove (handle->ph->addresslist_head, handle->ph->addresslist_tail, handle);
687   GNUNET_free (handle);
688 }
689
690
691 /**
692  * Change preferences for the given peer. Preference changes are forgotten if peers
693  * disconnect.
694  *
695  * @param ph performance handle
696  * @param peer identifies the peer
697  * @param ... 0-terminated specification of the desired changes
698  */
699 void
700 GNUNET_ATS_change_preference (struct GNUNET_ATS_PerformanceHandle *ph,
701                               const struct GNUNET_PeerIdentity *peer, ...)
702 {
703   struct PendingMessage *p;
704   struct ChangePreferenceMessage *m;
705   size_t msize;
706   uint32_t count;
707   struct PreferenceInformation *pi;
708   va_list ap;
709   enum GNUNET_ATS_PreferenceKind kind;
710
711   count = 0;
712   va_start (ap, peer);
713   while (GNUNET_ATS_PREFERENCE_END !=
714          (kind = va_arg (ap, enum GNUNET_ATS_PreferenceKind)))
715   {
716     switch (kind)
717     {
718     case GNUNET_ATS_PREFERENCE_BANDWIDTH:
719       count++;
720       (void) va_arg (ap, double);
721
722       break;
723     case GNUNET_ATS_PREFERENCE_LATENCY:
724       count++;
725       (void) va_arg (ap, double);
726
727       break;
728     default:
729       GNUNET_assert (0);
730     }
731   }
732   va_end (ap);
733   msize =
734       count * sizeof (struct PreferenceInformation) +
735       sizeof (struct ChangePreferenceMessage);
736   p = GNUNET_malloc (sizeof (struct PendingMessage) + msize);
737   p->size = msize;
738   p->is_init = GNUNET_NO;
739   m = (struct ChangePreferenceMessage *) &p[1];
740   m->header.type = htons (GNUNET_MESSAGE_TYPE_ATS_PREFERENCE_CHANGE);
741   m->header.size = htons (msize);
742   m->num_preferences = htonl (count);
743   m->peer = *peer;
744   pi = (struct PreferenceInformation *) &m[1];
745   count = 0;
746   va_start (ap, peer);
747   while (GNUNET_ATS_PREFERENCE_END !=
748          (kind = va_arg (ap, enum GNUNET_ATS_PreferenceKind)))
749   {
750     pi[count].preference_kind = htonl (kind);
751     switch (kind)
752     {
753     case GNUNET_ATS_PREFERENCE_BANDWIDTH:
754       pi[count].preference_value = (float) va_arg (ap, double);
755
756       count++;
757       break;
758     case GNUNET_ATS_PREFERENCE_LATENCY:
759       pi[count].preference_value = (float) va_arg (ap, double);
760
761       count++;
762       break;
763     default:
764       GNUNET_assert (0);
765     }
766   }
767   va_end (ap);
768   GNUNET_CONTAINER_DLL_insert_tail (ph->pending_head, ph->pending_tail, p);
769   do_transmit (ph);
770 }
771
772 /* end of ats_api_performance.c */