GNUnet CADET service with encryption. More...
#include "gnunet-service-cadet.h"
#include "gnunet-service-cadet_peer.h"
#include "cadet_protocol.h"
Go to the source code of this file.
Functions | |
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... | |
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... | |
void | GCCH_assign_type_to_drop (struct CadetChannel *ch, const struct GNUNET_CADET_RequestDropCadetMessage *message) |
Assign type of message to drop. More... | |
const char * | GCCH_2s (const struct CadetChannel *ch) |
Get the static string for identification of the channel. More... | |
void | GCCH_debug (struct CadetChannel *ch, enum GNUNET_ErrorType level) |
Log channel info. More... | |
struct GNUNET_CADET_ChannelTunnelNumber | GCCH_get_id (const struct CadetChannel *ch) |
Get the channel's public ID. More... | |
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. 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... | |
void | GCCH_channel_local_destroy (struct CadetChannel *ch, struct CadetClient *c, struct GNUNET_CADET_ClientChannelNumber ccn) |
Destroy locally created channel. 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_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. 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... | |
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... | |
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_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... | |
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... | |
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... | |
GNUnet CADET service with encryption.
Definition in file gnunet-service-cadet_channel.h.
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().
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().
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().
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_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().
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.
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().
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().
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_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_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().
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().
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().
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_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().
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().
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().