GNUnet  0.20.0
gnunet-service-transport.c File Reference

main for gnunet-service-transport More...

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 address 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_EddsaPrivateKey GST_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.

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

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 };
@ CT_CORE_NO_HANDLERS
CORE client without any handlers.
@ CT_BLACKLIST
It is a blacklist, query about allowed connections.
@ CT_MONITOR
It is a monitor, forward monitor data.
@ CT_NONE
We do not know yet (client is fresh).
@ CT_CORE
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.

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  }
451  GNUNET_MQ_send (tc->mq, env);
452 }
struct GNUNET_MessageHeader * msg
Definition: 005.c:2
struct GNUNET_MQ_Envelope * env
Definition: 005.c:1
#define gettext_noop(String)
Definition: gettext.h:70
#define MAX_PENDING
How many messages can we have pending for a given client process before we start to drop incoming mes...
struct GNUNET_STATISTICS_Handle * GST_stats
Statistics handle.
#define GNUNET_log(kind,...)
@ GNUNET_YES
@ GNUNET_NO
@ GNUNET_ERROR_TYPE_DEBUG
unsigned int GNUNET_MQ_get_length(struct GNUNET_MQ_Handle *mq)
Obtain the current length of the message queue.
Definition: mq.c:293
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:304
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:533
void GNUNET_STATISTICS_update(struct GNUNET_STATISTICS_Handle *handle, const char *name, int64_t delta, int make_persistent)
Set statistic value for the peer.
static struct GNUNET_SCHEDULER_TaskContext tc
Task context of the current task.
Definition: scheduler.c:431
uint16_t type
The type of the message (GNUNET_MESSAGE_TYPE_XXXX), in big-endian format.
uint16_t size
The length of the struct (in bytes, including the length field itself), in big-endian format.

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, GST_stats, MAX_PENDING, msg, GNUNET_MessageHeader::size, tc, and GNUNET_MessageHeader::type.

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

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.

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 }
struct GNUNET_MQ_Handle * mq
Definition: 003.c:5
static struct TransportClient * clients_head
Head of linked list of all clients to this service.
static struct TransportClient * clients_tail
Tail of linked list of all clients to this service.
#define GNUNET_CONTAINER_DLL_insert(head, tail, element)
Insert an element at the head of a DLL.
#define GNUNET_new(type)
Allocate a struct or union of the given type.
Client connected to the transport service.
struct GNUNET_SERVICE_Client * client
Handle to the client.

References TransportClient::client, clients_head, clients_tail, GNUNET_CONTAINER_DLL_insert, GNUNET_ERROR_TYPE_DEBUG, GNUNET_log, GNUNET_new, mq, and tc.

◆ do_blacklist_check()

static void do_blacklist_check ( void *  cls)
static

Perform next action in the blacklist check.

Parameters
clsthe struct GST_BlacklistCheck *

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

2194 {
2195  struct GST_BlacklistCheck *bc = cls;
2196  struct TransportClient *tc;
2197  struct GNUNET_MQ_Envelope *env;
2198  struct BlacklistMessage *bm;
2199 
2200  bc->task = NULL;
2201  while (NULL != (tc = bc->bl_pos))
2202  {
2203  if (CT_BLACKLIST == tc->type)
2204  break;
2205  bc->bl_pos = tc->next;
2206  }
2207  if (NULL == tc)
2208  {
2210  "No other blacklist clients active, will allow neighbour `%s'\n",
2211  GNUNET_i2s (&bc->peer));
2212 
2213  bc->cont (bc->cont_cls, &bc->peer, bc->address, bc->session, GNUNET_OK);
2215  return;
2216  }
2217  if ((NULL != tc->details.blacklist.bc) ||
2218  (GNUNET_NO != tc->details.blacklist.waiting_for_reply))
2219  return; /* someone else busy with this client */
2220  tc->details.blacklist.bc = bc;
2222  bm->is_allowed = htonl (0);
2223  bm->peer = bc->peer;
2224  GNUNET_MQ_send (tc->mq, env);
2225  if (GNUNET_YES == tc->details.blacklist.call_receive_done)
2226  {
2227  tc->details.blacklist.call_receive_done = GNUNET_NO;
2229  }
2230  tc->details.blacklist.waiting_for_reply = GNUNET_YES;
2231 }
void GST_blacklist_test_cancel(struct GST_BlacklistCheck *bc)
Cancel a blacklist check.
@ GNUNET_OK
const char * GNUNET_i2s(const struct GNUNET_PeerIdentity *pid)
Convert a peer identity to a string (for printing debug messages).
#define GNUNET_MQ_msg(mvar, type)
Allocate a GNUNET_MQ_Envelope.
Definition: gnunet_mq_lib.h:78
#define GNUNET_MESSAGE_TYPE_TRANSPORT_BLACKLIST_QUERY
Query to a blacklisting client (is this peer blacklisted)?
void GNUNET_SERVICE_client_continue(struct GNUNET_SERVICE_Client *c)
Continue receiving further messages from the given client.
Definition: service.c:2249
Change in blacklisting (either request or notification, depending on which direction it is going).
Definition: transport.h:586
uint32_t is_allowed
0 for the query, GNUNET_OK (allowed) or GNUNET_SYSERR (disallowed) for the response.
Definition: transport.h:597
struct GNUNET_PeerIdentity peer
Which peer is being blacklisted or queried?
Definition: transport.h:602
Context we use when performing a blacklist check.
struct GNUNET_SCHEDULER_Task * task
Current task performing the check.
GST_BlacklistTestContinuation cont
Continuation to call with the result.
struct GNUNET_ATS_Session * session
Session for GST_blacklist_abort_matching(), can be NULL.
struct GNUNET_PeerIdentity peer
Peer being checked.
struct GNUNET_HELLO_Address * address
Address for GST_blacklist_abort_matching(), can be NULL.
struct TransportClient * bl_pos
Our current position in the blacklisters list.
void * cont_cls
Closure for cont.

References GST_BlacklistCheck::address, GST_BlacklistCheck::bl_pos, GST_BlacklistCheck::cont, GST_BlacklistCheck::cont_cls, CT_BLACKLIST, 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, GST_BlacklistCheck::peer, BlacklistMessage::peer, GST_BlacklistCheck::session, GST_BlacklistCheck::task, and tc.

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

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.

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 char * value
Value of the record to add/remove.
Closure for handle_send_transmit_continuation()
int down
Set to GNUNET_YES if the connection for target goes down and we thus must no longer send the GNUNET_M...
struct TransportClient * tc
Client that made the request.

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

Referenced by client_disconnect_cb().

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.

525 {
526  struct TransportClient *tc = app_ctx;
527  struct GST_BlacklistCheck *bc;
528 
530  "Client %p disconnected, cleaning up.\n",
531  tc);
532  if (NULL != active_stccs)
535  tc);
536  for (struct AddressToStringContext *cur = a2s_head; NULL != cur;
537  cur = cur->next)
538  {
539  if (cur->tc == tc)
540  cur->tc = NULL;
541  }
543  switch (tc->type)
544  {
545  case CT_NONE:
546  break;
547 
548  case CT_CORE:
549  break;
550 
551  case CT_MONITOR:
552  break;
553 
554  case CT_BLACKLIST:
555  for (bc = bc_head; NULL != bc; bc = bc->next)
556  {
557  if (bc->bl_pos != tc)
558  continue;
559  bc->bl_pos = tc->next;
560  if (NULL == bc->task)
562  }
563  break;
564 
565  case CT_CORE_NO_HANDLERS:
566  break;
567  }
568  GNUNET_free (tc);
569 }
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.
static void do_blacklist_check(void *cls)
Perform next action in the blacklist check.
static struct AddressToStringContext * a2s_head
Head of linked list of all pending address iterations.
static struct GNUNET_CONTAINER_MultiPeerMap * active_stccs
Map of peer identities to active send transmit continuation contexts.
static struct GST_BlacklistCheck * bc_head
Head of DLL of active blacklisting queries.
#define GNUNET_CONTAINER_DLL_remove(head, tail, element)
Remove an element from 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.
#define GNUNET_free(ptr)
Wrapper around free.
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:1299
Context for address to string operations.
struct AddressToStringContext * next
This is a doubly-linked list.
struct GST_BlacklistCheck * next
This is a linked list.

References a2s_head, active_stccs, bc_head, GST_BlacklistCheck::bl_pos, clients_head, clients_tail, 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, GST_BlacklistCheck::task, and tc.

Here is the call 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 585 of file gnunet-service-transport.c.

592 {
593  struct TransportClient *tc = cls;
594  struct ConnectInfoMessage cim;
595 
597  return;
598  cim.header.size = htons (sizeof(struct ConnectInfoMessage));
599  cim.header.type = htons (GNUNET_MESSAGE_TYPE_TRANSPORT_CONNECT);
600  cim.id = *peer;
601  cim.quota_out = bandwidth_out;
602  unicast (tc, &cim.header, GNUNET_NO);
603 }
static void unicast(struct TransportClient *tc, const struct GNUNET_MessageHeader *msg, int may_drop)
Queue the given message for transmission to the given client.
int GST_neighbours_test_connected(const struct GNUNET_PeerIdentity *target)
Test if we're connected to the given peer.
#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:118
struct GNUNET_MessageHeader header
Type will be GNUNET_MESSAGE_TYPE_TRANSPORT_CONNECT.
Definition: transport.h:122
struct GNUNET_TESTBED_Peer * peer
The peer associated with this model.

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

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 615 of file gnunet-service-transport.c.

616 {
617  struct TransportClient *tc = cls;
618  const struct GNUNET_MessageHeader *hello;
619  uint32_t options;
620 
621  GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Client %p sent START\n", tc);
622  options = ntohl (start->options);
623  if ((0 != (1 & options)) &&
624  (0 != memcmp (&start->self,
626  sizeof(struct GNUNET_PeerIdentity))))
627  {
628  /* client thinks this is a different peer, reject */
629  GNUNET_break (0);
630  GNUNET_SERVICE_client_drop (tc->client);
631  return;
632  }
633  if (CT_NONE != tc->type)
634  {
635  GNUNET_break (0);
636  GNUNET_SERVICE_client_drop (tc->client);
637  return;
638  }
639  if (0 != (2 & options))
640  tc->type = CT_CORE;
641  else
642  tc->type = CT_CORE_NO_HANDLERS;
643  hello = GST_hello_get ();
644  if (NULL != hello)
645  unicast (tc, hello, GNUNET_NO);
648 }
struct GNUNET_GETOPT_CommandLineOption options[]
Definition: 002.c:5
static int start
Set if we are to start default services (including ARM).
Definition: gnunet-arm.c:39
struct GNUNET_PeerIdentity GST_my_identity
Configuration handle.
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.
const struct GNUNET_MessageHeader * GST_hello_get()
Obtain this peers HELLO message.
void GST_neighbours_iterate(GST_NeighbourIterator cb, void *cb_cls)
Iterate over all connected neighbours.
#define GNUNET_break(cond)
Use this for internal assertion violations that are not fatal (can be handled) but should not occur.
void GNUNET_SERVICE_client_drop(struct GNUNET_SERVICE_Client *c)
Ask the server to disconnect from the given client.
Definition: service.c:2330
Header for all communications.
The identity of the host (wraps the signing key of the peer).

References 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, start, tc, and unicast().

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 658 of file gnunet-service-transport.c.

659 {
660  return GNUNET_OK; /* FIXME: check here? */
661 }

References GNUNET_OK.

◆ 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 671 of file gnunet-service-transport.c.

672 {
673  struct TransportClient *tc = cls;
674 
675  GNUNET_log (GNUNET_ERROR_TYPE_INFO, "Received HELLO message\n");
676  GST_validation_handle_hello (message);
678 }
int GST_validation_handle_hello(const struct GNUNET_MessageHeader *hello)
We've received a HELLO, check which addresses are new and trigger validation.
@ GNUNET_ERROR_TYPE_INFO

References GNUNET_ERROR_TYPE_INFO, GNUNET_log, GNUNET_SERVICE_client_continue(), GST_validation_handle_hello(), and tc.

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 691 of file gnunet-service-transport.c.

695 {
696  struct SendTransmitContinuationContext *stcc = cls;
697  struct SendOkMessage send_ok_msg;
698 #ifdef ENABLE_TTD
700  const struct GNUNET_HELLO_Address *addr;
701 
704 
707  "It took us %s to send %u/%u bytes to %s (%d, %s)\n",
709  (unsigned int) bytes_payload,
710  (unsigned int) bytes_on_wire,
711  GNUNET_i2s (&stcc->target),
712  success,
713  (NULL != addr) ? addr->transport_name : "%");
714  else
716  "It took us %s to send %u/%u bytes to %s (%d, %s)\n",
718  (unsigned int) bytes_payload,
719  (unsigned int) bytes_on_wire,
720  GNUNET_i2s (&stcc->target),
721  success,
722  (NULL != addr) ? addr->transport_name : "%");
723 #endif
724 
725  if (GNUNET_NO == stcc->down)
726  {
727  /* Only send confirmation if we are still connected */
729  "Sending SEND_OK for transmission request %llu\n",
730  stcc->uuid);
731  send_ok_msg.header.size = htons (sizeof(send_ok_msg));
732  send_ok_msg.header.type = htons (GNUNET_MESSAGE_TYPE_TRANSPORT_SEND_OK);
733  send_ok_msg.bytes_msg = htons (bytes_payload);
734  send_ok_msg.bytes_physical = htonl (bytes_on_wire);
735  send_ok_msg.success = htons (success);
736  send_ok_msg.peer = stcc->target;
737  unicast (stcc->tc, &send_ok_msg.header, GNUNET_NO);
738  }
739  GNUNET_assert (
740  GNUNET_OK ==
742  GNUNET_free (stcc);
743 }
static struct GNUNET_TIME_Relative delay
When should dkg communication start?
const struct GNUNET_HELLO_Address * GST_neighbour_get_current_address(const struct GNUNET_PeerIdentity *peer)
Obtain current address information for the given neighbour.
#define GNUNET_CONSTANTS_LATENCY_WARN
After what amount of latency for a message do we print a warning?
enum GNUNET_GenericReturnValue 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_assert(cond)
Use this for fatal errors that cannot be handled.
@ GNUNET_ERROR_TYPE_WARNING
#define GNUNET_MESSAGE_TYPE_TRANSPORT_SEND_OK
Confirmation from TRANSPORT that message for transmission has been queued (and that the next message ...
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:436
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:569
An address for communicating with a peer.
const char * transport_name
Name of the transport plugin enabling the communication using this address.
Time for relative time used by GNUnet, in microseconds.
uint64_t rel_value_us
The actual value.
Message used to notify the transport API that it can send another message to the transport service.
Definition: transport.h:217
unsigned long long uuid
Unique ID, for logging.
struct GNUNET_PeerIdentity target
Peer that was the target.
struct GNUNET_TIME_Absolute send_time
At what time did we receive the message?

References active_stccs, SendOkMessage::bytes_msg, SendOkMessage::bytes_physical, delay, 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().

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 753 of file gnunet-service-transport.c.

754 {
755  uint16_t size;
756  const struct GNUNET_MessageHeader *obmm;
757 
758  size = ntohs (obm->header.size) - sizeof(struct OutboundMessage);
759  if (size < sizeof(struct GNUNET_MessageHeader))
760  {
761  GNUNET_break (0);
762  return GNUNET_SYSERR;
763  }
764  obmm = (const struct GNUNET_MessageHeader *) &obm[1];
765  if (size != ntohs (obmm->size))
766  {
767  GNUNET_break (0);
768  return GNUNET_SYSERR;
769  }
770  return GNUNET_OK;
771 }
@ GNUNET_SYSERR
static unsigned int size
Size of the "table".
Definition: peer.c:68
Message used to notify the transport service about a message to be transmitted to another peer.
Definition: transport.h:285
struct GNUNET_MessageHeader header
Type will be GNUNET_MESSAGE_TYPE_TRANSPORT_SEND.
Definition: transport.h:289

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

◆ 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 781 of file gnunet-service-transport.c.

782 {
783  static unsigned long long uuid_gen;
784  struct TransportClient *tc = cls;
785  const struct GNUNET_MessageHeader *obmm;
786  struct SendTransmitContinuationContext *stcc;
787 
788  obmm = (const struct GNUNET_MessageHeader *) &obm[1];
790  {
791  /* not connected, not allowed to send; can happen due to asynchronous operations */
793  "Could not send message to peer `%s': not connected\n",
794  GNUNET_i2s (&obm->peer));
796  GST_stats,
797  gettext_noop ("# bytes payload dropped (other peer was not connected)"),
798  ntohs (obmm->size),
799  GNUNET_NO);
801  return;
802  }
803  GNUNET_log (
805  "Received SEND request %llu for `%s' and first message of type %u and total size %u\n",
806  uuid_gen,
807  GNUNET_i2s (&obm->peer),
808  ntohs (obmm->type),
809  ntohs (obmm->size));
811 
813  stcc->target = obm->peer;
814  stcc->tc = tc;
816  stcc->uuid = uuid_gen++;
818  active_stccs,
819  &stcc->target,
820  stcc,
823  obmm,
824  ntohs (obmm->size),
827  stcc);
828 }
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.
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's send function and transport plugins.
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.
@ GNUNET_CONTAINER_MULTIHASHMAPOPTION_MULTIPLE
Allow multiple values with the same key.
struct GNUNET_TIME_Relative GNUNET_TIME_relative_ntoh(struct GNUNET_TIME_RelativeNBO a)
Convert relative time from network byte order.
Definition: time.c:628
struct GNUNET_TIME_Absolute GNUNET_TIME_absolute_get(void)
Get the current time.
Definition: time.c:111
struct GNUNET_PeerIdentity peer
Which peer should receive the message?
Definition: transport.h:308
struct GNUNET_TIME_RelativeNBO timeout
Allowed delay.
Definition: transport.h:302

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

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 several 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 846 of file gnunet-service-transport.c.

847 {
848  struct AddressToStringContext *actx = cls;
849  struct GNUNET_MQ_Envelope *env;
850  struct AddressToStringResultMessage *atsm;
851  size_t slen;
852 
854  if (NULL == actx->tc)
855  return;
856  if (NULL == buf)
857  {
858  env = GNUNET_MQ_msg (atsm,
860  if (GNUNET_OK == res)
861  {
862  /* this was the last call, transmit */
863  atsm->res = htonl (GNUNET_OK);
864  atsm->addr_len = htonl (0);
865  GNUNET_MQ_send (actx->tc->mq, env);
867  GNUNET_free (actx);
868  return;
869  }
870  if (GNUNET_SYSERR == res)
871  {
872  /* address conversion failed, but there will be more callbacks */
873  atsm->res = htonl (GNUNET_SYSERR);
874  atsm->addr_len = htonl (0);
875  GNUNET_MQ_send (actx->tc->mq, env);
876  return;
877  }
878  }
880  /* successful conversion, append*/
881  slen = strlen (buf) + 1;
882  env =
883  GNUNET_MQ_msg_extra (atsm,
884  slen,
886  atsm->res = htonl (GNUNET_YES);
887  atsm->addr_len = htonl (slen);
888  GNUNET_memcpy (&atsm[1], buf, slen);
889  GNUNET_MQ_send (actx->tc->mq, env);
890 }
static int res
static char buf[2048]
static struct AddressToStringContext * a2s_tail
Tail of linked list of all pending address iterations.
#define GNUNET_memcpy(dst, src, n)
Call memcpy() but check for n being 0 first.
#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:63
#define GNUNET_MESSAGE_TYPE_TRANSPORT_ADDRESS_TO_STRING_REPLY
Response to the address lookup request.
struct TransportClient * tc
Client that made the request.
Message used to notify the transport API about an address to string conversion.
Definition: transport.h:324
uint32_t addr_len
Length of the following string, zero if is GNUNET_SYSERR.
Definition: transport.h:339
uint32_t res
GNUNET_OK if the conversion succeeded, GNUNET_SYSERR if it failed
Definition: transport.h:334
struct GNUNET_MQ_Handle * mq
Message queue to the client.

References a2s_head, a2s_tail, AddressToStringResultMessage::addr_len, buf, 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, res, AddressToStringResultMessage::res, and AddressToStringContext::tc.

Referenced by handle_client_address_to_string().

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 901 of file gnunet-service-transport.c.

903 {
904  const char *plugin_name;
905  const char *address;
906  uint32_t address_len;
907  uint16_t size;
908 
909  size = ntohs (alum->header.size);
910  address_len = ntohs (alum->addrlen);
911  if (size <= sizeof(struct AddressLookupMessage) + address_len)
912  {
913  GNUNET_break (0);
914  return GNUNET_SYSERR;
915  }
916  address = (const char *) &alum[1];
917  plugin_name = (const char *) &address[address_len];
918  if ('\0' != plugin_name[size - sizeof(struct AddressLookupMessage)
919  - address_len - 1])
920  {
921  GNUNET_break (0);
922  return GNUNET_SYSERR;
923  }
924  return GNUNET_OK;
925 }
static char * address
GNS address for this phone.
static char * plugin_name
Name of our plugin.
Message from the library to the transport service asking for converting a transport address to a huma...
Definition: transport.h:349
uint16_t addrlen
Length of the (binary) address in bytes, in big-endian.
Definition: transport.h:364
struct GNUNET_MessageHeader header
Type will be GNUNET_MESSAGE_TYPE_TRANSPORT_ADDRESS_TO_STRING.
Definition: transport.h:353

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

◆ 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 935 of file gnunet-service-transport.c.

937 {
938  struct TransportClient *tc = cls;
940  const char *plugin_name;
941  const char *address;
942  uint32_t address_len;
943  struct AddressToStringContext *actx;
944  struct GNUNET_MQ_Envelope *env;
945  struct AddressToStringResultMessage *atsm;
946  struct GNUNET_TIME_Relative rtimeout;
947  int32_t numeric;
948 
949  address_len = ntohs (alum->addrlen);
950  address = (const char *) &alum[1];
951  plugin_name = (const char *) &address[address_len];
952  rtimeout = GNUNET_TIME_relative_ntoh (alum->timeout);
953  numeric = ntohs (alum->numeric_only);
955  if (NULL == papi)
956  {
958  "Failed to find plugin `%s'\n",
959  plugin_name);
960  env = GNUNET_MQ_msg (atsm,
962  atsm->res = htonl (GNUNET_SYSERR);
963  atsm->addr_len = htonl (0);
964  GNUNET_MQ_send (tc->mq, env);
965  env = GNUNET_MQ_msg (atsm,
967  atsm->res = htonl (GNUNET_OK);
968  atsm->addr_len = htonl (0);
969  GNUNET_MQ_send (tc->mq, env);
970  return;
971  }
972  actx = GNUNET_new (struct AddressToStringContext);
973  actx->tc = tc;
977  "Pretty-printing address of %u bytes using plugin `%s'\n",
978  address_len,
979  plugin_name);
980  papi->address_pretty_printer (papi->cls,
981  plugin_name,
982  address,
983  address_len,
984  numeric,
985  rtimeout,
987  actx);
988 }
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.
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.
static int numeric
Option -n.
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:2273
int16_t numeric_only
Should the conversion use numeric IP addresses (otherwise a reverse DNS lookup is OK – if applicable)...
Definition: transport.h:359
struct GNUNET_TIME_RelativeNBO timeout
timeout to give up (for DNS resolution timeout mostly)
Definition: transport.h:369
Each plugin is required to return a pointer to a struct of this type as the return value from its ent...
void * cls
Closure for all of the callbacks.
GNUNET_TRANSPORT_AddressPrettyPrinter address_pretty_printer
Function to pretty-print addresses.

References a2s_head, a2s_tail, AddressToStringResultMessage::addr_len, address, GNUNET_TRANSPORT_PluginFunctions::address_pretty_printer, AddressLookupMessage::addrlen, 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(), numeric, AddressLookupMessage::numeric_only, plugin_name, AddressToStringResultMessage::res, AddressToStringContext::tc, tc, AddressLookupMessage::timeout, and transmit_address_to_client().

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 999 of file gnunet-service-transport.c.

1002 {
1004  size_t size;
1005  size_t tlen;
1006  size_t alen;
1007  char *addr;
1008 
1009  GNUNET_assert (NULL != peer);
1010  if (NULL != address)
1011  {
1012  tlen = strlen (address->transport_name) + 1;
1013  alen = address->address_length;
1014  }
1015  else
1016  {
1017  tlen = 0;
1018  alen = 0;
1019  }
1020  size = (sizeof(struct PeerIterateResponseMessage) + alen + tlen);
1021  msg = GNUNET_malloc (size);
1022  msg->header.size = htons (size);
1023  msg->header.type =
1025  msg->reserved = htonl (0);
1026  msg->peer = *peer;
1027  msg->addrlen = htonl (alen);
1028  msg->pluginlen = htonl (tlen);
1029 
1030  if (NULL != address)
1031  {
1032  msg->local_address_info = htonl ((uint32_t) address->local_info);
1033  addr = (char *) &msg[1];
1034  GNUNET_memcpy (addr, address->address, alen);
1035  GNUNET_memcpy (&addr[alen], address->transport_name, tlen);
1036  }
1037  return msg;
1038 }
#define GNUNET_malloc(size)
Wrapper around malloc.
#define GNUNET_MESSAGE_TYPE_TRANSPORT_MONITOR_PEER_RESPONSE
Response to GNUNET_MESSAGE_TYPE_TRANSPORT_MONITOR_PEER_REQUEST request to iterate over all known addr...
Message from the transport service to the library containing information about a peer.
Definition: transport.h:538

References address, GNUNET_assert, GNUNET_malloc, GNUNET_memcpy, GNUNET_MESSAGE_TYPE_TRANSPORT_MONITOR_PEER_RESPONSE, msg, peer, GNUNET_MessageHeader::size, size, and GNUNET_MessageHeader::type.

Referenced by GST_clients_broadcast_peer_notification(), and send_peer_information().

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 1076 of file gnunet-service-transport.c.

1083 {
1084  struct IterationContext *pc = cls;
1085  struct GNUNET_MQ_Envelope *env;
1087 
1088  if ((GNUNET_YES != pc->all) && (0 != memcmp (peer, &pc->id, sizeof(pc->id))))
1089  return;
1091  "Sending information about `%s' using address `%s' in state `%s'\n",
1092  GNUNET_i2s (peer),
1093  (NULL != address) ? GST_plugins_a2s (address) : "<none>",
1096  msg->state = htonl (state);
1097  msg->state_timeout = GNUNET_TIME_absolute_hton (state_timeout);
1098  env = GNUNET_MQ_msg_copy (&msg->header);
1099  GNUNET_free (msg);
1100  GNUNET_MQ_send (pc->tc->mq, env);
1101 }
static struct GNUNET_FS_PublishContext * pc
Handle to FS-publishing operation.
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.
struct GNUNET_TIME_AbsoluteNBO GNUNET_TIME_absolute_hton(struct GNUNET_TIME_Absolute a)
Convert absolute time to network byte order.
Definition: time.c:638
const char * GNUNET_TRANSPORT_ps2s(enum GNUNET_TRANSPORT_PeerState state)
Convert a transport state to a human readable string.
struct GNUNET_MQ_Handle * mq
Our own message queue for the FS service; only briefly used when we start to index a file,...
Definition: fs_api.h:1221
Closure for call_iterator().
struct GNUNET_TIME_AbsoluteNBO state_timeout
Timeout for the state this peer is in.
Definition: transport.h:557

References address, 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(), GNUNET_FS_PublishContext::mq, msg, pc, peer, state, and PeerIterateResponseMessage::state_timeout.

Referenced by handle_client_monitor_peers().

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 1112 of file gnunet-service-transport.c.

1113 {
1114  struct TransportClient *tc = cls;
1115  struct IterationContext pc;
1116 
1117  if (CT_NONE != tc->type)
1118  {
1119  GNUNET_break (0);
1120  GNUNET_SERVICE_client_drop (tc->client);
1121  return;
1122  }
1125 
1126  /* Send initial list */
1127  pc.tc = tc;
1128  if (0 == memcmp (&msg->peer, &all_zeros, sizeof(struct GNUNET_PeerIdentity)))
1129  {
1130  /* iterate over all neighbours */
1131  pc.all = GNUNET_YES;
1132  pc.id = msg->peer;
1133  }
1134  else
1135  {
1136  /* just return one neighbour */
1137  pc.all = GNUNET_NO;
1138  pc.id = msg->peer;
1139  }
1141 
1142  if (GNUNET_YES != ntohl (msg->one_shot))
1143  {
1144  tc->details.monitor_peer = msg->peer;
1145  tc->type = CT_MONITOR;
1146  if (0 !=
1147  memcmp (&msg->peer, &all_zeros, sizeof(struct GNUNET_PeerIdentity)))
1149  "Client %p started monitoring of the peer `%s'\n",
1150  tc,
1151  GNUNET_i2s (&msg->peer));
1152  else
1154  "Client %p started monitoring all peers\n",
1155  tc);
1156  }
1157  else
1158  {
1159  struct GNUNET_MessageHeader *msg;
1160  struct GNUNET_MQ_Envelope *env;
1161 
1162  env =
1163  GNUNET_MQ_msg (msg,
1165  GNUNET_MQ_send (tc->mq, env);
1166  }
1167 }
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_PeerIdentity all_zeros
Peer identity that is all zeros, used as a way to indicate "all peers".
#define GNUNET_MESSAGE_TYPE_TRANSPORT_MONITOR_PEER_RESPONSE_END
Response to GNUNET_MESSAGE_TYPE_TRANSPORT_MONITOR_PEER_RESPONSE_END terminating list of replies.
void GNUNET_SERVICE_client_mark_monitor(struct GNUNET_SERVICE_Client *c)
Set the 'monitor' flag on this client.
Definition: service.c:2413

References all_zeros, CT_MONITOR, CT_NONE, 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(), msg, pc, send_peer_information(), and tc.

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 1183 of file gnunet-service-transport.c.

1186 {
1187  struct GNUNET_MQ_Envelope *env;
1189  struct GNUNET_MessageHeader *sync;
1190  size_t size;
1191  size_t slen;
1192  uint16_t alen;
1193  char *name;
1194  char *addr;
1195 
1197  {
1198  GST_plugins_monitor_subscribe (NULL, NULL);
1199  return;
1200  }
1201  if ((NULL == info) && (NULL == session))
1202  {
1203  /* end of initial iteration */
1204  if (NULL != sync_client)
1205  {
1206  env =
1209  sync_client = NULL;
1210  }
1211  return;
1212  }
1213  GNUNET_assert (NULL != info);
1215  "Plugin event for peer %s on transport %s\n",
1216  GNUNET_i2s (&info->address->peer),
1217  info->address->transport_name);
1218  slen = strlen (info->address->transport_name) + 1;
1219  alen = info->address->address_length;
1220  size = sizeof(struct TransportPluginMonitorMessage) + slen + alen;
1221  if (size > UINT16_MAX)
1222  {
1223  GNUNET_break (0);
1224  return;
1225  }
1226  msg = GNUNET_malloc (size);
1227  msg->header.size = htons (size);
1229  msg->session_state = htons ((uint16_t) info->state);
1230  msg->is_inbound = htons ((int16_t) info->is_inbound);
1231  msg->msgs_pending = htonl (info->num_msg_pending);
1232  msg->bytes_pending = htonl (info->num_bytes_pending);
1233  msg->timeout = GNUNET_TIME_absolute_hton (info->session_timeout);
1234  msg->delay = GNUNET_TIME_absolute_hton (info->receive_delay);
1235  msg->peer = info->address->peer;
1236  msg->session_id = (uint64_t) (intptr_t) session;
1237  msg->plugin_name_len = htons (slen);
1238  msg->plugin_address_len = htons (alen);
1239  name = (char *) &msg[1];
1240  GNUNET_memcpy (name, info->address->transport_name, slen);
1241  addr = &name[slen];
1242  GNUNET_memcpy (addr, info->address->address, alen);
1243  if (NULL != sync_client)
1244  {
1245  struct GNUNET_MQ_Envelope *env;
1246 
1247  env = GNUNET_MQ_msg_copy (&msg->header);
1249  }
1250  else
1251  {
1253  }
1254  GNUNET_free (msg);
1255 }
#define info
static struct GNUNET_NotificationContext * plugin_nc
Notification context, to send updates on changes to active plugin connections.
static struct TransportClient * sync_client
Plugin monitoring client we are currently syncing, NULL if all monitoring clients are in sync.
void GST_plugins_monitor_subscribe(GNUNET_TRANSPORT_SessionInfoCallback cb, void *cb_cls)
Register callback with all plugins to monitor their status.
unsigned int GNUNET_notification_context_get_size(struct GNUNET_NotificationContext *nc)
Return active number of subscribers in this context.
Definition: nc.c:216
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:190
#define GNUNET_MESSAGE_TYPE_TRANSPORT_MONITOR_PLUGIN_EVENT
Monitoring event about the connection state of plugins, generated in response to a subscription initi...
#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...
const char * name
Transport-level connection status update.
Definition: transport.h:610

References 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(), info, TransportClient::mq, msg, name, plugin_nc, GNUNET_MessageHeader::size, size, sync_client, and GNUNET_MessageHeader::type.

Referenced by handle_client_monitor_plugins().

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 1265 of file gnunet-service-transport.c.

1267 {
1268  struct TransportClient *tc = cls;
1269 
1273  GNUNET_assert (NULL == sync_client);
1274  sync_client = tc;
1276 }
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 GNUNET_notification_context_add(struct GNUNET_NotificationContext *nc, struct GNUNET_MQ_Handle *mq)
Add a subscriber to the notification context.
Definition: nc.c:161

References GNUNET_assert, GNUNET_notification_context_add(), GNUNET_SERVICE_client_disable_continue_warning(), GNUNET_SERVICE_client_mark_monitor(), GST_plugins_monitor_subscribe(), plugin_nc, plugin_session_info_cb(), sync_client, and tc.

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 1286 of file gnunet-service-transport.c.

1287 {
1288  int done;
1289 
1291  "Asked to broadcast message of type %u with %u bytes\n",
1292  (unsigned int) ntohs (msg->type),
1293  (unsigned int) ntohs (msg->size));
1294  done = GNUNET_NO;
1295  for (struct TransportClient *tc = clients_head; NULL != tc; tc = tc->next)
1296  {
1297  if (CT_NONE == tc->type)
1298  continue; /* client not yet ready */
1299  if ((GNUNET_YES == may_drop) && (CT_CORE != tc->type))
1300  continue; /* skip, this client does not care about payload */
1301  unicast (tc, msg, may_drop);
1302  done = GNUNET_YES;
1303  }
1304  if (GNUNET_NO == done)
1306  "Message of type %u not delivered, is CORE service up?\n",
1307  ntohs (msg->type));
1308 }
static void done()

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

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

Here is the call graph for this function:
Here is the caller graph for this function:

◆ GST_clients_broadcast_peer_notification()

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

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

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

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

1325 {
1326  struct GNUNET_MQ_Envelope *env;
1328 
1330  msg->state = htonl (state);
1331  msg->state_timeout = GNUNET_TIME_absolute_hton (state_timeout);
1332  for (struct TransportClient *tc = clients_head; NULL != tc; tc = tc->next)
1333  {
1334  if (CT_MONITOR != tc->type)
1335  continue;
1336  if ((0 == memcmp (&tc->details.monitor_peer,
1337  &all_zeros,
1338  sizeof(struct GNUNET_PeerIdentity))) ||
1339  (0 == memcmp (&tc->details.monitor_peer,
1340  peer,
1341  sizeof(struct GNUNET_PeerIdentity))))
1342  {
1343  env = GNUNET_MQ_msg_copy (&msg->header);
1344  GNUNET_MQ_send (tc->mq, env);
1345  }
1346  }
1347  GNUNET_free (msg);
1348 }

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

Referenced by neighbours_changed_notification().

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 1361 of file gnunet-service-transport.c.

1362 {
1363  struct SendTransmitContinuationContext *stcc = value;
1364 
1365  stcc->down = GNUNET_YES;
1366  return GNUNET_OK;
1367 }

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

Referenced by GST_clients_broadcast_disconnect().

Here is the caller graph for this function:

◆ GST_clients_broadcast_disconnect()

void GST_clients_broadcast_disconnect ( const struct GNUNET_PeerIdentity peer)

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

Parameters
peerpeer that disconnected

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

1378 {
1379  struct DisconnectInfoMessage disconnect_msg;
1380 
1382  peer,
1383  &mark_peer_down,
1384  NULL);
1385  disconnect_msg.header.size = htons (sizeof(struct DisconnectInfoMessage));
1386  disconnect_msg.header.type = htons (GNUNET_MESSAGE_TYPE_TRANSPORT_DISCONNECT);
1387  disconnect_msg.reserved = htonl (0);
1388  disconnect_msg.peer = *peer;
1389  GST_clients_broadcast (&disconnect_msg.header, GNUNET_NO);
1390 }
static 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.
void GST_clients_broadcast(const struct GNUNET_MessageHeader *msg, int may_drop)
Broadcast the given message to all of our clients.
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 GNUNET_MESSAGE_TYPE_TRANSPORT_DISCONNECT
Message from TRANSPORT notifying about a client that disconnected from us.
Message from the transport service to the library informing about disconnects.
Definition: transport.h:150

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

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 1405 of file gnunet-service-transport.c.

1412 {
1413  const struct GNUNET_MessageHeader *hello = cls;
1414 
1415  if (0 == memcmp (peer, &GST_my_identity, sizeof(struct GNUNET_PeerIdentity)))
1416  return; /* not to ourselves */
1418  return;
1419 
1421  hello,
1422  ntohs (hello->size),
1424  NULL,
1425  NULL);
1426 }
struct GNUNET_TIME_Relative hello_expiration
Hello address expiration.
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.

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

Referenced by process_hello_update().

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 1436 of file gnunet-service-transport.c.

1437 {
1438  GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Broadcasting HELLO to clients\n");
1440  GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Broadcasting HELLO to neighbours\n");
1441  GST_neighbours_iterate (&transmit_our_hello, (void *) hello);
1442 }
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.

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

Referenced by run().

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 1436 of file gnunet-service-transport.c.

1459 {
1460  struct GNUNET_TIME_Relative ret;
1461  int do_forward;
1462  struct InboundMessage *im;
1463  size_t msg_size = ntohs (message->size);
1464  size_t size = sizeof(struct InboundMessage) + msg_size;
1465  char buf[size] GNUNET_ALIGN;
1466 
1467  do_forward = GNUNET_SYSERR;
1469  msg_size,
1470  &do_forward);
1471  if (! GST_neighbours_test_connected (&address->peer))
1472  {
1474  "Discarded %u bytes type %u payload from peer `%s'\n",
1475  (unsigned int) msg_size,
1476  ntohs (message->type),
1477  GNUNET_i2s (&address->peer));
1479  GST_stats,
1480  gettext_noop ("# bytes payload discarded due to not connected peer"),
1481  msg_size,
1482  GNUNET_NO);
1483  return ret;
1484  }
1485 
1486  if (GNUNET_YES != do_forward)
1487  return ret;
1488  im = (struct InboundMessage *) buf;
1489  im->header.size = htons (size);
1491  im->peer = address->peer;
1492  GNUNET_memcpy (&im[1], message, ntohs (message->size));
1494  return ret;
1495 }
static int ret
Return value of the commandline.
Definition: gnunet-abd.c:81
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.
#define GNUNET_ALIGN
gcc-ism to force alignment; we use this to align char-arrays that may then be cast to 'struct's.
#define GNUNET_MESSAGE_TYPE_TRANSPORT_RECV
Message from TRANSPORT notifying about a message that was received.
Message used to notify the transport API about a message received from the network.
Definition: transport.h:199
struct GNUNET_MessageHeader header
Type will be GNUNET_MESSAGE_TYPE_TRANSPORT_RECV.
Definition: transport.h:203
struct GNUNET_PeerIdentity peer
Which peer sent the message?
Definition: transport.h:208

◆ 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 1504 of file gnunet-service-transport.c.

1505 {
1506  struct GNUNET_ATS_SessionKiller *sk = cls;
1507 
1508  sk->task = NULL;
1510  sk->plugin->disconnect_session (sk->plugin->cls, sk->session);
1511  GNUNET_free (sk);
1512 }
static struct GNUNET_ATS_SessionKiller * sk_tail
Tail of DLL of asynchronous tasks to kill sessions.
static struct GNUNET_ATS_SessionKiller * sk_head
Head of DLL of asynchronous tasks to kill sessions.
Information we need for an asynchronous session kill.
struct GNUNET_ATS_Session * session
Session to kill.
struct GNUNET_TRANSPORT_PluginFunctions * plugin
Plugin for the session.
struct GNUNET_SCHEDULER_Task * task
The kill task.
GNUNET_TRANSPORT_DisconnectSessionFunction disconnect_session
Function that can be used to force the plugin to disconnect from the given peer and cancel all previo...

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

Referenced by kill_session().

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 1523 of file gnunet-service-transport.c.

1524 {
1526  struct GNUNET_ATS_SessionKiller *sk;
1527 
1528  for (sk = sk_head; NULL != sk; sk = sk->next)
1529  if (sk->session == session)
1530  return;
1532  if (NULL == plugin)
1533  {
1534  GNUNET_break (0);
1535  return;
1536  }
1537  /* need to issue disconnect asynchronously */
1538  sk = GNUNET_new (struct GNUNET_ATS_SessionKiller);
1539  sk->session = session;
1540  sk->plugin = plugin;
1543 }
struct TestcasePlugin * plugin
The process handle to the testbed service.
static void kill_session_task(void *cls)
Task to asynchronously terminate a session.
struct GNUNET_TRANSPORT_PluginFunctions * GST_plugins_find(const char *name)
Obtain the plugin API based on a plugin name.
struct GNUNET_ATS_SessionKiller * next
Kept in a DLL.

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

Referenced by connect_bl_check_cont(), and plugin_env_session_start_bl_check_cont().

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 address and ???

Parameters
clsthe message
peerthe peer
addressthe address
sessionthe session
resultthe result

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

1562 {
1563  struct GNUNET_MessageHeader *msg = cls;
1564 
1565  if (GNUNET_OK == result)
1566  {
1567  /* Blacklist allows to speak to this peer, forward SYN to neighbours */
1569  "Received SYN message from peer `%s' at `%s'\n",
1570  GNUNET_i2s (peer),
1573  {
1575  kill_session (address->transport_name, session);
1576  }
1577  GNUNET_free (msg);
1578  return;
1579  }
1580  GNUNET_free (msg);
1581  if (GNUNET_SYSERR == result)
1582  return; /* check was aborted, session destroyed */
1583  /* Blacklist denies to speak to this peer */
1585  "Discarding SYN message from `%s' due to denied blacklist check\n",
1586  GNUNET_i2s (peer));
1587  kill_session (address->transport_name, session);
1588 }
static int result
Global testing status.
void GST_blacklist_abort_matching(const struct GNUNET_HELLO_Address *address, struct GNUNET_ATS_Session *session)
Abort blacklist if address and session match.
static void kill_session(const char *plugin_name, struct GNUNET_ATS_Session *session)
Force plugin to terminate session due to communication issue.
int GST_neighbours_handle_session_syn(const struct GNUNET_MessageHeader *message, const struct GNUNET_PeerIdentity *peer)
We received a 'SYN' message from the other peer.

References address, 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, peer, and result.

Here is the call 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 1557 of file gnunet-service-transport.c.

1609 {
1610  const char *plugin_name = cls;
1611  struct GNUNET_TIME_Relative ret;
1612  uint16_t type;
1613 
1615  if (NULL == message)
1616  goto end;
1617  type = ntohs (message->type);
1619  "Received message with type %u from peer `%s' at %s\n",
1620  type,
1621  GNUNET_i2s (&address->peer),
1623 
1625  gettext_noop ("# bytes total received"),
1626  ntohs (message->size),
1627  GNUNET_NO);
1629  switch (type)
1630  {
1632  /* Future HELLO message, discard */
1633  return ret;
1634 
1636  if (GNUNET_OK != GST_validation_handle_hello (message))
1637  {
1638  GNUNET_break_op (0);
1640  }
1641  return ret;
1642 
1645  "Processing PING from `%s'\n",
1647  if (GNUNET_OK !=
1648  GST_validation_handle_ping (&address->peer, message, address, session))
1649  {
1651  kill_session (plugin_name, session);
1652  }
1653  break;
1654 
1657  "Processing PONG from `%s'\n",
1659  if (GNUNET_OK != GST_validation_handle_pong (&address->peer, message))
1660  {
1661  GNUNET_break_op (0);
1663  kill_session (plugin_name, session);
1664  }
1665  break;
1666 
1668  /* Do blacklist check if communication with this peer is allowed */
1669  (void) GST_blacklist_test_allowed (&address->peer,
1670  NULL,
1672  GNUNET_copy_message (message),
1673  address,
1674  session);
1675  break;
1676 
1678  if (GNUNET_OK !=
1679  GST_neighbours_handle_session_syn_ack (message, address, session))
1680  {
1682  kill_session (plugin_name, session);
1683  }
1684  break;
1685 
1687  if (GNUNET_OK !=
1688  GST_neighbours_handle_session_ack (message, address, session))
1689  {
1690  GNUNET_break_op (0);
1692  kill_session (plugin_name, session);
1693  }
1694  break;
1695 
1698  break;
1699 
1701  GST_neighbours_handle_quota_message (&address->peer, message);
1702  break;
1703 
1705  GST_neighbours_keepalive (&address->peer, message);
1706  break;
1707 
1709  GST_neighbours_keepalive_response (&address->peer, message);
1710  break;
1711 
1712  default:
1713  /* should be payload */
1715  gettext_noop ("# bytes payload received"),
1716  ntohs (message->size),
1717  GNUNET_NO);
1718  ret = process_payload (address, session, message);
1719  break;
1720  }
1721 end:
1723  "Allowing receive from peer %s to continue in %s\n",
1724  GNUNET_i2s (&address->peer),
1726  return ret;
1727 }
static int end
Set if we are to shutdown all services (including ARM).
Definition: gnunet-arm.c:34
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.
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 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 address and...
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...
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.
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.
int GST_neighbours_handle_session_ack(const struct GNUNET_MessageHeader *message, const struct GNUNET_HELLO_Address *address, struct GNUNET_ATS_Session *session)
We received a 'ACK' message from the other peer.
int GST_neighbours_handle_session_syn_ack(const struct GNUNET_MessageHeader *message, const struct GNUNET_HELLO_Address *address, struct GNUNET_ATS_Session *session)
We received a 'SESSION_SYN_ACK' message from the other peer.
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...
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.
int GST_validation_handle_ping(const struct GNUNET_PeerIdentity *sender, const struct GNUNET_MessageHeader *hdr, const struct GNUNET_HELLO_Address *sender_address, struct GNUNET_ATS_Session *session)
We've received a PING.
int GST_validation_handle_pong(const struct GNUNET_PeerIdentity *sender, const struct GNUNET_MessageHeader *hdr)
We've received a PONG.
#define GNUNET_break_op(cond)
Use this for assertion violations caused by other peers (i.e.
struct GNUNET_MessageHeader * GNUNET_copy_message(const struct GNUNET_MessageHeader *msg)
Create a copy of the given message.
#define GNUNET_MESSAGE_TYPE_TRANSPORT_SESSION_QUOTA
Message exchanged between transport services to indicate that the sender should limit its transmissio...
#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...
#define GNUNET_MESSAGE_TYPE_TRANSPORT_SESSION_KEEPALIVE_RESPONSE
Response to a GNUNET_MESSAGE_TYPE_TRANSPORT_SESSION_KEEPALIVE message to measure latency in a regular...
#define GNUNET_MESSAGE_TYPE_TRANSPORT_PONG
Transport PONG message.
#define GNUNET_MESSAGE_TYPE_TRANSPORT_SESSION_ACK
Transport ACK message exchanged between transport services to indicate that a SYN_ACK message was acc...
#define GNUNET_MESSAGE_TYPE_TRANSPORT_SESSION_DISCONNECT
Transport DISCONNECT message exchanged between transport services to indicate that a connection shoul...
#define GNUNET_MESSAGE_TYPE_HELLO_URI
Latest HELLO messages used for communicating peer addresses.
#define GNUNET_MESSAGE_TYPE_HELLO
HELLO message with friend only flag used for communicating peer addresses.
#define GNUNET_MESSAGE_TYPE_TRANSPORT_PING
Transport PING message.
#define GNUNET_MESSAGE_TYPE_TRANSPORT_SESSION_SYN
Transport SYN message exchanged between transport services to indicate that a session should be marke...
#define GNUNET_MESSAGE_TYPE_TRANSPORT_SESSION_SYN_ACK
Transport SYN_ACK message exchanged between transport services to indicate that a SYN message was acc...
#define GNUNET_TIME_UNIT_ZERO
Relative time zero.
enum GNUNET_TESTBED_UnderlayLinkModelType type
the type of this model

◆ 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 1740 of file gnunet-service-transport.c.

1744 {
1745  static int addresses = 0;
1746 
1747  if (GNUNET_YES == add_remove)
1748  {
1749  addresses++;
1750  GNUNET_STATISTICS_update (GST_stats, "# transport addresses", 1, GNUNET_NO);
1751  }
1752  else if (GNUNET_NO == add_remove)
1753  {
1754  if (0 == addresses)
1755  {
1756  GNUNET_break (0);
1757  }
1758  else
1759  {
1760  addresses--;
1762  "# transport addresses",
1763  -1,
1764  GNUNET_NO);
1765  }
1766  }
1768  "Transport now has %u addresses to communicate\n",
1769  addresses);
1770  GST_hello_modify_addresses (add_remove, address);
1771 }
static struct GNUNET_CONTAINER_MultiPeerMap * addresses
Hashmap to store addresses.
Definition: gnunet-ats.c:146
void GST_hello_modify_addresses(int addremove, const struct GNUNET_HELLO_Address *address)
Add or remove an address from this peer's HELLO message.

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

Referenced by run().

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 destroyed

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

1791 {
1792  struct GNUNET_ATS_SessionKiller *sk;
1793 
1794  if (NULL == address)
1795  {
1796  GNUNET_break (0);
1797  return;
1798  }
1799  if (NULL == session)
1800  {
1801  GNUNET_break (0);
1802  return;
1803  }
1804  GNUNET_assert (strlen (address->transport_name) > 0);
1805 
1806  GNUNET_log (
1808  "Notification from plugin about terminated session %p from peer `%s' address `%s'\n",
1809  session,
1810  GNUNET_i2s (&address->peer),
1812 
1816 
1817  for (sk = sk_head; NULL != sk; sk = sk->next)
1818  {
1819  if (sk->session == session)
1820  {
1823  GNUNET_free (sk);
1824  break;
1825  }
1826  }
1827 }
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.
int GST_neighbours_session_terminated(const struct GNUNET_PeerIdentity *peer, struct GNUNET_ATS_Session *session)
A session was terminated.
void * GNUNET_SCHEDULER_cancel(struct GNUNET_SCHEDULER_Task *task)
Cancel the task with the specified identifier.
Definition: scheduler.c:975

References address, 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_ATS_SessionKiller::session, sk_head, sk_tail, and GNUNET_ATS_SessionKiller::task.

Referenced by run().

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 1842 of file gnunet-service-transport.c.

1848 {
1849  if (GNUNET_OK != result)
1850  {
1851  kill_session (address->transport_name, session);
1852  return;
1853  }
1854  if (GNUNET_YES !=
1857  {
1859  "Informing verifier about inbound session's address `%s'\n",
1862  }
1863 }
void GST_validation_handle_address(const struct GNUNET_HELLO_Address *address)
Validate an individual address.
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
@ GNUNET_HELLO_ADDRESS_INFO_INBOUND
This is an inbound address and cannot be used to initiate an outbound connection to another peer.

References address, 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(), result, and GNUNET_ATS_SessionKiller::session.

Referenced by plugin_env_session_start().

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 1875 of file gnunet-service-transport.c.

1879 {
1880  struct GNUNET_ATS_Properties prop;
1881 
1882  if (NULL == address)
1883  {
1884  GNUNET_break (0);
1885  return;
1886  }
1887  if (NULL == session)
1888  {
1889  GNUNET_break (0);
1890  return;
1891  }
1892  GNUNET_log (
1894  "Notification from plugin `%s' about new session from peer `%s' address `%s'\n",
1895  address->transport_name,
1896  GNUNET_i2s (&address->peer),
1898  if (GNUNET_YES ==
1901  {
1902  /* inbound is always new, but outbound MAY already be known, but
1903  for example for UNIX, we have symmetric connections and thus we
1904  may not know the address yet; add if necessary! */
1905  /* FIXME: maybe change API here so we just pass scope? */
1906  memset (&prop, 0, sizeof(prop));
1908  prop.scope = scope;
1909  GST_ats_add_inbound_address (address, session, &prop);
1910  }
1911  /* Do blacklist check if communication with this peer is allowed */
1912  (void) GST_blacklist_test_allowed (&address->peer,
1913  address->transport_name,
1915  NULL,
1916  address,
1917  session);
1918 }
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.
@ GNUNET_NT_UNSPECIFIED
Category of last resort.
Definition: gnunet_nt_lib.h:43
static enum GNUNET_NetworkType scope
Which network scope do we belong to?
ATS performance characteristics for an address.

References address, 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(), plugin_env_session_start_bl_check_cont(), GNUNET_ATS_Properties::scope, and scope.

Referenced by run().

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 1940 of file gnunet-service-transport.c.

1946 {
1947  uint32_t bw_in = ntohl (bandwidth_in.value__);
1948  uint32_t bw_out = ntohl (bandwidth_out.value__);
1949 
1950  if (NULL == peer)
1951  {
1952  /* ATS service died, all suggestions become invalid!
1953  (but we'll keep using the allocations for a little
1954  while, to keep going while ATS restarts) */
1955  /* FIXME: We should drop all
1956  connections now, as ATS won't explicitly tell
1957  us and be unaware of ongoing resource allocations! */
1958  return;
1959  }
1960  /* ATS tells me to disconnect from peer */
1961  if ((0 == bw_in) && (0 == bw_out))
1962  {
1964  "ATS tells me to disconnect from peer `%s'\n",
1965  GNUNET_i2s (peer));
1967  return;
1968  }
1969  GNUNET_assert (NULL != address);
1971  "# ATS suggestions received",
1972  1,
1973  GNUNET_NO);
1975  session,
1976  bandwidth_in,
1977  bandwidth_out);
1978 }
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.
uint32_t value__
The actual value (bytes per second).

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

Referenced by run().

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 2010 of file gnunet-service-transport.c.

2015 {
2016  if (GNUNET_OK == allowed)
2017  return; /* we're done */
2019  gettext_noop ("# disconnects due to blacklist"),
2020  1,
2021  GNUNET_NO);
2023 }

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

Referenced by test_connection_ok().

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 2039 of file gnunet-service-transport.c.

2046 {
2047  struct TestConnectionContext *tcc = cls;
2048  struct GST_BlacklistCheck *bc;
2049 
2050  bc = GNUNET_new (struct GST_BlacklistCheck);
2052  bc->peer = *peer;
2055  bc->cont_cls = NULL;
2056  bc->bl_pos = tcc->tc;
2057  if (GNUNET_YES == tcc->first)
2058  {
2059  /* all would wait for the same client, no need to
2060  * create more than just the first task right now */
2062  tcc->first = GNUNET_NO;
2063  }
2064 }
static struct GST_BlacklistCheck * bc_tail
Tail of DLL of active blacklisting queries.
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.
struct GNUNET_HELLO_Address * GNUNET_HELLO_address_copy(const struct GNUNET_HELLO_Address *address)
Copy an address struct.
Definition: address.c:99
Closure for test_connection_ok().
struct TransportClient * tc
Handle to the blacklisting client we need to ask.
int first
Is this the first neighbour we're checking?

References address, GST_BlacklistCheck::address, bc_head, bc_tail, 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().

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 2076 of file gnunet-service-transport.c.

2078 {
2079  struct TransportClient *tc = cls;
2080  struct TestConnectionContext tcc;
2081 
2082  if (CT_NONE != tc->type)
2083  {
2084  GNUNET_break (0);
2085  GNUNET_SERVICE_client_drop (tc->client);
2086  return;
2087  }
2089  tc->type = CT_BLACKLIST;
2090  tc->details.blacklist.call_receive_done = GNUNET_YES;
2091  GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "New blacklist client %p\n", tc);
2092  /* confirm that all existing connections are OK! */
2093  tcc.tc = tc;
2094  tcc.first = GNUNET_YES;
2096 }
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.

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

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 2108 of file gnunet-service-transport.c.

2111 {
2112  char *be = value;
2113 
2114  GNUNET_free (be);
2115  return GNUNET_OK;
2116 }

References GNUNET_free, GNUNET_OK, and value.

Referenced by shutdown_task().

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
tmmessage containing information

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

2127 {
2128  struct TransportClient *tc = cls;
2129 
2132 }
void GST_manipulation_set_metric(const struct TrafficMetricMessage *tm)
Set traffic metric to manipulate.

References GNUNET_SERVICE_client_continue(), GST_manipulation_set_metric(), and tc.

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 2142 of file gnunet-service-transport.c.

2143 {
2144  struct AddressToStringContext *cur;
2145 
2147  GST_plugins_unload ();
2149  GST_ats_done ();
2151  GST_ats = NULL;
2153  GST_ats_connect = NULL;
2155  GST_is = NULL;
2156  while (NULL != (cur = a2s_head))
2157  {
2159  GNUNET_free (cur);
2160  }
2161  if (NULL != plugin_nc)
2162  {
2164  plugin_nc = NULL;
2165  }
2167  active_stccs = NULL;
2168  if (NULL != blacklist)
2169  {
2172  NULL);
2174  blacklist = NULL;
2175  }
2176  GST_hello_stop ();
2178 
2179  if (NULL != GST_peerinfo)
2180  {
2182  GST_peerinfo = NULL;
2183  }
2184  if (NULL != GST_stats)
2185  {
2187  GST_stats = NULL;
2188  }
2189 }
struct GNUNET_ATS_ConnectivityHandle * GST_ats_connect
ATS connectivity handle.
struct GNUNET_ATS_SchedulingHandle * GST_ats
ATS scheduling handle.
static int free_blacklist_entry(void *cls, const struct GNUNET_PeerIdentity *key, void *value)
Free the given entry in the blacklist.
struct GNUNET_NT_InterfaceScanner * GST_is
Interface scanner determines our LAN address range(s).
static struct GNUNET_CONTAINER_MultiPeerMap * blacklist
Hashmap of blacklisted peers.
struct GNUNET_PEERINFO_Handle * GST_peerinfo
Handle to peerinfo service.
void GST_ats_done()
Shutdown ATS subsystem.
void GST_hello_stop()
Shutdown the HELLO module.
void GST_manipulation_stop()
Stop traffic manipulation.
void GST_neighbours_stop()
Cleanup the neighbours subsystem.
void GST_plugins_unload()
Unload all plugins.
void GST_validation_stop()
Stop the validation subsystem.
void GNUNET_ATS_connectivity_done(struct GNUNET_ATS_ConnectivityHandle *ch)
Client is done with ATS connectivity management, release resources.
void GNUNET_ATS_scheduling_done(struct GNUNET_ATS_SchedulingHandle *sh)
Client is done with ATS scheduling, release resources.
void GNUNET_CONTAINER_multipeermap_destroy(struct GNUNET_CONTAINER_MultiPeerMap *map)
Destroy a hash map.
void GNUNET_notification_context_destroy(struct GNUNET_NotificationContext *nc)
Destroy the context, force disconnect for all subscribers.
Definition: nc.c:138
void GNUNET_NT_scanner_done(struct GNUNET_NT_InterfaceScanner *is)
Terminate interface scanner.
Definition: nt.c:427
void GNUNET_PEERINFO_disconnect(struct GNUNET_PEERINFO_Handle *h)
Disconnect from the peerinfo service.
Definition: peerinfo_api.c:149
void GNUNET_STATISTICS_destroy(struct GNUNET_STATISTICS_Handle *h, int sync_first)
Destroy a handle (free all state associated with it).

References a2s_head, a2s_tail, active_stccs, blacklist, 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, GST_ats_connect, GST_ats_done(), GST_hello_stop(), GST_is, GST_manipulation_stop(), GST_neighbours_stop(), GST_peerinfo, GST_plugins_unload(), GST_stats, GST_validation_stop(), and plugin_nc.

Referenced by run().

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 2241 of file gnunet-service-transport.c.

2242 {
2243  struct TransportClient *tc = cls;
2244  struct GST_BlacklistCheck *bc;
2245 
2246  if (CT_BLACKLIST != tc->type)
2247  {
2248  GNUNET_break (0);
2249  GNUNET_SERVICE_client_drop (tc->client);
2250  return;
2251  }
2253  "Blacklist client %p sent reply for `%s'\n",
2254  tc,
2255  GNUNET_i2s (&msg->peer));
2256  bc = tc->details.blacklist.bc;
2257  tc->details.blacklist.bc = NULL;
2258  tc->details.blacklist.waiting_for_reply = GNUNET_NO;
2259  tc->details.blacklist.call_receive_done = GNUNET_YES;
2260  if (NULL != bc)
2261  {
2262  /* only run this if the blacklist check has not been
2263  * cancelled in the meantime... */
2264  GNUNET_assert (bc->bl_pos == tc);
2265  if (ntohl (msg->is_allowed) == GNUNET_SYSERR)
2266  {
2268  "Blacklist check failed, peer not allowed\n");
2269  /* For the duration of the continuation, make the ongoing
2270  check invisible (to avoid double-cancellation); then
2271  add it back again so we can re-use GST_blacklist_test_cancel() */
2273  bc->cont (bc->cont_cls, &bc->peer, bc->address, bc->session, GNUNET_NO);
2276  tc->details.blacklist.call_receive_done = GNUNET_NO;
2278  return;
2279  }
2280  else
2281  {
2283  "Blacklist check succeeded, continuing with checks\n");
2284  tc->details.blacklist.call_receive_done = GNUNET_NO;
2286  bc->bl_pos = tc->next;
2288  }
2289  }
2290  /* check if any other blacklist checks are waiting for this blacklister */
2291  for (bc = bc_head; bc != NULL; bc = bc->next)
2292  if ((bc->bl_pos == tc) && (NULL == bc->task))
2293  {
2295  break;
2296  }
2297 }

References GST_BlacklistCheck::address, bc_head, bc_tail, GST_BlacklistCheck::bl_pos, GST_BlacklistCheck::cont, GST_BlacklistCheck::cont_cls, CT_BLACKLIST, 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(), msg, GST_BlacklistCheck::next, GST_BlacklistCheck::peer, GST_BlacklistCheck::session, GST_BlacklistCheck::task, and tc.

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 2307 of file gnunet-service-transport.c.

2309 {
2310  char *transport = NULL;
2311 
2312  if (NULL != transport_name)
2313  {
2315  "Adding peer `%s' with plugin `%s' to blacklist\n",
2316  GNUNET_i2s (peer),
2317  transport_name);
2318  transport = GNUNET_strdup (transport_name);
2319  }
2320  else
2322  "Adding peer `%s' with all plugins to blacklist\n",
2323  GNUNET_i2s (peer));
2324  if (NULL == blacklist)
2325  blacklist =
2327  GNUNET_NO);
2328 
2330  peer,
2331  transport,
2333 }
static struct GNUNET_TRANSPORT_CoreHandle * transport
Transport service.
#define TRANSPORT_BLACKLIST_HT_SIZE
Size of the blacklist hash map.
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_.

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

Referenced by blacklist_cfg_iter(), and run().

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 2343 of file gnunet-service-transport.c.

2345 {
2346  struct GST_BlacklistCheck *bc;
2347  struct GST_BlacklistCheck *n;
2348 
2349  n = bc_head;
2350  while (NULL != (bc = n))
2351  {
2352  n = bc->next;
2353  if ((bc->session == session) &&
2355  {
2356  bc->cont (bc->cont_cls,
2357  &bc->peer,
2358  bc->address,
2359  bc->session,
2360  GNUNET_SYSERR);
2362  }
2363  }
2364 }
int GNUNET_HELLO_address_cmp(const struct GNUNET_HELLO_Address *a1, const struct GNUNET_HELLO_Address *a2)
Compare two addresses.
Definition: address.c:112

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

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 2377 of file gnunet-service-transport.c.

2378 {
2379  const char *transport_name = cls;
2380  char *be = value;
2381 
2382  /* Blacklist entry be:
2383  * (NULL == be): peer is blacklisted with all plugins
2384  * (NULL != be): peer is blacklisted for a specific plugin
2385  *
2386  * If (NULL != transport_name) we look for a transport specific entry:
2387  * if (transport_name == be) forbidden
2388  *
2390  "Comparing BL request for peer `%4s':`%s' with BL entry: `%s'\n",
2391  GNUNET_i2s (key),
2392  (NULL == transport_name) ? "unspecified" : transport_name,
2393  (NULL == be) ? "all plugins" : be);
2394  /* all plugins for this peer were blacklisted: disallow */
2395  if (NULL == value)
2396  return GNUNET_NO;
2397 
2398  /* blacklist check for specific transport */
2399  if ((NULL != transport_name) && (NULL != value))
2400  {
2401  if (0 == strcmp (transport_name, be))
2402  return GNUNET_NO; /* plugin is blacklisted! */
2403  }
2404  return GNUNET_OK;
2405 }
struct GNUNET_HashCode key
The key used in the DHT.

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

Referenced by GST_blacklist_test_allowed().

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 2421 of file gnunet-service-transport.c.

2427 {
2428  struct GST_BlacklistCheck *bc;
2429  struct TransportClient *tc;
2430 
2431  GNUNET_assert (NULL != peer);
2433  "Blacklist check for peer `%s':%s\n",
2434  GNUNET_i2s (peer),
2435  (NULL != transport_name) ? transport_name : "unspecified");
2436 
2437  /* Check local blacklist by iterating over hashmap
2438  * If iteration is aborted, we found a matching blacklist entry */
2439  if ((NULL != blacklist) &&
2440  (GNUNET_SYSERR ==
2442  peer,
2444  (void *) transport_name)))
2445  {
2446  /* Disallowed by config, disapprove instantly */
2448  gettext_noop ("# disconnects due to blacklist"),
2449  1,
2450  GNUNET_NO);
2452  _ ("Disallowing connection to peer `%s' on transport %s\n"),
2453  GNUNET_i2s (peer),
2454  (NULL != transport_name) ? transport_name : "unspecified");
2455  if (NULL != cont)
2456  cont (cont_cls, peer, address, session, GNUNET_NO);
2457  return NULL;
2458  }
2459 
2460  for (tc = clients_head; NULL != tc; tc = tc->next)
2461  if (CT_BLACKLIST == tc->type)
2462  break;
2463  if (NULL == tc)
2464  {
2465  /* no blacklist clients, approve instantly */
2466  if (NULL != cont)
2467  cont (cont_cls, peer, address, session, GNUNET_OK);
2469  "Allowing connection to peer `%s' %s\n",
2470  GNUNET_i2s (peer),
2471  (NULL != transport_name) ? transport_name : "");
2472  return NULL;
2473  }
2474 
2475  /* need to query blacklist clients */
2476  bc = GNUNET_new (struct GST_BlacklistCheck);
2478  bc->peer = *peer;
2480  bc->session = session;
2481  bc->cont = cont;
2482  bc->cont_cls = cont_cls;
2483  bc->bl_pos = tc;
2485  return bc;
2486 }
static int test_blacklisted(void *cls, const struct GNUNET_PeerIdentity *key, void *value)
Test if the given blacklist entry matches.
#define _(String)
GNU gettext support macro.
Definition: platform.h:178
struct GST_BlacklistCheck * bc
Blacklist check that we're currently performing (or NULL if we're performing one that has been cancel...

References _, address, GST_BlacklistCheck::address, TransportClient::bc, bc_head, bc_tail, GST_BlacklistCheck::bl_pos, blacklist, clients_head, 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, GST_stats, peer, GST_BlacklistCheck::peer, GST_BlacklistCheck::session, GST_BlacklistCheck::task, tc, and test_blacklisted().

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

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 2490 of file gnunet-service-transport.c.

2491 {
2493  if (NULL != bc->bl_pos)
2494  {
2495  if ((CT_BLACKLIST == bc->bl_pos->type) &&
2496  (bc->bl_pos->details.blacklist.bc == bc))
2497  {
2498  /* we're at the head of the queue, remove us! */
2499  bc->bl_pos->details.blacklist.bc = NULL;
2500  }
2501  }
2502  if (NULL != bc->task)
2503  {
2505  bc->task = NULL;
2506  }
2507  GNUNET_free (bc->address);
2508  GNUNET_free (bc);
2509 }
enum ClientType type
What type of client is this?
struct TransportClient::@70::@71 blacklist
Additional details if type is CT_BLACKLIST.
union TransportClient::@64 details

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

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

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 2521 of file gnunet-service-transport.c.

2525 {
2526  unsigned int *res = cls;
2527  struct GNUNET_PeerIdentity peer;
2528  char *plugs;
2529  char *pos;
2530 
2531  if (GNUNET_OK !=
2533  strlen (option),
2534  &peer.public_key))
2535  return;
2536 
2537  if ((NULL == value) || (0 == strcmp (value, "")))
2538  {
2539  /* Blacklist whole peer */
2540  GST_blacklist_add_peer (&peer, NULL);
2542  _ ("Adding blacklisting entry for peer `%s'\n"),
2543  GNUNET_i2s (&peer));
2544  }
2545  else
2546  {
2547  plugs = GNUNET_strdup (value);
2548  for (pos = strtok (plugs, " "); pos != NULL; pos = strtok (NULL, " "))
2549  {
2551  _ ("Adding blacklisting entry for peer `%s':`%s'\n"),
2552  GNUNET_i2s (&peer),
2553  pos);
2554  GST_blacklist_add_peer (&peer, pos);
2555  }
2556  GNUNET_free (plugs);
2557  }
2558  (*res)++;
2559 }
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).
enum GNUNET_GenericReturnValue 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:358

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(), peer, res, and value.

Referenced by read_blacklist_configuration().

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 2569 of file gnunet-service-transport.c.

2571 {
2572  char cfg_sect[512];
2573  unsigned int res = 0;
2574 
2575  GNUNET_snprintf (cfg_sect,
2576  sizeof(cfg_sect),
2577  "transport-blacklist-%s",
2578  GNUNET_i2s_full (my_id));
2580  cfg_sect,
2582  &res);
2584  "Loaded %u blacklisting entries from configuration\n",
2585  res);
2586 }
static const struct GNUNET_CONFIGURATION_Handle * cfg
Configuration we are using.
Definition: gnunet-abd.c:36
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.
void GNUNET_CONFIGURATION_iterate_section_values(const struct GNUNET_CONFIGURATION_Handle *cfg, const char *section, GNUNET_CONFIGURATION_Iterator iter, void *iter_cls)
Iterate over values of a section in the configuration.
const char * GNUNET_i2s_full(const struct GNUNET_PeerIdentity *pid)
Convert a peer identity to a string (for printing debug messages).
int GNUNET_snprintf(char *buf, size_t size, const char *format,...) __attribute__((format(printf
Like snprintf, just aborts if the buffer is of insufficient size.

References blacklist_cfg_iter(), cfg, GNUNET_CONFIGURATION_iterate_section_values(), GNUNET_ERROR_TYPE_DEBUG, GNUNET_i2s_full(), GNUNET_log, GNUNET_snprintf(), and res.

Referenced by run().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ run()

static void run ( void *  cls,
const struct GNUNET_CONFIGURATION_Handle c,
struct GNUNET_SERVICE_Handle service 
)
static

Initiate transport service.

Parameters
clsclosure
cconfiguration to use
servicethe initialized service

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

2600 {
2601  char *keyfile;
2602  long long unsigned int max_fd_cfg;
2603  int max_fd_rlimit;
2604  int max_fd;
2605  int friend_only;
2606 
2607  /* setup globals */
2608  GST_cfg = c;
2610  "PEER",
2611  "PRIVATE_KEY",
2612  &keyfile))
2613  {
2614  GNUNET_log (
2616  _ (
2617  "Transport service is lacking key configuration settings. Exiting.\n"));
2619  return;
2620  }
2622  "transport",
2623  "HELLO_EXPIRATION",
2624  &hello_expiration))
2625  {
2627  }
2628  if (GNUNET_SYSERR ==
2630  GNUNET_YES,
2632  {
2634  "Failed to setup peer's private key\n");
2636  GNUNET_free (keyfile);
2637  return;
2638  }
2639  GNUNET_free (keyfile);
2640  GST_stats = GNUNET_STATISTICS_create ("transport", GST_cfg);
2645  "My identity is `%s'\n",
2647 
2649  if (NULL == GST_peerinfo)
2650  {
2652  _ ("Could not access PEERINFO service. Exiting.\n"));
2654  return;
2655  }
2656 
2657  max_fd_rlimit = 0;
2658 #if HAVE_GETRLIMIT
2659  {
2660  struct rlimit r_file;
2661 
2662  if (0 == getrlimit (RLIMIT_NOFILE, &r_file))
2663  {
2664  max_fd_rlimit = r_file.rlim_cur;
2666  "Maximum number of open files was: %u/%u\n",
2667  (unsigned int) r_file.rlim_cur,
2668  (unsigned int) r_file.rlim_max);
2669  }
2670  max_fd_rlimit =
2671  (9 * max_fd_rlimit) / 10; /* Keep 10% for rest of transport */
2672  }
2673 #endif
2675  "transport",
2676  "MAX_FD",
2677  &max_fd_cfg))
2678  max_fd_cfg = max_fd_rlimit;
2679 
2680  if (max_fd_cfg > max_fd_rlimit)
2681  max_fd = max_fd_cfg;
2682  else
2683  max_fd = max_fd_rlimit;
2684  if (max_fd < DEFAULT_MAX_FDS)
2685  max_fd = DEFAULT_MAX_FDS;
2686 
2688  "Limiting number of sockets to %u: validation %u, neighbors: %u\n",
2689  max_fd,
2690  (max_fd / 3),
2691  (max_fd / 3) * 2);
2692 
2693  friend_only =
2694  GNUNET_CONFIGURATION_get_value_yesno (GST_cfg, "topology", "FRIENDS-ONLY");
2695  if (GNUNET_SYSERR == friend_only)
2696  friend_only = GNUNET_NO; /* According to topology defaults */
2697  /* start subsystems */
2698  /* Disable DSTJ peer */
2699  {
2700  struct GNUNET_PeerIdentity dstj;
2701  const char *ds = "DSTJBRRKZ8TBW3FGK6B0M5QXWT9WYNZ45H5MCV4HY7ST64Q8T9F0";
2702 
2703  GNUNET_assert (
2704  GNUNET_OK ==
2706  strlen (ds),
2707  &dstj.public_key));
2708  GST_blacklist_add_peer (&dstj, NULL);
2709  }
2713  GST_ats =
2715  GST_ats_init ();
2721  GST_hello_start (friend_only, &process_hello_update, NULL);
2722  GST_neighbours_start ((max_fd / 3) * 2);
2725  GST_validation_start ((max_fd / 3));
2726 }
static struct GNUNET_FS_DirScanner * ds
Handle to the directory scanner (for recursive insertions).
static void read_blacklist_configuration(const struct GNUNET_CONFIGURATION_Handle *cfg, const struct GNUNET_PeerIdentity *my_id)
Read blacklist configuration.
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 w...
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...
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...
static void shutdown_task(void *cls)
Function called when the service shuts down.
static void process_hello_update(void *cls, const struct GNUNET_MessageHeader *hello)
My HELLO has changed.
struct GNUNET_CRYPTO_EddsaPrivateKey GST_my_private_key
Our private key.
const struct GNUNET_CONFIGURATION_Handle * GST_cfg
Configuration handle.
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.
void GST_ats_init()
Initialize ATS subsystem.
void GST_hello_start(int friend_only, GST_HelloCallback cb, void *cb_cls)
Initialize the HELLO module.
void GST_manipulation_init()
Initialize traffic manipulation.
struct GNUNET_TIME_Relative GST_manipulation_recv(void *cls, const struct GNUNET_HELLO_Address *address, struct GNUNET_ATS_Session *session, const struct GNUNET_MessageHeader *message)
Adapter function between transport plugins and transport receive function manipulation delays for nex...
void GST_neighbours_start(unsigned int max_fds)
Initialize the neighbours subsystem.
void GST_plugins_load(GNUNET_TRANSPORT_PluginReceiveCallback recv_cb, GNUNET_TRANSPORT_AddressNotification address_cb, GNUNET_TRANSPORT_SessionStart session_start_cb, GNUNET_TRANSPORT_SessionEnd session_end_cb)
Load and initialize all plugins.
void GST_validation_start(unsigned int max_fds)
Start the validation subsystem.
struct GNUNET_ATS_SchedulingHandle * GNUNET_ATS_scheduling_init(const struct GNUNET_CONFIGURATION_Handle *cfg, GNUNET_ATS_AddressSuggestionCallback suggest_cb, void *suggest_cb_cls)
Initialize the ATS scheduling subsystem.
struct GNUNET_ATS_ConnectivityHandle * GNUNET_ATS_connectivity_init(const struct GNUNET_CONFIGURATION_Handle *cfg)
Initialize the ATS connectivity suggestion client handle.
enum GNUNET_GenericReturnValue GNUNET_CONFIGURATION_get_value_filename(const struct GNUNET_CONFIGURATION_Handle *cfg, const char *section, const char *option, char **value)
Get a configuration value that should be the name of a file or directory.
enum GNUNET_GenericReturnValue GNUNET_CONFIGURATION_get_value_number(const struct GNUNET_CONFIGURATION_Handle *cfg, const char *section, const char *option, unsigned long long *number)
Get a configuration value that should be a number.
enum GNUNET_GenericReturnValue GNUNET_CONFIGURATION_get_value_yesno(const struct GNUNET_CONFIGURATION_Handle *cfg, const char *section, const char *option)
Get a configuration value that should be in a set of "YES" or "NO".
enum GNUNET_GenericReturnValue GNUNET_CONFIGURATION_get_value_time(const struct GNUNET_CONFIGURATION_Handle *cfg, const char *section, const char *option, struct GNUNET_TIME_Relative *time)
Get a configuration value that should be a relative time.
#define GNUNET_CONSTANTS_HELLO_ADDRESS_EXPIRATION
After how long do we expire an address in a HELLO that we just validated? This value is also used for...
enum GNUNET_GenericReturnValue GNUNET_CRYPTO_eddsa_key_from_file(const char *filename, int do_create, struct GNUNET_CRYPTO_EddsaPrivateKey *pkey)
Create a new private key by reading it from a file.
void GNUNET_CRYPTO_eddsa_key_get_public(const struct GNUNET_CRYPTO_EddsaPrivateKey *priv, struct GNUNET_CRYPTO_EddsaPublicKey *pub)
Extract the public key for the given private key.
Definition: crypto_ecc.c:198
@ GNUNET_ERROR_TYPE_ERROR
struct GNUNET_NotificationContext * GNUNET_notification_context_create(unsigned int queue_length)
Create a new notification context.
Definition: nc.c:122
struct GNUNET_NT_InterfaceScanner * GNUNET_NT_scanner_init(void)
Initialize the address characterization client handle.
Definition: nt.c:406
struct GNUNET_PEERINFO_Handle * GNUNET_PEERINFO_connect(const struct GNUNET_CONFIGURATION_Handle *cfg)
Connect to the peerinfo service.
Definition: peerinfo_api.c:123
void GNUNET_SCHEDULER_shutdown(void)
Request the shutdown of a scheduler.
Definition: scheduler.c:562
struct GNUNET_SCHEDULER_Task * GNUNET_SCHEDULER_add_shutdown(GNUNET_SCHEDULER_TaskCallback task, void *task_cls)
Schedule a new task to be run on shutdown, that is when a CTRL-C signal is received,...
Definition: scheduler.c:1334
struct GNUNET_STATISTICS_Handle * GNUNET_STATISTICS_create(const char *subsystem, const struct GNUNET_CONFIGURATION_Handle *cfg)
Get handle for the statistics service.
struct GNUNET_CRYPTO_EddsaPublicKey public_key
#define DEFAULT_MAX_FDS
What's the maximum number of sockets transport uses for validation and neighbors.
Definition: transport.h:52

References _, active_stccs, ats_request_address_change(), DEFAULT_MAX_FDS, ds, GNUNET_assert, GNUNET_ATS_connectivity_init(), GNUNET_ATS_scheduling_init(), GNUNET_CONFIGURATION_get_value_filename(), GNUNET_CONFIGURATION_get_value_number(), GNUNET_CONFIGURATION_get_value_time(), GNUNET_CONFIGURATION_get_value_yesno(), GNUNET_CONSTANTS_HELLO_ADDRESS_EXPIRATION, GNUNET_CONTAINER_multipeermap_create(), GNUNET_CRYPTO_eddsa_key_from_file(), GNUNET_CRYPTO_eddsa_key_get_public(), GNUNET_CRYPTO_eddsa_public_key_from_string(), GNUNET_ERROR_TYPE_DEBUG, GNUNET_ERROR_TYPE_ERROR, GNUNET_ERROR_TYPE_INFO, GNUNET_free, GNUNET_i2s_full(), GNUNET_log, GNUNET_NO, GNUNET_notification_context_create(), GNUNET_NT_scanner_init(), GNUNET_OK, GNUNET_PEERINFO_connect(), GNUNET_SCHEDULER_add_shutdown(), GNUNET_SCHEDULER_shutdown(), GNUNET_STATISTICS_create(), GNUNET_SYSERR, GNUNET_YES, GST_ats, GST_ats_connect, GST_ats_init(), GST_blacklist_add_peer(), GST_cfg, GST_hello_start(), GST_is, GST_manipulation_init(), GST_manipulation_recv(), GST_my_identity, GST_my_private_key, GST_neighbours_start(), GST_peerinfo, GST_plugins_load(), GST_stats, GST_validation_start(), hello_expiration, plugin_env_address_change_notification(), plugin_env_session_end(), plugin_env_session_start(), plugin_nc, process_hello_update(), GNUNET_PeerIdentity::public_key, read_blacklist_configuration(), and shutdown_task().

Here is the call graph for this function:

◆ GNUNET_SERVICE_MAIN()

Variable Documentation

◆ clients_head

struct TransportClient* clients_head
static

Head of linked list of all clients to this service.

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

Referenced by client_connect_cb(), client_disconnect_cb(), GST_blacklist_test_allowed(), GST_clients_broadcast(), and GST_clients_broadcast_peer_notification().

◆ clients_tail

struct TransportClient* clients_tail
static

Tail of linked list of all clients to this service.

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

Referenced by client_connect_cb(), and client_disconnect_cb().

◆ active_stccs

struct GNUNET_CONTAINER_MultiPeerMap* active_stccs
static

Map of peer identities to active send transmit continuation contexts.

Used to flag contexts as 'dead' when a connection goes down. Values are of type struct SendTransmitContinuationContext *.

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

Referenced by client_disconnect_cb(), GST_clients_broadcast_disconnect(), handle_client_send(), handle_send_transmit_continuation(), run(), and shutdown_task().

◆ a2s_head

struct AddressToStringContext* a2s_head
static

Head of linked list of all pending address iterations.

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

Referenced by client_disconnect_cb(), handle_client_address_to_string(), shutdown_task(), and transmit_address_to_client().

◆ a2s_tail

struct AddressToStringContext* a2s_tail
static

Tail of linked list of all pending address iterations.

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

Referenced by handle_client_address_to_string(), shutdown_task(), and transmit_address_to_client().

◆ bc_head

◆ bc_tail

struct GST_BlacklistCheck* bc_tail
static

Tail of DLL of active blacklisting queries.

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

Referenced by GST_blacklist_test_allowed(), GST_blacklist_test_cancel(), handle_client_blacklist_reply(), and test_connection_ok().

◆ blacklist

struct GNUNET_CONTAINER_MultiPeerMap* blacklist
static

Hashmap of blacklisted peers.

Values are of type 'char *' (transport names), can be NULL if we have no static blacklist.

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

Referenced by GST_blacklist_add_peer(), GST_blacklist_test_allowed(), and shutdown_task().

◆ plugin_nc

struct GNUNET_NotificationContext* plugin_nc
static

Notification context, to send updates on changes to active plugin connections.

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

Referenced by handle_client_monitor_plugins(), plugin_session_info_cb(), run(), and shutdown_task().

◆ sync_client

struct TransportClient* sync_client
static

Plugin monitoring client we are currently syncing, NULL if all monitoring clients are in sync.

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

Referenced by handle_client_monitor_plugins(), and plugin_session_info_cb().

◆ all_zeros

struct GNUNET_PeerIdentity all_zeros
static

Peer identity that is all zeros, used as a way to indicate "all peers".

Used for comparisons.

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

Referenced by GST_clients_broadcast_peer_notification(), handle_client_monitor_peers(), handle_client_start_search(), and mac_test().

◆ GST_stats

◆ GST_cfg

const struct GNUNET_CONFIGURATION_Handle* GST_cfg

Configuration handle.

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

Referenced by run().

◆ GST_my_identity

struct GNUNET_PeerIdentity GST_my_identity

Configuration handle.

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

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

◆ GST_peerinfo

struct GNUNET_PEERINFO_Handle* GST_peerinfo

Handle to peerinfo service.

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

Referenced by GST_validation_handle_pong(), refresh_hello_task(), run(), and shutdown_task().

◆ GST_my_private_key

struct GNUNET_CRYPTO_EddsaPrivateKey GST_my_private_key

Our private key.

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

Referenced by run().

◆ GST_ats

struct GNUNET_ATS_SchedulingHandle* GST_ats

ATS scheduling handle.

ATS handle.

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

Referenced by GST_ats_add_address(), GST_ats_add_inbound_address(), run(), shutdown_task(), and unblock_address().

◆ GST_ats_connect

struct GNUNET_ATS_ConnectivityHandle* GST_ats_connect

ATS connectivity handle.

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

Referenced by run(), setup_neighbour(), and shutdown_task().

◆ hello_expiration

struct GNUNET_TIME_Relative hello_expiration

Hello address expiration.

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

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

◆ sk_head

struct GNUNET_ATS_SessionKiller* sk_head
static

Head of DLL of asynchronous tasks to kill sessions.

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

Referenced by kill_session(), kill_session_task(), and plugin_env_session_end().

◆ sk_tail

struct GNUNET_ATS_SessionKiller* sk_tail
static

Tail of DLL of asynchronous tasks to kill sessions.

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

Referenced by kill_session(), kill_session_task(), and plugin_env_session_end().

◆ GST_is

Interface scanner determines our LAN address range(s).

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

Referenced by run(), and shutdown_task().