GNUnet  0.11.x
Data Structures | Macros | Functions | Variables
gnunet-service-cadet.c File Reference

GNUnet CADET service with encryption. More...

#include "platform.h"
#include "gnunet_util_lib.h"
#include "cadet.h"
#include "gnunet_statistics_service.h"
#include "gnunet-service-cadet.h"
#include "gnunet-service-cadet_channel.h"
#include "gnunet-service-cadet_connection.h"
#include "gnunet-service-cadet_core.h"
#include "gnunet-service-cadet_dht.h"
#include "gnunet-service-cadet_hello.h"
#include "gnunet-service-cadet_tunnels.h"
#include "gnunet-service-cadet_peer.h"
#include "gnunet-service-cadet_paths.h"
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. More...
 
const char * GSC_2s (struct CadetClient *c)
 Return identifier for a client as a string. More...
 
static struct CadetChannellookup_channel (struct CadetClient *c, struct GNUNET_CADET_ClientChannelNumber ccn)
 Lookup channel of client c by ccn. More...
 
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. 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...
 
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. More...
 
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. More...
 
static void shutdown_rest ()
 Shutdown everything once the clients have disconnected. More...
 
static void shutdown_task (void *cls)
 Task run during shutdown. More...
 
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. More...
 
static void handle_port_open (void *cls, const struct GNUNET_CADET_PortMessage *pmsg)
 Handle port open request. More...
 
static void handle_port_close (void *cls, const struct GNUNET_CADET_PortMessage *pmsg)
 Handler for port close requests. More...
 
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. More...
 
static void handle_channel_destroy (void *cls, const struct GNUNET_CADET_LocalChannelDestroyMessage *msg)
 Handler for requests of destroying an existing channel. More...
 
static int check_local_data (void *cls, const struct GNUNET_CADET_LocalData *msg)
 Check for client traffic data message is well-formed. More...
 
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. More...
 
static void handle_local_ack (void *cls, const struct GNUNET_CADET_LocalAck *msg)
 Handler for client's ACKs for payload traffic. More...
 
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. More...
 
static void handle_get_peers (void *cls, const struct GNUNET_MessageHeader *message)
 Handler for client's INFO PEERS request. More...
 
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. More...
 
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. More...
 
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. More...
 
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. More...
 
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. 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...
 
static int channel_destroy_iterator (void *cls, uint32_t key, void *value)
 Iterator for deleting each channel whose client endpoint disconnected. More...
 
static int client_release_ports (void *cls, const struct GNUNET_HashCode *port, void *value)
 Remove client's ports from the global hashmap on disconnect. More...
 
static void client_disconnect_cb (void *cls, struct GNUNET_SERVICE_Client *client, void *internal_cls)
 Callback called when a client disconnected from the service. More...
 
static void run (void *cls, const struct GNUNET_CONFIGURATION_Handle *c, struct GNUNET_SERVICE_Handle *service)
 Setup CADET internals. More...
 
 GNUNET_SERVICE_MAIN ("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_handler_end())
 Define "main" method using service macro. 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...
 
int shutting_down
 Signal that shutdown is happening: prevent recovery measures. More...
 
static struct CadetClientclients_head
 DLL with all the clients, head. More...
 
static struct CadetClientclients_tail
 DLL with all the clients, tail. More...
 
static unsigned int next_client_id
 Next ID to assign to a client. More...
 
struct GNUNET_CONTAINER_MultiHashMapopen_ports
 All ports clients of this peer have opened. 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...
 
struct GNUNET_CONTAINER_MultiShortmapconnections
 Map from struct GNUNET_CADET_ConnectionTunnelIdentifier hash codes to struct CadetConnection objects. 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...
 
unsigned long long drop_percent
 Set to non-zero values to create random drops to test retransmissions. More...
 

Detailed Description

GNUnet CADET service with encryption.

Author
Bartlomiej Polot
Christian Grothoff

Dictionary:

Definition in file gnunet-service-cadet.c.

Macro Definition Documentation

◆ LOG

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

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.

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

207 {
208  GNUNET_MQ_send (c->mq,
209  env);
210 }
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:353
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_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.

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

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

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

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_local_ack(), and handle_local_data().

242 {
244  ntohl (ccn.channel_of_client));
245 }
uint32_t channel_of_client
Values for channel numbering.
Definition: cadet.h:111
struct GNUNET_CONTAINER_MultiHashMap32 * channels
Tunnels that belong to this client, indexed by local id, value is a struct CadetChannel.
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.
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 255 of file gnunet-service-cadet.c.

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

Referenced by GSC_bind().

256 {
258 
259  /* increment until we have a free one... */
260  while (NULL !=
261  lookup_channel (c,
262  ccn))
263  {
265  = htonl (1 + (ntohl (ccn.channel_of_client)));
266  if (ntohl (ccn.channel_of_client) >=
268  ccn.channel_of_client = htonl (0);
269  }
271  = htonl (1 + (ntohl (ccn.channel_of_client)));
272  return ccn;
273 }
static struct CadetChannel * lookup_channel(struct CadetClient *c, struct GNUNET_CADET_ClientChannelNumber ccn)
Lookup channel of client c by ccn.
uint32_t channel_of_client
Values for channel numbering.
Definition: cadet.h:111
Number uniquely identifying a channel of a client.
Definition: cadet.h:102
#define GNUNET_CADET_LOCAL_CHANNEL_ID_CLI
Minimum value for channel IDs of local clients.
Definition: cadet.h:71
struct GNUNET_CADET_ClientChannelNumber next_ccn
Channel ID to use for the next incoming channel for this client.
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 289 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().

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_CADET_ClientChannelNumber ccn
ID of a channel controlled by this client.
Definition: cadet.h:150
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:138
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:155
struct GNUNET_HashCode port
Port of the channel.
Definition: cadet.h:160
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:

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

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

Referenced by shutdown_rest().

339 {
340  struct CadetPeer *cp = value;
341  struct CadetTunnel *t = GCP_get_tunnel (cp,
342  GNUNET_NO);
343 
344  if (NULL != t)
346  return GNUNET_OK;
347 }
Peer description.
struct CadetTunnel * GCP_get_tunnel(struct CadetPeer *cp, int create)
Get the tunnel towards a peer.
#define GNUNET_NO
Definition: gnunet_common.h:78
#define GNUNET_OK
Named constants for return values.
Definition: gnunet_common.h:75
static struct GNUNET_SCHEDULER_Task * t
Main task.
static char * value
Value of the record to add/remove.
Struct containing all information regarding a tunnel to a peer.
void GCT_destroy_tunnel_now(struct CadetTunnel *t)
Destroys the tunnel t now, without delay.
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 360 of file gnunet-service-cadet.c.

References GCP_drop_owned_paths(), GNUNET_OK, and value.

Referenced by shutdown_rest().

363 {
364  struct CadetPeer *cp = value;
365 
367  return GNUNET_OK;
368 }
Peer description.
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...
#define GNUNET_OK
Named constants for return values.
Definition: gnunet_common.h:75
static char * value
Value of the record to add/remove.
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 375 of file gnunet-service-cadet.c.

References destroy_paths_now(), destroy_tunnels_now(), GCD_shutdown(), GCH_shutdown(), GCP_destroy_all_peers(), GCP_iterate_all(), GNUNET_ATS_connectivity_done(), GNUNET_CONTAINER_multihashmap_destroy(), GNUNET_CONTAINER_multipeermap_destroy(), GNUNET_CONTAINER_multishortmap_destroy(), GNUNET_free_non_null, GNUNET_NO, and GNUNET_STATISTICS_destroy().

Referenced by client_disconnect_cb(), and shutdown_task().

376 {
377  if (NULL != stats)
378  {
380  GNUNET_NO);
381  stats = NULL;
382  }
383  /* Destroy tunnels. Note that all channels must be destroyed first! */
385  NULL);
386  /* All tunnels, channels, connections and CORE must be down before this point. */
388  NULL);
389  /* All paths, tunnels, channels, connections and CORE must be down before this point. */
391  if (NULL != open_ports)
392  {
394  open_ports = NULL;
395  }
396  if (NULL != loose_channels)
397  {
399  loose_channels = NULL;
400  }
401  if (NULL != peers)
402  {
404  peers = NULL;
405  }
406  if (NULL != connections)
407  {
409  connections = NULL;
410  }
411  if (NULL != ats_ch)
412  {
414  ats_ch = NULL;
415  }
416  GCD_shutdown ();
417  GCH_shutdown ();
419  my_private_key = NULL;
420 }
struct GNUNET_CONTAINER_MultiPeerMap * peers
Map from PIDs to struct CadetPeer entries.
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.
struct GNUNET_ATS_ConnectivityHandle * ats_ch
Handle to communicate with ATS.
#define GNUNET_NO
Definition: gnunet_common.h:78
#define GNUNET_free_non_null(ptr)
Free the memory pointed to by ptr if ptr is not NULL.
void GCH_shutdown()
Shut down the hello subsystem.
void GNUNET_STATISTICS_destroy(struct GNUNET_STATISTICS_Handle *h, int sync_first)
Destroy a handle (free all state associated with it).
struct GNUNET_CONTAINER_MultiShortmap * connections
Map from struct GNUNET_CADET_ConnectionTunnelIdentifier hash codes to struct CadetConnection objects...
void GNUNET_CONTAINER_multipeermap_destroy(struct GNUNET_CONTAINER_MultiPeerMap *map)
Destroy a hash map.
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...
void GCP_destroy_all_peers()
Clean up all entries about all peers.
struct GNUNET_STATISTICS_Handle * stats
Handle to the statistics service.
void GNUNET_CONTAINER_multihashmap_destroy(struct GNUNET_CONTAINER_MultiHashMap *map)
Destroy a hash map.
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.
void GNUNET_CONTAINER_multishortmap_destroy(struct GNUNET_CONTAINER_MultiShortmap *map)
Destroy a hash map.
struct GNUNET_CRYPTO_EddsaPrivateKey * my_private_key
Own private key.
void GCP_iterate_all(GNUNET_CONTAINER_PeerMapIterator iter, void *cls)
Iterate over all known peers.
void GNUNET_ATS_connectivity_done(struct GNUNET_ATS_ConnectivityHandle *ch)
Client is done with ATS connectivity management, release resources.
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 429 of file gnunet-service-cadet.c.

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

