GNUnet  0.10.x
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", __VA_ARGS__)
32 
33 
38 {
39 
44 
49 
54 
58  int32_t size;
59 
64 
68  void *rcb_cls;
69 
78  int undo;
79 };
80 
81 
86 {
87 
92 
97 
102 
107 
111  void *cb_cls;
112 
117 
122 
127 
131  uint32_t id;
132 };
133 
134 
139 {
140 
145 
150 
155 
160 
165 
170 
175 
180 
184  struct GNUNET_CLIENT_TransmitHandle *th;
185 
190 
195 
199  uint32_t monitor_id;
200 
204  uint32_t id;
205 
210 };
211 
217 static void
219 
220 
226 static void
227 reconnect_task (void *cls)
228 {
229  struct GNUNET_ATS_PerformanceHandle *ph = cls;
230 
231  ph->task = NULL;
232  reconnect (ph);
233 }
234 
235 
241 static void
243 {
246  struct GNUNET_BANDWIDTH_Value32NBO bandwidth_zero;
247 
248  if (NULL != ph->mq)
249  {
250  GNUNET_MQ_destroy (ph->mq);
251  ph->mq = NULL;
252  }
253  while (NULL != (rc = ph->reservation_head))
254  {
256  ph->reservation_tail,
257  rc);
258  if (NULL != rc->rcb)
259  rc->rcb (rc->rcb_cls,
260  NULL,
261  0,
263  GNUNET_free (rc);
264  }
265  bandwidth_zero.value__ = htonl (0);
266  while (NULL != (alh = ph->addresslist_head))
267  {
269  ph->addresslist_tail,
270  alh);
271  if (NULL != alh->cb)
272  alh->cb (alh->cb_cls,
273  NULL,
274  GNUNET_NO,
275  bandwidth_zero,
276  bandwidth_zero,
277  NULL);
278  GNUNET_free (alh);
279  }
280  if (NULL != ph->addr_info_cb)
281  {
282  /* Indicate reconnect */
284  NULL,
285  GNUNET_NO,
286  bandwidth_zero,
287  bandwidth_zero,
288  NULL);
289  }
293  ph);
294 }
295 
296 
304 static int
306  const struct PeerInformationMessage *pi)
307 {
308  const char *plugin_address;
309  const char *plugin_name;
310  uint16_t plugin_address_length;
311  uint16_t plugin_name_length;
312 
313  plugin_address_length = ntohs (pi->address_length);
314  plugin_name_length = ntohs (pi->plugin_name_length);
315  plugin_address = (const char *) &pi[1];
316  plugin_name = &plugin_address[plugin_address_length];
317  if ( (plugin_address_length + plugin_name_length
318  + sizeof(struct PeerInformationMessage) != ntohs (pi->header.size)) ||
319  (plugin_name[plugin_name_length - 1] != '\0'))
320  {
321  GNUNET_break(0);
322  return GNUNET_SYSERR;
323  }
324  return GNUNET_OK;
325 }
326 
327 
335 static void
337  const struct PeerInformationMessage *pi)
338 {
339  struct GNUNET_ATS_PerformanceHandle *ph = cls;
340  const char *plugin_address;
341  const char *plugin_name;
342  struct GNUNET_HELLO_Address address;
343  uint16_t plugin_address_length;
344  int addr_active;
345  struct GNUNET_ATS_Properties prop;
346 
347  if (NULL == ph->addr_info_cb)
348  return;
349  plugin_address_length = ntohs (pi->address_length);
350  addr_active = (int) ntohl (pi->address_active);
351  plugin_address = (const char *) &pi[1];
352  plugin_name = &plugin_address[plugin_address_length];
353 
355  &pi->properties);
356  address.peer = pi->peer;
357  address.local_info = (enum GNUNET_HELLO_AddressInfo) ntohl (pi->address_local_info);
358  address.address = plugin_address;
359  address.address_length = plugin_address_length;
360  address.transport_name = plugin_name;
362  &address,
363  addr_active,
364  pi->bandwidth_out,
365  pi->bandwidth_in,
366  &prop);
367 }
368 
369 
376 static void
378  const struct ReservationResultMessage *rr)
379 {
380  struct GNUNET_ATS_PerformanceHandle *ph = cls;
382  int32_t amount;
383 
384  amount = ntohl (rr->amount);
385  rc = ph->reservation_head;
386  if (0 != GNUNET_memcmp (&rr->peer,
387  &rc->peer))
388  {
389  GNUNET_break(0);
390  reconnect (ph);
391  return;
392  }
394  ph->reservation_tail,
395  rc);
396  if ( (0 == amount) ||
397  (NULL != rc->rcb) )
398  {
399  /* tell client if not cancelled */
400  if (NULL != rc->rcb)
401  rc->rcb (rc->rcb_cls,
402  &rr->peer,
403  amount,
405  GNUNET_free (rc);
406  return;
407  }
408  /* amount non-zero, but client cancelled, consider undo! */
409  if (GNUNET_YES != rc->undo)
410  {
411  GNUNET_free (rc);
412  return; /* do not try to undo failed undos or negative amounts */
413  }
414  GNUNET_free (rc);
415  (void) GNUNET_ATS_reserve_bandwidth (ph,
416  &rr->peer,
417  -amount,
418  NULL, NULL);
419 }
420 
421 
429 static int
431  const struct PeerInformationMessage *pi)
432 {
433  const char *plugin_address;
434  const char *plugin_name;
435  uint16_t plugin_address_length;
436  uint16_t plugin_name_length;
437 
438  plugin_address_length = ntohs (pi->address_length);
439  plugin_name_length = ntohs (pi->plugin_name_length);
440  plugin_address = (const char *) &pi[1];
441  plugin_name = &plugin_address[plugin_address_length];
442  if ( (plugin_address_length + plugin_name_length
443  + sizeof (struct PeerInformationMessage) != ntohs (pi->header.size)) ||
444  (plugin_name[plugin_name_length - 1] != '\0') )
445  {
446  GNUNET_break(0);
447  return GNUNET_SYSERR;
448  }
449  return GNUNET_OK;
450 }
451 
452 
460 static void
462  const struct PeerInformationMessage *pi)
463 {
464  struct GNUNET_ATS_PerformanceHandle *ph = cls;
467  const char *plugin_address;
468  const char *plugin_name;
469  struct GNUNET_HELLO_Address address;
470  struct GNUNET_PeerIdentity allzeros;
471  struct GNUNET_BANDWIDTH_Value32NBO bandwidth_zero;
472  struct GNUNET_ATS_Properties prop;
473  uint16_t plugin_address_length;
474  uint16_t plugin_name_length;
475  uint32_t active;
476  uint32_t id;
477 
478  id = ntohl (pi->id);
479  active = ntohl (pi->address_active);
480  plugin_address_length = ntohs (pi->address_length);
481  plugin_name_length = ntohs (pi->plugin_name_length);
482  plugin_address = (const char *) &pi[1];
483  plugin_name = &plugin_address[plugin_address_length];
485  "Received ATS_ADDRESSLIST_RESPONSE message for peer %s and plugin %s\n",
486  GNUNET_i2s (&pi->peer),
487  plugin_name);
488 
489  next = ph->addresslist_head;
490  while (NULL != (alh = next))
491  {
492  next = alh->next;
493  if (alh->id == id)
494  break;
495  }
496  if (NULL == alh)
497  return; /* was canceled */
498 
499  memset (&allzeros, '\0', sizeof (allzeros));
500  if ( (0 == GNUNET_is_zero (&pi->peer)) &&
501  (0 == plugin_name_length) &&
502  (0 == plugin_address_length) )
503  {
504  /* Done */
506  "Received last message for ATS_ADDRESSLIST_RESPONSE\n");
507  bandwidth_zero.value__ = htonl (0);
509  ph->addresslist_tail,
510  alh);
511  if (NULL != alh->cb)
512  alh->cb (alh->cb_cls,
513  NULL,
514  GNUNET_NO,
515  bandwidth_zero,
516  bandwidth_zero,
517  NULL);
518  GNUNET_free (alh);
519  return;
520  }
521 
522  address.peer = pi->peer;
523  address.address = plugin_address;
524  address.address_length = plugin_address_length;
525  address.transport_name = plugin_name;
526  if ( ( (GNUNET_YES == alh->all_addresses) ||
527  (GNUNET_YES == active) ) &&
528  (NULL != alh->cb) )
529  {
531  &pi->properties);
532  alh->cb (alh->cb_cls,
533  &address,
534  active,
535  pi->bandwidth_out,
536  pi->bandwidth_in,
537  &prop);
538  }
539 }
540 
541 
550 static void
551 mq_error_handler (void *cls,
552  enum GNUNET_MQ_Error error)
553 {
554  struct GNUNET_ATS_PerformanceHandle *ph = cls;
555 
556  do_reconnect (ph);
557 }
558 
559 
565 static void
567 {
568  struct GNUNET_MQ_MessageHandler handlers[] = {
569  GNUNET_MQ_hd_var_size (peer_information,
571  struct PeerInformationMessage,
572  ph),
573  GNUNET_MQ_hd_fixed_size (reservation_result,
576  ph),
577  GNUNET_MQ_hd_var_size (address_list,
579  struct PeerInformationMessage,
580  ph),
582  };
583  struct GNUNET_MQ_Envelope *env;
584  struct ClientStartMessage *init;
585 
586  GNUNET_assert (NULL == ph->mq);
587  ph->mq = GNUNET_CLIENT_connect (ph->cfg,
588  "ats",
589  handlers,
591  ph);
592  if (NULL == ph->mq)
593  return;
594  env = GNUNET_MQ_msg (init,
596  init->start_flag = htonl ( (NULL == ph->addr_info_cb)
599  GNUNET_MQ_send (ph->mq,
600  env);
601 }
602 
603 
616  void *addr_info_cb_cls)
617 {
619 
621  ph->cfg = cfg;
624  reconnect (ph);
625  if (NULL == ph->mq)
626  {
627  GNUNET_free (ph);
628  return NULL;
629  }
630  return ph;
631 }
632 
633 
639 void
641 {
644 
645  while (NULL != (alh = ph->addresslist_head))
646  {
648  ph->addresslist_tail,
649  alh);
650  GNUNET_free (alh);
651  }
652  while (NULL != (rc = ph->reservation_head))
653  {
655  ph->reservation_tail,
656  rc);
657  GNUNET_break (NULL == rc->rcb);
658  GNUNET_free (rc);
659  }
660  if (NULL != ph->task)
661  {
663  ph->task = NULL;
664  }
665  if (NULL != ph->mq)
666  {
667  GNUNET_MQ_destroy (ph->mq);
668  ph->mq = NULL;
669  }
670  GNUNET_free (ph);
671 }
672 
673 
690  const struct GNUNET_PeerIdentity *peer,
691  int32_t amount,
693  void *rcb_cls)
694 {
696  struct GNUNET_MQ_Envelope *env;
698 
699  if (NULL == ph->mq)
700  return NULL;
702  rc->size = amount;
703  rc->peer = *peer;
704  rc->rcb = rcb;
705  rc->rcb_cls = rcb_cls;
706  if ( (NULL != rcb) &&
707  (amount > 0) )
708  rc->undo = GNUNET_YES;
710  ph->reservation_tail,
711  rc);
712  env = GNUNET_MQ_msg (m,
714  m->amount = htonl (amount);
715  m->peer = *peer;
716  GNUNET_MQ_send (ph->mq,
717  env);
718  return rc;
719 }
720 
721 
727 void
729 {
730  rc->rcb = NULL;
731 }
732 
733 
748  const struct GNUNET_PeerIdentity *peer,
749  int all,
751  void *infocb_cls)
752 {
754  struct GNUNET_MQ_Envelope *env;
756 
757  if (NULL == ph->mq)
758  return NULL;
759  if (NULL == infocb)
760  {
761  GNUNET_break (0);
762  return NULL;
763  }
765  alh->id = ph->id++;
766  alh->cb = infocb;
767  alh->cb_cls = infocb_cls;
768  alh->ph = ph;
769  alh->all_addresses = all;
770  if (NULL == peer)
771  {
772  alh->all_peers = GNUNET_YES;
773  }
774  else
775  {
776  alh->all_peers = GNUNET_NO;
777  alh->peer = *peer;
778  }
780  ph->addresslist_tail,
781  alh);
782  env = GNUNET_MQ_msg (m,
784  m->all = htonl (all);
785  m->id = htonl (alh->id);
786  if (NULL != peer)
787  m->peer = *peer;
788  GNUNET_MQ_send (ph->mq,
789  env);
790  return alh;
791 }
792 
793 
799 void
801 {
802  struct GNUNET_ATS_PerformanceHandle *ph = alh->ph;
803 
805  ph->addresslist_tail,
806  alh);
807  GNUNET_free (alh);
808 }
809 
810 
817 const char *
819 {
820  const char *prefs[] = GNUNET_ATS_PreferenceTypeString;
821 
822  if (type < GNUNET_ATS_PREFERENCE_END)
823  return prefs[type];
824  return NULL;
825 }
826 
827 
836 void
838  const struct GNUNET_PeerIdentity *peer,
839  ...)
840 {
841  struct GNUNET_MQ_Envelope *env;
842  struct ChangePreferenceMessage *m;
843  uint32_t count;
844  struct PreferenceInformation *pi;
845  va_list ap;
846  enum GNUNET_ATS_PreferenceKind kind;
847 
848  if (NULL == ph->mq)
849  return;
850  count = 0;
851  va_start(ap, peer);
852  while (GNUNET_ATS_PREFERENCE_END !=
854  {
855  switch (kind)
856  {
858  count++;
859  (void) va_arg (ap, double);
860  break;
862  count++;
863  (void) va_arg (ap, double);
864  break;
865  default:
866  GNUNET_assert(0);
867  }
868  }
869  va_end(ap);
870  env = GNUNET_MQ_msg_extra (m,
871  count * sizeof(struct PreferenceInformation),
873  m->num_preferences = htonl (count);
874  m->peer = *peer;
875  pi = (struct PreferenceInformation *) &m[1];
876  count = 0;
877  va_start(ap, peer);
878  while (GNUNET_ATS_PREFERENCE_END != (kind =
880  {
881  pi[count].preference_kind = htonl (kind);
882  switch (kind)
883  {
885  pi[count].preference_value = (float) va_arg (ap, double);
886 
887  count++;
888  break;
890  pi[count].preference_value = (float) va_arg (ap, double);
891 
892  count++;
893  break;
894  default:
895  GNUNET_assert(0);
896  }
897  }
898  va_end(ap);
899  GNUNET_MQ_send (ph->mq,
900  env);
901 }
902 
903 
913 void
915  const struct GNUNET_PeerIdentity *peer,
916  const struct GNUNET_TIME_Relative scope,
917  ...)
918 {
919  struct GNUNET_MQ_Envelope *env;
921  uint32_t count;
922  struct PreferenceInformation *pi;
923  va_list ap;
924  enum GNUNET_ATS_PreferenceKind kind;
925 
926  if (NULL == ph->mq)
927  return;
928  count = 0;
929  va_start(ap, scope);
930  while (GNUNET_ATS_PREFERENCE_END !=
932  {
933  switch (kind)
934  {
936  count++;
937  (void) va_arg (ap, double);
938  break;
940  count++;
941  (void) va_arg (ap, double);
942  break;
943  default:
944  GNUNET_assert(0);
945  }
946  }
947  va_end(ap);
948  env = GNUNET_MQ_msg_extra (m,
949  count * sizeof(struct PreferenceInformation),
951  m->scope = GNUNET_TIME_relative_hton (scope);
952  m->num_feedback = htonl (count);
953  m->peer = *peer;
954  pi = (struct PreferenceInformation *) &m[1];
955  count = 0;
956  va_start(ap, scope);
957  while (GNUNET_ATS_PREFERENCE_END != (kind =
959  {
960  pi[count].preference_kind = htonl (kind);
961  switch (kind)
962  {
964  pi[count].preference_value = (float) va_arg (ap, double);
965 
966  count++;
967  break;
969  pi[count].preference_value = (float) va_arg (ap, double);
970 
971  count++;
972  break;
973  default:
974  GNUNET_assert(0);
975  }
976  }
977  va_end(ap);
978  GNUNET_MQ_send (ph->mq,
979  env);
980 }
981 
982 /* end of ats_api_performance.c */
#define GNUNET_CONTAINER_DLL_remove(head, tail, element)
Remove an element from a DLL.
struct GNUNET_PeerIdentity peer
Which peer is the preference being expressed for?
Definition: ats.h:463
size_t address_length
Number of bytes in address.
struct GNUNET_ATS_AddressListHandle * addresslist_tail
Tail of linked list of pending address list requests.
enum GNUNET_HELLO_AddressInfo local_info
Extended information about address.
uint32_t id
Request multiplexing.
#define GNUNET_MESSAGE_TYPE_ATS_START
Type of the &#39;struct ClientStartMessage&#39; sent by clients to ATS to identify the type of the client...
uint32_t monitor_id
Monitor request multiplexing.
const void * address
Binary representation of the address (plugin-specific).
#define GNUNET_CONTAINER_DLL_insert(head, tail, element)
Insert an element at the head of a DLL.
struct GNUNET_ATS_ReservationContext * reservation_tail
Tail of linked list of pending reservation requests.
static struct GNUNET_TIME_Relative backoff
How long should we wait to reconnect?
Definition: resolver_api.c:81
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:901
uint16_t address_length
Definition: ats.h:294
uint32_t start_flag
NBO value of an enum StartFlag.
Definition: ats.h:80
GNUNET_MQ_Error
Error codes for the queue.
int all_addresses
Return all or used address only.
#define GNUNET_assert(cond)
Use this for fatal errors that cannot be handled.
struct GNUNET_ATS_AddressListHandle * addresslist_head
Head of linked list of pending address list requests.
static struct GNUNET_ATS_PerformanceHandle * ph
ATS performance handle used.
Definition: gnunet-ats.c:116
int all_peers
Return all or specific peer only.
struct GNUNET_ATS_ReservationContext * reservation_head
Head of linked list of pending reservation requests.
GNUNET_ATS_ReservationCallback rcb
Function to call on result.
struct GNUNET_BANDWIDTH_Value32NBO bandwidth_in
Definition: ats.h:324
struct GNUNET_MQ_Handle * mq
Connection to ATS service.
uint16_t plugin_name_length
Definition: ats.h:299
struct GNUNET_MessageHeader header
Type is GNUNET_MESSAGE_TYPE_ATS_PEER_INFORMATION.
Definition: ats.h:289
uint32_t preference_kind
An enum GNUNET_ATS_PreferenceKind in NBO.
Definition: ats.h:433
uint32_t address_local_info
Local-only information of the address, see enum GNUNET_HELLO_AddressInfo.
Definition: ats.h:335
void * rcb_cls
Closure for rcb.
uint32_t id
ID used to match replies to this request.
Definition: ats.h:358
#define GNUNET_MQ_hd_fixed_size(name, code, str, ctx)
void GNUNET_ATS_performance_done(struct GNUNET_ATS_PerformanceHandle *ph)
Client is done using the ATS performance subsystem, release resources.
static int check_address_list(void *cls, const struct PeerInformationMessage *pi)
We received a PeerInformationMessage.
#define GNUNET_MQ_msg(mvar, type)
Allocate a GNUNET_MQ_Envelope.
Definition: gnunet_mq_lib.h:67
#define GNUNET_NO
Definition: gnunet_common.h:81
static struct GNUNET_IDENTITY_Handle * id
Handle to identity service.
#define GNUNET_OK
Named constants for return values.
Definition: gnunet_common.h:78
Performance monitoring client that does NOT want to learn about changes in performance characteristic...
Definition: ats.h:55
#define GNUNET_new(type)
Allocate a struct or union of the given type.
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...
uint16_t size
The length of the struct (in bytes, including the length field itself), in big-endian format...
struct GNUNET_ATS_AddressListHandle * next
Kept in a DLL.
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.
struct GNUNET_ATS_ReservationContext * next
Kept in a DLL.
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.
#define GNUNET_MESSAGE_TYPE_ATS_PEER_INFORMATION
Type of the &#39;struct PeerInformationMessage&#39; sent by ATS to clients to inform about QoS for a particul...
ATS performance characteristics for an address.
struct GNUNET_ATS_PropertiesNBO properties
Performance properties of the address.
Definition: ats.h:329
uint32_t num_feedback
Number of feedback values included.
Definition: ats.h:483
#define GNUNET_break(cond)
Use this for internal assertion violations that are not fatal (can be handled) but should not occur...
struct GNUNET_PeerIdentity peer
Definition: ats.h:304
Linked list of pending reservations.
GNUNET_ATS_AddressInformationCallback cb
Callback.
End of preference list.
struct GNUNET_CLIENT_TransmitHandle * th
Current request for transmission to ATS.
#define GNUNET_MESSAGE_TYPE_ATS_ADDRESSLIST_REQUEST
Type of the &#39;struct AddressListRequestMessage&#39; sent by client to ATS to request information about add...
uint32_t value__
The actual value (bytes per second).
static struct GNUNET_ATS_AddressListHandle * alh
ATS address list handle used.
Definition: gnunet-ats.c:131
struct GNUNET_PeerIdentity peer
Definition: ats.h:414
int undo
Do we need to undo this reservation if it succeeded? Set to GNUNET_YES if a reservation is cancelled...
static struct GNUNET_ARM_MonitorHandle * m
Monitor connection with ARM.
Definition: gnunet-arm.c:99
int in_receive
Is the receive loop active?
struct GNUNET_SCHEDULER_Task * task
Task to trigger reconnect.
#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:52
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:1246
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_BANDWIDTH_Value32NBO bandwidth_out
Definition: ats.h:319
#define GNUNET_MQ_hd_var_size(name, code, str, ctx)
static enum GNUNET_NetworkType scope
Which network scope do we belong to?
GNUNET_ATS_AddressInformationCallback addr_info_cb
Callback to invoke when an address has performance changes.
void * cb_cls
Callback closure for cb.
struct GNUNET_ATS_PerformanceHandle * ph
Performance handle.
static int check_peer_information(void *cls, const struct PeerInformationMessage *pi)
We received a peer information message.
#define LOG(kind,...)
const char * transport_name
Name of the transport plugin enabling the communication using this address.
#define GNUNET_TIME_UNIT_FOREVER_REL
Constant used to specify "forever".
static char * plugin_name
Solver plugin name as string.
const char * GNUNET_ATS_print_preference_type(enum GNUNET_ATS_PreferenceKind type)
Convert a enum GNUNET_ATS_PreferenceType to a string.
struct GNUNET_TIME_Relative GNUNET_TIME_relative_ntoh(struct GNUNET_TIME_RelativeNBO a)
Convert relative time from network byte order.
Definition: time.c:638
static void do_reconnect(struct GNUNET_ATS_PerformanceHandle *ph)
Reconnect to the ATS service, something went wrong.
struct GNUNET_PeerIdentity peer
Peer this feedback is for.
Definition: ats.h:493
Message handler for a specific message type.
static struct GNUNET_CONFIGURATION_Handle * cfg
Our configuration.
Definition: gnunet-arm.c:104
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.
const struct GNUNET_CONFIGURATION_Handle * cfg
Our configuration.
#define GNUNET_SYSERR
Definition: gnunet_common.h:79
struct GNUNET_TIME_RelativeNBO GNUNET_TIME_relative_hton(struct GNUNET_TIME_Relative a)
Convert relative time to network byte order.
Definition: time.c:622
Client to service: please give us an overview of the addresses.
Definition: ats.h:348
uint32_t num_preferences
How many struct PreferenceInformation entries follow this struct?
Definition: ats.h:458
#define GNUNET_MESSAGE_TYPE_ATS_PREFERENCE_FEEDBACK
Type of the &#39;struct ChangePreferenceMessage&#39; sent by clients to ATS to ask for allocation preference ...
static void handle_reservation_result(void *cls, const struct ReservationResultMessage *rr)
We received a reservation result message.
struct GNUNET_MQ_Envelope * env
Definition: 005.c:1
#define GNUNET_CONTAINER_DLL_insert_tail(head, tail, element)
Insert an element at the tail of a DLL.
Change the peer&#39;s latency value to the given amount.
struct GNUNET_PeerIdentity peer
Target peer.
static char * init
Set to the name of a service to start.
Definition: gnunet-arm.c:69
#define GNUNET_TIME_STD_BACKOFF(r)
Perform our standard exponential back-off calculation, starting at 1 ms and then going by a factor of...
struct GNUNET_PeerIdentity peer
For which peer is this an address?
32-bit bandwidth used for network exchange by GNUnet, in bytes per second.
#define GNUNET_MESSAGE_TYPE_ATS_ADDRESSLIST_RESPONSE
Type of the &#39;struct AddressListResponseMessage&#39; sent by ATS to client with information about addresse...
#define GNUNET_is_zero(a)
Check that memory in a is all zeros.
static void reconnect_task(void *cls)
Re-establish the connection to the ATS service.
#define GNUNET_memcmp(a, b)
Compare memory in a and b, where both must be of the same pointer type.
ATS Handle to obtain and/or modify performance information.
uint32_t id
Request multiplexing.
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.
Handle to a message queue.
Definition: mq.c:85
int32_t all
GNUNET_YES to get information about all addresses, GNUNET_NO to only return addresses that are in use...
Definition: ats.h:369
static void handle_peer_information(void *cls, const struct PeerInformationMessage *pi)
We received a peer information message.
The identity of the host (wraps the signing key of the peer).
Message containing application feedback for a peer.
Definition: ats.h:473
struct GNUNET_TIME_RelativeNBO scope
Relative time describing for which time interval this feedback is.
Definition: ats.h:488
void GNUNET_ATS_reserve_bandwidth_cancel(struct GNUNET_ATS_ReservationContext *rc)
Cancel request for reserving bandwidth.
configuration data
Definition: configuration.c:85
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.
static void reconnect(struct GNUNET_ATS_PerformanceHandle *ph)
Re-establish the connection to the ATS service.
#define GNUNET_VA_ARG_ENUM(va, X)
wrap va_arg for enums
void GNUNET_ATS_performance_change_preference(struct GNUNET_ATS_PerformanceHandle *ph, const struct GNUNET_PeerIdentity *peer,...)
Change preferences for the given peer.
An address for communicating with a peer.
struct GNUNET_TIME_Relative backoff
Reconnect backoff delay.
void GNUNET_ATS_performance_list_addresses_cancel(struct GNUNET_ATS_AddressListHandle *alh)
Cancel a pending address listing operation.
Automatic transport selection and outbound bandwidth determination.
Entry in list of pending tasks.
Definition: scheduler.c:134
Change the peer&#39;s bandwidth value (value per byte of bandwidth in the goal function) to the given amo...
Variable-size entry in a struct ChangePreferenceMessage or struct FeedbackPreferenceMessage.
Definition: ats.h:427
struct GNUNET_ATS_AddressListHandle * prev
Kept in a DLL.
Client to ATS: I have a performance preference for a peer.
Definition: ats.h:447
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.
#define GNUNET_MESSAGE_TYPE_ATS_RESERVATION_REQUEST
Type of the &#39;struct ReservationRequestMessage&#39; sent by clients to ATS to ask for inbound bandwidth re...
enum GNUNET_TESTBED_UnderlayLinkModelType type
the type of this model
void GNUNET_MQ_destroy(struct GNUNET_MQ_Handle *mq)
Destroy the message queue.
Definition: mq.c:824
int32_t size
Desired reservation.
#define GNUNET_YES
Definition: gnunet_common.h:80
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:353
#define GNUNET_ATS_PreferenceTypeString
ATS preference types as string array initializer.
GNUNET_ATS_PreferenceKind
Enum defining all known preference categories.
uint32_t address_active
Definition: ats.h:309
struct GNUNET_ATS_ReservationContext * prev
Kept in a DLL.
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...
struct GNUNET_TIME_RelativeNBO res_delay
Definition: ats.h:419
#define GNUNET_MESSAGE_TYPE_ATS_RESERVATION_RESULT
Type of the &#39;struct ReservationResultMessage&#39; sent by ATS to clients in response to a reservation req...
GNUNET_HELLO_AddressInfo
Additional local information about an address.
float preference_value
Degree of preference (or appreciation) for this preference_kind being expressed.
Definition: ats.h:439
void * addr_info_cb_cls
Closure for addr_info_cb.
struct GNUNET_PeerIdentity peer
Which peer do we care about? All zeros for all.
Definition: ats.h:363
const char * GNUNET_i2s(const struct GNUNET_PeerIdentity *pid)
Convert a peer identity to a string (for printing debug messages).
#define GNUNET_MESSAGE_TYPE_ATS_PREFERENCE_CHANGE
Type of the &#39;struct ChangePreferenceMessage&#39; sent by clients to ATS to ask for allocation preference ...
#define GNUNET_MQ_handler_end()
End-marker for the handlers array.
struct GNUNET_PeerIdentity peer
Definition: ats.h:392
automatic transport selection messages
static void handle_address_list(void *cls, const struct PeerInformationMessage *pi)
We received a GNUNET_MESSAGE_TYPE_ATS_ADDRESSLIST_RESPONSE.
First message any client sends to ATS, used to self-identify (what type of client this is)...
Definition: ats.h:70
Performance monitoring client that wants to learn about changes in performance characteristics.
Definition: ats.h:49
#define GNUNET_free(ptr)
Wrapper around free.
Time for relative time used by GNUnet, in microseconds.
struct GNUNET_PeerIdentity peer
Target peer.
Linked list of pending reservations.
void * GNUNET_SCHEDULER_cancel(struct GNUNET_SCHEDULER_Task *task)
Cancel the task with the specified identifier.
Definition: scheduler.c:965