GNUnet  0.11.x
Data Structures | Macros | Enumerations | Functions | Variables
gnunet-service-transport_neighbours.c File Reference

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"
Include dependency graph for gnunet-service-transport_neighbours.c:

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 NeighbourMapEntrylookup_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 NeighbourMapEntrysetup_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_AddressGST_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_MultiPeerMapneighbours
 Hash map from peer identities to the respective struct NeighbourMapEntry. More...
 
static struct BlacklistCheckSwitchContextpending_bc_head
 List of pending blacklist checks: head. More...
 
static struct BlacklistCheckSwitchContextpending_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_Taskutil_transmission_tk
 Task transmitting utilization data. More...
 

Detailed Description

neighbour management

Author
Christian Grothoff

Definition in file gnunet-service-transport_neighbours.c.

Macro Definition Documentation

◆ IGNORE_INBOUND_QUOTA

#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.

◆ NEIGHBOUR_TABLE_SIZE

#define NEIGHBOUR_TABLE_SIZE   256

Size of the neighbour hash map.

Definition at line 47 of file gnunet-service-transport_neighbours.c.

◆ DISCONNECT_SENT_TIMEOUT

#define DISCONNECT_SENT_TIMEOUT
Value:
#define GNUNET_TIME_UNIT_MILLISECONDS
One millisecond.
struct GNUNET_TIME_Relative GNUNET_TIME_relative_multiply(struct GNUNET_TIME_Relative rel, unsigned long long factor)
Multiply relative time by a given factor.
Definition: time.c:311

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.

◆ QUOTA_VIOLATION_DROP_THRESHOLD

#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.

◆ ATS_RESPONSE_TIMEOUT

#define ATS_RESPONSE_TIMEOUT
Value:
#define GNUNET_TIME_UNIT_SECONDS
One second.

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.

◆ SETUP_CONNECTION_TIMEOUT

#define SETUP_CONNECTION_TIMEOUT
Value:

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.

◆ FAST_RECONNECT_TIMEOUT

#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.

◆ UTIL_TRANSMISSION_INTERVAL

#define UTIL_TRANSMISSION_INTERVAL   GNUNET_TIME_UNIT_SECONDS

Interval to send utilization data.

Definition at line 86 of file gnunet-service-transport_neighbours.c.

Enumeration Type Documentation

◆ GST_ACK_State

State describing which kind a reply this neighbour should send.

Enumerator
ACK_UNDEFINED 

We did not receive a SYN message for this neighbour.

ACK_SEND_SYN_ACK 

The neighbour received a SYN message and has to send a SYN_ACK as reply.

ACK_SEND_ACK 

The neighbour sent a SYN_ACK message and has to send a ACK as reply.

Definition at line 91 of file gnunet-service-transport_neighbours.c.

92 {
96  ACK_UNDEFINED = 0,
97 
102  ACK_SEND_SYN_ACK = 1,
103 
108  ACK_SEND_ACK = 2
109 };
@ ACK_SEND_SYN_ACK
The neighbour received a SYN message and has to send a SYN_ACK as reply.
@ ACK_SEND_ACK
The neighbour sent a SYN_ACK message and has to send a ACK as reply.
@ ACK_UNDEFINED
We did not receive a SYN message for this neighbour.

Function Documentation

◆ print_ack_state()

static char* print_ack_state ( enum GST_ACK_State  s)
static

Convert the given ACK state to a string.

Parameters
sstate
Returns
corresponding human-readable string

Definition at line 497 of file gnunet-service-transport_neighbours.c.

498 {
499  switch (s)
500  {
501  case ACK_UNDEFINED:
502  return "UNDEFINED";
503 
504  case ACK_SEND_SYN_ACK:
505  return "SEND_SYN_ACK";
506 
507  case ACK_SEND_ACK:
508  return "SEND_ACK";
509 
510  default:
511  GNUNET_break (0);
512  return "N/A";
513  }
514 }
#define GNUNET_break(cond)
Use this for internal assertion violations that are not fatal (can be handled) but should not occur.

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().

Here is the caller graph for this function:

◆ send_outbound_quota_to_clients()

static void send_outbound_quota_to_clients ( struct NeighbourMapEntry n)
static

Send information about a new outbound quota to our clients.

Note that the outbound quota is enforced client-side (i.e. in libgnunettransport).

Parameters
naffected peer

Definition at line 525 of file gnunet-service-transport_neighbours.c.

526 {
527  struct QuotaSetMessage q_msg;
528  struct GNUNET_BANDWIDTH_Value32NBO bandwidth_min;
529 
531  return;
532 #if IGNORE_INBOUND_QUOTA
533  bandwidth_min = n->primary_address.bandwidth_out;
534 #else
537 #endif
538 
540  "Sending outbound quota of %u Bps for peer `%s' to all clients\n",
541  ntohl (bandwidth_min.value__),
542  GNUNET_i2s (&n->id));
543  q_msg.header.size = htons (sizeof(struct QuotaSetMessage));
544  q_msg.header.type = htons (GNUNET_MESSAGE_TYPE_TRANSPORT_SET_QUOTA);
545  q_msg.quota = bandwidth_min;
546  q_msg.peer = n->id;
547  GST_clients_broadcast (&q_msg.header,
548  GNUNET_NO);
549 }
void GST_clients_broadcast(const struct GNUNET_MessageHeader *msg, int may_drop)
Broadcast the given message to all of our clients.
#define GNUNET_log(kind,...)
@ GNUNET_NO
Definition: gnunet_common.h:94
struct GNUNET_BANDWIDTH_Value32NBO GNUNET_BANDWIDTH_value_min(struct GNUNET_BANDWIDTH_Value32NBO b1, struct GNUNET_BANDWIDTH_Value32NBO b2)
Compute the MIN of two bandwidth values.
Definition: bandwidth.c:56
const char * GNUNET_i2s(const struct GNUNET_PeerIdentity *pid)
Convert a peer identity to a string (for printing debug messages).
@ GNUNET_ERROR_TYPE_DEBUG
#define GNUNET_MESSAGE_TYPE_TRANSPORT_SET_QUOTA
Message telling transport to limit its receive rate.
int GNUNET_TRANSPORT_is_connected(enum GNUNET_TRANSPORT_PeerState state)
Check if a state is defined as connected.
32-bit bandwidth used for network exchange by GNUnet, in bytes per second.
struct GNUNET_BANDWIDTH_Value32NBO bandwidth_out
Outbound bandwidth from ATS for this address.
struct NeighbourAddress primary_address
Primary address we currently use to communicate with the neighbour.
enum GNUNET_TRANSPORT_PeerState state
The current state of the peer.
struct GNUNET_BANDWIDTH_Value32NBO neighbour_receive_quota
Latest quota the other peer send us in bytes per second.
struct GNUNET_PeerIdentity id
Identity of this neighbour.
Message used to set a particular bandwidth quota.
Definition: transport.h:176

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().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ neighbours_connect_notification()

static void neighbours_connect_notification ( struct NeighbourMapEntry n)
static

Notify our clients that another peer connected to us.

Parameters
nthe peer that connected

Definition at line 558 of file gnunet-service-transport_neighbours.c.

559 {
560  size_t len = sizeof(struct ConnectInfoMessage);
561  char buf[len] GNUNET_ALIGN;
562  struct ConnectInfoMessage *connect_msg = (struct ConnectInfoMessage *) buf;
563  struct GNUNET_BANDWIDTH_Value32NBO bandwidth_min;
564 
565 #if IGNORE_INBOUND_QUOTA
566  bandwidth_min = n->primary_address.bandwidth_out;
567 #else
570 #endif
572  "We are now connected to peer `%s'\n",
573  GNUNET_i2s (&n->id));
574  connect_msg->header.size = htons (sizeof(buf));
575  connect_msg->header.type = htons (GNUNET_MESSAGE_TYPE_TRANSPORT_CONNECT);
576  connect_msg->id = n->id;
577  connect_msg->quota_out = bandwidth_min;
578  GST_clients_broadcast (&connect_msg->header,
579  GNUNET_NO);
580 }
uint16_t len
length of data (which is always a uint32_t, but presumably this can be used to specify that fewer byt...
static char buf[2048]
#define GNUNET_ALIGN
gcc-ism to force alignment; we use this to align char-arrays that may then be cast to 'struct's.
@ GNUNET_ERROR_TYPE_INFO
#define GNUNET_MESSAGE_TYPE_TRANSPORT_CONNECT
Message from TRANSPORT notifying about a client that connected to us.
Message from the transport service to the library informing about neighbors.
Definition: transport.h:118
struct GNUNET_MessageHeader header
Type will be GNUNET_MESSAGE_TYPE_TRANSPORT_CONNECT.
Definition: transport.h:122
struct GNUNET_PeerIdentity id
Identity of the new neighbour.
Definition: transport.h:141
struct GNUNET_BANDWIDTH_Value32NBO quota_out
Current outbound quota for this peer.
Definition: transport.h:135
uint16_t type
The type of the message (GNUNET_MESSAGE_TYPE_XXXX), in big-endian format.
uint16_t size
The length of the struct (in bytes, including the length field itself), in big-endian format.

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().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ neighbours_disconnect_notification()

static void neighbours_disconnect_notification ( struct NeighbourMapEntry n)
static

Notify our clients (and manipulation) that a peer disconnected from us.

Parameters
nthe peer that disconnected

Definition at line 590 of file gnunet-service-transport_neighbours.c.

591 {
593  "Peer `%s' disconnected\n",
594  GNUNET_i2s (&n->id));
597 }
void GST_clients_broadcast_disconnect(const struct GNUNET_PeerIdentity *peer)
Notify all clients about a disconnect, and cancel pending SEND_OK messages for this peer.
void GST_manipulation_peer_disconnect(const struct GNUNET_PeerIdentity *peer)
Notify manipulation about disconnect so it can discard queued messages.

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().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ neighbours_changed_notification()

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 
)
static

Notify transport clients that a neighbour peer changed its active address.

Parameters
peeridentity of the peer
addressaddress possibly NULL if peer is not connected
statecurrent state this peer is in
state_timeouttimeout for the current state of the peer
bandwidth_inbandwidth assigned inbound, 0 on disconnect
bandwidth_outbandwidth assigned outbound, 0 on disconnect

Definition at line 612 of file gnunet-service-transport_neighbours.c.

620 {
621  (void) bandwidth_in;
622  (void) bandwidth_out;
624  "Notifying about change for peer `%s' with address `%s' in state `%s' timing out at %s\n",
625  GNUNET_i2s (peer),
629  /* FIXME: include bandwidth in notification! */
631  address,
632  state,
633  state_timeout);
634 }
static char * address
GNS address for this phone.
enum State state
current state of profiling
void GST_clients_broadcast_peer_notification(const struct GNUNET_PeerIdentity *peer, const struct GNUNET_HELLO_Address *address, enum GNUNET_TRANSPORT_PeerState state, struct GNUNET_TIME_Absolute state_timeout)
Broadcast the new active address to all clients monitoring the peer.
const char * GST_plugins_a2s(const struct GNUNET_HELLO_Address *address)
Convert a given address to a human-readable format.
const char * GNUNET_STRINGS_absolute_time_to_string(struct GNUNET_TIME_Absolute t)
Like asctime, except for GNUnet time.
Definition: strings.c:604
const char * GNUNET_TRANSPORT_ps2s(enum GNUNET_TRANSPORT_PeerState state)
Convert a transport state to a human readable string.
struct GNUNET_TESTBED_Peer * peer
The peer associated with this model.

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().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ lookup_neighbour()

static struct NeighbourMapEntry* lookup_neighbour ( const struct GNUNET_PeerIdentity pid)
static

Lookup a neighbour entry in the neighbours hash map.

Parameters
pididentity of the peer to look up
Returns
the entry, NULL if there is no existing record

Definition at line 644 of file gnunet-service-transport_neighbours.c.

645 {
646  if (NULL == neighbours)
647  return NULL;
649 }
static struct GNUNET_CONTAINER_MultiPeerMap * neighbours
Hash map from peer identities to the respective struct NeighbourMapEntry.
static struct GNUNET_PeerIdentity pid
Identity of the peer we transmit to / connect to.
void * GNUNET_CONTAINER_multipeermap_get(const struct GNUNET_CONTAINER_MultiPeerMap *map, const struct GNUNET_PeerIdentity *key)
Given a key find a value in the map matching the key.

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().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ test_connected()

static int test_connected ( struct NeighbourMapEntry n)
static

Test if we're connected to the given peer.

Parameters
nneighbour entry of peer to test
Returns
GNUNET_YES if we are connected, GNUNET_NO if not

Definition at line 659 of file gnunet-service-transport_neighbours.c.

660 {
661  if (NULL == n)
662  return GNUNET_NO;
664 }

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().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ free_address()

static void free_address ( struct NeighbourAddress na)
static

We don't need a given neighbour address any more.

Release its resources and give appropriate notifications to ATS and other subsystems.

Parameters
naaddress 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.

676 {
677  if (GNUNET_YES == na->ats_active)
679  GNUNET_NO);
680  if (NULL != na->address)
681  {
683  na->session);
685  na->address = NULL;
686  }
689  na->ats_active = GNUNET_NO;
690  na->keep_alive_nonce = 0;
691  na->session = NULL;
692 }
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.
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.
@ GNUNET_YES
Definition: gnunet_common.h:97
struct GNUNET_BANDWIDTH_Value32NBO GNUNET_BANDWIDTH_value_init(uint32_t bytes_per_second)
Create a new bandwidth value.
Definition: bandwidth.c:39
#define GNUNET_HELLO_address_free(addr)
Free an address.
struct GNUNET_BANDWIDTH_Value32NBO bandwidth_in
Inbound bandwidth from ATS for this address.
uint32_t keep_alive_nonce
The current nonce sent in the last keep alive messages.
struct GNUNET_HELLO_Address * address
Network-level address information.
struct GNUNET_ATS_Session * session
Active session for this address.
int ats_active
Did we tell ATS that this is our 'active' address?

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().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ master_task()

