43 #include "gnunet_signatures.h"
53 #define COMMUNICATOR_CONFIG_SECTION "communicator-quic"
54 #define COMMUNICATOR_ADDRESS_PREFIX "quic"
55 #define MAX_DATAGRAM_SIZE 1350
60 #define LOCAL_CONN_ID_LEN 20
61 #define MAX_TOKEN_LEN \
62 sizeof("quiche") - 1 \
63 + sizeof(struct sockaddr_storage) \
64 + QUICHE_MAX_CONN_ID_LEN
65 #define CID_LEN sizeof(uint8_t) * QUICHE_MAX_CONN_ID_LEN
66 #define TOKEN_LEN sizeof (uint8_t) * MAX_TOKEN_LEN
77 #define ADDRESS_VALIDITY_PERIOD GNUNET_TIME_UNIT_HOURS
284 uint8_t
scid[QUICHE_MAX_CONN_ID_LEN];
287 uint8_t
dcid[QUICHE_MAX_CONN_ID_LEN];
290 uint8_t
odcid[QUICHE_MAX_CONN_ID_LEN];
305 char stream_buf[UINT16_MAX];
306 size_t buf_size = UINT16_MAX;
307 char *buf_ptr = stream_buf;
311 quiche_stream_iter *readable;
315 readable = quiche_conn_readable (
peer->conn->conn);
316 while (quiche_stream_iter_next (readable, &s))
321 recv_len = quiche_conn_stream_recv (
peer->conn->conn, s,
322 (uint8_t *) stream_buf, buf_size,
327 "error while receiving data from stream %" PRIu64
"\n", s);
341 "message recv len of %zd less than length of peer identity\n",
346 "received peer identity\n");
360 if (ntohs (hdr->
size) > recv_len)
363 "message size stated (%d) is greater than length of rcvd data (%zd)!\n",
364 ntohs (hdr->
size), recv_len);
372 recv_len -= ntohs (hdr->
size);
373 buf_ptr += ntohs (hdr->
size);
381 "message recv len of %zd less than length of message header\n",
391 "fin received, closing connection\n");
392 if (0 > quiche_conn_close (
peer->conn->conn,
true, 0, NULL, 0))
395 "quiche failed to close connection to peer\n");
399 quiche_stream_iter_free (readable);
408 struct sockaddr_storage *addr, socklen_t addr_len,
409 uint8_t *token,
size_t *token_len)
412 GNUNET_memcpy (token +
sizeof(
"quiche") - 1, addr, addr_len);
413 GNUNET_memcpy (token +
sizeof(
"quiche") - 1 + addr_len, dcid, dcid_len);
415 *token_len =
sizeof(
"quiche") - 1 + addr_len + dcid_len;
421 struct sockaddr_storage *addr, socklen_t addr_len,
422 uint8_t *odcid,
size_t *odcid_len)
424 if ((token_len <
sizeof(
"quiche") - 1) ||
425 memcmp (token,
"quiche",
sizeof(
"quiche") - 1))
430 token +=
sizeof(
"quiche") - 1;
431 token_len -=
sizeof(
"quiche") - 1;
433 if ((token_len < addr_len) || memcmp (token, addr, addr_len))
439 token_len -= addr_len;
441 if (*odcid_len < token_len)
446 memcpy (odcid, token, token_len);
447 *odcid_len = token_len;
455 uint8_t *odcid,
size_t odcid_len,
457 socklen_t local_addr_len,
458 struct sockaddr_storage *peer_addr,
459 socklen_t peer_addr_len)
467 "error while creating connection, scid length too short: %zu\n",
477 (
struct sockaddr *) peer_addr,
483 "quiche failed to create connection after call to quiche_accept\n");
496 quiche_send_info send_info;
503 written = quiche_conn_send (
conn->conn, out,
sizeof(out), &send_info);
504 if (QUICHE_ERR_DONE == written)
512 "quiche failed to create packet. quiche error: %zd\n",
517 (
struct sockaddr *) &send_info.to,
522 "quiche failed to send data to peer\n");
557 "Disconnecting peer for peer `%s'\n",
559 if (NULL !=
peer->d_qh)
573 "tried to remove non-existent peer from addr map\n");
580 quiche_conn_free (
peer->conn->conn);
623 uint16_t msize = ntohs (
msg->
size);
626 if (NULL ==
peer->conn->conn)
629 "peer never established quic connection\n");
634 if (msize >
peer->d_mtu)
637 "msize: %u, mtu: %lu\n",
644 "peer destroy called, destroying peer\n");
651 send_len = quiche_conn_stream_send (
peer->conn->conn, 4, (uint8_t *)
msg,
653 if (send_len != msize)
656 "tried to send message and quiche returned %zd", send_len);
661 "sent a message of %zd bytes\n", send_len);
679 "Default MQ destroyed\n");
718 "MQ error in queue to %s: %d\n",
732 static struct sockaddr *
741 if (1 == sscanf (bindto,
"%u%1s", &
port,
dummy))
744 if (
port > UINT16_MAX)
747 "BINDTO specification `%s' invalid: value too large for port\n",
757 struct sockaddr_in *i4;
760 i4->sin_family = AF_INET;
761 i4->sin_port = htons ((uint16_t)
port);
762 *sock_len =
sizeof(
struct sockaddr_in);
763 in = (
struct sockaddr *) i4;
767 struct sockaddr_in6 *i6;
770 i6->sin6_family = AF_INET6;
771 i6->sin6_port = htons ((uint16_t)
port);
772 *sock_len =
sizeof(
struct sockaddr_in6);
773 in = (
struct sockaddr *) i6;
778 colon = strrchr (cp,
':');
784 if (1 == sscanf (colon,
"%u%1s", &
port,
dummy))
787 if (
port > UINT16_MAX)
790 "BINDTO specification `%s' invalid: value too large for port\n",
800 "BINDTO specification `%s' invalid: last ':' not followed by number\n",
813 struct sockaddr_in v4;
815 memset (&v4, 0,
sizeof(v4));
816 if (1 == inet_pton (AF_INET, cp, &v4.sin_addr))
818 v4.sin_family = AF_INET;
819 v4.sin_port = htons ((uint16_t)
port);
820 #if HAVE_SOCKADDR_IN_SIN_LEN
821 v4.sin_len =
sizeof(
struct sockaddr_in);
824 *sock_len =
sizeof(
struct sockaddr_in);
831 struct sockaddr_in6 v6;
834 memset (&v6, 0,
sizeof(v6));
836 if ((
'[' == *cp) && (
']' == cp[strlen (cp) - 1]))
839 cp[strlen (cp) - 1] =
'\0';
841 if (1 == inet_pton (AF_INET6,
start, &v6.sin6_addr))
843 v6.sin6_family = AF_INET6;
844 v6.sin6_port = htons ((uint16_t)
port);
845 #if HAVE_SOCKADDR_IN_SIN_LEN
846 v6.sin6_len =
sizeof(
sizeof(
struct sockaddr_in6));
849 *sock_len =
sizeof(v6);
872 switch (
peer->address->sa_family)
891 peer->d_mtu = base_mtu;
894 "Setting up MQs and QHs\n");
898 if (NULL ==
peer->d_mq)
930 socklen_t address_len)
1061 struct sockaddr *in;
1068 socklen_t local_in_len;
1105 "ignoring transport service mq request, we already have an mq with this peer (address)\n");
1110 peer->address_len = in_len;
1121 peer->foreign_addr =
1130 "mq_init added new peer to the addr map\n");
1138 peer->conn = q_conn;
1140 "attempting to perform QUIC handshake with peer\n");
1143 local_in_len,
peer->address,
peer->address_len,
1158 const struct sockaddr *addr,
1163 "No connection reversal implemented!");
1185 const struct sockaddr *addr,
1229 quiche_config_free (
config);
1263 "do_shutdown finished\n");
1270 struct sockaddr_storage sa;
1271 struct sockaddr_in *addr_verify;
1272 socklen_t salen =
sizeof(sa);
1273 uint8_t
buf[UINT16_MAX];
1277 ssize_t process_pkt;
1316 (
struct sockaddr *) &sa,
1320 if (EAGAIN == errno)
1327 "Read %lu bytes\n", rcvd);
1356 peer->address_len = salen;
1373 "tried to add duplicate address into address map\n");
1377 "sock_read added new peer to address map\n");
1385 &quic_header.
type, quic_header.
scid,
1392 "failed to parse quic header: %d\n",
1400 if (NULL ==
peer->conn)
1403 "attempting to create new connection\n");
1404 if (0 == quiche_version_is_supported (quic_header.
version))
1407 "quic version negotiation initiated\n");
1415 ssize_t written = quiche_negotiate_version (quic_header.
scid,
1423 "quiche failed to generate version negotiation packet\n");
1429 (
struct sockaddr*) &sa,
1431 if (sent != written)
1434 "failed to send version negotiation packet to peer\n");
1438 "sent %zd bytes to peer during version negotiation\n",
1453 ssize_t written = quiche_retry (quic_header.
scid, quic_header.
scid_len,
1458 quic_header.
version, out,
sizeof(out));
1462 "quiche failed to write retry packet\n");
1468 (
struct sockaddr*) &sa,
1470 if (written != sent)
1486 "invalid address validation token created\n");
1493 if (NULL ==
peer->conn)
1496 "failed to create quic connection with peer\n");
1501 quiche_recv_info recv_info = {
1502 (
struct sockaddr *) &sa,
1511 if (quiche_conn_is_established (
peer->conn->conn) && !
peer->id_sent &&
1517 "handshake established with peer, sending our peer id\n");
1525 "failed to write peer identity packet. quiche error: %zd\n",
1538 process_pkt = quiche_conn_recv (
peer->conn->conn,
buf, rcvd, &recv_info);
1539 if (0 > process_pkt)
1542 "quiche failed to process received packet: %zd\n",
1547 "quiche processed %zd bytes\n", process_pkt);
1560 quiche_path_stats path_stats;
1564 if (quiche_conn_is_closed (
peer->conn->conn))
1566 quiche_conn_stats (
peer->conn->conn, &
stats);
1567 quiche_conn_path_stats (
peer->conn->conn, 0, &path_stats);
1570 "connection closed. quiche stats: sent=%zu, recv=%zu\n",
1590 const char *cfgfile,
1594 struct sockaddr *in;
1596 struct sockaddr_storage in_sto;
1619 "Failed to setup UDP socket address with path `%s'\n",
1635 if (AF_INET6 == in->sa_family)
1651 sto_len =
sizeof(in_sto);
1653 (
struct sockaddr *) &in_sto,
1656 memcpy (&in_sto, in, in_len);
1661 in = (
struct sockaddr *) &in_sto;
1666 GNUNET_a2s ((
const struct sockaddr *) &in_sto,
1668 switch (in->sa_family)
1671 my_port = ntohs (((
struct sockaddr_in *) in)->sin_port);
1675 my_port = ntohs (((
struct sockaddr_in6 *) in)->sin6_port);
1686 config = quiche_config_new (QUICHE_PROTOCOL_VERSION);
1687 quiche_config_verify_peer (
config,
false);
1691 quiche_config_load_cert_chain_from_pem_file (
config,
"./cert.crt");
1692 quiche_config_load_priv_key_from_pem_file (
config,
"./cert.key");
1693 quiche_config_set_application_protos (
config,
1695 "\x0ahq-interop\x05hq-29\x05hq-28\x05hq-27\x08http/0.9",
1697 quiche_config_set_max_idle_timeout (
config, 5000);
1698 quiche_config_set_max_recv_udp_payload_size (
config, 1200);
1699 quiche_config_set_max_send_udp_payload_size (
config, 1200);
1700 quiche_config_set_initial_max_data (
config, 10000000);
1701 quiche_config_set_initial_max_stream_data_bidi_local (
config, 1000000);
1702 quiche_config_set_initial_max_stream_data_bidi_remote (
config, 1000000);
1703 quiche_config_set_initial_max_stream_data_uni (
config, 1000000);
1704 quiche_config_set_initial_max_streams_bidi (
config, 100);
1705 quiche_config_set_initial_max_streams_uni (
config, 100);
1706 quiche_config_set_cc_algorithm (
config, QUICHE_CC_RENO);
1707 quiche_config_set_disable_active_migration (
config,
true);
1718 "Transport service is lacking key configuration settings. Exiting.\n"));
1741 (
const struct sockaddr **) &in,
1781 "Starting quic communicator\n");
1787 "gnunet-communicator-quic",
1788 _ (
"GNUnet QUIC 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 ret
Return value of the commandline.
static int start
Set if we are to start default services (including ARM).
static uint16_t port
Port number.
static char * peer_id
Option –peer.
static void mq_destroy_d(struct GNUNET_MQ_Handle *mq, void *impl_state)
Signature of functions implementing the destruction of a message queue.
struct GNUNET_PeerIdentity my_identity
Our peer identity.
#define COMMUNICATOR_ADDRESS_PREFIX
static void notify_cb(void *cls, const struct GNUNET_PeerIdentity *sender, const struct GNUNET_MessageHeader *msg)
Function called when the transport service has received a backchannel message for this communicator (...
static struct quic_conn * create_conn(uint8_t *scid, size_t scid_len, uint8_t *odcid, size_t odcid_len, struct sockaddr *local_addr, socklen_t local_addr_len, struct sockaddr_storage *peer_addr, socklen_t peer_addr_len)
#define ADDRESS_VALIDITY_PERIOD
How long do we believe our addresses to remain up (before the other peer should revalidate).
static enum GNUNET_GenericReturnValue validate_token(const uint8_t *token, size_t token_len, struct sockaddr_storage *addr, socklen_t addr_len, uint8_t *odcid, size_t *odcid_len)
static void try_connection_reversal(void *cls, const struct sockaddr *addr, socklen_t addrlen)
static struct GNUNET_NT_InterfaceScanner * is
Network scanner to determine network types.
static struct GNUNET_STATISTICS_Handle * stats
For logging statistics.
static const struct GNUNET_CONFIGURATION_Handle * cfg
Handle to the config.
static int mq_init(void *cls, const struct GNUNET_PeerIdentity *peer_id, const char *address)
Function called by the transport service to initialize a message queue given address information abou...
static void mint_token(const uint8_t *dcid, size_t dcid_len, struct sockaddr_storage *addr, socklen_t addr_len, uint8_t *token, size_t *token_len)
FIXME: review token generation, assure tokens are generated properly.
#define LOCAL_CONN_ID_LEN
static void flush_egress(struct quic_conn *conn)
static struct GNUNET_TIME_Relative rekey_interval
FIXME undocumented.
static struct GNUNET_NETWORK_Handle * udp_sock
FIXME undocumented.
static void peer_destroy(struct PeerAddress *peer)
Destroys a receiving state due to timeout or shutdown.
static void mq_send_d(struct GNUNET_MQ_Handle *mq, const struct GNUNET_MessageHeader *msg, void *impl_state)
Signature of functions implementing the sending functionality of a message queue.
static void sock_read(void *cls)
static void do_shutdown(void *cls)
Shutdown the QUIC communicator.
#define COMMUNICATOR_CONFIG_SECTION
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 ...
static struct GNUNET_TRANSPORT_CommunicatorHandle * ch
FIXME undocumented.
static void reschedule_peer_timeout(struct PeerAddress *peer)
Increment receiver timeout due to activity.
static quiche_config * config
FIXME undocumented.
struct GNUNET_CONTAINER_MultiHashMap * conn_map
Map of DCID (uint8_t) -> quic_conn for quickly retrieving connections to other peers.
static void run(void *cls, char *const *args, const char *cfgfile, const struct GNUNET_CONFIGURATION_Handle *c)
Setup communicator and launch network interactions.
static struct GNUNET_NAT_Handle * nat
Connection to NAT service.
struct GNUNET_CONTAINER_MultiHashMap * addr_map
Map of sockaddr -> struct PeerAddress.
static struct GNUNET_SCHEDULER_Task * read_task
FIXME undocumented.
static int get_peer_delete_it(void *cls, const struct GNUNET_HashCode *key, void *value)
Iterator over all peers to clean up.
static struct sockaddr * udp_address_to_sockaddr(const char *bindto, socklen_t *sock_len)
Convert UDP 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.
static struct GNUNET_TRANSPORT_ApplicationHandle * ah
FIXME undocumented.
static int have_v6_socket
FIXME undocumented.
static uint16_t my_port
FIXME undocumented.
static void check_timeouts(void *cls)
Task run to check #receiver_heap and #sender_heap for timeouts.
#define MAX_DATAGRAM_SIZE
static void recv_from_streams(struct PeerAddress *peer)
Given a PeerAddress, receive data from streams after doing connection logic.
static struct GNUNET_SCHEDULER_Task * timeout_task
ID of timeout task.
int main(int argc, char *const *argv)
static struct GNUNET_CRYPTO_EddsaPrivateKey * my_private_key
Our private key.
static void setup_peer_mq(struct PeerAddress *peer)
Setup the MQ for the peer.
static char * sockaddr_to_udpaddr_string(const struct sockaddr *address, socklen_t address_len)
Taken from: UDP communicator Converts address to the address string format used by this communicator ...
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 long long rekey_max_bytes
FIXME undocumented.
static struct GNUNET_TRANSPORT_AddressIdentifier * ai
Handle to the operation that publishes our address.
static char * address
GNS address for this phone.
struct GNUNET_HashCode key
The key used in the DHT.
static struct in_addr dummy
Target "dummy" address of the packet we pretend to respond to.
static char * value
Value of the record to add/remove.
static struct GNUNET_NAT_AUTO_Test * nt
Handle to a NAT test operation.
static char * local_addr
Local address to use for connection reversal request.
static struct GNUNET_MQ_Envelope * ac
Handle to current GNUNET_PEERINFO_add_peer() operation.
static struct GNUNET_PeerIdentity pid
Identity of the peer we transmit to / connect to.
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.
Constants for network protocols.
API to create, modify and access statistics.
Bandwidth allocation API for applications to interact with.
API of the transport service towards the communicator processes.
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.
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.
void GNUNET_TRANSPORT_application_done(struct GNUNET_TRANSPORT_ApplicationHandle *ch)
Shutdown TRANSPORT application client.
#define GNUNET_TRANSPORT_QUEUE_LENGTH_UNLIMITED
Queue length.
struct GNUNET_TRANSPORT_ApplicationHandle * GNUNET_TRANSPORT_application_init(const struct GNUNET_CONFIGURATION_Handle *cfg)
Initialize the TRANSPORT application 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 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.
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)
Connect to the transport service.
@ GNUNET_TRANSPORT_CC_RELIABLE
Transmission is reliabile (with ACKs), e.g.
@ GNUNET_TRANSPORT_CS_OUTBOUND
this is an outbound connection (transport initiated)
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".
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_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?
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.
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.
@ GNUNET_CRYPTO_QUALITY_STRONG
High-quality operations are desired.
void GNUNET_CRYPTO_hash(const void *block, size_t size, struct GNUNET_HashCode *ret)
Compute hash of a given block.
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.
struct GNUNET_CONTAINER_MultiHashMap * GNUNET_CONTAINER_multihashmap_create(unsigned int len, int do_not_copy_keys)
Create a multi hash 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.
enum GNUNET_GenericReturnValue 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.
@ 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_log(kind,...)
#define GNUNET_memcpy(dst, src, n)
Call memcpy() but check for n being 0 first.
GNUNET_GenericReturnValue
Named constants for return values.
#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).
#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.
void GNUNET_log_config_missing(enum GNUNET_ErrorType kind, const char *section, const char *option)
Log error message about missing configuration option.
#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_log_from_nocheck(enum GNUNET_ErrorType kind, const char *comp, const char *message,...) __attribute__((format(printf
Log function that specifies an alternative component.
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_file(level, cmd, filename)
Log an error message at log-level 'level' that indicates a failure of the command 'cmd' with the mess...
@ 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_free_nz(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.
GNUNET_NAT_AddressClass
Some addresses contain sensitive information or are not suitable for global distribution.
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...
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_recvfrom(const struct GNUNET_NETWORK_Handle *desc, void *buffer, size_t length, struct sockaddr *src_addr, socklen_t *addrlen)
Read data from a 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_test_pf(int pf)
Test if the given protocol family is supported by this system.
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.
ssize_t GNUNET_NETWORK_socket_sendto(const struct GNUNET_NETWORK_Handle *desc, const void *message, size_t length, const struct sockaddr *dest_addr, socklen_t dest_len)
Send data to a particular destination (always non-blocking).
GNUNET_NetworkType
Types of networks (with separate quotas) we support.
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.
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,...
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_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.
void GNUNET_STATISTICS_set(struct GNUNET_STATISTICS_Handle *handle, const char *name, uint64_t value, int make_persistent)
Set statistic value for the peer.
enum GNUNET_GenericReturnValue GNUNET_STRINGS_get_utf8_args(int argc, char *const *argv, int *u8argc, char *const **u8argv)
Returns utf-8 encoded arguments.
#define GNUNET_TIME_UNIT_FOREVER_REL
Constant used to specify "forever".
struct GNUNET_TIME_Absolute GNUNET_TIME_relative_to_absolute(struct GNUNET_TIME_Relative rel)
Convert relative time to an absolute time in the future.
Internal representation of the hash map.
Private ECC key encoded for transmission.
Definition of a command line option.
Handle to a message queue.
Handle for active NAT registrations.
Handle to the interface scanner.
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 times used by GNUnet, in microseconds.
Time for relative time used by GNUnet, in microseconds.
Internal representation of an address a communicator is currently providing for the transport service...
Handle to the TRANSPORT subsystem for application management.
Opaque handle to the transport service for communicators.
Handle returned to identify the internal data structure the transport API has created to manage a mes...
Information we track per peer we have recently been in contact with.
int id_rcvd
Flag to indicate whether we know the PeerIdentity (target) yet.
struct GNUNET_PeerIdentity target
To whom are we talking to.
struct GNUNET_TRANSPORT_QueueHandle * d_qh
handle for default queue with the ch.
struct sockaddr * address
Address of the other peer.
size_t d_mtu
MTU we allowed transport for this peer's default queue.
enum GNUNET_NetworkType nt
Which network type does this queue use?
struct GNUNET_TIME_Absolute timeout
Timeout for this peer address.
struct quic_conn * conn
The QUIC connection associated with this peer.
struct GNUNET_MQ_Handle * d_mq
Default message queue we are providing for the ch.
int id_sent
Flag to indicate whether we have sent OUR PeerIdentity to this peer.
char * foreign_addr
Address of the receiver in the human-readable format with the COMMUNICATOR_ADDRESS_PREFIX.
int peer_destroy_called
receiver_destroy already called on receiver.
socklen_t address_len
Length of the address.
int is_receiver
Flag to indicate if we are the initiator of the connection.
struct GNUNET_TESTBED_Peer * peer
The peer associated with this model.