GNUnet  0.11.x
Typedefs | Functions
gnunet-service-transport_neighbours.h File Reference

neighbour manipulation API, allows manipulation of performance metrics (delay and towards ATS) More...

#include "gnunet_statistics_service.h"
#include "gnunet_transport_service.h"
#include "gnunet_transport_plugin.h"
#include "gnunet-service-transport.h"
#include "transport.h"
#include "gnunet_util_lib.h"
Include dependency graph for gnunet-service-transport_neighbours.h:
This graph shows which files directly or indirectly include this file:

Go to the source code of this file.

Typedefs

typedef void(* GST_NeighbourSendContinuation) (void *cls, int success, size_t bytes_payload, size_t bytes_on_wire)
 Function called after the transmission is done. More...
 
typedef void(* GST_NeighbourIterator) (void *cls, 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)
 Function called for each neighbour. More...
 

Functions

void GST_neighbours_start (unsigned int max_fds)
 Initialize the neighbours subsystem. More...
 
void GST_neighbours_stop (void)
 Cleanup the neighbours subsystem. More...
 
int GST_neighbours_test_connected (const struct GNUNET_PeerIdentity *target)
 Test if we're connected to the given peer. 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...
 
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_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...
 
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...
 
void GST_neighbours_iterate (GST_NeighbourIterator cb, void *cb_cls)
 Iterate over all connected neighbours. More...
 
int GST_neighbours_session_terminated (const struct GNUNET_PeerIdentity *peer, struct GNUNET_ATS_Session *session)
 A session was terminated. 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...
 
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 an existing neighbour record, set the active connection to use the given address. More...
 
int GST_neighbours_handle_session_syn (const struct GNUNET_MessageHeader *message, const struct GNUNET_PeerIdentity *peer)
 We received a 'SESSION_CONNECT' message from the other peer. 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_CONNECT_ACK' message from the other peer. 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 'SESSION_ACK' message from the other peer. 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_handle_quota_message (const struct GNUNET_PeerIdentity *peer, const struct GNUNET_MessageHeader *msg)
 We received a quoat 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...
 

Detailed Description

neighbour manipulation API, allows manipulation of performance metrics (delay and towards ATS)

neighbour management API

Author
Christian Grothoff

Definition in file gnunet-service-transport_neighbours.h.

Typedef Documentation

◆ GST_NeighbourSendContinuation

typedef void(* GST_NeighbourSendContinuation) (void *cls, int success, size_t bytes_payload, size_t bytes_on_wire)

Function called after the transmission is done.

Parameters
clsclosure
successGNUNET_OK on success, GNUNET_NO on failure, GNUNET_SYSERR if we're not connected
bytes_payloadhow much payload was transmitted
bytes_on_wirehow many bytes were used on the wire

Definition at line 71 of file gnunet-service-transport_neighbours.h.

◆ GST_NeighbourIterator

typedef void(* GST_NeighbourIterator) (void *cls, 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)

Function called for each neighbour.

Parameters
clsclosure
peeridentity of the neighbour
addressthe address of the neighbour
statecurrent state the peer is in
state_timeouttimeout for this state
bandwidth_ininbound quota in NBO
bandwidth_outoutbound quota in NBO

Definition at line 159 of file gnunet-service-transport_neighbours.h.

Function Documentation

◆ GST_neighbours_start()

void GST_neighbours_start ( unsigned int  max_fds)

Initialize the neighbours subsystem.

Parameters
max_fdsmaximum number of fds to use

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

3914 {
3915  (void) max_fds;
3917  GNUNET_NO);
3921  NULL);
3922 }
#define NEIGHBOUR_TABLE_SIZE
Size of the neighbour hash map.
static void utilization_transmission(void *cls)
Task transmitting utilization in a regular interval.
static struct GNUNET_CONTAINER_MultiPeerMap * neighbours
Hash map from peer identities to the respective struct NeighbourMapEntry.
static struct GNUNET_SCHEDULER_Task * util_transmission_tk
Task transmitting utilization data.
#define UTIL_TRANSMISSION_INTERVAL
Interval to send utilization data.
@ GNUNET_NO
Definition: gnunet_common.h:94
struct GNUNET_CONTAINER_MultiPeerMap * GNUNET_CONTAINER_multipeermap_create(unsigned int len, int do_not_copy_keys)
Create a multi peer map (hash map for public keys of peers).
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

