GNUnet  0.19.5
gnunet-service-transport.h File Reference

globals More...

Include dependency graph for gnunet-service-transport.h:
This graph shows which files directly or indirectly include this file:

Go to the source code of this file.

Macros

#define VERBOSE_VALIDATION   GNUNET_YES
 

Typedefs

typedef void(* GNUNET_TRANSPORT_NeighbourChangeCallback) (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 to call when a peer's address has changed. More...
 
typedef void(* GST_BlacklistTestContinuation) (void *cls, const struct GNUNET_PeerIdentity *peer, const struct GNUNET_HELLO_Address *address, struct GNUNET_ATS_Session *session, int result)
 Continuation called from a blacklist test. More...
 

Functions

void GST_blacklist_add_peer (const struct GNUNET_PeerIdentity *peer, const char *transport_name)
 Add the given peer to the blacklist (for the given transport). More...
 
struct GST_BlacklistCheckGST_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. More...
 
void GST_blacklist_abort_matching (const struct GNUNET_HELLO_Address *address, struct GNUNET_ATS_Session *session)
 Abort blacklist if address and session match. More...
 
void GST_blacklist_test_cancel (struct GST_BlacklistCheck *bc)
 Cancel a blacklist check. More...
 
struct GNUNET_TIME_Relative GST_receive_callback (void *cls, const struct GNUNET_HELLO_Address *address, struct GNUNET_ATS_Session *session, const struct GNUNET_MessageHeader *message)
 Function called by the transport for each received message. More...
 
void GST_clients_broadcast (const struct GNUNET_MessageHeader *msg, int may_drop)
 Broadcast the given message to all of our clients. More...
 
void GST_clients_broadcast_peer_notification (const struct GNUNET_PeerIdentity *peer, const struct GNUNET_HELLO_Address *address, enum GNUNET_TRANSPORT_PeerState state, struct GNUNET_TIME_Absolute state_timeout)
 Broadcast the new active address to all clients monitoring the peer. More...
 
void GST_clients_broadcast_disconnect (const struct GNUNET_PeerIdentity *peer)
 Notify all clients about a disconnect, and cancel pending SEND_OK messages for this peer. More...
 

Variables

struct GNUNET_STATISTICS_HandleGST_stats
 Statistics handle. More...
 
const struct GNUNET_CONFIGURATION_HandleGST_cfg
 Configuration handle. More...
 
struct GNUNET_PeerIdentity GST_my_identity
 Configuration handle. More...
 
struct GNUNET_PEERINFO_HandleGST_peerinfo
 Handle to peerinfo service. More...
 
struct GNUNET_CRYPTO_EddsaPrivateKey GST_my_private_key
 Our private key. More...
 
struct GNUNET_ATS_SchedulingHandleGST_ats
 ATS handle. More...
 
struct GNUNET_ATS_ConnectivityHandleGST_ats_connect
 ATS connectivity handle. More...
 
struct GNUNET_NT_InterfaceScannerGST_is
 Interface scanner determines our LAN address range(s). More...
 

Detailed Description

globals

Author
Christian Grothoff

Definition in file gnunet-service-transport.h.

Macro Definition Documentation

◆ VERBOSE_VALIDATION

#define VERBOSE_VALIDATION   GNUNET_YES

Definition at line 34 of file gnunet-service-transport.h.

Typedef Documentation

◆ GNUNET_TRANSPORT_NeighbourChangeCallback

typedef void(* GNUNET_TRANSPORT_NeighbourChangeCallback) (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 to call when a peer's address has changed.

Parameters
clsclosure
peerpeer this update is about,
addressaddress, NULL for disconnect notification

Definition at line 84 of file gnunet-service-transport.h.

◆ GST_BlacklistTestContinuation

typedef void(* GST_BlacklistTestContinuation) (void *cls, const struct GNUNET_PeerIdentity *peer, const struct GNUNET_HELLO_Address *address, struct GNUNET_ATS_Session *session, int result)

Continuation called from a blacklist test.

Parameters
clsclosure
peeridentity of peer that was tested
addressaddress associated with the request
sessionsession associated with the request
resultGNUNET_OK if the connection is allowed, GNUNET_NO if not, GNUNET_SYSERR if operation was aborted

Definition at line 111 of file gnunet-service-transport.h.

Function Documentation

◆ GST_blacklist_add_peer()

void GST_blacklist_add_peer ( const struct GNUNET_PeerIdentity peer,
const char *  transport_name 
)

Add the given peer to the blacklist (for the given transport).

Parameters
peerpeer to blacklist
transport_nametransport to blacklist for this peer, NULL for all

Definition at line 2307 of file gnunet-service-transport.c.

2309 {
2310  char *transport = NULL;
2311 
2312  if (NULL != transport_name)
2313  {
2315  "Adding peer `%s' with plugin `%s' to blacklist\n",
2316  GNUNET_i2s (peer),
2317  transport_name);
2318  transport = GNUNET_strdup (transport_name);
2319  }
2320  else
2322  "Adding peer `%s' with all plugins to blacklist\n",
2323  GNUNET_i2s (peer));
2324  if (NULL == blacklist)
2325  blacklist =
2327  GNUNET_NO);
2328 
2330  peer,
2331  transport,
2333 }
static struct GNUNET_TRANSPORT_CoreHandle * transport
Transport service.
static struct GNUNET_CONTAINER_MultiPeerMap * blacklist
Hashmap of blacklisted peers.
#define TRANSPORT_BLACKLIST_HT_SIZE
Size of the blacklist hash map.
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).
int GNUNET_CONTAINER_multipeermap_put(struct GNUNET_CONTAINER_MultiPeerMap *map, const struct GNUNET_PeerIdentity *key, void *value, enum GNUNET_CONTAINER_MultiHashMapOption opt)
Store a key-value pair in the map.
@ GNUNET_CONTAINER_MULTIHASHMAPOPTION_MULTIPLE
Allow multiple values with the same key.
#define GNUNET_log(kind,...)
@ GNUNET_NO
const char * GNUNET_i2s(const struct GNUNET_PeerIdentity *pid)
Convert a peer identity to a string (for printing debug messages).
@ GNUNET_ERROR_TYPE_INFO
#define GNUNET_strdup(a)
Wrapper around GNUNET_xstrdup_.
struct GNUNET_TESTBED_Peer * peer
The peer associated with this model.