Referenced by run().

430 {
432  "Shutting down\n");
434  GCO_shutdown ();
435  if (NULL == clients_head)
436  shutdown_rest ();
437 }
static struct CadetClient * clients_head
DLL with all the clients, head.
static void shutdown_rest()
Shutdown everything once the clients have disconnected.
void GCO_shutdown()
Shut down the CORE subsystem.
int shutting_down
Signal that shutdown is happening: prevent recovery measures.
#define GNUNET_log(kind,...)
#define GNUNET_YES
Definition: gnunet_common.h:77
Here is the call graph for this function:
Here is the caller 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
h_portthe hashed port
valuethe struct CadetChannel
Returns
GNUNET_YES (iterate over all such channels)

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

References OpenPort::c, GCCH_bind(), GNUNET_assert, GNUNET_CONTAINER_multihashmap_remove(), GNUNET_YES, OpenPort::h_port, op, OpenPort::port, and value.

Referenced by handle_port_open().

453 {
454  struct OpenPort *op = cls;
455  struct CadetChannel *ch = value;
456 
457  GCCH_bind (ch,
458  op->c,
459  &op->port);
462  &op->h_port,
463  ch));
464  return GNUNET_YES;
465 }
static struct GNUNET_CADET_Channel * ch
Channel handle.
Definition: gnunet-cadet.c:117
#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...
static char * value
Value of the record to add/remove.
struct GNUNET_HashCode h_port
Port hashed with our PID (matches incoming OPEN messages).
Struct containing all information regarding a channel to a remote client.
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.
struct GNUNET_HashCode port
Port number.
#define GNUNET_YES
Definition: gnunet_common.h:77
static struct GNUNET_ARM_Operation * op
Current operation.
Definition: gnunet-arm.c:144
struct CadetClient * c
Client that opened the port.
Port opened by a client.
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.
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 478 of file gnunet-service-cadet.c.

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_h2s(), GNUNET_new, GNUNET_NO, GNUNET_OK, GNUNET_SERVICE_client_continue(), GNUNET_SERVICE_client_drop(), GSC_2s(), OpenPort::h_port, LOG, my_full_id, op, GNUNET_CADET_PortMessage::port, OpenPort::port, and CadetClient::ports.

480 {
481  struct CadetClient *c = cls;
482  struct OpenPort *op;
483 
485  "Open port %s requested by %s\n",
486  GNUNET_h2s (&pmsg->port),
487  GSC_2s (c));
488  if (NULL == c->ports)
490  GNUNET_NO);
491  op = GNUNET_new (struct OpenPort);
492  op->c = c;
493  op->port = pmsg->port;
494  GCCH_hash_port (&op->h_port,
495  &pmsg->port,
496  &my_full_id);
497  if (GNUNET_OK !=
499  &op->port,
500  op,
502  {
503  GNUNET_break (0);
505  return;
506  }
508  &op->h_port,
509  op,
512  &op->h_port,
514  op);
516 }
struct GNUNET_PeerIdentity my_full_id
Local peer own ID.
#define GNUNET_NO
Definition: gnunet_common.h:78
#define GNUNET_OK
Named constants for return values.
Definition: gnunet_common.h:75
const char * GNUNET_h2s(const struct GNUNET_HashCode *hc)
Convert a hash value to a string (for printing debug messages).
#define GNUNET_new(type)
Allocate a struct or union of the given type.
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...
#define GNUNET_break(cond)
Use this for internal assertion violations that are not fatal (can be handled) but should not occur...
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...
struct GNUNET_HashCode h_port
Port hashed with our PID (matches incoming OPEN messages).
struct GNUNET_SERVICE_Client * client
Client handle.
#define LOG(level,...)
struct GNUNET_HashCode port
Port number.
void GNUNET_SERVICE_client_drop(struct GNUNET_SERVICE_Client *c)
Ask the server to disconnect from the given client.
Definition: service.c:2324
There must only be one value per key; storing a value should fail if a value under the same key alrea...
Struct containing information about a client of the service.
struct GNUNET_HashCode port
Port to open/close.
Definition: cadet.h:131
int 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 * ports
Ports that this client has declared interest in.
Allow multiple values with the same key.
int GNUNET_CONTAINER_multihashmap_get_multiple(struct GNUNET_CONTAINER_MultiHashMap *map, const struct GNUNET_HashCode *key, GNUNET_CONTAINER_MulitHashMapIteratorCallback it, void *it_cls)
Iterate over all entries in the map that match a particular key.
const char * GSC_2s(struct CadetClient *c)
Return identifier for a client as a string.
struct GNUNET_CONTAINER_MultiHashMap * GNUNET_CONTAINER_multihashmap_create(unsigned int len, int do_not_copy_keys)
Create a multi hash map.
static struct GNUNET_ARM_Operation * op
Current operation.
Definition: gnunet-arm.c:144
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 CadetClient * c
Client that opened the port.
void GNUNET_SERVICE_client_continue(struct GNUNET_SERVICE_Client *c)
Continue receiving further messages from the given client.
Definition: service.c:2243
Port opened by a client.
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 529 of file gnunet-service-cadet.c.

References 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(), OpenPort::h_port, LOG, op, GNUNET_CADET_PortMessage::port, OpenPort::port, and CadetClient::ports.

