GNUnet  0.20.0
ats_api_scheduling.c File Reference

automatic transport selection and outbound bandwidth determination More...

#include "platform.h"
#include "gnunet_ats_service.h"
#include "ats.h"
Include dependency graph for ats_api_scheduling.c:

Go to the source code of this file.

Data Structures

struct  GNUNET_ATS_AddressRecord
 Information we track per address, incoming or outgoing. More...
 
struct  GNUNET_ATS_SchedulingHandle
 Handle to the ATS subsystem for bandwidth/transport scheduling information. More...
 

Macros

#define INTERFACE_PROCESSING_INTERVAL
 How frequently do we scan the interfaces for changes to the addresses? More...
 
#define LOG(kind, ...)   GNUNET_log_from (kind, "ats-scheduling-api", __VA_ARGS__)
 
#define NOT_FOUND   0
 Session ID we use if there is no session / slot. More...
 

Functions

static void reconnect (struct GNUNET_ATS_SchedulingHandle *sh)
 Re-establish the connection to the ATS service. More...
 
static void reconnect_task (void *cls)
 Re-establish the connection to the ATS service. More...
 
static void force_reconnect (struct GNUNET_ATS_SchedulingHandle *sh)
 Disconnect from ATS and then reconnect. More...
 
static struct GNUNET_ATS_AddressRecordfind_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. More...
 
static uint32_t find_empty_session_slot (struct GNUNET_ATS_SchedulingHandle *sh)
 Get an available session ID. More...
 
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. More...
 
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). More...
 
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. More...
 
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. More...
 
static void error_handler (void *cls, enum GNUNET_MQ_Error error)
 We encountered an error handling the MQ to the ATS service. More...
 
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. More...
 
struct GNUNET_ATS_SchedulingHandleGNUNET_ATS_scheduling_init (const struct GNUNET_CONFIGURATION_Handle *cfg, GNUNET_ATS_AddressSuggestionCallback suggest_cb, void *suggest_cb_cls)
 Initialize the ATS scheduling subsystem. More...
 
void GNUNET_ATS_scheduling_done (struct GNUNET_ATS_SchedulingHandle *sh)
 Client is done with ATS scheduling, release resources. More...
 
struct GNUNET_ATS_AddressRecordGNUNET_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. More...
 
void GNUNET_ATS_address_add_session (struct GNUNET_ATS_AddressRecord *ar, struct GNUNET_ATS_Session *session)
 An address was used to initiate a session. More...
 
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. More...
 
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. More...
 
void GNUNET_ATS_address_destroy (struct GNUNET_ATS_AddressRecord *ar)
 An address got destroyed, stop using it as a valid address. More...
 

Detailed Description

automatic transport selection and outbound bandwidth determination

Author
Christian Grothoff
Matthias Wachs

TODO:

  • we could avoid a linear scan over the active addresses in some cases, so if there is need, we can still optimize here
  • we might want to split off the logic to determine LAN vs. WAN, as it has nothing to do with accessing the ATS service.

Definition in file ats_api_scheduling.c.

Macro Definition Documentation

◆ INTERFACE_PROCESSING_INTERVAL

#define INTERFACE_PROCESSING_INTERVAL
Value:
#define GNUNET_TIME_UNIT_MINUTES
One minute.
struct GNUNET_TIME_Relative GNUNET_TIME_relative_multiply(struct GNUNET_TIME_Relative rel, unsigned long long factor)
Multiply relative time by a given factor.
Definition: time.c:484

How frequently do we scan the interfaces for changes to the addresses?

Definition at line 41 of file ats_api_scheduling.c.

◆ LOG

#define LOG (   kind,
  ... 
)    GNUNET_log_from (kind, "ats-scheduling-api", __VA_ARGS__)

Definition at line 44 of file ats_api_scheduling.c.

◆ NOT_FOUND

#define NOT_FOUND   0

Session ID we use if there is no session / slot.

Definition at line 49 of file ats_api_scheduling.c.

Function Documentation

◆ reconnect()

static void reconnect ( struct GNUNET_ATS_SchedulingHandle sh)
static

Re-establish the connection to the ATS service.

Parameters
shhandle to use to re-connect.

Definition at line 512 of file ats_api_scheduling.c.