References blacklist, GNUNET_CONTAINER_MULTIHASHMAPOPTION_MULTIPLE, GNUNET_CONTAINER_multipeermap_create(), GNUNET_CONTAINER_multipeermap_put(), GNUNET_ERROR_TYPE_INFO, GNUNET_i2s(), GNUNET_log, GNUNET_NO, GNUNET_strdup, peer, transport, and TRANSPORT_BLACKLIST_HT_SIZE.

Referenced by blacklist_cfg_iter(), and run().

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

◆ GST_blacklist_test_allowed()

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.

Parameters
peerthe identity of the peer to test
transport_namename of the transport to test, never NULL
contfunction to call with result
cont_clsclosure for cont
addressaddress to pass back to cont, can be NULL
sessionsession to pass back to cont, can be NULL
Returns
handle to the blacklist check, NULL if the decision was made instantly and cont was already called

Definition at line 2421 of file gnunet-service-transport.c.

2427 {
2428  struct GST_BlacklistCheck *bc;
2429  struct TransportClient *tc;
2430 
2431  GNUNET_assert (NULL != peer);
2433  "Blacklist check for peer `%s':%s\n",
2434  GNUNET_i2s (peer),
2435  (NULL != transport_name) ? transport_name : "unspecified");
2436 
2437  /* Check local blacklist by iterating over hashmap
2438  * If iteration is aborted, we found a matching blacklist entry */
2439  if ((NULL != blacklist) &&
2440  (GNUNET_SYSERR ==
2442  peer,
2444  (void *) transport_name)))
2445  {
2446  /* Disallowed by config, disapprove instantly */
2448  gettext_noop ("# disconnects due to blacklist"),
2449  1,
2450  GNUNET_NO);
2452  _ ("Disallowing connection to peer `%s' on transport %s\n"),
2453  GNUNET_i2s (peer),
2454  (NULL != transport_name) ? transport_name : "unspecified");
2455  if (NULL != cont)
2456  cont (cont_cls, peer, address, session, GNUNET_NO);
2457  return NULL;
2458  }
2459 
2460  for (tc = clients_head; NULL != tc; tc = tc->next)
2461  if (CT_BLACKLIST == tc->type)
2462  break;
2463  if (NULL == tc)
2464  {
2465  /* no blacklist clients, approve instantly */
2466  if (NULL != cont)
2467  cont (cont_cls, peer, address, session, GNUNET_OK);
2469  "Allowing connection to peer `%s' %s\n",
2470  GNUNET_i2s (peer),
2471  (NULL != transport_name) ? transport_name : "");
2472  return NULL;
2473  }
2474 
2475  /* need to query blacklist clients */
2476  bc = GNUNET_new (struct GST_BlacklistCheck);
2478  bc->peer = *peer;
2480  bc->session = session;
2481  bc->cont = cont;
2482  bc->cont_cls = cont_cls;
2483  bc->bl_pos = tc;
2485  return bc;
2486 }
#define gettext_noop(String)
Definition: gettext.h:70
static char * address
GNS address for this phone.
static int test_blacklisted(void *cls, const struct GNUNET_PeerIdentity *key, void *value)
Test if the given blacklist entry matches.
static struct GST_BlacklistCheck * bc_tail
Tail of DLL of active blacklisting queries.
static struct TransportClient * clients_head
Head of linked list of all clients to this service.
static void do_blacklist_check(void *cls)
Perform next action in the blacklist check.
struct GNUNET_STATISTICS_Handle * GST_stats
Statistics handle.
@ CT_BLACKLIST
It is a blacklist, query about allowed connections.
static struct GST_BlacklistCheck * bc_head
Head of DLL of active blacklisting queries.
#define GNUNET_CONTAINER_DLL_insert(head, tail, element)
Insert an element at the head of a DLL.
int GNUNET_CONTAINER_multipeermap_get_multiple(struct GNUNET_CONTAINER_MultiPeerMap *map, const struct GNUNET_PeerIdentity *key, GNUNET_CONTAINER_PeerMapIterator it, void *it_cls)
Iterate over all entries in the map that match a particular key.
struct GNUNET_HELLO_Address * GNUNET_HELLO_address_copy(const struct GNUNET_HELLO_Address *address)
Copy an address struct.
Definition: address.c:99
@ GNUNET_OK
@ GNUNET_SYSERR
#define GNUNET_assert(cond)
Use this for fatal errors that cannot be handled.
@ GNUNET_ERROR_TYPE_DEBUG
#define GNUNET_new(type)
Allocate a struct or union of the given type.
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:1299
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 _(String)
GNU gettext support macro.
Definition: platform.h:178
static struct GNUNET_SCHEDULER_TaskContext tc
Task context of the current task.
Definition: scheduler.c:431
Context we use when performing a blacklist check.
struct GNUNET_SCHEDULER_Task * task
Current task performing the check.
GST_BlacklistTestContinuation cont
Continuation to call with the result.
struct GNUNET_ATS_Session * session
Session for GST_blacklist_abort_matching(), can be NULL.
struct GNUNET_PeerIdentity peer
Peer being checked.
struct GNUNET_HELLO_Address * address
Address for GST_blacklist_abort_matching(), can be NULL.
struct TransportClient * bl_pos
Our current position in the blacklisters list.
void * cont_cls
Closure for cont.
Client connected to the transport service.
struct GST_BlacklistCheck * bc
Blacklist check that we're currently performing (or NULL if we're performing one that has been cancel...

