neighbour management More...
#include "platform.h"
#include "gnunet_ats_service.h"
#include "gnunet-service-transport_ats.h"
#include "gnunet-service-transport_neighbours.h"
#include "gnunet-service-transport_manipulation.h"
#include "gnunet-service-transport_plugins.h"
#include "gnunet-service-transport_validation.h"
#include "gnunet-service-transport.h"
#include "gnunet_peerinfo_service.h"
#include "gnunet_constants.h"
#include "transport.h"
Go to the source code of this file.
Data Structures | |
struct | TransportSynMessage |
Message a peer sends to another to indicate that it intends to setup a connection/session for data exchange. More... | |
struct | GNUNET_ATS_SessionKeepAliveMessage |
Message a peer sends to another when connected to indicate that a session is in use and the peer is still alive or to respond to a keep alive. More... | |
struct | GNUNET_ATS_SessionQuotaMessage |
Message a peer sends to another when connected to indicate that the other peer should limit transmissions to the indicated quota. More... | |
struct | GNUNET_ATS_SessionDisconnectMessage |
Message we send to the other peer to notify it that we intentionally are disconnecting (to reduce timeouts). More... | |
struct | MessageQueue |
For each neighbour we keep a list of messages that we still want to transmit to the neighbour. More... | |
struct | NeighbourAddress |
A possible address we could use to communicate with a neighbour. More... | |
struct | NeighbourMapEntry |
Entry in neighbours. More... | |
struct | BlacklistCheckSwitchContext |
Entry in a DLL we use to keep track of pending blacklist checks. More... | |
struct | IteratorContext |
Closure for the neighbours_iterate() function. More... | |
Macros | |
#define | IGNORE_INBOUND_QUOTA GNUNET_YES |
Experimental option to ignore SessionQuotaMessages from the other peer. More... | |
#define | NEIGHBOUR_TABLE_SIZE 256 |
Size of the neighbour hash map. More... | |
#define | DISCONNECT_SENT_TIMEOUT |
Time we give plugin to transmit DISCONNECT message before the neighbour entry self-destructs. More... | |
#define | QUOTA_VIOLATION_DROP_THRESHOLD 10 |
How often must a peer violate bandwidth quotas before we start to simply drop its messages? More... | |
#define | ATS_RESPONSE_TIMEOUT |
How long are we willing to wait for a response from ATS before timing out? More... | |
#define | SETUP_CONNECTION_TIMEOUT |
How long are we willing to wait for an ACK from the other peer before giving up on our connect operation? More... | |
#define | FAST_RECONNECT_TIMEOUT GNUNET_TIME_UNIT_SECONDS |
How long are we willing to wait for a successful reconnect if an existing connection went down? Much shorter than the usual SETUP_CONNECTION_TIMEOUT as we do not inform the higher layers about the disconnect during this period. More... | |
#define | UTIL_TRANSMISSION_INTERVAL GNUNET_TIME_UNIT_SECONDS |
Interval to send utilization data. More... | |
Enumerations | |
enum | GST_ACK_State { ACK_UNDEFINED = 0 , ACK_SEND_SYN_ACK = 1 , ACK_SEND_ACK = 2 } |
State describing which kind a reply this neighbour should send. More... | |
Functions | |
static char * | print_ack_state (enum GST_ACK_State s) |
Convert the given ACK state to a string. More... | |
static void | send_outbound_quota_to_clients (struct NeighbourMapEntry *n) |
Send information about a new outbound quota to our clients. More... | |
static void | neighbours_connect_notification (struct NeighbourMapEntry *n) |
Notify our clients that another peer connected to us. More... | |
static void | neighbours_disconnect_notification (struct NeighbourMapEntry *n) |
Notify our clients (and manipulation) that a peer disconnected from us. More... | |
static void | neighbours_changed_notification (const struct GNUNET_PeerIdentity *peer, const struct GNUNET_HELLO_Address *address, enum GNUNET_TRANSPORT_PeerState state, struct GNUNET_TIME_Absolute state_timeout, struct GNUNET_BANDWIDTH_Value32NBO bandwidth_in, struct GNUNET_BANDWIDTH_Value32NBO bandwidth_out) |
Notify transport clients that a neighbour peer changed its active address. More... | |
static struct NeighbourMapEntry * | lookup_neighbour (const struct GNUNET_PeerIdentity *pid) |
Lookup a neighbour entry in the neighbours hash map. More... | |
static int | test_connected (struct NeighbourMapEntry *n) |
Test if we're connected to the given peer. More... | |
static void | free_address (struct NeighbourAddress *na) |
We don't need a given neighbour address any more. More... | |
static void | master_task (void *cls) |
Master task run for every neighbour. More... | |
static void | set_state_and_timeout (struct NeighbourMapEntry *n, enum GNUNET_TRANSPORT_PeerState s, struct GNUNET_TIME_Absolute timeout) |
Set net state and state timeout for this neighbour and notify monitoring. More... | |
static void | set_alternative_address (struct NeighbourMapEntry *n, const struct GNUNET_HELLO_Address *address, struct GNUNET_ATS_Session *session, struct GNUNET_BANDWIDTH_Value32NBO bandwidth_in, struct GNUNET_BANDWIDTH_Value32NBO bandwidth_out) |
Initialize the alternative address of a neighbour. More... | |
static struct GNUNET_TIME_Relative | send_with_session (struct NeighbourMapEntry *n, const void *msgbuf, size_t msgbuf_size, uint32_t priority, struct GNUNET_TIME_Relative timeout, unsigned int use_keepalive_timeout, GNUNET_TRANSPORT_TransmitContinuation cont, void *cont_cls) |
Transmit a message using the current session of the given neighbour. More... | |
static void | unset_primary_address (struct NeighbourMapEntry *n) |
Clear the primary address of a neighbour since this address is not valid anymore and notify monitoring about it. More... | |
static void | free_neighbour (struct NeighbourMapEntry *n) |
Free a neighbour map entry. More... | |
static void | send_disconnect_cont (void *cls, const struct GNUNET_PeerIdentity *target, int result, size_t payload, size_t physical) |
Function called when the 'DISCONNECT' message has been sent by the plugin. More... | |
static void | send_disconnect (struct NeighbourMapEntry *n) |
Transmit a DISCONNECT message to the other peer. More... | |
static void | disconnect_neighbour (struct NeighbourMapEntry *n) |
Disconnect from the given neighbour, clean up the record. More... | |
static int | set_incoming_quota (struct NeighbourMapEntry *n, struct GNUNET_BANDWIDTH_Value32NBO quota) |
Change the incoming quota for the given peer. More... | |
static void | set_primary_address (struct NeighbourMapEntry *n, const struct GNUNET_HELLO_Address *address, struct GNUNET_ATS_Session *session, struct GNUNET_BANDWIDTH_Value32NBO bandwidth_in, struct GNUNET_BANDWIDTH_Value32NBO bandwidth_out) |
Initialize the primary address of a neighbour. More... | |
static void | transmit_send_continuation (void *cls, const struct GNUNET_PeerIdentity *receiver, int success, size_t size_payload, size_t physical) |
We're done with our transmission attempt, continue processing. More... | |
static void | try_transmission_to_peer (struct NeighbourMapEntry *n) |
Check the message list for the given neighbour and if we can send a message, do so. More... | |
static void | send_keepalive (struct NeighbourMapEntry *n) |
Send keepalive message to the neighbour. More... | |
void | GST_neighbours_keepalive (const struct GNUNET_PeerIdentity *neighbour, const struct GNUNET_MessageHeader *m) |
Keep the connection to the given neighbour alive longer, we received a KEEPALIVE (or equivalent); send a response. More... | |
void | GST_neighbours_keepalive_response (const struct GNUNET_PeerIdentity *neighbour, const struct GNUNET_MessageHeader *m) |
We received a KEEP_ALIVE_RESPONSE message and use this to calculate latency to this peer. More... | |
struct GNUNET_TIME_Relative | GST_neighbours_calculate_receive_delay (const struct GNUNET_PeerIdentity *sender, ssize_t size, int *do_forward) |
We have received a message from the given sender. More... | |
void | GST_neighbours_send (const struct GNUNET_PeerIdentity *target, const void *msg, size_t msg_size, struct GNUNET_TIME_Relative timeout, GST_NeighbourSendContinuation cont, void *cont_cls) |
Transmit a message to the given target using the active connection. More... | |
static void | send_session_syn_cont (void *cls, const struct GNUNET_PeerIdentity *target, int result, size_t size_payload, size_t size_on_wire) |
Continuation called from our attempt to transmitted our GNUNET_MESSAGE_TYPE_TRANSPORT_SESSION_SYN to the specified target. More... | |
static void | send_syn (struct NeighbourAddress *na) |
Send a SYN message via the given address. More... | |
static void | send_session_syn_ack_cont (void *cls, const struct GNUNET_PeerIdentity *target, int result, size_t size_payload, size_t size_on_wire) |
Continuation called from our attempt to transmitted our GNUNET_MESSAGE_TYPE_TRANSPORT_SESSION_SYN_ACK to the specified target. More... | |
static void | send_syn_ack_message (struct NeighbourAddress *na, struct GNUNET_TIME_Absolute timestamp) |
Send a SYN_ACK message via the given address. More... | |
static void | inbound_bw_tracker_update (void *cls) |
Function called by the bandwidth tracker for a peer whenever the tracker's state changed such that we need to recalculate the delay for flow control. More... | |
static struct NeighbourMapEntry * | setup_neighbour (const struct GNUNET_PeerIdentity *peer) |
Create a fresh entry in the neighbour map for the given peer. More... | |
int | GST_neighbours_handle_session_syn (const struct GNUNET_MessageHeader *message, const struct GNUNET_PeerIdentity *peer) |
We received a 'SYN' message from the other peer. More... | |
static int | try_run_fast_ats_update (const struct GNUNET_HELLO_Address *address, struct GNUNET_ATS_Session *session, struct GNUNET_BANDWIDTH_Value32NBO bandwidth_in, struct GNUNET_BANDWIDTH_Value32NBO bandwidth_out) |
Check if the given address is the same that we are already using for the respective neighbour. More... | |
static void | switch_address_bl_check_cont (void *cls, const struct GNUNET_PeerIdentity *peer, const struct GNUNET_HELLO_Address *address, struct GNUNET_ATS_Session *session, int result) |
We've been asked to switch addresses, and just now got the result from the blacklist check to see if this is allowed. More... | |
void | GST_neighbours_switch_to_address (const struct GNUNET_HELLO_Address *address, struct GNUNET_ATS_Session *session, struct GNUNET_BANDWIDTH_Value32NBO bandwidth_in, struct GNUNET_BANDWIDTH_Value32NBO bandwidth_out) |
For the given peer, switch to this address. More... | |
static int | send_utilization_data (void *cls, const struct GNUNET_PeerIdentity *key, void *value) |
Function called to send network utilization data to ATS for each active connection. More... | |
static void | utilization_transmission (void *cls) |
Task transmitting utilization in a regular interval. More... | |
void | GST_neighbours_notify_data_recv (const struct GNUNET_HELLO_Address *address, const struct GNUNET_MessageHeader *message) |
Track information about data we received from the given address (used to notify ATS about our utilization of allocated resources). More... | |
void | GST_neighbours_notify_data_sent (const struct GNUNET_HELLO_Address *address, struct GNUNET_ATS_Session *session, size_t size) |
Track information about data we transmitted using the given address and session (used to notify ATS about our utilization of allocated resources). More... | |
static void | send_session_ack_message (struct NeighbourMapEntry *n) |
Send a ACK message to the neighbour to confirm that we got its SYN_ACK. More... | |
int | GST_neighbours_handle_session_syn_ack (const struct GNUNET_MessageHeader *message, const struct GNUNET_HELLO_Address *address, struct GNUNET_ATS_Session *session) |
We received a 'SESSION_SYN_ACK' message from the other peer. More... | |
int | GST_neighbours_session_terminated (const struct GNUNET_PeerIdentity *peer, struct GNUNET_ATS_Session *session) |
A session was terminated. More... | |
int | GST_neighbours_handle_session_ack (const struct GNUNET_MessageHeader *message, const struct GNUNET_HELLO_Address *address, struct GNUNET_ATS_Session *session) |
We received a 'ACK' message from the other peer. More... | |
int | GST_neighbours_test_connected (const struct GNUNET_PeerIdentity *target) |
Test if we're connected to the given peer. More... | |
static void | delayed_disconnect (void *cls) |
Task to asynchronously run free_neighbour(). More... | |
void | GST_neighbours_handle_quota_message (const struct GNUNET_PeerIdentity *peer, const struct GNUNET_MessageHeader *msg) |
We received a quota message from the given peer, validate and process. More... | |
void | GST_neighbours_handle_disconnect_message (const struct GNUNET_PeerIdentity *peer, const struct GNUNET_MessageHeader *msg) |
We received a disconnect message from the given peer, validate and process. More... | |
static int | neighbours_iterate (void *cls, const struct GNUNET_PeerIdentity *key, void *value) |
Call the callback from the closure for each neighbour. More... | |
void | GST_neighbours_iterate (GST_NeighbourIterator cb, void *cb_cls) |
Iterate over all connected neighbours. More... | |
void | GST_neighbours_force_disconnect (const struct GNUNET_PeerIdentity *target) |
If we have an active connection to the given target, it must be shutdown. More... | |
const struct GNUNET_HELLO_Address * | GST_neighbour_get_current_address (const struct GNUNET_PeerIdentity *peer) |
Obtain current address information for the given neighbour. More... | |
void | GST_neighbours_start (unsigned int max_fds) |
Initialize the neighbours subsystem. More... | |
static int | disconnect_all_neighbours (void *cls, const struct GNUNET_PeerIdentity *key, void *value) |
Disconnect from the given neighbour. More... | |
void | GST_neighbours_stop () |
Cleanup the neighbours subsystem. More... | |
Variables | |
static struct GNUNET_CONTAINER_MultiPeerMap * | neighbours |
Hash map from peer identities to the respective struct NeighbourMapEntry . More... | |
static struct BlacklistCheckSwitchContext * | pending_bc_head |
List of pending blacklist checks: head. More... | |
static struct BlacklistCheckSwitchContext * | pending_bc_tail |
List of pending blacklist checks: tail. More... | |
static unsigned int | neighbours_connected |
counter for connected neighbours More... | |
static unsigned long long | bytes_in_send_queue |
Number of bytes we have currently queued for transmission. More... | |
static struct GNUNET_SCHEDULER_Task * | util_transmission_tk |
Task transmitting utilization data. More... | |
neighbour management
Definition in file gnunet-service-transport_neighbours.c.
#define IGNORE_INBOUND_QUOTA GNUNET_YES |
Experimental option to ignore SessionQuotaMessages from the other peer.
Definition at line 42 of file gnunet-service-transport_neighbours.c.
#define NEIGHBOUR_TABLE_SIZE 256 |
Size of the neighbour hash map.
Definition at line 47 of file gnunet-service-transport_neighbours.c.
#define DISCONNECT_SENT_TIMEOUT |
Time we give plugin to transmit DISCONNECT message before the neighbour entry self-destructs.
Definition at line 53 of file gnunet-service-transport_neighbours.c.
#define QUOTA_VIOLATION_DROP_THRESHOLD 10 |
How often must a peer violate bandwidth quotas before we start to simply drop its messages?
Definition at line 60 of file gnunet-service-transport_neighbours.c.
#define ATS_RESPONSE_TIMEOUT |
How long are we willing to wait for a response from ATS before timing out?
Definition at line 65 of file gnunet-service-transport_neighbours.c.
#define SETUP_CONNECTION_TIMEOUT |
How long are we willing to wait for an ACK from the other peer before giving up on our connect operation?
Definition at line 72 of file gnunet-service-transport_neighbours.c.
#define FAST_RECONNECT_TIMEOUT GNUNET_TIME_UNIT_SECONDS |
How long are we willing to wait for a successful reconnect if an existing connection went down? Much shorter than the usual SETUP_CONNECTION_TIMEOUT as we do not inform the higher layers about the disconnect during this period.
Definition at line 81 of file gnunet-service-transport_neighbours.c.
#define UTIL_TRANSMISSION_INTERVAL GNUNET_TIME_UNIT_SECONDS |
Interval to send utilization data.
Definition at line 86 of file gnunet-service-transport_neighbours.c.
enum GST_ACK_State |
State describing which kind a reply this neighbour should send.
Definition at line 91 of file gnunet-service-transport_neighbours.c.
|
static |
Convert the given ACK state to a string.
s | state |
Definition at line 497 of file gnunet-service-transport_neighbours.c.
References ACK_SEND_ACK, ACK_SEND_SYN_ACK, ACK_UNDEFINED, and GNUNET_break.
Referenced by GST_neighbours_handle_session_ack(), GST_neighbours_handle_session_syn(), and GST_neighbours_handle_session_syn_ack().
|
static |
Send information about a new outbound quota to our clients.
Note that the outbound quota is enforced client-side (i.e. in libgnunettransport).
n | affected peer |
Definition at line 525 of file gnunet-service-transport_neighbours.c.
References NeighbourAddress::bandwidth_out, GNUNET_BANDWIDTH_value_min(), GNUNET_ERROR_TYPE_DEBUG, GNUNET_i2s(), GNUNET_log, GNUNET_MESSAGE_TYPE_TRANSPORT_SET_QUOTA, GNUNET_NO, GNUNET_TRANSPORT_is_connected(), GST_clients_broadcast(), QuotaSetMessage::header, NeighbourMapEntry::id, NeighbourMapEntry::neighbour_receive_quota, QuotaSetMessage::peer, NeighbourMapEntry::primary_address, QuotaSetMessage::quota, GNUNET_MessageHeader::size, NeighbourMapEntry::state, GNUNET_MessageHeader::type, and GNUNET_BANDWIDTH_Value32NBO::value__.
Referenced by GST_neighbours_handle_quota_message(), set_primary_address(), and try_run_fast_ats_update().
|
static |
Notify our clients that another peer connected to us.
n | the peer that connected |
Definition at line 558 of file gnunet-service-transport_neighbours.c.
References NeighbourAddress::bandwidth_out, buf, GNUNET_ALIGN, GNUNET_BANDWIDTH_value_min(), GNUNET_ERROR_TYPE_INFO, GNUNET_i2s(), GNUNET_log, GNUNET_MESSAGE_TYPE_TRANSPORT_CONNECT, GNUNET_NO, GST_clients_broadcast(), ConnectInfoMessage::header, NeighbourMapEntry::id, ConnectInfoMessage::id, len, NeighbourMapEntry::neighbour_receive_quota, NeighbourMapEntry::primary_address, ConnectInfoMessage::quota_out, GNUNET_MessageHeader::size, and GNUNET_MessageHeader::type.
Referenced by set_state_and_timeout().
|
static |
Notify our clients (and manipulation) that a peer disconnected from us.
n | the peer that disconnected |
Definition at line 590 of file gnunet-service-transport_neighbours.c.
References GNUNET_ERROR_TYPE_INFO, GNUNET_i2s(), GNUNET_log, GST_clients_broadcast_disconnect(), GST_manipulation_peer_disconnect(), and NeighbourMapEntry::id.
Referenced by set_state_and_timeout().
|
static |
Notify transport clients that a neighbour peer changed its active address.
peer | identity of the peer |
address | address possibly NULL if peer is not connected |
state | current state this peer is in |
state_timeout | timeout for the current state of the peer |
bandwidth_in | bandwidth assigned inbound, 0 on disconnect |
bandwidth_out | bandwidth assigned outbound, 0 on disconnect |
Definition at line 612 of file gnunet-service-transport_neighbours.c.
References address, GNUNET_ERROR_TYPE_DEBUG, GNUNET_i2s(), GNUNET_log, GNUNET_STRINGS_absolute_time_to_string(), GNUNET_TRANSPORT_ps2s(), GST_clients_broadcast_peer_notification(), GST_plugins_a2s(), peer, and state.
Referenced by set_primary_address(), set_state_and_timeout(), and unset_primary_address().
|
static |
Lookup a neighbour entry in the neighbours hash map.
pid | identity of the peer to look up |
Definition at line 644 of file gnunet-service-transport_neighbours.c.
References GNUNET_CONTAINER_multipeermap_get(), neighbours, and pid.
Referenced by GST_neighbour_get_current_address(), GST_neighbours_calculate_receive_delay(), GST_neighbours_force_disconnect(), GST_neighbours_handle_disconnect_message(), GST_neighbours_handle_quota_message(), GST_neighbours_handle_session_ack(), GST_neighbours_handle_session_syn(), GST_neighbours_handle_session_syn_ack(), GST_neighbours_keepalive(), GST_neighbours_notify_data_recv(), GST_neighbours_notify_data_sent(), GST_neighbours_send(), GST_neighbours_session_terminated(), GST_neighbours_test_connected(), send_disconnect_cont(), send_session_syn_ack_cont(), send_session_syn_cont(), send_syn(), send_syn_ack_message(), switch_address_bl_check_cont(), transmit_send_continuation(), and try_run_fast_ats_update().
|
static |
Test if we're connected to the given peer.
n | neighbour entry of peer to test |
Definition at line 659 of file gnunet-service-transport_neighbours.c.
References GNUNET_NO, GNUNET_TRANSPORT_is_connected(), and NeighbourMapEntry::state.
Referenced by GST_neighbours_force_disconnect(), GST_neighbours_send(), GST_neighbours_test_connected(), send_utilization_data(), and set_incoming_quota().
|
static |
We don't need a given neighbour address any more.
Release its resources and give appropriate notifications to ATS and other subsystems.
na | address we are done with; na itself must NOT be 'free'd, only the contents! |
Definition at line 675 of file gnunet-service-transport_neighbours.c.
References NeighbourAddress::address, NeighbourAddress::ats_active, NeighbourAddress::bandwidth_in, NeighbourAddress::bandwidth_out, GNUNET_BANDWIDTH_value_init(), GNUNET_HELLO_address_free, GNUNET_NO, GNUNET_YES, GST_ats_block_address(), GST_validation_set_address_use(), NeighbourAddress::keep_alive_nonce, and NeighbourAddress::session.
Referenced by free_neighbour(), GST_neighbours_session_terminated(), master_task(), send_session_syn_cont(), send_syn(), send_with_session(), set_primary_address(), switch_address_bl_check_cont(), and unset_primary_address().
|
static |
Master task run for every neighbour.
Performs all of the time-related activities (keep alive, send next message, disconnect if idle, finish clean up after disconnect).
cls | the struct NeighbourMapEntry for which we are running |
Definition at line 3013 of file gnunet-service-transport_neighbours.c.
References NeighbourMapEntry::alternative_address, ATS_RESPONSE_TIMEOUT, delay, disconnect_neighbour(), free_address(), free_neighbour(), GNUNET_assert, GNUNET_break, GNUNET_ERROR_TYPE_DEBUG, GNUNET_ERROR_TYPE_ERROR, GNUNET_ERROR_TYPE_INFO, GNUNET_i2s(), GNUNET_log, GNUNET_SCHEDULER_add_delayed(), GNUNET_STRINGS_relative_time_to_string(), GNUNET_TIME_absolute_get_remaining(), GNUNET_TIME_relative_min(), GNUNET_TIME_relative_to_absolute(), GNUNET_TRANSPORT_ps2s(), GNUNET_TRANSPORT_PS_CONNECTED, GNUNET_TRANSPORT_PS_DISCONNECT, GNUNET_TRANSPORT_PS_DISCONNECT_FINISHED, GNUNET_TRANSPORT_PS_INIT_ATS, GNUNET_TRANSPORT_PS_NOT_CONNECTED, GNUNET_TRANSPORT_PS_RECONNECT_ATS, GNUNET_TRANSPORT_PS_RECONNECT_SENT, GNUNET_TRANSPORT_PS_SWITCH_SYN_SENT, GNUNET_TRANSPORT_PS_SYN_RECV_ACK, GNUNET_TRANSPORT_PS_SYN_RECV_ATS, GNUNET_TRANSPORT_PS_SYN_SENT, GNUNET_YES, NeighbourMapEntry::id, NeighbourMapEntry::keep_alive_time, GNUNET_TIME_Relative::rel_value_us, send_keepalive(), set_state_and_timeout(), SETUP_CONNECTION_TIMEOUT, NeighbourMapEntry::state, NeighbourMapEntry::task, NeighbourMapEntry::timeout, try_transmission_to_peer(), and unset_primary_address().
Referenced by disconnect_neighbour(), GST_neighbours_send(), GST_neighbours_session_terminated(), send_disconnect_cont(), set_state_and_timeout(), setup_neighbour(), and transmit_send_continuation().
|
static |
Set net state and state timeout for this neighbour and notify monitoring.
n | the respective neighbour |
s | the new state |
timeout | the new timeout |
Definition at line 714 of file gnunet-service-transport_neighbours.c.
References GNUNET_TIME_Absolute::abs_value_us, NeighbourAddress::address, NeighbourAddress::bandwidth_in, NeighbourAddress::bandwidth_out, gettext_noop, GNUNET_ERROR_TYPE_INFO, GNUNET_i2s(), GNUNET_log, GNUNET_NO, GNUNET_SCHEDULER_add_at(), GNUNET_SCHEDULER_cancel(), GNUNET_STATISTICS_set(), GNUNET_STRINGS_absolute_time_to_string(), GNUNET_TRANSPORT_is_connected(), GNUNET_TRANSPORT_ps2s(), GST_stats, NeighbourMapEntry::id, master_task(), neighbours_changed_notification(), neighbours_connect_notification(), neighbours_connected, neighbours_disconnect_notification(), NeighbourMapEntry::primary_address, NeighbourMapEntry::state, NeighbourMapEntry::task, timeout, and NeighbourMapEntry::timeout.
Referenced by disconnect_neighbour(), free_neighbour(), GST_neighbours_calculate_receive_delay(), GST_neighbours_handle_session_ack(), GST_neighbours_handle_session_syn(), GST_neighbours_handle_session_syn_ack(), GST_neighbours_session_terminated(), master_task(), send_session_syn_ack_cont(), send_session_syn_cont(), send_syn(), send_syn_ack_message(), setup_neighbour(), and switch_address_bl_check_cont().
|
static |
Initialize the alternative address of a neighbour.
n | the neighbour |
address | address of the other peer, NULL if other peer connected to us |
session | session to use (or NULL, in which case an address must be setup) |
bandwidth_in | inbound quota to be used when connection is up |
bandwidth_out | outbound quota to be used when connection is up |
Definition at line 773 of file gnunet-service-transport_neighbours.c.
Referenced by switch_address_bl_check_cont().
|
static |
Transmit a message using the current session of the given neighbour.
n | entry for the recipient |
msgbuf | buffer to transmit |
msgbuf_size | number of bytes in msgbuf buffer |
priority | transmission priority |
timeout | transmission timeout |
use_keepalive_timeout | GNUNET_YES to use plugin-specific keep-alive timeout (timeout is ignored in that case), GNUNET_NO otherwise |
cont | continuation to call when finished (can be NULL) |
cont_cls | closure for cont |
Definition at line 773 of file gnunet-service-transport_neighbours.c.
References address, NeighbourAddress::address, NeighbourMapEntry::alternative_address, NeighbourAddress::ats_active, NeighbourAddress::bandwidth_in, NeighbourAddress::bandwidth_out, GNUNET_TRANSPORT_PluginFunctions::cls, free_address(), GNUNET_TRANSPORT_PluginFunctions::get_session, gettext_noop, GNUNET_assert, GNUNET_break, GNUNET_ERROR_TYPE_DEBUG, GNUNET_ERROR_TYPE_INFO, GNUNET_HELLO_address_copy(), GNUNET_i2s(), GNUNET_log, GNUNET_NO, GNUNET_STATISTICS_update(), GNUNET_YES, GST_ats_is_known(), GST_ats_new_session(), GST_plugins_a2s(), GST_plugins_find(), GST_stats, NeighbourMapEntry::id, NeighbourAddress::keep_alive_nonce, and NeighbourAddress::session.
Referenced by GST_neighbours_keepalive(), send_disconnect(), send_keepalive(), send_session_ack_message(), set_incoming_quota(), and try_transmission_to_peer().
|
static |
Clear the primary address of a neighbour since this address is not valid anymore and notify monitoring about it.
n | the neighbour |
Definition at line 898 of file gnunet-service-transport_neighbours.c.
References NeighbourAddress::address, free_address(), GNUNET_BANDWIDTH_value_init(), GNUNET_ERROR_TYPE_DEBUG, GNUNET_log, NeighbourMapEntry::id, neighbours_changed_notification(), NeighbourMapEntry::primary_address, NeighbourMapEntry::state, and NeighbourMapEntry::timeout.
Referenced by free_neighbour(), GST_neighbours_session_terminated(), master_task(), send_session_syn_ack_cont(), send_session_syn_cont(), send_syn(), and send_syn_ack_message().
|
static |
Free a neighbour map entry.
n | entry to free |
Definition at line 921 of file gnunet-service-transport_neighbours.c.
References NeighbourAddress::address, NeighbourMapEntry::alternative_address, NeighbourMapEntry::delayed_disconnect_task, free_address(), GNUNET_assert, GNUNET_ATS_connectivity_suggest_cancel(), GNUNET_CONTAINER_DLL_remove, GNUNET_CONTAINER_multipeermap_remove(), GNUNET_ERROR_TYPE_DEBUG, GNUNET_free, GNUNET_i2s(), GNUNET_log, GNUNET_SCHEDULER_cancel(), GNUNET_SYSERR, GNUNET_TIME_UNIT_FOREVER_ABS, GNUNET_TRANSPORT_PS_DISCONNECT_FINISHED, GNUNET_YES, NeighbourMapEntry::id, NeighbourMapEntry::is_active, NeighbourMapEntry::messages_head, NeighbourMapEntry::messages_tail, mq, neighbours, set_state_and_timeout(), NeighbourMapEntry::suggest_handle, NeighbourMapEntry::task, and unset_primary_address().
Referenced by delayed_disconnect(), disconnect_all_neighbours(), disconnect_neighbour(), GST_neighbours_handle_session_syn(), GST_neighbours_handle_session_syn_ack(), GST_neighbours_session_terminated(), master_task(), and switch_address_bl_check_cont().
|
static |
Function called when the 'DISCONNECT' message has been sent by the plugin.
Frees the neighbour — if the entry still exists.
cls | NULL |
target | identity of the neighbour that was disconnected |
result | GNUNET_OK if the disconnect got out successfully |
payload | bytes payload |
physical | bytes on wire |
Definition at line 997 of file gnunet-service-transport_neighbours.c.
References GNUNET_SCHEDULER_add_now(), GNUNET_SCHEDULER_cancel(), GNUNET_TRANSPORT_PS_DISCONNECT, lookup_neighbour(), master_task(), payload, result, NeighbourMapEntry::state, and NeighbourMapEntry::task.
Referenced by send_disconnect().
|
static |
Transmit a DISCONNECT message to the other peer.
n | neighbour to send DISCONNECT message. |
Definition at line 1026 of file gnunet-service-transport_neighbours.c.
References gettext_noop, GNUNET_assert, GNUNET_CRYPTO_eddsa_sign_(), GNUNET_ERROR_TYPE_INFO, GNUNET_i2s(), GNUNET_log, GNUNET_MESSAGE_TYPE_TRANSPORT_SESSION_DISCONNECT, GNUNET_NO, GNUNET_OK, GNUNET_STATISTICS_update(), GNUNET_TIME_absolute_get(), GNUNET_TIME_absolute_hton(), GNUNET_TIME_UNIT_FOREVER_REL, GST_my_identity, GST_my_private_key, GST_stats, GNUNET_ATS_SessionDisconnectMessage::header, NeighbourMapEntry::id, GNUNET_PeerIdentity::public_key, GNUNET_ATS_SessionDisconnectMessage::public_key, GNUNET_CRYPTO_EccSignaturePurpose::purpose, GNUNET_ATS_SessionDisconnectMessage::purpose, GNUNET_ATS_SessionDisconnectMessage::reserved, send_disconnect_cont(), send_with_session(), GNUNET_ATS_SessionDisconnectMessage::signature, GNUNET_MessageHeader::size, GNUNET_CRYPTO_EccSignaturePurpose::size, GNUNET_ATS_SessionDisconnectMessage::timestamp, and GNUNET_MessageHeader::type.
Referenced by disconnect_neighbour().
|
static |
Disconnect from the given neighbour, clean up the record.
n | neighbour to disconnect from |
Definition at line 1073 of file gnunet-service-transport_neighbours.c.
References DISCONNECT_SENT_TIMEOUT, free_neighbour(), GNUNET_assert, GNUNET_break, GNUNET_ERROR_TYPE_ERROR, GNUNET_ERROR_TYPE_INFO, GNUNET_i2s(), GNUNET_log, GNUNET_SCHEDULER_add_delayed(), GNUNET_SCHEDULER_cancel(), GNUNET_TIME_UNIT_FOREVER_ABS, GNUNET_TRANSPORT_ps2s(), GNUNET_TRANSPORT_PS_CONNECTED, GNUNET_TRANSPORT_PS_DISCONNECT, GNUNET_TRANSPORT_PS_DISCONNECT_FINISHED, GNUNET_TRANSPORT_PS_INIT_ATS, GNUNET_TRANSPORT_PS_NOT_CONNECTED, GNUNET_TRANSPORT_PS_RECONNECT_ATS, GNUNET_TRANSPORT_PS_RECONNECT_SENT, GNUNET_TRANSPORT_PS_SWITCH_SYN_SENT, GNUNET_TRANSPORT_PS_SYN_RECV_ACK, GNUNET_TRANSPORT_PS_SYN_RECV_ATS, GNUNET_TRANSPORT_PS_SYN_SENT, NeighbourMapEntry::id, master_task(), send_disconnect(), set_state_and_timeout(), NeighbourMapEntry::state, and NeighbourMapEntry::task.
Referenced by GST_neighbours_force_disconnect(), master_task(), send_session_syn_cont(), send_syn(), and set_incoming_quota().
|
static |
Change the incoming quota for the given peer.
Updates our own receive rate and informs the neighbour about the new quota.
n | neighbour entry to change quota for |
quota | new quota |
Definition at line 1162 of file gnunet-service-transport_neighbours.c.
References disconnect_neighbour(), gettext_noop, GNUNET_BANDWIDTH_tracker_update_quota(), GNUNET_ERROR_TYPE_DEBUG, GNUNET_ERROR_TYPE_INFO, GNUNET_i2s(), GNUNET_log, GNUNET_MESSAGE_TYPE_TRANSPORT_SESSION_QUOTA, GNUNET_NO, GNUNET_STATISTICS_update(), GNUNET_TIME_UNIT_FOREVER_REL, GNUNET_YES, GST_stats, GNUNET_ATS_SessionQuotaMessage::header, NeighbourMapEntry::id, NeighbourMapEntry::in_tracker, NeighbourMapEntry::primary_address, quota, GNUNET_ATS_SessionQuotaMessage::quota, send_with_session(), NeighbourAddress::session, GNUNET_MessageHeader::size, test_connected(), and GNUNET_MessageHeader::type.
Referenced by set_primary_address(), and try_run_fast_ats_update().
|
static |
Initialize the primary address of a neighbour.
n | the neighbour |
address | address of the other peer, NULL if other peer connected to us |
session | session to use (or NULL, in which case an address must be setup) |
bandwidth_in | inbound quota to be used when connection is up |
bandwidth_out | outbound quota to be used when connection is up |
Definition at line 1211 of file gnunet-service-transport_neighbours.c.
References address, NeighbourAddress::address, NeighbourAddress::bandwidth_in, NeighbourAddress::bandwidth_out, free_address(), GNUNET_assert, GNUNET_break, GNUNET_ERROR_TYPE_DEBUG, GNUNET_ERROR_TYPE_INFO, GNUNET_HELLO_address_cmp(), GNUNET_HELLO_address_copy(), GNUNET_i2s(), GNUNET_log, GNUNET_YES, GST_ats_block_address(), GST_ats_is_known(), GST_plugins_a2s(), GST_validation_set_address_use(), NeighbourMapEntry::id, NeighbourAddress::keep_alive_nonce, neighbours_changed_notification(), NeighbourMapEntry::primary_address, send_outbound_quota_to_clients(), NeighbourAddress::session, set_incoming_quota(), NeighbourMapEntry::state, NeighbourMapEntry::timeout, and GNUNET_BANDWIDTH_Value32NBO::value__.
Referenced by GST_neighbours_handle_session_syn_ack(), and switch_address_bl_check_cont().
|
static |
We're done with our transmission attempt, continue processing.
cls | the struct MessageQueue of the message |
receiver | intended receiver |
success | whether it worked or not |
size_payload | bytes payload sent |
physical | bytes sent on wire |
Definition at line 1296 of file gnunet-service-transport_neighbours.c.
References bytes_in_send_queue, gettext_noop, GNUNET_break, GNUNET_ERROR_TYPE_DEBUG, GNUNET_ERROR_TYPE_ERROR, GNUNET_free, GNUNET_i2s(), GNUNET_log, GNUNET_NO, GNUNET_OK, GNUNET_SCHEDULER_add_now(), GNUNET_SCHEDULER_cancel(), GNUNET_STATISTICS_set(), GNUNET_STATISTICS_update(), GNUNET_SYSERR, GST_stats, NeighbourMapEntry::is_active, lookup_neighbour(), master_task(), mq, receiver(), and NeighbourMapEntry::task.
Referenced by try_transmission_to_peer().
|
static |
Check the message list for the given neighbour and if we can send a message, do so.
This function should only be called if the connection is at least generally ready for transmission. While we will only send one message at a time, no bandwidth quota management is performed here. If a message was given to the plugin, the continuation will automatically re-schedule the 'master' task once the next message might be transmitted.
n | target peer for which to transmit |
Definition at line 1383 of file gnunet-service-transport_neighbours.c.
References NeighbourAddress::address, GNUNET_HELLO_Address::address_length, gettext_noop, GNUNET_break, GNUNET_CONTAINER_DLL_remove, GNUNET_ERROR_TYPE_DEBUG, GNUNET_log, GNUNET_NO, GNUNET_STATISTICS_update(), GNUNET_SYSERR, GNUNET_TIME_absolute_get_remaining(), GST_stats, NeighbourMapEntry::id, NeighbourMapEntry::is_active, NeighbourMapEntry::messages_head, NeighbourMapEntry::messages_tail, mq, NeighbourMapEntry::primary_address, GNUNET_TIME_Relative::rel_value_us, send_with_session(), NeighbourAddress::session, timeout, and transmit_send_continuation().
Referenced by master_task().
|
static |
Send keepalive message to the neighbour.
Must only be called if we are on 'connected' state or while trying to switch addresses. Will internally determine if a keepalive is truly needed (so can always be called).
n | neighbour that went idle and needs a keepalive |
Definition at line 1467 of file gnunet-service-transport_neighbours.c.
References NeighbourMapEntry::expect_latency_response, gettext_noop, GNUNET_assert, GNUNET_CRYPTO_QUALITY_NONCE, GNUNET_CRYPTO_random_u32(), GNUNET_ERROR_TYPE_DEBUG, GNUNET_i2s(), GNUNET_log, GNUNET_MESSAGE_TYPE_TRANSPORT_SESSION_KEEPALIVE, GNUNET_NO, GNUNET_STATISTICS_update(), GNUNET_TIME_absolute_get(), GNUNET_TIME_absolute_get_remaining(), GNUNET_TIME_relative_to_absolute(), GNUNET_TIME_UNIT_FOREVER_REL, GNUNET_TRANSPORT_PS_CONNECTED, GNUNET_TRANSPORT_PS_SWITCH_SYN_SENT, GNUNET_YES, GST_stats, NeighbourMapEntry::id, NeighbourAddress::keep_alive_nonce, NeighbourMapEntry::keep_alive_time, NeighbourMapEntry::last_keep_alive_time, m, NeighbourMapEntry::primary_address, GNUNET_TIME_Relative::rel_value_us, send_with_session(), NeighbourMapEntry::state, and timeout.
Referenced by master_task().
void GST_neighbours_keepalive | ( | const struct GNUNET_PeerIdentity * | neighbour, |
const struct GNUNET_MessageHeader * | m | ||
) |
Keep the connection to the given neighbour alive longer, we received a KEEPALIVE (or equivalent); send a response.
neighbour | neighbour to keep alive (by sending keep alive response) |
m | the keep alive message containing the nonce to respond to |
Definition at line 1517 of file gnunet-service-transport_neighbours.c.
References gettext_noop, GNUNET_break_op, GNUNET_ERROR_TYPE_DEBUG, GNUNET_i2s(), GNUNET_log, GNUNET_MESSAGE_TYPE_TRANSPORT_SESSION_KEEPALIVE_RESPONSE, GNUNET_NO, GNUNET_STATISTICS_update(), GNUNET_TIME_UNIT_FOREVER_REL, GNUNET_YES, GST_stats, NeighbourMapEntry::id, lookup_neighbour(), m, msg, GNUNET_ATS_SessionKeepAliveMessage::nonce, NeighbourMapEntry::primary_address, send_with_session(), NeighbourAddress::session, GNUNET_MessageHeader::size, and GNUNET_MessageHeader::type.
void GST_neighbours_keepalive_response | ( | const struct GNUNET_PeerIdentity * | neighbour, |
const struct GNUNET_MessageHeader * | m | ||
) |
We received a KEEP_ALIVE_RESPONSE message and use this to calculate latency to this peer.
Pass the updated information (existing ats plus calculated latency) to ATS.
neighbour | neighbour to keep alive |
m | the message containing the keep alive response |
Definition at line 1582 of file gnunet-service-transport_neighbours.c.
struct GNUNET_TIME_Relative GST_neighbours_calculate_receive_delay | ( | const struct GNUNET_PeerIdentity * | sender, |
ssize_t | size, | ||
int * | do_forward | ||
) |
We have received a message from the given sender.
How long should we delay before receiving more? (Also used to keep the peer marked as live).
sender | sender of the message |
size | size of the message |
do_forward | set to GNUNET_YES if the message should be forwarded to clients GNUNET_NO if the neighbour is not connected or violates the quota, GNUNET_SYSERR if the connection is not fully up yet |
Definition at line 1582 of file gnunet-service-transport_neighbours.c.
References NeighbourAddress::address, GNUNET_TRANSPORT_PluginFunctions::cls, NeighbourMapEntry::expect_latency_response, gettext_noop, GNUNET_break, GNUNET_break_op, GNUNET_CONSTANTS_IDLE_CONNECTION_TIMEOUT, GNUNET_ERROR_TYPE_DEBUG, GNUNET_i2s(), GNUNET_log, GNUNET_NO, GNUNET_STATISTICS_update(), GNUNET_STRINGS_relative_time_to_string(), GNUNET_TIME_absolute_get_duration(), GNUNET_TIME_relative_divide(), GNUNET_TIME_relative_to_absolute(), GNUNET_TRANSPORT_PS_CONNECTED, GNUNET_YES, GST_ats_update_delay(), GST_plugins_find(), GST_stats, NeighbourMapEntry::id, NeighbourAddress::keep_alive_nonce, NeighbourMapEntry::last_keep_alive_time, lookup_neighbour(), m, msg, NeighbourMapEntry::primary_address, NeighbourAddress::session, set_state_and_timeout(), NeighbourMapEntry::state, GNUNET_HELLO_Address::transport_name, and GNUNET_TRANSPORT_PluginFunctions::update_session_timeout.
Referenced by inbound_bw_tracker_update().
void GST_neighbours_send | ( | const struct GNUNET_PeerIdentity * | target, |
const void * | msg, | ||
size_t | msg_size, | ||
struct GNUNET_TIME_Relative | timeout, | ||
GST_NeighbourSendContinuation | cont, | ||
void * | cont_cls | ||
) |
Transmit a message to the given target using the active connection.
target | destination |
msg | message to send |
msg_size | number of bytes in msg |
timeout | when to fail with timeout |
cont | function to call when done |
cont_cls | closure for cont |
Definition at line 1772 of file gnunet-service-transport_neighbours.c.
References bytes_in_send_queue, MessageQueue::cont, MessageQueue::cont_cls, gettext_noop, GNUNET_break, GNUNET_CONTAINER_DLL_insert_tail, GNUNET_ERROR_TYPE_DEBUG, GNUNET_i2s(), GNUNET_log, GNUNET_malloc, GNUNET_memcpy, GNUNET_NO, GNUNET_SCHEDULER_add_now(), GNUNET_SCHEDULER_cancel(), GNUNET_STATISTICS_set(), GNUNET_SYSERR, GNUNET_TIME_relative_to_absolute(), GNUNET_YES, GST_stats, lookup_neighbour(), master_task(), NeighbourMapEntry::messages_head, NeighbourMapEntry::messages_tail, mq, msg, NeighbourMapEntry::task, test_connected(), and timeout.
Referenced by GST_manipulation_send(), send_delayed(), and transmit_our_hello().
|
static |
Continuation called from our attempt to transmitted our GNUNET_MESSAGE_TYPE_TRANSPORT_SESSION_SYN to the specified target.
Continue processing based on the result. Specifically, if we failed to transmit, discard the address we used.
cls | NULL |
target | which peer received the transmission |
result | GNUNET_OK if sending worked |
size_payload | how many bytes of payload were sent (ignored) |
size_on_wire | how much bandwidth was consumed on the wire (ignored) |
Definition at line 1843 of file gnunet-service-transport_neighbours.c.
References _, NeighbourMapEntry::alternative_address, ATS_RESPONSE_TIMEOUT, disconnect_neighbour(), FAST_RECONNECT_TIMEOUT, free_address(), gettext_noop, GNUNET_ERROR_TYPE_DEBUG, GNUNET_ERROR_TYPE_INFO, GNUNET_i2s(), GNUNET_log, GNUNET_NO, GNUNET_OK, GNUNET_STATISTICS_update(), GNUNET_TIME_relative_to_absolute(), GNUNET_TRANSPORT_PS_CONNECTED, GNUNET_TRANSPORT_PS_INIT_ATS, GNUNET_TRANSPORT_PS_RECONNECT_ATS, GNUNET_TRANSPORT_PS_RECONNECT_SENT, GNUNET_TRANSPORT_PS_SWITCH_SYN_SENT, GNUNET_TRANSPORT_PS_SYN_SENT, GST_stats, lookup_neighbour(), result, set_state_and_timeout(), NeighbourMapEntry::state, and unset_primary_address().
Referenced by send_syn().
|
static |
Send a SYN message via the given address.
na | address to use |
Definition at line 1927 of file gnunet-service-transport_neighbours.c.
References _, NeighbourAddress::address, NeighbourMapEntry::alternative_address, ATS_RESPONSE_TIMEOUT, GNUNET_TRANSPORT_PluginFunctions::cls, NeighbourAddress::connect_timestamp, disconnect_neighbour(), FAST_RECONNECT_TIMEOUT, free_address(), gettext_noop, GNUNET_assert, GNUNET_break, GNUNET_ERROR_TYPE_DEBUG, GNUNET_ERROR_TYPE_INFO, GNUNET_ERROR_TYPE_WARNING, GNUNET_i2s(), GNUNET_log, GNUNET_MESSAGE_TYPE_TRANSPORT_SESSION_SYN, GNUNET_NO, GNUNET_STATISTICS_update(), GNUNET_TIME_absolute_get(), GNUNET_TIME_absolute_hton(), GNUNET_TIME_relative_to_absolute(), GNUNET_TRANSPORT_PS_CONNECTED, GNUNET_TRANSPORT_PS_INIT_ATS, GNUNET_TRANSPORT_PS_RECONNECT_ATS, GNUNET_TRANSPORT_PS_RECONNECT_SENT, GNUNET_TRANSPORT_PS_SWITCH_SYN_SENT, GNUNET_TRANSPORT_PS_SYN_SENT, GST_neighbours_notify_data_sent(), GST_plugins_a2s(), GST_plugins_find(), GST_stats, TransportSynMessage::header, lookup_neighbour(), GNUNET_HELLO_Address::peer, NeighbourMapEntry::primary_address, TransportSynMessage::reserved, GNUNET_TRANSPORT_PluginFunctions::send, send_session_syn_cont(), NeighbourAddress::session, set_state_and_timeout(), SETUP_CONNECTION_TIMEOUT, GNUNET_MessageHeader::size, NeighbourMapEntry::state, TransportSynMessage::timestamp, GNUNET_HELLO_Address::transport_name, GNUNET_MessageHeader::type, and unset_primary_address().
Referenced by switch_address_bl_check_cont().
|
static |
Continuation called from our attempt to transmitted our GNUNET_MESSAGE_TYPE_TRANSPORT_SESSION_SYN_ACK to the specified target.
Continue processing based on the result. Specifically, if we failed to transmit, discard the address we used.
cls | NULL |
target | which peer received the transmission |
result | GNUNET_OK if sending worked |
size_payload | how many bytes of payload were sent (ignored) |
size_on_wire | how much bandwidth was consumed on the wire (ignored) |
Definition at line 2035 of file gnunet-service-transport_neighbours.c.
References _, ACK_SEND_SYN_ACK, NeighbourMapEntry::ack_state, NeighbourAddress::address, ATS_RESPONSE_TIMEOUT, GNUNET_ERROR_TYPE_INFO, GNUNET_i2s(), GNUNET_log, GNUNET_OK, GNUNET_TIME_relative_to_absolute(), GNUNET_TRANSPORT_PS_SYN_RECV_ACK, GNUNET_TRANSPORT_PS_SYN_RECV_ATS, GST_plugins_a2s(), lookup_neighbour(), NeighbourMapEntry::primary_address, result, set_state_and_timeout(), NeighbourMapEntry::state, and unset_primary_address().
Referenced by send_syn_ack_message().
|
static |
Send a SYN_ACK message via the given address.
na | address and session to use |
timestamp | timestamp to use for the ACK message |
Definition at line 2092 of file gnunet-service-transport_neighbours.c.
References _, ACK_SEND_SYN_ACK, NeighbourMapEntry::ack_state, address, NeighbourAddress::address, ATS_RESPONSE_TIMEOUT, GNUNET_TRANSPORT_PluginFunctions::cls, GNUNET_TRANSPORT_PluginFunctions::get_session, gettext_noop, GNUNET_break, GNUNET_ERROR_TYPE_INFO, GNUNET_ERROR_TYPE_WARNING, GNUNET_i2s(), GNUNET_log, GNUNET_MESSAGE_TYPE_TRANSPORT_SESSION_SYN_ACK, GNUNET_NO, GNUNET_STATISTICS_update(), GNUNET_SYSERR, GNUNET_TIME_absolute_hton(), GNUNET_TIME_relative_to_absolute(), GNUNET_TIME_UNIT_FOREVER_REL, GNUNET_TRANSPORT_PS_SYN_RECV_ATS, GST_ats_new_session(), GST_plugins_a2s(), GST_plugins_find(), GST_stats, TransportSynMessage::header, lookup_neighbour(), TransportSynMessage::reserved, GNUNET_TRANSPORT_PluginFunctions::send, send_session_syn_ack_cont(), NeighbourAddress::session, set_state_and_timeout(), GNUNET_MessageHeader::size, TransportSynMessage::timestamp, GNUNET_MessageHeader::type, and unset_primary_address().
Referenced by GST_neighbours_handle_session_syn(), and switch_address_bl_check_cont().
|
static |
Function called by the bandwidth tracker for a peer whenever the tracker's state changed such that we need to recalculate the delay for flow control.
We calculate the latest delay and inform the plugin (if applicable).
cls | the struct NeighbourMapEntry to update calculations for |
Definition at line 2170 of file gnunet-service-transport_neighbours.c.
References NeighbourAddress::address, GNUNET_TRANSPORT_PluginFunctions::cls, delay, GNUNET_assert, GNUNET_ERROR_TYPE_DEBUG, GNUNET_i2s(), GNUNET_log, GST_neighbours_calculate_receive_delay(), GST_plugins_find(), NeighbourMapEntry::id, NeighbourMapEntry::primary_address, GNUNET_TIME_Relative::rel_value_us, NeighbourAddress::session, GNUNET_HELLO_Address::transport_name, and GNUNET_TRANSPORT_PluginFunctions::update_inbound_delay.
Referenced by setup_neighbour().
|
static |
Create a fresh entry in the neighbour map for the given peer.
peer | peer to create an entry for |
Definition at line 2206 of file gnunet-service-transport_neighbours.c.
References NeighbourMapEntry::ack_state, ACK_UNDEFINED, GNUNET_assert, GNUNET_ATS_connectivity_suggest(), GNUNET_BANDWIDTH_tracker_init(), GNUNET_CONSTANTS_DEFAULT_BW_IN_OUT, GNUNET_CONTAINER_MULTIHASHMAPOPTION_UNIQUE_ONLY, GNUNET_CONTAINER_multipeermap_put(), GNUNET_ERROR_TYPE_DEBUG, GNUNET_i2s(), GNUNET_log, GNUNET_new, GNUNET_OK, GNUNET_SCHEDULER_add_now(), GNUNET_TIME_absolute_get(), GNUNET_TIME_UNIT_FOREVER_ABS, GNUNET_TRANSPORT_PS_NOT_CONNECTED, GST_ats_connect, GST_my_identity, NeighbourMapEntry::id, NeighbourMapEntry::in_tracker, inbound_bw_tracker_update(), NeighbourMapEntry::last_util_transmission, master_task(), MAX_BANDWIDTH_CARRY_S, NeighbourMapEntry::neighbour_receive_quota, neighbours, peer, set_state_and_timeout(), NeighbourMapEntry::suggest_handle, and NeighbourMapEntry::task.
Referenced by GST_neighbours_handle_session_syn(), and switch_address_bl_check_cont().
int GST_neighbours_handle_session_syn | ( | const struct GNUNET_MessageHeader * | message, |
const struct GNUNET_PeerIdentity * | peer | ||
) |
We received a 'SYN' message from the other peer.
We received a 'SESSION_CONNECT' message from the other peer.
Consider switching to it.
message | possibly a struct TransportSynMessage (check format) |
peer | identity of the peer to switch the address for |
Definition at line 2290 of file gnunet-service-transport_neighbours.c.
References _, ACK_SEND_ACK, ACK_SEND_SYN_ACK, NeighbourMapEntry::ack_state, NeighbourAddress::address, ATS_RESPONSE_TIMEOUT, NeighbourMapEntry::connect_ack_timestamp, free_neighbour(), gettext_noop, GNUNET_assert, GNUNET_break, GNUNET_break_op, GNUNET_ERROR_TYPE_ERROR, GNUNET_ERROR_TYPE_INFO, GNUNET_i2s(), GNUNET_log, GNUNET_NO, GNUNET_OK, GNUNET_STATISTICS_update(), GNUNET_SYSERR, GNUNET_TIME_absolute_ntoh(), GNUNET_TIME_relative_to_absolute(), GNUNET_TRANSPORT_ps2s(), GNUNET_TRANSPORT_PS_CONNECTED, GNUNET_TRANSPORT_PS_DISCONNECT, GNUNET_TRANSPORT_PS_DISCONNECT_FINISHED, GNUNET_TRANSPORT_PS_INIT_ATS, GNUNET_TRANSPORT_PS_NOT_CONNECTED, GNUNET_TRANSPORT_PS_RECONNECT_ATS, GNUNET_TRANSPORT_PS_RECONNECT_SENT, GNUNET_TRANSPORT_PS_SWITCH_SYN_SENT, GNUNET_TRANSPORT_PS_SYN_RECV_ACK, GNUNET_TRANSPORT_PS_SYN_RECV_ATS, GNUNET_TRANSPORT_PS_SYN_SENT, GST_my_identity, GST_stats, lookup_neighbour(), neighbours, peer, NeighbourMapEntry::primary_address, print_ack_state(), TransportSynMessage::reserved, send_syn_ack_message(), NeighbourAddress::session, set_state_and_timeout(), setup_neighbour(), GNUNET_MessageHeader::size, NeighbourMapEntry::state, and TransportSynMessage::timestamp.
Referenced by connect_bl_check_cont().
|
static |
Check if the given address is the same that we are already using for the respective neighbour.
If so, update the bandwidth assignment and possibly the session and return GNUNET_OK. If the new address is different from what the neighbour is using right now, return GNUNET_NO.
address | address of the other peer, |
session | session to use or NULL if transport should initiate a session |
bandwidth_in | inbound quota to be used when connection is up, 0 to disconnect from peer |
bandwidth_out | outbound quota to be used when connection is up, 0 to disconnect from peer |
Definition at line 2454 of file gnunet-service-transport_neighbours.c.
References address, NeighbourAddress::address, NeighbourAddress::bandwidth_in, NeighbourAddress::bandwidth_out, GNUNET_assert, GNUNET_HELLO_address_cmp(), GNUNET_NO, GNUNET_OK, GNUNET_YES, GST_ats_is_known(), lookup_neighbour(), NeighbourMapEntry::primary_address, send_outbound_quota_to_clients(), NeighbourAddress::session, set_incoming_quota(), and GNUNET_BANDWIDTH_Value32NBO::value__.
Referenced by GST_neighbours_switch_to_address(), and switch_address_bl_check_cont().
|
static |
We've been asked to switch addresses, and just now got the result from the blacklist check to see if this is allowed.
cls | the struct BlacklistCheckSwitchContext with the information about the future address |
peer | the peer we may switch addresses on |
address | address associated with the request |
session | session associated with the request |
result | GNUNET_OK if the connection is allowed, GNUNET_NO if not, GNUNET_SYSERR if operation was aborted |
Definition at line 2509 of file gnunet-service-transport_neighbours.c.
References ACK_SEND_ACK, ACK_SEND_SYN_ACK, NeighbourMapEntry::ack_state, ACK_UNDEFINED, address, NeighbourAddress::address, NeighbourMapEntry::alternative_address, BlacklistCheckSwitchContext::bandwidth_in, BlacklistCheckSwitchContext::bandwidth_out, cleanup(), GNUNET_TRANSPORT_PluginFunctions::cls, NeighbourMapEntry::connect_ack_timestamp, GNUNET_TRANSPORT_PluginFunctions::disconnect_session, FAST_RECONNECT_TIMEOUT, free_address(), free_neighbour(), GNUNET_TRANSPORT_PluginFunctions::get_session, gettext_noop, GNUNET_assert, GNUNET_break, GNUNET_CONTAINER_DLL_remove, GNUNET_ERROR_TYPE_DEBUG, GNUNET_ERROR_TYPE_ERROR, GNUNET_ERROR_TYPE_INFO, GNUNET_free, GNUNET_HELLO_address_check_option(), GNUNET_HELLO_address_cmp(), GNUNET_HELLO_ADDRESS_INFO_INBOUND, GNUNET_i2s(), GNUNET_log, GNUNET_NO, GNUNET_OK, GNUNET_STATISTICS_update(), GNUNET_SYSERR, GNUNET_TIME_relative_to_absolute(), GNUNET_TRANSPORT_ps2s(), GNUNET_TRANSPORT_PS_CONNECTED, GNUNET_TRANSPORT_PS_DISCONNECT, GNUNET_TRANSPORT_PS_DISCONNECT_FINISHED, GNUNET_TRANSPORT_PS_INIT_ATS, GNUNET_TRANSPORT_PS_NOT_CONNECTED, GNUNET_TRANSPORT_PS_RECONNECT_ATS, GNUNET_TRANSPORT_PS_RECONNECT_SENT, GNUNET_TRANSPORT_PS_SWITCH_SYN_SENT, GNUNET_TRANSPORT_PS_SYN_RECV_ACK, GNUNET_TRANSPORT_PS_SYN_RECV_ATS, GNUNET_TRANSPORT_PS_SYN_SENT, GNUNET_YES, GST_ats_block_address(), GST_ats_new_session(), GST_plugins_a2s(), GST_plugins_find(), GST_stats, lookup_neighbour(), peer, pending_bc_head, pending_bc_tail, NeighbourMapEntry::primary_address, result, send_syn(), send_syn_ack_message(), NeighbourAddress::session, set_alternative_address(), set_primary_address(), set_state_and_timeout(), SETUP_CONNECTION_TIMEOUT, setup_neighbour(), NeighbourMapEntry::state, NeighbourMapEntry::timeout, and try_run_fast_ats_update().
Referenced by GST_neighbours_switch_to_address().
void GST_neighbours_switch_to_address | ( | const struct GNUNET_HELLO_Address * | address, |
struct GNUNET_ATS_Session * | session, | ||
struct GNUNET_BANDWIDTH_Value32NBO | bandwidth_in, | ||
struct GNUNET_BANDWIDTH_Value32NBO | bandwidth_out | ||
) |
For the given peer, switch to this address.
For an existing neighbour record, set the active connection to use the given address.
Before accepting this addresses and actively using it, a blacklist check is performed.
If any check fails or the suggestion can somehow not be followed, we MUST call GST_ats_block_address() to tell ATS that the suggestion could not be satisfied and force ATS to do something else.
address | address of the other peer, |
session | session to use or NULL if transport should initiate a session |
bandwidth_in | inbound quota to be used when connection is up, 0 to disconnect from peer |
bandwidth_out | outbound quota to be used when connection is up, 0 to disconnect from peer |
Definition at line 2834 of file gnunet-service-transport_neighbours.c.
References address, BlacklistCheckSwitchContext::bandwidth_in, BlacklistCheckSwitchContext::bandwidth_out, BlacklistCheckSwitchContext::blc, GNUNET_assert, GNUNET_break, GNUNET_CONTAINER_DLL_insert, GNUNET_ERROR_TYPE_DEBUG, GNUNET_HELLO_address_check_option(), GNUNET_HELLO_ADDRESS_INFO_INBOUND, GNUNET_i2s(), GNUNET_log, GNUNET_new, GNUNET_OK, GST_ats_block_address(), GST_blacklist_test_allowed(), GST_plugins_a2s(), GST_plugins_find(), pending_bc_head, pending_bc_tail, switch_address_bl_check_cont(), try_run_fast_ats_update(), and GNUNET_BANDWIDTH_Value32NBO::value__.
Referenced by ats_request_address_change().
|
static |
Function called to send network utilization data to ATS for each active connection.
cls | NULL |
key | peer we send utilization data for |
value | the struct NeighbourMapEntry * with data to send |
Definition at line 2908 of file gnunet-service-transport_neighbours.c.
References NeighbourAddress::address, delta, GNUNET_ERROR_TYPE_DEBUG, GNUNET_i2s(), GNUNET_log, GNUNET_OK, GNUNET_TIME_absolute_get(), GNUNET_TIME_absolute_get_difference(), GNUNET_YES, GST_ats_update_utilization(), key, NeighbourMapEntry::last_util_transmission, NeighbourMapEntry::primary_address, GNUNET_TIME_Relative::rel_value_us, test_connected(), NeighbourMapEntry::util_total_bytes_recv, NeighbourMapEntry::util_total_bytes_sent, and value.
Referenced by utilization_transmission().
|
static |
Task transmitting utilization in a regular interval.
cls | the struct NeighbourMapEntry for which we are running |
Definition at line 2952 of file gnunet-service-transport_neighbours.c.
References GNUNET_CONTAINER_multipeermap_iterate(), GNUNET_SCHEDULER_add_delayed(), neighbours, send_utilization_data(), UTIL_TRANSMISSION_INTERVAL, and util_transmission_tk.
Referenced by GST_neighbours_start().
void GST_neighbours_notify_data_recv | ( | const struct GNUNET_HELLO_Address * | address, |
const struct GNUNET_MessageHeader * | message | ||
) |
Track information about data we received from the given address (used to notify ATS about our utilization of allocated resources).
address | the address we got data from |
message | the message we received (really only the size is used) |
Definition at line 2975 of file gnunet-service-transport_neighbours.c.
References address, lookup_neighbour(), GNUNET_MessageHeader::size, and NeighbourMapEntry::util_total_bytes_recv.
void GST_neighbours_notify_data_sent | ( | const struct GNUNET_HELLO_Address * | address, |
struct GNUNET_ATS_Session * | session, | ||
size_t | size | ||
) |
Track information about data we transmitted using the given address and session (used to notify ATS about our utilization of allocated resources).
address | the address we transmitted data to |
session | session we used to transmit data |
message | the message we sent (really only the size is used) |
Definition at line 2997 of file gnunet-service-transport_neighbours.c.
References address, lookup_neighbour(), NeighbourMapEntry::primary_address, NeighbourAddress::session, size, and NeighbourMapEntry::util_total_bytes_sent.
Referenced by GST_validation_handle_ping(), multicast_pong(), send_syn(), and transmit_ping_if_allowed().
|
static |
Send a ACK message to the neighbour to confirm that we got its SYN_ACK.
n | neighbour to send the ACK to |
Definition at line 3177 of file gnunet-service-transport_neighbours.c.
References GNUNET_ERROR_TYPE_INFO, GNUNET_i2s(), GNUNET_log, GNUNET_MESSAGE_TYPE_TRANSPORT_SESSION_ACK, GNUNET_NO, GNUNET_TIME_UNIT_FOREVER_REL, NeighbourMapEntry::id, msg, send_with_session(), GNUNET_MessageHeader::size, and GNUNET_MessageHeader::type.
Referenced by GST_neighbours_handle_session_syn_ack().
int GST_neighbours_handle_session_syn_ack | ( | const struct GNUNET_MessageHeader * | message, |
const struct GNUNET_HELLO_Address * | address, | ||
struct GNUNET_ATS_Session * | session | ||
) |
We received a 'SESSION_SYN_ACK' message from the other peer.
We received a 'SESSION_CONNECT_ACK' message from the other peer.
Consider switching to it.
message | possibly a struct GNUNET_ATS_SessionConnectMessage (check format) |
peer | identity of the peer to switch the address for |
address | address of the other peer, NULL if other peer connected to us |
session | session to use (or NULL) |
Definition at line 3209 of file gnunet-service-transport_neighbours.c.
References GNUNET_TIME_Absolute::abs_value_us, NeighbourMapEntry::ack_state, address, NeighbourAddress::address, NeighbourMapEntry::alternative_address, NeighbourAddress::ats_active, NeighbourAddress::bandwidth_in, NeighbourAddress::bandwidth_out, NeighbourAddress::connect_timestamp, free_neighbour(), gettext_noop, GNUNET_assert, GNUNET_break, GNUNET_break_op, GNUNET_CONSTANTS_IDLE_CONNECTION_TIMEOUT, GNUNET_ERROR_TYPE_DEBUG, GNUNET_ERROR_TYPE_ERROR, GNUNET_ERROR_TYPE_INFO, GNUNET_HELLO_address_free, GNUNET_i2s(), GNUNET_log, GNUNET_NO, GNUNET_OK, GNUNET_STATISTICS_update(), GNUNET_SYSERR, GNUNET_TIME_absolute_ntoh(), GNUNET_TIME_relative_to_absolute(), GNUNET_TRANSPORT_ps2s(), GNUNET_TRANSPORT_PS_CONNECTED, GNUNET_TRANSPORT_PS_DISCONNECT, GNUNET_TRANSPORT_PS_DISCONNECT_FINISHED, GNUNET_TRANSPORT_PS_INIT_ATS, GNUNET_TRANSPORT_PS_NOT_CONNECTED, GNUNET_TRANSPORT_PS_RECONNECT_ATS, GNUNET_TRANSPORT_PS_RECONNECT_SENT, GNUNET_TRANSPORT_PS_SWITCH_SYN_SENT, GNUNET_TRANSPORT_PS_SYN_RECV_ACK, GNUNET_TRANSPORT_PS_SYN_RECV_ATS, GNUNET_TRANSPORT_PS_SYN_SENT, GST_stats, lookup_neighbour(), NeighbourMapEntry::primary_address, print_ack_state(), TransportSynMessage::reserved, send_session_ack_message(), NeighbourAddress::session, set_primary_address(), set_state_and_timeout(), GNUNET_MessageHeader::size, NeighbourMapEntry::state, and TransportSynMessage::timestamp.
int GST_neighbours_session_terminated | ( | const struct GNUNET_PeerIdentity * | peer, |
struct GNUNET_ATS_Session * | session | ||
) |
A session was terminated.
Take note; if needed, try to get an alternative address from ATS.
peer | identity of the peer where the session died |
session | session that is gone |
Definition at line 3371 of file gnunet-service-transport_neighbours.c.
References NeighbourAddress::address, NeighbourMapEntry::alternative_address, ATS_RESPONSE_TIMEOUT, NeighbourMapEntry::expect_latency_response, FAST_RECONNECT_TIMEOUT, free_address(), free_neighbour(), GNUNET_assert, GNUNET_break, GNUNET_ERROR_TYPE_DEBUG, GNUNET_ERROR_TYPE_ERROR, GNUNET_ERROR_TYPE_INFO, GNUNET_i2s(), GNUNET_log, GNUNET_NO, GNUNET_SCHEDULER_add_now(), GNUNET_SCHEDULER_cancel(), GNUNET_TIME_relative_to_absolute(), GNUNET_TRANSPORT_ps2s(), GNUNET_TRANSPORT_PS_CONNECTED, GNUNET_TRANSPORT_PS_DISCONNECT, GNUNET_TRANSPORT_PS_DISCONNECT_FINISHED, GNUNET_TRANSPORT_PS_INIT_ATS, GNUNET_TRANSPORT_PS_NOT_CONNECTED, GNUNET_TRANSPORT_PS_RECONNECT_ATS, GNUNET_TRANSPORT_PS_RECONNECT_SENT, GNUNET_TRANSPORT_PS_SWITCH_SYN_SENT, GNUNET_TRANSPORT_PS_SYN_RECV_ACK, GNUNET_TRANSPORT_PS_SYN_RECV_ATS, GNUNET_TRANSPORT_PS_SYN_SENT, GNUNET_YES, GST_ats_is_known(), GST_plugins_a2s(), lookup_neighbour(), master_task(), peer, NeighbourMapEntry::primary_address, NeighbourAddress::session, set_state_and_timeout(), NeighbourMapEntry::state, NeighbourMapEntry::task, NeighbourMapEntry::timeout, and unset_primary_address().
Referenced by plugin_env_session_end().
int GST_neighbours_handle_session_ack | ( | const struct GNUNET_MessageHeader * | message, |
const struct GNUNET_HELLO_Address * | address, | ||
struct GNUNET_ATS_Session * | session | ||
) |
We received a 'ACK' message from the other peer.
We received a 'SESSION_ACK' message from the other peer.
If we sent a 'SYN_ACK' last, this means we are now connected. Otherwise, do nothing.
message | possibly a 'struct GNUNET_ATS_SessionConnectMessage' (check format) |
address | address of the other peer |
session | session to use (or NULL) |
Definition at line 3518 of file gnunet-service-transport_neighbours.c.
References ACK_SEND_ACK, NeighbourMapEntry::ack_state, address, NeighbourAddress::address, gettext_noop, GNUNET_break, GNUNET_break_op, GNUNET_CONSTANTS_IDLE_CONNECTION_TIMEOUT, GNUNET_ERROR_TYPE_DEBUG, GNUNET_ERROR_TYPE_WARNING, GNUNET_i2s(), GNUNET_log, GNUNET_NO, GNUNET_OK, GNUNET_STATISTICS_update(), GNUNET_SYSERR, GNUNET_TIME_relative_to_absolute(), GNUNET_TRANSPORT_ps2s(), GNUNET_TRANSPORT_PS_CONNECTED, GNUNET_TRANSPORT_PS_SWITCH_SYN_SENT, GNUNET_TRANSPORT_PS_SYN_RECV_ACK, GST_ats_block_reset(), GST_stats, lookup_neighbour(), NeighbourMapEntry::primary_address, print_ack_state(), NeighbourAddress::session, set_state_and_timeout(), GNUNET_MessageHeader::size, and NeighbourMapEntry::state.
int GST_neighbours_test_connected | ( | const struct GNUNET_PeerIdentity * | target | ) |
Test if we're connected to the given peer.
target | peer to test |
Definition at line 3608 of file gnunet-service-transport_neighbours.c.
References lookup_neighbour(), and test_connected().
Referenced by handle_client_send(), notify_client_about_neighbour(), send_delayed(), and transmit_our_hello().