ascii-chat
Binary v0.16.114-28-gf5913657f
Library lib/v0.3.2-3302-gf5913657f
Video chat in your terminal
Loading...
Searching...
No Matches
lib/network/quic/connection.h
Go to the documentation of this file.
1#pragma once
2
3#include "stream.h"
4#include "tls.h"
6
7#include <libplatform/socket.h>
8#include <ngtcp2/ngtcp2.h>
9
10/* Private serialized connection engine. An endpoint owns and drives each
11 * instance from one lane; it must not call these operations concurrently.
12 * Times are nanoseconds on the time_get_ns() monotonic clock and cannot move
13 * backwards. The TLS context and callback reference outlive the connection. */
15
16/* Produce a best-effort CONNECTION_CLOSE before an owned connection is
17 * discarded. A zero-length result means that no close can be sent. */
18asciichat_error_t quic_connection_write_close(quic_connection_t *connection, ngtcp2_path_storage *path, void *packet, size_t capacity, size_t *length, uint64_t now_ns);
19
20asciichat_error_t quic_connection_client_create(quic_tls_t *tls, const char *server_name, const ngtcp2_path *path, uint64_t now_ns, quic_connection_t **out);
23asciichat_error_t quic_connection_server_create(quic_tls_t *tls, const ngtcp2_path *path, const void *initial, size_t initial_length, uint64_t now_ns, quic_connection_t **out);
24/* As above, after validating the Retry token and recovering its original DCID. */
25asciichat_error_t quic_connection_server_create_validated(quic_tls_t *tls, const ngtcp2_path *path, const void *initial, size_t initial_length, const ngtcp2_cid *original_dcid, uint64_t now_ns,
27asciichat_error_t quic_connection_receive(quic_connection_t *connection, const ngtcp2_path *path, const void *packet, size_t length, uint64_t now_ns);
32asciichat_error_t quic_connection_write(quic_connection_t *connection, ngtcp2_path_storage *path, void *packet, size_t capacity, size_t *length, uint64_t now_ns);
39bool quic_connection_tls_ready(const quic_connection_t *connection);
40/* A WebTransport listener is admitted only after its CONNECT is authorized. */
44asciichat_error_t quic_connection_peer_address(const quic_connection_t *connection, struct sockaddr_storage *address, socklen_t *length);
45/* Match an incoming destination CID, including the server's original Initial
46 * CID. Called only on the connection lane. */
47asciichat_error_t quic_connection_matches_cid(const quic_connection_t *connection, const uint8_t *cid, size_t length, bool *matches);
54void quic_connection_set_security_notifier(quic_connection_t *connection, void (*notify)(void *), void *context);
55/* Notifier runs on the serialized lane and must not acquire the outbound queue lock. */
56void quic_connection_set_keyframe_notifier(quic_connection_t *connection, void (*notify)(uint16_t, uint32_t, void *), void *context);
70asciichat_error_t quic_connection_submit(quic_connection_t *connection, acip_traffic_class_t traffic_class, const void *packet, size_t length);
71/* Maximum ACQD payload for the current path, or zero when unavailable. */
74asciichat_error_t quic_connection_submit_datagram(quic_connection_t *connection, acip_traffic_class_t traffic_class, const void *packet, size_t length, uint64_t deadline_ns);
75size_t quic_connection_pending_bytes(const quic_connection_t *connection);
76/* Queue FIN after all previously admitted data for an open stream. No further
77 * packets may be submitted to that class. ngtcp2 retransmits the FIN on loss. */
79bool quic_connection_received_fin(const quic_connection_t *connection, acip_traffic_class_t traffic_class);
81
82/* Client-only immediate migration after handshake confirmation. The new local
83 * socket must already be bound; its owner keeps it alive for the connection. */
84asciichat_error_t quic_connection_migrate(quic_connection_t *connection, const struct sockaddr *local, socklen_t length, uint64_t now_ns);
unsigned short uint16_t
unsigned int uint32_t
unsigned long long uint64_t
unsigned char uint8_t
asciichat_error_t
Error and exit codes - unified status values (0-255).
Definition error_codes.h:48
asciichat_error_t quic_connection_set_receiver(quic_connection_t *connection, quic_stream_emit_fn emit, void *context)
asciichat_error_t quic_connection_client_create(quic_tls_t *tls, const char *server_name, const ngtcp2_path *path, uint64_t now_ns, quic_connection_t **out)
asciichat_error_t quic_connection_validate_datagram(const quic_connection_t *connection, acip_traffic_class_t traffic_class, uint64_t deadline_ns)
void quic_connection_destroy(quic_connection_t **connection)
size_t quic_connection_pending_bytes(const quic_connection_t *connection)
asciichat_error_t quic_connection_peer_address(const quic_connection_t *connection, struct sockaddr_storage *address, socklen_t *length)
bool quic_connection_received_fin(const quic_connection_t *connection, acip_traffic_class_t traffic_class)
asciichat_error_t quic_connection_handle_expiry(quic_connection_t *connection, uint64_t now_ns)
bool quic_connection_tls_ready(const quic_connection_t *connection)
asciichat_error_t quic_connection_enable_security(quic_connection_t *connection, crypto_context_t *crypto)
asciichat_error_t quic_connection_write_close(quic_connection_t *connection, ngtcp2_path_storage *path, void *packet, size_t capacity, size_t *length, uint64_t now_ns)
asciichat_error_t quic_connection_matches_cid(const quic_connection_t *connection, const uint8_t *cid, size_t length, bool *matches)
asciichat_error_t quic_connection_write(quic_connection_t *connection, ngtcp2_path_storage *path, void *packet, size_t capacity, size_t *length, uint64_t now_ns)
asciichat_error_t quic_connection_finish_stream(quic_connection_t *connection, acip_traffic_class_t traffic_class)
asciichat_error_t quic_connection_receive(quic_connection_t *connection, const ngtcp2_path *path, const void *packet, size_t length, uint64_t now_ns)
struct quic_connection quic_connection_t
asciichat_error_t quic_connection_submit(quic_connection_t *connection, acip_traffic_class_t traffic_class, const void *packet, size_t length)
asciichat_error_t quic_connection_server_create(quic_tls_t *tls, const ngtcp2_path *path, const void *initial, size_t initial_length, uint64_t now_ns, quic_connection_t **out)
void quic_connection_set_keyframe_notifier(quic_connection_t *connection, void(*notify)(uint16_t, uint32_t, void *), void *context)
bool quic_connection_security_ready(const quic_connection_t *connection)
bool quic_connection_webtransport_ready(const quic_connection_t *connection)
asciichat_error_t quic_connection_packet_sent(quic_connection_t *connection, uint64_t now_ns)
uint64_t quic_connection_expiry(const quic_connection_t *connection)
bool quic_connection_pending_packet_class(const quic_connection_t *connection, acip_traffic_class_t *traffic_class)
bool quic_connection_accept_ready(const quic_connection_t *connection)
void quic_connection_set_security_notifier(quic_connection_t *connection, void(*notify)(void *), void *context)
asciichat_error_t quic_connection_migrate(quic_connection_t *connection, const struct sockaddr *local, socklen_t length, uint64_t now_ns)
asciichat_error_t quic_connection_server_create_validated(quic_tls_t *tls, const ngtcp2_path *path, const void *initial, size_t initial_length, const ngtcp2_cid *original_dcid, uint64_t now_ns, quic_connection_t **out)
size_t quic_connection_datagram_payload(const quic_connection_t *connection)
asciichat_error_t quic_connection_clear_receiver(quic_connection_t *connection, void *context)
asciichat_error_t quic_connection_allow_media(quic_connection_t *connection)
asciichat_error_t quic_connection_submit_datagram(quic_connection_t *connection, acip_traffic_class_t traffic_class, const void *packet, size_t length, uint64_t deadline_ns)
asciichat_error_t(* quic_stream_emit_fn)(acip_traffic_class_t traffic_class, const void *packet, size_t size, void *context)
static bool size_t gotel_query_t * out
Definition queries.h:10
Endpoint cryptographic state for handshake, packet protection, authentication, and rekeying.
This is the handoff point for receive stream. Callers fill id, received_offset, reader,...
ngtcp2_crypto_ossl_ctx * crypto
acip_traffic_class_t
Definition traffic.h:9