References _, address, GST_BlacklistCheck::address, TransportClient::bc, bc_head, bc_tail, GST_BlacklistCheck::bl_pos, blacklist, clients_head, GST_BlacklistCheck::cont, GST_BlacklistCheck::cont_cls, CT_BLACKLIST, do_blacklist_check(), gettext_noop, GNUNET_assert, GNUNET_CONTAINER_DLL_insert, GNUNET_CONTAINER_multipeermap_get_multiple(), GNUNET_ERROR_TYPE_DEBUG, GNUNET_ERROR_TYPE_INFO, GNUNET_HELLO_address_copy(), GNUNET_i2s(), GNUNET_log, GNUNET_new, GNUNET_NO, GNUNET_OK, GNUNET_SCHEDULER_add_now(), GNUNET_STATISTICS_update(), GNUNET_SYSERR, GST_stats, peer, GST_BlacklistCheck::peer, GST_BlacklistCheck::session, GST_BlacklistCheck::task, tc, and test_blacklisted().

Referenced by GST_neighbours_switch_to_address(), plugin_env_session_start(), and revalidate_address().

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

◆ GST_blacklist_abort_matching()

void GST_blacklist_abort_matching ( const struct GNUNET_HELLO_Address address,
struct GNUNET_ATS_Session session 
)

