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

2314 {
2315  char *transport = NULL;
2316 
2317  if (NULL != transport_name)
2318  {
2320  "Adding peer `%s' with plugin `%s' to blacklist\n",
2321  GNUNET_i2s (peer),
2322  transport_name);
2323  transport = GNUNET_strdup (transport_name);
2324  }
2325  else
2327  "Adding peer `%s' with all plugins to blacklist\n",
2328  GNUNET_i2s (peer));
2329  if (NULL == blacklist)
2330  blacklist =
2332  GNUNET_NO);
2333 
2335  peer,
2336  transport,
2338 }
static struct GNUNET_TRANSPORT_CoreHandle * transport
Transport service.
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 2426 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().

2432 {
2433  struct GST_BlacklistCheck *bc;
2434  struct TransportClient *tc;
2435 
2436  GNUNET_assert (NULL != peer);
2438  "Blacklist check for peer `%s':%s\n",
2439  GNUNET_i2s (peer),
2440  (NULL != transport_name) ? transport_name : "unspecified");
2441 
2442  /* Check local blacklist by iterating over hashmap
2443  * If iteration is aborted, we found a matching blacklist entry */
2444  if ((NULL != blacklist) &&
2445  (GNUNET_SYSERR ==
2447  peer,
2449  (void *) transport_name)))
2450  {
2451  /* Disallowed by config, disapprove instantly */
2453  gettext_noop ("# disconnects due to blacklist"),
2454  1,
2455  GNUNET_NO);
2457  _ ("Disallowing connection to peer `%s' on transport %s\n"),
2458  GNUNET_i2s (peer),
2459  (NULL != transport_name) ? transport_name : "unspecified");
2460  if (NULL != cont)
2461  cont (cont_cls, peer, address, session, GNUNET_NO);
2462  return NULL;
2463  }
2464 
2465  for (tc = clients_head; NULL != tc; tc = tc->next)
2466  if (CT_BLACKLIST == tc->type)
2467  break;
2468  if (NULL == tc)
2469  {
2470  /* no blacklist clients, approve instantly */
2471  if (NULL != cont)
2472  cont (cont_cls, peer, address, session, GNUNET_OK);
2474  "Allowing connection to peer `%s' %s\n",
2475  GNUNET_i2s (peer),
2476  (NULL != transport_name) ? transport_name : "");
2477  return NULL;
2478  }
2479 
2480  /* need to query blacklist clients */
2481  bc = GNUNET_new (struct GST_BlacklistCheck);
2483  bc->peer = *peer;
2484  bc->address = GNUNET_HELLO_address_copy (address);
2485  bc->session = session;
2486  bc->cont = cont;
2487  bc->cont_cls = cont_cls;
2488  bc->bl_pos = tc;
2490  return bc;
2491 }
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:423
#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:184
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:1296
struct GNUNET_TESTBED_Peer * peer
The peer associated with this model.
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 2348 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().

2350 {
2351  struct GST_BlacklistCheck *bc;
2352  struct GST_BlacklistCheck *n;
2353 
2354  n = bc_head;
2355  while (NULL != (bc = n))
2356  {
2357  n = bc->next;
2358  if ((bc->session == session) &&
2359  (0 == GNUNET_HELLO_address_cmp (bc->address, address)))
2360  {
2361  bc->cont (bc->cont_cls,
2362  &bc->peer,
2363  bc->address,
2364  bc->session,
2365  GNUNET_SYSERR);
2367  }
2368  }
2369 }
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
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 2500 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_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().

2501 {
2503  if (NULL != bc->bl_pos)
2504  {
2505  if ((CT_BLACKLIST == bc->bl_pos->type) &&
2506  (bc->bl_pos->details.blacklist.bc == bc))
2507  {
2508  /* we're at the head of the queue, remove us! */
2509  bc->bl_pos->details.blacklist.bc = NULL;
2510  }
2511  }
2512  if (NULL != bc->task)
2513  {
2515  bc->task = NULL;
2516  }
2517  GNUNET_free (bc->address);
2518  GNUNET_free (bc);
2519 }
#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.
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::@91::@92 blacklist
Additional details if type is CT_BLACKLIST.
union TransportClient::@85 details
struct TransportClient * bl_pos
Our current position in the blacklisters list.
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:972
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 1605 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().

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),
1622  GST_plugins_a2s (address));
1623 
1625  gettext_noop ("# bytes total received"),
1626  ntohs (message->size),
1627  GNUNET_NO);
1628  GST_neighbours_notify_data_recv (address, message);
1629  switch (type)
1630  {
1632  /* Legacy HELLO message, discard */
1633  return ret;
1634 
1636  if (GNUNET_OK != GST_validation_handle_hello (message))
1637  {
1638  GNUNET_break_op (0);
1639  GST_blacklist_abort_matching (address, session);
1640  }
1641  return ret;
1642 
1645  "Processing PING from `%s'\n",
1646  GST_plugins_a2s (address));
1647  if (GNUNET_OK !=
1648  GST_validation_handle_ping (&address->peer, message, address, session))
1649  {
1650  GST_blacklist_abort_matching (address, session);
1651  kill_session (plugin_name, session);
1652  }
1653  break;
1654 
1657  "Processing PONG from `%s'\n",
1658  GST_plugins_a2s (address));
1659  if (GNUNET_OK != GST_validation_handle_pong (&address->peer, message))
1660  {
1661  GNUNET_break_op (0);
1662  GST_blacklist_abort_matching (address, session);
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  {
1681  GST_blacklist_abort_matching (address, session);
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);
1691  GST_blacklist_abort_matching (address, session);
1692  kill_session (plugin_name, session);
1693  }
1694  break;
1695 
1697  GST_neighbours_handle_disconnect_message (&address->peer, message);
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 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
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:702
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_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 1286 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().

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 }
static void done()
static struct GNUNET_SCHEDULER_TaskContext tc
Task context of the current task.
Definition: scheduler.c:423
We do not know yet (client is fresh).
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,...)
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 1320 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().

1325 {
1326  struct GNUNET_MQ_Envelope *env;
1328 
1329  msg = compose_address_iterate_response_message (peer, address);
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 * GNUNET_MQ_msg_copy(const struct GNUNET_MessageHeader *hdr)
Create a new envelope by copying an existing message.
Definition: mq.c:666
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:423
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:355
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 1377 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().

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

Referenced by run().

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