ats service address management More...
#include "platform.h"
#include "gnunet-service-ats_addresses.h"
#include "gnunet-service-ats_performance.h"
#include "gnunet-service-ats_normalization.h"
#include "gnunet-service-ats_plugins.h"
Go to the source code of this file.
Data Structures | |
struct | FindAddressContext |
Closure for find_address_cb() More... | |
struct | PeerInfoIteratorContext |
Closure for peerinfo_it(). More... | |
struct | AddressIteration |
Information we need for the callbacks to return a list of addresses back to the client. More... | |
Functions | |
static void | update_addresses_stat () |
Update statistic on number of addresses. More... | |
static void | free_address (struct ATS_Address *addr) |
Free the given address. More... | |
static void | init_norm (struct GAS_NormalizationInfo *norm) |
Initialize norm. More... | |
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. More... | |
static int | find_address_cb (void *cls, const struct GNUNET_PeerIdentity *key, void *value) |
Find session matching given session ID. More... | |
static struct ATS_Address * | find_exact_address (const struct GNUNET_PeerIdentity *peer, uint32_t session_id) |
Find the exact address. 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_init () |
Initialize address subsystem. More... | |
static int | destroy_all_address_it (void *cls, const struct GNUNET_PeerIdentity *key, void *value) |
Destroy all addresses iterator. More... | |
void | GAS_addresses_destroy_all () |
Remove all addresses. More... | |
void | GAS_addresses_done () |
Shutdown address subsystem. More... | |
static int | peerinfo_it (void *cls, const struct GNUNET_PeerIdentity *key, void *value) |
Iterator to iterate over a peer's 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... | |
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 identified in ai. More... | |
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 to the client. 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_MultiPeerMap * | GSA_addresses |
A multihashmap to store all addresses. More... | |
ats service address management
Definition in file gnunet-service-ats_addresses.c.
|
static |
Update statistic on number of addresses.
Definition at line 44 of file gnunet-service-ats_addresses.c.
References GNUNET_CONTAINER_multipeermap_size(), GNUNET_NO, GNUNET_STATISTICS_set(), GSA_addresses, and GSA_stats.
Referenced by free_address(), GAS_addresses_add(), and GAS_addresses_init().
|
static |
Free the given address.
addr | address to destroy |
Definition at line 59 of file gnunet-service-ats_addresses.c.
References ATS_Address::addr, ATS_Address::addr_len, GAS_performance_notify_all_clients(), GAS_plugin_delete_address(), GNUNET_assert, GNUNET_BANDWIDTH_ZERO, GNUNET_CONTAINER_multipeermap_remove(), GNUNET_free, GNUNET_NO, GNUNET_YES, GSA_addresses, ATS_Address::local_address_info, ATS_Address::peer, ATS_Address::plugin, and update_addresses_stat().
Referenced by destroy_all_address_it(), and GAS_addresses_destroy().
|
static |
Initialize norm.
Sets all historic values to undefined.
norm | normalization data to initialize |
Definition at line 87 of file gnunet-service-ats_addresses.c.
References GAS_NormalizationInfo::atsi_abs, and GAS_normalization_queue_length.
Referenced by create_address().
|
static |
Create a ATS_address with the given information.
peer | peer |
plugin_name | plugin |
plugin_addr | address |
plugin_addr_len | address length |
local_address_info | additional local info for the address |
session_id | session identifier, can never be 0 |
Definition at line 108 of file gnunet-service-ats_addresses.c.
References ATS_Address::addr, ATS_Address::addr_len, GNUNET_malloc, GNUNET_memcpy, GNUNET_strdup, init_norm(), ATS_Address::local_address_info, ATS_Address::norm_delay, ATS_Address::norm_distance, ATS_Address::norm_utilization_in, ATS_Address::norm_utilization_out, ATS_Address::peer, peer, ATS_Address::plugin, plugin_name, ATS_Address::session_id, and session_id.
Referenced by GAS_addresses_add().
|
static |
Find session matching given session ID.
cls | a struct FindAddressContext |
key | peer id |
value | the address to compare with |
Definition at line 161 of file gnunet-service-ats_addresses.c.
References fac(), GNUNET_NO, GNUNET_YES, ATS_Address::session_id, and value.
Referenced by find_exact_address().
|
static |
Find the exact address.
peer | peer |
session_id | session id, can never be 0 |
Definition at line 185 of file gnunet-service-ats_addresses.c.
References fac(), find_address_cb(), GNUNET_CONTAINER_multipeermap_get_multiple(), GSA_addresses, peer, and session_id.
Referenced by GAS_addresses_add(), GAS_addresses_destroy(), and GAS_addresses_update().
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.
peer | peer |
plugin_name | transport plugin name |
plugin_addr | plugin address |
plugin_addr_len | length of the plugin_addr |
local_address_info | the local address for the address |
session_id | session id, can never be 0. |
prop | performance information for this address |
Definition at line 200 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(), GSA_addresses, ATS_Address::local_address_info, ATS_Address::peer, peer, ATS_Address::plugin, plugin_name, ATS_Address::properties, GNUNET_ATS_Properties::scope, session_id, ATS_Address::t_added, ATS_Address::t_last_activity, and update_addresses_stat().
Referenced by GAS_handle_address_add().
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.
peer | peer |
session_id | session id, can never be 0 |
prop | performance information for this address |
Definition at line 258 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, peer, ATS_Address::plugin, ATS_Address::properties, GNUNET_ATS_Properties::scope, session_id, ATS_Address::solver_information, and ATS_Address::t_last_activity.
Referenced by GAS_handle_address_update().
void GAS_addresses_destroy | ( | const struct GNUNET_PeerIdentity * | peer, |
uint32_t | session_id | ||
) |
Remove an address for a peer.
peer | peer |
session_id | session id, can never be 0 |
Definition at line 309 of file gnunet-service-ats_addresses.c.
References find_exact_address(), free_address(), GNUNET_break, GNUNET_ERROR_TYPE_DEBUG, GNUNET_i2s(), GNUNET_log, peer, and session_id.
Referenced by GAS_handle_address_destroyed().
void GAS_addresses_init | ( | void | ) |
Initialize address subsystem.
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 337 of file gnunet-service-ats_addresses.c.
References GNUNET_CONTAINER_multipeermap_create(), GNUNET_NO, GSA_addresses, and update_addresses_stat().
Referenced by run().
|
static |
Destroy all addresses iterator.
cls | NULL |
key | peer identity (unused) |
value | the 'struct ATS_Address' to free |
Definition at line 355 of file gnunet-service-ats_addresses.c.
References free_address(), GNUNET_OK, and value.
Referenced by GAS_addresses_destroy_all().
void GAS_addresses_destroy_all | ( | void | ) |
Remove all addresses.
Definition at line 370 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, GNUNET_log, and GSA_addresses.
Referenced by GAS_addresses_done(), and GAS_scheduling_remove_client().
void GAS_addresses_done | ( | void | ) |
Shutdown address subsystem.
Definition at line 391 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, GNUNET_log, and GSA_addresses.
Referenced by cleanup_task(), and run().
|
static |
Iterator to iterate over a peer's addresses.
cls | a struct PeerInfoIteratorContext |
key | the peer id |
value | the struct ATS_address |
Definition at line 429 of file gnunet-service-ats_addresses.c.
References ATS_Address::addr, GNUNET_BANDWIDTH_value_init(), GNUNET_OK, PeerInfoIteratorContext::it, PeerInfoIteratorContext::it_cls, and value.
Referenced by 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.
peer | the respective peer, NULL for 'all' peers |
pi_it | the iterator to call for every peer |
pi_it_cls | the closure for pi_it |
Definition at line 451 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, GSA_addresses, PeerInfoIteratorContext::it, PeerInfoIteratorContext::it_cls, peer, and peerinfo_it().
Referenced by GAS_handle_request_address_list(), and GAS_performance_add_client().
|
static |
Send a GNUNET_MESSAGE_TYPE_ATS_ADDRESSLIST_RESPONSE with the given address details to the client identified in ai.
ai | our address information context (identifies the client) |
id | the peer id this address is for |
plugin_name | name of the plugin that supports this address |
plugin_addr | address |
plugin_addr_len | length of plugin_addr |
active | GNUNET_YES if this address is actively used |
prop | performance information |
local_address_info | flags for the address |
bandwidth_out | current outbound bandwidth assigned to address |
bandwidth_in | current inbound bandwidth assigned to address |
Definition at line 529 of file gnunet-service-ats_addresses.c.
References ai, PeerInformationMessage::bandwidth_in, PeerInformationMessage::bandwidth_out, env, GNUNET_assert, GNUNET_ATS_properties_hton(), GNUNET_MAX_MESSAGE_SIZE, GNUNET_memcpy, GNUNET_MESSAGE_TYPE_ATS_ADDRESSLIST_RESPONSE, GNUNET_MQ_msg_extra, GNUNET_MQ_send(), GNUNET_SERVICE_client_get_mq(), id, msg, plugin_name, and PeerInformationMessage::plugin_name_length.
Referenced by GAS_handle_request_address_list(), and req_addr_peerinfo_it().
|
static |
Iterator for GAS_addresses_get_peer_info(), called with peer-specific information to be passed back to the client.
cls | closure with our struct AddressIteration * |
id | the peer id |
plugin_name | plugin name |
plugin_addr | address |
plugin_addr_len | length of plugin_addr |
active | is address actively used |
prop | performance information |
local_address_info | additional local info for the address |
bandwidth_out | current outbound bandwidth assigned to address |
bandwidth_in | current inbound bandwidth assigned to address |
Definition at line 598 of file gnunet-service-ats_addresses.c.
References ai, GNUNET_ERROR_TYPE_DEBUG, GNUNET_i2s(), GNUNET_log, GNUNET_YES, plugin_name, transmit_req_addr(), and GNUNET_BANDWIDTH_Value32NBO::value__.
Referenced by 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.
client | client that sent the request |
alrm | the request message |
Definition at line 644 of file gnunet-service-ats_addresses.c.
References ai, AddressListRequestMessage::all, GAS_addresses_get_peer_info(), GNUNET_BANDWIDTH_ZERO, GNUNET_ERROR_TYPE_DEBUG, GNUNET_HELLO_ADDRESS_INFO_NONE, GNUNET_is_zero, GNUNET_log, GNUNET_NO, GNUNET_YES, AddressListRequestMessage::id, AddressListRequestMessage::peer, req_addr_peerinfo_it(), and transmit_req_addr().
Referenced by handle_request_address_list().
struct GNUNET_CONTAINER_MultiPeerMap* GSA_addresses |
A multihashmap to store all addresses.
A multipeermap mapping peer identities to struct ATS_Address
.
Definition at line 37 of file gnunet-service-ats_addresses.c.
Referenced by find_exact_address(), free_address(), GAS_addresses_add(), GAS_addresses_destroy_all(), GAS_addresses_done(), GAS_addresses_get_peer_info(), GAS_addresses_init(), GAS_normalization_update_property(), GAS_plugin_init(), handle_feedback(), and update_addresses_stat().