Abort blacklist if address and session match.

Parameters
addressaddress used to abort matching checks
sessionsession used to abort matching checks

Definition at line 2343 of file gnunet-service-transport.c.

2345 {
2346  struct GST_BlacklistCheck *bc;
2347  struct GST_BlacklistCheck *n;
2348 
2349  n = bc_head;
2350  while (NULL != (bc = n))
2351  {
2352  n = bc->next;
2353  if ((bc->session == session) &&
2355  {
2356  bc->cont (bc->cont_cls,
2357  &bc->peer,
2358  bc->address,
2359  bc->session,
2360  GNUNET_SYSERR);
2362  }
2363  }
2364 }
void GST_blacklist_test_cancel(struct GST_BlacklistCheck *bc)
Cancel a blacklist check.
int GNUNET_HELLO_address_cmp(const struct GNUNET_HELLO_Address *a1, const struct GNUNET_HELLO_Address *a2)
Compare two addresses.
Definition: address.c:112
struct GST_BlacklistCheck * next
This is a linked list.

References address, GST_BlacklistCheck::address, bc_head, GST_BlacklistCheck::cont, GST_BlacklistCheck::cont_cls, GNUNET_HELLO_address_cmp(), GNUNET_SYSERR, GST_blacklist_test_cancel(), GST_BlacklistCheck::next, GST_BlacklistCheck::peer, and GST_BlacklistCheck::session.

Referenced by connect_bl_check_cont(), and plugin_env_session_end().

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

◆ GST_blacklist_test_cancel()

void GST_blacklist_test_cancel ( struct GST_BlacklistCheck bc)

Cancel a blacklist check.

Parameters
bccheck to cancel

Definition at line 2490 of file gnunet-service-transport.c.

2491 {
2493  if (NULL != bc->bl_pos)
2494  {
2495  if ((CT_BLACKLIST == bc->bl_pos->type) &&
2496  (bc->bl_pos->details.blacklist.bc == bc))
2497  {
2498  /* we're at the head of the queue, remove us! */
2499  bc->bl_pos->details.blacklist.bc = NULL;
2500  }
2501  }
2502  if (NULL != bc->task)
2503  {
2505  bc->task = NULL;
2506  }
2507  GNUNET_free (bc->address);
2508  GNUNET_free (bc);
2509 }
#define GNUNET_CONTAINER_DLL_remove(head, tail, element)
Remove an element from a DLL.
#define GNUNET_free(ptr)
Wrapper around free.
void * GNUNET_SCHEDULER_cancel(struct GNUNET_SCHEDULER_Task *task)
Cancel the task with the specified identifier.
Definition: scheduler.c:975
enum ClientType type
What type of client is this?
struct TransportClient::@70::@71 blacklist
Additional details if type is CT_BLACKLIST.
union TransportClient::@64 details

References GST_BlacklistCheck::address, TransportClient::bc, bc_head, bc_tail, GST_BlacklistCheck::bl_pos, TransportClient::blacklist, CT_BLACKLIST, TransportClient::details, GNUNET_CONTAINER_DLL_remove, GNUNET_free, GNUNET_SCHEDULER_cancel(), GST_BlacklistCheck::task, and TransportClient::type.

Referenced by cleanup_validation_entry(), do_blacklist_check(), GST_blacklist_abort_matching(), handle_client_blacklist_reply(), and revalidate_address().

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

◆ GST_receive_callback()

struct GNUNET_TIME_Relative GST_receive_callback ( void *  cls,
const struct GNUNET_HELLO_Address address,
struct GNUNET_ATS_Session session,
const struct GNUNET_MessageHeader message 
)

Function called by the transport for each received message.

Parameters
clsclosure, const char* with the name of the plugin we received the message from
addressaddress and (claimed) identity of the other peer
sessionidentifier used for this session (NULL for plugins that do not offer bi-directional communication to the sender using the same "connection")
messagethe message, NULL if we only care about learning about the delay until we should receive again
Returns
how long the plugin should wait until receiving more data (plugins that do not support this, can ignore the return value)
Parameters
clsclosure, const char* with the name of the plugin we received the message from
addressaddress and (claimed) identity of the other peer
messagethe message, NULL if we only care about learning about the delay until we should receive again
sessionidentifier used for this session (NULL for plugins that do not offer bi-directional communication to the sender using the same "connection")
Returns
how long the plugin should wait until receiving more data (plugins that do not support this, can ignore the return value)

Definition at line 1557 of file gnunet-service-transport.c.

1609 {
1610  const char *plugin_name = cls;
1611  struct GNUNET_TIME_Relative ret;
1612  uint16_t type;
1613 
1615  if (NULL == message)
1616  goto end;
1617  type = ntohs (message->type);
1619  "Received message with type %u from peer `%s' at %s\n",
1620  type,
1621  GNUNET_i2s (&address->peer),
1623 
1625  gettext_noop ("# bytes total received"),
1626  ntohs (message->size),
1627  GNUNET_NO);
1629  switch (type)
1630  {
1632  /* Future HELLO message, discard */
1633  return ret;
1634 
1636  if (GNUNET_OK != GST_validation_handle_hello (message))
1637  {
1638  GNUNET_break_op (0);
1640  }
1641  return ret;
1642 
1645  "Processing PING from `%s'\n",
1647  if (GNUNET_OK !=
1648  GST_validation_handle_ping (&address->peer, message, address, session))
1649  {
1651  kill_session (plugin_name, session);
1652  }
1653  break;
1654 
1657  "Processing PONG from `%s'\n",
1659  if (GNUNET_OK != GST_validation_handle_pong (&address->peer, message))
1660  {
1661  GNUNET_break_op (0);
1663  kill_session (plugin_name, session);
1664  }
1665  break;
1666 
1668  /* Do blacklist check if communication with this peer is allowed */
1669  (void) GST_blacklist_test_allowed (&address->peer,
1670  NULL,
1672  GNUNET_copy_message (message),
1673  address,
1674  session);
1675  break;
1676 
1678  if (GNUNET_OK !=
1679  GST_neighbours_handle_session_syn_ack (message, address, session))
1680  {
1682  kill_session (plugin_name, session);
1683  }
1684  break;
1685 
1687  if (GNUNET_OK !=
1688  GST_neighbours_handle_session_ack (message, address, session))
1689  {
1690  GNUNET_break_op (0);
1692  kill_session (plugin_name, session);
1693  }
1694  break;
1695 
1698  break;
1699 
1701  GST_neighbours_handle_quota_message (&address->peer, message);
1702  break;
1703 
1705  GST_neighbours_keepalive (&address->peer, message);
1706  break;
1707 
1709  GST_neighbours_keepalive_response (&address->peer, message);
1710  break;
1711 
1712  default:
1713  /* should be payload */
1715  gettext_noop ("# bytes payload received"),
1716  ntohs (message->size),
1717  GNUNET_NO);
1718  ret = process_payload (address, session, message);
1719  break;
1720  }
1721 end:
1723  "Allowing receive from peer %s to continue in %s\n",
1724  GNUNET_i2s (&address->peer),
1726  return ret;
1727 }
static int ret
Return value of the commandline.
Definition: gnunet-abd.c:81
static int end
Set if we are to shutdown all services (including ARM).
Definition: gnunet-arm.c:34
static char * plugin_name
Name of our plugin.
void GST_blacklist_abort_matching(const struct GNUNET_HELLO_Address *address, struct GNUNET_ATS_Session *session)
Abort blacklist if address and session match.
static void kill_session(const char *plugin_name, struct GNUNET_ATS_Session *session)
Force plugin to terminate session due to communication issue.
struct GST_BlacklistCheck * GST_blacklist_test_allowed(const struct GNUNET_PeerIdentity *peer, const char *transport_name, GST_BlacklistTestContinuation cont, void *cont_cls, const struct GNUNET_HELLO_Address *address, struct GNUNET_ATS_Session *session)
Test if a peer/transport combination is blacklisted.
static struct GNUNET_TIME_Relative process_payload(const struct GNUNET_HELLO_Address *address, struct GNUNET_ATS_Session *session, const struct GNUNET_MessageHeader *message)
We received some payload.
static void connect_bl_check_cont(void *cls, const struct GNUNET_PeerIdentity *peer, const struct GNUNET_HELLO_Address *address, struct GNUNET_ATS_Session *session, int result)
Black list check result for try_connect call If connection to the peer is allowed request address and...
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 utiliza...
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.
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.
int GST_neighbours_handle_session_ack(const struct GNUNET_MessageHeader *message, const struct GNUNET_HELLO_Address *address, struct GNUNET_ATS_Session *session)
We received a 'ACK' message from the other peer.
int GST_neighbours_handle_session_syn_ack(const struct GNUNET_MessageHeader *message, const struct GNUNET_HELLO_Address *address, struct GNUNET_ATS_Session *session)
We received a 'SESSION_SYN_ACK' message from the other peer.
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); sen...
void GST_neighbours_handle_quota_message(const struct GNUNET_PeerIdentity *peer, const struct GNUNET_MessageHeader *msg)
We received a quota message from the given peer, validate and process.
const char * GST_plugins_a2s(const struct GNUNET_HELLO_Address *address)
Convert a given address to a human-readable format.
int GST_validation_handle_ping(const struct GNUNET_PeerIdentity *sender, const struct GNUNET_MessageHeader *hdr, const struct GNUNET_HELLO_Address *sender_address, struct GNUNET_ATS_Session *session)
We've received a PING.
int GST_validation_handle_hello(const struct GNUNET_MessageHeader *hello)
We've received a HELLO, check which addresses are new and trigger validation.
int GST_validation_handle_pong(const struct GNUNET_PeerIdentity *sender, const struct GNUNET_MessageHeader *hdr)
We've received a PONG.
@ GNUNET_YES
#define GNUNET_break_op(cond)
Use this for assertion violations caused by other peers (i.e.
struct GNUNET_MessageHeader * GNUNET_copy_message(const struct GNUNET_MessageHeader *msg)
Create a copy of the given message.
#define GNUNET_MESSAGE_TYPE_TRANSPORT_SESSION_QUOTA
Message exchanged between transport services to indicate that the sender should limit its transmissio...
#define GNUNET_MESSAGE_TYPE_TRANSPORT_SESSION_KEEPALIVE
Message send by a peer to notify the other to keep the session alive and measure latency in a regular...
#define GNUNET_MESSAGE_TYPE_TRANSPORT_SESSION_KEEPALIVE_RESPONSE
Response to a GNUNET_MESSAGE_TYPE_TRANSPORT_SESSION_KEEPALIVE message to measure latency in a regular...
#define GNUNET_MESSAGE_TYPE_TRANSPORT_PONG
Transport PONG message.
#define GNUNET_MESSAGE_TYPE_TRANSPORT_SESSION_ACK
Transport ACK message exchanged between transport services to indicate that a SYN_ACK message was acc...
#define GNUNET_MESSAGE_TYPE_TRANSPORT_SESSION_DISCONNECT
Transport DISCONNECT message exchanged between transport services to indicate that a connection shoul...
#define GNUNET_MESSAGE_TYPE_HELLO_URI
Latest HELLO messages used for communicating peer addresses.
#define GNUNET_MESSAGE_TYPE_HELLO
HELLO message with friend only flag used for communicating peer addresses.
#define GNUNET_MESSAGE_TYPE_TRANSPORT_PING
Transport PING message.
#define GNUNET_MESSAGE_TYPE_TRANSPORT_SESSION_SYN
Transport SYN message exchanged between transport services to indicate that a session should be marke...
#define GNUNET_MESSAGE_TYPE_TRANSPORT_SESSION_SYN_ACK
Transport SYN_ACK message exchanged between transport services to indicate that a SYN message was acc...
#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:569
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.
Time for relative time used by GNUnet, in microseconds.
enum GNUNET_TESTBED_UnderlayLinkModelType type
the type of this model

◆ GST_clients_broadcast()

void GST_clients_broadcast ( const struct GNUNET_MessageHeader msg,
int  may_drop 
)

Broadcast the given message to all of our clients.

Parameters
msgmessage to broadcast
may_dropGNUNET_YES if the message can be dropped / is payload

Definition at line 1286 of file gnunet-service-transport.c.

1287 {
1288  int done;
1289 
1291  "Asked to broadcast message of type %u with %u bytes\n",
1292  (unsigned int) ntohs (msg->type),
1293  (unsigned int) ntohs (msg->size));
1294  done = GNUNET_NO;
1295  for (struct TransportClient *tc = clients_head; NULL != tc; tc = tc->next)
1296  {
1297  if (CT_NONE == tc->type)
1298  continue; /* client not yet ready */
1299  if ((GNUNET_YES == may_drop) && (CT_CORE != tc->type))
1300  continue; /* skip, this client does not care about payload */
1301  unicast (tc, msg, may_drop);
1302  done = GNUNET_YES;
1303  }
1304  if (GNUNET_NO == done)
1306  "Message of type %u not delivered, is CORE service up?\n",
1307  ntohs (msg->type));
1308 }
struct GNUNET_MessageHeader * msg
Definition: 005.c:2
static void done()
static void unicast(struct TransportClient *tc, const struct GNUNET_MessageHeader *msg, int may_drop)
Queue the given message for transmission to the given client.
@ CT_NONE
We do not know yet (client is fresh).
@ CT_CORE
Is the CORE service, we need to forward traffic to it.

