Transport plugin using UDP. More...
#include "platform.h"
#include "gnunet_util_lib.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_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 |
UDP message box. 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 |
Context information to be used while searching for operation contexts. More... | |
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 2 |
#define | KCN_THRESHOLD 92 |
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 128000 |
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 | bi_destroy (struct BroadcastInterface *bi) |
An interface went away, stop broadcasting on it. 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_HashCode *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 int | secret_destroy (struct SharedSecret *ss, int withoutKce) |
Destroy ss and associated key cache entries. 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_HashCode *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_HashCode *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 char tag[(128/8)], 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_EcdhePublicKey *ephemeral) |
Setup shared secret for decryption. More... | |
static struct SharedSecret * | setup_shared_secret_enc (const struct GNUNET_CRYPTO_EcdhePrivateKey *ephemeral, struct ReceiverAddress *receiver, int add_to_receiver) |
Setup shared secret for encryption. More... | |
static void | setup_receiver_mq (struct ReceiverAddress *receiver) |
Setup the MQ for the receiver. More... | |
static void | destroy_all_secrets (struct SharedSecret *ss, int withoutKce) |
Destroying all secrets. More... | |
static void | add_acks (struct SharedSecret *ss, int acks_to_add) |
static uint32_t | reset_rekey_kces (struct ReceiverAddress *receiver, uint32_t acks_to_add) |
static void | add_acks_rekey (struct ReceiverAddress *receiver) |
static int | handle_ack (void *cls, const struct GNUNET_PeerIdentity *pid, void *value) |
We received an ACK for pid. More... | |
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 | kce_generate_cb (void *cls) |
static void | kce_generate_rekey_cb (void *cls) |
static void | consider_ss_ack (struct SharedSecret *ss, int initial) |
We established a shared secret with a sender. 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 void | decrypt_rekey (const struct UDPRekey *rekey, size_t rekey_len, struct KeyCacheEntry *kce, struct SenderAddress *sender) |
We received a rekey with matching kce. More... | |
static int | find_sender_by_address (void *cls, const struct GNUNET_PeerIdentity *key, void *value) |
Find existing struct SenderAddress by matching addresses. 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_EcdhePublicKey *ephemeral, 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 void | sock_read (void *cls) |
Socket read task. More... | |
static struct sockaddr * | udp_address_to_sockaddr (const char *bindto, socklen_t *sock_len) |
Convert UDP bind specification to a struct sockaddr * More... | |
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 | 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 | check_for_rekeying (struct ReceiverAddress *receiver, struct UDPBox *box) |
static void | send_UDPRekey (struct ReceiverAddress *receiver, struct SharedSecret *ss) |
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_PeerIdentity *target, void *value) |
Iterator over all receivers to clean up. More... | |
static int | get_sender_delete_it (void *cls, const struct GNUNET_PeerIdentity *target, void *value) |
Iterator over all senders 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 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 | 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 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... | |
struct SharedSecret * | ss_finished |
Shared secret we finished the last kce working queue for. More... | |
static struct GNUNET_CONTAINER_MultiShortmap * | key_cache |
Cache of pre-generated key IDs. More... | |
static struct GNUNET_SCHEDULER_Task * | read_task |
ID of read 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_MultiPeerMap * | receivers |
Receivers (map from peer identity to struct ReceiverAddress ) More... | |
static struct GNUNET_CONTAINER_MultiPeerMap * | 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 * | udp_sock |
Our socket. More... | |
static int | have_v6_socket |
GNUNET_YES if udp_sock supports IPv6. More... | |
static struct GNUNET_PeerIdentity | my_identity |
Our public key. 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_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... | |
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 2 |
Definition at line 96 of file gnunet-communicator-udp.c.
#define KCN_THRESHOLD 92 |
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 128000 |
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 |
An interface went away, stop broadcasting on it.
bi | entity to close down |
Definition at line 904 of file gnunet-communicator-udp.c.
References BroadcastInterface::ba, bi_head, bi_tail, BroadcastInterface::broadcast_task, GNUNET_CONTAINER_DLL_remove, GNUNET_ERROR_TYPE_WARNING, GNUNET_free, GNUNET_log_strerror, GNUNET_NETWORK_socket_setsockopt(), GNUNET_OK, GNUNET_SCHEDULER_cancel(), BroadcastInterface::mcreq, BroadcastInterface::sa, and udp_sock.
Referenced by do_broadcast(), and do_shutdown().
|
static |
Destroys a receiving state due to timeout or shutdown.
receiver | entity to close down |
Definition at line 932 of file gnunet-communicator-udp.c.
References GNUNET_assert, GNUNET_CONTAINER_heap_remove_node(), GNUNET_CONTAINER_multipeermap_remove(), GNUNET_CONTAINER_multipeermap_size(), GNUNET_ERROR_TYPE_DEBUG, GNUNET_free, GNUNET_i2s(), GNUNET_log, GNUNET_NO, GNUNET_STATISTICS_set(), GNUNET_TRANSPORT_communicator_mq_del(), GNUNET_YES, receiver(), receivers, and stats.
Referenced by check_timeouts(), get_receiver_delete_it(), mq_destroy_d(), mq_destroy_kx(), mq_error(), mq_send_d(), and mq_send_kx().
|
static |
Free memory used by key cache entry.
kce | the key cache entry |
Definition at line 982 of file gnunet-communicator-udp.c.
References SenderAddress::acks_available, 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, SharedSecret::sender, and KeyCacheEntry::ss.
Referenced by consider_ss_ack(), decrypt_box(), decrypt_rekey(), 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 1004 of file gnunet-communicator-udp.c.
References GNUNET_CRYPTO_hkdf().
Referenced by kce_generate(), mq_send_d(), and send_UDPRekey().
|
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 1032 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 consider_ss_ack(), kce_generate_cb(), and kce_generate_rekey_cb().
|
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 1063 of file gnunet-communicator-udp.c.
References GNUNET_CONTAINER_DLL_remove, GNUNET_CONTAINER_multishortmap_size(), GNUNET_ERROR_TYPE_DEBUG, GNUNET_free, GNUNET_h2s(), GNUNET_log, GNUNET_NO, GNUNET_STATISTICS_set(), GNUNET_STATISTICS_update(), GNUNET_YES, kce_destroy(), SharedSecret::kce_head, key_cache, SharedSecret::master, SenderAddress::num_secrets, SharedSecret::receiver, receiver(), SharedSecret::sender, SharedSecret::sequence_allowed, SharedSecret::sequence_used, KeyCacheEntry::ss, SenderAddress::ss_head, SenderAddress::ss_tail, and stats.
Referenced by destroy_all_secrets().
|
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 1112 of file gnunet-communicator-udp.c.
References SenderAddress::address, GNUNET_assert, GNUNET_CONTAINER_heap_remove_node(), GNUNET_CONTAINER_multipeermap_remove(), GNUNET_CONTAINER_multipeermap_size(), GNUNET_free, GNUNET_NO, GNUNET_STATISTICS_set(), GNUNET_YES, SenderAddress::hn, SenderAddress::sender_destroy_called, senders, stats, and SenderAddress::target.
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 1137 of file gnunet-communicator-udp.c.
References AES_IV_SIZE, AES_KEY_SIZE, GNUNET_CRYPTO_hkdf(), key, and res.
Referenced by setup_cipher().
|
static |
Increment sender timeout due to activity.
sender | address for which the timeout should be rescheduled |
Definition at line 1168 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, 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 1182 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 mq_send_kx().
|
static |
Task run to check #receiver_heap and #sender_heap for timeouts.
cls | unused, NULL |
Definition at line 1197 of file gnunet-communicator-udp.c.
References delay, 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 mq_init(), and setup_sender().
|
static |
Calculate cmac from master in ss.
[in,out] | ss | data structure to complete |
Definition at line 1243 of file gnunet-communicator-udp.c.
References SharedSecret::cmac, GNUNET_CRYPTO_hkdf(), and SharedSecret::master.
Referenced by decrypt_rekey(), setup_shared_secret_enc(), 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 1269 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 1318 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(), mq_send_kx(), send_UDPRekey(), 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 1352 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(), decrypt_rekey(), and sock_read().
|
static |
Setup shared secret for decryption.
ephemeral | ephemeral key we received from the other peer |
Definition at line 1386 of file gnunet-communicator-udp.c.
References GNUNET_CRYPTO_eddsa_ecdh(), GNUNET_new, SharedSecret::master, and my_private_key.
Referenced by sock_read().
|
static |
Setup shared secret for encryption.
ephemeral | ephemeral key we are sending to the other peer | |
[in,out] | receiver | queue to initialize encryption key for |
Definition at line 1404 of file gnunet-communicator-udp.c.
References calculate_cmac(), GNUNET_CONTAINER_DLL_insert, GNUNET_CRYPTO_ecdh_eddsa(), GNUNET_new, GNUNET_NO, GNUNET_STATISTICS_update(), SharedSecret::master, SharedSecret::receiver, receiver(), and stats.
Referenced by mq_send_kx(), and send_UDPRekey().
|
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 3147 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 mq_init().
|
static |
Destroying all secrets.
Depending on parameter we keep those secrets having a kce.
ss | The secret we will not destroy. |
withoutKce | If GNUNET_YES shared secrets with kce will not be destroyed. |
Definition at line 1439 of file gnunet-communicator-udp.c.
References GNUNET_ERROR_TYPE_DEBUG, GNUNET_ERROR_TYPE_ERROR, GNUNET_log, GNUNET_NO, SharedSecret::next, SharedSecret::receiver, receiver(), secret_destroy(), SharedSecret::sender, and SenderAddress::ss_head.
Referenced by add_acks(), consider_ss_ack(), and mq_send_kx().
|
static |
Definition at line 1490 of file gnunet-communicator-udp.c.
References ch, destroy_all_secrets(), GNUNET_assert, GNUNET_CONTAINER_DLL_insert, GNUNET_CONTAINER_DLL_remove, GNUNET_ERROR_TYPE_DEBUG, GNUNET_log, GNUNET_TRANSPORT_communicator_mq_add(), GNUNET_TRANSPORT_communicator_mq_update(), GNUNET_TRANSPORT_CS_OUTBOUND, GNUNET_YES, SharedSecret::receiver, and receiver().
Referenced by add_acks_rekey(), and handle_ack().
|
static |
Definition at line 1537 of file gnunet-communicator-udp.c.
References GNUNET_ERROR_TYPE_DEBUG, GNUNET_log, and receiver().
Referenced by add_acks_rekey(), and handle_ack().
|
static |
Definition at line 1568 of file gnunet-communicator-udp.c.
References add_acks(), GNUNET_ERROR_TYPE_DEBUG, GNUNET_log, GNUNET_NO, GNUNET_STATISTICS_update(), receiver(), reset_rekey_kces(), and stats.
Referenced by handle_ack(), and mq_send_d().
|
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 1604 of file gnunet-communicator-udp.c.
References UDPAck::acks_available, add_acks(), add_acks_rekey(), UDPAck::cmac, GNUNET_ERROR_TYPE_DEBUG, GNUNET_h2s(), GNUNET_log, GNUNET_NO, GNUNET_YES, pid, receiver(), reset_rekey_kces(), UDPAck::sequence_max, and value.
Referenced by enc_notify_cb(), 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 1716 of file gnunet-communicator-udp.c.
References buf, GNUNET_CONTAINER_multipeermap_get_multiple(), GNUNET_ERROR_TYPE_DEBUG, GNUNET_log, GNUNET_MESSAGE_TYPE_COMMUNICATOR_UDP_ACK, GNUNET_MESSAGE_TYPE_COMMUNICATOR_UDP_PAD, handle_ack(), pass_plaintext_to_core(), receivers, GNUNET_MessageHeader::size, SenderAddress::target, GNUNET_MessageHeader::type, and type.
Referenced by decrypt_box(), and sock_read().
|
static |
Definition at line 1761 of file gnunet-communicator-udp.c.
References SenderAddress::acks_available, GENERATE_AT_ONCE, GNUNET_ERROR_TYPE_DEBUG, GNUNET_h2s(), GNUNET_log, GNUNET_NO, GNUNET_SCHEDULER_add_delayed(), GNUNET_YES, kce_generate(), SenderAddress::kce_task, SenderAddress::kce_task_finished, KCN_TARGET, SharedSecret::master, SenderAddress::rekeying, SharedSecret::sender, SharedSecret::sequence_allowed, ss_finished, SenderAddress::ss_rekey, and WORKING_QUEUE_INTERVALL.
Referenced by consider_ss_ack(), and kce_generate_rekey_cb().
|
static |
Definition at line 1802 of file gnunet-communicator-udp.c.
References GENERATE_AT_ONCE, GNUNET_ERROR_TYPE_DEBUG, GNUNET_h2s(), GNUNET_log, GNUNET_SCHEDULER_add_delayed(), kce_generate(), kce_generate_cb(), SenderAddress::kce_task, SenderAddress::kce_task_rekey, SharedSecret::master, SharedSecret::sender, SharedSecret::sequence_allowed, and WORKING_QUEUE_INTERVALL.
Referenced by consider_ss_ack().
|
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 |
initial | The SharedSecret came with initial KX. |
Definition at line 1844 of file gnunet-communicator-udp.c.
References UDPAck::acks_available, SenderAddress::acks_available, ch, UDPAck::cmac, SharedSecret::cmac, COMMUNICATOR_ADDRESS_PREFIX, destroy_all_secrets(), GNUNET_assert, GNUNET_ERROR_TYPE_DEBUG, GNUNET_h2s(), GNUNET_i2s_full(), GNUNET_log, GNUNET_MESSAGE_TYPE_COMMUNICATOR_UDP_ACK, GNUNET_NO, GNUNET_SCHEDULER_add_delayed(), GNUNET_TRANSPORT_communicator_notify(), GNUNET_YES, UDPAck::header, kce_destroy(), kce_generate(), kce_generate_cb(), kce_generate_rekey_cb(), SharedSecret::kce_head, SharedSecret::kce_tail, SenderAddress::kce_task, SenderAddress::kce_task_finished, SenderAddress::kce_task_rekey, KCN_THRESHOLD, SharedSecret::master, MAX_SECRETS, MAX_SQN_DELTA, SenderAddress::num_secrets, SenderAddress::rekeying, SharedSecret::sender, SharedSecret::sequence_allowed, UDPAck::sequence_max, KeyCacheEntry::sequence_number, GNUNET_MessageHeader::size, ss_finished, SenderAddress::target, GNUNET_MessageHeader::type, and WORKING_QUEUE_INTERVALL.
Referenced by decrypt_box(), decrypt_rekey(), 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 1953 of file gnunet-communicator-udp.c.
References consider_ss_ack(), UDPBox::gcm_tag, GNUNET_assert, GNUNET_ERROR_TYPE_DEBUG, GNUNET_log, GNUNET_NO, GNUNET_OK, GNUNET_sh2s(), GNUNET_STATISTICS_update(), GNUNET_YES, kce_destroy(), UDPBox::kid, UDPBox::rekeying, SenderAddress::rekeying, SharedSecret::sender, KeyCacheEntry::sequence_number, KeyCacheEntry::ss, SenderAddress::ss_rekey, stats, try_decrypt(), and try_handle_plaintext().
Referenced by sock_read().
|
static |
We received a rekey with matching kce.
Decrypt and process it.
rekey | the data we received |
rekey_len | number of bytes in rekey |
kce | key index to decrypt rekey |
Definition at line 2015 of file gnunet-communicator-udp.c.
References SenderAddress::acks_available, calculate_cmac(), SharedSecret::cmac, consider_ss_ack(), UDPRekey::gcm_tag, GNUNET_assert, GNUNET_CONTAINER_DLL_insert, GNUNET_ERROR_TYPE_DEBUG, GNUNET_h2s(), GNUNET_log, GNUNET_new, GNUNET_NO, GNUNET_OK, GNUNET_sh2s(), GNUNET_STATISTICS_update(), GNUNET_YES, kce_destroy(), UDPRekey::kid, SharedSecret::master, SenderAddress::num_secrets, SharedSecret::sender, SharedSecret::sequence_allowed, KeyCacheEntry::sequence_number, KeyCacheEntry::ss, SenderAddress::ss_head, SenderAddress::ss_rekey, SenderAddress::ss_tail, stats, and try_decrypt().
Referenced by sock_read().
|
static |
Find existing struct SenderAddress
by matching addresses.
cls | a struct SearchContext |
key | ignored, must match already |
value | a struct SenderAddress |
Definition at line 2126 of file gnunet-communicator-udp.c.
References SenderAddress::address, SenderAddress::address_len, GNUNET_NO, GNUNET_YES, sc, and value.
Referenced by setup_sender().
|
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 2155 of file gnunet-communicator-udp.c.
References GNUNET_TIME_Absolute::abs_value_us, address, SenderAddress::address, SenderAddress::address_len, SearchContext::address_len, check_timeouts(), find_sender_by_address(), GNUNET_CONSTANTS_IDLE_CONNECTION_TIMEOUT, GNUNET_CONTAINER_heap_insert(), GNUNET_CONTAINER_MULTIHASHMAPOPTION_MULTIPLE, GNUNET_CONTAINER_multipeermap_get_multiple(), GNUNET_CONTAINER_multipeermap_put(), GNUNET_CONTAINER_multipeermap_size(), 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::nt, receivers, reschedule_sender_timeout(), sc, SearchContext::sender, 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 2206 of file gnunet-communicator-udp.c.
References UdpHandshakeSignature::ephemeral, 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 2235 of file gnunet-communicator-udp.c.
References address, COMMUNICATOR_ADDRESS_PREFIX, GNUNET_a2s(), GNUNET_asprintf(), GNUNET_assert, and ret.
Referenced by mq_init(), and sock_read().
|
static |
Socket read task.
cls | NULL |
Definition at line 2269 of file gnunet-communicator-udp.c.
References ah, buf, calculate_cmac(), consider_ss_ack(), decrypt_box(), decrypt_rekey(), do_decrypt(), InitialKX::ephemeral, InitialKX::gcm_tag, GNUNET_a2s(), 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_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_read_net(), GNUNET_sh2s(), GNUNET_SIGNATURE_PURPOSE_COMMUNICATOR_UDP_BROADCAST, GNUNET_STATISTICS_update(), GNUNET_TIME_UNIT_FOREVER_REL, GNUNET_TRANSPORT_application_validate(), GNUNET_YES, UdpBroadcastSignature::h_address, is, key_cache, UDPBox::kid, UDPRekey::kid, my_identity, nt, GNUNET_PeerIdentity::public_key, GNUNET_CRYPTO_EccSignaturePurpose::purpose, UdpBroadcastSignature::purpose, read_task, InitialKX::rekeying, UDPBox::rekeying, SenderAddress::rekeying, UDPConfirmation::sender, UdpBroadcastSignature::sender, UDPBroadcast::sender, UDPRekey::sender, SharedSecret::sender, UDPBroadcast::sender_sig, setup_sender(), setup_shared_secret_dec(), GNUNET_CRYPTO_EccSignaturePurpose::size, sockaddr_to_udpaddr_string(), KeyCacheEntry::ss, SenderAddress::ss_rekey, stats, try_decrypt(), try_handle_plaintext(), uc, udp_sock, and verify_confirmation().
Referenced by run().
|
static |
Convert UDP bind specification to a struct sockaddr *
bindto | bind specification to convert | |
[out] | sock_len | set to the length of the address |
Definition at line 2513 of file gnunet-communicator-udp.c.
References cfg, COMMUNICATOR_CONFIG_SECTION, dummy, GNUNET_CONFIGURATION_get_value_yesno(), GNUNET_ERROR_TYPE_ERROR, GNUNET_free, GNUNET_log, GNUNET_malloc, GNUNET_memdup, GNUNET_NETWORK_test_pf(), GNUNET_NO, GNUNET_strdup, GNUNET_YES, port, and start.
Referenced by mq_init(), and run().
|
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 2648 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(), mq_send_kx(), and send_UDPRekey().
|
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 2676 of file gnunet-communicator-udp.c.
References cfg, destroy_all_secrets(), do_pad(), UdpHandshakeSignature::ephemeral, InitialKX::ephemeral, InitialKX::gcm_tag, GNUNET_a2s(), GNUNET_assert, GNUNET_break, GNUNET_CRYPTO_ecdhe_key_create(), GNUNET_CRYPTO_ecdhe_key_get_public(), GNUNET_CRYPTO_eddsa_sign, GNUNET_ERROR_TYPE_DEBUG, GNUNET_ERROR_TYPE_WARNING, GNUNET_log, GNUNET_log_strerror, GNUNET_MQ_impl_send_continue(), GNUNET_NETWORK_socket_sendto(), GNUNET_NO, 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, GNUNET_CRYPTO_EccSignaturePurpose::purpose, UdpHandshakeSignature::purpose, UdpHandshakeSignature::receiver, receiver(), receiver_destroy(), InitialKX::rekeying, reschedule_receiver_timeout(), UdpHandshakeSignature::sender, setup_cipher(), setup_shared_secret_enc(), GNUNET_MessageHeader::size, GNUNET_CRYPTO_EccSignaturePurpose::size, uc, and udp_sock.
Referenced by setup_receiver_mq().
|
static |
Definition at line 2766 of file gnunet-communicator-udp.c.
References GNUNET_ERROR_TYPE_DEBUG, GNUNET_log, GNUNET_sh2s(), GNUNET_TIME_absolute_get_remaining(), GNUNET_TIME_relative_to_absolute(), GNUNET_YES, UDPBox::kid, receiver(), rekey_interval, rekey_max_bytes, UDPBox::rekeying, and GNUNET_TIME_Relative::rel_value_us.
Referenced by mq_send_d().
|
static |
Definition at line 2819 of file gnunet-communicator-udp.c.
References do_pad(), UDPRekey::gcm_tag, get_kid(), GNUNET_a2s(), GNUNET_assert, GNUNET_CRYPTO_ecdhe_key_create(), GNUNET_ERROR_TYPE_DEBUG, GNUNET_ERROR_TYPE_WARNING, GNUNET_h2s(), GNUNET_log, GNUNET_log_strerror, GNUNET_NETWORK_socket_sendto(), GNUNET_NO, GNUNET_sh2s(), UDPRekey::kid, SharedSecret::master, my_identity, SharedSecret::prev, receiver(), UDPRekey::sender, SharedSecret::sequence_allowed, SharedSecret::sequence_used, setup_cipher(), setup_shared_secret_enc(), and udp_sock.
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 2945 of file gnunet-communicator-udp.c.
References add_acks_rekey(), check_for_rekeying(), do_pad(), UDPBox::gcm_tag, get_kid(), GNUNET_assert, GNUNET_break, GNUNET_ERROR_TYPE_DEBUG, GNUNET_ERROR_TYPE_WARNING, GNUNET_h2s(), GNUNET_log, GNUNET_log_strerror, GNUNET_MQ_impl_send_continue(), GNUNET_NETWORK_socket_sendto(), GNUNET_NO, GNUNET_YES, UDPBox::kid, mq, msg, receiver(), receiver_destroy(), UDPBox::rekeying, reschedule_receiver_timeout(), send_UDPRekey(), setup_cipher(), GNUNET_MessageHeader::size, and udp_sock.
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 3066 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 3089 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 3110 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 3127 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 3239 of file gnunet-communicator-udp.c.
References address, check_timeouts(), COMMUNICATOR_ADDRESS_PREFIX, GNUNET_break_op, GNUNET_CONSTANTS_IDLE_CONNECTION_TIMEOUT, GNUNET_CONTAINER_heap_insert(), GNUNET_CONTAINER_MULTIHASHMAPOPTION_MULTIPLE, GNUNET_CONTAINER_multipeermap_put(), GNUNET_CONTAINER_multipeermap_size(), GNUNET_ERROR_TYPE_DEBUG, GNUNET_i2s_full(), GNUNET_log, GNUNET_new, GNUNET_NO, GNUNET_NT_scanner_get_type(), GNUNET_OK, GNUNET_SCHEDULER_add_now(), GNUNET_STATISTICS_set(), GNUNET_SYSERR, GNUNET_TIME_relative_to_absolute(), is, peer, receiver(), receivers, receivers_heap, setup_receiver_mq(), sockaddr_to_udpaddr_string(), stats, timeout_task, and udp_address_to_sockaddr().
Referenced by run().
|
static |
Iterator over all receivers to clean up.
cls | NULL |
target | unused |
value | the queue to destroy |
Definition at line 3296 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 3318 of file gnunet-communicator-udp.c.
References GNUNET_OK, GNUNET_SCHEDULER_cancel(), SenderAddress::kce_task, SenderAddress::kce_task_rekey, sender_destroy(), SenderAddress::target, and value.
Referenced by do_shutdown().
|
static |
Shutdown the UNIX communicator.
cls | NULL (always) |
Definition at line 3349 of file gnunet-communicator-udp.c.
References ah, bi_destroy(), bi_head, broadcast_task, ch, get_receiver_delete_it(), get_sender_delete_it(), GNUNET_break, GNUNET_CONTAINER_heap_destroy(), GNUNET_CONTAINER_multipeermap_destroy(), GNUNET_CONTAINER_multipeermap_iterate(), GNUNET_CONTAINER_multishortmap_destroy(), GNUNET_ERROR_TYPE_DEBUG, GNUNET_free, GNUNET_log, GNUNET_NAT_unregister(), GNUNET_NETWORK_socket_close(), GNUNET_NO, GNUNET_NT_scanner_done(), GNUNET_OK, GNUNET_SCHEDULER_cancel(), GNUNET_STATISTICS_destroy(), GNUNET_TRANSPORT_application_done(), GNUNET_TRANSPORT_communicator_disconnect(), is, key_cache, my_private_key, nat, read_task, receivers, receivers_heap, senders, senders_heap, stats, timeout_task, and udp_sock.
Referenced by run().
|
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 3437 of file gnunet-communicator-udp.c.
References GNUNET_break_op, GNUNET_CONTAINER_multipeermap_get_multiple(), GNUNET_ERROR_TYPE_DEBUG, GNUNET_i2s_full(), GNUNET_log, GNUNET_MESSAGE_TYPE_COMMUNICATOR_UDP_ACK, handle_ack(), msg, receivers, 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 3475 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 3517 of file gnunet-communicator-udp.c.
References BroadcastInterface::ba, BroadcastInterface::bcm, BROADCAST_FREQUENCY, BroadcastInterface::broadcast_task, delay, 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(), BroadcastInterface::mcreq, my_port, GNUNET_TIME_Relative::rel_value_us, BroadcastInterface::sa, BroadcastInterface::salen, UDPBroadcast::sender, and udp_sock.
Referenced by iface_proc().
|
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 3610 of file gnunet-communicator-udp.c.
References BroadcastInterface::ba, BroadcastInterface::bcm, bi_head, bi_tail, BroadcastInterface::broadcast_task, 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, have_v6_socket, 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, GNUNET_CRYPTO_EccSignaturePurpose::size, and udp_sock.
Referenced by do_broadcast().
|
static |
Scan interfaces to broadcast our presence on the LAN.
cls | NULL, unused |
Definition at line 3719 of file gnunet-communicator-udp.c.
References bi_destroy(), bi_head, broadcast_task, BroadcastInterface::found, GNUNET_NO, GNUNET_OS_network_interfaces_list(), GNUNET_SCHEDULER_add_delayed(), iface_proc(), INTERFACE_SCAN_FREQUENCY, and BroadcastInterface::next.
Referenced by run().
|
static |
Definition at line 3739 of file gnunet-communicator-udp.c.
Referenced by run().
|
static |
Setup communicator and launch network interactions.
cls | NULL (always) |
args | remaining command-line arguments |
cfgfile | name of the configuration file used (for saving, can be NULL!) |
c | configuration |
Definition at line 3755 of file gnunet-communicator-udp.c.
References _, ah, broadcast_task, cfg, ch, COMMUNICATOR_ADDRESS_PREFIX, COMMUNICATOR_CONFIG_SECTION, DEFAULT_REKEY_MAX_BYTES, DEFAULT_REKEY_TIME_INTERVAL, do_broadcast(), do_shutdown(), enc_notify_cb(), GNUNET_a2s(), 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_multipeermap_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_free, GNUNET_log, GNUNET_log_config_missing(), GNUNET_log_from_nocheck(), GNUNET_log_strerror, GNUNET_log_strerror_file, GNUNET_NAT_register(), GNUNET_NETWORK_get_fd(), GNUNET_NETWORK_socket_bind(), GNUNET_NETWORK_socket_close(), GNUNET_NETWORK_socket_create(), GNUNET_NT_scanner_init(), GNUNET_OK, GNUNET_SCHEDULER_add_now(), GNUNET_SCHEDULER_add_read_net(), GNUNET_SCHEDULER_add_shutdown(), GNUNET_SCHEDULER_shutdown(), GNUNET_STATISTICS_create(), GNUNET_TIME_UNIT_FOREVER_REL, GNUNET_TRANSPORT_application_init(), GNUNET_TRANSPORT_CC_UNRELIABLE, GNUNET_TRANSPORT_communicator_connect(), GNUNET_YES, have_v6_socket, is, key_cache, mq_init(), my_identity, my_port, my_private_key, nat, nat_address_cb(), GNUNET_PeerIdentity::public_key, read_task, receivers, receivers_heap, rekey_interval, rekey_max_bytes, senders, senders_heap, sock_read(), stats, try_connection_reversal(), udp_address_to_sockaddr(), and udp_sock.
int main | ( | int | argc, |
char *const * | argv | ||
) |
The main function for the UNIX communicator.
argc | number of arguments from the command line |
argv | command line arguments |
Definition at line 3938 of file gnunet-communicator-udp.c.
|
static |
The rekey interval.
Definition at line 384 of file gnunet-communicator-udp.c.
Referenced by check_for_rekeying(), and run().
|
static |
How often we do rekey based on number of bytes transmitted.
Definition at line 786 of file gnunet-communicator-udp.c.
Referenced by check_for_rekeying(), and run().
struct SharedSecret* ss_finished |
Shared secret we finished the last kce working queue for.
Definition at line 790 of file gnunet-communicator-udp.c.
Referenced by consider_ss_ack(), and kce_generate_cb().
|
static |
Cache of pre-generated key IDs.
Definition at line 795 of file gnunet-communicator-udp.c.
Referenced by do_shutdown(), kce_destroy(), kce_generate(), run(), secret_destroy(), and sock_read().
|
static |
ID of read task.
Definition at line 800 of file gnunet-communicator-udp.c.
Referenced by do_shutdown(), run(), and sock_read().
|
static |
ID of timeout task.
Definition at line 805 of file gnunet-communicator-udp.c.
Referenced by check_timeouts(), do_shutdown(), mq_init(), and setup_sender().