GNUnet  0.10.x
Data Structures | Macros | Functions | Variables
gnunet-service-transport_ats.c File Reference

interfacing between transport and ATS service More...

#include "platform.h"
#include "gnunet-service-transport.h"
#include "gnunet-service-transport_ats.h"
#include "gnunet-service-transport_manipulation.h"
#include "gnunet-service-transport_plugins.h"
#include "gnunet_ats_service.h"
Include dependency graph for gnunet-service-transport_ats.c:

Go to the source code of this file.

Data Structures

struct  AddressInfo
 Information we track for each address known to ATS. More...
 
struct  FindClosure
 Closure for find_ai_cb() and find_ai_no_session_cb(). More...
 

Macros

#define LOG(kind, ...)   GNUNET_log_from(kind, "transport-ats", __VA_ARGS__)
 Log convenience function. More...
 

Functions

static void publish_p2a_stat_update ()
 Provide an update on the p2a map size to statistics. More...
 
static int find_ai_cb (void *cls, const struct GNUNET_PeerIdentity *key, void *value)
 Find matching address info. More...
 
static struct AddressInfofind_ai (const struct GNUNET_HELLO_Address *address, struct GNUNET_ATS_Session *session)
 Find the address information struct for the given address and session. More...
 
static int find_ai_no_session_cb (void *cls, const struct GNUNET_PeerIdentity *key, void *value)
 Find matching address info, ignoring sessions and expired addresses. More...
 
static struct AddressInfofind_ai_no_session (const struct GNUNET_HELLO_Address *address)
 Find the address information struct for the given address (ignoring sessions) More...
 
int GST_ats_is_known (const struct GNUNET_HELLO_Address *address, struct GNUNET_ATS_Session *session)
 Test if ATS knows about this address and session. More...
 
int GST_ats_is_known_no_session (const struct GNUNET_HELLO_Address *address)
 Test if ATS knows about this address. More...
 
static void unblock_address (void *cls)
 The blocking time for an address has expired, allow ATS to suggest it again. More...
 
void GST_ats_block_address (const struct GNUNET_HELLO_Address *address, struct GNUNET_ATS_Session *session)
 Temporarily block a valid address for use by ATS for address suggestions. More...
 
void GST_ats_block_reset (const struct GNUNET_HELLO_Address *address, struct GNUNET_ATS_Session *session)
 Reset address blocking time. More...
 
void GST_ats_add_inbound_address (const struct GNUNET_HELLO_Address *address, struct GNUNET_ATS_Session *session, const struct GNUNET_ATS_Properties *prop)
 Notify ATS about a new inbound address. More...
 
void GST_ats_add_address (const struct GNUNET_HELLO_Address *address, const struct GNUNET_ATS_Properties *prop)
 Notify ATS about the new address including the network this address is located in. More...
 
void GST_ats_new_session (const struct GNUNET_HELLO_Address *address, struct GNUNET_ATS_Session *session)
 Notify ATS about a new session now existing for the given address. More...
 
static void destroy_ai (struct AddressInfo *ai)
 Release memory used by the given address data. More...
 
void GST_ats_del_session (const struct GNUNET_HELLO_Address *address, struct GNUNET_ATS_Session *session)
 Notify ATS that the session (but not the address) of a given address is no longer relevant. More...
 
void GST_ats_update_distance (const struct GNUNET_HELLO_Address *address, uint32_t distance)
 Notify ATS about DV distance change to an address. More...
 
void GST_ats_update_delay (const struct GNUNET_HELLO_Address *address, struct GNUNET_TIME_Relative delay)
 Notify ATS about delay changes to properties of an address. More...
 
void GST_ats_update_utilization (const struct GNUNET_HELLO_Address *address, uint32_t bps_in, uint32_t bps_out)
 Notify ATS about utilization changes to an address. More...
 
void GST_ats_expire_address (const struct GNUNET_HELLO_Address *address)
 Notify ATS that the address has expired and thus cannot be used any longer. More...
 
void GST_ats_init ()
 Initialize ATS subsystem. More...
 
static int destroy_ai_cb (void *cls, const struct GNUNET_PeerIdentity *key, void *value)
 Release memory used by the given address data. More...
 
void GST_ats_done ()
 Shutdown ATS subsystem. More...
 

Variables

static struct GNUNET_CONTAINER_MultiPeerMapp2a
 Map from peer identities to one or more struct AddressInfo values for the peer. More...
 
static unsigned int num_blocked
 Number of blocked addresses. More...
 

Detailed Description

interfacing between transport and ATS service

Author
Christian Grothoff

Definition in file gnunet-service-transport_ats.c.

Macro Definition Documentation

◆ LOG

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

Function Documentation

◆ publish_p2a_stat_update()

static void publish_p2a_stat_update ( )
static

Provide an update on the p2a map size to statistics.

This function should be called whenever the p2a map is changed.

Definition at line 138 of file gnunet-service-transport_ats.c.

References gettext_noop, GNUNET_CONTAINER_multipeermap_size(), GNUNET_NO, GNUNET_STATISTICS_set(), GST_stats, and num_blocked.

Referenced by destroy_ai(), GST_ats_add_address(), GST_ats_add_inbound_address(), GST_ats_block_address(), GST_ats_done(), and unblock_address().

139 {
141  gettext_noop ("# Addresses given to ATS"),
143  GNUNET_NO);
145  "# blocked addresses",
146  num_blocked,
147  GNUNET_NO);
148 }
static unsigned int num_blocked
Number of blocked addresses.
#define GNUNET_NO
Definition: gnunet_common.h:81
static struct GNUNET_CONTAINER_MultiPeerMap * p2a
Map from peer identities to one or more struct AddressInfo values for the peer.
static struct GNUNET_STATISTICS_Handle * GST_stats
Statistics handle.
void GNUNET_STATISTICS_set(struct GNUNET_STATISTICS_Handle *handle, const char *name, uint64_t value, int make_persistent)
Set statistic value for the peer.
unsigned int GNUNET_CONTAINER_multipeermap_size(const struct GNUNET_CONTAINER_MultiPeerMap *map)
Get the number of key-value pairs in the map.
#define gettext_noop(String)
Definition: gettext.h:69
Here is the call graph for this function:
Here is the caller graph for this function:

◆ find_ai_cb()

static int find_ai_cb ( void *  cls,
const struct GNUNET_PeerIdentity key,
void *  value 
)
static

Find matching address info.

Both the address and the session must match; note that expired addresses are still found (as the session kind-of keeps those alive).

Parameters
clsthe struct FindClosure
keywhich peer is this about
valuethe struct AddressInfo
Returns
GNUNET_YES to continue to iterate, GNUNET_NO if we found the value

Definition at line 162 of file gnunet-service-transport_ats.c.

References AddressInfo::address, FindClosure::address, ai, GNUNET_HELLO_address_cmp(), GNUNET_NO, GNUNET_YES, FindClosure::ret, AddressInfo::session, FindClosure::session, and value.

Referenced by find_ai().

165 {
166  struct FindClosure *fc = cls;
167  struct AddressInfo *ai = value;
168 
169  if ( (0 ==
171  ai->address) ) &&
172  (fc->session == ai->session) )
173  {
174  fc->ret = ai;
175  return GNUNET_NO;
176  }
177  return GNUNET_YES;
178 }
struct GNUNET_ATS_Session * session
Session to look for (only used if the address is inbound).
Closure for find_ai_cb() and find_ai_no_session_cb().
struct AddressInfo * ret
Where to store the result.
#define GNUNET_NO
Definition: gnunet_common.h:81
int GNUNET_HELLO_address_cmp(const struct GNUNET_HELLO_Address *a1, const struct GNUNET_HELLO_Address *a2)
Compare two addresses.
Definition: address.c:130
static char * value
Value of the record to add/remove.
Information we track for each address known to ATS.
static struct GNUNET_TRANSPORT_AddressIdentifier * ai
Handle to the operation that publishes our address.
const struct GNUNET_HELLO_Address * address
Address to look for.
struct GNUNET_HELLO_Address * address
The address (with peer identity).
#define GNUNET_YES
Definition: gnunet_common.h:80
struct GNUNET_ATS_Session * session
Session (can be NULL)
Here is the call graph for this function:
Here is the caller graph for this function:

