GNUnet 0.28.1-dev.2-13-g57ceb9dfb
 
Loading...
Searching...
No Matches
gnunet-service-cadet.c File Reference

GNUnet CADET service with encryption. More...

Include dependency graph for gnunet-service-cadet.c:

Go to the source code of this file.

Data Structures

struct  CadetClient
 Struct containing information about a client of the service. More...
 

Macros

#define LOG(level, ...)   GNUNET_log (level, __VA_ARGS__)
 

Functions

void GSC_send_to_client (struct CadetClient *c, struct GNUNET_MQ_Envelope *env)
 Send a message to a client.
 
const char * GSC_2s (struct CadetClient *c)
 Return identifier for a client as a string.
 
static struct CadetChannellookup_channel (struct CadetClient *c, struct GNUNET_CADET_ClientChannelNumber ccn)
 Lookup channel of client c by ccn.
 
static struct GNUNET_CADET_ClientChannelNumber client_get_next_ccn (struct CadetClient *c)
 Obtain the next LID to use for incoming connections to the given client.
 
struct GNUNET_CADET_ClientChannelNumber GSC_bind (struct CadetClient *c, struct CadetChannel *ch, struct CadetPeer *dest, const struct GNUNET_HashCode *port, uint32_t options)
 Bind incoming channel to this client, and notify client about incoming connection.
 
static int destroy_tunnels_now (void *cls, const struct GNUNET_PeerIdentity *pid, void *value)
 Callback invoked on all peers to destroy all tunnels that may still exist.
 
static int destroy_paths_now (void *cls, const struct GNUNET_PeerIdentity *pid, void *value)
 Callback invoked on all peers to destroy all tunnels that may still exist.
 
static void shutdown_rest ()
 Shutdown everything once the clients have disconnected.
 
static void shutdown_task (void *cls)
 Task run during shutdown.
 
static int bind_loose_channel (void *cls, const struct GNUNET_HashCode *port, void *value)
 We had a remote connection value to port h_port before client cls opened port port.
 
static void handle_port_open (void *cls, const struct GNUNET_CADET_PortMessage *pmsg)
 Handle port open request.
 
static void handle_port_close (void *cls, const struct GNUNET_CADET_PortMessage *pmsg)
 Handler for port close requests.
 
static void handle_channel_create (void *cls, const struct GNUNET_CADET_LocalChannelCreateMessage *tcm)
 Handler for requests for us creating a new channel to another peer and port.
 
static void handle_channel_destroy (void *cls, const struct GNUNET_CADET_LocalChannelDestroyMessage *msg)
 Handler for requests of destroying an existing channel.
 
static int check_local_data (void *cls, const struct GNUNET_CADET_LocalData *msg)
 Check for client traffic data message is well-formed.
 
static void handle_local_data (void *cls, const struct GNUNET_CADET_LocalData *msg)
 Handler for client payload traffic to be send on a channel to another peer.
 
static void handle_local_ack (void *cls, const struct GNUNET_CADET_LocalAck *msg)
 Handler for client's ACKs for payload traffic.
 
static int get_all_peers_iterator (void *cls, const struct GNUNET_PeerIdentity *peer, void *value)
 Iterator over all peers to send a monitoring client info about each peer.
 
static void handle_get_peers (void *cls, const struct GNUNET_MessageHeader *message)
 Handler for client's INFO PEERS request.
 
static int path_info_iterator (void *cls, struct CadetPeerPath *path, unsigned int off)
 Iterator over all paths of a peer to build an InfoPeer message.
 
static void handle_show_path (void *cls, const struct GNUNET_CADET_RequestPathInfoMessage *msg)
 Handler for client's GNUNET_MESSAGE_TYPE_CADET_LOCAL_REQUEST_INFO_PATH request.
 
static int get_all_tunnels_iterator (void *cls, const struct GNUNET_PeerIdentity *peer, void *value)
 Iterator over all tunnels to send a monitoring client info about each tunnel.
 
static void handle_info_tunnels (void *cls, const struct GNUNET_MessageHeader *message)
 Handler for client's GNUNET_MESSAGE_TYPE_CADET_LOCAL_REQUEST_INFO_TUNNELS request.
 
static void handle_drop_message (void *cls, const struct GNUNET_CADET_RequestDropCadetMessage *message)
 Handler for client's GNUNET_MESSAGE_TYPE_CADET_DROP_CADET_MESSAGE request.
 
static void * client_connect_cb (void *cls, struct GNUNET_SERVICE_Client *client, struct GNUNET_MQ_Handle *mq)
 Callback called when a client connects to the service.
 
void GSC_handle_remote_channel_destroy (struct CadetClient *c, struct GNUNET_CADET_ClientChannelNumber ccn, struct CadetChannel *ch)
 A channel was destroyed by the other peer.
 
void GSC_drop_loose_channel (const struct GNUNET_HashCode *h_port, struct CadetChannel *ch)
 A client that created a loose channel that was not bound to a port disconnected, drop it from the loose_channels list.
 
static int channel_destroy_iterator (void *cls, uint32_t key, void *value)
 Iterator for deleting each channel whose client endpoint disconnected.
 
static int client_release_ports (void *cls, const struct GNUNET_HashCode *port, void *value)
 Remove client's ports from the global hashmap on disconnect.
 
static void client_disconnect_cb (void *cls, struct GNUNET_SERVICE_Client *client, void *internal_cls)
 Callback called when a client disconnected from the service.
 
static void run (void *cls, const struct GNUNET_CONFIGURATION_Handle *c, struct GNUNET_SERVICE_Handle *service)
 Setup CADET internals.
 
 GNUNET_SERVICE_MAIN (GNUNET_OS_project_data_gnunet(), "cadet", GNUNET_SERVICE_OPTION_NONE, &run, &client_connect_cb, &client_disconnect_cb, NULL, GNUNET_MQ_hd_fixed_size(port_open, GNUNET_MESSAGE_TYPE_CADET_LOCAL_PORT_OPEN, struct GNUNET_CADET_PortMessage, NULL), GNUNET_MQ_hd_fixed_size(port_close, GNUNET_MESSAGE_TYPE_CADET_LOCAL_PORT_CLOSE, struct GNUNET_CADET_PortMessage, NULL), GNUNET_MQ_hd_fixed_size(channel_create, GNUNET_MESSAGE_TYPE_CADET_LOCAL_CHANNEL_CREATE, struct GNUNET_CADET_LocalChannelCreateMessage, NULL), GNUNET_MQ_hd_fixed_size(channel_destroy, GNUNET_MESSAGE_TYPE_CADET_LOCAL_CHANNEL_DESTROY, struct GNUNET_CADET_LocalChannelDestroyMessage, NULL), GNUNET_MQ_hd_var_size(local_data, GNUNET_MESSAGE_TYPE_CADET_LOCAL_DATA, struct GNUNET_CADET_LocalData, NULL), GNUNET_MQ_hd_fixed_size(local_ack, GNUNET_MESSAGE_TYPE_CADET_LOCAL_ACK, struct GNUNET_CADET_LocalAck, NULL), GNUNET_MQ_hd_fixed_size(get_peers, GNUNET_MESSAGE_TYPE_CADET_LOCAL_REQUEST_INFO_PEERS, struct GNUNET_MessageHeader, NULL), GNUNET_MQ_hd_fixed_size(show_path, GNUNET_MESSAGE_TYPE_CADET_LOCAL_REQUEST_INFO_PATH, struct GNUNET_CADET_RequestPathInfoMessage, NULL), GNUNET_MQ_hd_fixed_size(info_tunnels, GNUNET_MESSAGE_TYPE_CADET_LOCAL_REQUEST_INFO_TUNNELS, struct GNUNET_MessageHeader, NULL), GNUNET_MQ_hd_fixed_size(drop_message, GNUNET_MESSAGE_TYPE_CADET_DROP_CADET_MESSAGE, struct GNUNET_CADET_RequestDropCadetMessage, NULL), GNUNET_MQ_handler_end())
 Define "main" method using service macro.
 

Variables

const struct GNUNET_CONFIGURATION_Handlecfg
 Handle to our configuration.
 
struct GNUNET_STATISTICS_Handlestats
 Handle to the statistics service.
 
struct GNUNET_TRANSPORT_ApplicationHandletransport
 Handle to Transport service.
 
struct GNUNET_PILS_Handlepils
 Handle to the pils service.
 
int shutting_down
 Signal that shutdown is happening: prevent recovery measures.
 
static struct CadetClientclients_head
 DLL with all the clients, head.
 
static struct CadetClientclients_tail
 DLL with all the clients, tail.
 
static unsigned int next_client_id
 Next ID to assign to a client.
 
struct GNUNET_CONTAINER_MultiHashMapopen_ports
 All ports clients of this peer have opened.
 
struct GNUNET_CONTAINER_MultiHashMaploose_channels
 Map from ports to channels where the ports were closed at the time we got the inbound connection.
 
struct GNUNET_CONTAINER_MultiPeerMappeers
 Map from PIDs to struct CadetPeer entries.
 
struct GNUNET_CONTAINER_MultiShortmapconnections
 Map from struct GNUNET_CADET_ConnectionTunnelIdentifier hash codes to struct CadetConnection objects.
 
unsigned long long ratchet_messages
 How many messages are needed to trigger an AXOLOTL ratchet advance.
 
struct GNUNET_TIME_Relative ratchet_time
 How long until we trigger a ratched advance due to time.
 
struct GNUNET_TIME_Relative keepalive_period
 How frequently do we send KEEPALIVE messages on idle connections?
 
unsigned long long drop_percent
 Set to non-zero values to create random drops to test retransmissions.
 

