ascii-chat
Binary v0.16.114-28-gf5913657f
Library lib/v0.3.2-3302-gf5913657f
Video chat in your terminal
Loading...
Searching...
No Matches
udp.h
Go to the documentation of this file.
1#pragma once
2
3#include "connection.h"
4
5/* Private, single-lane UDP driver. The caller owns TLS contexts and must keep
6 * them alive until after endpoint destruction. Accepted and connected handles
7 * are borrowed from the endpoint and become invalid when removed or destroyed.
8 * The accept callback runs on the pump lane before the Initial is processed;
9 * it may install the packet receiver but must not reenter the endpoint.
10 * Returning ERROR_BUFFER_FULL drops that Initial without stopping the listener;
11 * other callback errors are reported to the endpoint owner. A callback must
12 * decide whether to reject before attaching a transport, and must release any
13 * other resources it created when returning an error. */
16
17asciichat_error_t quic_udp_endpoint_create(const struct sockaddr *bind_address, socklen_t bind_length, quic_tls_t *server_tls, quic_udp_accept_fn accept, void *context, quic_udp_endpoint_t **out);
18asciichat_error_t quic_udp_endpoint_address(const quic_udp_endpoint_t *endpoint, struct sockaddr_storage *address, socklen_t *length);
19asciichat_error_t quic_udp_connect(quic_udp_endpoint_t *endpoint, quic_tls_t *client_tls, const char *server_name, const struct sockaddr *remote, socklen_t remote_length, uint64_t now_ns,
21/* Nonblocking bounded work. A per-connection failure is returned with *failed
22 * set to its borrowed handle; the caller may remove it and continue the other
23 * connections. Socket-level failures leave *failed NULL. */
25/* After pumping, obtain the earliest timer and whether a socket-blocked
26 * datagram needs write readiness. Call on the serialized endpoint lane. */
27asciichat_error_t quic_udp_wait_parameters(const quic_udp_endpoint_t *endpoint, uint64_t now_ns, uint64_t maximum_wait_ns, uint64_t *wait_ns, bool *want_write);
28/* Wait outside the endpoint lane. The owner must keep the endpoint/socket
29 * alive until the wait and all wake calls have returned. A wake is coalescible
30 * and must be followed by a pump; it carries no application data. */
31asciichat_error_t quic_udp_wait(quic_udp_endpoint_t *endpoint, uint64_t wait_ns, bool want_write, bool *ready);
33/* Test endpoint membership on its serialized lane without dereferencing the
34 * supplied handle. Useful after an application failure callback removes it. */
35bool quic_udp_contains(const quic_udp_endpoint_t *endpoint, const quic_connection_t *connection);
39
40/* Requires a stopped worker and a single client connection. A rejected
41 * migration leaves the existing socket and endpoint address unchanged. */
42asciichat_error_t quic_udp_migrate(quic_udp_endpoint_t *endpoint, const struct sockaddr *address, socklen_t length, uint64_t now_ns);
unsigned long long uint64_t
asciichat_error_t
Error and exit codes - unified status values (0-255).
Definition error_codes.h:48
struct quic_connection quic_connection_t
static bool size_t gotel_query_t * out
Definition queries.h:10
quic_tls_t * server_tls
Definition udp.c:37
void * context
Definition udp.c:40
quic_udp_accept_fn accept
Definition udp.c:39
bool quic_udp_contains(const quic_udp_endpoint_t *endpoint, const quic_connection_t *connection)
Definition udp.c:311
asciichat_error_t quic_udp_endpoint_address(const quic_udp_endpoint_t *endpoint, struct sockaddr_storage *address, socklen_t *length)
Definition udp.c:103
asciichat_error_t quic_udp_wake(quic_udp_endpoint_t *endpoint)
Definition udp.c:301
asciichat_error_t(* quic_udp_accept_fn)(quic_connection_t *, void *)
Definition udp.h:15
asciichat_error_t quic_udp_wait_parameters(const quic_udp_endpoint_t *endpoint, uint64_t now_ns, uint64_t maximum_wait_ns, uint64_t *wait_ns, bool *want_write)
Definition udp.c:269
void quic_udp_endpoint_destroy(quic_udp_endpoint_t **endpoint)
Definition udp.c:352
asciichat_error_t quic_udp_migrate(quic_udp_endpoint_t *endpoint, const struct sockaddr *address, socklen_t length, uint64_t now_ns)
Definition udp.c:363
asciichat_error_t quic_udp_pump(quic_udp_endpoint_t *endpoint, uint64_t now_ns, quic_connection_t **failed)
Definition udp.c:209
asciichat_error_t quic_udp_close_peer(quic_udp_endpoint_t *endpoint, quic_connection_t *connection)
Definition udp.c:320
asciichat_error_t quic_udp_endpoint_create(const struct sockaddr *bind_address, socklen_t bind_length, quic_tls_t *server_tls, quic_udp_accept_fn accept, void *context, quic_udp_endpoint_t **out)
Definition udp.c:66
asciichat_error_t quic_udp_connect(quic_udp_endpoint_t *endpoint, quic_tls_t *client_tls, const char *server_name, const struct sockaddr *remote, socklen_t remote_length, uint64_t now_ns, quic_connection_t **out)
Definition udp.c:137
struct quic_udp_endpoint quic_udp_endpoint_t
Definition udp.h:14
asciichat_error_t quic_udp_remove(quic_udp_endpoint_t *endpoint, quic_connection_t *connection)
Definition udp.c:336
asciichat_error_t quic_udp_wait(quic_udp_endpoint_t *endpoint, uint64_t wait_ns, bool want_write, bool *ready)
Definition udp.c:286