#include "platform.h"
#include "gnunet_common.h"
#include "gnunet_util_lib.h"
#include "gnunet_transport_application_service.h"
#include "gnunet_transport_communication_service.h"
#include "gnunet_nat_service.h"
#include "gnunet_core_service.h"
#include "gnunet_protocols.h"
#include "gnunet_signatures.h"
#include "gnunet_constants.h"
#include "gnunet_statistics_service.h"
#include "stdint.h"
#include "inttypes.h"
#include "stdlib.h"
#include <ngtcp2/ngtcp2.h>
#include <ngtcp2/ngtcp2_crypto.h>
#include <ngtcp2/ngtcp2_crypto_gnutls.h>
#include <nghttp3/nghttp3.h>
#include <gnutls/crypto.h>
#include <gnutls/gnutls.h>
Go to the source code of this file.
Data Structures | |
struct | Stream |
Information of a stream. More... | |
struct | HTTP_Message |
Message to send using http. More... | |
struct | Long_Poll_Request |
Long polling structure. More... | |
struct | Connection |
Information of the connection with peer. More... | |
Macros | |
#define | COMMUNICATOR_CONFIG_SECTION "communicator-http3" |
Configuration section used by the communicator. More... | |
#define | COMMUNICATOR_ADDRESS_PREFIX "http3" |
Address prefix used by the communicator. More... | |
#define | PRIORITY |
the priorities to use on the ciphers, key exchange methods, and macs. More... | |
#define | ADDRESS_VALIDITY_PERIOD GNUNET_TIME_UNIT_HOURS |
How long do we believe our addresses to remain up (before the other peer should revalidate). More... | |
#define | NUM_LONG_POLL 16 |
Long polling requests' number. More... | |
Enumerations | |
enum | network_error { NETWORK_ERR_OK = 0 , NETWORK_ERR_FATAL = -10 , NETWORK_ERR_SEND_BLOCKED = -11 , NETWORK_ERR_CLOSE_WAIT = -12 , NETWORK_ERR_RETRY = -13 , NETWORK_ERR_DROP_CONN = -14 } |
Defines some error types related to network errors. More... | |
Functions | |
static int | connection_write (struct Connection *connection) |
Write the data in the stream into the packet and handle timer. More... | |
static uint64_t | timestamp (void) |
Get current timestamp. More... | |
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 in HELLOs. More... | |
static struct sockaddr * | udp_address_to_sockaddr (const char *bindto, socklen_t *sock_len) |
Convert UDP bind specification to a struct sockaddr * More... | |
static ngtcp2_conn * | get_conn (ngtcp2_crypto_conn_ref *ref) |
The callback function for ngtcp2_crypto_conn_ref. More... | |
static void | try_connection_reversal (void *cls, const struct sockaddr *addr, socklen_t addrlen) |
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 (!) via a different return path. More... | |
static int | send_packet (struct Connection *connection, const uint8_t *data, size_t datalen) |
Send the udp packet to remote. More... | |
static struct Stream * | create_stream (struct Connection *connection, int64_t stream_id) |
Create a new stream of connection with stream_id. More... | |
static void | remove_stream (struct Connection *connection, int64_t stream_id) |
Remove the stream with the specified stream_id in connection. More... | |
static struct Stream * | find_stream (struct Connection *connection, int64_t stream_id) |
Find the stream specified with stream_id in connection and return the pointer of the stream, otherwise return NULL if we can't find this stream. More... | |
static int | client_gnutls_init (struct Connection *connection) |
As the client, initialize the corresponding connection. More... | |
static void | reschedule_peer_timeout (struct Connection *connection) |
Increment connection timeout due to activity. More... | |
static int | get_stream_delete_it (void *cls, const struct GNUNET_HashCode *key, void *value) |
Iterator over all streams to clean up. More... | |
static void | connection_destroy (struct Connection *connection) |
Destroys a receiving state due to timeout or shutdown. More... | |
static nghttp3_nv | make_nv (const char *name, const char *value, uint8_t flag) |
Make name/value pair for request headers. More... | |
static nghttp3_ssize | read_data (nghttp3_conn *conn, int64_t stream_id, nghttp3_vec *vec, size_t veccnt, uint32_t *pflags, void *user_data, void *stream_user_data) |
The callback function to generate body. More... | |
static int | submit_post_request (struct Connection *connection, struct Stream *stream, const uint8_t *data, size_t datalen) |
Submit the post request, send our data. More... | |
static int | submit_get_request (struct Connection *connection, struct Stream *stream) |
Client side submits the GET request, allow the server to send messages. More... | |
static void | long_poll_timeoutcb (void *cls) |
Timeout callback function in the long polling struct. More... | |
static int | stream_send_data (struct Stream *stream, uint8_t *data, size_t datalen) |
Send message through the specified stream. More... | |
static int | stream_start_response (struct Connection *connection, struct Stream *stream) |
Make response to the request. More... | |
static void | mq_send_d (struct GNUNET_MQ_Handle *mq, const struct GNUNET_MessageHeader *msg, void *impl_state) |
Signature of functions implementing the sending functionality of a message queue. More... | |
static void | mq_destroy_d (struct GNUNET_MQ_Handle *mq, void *impl_state) |
Signature of functions implementing the destruction of a message queue. More... | |
static void | mq_cancel (struct GNUNET_MQ_Handle *mq, void *impl_state) |
Implementation function that cancels the currently sent message. More... | |
static void | mq_error (void *cls, enum GNUNET_MQ_Error error) |
Generic error handler, called with the appropriate error code and the same closure specified at the creation of the message queue. More... | |
static void | setup_connection_mq (struct Connection *connection) |
Setup the MQ for the connection. More... | |
static void | http_consume (struct Connection *connection, int64_t stream_id, size_t consumed) |
Extend connection and stream offset. More... | |
static int | http_stream_close_cb (nghttp3_conn *conn, int64_t stream_id, uint64_t app_error_code, void *conn_user_data, void *stream_user_data) |
The callback of nghttp3_callback.stream_close. More... | |
static int | http_recv_data_cb (nghttp3_conn *conn, int64_t stream_id, const uint8_t *data, size_t datalen, void *user_data, void *stream_user_data) |
The callback of nghttp3_callback.recv_data. More... | |
static int | http_deferred_consume_cb (nghttp3_conn *conn, int64_t stream_id, size_t nconsumed, void *user_data, void *stream_user_data) |
The callback of nghttp3_callback.deferred_consume. More... | |
static int | http_begin_headers_cb (nghttp3_conn *conn, int64_t stream_id, void *user_data, void *stream_user_data) |
The callback of nghttp3_callback.begin_headers. More... | |
static int | http_recv_header_cb (nghttp3_conn *conn, int64_t stream_id, int32_t token, nghttp3_rcbuf *name, nghttp3_rcbuf *value, uint8_t flags, void *user_data, void *stream_user_data) |
The callback of nghttp3_callback.recv_header. More... | |
static int | http_stop_sending_cb (nghttp3_conn *conn, int64_t stream_id, uint64_t app_error_code, void *user_data, void *stream_user_data) |
The callback of nghttp3_callback.stop_sending. More... | |
static int | http_end_stream_cb (nghttp3_conn *conn, int64_t stream_id, void *user_data, void *stream_user_data) |
The callback of nghttp3_callback.end_stream. More... | |
static int | http_reset_stream_cb (nghttp3_conn *conn, int64_t stream_id, uint64_t app_error_code, void *user_data, void *stream_user_data) |
The callback of nghttp3_callback.reset_stream. More... | |
static int | setup_httpconn (struct Connection *connection) |
Setup the http3 connection. More... | |
static void | rand_cb (uint8_t *dest, size_t destlen, const ngtcp2_rand_ctx *rand_ctx) |
The callback function for ngtcp2_callbacks.rand. More... | |
static int | get_new_connection_id_cb (ngtcp2_conn *conn, ngtcp2_cid *cid, uint8_t *token, size_t cidlen, void *user_data) |
The callback function for ngtcp2_callbacks.get_new_connection_id. More... | |
static int | recv_stream_data_cb (ngtcp2_conn *conn, uint32_t flags, int64_t stream_id, uint64_t offset, const uint8_t *data, size_t datalen, void *user_data, void *stream_user_data) |
The callback function for ngtcp2_callbacks.recv_stream_data. More... | |
static int | stream_open_cb (ngtcp2_conn *conn, int64_t stream_id, void *user_data) |
The callback function for ngtcp2_callbacks.stream_open. More... | |
static int | stream_close_cb (ngtcp2_conn *conn, uint32_t flags, int64_t stream_id, uint64_t app_error_code, void *user_data, void *stream_user_data) |
The callback function for ngtcp2_callbacks.stream_close. More... | |
static int | acked_stream_data_offset_cb (ngtcp2_conn *conn, int64_t stream_id, uint64_t offset, uint64_t datalen, void *user_data, void *stream_user_data) |
The callback function for ngtcp2_callbacks.acked_stream_data_offset. More... | |
static int | extend_max_stream_data_cb (ngtcp2_conn *conn, int64_t stream_id, uint64_t max_data, void *user_data, void *stream_user_data) |
The callback function for ngtcp2_callbacks.extend_max_stream_data. More... | |
static int | stream_reset_cb (ngtcp2_conn *conn, int64_t stream_id, uint64_t final_size, uint64_t app_error_code, void *user_data, void *stream_user_data) |
The callback function for ngtcp2_callbacks.stream_reset. More... | |
static int | extend_max_remote_streams_bidi_cb (ngtcp2_conn *conn, uint64_t max_streams, void *user_data) |
The callback function for ngtcp2_callbacks.extend_max_remote_streams_bidi. More... | |
static int | stream_stop_sending_cb (ngtcp2_conn *conn, int64_t stream_id, uint64_t app_error_code, void *user_data, void *stream_user_data) |
The callback function for ngtcp2_callbacks.stream_stop_sending. More... | |
static int | recv_tx_key_cb (ngtcp2_conn *conn, ngtcp2_encryption_level level, void *user_data) |
The callback function for ngtcp2_callbacks.recv_tx_key. More... | |
static int | recv_rx_key_cb (ngtcp2_conn *conn, ngtcp2_encryption_level level, void *user_data) |
The callback function for ngtcp2_callbacks.recv_rx_key. More... | |
static int | client_quic_init (struct Connection *connection, struct sockaddr *local_addr, socklen_t local_addrlen, struct sockaddr *remote_addr, socklen_t remote_addrlen) |
Create new ngtcp2_conn as client side. More... | |
static void | close_waitcb (void *cls) |
The timeout callback function of closing/draining period. More... | |
static void | start_draining_period (struct Connection *connection) |
Start the draining period, called after receiving CONNECTION_CLOSE. More... | |
static int | start_closing_period (struct Connection *connection) |
Start the closing period and build the packet contains CONNECTION_CLOSE. More... | |
static int | send_conn_close (struct Connection *connection) |
Send the packet in the conn_closebuf. More... | |
static int | handle_error (struct Connection *connection) |
Handle errors. More... | |
static int | handle_expiry (struct Connection *connection) |
Handles expired timer. More... | |
static void | timeoutcb (void *cls) |
The timer callback function. More... | |
static void | connection_update_timer (struct Connection *connection) |
Update the timer. More... | |
static int | connection_write_streams (struct Connection *connection) |
Write HTTP stream data and send the packets. More... | |
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 about another peer. More... | |
static void | nat_address_cb (void *cls, void **app_ctx, int add_remove, enum GNUNET_NAT_AddressClass ac, const struct sockaddr *addr, socklen_t addrlen) |
Signature of the callback passed to GNUNET_NAT_register() for a function to call whenever our set of 'valid' addresses changes. More... | |
static int | get_connection_delete_it (void *cls, const struct GNUNET_HashCode *key, void *value) |
Iterator over all connection to clean up. More... | |
static void | do_shutdown (void *cls) |
Shutdown the HTTP3 communicator. More... | |
static int | connection_feed_data (struct Connection *connection, struct sockaddr *local_addr, socklen_t local_addrlen, struct sockaddr *remote_addr, socklen_t remote_addrlen, const ngtcp2_pkt_info *pi, const uint8_t *data, size_t datalen) |
Decrypt QUIC packet. More... | |
static int | connection_on_read (struct Connection *connection, struct sockaddr *local_addr, socklen_t local_addrlen, struct sockaddr *remote_addr, socklen_t remote_addrlen, const ngtcp2_pkt_info *pi, const uint8_t *data, size_t datalen) |
Connection read the packet data. More... | |
static struct Connection * | connection_init (struct sockaddr *local_addr, socklen_t local_addrlen, struct sockaddr *remote_addr, socklen_t remote_addrlen, const ngtcp2_cid *dcid, const ngtcp2_cid *scid, uint32_t version) |
Create a new connection. More... | |
static void | server_read_pkt (struct Connection *connection, const struct GNUNET_HashCode *addr_key, struct sockaddr *local_addr, socklen_t local_addrlen, struct sockaddr *remote_addr, socklen_t remote_addrlen, const ngtcp2_pkt_info *pi, const uint8_t *data, size_t datalen) |
The server processes the newly received data packet. More... | |
static void | sock_read (void *cls) |
Socket read task. More... | |
static void | run (void *cls, char *const *args, const char *cfgfile, const struct GNUNET_CONFIGURATION_Handle *c) |
Setup communicator and launch network interactions. More... | |
int | main (int argc, char *const *argv) |
The main function for the UNIX communicator. More... | |
Variables | |
static struct GNUNET_CONTAINER_MultiHashMap * | addr_map |
Map of sockaddr -> struct Connection. More... | |
static const struct GNUNET_CONFIGURATION_Handle * | cfg |
Our configuration. More... | |
static struct GNUNET_CRYPTO_EddsaPrivateKey * | my_private_key |
Our private key. More... | |
static struct GNUNET_PeerIdentity | my_identity |
Our peer identity. More... | |
static int | disable_v6 |
IPv6 disabled or not. More... | |
static struct GNUNET_NETWORK_Handle * | udp_sock |
Our socket. More... | |
static struct GNUNET_SCHEDULER_Task * | read_task |
ID of listen task. More... | |
static struct GNUNET_TRANSPORT_CommunicatorHandle * | ch |
Our environment. More... | |
static struct GNUNET_NAT_Handle * | nat |
Connection to NAT service. More... | |
static int | have_v6_socket |
GNUNET_YES if udp_sock supports IPv6. More... | |
static uint16_t | my_port |
Port number to which we are actually bound. More... | |
static struct GNUNET_NT_InterfaceScanner * | is |
Network scanner to determine network types. More... | |
static struct GNUNET_STATISTICS_Handle * | stats |
For logging statistics. More... | |
static gnutls_certificate_credentials_t | cred |
The credential. More... | |
#define COMMUNICATOR_CONFIG_SECTION "communicator-http3" |
Configuration section used by the communicator.
Definition at line 28 of file gnunet-communicator-http3.c.
#define COMMUNICATOR_ADDRESS_PREFIX "http3" |
Address prefix used by the communicator.
Definition at line 33 of file gnunet-communicator-http3.c.
#define PRIORITY |
the priorities to use on the ciphers, key exchange methods, and macs.
Definition at line 38 of file gnunet-communicator-http3.c.
#define ADDRESS_VALIDITY_PERIOD GNUNET_TIME_UNIT_HOURS |
How long do we believe our addresses to remain up (before the other peer should revalidate).
Definition at line 47 of file gnunet-communicator-http3.c.
#define NUM_LONG_POLL 16 |
Long polling requests' number.
Definition at line 52 of file gnunet-communicator-http3.c.
enum network_error |
Defines some error types related to network errors.
Enumerator | |
---|---|
NETWORK_ERR_OK | |
NETWORK_ERR_FATAL | |
NETWORK_ERR_SEND_BLOCKED | |
NETWORK_ERR_CLOSE_WAIT | |
NETWORK_ERR_RETRY | |
NETWORK_ERR_DROP_CONN |
Definition at line 57 of file gnunet-communicator-http3.c.
|
static |
Write the data in the stream into the packet and handle timer.
connection | the connection of the peer |
Definition at line 2915 of file gnunet-communicator-http3.c.
References Connection::conn, connection_update_timer(), connection_write_streams(), GNUNET_NO, and Connection::is_initiator.
Referenced by mq_init(), mq_send_d(), server_read_pkt(), sock_read(), and timeoutcb().
|
static |
Get current timestamp.
Definition at line 415 of file gnunet-communicator-http3.c.
Referenced by cleanup_store_discourse_messages_before(), client_quic_init(), connection_feed_data(), connection_update_timer(), connection_write_streams(), create_subscription(), find_proof(), get_matching_bits(), handle_estimate(), handle_expiry(), handle_message_subscribe(), has_subscription_of_timestamp(), iterate_flag_for_cleanup_discourse_message(), mq_send_d(), notify_srv_handle_message(), nse_callback(), nse_cb(), read_start_time(), solve_srv_room_member_collisions(), start_closing_period(), start_operation(), transmit_task_cb(), update_subscription(), verify_tunnel_message(), and write_start_time().
|
static |
Taken from: UDP communicator Converts address to the address string format used by this communicator in HELLOs.
address | the address to convert, must be AF_INET or AF_INET6. |
address_len | number of bytes in address |
Definition at line 433 of file gnunet-communicator-http3.c.
References address, COMMUNICATOR_ADDRESS_PREFIX, GNUNET_a2s(), GNUNET_asprintf(), GNUNET_assert, and ret.
Referenced by connection_init(), mq_init(), and sock_read().
|
static |
Convert UDP bind specification to a struct sockaddr *
bindto | bind specification to convert | |
[out] | sock_len | set to the length of the address |
Definition at line 469 of file gnunet-communicator-http3.c.
References disable_v6, dummy, GNUNET_ERROR_TYPE_ERROR, GNUNET_free, GNUNET_log, GNUNET_malloc, GNUNET_memdup, GNUNET_strdup, GNUNET_YES, port, and start.
Referenced by mq_init(), run(), and sock_read().
|
static |
The callback function for ngtcp2_crypto_conn_ref.
Definition at line 596 of file gnunet-communicator-http3.c.
Referenced by client_quic_init(), and connection_init().
|
static |
Definition at line 603 of file gnunet-communicator-http3.c.
References GNUNET_ERROR_TYPE_INFO, and GNUNET_log.
Referenced by run().
|
static |
Function called when the transport service has received a backchannel message for this communicator (!) via a different return path.
Should be an acknowledgement.
cls | closure, NULL |
sender | which peer sent the notification |
msg | payload |
Definition at line 623 of file gnunet-communicator-http3.c.
Referenced by GNUNET_TRANSPORT_communicator_connect(), run(), and sampler_notify_on_update().
|
static |
Send the udp packet to remote.
connection | connection of the peer |
data | the data we want to send |
datalen | the length of data |
Definition at line 641 of file gnunet-communicator-http3.c.
References Connection::address, Connection::address_len, data, GNUNET_ERROR_TYPE_DEBUG, GNUNET_log, GNUNET_NETWORK_socket_sendto(), GNUNET_NO, GNUNET_SYSERR, and udp_sock.
Referenced by connection_write_streams(), send_conn_close(), and start_closing_period().
|
static |
Create a new stream of connection with stream_id.
And return this stream.
connection | the connection. |
stream_id | the ID of new stream. |
Definition at line 668 of file gnunet-communicator-http3.c.
References Stream::connection, GNUNET_CONTAINER_multihashmap_put(), GNUNET_CONTAINER_MULTIHASHMAPOPTION_UNIQUE_ONLY, GNUNET_CRYPTO_hash(), GNUNET_new, Stream::stream_id, and Connection::streams.
Referenced by http_end_stream_cb(), mq_send_d(), recv_rx_key_cb(), and stream_open_cb().
|
static |
Remove the stream with the specified stream_id in connection.
connection | the connection. |
stream_id | the ID of the stream. |
Definition at line 693 of file gnunet-communicator-http3.c.
References Stream::authority, Stream::connection, GNUNET_CONTAINER_multihashmap_get(), GNUNET_CONTAINER_multihashmap_remove(), GNUNET_CRYPTO_hash(), GNUNET_ERROR_TYPE_WARNING, GNUNET_free, GNUNET_log, GNUNET_NO, Stream::method, Stream::stream_id, Connection::streams, and Stream::uri.
Referenced by http_stream_close_cb().
|
static |
Find the stream specified with stream_id in connection and return the pointer of the stream, otherwise return NULL if we can't find this stream.
connection | the connection. |
stream_id | the ID of the stream. |
Definition at line 739 of file gnunet-communicator-http3.c.
References Stream::connection, GNUNET_CONTAINER_multihashmap_get(), GNUNET_CRYPTO_hash(), Stream::stream_id, and Connection::streams.
Referenced by http_begin_headers_cb().
|
static |
As the client, initialize the corresponding connection.
connection | Corresponding connection |
TODO: Handle the situation when the remote host is an IP address. Numeric ip address are not permitted according to the document of GNUtls.
Definition at line 758 of file gnunet-communicator-http3.c.
References Connection::conn_ref, Stream::connection, cred, GNUNET_ERROR_TYPE_DEBUG, GNUNET_log, GNUNET_NO, GNUNET_SYSERR, PRIORITY, and Connection::session.
Referenced by mq_init().
|
static |
Increment connection timeout due to activity.
connection | address for which the timeout should be rescheduled |
Definition at line 828 of file gnunet-communicator-http3.c.
References Stream::connection, GNUNET_CONSTANTS_IDLE_CONNECTION_TIMEOUT, GNUNET_TIME_relative_to_absolute(), and Connection::timeout.
Referenced by mq_send_d().
|
static |
Iterator over all streams to clean up.
cls | NULL |
key | stream->stream_id |
value | the stream to destroy |
Definition at line 846 of file gnunet-communicator-http3.c.
References Stream::authority, GNUNET_free, GNUNET_OK, key, Stream::method, Stream::uri, and value.
Referenced by connection_destroy().
|
static |
Destroys a receiving state due to timeout or shutdown.
connection | entity to close down |
Definition at line 877 of file gnunet-communicator-http3.c.
References addr_map, Connection::address, Connection::address_len, HTTP_Message::buf, Connection::conn, Connection::conn_closebuf, Connection::connection_destroy_called, Connection::d_qh, Connection::foreign_addr, get_stream_delete_it(), GNUNET_CONTAINER_multihashmap_destroy(), GNUNET_CONTAINER_multihashmap_iterate(), GNUNET_CONTAINER_multihashmap_remove(), GNUNET_CONTAINER_multihashmap_size(), GNUNET_CRYPTO_hash(), GNUNET_ERROR_TYPE_WARNING, GNUNET_free, GNUNET_log, GNUNET_NO, GNUNET_STATISTICS_set(), GNUNET_TRANSPORT_communicator_mq_del(), GNUNET_YES, Connection::h3_conn, Connection::long_poll_head, Connection::long_poll_rear, Connection::msg_queue_head, Connection::msg_queue_rear, HTTP_Message::next, Long_Poll_Request::next, Connection::session, stats, Connection::streams, and Connection::submitted_msg_queue_head.
Referenced by close_waitcb(), GCO_init(), get_connection_delete_it(), handle_error(), mq_destroy_d(), mq_error(), mq_send_d(), server_read_pkt(), and timeoutcb().
|
static |
Make name/value pair for request headers.
name | The HTTP filed name. |
value | The HTTP filed value. |
flag | Flags for name/value pair. |
Definition at line 960 of file gnunet-communicator-http3.c.
Referenced by long_poll_timeoutcb(), stream_send_data(), stream_start_response(), submit_get_request(), and submit_post_request().
|
static |
The callback function to generate body.
Definition at line 977 of file gnunet-communicator-http3.c.
References Stream::data, and Stream::datalen.
Referenced by stream_send_data(), and submit_post_request().
|
static |
Submit the post request, send our data.
connection | the connection. |
stream | the stream. |
data | the data will be sent. |
datalen | the length of data. |
Definition at line 1002 of file gnunet-communicator-http3.c.
References Connection::address, Connection::address_len, Stream::connection, data, Stream::data, Stream::datalen, GNUNET_a2s(), GNUNET_ERROR_TYPE_DEBUG, GNUNET_log, GNUNET_NO, GNUNET_snprintf(), GNUNET_SYSERR, Connection::h3_conn, make_nv(), read_data(), and Stream::stream_id.
Referenced by mq_send_d(), and recv_rx_key_cb().
|
static |
Client side submits the GET request, allow the server to send messages.
connection | the connection. |
stream | the stream. |
Definition at line 1063 of file gnunet-communicator-http3.c.
References Connection::address, Connection::address_len, Stream::connection, GNUNET_a2s(), GNUNET_ERROR_TYPE_DEBUG, GNUNET_log, GNUNET_NO, GNUNET_SYSERR, Connection::h3_conn, make_nv(), and Stream::stream_id.
Referenced by http_end_stream_cb(), and recv_rx_key_cb().
|
static |
Timeout callback function in the long polling struct.
cls | the closure. |
Definition at line 1108 of file gnunet-communicator-http3.c.
References Connection::conn, Stream::connection, GNUNET_ERROR_TYPE_DEBUG, GNUNET_free, GNUNET_log, Connection::h3_conn, Connection::long_poll_head, Connection::long_poll_rear, make_nv(), Long_Poll_Request::next, Long_Poll_Request::prev, Long_Poll_Request::stream, Stream::stream_id, and Long_Poll_Request::timer.
Referenced by stream_start_response().
|
static |
Send message through the specified stream.
Mainly used to send data when the server responds.
stream | the stream. |
data | the data. |
datalen | the length of data. |
Definition at line 1172 of file gnunet-communicator-http3.c.
References Stream::connection, data, Stream::data, Stream::datalen, GNUNET_ERROR_TYPE_DEBUG, GNUNET_log, GNUNET_NO, GNUNET_snprintf(), GNUNET_SYSERR, Connection::h3_conn, make_nv(), read_data(), and Stream::stream_id.
Referenced by mq_send_d(), and stream_start_response().
|
static |
Make response to the request.
h3_conn | the HTTP/3 connection. |
stream | the stream. |
Definition at line 1220 of file gnunet-communicator-http3.c.
References Long_Poll_Request::delay_time, GNUNET_ERROR_TYPE_DEBUG, GNUNET_free, GNUNET_log, GNUNET_new, GNUNET_NO, GNUNET_SCHEDULER_add_delayed(), GNUNET_SCHEDULER_cancel(), GNUNET_SYSERR, GNUNET_TIME_relative_multiply(), GNUNET_TIME_UNIT_SECONDS, Connection::h3_conn, Connection::long_poll_head, Connection::long_poll_len, Connection::long_poll_rear, long_poll_timeoutcb(), make_nv(), Stream::methodlen, msg, Connection::msg_queue_head, Connection::msg_queue_len, Long_Poll_Request::next, NUM_LONG_POLL, Long_Poll_Request::prev, GNUNET_MessageHeader::size, Long_Poll_Request::stream, Stream::stream_id, stream_send_data(), Connection::submitted_msg_queue_head, and Long_Poll_Request::timer.
Referenced by http_end_stream_cb().
|
static |
Signature of functions implementing the sending functionality of a message queue.
mq | the message queue |
msg | the message to send |
impl_state | our struct PeerAddress |
Definition at line 1352 of file gnunet-communicator-http3.c.
References HTTP_Message::buf, Connection::conn, connection_destroy(), Connection::connection_destroy_called, connection_write(), create_stream(), Connection::d_mq, Connection::d_mtu, GNUNET_assert, GNUNET_break, GNUNET_ERROR_TYPE_DEBUG, GNUNET_ERROR_TYPE_ERROR, GNUNET_free, GNUNET_log, GNUNET_memdup, GNUNET_MQ_impl_send_continue(), GNUNET_new, GNUNET_SCHEDULER_cancel(), GNUNET_YES, Connection::is_initiator, Connection::long_poll_head, Connection::long_poll_len, mq, msg, Connection::msg_queue_head, Connection::msg_queue_len, Connection::msg_queue_rear, HTTP_Message::next, Long_Poll_Request::next, Long_Poll_Request::prev, reschedule_peer_timeout(), GNUNET_MessageHeader::size, HTTP_Message::size, Long_Poll_Request::stream, Stream::stream_id, stream_send_data(), submit_post_request(), Connection::submitted_msg_queue_head, Long_Poll_Request::timer, and timestamp().
Referenced by setup_connection_mq().
|
static |
Signature of functions implementing the destruction of a message queue.
Implementations must not free mq, but should take care of impl_state.
mq | the message queue to destroy |
impl_state | our struct PeerAddress |
Definition at line 1484 of file gnunet-communicator-http3.c.
References connection_destroy(), Connection::connection_destroy_called, Connection::d_mq, GNUNET_ERROR_TYPE_DEBUG, GNUNET_log, GNUNET_YES, and mq.
Referenced by setup_connection_mq().
|
static |
Implementation function that cancels the currently sent message.
mq | message queue |
impl_state | our struct PeerAddress |
Definition at line 1505 of file gnunet-communicator-http3.c.
References GNUNET_assert.
Referenced by setup_connection_mq().
|
static |
Generic error handler, called with the appropriate error code and the same closure specified at the creation of the message queue.
Not every message queue implementation supports an error handler.
cls | our struct ReceiverAddress |
error | error code |
Definition at line 1522 of file gnunet-communicator-http3.c.
References connection_destroy(), GNUNET_ERROR_TYPE_ERROR, GNUNET_i2s(), GNUNET_log, and Connection::target.
Referenced by setup_connection_mq().
|
static |
Setup the MQ for the connection.
If a queue exists, the existing one is destroyed. Then the MTU is recalculated and a fresh queue is initialized.
connection | connection to setup MQ for |
Definition at line 1541 of file gnunet-communicator-http3.c.
References Connection::address, ch, Connection::d_mq, Connection::d_mtu, Connection::d_qh, Connection::foreign_addr, GNUNET_assert, GNUNET_ERROR_TYPE_DEBUG, GNUNET_log, GNUNET_MQ_queue_for_callbacks(), GNUNET_TRANSPORT_communicator_mq_add(), GNUNET_TRANSPORT_CS_OUTBOUND, GNUNET_TRANSPORT_QUEUE_LENGTH_UNLIMITED, Connection::is_initiator, mq_cancel(), mq_destroy_d(), mq_error(), mq_send_d(), Connection::nt, and Connection::target.
Referenced by http_recv_data_cb(), and recv_rx_key_cb().
|
static |
Extend connection and stream offset.
Definition at line 1594 of file gnunet-communicator-http3.c.
References Connection::conn.
Referenced by http_deferred_consume_cb(), http_recv_data_cb(), and recv_stream_data_cb().
|
static |
The callback of nghttp3_callback.stream_close.
Definition at line 1605 of file gnunet-communicator-http3.c.
References Connection::conn, GNUNET_ERROR_TYPE_DEBUG, GNUNET_log, GNUNET_NO, GNUNET_YES, Connection::is_initiator, and remove_stream().
Referenced by setup_httpconn().
|
static |
The callback of nghttp3_callback.recv_data.
Definition at line 1634 of file gnunet-communicator-http3.c.
References ADDRESS_VALIDITY_PERIOD, ch, data, GNUNET_ERROR_TYPE_DEBUG, GNUNET_ERROR_TYPE_ERROR, GNUNET_log, GNUNET_NO, GNUNET_SYSERR, GNUNET_TRANSPORT_communicator_receive(), GNUNET_YES, http_consume(), Connection::id_rcvd, Connection::is_initiator, pid, setup_connection_mq(), GNUNET_MessageHeader::size, and Connection::target.
Referenced by setup_httpconn().
|
static |
The callback of nghttp3_callback.deferred_consume.
Definition at line 1689 of file gnunet-communicator-http3.c.
References http_consume().
Referenced by setup_httpconn().
|
static |
The callback of nghttp3_callback.begin_headers.
Definition at line 1703 of file gnunet-communicator-http3.c.
References Stream::connection, find_stream(), Connection::h3_conn, and Stream::stream_id.
Referenced by setup_httpconn().
|
static |
The callback of nghttp3_callback.recv_header.
Definition at line 1724 of file gnunet-communicator-http3.c.
References Stream::authority, Stream::authoritylen, GNUNET_ERROR_TYPE_DEBUG, GNUNET_log, GNUNET_NO, Connection::is_initiator, Stream::method, Stream::methodlen, name, Stream::uri, Stream::urilen, and value.
Referenced by setup_httpconn().
|
static |
The callback of nghttp3_callback.stop_sending.
Definition at line 1766 of file gnunet-communicator-http3.c.
References Connection::conn, GNUNET_ERROR_TYPE_DEBUG, and GNUNET_log.
Referenced by setup_httpconn().
|
static |
The callback of nghttp3_callback.end_stream.
When the client side receives the response to Long polling, it sends a new GET request again.
Definition at line 1792 of file gnunet-communicator-http3.c.
References Connection::conn, create_stream(), GNUNET_ERROR_TYPE_DEBUG, GNUNET_log, GNUNET_NO, Connection::is_initiator, Connection::long_poll_head, Long_Poll_Request::next, Long_Poll_Request::stream, Stream::stream_id, stream_start_response(), and submit_get_request().
Referenced by setup_httpconn().
|
static |
The callback of nghttp3_callback.reset_stream.
Definition at line 1846 of file gnunet-communicator-http3.c.
References Connection::conn, GNUNET_ERROR_TYPE_DEBUG, and GNUNET_log.
Referenced by setup_httpconn().
|
static |
Setup the http3 connection.
connection | the connection |
Definition at line 1876 of file gnunet-communicator-http3.c.
References Connection::conn, GNUNET_ERROR_TYPE_DEBUG, GNUNET_log, GNUNET_NO, GNUNET_SYSERR, GNUNET_YES, Connection::h3_conn, http_begin_headers_cb(), http_deferred_consume_cb(), http_end_stream_cb(), http_recv_data_cb(), http_recv_header_cb(), http_reset_stream_cb(), http_stop_sending_cb(), http_stream_close_cb(), and Connection::is_initiator.
Referenced by recv_rx_key_cb(), and recv_tx_key_cb().
|
static |
The callback function for ngtcp2_callbacks.rand.
Definition at line 2010 of file gnunet-communicator-http3.c.
References warningfilter::dest, GNUNET_CRYPTO_QUALITY_STRONG, and GNUNET_CRYPTO_random_block().
Referenced by client_quic_init(), and connection_init().
|
static |
The callback function for ngtcp2_callbacks.get_new_connection_id.
Definition at line 2025 of file gnunet-communicator-http3.c.
References Connection::conn, GNUNET_CRYPTO_QUALITY_STRONG, GNUNET_CRYPTO_random_block(), and GNUNET_NO.
Referenced by client_quic_init(), and connection_init().
|
static |
The callback function for ngtcp2_callbacks.recv_stream_data.
Definition at line 2047 of file gnunet-communicator-http3.c.
References data, GNUNET_ERROR_TYPE_DEBUG, GNUNET_log, Connection::h3_conn, http_consume(), Connection::is_initiator, and Connection::last_error.
Referenced by client_quic_init(), and connection_init().
|
static |
The callback function for ngtcp2_callbacks.stream_open.
Definition at line 2082 of file gnunet-communicator-http3.c.
References create_stream().
Referenced by connection_init().
|
static |
The callback function for ngtcp2_callbacks.stream_close.
Definition at line 2100 of file gnunet-communicator-http3.c.
References Connection::conn, GNUNET_ERROR_TYPE_DEBUG, GNUNET_log, GNUNET_NO, GNUNET_YES, Connection::h3_conn, Connection::is_initiator, and Connection::last_error.
Referenced by client_quic_init(), and connection_init().
|
static |
The callback function for ngtcp2_callbacks.acked_stream_data_offset.
Definition at line 2160 of file gnunet-communicator-http3.c.
References GNUNET_ERROR_TYPE_DEBUG, GNUNET_log, and Connection::h3_conn.
Referenced by client_quic_init(), and connection_init().
|
static |
The callback function for ngtcp2_callbacks.extend_max_stream_data.
Definition at line 2188 of file gnunet-communicator-http3.c.
References GNUNET_ERROR_TYPE_DEBUG, GNUNET_log, and Connection::h3_conn.
Referenced by client_quic_init(), and connection_init().
|
static |
The callback function for ngtcp2_callbacks.stream_reset.
Definition at line 2211 of file gnunet-communicator-http3.c.
References GNUNET_ERROR_TYPE_DEBUG, GNUNET_log, and Connection::h3_conn.
Referenced by client_quic_init().
|
static |
The callback function for ngtcp2_callbacks.extend_max_remote_streams_bidi.
Definition at line 2237 of file gnunet-communicator-http3.c.
References Connection::h3_conn.
Referenced by connection_init().
|
static |
The callback function for ngtcp2_callbacks.stream_stop_sending.
Definition at line 2254 of file gnunet-communicator-http3.c.
References GNUNET_ERROR_TYPE_DEBUG, GNUNET_log, and Connection::h3_conn.
Referenced by client_quic_init(), and connection_init().
|
static |
The callback function for ngtcp2_callbacks.recv_tx_key.
Definition at line 2280 of file gnunet-communicator-http3.c.
References setup_httpconn().
Referenced by connection_init().
|
static |
The callback function for ngtcp2_callbacks.recv_rx_key.
Definition at line 2304 of file gnunet-communicator-http3.c.
References create_stream(), GNUNET_new, GNUNET_NO, GNUNET_YES, Connection::id_sent, Connection::is_initiator, Connection::long_poll_head, Connection::long_poll_rear, my_identity, Long_Poll_Request::next, NUM_LONG_POLL, Long_Poll_Request::prev, setup_connection_mq(), setup_httpconn(), Long_Poll_Request::stream, Stream::stream_id, submit_get_request(), submit_post_request(), and Long_Poll_Request::timer.
Referenced by client_quic_init().
|
static |
Create new ngtcp2_conn as client side.
connection | new connection of the peer |
local_addr | local socket address |
local_addrlen | local socket address length |
remote_addr | remote(peer's) socket address |
remote_addrlen | remote socket address length |
Definition at line 2375 of file gnunet-communicator-http3.c.
References acked_stream_data_offset_cb(), Connection::conn, Connection::conn_ref, extend_max_stream_data_cb(), get_conn(), get_new_connection_id_cb(), GNUNET_CRYPTO_QUALITY_STRONG, GNUNET_CRYPTO_random_block(), GNUNET_ERROR_TYPE_DEBUG, GNUNET_log, GNUNET_NO, GNUNET_SYSERR, local_addr, rand_cb(), recv_rx_key_cb(), recv_stream_data_cb(), remote_addr, Connection::session, stream_close_cb(), stream_reset_cb(), stream_stop_sending_cb(), and timestamp().
Referenced by mq_init().
|
static |
The timeout callback function of closing/draining period.
cls | the closure of Connection. |
Definition at line 2466 of file gnunet-communicator-http3.c.
References Connection::conn, connection_destroy(), GNUNET_ERROR_TYPE_DEBUG, GNUNET_log, and Connection::timer.
Referenced by start_closing_period(), and start_draining_period().
|
static |
Start the draining period, called after receiving CONNECTION_CLOSE.
connection | The connection |
Definition at line 2494 of file gnunet-communicator-http3.c.
References close_waitcb(), Connection::conn, GNUNET_ERROR_TYPE_DEBUG, GNUNET_log, GNUNET_SCHEDULER_add_delayed(), GNUNET_SCHEDULER_cancel(), GNUNET_TIME_relative_multiply(), GNUNET_TIME_UNIT_MICROSECONDS, and Connection::timer.
Referenced by connection_feed_data().
|
static |
Start the closing period and build the packet contains CONNECTION_CLOSE.
If we are server side, the function will set the close_waitcb and write the packet to the conn_closebuf. If we are client side, send the CONNECTION_CLOSE packet directly, and won't wait close.
connection | the connection |
Definition at line 2526 of file gnunet-communicator-http3.c.
References close_waitcb(), Connection::conn, Connection::conn_closebuf, Connection::conn_closebuflen, GNUNET_ERROR_TYPE_DEBUG, GNUNET_log, GNUNET_new_array, GNUNET_NO, GNUNET_SCHEDULER_add_delayed(), GNUNET_SCHEDULER_cancel(), GNUNET_SYSERR, GNUNET_TIME_relative_multiply(), GNUNET_TIME_UNIT_MICROSECONDS, GNUNET_YES, Connection::is_initiator, Connection::last_error, ps, send_packet(), Connection::timer, and timestamp().
Referenced by handle_error().
|
static |
Send the packet in the conn_closebuf.
connection | the connection |
Definition at line 2599 of file gnunet-communicator-http3.c.
References Connection::conn_closebuf, Connection::conn_closebuflen, GNUNET_ERROR_TYPE_DEBUG, GNUNET_log, and send_packet().
Referenced by handle_error(), and server_read_pkt().
|
static |
Handle errors.
Both server and client will use this function.
connection | the connection. |
Definition at line 2620 of file gnunet-communicator-http3.c.
References Connection::conn, connection_destroy(), GNUNET_NO, GNUNET_SYSERR, GNUNET_YES, Connection::is_initiator, Connection::last_error, NETWORK_ERR_CLOSE_WAIT, NETWORK_ERR_OK, send_conn_close(), and start_closing_period().
Referenced by connection_feed_data(), connection_write_streams(), get_connection_delete_it(), and handle_expiry().
|
static |
Handles expired timer.
connection | the connection |
Definition at line 2665 of file gnunet-communicator-http3.c.
References Connection::conn, GNUNET_ERROR_TYPE_DEBUG, GNUNET_log, GNUNET_NO, handle_error(), Connection::last_error, and timestamp().
Referenced by timeoutcb().
|
static |
The timer callback function.
cls | The closure of struct Connection. |
Definition at line 2688 of file gnunet-communicator-http3.c.
References connection_destroy(), connection_write(), GNUNET_ERROR_TYPE_DEBUG, GNUNET_log, GNUNET_NO, GNUNET_YES, handle_expiry(), Connection::is_initiator, NETWORK_ERR_CLOSE_WAIT, and Connection::timer.
Referenced by connection_update_timer().
|
static |
Update the timer.
connection | the connection. |
Definition at line 2739 of file gnunet-communicator-http3.c.
References Connection::conn, GNUNET_ERROR_TYPE_DEBUG, GNUNET_log, GNUNET_SCHEDULER_add_delayed(), GNUNET_SCHEDULER_add_now(), GNUNET_SCHEDULER_cancel(), GNUNET_TIME_relative_multiply(), GNUNET_TIME_UNIT_MICROSECONDS, timeoutcb(), Connection::timer, and timestamp().
Referenced by connection_on_read(), and connection_write().
|
static |
Write HTTP stream data and send the packets.
connection | the connection of the peer |
Definition at line 2782 of file gnunet-communicator-http3.c.
References Connection::conn, GNUNET_ERROR_TYPE_DEBUG, GNUNET_log, GNUNET_NO, Connection::h3_conn, handle_error(), Connection::last_error, ps, send_packet(), and timestamp().
Referenced by connection_write().
|
static |
Function called by the transport service to initialize a message queue given address information about another peer.
If and when the communication channel is established, the communicator must call GNUNET_TRANSPORT_communicator_mq_add() to notify the service that the channel is now up. It is the responsibility of the communicator to manage sane retries and timeouts for any peer/address combination provided by the transport service. Timeouts and retries do not need to be signalled to the transport service.
cls | closure |
peer | identity of the other peer |
address | where to send the message, human-readable communicator-specific format, 0-terminated, UTF-8 |
Definition at line 2956 of file gnunet-communicator-http3.c.
References addr_map, address, Connection::address, Connection::address_len, cfg, client_gnutls_init(), client_quic_init(), COMMUNICATOR_ADDRESS_PREFIX, COMMUNICATOR_CONFIG_SECTION, Connection::conn, connection_write(), Connection::foreign_addr, GNUNET_break_op, GNUNET_CONFIGURATION_get_value_string(), GNUNET_CONSTANTS_IDLE_CONNECTION_TIMEOUT, GNUNET_CONTAINER_multihashmap_create(), GNUNET_CONTAINER_multihashmap_get(), GNUNET_CONTAINER_multihashmap_put(), GNUNET_CONTAINER_multihashmap_size(), GNUNET_CONTAINER_MULTIHASHMAPOPTION_UNIQUE_ONLY, GNUNET_CRYPTO_hash(), GNUNET_ERROR_TYPE_DEBUG, GNUNET_ERROR_TYPE_ERROR, GNUNET_free, GNUNET_log, GNUNET_log_config_missing(), GNUNET_new, GNUNET_NO, GNUNET_NT_scanner_get_type(), GNUNET_OK, GNUNET_STATISTICS_set(), GNUNET_SYSERR, GNUNET_TIME_relative_to_absolute(), GNUNET_YES, Connection::id_rcvd, Connection::id_sent, is, Connection::is_initiator, local_addr, Connection::nt, peer_id, remote_addr, Connection::session, sockaddr_to_udpaddr_string(), stats, Connection::streams, Connection::target, Connection::timeout, and udp_address_to_sockaddr().
Referenced by GNUNET_TRANSPORT_communicator_connect(), and run().
|
static |
Signature of the callback passed to GNUNET_NAT_register() for a function to call whenever our set of 'valid' addresses changes.
cls | closure |
app_ctx[in,out] | location where the app can store stuff on add and retrieve it on remove |
add_remove | GNUNET_YES to add a new public IP address, GNUNET_NO to remove a previous (now invalid) one |
ac | address class the address belongs to |
addr | either the previous or the new public IP address |
addrlen | actual length of the addr |
Definition at line 3073 of file gnunet-communicator-http3.c.
References ai, ch, COMMUNICATOR_ADDRESS_PREFIX, GNUNET_a2s(), GNUNET_asprintf(), GNUNET_free, GNUNET_NT_scanner_get_type(), GNUNET_TIME_UNIT_FOREVER_REL, GNUNET_TRANSPORT_communicator_address_add(), GNUNET_TRANSPORT_communicator_address_remove(), GNUNET_YES, is, and nt.
Referenced by run().
|
static |
Iterator over all connection to clean up.
cls | NULL |
key | connection->address |
value | the connection to destroy |
Definition at line 3118 of file gnunet-communicator-http3.c.
References connection_destroy(), GNUNET_OK, handle_error(), key, and value.
Referenced by do_shutdown().
|
static |
Shutdown the HTTP3 communicator.
cls | NULL (always) |
Definition at line 3137 of file gnunet-communicator-http3.c.
References addr_map, ch, cred, get_connection_delete_it(), GNUNET_break, GNUNET_CONTAINER_multihashmap_destroy(), GNUNET_CONTAINER_multihashmap_iterate(), GNUNET_ERROR_TYPE_DEBUG, GNUNET_free, GNUNET_log, GNUNET_NAT_unregister(), GNUNET_NETWORK_socket_close(), GNUNET_NT_scanner_done(), GNUNET_OK, GNUNET_SCHEDULER_cancel(), GNUNET_STATISTICS_destroy(), GNUNET_TRANSPORT_communicator_disconnect(), GNUNET_YES, is, my_private_key, nat, read_task, stats, and udp_sock.
Referenced by run().
|
static |
Decrypt QUIC packet.
Both the server and the client will use this function.
connection | the connection |
local_addr | our address |
local_addrlen | length of our address |
remote_addr | peer's address |
remote_addrlen | length of peer's address |
pi | ngtcp2 packet info |
data | the QUIC packet to be processed |
datalen | the length of data |
Definition at line 3203 of file gnunet-communicator-http3.c.
References Connection::conn, data, GNUNET_ERROR_TYPE_DEBUG, GNUNET_log, GNUNET_NO, handle_error(), Connection::is_initiator, Connection::last_error, local_addr, NETWORK_ERR_CLOSE_WAIT, NETWORK_ERR_DROP_CONN, NETWORK_ERR_RETRY, remote_addr, start_draining_period(), and timestamp().
Referenced by connection_on_read(), and sock_read().
|
static |
Connection read the packet data.
This function will only be called by the server.
connection | the connection |
local_addr | our address |
local_addrlen | length of our address |
remote_addr | peer's address |
remote_addrlen | length of peer's address |
pi | ngtcp2 packet info |
data | the QUIC packet to be processed |
datalen | the length of data |
Definition at line 3279 of file gnunet-communicator-http3.c.
References connection_feed_data(), connection_update_timer(), data, GNUNET_NO, local_addr, and remote_addr.
Referenced by server_read_pkt().
|
static |
Create a new connection.
This function will only be called by the server.
local_addr | our address |
local_addrlen | length of our address |
remote_addr | peer's address |
remote_addrlen | length of peer's address |
dcid | scid of the data packet from the client |
scid | dcid of the data packet from the client |
version | version of the data packet from the client |
Definition at line 3312 of file gnunet-communicator-http3.c.
References acked_stream_data_offset_cb(), Connection::address, Connection::address_len, Connection::conn, Connection::conn_ref, cred, extend_max_remote_streams_bidi_cb(), extend_max_stream_data_cb(), Connection::foreign_addr, get_conn(), get_new_connection_id_cb(), GNUNET_CONTAINER_multihashmap_create(), GNUNET_CRYPTO_QUALITY_STRONG, GNUNET_CRYPTO_random_block(), GNUNET_ERROR_TYPE_ERROR, GNUNET_log, GNUNET_memdup, GNUNET_new, GNUNET_NO, Connection::id_rcvd, Connection::id_sent, Connection::is_initiator, local_addr, PRIORITY, rand_cb(), recv_stream_data_cb(), recv_tx_key_cb(), remote_addr, Connection::session, sockaddr_to_udpaddr_string(), stream_close_cb(), stream_open_cb(), stream_stop_sending_cb(), and Connection::streams.
Referenced by server_read_pkt().
|
static |
The server processes the newly received data packet.
This function will only be called by the server.
connection | the connection |
addr_key | the hash key of peer's address |
local_addr | our address |
local_addrlen | length of our address |
remote_addr | peer's address |
remote_addrlen | length of peer's address |
pi | ngtcp2 packet info |
data | the QUIC packet to be processed |
datalen | the length of data |
TODO: handle the stateless reset token.
Definition at line 3441 of file gnunet-communicator-http3.c.
References addr_map, Connection::conn, connection_destroy(), connection_init(), connection_on_read(), connection_write(), data, GNUNET_CONTAINER_multihashmap_put(), GNUNET_CONTAINER_MULTIHASHMAPOPTION_UNIQUE_ONLY, GNUNET_ERROR_TYPE_DEBUG, GNUNET_ERROR_TYPE_ERROR, GNUNET_log, GNUNET_NO, local_addr, NETWORK_ERR_CLOSE_WAIT, NETWORK_ERR_RETRY, remote_addr, and send_conn_close().
Referenced by sock_read().
|
static |
Socket read task.
cls | NULL |
Definition at line 3556 of file gnunet-communicator-http3.c.
References addr_map, cfg, COMMUNICATOR_CONFIG_SECTION, connection_feed_data(), connection_write(), GNUNET_a2s(), GNUNET_break_op, GNUNET_CONFIGURATION_get_value_string(), GNUNET_CONTAINER_multihashmap_get(), GNUNET_CRYPTO_hash(), GNUNET_ERROR_TYPE_DEBUG, GNUNET_ERROR_TYPE_ERROR, GNUNET_free, GNUNET_log, GNUNET_log_config_missing(), GNUNET_log_strerror, GNUNET_NETWORK_socket_recvfrom(), GNUNET_NO, GNUNET_OK, GNUNET_SCHEDULER_add_read_net(), GNUNET_TIME_UNIT_FOREVER_REL, GNUNET_YES, Connection::is_initiator, local_addr, read_task, server_read_pkt(), sock_read(), sockaddr_to_udpaddr_string(), udp_address_to_sockaddr(), and udp_sock.
Referenced by run(), and sock_read().
|
static |
Setup communicator and launch network interactions.
cls | NULL (always) |
args | remaining command-line arguments |
cfgfile | name of the configuration file used (for saving, can be NULL!) |
c | configuration |
Get our public key for initial packet
Definition at line 3670 of file gnunet-communicator-http3.c.
References _, addr_map, cfg, ch, COMMUNICATOR_ADDRESS_PREFIX, COMMUNICATOR_CONFIG_SECTION, cred, disable_v6, do_shutdown(), GNUNET_a2s(), GNUNET_break, GNUNET_CONFIGURATION_get_value_filename(), GNUNET_CONFIGURATION_get_value_string(), GNUNET_CONFIGURATION_get_value_yesno(), GNUNET_CONTAINER_multihashmap_create(), GNUNET_CRYPTO_eddsa_key_create_from_configuration(), GNUNET_CRYPTO_eddsa_key_get_public(), GNUNET_DISK_file_test(), GNUNET_ERROR_TYPE_DEBUG, GNUNET_ERROR_TYPE_ERROR, GNUNET_ERROR_TYPE_INFO, GNUNET_free, GNUNET_log, GNUNET_log_config_missing(), GNUNET_log_from_nocheck(), GNUNET_log_strerror, GNUNET_log_strerror_file, GNUNET_NAT_register(), GNUNET_NETWORK_get_fd(), GNUNET_NETWORK_socket_bind(), GNUNET_NETWORK_socket_close(), GNUNET_NETWORK_socket_create(), GNUNET_NETWORK_test_pf(), GNUNET_NO, GNUNET_NT_scanner_init(), GNUNET_OK, GNUNET_OS_INHERIT_STD_OUT_AND_ERR, GNUNET_OS_process_destroy(), GNUNET_OS_process_wait(), GNUNET_OS_start_process(), GNUNET_SCHEDULER_add_read_net(), GNUNET_SCHEDULER_add_shutdown(), GNUNET_SCHEDULER_shutdown(), GNUNET_strdup, GNUNET_TIME_UNIT_FOREVER_REL, GNUNET_TRANSPORT_CC_RELIABLE, GNUNET_TRANSPORT_communicator_connect(), GNUNET_YES, have_v6_socket, is, mq_init(), my_identity, my_port, my_private_key, nat, nat_address_cb(), notify_cb(), GNUNET_PeerIdentity::public_key, read_task, sock_read(), try_connection_reversal(), udp_address_to_sockaddr(), and udp_sock.
Referenced by main().
int main | ( | int | argc, |
char *const * | argv | ||
) |
The main function for the UNIX communicator.
argc | number of arguments from the command line |
argv | command line arguments |
Definition at line 3917 of file gnunet-communicator-http3.c.
References _, GNUNET_ERROR_TYPE_DEBUG, GNUNET_free_nz, GNUNET_GETOPT_OPTION_END, GNUNET_log_from_nocheck(), GNUNET_OK, GNUNET_PROGRAM_run(), GNUNET_STRINGS_get_utf8_args(), options, ret, and run().
|
static |
Map of sockaddr -> struct Connection.
TODO: Maybe it would be better to use cid as key? addr_map can't be discarded yet, because mq_init parameter is address. So currently use cid_map seems not a perfet way.
Definition at line 74 of file gnunet-communicator-http3.c.
Referenced by connection_destroy(), do_shutdown(), mq_init(), run(), server_read_pkt(), and sock_read().
|
static |
Our configuration.
Definition at line 79 of file gnunet-communicator-http3.c.
Referenced by mq_init(), run(), and sock_read().
|
static |
Our private key.
Definition at line 84 of file gnunet-communicator-http3.c.
Referenced by do_shutdown(), and run().
|
static |
Our peer identity.
Definition at line 89 of file gnunet-communicator-http3.c.
Referenced by recv_rx_key_cb(), and run().
|
static |
IPv6 disabled or not.
Definition at line 94 of file gnunet-communicator-http3.c.
Referenced by run(), and udp_address_to_sockaddr().
|
static |
Our socket.
Definition at line 99 of file gnunet-communicator-http3.c.
Referenced by create_receiver(), do_shutdown(), get_socket(), read_send(), run(), send_packet(), and sock_read().
|
static |
ID of listen task.
Definition at line 104 of file gnunet-communicator-http3.c.
Referenced by do_shutdown(), run(), and sock_read().
|
static |
Our environment.
Definition at line 109 of file gnunet-communicator-http3.c.
Referenced by do_shutdown(), http_recv_data_cb(), nat_address_cb(), run(), and setup_connection_mq().
|
static |
Connection to NAT service.
Definition at line 114 of file gnunet-communicator-http3.c.
Referenced by do_shutdown(), and run().
|
static |
GNUNET_YES if udp_sock supports IPv6.
Definition at line 119 of file gnunet-communicator-http3.c.
Referenced by run().
|
static |
Port number to which we are actually bound.
Definition at line 124 of file gnunet-communicator-http3.c.
Referenced by run().
|
static |
Network scanner to determine network types.
Definition at line 129 of file gnunet-communicator-http3.c.
Referenced by do_shutdown(), mq_init(), nat_address_cb(), and run().
|
static |
For logging statistics.
Definition at line 134 of file gnunet-communicator-http3.c.
Referenced by connection_destroy(), do_shutdown(), and mq_init().
|
static |
The credential.
Definition at line 139 of file gnunet-communicator-http3.c.
Referenced by abd_string_to_value(), abd_value_to_string(), client_gnutls_init(), connection_init(), cred_collect(), cred_iter_cb(), cred_iter_finished(), do_shutdown(), filter_tickets_cb(), GNUNET_ABD_delegate_to_string(), GNUNET_RECLAIM_credential_get_presentation(), GNUNET_RECLAIM_JSON_spec_credential(), jwt_create_presentation(), jwt_get_expiration_c(), jwt_get_expiration_p(), jwt_get_issuer_c(), jwt_get_issuer_p(), jwt_parse_attributes_c(), jwt_parse_attributes_p(), oidc_cred_collect(), pabc_create_presentation(), pabc_get_expiration_c(), pabc_get_expiration_p(), pabc_get_issuer_c(), pabc_get_issuer_p(), pabc_parse_attributes_c(), pabc_parse_attributes_p(), parse_credential(), run(), and store_cb().