◆ find_ai()

static struct AddressInfo* find_ai ( const struct GNUNET_HELLO_Address address,
struct GNUNET_ATS_Session session 
)
static

Find the address information struct for the given address and session.

Parameters
addressaddress to look for
sessionsession to match for inbound connections
Returns
NULL if this combination is unknown

Definition at line 190 of file gnunet-service-transport_ats.c.

References AddressInfo::address, FindClosure::address, find_ai_cb(), GNUNET_CONTAINER_multipeermap_get_multiple(), GNUNET_HELLO_Address::peer, FindClosure::ret, AddressInfo::session, and FindClosure::session.

Referenced by GST_ats_add_inbound_address(), GST_ats_block_address(), GST_ats_block_reset(), GST_ats_del_session(), GST_ats_is_known(), and GST_ats_new_session().

192 {
193  struct FindClosure fc;
194 
195  fc.address = address;
196  fc.session = session;
197  fc.ret = NULL;
199  &address->peer,
200  &find_ai_cb,
201  &fc);
202  return fc.ret;
203 }
struct GNUNET_ATS_Session * session
Session to look for (only used if the address is inbound).
Closure for find_ai_cb() and find_ai_no_session_cb().
static struct GNUNET_CONTAINER_MultiPeerMap * p2a
Map from peer identities to one or more struct AddressInfo values for the peer.
struct GNUNET_PeerIdentity peer
For which peer is this an address?
const struct GNUNET_HELLO_Address * address
Address to look for.
static int find_ai_cb(void *cls, const struct GNUNET_PeerIdentity *key, void *value)
Find matching address info.
static char * address
GNS address for this phone.
int GNUNET_CONTAINER_multipeermap_get_multiple(struct GNUNET_CONTAINER_MultiPeerMap *map, const struct GNUNET_PeerIdentity *key, GNUNET_CONTAINER_PeerMapIterator it, void *it_cls)
Iterate over all entries in the map that match a particular key.
Here is the call graph for this function:
Here is the caller graph for this function:

◆ find_ai_no_session_cb()

static int find_ai_no_session_cb ( void *  cls,
const struct GNUNET_PeerIdentity key,
void *  value 
)
static

Find matching address info, ignoring sessions and expired addresses.

Parameters
clsthe struct FindClosure
keywhich peer is this about
valuethe struct AddressInfo
Returns
GNUNET_YES to continue to iterate, GNUNET_NO if we found the value

Definition at line 216 of file gnunet-service-transport_ats.c.

References AddressInfo::address, FindClosure::address, ai, AddressInfo::expired, GNUNET_HELLO_address_cmp(), GNUNET_NO, GNUNET_YES, FindClosure::ret, and value.

Referenced by find_ai_no_session().

219 {
220  struct FindClosure *fc = cls;
221  struct AddressInfo *ai = value;
222 
223  if (ai->expired)
224  return GNUNET_YES; /* expired do not count here */
225  if (0 ==
227  ai->address))
228  {
229  fc->ret = ai;
230  return GNUNET_NO;
231  }
232  return GNUNET_YES;
233 }
Closure for find_ai_cb() and find_ai_no_session_cb().
struct AddressInfo * ret
Where to store the result.
#define GNUNET_NO
Definition: gnunet_common.h:81
int GNUNET_HELLO_address_cmp(const struct GNUNET_HELLO_Address *a1, const struct GNUNET_HELLO_Address *a2)
Compare two addresses.
Definition: address.c:130
static char * value
Value of the record to add/remove.
Information we track for each address known to ATS.
static struct GNUNET_TRANSPORT_AddressIdentifier * ai
Handle to the operation that publishes our address.
const struct GNUNET_HELLO_Address * address
Address to look for.
struct GNUNET_HELLO_Address * address
The address (with peer identity).
#define GNUNET_YES
Definition: gnunet_common.h:80
int expired
Set to GNUNET_YES if the address has expired but we could not yet remove it because we still have a v...
Here is the call graph for this function:
Here is the caller graph for this function:

◆ find_ai_no_session()

static struct AddressInfo* find_ai_no_session ( const struct GNUNET_HELLO_Address address)
static

Find the address information struct for the given address (ignoring sessions)

Parameters
addressaddress to look for
Returns
NULL if this combination is unknown

Definition at line 244 of file gnunet-service-transport_ats.c.

References AddressInfo::address, FindClosure::address, find_ai_no_session_cb(), GNUNET_CONTAINER_multipeermap_get_multiple(), GNUNET_HELLO_Address::peer, FindClosure::ret, and FindClosure::session.

Referenced by GST_ats_add_address(), GST_ats_expire_address(), GST_ats_is_known_no_session(), GST_ats_update_delay(), GST_ats_update_distance(), and GST_ats_update_utilization().

245 {
246  struct FindClosure fc;
247 
248  fc.address = address;
249  fc.session = NULL;
250  fc.ret = NULL;
252  &address->peer,
254  &fc);
255  return fc.ret;
256 }
Closure for find_ai_cb() and find_ai_no_session_cb().
static struct GNUNET_CONTAINER_MultiPeerMap * p2a
Map from peer identities to one or more struct AddressInfo values for the peer.
struct GNUNET_PeerIdentity peer
For which peer is this an address?
const struct GNUNET_HELLO_Address * address
Address to look for.
static int find_ai_no_session_cb(void *cls, const struct GNUNET_PeerIdentity *key, void *value)
Find matching address info, ignoring sessions and expired addresses.
static char * address
GNS address for this phone.
int GNUNET_CONTAINER_multipeermap_get_multiple(struct GNUNET_CONTAINER_MultiPeerMap *map, const struct GNUNET_PeerIdentity *key, GNUNET_CONTAINER_PeerMapIterator it, void *it_cls)
Iterate over all entries in the map that match a particular key.
Here is the call graph for this function:
Here is the caller graph for this function:

◆ GST_ats_is_known()

int GST_ats_is_known ( const struct GNUNET_HELLO_Address address,
struct GNUNET_ATS_Session session 
)

Test if ATS knows about this address and session.

Note that even if the address is expired, we return GNUNET_YES if the respective session matches.

Parameters
addressthe address
sessionthe session
Returns
GNUNET_YES if address is known, GNUNET_NO if not.

Definition at line 269 of file gnunet-service-transport_ats.c.

References find_ai(), GNUNET_NO, and GNUNET_YES.

Referenced by GST_neighbours_session_terminated(), set_alternative_address(), set_primary_address(), and try_run_fast_ats_update().

271 {
272  return (NULL != find_ai (address, session)) ? GNUNET_YES : GNUNET_NO;
273 }
#define GNUNET_NO
Definition: gnunet_common.h:81
static struct AddressInfo * find_ai(const struct GNUNET_HELLO_Address *address, struct GNUNET_ATS_Session *session)
Find the address information struct for the given address and session.
#define GNUNET_YES
Definition: gnunet_common.h:80
Here is the call graph for this function:
Here is the caller graph for this function:

◆ GST_ats_is_known_no_session()

int GST_ats_is_known_no_session ( const struct GNUNET_HELLO_Address address)

Test if ATS knows about this address.

Note that expired addresses do not count.

Parameters
addressthe address
Returns
GNUNET_YES if address is known, GNUNET_NO if not.

Definition at line 284 of file gnunet-service-transport_ats.c.

References find_ai_no_session(), GNUNET_NO, and GNUNET_YES.

Referenced by add_valid_address(), cleanup_validation_entry(), find_validation_entry(), and GST_validation_handle_pong().

285 {
286  return (NULL != find_ai_no_session (address))
287  ? GNUNET_YES
288  : GNUNET_NO;
289 }
#define GNUNET_NO
Definition: gnunet_common.h:81
static struct AddressInfo * find_ai_no_session(const struct GNUNET_HELLO_Address *address)
Find the address information struct for the given address (ignoring sessions)
#define GNUNET_YES
Definition: gnunet_common.h:80
Here is the call graph for this function:
Here is the caller graph for this function:

◆ unblock_address()

static void unblock_address ( void *  cls)
static

The blocking time for an address has expired, allow ATS to suggest it again.

Parameters
clsthe struct AddressInfo of the address to unblock

Definition at line 299 of file gnunet-service-transport_ats.c.

References AddressInfo::address, ai, AddressInfo::ar, GNUNET_ATS_address_add(), GNUNET_break, GNUNET_ERROR_TYPE_DEBUG, GNUNET_i2s(), GST_ats, GST_plugins_a2s(), LOG, num_blocked, GNUNET_HELLO_Address::peer, AddressInfo::properties, publish_p2a_stat_update(), AddressInfo::session, and AddressInfo::unblock_task.

Referenced by GST_ats_block_address().

300 {
301  struct AddressInfo *ai = cls;
302 
303  ai->unblock_task = NULL;
305  "Unblocking address %s of peer %s\n",
306  GST_plugins_a2s (ai->address),
307  GNUNET_i2s (&ai->address->peer));
309  ai->address,
310  ai->session,
311  &ai->properties);
312  GNUNET_break (NULL != ai->ar);
313  num_blocked--;
315 }
struct GNUNET_SCHEDULER_Task * unblock_task
Task scheduled to unblock an ATS-blocked address at blocked time, or NULL if the address is not block...
struct GNUNET_ATS_Properties properties
Performance properties of this address.
static unsigned int num_blocked
Number of blocked addresses.
struct GNUNET_ATS_SchedulingHandle * GST_ats
ATS scheduling handle.
#define GNUNET_break(cond)
Use this for internal assertion violations that are not fatal (can be handled) but should not occur...
struct GNUNET_ATS_AddressRecord * ar
Record with ATS API for the address.
#define LOG(kind,...)
Log convenience function.
const char * GST_plugins_a2s(const struct GNUNET_HELLO_Address *address)
Convert a given address to a human-readable format.
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.
Information we track for each address known to ATS.
static struct GNUNET_TRANSPORT_AddressIdentifier * ai
Handle to the operation that publishes our address.
struct GNUNET_PeerIdentity peer
For which peer is this an address?
struct GNUNET_HELLO_Address * address
The address (with peer identity).
struct GNUNET_ATS_Session * session
Session (can be NULL)
const char * GNUNET_i2s(const struct GNUNET_PeerIdentity *pid)
Convert a peer identity to a string (for printing debug messages).
static void publish_p2a_stat_update()
Provide an update on the p2a map size to statistics.
Here is the call graph for this function:
Here is the caller graph for this function:

◆ GST_ats_block_address()

void GST_ats_block_address ( const struct GNUNET_HELLO_Address address,
struct GNUNET_ATS_Session session 
)

Temporarily block a valid address for use by ATS for address suggestions.

This function should be called if an address was suggested by ATS but failed to perform (i.e. failure to establish a session or to exchange the PING/PONG).

Parameters
addressthe address to block
sessionthe session (can be NULL)

Definition at line 328 of file gnunet-service-transport_ats.c.

References ai, AddressInfo::ar, AddressInfo::back_off, AddressInfo::blocked, find_ai(), GNUNET_ATS_address_del_session(), GNUNET_ATS_address_destroy(), GNUNET_ERROR_TYPE_DEBUG, GNUNET_ERROR_TYPE_INFO, GNUNET_HELLO_address_check_option(), GNUNET_HELLO_ADDRESS_INFO_INBOUND, GNUNET_i2s(), GNUNET_NO, GNUNET_SCHEDULER_add_delayed(), GNUNET_STRINGS_relative_time_to_string(), GNUNET_TIME_relative_to_absolute(), GNUNET_TIME_STD_BACKOFF, GNUNET_YES, GST_my_identity, GST_plugins_a2s(), LOG, num_blocked, GNUNET_HELLO_Address::peer, publish_p2a_stat_update(), unblock_address(), and AddressInfo::unblock_task.

Referenced by free_address(), GST_neighbours_switch_to_address(), set_primary_address(), and switch_address_bl_check_cont().

330 {
331  struct AddressInfo *ai;
332 
333  if (0 ==
334  memcmp (&GST_my_identity,
335  &address->peer,
336  sizeof (struct GNUNET_PeerIdentity)))
337  return; /* our own, ignore! */
338  ai = find_ai (address,
339  session);
340  if (NULL == ai || NULL == ai->ar)
341  {
342  /* The address is already gone/blocked, this can happen during a blacklist
343  * callback. */
344  return;
345  }
347  if (GNUNET_YES ==
351  "Removing address %s of peer %s from use (inbound died)\n",
352  GST_plugins_a2s (address),
353  GNUNET_i2s (&address->peer));
354  else
356  "Blocking address %s of peer %s from use for %s\n",
357  GST_plugins_a2s (address),
358  GNUNET_i2s (&address->peer),
360  GNUNET_YES));
361  /* destroy session and address */
362  if ( (NULL == session) ||
363  (GNUNET_NO ==
365  session)) )
366  {
368  }
369  /* "ar" has been freed, regardless how the branch
370  above played out: it was either freed in
371  #GNUNET_ATS_address_del_session() because it was
372  incoming, or explicitly in
373  #GNUNET_ATS_address_del_session(). */
374  ai->ar = NULL;
375 
376  /* determine when the address should come back to life */
380  ai);
381  num_blocked++;
383 }
static struct GNUNET_PeerIdentity GST_my_identity
Our public key.
struct GNUNET_TIME_Relative back_off
If an address is blocked as part of an exponential back-off, we track the current size of the backoff...
struct GNUNET_TIME_Absolute GNUNET_TIME_relative_to_absolute(struct GNUNET_TIME_Relative rel)
Convert relative time to an absolute time in the future.
Definition: time.c:245
struct GNUNET_SCHEDULER_Task * unblock_task
Task scheduled to unblock an ATS-blocked address at blocked time, or NULL if the address is not block...
static unsigned int num_blocked
Number of blocked addresses.
#define GNUNET_NO
Definition: gnunet_common.h:81
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
struct GNUNET_SCHEDULER_Task * GNUNET_SCHEDULER_add_delayed(struct GNUNET_TIME_Relative delay, GNUNET_SCHEDULER_TaskCallback task, void *task_cls)
Schedule a new task to be run with a specified delay.
Definition: scheduler.c:1246
struct GNUNET_ATS_AddressRecord * ar
Record with ATS API for the address.
This is an inbound address and cannot be used to initiate an outbound connection to another peer...
struct GNUNET_TIME_Absolute blocked
Time until when this address is blocked and should thus not be made available to ATS (ar should be NU...
const char * GNUNET_STRINGS_relative_time_to_string(struct GNUNET_TIME_Relative delta, int do_round)
Give relative time in human-readable fancy format.
Definition: strings.c:727
#define LOG(kind,...)
Log convenience function.
const char * GST_plugins_a2s(const struct GNUNET_HELLO_Address *address)
Convert a given address to a human-readable format.
Information we track for each address known to ATS.
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.
static struct GNUNET_TRANSPORT_AddressIdentifier * ai
Handle to the operation that publishes our address.
static void unblock_address(void *cls)
The blocking time for an address has expired, allow ATS to suggest it again.
#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?
The identity of the host (wraps the signing key of the peer).
static struct AddressInfo * find_ai(const struct GNUNET_HELLO_Address *address, struct GNUNET_ATS_Session *session)
Find the address information struct for the given address and session.
void GNUNET_ATS_address_destroy(struct GNUNET_ATS_AddressRecord *ar)
An address got destroyed, stop using it as a valid address.
#define GNUNET_YES
Definition: gnunet_common.h:80
const char * GNUNET_i2s(const struct GNUNET_PeerIdentity *pid)
Convert a peer identity to a string (for printing debug messages).
static void publish_p2a_stat_update()
Provide an update on the p2a map size to statistics.
Here is the call graph for this function:
Here is the caller graph for this function:

◆ GST_ats_block_reset()

void GST_ats_block_reset ( const struct GNUNET_HELLO_Address address,
struct GNUNET_ATS_Session session 
)

Reset address blocking time.

Resets the exponential back-off timer for this address to zero. Called when an address was used to create a successful connection.

Parameters
addressthe address to reset the blocking timer
sessionthe session (can be NULL)

Definition at line 395 of file gnunet-service-transport_ats.c.

References ai, AddressInfo::back_off, find_ai(), GNUNET_break, GNUNET_TIME_UNIT_ZERO, GST_my_identity, GNUNET_HELLO_Address::peer, and AddressInfo::unblock_task.

Referenced by GST_neighbours_handle_session_ack().

397 {
398  struct AddressInfo *ai;
399 
400  if (0 ==
401  memcmp (&GST_my_identity,
402  &address->peer,
403  sizeof (struct GNUNET_PeerIdentity)))
404  return; /* our own, ignore! */
405  ai = find_ai (address, session);
406  if (NULL == ai)
407  {
408  GNUNET_break (0);
409  return;
410  }
411  /* address is in successful use, so it should not be blocked right now */
412  GNUNET_break (NULL == ai->unblock_task);
414 }
static struct GNUNET_PeerIdentity GST_my_identity
Our public key.
struct GNUNET_TIME_Relative back_off
If an address is blocked as part of an exponential back-off, we track the current size of the backoff...
struct GNUNET_SCHEDULER_Task * unblock_task
Task scheduled to unblock an ATS-blocked address at blocked time, or NULL if the address is not block...
#define GNUNET_break(cond)
Use this for internal assertion violations that are not fatal (can be handled) but should not occur...
Information we track for each address known to ATS.
static struct GNUNET_TRANSPORT_AddressIdentifier * ai
Handle to the operation that publishes our address.
struct GNUNET_PeerIdentity peer
For which peer is this an address?
#define GNUNET_TIME_UNIT_ZERO
Relative time zero.
The identity of the host (wraps the signing key of the peer).
static struct AddressInfo * find_ai(const struct GNUNET_HELLO_Address *address, struct GNUNET_ATS_Session *session)
Find the address information struct for the given address and session.
Here is the call graph for this function:
Here is the caller graph for this function:

◆ GST_ats_add_inbound_address()

void GST_ats_add_inbound_address ( const struct GNUNET_HELLO_Address address,
struct GNUNET_ATS_Session session,
const struct GNUNET_ATS_Properties prop 
)

Notify ATS about a new inbound address.

The address in combination with the session must be new, but this function will perform a santiy check. If the address is indeed new, make it available to ATS.

Parameters
addressthe address
sessionthe session
propperformance information

Definition at line 428 of file gnunet-service-transport_ats.c.

References AddressInfo::address, ai, AddressInfo::ar, find_ai(), GNUNET_assert, GNUNET_ATS_address_add(), GNUNET_break, GNUNET_CONTAINER_MULTIHASHMAPOPTION_MULTIPLE, GNUNET_CONTAINER_multipeermap_put(), GNUNET_ERROR_TYPE_DEBUG, GNUNET_HELLO_address_check_option(), GNUNET_HELLO_address_copy(), GNUNET_HELLO_ADDRESS_INFO_INBOUND, GNUNET_i2s(), GNUNET_new, GNUNET_NT_to_string(), GNUNET_NT_UNSPECIFIED, GNUNET_YES, GST_ats, GST_my_identity, GST_plugins_a2s(), LOG, GNUNET_HELLO_Address::peer, AddressInfo::properties, publish_p2a_stat_update(), GNUNET_ATS_Properties::scope, AddressInfo::session, and GNUNET_HELLO_Address::transport_name.

Referenced by plugin_env_session_start().

431 {
432  struct GNUNET_ATS_AddressRecord *ar;
433  struct AddressInfo *ai;
434 
435  if (0 ==
436  memcmp (&GST_my_identity,
437  &address->peer,
438  sizeof (struct GNUNET_PeerIdentity)))
439  return; /* our own, ignore! */
440 
441  /* Sanity checks for a valid inbound address */
442  if (NULL == address->transport_name)
443  {
444  GNUNET_break(0);
445  return;
446  }
451  GNUNET_assert (NULL != session);
452  ai = find_ai (address, session);
453  if (NULL != ai)
454  {
455  /* This should only be called for new sessions, and thus
456  we should not already have the address */
457  GNUNET_break (0);
458  return;
459  }
460  /* Is indeed new, let's tell ATS */
462  "Notifying ATS about peer `%s''s new inbound address `%s' session %p in network %s\n",
463  GNUNET_i2s (&address->peer),
464  GST_plugins_a2s (address),
465  session,
466  GNUNET_NT_to_string (prop->scope));
468  address,
469  session,
470  prop);
471  GNUNET_assert (NULL != ar);
472  ai = GNUNET_new (struct AddressInfo);
473  ai->address = GNUNET_HELLO_address_copy (address);
474  ai->session = session;
475  ai->properties = *prop;
476  ai->ar = ar;
478  &ai->address->peer,
479  ai,
482 }
static struct GNUNET_PeerIdentity GST_my_identity
Our public key.
const char * GNUNET_NT_to_string(enum GNUNET_NetworkType net)
Convert a enum GNUNET_NetworkType to a string.
Definition: nt.c:43
#define GNUNET_assert(cond)
Use this for fatal errors that cannot be handled.
struct GNUNET_ATS_Properties properties
Performance properties of this address.
#define GNUNET_new(type)
Allocate a struct or union of the given type.
struct GNUNET_ATS_SchedulingHandle * GST_ats
ATS scheduling handle.
#define GNUNET_break(cond)
Use this for internal assertion violations that are not fatal (can be handled) but should not occur...
static struct GNUNET_CONTAINER_MultiPeerMap * p2a
Map from peer identities to one or more struct AddressInfo values for the peer.
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
struct GNUNET_ATS_AddressRecord * ar
Record with ATS API for the address.
This is an inbound address and cannot be used to initiate an outbound connection to another peer...
const char * transport_name
Name of the transport plugin enabling the communication using this address.
#define LOG(kind,...)
Log convenience function.
const char * GST_plugins_a2s(const struct GNUNET_HELLO_Address *address)
Convert a given address to a human-readable format.
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.
Information we track for each address known to ATS.
static struct GNUNET_TRANSPORT_AddressIdentifier * ai
Handle to the operation that publishes our address.
struct GNUNET_PeerIdentity peer
For which peer is this an address?
enum GNUNET_NetworkType scope
Which network scope does the respective address belong to? This property does not change...
Allow multiple values with the same key.
int GNUNET_CONTAINER_multipeermap_put(struct GNUNET_CONTAINER_MultiPeerMap *map, const struct GNUNET_PeerIdentity *key, void *value, enum GNUNET_CONTAINER_MultiHashMapOption opt)
Store a key-value pair in the map.
The identity of the host (wraps the signing key of the peer).
static struct AddressInfo * find_ai(const struct GNUNET_HELLO_Address *address, struct GNUNET_ATS_Session *session)
Find the address information struct for the given address and session.
struct GNUNET_HELLO_Address * GNUNET_HELLO_address_copy(const struct GNUNET_HELLO_Address *address)
Copy an address struct.
Definition: address.c:109
struct GNUNET_HELLO_Address * address
The address (with peer identity).
#define GNUNET_YES
Definition: gnunet_common.h:80
struct GNUNET_ATS_Session * session
Session (can be NULL)
const char * GNUNET_i2s(const struct GNUNET_PeerIdentity *pid)
Convert a peer identity to a string (for printing debug messages).
static void publish_p2a_stat_update()
Provide an update on the p2a map size to statistics.
Category of last resort.
Definition: gnunet_nt_lib.h:40
Here is the call graph for this function:
Here is the caller graph for this function:

◆ GST_ats_add_address()

void GST_ats_add_address ( const struct GNUNET_HELLO_Address address,
const struct GNUNET_ATS_Properties prop 
)

Notify ATS about the new address including the network this address is located in.

Notify ATS about a new address including the network this address is located in.

The address must NOT be inbound and must be new to ATS.

Parameters
addressthe address
propperformance information

Definition at line 493 of file gnunet-service-transport_ats.c.

References AddressInfo::address, ai, AddressInfo::ar, find_ai_no_session(), GNUNET_assert, GNUNET_ATS_address_add(), GNUNET_break, GNUNET_CONTAINER_MULTIHASHMAPOPTION_MULTIPLE, GNUNET_CONTAINER_multipeermap_put(), GNUNET_ERROR_TYPE_INFO, GNUNET_HELLO_address_check_option(), GNUNET_HELLO_address_copy(), GNUNET_HELLO_ADDRESS_INFO_INBOUND, GNUNET_i2s(), GNUNET_new, GNUNET_NT_UNSPECIFIED, GNUNET_YES, GST_ats, GST_my_identity, GST_plugins_a2s(), LOG, GNUNET_HELLO_Address::peer, AddressInfo::properties, publish_p2a_stat_update(), GNUNET_ATS_Properties::scope, and GNUNET_HELLO_Address::transport_name.

Referenced by add_valid_address(), and GST_validation_handle_pong().

495 {
496  struct GNUNET_ATS_AddressRecord *ar;
497  struct AddressInfo *ai;
498 
499  if (0 ==
500  memcmp (&GST_my_identity,
501  &address->peer,
502  sizeof (struct GNUNET_PeerIdentity)))
503  return; /* our own, ignore! */
504  /* validadte address */
505  if (NULL == address->transport_name)
506  {
507  GNUNET_break(0);
508  return;
509  }
513  ai = find_ai_no_session (address);
514  GNUNET_assert (NULL == ai);
516 
517  /* address seems sane, let's tell ATS */
519  "Notifying ATS about peer %s's new address `%s'\n",
520  GNUNET_i2s (&address->peer),
521  GST_plugins_a2s (address));
523  address,
524  NULL,
525  prop);
526  GNUNET_assert (NULL != ar);
527  ai = GNUNET_new (struct AddressInfo);
528  ai->address = GNUNET_HELLO_address_copy (address);
529  ai->ar = ar;
530  ai->properties = *prop;
532  &ai->address->peer,
533  ai,
536 }
static struct GNUNET_PeerIdentity GST_my_identity
Our public key.
#define GNUNET_assert(cond)
Use this for fatal errors that cannot be handled.
struct GNUNET_ATS_Properties properties
Performance properties of this address.
#define GNUNET_new(type)
Allocate a struct or union of the given type.
struct GNUNET_ATS_SchedulingHandle * GST_ats
ATS scheduling handle.
#define GNUNET_break(cond)
Use this for internal assertion violations that are not fatal (can be handled) but should not occur...
static struct GNUNET_CONTAINER_MultiPeerMap * p2a
Map from peer identities to one or more struct AddressInfo values for the peer.
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
struct GNUNET_ATS_AddressRecord * ar
Record with ATS API for the address.
This is an inbound address and cannot be used to initiate an outbound connection to another peer...
const char * transport_name
Name of the transport plugin enabling the communication using this address.
#define LOG(kind,...)
Log convenience function.
const char * GST_plugins_a2s(const struct GNUNET_HELLO_Address *address)
Convert a given address to a human-readable format.
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.
Information we track for each address known to ATS.
static struct AddressInfo * find_ai_no_session(const struct GNUNET_HELLO_Address *address)
Find the address information struct for the given address (ignoring sessions)
static struct GNUNET_TRANSPORT_AddressIdentifier * ai
Handle to the operation that publishes our address.
struct GNUNET_PeerIdentity peer
For which peer is this an address?
enum GNUNET_NetworkType scope
Which network scope does the respective address belong to? This property does not change...
Allow multiple values with the same key.
int GNUNET_CONTAINER_multipeermap_put(struct GNUNET_CONTAINER_MultiPeerMap *map, const struct GNUNET_PeerIdentity *key, void *value, enum GNUNET_CONTAINER_MultiHashMapOption opt)
Store a key-value pair in the map.
The identity of the host (wraps the signing key of the peer).
struct GNUNET_HELLO_Address * GNUNET_HELLO_address_copy(const struct GNUNET_HELLO_Address *address)
Copy an address struct.
Definition: address.c:109
struct GNUNET_HELLO_Address * address
The address (with peer identity).
#define GNUNET_YES
Definition: gnunet_common.h:80
const char * GNUNET_i2s(const struct GNUNET_PeerIdentity *pid)
Convert a peer identity to a string (for printing debug messages).
static void publish_p2a_stat_update()
Provide an update on the p2a map size to statistics.
Category of last resort.
Definition: gnunet_nt_lib.h:40
Here is the call graph for this function:
Here is the caller graph for this function:

◆ GST_ats_new_session()

void GST_ats_new_session ( const struct GNUNET_HELLO_Address address,
struct GNUNET_ATS_Session session 
)

Notify ATS about a new session now existing for the given address.

Essentially, an outbound address was used to establish a session. It is safe to call this function repeatedly for the same address and session pair.

Parameters
addressthe address
sessionthe session

Definition at line 549 of file gnunet-service-transport_ats.c.

References ai, AddressInfo::ar, find_ai(), GNUNET_assert, GNUNET_ATS_address_add_session(), GNUNET_ERROR_TYPE_DEBUG, GNUNET_i2s(), GST_my_identity, LOG, GNUNET_HELLO_Address::peer, AddressInfo::session, and AddressInfo::unblock_task.

Referenced by multicast_pong(), send_syn_ack_message(), set_alternative_address(), and switch_address_bl_check_cont().

551 {
552  struct AddressInfo *ai;
553 
554  if (0 ==
555  memcmp (&GST_my_identity,
556  &address->peer,
557  sizeof (struct GNUNET_PeerIdentity)))
558  return; /* our own, ignore! */
559  ai = find_ai (address, NULL);
560  if (NULL == ai)
561  {
562  /* We may simply already be aware of the session, even if some
563  other part of the code could not tell if it just created a new
564  session or just got one recycled from the plugin; hence, we may
565  be called with "new" session even for an "old" session; in that
566  case, check that this is the case, but just ignore it. */
567  GNUNET_assert (NULL != (find_ai (address, session)));
568  return;
569  }
570  GNUNET_assert (NULL == ai->session);
571  ai->session = session;
573  "Telling ATS about new session for peer %s\n",
574  GNUNET_i2s (&address->peer));
575  /* Note that the address might currently be blocked; we only
576  tell ATS about the session if the address is currently not
577  blocked; otherwise, ATS will be told about the session on
578  unblock. */
579  if (NULL != ai->ar)
581  session);
582  else
583  GNUNET_assert (NULL != ai->unblock_task);
584 }
static struct GNUNET_PeerIdentity GST_my_identity
Our public key.
#define GNUNET_assert(cond)
Use this for fatal errors that cannot be handled.
struct GNUNET_SCHEDULER_Task * unblock_task
Task scheduled to unblock an ATS-blocked address at blocked time, or NULL if the address is not block...
struct GNUNET_ATS_AddressRecord * ar
Record with ATS API for the address.
#define LOG(kind,...)
Log convenience function.
Information we track for each address known to ATS.
static struct GNUNET_TRANSPORT_AddressIdentifier * ai
Handle to the operation that publishes our address.
struct GNUNET_PeerIdentity peer
For which peer is this an address?
The identity of the host (wraps the signing key of the peer).
static struct AddressInfo * find_ai(const struct GNUNET_HELLO_Address *address, struct GNUNET_ATS_Session *session)
Find the address information struct for the given address and session.
void GNUNET_ATS_address_add_session(struct GNUNET_ATS_AddressRecord *ar, struct GNUNET_ATS_Session *session)
An address was used to initiate a session.
struct GNUNET_ATS_Session * session
Session (can be NULL)
const char * GNUNET_i2s(const struct GNUNET_PeerIdentity *pid)
Convert a peer identity to a string (for printing debug messages).
Here is the call graph for this function:
Here is the caller graph for this function:

◆ destroy_ai()

static void destroy_ai ( struct AddressInfo ai)
static

Release memory used by the given address data.

Parameters
aithe struct AddressInfo

Definition at line 593 of file gnunet-service-transport_ats.c.

References AddressInfo::address, AddressInfo::ar, GNUNET_assert, GNUNET_ATS_address_destroy(), GNUNET_CONTAINER_multipeermap_remove(), GNUNET_ERROR_TYPE_DEBUG, GNUNET_free, GNUNET_HELLO_address_free, GNUNET_i2s(), GNUNET_SCHEDULER_cancel(), GNUNET_YES, LOG, num_blocked, GNUNET_HELLO_Address::peer, publish_p2a_stat_update(), AddressInfo::session, and AddressInfo::unblock_task.

Referenced by destroy_ai_cb(), GST_ats_del_session(), and GST_ats_expire_address().

594 {
595  GNUNET_assert (NULL == ai->session);
596  if (NULL != ai->unblock_task)
597  {
599  ai->unblock_task = NULL;
600  num_blocked--;
601  }
604  &ai->address->peer,
605  ai));
607  "Telling ATS to destroy address from peer %s\n",
608  GNUNET_i2s (&ai->address->peer));
609  if (NULL != ai->ar)
610  {
612  ai->ar = NULL;
613  }
616  GNUNET_free (ai);
617 }
#define GNUNET_assert(cond)
Use this for fatal errors that cannot be handled.
struct GNUNET_SCHEDULER_Task * unblock_task
Task scheduled to unblock an ATS-blocked address at blocked time, or NULL if the address is not block...
static unsigned int num_blocked
Number of blocked addresses.
int GNUNET_CONTAINER_multipeermap_remove(struct GNUNET_CONTAINER_MultiPeerMap *map, const struct GNUNET_PeerIdentity *key, const void *value)
Remove the given key-value pair from the map.
static struct GNUNET_CONTAINER_MultiPeerMap * p2a
Map from peer identities to one or more struct AddressInfo values for the peer.
struct GNUNET_ATS_AddressRecord * ar
Record with ATS API for the address.
#define LOG(kind,...)
Log convenience function.
struct GNUNET_PeerIdentity peer
For which peer is this an address?
void GNUNET_ATS_address_destroy(struct GNUNET_ATS_AddressRecord *ar)
An address got destroyed, stop using it as a valid address.
struct GNUNET_HELLO_Address * address
The address (with peer identity).
#define GNUNET_YES
Definition: gnunet_common.h:80
struct GNUNET_ATS_Session * session
Session (can be NULL)
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.
static void publish_p2a_stat_update()
Provide an update on the p2a map size to statistics.
#define GNUNET_free(ptr)
Wrapper around free.
void * GNUNET_SCHEDULER_cancel(struct GNUNET_SCHEDULER_Task *task)
Cancel the task with the specified identifier.
Definition: scheduler.c:965
Here is the call graph for this function:
Here is the caller graph for this function:

◆ GST_ats_del_session()

void GST_ats_del_session ( const struct GNUNET_HELLO_Address address,
struct GNUNET_ATS_Session session 
)

Notify ATS that the session (but not the address) of a given address is no longer relevant.

(The session went down.) This function may be called even if for the respective outbound address GST_ats_new_session() was never called and thus the pair is unknown to ATS. In this case, the call is simply ignored.

Parameters
addressthe address
sessionthe session

Definition at line 632 of file gnunet-service-transport_ats.c.

References ai, AddressInfo::ar, destroy_ai(), AddressInfo::expired, find_ai(), GNUNET_assert, GNUNET_ATS_address_del_session(), GNUNET_ATS_address_destroy(), GNUNET_break, GNUNET_ERROR_TYPE_DEBUG, GNUNET_HELLO_address_check_option(), GNUNET_HELLO_ADDRESS_INFO_INBOUND, GNUNET_i2s(), GNUNET_NO, GNUNET_YES, GST_my_identity, LOG, GNUNET_HELLO_Address::peer, and AddressInfo::session.

Referenced by plugin_env_session_end().

634 {
635  struct AddressInfo *ai;
636 
637  if (0 ==
638  memcmp (&GST_my_identity,
639  &address->peer,
640  sizeof (struct GNUNET_PeerIdentity)))
641  return; /* our own, ignore! */
642  if (NULL == session)
643  {
644  GNUNET_break (0);
645  return;
646  }
647  ai = find_ai (address,
648  session);
649  if (NULL == ai)
650  {
651  /* We sometimes create sessions just for sending a PING,
652  and if those are destroyed they were never known to
653  ATS which means we end up here (however, in this
654  case, the address must be an outbound address). */
658  return;
659  }
660  GNUNET_assert (session == ai->session);
661  ai->session = NULL;
663  "Telling ATS to destroy session %p from peer %s\n",
664  session,
665  GNUNET_i2s (&address->peer));
666  if (GNUNET_YES == ai->expired)
667  {
668  /* last reason to keep this 'ai' around is now gone, the
669  session is dead as well, clean up */
670  if (NULL != ai->ar)
671  {
672  /* Address expired but not blocked, and thus 'ar' was still
673  live because of the session; deleting just the session
674  will do for an inbound session, but for an outbound we
675  then also need to destroy the address with ATS. */
676  if (GNUNET_NO ==
678  session))
679  {
681  }
682  /* "ar" has been freed, regardless how the branch
683  above played out: it was either freed in
684  #GNUNET_ATS_address_del_session() because it was
685  incoming, or explicitly in
686  #GNUNET_ATS_address_del_session(). */
687  ai->ar = NULL;
688  }
689  destroy_ai (ai);
690  return;
691  }
692 
693  if (NULL == ai->ar)
694  {
695  /* If ATS doesn't know about the address/session, this means
696  this address was blocked. */
697  if (GNUNET_YES ==
700  {
701  /* This was a blocked inbound session, which now lost the
702  session. But inbound addresses are by themselves useless,
703  so we must forget about the address as well. */
704  destroy_ai (ai);
705  return;
706  }
707  /* Otherwise, we are done as we have set `ai->session` to NULL
708  already and ATS will simply not be told about the session when
709  the connection is unblocked and the outbound address becomes
710  available again. . */
711  return;
712  }
713 
714  /* This is the "simple" case where ATS knows about the session and
715  the address is neither blocked nor expired. Delete the session,
716  and if it was inbound, free the address as well. */
717  if (GNUNET_YES ==
719  session))
720  {
721  /* This was an inbound address, the session is now gone, so we
722  need to also forget about the address itself. */
723  ai->ar = NULL;
724  destroy_ai (ai);
725  }
726 }
static struct GNUNET_PeerIdentity GST_my_identity
Our public key.
#define GNUNET_assert(cond)
Use this for fatal errors that cannot be handled.
#define GNUNET_NO
Definition: gnunet_common.h:81
#define GNUNET_break(cond)
Use this for internal assertion violations that are not fatal (can be handled) but should not occur...
static void destroy_ai(struct AddressInfo *ai)
Release memory used by the given address data.
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
struct GNUNET_ATS_AddressRecord * ar
Record with ATS API for the address.
This is an inbound address and cannot be used to initiate an outbound connection to another peer...
#define LOG(kind,...)
Log convenience function.
Information we track for each address known to ATS.
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.
static struct GNUNET_TRANSPORT_AddressIdentifier * ai
Handle to the operation that publishes our address.
struct GNUNET_PeerIdentity peer
For which peer is this an address?
The identity of the host (wraps the signing key of the peer).
static struct AddressInfo * find_ai(const struct GNUNET_HELLO_Address *address, struct GNUNET_ATS_Session *session)
Find the address information struct for the given address and session.
void GNUNET_ATS_address_destroy(struct GNUNET_ATS_AddressRecord *ar)
An address got destroyed, stop using it as a valid address.
#define GNUNET_YES
Definition: gnunet_common.h:80
struct GNUNET_ATS_Session * session
Session (can be NULL)
const char * GNUNET_i2s(const struct GNUNET_PeerIdentity *pid)
Convert a peer identity to a string (for printing debug messages).
int expired
Set to GNUNET_YES if the address has expired but we could not yet remove it because we still have a v...
Here is the call graph for this function:
Here is the caller graph for this function:

◆ GST_ats_update_distance()

void GST_ats_update_distance ( const struct GNUNET_HELLO_Address address,
uint32_t  distance 
)

Notify ATS about DV distance change to an address.

Does nothing if the address is not known to us.

Parameters
addressthe address
distancenew distance value

Definition at line 737 of file gnunet-service-transport_ats.c.

References ai, AddressInfo::ar, GNUNET_ATS_Properties::distance, find_ai_no_session(), GNUNET_ATS_address_update(), GNUNET_ERROR_TYPE_DEBUG, GNUNET_i2s(), GST_manipulation_manipulate_metrics(), LOG, GNUNET_HELLO_Address::peer, AddressInfo::properties, and AddressInfo::session.

Referenced by plugin_env_update_distance().

739 {
740  struct AddressInfo *ai;
741 
742  ai = find_ai_no_session (address);
743  if (NULL == ai)
744  {
745  /* We do not know about this address, do nothing. */
746  return;
747  }
749  "Updated distance for peer `%s' to %u\n",
750  GNUNET_i2s (&address->peer),
751  distance);
752  ai->properties.distance = distance;
753  /* Give manipulation its chance to change metrics */
755  ai->session,
756  &ai->properties);
757  /* Address may be blocked, only give ATS if address is
758  currently active. */
759  if (NULL != ai->ar)
761  &ai->properties);
762 }
void GST_manipulation_manipulate_metrics(const struct GNUNET_HELLO_Address *address, struct GNUNET_ATS_Session *session, struct GNUNET_ATS_Properties *prop)
Function that will be called to manipulate ATS information according to current manipulation settings...
struct GNUNET_ATS_Properties properties
Performance properties of this address.
struct GNUNET_ATS_AddressRecord * ar
Record with ATS API for the address.
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.
#define LOG(kind,...)
Log convenience function.
Information we track for each address known to ATS.
static struct AddressInfo * find_ai_no_session(const struct GNUNET_HELLO_Address *address)
Find the address information struct for the given address (ignoring sessions)
static struct GNUNET_TRANSPORT_AddressIdentifier * ai
Handle to the operation that publishes our address.
struct GNUNET_PeerIdentity peer
For which peer is this an address?
struct GNUNET_ATS_Session * session
Session (can be NULL)
unsigned int distance
Distance on network layer (required for distance-vector routing) in hops.
const char * GNUNET_i2s(const struct GNUNET_PeerIdentity *pid)
Convert a peer identity to a string (for printing debug messages).
Here is the call graph for this function:
Here is the caller graph for this function:

◆ GST_ats_update_delay()

void GST_ats_update_delay ( const struct GNUNET_HELLO_Address address,
struct GNUNET_TIME_Relative  delay 
)

Notify ATS about delay changes to properties of an address.

Does nothing if the address is not known to us.

Parameters
addressthe address
delaynew delay value

Definition at line 773 of file gnunet-service-transport_ats.c.

References ai, AddressInfo::ar, delay, GNUNET_ATS_Properties::delay, find_ai_no_session(), GNUNET_ATS_address_update(), GNUNET_ERROR_TYPE_DEBUG, GNUNET_i2s(), GNUNET_STRINGS_relative_time_to_string(), GNUNET_YES, GST_manipulation_manipulate_metrics(), LOG, GNUNET_HELLO_Address::peer, AddressInfo::properties, and AddressInfo::session.

Referenced by GST_neighbours_keepalive_response(), and GST_validation_handle_pong().

775 {
776  struct AddressInfo *ai;
777 
778  ai = find_ai_no_session (address);
779  if (NULL == ai)
780  {
781  /* We do not know about this address, do nothing. */
782  return;
783  }
785  "Updated latency for peer `%s' to %s\n",
786  GNUNET_i2s (&address->peer),
788  GNUNET_YES));
789  ai->properties.delay = delay;
790  /* Give manipulation its chance to change metrics */
792  ai->session,
793  &ai->properties);
794  /* Address may be blocked, only give ATS if address is
795  currently active. */
796  if (NULL != ai->ar)
798  &ai->properties);
799 }
void GST_manipulation_manipulate_metrics(const struct GNUNET_HELLO_Address *address, struct GNUNET_ATS_Session *session, struct GNUNET_ATS_Properties *prop)
Function that will be called to manipulate ATS information according to current manipulation settings...
struct GNUNET_ATS_Properties properties
Performance properties of this address.
struct GNUNET_ATS_AddressRecord * ar
Record with ATS API for the address.
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.
const char * GNUNET_STRINGS_relative_time_to_string(struct GNUNET_TIME_Relative delta, int do_round)
Give relative time in human-readable fancy format.
Definition: strings.c:727
struct GNUNET_TIME_Relative delay
Delay.
#define LOG(kind,...)
Log convenience function.
Information we track for each address known to ATS.
static struct AddressInfo * find_ai_no_session(const struct GNUNET_HELLO_Address *address)
Find the address information struct for the given address (ignoring sessions)
static struct GNUNET_TRANSPORT_AddressIdentifier * ai
Handle to the operation that publishes our address.
static struct GNUNET_TIME_Relative delay
When should dkg communication start?
struct GNUNET_PeerIdentity peer
For which peer is this an address?
#define GNUNET_YES
Definition: gnunet_common.h:80
struct GNUNET_ATS_Session * session
Session (can be NULL)
const char * GNUNET_i2s(const struct GNUNET_PeerIdentity *pid)
Convert a peer identity to a string (for printing debug messages).
Here is the call graph for this function:
Here is the caller graph for this function:

◆ GST_ats_update_utilization()

void GST_ats_update_utilization ( const struct GNUNET_HELLO_Address address,
uint32_t  bps_in,
uint32_t  bps_out 
)

Notify ATS about utilization changes to an address.

Does nothing if the address is not known to us.

Parameters
addressour information about the address
bps_innew utilization inbound
bps_outnew utilization outbound

Definition at line 811 of file gnunet-service-transport_ats.c.

References ai, AddressInfo::ar, find_ai_no_session(), GNUNET_ATS_address_update(), GNUNET_ERROR_TYPE_DEBUG, GNUNET_i2s(), GST_manipulation_manipulate_metrics(), GST_plugins_a2s(), LOG, GNUNET_HELLO_Address::peer, AddressInfo::properties, AddressInfo::session, GNUNET_ATS_Properties::utilization_in, and GNUNET_ATS_Properties::utilization_out.

Referenced by send_utilization_data().

814 {
815  struct AddressInfo *ai;
816 
817  ai = find_ai_no_session (address);
818  if (NULL == ai)
819  {
820  /* We do not know about this address, do nothing. */
821  return;
822  }
824  "Updating utilization for peer `%s' address %s: %u/%u\n",
825  GNUNET_i2s (&address->peer),
826  GST_plugins_a2s (address),
827  (unsigned int) bps_in,
828  (unsigned int) bps_out);
829  ai->properties.utilization_in = bps_in;
830  ai->properties.utilization_out = bps_out;
831  /* Give manipulation its chance to change metrics */
833  ai->session,
834  &ai->properties);
835  /* Address may be blocked, only give ATS if address is
836  currently active. */
837  if (NULL != ai->ar)
839  &ai->properties);
840 }
void GST_manipulation_manipulate_metrics(const struct GNUNET_HELLO_Address *address, struct GNUNET_ATS_Session *session, struct GNUNET_ATS_Properties *prop)
Function that will be called to manipulate ATS information according to current manipulation settings...
uint32_t utilization_in
Actual traffic on this connection from the other peer to this peer.
struct GNUNET_ATS_Properties properties
Performance properties of this address.
struct GNUNET_ATS_AddressRecord * ar
Record with ATS API for the address.
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.
#define LOG(kind,...)
Log convenience function.
const char * GST_plugins_a2s(const struct GNUNET_HELLO_Address *address)
Convert a given address to a human-readable format.
Information we track for each address known to ATS.
static struct AddressInfo * find_ai_no_session(const struct GNUNET_HELLO_Address *address)
Find the address information struct for the given address (ignoring sessions)
static struct GNUNET_TRANSPORT_AddressIdentifier * ai
Handle to the operation that publishes our address.
struct GNUNET_PeerIdentity peer
For which peer is this an address?
struct GNUNET_ATS_Session * session
Session (can be NULL)
const char * GNUNET_i2s(const struct GNUNET_PeerIdentity *pid)
Convert a peer identity to a string (for printing debug messages).
uint32_t utilization_out
Actual traffic on this connection from this peer to the other peer.
Here is the call graph for this function:
Here is the caller graph for this function:

◆ GST_ats_expire_address()

void GST_ats_expire_address ( const struct GNUNET_HELLO_Address address)

Notify ATS that the address has expired and thus cannot be used any longer.

This function must only be called if the corresponding session is already gone.

Parameters
addressthe address

Definition at line 851 of file gnunet-service-transport_ats.c.

References ai, destroy_ai(), AddressInfo::expired, find_ai_no_session(), GNUNET_assert, GNUNET_ERROR_TYPE_DEBUG, GNUNET_i2s(), GNUNET_YES, GST_my_identity, GST_plugins_a2s(), LOG, GNUNET_HELLO_Address::peer, and AddressInfo::session.

Referenced by cleanup_validation_entry().

852 {
853  struct AddressInfo *ai;
854 
855  if (0 ==
856  memcmp (&GST_my_identity,
857  &address->peer,
858  sizeof (struct GNUNET_PeerIdentity)))
859  return; /* our own, ignore! */
861  "Address %s of peer %s expired\n",
862  GST_plugins_a2s (address),
863  GNUNET_i2s (&address->peer));
864  ai = find_ai_no_session (address);
865  if (NULL == ai)
866  {
867  GNUNET_assert (0);
868  return;
869  }
870  if (NULL != ai->session)
871  {
872  /* Got an active session, just remember the expiration
873  and act upon it when the session goes down. */
874  ai->expired = GNUNET_YES;
875  return;
876  }
877  /* Address expired, no session, free resources */
878  destroy_ai (ai);
879 }
static struct GNUNET_PeerIdentity GST_my_identity
Our public key.
#define GNUNET_assert(cond)
Use this for fatal errors that cannot be handled.
static void destroy_ai(struct AddressInfo *ai)
Release memory used by the given address data.
#define LOG(kind,...)
Log convenience function.
const char * GST_plugins_a2s(const struct GNUNET_HELLO_Address *address)
Convert a given address to a human-readable format.
Information we track for each address known to ATS.
static struct AddressInfo * find_ai_no_session(const struct GNUNET_HELLO_Address *address)
Find the address information struct for the given address (ignoring sessions)
static struct GNUNET_TRANSPORT_AddressIdentifier * ai
Handle to the operation that publishes our address.
struct GNUNET_PeerIdentity peer
For which peer is this an address?
The identity of the host (wraps the signing key of the peer).
#define GNUNET_YES
Definition: gnunet_common.h:80
struct GNUNET_ATS_Session * session
Session (can be NULL)
const char * GNUNET_i2s(const struct GNUNET_PeerIdentity *pid)
Convert a peer identity to a string (for printing debug messages).
int expired
Set to GNUNET_YES if the address has expired but we could not yet remove it because we still have a v...
Here is the call graph for this function:
Here is the caller graph for this function:

◆ GST_ats_init()

void GST_ats_init ( void  )

Initialize ATS subsystem.

Definition at line 886 of file gnunet-service-transport_ats.c.

References GNUNET_CONTAINER_multipeermap_create(), and GNUNET_YES.

Referenced by run().

887 {
889 }
struct GNUNET_CONTAINER_MultiPeerMap * GNUNET_CONTAINER_multipeermap_create(unsigned int len, int do_not_copy_keys)
Create a multi peer map (hash map for public keys of peers).
static struct GNUNET_CONTAINER_MultiPeerMap * p2a
Map from peer identities to one or more struct AddressInfo values for the peer.
#define GNUNET_YES
Definition: gnunet_common.h:80
Here is the call graph for this function:
Here is the caller graph for this function:

◆ destroy_ai_cb()

static int destroy_ai_cb ( void *  cls,
const struct GNUNET_PeerIdentity key,
void *  value 
)
static

Release memory used by the given address data.

Parameters
clsNULL
keywhich peer is this about
valuethe struct AddressInfo
Returns
GNUNET_OK (continue to iterate)

Definition at line 901 of file gnunet-service-transport_ats.c.

References ai, destroy_ai(), GNUNET_OK, and value.

Referenced by GST_ats_done().

904 {
905  struct AddressInfo *ai = value;
906 
907  destroy_ai (ai);
908  return GNUNET_OK;
909 }
#define GNUNET_OK
Named constants for return values.
Definition: gnunet_common.h:78
static void destroy_ai(struct AddressInfo *ai)
Release memory used by the given address data.
static char * value
Value of the record to add/remove.
Information we track for each address known to ATS.
static struct GNUNET_TRANSPORT_AddressIdentifier * ai
Handle to the operation that publishes our address.
Here is the call graph for this function:
Here is the caller graph for this function:

◆ GST_ats_done()

void GST_ats_done ( void  )

Shutdown ATS subsystem.

Definition at line 916 of file gnunet-service-transport_ats.c.

References destroy_ai_cb(), GNUNET_CONTAINER_multipeermap_destroy(), GNUNET_CONTAINER_multipeermap_iterate(), and publish_p2a_stat_update().

Referenced by shutdown_task().

917 {
919  &destroy_ai_cb,
920  NULL);
923  p2a = NULL;
924 }
void GNUNET_CONTAINER_multipeermap_destroy(struct GNUNET_CONTAINER_MultiPeerMap *map)
Destroy a hash map.
static struct GNUNET_CONTAINER_MultiPeerMap * p2a
Map from peer identities to one or more struct AddressInfo values for the peer.
static int destroy_ai_cb(void *cls, const struct GNUNET_PeerIdentity *key, void *value)
Release memory used by the given address data.
int GNUNET_CONTAINER_multipeermap_iterate(struct GNUNET_CONTAINER_MultiPeerMap *map, GNUNET_CONTAINER_PeerMapIterator it, void *it_cls)
Iterate over all entries in the map.
static void publish_p2a_stat_update()
Provide an update on the p2a map size to statistics.
Here is the call graph for this function:
Here is the caller graph for this function:

Variable Documentation

◆ p2a

struct GNUNET_CONTAINER_MultiPeerMap* p2a
static

Map from peer identities to one or more struct AddressInfo values for the peer.

Definition at line 100 of file gnunet-service-transport_ats.c.

◆ num_blocked

unsigned int num_blocked
static

Number of blocked addresses.

Definition at line 105 of file gnunet-service-transport_ats.c.

Referenced by destroy_ai(), GST_ats_block_address(), publish_p2a_stat_update(), and unblock_address().