ascii-chat
Binary v0.15.83-53-gb711d8720
Library lib/v0.3.2-701-gb711d8720
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,
20asciichat_error_t quic_udp_endpoint_address(const quic_udp_endpoint_t *endpoint, struct sockaddr_storage *address,
21 socklen_t *length);
22asciichat_error_t quic_udp_connect(quic_udp_endpoint_t *endpoint, quic_tls_t *client_tls, const char *server_name,
23 const struct sockaddr *remote, socklen_t remote_length, uint64_t now_ns,
25/* Nonblocking bounded work. A per-connection failure is returned with *failed
26 * set to its borrowed handle; the caller may remove it and continue the other
27 * connections. Socket-level failures leave *failed NULL. */
29/* After pumping, obtain the earliest timer and whether a socket-blocked
30 * datagram needs write readiness. Call on the serialized endpoint lane. */
32 uint64_t maximum_wait_ns, uint64_t *wait_ns, bool *want_write);
33/* Wait outside the endpoint lane. The owner must keep the endpoint/socket
34 * alive until the wait and all wake calls have returned. A wake is coalescible
35 * and must be followed by a pump; it carries no application data. */
36asciichat_error_t quic_udp_wait(quic_udp_endpoint_t *endpoint, uint64_t wait_ns, bool want_write, bool *ready);
38/* Test endpoint membership on its serialized lane without dereferencing the
39 * supplied handle. Useful after an application failure callback removes it. */
40bool quic_udp_contains(const quic_udp_endpoint_t *endpoint, const quic_connection_t *connection);
44
45/* Requires a stopped worker and a single client connection. A rejected
46 * migration leaves the existing socket and endpoint address unchanged. */
47asciichat_error_t quic_udp_migrate(quic_udp_endpoint_t *endpoint, const struct sockaddr *address, socklen_t length,
48 uint64_t now_ns);
unsigned long long uint64_t
Definition common.h:63
asciichat_error_t
Error and exit codes - unified status values (0-255).
Definition error_codes.h:44
struct quic_connection quic_connection_t
static bool size_t gotel_query_t * out
Definition queries.h:8
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:330
asciichat_error_t quic_udp_endpoint_address(const quic_udp_endpoint_t *endpoint, struct sockaddr_storage *address, socklen_t *length)
Definition udp.c:106
asciichat_error_t quic_udp_wake(quic_udp_endpoint_t *endpoint)
Definition udp.c:319
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:286
void quic_udp_endpoint_destroy(quic_udp_endpoint_t **endpoint)
Definition udp.c:372
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:383
asciichat_error_t quic_udp_pump(quic_udp_endpoint_t *endpoint, uint64_t now_ns, quic_connection_t **failed)
Definition udp.c:222
asciichat_error_t quic_udp_close_peer(quic_udp_endpoint_t *endpoint, quic_connection_t *connection)
Definition udp.c:339
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:67
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:144
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:356
asciichat_error_t quic_udp_wait(quic_udp_endpoint_t *endpoint, uint64_t wait_ns, bool want_write, bool *ready)
Definition udp.c:304