Transport plugin using UDP. More...
#include "platform.h"
#include "gnunet_common.h"
#include "gnunet_util_lib.h"
#include "gnunet_protocols.h"
#include "gnunet_signatures.h"
#include "gnunet_constants.h"
#include "gnunet_nat_service.h"
#include "gnunet_statistics_service.h"
#include "gnunet_transport_application_service.h"
#include "gnunet_transport_communication_service.h"
Go to the source code of this file.
Data Structures | |
struct | UdpHandshakeSignature |
Signature we use to verify that the ephemeral key was really chosen by the specified sender. More... | |
struct | InitialKX |
"Plaintext" header at beginning of KX message. More... | |
struct | UDPConfirmation |
Encrypted continuation of UDP initial handshake, followed by message header with payload. More... | |
struct | UDPAck |
UDP key acknowledgement. More... | |
struct | UdpBroadcastSignature |
Signature we use to verify that the broadcast was really made by the peer that claims to have made it. More... | |
struct | UDPBroadcast |
Broadcast by peer in LAN announcing its presence. More... | |
struct | UDPBox |
UDP message box. More... | |
struct | UDPRekey |
Plaintext of a rekey payload in a UDPBox. More... | |
struct | KeyCacheEntry |
Pre-generated "kid" code (key and IV identification code) to quickly derive master key for a struct UDPBox . More... | |
struct | SharedSecret |
Shared secret we generated for a particular sender or receiver. More... | |
struct | SenderAddress |
Information we track per sender address we have recently been in contact with (we decrypt messages from the sender). More... | |
struct | ReceiverAddress |
Information we track per receiving address we have recently been in contact with (encryption to receiver). More... | |
struct | BroadcastInterface |
Interface we broadcast our presence on. More... | |
struct | SearchContext |
Closure for #find_sender_by_address() More... | |
struct | AckInfo |
Macros | |
#define | DEFAULT_REKEY_TIME_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 | BROADCAST_FREQUENCY GNUNET_TIME_UNIT_MINUTES |
How often do we broadcast our presence on the LAN? More... | |
#define | INTERFACE_SCAN_FREQUENCY GNUNET_TIME_relative_multiply (GNUNET_TIME_UNIT_MINUTES, 5) |
How often do we scan for changes to our network interfaces? More... | |
#define | ADDRESS_VALIDITY_PERIOD GNUNET_TIME_UNIT_HOURS |
How long do we believe our addresses to remain up (before the other peer should revalidate). More... | |
#define | WORKING_QUEUE_INTERVALL GNUNET_TIME_relative_multiply (GNUNET_TIME_UNIT_MICROSECONDS,1) |
#define | AES_KEY_SIZE (256 / 8) |
AES key size. More... | |
#define | AES_IV_SIZE (96 / 8) |
AES (GCM) IV size. More... | |
#define | GCM_TAG_SIZE (128 / 8) |
Size of the GCM tag. More... | |
#define | GENERATE_AT_ONCE 64 |
#define | KCN_THRESHOLD 96 |
If we fall below this number of available KCNs, we generate additional ACKs until we reach KCN_TARGET. More... | |
#define | KCN_TARGET 128 |
How many KCNs do we keep around after we hit the KCN_THRESHOLD? Should be larger than KCN_THRESHOLD so we do not generate just one ACK at the time. More... | |
#define | MAX_SQN_DELTA 160 |
What is the maximum delta between KCN sequence numbers that we allow. More... | |
#define | MAX_SECRETS 256 |
How many shared master secrets do we keep around at most per sender? Should be large enough so that we generally have a chance of sending an ACK before the sender already rotated out the master secret. More... | |
#define | DEFAULT_REKEY_MAX_BYTES (1024LLU * 1024 * 1024 * 4LLU) |
Default value for how often we do rekey based on number of bytes transmitted? (additionally randomized). More... | |
#define | COMMUNICATOR_ADDRESS_PREFIX "udp" |
Address prefix used by the communicator. More... | |
#define | COMMUNICATOR_CONFIG_SECTION "communicator-udp" |
Configuration section used by the communicator. More... | |
Functions | |
static void | eddsa_priv_to_hpke_key (struct GNUNET_CRYPTO_EddsaPrivateKey *edpk, struct GNUNET_CRYPTO_EcdhePrivateKey *pk) |
static void | eddsa_pub_to_hpke_key (struct GNUNET_CRYPTO_EddsaPublicKey *edpk, struct GNUNET_CRYPTO_EcdhePublicKey *pk) |
static void | bi_destroy (struct BroadcastInterface *bi) |
An interface went away, stop broadcasting on it. More... | |
static int | secret_destroy (struct SharedSecret *ss) |
Destroy ss and associated key cache entries. More... | |
static void | receiver_destroy (struct ReceiverAddress *receiver) |
Destroys a receiving state due to timeout or shutdown. More... | |
static void | kce_destroy (struct KeyCacheEntry *kce) |
Free memory used by key cache entry. More... | |
static void | get_kid (const struct GNUNET_ShortHashCode *msec, uint32_t serial, struct GNUNET_ShortHashCode *kid) |
Compute kid. More... | |
static void | kce_generate (struct SharedSecret *ss, uint32_t seq) |
Setup key cache entry for sequence number seq and shared secret ss. More... | |
static void | sender_destroy (struct SenderAddress *sender) |
Functions with this signature are called whenever we need to close a sender's state due to timeout. More... | |
static void | get_iv_key (const struct GNUNET_ShortHashCode *msec, uint32_t serial, char key[(256/8)], char iv[(96/8)]) |
Compute key and iv. More... | |
static void | reschedule_sender_timeout (struct SenderAddress *sender) |
Increment sender timeout due to activity. More... | |
static void | reschedule_receiver_timeout (struct ReceiverAddress *receiver) |
Increment receiver timeout due to activity. More... | |
static void | check_timeouts (void *cls) |
Task run to check #receiver_heap and #sender_heap for timeouts. More... | |
static void | calculate_cmac (struct SharedSecret *ss) |
Calculate cmac from master in ss. More... | |
static void | pass_plaintext_to_core (struct SenderAddress *sender, const void *plaintext, size_t plaintext_len) |
We received plaintext_len bytes of plaintext from a sender. More... | |
static void | setup_cipher (const struct GNUNET_ShortHashCode *msec, uint32_t serial, gcry_cipher_hd_t *cipher) |
Setup cipher based on shared secret msec and serial number serial. More... | |
static int | try_decrypt (const struct SharedSecret *ss, const uint8_t *tag, uint32_t serial, const char *in_buf, size_t in_buf_size, char *out_buf) |
Try to decrypt buf using shared secret ss and key/iv derived using serial. More... | |
static struct SharedSecret * | setup_shared_secret_dec (const struct GNUNET_CRYPTO_HpkeEncapsulation *ephemeral) |
Setup shared secret for decryption. More... | |
static struct SharedSecret * | setup_initial_shared_secret_dec (const struct GNUNET_CRYPTO_HpkeEncapsulation *c) |
Setup shared secret for decryption for initial handshake. More... | |
static struct SharedSecret * | setup_shared_secret_ephemeral (struct GNUNET_CRYPTO_HpkeEncapsulation *ephemeral, struct ReceiverAddress *receiver) |
Setup new shared secret for encryption using KEM. More... | |
static struct SharedSecret * | setup_initial_shared_secret_ephemeral (struct GNUNET_CRYPTO_HpkeEncapsulation *c, struct ReceiverAddress *receiver) |
Setup new shared secret for encryption using KEM for initial handshake. More... | |
static void | setup_receiver_mq (struct ReceiverAddress *receiver) |
Setup the MQ for the receiver. More... | |
static unsigned int | purge_secrets (struct SharedSecret *ss_list_tail) |
Best effort try to purge some secrets. More... | |
static void | add_acks (struct SharedSecret *ss, int acks_to_add) |
static int | handle_ack (void *cls, const struct GNUNET_HashCode *key, void *value) |
We received an ACK for pid. More... | |
static void | consider_ss_ack (struct SharedSecret *ss) |
We established a shared secret with a sender. More... | |
static void | kce_generate_cb (void *cls) |
static void | try_handle_plaintext (struct SenderAddress *sender, const void *buf, size_t buf_size) |
Test if we have received a valid message in plaintext. More... | |
static void | decrypt_box (const struct UDPBox *box, size_t box_len, struct KeyCacheEntry *kce) |
We received a box with matching kce. More... | |
static struct SenderAddress * | setup_sender (const struct GNUNET_PeerIdentity *target, const struct sockaddr *address, socklen_t address_len) |
Create sender address for target. More... | |
static int | verify_confirmation (const struct GNUNET_CRYPTO_HpkeEncapsulation *enc, const struct UDPConfirmation *uc) |
Check signature from uc against ephemeral. More... | |
static char * | sockaddr_to_udpaddr_string (const struct sockaddr *address, socklen_t address_len) |
Converts address to the address string format used by this communicator in HELLOs. More... | |
static struct GNUNET_NETWORK_Handle * | get_socket (struct ReceiverAddress *receiver) |
static struct sockaddr * | udp_address_to_sockaddr (const char *bindto, sa_family_t family, socklen_t *sock_len) |
Convert UDP bind specification to a struct sockaddr * More... | |
static void | sock_read (void *cls) |
Socket read task. More... | |
static enum GNUNET_GenericReturnValue | create_receiver (const struct GNUNET_PeerIdentity *peer, const char *address, struct GNUNET_NETWORK_Handle *udp_sock) |
static void | do_pad (gcry_cipher_hd_t out_cipher, char *dgram, size_t pad_size) |
Pad dgram by pad_size using out_cipher. More... | |
static void | send_msg_with_kx (const struct GNUNET_MessageHeader *msg, struct ReceiverAddress *receiver, struct GNUNET_MQ_Handle *mq) |
static void | mq_send_kx (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 | create_rekey (struct ReceiverAddress *receiver, struct SharedSecret *ss, struct UDPRekey *rekey) |
static void | mq_send_d (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_d (struct GNUNET_MQ_Handle *mq, void *impl_state) |
Signature of functions implementing the destruction of a message queue. More... | |
static void | mq_destroy_kx (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 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_receiver_delete_it (void *cls, const struct GNUNET_HashCode *target, void *value) |
Iterator over all receivers to clean up. More... | |
static int | get_sender_delete_it (void *cls, const struct GNUNET_HashCode *target, void *value) |
Iterator over all senders to clean up. More... | |
static void | do_shutdown (void *cls) |
Shutdown the UNIX communicator. More... | |
static int | handle_ack_by_sender (void *cls, const struct GNUNET_HashCode *key, void *value) |
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 a backchannel message 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 | ifc_broadcast (void *cls) |
Broadcast our presence on one of our interfaces. More... | |
static int | iface_proc (void *cls, const char *name, int isDefault, const struct sockaddr *addr, const struct sockaddr *broadcast_addr, const struct sockaddr *netmask, socklen_t addrlen) |
Callback function invoked for each interface found. More... | |
static void | do_broadcast (void *cls) |
Scan interfaces to broadcast our presence on the LAN. More... | |
static void | try_connection_reversal (void *cls, const struct sockaddr *addr, socklen_t addrlen) |
static void | udp_socket_notify (struct GNUNET_UdpSocketInfo *sock_info) |
static void | start_burst (const char *addr, struct GNUNET_TIME_Relative rtt, struct GNUNET_PeerIdentity *pid) |
static struct GNUNET_NETWORK_Handle * | create_udp_socket (const char *bindto, sa_family_t family, struct sockaddr **out, socklen_t *out_len) |
static void | shutdown_run (struct sockaddr *addrs[2]) |
static void | run (void *cls, char *const *args, const char *cfgfile, const struct GNUNET_CONFIGURATION_Handle *c) |
Variables | |
static struct GNUNET_TIME_Relative | rekey_interval |
The rekey interval. More... | |
static unsigned long long | rekey_max_bytes |
How often we do rekey based on number of bytes transmitted. More... | |
static struct GNUNET_CONTAINER_MultiShortmap * | key_cache |
Cache of pre-generated key IDs. More... | |
static struct GNUNET_SCHEDULER_Task * | read_v4_task |
ID of read IPv4 task. More... | |
static struct GNUNET_SCHEDULER_Task * | read_v6_task |
ID of read IPv6 task. More... | |
static struct GNUNET_SCHEDULER_Task * | timeout_task |
ID of timeout task. More... | |
static struct GNUNET_SCHEDULER_Task * | broadcast_task |
ID of master broadcast task. More... | |
static struct GNUNET_STATISTICS_Handle * | stats |
For logging statistics. More... | |
static struct GNUNET_TRANSPORT_CommunicatorHandle * | ch |
Our environment. More... | |
static struct GNUNET_CONTAINER_MultiHashMap * | receivers |
Receivers (map from peer identity to struct ReceiverAddress ) More... | |
static struct GNUNET_CONTAINER_MultiHashMap * | senders |
Senders (map from peer identity to struct SenderAddress ) More... | |
static struct GNUNET_CONTAINER_Heap * | senders_heap |
Expiration heap for senders (contains struct SenderAddress ) More... | |
static struct GNUNET_CONTAINER_Heap * | receivers_heap |
Expiration heap for receivers (contains struct ReceiverAddress ) More... | |
static struct BroadcastInterface * | bi_head |
Broadcast interface tasks. More... | |
static struct BroadcastInterface * | bi_tail |
Broadcast interface tasks. More... | |
static struct GNUNET_NETWORK_Handle * | default_v4_sock |
Our IPv4 socket. More... | |
static struct GNUNET_NETWORK_Handle * | default_v6_sock |
Our IPv6 socket. More... | |
static struct GNUNET_PeerIdentity | my_identity |
Our public key. More... | |
static struct GNUNET_CRYPTO_EddsaPrivateKey * | my_private_key |
Our private key. More... | |
static struct GNUNET_CRYPTO_EcdhePrivateKey | my_x25519_private_key |
Our private key for HPKE. More... | |
static const struct GNUNET_CONFIGURATION_Handle * | cfg |
Our configuration. More... | |
static struct GNUNET_TRANSPORT_ApplicationHandle * | ah |
Our handle to report addresses for validation to TRANSPORT. 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 uint16_t | my_port |
Port number to which we are actually bound. More... | |
char * | my_ipv4 |
Our ipv4 address. More... | |
static int | disable_v6 |
IPv6 disabled or not. More... | |
static struct GNUNET_SCHEDULER_Task * | burst_task |
Transport plugin using UDP.
TODO:
Definition in file gnunet-communicator-udp.c.
#define DEFAULT_REKEY_TIME_INTERVAL GNUNET_TIME_UNIT_DAYS |
How often do we rekey based on time (at least)
Definition at line 54 of file gnunet-communicator-udp.c.
#define PROTO_QUEUE_TIMEOUT GNUNET_TIME_UNIT_MINUTES |
How long do we wait until we must have received the initial KX?
Definition at line 59 of file gnunet-communicator-udp.c.
#define BROADCAST_FREQUENCY GNUNET_TIME_UNIT_MINUTES |
How often do we broadcast our presence on the LAN?
Definition at line 64 of file gnunet-communicator-udp.c.
#define INTERFACE_SCAN_FREQUENCY GNUNET_TIME_relative_multiply (GNUNET_TIME_UNIT_MINUTES, 5) |
How often do we scan for changes to our network interfaces?
Definition at line 69 of file gnunet-communicator-udp.c.
#define ADDRESS_VALIDITY_PERIOD GNUNET_TIME_UNIT_HOURS |
How long do we believe our addresses to remain up (before the other peer should revalidate).
Definition at line 76 of file gnunet-communicator-udp.c.
#define WORKING_QUEUE_INTERVALL GNUNET_TIME_relative_multiply (GNUNET_TIME_UNIT_MICROSECONDS,1) |
Definition at line 78 of file gnunet-communicator-udp.c.
#define AES_KEY_SIZE (256 / 8) |
AES key size.
Definition at line 84 of file gnunet-communicator-udp.c.
#define AES_IV_SIZE (96 / 8) |
AES (GCM) IV size.
Definition at line 89 of file gnunet-communicator-udp.c.
#define GCM_TAG_SIZE (128 / 8) |
Size of the GCM tag.
Definition at line 94 of file gnunet-communicator-udp.c.
#define GENERATE_AT_ONCE 64 |
Definition at line 96 of file gnunet-communicator-udp.c.
#define KCN_THRESHOLD 96 |
If we fall below this number of available KCNs, we generate additional ACKs until we reach KCN_TARGET.
Should be large enough that we don't generate ACKs all the time and still have enough time for the ACK to arrive before the sender runs out. So really this should ideally be based on the RTT.
Definition at line 107 of file gnunet-communicator-udp.c.
#define KCN_TARGET 128 |
How many KCNs do we keep around after we hit the KCN_THRESHOLD? Should be larger than KCN_THRESHOLD so we do not generate just one ACK at the time.
Definition at line 115 of file gnunet-communicator-udp.c.
#define MAX_SQN_DELTA 160 |
What is the maximum delta between KCN sequence numbers that we allow.
Used to expire 'ancient' KCNs that likely were dropped by the network. Must be larger than KCN_TARGET (otherwise we generate new KCNs all the time), but not too large (otherwise packet loss may cause sender to fall back to KX needlessly when sender runs out of ACK'ed KCNs due to losses).
Definition at line 126 of file gnunet-communicator-udp.c.
#define MAX_SECRETS 256 |
How many shared master secrets do we keep around at most per sender? Should be large enough so that we generally have a chance of sending an ACK before the sender already rotated out the master secret.
Generally values around KCN_TARGET make sense. Might make sense to adapt to RTT if we had a good measurement...
Definition at line 137 of file gnunet-communicator-udp.c.
#define DEFAULT_REKEY_MAX_BYTES (1024LLU * 1024 * 1024 * 4LLU) |
Default value for how often we do rekey based on number of bytes transmitted? (additionally randomized).
Definition at line 143 of file gnunet-communicator-udp.c.
#define COMMUNICATOR_ADDRESS_PREFIX "udp" |
Address prefix used by the communicator.
Definition at line 149 of file gnunet-communicator-udp.c.
#define COMMUNICATOR_CONFIG_SECTION "communicator-udp" |
Configuration section used by the communicator.
Definition at line 154 of file gnunet-communicator-udp.c.
|
static |
Definition at line 893 of file gnunet-communicator-udp.c.
References GNUNET_CRYPTO_hpke_sk_to_x25519(), GNUNET_PUBLIC_KEY_TYPE_EDDSA, key, and pk.
Referenced by run().
|
static |
Definition at line 904 of file gnunet-communicator-udp.c.
References GNUNET_CRYPTO_hpke_pk_to_x25519(), GNUNET_PUBLIC_KEY_TYPE_EDDSA, key, and pk.
Referenced by create_receiver().
|
static |
An interface went away, stop broadcasting on it.
bi | entity to close down |
Definition at line 920 of file gnunet-communicator-udp.c.
References BroadcastInterface::ba, bi_head, bi_tail, BroadcastInterface::broadcast_task, default_v6_sock, GNUNET_CONTAINER_DLL_remove, GNUNET_ERROR_TYPE_WARNING, GNUNET_free, GNUNET_log_strerror, GNUNET_NETWORK_socket_setsockopt(), GNUNET_OK, GNUNET_SCHEDULER_cancel(), BroadcastInterface::mcreq, and BroadcastInterface::sa.
Referenced by do_broadcast(), and do_shutdown().
|
static |
Destroy ss and associated key cache entries.
ss | shared secret to destroy |
withoutKce | If GNUNET_YES shared secrets with kce will not be destroyed. |
Definition at line 1085 of file gnunet-communicator-udp.c.
References SenderAddress::acks_available, GNUNET_CONTAINER_DLL_remove, GNUNET_CONTAINER_multishortmap_size(), GNUNET_ERROR_TYPE_DEBUG, GNUNET_free, GNUNET_log, GNUNET_NO, GNUNET_SCHEDULER_cancel(), GNUNET_sh2s(), GNUNET_STATISTICS_set(), GNUNET_STATISTICS_update(), GNUNET_YES, kce_destroy(), SharedSecret::kce_head, SenderAddress::kce_task, key_cache, SharedSecret::master, SenderAddress::num_secrets, receiver(), SharedSecret::receiver, SharedSecret::sender, SharedSecret::sequence_allowed, SharedSecret::sequence_used, KeyCacheEntry::ss, SenderAddress::ss_head, SenderAddress::ss_tail, and stats.
Referenced by decrypt_box(), mq_send_d(), purge_secrets(), receiver_destroy(), send_msg_with_kx(), sender_destroy(), sock_read(), and try_handle_plaintext().
|
static |
Destroys a receiving state due to timeout or shutdown.
receiver | entity to close down |
Definition at line 951 of file gnunet-communicator-udp.c.
References GNUNET_assert, GNUNET_break, GNUNET_CONTAINER_heap_remove_node(), GNUNET_CONTAINER_multihashmap_remove(), GNUNET_CONTAINER_multihashmap_size(), GNUNET_ERROR_TYPE_DEBUG, GNUNET_free, GNUNET_i2s(), GNUNET_log, GNUNET_MQ_destroy(), GNUNET_NETWORK_socket_close(), GNUNET_NO, GNUNET_OK, GNUNET_STATISTICS_set(), GNUNET_TRANSPORT_communicator_mq_del(), GNUNET_YES, receiver(), receivers, secret_destroy(), and stats.
Referenced by check_timeouts(), get_receiver_delete_it(), mq_destroy_d(), mq_destroy_kx(), mq_error(), mq_send_d(), and send_msg_with_kx().
|
static |
Free memory used by key cache entry.
kce | the key cache entry |
Definition at line 1006 of file gnunet-communicator-udp.c.
References SharedSecret::active_kce_count, GNUNET_assert, GNUNET_CONTAINER_DLL_remove, GNUNET_CONTAINER_multishortmap_remove(), GNUNET_free, GNUNET_YES, SharedSecret::kce_head, SharedSecret::kce_tail, key_cache, KeyCacheEntry::kid, and KeyCacheEntry::ss.
Referenced by consider_ss_ack(), decrypt_box(), and secret_destroy().
|
static |
Compute kid.
msec | master secret for HMAC calculation | |
serial | number for the smac calculation | |
[out] | kid | where to write the key ID |
Definition at line 1027 of file gnunet-communicator-udp.c.
References GNUNET_CRYPTO_hkdf_expand(), and GNUNET_CRYPTO_hkdf_extract().
Referenced by kce_generate(), and mq_send_d().
|
static |
Setup key cache entry for sequence number seq and shared secret ss.
ss | shared secret |
seq | sequence number for the key cache entry |
Definition at line 1054 of file gnunet-communicator-udp.c.
References SenderAddress::acks_available, SharedSecret::active_kce_count, get_kid(), GNUNET_assert, GNUNET_CONTAINER_DLL_insert, GNUNET_CONTAINER_MULTIHASHMAPOPTION_MULTIPLE, GNUNET_CONTAINER_multishortmap_put(), GNUNET_CONTAINER_multishortmap_size(), GNUNET_new, GNUNET_NO, GNUNET_STATISTICS_set(), SharedSecret::kce_head, SharedSecret::kce_tail, key_cache, KeyCacheEntry::kid, SharedSecret::master, SharedSecret::sender, KeyCacheEntry::sequence_number, KeyCacheEntry::ss, and stats.
Referenced by kce_generate_cb().
|
static |
Functions with this signature are called whenever we need to close a sender's state due to timeout.
sender | entity to close down |
Definition at line 1138 of file gnunet-communicator-udp.c.
References SenderAddress::address, GNUNET_assert, GNUNET_CONTAINER_heap_remove_node(), GNUNET_CONTAINER_multihashmap_remove(), GNUNET_CONTAINER_multihashmap_size(), GNUNET_free, GNUNET_NO, GNUNET_STATISTICS_set(), GNUNET_YES, SenderAddress::hn, SenderAddress::key, secret_destroy(), SharedSecret::sender, SenderAddress::sender_destroy_called, senders, SenderAddress::ss_head, and stats.
Referenced by check_timeouts(), and get_sender_delete_it().
|
static |
Compute key and iv.
msec | master secret for calculation | |
serial | number for the smac calculation | |
[out] | key | where to write the decryption key |
[out] | iv | where to write the IV |
Definition at line 1168 of file gnunet-communicator-udp.c.
References AES_IV_SIZE, AES_KEY_SIZE, GNUNET_CRYPTO_hkdf_expand(), and key.
Referenced by setup_cipher().
|
static |
Increment sender timeout due to activity.
sender | address for which the timeout should be rescheduled |
Definition at line 1200 of file gnunet-communicator-udp.c.
References GNUNET_TIME_Absolute::abs_value_us, GNUNET_CONSTANTS_IDLE_CONNECTION_TIMEOUT, GNUNET_CONTAINER_heap_update_cost(), GNUNET_TIME_relative_to_absolute(), SenderAddress::hn, SharedSecret::sender, and SenderAddress::timeout.
Referenced by setup_sender().
|
static |
Increment receiver timeout due to activity.
receiver | address for which the timeout should be rescheduled |
Definition at line 1214 of file gnunet-communicator-udp.c.
References GNUNET_CONSTANTS_IDLE_CONNECTION_TIMEOUT, GNUNET_CONTAINER_heap_update_cost(), GNUNET_TIME_relative_to_absolute(), and receiver().
Referenced by mq_send_d(), and send_msg_with_kx().
|
static |
Task run to check #receiver_heap and #sender_heap for timeouts.
cls | unused, NULL |
Definition at line 1229 of file gnunet-communicator-udp.c.
References check_timeouts(), GNUNET_CONTAINER_heap_peek(), GNUNET_ERROR_TYPE_DEBUG, GNUNET_log, GNUNET_SCHEDULER_add_delayed(), GNUNET_TIME_absolute_get_remaining(), GNUNET_TIME_relative_min(), GNUNET_TIME_UNIT_FOREVER_REL, GNUNET_YES, receiver(), receiver_destroy(), receivers_heap, GNUNET_TIME_Relative::rel_value_us, sender_destroy(), SenderAddress::sender_destroy_called, senders_heap, st, SenderAddress::timeout, and timeout_task.
Referenced by check_timeouts(), create_receiver(), and setup_sender().
|
static |
Calculate cmac from master in ss.
[in,out] | ss | data structure to complete |
Definition at line 1272 of file gnunet-communicator-udp.c.
References SharedSecret::cmac, GNUNET_CRYPTO_hkdf_expand(), and SharedSecret::master.
Referenced by setup_initial_shared_secret_dec(), setup_initial_shared_secret_ephemeral(), setup_shared_secret_dec(), setup_shared_secret_ephemeral(), and sock_read().
|
static |
We received plaintext_len bytes of plaintext from a sender.
Pass it on to CORE.
queue | the queue that received the plaintext |
plaintext | the plaintext that was received |
plaintext_len | number of bytes of plaintext received |
Definition at line 1293 of file gnunet-communicator-udp.c.
References ADDRESS_VALIDITY_PERIOD, ch, GNUNET_assert, GNUNET_ERROR_TYPE_DEBUG, GNUNET_log, GNUNET_NO, GNUNET_STATISTICS_update(), GNUNET_SYSERR, GNUNET_TRANSPORT_communicator_receive(), GNUNET_MessageHeader::size, stats, and SenderAddress::target.
Referenced by try_handle_plaintext().
|
static |
Setup cipher based on shared secret msec and serial number serial.
msec | master shared secret |
serial | serial number of cipher to set up |
cipher[out] | cipher to initialize |
Definition at line 1342 of file gnunet-communicator-udp.c.
References AES_IV_SIZE, AES_KEY_SIZE, get_iv_key(), GNUNET_assert, and key.
Referenced by mq_send_d(), send_msg_with_kx(), and try_decrypt().
|
static |
Try to decrypt buf using shared secret ss and key/iv derived using serial.
ss | shared secret |
tag | GCM authentication tag |
serial | serial number to use |
in_buf | input buffer to decrypt |
in_buf_size | number of bytes in in_buf and available in out_buf |
out_buf | where to write the result |
Definition at line 1377 of file gnunet-communicator-udp.c.
References GCM_TAG_SIZE, GNUNET_assert, GNUNET_NO, GNUNET_OK, GNUNET_STATISTICS_update(), GNUNET_SYSERR, SharedSecret::master, setup_cipher(), and stats.
Referenced by decrypt_box(), and sock_read().
|
static |
Setup shared secret for decryption.
ephemeral | ephemeral key we received from the other peer |
Definition at line 1411 of file gnunet-communicator-udp.c.
References calculate_cmac(), GNUNET_CRYPTO_eddsa_kem_decaps(), GNUNET_new, SharedSecret::master, and my_private_key.
Referenced by try_handle_plaintext().
|
static |
Setup shared secret for decryption for initial handshake.
representative | of ephemeral key we received from the other peer |
Definition at line 1430 of file gnunet-communicator-udp.c.
References calculate_cmac(), GNUNET_CRYPTO_hpke_elligator_kem_decaps(), GNUNET_ERROR_TYPE_DEBUG, GNUNET_log, GNUNET_new, GNUNET_sh2s(), SharedSecret::master, and my_x25519_private_key.
Referenced by sock_read().
|
static |
Setup new shared secret for encryption using KEM.
[out] | ephemeral | ephemeral key to be sent to other peer (encapsulated key from KEM) |
[in,out] | receiver | queue to initialize encryption key for |
Definition at line 1453 of file gnunet-communicator-udp.c.
References calculate_cmac(), GNUNET_CONTAINER_DLL_insert, GNUNET_CRYPTO_eddsa_kem_encaps(), GNUNET_new, GNUNET_NO, GNUNET_STATISTICS_update(), SharedSecret::master, receiver(), SharedSecret::receiver, and stats.
Referenced by create_rekey().
|
static |
Setup new shared secret for encryption using KEM for initial handshake.
[out] | representative | of ephemeral key to be sent to other peer (encapsulated key from KEM) |
[in,out] | receiver | queue to initialize encryption key for |
Definition at line 1479 of file gnunet-communicator-udp.c.
References calculate_cmac(), GNUNET_CONTAINER_DLL_insert, GNUNET_CRYPTO_hpke_elligator_kem_encaps(), GNUNET_ERROR_TYPE_DEBUG, GNUNET_log, GNUNET_new, GNUNET_NO, GNUNET_sh2s(), GNUNET_STATISTICS_update(), SharedSecret::master, receiver(), SharedSecret::receiver, and stats.
Referenced by send_msg_with_kx().
|
static |
Setup the MQ for the receiver.
If a queue exists, the existing one is destroyed. Then the MTU is recalculated and a fresh queue is initialized.
receiver | receiver to setup MQ for |
Definition at line 2999 of file gnunet-communicator-udp.c.
References ch, GNUNET_assert, GNUNET_ERROR_TYPE_DEBUG, GNUNET_log, GNUNET_MQ_queue_for_callbacks(), GNUNET_TRANSPORT_communicator_mq_add(), GNUNET_TRANSPORT_CS_OUTBOUND, GNUNET_TRANSPORT_QUEUE_LENGTH_UNLIMITED, mq_cancel(), mq_destroy_d(), mq_destroy_kx(), mq_error(), mq_send_d(), mq_send_kx(), and receiver().
Referenced by create_receiver().
|
static |
Best effort try to purge some secrets.
Ideally those, not ACKed.
ss_list_tail | the oldest secret in the list of interest. |
Definition at line 1518 of file gnunet-communicator-udp.c.
References SharedSecret::bytes_sent, GNUNET_ERROR_TYPE_DEBUG, GNUNET_log, SharedSecret::prev, and secret_destroy().
Referenced by mq_send_d(), send_msg_with_kx(), sock_read(), and try_handle_plaintext().
|
static |
Definition at line 1546 of file gnunet-communicator-udp.c.
References ch, GNUNET_assert, GNUNET_ERROR_TYPE_DEBUG, GNUNET_log, GNUNET_TRANSPORT_communicator_mq_add(), GNUNET_TRANSPORT_communicator_mq_update(), GNUNET_TRANSPORT_CS_OUTBOUND, receiver(), and SharedSecret::receiver.
Referenced by handle_ack().
|
static |
We received an ACK for pid.
Check if it is for the receiver in value and if so, handle it and return GNUNET_NO. Otherwise, return GNUNET_YES.
cls | a const struct UDPAck |
pid | peer the ACK is from |
value | a struct ReceiverAddress |
Definition at line 1599 of file gnunet-communicator-udp.c.
References add_acks(), UDPAck::cmac, GNUNET_assert, GNUNET_ERROR_TYPE_DEBUG, GNUNET_h2s(), GNUNET_log, GNUNET_NO, GNUNET_sh2s(), GNUNET_YES, key, receiver(), UDPAck::sequence_ack, and value.
Referenced by handle_ack_by_sender(), and try_handle_plaintext().
|
static |
We established a shared secret with a sender.
We should try to send the sender an struct UDPAck
at the next opportunity to allow the sender to use ss longer (assuming we did not yet already recently).
ss | shared secret to generate ACKs for |
Definition at line 1656 of file gnunet-communicator-udp.c.
References SenderAddress::acks_available, ch, UDPAck::cmac, SharedSecret::cmac, COMMUNICATOR_ADDRESS_PREFIX, GNUNET_assert, GNUNET_ERROR_TYPE_DEBUG, GNUNET_i2s_full(), GNUNET_log, GNUNET_MESSAGE_TYPE_COMMUNICATOR_UDP_ACK, GNUNET_sh2s(), GNUNET_TRANSPORT_communicator_notify(), UDPAck::header, kce_destroy(), SharedSecret::kce_head, SharedSecret::kce_tail, SharedSecret::master, MAX_SQN_DELTA, SharedSecret::sender, UDPAck::sequence_ack, SharedSecret::sequence_allowed, KeyCacheEntry::sequence_number, GNUNET_MessageHeader::size, SenderAddress::target, and GNUNET_MessageHeader::type.
Referenced by kce_generate_cb().
|
static |
As long as we loose over 30% of max acks in reschedule, We keep generating acks for this ss.
Definition at line 1691 of file gnunet-communicator-udp.c.
References SenderAddress::acks_available, consider_ss_ack(), GENERATE_AT_ONCE, GNUNET_ERROR_TYPE_DEBUG, GNUNET_log, GNUNET_NO, GNUNET_SCHEDULER_add_delayed(), GNUNET_sh2s(), GNUNET_YES, kce_generate(), kce_generate_cb(), SenderAddress::kce_send_ack_on_finish, SenderAddress::kce_task, SenderAddress::kce_task_finished, KCN_TARGET, SharedSecret::master, SharedSecret::override_available_acks, SharedSecret::sender, SharedSecret::sequence_allowed, and WORKING_QUEUE_INTERVALL.
Referenced by decrypt_box(), kce_generate_cb(), sock_read(), and try_handle_plaintext().
|
static |
Test if we have received a valid message in plaintext.
If so, handle it.
sender | peer to process inbound plaintext for |
buf | buffer we received |
buf_size | number of bytes in buf |
Definition at line 1736 of file gnunet-communicator-udp.c.
References SenderAddress::acks_available, SharedSecret::cmac, UDPRekey::ephemeral, GNUNET_CONTAINER_DLL_insert, GNUNET_CONTAINER_multihashmap_get_multiple(), GNUNET_ERROR_TYPE_DEBUG, GNUNET_h2s(), GNUNET_log, GNUNET_MESSAGE_TYPE_COMMUNICATOR_UDP_ACK, GNUNET_MESSAGE_TYPE_COMMUNICATOR_UDP_PAD, GNUNET_MESSAGE_TYPE_COMMUNICATOR_UDP_REKEY, GNUNET_NO, GNUNET_sh2s(), GNUNET_STATISTICS_update(), GNUNET_YES, handle_ack(), kce_generate_cb(), SenderAddress::kce_send_ack_on_finish, SenderAddress::key, SharedSecret::master, MAX_SECRETS, SenderAddress::num_secrets, SharedSecret::override_available_acks, pass_plaintext_to_core(), purge_secrets(), receivers, secret_destroy(), SharedSecret::sender, SharedSecret::sequence_allowed, setup_shared_secret_dec(), GNUNET_MessageHeader::size, SenderAddress::ss_head, SenderAddress::ss_tail, stats, type, and GNUNET_MessageHeader::type.
Referenced by decrypt_box(), and sock_read().
|
static |
We received a box with matching kce.
Decrypt and process it.
box | the data we received |
box_len | number of bytes in box |
kce | key index to decrypt box |
Definition at line 1843 of file gnunet-communicator-udp.c.
References SenderAddress::acks_available, SharedSecret::bytes_sent, UDPBox::gcm_tag, GNUNET_assert, GNUNET_ERROR_TYPE_DEBUG, GNUNET_log, GNUNET_NO, GNUNET_OK, GNUNET_SCHEDULER_add_now(), GNUNET_sh2s(), GNUNET_STATISTICS_update(), GNUNET_YES, kce_destroy(), kce_generate_cb(), SenderAddress::kce_send_ack_on_finish, SenderAddress::kce_task, SenderAddress::kce_task_finished, KCN_THRESHOLD, UDPBox::kid, SharedSecret::prev, rekey_max_bytes, secret_destroy(), SharedSecret::sender, KeyCacheEntry::sequence_number, SharedSecret::sequence_used, KeyCacheEntry::ss, SenderAddress::ss_tail, stats, try_decrypt(), and try_handle_plaintext().
Referenced by sock_read().
|
static |
Create sender address for target.
Note that we might already have one, so a fresh one is only allocated if one does not yet exist for address.
target | peer to generate address for |
address | target address |
address_len | number of bytes in address |
Definition at line 1957 of file gnunet-communicator-udp.c.
References GNUNET_TIME_Absolute::abs_value_us, address, SenderAddress::address, SenderAddress::address_len, check_timeouts(), GNUNET_CONSTANTS_IDLE_CONNECTION_TIMEOUT, GNUNET_CONTAINER_heap_insert(), GNUNET_CONTAINER_multihashmap_get(), GNUNET_CONTAINER_multihashmap_put(), GNUNET_CONTAINER_multihashmap_size(), GNUNET_CONTAINER_MULTIHASHMAPOPTION_MULTIPLE, GNUNET_CRYPTO_hash_context_finish(), GNUNET_CRYPTO_hash_context_read(), GNUNET_CRYPTO_hash_context_start(), GNUNET_memdup, GNUNET_new, GNUNET_NO, GNUNET_NT_scanner_get_type(), GNUNET_SCHEDULER_add_now(), GNUNET_STATISTICS_set(), GNUNET_TIME_relative_to_absolute(), SenderAddress::hn, is, SenderAddress::key, SenderAddress::nt, receivers, reschedule_sender_timeout(), senders, senders_heap, stats, SenderAddress::target, SenderAddress::timeout, and timeout_task.
Referenced by sock_read().
|
static |
Check signature from uc against ephemeral.
ephemeral | key that is signed |
uc | signature of claimant |
Definition at line 2010 of file gnunet-communicator-udp.c.
References enc, UdpHandshakeSignature::enc, GNUNET_CRYPTO_eddsa_verify, GNUNET_SIGNATURE_PURPOSE_COMMUNICATOR_UDP_HANDSHAKE, UdpHandshakeSignature::monotonic_time, my_identity, GNUNET_CRYPTO_EccSignaturePurpose::purpose, UdpHandshakeSignature::purpose, UdpHandshakeSignature::receiver, UdpHandshakeSignature::sender, GNUNET_CRYPTO_EccSignaturePurpose::size, and uc.
Referenced by sock_read().
|
static |
Converts address to the address string format used by this communicator in HELLOs.
address | the address to convert, must be AF_INET or AF_INET6. |
address_len | number of bytes in address |
Definition at line 2039 of file gnunet-communicator-udp.c.
References address, COMMUNICATOR_ADDRESS_PREFIX, GNUNET_a2s(), GNUNET_asprintf(), GNUNET_assert, and ret.
Referenced by create_receiver(), sock_read(), and udp_socket_notify().
|
static |
Definition at line 2068 of file gnunet-communicator-udp.c.
References default_v4_sock, default_v6_sock, receiver(), and udp_sock.
Referenced by mq_send_d(), and send_msg_with_kx().
|
static |
Convert UDP bind specification to a struct sockaddr *
bindto | bind specification to convert | |
family | address family to enforce | |
[out] | sock_len | set to the length of the address |
Definition at line 2095 of file gnunet-communicator-udp.c.
References disable_v6, dummy, GNUNET_ERROR_TYPE_ERROR, GNUNET_free, GNUNET_log, GNUNET_malloc, GNUNET_memdup, GNUNET_strdup, GNUNET_YES, port, and start.
Referenced by create_receiver(), and create_udp_socket().
|
static |
Socket read task.
cls | NULL |
Definition at line 2335 of file gnunet-communicator-udp.c.
References SenderAddress::acks_available, address, ah, calculate_cmac(), ch, create_receiver(), decrypt_box(), default_v4_sock, default_v6_sock, InitialKX::enc, InitialKX::gcm_tag, GNUNET_a2s(), GNUNET_assert, GNUNET_break_op, GNUNET_CONTAINER_DLL_insert, GNUNET_CONTAINER_multishortmap_get(), GNUNET_CRYPTO_eddsa_verify, GNUNET_CRYPTO_hash(), GNUNET_ERROR_TYPE_DEBUG, GNUNET_ERROR_TYPE_ERROR, GNUNET_ERROR_TYPE_WARNING, GNUNET_free, GNUNET_i2s(), GNUNET_log, GNUNET_log_strerror, GNUNET_memdup, GNUNET_NETWORK_socket_recvfrom(), GNUNET_NO, GNUNET_NT_scanner_get_type(), GNUNET_OK, GNUNET_SCHEDULER_add_now(), GNUNET_SCHEDULER_add_read_net(), GNUNET_sh2s(), GNUNET_SIGNATURE_PURPOSE_COMMUNICATOR_UDP_BROADCAST, GNUNET_STATISTICS_update(), GNUNET_stop_burst(), GNUNET_TIME_UNIT_FOREVER_REL, GNUNET_TRANSPORT_application_validate(), GNUNET_TRANSPORT_communicator_burst_finished(), GNUNET_YES, UdpBroadcastSignature::h_address, is, kce_generate_cb(), SenderAddress::kce_send_ack_on_finish, SenderAddress::kce_task, SenderAddress::kce_task_finished, KCN_THRESHOLD, key_cache, UDPBox::kid, GNUNET_BurstMessage::local_port, MAX_SECRETS, my_identity, nt, GNUNET_BurstMessage::peer, GNUNET_PeerIdentity::public_key, purge_secrets(), GNUNET_CRYPTO_EccSignaturePurpose::purpose, UdpBroadcastSignature::purpose, read_v4_task, read_v6_task, secret_destroy(), UDPConfirmation::sender, UdpBroadcastSignature::sender, UDPBroadcast::sender, SharedSecret::sender, UDPBroadcast::sender_sig, setup_initial_shared_secret_dec(), setup_sender(), GNUNET_CRYPTO_EccSignaturePurpose::size, sock_read(), sockaddr_to_udpaddr_string(), stats, try_decrypt(), try_handle_plaintext(), uc, udp_sock, and verify_confirmation().
Referenced by create_receiver(), run(), and sock_read().
|
static |
Definition at line 2227 of file gnunet-communicator-udp.c.
References address, check_timeouts(), COMMUNICATOR_ADDRESS_PREFIX, disable_v6, eddsa_pub_to_hpke_key(), GNUNET_break_op, GNUNET_CONSTANTS_IDLE_CONNECTION_TIMEOUT, GNUNET_CONTAINER_heap_insert(), GNUNET_CONTAINER_multihashmap_get(), GNUNET_CONTAINER_multihashmap_put(), GNUNET_CONTAINER_multihashmap_size(), GNUNET_CONTAINER_MULTIHASHMAPOPTION_MULTIPLE, GNUNET_CRYPTO_hash_context_finish(), GNUNET_CRYPTO_hash_context_read(), GNUNET_CRYPTO_hash_context_start(), GNUNET_ERROR_TYPE_DEBUG, GNUNET_ERROR_TYPE_ERROR, GNUNET_free, GNUNET_i2s_full(), GNUNET_log, GNUNET_new, GNUNET_NO, GNUNET_NT_scanner_get_type(), GNUNET_OK, GNUNET_SCHEDULER_add_now(), GNUNET_SCHEDULER_add_read_net(), GNUNET_STATISTICS_set(), GNUNET_SYSERR, GNUNET_TIME_relative_to_absolute(), GNUNET_TIME_UNIT_FOREVER_REL, GNUNET_YES, is, receiver(), receivers, receivers_heap, setup_receiver_mq(), sock_read(), sockaddr_to_udpaddr_string(), stats, timeout_task, udp_address_to_sockaddr(), and udp_sock.
Referenced by mq_init(), sock_read(), and udp_socket_notify().
|
static |
Pad dgram by pad_size using out_cipher.
out_cipher | cipher to use |
dgram | datagram to pad |
pad_size | number of bytes of padding to append |
Definition at line 2596 of file gnunet-communicator-udp.c.
References GNUNET_assert, GNUNET_CRYPTO_QUALITY_WEAK, GNUNET_CRYPTO_random_block(), GNUNET_MESSAGE_TYPE_COMMUNICATOR_UDP_PAD, and GNUNET_MessageHeader::size.
Referenced by mq_send_d(), and send_msg_with_kx().
|
static |
Definition at line 2616 of file gnunet-communicator-udp.c.
References cfg, do_pad(), UdpHandshakeSignature::enc, InitialKX::enc, InitialKX::gcm_tag, get_socket(), GNUNET_a2s(), GNUNET_assert, GNUNET_break, GNUNET_CRYPTO_eddsa_sign, GNUNET_ERROR_TYPE_DEBUG, GNUNET_ERROR_TYPE_ERROR, GNUNET_ERROR_TYPE_WARNING, GNUNET_log, GNUNET_log_strerror, GNUNET_MQ_impl_send_continue(), GNUNET_NETWORK_socket_sendto(), GNUNET_SIGNATURE_PURPOSE_COMMUNICATOR_UDP_HANDSHAKE, GNUNET_TIME_absolute_get_monotonic(), GNUNET_TIME_absolute_hton(), GNUNET_YES, SharedSecret::master, MAX_SECRETS, UdpHandshakeSignature::monotonic_time, mq, msg, my_identity, my_private_key, purge_secrets(), GNUNET_CRYPTO_EccSignaturePurpose::purpose, UdpHandshakeSignature::purpose, receiver(), UdpHandshakeSignature::receiver, receiver_destroy(), reschedule_receiver_timeout(), secret_destroy(), UdpHandshakeSignature::sender, setup_cipher(), setup_initial_shared_secret_ephemeral(), GNUNET_MessageHeader::size, GNUNET_CRYPTO_EccSignaturePurpose::size, and uc.
Referenced by mq_send_d(), and mq_send_kx().
|
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 ReceiverAddress |
Definition at line 2721 of file gnunet-communicator-udp.c.
References GNUNET_assert, mq, msg, receiver(), and send_msg_with_kx().
Referenced by setup_receiver_mq().
|
static |
Definition at line 2733 of file gnunet-communicator-udp.c.
References SharedSecret::cmac, UDPRekey::ephemeral, GNUNET_ERROR_TYPE_DEBUG, GNUNET_h2s(), GNUNET_log, GNUNET_MESSAGE_TYPE_COMMUNICATOR_UDP_REKEY, GNUNET_sh2s(), GNUNET_YES, UDPRekey::header, SharedSecret::master, receiver(), SharedSecret::rekey_initiated, SharedSecret::sequence_allowed, setup_shared_secret_ephemeral(), GNUNET_MessageHeader::size, and GNUNET_MessageHeader::type.
Referenced by mq_send_d().
|
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 ReceiverAddress |
Definition at line 2765 of file gnunet-communicator-udp.c.
References SharedSecret::bytes_sent, create_rekey(), do_pad(), UDPBox::gcm_tag, get_kid(), get_socket(), GNUNET_a2s(), GNUNET_assert, GNUNET_break, GNUNET_ERROR_TYPE_DEBUG, GNUNET_ERROR_TYPE_ERROR, GNUNET_ERROR_TYPE_WARNING, GNUNET_log, GNUNET_log_strerror, GNUNET_MQ_impl_send_continue(), GNUNET_NETWORK_socket_sendto(), GNUNET_NO, GNUNET_sh2s(), GNUNET_YES, inject_rekey(), UDPBox::kid, SharedSecret::master, MAX_SECRETS, mq, msg, SharedSecret::prev, purge_secrets(), receiver(), receiver_destroy(), SharedSecret::rekey_initiated, rekey_max_bytes, reschedule_receiver_timeout(), secret_destroy(), send_msg_with_kx(), SharedSecret::sequence_allowed, SharedSecret::sequence_used, setup_cipher(), and GNUNET_MessageHeader::size.
Referenced by setup_receiver_mq().
|
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 ReceiverAddress |
Definition at line 2918 of file gnunet-communicator-udp.c.
References GNUNET_ERROR_TYPE_DEBUG, GNUNET_log, GNUNET_YES, mq, receiver(), and receiver_destroy().
Referenced by setup_receiver_mq().
|
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 ReceiverAddress |
Definition at line 2941 of file gnunet-communicator-udp.c.
References GNUNET_ERROR_TYPE_DEBUG, GNUNET_log, GNUNET_YES, mq, receiver(), and receiver_destroy().
Referenced by setup_receiver_mq().
|
static |
Implementation function that cancels the currently sent message.
mq | message queue |
impl_state | our struct RecvierAddress |
Definition at line 2962 of file gnunet-communicator-udp.c.
References GNUNET_assert.
Referenced by setup_receiver_mq().
|
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 ReceiverAddress |
error | error code |
Definition at line 2979 of file gnunet-communicator-udp.c.
References GNUNET_ERROR_TYPE_ERROR, GNUNET_i2s(), GNUNET_log, receiver(), and receiver_destroy().
Referenced by setup_receiver_mq().
|
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 3080 of file gnunet-communicator-udp.c.
References address, create_receiver(), GNUNET_ERROR_TYPE_DEBUG, and GNUNET_log.
Referenced by run().
|
static |
Iterator over all receivers to clean up.
cls | NULL |
target | unused |
value | the queue to destroy |
Definition at line 3100 of file gnunet-communicator-udp.c.
References GNUNET_OK, receiver(), receiver_destroy(), ReceiverAddress::target, and value.
Referenced by do_shutdown().
|
static |
Iterator over all senders to clean up.
cls | NULL |
target | unused |
value | the queue to destroy |
Definition at line 3122 of file gnunet-communicator-udp.c.
References GNUNET_OK, sender_destroy(), SenderAddress::target, and value.
Referenced by do_shutdown().
|
static |
Shutdown the UNIX communicator.
cls | NULL (always) |
Definition at line 3143 of file gnunet-communicator-udp.c.
References ah, bi_destroy(), bi_head, broadcast_task, ch, default_v4_sock, default_v6_sock, get_receiver_delete_it(), get_sender_delete_it(), GNUNET_break, GNUNET_CONTAINER_heap_destroy(), GNUNET_CONTAINER_multihashmap_destroy(), GNUNET_CONTAINER_multihashmap_iterate(), GNUNET_CONTAINER_multishortmap_destroy(), GNUNET_ERROR_TYPE_DEBUG, GNUNET_free, GNUNET_log, GNUNET_NAT_unregister(), GNUNET_NETWORK_socket_close(), GNUNET_NT_scanner_done(), GNUNET_OK, GNUNET_SCHEDULER_cancel(), GNUNET_STATISTICS_destroy(), GNUNET_stop_burst(), GNUNET_TRANSPORT_application_done(), GNUNET_TRANSPORT_communicator_disconnect(), GNUNET_YES, is, key_cache, my_private_key, nat, read_v4_task, read_v6_task, receivers, receivers_heap, senders, senders_heap, stats, and timeout_task.
Referenced by run().
|
static |
Definition at line 3241 of file gnunet-communicator-udp.c.
References ai, GNUNET_memcmp, GNUNET_YES, handle_ack(), key, receiver(), and value.
Referenced by enc_notify_cb().
|
static |
Function called when the transport service has received a backchannel message for this communicator (!) via a different return path.
Should be an acknowledgement.
cls | closure, NULL |
sender | which peer sent the notification |
msg | payload |
Definition at line 3265 of file gnunet-communicator-udp.c.
References ai, GNUNET_break_op, GNUNET_CONTAINER_multihashmap_iterate(), GNUNET_ERROR_TYPE_DEBUG, GNUNET_i2s_full(), GNUNET_log, GNUNET_MESSAGE_TYPE_COMMUNICATOR_UDP_ACK, handle_ack_by_sender(), msg, receivers, AckInfo::sender, GNUNET_MessageHeader::size, and GNUNET_MessageHeader::type.
Referenced by run().
|
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 3303 of file gnunet-communicator-udp.c.
References ai, ch, COMMUNICATOR_ADDRESS_PREFIX, GNUNET_a2s(), GNUNET_asprintf(), GNUNET_free, GNUNET_NT_scanner_get_type(), GNUNET_TIME_UNIT_FOREVER_REL, GNUNET_TRANSPORT_communicator_address_add(), GNUNET_TRANSPORT_communicator_address_remove(), GNUNET_YES, is, and nt.
Referenced by run().
|
static |
Broadcast our presence on one of our interfaces.
cls | a struct BroadcastInterface |
Definition at line 3345 of file gnunet-communicator-udp.c.
References BroadcastInterface::ba, BroadcastInterface::bcm, BROADCAST_FREQUENCY, BroadcastInterface::broadcast_task, default_v4_sock, default_v6_sock, GNUNET_a2s(), GNUNET_break, GNUNET_CRYPTO_QUALITY_WEAK, GNUNET_CRYPTO_random_u64(), GNUNET_ERROR_TYPE_DEBUG, GNUNET_ERROR_TYPE_WARNING, GNUNET_i2s(), GNUNET_log, GNUNET_log_strerror, GNUNET_NETWORK_socket_sendto(), GNUNET_NETWORK_socket_setsockopt(), GNUNET_OK, GNUNET_SCHEDULER_add_delayed(), ifc_broadcast(), BroadcastInterface::mcreq, my_port, GNUNET_TIME_Relative::rel_value_us, BroadcastInterface::sa, BroadcastInterface::salen, and UDPBroadcast::sender.
Referenced by iface_proc(), and ifc_broadcast().
|
static |
Callback function invoked for each interface found.
Activates/deactivates broadcast interfaces.
cls | NULL |
name | name of the interface (can be NULL for unknown) |
isDefault | is this presumably the default interface |
addr | address of this interface (can be NULL for unknown or unassigned) |
broadcast_addr | the broadcast address (can be NULL for unknown or unassigned) |
netmask | the network mask (can be NULL for unknown or unassigned) |
addrlen | length of the address |
Definition at line 3438 of file gnunet-communicator-udp.c.
References BroadcastInterface::ba, BroadcastInterface::bcm, bi_head, bi_tail, BroadcastInterface::broadcast_task, default_v6_sock, BroadcastInterface::found, GNUNET_a2s(), GNUNET_assert, GNUNET_CONTAINER_DLL_insert, GNUNET_CRYPTO_eddsa_sign, GNUNET_CRYPTO_hash(), GNUNET_ERROR_TYPE_DEBUG, GNUNET_ERROR_TYPE_WARNING, GNUNET_log, GNUNET_log_strerror, GNUNET_memdup, GNUNET_NETWORK_socket_setsockopt(), GNUNET_new, GNUNET_NT_LOOPBACK, GNUNET_NT_scanner_get_type(), GNUNET_OK, GNUNET_SCHEDULER_add_now(), GNUNET_SIGNATURE_PURPOSE_COMMUNICATOR_UDP_BROADCAST, GNUNET_YES, UdpBroadcastSignature::h_address, ifc_broadcast(), is, BroadcastInterface::mcreq, my_identity, my_private_key, BroadcastInterface::next, GNUNET_CRYPTO_EccSignaturePurpose::purpose, UdpBroadcastSignature::purpose, BroadcastInterface::sa, BroadcastInterface::salen, UdpBroadcastSignature::sender, UDPBroadcast::sender, UDPBroadcast::sender_sig, and GNUNET_CRYPTO_EccSignaturePurpose::size.
Referenced by do_broadcast().
|
static |
Scan interfaces to broadcast our presence on the LAN.
cls | NULL, unused |
Definition at line 3548 of file gnunet-communicator-udp.c.
References bi_destroy(), bi_head, broadcast_task, do_broadcast(), BroadcastInterface::found, GNUNET_NO, GNUNET_OS_network_interfaces_list(), GNUNET_SCHEDULER_add_delayed(), iface_proc(), INTERFACE_SCAN_FREQUENCY, and BroadcastInterface::next.
Referenced by do_broadcast(), and run().
|
static |
Definition at line 3569 of file gnunet-communicator-udp.c.
References GNUNET_ERROR_TYPE_INFO, and GNUNET_log.
Referenced by run().
|
static |
Definition at line 3580 of file gnunet-communicator-udp.c.
References GNUNET_UdpSocketInfo::actual_address, address, ch, create_receiver(), default_v4_sock, default_v6_sock, GNUNET_free, GNUNET_TRANSPORT_communicator_burst_finished(), GNUNET_UdpSocketInfo::pid, sockaddr_to_udpaddr_string(), and GNUNET_UdpSocketInfo::udp_sock.
Referenced by start_burst().
|
static |
Definition at line 3596 of file gnunet-communicator-udp.c.
References GNUNET_UdpSocketInfo::address, GNUNET_UdpSocketInfo::bind_address, burst_task, default_v4_sock, GNUNET_ERROR_TYPE_DEBUG, GNUNET_free, GNUNET_get_udp_socket(), GNUNET_log, GNUNET_memcpy, GNUNET_new, GNUNET_stop_burst(), GNUNET_strdup, GNUNET_YES, GNUNET_UdpSocketInfo::has_port, my_ipv4, my_port, GNUNET_UdpSocketInfo::pid, pid, GNUNET_TIME_Relative::rel_value_us, GNUNET_UdpSocketInfo::rtt, GNUNET_UdpSocketInfo::std_port, GNUNET_UdpSocketInfo::udp_sock, and udp_socket_notify().
Referenced by reconnect(), and run().
|
static |
Definition at line 3631 of file gnunet-communicator-udp.c.
References GNUNET_a2s(), GNUNET_ERROR_TYPE_ERROR, GNUNET_free, GNUNET_log, GNUNET_log_strerror, GNUNET_log_strerror_file, GNUNET_malloc, GNUNET_NETWORK_get_fd(), GNUNET_NETWORK_socket_bind(), GNUNET_NETWORK_socket_close(), GNUNET_NETWORK_socket_create(), GNUNET_OK, and udp_address_to_sockaddr().
Referenced by run().
|
static |
Definition at line 3714 of file gnunet-communicator-udp.c.
References GNUNET_free, and GNUNET_SCHEDULER_shutdown().
Referenced by run().
|
static |
Definition at line 3725 of file gnunet-communicator-udp.c.
References _, ah, broadcast_task, cfg, ch, COMMUNICATOR_ADDRESS_PREFIX, COMMUNICATOR_CONFIG_SECTION, create_udp_socket(), DEFAULT_REKEY_MAX_BYTES, DEFAULT_REKEY_TIME_INTERVAL, default_v4_sock, default_v6_sock, disable_v6, do_broadcast(), do_shutdown(), eddsa_priv_to_hpke_key(), enc_notify_cb(), GNUNET_a2s(), GNUNET_assert, GNUNET_break, GNUNET_CONFIGURATION_get_value_size(), GNUNET_CONFIGURATION_get_value_string(), GNUNET_CONFIGURATION_get_value_time(), GNUNET_CONFIGURATION_get_value_yesno(), GNUNET_CONTAINER_heap_create(), GNUNET_CONTAINER_HEAP_ORDER_MIN, GNUNET_CONTAINER_multihashmap_create(), GNUNET_CONTAINER_multishortmap_create(), GNUNET_CRYPTO_eddsa_key_create_from_configuration(), GNUNET_CRYPTO_eddsa_key_get_public(), GNUNET_ERROR_TYPE_DEBUG, GNUNET_ERROR_TYPE_ERROR, GNUNET_ERROR_TYPE_INFO, GNUNET_free, GNUNET_log, GNUNET_log_config_missing(), GNUNET_log_from_nocheck(), GNUNET_malloc, GNUNET_NAT_register(), GNUNET_NETWORK_test_pf(), GNUNET_NO, GNUNET_NT_scanner_init(), GNUNET_OK, GNUNET_SCHEDULER_add_now(), GNUNET_SCHEDULER_add_read_net(), GNUNET_SCHEDULER_add_shutdown(), GNUNET_STATISTICS_create(), GNUNET_TIME_UNIT_FOREVER_REL, GNUNET_TRANSPORT_application_init(), GNUNET_TRANSPORT_CC_UNRELIABLE, GNUNET_TRANSPORT_communicator_connect(), GNUNET_YES, is, key_cache, mq_init(), my_identity, my_ipv4, my_port, my_private_key, my_x25519_private_key, nat, nat_address_cb(), GNUNET_PeerIdentity::public_key, read_v4_task, read_v6_task, receivers, receivers_heap, rekey_interval, rekey_max_bytes, senders, senders_heap, shutdown_run(), sock_read(), start_burst(), stats, and try_connection_reversal().
|
static |
|
static |
How often we do rekey based on number of bytes transmitted.
Definition at line 762 of file gnunet-communicator-udp.c.
Referenced by decrypt_box(), mq_send_d(), and run().
|
static |
Cache of pre-generated key IDs.
Definition at line 767 of file gnunet-communicator-udp.c.
Referenced by do_shutdown(), kce_destroy(), kce_generate(), run(), secret_destroy(), and sock_read().
|
static |
ID of read IPv4 task.
Definition at line 772 of file gnunet-communicator-udp.c.
Referenced by do_shutdown(), run(), and sock_read().
|
static |
ID of read IPv6 task.
Definition at line 777 of file gnunet-communicator-udp.c.
Referenced by do_shutdown(), run(), and sock_read().
|
static |
ID of timeout task.
Definition at line 782 of file gnunet-communicator-udp.c.
Referenced by check_timeouts(), create_receiver(), do_shutdown(), and setup_sender().
|
static |
ID of master broadcast task.
Definition at line 787 of file gnunet-communicator-udp.c.
Referenced by do_broadcast(), do_shutdown(), and run().
|
static |
For logging statistics.
Definition at line 792 of file gnunet-communicator-udp.c.
Referenced by create_receiver(), decrypt_box(), do_shutdown(), kce_generate(), pass_plaintext_to_core(), receiver_destroy(), run(), secret_destroy(), sender_destroy(), setup_initial_shared_secret_ephemeral(), setup_sender(), setup_shared_secret_ephemeral(), sock_read(), try_decrypt(), and try_handle_plaintext().
|