GNUnet  0.11.x
Macros | Typedefs | Functions | Variables
gnunet-service-transport.h File Reference

globals More...

#include "gnunet_util_lib.h"
#include "gnunet_statistics_service.h"
#include "gnunet_ats_service.h"
#include "gnunet_transport_service.h"
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_EddsaPrivateKeyGST_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 85 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 112 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 2311 of file gnunet-service-transport.c.

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

Referenced by blacklist_cfg_iter(), and run().

2313 {
2314  char *transport = NULL;
2315 
2316  if (NULL != transport_name)
2317  {
2319  "Adding peer `%s' with plugin `%s' to blacklist\n",
2320  GNUNET_i2s (peer),
2321  transport_name);
2322  transport = GNUNET_strdup (transport_name);
2323  }
2324  else
2326  "Adding peer `%s' with all plugins to blacklist\n",
2327  GNUNET_i2s (peer));
2328  if (NULL == blacklist)
2329  blacklist =
2331  GNUNET_NO);
2332 
2334  peer,
2335  transport,
2337 }
static struct GNUNET_TRANSPORT_CoreHandle * transport
Transport service.
#define GNUNET_NO
Definition: gnunet_common.h:78
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).
#define GNUNET_strdup(a)
Wrapper around GNUNET_xstrdup_.
static struct GNUNET_CONTAINER_MultiPeerMap * blacklist
Hashmap of blacklisted peers.
Allow multiple values with the same key.
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.
#define GNUNET_log(kind,...)
#define TRANSPORT_BLACKLIST_HT_SIZE
Size of the blacklist hash map.
const char * GNUNET_i2s(const struct GNUNET_PeerIdentity *pid)
Convert a peer identity to a string (for printing debug messages).
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 2425 of file gnunet-service-transport.c.

References _, GST_BlacklistCheck::address, TransportClient::bc, GST_BlacklistCheck::bl_pos, 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, TransportClient::next, peer, GST_BlacklistCheck::peer, GNUNET_ATS_SessionKiller::session, GST_BlacklistCheck::session, GST_BlacklistCheck::task, tc, test_blacklisted(), and TransportClient::type.

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