513 {
515  GNUNET_MQ_hd_fixed_size (ats_session_release,
518  sh),
519  GNUNET_MQ_hd_fixed_size (ats_address_suggestion,
522  sh),
524  };
525  struct GNUNET_MQ_Envelope *ev;
526  struct ClientStartMessage *init;
527  unsigned int i;
528  struct GNUNET_ATS_AddressRecord *ar;
529 
530  GNUNET_assert (NULL == sh->mq);
531  sh->mq = GNUNET_CLIENT_connect (sh->cfg,
532  "ats",
533  handlers,
534  &error_handler,
535  sh);
536  if (NULL == sh->mq)
537  {
538  GNUNET_break (0);
540  return;
541  }
542  ev = GNUNET_MQ_msg (init,
544  init->start_flag = htonl (START_FLAG_SCHEDULING);
545  GNUNET_MQ_send (sh->mq, ev);
546  if (NULL == sh->mq)
547  return;
548  for (i = 0; i < sh->session_array_size; i++)
549  {
550  ar = sh->session_array[i];
551  if (NULL == ar)
552  continue;
554  if (NULL == sh->mq)
555  return;
556  }
557 }
@ START_FLAG_SCHEDULING
This is a scheduling client (aka transport service)
Definition: ats.h:42
static void force_reconnect(struct GNUNET_ATS_SchedulingHandle *sh)
Disconnect from ATS and then reconnect.
static void error_handler(void *cls, enum GNUNET_MQ_Error error)
We encountered an error handling the MQ to the ATS service.
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.
static char * init
Set to the name of a service to start.
Definition: gnunet-arm.c:74
static struct SolverHandle * sh
static struct GNUNET_CADET_MessageHandler handlers[]
Handlers, for diverse services.
struct GNUNET_MQ_Handle * GNUNET_CLIENT_connect(const struct GNUNET_CONFIGURATION_Handle *cfg, const char *service_name, const struct GNUNET_MQ_MessageHandler *handlers, GNUNET_MQ_ErrorHandler error_handler, void *error_handler_cls)
Create a message queue to connect to a GNUnet service.
Definition: client.c:1057
#define GNUNET_assert(cond)
Use this for fatal errors that cannot be handled.
#define GNUNET_break(cond)
Use this for internal assertion violations that are not fatal (can be handled) but should not occur.
void GNUNET_MQ_send(struct GNUNET_MQ_Handle *mq, struct GNUNET_MQ_Envelope *ev)
Send a message with the given message queue.
Definition: mq.c:304
#define GNUNET_MQ_handler_end()
End-marker for the handlers array.
#define GNUNET_MQ_msg(mvar, type)
Allocate a GNUNET_MQ_Envelope.
Definition: gnunet_mq_lib.h:78
#define GNUNET_MQ_hd_fixed_size(name, code, str, ctx)
#define GNUNET_MESSAGE_TYPE_ATS_START
Type of the 'struct ClientStartMessage' sent by clients to ATS to identify the type of the client.
#define GNUNET_MESSAGE_TYPE_ATS_ADDRESS_SUGGESTION
Type of the 'struct AddressSuggestionMessage' sent by ATS to clients to suggest switching to a differ...
#define GNUNET_MESSAGE_TYPE_ATS_SESSION_RELEASE
Type of the 'struct SessionReleaseMessage' sent by ATS to client to confirm that a session ID was des...
ATS Service suggests to the transport service to use the address identified by the given session_id f...
Definition: ats.h:244
First message any client sends to ATS, used to self-identify (what type of client this is).
Definition: ats.h:70
Information we track per address, incoming or outgoing.
Message sent by ATS service to client to confirm that it is done using the given session ID.
Definition: ats.h:218
Message handler for a specific message type.

References error_handler(), force_reconnect(), GNUNET_assert, GNUNET_break, GNUNET_CLIENT_connect(), GNUNET_MESSAGE_TYPE_ATS_ADDRESS_SUGGESTION, GNUNET_MESSAGE_TYPE_ATS_SESSION_RELEASE, GNUNET_MESSAGE_TYPE_ATS_START, GNUNET_MQ_handler_end, GNUNET_MQ_hd_fixed_size, GNUNET_MQ_msg, GNUNET_MQ_send(), handlers, init, send_add_address_message(), sh, and START_FLAG_SCHEDULING.

Referenced by GNUNET_ATS_scheduling_init(), and reconnect_task().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ reconnect_task()

