GNUnet  0.11.x
Data Structures | Macros | Enumerations | Functions | Variables
gnunet-service-transport.c File Reference

main for gnunet-service-transport More...

#include "platform.h"
#include "gnunet_util_lib.h"
#include "gnunet_hello_lib.h"
#include "gnunet_statistics_service.h"
#include "gnunet_transport_service.h"
#include "gnunet_peerinfo_service.h"
#include "gnunet_ats_service.h"
#include "gnunet-service-transport.h"
#include "gnunet-service-transport_ats.h"
#include "gnunet-service-transport_hello.h"
#include "gnunet-service-transport_neighbours.h"
#include "gnunet-service-transport_plugins.h"
#include "gnunet-service-transport_validation.h"
#include "gnunet-service-transport_manipulation.h"
#include "transport.h"
Include dependency graph for gnunet-service-transport.c:

Go to the source code of this file.

Data Structures

struct  GNUNET_ATS_SessionKiller
 Information we need for an asynchronous session kill. More...
 
struct  TransportClient
 Client connected to the transport service. More...
 
struct  GST_BlacklistCheck
 Context we use when performing a blacklist check. More...
 
struct  AddressToStringContext
 Context for address to string operations. More...
 
struct  SendTransmitContinuationContext
 Closure for handle_send_transmit_continuation() More...
 
struct  IterationContext
 Closure for call_iterator(). More...
 
struct  TestConnectionContext
 Closure for test_connection_ok(). More...
 

Macros

#define TRANSPORT_BLACKLIST_HT_SIZE   64
 Size of the blacklist hash map. More...
 
#define MAX_PENDING   (128 * 1024)
 How many messages can we have pending for a given client process before we start to drop incoming messages? We typically should have only one client and so this would be the primary buffer for messages, so the number should be chosen rather generously. More...
 

Enumerations

enum  ClientType {
  CT_NONE = 0, CT_CORE = 1, CT_MONITOR = 2, CT_COMMUNICATOR = 3,
  CT_APPLICATION = 4, CT_NONE = 0, CT_CORE = 1, CT_MONITOR = 2,
  CT_BLACKLIST = 3, CT_CORE_NO_HANDLERS = 4
}
 What type of client is the struct TransportClient about? More...
 

Functions

static void unicast (struct TransportClient *tc, const struct GNUNET_MessageHeader *msg, int may_drop)
 Queue the given message for transmission to the given client. More...
 
static void * client_connect_cb (void *cls, struct GNUNET_SERVICE_Client *client, struct GNUNET_MQ_Handle *mq)
 Called whenever a client connects. More...
 
static void do_blacklist_check (void *cls)
 Perform next action in the blacklist check. More...
 
static int mark_match_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. More...
 
static void client_disconnect_cb (void *cls, struct GNUNET_SERVICE_Client *client, void *app_ctx)
 Called whenever a client is disconnected. More...
 
static void notify_client_about_neighbour (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 called for each of our connected neighbours. More...
 
static void handle_client_start (void *cls, const struct StartMessage *start)
 Initialize a normal client. More...
 
static int check_client_hello (void *cls, const struct GNUNET_MessageHeader *message)
 Client sent us a HELLO. More...
 
static void handle_client_hello (void *cls, const struct GNUNET_MessageHeader *message)
 Client sent us a HELLO. More...
 
static void handle_send_transmit_continuation (void *cls, int success, size_t bytes_payload, size_t bytes_on_wire)
 Function called after the transmission is done. More...
 
static int check_client_send (void *cls, const struct OutboundMessage *obm)
 Client asked for transmission to a peer. More...
 
static void handle_client_send (void *cls, const struct OutboundMessage *obm)
 Client asked for transmission to a peer. More...
 
static void transmit_address_to_client (void *cls, const char *buf, int res)
 Take the given address and append it to the set of results sent back to the client. More...
 
static int check_client_address_to_string (void *cls, const struct AddressLookupMessage *alum)
 Client asked to resolve an address. More...
 
static void handle_client_address_to_string (void *cls, const struct AddressLookupMessage *alum)
 Client asked to resolve an address. More...
 
static struct PeerIterateResponseMessagecompose_address_iterate_response_message (const struct GNUNET_PeerIdentity *peer, const struct GNUNET_HELLO_Address *address)
 Compose PeerIterateResponseMessage using the given peer and address. More...
 
static void send_peer_information (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)
 Output information of neighbours to the given client. More...
 
static void handle_client_monitor_peers (void *cls, const struct PeerMonitorMessage *msg)
 Client asked to obtain information about a specific or all peers Process the request. More...
 
static void plugin_session_info_cb (void *cls, struct GNUNET_ATS_Session *session, const struct GNUNET_TRANSPORT_SessionInfo *info)
 Function called by the plugin with information about the current sessions managed by the plugin (for monitoring). More...
 
static void handle_client_monitor_plugins (void *cls, const struct GNUNET_MessageHeader *message)
 Client asked to obtain information about all plugin connections. 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...
 
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. 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...
 
static void transmit_our_hello (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)
 Transmit our HELLO message to the given (connected) neighbour. More...
 
static void process_hello_update (void *cls, const struct GNUNET_MessageHeader *hello)
 My HELLO has changed. More...
 
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. More...
 
static void kill_session_task (void *cls)
 Task to asynchronously terminate a session. More...
 
static void kill_session (const char *plugin_name, struct GNUNET_ATS_Session *session)
 Force plugin to terminate session due to communication issue. More...
 
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 and ??? 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...
 
static void plugin_env_address_change_notification (void *cls, int add_remove, const struct GNUNET_HELLO_Address *address)
 Function that will be called for each address the transport is aware that it might be reachable under. More...
 
static void plugin_env_session_end (void *cls, const struct GNUNET_HELLO_Address *address, struct GNUNET_ATS_Session *session)
 Function that will be called whenever the plugin internally cleans up a session pointer and hence the service needs to discard all of those sessions as well. More...
 
static void plugin_env_session_start_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 from blacklist check triggered when a plugin gave us a new session in plugin_env_session_start(). More...
 
static void plugin_env_session_start (void *cls, const struct GNUNET_HELLO_Address *address, struct GNUNET_ATS_Session *session, enum GNUNET_NetworkType scope)
 Plugin tells transport service about a new inbound session. More...
 
static void ats_request_address_change (void *cls, const struct GNUNET_PeerIdentity *peer, const struct GNUNET_HELLO_Address *address, struct GNUNET_ATS_Session *session, struct GNUNET_BANDWIDTH_Value32NBO bandwidth_out, struct GNUNET_BANDWIDTH_Value32NBO bandwidth_in)
 Function called by ATS to notify the callee that the assigned bandwidth or address for a given peer was changed. More...
 
static void confirm_or_drop_neighbour (void *cls, const struct GNUNET_PeerIdentity *peer, const struct GNUNET_HELLO_Address *address, struct GNUNET_ATS_Session *session, int allowed)
 Got the result about an existing connection from a new blacklister. More...
 
static void test_connection_ok (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)
 Test if an existing connection is still acceptable given a new blacklisting client. More...
 
static void handle_client_blacklist_init (void *cls, const struct GNUNET_MessageHeader *message)
 Initialize a blacklisting client. More...
 
static int free_blacklist_entry (void *cls, const struct GNUNET_PeerIdentity *key, void *value)
 Free the given entry in the blacklist. More...
 
static void handle_client_set_metric (void *cls, const struct TrafficMetricMessage *tm)
 Set traffic metric to manipulate. More...
 
static void shutdown_task (void *cls)
 Function called when the service shuts down. More...
 
static void handle_client_blacklist_reply (void *cls, const struct BlacklistMessage *msg)
 A blacklisting client has sent us reply. More...
 
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...
 
void GST_blacklist_abort_matching (const struct GNUNET_HELLO_Address *address, struct GNUNET_ATS_Session *session)
 Abort blacklist if address and session match. More...
 
static int test_blacklisted (void *cls, const struct GNUNET_PeerIdentity *key, void *value)
 Test if the given blacklist entry matches. 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_test_cancel (struct GST_BlacklistCheck *bc)
 Cancel a blacklist check. More...
 
static void blacklist_cfg_iter (void *cls, const char *section, const char *option, const char *value)
 Function to iterate over options in the blacklisting section for a peer. More...
 
static void read_blacklist_configuration (const struct GNUNET_CONFIGURATION_Handle *cfg, const struct GNUNET_PeerIdentity *my_id)
 Read blacklist configuration. More...
 
static void run (void *cls, const struct GNUNET_CONFIGURATION_Handle *c, struct GNUNET_SERVICE_Handle *service)
 Initiate transport service. More...
 
 GNUNET_SERVICE_MAIN ("transport", GNUNET_SERVICE_OPTION_NONE, &run, &client_connect_cb, &client_disconnect_cb, NULL, GNUNET_MQ_hd_fixed_size(client_start, GNUNET_MESSAGE_TYPE_TRANSPORT_START, struct StartMessage, NULL), GNUNET_MQ_hd_var_size(client_hello, GNUNET_MESSAGE_TYPE_HELLO, struct GNUNET_MessageHeader, NULL), GNUNET_MQ_hd_var_size(client_send, GNUNET_MESSAGE_TYPE_TRANSPORT_SEND, struct OutboundMessage, NULL), GNUNET_MQ_hd_var_size(client_address_to_string, GNUNET_MESSAGE_TYPE_TRANSPORT_ADDRESS_TO_STRING, struct AddressLookupMessage, NULL), GNUNET_MQ_hd_fixed_size(client_monitor_peers, GNUNET_MESSAGE_TYPE_TRANSPORT_MONITOR_PEER_REQUEST, struct PeerMonitorMessage, NULL), GNUNET_MQ_hd_fixed_size(client_blacklist_init, GNUNET_MESSAGE_TYPE_TRANSPORT_BLACKLIST_INIT, struct GNUNET_MessageHeader, NULL), GNUNET_MQ_hd_fixed_size(client_blacklist_reply, GNUNET_MESSAGE_TYPE_TRANSPORT_BLACKLIST_REPLY, struct BlacklistMessage, NULL), GNUNET_MQ_hd_fixed_size(client_set_metric, GNUNET_MESSAGE_TYPE_TRANSPORT_TRAFFIC_METRIC, struct TrafficMetricMessage, NULL), GNUNET_MQ_hd_fixed_size(client_monitor_plugins, GNUNET_MESSAGE_TYPE_TRANSPORT_MONITOR_PLUGIN_START, struct GNUNET_MessageHeader, NULL), GNUNET_MQ_handler_end())
 Define "main" method using service macro. More...
 

Variables

static struct TransportClientclients_head
 Head of linked list of all clients to this service. More...
 
static struct TransportClientclients_tail
 Tail of linked list of all clients to this service. More...
 
static struct GNUNET_CONTAINER_MultiPeerMapactive_stccs
 Map of peer identities to active send transmit continuation contexts. More...
 
static struct AddressToStringContexta2s_head
 Head of linked list of all pending address iterations. More...
 
static struct AddressToStringContexta2s_tail
 Tail of linked list of all pending address iterations. More...
 
static struct GST_BlacklistCheckbc_head
 Head of DLL of active blacklisting queries. More...
 
static struct GST_BlacklistCheckbc_tail
 Tail of DLL of active blacklisting queries. More...
 
static struct GNUNET_CONTAINER_MultiPeerMapblacklist
 Hashmap of blacklisted peers. More...
 
static struct GNUNET_NotificationContextplugin_nc
 Notification context, to send updates on changes to active plugin connections. More...
 
static struct TransportClientsync_client
 Plugin monitoring client we are currently syncing, NULL if all monitoring clients are in sync. More...
 
static struct GNUNET_PeerIdentity all_zeros
 Peer identity that is all zeros, used as a way to indicate "all peers". More...
 
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 scheduling handle. More...
 
struct GNUNET_ATS_ConnectivityHandleGST_ats_connect
 ATS connectivity handle. More...
 
struct GNUNET_TIME_Relative hello_expiration
 Hello address expiration. More...
 
static struct GNUNET_ATS_SessionKillersk_head
 Head of DLL of asynchronous tasks to kill sessions. More...
 
static struct GNUNET_ATS_SessionKillersk_tail
 Tail of DLL of asynchronous tasks to kill sessions. More...
 
struct GNUNET_NT_InterfaceScannerGST_is
 Interface scanner determines our LAN address range(s). More...
 

Detailed Description

main for gnunet-service-transport

Author
Christian Grothoff

Definition in file gnunet-service-transport.c.

Macro Definition Documentation

◆ TRANSPORT_BLACKLIST_HT_SIZE

#define TRANSPORT_BLACKLIST_HT_SIZE   64

Size of the blacklist hash map.

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

Referenced by GST_blacklist_add_peer().

◆ MAX_PENDING

#define MAX_PENDING   (128 * 1024)

How many messages can we have pending for a given client process before we start to drop incoming messages? We typically should have only one client and so this would be the primary buffer for messages, so the number should be chosen rather generously.

The expectation here is that most of the time the queue is large enough so that a drop is virtually never required. Note that this value must be about as large as 'TOTAL_MSGS' in the 'test_transport_api_reliability.c', otherwise that testcase may fail.

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

Referenced by unicast().

Enumeration Type Documentation

◆ ClientType

enum ClientType

What type of client is the struct TransportClient about?

Enumerator
CT_NONE 

We do not know yet (client is fresh).

CT_CORE 

Is the CORE service, we need to forward traffic to it.

CT_MONITOR 

It is a monitor, forward monitor data.

CT_COMMUNICATOR 

It is a communicator, use for communication.

CT_APPLICATION 

"Application" telling us where to connect (i.e.

TOPOLOGY, DHT or CADET).

CT_NONE 

We do not know yet (client is fresh).

CT_CORE 

Is the CORE service, we need to forward traffic to it.

CT_MONITOR 

It is a monitor, forward monitor data.

CT_BLACKLIST 

It is a blacklist, query about allowed connections.

CT_CORE_NO_HANDLERS 

CORE client without any handlers.

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

97 {
101  CT_NONE = 0,
102 
106  CT_CORE = 1,
107 
111  CT_MONITOR = 2,
112 
116  CT_BLACKLIST = 3,
117 
122 };
It is a monitor, forward monitor data.
We do not know yet (client is fresh).
It is a blacklist, query about allowed connections.
CORE client without any handlers.
Is the CORE service, we need to forward traffic to it.

Function Documentation

◆ unicast()

static void unicast ( struct TransportClient tc,
const struct GNUNET_MessageHeader msg,
int  may_drop 
)
static

Queue the given message for transmission to the given client.

Parameters
tctarget of the message
msgmessage to transmit
may_dropGNUNET_YES if the message can be dropped

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

References env, gettext_noop, GNUNET_ERROR_TYPE_DEBUG, GNUNET_log, GNUNET_MQ_get_length(), GNUNET_MQ_msg_copy(), GNUNET_MQ_send(), GNUNET_NO, GNUNET_STATISTICS_update(), GNUNET_YES, MAX_PENDING, TransportClient::mq, GNUNET_MessageHeader::size, and GNUNET_MessageHeader::type.

Referenced by GST_clients_broadcast(), handle_client_start(), handle_send_transmit_continuation(), and notify_client_about_neighbour().

430 {
431  struct GNUNET_MQ_Envelope *env;
432 
433  if ((GNUNET_MQ_get_length (tc->mq) >= MAX_PENDING) &&
434  (GNUNET_YES == may_drop))
435  {
436  GNUNET_log (
438  "Dropping message of type %u and size %u, have %u/%u messages pending\n",
439  ntohs (msg->type),
440  ntohs (msg->size),
441  GNUNET_MQ_get_length (tc->mq),
442  MAX_PENDING);
444  gettext_noop (
445  "# messages dropped due to slow client"),
446  1,
447  GNUNET_NO);
448  return;
449  }
450  env = GNUNET_MQ_msg_copy (msg);
451  GNUNET_MQ_send (tc->mq, env);
452 }
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_STATISTICS_Handle * GST_stats
Statistics handle.
#define GNUNET_NO
Definition: gnunet_common.h:78
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 MAX_PENDING
How many messages can we have pending for a given client process before we start to drop incoming mes...
uint16_t type
The type of the message (GNUNET_MESSAGE_TYPE_XXXX), in big-endian format.
unsigned int GNUNET_MQ_get_length(struct GNUNET_MQ_Handle *mq)
Obtain the current length of the message queue.
Definition: mq.c:335
struct GNUNET_MQ_Handle * mq
Message queue to the client.
struct GNUNET_MQ_Envelope * env
Definition: 005.c:1
#define GNUNET_log(kind,...)
#define GNUNET_YES
Definition: gnunet_common.h:77
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
#define gettext_noop(String)
Definition: gettext.h:69
Here is the call graph for this function:
Here is the caller graph for this function:

◆ client_connect_cb()

static void* client_connect_cb ( void *  cls,
struct GNUNET_SERVICE_Client client,
struct GNUNET_MQ_Handle mq 
)
static

Called whenever a client connects.

Allocates our data structures associated with that client.

Parameters
clsclosure, NULL
clientidentification of the client
mqmessage queue for the client
Returns
our struct TransportClient

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

References TransportClient::client, do_blacklist_check(), GNUNET_CONTAINER_DLL_insert, GNUNET_ERROR_TYPE_DEBUG, GNUNET_log, GNUNET_new, mq, TransportClient::mq, and tc.

Referenced by run().

468 {
469  struct TransportClient *tc;
470 
471  tc = GNUNET_new (struct TransportClient);
472  tc->client = client;
473  tc->mq = mq;
475  GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Client %p connected\n", tc);
476  return tc;
477 }
#define GNUNET_CONTAINER_DLL_insert(head, tail, element)
Insert an element at the head of a DLL.
static struct GNUNET_SCHEDULER_TaskContext tc
Task context of the current task.
Definition: scheduler.c:418
#define GNUNET_new(type)
Allocate a struct or union of the given type.
static struct TransportClient * clients_tail
Tail of linked list of all clients to this service.
struct GNUNET_SERVICE_Client * client
Handle to the client.
static struct TransportClient * clients_head
Head of linked list of all clients to this service.
struct GNUNET_MQ_Handle * mq
Message queue to the client.
struct GNUNET_MQ_Handle * mq
Definition: 003.c:5
Client connected to the transport service.
#define GNUNET_log(kind,...)
Here is the call graph for this function:
Here is the caller graph for this function:

