GNUnet  0.10.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 106 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 2301 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().

2303 {
2304  char *transport = NULL;
2305 
2306  if (NULL != transport_name)
2307  {
2309  "Adding peer `%s' with plugin `%s' to blacklist\n",
2310  GNUNET_i2s(peer),
2311  transport_name);
2312  transport = GNUNET_strdup(transport_name);
2313  }
2314  else
2316  "Adding peer `%s' with all plugins to blacklist\n",
2317  GNUNET_i2s(peer));
2318  if (NULL == blacklist)
2319  blacklist =
2321  GNUNET_NO);
2322 
2324  peer,
2325  transport,
2327 }
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 2417 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().

2423 {
2424  struct GST_BlacklistCheck *bc;
2425  struct TransportClient *tc;
2426 
2427  GNUNET_assert(NULL != peer);
2429  "Blacklist check for peer `%s':%s\n",
2430  GNUNET_i2s(peer),
2431  (NULL != transport_name) ? transport_name : "unspecified");
2432 
2433  /* Check local blacklist by iterating over hashmap
2434  * If iteration is aborted, we found a matching blacklist entry */
2435  if ((NULL != blacklist) &&
2436  (GNUNET_SYSERR ==
2438  peer,
2440  (void *)transport_name)))
2441  {
2442  /* Disallowed by config, disapprove instantly */
2444  gettext_noop("# disconnects due to blacklist"),
2445  1,
2446  GNUNET_NO);
2448  _("Disallowing connection to peer `%s' on transport %s\n"),
2449  GNUNET_i2s(peer),
2450  (NULL != transport_name) ? transport_name : "unspecified");
2451  if (NULL != cont)
2452  cont(cont_cls, peer, address, session, GNUNET_NO);
2453  return NULL;
2454  }
2455 
2456  for (tc = clients_head; NULL != tc; tc = tc->next)
2457  if (CT_BLACKLIST == tc->type)
2458  break;
2459  if (NULL == tc)
2460  {
2461  /* no blacklist clients, approve instantly */
2462  if (NULL != cont)
2463  cont(cont_cls, peer, address, session, GNUNET_OK);
2465  "Allowing connection to peer `%s' %s\n",
2466  GNUNET_i2s(peer),
2467  (NULL != transport_name) ? transport_name : "");
2468  return NULL;
2469  }
2470 
2471  /* need to query blacklist clients */
2472  bc = GNUNET_new(struct GST_BlacklistCheck);
2474  bc->peer = *peer;
2475  bc->address = GNUNET_HELLO_address_copy(address);
2476  bc->session = session;
2477  bc->cont = cont;
2478  bc->cont_cls = cont_cls;
2479  bc->bl_pos = tc;
2481  return bc;
2482 }
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:410
#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:1264
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 2337 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().

2339 {
2340  struct GST_BlacklistCheck *bc;
2341  struct GST_BlacklistCheck *n;
2342 
2343  n = bc_head;
2344  while (NULL != (bc = n))
2345  {
2346  n = bc->next;
2347  if ((bc->session == session) &&
2348  (0 == GNUNET_HELLO_address_cmp(bc->address, address)))
2349  {
2350  bc->cont(bc->cont_cls,
2351  &bc->peer,
2352  bc->address,
2353  bc->session,
2354  GNUNET_SYSERR);
2356  }
2357  }
2358 }
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 2491 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().

2492 {
2494  if (NULL != bc->bl_pos)
2495  {
2496  if ((CT_BLACKLIST == bc->bl_pos->type) &&
2497  (bc->bl_pos->details.blacklist.bc == bc))
2498  {
2499  /* we're at the head of the queue, remove us! */
2500  bc->bl_pos->details.blacklist.bc = NULL;
2501  }
2502  }
2503  if (NULL != bc->task)
2504  {
2506  bc->task = NULL;
2507  }
2509  GNUNET_free(bc);
2510 }
#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.
struct TransportClient::@81::@82 blacklist
Additional details if type is CT_BLACKLIST.
#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 * bl_pos
Our current position in the blacklisters list.
union TransportClient::@75 details
struct GNUNET_SCHEDULER_Task * task
Current task performing the check.
#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:956
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 1590 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().

1594 {
1595  const char *plugin_name = cls;
1596  struct GNUNET_TIME_Relative ret;
1597  uint16_t type;
1598 
1600  if (NULL == message)
1601  goto end;
1602  type = ntohs(message->type);
1604  "Received message with type %u from peer `%s' at %s\n",
1605  type,
1606  GNUNET_i2s(&address->peer),
1607  GST_plugins_a2s(address));
1608 
1610  gettext_noop("# bytes total received"),
1611  ntohs(message->size),
1612  GNUNET_NO);
1613  GST_neighbours_notify_data_recv(address, message);
1614  switch (type)
1615  {
1617  /* Legacy HELLO message, discard */
1618  return ret;
1619 
1621  if (GNUNET_OK != GST_validation_handle_hello(message))
1622  {
1623  GNUNET_break_op(0);
1624  GST_blacklist_abort_matching(address, session);
1625  }
1626  return ret;
1627 
1630  "Processing PING from `%s'\n",
1631  GST_plugins_a2s(address));
1632  if (GNUNET_OK !=
1633  GST_validation_handle_ping(&address->peer, message, address, session))
1634  {
1635  GST_blacklist_abort_matching(address, session);
1636  kill_session(plugin_name, session);
1637  }
1638  break;
1639 
1642  "Processing PONG from `%s'\n",
1643  GST_plugins_a2s(address));
1644  if (GNUNET_OK != GST_validation_handle_pong(&address->peer, message))
1645  {
1646  GNUNET_break_op(0);
1647  GST_blacklist_abort_matching(address, session);
1648  kill_session(plugin_name, session);
1649  }
1650  break;
1651 
1653  /* Do blacklist check if communication with this peer is allowed */
1654  (void)GST_blacklist_test_allowed(&address->peer,
1655  NULL,
1657  GNUNET_copy_message(message),
1658  address,
1659  session);
1660  break;
1661 
1663  if (GNUNET_OK !=
1664  GST_neighbours_handle_session_syn_ack(message, address, session))
1665  {
1666  GST_blacklist_abort_matching(address, session);
1667  kill_session(plugin_name, session);
1668  }
1669  break;
1670 
1672  if (GNUNET_OK !=
1673  GST_neighbours_handle_session_ack(message, address, session))
1674  {
1675  GNUNET_break_op(0);
1676  GST_blacklist_abort_matching(address, session);
1677  kill_session(plugin_name, session);
1678  }
1679  break;
1680 
1682  GST_neighbours_handle_disconnect_message(&address->peer, message);
1683  break;
1684 
1686  GST_neighbours_handle_quota_message(&address->peer, message);
1687  break;
1688 
1690  GST_neighbours_keepalive(&address->peer, message);
1691  break;
1692 
1694  GST_neighbours_keepalive_response(&address->peer, message);
1695  break;
1696 
1697  default:
1698  /* should be payload */
1700  gettext_noop("# bytes payload received"),
1701  ntohs(message->size),
1702  GNUNET_NO);
1703  ret = process_payload(address, session, message);
1704  break;
1705  }
1706 end:
1708  "Allowing receive from peer %s to continue in %s\n",
1709  GNUNET_i2s(&address->peer),
1711  return ret;
1712 }
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.
#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.
static int ret
Final status code.
Definition: gnunet-arm.c:89
#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:686
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.
static char * plugin_name
Solver plugin name as string.
#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).
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 1271 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().

1272 {
1273  int done;
1274 
1276  "Asked to broadcast message of type %u with %u bytes\n",
1277  (unsigned int)ntohs(msg->type),
1278  (unsigned int)ntohs(msg->size));
1279  done = GNUNET_NO;
1280  for (struct TransportClient *tc = clients_head; NULL != tc; tc = tc->next)
1281  {
1282  if (CT_NONE == tc->type)
1283  continue; /* client not yet ready */
1284  if ((GNUNET_YES == may_drop) && (CT_CORE != tc->type))
1285  continue; /* skip, this client does not care about payload */
1286  unicast(tc, msg, may_drop);
1287  done = GNUNET_YES;
1288  }
1289  if (GNUNET_NO == done)
1291  "Message of type %u not delivered, is CORE service up?\n",
1292  ntohs(msg->type));
1293 }
static void done()
static struct GNUNET_SCHEDULER_TaskContext tc
Task context of the current task.
Definition: scheduler.c:410
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 1305 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().

1310 {
1311  struct GNUNET_MQ_Envelope *env;
1313 
1314  msg = compose_address_iterate_response_message(peer, address);
1315  msg->state = htonl(state);
1316  msg->state_timeout = GNUNET_TIME_absolute_hton(state_timeout);
1317  for (struct TransportClient *tc = clients_head; NULL != tc; tc = tc->next)
1318  {
1319  if (CT_MONITOR != tc->type)
1320  continue;
1321  if ((0 == memcmp(&tc->details.monitor_peer,
1322  &all_zeros,
1323  sizeof(struct GNUNET_PeerIdentity))) ||
1324  (0 == memcmp(&tc->details.monitor_peer,
1325  peer,
1326  sizeof(struct GNUNET_PeerIdentity))))
1327  {
1328  env = GNUNET_MQ_msg_copy(&msg->header);
1329  GNUNET_MQ_send(tc->mq, env);
1330  }
1331  }
1332  GNUNET_free(msg);
1333 }
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:651
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:410
struct GNUNET_TIME_AbsoluteNBO state_timeout
Timeout for the state this peer is in.
Definition: transport.h:542
Message from the transport service to the library containing information about a peer.
Definition: transport.h:523
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:552
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:527
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:351
struct GNUNET_TIME_AbsoluteNBO GNUNET_TIME_absolute_hton(struct GNUNET_TIME_Absolute a)
Convert absolute time to network byte order.
Definition: time.c:655
#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 1362 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().

1363 {
1364  struct DisconnectInfoMessage disconnect_msg;
1365 
1367  peer,
1368  &mark_peer_down,
1369  NULL);
1370  disconnect_msg.header.size = htons(sizeof(struct DisconnectInfoMessage));
1371  disconnect_msg.header.type = htons(GNUNET_MESSAGE_TYPE_TRANSPORT_DISCONNECT);
1372  disconnect_msg.reserved = htonl(0);
1373  disconnect_msg.peer = *peer;
1374  GST_clients_broadcast(&disconnect_msg.header, GNUNET_NO);
1375 }
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:147
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 359 of file gnunet-service-transport.c.

◆ GST_cfg

const struct GNUNET_CONFIGURATION_Handle* GST_cfg

Configuration handle.

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

◆ GST_my_identity

struct GNUNET_PeerIdentity GST_my_identity

Configuration handle.

Definition at line 369 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 374 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 379 of file gnunet-service-transport.c.

◆ GST_ats

struct GNUNET_ATS_SchedulingHandle* GST_ats

ATS handle.

ATS handle.

Definition at line 384 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 389 of file gnunet-service-transport.c.

Referenced by setup_neighbour().

◆ GST_is

Interface scanner determines our LAN address range(s).

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

Referenced by plugin_env_address_to_type().