static void master_task ( void *  cls)
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).

Parameters
clsthe struct NeighbourMapEntry for which we are running

Performs all of the time-related activities (keep alive, send next message, disconnect if idle, finish clean up after disconnect).

Parameters
clsthe 'struct NeighbourMapEntry' for which we are running

Definition at line 3030 of file gnunet-service-transport_neighbours.c.

3031 {
3032  struct NeighbourMapEntry *n = cls;
3033  struct GNUNET_TIME_Relative delay;
3034 
3035  n->task = NULL;
3038  "Master task runs for neighbour `%s' in state %s with timeout in %s\n",
3039  GNUNET_i2s (&n->id),
3042  GNUNET_YES));
3043  switch (n->state)
3044  {
3046  /* invalid state for master task, clean up */
3047  GNUNET_break (0);
3048  free_neighbour (n);
3049  return;
3050 
3052  if (0 == delay.rel_value_us)
3053  {
3055  "Connection to `%s' timed out waiting for ATS to provide address\n",
3056  GNUNET_i2s (&n->id));
3057  free_neighbour (n);
3058  return;
3059  }
3060  break;
3061 
3063  if (0 == delay.rel_value_us)
3064  {
3066  "Connection to `%s' timed out waiting for other peer to send SYN_ACK\n",
3067  GNUNET_i2s (&n->id));
3068  /* Remove address and request and additional one */
3074  return;
3075  }
3076  break;
3077 
3079  if (0 == delay.rel_value_us)
3080  {
3082  "Connection to `%s' timed out waiting ATS to provide address to use for SYN_ACK\n",
3083  GNUNET_i2s (&n->id));
3084  free_neighbour (n);
3085  return;
3086  }
3087  break;
3088 
3090  if (0 == delay.rel_value_us)
3091  {
3093  "Connection to `%s' timed out waiting for other peer to send ACK\n",
3094  GNUNET_i2s (&n->id));
3096  return;
3097  }
3098  break;
3099 
3101  if (0 == delay.rel_value_us)
3102  {
3104  "Connection to `%s' timed out, missing KEEPALIVE_RESPONSEs\n",
3105  GNUNET_i2s (&n->id));
3107  return;
3108  }
3110  send_keepalive (n);
3111  break;
3112 
3114  if (0 == delay.rel_value_us)
3115  {
3117  "Connection to `%s' timed out, waiting for ATS replacement address\n",
3118  GNUNET_i2s (&n->id));
3120  return;
3121  }
3122  break;
3123 
3125  if (0 == delay.rel_value_us)
3126  {
3128  "Connection to `%s' timed out, waiting for other peer to SYN_ACK replacement address\n",
3129  GNUNET_i2s (&n->id));
3131  return;
3132  }
3133  break;
3134 
3136  if (0 == delay.rel_value_us)
3137  {
3139  "Switch failed, cleaning up alternative address\n");
3145  }
3147  send_keepalive (n);
3148  break;
3149 
3152  "Cleaning up connection to `%s' after sending DISCONNECT\n",
3153  GNUNET_i2s (&n->id));
3154  free_neighbour (n);
3155  return;
3156 
3158  /* how did we get here!? */
3159  GNUNET_assert (0);
3160  break;
3161 
3162  default:
3164  "Unhandled state `%s'\n",
3166  GNUNET_break (0);
3167  break;
3168  }
3172  {
3173  /* if we are *now* in one of the two states, we're sending
3174  keep alive messages, so we need to consider the keepalive
3175  delay, not just the connection timeout */
3177  n->keep_alive_time),
3178  delay);
3179  }
3180  if (NULL == n->task)
3182  &master_task,
3183  n);
3184 }
static struct GNUNET_TIME_Relative delay
When should dkg communication start?
static void master_task(void *cls)
Master task run for every neighbour.
static void unset_primary_address(struct NeighbourMapEntry *n)
Clear the primary address of a neighbour since this address is not valid anymore and notify monitorin...
#define SETUP_CONNECTION_TIMEOUT
How long are we willing to wait for an ACK from the other peer before giving up on our connect operat...
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.
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.
static void free_address(struct NeighbourAddress *na)
We don't need a given neighbour address any more.
#define ATS_RESPONSE_TIMEOUT
How long are we willing to wait for a response from ATS before timing out?
static void disconnect_neighbour(struct NeighbourMapEntry *n)
Disconnect from the given neighbour, clean up the record.
static void free_neighbour(struct NeighbourMapEntry *n)
Free a neighbour map entry.
static void send_keepalive(struct NeighbourMapEntry *n)
Send keepalive message to the neighbour.
#define GNUNET_assert(cond)
Use this for fatal errors that cannot be handled.
@ GNUNET_ERROR_TYPE_ERROR
struct GNUNET_SCHEDULER_Task * GNUNET_SCHEDULER_add_delayed(struct GNUNET_TIME_Relative delay, GNUNET_SCHEDULER_TaskCallback task, void *task_cls)
Schedule a new task to be run with a specified delay.
Definition: scheduler.c:1269
struct GNUNET_TIME_Relative GNUNET_TIME_relative_min(struct GNUNET_TIME_Relative t1, struct GNUNET_TIME_Relative t2)
Return the minimum of two relative time values.
Definition: time.c:200
struct GNUNET_TIME_Relative GNUNET_TIME_absolute_get_remaining(struct GNUNET_TIME_Absolute future)
Given a timestamp in the future, how much time remains until then?
Definition: time.c:232
struct GNUNET_TIME_Absolute GNUNET_TIME_relative_to_absolute(struct GNUNET_TIME_Relative rel)
Convert relative time to an absolute time in the future.
Definition: time.c:181
const char * GNUNET_STRINGS_relative_time_to_string(struct GNUNET_TIME_Relative delta, int do_round)
Give relative time in human-readable fancy format.
Definition: strings.c:557
@ GNUNET_TRANSPORT_PS_DISCONNECT_FINISHED
We're finished with the disconnect; and are cleaning up the state now! We put the struct into this st...
@ GNUNET_TRANSPORT_PS_NOT_CONNECTED
Fresh peer or completely disconnected.
@ GNUNET_TRANSPORT_PS_INIT_ATS
Asked to initiate connection, trying to get address from ATS.
@ GNUNET_TRANSPORT_PS_SYN_RECV_ATS
Received a SYN, asking ATS about address suggestions.
@ GNUNET_TRANSPORT_PS_SYN_RECV_ACK
SYN request from other peer was SYN_ACK'ed, waiting for ACK.
@ GNUNET_TRANSPORT_PS_RECONNECT_SENT
Sent SYN over new address (either by ATS telling us to switch addresses or from RECONNECT_ATS); if th...
@ GNUNET_TRANSPORT_PS_SWITCH_SYN_SENT
We have some primary connection, but ATS suggested we switch to some alternative; we now sent a SYN m...
@ GNUNET_TRANSPORT_PS_CONNECTED
Got our SYN_ACK/ACK, connection is up.
@ GNUNET_TRANSPORT_PS_SYN_SENT
Sent SYN message to other peer, waiting for SYN_ACK.
@ GNUNET_TRANSPORT_PS_RECONNECT_ATS
Connection got into trouble, rest of the system still believes it to be up, but we're getting a new a...
@ GNUNET_TRANSPORT_PS_DISCONNECT
Disconnect in progress (we're sending the DISCONNECT message to the other peer; after that is finishe...
Time for relative time used by GNUnet, in microseconds.
uint64_t rel_value_us
The actual value.
struct NeighbourAddress alternative_address
Alternative address currently under consideration for communicating with the neighbour.
struct GNUNET_TIME_Absolute keep_alive_time
At what time should we sent the next keep-alive message?
struct GNUNET_TIME_Absolute timeout
Time where we should cut the connection (timeout) if we don't make progress in the state machine (or ...
struct GNUNET_SCHEDULER_Task * task
Main task that drives this peer (timeouts, keepalives, etc.).

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().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ set_state_and_timeout()

static void set_state_and_timeout ( struct NeighbourMapEntry n,
enum GNUNET_TRANSPORT_PeerState  s,
struct GNUNET_TIME_Absolute  timeout 
)
static

Set net state and state timeout for this neighbour and notify monitoring.

Parameters
nthe respective neighbour
sthe new state
timeoutthe new timeout

Definition at line 714 of file gnunet-service-transport_neighbours.c.

717 {
720  {
723  gettext_noop ("# peers connected"),
725  GNUNET_NO);
726  }
727  if ((! GNUNET_TRANSPORT_is_connected (s)) &&
729  {
731  gettext_noop ("# peers connected"),
733  GNUNET_NO);
735  }
736  n->state = s;
737  if ((timeout.abs_value_us < n->timeout.abs_value_us) &&
738  (NULL != n->task))
739  {
740  /* new timeout is earlier, reschedule master task */
743  &master_task,
744  n);
745  }
746  n->timeout = timeout;
748  "Neighbour `%s' changed state to %s with timeout %s\n",
749  GNUNET_i2s (&n->id),
754  n->state,
755  n->timeout,
758 }
#define gettext_noop(String)
Definition: gettext.h:69
static struct GNUNET_TIME_Relative timeout
Desired timeout for the lookup (default is no timeout).
Definition: gnunet-abd.c:61
static struct GNUNET_STATISTICS_Handle * GST_stats
Statistics handle.
static void neighbours_connect_notification(struct NeighbourMapEntry *n)
Notify our clients that another peer connected to us.
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.
static unsigned int neighbours_connected
counter for connected neighbours
static void neighbours_disconnect_notification(struct NeighbourMapEntry *n)
Notify our clients (and manipulation) that a peer disconnected from us.
struct GNUNET_SCHEDULER_Task * GNUNET_SCHEDULER_add_at(struct GNUNET_TIME_Absolute at, GNUNET_SCHEDULER_TaskCallback task, void *task_cls)
Schedule a new task to be run at the specified time.
Definition: scheduler.c:1246
void * GNUNET_SCHEDULER_cancel(struct GNUNET_SCHEDULER_Task *task)
Cancel the task with the specified identifier.
Definition: scheduler.c:972
void GNUNET_STATISTICS_set(struct GNUNET_STATISTICS_Handle *handle, const char *name, uint64_t value, int make_persistent)
Set statistic value for the peer.
uint64_t abs_value_us
The actual value.

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().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ set_alternative_address()

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 
)
static

Initialize the alternative address of a neighbour.

Parameters
nthe neighbour
addressaddress of the other peer, NULL if other peer connected to us
sessionsession to use (or NULL, in which case an address must be setup)
bandwidth_ininbound quota to be used when connection is up
bandwidth_outoutbound quota to be used when connection is up

Definition at line 773 of file gnunet-service-transport_neighbours.c.

778 {
780 
781  if (NULL == (papi = GST_plugins_find (address->transport_name)))
782  {
783  GNUNET_break (0);
784  return;
785  }
786  if (session == n->alternative_address.session)
787  {
788  n->alternative_address.bandwidth_in = bandwidth_in;
789  n->alternative_address.bandwidth_out = bandwidth_out;
790  return;
791  }
792  if (NULL != n->alternative_address.address)
793  {
795  "Replacing existing alternative address with another one\n");
797  }
798  if (NULL == session)
799  session = papi->get_session (papi->cls,
800  address);
801  if (NULL == session)
802  {
804  "Failed to obtain new session for peer `%s' and address '%s'\n",
805  GNUNET_i2s (&address->peer),
808  gettext_noop ("# session creation failed"),
809  1,
810  GNUNET_NO);
811  return;
812  }
814  session);
816  "Neighbour `%s' configured alternative address %s\n",
817  GNUNET_i2s (&n->id),
819 
821  n->alternative_address.bandwidth_in = bandwidth_in;
822  n->alternative_address.bandwidth_out = bandwidth_out;
823  n->alternative_address.session = session;
829 }
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.
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.
struct GNUNET_TRANSPORT_PluginFunctions * GST_plugins_find(const char *name)
Obtain the plugin API based on a plugin name.
struct GNUNET_HELLO_Address * GNUNET_HELLO_address_copy(const struct GNUNET_HELLO_Address *address)
Copy an address struct.
Definition: address.c:109
void GNUNET_STATISTICS_update(struct GNUNET_STATISTICS_Handle *handle, const char *name, int64_t delta, int make_persistent)
Set statistic value for the peer.
Each plugin is required to return a pointer to a struct of this type as the return value from its ent...
void * cls
Closure for all of the callbacks.
GNUNET_TRANSPORT_CreateSession get_session
Function that will be called tell the plugin to create a session object.

Referenced by switch_address_bl_check_cont().

Here is the caller graph for this function:

◆ send_with_session()

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 
)
static

Transmit a message using the current session of the given neighbour.

Parameters
nentry for the recipient
msgbufbuffer to transmit
msgbuf_sizenumber of bytes in msgbuf buffer
prioritytransmission priority
timeouttransmission timeout
use_keepalive_timeoutGNUNET_YES to use plugin-specific keep-alive timeout (timeout is ignored in that case), GNUNET_NO otherwise
contcontinuation to call when finished (can be NULL)
cont_clsclosure for cont
Returns
timeout (copy of timeout or a calculated one if use_keepalive_timeout is GNUNET_YES.

Definition at line 773 of file gnunet-service-transport_neighbours.c.

857 {
860 
862  if ((((NULL == (papi = GST_plugins_find (
864  (-1 == papi->send (papi->cls,
866  msgbuf,
867  msgbuf_size,
868  priority,
869  (result = (GNUNET_NO == use_keepalive_timeout) ?
870  timeout :
873  papi->
874  query_keepalive_factor (papi->cls))),
875  cont,
876  cont_cls)))) &&
877  (NULL != cont))
878  cont (cont_cls,
879  &n->id,
881  msgbuf_size,
882  0);
885  msgbuf_size);
886  GNUNET_break (NULL != papi);
887  return result;
888 }
static int result
Global testing status.
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 a...
@ GNUNET_SYSERR
Definition: gnunet_common.h:93
#define GNUNET_CONSTANTS_IDLE_CONNECTION_TIMEOUT
After how long do we consider a connection to a peer dead if we don't receive messages from the peer?
#define GNUNET_TIME_UNIT_FOREVER_REL
Constant used to specify "forever".
struct GNUNET_TIME_Relative GNUNET_TIME_relative_divide(struct GNUNET_TIME_Relative rel, unsigned long long factor)
Divide relative time by a given factor.
Definition: time.c:376
const char * transport_name
Name of the transport plugin enabling the communication using this address.
GNUNET_TRANSPORT_TransmitFunction send
Function that the transport service will use to transmit data to another peer.

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().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ unset_primary_address()

static void unset_primary_address ( struct NeighbourMapEntry n)
static

Clear the primary address of a neighbour since this address is not valid anymore and notify monitoring about it.

Parameters
nthe neighbour

Definition at line 898 of file gnunet-service-transport_neighbours.c.

899 {
900  /* Notify monitoring about change */
901  if (NULL == n->primary_address.address)
902  return;
904  "Disabling primary address\n");
907  n->state,
908  n->timeout,
912 }

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().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ free_neighbour()

static void free_neighbour ( struct NeighbourMapEntry n)
static

Free a neighbour map entry.

Parameters
nentry to free

Definition at line 921 of file gnunet-service-transport_neighbours.c.

922 {
923  struct MessageQueue *mq;
924 
926  "Freeing neighbour state of peer `%s'\n",
927  GNUNET_i2s (&n->id));
928  n->is_active = NULL; /* always free'd by its own continuation! */
929 
930  /* fail messages currently in the queue */
931  while (NULL != (mq = n->messages_head))
932  {
934  n->messages_tail,
935  mq);
936  if (NULL != mq->cont)
937  mq->cont (mq->cont_cls,
939  mq->message_buf_size,
940  0);
941  GNUNET_free (mq);
942  }
943  /* Mark peer as disconnected */
947  /* free addresses and mark as unused */
949 
950  if (NULL != n->alternative_address.address)
951  {
953  "Cleaning up alternative address\n");
955  }
958  &n->id,
959  n));
960 
961  /* Cancel address requests for this peer */
962  if (NULL != n->suggest_handle)
963  {
965  n->suggest_handle = NULL;
966  }
967 
968  /* Cancel the disconnect task */
969  if (NULL != n->delayed_disconnect_task)
970  {
972  n->delayed_disconnect_task = NULL;
973  }
974 
975  /* Cancel the master task */
976  if (NULL != n->task)
977  {
979  n->task = NULL;
980  }
981  /* free rest of memory */
982  GNUNET_free (n);
983 }
struct GNUNET_MQ_Handle * mq
Definition: 003.c:5
void GNUNET_ATS_connectivity_suggest_cancel(struct GNUNET_ATS_ConnectivitySuggestHandle *sh)
We no longer care about being connected to a peer.
#define GNUNET_CONTAINER_DLL_remove(head, tail, element)
Remove an element from a DLL.
int GNUNET_CONTAINER_multipeermap_remove(struct GNUNET_CONTAINER_MultiPeerMap *map, const struct GNUNET_PeerIdentity *key, const void *value)
Remove the given key-value pair from the map.
#define GNUNET_free(ptr)
Wrapper around free.
#define GNUNET_TIME_UNIT_FOREVER_ABS
Constant used to specify "forever".
For each neighbour we keep a list of messages that we still want to transmit to the neighbour.
struct MessageQueue * messages_head
Head of list of messages we would like to send to this peer; must contain at most one message per cli...
struct GNUNET_ATS_ConnectivitySuggestHandle * suggest_handle
ATS address suggest handle.
struct MessageQueue * is_active
Are we currently trying to send a message? If so, which one?
struct MessageQueue * messages_tail
Tail of list of messages we would like to send to this peer; must contain at most one message per cli...
struct GNUNET_SCHEDULER_Task * delayed_disconnect_task
Task to disconnect neighbour after we received a DISCONNECT message.

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().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ send_disconnect_cont()

static void send_disconnect_cont ( void *  cls,
const struct GNUNET_PeerIdentity target,
int  result,
size_t  payload,
size_t  physical 
)
static

Function called when the 'DISCONNECT' message has been sent by the plugin.

Frees the neighbour — if the entry still exists.

Parameters
clsNULL
targetidentity of the neighbour that was disconnected
resultGNUNET_OK if the disconnect got out successfully
payloadbytes payload
physicalbytes on wire

Definition at line 997 of file gnunet-service-transport_neighbours.c.

1002 {
1003  struct NeighbourMapEntry *n;
1004 
1005  (void) cls;
1006  (void) result;
1007  (void) payload;
1008  (void) physical;
1009  n = lookup_neighbour (target);
1010  if (NULL == n)
1011  return; /* already gone */
1013  return; /* have created a fresh entry since */
1014  if (NULL != n->task)
1017 }
static unsigned long long payload
How much data are we currently storing in the database?
static struct NeighbourMapEntry * lookup_neighbour(const struct GNUNET_PeerIdentity *pid)
Lookup a neighbour entry in the neighbours hash map.
struct GNUNET_SCHEDULER_Task * GNUNET_SCHEDULER_add_now(GNUNET_SCHEDULER_TaskCallback task, void *task_cls)
Schedule a new task to be run as soon as possible.
Definition: scheduler.c:1296

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().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ send_disconnect()

static void send_disconnect ( struct NeighbourMapEntry n)
static

Transmit a DISCONNECT message to the other peer.

Parameters
nneighbour to send DISCONNECT message.

Definition at line 1026 of file gnunet-service-transport_neighbours.c.

1027 {
1028  struct GNUNET_ATS_SessionDisconnectMessage disconnect_msg;
1029 
1031  "Sending DISCONNECT message to peer `%4s'\n",
1032  GNUNET_i2s (&n->id));
1033  disconnect_msg.header.size = htons (sizeof(struct
1035  disconnect_msg.header.type =
1037  disconnect_msg.reserved = htonl (0);
1038  disconnect_msg.purpose.size =
1039  htonl (sizeof(struct GNUNET_CRYPTO_EccSignaturePurpose)
1040  + sizeof(struct GNUNET_CRYPTO_EddsaPublicKey)
1041  + sizeof(struct GNUNET_TIME_AbsoluteNBO));
1042  disconnect_msg.purpose.purpose =
1044  disconnect_msg.timestamp =
1046  disconnect_msg.public_key = GST_my_identity.public_key;
1049  &disconnect_msg.purpose,
1050  &disconnect_msg.signature));
1051 
1052  (void) send_with_session (n,
1053  &disconnect_msg,
1054  sizeof(disconnect_msg),
1055  UINT32_MAX,
1057  GNUNET_NO,
1059  NULL);
1061  gettext_noop ("# DISCONNECT messages sent"),
1062  1,
1063  GNUNET_NO);
1064 }
static struct GNUNET_PeerIdentity GST_my_identity
Our public key.
static struct GNUNET_CRYPTO_EddsaPrivateKey * GST_my_private_key
Our private key.
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.
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.
@ GNUNET_OK
Definition: gnunet_common.h:95
enum GNUNET_GenericReturnValue GNUNET_CRYPTO_eddsa_sign_(const struct GNUNET_CRYPTO_EddsaPrivateKey *priv, const struct GNUNET_CRYPTO_EccSignaturePurpose *purpose, struct GNUNET_CRYPTO_EddsaSignature *sig)
EdDSA sign a given block.
Definition: crypto_ecc.c:599
#define GNUNET_MESSAGE_TYPE_TRANSPORT_SESSION_DISCONNECT
Transport DISCONNECT message exchanged between transport services to indicate that a connection shoul...
struct GNUNET_TIME_Absolute GNUNET_TIME_absolute_get(void)
Get the current time.
Definition: time.c:86
struct GNUNET_TIME_AbsoluteNBO GNUNET_TIME_absolute_hton(struct GNUNET_TIME_Absolute a)
Convert absolute time to network byte order.
Definition: time.c:464
Message we send to the other peer to notify it that we intentionally are disconnecting (to reduce tim...
header of what an ECC signature signs this must be followed by "size - 8" bytes of the actual signed ...
Public ECC key (always for curve Ed25519) encoded in a format suitable for network transmission and E...
struct GNUNET_CRYPTO_EddsaPublicKey public_key
Time for absolute time used by GNUnet, in microseconds and in network byte order.

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().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ disconnect_neighbour()

static void disconnect_neighbour ( struct NeighbourMapEntry n)
static

Disconnect from the given neighbour, clean up the record.

Parameters
nneighbour to disconnect from

Definition at line 1073 of file gnunet-service-transport_neighbours.c.

1074 {
1076  "Disconnecting from peer %s in state %s\n",
1077  GNUNET_i2s (&n->id),
1079  /* depending on state, notify neighbour and/or upper layers of this peer
1080  about disconnect */
1081  switch (n->state)
1082  {
1085  /* other peer is completely unaware of us, no need to send DISCONNECT */
1086  free_neighbour (n);
1087  return;
1088 
1090  send_disconnect (n);
1094  break;
1095 
1097  /* we never ACK'ed the other peer's request, no need to send DISCONNECT */
1098  free_neighbour (n);
1099  return;
1100 
1102  /* we DID ACK the other peer's request, must send DISCONNECT */
1103  send_disconnect (n);
1107  break;
1108 
1112  /* we are currently connected, need to send disconnect and do
1113  internal notifications and update statistics */
1114  send_disconnect (n);
1118  break;
1119 
1121  /* Disconnecting while waiting for an ATS address to reconnect,
1122  * cannot send DISCONNECT */
1123  free_neighbour (n);
1124  return;
1125 
1127  /* already disconnected, ignore */
1128  break;
1129 
1131  /* already cleaned up, how did we get here!? */
1132  GNUNET_assert (0);
1133  break;
1134 
1135  default:
1137  "Unhandled state `%s'\n",
1139  GNUNET_break (0);
1140  break;
1141  }
1142  /* schedule timeout to clean up */
1143  if (NULL != n->task)
1146  &master_task,
1147  n);
1148 }
static void send_disconnect(struct NeighbourMapEntry *n)
Transmit a DISCONNECT message to the other peer.
#define DISCONNECT_SENT_TIMEOUT
Time we give plugin to transmit DISCONNECT message before the neighbour entry self-destructs.

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().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ set_incoming_quota()

static int set_incoming_quota ( struct NeighbourMapEntry n,
struct GNUNET_BANDWIDTH_Value32NBO  quota 
)
static

Change the incoming quota for the given peer.

Updates our own receive rate and informs the neighbour about the new quota.

Parameters
nneighbour entry to change quota for
quotanew quota
Returns
GNUNET_YES if n is still valid, GNUNET_NO if n was freed

Definition at line 1162 of file gnunet-service-transport_neighbours.c.

1164 {
1166  "Setting inbound quota of %u Bps for peer `%s' to all clients\n",
1167  ntohl (quota.value__), GNUNET_i2s (&n->id));
1169  quota);
1170  if (0 != ntohl (quota.value__))
1171  {
1172  struct GNUNET_ATS_SessionQuotaMessage sqm;
1173 
1174  sqm.header.size = htons (sizeof(struct GNUNET_ATS_SessionQuotaMessage));
1175  sqm.header.type = htons (GNUNET_MESSAGE_TYPE_TRANSPORT_SESSION_QUOTA);
1176  sqm.quota = quota.value__;
1177  if (NULL != n->primary_address.session)
1178  (void) send_with_session (n,
1179  &sqm,
1180  sizeof(sqm),
1181  UINT32_MAX - 1,
1183  GNUNET_NO,
1184  NULL, NULL);
1185  return GNUNET_YES;
1186  }
1188  "Disconnecting peer `%s' due to SET_QUOTA\n",
1189  GNUNET_i2s (&n->id));
1190  if (GNUNET_YES == test_connected (n))
1192  gettext_noop ("# disconnects due to quota of 0"),
1193  1, GNUNET_NO);
1195  return GNUNET_NO;
1196 }
static unsigned long long quota
How much space are we allowed to use?
static int test_connected(struct NeighbourMapEntry *n)
Test if we're connected to the given peer.
void GNUNET_BANDWIDTH_tracker_update_quota(struct GNUNET_BANDWIDTH_Tracker *av, struct GNUNET_BANDWIDTH_Value32NBO bytes_per_second_limit)
Update quota of bandwidth tracker.
Definition: bandwidth.c:526
#define GNUNET_MESSAGE_TYPE_TRANSPORT_SESSION_QUOTA
Message exchanged between transport services to indicate that the sender should limit its transmissio...
Message a peer sends to another when connected to indicate that the other peer should limit transmiss...
struct GNUNET_MessageHeader header
Header of type GNUNET_MESSAGE_TYPE_TRANSPORT_SESSION_QUOTA.
struct GNUNET_BANDWIDTH_Tracker in_tracker
Tracker for inbound bandwidth.

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().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ set_primary_address()

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 
)
static

