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 
42 
47 
52 
56  int32_t size;
57 
62 
66  void *rcb_cls;
67 
76  int undo;
77 };
78 
79 
88 
93 
98 
103 
107  void *cb_cls;
108 
113 
118 
123 
127  uint32_t id;
128 };
129 
130 
139 
144 
149 
154 
159 
164 
169 
174 
178  struct GNUNET_CLIENT_TransmitHandle *th;
179 
184 
189 
193  uint32_t monitor_id;
194 
198  uint32_t id;
199 
204 };
205 
211 static void
213 
214 
220 static void
221 reconnect_task(void *cls)
222 {
223  struct GNUNET_ATS_PerformanceHandle *ph = cls;
224 
225  ph->task = NULL;
226  reconnect(ph);
227 }
228 
229 
235 static void
237 {
240  struct GNUNET_BANDWIDTH_Value32NBO bandwidth_zero;
241 
242  if (NULL != ph->mq)
243  {
244  GNUNET_MQ_destroy(ph->mq);
245  ph->mq = NULL;
246  }
247  while (NULL != (rc = ph->reservation_head))
248  {
250  ph->reservation_tail,
251  rc);
252  if (NULL != rc->rcb)
253  rc->rcb(rc->rcb_cls,
254  NULL,
255  0,
257  GNUNET_free(rc);
258  }
259  bandwidth_zero.value__ = htonl(0);
260  while (NULL != (alh = ph->addresslist_head))
261  {
263  ph->addresslist_tail,
264  alh);
265  if (NULL != alh->cb)
266  alh->cb(alh->cb_cls,
267  NULL,
268  GNUNET_NO,
269  bandwidth_zero,
270  bandwidth_zero,
271  NULL);
272  GNUNET_free(alh);
273  }
274  if (NULL != ph->addr_info_cb)
275  {
276  /* Indicate reconnect */
278  NULL,
279  GNUNET_NO,
280  bandwidth_zero,
281  bandwidth_zero,
282  NULL);
283  }
287  ph);
288 }
289 
290 
298 static int
300  const struct PeerInformationMessage *pi)
301 {
302  const char *plugin_address;
303  const char *plugin_name;
304  uint16_t plugin_address_length;
305  uint16_t plugin_name_length;
306 
307  plugin_address_length = ntohs(pi->address_length);
308  plugin_name_length = ntohs(pi->plugin_name_length);
309  plugin_address = (const char *)&pi[1];
310  plugin_name = &plugin_address[plugin_address_length];
311  if ((plugin_address_length + plugin_name_length
312  + sizeof(struct PeerInformationMessage) != ntohs(pi->header.size)) ||
313  (plugin_name[plugin_name_length - 1] != '\0'))
314  {
315  GNUNET_break(0);
316  return GNUNET_SYSERR;
317  }
318  return GNUNET_OK;
319 }
320 
321 
329 static void
331  const struct PeerInformationMessage *pi)
332 {
333  struct GNUNET_ATS_PerformanceHandle *ph = cls;
334  const char *plugin_address;
335  const char *plugin_name;
336  struct GNUNET_HELLO_Address address;
337  uint16_t plugin_address_length;
338  int addr_active;
339  struct GNUNET_ATS_Properties prop;
340 
341  if (NULL == ph->addr_info_cb)
342  return;
343  plugin_address_length = ntohs(pi->address_length);
344  addr_active = (int)ntohl(pi->address_active);
345  plugin_address = (const char *)&pi[1];
346  plugin_name = &plugin_address[plugin_address_length];
347 
349  &pi->properties);
350  address.peer = pi->peer;
351  address.local_info = (enum GNUNET_HELLO_AddressInfo)ntohl(pi->address_local_info);
352  address.address = plugin_address;
353  address.address_length = plugin_address_length;
354  address.transport_name = plugin_name;
356  &address,
357  addr_active,
358  pi->bandwidth_out,
359  pi->bandwidth_in,
360  &prop);
361 }
362 
363 
370 static void
372  const struct ReservationResultMessage *rr)
373 {
374  struct GNUNET_ATS_PerformanceHandle *ph = cls;
376  int32_t amount;
377 
378  amount = ntohl(rr->amount);
379  rc = ph->reservation_head;
380  if (0 != GNUNET_memcmp(&rr->peer,
381  &rc->peer))
382  {
383  GNUNET_break(0);
384  reconnect(ph);
385  return;
386  }
388  ph->reservation_tail,
389  rc);
390  if ((0 == amount) ||
391  (NULL != rc->rcb))
392  {
393  /* tell client if not cancelled */
394  if (NULL != rc->rcb)
395  rc->rcb(rc->rcb_cls,
396  &rr->peer,
397  amount,
399  GNUNET_free(rc);
400  return;
401  }
402  /* amount non-zero, but client cancelled, consider undo! */
403  if (GNUNET_YES != rc->undo)
404  {
405  GNUNET_free(rc);
406  return; /* do not try to undo failed undos or negative amounts */
407  }
408  GNUNET_free(rc);
410  &rr->peer,
411  -amount,
412  NULL, NULL);
413 }
414 
415 
423 static int
425  const struct PeerInformationMessage *pi)
426 {
427  const char *plugin_address;
428  const char *plugin_name;
429  uint16_t plugin_address_length;
430  uint16_t plugin_name_length;
431 
432  plugin_address_length = ntohs(pi->address_length);
433  plugin_name_length = ntohs(pi->plugin_name_length);
434  plugin_address = (const char *)&pi[1];
435  plugin_name = &plugin_address[plugin_address_length];
436  if ((plugin_address_length + plugin_name_length
437  + sizeof(struct PeerInformationMessage) != ntohs(pi->header.size)) ||
438  (plugin_name[plugin_name_length - 1] != '\0'))
439  {
440  GNUNET_break(0);
441  return GNUNET_SYSERR;
442  }
443  return GNUNET_OK;
444 }
445 
446 
454 static void
456  const struct PeerInformationMessage *pi)
457 {
458  struct GNUNET_ATS_PerformanceHandle *ph = cls;
461  const char *plugin_address;
462  const char *plugin_name;
463  struct GNUNET_HELLO_Address address;
464  struct GNUNET_PeerIdentity allzeros;
465  struct GNUNET_BANDWIDTH_Value32NBO bandwidth_zero;
466  struct GNUNET_ATS_Properties prop;
467  uint16_t plugin_address_length;
468  uint16_t plugin_name_length;
469  uint32_t active;
470  uint32_t id;
471 
472  id = ntohl(pi->id);
473  active = ntohl(pi->address_active);
474  plugin_address_length = ntohs(pi->address_length);
475  plugin_name_length = ntohs(pi->plugin_name_length);
476  plugin_address = (const char *)&pi[1];
477  plugin_name = &plugin_address[plugin_address_length];
479  "Received ATS_ADDRESSLIST_RESPONSE message for peer %s and plugin %s\n",
480  GNUNET_i2s(&pi->peer),
481  plugin_name);
482 
483  next = ph->addresslist_head;
484  while (NULL != (alh = next))
485  {
486  next = alh->next;
487  if (alh->id == id)
488  break;
489  }
490  if (NULL == alh)
491  return; /* was canceled */
492 
493  memset(&allzeros, '\0', sizeof(allzeros));
494  if ((0 == GNUNET_is_zero(&pi->peer)) &&
495  (0 == plugin_name_length) &&
496  (0 == plugin_address_length))
497  {
498  /* Done */
500  "Received last message for ATS_ADDRESSLIST_RESPONSE\n");
501  bandwidth_zero.value__ = htonl(0);
503  ph->addresslist_tail,
504  alh);
505  if (NULL != alh->cb)
506  alh->cb(alh->cb_cls,
507  NULL,
508  GNUNET_NO,
509  bandwidth_zero,
510  bandwidth_zero,
511  NULL);
512  GNUNET_free(alh);
513  return;
514  }
515 
516  address.peer = pi->peer;
517  address.address = plugin_address;
518  address.address_length = plugin_address_length;
519  address.transport_name = plugin_name;
520  if (((GNUNET_YES == alh->all_addresses) ||
521  (GNUNET_YES == active)) &&
522  (NULL != alh->cb))
523  {
525  &pi->properties);
526  alh->cb(alh->cb_cls,
527  &address,
528  active,
529  pi->bandwidth_out,
530  pi->bandwidth_in,
531  &prop);
532  }
533 }
534 
535 
544 static void
546  enum GNUNET_MQ_Error error)
547 {
548  struct GNUNET_ATS_PerformanceHandle *ph = cls;
549 
550  do_reconnect(ph);
551 }
552 
553 
559 static void
561 {
562  struct GNUNET_MQ_MessageHandler handlers[] = {
563  GNUNET_MQ_hd_var_size(peer_information,
565  struct PeerInformationMessage,
566  ph),
567  GNUNET_MQ_hd_fixed_size(reservation_result,
570  ph),
571  GNUNET_MQ_hd_var_size(address_list,
573  struct PeerInformationMessage,
574  ph),
576  };
577  struct GNUNET_MQ_Envelope *env;
578  struct ClientStartMessage *init;
579 
580  GNUNET_assert(NULL == ph->mq);
581  ph->mq = GNUNET_CLIENT_connect(ph->cfg,
582  "ats",
583  handlers,
585  ph);
586  if (NULL == ph->mq)
587  return;
588  env = GNUNET_MQ_msg(init,
590  init->start_flag = htonl((NULL == ph->addr_info_cb)
593  GNUNET_MQ_send(ph->mq,
594  env);
595 }
596 
597 
610  void *addr_info_cb_cls)
611 {
613 
615  ph->cfg = cfg;
618  reconnect(ph);
619  if (NULL == ph->mq)
620  {
621  GNUNET_free(ph);
622  return NULL;
623  }
624  return ph;
625 }
626 
627 
633 void
635 {
638 
639  while (NULL != (alh = ph->addresslist_head))
640  {
642  ph->addresslist_tail,
643  alh);
644  GNUNET_free(alh);
645  }
646  while (NULL != (rc = ph->reservation_head))
647  {
649  ph->reservation_tail,
650  rc);
651  GNUNET_break(NULL == rc->rcb);
652  GNUNET_free(rc);
653  }
654  if (NULL != ph->task)
655  {
657  ph->task = NULL;
658  }
659  if (NULL != ph->mq)
660  {
661  GNUNET_MQ_destroy(ph->mq);
662  ph->mq = NULL;
663  }
664  GNUNET_free(ph);
665 }
666 
667 
684  const struct GNUNET_PeerIdentity *peer,
685  int32_t amount,
687  void *rcb_cls)
688 {
690  struct GNUNET_MQ_Envelope *env;
692 
693  if (NULL == ph->mq)
694  return NULL;
696  rc->size = amount;
697  rc->peer = *peer;
698  rc->rcb = rcb;
699  rc->rcb_cls = rcb_cls;
700  if ((NULL != rcb) &&
701  (amount > 0))
702  rc->undo = GNUNET_YES;
704  ph->reservation_tail,
705  rc);
706  env = GNUNET_MQ_msg(m,
708  m->amount = htonl(amount);
709  m->peer = *peer;
710  GNUNET_MQ_send(ph->mq,
711  env);
712  return rc;
713 }
714 
715 
721 void
723 {
724  rc->rcb = NULL;
725 }
726 
727 
742  const struct GNUNET_PeerIdentity *peer,
743  int all,
745  void *infocb_cls)
746 {
748  struct GNUNET_MQ_Envelope *env;
750 
751  if (NULL == ph->mq)
752  return NULL;
753  if (NULL == infocb)
754  {
755  GNUNET_break(0);
756  return NULL;
757  }
759  alh->id = ph->id++;
760  alh->cb = infocb;
761  alh->cb_cls = infocb_cls;
762  alh->ph = ph;
763  alh->all_addresses = all;
764  if (NULL == peer)
765  {
766  alh->all_peers = GNUNET_YES;
767  }
768  else
769  {
770  alh->all_peers = GNUNET_NO;
771  alh->peer = *peer;
772  }
774  ph->addresslist_tail,
775  alh);
776  env = GNUNET_MQ_msg(m,
778  m->all = htonl(all);
779  m->id = htonl(alh->id);
780  if (NULL != peer)
781  m->peer = *peer;
782  GNUNET_MQ_send(ph->mq,
783  env);
784  return alh;
785 }
786 
787 
793 void
795 {
796  struct GNUNET_ATS_PerformanceHandle *ph = alh->ph;
797 
799  ph->addresslist_tail,
800  alh);
801  GNUNET_free(alh);
802 }
803 
804 
811 const char *
813 {
814  const char *prefs[] = GNUNET_ATS_PreferenceTypeString;
815 
816  if (type < GNUNET_ATS_PREFERENCE_END)
817  return prefs[type];
818  return NULL;
819 }
820 
821 
830 void
832  const struct GNUNET_PeerIdentity *peer,
833  ...)
834 {
835  struct GNUNET_MQ_Envelope *env;
836  struct ChangePreferenceMessage *m;
837  uint32_t count;
838  struct PreferenceInformation *pi;
839  va_list ap;
840  enum GNUNET_ATS_PreferenceKind kind;
841 
842  if (NULL == ph->mq)
843  return;
844  count = 0;
845  va_start(ap, peer);
846  while (GNUNET_ATS_PREFERENCE_END !=
848  {
849  switch (kind)
850  {
852  count++;
853  (void)va_arg(ap, double);
854  break;
855 
857  count++;
858  (void)va_arg(ap, double);
859  break;
860 
861  default:
862  GNUNET_assert(0);
863  }
864  }
865  va_end(ap);
866  env = GNUNET_MQ_msg_extra(m,
867  count * sizeof(struct PreferenceInformation),
869  m->num_preferences = htonl(count);
870  m->peer = *peer;
871  pi = (struct PreferenceInformation *)&m[1];
872  count = 0;
873  va_start(ap, peer);
874  while (GNUNET_ATS_PREFERENCE_END != (kind =
876  {
877  pi[count].preference_kind = htonl(kind);
878  switch (kind)
879  {
881  pi[count].preference_value = (float)va_arg(ap, double);
882 
883  count++;
884  break;
885 
887  pi[count].preference_value = (float)va_arg(ap, double);
888 
889  count++;
890  break;
891 
892  default:
893  GNUNET_assert(0);
894  }
895  }
896  va_end(ap);
897  GNUNET_MQ_send(ph->mq,
898  env);
899 }
900 
901 
911 void
913  const struct GNUNET_PeerIdentity *peer,
914  const struct GNUNET_TIME_Relative scope,
915  ...)
916 {
917  struct GNUNET_MQ_Envelope *env;
919  uint32_t count;
920  struct PreferenceInformation *pi;
921  va_list ap;
922  enum GNUNET_ATS_PreferenceKind kind;
923 
924  if (NULL == ph->mq)
925  return;
926  count = 0;
927  va_start(ap, scope);
928  while (GNUNET_ATS_PREFERENCE_END !=
930  {
931  switch (kind)
932  {
934  count++;
935  (void)va_arg(ap, double);
936  break;
937 
939  count++;
940  (void)va_arg(ap, double);
941  break;
942 
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;
968 
970  pi[count].preference_value = (float)va_arg(ap, double);
971 
972  count++;
973  break;
974 
975  default:
976  GNUNET_assert(0);
977  }
978  }
979  va_end(ap);
980  GNUNET_MQ_send(ph->mq,
981  env);
982 }
983 
984 /* 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:440
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:900
uint16_t address_length
Definition: ats.h:280
uint32_t start_flag
NBO value of an enum StartFlag.
Definition: ats.h:77
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:310
struct GNUNET_MQ_Handle * mq
Connection to ATS service.
uint16_t plugin_name_length
Definition: ats.h:285
struct GNUNET_MessageHeader header
Type is GNUNET_MESSAGE_TYPE_ATS_PEER_INFORMATION.
Definition: ats.h:275
uint32_t preference_kind
An enum GNUNET_ATS_PreferenceKind in NBO.
Definition: ats.h:412
uint32_t address_local_info
Local-only information of the address, see enum GNUNET_HELLO_AddressInfo.
Definition: ats.h:321
void * rcb_cls
Closure for rcb.
uint32_t id
ID used to match replies to this request.
Definition: ats.h:342
#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:78
static struct GNUNET_IDENTITY_Handle * id
Handle to identity service.
#define GNUNET_OK
Named constants for return values.
Definition: gnunet_common.h:75
Performance monitoring client that does NOT want to learn about changes in performance characteristic...
Definition: ats.h:53
#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:315
uint32_t num_feedback
Number of feedback values included.
Definition: ats.h:459
#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:290
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:395
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:1237
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:305
#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:639
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:469
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:76
struct GNUNET_TIME_RelativeNBO GNUNET_TIME_relative_hton(struct GNUNET_TIME_Relative a)
Convert relative time to network byte order.
Definition: time.c:623
Client to service: please give us an overview of the addresses.
Definition: ats.h:333
uint32_t num_preferences
How many struct PreferenceInformation entries follow this struct?
Definition: ats.h:435
#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:84
int32_t all
GNUNET_YES to get information about all addresses, GNUNET_NO to only return addresses that are in use...
Definition: ats.h:353
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:450
struct GNUNET_TIME_RelativeNBO scope
Relative time describing for which time interval this feedback is.
Definition: ats.h:464
void GNUNET_ATS_reserve_bandwidth_cancel(struct GNUNET_ATS_ReservationContext *rc)
Cancel request for reserving bandwidth.
configuration data
Definition: configuration.c:83
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:131
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:408
struct GNUNET_ATS_AddressListHandle * prev
Kept in a DLL.
Client to ATS: I have a performance preference for a peer.
Definition: ats.h:425
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:821
int32_t size
Desired reservation.
#define GNUNET_YES
Definition: gnunet_common.h:77
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:351
#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:295
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:400
#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:418
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:347
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:374
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:68
Performance monitoring client that wants to learn about changes in performance characteristics.
Definition: ats.h:47
#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:956