static void reconnect_task ( void *  cls)
static

Re-establish the connection to the ATS service.

Parameters
clshandle to use to re-connect.

Definition at line 164 of file ats_api_scheduling.c.

165 {
166  struct GNUNET_ATS_SchedulingHandle *sh = cls;
167 
168  sh->task = NULL;
169  reconnect (sh);
170 }
static void reconnect(struct GNUNET_ATS_SchedulingHandle *sh)
Re-establish the connection to the ATS service.
Handle to the ATS subsystem for bandwidth/transport scheduling information.

References reconnect(), and sh.

Referenced by force_reconnect().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ force_reconnect()

static void force_reconnect ( struct GNUNET_ATS_SchedulingHandle sh)
static

Disconnect from ATS and then reconnect.

Parameters
shour handle

Definition at line 179 of file ats_api_scheduling.c.

180 {
181  if (NULL != sh->mq)
182  {
183  GNUNET_MQ_destroy (sh->mq);
184  sh->mq = NULL;
185  }
186  sh->suggest_cb (sh->suggest_cb_cls,
187  NULL, NULL, NULL,
190  sh->backoff = GNUNET_TIME_STD_BACKOFF (sh->backoff);
191  sh->task = GNUNET_SCHEDULER_add_delayed (sh->backoff,
193  sh);
194 }
static void reconnect_task(void *cls)
Re-establish the connection to the ATS service.
#define GNUNET_BANDWIDTH_ZERO
Convenience definition to use for 0-bandwidth.
void GNUNET_MQ_destroy(struct GNUNET_MQ_Handle *mq)
Destroy the message queue.
Definition: mq.c:683
struct GNUNET_SCHEDULER_Task * GNUNET_SCHEDULER_add_delayed(struct GNUNET_TIME_Relative delay, GNUNET_SCHEDULER_TaskCallback task, void *task_cls)
Schedule a new task to be run with a specified delay.
Definition: scheduler.c:1272
#define GNUNET_TIME_STD_BACKOFF(r)
Perform our standard exponential back-off calculation, starting at 1 ms and then going by a factor of...

References GNUNET_BANDWIDTH_ZERO, GNUNET_MQ_destroy(), GNUNET_SCHEDULER_add_delayed(), GNUNET_TIME_STD_BACKOFF, reconnect_task(), and sh.

Referenced by error_handler(), handle_ats_address_suggestion(), reconnect(), and release_session().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ find_session()

static struct GNUNET_ATS_AddressRecord* find_session ( struct GNUNET_ATS_SchedulingHandle sh,
uint32_t  session_id,
const struct GNUNET_PeerIdentity peer 
)
static

Find the session object corresponding to the given session ID.

Parameters
shour handle
session_idcurrent session ID
peerpeer the session belongs to
Returns
the session object (or NULL)

Definition at line 206 of file ats_api_scheduling.c.

209 {
210  struct GNUNET_ATS_AddressRecord *ar;
211 
212  if (session_id >= sh->session_array_size)
213  {
214  GNUNET_break (0);
215  return NULL;
216  }
217  if (0 == session_id)
218  return NULL;
219  ar = sh->session_array[session_id];
220  if (NULL == ar)
221  {
222  GNUNET_break (0);
223  return NULL;
224  }
225  if (NULL == ar->address)
226  {
227  /* address was destroyed in the meantime, this can happen
228  as we communicate asynchronously with the ATS service. */
229  return NULL;
230  }
231  if (0 != GNUNET_memcmp (peer,
232  &ar->address->peer))
233  {
234  GNUNET_break (0);
235  return NULL;
236  }
237  return ar;
238 }
static struct GNUNET_HashCode session_id
#define GNUNET_memcmp(a, b)
Compare memory in a and b, where both must be of the same pointer type.
struct GNUNET_HELLO_Address * address
Address data.
struct GNUNET_PeerIdentity peer
For which peer is this an address?
struct GNUNET_TESTBED_Peer * peer
The peer associated with this model.

References GNUNET_ATS_AddressRecord::address, GNUNET_break, GNUNET_memcmp, GNUNET_HELLO_Address::peer, peer, session_id, and sh.

Referenced by handle_ats_address_suggestion().

Here is the caller graph for this function:

◆ find_empty_session_slot()

static uint32_t find_empty_session_slot ( struct GNUNET_ATS_SchedulingHandle sh)
static

Get an available session ID.

Parameters
shour handle
Returns
an unused slot, but never NOT_FOUND (0)

Definition at line 248 of file ats_api_scheduling.c.

249 {
250  static uint32_t off;
251  uint32_t i;
252 
253  GNUNET_assert (0 != sh->session_array_size);
254  i = 0;
255  while (((NOT_FOUND == off) ||
256  (NULL != sh->session_array[off % sh->session_array_size])) &&
257  (i < sh->session_array_size))
258  {
259  off++;
260  i++;
261  }
262  if ((NOT_FOUND != off % sh->session_array_size) &&
263  (NULL == sh->session_array[off % sh->session_array_size]))
264  return off;
265  i = sh->session_array_size;
266  GNUNET_array_grow (sh->session_array,
267  sh->session_array_size,
268  sh->session_array_size * 2);
269  return i;
270 }
#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.

References GNUNET_array_grow, GNUNET_assert, NOT_FOUND, and sh.

Referenced by GNUNET_ATS_address_add().

Here is the caller graph for this function:

◆ find_session_id()

static uint32_t find_session_id ( struct GNUNET_ATS_SchedulingHandle sh,
struct GNUNET_ATS_Session session,
const struct GNUNET_HELLO_Address address 
)
static

Get the ID for the given session object.

Parameters
shour handle
sessionsession object
addressthe address we are looking for
Returns
the session id or NOT_FOUND for error

Definition at line 282 of file ats_api_scheduling.c.

285 {
286  uint32_t i;
287 
288  if (NULL == address)
289  {
290  GNUNET_break (0);
291  return NOT_FOUND;
292  }
293  for (i = 1; i < sh->session_array_size; i++)
294  if ((NULL != sh->session_array[i]) &&
295  (GNUNET_NO == sh->session_array[i]->in_destroy) &&
296  ((session == sh->session_array[i]->session) ||
297  (NULL == sh->session_array[i]->session)) &&
298  (0 == GNUNET_memcmp (&address->peer,
299  &sh->session_array[i]->address->peer)) &&
301  sh->session_array[i]->address)))
302  return i;
303  return NOT_FOUND;
304 }
static char * address
GNS address for this phone.
int GNUNET_HELLO_address_cmp(const struct GNUNET_HELLO_Address *a1, const struct GNUNET_HELLO_Address *a2)
Compare two addresses.
Definition: address.c:112
@ GNUNET_NO