Initialize the primary address of a neighbour.

Parameters
nthe neighbour
addressaddress of the other peer, NULL if other peer connected to us
sessionsession to use (or NULL, in which case an address must be setup)
bandwidth_ininbound quota to be used when connection is up
bandwidth_outoutbound quota to be used when connection is up

Definition at line 1211 of file gnunet-service-transport_neighbours.c.

1216 {
1217  if (session == n->primary_address.session)
1218  {
1220  GNUNET_YES);
1221  if (n->primary_address.bandwidth_in.value__ != bandwidth_in.value__)
1222  {
1223  n->primary_address.bandwidth_in = bandwidth_in;
1224  if (GNUNET_YES !=
1225  set_incoming_quota (n,
1226  bandwidth_in))
1227  return;
1228  }
1229  if (n->primary_address.bandwidth_out.value__ != bandwidth_out.value__)
1230  {
1231  n->primary_address.bandwidth_out = bandwidth_out;
1233  }
1234  return;
1235  }
1236  if ((NULL != n->primary_address.address) &&
1238  n->primary_address.address)))
1239  {
1240  GNUNET_break (0);
1241  return;
1242  }
1243  if (NULL == session)
1244  {
1245  GNUNET_break (0);
1247  session);
1248  return;
1249  }
1250  if (NULL != n->primary_address.address)
1251  {
1253  "Replacing existing primary address with another one\n");
1255  }
1257  n->primary_address.bandwidth_in = bandwidth_in;
1258  n->primary_address.bandwidth_out = bandwidth_out;
1259  n->primary_address.session = session;
1263  n->primary_address.session));
1264  /* subsystems about address use */
1266  GNUNET_YES);
1267  if (GNUNET_YES !=
1268  set_incoming_quota (n,
1269  bandwidth_in))
1270  return;
1273  "Neighbour `%s' switched to address `%s'\n",
1274  GNUNET_i2s (&n->id),
1276 
1279  n->state,
1280  n->timeout,
1283 }
static void send_outbound_quota_to_clients(struct NeighbourMapEntry *n)
Send information about a new outbound quota to our clients.
static int set_incoming_quota(struct NeighbourMapEntry *n, struct GNUNET_BANDWIDTH_Value32NBO quota)
Change the incoming quota for the given peer.
int GNUNET_HELLO_address_cmp(const struct GNUNET_HELLO_Address *a1, const struct GNUNET_HELLO_Address *a2)
Compare two addresses.
Definition: address.c:130
uint32_t value__
The actual value (bytes per second).

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().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ transmit_send_continuation()

static void transmit_send_continuation ( void *  cls,
const struct GNUNET_PeerIdentity receiver,
int  success,
size_t  size_payload,
size_t  physical 
)
static

We're done with our transmission attempt, continue processing.

Parameters
clsthe struct MessageQueue of the message
receiverintended receiver
successwhether it worked or not
size_payloadbytes payload sent
physicalbytes sent on wire

Definition at line 1296 of file gnunet-service-transport_neighbours.c.

1301 {
1302  struct MessageQueue *mq = cls;
1303  struct NeighbourMapEntry *n;
1304 
1305  if (NULL == (n = lookup_neighbour (receiver)))
1306  {
1307  if (NULL != mq->cont)
1308  mq->cont (mq->cont_cls,
1309  GNUNET_SYSERR /* not connected */,
1310  size_payload,
1311  0);
1312  GNUNET_free (mq);
1313  return; /* disconnect or other error while transmitting, can happen */
1314  }
1315  if (n->is_active == mq)
1316  {
1317  /* this is still "our" neighbour, remove us from its queue
1318  and allow it to send the next message now */
1319  n->is_active = NULL;
1320  if (NULL != n->task)
1323  n);
1324  }
1325  if (bytes_in_send_queue < mq->message_buf_size)
1326  {
1328  "Bytes_in_send_queue `%llu', Message_size %u, result: %s, payload %u, on wire %u\n",
1330  (unsigned int) mq->message_buf_size,
1331  (GNUNET_OK == success) ? "OK" : "FAIL",
1332  (unsigned int) size_payload,
1333  (unsigned int) physical);
1334  GNUNET_break (0);
1335  }
1336 
1337  GNUNET_break (size_payload == mq->message_buf_size);
1338  bytes_in_send_queue -= mq->message_buf_size;
1340  gettext_noop (
1341  "# bytes in message queue for other peers"),
1343  GNUNET_NO);
1344  if (GNUNET_OK == success)
1346  gettext_noop (
1347  "# messages transmitted to other peers"),
1348  1,
1349  GNUNET_NO);
1350  else
1352  gettext_noop
1353  (
1354  "# transmission failures for messages to other peers"),
1355  1, GNUNET_NO);
1357  "Sending message to `%s' of type %u with %u bytes was a %s\n",
1358  GNUNET_i2s (receiver),
1359  ntohs (((struct GNUNET_MessageHeader *) mq->message_buf)->type),
1360  (unsigned int) mq->message_buf_size,
1361  (success == GNUNET_OK) ? "success" : "FAILURE");
1362  if (NULL != mq->cont)
1363  mq->cont (mq->cont_cls,
1364  success,
1365  size_payload,
1366  physical);
1367  GNUNET_free (mq);
1368 }
static unsigned long long bytes_in_send_queue
Number of bytes we have currently queued for transmission.
void receiver(void *cls, const void *buf, size_t available, const struct sockaddr *addr, socklen_t addrlen, int errCode)
Callback to read from the SOCKS5 proxy.
Definition: socks.c:329
Header for all communications.

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().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ try_transmission_to_peer()

static void try_transmission_to_peer ( struct NeighbourMapEntry n)
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.

Parameters
ntarget peer for which to transmit

Definition at line 1383 of file gnunet-service-transport_neighbours.c.

1384 {
1385  struct MessageQueue *mq;
1387 
1388  if (NULL == n->primary_address.address)
1389  {
1390  /* no address, why are we here? */
1391  GNUNET_break (0);
1392  return;
1393  }
1394  if ((0 == n->primary_address.address->address_length) &&
1395  (NULL == n->primary_address.session))
1396  {
1397  /* no address, why are we here? */
1398  GNUNET_break (0);
1399  return;
1400  }
1401  if (NULL != n->is_active)
1402  {
1403  /* transmission already pending */
1404  return;
1405  }
1406 
1407  /* timeout messages from the queue that are past their due date */
1408  while (NULL != (mq = n->messages_head))
1409  {
1411  if (timeout.rel_value_us > 0)
1412  break;
1414  gettext_noop (
1415  "# messages timed out while in transport queue"),
1416  1,
1417  GNUNET_NO);
1419  n->messages_tail,
1420  mq);
1421  n->is_active = mq;
1423  &n->id,
1424  GNUNET_SYSERR,
1425  mq->message_buf_size,
1426  0); /* timeout */
1427  }
1428  if (NULL == mq)
1429  return; /* no more messages */
1430  if (NULL == n->primary_address.address)
1431  {
1432  /* transmit_send_continuation() caused us to drop session,
1433  can't try transmission anymore. */
1434  return;
1435  }
1436 
1437 
1439  n->messages_tail,
1440  mq);
1441  n->is_active = mq;
1442 
1444  "Giving message with %u bytes to plugin session %p\n",
1445  (unsigned int) mq->message_buf_size,
1447  (void) send_with_session (n,
1448  mq->message_buf,
1449  mq->message_buf_size,
1450  0 /* priority */,
1451  timeout,
1452  GNUNET_NO,
1454  mq);
1455 }
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.
size_t address_length
Number of bytes in address.

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().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ send_keepalive()

static void send_keepalive ( struct NeighbourMapEntry n)
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).

Parameters
nneighbour that went idle and needs a keepalive

Definition at line 1467 of file gnunet-service-transport_neighbours.c.

1468 {
1471  uint32_t nonce;
1472 
1476  return; /* no keepalive needed at this time */
1477 
1478  nonce = 0; /* 0 indicates 'not set' */
1479  while (0 == nonce)
1481  UINT32_MAX);
1482 
1484  "Sending KEEPALIVE to peer `%s' with nonce %u\n",
1485  GNUNET_i2s (&n->id),
1486  nonce);
1487  m.header.size = htons (sizeof(struct GNUNET_ATS_SessionKeepAliveMessage));
1488  m.header.type = htons (GNUNET_MESSAGE_TYPE_TRANSPORT_SESSION_KEEPALIVE);
1489  m.nonce = htonl (nonce);
1490 
1492  &m,
1493  sizeof(m),
1494  UINT32_MAX /* priority */,
1496  GNUNET_YES,
1497  NULL, NULL);
1499  gettext_noop ("# KEEPALIVES sent"),
1500  1,
1501  GNUNET_NO);
1502  n->primary_address.keep_alive_nonce = nonce;
1506 }
static struct GNUNET_ARM_MonitorHandle * m
Monitor connection with ARM.
Definition: gnunet-arm.c:104
uint32_t GNUNET_CRYPTO_random_u32(enum GNUNET_CRYPTO_Quality mode, uint32_t i)
Produce a random value.
@ GNUNET_CRYPTO_QUALITY_NONCE
Randomness for IVs etc.
#define GNUNET_MESSAGE_TYPE_TRANSPORT_SESSION_KEEPALIVE
Message send by a peer to notify the other to keep the session alive and measure latency in a regular...
Message a peer sends to another when connected to indicate that a session is in use and the peer is s...
int expect_latency_response
Did we sent an KEEP_ALIVE message and are we expecting a response?
struct GNUNET_TIME_Absolute last_keep_alive_time
At what time did we sent the last keep-alive message? Used to calculate round-trip time ("latency").

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().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ GST_neighbours_keepalive()

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.

Parameters
neighbourneighbour to keep alive (by sending keep alive response)
mthe keep alive message containing the nonce to respond to

Definition at line 1517 of file gnunet-service-transport_neighbours.c.

1519 {
1520  struct NeighbourMapEntry *n;
1521  const struct GNUNET_ATS_SessionKeepAliveMessage *msg_in;
1523 
1524  if (sizeof(struct GNUNET_ATS_SessionKeepAliveMessage) != ntohs (m->size))
1525  {
1526  GNUNET_break_op (0);
1527  return;
1528  }
1529 
1530  msg_in = (const struct GNUNET_ATS_SessionKeepAliveMessage *) m;
1531  if (NULL == (n = lookup_neighbour (neighbour)))
1532  {
1534  gettext_noop
1535  ("# KEEPALIVE messages discarded (peer unknown)"),
1536  1, GNUNET_NO);
1537  return;
1538  }
1539  if (NULL == n->primary_address.session)
1540  {
1542  gettext_noop
1543  ("# KEEPALIVE messages discarded (no session)"),
1544  1, GNUNET_NO);
1545  return;
1546  }
1547 
1549  "Received KEEPALIVE request from peer `%s' with nonce %u\n",
1550  GNUNET_i2s (&n->id),
1551  ntohl (msg_in->nonce));
1553  gettext_noop (
1554  "# KEEPALIVES received in good order"),
1555  1,
1556  GNUNET_NO);
1557 
1558  /* send reply to allow neighbour to measure latency */
1559  msg.header.size = htons (sizeof(struct GNUNET_ATS_SessionKeepAliveMessage));
1560  msg.header.type = htons (
1562  msg.nonce = msg_in->nonce;
1563  (void) send_with_session (n,
1564  &msg,
1565  sizeof(struct GNUNET_ATS_SessionKeepAliveMessage),
1566  UINT32_MAX /* priority */,
1568  GNUNET_YES,
1569  NULL, NULL);
1570 }
struct GNUNET_MessageHeader * msg
Definition: 005.c:2
#define GNUNET_break_op(cond)
Use this for assertion violations caused by other peers (i.e.
#define GNUNET_MESSAGE_TYPE_TRANSPORT_SESSION_KEEPALIVE_RESPONSE
Response to a GNUNET_MESSAGE_TYPE_TRANSPORT_SESSION_KEEPALIVE message to measure latency in a regular...
uint32_t nonce
A nonce to identify the session the keep alive is used for.

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.

Here is the call graph for this function:

◆ GST_neighbours_keepalive_response()

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.

Parameters
neighbourneighbour to keep alive
mthe message containing the keep alive response

Definition at line 1582 of file gnunet-service-transport_neighbours.c.

1584 {
1585  struct NeighbourMapEntry *n;
1587  struct GNUNET_TRANSPORT_PluginFunctions *papi;
1588  struct GNUNET_TIME_Relative latency;
1589 
1590  if (sizeof(struct GNUNET_ATS_SessionKeepAliveMessage) != ntohs (m->size))
1591  {
1592  GNUNET_break_op (0);
1593  return;
1594  }
1595 
1596  msg = (const struct GNUNET_ATS_SessionKeepAliveMessage *) m;
1597  if (NULL == (n = lookup_neighbour (neighbour)))
1598  {
1600  gettext_noop (
1601  "# KEEPALIVE_RESPONSEs discarded (not connected)"),
1602  1,
1603  GNUNET_NO);
1604  return;
1605  }
1606  if ((GNUNET_TRANSPORT_PS_CONNECTED != n->state) ||
1608  {
1610  gettext_noop (
1611  "# KEEPALIVE_RESPONSEs discarded (not expected)"),
1612  1,
1613  GNUNET_NO);
1614  return;
1615  }
1616  if (NULL == n->primary_address.address)
1617  {
1619  gettext_noop (
1620  "# KEEPALIVE_RESPONSEs discarded (address changed)"),
1621  1,
1622  GNUNET_NO);
1623  return;
1624  }
1625  if (n->primary_address.keep_alive_nonce != ntohl (msg->nonce))
1626  {
1627  if (0 == n->primary_address.keep_alive_nonce)
1629  gettext_noop (
1630  "# KEEPALIVE_RESPONSEs discarded (no nonce)"),
1631  1,
1632  GNUNET_NO);
1633  else
1635  gettext_noop (
1636  "# KEEPALIVE_RESPONSEs discarded (bad nonce)"),
1637  1,
1638  GNUNET_NO);
1639  return;
1640  }
1642  gettext_noop (
1643  "# KEEPALIVE_RESPONSEs received (OK)"),
1644  1,
1645  GNUNET_NO);
1646 
1647 
1648  /* Update session timeout here */
1649  if (NULL != (papi = GST_plugins_find (
1651  {
1653  "Updating session for peer `%s' for session %p\n",
1654  GNUNET_i2s (&n->id),
1656  papi->update_session_timeout (papi->cls,
1657  &n->id,
1659  }
1660  else
1661  {
1662  GNUNET_break (0);
1663  }
1664 
1668  n->state,
1671 
1674  "Received KEEPALIVE_RESPONSE from peer `%s', latency is %s\n",
1675  GNUNET_i2s (&n->id),
1677  GNUNET_YES));
1679  GNUNET_TIME_relative_divide (latency,
1680  2));
1681 }
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.
struct GNUNET_TIME_Relative GNUNET_TIME_absolute_get_duration(struct GNUNET_TIME_Absolute whence)
Get the duration of an operation as the difference of the current time and the given start time "henc...
Definition: time.c:263
GNUNET_TRANSPORT_UpdateSessionTimeout update_session_timeout
Function that will be called whenever the transport service wants to notify the plugin that a session...

◆ GST_neighbours_calculate_receive_delay()

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).

Parameters
sendersender of the message
sizesize of the message
do_forwardset 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
Returns
how long to wait before reading more from this sender

Definition at line 1582 of file gnunet-service-transport_neighbours.c.

1701 {
1702  struct NeighbourMapEntry *n;
1703  struct GNUNET_TIME_Relative ret;
1704 
1705  if (NULL == neighbours)
1706  {
1707  *do_forward = GNUNET_NO;
1708  return GNUNET_TIME_UNIT_FOREVER_REL; /* This can happen during shutdown */
1709  }
1710  if (NULL == (n = lookup_neighbour (sender)))
1711  {
1713  gettext_noop (
1714  "# messages discarded due to lack of neighbour record"),
1715  1,
1716  GNUNET_NO);
1717  *do_forward = GNUNET_NO;
1718  return GNUNET_TIME_UNIT_ZERO;
1719  }
1720  if (! test_connected (n))
1721  {
1722  *do_forward = GNUNET_SYSERR;
1723  return GNUNET_TIME_UNIT_ZERO;
1724  }
1726  {
1727  n->quota_violation_count++;
1729  "Bandwidth quota (%u b/s) violation detected (total of %u).\n",
1732  /* Discount 32k per violation */
1733  GNUNET_BANDWIDTH_tracker_consume (&n->in_tracker, -32 * 1024);
1734  }
1735  else
1736  {
1737  if (n->quota_violation_count > 0)
1738  {
1739  /* try to add 32k back */
1741  n->quota_violation_count--;
1742  }
1743  }
1745  {
1747  gettext_noop
1748  ("# bandwidth quota violations by other peers"),
1749  1, GNUNET_NO);
1750  *do_forward = GNUNET_NO;
1752  }
1753  *do_forward = GNUNET_YES;
1755  if (ret.rel_value_us > 0)
1756  {
1758  "Throttling read (%lld bytes excess at %u b/s), waiting %s before reading more.\n",
1760  (unsigned int) n->in_tracker.available_bytes_per_s__,
1763  gettext_noop ("# ms throttling suggested"),
1764  (int64_t) ret.rel_value_us / 1000LL,
1765  GNUNET_NO);
1766  }
1767  return ret;
1768 }
static int ret
Return value of the commandline.
Definition: gnunet-abd.c:81
#define QUOTA_VIOLATION_DROP_THRESHOLD
How often must a peer violate bandwidth quotas before we start to simply drop its messages?
int GNUNET_BANDWIDTH_tracker_consume(struct GNUNET_BANDWIDTH_Tracker *av, ssize_t size)
Notify the tracker that a certain number of bytes of bandwidth have been consumed.
Definition: bandwidth.c:402
struct GNUNET_TIME_Relative GNUNET_BANDWIDTH_tracker_get_delay(struct GNUNET_BANDWIDTH_Tracker *av, size_t size)
Compute how long we should wait until consuming size bytes of bandwidth in order to stay within the g...
Definition: bandwidth.c:458
#define GNUNET_CONSTANTS_QUOTA_VIOLATION_TIMEOUT
How long do we delay reading more from a peer after a quota violation?
#define GNUNET_TIME_UNIT_ZERO
Relative time zero.
static unsigned int size
Size of the "table".
Definition: peer.c:67
int64_t consumption_since_last_update__
Number of bytes consumed since we last updated the tracker.
uint32_t available_bytes_per_s__
Bandwidth limit to enforce in bytes per second.
unsigned int quota_violation_count
How often has the other peer (recently) violated the inbound traffic limit? Incremented by 10 per vio...

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().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ GST_neighbours_send()

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.

Parameters
targetdestination
msgmessage to send
msg_sizenumber of bytes in msg
timeoutwhen to fail with timeout
contfunction to call when done
cont_clsclosure for cont

Definition at line 1782 of file gnunet-service-transport_neighbours.c.

1788 {
1789  struct NeighbourMapEntry *n;
1790  struct MessageQueue *mq;
1791 
1792  /* All ove these cases should never happen; they are all API violations.
1793  But we check anyway, just to be sure. */
1794  if (NULL == (n = lookup_neighbour (target)))
1795  {
1796  GNUNET_break (0);
1797  if (NULL != cont)
1798  cont (cont_cls,
1799  GNUNET_SYSERR,
1800  msg_size,
1801  0);
1802  return;
1803  }
1804  if (GNUNET_YES != test_connected (n))
1805  {
1806  GNUNET_break (0);
1807  if (NULL != cont)
1808  cont (cont_cls,
1809  GNUNET_SYSERR,
1810  msg_size,
1811  0);
1812  return;
1813  }
1814  bytes_in_send_queue += msg_size;
1816  gettext_noop
1817  ("# bytes in message queue for other peers"),
1819  mq = GNUNET_malloc (sizeof(struct MessageQueue) + msg_size);
1820  mq->cont = cont;
1821  mq->cont_cls = cont_cls;
1822  GNUNET_memcpy (&mq[1], msg, msg_size);
1823  mq->message_buf = (const char *) &mq[1];
1824  mq->message_buf_size = msg_size;
1826 
1828  "Enqueueing %u bytes to send to peer %s\n",
1829  (unsigned int) msg_size,
1830  GNUNET_i2s (target));
1832  n->messages_tail,
1833  mq);
1834  if (NULL != n->task)
1837 }
#define GNUNET_memcpy(dst, src, n)
Call memcpy() but check for n being 0 first.
#define GNUNET_CONTAINER_DLL_insert_tail(head, tail, element)
Insert an element at the tail of a DLL.
#define GNUNET_malloc(size)
Wrapper around malloc.
void * cont_cls
Closure for cont.
GST_NeighbourSendContinuation cont
Function to call once we're done.

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().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ send_session_syn_cont()

static void send_session_syn_cont ( void *  cls,
const struct GNUNET_PeerIdentity target,
int  result,
size_t  size_payload,
size_t  size_on_wire 
)
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.

Parameters
clsNULL
targetwhich peer received the transmission
resultGNUNET_OK if sending worked
size_payloadhow many bytes of payload were sent (ignored)
size_on_wirehow much bandwidth was consumed on the wire (ignored)

Definition at line 1853 of file gnunet-service-transport_neighbours.c.

1858 {
1859  struct NeighbourMapEntry *n;
1860 
1861  (void) cls;
1862  (void) size_payload;
1863  (void) size_on_wire;
1864  n = lookup_neighbour (target);
1865  if (NULL == n)
1866  {
1867  /* SYN continuation was called after neighbor was freed,
1868  * for example due to a time out for the state or the session
1869  * used was already terminated: nothing to do here... */
1870  return;
1871  }
1872 
1873  if ((GNUNET_TRANSPORT_PS_SYN_SENT != n->state) &&
1876  {
1877  /* SYN continuation was called after neighbor changed state,
1878  * for example due to a time out for the state or the session
1879  * used was already terminated: nothing to do here... */
1880  return;
1881  }
1882  if (GNUNET_OK == result)
1883  return;
1884 
1886  _ ("Failed to send SYN message to peer `%s'\n"),
1887  GNUNET_i2s (target));
1888  switch (n->state)
1889  {
1891  /* Remove address and request an additional one */
1897  break;
1898 
1900  /* Remove address and request an additional one */
1906  break;
1907 
1909  /* Remove address and request and go back to primary address */
1911  gettext_noop (
1912  "# Failed attempts to switch addresses (failed to send SYN CONT)"),
1913  1,
1914  GNUNET_NO);
1916  "Switch failed, cleaning up alternative address\n");
1922  break;
1923 
1924  default:
1926  break;
1927  }
1928 }
#define FAST_RECONNECT_TIMEOUT
How long are we willing to wait for a successful reconnect if an existing connection went down?...
#define _(String)
GNU gettext support macro.
Definition: platform.h:177

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().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ send_syn()

static void send_syn ( struct NeighbourAddress na)
static

Send a SYN message via the given address.

Parameters
naaddress to use

Definition at line 1937 of file gnunet-service-transport_neighbours.c.

1938 {
1939  struct GNUNET_TRANSPORT_PluginFunctions *papi;
1940  struct TransportSynMessage connect_msg;
1941  struct NeighbourMapEntry *n;
1942 
1943  GNUNET_assert (NULL != na->session);
1945  "Sending SYN message to peer `%s' at %s\n",
1946  GNUNET_i2s (&na->address->peer),
1947  GST_plugins_a2s (na->address));
1948 
1949  papi = GST_plugins_find (na->address->transport_name);
1950  GNUNET_assert (NULL != papi);
1952  gettext_noop
1953  ("# SYN messages sent"),
1954  1, GNUNET_NO);
1956  connect_msg.header.size = htons (sizeof(struct TransportSynMessage));
1957  connect_msg.header.type = htons (GNUNET_MESSAGE_TYPE_TRANSPORT_SESSION_SYN);
1958  connect_msg.reserved = htonl (0);
1959  connect_msg.timestamp = GNUNET_TIME_absolute_hton (na->connect_timestamp);
1960  if (-1 ==
1961  papi->send (papi->cls,
1962  na->session,
1963  (const char *) &connect_msg,
1964  sizeof(struct TransportSynMessage),
1965  UINT_MAX,
1967  &send_session_syn_cont, NULL))
1968  {
1970  _ ("Failed to transmit SYN message to %s\n"),
1971  GST_plugins_a2s (na->address));
1972  n = lookup_neighbour (&na->address->peer);
1973  if (NULL == n)
1974  {
1975  GNUNET_break (0);
1976  return;
1977  }
1978  switch (n->state)
1979  {
1981  /* Remove address and request and additional one */
1982  GNUNET_assert (na == &n->primary_address);
1988  /* Hard failure to send the SYN message with this address:
1989  Destroy address and session */
1990  break;
1991 
1993  /* Remove address and request an additional one */
1994  GNUNET_assert (na == &n->primary_address);
2000  break;
2001 
2003  GNUNET_assert (na == &n->alternative_address);
2005  gettext_noop (
2006  "# Failed attempts to switch addresses (failed to send SYN)"),
2007  1,
2008  GNUNET_NO);
2009  /* Remove address and request an additional one */
2011  "Switch failed, cleaning up alternative address\n");
2017  break;
2018 
2019  default:
2020  GNUNET_break (0);
2022  break;
2023  }
2024  return;
2025  }
2027  na->session,
2028  sizeof(struct TransportSynMessage));
2029 }
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 ...
@ GNUNET_ERROR_TYPE_WARNING
#define GNUNET_MESSAGE_TYPE_TRANSPORT_SESSION_SYN
Transport SYN message exchanged between transport services to indicate that a session should be marke...
struct GNUNET_PeerIdentity peer
For which peer is this an address?
struct GNUNET_TIME_Absolute connect_timestamp
Timestamp of the 'SESSION_CONNECT' message we sent to the other peer for this address.
Message a peer sends to another to indicate that it intends to setup a connection/session for data ex...

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().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ send_session_syn_ack_cont()

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 
)
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.

Parameters
clsNULL
targetwhich peer received the transmission
resultGNUNET_OK if sending worked
size_payloadhow many bytes of payload were sent (ignored)
size_on_wirehow much bandwidth was consumed on the wire (ignored)

Definition at line 2045 of file gnunet-service-transport_neighbours.c.

2050 {
2051  struct NeighbourMapEntry *n;
2052 
2053  (void) cls;
2054  (void) size_payload;
2055  (void) size_on_wire;
2056  n = lookup_neighbour (target);
2057  if (NULL == n)
2058  {
2059  /* SYN_ACK continuation was called after neighbor was freed,
2060  * for example due to a time out for the state or the session
2061  * used was already terminated: nothing to do here... */
2062  return;
2063  }
2064 
2066  {
2067  /* SYN_ACK continuation was called after neighbor changed state,
2068  * for example due to a time out for the state or the session
2069  * used was already terminated: nothing to do here... */
2070  return;
2071  }
2072  if (GNUNET_OK == result)
2073  return;
2074 
2076  _ (
2077  "Failed to send SYN_ACK message to peer `%s' using address `%s'\n"),
2078  GNUNET_i2s (target),
2080 
2081  /* Remove address and request and additional one */
2082  /* FIXME: what if the neighbour's primary address
2083  changed in the meantime? Might want to instead
2084  pass "something" around in closure to be sure. */
2091 }
enum GST_ACK_State ack_state
When a peer wants to connect we have to reply to the 1st SYN message with a SYN_ACK message.

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().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ send_syn_ack_message()

static void send_syn_ack_message ( struct NeighbourAddress na,
struct GNUNET_TIME_Absolute  timestamp 
)
static

Send a SYN_ACK message via the given address.

Parameters
naaddress and session to use
timestamptimestamp to use for the ACK message
Returns
GNUNET_SYSERR if sending immediately failed, GNUNET_OK otherwise

Definition at line 2102 of file gnunet-service-transport_neighbours.c.

2104 {
2105  const struct GNUNET_HELLO_Address *address = na->address;
2106  struct GNUNET_ATS_Session *session = na->session;
2107  struct GNUNET_TRANSPORT_PluginFunctions *papi;
2108  struct TransportSynMessage connect_msg;
2109  struct NeighbourMapEntry *n;
2110 
2112  "Sending SYN_ACK to peer `%s'\n",
2113  GNUNET_i2s (&address->peer));
2114 
2115  if (NULL == (papi = GST_plugins_find (address->transport_name)))
2116  {
2117  GNUNET_break (0);
2118  return;
2119  }
2120  if (NULL == session)
2121  session = papi->get_session (papi->cls,
2122  address);
2123  if (NULL == session)
2124  {
2125  GNUNET_break (0);
2126  return;
2127  }
2129  session);
2131  gettext_noop
2132  ("# SYN_ACK messages sent"),
2133  1, GNUNET_NO);
2134  connect_msg.header.size = htons (sizeof(struct TransportSynMessage));
2135  connect_msg.header.type = htons (
2137  connect_msg.reserved = htonl (0);
2138  connect_msg.timestamp = GNUNET_TIME_absolute_hton (timestamp);
2139 
2140  if (GNUNET_SYSERR ==
2141  papi->send (papi->cls,
2142  session,
2143  (const char *) &connect_msg,
2144  sizeof(struct TransportSynMessage),
2145  UINT_MAX,
2147  &send_session_syn_ack_cont, NULL))
2148  {
2150  _ ("Failed to transmit SYN_ACK message to %s\n"),
2152 
2153  n = lookup_neighbour (&address->peer);
2154  if (NULL == n)
2155  {
2156  GNUNET_break (0);
2157  return;
2158  }
2159  /* Remove address and request and additional one */
2166  return;
2167  }
2168 }
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...
#define GNUNET_MESSAGE_TYPE_TRANSPORT_SESSION_SYN_ACK
Transport SYN_ACK message exchanged between transport services to indicate that a SYN message was acc...
Session handle for connections.
An address for communicating with a peer.

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().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ inbound_bw_tracker_update()

static void inbound_bw_tracker_update ( void *  cls)
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).

Parameters
clsthe struct NeighbourMapEntry to update calculations for

Definition at line 2180 of file gnunet-service-transport_neighbours.c.

2181 {
2182  struct NeighbourMapEntry *n = cls;
2183  struct GNUNET_TRANSPORT_PluginFunctions *papi;
2184  struct GNUNET_TIME_Relative delay;
2185  int do_forward;
2186 
2187  if (NULL == n->primary_address.address)
2188  return; /* not active, ignore */
2190  GNUNET_assert (NULL != papi);
2191  if (NULL == papi->update_inbound_delay)
2192  return;
2194  0,
2195  &do_forward);
2197  "New inbound delay for peer `%s' is %llu ms\n",
2198  GNUNET_i2s (&n->id),
2199  (unsigned long long) delay.rel_value_us / 1000LL);
2200  if (NULL == n->primary_address.session)
2201  return;
2202  papi->update_inbound_delay (papi->cls,
2203  &n->id,
2205  delay);
2206 }
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.
GNUNET_TRANSPORT_UpdateInboundDelay update_inbound_delay
Function that will be called whenever the transport service wants to notify the plugin that the inbou...

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().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ setup_neighbour()

static struct NeighbourMapEntry* setup_neighbour ( const struct GNUNET_PeerIdentity peer)
static

Create a fresh entry in the neighbour map for the given peer.

Parameters
peerpeer to create an entry for
Returns
new neighbour map entry

Definition at line 2216 of file gnunet-service-transport_neighbours.c.

2217 {
2218  struct NeighbourMapEntry *n;
2219 
2220  if (0 ==
2221  memcmp (&GST_my_identity,
2222  peer,
2223  sizeof(struct GNUNET_PeerIdentity)))
2224  {
2226  "Cowardly refusing to consider myself my neighbour!\n");
2227  return NULL;
2228  }
2230  "Creating new neighbour entry for `%s'\n",
2231  GNUNET_i2s (peer));
2232  n = GNUNET_new (struct NeighbourMapEntry);
2233  n->id = *peer;
2234  n->ack_state = ACK_UNDEFINED;
2239  n,
2248  &n->id,
2249  n,
2252  peer,
2253  0);
2254 
2255  return n;
2256 }
#define MAX_BANDWIDTH_CARRY_S
Number of seconds that available bandwidth carries over (can accumulate).
struct GNUNET_ATS_ConnectivityHandle * GST_ats_connect
ATS connectivity handle.
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...
struct GNUNET_ATS_ConnectivitySuggestHandle * GNUNET_ATS_connectivity_suggest(struct GNUNET_ATS_ConnectivityHandle *ch, const struct GNUNET_PeerIdentity *peer, uint32_t strength)
We would like to receive address suggestions for a peer.
void GNUNET_BANDWIDTH_tracker_init(struct GNUNET_BANDWIDTH_Tracker *av, GNUNET_BANDWIDTH_TrackerUpdateCallback update_cb, void *update_cb_cls, struct GNUNET_BANDWIDTH_Value32NBO bytes_per_second_limit, uint32_t max_carry_s)
Initialize bandwidth tracker.
Definition: bandwidth.c:302
#define GNUNET_CONSTANTS_DEFAULT_BW_IN_OUT
Bandwidth (in/out) to assume initially (before either peer has communicated any particular preference...
int GNUNET_CONTAINER_multipeermap_put(struct GNUNET_CONTAINER_MultiPeerMap *map, const struct GNUNET_PeerIdentity *key, void *value, enum GNUNET_CONTAINER_MultiHashMapOption opt)
Store a key-value pair in the map.
@ GNUNET_CONTAINER_MULTIHASHMAPOPTION_UNIQUE_ONLY
There must only be one value per key; storing a value should fail if a value under the same key alrea...
#define GNUNET_new(type)
Allocate a struct or union of the given type.
The identity of the host (wraps the signing key of the peer).
struct GNUNET_TIME_Absolute last_util_transmission
Date of last utilization transmission.

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().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ GST_neighbours_handle_session_syn()

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.

Parameters
messagepossibly a struct TransportSynMessage (check format)
peeridentity of the peer to switch the address for
Returns
GNUNET_OK if the message was fine, GNUNET_SYSERR on serious error

Definition at line 2300 of file gnunet-service-transport_neighbours.c.

2302 {
2303  const struct TransportSynMessage *scm;
2304  struct NeighbourMapEntry *n;
2305  struct GNUNET_TIME_Absolute ts;
2306 
2307  if (ntohs (message->size) != sizeof(struct TransportSynMessage))
2308  {
2309  GNUNET_break_op (0);
2310  return GNUNET_SYSERR;
2311  }
2313  gettext_noop
2314  ("# SYN messages received"),
2315  1, GNUNET_NO);
2316  if (NULL == neighbours)
2317  {
2319  _ (
2320  "SYN request from peer `%s' ignored due impending shutdown\n"),
2321  GNUNET_i2s (peer));
2322  return GNUNET_OK; /* we're shutting down */
2323  }
2324  scm = (const struct TransportSynMessage *) message;
2325  GNUNET_break_op (0 == ntohl (scm->reserved));
2327  if (0 ==
2328  memcmp (&GST_my_identity,
2329  peer,
2330  sizeof(struct GNUNET_PeerIdentity)))
2331  {
2332  /* loopback connection-to-self, ignore */
2333  return GNUNET_SYSERR;
2334  }
2335  n = lookup_neighbour (peer);
2336  if (NULL == n)
2337  {
2338  /* This is a new neighbour and set to not connected */
2339  n = setup_neighbour (peer);
2340  GNUNET_assert (NULL != n);
2341  }
2342 
2343  /* Remember this SYN message in neighbour */
2345  n->connect_ack_timestamp = ts;
2346 
2348  "Received SYN for peer `%s' in state %s/%s\n",
2349  GNUNET_i2s (peer),
2351  print_ack_state (n->ack_state));
2352 
2353  switch (n->state)
2354  {
2356  /* Request an address from ATS to send SYN_ACK to this peer */
2361  break;
2362 
2364  /* SYN message takes priority over us asking ATS for address:
2365  * Wait for ATS to suggest an address and send SYN_ACK */
2370  break;
2371 
2373  /* We already wait for an address to send an SYN_ACK */
2374  break;
2375 
2378  /* Send ACK immediately */
2379  n->ack_state = ACK_SEND_ACK;
2381  ts);
2382  break;
2383 
2385  /* we are already connected and can thus send the ACK immediately */
2386  GNUNET_assert (NULL != n->primary_address.address);
2387  GNUNET_assert (NULL != n->primary_address.session);
2388  n->ack_state = ACK_SEND_ACK;
2390  ts);
2391  break;
2392 
2394  /* We wait for ATS address suggestion */
2395  break;
2396 
2398  /* We received a SYN message while waiting for a SYN_ACK in fast
2399  * reconnect. Send SYN_ACK immediately */
2400  n->ack_state = ACK_SEND_ACK;
2403  break;
2404 
2406  /* We are already connected and can thus send the ACK immediately;
2407  still, it can never hurt to have an alternative address, so also
2408  tell ATS about it */
2409  GNUNET_assert (NULL != n->primary_address.address);
2410  GNUNET_assert (NULL != n->primary_address.session);
2411  n->ack_state = ACK_SEND_ACK;
2413  ts);
2414  break;
2415 
2417  /* Get rid of remains and re-try */
2418  free_neighbour (n);
2419  n = setup_neighbour (peer);
2420  GNUNET_assert (NULL != n);
2421  /* Remember the SYN time stamp for ACK message */
2423  n->connect_ack_timestamp = ts;
2424  /* Request an address for the peer */
2429  break;
2430 
2432  /* should not be possible */
2433  GNUNET_assert (0);
2434  break;
2435 
2436  default:
2438  "Unhandled state `%s'\n",
2440  GNUNET_break (0);
2441  return GNUNET_SYSERR;
2442  }
2443  return GNUNET_OK;
2444 }
static void send_syn_ack_message(struct NeighbourAddress *na, struct GNUNET_TIME_Absolute timestamp)
Send a SYN_ACK message via the given address.
static struct NeighbourMapEntry * setup_neighbour(const struct GNUNET_PeerIdentity *peer)
Create a fresh entry in the neighbour map for the given peer.
static char * print_ack_state(enum GST_ACK_State s)
Convert the given ACK state to a string.
struct GNUNET_TIME_Absolute GNUNET_TIME_absolute_ntoh(struct GNUNET_TIME_AbsoluteNBO a)
Convert absolute time from network byte order.
Definition: time.c:542
Time for absolute times used by GNUnet, in microseconds.
struct GNUNET_TIME_Absolute connect_ack_timestamp
Timestamp we should include in our next SYN_ACK message.
struct GNUNET_TIME_AbsoluteNBO timestamp
Absolute time at the sender.

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().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ try_run_fast_ats_update()

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 
)
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.

Parameters
addressaddress of the other peer,
sessionsession to use or NULL if transport should initiate a session
bandwidth_ininbound quota to be used when connection is up, 0 to disconnect from peer
bandwidth_outoutbound quota to be used when connection is up, 0 to disconnect from peer
Returns
GNUNET_OK if we were able to just update the bandwidth and session, GNUNET_NO if more extensive changes are required (address changed)

Definition at line 2464 of file gnunet-service-transport_neighbours.c.

2468 {
2469  struct NeighbourMapEntry *n;
2470 
2471  n = lookup_neighbour (&address->peer);
2472  if ((NULL == n) ||
2473  (NULL == n->primary_address.address) ||
2475  n->primary_address.address)))
2476  return GNUNET_NO;
2477  /* We are not really switching addresses, but merely adjusting
2478  session and/or bandwidth, can do fast ATS update! */
2479  if (session != n->primary_address.session)
2480  {
2481  /* switch to a different session, but keeping same address; could
2482  happen if there is a 2nd inbound connection */
2483  n->primary_address.session = session;
2486  n->primary_address.session));
2487  }
2488  if (n->primary_address.bandwidth_in.value__ != bandwidth_in.value__)
2489  {
2490  n->primary_address.bandwidth_in = bandwidth_in;
2491  if (GNUNET_YES !=
2492  set_incoming_quota (n,
2493  bandwidth_in))
2494  return GNUNET_NO;
2495  }
2496  if (n->primary_address.bandwidth_out.value__ != bandwidth_out.value__)
2497  {
2498  n->primary_address.bandwidth_out = bandwidth_out;
2500  }
2501  return GNUNET_OK;
2502 }

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().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ switch_address_bl_check_cont()

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 
)
static

We've been asked to switch addresses, and just now got the result from the blacklist check to see if this is allowed.

Parameters
clsthe struct BlacklistCheckSwitchContext with the information about the future address
peerthe peer we may switch addresses on
addressaddress associated with the request
sessionsession associated with the request
resultGNUNET_OK if the connection is allowed, GNUNET_NO if not, GNUNET_SYSERR if operation was aborted

Definition at line 2519 of file gnunet-service-transport_neighbours.c.

2524 {
2525  struct BlacklistCheckSwitchContext *blc_ctx = cls;
2526  struct GNUNET_TRANSPORT_PluginFunctions *papi;
2527  struct NeighbourMapEntry *n;
2528 
2529  if (GNUNET_SYSERR == result)
2530  goto cleanup;
2531 
2532  papi = GST_plugins_find (address->transport_name);
2533  if (NULL == papi)
2534  {
2535  /* This can happen during shutdown. */
2536  goto cleanup;
2537  }
2538 
2539  if (GNUNET_NO == result)
2540  {
2542  "Blacklist denied to switch to suggested address `%s' session %p for peer `%s'\n",
2544  session,
2545  GNUNET_i2s (peer));
2547  "# ATS suggestions ignored (blacklist denied)",
2548  1,
2549  GNUNET_NO);
2550  if (NULL != session)
2551  papi->disconnect_session (papi->cls,
2552  session);
2553  if (GNUNET_YES !=
2557  NULL);
2558  goto cleanup;
2559  }
2560 
2561 
2562  if (NULL == session)
2563  {
2564  /* need to create a session, ATS only gave us an address */
2565  session = papi->get_session (papi->cls,
2566  address);
2568  "Obtained new session for peer `%s' and address '%s': %p\n",
2569  GNUNET_i2s (&address->peer),
2571  session);
2572  if (NULL != session)
2574  session);
2575  }
2576  if (NULL == session)
2577  {
2578  /* session creation failed, bad!, fail! */
2580  "# ATS suggestions ignored (failed to create session)",
2581  1,
2582  GNUNET_NO);
2583  /* No session could be obtained, remove blacklist check and clean up */
2585  "Failed to obtain new session for peer `%s' and address '%s'\n",
2586  GNUNET_i2s (&address->peer),
2589  session);
2590  goto cleanup;
2591  }
2592 
2593  /* We did this check already before going into blacklist, but
2594  it is theoretically possible that the situation changed in
2595  the meantime, hence we check again here */
2596  if (GNUNET_OK ==
2598  session,
2599  blc_ctx->bandwidth_in,
2600  blc_ctx->bandwidth_out))
2601  goto cleanup; /* was just a minor update, we're done */
2602 
2603  /* check if we also need to setup the neighbour entry */
2604  if (NULL == (n = lookup_neighbour (peer)))
2605  {
2606  n = setup_neighbour (peer);
2607  if (NULL == n)
2608  {
2609  /* not sure how this can happen... */
2610  GNUNET_break (0);
2611  goto cleanup;
2612  }
2614  }
2615 
2617  "Peer `%s' switches to address `%s'\n",
2618  GNUNET_i2s (&address->peer),
2620 
2621  switch (n->state)
2622  {
2624  GNUNET_break (0);
2626  session);
2627  free_neighbour (n);
2628  return;
2629 
2631  /* We requested an address and ATS suggests one:
2632  * set primary address and send SYN message*/
2634  address,
2635  session,
2636  blc_ctx->bandwidth_in,
2637  blc_ctx->bandwidth_out);
2638  if (ACK_SEND_SYN_ACK == n->ack_state)
2639  {
2640  /* Send pending SYN_ACK message */
2641  n->ack_state = ACK_SEND_ACK;
2644  }
2649  send_syn (&n->primary_address);
2650  break;
2651 
2653  /* ATS suggested a new address while waiting for an SYN_ACK:
2654  * Switch and send new SYN */
2655  /* ATS suggests a different address, switch again */
2657  address,
2658  session,
2659  blc_ctx->bandwidth_in,
2660  blc_ctx->bandwidth_out);
2661  if (ACK_SEND_SYN_ACK == n->ack_state)
2662  {
2663  /* Send pending SYN_ACK message */
2664  n->ack_state = ACK_SEND_ACK;
2667  }
2672  send_syn (&n->primary_address);
2673  break;
2674 
2676  /* We requested an address and ATS suggests one:
2677  * set primary address and send SYN_ACK message*/
2679  address,
2680  session,
2681  blc_ctx->bandwidth_in,
2682  blc_ctx->bandwidth_out);
2683  /* Send an ACK message as a response to the SYN msg */
2690  if ((ACK_SEND_SYN_ACK == n->ack_state) ||
2691  (ACK_UNDEFINED == n->ack_state))
2692  n->ack_state = ACK_SEND_ACK;
2693  break;
2694 
2696  /* ATS asks us to switch while we were trying to connect; switch to new
2697  address and check blacklist again */
2698  if ((ACK_SEND_SYN_ACK == n->ack_state))
2699  {
2700  n->ack_state = ACK_SEND_ACK;
2703  }
2705  address,
2706  session,
2707  blc_ctx->bandwidth_in,
2708  blc_ctx->bandwidth_out);
2713  break;
2714 
2716  GNUNET_assert (NULL != n->primary_address.address);
2717  GNUNET_assert (NULL != n->primary_address.session);
2718  GNUNET_break (n->primary_address.session != session);
2719  /* ATS asks us to switch a life connection; see if we can get
2720  a SYN_ACK on it before we actually do this! */
2722  address,
2723  session,
2724  blc_ctx->bandwidth_in,
2725  blc_ctx->bandwidth_out);
2731  gettext_noop ("# Attempts to switch addresses"),
2732  1,
2733  GNUNET_NO);
2735  break;
2736 
2739  address,
2740  session,
2741  blc_ctx->bandwidth_in,
2742  blc_ctx->bandwidth_out);
2743  if (ACK_SEND_SYN_ACK == n->ack_state)
2744  {
2745  /* Send pending SYN_ACK message */
2746  n->ack_state = ACK_SEND_ACK;
2749  }
2754  send_syn (&n->primary_address);
2755  break;
2756 
2758  /* ATS asks us to switch while we were trying to reconnect; switch to new
2759  address and send SYN again */
2761  address,
2762  session,
2763  blc_ctx->bandwidth_in,
2764  blc_ctx->bandwidth_out);
2769  send_syn (&n->primary_address);
2770  break;
2771 
2774  address)) &&
2775  (n->primary_address.session == session))
2776  {
2777  /* ATS switches back to still-active session */
2779  "ATS double-switched, cleaning up alternative address\n");
2783  n->timeout);
2784  break;
2785  }
2786  /* ATS asks us to switch a life connection, send */
2788  address,
2789  session,
2790  blc_ctx->bandwidth_in,
2791  blc_ctx->bandwidth_out);
2797  break;
2798 
2800  /* not going to switch addresses while disconnecting */
2802  "# ATS suggestion ignored (disconnecting)",
2803  1,
2804  GNUNET_NO);
2805  return;
2806 
2808  GNUNET_assert (0);
2809  break;
2810 
2811  default:
2813  "Unhandled state `%s'\n",
2815  GNUNET_break (0);
2816  break;
2817  }
2818 cleanup:
2821  blc_ctx);
2822  GNUNET_free (blc_ctx);
2823 }
static void cleanup(void *cls)
Function scheduled as very last function, cleans up after us.
static void send_syn(struct NeighbourAddress *na)
Send a SYN message via the given address.
static struct BlacklistCheckSwitchContext * pending_bc_head
List of pending blacklist checks: head.
static struct BlacklistCheckSwitchContext * pending_bc_tail
List of pending blacklist checks: tail.
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.
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.
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.
int GNUNET_HELLO_address_check_option(const struct GNUNET_HELLO_Address *address, enum GNUNET_HELLO_AddressInfo option)
Check if an address has a local option set.
Definition: address.c:39
@ GNUNET_HELLO_ADDRESS_INFO_INBOUND
This is an inbound address and cannot be used to initiate an outbound connection to another peer.
Entry in a DLL we use to keep track of pending blacklist checks.
struct GNUNET_BANDWIDTH_Value32NBO bandwidth_in
Inbound bandwidth that was assigned to address.
struct GNUNET_BANDWIDTH_Value32NBO bandwidth_out
Outbound bandwidth that was assigned to address.
GNUNET_TRANSPORT_DisconnectSessionFunction disconnect_session
Function that can be used to force the plugin to disconnect from the given peer and cancel all previo...

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().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ 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.

Parameters
addressaddress of the other peer,
sessionsession to use or NULL if transport should initiate a session
bandwidth_ininbound quota to be used when connection is up, 0 to disconnect from peer
bandwidth_outoutbound quota to be used when connection is up, 0 to disconnect from peer

Definition at line 2844 of file gnunet-service-transport_neighbours.c.

2850 {
2851  struct GST_BlacklistCheck *blc;
2852  struct BlacklistCheckSwitchContext *blc_ctx;
2853 
2854  GNUNET_assert (NULL != address->transport_name);
2855  if (GNUNET_OK ==
2857  session,
2858  bandwidth_in,
2859  bandwidth_out))
2860  return;
2861 
2862  /* Check if plugin is available */
2863  if (NULL == (GST_plugins_find (address->transport_name)))
2864  {
2865  /* we don't have the plugin for this address */
2866  GNUNET_break (0);
2868  session);
2869  return;
2870  }
2871  if ((NULL == session) &&
2874  {
2875  /* This is a inbound address and we do not have a session to use! */
2876  GNUNET_break (0);
2878  session);
2879  return;
2880  }
2881 
2883  "ATS suggests address '%s' for peer `%s' at %u/%u speed\n",
2885  GNUNET_i2s (&address->peer),
2886  (unsigned int) ntohl (bandwidth_in.value__),
2887  (unsigned int) ntohl (bandwidth_out.value__));
2888 
2889  /* Perform blacklist check */
2890  blc_ctx = GNUNET_new (struct BlacklistCheckSwitchContext);
2891  blc_ctx->bandwidth_in = bandwidth_in;
2892  blc_ctx->bandwidth_out = bandwidth_out;
2895  blc_ctx);
2896  if (NULL != (blc = GST_blacklist_test_allowed (&address->peer,
2897  address->transport_name,
2899  blc_ctx,
2900  address,
2901  session)))
2902  {
2903  blc_ctx->blc = blc;
2904  }
2905 }
struct GST_BlacklistCheck * GST_blacklist_test_allowed(const struct GNUNET_PeerIdentity *peer, const char *transport_name, GST_BlacklistTestContinuation cont, void *cont_cls, const struct GNUNET_HELLO_Address *address, struct GNUNET_ATS_Session *session)
Test if a peer/transport combination is blacklisted.
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 ...
#define GNUNET_CONTAINER_DLL_insert(head, tail, element)
Insert an element at the head of a DLL.
struct GST_BlacklistCheck * blc
Handle to the blacklist check we are performing.
Context we use when performing a blacklist check.

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().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ send_utilization_data()

static int send_utilization_data ( void *  cls,
const struct GNUNET_PeerIdentity key,
void *  value 
)
static

Function called to send network utilization data to ATS for each active connection.

Parameters
clsNULL
keypeer we send utilization data for
valuethe struct NeighbourMapEntry * with data to send
Returns
GNUNET_OK (continue to iterate)

Definition at line 2918 of file gnunet-service-transport_neighbours.c.

2921 {
2922  struct NeighbourMapEntry *n = value;
2923  uint32_t bps_in;
2924  uint32_t bps_out;
2925  struct GNUNET_TIME_Relative delta;
2926 
2927  (void) cls;
2928  if ((GNUNET_YES != test_connected (n)) ||
2929  (NULL == n->primary_address.address))
2930  return GNUNET_OK;
2933  bps_in = 0;
2934  if ((0 != n->util_total_bytes_recv) && (0 != delta.rel_value_us))
2935  bps_in = (1000LL * 1000LL * n->util_total_bytes_recv)
2936  / (delta.rel_value_us);
2937  bps_out = 0;
2938  if ((0 != n->util_total_bytes_sent) && (0 != delta.rel_value_us))
2939  bps_out = (1000LL * 1000LL * n->util_total_bytes_sent) / delta.rel_value_us;
2940 
2942  "`%s' total: received %u Bytes/s, sent %u Bytes/s\n",
2943  GNUNET_i2s (key),
2944  bps_in,
2945  bps_out);
2947  bps_in,
2948  bps_out);
2949  n->util_total_bytes_recv = 0;
2950  n->util_total_bytes_sent = 0;
2952  return GNUNET_OK;
2953 }
struct GNUNET_HashCode key
The key used in the DHT.
static char * value
Value of the record to add/remove.
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.
struct GNUNET_TIME_Relative GNUNET_TIME_absolute_get_difference(struct GNUNET_TIME_Absolute start, struct GNUNET_TIME_Absolute end)
Compute the time difference between the given start and end times.
Definition: time.c:248
static struct GNUNET_TIME_Relative delta
Definition: speedup.c:35
uint32_t util_total_bytes_sent
Tracking utilization of outbound bandwidth.
uint32_t util_total_bytes_recv
Tracking utilization of inbound bandwidth.

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().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ utilization_transmission()

static void utilization_transmission ( void *  cls)
static

Task transmitting utilization in a regular interval.

