GNUnet  0.10.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 72 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 3770 of file gnunet-service-transport_neighbours.c.

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

Referenced by run().

3771 {
3772  (void) max_fds;
3774  GNUNET_NO);
3777  NULL);
3778 }
static struct GNUNET_CONTAINER_MultiPeerMap * neighbours
Hash map from peer identities to the respective struct NeighbourMapEntry.
#define GNUNET_NO
Definition: gnunet_common.h:81
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:1246
#define UTIL_TRANSMISSION_INTERVAL
Interval to send utilization data.
static struct GNUNET_SCHEDULER_Task * util_transmission_tk
Task transmitting utilization data.
#define NEIGHBOUR_TABLE_SIZE
Size of the neighbour hash map.
static void utilization_transmission(void *cls)
Task transmitting utilization in a regular interval.
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 3810 of file gnunet-service-transport_neighbours.c.

References disconnect_all_neighbours(), GNUNET_CONTAINER_multipeermap_destroy(), GNUNET_CONTAINER_multipeermap_iterate(), and GNUNET_SCHEDULER_cancel().

Referenced by shutdown_task().

3811 {
3812  if (NULL == neighbours)
3813  return;
3814  if (NULL != util_transmission_tk)
3815  {
3817  util_transmission_tk = NULL;
3818  }
3821  NULL);
3823  neighbours = NULL;
3824 }
static struct GNUNET_CONTAINER_MultiPeerMap * neighbours
Hash map from peer identities to the respective struct NeighbourMapEntry.
void GNUNET_CONTAINER_multipeermap_destroy(struct GNUNET_CONTAINER_MultiPeerMap *map)
Destroy a hash map.
static struct GNUNET_SCHEDULER_Task * util_transmission_tk
Task transmitting 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.
static int disconnect_all_neighbours(void *cls, const struct GNUNET_PeerIdentity *key, void *value)
Disconnect from the given neighbour.
void * GNUNET_SCHEDULER_cancel(struct GNUNET_SCHEDULER_Task *task)
Cancel the task with the specified identifier.
Definition: scheduler.c:965
Here is the call graph for this function:
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 3490 of file gnunet-service-transport_neighbours.c.

References lookup_neighbour(), and test_connected().

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

3491 {
3492  return test_connected (lookup_neighbour (target));
3493 }
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.
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 1750 of file gnunet-service-transport_neighbours.c.

References bytes_in_send_queue, MessageQueue::cont, MessageQueue::cont_cls, gettext_noop, GNUNET_break, GNUNET_CONTAINER_DLL_insert_tail, GNUNET_ERROR_TYPE_DEBUG, GNUNET_i2s(), GNUNET_log, GNUNET_malloc, GNUNET_memcpy, GNUNET_NO, GNUNET_SCHEDULER_add_now(), GNUNET_SCHEDULER_cancel(), GNUNET_STATISTICS_set(), GNUNET_SYSERR, GNUNET_TIME_relative_to_absolute(), GNUNET_YES, GST_stats, lookup_neighbour(), master_task(), MessageQueue::message_buf, MessageQueue::message_buf_size, NeighbourMapEntry::messages_head, NeighbourMapEntry::messages_tail, mq, NeighbourMapEntry::task, test_connected(), and MessageQueue::timeout.

Referenced by GST_manipulation_send(), send_delayed(), and transmit_our_hello().

1756 {
1757  struct NeighbourMapEntry *n;
1758  struct MessageQueue *mq;
1759 
1760  /* All ove these cases should never happen; they are all API violations.
1761  But we check anyway, just to be sure. */
1762  if (NULL == (n = lookup_neighbour (target)))
1763  {
1764  GNUNET_break (0);
1765  if (NULL != cont)
1766  cont (cont_cls,
1767  GNUNET_SYSERR,
1768  msg_size,
1769  0);
1770  return;
1771  }
1772  if (GNUNET_YES != test_connected (n))
1773  {
1774  GNUNET_break (0);
1775  if (NULL != cont)
1776  cont (cont_cls,
1777  GNUNET_SYSERR,
1778  msg_size,
1779  0);
1780  return;
1781  }
1782  bytes_in_send_queue += msg_size;
1784  gettext_noop
1785  ("# bytes in message queue for other peers"),
1787  mq = GNUNET_malloc (sizeof (struct MessageQueue) + msg_size);
1788  mq->cont = cont;
1789  mq->cont_cls = cont_cls;
1790  GNUNET_memcpy (&mq[1], msg, msg_size);
1791  mq->message_buf = (const char *) &mq[1];
1792  mq->message_buf_size = msg_size;
1793  mq->timeout = GNUNET_TIME_relative_to_absolute (timeout);
1794 
1796  "Enqueueing %u bytes to send to peer %s\n",
1797  (unsigned int) msg_size,
1798  GNUNET_i2s (target));
1800  n->messages_tail,
1801  mq);
1802  if (NULL != n->task)
1805 }
struct GNUNET_MessageHeader * msg
Definition: 005.c:2
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:245
struct GNUNET_TIME_Absolute timeout
At what time should we fail?
#define GNUNET_NO
Definition: gnunet_common.h:81
#define GNUNET_break(cond)
Use this for internal assertion violations that are not fatal (can be handled) but should not occur...
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...
static struct GNUNET_STATISTICS_Handle * GST_stats
Statistics handle.
#define GNUNET_memcpy(dst, src, n)
static int test_connected(struct NeighbourMapEntry *n)
Test if we're connected to the given peer.
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:1273
void * cont_cls
Closure for cont.
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_SCHEDULER_Task * task
Main task that drives this peer (timeouts, keepalives, etc.).
void GNUNET_STATISTICS_set(struct GNUNET_STATISTICS_Handle *handle, const char *name, uint64_t value, int make_persistent)
Set statistic value for the peer.
static struct NeighbourMapEntry * lookup_neighbour(const struct GNUNET_PeerIdentity *pid)
Lookup a neighbour entry in the neighbours hash map.
static unsigned long long bytes_in_send_queue
Number of bytes we have currently queued for transmission.
const char * message_buf
The message(s) we want to transmit, GNUNET_MessageHeader(s) stuck together in memory.
#define GNUNET_SYSERR
Definition: gnunet_common.h:79
#define GNUNET_CONTAINER_DLL_insert_tail(head, tail, element)
Insert an element at the tail of a DLL.
GST_NeighbourSendContinuation cont
Function to call once we're done.
struct GNUNET_MQ_Handle * mq
Definition: 003.c:5
#define GNUNET_log(kind,...)
#define GNUNET_YES
Definition: gnunet_common.h:80
static void master_task(void *cls)
Master task run for every neighbour.
size_t message_buf_size
Size of the message buf.
const char * GNUNET_i2s(const struct GNUNET_PeerIdentity *pid)
Convert a peer identity to a string (for printing debug messages).
#define GNUNET_malloc(size)
Wrapper around malloc.
#define gettext_noop(String)
Definition: gettext.h:69
void * GNUNET_SCHEDULER_cancel(struct GNUNET_SCHEDULER_Task *task)
Cancel the task with the specified identifier.
Definition: scheduler.c:965
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 1667 of file gnunet-service-transport_neighbours.c.

References GNUNET_BANDWIDTH_Tracker::available_bytes_per_s__, GNUNET_BANDWIDTH_Tracker::consumption_since_last_update__, gettext_noop, GNUNET_BANDWIDTH_tracker_consume(), GNUNET_BANDWIDTH_tracker_get_delay(), GNUNET_CONSTANTS_QUOTA_VIOLATION_TIMEOUT, GNUNET_ERROR_TYPE_DEBUG, GNUNET_log, GNUNET_NO, GNUNET_STATISTICS_update(), GNUNET_STRINGS_relative_time_to_string(), GNUNET_SYSERR, GNUNET_TIME_UNIT_FOREVER_REL, GNUNET_TIME_UNIT_ZERO, GNUNET_YES, GST_stats, NeighbourMapEntry::in_tracker, lookup_neighbour(), NeighbourMapEntry::quota_violation_count, QUOTA_VIOLATION_DROP_THRESHOLD, GNUNET_TIME_Relative::rel_value_us, ret, size, and test_connected().

Referenced by inbound_bw_tracker_update(), and process_payload().

