GNUnet  0.10.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 204 of file gnunet-service-cadet.c.

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

206 {
207  GNUNET_MQ_send(c->mq,
208  env);
209 }
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:351
struct GNUNET_MQ_Handle * mq
Handle to communicate with the 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 1049 of file gnunet-service-cadet.c.

References GNUNET_CADET_LocalChannelDestroyMessage::ccn, 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().

1052 {
1053  struct GNUNET_MQ_Envelope *env;
1055 
1056  env = GNUNET_MQ_msg(tdm,
1058  tdm->ccn = ccn;
1060  env);
1063  ntohl(ccn.channel_of_client),
1064  ch));
1065 }
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:169
#define GNUNET_MESSAGE_TYPE_CADET_LOCAL_CHANNEL_DESTROY
Tell client that a channel was destroyed.
#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
struct GNUNET_CONTAINER_MultiHashMap32 * channels
Tunnels that belong to this client, indexed by local id, value is a struct CadetChannel.
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.
struct GNUNET_MQ_Envelope * env
Definition: 005.c:1
struct GNUNET_CADET_ClientChannelNumber ccn
ID of a channel controlled by this client.
Definition: cadet.h:178
void GSC_send_to_client(struct CadetClient *c, struct GNUNET_MQ_Envelope *env)
Send a message to a client.
#define GNUNET_YES
Definition: gnunet_common.h:77
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 1076 of file gnunet-service-cadet.c.

References GNUNET_assert, GNUNET_CONTAINER_multihashmap_remove(), and GNUNET_YES.

Referenced by channel_destroy().

1078 {
1081  h_port,
1082  ch));
1083 }
#define GNUNET_assert(cond)
Use this for fatal errors that cannot be handled.
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.
#define GNUNET_YES
Definition: gnunet_common.h:77
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 288 of file gnunet-service-cadet.c.

References GNUNET_CADET_LocalChannelCreateMessage::ccn, 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, port, and GNUNET_CADET_LocalChannelCreateMessage::port.

Referenced by GCCH_bind().

293 {
294  struct GNUNET_MQ_Envelope *env;
297 
298  ccn = client_get_next_ccn(c);
301  ntohl(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),
308  GNUNET_h2s(port),
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_CADET_ClientChannelNumber ccn
ID of a channel controlled by this client.
Definition: cadet.h:147
struct GNUNET_GETOPT_CommandLineOption options[]
Definition: 002.c:5
#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
struct GNUNET_CONTAINER_MultiHashMap32 * channels
Tunnels that belong to this client, indexed by local id, value is a struct CadetChannel.
const char * GNUNET_h2s(const struct GNUNET_HashCode *hc)
Convert a hash value to a string (for printing debug messages).
#define GNUNET_MESSAGE_TYPE_CADET_LOCAL_CHANNEL_CREATE
Ask the cadet service to create a new channel.
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.
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.
const char * GCP_2s(const struct CadetPeer *cp)
Get the static string for a peer ID.
#define LOG(level,...)
Number uniquely identifying a channel of a client.
Definition: cadet.h:102
There must only be one value per key; storing a value should fail if a value under the same key alrea...
Message for a client to create channels.
Definition: cadet.h:136
struct GNUNET_MQ_Envelope * env
Definition: 005.c:1
const char * GCCH_2s(const struct CadetChannel *ch)
Get the static string for identification of the channel.
static uint16_t port
Port number.
Definition: gnunet-bcd.c:81
void GSC_send_to_client(struct CadetClient *c, struct GNUNET_MQ_Envelope *env)
Send a message to a client.
#define GNUNET_YES
Definition: gnunet_common.h:77
struct GNUNET_PeerIdentity peer
Channel's peer.
Definition: cadet.h:152
struct GNUNET_HashCode port
Port of the channel.
Definition: cadet.h:157
const struct GNUNET_PeerIdentity * GCP_get_id(struct CadetPeer *cp)
Obtain the peer identity for a struct CadetPeer.
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 219 of file gnunet-service-cadet.c.

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

220 {
221  static char buf[32];
222 
223  GNUNET_snprintf(buf,
224  sizeof(buf),
225  "Client(%u)",
226  c->id);
227  return buf;
228 }
int GNUNET_snprintf(char *buf, size_t size, const char *format,...)
Like snprintf, just aborts if the buffer is of insufficient size.
unsigned int id
ID of the client, mainly for debug messages.
static char buf[2048]
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

Handle to our configuration.

Handle to our configuration.

Definition at line 50 of file ats-testing.c.

◆ stats

struct GNUNET_STATISTICS_Handle* stats

Handle to the statistics service.

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

◆ ats_ch

Handle to communicate with ATS.

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

◆ my_full_id

struct GNUNET_PeerIdentity my_full_id

◆ my_private_key

struct GNUNET_CRYPTO_EddsaPrivateKey* my_private_key

Own private key.

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

Referenced by GCT_handle_kx_auth(), send_kx(), send_kx_auth(), and update_ax_by_kx().

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

Referenced by GCCH_channel_incoming_new(), and GCCH_channel_local_new().

◆ connections

struct GNUNET_CONTAINER_MultiShortmap* connections

Map from struct GNUNET_CADET_ConnectionTunnelIdentifier hash codes to struct CadetConnection objects.

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

Referenced by connect_nse_service(), connection_create(), GCC_destroy(), and GCC_lookup().

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

Referenced by GCCH_channel_incoming_new(), and GCCH_channel_local_new().

◆ peers

Map from PIDs to struct CadetPeer entries.

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

◆ ratchet_messages

unsigned long long ratchet_messages

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

Definition at line 179 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 184 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 189 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

Signal that shutdown is happening: prevent recovery measures.

Definition at line 135 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

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

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

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