A connection is a live end-to-end messaging mechanism where the peers are identified by a path and know how to forward along the route using a connection identifier for routing the data. More...
#include "gnunet_util_lib.h"#include "gnunet-service-cadet.h"#include "gnunet-service-cadet_peer.h"#include "cadet_protocol.h"Go to the source code of this file.
Data Structures | |
| struct | CadetConnectionCreatePS |
| Purpose for the signature of a monotime. More... | |
| struct | CadetConnectionMetrics |
| Performance metrics for a connection. More... | |
Typedefs | |
| typedef void(* | GCC_ReadyCallback) (void *cls, int is_ready) |
| Function called to notify tunnel about change in our readiness. | |
Functions | |
| void | GCC_destroy_without_core (struct CadetConnection *cc) |
| Destroy a connection, called when the CORE layer is already done (i.e. | |
| 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. | |
| struct CadetConnection * | GCC_lookup (const struct GNUNET_CADET_ConnectionTunnelIdentifier *cid) |
| Lookup a connection by its identifier. | |
| 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. | |
| 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. | |
| void | GCC_transmit (struct CadetConnection *cc, struct GNUNET_MQ_Envelope *env) |
| Transmit message msg via connection cc. | |
| 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. | |
| void | GCC_handle_duplicate_create (struct CadetConnection *cc) |
| We got a GNUNET_MESSAGE_TYPE_CADET_CONNECTION_CREATE for a connection that we already have. | |
| void | GCC_handle_kx (struct CadetConnection *cc, const struct GNUNET_CADET_TunnelKeyExchangeMessage *msg) |
| Handle KX message. | |
| void | GCC_handle_kx_auth (struct CadetConnection *cc, const struct GNUNET_CADET_TunnelKeyExchangeAuthMessage *msg) |
| Handle KX_AUTH message. | |
| const struct CadetConnectionMetrics * | GCC_get_metrics (struct CadetConnection *cc) |
| Obtain performance metrics from cc. | |
| void | GCC_handle_encrypted (struct CadetConnection *cc, const struct GNUNET_CADET_TunnelEncryptedMessage *msg) |
| Handle encrypted message. | |
| 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. | |
| 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. | |
| void | GCC_latency_observed (const struct GNUNET_CADET_ConnectionTunnelIdentifier *cti, struct GNUNET_TIME_Relative latency) |
| We observed some the given latency on the connection identified by cti. | |
| struct CadetTConnection * | GCC_get_ct (struct CadetConnection *cc) |
| Return the tunnel associated with this connection. | |
| struct CadetPeerPath * | GCC_get_path (struct CadetConnection *cc, unsigned int *off) |
| Obtain the path used by this connection. | |
| const struct GNUNET_CADET_ConnectionTunnelIdentifier * | GCC_get_id (struct CadetConnection *cc) |
| Obtain unique ID for the connection. | |
| const char * | GCC_2s (const struct CadetConnection *cc) |
| Get a (static) string for a connection. | |
| void | GCC_debug (struct CadetConnection *cc, enum GNUNET_ErrorType level) |
| Log connection info. | |
A connection is a live end-to-end messaging mechanism where the peers are identified by a path and know how to forward along the route using a connection identifier for routing the data.
Definition in file gnunet-service-cadet_connection.h.
| typedef void(* GCC_ReadyCallback) (void *cls, int is_ready) |
Function called to notify tunnel about change in our readiness.
| cls | closure |
| is_ready | GNUNET_YES if the connection is now ready for transmission, GNUNET_NO if the connection is no longer ready for transmission |
Definition at line 46 of file gnunet-service-cadet_connection.h.
| 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).
| cc | connection to destroy |
Definition at line 284 of file gnunet-service-cadet_connection.c.
References CadetConnection::ct, GCC_destroy(), GCT_connection_lost(), and CadetConnection::off.
Referenced by handle_connection_broken(), and handle_connection_destroy().
| 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.
| cc | connection to destroy |
Definition at line 303 of file gnunet-service-cadet_connection.c.
References CADET_CONNECTION_SENDING_CREATE, GNUNET_CADET_ConnectionDestroyMessage::cid, CadetConnection::cid, CadetConnection::ct, env, GCC_destroy(), GCP_request_mq_cancel(), GNUNET_MESSAGE_TYPE_CADET_CONNECTION_DESTROY, GNUNET_MQ_msg, CadetConnection::mq_man, CadetConnection::off, and CadetConnection::state.
Referenced by destroy_t_connection(), and GCC_create_inbound().
| struct CadetConnection * GCC_lookup | ( | const struct GNUNET_CADET_ConnectionTunnelIdentifier * | cid | ) |
Lookup a connection by its identifier.
| cid | identifier to resolve |
Definition at line 186 of file gnunet-service-cadet_connection.c.
References CadetConnection::cid, 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().
| 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.
| destination | where to go |
| path | which path to take (may not be the full path) |
| off | offset of destination on path |
| ct | which tunnel uses this connection |
| ready_cb | function to call when ready to transmit |
| ready_cb_cls | closure for cb |
Definition at line 932 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().
| 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
| destination | where to go |
| path | which path to take (may not be the full path) |
| ct | which tunnel uses this connection |
| ready_cb | function to call when ready to transmit |
| ready_cb_cls | closure for cb |
Definition at line 870 of file gnunet-service-cadet_connection.c.
References CADET_CONNECTION_CREATE_RECEIVED, CadetConnection::cid, connection_create(), CadetConnection::ct, CadetConnection::destination, 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, CadetConnection::off, CadetConnection::path, CadetConnection::ready_cb, and CadetConnection::ready_cb_cls.
Referenced by GCT_add_inbound_connection().
| 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.
| cc | connection identification |
| env | envelope with message to transmit; the #GNUNET_MQ_notify_send() must not have yet been used for the envelope. Also, the message better match the connection identifier of this connection... |
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.
| cc | connection identification |
| env | envelope with message to transmit; must NOT yet have a GNUNET_MQ_notify_sent() callback attached to it |
Definition at line 964 of file gnunet-service-cadet_connection.c.
References CADET_CONNECTION_READY, env, 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().
| 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.
Process it.
| cc | the 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, CadetConnection::off, 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().
| 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.
| cc | connection that got the duplicate CREATE |
Definition at line 695 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().
| void GCC_handle_kx | ( | struct CadetConnection * | cc, |
| const struct GNUNET_CADET_TunnelKeyExchangeMessage * | msg | ||
| ) |
Handle KX message.
| cc | connection that received encrypted message |
| msg | the 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, GCC_2s(), GCC_handle_connection_create_ack(), GCT_handle_kx(), GNUNET_e2s(), GNUNET_ERROR_TYPE_DEBUG, GNUNET_sh2s(), LOG, msg, and CadetConnection::state.
Referenced by handle_tunnel_kx().
| void GCC_handle_kx_auth | ( | struct CadetConnection * | cc, |
| const struct GNUNET_CADET_TunnelKeyExchangeAuthMessage * | msg | ||
| ) |
Handle KX_AUTH message.
| cc | connection that received encrypted message |
| msg | the 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, GCC_2s(), GCC_handle_connection_create_ack(), GCT_handle_kx_auth(), GNUNET_e2s(), GNUNET_ERROR_TYPE_DEBUG, GNUNET_sh2s(), LOG, msg, and CadetConnection::state.
Referenced by handle_tunnel_kx_auth().
| const struct CadetConnectionMetrics * GCC_get_metrics | ( | struct CadetConnection * | cc | ) |
Obtain performance metrics from cc.
| cc | connection to query |
Definition at line 342 of file gnunet-service-cadet_connection.c.
References CadetConnection::metrics.
Referenced by data_sent_cb(), and evaluate_connection().
| void GCC_handle_encrypted | ( | struct CadetConnection * | cc, |
| const struct GNUNET_CADET_TunnelEncryptedMessage * | msg | ||
| ) |
Handle encrypted message.
| cc | connection that received encrypted message |
| msg | the 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, msg, and CadetConnection::state.
Referenced by handle_tunnel_encrypted().
| 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.
| cid | connection identifier where we expect an ACK |
Definition at line 421 of file gnunet-service-cadet_connection.c.
References CadetConnection::cid, GCC_lookup(), CadetConnection::metrics, CadetConnectionMetrics::num_acked_transmissions, and CadetConnection::off.
Referenced by data_sent_cb().
| 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.
| cid | connection 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). |
We observed an ACK for a message that was originally sent via the connection identified by cti.
| cid | connection 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 441 of file gnunet-service-cadet_connection.c.
References CadetConnection::cid, GCC_lookup(), CadetConnection::metrics, CadetConnectionMetrics::num_successes, and CadetConnection::off.
Referenced by handle_matching_ack().
| void GCC_latency_observed | ( | const struct GNUNET_CADET_ConnectionTunnelIdentifier * | cti, |
| 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.)
| cti | connection identifier where we measured latency |
| latency | the observed latency |
Definition at line 453 of file gnunet-service-cadet_connection.c.
References CadetConnectionMetrics::aged_latency, CadetConnection::cid, GCC_lookup(), GNUNET_NO, GNUNET_STATISTICS_update(), CadetConnection::latency_datapoints, CadetConnection::metrics, CadetConnection::off, GNUNET_TIME_Relative::rel_value_us, result, and stats.
Referenced by handle_matching_ack().
| struct CadetTConnection * GCC_get_ct | ( | struct CadetConnection * | cc | ) |
Return the tunnel associated with this connection.
| cc | connection to query |
Definition at line 329 of file gnunet-service-cadet_connection.c.
References CadetTConnection::cc, and CadetConnection::ct.
| struct CadetPeerPath * GCC_get_path | ( | struct CadetConnection * | cc, |
| unsigned int * | off | ||
| ) |
Obtain the path used by this connection.
| cc | connection | |
| [out] | off | set to offset in this path where the connection cc ends |
| cc | connection | |
| [out] | off | set to the length of the path we use |
Definition at line 990 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().
| const struct GNUNET_CADET_ConnectionTunnelIdentifier * GCC_get_id | ( | struct CadetConnection * | cc | ) |
Obtain unique ID for the connection.
| cc | connection. |
Definition at line 1004 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().
| const char * GCC_2s | ( | const struct CadetConnection * | cc | ) |
Get a (static) string for a connection.
| cc | Connection. |
Definition at line 1016 of file gnunet-service-cadet_connection.c.
References 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().
| void GCC_debug | ( | struct CadetConnection * | cc, |
| enum GNUNET_ErrorType | level | ||
| ) |
Log connection info.
| cc | connection |
| level | Debug level to use. |
Definition at line 1051 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().