GNUnet  0.11.x
Data Structures | Functions | Variables
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_ATS_ConnectivityHandleats_ch
 Handle to communicate with ATS. 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 205 of file gnunet-service-cadet.c.

207 {
208  GNUNET_MQ_send (c->mq,
209  env);
210 }
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:355
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_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 1080 of file gnunet-service-cadet.c.

1083 {
1084  struct GNUNET_MQ_Envelope *env;
1086 
1087  env = GNUNET_MQ_msg (tdm,
1089  tdm->ccn = ccn;
1090  GSC_send_to_client (c,
1091  env);
1094  ntohl (
1096  ch));
1097 }
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.
@ GNUNET_YES
Definition: gnunet_common.h:97
int GNUNET_CONTAINER_multihashmap32_remove(struct GNUNET_CONTAINER_MultiHashMap32 *map, uint32_t 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.
#define GNUNET_MQ_msg(mvar, type)
Allocate a GNUNET_MQ_Envelope.
Definition: gnunet_mq_lib.h:67
#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:110
Message for or to a client to destroy tunnel.
Definition: cadet.h:236
struct GNUNET_CADET_ClientChannelNumber ccn
ID of a channel controlled by this client.
Definition: cadet.h:245

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

1110 {
1113  h_port,
1114  ch));
1115 }
struct GNUNET_CONTAINER_MultiHashMap * loose_channels
Map from ports to channels where the ports were closed at the time we got the inbound connection.
int 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 240 of file gnunet-service-cadet.c.

294 {
295  struct GNUNET_MQ_Envelope *env;
298 
299  ccn = client_get_next_ccn (c);
302  ntohl (
303  ccn.channel_of_client),
304  ch,
307  "Accepting incoming %s from %s on open port %s (%u), assigning ccn %X\n",
308  GCCH_2s (ch),
309  GCP_2s (dest),
310  GNUNET_h2s (port),
311  (uint32_t) ntohl (options),
312  (uint32_t) ntohl (ccn.channel_of_client));
313  /* notify local client about incoming connection! */
314  env = GNUNET_MQ_msg (cm,
316  cm->ccn = ccn;
317  cm->port = *port;
318  cm->opt = htonl (options);
319  cm->peer = *GCP_get_id (dest);
321  env);
322  return ccn;
323 }
struct GNUNET_GETOPT_CommandLineOption options[]
Definition: 002.c:5
static uint16_t port
Port number.
Definition: gnunet-bcd.c:83
#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.
int 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:102
Message for a client to create channels.
Definition: cadet.h:202
struct GNUNET_PeerIdentity peer
Channel's peer.
Definition: cadet.h:218
struct GNUNET_CADET_ClientChannelNumber ccn
ID of a channel controlled by this client.
Definition: cadet.h:213
struct GNUNET_HashCode port
Port of the channel.
Definition: cadet.h:223

Referenced by GCCH_bind().

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

221 {
222  static char buf[32];
223 
225  sizeof(buf),
226  "Client(%u)",
227  c->id);
228  return buf;
229 }
static char buf[2048]
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 buf, 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

◆ stats

struct GNUNET_STATISTICS_Handle* stats
extern

Handle to the statistics service.

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

◆ ats_ch

struct GNUNET_ATS_ConnectivityHandle* ats_ch
extern

Handle to communicate with ATS.

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

Referenced by run(), and shutdown_rest().

◆ my_full_id

struct GNUNET_PeerIdentity my_full_id
extern

◆ my_private_key

struct GNUNET_CRYPTO_EddsaPrivateKey* my_private_key
extern

Own private key.

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

Referenced by GCT_add_channel(), run(), send_kx(), send_kx_auth(), set_monotime_sig(), shutdown_rest(), and update_ax_by_kx().

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

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

struct GNUNET_CONTAINER_MultiPeerMap* peers
extern

Map from PIDs to struct CadetPeer entries.

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

Referenced by run(), and shutdown_rest().

◆ ratchet_messages

unsigned long long ratchet_messages
extern

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

Definition at line 180 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 180 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 180 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 136 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 195 of file gnunet-service-cadet.c.

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