Parameters
clsthe struct NeighbourMapEntry for which we are running

Definition at line 2962 of file gnunet-service-transport_neighbours.c.

2963 {
2964  (void) cls;
2965  util_transmission_tk = NULL;
2968  NULL);
2972  NULL);
2973 }
static void utilization_transmission(void *cls)
Task transmitting utilization in a regular interval.
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.
static struct GNUNET_SCHEDULER_Task * util_transmission_tk
Task transmitting utilization data.
#define UTIL_TRANSMISSION_INTERVAL
Interval to send utilization data.
int GNUNET_CONTAINER_multipeermap_iterate(struct GNUNET_CONTAINER_MultiPeerMap *map, GNUNET_CONTAINER_PeerMapIterator it, void *it_cls)
Iterate over all entries in the map.

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().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ GST_neighbours_notify_data_recv()

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).

Parameters
addressthe address we got data from
messagethe message we received (really only the size is used)

Definition at line 2985 of file gnunet-service-transport_neighbours.c.

2987 {
2988  struct NeighbourMapEntry *n;
2989 
2990  n = lookup_neighbour (&address->peer);
2991  if (NULL == n)
2992  return;
2993  n->util_total_bytes_recv += ntohs (message->size);
2994 }

References address, lookup_neighbour(), GNUNET_MessageHeader::size, and NeighbourMapEntry::util_total_bytes_recv.

Here is the call graph for this function:

◆ GST_neighbours_notify_data_sent()

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).

Parameters
addressthe address we transmitted data to
sessionsession we used to transmit data
messagethe message we sent (really only the size is used)

Definition at line 3007 of file gnunet-service-transport_neighbours.c.

3010 {
3011  struct NeighbourMapEntry *n;
3012 
3013  n = lookup_neighbour (&address->peer);
3014  if (NULL == n)
3015  return;
3016  if (n->primary_address.session != session)
3017  return;
3019 }

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().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ send_session_ack_message()

static void send_session_ack_message ( struct NeighbourMapEntry n)
static

Send a ACK message to the neighbour to confirm that we got its SYN_ACK.

Parameters
nneighbour to send the ACK to

Definition at line 3194 of file gnunet-service-transport_neighbours.c.

3195 {
3196  struct GNUNET_MessageHeader msg;
3197 
3199  "Sending ACK message to peer `%s'\n",
3200  GNUNET_i2s (&n->id));
3201 
3202  msg.size = htons (sizeof(struct GNUNET_MessageHeader));
3204  (void) send_with_session (n,
3205  &msg,
3206  sizeof(struct GNUNET_MessageHeader),
3207  UINT32_MAX,
3209  GNUNET_NO,
3210  NULL, NULL);
3211 }
#define GNUNET_MESSAGE_TYPE_TRANSPORT_SESSION_ACK
Transport ACK message exchanged between transport services to indicate that a SYN_ACK message was acc...

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().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ 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.

Parameters
messagepossibly a struct GNUNET_ATS_SessionConnectMessage (check format)
peeridentity of the peer to switch the address for
addressaddress of the other peer, NULL if other peer connected to us
sessionsession to use (or NULL)
Returns
GNUNET_OK if the message was fine, GNUNET_SYSERR on serious error

Definition at line 3226 of file gnunet-service-transport_neighbours.c.

3231 {
3232  const struct TransportSynMessage *scm;
3233  struct GNUNET_TIME_Absolute ts;
3234  struct NeighbourMapEntry *n;
3235 
3236  (void) session;
3237  if (ntohs (message->size) != sizeof(struct TransportSynMessage))
3238  {
3239  GNUNET_break_op (0);
3240  return GNUNET_SYSERR;
3241  }
3243  gettext_noop
3244  ("# SYN_ACK messages received"),
3245  1, GNUNET_NO);
3246  scm = (const struct TransportSynMessage *) message;
3247  GNUNET_break_op (ntohl (scm->reserved) == 0);
3248  if (NULL == (n = lookup_neighbour (&address->peer)))
3249  {
3251  gettext_noop
3252  ("# unexpected SYN_ACK messages (no peer)"),
3253  1, GNUNET_NO);
3254  return GNUNET_SYSERR;
3255  }
3257  "Received SYN_ACK message from peer `%s' in state %s/%s\n",
3258  GNUNET_i2s (&address->peer),
3260  print_ack_state (n->ack_state));
3262  switch (n->state)
3263  {
3265  GNUNET_break (0);
3266  free_neighbour (n);
3267  return GNUNET_SYSERR;
3268 
3271  gettext_noop (
3272  "# unexpected SYN_ACK messages (not ready)"),
3273  1,
3274  GNUNET_NO);
3275  break;
3276 
3278  if (ts.abs_value_us != n->primary_address.connect_timestamp.abs_value_us)
3279  {
3281  "SYN_ACK ignored as the timestamp does not match our SYN request\n");
3282  return GNUNET_OK;
3283  }
3294  break;
3295 
3299  gettext_noop (
3300  "# unexpected SYN_ACK messages (not ready)"),
3301  1,
3302  GNUNET_NO);
3303  break;
3304 
3306  /* duplicate SYN_ACK, let's answer by duplicate ACK just in case */
3308  break;
3309 
3311  /* we didn't expect any SYN_ACK, as we are waiting for ATS
3312  to give us a new address... */
3314  gettext_noop (
3315  "# unexpected SYN_ACK messages (waiting on ATS)"),
3316  1,
3317  GNUNET_NO);
3318  break;
3319 
3321  /* Reconnecting with new address address worked; go back to connected! */
3327  break;
3328 
3330  /* new address worked; adopt it and go back to connected! */
3336 
3337  /* Set primary addresses */
3344  gettext_noop (
3345  "# Successful attempts to switch addresses"),
3346  1,
3347  GNUNET_NO);
3348 
3350  memset (&n->alternative_address,
3351  0,
3352  sizeof(n->alternative_address));
3354  break;
3355 
3358  gettext_noop
3359  ("# unexpected SYN_ACK messages (disconnecting)"),
3360  1, GNUNET_NO);
3361  return GNUNET_SYSERR;
3362 
3364  GNUNET_assert (0);
3365  break;
3366 
3367  default:
3369  "Unhandled state `%s'\n",
3371  GNUNET_break (0);
3372  return GNUNET_SYSERR;
3373  }
3374  return GNUNET_OK;
3375 }
static void send_session_ack_message(struct NeighbourMapEntry *n)
Send a ACK message to the neighbour to confirm that we got its SYN_ACK.

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.

Here is the call graph for this function:

◆ GST_neighbours_session_terminated()

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.

Parameters
peeridentity of the peer where the session died
sessionsession that is gone
Returns
GNUNET_YES if this was a session used, GNUNET_NO if this session was not in use

Definition at line 3388 of file gnunet-service-transport_neighbours.c.

3390 {
3391  struct NeighbourMapEntry *n;
3392 
3393  if (NULL == (n = lookup_neighbour (peer)))
3394  return GNUNET_NO; /* can't affect us */
3395  if (session != n->primary_address.session)
3396  {
3397  /* Free alternative address */
3398  if (session == n->alternative_address.session)
3399  {
3403  n->timeout);
3405  "Session died, cleaning up alternative address\n");
3407  }
3408  return GNUNET_NO; /* doesn't affect us further */
3409  }
3410 
3412  /* The session for neighbour's primary address died */
3413  switch (n->state)
3414  {
3416  GNUNET_break (0);
3417  free_neighbour (n);
3418  return GNUNET_YES;
3419 
3421  GNUNET_break (0);
3422  free_neighbour (n);
3423  return GNUNET_YES;
3424 
3426  /* The session used to send the SYN terminated:
3427  * this implies a connect error*/
3429  "Failed to send SYN in CONNECT_SENT with `%s' %p: session terminated\n",
3432 
3433  /* Destroy the address since it cannot be used */
3439  break;
3440 
3443  /* error on inbound session; free neighbour entirely */
3444  free_neighbour (n);
3445  return GNUNET_YES;
3446 
3448  /* Our primary connection died, try a fast reconnect */
3454  break;
3455 
3457  /* we don't have an address, how can it go down? */
3458  GNUNET_break (0);
3459  break;
3460 
3463  "Failed to send SYN in RECONNECT_SENT with `%s' %p: session terminated\n",
3466  /* Destroy the address since it cannot be used */
3472  break;
3473 
3475  /* primary went down while we were waiting for SYN_ACK on secondary;
3476  secondary as primary */
3477 
3479  "Connection `%s' %p to peer `%s' was terminated while switching, "
3480  "switching to alternative address `%s' %p\n",
3483  GNUNET_i2s (peer),
3486 
3487  /* Destroy the inbound address since it cannot be used */
3492  n->primary_address.session));
3493  memset (&n->alternative_address,
3494  0,
3495  sizeof(struct NeighbourAddress));
3500  break;
3501 
3504  break;
3505 
3507  /* neighbour was freed and plugins told to terminate session */
3508  return GNUNET_NO;
3509 
3510  default:
3512  "Unhandled state `%s'\n",
3514  GNUNET_break (0);
3515  break;
3516  }
3517  if (NULL != n->task)
3520  return GNUNET_YES;
3521 }
A possible address we could use to communicate with a neighbour.

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().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ GST_neighbours_handle_session_ack()

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.

Parameters
messagepossibly a 'struct GNUNET_ATS_SessionConnectMessage' (check format)
addressaddress of the other peer
sessionsession to use (or NULL)
Returns
GNUNET_OK if the message was fine, GNUNET_SYSERR on serious error

Definition at line 3535 of file gnunet-service-transport_neighbours.c.

3538 {
3539  struct NeighbourMapEntry *n;
3540 
3541  (void) session;
3542  if (ntohs (message->size) != sizeof(struct GNUNET_MessageHeader))
3543  {
3544  GNUNET_break_op (0);
3545  return GNUNET_SYSERR;
3546  }
3548  gettext_noop ("# ACK messages received"),
3549  1,
3550  GNUNET_NO);
3551  if (NULL == (n = lookup_neighbour (&address->peer)))
3552  {
3553  GNUNET_break_op (0);
3554  return GNUNET_SYSERR;
3555  }
3557  "Received ACK for peer `%s' in state %s/%s\n",
3558  GNUNET_i2s (&address->peer),
3560  print_ack_state (n->ack_state));
3561 
3562  /* Check if we are in a plausible state for having sent
3563  a SYN_ACK. If not, return, otherwise break.
3564 
3565  The remote peers sends a ACK as a response for a SYN_ACK
3566  message.
3567 
3568  We expect a ACK:
3569  - If a remote peer has sent a SYN, we responded with a SYN_ACK and
3570  now wait for the ACK to finally be connected
3571  - If we sent a SYN_ACK to this peer before */if (((GNUNET_TRANSPORT_PS_SYN_RECV_ACK != n->state) &&
3572  (ACK_SEND_ACK != n->ack_state)) ||
3573  (NULL == n->primary_address.address))
3574  {
3576  "Received unexpected ACK message from peer `%s' in state %s/%s\n",
3577  GNUNET_i2s (&address->peer),
3579  print_ack_state (n->ack_state));
3580 
3582  gettext_noop ("# unexpected ACK messages"),
3583  1,
3584  GNUNET_NO);
3585  return GNUNET_OK;
3586  }
3588  {
3589  /* We tried to switch addresses while being connect. We explicitly wait
3590  * for a SYN_ACK before going to GNUNET_TRANSPORT_PS_CONNECTED,
3591  * so we do not want to set the address as in use! */
3592  return GNUNET_OK;
3593  }
3598 
3599  if (NULL == n->primary_address.address)
3600  {
3601  /* See issue #3693.
3602  * We are in state = PSY_SYN_RECV_ACK or ack_state = ACK_SEND_ACK, which
3603  * really means we did try (and succeed) to send a SYN and are waiting for
3604  * an ACK.
3605  * That suggests that the primary_address used to be non-NULL, but maybe it
3606  * got reset to NULL without the state being changed appropriately?
3607  */GNUNET_break (0);
3608  return GNUNET_OK;
3609  }
3610 
3611  /* Reset backoff for primary address */
3614  return GNUNET_OK;
3615 }
void GST_ats_block_reset(const struct GNUNET_HELLO_Address *address, struct GNUNET_ATS_Session *session)
Reset address blocking time.

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.

Here is the call graph for this function:

◆ GST_neighbours_test_connected()

int GST_neighbours_test_connected ( const struct GNUNET_PeerIdentity target)

Test if we're connected to the given peer.

Parameters
targetpeer to test
Returns
GNUNET_YES if we are connected, GNUNET_NO if not

Definition at line 3625 of file gnunet-service-transport_neighbours.c.

3626 {
3627  return test_connected (lookup_neighbour (target));
3628 }

References lookup_neighbour(), and test_connected().

Referenced by handle_client_send(), notify_client_about_neighbour(), send_delayed(), and transmit_our_hello().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ delayed_disconnect()

static void delayed_disconnect ( void *  cls)
static

Task to asynchronously run free_neighbour().

Parameters
clsthe struct NeighbourMapEntry to free

Definition at line 3637 of file gnunet-service-transport_neighbours.c.

3638 {
3639  struct NeighbourMapEntry *n = cls;
3640 
3641  n->delayed_disconnect_task = NULL;
3643  "Disconnecting by request from peer %s\n",
3644  GNUNET_i2s (&n->id));
3645  free_neighbour (n);
3646 }

References NeighbourMapEntry::delayed_disconnect_task, free_neighbour(), GNUNET_ERROR_TYPE_INFO, GNUNET_i2s(), GNUNET_log,