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"
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 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. 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 AddressInfo * | find_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 a new address including the network the 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_MultiPeerMap * | p2a |
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... | |
interfacing between transport and ATS service
Definition in file gnunet-service-transport_ats.c.
#define LOG | ( | kind, | |
... | |||
) | GNUNET_log_from (kind, "transport-ats", __VA_ARGS__) |
Log convenience function.
Definition at line 35 of file gnunet-service-transport_ats.c.
|
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 134 of file gnunet-service-transport_ats.c.
References gettext_noop, GNUNET_CONTAINER_multipeermap_size(), GNUNET_NO, GNUNET_STATISTICS_set(), GST_stats, num_blocked, and p2a.
Referenced by destroy_ai(), GST_ats_add_address(), GST_ats_add_inbound_address(), GST_ats_block_address(), GST_ats_done(), and unblock_address().
|
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).
cls | the struct FindClosure |
key | which peer is this about |
value | the struct AddressInfo |
Definition at line 158 of file gnunet-service-transport_ats.c.
References FindClosure::address, GNUNET_TRANSPORT_AddressIdentifier::address, ai, GNUNET_HELLO_address_cmp(), GNUNET_NO, GNUNET_YES, FindClosure::ret, FindClosure::session, and value.
Referenced by find_ai().
|
static |
Find the address information struct for the given address and session.
address | address to look for |
session | session to match for inbound connections |
Definition at line 186 of file gnunet-service-transport_ats.c.
References address, FindClosure::address, find_ai_cb(), GNUNET_CONTAINER_multipeermap_get_multiple(), p2a, FindClosure::ret, 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().
|
static |
Find matching address info, ignoring sessions and expired addresses.
cls | the struct FindClosure |
key | which peer is this about |
value | the struct AddressInfo |
Definition at line 212 of file gnunet-service-transport_ats.c.
References FindClosure::address, GNUNET_TRANSPORT_AddressIdentifier::address, ai, GNUNET_HELLO_address_cmp(), GNUNET_NO, GNUNET_YES, FindClosure::ret, and value.
Referenced by find_ai_no_session().
|
static |
Find the address information struct for the given address (ignoring sessions)
address | address to look for |
Definition at line 240 of file gnunet-service-transport_ats.c.
References address, FindClosure::address, find_ai_no_session_cb(), GNUNET_CONTAINER_multipeermap_get_multiple(), p2a, 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().
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.
address | the address |
session | the session |
Definition at line 265 of file gnunet-service-transport_ats.c.
References address, find_ai(), GNUNET_NO, GNUNET_YES, and FindClosure::session.
Referenced by GST_neighbours_session_terminated(), send_with_session(), set_primary_address(), and try_run_fast_ats_update().
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.
address | the address |
Definition at line 280 of file gnunet-service-transport_ats.c.
References address, 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().
|
static |
The blocking time for an address has expired, allow ATS to suggest it again.
cls | the struct AddressInfo of the address to unblock |
Definition at line 295 of file gnunet-service-transport_ats.c.
References GNUNET_TRANSPORT_AddressIdentifier::address, ai, GNUNET_ATS_address_add(), GNUNET_break, GNUNET_ERROR_TYPE_DEBUG, GNUNET_i2s(), GST_ats, GST_plugins_a2s(), LOG, num_blocked, and publish_p2a_stat_update().
Referenced by 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).
address | the address to block |
session | the session (can be NULL) |
Definition at line 324 of file gnunet-service-transport_ats.c.
References address, ai, 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, publish_p2a_stat_update(), AddressInfo::session, and unblock_address().
Referenced by free_address(), GST_neighbours_switch_to_address(), set_primary_address(), and switch_address_bl_check_cont().
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.
address | the address to reset the blocking timer |
session | the session (can be NULL) |
Definition at line 390 of file gnunet-service-transport_ats.c.
References address, ai, find_ai(), GNUNET_break, GNUNET_TIME_UNIT_ZERO, GST_my_identity, and AddressInfo::session.
Referenced by GST_neighbours_handle_session_ack().
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.
address | the address |
session | the session |
prop | performance information |
Definition at line 423 of file gnunet-service-transport_ats.c.
References address, GNUNET_TRANSPORT_AddressIdentifier::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, p2a, publish_p2a_stat_update(), GNUNET_ATS_Properties::scope, and AddressInfo::session.
Referenced by plugin_env_session_start().
void GST_ats_add_address | ( | const struct GNUNET_HELLO_Address * | address, |
const struct GNUNET_ATS_Properties * | prop | ||
) |
Notify ATS about a new address including the network the address is located in.
The address must NOT be inbound and must be new to ATS.
address | the address |
prop | performance information |
Definition at line 481 of file gnunet-service-transport_ats.c.
References address, GNUNET_TRANSPORT_AddressIdentifier::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, p2a, publish_p2a_stat_update(), and GNUNET_ATS_Properties::scope.
Referenced by add_valid_address(), and GST_validation_handle_pong().
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.
address | the address |
session | the session |
Definition at line 537 of file gnunet-service-transport_ats.c.
References address, ai, find_ai(), GNUNET_assert, GNUNET_ATS_address_add_session(), GNUNET_ERROR_TYPE_DEBUG, GNUNET_i2s(), GST_my_identity, LOG, and AddressInfo::session.
Referenced by multicast_pong(), send_syn_ack_message(), send_with_session(), and switch_address_bl_check_cont().
|
static |
Release memory used by the given address data.
ai | the struct AddressInfo |
Definition at line 580 of file gnunet-service-transport_ats.c.
References GNUNET_TRANSPORT_AddressIdentifier::address, ai, 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, p2a, and publish_p2a_stat_update().
Referenced by destroy_ai_cb(), GST_ats_del_session(), and GST_ats_expire_address().
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.
address | the address |
session | the session |
Definition at line 619 of file gnunet-service-transport_ats.c.
References address, ai, destroy_ai(), 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, and AddressInfo::session.
Referenced by plugin_env_session_end().
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.
address | the address |
distance | new distance value |
Definition at line 723 of file gnunet-service-transport_ats.c.
References address, ai, find_ai_no_session(), GNUNET_ATS_address_update(), GNUNET_ERROR_TYPE_DEBUG, GNUNET_i2s(), GST_manipulation_manipulate_metrics(), and LOG.
Referenced by plugin_env_address_to_type().
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.
address | the address |
delay | new delay value |
Definition at line 752 of file gnunet-service-transport_ats.c.
References address, ai, 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(), and LOG.
Referenced by GST_neighbours_calculate_receive_delay(), and GST_validation_handle_pong().
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.
address | our information about the address |
bps_in | new utilization inbound |
bps_out | new utilization outbound |
Definition at line 790 of file gnunet-service-transport_ats.c.
References address, ai, find_ai_no_session(), GNUNET_ATS_address_update(), GNUNET_ERROR_TYPE_DEBUG, GNUNET_i2s(), GST_manipulation_manipulate_metrics(), GST_plugins_a2s(), and LOG.
Referenced by send_utilization_data().
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.
address | the address |
Definition at line 830 of file gnunet-service-transport_ats.c.
References address, ai, destroy_ai(), find_ai_no_session(), GNUNET_assert, GNUNET_ERROR_TYPE_DEBUG, GNUNET_i2s(), GNUNET_YES, GST_my_identity, GST_plugins_a2s(), and LOG.
Referenced by cleanup_validation_entry().
void GST_ats_init | ( | void | ) |
Initialize ATS subsystem.
Definition at line 865 of file gnunet-service-transport_ats.c.
References GNUNET_CONTAINER_multipeermap_create(), GNUNET_YES, and p2a.
Referenced by run().
|
static |
Release memory used by the given address data.
cls | NULL |
key | which peer is this about |
value | the struct AddressInfo |
Definition at line 880 of file gnunet-service-transport_ats.c.
References ai, destroy_ai(), GNUNET_OK, and value.
Referenced by GST_ats_done().
void GST_ats_done | ( | void | ) |
Shutdown ATS subsystem.
Definition at line 895 of file gnunet-service-transport_ats.c.
References destroy_ai_cb(), GNUNET_CONTAINER_multipeermap_destroy(), GNUNET_CONTAINER_multipeermap_iterate(), p2a, and publish_p2a_stat_update().
Referenced by shutdown_task().
|
static |
Map from peer identities to one or more struct AddressInfo
values for the peer.
Definition at line 98 of file gnunet-service-transport_ats.c.
Referenced by destroy_ai(), find_ai(), find_ai_no_session(), GST_ats_add_address(), GST_ats_add_inbound_address(), GST_ats_done(), GST_ats_init(), and publish_p2a_stat_update().
|
static |
Number of blocked addresses.
Definition at line 103 of file gnunet-service-transport_ats.c.
Referenced by destroy_ai(), GST_ats_block_address(), publish_p2a_stat_update(), and unblock_address().