2431 {
2432  struct GST_BlacklistCheck *bc;
2433  struct TransportClient *tc;
2434 
2435  GNUNET_assert (NULL != peer);
2437  "Blacklist check for peer `%s':%s\n",
2438  GNUNET_i2s (peer),
2439  (NULL != transport_name) ? transport_name : "unspecified");
2440 
2441  /* Check local blacklist by iterating over hashmap
2442  * If iteration is aborted, we found a matching blacklist entry */
2443  if ((NULL != blacklist) &&
2444  (GNUNET_SYSERR ==
2446  peer,
2448  (void *) transport_name)))
2449  {
2450  /* Disallowed by config, disapprove instantly */
2452  gettext_noop ("# disconnects due to blacklist"),
2453  1,
2454  GNUNET_NO);
2456  _ ("Disallowing connection to peer `%s' on transport %s\n"),
2457  GNUNET_i2s (peer),
2458  (NULL != transport_name) ? transport_name : "unspecified");
2459  if (NULL != cont)
2460  cont (cont_cls, peer, address, session, GNUNET_NO);
2461  return NULL;
2462  }
2463 
2464  for (tc = clients_head; NULL != tc; tc = tc->next)
2465  if (CT_BLACKLIST == tc->type)
2466  break;
2467  if (NULL == tc)
2468  {
2469  /* no blacklist clients, approve instantly */
2470  if (NULL != cont)
2471  cont (cont_cls, peer, address, session, GNUNET_OK);
2473  "Allowing connection to peer `%s' %s\n",
2474  GNUNET_i2s (peer),
2475  (NULL != transport_name) ? transport_name : "");
2476  return NULL;
2477  }
2478 
2479  /* need to query blacklist clients */
2480  bc = GNUNET_new (struct GST_BlacklistCheck);
2482  bc->peer = *peer;
2483  bc->address = GNUNET_HELLO_address_copy (address);
2484  bc->session = session;
2485  bc->cont = cont;
2486  bc->cont_cls = cont_cls;
2487  bc->bl_pos = tc;
2489  return bc;
2490 }
struct GNUNET_HELLO_Address * address
Address for GST_blacklist_abort_matching(), can be NULL.
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 GNUNET_STATISTICS_Handle * GST_stats
Statistics handle.
#define GNUNET_assert(cond)
Use this for fatal errors that cannot be handled.
static struct GNUNET_SCHEDULER_TaskContext tc
Task context of the current task.
Definition: scheduler.c:418
#define GNUNET_NO
Definition: gnunet_common.h:78
#define GNUNET_OK
Named constants for return values.
Definition: gnunet_common.h:75
#define GNUNET_new(type)
Allocate a struct or union of the given type.
static void do_blacklist_check(void *cls)
Perform next action in the blacklist check.
static struct TransportClient * clients_head
Head of linked list of all clients to this service.
void GNUNET_STATISTICS_update(struct GNUNET_STATISTICS_Handle *handle, const char *name, int64_t delta, int make_persistent)
Set statistic value for the peer.
enum ClientType type
What type of client is this?
It is a blacklist, query about allowed connections.
#define _(String)
GNU gettext support macro.
Definition: platform.h:181
struct GNUNET_ATS_Session * session
Session for GST_blacklist_abort_matching(), can be NULL.
static struct GST_BlacklistCheck * bc_head
Head of DLL of active blacklisting queries.
struct GST_BlacklistCheck * bc
Blacklist check that we're currently performing (or NULL if we're performing one that has been cancel...
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:1280
struct GNUNET_TESTBED_Peer * peer
The peer associated with this model.
#define GNUNET_SYSERR
Definition: gnunet_common.h:76
GST_BlacklistTestContinuation cont
Continuation to call with the result.
static struct GNUNET_CONTAINER_MultiPeerMap * blacklist
Hashmap of blacklisted peers.
static int test_blacklisted(void *cls, const struct GNUNET_PeerIdentity *key, void *value)
Test if the given blacklist entry matches.
struct TransportClient * next
Kept in a DLL.
struct TransportClient * bl_pos
Our current position in the blacklisters list.
struct GNUNET_SCHEDULER_Task * task
Current task performing the check.
struct GNUNET_HELLO_Address * GNUNET_HELLO_address_copy(const struct GNUNET_HELLO_Address *address)
Copy an address struct.
Definition: address.c:109
Client connected to the transport service.
#define GNUNET_log(kind,...)
struct GNUNET_PeerIdentity peer
Peer being checked.
void * cont_cls
Closure for cont.
const char * GNUNET_i2s(const struct GNUNET_PeerIdentity *pid)
Convert a peer identity to a string (for printing debug messages).
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.
#define gettext_noop(String)
Definition: gettext.h:69
static struct GST_BlacklistCheck * bc_tail
Tail of DLL of active blacklisting queries.
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 2347 of file gnunet-service-transport.c.

References 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(), GST_receive_callback(), and plugin_env_session_end().

2349 {
2350  struct GST_BlacklistCheck *bc;
2351  struct GST_BlacklistCheck *n;
2352 
2353  n = bc_head;
2354  while (NULL != (bc = n))
2355  {
2356  n = bc->next;
2357  if ((bc->session == session) &&
2358  (0 == GNUNET_HELLO_address_cmp (bc->address, address)))
2359  {
2360  bc->cont (bc->cont_cls,
2361  &bc->peer,
2362  bc->address,
2363  bc->session,
2364  GNUNET_SYSERR);
2366  }
2367  }
2368 }
struct GNUNET_HELLO_Address * address
Address for GST_blacklist_abort_matching(), can be NULL.
Context we use when performing a blacklist check.
struct GST_BlacklistCheck * next
This is a linked list.
struct GNUNET_ATS_Session * session
Session for GST_blacklist_abort_matching(), can be NULL.
static struct GST_BlacklistCheck * bc_head
Head of DLL of active blacklisting queries.
int GNUNET_HELLO_address_cmp(const struct GNUNET_HELLO_Address *a1, const struct GNUNET_HELLO_Address *a2)
Compare two addresses.
Definition: address.c:130
#define GNUNET_SYSERR
Definition: gnunet_common.h:76
void GST_blacklist_test_cancel(struct GST_BlacklistCheck *bc)
Cancel a blacklist check.
GST_BlacklistTestContinuation cont
Continuation to call with the result.
struct GNUNET_PeerIdentity peer
Peer being checked.
void * cont_cls
Closure for cont.
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 2499 of file gnunet-service-transport.c.

References GST_BlacklistCheck::address, GST_BlacklistCheck::bl_pos, TransportClient::blacklist, CT_BLACKLIST, TransportClient::details, GNUNET_CONTAINER_DLL_remove, GNUNET_free, GNUNET_free_non_null, 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().