1670 {
1671  struct NeighbourMapEntry *n;
1672  struct GNUNET_TIME_Relative ret;
1673 
1674  if (NULL == neighbours)
1675  {
1676  *do_forward = GNUNET_NO;
1677  return GNUNET_TIME_UNIT_FOREVER_REL; /* This can happen during shutdown */
1678  }
1679  if (NULL == (n = lookup_neighbour (sender)))
1680  {
1682  gettext_noop ("# messages discarded due to lack of neighbour record"),
1683  1,
1684  GNUNET_NO);
1685  *do_forward = GNUNET_NO;
1686  return GNUNET_TIME_UNIT_ZERO;
1687  }
1688  if (! test_connected (n))
1689  {
1690  *do_forward = GNUNET_SYSERR;
1691  return GNUNET_TIME_UNIT_ZERO;
1692  }
1694  {
1695  n->quota_violation_count++;
1697  "Bandwidth quota (%u b/s) violation detected (total of %u).\n",
1700  /* Discount 32k per violation */
1701  GNUNET_BANDWIDTH_tracker_consume (&n->in_tracker, -32 * 1024);
1702  }
1703  else
1704  {
1705  if (n->quota_violation_count > 0)
1706  {
1707  /* try to add 32k back */
1709  n->quota_violation_count--;
1710  }
1711  }
1713  {
1715  gettext_noop
1716  ("# bandwidth quota violations by other peers"),
1717  1, GNUNET_NO);
1718  *do_forward = GNUNET_NO;
1720  }
1721  *do_forward = GNUNET_YES;
1723  if (ret.rel_value_us > 0)
1724  {
1726  "Throttling read (%lld bytes excess at %u b/s), waiting %s before reading more.\n",
1728  (unsigned int) n->in_tracker.available_bytes_per_s__,
1731  gettext_noop ("# ms throttling suggested"),
1732  (int64_t) ret.rel_value_us / 1000LL,
1733  GNUNET_NO);
1734  }
1735  return ret;
1736 }
static struct GNUNET_CONTAINER_MultiPeerMap * neighbours
Hash map from peer identities to the respective struct NeighbourMapEntry.
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
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.
#define GNUNET_NO
Definition: gnunet_common.h:81
void GNUNET_STATISTICS_update(struct GNUNET_STATISTICS_Handle *handle, const char *name, int64_t delta, int make_persistent)
Set statistic value for the peer.
static int ret
Final status code.
Definition: gnunet-arm.c:89
static struct GNUNET_STATISTICS_Handle * GST_stats
Statistics handle.
int64_t consumption_since_last_update__
Number of bytes consumed since we last updated the tracker.
static int test_connected(struct NeighbourMapEntry *n)
Test if we're connected to the given peer.
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:727
#define GNUNET_TIME_UNIT_FOREVER_REL
Constant used to specify "forever".
#define GNUNET_CONSTANTS_QUOTA_VIOLATION_TIMEOUT
How long do we delay reading more from a peer after a quota violation?
static struct NeighbourMapEntry * lookup_neighbour(const struct GNUNET_PeerIdentity *pid)
Lookup a neighbour entry in the neighbours hash map.
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 QUOTA_VIOLATION_DROP_THRESHOLD
How often must a peer violate bandwidth quotas before we start to simply drop its messages...
#define GNUNET_SYSERR
Definition: gnunet_common.h:79
static unsigned int size
Size of the "table".
Definition: peer.c:67
#define GNUNET_TIME_UNIT_ZERO
Relative time zero.
uint32_t available_bytes_per_s__
Bandwidth limit to enforce in bytes per second.
#define GNUNET_log(kind,...)
#define GNUNET_YES
Definition: gnunet_common.h:80
Time for relative time used by GNUnet, in microseconds.
#define gettext_noop(String)
Definition: gettext.h:69
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 1497 of file gnunet-service-transport_neighbours.c.

References gettext_noop, GNUNET_break_op, GNUNET_ERROR_TYPE_DEBUG, GNUNET_i2s(), GNUNET_log, GNUNET_MESSAGE_TYPE_TRANSPORT_SESSION_KEEPALIVE_RESPONSE, GNUNET_NO, GNUNET_STATISTICS_update(), GNUNET_TIME_UNIT_FOREVER_REL, GNUNET_YES, GST_stats, GNUNET_ATS_SessionKeepAliveMessage::header, NeighbourMapEntry::id, lookup_neighbour(), GNUNET_ATS_SessionKeepAliveMessage::nonce, NeighbourMapEntry::primary_address, send_with_session(), NeighbourAddress::session, GNUNET_MessageHeader::size, and GNUNET_MessageHeader::type.

Referenced by GST_receive_callback().

1499 {
1500  struct NeighbourMapEntry *n;
1501  const struct GNUNET_ATS_SessionKeepAliveMessage *msg_in;
1503 
1504  if (sizeof (struct GNUNET_ATS_SessionKeepAliveMessage) != ntohs (m->size))
1505  {
1506  GNUNET_break_op (0);
1507  return;
1508  }
1509 
1510  msg_in = (const struct GNUNET_ATS_SessionKeepAliveMessage *) m;
1511  if (NULL == (n = lookup_neighbour (neighbour)))
1512  {
1514  gettext_noop
1515  ("# KEEPALIVE messages discarded (peer unknown)"),
1516  1, GNUNET_NO);
1517  return;
1518  }
1519  if (NULL == n->primary_address.session)
1520  {
1522  gettext_noop
1523  ("# KEEPALIVE messages discarded (no session)"),
1524  1, GNUNET_NO);
1525  return;
1526  }
1527 
1529  "Received KEEPALIVE request from peer `%s' with nonce %u\n",
1530  GNUNET_i2s (&n->id),
1531  ntohl (msg_in->nonce));
1533  gettext_noop ("# KEEPALIVES received in good order"),
1534  1,
1535  GNUNET_NO);
1536 
1537  /* send reply to allow neighbour to measure latency */
1538  msg.header.size = htons (sizeof (struct GNUNET_ATS_SessionKeepAliveMessage));
1540  msg.nonce = msg_in->nonce;
1541  (void) send_with_session (n,
1542  &msg,
1543  sizeof (struct GNUNET_ATS_SessionKeepAliveMessage),
1544  UINT32_MAX /* priority */,
1546  GNUNET_YES,
1547  NULL, NULL);
1548 }
struct GNUNET_MessageHeader * msg
Definition: 005.c:2
#define GNUNET_NO
Definition: gnunet_common.h:81
uint16_t size
The length of the struct (in bytes, including the length field itself), in big-endian format...
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_MESSAGE_TYPE_TRANSPORT_SESSION_KEEPALIVE_RESPONSE
Response to a GNUNET_MESSAGE_TYPE_TRANSPORT_SESSION_KEEPALIVE message to measure latency in a regular...
uint16_t type
The type of the message (GNUNET_MESSAGE_TYPE_XXXX), in big-endian format.
static struct GNUNET_STATISTICS_Handle * GST_stats
Statistics handle.
struct NeighbourAddress primary_address
Primary address we currently use to communicate with the neighbour.
#define GNUNET_break_op(cond)
Use this for assertion violations caused by other peers (i.e.
#define GNUNET_TIME_UNIT_FOREVER_REL
Constant used to specify "forever".
struct GNUNET_PeerIdentity id
Identity of this neighbour.
struct GNUNET_ATS_Session * session
Active session for this address.
static struct NeighbourMapEntry * lookup_neighbour(const struct GNUNET_PeerIdentity *pid)
Lookup a neighbour entry in the neighbours hash map.
Message a peer sends to another when connected to indicate that a session is in use and the peer is s...
#define GNUNET_log(kind,...)
#define GNUNET_YES
Definition: gnunet_common.h:80
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.
uint32_t nonce
A nonce to identify the session the keep alive is used for.
const char * GNUNET_i2s(const struct GNUNET_PeerIdentity *pid)
Convert a peer identity to a string (for printing debug messages).
#define gettext_noop(String)
Definition: gettext.h:69
Here is the call graph for this function:
Here is the caller 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 1560 of file gnunet-service-transport_neighbours.c.

References NeighbourAddress::address, GNUNET_TRANSPORT_PluginFunctions::cls, NeighbourMapEntry::expect_latency_response, gettext_noop, GNUNET_break, GNUNET_break_op, GNUNET_CONSTANTS_IDLE_CONNECTION_TIMEOUT, GNUNET_ERROR_TYPE_DEBUG, GNUNET_i2s(), GNUNET_log, GNUNET_NO, GNUNET_STATISTICS_update(), GNUNET_STRINGS_relative_time_to_string(), GNUNET_TIME_absolute_get_duration(), GNUNET_TIME_relative_divide(), GNUNET_TIME_relative_to_absolute(), GNUNET_TRANSPORT_PS_CONNECTED, GNUNET_YES, GST_ats_update_delay(), GST_plugins_find(), GST_stats, NeighbourMapEntry::id, NeighbourAddress::keep_alive_nonce, NeighbourMapEntry::last_keep_alive_time, lookup_neighbour(), msg, GNUNET_ATS_SessionKeepAliveMessage::nonce, NeighbourMapEntry::primary_address, NeighbourAddress::session, set_state_and_timeout(), GNUNET_MessageHeader::size, NeighbourMapEntry::state, GNUNET_HELLO_Address::transport_name, and GNUNET_TRANSPORT_PluginFunctions::update_session_timeout.

Referenced by GST_receive_callback().

1562 {
1563  struct NeighbourMapEntry *n;
1565  struct GNUNET_TRANSPORT_PluginFunctions *papi;
1566  struct GNUNET_TIME_Relative latency;
1567 
1568  if (sizeof (struct GNUNET_ATS_SessionKeepAliveMessage) != ntohs (m->size))
1569  {
1570  GNUNET_break_op (0);
1571  return;
1572  }
1573 
1574  msg = (const struct GNUNET_ATS_SessionKeepAliveMessage *) m;
1575  if (NULL == (n = lookup_neighbour (neighbour)))
1576  {
1578  gettext_noop ("# KEEPALIVE_RESPONSEs discarded (not connected)"),
1579  1,
1580  GNUNET_NO);
1581  return;
1582  }
1583  if ( (GNUNET_TRANSPORT_PS_CONNECTED != n->state) ||
1585  {
1587  gettext_noop ("# KEEPALIVE_RESPONSEs discarded (not expected)"),
1588  1,
1589  GNUNET_NO);
1590  return;
1591  }
1592  if (NULL == n->primary_address.address)
1593  {
1595  gettext_noop ("# KEEPALIVE_RESPONSEs discarded (address changed)"),
1596  1,
1597  GNUNET_NO);
1598  return;
1599  }
1600  if (n->primary_address.keep_alive_nonce != ntohl (msg->nonce))
1601  {
1602  if (0 == n->primary_address.keep_alive_nonce)
1604  gettext_noop ("# KEEPALIVE_RESPONSEs discarded (no nonce)"),
1605  1,
1606  GNUNET_NO);
1607  else
1609  gettext_noop ("# KEEPALIVE_RESPONSEs discarded (bad nonce)"),
1610  1,
1611  GNUNET_NO);
1612  return;
1613  }
1615  gettext_noop ("# KEEPALIVE_RESPONSEs received (OK)"),
1616  1,
1617  GNUNET_NO);
1618 
1619 
1620  /* Update session timeout here */
1621  if (NULL != (papi = GST_plugins_find (n->primary_address.address->transport_name)))
1622  {
1624  "Updating session for peer `%s' for session %p\n",
1625  GNUNET_i2s (&n->id),
1627  papi->update_session_timeout (papi->cls,
1628  &n->id,
1630  }
1631  else
1632  {
1633  GNUNET_break (0);
1634  }
1635 
1639  n->state,
1641 
1644  "Received KEEPALIVE_RESPONSE from peer `%s', latency is %s\n",
1645  GNUNET_i2s (&n->id),
1647  GNUNET_YES));
1649  GNUNET_TIME_relative_divide (latency,
1650  2));
1651 }
struct GNUNET_MessageHeader * msg
Definition: 005.c:2
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:245
Each plugin is required to return a pointer to a struct of this type as the return value from its ent...
#define GNUNET_NO
Definition: gnunet_common.h:81
uint16_t size
The length of the struct (in bytes, including the length field itself), in big-endian format...
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_break(cond)
Use this for internal assertion violations that are not fatal (can be handled) but should not occur...
GNUNET_TRANSPORT_UpdateSessionTimeout update_session_timeout
Function that will be called whenever the transport service wants to notify the plugin that a session...
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")...
static struct GNUNET_STATISTICS_Handle * GST_stats
Statistics handle.
void * cls
Closure for all of the callbacks.
struct NeighbourAddress primary_address
Primary address we currently use to communicate with the neighbour.
#define GNUNET_break_op(cond)
Use this for assertion violations caused by other peers (i.e.
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:727
const char * transport_name
Name of the transport plugin enabling the communication using this address.
struct GNUNET_PeerIdentity id
Identity of this neighbour.
struct GNUNET_ATS_Session * session
Active session for this address.
struct GNUNET_TRANSPORT_PluginFunctions * GST_plugins_find(const char *name)
Obtain the plugin API based on a plugin name.
static struct NeighbourMapEntry * lookup_neighbour(const struct GNUNET_PeerIdentity *pid)
Lookup a neighbour entry in the neighbours hash map.
struct GNUNET_HELLO_Address * address
Network-level address information.
Message a peer sends to another when connected to indicate that a session is in use and the peer is s...
enum GNUNET_TRANSPORT_PeerState state
The current state of the peer.
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.
#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:373
int expect_latency_response
Did we sent an KEEP_ALIVE message and are we expecting a response?
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.
#define GNUNET_log(kind,...)
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:525
#define GNUNET_YES
Definition: gnunet_common.h:80
Got our SYN_ACK/ACK, connection is up.
uint32_t keep_alive_nonce
The current nonce sent in the last keep alive messages.
uint32_t nonce
A nonce to identify the session the keep alive is used for.
const char * GNUNET_i2s(const struct GNUNET_PeerIdentity *pid)
Convert a peer identity to a string (for printing debug messages).
Time for relative time used by GNUnet, in microseconds.
#define gettext_noop(String)
Definition: gettext.h:69
Here is the call graph for this function:
Here is the caller graph for this function:

◆ 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 3728 of file gnunet-service-transport_neighbours.c.

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

3729 {
3730  struct NeighbourMapEntry *n;
3731 
3732  if (NULL == (n = lookup_neighbour (target)))
3733  return; /* not active */
3734  if (GNUNET_YES == test_connected (n))
3736  gettext_noop ("# disconnected from peer upon explicit request"),
3737  1,
3738  GNUNET_NO);
3740  "Forced disconnect from peer %s\n",
3741  GNUNET_i2s (target));
3743 }
#define GNUNET_NO
Definition: gnunet_common.h:81
void GNUNET_STATISTICS_update(struct GNUNET_STATISTICS_Handle *handle, const char *name, int64_t delta, int make_persistent)
Set statistic value for the peer.
static struct GNUNET_STATISTICS_Handle * GST_stats
Statistics handle.
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.
static void disconnect_neighbour(struct NeighbourMapEntry *n)
Disconnect from the given neighbour, clean up the record.
#define GNUNET_log(kind,...)
#define GNUNET_YES
Definition: gnunet_common.h:80
const char * GNUNET_i2s(const struct GNUNET_PeerIdentity *pid)
Convert a peer identity to a string (for printing debug messages).
#define gettext_noop(String)
Definition: gettext.h:69
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 3707 of file gnunet-service-transport_neighbours.c.

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

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

3709 {
3710  struct IteratorContext ic;
3711 
3712  if (NULL == neighbours)
3713  return; /* can happen during shutdown */
3714  ic.cb = cb;
3715  ic.cb_cls = cb_cls;
3718  &ic);
3719 }
static struct GNUNET_CONTAINER_MultiPeerMap * neighbours
Hash map from peer identities to the respective struct NeighbourMapEntry.
Closure for the neighbours_iterate() function.
GST_NeighbourIterator cb
Function to call on each connected neighbour.
int GNUNET_CONTAINER_multipeermap_iterate(struct GNUNET_CONTAINER_MultiPeerMap *map, GNUNET_CONTAINER_PeerMapIterator it, void *it_cls)
Iterate over all entries in the map.
static int neighbours_iterate(void *cls, const struct GNUNET_PeerIdentity *key, void *value)
Call the callback from the closure for each neighbour.
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 3266 of file gnunet-service-transport_neighbours.c.

References NeighbourAddress::address, NeighbourMapEntry::alternative_address, ATS_RESPONSE_TIMEOUT, NeighbourMapEntry::expect_latency_response, FAST_RECONNECT_TIMEOUT, free_address(), free_neighbour(), GNUNET_assert, GNUNET_break, GNUNET_ERROR_TYPE_DEBUG, GNUNET_ERROR_TYPE_ERROR, GNUNET_ERROR_TYPE_INFO, GNUNET_i2s(), GNUNET_log, GNUNET_NO, GNUNET_SCHEDULER_add_now(), GNUNET_SCHEDULER_cancel(), GNUNET_TIME_relative_to_absolute(), GNUNET_TRANSPORT_ps2s(), GNUNET_TRANSPORT_PS_CONNECTED, GNUNET_TRANSPORT_PS_DISCONNECT, GNUNET_TRANSPORT_PS_DISCONNECT_FINISHED, GNUNET_TRANSPORT_PS_INIT_ATS, GNUNET_TRANSPORT_PS_NOT_CONNECTED, GNUNET_TRANSPORT_PS_RECONNECT_ATS, GNUNET_TRANSPORT_PS_RECONNECT_SENT, GNUNET_TRANSPORT_PS_SWITCH_SYN_SENT, GNUNET_TRANSPORT_PS_SYN_RECV_ACK, GNUNET_TRANSPORT_PS_SYN_RECV_ATS, GNUNET_TRANSPORT_PS_SYN_SENT, GNUNET_YES, GST_ats_is_known(), GST_plugins_a2s(), lookup_neighbour(), master_task(), 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().

3268 {
3269  struct NeighbourMapEntry *n;
3270 
3271  if (NULL == (n = lookup_neighbour (peer)))
3272  return GNUNET_NO; /* can't affect us */
3273  if (session != n->primary_address.session)
3274  {
3275  /* Free alternative address */
3276  if (session == n->alternative_address.session)
3277  {
3281  n->timeout);
3283  "Session died, cleaning up alternative address\n");
3285  }
3286  return GNUNET_NO; /* doesn't affect us further */
3287  }
3288 
3290  /* The session for neighbour's primary address died */
3291  switch (n->state)
3292  {
3294  GNUNET_break (0);
3295  free_neighbour (n);
3296  return GNUNET_YES;
3298  GNUNET_break (0);
3299  free_neighbour (n);
3300  return GNUNET_YES;
3302  /* The session used to send the SYN terminated:
3303  * this implies a connect error*/
3305  "Failed to send SYN in CONNECT_SENT with `%s' %p: session terminated\n",
3308 
3309  /* Destroy the address since it cannot be used */
3314  break;
3317  /* error on inbound session; free neighbour entirely */
3318  free_neighbour (n);
3319  return GNUNET_YES;
3321  /* Our primary connection died, try a fast reconnect */
3326  break;
3328  /* we don't have an address, how can it go down? */
3329  GNUNET_break (0);
3330  break;
3333  "Failed to send SYN in RECONNECT_SENT with `%s' %p: session terminated\n",
3336  /* Destroy the address since it cannot be used */
3341  break;
3343  /* primary went down while we were waiting for SYN_ACK on secondary;
3344  secondary as primary */
3345 
3347  "Connection `%s' %p to peer `%s' was terminated while switching, "
3348  "switching to alternative address `%s' %p\n",
3351  GNUNET_i2s (peer),
3354 
3355  /* Destroy the inbound address since it cannot be used */
3360  n->primary_address.session));
3361  memset (&n->alternative_address,
3362  0,
3363  sizeof (struct NeighbourAddress));
3367  break;
3370  break;
3372  /* neighbour was freed and plugins told to terminate session */
3373  return GNUNET_NO;
3374  default:
3376  "Unhandled state `%s'\n",
3378  GNUNET_break (0);
3379  break;
3380  }
3381  if (NULL != n->task)
3384  return GNUNET_YES;
3385 }
Connection got into trouble, rest of the system still believes it to be up, but we're getting a new a...
We have some primary connection, but ATS suggested we switch to some alternative; we now sent a SYN m...
Sent SYN over new address (either by ATS telling us to switch addresses or from RECONNECT_ATS); if th...
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.
struct NeighbourAddress alternative_address
Alternative address currently under consideration for communicating with the neighbour.
We're finished with the disconnect; and are cleaning up the state now! We put the struct into this st...
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:245
struct GNUNET_TIME_Absolute timeout
Time where we should cut the connection (timeout) if we don't make progress in the state machine (or ...
#define GNUNET_assert(cond)
Use this for fatal errors that cannot be handled.
#define GNUNET_NO
Definition: gnunet_common.h:81
Received a SYN, asking ATS about address suggestions.
#define GNUNET_break(cond)
Use this for internal assertion violations that are not fatal (can be handled) but should not occur...
static void free_neighbour(struct NeighbourMapEntry *n)
Free a neighbour map entry.
Fresh peer or completely disconnected.
struct NeighbourAddress primary_address
Primary address we currently use to communicate with the neighbour.
A possible address we could use to communicate with a neighbour.
#define FAST_RECONNECT_TIMEOUT
How long are we willing to wait for a successful reconnect if an existing connection went down...
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:1273
struct GNUNET_ATS_Session * session
Active session for this address.
Asked to initiate connection, trying to get address from ATS.
const char * GST_plugins_a2s(const struct GNUNET_HELLO_Address *address)
Convert a given address to a human-readable format.
struct GNUNET_SCHEDULER_Task * task
Main task that drives this peer (timeouts, keepalives, etc.).
static struct NeighbourMapEntry * lookup_neighbour(const struct GNUNET_PeerIdentity *pid)
Lookup a neighbour entry in the neighbours hash map.
const char * GNUNET_TRANSPORT_ps2s(enum GNUNET_TRANSPORT_PeerState state)
Convert a transport state to a human readable string.
struct GNUNET_HELLO_Address * address
Network-level address information.
Sent SYN message to other peer, waiting for SYN_ACK.
enum GNUNET_TRANSPORT_PeerState state
The current state of the peer.
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.
int expect_latency_response
Did we sent an KEEP_ALIVE message and are we expecting a response?
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...
Disconnect in progress (we're sending the DISCONNECT message to the other peer; after that is finishe...
#define ATS_RESPONSE_TIMEOUT
How long are we willing to wait for a response from ATS before timing out?
#define GNUNET_log(kind,...)
#define GNUNET_YES
Definition: gnunet_common.h:80
Got our SYN_ACK/ACK, connection is up.
static void master_task(void *cls)
Master task run for every neighbour.
const char * GNUNET_i2s(const struct GNUNET_PeerIdentity *pid)
Convert a peer identity to a string (for printing debug messages).
SYN request from other peer was SYN_ACK'ed, waiting for ACK.
void * GNUNET_SCHEDULER_cancel(struct GNUNET_SCHEDULER_Task *task)
Cancel the task with the specified identifier.
Definition: scheduler.c:965
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 2896 of file gnunet-service-transport_neighbours.c.

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

Referenced by GST_receive_callback().

2898 {
2899  struct NeighbourMapEntry *n;
2900 
2901  n = lookup_neighbour (&address->peer);
2902  if (NULL == n)
2903  return;
2904  n->util_total_bytes_recv += ntohs (message->size);
2905 }
uint32_t util_total_bytes_recv
Tracking utilization of inbound bandwidth.
uint16_t size
The length of the struct (in bytes, including the length field itself), in big-endian format...
static struct NeighbourMapEntry * lookup_neighbour(const struct GNUNET_PeerIdentity *pid)
Lookup a neighbour entry in the neighbours hash map.
struct GNUNET_PeerIdentity peer
For which peer is this an address?
Here is the call graph for this function:
Here is the caller 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 2918 of file gnunet-service-transport_neighbours.c.

References lookup_neighbour(), GNUNET_HELLO_Address::peer, NeighbourMapEntry::primary_address, NeighbourAddress::session, size, and NeighbourMapEntry::util_total_bytes_sent.

Referenced by GST_validation_handle_ping(), multicast_pong(), send_syn(), send_with_session(), and transmit_ping_if_allowed().

2921 {
2922  struct NeighbourMapEntry *n;
2923 
2924  n = lookup_neighbour (&address->peer);
2925  if (NULL == n)
2926  return;
2927  if (n->primary_address.session != session)
2928  return;
2930 }
struct NeighbourAddress primary_address
Primary address we currently use to communicate with the neighbour.
uint32_t util_total_bytes_sent
Tracking utilization of outbound bandwidth.
struct GNUNET_ATS_Session * session
Active session for this address.
static struct NeighbourMapEntry * lookup_neighbour(const struct GNUNET_PeerIdentity *pid)
Lookup a neighbour entry in the neighbours hash map.
static unsigned int size
Size of the "table".
Definition: peer.c:67
struct GNUNET_PeerIdentity peer
For which peer is this an 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 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 2758 of file gnunet-service-transport_neighbours.c.

References 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(), GNUNET_HELLO_Address::peer, switch_address_bl_check_cont(), GNUNET_HELLO_Address::transport_name, try_run_fast_ats_update(), and GNUNET_BANDWIDTH_Value32NBO::value__.

Referenced by ats_request_address_change().

2762 {
2763  struct GST_BlacklistCheck *blc;
2764  struct BlacklistCheckSwitchContext *blc_ctx;
2765 
2766  GNUNET_assert (NULL != address->transport_name);
2767  if (GNUNET_OK ==
2768  try_run_fast_ats_update (address,
2769  session,
2770  bandwidth_in,
2771  bandwidth_out))
2772  return;
2773 
2774  /* Check if plugin is available */
2775  if (NULL == (GST_plugins_find (address->transport_name)))
2776  {
2777  /* we don't have the plugin for this address */
2778  GNUNET_break (0);
2779  GST_ats_block_address (address,
2780  session);
2781  return;
2782  }
2783  if ((NULL == session) &&
2786  {
2787  /* This is a inbound address and we do not have a session to use! */
2788  GNUNET_break (0);
2789  GST_ats_block_address (address,
2790  session);
2791  return;
2792  }
2793 
2795  "ATS suggests address '%s' for peer `%s' at %u/%u speed\n",
2796  GST_plugins_a2s (address),
2797  GNUNET_i2s (&address->peer),
2798  (unsigned int) ntohl (bandwidth_in.value__),
2799  (unsigned int) ntohl (bandwidth_out.value__));
2800 
2801  /* Perform blacklist check */
2802  blc_ctx = GNUNET_new (struct BlacklistCheckSwitchContext);
2803  blc_ctx->bandwidth_in = bandwidth_in;
2804  blc_ctx->bandwidth_out = bandwidth_out;
2807  blc_ctx);
2808  if (NULL != (blc = GST_blacklist_test_allowed (&address->peer,
2809  address->transport_name,
2811  blc_ctx,
2812  address,
2813  session)))
2814  {
2815  blc_ctx->blc = blc;
2816  }
2817 }
Context we use when performing a blacklist check.
#define GNUNET_CONTAINER_DLL_insert(head, tail, element)
Insert an element at the head of a DLL.
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.
struct GST_BlacklistCheck * blc
Handle to the blacklist check we are performing.
#define GNUNET_assert(cond)
Use this for fatal errors that cannot be handled.
struct GNUNET_BANDWIDTH_Value32NBO bandwidth_in
Inbound bandwidth that was assigned to address.
#define GNUNET_OK
Named constants for return values.
Definition: gnunet_common.h:78
#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.
#define GNUNET_break(cond)
Use this for internal assertion violations that are not fatal (can be handled) but should not occur...
uint32_t value__
The actual value (bytes per second).
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
This is an inbound address and cannot be used to initiate an outbound connection to another peer...
const char * transport_name
Name of the transport plugin enabling the communication using this address.
static struct BlacklistCheckSwitchContext * pending_bc_tail
List of pending blacklist checks: tail.
const char * GST_plugins_a2s(const struct GNUNET_HELLO_Address *address)
Convert a given address to a human-readable format.
struct GNUNET_TRANSPORT_PluginFunctions * GST_plugins_find(const char *name)
Obtain the plugin API based on a plugin name.
struct GNUNET_BANDWIDTH_Value32NBO bandwidth_out
Outbound bandwidth that was assigned to address.
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 ...
struct GNUNET_PeerIdentity peer
For which peer is this an address?
static struct BlacklistCheckSwitchContext * pending_bc_head
List of pending blacklist checks: head.
#define GNUNET_log(kind,...)
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...
const char * GNUNET_i2s(const struct GNUNET_PeerIdentity *pid)
Convert a peer identity to a string (for printing debug messages).
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.
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 2248 of file gnunet-service-transport_neighbours.c.

References _, ACK_SEND_ACK, ACK_SEND_SYN_ACK, NeighbourMapEntry::ack_state, NeighbourAddress::address, ATS_RESPONSE_TIMEOUT, NeighbourMapEntry::connect_ack_timestamp, free_neighbour(), gettext_noop, GNUNET_assert, GNUNET_break, GNUNET_break_op, GNUNET_ERROR_TYPE_ERROR, GNUNET_ERROR_TYPE_INFO, GNUNET_i2s(), GNUNET_log, GNUNET_NO, GNUNET_OK, GNUNET_STATISTICS_update(), GNUNET_SYSERR, GNUNET_TIME_absolute_ntoh(), GNUNET_TIME_relative_to_absolute(), GNUNET_TRANSPORT_ps2s(), GNUNET_TRANSPORT_PS_CONNECTED, GNUNET_TRANSPORT_PS_DISCONNECT, GNUNET_TRANSPORT_PS_DISCONNECT_FINISHED, GNUNET_TRANSPORT_PS_INIT_ATS, GNUNET_TRANSPORT_PS_NOT_CONNECTED, GNUNET_TRANSPORT_PS_RECONNECT_ATS, GNUNET_TRANSPORT_PS_RECONNECT_SENT, GNUNET_TRANSPORT_PS_SWITCH_SYN_SENT, GNUNET_TRANSPORT_PS_SYN_RECV_ACK, GNUNET_TRANSPORT_PS_SYN_RECV_ATS, GNUNET_TRANSPORT_PS_SYN_SENT, GST_my_identity, GST_stats, lookup_neighbour(), 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().

2250 {
2251  const struct TransportSynMessage *scm;
2252  struct NeighbourMapEntry *n;
2253  struct GNUNET_TIME_Absolute ts;
2254 
2255  if (ntohs (message->size) != sizeof (struct TransportSynMessage))
2256  {
2257  GNUNET_break_op (0);
2258  return GNUNET_SYSERR;
2259  }
2261  gettext_noop
2262  ("# SYN messages received"),
2263  1, GNUNET_NO);
2264  if (NULL == neighbours)
2265  {
2267  _("SYN request from peer `%s' ignored due impending shutdown\n"),
2268  GNUNET_i2s (peer));
2269  return GNUNET_OK; /* we're shutting down */
2270  }
2271  scm = (const struct TransportSynMessage *) message;
2272  GNUNET_break_op (0 == ntohl (scm->reserved));
2274  if (0 ==
2275  memcmp (&GST_my_identity,
2276  peer,
2277  sizeof (struct GNUNET_PeerIdentity)))
2278  {
2279  /* loopback connection-to-self, ignore */
2280  return GNUNET_SYSERR;
2281  }
2282  n = lookup_neighbour (peer);
2283  if (NULL == n)
2284  {
2285  /* This is a new neighbour and set to not connected */
2286  n = setup_neighbour (peer);
2287  GNUNET_assert (NULL != n);
2288  }
2289 
2290  /* Remember this SYN message in neighbour */
2292  n->connect_ack_timestamp = ts;
2293 
2295  "Received SYN for peer `%s' in state %s/%s\n",
2296  GNUNET_i2s (peer),
2298  print_ack_state (n->ack_state));
2299 
2300  switch (n->state)
2301  {
2303  /* Request an address from ATS to send SYN_ACK to this peer */
2307  break;
2309  /* SYN message takes priority over us asking ATS for address:
2310  * Wait for ATS to suggest an address and send SYN_ACK */
2314  break;
2316  /* We already wait for an address to send an SYN_ACK */
2317  break;
2320  /* Send ACK immediately */
2321  n->ack_state = ACK_SEND_ACK;
2323  ts);
2324  break;
2326  /* we are already connected and can thus send the ACK immediately */
2327  GNUNET_assert (NULL != n->primary_address.address);
2328  GNUNET_assert (NULL != n->primary_address.session);
2329  n->ack_state = ACK_SEND_ACK;
2331  ts);
2332  break;
2334  /* We wait for ATS address suggestion */
2335  break;
2337  /* We received a SYN message while waiting for a SYN_ACK in fast
2338  * reconnect. Send SYN_ACK immediately */
2339  n->ack_state = ACK_SEND_ACK;
2342  break;
2344  /* We are already connected and can thus send the ACK immediately;
2345  still, it can never hurt to have an alternative address, so also
2346  tell ATS about it */
2347  GNUNET_assert (NULL != n->primary_address.address);
2348  GNUNET_assert (NULL != n->primary_address.session);
2349  n->ack_state = ACK_SEND_ACK;
2351  ts);
2352  break;
2354  /* Get rid of remains and re-try */
2355  free_neighbour (n);
2356  n = setup_neighbour (peer);
2357  GNUNET_assert (NULL != n);
2358  /* Remember the SYN time stamp for ACK message */
2360  n->connect_ack_timestamp = ts;
2361  /* Request an address for the peer */
2365  break;
2367  /* should not be possible */
2368  GNUNET_assert (0);
2369  break;
2370  default:
2372  "Unhandled state `%s'\n",
2374  GNUNET_break (0);
2375  return GNUNET_SYSERR;
2376  }
2377  return GNUNET_OK;
2378 }
static struct GNUNET_PeerIdentity GST_my_identity
Our public key.
static struct GNUNET_CONTAINER_MultiPeerMap * neighbours
Hash map from peer identities to the respective struct NeighbourMapEntry.
Connection got into trouble, rest of the system still believes it to be up, but we're getting a new a...
We have some primary connection, but ATS suggested we switch to some alternative; we now sent a SYN m...
struct GNUNET_TIME_Absolute GNUNET_TIME_absolute_ntoh(struct GNUNET_TIME_AbsoluteNBO a)
Convert absolute time from network byte order.
Definition: time.c:670
Sent SYN over new address (either by ATS telling us to switch addresses or from RECONNECT_ATS); if th...
We're finished with the disconnect; and are cleaning up the state now! We put the struct into this st...
struct GNUNET_TIME_AbsoluteNBO timestamp
Absolute time at the sender.
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:245
#define GNUNET_assert(cond)
Use this for fatal errors that cannot be handled.
struct GNUNET_TIME_Absolute connect_ack_timestamp
Timestamp we should include in our next SYN_ACK message.
#define GNUNET_NO
Definition: gnunet_common.h:81
#define GNUNET_OK
Named constants for return values.
Definition: gnunet_common.h:78
Received a SYN, asking ATS about address suggestions.
uint16_t size
The length of the struct (in bytes, including the length field itself), in big-endian format...
void GNUNET_STATISTICS_update(struct GNUNET_STATISTICS_Handle *handle, const char *name, int64_t delta, int make_persistent)
Set statistic value for the peer.
static char * print_ack_state(enum GST_ACK_State s)
Convert the given ACK state to a string.
#define GNUNET_break(cond)
Use this for internal assertion violations that are not fatal (can be handled) but should not occur...
#define _(String)
GNU gettext support macro.
Definition: platform.h:208
Message a peer sends to another to indicate that it intends to setup a connection/session for data ex...
static void free_neighbour(struct NeighbourMapEntry *n)
Free a neighbour map entry.
Fresh peer or completely disconnected.
static struct GNUNET_STATISTICS_Handle * GST_stats
Statistics handle.
struct NeighbourAddress primary_address
Primary address we currently use to communicate with the neighbour.
#define GNUNET_break_op(cond)
Use this for assertion violations caused by other peers (i.e.
struct GNUNET_ATS_Session * session
Active session for this address.
Asked to initiate connection, trying to get address from ATS.
static struct NeighbourMapEntry * lookup_neighbour(const struct GNUNET_PeerIdentity *pid)
Lookup a neighbour entry in the neighbours hash map.
const char * GNUNET_TRANSPORT_ps2s(enum GNUNET_TRANSPORT_PeerState state)
Convert a transport state to a human readable string.
#define GNUNET_SYSERR
Definition: gnunet_common.h:79
struct GNUNET_HELLO_Address * address
Network-level address information.
Sent SYN message to other peer, waiting for SYN_ACK.
enum GNUNET_TRANSPORT_PeerState state
The current state of the peer.
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.
The neighbour sent a SYN_ACK message and has to send a ACK as reply.
The identity of the host (wraps the signing key of the peer).
static void send_syn_ack_message(struct NeighbourAddress *na, struct GNUNET_TIME_Absolute timestamp)
Send a SYN_ACK message via the given address.
Disconnect in progress (we're sending the DISCONNECT message to the other peer; after that is finishe...
#define ATS_RESPONSE_TIMEOUT
How long are we willing to wait for a response from ATS before timing out?
#define GNUNET_log(kind,...)
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...
static struct NeighbourMapEntry * setup_neighbour(const struct GNUNET_PeerIdentity *peer)
Create a fresh entry in the neighbour map for the given peer.
Time for absolute times used by GNUnet, in microseconds.
The neighbour received a SYN message and has to send a SYN_ACK as reply.
Got our SYN_ACK/ACK, connection is up.
const char * GNUNET_i2s(const struct GNUNET_PeerIdentity *pid)
Convert a peer identity to a string (for printing debug messages).
SYN request from other peer was SYN_ACK'ed, waiting for ACK.
#define gettext_noop(String)
Definition: gettext.h:69
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 3123 of file gnunet-service-transport_neighbours.c.

References GNUNET_TIME_Absolute::abs_value_us, NeighbourMapEntry::ack_state, 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(), GNUNET_HELLO_Address::peer, 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.

Referenced by GST_receive_callback().

3126 {
3127  const struct TransportSynMessage *scm;
3128  struct GNUNET_TIME_Absolute ts;
3129  struct NeighbourMapEntry *n;
3130 
3131  (void) session;
3132  if (ntohs (message->size) != sizeof (struct TransportSynMessage))
3133  {
3134  GNUNET_break_op (0);
3135  return GNUNET_SYSERR;
3136  }
3138  gettext_noop
3139  ("# SYN_ACK messages received"),
3140  1, GNUNET_NO);
3141  scm = (const struct TransportSynMessage *) message;
3142  GNUNET_break_op (ntohl (scm->reserved) == 0);
3143  if (NULL == (n = lookup_neighbour (&address->peer)))
3144  {
3146  gettext_noop
3147  ("# unexpected SYN_ACK messages (no peer)"),
3148  1, GNUNET_NO);
3149  return GNUNET_SYSERR;
3150  }
3152  "Received SYN_ACK message from peer `%s' in state %s/%s\n",
3153  GNUNET_i2s (&address->peer),
3155  print_ack_state (n->ack_state));
3157  switch (n->state)
3158  {
3160  GNUNET_break (0);
3161  free_neighbour (n);
3162  return GNUNET_SYSERR;
3165  gettext_noop ("# unexpected SYN_ACK messages (not ready)"),
3166  1,
3167  GNUNET_NO);
3168  break;
3170  if (ts.abs_value_us != n->primary_address.connect_timestamp.abs_value_us)
3171  {
3173  "SYN_ACK ignored as the timestamp does not match our SYN request\n");
3174  return GNUNET_OK;
3175  }
3185  break;
3189  gettext_noop ("# unexpected SYN_ACK messages (not ready)"),
3190  1,
3191  GNUNET_NO);
3192  break;
3194  /* duplicate SYN_ACK, let's answer by duplicate ACK just in case */
3196  break;
3198  /* we didn't expect any SYN_ACK, as we are waiting for ATS
3199  to give us a new address... */
3201  gettext_noop ("# unexpected SYN_ACK messages (waiting on ATS)"),
3202  1,
3203  GNUNET_NO);
3204  break;
3206  /* Reconnecting with new address address worked; go back to connected! */
3211  break;
3213  /* new address worked; adopt it and go back to connected! */
3218 
3219  /* Set primary addresses */
3226  gettext_noop ("# Successful attempts to switch addresses"),
3227  1,
3228  GNUNET_NO);
3229 
3231  memset (&n->alternative_address,
3232  0,
3233  sizeof (n->alternative_address));
3235  break;
3238  gettext_noop
3239  ("# unexpected SYN_ACK messages (disconnecting)"),
3240  1, GNUNET_NO);
3241  return GNUNET_SYSERR;
3243  GNUNET_assert (0);
3244  break;
3245  default:
3247  "Unhandled state `%s'\n",
3249  GNUNET_break (0);
3250  return GNUNET_SYSERR;
3251  }
3252  return GNUNET_OK;
3253 }
Connection got into trouble, rest of the system still believes it to be up, but we're getting a new a...
We have some primary connection, but ATS suggested we switch to some alternative; we now sent a SYN m...
struct GNUNET_TIME_Absolute GNUNET_TIME_absolute_ntoh(struct GNUNET_TIME_AbsoluteNBO a)
Convert absolute time from network byte order.
Definition: time.c:670
Sent SYN over new address (either by ATS telling us to switch addresses or from RECONNECT_ATS); if th...
struct NeighbourAddress alternative_address
Alternative address currently under consideration for communicating with the neighbour.
We're finished with the disconnect; and are cleaning up the state now! We put the struct into this st...
struct GNUNET_TIME_AbsoluteNBO timestamp
Absolute time at the sender.
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:245
#define GNUNET_assert(cond)
Use this for fatal errors that cannot be handled.
#define GNUNET_NO
Definition: gnunet_common.h:81
#define GNUNET_OK
Named constants for return values.
Definition: gnunet_common.h:78
Received a SYN, asking ATS about address suggestions.
uint16_t size
The length of the struct (in bytes, including the length field itself), in big-endian format...
void GNUNET_STATISTICS_update(struct GNUNET_STATISTICS_Handle *handle, const char *name, int64_t delta, int make_persistent)
Set statistic value for the peer.
static char * print_ack_state(enum GST_ACK_State s)
Convert the given ACK state to a string.
uint64_t abs_value_us
The actual value.
#define GNUNET_break(cond)
Use this for internal assertion violations that are not fatal (can be handled) but should not occur...
Message a peer sends to another to indicate that it intends to setup a connection/session for data ex...
static void free_neighbour(struct NeighbourMapEntry *n)
Free a neighbour map entry.
Fresh peer or completely disconnected.
static struct GNUNET_STATISTICS_Handle * GST_stats
Statistics handle.
struct NeighbourAddress primary_address
Primary address we currently use to communicate with the neighbour.
#define GNUNET_break_op(cond)
Use this for assertion violations caused by other peers (i.e.
struct GNUNET_TIME_Absolute connect_timestamp
Timestamp of the 'SESSION_CONNECT' message we sent to the other peer for this address.
struct GNUNET_BANDWIDTH_Value32NBO bandwidth_in
Inbound bandwidth from ATS for this address.
struct GNUNET_ATS_Session * session
Active session for this address.
Asked to initiate connection, trying to get address from ATS.
int ats_active
Did we tell ATS that this is our 'active' address?
static struct NeighbourMapEntry * lookup_neighbour(const struct GNUNET_PeerIdentity *pid)
Lookup a neighbour entry in the neighbours hash map.
const char * GNUNET_TRANSPORT_ps2s(enum GNUNET_TRANSPORT_PeerState state)
Convert a transport state to a human readable string.
#define GNUNET_SYSERR
Definition: gnunet_common.h:79
struct GNUNET_HELLO_Address * address
Network-level address information.
Sent SYN message to other peer, waiting for 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.
static void send_session_ack_message(struct NeighbourMapEntry *n)
Send a ACK message to the neighbour to confirm that we got its SYN_ACK.
struct GNUNET_PeerIdentity peer
For which peer is this an address?
enum GNUNET_TRANSPORT_PeerState state
The current state of the peer.
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.
#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_BANDWIDTH_Value32NBO bandwidth_out
Outbound bandwidth from ATS for this address.
Disconnect in progress (we're sending the DISCONNECT message to the other peer; after that is finishe...
#define GNUNET_log(kind,...)
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...
Time for absolute times used by GNUnet, in microseconds.
Got our SYN_ACK/ACK, connection is up.
const char * GNUNET_i2s(const struct GNUNET_PeerIdentity *pid)
Convert a peer identity to a string (for printing debug messages).
SYN request from other peer was SYN_ACK'ed, waiting for ACK.
#define GNUNET_HELLO_address_free(addr)
Free an address.
#define gettext_noop(String)
Definition: gettext.h:69
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 '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 3399 of file gnunet-service-transport_neighbours.c.

References ACK_SEND_ACK, NeighbourMapEntry::ack_state, 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(), GNUNET_HELLO_Address::peer, NeighbourMapEntry::primary_address, print_ack_state(), NeighbourAddress::session, set_state_and_timeout(), GNUNET_MessageHeader::size, and NeighbourMapEntry::state.

Referenced by GST_receive_callback().

3402 {
3403  struct NeighbourMapEntry *n;
3404 
3405  (void) session;
3406  if (ntohs (message->size) != sizeof (struct GNUNET_MessageHeader))
3407  {
3408  GNUNET_break_op (0);
3409  return GNUNET_SYSERR;
3410  }
3412  gettext_noop ("# ACK messages received"),
3413  1,
3414  GNUNET_NO);
3415  if (NULL == (n = lookup_neighbour (&address->peer)))
3416  {
3417  GNUNET_break_op (0);
3418  return GNUNET_SYSERR;
3419  }
3421  "Received ACK for peer `%s' in state %s/%s\n",
3422  GNUNET_i2s (&address->peer),
3424  print_ack_state (n->ack_state));
3425 
3426  /* Check if we are in a plausible state for having sent
3427  a SYN_ACK. If not, return, otherwise break.
3428 
3429  The remote peers sends a ACK as a response for a SYN_ACK
3430  message.
3431 
3432  We expect a ACK:
3433  - If a remote peer has sent a SYN, we responded with a SYN_ACK and
3434  now wait for the ACK to finally be connected
3435  - If we sent a SYN_ACK to this peer before */
3436 
3437  if ( ( (GNUNET_TRANSPORT_PS_SYN_RECV_ACK != n->state) &&
3438  (ACK_SEND_ACK != n->ack_state) ) ||
3439  (NULL == n->primary_address.address) )
3440  {
3442  "Received unexpected ACK message from peer `%s' in state %s/%s\n",
3443  GNUNET_i2s (&address->peer),
3445  print_ack_state (n->ack_state));
3446 
3448  gettext_noop ("# unexpected ACK messages"),
3449  1,
3450  GNUNET_NO);
3451  return GNUNET_OK;
3452  }
3454  {
3455  /* We tried to switch addresses while being connect. We explicitly wait
3456  * for a SYN_ACK before going to GNUNET_TRANSPORT_PS_CONNECTED,
3457  * so we do not want to set the address as in use! */
3458  return GNUNET_OK;
3459  }
3463 
3464  if (NULL == n->primary_address.address) {
3465  /* See issue #3693.
3466  * We are in state = PSY_SYN_RECV_ACK or ack_state = ACK_SEND_ACK, which
3467  * really means we did try (and succeed) to send a SYN and are waiting for
3468  * an ACK.
3469  * That suggests that the primary_address used to be non-NULL, but maybe it
3470  * got reset to NULL without the state being changed appropriately?
3471  */
3472  GNUNET_break (0);
3473  return GNUNET_OK;
3474  }
3475 
3476  /* Reset backoff for primary address */
3479  return GNUNET_OK;
3480 }
We have some primary connection, but ATS suggested we switch to some alternative; we now sent a SYN m...
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:245
#define GNUNET_NO
Definition: gnunet_common.h:81
#define GNUNET_OK
Named constants for return values.
Definition: gnunet_common.h:78
uint16_t size
The length of the struct (in bytes, including the length field itself), in big-endian format...
void GNUNET_STATISTICS_update(struct GNUNET_STATISTICS_Handle *handle, const char *name, int64_t delta, int make_persistent)
Set statistic value for the peer.
static char * print_ack_state(enum GST_ACK_State s)
Convert the given ACK state to a string.
#define GNUNET_break(cond)
Use this for internal assertion violations that are not fatal (can be handled) but should not occur...
static struct GNUNET_STATISTICS_Handle * GST_stats
Statistics handle.
struct NeighbourAddress primary_address
Primary address we currently use to communicate with the neighbour.
#define GNUNET_break_op(cond)
Use this for assertion violations caused by other peers (i.e.
struct GNUNET_ATS_Session * session
Active session for this address.
static struct NeighbourMapEntry * lookup_neighbour(const struct GNUNET_PeerIdentity *pid)
Lookup a neighbour entry in the neighbours hash map.
const char * GNUNET_TRANSPORT_ps2s(enum GNUNET_TRANSPORT_PeerState state)
Convert a transport state to a human readable string.
#define GNUNET_SYSERR
Definition: gnunet_common.h:79
struct GNUNET_HELLO_Address * address
Network-level address information.
struct GNUNET_PeerIdentity peer
For which peer is this an address?
enum GNUNET_TRANSPORT_PeerState state
The current state of the peer.
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.
#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...
The neighbour sent a SYN_ACK message and has to send a ACK as reply.
void GST_ats_block_reset(const struct GNUNET_HELLO_Address *address, struct GNUNET_ATS_Session *session)
Reset address blocking time.
#define GNUNET_log(kind,...)
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...
Header for all communications.
Got our SYN_ACK/ACK, connection is up.
const char * GNUNET_i2s(const struct GNUNET_PeerIdentity *pid)
Convert a peer identity to a string (for printing debug messages).
SYN request from other peer was SYN_ACK'ed, waiting for ACK.
#define gettext_noop(String)
Definition: gettext.h:69
Here is the call graph for this function:
Here is the caller 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 3753 of file gnunet-service-transport_neighbours.c.

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

Referenced by handle_send_transmit_continuation().

3754 {
3755  struct NeighbourMapEntry *n;
3756 
3757  n = lookup_neighbour (peer);
3758  if (NULL == n)
3759  return NULL;
3760  return n->primary_address.address;
3761 }
struct NeighbourAddress primary_address
Primary address we currently use to communicate with the neighbour.
static struct NeighbourMapEntry * lookup_neighbour(const struct GNUNET_PeerIdentity *pid)
Lookup a neighbour entry in the neighbours hash map.
struct GNUNET_HELLO_Address * address
Network-level address information.
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 3522 of file gnunet-service-transport_neighbours.c.

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(), NeighbourMapEntry::neighbour_receive_quota, GNUNET_ATS_SessionQuotaMessage::quota, send_outbound_quota_to_clients(), GNUNET_MessageHeader::size, and GNUNET_BANDWIDTH_Value32NBO::value__.

Referenced by GST_receive_callback().

3524 {
3525  struct NeighbourMapEntry *n;
3526  const struct GNUNET_ATS_SessionQuotaMessage *sqm;
3527  struct GNUNET_BANDWIDTH_Value32NBO last;
3528 
3530  "Received QUOTA message from peer `%s'\n",
3531  GNUNET_i2s (peer));
3532  if (ntohs (msg->size) != sizeof (struct GNUNET_ATS_SessionQuotaMessage))
3533  {
3534  GNUNET_break_op (0);
3536  gettext_noop ("# quota messages ignored (malformed)"),
3537  1,
3538  GNUNET_NO);
3539  return;
3540  }
3542  gettext_noop
3543  ("# QUOTA messages received"),
3544  1, GNUNET_NO);
3545  sqm = (const struct GNUNET_ATS_SessionQuotaMessage *) msg;
3546  if (NULL == (n = lookup_neighbour (peer)))
3547  {
3548  /* gone already */
3549  return;
3550  }
3552  GNUNET_BANDWIDTH_value_init (ntohl (sqm->quota)));
3553  if (last.value__ != n->neighbour_receive_quota.value__)
3554  {
3555  n->neighbour_receive_quota = last;
3557  }
3558 }
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
Message a peer sends to another when connected to indicate that the other peer should limit transmiss...
#define GNUNET_CONSTANTS_DEFAULT_BW_IN_OUT
Bandwidth (in/out) to assume initially (before either peer has communicated any particular preference...
#define GNUNET_NO
Definition: gnunet_common.h:81
uint32_t quota
Quota to use (for sending), in bytes per second.
uint16_t size
The length of the struct (in bytes, including the length field itself), in big-endian format...
void GNUNET_STATISTICS_update(struct GNUNET_STATISTICS_Handle *handle, const char *name, int64_t delta, int make_persistent)
Set statistic value for the peer.
uint32_t value__
The actual value (bytes per second).
static struct GNUNET_STATISTICS_Handle * GST_stats
Statistics handle.
#define GNUNET_break_op(cond)
Use this for assertion violations caused by other peers (i.e.
static struct NeighbourMapEntry * lookup_neighbour(const struct GNUNET_PeerIdentity *pid)
Lookup a neighbour entry in the neighbours hash map.
struct GNUNET_BANDWIDTH_Value32NBO GNUNET_BANDWIDTH_value_init(uint32_t bytes_per_second)
Create a new bandwidth value.
Definition: bandwidth.c:39
32-bit bandwidth used for network exchange by GNUnet, in bytes per second.
#define GNUNET_log(kind,...)
struct GNUNET_BANDWIDTH_Value32NBO neighbour_receive_quota
Latest quota the other peer send us in bytes per second.
static void send_outbound_quota_to_clients(struct NeighbourMapEntry *n)
Send information about a new outbound quota to our clients.
const char * GNUNET_i2s(const struct GNUNET_PeerIdentity *pid)
Convert a peer identity to a string (for printing debug messages).
#define gettext_noop(String)
Definition: gettext.h:69
Here is the call graph for this function:
Here is the caller 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 3569 of file gnunet-service-transport_neighbours.c.

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(), GNUNET_ATS_SessionDisconnectMessage::public_key, GNUNET_ATS_SessionDisconnectMessage::purpose, GNUNET_ATS_SessionDisconnectMessage::signature, GNUNET_CRYPTO_EccSignaturePurpose::size, GNUNET_MessageHeader::size, and GNUNET_ATS_SessionDisconnectMessage::timestamp.

Referenced by GST_receive_callback().

3571 {
3572  struct NeighbourMapEntry *n;
3573  const struct GNUNET_ATS_SessionDisconnectMessage *sdm;
3574 
3576  "Received DISCONNECT message from peer `%s'\n",
3577  GNUNET_i2s (peer));
3578  if (ntohs (msg->size) != sizeof (struct GNUNET_ATS_SessionDisconnectMessage))
3579  {
3580  GNUNET_break_op (0);
3582  gettext_noop
3583  ("# disconnect messages ignored (malformed)"),
3584  1,
3585  GNUNET_NO);
3586  return;
3587  }
3589  gettext_noop
3590  ("# DISCONNECT messages received"),
3591  1, GNUNET_NO);
3592  sdm = (const struct GNUNET_ATS_SessionDisconnectMessage *) msg;
3593  if (NULL == (n = lookup_neighbour (peer)))
3594  {
3595  /* gone already */
3596  return;
3597  }
3599  {
3601  gettext_noop ("# disconnect messages ignored (timestamp)"),
3602  1,
3603  GNUNET_NO);
3604  return;
3605  }
3606  if (0 != memcmp (peer,
3607  &sdm->public_key,
3608  sizeof (struct GNUNET_PeerIdentity)))
3609  {
3610  GNUNET_break_op (0);
3611  return;
3612  }
3613  if (ntohl (sdm->purpose.size) !=
3614  sizeof (struct GNUNET_CRYPTO_EccSignaturePurpose) +
3615  sizeof (struct GNUNET_CRYPTO_EddsaPublicKey) +
3616  sizeof (struct GNUNET_TIME_AbsoluteNBO))
3617  {
3619  "DISCONNECT message from peer `%s' has invalid size\n",
3620  GNUNET_i2s (peer));
3621  GNUNET_break_op (0);
3622  return;
3623  }
3624  if (GNUNET_OK !=
3626  &sdm->purpose,
3627  &sdm->signature,
3628  &sdm->public_key))
3629  {
3631  "DISCONNECT message from peer `%s' cannot be verified \n",
3632  GNUNET_i2s (peer));
3633  GNUNET_break_op (0);
3634  return;
3635  }
3636  if (NULL == n->delayed_disconnect_task)
3637  {
3639  n);
3640  }
3641 }
struct GNUNET_CRYPTO_EddsaPublicKey public_key
Public key of the sender.
struct GNUNET_TIME_Absolute GNUNET_TIME_absolute_ntoh(struct GNUNET_TIME_AbsoluteNBO a)
Convert absolute time from network byte order.
Definition: time.c:670
struct GNUNET_TIME_Absolute connect_ack_timestamp
Timestamp we should include in our next SYN_ACK message.
#define GNUNET_NO
Definition: gnunet_common.h:81
#define GNUNET_OK
Named constants for return values.
Definition: gnunet_common.h:78
uint16_t size
The length of the struct (in bytes, including the length field itself), in big-endian format...
void GNUNET_STATISTICS_update(struct GNUNET_STATISTICS_Handle *handle, const char *name, int64_t delta, int make_persistent)
Set statistic value for the peer.
Time for absolute time used by GNUnet, in microseconds and in network byte order. ...
uint64_t abs_value_us
The actual value.
header of what an ECC signature signs this must be followed by "size - 8" bytes of the actual signed ...
static void delayed_disconnect(void *cls)
Task to asynchronously run free_neighbour().
struct GNUNET_TIME_AbsoluteNBO timestamp
Absolute time at the sender.
static struct GNUNET_STATISTICS_Handle * GST_stats
Statistics handle.
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:1116
#define GNUNET_break_op(cond)
Use this for assertion violations caused by other peers (i.e.
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:1273
struct GNUNET_CRYPTO_EccSignaturePurpose purpose
Purpose of the signature.
uint32_t size
How many bytes does this signature sign? (including this purpose header); in network byte order (!)...
static struct NeighbourMapEntry * lookup_neighbour(const struct GNUNET_PeerIdentity *pid)
Lookup a neighbour entry in the neighbours hash map.
Message we send to the other peer to notify it that we intentionally are disconnecting (to reduce tim...
#define GNUNET_MESSAGE_TYPE_TRANSPORT_SESSION_DISCONNECT
Transport DISCONNECT message exchanged between transport services to indicate that a connection shoul...
struct GNUNET_CRYPTO_EddsaSignature signature
Signature of the peer that sends us the disconnect.
The identity of the host (wraps the signing key of the peer).
struct GNUNET_SCHEDULER_Task * delayed_disconnect_task
Task to disconnect neighbour after we received a DISCONNECT message.
#define GNUNET_log(kind,...)
const char * GNUNET_i2s(const struct GNUNET_PeerIdentity *pid)
Convert a peer identity to a string (for printing debug messages).
#define gettext_noop(String)
Definition: gettext.h:69
Public ECC key (always for curve Ed25519) encoded in a format suitable for network transmission and E...
Here is the call graph for this function:
Here is the caller graph for this function: