GNUnet  0.10.x
Data Structures | Macros | Typedefs | Functions | Variables
gnunet-service-ats_addresses.h File Reference

ats service address management More...

#include "gnunet_util_lib.h"
#include "gnunet_ats_service.h"
#include "gnunet-service-ats.h"
#include "ats.h"
Include dependency graph for gnunet-service-ats_addresses.h:
This graph shows which files directly or indirectly include this file:

Go to the source code of this file.

Data Structures

struct  GAS_NormalizationInfo
 Information provided by ATS normalization. More...
 
struct  ATS_Address
 Address with additional information. More...
 

Macros

#define ATS_BLOCKING_DELTA   GNUNET_TIME_relative_multiply(GNUNET_TIME_UNIT_MILLISECONDS, 100)
 NOTE: Do not change this documentation. More...
 

Typedefs

typedef void(* GNUNET_ATS_PeerInfo_Iterator) (void *cls, const struct GNUNET_PeerIdentity *id, const char *plugin_name, const void *plugin_addr, size_t plugin_addr_len, const int address_active, const struct GNUNET_ATS_Properties *prop, enum GNUNET_HELLO_AddressInfo local_address_info, struct GNUNET_BANDWIDTH_Value32NBO bandwidth_out, struct GNUNET_BANDWIDTH_Value32NBO bandwidth_in)
 Iterator for GAS_addresses_get_peer_info() More...
 

Functions

void GAS_addresses_init (void)
 Initialize address subsystem. More...
 
void GAS_addresses_done (void)
 Shutdown address subsystem. More...
 
void GAS_addresses_add (const struct GNUNET_PeerIdentity *peer, const char *plugin_name, const void *plugin_addr, size_t plugin_addr_len, uint32_t local_address_info, uint32_t session_id, const struct GNUNET_ATS_Properties *prop)
 Add a new address for a peer. More...
 
void GAS_addresses_update (const struct GNUNET_PeerIdentity *peer, uint32_t session_id, const struct GNUNET_ATS_Properties *prop)
 Update an address with new performance information for a peer. More...
 
void GAS_addresses_destroy (const struct GNUNET_PeerIdentity *peer, uint32_t session_id)
 Remove an address for a peer. More...
 
void GAS_addresses_destroy_all (void)
 Remove all addresses. More...
 
void GAS_addresses_get_peer_info (const struct GNUNET_PeerIdentity *peer, GNUNET_ATS_PeerInfo_Iterator pi_it, void *pi_it_cls)
 Return information all peers currently known to ATS. More...
 
void GAS_handle_request_address_list (struct GNUNET_SERVICE_Client *client, const struct AddressListRequestMessage *alrm)
 Handle 'address list request' messages from clients. More...
 

Variables

struct GNUNET_CONTAINER_MultiPeerMapGSA_addresses
 A multipeermap mapping peer identities to struct ATS_Address. More...
 

Detailed Description

ats service address management

Author
Matthias Wachs
Christian Grothoff

Definition in file gnunet-service-ats_addresses.h.

Macro Definition Documentation

◆ ATS_BLOCKING_DELTA

#define ATS_BLOCKING_DELTA   GNUNET_TIME_relative_multiply(GNUNET_TIME_UNIT_MILLISECONDS, 100)

NOTE: Do not change this documentation.

This documentation is based on gnunet.org:/vcs/fsnsg/ats-paper.git/tech-doku/ats-tech-guide.tex use build_txt.sh to generate plaintext output

1 ATS addresses : ATS address management

This ATS addresses ("addresses") component manages the addresses known to ATS service and suggests addresses to transport service when it is interested in address suggestion for a peer. ATS addresses also instantiates the bandwidth assignment mechanism (solver), notifies it about changes to addresses and forwards changes to bandwidth assignments to transport, depending if transport is interested in this change.

1.1 Input data

1.1.1 Addresses

Addresses are added by specifying peer ID, plugin, address, address length and session, if available. ATS information can be specified if available.

1.1.2 Networks

ATS specifies a fix set of networks an address can belong to. For each network an inbound and outbound quota will be specified. The available networks and addtional helper varaibles are defined in gnunet_ats_service.h. At the moment 5 networks are defined:

  • GNUNET_NT_UNSPECIFIED
  • GNUNET_NT_LOOPBACK
  • GNUNET_NT_LAN
  • GNUNET_NT_WAN
  • GNUNET_NT_WLAN

