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 
61 
66 
72 
77 
86  uint32_t slot;
87 
94 };
95 
96 
105 
110 
115 
120 
128 
133 
138 
142  unsigned int session_array_size;
143 };
144 
145 
151 static void
153 
154 
160 static void
161 reconnect_task(void *cls)
162 {
163  struct GNUNET_ATS_SchedulingHandle *sh = cls;
164 
165  sh->task = NULL;
166  reconnect(sh);
167 }
168 
169 
175 static void
177 {
178  if (NULL != sh->mq)
179  {
180  GNUNET_MQ_destroy(sh->mq);
181  sh->mq = NULL;
182  }
183  sh->suggest_cb(sh->suggest_cb_cls,
184  NULL, NULL, NULL,
190  sh);
191 }
192 
193 
202 static struct GNUNET_ATS_AddressRecord *
204  uint32_t session_id,
205  const struct GNUNET_PeerIdentity *peer)
206 {
207  struct GNUNET_ATS_AddressRecord *ar;
208 
209  if (session_id >= sh->session_array_size)
210  {
211  GNUNET_break(0);
212  return NULL;
213  }
214  if (0 == session_id)
215  return NULL;
216  ar = sh->session_array[session_id];
217  if (NULL == ar)
218  {
219  GNUNET_break(0);
220  return NULL;
221  }
222  if (NULL == ar->address)
223  {
224  /* address was destroyed in the meantime, this can happen
225  as we communicate asynchronously with the ATS service. */
226  return NULL;
227  }
228  if (0 != GNUNET_memcmp(peer,
229  &ar->address->peer))
230  {
231  GNUNET_break(0);
232  return NULL;
233  }
234  return ar;
235 }
236 
237 
244 static uint32_t
246 {
247  static uint32_t off;
248  uint32_t i;
249 
251  i = 0;
252  while (((NOT_FOUND == off) ||
253  (NULL != sh->session_array[off % sh->session_array_size])) &&
254  (i < sh->session_array_size))
255  {
256  off++;
257  i++;
258  }
259  if ((NOT_FOUND != off % sh->session_array_size) &&
260  (NULL == sh->session_array[off % sh->session_array_size]))
261  return off;
262  i = sh->session_array_size;
264  sh->session_array_size,
265  sh->session_array_size * 2);
266  return i;
267 }
268 
269 
278 static uint32_t
280  struct GNUNET_ATS_Session *session,
281  const struct GNUNET_HELLO_Address *address)
282 {
283  uint32_t i;
284 
285  if (NULL == address)
286  {
287  GNUNET_break(0);
288  return NOT_FOUND;
289  }
290  for (i = 1; i < sh->session_array_size; i++)
291  if ((NULL != sh->session_array[i]) &&
292  (GNUNET_NO == sh->session_array[i]->in_destroy) &&
293  ((session == sh->session_array[i]->session) ||
294  (NULL == sh->session_array[i]->session)) &&
295  (0 == GNUNET_memcmp(&address->peer,
296  &sh->session_array[i]->address->peer)) &&
297  (0 == GNUNET_HELLO_address_cmp(address,
298  sh->session_array[i]->address)))
299  return i;
300  return NOT_FOUND;
301 }
302 
303 
311 static void
313  uint32_t session_id)
314 {
315  struct GNUNET_ATS_AddressRecord *ar;
316 
317  if (NOT_FOUND == session_id)
318  return;
319  if (session_id >= sh->session_array_size)
320  {
321  GNUNET_break(0);
322  force_reconnect(sh);
323  return;
324  }
325  /* this slot should have been removed from remove_session before */
326  ar = sh->session_array[session_id];
327  if (NULL != ar->session)
328  {
329  GNUNET_break(0);
330  force_reconnect(sh);
331  return;
332  }
334  GNUNET_free(ar);
335  sh->session_array[session_id] = NULL;
336 }
337 
338 
346 static void
348  const struct GNUNET_ATS_SessionReleaseMessage *srm)
349 {
350  struct GNUNET_ATS_SchedulingHandle *sh = cls;
351 
352  /* Note: peer field in srm not necessary right now,
353  but might be good to have in the future */
354  release_session(sh,
355  ntohl(srm->session_id));
356 }
357 
358 
366 static void
368  const struct AddressSuggestionMessage *m)
369 {
370  struct GNUNET_ATS_SchedulingHandle *sh = cls;
371  struct GNUNET_ATS_AddressRecord *ar;
372  uint32_t session_id;
373 
374  session_id = ntohl(m->session_id);
375  if (0 == session_id)
376  {
377  GNUNET_break(0);
378  force_reconnect(sh);
379  return;
380  }
381  ar = find_session(sh,
382  session_id,
383  &m->peer);
384  if (NULL == ar)
385  {
386  GNUNET_break(0);
387  force_reconnect(sh);
388  return;
389  }
390  if (NULL == sh->suggest_cb)
391  return;
392  if (GNUNET_YES == ar->in_destroy)
393  {
394  /* ignore suggestion, as this address is dying, unless BW is 0,
395  in that case signal 'disconnect' via BW 0 */
396  if ((0 == ntohl(m->bandwidth_out.value__)) &&
397  (0 == ntohl(m->bandwidth_in.value__)))
398  {
400  "ATS suggests disconnect from peer `%s' with BW %u/%u\n",
401  GNUNET_i2s(&ar->address->peer),
402  (unsigned int)ntohl(m->bandwidth_out.value__),
403  (unsigned int)ntohl(m->bandwidth_in.value__));
404  sh->suggest_cb(sh->suggest_cb_cls,
405  &m->peer,
406  NULL,
407  NULL,
408  m->bandwidth_out,
409  m->bandwidth_in);
410  }
411  return;
412  }
413  if ((NULL == ar->session) &&
416  {
417  GNUNET_break(0);
418  return;
419  }
422  "ATS suggests address slot %u for peer `%s' using plugin %s\n",
423  ar->slot,
424  GNUNET_i2s(&ar->address->peer),
425  ar->address->transport_name);
426  sh->suggest_cb(sh->suggest_cb_cls,
427  &m->peer,
428  ar->address,
429  ar->session,
430  m->bandwidth_out,
431  m->bandwidth_in);
432 }
433 
434 
442 static void
443 error_handler(void *cls,
444  enum GNUNET_MQ_Error error)
445 {
446  struct GNUNET_ATS_SchedulingHandle *sh = cls;
447 
449  "ATS connection died (code %d), reconnecting\n",
450  (int)error);
451  force_reconnect(sh);
452 }
453 
454 
462 static void
464  const struct GNUNET_ATS_AddressRecord *ar)
465 {
466  struct GNUNET_MQ_Envelope *ev;
467  struct AddressAddMessage *m;
468  char *pm;
469  size_t namelen;
470  size_t msize;
471 
472  if (NULL == sh->mq)
473  return; /* disconnected, skip for now */
475  namelen = strlen(ar->address->transport_name) + 1;
476  msize = ar->address->address_length + namelen;
478  m->peer = ar->address->peer;
479  m->address_length = htons(ar->address->address_length);
480  m->address_local_info = htonl((uint32_t)ar->address->local_info);
481  m->plugin_name_length = htons(namelen);
482  m->session_id = htonl(ar->slot);
483  m->properties = ar->properties;
484 
486  "Adding address for peer `%s', plugin `%s', session %p slot %u\n",
487  GNUNET_i2s(&ar->address->peer),
488  ar->address->transport_name,
489  ar->session,
490  ar->slot);
491  pm = (char *)&m[1];
492  GNUNET_memcpy(pm,
493  ar->address->address,
494  ar->address->address_length);
495  if (NULL != ar->address->transport_name)
497  ar->address->transport_name,
498  namelen);
499  GNUNET_MQ_send(sh->mq, ev);
500 }
501 
502 
508 static void
510 {
511  struct GNUNET_MQ_MessageHandler handlers[] = {
512  GNUNET_MQ_hd_fixed_size(ats_session_release,
515  sh),
516  GNUNET_MQ_hd_fixed_size(ats_address_suggestion,
519  sh),
521  };
522  struct GNUNET_MQ_Envelope *ev;
523  struct ClientStartMessage *init;
524  unsigned int i;
525  struct GNUNET_ATS_AddressRecord *ar;
526 
527  GNUNET_assert(NULL == sh->mq);
528  sh->mq = GNUNET_CLIENT_connect(sh->cfg,
529  "ats",
530  handlers,
531  &error_handler,
532  sh);
533  if (NULL == sh->mq)
534  {
535  GNUNET_break(0);
536  force_reconnect(sh);
537  return;
538  }
539  ev = GNUNET_MQ_msg(init,
541  init->start_flag = htonl(START_FLAG_SCHEDULING);
542  GNUNET_MQ_send(sh->mq, ev);
543  if (NULL == sh->mq)
544  return;
545  for (i = 0; i < sh->session_array_size; i++)
546  {
547  ar = sh->session_array[i];
548  if (NULL == ar)
549  continue;
550  send_add_address_message(sh, ar);
551  if (NULL == sh->mq)
552  return;
553  }
554 }
555 
556 
568  void *suggest_cb_cls)
569 {
571 
573  sh->cfg = cfg;
574  sh->suggest_cb = suggest_cb;
577  sh->session_array_size,
578  4);
579  reconnect(sh);
580  return sh;
581 }
582 
583 
589 void
591 {
592  struct GNUNET_ATS_AddressRecord *ar;
593  unsigned int i;
594 
595  if (NULL != sh->mq)
596  {
597  GNUNET_MQ_destroy(sh->mq);
598  sh->mq = NULL;
599  }
600  if (NULL != sh->task)
601  {
603  sh->task = NULL;
604  }
605  for (i = 0; i < sh->session_array_size; i++)
606  {
607  if (NULL != (ar = sh->session_array[i]))
608  {
610  GNUNET_free(ar);
611  sh->session_array[i] = NULL;
612  }
613  }
615  sh->session_array_size,
616  0);
617  GNUNET_free(sh);
618 }
619 
620 
635  const struct GNUNET_HELLO_Address *address,
636  struct GNUNET_ATS_Session *session,
637  const struct GNUNET_ATS_Properties *prop)
638 {
639  struct GNUNET_ATS_AddressRecord *ar;
640  size_t namelen;
641  size_t msize;
642  uint32_t s;
643 
644  if (NULL == address)
645  {
646  /* we need a valid address */
647  GNUNET_break(0);
648  return NULL;
649  }
651  namelen = strlen(address->transport_name) + 1;
652  msize = address->address_length + namelen;
653  if ((msize + sizeof(struct AddressUpdateMessage) >= GNUNET_MAX_MESSAGE_SIZE) ||
654  (address->address_length >= GNUNET_MAX_MESSAGE_SIZE) ||
655  (namelen >= GNUNET_MAX_MESSAGE_SIZE))
656  {
657  /* address too large for us, this should not happen */
658  GNUNET_break(0);
659  return NULL;
660  }
661 
662  if (NOT_FOUND !=
663  find_session_id(sh,
664  session,
665  address))
666  {
667  /* Already existing, nothing todo, but this should not happen */
668  GNUNET_break(0);
669  return NULL;
670  }
671  s = find_empty_session_slot(sh);
673  ar->sh = sh;
674  ar->slot = s;
675  ar->session = session;
676  ar->address = GNUNET_HELLO_address_copy(address);
678  prop);
679  sh->session_array[s] = ar;
680  send_add_address_message(sh, ar);
681  return ar;
682 }
683 
684 
691 void
693  struct GNUNET_ATS_Session *session)
694 {
695  GNUNET_break(NULL == ar->session);
696  ar->session = session;
697 }
698 
699 
712 int
714  struct GNUNET_ATS_Session *session)
715 {
716  GNUNET_assert(session == ar->session);
717  ar->session = NULL;
720  {
722  return GNUNET_YES;
723  }
724  return GNUNET_NO;
725 }
726 
727 
739 void
741  const struct GNUNET_ATS_Properties *prop)
742 {
743  struct GNUNET_ATS_SchedulingHandle *sh = ar->sh;
744  struct GNUNET_MQ_Envelope *ev;
745  struct AddressUpdateMessage *m;
746 
748  "Updating address for peer `%s', plugin `%s', session %p slot %u\n",
749  GNUNET_i2s(&ar->address->peer),
750  ar->address->transport_name,
751  ar->session,
752  ar->slot);
755  prop);
756  if (NULL == sh->mq)
757  return; /* disconnected, skip for now */
759  m->session_id = htonl(ar->slot);
760  m->peer = ar->address->peer;
761  m->properties = ar->properties;
762  GNUNET_MQ_send(sh->mq,
763  ev);
764 }
765 
766 
772 void
774 {
775  struct GNUNET_ATS_SchedulingHandle *sh = ar->sh;
776  struct GNUNET_MQ_Envelope *ev;
777  struct AddressDestroyedMessage *m;
778 
780  "Deleting address for peer `%s', plugin `%s', slot %u session %p\n",
781  GNUNET_i2s(&ar->address->peer),
782  ar->address->transport_name,
783  ar->slot,
784  ar->session);
785  GNUNET_break(NULL == ar->session);
786  ar->session = NULL;
787  ar->in_destroy = GNUNET_YES;
788  if (NULL == sh->mq)
789  return;
791  m->session_id = htonl(ar->slot);
792  m->peer = ar->address->peer;
793  GNUNET_MQ_send(sh->mq, ev);
794 }
795 
796 
797 /* 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:117
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:173
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:127
struct GNUNET_ATS_PropertiesNBO properties
Performance properties of the address.
Definition: ats.h:144
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
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:77
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:203
#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:220
#define GNUNET_memcpy(dst, src, n)
Call memcpy() but check for n being 0 first.
#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:264
#define GNUNET_NO
Definition: gnunet_common.h:78
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:259
#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:196
#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:247
#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:157
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:1237
#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.
void * suggest_cb_cls
Closure for suggest_cb.
This is a scheduling client (aka transport service)
Definition: ats.h:41
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:122
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:237
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:84
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:139
#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:83
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:131
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:821
struct GNUNET_ATS_PropertiesNBO properties
Performance properties of the address.
Definition: ats.h:178
#define GNUNET_YES
Definition: gnunet_common.h:77
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:254
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:351
#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:187
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:133
Message sent by ATS service to client to confirm that it is done using the given session ID...
Definition: ats.h:211
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:166
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:68
#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:39
void * GNUNET_SCHEDULER_cancel(struct GNUNET_SCHEDULER_Task *task)
Cancel the task with the specified identifier.
Definition: scheduler.c:956
Scheduling client to ATS service: here is another address you can use.
Definition: ats.h:108