Loading...
Searching...
No Matches
network.h
Go to the documentation of this file.
1
14#ifndef IMQUIC_NETWORK_H
15#define IMQUIC_NETWORK_H
16
17#include <stdint.h>
18#include <sys/socket.h>
19
20#include "../imquic/imquic.h"
21#include "configuration.h"
22#include "loop.h"
23#include "crypto.h"
24#include "moq.h"
25#include "roq.h"
26#include "refcount.h"
27
29typedef struct imquic_network_address {
31 struct sockaddr_storage addr;
33 socklen_t addrlen;
40char *imquic_network_address_str(imquic_network_address *address, char *output, size_t outlen);
41
45 void *source;
47 char *name;
49 gboolean is_server;
51 int fd;
53 uint16_t port;
59 char *sni;
61 gboolean raw_quic;
63 char *alpn;
65 gboolean webtransport;
67 char *h3_path;
71 GHashTable *connections;
73 uint64_t conns_num;
79 void (* stream_incoming)(imquic_connection *conn, uint64_t stream_id,
80 uint8_t *bytes, uint64_t offset, uint64_t length, gboolean complete);
82 void (* datagram_incoming)(imquic_connection *conn, uint8_t *bytes, uint64_t length);
88 void *user_data;
90 uint64_t protocol;
92 union {
99 volatile gint started;
101 volatile gint shutting;
103 volatile gint destroyed;
127
133int imquic_network_send(imquic_connection *conn, uint8_t *bytes, size_t blen);
134
135#endif
imquic public interface
QUIC cryptographic utilities (headers)
imquic public interface (headers)
Media Over QUIC (MoQ) stack (headers)
RTP Over QUIC (RoQ) stack (headers)
Event loop (headers)
GMutex imquic_mutex
imquic mutex implementation
Definition mutex.h:18
struct imquic_network_endpoint imquic_network_endpoint
Abstraction of a network endpoint (client or server)
struct imquic_network_address imquic_network_address
Abstraction of a network address.
void imquic_network_endpoint_remove_connection(imquic_network_endpoint *ne, imquic_connection *conn, gboolean lock_mutex)
Helper to remove an existing connection from the list of connections originated by this endpoint.
Definition network.c:102
imquic_network_endpoint * imquic_network_endpoint_create(imquic_configuration *config)
Helper to create a new imquic_network_endpoint instance from a imquic_configuration object.
Definition network.c:143
int imquic_network_send(imquic_connection *conn, uint8_t *bytes, size_t blen)
Helper to send data on a connection.
Definition network.c:378
void imquic_network_endpoint_shutdown(imquic_network_endpoint *ne)
Helper to shutdown an existing endpoint.
Definition network.c:116
void imquic_network_endpoint_destroy(imquic_network_endpoint *ne)
Helper to destroy an existing endpoint instance.
Definition network.c:123
char * imquic_network_address_str(imquic_network_address *address, char *output, size_t outlen)
Helper to serialize a network address to a string.
Definition network.c:33
void imquic_network_endpoint_add_connection(imquic_network_endpoint *ne, imquic_connection *conn, gboolean lock_mutex)
Helper to add a new connection to the list of connections originated by this endpoint.
Definition network.c:91
Reference counter mechanism.
A client/server configuration.
Definition configuration.h:27
QUIC Connection.
Definition connection.h:101
RoQ public callbacks.
Definition internal/moq.h:1134
Abstraction of a network address.
Definition network.h:29
struct sockaddr_storage addr
Network address.
Definition network.h:31
socklen_t addrlen
Size of the network address.
Definition network.h:33
Abstraction of a network endpoint (client or server)
Definition network.h:43
void(* connection_failed)(void *user_data)
Callback to invoke when a client connection attempt fails.
Definition network.h:86
uint64_t protocol
(Sub-)Protocol this endpoint uses, in case imquic is handling a protocol natively
Definition network.h:90
void(* stream_incoming)(imquic_connection *conn, uint64_t stream_id, uint8_t *bytes, uint64_t offset, uint64_t length, gboolean complete)
Callback to invoke when new STREAM data is available on one of the connections handled by this endpoi...
Definition network.h:79
volatile gint started
Whether this connection has been started.
Definition network.h:99
uint16_t port
Local port.
Definition network.h:53
imquic_moq_callbacks moq
Definition network.h:93
imquic_roq_callbacks roq
Definition network.h:94
uint64_t conns_num
Number of connections handled by this socket (may be more than one for servers)
Definition network.h:73
void * source
Definition network.h:45
imquic_tls * tls
TLS stack.
Definition network.h:57
imquic_mutex mutex
Mutex.
Definition network.h:97
gboolean raw_quic
Whether raw QUIC should be supported.
Definition network.h:61
GHashTable * connections
List of connections handled by this socket (may be more than one for servers)
Definition network.h:71
char * h3_path
For WebTransport clients, the path to CONNECT to (/ by default)
Definition network.h:67
imquic_network_address remote_address
Remote address of the peer (clients only)
Definition network.h:55
gboolean internal_callbacks
Whether this endpoint has internal generic callbacks (true for the native RoQ and MoQ stacks)
Definition network.h:75
char * alpn
ALPN this endpoint will negotiate, when using raw QUIC.
Definition network.h:63
char * name
Name of this endpoint.
Definition network.h:47
void(* datagram_incoming)(imquic_connection *conn, uint8_t *bytes, uint64_t length)
Callback to invoke when new DATAGRAM data is available on one of the connections handled by this endp...
Definition network.h:82
char * sni
SNI the client will use.
Definition network.h:59
void(* new_connection)(imquic_connection *conn, void *user_data)
Callback to invoke when a new connection is available on this endpoint.
Definition network.h:77
void(* connection_gone)(imquic_connection *conn)
Callback to invoke when new one of the connections handled by this endpoint is closed.
Definition network.h:84
void * user_data
User data to pass in the new_connection callback, to correlate a connection to the endpoint it's comi...
Definition network.h:88
int fd
Socket.
Definition network.h:51
gboolean webtransport
Whether WebTransport should be supported.
Definition network.h:65
volatile gint shutting
Whether this connection is being shut down.
Definition network.h:101
volatile gint destroyed
Whether this instance has been destroyed (reference counting)
Definition network.h:103
imquic_refcount ref
Reference counter.
Definition network.h:105
char * subprotocol
In case WebTransport is used, subprotocol to negotiate (currently unused)
Definition network.h:69
union imquic_network_endpoint::@2 callbacks
(Sub-)Protocol specific callbacks (at the time of writing, RoQ and MoQ only)
gboolean is_server
Whether this is a client or a server.
Definition network.h:49
Definition refcount.h:77
RoQ public callbacks.
Definition internal/roq.h:61
TLS context.
Definition crypto.h:42