The total number of networks defined is stored in GNUNET_NT_COUNT GNUNET_ATS_NetworkType can be used array initializer for an int array, while GNUNET_ATS_NetworkType is an initializer for a char array containing a string description of all networks

1.1.3 Quotas

An inbound and outbound quota for each of the networks mentioned in 1.1.2 is loaded from ats configuration during initialization. This quota defines to total amount of inbound and outbound traffic allowed for a specific network. The configuration values used are in section ats:

  • "NETWORK"_QUOTA_IN =
  • "NETWORK"_QUOTA_IN =

You can specify quotas by setting the

to a:

  • unrestricted: unlimited
  • number of bytes: e.g. 10240
  • fancy value: e.g. 64 Kib

unlimited is defined as GNUNET_ATS_MaxBandwidthString and equivalent to the value GNUNET_ATS_MaxBandwidth Important predefined values for quotas are:

  • GNUNET_ATS_DefaultBandwidth: 65536
  • GNUNET_ATS_MaxBandwidth: UINT32_MAX
  • GNUNET_CONSTANTS_DEFAULT_BW_IN_OUT: 1024

Details of loading quotas and default values will be described on

1.1.4 Preference values

1.2 Data structures used

Addresse uses struct ATS_Address for each address. The structs are stored in a linked list and provides a pointer void *solver_information for the solver to store address specific information. It provides the int values active which is set to GNUNET_YES if the address is select for transport use and used, representing that transport service is actively using this address. Address information are stored in peer, addr, addr_len, plugin.

1.3 Initialization

During initialization a hashmap to store addresses is created. The quotas for all networks defined for ATS are loaded from configuration. For each network first the logic will check if the string GNUNET_ATS_MaxBandwidthString is configured, if not it will try to convert the configured value as a fancy size and if this fails it will try to use it as a value_number. If no configuration value is found it will assign GNUNET_ATS_DefaultBandwidth. The most important step is to load the configured solver using configuration "[ats]:MODE". Current solvers are MODE_PROPORTIONAL, MODE_MLP. Interaction is done using a solver API

1.4 Solver API

Solver functions:

  • s_init: init the solver with required information
  • s_add: add a new address
  • s_update: update ATS values or session for an address
  • s_get: get prefered address for a peer
  • s_del: delete an address
  • s_pref: change preference value for a peer
  • s_done: shutdown solver

Callbacks: addresses provides a bandwidth_changed_cb callback to the solver which is called when bandwidth assigned to peer has changed

1.5 Shutdown

During shutdown all addresses are freed and the solver told to shutdown

1.6 Addresses and sessions

Addresses consist of the address itself and a numerical session. When a new address without a session is added it has no session, so it gets session 0 assigned. When an address with a session is added and an address object with session 0 is found, this object is updated with the session otherwise a new address object with this session assigned is created.

1.6.1 Terminology