◆ do_blacklist_check()

static void do_blacklist_check ( void *  cls)
static

Perform next action in the blacklist check.

Parameters
clsthe struct BlacklistCheck*
clsthe struct GST_BlacklistCheck *

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

References GST_BlacklistCheck::address, GST_BlacklistCheck::bl_pos, TransportClient::blacklist, TransportClient::client, GST_BlacklistCheck::cont, GST_BlacklistCheck::cont_cls, CT_BLACKLIST, TransportClient::details, env, GNUNET_ERROR_TYPE_DEBUG, GNUNET_i2s(), GNUNET_log, GNUNET_MESSAGE_TYPE_TRANSPORT_BLACKLIST_QUERY, GNUNET_MQ_msg, GNUNET_MQ_send(), GNUNET_NO, GNUNET_OK, GNUNET_SERVICE_client_continue(), GNUNET_YES, GST_blacklist_test_cancel(), BlacklistMessage::is_allowed, TransportClient::mq, TransportClient::next, GST_BlacklistCheck::peer, BlacklistMessage::peer, GST_BlacklistCheck::session, GST_BlacklistCheck::task, tc, and TransportClient::type.

Referenced by client_connect_cb(), client_disconnect_cb(), GST_blacklist_test_allowed(), handle_client_blacklist_reply(), and test_connection_ok().

2198 {
2199  struct GST_BlacklistCheck *bc = cls;
2200  struct TransportClient *tc;
2201  struct GNUNET_MQ_Envelope *env;
2202  struct BlacklistMessage *bm;
2203 
2204  bc->task = NULL;
2205  while (NULL != (tc = bc->bl_pos))
2206  {
2207  if (CT_BLACKLIST == tc->type)
2208  break;
2209  bc->bl_pos = tc->next;
2210  }
2211  if (NULL == tc)
2212  {
2214  "No other blacklist clients active, will allow neighbour `%s'\n",
2215  GNUNET_i2s (&bc->peer));
2216 
2217  bc->cont (bc->cont_cls, &bc->peer, bc->address, bc->session, GNUNET_OK);
2219  return;
2220  }
2221  if ((NULL != tc->details.blacklist.bc) ||
2222  (GNUNET_NO != tc->details.blacklist.waiting_for_reply))
2223  return; /* someone else busy with this client */
2224  tc->details.blacklist.bc = bc;
2226  bm->is_allowed = htonl (0);
2227  bm->peer = bc->peer;
2228  GNUNET_MQ_send (tc->mq, env);
2229  if (GNUNET_YES == tc->details.blacklist.call_receive_done)
2230  {
2231  tc->details.blacklist.call_receive_done = GNUNET_NO;
2233  }
2234  tc->details.blacklist.waiting_for_reply = GNUNET_YES;
2235 }
struct GNUNET_HELLO_Address * address
Address for GST_blacklist_abort_matching(), can be NULL.
Context we use when performing a blacklist check.
struct GNUNET_PeerIdentity peer
Which peer is being blacklisted or queried?
Definition: transport.h:602
uint32_t is_allowed
0 for the query, GNUNET_OK (allowed) or GNUNET_SYSERR (disallowed) for the response.
Definition: transport.h:597
static struct GNUNET_SCHEDULER_TaskContext tc
Task context of the current task.
Definition: scheduler.c:418
#define GNUNET_MQ_msg(mvar, type)
Allocate a GNUNET_MQ_Envelope.
Definition: gnunet_mq_lib.h:67
#define GNUNET_NO
Definition: gnunet_common.h:78
#define GNUNET_OK
Named constants for return values.
Definition: gnunet_common.h:75
struct GNUNET_SERVICE_Client * client
Handle to the client.
enum ClientType type
What type of client is this?
It is a blacklist, query about allowed connections.
struct GNUNET_ATS_Session * session
Session for GST_blacklist_abort_matching(), can be NULL.
Change in blacklisting (either request or notification, depending on which direction it is going)...
Definition: transport.h:585
struct GNUNET_MQ_Handle * mq
Message queue to the client.
struct GNUNET_MQ_Envelope * env
Definition: 005.c:1
void GST_blacklist_test_cancel(struct GST_BlacklistCheck *bc)
Cancel a blacklist check.
GST_BlacklistTestContinuation cont
Continuation to call with the result.
struct TransportClient::@78::@79 blacklist
Additional details if type is CT_BLACKLIST.
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.
Client connected to the transport service.
#define GNUNET_log(kind,...)
#define GNUNET_MESSAGE_TYPE_TRANSPORT_BLACKLIST_QUERY
Query to a blacklisting client (is this peer blacklisted)?
#define GNUNET_YES
Definition: gnunet_common.h:77
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
union TransportClient::@72 details
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).
void GNUNET_SERVICE_client_continue(struct GNUNET_SERVICE_Client *c)
Continue receiving further messages from the given client.
Definition: service.c:2243
Here is the call graph for this function:
Here is the caller graph for this function:

◆ mark_match_down()

static int mark_match_down ( void *  cls,
const struct GNUNET_PeerIdentity peer,
void *  value 
)
static

Mark the peer as down so we don't call the continuation context in the future.

Parameters
clsa struct TransportClient
peera peer we are sending to
valuea struct SendTransmitContinuationContext to mark
Returns
GNUNET_OK (continue to iterate)

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

References SendTransmitContinuationContext::down, GNUNET_OK, GNUNET_YES, SendTransmitContinuationContext::tc, tc, and value.

Referenced by client_disconnect_cb().

500 {
501  struct TransportClient *tc = cls;
502  struct SendTransmitContinuationContext *stcc = value;
503 
504  if (tc == stcc->tc)
505  {
506  stcc->down = GNUNET_YES;
507  stcc->tc = NULL;
508  }
509  return GNUNET_OK;
510 }
static struct GNUNET_SCHEDULER_TaskContext tc
Task context of the current task.
Definition: scheduler.c:418
#define GNUNET_OK
Named constants for return values.
Definition: gnunet_common.h:75
struct TransportClient * tc
Client that made the request.
static char * value
Value of the record to add/remove.
int down
Set to GNUNET_YES if the connection for target goes down and we thus must no longer send the GNUNET_M...
Closure for handle_send_transmit_continuation()
Client connected to the transport service.
#define GNUNET_YES
Definition: gnunet_common.h:77
Here is the caller graph for this function:

◆ client_disconnect_cb()

static void client_disconnect_cb ( void *  cls,
struct GNUNET_SERVICE_Client client,
void *  app_ctx 
)
static

Called whenever a client is disconnected.

Frees our resources associated with that client.

Parameters
clsclosure, NULL
clientidentification of the client
app_ctxour struct TransportClient

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

References GST_BlacklistCheck::bl_pos, CT_BLACKLIST, CT_CORE, CT_CORE_NO_HANDLERS, CT_MONITOR, CT_NONE, do_blacklist_check(), GNUNET_CONTAINER_DLL_remove, GNUNET_CONTAINER_multipeermap_iterate(), GNUNET_ERROR_TYPE_DEBUG, GNUNET_free, GNUNET_log, GNUNET_SCHEDULER_add_now(), mark_match_down(), GST_BlacklistCheck::next, AddressToStringContext::next, TransportClient::next, GST_BlacklistCheck::task, tc, and TransportClient::type.

Referenced by run().

525 {
526  struct TransportClient *tc = app_ctx;
527  struct GST_BlacklistCheck *bc;
528 
530  "Client %p disconnected, cleaning up.\n",
531  tc);
533  for (struct AddressToStringContext *cur = a2s_head; NULL != cur;
534  cur = cur->next)
535  {
536  if (cur->tc == tc)
537  cur->tc = NULL;
538  }
540  switch (tc->type)
541  {
542  case CT_NONE:
543  break;
544 
545  case CT_CORE:
546  break;
547 
548  case CT_MONITOR:
549  break;
550 
551  case CT_BLACKLIST:
552  for (bc = bc_head; NULL != bc; bc = bc->next)
553  {
554  if (bc->bl_pos != tc)
555  continue;
556  bc->bl_pos = tc->next;
557  if (NULL == bc->task)
559  }
560  break;
561 
562  case CT_CORE_NO_HANDLERS:
563  break;
564  }
565  GNUNET_free (tc);
566 }
#define GNUNET_CONTAINER_DLL_remove(head, tail, element)
Remove an element from a DLL.
static struct GNUNET_CONTAINER_MultiPeerMap * active_stccs
Map of peer identities to active send transmit continuation contexts.
It is a monitor, forward monitor data.
Context we use when performing a blacklist check.
static struct GNUNET_SCHEDULER_TaskContext tc
Task context of the current task.
Definition: scheduler.c:418
static int mark_match_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.
We do not know yet (client is fresh).
static struct TransportClient * clients_tail
Tail of linked list of all clients to this service.
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.
struct GST_BlacklistCheck * next
This is a linked list.
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 AddressToStringContext * next
This is a doubly-linked list.
struct GNUNET_SCHEDULER_Task * GNUNET_SCHEDULER_add_now(GNUNET_SCHEDULER_TaskCallback task, void *task_cls)
Schedule a new task to be run as soon as possible.
Definition: scheduler.c:1280
CORE client without any handlers.
struct TransportClient * next
Kept in a DLL.
int GNUNET_CONTAINER_multipeermap_iterate(struct GNUNET_CONTAINER_MultiPeerMap *map, GNUNET_CONTAINER_PeerMapIterator it, void *it_cls)
Iterate over all entries in the map.
static struct AddressToStringContext * a2s_head
Head of linked list of all pending address iterations.
struct TransportClient * bl_pos
Our current position in the blacklisters list.
struct GNUNET_SCHEDULER_Task * task
Current task performing the check.
Client connected to the transport service.
#define GNUNET_log(kind,...)
Is the CORE service, we need to forward traffic to it.
Context for address to string operations.
#define GNUNET_free(ptr)
Wrapper around free.
Here is the call graph for this function:
Here is the caller graph for this function:

◆ notify_client_about_neighbour()

static void notify_client_about_neighbour ( 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 
)
static

Function called for each of our connected neighbours.

Notify the client about the existing neighbour.

Parameters
clsthe struct TransportClient * to notify
peeridentity of the neighbour
addressthe address
statethe current state of the peer
state_timeoutthe time out for the state
bandwidth_ininbound bandwidth in NBO
bandwidth_outoutbound bandwidth in NBO

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

References GNUNET_MESSAGE_TYPE_TRANSPORT_CONNECT, GNUNET_NO, GST_neighbours_test_connected(), ConnectInfoMessage::header, ConnectInfoMessage::id, peer, ConnectInfoMessage::quota_out, GNUNET_MessageHeader::size, tc, GNUNET_MessageHeader::type, and unicast().

Referenced by handle_client_start().

589 {
590  struct TransportClient *tc = cls;
591  struct ConnectInfoMessage cim;
592 
594  return;
595  cim.header.size = htons (sizeof(struct ConnectInfoMessage));
596  cim.header.type = htons (GNUNET_MESSAGE_TYPE_TRANSPORT_CONNECT);
597  cim.id = *peer;
598  cim.quota_out = bandwidth_out;
599  unicast (tc, &cim.header, GNUNET_NO);
600 }
struct GNUNET_MessageHeader header
Type will be GNUNET_MESSAGE_TYPE_TRANSPORT_CONNECT.
Definition: transport.h:122
int GST_neighbours_test_connected(const struct GNUNET_PeerIdentity *target)
Test if we're connected to the given peer.
static struct GNUNET_SCHEDULER_TaskContext tc
Task context of the current task.
Definition: scheduler.c:418
#define GNUNET_NO
Definition: gnunet_common.h:78
uint16_t size
The length of the struct (in bytes, including the length field itself), in big-endian format...
#define GNUNET_MESSAGE_TYPE_TRANSPORT_CONNECT
Message from TRANSPORT notifying about a client that connected to us.
Message from the transport service to the library informing about neighbors.
Definition: transport.h:117
struct GNUNET_TESTBED_Peer * peer
The peer associated with this model.
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.
Here is the call graph for this function:
Here is the caller graph for this function:

◆ handle_client_start()

static void handle_client_start ( void *  cls,
const struct StartMessage start 
)
static

Initialize a normal client.

We got a start message from this client, add it to the list of clients for broadcasting of inbound messages.

Parameters
clsthe client
startthe start message that was sent

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

References TransportClient::client, CT_CORE, CT_CORE_NO_HANDLERS, CT_NONE, GNUNET_break, GNUNET_ERROR_TYPE_DEBUG, GNUNET_log, GNUNET_NO, GNUNET_SERVICE_client_continue(), GNUNET_SERVICE_client_drop(), GST_hello_get(), GST_my_identity, GST_neighbours_iterate(), notify_client_about_neighbour(), options, StartMessage::options, StartMessage::self, tc, TransportClient::type, and unicast().

613 {
614  struct TransportClient *tc = cls;
615  const struct GNUNET_MessageHeader *hello;
616  uint32_t options;
617 
618  GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Client %p sent START\n", tc);
619  options = ntohl (start->options);
620  if ((0 != (1 & options)) &&
621  (0 != memcmp (&start->self,
623  sizeof(struct GNUNET_PeerIdentity))))
624  {
625  /* client thinks this is a different peer, reject */
626  GNUNET_break (0);
628  return;
629  }
630  if (CT_NONE != tc->type)
631  {
632  GNUNET_break (0);
634  return;
635  }
636  if (0 != (2 & options))
637  tc->type = CT_CORE;
638  else
640  hello = GST_hello_get ();
641  if (NULL != hello)
642  unicast (tc, hello, GNUNET_NO);
645 }
void GST_neighbours_iterate(GST_NeighbourIterator cb, void *cb_cls)
Iterate over all connected neighbours.
struct GNUNET_GETOPT_CommandLineOption options[]
Definition: 002.c:5
struct GNUNET_PeerIdentity GST_my_identity
Configuration handle.
static struct GNUNET_SCHEDULER_TaskContext tc
Task context of the current task.
Definition: scheduler.c:418
static void notify_client_about_neighbour(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 called for each of our connected neighbours.
We do not know yet (client is fresh).
#define GNUNET_NO
Definition: gnunet_common.h:78
struct GNUNET_PeerIdentity self
Identity we think we have.
Definition: transport.h:109
struct GNUNET_SERVICE_Client * client
Handle to the client.
#define GNUNET_break(cond)
Use this for internal assertion violations that are not fatal (can be handled) but should not occur...
enum ClientType type
What type of client is this?
uint32_t options
0: no options 1: The self field should be checked 2: this client is interested in payload traffic ...
Definition: transport.h:103
void GNUNET_SERVICE_client_drop(struct GNUNET_SERVICE_Client *c)
Ask the server to disconnect from the given client.
Definition: service.c:2324
CORE client without any handlers.
static void unicast(struct TransportClient *tc, const struct GNUNET_MessageHeader *msg, int may_drop)
Queue the given message for transmission to the given client.
const struct GNUNET_MessageHeader * GST_hello_get()
Obtain this peers HELLO message.
The identity of the host (wraps the signing key of the peer).
Client connected to the transport service.
#define GNUNET_log(kind,...)
Header for all communications.
Is the CORE service, we need to forward traffic to it.
void GNUNET_SERVICE_client_continue(struct GNUNET_SERVICE_Client *c)
Continue receiving further messages from the given client.
Definition: service.c:2243
Here is the call graph for this function:

◆ check_client_hello()

static int check_client_hello ( void *  cls,
const struct GNUNET_MessageHeader message 
)
static

Client sent us a HELLO.

Check the request.

Parameters
clsthe client
messagethe HELLO message

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

References GNUNET_OK.

656 {
657  return GNUNET_OK; /* FIXME: check here? */
658 }
#define GNUNET_OK
Named constants for return values.
Definition: gnunet_common.h:75

◆ handle_client_hello()

static void handle_client_hello ( void *  cls,
const struct GNUNET_MessageHeader message 
)
static

Client sent us a HELLO.

Process the request.

Parameters
clsthe client
messagethe HELLO message

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

References TransportClient::client, GNUNET_ERROR_TYPE_INFO, GNUNET_log, GNUNET_SERVICE_client_continue(), GST_validation_handle_hello(), and tc.

669 {
670  struct TransportClient *tc = cls;
671 
672  GNUNET_log (GNUNET_ERROR_TYPE_INFO, "Received HELLO message\n");
673  GST_validation_handle_hello (message);
675 }
static struct GNUNET_SCHEDULER_TaskContext tc
Task context of the current task.
Definition: scheduler.c:418
int GST_validation_handle_hello(const struct GNUNET_MessageHeader *hello)
We've received a HELLO, check which addresses are new and trigger validation.
struct GNUNET_SERVICE_Client * client
Handle to the client.
Client connected to the transport service.
#define GNUNET_log(kind,...)
void GNUNET_SERVICE_client_continue(struct GNUNET_SERVICE_Client *c)
Continue receiving further messages from the given client.
Definition: service.c:2243
Here is the call graph for this function:

◆ handle_send_transmit_continuation()

static void handle_send_transmit_continuation ( void *  cls,
int  success,
size_t  bytes_payload,
size_t  bytes_on_wire 
)
static

Function called after the transmission is done.

Notify the client that it is OK to send the next message.

Parameters
clsclosure
successGNUNET_OK on success, GNUNET_NO on failure, GNUNET_SYSERR if we're not connected
bytes_payloadbytes payload sent
bytes_on_wirebytes sent on wire

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

References SendOkMessage::bytes_msg, SendOkMessage::bytes_physical, SendTransmitContinuationContext::down, GNUNET_assert, GNUNET_CONSTANTS_LATENCY_WARN, GNUNET_CONTAINER_multipeermap_remove(), GNUNET_ERROR_TYPE_DEBUG, GNUNET_ERROR_TYPE_WARNING, GNUNET_free, GNUNET_i2s(), GNUNET_log, GNUNET_MESSAGE_TYPE_TRANSPORT_SEND_OK, GNUNET_NO, GNUNET_OK, GNUNET_STRINGS_relative_time_to_string(), GNUNET_TIME_absolute_get_duration(), GNUNET_YES, GST_neighbour_get_current_address(), SendOkMessage::header, SendOkMessage::peer, GNUNET_TIME_Relative::rel_value_us, SendTransmitContinuationContext::send_time, GNUNET_MessageHeader::size, SendOkMessage::success, SendTransmitContinuationContext::target, SendTransmitContinuationContext::tc, GNUNET_HELLO_Address::transport_name, GNUNET_MessageHeader::type, unicast(), and SendTransmitContinuationContext::uuid.

Referenced by handle_client_send().

692 {
693  struct SendTransmitContinuationContext *stcc = cls;
694  struct SendOkMessage send_ok_msg;
696  const struct GNUNET_HELLO_Address *addr;
697 
702  "It took us %s to send %u/%u bytes to %s (%d, %s)\n",
704  (unsigned int) bytes_payload,
705  (unsigned int) bytes_on_wire,
706  GNUNET_i2s (&stcc->target),
707  success,
708  (NULL != addr) ? addr->transport_name : "%");
709  else
711  "It took us %s to send %u/%u bytes to %s (%d, %s)\n",
713  (unsigned int) bytes_payload,
714  (unsigned int) bytes_on_wire,
715  GNUNET_i2s (&stcc->target),
716  success,
717  (NULL != addr) ? addr->transport_name : "%");
718 
719  if (GNUNET_NO == stcc->down)
720  {
721  /* Only send confirmation if we are still connected */
723  "Sending SEND_OK for transmission request %llu\n",
724  stcc->uuid);
725  send_ok_msg.header.size = htons (sizeof(send_ok_msg));
726  send_ok_msg.header.type = htons (GNUNET_MESSAGE_TYPE_TRANSPORT_SEND_OK);
727  send_ok_msg.bytes_msg = htonl (bytes_payload);
728  send_ok_msg.bytes_physical = htonl (bytes_on_wire);
729  send_ok_msg.success = htonl (success);
730  send_ok_msg.peer = stcc->target;
731  unicast (stcc->tc, &send_ok_msg.header, GNUNET_NO);
732  }
733  GNUNET_assert (
734  GNUNET_OK ==
736  GNUNET_free (stcc);
737 }
static struct GNUNET_CONTAINER_MultiPeerMap * active_stccs
Map of peer identities to active send transmit continuation contexts.
uint64_t rel_value_us
The actual value.
struct GNUNET_TIME_Absolute send_time
At what time did we receive the message?
#define GNUNET_assert(cond)
Use this for fatal errors that cannot be handled.
struct GNUNET_PeerIdentity target
Peer that was the target.
#define GNUNET_CONSTANTS_LATENCY_WARN
After what amount of latency for a message do we print a warning?
int GNUNET_CONTAINER_multipeermap_remove(struct GNUNET_CONTAINER_MultiPeerMap *map, const struct GNUNET_PeerIdentity *key, const void *value)
Remove the given key-value pair from the map.
#define GNUNET_NO
Definition: gnunet_common.h:78
#define GNUNET_OK
Named constants for return values.
Definition: gnunet_common.h:75
struct TransportClient * tc
Client that made the request.
const struct GNUNET_HELLO_Address * GST_neighbour_get_current_address(const struct GNUNET_PeerIdentity *peer)
Obtain current address information for the given neighbour.
const char * GNUNET_STRINGS_relative_time_to_string(struct GNUNET_TIME_Relative delta, int do_round)
Give relative time in human-readable fancy format.
Definition: strings.c:687
const char * transport_name
Name of the transport plugin enabling the communication using this address.
int down
Set to GNUNET_YES if the connection for target goes down and we thus must no longer send the GNUNET_M...
unsigned long long uuid
Unique ID, for logging.
static void unicast(struct TransportClient *tc, const struct GNUNET_MessageHeader *msg, int may_drop)
Queue the given message for transmission to the given client.
static struct GNUNET_TIME_Relative delay
When should dkg communication start?
#define GNUNET_MESSAGE_TYPE_TRANSPORT_SEND_OK
Confirmation from TRANSPORT that message for transmission has been queued (and that the next message ...
Message used to notify the transport API that it can send another message to the transport service...
Definition: transport.h:216
struct GNUNET_TIME_Relative GNUNET_TIME_absolute_get_duration(struct GNUNET_TIME_Absolute whence)
Get the duration of an operation as the difference of the current time and the given start time "henc...
Definition: time.c:375
Closure for handle_send_transmit_continuation()
An address for communicating with a peer.
#define GNUNET_log(kind,...)
#define GNUNET_YES
Definition: gnunet_common.h:77
const char * GNUNET_i2s(const struct GNUNET_PeerIdentity *pid)
Convert a peer identity to a string (for printing debug messages).
#define GNUNET_free(ptr)
Wrapper around free.
Time for relative time used by GNUnet, in microseconds.
Here is the call graph for this function:
Here is the caller graph for this function:

◆ check_client_send()

static int check_client_send ( void *  cls,
const struct OutboundMessage obm 
)
static

Client asked for transmission to a peer.

Process the request.

Parameters
clsthe client
obmthe send message that was sent

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

References GNUNET_break, GNUNET_OK, GNUNET_SYSERR, OutboundMessage::header, size, and GNUNET_MessageHeader::size.

748 {
749  uint16_t size;
750  const struct GNUNET_MessageHeader *obmm;
751 
752  size = ntohs (obm->header.size) - sizeof(struct OutboundMessage);
753  if (size < sizeof(struct GNUNET_MessageHeader))
754  {
755  GNUNET_break (0);
756  return GNUNET_SYSERR;
757  }
758  obmm = (const struct GNUNET_MessageHeader *) &obm[1];
759  if (size != ntohs (obmm->size))
760  {
761  GNUNET_break (0);
762  return GNUNET_SYSERR;
763  }
764  return GNUNET_OK;
765 }
struct GNUNET_MessageHeader header
Type will be GNUNET_MESSAGE_TYPE_TRANSPORT_SEND.
Definition: transport.h:289
#define GNUNET_OK
Named constants for return values.
Definition: gnunet_common.h:75
uint16_t size
The length of the struct (in bytes, including the length field itself), in big-endian format...
#define GNUNET_break(cond)
Use this for internal assertion violations that are not fatal (can be handled) but should not occur...
Message used to notify the transport service about a message to be transmitted to another peer...
Definition: transport.h:284
#define GNUNET_SYSERR
Definition: gnunet_common.h:76
static unsigned int size
Size of the "table".
Definition: peer.c:67
Header for all communications.

◆ handle_client_send()

static void handle_client_send ( void *  cls,
const struct OutboundMessage obm 
)
static

Client asked for transmission to a peer.

Process the request.

Parameters
clsthe client
obmthe send message that was sent

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

References TransportClient::client, gettext_noop, GNUNET_CONTAINER_MULTIHASHMAPOPTION_MULTIPLE, GNUNET_CONTAINER_multipeermap_put(), GNUNET_ERROR_TYPE_DEBUG, GNUNET_i2s(), GNUNET_log, GNUNET_new, GNUNET_NO, GNUNET_SERVICE_client_continue(), GNUNET_STATISTICS_update(), GNUNET_TIME_absolute_get(), GNUNET_TIME_relative_ntoh(), GST_manipulation_send(), GST_neighbours_test_connected(), handle_send_transmit_continuation(), OutboundMessage::peer, SendTransmitContinuationContext::send_time, GNUNET_MessageHeader::size, SendTransmitContinuationContext::target, SendTransmitContinuationContext::tc, tc, OutboundMessage::timeout, GNUNET_MessageHeader::type, and SendTransmitContinuationContext::uuid.

776 {
777  static unsigned long long uuid_gen;
778  struct TransportClient *tc = cls;
779  const struct GNUNET_MessageHeader *obmm;
780  struct SendTransmitContinuationContext *stcc;
781 
782  obmm = (const struct GNUNET_MessageHeader *) &obm[1];
784  {
785  /* not connected, not allowed to send; can happen due to asynchronous operations */
787  "Could not send message to peer `%s': not connected\n",
788  GNUNET_i2s (&obm->peer));
790  GST_stats,
791  gettext_noop ("# bytes payload dropped (other peer was not connected)"),
792  ntohs (obmm->size),
793  GNUNET_NO);
795  return;
796  }
797  GNUNET_log (
799  "Received SEND request %llu for `%s' and first message of type %u and total size %u\n",
800  uuid_gen,
801  GNUNET_i2s (&obm->peer),
802  ntohs (obmm->type),
803  ntohs (obmm->size));
805 
807  stcc->target = obm->peer;
808  stcc->tc = tc;
810  stcc->uuid = uuid_gen++;
812  active_stccs,
813  &stcc->target,
814  stcc,
817  obmm,
818  ntohs (obmm->size),
821  stcc);
822 }
static struct GNUNET_CONTAINER_MultiPeerMap * active_stccs
Map of peer identities to active send transmit continuation contexts.
struct GNUNET_TIME_Absolute send_time
At what time did we receive the message?
struct GNUNET_STATISTICS_Handle * GST_stats
Statistics handle.
int GST_neighbours_test_connected(const struct GNUNET_PeerIdentity *target)
Test if we&#39;re connected to the given peer.
struct GNUNET_PeerIdentity peer
Which peer should receive the message?
Definition: transport.h:308
struct GNUNET_PeerIdentity target
Peer that was the target.
static struct GNUNET_SCHEDULER_TaskContext tc
Task context of the current task.
Definition: scheduler.c:418
static void handle_send_transmit_continuation(void *cls, int success, size_t bytes_payload, size_t bytes_on_wire)
Function called after the transmission is done.
#define GNUNET_NO
Definition: gnunet_common.h:78
#define GNUNET_new(type)
Allocate a struct or union of the given type.
struct GNUNET_SERVICE_Client * client
Handle to the client.
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.
struct TransportClient * tc
Client that made the request.
uint16_t type
The type of the message (GNUNET_MESSAGE_TYPE_XXXX), in big-endian format.
struct GNUNET_TIME_RelativeNBO timeout
Allowed delay.
Definition: transport.h:302
struct GNUNET_TIME_Relative GNUNET_TIME_relative_ntoh(struct GNUNET_TIME_RelativeNBO a)
Convert relative time from network byte order.
Definition: time.c:641
struct GNUNET_TIME_Absolute GNUNET_TIME_absolute_get(void)
Get the current time.
Definition: time.c:118
void GST_manipulation_send(const struct GNUNET_PeerIdentity *target, const void *msg, size_t msg_size, struct GNUNET_TIME_Relative timeout, GST_NeighbourSendContinuation cont, void *cont_cls)
Adapter function between transport&#39;s send function and transport plugins.
unsigned long long uuid
Unique ID, for logging.
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.
Closure for handle_send_transmit_continuation()
Client connected to the transport service.
#define GNUNET_log(kind,...)
Header for all communications.
const char * GNUNET_i2s(const struct GNUNET_PeerIdentity *pid)
Convert a peer identity to a string (for printing debug messages).
void GNUNET_SERVICE_client_continue(struct GNUNET_SERVICE_Client *c)
Continue receiving further messages from the given client.
Definition: service.c:2243
#define gettext_noop(String)
Definition: gettext.h:69
Here is the call graph for this function:

◆ transmit_address_to_client()

static void transmit_address_to_client ( void *  cls,
const char *  buf,
int  res 
)
static

Take the given address and append it to the set of results sent back to the client.

This function may be called serveral times for a single conversion. The last invocation will be with a address of NULL and a res of GNUNET_OK. Thus, to indicate conversion errors, the callback might be called first with address NULL and res being GNUNET_SYSERR. In that case, there will still be a subsequent call later with address NULL and res GNUNET_OK.

Parameters
clsthe struct AddressToStringContext
buftext to transmit (contains the human-readable address, or NULL)
resGNUNET_OK if conversion was successful, GNUNET_SYSERR on error, never GNUNET_NO

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

References AddressToStringResultMessage::addr_len, env, GNUNET_assert, GNUNET_CONTAINER_DLL_remove, GNUNET_free, GNUNET_memcpy, GNUNET_MESSAGE_TYPE_TRANSPORT_ADDRESS_TO_STRING_REPLY, GNUNET_MQ_msg, GNUNET_MQ_msg_extra, GNUNET_MQ_send(), GNUNET_OK, GNUNET_SYSERR, GNUNET_YES, TransportClient::mq, AddressToStringResultMessage::res, and AddressToStringContext::tc.

Referenced by handle_client_address_to_string().

841 {
842  struct AddressToStringContext *actx = cls;
843  struct GNUNET_MQ_Envelope *env;
844  struct AddressToStringResultMessage *atsm;
845  size_t slen;
846 
848  if (NULL == actx->tc)
849  return;
850  if (NULL == buf)
851  {
852  env = GNUNET_MQ_msg (atsm,
854  if (GNUNET_OK == res)
855  {
856  /* this was the last call, transmit */
857  atsm->res = htonl (GNUNET_OK);
858  atsm->addr_len = htonl (0);
859  GNUNET_MQ_send (actx->tc->mq, env);
861  GNUNET_free (actx);
862  return;
863  }
864  if (GNUNET_SYSERR == res)
865  {
866  /* address conversion failed, but there will be more callbacks */
867  atsm->res = htonl (GNUNET_SYSERR);
868  atsm->addr_len = htonl (0);
869  GNUNET_MQ_send (actx->tc->mq, env);
870  return;
871  }
872  }
874  /* succesful conversion, append*/
875  slen = strlen (buf) + 1;
876  env =
877  GNUNET_MQ_msg_extra (atsm,
878  slen,
880  atsm->res = htonl (GNUNET_YES);
881  atsm->addr_len = htonl (slen);
882  GNUNET_memcpy (&atsm[1], buf, slen);
883  GNUNET_MQ_send (actx->tc->mq, env);
884 }
#define GNUNET_CONTAINER_DLL_remove(head, tail, element)
Remove an element from a DLL.
Message used to notify the transport API about an address to string conversion.
Definition: transport.h:323
uint32_t addr_len
Length of the following string, zero if is GNUNET_SYSERR.
Definition: transport.h:339
#define GNUNET_assert(cond)
Use this for fatal errors that cannot be handled.
#define GNUNET_memcpy(dst, src, n)
Call memcpy() but check for n being 0 first.
#define GNUNET_MQ_msg(mvar, type)
Allocate a GNUNET_MQ_Envelope.
Definition: gnunet_mq_lib.h:67
#define GNUNET_OK
Named constants for return values.
Definition: gnunet_common.h:75
#define GNUNET_MQ_msg_extra(mvar, esize, type)
Allocate an envelope, with extra space allocated after the space needed by the message struct...
Definition: gnunet_mq_lib.h:52
uint32_t res
GNUNET_OK if the conversion succeeded, GNUNET_SYSERR if it failed
Definition: transport.h:334
struct TransportClient * tc
Client that made the request.
#define GNUNET_MESSAGE_TYPE_TRANSPORT_ADDRESS_TO_STRING_REPLY
Response to the address lookup request.
static char buf[2048]
static struct AddressToStringContext * a2s_tail
Tail of linked list of all pending address iterations.
static int res
#define GNUNET_SYSERR
Definition: gnunet_common.h:76
struct GNUNET_MQ_Handle * mq
Message queue to the client.
struct GNUNET_MQ_Envelope * env
Definition: 005.c:1
static struct AddressToStringContext * a2s_head
Head of linked list of all pending address iterations.
#define GNUNET_YES
Definition: gnunet_common.h:77
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
Context for address to string operations.
#define GNUNET_free(ptr)
Wrapper around free.
Here is the call graph for this function:
Here is the caller graph for this function:

◆ check_client_address_to_string()

static int check_client_address_to_string ( void *  cls,
const struct AddressLookupMessage alum 
)
static

Client asked to resolve an address.

Check the request.

Parameters
clsthe client
alumthe resolution request
Returns
GNUNET_OK if alum is well-formed

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

References address, AddressLookupMessage::addrlen, GNUNET_break, GNUNET_OK, GNUNET_SYSERR, AddressLookupMessage::header, plugin_name, size, and GNUNET_MessageHeader::size.

897 {
898  const char *plugin_name;
899  const char *address;
900  uint32_t address_len;
901  uint16_t size;
902 
903  size = ntohs (alum->header.size);
904  address_len = ntohs (alum->addrlen);
905  if (size <= sizeof(struct AddressLookupMessage) + address_len)
906  {
907  GNUNET_break (0);
908  return GNUNET_SYSERR;
909  }
910  address = (const char *) &alum[1];
911  plugin_name = (const char *) &address[address_len];
912  if ('\0' != plugin_name[size - sizeof(struct AddressLookupMessage)
913  - address_len - 1])
914  {
915  GNUNET_break (0);
916  return GNUNET_SYSERR;
917  }
918  return GNUNET_OK;
919 }
#define GNUNET_OK
Named constants for return values.
Definition: gnunet_common.h:75
uint16_t size
The length of the struct (in bytes, including the length field itself), in big-endian format...
#define GNUNET_break(cond)
Use this for internal assertion violations that are not fatal (can be handled) but should not occur...
#define GNUNET_SYSERR
Definition: gnunet_common.h:76
static unsigned int size
Size of the "table".
Definition: peer.c:67
Message from the library to the transport service asking for converting a transport address to a huma...
Definition: transport.h:348
struct GNUNET_MessageHeader header
Type will be GNUNET_MESSAGE_TYPE_TRANSPORT_ADDRESS_TO_STRING.
Definition: transport.h:353
uint16_t addrlen
Length of the (binary) address in bytes, in big-endian.
Definition: transport.h:364
static char * address
GNS address for this phone.
static char * plugin_name
Name of our plugin.

◆ handle_client_address_to_string()

static void handle_client_address_to_string ( void *  cls,
const struct AddressLookupMessage alum 
)
static

Client asked to resolve an address.

Process the request.

Parameters
clsthe client
alumthe resolution request

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

References AddressToStringResultMessage::addr_len, address, GNUNET_TRANSPORT_PluginFunctions::address_pretty_printer, AddressLookupMessage::addrlen, TransportClient::client, GNUNET_TRANSPORT_PluginFunctions::cls, env, GNUNET_CONTAINER_DLL_insert, GNUNET_ERROR_TYPE_DEBUG, GNUNET_ERROR_TYPE_WARNING, GNUNET_log, GNUNET_MESSAGE_TYPE_TRANSPORT_ADDRESS_TO_STRING_REPLY, GNUNET_MQ_msg, GNUNET_MQ_send(), GNUNET_new, GNUNET_OK, GNUNET_SERVICE_client_disable_continue_warning(), GNUNET_SYSERR, GNUNET_TIME_relative_ntoh(), GST_plugins_printer_find(), TransportClient::mq, numeric, AddressLookupMessage::numeric_only, plugin_name, AddressToStringResultMessage::res, AddressToStringContext::tc, tc, AddressLookupMessage::timeout, and transmit_address_to_client().

931 {
932  struct TransportClient *tc = cls;
934  const char *plugin_name;
935  const char *address;
936  uint32_t address_len;
937  struct AddressToStringContext *actx;
938  struct GNUNET_MQ_Envelope *env;
939  struct AddressToStringResultMessage *atsm;
940  struct GNUNET_TIME_Relative rtimeout;
941  int32_t numeric;
942 
943  address_len = ntohs (alum->addrlen);
944  address = (const char *) &alum[1];
945  plugin_name = (const char *) &address[address_len];
946  rtimeout = GNUNET_TIME_relative_ntoh (alum->timeout);
947  numeric = ntohs (alum->numeric_only);
948  papi = GST_plugins_printer_find (plugin_name);
949  if (NULL == papi)
950  {
952  "Failed to find plugin `%s'\n",
953  plugin_name);
954  env = GNUNET_MQ_msg (atsm,
956  atsm->res = htonl (GNUNET_SYSERR);
957  atsm->addr_len = htonl (0);
958  GNUNET_MQ_send (tc->mq, env);
959  env = GNUNET_MQ_msg (atsm,
961  atsm->res = htonl (GNUNET_OK);
962  atsm->addr_len = htonl (0);
963  GNUNET_MQ_send (tc->mq, env);
964  return;
965  }
966  actx = GNUNET_new (struct AddressToStringContext);
967  actx->tc = tc;
971  "Pretty-printing address of %u bytes using plugin `%s'\n",
972  address_len,
973  plugin_name);
974  papi->address_pretty_printer (papi->cls,
975  plugin_name,
976  address,
977  address_len,
978  numeric,
979  rtimeout,
981  actx);
982 }
Message used to notify the transport API about an address to string conversion.
Definition: transport.h:323
#define GNUNET_CONTAINER_DLL_insert(head, tail, element)
Insert an element at the head of a DLL.
uint32_t addr_len
Length of the following string, zero if is GNUNET_SYSERR.
Definition: transport.h:339
static struct GNUNET_SCHEDULER_TaskContext tc
Task context of the current task.
Definition: scheduler.c:418
static void transmit_address_to_client(void *cls, const char *buf, int res)
Take the given address and append it to the set of results sent back to the client.
Each plugin is required to return a pointer to a struct of this type as the return value from its ent...
#define GNUNET_MQ_msg(mvar, type)
Allocate a GNUNET_MQ_Envelope.
Definition: gnunet_mq_lib.h:67
static int numeric
Option -n.
#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.
struct GNUNET_TRANSPORT_PluginFunctions * GST_plugins_printer_find(const char *name)
Obtain the plugin API based on a the stripped plugin name after the underscore.
struct GNUNET_SERVICE_Client * client
Handle to the client.
uint32_t res
GNUNET_OK if the conversion succeeded, GNUNET_SYSERR if it failed
Definition: transport.h:334
struct TransportClient * tc
Client that made the request.
void * cls
Closure for all of the callbacks.
#define GNUNET_MESSAGE_TYPE_TRANSPORT_ADDRESS_TO_STRING_REPLY
Response to the address lookup request.
struct GNUNET_TIME_Relative GNUNET_TIME_relative_ntoh(struct GNUNET_TIME_RelativeNBO a)
Convert relative time from network byte order.
Definition: time.c:641
int16_t numeric_only
Should the conversion use numeric IP addresses (otherwise a reverse DNS lookup is OK – if applicable...
Definition: transport.h:359
static struct AddressToStringContext * a2s_tail
Tail of linked list of all pending address iterations.
#define GNUNET_SYSERR
Definition: gnunet_common.h:76
struct GNUNET_MQ_Handle * mq
Message queue to the client.
struct GNUNET_TIME_RelativeNBO timeout
timeout to give up (for DNS resolution timeout mostly)
Definition: transport.h:369
struct GNUNET_MQ_Envelope * env
Definition: 005.c:1
static struct AddressToStringContext * a2s_head
Head of linked list of all pending address iterations.
Client connected to the transport service.
#define GNUNET_log(kind,...)
GNUNET_TRANSPORT_AddressPrettyPrinter address_pretty_printer
Function to pretty-print addresses.
uint16_t addrlen
Length of the (binary) address in bytes, in big-endian.
Definition: transport.h:364
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
void GNUNET_SERVICE_client_disable_continue_warning(struct GNUNET_SERVICE_Client *c)
Disable the warning the server issues if a message is not acknowledged in a timely fashion...
Definition: service.c:2267
Context for address to string operations.
static char * address
GNS address for this phone.
static char * plugin_name
Name of our plugin.
Time for relative time used by GNUnet, in microseconds.
Here is the call graph for this function:

◆ compose_address_iterate_response_message()

static struct PeerIterateResponseMessage* compose_address_iterate_response_message ( const struct GNUNET_PeerIdentity peer,
const struct GNUNET_HELLO_Address address 
)
static

Compose PeerIterateResponseMessage using the given peer and address.

Parameters
peeridentity of the peer
addressthe address, NULL on disconnect
Returns
composed message

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

References GNUNET_HELLO_Address::address, GNUNET_HELLO_Address::address_length, PeerIterateResponseMessage::addrlen, GNUNET_assert, GNUNET_malloc, GNUNET_memcpy, GNUNET_MESSAGE_TYPE_TRANSPORT_MONITOR_PEER_RESPONSE, PeerIterateResponseMessage::header, PeerIterateResponseMessage::local_address_info, GNUNET_HELLO_Address::local_info, msg, peer, PeerIterateResponseMessage::peer, PeerIterateResponseMessage::pluginlen, PeerIterateResponseMessage::reserved, size, GNUNET_MessageHeader::size, GNUNET_HELLO_Address::transport_name, and GNUNET_MessageHeader::type.

Referenced by GST_clients_broadcast_peer_notification(), and send_peer_information().

996 {
998  size_t size;
999  size_t tlen;
1000  size_t alen;
1001  char *addr;
1002 
1003  GNUNET_assert (NULL != peer);
1004  if (NULL != address)
1005  {
1006  tlen = strlen (address->transport_name) + 1;
1007  alen = address->address_length;
1008  }
1009  else
1010  {
1011  tlen = 0;
1012  alen = 0;
1013  }
1014  size = (sizeof(struct PeerIterateResponseMessage) + alen + tlen);
1015  msg = GNUNET_malloc (size);
1016  msg->header.size = htons (size);
1017  msg->header.type =
1019  msg->reserved = htonl (0);
1020  msg->peer = *peer;
1021  msg->addrlen = htonl (alen);
1022  msg->pluginlen = htonl (tlen);
1023 
1024  if (NULL != address)
1025  {
1026  msg->local_address_info = htonl ((uint32_t) address->local_info);
1027  addr = (char *) &msg[1];
1028  GNUNET_memcpy (addr, address->address, alen);
1029  GNUNET_memcpy (&addr[alen], address->transport_name, tlen);
1030  }
1031  return msg;
1032 }
size_t address_length
Number of bytes in address.
enum GNUNET_HELLO_AddressInfo local_info
Extended information about address.
struct GNUNET_MessageHeader * msg
Definition: 005.c:2
const void * address
Binary representation of the address (plugin-specific).
uint32_t local_address_info
Local info about the address.
Definition: transport.h:562
#define GNUNET_assert(cond)
Use this for fatal errors that cannot be handled.
#define GNUNET_memcpy(dst, src, n)
Call memcpy() but check for n being 0 first.
Message from the transport service to the library containing information about a peer.
Definition: transport.h:537
uint16_t size
The length of the struct (in bytes, including the length field itself), in big-endian format...
uint32_t addrlen
Address length.
Definition: transport.h:572
uint16_t type
The type of the message (GNUNET_MESSAGE_TYPE_XXXX), in big-endian format.
#define GNUNET_MESSAGE_TYPE_TRANSPORT_MONITOR_PEER_RESPONSE
Response to GNUNET_MESSAGE_TYPE_TRANSPORT_MONITOR_PEER_REQUEST request to iterate over all known addr...
const char * transport_name
Name of the transport plugin enabling the communication using this address.
struct GNUNET_TESTBED_Peer * peer
The peer associated with this model.
static unsigned int size
Size of the "table".
Definition: peer.c:67
uint32_t reserved
For alignment.
Definition: transport.h:547
struct GNUNET_PeerIdentity peer
Peer identity.
Definition: transport.h:552
struct GNUNET_MessageHeader header
Type is GNUNET_MESSAGE_TYPE_TRANSPORT_MONITOR_PEER_RESPONSE.
Definition: transport.h:542
uint32_t pluginlen
Length of the plugin name.
Definition: transport.h:577
#define GNUNET_malloc(size)
Wrapper around malloc.
Here is the caller graph for this function:

◆ send_peer_information()

static void send_peer_information ( 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 
)
static

Output information of neighbours to the given client.

Parameters
clsthe struct PeerIterationContext *
peeridentity of the neighbour
addressthe address
statecurrent state this peer is in
state_timeouttimeout for the current state of the peer
bandwidth_ininbound quota in NBO
bandwidth_outoutbound quota in NBO

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

References IterationContext::all, compose_address_iterate_response_message(), env, GNUNET_ERROR_TYPE_DEBUG, GNUNET_free, GNUNET_i2s(), GNUNET_log, GNUNET_MQ_msg_copy(), GNUNET_MQ_send(), GNUNET_TIME_absolute_hton(), GNUNET_TRANSPORT_ps2s(), GNUNET_YES, GST_plugins_a2s(), PeerIterateResponseMessage::header, IterationContext::id, TransportClient::mq, msg, pc, PeerIterateResponseMessage::state, PeerIterateResponseMessage::state_timeout, and IterationContext::tc.

Referenced by handle_client_monitor_peers().

1077 {
1078  struct IterationContext *pc = cls;
1079  struct GNUNET_MQ_Envelope *env;
1081 
1082  if ((GNUNET_YES != pc->all) && (0 != memcmp (peer, &pc->id, sizeof(pc->id))))
1083  return;
1085  "Sending information about `%s' using address `%s' in state `%s'\n",
1086  GNUNET_i2s (peer),
1087  (NULL != address) ? GST_plugins_a2s (address) : "<none>",
1089  msg = compose_address_iterate_response_message (peer, address);
1090  msg->state = htonl (state);
1091  msg->state_timeout = GNUNET_TIME_absolute_hton (state_timeout);
1092  env = GNUNET_MQ_msg_copy (&msg->header);
1093  GNUNET_free (msg);
1094  GNUNET_MQ_send (pc->tc->mq, env);
1095 }
Closure for call_iterator().
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
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
struct GNUNET_PeerIdentity id
Which peers do we care about?
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.
const char * GST_plugins_a2s(const struct GNUNET_HELLO_Address *address)
Convert a given address to a human-readable format.
int all
GNUNET_YES if id should be ignored because we want all peers.
const char * GNUNET_TRANSPORT_ps2s(enum GNUNET_TRANSPORT_PeerState state)
Convert a transport state to a human readable string.
struct GNUNET_MQ_Handle * mq
Message queue to the client.
struct GNUNET_MQ_Envelope * env
Definition: 005.c:1
static struct GNUNET_FS_PublishContext * pc
Handle to FS-publishing operation.
#define GNUNET_log(kind,...)
struct GNUNET_MessageHeader header
Type is GNUNET_MESSAGE_TYPE_TRANSPORT_MONITOR_PEER_RESPONSE.
Definition: transport.h:542
#define GNUNET_YES
Definition: gnunet_common.h:77
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 TransportClient * tc
Context to use for the transmission.
struct GNUNET_TIME_AbsoluteNBO GNUNET_TIME_absolute_hton(struct GNUNET_TIME_Absolute a)
Convert absolute time to network byte order.
Definition: time.c:657
const char * GNUNET_i2s(const struct GNUNET_PeerIdentity *pid)
Convert a peer identity to a string (for printing debug messages).
#define GNUNET_free(ptr)
Wrapper around free.
Here is the call graph for this function:
Here is the caller graph for this function:

◆ handle_client_monitor_peers()

static void handle_client_monitor_peers ( void *  cls,
const struct PeerMonitorMessage msg 
)
static

Client asked to obtain information about a specific or all peers Process the request.

Parameters
clsthe client
msgthe peer address information request

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

References IterationContext::all, all_zeros, TransportClient::client, CT_MONITOR, CT_NONE, TransportClient::details, env, GNUNET_break, GNUNET_ERROR_TYPE_DEBUG, GNUNET_i2s(), GNUNET_log, GNUNET_MESSAGE_TYPE_TRANSPORT_MONITOR_PEER_RESPONSE_END, GNUNET_MQ_msg, GNUNET_MQ_send(), GNUNET_NO, GNUNET_SERVICE_client_disable_continue_warning(), GNUNET_SERVICE_client_drop(), GNUNET_SERVICE_client_mark_monitor(), GNUNET_YES, GST_neighbours_iterate(), IterationContext::id, TransportClient::monitor_peer, TransportClient::mq, msg, PeerMonitorMessage::one_shot, PeerMonitorMessage::peer, send_peer_information(), tc, IterationContext::tc, and TransportClient::type.

1107 {
1108  struct TransportClient *tc = cls;
1109  struct IterationContext pc;
1110 
1111  if (CT_NONE != tc->type)
1112  {
1113  GNUNET_break (0);
1115  return;
1116  }
1119 
1120  /* Send initial list */
1121  pc.tc = tc;
1122  if (0 == memcmp (&msg->peer, &all_zeros, sizeof(struct GNUNET_PeerIdentity)))
1123  {
1124  /* iterate over all neighbours */
1125  pc.all = GNUNET_YES;
1126  pc.id = msg->peer;
1127  }
1128  else
1129  {
1130  /* just return one neighbour */
1131  pc.all = GNUNET_NO;
1132  pc.id = msg->peer;
1133  }
1135 
1136  if (GNUNET_YES != ntohl (msg->one_shot))
1137  {
1138  tc->details.monitor_peer = msg->peer;
1139  tc->type = CT_MONITOR;
1140  if (0 !=
1141  memcmp (&msg->peer, &all_zeros, sizeof(struct GNUNET_PeerIdentity)))
1143  "Client %p started monitoring of the peer `%s'\n",
1144  tc,
1145  GNUNET_i2s (&msg->peer));
1146  else
1148  "Client %p started monitoring all peers\n",
1149  tc);
1150  }
1151  else
1152  {
1153  struct GNUNET_MessageHeader *msg;
1154  struct GNUNET_MQ_Envelope *env;
1155 
1156  env =
1157  GNUNET_MQ_msg (msg,
1159  GNUNET_MQ_send (tc->mq, env);
1160  }
1161 }
Closure for call_iterator().
void GST_neighbours_iterate(GST_NeighbourIterator cb, void *cb_cls)
Iterate over all connected neighbours.
struct GNUNET_PeerIdentity monitor_peer
Peer identity to monitor the addresses of.
struct GNUNET_MessageHeader * msg
Definition: 005.c:2
It is a monitor, forward monitor data.
static void send_peer_information(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)
Output information of neighbours to the given client.
static struct GNUNET_SCHEDULER_TaskContext tc
Task context of the current task.
Definition: scheduler.c:418
#define GNUNET_MQ_msg(mvar, type)
Allocate a GNUNET_MQ_Envelope.
Definition: gnunet_mq_lib.h:67
We do not know yet (client is fresh).
#define GNUNET_NO
Definition: gnunet_common.h:78
struct GNUNET_SERVICE_Client * client
Handle to the client.
#define GNUNET_break(cond)
Use this for internal assertion violations that are not fatal (can be handled) but should not occur...
enum ClientType type
What type of client is this?
#define GNUNET_MESSAGE_TYPE_TRANSPORT_MONITOR_PEER_RESPONSE_END
Response to GNUNET_MESSAGE_TYPE_TRANSPORT_MONITOR_PEER_RESPONSE_END terminating list of replies...
struct GNUNET_PeerIdentity peer
The identity of the peer to look up.
Definition: transport.h:485
void GNUNET_SERVICE_client_mark_monitor(struct GNUNET_SERVICE_Client *c)
Set the &#39;monitor&#39; flag on this client.
Definition: service.c:2407
void GNUNET_SERVICE_client_drop(struct GNUNET_SERVICE_Client *c)
Ask the server to disconnect from the given client.
Definition: service.c:2324
struct GNUNET_MQ_Handle * mq
Message queue to the client.
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).
static struct GNUNET_FS_PublishContext * pc
Handle to FS-publishing operation.
uint32_t one_shot
One shot call or continous replies?
Definition: transport.h:480
Client connected to the transport service.
#define GNUNET_log(kind,...)
Header for all communications.
#define GNUNET_YES
Definition: gnunet_common.h:77
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
union TransportClient::@72 details
void GNUNET_SERVICE_client_disable_continue_warning(struct GNUNET_SERVICE_Client *c)
Disable the warning the server issues if a message is not acknowledged in a timely fashion...
Definition: service.c:2267
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:

◆ plugin_session_info_cb()

static void plugin_session_info_cb ( void *  cls,
struct GNUNET_ATS_Session session,
const struct GNUNET_TRANSPORT_SessionInfo info 
)
static

Function called by the plugin with information about the current sessions managed by the plugin (for monitoring).

Parameters
clsclosure
sessionsession handle this information is about, NULL to indicate that we are "in sync" (initial iteration complete)
infoinformation about the state of the session, NULL if session is also NULL and we are merely signalling that the initial iteration is over

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

References GNUNET_HELLO_Address::address, GNUNET_TRANSPORT_SessionInfo::address, GNUNET_HELLO_Address::address_length, TransportPluginMonitorMessage::bytes_pending, TransportPluginMonitorMessage::delay, env, GNUNET_assert, GNUNET_break, GNUNET_ERROR_TYPE_DEBUG, GNUNET_free, GNUNET_i2s(), GNUNET_log, GNUNET_malloc, GNUNET_memcpy, GNUNET_MESSAGE_TYPE_TRANSPORT_MONITOR_PLUGIN_EVENT, GNUNET_MESSAGE_TYPE_TRANSPORT_MONITOR_PLUGIN_SYNC, GNUNET_MQ_msg, GNUNET_MQ_msg_copy(), GNUNET_MQ_send(), GNUNET_NO, GNUNET_notification_context_broadcast(), GNUNET_notification_context_get_size(), GNUNET_TIME_absolute_hton(), GST_plugins_monitor_subscribe(), TransportPluginMonitorMessage::header, GNUNET_TRANSPORT_SessionInfo::is_inbound, TransportPluginMonitorMessage::is_inbound, TransportClient::mq, msg, TransportPluginMonitorMessage::msgs_pending, name, GNUNET_TRANSPORT_SessionInfo::num_bytes_pending, GNUNET_TRANSPORT_SessionInfo::num_msg_pending, GNUNET_HELLO_Address::peer, TransportPluginMonitorMessage::peer, TransportPluginMonitorMessage::plugin_address_len, TransportPluginMonitorMessage::plugin_name_len, GNUNET_TRANSPORT_SessionInfo::receive_delay, GNUNET_ATS_SessionKiller::session, TransportPluginMonitorMessage::session_id, TransportPluginMonitorMessage::session_state, GNUNET_TRANSPORT_SessionInfo::session_timeout, size, GNUNET_MessageHeader::size, GNUNET_TRANSPORT_SessionInfo::state, TransportPluginMonitorMessage::timeout, GNUNET_HELLO_Address::transport_name, and GNUNET_MessageHeader::type.

Referenced by handle_client_monitor_plugins().

1180 {
1181  struct GNUNET_MQ_Envelope *env;
1183  struct GNUNET_MessageHeader *sync;
1184  size_t size;
1185  size_t slen;
1186  uint16_t alen;
1187  char *name;
1188  char *addr;
1189 
1191  {
1192  GST_plugins_monitor_subscribe (NULL, NULL);
1193  return;
1194  }
1195  if ((NULL == info) && (NULL == session))
1196  {
1197  /* end of initial iteration */
1198  if (NULL != sync_client)
1199  {
1200  env =
1202  GNUNET_MQ_send (sync_client->mq, env);
1203  sync_client = NULL;
1204  }
1205  return;
1206  }
1207  GNUNET_assert (NULL != info);
1209  "Plugin event for peer %s on transport %s\n",
1210  GNUNET_i2s (&info->address->peer),
1211  info->address->transport_name);
1212  slen = strlen (info->address->transport_name) + 1;
1213  alen = info->address->address_length;
1214  size = sizeof(struct TransportPluginMonitorMessage) + slen + alen;
1215  if (size > UINT16_MAX)
1216  {
1217  GNUNET_break (0);
1218  return;
1219  }
1220  msg = GNUNET_malloc (size);
1221  msg->header.size = htons (size);
1223  msg->session_state = htons ((uint16_t) info->state);
1224  msg->is_inbound = htons ((int16_t) info->is_inbound);
1225  msg->msgs_pending = htonl (info->num_msg_pending);
1226  msg->bytes_pending = htonl (info->num_bytes_pending);
1229  msg->peer = info->address->peer;
1230  msg->session_id = (uint64_t) (intptr_t) session;
1231  msg->plugin_name_len = htons (slen);
1232  msg->plugin_address_len = htons (alen);
1233  name = (char *) &msg[1];
1234  GNUNET_memcpy (name, info->address->transport_name, slen);
1235  addr = &name[slen];
1236  GNUNET_memcpy (addr, info->address->address, alen);
1237  if (NULL != sync_client)
1238  {
1239  struct GNUNET_MQ_Envelope *env;
1240 
1241  env = GNUNET_MQ_msg_copy (&msg->header);
1242  GNUNET_MQ_send (sync_client->mq, env);
1243  }
1244  else
1245  {
1247  }
1248  GNUNET_free (msg);
1249 }
size_t address_length
Number of bytes in address.
uint32_t num_bytes_pending
Number of bytes pending transmission for this session.
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
const void * address
Binary representation of the address (plugin-specific).
#define GNUNET_MESSAGE_TYPE_TRANSPORT_MONITOR_PLUGIN_EVENT
Monitoring event about the connection state of plugins, generated in response to a subscription initi...
void GST_plugins_monitor_subscribe(GNUNET_TRANSPORT_SessionInfoCallback cb, void *cb_cls)
Register callback with all plugins to monitor their status.
int16_t is_inbound
GNUNET_YES if this is an inbound connection, GNUNET_NO if this is an outbound connection, GNUNET_SYSERR if connections of this plugin are so fundamentally bidirectional that they have no &#39;initiator&#39; Value given in NBO.
Definition: transport.h:629
int is_inbound
GNUNET_YES if this is an inbound connection, GNUNET_NO if this is an outbound connection, GNUNET_SYSERR if connections of this plugin are so fundamentally bidirectional that they have no &#39;initiator&#39;
struct GNUNET_PeerIdentity peer
Which peer is this connection for?
Definition: transport.h:654
enum GNUNET_TRANSPORT_SessionState state
New state of the session.
#define GNUNET_assert(cond)
Use this for fatal errors that cannot be handled.
#define GNUNET_memcpy(dst, src, n)
Call memcpy() but check for n being 0 first.
#define GNUNET_MQ_msg(mvar, type)
Allocate a GNUNET_MQ_Envelope.
Definition: gnunet_mq_lib.h:67
#define GNUNET_NO
Definition: gnunet_common.h:78
uint16_t size
The length of the struct (in bytes, including the length field itself), in big-endian format...
const struct GNUNET_HELLO_Address * address
Address used by the session.
uint32_t num_msg_pending
Number of messages pending transmission for this session.
#define GNUNET_break(cond)
Use this for internal assertion violations that are not fatal (can be handled) but should not occur...
static struct TransportClient * sync_client
Plugin monitoring client we are currently syncing, NULL if all monitoring clients are in sync...
struct GNUNET_TIME_Absolute receive_delay
Until when does this plugin refuse to receive to manage staying within the inbound quota...
uint16_t type
The type of the message (GNUNET_MESSAGE_TYPE_XXXX), in big-endian format.
unsigned int GNUNET_notification_context_get_size(struct GNUNET_NotificationContext *nc)
Return active number of subscribers in this context.
Definition: nc.c:215
uint16_t plugin_name_len
Length of the plugin name in bytes, including 0-termination.
Definition: transport.h:664
uint16_t plugin_address_len
Length of the plugin address in bytes.
Definition: transport.h:669
const char * transport_name
Name of the transport plugin enabling the communication using this address.
uint32_t msgs_pending
Number of messages waiting transmission.
Definition: transport.h:634
struct GNUNET_TIME_Absolute session_timeout
At what time will this session timeout (unless activity happens)?
struct GNUNET_TIME_AbsoluteNBO timeout
When will this transport plugin session time out?
Definition: transport.h:644
#define GNUNET_MESSAGE_TYPE_TRANSPORT_MONITOR_PLUGIN_SYNC
Monitoring event notifying client that the initial iteration is now completed and we are in sync with...
static unsigned int size
Size of the "table".
Definition: peer.c:67
struct GNUNET_MQ_Handle * mq
Message queue to the client.
Transport-level connection status update.
Definition: transport.h:609
struct GNUNET_MQ_Envelope * env
Definition: 005.c:1
uint32_t bytes_pending
Number of bytes waiting for transmission.
Definition: transport.h:639
struct GNUNET_PeerIdentity peer
For which peer is this an address?
uint64_t session_id
Unique identifier for the session.
Definition: transport.h:659
void GNUNET_notification_context_broadcast(struct GNUNET_NotificationContext *nc, const struct GNUNET_MessageHeader *msg, int can_drop)
Send a message to all subscribers of this context.
Definition: nc.c:189
uint16_t session_state
An enum GNUNET_TRANSPORT_SessionState in NBO.
Definition: transport.h:619
struct GNUNET_TIME_AbsoluteNBO delay
Until how long is this plugin currently blocked from reading?
Definition: transport.h:649
const char * name
#define GNUNET_log(kind,...)
static struct GNUNET_NotificationContext * plugin_nc
Notification context, to send updates on changes to active plugin connections.
Header for all communications.
void GNUNET_MQ_send(struct GNUNET_MQ_Handle *mq, struct GNUNET_MQ_Envelope *ev)
Send a message with the given message queue.
Definition: mq.c:353
struct GNUNET_TIME_AbsoluteNBO GNUNET_TIME_absolute_hton(struct GNUNET_TIME_Absolute a)
Convert absolute time to network byte order.
Definition: time.c:657
const char * GNUNET_i2s(const struct GNUNET_PeerIdentity *pid)
Convert a peer identity to a string (for printing debug messages).
#define GNUNET_malloc(size)
Wrapper around malloc.
#define GNUNET_free(ptr)
Wrapper around free.
struct GNUNET_MessageHeader header
Type will be GNUNET_MESSAGE_TYPE_TRANSPORT_MONITOR_PLUGIN_EVENT.
Definition: transport.h:614
Here is the call graph for this function:
Here is the caller graph for this function:

◆ handle_client_monitor_plugins()

static void handle_client_monitor_plugins ( void *  cls,
const struct GNUNET_MessageHeader message 
)
static

Client asked to obtain information about all plugin connections.

Parameters
clsthe client
messagethe peer address information request

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

References TransportClient::client, GNUNET_assert, GNUNET_notification_context_add(), GNUNET_SERVICE_client_disable_continue_warning(), GNUNET_SERVICE_client_mark_monitor(), GST_plugins_monitor_subscribe(), TransportClient::mq, plugin_session_info_cb(), and tc.

1261 {
1262  struct TransportClient *tc = cls;
1263 
1267  GNUNET_assert (NULL == sync_client);
1268  sync_client = tc;
1270 }
static void plugin_session_info_cb(void *cls, struct GNUNET_ATS_Session *session, const struct GNUNET_TRANSPORT_SessionInfo *info)
Function called by the plugin with information about the current sessions managed by the plugin (for ...
void GST_plugins_monitor_subscribe(GNUNET_TRANSPORT_SessionInfoCallback cb, void *cb_cls)
Register callback with all plugins to monitor their status.
#define GNUNET_assert(cond)
Use this for fatal errors that cannot be handled.
static struct GNUNET_SCHEDULER_TaskContext tc
Task context of the current task.
Definition: scheduler.c:418
struct GNUNET_SERVICE_Client * client
Handle to the client.
void GNUNET_notification_context_add(struct GNUNET_NotificationContext *nc, struct GNUNET_MQ_Handle *mq)
Add a subscriber to the notification context.
Definition: nc.c:160
static struct TransportClient * sync_client
Plugin monitoring client we are currently syncing, NULL if all monitoring clients are in sync...
void GNUNET_SERVICE_client_mark_monitor(struct GNUNET_SERVICE_Client *c)
Set the &#39;monitor&#39; flag on this client.
Definition: service.c:2407
struct GNUNET_MQ_Handle * mq
Message queue to the client.
Client connected to the transport service.
static struct GNUNET_NotificationContext * plugin_nc
Notification context, to send updates on changes to active plugin connections.
void GNUNET_SERVICE_client_disable_continue_warning(struct GNUNET_SERVICE_Client *c)
Disable the warning the server issues if a message is not acknowledged in a timely fashion...
Definition: service.c:2267
Here is the call graph for this function:

◆ GST_clients_broadcast()

void GST_clients_broadcast ( const struct GNUNET_MessageHeader msg,
int  may_drop 
)

Broadcast the given message to all of our clients.

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

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

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

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

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

◆ GST_clients_broadcast_peer_notification()

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

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

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

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

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

Referenced by neighbours_changed_notification().

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

◆ mark_peer_down()

static int mark_peer_down ( void *  cls,
const struct GNUNET_PeerIdentity peer,
void *  value 
)
static

Mark the peer as down so we don't call the continuation context in the future.

Parameters
clsNULL
peerpeer that got disconnected
valuea struct SendTransmitContinuationContext to mark
Returns
GNUNET_OK (continue to iterate)

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

References SendTransmitContinuationContext::down, GNUNET_OK, GNUNET_YES, and value.

Referenced by GST_clients_broadcast_disconnect().

1356 {
1357  struct SendTransmitContinuationContext *stcc = value;
1358 
1359  stcc->down = GNUNET_YES;
1360  return GNUNET_OK;
1361 }
#define GNUNET_OK
Named constants for return values.
Definition: gnunet_common.h:75
static char * value
Value of the record to add/remove.
int down
Set to GNUNET_YES if the connection for target goes down and we thus must no longer send the GNUNET_M...
Closure for handle_send_transmit_continuation()
#define GNUNET_YES
Definition: gnunet_common.h:77
Here is the caller graph for this function:

◆ GST_clients_broadcast_disconnect()

void GST_clients_broadcast_disconnect ( const struct GNUNET_PeerIdentity peer)

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

Parameters
peerpeer that disconnected

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

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

Referenced by neighbours_disconnect_notification().

1372 {
1373  struct DisconnectInfoMessage disconnect_msg;
1374 
1376  peer,
1377  &mark_peer_down,
1378  NULL);
1379  disconnect_msg.header.size = htons (sizeof(struct DisconnectInfoMessage));
1380  disconnect_msg.header.type = htons (GNUNET_MESSAGE_TYPE_TRANSPORT_DISCONNECT);
1381  disconnect_msg.reserved = htonl (0);
1382  disconnect_msg.peer = *peer;
1383  GST_clients_broadcast (&disconnect_msg.header, GNUNET_NO);
1384 }
static struct GNUNET_CONTAINER_MultiPeerMap * active_stccs
Map of peer identities to active send transmit continuation contexts.
void GST_clients_broadcast(const struct GNUNET_MessageHeader *msg, int may_drop)
Broadcast the given message to all of our clients.
#define GNUNET_NO
Definition: gnunet_common.h:78
static int mark_peer_down(void *cls, const struct GNUNET_PeerIdentity *peer, void *value)
Mark the peer as down so we don&#39;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:

◆ transmit_our_hello()

static void transmit_our_hello ( 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 
)
static

Transmit our HELLO message to the given (connected) neighbour.

Parameters
clsthe 'HELLO' message
peeridentity of the peer
addressthe address
statecurrent state this peer is in
state_timeouttimeout for the current state of the peer
bandwidth_ininbound quota in NBO
bandwidth_outoutbound quota in NBO

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

References GNUNET_NO, GST_my_identity, GST_neighbours_send(), GST_neighbours_test_connected(), hello_expiration, and GNUNET_MessageHeader::size.

Referenced by process_hello_update().

1406 {
1407  const struct GNUNET_MessageHeader *hello = cls;
1408 
1409  if (0 == memcmp (peer, &GST_my_identity, sizeof(struct GNUNET_PeerIdentity)))
1410  return; /* not to ourselves */
1412  return;
1413 
1414  GST_neighbours_send (peer,
1415  hello,
1416  ntohs (hello->size),
1418  NULL,
1419  NULL);
1420 }
struct GNUNET_PeerIdentity GST_my_identity
Configuration handle.
int GST_neighbours_test_connected(const struct GNUNET_PeerIdentity *target)
Test if we&#39;re connected to the given peer.
#define GNUNET_NO
Definition: gnunet_common.h:78
uint16_t size
The length of the struct (in bytes, including the length field itself), in big-endian format...
struct GNUNET_TIME_Relative hello_expiration
Hello address expiration.
The identity of the host (wraps the signing key of the peer).
void GST_neighbours_send(const struct GNUNET_PeerIdentity *target, const void *msg, size_t msg_size, struct GNUNET_TIME_Relative timeout, GST_NeighbourSendContinuation cont, void *cont_cls)
Transmit a message to the given target using the active connection.
Header for all communications.
Here is the call graph for this function:
Here is the caller graph for this function:

◆ process_hello_update()

static void process_hello_update ( void *  cls,
const struct GNUNET_MessageHeader hello 
)
static

My HELLO has changed.

Tell everyone who should know.

Parameters
clsunused
hellonew HELLO

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

References GNUNET_ERROR_TYPE_DEBUG, GNUNET_log, GNUNET_NO, GST_clients_broadcast(), GST_neighbours_iterate(), and transmit_our_hello().

Referenced by run().

1431 {
1432  GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Broadcasting HELLO to clients\n");
1434  GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Broadcasting HELLO to neighbours\n");
1435  GST_neighbours_iterate (&transmit_our_hello, (void *) hello);
1436 }
void GST_neighbours_iterate(GST_NeighbourIterator cb, void *cb_cls)
Iterate over all connected neighbours.
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
#define GNUNET_log(kind,...)
static void transmit_our_hello(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)
Transmit our HELLO message to the given (connected) neighbour.
Here is the call graph for this function:
Here is the caller graph for this function:

◆ process_payload()

static struct GNUNET_TIME_Relative process_payload ( const struct GNUNET_HELLO_Address address,
struct GNUNET_ATS_Session session,
const struct GNUNET_MessageHeader message 
)
static

We received some payload.

Prepare to pass it on to our clients.

Parameters
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 to process
Returns
how long the plugin should wait until receiving more data

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

References buf, gettext_noop, GNUNET_ALIGN, GNUNET_ERROR_TYPE_DEBUG, GNUNET_i2s(), GNUNET_log, GNUNET_memcpy, GNUNET_MESSAGE_TYPE_TRANSPORT_RECV, GNUNET_NO, GNUNET_STATISTICS_update(), GNUNET_SYSERR, GNUNET_YES, GST_clients_broadcast(), GST_neighbours_calculate_receive_delay(), GST_neighbours_test_connected(), InboundMessage::header, InboundMessage::peer, ret, size, GNUNET_MessageHeader::size, and GNUNET_MessageHeader::type.

Referenced by GST_receive_callback().

1453 {
1454  struct GNUNET_TIME_Relative ret;
1455  int do_forward;
1456  struct InboundMessage *im;
1457  size_t msg_size = ntohs (message->size);
1458  size_t size = sizeof(struct InboundMessage) + msg_size;
1459  char buf[size] GNUNET_ALIGN;
1460 
1461  do_forward = GNUNET_SYSERR;
1463  msg_size,
1464  &do_forward);
1465  if (! GST_neighbours_test_connected (&address->peer))
1466  {
1468  "Discarded %u bytes type %u payload from peer `%s'\n",
1469  (unsigned int) msg_size,
1470  ntohs (message->type),
1471  GNUNET_i2s (&address->peer));
1473  GST_stats,
1474  gettext_noop ("# bytes payload discarded due to not connected peer"),
1475  msg_size,
1476  GNUNET_NO);
1477  return ret;
1478  }
1479 
1480  if (GNUNET_YES != do_forward)
1481  return ret;
1482  im = (struct InboundMessage *) buf;
1483  im->header.size = htons (size);
1485  im->peer = address->peer;
1486  GNUNET_memcpy (&im[1], message, ntohs (message->size));
1488  return ret;
1489 }
void GST_clients_broadcast(const struct GNUNET_MessageHeader *msg, int may_drop)
Broadcast the given message to all of our clients.
struct GNUNET_STATISTICS_Handle * GST_stats
Statistics handle.
int GST_neighbours_test_connected(const struct GNUNET_PeerIdentity *target)
Test if we&#39;re connected to the given peer.
#define GNUNET_memcpy(dst, src, n)
Call memcpy() but check for n being 0 first.
static int ret
Return value of the commandline.
Definition: gnunet-abd.c:81
#define GNUNET_NO
Definition: gnunet_common.h:78
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.
struct GNUNET_TIME_Relative GST_neighbours_calculate_receive_delay(const struct GNUNET_PeerIdentity *sender, ssize_t size, int *do_forward)
We have received a message from the given sender.
uint16_t type
The type of the message (GNUNET_MESSAGE_TYPE_XXXX), in big-endian format.
static char buf[2048]
#define GNUNET_SYSERR
Definition: gnunet_common.h:76
static unsigned int size
Size of the "table".
Definition: peer.c:67
struct GNUNET_PeerIdentity peer
Which peer sent the message?
Definition: transport.h:208
struct GNUNET_PeerIdentity peer
For which peer is this an address?
#define GNUNET_ALIGN
gcc-ism to force alignment; we use this to align char-arrays that may then be cast to &#39;struct&#39;s...
#define GNUNET_MESSAGE_TYPE_TRANSPORT_RECV
Message from TRANSPORT notifying about a message that was received.
#define GNUNET_log(kind,...)
#define GNUNET_YES
Definition: gnunet_common.h:77
struct GNUNET_MessageHeader header
Type will be GNUNET_MESSAGE_TYPE_TRANSPORT_RECV.
Definition: transport.h:203
const char * GNUNET_i2s(const struct GNUNET_PeerIdentity *pid)
Convert a peer identity to a string (for printing debug messages).
Message used to notify the transport API about a message received from the network.
Definition: transport.h:198
Time for relative time used by GNUnet, in microseconds.
#define gettext_noop(String)
Definition: gettext.h:69
Here is the call graph for this function:
Here is the caller graph for this function:

◆ kill_session_task()

static void kill_session_task ( void *  cls)
static

Task to asynchronously terminate a session.

Parameters
clsthe struct GNUNET_ATS_SessionKiller with the information for the kill

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

References GNUNET_TRANSPORT_PluginFunctions::cls, GNUNET_TRANSPORT_PluginFunctions::disconnect_session, GNUNET_CONTAINER_DLL_remove, GNUNET_free, GNUNET_ATS_SessionKiller::plugin, GNUNET_ATS_SessionKiller::session, and GNUNET_ATS_SessionKiller::task.

Referenced by kill_session().

1499 {
1500  struct GNUNET_ATS_SessionKiller *sk = cls;
1501 
1502  sk->task = NULL;
1504  sk->plugin->disconnect_session (sk->plugin->cls, sk->session);
1505  GNUNET_free (sk);
1506 }
#define GNUNET_CONTAINER_DLL_remove(head, tail, element)
Remove an element from a DLL.
static struct GNUNET_ATS_SessionKiller * sk_head
Head of DLL of asynchronous tasks to kill sessions.
struct GNUNET_TRANSPORT_PluginFunctions * plugin
Plugin for the session.
GNUNET_TRANSPORT_DisconnectSessionFunction disconnect_session
Function that can be used to force the plugin to disconnect from the given peer and cancel all previo...
void * cls
Closure for all of the callbacks.
struct GNUNET_ATS_Session * session
Session to kill.
static struct GNUNET_ATS_SessionKiller * sk_tail
Tail of DLL of asynchronous tasks to kill sessions.
Information we need for an asynchronous session kill.
struct GNUNET_SCHEDULER_Task * task
The kill task.
#define GNUNET_free(ptr)
Wrapper around free.
Here is the caller graph for this function:

◆ kill_session()

static void kill_session ( const char *  plugin_name,
struct GNUNET_ATS_Session session 
)
static

Force plugin to terminate session due to communication issue.

Parameters
plugin_namename of the plugin
sessionsession to termiante

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

References GNUNET_break, GNUNET_CONTAINER_DLL_insert, GNUNET_new, GNUNET_SCHEDULER_add_now(), GST_plugins_find(), kill_session_task(), GNUNET_ATS_SessionKiller::next, GNUNET_ATS_SessionKiller::plugin, GNUNET_ATS_SessionKiller::session, and GNUNET_ATS_SessionKiller::task.

Referenced by connect_bl_check_cont(), GST_receive_callback(), and plugin_env_session_start_bl_check_cont().

1518 {
1520  struct GNUNET_ATS_SessionKiller *sk;
1521 
1522  for (sk = sk_head; NULL != sk; sk = sk->next)
1523  if (sk->session == session)
1524  return;
1525  plugin = GST_plugins_find (plugin_name);
1526  if (NULL == plugin)
1527  {
1528  GNUNET_break (0);
1529  return;
1530  }
1531  /* need to issue disconnect asynchronously */
1532  sk = GNUNET_new (struct GNUNET_ATS_SessionKiller);
1533  sk->session = session;
1534  sk->plugin = plugin;
1537 }
static struct GNUNET_ATS_SessionKiller * sk_head
Head of DLL of asynchronous tasks to kill sessions.
#define GNUNET_CONTAINER_DLL_insert(head, tail, element)
Insert an element at the head of a DLL.
struct GNUNET_TRANSPORT_PluginFunctions * plugin
Plugin for the session.
Each plugin is required to return a pointer to a struct of this type as the return value from its ent...
struct GNUNET_ATS_SessionKiller * next
Kept in a DLL.
static void kill_session_task(void *cls)
Task to asynchronously terminate a session.
#define GNUNET_new(type)
Allocate a struct or union of the given type.
#define GNUNET_break(cond)
Use this for internal assertion violations that are not fatal (can be handled) but should not occur...
struct GNUNET_ATS_Session * session
Session to kill.
struct GNUNET_SCHEDULER_Task * GNUNET_SCHEDULER_add_now(GNUNET_SCHEDULER_TaskCallback task, void *task_cls)
Schedule a new task to be run as soon as possible.
Definition: scheduler.c:1280
struct GNUNET_TRANSPORT_PluginFunctions * GST_plugins_find(const char *name)
Obtain the plugin API based on a plugin name.
static char * plugin
Solver plugin name as string.
static struct GNUNET_ATS_SessionKiller * sk_tail
Tail of DLL of asynchronous tasks to kill sessions.
Information we need for an asynchronous session kill.
struct GNUNET_SCHEDULER_Task * task
The kill task.
static char * plugin_name
Name of our plugin.
Here is the call graph for this function:
Here is the caller graph for this function:

◆ connect_bl_check_cont()

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 
)
static

Black list check result for try_connect call If connection to the peer is allowed request adddress and ???

Parameters
clsthe message
peerthe peer
addressthe address
sessionthe session
resultthe result

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

References GNUNET_ERROR_TYPE_INFO, GNUNET_free, GNUNET_i2s(), GNUNET_log, GNUNET_OK, GNUNET_SYSERR, GST_blacklist_abort_matching(), GST_neighbours_handle_session_syn(), GST_plugins_a2s(), kill_session(), msg, and GNUNET_HELLO_Address::transport_name.

Referenced by GST_receive_callback().

1556 {
1557  struct GNUNET_MessageHeader *msg = cls;
1558 
1559  if (GNUNET_OK == result)
1560  {
1561  /* Blacklist allows to speak to this peer, forward SYN to neighbours */
1563  "Received SYN message from peer `%s' at `%s'\n",
1564  GNUNET_i2s (peer),
1565  GST_plugins_a2s (address));
1566  if (GNUNET_OK != GST_neighbours_handle_session_syn (msg, peer))
1567  {
1568  GST_blacklist_abort_matching (address, session);
1569  kill_session (address->transport_name, session);
1570  }
1571  GNUNET_free (msg);
1572  return;
1573  }
1574  GNUNET_free (msg);
1575  if (GNUNET_SYSERR == result)
1576  return; /* check was aborted, session destroyed */
1577  /* Blacklist denies to speak to this peer */
1579  "Discarding SYN message from `%s' due to denied blacklist check\n",
1580  GNUNET_i2s (peer));
1581  kill_session (address->transport_name, session);
1582 }
struct GNUNET_MessageHeader * msg
Definition: 005.c:2
int GST_neighbours_handle_session_syn(const struct GNUNET_MessageHeader *message, const struct GNUNET_PeerIdentity *peer)
We received a &#39;SYN&#39; message from the other peer.
void GST_blacklist_abort_matching(const struct GNUNET_HELLO_Address *address, struct GNUNET_ATS_Session *session)
Abort blacklist if address and session match.
#define GNUNET_OK
Named constants for return values.
Definition: gnunet_common.h:75
static void kill_session(const char *plugin_name, struct GNUNET_ATS_Session *session)
Force plugin to terminate session due to communication issue.
const char * transport_name
Name of the transport plugin enabling the communication using this address.
static int result
Global testing status.
const char * GST_plugins_a2s(const struct GNUNET_HELLO_Address *address)
Convert a given address to a human-readable format.
#define GNUNET_SYSERR
Definition: gnunet_common.h:76
#define GNUNET_log(kind,...)
Header for all communications.
const char * GNUNET_i2s(const struct GNUNET_PeerIdentity *pid)
Convert a peer identity to a string (for printing debug messages).
#define GNUNET_free(ptr)
Wrapper around free.
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
messagethe message, NULL if we only care about learning about the delay until we should receive again
sessionidentifier used for this session (NULL for plugins that do not offer bi-directional communication to the sender using the same "connection")
Returns
how long the plugin should wait until receiving more data (plugins that do not support this, can ignore the return value)

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

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

Referenced by GST_manipulation_recv().

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

◆ plugin_env_address_change_notification()

static void plugin_env_address_change_notification ( void *  cls,
int  add_remove,
const struct GNUNET_HELLO_Address address 
)
static

Function that will be called for each address the transport is aware that it might be reachable under.

Update our HELLO.

Parameters
clsname of the plugin (const char*)
add_removeshould the address added (YES) or removed (NO) from the set of valid addresses?
addressthe address to add or remove

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

References addresses, GNUNET_break, GNUNET_ERROR_TYPE_INFO, GNUNET_log, GNUNET_NO, GNUNET_STATISTICS_update(), GNUNET_YES, and GST_hello_modify_addresses().

Referenced by run().

1738 {
1739  static int addresses = 0;
1740 
1741  if (GNUNET_YES == add_remove)
1742  {
1743  addresses++;
1744  GNUNET_STATISTICS_update (GST_stats, "# transport addresses", 1, GNUNET_NO);
1745  }
1746  else if (GNUNET_NO == add_remove)
1747  {
1748  if (0 == addresses)
1749  {
1750  GNUNET_break (0);
1751  }
1752  else
1753  {
1754  addresses--;
1756  "# transport addresses",
1757  -1,
1758  GNUNET_NO);
1759  }
1760  }
1762  "Transport now has %u addresses to communicate\n",
1763  addresses);
1764  GST_hello_modify_addresses (add_remove, address);
1765 }
struct GNUNET_STATISTICS_Handle * GST_stats
Statistics handle.
#define GNUNET_NO
Definition: gnunet_common.h:78
static struct GNUNET_CONTAINER_MultiPeerMap * addresses
Hashmap to store addresses.
Definition: gnunet-ats.c:146
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_break(cond)
Use this for internal assertion violations that are not fatal (can be handled) but should not occur...
#define GNUNET_log(kind,...)
#define GNUNET_YES
Definition: gnunet_common.h:77
void GST_hello_modify_addresses(int addremove, const struct GNUNET_HELLO_Address *address)
Add or remove an address from this peer&#39;s HELLO message.
Here is the call graph for this function:
Here is the caller graph for this function:

◆ plugin_env_session_end()

static void plugin_env_session_end ( void *  cls,
const struct GNUNET_HELLO_Address address,
struct GNUNET_ATS_Session session 
)
static

Function that will be called whenever the plugin internally cleans up a session pointer and hence the service needs to discard all of those sessions as well.

Plugins that do not use sessions can simply omit calling this function and always use NULL wherever a session pointer is needed. This function should be called BEFORE a potential "TransmitContinuation" from the "TransmitFunction".

Parameters
clsclosure
addresswhich address was the session for
sessionwhich session is being destoyed

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

References GNUNET_assert, GNUNET_break, GNUNET_CONTAINER_DLL_remove, GNUNET_ERROR_TYPE_DEBUG, GNUNET_free, GNUNET_i2s(), GNUNET_log, GNUNET_SCHEDULER_cancel(), GST_ats_del_session(), GST_blacklist_abort_matching(), GST_neighbours_session_terminated(), GST_plugins_a2s(), GNUNET_ATS_SessionKiller::next, GNUNET_HELLO_Address::peer, GNUNET_ATS_SessionKiller::session, GNUNET_ATS_SessionKiller::task, and GNUNET_HELLO_Address::transport_name.

Referenced by run().

1785 {
1786  struct GNUNET_ATS_SessionKiller *sk;
1787 
1788  if (NULL == address)
1789  {
1790  GNUNET_break (0);
1791  return;
1792  }
1793  if (NULL == session)
1794  {
1795  GNUNET_break (0);
1796  return;
1797  }
1798  GNUNET_assert (strlen (address->transport_name) > 0);
1799 
1800  GNUNET_log (
1802  "Notification from plugin about terminated session %p from peer `%s' address `%s'\n",
1803  session,
1804  GNUNET_i2s (&address->peer),
1805  GST_plugins_a2s (address));
1806 
1807  GST_neighbours_session_terminated (&address->peer, session);
1808  GST_ats_del_session (address, session);
1809  GST_blacklist_abort_matching (address, session);
1810 
1811  for (sk = sk_head; NULL != sk; sk = sk->next)
1812  {
1813  if (sk->session == session)
1814  {
1817  GNUNET_free (sk);
1818  break;
1819  }
1820  }
1821 }
#define GNUNET_CONTAINER_DLL_remove(head, tail, element)
Remove an element from a DLL.
static struct GNUNET_ATS_SessionKiller * sk_head
Head of DLL of asynchronous tasks to kill sessions.
void GST_blacklist_abort_matching(const struct GNUNET_HELLO_Address *address, struct GNUNET_ATS_Session *session)
Abort blacklist if address and session match.
#define GNUNET_assert(cond)
Use this for fatal errors that cannot be handled.
int GST_neighbours_session_terminated(const struct GNUNET_PeerIdentity *peer, struct GNUNET_ATS_Session *session)
A session was terminated.
struct GNUNET_ATS_SessionKiller * next
Kept in a DLL.
#define GNUNET_break(cond)
Use this for internal assertion violations that are not fatal (can be handled) but should not occur...
struct GNUNET_ATS_Session * session
Session to kill.
const char * transport_name
Name of the transport plugin enabling the communication using this address.
const char * GST_plugins_a2s(const struct GNUNET_HELLO_Address *address)
Convert a given address to a human-readable format.
static struct GNUNET_ATS_SessionKiller * sk_tail
Tail of DLL of asynchronous tasks to kill sessions.
struct GNUNET_PeerIdentity peer
For which peer is this an address?
Information we need for an asynchronous session kill.
struct GNUNET_SCHEDULER_Task * task
The kill task.
#define GNUNET_log(kind,...)
void GST_ats_del_session(const struct GNUNET_HELLO_Address *address, struct GNUNET_ATS_Session *session)
Notify ATS that the session (but not the address) of a given address is no longer relevant...
const char * GNUNET_i2s(const struct GNUNET_PeerIdentity *pid)
Convert a peer identity to a string (for printing debug messages).
#define GNUNET_free(ptr)
Wrapper around free.
void * GNUNET_SCHEDULER_cancel(struct GNUNET_SCHEDULER_Task *task)
Cancel the task with the specified identifier.
Definition: scheduler.c:966
Here is the call graph for this function:
Here is the caller graph for this function:

◆ plugin_env_session_start_bl_check_cont()

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

Black list check result from blacklist check triggered when a plugin gave us a new session in plugin_env_session_start().

If connection to the peer is disallowed, kill the session.

Parameters
clsNULL
peerthe peer
addressaddress associated with the request
sessionsession associated with the request
resultthe result

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

References GNUNET_ERROR_TYPE_DEBUG, GNUNET_HELLO_address_check_option(), GNUNET_HELLO_ADDRESS_INFO_INBOUND, GNUNET_log, GNUNET_OK, GNUNET_YES, GST_plugins_a2s(), GST_validation_handle_address(), kill_session(), and GNUNET_HELLO_Address::transport_name.

Referenced by plugin_env_session_start().

1842 {
1843  if (GNUNET_OK != result)
1844  {
1845  kill_session (address->transport_name, session);
1846  return;
1847  }
1848  if (GNUNET_YES !=
1851  {
1853  "Informing verifier about inbound session's address `%s'\n",
1854  GST_plugins_a2s (address));
1856  }
1857 }
#define GNUNET_OK
Named constants for return values.
Definition: gnunet_common.h:75
int GNUNET_HELLO_address_check_option(const struct GNUNET_HELLO_Address *address, enum GNUNET_HELLO_AddressInfo option)
Check if an address has a local option set.
Definition: address.c:39
static void kill_session(const char *plugin_name, struct GNUNET_ATS_Session *session)
Force plugin to terminate session due to communication issue.
This is an inbound address and cannot be used to initiate an outbound connection to another peer...
const char * transport_name
Name of the transport plugin enabling the communication using this address.
static int result
Global testing status.
const char * GST_plugins_a2s(const struct GNUNET_HELLO_Address *address)
Convert a given address to a human-readable format.
#define GNUNET_log(kind,...)
#define GNUNET_YES
Definition: gnunet_common.h:77
void GST_validation_handle_address(const struct GNUNET_HELLO_Address *address)
Validate an individual address.
Here is the call graph for this function:
Here is the caller graph for this function:

◆ plugin_env_session_start()

static void plugin_env_session_start ( void *  cls,
const struct GNUNET_HELLO_Address address,
struct GNUNET_ATS_Session session,
enum GNUNET_NetworkType  scope 
)
static

Plugin tells transport service about a new inbound session.

Parameters
clsunused
addressthe address
sessionthe new session
scopenetwork scope information

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

References GNUNET_break, GNUNET_ERROR_TYPE_INFO, GNUNET_HELLO_address_check_option(), GNUNET_HELLO_ADDRESS_INFO_INBOUND, GNUNET_i2s(), GNUNET_log, GNUNET_NT_UNSPECIFIED, GNUNET_YES, GST_ats_add_inbound_address(), GST_blacklist_test_allowed(), GST_plugins_a2s(), GNUNET_HELLO_Address::peer, plugin_env_session_start_bl_check_cont(), GNUNET_ATS_Properties::scope, scope, and GNUNET_HELLO_Address::transport_name.

Referenced by run().

1873 {
1874  struct GNUNET_ATS_Properties prop;
1875 
1876  if (NULL == address)
1877  {
1878  GNUNET_break (0);
1879  return;
1880  }
1881  if (NULL == session)
1882  {
1883  GNUNET_break (0);
1884  return;
1885  }
1886  GNUNET_log (
1888  "Notification from plugin `%s' about new session from peer `%s' address `%s'\n",
1889  address->transport_name,
1890  GNUNET_i2s (&address->peer),
1891  GST_plugins_a2s (address));
1892  if (GNUNET_YES ==
1895  {
1896  /* inbound is always new, but outbound MAY already be known, but
1897  for example for UNIX, we have symmetric connections and thus we
1898  may not know the address yet; add if necessary! */
1899  /* FIXME: maybe change API here so we just pass scope? */
1900  memset (&prop, 0, sizeof(prop));
1902  prop.scope = scope;
1903  GST_ats_add_inbound_address (address, session, &prop);
1904  }
1905  /* Do blacklist check if communication with this peer is allowed */
1906  (void) GST_blacklist_test_allowed (&address->peer,
1907  address->transport_name,
1909  NULL,
1910  address,
1911  session);
1912 }
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.
ATS performance characteristics for an address.
#define GNUNET_break(cond)
Use this for internal assertion violations that are not fatal (can be handled) but should not occur...
int GNUNET_HELLO_address_check_option(const struct GNUNET_HELLO_Address *address, enum GNUNET_HELLO_AddressInfo option)
Check if an address has a local option set.
Definition: address.c:39
This is an inbound address and cannot be used to initiate an outbound connection to another peer...
static enum GNUNET_NetworkType scope
Which network scope do we belong to?
const char * transport_name
Name of the transport plugin enabling the communication using this address.
static void plugin_env_session_start_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 from blacklist check triggered when a plugin gave us a new session in plugin_...
void GST_ats_add_inbound_address(const struct GNUNET_HELLO_Address *address, struct GNUNET_ATS_Session *session, const struct GNUNET_ATS_Properties *prop)
Notify ATS about a new inbound address.
const char * GST_plugins_a2s(const struct GNUNET_HELLO_Address *address)
Convert a given address to a human-readable format.
struct GNUNET_PeerIdentity peer
For which peer is this an address?
#define GNUNET_log(kind,...)
#define GNUNET_YES
Definition: gnunet_common.h:77
const char * GNUNET_i2s(const struct GNUNET_PeerIdentity *pid)
Convert a peer identity to a string (for printing debug messages).
Category of last resort.
Definition: gnunet_nt_lib.h:40
Here is the call graph for this function:
Here is the caller graph for this function:

◆ ats_request_address_change()

static void ats_request_address_change ( void *  cls,
const struct GNUNET_PeerIdentity peer,
const struct GNUNET_HELLO_Address address,
struct GNUNET_ATS_Session session,
struct GNUNET_BANDWIDTH_Value32NBO  bandwidth_out,
struct GNUNET_BANDWIDTH_Value32NBO  bandwidth_in 
)
static

Function called by ATS to notify the callee that the assigned bandwidth or address for a given peer was changed.

If the callback is called with address/bandwidth assignments of zero, the ATS disconnect function will still be called once the disconnect actually happened.

Parameters
clsclosure
peerthe peer this address is intended for
addressaddress to use (for peer given in address)
sessionsession to use (if available)
bandwidth_outassigned outbound bandwidth for the connection in NBO, 0 to disconnect from peer
bandwidth_inassigned inbound bandwidth for the connection in NBO, 0 to disconnect from peer
atsATS information
ats_countnumber of ats elements

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

References GNUNET_assert, GNUNET_ERROR_TYPE_INFO, GNUNET_i2s(), GNUNET_log, GNUNET_NO, GNUNET_STATISTICS_update(), GST_neighbours_force_disconnect(), GST_neighbours_switch_to_address(), and GNUNET_BANDWIDTH_Value32NBO::value__.

Referenced by run().

1940 {
1941  uint32_t bw_in = ntohl (bandwidth_in.value__);
1942  uint32_t bw_out = ntohl (bandwidth_out.value__);
1943 
1944  if (NULL == peer)
1945  {
1946  /* ATS service died, all suggestions become invalid!
1947  (but we'll keep using the allocations for a little
1948  while, to keep going while ATS restarts) */
1949  /* FIXME: We should drop all
1950  connections now, as ATS won't explicitly tell
1951  us and be unaware of ongoing resource allocations! */
1952  return;
1953  }
1954  /* ATS tells me to disconnect from peer */
1955  if ((0 == bw_in) && (0 == bw_out))
1956  {
1958  "ATS tells me to disconnect from peer `%s'\n",
1959  GNUNET_i2s (peer));
1961  return;
1962  }
1963  GNUNET_assert (NULL != address);
1965  "# ATS suggestions received",
1966  1,
1967  GNUNET_NO);
1969  session,
1970  bandwidth_in,
1971  bandwidth_out);
1972 }
struct GNUNET_STATISTICS_Handle * GST_stats
Statistics handle.
#define GNUNET_assert(cond)
Use this for fatal errors that cannot be handled.
#define GNUNET_NO
Definition: gnunet_common.h:78
void GNUNET_STATISTICS_update(struct GNUNET_STATISTICS_Handle *handle, const char *name, int64_t delta, int make_persistent)
Set statistic value for the peer.
uint32_t value__
The actual value (bytes per second).
void GST_neighbours_switch_to_address(const struct GNUNET_HELLO_Address *address, struct GNUNET_ATS_Session *session, struct GNUNET_BANDWIDTH_Value32NBO bandwidth_in, struct GNUNET_BANDWIDTH_Value32NBO bandwidth_out)
For the given peer, switch to this address.
void GST_neighbours_force_disconnect(const struct GNUNET_PeerIdentity *target)
If we have an active connection to the given target, it must be shutdown.
#define GNUNET_log(kind,...)
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:

◆ confirm_or_drop_neighbour()

static void confirm_or_drop_neighbour ( void *  cls,
const struct GNUNET_PeerIdentity peer,
const struct GNUNET_HELLO_Address address,
struct GNUNET_ATS_Session session,
int  allowed 
)
static

Got the result about an existing connection from a new blacklister.

Shutdown the neighbour if necessary.

Parameters
clsunused
peerthe neighbour that was investigated
addressaddress associated with the request
sessionsession associated with the request
allowedGNUNET_OK if we can keep it, GNUNET_NO if we must shutdown the connection

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

References gettext_noop, GNUNET_NO, GNUNET_OK, GNUNET_STATISTICS_update(), and GST_neighbours_force_disconnect().

Referenced by test_connection_ok().

2009 {
2010  if (GNUNET_OK == allowed)
2011  return; /* we're done */
2013  gettext_noop ("# disconnects due to blacklist"),
2014  1,
2015  GNUNET_NO);
2017 }
struct GNUNET_STATISTICS_Handle * GST_stats
Statistics handle.
#define GNUNET_NO
Definition: gnunet_common.h:78
#define GNUNET_OK
Named constants for return values.
Definition: gnunet_common.h:75
void GNUNET_STATISTICS_update(struct GNUNET_STATISTICS_Handle *handle, const char *name, int64_t delta, int make_persistent)
Set statistic value for the peer.
void GST_neighbours_force_disconnect(const struct GNUNET_PeerIdentity *target)
If we have an active connection to the given target, it must be shutdown.
#define gettext_noop(String)
Definition: gettext.h:69
Here is the call graph for this function:
Here is the caller graph for this function:

◆ test_connection_ok()

static void test_connection_ok ( 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 
)
static

Test if an existing connection is still acceptable given a new blacklisting client.

Parameters
clsthe struct TestConnectionContext *
peeridentity of the peer
addressthe address
statecurrent state this peer is in
state_timeouttimeout for the current state of the peer
bandwidth_inbandwidth assigned inbound
bandwidth_outbandwidth assigned outbound

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

References GST_BlacklistCheck::address, GST_BlacklistCheck::bl_pos, confirm_or_drop_neighbour(), GST_BlacklistCheck::cont, GST_BlacklistCheck::cont_cls, do_blacklist_check(), TestConnectionContext::first, GNUNET_CONTAINER_DLL_insert, GNUNET_HELLO_address_copy(), GNUNET_new, GNUNET_NO, GNUNET_SCHEDULER_add_now(), GNUNET_YES, peer, GST_BlacklistCheck::peer, GST_BlacklistCheck::task, and TestConnectionContext::tc.

Referenced by handle_client_blacklist_init().

2040 {
2041  struct TestConnectionContext *tcc = cls;
2042  struct GST_BlacklistCheck *bc;
2043 
2044  bc = GNUNET_new (struct GST_BlacklistCheck);
2046  bc->peer = *peer;
2047  bc->address = GNUNET_HELLO_address_copy (address);
2049  bc->cont_cls = NULL;
2050  bc->bl_pos = tcc->tc;
2051  if (GNUNET_YES == tcc->first)
2052  {
2053  /* all would wait for the same client, no need to
2054  * create more than just the first task right now */
2056  tcc->first = GNUNET_NO;
2057  }
2058 }
struct GNUNET_HELLO_Address * address
Address for GST_blacklist_abort_matching(), can be NULL.
struct TransportClient * tc
Handle to the blacklisting client we need to ask.
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.
static void confirm_or_drop_neighbour(void *cls, const struct GNUNET_PeerIdentity *peer, const struct GNUNET_HELLO_Address *address, struct GNUNET_ATS_Session *session, int allowed)
Got the result about an existing connection from a new blacklister.
#define GNUNET_NO
Definition: gnunet_common.h:78
Closure for test_connection_ok().
#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 GST_BlacklistCheck * bc_head
Head of DLL of active blacklisting queries.
int first
Is this the first neighbour we&#39;re checking?
struct GNUNET_SCHEDULER_Task * GNUNET_SCHEDULER_add_now(GNUNET_SCHEDULER_TaskCallback task, void *task_cls)
Schedule a new task to be run as soon as possible.
Definition: scheduler.c:1280
struct GNUNET_TESTBED_Peer * peer
The peer associated with this model.
GST_BlacklistTestContinuation cont
Continuation to call with the result.
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
#define GNUNET_YES
Definition: gnunet_common.h:77
struct GNUNET_PeerIdentity peer
Peer being checked.
void * cont_cls
Closure for cont.
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:

◆ handle_client_blacklist_init()

static void handle_client_blacklist_init ( void *  cls,
const struct GNUNET_MessageHeader message 
)
static

Initialize a blacklisting client.

We got a blacklist-init message from this client, add it to the list of clients to query for blacklisting.

Parameters
clsthe client
messagethe blacklist-init message that was sent

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

References TransportClient::blacklist, TransportClient::client, CT_BLACKLIST, CT_NONE, TransportClient::details, TestConnectionContext::first, GNUNET_break, GNUNET_ERROR_TYPE_DEBUG, GNUNET_log, GNUNET_SERVICE_client_drop(), GNUNET_SERVICE_client_mark_monitor(), GNUNET_YES, GST_neighbours_iterate(), tc, TestConnectionContext::tc, test_connection_ok(), and TransportClient::type.

2072 {
2073  struct TransportClient *tc = cls;
2074  struct TestConnectionContext tcc;
2075 
2076  if (CT_NONE != tc->type)
2077  {
2078  GNUNET_break (0);
2080  return;
2081  }
2083  tc->type = CT_BLACKLIST;
2084  tc->details.blacklist.call_receive_done = GNUNET_YES;
2085  GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "New blacklist client %p\n", tc);
2086  /* confirm that all existing connections are OK! */
2087  tcc.tc = tc;
2088  tcc.first = GNUNET_YES;
2090 }
void GST_neighbours_iterate(GST_NeighbourIterator cb, void *cb_cls)
Iterate over all connected neighbours.
static struct GNUNET_SCHEDULER_TaskContext tc
Task context of the current task.
Definition: scheduler.c:418
We do not know yet (client is fresh).
Closure for test_connection_ok().
struct GNUNET_SERVICE_Client * client
Handle to the client.
#define GNUNET_break(cond)
Use this for internal assertion violations that are not fatal (can be handled) but should not occur...
enum ClientType type
What type of client is this?
It is a blacklist, query about allowed connections.
void GNUNET_SERVICE_client_mark_monitor(struct GNUNET_SERVICE_Client *c)
Set the &#39;monitor&#39; flag on this client.
Definition: service.c:2407
void GNUNET_SERVICE_client_drop(struct GNUNET_SERVICE_Client *c)
Ask the server to disconnect from the given client.
Definition: service.c:2324
struct TransportClient::@78::@79 blacklist
Additional details if type is CT_BLACKLIST.
Client connected to the transport service.
#define GNUNET_log(kind,...)
#define GNUNET_YES
Definition: gnunet_common.h:77
union TransportClient::@72 details
static void test_connection_ok(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)
Test if an existing connection is still acceptable given a new blacklisting client.
Here is the call graph for this function:

◆ free_blacklist_entry()

static int free_blacklist_entry ( void *  cls,
const struct GNUNET_PeerIdentity key,
void *  value 
)
static

Free the given entry in the blacklist.

Parameters
clsunused
keyhost identity (unused)
valuethe blacklist entry
Returns
GNUNET_OK (continue to iterate)

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

References GNUNET_free_non_null, GNUNET_OK, and value.

Referenced by shutdown_task().

2105 {
2106  char *be = value;
2107 
2108  GNUNET_free_non_null (be);
2109  return GNUNET_OK;
2110 }
#define GNUNET_OK
Named constants for return values.
Definition: gnunet_common.h:75
#define GNUNET_free_non_null(ptr)
Free the memory pointed to by ptr if ptr is not NULL.
static char * value
Value of the record to add/remove.
Here is the caller graph for this function:

◆ handle_client_set_metric()

static void handle_client_set_metric ( void *  cls,
const struct TrafficMetricMessage tm 
)
static

Set traffic metric to manipulate.

Parameters
clsclosure
messagecontaining information

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

References TransportClient::client, GNUNET_SERVICE_client_continue(), GST_manipulation_set_metric(), and tc.

2121 {
2122  struct TransportClient *tc = cls;
2123 
2126 }
static struct GNUNET_SCHEDULER_TaskContext tc
Task context of the current task.
Definition: scheduler.c:418
struct GNUNET_SERVICE_Client * client
Handle to the client.
void GST_manipulation_set_metric(const struct TrafficMetricMessage *tm)
Set traffic metric to manipulate.
Client connected to the transport service.
void GNUNET_SERVICE_client_continue(struct GNUNET_SERVICE_Client *c)
Continue receiving further messages from the given client.
Definition: service.c:2243
Here is the call graph for this function:

◆ shutdown_task()

static void shutdown_task ( void *  cls)
static

Function called when the service shuts down.

Unloads our plugins and cancels pending validations.

Parameters
clsclosure, unused

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

References free_blacklist_entry(), GNUNET_ATS_connectivity_done(), GNUNET_ATS_scheduling_done(), GNUNET_CONTAINER_DLL_remove, GNUNET_CONTAINER_multipeermap_destroy(), GNUNET_CONTAINER_multipeermap_iterate(), GNUNET_free, GNUNET_NO, GNUNET_notification_context_destroy(), GNUNET_NT_scanner_done(), GNUNET_PEERINFO_disconnect(), GNUNET_STATISTICS_destroy(), GST_ats_done(), GST_hello_stop(), GST_manipulation_stop(), GST_neighbours_stop(), GST_plugins_unload(), and GST_validation_stop().

Referenced by run().

2137 {
2138  struct AddressToStringContext *cur;
2139 
2141  GST_plugins_unload ();
2143  GST_ats_done ();
2145  GST_ats = NULL;
2147  GST_ats_connect = NULL;
2149  GST_is = NULL;
2150  while (NULL != (cur = a2s_head))
2151  {
2153  GNUNET_free (cur);
2154  }
2155  if (NULL != plugin_nc)
2156  {
2158  plugin_nc = NULL;
2159  }
2161  active_stccs = NULL;
2162  if (NULL != blacklist)
2163  {
2166  NULL);
2168  blacklist = NULL;
2169  }
2170  GST_hello_stop ();
2172 
2173  if (NULL != GST_peerinfo)
2174  {
2176  GST_peerinfo = NULL;
2177  }
2178  if (NULL != GST_stats)
2179  {
2181  GST_stats = NULL;
2182  }
2183  if (NULL != GST_my_private_key)
2184  {
2186  GST_my_private_key = NULL;
2187  }
2188 }
struct GNUNET_CRYPTO_EddsaPrivateKey * GST_my_private_key
Our private key.
#define GNUNET_CONTAINER_DLL_remove(head, tail, element)
Remove an element from a DLL.
static struct GNUNET_CONTAINER_MultiPeerMap * active_stccs
Map of peer identities to active send transmit continuation contexts.
void GST_ats_done()
Shutdown ATS subsystem.
struct GNUNET_STATISTICS_Handle * GST_stats
Statistics handle.
void GST_manipulation_stop()
Stop traffic manipulation.
static int free_blacklist_entry(void *cls, const struct GNUNET_PeerIdentity *key, void *value)
Free the given entry in the blacklist.
void GNUNET_ATS_scheduling_done(struct GNUNET_ATS_SchedulingHandle *sh)
Client is done with ATS scheduling, release resources.
#define GNUNET_NO
Definition: gnunet_common.h:78
void GST_validation_stop()
Stop the validation subsystem.
struct GNUNET_ATS_SchedulingHandle * GST_ats
ATS scheduling handle.
void GNUNET_STATISTICS_destroy(struct GNUNET_STATISTICS_Handle *h, int sync_first)
Destroy a handle (free all state associated with it).
void GNUNET_CONTAINER_multipeermap_destroy(struct GNUNET_CONTAINER_MultiPeerMap *map)
Destroy a hash map.
struct GNUNET_NT_InterfaceScanner * GST_is
Interface scanner determines our LAN address range(s).
void GST_neighbours_stop()
Cleanup the neighbours subsystem.
static struct AddressToStringContext * a2s_tail
Tail of linked list of all pending address iterations.
void GNUNET_NT_scanner_done(struct GNUNET_NT_InterfaceScanner *is)
Terminate interface scanner.
Definition: nt.c:433
static struct GNUNET_CONTAINER_MultiPeerMap * blacklist
Hashmap of blacklisted peers.
struct GNUNET_ATS_ConnectivityHandle * GST_ats_connect
ATS connectivity handle.
int GNUNET_CONTAINER_multipeermap_iterate(struct GNUNET_CONTAINER_MultiPeerMap *map, GNUNET_CONTAINER_PeerMapIterator it, void *it_cls)
Iterate over all entries in the map.
static struct AddressToStringContext * a2s_head
Head of linked list of all pending address iterations.
struct GNUNET_PEERINFO_Handle * GST_peerinfo
Handle to peerinfo service.
void GST_plugins_unload()
Unload all plugins.
static struct GNUNET_NotificationContext * plugin_nc
Notification context, to send updates on changes to active plugin connections.
void GNUNET_PEERINFO_disconnect(struct GNUNET_PEERINFO_Handle *h)
Disconnect from the peerinfo service.
Definition: peerinfo_api.c:156
void GNUNET_notification_context_destroy(struct GNUNET_NotificationContext *nc)
Destroy the context, force disconnect for all subscribers.
Definition: nc.c:137
void GNUNET_ATS_connectivity_done(struct GNUNET_ATS_ConnectivityHandle *ch)
Client is done with ATS connectivity management, release resources.
Context for address to string operations.
void GST_hello_stop()
Shutdown the HELLO module.
#define GNUNET_free(ptr)
Wrapper around free.
Here is the call graph for this function:
Here is the caller graph for this function:

◆ handle_client_blacklist_reply()

static void handle_client_blacklist_reply ( void *  cls,
const struct BlacklistMessage msg 
)
static

A blacklisting client has sent us reply.

Process it.

Parameters
clsthe client
msgthe blacklist-reply message that was sent

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

References GST_BlacklistCheck::address, GST_BlacklistCheck::bl_pos, TransportClient::blacklist, TransportClient::client, GST_BlacklistCheck::cont, GST_BlacklistCheck::cont_cls, CT_BLACKLIST, TransportClient::details, do_blacklist_check(), GNUNET_assert, GNUNET_break, GNUNET_CONTAINER_DLL_insert, GNUNET_CONTAINER_DLL_remove, GNUNET_ERROR_TYPE_DEBUG, GNUNET_i2s(), GNUNET_log, GNUNET_NO, GNUNET_SCHEDULER_add_now(), GNUNET_SERVICE_client_continue(), GNUNET_SERVICE_client_drop(), GNUNET_SYSERR, GNUNET_YES, GST_blacklist_test_cancel(), BlacklistMessage::is_allowed, GST_BlacklistCheck::next, TransportClient::next, GST_BlacklistCheck::peer, BlacklistMessage::peer, GST_BlacklistCheck::session, GST_BlacklistCheck::task, tc, and TransportClient::type.

2246 {
2247  struct TransportClient *tc = cls;
2248  struct GST_BlacklistCheck *bc;
2249 
2250  if (CT_BLACKLIST != tc->type)
2251  {
2252  GNUNET_break (0);
2254  return;
2255  }
2257  "Blacklist client %p sent reply for `%s'\n",
2258  tc,
2259  GNUNET_i2s (&msg->peer));
2260  bc = tc->details.blacklist.bc;
2261  tc->details.blacklist.bc = NULL;
2262  tc->details.blacklist.waiting_for_reply = GNUNET_NO;
2263  tc->details.blacklist.call_receive_done = GNUNET_YES;
2264  if (NULL != bc)
2265  {
2266  /* only run this if the blacklist check has not been
2267  * cancelled in the meantime... */
2268  GNUNET_assert (bc->bl_pos == tc);
2269  if (ntohl (msg->is_allowed) == GNUNET_SYSERR)
2270  {
2272  "Blacklist check failed, peer not allowed\n");
2273  /* For the duration of the continuation, make the ongoing
2274  check invisible (to avoid double-cancellation); then
2275  add it back again so we can re-use GST_blacklist_test_cancel() */
2277  bc->cont (bc->cont_cls, &bc->peer, bc->address, bc->session, GNUNET_NO);
2280  tc->details.blacklist.call_receive_done = GNUNET_NO;
2282  return;
2283  }
2284  else
2285  {
2287  "Blacklist check succeeded, continuing with checks\n");
2288  tc->details.blacklist.call_receive_done = GNUNET_NO;
2290  bc->bl_pos = tc->next;
2292  }
2293  }
2294  /* check if any other blacklist checks are waiting for this blacklister */
2295  for (bc = bc_head; bc != NULL; bc = bc->next)
2296  if ((bc->bl_pos == tc) && (NULL == bc->task))
2297  {
2299  break;
2300  }
2301 }
#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.
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_PeerIdentity peer
Which peer is being blacklisted or queried?
Definition: transport.h:602
uint32_t is_allowed
0 for the query, GNUNET_OK (allowed) or GNUNET_SYSERR (disallowed) for the response.
Definition: transport.h:597
#define GNUNET_assert(cond)
Use this for fatal errors that cannot be handled.
static struct GNUNET_SCHEDULER_TaskContext tc
Task context of the current task.
Definition: scheduler.c:418
#define GNUNET_NO
Definition: gnunet_common.h:78
static void do_blacklist_check(void *cls)
Perform next action in the blacklist check.
struct GNUNET_SERVICE_Client * client
Handle to the client.
struct GST_BlacklistCheck * next
This is a linked list.
#define GNUNET_break(cond)
Use this for internal assertion violations that are not fatal (can be handled) but should not occur...
enum ClientType type
What type of client is this?
It is a blacklist, query about allowed connections.
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 GNUNET_SCHEDULER_Task * GNUNET_SCHEDULER_add_now(GNUNET_SCHEDULER_TaskCallback task, void *task_cls)
Schedule a new task to be run as soon as possible.
Definition: scheduler.c:1280
void GNUNET_SERVICE_client_drop(struct GNUNET_SERVICE_Client *c)
Ask the server to disconnect from the given client.
Definition: service.c:2324
#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 TransportClient::@78::@79 blacklist
Additional details if type is CT_BLACKLIST.
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.
Client connected to the transport service.
#define GNUNET_log(kind,...)
#define GNUNET_YES
Definition: gnunet_common.h:77
union TransportClient::@72 details
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).
void GNUNET_SERVICE_client_continue(struct GNUNET_SERVICE_Client *c)
Continue receiving further messages from the given client.
Definition: service.c:2243
static struct GST_BlacklistCheck * bc_tail
Tail of DLL of active blacklisting queries.
Here is the call graph for this function:

◆ GST_blacklist_add_peer()

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

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

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

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

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

Referenced by blacklist_cfg_iter(), and run().

2313 {
2314  char *transport = NULL;
2315 
2316  if (NULL != transport_name)
2317  {
2319  "Adding peer `%s' with plugin `%s' to blacklist\n",
2320  GNUNET_i2s (peer),
2321  transport_name);
2322  transport = GNUNET_strdup (transport_name);
2323  }
2324  else
2326  "Adding peer `%s' with all plugins to blacklist\n",
2327  GNUNET_i2s (peer));
2328  if (NULL == blacklist)
2329  blacklist =
2331  GNUNET_NO);
2332 
2334  peer,
2335  transport,
2337 }
static struct GNUNET_TRANSPORT_CoreHandle * transport
Transport service.
#define GNUNET_NO
Definition: gnunet_common.h:78
struct GNUNET_CONTAINER_MultiPeerMap * GNUNET_CONTAINER_multipeermap_create(unsigned int len, int do_not_copy_keys)
Create a multi peer map (hash map for public keys of peers).
#define GNUNET_strdup(a)
Wrapper around GNUNET_xstrdup_.
static struct GNUNET_CONTAINER_MultiPeerMap * blacklist
Hashmap of blacklisted peers.
Allow multiple values with the same key.
int GNUNET_CONTAINER_multipeermap_put(struct GNUNET_CONTAINER_MultiPeerMap *map, const struct GNUNET_PeerIdentity *key, void *value, enum GNUNET_CONTAINER_MultiHashMapOption opt)
Store a key-value pair in the map.
#define GNUNET_log(kind,...)
#define TRANSPORT_BLACKLIST_HT_SIZE
Size of the blacklist hash map.
const char * GNUNET_i2s(const struct GNUNET_PeerIdentity *pid)
Convert a peer identity to a string (for printing debug messages).
Here is the call graph for this function:
Here is the caller graph for this function:

◆ GST_blacklist_abort_matching()

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

Abort blacklist if address and session match.

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

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

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

Referenced by connect_bl_check_cont(), GST_receive_callback(), and plugin_env_session_end().

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

◆ test_blacklisted()

static int test_blacklisted ( void *  cls,
const struct GNUNET_PeerIdentity key,
void *  value 
)
static

Test if the given blacklist entry matches.

If so, abort the iteration.

Parameters
clsthe transport name to match (const char*)
keythe key (unused)
valuethe 'char *' (name of a blacklisted transport)
Returns
GNUNET_OK if the entry does not match, GNUNET_NO if it matches

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

References GNUNET_ERROR_TYPE_DEBUG, GNUNET_i2s(), GNUNET_log, GNUNET_NO, GNUNET_OK, and value.

Referenced by GST_blacklist_test_allowed().

2382 {
2383  const char *transport_name = cls;
2384  char *be = value;
2385 
2386  /* Blacklist entry be:
2387  * (NULL == be): peer is blacklisted with all plugins
2388  * (NULL != be): peer is blacklisted for a specific plugin
2389  *
2390  * If (NULL != transport_name) we look for a transport specific entry:
2391  * if (transport_name == be) forbidden
2392  *
2394  "Comparing BL request for peer `%4s':`%s' with BL entry: `%s'\n",
2395  GNUNET_i2s (key),
2396  (NULL == transport_name) ? "unspecified" : transport_name,
2397  (NULL == be) ? "all plugins" : be);
2398  /* all plugins for this peer were blacklisted: disallow */
2399  if (NULL == value)
2400  return GNUNET_NO;
2401 
2402  /* blacklist check for specific transport */
2403  if ((NULL != transport_name) && (NULL != value))
2404  {
2405  if (0 == strcmp (transport_name, be))
2406  return GNUNET_NO; /* plugin is blacklisted! */
2407  }
2408  return GNUNET_OK;
2409 }
#define GNUNET_NO
Definition: gnunet_common.h:78
#define GNUNET_OK
Named constants for return values.
Definition: gnunet_common.h:75
static char * value
Value of the record to add/remove.
#define GNUNET_log(kind,...)
const char * GNUNET_i2s(const struct GNUNET_PeerIdentity *pid)
Convert a peer identity to a string (for printing debug messages).
Here is the call graph for this function:
Here is the caller graph for this function:

◆ GST_blacklist_test_allowed()

struct GST_BlacklistCheck* GST_blacklist_test_allowed ( const struct GNUNET_PeerIdentity peer,
const char *  transport_name,
GST_BlacklistTestContinuation  cont,
void *  cont_cls,
const struct GNUNET_HELLO_Address address,
struct GNUNET_ATS_Session session 
)

Test if a peer/transport combination is blacklisted.

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

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

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

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

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

◆ GST_blacklist_test_cancel()

void GST_blacklist_test_cancel ( struct GST_BlacklistCheck bc)

Cancel a blacklist check.

Parameters
bccheck to cancel

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

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

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

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

◆ blacklist_cfg_iter()

static void blacklist_cfg_iter ( void *  cls,
const char *  section,
const char *  option,
const char *  value 
)
static

Function to iterate over options in the blacklisting section for a peer.

Parameters
clsclosure
sectionname of the section
optionname of the option
valuevalue of the option

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

References _, GNUNET_CRYPTO_eddsa_public_key_from_string(), GNUNET_ERROR_TYPE_INFO, GNUNET_free, GNUNET_i2s(), GNUNET_log, GNUNET_OK, GNUNET_strdup, GST_blacklist_add_peer(), GNUNET_PeerIdentity::public_key, and res.

Referenced by read_blacklist_configuration().

2534 {
2535  unsigned int *res = cls;
2536  struct GNUNET_PeerIdentity peer;
2537  char *plugs;
2538  char *pos;
2539 
2540  if (GNUNET_OK !=
2542  strlen (option),
2543  &peer.public_key))
2544  return;
2545 
2546  if ((NULL == value) || (0 == strcmp (value, "")))
2547  {
2548  /* Blacklist whole peer */
2549  GST_blacklist_add_peer (&peer, NULL);
2551  _ ("Adding blacklisting entry for peer `%s'\n"),
2552  GNUNET_i2s (&peer));
2553  }
2554  else
2555  {
2556  plugs = GNUNET_strdup (value);
2557  for (pos = strtok (plugs, " "); pos != NULL; pos = strtok (NULL, " "))
2558  {
2560  _ ("Adding blacklisting entry for peer `%s':`%s'\n"),
2561  GNUNET_i2s (&peer),
2562  pos);
2563  GST_blacklist_add_peer (&peer, pos);
2564  }
2565  GNUNET_free (plugs);
2566  }
2567  (*res)++;
2568 }
#define GNUNET_OK
Named constants for return values.
Definition: gnunet_common.h:75
#define GNUNET_strdup(a)
Wrapper around GNUNET_xstrdup_.
#define _(String)
GNU gettext support macro.
Definition: platform.h:181
static char * value
Value of the record to add/remove.
static char * option
Name of the option.
Definition: gnunet-config.c:38
static int res
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).
struct GNUNET_TESTBED_Peer * peer
The peer associated with this model.
int GNUNET_CRYPTO_eddsa_public_key_from_string(const char *enc, size_t enclen, struct GNUNET_CRYPTO_EddsaPublicKey *pub)
Convert a string representing a public key to a public key.
Definition: crypto_ecc.c:499
The identity of the host (wraps the signing key of the peer).
#define GNUNET_log(kind,...)
const char * GNUNET_i2s(const struct GNUNET_PeerIdentity *pid)
Convert a peer identity to a string (for printing debug messages).
#define GNUNET_free(ptr)
Wrapper around free.
Here is the call graph for this function:
Here is the caller graph for this function:

◆ read_blacklist_configuration()

static void read_blacklist_configuration ( const struct GNUNET_CONFIGURATION_Handle cfg,
const struct GNUNET_PeerIdentity my_id 
)
static

Read blacklist configuration.

Parameters
cfgthe configuration handle
my_idmy peer identity

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

References blacklist_cfg_iter(), GNUNET_CONFIGURATION_iterate_section_values(),