GNUnet  0.10.x
Data Structures | Macros | Functions | Variables
gnunet-service-cadet_core.c File Reference

cadet service; interaction with CORE service More...

#include "platform.h"
#include "gnunet-service-cadet_core.h"
#include "gnunet-service-cadet_paths.h"
#include "gnunet-service-cadet_peer.h"
#include "gnunet-service-cadet_connection.h"
#include "gnunet-service-cadet_tunnels.h"
#include "gnunet_core_service.h"
#include "gnunet_statistics_service.h"
#include "cadet_protocol.h"
Include dependency graph for gnunet-service-cadet_core.c:

Go to the source code of this file.

Data Structures

struct  Rung
 Set of CadetRoutes that have exactly the same number of messages in their buffer. More...
 
struct  RouteDirection
 Information we keep per direction for a route. More...
 
struct  CadetRoute
 Description of a segment of a struct CadetConnection at the intermediate peers. More...
 

Macros

#define LOG(level, ...)   GNUNET_log_from(level,"cadet-cor",__VA_ARGS__)
 

Functions

static struct CadetRouteget_route (const struct GNUNET_CADET_ConnectionTunnelIdentifier *cid)
 Get the route corresponding to a hash. More...
 
static void lower_rung (struct RouteDirection *dir)
 Lower the rung in which dir is by 1. More...
 
static void discard_buffer (struct RouteDirection *dir, struct GNUNET_MQ_Envelope *env)
 Discard the buffer env from the route direction dir and move dir down a rung. More...
 
static void discard_all_from_rung_tail ()
 Discard all messages from the highest rung, to make space. More...
 
static void route_message (struct CadetPeer *prev, const struct GNUNET_CADET_ConnectionTunnelIdentifier *cid, const struct GNUNET_MessageHeader *msg)
 We message msg from prev. More...
 
static int check_connection_create (void *cls, const struct GNUNET_CADET_ConnectionCreateMessage *msg)
 Check if the create_connection message has the appropriate size. More...
 
static void destroy_direction (struct RouteDirection *dir)
 Free internal data of a route direction. More...
 
static void destroy_route (struct CadetRoute *route)
 Destroy our state for route. More...
 
static void send_broken (struct RouteDirection *target, const struct GNUNET_CADET_ConnectionTunnelIdentifier *cid, const struct GNUNET_PeerIdentity *peer1, const struct GNUNET_PeerIdentity *peer2)
 Send message that a route is broken between peer1 and peer2. More...
 
static void timeout_cb (void *cls)
 Function called to check if any routes have timed out, and if so, to clean them up. More...
 
static void dir_ready_cb (void *cls, int ready)
 Function called when the message queue to the previous hop becomes available/unavailable. More...
 
static void dir_init (struct RouteDirection *dir, struct CadetRoute *route, struct CadetPeer *hop)
 Initialize one of the directions of a route. More...
 
static void send_broken_without_mqm (struct CadetPeer *target, const struct GNUNET_CADET_ConnectionTunnelIdentifier *cid, const struct GNUNET_PeerIdentity *failure_at)
 We could not create the desired route. More...
 
static void handle_connection_create (void *cls, const struct GNUNET_CADET_ConnectionCreateMessage *msg)
 Handle for GNUNET_MESSAGE_TYPE_CADET_CONNECTION_CREATE. More...
 
static void handle_connection_create_ack (void *cls, const struct GNUNET_CADET_ConnectionCreateAckMessage *msg)
 Handle for GNUNET_MESSAGE_TYPE_CADET_CONNECTION_CREATE_ACK. More...
 
static void handle_connection_broken (void *cls, const struct GNUNET_CADET_ConnectionBrokenMessage *msg)
 Handle for GNUNET_MESSAGE_TYPE_CADET_CONNECTION_BROKEN. More...
 
static void handle_connection_destroy (void *cls, const struct GNUNET_CADET_ConnectionDestroyMessage *msg)
 Handle for GNUNET_MESSAGE_TYPE_CADET_CONNECTION_DESTROY. More...
 
static void handle_tunnel_kx (void *cls, const struct GNUNET_CADET_TunnelKeyExchangeMessage *msg)
 Handle for GNUNET_MESSAGE_TYPE_CADET_TUNNEL_KX. More...
 
static void handle_tunnel_kx_auth (void *cls, const struct GNUNET_CADET_TunnelKeyExchangeAuthMessage *msg)
 Handle for GNUNET_MESSAGE_TYPE_CADET_TUNNEL_KX_AUTH. More...
 
static int check_tunnel_encrypted (void *cls, const struct GNUNET_CADET_TunnelEncryptedMessage *msg)
 Check if the encrypted message has the appropriate size. More...
 
static void handle_tunnel_encrypted (void *cls, const struct GNUNET_CADET_TunnelEncryptedMessage *msg)
 Handle for GNUNET_MESSAGE_TYPE_CADET_TUNNEL_ENCRYPTED. More...
 
static void core_init_cb (void *cls, const struct GNUNET_PeerIdentity *my_identity)
 Function called after GNUNET_CORE_connect has succeeded (or failed for good). More...
 
static void * core_connect_cb (void *cls, const struct GNUNET_PeerIdentity *peer, struct GNUNET_MQ_Handle *mq)
 Method called whenever a given peer connects. More...
 
static void core_disconnect_cb (void *cls, const struct GNUNET_PeerIdentity *peer, void *peer_cls)
 Method called whenever a peer disconnects. More...
 
void GCO_init (const struct GNUNET_CONFIGURATION_Handle *c)
 Initialize the CORE subsystem. More...
 
void GCO_shutdown ()
 Shut down the CORE subsystem. More...
 

Variables

static struct GNUNET_CORE_Handlecore
 Handle to the CORE service. More...
 
static struct GNUNET_CONTAINER_MultiShortmaproutes
 Routes on which this peer is an intermediate. More...
 
static struct GNUNET_CONTAINER_Heaproute_heap
 Heap of routes, MIN-sorted by last activity. More...
 
static struct Rung rung_zero
 Rung zero (always pointed to by rung_head). More...
 
static struct Rungrung_head = &rung_zero
 DLL of rungs, with the head always point to a rung of route directions with no messages in the queue. More...
 
static struct Rungrung_tail = &rung_zero
 Tail of the rung_head DLL. More...
 
static unsigned long long max_routes
 Maximum number of concurrent routes this peer will support. More...
 
static unsigned long long max_buffers
 Maximum number of envelopes we will buffer at this peer. More...
 
static unsigned long long cur_buffers
 Current number of envelopes we have buffered at this peer. More...
 
static struct GNUNET_SCHEDULER_Tasktimeout_task
 Task to timeout routes. More...
 

Detailed Description

cadet service; interaction with CORE service

Author
Bartlomiej Polot
Christian Grothoff

All functions in this file should use the prefix GCO (Gnunet Cadet cOre (bottom))

TODO:

Definition in file gnunet-service-cadet_core.c.

Macro Definition Documentation

◆ LOG

#define LOG (   level,
  ... 
)    GNUNET_log_from(level,"cadet-cor",__VA_ARGS__)

Function Documentation

◆ get_route()

static struct CadetRoute* get_route ( const struct GNUNET_CADET_ConnectionTunnelIdentifier cid)
static

Get the route corresponding to a hash.

Parameters
cidhash generated from the connection identifier

Definition at line 248 of file gnunet-service-cadet_core.c.

References GNUNET_CADET_ConnectionTunnelIdentifier::connection_of_tunnel, and GNUNET_CONTAINER_multishortmap_get().

Referenced by handle_connection_broken(), handle_connection_create(), handle_connection_destroy(), and route_message().

249 {
251  &cid->connection_of_tunnel);
252 }
void * GNUNET_CONTAINER_multishortmap_get(const struct GNUNET_CONTAINER_MultiShortmap *map, const struct GNUNET_ShortHashCode *key)
Given a key find a value in the map matching the key.
struct GNUNET_ShortHashCode connection_of_tunnel
static struct GNUNET_CONTAINER_MultiShortmap * routes
Routes on which this peer is an intermediate.
Here is the call graph for this function:
Here is the caller graph for this function:

◆ lower_rung()

static void lower_rung ( struct RouteDirection dir)
static

Lower the rung in which dir is by 1.

Parameters
dirdirection to lower in rung.

Definition at line 261 of file gnunet-service-cadet_core.c.

References GNUNET_assert, GNUNET_CONTAINER_DLL_insert, GNUNET_CONTAINER_DLL_insert_after, GNUNET_CONTAINER_DLL_remove, GNUNET_new, Rung::prev, Rung::rd_head, Rung::rd_tail, RouteDirection::rung, and Rung::rung_off.

Referenced by dir_ready_cb(), and discard_buffer().

262 {
263  struct Rung *rung = dir->rung;
264  struct Rung *prev;
265 
267  rung->rd_tail,
268  dir);
269  prev = rung->prev;
270  GNUNET_assert (NULL != prev);
271  if (prev->rung_off != rung->rung_off - 1)
272  {
273  prev = GNUNET_new (struct Rung);
274  prev->rung_off = rung->rung_off - 1;
276  rung_tail,
277  rung->prev,
278  prev);
279  }
280  GNUNET_assert (NULL != prev);
282  prev->rd_tail,
283  dir);
284  dir->rung = prev;
285 }
#define GNUNET_CONTAINER_DLL_remove(head, tail, element)
Remove an element from a DLL.
#define GNUNET_CONTAINER_DLL_insert(head, tail, element)
Insert an element at the head of a DLL.
#define GNUNET_assert(cond)
Use this for fatal errors that cannot be handled.
#define GNUNET_new(type)
Allocate a struct or union of the given type.
Set of CadetRoutes that have exactly the same number of messages in their buffer. ...
struct Rung * prev
Rung of RouteDirections with one less buffer entry each.
struct RouteDirection * rd_head
DLL of route directions with a number of buffer entries matching this rung.
static struct Rung * rung_head
DLL of rungs, with the head always point to a rung of route directions with no messages in the queue...
#define GNUNET_CONTAINER_DLL_insert_after(head, tail, other, element)
Insert an element into a DLL after the given other element.
struct RouteDirection * rd_tail
DLL of route directions with a number of buffer entries matching this rung.
unsigned int rung_off
Number of messages route directions at this rung have in their buffer.
struct Rung * rung
Rung of this route direction (matches length of the buffer DLL).
static struct Rung * rung_tail
Tail of the rung_head DLL.
Here is the caller graph for this function:

◆ discard_buffer()

static void discard_buffer ( struct RouteDirection dir,
struct GNUNET_MQ_Envelope env 
)
static

Discard the buffer env from the route direction dir and move dir down a rung.

Parameters
dirdirection that contains the env in the buffer
envenvelope to discard

Definition at line 296 of file gnunet-service-cadet_core.c.

References cur_buffers, RouteDirection::env_head, RouteDirection::env_tail, GNUNET_MQ_discard(), GNUNET_MQ_dll_remove(), GNUNET_NO, GNUNET_STATISTICS_set(), lower_rung(), and stats.

Referenced by destroy_direction(), discard_all_from_rung_tail(), and route_message().

298 {
300  &dir->env_tail,
301  env);
302  cur_buffers--;
303  GNUNET_MQ_discard (env);
304  lower_rung (dir);
306  "# buffer use",
307  cur_buffers,
308  GNUNET_NO);
309 }
static struct GNUNET_STATISTICS_Handle * stats
Handle for statistics.
struct GNUNET_MQ_Envelope * env_head
Head of DLL of envelopes we have in the buffer for this direction.
static unsigned long long cur_buffers
Current number of envelopes we have buffered at this peer.
#define GNUNET_NO
Definition: gnunet_common.h:81
void GNUNET_STATISTICS_set(struct GNUNET_STATISTICS_Handle *handle, const char *name, uint64_t value, int make_persistent)
Set statistic value for the peer.
void GNUNET_MQ_dll_remove(struct GNUNET_MQ_Envelope **env_head, struct GNUNET_MQ_Envelope **env_tail, struct GNUNET_MQ_Envelope *env)
Remove env from the envelope DLL starting at env_head.
Definition: mq.c:1174
static void lower_rung(struct RouteDirection *dir)
Lower the rung in which dir is by 1.
void GNUNET_MQ_discard(struct GNUNET_MQ_Envelope *mqm)
Discard the message queue message, free all allocated resources.
Definition: mq.c:321
struct GNUNET_MQ_Envelope * env_tail
Tail of DLL of envelopes we have in the buffer for this direction.
Here is the call graph for this function:
Here is the caller graph for this function:

◆ discard_all_from_rung_tail()

static void discard_all_from_rung_tail ( )
static

Discard all messages from the highest rung, to make space.

Definition at line 316 of file gnunet-service-cadet_core.c.

References CadetRoute::cid, GNUNET_CADET_ConnectionTunnelIdentifier::connection_of_tunnel, dir, discard_buffer(), RouteDirection::env_head, GNUNET_CONTAINER_DLL_remove, GNUNET_ERROR_TYPE_DEBUG, GNUNET_free, GNUNET_NO, GNUNET_sh2s(), GNUNET_STATISTICS_update(), LOG, RouteDirection::my_route, Rung::rd_head, rung_tail, stats, and tail.

Referenced by route_message().

317 {
318  struct Rung *tail = rung_tail;
319  struct RouteDirection *dir;
320 
321  while (NULL != (dir = tail->rd_head))
322  {
324  "Queue full due new message %s on connection %s, dropping old message\n",
327  "# messages dropped due to full buffer",
328  1,
329  GNUNET_NO);
330  discard_buffer (dir,
331  dir->env_head);
332  }
334  rung_tail,
335  tail);
336  GNUNET_free (tail);
337 }
#define GNUNET_CONTAINER_DLL_remove(head, tail, element)
Remove an element from a DLL.
static struct GNUNET_STATISTICS_Handle * stats
Handle for statistics.
static char * dir
Set to the directory where runtime files are stored.
Definition: gnunet-arm.c:84
const char * GNUNET_sh2s(const struct GNUNET_ShortHashCode *shc)
Convert a short hash value to a string (for printing debug messages).
struct GNUNET_MQ_Envelope * env_head
Head of DLL of envelopes we have in the buffer for this direction.
Information we keep per direction for a route.
#define LOG(level,...)
#define GNUNET_NO
Definition: gnunet_common.h:81
void GNUNET_STATISTICS_update(struct GNUNET_STATISTICS_Handle *handle, const char *name, int64_t delta, int make_persistent)
Set statistic value for the peer.
Set of CadetRoutes that have exactly the same number of messages in their buffer. ...
struct GNUNET_CADET_ConnectionTunnelIdentifier cid
Unique identifier for the connection that uses this route.
struct CadetRoute * my_route
Route this direction is part of.
struct RouteDirection * rd_head
DLL of route directions with a number of buffer entries matching this rung.
static struct Rung * rung_head
DLL of rungs, with the head always point to a rung of route directions with no messages in the queue...
static struct PendingResolutions * tail
Tail of list of pending resolution requests.
Definition: gnunet-ats.c:236
static void discard_buffer(struct RouteDirection *dir, struct GNUNET_MQ_Envelope *env)
Discard the buffer env from the route direction dir and move dir down a rung.
struct GNUNET_ShortHashCode connection_of_tunnel
static struct Rung * rung_tail
Tail of the rung_head DLL.
#define GNUNET_free(ptr)
Wrapper around free.
Here is the call graph for this function:
Here is the caller graph for this function:

◆ route_message()

static void route_message ( struct CadetPeer prev,
const struct GNUNET_CADET_ConnectionTunnelIdentifier cid,
const struct GNUNET_MessageHeader msg 
)
static

We message msg from prev.

Find its route by cid and forward to the next hop. Drop and signal broken route if we do not have a route.

Parameters
prevprevious hop (sender)
cidconnection identifier, tells us which route to use
msgthe message to forward

Definition at line 350 of file gnunet-service-cadet_core.c.

References GNUNET_TIME_Absolute::abs_value_us, GNUNET_CADET_ConnectionBrokenMessage::cid, CadetRoute::cid, GNUNET_CADET_ConnectionTunnelIdentifier::connection_of_tunnel, cur_buffers, dir, discard_all_from_rung_tail(), discard_buffer(), env, RouteDirection::env_head, RouteDirection::env_tail, GCP_2s(), GCP_get_id(), GCP_send(), GCP_send_ooo(), get_route(), GNUNET_CADET_OPTION_NOBUFFER, GNUNET_CONTAINER_DLL_insert, GNUNET_CONTAINER_DLL_insert_after, GNUNET_CONTAINER_DLL_remove, GNUNET_CONTAINER_heap_update_cost(), GNUNET_ERROR_TYPE_DEBUG, GNUNET_free, GNUNET_i2s(), GNUNET_MESSAGE_TYPE_CADET_CONNECTION_BROKEN, GNUNET_MESSAGE_TYPE_CADET_CONNECTION_DESTROY, GNUNET_MQ_dll_insert_tail(), GNUNET_MQ_env_get_msg(), GNUNET_MQ_env_next(), GNUNET_MQ_msg, GNUNET_MQ_msg_copy(), GNUNET_new, GNUNET_NO, GNUNET_sh2s(), GNUNET_STATISTICS_set(), GNUNET_STATISTICS_update(), GNUNET_TIME_absolute_get(), GNUNET_YES, CadetRoute::hn, RouteDirection::hop, RouteDirection::is_ready, CadetRoute::last_use, LOG, max_buffers, RouteDirection::mqm, my_full_id, RouteDirection::my_route, Rung::next, CadetRoute::next, CadetRoute::options, GNUNET_CADET_ConnectionBrokenMessage::peer1, CadetRoute::prev, Rung::rd_head, Rung::rd_tail, RouteDirection::rung, Rung::rung_off, GNUNET_MessageHeader::size, stats, and GNUNET_MessageHeader::type.

Referenced by handle_connection_broken(), handle_connection_create(), handle_connection_create_ack(), handle_connection_destroy(), handle_tunnel_encrypted(), handle_tunnel_kx(), and handle_tunnel_kx_auth().

353 {
354  struct CadetRoute *route;
355  struct RouteDirection *dir;
356  struct Rung *rung;
357  struct Rung *nxt;
358  struct GNUNET_MQ_Envelope *env;
359 
360  route = get_route (cid);
361  if (NULL == route)
362  {
363  struct GNUNET_MQ_Envelope *env;
365 
367  "Failed to route message of type %u from %s on connection %s: no route\n",
368  ntohs (msg->type),
369  GCP_2s (prev),
371  switch (ntohs (msg->type))
372  {
375  /* No need to respond to these! */
376  return;
377  }
378  env = GNUNET_MQ_msg (bm,
380  bm->cid = *cid;
381  bm->peer1 = my_full_id;
382  GCP_send_ooo (prev,
383  env);
384  return;
385  }
388  route->last_use.abs_value_us);
389  dir = (prev == route->prev.hop) ? &route->next : &route->prev;
390  if (GNUNET_YES == dir->is_ready)
391  {
393  "Routing message of type %u from %s to %s on connection %s\n",
394  ntohs (msg->type),
395  GCP_2s (prev),
396  GNUNET_i2s (GCP_get_id (dir->hop)),
398  dir->is_ready = GNUNET_NO;
399  GCP_send (dir->mqm,
400  GNUNET_MQ_msg_copy (msg));
401  return;
402  }
403  /* Check if buffering is disallowed, and if so, make sure we only queue
404  one message per direction. */
405  if ( (0 != (route->options & GNUNET_CADET_OPTION_NOBUFFER)) &&
406  (NULL != dir->env_head) )
407  discard_buffer (dir,
408  dir->env_head);
409  /* Check for duplicates */
410  for (const struct GNUNET_MQ_Envelope *env = dir->env_head;
411  NULL != env;
412  env = GNUNET_MQ_env_next (env))
413  {
414  const struct GNUNET_MessageHeader *hdr = GNUNET_MQ_env_get_msg (env);
415 
416  if ( (hdr->size == msg->size) &&
417  (0 == memcmp (hdr,
418  msg,
419  ntohs (msg->size))) )
420  {
422  "Received duplicate of message already in buffer, dropping\n");
424  "# messages dropped due to duplicate in buffer",
425  1,
426  GNUNET_NO);
427  return;
428  }
429  }
430 
431  rung = dir->rung;
432  if (cur_buffers == max_buffers)
433  {
434  /* Need to make room. */
435  if (NULL != rung->next)
436  {
437  /* Easy case, drop messages from route directions in highest rung */
439  }
440  else
441  {
442  /* We are in the highest rung, drop our own! */
444  "Queue full due new message %s on connection %s, dropping old message\n",
447  "# messages dropped due to full buffer",
448  1,
449  GNUNET_NO);
450  discard_buffer (dir,
451  dir->env_head);
452  rung = dir->rung;
453  }
454  }
455  /* remove 'dir' from current rung */
457  rung->rd_tail,
458  dir);
459  /* make 'nxt' point to the next higher rung, create if necessary */
460  nxt = rung->next;
461  if ( (NULL == nxt) ||
462  (rung->rung_off + 1 != nxt->rung_off) )
463  {
464  nxt = GNUNET_new (struct Rung);
465  nxt->rung_off = rung->rung_off + 1;
467  rung_tail,
468  rung,
469  nxt);
470  }
471  /* insert 'dir' into next higher rung */
473  nxt->rd_tail,
474  dir);
475  dir->rung = nxt;
476 
477  /* add message into 'dir' buffer */
479  "Queueing new message of type %u from %s to %s on connection %s\n",
480  ntohs (msg->type),
481  GCP_2s (prev),
482  GNUNET_i2s (GCP_get_id (dir->hop)),
484  env = GNUNET_MQ_msg_copy (msg);
486  &dir->env_tail,
487  env);
488  cur_buffers++;
490  "# buffer use",
491  cur_buffers,
492  GNUNET_NO);
493  /* Clean up 'rung' if now empty (and not head) */
494  if ( (NULL == rung->rd_head) &&
495  (rung != rung_head) )
496  {
498  rung_tail,
499  rung);
500  GNUNET_free (rung);
501  }
502 }
#define GNUNET_CONTAINER_DLL_remove(head, tail, element)
Remove an element from a DLL.
void GNUNET_MQ_dll_insert_tail(struct GNUNET_MQ_Envelope **env_head, struct GNUNET_MQ_Envelope **env_tail, struct GNUNET_MQ_Envelope *env)
Insert env into the envelope DLL starting at env_head Note that env must not be in any MQ while this ...
Definition: mq.c:1153
static struct GNUNET_STATISTICS_Handle * stats
Handle for statistics.
static char * dir
Set to the directory where runtime files are stored.
Definition: gnunet-arm.c:84
static unsigned long long max_buffers
Maximum number of envelopes we will buffer at this peer.
const char * GNUNET_sh2s(const struct GNUNET_ShortHashCode *shc)
Convert a short hash value to a string (for printing debug messages).
void GNUNET_CONTAINER_heap_update_cost(struct GNUNET_CONTAINER_HeapNode *node, GNUNET_CONTAINER_HeapCostType new_cost)
Updates the cost of any node in the tree.
struct GNUNET_MQ_Envelope * GNUNET_MQ_msg_copy(const struct GNUNET_MessageHeader *hdr)
Create a new envelope by copying an existing message.
Definition: mq.c:653
struct GNUNET_MQ_Envelope * env_head
Head of DLL of envelopes we have in the buffer for this direction.
const struct GNUNET_MessageHeader * GNUNET_MQ_env_get_msg(const struct GNUNET_MQ_Envelope *env)
Obtain message contained in envelope.
Definition: mq.c:1080
#define GNUNET_CONTAINER_DLL_insert(head, tail, element)
Insert an element at the head of a DLL.
Information we keep per direction for a route.
struct GNUNET_CONTAINER_HeapNode * hn
Position of this route in the route_heap.
#define LOG(level,...)
struct GNUNET_PeerIdentity my_full_id
Local peer own ID.
static unsigned long long cur_buffers
Current number of envelopes we have buffered at this peer.
#define GNUNET_MQ_msg(mvar, type)
Allocate a GNUNET_MQ_Envelope.
Definition: gnunet_mq_lib.h:67
#define GNUNET_NO
Definition: gnunet_common.h:81
#define GNUNET_new(type)
Allocate a struct or union of the given type.
void GCP_send(struct GCP_MessageQueueManager *mqm, struct GNUNET_MQ_Envelope *env)
Send the message in env to cp.
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.
Set of CadetRoutes that have exactly the same number of messages in their buffer. ...
uint64_t abs_value_us
The actual value.
const struct GNUNET_MQ_Envelope * GNUNET_MQ_env_next(const struct GNUNET_MQ_Envelope *env)
Return next envelope in queue.
Definition: mq.c:1093
struct Rung * next
Rung of RouteDirections with one more buffer entry each.
const char * GCP_2s(const struct CadetPeer *cp)
Get the static string for a peer ID.
struct GNUNET_CADET_ConnectionTunnelIdentifier cid
Unique identifier for the connection that uses this route.
struct CadetRoute * my_route
Route this direction is part of.
struct RouteDirection * rd_head
DLL of route directions with a number of buffer entries matching this rung.
uint16_t type
The type of the message (GNUNET_MESSAGE_TYPE_XXXX), in big-endian format.
static struct CadetRoute * get_route(const struct GNUNET_CADET_ConnectionTunnelIdentifier *cid)
Get the route corresponding to a hash.
struct RouteDirection prev
Information about the previous hop on this route.
void GCP_send_ooo(struct CadetPeer *cp, struct GNUNET_MQ_Envelope *env)
Send the message in env to cp, overriding queueing logic.
Description of a segment of a struct CadetConnection at the intermediate peers.
struct CadetPeer * hop
Target peer.
struct GNUNET_TIME_Absolute last_use
When was this route last in use?
static struct Rung * rung_head
DLL of rungs, with the head always point to a rung of route directions with no messages in the queue...
#define GNUNET_CONTAINER_DLL_insert_after(head, tail, other, element)
Insert an element into a DLL after the given other element.
Message for notifying a disconnection in a path.
struct GNUNET_CADET_ConnectionTunnelIdentifier cid
ID of the connection.
void GNUNET_STATISTICS_set(struct GNUNET_STATISTICS_Handle *handle, const char *name, uint64_t value, int make_persistent)
Set statistic value for the peer.
struct RouteDirection next
Information about the next hop on this route.
struct GNUNET_TIME_Absolute GNUNET_TIME_absolute_get(void)
Get the current time.
Definition: time.c:118
enum GNUNET_CADET_ChannelOption options
Options for the route, control buffering.
struct RouteDirection * rd_tail
DLL of route directions with a number of buffer entries matching this rung.
unsigned int rung_off
Number of messages route directions at this rung have in their buffer.
struct GNUNET_PeerIdentity peer1
ID of the endpoint.
struct GNUNET_MQ_Envelope * env
Definition: 005.c:1
struct GCP_MessageQueueManager * mqm
Message queue manager for hop.
#define GNUNET_MESSAGE_TYPE_CADET_CONNECTION_DESTROY
Request the destuction of a connection.
struct Rung * rung
Rung of this route direction (matches length of the buffer DLL).
Header for all communications.
#define GNUNET_YES
Definition: gnunet_common.h:80
int is_ready
Is mqm currently ready for transmission?
static void discard_all_from_rung_tail()
Discard all messages from the highest rung, to make space.
static void discard_buffer(struct RouteDirection *dir, struct GNUNET_MQ_Envelope *env)
Discard the buffer env from the route direction dir and move dir down a rung.
struct GNUNET_ShortHashCode connection_of_tunnel
static struct Rung * rung_tail
Tail of the rung_head DLL.
const char * GNUNET_i2s(const struct GNUNET_PeerIdentity *pid)
Convert a peer identity to a string (for printing debug messages).
#define GNUNET_MESSAGE_TYPE_CADET_CONNECTION_BROKEN
Notify that a connection is no longer valid.
struct GNUNET_MQ_Envelope * env_tail
Tail of DLL of envelopes we have in the buffer for this direction.
#define GNUNET_free(ptr)
Wrapper around free.
const struct GNUNET_PeerIdentity * GCP_get_id(struct CadetPeer *cp)
Obtain the peer identity for a struct CadetPeer.
Disable buffering on intermediate nodes (for minimum latency).
Here is the call graph for this function:
Here is the caller graph for this function:

◆ check_connection_create()

static int check_connection_create ( void *  cls,
const struct GNUNET_CADET_ConnectionCreateMessage msg 
)
static

Check if the create_connection message has the appropriate size.

Parameters
clsClosure (unused).
msgMessage to check.
Returns
GNUNET_YES if size is correct, GNUNET_NO otherwise.

Definition at line 514 of file gnunet-service-cadet_core.c.

References GNUNET_break_op, GNUNET_NO, GNUNET_YES, GNUNET_CADET_ConnectionCreateMessage::header, size, and GNUNET_MessageHeader::size.

516 {
517  uint16_t size = ntohs (msg->header.size) - sizeof (*msg);
518 
519  if (0 != (size % sizeof (struct GNUNET_PeerIdentity)))
520  {
521  GNUNET_break_op (0);
522  return GNUNET_NO;
523  }
524  return GNUNET_YES;
525 }
struct GNUNET_MessageHeader header
Type: GNUNET_MESSAGE_TYPE_CADET_CONNECTION_CREATE.
#define GNUNET_NO
Definition: gnunet_common.h:81
uint16_t size
The length of the struct (in bytes, including the length field itself), in big-endian format...
#define GNUNET_break_op(cond)
Use this for assertion violations caused by other peers (i.e.
static unsigned int size
Size of the "table".
Definition: peer.c:67
The identity of the host (wraps the signing key of the peer).
#define GNUNET_YES
Definition: gnunet_common.h:80

◆ destroy_direction()

static void destroy_direction ( struct RouteDirection dir)
static

Free internal data of a route direction.

Parameters
dirdirection to destroy (do NOT free memory of 'dir' itself)

Definition at line 534 of file gnunet-service-cadet_core.c.

References discard_buffer(), env, RouteDirection::env_head, GCP_request_mq_cancel(), GNUNET_CONTAINER_DLL_remove, GNUNET_NO, GNUNET_STATISTICS_update(), RouteDirection::mqm, Rung::rd_head, Rung::rd_tail, and stats.

Referenced by destroy_route().

535 {
536  struct GNUNET_MQ_Envelope *env;
537 
538  while (NULL != (env = dir->env_head))
539  {
541  "# messages dropped due to route destruction",
542  1,
543  GNUNET_NO);
544  discard_buffer (dir,
545  env);
546  }
547  if (NULL != dir->mqm)
548  {
550  NULL);
551  dir->mqm = NULL;
552  }
555  dir);
556 }
#define GNUNET_CONTAINER_DLL_remove(head, tail, element)
Remove an element from a DLL.
static struct GNUNET_STATISTICS_Handle * stats
Handle for statistics.
struct GNUNET_MQ_Envelope * env_head
Head of DLL of envelopes we have in the buffer for this direction.
#define GNUNET_NO
Definition: gnunet_common.h:81
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 RouteDirection * rd_head
DLL of route directions with a number of buffer entries matching this rung.
static struct Rung * rung_head
DLL of rungs, with the head always point to a rung of route directions with no messages in the queue...
struct RouteDirection * rd_tail
DLL of route directions with a number of buffer entries matching this rung.
struct GNUNET_MQ_Envelope * env
Definition: 005.c:1
struct GCP_MessageQueueManager * mqm
Message queue manager for hop.
void GCP_request_mq_cancel(struct GCP_MessageQueueManager *mqm, struct GNUNET_MQ_Envelope *last_env)
Stops message queue change notifications.
static void discard_buffer(struct RouteDirection *dir, struct GNUNET_MQ_Envelope *env)
Discard the buffer env from the route direction dir and move dir down a rung.
Here is the call graph for this function:
Here is the caller graph for this function:

◆ destroy_route()

static void destroy_route ( struct CadetRoute route)
static

Destroy our state for route.

Parameters
routeroute to destroy

Definition at line 565 of file gnunet-service-cadet_core.c.

References CadetRoute::cid, GNUNET_CADET_ConnectionTunnelIdentifier::connection_of_tunnel, destroy_direction(), GCP_get_id(), GNUNET_assert, GNUNET_CONTAINER_heap_remove_node(), GNUNET_CONTAINER_multishortmap_remove(), GNUNET_CONTAINER_multishortmap_size(), GNUNET_ERROR_TYPE_DEBUG, GNUNET_free, GNUNET_i2s(), GNUNET_i2s2(), GNUNET_NO, GNUNET_sh2s(), GNUNET_STATISTICS_set(), GNUNET_YES, CadetRoute::hn, RouteDirection::hop, LOG, CadetRoute::next, CadetRoute::prev, and stats.

Referenced by dir_ready_cb(), handle_connection_broken(), handle_connection_destroy(), and timeout_cb().

566 {
568  "Destroying route from %s to %s of connection %s\n",
569  GNUNET_i2s (GCP_get_id (route->prev.hop)),
570  GNUNET_i2s2 (GCP_get_id (route->next.hop)),
572  GNUNET_assert (route ==
576  &route->cid.connection_of_tunnel,
577  route));
579  "# routes",
581  GNUNET_NO);
582  destroy_direction (&route->prev);
583  destroy_direction (&route->next);
584  GNUNET_free (route);
585 }
static struct GNUNET_STATISTICS_Handle * stats
Handle for statistics.
const char * GNUNET_sh2s(const struct GNUNET_ShortHashCode *shc)
Convert a short hash value to a string (for printing debug messages).
const char * GNUNET_i2s2(const struct GNUNET_PeerIdentity *pid)
Convert a peer identity to a string (for printing debug messages).
unsigned int GNUNET_CONTAINER_multishortmap_size(const struct GNUNET_CONTAINER_MultiShortmap *map)
Get the number of key-value pairs in the map.
struct GNUNET_CONTAINER_HeapNode * hn
Position of this route in the route_heap.
#define LOG(level,...)
#define GNUNET_assert(cond)
Use this for fatal errors that cannot be handled.
int GNUNET_CONTAINER_multishortmap_remove(struct GNUNET_CONTAINER_MultiShortmap *map, const struct GNUNET_ShortHashCode *key, const void *value)
Remove the given key-value pair from the map.
#define GNUNET_NO
Definition: gnunet_common.h:81
static void destroy_direction(struct RouteDirection *dir)
Free internal data of a route direction.
struct GNUNET_CADET_ConnectionTunnelIdentifier cid
Unique identifier for the connection that uses this route.
struct RouteDirection prev
Information about the previous hop on this route.
struct CadetPeer * hop
Target peer.
void GNUNET_STATISTICS_set(struct GNUNET_STATISTICS_Handle *handle, const char *name, uint64_t value, int make_persistent)
Set statistic value for the peer.
struct RouteDirection next
Information about the next hop on this route.
#define GNUNET_YES
Definition: gnunet_common.h:80
struct GNUNET_ShortHashCode connection_of_tunnel
void * GNUNET_CONTAINER_heap_remove_node(struct GNUNET_CONTAINER_HeapNode *node)
Removes a node from the heap.
const char * GNUNET_i2s(const struct GNUNET_PeerIdentity *pid)
Convert a peer identity to a string (for printing debug messages).
#define GNUNET_free(ptr)
Wrapper around free.
const struct GNUNET_PeerIdentity * GCP_get_id(struct CadetPeer *cp)
Obtain the peer identity for a struct CadetPeer.
static struct GNUNET_CONTAINER_MultiShortmap * routes
Routes on which this peer is an intermediate.
Here is the call graph for this function:
Here is the caller graph for this function:

◆ send_broken()

static void send_broken ( struct RouteDirection target,
const struct GNUNET_CADET_ConnectionTunnelIdentifier cid,
const struct GNUNET_PeerIdentity peer1,
const struct GNUNET_PeerIdentity peer2 
)
static

Send message that a route is broken between peer1 and peer2.

Parameters
targetwhere to send the message
cidconnection identifier to use
peer1one of the peers where a link is broken
peer2another one of the peers where a link is broken

Definition at line 597 of file gnunet-service-cadet_core.c.

References GNUNET_CADET_ConnectionBrokenMessage::cid, GNUNET_CADET_ConnectionTunnelIdentifier::connection_of_tunnel, env, GCP_2s(), GCP_request_mq_cancel(), GNUNET_ERROR_TYPE_DEBUG, GNUNET_i2s(), GNUNET_i2s2(), GNUNET_MESSAGE_TYPE_CADET_CONNECTION_BROKEN, GNUNET_MQ_msg, GNUNET_sh2s(), RouteDirection::hop, LOG, RouteDirection::mqm, GNUNET_CADET_ConnectionBrokenMessage::peer1, and GNUNET_CADET_ConnectionBrokenMessage::peer2.

Referenced by dir_ready_cb(), and timeout_cb().

601 {
602  struct GNUNET_MQ_Envelope *env;
604 
605  if (NULL == target->mqm)
606  return; /* Can't send notification, connection is down! */
608  "Notifying %s about BROKEN route at %s-%s of connection %s\n",
609  GCP_2s (target->hop),
610  GNUNET_i2s (peer1),
611  GNUNET_i2s2 (peer2),
613 
614  env = GNUNET_MQ_msg (bm,
616  bm->cid = *cid;
617  if (NULL != peer1)
618  bm->peer1 = *peer1;
619  if (NULL != peer2)
620  bm->peer2 = *peer2;
621  GCP_request_mq_cancel (target->mqm,
622  env);
623  target->mqm = NULL;
624 }
const char * GNUNET_sh2s(const struct GNUNET_ShortHashCode *shc)
Convert a short hash value to a string (for printing debug messages).
const char * GNUNET_i2s2(const struct GNUNET_PeerIdentity *pid)
Convert a peer identity to a string (for printing debug messages).
#define LOG(level,...)
#define GNUNET_MQ_msg(mvar, type)
Allocate a GNUNET_MQ_Envelope.
Definition: gnunet_mq_lib.h:67
struct GNUNET_PeerIdentity peer2
ID of the endpoint.
const char * GCP_2s(const struct CadetPeer *cp)
Get the static string for a peer ID.
struct CadetPeer * hop
Target peer.
Message for notifying a disconnection in a path.
struct GNUNET_CADET_ConnectionTunnelIdentifier cid
ID of the connection.
struct GNUNET_PeerIdentity peer1
ID of the endpoint.
struct GNUNET_MQ_Envelope * env
Definition: 005.c:1
struct GCP_MessageQueueManager * mqm
Message queue manager for hop.
void GCP_request_mq_cancel(struct GCP_MessageQueueManager *mqm, struct GNUNET_MQ_Envelope *last_env)
Stops message queue change notifications.
struct GNUNET_ShortHashCode connection_of_tunnel
const char * GNUNET_i2s(const struct GNUNET_PeerIdentity *pid)
Convert a peer identity to a string (for printing debug messages).
#define GNUNET_MESSAGE_TYPE_CADET_CONNECTION_BROKEN
Notify that a connection is no longer valid.
Here is the call graph for this function:
Here is the caller graph for this function:

◆ timeout_cb()

static void timeout_cb ( void *  cls)
static

Function called to check if any routes have timed out, and if so, to clean them up.

Finally, schedules itself again at the earliest time where there might be more work.

Parameters
clsNULL

Definition at line 635 of file gnunet-service-cadet_core.c.

References CadetRoute::cid, destroy_route(), GNUNET_CONTAINER_heap_peek(), GNUNET_ERROR_TYPE_INFO, GNUNET_log, GNUNET_SCHEDULER_add_at(), GNUNET_STRINGS_absolute_time_to_string(), GNUNET_STRINGS_relative_time_to_string(), GNUNET_TIME_absolute_add(), GNUNET_TIME_absolute_get_remaining(), GNUNET_TIME_relative_multiply(), GNUNET_YES, keepalive_period, CadetRoute::last_use, CadetRoute::next, CadetRoute::prev, and send_broken().

Referenced by handle_connection_create().

636 {
637  struct CadetRoute *r;
638  struct GNUNET_TIME_Relative linger;
639  struct GNUNET_TIME_Absolute exp;
640 
641  timeout_task = NULL;
643  3);
644  while (NULL != (r = GNUNET_CONTAINER_heap_peek (route_heap)))
645  {
647  linger);
648  if (0 != GNUNET_TIME_absolute_get_remaining (exp).rel_value_us)
649  {
650  /* Route not yet timed out, wait until it does. */
651  timeout_task = GNUNET_SCHEDULER_add_at (exp,
652  &timeout_cb,
653  NULL);
654  return;
655  }
657  "Sending BROKEN due to timeout (%s was last use, %s linger)\n",
660  GNUNET_YES));
661  send_broken (&r->prev,
662  &r->cid,
663  NULL,
664  NULL);
665  send_broken (&r->next,
666  &r->cid,
667  NULL,
668  NULL);
669  destroy_route (r);
670  }
671  /* No more routes left, so no need for a #timeout_task */
672 }
struct GNUNET_TIME_Absolute GNUNET_TIME_absolute_add(struct GNUNET_TIME_Absolute start, struct GNUNET_TIME_Relative duration)
Add a given relative duration to the given start time.
Definition: time.c:393
struct GNUNET_CADET_ConnectionTunnelIdentifier cid
Unique identifier for the connection that uses this route.
static void destroy_route(struct CadetRoute *route)
Destroy our state for route.
struct RouteDirection prev
Information about the previous hop on this route.
void * GNUNET_CONTAINER_heap_peek(const struct GNUNET_CONTAINER_Heap *heap)
Get element stored at the root of heap.
const char * GNUNET_STRINGS_relative_time_to_string(struct GNUNET_TIME_Relative delta, int do_round)
Give relative time in human-readable fancy format.
Definition: strings.c:727
Description of a segment of a struct CadetConnection at the intermediate peers.
struct GNUNET_TIME_Absolute last_use
When was this route last in use?
struct GNUNET_TIME_Relative GNUNET_TIME_relative_multiply(struct GNUNET_TIME_Relative rel, unsigned long long factor)
Multiply relative time by a given factor.
Definition: time.c:439
struct RouteDirection next
Information about the next hop on this route.
static void send_broken(struct RouteDirection *target, const struct GNUNET_CADET_ConnectionTunnelIdentifier *cid, const struct GNUNET_PeerIdentity *peer1, const struct GNUNET_PeerIdentity *peer2)
Send message that a route is broken between peer1 and peer2.
static struct GNUNET_CONTAINER_Heap * route_heap
Heap of routes, MIN-sorted by last activity.
static struct GNUNET_SCHEDULER_Task * timeout_task
Task to timeout routes.
#define GNUNET_log(kind,...)
struct GNUNET_TIME_Relative keepalive_period
How frequently do we send KEEPALIVE messages on idle connections?
struct GNUNET_TIME_Relative GNUNET_TIME_absolute_get_remaining(struct GNUNET_TIME_Absolute future)
Given a timestamp in the future, how much time remains until then?
Definition: time.c:331
Time for absolute times used by GNUnet, in microseconds.
#define GNUNET_YES
Definition: gnunet_common.h:80
static void timeout_cb(void *cls)
Function called to check if any routes have timed out, and if so, to clean them up.
const char * GNUNET_STRINGS_absolute_time_to_string(struct GNUNET_TIME_Absolute t)
Like asctime, except for GNUnet time.
Definition: strings.c:792
struct GNUNET_SCHEDULER_Task * GNUNET_SCHEDULER_add_at(struct GNUNET_TIME_Absolute at, GNUNET_SCHEDULER_TaskCallback task, void *task_cls)
Schedule a new task to be run at the specified time.
Definition: scheduler.c:1223
Time for relative time used by GNUnet, in microseconds.
Here is the call graph for this function:
Here is the caller graph for this function:

◆ dir_ready_cb()

static void dir_ready_cb ( void *  cls,
int  ready 
)
static

Function called when the message queue to the previous hop becomes available/unavailable.

We expect this function to be called immediately when we register, and then again later if the connection ever goes down.

Parameters
clsthe struct RouteDirection
availableGNUNET_YES if sending is now possible, GNUNET_NO if sending is no longer possible GNUNET_SYSERR if sending is no longer possible and the last envelope was discarded

Definition at line 688 of file gnunet-service-cadet_core.c.

References CadetRoute::cid, cur_buffers, destroy_route(), dir, env, RouteDirection::env_head, RouteDirection::env_tail, GCP_get_id(), GCP_send(), GNUNET_ERROR_TYPE_DEBUG, GNUNET_log, GNUNET_MQ_dll_remove(), GNUNET_NO, GNUNET_STATISTICS_set(), GNUNET_YES, RouteDirection::hop, RouteDirection::is_ready, lower_rung(), RouteDirection::mqm, my_full_id, RouteDirection::my_route, CadetRoute::next, CadetRoute::prev, send_broken(), and stats.

Referenced by dir_init().

690 {
691  struct RouteDirection *dir = cls;
692  struct CadetRoute *route = dir->my_route;
693  struct RouteDirection *odir;
694 
695  if (GNUNET_YES == ready)
696  {
697  struct GNUNET_MQ_Envelope *env;
698 
699  dir->is_ready = GNUNET_YES;
700  if (NULL != (env = dir->env_head))
701  {
703  &dir->env_tail,
704  env);
705  cur_buffers--;
707  "# buffer use",
708  cur_buffers,
709  GNUNET_NO);
710  lower_rung (dir);
711  dir->is_ready = GNUNET_NO;
712  GCP_send (dir->mqm,
713  env);
714  }
715  return;
716  }
717  odir = (dir == &route->next) ? &route->prev : &route->next;
719  "Sending BROKEN due to MQ going down\n");
720  send_broken (&route->next,
721  &route->cid,
722  GCP_get_id (odir->hop),
723  &my_full_id);
724  destroy_route (route);
725 }
static struct GNUNET_STATISTICS_Handle * stats
Handle for statistics.
static char * dir
Set to the directory where runtime files are stored.
Definition: gnunet-arm.c:84
struct GNUNET_MQ_Envelope * env_head
Head of DLL of envelopes we have in the buffer for this direction.
Information we keep per direction for a route.
struct GNUNET_PeerIdentity my_full_id
Local peer own ID.
static unsigned long long cur_buffers
Current number of envelopes we have buffered at this peer.
#define GNUNET_NO
Definition: gnunet_common.h:81
void GCP_send(struct GCP_MessageQueueManager *mqm, struct GNUNET_MQ_Envelope *env)
Send the message in env to cp.
struct GNUNET_CADET_ConnectionTunnelIdentifier cid
Unique identifier for the connection that uses this route.
struct CadetRoute * my_route
Route this direction is part of.
static void destroy_route(struct CadetRoute *route)
Destroy our state for route.
struct RouteDirection prev
Information about the previous hop on this route.
Description of a segment of a struct CadetConnection at the intermediate peers.
struct CadetPeer * hop
Target peer.
void GNUNET_STATISTICS_set(struct GNUNET_STATISTICS_Handle *handle, const char *name, uint64_t value, int make_persistent)
Set statistic value for the peer.
struct RouteDirection next
Information about the next hop on this route.
void GNUNET_MQ_dll_remove(struct GNUNET_MQ_Envelope **env_head, struct GNUNET_MQ_Envelope **env_tail, struct GNUNET_MQ_Envelope *env)
Remove env from the envelope DLL starting at env_head.
Definition: mq.c:1174
static void lower_rung(struct RouteDirection *dir)
Lower the rung in which dir is by 1.
static void send_broken(struct RouteDirection *target, const struct GNUNET_CADET_ConnectionTunnelIdentifier *cid, const struct GNUNET_PeerIdentity *peer1, const struct GNUNET_PeerIdentity *peer2)
Send message that a route is broken between peer1 and peer2.
struct GNUNET_MQ_Envelope * env
Definition: 005.c:1
struct GCP_MessageQueueManager * mqm
Message queue manager for hop.
#define GNUNET_log(kind,...)
#define GNUNET_YES
Definition: gnunet_common.h:80
int is_ready
Is mqm currently ready for transmission?
struct GNUNET_MQ_Envelope * env_tail
Tail of DLL of envelopes we have in the buffer for this direction.
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:

◆ dir_init()

static void dir_init ( struct RouteDirection dir,
struct CadetRoute route,
struct CadetPeer hop 
)
static

Initialize one of the directions of a route.

Parameters
routeroute the direction belongs to
dirdirection to initialize
hopnext hop on in the dir

Definition at line 736 of file gnunet-service-cadet_core.c.

References dir_ready_cb(), GCP_request_mq(), GNUNET_assert, GNUNET_CONTAINER_DLL_insert, GNUNET_YES, RouteDirection::hop, RouteDirection::is_ready, RouteDirection::mqm, RouteDirection::my_route, Rung::rd_head, Rung::rd_tail, RouteDirection::rung, and rung_head.

Referenced by handle_connection_create().

739 {
740  dir->hop = hop;
741  dir->my_route = route;
742  dir->mqm = GCP_request_mq (hop,
743  &dir_ready_cb,
744  dir);
747  dir);
748  dir->rung = rung_head;
750 }
#define GNUNET_CONTAINER_DLL_insert(head, tail, element)
Insert an element at the head of a DLL.
#define GNUNET_assert(cond)
Use this for fatal errors that cannot be handled.
struct CadetRoute * my_route
Route this direction is part of.
struct RouteDirection * rd_head
DLL of route directions with a number of buffer entries matching this rung.
struct CadetPeer * hop
Target peer.
static struct Rung * rung_head
DLL of rungs, with the head always point to a rung of route directions with no messages in the queue...
static void dir_ready_cb(void *cls, int ready)
Function called when the message queue to the previous hop becomes available/unavailable.
struct RouteDirection * rd_tail
DLL of route directions with a number of buffer entries matching this rung.
struct GCP_MessageQueueManager * mqm
Message queue manager for hop.
struct Rung * rung
Rung of this route direction (matches length of the buffer DLL).
#define GNUNET_YES
Definition: gnunet_common.h:80
int is_ready
Is mqm currently ready for transmission?
struct GCP_MessageQueueManager * GCP_request_mq(struct CadetPeer *cp, GCP_MessageQueueNotificationCallback cb, void *cb_cls)
Start message queue change notifications.
Here is the call graph for this function:
Here is the caller graph for this function:

◆ send_broken_without_mqm()

static void send_broken_without_mqm ( struct CadetPeer target,
const struct GNUNET_CADET_ConnectionTunnelIdentifier cid,
const struct GNUNET_PeerIdentity failure_at 
)
static

We could not create the desired route.

Send a GNUNET_MESSAGE_TYPE_CADET_CONNECTION_BROKEN message to target.

Parameters
targetwho should receive the message
cididentifier of the connection/route that failed
failure_atneighbour with which we failed to route, or NULL.

Definition at line 764 of file gnunet-service-cadet_core.c.

References GNUNET_CADET_ConnectionBrokenMessage::cid, env, GCP_send_ooo(), GNUNET_MESSAGE_TYPE_CADET_CONNECTION_BROKEN, GNUNET_MQ_msg, my_full_id, GNUNET_CADET_ConnectionBrokenMessage::peer1, and GNUNET_CADET_ConnectionBrokenMessage::peer2.

Referenced by handle_connection_create().

767 {
768  struct GNUNET_MQ_Envelope *env;
770 
771  env = GNUNET_MQ_msg (bm,
773  bm->cid = *cid;
774  bm->peer1 = my_full_id;
775  if (NULL != failure_at)
776  bm->peer2 = *failure_at;
777  GCP_send_ooo (target,
778  env);
779 }
struct GNUNET_PeerIdentity my_full_id
Local peer own ID.
#define GNUNET_MQ_msg(mvar, type)
Allocate a GNUNET_MQ_Envelope.
Definition: gnunet_mq_lib.h:67
struct GNUNET_PeerIdentity peer2
ID of the endpoint.
void GCP_send_ooo(struct CadetPeer *cp, struct GNUNET_MQ_Envelope *env)
Send the message in env to cp, overriding queueing logic.
Message for notifying a disconnection in a path.
struct GNUNET_CADET_ConnectionTunnelIdentifier cid
ID of the connection.
struct GNUNET_PeerIdentity peer1
ID of the endpoint.
struct GNUNET_MQ_Envelope * env
Definition: 005.c:1
#define GNUNET_MESSAGE_TYPE_CADET_CONNECTION_BROKEN
Notify that a connection is no longer valid.
Here is the call graph for this function:
Here is the caller graph for this function:

◆ handle_connection_create()

static void handle_connection_create ( void *  cls,
const struct GNUNET_CADET_ConnectionCreateMessage msg 
)
static

Handle for GNUNET_MESSAGE_TYPE_CADET_CONNECTION_CREATE.

Parameters
clsClosure (CadetPeer for neighbor that sent the message).
msgMessage itself.

Definition at line 789 of file gnunet-service-cadet_core.c.

References GNUNET_TIME_Absolute::abs_value_us, GNUNET_CADET_ConnectionCreateMessage::cid, CadetRoute::cid, GNUNET_CADET_ConnectionTunnelIdentifier::connection_of_tunnel, dir_init(), GCC_handle_duplicate_create(), GCC_lookup(), GCP_2s(), GCP_get(), GCP_get_tunnel(), GCP_has_core_connection(), GCPP_2s(), GCPP_get_path_from_route(), GCT_add_inbound_connection(), get_route(), GNUNET_assert, GNUNET_break_op, GNUNET_CONTAINER_heap_insert(), GNUNET_CONTAINER_MULTIHASHMAPOPTION_UNIQUE_ONLY, GNUNET_CONTAINER_multipeermap_create(), GNUNET_CONTAINER_multipeermap_destroy(), GNUNET_CONTAINER_multipeermap_put(), GNUNET_CONTAINER_multishortmap_put(), GNUNET_CONTAINER_multishortmap_size(), GNUNET_ERROR_TYPE_DEBUG, GNUNET_i2s(), GNUNET_memcmp, GNUNET_new, GNUNET_NO, GNUNET_OK, GNUNET_SCHEDULER_add_delayed(), GNUNET_sh2s(), GNUNET_STATISTICS_set(), GNUNET_SYSERR, GNUNET_TIME_absolute_get(), GNUNET_TIME_relative_multiply(), GNUNET_YES, GNUNET_CADET_ConnectionCreateMessage::header, CadetRoute::hn, keepalive_period, CadetRoute::last_use, LOG, map, max_routes, my_full_id, Rung::next, CadetRoute::next, options, GNUNET_CADET_ConnectionCreateMessage::options, CadetRoute::options, CadetRoute::prev, route_message(), send_broken_without_mqm(), size, GNUNET_MessageHeader::size, stats, and timeout_cb().

791 {
792  struct CadetPeer *sender = cls;
793  struct CadetPeer *next;
794  const struct GNUNET_PeerIdentity *pids = (const struct GNUNET_PeerIdentity *) &msg[1];
795  struct CadetRoute *route;
796  uint16_t size = ntohs (msg->header.size) - sizeof (*msg);
797  unsigned int path_length;
798  unsigned int off;
800 
801  options = (enum GNUNET_CADET_ChannelOption) ntohl (msg->options);
802  path_length = size / sizeof (struct GNUNET_PeerIdentity);
803  if (0 == path_length)
804  {
806  "Dropping CADET_CONNECTION_CREATE with empty path\n");
807  GNUNET_break_op (0);
808  return;
809  }
811  "Handling CADET_CONNECTION_CREATE from %s for CID %s with %u hops\n",
812  GCP_2s (sender),
814  path_length);
815  /* Check for loops */
816  {
818 
819  map = GNUNET_CONTAINER_multipeermap_create (path_length * 2,
820  GNUNET_YES);
821  GNUNET_assert (NULL != map);
822  for (unsigned int i=0;i<path_length;i++)
823  {
825  "CADET_CONNECTION_CREATE has peer %s at offset %u\n",
826  GNUNET_i2s (&pids[i]),
827  i);
828  if (GNUNET_SYSERR ==
830  &pids[i],
831  NULL,
833  {
834  /* bogus request */
837  "Dropping CADET_CONNECTION_CREATE with cyclic path\n");
838  GNUNET_break_op (0);
839  return;
840  }
841  }
843  }
844  /* Initiator is at offset 0, find us */
845  for (off=1;off<path_length;off++)
846  if (0 == GNUNET_memcmp (&my_full_id,
847  &pids[off]))
848  break;
849  if (off == path_length)
850  {
852  "Dropping CADET_CONNECTION_CREATE without us in the path\n");
853  GNUNET_break_op (0);
854  return;
855  }
856  /* Check previous hop */
857  if (sender != GCP_get (&pids[off - 1],
858  GNUNET_NO))
859  {
861  "Dropping CADET_CONNECTION_CREATE without sender at previous hop in the path\n");
862  GNUNET_break_op (0);
863  return;
864  }
865  if (NULL !=
866  (route = get_route (&msg->cid)))
867  {
868  /* Duplicate CREATE, pass it on, previous one might have been lost! */
869 
871  "Passing on duplicate CADET_CONNECTION_CREATE message on connection %s\n",
873  route_message (sender,
874  &msg->cid,
875  &msg->header);
876  return;
877  }
878  if (off == path_length - 1)
879  {
880  /* We are the destination, create connection */
881  struct CadetConnection *cc;
882  struct CadetPeerPath *path;
883  struct CadetPeer *origin;
884 
885  cc = GCC_lookup (&msg->cid);
886  if (NULL != cc)
887  {
889  "Received duplicate CADET_CONNECTION_CREATE message on connection %s\n",
892  return;
893  }
894 
895  origin = GCP_get (&pids[0],
896  GNUNET_YES);
898  "I am destination for CADET_CONNECTION_CREATE message from %s for connection %s, building inverse path\n",
899  GCP_2s (origin),
901  path = GCPP_get_path_from_route (path_length - 1,
902  pids);
903  if (GNUNET_OK !=
905  GNUNET_YES),
906  &msg->cid,
907  (enum GNUNET_CADET_ChannelOption) ntohl (msg->options),
908  path))
909  {
910  /* Send back BROKEN: duplicate connection on the same path,
911  we will use the other one. */
913  "Received CADET_CONNECTION_CREATE from %s for %s, but %s already has a connection. Sending BROKEN\n",
914  GCP_2s (sender),
916  GCPP_2s (path));
917  send_broken_without_mqm (sender,
918  &msg->cid,
919  NULL);
920  return;
921  }
922  return;
923  }
924  /* We are merely a hop on the way, check if we can support the route */
925  next = GCP_get (&pids[off + 1],
926  GNUNET_NO);
927  if ( (NULL == next) ||
928  (GNUNET_NO == GCP_has_core_connection (next)) )
929  {
930  /* unworkable, send back BROKEN notification */
932  "Received CADET_CONNECTION_CREATE from %s for %s. Next hop %s:%u is down. Sending BROKEN\n",
933  GCP_2s (sender),
935  GNUNET_i2s (&pids[off + 1]),
936  off + 1);
937  send_broken_without_mqm (sender,
938  &msg->cid,
939  &pids[off + 1]);
940  return;
941  }
943  {
945  "Received CADET_CONNECTION_CREATE from %s for %s. We have reached our route limit. Sending BROKEN\n",
946  GCP_2s (sender),
948  send_broken_without_mqm (sender,
949  &msg->cid,
950  &pids[off - 1]);
951  return;
952  }
953 
954  /* Workable route, create routing entry */
956  "Received CADET_CONNECTION_CREATE from %s for %s. Next hop %s:%u is up. Creating route\n",
957  GCP_2s (sender),
959  GNUNET_i2s (&pids[off + 1]),
960  off + 1);
961  route = GNUNET_new (struct CadetRoute);
962  route->options = options;
963  route->cid = msg->cid;
965  dir_init (&route->prev,
966  route,
967  sender);
968  dir_init (&route->next,
969  route,
970  next);
973  &route->cid.connection_of_tunnel,
974  route,
977  "# routes",
979  GNUNET_NO);
981  route,
982  route->last_use.abs_value_us);
983  if (NULL == timeout_task)
985  3),
986  &timeout_cb,
987  NULL);
988  /* also pass CREATE message along to next hop */
989  route_message (sender,
990  &msg->cid,
991  &msg->header);
992 }
static struct GNUNET_STATISTICS_Handle * stats
Handle for statistics.
const char * GNUNET_sh2s(const struct GNUNET_ShortHashCode *shc)
Convert a short hash value to a string (for printing debug messages).
static void dir_init(struct RouteDirection *dir, struct CadetRoute *route, struct CadetPeer *hop)
Initialize one of the directions of a route.
Peer description.
int GCT_add_inbound_connection(struct CadetTunnel *t, const struct GNUNET_CADET_ConnectionTunnelIdentifier *cid, enum GNUNET_CADET_ChannelOption options, struct CadetPeerPath *path)
Add a connection to the tunnel.
Low-level connection to a destination.
struct CadetTunnel * GCP_get_tunnel(struct CadetPeer *cp, int create)
Get the tunnel towards a peer.
unsigned int GNUNET_CONTAINER_multishortmap_size(const struct GNUNET_CONTAINER_MultiShortmap *map)
Get the number of key-value pairs in the map.
struct GNUNET_CONTAINER_HeapNode * GNUNET_CONTAINER_heap_insert(struct GNUNET_CONTAINER_Heap *heap, void *element, GNUNET_CONTAINER_HeapCostType cost)
Inserts a new element into the heap.
struct GNUNET_GETOPT_CommandLineOption options[]
Definition: 002.c:5
struct GNUNET_CONTAINER_HeapNode * hn
Position of this route in the route_heap.
static unsigned long long max_routes
Maximum number of concurrent routes this peer will support.
#define LOG(level,...)
struct GNUNET_MessageHeader header
Type: GNUNET_MESSAGE_TYPE_CADET_CONNECTION_CREATE.
struct GNUNET_PeerIdentity my_full_id
Local peer own ID.
#define GNUNET_assert(cond)
Use this for fatal errors that cannot be handled.
#define GNUNET_NO
Definition: gnunet_common.h:81
#define GNUNET_OK
Named constants for return values.
Definition: gnunet_common.h:78
#define GNUNET_new(type)
Allocate a struct or union of the given type.
uint16_t size
The length of the struct (in bytes, including the length field itself), in big-endian format...
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).
uint64_t abs_value_us
The actual value.
void GNUNET_CONTAINER_multipeermap_destroy(struct GNUNET_CONTAINER_MultiPeerMap *map)
Destroy a hash map.
static struct GNUNET_CONTAINER_MultiPeerMap * map
Handle to the map used to store old latency values for peers.
const char * GCP_2s(const struct CadetPeer *cp)
Get the static string for a peer ID.
struct GNUNET_CADET_ConnectionTunnelIdentifier cid
Unique identifier for the connection that uses this route.
const char * GCPP_2s(struct CadetPeerPath *path)
Convert a path to a human-readable string.
struct GNUNET_SCHEDULER_Task * GNUNET_SCHEDULER_add_delayed(struct GNUNET_TIME_Relative delay, GNUNET_SCHEDULER_TaskCallback task, void *task_cls)
Schedule a new task to be run with a specified delay.
Definition: scheduler.c:1246
static struct CadetRoute * get_route(const struct GNUNET_CADET_ConnectionTunnelIdentifier *cid)
Get the route corresponding to a hash.
struct CadetPeerPath * GCPP_get_path_from_route(unsigned int path_length, const struct GNUNET_PeerIdentity *pids)
We got an incoming connection, obtain the corresponding path.
#define GNUNET_break_op(cond)
Use this for assertion violations caused by other peers (i.e.
struct RouteDirection prev
Information about the previous hop on this route.
Description of a segment of a struct CadetConnection at the intermediate peers.
struct GNUNET_TIME_Absolute last_use
When was this route last in use?
int GNUNET_CONTAINER_multishortmap_put(struct GNUNET_CONTAINER_MultiShortmap *map, const struct GNUNET_ShortHashCode *key, void *value, enum GNUNET_CONTAINER_MultiHashMapOption opt)
Store a key-value pair in the map.
struct GNUNET_TIME_Relative GNUNET_TIME_relative_multiply(struct GNUNET_TIME_Relative rel, unsigned long long factor)
Multiply relative time by a given factor.
Definition: time.c:439
Internal representation of the hash map.
void GNUNET_STATISTICS_set(struct GNUNET_STATISTICS_Handle *handle, const char *name, uint64_t value, int make_persistent)
Set statistic value for the peer.
struct RouteDirection next
Information about the next hop on this route.
struct GNUNET_TIME_Absolute GNUNET_TIME_absolute_get(void)
Get the current time.
Definition: time.c:118
enum GNUNET_CADET_ChannelOption options
Options for the route, control buffering.
static void route_message(struct CadetPeer *prev, const struct GNUNET_CADET_ConnectionTunnelIdentifier *cid, const struct GNUNET_MessageHeader *msg)
We message msg from prev.
void GCC_handle_duplicate_create(struct CadetConnection *cc)
We got a GNUNET_MESSAGE_TYPE_CADET_CONNECTION_CREATE for a connection that we already have...
There must only be one value per key; storing a value should fail if a value under the same key alrea...
#define GNUNET_SYSERR
Definition: gnunet_common.h:79
static unsigned int size
Size of the "table".
Definition: peer.c:67
#define GNUNET_memcmp(a, b)
Compare memory in a and b, where both must be of the same pointer type.
int GCP_has_core_connection(struct CadetPeer *cp)
Test if cp has a core-level connection.
struct CadetConnection * GCC_lookup(const struct GNUNET_CADET_ConnectionTunnelIdentifier *cid)
Lookup a connection by its identifier.
int GNUNET_CONTAINER_multipeermap_put(struct GNUNET_CONTAINER_MultiPeerMap *map, const struct GNUNET_PeerIdentity *key, void *value, enum GNUNET_CONTAINER_MultiHashMapOption opt)
Store a key-value pair in the map.
The identity of the host (wraps the signing key of the peer).
static struct GNUNET_CONTAINER_Heap * route_heap
Heap of routes, MIN-sorted by last activity.
static struct GNUNET_SCHEDULER_Task * timeout_task
Task to timeout routes.
struct CadetPeer * GCP_get(const struct GNUNET_PeerIdentity *peer_id, int create)
Retrieve the CadetPeer stucture associated with the peer.
struct GNUNET_TIME_Relative keepalive_period
How frequently do we send KEEPALIVE messages on idle connections?
#define GNUNET_YES
Definition: gnunet_common.h:80
static void send_broken_without_mqm(struct CadetPeer *target, const struct GNUNET_CADET_ConnectionTunnelIdentifier *cid, const struct GNUNET_PeerIdentity *failure_at)
We could not create the desired route.
uint32_t options
Connection options in network byte order.
static void timeout_cb(void *cls)
Function called to check if any routes have timed out, and if so, to clean them up.
Information regarding a possible path to reach a peer.
struct GNUNET_ShortHashCode connection_of_tunnel
GNUNET_CADET_ChannelOption
Channel options.
struct GNUNET_CADET_ConnectionTunnelIdentifier cid
ID of the connection.
const char * GNUNET_i2s(const struct GNUNET_PeerIdentity *pid)
Convert a peer identity to a string (for printing debug messages).
static struct GNUNET_CONTAINER_MultiShortmap * routes
Routes on which this peer is an intermediate.
Here is the call graph for this function:

◆ handle_connection_create_ack()

static void handle_connection_create_ack ( void *  cls,
const struct GNUNET_CADET_ConnectionCreateAckMessage msg 
)
static

Handle for GNUNET_MESSAGE_TYPE_CADET_CONNECTION_CREATE_ACK.

Parameters
clsClosure (CadetPeer for neighbor that sent the message).
msgMessage itself.

Definition at line 1002 of file gnunet-service-cadet_core.c.

References GNUNET_CADET_ConnectionCreateAckMessage::cid, GNUNET_CADET_ConnectionTunnelIdentifier::connection_of_tunnel, GCC_get_path(), GCC_handle_connection_create_ack(), GCC_lookup(), GCPP_get_peer_at_offset(), GNUNET_break_op, GNUNET_ERROR_TYPE_DEBUG, GNUNET_sh2s(), GNUNET_CADET_ConnectionCreateAckMessage::header, len, LOG, peer, and route_message().

1004 {
1005  struct CadetPeer *peer = cls;
1006  struct CadetConnection *cc;
1007 
1008  /* First, check if ACK belongs to a connection that ends here. */
1009  cc = GCC_lookup (&msg->cid);
1010  if (NULL != cc)
1011  {
1012  /* verify ACK came from the right direction */
1013  unsigned int len;
1014  struct CadetPeerPath *path = GCC_get_path (cc,
1015  &len);
1016 
1017  if (peer !=
1019  0))
1020  {
1021  /* received ACK from unexpected direction, ignore! */
1022  GNUNET_break_op (0);
1023  return;
1024  }
1026  "Received CONNECTION_CREATE_ACK for connection %s.\n",
1029  return;
1030  }
1031 
1032  /* We're just an intermediary peer, route the message along its path */
1033  route_message (peer,
1034  &msg->cid,
1035  &msg->header);
1036 }
const char * GNUNET_sh2s(const struct GNUNET_ShortHashCode *shc)
Convert a short hash value to a string (for printing debug messages).
Peer description.
Low-level connection to a destination.
#define LOG(level,...)
void GCC_handle_connection_create_ack(struct CadetConnection *cc)
A GNUNET_MESSAGE_TYPE_CADET_CONNECTION_CREATE_ACK was received for this connection, implying that the end-to-end connection is up.
struct GNUNET_MessageHeader header
Type: GNUNET_MESSAGE_TYPE_CADET_CONNECTION_CREATE_ACK.
#define GNUNET_break_op(cond)
Use this for assertion violations caused by other peers (i.e.
static void route_message(struct CadetPeer *prev, const struct GNUNET_CADET_ConnectionTunnelIdentifier *cid, const struct GNUNET_MessageHeader *msg)
We message msg from prev.
struct GNUNET_TESTBED_Peer * peer
The peer associated with this model.
struct CadetPeerPath * GCC_get_path(struct CadetConnection *cc, unsigned int *off)
Obtain the path used by this connection.
struct CadetConnection * GCC_lookup(const struct GNUNET_CADET_ConnectionTunnelIdentifier *cid)
Lookup a connection by its identifier.
struct CadetPeer * GCPP_get_peer_at_offset(struct CadetPeerPath *path, unsigned int off)
Obtain the peer at offset off in path.
Information regarding a possible path to reach a peer.
struct GNUNET_ShortHashCode connection_of_tunnel
struct GNUNET_CADET_ConnectionTunnelIdentifier cid
ID of the connection.
uint16_t len
length of data (which is always a uint32_t, but presumably this can be used to specify that fewer byt...
Here is the call graph for this function:

◆ handle_connection_broken()

static void handle_connection_broken ( void *  cls,
const struct GNUNET_CADET_ConnectionBrokenMessage msg 
)
static

Handle for GNUNET_MESSAGE_TYPE_CADET_CONNECTION_BROKEN.

Parameters
clsClosure (CadetPeer for neighbor that sent the message).
msgMessage itself.
Deprecated:
duplicate logic with #handle_destroy(); dedup!

Definition at line 1047 of file gnunet-service-cadet_core.c.

References GNUNET_CADET_ConnectionBrokenMessage::cid, GNUNET_CADET_ConnectionTunnelIdentifier::connection_of_tunnel, destroy_route(), GCC_destroy_without_core(), GCC_get_path(), GCC_lookup(), GCPP_get_peer_at_offset(), get_route(), GNUNET_break_op, GNUNET_ERROR_TYPE_DEBUG, GNUNET_sh2s(), GNUNET_CADET_ConnectionBrokenMessage::header, len, LOG, peer, and route_message().

1049 {
1050  struct CadetPeer *peer = cls;
1051  struct CadetConnection *cc;
1052  struct CadetRoute *route;
1053 
1054  /* First, check if message belongs to a connection that ends here. */
1055  cc = GCC_lookup (&msg->cid);
1056  if (NULL != cc)
1057  {
1058  /* verify message came from the right direction */
1059  unsigned int len;
1060  struct CadetPeerPath *path = GCC_get_path (cc,
1061  &len);
1062 
1063  if (peer !=
1065  0))
1066  {
1067  /* received message from unexpected direction, ignore! */
1068  GNUNET_break_op (0);
1069  return;
1070  }
1072  "Received CONNECTION_BROKEN for connection %s. Destroying it.\n",
1075 
1076  /* FIXME: also destroy the path up to the specified link! */
1077  return;
1078  }
1079 
1080  /* We're just an intermediary peer, route the message along its path */
1081  route_message (peer,
1082  &msg->cid,
1083  &msg->header);
1084  route = get_route (&msg->cid);
1085  if (NULL != route)
1086  destroy_route (route);
1087  /* FIXME: also destroy paths we MAY have up to the specified link! */
1088 }
const char * GNUNET_sh2s(const struct GNUNET_ShortHashCode *shc)
Convert a short hash value to a string (for printing debug messages).
Peer description.
Low-level connection to a destination.
#define LOG(level,...)
void GCC_destroy_without_core(struct CadetConnection *cc)
Destroy a connection, called when the CORE layer is already done (i.e.
static void destroy_route(struct CadetRoute *route)
Destroy our state for route.
static struct CadetRoute * get_route(const struct GNUNET_CADET_ConnectionTunnelIdentifier *cid)
Get the route corresponding to a hash.
#define GNUNET_break_op(cond)
Use this for assertion violations caused by other peers (i.e.
Description of a segment of a struct CadetConnection at the intermediate peers.
struct GNUNET_CADET_ConnectionTunnelIdentifier cid
ID of the connection.
static void route_message(struct CadetPeer *prev, const struct GNUNET_CADET_ConnectionTunnelIdentifier *cid, const struct GNUNET_MessageHeader *msg)
We message msg from prev.
struct GNUNET_TESTBED_Peer * peer
The peer associated with this model.
struct CadetPeerPath * GCC_get_path(struct CadetConnection *cc, unsigned int *off)
Obtain the path used by this connection.
struct CadetConnection * GCC_lookup(const struct GNUNET_CADET_ConnectionTunnelIdentifier *cid)
Lookup a connection by its identifier.
struct CadetPeer * GCPP_get_peer_at_offset(struct CadetPeerPath *path, unsigned int off)
Obtain the peer at offset off in path.
Information regarding a possible path to reach a peer.
struct GNUNET_ShortHashCode connection_of_tunnel
struct GNUNET_MessageHeader header
Type: GNUNET_MESSAGE_TYPE_CADET_CONNECTION_BROKEN.
uint16_t len
length of data (which is always a uint32_t, but presumably this can be used to specify that fewer byt...
Here is the call graph for this function:

◆ handle_connection_destroy()

static void handle_connection_destroy ( void *  cls,
const struct GNUNET_CADET_ConnectionDestroyMessage msg 
)
static

Handle for GNUNET_MESSAGE_TYPE_CADET_CONNECTION_DESTROY.

Parameters
clsClosure (CadetPeer for neighbor that sent the message).
msgMessage itself.

Definition at line 1098 of file gnunet-service-cadet_core.c.

References GNUNET_CADET_ConnectionDestroyMessage::cid, GNUNET_CADET_ConnectionTunnelIdentifier::connection_of_tunnel, destroy_route(), GCC_destroy_without_core(), GCC_get_path(), GCC_lookup(), GCPP_get_peer_at_offset(), get_route(), GNUNET_break_op, GNUNET_ERROR_TYPE_DEBUG, GNUNET_sh2s(), GNUNET_CADET_ConnectionDestroyMessage::header, len, LOG, peer, and route_message().

1100 {
1101  struct CadetPeer *peer = cls;
1102  struct CadetConnection *cc;
1103  struct CadetRoute *route;
1104 
1105  /* First, check if message belongs to a connection that ends here. */
1106  cc = GCC_lookup (&msg->cid);
1107  if (NULL != cc)
1108  {
1109  /* verify message came from the right direction */
1110  unsigned int len;
1111  struct CadetPeerPath *path = GCC_get_path (cc,
1112  &len);
1113 
1114  if (peer !=
1116  0))
1117  {
1118  /* received message from unexpected direction, ignore! */
1119  GNUNET_break_op (0);
1120  return;
1121  }
1123  "Received CONNECTION_DESTROY for connection %s. Destroying connection.\n",
1125 
1127  return;
1128  }
1129 
1130  /* We're just an intermediary peer, route the message along its path */
1132  "Received CONNECTION_DESTROY for connection %s. Destroying route.\n",
1134  route_message (peer,
1135  &msg->cid,
1136  &msg->header);
1137  route = get_route (&msg->cid);
1138  if (NULL != route)
1139  destroy_route (route);
1140 }
const char * GNUNET_sh2s(const struct GNUNET_ShortHashCode *shc)
Convert a short hash value to a string (for printing debug messages).
Peer description.
Low-level connection to a destination.
#define LOG(level,...)
void GCC_destroy_without_core(struct CadetConnection *cc)
Destroy a connection, called when the CORE layer is already done (i.e.
static void destroy_route(struct CadetRoute *route)
Destroy our state for route.
static struct CadetRoute * get_route(const struct GNUNET_CADET_ConnectionTunnelIdentifier *cid)
Get the route corresponding to a hash.
#define GNUNET_break_op(cond)
Use this for assertion violations caused by other peers (i.e.
Description of a segment of a struct CadetConnection at the intermediate peers.
struct GNUNET_CADET_ConnectionTunnelIdentifier cid
ID of the connection.
static void route_message(struct CadetPeer *prev, const struct GNUNET_CADET_ConnectionTunnelIdentifier *cid, const struct GNUNET_MessageHeader *msg)
We message msg from prev.
struct GNUNET_TESTBED_Peer * peer
The peer associated with this model.
struct CadetPeerPath * GCC_get_path(struct CadetConnection *cc, unsigned int *off)
Obtain the path used by this connection.
struct CadetConnection * GCC_lookup(const struct GNUNET_CADET_ConnectionTunnelIdentifier *cid)
Lookup a connection by its identifier.
struct CadetPeer * GCPP_get_peer_at_offset(struct CadetPeerPath *path, unsigned int off)
Obtain the peer at offset off in path.
Information regarding a possible path to reach a peer.
struct GNUNET_ShortHashCode connection_of_tunnel
uint16_t len
length of data (which is always a uint32_t, but presumably this can be used to specify that fewer byt...
struct GNUNET_MessageHeader header
Type: GNUNET_MESSAGE_TYPE_CADET_CONNECTION_DESTROY.
Here is the call graph for this function:

◆ handle_tunnel_kx()

static void handle_tunnel_kx ( void *  cls,
const struct GNUNET_CADET_TunnelKeyExchangeMessage msg 
)
static

Handle for GNUNET_MESSAGE_TYPE_CADET_TUNNEL_KX.

Parameters
clsClosure (CadetPeer for neighbor that sent the message).
msgMessage itself.

Definition at line 1150 of file gnunet-service-cadet_core.c.

References GNUNET_CADET_TunnelKeyExchangeMessage::cid, GNUNET_CADET_ConnectionTunnelIdentifier::connection_of_tunnel, GNUNET_CADET_TunnelKeyExchangeMessage::ephemeral_key, GCC_get_path(), GCC_handle_kx(), GCC_lookup(), GCPP_get_peer_at_offset(), GNUNET_break_op, GNUNET_e2s(), GNUNET_ERROR_TYPE_DEBUG, GNUNET_sh2s(), GNUNET_CADET_TunnelKeyExchangeMessage::header, len, LOG, peer, and route_message().

1152 {
1153  struct CadetPeer *peer = cls;
1154  struct CadetConnection *cc;
1155 
1156  /* First, check if message belongs to a connection that ends here. */
1158  "Routing KX with ephemeral %s on CID %s\n",
1159  GNUNET_e2s (&msg->ephemeral_key),
1161 
1162 
1163  cc = GCC_lookup (&msg->cid);
1164  if (NULL != cc)
1165  {
1166  /* verify message came from the right direction */
1167  unsigned int len;
1168  struct CadetPeerPath *path = GCC_get_path (cc,
1169  &len);
1170 
1171  if (peer !=
1173  0))
1174  {
1175  /* received message from unexpected direction, ignore! */
1176  GNUNET_break_op (0);
1177  return;
1178  }
1179  GCC_handle_kx (cc,
1180  msg);
1181  return;
1182  }
1183 
1184  /* We're just an intermediary peer, route the message along its path */
1185  route_message (peer,
1186  &msg->cid,
1187  &msg->header);
1188 }
const char * GNUNET_sh2s(const struct GNUNET_ShortHashCode *shc)
Convert a short hash value to a string (for printing debug messages).
Peer description.
Low-level connection to a destination.
#define LOG(level,...)
void GCC_handle_kx(struct CadetConnection *cc, const struct GNUNET_CADET_TunnelKeyExchangeMessage *msg)
Handle KX message.
#define GNUNET_break_op(cond)
Use this for assertion violations caused by other peers (i.e.
struct GNUNET_CADET_ConnectionTunnelIdentifier cid
ID of the connection.
static void route_message(struct CadetPeer *prev, const struct GNUNET_CADET_ConnectionTunnelIdentifier *cid, const struct GNUNET_MessageHeader *msg)
We message msg from prev.
struct GNUNET_TESTBED_Peer * peer
The peer associated with this model.
struct CadetPeerPath * GCC_get_path(struct CadetConnection *cc, unsigned int *off)
Obtain the path used by this connection.
struct CadetConnection * GCC_lookup(const struct GNUNET_CADET_ConnectionTunnelIdentifier *cid)
Lookup a connection by its identifier.
struct GNUNET_MessageHeader header
Type: GNUNET_MESSAGE_TYPE_CADET_TUNNEL_KX or GNUNET_MESSAGE_TYPE_CADET_TUNNEL_KX_AUTH as part of stru...
struct CadetPeer * GCPP_get_peer_at_offset(struct CadetPeerPath *path, unsigned int off)
Obtain the peer at offset off in path.
struct GNUNET_CRYPTO_EcdhePublicKey ephemeral_key
Sender&#39;s ephemeral public ECC key encoded in a format suitable for network transmission, as created using &#39;gcry_sexp_sprint&#39;.
const char * GNUNET_e2s(const struct GNUNET_CRYPTO_EcdhePublicKey *p)
Convert a public key value to a string (for printing debug messages).
Information regarding a possible path to reach a peer.
struct GNUNET_ShortHashCode connection_of_tunnel
uint16_t len
length of data (which is always a uint32_t, but presumably this can be used to specify that fewer byt...
Here is the call graph for this function:

◆ handle_tunnel_kx_auth()

static void handle_tunnel_kx_auth ( void *  cls,
const struct GNUNET_CADET_TunnelKeyExchangeAuthMessage msg 
)
static

Handle for GNUNET_MESSAGE_TYPE_CADET_TUNNEL_KX_AUTH.

Parameters
clsClosure (CadetPeer for neighbor that sent the message).
msgMessage itself.

Definition at line 1198 of file gnunet-service-cadet_core.c.

References GNUNET_CADET_TunnelKeyExchangeMessage::cid, GCC_get_path(), GCC_handle_kx_auth(), GCC_lookup(), GCPP_get_peer_at_offset(), GNUNET_break_op, GNUNET_CADET_TunnelKeyExchangeMessage::header, GNUNET_CADET_TunnelKeyExchangeAuthMessage::kx, len, peer, and route_message().

1200 {
1201  struct CadetPeer *peer = cls;
1202  struct CadetConnection *cc;
1203 
1204  /* First, check if message belongs to a connection that ends here. */
1205  cc = GCC_lookup (&msg->kx.cid);
1206  if (NULL != cc)
1207  {
1208  /* verify message came from the right direction */
1209  unsigned int len;
1210  struct CadetPeerPath *path = GCC_get_path (cc,
1211  &len);
1212 
1213  if (peer !=
1215  0))
1216  {
1217  /* received message from unexpected direction, ignore! */
1218  GNUNET_break_op (0);
1219  return;
1220  }
1221  GCC_handle_kx_auth (cc,
1222  msg);
1223  return;
1224  }
1225 
1226  /* We're just an intermediary peer, route the message along its path */
1227  route_message (peer,
1228  &msg->kx.cid,
1229  &msg->kx.header);
1230 }
Peer description.
Low-level connection to a destination.
struct GNUNET_CADET_TunnelKeyExchangeMessage kx
Message header with key material.
#define GNUNET_break_op(cond)
Use this for assertion violations caused by other peers (i.e.
struct GNUNET_CADET_ConnectionTunnelIdentifier cid
ID of the connection.
static void route_message(struct CadetPeer *prev, const struct GNUNET_CADET_ConnectionTunnelIdentifier *cid, const struct GNUNET_MessageHeader *msg)
We message msg from prev.
struct GNUNET_TESTBED_Peer * peer
The peer associated with this model.
struct CadetPeerPath * GCC_get_path(struct CadetConnection *cc, unsigned int *off)
Obtain the path used by this connection.
struct CadetConnection * GCC_lookup(const struct GNUNET_CADET_ConnectionTunnelIdentifier *cid)
Lookup a connection by its identifier.
struct GNUNET_MessageHeader header
Type: GNUNET_MESSAGE_TYPE_CADET_TUNNEL_KX or GNUNET_MESSAGE_TYPE_CADET_TUNNEL_KX_AUTH as part of stru...
struct CadetPeer * GCPP_get_peer_at_offset(struct CadetPeerPath *path, unsigned int off)
Obtain the peer at offset off in path.
void GCC_handle_kx_auth(struct CadetConnection *cc, const struct GNUNET_CADET_TunnelKeyExchangeAuthMessage *msg)
Handle KX_AUTH message.
Information regarding a possible path to reach a peer.
uint16_t len
length of data (which is always a uint32_t, but presumably this can be used to specify that fewer byt...
Here is the call graph for this function:

◆ check_tunnel_encrypted()

static int check_tunnel_encrypted ( void *  cls,
const struct GNUNET_CADET_TunnelEncryptedMessage msg 
)
static

Check if the encrypted message has the appropriate size.

Parameters
clsClosure (unused).
msgMessage to check.
Returns
GNUNET_YES if size is correct, GNUNET_NO otherwise.

Definition at line 1242 of file gnunet-service-cadet_core.c.

References GNUNET_YES.

1244 {
1245  return GNUNET_YES;
1246 }
#define GNUNET_YES
Definition: gnunet_common.h:80

◆ handle_tunnel_encrypted()

static void handle_tunnel_encrypted ( void *  cls,
const struct GNUNET_CADET_TunnelEncryptedMessage msg 
)
static

Handle for GNUNET_MESSAGE_TYPE_CADET_TUNNEL_ENCRYPTED.

Parameters
clsClosure (CadetPeer for neighbor that sent the message).
msgMessage itself.

Definition at line 1256 of file gnunet-service-cadet_core.c.

References GNUNET_CADET_TunnelEncryptedMessage::cid, GCC_get_path(), GCC_handle_encrypted(), GCC_lookup(), GCPP_get_peer_at_offset(), GNUNET_break_op, GNUNET_CADET_TunnelEncryptedMessage::header, len, peer, and route_message().

1258 {
1259  struct CadetPeer *peer = cls;
1260  struct CadetConnection *cc;
1261 
1262  /* First, check if message belongs to a connection that ends here. */
1263  cc = GCC_lookup (&msg->cid);
1264  if (NULL != cc)
1265  {
1266  /* verify message came from the right direction */
1267  unsigned int len;
1268  struct CadetPeerPath *path = GCC_get_path (cc,
1269  &len);
1270 
1271  if (peer !=
1273  0))
1274  {
1275  /* received message from unexpected direction, ignore! */
1276  GNUNET_break_op (0);
1277  return;
1278  }
1280  msg);
1281  return;
1282  }
1283  /* We're just an intermediary peer, route the message along its path */
1284  route_message (peer,
1285  &msg->cid,
1286  &msg->header);
1287 }
Peer description.
Low-level connection to a destination.
#define GNUNET_break_op(cond)
Use this for assertion violations caused by other peers (i.e.
struct GNUNET_MessageHeader header
Type: GNUNET_MESSAGE_TYPE_CADET_TUNNEL_ENCRYPTED.
struct GNUNET_CADET_ConnectionTunnelIdentifier cid
ID of the connection.
static void route_message(struct CadetPeer *prev, const struct GNUNET_CADET_ConnectionTunnelIdentifier *cid, const struct GNUNET_MessageHeader *msg)
We message msg from prev.
struct GNUNET_TESTBED_Peer * peer
The peer associated with this model.
struct CadetPeerPath * GCC_get_path(struct CadetConnection *cc, unsigned int *off)
Obtain the path used by this connection.
struct CadetConnection * GCC_lookup(const struct GNUNET_CADET_ConnectionTunnelIdentifier *cid)
Lookup a connection by its identifier.
void GCC_handle_encrypted(struct CadetConnection *cc, const struct GNUNET_CADET_TunnelEncryptedMessage *msg)
Handle encrypted message.
struct CadetPeer * GCPP_get_peer_at_offset(struct CadetPeerPath *path, unsigned int off)
Obtain the peer at offset off in path.
Information regarding a possible path to reach a peer.
uint16_t len
length of data (which is always a uint32_t, but presumably this can be used to specify that fewer byt...
Here is the call graph for this function:

◆ core_init_cb()

static void core_init_cb ( void *  cls,
const struct GNUNET_PeerIdentity my_identity 
)
static

Function called after GNUNET_CORE_connect has succeeded (or failed for good).

Note that the private key of the peer is intentionally not exposed here; if you need it, your process should try to read the private key file directly (which should work if you are authorized...). Implementations of this function must not call GNUNET_CORE_disconnect (other than by scheduling a new task to do this later).

Parameters
clsclosure
my_identityID of this peer, NULL if we failed

Definition at line 1303 of file gnunet-service-cadet_core.c.

References GNUNET_break, GNUNET_memcmp, and my_full_id.

Referenced by GCO_init().

1305 {
1306  if (NULL == my_identity)
1307  {
1308  GNUNET_break (0);
1309  return;
1310  }
1311  GNUNET_break (0 ==
1312  GNUNET_memcmp (my_identity,
1313  &my_full_id));
1314 }
struct GNUNET_PeerIdentity my_full_id
Local peer own ID.
#define GNUNET_break(cond)
Use this for internal assertion violations that are not fatal (can be handled) but should not occur...
#define GNUNET_memcmp(a, b)
Compare memory in a and b, where both must be of the same pointer type.
Here is the caller graph for this function:

◆ core_connect_cb()

static void* core_connect_cb ( void *  cls,
const struct GNUNET_PeerIdentity peer,
struct GNUNET_MQ_Handle mq 
)
static

Method called whenever a given peer connects.

Parameters
clsclosure
peerpeer identity this notification is about

Definition at line 1324 of file gnunet-service-cadet_core.c.

References GCP_get(), GCP_set_mq(), GNUNET_ERROR_TYPE_DEBUG, GNUNET_i2s(), GNUNET_YES, and LOG.

Referenced by GCO_init().

1327 {
1328  struct CadetPeer *cp;
1329 
1331  "CORE connection to peer %s was established.\n",
1332  GNUNET_i2s (peer));
1333  cp = GCP_get (peer,
1334  GNUNET_YES);
1335  GCP_set_mq (cp,
1336  mq);
1337  return cp;
1338 }
Peer description.
#define LOG(level,...)
void GCP_set_mq(struct CadetPeer *cp, struct GNUNET_MQ_Handle *mq)
Set the message queue to mq for peer cp and notify watchers.
struct CadetPeer * GCP_get(const struct GNUNET_PeerIdentity *peer_id, int create)
Retrieve the CadetPeer stucture associated with the peer.
#define GNUNET_YES
Definition: gnunet_common.h:80
const char * GNUNET_i2s(const struct GNUNET_PeerIdentity *pid)
Convert a peer identity to a string (for printing debug messages).
Here is the call graph for this function:
Here is the caller graph for this function:

◆ core_disconnect_cb()

static void core_disconnect_cb ( void *  cls,
const struct GNUNET_PeerIdentity peer,
void *  peer_cls 
)
static

Method called whenever a peer disconnects.

Parameters
clsclosure
peerpeer identity this notification is about

Definition at line 1348 of file gnunet-service-cadet_core.c.

References GCP_set_mq(), GNUNET_ERROR_TYPE_DEBUG, GNUNET_i2s(), and LOG.

Referenced by GCO_init().

1351 {
1352  struct CadetPeer *cp = peer_cls;
1353 
1355  "CORE connection to peer %s went down.\n",
1356  GNUNET_i2s (peer));
1357  GCP_set_mq (cp,
1358  NULL);
1359 }
Peer description.
#define LOG(level,...)
void GCP_set_mq(struct CadetPeer *cp, struct GNUNET_MQ_Handle *mq)
Set the message queue to mq for peer cp and notify watchers.
const char * GNUNET_i2s(const struct GNUNET_PeerIdentity *pid)
Convert a peer identity to a string (for printing debug messages).
Here is the call graph for this function:
Here is the caller graph for this function:

◆ GCO_init()

void GCO_init ( const struct GNUNET_CONFIGURATION_Handle c)

Initialize the CORE subsystem.

Parameters
cConfiguration.

Definition at line 1368 of file gnunet-service-cadet_core.c.

References connection_create(), core_connect_cb(), core_disconnect_cb(), core_init_cb(), GNUNET_CONFIGURATION_get_value_number(), GNUNET_CONTAINER_heap_create(), GNUNET_CONTAINER_HEAP_ORDER_MIN, GNUNET_CONTAINER_multishortmap_create(), GNUNET_CORE_connect(), GNUNET_MESSAGE_TYPE_CADET_CONNECTION_BROKEN, GNUNET_MESSAGE_TYPE_CADET_CONNECTION_CREATE, GNUNET_MESSAGE_TYPE_CADET_CONNECTION_CREATE_ACK, GNUNET_MESSAGE_TYPE_CADET_CONNECTION_DESTROY, GNUNET_MESSAGE_TYPE_CADET_TUNNEL_ENCRYPTED, GNUNET_MESSAGE_TYPE_CADET_TUNNEL_KX, GNUNET_MESSAGE_TYPE_CADET_TUNNEL_KX_AUTH, GNUNET_MQ_handler_end, GNUNET_MQ_hd_fixed_size, GNUNET_MQ_hd_var_size, GNUNET_NO, GNUNET_OK, max_buffers, and max_routes.

Referenced by run().

1369 {
1370  struct GNUNET_MQ_MessageHandler handlers[] = {
1374  NULL),
1375  GNUNET_MQ_hd_fixed_size (connection_create_ack,
1378  NULL),
1379  GNUNET_MQ_hd_fixed_size (connection_broken,
1382  NULL),
1383  GNUNET_MQ_hd_fixed_size (connection_destroy,
1386  NULL),
1387  GNUNET_MQ_hd_fixed_size (tunnel_kx,
1390  NULL),
1391  GNUNET_MQ_hd_fixed_size (tunnel_kx_auth,
1394  NULL),
1395  GNUNET_MQ_hd_var_size (tunnel_encrypted,
1398  NULL),
1400  };
1401 
1402  if (GNUNET_OK !=
1404  "CADET",
1405  "MAX_ROUTES",
1406  &max_routes))
1407  max_routes = 5000;
1408  if (GNUNET_OK !=
1410  "CADET",
1411  "MAX_MSGS_QUEUE",
1412  &max_buffers))
1413  max_buffers = 10000;
1415  GNUNET_NO);
1418  NULL,
1419  &core_init_cb,
1420  &core_connect_cb,
1422  handlers);
1423 }
Axolotl-encrypted tunnel message with application payload.
#define GNUNET_MESSAGE_TYPE_CADET_TUNNEL_ENCRYPTED
Axolotl encrypted data.
static unsigned long long max_buffers
Maximum number of envelopes we will buffer at this peer.
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.
Message to destroy a connection.
static unsigned long long max_routes
Maximum number of concurrent routes this peer will support.
static void core_disconnect_cb(void *cls, const struct GNUNET_PeerIdentity *peer, void *peer_cls)
Method called whenever a peer disconnects.
Message for ack&#39;ing a connection.
static struct CadetConnection * connection_create(struct CadetPeer *destination, struct CadetPeerPath *path, unsigned int off, enum GNUNET_CADET_ChannelOption options, struct CadetTConnection *ct, const struct GNUNET_CADET_ConnectionTunnelIdentifier *cid, enum CadetConnectionState init_state, GCC_ReadyCallback ready_cb, void *ready_cb_cls)
Create a connection to destination via path and notify cb whenever we are ready for more data...
#define GNUNET_MQ_hd_fixed_size(name, code, str, ctx)
#define GNUNET_NO
Definition: gnunet_common.h:81
#define GNUNET_OK
Named constants for return values.
Definition: gnunet_common.h:78
static void * core_connect_cb(void *cls, const struct GNUNET_PeerIdentity *peer, struct GNUNET_MQ_Handle *mq)
Method called whenever a given peer connects.
static struct GNUNET_CADET_MessageHandler handlers[]
Handlers, for diverse services.
#define GNUNET_MQ_hd_var_size(name, code, str, ctx)
Message for a Key eXchange for a tunnel, with authentication.
#define GNUNET_MESSAGE_TYPE_CADET_CONNECTION_CREATE
Request the creation of a connection.
Message for notifying a disconnection in a path.
#define GNUNET_MESSAGE_TYPE_CADET_CONNECTION_CREATE_ACK
Send origin an ACK that the connection is complete.
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).
Heap with the minimum cost at the root.
Message handler for a specific message type.
static void core_init_cb(void *cls, const struct GNUNET_PeerIdentity *my_identity)
Function called after GNUNET_CORE_connect has succeeded (or failed for good).
struct GNUNET_CORE_Handle * GNUNET_CORE_connect(const struct GNUNET_CONFIGURATION_Handle *cfg, void *cls, GNUNET_CORE_StartupCallback init, GNUNET_CORE_ConnectEventHandler connects, GNUNET_CORE_DisconnectEventHandler disconnects, const struct GNUNET_MQ_MessageHandler *handlers)
Connect to the core service.
Definition: core_api.c:694
struct GNUNET_CONTAINER_Heap * GNUNET_CONTAINER_heap_create(enum GNUNET_CONTAINER_HeapOrder order)
Create a new heap.
static struct GNUNET_CONTAINER_Heap * route_heap
Heap of routes, MIN-sorted by last activity.
#define GNUNET_MESSAGE_TYPE_CADET_CONNECTION_DESTROY
Request the destuction of a connection.
Message for a Key eXchange for a tunnel.
#define GNUNET_MESSAGE_TYPE_CADET_TUNNEL_KX_AUTH
Axolotl key exchange response with authentication.
#define GNUNET_MESSAGE_TYPE_CADET_CONNECTION_BROKEN
Notify that a connection is no longer valid.
Message for cadet connection creation.
#define GNUNET_MQ_handler_end()
End-marker for the handlers array.
static struct GNUNET_CORE_Handle * core
Handle to the CORE service.
#define GNUNET_MESSAGE_TYPE_CADET_TUNNEL_KX
Axolotl key exchange.
static struct GNUNET_CONTAINER_MultiShortmap * routes
Routes on which this peer is an intermediate.
Here is the call graph for this function:
Here is the caller graph for this function:

◆ GCO_shutdown()

void GCO_shutdown ( void  )

Shut down the CORE subsystem.

Definition at line 1430 of file gnunet-service-cadet_core.c.

References GNUNET_assert, GNUNET_CONTAINER_heap_destroy(), GNUNET_CONTAINER_multishortmap_destroy(), GNUNET_CONTAINER_multishortmap_size(), GNUNET_CORE_disconnect(), and GNUNET_SCHEDULER_cancel().

Referenced by shutdown_task().

1431 {
1432  if (NULL != core)
1433  {
1435  core = NULL;
1436  }
1439  routes = NULL;
1441  route_heap = NULL;
1442  if (NULL != timeout_task)
1443  {
1445  timeout_task = NULL;
1446  }
1447 }
unsigned int GNUNET_CONTAINER_multishortmap_size(const struct GNUNET_CONTAINER_MultiShortmap *map)
Get the number of key-value pairs in the map.
#define GNUNET_assert(cond)
Use this for fatal errors that cannot be handled.
void GNUNET_CONTAINER_heap_destroy(struct GNUNET_CONTAINER_Heap *heap)
Destroys the heap.
void GNUNET_CORE_disconnect(struct GNUNET_CORE_Handle *handle)
Disconnect from the core service.
Definition: core_api.c:732
void GNUNET_CONTAINER_multishortmap_destroy(struct GNUNET_CONTAINER_MultiShortmap *map)
Destroy a hash map.
static struct GNUNET_CONTAINER_Heap * route_heap
Heap of routes, MIN-sorted by last activity.
static struct GNUNET_SCHEDULER_Task * timeout_task
Task to timeout routes.
static struct GNUNET_CORE_Handle * core
Handle to the CORE service.
static struct GNUNET_CONTAINER_MultiShortmap * routes
Routes on which this peer is an intermediate.
void * GNUNET_SCHEDULER_cancel(struct GNUNET_SCHEDULER_Task *task)
Cancel the task with the specified identifier.
Definition: scheduler.c:965
Here is the call graph for this function:
Here is the caller graph for this function:

Variable Documentation

◆ core

struct GNUNET_CORE_Handle* core
static

Handle to the CORE service.

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

Referenced by inittransport_smtp().

◆ routes

struct GNUNET_CONTAINER_MultiShortmap* routes
static

Routes on which this peer is an intermediate.

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

◆ route_heap

struct GNUNET_CONTAINER_Heap* route_heap
static

Heap of routes, MIN-sorted by last activity.

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

◆ rung_zero

struct Rung rung_zero
static

Rung zero (always pointed to by rung_head).

Definition at line 208 of file gnunet-service-cadet_core.c.

◆ rung_head

struct Rung* rung_head = &rung_zero
static

DLL of rungs, with the head always point to a rung of route directions with no messages in the queue.

Definition at line 214 of file gnunet-service-cadet_core.c.

Referenced by dir_init().

◆ rung_tail

struct Rung* rung_tail = &rung_zero
static

Tail of the rung_head DLL.

Definition at line 219 of file gnunet-service-cadet_core.c.

Referenced by discard_all_from_rung_tail().

◆ max_routes

unsigned long long max_routes
static

Maximum number of concurrent routes this peer will support.

Definition at line 224 of file gnunet-service-cadet_core.c.

Referenced by GCO_init(), and handle_connection_create().

◆ max_buffers

unsigned long long max_buffers
static

Maximum number of envelopes we will buffer at this peer.

Definition at line 229 of file gnunet-service-cadet_core.c.

Referenced by GCO_init(), and route_message().

◆ cur_buffers

unsigned long long cur_buffers
static

Current number of envelopes we have buffered at this peer.

Definition at line 234 of file gnunet-service-cadet_core.c.

Referenced by dir_ready_cb(), discard_buffer(), and route_message().

◆ timeout_task

struct GNUNET_SCHEDULER_Task* timeout_task
static

Task to timeout routes.

Definition at line 239 of file gnunet-service-cadet_core.c.