Addresses a1,a2 with session s1, s2 are "exact" if: (a1 == a2)&&(s1 == s2) Addresses a1,a2 with session s1, s2 are "equivalent" if: (a1 == a2)&&((s1 == s2)||(s1 == 0)||(s2 == 0)

1.7 Address management

Transport service notifies ATS about changes to the addresses known to it.

1.7.1 Adding an address

When transport learns a new address it tells ATS and ATS is telling addresses about it using GAS_address_add. If not known to addresses it creates a new address object and calls solver's s_add. ATS information are deserialized and solver is notified about the session and ATS information using s_update.

1.7.2 Updating an address

Addresses does an lookup up for the existing address with the given session. If disassembles included ATS information and notifies the solver using s_update about the update.

1.7.3 Deleting an address

Addresses does an lookup for the exact address and session and if removes this address. If session != 0 the session is set to 0 and the address is kept. If session == 0, the addresses is removed.

1.7.4 Requesting an address suggestion

The address client issues a request address message to be notified about address suggestions for a specific peer. Addresses asks the solver with s_get. If no address is available, it will not send a response, otherwise it will respond with the choosen address.

1.7.5 Address suggestions

Addresses will notify the client automatically on any bandwidth_changed_cb by the solver if a address suggestion request is pending. If no address is available it will not respond at all If the client is not interested anymore, it has to cancel the address suggestion request.

1.7.6 Suggestions blocks and reset

After suggesting an address it is blocked for ATS_BLOCKING_DELTA sec. to prevent the client from being thrashed. If the client requires immediately it can reset this block using GAS_addresses_handle_backoff_reset.

1.7.7 Address lifecycle

  • (add address)
  • (updated address)
  • (delete address)

1.8 Bandwidth assignment

The addresses are used to perform resource allocation operations. ATS addresses takes care of instantiating the solver configured and notifies the respective solver about address changes and receives changes to the bandwidth assignment from the solver. The current bandwidth assignment is sent to transport. The specific solvers will be described in the specific section.

1.9 Changing peer preferences

The bandwidth assigned to a peer can be influenced by setting a preference for a peer. The prefernce will be given to to the solver with s_pref which has to take care of the preference value

Definition at line 224 of file gnunet-service-ats_addresses.h.

Typedef Documentation

◆ GNUNET_ATS_PeerInfo_Iterator

typedef void(* GNUNET_ATS_PeerInfo_Iterator) (void *cls, const struct GNUNET_PeerIdentity *id, const char *plugin_name, const void *plugin_addr, size_t plugin_addr_len, const int address_active, const struct GNUNET_ATS_Properties *prop, enum GNUNET_HELLO_AddressInfo local_address_info, struct GNUNET_BANDWIDTH_Value32NBO bandwidth_out, struct GNUNET_BANDWIDTH_Value32NBO bandwidth_in)

Iterator for GAS_addresses_get_peer_info()

Parameters
clsclosure
idthe peer id
plugin_nameplugin name
plugin_addraddress
plugin_addr_lenlength of plugin_addr
address_activeis address actively used
atsiats performance information
local_address_infoflags for the address
bandwidth_outcurrent outbound bandwidth assigned to address
bandwidth_incurrent inbound bandwidth assigned to address

Definition at line 446 of file gnunet-service-ats_addresses.h.

Function Documentation

◆ GAS_addresses_init()

void GAS_addresses_init ( void  )

Initialize address subsystem.

The addresses subsystem manages the addresses known and current performance information.

The addresses subsystem manages the addresses known and current performance information. It has a solver component responsible for the resource allocation. It tells the solver about changes and receives updates when the solver changes the resource allocation.

Definition at line 350 of file gnunet-service-ats_addresses.c.

References GNUNET_CONTAINER_multipeermap_create(), GNUNET_NO, and update_addresses_stat().

Referenced by run().

351 {
354  GNUNET_NO);
356 }
static void update_addresses_stat()
Update statistic on number of addresses.
#define GNUNET_NO
Definition: gnunet_common.h:78
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).
struct GNUNET_CONTAINER_MultiPeerMap * GSA_addresses
A multihashmap to store all addresses.
Here is the call graph for this function:
Here is the caller graph for this function:

◆ GAS_addresses_done()

void GAS_addresses_done ( void  )

Shutdown address subsystem.

Definition at line 402 of file gnunet-service-ats_addresses.c.

References GAS_addresses_destroy_all(), GAS_plugin_solver_lock(), GAS_plugin_solver_unlock(), GNUNET_CONTAINER_multipeermap_destroy(), GNUNET_ERROR_TYPE_INFO, and GNUNET_log.

Referenced by cleanup_task(), and run().

403 {
405  "Shutting down addresses\n");
410  GSA_addresses = NULL;
411 }
void GAS_plugin_solver_lock()
Stop instant solving, there are many state updates happening in bulk right now.
void GAS_addresses_destroy_all()
Remove all addresses.
void GNUNET_CONTAINER_multipeermap_destroy(struct GNUNET_CONTAINER_MultiPeerMap *map)
Destroy a hash map.
void GAS_plugin_solver_unlock()
Resume instant solving, we are done with the bulk state updates.
struct GNUNET_CONTAINER_MultiPeerMap * GSA_addresses
A multihashmap to store all addresses.
#define GNUNET_log(kind,...)
Here is the call graph for this function:
Here is the caller graph for this function:

◆ GAS_addresses_add()

