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

2305 {
2306  char *transport = NULL;
2307 
2308  if (NULL != transport_name)
2309  {
2311  "Adding peer `%s' with plugin `%s' to blacklist\n",
2312  GNUNET_i2s (peer),
2313  transport_name);
2314  transport = GNUNET_strdup (transport_name);
2315  }
2316  else
2318  "Adding peer `%s' with all plugins to blacklist\n",
2319  GNUNET_i2s (peer));
2320  if (NULL == blacklist)
2321  blacklist =
2323  GNUNET_NO);
2324 
2326  peer,
2327  transport,
2329 }
static struct GNUNET_TRANSPORT_CoreHandle * transport
Transport service.
#define GNUNET_NO
Definition: gnunet_common.h:81
struct GNUNET_CONTAINER_MultiPeerMap * GNUNET_CONTAINER_multipeermap_create(unsigned int len, int do_not_copy_keys)
Create a multi peer map (hash map for public keys of peers).
#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 2419 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().

2425 {
2426  struct GST_BlacklistCheck *bc;
2427  struct TransportClient *tc;
2428 
2429  GNUNET_assert (NULL != peer);
2431  "Blacklist check for peer `%s':%s\n",
2432  GNUNET_i2s (peer),
2433  (NULL != transport_name) ? transport_name : "unspecified");
2434 
2435  /* Check local blacklist by iterating over hashmap
2436  * If iteration is aborted, we found a matching blacklist entry */
2437  if ((NULL != blacklist) &&
2438  (GNUNET_SYSERR ==
2440  peer,
2442  (void *) transport_name)))
2443  {
2444  /* Disallowed by config, disapprove instantly */
2446  gettext_noop ("# disconnects due to blacklist"),
2447  1,
2448  GNUNET_NO);
2450  _ ("Disallowing connection to peer `%s' on transport %s\n"),
2451  GNUNET_i2s (peer),
2452  (NULL != transport_name) ? transport_name : "unspecified");
2453  if (NULL != cont)
2454  cont (cont_cls, peer, address, session, GNUNET_NO);
2455  return NULL;
2456  }
2457 
2458  for (tc = clients_head; NULL != tc; tc = tc->next)
2459  if (CT_BLACKLIST == tc->type)
2460  break;
2461  if (NULL == tc)
2462  {
2463  /* no blacklist clients, approve instantly */
2464  if (NULL != cont)
2465  cont (cont_cls, peer, address, session, GNUNET_OK);
2467  "Allowing connection to peer `%s' %s\n",
2468  GNUNET_i2s (peer),
2469  (NULL != transport_name) ? transport_name : "");
2470  return NULL;
2471  }
2472 
2473  /* need to query blacklist clients */
2474  bc = GNUNET_new (struct GST_BlacklistCheck);
2476  bc->peer = *peer;
2477  bc->address = GNUNET_HELLO_address_copy (address);
2478  bc->session = session;
2479  bc->cont = cont;
2480  bc->cont_cls = cont_cls;
2481  bc->bl_pos = tc;
2483  return bc;
2484 }
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:417
#define GNUNET_NO
Definition: gnunet_common.h:81
#define GNUNET_OK
Named constants for return values.
Definition: gnunet_common.h:78
#define GNUNET_new(type)
Allocate a struct or union of the given type.
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:208
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:1273
struct GNUNET_TESTBED_Peer * peer
The peer associated with this model.
#define GNUNET_SYSERR
Definition: gnunet_common.h:79
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 2339 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().

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

2494 {
2496  if (NULL != bc->bl_pos)
2497  {
2498  if ((CT_BLACKLIST == bc->bl_pos->type) &&
2499  (bc->bl_pos->details.blacklist.bc == bc))
2500  {
2501  /* we're at the head of the queue, remove us! */
2502  bc->bl_pos->details.blacklist.bc = NULL;
2503  }
2504  }
2505  if (NULL != bc->task)
2506  {
2508  bc->task = NULL;
2509  }
2511  GNUNET_free (bc);
2512 }
#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:965
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 1602 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().

1606 {
1607  const char *plugin_name = cls;
1608  struct GNUNET_TIME_Relative ret;
1609  uint16_t type;
1610 
1612  if (NULL == message)
1613  goto end;
1614  type = ntohs (message->type);
1616  "Received message with type %u from peer `%s' at %s\n",
1617  type,
1618  GNUNET_i2s (&address->peer),
1619  GST_plugins_a2s (address));
1620 
1622  gettext_noop ("# bytes total received"),
1623  ntohs (message->size),
1624  GNUNET_NO);
1625  GST_neighbours_notify_data_recv (address, message);
1626  switch (type)
1627  {
1629  /* Legacy HELLO message, discard */
1630  return ret;
1632  if (GNUNET_OK != GST_validation_handle_hello (message))
1633  {
1634  GNUNET_break_op (0);
1635  GST_blacklist_abort_matching (address, session);
1636  }
1637  return ret;
1640  "Processing PING from `%s'\n",
1641  GST_plugins_a2s (address));
1642  if (GNUNET_OK !=
1643  GST_validation_handle_ping (&address->peer, message, address, session))
1644  {
1645  GST_blacklist_abort_matching (address, session);
1646  kill_session (plugin_name, session);
1647  }
1648  break;
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;
1661  /* Do blacklist check if communication with this peer is allowed */
1662  (void) GST_blacklist_test_allowed (&address->peer,
1663  NULL,
1665  GNUNET_copy_message (message),
1666  address,
1667  session);
1668  break;
1670  if (GNUNET_OK !=
1671  GST_neighbours_handle_session_syn_ack (message, address, session))
1672  {
1673  GST_blacklist_abort_matching (address, session);
1674  kill_session (plugin_name, session);
1675  }
1676  break;
1678  if (GNUNET_OK !=
1679  GST_neighbours_handle_session_ack (message, address, session))
1680  {
1681  GNUNET_break_op (0);
1682  GST_blacklist_abort_matching (address, session);
1683  kill_session (plugin_name, session);
1684  }
1685  break;
1687  GST_neighbours_handle_disconnect_message (&address->peer, message);
1688  break;
1690  GST_neighbours_handle_quota_message (&address->peer, message);
1691  break;
1693  GST_neighbours_keepalive (&address->peer, message);
1694  break;
1696  GST_neighbours_keepalive_response (&address->peer, message);
1697  break;
1698  default:
1699  /* should be payload */
1701  gettext_noop ("# bytes payload received"),
1702  ntohs (message->size),
1703  GNUNET_NO);
1704  ret = process_payload (address, session, message);
1705  break;
1706  }
1707 end:
1709  "Allowing receive from peer %s to continue in %s\n",
1710  GNUNET_i2s (&address->peer),
1712  return ret;
1713 }
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:81
#define GNUNET_OK
Named constants for return values.
Definition: gnunet_common.h:78
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:727
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:80
#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 1283 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().

1284 {
1285  int done;
1286 
1288  "Asked to broadcast message of type %u with %u bytes\n",
1289  (unsigned int) ntohs (msg->type),
1290  (unsigned int) ntohs (msg->size));
1291  done = GNUNET_NO;
1292  for (struct TransportClient *tc = clients_head; NULL != tc; tc = tc->next)
1293  {
1294  if (CT_NONE == tc->type)
1295  continue; /* client not yet ready */
1296  if ((GNUNET_YES == may_drop) && (CT_CORE != tc->type))
1297  continue; /* skip, this client does not care about payload */
1298  unicast (tc, msg, may_drop);
1299  done = GNUNET_YES;
1300  }
1301  if (GNUNET_NO == done)
1303  "Message of type %u not delivered, is CORE service up?\n",
1304  ntohs (msg->type));
1305 }
static void done()
static struct GNUNET_SCHEDULER_TaskContext tc
Task context of the current task.
Definition: scheduler.c:417
We do not know yet (client is fresh).
#define GNUNET_NO
Definition: gnunet_common.h:81
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:80
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 1317 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().

1322 {
1323  struct GNUNET_MQ_Envelope *env;
1325 
1326  msg = compose_address_iterate_response_message (peer, address);
1327  msg->state = htonl (state);
1328  msg->state_timeout = GNUNET_TIME_absolute_hton (state_timeout);
1329  for (struct TransportClient *tc = clients_head; NULL != tc; tc = tc->next)
1330  {
1331  if (CT_MONITOR != tc->type)
1332  continue;
1333  if ((0 == memcmp (&tc->details.monitor_peer,
1334  &all_zeros,
1335  sizeof (struct GNUNET_PeerIdentity))) ||
1336  (0 == memcmp (&tc->details.monitor_peer,
1337  peer,
1338  sizeof (struct GNUNET_PeerIdentity))))
1339  {
1340  env = GNUNET_MQ_msg_copy (&msg->header);
1341  GNUNET_MQ_send (tc->mq, env);
1342  }
1343  }
1344  GNUNET_free (msg);
1345 }
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:417
struct GNUNET_TIME_AbsoluteNBO state_timeout
Timeout for the state this peer is in.
Definition: transport.h:572
Message from the transport service to the library containing information about a peer.
Definition: transport.h:552
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:582
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:557
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:654
#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 1374 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().

1375 {
1376  struct DisconnectInfoMessage disconnect_msg;
1377 
1379  peer,
1380  &mark_peer_down,
1381  NULL);
1382  disconnect_msg.header.size = htons (sizeof (struct DisconnectInfoMessage));
1383  disconnect_msg.header.type = htons (GNUNET_MESSAGE_TYPE_TRANSPORT_DISCONNECT);
1384  disconnect_msg.reserved = htonl (0);
1385  disconnect_msg.peer = *peer;
1386  GST_clients_broadcast (&disconnect_msg.header, GNUNET_NO);
1387 }
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:81
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:153
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 374 of file gnunet-service-transport.c.

◆ GST_cfg

const struct GNUNET_CONFIGURATION_Handle* GST_cfg

Configuration handle.

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

◆ GST_my_identity

struct GNUNET_PeerIdentity GST_my_identity

Configuration handle.

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

◆ GST_ats

struct GNUNET_ATS_SchedulingHandle* GST_ats

ATS handle.

ATS handle.

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

Referenced by setup_neighbour().

◆ GST_is

Interface scanner determines our LAN address range(s).

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

Referenced by plugin_env_address_to_type().