address validation API More...
#include "gnunet_statistics_service.h"
#include "gnunet_transport_plugin.h"
#include "gnunet_util_lib.h"
#include "gnunet_hello_lib.h"
Go to the source code of this file.
Typedefs | |
typedef void(* | GST_ValidationAddressCallback) (void *cls, struct GNUNET_TIME_Absolute valid_until, struct GNUNET_TIME_Absolute validation_block, const struct GNUNET_HELLO_Address *address) |
Function called for each address (or address status change) that the validation module is aware of (for the given target). More... | |
Functions | |
void | GST_validation_start (unsigned int max_fds) |
Start the validation subsystem. More... | |
void | GST_validation_stop (void) |
Stop the validation subsystem. More... | |
void | GST_validation_set_address_use (const struct GNUNET_HELLO_Address *address, int in_use) |
Update if we are using an address for a connection actively right now. More... | |
int | GST_validation_handle_ping (const struct GNUNET_PeerIdentity *sender, const struct GNUNET_MessageHeader *hdr, const struct GNUNET_HELLO_Address *sender_address, struct GNUNET_ATS_Session *session) |
We've received a PING. More... | |
int | GST_validation_handle_pong (const struct GNUNET_PeerIdentity *sender, const struct GNUNET_MessageHeader *hdr) |
We've received a PONG. More... | |
int | GST_validation_handle_hello (const struct GNUNET_MessageHeader *hello) |
We've received a HELLO, check which addresses are new and trigger validation. More... | |
void | GST_validation_handle_address (const struct GNUNET_HELLO_Address *address) |
Validate an individual address. More... | |
void | GST_validation_get_addresses (const struct GNUNET_PeerIdentity *target, GST_ValidationAddressCallback cb, void *cb_cls) |
Call the given function for each address for the given target. More... | |
address validation API
Definition in file gnunet-service-transport_validation.h.
typedef void(* GST_ValidationAddressCallback) (void *cls, struct GNUNET_TIME_Absolute valid_until, struct GNUNET_TIME_Absolute validation_block, const struct GNUNET_HELLO_Address *address) |
Function called for each address (or address status change) that the validation module is aware of (for the given target).
cls | closure |
public_key | public key for the peer, never NULL |
valid_until | is ZERO if we never validated the address, otherwise a time up to when we consider it (or was) valid |
validation_block | is FOREVER if the address is for an unsupported plugin (from PEERINFO) is ZERO if the address is considered valid (no validation needed) otherwise a time in the future if we're currently denying re-validation |
address | the address |
Definition at line 126 of file gnunet-service-transport_validation.h.
void GST_validation_start | ( | unsigned int | max_fds | ) |
Start the validation subsystem.
max_fds | maximum number of fds to use |
Initialization for validation throttling
We have a maximum number max_fds of connections we can use for validation We monitor the number of validations in parallel and start to throttle it when doing to many validations in parallel: if (running validations < (max_fds / 2))
Definition at line 982 of file gnunet-service-transport_validation.c.
References gettext_noop, GNUNET_CONSTANTS_IDLE_CONNECTION_TIMEOUT, GNUNET_CONTAINER_multipeermap_create(), GNUNET_ERROR_TYPE_DEBUG, GNUNET_log, GNUNET_NO, GNUNET_PEERINFO_notify(), GNUNET_STATISTICS_set(), GNUNET_STRINGS_relative_time_to_string(), GNUNET_TIME_absolute_get(), GNUNET_YES, GST_cfg, GST_stats, pnc, process_peerinfo_hello(), GNUNET_TIME_Relative::rel_value_us, validation_delay, validation_map, VALIDATION_MAP_SIZE, validation_next, validations_fast_start_threshold, and validations_running.
Referenced by run().
void GST_validation_stop | ( | void | ) |
Stop the validation subsystem.
Definition at line 1019 of file gnunet-service-transport_validation.c.
References cleanup_validation_entry(), GNUNET_CONTAINER_multipeermap_destroy(), GNUNET_CONTAINER_multipeermap_iterate(), GNUNET_PEERINFO_notify_cancel(), pnc, and validation_map.
Referenced by shutdown_task().
void GST_validation_set_address_use | ( | const struct GNUNET_HELLO_Address * | address, |
int | in_use | ||
) |
Update if we are using an address for a connection actively right now.
Based on this, the validation module will measure latency for the address more or less often.
address | the address that we are now using (or not) |
in_use | GNUNET_YES if we are now using the address for a connection, GNUNET_NO if we are no longer using the address for a connection |
Definition at line 1785 of file gnunet-service-transport_validation.c.
Referenced by free_address(), and set_primary_address().
int GST_validation_handle_ping | ( | const struct GNUNET_PeerIdentity * | sender, |
const struct GNUNET_MessageHeader * | hdr, | ||
const struct GNUNET_HELLO_Address * | sender_address, | ||
struct GNUNET_ATS_Session * | session | ||
) |
We've received a PING.
If appropriate, generate a PONG.
sender | peer sending the PING |
hdr | the PING |
sender_address | address of the sender, NULL if we did not initiate |
session | session we got the PING from |
If appropriate, generate a PONG.
sender | peer sending the PING |
hdr | the PING |
sender_address | the sender address as we got it |
session | session we got the PING from |
Definition at line 1090 of file gnunet-service-transport_validation.c.
References _, ACCEPTABLE_PING_DELAY, address, GNUNET_TRANSPORT_PluginFunctions::check_address, GNUNET_TRANSPORT_PluginFunctions::cls, GNUNET_TRANSPORT_PluginFunctions::get_session, gettext_noop, GNUNET_assert, GNUNET_break, GNUNET_break_op, GNUNET_CRYPTO_eddsa_sign_(), GNUNET_ERROR_TYPE_DEBUG, GNUNET_ERROR_TYPE_ERROR, GNUNET_ERROR_TYPE_INFO, GNUNET_free, GNUNET_HELLO_ADDRESS_INFO_NONE, GNUNET_i2s(), GNUNET_i2s_full(), GNUNET_log, GNUNET_malloc, GNUNET_memcpy, GNUNET_MESSAGE_TYPE_TRANSPORT_PONG, GNUNET_NO, GNUNET_OK, GNUNET_SIGNATURE_PURPOSE_TRANSPORT_PONG_OWN, GNUNET_snprintf(), GNUNET_STATISTICS_update(), GNUNET_strdup, GNUNET_SYSERR, GNUNET_TIME_absolute_get_remaining(), GNUNET_TIME_absolute_hton(), GNUNET_TIME_relative_to_absolute(), GNUNET_YES, GST_hello_test_address(), GST_my_identity, GST_my_private_key, GST_neighbours_notify_data_sent(), GST_plugins_a2s(), GST_plugins_find(), GST_stats, GST_validation_get_addresses(), multicast_pong(), ping(), plugin_name, pong(), PONG_PRIORITY, PONG_SIGNATURE_LIFETIME, GNUNET_TIME_Relative::rel_value_us, ret, GNUNET_TRANSPORT_PluginFunctions::send, and GNUNET_MessageHeader::size.
int GST_validation_handle_pong | ( | const struct GNUNET_PeerIdentity * | sender, |
const struct GNUNET_MessageHeader * | hdr | ||
) |
We've received a PONG.
Check if it matches a pending PING and mark the respective address as confirmed.
sender | peer sending the PONG |
hdr | the PONG |
Definition at line 1449 of file gnunet-service-transport_validation.c.
References add_valid_peer_address(), address, ValidationEntry::address, TransportPongMessage::addrlen, ValidationEntry::copied, GNUNET_ATS_Properties::delay, ValidationEntry::expecting_pong, find_validation_entry(), gettext_noop, GNUNET_assert, GNUNET_break, GNUNET_break_op, GNUNET_CRYPTO_eddsa_verify_(), GNUNET_ERROR_TYPE_DEBUG, GNUNET_ERROR_TYPE_INFO, GNUNET_ERROR_TYPE_WARNING, GNUNET_free, GNUNET_HELLO_ADDRESS_INFO_NONE, GNUNET_HELLO_create(), GNUNET_i2s(), GNUNET_log, GNUNET_NO, GNUNET_NT_UNSPECIFIED, GNUNET_OK, GNUNET_PEERINFO_add_peer(), GNUNET_SIGNATURE_PURPOSE_TRANSPORT_PONG_OWN, GNUNET_STATISTICS_set(), GNUNET_STATISTICS_update(), GNUNET_SYSERR, GNUNET_TIME_absolute_get_duration(), GNUNET_TIME_absolute_get_remaining(), GNUNET_TIME_absolute_ntoh(), GNUNET_TIME_relative_divide(), GNUNET_TIME_relative_to_absolute(), GNUNET_TRANSPORT_VS_UPDATE, GNUNET_YES, GST_ats_add_address(), GST_ats_is_known_no_session(), GST_ats_update_delay(), GST_my_identity, GST_peerinfo, GST_plugins_a2s(), GST_plugins_find(), GST_stats, HELLO_ADDRESS_EXPIRATION, ValidationEntry::known_to_ats, ValidationEntry::latency, ValidationEntry::network, GNUNET_HELLO_Address::peer, pong(), ValidationEntry::pong_sig_cache, ValidationEntry::pong_sig_valid_until, GNUNET_PeerIdentity::public_key, GNUNET_TIME_Relative::rel_value_us, GNUNET_ATS_Properties::scope, ValidationEntry::send_time, GNUNET_MessageHeader::size, size, ValidationEntry::valid_until, validation_entry_changed(), and validations_running.
int GST_validation_handle_hello | ( | const struct GNUNET_MessageHeader * | hello | ) |
We've received a HELLO, check which addresses are new and trigger validation.
hello | the HELLO we received |
Definition at line 1671 of file gnunet-service-transport_validation.c.
References GNUNET_assert, GNUNET_break_op, GNUNET_ERROR_TYPE_DEBUG, GNUNET_HELLO_get_id(), GNUNET_HELLO_is_friend_only(), GNUNET_HELLO_iterate_addresses(), GNUNET_i2s(), GNUNET_log, GNUNET_NO, GNUNET_OK, GNUNET_SYSERR, GNUNET_YES, GST_my_identity, pid, GNUNET_MessageHeader::size, and validate_address_iterator().
Referenced by handle_client_hello().
void GST_validation_handle_address | ( | const struct GNUNET_HELLO_Address * | address | ) |
Validate an individual address.
address | address we should try to validate |
Definition at line 1356 of file gnunet-service-transport_validation.c.
References address, ValidationEntry::address, find_validation_entry(), GNUNET_ERROR_TYPE_INFO, GNUNET_i2s(), GNUNET_log, GNUNET_SCHEDULER_add_now(), GST_plugins_a2s(), GST_plugins_find(), GNUNET_HELLO_Address::peer, revalidate_address(), and ValidationEntry::revalidation_task.
Referenced by plugin_env_session_start_bl_check_cont(), and validate_address_iterator().
void GST_validation_get_addresses | ( | const struct GNUNET_PeerIdentity * | target, |
GST_ValidationAddressCallback | cb, | ||
void * | cb_cls | ||
) |
Call the given function for each address for the given target.
target | peer information is requested for |
cb | function to call; will not be called after this function returns |
cb_cls | closure for cb |
Can either give a snapshot (synchronous API) or be continuous.
target | peer information is requested for |
cb | function to call; will not be called after this function returns |
cb_cls | closure for cb |
Definition at line 1761 of file gnunet-service-transport_validation.c.
References IteratorContext::cb, IteratorContext::cb_cls, GNUNET_CONTAINER_multipeermap_get_multiple(), iterate_addresses(), and validation_map.
Referenced by GST_validation_handle_ping().