void GAS_addresses_add ( const struct GNUNET_PeerIdentity peer,
const char *  plugin_name,
const void *  plugin_addr,
size_t  plugin_addr_len,
uint32_t  local_address_info,
uint32_t  session_id,
const struct GNUNET_ATS_Properties prop 
)

Add a new address for a peer.

Parameters
peerpeer
plugin_nametransport plugin name
plugin_addrplugin address
plugin_addr_lenlength of the plugin_addr
local_address_infothe local address for the address
session_idsession id, can never be 0.
propperformance information for this address
peerpeer
plugin_nametransport plugin name
plugin_addrplugin address
plugin_addr_lenlength of the plugin address in plugin_addr
local_address_infothe local address for the address
session_idsession id, can be 0
propperformance information for this address

Definition at line 210 of file gnunet-service-ats_addresses.c.

References ATS_Address::active, ATS_Address::addr, ATS_Address::addr_len, ATS_Address::assigned_bw_in, ATS_Address::assigned_bw_out, create_address(), find_exact_address(), GAS_normalization_update_property(), GAS_performance_notify_all_clients(), GAS_plugin_new_address(), GAS_plugin_solver_lock(), GAS_plugin_solver_unlock(), GNUNET_assert, GNUNET_BANDWIDTH_value_init(), GNUNET_break, GNUNET_CONTAINER_MULTIHASHMAPOPTION_MULTIPLE, GNUNET_CONTAINER_multipeermap_put(), GNUNET_ERROR_TYPE_INFO, GNUNET_i2s(), GNUNET_log, GNUNET_NT_UNSPECIFIED, GNUNET_OK, GNUNET_TIME_absolute_get(), ATS_Address::local_address_info, ATS_Address::peer, ATS_Address::plugin, ATS_Address::properties, GNUNET_ATS_Properties::scope, ATS_Address::t_added, ATS_Address::t_last_activity, and update_addresses_stat().

Referenced by GAS_handle_address_add().

217 {
218  struct ATS_Address *new_address;
219 
220  if (NULL != find_exact_address(peer,
221  session_id))
222  {
223  GNUNET_break(0);
224  return;
225  }
227  new_address = create_address(peer,
228  plugin_name,
229  plugin_addr,
230  plugin_addr_len,
232  session_id);
233  /* Add a new address */
234  new_address->properties = *prop;
235  new_address->t_added = GNUNET_TIME_absolute_get();
236  new_address->t_last_activity = GNUNET_TIME_absolute_get();
239  peer,
240  new_address,
244  "Adding new address for peer `%s' slot %u\n",
245  GNUNET_i2s(peer),
246  session_id);
247  /* Tell solver about new address */
249  GAS_plugin_new_address(new_address);
250  GAS_normalization_update_property(new_address); // FIXME: needed?
252  /* Notify performance clients about new address */
254  new_address->plugin,
255  new_address->addr,
256  new_address->addr_len,
257  new_address->active,
258  &new_address->properties,
259  new_address->local_address_info,
262 }
static void update_addresses_stat()
Update statistic on number of addresses.
struct GNUNET_ATS_Properties properties
ATS performance information for this address.
void GAS_plugin_new_address(struct ATS_Address *new_address)
Tell the solver that the given address can now be used for talking to the respective peer...
int active
Is this the active address for this peer?
struct GNUNET_PeerIdentity peer
Peer ID this address is for.
void GAS_plugin_solver_lock()
Stop instant solving, there are many state updates happening in bulk right now.
#define GNUNET_assert(cond)
Use this for fatal errors that cannot be handled.
const void * addr
Address (in plugin-specific binary format).
static struct ATS_Address * create_address(const struct GNUNET_PeerIdentity *peer, const char *plugin_name, const void *plugin_addr, size_t plugin_addr_len, uint32_t local_address_info, uint32_t session_id)
Create a ATS_address with the given information.
static struct GNUNET_HashCode session_id
#define GNUNET_OK
Named constants for return values.
Definition: gnunet_common.h:75
size_t addr_len
Address length, number of bytes in addr.
char * plugin
Plugin name.
#define GNUNET_break(cond)
Use this for internal assertion violations that are not fatal (can be handled) but should not occur...
void GAS_performance_notify_all_clients(const struct GNUNET_PeerIdentity *peer, const char *plugin_name, const void *plugin_addr, size_t plugin_addr_len, int active, const struct GNUNET_ATS_Properties *prop, enum GNUNET_HELLO_AddressInfo local_address_info, struct GNUNET_BANDWIDTH_Value32NBO bandwidth_out, struct GNUNET_BANDWIDTH_Value32NBO bandwidth_in)
Transmit the given performance information to all performance clients.
void GAS_plugin_solver_unlock()
Resume instant solving, we are done with the bulk state updates.
uint32_t assigned_bw_in
Inbound bandwidth assigned by solver.
void GAS_normalization_update_property(struct ATS_Address *address)
Update and normalize atsi performance information.
static struct ATS_Address * find_exact_address(const struct GNUNET_PeerIdentity *peer, uint32_t session_id)
Find the exact address.
static char * plugin_name
Solver plugin name as string.
struct GNUNET_TIME_Absolute GNUNET_TIME_absolute_get(void)
Get the current time.
Definition: time.c:118
struct GNUNET_TIME_Absolute t_added
Time when address was added.
Address with additional information.
struct GNUNET_CONTAINER_MultiPeerMap * GSA_addresses
A multihashmap to store all addresses.
struct GNUNET_BANDWIDTH_Value32NBO GNUNET_BANDWIDTH_value_init(uint32_t bytes_per_second)
Create a new bandwidth value.
Definition: bandwidth.c:39
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.
uint32_t assigned_bw_out
Outbound bandwidth assigned by solver.
#define GNUNET_log(kind,...)
const char * GNUNET_i2s(const struct GNUNET_PeerIdentity *pid)
Convert a peer identity to a string (for printing debug messages).
enum GNUNET_HELLO_AddressInfo local_address_info
Field to store local flags.
Category of last resort.
Definition: gnunet_nt_lib.h:39
struct GNUNET_TIME_Absolute t_last_activity
Time when address had last activity (update, in uses)
Here is the call graph for this function:
Here is the caller graph for this function:

◆ GAS_addresses_update()

void GAS_addresses_update ( const struct GNUNET_PeerIdentity peer,
uint32_t  session_id,
const struct GNUNET_ATS_Properties prop 
)

Update an address with new performance information for a peer.

Parameters
peerpeer
session_idsession id, can never be 0
propperformance information for this address
peerpeer
session_idsession id, never 0
propperformance information for this address

Definition at line 273 of file gnunet-service-ats_addresses.c.

References ATS_Address::active, ATS_Address::addr, ATS_Address::addr_len, ATS_Address::assigned_bw_in, ATS_Address::assigned_bw_out, find_exact_address(), GAS_normalization_update_property(), GAS_performance_notify_all_clients(), GNUNET_BANDWIDTH_value_init(), GNUNET_break, GNUNET_ERROR_TYPE_DEBUG, GNUNET_i2s(), GNUNET_log, GNUNET_NT_UNSPECIFIED, GNUNET_TIME_absolute_get(), ATS_Address::local_address_info, ATS_Address::peer, ATS_Address::plugin, ATS_Address::properties, GNUNET_ATS_Properties::scope, ATS_Address::solver_information, and ATS_Address::t_last_activity.

Referenced by GAS_handle_address_update().

276 {
277  struct ATS_Address *aa;
278 
279  /* Get existing address */
280  aa = find_exact_address(peer,
281  session_id);
282  if (NULL == aa)
283  {
284  GNUNET_break(0);
285  return;
286  }
287  if (NULL == aa->solver_information)
288  {
289  GNUNET_break(0);
290  return;
291  }
293  "Received ADDRESS_UPDATE for peer `%s' slot %u\n",
294  GNUNET_i2s(peer),
295  (unsigned int)session_id);
297  /* Update address */
299  aa->properties = *prop;
300  /* Notify performance clients about updated address */
302  aa->plugin,
303  aa->addr,
304  aa->addr_len,
305  aa->active,
306  prop,
307  aa->local_address_info,
310 
312 }
struct GNUNET_ATS_Properties properties
ATS performance information for this address.
int active
Is this the active address for this peer?
struct GNUNET_PeerIdentity peer
Peer ID this address is for.
const void * addr
Address (in plugin-specific binary format).
static struct GNUNET_HashCode session_id
size_t addr_len
Address length, number of bytes in addr.
char * plugin
Plugin name.
#define GNUNET_break(cond)
Use this for internal assertion violations that are not fatal (can be handled) but should not occur...
void GAS_performance_notify_all_clients(const struct GNUNET_PeerIdentity *peer, const char *plugin_name, const void *plugin_addr, size_t plugin_addr_len, int active, const struct GNUNET_ATS_Properties *prop, enum GNUNET_HELLO_AddressInfo local_address_info, struct GNUNET_BANDWIDTH_Value32NBO bandwidth_out, struct GNUNET_BANDWIDTH_Value32NBO bandwidth_in)
Transmit the given performance information to all performance clients.
uint32_t assigned_bw_in
Inbound bandwidth assigned by solver.
void GAS_normalization_update_property(struct ATS_Address *address)
Update and normalize atsi performance information.
static struct ATS_Address * find_exact_address(const struct GNUNET_PeerIdentity *peer, uint32_t session_id)
Find the exact address.
struct GNUNET_TIME_Absolute GNUNET_TIME_absolute_get(void)
Get the current time.
Definition: time.c:118
Address with additional information.
void * solver_information
Solver-specific information for this address.
struct GNUNET_BANDWIDTH_Value32NBO GNUNET_BANDWIDTH_value_init(uint32_t bytes_per_second)
Create a new bandwidth value.
Definition: bandwidth.c:39
enum GNUNET_NetworkType scope
Which network scope does the respective address belong to? This property does not change...
uint32_t assigned_bw_out
Outbound bandwidth assigned by solver.
#define GNUNET_log(kind,...)
const char * GNUNET_i2s(const struct GNUNET_PeerIdentity *pid)
Convert a peer identity to a string (for printing debug messages).
enum GNUNET_HELLO_AddressInfo local_address_info
Field to store local flags.
Category of last resort.
Definition: gnunet_nt_lib.h:39
struct GNUNET_TIME_Absolute t_last_activity
Time when address had last activity (update, in uses)
Here is the call graph for this function:
Here is the caller graph for this function:

◆ GAS_addresses_destroy()

void GAS_addresses_destroy ( const struct GNUNET_PeerIdentity peer,
uint32_t  session_id 
)

Remove an address for a peer.

Parameters
peerpeer
session_idsession id, can never be 0

Definition at line 322 of file gnunet-service-ats_addresses.c.

References find_exact_address(), free_address(), GNUNET_break, GNUNET_ERROR_TYPE_DEBUG, GNUNET_i2s(), and GNUNET_log.

Referenced by GAS_handle_address_destroyed().

324 {
325  struct ATS_Address *ea;
326 
327  /* Get existing address */
328  ea = find_exact_address(peer,
329  session_id);
330  if (NULL == ea)
331  {
332  GNUNET_break(0);
333  return;
334  }
336  "Received ADDRESS_DESTROYED for peer `%s' session %u\n",
337  GNUNET_i2s(peer),
338  session_id);
339  free_address(ea);
340 }
static struct GNUNET_HashCode session_id
#define GNUNET_break(cond)
Use this for internal assertion violations that are not fatal (can be handled) but should not occur...
static struct ATS_Address * find_exact_address(const struct GNUNET_PeerIdentity *peer, uint32_t session_id)
Find the exact address.
Address with additional information.
#define GNUNET_log(kind,...)
const char * GNUNET_i2s(const struct GNUNET_PeerIdentity *pid)
Convert a peer identity to a string (for printing debug messages).
static void free_address(struct ATS_Address *addr)
Free the given address.
Here is the call graph for this function:
Here is the caller graph for this function:

◆ GAS_addresses_destroy_all()

void GAS_addresses_destroy_all ( void  )

Remove all addresses.

Definition at line 383 of file gnunet-service-ats_addresses.c.

References destroy_all_address_it(), GAS_plugin_solver_lock(), GAS_plugin_solver_unlock(), GNUNET_CONTAINER_multipeermap_iterate(), GNUNET_CONTAINER_multipeermap_size(), GNUNET_ERROR_TYPE_INFO, and GNUNET_log.

Referenced by GAS_addresses_done(), and GAS_scheduling_remove_client().

384 {
386  "Destroying all addresses\n");
387  if (0 ==
389  return;
393  NULL);
395 }
void GAS_plugin_solver_lock()
Stop instant solving, there are many state updates happening in bulk right now.
void GAS_plugin_solver_unlock()
Resume instant solving, we are done with the bulk state updates.
struct GNUNET_CONTAINER_MultiPeerMap * GSA_addresses
A multihashmap to store all addresses.
int GNUNET_CONTAINER_multipeermap_iterate(struct GNUNET_CONTAINER_MultiPeerMap *map, GNUNET_CONTAINER_PeerMapIterator it, void *it_cls)
Iterate over all entries in the map.
#define GNUNET_log(kind,...)
unsigned int GNUNET_CONTAINER_multipeermap_size(const struct GNUNET_CONTAINER_MultiPeerMap *map)
Get the number of key-value pairs in the map.
static int destroy_all_address_it(void *cls, const struct GNUNET_PeerIdentity *key, void *value)
Destroy all addresses iterator.
Here is the call graph for this function:
Here is the caller graph for this function:

◆ GAS_addresses_get_peer_info()

void GAS_addresses_get_peer_info ( const struct GNUNET_PeerIdentity peer,
GNUNET_ATS_PeerInfo_Iterator  pi_it,
void *  pi_it_cls 
)

Return information all peers currently known to ATS.

Parameters
peerthe respective peer
pi_itthe iterator to call for every peer
pi_it_clsthe closure for pi_it
peerthe respective peer, NULL for 'all' peers
pi_itthe iterator to call for every peer
pi_it_clsthe closure for pi_it

Definition at line 468 of file gnunet-service-ats_addresses.c.

References GNUNET_BANDWIDTH_ZERO, GNUNET_break, GNUNET_CONTAINER_multipeermap_get_multiple(), GNUNET_CONTAINER_multipeermap_iterate(), GNUNET_CONTAINER_multipeermap_size(), GNUNET_ERROR_TYPE_DEBUG, GNUNET_HELLO_ADDRESS_INFO_NONE, GNUNET_i2s(), GNUNET_log, GNUNET_NO, PeerInfoIteratorContext::it, PeerInfoIteratorContext::it_cls, and peerinfo_it().

Referenced by GAS_handle_request_address_list(), and GAS_performance_add_client().

471 {
472  struct PeerInfoIteratorContext pi_ctx;
473 
474  if (NULL == pi_it)
475  {
476  /* does not make sense without callback */
477  GNUNET_break(0);
478  return;
479  }
481  "Returning information for %s from a total of %u known addresses\n",
482  (NULL == peer)
483  ? "all peers"
484  : GNUNET_i2s(peer),
486  pi_ctx.it = pi_it;
487  pi_ctx.it_cls = pi_it_cls;
488  if (NULL == peer)
490  &peerinfo_it,
491  &pi_ctx);
492  else
494  peer,
495  &peerinfo_it, &pi_ctx);
496  pi_it(pi_it_cls,
497  NULL, NULL, NULL, 0,
498  GNUNET_NO,
499  NULL,
503 }
#define GNUNET_NO
Definition: gnunet_common.h:78
#define GNUNET_break(cond)
Use this for internal assertion violations that are not fatal (can be handled) but should not occur...
Closure for peerinfo_it().
struct GNUNET_CONTAINER_MultiPeerMap * GSA_addresses
A multihashmap to store all addresses.
int GNUNET_CONTAINER_multipeermap_iterate(struct GNUNET_CONTAINER_MultiPeerMap *map, GNUNET_CONTAINER_PeerMapIterator it, void *it_cls)
Iterate over all entries in the map.
No additional information.
#define GNUNET_BANDWIDTH_ZERO
Convenience definition to use for 0-bandwidth.
#define GNUNET_log(kind,...)
static int peerinfo_it(void *cls, const struct GNUNET_PeerIdentity *key, void *value)
Iterator to iterate over a peer's addresses.
unsigned int GNUNET_CONTAINER_multipeermap_size(const struct GNUNET_CONTAINER_MultiPeerMap *map)
Get the number of key-value pairs in the map.
const char * GNUNET_i2s(const struct GNUNET_PeerIdentity *pid)
Convert a peer identity to a string (for printing debug messages).
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:

◆ GAS_handle_request_address_list()

void GAS_handle_request_address_list ( struct GNUNET_SERVICE_Client client,
const struct AddressListRequestMessage alrm 
)

Handle 'address list request' messages from clients.

Parameters
clientclient that sent the request
alrmthe request message
clsclient that sent the request
alrmthe request message

Definition at line 665 of file gnunet-service-ats_addresses.c.

References AddressListRequestMessage::all, AddressIteration::all, AddressIteration::client, GAS_addresses_get_peer_info(), GNUNET_BANDWIDTH_ZERO, GNUNET_ERROR_TYPE_DEBUG, GNUNET_HELLO_ADDRESS_INFO_NONE, GNUNET_is_zero, GNUNET_log, GNUNET_NO, AddressListRequestMessage::id, AddressIteration::id, AddressListRequestMessage::peer, req_addr_peerinfo_it(), and transmit_req_addr().

Referenced by handle_request_address_list().

667 {
668  struct AddressIteration ai;
669  struct GNUNET_PeerIdentity allzeros;
670 
672  "Received ADDRESSLIST_REQUEST message\n");
673  ai.all = ntohl(alrm->all);
674  ai.id = ntohl(alrm->id);
675  ai.client = client;
676 
677  memset(&allzeros,
678  '\0',
679  sizeof(struct GNUNET_PeerIdentity));
680  if (0 == GNUNET_is_zero(&alrm->peer))
681  {
682  /* Return addresses for all peers */
685  &ai);
686  }
687  else
688  {
689  /* Return addresses for a specific peer */
692  &ai);
693  }
695  "Finished handling `%s' message\n",
696  "ADDRESSLIST_REQUEST");
698  NULL, NULL, NULL,
699  0, GNUNET_NO,
700  NULL,
704 }
Information we need for the callbacks to return a list of addresses back to the client.
uint32_t id
ID used to match replies to this request.
Definition: ats.h:342
static void transmit_req_addr(struct AddressIteration *ai, const struct GNUNET_PeerIdentity *id, const char *plugin_name, const void *plugin_addr, size_t plugin_addr_len, int active, const struct GNUNET_ATS_Properties *prop, enum GNUNET_HELLO_AddressInfo local_address_info, struct GNUNET_BANDWIDTH_Value32NBO bandwidth_out, struct GNUNET_BANDWIDTH_Value32NBO bandwidth_in)
Send a GNUNET_MESSAGE_TYPE_ATS_ADDRESSLIST_RESPONSE with the given address details to the client iden...
#define GNUNET_NO
Definition: gnunet_common.h:78
void GAS_addresses_get_peer_info(const struct GNUNET_PeerIdentity *peer, GNUNET_ATS_PeerInfo_Iterator pi_it, void *pi_it_cls)
Return information all peers currently known to ATS.
static struct GNUNET_TRANSPORT_AddressIdentifier * ai
Handle to the operation that publishes our address.
#define GNUNET_is_zero(a)
Check that memory in a is all zeros.
int32_t all
GNUNET_YES to get information about all addresses, GNUNET_NO to only return addresses that are in use...
Definition: ats.h:353
The identity of the host (wraps the signing key of the peer).
No additional information.
#define GNUNET_BANDWIDTH_ZERO
Convenience definition to use for 0-bandwidth.
#define GNUNET_log(kind,...)
struct GNUNET_PeerIdentity peer
Which peer do we care about? All zeros for all.
Definition: ats.h:347
static void req_addr_peerinfo_it(void *cls, const struct GNUNET_PeerIdentity *id, const char *plugin_name, const void *plugin_addr, size_t plugin_addr_len, int active, const struct GNUNET_ATS_Properties *prop, enum GNUNET_HELLO_AddressInfo local_address_info, struct GNUNET_BANDWIDTH_Value32NBO bandwidth_out, struct GNUNET_BANDWIDTH_Value32NBO bandwidth_in)
Iterator for GAS_addresses_get_peer_info(), called with peer-specific information to be passed back t...
Here is the call graph for this function:
Here is the caller graph for this function:

Variable Documentation

◆ GSA_addresses

struct GNUNET_CONTAINER_MultiPeerMap* GSA_addresses

A multipeermap mapping peer identities to struct ATS_Address.

A multipeermap mapping peer identities to struct ATS_Address.

Definition at line 37 of file gnunet-service-ats_addresses.c.

Referenced by GAS_normalization_update_property(), GAS_plugin_init(), and handle_feedback().