Loading...
Searching...
No Matches
imquic.h
Go to the documentation of this file.
1
145#ifndef IMQUIC_IMQUIC_H
146#define IMQUIC_IMQUIC_H
147
148#include "debug.h"
149
150/* Opaque structures */
155
159
163int imquic_init(const char *secrets_log);
165void imquic_deinit(void);
167
171
175uint32_t imquic_get_version(void);
188const char *imquic_get_version_release(void);
191const char *imquic_get_version_string(void);
194const char *imquic_get_version_string_full(void);
197const char *imquic_get_build_time(void);
200const char *imquic_get_build_sha(void);
202
206
209void imquic_set_log_level(int level);
211
215
217gboolean imquic_is_qlog_supported(void);
219
223
225void imquic_set_lock_debugging(gboolean enabled);
228void imquic_set_refcount_debugging(gboolean enabled);
230
293const char *imquic_config_str(imquic_config type);
294
298
324imquic_server *imquic_create_server(const char *name, ...);
352imquic_client *imquic_create_client(const char *name, ...);
353
357const char *imquic_get_endpoint_name(imquic_endpoint *endpoint);
365const char *imquic_get_endpoint_alpn(imquic_endpoint *endpoint);
373uint16_t imquic_get_endpoint_port(imquic_endpoint *endpoint);
374
387
396 void (* new_connection)(imquic_connection *conn, void *user_data));
402 void (* stream_incoming)(imquic_connection *conn, uint64_t stream_id,
403 uint8_t *bytes, uint64_t offset, uint64_t length, gboolean complete));
409 void (* datagram_incoming)(imquic_connection *conn, uint8_t *bytes, uint64_t length));
416 void (* connection_gone)(imquic_connection *conn));
418
422
437int imquic_new_stream_id(imquic_connection *conn, gboolean bidirectional, uint64_t *stream_id);
450int imquic_send_on_stream(imquic_connection *conn, uint64_t stream_id,
451 uint8_t *bytes, uint64_t offset, uint64_t length, gboolean complete);
460int imquic_send_on_datagram(imquic_connection *conn, uint8_t *bytes, uint64_t length);
469void imquic_close_connection(imquic_connection *conn, uint64_t error, const char *reason);
471
475
488
494void imquic_stream_id_parse(uint64_t stream_id, uint64_t *id, gboolean *client_initiated, gboolean *bidirectional);
500uint64_t imquic_stream_id_build(uint64_t id, gboolean client_initiated, gboolean bidirectional);
501
510uint64_t imquic_varint_read(uint8_t *bytes, size_t blen, uint8_t *length);
519uint8_t imquic_varint_write(uint64_t number, uint8_t *bytes, size_t blen);
520
525uint64_t imquic_uint64_random(void);
533uint64_t *imquic_uint64_dup(uint64_t num);
535#endif
Logging and Debugging.
void imquic_set_stream_incoming_cb(imquic_endpoint *endpoint, void(*stream_incoming)(imquic_connection *conn, uint64_t stream_id, uint8_t *bytes, uint64_t offset, uint64_t length, gboolean complete))
Configure the callback function to be notified about incoming STREAM data on an existing connection h...
Definition imquic.c:401
uint64_t imquic_uint64_random(void)
Helper to generate random 64 bit unsigned integers.
Definition imquic.c:499
const char * imquic_get_build_time(void)
Get info on when this shared object was built.
Definition imquic.c:112
const char * imquic_get_connection_alpn(imquic_connection *conn)
Helper function to get the ALPN of a connection.
Definition imquic.c:452
int imquic_init(const char *secrets_log)
Initialize the imquic library.
Definition imquic.c:41
const char * imquic_get_version_string_full(void)
Get the current version of the library, including release type, as a string.
Definition imquic.c:109
int imquic_send_on_stream(imquic_connection *conn, uint64_t stream_id, uint8_t *bytes, uint64_t offset, uint64_t length, gboolean complete)
Helper method to send data on a QUIC STREAM.
Definition imquic.c:436
void imquic_connection_unref(imquic_connection *conn)
Decrease a reference to a imquic_connection instance.
Definition imquic.c:475
void imquic_set_connection_gone_cb(imquic_endpoint *endpoint, void(*connection_gone)(imquic_connection *conn))
Configure the callback function to be notified when an existing connection handled by this endpoint h...
Definition imquic.c:424
int imquic_get_version_minor(void)
Get the current minor version of the library as a number.
Definition imquic.c:97
gboolean imquic_is_qlog_supported(void)
Check if QLOG is supported at runtime.
Definition imquic.c:132
void imquic_stream_id_parse(uint64_t stream_id, uint64_t *id, gboolean *client_initiated, gboolean *bidirectional)
Parse a QUIC stream ID to its actual ID and its other properties.
Definition imquic.c:481
void imquic_start_endpoint(imquic_endpoint *endpoint)
Start a QUIC stack previously created with imquic_create_server or imquic_create_client....
Definition imquic.c:367
void imquic_set_lock_debugging(gboolean enabled)
Enable or disable lock/mutex debugging.
Definition imquic.c:137
const char * imquic_get_endpoint_name(imquic_endpoint *endpoint)
Helper function to get the endpoint name of a local client or server.
Definition imquic.c:347
uint32_t imquic_get_version(void)
Get the current version of the library as a number.
Definition imquic.c:88
int imquic_get_version_major(void)
Get the current major version of the library as a number.
Definition imquic.c:94
const char * imquic_get_build_sha(void)
Get info on the git commit was compiled in this build.
Definition imquic.c:115
imquic_client * imquic_create_client(const char *name,...)
Method to create a new QUIC client, using variable arguments to dictate what the client should do (e....
Definition imquic.c:267
const char * imquic_get_endpoint_alpn(imquic_endpoint *endpoint)
Helper function to get the ALPN a local client or server is configured to negotiate.
Definition imquic.c:355
const char * imquic_get_version_release(void)
Get the current release type of the library as a string.
Definition imquic.c:103
imquic_server * imquic_create_server(const char *name,...)
Method to create a new QUIC server, using variable arguments to dictate what the server should do (e....
Definition imquic.c:183
void imquic_set_log_level(int level)
Set the log level for the library.
Definition imquic.c:120
void imquic_set_datagram_incoming_cb(imquic_endpoint *endpoint, void(*datagram_incoming)(imquic_connection *conn, uint8_t *bytes, uint64_t length))
Configure the callback function to be notified about incoming DATAGRAM data on an existing connection...
Definition imquic.c:413
void imquic_close_connection(imquic_connection *conn, uint64_t error, const char *reason)
Helper method to close a QUIC connection.
Definition imquic.c:464
uint16_t imquic_get_endpoint_port(imquic_endpoint *endpoint)
Helper function to get the local port a client or server is bound to.
Definition imquic.c:363
uint64_t imquic_stream_id_build(uint64_t id, gboolean client_initiated, gboolean bidirectional)
Build a QUIC stream ID out of its actual ID and its other properties.
Definition imquic.c:485
int imquic_send_on_datagram(imquic_connection *conn, uint8_t *bytes, uint64_t length)
Helper method to send data on a QUIC DATAGRAM.
Definition imquic.c:446
void imquic_set_new_connection_cb(imquic_endpoint *endpoint, void(*new_connection)(imquic_connection *conn, void *user_data))
Configure the callback function to be notified about new connections on the configured endpoint....
Definition imquic.c:390
gboolean imquic_is_endpoint_server(imquic_endpoint *endpoint)
Helper function to check whether a local endpoint is a server.
Definition imquic.c:351
const char * imquic_get_connection_name(imquic_connection *conn)
Helper function to get the display name of a connection.
Definition imquic.c:456
uint64_t * imquic_uint64_dup(uint64_t num)
Helper to generate an allocated copy of a uint64_t number.
Definition imquic.c:503
void imquic_shutdown_endpoint(imquic_endpoint *endpoint)
Shutdown a previously started QUIC endpoint (client or server) In case of a server,...
Definition imquic.c:381
void imquic_set_refcount_debugging(gboolean enabled)
Enable or disable debugging of reference counters.
Definition imquic.c:141
const char * imquic_get_endpoint_subprotocol(imquic_endpoint *endpoint)
Helper function to get the WebTransport protocol a local client or server is configured to negotiate.
Definition imquic.c:359
int imquic_new_stream_id(imquic_connection *conn, gboolean bidirectional, uint64_t *stream_id)
Helper method to ask for the next usable locally originated stream ID on this connection.
Definition imquic.c:460
uint8_t imquic_varint_write(uint64_t number, uint8_t *bytes, size_t blen)
Write a variable size integer to a buffer.
Definition imquic.c:494
const char * imquic_get_version_string(void)
Get the current version of the library as a string.
Definition imquic.c:106
void imquic_deinit(void)
Uninitialize the imquic library.
Definition imquic.c:63
imquic_config
Configuration properties when creating servers/clients.
Definition imquic.h:232
@ IMQUIC_CONFIG_SNI
SNI to use, for clients (string)
Definition imquic.h:254
@ IMQUIC_CONFIG_QLOG_ROQ
Whether to save RoQ events to QLOG.
Definition imquic.h:278
@ IMQUIC_CONFIG_WEBTRANSPORT
Whether WebTransport should be offered (boolean)
Definition imquic.h:260
@ IMQUIC_CONFIG_REMOTE_HOST
Remote host to connect to (string, clients only)
Definition imquic.h:240
@ IMQUIC_CONFIG_RAW_QUIC
Whether raw QUIC should be offered (boolean)
Definition imquic.h:258
@ IMQUIC_CONFIG_TLS_KEY
TLS certificate key to use, if any (file path)
Definition imquic.h:246
@ IMQUIC_CONFIG_USER_DATA
Generic user data, if any (void pointer)
Definition imquic.h:286
@ IMQUIC_CONFIG_QLOG_HTTP3
Whether to save HTTP/3 events to QLOG (ignored if not offering WebTransport)
Definition imquic.h:275
@ IMQUIC_CONFIG_TICKET_FILE
If early data is supported, path to file to write/read the session ticket to/from (client only)
Definition imquic.h:252
@ IMQUIC_CONFIG_REMOTE_PORT
Remote host to connect to (clients only)
Definition imquic.h:242
@ IMQUIC_CONFIG_SUBPROTOCOL
Subprotocol to negotiate on the main ALPN, if any (string)
Definition imquic.h:264
@ IMQUIC_CONFIG_TLS_CERT
TLS certificate to use, if any (file path)
Definition imquic.h:244
@ IMQUIC_CONFIG_ALPN
ALPN to negotiate (string, raw QUIC only)
Definition imquic.h:256
@ IMQUIC_CONFIG_HTTP3_PATH
For WebTransport, path to respond to (defaults to "/")
Definition imquic.h:262
@ IMQUIC_CONFIG_TLS_PASSWORD
TLS certificate password to use, if any (string)
Definition imquic.h:248
@ IMQUIC_CONFIG_QLOG_PATH
Save a QLOG file to this path.
Definition imquic.h:269
@ IMQUIC_CONFIG_EARLY_DATA
Whether early data should be supported (boolean)
Definition imquic.h:250
@ IMQUIC_CONFIG_DONE
Must be the last property, followed by NULL.
Definition imquic.h:288
@ IMQUIC_CONFIG_LOCAL_BIND
Local IP address to bind to (default=all interfaces)
Definition imquic.h:236
@ IMQUIC_CONFIG_QLOG_QUIC
Whether to save QUIC events to QLOG.
Definition imquic.h:272
@ IMQUIC_CONFIG_LOCAL_PORT
Local port to bind to (0=random)
Definition imquic.h:238
@ IMQUIC_CONFIG_QLOG_MOQ
Whether to save MoQ events to QLOG.
Definition imquic.h:281
@ IMQUIC_CONFIG_QLOG_SEQUENTIAL
Whether sequential JSON should be used, instead of regular JSON.
Definition imquic.h:284
@ IMQUIC_CONFIG_INIT
Must be the first property (no arguments)
Definition imquic.h:234
const char * imquic_config_str(imquic_config type)
Helper function to serialize to string the name of a imquic_config property.
Definition imquic.c:146
int imquic_get_version_patch(void)
Get the current patch version of the library as a number.
Definition imquic.c:100
uint64_t imquic_varint_read(uint8_t *bytes, size_t blen, uint8_t *length)
Read a variable size integer from a buffer.
Definition imquic.c:490
void imquic_connection_ref(imquic_connection *conn)
Increase a reference to a imquic_connection instance.
Definition imquic.c:470
QUIC Connection.
Definition connection.h:114
Abstraction of a network endpoint (client or server)
Definition network.h:53
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:91
char * name
Name of this endpoint.
Definition network.h:57
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:94
void(* new_connection)(imquic_connection *conn, void *user_data)
Callback to invoke when a new connection is available on this endpoint.
Definition network.h:89
void(* connection_gone)(imquic_connection *conn)
Callback to invoke when new one of the connections handled by this endpoint is closed.
Definition network.h:96
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:100