![]() |
GNUnet
0.11.x
|
Transport plugin using TCP. More...
#include "platform.h"
#include "gnunet_util_lib.h"
#include "gnunet_core_service.h"
#include "gnunet_peerstore_service.h"
#include "gnunet_protocols.h"
#include "gnunet_signatures.h"
#include "gnunet_constants.h"
#include "gnunet_nt_lib.h"
#include "gnunet_nat_service.h"
#include "gnunet_statistics_service.h"
#include "gnunet_transport_communication_service.h"
#include "gnunet_resolver_service.h"
Go to the source code of this file.
Data Structures | |
struct | TcpHandshakeSignature |
Signature we use to verify that the ephemeral key was really chosen by the specified sender. More... | |
struct | TcpHandshakeAckSignature |
Signature we use to verify that the ack from the receiver of the ephemeral key was really send by the specified sender. More... | |
struct | TCPConfirmation |
Encrypted continuation of TCP initial handshake. More... | |
struct | TCPConfirmationAck |
Ack for the encrypted continuation of TCP initial handshake. More... | |
struct | TCPBox |
TCP message box. More... | |
struct | TCPRekey |
TCP rekey message box. More... | |
struct | TcpRekeySignature |
Signature we use to verify that the ephemeral key was really chosen by the specified sender. More... | |
struct | TCPFinish |
TCP finish. More... | |
struct | ListenTask |
Struct to use as closure. More... | |
struct | Queue |
Handle for a queue. More... | |
struct | ProtoQueue |
Handle for an incoming connection where we do not yet have enough information to setup a full queue. More... | |
struct | PortOnlyIpv4Ipv6 |
In case of port only configuration we like to bind to ipv4 and ipv6 addresses. More... | |
struct | Addresses |
DLL to store the addresses we like to register at NAT service. More... | |
Macros | |
#define | ADDRESS_VALIDITY_PERIOD GNUNET_TIME_relative_multiply (GNUNET_TIME_UNIT_HOURS, 4) |
How long do we believe our addresses to remain up (before the other peer should revalidate). More... | |
#define | DEFAULT_MAX_QUEUE_LENGTH 8 |
How many messages do we keep at most in the queue to the transport service before we start to drop (default, can be changed via the configuration file). More... | |
#define | BUF_SIZE (2 * 64 * 1024 + sizeof(struct TCPBox)) |
Size of our IO buffers for ciphertext data. More... | |
#define | DEFAULT_REKEY_INTERVAL GNUNET_TIME_UNIT_DAYS |
How often do we rekey based on time (at least) More... | |
#define | PROTO_QUEUE_TIMEOUT GNUNET_TIME_UNIT_MINUTES |
How long do we wait until we must have received the initial KX? More... | |
#define | REKEY_MAX_BYTES (1024LLU * 1024 * 1024 * 4LLU) |
How often do we rekey based on number of bytes transmitted? (additionally randomized). More... | |
#define | INITIAL_KX_SIZE |
Size of the initial key exchange message sent first in both directions. More... | |
#define | INITIAL_CORE_KX_SIZE |
Size of the initial core key exchange messages. More... | |
#define | COMMUNICATOR_ADDRESS_PREFIX "tcp" |
Address prefix used by the communicator. More... | |
#define | COMMUNICATOR_CONFIG_SECTION "communicator-tcp" |
Configuration section used by the communicator. More... | |
Functions | |
static void | listen_cb (void *cls) |
We have been notified that our listen socket has something to read. More... | |
static void | queue_destroy (struct Queue *queue) |
Functions with this signature are called whenever we need to close a queue due to a disconnect or failure to establish a connection. More... | |
static void | calculate_hmac (struct GNUNET_HashCode *hmac_secret, const void *buf, size_t buf_size, struct GNUNET_ShortHashCode *smac) |
Compute mac over buf, and ratched the hmac_secret. More... | |
static void | queue_finish (struct Queue *queue) |
Append a 'finish' message to the outgoing transmission. More... | |
static void | reschedule_queue_timeout (struct Queue *queue) |
Increment queue timeout due to activity. More... | |
static void | queue_read (void *cls) |
Queue read task. More... | |
static void | core_read_finished_cb (void *cls, int success) |
Core tells us it is done processing a message that transport received on a queue with status success. More... | |
static void | pass_plaintext_to_core (struct Queue *queue, const void *plaintext, size_t plaintext_len) |
We received plaintext_len bytes of plaintext on queue. More... | |
static void | setup_cipher (const struct GNUNET_HashCode *dh, const struct GNUNET_PeerIdentity *pid, gcry_cipher_hd_t *cipher, struct GNUNET_HashCode *hmac_key) |
Setup cipher based on shared secret dh and decrypting peer pid. More... | |
static void | rekey_monotime_store_cb (void *cls, int success) |
Callback called when peerstore store operation for rekey monotime value is finished. More... | |
static void | rekey_monotime_cb (void *cls, const struct GNUNET_PEERSTORE_Record *record, const char *emsg) |
Callback called by peerstore when records for GNUNET_PEERSTORE_TRANSPORT_TCP_COMMUNICATOR_REKEY where found. More... | |
static void | setup_in_cipher (const struct GNUNET_CRYPTO_EcdhePublicKey *ephemeral, struct Queue *queue) |
Setup cipher of queue for decryption. More... | |
static void | do_rekey (struct Queue *queue, const struct TCPRekey *rekey) |
Handle rekey message on queue. More... | |
static void | handshake_ack_monotime_store_cb (void *cls, int success) |
Callback called when peerstore store operation for handshake ack monotime value is finished. More... | |
static void | handshake_ack_monotime_cb (void *cls, const struct GNUNET_PEERSTORE_Record *record, const char *emsg) |
Callback called by peerstore when records for GNUNET_PEERSTORE_TRANSPORT_TCP_COMMUNICATOR_HANDSHAKE_ACK where found. More... | |
static void | send_challenge (struct ChallengeNonceP challenge, struct Queue *queue) |
Sending challenge with TcpConfirmationAck back to sender of ephemeral key. More... | |
static void | setup_out_cipher (struct Queue *queue) |
Setup cipher for outgoing data stream based on target and our ephemeral private key. More... | |
static void | inject_rekey (struct Queue *queue) |
Inject a struct TCPRekey message into the queue's plaintext buffer. More... | |
static void | queue_write (void *cls) |
We have been notified that our socket is ready to write. More... | |
static size_t | try_handle_plaintext (struct Queue *queue) |
Test if we have received a full message in plaintext. More... | |
static struct sockaddr * | tcp_address_to_sockaddr_numeric_v6 (socklen_t *sock_len, struct sockaddr_in6 v6, unsigned int port) |
Convert a struct sockaddr_in6 to a struct sockaddr *`. More... | |
static struct sockaddr * | tcp_address_to_sockaddr_numeric_v4 (socklen_t *sock_len, struct sockaddr_in v4, unsigned int port) |
Convert a struct sockaddr_in4 to a struct sockaddr *`. More... | |
static struct PortOnlyIpv4Ipv6 * | tcp_address_to_sockaddr_port_only (const char *bindto, unsigned int *port) |
Convert TCP bind specification to a struct PortOnlyIpv4Ipv6 * More... | |
static char * | extract_address (const char *bindto) |
This Method extracts the address part of the BINDTO string. More... | |
static unsigned int | extract_port (const char *addr_and_port) |
This Method extracts the port part of the BINDTO string. More... | |
static struct sockaddr * | tcp_address_to_sockaddr (const char *bindto, socklen_t *sock_len) |
Convert TCP bind specification to a struct sockaddr * More... | |
static void | mq_send (struct GNUNET_MQ_Handle *mq, const struct GNUNET_MessageHeader *msg, void *impl_state) |
Signature of functions implementing the sending functionality of a message queue. More... | |
static void | mq_destroy (struct GNUNET_MQ_Handle *mq, void *impl_state) |
Signature of functions implementing the destruction of a message queue. More... | |
static void | mq_cancel (struct GNUNET_MQ_Handle *mq, void *impl_state) |
Implementation function that cancels the currently sent message. More... | |
static void | mq_error (void *cls, enum GNUNET_MQ_Error error) |
Generic error handler, called with the appropriate error code and the same closure specified at the creation of the message queue. More... | |
static void | boot_queue (struct Queue *queue) |
Add the given queue to our internal data structure. More... | |
static void | transmit_kx (struct Queue *queue, const struct GNUNET_CRYPTO_EcdhePublicKey *epub) |
Generate and transmit our ephemeral key and the signature for the initial KX with the other peer. More... | |
static void | start_initial_kx_out (struct Queue *queue) |
Initialize our key material for outgoing transmissions and inform the other peer about it. More... | |
static void | handshake_monotime_store_cb (void *cls, int success) |
Callback called when peerstore store operation for handshake monotime is finished. More... | |
static void | handshake_monotime_cb (void *cls, const struct GNUNET_PEERSTORE_Record *record, const char *emsg) |
Callback called by peerstore when records for GNUNET_PEERSTORE_TRANSPORT_TCP_COMMUNICATOR_HANDSHAKE where found. More... | |
static int | decrypt_and_check_tc (struct Queue *queue, struct TCPConfirmation *tc, char *ibuf) |
We have received the first bytes from the other side on a queue. More... | |
static void | free_proto_queue (struct ProtoQueue *pq) |
Closes socket and frees memory associated with pq. More... | |
static void | proto_read_kx (void *cls) |
Read from the socket of the proto queue until we have enough data to upgrade to full queue. More... | |
static void | queue_read_kx (void *cls) |
Read from the socket of the queue until we have enough data to initialize the decryption logic and can switch to regular reading. More... | |
static int | mq_init (void *cls, const struct GNUNET_PeerIdentity *peer, const char *address) |
Function called by the transport service to initialize a message queue given address information about another peer. More... | |
static int | get_lt_delete_it (void *cls, const struct GNUNET_HashCode *key, void *value) |
Iterator over all ListenTasks to clean up. More... | |
static int | get_queue_delete_it (void *cls, const struct GNUNET_PeerIdentity *target, void *value) |
Iterator over all message queues to clean up. More... | |
static void | do_shutdown (void *cls) |
Shutdown the UNIX communicator. More... | |
static void | enc_notify_cb (void *cls, const struct GNUNET_PeerIdentity *sender, const struct GNUNET_MessageHeader *msg) |
Function called when the transport service has received an acknowledgement for this communicator (!) via a different return path. More... | |
static void | nat_address_cb (void *cls, void **app_ctx, int add_remove, enum GNUNET_NAT_AddressClass ac, const struct sockaddr *addr, socklen_t addrlen) |
Signature of the callback passed to GNUNET_NAT_register() for a function to call whenever our set of 'valid' addresses changes. More... | |
static void | add_addr (struct sockaddr *in, socklen_t in_len) |
This method adds addresses to the DLL, that are later register at the NAT service. More... | |
static int | init_socket (struct sockaddr *addr, socklen_t in_len) |
This method launch network interactions for each address we like to bind to. More... | |
static void | nat_register () |
This method reads from the DLL addrs_head to register them at the NAT service. More... | |
static void | init_socket_resolv (void *cls, const struct sockaddr *addr, socklen_t in_len) |
This method is the callback called by the resolver API, and wraps method init_socket. More... | |
static void | run (void *cls, char *const *args, const char *cfgfile, const struct GNUNET_CONFIGURATION_Handle *c) |
Setup communicator and launch network interactions. More... | |
int | main (int argc, char *const *argv) |
The main function for the UNIX communicator. More... | |
Variables | |
static unsigned long long | max_queue_length |
Maximum queue length before we stop reading towards the transport service. More... | |
static struct GNUNET_STATISTICS_Handle * | stats |
For logging statistics. More... | |
static struct GNUNET_TRANSPORT_CommunicatorHandle * | ch |
Our environment. More... | |
static struct GNUNET_CONTAINER_MultiPeerMap * | queue_map |
Queues (map from peer identity to struct Queue ) More... | |
static struct GNUNET_CONTAINER_MultiHashMap * | lt_map |
ListenTasks (map from socket to struct ListenTask ) More... | |
static struct GNUNET_PeerIdentity | my_identity |
Our public key. More... | |
static struct GNUNET_TIME_Relative | rekey_interval |
The rekey interval. More... | |
static struct GNUNET_CRYPTO_EddsaPrivateKey * | my_private_key |
Our private key. More... | |
static const struct GNUNET_CONFIGURATION_Handle * | cfg |
Our configuration. More... | |
static struct GNUNET_NT_InterfaceScanner * | is |
Network scanner to determine network types. More... | |
static struct GNUNET_NAT_Handle * | nat |
Connection to NAT service. More... | |
static struct ProtoQueue * | proto_head |
Protoqueues DLL head. More... | |
static struct ProtoQueue * | proto_tail |
Protoqueues DLL tail. More... | |
struct GNUNET_RESOLVER_RequestHandle * | resolve_request_handle |
Handle for DNS lookup of bindto address. More... | |
struct Addresses * | addrs_head |
Head of DLL with addresses we like to register at NAT servcie. More... | |
struct Addresses * | addrs_tail |
Head of DLL with addresses we like to register at NAT servcie. More... | |
struct ListenTask * | lts_head |
Head of DLL with ListenTasks. More... | |
struct ListenTask * | lts_tail |
Head of DLL with ListenTask. More... | |
int | addrs_lens |
Number of addresses in the DLL for register at NAT service. More... | |
size_t | unverified_size |
Size of data received without KX challenge played back. More... | |
static struct GNUNET_PEERSTORE_Handle * | peerstore |
Database for peer's HELLOs. More... | |
int | shutdown_running = GNUNET_NO |
A flag indicating we are already doing a shutdown. More... | |
unsigned int | bind_port |
The port the communicator should be assigned to. More... | |
Transport plugin using TCP.
TODO:
Definition in file gnunet-communicator-tcp.c.
#define ADDRESS_VALIDITY_PERIOD GNUNET_TIME_relative_multiply (GNUNET_TIME_UNIT_HOURS, 4) |
How long do we believe our addresses to remain up (before the other peer should revalidate).
Definition at line 47 of file gnunet-communicator-tcp.c.
Referenced by pass_plaintext_to_core().
#define DEFAULT_MAX_QUEUE_LENGTH 8 |
How many messages do we keep at most in the queue to the transport service before we start to drop (default, can be changed via the configuration file).
Should be below the level of the communicator API, as otherwise we may read messages just to have them dropped by the communicator API.
Definition at line 58 of file gnunet-communicator-tcp.c.
Referenced by run().
#define BUF_SIZE (2 * 64 * 1024 + sizeof(struct TCPBox)) |
Size of our IO buffers for ciphertext data.
Must be at least UINT_MAX + sizeof (struct TCPBox).
Definition at line 64 of file gnunet-communicator-tcp.c.
Referenced by queue_read(), queue_read_kx(), and queue_write().
#define DEFAULT_REKEY_INTERVAL GNUNET_TIME_UNIT_DAYS |
How often do we rekey based on time (at least)
Definition at line 69 of file gnunet-communicator-tcp.c.
Referenced by run().
#define PROTO_QUEUE_TIMEOUT GNUNET_TIME_UNIT_MINUTES |
How long do we wait until we must have received the initial KX?
Definition at line 74 of file gnunet-communicator-tcp.c.
Referenced by listen_cb().
#define REKEY_MAX_BYTES (1024LLU * 1024 * 1024 * 4LLU) |
How often do we rekey based on number of bytes transmitted? (additionally randomized).
Definition at line 80 of file gnunet-communicator-tcp.c.
Referenced by setup_out_cipher().
#define INITIAL_KX_SIZE |
Size of the initial key exchange message sent first in both directions.
Definition at line 86 of file gnunet-communicator-tcp.c.
Referenced by queue_read_kx().
#define INITIAL_CORE_KX_SIZE |
Size of the initial core key exchange messages.
Definition at line 93 of file gnunet-communicator-tcp.c.
Referenced by try_handle_plaintext().
#define COMMUNICATOR_ADDRESS_PREFIX "tcp" |
Address prefix used by the communicator.
Definition at line 101 of file gnunet-communicator-tcp.c.
Referenced by init_socket(), mq_init(), nat_address_cb(), and try_handle_plaintext().
#define COMMUNICATOR_CONFIG_SECTION "communicator-tcp" |
Configuration section used by the communicator.
Definition at line 106 of file gnunet-communicator-tcp.c.
Referenced by init_socket(), nat_register(), run(), and tcp_address_to_sockaddr_port_only().
|
static |
We have been notified that our listen socket has something to read.
Do the read and reschedule this function to be called again once more is available.
cls | NULL |
Do the read and reschedule this function to be called again once more is available.
cls | ListenTask with listening socket and task |
Definition at line 2779 of file gnunet-communicator-tcp.c.
References ProtoQueue::address, ProtoQueue::address_len, GNUNET_assert, GNUNET_CONTAINER_DLL_insert, GNUNET_ERROR_TYPE_DEBUG, GNUNET_ERROR_TYPE_WARNING, GNUNET_log, GNUNET_log_strerror, GNUNET_memdup, GNUNET_NETWORK_socket_accept(), GNUNET_new, GNUNET_SCHEDULER_add_read_net(), GNUNET_TIME_relative_to_absolute(), GNUNET_TIME_UNIT_FOREVER_REL, ListenTask::listen_sock, ListenTask::listen_task, PROTO_QUEUE_TIMEOUT, proto_read_kx(), ProtoQueue::read_task, ProtoQueue::sock, and ProtoQueue::timeout.
Referenced by GNUNET_SET_listen(), GNUNET_SETI_listen(), GNUNET_SETU_listen(), init_socket(), and queue_destroy().
|
static |
Functions with this signature are called whenever we need to close a queue due to a disconnect or failure to establish a connection.
queue | queue to close down |
Definition at line 876 of file gnunet-communicator-tcp.c.
References Queue::address, Queue::backpressure, Queue::destroyed, GNUNET_assert, GNUNET_CONTAINER_multihashmap_get(), GNUNET_CONTAINER_multipeermap_remove(), GNUNET_CONTAINER_multipeermap_size(), GNUNET_CRYPTO_hash(), GNUNET_ERROR_TYPE_DEBUG, GNUNET_ERROR_TYPE_ERROR, GNUNET_free, GNUNET_i2s(), GNUNET_log, GNUNET_NETWORK_socket_close(), GNUNET_NO, GNUNET_PEERSTORE_iterate_cancel(), GNUNET_PEERSTORE_store_cancel(), GNUNET_SCHEDULER_add_read_net(), GNUNET_SCHEDULER_cancel(), GNUNET_STATISTICS_set(), GNUNET_SYSERR, GNUNET_TIME_UNIT_FOREVER_REL, GNUNET_TRANSPORT_communicator_mq_del(), GNUNET_YES, Queue::handshake_ack_monotime_get, Queue::handshake_ack_monotime_sc, Queue::handshake_monotime_get, Queue::handshake_monotime_sc, Queue::in_cipher, listen_cb(), ListenTask::listen_sock, Queue::listen_sock, ListenTask::listen_task, Queue::out_cipher, Queue::qh, Queue::read_task, Queue::rekey_monotime_get, Queue::rekey_monotime_sc, shutdown_running, Queue::sock, Queue::target, and Queue::write_task.
Referenced by get_queue_delete_it(), queue_read_kx(), queue_write(), and try_handle_plaintext().
|
static |
Compute mac over buf, and ratched the hmac_secret.
[in,out] | hmac_secret | secret for HMAC calculation |
buf | buffer to MAC | |
buf_size | number of bytes in buf | |
smac[out] | where to write the HMAC |
Definition at line 982 of file gnunet-communicator-tcp.c.
References GNUNET_CRYPTO_hash(), and GNUNET_CRYPTO_hmac_raw().
Referenced by inject_rekey(), mq_send(), queue_finish(), and try_handle_plaintext().
|
static |
Append a 'finish' message to the outgoing transmission.
Once the finish has been transmitted, destroy the queue.
queue | queue to shut down nicely |
Definition at line 1010 of file gnunet-communicator-tcp.c.
References calculate_hmac(), Queue::finishing, GNUNET_MESSAGE_TYPE_COMMUNICATOR_TCP_FINISH, GNUNET_YES, TCPFinish::header, TCPFinish::hmac, Queue::out_hmac, Queue::pwrite_buf, Queue::pwrite_off, GNUNET_MessageHeader::size, and GNUNET_MessageHeader::type.
Referenced by do_rekey(), handshake_ack_monotime_cb(), handshake_monotime_cb(), mq_destroy(), mq_error(), queue_read(), rekey_monotime_cb(), and try_handle_plaintext().
|
static |
Increment queue timeout due to activity.
We do not immediately notify the monitor here as that might generate excessive signalling.
queue | queue for which the timeout should be rescheduled |
Definition at line 1039 of file gnunet-communicator-tcp.c.
References GNUNET_CONSTANTS_IDLE_CONNECTION_TIMEOUT, GNUNET_TIME_relative_to_absolute(), queue_read(), and Queue::timeout.
Referenced by core_read_finished_cb(), queue_read(), queue_read_kx(), and queue_write().
|
static |
Queue read task.
If we hit the timeout, disconnect it
cls | the struct Queue * to disconnect |
Definition at line 1888 of file gnunet-communicator-tcp.c.
References Queue::backpressure, BUF_SIZE, Queue::cread_buf, Queue::cread_off, done(), GNUNET_assert, GNUNET_CONSTANTS_IDLE_CONNECTION_TIMEOUT, GNUNET_ERROR_TYPE_DEBUG, GNUNET_log, GNUNET_log_strerror, GNUNET_MIN, GNUNET_NETWORK_socket_recv(), GNUNET_NO, GNUNET_SCHEDULER_add_read_net(), GNUNET_STRINGS_relative_time_to_string(), GNUNET_TIME_absolute_get_remaining(), GNUNET_YES, Queue::in_cipher, max, max_queue_length, Queue::pread_buf, Queue::pread_off, queue(), queue_finish(), Queue::read_task, Queue::rekeyed, GNUNET_TIME_Relative::rel_value_us, reschedule_queue_timeout(), Queue::sock, Queue::timeout, and try_handle_plaintext().
Referenced by core_read_finished_cb(), proto_read_kx(), queue_read_kx(), and reschedule_queue_timeout().
|
static |
Core tells us it is done processing a message that transport received on a queue with status success.
Definition at line 1063 of file gnunet-communicator-tcp.c.
References Queue::backpressure, Queue::destroyed, GNUNET_ERROR_TYPE_DEBUG, GNUNET_free, GNUNET_log, GNUNET_NO, GNUNET_OK, GNUNET_SCHEDULER_add_read_net(), GNUNET_STATISTICS_update(), GNUNET_TIME_absolute_get_remaining(), GNUNET_YES, queue(), queue_read(), Queue::read_task, reschedule_queue_timeout(), Queue::sock, and Queue::timeout.
Referenced by pass_plaintext_to_core().
|
static |
We received plaintext_len bytes of plaintext on queue.
Pass it on to CORE. If transmission is actually happening, increase backpressure counter.
queue | the queue that received the plaintext |
plaintext | the plaintext that was received |
plaintext_len | number of bytes of plaintext received |
Definition at line 1110 of file gnunet-communicator-tcp.c.
References ADDRESS_VALIDITY_PERIOD, Queue::backpressure, core_read_finished_cb(), GNUNET_break, GNUNET_NO, GNUNET_OK, GNUNET_STATISTICS_update(), GNUNET_SYSERR, GNUNET_TRANSPORT_communicator_receive(), ret, GNUNET_MessageHeader::size, and Queue::target.
Referenced by try_handle_plaintext().
|
static |
Setup cipher based on shared secret dh and decrypting peer pid.
dh | shared secret |
pid | decrypting peer's identity |
cipher[out] | cipher to initialize |
hmac_key[out] | HMAC key to initialize |
Definition at line 1151 of file gnunet-communicator-tcp.c.
References GNUNET_assert, GNUNET_CRYPTO_kdf(), GNUNET_YES, and key.
Referenced by setup_in_cipher(), and setup_out_cipher().
|
static |
Callback called when peerstore store operation for rekey monotime value is finished.
cls | Queue context the store operation was executed. |
success | Store operation was successful (GNUNET_OK) or not. |
Definition at line 1205 of file gnunet-communicator-tcp.c.
References GNUNET_ERROR_TYPE_ERROR, GNUNET_log, GNUNET_OK, queue(), and Queue::rekey_monotime_sc.
Referenced by rekey_monotime_cb().
|
static |
Callback called by peerstore when records for GNUNET_PEERSTORE_TRANSPORT_TCP_COMMUNICATOR_REKEY where found.
cls | Queue context the store operation was executed. |
record | The record found or NULL if there is no record left. |
emsg | Message from peerstore. |
Definition at line 1225 of file gnunet-communicator-tcp.c.
References GNUNET_TIME_Absolute::abs_value_us, GNUNET_break, GNUNET_ERROR_TYPE_ERROR, GNUNET_i2s(), GNUNET_log, GNUNET_PEERSTORE_store(), GNUNET_PEERSTORE_STOREOPTION_REPLACE, GNUNET_PEERSTORE_TRANSPORT_TCP_COMMUNICATOR_REKEY, GNUNET_TIME_absolute_ntoh(), GNUNET_TIME_UNIT_FOREVER_ABS, pid, queue(), queue_finish(), Queue::rekey_monotime_get, Queue::rekey_monotime_sc, rekey_monotime_store_cb(), Queue::rekey_monotonic_time, Queue::target, GNUNET_PEERSTORE_Record::value, and GNUNET_PEERSTORE_Record::value_size.
Referenced by do_rekey().
|
static |
Setup cipher of queue for decryption.
ephemeral | ephemeral key we received from the other peer |
queue[in,out] | queue to initialize decryption cipher for |
Definition at line 1281 of file gnunet-communicator-tcp.c.
References GNUNET_CRYPTO_eddsa_ecdh(), Queue::in_cipher, Queue::in_hmac, my_identity, and setup_cipher().
Referenced by do_rekey(), proto_read_kx(), and queue_read_kx().
Handle rekey message on queue.
The message was already HMAC'ed, but we should additionally still check the signature. Then we need to stop the old cipher and start afresh.
queue | the queue rekey was received on |
rekey | the rekey message |
Definition at line 1300 of file gnunet-communicator-tcp.c.
References TcpRekeySignature::ephemeral, TCPRekey::ephemeral, GNUNET_assert, GNUNET_break, GNUNET_CRYPTO_eddsa_verify, GNUNET_e2s(), GNUNET_ERROR_TYPE_DEBUG, GNUNET_log, GNUNET_OK, GNUNET_p2s(), GNUNET_PEERSTORE_iterate(), GNUNET_PEERSTORE_TRANSPORT_TCP_COMMUNICATOR_REKEY, GNUNET_SIGNATURE_COMMUNICATOR_TCP_REKEY, GNUNET_STRINGS_absolute_time_to_string(), GNUNET_TIME_absolute_ntoh(), GNUNET_YES, Queue::in_cipher, TcpRekeySignature::monotonic_time, TCPRekey::monotonic_time, my_identity, GNUNET_PeerIdentity::public_key, GNUNET_CRYPTO_EccSignaturePurpose::purpose, TcpRekeySignature::purpose, TcpHandshakeSignature::purpose, queue_finish(), TcpRekeySignature::receiver, rekey_monotime_cb(), Queue::rekey_monotime_get, Queue::rekey_monotonic_time, Queue::rekeyed, TcpRekeySignature::sender, TCPRekey::sender_sig, setup_in_cipher(), GNUNET_CRYPTO_EccSignaturePurpose::size, and Queue::target.
Referenced by try_handle_plaintext().
|
static |
Callback called when peerstore store operation for handshake ack monotime value is finished.
cls | Queue context the store operation was executed. |
success | Store operation was successful (GNUNET_OK) or not. |
Definition at line 1359 of file gnunet-communicator-tcp.c.
References GNUNET_ERROR_TYPE_ERROR, GNUNET_log, GNUNET_OK, Queue::handshake_ack_monotime_sc, and queue().
Referenced by handshake_ack_monotime_cb().
|
static |
Callback called by peerstore when records for GNUNET_PEERSTORE_TRANSPORT_TCP_COMMUNICATOR_HANDSHAKE_ACK where found.
cls | Queue context the store operation was executed. |
record | The record found or NULL if there is no record left. |
emsg | Message from peerstore. |
Definition at line 1380 of file gnunet-communicator-tcp.c.
References GNUNET_TIME_Absolute::abs_value_us, GNUNET_break, GNUNET_ERROR_TYPE_ERROR, GNUNET_i2s(), GNUNET_log, GNUNET_PEERSTORE_store(), GNUNET_PEERSTORE_STOREOPTION_REPLACE, GNUNET_PEERSTORE_TRANSPORT_TCP_COMMUNICATOR_HANDSHAKE_ACK, GNUNET_TIME_absolute_ntoh(), GNUNET_TIME_UNIT_FOREVER_ABS, Queue::handshake_ack_monotime_get, Queue::handshake_ack_monotime_sc, handshake_ack_monotime_store_cb(), Queue::handshake_ack_monotonic_time, pid, queue(), queue_finish(), Queue::target, GNUNET_PEERSTORE_Record::value, and GNUNET_PEERSTORE_Record::value_size.
Referenced by try_handle_plaintext().
|
static |
Sending challenge with TcpConfirmationAck back to sender of ephemeral key.
tc | The TCPConfirmation originally send. |
queue | The queue context. |
Definition at line 1438 of file gnunet-communicator-tcp.c.
References TCPConfirmationAck::challenge, TcpHandshakeSignature::challenge, TcpHandshakeAckSignature::challenge, Queue::cwrite_buf, Queue::cwrite_off, GNUNET_assert, GNUNET_CRYPTO_eddsa_sign, GNUNET_ERROR_TYPE_DEBUG, GNUNET_log_from_nocheck(), GNUNET_MESSAGE_TYPE_COMMUNICATOR_TCP_CONFIRMATION_ACK, GNUNET_SIGNATURE_COMMUNICATOR_TCP_HANDSHAKE_ACK, GNUNET_TIME_absolute_get_monotonic(), GNUNET_TIME_absolute_hton(), TCPConfirmationAck::header, TcpHandshakeAckSignature::monotonic_time, TCPConfirmationAck::monotonic_time, my_identity, Queue::out_cipher, GNUNET_CRYPTO_EccSignaturePurpose::purpose, TcpHandshakeAckSignature::purpose, TcpHandshakeAckSignature::receiver, TCPConfirmationAck::sender, TcpHandshakeAckSignature::sender, TCPConfirmationAck::sender_sig, GNUNET_CRYPTO_EccSignaturePurpose::size, GNUNET_MessageHeader::size, Queue::target, and GNUNET_MessageHeader::type.
Referenced by queue_read_kx(), and try_handle_plaintext().
|
static |
Setup cipher for outgoing data stream based on target and our ephemeral private key.
queue | queue to setup outgoing (encryption) cipher for |
Definition at line 1484 of file gnunet-communicator-tcp.c.
References Queue::ephemeral, GNUNET_CRYPTO_ecdh_eddsa(), GNUNET_CRYPTO_QUALITY_WEAK, GNUNET_CRYPTO_random_u64(), GNUNET_TIME_relative_to_absolute(), Queue::out_cipher, Queue::out_hmac, GNUNET_PeerIdentity::public_key, rekey_interval, Queue::rekey_left_bytes, REKEY_MAX_BYTES, Queue::rekey_time, setup_cipher(), and Queue::target.
Referenced by inject_rekey(), and start_initial_kx_out().
|
static |
Inject a struct TCPRekey
message into the queue's plaintext buffer.
queue | queue to perform rekeying on |
Definition at line 1505 of file gnunet-communicator-tcp.c.
References calculate_hmac(), Queue::cwrite_buf, Queue::cwrite_off, Queue::ephemeral, TCPRekey::ephemeral, TcpRekeySignature::ephemeral, GNUNET_assert, GNUNET_CRYPTO_ecdhe_key_create(), GNUNET_CRYPTO_ecdhe_key_get_public(), GNUNET_CRYPTO_eddsa_sign, GNUNET_e2s(), GNUNET_ERROR_TYPE_DEBUG, GNUNET_log, GNUNET_MESSAGE_TYPE_COMMUNICATOR_TCP_REKEY, GNUNET_p2s(), GNUNET_SIGNATURE_COMMUNICATOR_TCP_REKEY, GNUNET_STRINGS_absolute_time_to_string(), GNUNET_TIME_absolute_get_monotonic(), GNUNET_TIME_absolute_hton(), GNUNET_TIME_absolute_ntoh(), TCPRekey::header, TCPRekey::hmac, TCPRekey::monotonic_time, TcpRekeySignature::monotonic_time, my_identity, Queue::out_cipher, Queue::out_hmac, GNUNET_PeerIdentity::public_key, GNUNET_CRYPTO_EccSignaturePurpose::purpose, TcpRekeySignature::purpose, Queue::pwrite_off, TcpRekeySignature::receiver, TcpRekeySignature::sender, TCPRekey::sender_sig, setup_out_cipher(), GNUNET_CRYPTO_EccSignaturePurpose::size, GNUNET_MessageHeader::size, Queue::target, and GNUNET_MessageHeader::type.
Referenced by queue_write().
|
static |
We have been notified that our socket is ready to write.
Then reschedule this function to be called again once more is available.
cls | a struct Queue |
Definition at line 1565 of file gnunet-communicator-tcp.c.
References BUF_SIZE, Queue::cwrite_buf, Queue::cwrite_off, Queue::finishing, GNUNET_assert, GNUNET_ERROR_TYPE_DEBUG, GNUNET_ERROR_TYPE_WARNING, GNUNET_log, GNUNET_log_strerror, GNUNET_MQ_impl_send_continue(), GNUNET_NETWORK_socket_send(), GNUNET_NO, GNUNET_SCHEDULER_add_write_net(), GNUNET_TIME_absolute_get_remaining(), GNUNET_TIME_UNIT_FOREVER_REL, GNUNET_YES, inject_rekey(), Queue::mq, Queue::mq_awaits_continue, Queue::out_cipher, Queue::pwrite_buf, Queue::pwrite_off, queue(), queue_destroy(), Queue::rekey_left_bytes, Queue::rekey_time, GNUNET_TIME_Relative::rel_value_us, reschedule_queue_timeout(), Queue::sock, and Queue::write_task.
Referenced by mq_init(), mq_send(), proto_read_kx(), queue_read_kx(), and try_handle_plaintext().
|
static |
Test if we have received a full message in plaintext.
If so, handle it.
queue | queue to process inbound plaintext for |
Definition at line 1656 of file gnunet-communicator-tcp.c.
References Queue::address, Queue::address_len, calculate_hmac(), Queue::challenge, Queue::challenge_received, COMMUNICATOR_ADDRESS_PREFIX, Queue::cs, do_rekey(), GNUNET_a2s(), GNUNET_asprintf(), GNUNET_assert, GNUNET_break, GNUNET_break_op, GNUNET_CRYPTO_eddsa_verify, GNUNET_ERROR_TYPE_DEBUG, GNUNET_ERROR_TYPE_ERROR, GNUNET_free, GNUNET_log, GNUNET_memcmp, GNUNET_MESSAGE_TYPE_COMMUNICATOR_TCP_BOX, GNUNET_MESSAGE_TYPE_COMMUNICATOR_TCP_CONFIRMATION_ACK, GNUNET_MESSAGE_TYPE_COMMUNICATOR_TCP_FINISH, GNUNET_MESSAGE_TYPE_COMMUNICATOR_TCP_REKEY, GNUNET_PEERSTORE_iterate(), GNUNET_PEERSTORE_TRANSPORT_TCP_COMMUNICATOR_HANDSHAKE_ACK, GNUNET_SCHEDULER_add_write_net(), GNUNET_SIGNATURE_COMMUNICATOR_TCP_HANDSHAKE_ACK, GNUNET_SYSERR, GNUNET_TIME_UNIT_FOREVER_REL, GNUNET_TRANSPORT_communicator_mq_add(), GNUNET_TRANSPORT_CS_INBOUND, GNUNET_TRANSPORT_QUEUE_LENGTH_UNLIMITED, handshake_ack_monotime_cb(), Queue::handshake_ack_monotime_get, TCPBox::hmac, TCPFinish::hmac, Queue::in_hmac, INITIAL_CORE_KX_SIZE, Queue::mq, my_identity, Queue::nt, pass_plaintext_to_core(), Queue::pread_buf, Queue::pread_off, Queue::qh, queue_destroy(), queue_finish(), queue_write(), send_challenge(), size, GNUNET_MessageHeader::size, Queue::sock, Queue::target, type, GNUNET_MessageHeader::type, unverified_size, and Queue::write_task.
Referenced by queue_read().
|
static |
Convert a struct sockaddr_in6 to a
struct sockaddr *`.
[out] | sock_len | set to the length of the address. |
v6 | The sockaddr_in6 to be converted. |
Definition at line 1998 of file gnunet-communicator-tcp.c.
References GNUNET_memdup.
Referenced by init_socket_resolv(), run(), tcp_address_to_sockaddr(), and tcp_address_to_sockaddr_port_only().
|
static |
Convert a struct sockaddr_in4 to a
struct sockaddr *`.
[out] | sock_len | set to the length of the address. |
v4 | The sockaddr_in4 to be converted. |
Definition at line 2025 of file gnunet-communicator-tcp.c.
References GNUNET_memdup.
Referenced by init_socket_resolv(), run(), tcp_address_to_sockaddr(), and tcp_address_to_sockaddr_port_only().
|
static |
Convert TCP bind specification to a struct PortOnlyIpv4Ipv6 *
bindto | bind specification to convert. |
Definition at line 2048 of file gnunet-communicator-tcp.c.
References PortOnlyIpv4Ipv6::addr_ipv4, PortOnlyIpv4Ipv6::addr_ipv6, PortOnlyIpv4Ipv6::addr_len_ipv4, PortOnlyIpv4Ipv6::addr_len_ipv6, COMMUNICATOR_CONFIG_SECTION, GNUNET_CONFIGURATION_get_value_yesno(), GNUNET_ERROR_TYPE_ERROR, GNUNET_free, GNUNET_log, GNUNET_malloc, GNUNET_NETWORK_test_pf(), GNUNET_new, GNUNET_NO, GNUNET_YES, tcp_address_to_sockaddr_numeric_v4(), and tcp_address_to_sockaddr_numeric_v6().
Referenced by run().
|
static |
This Method extracts the address part of the BINDTO string.
bindto | String we extract the address part from. |
Definition at line 2108 of file gnunet-communicator-tcp.c.
References GNUNET_ERROR_TYPE_DEBUG, GNUNET_ERROR_TYPE_ERROR, GNUNET_log, GNUNET_strdup, and start.
Referenced by run(), and tcp_address_to_sockaddr().
|
static |
This Method extracts the port part of the BINDTO string.
addr_and_port | String we extract the port from. |
Definition at line 2166 of file gnunet-communicator-tcp.c.
References dummy, GNUNET_ERROR_TYPE_ERROR, GNUNET_log, GNUNET_strdup, and port.
Referenced by run(), and tcp_address_to_sockaddr().
|
static |
Convert TCP bind specification to a struct sockaddr *
bindto | bind specification to convert | |
[out] | sock_len | set to the length of the address |
Definition at line 2246 of file gnunet-communicator-tcp.c.
References extract_address(), extract_port(), GNUNET_assert, GNUNET_ERROR_TYPE_DEBUG, GNUNET_log, port, start, tcp_address_to_sockaddr_numeric_v4(), and tcp_address_to_sockaddr_numeric_v6().
Referenced by mq_init().
|
static |
Signature of functions implementing the sending functionality of a message queue.
mq | the message queue |
msg | the message to send |
impl_state | our struct Queue |
Definition at line 2303 of file gnunet-communicator-tcp.c.
References calculate_hmac(), Queue::finishing, GNUNET_assert, GNUNET_ERROR_TYPE_DEBUG, GNUNET_log, GNUNET_MESSAGE_TYPE_COMMUNICATOR_TCP_BOX, GNUNET_SCHEDULER_add_write_net(), GNUNET_TIME_UNIT_FOREVER_REL, GNUNET_YES, TCPBox::header, TCPBox::hmac, Queue::mq, Queue::mq_awaits_continue, Queue::out_hmac, Queue::pwrite_buf, Queue::pwrite_off, queue(), queue_write(), GNUNET_MessageHeader::size, Queue::sock, GNUNET_MessageHeader::type, and Queue::write_task.
Referenced by boot_queue().
|
static |
Signature of functions implementing the destruction of a message queue.
Implementations must not free mq, but should take care of impl_state.
mq | the message queue to destroy |
impl_state | our struct Queue |
Definition at line 2347 of file gnunet-communicator-tcp.c.
References Queue::mq, queue(), and queue_finish().
Referenced by boot_queue().
|
static |
Implementation function that cancels the currently sent message.
mq | message queue |
impl_state | our struct Queue |
Definition at line 2366 of file gnunet-communicator-tcp.c.
References GNUNET_assert, Queue::pwrite_off, and queue().
Referenced by boot_queue().
|
static |
Generic error handler, called with the appropriate error code and the same closure specified at the creation of the message queue.
Not every message queue implementation supports an error handler.
cls | our struct Queue |
error | error code |
Definition at line 2385 of file gnunet-communicator-tcp.c.
References GNUNET_ERROR_TYPE_ERROR, GNUNET_i2s(), GNUNET_log, queue(), queue_finish(), and Queue::target.
Referenced by boot_queue().
|
static |
Add the given queue to our internal data structure.
Setup the MQ processing and inform transport that the queue is ready. Must be called after the KX for outgoing messages has been bootstrapped.
queue | queue to boot |
Definition at line 2405 of file gnunet-communicator-tcp.c.
References Queue::address, Queue::address_len, GNUNET_CONSTANTS_IDLE_CONNECTION_TIMEOUT, GNUNET_CONTAINER_MULTIHASHMAPOPTION_MULTIPLE, GNUNET_CONTAINER_multipeermap_put(), GNUNET_CONTAINER_multipeermap_size(), GNUNET_MQ_queue_for_callbacks(), GNUNET_NO, GNUNET_NT_scanner_get_type(), GNUNET_STATISTICS_set(), GNUNET_TIME_relative_to_absolute(), Queue::mq, mq_cancel(), mq_destroy(), mq_error(), mq_send(), Queue::nt, Queue::target, and Queue::timeout.
Referenced by mq_init(), and proto_read_kx().
|
static |
Generate and transmit our ephemeral key and the signature for the initial KX with the other peer.
Must be called first, before any other bytes are ever written to the output buffer. Note that our cipher must already be initialized when calling this function. Helper function for start_initial_kx_out().
queue | queue to do KX for |
epub | our public key for the KX |
Definition at line 2474 of file gnunet-communicator-tcp.c.
References Queue::challenge, TcpHandshakeSignature::challenge, TCPConfirmation::challenge, Queue::cwrite_buf, Queue::cwrite_off, TcpHandshakeSignature::ephemeral, GNUNET_assert, GNUNET_CRYPTO_eddsa_sign, GNUNET_CRYPTO_QUALITY_NONCE, GNUNET_CRYPTO_random_block(), GNUNET_ERROR_TYPE_DEBUG, GNUNET_log_from_nocheck(), GNUNET_SIGNATURE_COMMUNICATOR_TCP_HANDSHAKE, GNUNET_TIME_absolute_get_monotonic(), GNUNET_TIME_absolute_hton(), TcpHandshakeSignature::monotonic_time, TCPConfirmation::monotonic_time, my_identity, Queue::out_cipher, GNUNET_CRYPTO_EccSignaturePurpose::purpose, TcpHandshakeSignature::purpose, TcpHandshakeSignature::receiver, TCPConfirmation::sender, TcpHandshakeSignature::sender, TCPConfirmation::sender_sig, GNUNET_CRYPTO_EccSignaturePurpose::size, Queue::target, and tc.
Referenced by start_initial_kx_out().
|
static |
Initialize our key material for outgoing transmissions and inform the other peer about it.
Must be called first before any data is sent.
queue | the queue to setup |
Definition at line 2522 of file gnunet-communicator-tcp.c.
References Queue::ephemeral, GNUNET_CRYPTO_ecdhe_key_create(), GNUNET_CRYPTO_ecdhe_key_get_public(), setup_out_cipher(), and transmit_kx().
Referenced by mq_init(), and proto_read_kx().
|
static |
Callback called when peerstore store operation for handshake monotime is finished.
cls | Queue context the store operation was executed. |
success | Store operation was successful (GNUNET_OK) or not. |
Definition at line 2539 of file gnunet-communicator-tcp.c.
References GNUNET_ERROR_TYPE_ERROR, GNUNET_log, GNUNET_OK, Queue::handshake_monotime_sc, and queue().
Referenced by handshake_monotime_cb().
|
static |
Callback called by peerstore when records for GNUNET_PEERSTORE_TRANSPORT_TCP_COMMUNICATOR_HANDSHAKE where found.
cls | Queue context the store operation was executed. |
record | The record found or NULL if there is no record left. |
emsg | Message from peerstore. |
Definition at line 2559 of file gnunet-communicator-tcp.c.
References GNUNET_TIME_Absolute::abs_value_us, GNUNET_break, GNUNET_ERROR_TYPE_ERROR, GNUNET_i2s(), GNUNET_log, GNUNET_PEERSTORE_store(), GNUNET_PEERSTORE_STOREOPTION_REPLACE, GNUNET_PEERSTORE_TRANSPORT_TCP_COMMUNICATOR_HANDSHAKE, GNUNET_TIME_absolute_ntoh(), GNUNET_TIME_UNIT_FOREVER_ABS, Queue::handshake_monotime_get, Queue::handshake_monotime_sc, handshake_monotime_store_cb(), Queue::handshake_monotonic_time, pid, queue(), queue_finish(), Queue::target, GNUNET_PEERSTORE_Record::value, and GNUNET_PEERSTORE_Record::value_size.
Referenced by decrypt_and_check_tc().
|
static |
We have received the first bytes from the other side on a queue.
Decrypt the tc contained in ibuf and check the signature. Note that setup_in_cipher() must have already been called.
queue | queue to decrypt initial bytes from other peer for |
tc[out] | where to store the result |
ibuf | incoming data, of size INITIAL_KX_SIZE |
Definition at line 2622 of file gnunet-communicator-tcp.c.
References TcpHandshakeSignature::challenge, TCPConfirmation::challenge, TcpHandshakeSignature::ephemeral, GNUNET_assert, GNUNET_CRYPTO_eddsa_verify, GNUNET_PEERSTORE_iterate(), GNUNET_PEERSTORE_TRANSPORT_TCP_COMMUNICATOR_HANDSHAKE, GNUNET_SIGNATURE_COMMUNICATOR_TCP_HANDSHAKE, handshake_monotime_cb(), Queue::handshake_monotime_get, Queue::in_cipher, TCPConfirmation::monotonic_time, TcpHandshakeSignature::monotonic_time, my_identity, GNUNET_PeerIdentity::public_key, GNUNET_CRYPTO_EccSignaturePurpose::purpose, TcpHandshakeSignature::purpose, TcpHandshakeSignature::receiver, TCPConfirmation::sender, TcpHandshakeSignature::sender, TCPConfirmation::sender_sig, GNUNET_CRYPTO_EccSignaturePurpose::size, and Queue::target.
Referenced by proto_read_kx(), and queue_read_kx().
|
static |
Closes socket and frees memory associated with pq.
pq | proto queue to free |
Definition at line 2663 of file gnunet-communicator-tcp.c.
References ProtoQueue::address, GNUNET_break, GNUNET_CONTAINER_DLL_remove, GNUNET_free, GNUNET_NETWORK_socket_close(), GNUNET_OK, ProtoQueue::listen_sock, and ProtoQueue::sock.
Referenced by do_shutdown(), and proto_read_kx().
|
static |
Read from the socket of the proto queue until we have enough data to upgrade to full queue.
cls | a struct ProtoQueue |
Definition at line 2684 of file gnunet-communicator-tcp.c.
References Queue::address, ProtoQueue::address, Queue::address_len, ProtoQueue::address_len, boot_queue(), TCPConfirmation::challenge, Queue::challenge_received, Queue::cs, decrypt_and_check_tc(), free_proto_queue(), GNUNET_a2s(), GNUNET_CONSTANTS_IDLE_CONNECTION_TIMEOUT, GNUNET_CONTAINER_DLL_remove, GNUNET_ERROR_TYPE_DEBUG, GNUNET_ERROR_TYPE_INFO, GNUNET_free, GNUNET_log, GNUNET_log_strerror, GNUNET_NETWORK_socket_recv(), GNUNET_new, GNUNET_OK, GNUNET_SCHEDULER_add_read_net(), GNUNET_SCHEDULER_add_write_net(), GNUNET_TIME_absolute_get_remaining(), GNUNET_TIME_UNIT_FOREVER_REL, GNUNET_TRANSPORT_CS_INBOUND, ProtoQueue::ibuf, ProtoQueue::ibuf_off, Queue::in_cipher, Queue::listen_sock, ProtoQueue::listen_sock, queue(), queue_read(), queue_write(), Queue::read_task, ProtoQueue::read_task, GNUNET_TIME_Relative::rel_value_us, TCPConfirmation::sender, setup_in_cipher(), Queue::sock, ProtoQueue::sock, start_initial_kx_out(), Queue::target, ProtoQueue::timeout, and Queue::write_task.
Referenced by listen_cb().
|
static |
Read from the socket of the queue until we have enough data to initialize the decryption logic and can switch to regular reading.
cls | a struct Queue |
Definition at line 2833 of file gnunet-communicator-tcp.c.
References Queue::address, Queue::address_len, BUF_SIZE, TCPConfirmation::challenge, Queue::cread_buf, Queue::cread_off, decrypt_and_check_tc(), GNUNET_a2s(), GNUNET_ERROR_TYPE_DEBUG, GNUNET_ERROR_TYPE_INFO, GNUNET_ERROR_TYPE_WARNING, GNUNET_log, GNUNET_log_strerror, GNUNET_NETWORK_socket_recv(), GNUNET_OK, GNUNET_SCHEDULER_add_now(), GNUNET_SCHEDULER_add_read_net(), GNUNET_SCHEDULER_add_write_net(), GNUNET_TIME_absolute_get_remaining(), GNUNET_TIME_UNIT_FOREVER_REL, INITIAL_KX_SIZE, queue(), queue_destroy(), queue_read(), queue_write(), Queue::read_task, GNUNET_TIME_Relative::rel_value_us, reschedule_queue_timeout(), send_challenge(), TCPConfirmation::sender, setup_in_cipher(), Queue::sock, Queue::target, Queue::timeout, and Queue::write_task.
Referenced by mq_init().
|
static |
Function called by the transport service to initialize a message queue given address information about another peer.
If and when the communication channel is established, the communicator must call GNUNET_TRANSPORT_communicator_mq_add() to notify the service that the channel is now up. It is the responsibility of the communicator to manage sane retries and timeouts for any peer/address combination provided by the transport service. Timeouts and retries do not need to be signalled to the transport service.
cls | closure |
peer | identity of the other peer |
address | where to send the message, human-readable communicator-specific format, 0-terminated, UTF-8 |
Definition at line 2938 of file gnunet-communicator-tcp.c.
References Queue::address, Queue::address_len, boot_queue(), COMMUNICATOR_ADDRESS_PREFIX, Queue::cs, GNUNET_a2s(), GNUNET_break_op, GNUNET_CONSTANTS_IDLE_CONNECTION_TIMEOUT, GNUNET_ERROR_TYPE_DEBUG, GNUNET_ERROR_TYPE_ERROR, GNUNET_ERROR_TYPE_WARNING, GNUNET_free, GNUNET_log, GNUNET_NETWORK_socket_close(), GNUNET_NETWORK_socket_connect(), GNUNET_NETWORK_socket_create(), GNUNET_new, GNUNET_OK, GNUNET_SCHEDULER_add_read_net(), GNUNET_SCHEDULER_add_write_net(), GNUNET_SYSERR, GNUNET_TIME_UNIT_FOREVER_REL, GNUNET_TRANSPORT_CS_OUTBOUND, peer, queue(), queue_read_kx(), queue_write(), Queue::read_task, Queue::sock, start_initial_kx_out(), Queue::target, tcp_address_to_sockaddr(), and Queue::write_task.
Referenced by GNUNET_TRANSPORT_communicator_connect(), and init_socket().
|
static |
Iterator over all ListenTasks to clean up.
cls | NULL |
key | unused |
value | the ListenTask to cancel. |
Definition at line 3028 of file gnunet-communicator-tcp.c.
References GNUNET_break, GNUNET_NETWORK_socket_close(), GNUNET_OK, GNUNET_SCHEDULER_cancel(), ListenTask::listen_sock, ListenTask::listen_task, and value.
Referenced by do_shutdown().
|
static |
Iterator over all message queues to clean up.
cls | NULL |
target | unused |
value | the queue to destroy |
Definition at line 3059 of file gnunet-communicator-tcp.c.
References GNUNET_OK, queue(), queue_destroy(), and value.
Referenced by do_shutdown().
|
static |
Shutdown the UNIX communicator.
cls | NULL (always) |
Definition at line 3078 of file gnunet-communicator-tcp.c.
References free_proto_queue(), get_lt_delete_it(), get_queue_delete_it(), GNUNET_CONTAINER_multihashmap_iterate(), GNUNET_CONTAINER_multipeermap_destroy(), GNUNET_CONTAINER_multipeermap_iterate(), GNUNET_ERROR_TYPE_DEBUG, GNUNET_free, GNUNET_log, GNUNET_NAT_unregister(), GNUNET_NO, GNUNET_NT_scanner_done(), GNUNET_PEERSTORE_disconnect(), GNUNET_RESOLVER_request_cancel(), GNUNET_STATISTICS_destroy(), GNUNET_TRANSPORT_communicator_address_remove_all(), GNUNET_TRANSPORT_communicator_disconnect(), GNUNET_YES, and shutdown_running.
Referenced by run().
|
static |
Function called when the transport service has received an acknowledgement for this communicator (!) via a different return path.
Not applicable for TCP.
cls | closure |
sender | which peer sent the notification |
msg | payload |
Definition at line 3147 of file gnunet-communicator-tcp.c.
References GNUNET_break_op.
Referenced by init_socket().
|
static |
Signature of the callback passed to GNUNET_NAT_register() for a function to call whenever our set of 'valid' addresses changes.
cls | closure |
app_ctx[in,out] | location where the app can store stuff on add and retrieve it on remove |
add_remove | GNUNET_YES to add a new public IP address, GNUNET_NO to remove a previous (now invalid) one |
ac | address class the address belongs to |
addr | either the previous or the new public IP address |
addrlen | actual length of the addr |
Definition at line 3172 of file gnunet-communicator-tcp.c.
References ai, COMMUNICATOR_ADDRESS_PREFIX, GNUNET_a2s(), GNUNET_asprintf(), GNUNET_ERROR_TYPE_DEBUG, GNUNET_free, GNUNET_log, GNUNET_NT_scanner_get_type(), GNUNET_TIME_UNIT_FOREVER_REL, GNUNET_TRANSPORT_communicator_address_add(), GNUNET_TRANSPORT_communicator_address_remove(), GNUNET_YES, and nt.
Referenced by nat_register().
|
static |
This method adds addresses to the DLL, that are later register at the NAT service.
Definition at line 3217 of file gnunet-communicator-tcp.c.
References Addresses::addr, Addresses::addr_len, addrs_lens, GNUNET_a2s(), GNUNET_CONTAINER_DLL_insert, GNUNET_ERROR_TYPE_DEBUG, GNUNET_log, and GNUNET_new.
Referenced by init_socket().