531 {
532  struct CadetClient *c = cls;
533  struct OpenPort *op;
534 
536  "Closing port %s as requested by %s\n",
537  GNUNET_h2s (&pmsg->port),
538  GSC_2s (c));
539  if (NULL == c->ports)
540  {
541  /* Client closed a port despite _never_ having opened one? */
542  GNUNET_break (0);
544  return;
545  }
547  &pmsg->port);
548  if (NULL == op)
549  {
550  GNUNET_break (0);
552  return;
553  }
556  &op->port,
557  op));
560  &op->h_port,
561  op));
562  GNUNET_free (op);
564 }
#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).
#define GNUNET_break(cond)
Use this for internal assertion violations that are not fatal (can be handled) but should not occur...
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.
struct GNUNET_CONTAINER_MultiHashMap * open_ports
All ports clients of this peer have opened.
struct GNUNET_HashCode h_port
Port hashed with our PID (matches incoming OPEN messages).
struct GNUNET_SERVICE_Client * client
Client handle.
#define LOG(level,...)
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.
struct GNUNET_HashCode port
Port number.
void GNUNET_SERVICE_client_drop(struct GNUNET_SERVICE_Client *c)
Ask the server to disconnect from the given client.
Definition: service.c:2324
Struct containing information about a client of the service.
struct GNUNET_HashCode port
Port to open/close.
Definition: cadet.h:131
struct GNUNET_CONTAINER_MultiHashMap * ports
Ports that this client has declared interest in.
const char * GSC_2s(struct CadetClient *c)
Return identifier for a client as a string.
#define GNUNET_YES
Definition: gnunet_common.h:77
static struct GNUNET_ARM_Operation * op
Current operation.
Definition: gnunet-arm.c:144
void GNUNET_SERVICE_client_continue(struct GNUNET_SERVICE_Client *c)
Continue receiving further messages from the given client.
Definition: service.c:2243
Port opened by a client.
#define GNUNET_free(ptr)
Wrapper around free.
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 574 of file gnunet-service-cadet.c.

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.

576 {
577  struct CadetClient *c = cls;
578  struct CadetChannel *ch;
579 
581  {
582  /* Channel ID not in allowed range. */
583  GNUNET_break (0);
585  return;
586  }
587  ch = lookup_channel (c,
588  tcm->ccn);
589  if (NULL != ch)
590  {
591  /* Channel ID already in use. Not allowed. */
592  GNUNET_break (0);
594  return;
595  }
597  "New channel to %s at port %s requested by %s\n",
598  GNUNET_i2s (&tcm->peer),
599  GNUNET_h2s (&tcm->port),
600  GSC_2s (c));
601 
602  /* Create channel */
603  ch = GCCH_channel_local_new (c,
604  tcm->ccn,
605  GCP_get (&tcm->peer,
606  GNUNET_YES),
607  &tcm->port,
608  ntohl (tcm->opt));
609  if (NULL == ch)
610  {
611  GNUNET_break (0);
613  return;
614  }
617  ntohl (
618  tcm->ccn.
619  channel_of_client),
620  ch,
622 
624 }
static struct CadetChannel * lookup_channel(struct CadetClient *c, struct GNUNET_CADET_ClientChannelNumber ccn)
Lookup channel of client c by ccn.
static struct GNUNET_CADET_Channel * ch
Channel handle.
Definition: gnunet-cadet.c:117
struct GNUNET_CADET_ClientChannelNumber ccn
ID of a channel controlled by this client.
Definition: cadet.h:150
uint32_t channel_of_client
Values for channel numbering.
Definition: cadet.h:111
#define GNUNET_assert(cond)
Use this for fatal errors that cannot be handled.
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).
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.
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.
#define GNUNET_break(cond)
Use this for internal assertion violations that are not fatal (can be handled) but should not occur...
Struct containing all information regarding a channel to a remote client.
struct GNUNET_SERVICE_Client * client
Client handle.
#define LOG(level,...)
#define GNUNET_CADET_LOCAL_CHANNEL_ID_CLI
Minimum value for channel IDs of local clients.
Definition: cadet.h:71
void GNUNET_SERVICE_client_drop(struct GNUNET_SERVICE_Client *c)
Ask the server to disconnect from the given client.
Definition: service.c:2324
There must only be one value per key; storing a value should fail if a value under the same key alrea...
Struct containing information about a client of the service.
struct CadetPeer * GCP_get(const struct GNUNET_PeerIdentity *peer_id, int create)
Retrieve the CadetPeer stucture associated with the peer.
const char * GSC_2s(struct CadetClient *c)
Return identifier for a client as a string.
#define GNUNET_YES
Definition: gnunet_common.h:77
struct GNUNET_PeerIdentity peer
Channel's peer.
Definition: cadet.h:155
const char * GNUNET_i2s(const struct GNUNET_PeerIdentity *pid)
Convert a peer identity to a string (for printing debug messages).
void GNUNET_SERVICE_client_continue(struct GNUNET_SERVICE_Client *c)
Continue receiving further messages from the given client.
Definition: service.c:2243
struct GNUNET_HashCode port
Port of the channel.
Definition: cadet.h:160
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 634 of file gnunet-service-cadet.c.

References GNUNET_CADET_LocalChannelDestroyMessage::ccn, ch, GNUNET_CADET_ClientChannelNumber::channel_of_client, 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, and lookup_channel().

637 {
638  struct CadetClient *c = cls;
639  struct CadetChannel *ch;
640 
641  ch = lookup_channel (c,
642  msg->ccn);
643  if (NULL == ch)
644  {
645  /* Client attempted to destroy unknown channel.
646  Can happen if the other side went down at the same time.*/
648  "%s tried to destroy unknown channel %X\n",
649  GSC_2s (c),
650  (uint32_t) ntohl (msg->ccn.channel_of_client));
652  return;
653  }
655  "%s is destroying %s\n",
656  GSC_2s (c),
657  GCCH_2s (ch));
660  ntohl (
661  msg->ccn.
662  channel_of_client),
663  ch));
665  c,
666  msg->ccn);
668 }
static struct CadetChannel * lookup_channel(struct CadetClient *c, struct GNUNET_CADET_ClientChannelNumber ccn)
Lookup channel of client c by ccn.
static struct GNUNET_CADET_Channel * ch
Channel handle.
Definition: gnunet-cadet.c:117
uint32_t channel_of_client
Values for channel numbering.
Definition: cadet.h:111
#define GNUNET_assert(cond)
Use this for fatal errors that cannot be handled.
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 containing all information regarding a channel to a remote client.
struct GNUNET_SERVICE_Client * client
Client handle.
#define LOG(level,...)
Struct containing information about a client of the service.
void GCCH_channel_local_destroy(struct CadetChannel *ch, struct CadetClient *c, struct GNUNET_CADET_ClientChannelNumber ccn)
Destroy locally created channel.
const char * GCCH_2s(const struct CadetChannel *ch)
Get the static string for identification of the channel.
struct GNUNET_CADET_ClientChannelNumber ccn
ID of a channel controlled by this client.
Definition: cadet.h:182
const char * GSC_2s(struct CadetClient *c)
Return identifier for a client as a string.
#define GNUNET_YES
Definition: gnunet_common.h:77
void GNUNET_SERVICE_client_continue(struct GNUNET_SERVICE_Client *c)
Continue receiving further messages from the given client.
Definition: service.c:2243
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 679 of file gnunet-service-cadet.c.

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

681 {
682  size_t payload_size;
683  size_t payload_claimed_size;
684  const char *buf;
685  struct GNUNET_MessageHeader pa;
686 
687  /* FIXME: what is the format we shall allow for @a msg?
688  ONE payload item or multiple? Seems current cadet_api
689  at least in theory allows more than one. Next-gen
690  cadet_api will likely no more, so we could then
691  simplify this mess again. *//* Sanity check for message size */payload_size = ntohs (msg->header.size) - sizeof(*msg);
692  buf = (const char *) &msg[1];
693  while (payload_size >= sizeof(struct GNUNET_MessageHeader))
694  {
695  /* need to memcpy() for alignment */
696  GNUNET_memcpy (&pa,
697  buf,
698  sizeof(pa));
699  payload_claimed_size = ntohs (pa.size);
700  if ((payload_size < payload_claimed_size) ||
701  (payload_claimed_size < sizeof(struct GNUNET_MessageHeader)) ||
702  (GNUNET_CONSTANTS_MAX_CADET_MESSAGE_SIZE < payload_claimed_size))
703  {
704  GNUNET_break (0);
706  "Local data of %u total size had sub-message %u at %u with %u bytes\n",
707  ntohs (msg->header.size),
708  ntohs (pa.type),
709  (unsigned int) (buf - (const char *) &msg[1]),
710  (unsigned int) payload_claimed_size);
711  return GNUNET_SYSERR;
712  }
713  payload_size -= payload_claimed_size;
714  buf += payload_claimed_size;
715  }
716  if (0 != payload_size)
717  {
718  GNUNET_break_op (0);
719  return GNUNET_SYSERR;
720  }
721  return GNUNET_OK;
722 }
#define GNUNET_memcpy(dst, src, n)
Call memcpy() but check for n being 0 first.
#define GNUNET_OK
Named constants for return values.
Definition: gnunet_common.h:75
uint16_t size
The length of the struct (in bytes, including the length field itself), in big-endian format...
#define GNUNET_break(cond)
Use this for internal assertion violations that are not fatal (can be handled) but should not occur...
#define GNUNET_break_op(cond)
Use this for assertion violations caused by other peers (i.e.
#define LOG(level,...)
static char buf[2048]
#define GNUNET_CONSTANTS_MAX_CADET_MESSAGE_SIZE
Maximum message size that can be sent on CADET.
#define GNUNET_SYSERR
Definition: gnunet_common.h:76
Header for all communications.
struct GNUNET_MessageHeader header
Type: GNUNET_MESSAGE_TYPE_CADET_LOCAL_DATA.
Definition: cadet.h:194

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

References buf, GNUNET_CADET_LocalData::ccn, ch, GNUNET_CADET_ClientChannelNumber::channel_of_client, 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(), GNUNET_CADET_LocalData::header, LOG, lookup_channel(), and GNUNET_MessageHeader::size.

735 {
736  struct CadetClient *c = cls;
737  struct CadetChannel *ch;
738  size_t payload_size;
739  const char *buf;
740 
741  ch = lookup_channel (c,
742  msg->ccn);
743  if (NULL == ch)
744  {
745  /* Channel does not exist (anymore) */
747  "Dropping payload for channel %u from client (channel unknown, other endpoint may have disconnected)\n",
748  (unsigned int) ntohl (msg->ccn.channel_of_client));
750  return;
751  }
752  payload_size = ntohs (msg->header.size) - sizeof(*msg);
754  "# payload received from clients",
755  payload_size,
756  GNUNET_NO);
757  buf = (const char *) &msg[1];
759  "Received %u bytes payload from %s for %s\n",
760  (unsigned int) payload_size,
761  GSC_2s (c),
762  GCCH_2s (ch));
763  if (GNUNET_OK !=
765  msg->ccn,
766  buf,
767  payload_size))
768  {
769  GNUNET_break (0);
771  return;
772  }
774 }
static struct CadetChannel * lookup_channel(struct CadetClient *c, struct GNUNET_CADET_ClientChannelNumber ccn)
Lookup channel of client c by ccn.
static struct GNUNET_CADET_Channel * ch
Channel handle.
Definition: gnunet-cadet.c:117
uint32_t channel_of_client
Values for channel numbering.
Definition: cadet.h:111
#define GNUNET_NO
Definition: gnunet_common.h:78
#define GNUNET_OK
Named constants for return values.
Definition: gnunet_common.h:75
uint16_t size
The length of the struct (in bytes, including the length field itself), in big-endian format...
void GNUNET_STATISTICS_update(struct GNUNET_STATISTICS_Handle *handle, const char *name, int64_t delta, int make_persistent)
Set statistic value for the peer.
#define GNUNET_break(cond)
Use this for internal assertion violations that are not fatal (can be handled) but should not occur...
struct GNUNET_STATISTICS_Handle * stats
Handle to the statistics service.
Struct containing all information regarding a channel to a remote client.
struct GNUNET_SERVICE_Client * client
Client handle.
#define LOG(level,...)
static char buf[2048]
struct GNUNET_CADET_ClientChannelNumber ccn
ID of the channel.
Definition: cadet.h:199
void GNUNET_SERVICE_client_drop(struct GNUNET_SERVICE_Client *c)
Ask the server to disconnect from the given client.
Definition: service.c:2324
Struct containing information about a client of the service.
const char * GCCH_2s(const struct CadetChannel *ch)
Get the static string for identification of the channel.
const char * GSC_2s(struct CadetClient *c)
Return identifier for a client as a string.
struct GNUNET_MessageHeader header
Type: GNUNET_MESSAGE_TYPE_CADET_LOCAL_DATA.
Definition: cadet.h:194
void GNUNET_SERVICE_client_continue(struct GNUNET_SERVICE_Client *c)
Continue receiving further messages from the given client.
Definition: service.c:2243
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.
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 784 of file gnunet-service-cadet.c.

References GNUNET_CADET_LocalAck::ccn, ch, GNUNET_CADET_ClientChannelNumber::channel_of_client, CadetClient::client, GCCH_2s(), GCCH_handle_local_ack(), GNUNET_ERROR_TYPE_DEBUG, GNUNET_ERROR_TYPE_WARNING, GNUNET_SERVICE_client_continue(), GSC_2s(), LOG, and lookup_channel().

786 {
787  struct CadetClient *c = cls;
788  struct CadetChannel *ch;
789 
790  ch = lookup_channel (c,
791  msg->ccn);
792  if (NULL == ch)
793  {
794  /* Channel does not exist (anymore) */
796  "Ignoring local ACK for channel %u from client (channel unknown, other endpoint may have disconnected)\n",
797  (unsigned int) ntohl (msg->ccn.channel_of_client));
799  return;
800  }
802  "Got a local ACK from %s for %s\n",
803  GSC_2s (c),
804  GCCH_2s (ch));
806  msg->ccn);
808 }
static struct CadetChannel * lookup_channel(struct CadetClient *c, struct GNUNET_CADET_ClientChannelNumber ccn)
Lookup channel of client c by ccn.
static struct GNUNET_CADET_Channel * ch
Channel handle.
Definition: gnunet-cadet.c:117
uint32_t channel_of_client
Values for channel numbering.
Definition: cadet.h:111
void GCCH_handle_local_ack(struct CadetChannel *ch, struct GNUNET_CADET_ClientChannelNumber client_ccn)
Handle ACK from client on local channel.
Struct containing all information regarding a channel to a remote client.
struct GNUNET_SERVICE_Client * client
Client handle.
#define LOG(level,...)
Struct containing information about a client of the service.
struct GNUNET_CADET_ClientChannelNumber ccn
ID of the channel allowed to send more data.
Definition: cadet.h:227
const char * GCCH_2s(const struct CadetChannel *ch)
Get the static string for identification of the channel.
const char * GSC_2s(struct CadetClient *c)
Return identifier for a client as a string.
void GNUNET_SERVICE_client_continue(struct GNUNET_SERVICE_Client *c)
Continue receiving further messages from the given client.
Definition: service.c:2243
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 820 of file gnunet-service-cadet.c.

References GNUNET_CADET_LocalInfoPeers::best_path_length, GNUNET_CADET_LocalInfoPeers::destination, 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, GNUNET_CADET_LocalInfoPeers::paths, peer, GNUNET_CADET_LocalInfoPeers::tunnel, and value.

Referenced by handle_get_peers().

823 {
824  struct CadetClient *c = cls;
825  struct CadetPeer *p = value;
826  struct GNUNET_MQ_Envelope *env;
828 
829  env = GNUNET_MQ_msg (msg,
831  msg->destination = *peer;
832  msg->paths = htons (GCP_count_paths (p));
833  msg->tunnel = htons (NULL != GCP_get_tunnel (p,
834  GNUNET_NO));
835  msg->best_path_length = htonl (0); // FIXME: get length of shortest known path!
836  GNUNET_MQ_send (c->mq,
837  env);
838  return GNUNET_YES;
839 }
Peer description.
struct GNUNET_MessageHeader * msg
Definition: 005.c:2
struct CadetTunnel * GCP_get_tunnel(struct CadetPeer *cp, int create)
Get the tunnel towards a peer.
uint32_t best_path_length
Shortest known path.
Definition: cadet.h:359
#define GNUNET_MQ_msg(mvar, type)
Allocate a GNUNET_MQ_Envelope.
Definition: gnunet_mq_lib.h:67
#define GNUNET_NO
Definition: gnunet_common.h:78
uint16_t paths
Number of paths.
Definition: cadet.h:349
int16_t tunnel
Do we have a tunnel toward this peer?
Definition: cadet.h:354
static struct GNUNET_OS_Process * p
Helper process we started.
Definition: gnunet-qr.c:59
static char * value
Value of the record to add/remove.
Message to inform the client about one of the peers in the service.
Definition: cadet.h:339
Struct containing information about a client of the service.
struct GNUNET_TESTBED_Peer * peer
The peer associated with this model.
struct GNUNET_MQ_Envelope * env
Definition: 005.c:1
#define GNUNET_MESSAGE_TYPE_CADET_LOCAL_INFO_PEERS
Local information about all peers known to the service.
struct GNUNET_PeerIdentity destination
ID of the peer (can be local peer).
Definition: cadet.h:364
#define GNUNET_YES
Definition: gnunet_common.h:77
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:353
unsigned int GCP_count_paths(const struct CadetPeer *cp)
Count the number of known paths toward the peer.
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:

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

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.

851 {
852  struct CadetClient *c = cls;
853  struct GNUNET_MQ_Envelope *env;
854  struct GNUNET_MessageHeader *reply;
855 
857  c);
858  env = GNUNET_MQ_msg (reply,
860  GNUNET_MQ_send (c->mq,
861  env);
863 }
#define GNUNET_MQ_msg(mvar, type)
Allocate a GNUNET_MQ_Envelope.
Definition: gnunet_mq_lib.h:67
#define GNUNET_MESSAGE_TYPE_CADET_LOCAL_INFO_PEERS_END
End of local information about all peers known to the service.
struct GNUNET_SERVICE_Client * client
Client handle.
Struct containing information about a client of the service.
struct GNUNET_MQ_Envelope * env
Definition: 005.c:1
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.
Header for all communications.
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:353
void GCP_iterate_all(GNUNET_CONTAINER_PeerMapIterator iter, void *cls)
Iterate over all known peers.
void GNUNET_SERVICE_client_continue(struct GNUNET_SERVICE_Client *c)
Continue receiving further messages from the given client.
Definition: service.c:2243
struct GNUNET_MQ_Handle * mq
Handle to communicate with the client.
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 877 of file gnunet-service-cadet.c.

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, CadetClient::id, LOG, CadetClient::mq, and GNUNET_CADET_LocalInfoPath::off.

Referenced by handle_show_path().

880 {
881  struct GNUNET_MQ_Handle *mq = cls;
882  struct GNUNET_MQ_Envelope *env;
883  struct GNUNET_CADET_LocalInfoPath *resp;
884  struct GNUNET_PeerIdentity *id;
885  size_t path_size;
886  unsigned int path_length;
887 
888  path_length = GCPP_get_length (path);
889  path_size = sizeof(struct GNUNET_PeerIdentity) * path_length;
890  if (sizeof(*resp) + path_size > UINT16_MAX)
891  {
892  /* try just giving the relevant path */
893  path_length = GNUNET_MIN ((UINT16_MAX - sizeof(*resp)) / sizeof(struct
895  off);
896  path_size = sizeof(struct GNUNET_PeerIdentity) * path_length;
897  }
898  if (sizeof(*resp) + path_size > UINT16_MAX)
899  {
901  "Path of %u entries is too long for info message\n",
902  path_length);
903  return GNUNET_YES;
904  }
905  env = GNUNET_MQ_msg_extra (resp,
906  path_size,
908  id = (struct GNUNET_PeerIdentity *) &resp[1];
909 
910  /* Don't copy first peer. First peer is always the local one. Last
911  * peer is always the destination (leave as 0, EOL).
912  */
913  for (unsigned int i = 0; i < path_length; i++)
914  id[i] = *GCP_get_id (GCPP_get_peer_at_offset (path,
915  i));
916  resp->off = htonl (off);
917  GNUNET_MQ_send (mq,
918  env);
919  return GNUNET_YES;
920 }
#define GNUNET_MESSAGE_TYPE_CADET_LOCAL_INFO_PATH
Local information of service about a specific path.
static struct GNUNET_IDENTITY_Handle * id
Handle to identity service.
Message to inform the client about one of the paths known to the service.
Definition: cadet.h:322
#define GNUNET_MQ_msg_extra(mvar, esize, type)
Allocate an envelope, with extra space allocated after the space needed by the message struct...
Definition: gnunet_mq_lib.h:52
#define GNUNET_MIN(a, b)
Definition: gnunet_common.h:80
#define LOG(level,...)
uint32_t off
Offset of the peer that was requested.
Definition: cadet.h:332
struct GNUNET_MQ_Envelope * env
Definition: 005.c:1
Handle to a message queue.
Definition: mq.c:85
The identity of the host (wraps the signing key of the peer).
struct GNUNET_MQ_Handle * mq
Definition: 003.c:5
struct CadetPeer * GCPP_get_peer_at_offset(struct CadetPeerPath *path, unsigned int off)
Obtain the peer at offset off in path.
#define GNUNET_YES
Definition: gnunet_common.h:77
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:353
unsigned int GCPP_get_length(struct CadetPeerPath *path)
Return the length of the path.
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:

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

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, p, path_info_iterator(), and GNUNET_CADET_RequestPathInfoMessage::peer.

932 {
933  struct CadetClient *c = cls;
934  struct CadetPeer *p;
935  struct GNUNET_MQ_Envelope *env;
936  struct GNUNET_MessageHeader *resp;
937 
938  p = GCP_get (&msg->peer,
939  GNUNET_NO);
940  if (NULL != p)
943  c->mq);
944  env = GNUNET_MQ_msg (resp,
946  GNUNET_MQ_send (c->mq,
947  env);
949 }
Peer description.
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.
#define GNUNET_MQ_msg(mvar, type)
Allocate a GNUNET_MQ_Envelope.
Definition: gnunet_mq_lib.h:67
#define GNUNET_NO
Definition: gnunet_common.h:78
struct GNUNET_PeerIdentity peer
ID of the destination of the channel (can be local peer).
Definition: cadet.h:274
static struct GNUNET_OS_Process * p
Helper process we started.
Definition: gnunet-qr.c:59
struct GNUNET_SERVICE_Client * client
Client handle.
Struct containing information about a client of the service.
struct GNUNET_MQ_Envelope * env
Definition: 005.c:1
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.
struct CadetPeer * GCP_get(const struct GNUNET_PeerIdentity *peer_id, int create)
Retrieve the CadetPeer stucture associated with the peer.
#define GNUNET_MESSAGE_TYPE_CADET_LOCAL_INFO_PATH_END
End of local information of service about a specific path.
Header for all communications.
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:353
void GNUNET_SERVICE_client_continue(struct GNUNET_SERVICE_Client *c)
Continue receiving further messages from the given client.
Definition: service.c:2243
struct GNUNET_MQ_Handle * mq
Handle to communicate with the client.
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 961 of file gnunet-service-cadet.c.

References GNUNET_CADET_LocalInfoTunnel::channels, GNUNET_CADET_LocalInfoTunnel::connections, GNUNET_CADET_LocalInfoTunnel::cstate, GNUNET_CADET_LocalInfoTunnel::destination, env, GNUNET_CADET_LocalInfoTunnel::estate, 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, peer, t, and value.

Referenced by handle_info_tunnels().

964 {
965  struct CadetClient *c = cls;
966  struct CadetPeer *p = value;
967  struct GNUNET_MQ_Envelope *env;
969  struct CadetTunnel *t;
970 
971  t = GCP_get_tunnel (p,
972  GNUNET_NO);
973  if (NULL == t)
974  return GNUNET_YES;
975  env = GNUNET_MQ_msg (msg,
977  msg->destination = *peer;
978  msg->channels = htonl (GCT_count_channels (t));
979  msg->connections = htonl (GCT_count_any_connections (t));
980  msg->cstate = htons (0);
981  msg->estate = htons ((uint16_t) GCT_get_estate (t));
982  GNUNET_MQ_send (c->mq,
983  env);
984  return GNUNET_YES;
985 }
uint16_t cstate
Connection state.
Definition: cadet.h:404
Peer description.
struct GNUNET_MessageHeader * msg
Definition: 005.c:2
enum CadetTunnelEState GCT_get_estate(struct CadetTunnel *t)
Get the encryption state of a tunnel.
struct CadetTunnel * GCP_get_tunnel(struct CadetPeer *cp, int create)
Get the tunnel towards a peer.
struct GNUNET_PeerIdentity destination
ID of the destination of the tunnel (can be local peer).
Definition: cadet.h:389
unsigned int GCT_count_any_connections(const struct CadetTunnel *t)
Count all created connections of a tunnel.
#define GNUNET_MQ_msg(mvar, type)
Allocate a GNUNET_MQ_Envelope.
Definition: gnunet_mq_lib.h:67
#define GNUNET_NO
Definition: gnunet_common.h:78
static struct GNUNET_SCHEDULER_Task * t
Main task.
#define GNUNET_MESSAGE_TYPE_CADET_LOCAL_INFO_TUNNELS
Local information about all tunnels of service.
static struct GNUNET_OS_Process * p
Helper process we started.
Definition: gnunet-qr.c:59
static char * value
Value of the record to add/remove.
Message to inform the client about one of the tunnels in the service.
Definition: cadet.h:373
Struct containing all information regarding a tunnel to a peer.
Struct containing information about a client of the service.
struct GNUNET_TESTBED_Peer * peer
The peer associated with this model.
struct GNUNET_MQ_Envelope * env
Definition: 005.c:1
uint32_t connections
Number of connections.
Definition: cadet.h:394
uint32_t channels
Number of channels.
Definition: cadet.h:384
uint16_t estate
Encryption state.
Definition: cadet.h:399
unsigned int GCT_count_channels(struct CadetTunnel *t)
Count channels of a tunnel.
#define GNUNET_YES
Definition: gnunet_common.h:77
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:353
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:

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

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.

997 {
998  struct CadetClient *c = cls;
999  struct GNUNET_MQ_Envelope *env;
1000  struct GNUNET_MessageHeader *reply;
1001 
1003  c);
1004  env = GNUNET_MQ_msg (reply,
1006  GNUNET_MQ_send (c->mq,
1007  env);
1009 }
#define GNUNET_MQ_msg(mvar, type)
Allocate a GNUNET_MQ_Envelope.
Definition: gnunet_mq_lib.h:67
struct GNUNET_SERVICE_Client * client
Client handle.
Struct containing information about a client of the service.
#define GNUNET_MESSAGE_TYPE_CADET_LOCAL_INFO_TUNNELS_END
End of local information about all tunnels of service.
struct GNUNET_MQ_Envelope * env
Definition: 005.c:1
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.
Header for all communications.
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:353
void GCP_iterate_all(GNUNET_CONTAINER_PeerMapIterator iter, void *cls)
Iterate over all known peers.
void GNUNET_SERVICE_client_continue(struct GNUNET_SERVICE_Client *c)
Continue receiving further messages from the given client.
Definition: service.c:2243
struct GNUNET_MQ_Handle * mq
Handle to communicate with the client.
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 1021 of file gnunet-service-cadet.c.

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

Referenced by run().

1024 {
1025  struct CadetClient *c;
1026 
1027  c = GNUNET_new (struct CadetClient);
1028  c->client = client;
1029  c->mq = mq;
1030  c->id = next_client_id++; /* overflow not important: just for debug */
1031  c->channels
1034  clients_tail,
1035  c);
1037  "# clients",
1038  +1,
1039  GNUNET_NO);
1041  "%s connected\n",
1042  GSC_2s (c));
1043  return c;
1044 }
static unsigned int next_client_id
Next ID to assign to a client.
static struct CadetClient * clients_head
DLL with all the clients, head.
#define GNUNET_CONTAINER_DLL_insert(head, tail, element)
Insert an element at the head of a DLL.
static struct CadetClient * clients_tail
DLL with all the clients, tail.
#define GNUNET_NO
Definition: gnunet_common.h:78
struct GNUNET_CONTAINER_MultiHashMap32 * channels
Tunnels that belong to this client, indexed by local id, value is a struct CadetChannel.
#define GNUNET_new(type)
Allocate a struct or union of the given type.
unsigned int id
ID of the client, mainly for debug messages.
void GNUNET_STATISTICS_update(struct GNUNET_STATISTICS_Handle *handle, const char *name, int64_t delta, int make_persistent)
Set statistic value for the peer.
struct GNUNET_STATISTICS_Handle * stats
Handle to the statistics service.
struct GNUNET_SERVICE_Client * client
Client handle.
#define LOG(level,...)
struct GNUNET_CONTAINER_MultiHashMap32 * GNUNET_CONTAINER_multihashmap32_create(unsigned int len)
Create a 32-bit key multi hash map.
Struct containing information about a client of the service.
struct GNUNET_MQ_Handle * mq
Definition: 003.c:5
const char * GSC_2s(struct CadetClient *c)
Return identifier for a client as a string.
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 1055 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().

1058 {
1059  struct GNUNET_MQ_Envelope *env;
1061 
1062  env = GNUNET_MQ_msg (tdm,
1064  tdm->ccn = ccn;
1065  GSC_send_to_client (c,
1066  env);
1069  ntohl (
1070  ccn.channel_of_client),
1071  ch));
1072 }
uint32_t channel_of_client
Values for channel numbering.
Definition: cadet.h:111
Message for or to a client to destroy tunnel.
Definition: cadet.h:172
#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:182
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 1083 of file gnunet-service-cadet.c.

References GNUNET_assert, GNUNET_CONTAINER_multihashmap_remove(), and GNUNET_YES.

Referenced by channel_destroy().

1085 {
1088  h_port,
1089  ch));
1090 }
#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:

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

References 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(), LOG, and value.

Referenced by client_disconnect_cb().

1105 {
1106  struct CadetClient *c = cls;
1108  struct CadetChannel *ch = value;
1109 
1111  "Destroying %s, due to %s disconnecting.\n",
1112  GCCH_2s (ch),
1113  GSC_2s (c));
1114  ccn.channel_of_client = htonl (key);
1116  c,
1117  ccn);
1120  key,
1121  ch));
1122  return GNUNET_OK;
1123 }
static struct GNUNET_CADET_Channel * ch
Channel handle.
Definition: gnunet-cadet.c:117
#define GNUNET_assert(cond)
Use this for fatal errors that cannot be handled.
struct GNUNET_CONTAINER_MultiHashMap32 * channels
Tunnels that belong to this client, indexed by local id, value is a struct CadetChannel.
#define GNUNET_OK
Named constants for return values.
Definition: gnunet_common.h:75
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.
static char * value
Value of the record to add/remove.
Struct containing all information regarding a channel to a remote client.
#define LOG(level,...)
Number uniquely identifying a channel of a client.
Definition: cadet.h:102
Struct containing information about a client of the service.
struct GNUNET_HashCode key
The key used in the DHT.
void GCCH_channel_local_destroy(struct CadetChannel *ch, struct CadetClient *c, struct GNUNET_CADET_ClientChannelNumber ccn)
Destroy locally created channel.
const char * GCCH_2s(const struct CadetChannel *ch)
Get the static string for identification of the channel.
const char * GSC_2s(struct CadetClient *c)
Return identifier for a client as a string.
#define GNUNET_YES
Definition: gnunet_common.h:77
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 1135 of file gnunet-service-cadet.c.

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

Referenced by client_disconnect_cb().

1138 {
1139  struct CadetClient *c = cls;
1140  struct OpenPort *op = value;
1141 
1142  GNUNET_assert (c == op->c);
1144  "Closing port %s due to %s disconnect.\n",
1145  GNUNET_h2s (port),
1146  GSC_2s (c));
1149  &op->h_port,
1150  op));
1153  port,
1154  op));
1155  GNUNET_free (op);
1156  return GNUNET_OK;
1157 }
#define GNUNET_assert(cond)
Use this for fatal errors that cannot be handled.
#define GNUNET_OK
Named constants for return values.
Definition: gnunet_common.h:75
const char * GNUNET_h2s(const struct GNUNET_HashCode *hc)
Convert a hash value to a string (for printing debug messages).
struct GNUNET_CONTAINER_MultiHashMap * open_ports
All ports clients of this peer have opened.
static char * value
Value of the record to add/remove.
struct GNUNET_HashCode h_port
Port hashed with our PID (matches incoming OPEN messages).
#define LOG(level,...)
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.
Struct containing information about a client of the service.
struct GNUNET_CONTAINER_MultiHashMap * ports
Ports that this client has declared interest in.
const char * GSC_2s(struct CadetClient *c)
Return identifier for a client as a string.
#define GNUNET_YES
Definition: gnunet_common.h:77
static struct GNUNET_ARM_Operation * op
Current operation.
Definition: gnunet-arm.c:144
struct CadetClient * c
Client that opened the port.
Port opened by a client.
#define GNUNET_free(ptr)
Wrapper around free.
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 1168 of file gnunet-service-cadet.c.

References channel_destroy_iterator(), CadetClient::channels, CadetClient::client, client_release_ports(), 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(), and shutting_down.

Referenced by run().

1171 {
1172  struct CadetClient *c = internal_cls;
1173 
1174  GNUNET_assert (c->client == client);
1176  "%s is disconnecting.\n",
1177  GSC_2s (c));
1178  if (NULL != c->channels)
1179  {
1182  c);
1185  }
1186  if (NULL != c->ports)
1187  {
1190  c);
1192  }
1194  clients_tail,
1195  c);
1197  "# clients",
1198  -1,
1199  GNUNET_NO);
1200  GNUNET_free (c);
1201  if ((NULL == clients_head) &&
1203  shutdown_rest ();
1204 }
#define GNUNET_CONTAINER_DLL_remove(head, tail, element)
Remove an element from a DLL.
static struct CadetClient * clients_head
DLL with all the clients, head.
static void shutdown_rest()
Shutdown everything once the clients have disconnected.
int GNUNET_CONTAINER_multihashmap32_iterate(struct GNUNET_CONTAINER_MultiHashMap32 *map, GNUNET_CONTAINER_MulitHashMapIterator32Callback it, void *it_cls)
Iterate over all entries in the map.
#define GNUNET_assert(cond)
Use this for fatal errors that cannot be handled.
static struct CadetClient * clients_tail
DLL with all the clients, tail.
#define GNUNET_NO
Definition: gnunet_common.h:78
struct GNUNET_CONTAINER_MultiHashMap32 * channels
Tunnels that belong to this client, indexed by local id, value is a struct CadetChannel.
void GNUNET_STATISTICS_update(struct GNUNET_STATISTICS_Handle *handle, const char *name, int64_t delta, int make_persistent)
Set statistic value for the peer.
struct GNUNET_STATISTICS_Handle * stats
Handle to the statistics service.
struct GNUNET_SERVICE_Client * client
Client handle.
void GNUNET_CONTAINER_multihashmap_destroy(struct GNUNET_CONTAINER_MultiHashMap *map)
Destroy a hash map.
#define LOG(level,...)
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.
Struct containing information about a client of the service.
struct GNUNET_CONTAINER_MultiHashMap * ports
Ports that this client has declared interest in.
int shutting_down
Signal that shutdown is happening: prevent recovery measures.
const char * GSC_2s(struct CadetClient *c)
Return identifier for a client as a string.
static int client_release_ports(void *cls, const struct GNUNET_HashCode *port, void *value)
Remove client&#39;s ports from the global hashmap on disconnect.
#define GNUNET_YES
Definition: gnunet_common.h:77
int GNUNET_CONTAINER_multihashmap_iterate(struct GNUNET_CONTAINER_MultiHashMap *map, GNUNET_CONTAINER_MulitHashMapIteratorCallback it, void *it_cls)
Iterate over all entries in the map.
static int channel_destroy_iterator(void *cls, uint32_t key, void *value)
Iterator for deleting each channel whose client endpoint disconnected.
#define GNUNET_free(ptr)
Wrapper around free.
Here is the call graph for this function:
Here is the caller graph for this function:

◆ run()

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

Setup CADET internals.

Parameters
clsclosure
serverthe initialized server
cconfiguration to use

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

References channel_destroy(), client_connect_cb(), client_disconnect_cb(), drop_percent, GCD_init(), GCH_init(), GCO_init(), get_peers(), GNUNET_ATS_connectivity_init(), GNUNET_break, GNUNET_CONFIGURATION_get_value_number(), GNUNET_CONFIGURATION_get_value_time(), GNUNET_CONTAINER_multihashmap_create(), GNUNET_CONTAINER_multipeermap_create(), GNUNET_CONTAINER_multishortmap_create(), GNUNET_CRYPTO_eddsa_key_create_from_configuration(), GNUNET_CRYPTO_eddsa_key_get_public(), GNUNET_ERROR_TYPE_INFO, GNUNET_ERROR_TYPE_WARNING, GNUNET_i2s(), GNUNET_log, GNUNET_log_config_invalid(), GNUNET_MESSAGE_TYPE_CADET_LOCAL_ACK, GNUNET_MESSAGE_TYPE_CADET_LOCAL_CHANNEL_CREATE, GNUNET_MESSAGE_TYPE_CADET_LOCAL_CHANNEL_DESTROY, GNUNET_MESSAGE_TYPE_CADET_LOCAL_DATA, GNUNET_MESSAGE_TYPE_CADET_LOCAL_PORT_CLOSE, GNUNET_MESSAGE_TYPE_CADET_LOCAL_PORT_OPEN, GNUNET_MESSAGE_TYPE_CADET_LOCAL_REQUEST_INFO_PATH, GNUNET_MESSAGE_TYPE_CADET_LOCAL_REQUEST_INFO_PEERS, GNUNET_MESSAGE_TYPE_CADET_LOCAL_REQUEST_INFO_TUNNELS, GNUNET_MQ_handler_end, GNUNET_MQ_hd_fixed_size, GNUNET_MQ_hd_var_size, GNUNET_NO, GNUNET_OK, GNUNET_SCHEDULER_add_shutdown(), GNUNET_SCHEDULER_shutdown(), GNUNET_SERVICE_MAIN(), GNUNET_SERVICE_OPTION_NONE, GNUNET_STATISTICS_create(), GNUNET_TIME_UNIT_HOURS, GNUNET_TIME_UNIT_MINUTES, GNUNET_YES, keepalive_period, LOG, my_full_id, GNUNET_PeerIdentity::public_key, ratchet_messages, ratchet_time, and shutdown_task().

1218 {
1219  cfg = c;
1220  if (GNUNET_OK !=
1222  "CADET",
1223  "RATCHET_MESSAGES",
1224  &ratchet_messages))
1225  {
1227  "CADET",
1228  "RATCHET_MESSAGES",
1229  "needs to be a number");
1230  ratchet_messages = 64;
1231  }
1232  if (GNUNET_OK !=
1234  "CADET",
1235  "RATCHET_TIME",
1236  &ratchet_time))
1237  {
1239  "CADET",
1240  "RATCHET_TIME",
1241  "need delay value");
1243  }
1244  if (GNUNET_OK !=
1246  "CADET",
1247  "REFRESH_CONNECTION_TIME",
1248  &keepalive_period))
1249  {
1251  "CADET",
1252  "REFRESH_CONNECTION_TIME",
1253  "need delay value");
1255  }
1256  if (GNUNET_OK !=
1258  "CADET",
1259  "DROP_PERCENT",
1260  &drop_percent))
1261  {
1262  drop_percent = 0;
1263  }
1264  else
1265  {
1266  LOG (GNUNET_ERROR_TYPE_WARNING, "**************************************\n");
1267  LOG (GNUNET_ERROR_TYPE_WARNING, "Cadet is running with DROP enabled.\n");
1268  LOG (GNUNET_ERROR_TYPE_WARNING, "This is NOT a good idea!\n");
1269  LOG (GNUNET_ERROR_TYPE_WARNING, "Remove DROP_PERCENT from config file.\n");
1270  LOG (GNUNET_ERROR_TYPE_WARNING, "**************************************\n");
1271  }
1273  if (NULL == my_private_key)
1274  {
1275  GNUNET_break (0);
1277  return;
1278  }
1281  stats = GNUNET_STATISTICS_create ("cadet",
1282  c);
1284  NULL);
1286  /* FIXME: optimize code to allow GNUNET_YES here! */
1288  GNUNET_NO);
1290  GNUNET_NO);
1292  GNUNET_YES);
1294  GNUNET_YES);
1295  GCH_init (c);
1296  GCD_init (c);
1297  GCO_init (c);
1299  "CADET started for peer %s\n",
1300  GNUNET_i2s (&my_full_id));
1301 }
int GNUNET_CONFIGURATION_get_value_time(const struct GNUNET_CONFIGURATION_Handle *cfg, const char *section, const char *option, struct GNUNET_TIME_Relative *time)
Get a configuration value that should be a relative time.
#define GNUNET_TIME_UNIT_HOURS
One hour.
int 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.
struct GNUNET_CONTAINER_MultiPeerMap * peers
Map from PIDs to struct CadetPeer entries.
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, or when GNUNET_SCHEDULER_shutdown() is being invoked.
Definition: scheduler.c:1300
#define GNUNET_TIME_UNIT_MINUTES
One minute.
struct GNUNET_STATISTICS_Handle * GNUNET_STATISTICS_create(const char *subsystem, const struct GNUNET_CONFIGURATION_Handle *cfg)
Get handle for the statistics service.
struct GNUNET_PeerIdentity my_full_id
Local peer own ID.
struct GNUNET_ATS_ConnectivityHandle * ats_ch
Handle to communicate with ATS.
#define GNUNET_NO
Definition: gnunet_common.h:78
#define GNUNET_OK
Named constants for return values.
Definition: gnunet_common.h:75
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.
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_SCHEDULER_shutdown(void)
Request the shutdown of a scheduler.
Definition: scheduler.c:526
struct GNUNET_CONTAINER_MultiShortmap * connections
Map from struct GNUNET_CADET_ConnectionTunnelIdentifier hash codes to struct CadetConnection objects...
#define GNUNET_break(cond)
Use this for internal assertion violations that are not fatal (can be handled) but should not occur...
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...
struct GNUNET_TIME_Relative ratchet_time
How long until we trigger a ratched advance due to time.
struct GNUNET_STATISTICS_Handle * stats
Handle to the statistics service.
#define LOG(level,...)
static void shutdown_task(void *cls)
Task run during shutdown.
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).
unsigned long long drop_percent
Set to non-zero values to create random drops to test retransmissions.
unsigned long long ratchet_messages
How many messages are needed to trigger an AXOLOTL ratchet advance.
void GNUNET_CRYPTO_eddsa_key_get_public(const struct GNUNET_CRYPTO_EddsaPrivateKey *priv, struct GNUNET_CRYPTO_EddsaPublicKey *pub)
Extract the public key for the given private key.
Definition: crypto_ecc.c:270
struct GNUNET_CRYPTO_EddsaPrivateKey * my_private_key
Own private key.
struct GNUNET_ATS_ConnectivityHandle * GNUNET_ATS_connectivity_init(const struct GNUNET_CONFIGURATION_Handle *cfg)
Initialize the ATS connectivity suggestion client handle.
void GCD_init(const struct GNUNET_CONFIGURATION_Handle *c)
Initialize the DHT subsystem.
#define GNUNET_log(kind,...)
const struct GNUNET_CONFIGURATION_Handle * cfg
Handle to our configuration.
struct GNUNET_CONTAINER_MultiHashMap * GNUNET_CONTAINER_multihashmap_create(unsigned int len, int do_not_copy_keys)
Create a multi hash map.
struct GNUNET_CRYPTO_EddsaPrivateKey * GNUNET_CRYPTO_eddsa_key_create_from_configuration(const struct GNUNET_CONFIGURATION_Handle *cfg)
Create a new private key by reading our peer&#39;s key from the file specified in the configuration...
struct GNUNET_TIME_Relative keepalive_period
How frequently do we send KEEPALIVE messages on idle connections?
#define GNUNET_YES
Definition: gnunet_common.h:77
void GCO_init(const struct GNUNET_CONFIGURATION_Handle *c)
Initialize the CORE subsystem.
void GCH_init(const struct GNUNET_CONFIGURATION_Handle *c)
Initialize the hello subsystem.
const char * GNUNET_i2s(const struct GNUNET_PeerIdentity *pid)
Convert a peer identity to a string (for printing debug messages).
struct GNUNET_CRYPTO_EddsaPublicKey public_key
Here is the call graph for this function:

◆ GNUNET_SERVICE_MAIN()

Define "main" method using service macro.

Referenced by run().

Here is the caller graph for this function:

Variable Documentation

◆ cfg

const struct GNUNET_CONFIGURATION_Handle* cfg

Handle to our configuration.

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

◆ stats

struct GNUNET_STATISTICS_Handle* stats

◆ ats_ch

Handle to communicate with ATS.

Definition at line 121 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 131 of file gnunet-service-cadet.c.

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

◆ shutting_down

int shutting_down

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

◆ clients_head

struct CadetClient* clients_head
static

DLL with all the clients, head.

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

◆ clients_tail

struct CadetClient* clients_tail
static

DLL with all the clients, tail.

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

◆ next_client_id

unsigned int next_client_id
static

Next ID to assign to a client.

Definition at line 151 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 157 of file gnunet-service-cadet.c.

Referenced by GCCH_channel_incoming_new(), and GCCH_channel_local_new().

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

◆ connections

struct GNUNET_CONTAINER_MultiShortmap* connections

Map from struct GNUNET_CADET_ConnectionTunnelIdentifier hash codes to struct CadetConnection objects.

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

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

◆ ratchet_messages

unsigned long long ratchet_messages

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

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

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

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