GNUnet  0.20.0
ats_api_performance.c
Go to the documentation of this file.
1 /*
2  This file is part of GNUnet.
3  Copyright (C) 2010, 2011, 2016 GNUnet e.V.
4 
5  GNUnet is free software: you can redistribute it and/or modify it
6  under the terms of the GNU Affero General Public License as published
7  by the Free Software Foundation, either version 3 of the License,
8  or (at your 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  Affero General Public License for more details.
14 
15  You should have received a copy of the GNU Affero General Public License
16  along with this program. If not, see <http://www.gnu.org/licenses/>.
17 
18  SPDX-License-Identifier: AGPL3.0-or-later
19  */
26 #include "platform.h"
27 #include "gnunet_ats_service.h"
28 #include "ats.h"
29 
30 
31 #define LOG(kind, ...) GNUNET_log_from (kind, "ats-performance-api", \
32  __VA_ARGS__)
33 
34 
39 {
44 
49 
54 
58  int32_t size;
59 
64 
68  void *rcb_cls;
69 
78  int undo;
79 };
80 
81 
86 {
91 
96 
101 
106 
110  void *cb_cls;
111 
115  struct GNUNET_PeerIdentity peer;
116 
121 
126 
130  uint32_t id;
131 };
132 
133 
138 {
143 
148 
153 
158 
163 
168 
173 
178 
182  struct GNUNET_CLIENT_TransmitHandle *th;
183 
188 
193 
197  uint32_t monitor_id;
198 
202  uint32_t id;
203 
208 };
209 
215 static void
217 
218 
224 static void
225 reconnect_task (void *cls)
226 {
227  struct GNUNET_ATS_PerformanceHandle *ph = cls;
228 
229  ph->task = NULL;
230  reconnect (ph);
231 }
232 
233 
239 static void
241 {
244  struct GNUNET_BANDWIDTH_Value32NBO bandwidth_zero;
245 
246  if (NULL != ph->mq)
247  {
249  ph->mq = NULL;
250  }
251  while (NULL != (rc = ph->reservation_head))
252  {
255  rc);
256  if (NULL != rc->rcb)
257  rc->rcb (rc->rcb_cls,
258  NULL,
259  0,
261  GNUNET_free (rc);
262  }
263  bandwidth_zero.value__ = htonl (0);
264  while (NULL != (alh = ph->addresslist_head))
265  {
268  alh);
269  if (NULL != alh->cb)
270  alh->cb (alh->cb_cls,
271  NULL,
272  GNUNET_NO,
273  bandwidth_zero,
274  bandwidth_zero,
275  NULL);
276  GNUNET_free (alh);
277  }
278  if (NULL != ph->addr_info_cb)
279  {
280  /* Indicate reconnect */
282  NULL,
283  GNUNET_NO,
284  bandwidth_zero,
285  bandwidth_zero,
286  NULL);
287  }
291  ph);
292 }
293 
294 
302 static int
304  const struct PeerInformationMessage *pi)
305 {
306  const char *plugin_address;
307  const char *plugin_name;
308  uint16_t plugin_address_length;
309  uint16_t plugin_name_length;
310 
311  plugin_address_length = ntohs (pi->address_length);
312  plugin_name_length = ntohs (pi->plugin_name_length);
313  plugin_address = (const char *) &pi[1];
314  plugin_name = &plugin_address[plugin_address_length];
315  if ((plugin_address_length + plugin_name_length
316  + sizeof(struct PeerInformationMessage) != ntohs (pi->header.size)) ||
317  (plugin_name[plugin_name_length - 1] != '\0'))
318  {
319  GNUNET_break (0);
320  return GNUNET_SYSERR;
321  }
322  return GNUNET_OK;
323 }
324 
325 
333 static void
335  const struct PeerInformationMessage *pi)
336 {
337  struct GNUNET_ATS_PerformanceHandle *ph = cls;
338  const char *plugin_address;
339  const char *plugin_name;
341  uint16_t plugin_address_length;
342  int addr_active;
343  struct GNUNET_ATS_Properties prop;
344 
345  if (NULL == ph->addr_info_cb)
346  return;
347  plugin_address_length = ntohs (pi->address_length);
348  addr_active = (int) ntohl (pi->address_active);
349  plugin_address = (const char *) &pi[1];
350  plugin_name = &plugin_address[plugin_address_length];
351 
353  &pi->properties);
354  address.peer = pi->peer;
355  address.local_info = (enum GNUNET_HELLO_AddressInfo) ntohl (
356  pi->address_local_info);
357  address.address = plugin_address;
358  address.address_length = plugin_address_length;
359  address.transport_name = plugin_name;
361  &address,
362  addr_active,
363  pi->bandwidth_out,
364  pi->bandwidth_in,
365  &prop);
366 }
367 
368 
375 static void
377  const struct ReservationResultMessage *rr)
378 {
379  struct GNUNET_ATS_PerformanceHandle *ph = cls;
381  int32_t amount;
382 
383  amount = ntohl (rr->amount);
384  rc = ph->reservation_head;
385  if (0 != GNUNET_memcmp (&rr->peer,
386  &rc->peer))
387  {
388  GNUNET_break (0);
389  reconnect (ph);
390  return;
391  }
394  rc);
395  if ((0 == amount) ||
396  (NULL != rc->rcb))
397  {
398  /* tell client if not cancelled */
399  if (NULL != rc->rcb)
400  rc->rcb (rc->rcb_cls,
401  &rr->peer,
402  amount,
404  GNUNET_free (rc);
405  return;
406  }
407  /* amount non-zero, but client cancelled, consider undo! */
408  if (GNUNET_YES != rc->undo)
409  {
410  GNUNET_free (rc);
411  return; /* do not try to undo failed undos or negative amounts */
412  }
413  GNUNET_free (rc);
415  &rr->peer,
416  -amount,
417  NULL, NULL);
418 }
419 
420 
428 static int
430  const struct PeerInformationMessage *pi)
431 {
432  const char *plugin_address;
433  const char *plugin_name;
434  uint16_t plugin_address_length;
435  uint16_t plugin_name_length;
436 
437  plugin_address_length = ntohs (pi->address_length);
438  plugin_name_length = ntohs (pi->plugin_name_length);
439  plugin_address = (const char *) &pi[1];
440  plugin_name = &plugin_address[plugin_address_length];
441  if ((plugin_address_length + plugin_name_length
442  + sizeof(struct PeerInformationMessage) != ntohs (pi->header.size)) ||
443  (plugin_name[plugin_name_length - 1] != '\0'))
444  {
445  GNUNET_break (0);
446  return GNUNET_SYSERR;
447  }
448  return GNUNET_OK;
449 }
450 
451 
459 static void
461  const struct PeerInformationMessage *pi)
462 {
463  struct GNUNET_ATS_PerformanceHandle *ph = cls;
466  const char *plugin_address;
467  const char *plugin_name;
469  struct GNUNET_PeerIdentity allzeros;
470  struct GNUNET_BANDWIDTH_Value32NBO bandwidth_zero;
471  struct GNUNET_ATS_Properties prop;
472  uint16_t plugin_address_length;
473  uint16_t plugin_name_length;
474  uint32_t active;
475  uint32_t id;
476 
477  id = ntohl (pi->id);
478  active = ntohl (pi->address_active);
479  plugin_address_length = ntohs (pi->address_length);
480  plugin_name_length = ntohs (pi->plugin_name_length);
481  plugin_address = (const char *) &pi[1];
482  plugin_name = &plugin_address[plugin_address_length];
484  "Received ATS_ADDRESSLIST_RESPONSE message for peer %s and plugin %s\n",
485  GNUNET_i2s (&pi->peer),
486  plugin_name);
487 
488  next = ph->addresslist_head;
489  while (NULL != (alh = next))
490  {
491  next = alh->next;
492  if (alh->id == id)
493  break;
494  }
495  if (NULL == alh)
496  return; /* was canceled */
497 
498  memset (&allzeros, '\0', sizeof(allzeros));
499  if ((GNUNET_YES == GNUNET_is_zero (&pi->peer)) &&
500  (0 == plugin_name_length) &&
501  (0 == plugin_address_length))
502  {
503  /* Done */
505  "Received last message for ATS_ADDRESSLIST_RESPONSE\n");
506  bandwidth_zero.value__ = htonl (0);
509  alh);
510  if (NULL != alh->cb)
511  alh->cb (alh->cb_cls,
512  NULL,
513  GNUNET_NO,
514  bandwidth_zero,
515  bandwidth_zero,
516  NULL);
517  GNUNET_free (alh);
518  return;
519  }
520 
521  address.peer = pi->peer;
522  address.address = plugin_address;
523  address.address_length = plugin_address_length;
524  address.transport_name = plugin_name;
525  if (((GNUNET_YES == alh->all_addresses) ||
526  (GNUNET_YES == active)) &&
527  (NULL != alh->cb))
528  {
530  &pi->properties);
531  alh->cb (alh->cb_cls,
532  &address,
533  active,
534  pi->bandwidth_out,
535  pi->bandwidth_in,
536  &prop);
537  }
538 }
539 
540 
549 static void
550 mq_error_handler (void *cls,
551  enum GNUNET_MQ_Error error)
552 {
553  struct GNUNET_ATS_PerformanceHandle *ph = cls;
554 
555  do_reconnect (ph);
556 }
557 
558 
564 static void
566 {
568  GNUNET_MQ_hd_var_size (peer_information,
570  struct PeerInformationMessage,
571  ph),
572  GNUNET_MQ_hd_fixed_size (reservation_result,
575  ph),
576  GNUNET_MQ_hd_var_size (address_list,
578  struct PeerInformationMessage,
579  ph),
581  };
582  struct GNUNET_MQ_Envelope *env;
583  struct ClientStartMessage *init;
584 
585  GNUNET_assert (NULL == ph->mq);
587  "ats",
588  handlers,
590  ph);
591  if (NULL == ph->mq)
592  return;
595  init->start_flag = htonl ((NULL == ph->addr_info_cb)
598  GNUNET_MQ_send (ph->mq,
599  env);
600 }
601 
602 
615  void *addr_info_cb_cls)
616 {
618 
620  ph->cfg = cfg;
623  reconnect (ph);
624  if (NULL == ph->mq)
625  {
626  GNUNET_free (ph);
627  return NULL;
628  }
629  return ph;
630 }
631 
632 
638 void
640 {
643 
644  while (NULL != (alh = ph->addresslist_head))
645  {
648  alh);
649  GNUNET_free (alh);
650  }
651  while (NULL != (rc = ph->reservation_head))
652  {
655  rc);
656  GNUNET_break (NULL == rc->rcb);
657  GNUNET_free (rc);
658  }
659  if (NULL != ph->task)
660  {
662  ph->task = NULL;
663  }
664  if (NULL != ph->mq)
665  {
667  ph->mq = NULL;
668  }
669  GNUNET_free (ph);
670 }
671 
672 
675  const struct GNUNET_PeerIdentity *peer,
676  int32_t amount,
678  void *rcb_cls)
679 {
681  struct GNUNET_MQ_Envelope *env;
683 
684  if (NULL == ph->mq)
685  return NULL;
687  rc->size = amount;
688  rc->peer = *peer;
689  rc->rcb = rcb;
690  rc->rcb_cls = rcb_cls;
691  if ((NULL != rcb) &&
692  (amount > 0))
693  rc->undo = GNUNET_YES;
696  rc);
697  env = GNUNET_MQ_msg (m,
699  m->amount = htonl (amount);
700  m->peer = *peer;
701  GNUNET_MQ_send (ph->mq,
702  env);
703  return rc;
704 }
705 
706 
707 void
709 {
710  rc->rcb = NULL;
711 }
712 
713 
716  const struct GNUNET_PeerIdentity *peer,
717  int all,
719  infocb,
720  void *infocb_cls)
721 {
723  struct GNUNET_MQ_Envelope *env;
725 
726  if (NULL == ph->mq)
727  return NULL;
728  if (NULL == infocb)
729  {
730  GNUNET_break (0);
731  return NULL;
732  }
734  alh->id = ph->id++;
735  alh->cb = infocb;
736  alh->cb_cls = infocb_cls;
737  alh->ph = ph;
738  alh->all_addresses = all;
739  if (NULL == peer)
740  {
742  }
743  else
744  {
746  alh->peer = *peer;
747  }
750  alh);
751  env = GNUNET_MQ_msg (m,
753  m->all = htonl (all);
754  m->id = htonl (alh->id);
755  if (NULL != peer)
756  m->peer = *peer;
757  GNUNET_MQ_send (ph->mq,
758  env);
759  return alh;
760 }
761 
762 
763 void
766 {
768 
771  alh);
772  GNUNET_free (alh);
773 }
774 
775 
776 const char *
778 {
779  const char *prefs[] = GNUNET_ATS_PreferenceTypeString;
780 
782  return prefs[type];
783  return NULL;
784 }
785 
786 
787 void
790  const struct
792  ...)
793 {
794  struct GNUNET_MQ_Envelope *env;
795  struct ChangePreferenceMessage *m;
796  uint32_t count;
797  struct PreferenceInformation *pi;
798  va_list ap;
799  enum GNUNET_ATS_PreferenceKind kind;
800 
801  if (NULL == ph->mq)
802  return;
803  count = 0;
804  va_start (ap, peer);
805  while (GNUNET_ATS_PREFERENCE_END !=
807  {
808  switch (kind)
809  {
811  count++;
812  (void) va_arg (ap, double);
813  break;
814 
816  count++;
817  (void) va_arg (ap, double);
818  break;
819 
820  default:
821  GNUNET_assert (0);
822  }
823  }
824  va_end (ap);
826  count * sizeof(struct PreferenceInformation),
828  m->num_preferences = htonl (count);
829  m->peer = *peer;
830  pi = (struct PreferenceInformation *) &m[1];
831  count = 0;
832  va_start (ap, peer);
833  while (GNUNET_ATS_PREFERENCE_END != (kind =
834  GNUNET_VA_ARG_ENUM (ap,
836  {
837  pi[count].preference_kind = htonl (kind);
838  switch (kind)
839  {
841  pi[count].preference_value = (float) va_arg (ap, double);
842 
843  count++;
844  break;
845 
847  pi[count].preference_value = (float) va_arg (ap, double);
848 
849  count++;
850  break;
851 
852  default:
853  GNUNET_assert (0);
854  }
855  }
856  va_end (ap);
857  GNUNET_MQ_send (ph->mq,
858  env);
859 }
860 
861 
871 void
873  const struct GNUNET_PeerIdentity *peer,
874  const struct GNUNET_TIME_Relative scope,
875  ...)
876 {
877  struct GNUNET_MQ_Envelope *env;
879  uint32_t count;
880  struct PreferenceInformation *pi;
881  va_list ap;
882  enum GNUNET_ATS_PreferenceKind kind;
883 
884  if (NULL == ph->mq)
885  return;
886  count = 0;
887  va_start (ap, scope);
888  while (GNUNET_ATS_PREFERENCE_END !=
890  {
891  switch (kind)
892  {
894  count++;
895  (void) va_arg (ap, double);
896  break;
897 
899  count++;
900  (void) va_arg (ap, double);
901  break;
902 
903  default:
904  GNUNET_assert (0);
905  }
906  }
907  va_end (ap);
909  count * sizeof(struct PreferenceInformation),
911  m->scope = GNUNET_TIME_relative_hton (scope);
912  m->num_feedback = htonl (count);
913  m->peer = *peer;
914  pi = (struct PreferenceInformation *) &m[1];
915  count = 0;
916  va_start (ap, scope);
917  while (GNUNET_ATS_PREFERENCE_END != (kind =
918  GNUNET_VA_ARG_ENUM (ap,
920  {
921  pi[count].preference_kind = htonl (kind);
922  switch (kind)
923  {
925  pi[count].preference_value = (float) va_arg (ap, double);
926 
927  count++;
928  break;
929 
931  pi[count].preference_value = (float) va_arg (ap, double);
932 
933  count++;
934  break;
935 
936  default:
937  GNUNET_assert (0);
938  }
939  }
940  va_end (ap);
941  GNUNET_MQ_send (ph->mq,
942  env);
943 }
944 
945 
946 /* end of ats_api_performance.c */
struct GNUNET_MQ_Envelope * env
Definition: 005.c:1
automatic transport selection messages
@ START_FLAG_PERFORMANCE_NO_PIC
Performance monitoring client that does NOT want to learn about changes in performance characteristic...
Definition: ats.h:54
@ START_FLAG_PERFORMANCE_WITH_PIC
Performance monitoring client that wants to learn about changes in performance characteristics.
Definition: ats.h:48
static void reconnect(struct GNUNET_ATS_PerformanceHandle *ph)
Re-establish the connection to the ATS service.
static void handle_peer_information(void *cls, const struct PeerInformationMessage *pi)
We received a peer information message.
static void do_reconnect(struct GNUNET_ATS_PerformanceHandle *ph)
Reconnect to the ATS service, something went wrong.
static void handle_reservation_result(void *cls, const struct ReservationResultMessage *rr)
We received a reservation result message.
static void mq_error_handler(void *cls, enum GNUNET_MQ_Error error)
Generic error handler, called with the appropriate error code and the same closure specified at the c...
static int check_peer_information(void *cls, const struct PeerInformationMessage *pi)
We received a peer information message.
static int check_address_list(void *cls, const struct PeerInformationMessage *pi)
We received a PeerInformationMessage.
#define LOG(kind,...)
static void handle_address_list(void *cls, const struct PeerInformationMessage *pi)
We received a GNUNET_MESSAGE_TYPE_ATS_ADDRESSLIST_RESPONSE.
static void reconnect_task(void *cls)
Re-establish the connection to the ATS service.
static const struct GNUNET_CONFIGURATION_Handle * cfg
Configuration we are using.
Definition: gnunet-abd.c:36
static struct GNUNET_ARM_MonitorHandle * m
Monitor connection with ARM.
Definition: gnunet-arm.c:104
static char * init
Set to the name of a service to start.
Definition: gnunet-arm.c:74
static struct GNUNET_ATS_PerformanceHandle * ph
ATS performance handle used.
Definition: gnunet-ats.c:116
static struct GNUNET_ATS_AddressListHandle * alh
ATS address list handle used.
Definition: gnunet-ats.c:131
static struct GNUNET_CADET_MessageHandler handlers[]
Handlers, for diverse services.
static char * address
GNS address for this phone.
static struct GNUNET_IDENTITY_Handle * id
Handle to identity service.
static struct GNUNET_PEERINFO_Handle * pi
Handle to peerinfo service.
static void addr_info_cb(void *cls, const struct GNUNET_HELLO_Address *address, int address_active, struct GNUNET_BANDWIDTH_Value32NBO bandwidth_out, struct GNUNET_BANDWIDTH_Value32NBO bandwidth_in, const struct GNUNET_ATS_Properties *prop)
Signature of a function that is called with QoS information about an address.
static char * plugin_name
Name of our plugin.
Automatic transport selection and outbound bandwidth determination.
struct GNUNET_ATS_PerformanceHandle * GNUNET_ATS_performance_init(const struct GNUNET_CONFIGURATION_Handle *cfg, GNUNET_ATS_AddressInformationCallback addr_info_cb, void *addr_info_cb_cls)
Get handle to access performance API of the ATS subsystem.
void GNUNET_ATS_performance_list_addresses_cancel(struct GNUNET_ATS_AddressListHandle *alh)
Cancel a pending address listing operation.
void GNUNET_ATS_performance_done(struct GNUNET_ATS_PerformanceHandle *ph)
Client is done using the ATS performance subsystem, release resources.
void GNUNET_ATS_properties_ntoh(struct GNUNET_ATS_Properties *hbo, const struct GNUNET_ATS_PropertiesNBO *nbo)
Convert ATS properties from network to host byte order.
void GNUNET_ATS_performance_give_feedback(struct GNUNET_ATS_PerformanceHandle *ph, const struct GNUNET_PeerIdentity *peer, const struct GNUNET_TIME_Relative scope,...)
Send feedback to ATS on how good a the requirements for a peer and a preference is satisfied by ATS.
void GNUNET_ATS_reserve_bandwidth_cancel(struct GNUNET_ATS_ReservationContext *rc)
Cancel request for reserving bandwidth.
void GNUNET_ATS_performance_change_preference(struct GNUNET_ATS_PerformanceHandle *ph, const struct GNUNET_PeerIdentity *peer,...)
Change preferences for the given peer.
const char * GNUNET_ATS_print_preference_type(enum GNUNET_ATS_PreferenceKind type)
Convert an enum GNUNET_ATS_PreferenceType to a string.
struct GNUNET_ATS_ReservationContext * GNUNET_ATS_reserve_bandwidth(struct GNUNET_ATS_PerformanceHandle *ph, const struct GNUNET_PeerIdentity *peer, int32_t amount, GNUNET_ATS_ReservationCallback rcb, void *rcb_cls)
Reserve inbound bandwidth from the given peer.
struct GNUNET_ATS_AddressListHandle * GNUNET_ATS_performance_list_addresses(struct GNUNET_ATS_PerformanceHandle *ph, const struct GNUNET_PeerIdentity *peer, int all, GNUNET_ATS_AddressInformationCallback infocb, void *infocb_cls)
Get information about addresses known to the ATS subsystem.
void(* GNUNET_ATS_AddressInformationCallback)(void *cls, const struct GNUNET_HELLO_Address *address, int address_active, struct GNUNET_BANDWIDTH_Value32NBO bandwidth_out, struct GNUNET_BANDWIDTH_Value32NBO bandwidth_in, const struct GNUNET_ATS_Properties *prop)
Signature of a function that is called with QoS information about an address.
void(* GNUNET_ATS_ReservationCallback)(void *cls, const struct GNUNET_PeerIdentity *peer, int32_t amount, struct GNUNET_TIME_Relative res_delay)
Function called with reservation result.
GNUNET_ATS_PreferenceKind
Enum defining all known preference categories.
#define GNUNET_ATS_PreferenceTypeString
ATS preference types as string array initializer.
@ GNUNET_ATS_PREFERENCE_BANDWIDTH
Change the peer's bandwidth value (value per byte of bandwidth in the goal function) to the given amo...
@ GNUNET_ATS_PREFERENCE_LATENCY
Change the peer's latency value to the given amount.
@ GNUNET_ATS_PREFERENCE_END
End of preference list.
struct GNUNET_MQ_Handle * GNUNET_CLIENT_connect(const struct GNUNET_CONFIGURATION_Handle *cfg, const char *service_name, const struct GNUNET_MQ_MessageHandler *handlers, GNUNET_MQ_ErrorHandler error_handler, void *error_handler_cls)
Create a message queue to connect to a GNUnet service.
Definition: client.c:1057
#define GNUNET_CONTAINER_DLL_remove(head, tail, element)
Remove an element from a DLL.
#define GNUNET_CONTAINER_DLL_insert_tail(head, tail, element)
Insert an element at the tail of a DLL.
#define GNUNET_CONTAINER_DLL_insert(head, tail, element)
Insert an element at the head of a DLL.
GNUNET_HELLO_AddressInfo
Additional local information about an address.
#define GNUNET_is_zero(a)
Check that memory in a is all zeros.
#define GNUNET_VA_ARG_ENUM(va, X)
wrap va_arg for enums
#define GNUNET_memcmp(a, b)
Compare memory in a and b, where both must be of the same pointer type.
@ GNUNET_OK
@ GNUNET_YES
@ GNUNET_NO
@ GNUNET_SYSERR
const char * GNUNET_i2s(const struct GNUNET_PeerIdentity *pid)
Convert a peer identity to a string (for printing debug messages).
#define GNUNET_assert(cond)
Use this for fatal errors that cannot be handled.
#define GNUNET_break(cond)
Use this for internal assertion violations that are not fatal (can be handled) but should not occur.
@ GNUNET_ERROR_TYPE_DEBUG
#define GNUNET_new(type)
Allocate a struct or union of the given type.
#define GNUNET_free(ptr)
Wrapper around free.
GNUNET_MQ_Error
Error codes for the queue.
void GNUNET_MQ_send(struct GNUNET_MQ_Handle *mq, struct GNUNET_MQ_Envelope *ev)
Send a message with the given message queue.
Definition: mq.c:304
#define GNUNET_MQ_handler_end()
End-marker for the handlers array.
#define GNUNET_MQ_msg_extra(mvar, esize, type)
Allocate an envelope, with extra space allocated after the space needed by the message struct.
Definition: gnunet_mq_lib.h:63
#define GNUNET_MQ_msg(mvar, type)
Allocate a GNUNET_MQ_Envelope.
Definition: gnunet_mq_lib.h:78
#define GNUNET_MQ_hd_var_size(name, code, str, ctx)
#define GNUNET_MQ_hd_fixed_size(name, code, str, ctx)
void GNUNET_MQ_destroy(struct GNUNET_MQ_Handle *mq)
Destroy the message queue.
Definition: mq.c:683
#define GNUNET_MESSAGE_TYPE_ATS_PREFERENCE_FEEDBACK
Type of the 'struct ChangePreferenceMessage' sent by clients to ATS to ask for allocation preference ...
#define GNUNET_MESSAGE_TYPE_ATS_ADDRESSLIST_REQUEST
Type of the 'struct AddressListRequestMessage' sent by client to ATS to request information about add...
#define GNUNET_MESSAGE_TYPE_ATS_START
Type of the 'struct ClientStartMessage' sent by clients to ATS to identify the type of the client.
#define GNUNET_MESSAGE_TYPE_ATS_RESERVATION_RESULT
Type of the 'struct ReservationResultMessage' sent by ATS to clients in response to a reservation req...
#define GNUNET_MESSAGE_TYPE_ATS_PEER_INFORMATION
Type of the 'struct PeerInformationMessage' sent by ATS to clients to inform about QoS for a particul...
#define GNUNET_MESSAGE_TYPE_ATS_ADDRESSLIST_RESPONSE
Type of the 'struct AddressListResponseMessage' sent by ATS to client with information about addresse...
#define GNUNET_MESSAGE_TYPE_ATS_RESERVATION_REQUEST
Type of the 'struct ReservationRequestMessage' sent by clients to ATS to ask for inbound bandwidth re...
#define GNUNET_MESSAGE_TYPE_ATS_PREFERENCE_CHANGE
Type of the 'struct ChangePreferenceMessage' sent by clients to ATS to ask for allocation preference ...
void * GNUNET_SCHEDULER_cancel(struct GNUNET_SCHEDULER_Task *task)
Cancel the task with the specified identifier.
Definition: scheduler.c:975
struct GNUNET_SCHEDULER_Task * GNUNET_SCHEDULER_add_delayed(struct GNUNET_TIME_Relative delay, GNUNET_SCHEDULER_TaskCallback task, void *task_cls)
Schedule a new task to be run with a specified delay.
Definition: scheduler.c:1272
#define GNUNET_TIME_UNIT_FOREVER_REL
Constant used to specify "forever".
struct GNUNET_TIME_Relative GNUNET_TIME_relative_ntoh(struct GNUNET_TIME_RelativeNBO a)
Convert relative time from network byte order.
Definition: time.c:628
struct GNUNET_TIME_RelativeNBO GNUNET_TIME_relative_hton(struct GNUNET_TIME_Relative a)
Convert relative time to network byte order.
Definition: time.c:618
#define GNUNET_TIME_STD_BACKOFF(r)
Perform our standard exponential back-off calculation, starting at 1 ms and then going by a factor of...
static enum GNUNET_NetworkType scope
Which network scope do we belong to?
Client to service: please give us an overview of the addresses.
Definition: ats.h:342
int32_t all
GNUNET_YES to get information about all addresses, GNUNET_NO to only return addresses that are in use...
Definition: ats.h:362
Client to ATS: I have a performance preference for a peer.
Definition: ats.h:438
First message any client sends to ATS, used to self-identify (what type of client this is).
Definition: ats.h:70
Message containing application feedback for a peer.
Definition: ats.h:464
Linked list of pending reservations.
GNUNET_ATS_AddressInformationCallback cb
Callback.
struct GNUNET_ATS_AddressListHandle * prev
Kept in a DLL.
void * cb_cls
Callback closure for cb.
struct GNUNET_ATS_AddressListHandle * next
Kept in a DLL.
uint32_t id
Request multiplexing.
struct GNUNET_PeerIdentity peer
Target peer.
struct GNUNET_ATS_PerformanceHandle * ph
Performance handle.
int all_peers
Return all or specific peer only.
int all_addresses
Return all or used address only.
ATS Handle to obtain and/or modify performance information.
struct GNUNET_MQ_Handle * mq
Connection to ATS service.
const struct GNUNET_CONFIGURATION_Handle * cfg
Our configuration.
uint32_t id
Request multiplexing.
void * addr_info_cb_cls
Closure for addr_info_cb.
struct GNUNET_ATS_AddressListHandle * addresslist_head
Head of linked list of pending address list requests.
uint32_t monitor_id
Monitor request multiplexing.
struct GNUNET_ATS_AddressListHandle * addresslist_tail
Tail of linked list of pending address list requests.
struct GNUNET_ATS_ReservationContext * reservation_tail
Tail of linked list of pending reservation requests.
struct GNUNET_ATS_ReservationContext * reservation_head
Head of linked list of pending reservation requests.
struct GNUNET_TIME_Relative backoff
Reconnect backoff delay.
int in_receive
Is the receive loop active?
struct GNUNET_SCHEDULER_Task * task
Task to trigger reconnect.
GNUNET_ATS_AddressInformationCallback addr_info_cb
Callback to invoke when an address has performance changes.
struct GNUNET_CLIENT_TransmitHandle * th
Current request for transmission to ATS.
ATS performance characteristics for an address.
Linked list of pending reservations.
struct GNUNET_PeerIdentity peer
Target peer.
int undo
Do we need to undo this reservation if it succeeded? Set to GNUNET_YES if a reservation is cancelled.
struct GNUNET_ATS_ReservationContext * prev
Kept in a DLL.
struct GNUNET_ATS_ReservationContext * next
Kept in a DLL.
GNUNET_ATS_ReservationCallback rcb
Function to call on result.
void * rcb_cls
Closure for rcb.
int32_t size
Desired reservation.
32-bit bandwidth used for network exchange by GNUnet, in bytes per second.
uint32_t value__
The actual value (bytes per second).
An address for communicating with a peer.
Handle to a message queue.
Definition: mq.c:87
Message handler for a specific message type.
The identity of the host (wraps the signing key of the peer).
Entry in list of pending tasks.
Definition: scheduler.c:136
Time for relative time used by GNUnet, in microseconds.
Variable-size entry in a struct ChangePreferenceMessage or struct FeedbackPreferenceMessage.
Definition: ats.h:420
struct GNUNET_TIME_RelativeNBO res_delay
Definition: ats.h:411
struct GNUNET_PeerIdentity peer
Definition: ats.h:406
enum GNUNET_TESTBED_UnderlayLinkModelType type
the type of this model
struct GNUNET_TESTBED_Peer * peer
The peer associated with this model.