43#include <libp2p/basic/scheduler.hpp>
44#include <libp2p/common/literals.hpp>
45#include <libp2p/injector/host_injector.hpp>
46#include <libp2p/layer/websocket/ws_adaptor.hpp>
47#include <libp2p/log/configurator.hpp>
48#include <libp2p/log/logger.hpp>
49#include <libp2p/protocol/echo.hpp>
53#define LOG(kind, ...) GNUNET_log_from (kind, "communicator-tcp", __VA_ARGS__)
199 key.eddsa_key = *edpk;
210 key.eddsa_key = *edpk;
229 if (NULL !=
queue->listen_sock)
240 "Disconnecting queue for peer `%s'\n",
242 if (NULL !=
queue->rekey_monotime_sc)
245 queue->rekey_monotime_sc = NULL;
247 if (NULL !=
queue->handshake_monotime_sc)
250 queue->handshake_monotime_sc = NULL;
252 if (NULL !=
queue->handshake_ack_monotime_sc)
255 queue->handshake_ack_monotime_sc = NULL;
257 if (NULL !=
queue->rekey_monotime_get)
260 queue->rekey_monotime_get = NULL;
262 if (NULL !=
queue->handshake_monotime_get)
265 queue->handshake_monotime_get = NULL;
267 if (NULL !=
queue->handshake_ack_monotime_get)
270 queue->handshake_ack_monotime_get = NULL;
272 if (NULL !=
queue->qh)
284 if (NULL !=
queue->read_task)
287 queue->read_task = NULL;
289 if (NULL !=
queue->write_task)
292 queue->write_task = NULL;
297 "closing socket failed\n");
299 gcry_cipher_close (
queue->in_cipher);
300 gcry_cipher_close (
queue->out_cipher);
302 if (0 !=
queue->backpressure)
313 "add read net listen\n");
366 memset (&fin, 0,
sizeof(fin));
373 memcpy (
queue->pwrite_buf, &fin,
sizeof(fin));
374 queue->pwrite_off =
sizeof(fin);
405 "# messages lost in communicator API towards CORE",
413 queue->backpressure);
415 queue->backpressure--;
417 if ((
queue->destroyed) && (0 ==
queue->backpressure))
428 if (NULL ==
queue->read_task)
450 const void *plaintext,
451 size_t plaintext_len)
457 "pass message from %s to core\n",
460 if (ntohs (hdr->
size) != plaintext_len)
476 queue->backpressure++;
480 "# bytes lost due to CORE not running",
498 gcry_cipher_hd_t *cipher,
507 GCRY_CIPHER_MODE_CTR,
513 "gnunet-communicator-tcp-key",
515 "gnunet-communicator-tcp-key"),
523 "gnunet-communicator-tcp-ctr",
525 "gnunet-communicator-tcp-ctr"),
528 gcry_cipher_setctr (*cipher, ctr,
sizeof(ctr));
533 "gnunet-communicator-hmac",
534 strlen (
"gnunet-communicator-hmac"),
552 "Failed to store rekey monotonic time in PEERSTORE!\n");
554 queue->rekey_monotime_sc = NULL;
579 rekey_monotonic_time = &
queue->rekey_monotonic_time;
583 queue->rekey_monotime_get = NULL;
586 if (
sizeof(*mtbe) !=
record->value_size)
598 "Queue from %s dropped, rekey monotime in the past\n",
602 queue->rekey_monotime_get = NULL;
608 "transport_tcp_communicator",
611 rekey_monotonic_time,
613 rekey_monotonic_time),
672 "do_rekey size %u\n",
701 &
queue->target.public_key))
710 "transport_tcp_communicator",
716 gcry_cipher_close (
queue->in_cipher);
735 "Failed to store handshake ack monotonic time in PEERSTORE!\n");
737 queue->handshake_ack_monotime_sc = NULL;
762 handshake_ack_monotonic_time = &
queue->handshake_ack_monotonic_time;
766 queue->handshake_ack_monotime_get = NULL;
769 if (
sizeof(*mtbe) !=
record->value_size)
781 "Queue from %s dropped, handshake ack monotime in the past\n",
785 queue->handshake_ack_monotime_get = NULL;
790 queue->handshake_ack_monotime_sc =
792 "transport_tcp_communicator",
795 handshake_ack_monotonic_time,
796 sizeof(*handshake_ack_monotonic_time),
818 "sending challenge\n");
838 gcry_cipher_encrypt (
queue->out_cipher,
843 queue->cwrite_off +=
sizeof(tca);
845 "sending challenge done\n");
860 queue->rekey_left_bytes =
879 memset (&rekey, 0,
sizeof(rekey));
889 "inject_rekey size %u\n",
915 gcry_cipher_encrypt (
queue->out_cipher,
920 queue->cwrite_off +=
sizeof(rekey);
922 gcry_cipher_close (
queue->out_cipher);
954 if (AF_INET == sa_family)
958 struct sockaddr_in *natted_address;
960 natted_address =
GNUNET_memdup (in,
sizeof (
struct sockaddr));
961 natted_address->sin_port = 0;
963 sizeof(
struct sockaddr),
968 if (NULL != pending_reversal && (NULL == sender ||
970 &pending_reversal->
target,
975 "Removing invalid pending reversal for `%s'at `%s'\n",
1035 "Sent %lu bytes to TCP queue\n", sent);
1036 if ((-1 == sent) && (EAGAIN != errno) && (EINTR != errno))
1044 size_t usent = (size_t) sent;
1073 queue->write_task = NULL;
1074 if (0 !=
queue->cwrite_off)
1080 "Sent %lu bytes to TCP queue\n", sent);
1081 if ((-1 == sent) && (EAGAIN != errno) && (EINTR != errno))
1089 size_t usent = (size_t) sent;
1090 queue->cwrite_off -= usent;
1091 memmove (
queue->cwrite_buf,
1092 &
queue->cwrite_buf[usent],
1102 unsigned int we_do_not_need_to_rekey = (0 <
queue->rekey_left_bytes
1103 - (
queue->cwrite_off
1106 if (we_do_not_need_to_rekey &&
1107 (
queue->pwrite_off > 0) &&
1111 "Encrypting %lu bytes\n",
queue->pwrite_off);
1113 gcry_cipher_encrypt (
queue->out_cipher,
1117 queue->pwrite_off));
1118 if (
queue->rekey_left_bytes >
queue->pwrite_off)
1119 queue->rekey_left_bytes -=
queue->pwrite_off;
1121 queue->rekey_left_bytes = 0;
1123 queue->pwrite_off = 0;
1126 if (((0 ==
queue->rekey_left_bytes) ||
1129 (((0 ==
queue->pwrite_off) || ! we_do_not_need_to_rekey) &&
1135 if ((0 ==
queue->pwrite_off) && (!
queue->finishing) &&
1145 "Finishing queue\n");
1150 if ((0 <
queue->cwrite_off) || (0 <
queue->pwrite_off))
1171 const struct TCPBox *box;
1183 "try handle plaintext!\n");
1186 if ((
sizeof(*hdr) >
queue->pread_off))
1189 "Handling plaintext, not even a header!\n");
1197 "Already received data of size %lu bigger than KX size %lu!\n",
1198 queue->unverified_size,
1211 "start processing ack\n");
1212 if (
sizeof(*tca) >
queue->pread_off)
1215 "Handling plaintext size of tca greater than pread offset.\n")
1219 if (ntohs (hdr->
size) !=
sizeof(*tca))
1222 "Handling plaintext size does not match message type.\n");
1243 "Verification of signature failed!\n");
1251 "Challenge in TCPConfirmationAck not correct!\n");
1259 "transport_tcp_communicator",
1266 "Handling plaintext, ack processed!\n");
1280 queue->address->sa_family, NULL);
1292 switch (
queue->address->sa_family)
1332 if (0 != memcmp (&tmac, &box->
hmac,
sizeof(tmac)))
1339 size = ntohs (hdr->
size) +
sizeof(*box);
1341 "Handling plaintext, box processed!\n");
1343 "# bytes decrypted with BOX",
1347 "# messages decrypted with BOX",
1354 if (
sizeof(*rekey) >
queue->pread_off)
1356 if (ntohs (hdr->
size) !=
sizeof(*rekey))
1363 memset (&rekeyz.
hmac, 0,
sizeof(rekeyz.
hmac));
1365 if (0 != memcmp (&tmac, &rekey->
hmac,
sizeof(tmac)))
1374 "Handling plaintext, rekey processed!\n");
1376 "# rekeying successful",
1383 if (
sizeof(*fin) >
queue->pread_off)
1385 if (ntohs (hdr->
size) !=
sizeof(*fin))
1392 memset (&finz.
hmac, 0,
sizeof(finz.
hmac));
1394 if (0 != memcmp (&tmac, &fin->
hmac,
sizeof(tmac)))
1403 "Handling plaintext, finish processed!\n");
1408 "Handling plaintext, nothing processed!\n");
1414 if (-1 !=
queue->unverified_size)
1432 queue->read_task = NULL;
1437 "Received %zd bytes from TCP queue\n", rcvd);
1440 if ((EAGAIN != errno) && (EINTR != errno))
1455 "Queue %p was idle for %s, disconnecting\n",
1467 "Socket for queue %p seems to have been closed\n",
queue);
1473 queue->cread_off += rcvd;
1474 while ((
queue->pread_off <
sizeof(
queue->pread_buf)) &&
1475 (
queue->cread_off > 0))
1481 size_t old_pread_off =
queue->pread_off;
1484 gcry_cipher_decrypt (
queue->in_cipher,
1498 memmove (
queue->pread_buf,
1499 &
queue->pread_buf[done],
1500 queue->pread_off - done);
1501 queue->pread_off -= done;
1516 max = total - old_pread_off;
1518 queue->pread_off = 0;
1537 "Queue %p was idle for %s, disconnecting\n",
1553static struct sockaddr *
1555 struct sockaddr_in6 v6,
1558 struct sockaddr *in;
1560 v6.sin6_family = AF_INET6;
1561 v6.sin6_port = htons ((uint16_t)
port);
1562#if HAVE_SOCKADDR_IN_SIN_LEN
1563 v6.sin6_len =
sizeof(
struct sockaddr_in6);
1565 v6.sin6_flowinfo = 0;
1566 v6.sin6_scope_id = 0;
1568 *sock_len =
sizeof(
struct sockaddr_in6);
1581static struct sockaddr *
1583 struct sockaddr_in v4,
1586 struct sockaddr *in;
1588 v4.sin_family = AF_INET;
1589 v4.sin_port = htons ((uint16_t)
port);
1590#if HAVE_SOCKADDR_IN_SIN_LEN
1591 v4.sin_len =
sizeof(
struct sockaddr_in);
1594 *sock_len =
sizeof(
struct sockaddr_in);
1609 struct sockaddr_in *i4;
1610 struct sockaddr_in6 *i6;
1611 socklen_t sock_len_ipv4;
1612 socklen_t sock_len_ipv6;
1615 if (*
port > UINT16_MAX)
1618 "BINDTO specification `%s' invalid: value too large for port\n",
1671 "extract address with bindto %s\n",
1676 "bindto is NULL\n");
1681 "extract address 2\n");
1684 if ((
'[' == *cp) && (
']' == cp[strlen (cp) - 1]))
1687 cp[strlen (cp) - 1] =
'\0';
1692 token = strtok_r (cp,
"]", &rest);
1693 if (strlen (bindto) == strlen (token))
1695 token = strtok_r (cp,
":", &rest);
1706 "tcp address: %s\n",
1730 if (NULL != addr_and_port)
1733 token = strtok_r (cp,
"]", &rest);
1734 if (strlen (addr_and_port) == strlen (token))
1736 colon = strrchr (cp,
':');
1747 token = strtok_r (NULL,
"]", &rest);
1761 if (1 == sscanf (addr,
"%u%1s", &
port,
dummy))
1764 if (
port > UINT16_MAX)
1767 "Port `%u' invalid: value too large for port\n",
1776 "BINDTO specification invalid: last ':' not followed by number\n");
1801static struct sockaddr *
1804 struct sockaddr *in;
1806 struct sockaddr_in v4;
1807 struct sockaddr_in6 v6;
1810 memset (&v4, 0,
sizeof(v4));
1822 if (1 == inet_pton (AF_INET,
start, &v4.sin_addr))
1832 else if (1 == inet_pton (AF_INET6,
start, &v6.sin6_addr))
1861 uint16_t msize = ntohs (
msg->
size);
1864 "In MQ send. Queue finishing: %s; write task running: %s\n",
1866 (NULL ==
queue->write_task) ?
"yes" :
"no");
1875 memcpy (&
queue->pwrite_buf[
queue->pwrite_off], &box,
sizeof(box));
1876 queue->pwrite_off +=
sizeof(box);
1878 queue->pwrite_off += msize;
1880 "%lu bytes of plaintext to send\n",
queue->pwrite_off);
1882 if (NULL ==
queue->write_task)
1924 queue->pwrite_off = 0;
1943 "MQ error in queue to %s: %d\n",
2000 memcpy (
queue->cwrite_buf, c,
sizeof(*c));
2001 queue->cwrite_off =
sizeof(*c);
2008 sizeof(
tc.challenge));
2021 gcry_cipher_encrypt (
queue->out_cipher,
2026 queue->challenge =
tc.challenge;
2027 queue->cwrite_off +=
sizeof(
tc);
2030 "handshake written\n");
2066 "Failed to store handshake monotonic time in PEERSTORE!\n");
2068 queue->handshake_monotime_sc = NULL;
2093 handshake_monotonic_time = &
queue->handshake_monotonic_time;
2096 "tcp handshake with us %s\n",
2100 queue->handshake_monotime_get = NULL;
2104 "tcp handshake from peer %s\n",
2106 if (
sizeof(*mtbe) !=
record->value_size)
2118 "Queue from %s dropped, handshake monotime in the past\n",
2122 queue->handshake_ack_monotime_get = NULL;
2127 "transport_tcp_communicator",
2130 handshake_monotonic_time,
2132 handshake_monotonic_time),
2162 gcry_cipher_decrypt (
queue->in_cipher,
2179 &
tc->sender.public_key);
2181 queue->handshake_monotime_get =
2183 "transport_tcp_communicator",
2207 queue->read_task = NULL;
2218 "Received %lu bytes to write in buffer of size %lu for KX from queue %p (expires in %"
2223 if ((EAGAIN != errno) && (EINTR != errno))
2237 "Socket for queue %p seems to have been closed\n",
queue);
2241 queue->cread_off += rcvd;
2246 "%lu/%lu bytes of KX read. Rescheduling...\n",
2260 "Invalid TCP KX received from %s\n",
2269 "Invalid sender in TCP KX received from %s\n",
2285 memmove (
queue->cread_buf,
2289 "cread_off is %lu bytes before adjusting\n",
2293 "cread_off set to %lu bytes\n",
2326 "Proto received %lu bytes for KX\n", rcvd);
2329 if ((EAGAIN != errno) && (EINTR != errno))
2344 "Socket for proto queue %p seems to have been closed\n", pq);
2354 &
pm->clientIdentity);
2357 queue->target =
pm->clientIdentity;
2380 "Invalid TCP KX received from %s\n",
2382 gcry_cipher_close (
queue->in_cipher);
2398 "created queue with target %s\n",
2402 "start kx proto\n");
2418 queue->challenge_received =
tc.challenge;
2427 struct sockaddr *in,
2439 "socket(%d) failed: %s",
2447 (errno != EINPROGRESS))
2450 "connect to `%s' failed: %s",
2483 struct sockaddr_storage in;
2487 struct sockaddr *in_addr;
2496 addrlen =
sizeof(in);
2497 memset (&in, 0,
sizeof(in));
2499 (
struct sockaddr*) &in,
2501 if ((NULL == sock) && ((EMFILE == errno) || (ENFILE == errno)))
2507 if ((NULL == sock) && ((EAGAIN == errno) || (ENOBUFS == errno)))
2522 struct sockaddr *in = cls;
2527 sizeof(
struct sockaddr),
2538 "No pending reversal found for address %s\n",
2566 struct sockaddr *in;
2567 socklen_t in_len = 0;
2569 struct sockaddr_in *v4;
2570 struct sockaddr_in6 *v6;
2578 "Connecting to %s at %s\n",
2594 "Failed to setup TCP socket address\n");
2611 "Queue for %s already exists or is in construction\n",
address);
2615 switch (in->sa_family)
2618 v4 = (
struct sockaddr_in *) in;
2619 if (0 == v4->sin_port)
2623 sizeof(
struct sockaddr),
2630 "There is already a request reversal for `%s'at `%s'\n",
2643 "IPv6 disabled, skipping %s\n",
address);
2647 v6 = (
struct sockaddr_in6 *) in;
2648 if (0 == v6->sin6_port)
2651 "Request reversal for `%s' at `%s' not possible for an IPv6 address\n",
2665 struct sockaddr_in local_sa;
2668 memset (&local_sa, 0,
sizeof(local_sa));
2669 local_sa.sin_family = AF_INET;
2677 "request reversal for `%s' at `%s' failed\n",
2684 pending_reversal->
in =
in;
2690 pending_reversal->
target = *peer;
2696 "Created NAT WAIT connection to `%s' at `%s'\n",
2709 "socket(%d) failed: %s",
2716 (errno != EINPROGRESS))
2719 "connect to `%s' failed: %s",
2728 queue->target = *peer;
2730 queue->key = queue_map_key;
2731 queue->address = in;
2732 queue->address_len = in_len;
2737 "booted queue with target %s\n",
2748 "start kx mq_init\n");
2884 "Shutdown done!\n");
2930 "after add address %s\n",
2968 "PILS service is lacking initial secret key file configuration setting. Exiting\n");
2986 "PILS service cannot create dir for saving initial secret key file. Exiting\n");
3000 if (NULL == filehandle)
3003 "PILS service had an issue with opening the initial secret key file. Exiting\n");
3014 "PILS service had an issue with writing the initial secret key to file. Exiting\n")
3024 "PILS is going to read initial secret key from file %s\n",
3029 if (NULL == filehandle)
3032 " Not able to open file\n");
3038 " File has the wrong size %lu\n",
3046 " Something is wrong with the file size, expected: %lu size, got: %lu\n",
3059 " Read initial secret key with wrong size %u, expected %lu\n",
ret,
3080 struct sockaddr_storage in_sto;
3090 "Address is NULL.\n");
3100 if (NULL == listen_sock)
3127 sto_len =
sizeof(in_sto);
3130 (
struct sockaddr *) &in_sto,
3133 memcpy (&in_sto, addr, in_len);
3141 GNUNET_a2s ((
const struct sockaddr *) &in_sto, sto_len));
3171 "creating map entry\n");
3179 "map entry created\n");
3216 "Got PID to derive from `%s':\n",
3243 const char *cfgfile,
3246 struct sockaddr *in;
3276 addr_len_ipv4 = po->addr_len_ipv4;
3280 if (NULL != po->addr_ipv4)
3284 if (NULL != po->addr_ipv6)
3286 addr_len_ipv6 = po->addr_len_ipv6;
3402 "Starting tcp communicator\n");
3408 "gnunet-communicator-libp2p",
3409 _ (
"GNUnet libp2p communicator"),
struct GNUNET_GETOPT_CommandLineOption GNUNET_GETOPT_OPTION_END
struct GNUNET_GETOPT_CommandLineOption options[]
struct GNUNET_MQ_Handle * mq
struct GNUNET_MessageHeader * msg
static int start
Set if we are to start default services (including ARM).
static int ret
Final status code.
static uint16_t port
Port number.
static struct GNUNET_TESTING_Interpreter * is
#define COMMUNICATOR_ADDRESS_PREFIX
Address prefix used by the communicator.
#define ADDRESS_VALIDITY_PERIOD
How long do we believe our addresses to remain up (before the other peer should revalidate).
#define COMMUNICATOR_CONFIG_SECTION
Configuration section used by the communicator.
static struct GNUNET_NAT_Handle * nat
Connection to NAT service.
void pid_change_cb(void *cls, const struct GNUNET_HELLO_Parser *parser, const struct GNUNET_HashCode *addr_hash)
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.
static void queue_finish(struct Queue *queue)
Append a 'finish' message to the outgoing transmission.
static void transmit_kx(struct Queue *queue, const struct GNUNET_CRYPTO_HpkeEncapsulation *c)
Generate and transmit our ephemeral key and the signature for the initial KX with the other peer.
static void boot_queue(struct Queue *queue)
Add the given queue to our internal data structure.
static size_t try_handle_plaintext(struct Queue *queue)
Test if we have received a full message in plaintext.
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.
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 *`.
static struct GNUNET_PeerIdentity my_identity
Our public key.
static void mq_destroy(struct GNUNET_MQ_Handle *mq, void *impl_state)
Signature of functions implementing the destruction of a message queue.
static struct PortOnlyIpv4Ipv6 * tcp_address_to_sockaddr_port_only(const char *bindto, unsigned int *port)
Convert TCP bind specification to a struct PortOnlyIpv4Ipv6 *
static void setup_in_cipher(const struct GNUNET_CRYPTO_HpkeEncapsulation *ephemeral, struct Queue *queue)
Setup cipher of queue for decryption.
static void do_rekey(struct Queue *queue, const struct TCPRekey *rekey)
Handle rekey message on queue.
static void eddsa_priv_to_hpke_key(struct GNUNET_CRYPTO_EddsaPrivateKey *edpk, struct GNUNET_CRYPTO_EcdhePrivateKey *pk)
static struct ProtoQueue * create_proto_queue(struct GNUNET_NETWORK_Handle *sock, struct sockaddr *in, socklen_t addrlen)
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 void listen_cb(void *cls)
We have been notified that our listen socket has something to read.
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...
static struct GNUNET_STATISTICS_Handle * stats
For logging statistics.
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...
static const struct GNUNET_CONFIGURATION_Handle * cfg
Our configuration.
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 (!...
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_PEERSTORE_Handle * peerstore
Database for peer's HELLOs.
static int pending_reversals_delete_it(void *cls, const struct GNUNET_HashCode *key, void *value)
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...
static int get_lt_delete_it(void *cls, const struct GNUNET_HashCode *key, void *value)
Iterator over all ListenTasks to clean up.
static void inject_rekey(struct Queue *queue)
Inject a struct TCPRekey message into the queue's plaintext buffer.
static void do_shutdown(void *cls)
Shutdown the UNIX communicator.
static struct GNUNET_CONTAINER_MultiHashMap * queue_map
Queues (map from peer identity to struct Queue)
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 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 *`.
static void check_and_remove_pending_reversal(struct sockaddr *in, sa_family_t sa_family, struct GNUNET_PeerIdentity *sender)
static struct GNUNET_TRANSPORT_CommunicatorHandle * ch
Our environment.
static void setup_cipher(const struct GNUNET_ShortHashCode *prk, 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.
static void setup_out_cipher(struct Queue *queue, struct GNUNET_ShortHashCode *dh)
Setup cipher for outgoing data stream based on target and our ephemeral private key.
static void run(void *cls, char *const *args, const char *cfgfile, const struct GNUNET_CONFIGURATION_Handle *c)
Setup communicator and launch network interactions.
static void pending_reversal_timeout(void *cls)
static void queue_read(void *cls)
Queue read task.
static int get_queue_delete_it(void *cls, const struct GNUNET_HashCode *target, void *value)
Iterator over all message queues to clean up.
static void mq_cancel(struct GNUNET_MQ_Handle *mq, void *impl_state)
Implementation function that cancels the currently sent message.
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...
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 void proto_queue_write(void *cls)
We have been notified that our socket is ready to write.
static void handshake_monotime_store_cb(void *cls, int success)
Callback called when peerstore store operation for handshake monotime is finished.
static void send_challenge(struct GNUNET_CRYPTO_ChallengeNonceP challenge, struct Queue *queue)
Sending challenge with TcpConfirmationAck back to sender of ephemeral key.
static void rekey_monotime_store_cb(void *cls, int success)
Callback called when peerstore store operation for rekey monotime value is finished.
static char * extract_address(const char *bindto)
This Method extracts the address part of the BINDTO string.
static int shutdown_running
A flag indicating we are already doing a shutdown.
static enum GNUNET_GenericReturnValue load_ikm()
FIXME: We could alternatively ask PILS for de/encaps, but at a high cost wrt async RPC calls....
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.
int main(int argc, char *const *argv)
The main function for the UNIX communicator.
static struct GNUNET_CRYPTO_EddsaPrivateKey * my_private_key
Our private key.
static void queue_write(void *cls)
We have been notified that our socket is ready to write.
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.
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...
static struct Addresses * addrs_head
Head of DLL with addresses we like to register at NAT service.
static struct sockaddr * tcp_address_to_sockaddr(const char *bindto, socklen_t *sock_len)
Convert TCP bind specification to a struct sockaddr *
static void eddsa_pub_to_hpke_key(struct GNUNET_CRYPTO_EddsaPublicKey *edpk, struct GNUNET_CRYPTO_EcdhePublicKey *pk)
static struct Addresses * addrs_tail
Head of DLL with addresses we like to register at NAT service.
static void setup_in_cipher_elligator(const struct GNUNET_CRYPTO_HpkeEncapsulation *c, struct Queue *queue)
Setup cipher of queue for decryption from an elligator representative.
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 unsigned int extract_port(const char *addr_and_port)
This Method extracts the port part of the BINDTO string.
static struct GNUNET_CRYPTO_EcdhePrivateKey my_x25519_private_key
Our private key.
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.
static struct GNUNET_PILS_Handle * pils
For PILS.
static void start_initial_kx_out(struct Queue *queue)
Initialize our key material for outgoing transmissions and inform the other peer about it.
static void free_proto_queue(struct ProtoQueue *pq)
Closes socket and frees memory associated with pq.
static struct GNUNET_CONTAINER_MultiHashMap * lt_map
ListenTasks (map from socket to struct ListenTask)
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.
static unsigned int bind_port
The port the communicator should be assigned to.
#define INITIAL_CORE_KX_SIZE
Size of the initial core key exchange messages.
static struct GNUNET_CONTAINER_MultiHashMap * pending_reversals
Map of pending reversals.
static struct ProtoQueue * proto_tail
Protoqueues DLL tail.
static struct GNUNET_TIME_Relative rekey_interval
The rekey interval.
#define NAT_TIMEOUT
How long until we give up on establishing an NAT connection? Must be > 4 RTT.
#define BUF_SIZE
Size of our IO buffers for ciphertext data.
static unsigned long long max_queue_length
Maximum queue length before we stop reading towards the transport service.
struct GNUNET_RESOLVER_RequestHandle * resolve_request_handle
Handle for DNS lookup of bindto address.
static int addrs_lens
Number of addresses in the DLL for register at NAT service.
#define PROTO_QUEUE_TIMEOUT
How long do we wait until we must have received the initial KX?
#define INITIAL_KX_SIZE
Size of the initial key exchange message sent first in both directions.
static struct ProtoQueue * proto_head
Protoqueues DLL head.
#define DEFAULT_REKEY_INTERVAL
How often do we rekey based on time (at least)
static unsigned long long rekey_max_bytes
The rekey byte maximum.
static void record(void *cls, size_t data_size, const void *data)
Process recorded audio data.
static char * address
GNS address for this phone.
struct GNUNET_HashCode key
The key used in the DHT.
static int disable_v6
Disable IPv6.
static struct in_addr dummy
Target "dummy" address of the packet we pretend to respond to.
struct GNUNET_CRYPTO_PrivateKey pk
Private key from command line option, or NULL.
struct GNUNET_SCHEDULER_Task * read_task
static char * value
Value of the record to add/remove.
static uint32_t type
Type string converted to DNS type value.
static unsigned char ikm[256/8]
The initial key material for the peer.
static struct GNUNET_PeerIdentity pid
Identity of the peer we transmit to / connect to.
static struct GNUNET_TRANSPORT_PluginMonitor * pm
Handle if we are monitoring plugin session activity.
static void queue(const char *hostname)
Add hostname to the list of requests to be made.
commonly used definitions; globals in this file are exempt from the rule that the module name ("commo...
Core service; the main API for encrypted P2P communications.
API to the peerstore service.
struct GNUNET_PILS_Handle * GNUNET_PILS_connect(const struct GNUNET_CONFIGURATION_Handle *cfg, GNUNET_PILS_PidChangeCallback pid_change_cb, void *cls)
Connect to the PILS service.
void GNUNET_PILS_disconnect(struct GNUNET_PILS_Handle *handle)
Disconnect from the PILS service.
void GNUNET_PILS_derive_pid(size_t seed_key_bytes, const uint8_t seed_key[seed_key_bytes], const struct GNUNET_HashCode *addrs_hash, struct GNUNET_CRYPTO_EddsaPrivateKey *outkey)
Generate the peer id from the addresses hash and the initial secret key.
Constants for network protocols.
Functions related to doing DNS lookups.
#define GNUNET_SIGNATURE_PURPOSE_COMMUNICATOR_TCP_HANDSHAKE_ACK
Signature by a peer sending back the nonce received at initial handshake.
#define GNUNET_SIGNATURE_PURPOSE_COMMUNICATOR_TCP_REKEY
Signature used by TCP communicator rekey.
#define GNUNET_SIGNATURE_PURPOSE_COMMUNICATOR_TCP_HANDSHAKE
Signature used by TCP communicator handshake.
API to create, modify and access statistics.
API of the transport service towards the communicator processes.
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.
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 GNUNET_TRANSPORT_QUEUE_LENGTH_UNLIMITED
Queue length.
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...
void GNUNET_TRANSPORT_communicator_disconnect(struct GNUNET_TRANSPORT_CommunicatorHandle *ch)
Disconnect from the transport service.
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, GNUNET_TRANSPORT_StartBurstNotify sb)
Connect to the transport service.
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.
@ GNUNET_TRANSPORT_CC_RELIABLE
Transmission is reliabile (with ACKs), e.g.
@ GNUNET_TRANSPORT_CS_INBOUND
this is an inbound connection (communicator initiated)
@ GNUNET_TRANSPORT_CS_OUTBOUND
this is an outbound connection (transport initiated)
enum GNUNET_GenericReturnValue GNUNET_CONFIGURATION_get_value_filename(const struct GNUNET_CONFIGURATION_Handle *cfg, const char *section, const char *option, char **value)
Get a configuration value that should be the name of a file or directory.
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.
#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?
enum GNUNET_GenericReturnValue GNUNET_CRYPTO_eddsa_kem_decaps(const struct GNUNET_CRYPTO_EddsaPrivateKey *priv, const struct GNUNET_CRYPTO_HpkeEncapsulation *c, struct GNUNET_ShortHashCode *prk)
Decapsulate a key for a private EdDSA key.
uint64_t GNUNET_CRYPTO_random_u64(enum GNUNET_CRYPTO_Quality mode, uint64_t max)
Generate a random unsigned 64-bit value.
enum GNUNET_GenericReturnValue GNUNET_CRYPTO_hpke_elligator_kem_decaps(const struct GNUNET_CRYPTO_EcdhePrivateKey *skR, const struct GNUNET_CRYPTO_HpkeEncapsulation *c, struct GNUNET_ShortHashCode *shared_secret)
Carries out ecdh decapsulation with own private key and the representative of the received public key...
void GNUNET_CRYPTO_random_block(enum GNUNET_CRYPTO_Quality mode, void *buffer, size_t length)
Fill block with a random values.
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.
enum GNUNET_GenericReturnValue GNUNET_CRYPTO_hpke_elligator_kem_encaps(const struct GNUNET_CRYPTO_EcdhePublicKey *pkR, struct GNUNET_CRYPTO_HpkeEncapsulation *c, struct GNUNET_ShortHashCode *shared_secret)
Carries out ecdh encapsulation with given public key and the private key from a freshly created ephem...
enum GNUNET_GenericReturnValue GNUNET_CRYPTO_eddsa_kem_encaps(const struct GNUNET_CRYPTO_EddsaPublicKey *pub, struct GNUNET_CRYPTO_HpkeEncapsulation *c, struct GNUNET_ShortHashCode *prk)
Encapsulate key material for a EdDSA public key.
#define GNUNET_CRYPTO_eddsa_sign(priv, ps, sig)
EdDSA sign a given block.
#define GNUNET_CRYPTO_eddsa_verify(purp, ps, sig, pub)
Verify EdDSA signature.
@ GNUNET_CRYPTO_QUALITY_WEAK
No good quality of the operation is needed (i.e., random numbers can be pseudo-random).
@ GNUNET_CRYPTO_QUALITY_NONCE
Randomness for IVs etc.
struct GNUNET_DISK_FileHandle * GNUNET_DISK_file_open(const char *fn, enum GNUNET_DISK_OpenFlags flags, enum GNUNET_DISK_AccessPermissions perm)
Open a file.
ssize_t GNUNET_DISK_file_write(const struct GNUNET_DISK_FileHandle *h, const void *buffer, size_t n)
Write a buffer to a file.
enum GNUNET_GenericReturnValue GNUNET_DISK_file_test_read(const char *fil)
Check that fil corresponds to a filename and the file has read permissions.
enum GNUNET_GenericReturnValue GNUNET_DISK_file_close(struct GNUNET_DISK_FileHandle *h)
Close an open file.
enum GNUNET_GenericReturnValue GNUNET_DISK_directory_create_for_file(const char *filename)
Create the directory structure for storing a file.
ssize_t GNUNET_DISK_file_read(const struct GNUNET_DISK_FileHandle *h, void *result, size_t len)
Read the contents of a binary file into a buffer.
enum GNUNET_GenericReturnValue GNUNET_DISK_file_handle_size(struct GNUNET_DISK_FileHandle *fh, off_t *size)
Get the size of an open file.
@ GNUNET_DISK_OPEN_READ
Open the file for reading.
@ GNUNET_DISK_OPEN_WRITE
Open the file for writing.
@ GNUNET_DISK_OPEN_CREATE
Create file if it doesn't exist.
@ GNUNET_DISK_PERM_USER_READ
Owner can read.
@ GNUNET_DISK_PERM_NONE
Nobody is allowed to do anything to the file.
@ GNUNET_DISK_PERM_USER_WRITE
Owner can write.
#define GNUNET_CONTAINER_DLL_remove(head, tail, element)
Remove an element from a DLL.
#define GNUNET_CONTAINER_DLL_insert(head, tail, element)
Insert an element at the head of a DLL.
void GNUNET_CRYPTO_hash(const void *block, size_t size, struct GNUNET_HashCode *ret)
Compute hash of a given block.
enum GNUNET_GenericReturnValue GNUNET_CRYPTO_hkdf_expand(void *result, size_t out_len, const struct GNUNET_ShortHashCode *prk,...)
HKDF-Expand using SHA256.
enum GNUNET_GenericReturnValue GNUNET_CONTAINER_multihashmap_contains(const struct GNUNET_CONTAINER_MultiHashMap *map, const struct GNUNET_HashCode *key)
Check if the map contains any value under the given key (including values that are NULL).
int GNUNET_CONTAINER_multihashmap_iterate(struct GNUNET_CONTAINER_MultiHashMap *map, GNUNET_CONTAINER_MultiHashMapIteratorCallback it, void *it_cls)
Iterate over all entries in the map.
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.
enum GNUNET_GenericReturnValue GNUNET_CONTAINER_multihashmap_remove(struct GNUNET_CONTAINER_MultiHashMap *map, const struct GNUNET_HashCode *key, const void *value)
Remove the given key-value pair from the map.
enum GNUNET_GenericReturnValue 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.
unsigned int GNUNET_CONTAINER_multihashmap_size(const struct GNUNET_CONTAINER_MultiHashMap *map)
Get the number of key-value pairs in the map.
void GNUNET_CONTAINER_multihashmap_destroy(struct GNUNET_CONTAINER_MultiHashMap *map)
Destroy a hash map.
struct GNUNET_CONTAINER_MultiHashMap * GNUNET_CONTAINER_multihashmap_create(unsigned int len, int do_not_copy_keys)
Create a multi hash map.
@ GNUNET_CONTAINER_MULTIHASHMAPOPTION_MULTIPLE
Allow multiple values with the same key.
@ GNUNET_CONTAINER_MULTIHASHMAPOPTION_UNIQUE_ONLY
There must only be one value per key; storing a value should fail if a value under the same key alrea...
#define GNUNET_NETWORK_STRUCT_BEGIN
Define as empty, GNUNET_PACKED should suffice, but this won't work on W32.
uint16_t type
The type of the message (GNUNET_MESSAGE_TYPE_XXXX), in big-endian format.
#define GNUNET_log(kind,...)
void GNUNET_CRYPTO_hash_context_read(struct GNUNET_HashContext *hc, const void *buf, size_t size)
Add data to be hashed.
#define GNUNET_memcmp(a, b)
Compare memory in a and b, where both must be of the same pointer type.
void GNUNET_CRYPTO_hash_context_finish(struct GNUNET_HashContext *hc, struct GNUNET_HashCode *r_hash)
Finish the hash computation.
enum GNUNET_GenericReturnValue GNUNET_CRYPTO_hpke_sk_to_x25519(const struct GNUNET_CRYPTO_PrivateKey *sk, struct GNUNET_CRYPTO_EcdhePrivateKey *x25519)
Convert a GNUnet identity key to a key sutiable for HPKE (X25519)
enum GNUNET_GenericReturnValue GNUNET_CRYPTO_hpke_pk_to_x25519(const struct GNUNET_CRYPTO_PublicKey *pk, struct GNUNET_CRYPTO_EcdhePublicKey *x25519)
Convert a GNUnet identity key to a key sutiable for HPKE (X25519)
GNUNET_GenericReturnValue
Named constants for return values.
uint16_t size
The length of the struct (in bytes, including the length field itself), in big-endian format.
struct GNUNET_HashContext * GNUNET_CRYPTO_hash_context_start(void)
Start incremental hashing operation.
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't this be the standard hmac function and the abo...
@ GNUNET_PUBLIC_KEY_TYPE_EDDSA
EDDSA identity.
#define GNUNET_break_op(cond)
Use this for assertion violations caused by other peers (i.e.
const char * GNUNET_i2s(const struct GNUNET_PeerIdentity *pid)
Convert a peer identity to a string (for printing debug messages).
const char * GNUNET_e2s(const struct GNUNET_CRYPTO_EcdhePublicKey *p)
Convert a public key value to a string (for printing debug messages).
#define GNUNET_assert(cond)
Use this for fatal errors that cannot be handled.
#define GNUNET_break(cond)
Use this for internal assertion violations that are not fatal (can be handled) but should not occur.
const char * GNUNET_h2s(const struct GNUNET_HashCode *hc)
Convert a hash value to a string (for printing debug messages).
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).
#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...
const char * GNUNET_p2s(const struct GNUNET_CRYPTO_EddsaPublicKey *p)
Convert a public key value to a string (for printing debug messages).
@ GNUNET_ERROR_TYPE_WARNING
@ GNUNET_ERROR_TYPE_ERROR
@ GNUNET_ERROR_TYPE_DEBUG
int int GNUNET_asprintf(char **buf, const char *format,...) __attribute__((format(printf
Like asprintf, just portable.
#define GNUNET_strdup(a)
Wrapper around GNUNET_xstrdup_.
#define GNUNET_new(type)
Allocate a struct or union of the given type.
#define GNUNET_malloc(size)
Wrapper around malloc.
#define GNUNET_free(ptr)
Wrapper around free.
#define GNUNET_memdup(buf, size)
Allocate and initialize a block of memory.
GNUNET_MQ_Error
Error codes for the queue.
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.
void GNUNET_MQ_impl_send_continue(struct GNUNET_MQ_Handle *mq)
Call the send implementation for the next queued message, if any.
int GNUNET_NAT_request_reversal(struct GNUNET_NAT_Handle *nh, const struct sockaddr_in *local_sa, const struct sockaddr_in *remote_sa)
We learned about a peer (possibly behind NAT) so run the gnunet-nat-client to send dummy ICMP respons...
void GNUNET_NAT_unregister(struct GNUNET_NAT_Handle *nh)
Stop port redirection and public IP address detection for the given handle.
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.
enum GNUNET_GenericReturnValue GNUNET_NETWORK_socket_close(struct GNUNET_NETWORK_Handle *desc)
Close a socket.
int GNUNET_NETWORK_get_fd(const struct GNUNET_NETWORK_Handle *desc)
Return file descriptor for this network handle.
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).
struct GNUNET_NETWORK_Handle * GNUNET_NETWORK_socket_create(int domain, int type, int protocol)
Create a new socket.
enum GNUNET_GenericReturnValue 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.
ssize_t GNUNET_NETWORK_socket_send(const struct GNUNET_NETWORK_Handle *desc, const void *buffer, size_t length)
Send data (always non-blocking).
enum GNUNET_GenericReturnValue GNUNET_NETWORK_socket_bind(struct GNUNET_NETWORK_Handle *desc, const struct sockaddr *address, socklen_t address_len)
Bind a socket to a particular address.
enum GNUNET_GenericReturnValue GNUNET_NETWORK_socket_listen(const struct GNUNET_NETWORK_Handle *desc, int backlog)
Listen on a socket.
void GNUNET_NT_scanner_done(struct GNUNET_NT_InterfaceScanner *is)
Terminate interface scanner.
struct GNUNET_NT_InterfaceScanner * GNUNET_NT_scanner_init(void)
Initialize the address characterization client handle.
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 WAN.
const struct GNUNET_OS_ProjectData * GNUNET_OS_project_data_gnunet(void)
Return default project data used by 'libgnunetutil' for GNUnet.
struct GNUNET_PEERSTORE_IterateContext * GNUNET_PEERSTORE_iteration_start(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 peerstore entries.
void GNUNET_PEERSTORE_iteration_next(struct GNUNET_PEERSTORE_IterateContext *ic, uint64_t limit)
Continue an iteration.
void GNUNET_PEERSTORE_store_cancel(struct GNUNET_PEERSTORE_StoreContext *sc)
Cancel a store request.
void GNUNET_PEERSTORE_disconnect(struct GNUNET_PEERSTORE_Handle *h)
Disconnect from the PEERSTORE service.
struct GNUNET_PEERSTORE_Handle * GNUNET_PEERSTORE_connect(const struct GNUNET_CONFIGURATION_Handle *cfg)
Connect to the PEERSTORE service.
#define GNUNET_PEERSTORE_TRANSPORT_TCP_COMMUNICATOR_HANDSHAKE
Key used to store sender's monotonic time from handshake message.
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.
#define GNUNET_PEERSTORE_TRANSPORT_TCP_COMMUNICATOR_HANDSHAKE_ACK
Key used to store sender's monotonic time from handshake ack message.
#define GNUNET_PEERSTORE_TRANSPORT_TCP_COMMUNICATOR_REKEY
Key used to store sender's monotonic time from rekey message.
void GNUNET_PEERSTORE_iteration_stop(struct GNUNET_PEERSTORE_IterateContext *ic)
Cancel an iteration.
@ GNUNET_PEERSTORE_STOREOPTION_REPLACE
Delete any previous values for the given key before storing the given value.
enum GNUNET_GenericReturnValue GNUNET_PROGRAM_run(const struct GNUNET_OS_ProjectData *pd, 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,...
#define GNUNET_MESSAGE_TYPE_COMMUNICATOR_TCP_CONFIRMATION_ACK
TCP communicator confirmation ack.
#define GNUNET_MESSAGE_TYPE_COMMUNICATOR_TCP_FINISH
TCP communicator end of stream.
#define GNUNET_MESSAGE_TYPE_COMMUNICATOR_TCP_BOX
TCP communicator payload box.
#define GNUNET_MESSAGE_TYPE_COMMUNICATOR_TCP_REKEY
TCP communicator rekey message.
void GNUNET_RESOLVER_request_cancel(struct GNUNET_RESOLVER_RequestHandle *rh)
Cancel a request that is still pending with the resolver.
void GNUNET_SCHEDULER_shutdown(void)
Request the shutdown of a scheduler.
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...
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...
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,...
void * GNUNET_SCHEDULER_cancel(struct GNUNET_SCHEDULER_Task *task)
Cancel the task with the specified identifier.
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.
void(* GNUNET_SCHEDULER_TaskCallback)(void *cls)
Signature of the main function of a task.
struct GNUNET_SCHEDULER_Task * GNUNET_SCHEDULER_add_delayed(struct GNUNET_TIME_Relative delay, GNUNET_SCHEDULER_TaskCallback task, void *task_cls)
Schedule a new task to be run with a specified delay.
struct GNUNET_STATISTICS_Handle * GNUNET_STATISTICS_create(const char *subsystem, const struct GNUNET_CONFIGURATION_Handle *cfg)
Get handle for the statistics 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.
void GNUNET_STATISTICS_update(struct GNUNET_STATISTICS_Handle *handle, const char *name, int64_t delta, int make_persistent)
Set statistic value for the peer.
void GNUNET_STATISTICS_destroy(struct GNUNET_STATISTICS_Handle *h, int sync_first)
Destroy a handle (free all state associated with it).
#define GNUNET_TIME_UNIT_FOREVER_REL
Constant used to specify "forever".
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?
const char * GNUNET_STRINGS_relative_time_to_string(struct GNUNET_TIME_Relative delta, int do_round)
Give relative time in human-readable fancy format.
struct GNUNET_TIME_Absolute GNUNET_TIME_absolute_ntoh(struct GNUNET_TIME_AbsoluteNBO a)
Convert absolute time from network byte order.
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 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.
struct GNUNET_TIME_AbsoluteNBO GNUNET_TIME_absolute_hton(struct GNUNET_TIME_Absolute a)
Convert absolute time to network byte order.
const char * GNUNET_STRINGS_absolute_time_to_string(struct GNUNET_TIME_Absolute t)
Like asctime, except for GNUnet time.
#define GNUNET_TIME_UNIT_FOREVER_ABS
Constant used to specify "forever".
static unsigned int size
Size of the "table".
static struct GNUNET_SCHEDULER_TaskContext tc
Task context of the current task.
DLL to store the addresses we like to register at NAT service.
struct Addresses * next
Kept in a DLL.
struct Addresses * prev
Kept in a DLL.
struct sockaddr * addr
Address we like to register at NAT service.
socklen_t addr_len
Length of address we like to register at NAT service.
Internal representation of the hash map.
Type of a nonce used for challenges.
uint32_t size
How many bytes does this signature sign? (including this purpose header); in network byte order (!...
uint32_t purpose
What does this signature vouch for? This must contain a GNUNET_SIGNATURE_PURPOSE_XXX constant (from g...
Private ECC key encoded for transmission.
Public ECC key (always for Curve25519) encoded in a format suitable for network transmission and encr...
Private ECC key encoded for transmission.
Public ECC key (always for curve Ed25519) encoded in a format suitable for network transmission and E...
HPKE DHKEM encapsulation (X25519) See RFC 9180.
A private key for an identity as per LSD0001.
An identity key as per LSD0001.
Handle used to access files (and pipes).
Definition of a command line option.
Context for parsing HELLOs.
Handle to a message queue.
Handle to the PEERSTORE service.
A handle for the PILS service.
The identity of the host (wraps the signing key of the peer).
struct GNUNET_CRYPTO_EddsaPublicKey public_key
Entry in list of pending tasks.
Time for absolute time used by GNUnet, in microseconds and in network byte order.
Time for absolute times used by GNUnet, in microseconds.
uint64_t abs_value_us
The actual value.
Time for relative time used by GNUnet, in microseconds.
uint64_t rel_value_us
The actual value.
Opaque handle to the transport service for communicators.
Struct to use as closure.
struct GNUNET_NETWORK_Handle * listen_sock
Listen socket.
struct GNUNET_SCHEDULER_Task * listen_task
ID of listen task.
Struct for pending nat reversals.
struct sockaddr * in
Address the reversal was send to.
struct GNUNET_SCHEDULER_Task * timeout_task
struct GNUNET_PeerIdentity target
To whom are we like to talk to.
In case of port only configuration we like to bind to ipv4 and ipv6 addresses.
struct sockaddr * addr_ipv4
Ipv4 address we like to bind to.
struct sockaddr * addr_ipv6
Ipv6 address we like to bind to.
socklen_t addr_len_ipv6
Length of ipv6 address.
socklen_t addr_len_ipv4
Length of ipv4 address.
Handle for an incoming connection where we do not yet have enough information to setup a full queue.
socklen_t address_len
Length of the address.
struct GNUNET_SCHEDULER_Task * write_task
ID of write task for this connection.
char write_buf[sizeof(struct TCPNATProbeMessage)]
buffer for writing struct TCPNATProbeMessage to network.
struct GNUNET_NETWORK_Handle * listen_sock
Listen socket.
size_t ibuf_off
Current offset for reading into ibuf.
struct GNUNET_TIME_Absolute timeout
Timeout for this protoqueue.
struct GNUNET_NETWORK_Handle * sock
socket that we transmit all data with on this queue
struct sockaddr * address
Address of the other peer.
char ibuf[(sizeof(struct GNUNET_CRYPTO_EcdhePublicKey)+sizeof(struct TCPConfirmation))]
Buffer for reading all the information we need to upgrade from protoqueue to queue.
size_t write_off
Offset of the buffer?
struct GNUNET_SCHEDULER_Task * read_task
ID of read task for this connection.
struct GNUNET_SCHEDULER_Task * write_task
ID of write task for this connection.
struct GNUNET_PeerIdentity target
To whom are we talking to.
struct GNUNET_SCHEDULER_Task * read_task
ID of read task for this connection.
struct sockaddr * address
Address of the other peer.
struct GNUNET_MessageHeader header
Type is GNUNET_MESSAGE_TYPE_COMMUNICATOR_TCP_BOX.
struct GNUNET_ShortHashCode hmac
HMAC for the following encrypted message.
Ack for the encrypted continuation of TCP initial handshake.
struct GNUNET_TIME_AbsoluteNBO monotonic_time
Monotonic time of sender, to possibly help detect replay attacks (if receiver persists times by sende...
struct GNUNET_CRYPTO_EddsaSignature sender_sig
Sender's signature of type GNUNET_SIGNATURE_PURPOSE_COMMUNICATOR_TCP_HANDSHAKE_ACK.
struct GNUNET_CRYPTO_ChallengeNonceP challenge
Challenge value used to protect against replay attack, if there is no stored monotonic time value.
struct GNUNET_MessageHeader header
Type is GNUNET_MESSAGE_TYPE_COMMUNICATOR_TCP_CONFIRMATION_ACK.
struct GNUNET_PeerIdentity sender
Sender's identity.
Encrypted continuation of TCP initial handshake.
struct GNUNET_MessageHeader header
Type is GNUNET_MESSAGE_TYPE_COMMUNICATOR_TCP_FINISH.
struct GNUNET_ShortHashCode hmac
HMAC for the following encrypted message.
Basically a WELCOME message, but with the purpose of giving the waiting peer a client handle to use.
struct GNUNET_TIME_AbsoluteNBO monotonic_time
Monotonic time of sender, to possibly help detect replay attacks (if receiver persists times by sende...
struct GNUNET_CRYPTO_EddsaSignature sender_sig
Sender's signature of type GNUNET_SIGNATURE_PURPOSE_COMMUNICATOR_TCP_REKEY.
struct GNUNET_CRYPTO_HpkeEncapsulation ephemeral
New ephemeral key.
struct GNUNET_ShortHashCode hmac
HMAC for the following encrypted message.
struct GNUNET_MessageHeader header
Type is GNUNET_MESSAGE_TYPE_COMMUNICATOR_TCP_REKEY.
Signature we use to verify that the ack from the receiver of the ephemeral key was really send by the...
struct GNUNET_CRYPTO_EccSignaturePurpose purpose
Purpose must be GNUNET_SIGNATURE_PURPOSE_COMMUNICATOR_TCP_HANDSHAKE_ACK.
struct GNUNET_PeerIdentity sender
Identity of the inititor of the TCP connection (TCP client).
struct GNUNET_CRYPTO_ChallengeNonceP challenge
Challenge value used to protect against replay attack, if there is no stored monotonic time value.
struct GNUNET_PeerIdentity receiver
Presumed identity of the target of the TCP connection (TCP server)
struct GNUNET_TIME_AbsoluteNBO monotonic_time
Monotonic time of sender, to possibly help detect replay attacks (if receiver persists times by sende...
Signature we use to verify that the ephemeral key was really chosen by the specified sender.
struct GNUNET_CRYPTO_ChallengeNonceP challenge
Challenge value used to protect against replay attack, if there is no stored monotonic time value.
struct GNUNET_CRYPTO_EccSignaturePurpose purpose
Purpose must be GNUNET_SIGNATURE_PURPOSE_COMMUNICATOR_TCP_HANDSHAKE.
struct GNUNET_CRYPTO_HpkeEncapsulation ephemeral
Ephemeral key used by the sender (as Elligator representative).
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...
struct GNUNET_PeerIdentity receiver
Presumed identity of the target of the TCP connection (TCP server)
Signature we use to verify that the ephemeral key was really chosen by the specified sender.
struct GNUNET_CRYPTO_HpkeEncapsulation ephemeral
Ephemeral key used by the sender.
struct GNUNET_CRYPTO_EccSignaturePurpose purpose
Purpose must be GNUNET_SIGNATURE_PURPOSE_COMMUNICATOR_TCP_REKEY.
struct GNUNET_PeerIdentity sender
Identity of the inititor of the TCP connection (TCP client).
struct GNUNET_PeerIdentity receiver
Presumed identity of the target of the TCP connection (TCP server)
struct GNUNET_TIME_AbsoluteNBO monotonic_time
Monotonic time of sender, to possibly help detect replay attacks (if receiver persists times by sende...