2500 {
2502  if (NULL != bc->bl_pos)
2503  {
2504  if ((CT_BLACKLIST == bc->bl_pos->type) &&
2505  (bc->bl_pos->details.blacklist.bc == bc))
2506  {
2507  /* we're at the head of the queue, remove us! */
2508  bc->bl_pos->details.blacklist.bc = NULL;
2509  }
2510  }
2511  if (NULL != bc->task)
2512  {
2514  bc->task = NULL;
2515  }
2517  GNUNET_free (bc);
2518 }
#define GNUNET_CONTAINER_DLL_remove(head, tail, element)
Remove an element from a DLL.
struct GNUNET_HELLO_Address * address
Address for GST_blacklist_abort_matching(), can be NULL.
#define GNUNET_free_non_null(ptr)
Free the memory pointed to by ptr if ptr is not NULL.
enum ClientType type
What type of client is this?
It is a blacklist, query about allowed connections.
static struct GST_BlacklistCheck * bc_head
Head of DLL of active blacklisting queries.
struct TransportClient::@78::@79 blacklist
Additional details if type is CT_BLACKLIST.
struct TransportClient * bl_pos
Our current position in the blacklisters list.
struct GNUNET_SCHEDULER_Task * task
Current task performing the check.
union TransportClient::@72 details
#define GNUNET_free(ptr)
Wrapper around free.
static struct GST_BlacklistCheck * bc_tail
Tail of DLL of active blacklisting queries.
void * GNUNET_SCHEDULER_cancel(struct GNUNET_SCHEDULER_Task *task)
Cancel the task with the specified identifier.
Definition: scheduler.c:966
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 1599 of file gnunet-service-transport.c.

References address, connect_bl_check_cont(), end, gettext_noop, GNUNET_break_op, GNUNET_copy_message(), GNUNET_ERROR_TYPE_DEBUG, GNUNET_i2s(), GNUNET_log, GNUNET_MESSAGE_TYPE_HELLO, GNUNET_MESSAGE_TYPE_HELLO_LEGACY, GNUNET_MESSAGE_TYPE_TRANSPORT_PING, GNUNET_MESSAGE_TYPE_TRANSPORT_PONG, GNUNET_MESSAGE_TYPE_TRANSPORT_SESSION_ACK, GNUNET_MESSAGE_TYPE_TRANSPORT_SESSION_DISCONNECT, GNUNET_MESSAGE_TYPE_TRANSPORT_SESSION_KEEPALIVE, GNUNET_MESSAGE_TYPE_TRANSPORT_SESSION_KEEPALIVE_RESPONSE, GNUNET_MESSAGE_TYPE_TRANSPORT_SESSION_QUOTA, GNUNET_MESSAGE_TYPE_TRANSPORT_SESSION_SYN, GNUNET_MESSAGE_TYPE_TRANSPORT_SESSION_SYN_ACK, GNUNET_NO, GNUNET_OK, GNUNET_STATISTICS_update(), GNUNET_STRINGS_relative_time_to_string(), GNUNET_TIME_UNIT_ZERO, GNUNET_YES, GST_blacklist_abort_matching(), GST_blacklist_test_allowed(), GST_neighbours_handle_disconnect_message(), GST_neighbours_handle_quota_message(), GST_neighbours_handle_session_ack(), GST_neighbours_handle_session_syn_ack(), GST_neighbours_keepalive(), GST_neighbours_keepalive_response(), GST_neighbours_notify_data_recv(), GST_plugins_a2s(), GST_validation_handle_hello(), GST_validation_handle_ping(), GST_validation_handle_pong(), kill_session(), GNUNET_HELLO_Address::peer, plugin_name, process_payload(), ret, GNUNET_ATS_SessionKiller::session, and type.

Referenced by GST_manipulation_recv().

1603 {
1604  const char *plugin_name = cls;
1605  struct GNUNET_TIME_Relative ret;
1606  uint16_t type;
1607 
1609  if (NULL == message)
1610  goto end;
1611  type = ntohs (message->type);
1613  "Received message with type %u from peer `%s' at %s\n",
1614  type,
1615  GNUNET_i2s (&address->peer),
1616  GST_plugins_a2s (address));
1617 
1619  gettext_noop ("# bytes total received"),
1620  ntohs (message->size),
1621  GNUNET_NO);
1622  GST_neighbours_notify_data_recv (address, message);
1623  switch (type)
1624  {
1626  /* Legacy HELLO message, discard */
1627  return ret;
1628 
1630  if (GNUNET_OK != GST_validation_handle_hello (message))
1631  {
1632  GNUNET_break_op (0);
1633  GST_blacklist_abort_matching (address, session);
1634  }
1635  return ret;
1636 
1639  "Processing PING from `%s'\n",
1640  GST_plugins_a2s (address));
1641  if (GNUNET_OK !=
1642  GST_validation_handle_ping (&address->peer, message, address, session))
1643  {
1644  GST_blacklist_abort_matching (address, session);
1645  kill_session (plugin_name, session);
1646  }
1647  break;
1648 
1651  "Processing PONG from `%s'\n",
1652  GST_plugins_a2s (address));
1653  if (GNUNET_OK != GST_validation_handle_pong (&address->peer, message))
1654  {
1655  GNUNET_break_op (0);
1656  GST_blacklist_abort_matching (address, session);
1657  kill_session (plugin_name, session);
1658  }
1659  break;
1660 
1662  /* Do blacklist check if communication with this peer is allowed */
1663  (void) GST_blacklist_test_allowed (&address->peer,
1664  NULL,
1666  GNUNET_copy_message (message),
1667  address,
1668  session);
1669  break;
1670 
1672  if (GNUNET_OK !=
1673  GST_neighbours_handle_session_syn_ack (message, address, session))
1674  {
1675  GST_blacklist_abort_matching (address, session);
1676  kill_session (plugin_name, session);
1677  }
1678  break;
1679 
1681  if (GNUNET_OK !=
1682  GST_neighbours_handle_session_ack (message, address, session))
1683  {
1684  GNUNET_break_op (0);
1685  GST_blacklist_abort_matching (address, session);
1686  kill_session (plugin_name, session);
1687  }
1688  break;
1689 
1691  GST_neighbours_handle_disconnect_message (&address->peer, message);
1692  break;
1693 
1695  GST_neighbours_handle_quota_message (&address->peer, message);
1696  break;
1697 
1699  GST_neighbours_keepalive (&address->peer, message);
1700  break;
1701 
1703  GST_neighbours_keepalive_response (&address->peer, message);
1704  break;
1705 
1706  default:
1707  /* should be payload */
1709  gettext_noop ("# bytes payload received"),
1710  ntohs (message->size),
1711  GNUNET_NO);
1712  ret = process_payload (address, session, message);
1713  break;
1714  }
1715 end:
1717  "Allowing receive from peer %s to continue in %s\n",
1718  GNUNET_i2s (&address->peer),
1720  return ret;
1721 }
static int end
Set if we are to shutdown all services (including ARM).
Definition: gnunet-arm.c:34
#define GNUNET_MESSAGE_TYPE_TRANSPORT_PING
Transport PING message.
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...
struct GNUNET_STATISTICS_Handle * GST_stats
Statistics handle.
struct GST_BlacklistCheck * GST_blacklist_test_allowed(const struct GNUNET_PeerIdentity *peer, const char *transport_name, GST_BlacklistTestContinuation cont, void *cont_cls, const struct GNUNET_HELLO_Address *address, struct GNUNET_ATS_Session *session)
Test if a peer/transport combination is blacklisted.
void GST_blacklist_abort_matching(const struct GNUNET_HELLO_Address *address, struct GNUNET_ATS_Session *session)
Abort blacklist if address and session match.
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.
#define GNUNET_MESSAGE_TYPE_TRANSPORT_SESSION_QUOTA
Message exchanged between transport services to indicate that the sender should limit its transmissio...
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 int ret
Return value of the commandline.
Definition: gnunet-abd.c:81
#define GNUNET_NO
Definition: gnunet_common.h:78
#define GNUNET_OK
Named constants for return values.
Definition: gnunet_common.h:75
int GST_validation_handle_hello(const struct GNUNET_MessageHeader *hello)
We've received a HELLO, check which addresses are new and trigger validation.
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...
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...
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.
#define GNUNET_MESSAGE_TYPE_HELLO_LEGACY
Previously used for HELLO messages used for communicating peer addresses.
int GST_validation_handle_pong(const struct GNUNET_PeerIdentity *sender, const struct GNUNET_MessageHeader *hdr)
We've received a PONG.
uint16_t type
The type of the message (GNUNET_MESSAGE_TYPE_XXXX), in big-endian format.
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.
#define GNUNET_MESSAGE_TYPE_TRANSPORT_SESSION_SYN_ACK
Transport SYN_ACK message exchanged between transport services to indicate that a SYN message was acc...
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.
static void kill_session(const char *plugin_name, struct GNUNET_ATS_Session *session)
Force plugin to terminate session due to communication issue.
#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:687
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...
const char * GST_plugins_a2s(const struct GNUNET_HELLO_Address *address)
Convert a given address to a human-readable format.
#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...
struct GNUNET_PeerIdentity peer
For which peer is this an address?
#define GNUNET_MESSAGE_TYPE_TRANSPORT_SESSION_DISCONNECT
Transport DISCONNECT message exchanged between transport services to indicate that a connection shoul...
#define GNUNET_TIME_UNIT_ZERO
Relative time zero.
#define GNUNET_MESSAGE_TYPE_TRANSPORT_PONG
Transport PONG message.
#define GNUNET_MESSAGE_TYPE_TRANSPORT_SESSION_SYN
Transport SYN message exchanged between transport services to indicate that a session should be marke...
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 adddress an...
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.
#define GNUNET_log(kind,...)
#define GNUNET_MESSAGE_TYPE_TRANSPORT_SESSION_ACK
Transport ACK message exchanged between transport services to indicate that a SYN_ACK message was acc...
enum GNUNET_TESTBED_UnderlayLinkModelType type
the type of this model
#define GNUNET_YES
Definition: gnunet_common.h:77
#define GNUNET_MESSAGE_TYPE_HELLO
HELLO message with friend only flag used for communicating peer addresses.
static char * address
GNS address for this phone.
const char * GNUNET_i2s(const struct GNUNET_PeerIdentity *pid)
Convert a peer identity to a string (for printing debug messages).
static char * plugin_name
Name of our plugin.
Time for relative time used by GNUnet, in microseconds.
struct GNUNET_MessageHeader * GNUNET_copy_message(const struct GNUNET_MessageHeader *msg)
Create a copy of the given message.
#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_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 1280 of file gnunet-service-transport.c.

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

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