References GNUNET_CONTAINER_multipeermap_create(), GNUNET_NO, GNUNET_SCHEDULER_add_delayed(), NEIGHBOUR_TABLE_SIZE, neighbours, UTIL_TRANSMISSION_INTERVAL, util_transmission_tk, and utilization_transmission().

Referenced by run().

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

◆ GST_neighbours_stop()

void GST_neighbours_stop ( void  )

Cleanup the neighbours subsystem.

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

3955 {
3956  if (NULL == neighbours)
3957  return;
3958  if (NULL != util_transmission_tk)
3959  {
3961  util_transmission_tk = NULL;
3962  }
3965  NULL);
3967  neighbours = NULL;
3968 }
static int disconnect_all_neighbours(void *cls, const struct GNUNET_PeerIdentity *key, void *value)
Disconnect from the given neighbour.
void GNUNET_CONTAINER_multipeermap_destroy(struct GNUNET_CONTAINER_MultiPeerMap *map)
Destroy a hash map.
int GNUNET_CONTAINER_multipeermap_iterate(struct GNUNET_CONTAINER_MultiPeerMap *map, GNUNET_CONTAINER_PeerMapIterator it, void *it_cls)
Iterate over all entries in the map.
void * GNUNET_SCHEDULER_cancel(struct GNUNET_SCHEDULER_Task *task)
Cancel the task with the specified identifier.
Definition: scheduler.c:972

Referenced by shutdown_task().

Here is the caller 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 }
static int test_connected(struct NeighbourMapEntry *n)
Test if we're connected to the given peer.
static struct NeighbourMapEntry * lookup_neighbour(const struct GNUNET_PeerIdentity *pid)
Lookup a neighbour entry in the neighbours hash map.

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:

◆ 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
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 }
struct GNUNET_MQ_Handle * mq
Definition: 003.c:5
struct GNUNET_MessageHeader * msg
Definition: 005.c:2
#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 master_task(void *cls)
Master task run for every neighbour.
static unsigned long long bytes_in_send_queue
Number of bytes we have currently queued for transmission.
#define GNUNET_log(kind,...)
#define GNUNET_memcpy(dst, src, n)
Call memcpy() but check for n being 0 first.
@ GNUNET_YES
Definition: gnunet_common.h:97
@ GNUNET_SYSERR
Definition: gnunet_common.h:93
#define GNUNET_CONTAINER_DLL_insert_tail(head, tail, element)
Insert an element at the tail of a DLL.
const char * GNUNET_i2s(const struct GNUNET_PeerIdentity *pid)
Convert a peer identity to a string (for printing debug messages).
#define GNUNET_break(cond)
Use this for internal assertion violations that are not fatal (can be handled) but should not occur.
@ GNUNET_ERROR_TYPE_DEBUG
#define GNUNET_malloc(size)
Wrapper around malloc.
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
void GNUNET_STATISTICS_set(struct GNUNET_STATISTICS_Handle *handle, const char *name, uint64_t value, int make_persistent)
Set statistic value for the peer.
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
For each neighbour we keep a list of messages that we still want to transmit to the neighbour.
void * cont_cls
Closure for cont.
GST_NeighbourSendContinuation cont
Function to call once we're done.
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_SCHEDULER_Task * task
Main task that drives this peer (timeouts, keepalives, etc.).
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...

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:

◆ 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
Returns
how long to wait before reading more from this 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?
void GNUNET_STATISTICS_update(struct GNUNET_STATISTICS_Handle *handle, const char *name, int64_t delta, int make_persistent)
Set statistic value for the peer.
#define GNUNET_TIME_UNIT_FOREVER_REL
Constant used to specify "forever".
#define GNUNET_TIME_UNIT_ZERO
Relative time zero.
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
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.
Time for relative time used by GNUnet, in microseconds.
unsigned int quota_violation_count
How often has the other peer (recently) violated the inbound traffic limit? Incremented by 10 per vio...
struct GNUNET_BANDWIDTH_Tracker in_tracker
Tracker for inbound bandwidth.

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_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 }
static struct GNUNET_ARM_MonitorHandle * m
Monitor connection with ARM.
Definition: gnunet-arm.c:104
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.
#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...
Message a peer sends to another when connected to indicate that a session is in use and the peer is s...
uint32_t nonce
A nonce to identify the session the keep alive is used for.
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.
struct GNUNET_ATS_Session * session
Active session for this address.
struct NeighbourAddress primary_address
Primary address we currently use to communicate with the neighbour.
struct GNUNET_PeerIdentity id
Identity of this neighbour.

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.
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.
struct GNUNET_TRANSPORT_PluginFunctions * GST_plugins_find(const char *name)
Obtain the plugin API based on a plugin name.
#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?
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
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
@ GNUNET_TRANSPORT_PS_CONNECTED
Got our SYN_ACK/ACK, connection is up.
const char * transport_name
Name of the transport plugin enabling the communication using this address.
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_UpdateSessionTimeout update_session_timeout
Function that will be called whenever the transport service wants to notify the plugin that a session...
uint32_t keep_alive_nonce
The current nonce sent in the last keep alive messages.
struct GNUNET_HELLO_Address * address
Network-level address information.
int expect_latency_response
Did we sent an KEEP_ALIVE message and are we expecting a response?
enum GNUNET_TRANSPORT_PeerState state
The current state of the peer.
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").

◆ GST_neighbours_force_disconnect()

void GST_neighbours_force_disconnect ( const struct GNUNET_PeerIdentity target)

If we have an active connection to the given target, it must be shutdown.

Parameters
targetpeer to disconnect from

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

3871 {
3872  struct NeighbourMapEntry *n;
3873 
3874  if (NULL == (n = lookup_neighbour (target)))
3875  return; /* not active */
3876  if (GNUNET_YES == test_connected (n))
3878  gettext_noop (
3879  "# disconnected from peer upon explicit request"),
3880  1,
3881  GNUNET_NO);
3883  "Forced disconnect from peer %s\n",
3884  GNUNET_i2s (target));
3886 }
static void disconnect_neighbour(struct NeighbourMapEntry *n)
Disconnect from the given neighbour, clean up the record.
@ GNUNET_ERROR_TYPE_INFO

References disconnect_neighbour(), gettext_noop, GNUNET_ERROR_TYPE_INFO, GNUNET_i2s(), GNUNET_log, GNUNET_NO, GNUNET_STATISTICS_update(), GNUNET_YES, GST_stats, lookup_neighbour(), and test_connected().

Referenced by ats_request_address_change(), and confirm_or_drop_neighbour().

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

◆ GST_neighbours_iterate()

void GST_neighbours_iterate ( GST_NeighbourIterator  cb,
void *  cb_cls 
)

Iterate over all connected neighbours.

Parameters
cbfunction to call
cb_clsclosure for cb

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

3851 {
3852  struct IteratorContext ic;
3853 
3854  if (NULL == neighbours)
3855  return; /* can happen during shutdown */
3856  ic.cb = cb;
3857  ic.cb_cls = cb_cls;
3860  &ic);
3861 }
static int neighbours_iterate(void *cls, const struct GNUNET_PeerIdentity *key, void *value)
Call the callback from the closure for each neighbour.
Closure for the neighbours_iterate() function.
GST_NeighbourIterator cb
Function to call on each connected neighbour.

References IteratorContext::cb, IteratorContext::cb_cls, GNUNET_CONTAINER_multipeermap_iterate(), neighbours, and neighbours_iterate().

Referenced by handle_client_blacklist_init(), handle_client_monitor_peers(), handle_client_start(), and process_hello_update().

Here is the call graph for this function:
Here is the caller 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.

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

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 }
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.
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...
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 free_neighbour(struct NeighbourMapEntry *n)
Free a neighbour map entry.
#define FAST_RECONNECT_TIMEOUT
How long are we willing to wait for a successful reconnect if an existing connection went down?...
const char * GST_plugins_a2s(const struct GNUNET_HELLO_Address *address)
Convert a given address to a human-readable format.
#define GNUNET_assert(cond)
Use this for fatal errors that cannot be handled.
@ GNUNET_ERROR_TYPE_ERROR
const char * GNUNET_TRANSPORT_ps2s(enum GNUNET_TRANSPORT_PeerState state)
Convert a transport state to a human readable string.
@ 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_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...
A possible address we could use to communicate with a neighbour.
struct NeighbourAddress alternative_address
Alternative address currently under consideration for communicating with the neighbour.
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_TESTBED_Peer * peer
The peer associated with this model.

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_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 }
static char * address
GNS address for this phone.
uint32_t util_total_bytes_recv
Tracking utilization of inbound bandwidth.

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 }
uint32_t util_total_bytes_sent
Tracking utilization of outbound bandwidth.

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:

◆ 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 an existing neighbour record, set the active connection to use the given address.

Parameters
addressaddress of the other peer to start using
sessionsession to use (or NULL)
bandwidth_ininbound quota to be used when connection is up
bandwidth_outoutbound quota to be used when connection is up

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.
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.
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 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 ...
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.
@ GNUNET_OK
Definition: gnunet_common.h:95
#define GNUNET_CONTAINER_DLL_insert(head, tail, element)
Insert an element at the head of a DLL.
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.
#define GNUNET_new(type)
Allocate a struct or union of the given type.
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 GST_BlacklistCheck * blc
Handle to the blacklist check we are performing.
struct GNUNET_BANDWIDTH_Value32NBO bandwidth_out
Outbound bandwidth that was assigned to address.
uint32_t value__
The actual value (bytes per second).
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:

◆ GST_neighbours_handle_session_syn()

int GST_neighbours_handle_session_syn ( const struct GNUNET_MessageHeader message,
const struct GNUNET_PeerIdentity peer 
)

We received a 'SESSION_CONNECT' 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
Returns
GNUNET_OK if the message was fine, GNUNET_SYSERR on serious error

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 struct GNUNET_PeerIdentity GST_my_identity
Our public key.
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.
@ 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.
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
#define _(String)
GNU gettext support macro.
Definition: platform.h:177
The identity of the host (wraps the signing key of the peer).
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.
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.
Message a peer sends to another to indicate that it intends to setup a connection/session for data ex...
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:

◆ 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_CONNECT_ACK' message from the other peer.

Consider switching to it.

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

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.
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.
#define GNUNET_HELLO_address_free(addr)
Free an address.
uint64_t abs_value_us
The actual value.
struct GNUNET_BANDWIDTH_Value32NBO bandwidth_in
Inbound bandwidth from ATS for this address.
struct GNUNET_TIME_Absolute connect_timestamp
Timestamp of the 'SESSION_CONNECT' message we sent to the other peer for this address.
int ats_active
Did we tell ATS that this is our 'active' address?
struct GNUNET_BANDWIDTH_Value32NBO bandwidth_out
Outbound bandwidth from ATS for this address.

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_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 'SESSION_ACK' message from the other peer.

If we sent a 'CONNECT_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

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.
@ GNUNET_ERROR_TYPE_WARNING
Header for all communications.

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

const struct GNUNET_HELLO_Address* GST_neighbour_get_current_address ( const struct GNUNET_PeerIdentity peer)

Obtain current address information for the given neighbour.

Parameters
peer
Returns
address currently used

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

3897 {
3898  struct NeighbourMapEntry *n;
3899 
3900  n = lookup_neighbour (peer);
3901  if (NULL == n)
3902  return NULL;
3903  return n->primary_address.address;
3904 }

References NeighbourAddress::address, lookup_neighbour(), peer, and NeighbourMapEntry::primary_address.

Referenced by handle_send_transmit_continuation().

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

◆ GST_neighbours_handle_quota_message()

void GST_neighbours_handle_quota_message ( const struct GNUNET_PeerIdentity peer,
const struct GNUNET_MessageHeader msg 
)

We received a quoat message from the given peer, validate and process.

Parameters
peersender of the message
msgthe quota message

We received a quoat message from the given peer, validate and process.

Parameters
peersender of the message
msgthe quota message

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

3659 {
3660  struct NeighbourMapEntry *n;
3661  const struct GNUNET_ATS_SessionQuotaMessage *sqm;
3662  struct GNUNET_BANDWIDTH_Value32NBO last;
3663 
3665  "Received QUOTA message from peer `%s'\n",
3666  GNUNET_i2s (peer));
3667  if (ntohs (msg->size) != sizeof(struct GNUNET_ATS_SessionQuotaMessage))
3668  {
3669  GNUNET_break_op (0);
3671  gettext_noop (
3672  "# quota messages ignored (malformed)"),
3673  1,
3674  GNUNET_NO);
3675  return;
3676  }
3678  gettext_noop
3679  ("# QUOTA messages received"),
3680  1, GNUNET_NO);
3681  sqm = (const struct GNUNET_ATS_SessionQuotaMessage *) msg;
3682  if (NULL == (n = lookup_neighbour (peer)))
3683  {
3684  /* gone already */
3685  return;
3686  }
3689  sqm->quota)));
3690  if (last.value__ != n->neighbour_receive_quota.value__)
3691  {
3692  n->neighbour_receive_quota = last;
3694  }
3695 }
static void send_outbound_quota_to_clients(struct NeighbourMapEntry *n)
Send information about a new outbound quota to our clients.
struct GNUNET_BANDWIDTH_Value32NBO GNUNET_BANDWIDTH_value_init(uint32_t bytes_per_second)
Create a new bandwidth value.
Definition: bandwidth.c:39
struct GNUNET_BANDWIDTH_Value32NBO GNUNET_BANDWIDTH_value_max(struct GNUNET_BANDWIDTH_Value32NBO b1, struct GNUNET_BANDWIDTH_Value32NBO b2)
Compute the MAX of two bandwidth values.
Definition: bandwidth.c:72
#define GNUNET_CONSTANTS_DEFAULT_BW_IN_OUT
Bandwidth (in/out) to assume initially (before either peer has communicated any particular preference...
Message a peer sends to another when connected to indicate that the other peer should limit transmiss...
uint32_t quota
Quota to use (for sending), in bytes per second.
32-bit bandwidth used for network exchange by GNUnet, in bytes per second.
struct GNUNET_BANDWIDTH_Value32NBO neighbour_receive_quota
Latest quota the other peer send us in bytes per second.

References gettext_noop, GNUNET_BANDWIDTH_value_init(), GNUNET_BANDWIDTH_value_max(), GNUNET_break_op, GNUNET_CONSTANTS_DEFAULT_BW_IN_OUT, GNUNET_ERROR_TYPE_DEBUG, GNUNET_i2s(), GNUNET_log, GNUNET_NO, GNUNET_STATISTICS_update(), GST_stats, lookup_neighbour(), msg, NeighbourMapEntry::neighbour_receive_quota, peer, GNUNET_ATS_SessionQuotaMessage::quota, send_outbound_quota_to_clients(), GNUNET_MessageHeader::size, and GNUNET_BANDWIDTH_Value32NBO::value__.

Here is the call graph for this function:

◆ GST_neighbours_handle_disconnect_message()

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.

Parameters
peersender of the message
msgthe disconnect message

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

3710 {
3711  struct NeighbourMapEntry *n;
3712  const struct GNUNET_ATS_SessionDisconnectMessage *sdm;
3713 
3715  "Received DISCONNECT message from peer `%s'\n",
3716  GNUNET_i2s (peer));
3717  if (ntohs (msg->size) != sizeof(struct GNUNET_ATS_SessionDisconnectMessage))
3718  {
3719  GNUNET_break_op (0);
3721  gettext_noop
3722  ("# disconnect messages ignored (malformed)"),
3723  1,
3724  GNUNET_NO);
3725  return;
3726  }
3728  gettext_noop
3729  ("# DISCONNECT messages received"),
3730  1, GNUNET_NO);
3731  sdm = (const struct GNUNET_ATS_SessionDisconnectMessage *) msg;
3732  if (NULL == (n = lookup_neighbour (peer)))
3733  {
3734  /* gone already */
3735  return;
3736  }
3739  {
3741  gettext_noop (
3742  "# disconnect messages ignored (timestamp)"),
3743  1,
3744  GNUNET_NO);
3745  return;
3746  }
3747  if (0 != memcmp (peer,
3748  &sdm->public_key,
3749  sizeof(struct GNUNET_PeerIdentity)))
3750  {
3751  GNUNET_break_op (0);
3752  return;
3753  }
3754  if (ntohl (sdm->purpose.size) !=
3755  sizeof(struct GNUNET_CRYPTO_EccSignaturePurpose)
3756  + sizeof(struct GNUNET_CRYPTO_EddsaPublicKey)
3757  + sizeof(struct GNUNET_TIME_AbsoluteNBO))
3758  {
3760  "DISCONNECT message from peer `%s' has invalid size\n",
3761  GNUNET_i2s (peer));
3762  GNUNET_break_op (0);
3763  return;
3764  }
3765  if (GNUNET_OK !=
3768  &sdm->purpose,
3769  &sdm->signature,
3770  &sdm->public_key))
3771  {
3773  "DISCONNECT message from peer `%s' cannot be verified \n",
3774  GNUNET_i2s (peer));
3775  GNUNET_break_op (0);
3776  return;
3777  }
3778  if (NULL == n->delayed_disconnect_task)
3779  {
3781  n);
3782  }
3783 }
static void delayed_disconnect(void *cls)
Task to asynchronously run free_neighbour().
int GNUNET_CRYPTO_eddsa_verify_(uint32_t purpose, const struct GNUNET_CRYPTO_EccSignaturePurpose *validate, const struct GNUNET_CRYPTO_EddsaSignature *sig, const struct GNUNET_CRYPTO_EddsaPublicKey *pub)
Verify EdDSA signature.
Definition: crypto_ecc.c:682
#define GNUNET_MESSAGE_TYPE_TRANSPORT_SESSION_DISCONNECT
Transport DISCONNECT message exchanged between transport services to indicate that a connection shoul...
Message we send to the other peer to notify it that we intentionally are disconnecting (to reduce tim...
struct GNUNET_TIME_AbsoluteNBO timestamp
Absolute time at the sender.
struct GNUNET_CRYPTO_EccSignaturePurpose purpose
Purpose of the signature.
struct GNUNET_CRYPTO_EddsaSignature signature
Signature of the peer that sends us the disconnect.
struct GNUNET_CRYPTO_EddsaPublicKey public_key
Public key of the sender.
header of what an ECC signature signs this must be followed by "size - 8" bytes of the actual signed ...
uint32_t size
How many bytes does this signature sign? (including this purpose header); in network byte order (!...
Public ECC key (always for curve Ed25519) encoded in a format suitable for network transmission and E...
Time for absolute time used by GNUnet, in microseconds and in network byte order.
struct GNUNET_SCHEDULER_Task * delayed_disconnect_task
Task to disconnect neighbour after we received a DISCONNECT message.

References GNUNET_TIME_Absolute::abs_value_us, NeighbourMapEntry::connect_ack_timestamp, delayed_disconnect(), NeighbourMapEntry::delayed_disconnect_task, gettext_noop, GNUNET_break_op, GNUNET_CRYPTO_eddsa_verify_(), GNUNET_ERROR_TYPE_DEBUG, GNUNET_i2s(), GNUNET_log, GNUNET_MESSAGE_TYPE_TRANSPORT_SESSION_DISCONNECT, GNUNET_NO, GNUNET_OK, GNUNET_SCHEDULER_add_now(), GNUNET_STATISTICS_update(), GNUNET_TIME_absolute_ntoh(), GST_stats, lookup_neighbour(), msg, peer, GNUNET_ATS_SessionDisconnectMessage::public_key, GNUNET_ATS_SessionDisconnectMessage::purpose, GNUNET_ATS_SessionDisconnectMessage::signature, GNUNET_MessageHeader::size, GNUNET_CRYPTO_EccSignaturePurpose::size, and GNUNET_ATS_SessionDisconnectMessage::timestamp.

Here is the call graph for this function: