GNUnet  0.10.x
ats_api_scheduling.c
Go to the documentation of this file.
1 /*
2  This file is part of GNUnet.
3  Copyright (C) 2010-2015 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 */
34 #include "platform.h"
35 #include "gnunet_ats_service.h"
36 #include "ats.h"
37 
41 #define INTERFACE_PROCESSING_INTERVAL GNUNET_TIME_relative_multiply (GNUNET_TIME_UNIT_MINUTES, 2)
42 
43 #define LOG(kind,...) GNUNET_log_from(kind, "ats-scheduling-api", __VA_ARGS__)
44 
48 #define NOT_FOUND 0
49 
50 
57 {
58 
63 
68 
74 
79 
88  uint32_t slot;
89 
96 };
97 
98 
103 {
104 
109 
114 
119 
124 
132 
137 
142 
146  unsigned int session_array_size;
147 
148 };
149 
150 
156 static void
158 
159 
165 static void
166 reconnect_task (void *cls)
167 {
168  struct GNUNET_ATS_SchedulingHandle *sh = cls;
169 
170  sh->task = NULL;
171  reconnect (sh);
172 }
173 
174 
180 static void
182 {
183  if (NULL != sh->mq)
184  {
185  GNUNET_MQ_destroy (sh->mq);
186  sh->mq = NULL;
187  }
188  sh->suggest_cb (sh->suggest_cb_cls,
189  NULL, NULL, NULL,
195  sh);
196 }
197 
198 
207 static struct GNUNET_ATS_AddressRecord *
209  uint32_t session_id,
210  const struct GNUNET_PeerIdentity *peer)
211 {
212  struct GNUNET_ATS_AddressRecord *ar;
213 
214  if (session_id >= sh->session_array_size)
215  {
216  GNUNET_break (0);
217  return NULL;
218  }
219  if (0 == session_id)
220  return NULL;
221  ar = sh->session_array[session_id];
222  if (NULL == ar)
223  {
224  GNUNET_break (0);
225  return NULL;
226  }
227  if (NULL == ar->address)
228  {
229  /* address was destroyed in the meantime, this can happen
230  as we communicate asynchronously with the ATS service. */
231  return NULL;
232  }
233  if (0 != GNUNET_memcmp (peer,
234  &ar->address->peer))
235  {
236  GNUNET_break (0);
237  return NULL;
238  }
239  return ar;
240 }
241 
242 
249 static uint32_t
251 {
252  static uint32_t off;
253  uint32_t i;
254 
256  i = 0;
257  while ( ( (NOT_FOUND == off) ||
258  (NULL != sh->session_array[off % sh->session_array_size]) ) &&
259  (i < sh->session_array_size) )
260  {
261  off++;
262  i++;
263  }
264  if ( (NOT_FOUND != off % sh->session_array_size) &&
265  (NULL == sh->session_array[off % sh->session_array_size]) )
266  return off;
267  i = sh->session_array_size;
269  sh->session_array_size,
270  sh->session_array_size * 2);
271  return i;
272 }
273 
274 
283 static uint32_t
285  struct GNUNET_ATS_Session *session,
286  const struct GNUNET_HELLO_Address *address)
287 {
288  uint32_t i;
289 
290  if (NULL == address)
291  {
292  GNUNET_break (0);
293  return NOT_FOUND;
294  }
295  for (i = 1; i < sh->session_array_size; i++)
296  if ( (NULL != sh->session_array[i]) &&
297  (GNUNET_NO == sh->session_array[i]->in_destroy) &&
298  ( (session == sh->session_array[i]->session) ||
299  (NULL == sh->session_array[i]->session) ) &&
300  (0 == GNUNET_memcmp (&address->peer,
301  &sh->session_array[i]->address->peer)) &&
302  (0 == GNUNET_HELLO_address_cmp (address,
303  sh->session_array[i]->address)) )
304  return i;
305  return NOT_FOUND;
306 }
307 
308 
316 static void
318  uint32_t session_id)
319 {
320  struct GNUNET_ATS_AddressRecord *ar;
321 
322  if (NOT_FOUND == session_id)
323  return;
324  if (session_id >= sh->session_array_size)
325  {
326  GNUNET_break (0);
327  force_reconnect (sh);
328  return;
329  }
330  /* this slot should have been removed from remove_session before */
331  ar = sh->session_array[session_id];
332  if (NULL != ar->session)
333  {
334  GNUNET_break (0);
335  force_reconnect (sh);
336  return;
337  }
339  GNUNET_free (ar);
340  sh->session_array[session_id] = NULL;
341 }
342 
343 
351 static void
353  const struct GNUNET_ATS_SessionReleaseMessage *srm)
354 {
355  struct GNUNET_ATS_SchedulingHandle *sh = cls;
356 
357  /* Note: peer field in srm not necessary right now,
358  but might be good to have in the future */
359  release_session (sh,
360  ntohl (srm->session_id));
361 }
362 
363 
371 static void
373  const struct AddressSuggestionMessage *m)
374 {
375  struct GNUNET_ATS_SchedulingHandle *sh = cls;
376  struct GNUNET_ATS_AddressRecord *ar;
377  uint32_t session_id;
378 
379  session_id = ntohl (m->session_id);
380  if (0 == session_id)
381  {
382  GNUNET_break (0);
383  force_reconnect (sh);
384  return;
385  }
386  ar = find_session (sh,
387  session_id,
388  &m->peer);
389  if (NULL == ar)
390  {
391  GNUNET_break (0);
392  force_reconnect (sh);
393  return;
394  }
395  if (NULL == sh->suggest_cb)
396  return;
397  if (GNUNET_YES == ar->in_destroy)
398  {
399  /* ignore suggestion, as this address is dying, unless BW is 0,
400  in that case signal 'disconnect' via BW 0 */
401  if ( (0 == ntohl (m->bandwidth_out.value__)) &&
402  (0 == ntohl (m->bandwidth_in.value__)) )
403  {
405  "ATS suggests disconnect from peer `%s' with BW %u/%u\n",
406  GNUNET_i2s (&ar->address->peer),
407  (unsigned int) ntohl (m->bandwidth_out.value__),
408  (unsigned int) ntohl (m->bandwidth_in.value__));
409  sh->suggest_cb (sh->suggest_cb_cls,
410  &m->peer,
411  NULL,
412  NULL,
413  m->bandwidth_out,
414  m->bandwidth_in);
415  }
416  return;
417  }
418  if ( (NULL == ar->session) &&
421  {
422  GNUNET_break (0);
423  return;
424  }
427  "ATS suggests address slot %u for peer `%s' using plugin %s\n",
428  ar->slot,
429  GNUNET_i2s (&ar->address->peer),
430  ar->address->transport_name);
431  sh->suggest_cb (sh->suggest_cb_cls,
432  &m->peer,
433  ar->address,
434  ar->session,
435  m->bandwidth_out,
436  m->bandwidth_in);
437 }
438 
439 
447 static void
448 error_handler (void *cls,
449  enum GNUNET_MQ_Error error)
450 {
451  struct GNUNET_ATS_SchedulingHandle *sh = cls;
452 
454  "ATS connection died (code %d), reconnecting\n",
455  (int) error);
456  force_reconnect (sh);
457 }
458 
459 
467 static void
469  const struct GNUNET_ATS_AddressRecord *ar)
470 {
471  struct GNUNET_MQ_Envelope *ev;
472  struct AddressAddMessage *m;
473  char *pm;
474  size_t namelen;
475  size_t msize;
476 
477  if (NULL == sh->mq)
478  return; /* disconnected, skip for now */
480  namelen = strlen (ar->address->transport_name) + 1;
481  msize = ar->address->address_length + namelen;
483  m->peer = ar->address->peer;
484  m->address_length = htons (ar->address->address_length);
485  m->address_local_info = htonl ((uint32_t) ar->address->local_info);
486  m->plugin_name_length = htons (namelen);
487  m->session_id = htonl (ar->slot);
488  m->properties = ar->properties;
489 
491  "Adding address for peer `%s', plugin `%s', session %p slot %u\n",
492  GNUNET_i2s (&ar->address->peer),
493  ar->address->transport_name,
494  ar->session,
495  ar->slot);
496  pm = (char *) &m[1];
497  GNUNET_memcpy (pm,
498  ar->address->address,
499  ar->address->address_length);
500  if (NULL != ar->address->transport_name)
502  ar->address->transport_name,
503  namelen);
504  GNUNET_MQ_send (sh->mq, ev);
505 }
506 
507 
513 static void
515 {
516  struct GNUNET_MQ_MessageHandler handlers[] = {
517  GNUNET_MQ_hd_fixed_size (ats_session_release,
520  sh),
521  GNUNET_MQ_hd_fixed_size (ats_address_suggestion,
524  sh),
526  };
527  struct GNUNET_MQ_Envelope *ev;
528  struct ClientStartMessage *init;
529  unsigned int i;
530  struct GNUNET_ATS_AddressRecord *ar;
531 
532  GNUNET_assert (NULL == sh->mq);
533  sh->mq = GNUNET_CLIENT_connect (sh->cfg,
534  "ats",
535  handlers,
536  &error_handler,
537  sh);
538  if (NULL == sh->mq)
539  {
540  GNUNET_break (0);
541  force_reconnect (sh);
542  return;
543  }
544  ev = GNUNET_MQ_msg (init,
546  init->start_flag = htonl (START_FLAG_SCHEDULING);
547  GNUNET_MQ_send (sh->mq, ev);
548  if (NULL == sh->mq)
549  return;
550  for (i=0;i<sh->session_array_size;i++)
551  {
552  ar = sh->session_array[i];
553  if (NULL == ar)
554  continue;
555  send_add_address_message (sh, ar);
556  if (NULL == sh->mq)
557  return;
558  }
559 }
560 
561 
573  void *suggest_cb_cls)
574 {
576 
578  sh->cfg = cfg;
579  sh->suggest_cb = suggest_cb;
582  sh->session_array_size,
583  4);
584  reconnect (sh);
585  return sh;
586 }
587 
588 
594 void
596 {
597  struct GNUNET_ATS_AddressRecord *ar;
598  unsigned int i;
599 
600  if (NULL != sh->mq)
601  {
602  GNUNET_MQ_destroy (sh->mq);
603  sh->mq = NULL;
604  }
605  if (NULL != sh->task)
606  {
608  sh->task = NULL;
609  }
610  for (i=0;i<sh->session_array_size;i++)
611  {
612  if (NULL != (ar = sh->session_array[i]))
613  {
615  GNUNET_free (ar);
616  sh->session_array[i] = NULL;
617  }
618  }
620  sh->session_array_size,
621  0);
622  GNUNET_free (sh);
623 }
624 
625 
640  const struct GNUNET_HELLO_Address *address,
641  struct GNUNET_ATS_Session *session,
642  const struct GNUNET_ATS_Properties *prop)
643 {
644  struct GNUNET_ATS_AddressRecord *ar;
645  size_t namelen;
646  size_t msize;
647  uint32_t s;
648 
649  if (NULL == address)
650  {
651  /* we need a valid address */
652  GNUNET_break (0);
653  return NULL;
654  }
656  namelen = strlen (address->transport_name) + 1;
657  msize = address->address_length + namelen;
658  if ((msize + sizeof (struct AddressUpdateMessage) >= GNUNET_MAX_MESSAGE_SIZE) ||
659  (address->address_length >= GNUNET_MAX_MESSAGE_SIZE) ||
660  (namelen >= GNUNET_MAX_MESSAGE_SIZE) )
661  {
662  /* address too large for us, this should not happen */
663  GNUNET_break (0);
664  return NULL;
665  }
666 
667  if (NOT_FOUND !=
668  find_session_id (sh,
669  session,
670  address))
671  {
672  /* Already existing, nothing todo, but this should not happen */
673  GNUNET_break (0);
674  return NULL;
675  }
676  s = find_empty_session_slot (sh);
677  ar = GNUNET_new (struct GNUNET_ATS_AddressRecord);
678  ar->sh = sh;
679  ar->slot = s;
680  ar->session = session;
681  ar->address = GNUNET_HELLO_address_copy (address);
683  prop);
684  sh->session_array[s] = ar;
685  send_add_address_message (sh, ar);
686  return ar;
687 }
688 
689 
696 void
698  struct GNUNET_ATS_Session *session)
699 {
700  GNUNET_break (NULL == ar->session);
701  ar->session = session;
702 }
703 
704 
717 int
719  struct GNUNET_ATS_Session *session)
720 {
721  GNUNET_assert (session == ar->session);
722  ar->session = NULL;
725  {
727  return GNUNET_YES;
728  }
729  return GNUNET_NO;
730 }
731 
732 
744 void
746  const struct GNUNET_ATS_Properties *prop)
747 {
748  struct GNUNET_ATS_SchedulingHandle *sh = ar->sh;
749  struct GNUNET_MQ_Envelope *ev;
750  struct AddressUpdateMessage *m;
751 
753  "Updating address for peer `%s', plugin `%s', session %p slot %u\n",
754  GNUNET_i2s (&ar->address->peer),
755  ar->address->transport_name,
756  ar->session,
757  ar->slot);
760  prop);
761  if (NULL == sh->mq)
762  return; /* disconnected, skip for now */
764  m->session_id = htonl (ar->slot);
765  m->peer = ar->address->peer;
766  m->properties = ar->properties;
767  GNUNET_MQ_send (sh->mq,
768  ev);
769 }
770 
771 
777 void
779 {
780  struct GNUNET_ATS_SchedulingHandle *sh = ar->sh;
781  struct GNUNET_MQ_Envelope *ev;
782  struct AddressDestroyedMessage *m;
783 
785  "Deleting address for peer `%s', plugin `%s', slot %u session %p\n",
786  GNUNET_i2s (&ar->address->peer),
787  ar->address->transport_name,
788  ar->slot,
789  ar->session);
790  GNUNET_break (NULL == ar->session);
791  ar->session = NULL;
792  ar->in_destroy = GNUNET_YES;
793  if (NULL == sh->mq)
794  return;
796  m->session_id = htonl (ar->slot);
797  m->peer = ar->address->peer;
798  GNUNET_MQ_send (sh->mq, ev);
799 }
800 
801 
802 /* end of ats_api_scheduling.c */
#define GNUNET_MESSAGE_TYPE_ATS_ADDRESS_DESTROYED
Type of the &#39;struct AddressDestroyedMessage&#39; sent by clients to ATS to inform ATS about an address be...
static struct GNUNET_ATS_AddressRecord * find_session(struct GNUNET_ATS_SchedulingHandle *sh, uint32_t session_id, const struct GNUNET_PeerIdentity *peer)
Find the session object corresponding to the given session ID.
size_t address_length
Number of bytes in address.
struct GNUNET_SCHEDULER_Task * task
Task to trigger reconnect.
uint16_t address_length
Number of bytes in the address that follows this struct.
Definition: ats.h:122
enum GNUNET_HELLO_AddressInfo local_info
Extended information about address.
#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...
static void send_add_address_message(struct GNUNET_ATS_SchedulingHandle *sh, const struct GNUNET_ATS_AddressRecord *ar)
Generate and transmit the struct AddressAddMessage for the given address record.
struct GNUNET_PeerIdentity peer
Which peer is this about? (Technically redundant, as the session_id should be sufficient, but enables ATS service to find the session faster).
Definition: ats.h:180
struct GNUNET_ATS_AddressRecord ** session_array
Array of session objects (we need to translate them to numbers and back for the protocol; the offset ...
const void * address
Binary representation of the address (plugin-specific).
static struct GNUNET_TIME_Relative backoff
How long should we wait to reconnect?
Definition: resolver_api.c:81
struct GNUNET_PeerIdentity peer
Identity of the peer that this address is for.
Definition: ats.h:132
struct GNUNET_ATS_PropertiesNBO properties
Performance properties of the address.
Definition: ats.h:149
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
Handle to the ATS subsystem for bandwidth/transport scheduling information.
const struct GNUNET_CONFIGURATION_Handle * cfg
Our configuration.
uint32_t start_flag
NBO value of an enum StartFlag.
Definition: ats.h:80
GNUNET_ATS_AddressSuggestionCallback suggest_cb
Callback to invoke on suggestions.
GNUNET_MQ_Error
Error codes for the queue.
struct GNUNET_PeerIdentity peer
Which peer is this about? (Technically redundant, as the session_id should be sufficient, but enables ATS service to find the session faster).
Definition: ats.h:212
#define GNUNET_assert(cond)
Use this for fatal errors that cannot be handled.
#define GNUNET_MESSAGE_TYPE_ATS_ADDRESS_SUGGESTION
Type of the &#39;struct AddressSuggestionMessage&#39; sent by ATS to clients to suggest switching to a differ...
void GNUNET_ATS_properties_hton(struct GNUNET_ATS_PropertiesNBO *nbo, const struct GNUNET_ATS_Properties *hbo)
Convert ATS properties from host to network byte order.
struct GNUNET_ATS_SchedulingHandle * GNUNET_ATS_scheduling_init(const struct GNUNET_CONFIGURATION_Handle *cfg, GNUNET_ATS_AddressSuggestionCallback suggest_cb, void *suggest_cb_cls)
Initialize the ATS subsystem.
void GNUNET_ATS_scheduling_done(struct GNUNET_ATS_SchedulingHandle *sh)
Client is done with ATS scheduling, release resources.
uint32_t session_id
Number the client used to identify the session.
Definition: ats.h:231
#define GNUNET_MQ_hd_fixed_size(name, code, str, ctx)
#define GNUNET_MQ_msg(mvar, type)
Allocate a GNUNET_MQ_Envelope.
Definition: gnunet_mq_lib.h:67
static struct GNUNET_HashCode session_id
struct GNUNET_BANDWIDTH_Value32NBO bandwidth_in
How much bandwidth we are allowed for receiving.
Definition: ats.h:276
#define GNUNET_NO
Definition: gnunet_common.h:81
uint32_t scope
Which network scope does the respective address belong to? This property does not change...
struct GNUNET_BANDWIDTH_Value32NBO bandwidth_out
How much bandwidth we are allowed for sending.
Definition: ats.h:271
#define GNUNET_new(type)
Allocate a struct or union of the given type.
uint32_t session_id
Internal number this client uses to refer to this address.
Definition: ats.h:205
#define LOG(kind,...)
ATS performance characteristics for an address.
uint32_t session_id
Internal number this client uses to refer to the address this suggestion is about.
Definition: ats.h:259
#define GNUNET_break(cond)
Use this for internal assertion violations that are not fatal (can be handled) but should not occur...
void(* GNUNET_ATS_AddressSuggestionCallback)(void *cls, const struct GNUNET_PeerIdentity *peer, const struct GNUNET_HELLO_Address *address, struct GNUNET_ATS_Session *session, struct GNUNET_BANDWIDTH_Value32NBO bandwidth_out, struct GNUNET_BANDWIDTH_Value32NBO bandwidth_in)
Signature of a function called by ATS with the current bandwidth and address preferences as determine...
Message used to notify ATS that the performance characteristics for an address have changed...
Definition: ats.h:163
uint32_t value__
The actual value (bytes per second).
struct GNUNET_ATS_Session * session
Session handle.
int GNUNET_HELLO_address_check_option(const struct GNUNET_HELLO_Address *address, enum GNUNET_HELLO_AddressInfo option)
Check if an address has a local option set.
Definition: address.c:39
static uint32_t find_empty_session_slot(struct GNUNET_ATS_SchedulingHandle *sh)
Get an available session ID.
static struct GNUNET_ARM_MonitorHandle * m
Monitor connection with ARM.
Definition: gnunet-arm.c:99
#define GNUNET_MESSAGE_TYPE_ATS_SESSION_RELEASE
Type of the &#39;struct SessionReleaseMessage&#39; sent by ATS to client to confirm that a session ID was des...
int GNUNET_HELLO_address_cmp(const struct GNUNET_HELLO_Address *a1, const struct GNUNET_HELLO_Address *a2)
Compare two addresses.
Definition: address.c:130
#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
#define NOT_FOUND
Session ID we use if there is no session / slot.
#define GNUNET_array_grow(arr, size, tsize)
Grow a well-typed (!) array.
#define GNUNET_memcpy(dst, src, n)
void * suggest_cb_cls
Closure for suggest_cb.
This is a scheduling client (aka transport service)
Definition: ats.h:43
Information about ongoing sessions of the transport client.
This is an inbound address and cannot be used to initiate an outbound connection to another peer...
void GNUNET_ATS_address_update(struct GNUNET_ATS_AddressRecord *ar, const struct GNUNET_ATS_Properties *prop)
We have updated performance statistics for a given address.
unsigned int session_array_size
Size of the session_array.
const char * transport_name
Name of the transport plugin enabling the communication using this address.
Information we track per address, incoming or outgoing.
struct GNUNET_ATS_AddressRecord * GNUNET_ATS_address_add(struct GNUNET_ATS_SchedulingHandle *sh, const struct GNUNET_HELLO_Address *address, struct GNUNET_ATS_Session *session, const struct GNUNET_ATS_Properties *prop)
We have a new address ATS should know.
static void error_handler(void *cls, enum GNUNET_MQ_Error error)
We encountered an error handling the MQ to the ATS service.
Message handler for a specific message type.
uint16_t plugin_name_length
Number of bytes in the plugin name that follows this struct.
Definition: ats.h:127
static struct GNUNET_CONFIGURATION_Handle * cfg
Our configuration.
Definition: gnunet-arm.c:104
int GNUNET_ATS_address_del_session(struct GNUNET_ATS_AddressRecord *ar, struct GNUNET_ATS_Session *session)
A session was destroyed, disassociate it from the given address record.
struct GNUNET_ATS_PropertiesNBO properties
Performance data about the address.
struct GNUNET_TESTBED_Peer * peer
The peer associated with this model.
static void handle_ats_session_release(void *cls, const struct GNUNET_ATS_SessionReleaseMessage *srm)
Type of a function to call when we receive a session release message from the service.
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?
struct GNUNET_ATS_SchedulingHandle * sh
Scheduling handle this address record belongs to.
#define GNUNET_TIME_UNIT_ZERO
Relative time zero.
#define GNUNET_memcmp(a, b)
Compare memory in a and b, where both must be of the same pointer type.
#define GNUNET_MAX_MESSAGE_SIZE
Largest supported message (to be precise, one byte more than the largest possible message...
ATS Service suggests to the transport service to use the address identified by the given session_id f...
Definition: ats.h:248
static void suggest_cb(void *cls, const struct GNUNET_PeerIdentity *pid, const char *address)
Function called by the solver to prompt the transport to try out a new address.
enum GNUNET_NetworkType scope
Which network scope does the respective address belong to? This property does not change...
struct GNUNET_TIME_Relative backoff
Reconnect backoff delay.
Handle to a message queue.
Definition: mq.c:85
The identity of the host (wraps the signing key of the peer).
uint32_t address_local_info
Local-only information of the address, see enum GNUNET_HELLO_AddressInfo.
Definition: ats.h:144
#define GNUNET_BANDWIDTH_ZERO
Convenience definition to use for 0-bandwidth.
struct GNUNET_MQ_Handle * mq
Message queue for sending requests to the ATS service.
static void reconnect_task(void *cls)
Re-establish the connection to the ATS service.
struct GNUNET_HELLO_Address * address
Address data.
configuration data
Definition: configuration.c:85
static void reconnect(struct GNUNET_ATS_SchedulingHandle *sh)
Re-establish the connection to the ATS service.
An address for communicating with a peer.
struct GNUNET_HELLO_Address * GNUNET_HELLO_address_copy(const struct GNUNET_HELLO_Address *address)
Copy an address struct.
Definition: address.c:109
Automatic transport selection and outbound bandwidth determination.
static uint32_t find_session_id(struct GNUNET_ATS_SchedulingHandle *sh, struct GNUNET_ATS_Session *session, const struct GNUNET_HELLO_Address *address)
Get the ID for the given session object.
Entry in list of pending tasks.
Definition: scheduler.c:134
void GNUNET_ATS_address_destroy(struct GNUNET_ATS_AddressRecord *ar)
An address got destroyed, stop using it as a valid address.
void GNUNET_MQ_destroy(struct GNUNET_MQ_Handle *mq)
Destroy the message queue.
Definition: mq.c:824
struct GNUNET_ATS_PropertiesNBO properties
Performance properties of the address.
Definition: ats.h:185
#define GNUNET_YES
Definition: gnunet_common.h:80
struct GNUNET_PeerIdentity peer
Which peer is this about? (Technically redundant, as the session_id should be sufficient, but may enable client to find the session faster and/or check consistency).
Definition: ats.h:266
int in_destroy
We&#39;re about to destroy this address record, just ATS does not know this yet.
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_MESSAGE_TYPE_ATS_ADDRESS_ADD
Type of the &#39;struct AddressUpdateMessage&#39; sent by client to ATS to add a new address.
Message sent by ATS client to ATS service when an address was destroyed and must thus henceforth no l...
Definition: ats.h:195
static void handle_ats_address_suggestion(void *cls, const struct AddressSuggestionMessage *m)
Type of a function to call when we receive a address suggestion message from the service.
void GNUNET_ATS_address_add_session(struct GNUNET_ATS_AddressRecord *ar, struct GNUNET_ATS_Session *session)
An address was used to initiate a session.
uint32_t session_id
Internal number this client will henceforth use to refer to this address.
Definition: ats.h:138
Message sent by ATS service to client to confirm that it is done using the given session ID...
Definition: ats.h:221
ATS performance characteristics for an address in network byte order (for IPC).
static void release_session(struct GNUNET_ATS_SchedulingHandle *sh, uint32_t session_id)
Release the session slot from the session table (ATS service is also done using it).
uint32_t slot
Which slot (index) in the session array does this record correspond to? FIXME: a linear search on thi...
const char * GNUNET_i2s(const struct GNUNET_PeerIdentity *pid)
Convert a peer identity to a string (for printing debug messages).
#define GNUNET_HELLO_address_free(addr)
Free an address.
#define GNUNET_MQ_handler_end()
End-marker for the handlers array.
uint32_t session_id
Internal number this client uses to refer to this address.
Definition: ats.h:173
automatic transport selection messages
#define GNUNET_MESSAGE_TYPE_ATS_ADDRESS_UPDATE
Type of the &#39;struct AddressUpdateMessage&#39; sent by clients to ATS to inform ATS about performance chan...
First message any client sends to ATS, used to self-identify (what type of client this is)...
Definition: ats.h:70
#define GNUNET_free(ptr)
Wrapper around free.
static void force_reconnect(struct GNUNET_ATS_SchedulingHandle *sh)
Disconnect from ATS and then reconnect.
Time for relative time used by GNUnet, in microseconds.
static struct GNUNET_TRANSPORT_PluginMonitor * pm
Handle if we are monitoring plugin session activity.
Category of last resort.
Definition: gnunet_nt_lib.h:40
void * GNUNET_SCHEDULER_cancel(struct GNUNET_SCHEDULER_Task *task)
Cancel the task with the specified identifier.
Definition: scheduler.c:965
Scheduling client to ATS service: here is another address you can use.
Definition: ats.h:112