1281 {
1282  int done;
1283 
1285  "Asked to broadcast message of type %u with %u bytes\n",
1286  (unsigned int) ntohs (msg->type),
1287  (unsigned int) ntohs (msg->size));
1288  done = GNUNET_NO;
1289  for (struct TransportClient *tc = clients_head; NULL != tc; tc = tc->next)
1290  {
1291  if (CT_NONE == tc->type)
1292  continue; /* client not yet ready */
1293  if ((GNUNET_YES == may_drop) && (CT_CORE != tc->type))
1294  continue; /* skip, this client does not care about payload */
1295  unicast (tc, msg, may_drop);
1296  done = GNUNET_YES;
1297  }
1298  if (GNUNET_NO == done)
1300  "Message of type %u not delivered, is CORE service up?\n",
1301  ntohs (msg->type));
1302 }
static void done()
static struct GNUNET_SCHEDULER_TaskContext tc
Task context of the current task.
Definition: scheduler.c:418
We do not know yet (client is fresh).
#define GNUNET_NO
Definition: gnunet_common.h:78
static struct TransportClient * clients_head
Head of linked list of all clients to this service.
uint16_t size
The length of the struct (in bytes, including the length field itself), in big-endian format...
uint16_t type
The type of the message (GNUNET_MESSAGE_TYPE_XXXX), in big-endian format.
static void unicast(struct TransportClient *tc, const struct GNUNET_MessageHeader *msg, int may_drop)
Queue the given message for transmission to the given client.
Client connected to the transport service.
#define GNUNET_log(kind,...)
#define GNUNET_YES
Definition: gnunet_common.h:77
Is the CORE service, we need to forward traffic to it.
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 1314 of file gnunet-service-transport.c.

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

Referenced by neighbours_changed_notification().

1319 {
1320  struct GNUNET_MQ_Envelope *env;
1322 
1323  msg = compose_address_iterate_response_message (peer, address);
1324  msg->state = htonl (state);
1325  msg->state_timeout = GNUNET_TIME_absolute_hton (state_timeout);
1326  for (struct TransportClient *tc = clients_head; NULL != tc; tc = tc->next)
1327  {
1328  if (CT_MONITOR != tc->type)
1329  continue;
1330  if ((0 == memcmp (&tc->details.monitor_peer,
1331  &all_zeros,
1332  sizeof(struct GNUNET_PeerIdentity))) ||
1333  (0 == memcmp (&tc->details.monitor_peer,
1334  peer,
1335  sizeof(struct GNUNET_PeerIdentity))))
1336  {
1337  env = GNUNET_MQ_msg_copy (&msg->header);
1338  GNUNET_MQ_send (tc->mq, env);
1339  }
1340  }
1341  GNUNET_free (msg);
1342 }
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:653
struct GNUNET_MessageHeader * msg
Definition: 005.c:2
It is a monitor, forward monitor data.
static struct GNUNET_SCHEDULER_TaskContext tc
Task context of the current task.
Definition: scheduler.c:418
struct GNUNET_TIME_AbsoluteNBO state_timeout
Timeout for the state this peer is in.
Definition: transport.h:557
Message from the transport service to the library containing information about a peer.
Definition: transport.h:537
static struct TransportClient * clients_head
Head of linked list of all clients to this service.
uint32_t state
State this peer is in as an enum GNUNET_TRANSPORT_PeerState
Definition: transport.h:567
enum State state
current state of profiling
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.
struct GNUNET_MQ_Envelope * env
Definition: 005.c:1
static struct GNUNET_PeerIdentity all_zeros
Peer identity that is all zeros, used as a way to indicate "all peers".
The identity of the host (wraps the signing key of the peer).
Client connected to the transport service.
struct GNUNET_MessageHeader header
Type is GNUNET_MESSAGE_TYPE_TRANSPORT_MONITOR_PEER_RESPONSE.
Definition: transport.h:542
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:353
struct GNUNET_TIME_AbsoluteNBO GNUNET_TIME_absolute_hton(struct GNUNET_TIME_Absolute a)
Convert absolute time to network byte order.
Definition: time.c:657
#define GNUNET_free(ptr)
Wrapper around free.
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 1371 of file gnunet-service-transport.c.

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

1372 {
1373  struct DisconnectInfoMessage disconnect_msg;
1374 
1376  peer,
1377  &mark_peer_down,
1378  NULL);
1379  disconnect_msg.header.size = htons (sizeof(struct DisconnectInfoMessage));
1380  disconnect_msg.header.type = htons (GNUNET_MESSAGE_TYPE_TRANSPORT_DISCONNECT);
1381  disconnect_msg.reserved = htonl (0);
1382  disconnect_msg.peer = *peer;
1383  GST_clients_broadcast (&disconnect_msg.header, GNUNET_NO);
1384 }
static struct GNUNET_CONTAINER_MultiPeerMap * active_stccs
Map of peer identities to active send transmit continuation contexts.
void GST_clients_broadcast(const struct GNUNET_MessageHeader *msg, int may_drop)
Broadcast the given message to all of our clients.
#define GNUNET_NO
Definition: gnunet_common.h:78
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.
#define GNUNET_MESSAGE_TYPE_TRANSPORT_DISCONNECT
Message from TRANSPORT notifying about a client that disconnected from us.
struct GNUNET_TESTBED_Peer * peer
The peer associated with this model.
Message from the transport service to the library informing about disconnects.
Definition: transport.h:149
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.
Here is the call graph for this function:
Here is the caller graph for this function:

Variable Documentation

◆ GST_stats

struct GNUNET_STATISTICS_Handle* GST_stats

Statistics handle.

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

◆ GST_cfg

const struct GNUNET_CONFIGURATION_Handle* GST_cfg

Configuration handle.

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

◆ GST_my_identity

struct GNUNET_PeerIdentity GST_my_identity

Configuration handle.

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

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

◆ GST_peerinfo

struct GNUNET_PEERINFO_Handle* GST_peerinfo

Handle to peerinfo service.

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

Referenced by GST_validation_handle_pong(), and refresh_hello_task().

◆ GST_my_private_key

struct GNUNET_CRYPTO_EddsaPrivateKey* GST_my_private_key

Our private key.

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

◆ GST_ats

struct GNUNET_ATS_SchedulingHandle* GST_ats

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(), and unblock_address().

◆ GST_ats_connect

struct GNUNET_ATS_ConnectivityHandle* GST_ats_connect

ATS connectivity handle.

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

Referenced by setup_neighbour().

◆ GST_is

Interface scanner determines our LAN address range(s).

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

Referenced by plugin_env_address_to_type().