Detailed Description

GNUnet CADET service with encryption.

Author
Bartlomiej Polot
Christian Grothoff

Dictionary:

  • peer: other cadet instance. If there is direct connection it's a neighbor.
  • path: series of directly connected peer from one peer to another.
  • connection: path which is being used in a tunnel.
  • tunnel: encrypted connection to a peer, neighbor or not.
  • channel: logical link between two clients, on the same or different peers. have properties like reliability.

Definition in file gnunet-service-cadet.c.

Macro Definition Documentation

◆ LOG

#define LOG (   level,
  ... 
)    GNUNET_log (level, __VA_ARGS__)

Definition at line 52 of file gnunet-service-cadet.c.

Function Documentation

◆ GSC_send_to_client()

void GSC_send_to_client ( struct CadetClient c,
struct GNUNET_MQ_Envelope env 
)

Send a message to a client.

Parameters
cclient to get the message
envenvelope with the message

Definition at line 203 of file gnunet-service-cadet.c.

205{
206 GNUNET_MQ_send (c->mq,
207 env);
208}
struct GNUNET_MQ_Envelope * env
Definition 005.c:1
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:337
struct GNUNET_MQ_Handle * mq
Handle to communicate with the client.

References env, GNUNET_MQ_send(), and CadetClient::mq.

Referenced by GCCH_handle_channel_plaintext_data(), GCCH_handle_local_ack(), GCCH_handle_local_data(), GSC_bind(), GSC_handle_remote_channel_destroy(), and send_ack_to_client().

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

◆ GSC_2s()

const char * GSC_2s ( struct CadetClient c)

Return identifier for a client as a string.

Parameters
cclient to identify
Returns
string for debugging

Definition at line 218 of file gnunet-service-cadet.c.

219{
220 static char buf[32];
221
222 GNUNET_snprintf (buf,
223 sizeof(buf),
224 "Client(%u)",
225 c->id);
226 return buf;
227}
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.
unsigned int id
ID of the client, mainly for debug messages.

References GNUNET_snprintf(), and CadetClient::id.

Referenced by channel_destroy_iterator(), client_connect_cb(), client_disconnect_cb(), client_release_ports(), GCCH_bind(), GCCH_channel_local_destroy(), GCCH_channel_local_new(), GCCH_debug(), GCCH_handle_channel_plaintext_data(), GCCH_handle_local_ack(), handle_channel_create(), handle_channel_destroy(), handle_local_ack(), handle_local_data(), handle_port_close(), handle_port_open(), and send_ack_to_client().

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

◆ lookup_channel()

static struct CadetChannel * lookup_channel ( struct CadetClient c,
struct GNUNET_CADET_ClientChannelNumber  ccn 
)
static

Lookup channel of client c by ccn.

Parameters
cclient to look in
ccnchannel ID to look up
Returns
NULL if no such channel exists

Definition at line 238 of file gnunet-service-cadet.c.

240{
242 ntohl (ccn.channel_of_client));
243}
void * GNUNET_CONTAINER_multihashmap32_get(const struct GNUNET_CONTAINER_MultiHashMap32 *map, uint32_t key)
Given a key find a value in the map matching the key.
struct GNUNET_CONTAINER_MultiHashMap32 * channels
Tunnels that belong to this client, indexed by local id, value is a struct CadetChannel.
uint32_t channel_of_client
Values for channel numbering.
Definition cadet.h:109

References GNUNET_CADET_ClientChannelNumber::channel_of_client, CadetClient::channels, and GNUNET_CONTAINER_multihashmap32_get().

Referenced by client_get_next_ccn(), handle_channel_create(), handle_channel_destroy(), handle_drop_message(), handle_local_ack(), and handle_local_data().

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

◆ client_get_next_ccn()

static struct GNUNET_CADET_ClientChannelNumber client_get_next_ccn ( struct CadetClient c)
static

Obtain the next LID to use for incoming connections to the given client.

Parameters
cclient handle

Definition at line 253 of file gnunet-service-cadet.c.

254{
256
257 /* increment until we have a free one... */
258 while (NULL !=
260 ccn))
261 {
263 = htonl (1 + (ntohl (ccn.channel_of_client)));
264 if (ntohl (ccn.channel_of_client) >=
266 ccn.channel_of_client = htonl (0);
267 }
269 = htonl (1 + (ntohl (ccn.channel_of_client)));
270 return ccn;
271}
#define GNUNET_CADET_LOCAL_CHANNEL_ID_CLI
Minimum value for channel IDs of local clients.
Definition cadet.h:70
static struct CadetChannel * lookup_channel(struct CadetClient *c, struct GNUNET_CADET_ClientChannelNumber ccn)
Lookup channel of client c by ccn.
struct GNUNET_CADET_ClientChannelNumber next_ccn
Channel ID to use for the next incoming channel for this client.
Number uniquely identifying a channel of a client.
Definition cadet.h:101

References GNUNET_CADET_ClientChannelNumber::channel_of_client, GNUNET_CADET_LOCAL_CHANNEL_ID_CLI, and lookup_channel().

Referenced by GSC_bind().

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

◆ GSC_bind()

struct GNUNET_CADET_ClientChannelNumber GSC_bind ( struct CadetClient c,
struct CadetChannel ch,
struct CadetPeer dest,
const struct GNUNET_HashCode port,
uint32_t  options 
)

Bind incoming channel to this client, and notify client about incoming connection.

Caller is responsible for notifying the other peer about our acceptance of the channel.

Parameters
cclient to bind to
chchannel to be bound
destpeer that establishes the connection
portport number
optionsoptions
Returns
local channel number assigned to the new client

Definition at line 287 of file gnunet-service-cadet.c.

292{
293 struct GNUNET_MQ_Envelope *env;
296
297 ccn = client_get_next_ccn (c);
300 ntohl (
301 ccn.channel_of_client),
302 ch,
305 "Accepting incoming %s from %s on open port %s (%u), assigning ccn %X\n",
306 GCCH_2s (ch),
307 GCP_2s (dest),
309 (uint32_t) ntohl (options),
310 (uint32_t) ntohl (ccn.channel_of_client));
311 /* notify local client about incoming connection! */
312 env = GNUNET_MQ_msg (cm,
314 cm->ccn = ccn;
315 cm->port = *port;
316 cm->opt = htonl (options);
317 cm->peer = *GCP_get_id (dest);
319 env);
320 return ccn;
321}
struct GNUNET_GETOPT_CommandLineOption options[]
Definition 002.c:5
static uint16_t port
Port number.
Definition gnunet-bcd.c:146
static struct GNUNET_CADET_Channel * ch
Channel handle.
void GSC_send_to_client(struct CadetClient *c, struct GNUNET_MQ_Envelope *env)
Send a message to a client.
#define LOG(level,...)
static struct GNUNET_CADET_ClientChannelNumber client_get_next_ccn(struct CadetClient *c)
Obtain the next LID to use for incoming connections to the given client.
const char * GCCH_2s(const struct CadetChannel *ch)
Get the static string for identification of the channel.
const struct GNUNET_PeerIdentity * GCP_get_id(struct CadetPeer *cp)
Obtain the peer identity for a struct CadetPeer.
const char * GCP_2s(const struct CadetPeer *cp)
Get the static string for a peer ID.
enum GNUNET_GenericReturnValue GNUNET_CONTAINER_multihashmap32_put(struct GNUNET_CONTAINER_MultiHashMap32 *map, uint32_t key, void *value, enum GNUNET_CONTAINER_MultiHashMapOption opt)
Store a key-value pair in the map.
@ GNUNET_CONTAINER_MULTIHASHMAPOPTION_UNIQUE_ONLY
There must only be one value per key; storing a value should fail if a value under the same key alrea...
@ GNUNET_YES
#define GNUNET_assert(cond)
Use this for fatal errors that cannot be handled.
const char * GNUNET_h2s(const struct GNUNET_HashCode *hc)
Convert a hash value to a string (for printing debug messages).
@ GNUNET_ERROR_TYPE_DEBUG
#define GNUNET_MQ_msg(mvar, type)
Allocate a GNUNET_MQ_Envelope.
#define GNUNET_MESSAGE_TYPE_CADET_LOCAL_CHANNEL_CREATE
Ask the cadet service to create a new channel.
Message for a client to create channels.
Definition cadet.h:201
struct GNUNET_PeerIdentity peer
Channel's peer.
Definition cadet.h:217
struct GNUNET_CADET_ClientChannelNumber ccn
ID of a channel controlled by this client.
Definition cadet.h:212
struct GNUNET_HashCode port
Port of the channel.
Definition cadet.h:222

References GNUNET_CADET_LocalChannelCreateMessage::ccn, ch, GNUNET_CADET_ClientChannelNumber::channel_of_client, client_get_next_ccn(), env, GCCH_2s(), GCP_2s(), GCP_get_id(), GNUNET_assert, GNUNET_CONTAINER_multihashmap32_put(), GNUNET_CONTAINER_MULTIHASHMAPOPTION_UNIQUE_ONLY, GNUNET_ERROR_TYPE_DEBUG, GNUNET_h2s(), GNUNET_MESSAGE_TYPE_CADET_LOCAL_CHANNEL_CREATE, GNUNET_MQ_msg, GNUNET_YES, GSC_send_to_client(), LOG, GNUNET_CADET_LocalChannelCreateMessage::opt, options, GNUNET_CADET_LocalChannelCreateMessage::peer, GNUNET_CADET_LocalChannelCreateMessage::port, and port.

Referenced by GCCH_bind().

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

◆ destroy_tunnels_now()

static int destroy_tunnels_now ( void *  cls,
const struct GNUNET_PeerIdentity pid,
void *  value 
)
static

Callback invoked on all peers to destroy all tunnels that may still exist.

Parameters
clsNULL
pididentify of a peer
valuea struct CadetPeer that may still have a tunnel
Returns
GNUNET_OK (iterate over all entries)

Definition at line 334 of file gnunet-service-cadet.c.

337{
338 struct CadetPeer *cp = value;
339 struct CadetTunnel *t = GCP_get_tunnel (cp,
340 GNUNET_NO);
341
342 if (NULL != t)
344 return GNUNET_OK;
345}
static struct GNUNET_SCHEDULER_Task * t
Main task.
static char * value
Value of the record to add/remove.
struct CadetTunnel * GCP_get_tunnel(struct CadetPeer *cp, int create)
Get the tunnel towards a peer.
void GCT_destroy_tunnel_now(struct CadetTunnel *t)
Destroys the tunnel t now, without delay.
@ GNUNET_OK
@ GNUNET_NO
Struct containing all information regarding a given peer.
Struct containing all information regarding a tunnel to a peer.

References GCP_get_tunnel(), GCT_destroy_tunnel_now(), GNUNET_NO, GNUNET_OK, t, and value.

Referenced by shutdown_rest().

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

◆ destroy_paths_now()

static int destroy_paths_now ( void *  cls,
const struct GNUNET_PeerIdentity pid,
void *  value 
)
static

Callback invoked on all peers to destroy all tunnels that may still exist.

Parameters
clsNULL
pididentify of a peer
valuea struct CadetPeer that may still have a tunnel
Returns
GNUNET_OK (iterate over all entries)

Definition at line 358 of file gnunet-service-cadet.c.

361{
362 struct CadetPeer *cp = value;
363
365 return GNUNET_OK;
366}
void GCP_drop_owned_paths(struct CadetPeer *cp)
Drop all paths owned by this peer, and do not allow new ones to be added: We are shutting down.

References GCP_drop_owned_paths(), GNUNET_OK, and value.

Referenced by shutdown_rest().

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

◆ shutdown_rest()

static void shutdown_rest ( )
static

Shutdown everything once the clients have disconnected.

Definition at line 373 of file gnunet-service-cadet.c.

374{
375 if (NULL != stats)
376 {
378 GNUNET_NO);
379 stats = NULL;
380 }
381 /* Destroy tunnels. Note that all channels must be destroyed first! */
383 NULL);
384 /* All tunnels, channels, connections and CORE must be down before this point. */
386 NULL);
387 /* All paths, tunnels, channels, connections and CORE must be down before this point. */
389 if (NULL != open_ports)
390 {
392 open_ports = NULL;
393 }
394 if (NULL != loose_channels)
395 {
397 loose_channels = NULL;
398 }
399 if (NULL != peers)
400 {
402 peers = NULL;
403 }
404 if (NULL != connections)
405 {
407 connections = NULL;
408 }
409 if (NULL != transport)
410 {
412 transport = NULL;
413 }
414 GCD_shutdown ();
415 GCH_shutdown ();
416}
struct GNUNET_CONTAINER_MultiPeerMap * peers
Map from PIDs to struct CadetPeer entries.
struct GNUNET_CONTAINER_MultiShortmap * connections
Map from struct GNUNET_CADET_ConnectionTunnelIdentifier hash codes to struct CadetConnection objects.
struct GNUNET_STATISTICS_Handle * stats
Handle to the statistics service.
static int destroy_paths_now(void *cls, const struct GNUNET_PeerIdentity *pid, void *value)
Callback invoked on all peers to destroy all tunnels that may still exist.
struct GNUNET_TRANSPORT_ApplicationHandle * transport
Handle to Transport service.
struct GNUNET_CONTAINER_MultiHashMap * open_ports
All ports clients of this peer have opened.
struct GNUNET_CONTAINER_MultiHashMap * loose_channels
Map from ports to channels where the ports were closed at the time we got the inbound connection.
static int destroy_tunnels_now(void *cls, const struct GNUNET_PeerIdentity *pid, void *value)
Callback invoked on all peers to destroy all tunnels that may still exist.
void GCD_shutdown(void)
Shut down the DHT subsystem.
void GCH_shutdown()
Shut down the hello subsystem.
void GCP_destroy_all_peers()
Clean up all entries about all peers.
void GCP_iterate_all(GNUNET_CONTAINER_PeerMapIterator iter, void *cls)
Iterate over all known peers.
void GNUNET_TRANSPORT_application_done(struct GNUNET_TRANSPORT_ApplicationHandle *ch)
Shutdown TRANSPORT application client.
void GNUNET_CONTAINER_multipeermap_destroy(struct GNUNET_CONTAINER_MultiPeerMap *map)
Destroy a hash map.
void GNUNET_CONTAINER_multihashmap_destroy(struct GNUNET_CONTAINER_MultiHashMap *map)
Destroy a hash map.
void GNUNET_CONTAINER_multishortmap_destroy(struct GNUNET_CONTAINER_MultiShortmap *map)
Destroy a hash map.
void GNUNET_STATISTICS_destroy(struct GNUNET_STATISTICS_Handle *h, int sync_first)
Destroy a handle (free all state associated with it).

References connections, destroy_paths_now(), destroy_tunnels_now(), GCD_shutdown(), GCH_shutdown(), GCP_destroy_all_peers(), GCP_iterate_all(), GNUNET_CONTAINER_multihashmap_destroy(), GNUNET_CONTAINER_multipeermap_destroy(), GNUNET_CONTAINER_multishortmap_destroy(), GNUNET_NO, GNUNET_STATISTICS_destroy(), GNUNET_TRANSPORT_application_done(), loose_channels, open_ports, peers, stats, and transport.

Referenced by client_disconnect_cb(), and shutdown_task().

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

◆ shutdown_task()

static void shutdown_task ( void *  cls)
static

Task run during shutdown.

Parameters
clsunused

Definition at line 425 of file gnunet-service-cadet.c.

426{
428 "Shutting down\n");
430 GCO_shutdown ();
431 if (NULL == clients_head)
432 shutdown_rest ();
433}
int shutting_down
Signal that shutdown is happening: prevent recovery measures.
static void shutdown_rest()
Shutdown everything once the clients have disconnected.
static struct CadetClient * clients_head
DLL with all the clients, head.
void GCO_shutdown()
Shut down the CORE subsystem.
#define GNUNET_log(kind,...)

References clients_head, GCO_shutdown(), GNUNET_ERROR_TYPE_DEBUG, GNUNET_log, GNUNET_YES, shutdown_rest(), and shutting_down.

Here is the call graph for this function:

◆ bind_loose_channel()

static int bind_loose_channel ( void *  cls,
const struct GNUNET_HashCode port,
void *  value 
)
static

We had a remote connection value to port h_port before client cls opened port port.

Bind them now.

Parameters
clsthe struct CadetClient
portthe hashed port
valuethe struct CadetChannel
Returns
GNUNET_YES (iterate over all such channels)

Definition at line 446 of file gnunet-service-cadet.c.

449{
450 struct OpenPort *op = cls;
451 struct CadetChannel *ch = value;
452
453 GCCH_bind (ch,
454 op->c,
455 &op->port);
458 &op->h_port,
459 ch));
460 return GNUNET_YES;
461}
static struct GNUNET_ARM_Operation * op
Current operation.
Definition gnunet-arm.c:143
void GCCH_bind(struct CadetChannel *ch, struct CadetClient *c, const struct GNUNET_HashCode *port)
A client is bound to the port that we have a channel open to.
enum GNUNET_GenericReturnValue GNUNET_CONTAINER_multihashmap_remove(struct GNUNET_CONTAINER_MultiHashMap *map, const struct GNUNET_HashCode *key, const void *value)
Remove the given key-value pair from the map.
Struct containing all information regarding a channel to a remote client.
Port opened by a client.

References ch, GCCH_bind(), GNUNET_assert, GNUNET_CONTAINER_multihashmap_remove(), GNUNET_YES, loose_channels, op, and value.

Referenced by handle_port_open().

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

◆ handle_port_open()

static void handle_port_open ( void *  cls,
const struct GNUNET_CADET_PortMessage pmsg 
)
static

Handle port open request.

Creates a mapping from the port to the respective client and checks whether we have loose channels trying to bind to the port. If so, those are bound.

Parameters
clsIdentification of the client.
pmsgThe actual message.

Definition at line 474 of file gnunet-service-cadet.c.

476{
477 const struct GNUNET_PeerIdentity *my_identity;
478 struct CadetClient *c = cls;
479 struct OpenPort *op;
480
482 "Open port %s requested by %s\n",
483 GNUNET_h2s (&pmsg->port),
484 GSC_2s (c));
485
487 if (! my_identity)
488 {
489 /* PILS has not delivered our peer identity yet -- #GCH_init() only
490 *starts* the connection, so there is a window right after startup in
491 which we are already accepting clients but cannot compute @e h_port.
492
493 This used to `return' here, which called neither
494 #GNUNET_SERVICE_client_continue() nor #GNUNET_SERVICE_client_drop().
495 The service framework then never reads another message from that
496 client, for the lifetime of the process: it just logs "Processing code
497 for message of type 1022 did not call `GNUNET_SERVICE_client_continue'"
498 once a minute, forever. The port was silently never opened either, so
499 the application waits for incoming channels that cannot arrive, and a
500 later #GNUNET_MESSAGE_TYPE_CADET_LOCAL_PORT_CLOSE for it trips the
501 GNUNET_break(0) in #handle_port_close().
502
503 Dropping the client is recoverable and honest: the port really was not
504 opened, and #reconnect_cbk() in cadet_api.c re-opens every port the
505 client holds after a GNUNET_TIME_STD_BACKOFF delay, by which time PILS
506 will have answered. */
508 "Cannot open port for %s yet: no peer identity from PILS. "
509 "Dropping the client so that it retries.\n",
510 GSC_2s (c));
512 return;
513 }
514
515 if (NULL == c->ports)
517 GNUNET_NO);
518 op = GNUNET_new (struct OpenPort);
519 op->c = c;
520 op->port = pmsg->port;
521 GCCH_hash_port (&op->h_port,
522 &pmsg->port,
524 if (GNUNET_OK !=
526 &op->port,
527 op,
529 {
530 GNUNET_break (0);
532 return;
533 }
535 &op->h_port,
536 op,
539 &op->h_port,
541 op);
543}
static int bind_loose_channel(void *cls, const struct GNUNET_HashCode *port, void *value)
We had a remote connection value to port h_port before client cls opened port port.
struct GNUNET_PILS_Handle * pils
Handle to the pils service.
const char * GSC_2s(struct CadetClient *c)
Return identifier for a client as a string.
void GCCH_hash_port(struct GNUNET_HashCode *h_port, const struct GNUNET_HashCode *port, const struct GNUNET_PeerIdentity *listener)
Hash the port and initiator and listener to calculate the "challenge" h_port we send to the other pee...
static struct GNUNET_PeerIdentity my_identity
Identity of this peer.
const struct GNUNET_PeerIdentity * GNUNET_PILS_get_identity(const struct GNUNET_PILS_Handle *handle)
Return the current peer identity of a given handle.
Definition pils_api.c:875
enum GNUNET_GenericReturnValue GNUNET_CONTAINER_multihashmap_put(struct GNUNET_CONTAINER_MultiHashMap *map, const struct GNUNET_HashCode *key, void *value, enum GNUNET_CONTAINER_MultiHashMapOption opt)
Store a key-value pair in the map.
struct GNUNET_CONTAINER_MultiHashMap * GNUNET_CONTAINER_multihashmap_create(unsigned int len, int do_not_copy_keys)
Create a multi hash map.
enum GNUNET_GenericReturnValue GNUNET_CONTAINER_multihashmap_get_multiple(struct GNUNET_CONTAINER_MultiHashMap *map, const struct GNUNET_HashCode *key, GNUNET_CONTAINER_MultiHashMapIteratorCallback it, void *it_cls)
Iterate over all entries in the map that match a particular key.
@ GNUNET_CONTAINER_MULTIHASHMAPOPTION_MULTIPLE
Allow multiple values with the same key.
#define GNUNET_break(cond)
Use this for internal assertion violations that are not fatal (can be handled) but should not occur.
@ GNUNET_ERROR_TYPE_WARNING
#define GNUNET_new(type)
Allocate a struct or union of the given type.
void GNUNET_SERVICE_client_drop(struct GNUNET_SERVICE_Client *c)
Ask the server to disconnect from the given client.
Definition service.c:2463
void GNUNET_SERVICE_client_continue(struct GNUNET_SERVICE_Client *c)
Continue receiving further messages from the given client.
Definition service.c:2434
Struct containing information about a client of the service.
struct GNUNET_SERVICE_Client * client
Client handle.
struct GNUNET_CONTAINER_MultiHashMap * ports
Ports that this client has declared interest in.
struct GNUNET_HashCode port
Port to open/close.
Definition cadet.h:193
The identity of the host (wraps the signing key of the peer).
struct CadetClient * c
Client that opened the port.

References bind_loose_channel(), OpenPort::c, CadetClient::client, GCCH_hash_port(), GNUNET_break, GNUNET_CONTAINER_multihashmap_create(), GNUNET_CONTAINER_multihashmap_get_multiple(), GNUNET_CONTAINER_multihashmap_put(), GNUNET_CONTAINER_MULTIHASHMAPOPTION_MULTIPLE, GNUNET_CONTAINER_MULTIHASHMAPOPTION_UNIQUE_ONLY, GNUNET_ERROR_TYPE_DEBUG, GNUNET_ERROR_TYPE_WARNING, GNUNET_h2s(), GNUNET_log, GNUNET_new, GNUNET_NO, GNUNET_OK, GNUNET_PILS_get_identity(), GNUNET_SERVICE_client_continue(), GNUNET_SERVICE_client_drop(), GSC_2s(), LOG, loose_channels, my_identity, op, open_ports, pils, GNUNET_CADET_PortMessage::port, and CadetClient::ports.

Here is the call graph for this function:

◆ handle_port_close()

static void handle_port_close ( void *  cls,
const struct GNUNET_CADET_PortMessage pmsg 
)
static

Handler for port close requests.

Marks this port as closed (unless of course we have another client with the same port open). Note that existing channels accepted on the port are not affected.

Parameters
clsIdentification of the client.
pmsgThe actual message.

Definition at line 556 of file gnunet-service-cadet.c.

558{
559 struct CadetClient *c = cls;
560 struct OpenPort *op;
561
563 "Closing port %s as requested by %s\n",
564 GNUNET_h2s (&pmsg->port),
565 GSC_2s (c));
566 if (NULL == c->ports)
567 {
568 /* Client closed a port despite _never_ having opened one? */
569 GNUNET_break (0);
571 return;
572 }
574 &pmsg->port);
575 if (NULL == op)
576 {
577 GNUNET_break (0);
579 return;
580 }
583 &op->port,
584 op));
587 &op->h_port,
588 op));
589 GNUNET_free (op);
591}
void * GNUNET_CONTAINER_multihashmap_get(const struct GNUNET_CONTAINER_MultiHashMap *map, const struct GNUNET_HashCode *key)
Given a key find a value in the map matching the key.
#define GNUNET_free(ptr)
Wrapper around free.

References OpenPort::c, CadetClient::client, GNUNET_assert, GNUNET_break, GNUNET_CONTAINER_multihashmap_get(), GNUNET_CONTAINER_multihashmap_remove(), GNUNET_ERROR_TYPE_DEBUG, GNUNET_free, GNUNET_h2s(), GNUNET_SERVICE_client_continue(), GNUNET_SERVICE_client_drop(), GNUNET_YES, GSC_2s(), LOG, op, open_ports, GNUNET_CADET_PortMessage::port, and CadetClient::ports.

Here is the call graph for this function:

◆ handle_channel_create()

static void handle_channel_create ( void *  cls,
const struct GNUNET_CADET_LocalChannelCreateMessage tcm 
)
static

Handler for requests for us creating a new channel to another peer and port.

Parameters
clsIdentification of the client.
tcmThe actual message.

Definition at line 601 of file gnunet-service-cadet.c.

603{
604 struct CadetClient *c = cls;
605 struct CadetChannel *ch;
606
608 {
609 /* Channel ID not in allowed range. */
610 LOG (GNUNET_ERROR_TYPE_DEBUG,"Channel ID not in allowed range.");
611 GNUNET_break (0);
613 return;
614 }
615 ch = lookup_channel (c,
616 tcm->ccn);
617 if (NULL != ch)
618 {
619 /* Channel ID already in use. Not allowed. */
620 LOG (GNUNET_ERROR_TYPE_DEBUG,"Channel ID already in use. Not allowed.");
621 GNUNET_break (0);
623 return;
624 }
626 "New channel to %s at port %s requested by %s\n",
627 GNUNET_i2s (&tcm->peer),
628 GNUNET_h2s (&tcm->port),
629 GSC_2s (c));
630
631 /* Create channel */
633 tcm->ccn,
634 GCP_get (&tcm->peer,
635 GNUNET_YES),
636 &tcm->port,
637 ntohl (tcm->opt));
638 if (NULL == ch)
639 {
640 GNUNET_break (0);
642 return;
643 }
646 ntohl (
647 tcm->ccn.
648 channel_of_client),
649 ch,
651
653}
struct CadetChannel * GCCH_channel_local_new(struct CadetClient *owner, struct GNUNET_CADET_ClientChannelNumber ccn, struct CadetPeer *destination, const struct GNUNET_HashCode *port, uint32_t options)
Create a new channel.
struct CadetPeer * GCP_get(const struct GNUNET_PeerIdentity *peer_id, int create)
Retrieve the CadetPeer structure associated with the peer.
const char * GNUNET_i2s(const struct GNUNET_PeerIdentity *pid)
Convert a peer identity to a string (for printing debug messages).

References GNUNET_CADET_LocalChannelCreateMessage::ccn, ch, GNUNET_CADET_ClientChannelNumber::channel_of_client, CadetClient::channels, CadetClient::client, GCCH_channel_local_new(), GCP_get(), GNUNET_assert, GNUNET_break, GNUNET_CADET_LOCAL_CHANNEL_ID_CLI, GNUNET_CONTAINER_multihashmap32_put(), GNUNET_CONTAINER_MULTIHASHMAPOPTION_UNIQUE_ONLY, GNUNET_ERROR_TYPE_DEBUG, GNUNET_h2s(), GNUNET_i2s(), GNUNET_SERVICE_client_continue(), GNUNET_SERVICE_client_drop(), GNUNET_YES, GSC_2s(), LOG, lookup_channel(), GNUNET_CADET_LocalChannelCreateMessage::opt, GNUNET_CADET_LocalChannelCreateMessage::peer, and GNUNET_CADET_LocalChannelCreateMessage::port.

Here is the call graph for this function:

◆ handle_channel_destroy()

static void handle_channel_destroy ( void *  cls,
const struct GNUNET_CADET_LocalChannelDestroyMessage msg 
)
static

Handler for requests of destroying an existing channel.

Parameters
clsclient identification of the client
msgthe actual message

Definition at line 663 of file gnunet-service-cadet.c.

666{
667 struct CadetClient *c = cls;
668 struct CadetChannel *ch;
669
670 ch = lookup_channel (c,
671 msg->ccn);
672 if (NULL == ch)
673 {
674 /* Client attempted to destroy unknown channel.
675 Can happen if the other side went down at the same time.*/
677 "%s tried to destroy unknown channel %X\n",
678 GSC_2s (c),
679 (uint32_t) ntohl (msg->ccn.channel_of_client));
681 return;
682 }
684 "%s is destroying %s\n",
685 GSC_2s (c),
686 GCCH_2s (ch));
689 ntohl (
690 msg->ccn.
691 channel_of_client),
692 ch));
694 c,
695 msg->ccn);
697}
struct GNUNET_MessageHeader * msg
Definition 005.c:2
void GCCH_channel_local_destroy(struct CadetChannel *ch, struct CadetClient *c, struct GNUNET_CADET_ClientChannelNumber ccn)
Destroy locally created channel.
enum GNUNET_GenericReturnValue GNUNET_CONTAINER_multihashmap32_remove(struct GNUNET_CONTAINER_MultiHashMap32 *map, uint32_t key, const void *value)
Remove the given key-value pair from the map.

References ch, CadetClient::channels, CadetClient::client, GCCH_2s(), GCCH_channel_local_destroy(), GNUNET_assert, GNUNET_CONTAINER_multihashmap32_remove(), GNUNET_ERROR_TYPE_DEBUG, GNUNET_SERVICE_client_continue(), GNUNET_YES, GSC_2s(), LOG, lookup_channel(), and msg.

Here is the call graph for this function:

◆ check_local_data()

static int check_local_data ( void *  cls,
const struct GNUNET_CADET_LocalData msg 
)
static

Check for client traffic data message is well-formed.

Parameters
clsidentification of the client
msgthe actual message
Returns
GNUNET_OK if msg is OK, GNUNET_SYSERR if not

Definition at line 708 of file gnunet-service-cadet.c.

710{
711 size_t payload_size;
712 size_t payload_claimed_size;
713 const char *buf;
714 struct GNUNET_MessageHeader pa;
715
716 /* FIXME: what is the format we shall allow for @a msg?
717 ONE payload item or multiple? Seems current cadet_api
718 at least in theory allows more than one. Next-gen
719 cadet_api will likely no more, so we could then
720 simplify this mess again. *//* Sanity check for message size */payload_size = ntohs (msg->header.size) - sizeof(*msg);
721 buf = (const char *) &msg[1];
722 while (payload_size >= sizeof(struct GNUNET_MessageHeader))
723 {
724 /* need to memcpy() for alignment */
725 GNUNET_memcpy (&pa,
726 buf,
727 sizeof(pa));
728 payload_claimed_size = ntohs (pa.size);
729 if ((payload_size < payload_claimed_size) ||
730 (payload_claimed_size < sizeof(struct GNUNET_MessageHeader)) ||
731 (GNUNET_CONSTANTS_MAX_CADET_MESSAGE_SIZE < payload_claimed_size))
732 {
733 GNUNET_break (0);
735 "Local data of %u total size had sub-message %u at %u with %u bytes\n",
736 ntohs (msg->header.size),
737 ntohs (pa.type),
738 (unsigned int) (buf - (const char *) &msg[1]),
739 (unsigned int) payload_claimed_size);
740 return GNUNET_SYSERR;
741 }
742 payload_size -= payload_claimed_size;
743 buf += payload_claimed_size;
744 }
745 if (0 != payload_size)
746 {
747 GNUNET_break_op (0);
748 return GNUNET_SYSERR;
749 }
750 return GNUNET_OK;
751}
#define GNUNET_CONSTANTS_MAX_CADET_MESSAGE_SIZE
Maximum message size that can be sent on CADET.
#define GNUNET_memcpy(dst, src, n)
Call memcpy() but check for n being 0 first.
uint16_t size
The length of the struct (in bytes, including the length field itself), in big-endian format.
@ GNUNET_SYSERR
#define GNUNET_break_op(cond)
Use this for assertion violations caused by other peers (i.e.
Header for all communications.

References GNUNET_break, GNUNET_break_op, GNUNET_CONSTANTS_MAX_CADET_MESSAGE_SIZE, GNUNET_ERROR_TYPE_DEBUG, GNUNET_memcpy, GNUNET_OK, GNUNET_SYSERR, LOG, msg, GNUNET_MessageHeader::size, and GNUNET_MessageHeader::type.

◆ handle_local_data()

static void handle_local_data ( void *  cls,
const struct GNUNET_CADET_LocalData msg 
)
static

Handler for client payload traffic to be send on a channel to another peer.

Parameters
clsidentification of the client
msgthe actual message

Definition at line 762 of file gnunet-service-cadet.c.

764{
765 struct CadetClient *c = cls;
766 struct CadetChannel *ch;
767 size_t payload_size;
768 const char *buf;
769
770 ch = lookup_channel (c,
771 msg->ccn);
772 if (NULL == ch)
773 {
774 /* Channel does not exist (anymore) */
776 "Dropping payload for channel %u from client (channel unknown, other endpoint may have disconnected)\n",
777 (unsigned int) ntohl (msg->ccn.channel_of_client));
779 return;
780 }
781 payload_size = ntohs (msg->header.size) - sizeof(*msg);
783 "# payload received from clients",
784 payload_size,
785 GNUNET_NO);
786 buf = (const char *) &msg[1];
788 "Received %u bytes payload from %s for %s\n",
789 (unsigned int) payload_size,
790 GSC_2s (c),
791 GCCH_2s (ch));
792 if (GNUNET_OK !=
794 msg->ccn,
795 buf,
796 payload_size))
797 {
798 GNUNET_break (0);
800 return;
801 }
803}
int GCCH_handle_local_data(struct CadetChannel *ch, struct GNUNET_CADET_ClientChannelNumber sender_ccn, const char *buf, size_t buf_len)
Handle data given by a client.
void GNUNET_STATISTICS_update(struct GNUNET_STATISTICS_Handle *handle, const char *name, int64_t delta, int make_persistent)
Set statistic value for the peer.

References ch, CadetClient::client, GCCH_2s(), GCCH_handle_local_data(), GNUNET_break, GNUNET_ERROR_TYPE_DEBUG, GNUNET_ERROR_TYPE_WARNING, GNUNET_NO, GNUNET_OK, GNUNET_SERVICE_client_continue(), GNUNET_SERVICE_client_drop(), GNUNET_STATISTICS_update(), GSC_2s(), LOG, lookup_channel(), msg, GNUNET_MessageHeader::size, and stats.

Here is the call graph for this function:

◆ handle_local_ack()

static void handle_local_ack ( void *  cls,
const struct GNUNET_CADET_LocalAck msg 
)
static

Handler for client's ACKs for payload traffic.

Parameters
clsidentification of the client.
msgThe actual message.

Definition at line 813 of file gnunet-service-cadet.c.

815{
816 struct CadetClient *c = cls;
817 struct CadetChannel *ch;
818
819 ch = lookup_channel (c,
820 msg->ccn);
821 if (NULL == ch)
822 {
823 /* Channel does not exist (anymore) */
825 "Ignoring local ACK for channel %u from client (channel unknown, other endpoint may have disconnected)\n",
826 (unsigned int) ntohl (msg->ccn.channel_of_client));
828 return;
829 }
831 "Got a local ACK from %s for %s\n",
832 GSC_2s (c),
833 GCCH_2s (ch));
835 msg->ccn);
837}
void GCCH_handle_local_ack(struct CadetChannel *ch, struct GNUNET_CADET_ClientChannelNumber client_ccn)
Handle ACK from client on local channel.

References ch, CadetClient::client, GCCH_2s(), GCCH_handle_local_ack(), GNUNET_ERROR_TYPE_DEBUG, GNUNET_ERROR_TYPE_WARNING, GNUNET_SERVICE_client_continue(), GSC_2s(), LOG, lookup_channel(), and msg.

Here is the call graph for this function:

◆ get_all_peers_iterator()

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

Iterator over all peers to send a monitoring client info about each peer.

Parameters
clsClosure ().
peerPeer ID (tunnel remote peer).
valuePeer info.
Returns
GNUNET_YES, to keep iterating.

Definition at line 849 of file gnunet-service-cadet.c.

852{
853 struct CadetClient *c = cls;
854 struct CadetPeer *p = value;
855 struct GNUNET_MQ_Envelope *env;
857
860 msg->destination = *peer;
861 msg->paths = htons (GCP_count_paths (p));
862 msg->tunnel = htons (NULL != GCP_get_tunnel (p,
863 GNUNET_NO));
864 msg->best_path_length = htonl (0); // FIXME: get length of shortest known path!
865 GNUNET_MQ_send (c->mq,
866 env);
867 return GNUNET_YES;
868}
unsigned int GCP_count_paths(const struct CadetPeer *cp)
Count the number of known paths toward the peer.
static struct GNUNET_Process * p
Helper process we started.
Definition gnunet-uri.c:38
#define GNUNET_MESSAGE_TYPE_CADET_LOCAL_INFO_PEERS
Local information about all peers known to the service.
Message to inform the client about one of the peers in the service.
Definition cadet.h:424

References env, GCP_count_paths(), GCP_get_tunnel(), GNUNET_MESSAGE_TYPE_CADET_LOCAL_INFO_PEERS, GNUNET_MQ_msg, GNUNET_MQ_send(), GNUNET_NO, GNUNET_YES, CadetClient::mq, msg, p, and value.

Referenced by handle_get_peers().

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

◆ handle_get_peers()

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

Handler for client's INFO PEERS request.

Parameters
clsIdentification of the client.
messageThe actual message.

Definition at line 878 of file gnunet-service-cadet.c.

880{
881 struct CadetClient *c = cls;
882 struct GNUNET_MQ_Envelope *env;
883 struct GNUNET_MessageHeader *reply;
884
886 c);
887 env = GNUNET_MQ_msg (reply,
889 GNUNET_MQ_send (c->mq,
890 env);
892}
static int get_all_peers_iterator(void *cls, const struct GNUNET_PeerIdentity *peer, void *value)
Iterator over all peers to send a monitoring client info about each peer.
#define GNUNET_MESSAGE_TYPE_CADET_LOCAL_INFO_PEERS_END
End of local information about all peers known to the service.

References CadetClient::client, env, GCP_iterate_all(), get_all_peers_iterator(), GNUNET_MESSAGE_TYPE_CADET_LOCAL_INFO_PEERS_END, GNUNET_MQ_msg, GNUNET_MQ_send(), GNUNET_SERVICE_client_continue(), and CadetClient::mq.

Here is the call graph for this function:

◆ path_info_iterator()

static int path_info_iterator ( void *  cls,
struct CadetPeerPath path,
unsigned int  off 
)
static

Iterator over all paths of a peer to build an InfoPeer message.

Message contains blocks of peers, first not included.

Parameters
clsmessage queue for transmission
pathPath itself
offoffset of the peer on path
Returns
GNUNET_YES if should keep iterating. GNUNET_NO otherwise.

Definition at line 906 of file gnunet-service-cadet.c.

909{
910 struct GNUNET_MQ_Handle *mq = cls;
911 struct GNUNET_MQ_Envelope *env;
913 struct GNUNET_PeerIdentity *id;
914 size_t path_size;
915 unsigned int path_length;
916
917 path_length = GCPP_get_length (path);
918 path_size = sizeof(struct GNUNET_PeerIdentity) * path_length;
919 if (sizeof(*resp) + path_size > UINT16_MAX)
920 {
921 /* try just giving the relevant path */
922 path_length = GNUNET_MIN ((UINT16_MAX - sizeof(*resp)) / sizeof(struct
924 off);
925 path_size = sizeof(struct GNUNET_PeerIdentity) * path_length;
926 }
927 if (sizeof(*resp) + path_size > UINT16_MAX)
928 {
930 "Path of %u entries is too long for info message\n",
931 path_length);
932 return GNUNET_YES;
933 }
934 env = GNUNET_MQ_msg_extra (resp,
935 path_size,
937 id = (struct GNUNET_PeerIdentity *) &resp[1];
938
939 /* Don't copy first peer. First peer is always the local one. Last
940 * peer is always the destination (leave as 0, EOL).
941 */
942 for (unsigned int i = 0; i < path_length; i++)
943 id[i] = *GCP_get_id (GCPP_get_peer_at_offset (path,
944 i));
945 resp->off = htonl (off);
947 env);
948 return GNUNET_YES;
949}
static struct GNUNET_IDENTITY_Handle * id
Handle to IDENTITY.
unsigned int GCPP_get_length(struct CadetPeerPath *path)
Return the length of the path.
struct CadetPeer * GCPP_get_peer_at_offset(struct CadetPeerPath *path, unsigned int off)
Obtain the peer at offset off in path.
#define GNUNET_MIN(a, b)
#define GNUNET_MQ_msg_extra(mvar, esize, type)
Allocate an envelope, with extra space allocated after the space needed by the message struct.
#define GNUNET_MESSAGE_TYPE_CADET_LOCAL_INFO_PATH
Local information of service about a specific path.
static struct GNUNET_MQ_Handle * mq
Our connection to the resolver service, created on-demand, but then persists until error or shutdown.
Message to inform the client about one of the paths known to the service.
Definition cadet.h:407
uint32_t off
Offset of the peer that was requested.
Definition cadet.h:416
Handle to a message queue.
Definition mq.c:87

References env, GCP_get_id(), GCPP_get_length(), GCPP_get_peer_at_offset(), GNUNET_ERROR_TYPE_WARNING, GNUNET_MESSAGE_TYPE_CADET_LOCAL_INFO_PATH, GNUNET_MIN, GNUNET_MQ_msg_extra, GNUNET_MQ_send(), GNUNET_YES, id, LOG, mq, and GNUNET_CADET_LocalInfoPath::off.

Referenced by handle_show_path().

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

◆ handle_show_path()

static void handle_show_path ( void *  cls,
const struct GNUNET_CADET_RequestPathInfoMessage msg 
)
static

Handler for client's GNUNET_MESSAGE_TYPE_CADET_LOCAL_REQUEST_INFO_PATH request.

Parameters
clsIdentification of the client.
msgThe actual message.

Definition at line 959 of file gnunet-service-cadet.c.

961{
962 struct CadetClient *c = cls;
963 struct CadetPeer *p;
964 struct GNUNET_MQ_Envelope *env;
965 struct GNUNET_MessageHeader *resp;
966
967 p = GCP_get (&msg->peer,
968 GNUNET_NO);
969 if (NULL != p)
972 c->mq);
973 env = GNUNET_MQ_msg (resp,
975 GNUNET_MQ_send (c->mq,
976 env);
978}
static int path_info_iterator(void *cls, struct CadetPeerPath *path, unsigned int off)
Iterator over all paths of a peer to build an InfoPeer message.
unsigned int GCP_iterate_indirect_paths(struct CadetPeer *cp, GCP_PathIterator callback, void *callback_cls)
Iterate over the paths to a peer without direct link.
#define GNUNET_MESSAGE_TYPE_CADET_LOCAL_INFO_PATH_END
End of local information of service about a specific path.

References CadetClient::client, env, GCP_get(), GCP_iterate_indirect_paths(), GNUNET_MESSAGE_TYPE_CADET_LOCAL_INFO_PATH_END, GNUNET_MQ_msg, GNUNET_MQ_send(), GNUNET_NO, GNUNET_SERVICE_client_continue(), CadetClient::mq, msg, p, and path_info_iterator().

Here is the call graph for this function:

◆ get_all_tunnels_iterator()

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

Iterator over all tunnels to send a monitoring client info about each tunnel.

Parameters
clsClosure ().
peerPeer ID (tunnel remote peer).
valuea struct CadetPeer
Returns
GNUNET_YES, to keep iterating.

Definition at line 990 of file gnunet-service-cadet.c.

993{
994 struct CadetClient *c = cls;
995 struct CadetPeer *p = value;
996 struct GNUNET_MQ_Envelope *env;
998 struct CadetTunnel *t;
999
1000 t = GCP_get_tunnel (p,
1001 GNUNET_NO);
1002 if (NULL == t)
1003 return GNUNET_YES;
1006 msg->destination = *peer;
1007 msg->channels = htonl (GCT_count_channels (t));
1008 msg->connections = htonl (GCT_count_any_connections (t));
1009 msg->cstate = htons (0);
1010 msg->estate = htons (GCT_get_estate (t));
1011 GNUNET_MQ_send (c->mq,
1012 env);
1013 return GNUNET_YES;
1014}
unsigned int GCT_count_any_connections(const struct CadetTunnel *t)
Counts the number of connections created for a tunnel, including busy connections.
unsigned int GCT_count_channels(struct CadetTunnel *t)
Returns the number of channels using a tunnel.
enum CadetTunnelEState GCT_get_estate(struct CadetTunnel *t)
Get the encryption state of a tunnel.
#define GNUNET_MESSAGE_TYPE_CADET_LOCAL_INFO_TUNNELS
Local information about all tunnels of service.
Message to inform the client about one of the tunnels in the service.
Definition cadet.h:458

References env, GCP_get_tunnel(), GCT_count_any_connections(), GCT_count_channels(), GCT_get_estate(), GNUNET_MESSAGE_TYPE_CADET_LOCAL_INFO_TUNNELS, GNUNET_MQ_msg, GNUNET_MQ_send(), GNUNET_NO, GNUNET_YES, CadetClient::mq, msg, p, t, and value.

Referenced by handle_info_tunnels().

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

◆ handle_info_tunnels()

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

Handler for client's GNUNET_MESSAGE_TYPE_CADET_LOCAL_REQUEST_INFO_TUNNELS request.

Parameters
clsclient Identification of the client.
messageThe actual message.

Definition at line 1024 of file gnunet-service-cadet.c.

1026{
1027 struct CadetClient *c = cls;
1028 struct GNUNET_MQ_Envelope *env;
1029 struct GNUNET_MessageHeader *reply;
1030
1032 c);
1033 env = GNUNET_MQ_msg (reply,
1035 GNUNET_MQ_send (c->mq,
1036 env);
1038}
static int get_all_tunnels_iterator(void *cls, const struct GNUNET_PeerIdentity *peer, void *value)
Iterator over all tunnels to send a monitoring client info about each tunnel.
#define GNUNET_MESSAGE_TYPE_CADET_LOCAL_INFO_TUNNELS_END
End of local information about all tunnels of service.

References CadetClient::client, env, GCP_iterate_all(), get_all_tunnels_iterator(), GNUNET_MESSAGE_TYPE_CADET_LOCAL_INFO_TUNNELS_END, GNUNET_MQ_msg, GNUNET_MQ_send(), GNUNET_SERVICE_client_continue(), and CadetClient::mq.

Here is the call graph for this function:

◆ handle_drop_message()

static void handle_drop_message ( void *  cls,
const struct GNUNET_CADET_RequestDropCadetMessage message 
)
static

Handler for client's GNUNET_MESSAGE_TYPE_CADET_DROP_CADET_MESSAGE request.

Parameters
clsclient Identification of the client.
messageThe actual message.

Definition at line 1048 of file gnunet-service-cadet.c.

1050{
1051 struct CadetClient *c = cls;
1052 struct CadetChannel *ch;
1053
1054 ch = lookup_channel (c,
1055 message->ccn);
1056
1057 if (NULL != ch)
1058 GCCH_assign_type_to_drop (ch, message);
1059
1061}
void GCCH_assign_type_to_drop(struct CadetChannel *ch, const struct GNUNET_CADET_RequestDropCadetMessage *message)
Assign type of message to drop.
struct GNUNET_CADET_ClientChannelNumber ccn
ID of the channel we want to drop a message for.
Definition cadet.h:336

References GNUNET_CADET_RequestDropCadetMessage::ccn, ch, CadetClient::client, GCCH_assign_type_to_drop(), GNUNET_SERVICE_client_continue(), and lookup_channel().

Here is the call 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

Callback called when a client connects to the service.

Parameters
clsclosure for the service
clientthe new client that connected to the service
mqthe message queue used to send messages to the client
Returns
c

Definition at line 1073 of file gnunet-service-cadet.c.

1076{
1077 struct CadetClient *c;
1078
1079 c = GNUNET_new (struct CadetClient);
1080 c->client = client;
1081 c->mq = mq;
1082 c->id = next_client_id++; /* overflow not important: just for debug */
1083 c->channels
1087 c);
1089 "# clients",
1090 +1,
1091 GNUNET_NO);
1093 "%s connected\n",
1094 GSC_2s (c));
1095 return c;
1096}
static struct CadetClient * clients_tail
DLL with all the clients, tail.
static unsigned int next_client_id
Next ID to assign to a client.
#define GNUNET_CONTAINER_DLL_insert(head, tail, element)
Insert an element at the head of a DLL.
struct GNUNET_CONTAINER_MultiHashMap32 * GNUNET_CONTAINER_multihashmap32_create(unsigned int len)
Create a 32-bit key multi hash map.

References CadetClient::channels, CadetClient::client, clients_head, clients_tail, GNUNET_CONTAINER_DLL_insert, GNUNET_CONTAINER_multihashmap32_create(), GNUNET_ERROR_TYPE_DEBUG, GNUNET_new, GNUNET_NO, GNUNET_STATISTICS_update(), GSC_2s(), CadetClient::id, LOG, mq, CadetClient::mq, next_client_id, and stats.

Here is the call graph for this function:

◆ GSC_handle_remote_channel_destroy()

void GSC_handle_remote_channel_destroy ( struct CadetClient c,
struct GNUNET_CADET_ClientChannelNumber  ccn,
struct CadetChannel ch 
)

A channel was destroyed by the other peer.

Tell our client.

Parameters
cclient that lost a channel
ccnchannel identification number for the client
chthe channel object

Definition at line 1107 of file gnunet-service-cadet.c.

1110{
1111 struct GNUNET_MQ_Envelope *env;
1113
1114 env = GNUNET_MQ_msg (tdm,
1116 tdm->ccn = ccn;
1118 env);
1121 ntohl (
1123 ),
1124 ch));
1125}
#define GNUNET_MESSAGE_TYPE_CADET_LOCAL_CHANNEL_DESTROY
Tell client that a channel was destroyed.
Message for or to a client to destroy tunnel.
Definition cadet.h:235
struct GNUNET_CADET_ClientChannelNumber ccn
ID of a channel controlled by this client.
Definition cadet.h:244

References GNUNET_CADET_LocalChannelDestroyMessage::ccn, ch, GNUNET_CADET_ClientChannelNumber::channel_of_client, CadetClient::channels, env, GNUNET_assert, GNUNET_CONTAINER_multihashmap32_remove(), GNUNET_MESSAGE_TYPE_CADET_LOCAL_CHANNEL_DESTROY, GNUNET_MQ_msg, GNUNET_YES, and GSC_send_to_client().

Referenced by GCCH_handle_remote_destroy(), and signal_remote_destroy_cb().

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

◆ GSC_drop_loose_channel()

void GSC_drop_loose_channel ( const struct GNUNET_HashCode h_port,
struct CadetChannel ch 
)

A client that created a loose channel that was not bound to a port disconnected, drop it from the loose_channels list.

Parameters
h_portthe hashed port the channel was trying to bind to
chthe channel that was lost

Definition at line 1129 of file gnunet-service-cadet.c.

1131{
1134 h_port,
1135 ch));
1136}

References ch, GNUNET_assert, GNUNET_CONTAINER_multihashmap_remove(), GNUNET_YES, and loose_channels.

Referenced by channel_destroy().

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

◆ channel_destroy_iterator()

static int channel_destroy_iterator ( void *  cls,
uint32_t  key,
void *  value 
)
static

Iterator for deleting each channel whose client endpoint disconnected.

Parameters
clsClosure (client that has disconnected).
keyThe local channel id in host byte order
valueThe value stored at the key (channel to destroy).
Returns
GNUNET_OK, keep iterating.

Definition at line 1148 of file gnunet-service-cadet.c.

1151{
1152 struct CadetClient *c = cls;
1154 struct CadetChannel *ch = value;
1155
1157 "Destroying %s, due to %s disconnecting.\n",
1158 GCCH_2s (ch),
1159 GSC_2s (c));
1160 ccn.channel_of_client = htonl (key);
1163 key,
1164 ch));
1166 c,
1167 ccn);
1168 return GNUNET_OK;
1169}
struct GNUNET_HashCode key
The key used in the DHT.

References ch, GNUNET_CADET_ClientChannelNumber::channel_of_client, CadetClient::channels, GCCH_2s(), GCCH_channel_local_destroy(), GNUNET_assert, GNUNET_CONTAINER_multihashmap32_remove(), GNUNET_ERROR_TYPE_DEBUG, GNUNET_OK, GNUNET_YES, GSC_2s(), key, LOG, and value.

Referenced by client_disconnect_cb().

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

◆ client_release_ports()

static int client_release_ports ( void *  cls,
const struct GNUNET_HashCode port,
void *  value 
)
static

Remove client's ports from the global hashmap on disconnect.

Parameters
clsthe struct CadetClient
portthe port.
valuethe struct OpenPort to remove
Returns
GNUNET_OK, keep iterating.

Definition at line 1181 of file gnunet-service-cadet.c.

1184{
1185 struct CadetClient *c = cls;
1186 struct OpenPort *op = value;
1187
1188 GNUNET_assert (c == op->c);
1190 "Closing port %s due to %s disconnect.\n",
1191 GNUNET_h2s (port),
1192 GSC_2s (c));
1195 &op->h_port,
1196 op));
1199 port,
1200 op));
1201 GNUNET_free (op);
1202 return GNUNET_OK;
1203}

References OpenPort::c, GNUNET_assert, GNUNET_CONTAINER_multihashmap_remove(), GNUNET_ERROR_TYPE_DEBUG, GNUNET_free, GNUNET_h2s(), GNUNET_OK, GNUNET_YES, GSC_2s(), LOG, op, open_ports, port, CadetClient::ports, and value.

Referenced by client_disconnect_cb().

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

◆ client_disconnect_cb()

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

Callback called when a client disconnected from the service.

Parameters
clsclosure for the service
clientthe client that disconnected
internal_clsshould be equal to c

Definition at line 1214 of file gnunet-service-cadet.c.

1217{
1218 struct CadetClient *c = internal_cls;
1219
1220 GNUNET_assert (c->client == client);
1222 "%s is disconnecting.\n",
1223 GSC_2s (c));
1224 if (NULL != c->channels)
1225 {
1228 c);
1231 }
1232 if (NULL != c->ports)
1233 {
1236 c);
1238 }
1241 c);
1243 "# clients",
1244 -1,
1245 GNUNET_NO);
1246 GNUNET_free (c);
1247 if ((NULL == clients_head) &&
1249 shutdown_rest ();
1250}
static int channel_destroy_iterator(void *cls, uint32_t key, void *value)
Iterator for deleting each channel whose client endpoint disconnected.
static int client_release_ports(void *cls, const struct GNUNET_HashCode *port, void *value)
Remove client's ports from the global hashmap on disconnect.
#define GNUNET_CONTAINER_DLL_remove(head, tail, element)
Remove an element from a DLL.
int GNUNET_CONTAINER_multihashmap_iterate(struct GNUNET_CONTAINER_MultiHashMap *map, GNUNET_CONTAINER_MultiHashMapIteratorCallback it, void *it_cls)
Iterate over all entries in the map.
unsigned int GNUNET_CONTAINER_multihashmap32_size(const struct GNUNET_CONTAINER_MultiHashMap32 *map)
Get the number of key-value pairs in the map.
void GNUNET_CONTAINER_multihashmap32_destroy(struct GNUNET_CONTAINER_MultiHashMap32 *map)
Destroy a 32-bit key hash map.
int GNUNET_CONTAINER_multihashmap32_iterate(struct GNUNET_CONTAINER_MultiHashMap32 *map, GNUNET_CONTAINER_MultiHashMapIterator32Callback it, void *it_cls)
Iterate over all entries in the map.

References channel_destroy_iterator(), CadetClient::channels, CadetClient::client, client_release_ports(), clients_head, clients_tail, GNUNET_assert, GNUNET_CONTAINER_DLL_remove, GNUNET_CONTAINER_multihashmap32_destroy(), GNUNET_CONTAINER_multihashmap32_iterate(), GNUNET_CONTAINER_multihashmap32_size(), GNUNET_CONTAINER_multihashmap_destroy(), GNUNET_CONTAINER_multihashmap_iterate(), GNUNET_ERROR_TYPE_DEBUG, GNUNET_free, GNUNET_NO, GNUNET_STATISTICS_update(), GNUNET_YES, GSC_2s(), LOG, CadetClient::ports, shutdown_rest(), shutting_down, and stats.

Here is the call graph for this function:

◆ run()

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

Setup CADET internals.

Parameters
clsclosure
cconfiguration to use

Definition at line 1260 of file gnunet-service-cadet.c.

1263{
1264 cfg = c;
1265 if (GNUNET_OK !=
1267 "CADET",
1268 "RATCHET_MESSAGES",
1270 {
1272 "CADET",
1273 "RATCHET_MESSAGES",
1274 "needs to be a number");
1275 ratchet_messages = 64;
1276 }
1277 if (GNUNET_OK !=
1279 "CADET",
1280 "RATCHET_TIME",
1281 &ratchet_time))
1282 {
1284 "CADET",
1285 "RATCHET_TIME",
1286 "need delay value");
1288 }
1289 if (GNUNET_OK !=
1291 "CADET",
1292 "REFRESH_CONNECTION_TIME",
1294 {
1296 "CADET",
1297 "REFRESH_CONNECTION_TIME",
1298 "need delay value");
1300 }
1301 if (GNUNET_OK !=
1303 "CADET",
1304 "DROP_PERCENT",
1305 &drop_percent))
1306 {
1307 drop_percent = 0;
1308 }
1309 else
1310 {
1311 LOG (GNUNET_ERROR_TYPE_WARNING, "**************************************\n");
1312 LOG (GNUNET_ERROR_TYPE_WARNING, "Cadet is running with DROP enabled.\n");
1313 LOG (GNUNET_ERROR_TYPE_WARNING, "This is NOT a good idea!\n");
1314 LOG (GNUNET_ERROR_TYPE_WARNING, "Remove DROP_PERCENT from config file.\n");
1315 LOG (GNUNET_ERROR_TYPE_WARNING, "**************************************\n");
1316 }
1318 c);
1320 NULL);
1322 /* FIXME: optimize code to allow GNUNET_YES here! */
1324 GNUNET_NO);
1326 GNUNET_NO);
1328 GNUNET_YES);
1330 GNUNET_YES);
1331 GCH_init (c);
1332 GCD_init (c);
1333 GCO_init (c);
1335 "CADET started for peer %s\n",
1337}
struct GNUNET_SCHEDULER_Task * shutdown_task
unsigned long long drop_percent
Set to non-zero values to create random drops to test retransmissions.
const struct GNUNET_CONFIGURATION_Handle * cfg
Handle to our configuration.
struct GNUNET_TIME_Relative keepalive_period
How frequently do we send KEEPALIVE messages on idle connections?
unsigned long long ratchet_messages
How many messages are needed to trigger an AXOLOTL ratchet advance.
struct GNUNET_TIME_Relative ratchet_time
How long until we trigger a ratched advance due to time.
void GCO_init(const struct GNUNET_CONFIGURATION_Handle *c)
Initialize the CORE subsystem.
void GCD_init(const struct GNUNET_CONFIGURATION_Handle *c)
Initialize the DHT subsystem.
void GCH_init(const struct GNUNET_CONFIGURATION_Handle *c)
Initialize the hello subsystem.
struct GNUNET_TRANSPORT_ApplicationHandle * GNUNET_TRANSPORT_application_init(const struct GNUNET_CONFIGURATION_Handle *cfg)
Initialize the TRANSPORT application client handle.
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_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.
struct GNUNET_CONTAINER_MultiShortmap * GNUNET_CONTAINER_multishortmap_create(unsigned int len, int do_not_copy_keys)
Create a multi peer map (hash map for public keys of peers).
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).
void GNUNET_log_config_invalid(enum GNUNET_ErrorType kind, const char *section, const char *option, const char *required)
Log error message about invalid configuration option value.
@ GNUNET_ERROR_TYPE_INFO
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:1345
struct GNUNET_STATISTICS_Handle * GNUNET_STATISTICS_create(const char *subsystem, const struct GNUNET_CONFIGURATION_Handle *cfg)
Get handle for the statistics service.
#define GNUNET_TIME_UNIT_HOURS
One hour.
#define GNUNET_TIME_UNIT_MINUTES
One minute.

References cfg, connections, drop_percent, GCD_init(), GCH_init(), GCO_init(), GNUNET_CONFIGURATION_get_value_number(), GNUNET_CONFIGURATION_get_value_time(), GNUNET_CONTAINER_multihashmap_create(), GNUNET_CONTAINER_multipeermap_create(), GNUNET_CONTAINER_multishortmap_create(), GNUNET_ERROR_TYPE_INFO, GNUNET_ERROR_TYPE_WARNING, GNUNET_i2s(), GNUNET_log, GNUNET_log_config_invalid(), GNUNET_NO, GNUNET_OK, GNUNET_PILS_get_identity(), GNUNET_SCHEDULER_add_shutdown(), GNUNET_STATISTICS_create(), GNUNET_TIME_UNIT_HOURS, GNUNET_TIME_UNIT_MINUTES, GNUNET_TRANSPORT_application_init(), GNUNET_YES, keepalive_period, LOG, loose_channels, open_ports, peers, pils, ratchet_messages, ratchet_time, shutdown_task, stats, and transport.

Here is the call graph for this function:

◆ GNUNET_SERVICE_MAIN()

Define "main" method using service macro.

Variable Documentation

◆ cfg

const struct GNUNET_CONFIGURATION_Handle* cfg

Handle to our configuration.

Handle to our configuration.

Definition at line 114 of file gnunet-service-cadet.c.

Referenced by run().

◆ stats

struct GNUNET_STATISTICS_Handle* stats

Handle to the statistics service.

Definition at line 119 of file gnunet-service-cadet.c.

Referenced by client_connect_cb(), client_disconnect_cb(), handle_local_data(), run(), and shutdown_rest().

◆ transport

Handle to Transport service.

Definition at line 124 of file gnunet-service-cadet.c.

Referenced by consider_peer_activate(), GCP_set_hello(), run(), and shutdown_rest().

◆ pils

struct GNUNET_PILS_Handle* pils

Handle to the pils service.

Handle to Pils service.

Definition at line 129 of file gnunet-service-cadet.c.

Referenced by handle_port_open(), and run().

◆ shutting_down

int shutting_down

Signal that shutdown is happening: prevent recovery measures.

Definition at line 134 of file gnunet-service-cadet.c.

Referenced by client_disconnect_cb(), GCT_destroy_tunnel_now(), and shutdown_task().

◆ clients_head

struct CadetClient* clients_head
static

DLL with all the clients, head.

Definition at line 139 of file gnunet-service-cadet.c.

Referenced by client_connect_cb(), client_disconnect_cb(), and shutdown_task().

◆ clients_tail

struct CadetClient* clients_tail
static

DLL with all the clients, tail.

Definition at line 144 of file gnunet-service-cadet.c.

Referenced by client_connect_cb(), and client_disconnect_cb().

◆ next_client_id

unsigned int next_client_id
static

Next ID to assign to a client.

Definition at line 149 of file gnunet-service-cadet.c.

Referenced by client_connect_cb().

◆ open_ports

struct GNUNET_CONTAINER_MultiHashMap* open_ports

All ports clients of this peer have opened.

Maps from a hashed port to a struct OpenPort.

Definition at line 155 of file gnunet-service-cadet.c.

Referenced by client_release_ports(), GCCH_channel_incoming_new(), GCCH_channel_local_new(), handle_port_close(), handle_port_open(), run(), and shutdown_rest().

◆ loose_channels

struct GNUNET_CONTAINER_MultiHashMap* loose_channels

Map from ports to channels where the ports were closed at the time we got the inbound connection.

Indexed by h_port, contains struct CadetChannel.

Definition at line 162 of file gnunet-service-cadet.c.

Referenced by bind_loose_channel(), GCCH_channel_incoming_new(), GCCH_channel_local_new(), GSC_drop_loose_channel(), handle_port_open(), run(), and shutdown_rest().

◆ peers

◆ connections

struct GNUNET_CONTAINER_MultiShortmap* connections

Map from struct GNUNET_CADET_ConnectionTunnelIdentifier hash codes to struct CadetConnection objects.

Definition at line 173 of file gnunet-service-cadet.c.

Referenced by connection_create(), GCC_destroy(), GCC_lookup(), run(), and shutdown_rest().

◆ ratchet_messages

unsigned long long ratchet_messages

How many messages are needed to trigger an AXOLOTL ratchet advance.

Definition at line 178 of file gnunet-service-cadet.c.

Referenced by run().

◆ ratchet_time

struct GNUNET_TIME_Relative ratchet_time

How long until we trigger a ratched advance due to time.

Definition at line 183 of file gnunet-service-cadet.c.

Referenced by run(), t_ax_encrypt(), and update_ax_by_kx().

◆ keepalive_period

struct GNUNET_TIME_Relative keepalive_period

How frequently do we send KEEPALIVE messages on idle connections?

Definition at line 188 of file gnunet-service-cadet.c.

Referenced by GCC_handle_connection_create_ack(), handle_connection_create(), keepalive_done(), manage_first_hop_mq(), run(), send_create_ack(), send_keepalive(), and timeout_cb().

◆ drop_percent

unsigned long long drop_percent

Set to non-zero values to create random drops to test retransmissions.

Definition at line 193 of file gnunet-service-cadet.c.

Referenced by get_channel_weight(), run(), and should_I_drop().