References address, GNUNET_break, GNUNET_HELLO_address_cmp(), GNUNET_memcmp, GNUNET_NO, NOT_FOUND, GNUNET_ATS_AddressRecord::session, and sh.

Referenced by GNUNET_ATS_address_add().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ release_session()

static void release_session ( struct GNUNET_ATS_SchedulingHandle sh,
uint32_t  session_id 
)
static

Release the session slot from the session table (ATS service is also done using it).

Parameters
shour handle
session_ididentifies session that is no longer valid

Definition at line 315 of file ats_api_scheduling.c.

317 {
318  struct GNUNET_ATS_AddressRecord *ar;
319 
320  if (NOT_FOUND == session_id)
321  return;
322  if (session_id >= sh->session_array_size)
323  {
324  GNUNET_break (0);
326  return;
327  }
328  /* this slot should have been removed from remove_session before */
329  ar = sh->session_array[session_id];
330  if (NULL != ar->session)
331  {
332  GNUNET_break (0);
334  return;
335  }
337  GNUNET_free (ar);
338  sh->session_array[session_id] = NULL;
339 }
#define GNUNET_HELLO_address_free(addr)
Free an address.
#define GNUNET_free(ptr)
Wrapper around free.
struct GNUNET_ATS_Session * session
Session handle.

References GNUNET_ATS_AddressRecord::address, force_reconnect(), GNUNET_break, GNUNET_free, GNUNET_HELLO_address_free, NOT_FOUND, GNUNET_ATS_AddressRecord::session, session_id, and sh.

Referenced by handle_ats_session_release().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ handle_ats_session_release()

static void handle_ats_session_release ( void *  cls,
const struct GNUNET_ATS_SessionReleaseMessage srm 
)
static

Type of a function to call when we receive a session release message from the service.

Parameters
clsthe struct GNUNET_ATS_SchedulingHandle
srmmessage received

Definition at line 350 of file ats_api_scheduling.c.

352 {
353  struct GNUNET_ATS_SchedulingHandle *sh = cls;
354 
355  /* Note: peer field in srm not necessary right now,
356  but might be good to have in the future */
358  ntohl (srm->session_id));
359 }
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 session_id
Number the client used to identify the session.
Definition: ats.h:227

References release_session(), GNUNET_ATS_SessionReleaseMessage::session_id, and sh.

Here is the call graph for this function:

◆ handle_ats_address_suggestion()

static void handle_ats_address_suggestion ( void *  cls,
const struct AddressSuggestionMessage m 
)
static

Type of a function to call when we receive a address suggestion message from the service.

Parameters
clsthe struct GNUNET_ATS_SchedulingHandle
mmessage received

Definition at line 370 of file ats_api_scheduling.c.

372 {
373  struct GNUNET_ATS_SchedulingHandle *sh = cls;
374  struct GNUNET_ATS_AddressRecord *ar;
375  uint32_t session_id;
376 
377  session_id = ntohl (m->session_id);
378  if (0 == session_id)
379  {
380  GNUNET_break (0);
382  return;
383  }
384  ar = find_session (sh,
385  session_id,
386  &m->peer);
387  if (NULL == ar)
388  {
389  GNUNET_break (0);
391  return;
392  }
393  if (NULL == sh->suggest_cb)
394  return;
395  if (GNUNET_YES == ar->in_destroy)
396  {
397  /* ignore suggestion, as this address is dying, unless BW is 0,
398  in that case signal 'disconnect' via BW 0 */
399  if ((0 == ntohl (m->bandwidth_out.value__)) &&
400  (0 == ntohl (m->bandwidth_in.value__)))
401  {
403  "ATS suggests disconnect from peer `%s' with BW %u/%u\n",
404  GNUNET_i2s (&ar->address->peer),
405  (unsigned int) ntohl (m->bandwidth_out.value__),
406  (unsigned int) ntohl (m->bandwidth_in.value__));
407  sh->suggest_cb (sh->suggest_cb_cls,
408  &m->peer,
409  NULL,
410  NULL,
411  m->bandwidth_out,
412  m->bandwidth_in);
413  }
414  return;
415  }
416  if ((NULL == ar->session) &&
419  {
420  GNUNET_break (0);
421  return;
422  }
423  sh->backoff = GNUNET_TIME_UNIT_ZERO;
425  "ATS suggests address slot %u for peer `%s' using plugin %s\n",
426  ar->slot,
427  GNUNET_i2s (&ar->address->peer),
428  ar->address->transport_name);
429  sh->suggest_cb (sh->suggest_cb_cls,
430  &m->peer,
431  ar->address,
432  ar->session,
433  m->bandwidth_out,
434  m->bandwidth_in);
435 }
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.
#define LOG(kind,...)
static struct GNUNET_ARM_MonitorHandle * m
Monitor connection with ARM.
Definition: gnunet-arm.c:104
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
@ GNUNET_HELLO_ADDRESS_INFO_INBOUND
This is an inbound address and cannot be used to initiate an outbound connection to another peer.
@ GNUNET_YES
const char * GNUNET_i2s(const struct GNUNET_PeerIdentity *pid)
Convert a peer identity to a string (for printing debug messages).
@ GNUNET_ERROR_TYPE_DEBUG
#define GNUNET_TIME_UNIT_ZERO
Relative time zero.
int in_destroy
We're about to destroy this address record, just ATS does not know this yet.
uint32_t slot
Which slot (index) in the session array does this record correspond to? FIXME: a linear search on thi...
const char * transport_name
Name of the transport plugin enabling the communication using this address.

References GNUNET_ATS_AddressRecord::address, find_session(), force_reconnect(), GNUNET_break, GNUNET_ERROR_TYPE_DEBUG, GNUNET_HELLO_address_check_option(), GNUNET_HELLO_ADDRESS_INFO_INBOUND, GNUNET_i2s(), GNUNET_TIME_UNIT_ZERO, GNUNET_YES, GNUNET_ATS_AddressRecord::in_destroy, LOG, m, GNUNET_HELLO_Address::peer, GNUNET_ATS_AddressRecord::session, session_id, sh, GNUNET_ATS_AddressRecord::slot, and GNUNET_HELLO_Address::transport_name.

Here is the call graph for this function:

◆ error_handler()

static void error_handler ( void *  cls,
enum GNUNET_MQ_Error  error 
)
static

We encountered an error handling the MQ to the ATS service.

Reconnect.

Parameters
clsthe struct GNUNET_ATS_SchedulingHandle
errordetails about the error

Definition at line 446 of file ats_api_scheduling.c.

448 {
449  struct GNUNET_ATS_SchedulingHandle *sh = cls;
450 
452  "ATS connection died (code %d), reconnecting\n",
453  (int) error);
455 }

References force_reconnect(), GNUNET_ERROR_TYPE_DEBUG, LOG, and sh.

Referenced by reconnect().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ send_add_address_message()

static void send_add_address_message ( struct GNUNET_ATS_SchedulingHandle sh,
const struct GNUNET_ATS_AddressRecord ar 
)
static

Generate and transmit the struct AddressAddMessage for the given address record.

Parameters
shthe scheduling handle to use for transmission
arthe address to inform the ATS service about

Definition at line 466 of file ats_api_scheduling.c.

468 {
469  struct GNUNET_MQ_Envelope *ev;
470  struct AddressAddMessage *m;
471  char *pm;
472  size_t namelen;
473  size_t msize;
474 
475  if (NULL == sh->mq)
476  return; /* disconnected, skip for now */
478  namelen = strlen (ar->address->transport_name) + 1;
479  msize = ar->address->address_length + namelen;
481  m->peer = ar->address->peer;
482  m->address_length = htons (ar->address->address_length);
483  m->address_local_info = htonl ((uint32_t) ar->address->local_info);
484  m->plugin_name_length = htons (namelen);
485  m->session_id = htonl (ar->slot);
486  m->properties = ar->properties;
487 
489  "Adding address for peer `%s', plugin `%s', session %p slot %u\n",
490  GNUNET_i2s (&ar->address->peer),
491  ar->address->transport_name,
492  ar->session,
493  ar->slot);
494  pm = (char *) &m[1];
495  GNUNET_memcpy (pm,
496  ar->address->address,
497  ar->address->address_length);
498  if (NULL != ar->address->transport_name)
500  ar->address->transport_name,
501  namelen);
502  GNUNET_MQ_send (sh->mq, ev);
503 }
static struct GNUNET_TRANSPORT_PluginMonitor * pm
Handle if we are monitoring plugin session activity.
#define GNUNET_memcpy(dst, src, n)
Call memcpy() but check for n being 0 first.
#define GNUNET_MQ_msg_extra(mvar, esize, type)
Allocate an envelope, with extra space allocated after the space needed by the message struct.
Definition: gnunet_mq_lib.h:63
@ GNUNET_NT_UNSPECIFIED
Category of last resort.
Definition: gnunet_nt_lib.h:43
#define GNUNET_MESSAGE_TYPE_ATS_ADDRESS_ADD
Type of the 'struct AddressUpdateMessage' sent by client to ATS to add a new address.
Scheduling client to ATS service: here is another address you can use.
Definition: ats.h:112
struct GNUNET_ATS_PropertiesNBO properties
Performance data about the address.
uint32_t scope
Which network scope does the respective address belong to? This property does not change.
size_t address_length
Number of bytes in address.
enum GNUNET_HELLO_AddressInfo local_info
Extended information about address.
const void * address
Binary representation of the address (plugin-specific).

References GNUNET_ATS_AddressRecord::address, GNUNET_HELLO_Address::address, GNUNET_HELLO_Address::address_length, GNUNET_break, GNUNET_ERROR_TYPE_DEBUG, GNUNET_i2s(), GNUNET_memcpy, GNUNET_MESSAGE_TYPE_ATS_ADDRESS_ADD, GNUNET_MQ_msg_extra, GNUNET_MQ_send(), GNUNET_NT_UNSPECIFIED, GNUNET_HELLO_Address::local_info, LOG, m, GNUNET_HELLO_Address::peer, pm, GNUNET_ATS_AddressRecord::properties, GNUNET_ATS_PropertiesNBO::scope, GNUNET_ATS_AddressRecord::session, sh, GNUNET_ATS_AddressRecord::slot, and GNUNET_HELLO_Address::transport_name.

Referenced by GNUNET_ATS_address_add(), and reconnect().

Here is the call graph for this function:
Here is the caller graph for this function: