GNUnet  0.11.x
Data Structures | Macros | Enumerations | Functions
gnunet-service-cadet_connection.c File Reference

management of CORE-level end-to-end connections; establishes end-to-end routes and transmits messages along the route More...

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

Go to the source code of this file.

Data Structures

struct  CadetConnection
 Low-level connection to a destination. More...
 

Macros

#define LOG(level, ...)   GNUNET_log_from (level, "cadet-con", __VA_ARGS__)
 
#define INITIAL_CONNECTION_CREATE_RETRY_DELAY   GNUNET_TIME_relative_multiply (GNUNET_TIME_UNIT_MILLISECONDS, 200)
 How long do we wait initially before retransmitting the KX? TODO: replace by 2 RTT if/once we have connection-level RTT data! More...
 
#define LOG2(level, ...)   GNUNET_log_from_nocheck (level, "cadet-con", __VA_ARGS__)
 

Enumerations

enum  CadetConnectionState {
  CADET_CONNECTION_NEW, CADET_CONNECTION_SENDING_CREATE, CADET_CONNECTION_SENT, CADET_CONNECTION_CREATE_RECEIVED,
  CADET_CONNECTION_READY
}
 All the states a connection can be in. More...
 

Functions

struct CadetConnectionGCC_lookup (const struct GNUNET_CADET_ConnectionTunnelIdentifier *cid)
 Lookup a connection by its identifier. More...
 
static void update_state (struct CadetConnection *cc, enum CadetConnectionState new_state, int new_mqm_ready)
 Update the connection state. More...
 
static void GCC_destroy (struct CadetConnection *cc)
 Destroy a connection, part of the internal implementation. More...
 
void GCC_destroy_without_core (struct CadetConnection *cc)
 Destroy a connection, called when the CORE layer is already done (i.e. More...
 
void GCC_destroy_without_tunnel (struct CadetConnection *cc)
 Destroy a connection, called if the tunnel association with the connection was already broken, but we still need to notify the CORE layer about the breakage. More...
 
struct CadetTConnectionGCC_get_ct (struct CadetConnection *cc)
 Return the tunnel associated with this connection. More...
 
const struct CadetConnectionMetricsGCC_get_metrics (struct CadetConnection *cc)
 Obtain performance metrics from cc. More...
 
static void send_keepalive (void *cls)
 Send a GNUNET_MESSAGE_TYPE_CADET_CHANNEL_KEEPALIVE through the tunnel to prevent it from timing out. More...
 
static void keepalive_done (void *cls, const struct GNUNET_CADET_ConnectionTunnelIdentifier *cid)
 Keepalive was transmitted. More...
 
void GCC_ack_expected (const struct GNUNET_CADET_ConnectionTunnelIdentifier *cid)
 We sent a message for which we expect to receive an ACK via the connection identified by cti. More...
 
void GCC_ack_observed (const struct GNUNET_CADET_ConnectionTunnelIdentifier *cid)
 We observed an ACK for a message that was originally sent via the connection identified by cti. More...
 
void GCC_latency_observed (const struct GNUNET_CADET_ConnectionTunnelIdentifier *cid, struct GNUNET_TIME_Relative latency)
 We observed some the given latency on the connection identified by cti. More...
 
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. More...
 
void GCC_handle_kx (struct CadetConnection *cc, const struct GNUNET_CADET_TunnelKeyExchangeMessage *msg)
 Handle KX message. More...
 
void GCC_handle_kx_auth (struct CadetConnection *cc, const struct GNUNET_CADET_TunnelKeyExchangeAuthMessage *msg)
 Handle KX_AUTH message. More...
 
void GCC_handle_encrypted (struct CadetConnection *cc, const struct GNUNET_CADET_TunnelEncryptedMessage *msg)
 Handle encrypted message. More...
 
static void send_create (void *cls)
 Send a GNUNET_MESSAGE_TYPE_CADET_CONNECTION_CREATE message to the first hop. More...
 
static void send_create_ack (void *cls)
 Send a CREATE_ACK message towards the origin. More...
 
void GCC_handle_duplicate_create (struct CadetConnection *cc)
 We got a GNUNET_MESSAGE_TYPE_CADET_CONNECTION_CREATE for a connection that we already have. More...
 
static void manage_first_hop_mq (void *cls, int available)
 There has been a change in the message queue existence for our peer at the first hop. More...
 
static struct CadetConnectionconnection_create (struct CadetPeer *destination, struct CadetPeerPath *path, unsigned int off, 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. More...
 
struct CadetConnectionGCC_create_inbound (struct CadetPeer *destination, struct CadetPeerPath *path, struct CadetTConnection *ct, const struct GNUNET_CADET_ConnectionTunnelIdentifier *cid, 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. More...
 
struct CadetConnectionGCC_create (struct CadetPeer *destination, struct CadetPeerPath *path, unsigned int off, struct CadetTConnection *ct, 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. More...
 
void GCC_transmit (struct CadetConnection *cc, struct GNUNET_MQ_Envelope *env)
 Transmit message msg via connection cc. More...
 
struct CadetPeerPathGCC_get_path (struct CadetConnection *cc, unsigned int *off)
 Obtain the path used by this connection. More...
 
const struct GNUNET_CADET_ConnectionTunnelIdentifierGCC_get_id (struct CadetConnection *cc)
 Obtain unique ID for the connection. More...
 
const char * GCC_2s (const struct CadetConnection *cc)
 Get a (static) string for a connection. More...
 
void GCC_debug (struct CadetConnection *cc, enum GNUNET_ErrorType level)
 Log connection info. More...
 

Detailed Description

management of CORE-level end-to-end connections; establishes end-to-end routes and transmits messages along the route

Author
Bartlomiej Polot
Christian Grothoff

Definition in file gnunet-service-cadet_connection.c.

Macro Definition Documentation

◆ LOG

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

◆ INITIAL_CONNECTION_CREATE_RETRY_DELAY

#define INITIAL_CONNECTION_CREATE_RETRY_DELAY   GNUNET_TIME_relative_multiply (GNUNET_TIME_UNIT_MILLISECONDS, 200)

How long do we wait initially before retransmitting the KX? TODO: replace by 2 RTT if/once we have connection-level RTT data!

Definition at line 45 of file gnunet-service-cadet_connection.c.

Referenced by connection_create(), and manage_first_hop_mq().

◆ LOG2

#define LOG2 (   level,
  ... 
)    GNUNET_log_from_nocheck (level, "cadet-con", __VA_ARGS__)

Definition at line 1018 of file gnunet-service-cadet_connection.c.

Referenced by GCC_debug().

Enumeration Type Documentation

◆ CadetConnectionState

All the states a connection can be in.

Enumerator
CADET_CONNECTION_NEW 

Uninitialized status, we have not yet even gotten the message queue.

CADET_CONNECTION_SENDING_CREATE 

Connection create message in queue, awaiting transmission by CORE.

CADET_CONNECTION_SENT 

Connection create message sent, waiting for ACK.

CADET_CONNECTION_CREATE_RECEIVED 

We are an inbound connection, and received a CREATE.

Need to send an CREATE_ACK back.

CADET_CONNECTION_READY 

Connection confirmed, ready to carry traffic.

Definition at line 52 of file gnunet-service-cadet_connection.c.

53 {
58 
63 
68 
74 
79 };
We are an inbound connection, and received a CREATE.
Connection create message in queue, awaiting transmission by CORE.
Connection confirmed, ready to carry traffic.
Connection create message sent, waiting for ACK.
Uninitialized status, we have not yet even gotten the message queue.

Function Documentation

◆ GCC_lookup()

struct CadetConnection* GCC_lookup ( const struct GNUNET_CADET_ConnectionTunnelIdentifier cid)

Lookup a connection by its identifier.

Parameters
cididentifier to resolve
Returns
NULL if connection was not found

Definition at line 186 of file gnunet-service-cadet_connection.c.

References GNUNET_CADET_ConnectionTunnelIdentifier::connection_of_tunnel, connections, and GNUNET_CONTAINER_multishortmap_get().

Referenced by data_sent_cb(), GCC_ack_expected(), GCC_ack_observed(), GCC_latency_observed(), handle_connection_broken(), handle_connection_create(), handle_connection_create_ack(), handle_connection_destroy(), handle_tunnel_encrypted(), handle_tunnel_kx(), and handle_tunnel_kx_auth().

187 {
189  &cid->connection_of_tunnel);
190 }
struct GNUNET_CONTAINER_MultiShortmap * connections
Map from struct GNUNET_CADET_ConnectionTunnelIdentifier hash codes to struct CadetConnection objects...
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
Here is the call graph for this function:
Here is the caller graph for this function:

◆ update_state()

static void update_state ( struct CadetConnection cc,
enum CadetConnectionState  new_state,
int  new_mqm_ready 
)
static

Update the connection state.

Also triggers the necessary MQM notifications.

Parameters
ccconnection to update the state for
new_statenew state for cc
new_mqm_readynew mqm_ready state for cc

Definition at line 202 of file gnunet-service-cadet_connection.c.

References CADET_CONNECTION_READY, GNUNET_YES, CadetConnection::mqm_ready, CadetConnection::ready_cb, CadetConnection::ready_cb_cls, and CadetConnection::state.

Referenced by GCC_handle_connection_create_ack(), GCC_handle_duplicate_create(), manage_first_hop_mq(), send_create(), and send_create_ack().

205 {
206  int old_ready;
207  int new_ready;
208 
209  if ((new_state == cc->state) && (new_mqm_ready == cc->mqm_ready))
210  return; /* no change, nothing to do */
211  old_ready =
212  ((CADET_CONNECTION_READY == cc->state) && (GNUNET_YES == cc->mqm_ready));
213  new_ready =
214  ((CADET_CONNECTION_READY == new_state) && (GNUNET_YES == new_mqm_ready));
215  cc->state = new_state;
216  cc->mqm_ready = new_mqm_ready;
217  if (old_ready != new_ready)
218  cc->ready_cb (cc->ready_cb_cls, new_ready);
219 }
int mqm_ready
Are we ready to transmit via mq_man right now?
GCC_ReadyCallback ready_cb
Function to call once we are ready to transmit.
Connection confirmed, ready to carry traffic.
void * ready_cb_cls
Closure for ready_cb.
enum CadetConnectionState state
State of the connection.
#define GNUNET_YES
Definition: gnunet_common.h:77
Here is the caller graph for this function:

◆ GCC_destroy()

static void GCC_destroy ( struct CadetConnection cc)
static

Destroy a connection, part of the internal implementation.

Called only from #GCC_destroy_from_core() or #GCC_destroy_from_tunnel().

Parameters
ccconnection to destroy

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

References connections, GCC_2s(), GCC_get_id(), GCP_remove_connection(), GCP_request_mq_cancel(), GCPP_del_connection(), GCPP_get_peer_at_offset(), GCT_send_cancel(), GNUNET_assert, GNUNET_CONTAINER_multishortmap_remove(), GNUNET_ERROR_TYPE_DEBUG, GNUNET_free, GNUNET_SCHEDULER_cancel(), GNUNET_YES, CadetConnection::keepalive_qe, LOG, CadetConnection::mq_man, CadetConnection::off, CadetConnection::path, and CadetConnection::task.

Referenced by GCC_destroy_without_core(), and GCC_destroy_without_tunnel().

230 {
231  LOG (GNUNET_ERROR_TYPE_DEBUG, "Destroying %s\n", GCC_2s (cc));
232  if (NULL != cc->mq_man)
233  {
234  GCP_request_mq_cancel (cc->mq_man, NULL);
235  cc->mq_man = NULL;
236  }
237  if (NULL != cc->task)
238  {
240  cc->task = NULL;
241  }
242  if (NULL != cc->keepalive_qe)
243  {
245  cc->keepalive_qe = NULL;
246  }
247  GCPP_del_connection (cc->path, cc->off, cc);
248  for (unsigned int i = 0; i < cc->off; i++)
250  GNUNET_assert (
251  GNUNET_YES ==
253  &GCC_get_id (cc)
254  ->connection_of_tunnel,
255  cc));
256  GNUNET_free (cc);
257 }
struct GNUNET_SCHEDULER_Task * task
Task for connection maintenance.
const char * GCC_2s(const struct CadetConnection *cc)
Get a (static) string for a connection.
#define GNUNET_assert(cond)
Use this for fatal errors that cannot be handled.
void GCT_send_cancel(struct CadetTunnelQueueEntry *tq)
Cancel a previously sent message while it&#39;s in the queue.
const struct GNUNET_CADET_ConnectionTunnelIdentifier * GCC_get_id(struct CadetConnection *cc)
Obtain unique ID for the connection.
struct CadetPeerPath * path
Path we are using to our destination.
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.
struct GNUNET_CONTAINER_MultiShortmap * connections
Map from struct GNUNET_CADET_ConnectionTunnelIdentifier hash codes to struct CadetConnection objects...
#define LOG(level,...)
void GCP_remove_connection(struct CadetPeer *cp, struct CadetConnection *cc)
Remove a connection that went via this cp.
struct GCP_MessageQueueManager * mq_man
Handle for calling GCP_request_mq_cancel() once we are finished.
struct CadetTunnelQueueEntry * keepalive_qe
Queue entry for keepalive messages.
void GCPP_del_connection(struct CadetPeerPath *path, unsigned int off, struct CadetConnection *cc)
Notify path that it is no longer used for connection cc which ended at the path&#39;s offset off...
void GCP_request_mq_cancel(struct GCP_MessageQueueManager *mqm, struct GNUNET_MQ_Envelope *last_env)
Stops message queue change notifications.
struct CadetPeer * GCPP_get_peer_at_offset(struct CadetPeerPath *path, unsigned int off)
Obtain the peer at offset off in path.
#define GNUNET_YES
Definition: gnunet_common.h:77
#define GNUNET_free(ptr)
Wrapper around free.
unsigned int off
Offset of our destination in path.
void * GNUNET_SCHEDULER_cancel(struct GNUNET_SCHEDULER_Task *task)
Cancel the task with the specified identifier.
Definition: scheduler.c:966
Here is the call graph for this function:
Here is the caller graph for this function:

◆ GCC_destroy_without_core()

void GCC_destroy_without_core ( struct CadetConnection cc)

Destroy a connection, called when the CORE layer is already done (i.e.

has received a BROKEN message), but if we still have to communicate the destruction of the connection to the tunnel (if one exists).

Parameters
ccconnection to destroy

Definition at line 269 of file gnunet-service-cadet_connection.c.

References CadetConnection::ct, GCC_destroy(), and GCT_connection_lost().

Referenced by handle_connection_broken(), and handle_connection_destroy().

270 {
271  if (NULL != cc->ct)
272  {
273  GCT_connection_lost (cc->ct);
274  cc->ct = NULL;
275  }
276  GCC_destroy (cc);
277 }
void GCT_connection_lost(struct CadetTConnection *ct)
We lost a connection, remove it from our list and clean up the connection object itself.
static void GCC_destroy(struct CadetConnection *cc)
Destroy a connection, part of the internal implementation.
struct CadetTConnection * ct
Which tunnel is using this connection?
Here is the call graph for this function:
Here is the caller graph for this function:

◆ GCC_destroy_without_tunnel()

void GCC_destroy_without_tunnel ( struct CadetConnection cc)

Destroy a connection, called if the tunnel association with the connection was already broken, but we still need to notify the CORE layer about the breakage.

Parameters
ccconnection to destroy

Definition at line 288 of file gnunet-service-cadet_connection.c.

References CADET_CONNECTION_SENDING_CREATE, GNUNET_CADET_ConnectionDestroyMessage::cid, CadetConnection::cid, CadetConnection::ct, CadetConnection::env, GCC_destroy(), GCP_request_mq_cancel(), GNUNET_MESSAGE_TYPE_CADET_CONNECTION_DESTROY, GNUNET_MQ_msg, CadetConnection::mq_man, and CadetConnection::state.

Referenced by destroy_t_connection(), and GCC_create_inbound().

289 {
290  cc->ct = NULL;
291  if ((CADET_CONNECTION_SENDING_CREATE != cc->state) && (NULL != cc->mq_man))
292  {
293  struct GNUNET_MQ_Envelope *env;
294  struct GNUNET_CADET_ConnectionDestroyMessage *destroy_msg;
295 
296  /* Need to notify next hop that we are down. */
297  env =
299  destroy_msg->cid = cc->cid;
300  GCP_request_mq_cancel (cc->mq_man, env);
301  cc->mq_man = NULL;
302  }
303  GCC_destroy (cc);
304 }
Message to destroy a connection.
struct GNUNET_CADET_ConnectionTunnelIdentifier cid
ID of the connection.
#define GNUNET_MQ_msg(mvar, type)
Allocate a GNUNET_MQ_Envelope.
Definition: gnunet_mq_lib.h:67
static void GCC_destroy(struct CadetConnection *cc)
Destroy a connection, part of the internal implementation.
Connection create message in queue, awaiting transmission by CORE.
struct CadetTConnection * ct
Which tunnel is using this connection?
struct GNUNET_CADET_ConnectionTunnelIdentifier cid
ID of the connection.
struct GCP_MessageQueueManager * mq_man
Handle for calling GCP_request_mq_cancel() once we are finished.
struct GNUNET_MQ_Envelope * env
Definition: 005.c:1
enum CadetConnectionState state
State of the connection.
#define GNUNET_MESSAGE_TYPE_CADET_CONNECTION_DESTROY
Request the destuction of a connection.
void GCP_request_mq_cancel(struct GCP_MessageQueueManager *mqm, struct GNUNET_MQ_Envelope *last_env)
Stops message queue change notifications.
Here is the call graph for this function:
Here is the caller graph for this function:

◆ GCC_get_ct()

struct CadetTConnection* GCC_get_ct ( struct CadetConnection cc)

Return the tunnel associated with this connection.

Parameters
ccconnection to query
Returns
corresponding entry in the tunnel's connection list

Definition at line 314 of file gnunet-service-cadet_connection.c.

References CadetConnection::ct.

315 {
316  return cc->ct;
317 }
struct CadetTConnection * ct
Which tunnel is using this connection?

◆ GCC_get_metrics()

const struct CadetConnectionMetrics* GCC_get_metrics ( struct CadetConnection cc)

Obtain performance metrics from cc.

Parameters
ccconnection to query
Returns
the metrics

Definition at line 327 of file gnunet-service-cadet_connection.c.

References CadetConnection::metrics, and send_keepalive().

Referenced by data_sent_cb(), and evaluate_connection().

328 {
329  return &cc->metrics;
330 }
struct CadetConnectionMetrics metrics
Performance metrics for this connection.
Here is the call graph for this function:
Here is the caller graph for this function:

◆ send_keepalive()

static void send_keepalive ( void *  cls)
static

Send a GNUNET_MESSAGE_TYPE_CADET_CHANNEL_KEEPALIVE through the tunnel to prevent it from timing out.

Parameters
clsthe struct CadetConnection to keep alive.

Definition at line 371 of file gnunet-service-cadet_connection.c.

References CADET_TUNNEL_KEY_OK, CadetConnection::ct, GCC_2s(), GCT_2s(), GCT_get_estate(), GCT_send(), GNUNET_assert, GNUNET_ERROR_TYPE_INFO, GNUNET_MESSAGE_TYPE_CADET_CHANNEL_KEEPALIVE, GNUNET_NO, GNUNET_SCHEDULER_add_delayed(), GNUNET_STATISTICS_update(), GNUNET_YES, keepalive_done(), keepalive_period, CadetConnection::keepalive_qe, LOG, CadetConnection::mqm_ready, GNUNET_MessageHeader::size, stats, CadetTConnection::t, CadetConnection::task, and GNUNET_MessageHeader::type.

Referenced by GCC_get_metrics(), GCC_handle_connection_create_ack(), keepalive_done(), manage_first_hop_mq(), and send_create_ack().

372 {
373  struct CadetConnection *cc = cls;
374  struct GNUNET_MessageHeader msg;
375 
376  cc->task = NULL;
377  if (CADET_TUNNEL_KEY_OK != GCT_get_estate (cc->ct->t))
378  {
379  /* Tunnel not yet ready, wait with keepalives... */
380  cc->task =
382  return;
383  }
384  GNUNET_assert (NULL != cc->ct);
386  GNUNET_assert (NULL == cc->keepalive_qe);
388  "Sending KEEPALIVE on behalf of %s via %s\n",
389  GCC_2s (cc),
390  GCT_2s (cc->ct->t));
391  GNUNET_STATISTICS_update (stats, "# keepalives sent", 1, GNUNET_NO);
392  msg.size = htons (sizeof(msg));
394 
395  cc->keepalive_qe = GCT_send (cc->ct->t, &msg, &keepalive_done, cc);
396 }
int mqm_ready
Are we ready to transmit via mq_man right now?
struct GNUNET_MessageHeader * msg
Definition: 005.c:2
struct GNUNET_SCHEDULER_Task * task
Task for connection maintenance.
Low-level connection to a destination.
static void send_keepalive(void *cls)
Send a GNUNET_MESSAGE_TYPE_CADET_CHANNEL_KEEPALIVE through the tunnel to prevent it from timing out...
enum CadetTunnelEState GCT_get_estate(struct CadetTunnel *t)
Get the encryption state of a tunnel.
const char * GCT_2s(const struct CadetTunnel *t)
Get the static string for the peer this tunnel is directed.
const char * GCC_2s(const struct CadetConnection *cc)
Get a (static) string for a connection.
#define GNUNET_assert(cond)
Use this for fatal errors that cannot be handled.
struct CadetTunnelQueueEntry * GCT_send(struct CadetTunnel *t, const struct GNUNET_MessageHeader *message, GCT_SendContinuation cont, void *cont_cls)
Sends an already built message on a tunnel, encrypting it and choosing the best connection if not pro...
#define GNUNET_NO
Definition: gnunet_common.h:78
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.
struct CadetTunnel * t
Tunnel this connection belongs to.
#define LOG(level,...)
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:1253
uint16_t type
The type of the message (GNUNET_MESSAGE_TYPE_XXXX), in big-endian format.
struct GNUNET_STATISTICS_Handle * stats
Handle to the statistics service.
static void keepalive_done(void *cls, const struct GNUNET_CADET_ConnectionTunnelIdentifier *cid)
Keepalive was transmitted.
struct CadetTConnection * ct
Which tunnel is using this connection?
#define GNUNET_MESSAGE_TYPE_CADET_CHANNEL_KEEPALIVE
Announce connection is still alive (direction sensitive).
Handshake completed: session key available.
struct CadetTunnelQueueEntry * keepalive_qe
Queue entry for keepalive messages.
struct GNUNET_TIME_Relative keepalive_period
How frequently do we send KEEPALIVE messages on idle connections?
Header for all communications.
#define GNUNET_YES
Definition: gnunet_common.h:77
Here is the call graph for this function:
Here is the caller graph for this function:

◆ keepalive_done()

static void keepalive_done ( void *  cls,
const struct GNUNET_CADET_ConnectionTunnelIdentifier cid 
)
static

Keepalive was transmitted.

Remember this, and possibly schedule the next one.

Parameters
clsthe struct CadetConnection to keep alive.
cididentifier of the connection within the tunnel, NULL if transmission failed

Definition at line 352 of file gnunet-service-cadet_connection.c.

References GNUNET_SCHEDULER_add_delayed(), GNUNET_YES, keepalive_period, CadetConnection::keepalive_qe, CadetConnection::mqm_ready, send_keepalive(), and CadetConnection::task.

Referenced by send_keepalive().

354 {
355  struct CadetConnection *cc = cls;
356 
357  cc->keepalive_qe = NULL;
358  if ((GNUNET_YES == cc->mqm_ready) && (NULL == cc->task))
359  cc->task =
361 }
int mqm_ready
Are we ready to transmit via mq_man right now?
struct GNUNET_SCHEDULER_Task * task
Task for connection maintenance.
Low-level connection to a destination.
static void send_keepalive(void *cls)
Send a GNUNET_MESSAGE_TYPE_CADET_CHANNEL_KEEPALIVE through the tunnel to prevent it from timing out...
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:1253
struct CadetTunnelQueueEntry * keepalive_qe
Queue entry for keepalive messages.
struct GNUNET_TIME_Relative keepalive_period
How frequently do we send KEEPALIVE messages on idle connections?
#define GNUNET_YES
Definition: gnunet_common.h:77
Here is the call graph for this function:
Here is the caller graph for this function:

◆ GCC_ack_expected()

void GCC_ack_expected ( const struct GNUNET_CADET_ConnectionTunnelIdentifier cid)

We sent a message for which we expect to receive an ACK via the connection identified by cti.

Parameters
cidconnection identifier where we expect an ACK

Definition at line 406 of file gnunet-service-cadet_connection.c.

References GCC_lookup(), CadetConnection::metrics, and CadetConnectionMetrics::num_acked_transmissions.

Referenced by data_sent_cb().

407 {
408  struct CadetConnection *cc;
409 
410  cc = GCC_lookup (cid);
411  if (NULL == cc)
412  return; /* whopise, connection alredy down? */
414 }
Low-level connection to a destination.
struct CadetConnectionMetrics metrics
Performance metrics for this connection.
struct CadetConnection * GCC_lookup(const struct GNUNET_CADET_ConnectionTunnelIdentifier *cid)
Lookup a connection by its identifier.
unsigned long long num_acked_transmissions
How many packets that ought to generate an ACK did we send via this connection?
Here is the call graph for this function:
Here is the caller graph for this function:

◆ GCC_ack_observed()

void GCC_ack_observed ( const struct GNUNET_CADET_ConnectionTunnelIdentifier cid)

We observed an ACK for a message that was originally sent via the connection identified by cti.

Parameters
cticonnection identifier where we got an ACK for a message that was originally sent via this connection (the ACK may have gotten back to us via a different connection).

Definition at line 426 of file gnunet-service-cadet_connection.c.

References GCC_lookup(), CadetConnection::metrics, and CadetConnectionMetrics::num_successes.

Referenced by handle_matching_ack().

427 {
428  struct CadetConnection *cc;
429 
430  cc = GCC_lookup (cid);
431  if (NULL == cc)
432  return; /* whopise, connection alredy down? */
433  cc->metrics.num_successes++;
434 }
Low-level connection to a destination.
unsigned long long num_successes
Number of packets that were sent via this connection did actually receive an ACK? (Note: ACKs may be ...
struct CadetConnectionMetrics metrics
Performance metrics for this connection.
struct CadetConnection * GCC_lookup(const struct GNUNET_CADET_ConnectionTunnelIdentifier *cid)
Lookup a connection by its identifier.
Here is the call graph for this function:
Here is the caller graph for this function:

◆ GCC_latency_observed()

void GCC_latency_observed ( const struct GNUNET_CADET_ConnectionTunnelIdentifier cid,
struct GNUNET_TIME_Relative  latency 
)

We observed some the given latency on the connection identified by cti.

(The same connection was taken in both directions.)

Parameters
cidconnection identifier where we measured latency
latencythe observed latency

Definition at line 446 of file gnunet-service-cadet_connection.c.

References CadetConnectionMetrics::aged_latency, GCC_lookup(), GNUNET_NO, GNUNET_STATISTICS_update(), CadetConnection::latency_datapoints, CadetConnection::metrics, GNUNET_TIME_Relative::rel_value_us, result, and stats.

Referenced by handle_matching_ack().

448 {
449  struct CadetConnection *cc;
450  double weight;
451  double result;
452 
453  cc = GCC_lookup (cid);
454  if (NULL == cc)
455  return; /* whopise, connection alredy down? */
456  GNUNET_STATISTICS_update (stats, "# latencies observed", 1, GNUNET_NO);
457  cc->latency_datapoints++;
458  if (cc->latency_datapoints >= 7)
459  weight = 7.0;
460  else
461  weight = cc->latency_datapoints;
462  /* Compute weighted average, giving at MOST weight 7 to the
463  existing values, or less if that value is based on fewer than 7
464  measurements. */
465  result = (weight * cc->metrics.aged_latency.rel_value_us)
466  + 1.0 * latency.rel_value_us;
467  result /= (weight + 1.0);
468  cc->metrics.aged_latency.rel_value_us = (uint64_t) result;
469 }
Low-level connection to a destination.
uint64_t rel_value_us
The actual value.
#define GNUNET_NO
Definition: gnunet_common.h:78
void GNUNET_STATISTICS_update(struct GNUNET_STATISTICS_Handle *handle, const char *name, int64_t delta, int make_persistent)
Set statistic value for the peer.
unsigned int latency_datapoints
How many latency observations did we make for this connection?
struct GNUNET_STATISTICS_Handle * stats
Handle to the statistics service.
struct GNUNET_TIME_Relative aged_latency
Our current best estimate of the latency, based on a weighted average of at least latency_datapoints ...
static int result
Global testing status.
struct CadetConnectionMetrics metrics
Performance metrics for this connection.
struct CadetConnection * GCC_lookup(const struct GNUNET_CADET_ConnectionTunnelIdentifier *cid)
Lookup a connection by its identifier.
Here is the call graph for this function:
Here is the caller graph for this function:

◆ GCC_handle_connection_create_ack()

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.

A CREATE_ACK was received for this connection, process it.

Process it.

Parameters
ccthe connection that got the ACK.

Definition at line 480 of file gnunet-service-cadet_connection.c.

References CadetConnectionMetrics::age, CADET_CONNECTION_READY, GCC_2s(), GNUNET_ERROR_TYPE_DEBUG, GNUNET_SCHEDULER_add_delayed(), GNUNET_SCHEDULER_cancel(), GNUNET_TIME_absolute_get(), GNUNET_YES, keepalive_period, CadetConnection::keepalive_qe, LOG, CadetConnection::metrics, CadetConnection::mqm_ready, send_keepalive(), CadetConnection::state, CadetConnection::task, and update_state().

Referenced by GCC_handle_encrypted(), GCC_handle_kx(), GCC_handle_kx_auth(), and handle_connection_create_ack().

481 {
483  "Received CADET_CONNECTION_CREATE_ACK for %s in state %d (%s)\n",
484  GCC_2s (cc),
485  cc->state,
486  (GNUNET_YES == cc->mqm_ready) ? "MQM ready" : "MQM busy");
487  if (CADET_CONNECTION_READY == cc->state)
488  return; /* Duplicate ACK, ignore */
489  if (NULL != cc->task)
490  {
492  cc->task = NULL;
493  }
496  if ((NULL == cc->keepalive_qe) && (GNUNET_YES == cc->mqm_ready) &&
497  (NULL == cc->task))
498  cc->task =
500 }
int mqm_ready
Are we ready to transmit via mq_man right now?
struct GNUNET_SCHEDULER_Task * task
Task for connection maintenance.
static void send_keepalive(void *cls)
Send a GNUNET_MESSAGE_TYPE_CADET_CHANNEL_KEEPALIVE through the tunnel to prevent it from timing out...
const char * GCC_2s(const struct CadetConnection *cc)
Get a (static) string for a connection.
static void update_state(struct CadetConnection *cc, enum CadetConnectionState new_state, int new_mqm_ready)
Update the connection state.
#define LOG(level,...)
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:1253
Connection confirmed, ready to carry traffic.
struct GNUNET_TIME_Absolute GNUNET_TIME_absolute_get(void)
Get the current time.
Definition: time.c:118
struct CadetConnectionMetrics metrics
Performance metrics for this connection.
struct CadetTunnelQueueEntry * keepalive_qe
Queue entry for keepalive messages.
enum CadetConnectionState state
State of the connection.
struct GNUNET_TIME_Relative keepalive_period
How frequently do we send KEEPALIVE messages on idle connections?
#define GNUNET_YES
Definition: gnunet_common.h:77
struct GNUNET_TIME_Absolute age
When was this connection first established? (by us sending or receiving the CREATE_ACK for the first ...
void * GNUNET_SCHEDULER_cancel(struct GNUNET_SCHEDULER_Task *task)
Cancel the task with the specified identifier.
Definition: scheduler.c:966
Here is the call graph for this function:
Here is the caller graph for this function:

◆ GCC_handle_kx()

void GCC_handle_kx ( struct CadetConnection cc,
const struct GNUNET_CADET_TunnelKeyExchangeMessage msg 
)

Handle KX message.

Parameters
ccconnection that received encrypted message
msgthe key exchange message

Definition at line 510 of file gnunet-service-cadet_connection.c.

References CADET_CONNECTION_SENT, CadetConnection::cid, GNUNET_CADET_ConnectionTunnelIdentifier::connection_of_tunnel, CadetConnection::ct, GNUNET_CADET_TunnelKeyExchangeMessage::ephemeral_key, GCC_2s(), GCC_handle_connection_create_ack(), GCT_handle_kx(), GNUNET_e2s(), GNUNET_ERROR_TYPE_DEBUG, GNUNET_sh2s(), LOG, and CadetConnection::state.

Referenced by handle_tunnel_kx().

512 {
514  "Received KX message with ephermal %s on CC %s in state %d\n",
515  GNUNET_e2s (&msg->ephemeral_key),
517  cc->state);
518  if (CADET_CONNECTION_SENT == cc->state)
519  {
520  /* We didn't get the CADET_CONNECTION_CREATE_ACK, but instead got payload. That's fine,
521  clearly something is working, so pretend we got an ACK. */
523  "Faking connection CADET_CONNECTION_CREATE_ACK for %s due to KX\n",
524  GCC_2s (cc));
526  }
527  GCT_handle_kx (cc->ct, msg);
528 }
const char * GNUNET_sh2s(const struct GNUNET_ShortHashCode *shc)
Convert a short hash value to a string (for printing debug messages).
const char * GCC_2s(const struct CadetConnection *cc)
Get a (static) string for a connection.
struct GNUNET_CADET_ConnectionTunnelIdentifier cid
ID of the connection.
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.
#define LOG(level,...)
struct CadetTConnection * ct
Which tunnel is using this connection?
void GCT_handle_kx(struct CadetTConnection *ct, const struct GNUNET_CADET_TunnelKeyExchangeMessage *msg)
Handle KX message that lacks authentication (and which will thus only be considered authenticated aft...
Connection create message sent, waiting for ACK.
enum CadetConnectionState state
State of the connection.
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).
struct GNUNET_ShortHashCode connection_of_tunnel
Here is the call graph for this function:
Here is the caller graph for this function:

◆ GCC_handle_kx_auth()

void GCC_handle_kx_auth ( struct CadetConnection cc,
const struct GNUNET_CADET_TunnelKeyExchangeAuthMessage msg 
)

Handle KX_AUTH message.

Parameters
ccconnection that received encrypted message
msgthe key exchange message

Definition at line 538 of file gnunet-service-cadet_connection.c.

References CADET_CONNECTION_SENT, CadetConnection::cid, GNUNET_CADET_ConnectionTunnelIdentifier::connection_of_tunnel, CadetConnection::ct, GNUNET_CADET_TunnelKeyExchangeMessage::ephemeral_key, GCC_2s(), GCC_handle_connection_create_ack(), GCT_handle_kx_auth(), GNUNET_e2s(), GNUNET_ERROR_TYPE_DEBUG, GNUNET_sh2s(), GNUNET_CADET_TunnelKeyExchangeAuthMessage::kx, LOG, and CadetConnection::state.

Referenced by handle_tunnel_kx_auth().

540 {
542  "Received KX AUTH message with ephermal %s on CC %s in state %d\n",
543  GNUNET_e2s (&msg->kx.ephemeral_key),
545  cc->state);
546  if (CADET_CONNECTION_SENT == cc->state)
547  {
548  /* We didn't get the CADET_CONNECTION_CREATE_ACK, but instead got payload. That's fine,
549  clearly something is working, so pretend we got an ACK. */
551  "Faking connection CADET_CONNECTION_CREATE_ACK for %s due to KX\n",
552  GCC_2s (cc));
554  }
555  GCT_handle_kx_auth (cc->ct, msg);
556 }
const char * GNUNET_sh2s(const struct GNUNET_ShortHashCode *shc)
Convert a short hash value to a string (for printing debug messages).
const char * GCC_2s(const struct CadetConnection *cc)
Get a (static) string for a connection.
struct GNUNET_CADET_TunnelKeyExchangeMessage kx
Message header with key material.
struct GNUNET_CADET_ConnectionTunnelIdentifier cid
ID of the connection.
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.
#define LOG(level,...)
struct CadetTConnection * ct
Which tunnel is using this connection?
Connection create message sent, waiting for ACK.
void GCT_handle_kx_auth(struct CadetTConnection *ct, const struct GNUNET_CADET_TunnelKeyExchangeAuthMessage *msg)
Handle KX_AUTH message.
enum CadetConnectionState state
State of the connection.
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).
struct GNUNET_ShortHashCode connection_of_tunnel
Here is the call graph for this function:
Here is the caller graph for this function:

◆ GCC_handle_encrypted()

void GCC_handle_encrypted ( struct CadetConnection cc,
const struct GNUNET_CADET_TunnelEncryptedMessage msg 
)

Handle encrypted message.

Parameters
ccconnection that received encrypted message
msgthe encrypted message to decrypt

Definition at line 566 of file gnunet-service-cadet_connection.c.

References CADET_CONNECTION_SENT, CadetConnection::ct, GCC_2s(), GCC_handle_connection_create_ack(), GCT_handle_encrypted(), GNUNET_ERROR_TYPE_DEBUG, GNUNET_TIME_absolute_get(), CadetConnectionMetrics::last_use, LOG, CadetConnection::metrics, and CadetConnection::state.

Referenced by handle_tunnel_encrypted().

568 {
569  if (CADET_CONNECTION_SENT == cc->state)
570  {
571  /* We didn't get the CREATE_ACK, but instead got payload. That's fine,
572  clearly something is working, so pretend we got an ACK. */
574  "Faking connection ACK for %s due to ENCRYPTED payload\n",
575  GCC_2s (cc));
577  }
579  GCT_handle_encrypted (cc->ct, msg);
580 }
void GCT_handle_encrypted(struct CadetTConnection *ct, const struct GNUNET_CADET_TunnelEncryptedMessage *msg)
Handle encrypted message.
const char * GCC_2s(const struct CadetConnection *cc)
Get a (static) string for a connection.
struct GNUNET_TIME_Absolute last_use
When was this connection last used? (by us sending or receiving a PAYLOAD message on it) ...
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.
#define LOG(level,...)
struct CadetTConnection * ct
Which tunnel is using this connection?
struct GNUNET_TIME_Absolute GNUNET_TIME_absolute_get(void)
Get the current time.
Definition: time.c:118
struct CadetConnectionMetrics metrics
Performance metrics for this connection.
Connection create message sent, waiting for ACK.
enum CadetConnectionState state
State of the connection.
Here is the call graph for this function:
Here is the caller graph for this function:

◆ send_create()

static void send_create ( void *  cls)
static

Send a GNUNET_MESSAGE_TYPE_CADET_CONNECTION_CREATE message to the first hop.

Parameters
clsthe struct CadetConnection to initiate

Definition at line 590 of file gnunet-service-cadet_connection.c.

References CADET_CONNECTION_SENT, GNUNET_CADET_ConnectionCreateMessage::cid, CadetConnection::cid, CadetConnection::create_at, CadetConnection::env, GCC_2s(), GCP_get_id(), GCP_send(), GCPP_get_peer_at_offset(), GNUNET_assert, GNUNET_ERROR_TYPE_DEBUG, GNUNET_MESSAGE_TYPE_CADET_CONNECTION_CREATE, GNUNET_MQ_msg_extra, GNUNET_NO, GNUNET_TIME_relative_to_absolute(), GNUNET_TIME_STD_BACKOFF, GNUNET_YES, LOG, CadetConnection::mq_man, CadetConnection::mqm_ready, my_full_id, CadetConnection::off, GNUNET_CADET_ConnectionCreateMessage::options, CadetConnection::path, CadetConnection::retry_delay, CadetConnection::task, and update_state().

Referenced by manage_first_hop_mq().

591 {
592  struct CadetConnection *cc = cls;
593  struct GNUNET_CADET_ConnectionCreateMessage *create_msg;
594  struct GNUNET_PeerIdentity *pids;
595  struct GNUNET_MQ_Envelope *env;
596 
597  cc->task = NULL;
599  env =
600  GNUNET_MQ_msg_extra (create_msg,
601  (2 + cc->off) * sizeof(struct GNUNET_PeerIdentity),
603  // TODO This will be removed in a major release, because this will be a protocol breaking change. We set the deprecated 'reliable' bit here that was removed.
604  create_msg->options = 2;
605  create_msg->cid = cc->cid;
606  pids = (struct GNUNET_PeerIdentity *) &create_msg[1];
607  pids[0] = my_full_id;
608  for (unsigned int i = 0; i <= cc->off; i++)
609  pids[i + 1] = *GCP_get_id (GCPP_get_peer_at_offset (cc->path, i));
611  "Sending CADET_CONNECTION_CREATE message for %s with %u hops\n",
612  GCC_2s (cc),
613  cc->off + 2);
614  cc->env = env;
618  GCP_send (cc->mq_man, env);
619 }
int mqm_ready
Are we ready to transmit via mq_man right now?
struct GNUNET_SCHEDULER_Task * task
Task for connection maintenance.
Low-level connection to a destination.
const char * GCC_2s(const struct CadetConnection *cc)
Get a (static) string for a connection.
struct GNUNET_PeerIdentity my_full_id
Local peer own ID.
static void update_state(struct CadetConnection *cc, enum CadetConnectionState new_state, int new_mqm_ready)
Update the connection state.
struct GNUNET_TIME_Absolute GNUNET_TIME_relative_to_absolute(struct GNUNET_TIME_Relative rel)
Convert relative time to an absolute time in the future.
Definition: time.c:246
#define GNUNET_assert(cond)
Use this for fatal errors that cannot be handled.
struct CadetPeerPath * path
Path we are using to our destination.
struct GNUNET_CADET_ConnectionTunnelIdentifier cid
ID of the connection.
#define GNUNET_NO
Definition: gnunet_common.h:78
void GCP_send(struct GCP_MessageQueueManager *mqm, struct GNUNET_MQ_Envelope *env)
Send the message in env to cp.
struct GNUNET_TIME_Absolute create_at
Earliest time for re-trying CREATE.
#define LOG(level,...)
#define GNUNET_MQ_msg_extra(mvar, esize, type)
Allocate an envelope, with extra space allocated after the space needed by the message struct...
Definition: gnunet_mq_lib.h:52
struct GNUNET_TIME_Relative retry_delay
How long do we wait before we try again with a CREATE message?
struct GNUNET_MQ_Envelope * env
Pending message, NULL if we are ready to transmit.
#define GNUNET_MESSAGE_TYPE_CADET_CONNECTION_CREATE
Request the creation of a connection.
struct GCP_MessageQueueManager * mq_man
Handle for calling GCP_request_mq_cancel() once we are finished.
struct GNUNET_MQ_Envelope * env
Definition: 005.c:1
#define GNUNET_TIME_STD_BACKOFF(r)
Perform our standard exponential back-off calculation, starting at 1 ms and then going by a factor of...
Connection create message sent, waiting for ACK.
The identity of the host (wraps the signing key of the peer).
struct CadetPeer * GCPP_get_peer_at_offset(struct CadetPeerPath *path, unsigned int off)
Obtain the peer at offset off in path.
#define GNUNET_YES
Definition: gnunet_common.h:77
uint32_t options
Connection options in network byte order.
struct GNUNET_CADET_ConnectionTunnelIdentifier cid
ID of the connection.
Message for cadet connection creation.
const struct GNUNET_PeerIdentity * GCP_get_id(struct CadetPeer *cp)
Obtain the peer identity for a struct CadetPeer.
unsigned int off
Offset of our destination in path.
Here is the call graph for this function:
Here is the caller graph for this function:

◆ send_create_ack()

static void send_create_ack ( void *  cls)
static

Send a CREATE_ACK message towards the origin.

Parameters
clsthe struct CadetConnection to initiate

Definition at line 628 of file gnunet-service-cadet_connection.c.

References CADET_CONNECTION_CREATE_RECEIVED, CADET_CONNECTION_READY, GNUNET_CADET_ConnectionCreateAckMessage::cid, CadetConnection::cid, CadetConnection::create_ack_at, CadetConnection::env, GCC_2s(), GCP_send(), GNUNET_assert, GNUNET_ERROR_TYPE_DEBUG, GNUNET_MESSAGE_TYPE_CADET_CONNECTION_CREATE_ACK, GNUNET_MQ_msg, GNUNET_NO, GNUNET_SCHEDULER_add_delayed(), GNUNET_TIME_relative_to_absolute(), GNUNET_TIME_STD_BACKOFF, GNUNET_YES, keepalive_period, LOG, CadetConnection::mq_man, CadetConnection::mqm_ready, CadetConnection::retry_delay, send_keepalive(), CadetConnection::state, CadetConnection::task, and update_state().

Referenced by GCC_handle_duplicate_create(), and manage_first_hop_mq().

629 {
630  struct CadetConnection *cc = cls;
632  struct GNUNET_MQ_Envelope *env;
633 
634  cc->task = NULL;
636  "Sending CONNECTION_CREATE_ACK message for %s\n",
637  GCC_2s (cc));
639  env =
641  ack_msg->cid = cc->cid;
642  cc->env = env;
647  if (CADET_CONNECTION_READY == cc->state)
648  cc->task =
650  GCP_send (cc->mq_man, env);
651 }
int mqm_ready
Are we ready to transmit via mq_man right now?
struct GNUNET_TIME_Absolute create_ack_at
Earliest time for re-trying CREATE_ACK.
struct GNUNET_SCHEDULER_Task * task
Task for connection maintenance.
Low-level connection to a destination.
static void send_keepalive(void *cls)
Send a GNUNET_MESSAGE_TYPE_CADET_CHANNEL_KEEPALIVE through the tunnel to prevent it from timing out...
const char * GCC_2s(const struct CadetConnection *cc)
Get a (static) string for a connection.
static void update_state(struct CadetConnection *cc, enum CadetConnectionState new_state, int new_mqm_ready)
Update the connection state.
struct GNUNET_TIME_Absolute GNUNET_TIME_relative_to_absolute(struct GNUNET_TIME_Relative rel)
Convert relative time to an absolute time in the future.
Definition: time.c:246
#define GNUNET_assert(cond)
Use this for fatal errors that cannot be handled.
Message for ack&#39;ing a connection.
We are an inbound connection, and received a CREATE.
struct GNUNET_CADET_ConnectionTunnelIdentifier cid
ID of the connection.
#define GNUNET_MQ_msg(mvar, type)
Allocate a GNUNET_MQ_Envelope.
Definition: gnunet_mq_lib.h:67
#define GNUNET_NO
Definition: gnunet_common.h:78
void GCP_send(struct GCP_MessageQueueManager *mqm, struct GNUNET_MQ_Envelope *env)
Send the message in env to cp.
#define LOG(level,...)
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:1253
struct GNUNET_TIME_Relative retry_delay
How long do we wait before we try again with a CREATE message?
Connection confirmed, ready to carry traffic.
struct GNUNET_MQ_Envelope * env
Pending message, NULL if we are ready to transmit.
#define GNUNET_MESSAGE_TYPE_CADET_CONNECTION_CREATE_ACK
Send origin an ACK that the connection is complete.
struct GCP_MessageQueueManager * mq_man
Handle for calling GCP_request_mq_cancel() once we are finished.
struct GNUNET_MQ_Envelope * env
Definition: 005.c:1
#define GNUNET_TIME_STD_BACKOFF(r)
Perform our standard exponential back-off calculation, starting at 1 ms and then going by a factor of...
enum CadetConnectionState state
State of the connection.
struct GNUNET_TIME_Relative keepalive_period
How frequently do we send KEEPALIVE messages on idle connections?
#define GNUNET_YES
Definition: gnunet_common.h:77
struct GNUNET_CADET_ConnectionTunnelIdentifier cid
ID of the connection.
Here is the call graph for this function:
Here is the caller graph for this function:

◆ GCC_handle_duplicate_create()

void GCC_handle_duplicate_create ( struct CadetConnection cc)

We got a GNUNET_MESSAGE_TYPE_CADET_CONNECTION_CREATE for a connection that we already have.

Either our ACK got lost or something is fishy. Consider retransmitting the ACK.

Parameters
ccconnection that got the duplicate CREATE

Definition at line 662 of file gnunet-service-cadet_connection.c.

References CADET_CONNECTION_CREATE_RECEIVED, CadetConnection::create_ack_at, GCC_2s(), GNUNET_ERROR_TYPE_DEBUG, GNUNET_SCHEDULER_add_at(), GNUNET_SCHEDULER_cancel(), GNUNET_YES, LOG, CadetConnection::mqm_ready, send_create_ack(), CadetConnection::task, and update_state().

Referenced by handle_connection_create().

663 {
664  if (GNUNET_YES == cc->mqm_ready)
665  {
667  "Got duplicate CREATE for %s, scheduling another ACK (%s)\n",
668  GCC_2s (cc),
669  (GNUNET_YES == cc->mqm_ready) ? "MQM ready" : "MQM busy");
670  /* Revert back to the state of having only received the 'CREATE',
671  and immediately proceed to send the CREATE_ACK. */
673  if (NULL != cc->task)
675  cc->task =
677  }
678  else
679  {
680  /* We are currently sending something else back, which
681  can only be an ACK or payload, either of which would
682  do. So actually no need to do anything. */
684  "Got duplicate CREATE for %s. MQ is busy, not queueing another ACK\n",
685  GCC_2s (cc));
686  }
687 }
int mqm_ready
Are we ready to transmit via mq_man right now?
struct GNUNET_TIME_Absolute create_ack_at
Earliest time for re-trying CREATE_ACK.
struct GNUNET_SCHEDULER_Task * task
Task for connection maintenance.
static void send_create_ack(void *cls)
Send a CREATE_ACK message towards the origin.
const char * GCC_2s(const struct CadetConnection *cc)
Get a (static) string for a connection.
static void update_state(struct CadetConnection *cc, enum CadetConnectionState new_state, int new_mqm_ready)
Update the connection state.
We are an inbound connection, and received a CREATE.
#define LOG(level,...)
#define GNUNET_YES
Definition: gnunet_common.h:77
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:1230
void * GNUNET_SCHEDULER_cancel(struct GNUNET_SCHEDULER_Task *task)
Cancel the task with the specified identifier.
Definition: scheduler.c:966
Here is the call graph for this function:
Here is the caller graph for this function:

◆ manage_first_hop_mq()

static void manage_first_hop_mq ( void *  cls,
int  available 
)
static

There has been a change in the message queue existence for our peer at the first hop.

Adjust accordingly.

Parameters
clsthe struct CadetConnection
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 701 of file gnunet-service-cadet_connection.c.

References CadetConnectionMetrics::age, CADET_CONNECTION_CREATE_RECEIVED, CADET_CONNECTION_NEW, CADET_CONNECTION_READY, CADET_CONNECTION_SENDING_CREATE, CADET_CONNECTION_SENT, CadetConnection::create_ack_at, CadetConnection::create_at, GCC_2s(), GNUNET_assert, GNUNET_ERROR_TYPE_DEBUG, GNUNET_NO, GNUNET_SCHEDULER_add_at(), GNUNET_SCHEDULER_add_delayed(), GNUNET_SCHEDULER_cancel(), GNUNET_STRINGS_relative_time_to_string(), GNUNET_TIME_absolute_get(), GNUNET_YES, INITIAL_CONNECTION_CREATE_RETRY_DELAY, keepalive_period, CadetConnection::keepalive_qe, LOG, CadetConnection::metrics, CadetConnection::mqm_ready, CadetConnection::retry_delay, send_create(), send_create_ack(), send_keepalive(), CadetConnection::state, CadetConnection::task, and update_state().

Referenced by connection_create().

702 {
703  struct CadetConnection *cc = cls;
704 
705  if (GNUNET_YES != available)
706  {
707  /* Connection is down, for now... */
708  LOG (GNUNET_ERROR_TYPE_DEBUG, "Core MQ for %s went down\n", GCC_2s (cc));
711  if (NULL != cc->task)
712  {
714  cc->task = NULL;
715  }
716  return;
717  }
718 
719  update_state (cc, cc->state, GNUNET_YES);
721  "Core MQ for %s became available in state %d\n",
722  GCC_2s (cc),
723  cc->state);
724  switch (cc->state)
725  {
727  /* Transmit immediately */
729  break;
730 
732  /* Should not be possible to be called in this state. */
733  GNUNET_assert (0);
734  break;
735 
737  /* Retry a bit later... */
739  break;
740 
742  /* We got the 'CREATE' (incoming connection), should send the CREATE_ACK */
744  cc->task =
746  break;
747 
749  if ((NULL == cc->keepalive_qe) && (GNUNET_YES == cc->mqm_ready) &&
750  (NULL == cc->task))
751  {
753  "Scheduling keepalive for %s in %s\n",
754  GCC_2s (cc),
756  GNUNET_YES));
757  cc->task =
759  }
760  break;
761  }
762 }
int mqm_ready
Are we ready to transmit via mq_man right now?
#define INITIAL_CONNECTION_CREATE_RETRY_DELAY
How long do we wait initially before retransmitting the KX? TODO: replace by 2 RTT if/once we have co...
struct GNUNET_TIME_Absolute create_ack_at
Earliest time for re-trying CREATE_ACK.
struct GNUNET_SCHEDULER_Task * task
Task for connection maintenance.
Low-level connection to a destination.
static void send_keepalive(void *cls)
Send a GNUNET_MESSAGE_TYPE_CADET_CHANNEL_KEEPALIVE through the tunnel to prevent it from timing out...
static void send_create_ack(void *cls)
Send a CREATE_ACK message towards the origin.
const char * GCC_2s(const struct CadetConnection *cc)
Get a (static) string for a connection.
static void update_state(struct CadetConnection *cc, enum CadetConnectionState new_state, int new_mqm_ready)
Update the connection state.
#define GNUNET_assert(cond)
Use this for fatal errors that cannot be handled.
We are an inbound connection, and received a CREATE.
#define GNUNET_NO
Definition: gnunet_common.h:78
static void send_create(void *cls)
Send a GNUNET_MESSAGE_TYPE_CADET_CONNECTION_CREATE message to the first hop.
struct GNUNET_TIME_Absolute create_at
Earliest time for re-trying CREATE.
#define LOG(level,...)
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:1253
Connection create message in queue, awaiting transmission by CORE.
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:687
struct GNUNET_TIME_Relative retry_delay
How long do we wait before we try again with a CREATE message?
Connection confirmed, ready to carry traffic.
struct GNUNET_TIME_Absolute GNUNET_TIME_absolute_get(void)
Get the current time.
Definition: time.c:118
struct CadetConnectionMetrics metrics
Performance metrics for this connection.
Connection create message sent, waiting for ACK.
struct CadetTunnelQueueEntry * keepalive_qe
Queue entry for keepalive messages.
enum CadetConnectionState state
State of the connection.
struct GNUNET_TIME_Relative keepalive_period
How frequently do we send KEEPALIVE messages on idle connections?
#define GNUNET_YES
Definition: gnunet_common.h:77
Uninitialized status, we have not yet even gotten the message queue.
struct GNUNET_TIME_Absolute age
When was this connection first established? (by us sending or receiving the CREATE_ACK for the first ...
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:1230
void * GNUNET_SCHEDULER_cancel(struct GNUNET_SCHEDULER_Task *task)
Cancel the task with the specified identifier.
Definition: scheduler.c:966
Here is the call graph for this function:
Here is the caller graph for this function:

◆ connection_create()

static struct CadetConnection* connection_create ( struct CadetPeer destination,
struct CadetPeerPath path,
unsigned int  off,
struct CadetTConnection ct,
const struct GNUNET_CADET_ConnectionTunnelIdentifier cid,
enum CadetConnectionState  init_state,
GCC_ReadyCallback  ready_cb,
void *  ready_cb_cls 
)
static

Create a connection to destination via path and notify cb whenever we are ready for more data.

Shared logic independent of who is initiating the connection.

Parameters
destinationwhere to go
pathwhich path to take (may not be the full path)
offoffset of destination on path
ctwhich tunnel uses this connection
init_stateinitial state for the connection
ready_cbfunction to call when ready to transmit
ready_cb_clsclosure for cb
Returns
handle to the connection

Definition at line 780 of file gnunet-service-cadet_connection.c.

References CadetConnection::cid, connections, CadetConnection::ct, GCC_2s(), GCC_get_id(), GCP_add_connection(), GCP_request_mq(), GCPP_2s(), GCPP_add_connection(), GCPP_get_peer_at_offset(), GNUNET_assert, GNUNET_CONTAINER_MULTIHASHMAPOPTION_UNIQUE_ONLY, GNUNET_CONTAINER_multishortmap_put(), GNUNET_ERROR_TYPE_DEBUG, GNUNET_new, GNUNET_OK, GNUNET_TIME_relative_multiply(), INITIAL_CONNECTION_CREATE_RETRY_DELAY, LOG, manage_first_hop_mq(), CadetConnection::mq_man, CadetConnection::off, CadetConnection::path, CadetConnection::ready_cb, CadetConnection::ready_cb_cls, CadetConnection::retry_delay, and CadetConnection::state.

Referenced by GCC_create(), GCC_create_inbound(), and GCO_init().

788 {
789  struct CadetConnection *cc;
790  struct CadetPeer *first_hop;
791 
792  cc = GNUNET_new (struct CadetConnection);
793  cc->state = init_state;
794  cc->ct = ct;
795  cc->cid = *cid;
796  cc->retry_delay =
800  connections,
801  &GCC_get_id (cc)->connection_of_tunnel,
802  cc,
804  cc->ready_cb = ready_cb;
805  cc->ready_cb_cls = ready_cb_cls;
806  cc->path = path;
807  cc->off = off;
809  "Creating %s using path %s (offset: %u)\n",
810  GCC_2s (cc),
811  GCPP_2s (path),
812  off);
813  GCPP_add_connection (path, off, cc);
814  for (unsigned int i = 0; i < off; i++)
816  first_hop = GCPP_get_peer_at_offset (path, 0);
817  cc->mq_man = GCP_request_mq (first_hop, &manage_first_hop_mq, cc);
818  return cc;
819 }
#define INITIAL_CONNECTION_CREATE_RETRY_DELAY
How long do we wait initially before retransmitting the KX? TODO: replace by 2 RTT if/once we have co...
Peer description.
Low-level connection to a destination.
const char * GCC_2s(const struct CadetConnection *cc)
Get a (static) string for a connection.
#define GNUNET_assert(cond)
Use this for fatal errors that cannot be handled.
const struct GNUNET_CADET_ConnectionTunnelIdentifier * GCC_get_id(struct CadetConnection *cc)
Obtain unique ID for the connection.
struct CadetPeerPath * path
Path we are using to our destination.
struct GNUNET_CADET_ConnectionTunnelIdentifier cid
ID of the connection.
#define GNUNET_OK
Named constants for return values.
Definition: gnunet_common.h:75
#define GNUNET_new(type)
Allocate a struct or union of the given type.
GCC_ReadyCallback ready_cb
Function to call once we are ready to transmit.
struct GNUNET_CONTAINER_MultiShortmap * connections
Map from struct GNUNET_CADET_ConnectionTunnelIdentifier hash codes to struct CadetConnection objects...
const char * GCPP_2s(struct CadetPeerPath *path)
Convert a path to a human-readable string.
#define LOG(level,...)
struct GNUNET_TIME_Relative retry_delay
How long do we wait before we try again with a CREATE message?
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:442
struct CadetTConnection * ct
Which tunnel is using this connection?
void GCP_add_connection(struct CadetPeer *cp, struct CadetConnection *cc)
Add a connection to this cp.
There must only be one value per key; storing a value should fail if a value under the same key alrea...
struct GCP_MessageQueueManager * mq_man
Handle for calling GCP_request_mq_cancel() once we are finished.
static void manage_first_hop_mq(void *cls, int available)
There has been a change in the message queue existence for our peer at the first hop.
void * ready_cb_cls
Closure for ready_cb.
enum CadetConnectionState state
State of the connection.
struct CadetPeer * GCPP_get_peer_at_offset(struct CadetPeerPath *path, unsigned int off)
Obtain the peer at offset off in path.
void GCPP_add_connection(struct CadetPeerPath *path, unsigned int off, struct CadetConnection *cc)
Notify path that it is used for connection cc which ends at the path&#39;s offset off.
struct GCP_MessageQueueManager * GCP_request_mq(struct CadetPeer *cp, GCP_MessageQueueNotificationCallback cb, void *cb_cls)
Start message queue change notifications.
unsigned int off
Offset of our destination in path.
Here is the call graph for this function:
Here is the caller graph for this function:

◆ GCC_create_inbound()

struct CadetConnection* GCC_create_inbound ( struct CadetPeer destination,
struct CadetPeerPath path,
struct CadetTConnection ct,
const struct GNUNET_CADET_ConnectionTunnelIdentifier cid,
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.

This is an inbound tunnel, so we must use the existing cid

Parameters
destinationwhere to go
pathwhich path to take (may not be the full path)
ctwhich tunnel uses this connection
ready_cbfunction to call when ready to transmit
ready_cb_clsclosure for cb
Returns
handle to the connection, NULL if we already have a connection that takes precedence on path

Definition at line 836 of file gnunet-service-cadet_connection.c.

References CADET_CONNECTION_CREATE_RECEIVED, CadetConnection::cid, connection_create(), CadetConnection::ct, GCC_2s(), GCC_destroy_without_tunnel(), GCPP_2s(), GCPP_find_peer(), GCPP_get_connection(), GCT_connection_lost(), GNUNET_assert, GNUNET_break_op, GNUNET_ERROR_TYPE_DEBUG, GNUNET_memcmp, LOG, and CadetConnection::off.

Referenced by GCT_add_inbound_connection().

842 {
843  struct CadetConnection *cc;
844  unsigned int off;
845 
846  off = GCPP_find_peer (path, destination);
847  GNUNET_assert (UINT_MAX != off);
848  cc = GCPP_get_connection (path, destination, off);
849  if (NULL != cc)
850  {
851  int cmp;
852 
853  cmp = GNUNET_memcmp (cid, &cc->cid);
854  if (0 == cmp)
855  {
856  /* Two peers picked the SAME random connection identifier at the
857  same time for the same path? Must be malicious. Drop
858  connection (existing and inbound), even if it is the only
859  one. */
860  GNUNET_break_op (0);
861  GCT_connection_lost (cc->ct);
863  return NULL;
864  }
865  if (0 < cmp)
866  {
867  /* drop existing */
869  "Got two connections on %s, dropping my existing %s\n",
870  GCPP_2s (path),
871  GCC_2s (cc));
872  GCT_connection_lost (cc->ct);
874  }
875  else
876  {
877  /* keep existing */
879  "Got two connections on %s, keeping my existing %s\n",
880  GCPP_2s (path),
881  GCC_2s (cc));
882  return NULL;
883  }
884  }
885 
886  return connection_create (destination,
887  path,
888  off,
889  ct,
890  cid,
892  ready_cb,
893  ready_cb_cls);
894 }
void GCT_connection_lost(struct CadetTConnection *ct)
We lost a connection, remove it from our list and clean up the connection object itself.
Low-level connection to a destination.
const char * GCC_2s(const struct CadetConnection *cc)
Get a (static) string for a connection.
#define GNUNET_assert(cond)
Use this for fatal errors that cannot be handled.
We are an inbound connection, and received a CREATE.
struct GNUNET_CADET_ConnectionTunnelIdentifier cid
ID of the connection.
static struct CadetConnection * connection_create(struct CadetPeer *destination, struct CadetPeerPath *path, unsigned int off, 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...
GCC_ReadyCallback ready_cb
Function to call once we are ready to transmit.
const char * GCPP_2s(struct CadetPeerPath *path)
Convert a path to a human-readable string.
#define LOG(level,...)
#define GNUNET_break_op(cond)
Use this for assertion violations caused by other peers (i.e.
struct CadetTConnection * ct
Which tunnel is using this connection?
void GCC_destroy_without_tunnel(struct CadetConnection *cc)
Destroy a connection, called if the tunnel association with the connection was already broken...
#define GNUNET_memcmp(a, b)
Compare memory in a and b, where both must be of the same pointer type.
unsigned int GCPP_find_peer(struct CadetPeerPath *path, struct CadetPeer *cp)
Find peer&#39;s offset on path.
void * ready_cb_cls
Closure for ready_cb.
struct CadetConnection * GCPP_get_connection(struct CadetPeerPath *path, struct CadetPeer *destination, unsigned int off)
Return connection to destination using path, or return NULL if no such connection exists...
unsigned int off
Offset of our destination in path.
Here is the call graph for this function:
Here is the caller graph for this function:

◆ GCC_create()

struct CadetConnection* GCC_create ( struct CadetPeer destination,
struct CadetPeerPath path,
unsigned int  off,
struct CadetTConnection ct,
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.

Parameters
destinationwhere to go
pathwhich path to take (may not be the full path)
offoffset of destination on path
cttunnel that uses the connection
ready_cbfunction to call when ready to transmit
ready_cb_clsclosure for cb
Returns
handle to the connection

Definition at line 910 of file gnunet-service-cadet_connection.c.

References CADET_CONNECTION_NEW, connection_create(), GNUNET_CRYPTO_QUALITY_NONCE, and GNUNET_CRYPTO_random_block().

Referenced by consider_path_cb().

916 {
918 
920  return connection_create (destination,
921  path,
922  off,
923  ct,
924  &cid,
926  ready_cb,
927  ready_cb_cls);
928 }
static struct CadetConnection * connection_create(struct CadetPeer *destination, struct CadetPeerPath *path, unsigned int off, 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...
Randomness for IVs etc.
Hash uniquely identifying a connection below a tunnel.
void GNUNET_CRYPTO_random_block(enum GNUNET_CRYPTO_Quality mode, void *buffer, size_t length)
Fill block with a random values.
Uninitialized status, we have not yet even gotten the message queue.
Here is the call graph for this function:
Here is the caller graph for this function:

◆ GCC_transmit()

void GCC_transmit ( struct CadetConnection cc,
struct GNUNET_MQ_Envelope env 
)

Transmit message msg via connection cc.

Must only be called (once) after the connection has signalled that it is ready via the ready_cb. Clients can also use #GCC_is_ready() to check if the connection is right now ready for transmission.

Parameters
ccconnection identification
envenvelope with message to transmit; must NOT yet have a GNUNET_MQ_notify_sent() callback attached to it

Definition at line 942 of file gnunet-service-cadet_connection.c.

References CADET_CONNECTION_READY, GCC_2s(), GCP_send(), GNUNET_assert, GNUNET_ERROR_TYPE_DEBUG, GNUNET_NO, GNUNET_SCHEDULER_cancel(), GNUNET_TIME_absolute_get(), GNUNET_YES, CadetConnectionMetrics::last_use, LOG, CadetConnection::metrics, CadetConnection::mq_man, CadetConnection::mqm_ready, CadetConnection::state, and CadetConnection::task.

Referenced by send_kx(), send_kx_auth(), and try_send_normal_payload().

943 {
945  "Scheduling message for transmission on %s\n",
946  GCC_2s (cc));
950  cc->mqm_ready = GNUNET_NO;
951  if (NULL != cc->task)
952  {
954  cc->task = NULL;
955  }
956  GCP_send (cc->mq_man, env);
957 }
int mqm_ready
Are we ready to transmit via mq_man right now?
struct GNUNET_SCHEDULER_Task * task
Task for connection maintenance.
const char * GCC_2s(const struct CadetConnection *cc)
Get a (static) string for a connection.
struct GNUNET_TIME_Absolute last_use
When was this connection last used? (by us sending or receiving a PAYLOAD message on it) ...
#define GNUNET_assert(cond)
Use this for fatal errors that cannot be handled.
#define GNUNET_NO
Definition: gnunet_common.h:78
void GCP_send(struct GCP_MessageQueueManager *mqm, struct GNUNET_MQ_Envelope *env)
Send the message in env to cp.
#define LOG(level,...)
Connection confirmed, ready to carry traffic.
struct GNUNET_TIME_Absolute GNUNET_TIME_absolute_get(void)
Get the current time.
Definition: time.c:118
struct CadetConnectionMetrics metrics
Performance metrics for this connection.
struct GCP_MessageQueueManager * mq_man
Handle for calling GCP_request_mq_cancel() once we are finished.
enum CadetConnectionState state
State of the connection.
#define GNUNET_YES
Definition: gnunet_common.h:77
void * GNUNET_SCHEDULER_cancel(struct GNUNET_SCHEDULER_Task *task)
Cancel the task with the specified identifier.
Definition: scheduler.c:966
Here is the call graph for this function:
Here is the caller graph for this function:

◆ GCC_get_path()

struct CadetPeerPath* GCC_get_path ( struct CadetConnection cc,
unsigned int *  off 
)

Obtain the path used by this connection.

Parameters
ccconnection
off[out]set to the length of the path we use
Returns
path to cc

Definition at line 968 of file gnunet-service-cadet_connection.c.

References CadetConnection::off, and CadetConnection::path.

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

969 {
970  *off = cc->off;
971  return cc->path;
972 }
struct CadetPeerPath * path
Path we are using to our destination.
unsigned int off
Offset of our destination in path.
Here is the caller graph for this function:

◆ GCC_get_id()

const struct GNUNET_CADET_ConnectionTunnelIdentifier* GCC_get_id ( struct CadetConnection cc)

Obtain unique ID for the connection.

Parameters
ccconnection.
Returns
unique number of the connection

Definition at line 982 of file gnunet-service-cadet_connection.c.

References CadetConnection::cid.

Referenced by connection_create(), GCC_destroy(), GCP_add_connection(), GCP_remove_connection(), handle_plaintext_channel_destroy(), handle_plaintext_channel_open(), handle_plaintext_channel_open_ack(), handle_plaintext_data(), handle_plaintext_data_ack(), send_kx(), send_kx_auth(), and try_send_normal_payload().

983 {
984  return &cc->cid;
985 }
struct GNUNET_CADET_ConnectionTunnelIdentifier cid
ID of the connection.
Here is the caller graph for this function:

◆ GCC_2s()

const char* GCC_2s ( const struct CadetConnection cc)

Get a (static) string for a connection.

Parameters
ccConnection.

Definition at line 994 of file gnunet-service-cadet_connection.c.

References buf, CadetConnection::cid, GNUNET_CADET_ConnectionTunnelIdentifier::connection_of_tunnel, CadetConnection::ct, GCT_2s(), GNUNET_sh2s(), GNUNET_snprintf(), and CadetTConnection::t.

Referenced by connection_create(), connection_ready_cb(), consider_path_cb(), evaluate_connection(), GCC_create_inbound(), GCC_debug(), GCC_destroy(), GCC_handle_connection_create_ack(), GCC_handle_duplicate_create(), GCC_handle_encrypted(), GCC_handle_kx(), GCC_handle_kx_auth(), GCC_transmit(), GCP_add_connection(), GCP_remove_connection(), GCPP_add_connection(), GCPP_del_connection(), GCT_add_inbound_connection(), GCT_handle_kx(), manage_first_hop_mq(), send_create(), send_create_ack(), send_keepalive(), and try_send_normal_payload().

995 {
996  static char buf[128];
997 
998  if (NULL == cc)
999  return "Connection(NULL)";
1000 
1001  if (NULL != cc->ct)
1002  {
1003  GNUNET_snprintf (buf,
1004  sizeof(buf),
1005  "Connection %s (%s)",
1007  GCT_2s (cc->ct->t));
1008  return buf;
1009  }
1010  GNUNET_snprintf (buf,
1011  sizeof(buf),
1012  "Connection %s",
1014  return buf;
1015 }
const char * GNUNET_sh2s(const struct GNUNET_ShortHashCode *shc)
Convert a short hash value to a string (for printing debug messages).
const char * GCT_2s(const struct CadetTunnel *t)
Get the static string for the peer this tunnel is directed.
int GNUNET_snprintf(char *buf, size_t size, const char *format,...)
Like snprintf, just aborts if the buffer is of insufficient size.
struct GNUNET_CADET_ConnectionTunnelIdentifier cid
ID of the connection.
struct CadetTunnel * t
Tunnel this connection belongs to.
static char buf[2048]
struct CadetTConnection * ct
Which tunnel is using this connection?
struct GNUNET_ShortHashCode connection_of_tunnel
Here is the call graph for this function:
Here is the caller graph for this function:

◆ GCC_debug()

void GCC_debug ( struct CadetConnection cc,
enum GNUNET_ErrorType  level 
)

Log connection info.

Parameters
ccconnection
levelDebug level to use.

Definition at line 1029 of file gnunet-service-cadet_connection.c.

References CadetConnection::destination, GCC_2s(), GCP_2s(), GCPP_2s(), GNUNET_ERROR_TYPE_BULK, GNUNET_get_log_call_status(), GNUNET_YES, LOG2, CadetConnection::mqm_ready, CadetConnection::path, and CadetConnection::state.

Referenced by GCT_debug().

1030 {
1031 #if ! defined(GNUNET_CULL_LOGGING)
1032  int do_log;
1033 
1035  "cadet-con",
1036  __FILE__,
1037  __FUNCTION__,
1038  __LINE__);
1039  if (0 == do_log)
1040  return;
1041  if (NULL == cc)
1042  {
1043  LOG2 (level, "Connection (NULL)\n");
1044  return;
1045  }
1046  LOG2 (level,
1047  "%s to %s via path %s in state %d is %s\n",
1048  GCC_2s (cc),
1049  GCP_2s (cc->destination),
1050  GCPP_2s (cc->path),
1051  cc->state,
1052  (GNUNET_YES == cc->mqm_ready) ? "ready" : "busy");
1053 #endif
1054 }
int mqm_ready
Are we ready to transmit via mq_man right now?
const char * GCC_2s(const struct CadetConnection *cc)
Get a (static) string for a connection.
struct CadetPeerPath * path
Path we are using to our destination.
struct CadetPeer * destination
To which peer does this connection go?
#define LOG2(level,...)
const char * GCP_2s(const struct CadetPeer *cp)
Get the static string for a peer ID.
const char * GCPP_2s(struct CadetPeerPath *path)
Convert a path to a human-readable string.
int GNUNET_get_log_call_status(int caller_level, const char *comp, const char *file, const char *function, int line)
Decides whether a particular logging call should or should not be allowed to be made.
enum CadetConnectionState state
State of the connection.
#define GNUNET_YES
Definition: gnunet_common.h:77
Here is the call graph for this function:
Here is the caller graph for this function: