GNUnet 0.21.1
gnunet-service-cadet.h File Reference

Information we track per peer. More...

#include "gnunet_util_lib.h"
#include "cadet_protocol.h"
Include dependency graph for gnunet-service-cadet.h:
This graph shows which files directly or indirectly include this file:

Go to the source code of this file.

Data Structures

struct  CadetPeerPathEntry
 Entry in a peer path. More...
 
struct  CadetTConnection
 Entry in list of connections used by tunnel, with metadata. More...
 
struct  OpenPort
 Port opened by a client. More...
 

Functions

void GSC_send_to_client (struct CadetClient *c, struct GNUNET_MQ_Envelope *env)
 Send a message to a client. More...
 
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. More...
 
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. More...
 
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. More...
 
const char * GSC_2s (struct CadetClient *c)
 Return identifier for a client as a string. More...
 

Variables

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

Detailed Description

Information we track per peer.

Author
Bartlomiej Polot
Christian Grothoff

Definition in file gnunet-service-cadet.h.

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 208 of file gnunet-service-cadet.c.

210{
211 GNUNET_MQ_send (c->mq,
212 env);
213}
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:304
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_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 1083 of file gnunet-service-cadet.c.

1086{
1087 struct GNUNET_MQ_Envelope *env;
1089
1090 env = GNUNET_MQ_msg (tdm,
1092 tdm->ccn = ccn;
1094 env);
1097 ntohl (
1099 ch));
1100}
static struct GNUNET_CADET_Channel * ch
Channel handle.
Definition: gnunet-cadet.c:117
void GSC_send_to_client(struct CadetClient *c, struct GNUNET_MQ_Envelope *env)
Send a message to a client.
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.
@ GNUNET_YES
#define GNUNET_assert(cond)
Use this for fatal errors that cannot be handled.
#define GNUNET_MQ_msg(mvar, type)
Allocate a GNUNET_MQ_Envelope.
Definition: gnunet_mq_lib.h:78
#define GNUNET_MESSAGE_TYPE_CADET_LOCAL_CHANNEL_DESTROY
Tell client that a channel was destroyed.
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
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 1104 of file gnunet-service-cadet.c.

1106{
1109 h_port,
1110 ch));
1111}
struct GNUNET_CONTAINER_MultiHashMap * loose_channels
Map from ports to channels where the ports were closed at the time we got the inbound connection.
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.

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:

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

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

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 292 of file gnunet-service-cadet.c.

297{
298 struct GNUNET_MQ_Envelope *env;
301
302 ccn = client_get_next_ccn (c);
305 ntohl (
306 ccn.channel_of_client),
307 ch,
310 "Accepting incoming %s from %s on open port %s (%u), assigning ccn %X\n",
311 GCCH_2s (ch),
312 GCP_2s (dest),
314 (uint32_t) ntohl (options),
315 (uint32_t) ntohl (ccn.channel_of_client));
316 /* notify local client about incoming connection! */
317 env = GNUNET_MQ_msg (cm,
319 cm->ccn = ccn;
320 cm->port = *port;
321 cm->opt = htonl (options);
322 cm->peer = *GCP_get_id (dest);
324 env);
325 return ccn;
326}
struct GNUNET_GETOPT_CommandLineOption options[]
Definition: 002.c:5
static uint16_t port
Port number.
Definition: gnunet-bcd.c:147
#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...
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_MESSAGE_TYPE_CADET_LOCAL_CHANNEL_CREATE
Ask the cadet service to create a new channel.
Number uniquely identifying a channel of a client.
Definition: cadet.h:101
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(), warningfilter::dest, 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:

◆ 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 223 of file gnunet-service-cadet.c.

224{
225 static char buf[32];
226
227 GNUNET_snprintf (buf,
228 sizeof(buf),
229 "Client(%u)",
230 c->id);
231 return buf;
232}
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:

Variable Documentation

◆ cfg

const struct GNUNET_CONFIGURATION_Handle* cfg
extern

Handle to our configuration.

Handle to our configuration.

Definition at line 164 of file gnunet-namestore.c.

Referenced by id_connect_cb(), libgnunet_plugin_rest_pabc_init(), process_command_stdin(), run(), and run_with_zone_pkey().

◆ stats

◆ transport

struct GNUNET_TRANSPORT_ApplicationHandle* transport
extern

Handle to Transport service.

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

Referenced by attempt_connect(), cleaning_task(), consider_peer_activate(), GCP_set_hello(), print_info(), run(), and shutdown_rest().

◆ my_full_id

◆ my_private_key

struct GNUNET_CRYPTO_EddsaPrivateKey* my_private_key
extern

Own private key.

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

Referenced by run(), and shutdown_rest().

◆ open_ports

struct GNUNET_CONTAINER_MultiHashMap* open_ports
extern

All ports clients of this peer have opened.

Maps from a hashed port to a struct OpenPort.

Definition at line 160 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().

◆ connections

struct GNUNET_CONTAINER_MultiShortmap* connections
extern

Map from struct GNUNET_CADET_ConnectionTunnelIdentifier hash codes to struct CadetConnection objects.

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

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

◆ loose_channels

struct GNUNET_CONTAINER_MultiHashMap* loose_channels
extern

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

◆ ratchet_messages

unsigned long long ratchet_messages
extern

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

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

Referenced by run().

◆ ratchet_time

struct GNUNET_TIME_Relative ratchet_time
extern

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

Definition at line 188 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
extern

How frequently do we send KEEPALIVE messages on idle connections?

Definition at line 193 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().

◆ shutting_down

int shutting_down
extern

Signal that shutdown is happening: prevent recovery measures.

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

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

◆ drop_percent

unsigned long long drop_percent
extern

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

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

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