47 #define ADDRESS_VALIDITY_PERIOD \ 48 GNUNET_TIME_relative_multiply (GNUNET_TIME_UNIT_HOURS, 4) 58 #define DEFAULT_MAX_QUEUE_LENGTH 8 64 #define BUF_SIZE (2 * 64 * 1024 + sizeof(struct TCPBox)) 69 #define DEFAULT_REKEY_INTERVAL GNUNET_TIME_UNIT_DAYS 74 #define PROTO_QUEUE_TIMEOUT GNUNET_TIME_UNIT_MINUTES 80 #define REKEY_MAX_BYTES (1024LLU * 1024 * 1024 * 4LLU) 86 #define INITIAL_KX_SIZE \ 87 (sizeof(struct GNUNET_CRYPTO_EcdhePublicKey) \ 88 + sizeof(struct TCPConfirmation)) 93 #define INITIAL_CORE_KX_SIZE \ 94 (sizeof(struct EphemeralKeyMessage) \ 95 + sizeof(struct PingMessage) \ 96 + sizeof(struct PongMessage)) 101 #define COMMUNICATOR_ADDRESS_PREFIX "tcp" 106 #define COMMUNICATOR_CONFIG_SECTION "communicator-tcp" 493 char pread_buf[UINT16_MAX + 1 +
sizeof(
struct TCPBox)];
498 char pwrite_buf[UINT16_MAX + 1 +
sizeof(
struct TCPBox)];
884 "Disconnecting queue for peer `%s'\n",
916 if (NULL != queue->
qh)
941 "closing socket failed\n");
954 "add read net listen\n");
1007 memset (&fin, 0,
sizeof(fin));
1014 memcpy (queue->
pwrite_buf, &fin,
sizeof(fin));
1061 "# messages lost in communicator API towards CORE",
1068 "backpressure %u\n",
1104 const void *plaintext,
1105 size_t plaintext_len)
1110 if (ntohs (hdr->
size) != plaintext_len)
1128 "# bytes lost due to CORE not running",
1146 gcry_cipher_hd_t *cipher,
1152 gcry_cipher_open (cipher,
1153 GCRY_CIPHER_AES256 ,
1154 GCRY_CIPHER_MODE_CTR,
1166 gcry_cipher_setkey (*cipher, key,
sizeof(key));
1177 gcry_cipher_setctr (*cipher, ctr,
sizeof(ctr));
1182 strlen (
"TCP-hmac"),
1220 "Failed to store rekey monotonic time in PEERSTORE!\n");
1257 mtbe = record->
value;
1263 "Queue from %s dropped, rekey monotime in the past\n",
1270 "transport_tcp_communicator",
1273 rekey_monotonic_time,
1274 sizeof(rekey_monotonic_time),
1297 "do_rekey size %u\n",
1332 "transport_tcp_communicator",
1355 "Failed to store handshake ack monotonic time in PEERSTORE!\n");
1392 mtbe = record->
value;
1398 "Queue from %s dropped, handshake ack monotime in the past\n",
1405 "transport_tcp_communicator",
1408 handshake_ack_monotonic_time,
1410 handshake_ack_monotonic_time),
1444 "try handle plaintext!\n");
1449 "Handling plaintext, not even a header!\n");
1469 "start processing ack\n");
1473 "Handling plaintext size of tca greater than pread offset.\n");
1476 if (ntohs (hdr->
size) !=
sizeof(*tca))
1479 "Handling plaintext size does not match message type.\n");
1485 thas.purpose.purpose = htonl (
1487 thas.purpose.size = htonl (
sizeof(thas));
1488 thas.sender = tca->sender;
1490 thas.monotonic_time = tca->monotonic_time;
1491 thas.challenge = tca->challenge;
1497 &tca->sender.public_key))
1500 "Verification of signature failed!\n");
1508 "Challenge in TCPConfirmationAck not correct!\n");
1515 "transport_tcp_communicator",
1523 "Handling plaintext, ack processed!");
1568 if (0 != memcmp (&tmac, &box->
hmac,
sizeof(tmac)))
1575 size = ntohs (hdr->
size) +
sizeof(*box);
1577 "Handling plaintext, box processed!\n");
1583 if (ntohs (hdr->
size) !=
sizeof(*rekey))
1590 memset (&rekeyz.hmac, 0,
sizeof(rekeyz.hmac));
1592 if (0 != memcmp (&tmac, &rekey->hmac,
sizeof(tmac)))
1601 "Handling plaintext, rekey processed!\n");
1607 if (ntohs (hdr->
size) !=
sizeof(*fin))
1614 memset (&finz.hmac, 0,
sizeof(finz.hmac));
1616 if (0 != memcmp (&tmac, &fin->
hmac,
sizeof(tmac)))
1625 "Handling plaintext, finish processed!\n");
1630 "Handling plaintext, nothing processed!\n");
1659 "Received %lu bytes from TCP queue\n", rcvd);
1662 if ((EAGAIN != errno) && (EINTR != errno))
1684 size_t old_pread_off = queue->
pread_off;
1719 max = total - old_pread_off;
1741 "Queue %p was idle for %s, disconnecting\n",
1756 static struct sockaddr *
1760 struct sockaddr *in;
1762 v6.sin6_family = AF_INET6;
1763 v6.sin6_port = htons ((uint16_t) port);
1764 #if HAVE_SOCKADDR_IN_SIN_LEN 1765 v6.sin6_len =
sizeof(
sizeof(
struct sockaddr_in6));
1767 v6.sin6_flowinfo = 0;
1768 v6.sin6_scope_id = 0;
1770 *sock_len =
sizeof(
struct sockaddr_in6);
1782 static struct sockaddr *
1786 struct sockaddr *in;
1788 v4.sin_family = AF_INET;
1789 v4.sin_port = htons ((uint16_t) port);
1790 #if HAVE_SOCKADDR_IN_SIN_LEN 1791 v4.sin_len =
sizeof(
struct sockaddr_in);
1794 *sock_len =
sizeof(
struct sockaddr_in);
1808 struct sockaddr_in *i4;
1809 struct sockaddr_in6 *i6;
1810 socklen_t sock_len_ipv4;
1811 socklen_t sock_len_ipv6;
1814 if (*port > UINT16_MAX)
1817 "BINDTO specification `%s' invalid: value too large for port\n",
1873 "extract address with bindto %s\n",
1878 "bindto is NULL\n");
1883 "extract address 2\n");
1886 if ((
'[' == *cp) && (
']' == cp[strlen (cp) - 1]))
1889 cp[strlen (cp) - 1] =
'\0';
1892 token = strtok_r (cp,
"]", &rest);
1893 if (strlen (bindto) == strlen (token))
1895 token = strtok_r (cp,
":", &rest);
1905 "extract address 3\n");
1907 "extract address with start %s\n",
1930 if (NULL != addr_and_port)
1933 token = strtok_r (cp,
"]", &rest);
1934 if (strlen (addr_and_port) == strlen (token))
1936 colon = strrchr (cp,
':');
1946 token = strtok_r (NULL,
"]", &rest);
1959 if (1 == sscanf (addr,
"%u%1s", &port, dummy))
1962 if (port > UINT16_MAX)
1965 "Port `%u' invalid: value too large for port\n",
1974 "BINDTO specification invalid: last ':' not followed by number\n");
1998 static struct sockaddr *
2001 struct sockaddr *in;
2003 struct sockaddr_in v4;
2004 struct sockaddr_in6 v6;
2020 if (1 == inet_pton (AF_INET, start, &v4.sin_addr))
2031 else if (1 == inet_pton (AF_INET6, start, &v6.sin6_addr))
2081 memset (&rekey, 0,
sizeof(rekey));
2091 "inject_rekey size %u\n",
2147 "Sent %lu bytes to TCP queue\n", sent);
2148 if ((-1 == sent) && (EAGAIN != errno) && (EINTR != errno))
2156 size_t usent = (size_t) sent;
2171 "Encrypting %lu bytes\n", queue->
pwrite_off);
2204 "Finishing queue\n");
2232 uint16_t msize = ntohs (msg->
size);
2235 "In MQ send. Queue finishing: %s; write task running: %s\n",
2251 "%lu bytes of plaintext to send\n", queue->
pwrite_off);
2275 if (mq == queue->
mq)
2314 "MQ error in queue to %s: %d\n",
2354 switch (queue->
address->sa_family)
2404 memcpy (queue->
cwrite_buf, epub,
sizeof(*epub));
2434 "handshake written\n");
2468 "Failed to store handshake monotonic time in PEERSTORE!\n");
2505 mtbe = record->
value;
2511 "Queue from %s dropped, handshake monotime in the past\n",
2518 "transport_tcp_communicator",
2521 handshake_monotonic_time,
2523 handshake_monotonic_time),
2569 "transport_tcp_communicator",
2611 "sending challenge\n");
2665 "Received %lu bytes for KX\n", rcvd);
2668 if ((EAGAIN != errno) && (EINTR != errno))
2694 "Invalid TCP KX received from %s\n",
2709 "start kx proto\n");
2742 struct sockaddr_storage in;
2755 addrlen =
sizeof(in);
2756 memset (&in, 0,
sizeof(in));
2758 (
struct sockaddr*) &in,
2760 if ((NULL == sock) && ((EMFILE == errno) || (ENFILE == errno)))
2766 if ((NULL == sock) && ((EAGAIN == errno) || (ENOBUFS == errno)))
2812 "Received %lu bytes for KX\n",
2816 if ((EAGAIN != errno) && (EINTR != errno))
2841 "Invalid TCP KX received from %s\n",
2850 "Invalid sender in TCP KX received from %s\n",
2863 "cread_off is %lu bytes before adjusting\n",
2867 "cread_off set to %lu bytes\n",
2896 struct sockaddr *in;
2897 socklen_t in_len = 0;
2901 "Connecting to %s\n", address);
2902 if (0 != strncmp (address,
2915 "Failed to setup TCP socket address\n");
2927 "socket(%d) failed: %s",
2934 (errno != EINPROGRESS))
2937 "connect to `%s' failed: %s",
2961 "start kx mq_init\n");
3040 while (NULL != proto_head)
3061 if (NULL != my_private_key)
3064 my_private_key = NULL;
3071 if (NULL != peerstore)
3076 if (NULL != resolve_request_handle)
3079 resolve_request_handle = NULL;
3082 "Shutdown done!\n");
3127 const struct sockaddr *addr,
3134 "nat address cb %s %s\n",
3135 add_remove ?
"add" :
"remove",
3182 "after add address %s\n",
3203 struct sockaddr_storage in_sto;
3212 "Address is NULL.\n");
3222 if (NULL == listen_sock)
3249 sto_len =
sizeof(in_sto);
3252 (
struct sockaddr *) &in_sto,
3255 memcpy (&in_sto, addr, in_len);
3263 GNUNET_a2s ((
const struct sockaddr *) &in_sto, sto_len));
3269 if (NULL == my_private_key)
3271 if (NULL == my_private_key)
3276 "Transport service is lacking key configuration settings. Exiting.\n"));
3277 if (NULL != resolve_request_handle)
3305 "creating map entry\n");
3312 "map entry created\n");
3314 if (NULL == queue_map)
3330 if (NULL != resolve_request_handle)
3348 struct sockaddr **saddrs;
3349 socklen_t *saddr_lens;
3355 "starting nat register!\n");
3362 for (pos = addrs_head; NULL != pos; pos = pos->
next)
3366 "registering address %s\n",
3369 saddr_lens[i] = addrs_head->
addr_len;
3380 (
const struct sockaddr **) saddrs,
3396 if (NULL != resolve_request_handle)
3411 const struct sockaddr *
addr,
3414 struct sockaddr_in *v4;
3415 struct sockaddr_in6 *v6;
3416 struct sockaddr *in;
3421 if (AF_INET == addr->sa_family)
3423 v4 = (
struct sockaddr_in *) addr;
3426 else if (AF_INET6 == addr->sa_family)
3428 v6 = (
struct sockaddr_in6 *) addr;
3434 "Address family %u not suitable (not AF_INET %u nor AF_INET6 %u \n",
3445 "Address is NULL. This might be an error or the resolver finished resolving.\n");
3446 if (NULL == addrs_head)
3449 "Resolver finished resolving, but we do not listen to an address!.\n");
3468 const char *cfgfile,
3472 struct sockaddr *in;
3474 struct sockaddr_in v4;
3475 struct sockaddr_in6 v6;
3511 if (NULL == peerstore)
3520 if (1 == sscanf (bindto,
"%u%1s", &
bind_port, dummy))
3551 if (1 == inet_pton (AF_INET, start, &v4.sin_addr))
3563 if (1 == inet_pton (AF_INET6, start, &v6.sin6_addr))
3607 "gnunet-communicator-tcp",
3608 _ (
"GNUnet TCP communicator"),
#define GNUNET_SIGNATURE_COMMUNICATOR_TCP_HANDSHAKE
Signature used by TCP communicator handshake,.
In case of port only configuration we like to bind to ipv4 and ipv6 addresses.
#define GNUNET_CONTAINER_DLL_remove(head, tail, element)
Remove an element from a DLL.
int GNUNET_NETWORK_socket_listen(const struct GNUNET_NETWORK_Handle *desc, int backlog)
Listen on a socket.
void GNUNET_TRANSPORT_communicator_address_remove_all(struct GNUNET_TRANSPORT_CommunicatorHandle *ch)
Notify transport service that this communicator no longer provides all its addresses for this peer...
#define COMMUNICATOR_CONFIG_SECTION
Configuration section used by the communicator.
static void queue(const char *hostname)
Add hostname to the list of requests to be made.
Handle to the interface scanner.
int rekeyed
GNUNET_YES if we just rekeyed and must thus possibly re-decrypt ciphertext.
char ibuf[(sizeof(struct GNUNET_CRYPTO_EcdhePublicKey)+sizeof(struct TCPConfirmation))]
Buffer for reading all the information we need to upgrade from protoqueue to queue.
static void listen_cb(void *cls)
We have been notified that our listen socket has something to read.
static int get_lt_delete_it(void *cls, const struct GNUNET_HashCode *key, void *value)
Iterator over all ListenTasks to clean up.
Transmission is reliabile (with ACKs), i.e.
int GNUNET_NETWORK_get_fd(const struct GNUNET_NETWORK_Handle *desc)
Return file descriptor for this network handle.
static void setup_in_cipher(const struct GNUNET_CRYPTO_EcdhePublicKey *ephemeral, struct Queue *queue)
Setup cipher of queue for decryption.
static void queue_read_kx(void *cls)
Read from the socket of the queue until we have enough data to initialize the decryption logic and ca...
char cread_buf[(2 *64 *1024+sizeof(struct TCPBox))]
Buffer for reading ciphertext from network into.
static void init_socket_resolv(void *cls, const struct sockaddr *addr, socklen_t in_len)
This method is the callback called by the resolver API, and wraps method init_socket.
enum GNUNET_NetworkType GNUNET_NT_scanner_get_type(struct GNUNET_NT_InterfaceScanner *is, const struct sockaddr *addr, socklen_t addrlen)
Returns where the address is located: loopback, LAN or WANT.
struct GNUNET_PEERSTORE_IterateContext * handshake_monotime_get
Iteration Context for retrieving the monotonic time send with the handshake.
struct sockaddr * addr_ipv4
Ipv4 address we like to bind to.
Handle for active NAT registrations.
struct GNUNET_CRYPTO_EccSignaturePurpose purpose
Purpose must be GNUNET_SIGNATURE_COMMUNICATOR_TCP_HANDSHAKE_ACK.
struct GNUNET_MessageHeader * msg
struct GNUNET_PeerIdentity target
To whom are we talking to.
void GNUNET_RESOLVER_request_cancel(struct GNUNET_RESOLVER_RequestHandle *rh)
Cancel a request that is still pending with the resolver.
struct GNUNET_TIME_Absolute GNUNET_TIME_absolute_ntoh(struct GNUNET_TIME_AbsoluteNBO a)
Convert absolute time from network byte order.
enum GNUNET_GenericReturnValue GNUNET_PROGRAM_run(int argc, char *const *argv, const char *binaryName, const char *binaryHelp, const struct GNUNET_GETOPT_CommandLineOption *options, GNUNET_PROGRAM_Main task, void *task_cls)
Run a standard GNUnet command startup sequence (initialize loggers and configuration, parse options).
static void handshake_monotime_cb(void *cls, const struct GNUNET_PEERSTORE_Record *record, const char *emsg)
Callback called by peerstore when records for GNUNET_PEERSTORE_TRANSPORT_TCP_COMMUNICATOR_HANDSHAKE w...
GNUNET_NAT_AddressClass
Some addresses contain sensitive information or are not suitable for global distribution.
static void core_read_finished_cb(void *cls, int success)
Core tells us it is done processing a message that transport received on a queue with status success...
uint64_t rel_value_us
The actual value.
int main(int argc, char *const *argv)
The main function for the UNIX communicator.
struct GNUNET_NETWORK_Handle * listen_sock
Listen socket.
#define GNUNET_CRYPTO_eddsa_sign(priv, ps, sig)
EdDSA sign a given block.
static struct GNUNET_NAT_Handle * nat
Connection to NAT service.
int finishing
Did we enqueue a finish message and are closing down the queue?
struct GNUNET_HashCode in_hmac
Shared secret for HMAC verification on incoming data.
struct GNUNET_PeerIdentity sender
Identity of the inititor of the TCP connection (TCP client).
#define GNUNET_CONTAINER_DLL_insert(head, tail, element)
Insert an element at the head of a DLL.
socklen_t address_len
Length of the address.
ssize_t GNUNET_NETWORK_socket_send(const struct GNUNET_NETWORK_Handle *desc, const void *buffer, size_t length)
Send data (always non-blocking).
static struct GNUNET_PeerIdentity my_identity
Our public key.
uint32_t purpose
What does this signature vouch for? This must contain a GNUNET_SIGNATURE_PURPOSE_XXX constant (from g...
size_t cread_off
At which offset in the ciphertext read buffer should we append more ciphertext for transmission next...
struct GNUNET_TRANSPORT_AddressIdentifier * GNUNET_TRANSPORT_communicator_address_add(struct GNUNET_TRANSPORT_CommunicatorHandle *ch, const char *address, enum GNUNET_NetworkType nt, struct GNUNET_TIME_Relative expiration)
Notify transport service about an address that this communicator provides for this peer...
static void run(void *cls, char *const *args, const char *cfgfile, const struct GNUNET_CONFIGURATION_Handle *c)
Setup communicator and launch network interactions.
struct GNUNET_CRYPTO_EcdhePublicKey ephemeral
Ephemeral key used by the sender.
void GNUNET_CRYPTO_hmac_raw(const void *key, size_t key_len, const void *plaintext, size_t plaintext_len, struct GNUNET_HashCode *hmac)
Calculate HMAC of a message (RFC 2104) TODO: Shouldn' this be the standard hmac function and the abov...
struct GNUNET_PeerIdentity sender
Sender's identity.
Delete any previous values for the given key before storing the given value.
GNUNET_MQ_Error
Error codes for the queue.
uint64_t GNUNET_CRYPTO_random_u64(enum GNUNET_CRYPTO_Quality mode, uint64_t max)
Random on unsigned 64-bit values.
#define GNUNET_MESSAGE_TYPE_COMMUNICATOR_TCP_CONFIRMATION_ACK
TCP communicator confirmation ack.
struct GNUNET_PEERSTORE_IterateContext * GNUNET_PEERSTORE_iterate(struct GNUNET_PEERSTORE_Handle *h, const char *sub_system, const struct GNUNET_PeerIdentity *peer, const char *key, GNUNET_PEERSTORE_Processor callback, void *callback_cls)
Iterate over records matching supplied key information.
struct GNUNET_SCHEDULER_Task * GNUNET_SCHEDULER_add_shutdown(GNUNET_SCHEDULER_TaskCallback task, void *task_cls)
Schedule a new task to be run on shutdown, that is when a CTRL-C signal is received, or when GNUNET_SCHEDULER_shutdown() is being invoked.
DLL to store the addresses we like to register at NAT service.
struct GNUNET_CRYPTO_EddsaSignature sender_sig
Sender's signature of type GNUNET_SIGNATURE_COMMUNICATOR_TCP_HANDSHAKE.
struct GNUNET_PEERSTORE_StoreContext * handshake_monotime_sc
Store Context for retrieving the monotonic time send with the handshake.
#define GNUNET_TIME_UNIT_MINUTES
One minute.
unsigned int backpressure
How may messages did we pass from this queue to CORE for which we have yet to receive an acknoweldgem...
ssize_t GNUNET_NETWORK_socket_recv(const struct GNUNET_NETWORK_Handle *desc, void *buffer, size_t length)
Read data from a connected socket (always non-blocking).
unsigned int bind_port
The port the communicator should be assigned to.
struct GNUNET_SCHEDULER_Task * read_task
ID of read task for this connection.
#define GNUNET_SIGNATURE_COMMUNICATOR_TCP_REKEY
Signature used by TCP communicator rekey.
int destroyed
Did we technically destroy this queue, but kept the allocation around because of backpressure not bei...
struct GNUNET_STATISTICS_Handle * GNUNET_STATISTICS_create(const char *subsystem, const struct GNUNET_CONFIGURATION_Handle *cfg)
Get handle for the statistics service.
struct ChallengeNonceP challenge
Challenge value used to protect against replay attack, if there is no stored monotonic time value...
static int start
Set if we are to start default services (including ARM).
size_t value_size
Size of value BLOB.
int GNUNET_STRINGS_get_utf8_args(int argc, char *const *argv, int *u8argc, char *const **u8argv)
Returns utf-8 encoded arguments.
struct GNUNET_TIME_Absolute GNUNET_TIME_relative_to_absolute(struct GNUNET_TIME_Relative rel)
Convert relative time to an absolute time in the future.
struct ListenTask * lts_tail
Head of DLL with ListenTask.
#define GNUNET_MESSAGE_TYPE_COMMUNICATOR_TCP_REKEY
TCP communicator rekey message.
#define GNUNET_assert(cond)
Use this for fatal errors that cannot be handled.
static void proto_read_kx(void *cls)
Read from the socket of the proto queue until we have enough data to upgrade to full queue...
static struct GNUNET_SCHEDULER_TaskContext tc
Task context of the current task.
struct ChallengeNonceP challenge
Challenge value used to protect against replay attack, if there is no stored monotonic time value...
uint64_t rekey_left_bytes
How many more bytes may we sent with the current out_cipher before we should rekey?
#define BUF_SIZE
Size of our IO buffers for ciphertext data.
struct GNUNET_MessageHeader header
Type is GNUNET_MESSAGE_TYPE_COMMUNICATOR_TCP_CONFIRMATION_ACK.
int GNUNET_NETWORK_socket_bind(struct GNUNET_NETWORK_Handle *desc, const struct sockaddr *address, socklen_t address_len)
Bind a socket to a particular address.
#define PROTO_QUEUE_TIMEOUT
How long do we wait until we must have received the initial KX?
struct GNUNET_SCHEDULER_Task * GNUNET_SCHEDULER_add_write_net(struct GNUNET_TIME_Relative delay, struct GNUNET_NETWORK_Handle *wfd, GNUNET_SCHEDULER_TaskCallback task, void *task_cls)
Schedule a new task to be run with a specified delay or when the specified file descriptor is ready f...
static int ret
Return value of the commandline.
static void pass_plaintext_to_core(struct Queue *queue, const void *plaintext, size_t plaintext_len)
We received plaintext_len bytes of plaintext on queue.
enum GNUNET_GenericReturnValue GNUNET_CONFIGURATION_get_value_number(const struct GNUNET_CONFIGURATION_Handle *cfg, const char *section, const char *option, unsigned long long *number)
Get a configuration value that should be a number.
static struct PortOnlyIpv4Ipv6 * tcp_address_to_sockaddr_port_only(const char *bindto, unsigned int *port)
Convert TCP bind specification to a struct PortOnlyIpv4Ipv6 *
int GNUNET_CONTAINER_multipeermap_remove(struct GNUNET_CONTAINER_MultiPeerMap *map, const struct GNUNET_PeerIdentity *key, const void *value)
Remove the given key-value pair from the map.
struct GNUNET_TIME_Absolute rekey_time
Until what time may we sent with the current out_cipher before we should rekey?
int addrs_lens
Number of addresses in the DLL for register at NAT service.
struct GNUNET_RESOLVER_RequestHandle * GNUNET_RESOLVER_ip_get(const char *hostname, int af, struct GNUNET_TIME_Relative timeout, GNUNET_RESOLVER_AddressCallback callback, void *callback_cls)
Convert a string to one or more IP addresses.
#define GNUNET_memdup(buf, size)
Allocate and initialize a block of memory.
static void transmit_kx(struct Queue *queue, const struct GNUNET_CRYPTO_EcdhePublicKey *epub)
Generate and transmit our ephemeral key and the signature for the initial KX with the other peer...
socklen_t addr_len_ipv4
Length of ipv4 address.
static struct GNUNET_NT_InterfaceScanner * is
Network scanner to determine network types.
struct GNUNET_CRYPTO_EcdhePrivateKey ephemeral
Our ephemeral key.
#define GNUNET_new(type)
Allocate a struct or union of the given type.
Definition of a command line option.
#define GNUNET_PEERSTORE_TRANSPORT_TCP_COMMUNICATOR_REKEY
Key used to store sender's monotonic time from rekey message.
#define GNUNET_MESSAGE_TYPE_COMMUNICATOR_TCP_BOX
TCP communicator payload box.
#define GNUNET_PEERSTORE_TRANSPORT_TCP_COMMUNICATOR_HANDSHAKE
Key used to store sender's monotonic time from handshake message.
struct GNUNET_RESOLVER_RequestHandle * resolve_request_handle
Handle for DNS lookup of bindto address.
struct GNUNET_TIME_AbsoluteNBO monotonic_time
Monotonic time of sender, to possibly help detect replay attacks (if receiver persists times by sende...
static void calculate_hmac(struct GNUNET_HashCode *hmac_secret, const void *buf, size_t buf_size, struct GNUNET_ShortHashCode *smac)
Compute mac over buf, and ratched the hmac_secret.
struct GNUNET_SCHEDULER_Task * listen_task
ID of listen task.
void GNUNET_STATISTICS_destroy(struct GNUNET_STATISTICS_Handle *h, int sync_first)
Destroy a handle (free all state associated with it).
void GNUNET_STATISTICS_update(struct GNUNET_STATISTICS_Handle *handle, const char *name, int64_t delta, int make_persistent)
Set statistic value for the peer.
struct GNUNET_CONTAINER_MultiPeerMap * GNUNET_CONTAINER_multipeermap_create(unsigned int len, int do_not_copy_keys)
Create a multi peer map (hash map for public keys of peers).
void GNUNET_SCHEDULER_shutdown(void)
Request the shutdown of a scheduler.
static void queue_read(void *cls)
Queue read task.
#define GNUNET_CRYPTO_eddsa_verify(purp, ps, sig, pub)
Verify EdDSA signature.
enum GNUNET_GenericReturnValue GNUNET_CONFIGURATION_get_value_string(const struct GNUNET_CONFIGURATION_Handle *cfg, const char *section, const char *option, char **value)
Get a configuration value that should be a string.
#define GNUNET_strdup(a)
Wrapper around GNUNET_xstrdup_.
static void rekey_monotime_store_cb(void *cls, int success)
Callback called when peerstore store operation for rekey monotime value is finished.
Time for absolute time used by GNUnet, in microseconds and in network byte order. ...
uint64_t abs_value_us
The actual value.
static struct GNUNET_PEERSTORE_Handle * peerstore
Size of data received without KX challenge played back.
struct GNUNET_MQ_Handle * mq
Message queue we are providing for the ch.
Internal representation of the hash map.
GNUNET_NetworkType
Types of networks (with separate quotas) we support.
Handle for an incoming connection where we do not yet have enough information to setup a full queue...
#define GNUNET_break(cond)
Use this for internal assertion violations that are not fatal (can be handled) but should not occur...
struct GNUNET_GETOPT_CommandLineOption GNUNET_GETOPT_OPTION_END
struct Addresses * prev
Kept in a DLL.
#define GNUNET_NETWORK_STRUCT_BEGIN
Define as empty, GNUNET_PACKED should suffice, but this won't work on W32.
struct GNUNET_TIME_AbsoluteNBO monotonic_time
Monotonic time of sender, to possibly help detect replay attacks (if receiver persists times by sende...
void GNUNET_CONTAINER_multipeermap_destroy(struct GNUNET_CONTAINER_MultiPeerMap *map)
Destroy a hash map.
static void inject_rekey(struct Queue *queue)
Inject a struct TCPRekey message into the queue's plaintext buffer.
struct GNUNET_PeerIdentity sender
Identity of the inititor of the TCP connection (TCP client).
struct GNUNET_TIME_AbsoluteNBO monotonic_time
Monotonic time of sender, to possibly help detect replay attacks (if receiver persists times by sende...
Opaque handle to the transport service for communicators.
#define GNUNET_TIME_UNIT_FOREVER_ABS
Constant used to specify "forever".
void * GNUNET_CONTAINER_multihashmap_get(const struct GNUNET_CONTAINER_MultiHashMap *map, const struct GNUNET_HashCode *key)
Given a key find a value in the map matching the key.
void GNUNET_TRANSPORT_communicator_disconnect(struct GNUNET_TRANSPORT_CommunicatorHandle *ch)
Disconnect from the transport service.
static int decrypt_and_check_tc(struct Queue *queue, struct TCPConfirmation *tc, char *ibuf)
We have received the first bytes from the other side on a queue.
Signature we use to verify that the ack from the receiver of the ephemeral key was really send by the...
struct GNUNET_PeerIdentity sender
Identity of the inititor of the TCP connection (TCP client).
struct GNUNET_NETWORK_Handle * GNUNET_NETWORK_socket_accept(const struct GNUNET_NETWORK_Handle *desc, struct sockaddr *address, socklen_t *address_len)
Accept a new connection on a socket.
Signature we use to verify that the ephemeral key was really chosen by the specified sender...
header of what an ECC signature signs this must be followed by "size - 8" bytes of the actual signed ...
static struct GNUNET_TIME_Relative rekey_interval
The rekey interval.
static unsigned long long max_queue_length
Maximum queue length before we stop reading towards the transport service.
void GNUNET_TRANSPORT_communicator_mq_del(struct GNUNET_TRANSPORT_QueueHandle *qh)
Notify transport service that an MQ became unavailable due to a disconnect or timeout.
#define INITIAL_KX_SIZE
Size of the initial key exchange message sent first in both directions.
struct GNUNET_HashCode out_hmac
Shared secret for HMAC generation on outgoing data, ratcheted after each operation.
#define GNUNET_log_strerror(level, cmd)
Log an error message at log-level 'level' that indicates a failure of the command 'cmd' with the mess...
void GNUNET_CRYPTO_ecdhe_key_create(struct GNUNET_CRYPTO_EcdhePrivateKey *pk)
Create a new private key.
static void enc_notify_cb(void *cls, const struct GNUNET_PeerIdentity *sender, const struct GNUNET_MessageHeader *msg)
Function called when the transport service has received an acknowledgement for this communicator (!) ...
int GNUNET_NETWORK_socket_connect(const struct GNUNET_NETWORK_Handle *desc, const struct sockaddr *address, socklen_t address_len)
Connect a socket to some remote address.
unsigned long long bytes_in_queue
Number of bytes we currently have in our write queue.
static struct GNUNET_CONTAINER_MultiPeerMap * queue_map
Queues (map from peer identity to struct Queue)
struct GNUNET_PEERSTORE_IterateContext * rekey_monotime_get
Iteration Context for retrieving the monotonic time send with key for rekeying.
static struct sockaddr * tcp_address_to_sockaddr_numeric_v4(socklen_t *sock_len, struct sockaddr_in v4, unsigned int port)
Convert a struct sockaddr_in4 to astruct sockaddr *`.
struct GNUNET_TIME_AbsoluteNBO handshake_ack_monotonic_time
Monotonic time value for handshake ack message.
static struct GNUNET_TIME_Relative timeout
Desired timeout for the lookup (default is no timeout).
struct GNUNET_MQ_Handle * GNUNET_MQ_queue_for_callbacks(GNUNET_MQ_SendImpl send, GNUNET_MQ_DestroyImpl destroy, GNUNET_MQ_CancelImpl cancel, void *impl_state, const struct GNUNET_MQ_MessageHandler *handlers, GNUNET_MQ_ErrorHandler error_handler, void *cls)
Create a message queue for the specified handlers.
static void queue_destroy(struct Queue *queue)
Functions with this signature are called whenever we need to close a queue due to a disconnect or fai...
void * value
Record value BLOB.
void GNUNET_log_config_missing(enum GNUNET_ErrorType kind, const char *section, const char *option)
Log error message about missing configuration option.
static char * value
Value of the record to add/remove.
const char * GNUNET_p2s(const struct GNUNET_CRYPTO_EddsaPublicKey *p)
Convert a public key value to a string (for printing debug messages).
enum GNUNET_GenericReturnValue GNUNET_CRYPTO_ecdh_eddsa(const struct GNUNET_CRYPTO_EcdhePrivateKey *priv, const struct GNUNET_CRYPTO_EddsaPublicKey *pub, struct GNUNET_HashCode *key_material)
Derive key material from a EdDSA public key and a private ECDH key.
#define GNUNET_break_op(cond)
Use this for assertion violations caused by other peers (i.e.
void GNUNET_CRYPTO_hash(const void *block, size_t size, struct GNUNET_HashCode *ret)
Compute hash of a given block.
void GNUNET_PEERSTORE_disconnect(struct GNUNET_PEERSTORE_Handle *h, int sync_first)
Disconnect from the PEERSTORE service.
Context for a store request.
struct GNUNET_PEERSTORE_StoreContext * GNUNET_PEERSTORE_store(struct GNUNET_PEERSTORE_Handle *h, const char *sub_system, const struct GNUNET_PeerIdentity *peer, const char *key, const void *value, size_t size, struct GNUNET_TIME_Absolute expiry, enum GNUNET_PEERSTORE_StoreOption options, GNUNET_PEERSTORE_Continuation cont, void *cont_cls)
Store a new entry in the PEERSTORE.
struct GNUNET_SCHEDULER_Task * GNUNET_SCHEDULER_add_now(GNUNET_SCHEDULER_TaskCallback task, void *task_cls)
Schedule a new task to be run as soon as possible.
size_t cwrite_off
At which offset in the ciphertext write buffer should we append more ciphertext from reading next...
#define COMMUNICATOR_ADDRESS_PREFIX
Address prefix used by the communicator.
const char * GNUNET_STRINGS_relative_time_to_string(struct GNUNET_TIME_Relative delta, int do_round)
Give relative time in human-readable fancy format.
#define GNUNET_SIGNATURE_COMMUNICATOR_TCP_HANDSHAKE_ACK
Signature by a peer sending back the nonce received at initial handshake.
enum GNUNET_GenericReturnValue GNUNET_CRYPTO_kdf(void *result, size_t out_len, const void *xts, size_t xts_len, const void *skm, size_t skm_len,...)
Derive key.
static struct GNUNET_CRYPTO_EddsaPrivateKey * my_private_key
Our private key.
struct GNUNET_TRANSPORT_CommunicatorHandle * GNUNET_TRANSPORT_communicator_connect(const struct GNUNET_CONFIGURATION_Handle *cfg, const char *config_section_name, const char *addr_prefix, enum GNUNET_TRANSPORT_CommunicatorCharacteristics cc, GNUNET_TRANSPORT_CommunicatorMqInit mq_init, void *mq_init_cls, GNUNET_TRANSPORT_CommunicatorNotify notify_cb, void *notify_cb_cls)
Connect to the transport service.
void GNUNET_PEERSTORE_store_cancel(struct GNUNET_PEERSTORE_StoreContext *sc)
Cancel a store request.
struct GNUNET_PEERSTORE_StoreContext * rekey_monotime_sc
Store Context for retrieving the monotonic time send with key for rekeying.
static void setup_cipher(const struct GNUNET_HashCode *dh, const struct GNUNET_PeerIdentity *pid, gcry_cipher_hd_t *cipher, struct GNUNET_HashCode *hmac_key)
Setup cipher based on shared secret dh and decrypting peer pid.
this is an inbound connection (communicator initiated)
#define GNUNET_TIME_UNIT_FOREVER_REL
Constant used to specify "forever".
static void mq_destroy(struct GNUNET_MQ_Handle *mq, void *impl_state)
Signature of functions implementing the destruction of a message queue.
struct GNUNET_CRYPTO_EddsaSignature sender_sig
Sender's signature of type GNUNET_SIGNATURE_COMMUNICATOR_TCP_HANDSHAKE_ACK.
static void reschedule_queue_timeout(struct Queue *queue)
Increment queue timeout due to activity.
static void queue_finish(struct Queue *queue)
Append a 'finish' message to the outgoing transmission.
const char * GNUNET_a2s(const struct sockaddr *addr, socklen_t addrlen)
Convert a "struct sockaddr*" (IPv4 or IPv6 address) to a string (for printing debug messages)...
struct GNUNET_MessageHeader header
Type is GNUNET_MESSAGE_TYPE_COMMUNICATOR_TCP_FINISH.
struct GNUNET_NETWORK_Handle * sock
socket that we transmit all data with on this queue
struct GNUNET_TIME_Absolute timeout
Timeout for this protoqueue.
struct sockaddr * addr_ipv6
Ipv6 address we like to bind to.
uint32_t size
How many bytes does this signature sign? (including this purpose header); in network byte order (!)...
Internal representation of the hash map.
struct GNUNET_SCHEDULER_Task * write_task
ID of write task for this connection.
struct sockaddr * address
Address of the other peer.
struct Addresses * addrs_head
Head of DLL with addresses we like to register at NAT servcie.
Handle to the PEERSTORE service.
void GNUNET_STATISTICS_set(struct GNUNET_STATISTICS_Handle *handle, const char *name, uint64_t value, int make_persistent)
Set statistic value for the peer.
struct GNUNET_CRYPTO_EddsaSignature sender_sig
Sender's signature of type GNUNET_SIGNATURE_COMMUNICATOR_TCP_REKEY.
#define GNUNET_MESSAGE_TYPE_COMMUNICATOR_TCP_FINISH
TCP communicator end of stream.
struct ChallengeNonceP challenge
Challenge value used to protect against replay attack, if there is no stored monotonic time value...
char cwrite_buf[(2 *64 *1024+sizeof(struct TCPBox))]
buffer for writing ciphertext to network.
struct GNUNET_TIME_AbsoluteNBO monotonic_time
Monotonic time of sender, to possibly help detect replay attacks (if receiver persists times by sende...
static void do_rekey(struct Queue *queue, const struct TCPRekey *rekey)
Handle rekey message on queue.
char pwrite_buf[UINT16_MAX+1+sizeof(struct TCPBox)]
Plaintext buffer for messages to be encrypted.
static struct GNUNET_NAT_AUTO_Test * nt
Handle to a NAT test operation.
void GNUNET_NT_scanner_done(struct GNUNET_NT_InterfaceScanner *is)
Terminate interface scanner.
int int GNUNET_asprintf(char **buf, const char *format,...) __attribute__((format(printf
Like asprintf, just portable.
static struct sockaddr * tcp_address_to_sockaddr(const char *bindto, socklen_t *sock_len)
Convert TCP bind specification to a struct sockaddr *
static void mq_cancel(struct GNUNET_MQ_Handle *mq, void *impl_state)
Implementation function that cancels the currently sent message.
struct GNUNET_TIME_AbsoluteNBO monotonic_time
Monotonic time of sender, to possibly help detect replay attacks (if receiver persists times by sende...
struct ChallengeNonceP challenge
Challenge value used to protect against replay attack, if there is no stored monotonic time value...
Private ECC key encoded for transmission.
void GNUNET_NAT_unregister(struct GNUNET_NAT_Handle *nh)
Stop port redirection and public IP address detection for the given handle.
#define GNUNET_free_nz(ptr)
Wrapper around free.
struct GNUNET_CRYPTO_EcdhePublicKey ephemeral
New ephemeral key.
size_t pread_off
At which offset in the plaintext input buffer should we append more plaintext from decryption next...
struct Addresses * next
Kept in a DLL.
int mq_awaits_continue
Is MQ awaiting a GNUNET_MQ_impl_send_continue() call?
struct GNUNET_NETWORK_Handle * sock
socket that we transmit all data with on this queue
There must only be one value per key; storing a value should fail if a value under the same key alrea...
void GNUNET_TRANSPORT_communicator_address_remove(struct GNUNET_TRANSPORT_AddressIdentifier *ai)
Notify transport service about an address that this communicator no longer provides for this peer...
static void handshake_monotime_store_cb(void *cls, int success)
Callback called when peerstore store operation for handshake monotime is finished.
struct GNUNET_TESTBED_Peer * peer
The peer associated with this model.
struct GNUNET_HashCode key
The key used in the DHT.
static unsigned int size
Size of the "table".
static struct GNUNET_TRANSPORT_AddressIdentifier * ai
Handle to the operation that publishes our address.
void GNUNET_CRYPTO_ecdhe_key_get_public(const struct GNUNET_CRYPTO_EcdhePrivateKey *priv, struct GNUNET_CRYPTO_EcdhePublicKey *pub)
Extract the public key for the given private key.
struct GNUNET_PeerIdentity sender
Sender's identity.
struct GNUNET_PEERSTORE_IterateContext * handshake_ack_monotime_get
Iteration Context for retrieving the monotonic time send with the handshake ack.
static int get_queue_delete_it(void *cls, const struct GNUNET_PeerIdentity *target, void *value)
Iterator over all message queues to clean up.
struct GNUNET_PEERSTORE_Handle * GNUNET_PEERSTORE_connect(const struct GNUNET_CONFIGURATION_Handle *cfg)
Connect to the PEERSTORE service.
Handle to a request given to the resolver.
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 abou...
static char * extract_address(const char *bindto)
This Method extracts the address part of the BINDTO string.
struct GNUNET_NAT_Handle * GNUNET_NAT_register(const struct GNUNET_CONFIGURATION_Handle *cfg, const char *config_section, uint8_t proto, unsigned int num_addrs, const struct sockaddr **addrs, const socklen_t *addrlens, GNUNET_NAT_AddressCallback address_callback, GNUNET_NAT_ReversalCallback reversal_callback, void *callback_cls)
Attempt to enable port redirection and detect public IP address contacting UPnP or NAT-PMP routers on...
static struct GNUNET_MQ_Envelope * ac
Handle to current GNUNET_PEERINFO_add_peer() operation.
static void mq_send(struct GNUNET_MQ_Handle *mq, const struct GNUNET_MessageHeader *msg, void *impl_state)
Signature of functions implementing the sending functionality of a message queue. ...
struct GNUNET_NT_InterfaceScanner * GNUNET_NT_scanner_init(void)
Initialize the address characterization client handle.
struct GNUNET_TRANSPORT_QueueHandle * GNUNET_TRANSPORT_communicator_mq_add(struct GNUNET_TRANSPORT_CommunicatorHandle *ch, const struct GNUNET_PeerIdentity *peer, const char *address, uint32_t mtu, uint64_t q_len, uint32_t priority, enum GNUNET_NetworkType nt, enum GNUNET_TRANSPORT_ConnectionStatus cs, struct GNUNET_MQ_Handle *mq)
Notify transport service that a MQ became available due to an "inbound" connection or because the com...
struct ChallengeNonceP challenge
Challenge value used to protect against replay attack, if there is no stored monotonic time value...
static struct ProtoQueue * proto_tail
Protoqueues DLL tail.
struct GNUNET_PeerIdentity receiver
Presumed identity of the target of the TCP connection (TCP server)
static void rekey_monotime_cb(void *cls, const struct GNUNET_PEERSTORE_Record *record, const char *emsg)
Callback called by peerstore when records for GNUNET_PEERSTORE_TRANSPORT_TCP_COMMUNICATOR_REKEY where...
struct GNUNET_NETWORK_Handle * listen_sock
Listen socket.
#define DEFAULT_MAX_QUEUE_LENGTH
How many messages do we keep at most in the queue to the transport service before we start to drop (d...
int GNUNET_CONTAINER_multihashmap_put(struct GNUNET_CONTAINER_MultiHashMap *map, const struct GNUNET_HashCode *key, void *value, enum GNUNET_CONTAINER_MultiHashMapOption opt)
Store a key-value pair in the map.
static struct GNUNET_CONTAINER_MultiHashMap * lt_map
ListenTasks (map from socket to struct ListenTask)
struct GNUNET_TIME_Absolute GNUNET_TIME_absolute_get_monotonic(const struct GNUNET_CONFIGURATION_Handle *cfg)
Obtain the current time and make sure it is monotonically increasing.
Type of a nonce used for challenges.
struct Addresses * addrs_tail
Head of DLL with addresses we like to register at NAT servcie.
int GNUNET_TRANSPORT_communicator_receive(struct GNUNET_TRANSPORT_CommunicatorHandle *handle, const struct GNUNET_PeerIdentity *sender, const struct GNUNET_MessageHeader *msg, struct GNUNET_TIME_Relative expected_addr_validity, GNUNET_TRANSPORT_MessageCompletedCallback cb, void *cb_cls)
Notify transport service that the communicator has received a message.
static void start_initial_kx_out(struct Queue *queue)
Initialize our key material for outgoing transmissions and inform the other peer about it...
#define GNUNET_memcmp(a, b)
Compare memory in a and b, where both must be of the same pointer type.
an ECC signature using EdDSA.
struct GNUNET_PeerIdentity receiver
Presumed identity of the target of the TCP connection (TCP server)
void GNUNET_CRYPTO_eddsa_key_get_public(const struct GNUNET_CRYPTO_EddsaPrivateKey *priv, struct GNUNET_CRYPTO_EddsaPublicKey *pub)
Extract the public key for the given private key.
struct GNUNET_TIME_AbsoluteNBO rekey_monotonic_time
Monotonic time value for rekey message.
static struct in_addr dummy
Target "dummy" address of the packet we pretend to respond to.
void GNUNET_log_from_nocheck(enum GNUNET_ErrorType kind, const char *comp, const char *message,...) __attribute__((format(printf
Log function that specifies an alternative component.
#define REKEY_MAX_BYTES
How often do we rekey based on number of bytes transmitted? (additionally randomized).
Allow multiple values with the same key.
#define GNUNET_CONSTANTS_IDLE_CONNECTION_TIMEOUT
After how long do we consider a connection to a peer dead if we don't receive messages from the peer...
Handle to a message queue.
int GNUNET_CONTAINER_multipeermap_put(struct GNUNET_CONTAINER_MultiPeerMap *map, const struct GNUNET_PeerIdentity *key, void *value, enum GNUNET_CONTAINER_MultiHashMapOption opt)
Store a key-value pair in the map.
struct GNUNET_TIME_AbsoluteNBO monotonic_time
Monotonic time of sender, to possibly help detect replay attacks (if receiver persists times by sende...
struct GNUNET_PeerIdentity receiver
Presumed identity of the target of the TCP connection (TCP server)
socklen_t address_len
Length of the address.
#define GNUNET_NETWORK_STRUCT_END
Define as empty, GNUNET_PACKED should suffice, but this won't work on W32;.
Private ECC key encoded for transmission.
int GNUNET_CONTAINER_multipeermap_iterate(struct GNUNET_CONTAINER_MultiPeerMap *map, GNUNET_CONTAINER_PeerMapIterator it, void *it_cls)
Iterate over all entries in the map.
static void nat_register()
This method reads from the DLL addrs_head to register them at the NAT service.
int shutdown_running
A flag indicating we are already doing a shutdown.
The identity of the host (wraps the signing key of the peer).
enum GNUNET_GenericReturnValue GNUNET_CRYPTO_eddsa_ecdh(const struct GNUNET_CRYPTO_EddsaPrivateKey *priv, const struct GNUNET_CRYPTO_EcdhePublicKey *pub, struct GNUNET_HashCode *key_material)
Derive key material from a ECDH public key and a private EdDSA key.
static void free_proto_queue(struct ProtoQueue *pq)
Closes socket and frees memory associated with pq.
Ack for the encrypted continuation of TCP initial handshake.
struct sockaddr * address
Address of the other peer.
size_t ibuf_off
Current offset for reading into ibuf.
static void setup_out_cipher(struct Queue *queue)
Setup cipher for outgoing data stream based on target and our ephemeral private key.
#define GNUNET_TRANSPORT_QUEUE_LENGTH_UNLIMITED
Queue length.
static uint16_t port
Port number.
struct GNUNET_ShortHashCode hmac
HMAC for the following encrypted message.
struct sockaddr * addr
Address we like to register at NAT service.
struct GNUNET_TIME_AbsoluteNBO handshake_monotonic_time
Monotonic time value for handshake message.
enum GNUNET_GenericReturnValue GNUNET_CONFIGURATION_get_value_time(const struct GNUNET_CONFIGURATION_Handle *cfg, const char *section, const char *option, struct GNUNET_TIME_Relative *time)
Get a configuration value that should be a relative time.
this is an outbound connection (transport initiated)
struct GNUNET_CRYPTO_EcdhePublicKey ephemeral
Ephemeral key used by the sender.
struct GNUNET_PEERSTORE_StoreContext * handshake_ack_monotime_sc
Store Context for retrieving the monotonic time send with the handshake ack.
static void handshake_ack_monotime_store_cb(void *cls, int success)
Callback called when peerstore store operation for handshake ack monotime value is finished...
static struct GNUNET_STATISTICS_Handle * stats
For logging statistics.
enum GNUNET_TRANSPORT_ConnectionStatus cs
The connection status of this queue.
struct GNUNET_SCHEDULER_Task * read_task
ID of read task for this connection.
Encrypted continuation of TCP initial handshake.
Public ECC key (always for Curve25519) encoded in a format suitable for network transmission and encr...
struct GNUNET_MQ_Handle * mq
#define ADDRESS_VALIDITY_PERIOD
How long do we believe our addresses to remain up (before the other peer should revalidate).
size_t pwrite_off
At which offset in the plaintext output buffer should we append more plaintext for encryption next...
#define GNUNET_log(kind,...)
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 ...
Entry in list of pending tasks.
struct ProtoQueue * next
Kept in a DLL.
struct ListenTask * lts_head
Head of DLL with ListenTasks.
static void boot_queue(struct Queue *queue)
Add the given queue to our internal data structure.
void GNUNET_PEERSTORE_iterate_cancel(struct GNUNET_PEERSTORE_IterateContext *ic)
Cancel an iterate request Please do not call after the iterate request is done.
struct GNUNET_MessageHeader header
Type is GNUNET_MESSAGE_TYPE_COMMUNICATOR_TCP_REKEY.
static unsigned int extract_port(const char *addr_and_port)
This Method extracts the port part of the BINDTO string.
static void record(void *cls, size_t data_size, const void *data)
Process recorded audio data.
struct GNUNET_MessageHeader header
Type is GNUNET_MESSAGE_TYPE_COMMUNICATOR_TCP_BOX.
struct GNUNET_CONTAINER_MultiHashMap * GNUNET_CONTAINER_multihashmap_create(unsigned int len, int do_not_copy_keys)
Create a multi hash map.
enum GNUNET_GenericReturnValue GNUNET_CONFIGURATION_get_value_yesno(const struct GNUNET_CONFIGURATION_Handle *cfg, const char *section, const char *option)
Get a configuration value that should be in a set of "YES" or "NO".
void GNUNET_CRYPTO_random_block(enum GNUNET_CRYPTO_Quality mode, void *buffer, size_t length)
Fill block with a random values.
struct GNUNET_ShortHashCode hmac
HMAC for the following encrypted message.
struct ProtoQueue * prev
Kept in a DLL.
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 c...
static size_t try_handle_plaintext(struct Queue *queue)
Test if we have received a full message in plaintext.
struct GNUNET_CRYPTO_EddsaPrivateKey * GNUNET_CRYPTO_eddsa_key_create_from_configuration(const struct GNUNET_CONFIGURATION_Handle *cfg)
Create a new private key by reading our peer's key from the file specified in the configuration...
struct GNUNET_TIME_Relative GNUNET_TIME_absolute_get_remaining(struct GNUNET_TIME_Absolute future)
Given a timestamp in the future, how much time remains until then?
socklen_t addr_len
Length of address we like to register at NAT service.
socklen_t addr_len_ipv6
Length of ipv6 address.
static struct sockaddr * tcp_address_to_sockaddr_numeric_v6(socklen_t *sock_len, struct sockaddr_in6 v6, unsigned int port)
Convert a struct sockaddr_in6 to astruct sockaddr *`.
enum GNUNET_TESTBED_UnderlayLinkModelType type
the type of this model
static void add_addr(struct sockaddr *in, socklen_t in_len)
This method adds addresses to the DLL, that are later register at the NAT service.
gcry_cipher_hd_t in_cipher
cipher for decryption of incoming data.
Time for absolute times used by GNUnet, in microseconds.
struct GNUNET_SCHEDULER_Task * GNUNET_SCHEDULER_add_read_net(struct GNUNET_TIME_Relative delay, struct GNUNET_NETWORK_Handle *rfd, GNUNET_SCHEDULER_TaskCallback task, void *task_cls)
Schedule a new task to be run with a specified delay or when the specified file descriptor is ready f...
GNUNET_TRANSPORT_ConnectionStatus
Possible states of a connection.
struct GNUNET_NETWORK_Handle * listen_sock
Listen socket.
enum GNUNET_NetworkType nt
Which network type does this queue use?
unsigned int GNUNET_CONTAINER_multipeermap_size(const struct GNUNET_CONTAINER_MultiPeerMap *map)
Get the number of key-value pairs in the map.
struct GNUNET_CRYPTO_EccSignaturePurpose purpose
Purpose must be GNUNET_SIGNATURE_COMMUNICATOR_TCP_HANDSHAKE.
struct GNUNET_TIME_Absolute timeout
Timeout for this queue.
struct GNUNET_CRYPTO_EccSignaturePurpose purpose
Purpose must be GNUNET_SIGNATURE_COMMUNICATOR_TCP_REKEY.
const char * GNUNET_STRINGS_absolute_time_to_string(struct GNUNET_TIME_Absolute t)
Like asctime, except for GNUnet time.
static void do_shutdown(void *cls)
Shutdown the UNIX communicator.
const char * GNUNET_e2s(const struct GNUNET_CRYPTO_EcdhePublicKey *p)
Convert a public key value to a string (for printing debug messages).
static struct GNUNET_PeerIdentity pid
Identity of the peer we transmit to / connect to.
struct GNUNET_ShortHashCode hmac
HMAC for the following encrypted message.
#define DEFAULT_REKEY_INTERVAL
How often do we rekey based on time (at least)
static int init_socket(struct sockaddr *addr, socklen_t in_len)
This method launch network interactions for each address we like to bind to.
static struct ProtoQueue * proto_head
Protoqueues DLL head.
int GNUNET_CONTAINER_multihashmap_iterate(struct GNUNET_CONTAINER_MultiHashMap *map, GNUNET_CONTAINER_MulitHashMapIteratorCallback it, void *it_cls)
Iterate over all entries in the map.
static struct GNUNET_TRANSPORT_CommunicatorHandle * ch
Our environment.
static const struct GNUNET_CONFIGURATION_Handle * cfg
Our configuration.
#define GNUNET_PEERSTORE_TRANSPORT_TCP_COMMUNICATOR_HANDSHAKE_ACK
Key used to store sender's monotonic time from handshake ack message.
struct GNUNET_TRANSPORT_QueueHandle * qh
handle for this queue with the ch.
struct GNUNET_TIME_AbsoluteNBO GNUNET_TIME_absolute_hton(struct GNUNET_TIME_Absolute a)
Convert absolute time to network byte order.
static char * address
GNS address for this phone.
void GNUNET_MQ_impl_send_continue(struct GNUNET_MQ_Handle *mq)
Call the send implementation for the next queued message, if any.
gcry_cipher_hd_t out_cipher
cipher for encryption of outgoing data.
static void handshake_ack_monotime_cb(void *cls, const struct GNUNET_PEERSTORE_Record *record, const char *emsg)
Callback called by peerstore when records for GNUNET_PEERSTORE_TRANSPORT_TCP_COMMUNICATOR_HANDSHAKE_A...
const char * GNUNET_i2s(const struct GNUNET_PeerIdentity *pid)
Convert a peer identity to a string (for printing debug messages).
Handle returned to identify the internal data structure the transport API has created to manage a mes...
char pread_buf[UINT16_MAX+1+sizeof(struct TCPBox)]
Plaintext buffer for decrypted plaintext.
int GNUNET_NETWORK_socket_close(struct GNUNET_NETWORK_Handle *desc)
Close a socket.
Signature we use to verify that the ephemeral key was really chosen by the specified sender...
static void send_challenge(struct ChallengeNonceP challenge, struct Queue *queue)
Sending challenge with TcpConfirmationAck back to sender of ephemeral key.
No good quality of the operation is needed (i.e., random numbers can be pseudo-random).
Struct to use as closure.
#define GNUNET_malloc(size)
Wrapper around malloc.
int GNUNET_NETWORK_test_pf(int pf)
Test if the given protocol family is supported by this system.
Context for a iterate request.
Internal representation of an address a communicator is currently providing for the transport service...
#define GNUNET_free(ptr)
Wrapper around free.
Time for relative time used by GNUnet, in microseconds.
struct GNUNET_CRYPTO_EddsaPublicKey public_key
struct GNUNET_NETWORK_Handle * GNUNET_NETWORK_socket_create(int domain, int type, int protocol)
Create a new socket.
static void queue_write(void *cls)
We have been notified that our socket is ready to write.
void * GNUNET_SCHEDULER_cancel(struct GNUNET_SCHEDULER_Task *task)
Cancel the task with the specified identifier.