References clients_head, CT_CORE, CT_NONE, done(), GNUNET_ERROR_TYPE_DEBUG, GNUNET_log, GNUNET_NO, GNUNET_YES, msg, GNUNET_MessageHeader::size, tc, GNUNET_MessageHeader::type, and unicast().

Referenced by GST_clients_broadcast_disconnect(), neighbours_connect_notification(), process_hello_update(), and send_outbound_quota_to_clients().

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

◆ GST_clients_broadcast_peer_notification()

void GST_clients_broadcast_peer_notification ( const struct GNUNET_PeerIdentity peer,
const struct GNUNET_HELLO_Address address,
enum GNUNET_TRANSPORT_PeerState  state,
struct GNUNET_TIME_Absolute  state_timeout 
)

Broadcast the new active address to all clients monitoring the peer.

Parameters
peerpeer this update is about (never NULL)
addressaddress, NULL on disconnect
statethe current state of the peer
state_timeoutthe time out for the state

Definition at line 1320 of file gnunet-service-transport.c.

1325 {
1326  struct GNUNET_MQ_Envelope *env;
1328 
1330  msg->state = htonl (state);
1331  msg->state_timeout = GNUNET_TIME_absolute_hton (state_timeout);
1332  for (struct TransportClient *tc = clients_head; NULL != tc; tc = tc->next)
1333  {
1334  if (CT_MONITOR != tc->type)
1335  continue;
1336  if ((0 == memcmp (&tc->details.monitor_peer,
1337  &all_zeros,
1338  sizeof(struct GNUNET_PeerIdentity))) ||
1339  (0 == memcmp (&tc->details.monitor_peer,
1340  peer,
1341  sizeof(struct GNUNET_PeerIdentity))))
1342  {
1343  env = GNUNET_MQ_msg_copy (&msg->header);
1344  GNUNET_MQ_send (tc->mq, env);
1345  }
1346  }
1347  GNUNET_free (msg);
1348 }
struct GNUNET_MQ_Envelope * env
Definition: 005.c:1
enum State state
current state of profiling
static struct GNUNET_PeerIdentity all_zeros
Peer identity that is all zeros, used as a way to indicate "all peers".
static struct PeerIterateResponseMessage * compose_address_iterate_response_message(const struct GNUNET_PeerIdentity *peer, const struct GNUNET_HELLO_Address *address)
Compose PeerIterateResponseMessage using the given peer and address.
@ CT_MONITOR
It is a monitor, forward monitor data.
void GNUNET_MQ_send(struct GNUNET_MQ_Handle *mq, struct GNUNET_MQ_Envelope *ev)
Send a message with the given message queue.
Definition: mq.c:304
struct GNUNET_MQ_Envelope * GNUNET_MQ_msg_copy(const struct GNUNET_MessageHeader *hdr)
Create a new envelope by copying an existing message.
Definition: mq.c:533
struct GNUNET_TIME_AbsoluteNBO GNUNET_TIME_absolute_hton(struct GNUNET_TIME_Absolute a)
Convert absolute time to network byte order.
Definition: time.c:638
The identity of the host (wraps the signing key of the peer).
Message from the transport service to the library containing information about a peer.
Definition: transport.h:538
struct GNUNET_TIME_AbsoluteNBO state_timeout
Timeout for the state this peer is in.
Definition: transport.h:557

References address, all_zeros, clients_head, compose_address_iterate_response_message(), CT_MONITOR, env, GNUNET_free, GNUNET_MQ_msg_copy(), GNUNET_MQ_send(), GNUNET_TIME_absolute_hton(), msg, peer, state, PeerIterateResponseMessage::state_timeout, and tc.

Referenced by neighbours_changed_notification().

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

◆ GST_clients_broadcast_disconnect()

void GST_clients_broadcast_disconnect ( const struct GNUNET_PeerIdentity peer)

Notify all clients about a disconnect, and cancel pending SEND_OK messages for this peer.

Parameters
peerpeer that disconnected

Definition at line 1377 of file gnunet-service-transport.c.

1378 {
1379  struct DisconnectInfoMessage disconnect_msg;
1380 
1382  peer,
1383  &mark_peer_down,
1384  NULL);
1385  disconnect_msg.header.size = htons (sizeof(struct DisconnectInfoMessage));
1386  disconnect_msg.header.type = htons (GNUNET_MESSAGE_TYPE_TRANSPORT_DISCONNECT);
1387  disconnect_msg.reserved = htonl (0);
1388  disconnect_msg.peer = *peer;
1389  GST_clients_broadcast (&disconnect_msg.header, GNUNET_NO);
1390 }
static int mark_peer_down(void *cls, const struct GNUNET_PeerIdentity *peer, void *value)
Mark the peer as down so we don't call the continuation context in the future.
void GST_clients_broadcast(const struct GNUNET_MessageHeader *msg, int may_drop)
Broadcast the given message to all of our clients.
static struct GNUNET_CONTAINER_MultiPeerMap * active_stccs
Map of peer identities to active send transmit continuation contexts.
#define GNUNET_MESSAGE_TYPE_TRANSPORT_DISCONNECT
Message from TRANSPORT notifying about a client that disconnected from us.
Message from the transport service to the library informing about disconnects.
Definition: transport.h:150

References active_stccs, GNUNET_CONTAINER_multipeermap_get_multiple(), GNUNET_MESSAGE_TYPE_TRANSPORT_DISCONNECT, GNUNET_NO, GST_clients_broadcast(), DisconnectInfoMessage::header, mark_peer_down(), peer, DisconnectInfoMessage::peer, DisconnectInfoMessage::reserved, GNUNET_MessageHeader::size, and GNUNET_MessageHeader::type.

Referenced by neighbours_disconnect_notification().

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

Variable Documentation

◆ GST_stats

◆ GST_cfg

const struct GNUNET_CONFIGURATION_Handle* GST_cfg
extern

Configuration handle.

Definition at line 372 of file gnunet-service-transport.c.

Referenced by run().

◆ GST_my_identity

struct GNUNET_PeerIdentity GST_my_identity
extern

Configuration handle.

Definition at line 372 of file gnunet-service-transport.c.

Referenced by handle_client_start(), run(), and transmit_our_hello().

◆ GST_peerinfo

struct GNUNET_PEERINFO_Handle* GST_peerinfo
extern

Handle to peerinfo service.

Definition at line 382 of file gnunet-service-transport.c.

Referenced by GST_validation_handle_pong(), refresh_hello_task(), run(), and shutdown_task().

◆ GST_my_private_key

struct GNUNET_CRYPTO_EddsaPrivateKey GST_my_private_key
extern

Our private key.

Definition at line 382 of file gnunet-service-transport.c.

Referenced by run().

◆ GST_ats

struct GNUNET_ATS_SchedulingHandle* GST_ats
extern

ATS handle.

ATS handle.

Definition at line 392 of file gnunet-service-transport.c.

Referenced by GST_ats_add_address(), GST_ats_add_inbound_address(), run(), shutdown_task(), and unblock_address().

◆ GST_ats_connect

struct GNUNET_ATS_ConnectivityHandle* GST_ats_connect
extern

ATS connectivity handle.

Definition at line 397 of file gnunet-service-transport.c.

Referenced by run(), setup_neighbour(), and shutdown_task().

◆ GST_is

struct GNUNET_NT_InterfaceScanner* GST_is
extern

Interface scanner determines our LAN address range(s).

Definition at line 417 of file gnunet-service-transport.c.

Referenced by run(), and shutdown_task().