logical links between CADET clients More...
#include "platform.h"
#include "cadet.h"
#include "gnunet_statistics_service.h"
#include "gnunet-service-cadet_channel.h"
#include "gnunet-service-cadet_connection.h"
#include "gnunet-service-cadet_tunnels.h"
#include "gnunet-service-cadet_paths.h"
Go to the source code of this file.
Data Structures | |
struct | CadetReliableMessage |
Info needed to retry a message in case it gets lost. More... | |
struct | CadetOutOfOrderMessage |
List of received out-of-order data messages. More... | |
struct | CadetChannelClient |
Client endpoint of a struct CadetChannel . More... | |
struct | CadetChannel |
Struct containing all information regarding a channel to a remote client. More... | |
Macros | |
#define | LOG(level, ...) GNUNET_log_from (level, "cadet-chn", __VA_ARGS__) |
#define | CADET_INITIAL_RETRANSMIT_TIME GNUNET_TIME_relative_multiply (GNUNET_TIME_UNIT_MILLISECONDS, 250) |
How long do we initially wait before retransmitting? More... | |
#define | TIMEOUT_CLOSED_PORT GNUNET_TIME_relative_multiply (GNUNET_TIME_UNIT_SECONDS, 30) |
How long do we wait before dropping state about incoming connection to closed port? More... | |
#define | MIN_RTT_DELAY GNUNET_TIME_relative_multiply (GNUNET_TIME_UNIT_MILLISECONDS, 75) |
How long do we wait at least before retransmitting ever? More... | |
#define | MAX_OUT_OF_ORDER_DISTANCE 1024 |
Maximum message ID into the future we accept for out-of-order messages. More... | |
#define | LOG2(level, ...) GNUNET_log_from_nocheck (level, "cadet-chn", __VA_ARGS__) |
Enumerations | |
enum | CadetChannelState { CADET_CHANNEL_NEW , CADET_CHANNEL_LOOSE , CADET_CHANNEL_OPEN_SENT , CADET_CHANNEL_READY } |
All the states a channel can be in. More... | |
Functions | |
void | GCCH_assign_type_to_drop (struct CadetChannel *ch, const struct GNUNET_CADET_RequestDropCadetMessage *message) |
Assign type of message to drop. More... | |
int | GCCH_is_type_to_drop (struct CadetChannel *ch, const struct GNUNET_MessageHeader *message) |
Check if type of message is the one to drop. More... | |
const char * | GCCH_2s (const struct CadetChannel *ch) |
Get the static string for identification of the channel. More... | |
void | GCCH_hash_port (struct GNUNET_HashCode *h_port, const struct GNUNET_HashCode *port, const struct GNUNET_PeerIdentity *listener) |
Hash the port and initiator and listener to calculate the "challenge" h_port we send to the other peer on GNUNET_MESSAGE_TYPE_CADET_CHANNEL_OPEN. More... | |
struct GNUNET_CADET_ChannelTunnelNumber | GCCH_get_id (const struct CadetChannel *ch) |
Get the channel's public ID. More... | |
static void | free_channel_client (struct CadetChannelClient *ccc) |
Release memory associated with ccc. More... | |
static void | channel_destroy (struct CadetChannel *ch) |
Destroy the given channel. More... | |
static void | send_channel_open (void *cls) |
Send a channel create message. More... | |
static void | channel_open_sent_cb (void *cls, const struct GNUNET_CADET_ConnectionTunnelIdentifier *cid) |
Function called once the tunnel confirms that we sent the create message. More... | |
void | GCCH_tunnel_up (struct CadetChannel *ch) |
Function called once and only once after a channel was bound to its tunnel via GCT_add_channel() is ready for transmission. More... | |
struct CadetChannel * | GCCH_channel_local_new (struct CadetClient *owner, struct GNUNET_CADET_ClientChannelNumber ccn, struct CadetPeer *destination, const struct GNUNET_HashCode *port, uint32_t options) |
Create a new channel. More... | |
static void | timeout_closed_cb (void *cls) |
We had an incoming channel to a port that is closed. More... | |
struct CadetChannel * | GCCH_channel_incoming_new (struct CadetTunnel *t, struct GNUNET_CADET_ChannelTunnelNumber ctn, const struct GNUNET_HashCode *h_port, uint32_t options) |
Create a new channel based on a request coming in over the network. More... | |
static void | send_ack_cb (void *cls, const struct GNUNET_CADET_ConnectionTunnelIdentifier *cid) |
Function called once the tunnel confirms that we sent the ACK message. More... | |
static void | send_channel_data_ack (struct CadetChannel *ch) |
Compute and send the current GNUNET_MESSAGE_TYPE_CADET_CHANNEL_APP_DATA_ACK to the other peer. More... | |
static void | send_open_ack (void *cls) |
Send our initial GNUNET_MESSAGE_TYPE_CADET_CHANNEL_OPEN_ACK to the client confirming that the connection is up. More... | |
void | GCCH_handle_duplicate_open (struct CadetChannel *ch, const struct GNUNET_CADET_ConnectionTunnelIdentifier *cti) |
We got a GNUNET_MESSAGE_TYPE_CADET_CHANNEL_OPEN message again for this channel. More... | |
static void | send_ack_to_client (struct CadetChannel *ch, int to_owner) |
Send a GNUNET_MESSAGE_TYPE_CADET_LOCAL_ACK to the client to solicit more messages. More... | |
void | GCCH_bind (struct CadetChannel *ch, struct CadetClient *c, const struct GNUNET_HashCode *port) |
A client is bound to the port that we have a channel open to. More... | |
static void | signal_remote_destroy_cb (void *cls) |
One of our clients has disconnected, tell the other one that we are finished. More... | |
void | GCCH_channel_local_destroy (struct CadetChannel *ch, struct CadetClient *c, struct GNUNET_CADET_ClientChannelNumber ccn) |
Destroy locally created channel. More... | |
void | GCCH_handle_channel_open_ack (struct CadetChannel *ch, const struct GNUNET_CADET_ConnectionTunnelIdentifier *cti, const struct GNUNET_HashCode *port) |
We got an acknowledgement for the creation of the channel (the port is open on the other side). More... | |
static int | is_before (void *cls, struct CadetOutOfOrderMessage *m1, struct CadetOutOfOrderMessage *m2) |
Test if element e1 comes before element e2. More... | |
void | GCCH_handle_channel_plaintext_data (struct CadetChannel *ch, const struct GNUNET_CADET_ConnectionTunnelIdentifier *cti, const struct GNUNET_CADET_ChannelAppDataMessage *msg) |
We got payload data for a channel. More... | |
static void | data_sent_cb (void *cls, const struct GNUNET_CADET_ConnectionTunnelIdentifier *cid) |
Function called once the tunnel has sent one of our messages. More... | |
static void | retry_transmission (void *cls) |
We need to retry a transmission, the last one took too long to be acknowledged. More... | |
static void | handle_matching_ack (struct CadetChannel *ch, const struct GNUNET_CADET_ConnectionTunnelIdentifier *cti, struct CadetReliableMessage *crm) |
We got an PLAINTEXT_DATA_ACK for a message in our queue, remove it from the queue and tell our client that it can send more. More... | |
void | GCCH_handle_channel_plaintext_data_ack (struct CadetChannel *ch, const struct GNUNET_CADET_ConnectionTunnelIdentifier *cti, const struct GNUNET_CADET_ChannelDataAckMessage *ack) |
We got an acknowledgement for payload data for a channel. More... | |
void | GCCH_handle_remote_destroy (struct CadetChannel *ch, const struct GNUNET_CADET_ConnectionTunnelIdentifier *cti) |
Destroy channel, based on the other peer closing the connection. More... | |
static int | cmp_crm_by_next_retry (void *cls, struct CadetReliableMessage *crm1, struct CadetReliableMessage *crm2) |
Test if element e1 comes before element e2. More... | |
int | GCCH_handle_local_data (struct CadetChannel *ch, struct GNUNET_CADET_ClientChannelNumber sender_ccn, const char *buf, size_t buf_len) |
Handle data given by a client. More... | |
void | GCCH_handle_local_ack (struct CadetChannel *ch, struct GNUNET_CADET_ClientChannelNumber client_ccn) |
Handle ACK from client on local channel. More... | |
void | GCCH_debug (struct CadetChannel *ch, enum GNUNET_ErrorType level) |
Log channel info. More... | |
logical links between CADET clients
TODO:
Definition in file gnunet-service-cadet_channel.c.
#define LOG | ( | level, | |
... | |||
) | GNUNET_log_from (level, "cadet-chn", __VA_ARGS__) |
Definition at line 44 of file gnunet-service-cadet_channel.c.
#define CADET_INITIAL_RETRANSMIT_TIME GNUNET_TIME_relative_multiply (GNUNET_TIME_UNIT_MILLISECONDS, 250) |
How long do we initially wait before retransmitting?
Definition at line 49 of file gnunet-service-cadet_channel.c.
#define TIMEOUT_CLOSED_PORT GNUNET_TIME_relative_multiply (GNUNET_TIME_UNIT_SECONDS, 30) |
How long do we wait before dropping state about incoming connection to closed port?
Definition at line 56 of file gnunet-service-cadet_channel.c.
#define MIN_RTT_DELAY GNUNET_TIME_relative_multiply (GNUNET_TIME_UNIT_MILLISECONDS, 75) |
How long do we wait at least before retransmitting ever?
Definition at line 62 of file gnunet-service-cadet_channel.c.
#define MAX_OUT_OF_ORDER_DISTANCE 1024 |
Maximum message ID into the future we accept for out-of-order messages.
If the message is more than this into the future, we drop it. This is important both to detect values that are actually in the past, as well as to limit adversarially triggerable memory consumption.
Note that right now we have "max_pending_messages = 4" hard-coded in the logic below, so a value of 4 would suffice here. But we plan to allow larger windows in the future...
Definition at line 75 of file gnunet-service-cadet_channel.c.
#define LOG2 | ( | level, | |
... | |||
) | GNUNET_log_from_nocheck (level, "cadet-chn", __VA_ARGS__) |
Definition at line 1953 of file gnunet-service-cadet_channel.c.
enum CadetChannelState |
All the states a channel can be in.
Enumerator | |
---|---|
CADET_CHANNEL_NEW | Uninitialized status, should never appear in operation. |
CADET_CHANNEL_LOOSE | Channel is to a port that is not open, we're waiting for the port to be opened. |
CADET_CHANNEL_OPEN_SENT | CHANNEL_OPEN message sent, waiting for CHANNEL_OPEN_ACK. |
CADET_CHANNEL_READY | Connection confirmed, ready to carry traffic. |
Definition at line 81 of file gnunet-service-cadet_channel.c.
void GCCH_assign_type_to_drop | ( | struct CadetChannel * | ch, |
const struct GNUNET_CADET_RequestDropCadetMessage * | message | ||
) |
Assign type of message to drop.
ch | CadetChannel to assign type to drop. |
message | GNUNET_CADET_RequestDropCadetMessage to get the type from. |
Definition at line 392 of file gnunet-service-cadet_channel.c.
References ch, and GNUNET_CADET_RequestDropCadetMessage::type.
Referenced by handle_drop_message().
int GCCH_is_type_to_drop | ( | struct CadetChannel * | ch, |
const struct GNUNET_MessageHeader * | message | ||
) |
Check if type of message is the one to drop.
ch | CadetChannel to check for message type to drop. |
message | GNUNET_MessageHeader to compare the type with. |
Definition at line 407 of file gnunet-service-cadet_channel.c.
References ch, GNUNET_NO, GNUNET_YES, and GNUNET_MessageHeader::type.
Referenced by GCT_send().
const char * GCCH_2s | ( | const struct CadetChannel * | ch | ) |
Get the static string for identification of the channel.
ch | Channel. |
Definition at line 429 of file gnunet-service-cadet_channel.c.
References GNUNET_CADET_Channel::ccn, ch, GNUNET_CADET_ClientChannelNumber::channel_of_client, GCP_get_id(), GCT_get_destination(), GNUNET_h2s(), GNUNET_i2s(), GNUNET_snprintf(), and GNUNET_YES.
Referenced by channel_destroy_iterator(), channel_open_sent_cb(), data_sent_cb(), GCCH_bind(), GCCH_channel_local_destroy(), GCCH_handle_channel_open_ack(), GCCH_handle_channel_plaintext_data(), GCCH_handle_channel_plaintext_data_ack(), GCCH_handle_duplicate_open(), GCCH_handle_local_ack(), GCCH_handle_local_data(), GCCH_handle_remote_destroy(), GCCH_tunnel_up(), GCT_add_channel(), GCT_remove_channel(), GSC_bind(), handle_channel_destroy(), handle_local_ack(), handle_local_data(), handle_matching_ack(), handle_plaintext_channel_destroy(), handle_plaintext_channel_open(), handle_plaintext_channel_open_ack(), retry_transmission(), send_channel_data_ack(), send_channel_open(), and send_open_ack().
void GCCH_hash_port | ( | struct GNUNET_HashCode * | h_port, |
const struct GNUNET_HashCode * | port, | ||
const struct GNUNET_PeerIdentity * | listener | ||
) |
Hash the port and initiator and listener to calculate the "challenge" h_port we send to the other peer on GNUNET_MESSAGE_TYPE_CADET_CHANNEL_OPEN.
[out] | h_port | set to the hash of port, initiator and listener |
port | cadet port, as seen by CADET clients | |
listener | peer that is listining on port |
Definition at line 461 of file gnunet-service-cadet_channel.c.
References GNUNET_CRYPTO_hash_context_finish(), GNUNET_CRYPTO_hash_context_read(), GNUNET_CRYPTO_hash_context_start(), GNUNET_ERROR_TYPE_DEBUG, GNUNET_h2s(), LOG, and port.
Referenced by GCCH_channel_local_new(), and handle_port_open().
struct GNUNET_CADET_ChannelTunnelNumber GCCH_get_id | ( | const struct CadetChannel * | ch | ) |
Get the channel's public ID.
ch | Channel. |
Definition at line 485 of file gnunet-service-cadet_channel.c.
References ch.
|
static |
Release memory associated with ccc.
ccc | data structure to clean up |
Definition at line 497 of file gnunet-service-cadet_channel.c.
References CadetOutOfOrderMessage::env, GNUNET_CONTAINER_DLL_remove, GNUNET_free, GNUNET_MQ_discard(), CadetChannelClient::head_recv, CadetChannelClient::num_recv, and CadetChannelClient::tail_recv.
Referenced by channel_destroy(), and GCCH_channel_local_destroy().
|
static |
Destroy the given channel.
ch | channel to destroy |
Definition at line 518 of file gnunet-service-cadet_channel.c.
References CADET_CHANNEL_LOOSE, ch, CadetReliableMessage::ch, CadetReliableMessage::data_message, free_channel_client(), GCT_remove_channel(), GCT_send_cancel(), GNUNET_assert, GNUNET_CONTAINER_DLL_remove, GNUNET_free, GNUNET_NO, GNUNET_SCHEDULER_cancel(), GSC_drop_loose_channel(), and CadetReliableMessage::qe.
Referenced by GCCH_channel_local_destroy(), GCCH_handle_local_ack(), GCCH_handle_remote_destroy(), reconnect(), signal_remote_destroy_cb(), and timeout_closed_cb().
|
static |
Send a channel create message.
Send a channel open message.
cls | Channel for which to send. |
Definition at line 613 of file gnunet-service-cadet_channel.c.
References CADET_CHANNEL_OPEN_SENT, ch, channel_open_sent_cb(), GNUNET_CADET_ChannelOpenMessage::ctn, GCCH_2s(), GCT_send(), GCT_send_cancel(), GNUNET_assert, GNUNET_ERROR_TYPE_DEBUG, GNUNET_MESSAGE_TYPE_CADET_CHANNEL_OPEN, GNUNET_CADET_ChannelOpenMessage::h_port, GNUNET_CADET_ChannelOpenMessage::header, LOG, GNUNET_CADET_ChannelOpenMessage::opt, GNUNET_MessageHeader::size, and GNUNET_MessageHeader::type.
Referenced by channel_open_sent_cb(), and GCCH_tunnel_up().
|
static |
Function called once the tunnel confirms that we sent the create message.
Delays for a bit until we retry.
cls | our struct CadetChannel . |
cid | identifier of the connection within the tunnel, NULL if transmission failed |
Definition at line 590 of file gnunet-service-cadet_channel.c.
References ch, GCCH_2s(), GNUNET_assert, GNUNET_ERROR_TYPE_DEBUG, GNUNET_SCHEDULER_add_delayed(), GNUNET_STRINGS_relative_time_to_string(), GNUNET_TIME_STD_BACKOFF, GNUNET_YES, LOG, and send_channel_open().
Referenced by send_channel_open().
void GCCH_tunnel_up | ( | struct CadetChannel * | ch | ) |
Function called once and only once after a channel was bound to its tunnel via GCT_add_channel() is ready for transmission.
Note that this is only the case for channels that this peer initiates, as for incoming channels we assume that they are ready for transmission immediately upon receiving the open message. Used to bootstrap the GCT_send() process.
ch | the channel for which the tunnel is now ready |
Definition at line 648 of file gnunet-service-cadet_channel.c.
References ch, GCCH_2s(), GNUNET_assert, GNUNET_ERROR_TYPE_DEBUG, GNUNET_SCHEDULER_add_now(), LOG, and send_channel_open().
Referenced by GCT_add_channel(), and notify_tunnel_up_cb().
struct CadetChannel * GCCH_channel_local_new | ( | struct CadetClient * | owner, |
struct GNUNET_CADET_ClientChannelNumber | owner_id, | ||
struct CadetPeer * | destination, | ||
const struct GNUNET_HashCode * | port, | ||
uint32_t | options | ||
) |
Create a new channel.
owner | local client owning the channel |
owner_id | local chid of this channel at the owner |
destination | peer to which we should build the channel |
port | desired port at destination |
options | options for the channel |
Definition at line 659 of file gnunet-service-cadet_channel.c.
References CadetChannelClient::c, CADET_CHANNEL_LOOSE, CADET_INITIAL_RETRANSMIT_TIME, CadetChannelClient::ccn, ch, CadetChannelClient::client_ready, GCCH_bind(), GCCH_hash_port(), GCP_2s(), GCP_get_id(), GCP_get_tunnel(), GCT_2s(), GCT_add_channel(), GNUNET_CONTAINER_multihashmap_get(), GNUNET_CONTAINER_multihashmap_put(), GNUNET_CONTAINER_MULTIHASHMAPOPTION_MULTIPLE, GNUNET_ERROR_TYPE_DEBUG, GNUNET_h2s(), GNUNET_memcmp, GNUNET_new, GNUNET_NO, GNUNET_STATISTICS_update(), GNUNET_YES, GSC_2s(), LOG, loose_channels, my_full_id, op, open_ports, port, and stats.
Referenced by handle_channel_create().
|
static |
We had an incoming channel to a port that is closed.
It has not been opened for a while, drop it.
cls | the channel to drop |
Definition at line 731 of file gnunet-service-cadet_channel.c.
References ch, channel_destroy(), GCP_2s(), GCT_get_destination(), GNUNET_ERROR_TYPE_DEBUG, GNUNET_h2s(), and LOG.
Referenced by GCCH_channel_incoming_new().
struct CadetChannel * GCCH_channel_incoming_new | ( | struct CadetTunnel * | t, |
struct GNUNET_CADET_ChannelTunnelNumber | chid, | ||
const struct GNUNET_HashCode * | h_port, | ||
uint32_t | options | ||
) |
Create a new channel based on a request coming in over the network.
t | tunnel to the remote peer |
chid | identifier of this channel in the tunnel |
h_port | hash of desired local port |
options | options for the channel |
Definition at line 745 of file gnunet-service-cadet_channel.c.
References CADET_CHANNEL_LOOSE, CADET_INITIAL_RETRANSMIT_TIME, ch, GCCH_bind(), GCP_2s(), GCT_get_destination(), GNUNET_assert, GNUNET_CONTAINER_multihashmap_get(), GNUNET_CONTAINER_multihashmap_put(), GNUNET_CONTAINER_MULTIHASHMAPOPTION_MULTIPLE, GNUNET_ERROR_TYPE_DEBUG, GNUNET_h2s(), GNUNET_new, GNUNET_NO, GNUNET_SCHEDULER_add_delayed(), GNUNET_STATISTICS_update(), GNUNET_YES, OpenPort::h_port, LOG, loose_channels, op, open_ports, stats, t, timeout_closed_cb(), and TIMEOUT_CLOSED_PORT.
Referenced by handle_plaintext_channel_open().
|
static |
Function called once the tunnel confirms that we sent the ACK message.
Just remembers it was sent, we do not expect ACKs for ACKs ;-).
cls | our struct CadetChannel . |
cid | identifier of the connection within the tunnel, NULL if transmission failed |
Definition at line 803 of file gnunet-service-cadet_channel.c.
References ch, and GNUNET_assert.
Referenced by send_channel_data_ack(), and send_open_ack().
|
static |
Compute and send the current GNUNET_MESSAGE_TYPE_CADET_CHANNEL_APP_DATA_ACK to the other peer.
ch | channel to send the GNUNET_MESSAGE_TYPE_CADET_CHANNEL_APP_DATA_ACK for |
Definition at line 819 of file gnunet-service-cadet_channel.c.
References ch, GCCH_2s(), GCT_send(), GCT_send_cancel(), GNUNET_ERROR_TYPE_DEBUG, GNUNET_htonll(), GNUNET_MESSAGE_TYPE_CADET_CHANNEL_APP_DATA_ACK, GNUNET_NO, LOG, msg, send_ack_cb(), GNUNET_MessageHeader::size, and GNUNET_MessageHeader::type.
Referenced by GCCH_handle_channel_plaintext_data(), and GCCH_handle_local_ack().
|
static |
Send our initial GNUNET_MESSAGE_TYPE_CADET_CHANNEL_OPEN_ACK to the client confirming that the connection is up.
cls | the struct CadetChannel |
Definition at line 849 of file gnunet-service-cadet_channel.c.
References ch, GCCH_2s(), GCT_send(), GCT_send_cancel(), GNUNET_ERROR_TYPE_DEBUG, GNUNET_MESSAGE_TYPE_CADET_CHANNEL_OPEN_ACK, LOG, msg, send_ack_cb(), GNUNET_MessageHeader::size, and GNUNET_MessageHeader::type.
Referenced by GCCH_bind(), and GCCH_handle_duplicate_open().
void GCCH_handle_duplicate_open | ( | struct CadetChannel * | ch, |
const struct GNUNET_CADET_ConnectionTunnelIdentifier * | cti | ||
) |
We got a GNUNET_MESSAGE_TYPE_CADET_CHANNEL_OPEN message again for this channel.
If the binding was successful, (re)transmit the GNUNET_MESSAGE_TYPE_CADET_CHANNEL_OPEN_ACK.
ch | channel that got the duplicate open |
cti | identifier of the connection that delivered the message |
Definition at line 879 of file gnunet-service-cadet_channel.c.
References ch, GCCH_2s(), GNUNET_ERROR_TYPE_DEBUG, GNUNET_SCHEDULER_add_now(), LOG, and send_open_ack().
Referenced by handle_plaintext_channel_open().
|
static |
Send a GNUNET_MESSAGE_TYPE_CADET_LOCAL_ACK to the client to solicit more messages.
ch | channel the ack is for |
to_owner | GNUNET_YES to send to owner, GNUNET_NO to send to dest |
Definition at line 912 of file gnunet-service-cadet_channel.c.
References CadetChannelClient::c, GNUNET_CADET_LocalAck::ccn, CadetChannelClient::ccn, ch, GNUNET_CADET_ClientChannelNumber::channel_of_client, env, GNUNET_assert, GNUNET_ERROR_TYPE_DEBUG, GNUNET_MESSAGE_TYPE_CADET_LOCAL_ACK, GNUNET_MQ_msg, GNUNET_YES, GSC_2s(), GSC_send_to_client(), and LOG.
Referenced by data_sent_cb(), GCCH_bind(), GCCH_handle_channel_open_ack(), GCCH_handle_local_ack(), GCCH_handle_local_data(), and handle_matching_ack().
void GCCH_bind | ( | struct CadetChannel * | ch, |
struct CadetClient * | c, | ||
const struct GNUNET_HashCode * | port | ||
) |
A client is bound to the port that we have a channel open to.
Send the acknowledgement for the connection request and establish the link with the client.
ch | open incoming channel |
c | client listening on the respective port |
port | port number c is listening on |
Definition at line 940 of file gnunet-service-cadet_channel.c.
References CadetChannelClient::c, CADET_CHANNEL_OPEN_SENT, CADET_CHANNEL_READY, CadetChannelClient::ccn, ch, GNUNET_CADET_ClientChannelNumber::channel_of_client, CadetChannelClient::client_ready, GCCH_2s(), GCCH_handle_channel_open_ack(), GCP_get(), GCT_2s(), GCT_get_destination(), GNUNET_assert, GNUNET_CADET_LOCAL_CHANNEL_ID_CLI, GNUNET_ERROR_TYPE_DEBUG, GNUNET_h2s(), GNUNET_new, GNUNET_NO, GNUNET_SCHEDULER_add_now(), GNUNET_SCHEDULER_cancel(), GNUNET_YES, GSC_2s(), GSC_bind(), LOG, my_full_id, options, port, send_ack_to_client(), and send_open_ack().
Referenced by bind_loose_channel(), GCCH_channel_incoming_new(), and GCCH_channel_local_new().
|
static |
One of our clients has disconnected, tell the other one that we are finished.
Done asynchronously to avoid concurrent modification issues if this is the same client.
cls | the struct CadetChannel where one of the ends is now dead |
Definition at line 1003 of file gnunet-service-cadet_channel.c.
References CadetChannelClient::c, CadetChannelClient::ccn, ch, channel_destroy(), and GSC_handle_remote_channel_destroy().
Referenced by GCCH_channel_local_destroy().
void GCCH_channel_local_destroy | ( | struct CadetChannel * | ch, |
struct CadetClient * | c, | ||
struct GNUNET_CADET_ClientChannelNumber | ccn | ||
) |
Destroy locally created channel.
Called by the local client, so no need to tell the client.
ch | channel to destroy |
c | client that caused the destruction |
ccn | client number of the client c |
Definition at line 1025 of file gnunet-service-cadet_channel.c.
References CadetChannelClient::c, CADET_CHANNEL_LOOSE, CADET_CHANNEL_NEW, GNUNET_CADET_Channel::ccn, CadetChannelClient::ccn, ch, channel_destroy(), GNUNET_CADET_ClientChannelNumber::channel_of_client, free_channel_client(), GCCH_2s(), GCT_send_channel_destroy(), GNUNET_assert, GNUNET_ERROR_TYPE_DEBUG, GNUNET_NO, GNUNET_SCHEDULER_add_now(), GNUNET_SCHEDULER_cancel(), GNUNET_YES, GSC_2s(), LOG, and signal_remote_destroy_cb().
Referenced by channel_destroy_iterator(), and handle_channel_destroy().
void GCCH_handle_channel_open_ack | ( | struct CadetChannel * | ch, |
const struct GNUNET_CADET_ConnectionTunnelIdentifier * | cti, | ||
const struct GNUNET_HashCode * | port | ||
) |
We got an acknowledgement for the creation of the channel (the port is open on the other side).
Verify that the other end really has the right port, and begin transmissions.
ch | channel to destroy |
cti | identifier of the connection that delivered the message, NULL if the ACK was inferred because we got payload or are on loopback |
port | port number (needed to verify receiver knows the port) |
Definition at line 1097 of file gnunet-service-cadet_channel.c.
References CADET_CHANNEL_LOOSE, CADET_CHANNEL_NEW, CADET_CHANNEL_OPEN_SENT, CADET_CHANNEL_READY, ch, GCCH_2s(), GNUNET_break, GNUNET_break_op, GNUNET_ERROR_TYPE_DEBUG, GNUNET_memcmp, GNUNET_NO, GNUNET_SCHEDULER_cancel(), GNUNET_STATISTICS_update(), GNUNET_YES, LOG, port, send_ack_to_client(), and stats.
Referenced by GCCH_bind(), and handle_plaintext_channel_open_ack().
|
static |
Test if element e1 comes before element e2.
cls | closure, to a flag where we indicate duplicate packets |
m1 | a message of to sort |
m2 | another message to sort |
Definition at line 1163 of file gnunet-service-cadet_channel.c.
References delta, GNUNET_NO, GNUNET_YES, INT_MAX, ChannelMessageIdentifier::mid, and CadetOutOfOrderMessage::mid.
Referenced by GCCH_handle_channel_plaintext_data().
void GCCH_handle_channel_plaintext_data | ( | struct CadetChannel * | ch, |
const struct GNUNET_CADET_ConnectionTunnelIdentifier * | cti, | ||
const struct GNUNET_CADET_ChannelAppDataMessage * | msg | ||
) |
We got payload data for a channel.
Pass it on to the client and send an ACK to the other end (once flow control allows it!)
ch | channel that got data |
cti | identifier of the connection that delivered the message |
msg | message that was received |
We always send if possible in this case. It is guaranteed that the queued MID < received MID
Definition at line 1189 of file gnunet-service-cadet_channel.c.
References CadetChannelClient::c, GNUNET_CADET_Channel::ccn, GNUNET_CADET_LocalData::ccn, CadetChannelClient::ccn, ch, GNUNET_CADET_ClientChannelNumber::channel_of_client, CadetChannelClient::client_ready, d, delta, env, CadetOutOfOrderMessage::env, GCCH_2s(), GCT_send_channel_destroy(), GNUNET_assert, GNUNET_CONTAINER_DLL_insert_sorted, GNUNET_CONTAINER_DLL_remove, GNUNET_ERROR_TYPE_DEBUG, GNUNET_free, GNUNET_memcpy, GNUNET_MESSAGE_TYPE_CADET_LOCAL_DATA, GNUNET_MQ_discard(), GNUNET_MQ_msg_extra, GNUNET_new, GNUNET_NO, GNUNET_STATISTICS_update(), GNUNET_YES, GSC_2s(), GSC_send_to_client(), CadetChannelClient::head_recv, is_before(), LOG, ChannelMessageIdentifier::mid, CadetOutOfOrderMessage::mid, msg, CadetChannelClient::num_recv, send_channel_data_ack(), GNUNET_MessageHeader::size, stats, and CadetChannelClient::tail_recv.
Referenced by handle_plaintext_data().
|
static |
Function called once the tunnel has sent one of our messages.
If the message is unreliable, simply frees the crm
. If the message was reliable, calculate retransmission time and wait for ACK (or retransmit).
cls | the struct CadetReliableMessage that was sent |
cid | identifier of the connection within the tunnel, NULL if transmission failed |
Definition at line 1672 of file gnunet-service-cadet_channel.c.
References CadetConnectionMetrics::aged_latency, ch, CadetReliableMessage::ch, CadetConnection::cid, cmp_crm_by_next_retry(), CadetReliableMessage::connection_taken, CadetReliableMessage::data_message, CadetReliableMessage::first_transmission_time, GCC_ack_expected(), GCC_get_metrics(), GCC_lookup(), GCCH_2s(), GNUNET_assert, GNUNET_CONTAINER_DLL_insert_sorted, GNUNET_CONTAINER_DLL_remove, GNUNET_ERROR_TYPE_DEBUG, GNUNET_free, GNUNET_NO, GNUNET_SCHEDULER_add_at(), GNUNET_SCHEDULER_cancel(), GNUNET_STRINGS_relative_time_to_string(), GNUNET_SYSERR, GNUNET_TIME_absolute_get(), GNUNET_TIME_absolute_get_remaining(), GNUNET_TIME_relative_max(), GNUNET_TIME_relative_to_absolute(), GNUNET_TIME_STD_BACKOFF, GNUNET_YES, LOG, ChannelMessageIdentifier::mid, GNUNET_CADET_ChannelAppDataMessage::mid, MIN_RTT_DELAY, CadetReliableMessage::next_retry, CadetReliableMessage::num_transmissions, CadetReliableMessage::qe, GNUNET_TIME_Relative::rel_value_us, CadetReliableMessage::retry_delay, retry_transmission(), and send_ack_to_client().
Referenced by GCCH_handle_local_data(), and retry_transmission().
|
static |
We need to retry a transmission, the last one took too long to be acknowledged.
cls | the struct CadetChannel where we need to retransmit |
Definition at line 1461 of file gnunet-service-cadet_channel.c.
References ch, GNUNET_CADET_ChannelAppDataMessage::ctn, CadetReliableMessage::data_message, data_sent_cb(), GCCH_2s(), GCT_send(), GNUNET_assert, GNUNET_ERROR_TYPE_DEBUG, GNUNET_CADET_ChannelAppDataMessage::header, LOG, ChannelMessageIdentifier::mid, GNUNET_CADET_ChannelAppDataMessage::mid, and CadetReliableMessage::qe.
Referenced by data_sent_cb(), and GCCH_handle_channel_plaintext_data_ack().
|
static |
We got an PLAINTEXT_DATA_ACK for a message in our queue, remove it from the queue and tell our client that it can send more.
ch | the channel that got the PLAINTEXT_DATA_ACK |
cti | identifier of the connection that delivered the message |
crm | the message that got acknowledged |
Definition at line 1487 of file gnunet-service-cadet_channel.c.
References ch, CadetReliableMessage::connection_taken, CadetReliableMessage::data_message, CadetReliableMessage::first_transmission_time, GCC_ack_observed(), GCC_latency_observed(), GCCH_2s(), GCT_send_cancel(), GNUNET_assert, GNUNET_CONTAINER_DLL_remove, GNUNET_ERROR_TYPE_DEBUG, GNUNET_free, GNUNET_memcmp, GNUNET_NO, GNUNET_TIME_absolute_get_duration(), GNUNET_YES, LOG, ChannelMessageIdentifier::mid, GNUNET_CADET_ChannelAppDataMessage::mid, CadetReliableMessage::num_transmissions, CadetReliableMessage::qe, and send_ack_to_client().
Referenced by GCCH_handle_channel_plaintext_data_ack().
void GCCH_handle_channel_plaintext_data_ack | ( | struct CadetChannel * | ch, |
const struct GNUNET_CADET_ConnectionTunnelIdentifier * | cti, | ||
const struct GNUNET_CADET_ChannelDataAckMessage * | ack | ||
) |
We got an acknowledgement for payload data for a channel.
Possibly resume transmissions.
ch | channel that got the ack |
cti | identifier of the connection that delivered the message |
ack | details about what was received |
Definition at line 1529 of file gnunet-service-cadet_channel.c.
References ch, CadetReliableMessage::data_message, delta, GNUNET_CADET_ChannelDataAckMessage::futures, GCCH_2s(), GNUNET_break, GNUNET_break_op, GNUNET_ERROR_TYPE_DEBUG, GNUNET_htonll(), GNUNET_NO, GNUNET_SCHEDULER_add_at(), GNUNET_SCHEDULER_cancel(), GNUNET_STATISTICS_update(), GNUNET_YES, handle_matching_ack(), consensus-simulation::int, LOG, ChannelMessageIdentifier::mid, GNUNET_CADET_ChannelAppDataMessage::mid, GNUNET_CADET_ChannelDataAckMessage::mid, CadetReliableMessage::next, retry_transmission(), and stats.
Referenced by handle_plaintext_data_ack().
void GCCH_handle_remote_destroy | ( | struct CadetChannel * | ch, |
const struct GNUNET_CADET_ConnectionTunnelIdentifier * | cti | ||
) |
Destroy channel, based on the other peer closing the connection.
Also needs to remove this channel from the tunnel.
FIXME: need to make it possible to defer destruction until we have received all messages up to the destroy, and right now the destroy message (and this API) fails to give is the information we need!
FIXME: also need to know if the other peer got a destroy from us before!
ch | channel to destroy |
cti | identifier of the connection that delivered the message, NULL if we are simulating receiving a destroy due to shutdown |
Definition at line 1611 of file gnunet-service-cadet_channel.c.
References CadetChannelClient::c, CadetChannelClient::ccn, ch, channel_destroy(), GCCH_2s(), GNUNET_assert, GNUNET_ERROR_TYPE_DEBUG, GNUNET_ERROR_TYPE_WARNING, GNUNET_NO, GNUNET_YES, GSC_handle_remote_channel_destroy(), CadetChannelClient::head_recv, and LOG.
Referenced by destroy_remaining_channels(), and handle_plaintext_channel_destroy().
|
static |
Test if element e1 comes before element e2.
cls | closure, to a flag where we indicate duplicate packets |
crm1 | an element of to sort |
crm2 | another element to sort |
Definition at line 1651 of file gnunet-service-cadet_channel.c.
References GNUNET_TIME_Absolute::abs_value_us, GNUNET_NO, GNUNET_YES, and CadetReliableMessage::next_retry.
Referenced by data_sent_cb().
int GCCH_handle_local_data | ( | struct CadetChannel * | ch, |
struct GNUNET_CADET_ClientChannelNumber | sender_ccn, | ||
const char * | buf, | ||
size_t | buf_len | ||
) |
Handle data given by a client.
Check whether the client is allowed to send in this tunnel, save if channel is reliable and send an ACK to the client if there is still buffer space in the tunnel.
ch | Channel. |
sender_ccn | ccn of the sender |
buf | payload to transmit. |
buf_len | number of bytes in buf |
Definition at line 1760 of file gnunet-service-cadet_channel.c.
References GNUNET_CADET_Channel::ccn, GNUNET_CADET_LocalData::ccn, ch, CadetReliableMessage::ch, GNUNET_CADET_ClientChannelNumber::channel_of_client, GNUNET_CADET_ChannelAppDataMessage::ctn, CadetReliableMessage::data_message, data_sent_cb(), env, CadetOutOfOrderMessage::env, GCCH_2s(), GCT_send(), GNUNET_assert, GNUNET_break, GNUNET_CONTAINER_DLL_insert_tail, GNUNET_ERROR_TYPE_DEBUG, GNUNET_free, GNUNET_malloc, GNUNET_memcpy, GNUNET_MESSAGE_TYPE_CADET_CHANNEL_APP_DATA, GNUNET_MESSAGE_TYPE_CADET_LOCAL_DATA, GNUNET_MQ_msg_extra, GNUNET_new, GNUNET_NO, GNUNET_OK, GNUNET_SCHEDULER_cancel(), GNUNET_SYSERR, GNUNET_YES, GSC_send_to_client(), GNUNET_CADET_ChannelAppDataMessage::header, LOG, ChannelMessageIdentifier::mid, GNUNET_CADET_ChannelAppDataMessage::mid, CadetReliableMessage::qe, receiver(), send_ack_to_client(), GNUNET_MessageHeader::size, and GNUNET_MessageHeader::type.
Referenced by handle_local_data().
void GCCH_handle_local_ack | ( | struct CadetChannel * | ch, |
struct GNUNET_CADET_ClientChannelNumber | client_ccn | ||
) |
Handle ACK from client on local channel.
Means the client is ready for more data, see if we have any for it.
ch | channel to destroy |
client_ccn | ccn of the client sending the ack |
Definition at line 1861 of file gnunet-service-cadet_channel.c.
References CadetChannelClient::c, GNUNET_CADET_Channel::ccn, CadetChannelClient::ccn, ch, channel_destroy(), GNUNET_CADET_ClientChannelNumber::channel_of_client, CadetChannelClient::client_ready, CadetOutOfOrderMessage::env, GCCH_2s(), GCT_send_channel_destroy(), GNUNET_assert, GNUNET_CONTAINER_DLL_remove, GNUNET_ERROR_TYPE_DEBUG, GNUNET_free, GNUNET_NO, GNUNET_YES, GSC_2s(), GSC_send_to_client(), CadetChannelClient::head_recv, LOG, ChannelMessageIdentifier::mid, CadetOutOfOrderMessage::mid, CadetChannelClient::num_recv, send_ack_to_client(), send_channel_data_ack(), and CadetChannelClient::tail_recv.
Referenced by handle_local_ack().
void GCCH_debug | ( | struct CadetChannel * | ch, |
enum GNUNET_ErrorType | level | ||
) |
Log channel info.
ch | Channel. |
level | Debug level to use. |
Definition at line 1964 of file gnunet-service-cadet_channel.c.
References GNUNET_CADET_Channel::ccn, ch, GNUNET_CADET_ClientChannelNumber::channel_of_client, GCT_2s(), GNUNET_ERROR_TYPE_BULK, GNUNET_get_log_call_status(), GSC_2s(), and LOG2.
Referenced by debug_channel().