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_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 |
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 |
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 16 |
#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 | 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) |
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 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_EcdhePublicKey *ephemeral) |
Setup shared secret for decryption. More... | |
static struct SharedSecret * | setup_shared_secret_ephemeral (struct GNUNET_CRYPTO_EcdhePublicKey *ephemeral, struct ReceiverAddress *receiver) |
Setup new shared secret for encryption using KEM. More... | |
static void | setup_receiver_mq (struct ReceiverAddress *receiver) |
Setup the MQ for the receiver. More... | |
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_PeerIdentity *pid, 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 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 | send_msg_with_kx (const struct GNUNET_MessageHeader *msg, struct ReceiverAddress *receiver) |
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_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... | |
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 55 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 60 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 65 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 70 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 77 of file gnunet-communicator-udp.c.
#define WORKING_QUEUE_INTERVALL GNUNET_TIME_relative_multiply (GNUNET_TIME_UNIT_MICROSECONDS,1) |
Definition at line 79 of file gnunet-communicator-udp.c.
#define AES_KEY_SIZE (256 / 8) |
AES key size.
Definition at line 85 of file gnunet-communicator-udp.c.
#define AES_IV_SIZE (96 / 8) |
AES (GCM) IV size.
Definition at line 90 of file gnunet-communicator-udp.c.
#define GCM_TAG_SIZE (128 / 8) |
Size of the GCM tag.
Definition at line 95 of file gnunet-communicator-udp.c.
#define GENERATE_AT_ONCE 16 |
Definition at line 97 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 108 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 116 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 127 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 138 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 144 of file gnunet-communicator-udp.c.
#define COMMUNICATOR_ADDRESS_PREFIX "udp" |
Address prefix used by the communicator.
Definition at line 150 of file gnunet-communicator-udp.c.
#define COMMUNICATOR_CONFIG_SECTION "communicator-udp" |
Configuration section used by the communicator.
Definition at line 155 of file gnunet-communicator-udp.c.
|
static |
An interface went away, stop broadcasting on it.
bi | entity to close down |
Definition at line 851 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 879 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 send_msg_with_kx().
|
static |
Free memory used by key cache entry.
kce | the key cache entry |
Definition at line 919 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(), 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 941 of file gnunet-communicator-udp.c.
References GNUNET_CRYPTO_hkdf().
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 969 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 |
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 1000 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_SCHEDULER_cancel(), GNUNET_STATISTICS_set(), GNUNET_STATISTICS_update(), GNUNET_YES, kce_destroy(), SharedSecret::kce_head, SenderAddress::kce_task, 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 mq_send_d(), purge_secrets(), send_msg_with_kx(), sock_read(), and try_handle_plaintext().
|
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 1051 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 1076 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 1107 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 1121 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 1136 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 1179 of file gnunet-communicator-udp.c.
References SharedSecret::cmac, GNUNET_CRYPTO_hkdf(), and SharedSecret::master.
Referenced by 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 1205 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 1254 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 1288 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 1322 of file gnunet-communicator-udp.c.
References calculate_cmac(), GNUNET_CRYPTO_eddsa_kem_decaps(), GNUNET_new, SharedSecret::master, and my_private_key.
Referenced by sock_read(), and try_handle_plaintext().
|
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 1341 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, SharedSecret::receiver, receiver(), and stats.
Referenced by create_rekey(), and 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 2643 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().
unsigned int purge_secrets | ( | struct SharedSecret * | ss_list_tail | ) |
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 1378 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 1406 of file gnunet-communicator-udp.c.
References ch, 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, SharedSecret::receiver, and 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 1459 of file gnunet-communicator-udp.c.
References add_acks(), UDPAck::cmac, GNUNET_assert, GNUNET_ERROR_TYPE_DEBUG, GNUNET_h2s(), GNUNET_log, GNUNET_NO, GNUNET_YES, pid, receiver(), UDPAck::sequence_ack, and value.
Referenced by enc_notify_cb(), 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 1516 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_h2s(), GNUNET_i2s_full(), GNUNET_log, GNUNET_MESSAGE_TYPE_COMMUNICATOR_UDP_ACK, 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 1551 of file gnunet-communicator-udp.c.
References SenderAddress::acks_available, consider_ss_ack(), GENERATE_AT_ONCE, GNUNET_ERROR_TYPE_DEBUG, GNUNET_h2s(), GNUNET_log, GNUNET_NO, GNUNET_SCHEDULER_add_delayed(), GNUNET_YES, kce_generate(), 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(), 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 1596 of file gnunet-communicator-udp.c.
References SenderAddress::acks_available, buf, SharedSecret::cmac, UDPRekey::ephemeral, GNUNET_CONTAINER_DLL_insert, GNUNET_CONTAINER_multipeermap_get_multiple(), GNUNET_ERROR_TYPE_DEBUG, GNUNET_ERROR_TYPE_ERROR, GNUNET_h2s(), GNUNET_log, GNUNET_MESSAGE_TYPE_COMMUNICATOR_UDP_ACK, GNUNET_MESSAGE_TYPE_COMMUNICATOR_UDP_PAD, GNUNET_MESSAGE_TYPE_COMMUNICATOR_UDP_REKEY, GNUNET_SCHEDULER_add_delayed(), GNUNET_YES, handle_ack(), kce_generate_cb(), SenderAddress::kce_send_ack_on_finish, SenderAddress::kce_task, 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, SenderAddress::target, GNUNET_MessageHeader::type, type, and WORKING_QUEUE_INTERVALL.
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 1698 of file gnunet-communicator-udp.c.
References SenderAddress::acks_available, 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::sender, KeyCacheEntry::sequence_number, KeyCacheEntry::ss, stats, try_decrypt(), and try_handle_plaintext().
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 1781 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 1810 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 1861 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 1890 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 1924 of file gnunet-communicator-udp.c.
References SenderAddress::acks_available, ah, buf, calculate_cmac(), decrypt_box(), 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_now(), 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, kce_generate_cb(), SenderAddress::kce_send_ack_on_finish, SenderAddress::kce_task, SenderAddress::kce_task_finished, KCN_THRESHOLD, key_cache, UDPBox::kid, MAX_SECRETS, my_identity, nt, GNUNET_PeerIdentity::public_key, purge_secrets(), GNUNET_CRYPTO_EccSignaturePurpose::purpose, UdpBroadcastSignature::purpose, read_task, secret_destroy(), UDPConfirmation::sender, UDPBroadcast::sender, UdpBroadcastSignature::sender, SharedSecret::sender, UDPBroadcast::sender_sig, setup_sender(), setup_shared_secret_dec(), GNUNET_CRYPTO_EccSignaturePurpose::size, sockaddr_to_udpaddr_string(), 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 2140 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 2275 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 2295 of file gnunet-communicator-udp.c.
References cfg, do_pad(), InitialKX::ephemeral, UdpHandshakeSignature::ephemeral, InitialKX::gcm_tag, GNUNET_a2s(), GNUNET_assert, GNUNET_break, GNUNET_CRYPTO_eddsa_sign, GNUNET_ERROR_TYPE_DEBUG, GNUNET_ERROR_TYPE_WARNING, GNUNET_log, GNUNET_log_strerror, 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, msg, my_identity, my_private_key, purge_secrets(), GNUNET_CRYPTO_EccSignaturePurpose::purpose, UdpHandshakeSignature::purpose, UdpHandshakeSignature::receiver, receiver(), receiver_destroy(), reschedule_receiver_timeout(), secret_destroy(), UdpHandshakeSignature::sender, setup_cipher(), setup_shared_secret_ephemeral(), GNUNET_MessageHeader::size, GNUNET_CRYPTO_EccSignaturePurpose::size, uc, and udp_sock.
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 2386 of file gnunet-communicator-udp.c.
References GNUNET_assert, GNUNET_MQ_impl_send_continue(), mq, msg, receiver(), and send_msg_with_kx().
Referenced by setup_receiver_mq().
|
static |
Definition at line 2399 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_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 2431 of file gnunet-communicator-udp.c.
References SharedSecret::bytes_sent, create_rekey(), do_pad(), UDPBox::gcm_tag, get_kid(), GNUNET_assert, GNUNET_break, GNUNET_ERROR_TYPE_DEBUG, GNUNET_ERROR_TYPE_ERROR, GNUNET_ERROR_TYPE_WARNING, GNUNET_h2s(), GNUNET_log, GNUNET_log_strerror, GNUNET_MQ_impl_send_continue(), GNUNET_NETWORK_socket_sendto(), GNUNET_NO, 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(), 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 2562 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 2585 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 2606 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 2623 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 2724 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 2781 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 2803 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 2824 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 2912 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 2950 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 2992 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 3085 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 3195 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 3216 of file gnunet-communicator-udp.c.
References GNUNET_ERROR_TYPE_INFO, and GNUNET_log.
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 3235 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 3418 of file gnunet-communicator-udp.c.
|
static |
|
static |
How often we do rekey based on number of bytes transmitted.
Definition at line 737 of file gnunet-communicator-udp.c.
Referenced by mq_send_d(), and run().
|
static |
Cache of pre-generated key IDs.
Definition at line 742 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 747 of file gnunet-communicator-udp.c.
Referenced by do_shutdown(), run(), and sock_read().
|
static |
ID of timeout task.
Definition at line 752 of file gnunet-communicator-udp.c.
Referenced by check_timeouts(), do_shutdown(), mq_init(), and setup_sender().
|
static |
ID of master broadcast task.
Definition at line 757 of file gnunet-communicator-udp.c.
Referenced by do_broadcast(), do_shutdown(), and run().
|
static |
For logging statistics.
Definition at line 762 of file gnunet-communicator-udp.c.
Referenced by decrypt_box(), do_shutdown(), kce_generate(), mq_init(), pass_plaintext_to_core(), receiver_destroy(), run(), secret_destroy(), sender_destroy(), setup_sender(), setup_shared_secret_ephemeral(), sock_read(), and try_decrypt().
|
static |
Our environment.
Definition at line 767 of file gnunet-communicator-udp.c.
Referenced by add_acks(), consider_ss_ack(), do_shutdown(), nat_address_cb(), pass_plaintext_to_core(), run(), and setup_receiver_mq().
|
static |
Receivers (map from peer identity to struct ReceiverAddress
)
Definition at line 772 of file gnunet-communicator-udp.c.
Referenced by do_shutdown(), enc_notify_cb(), mq_init(), receiver_destroy(), run(), setup_sender(), and try_handle_plaintext().
|
static |
Senders (map from peer identity to struct SenderAddress
)
Definition at line 777 of file gnunet-communicator-udp.c.
Referenced by do_shutdown(), run(), sender_destroy(), and setup_sender().
|
static |
Expiration heap for senders (contains struct SenderAddress
)
Definition at line 782 of file gnunet-communicator-udp.c.
Referenced by check_timeouts(), do_shutdown(), run(), and setup_sender().
|
static |
Expiration heap for receivers (contains struct ReceiverAddress
)
Definition at line 787 of file gnunet-communicator-udp.c.
Referenced by check_timeouts(), do_shutdown(), mq_init(), and run().
|
static |
Broadcast interface tasks.
Kept in a DLL.
Definition at line 792 of file gnunet-communicator-udp.c.
Referenced by bi_destroy(), do_broadcast(), do_shutdown(), and iface_proc().
|
static |
Broadcast interface tasks.
Kept in a DLL.
Definition at line 797 of file gnunet-communicator-udp.c.
Referenced by bi_destroy(), and iface_proc().
|
static |
Our socket.
Definition at line 802 of file gnunet-communicator-udp.c.
Referenced by bi_destroy(), do_shutdown(), iface_proc(), ifc_broadcast(), mq_send_d(), run(), send_msg_with_kx(), and sock_read().
|
static |
GNUNET_YES if udp_sock supports IPv6.
Definition at line 807 of file gnunet-communicator-udp.c.
Referenced by iface_proc(), and run().
|
static |
Our public key.
Definition at line 807 of file gnunet-communicator-udp.c.
Referenced by iface_proc(), run(), send_msg_with_kx(), sock_read(), and verify_confirmation().
|
static |
Our private key.
Definition at line 817 of file gnunet-communicator-udp.c.
Referenced by do_shutdown(), iface_proc(), run(), send_msg_with_kx(), and setup_shared_secret_dec().
|
static |
Our configuration.
Definition at line 822 of file gnunet-communicator-udp.c.
Referenced by run(), send_msg_with_kx(), and udp_address_to_sockaddr().
|
static |
Our handle to report addresses for validation to TRANSPORT.
Definition at line 827 of file gnunet-communicator-udp.c.
Referenced by do_shutdown(), run(), and sock_read().
|
static |
Network scanner to determine network types.
Definition at line 832 of file gnunet-communicator-udp.c.
Referenced by do_shutdown(), iface_proc(), mq_init(), nat_address_cb(), run(), setup_sender(), and sock_read().
|
static |
Connection to NAT service.
Definition at line 837 of file gnunet-communicator-udp.c.
Referenced by do_shutdown(), and run().
|
static |
Port number to which we are actually bound.
Definition at line 842 of file gnunet-communicator-udp.c.
Referenced by ifc_broadcast(), and run().