Types (structs, unions and typedefs)
-
typedef ptrdiff_t dwnx_ssize
dwnx_ssizeis signed counterpart of size_t.
-
typedef void *(*dwnx_malloc)(size_t size, void *user_data)
dwnx_mallocis a custom memory allocator to replace malloc(3). The user_data isdwnx_mem.user_data.
-
typedef void (*dwnx_free)(void *ptr, void *user_data)
dwnx_freeis a custom memory allocator to replace free(3). The user_data isdwnx_mem.user_data.
-
typedef void *(*dwnx_calloc)(size_t nmemb, size_t size, void *user_data)
dwnx_callocis a custom memory allocator to replace calloc(3). The user_data is thedwnx_mem.user_data.
-
typedef void *(*dwnx_realloc)(void *ptr, size_t size, void *user_data)
dwnx_reallocis a custom memory allocator to replace realloc(3). The user_data is thedwnx_mem.user_data.
-
type dwnx_mem
dwnx_memis a custom memory allocator. Theuser_datafield is passed to each allocator function. This can be used, for example, to achieve per-connection memory pool.In the following example code,
my_malloc,my_free,my_callocandmy_reallocare the replacement of the standard allocators malloc(3), free(3), calloc(3) and realloc(3) respectively:void *my_malloc_cb(size_t size, void *user_data) { (void)user_data; return my_malloc(size); } void my_free_cb(void *ptr, void *user_data) { (void)user_data; my_free(ptr); } void *my_calloc_cb(size_t nmemb, size_t size, void *user_data) { (void)user_data; return my_calloc(nmemb, size); } void *my_realloc_cb(void *ptr, size_t size, void *user_data) { (void)user_data; return my_realloc(ptr, size); } void conn_new() { dwnx_mem mem = { .malloc = my_malloc_cb, .free = my_free_cb, .calloc = my_calloc_cb, .realloc = my_realloc_cb, }; ... }
-
void *user_data
user_datais an arbitrary user supplied data. This is passed to each allocator function.
-
dwnx_malloc malloc
-
dwnx_calloc calloc
-
dwnx_realloc realloc
reallocis a custom allocator function to replace realloc(3).
-
void *user_data
-
typedef uint64_t dwnx_tstamp
dwnx_tstampis a timestamp with nanosecond resolution.UINT64_MAXis an invalid value, and it is often used to indicate that no value is set.
-
typedef uint64_t dwnx_duration
dwnx_durationis a period of time in nanosecond resolution.UINT64_MAXis an invalid value, and it is often used to indicate that no value is set.
-
type dwnx_transport_params
dwnx_transport_paramsrepresents QUIC transport parameters.-
uint64_t initial_max_stream_data_bidi_local
initial_max_stream_data_bidi_localis the size of flow control window of locally initiated stream. This is the number of bytes that the remote endpoint can send, and the local endpoint must ensure that it has enough buffer to receive them.
-
uint64_t initial_max_stream_data_bidi_remote
initial_max_stream_data_bidi_remoteis the size of flow control window of remotely initiated stream. This is the number of bytes that the remote endpoint can send, and the local endpoint must ensure that it has enough buffer to receive them.
-
uint64_t initial_max_stream_data_uni
initial_max_stream_data_uniis the size of flow control window of remotely initiated unidirectional stream. This is the number of bytes that the remote endpoint can send, and the local endpoint must ensure that it has enough buffer to receive them.
-
uint64_t initial_max_data
initial_max_datais the connection level flow control window.
-
uint64_t initial_max_streams_bidi
initial_max_streams_bidiis the number of concurrent streams that the remote endpoint can create.
-
uint64_t initial_max_streams_uni
initial_max_streams_uniis the number of concurrent unidirectional streams that the remote endpoint can create.
-
dwnx_duration max_idle_timeout
max_idle_timeoutis a duration during which sender allows quiescent. 0 means no idle timeout. It must not be UINT64_MAX.
-
uint64_t max_record_size
max_record_sizeis the maximum QMux record size that the sender accepts. It must be greater than or equal toDWNX_DEFAULT_MAX_RECORD_SIZE.
-
uint64_t initial_max_stream_data_bidi_local
-
typedef void (*dwnx_log_write)(void *user_data, char *msg, size_t len)
dwnx_log_writeis a callback function for logging. user_data is the same object passed todwnx_conn_client_new()ordwnx_conn_server_new(). The caller guarantees that the memory region [msg, msg + len], inclusive, are writable, and msg*[*len] == ‘0’. If application needs to emit a single line with a line terminator, one can do msg[len] = ‘n’, and write len + 1 bytes from msg.
-
type dwnx_settings
dwnx_settingsdefines QMux connection settings.-
uint64_t conn_id
conn_idis the identifier of this connection. Currently, it is used in a log header so that people can distinguish the particular connection from the others.
-
dwnx_tstamp initial_ts
initial_tsis an initial timestamp given to the library.
-
dwnx_log_write log_write
log_writeis the callback function when a single log message is emitted. If this field is NULL, logging is disabled.
-
uint64_t conn_id
-
typedef int (*dwnx_recv_transport_params)(dwnx_conn *conn, const dwnx_transport_params *params, void *user_data)
dwnx_recv_transport_paramsis invoked when transport parameters params are received from the remote endpoint.The callback function must return 0 if it succeeds, or
DWNX_ERR_CALLBACK_FAILUREwhich makes the library return immediately.
-
typedef int (*dwnx_recv_stream_data)(dwnx_conn *conn, uint32_t flags, int64_t stream_id, uint64_t offset, const uint8_t *data, size_t datalen, void *user_data, void *stream_user_data)
dwnx_recv_stream_datais invoked when stream data is received. The stream is specified by stream_id. flags is the bitwise-OR of zero or more ofDWNX_STREAM_DATA_FLAG_*. If flags &DWNX_STREAM_DATA_FLAG_FINis nonzero, this portion of the data is the last data in this stream. offset is the offset where this data begins. The library ensures that data is passed to the application in the non-decreasing order of offset without any overlap. The data is passed as data of length datalen. datalen may be 0 if and only if fin is nonzero.The callback function must return 0 if it succeeds, or
DWNX_ERR_CALLBACK_FAILUREwhich makes the library return immediately.
-
typedef int (*dwnx_stream_open)(dwnx_conn *conn, int64_t stream_id, void *user_data)
dwnx_stream_openis a callback function which is called when remote stream is opened by a remote endpoint. This function is not called if stream is opened by implicitly (we might reconsider this behaviour later).The implementation of this callback should return 0 if it succeeds. Returning
DWNX_ERR_CALLBACK_FAILUREmakes the library call return immediately.
-
typedef int (*dwnx_stream_close)(dwnx_conn *conn, uint32_t flags, int64_t stream_id, uint64_t rx_app_error_code, uint64_t tx_app_error_code, void *user_data, void *stream_user_data)
dwnx_stream_closeis invoked when a stream is closed. This callback is not called when QUIC connection is closed before existing streams are closed. flags is the bitwise-OR of zero or more ofDWNX_STREAM_CLOSE_FLAG_*. rx_app_error_code indicates the error code that shut down the receiving side of the stream ifDWNX_STREAM_CLOSE_FLAG_RX_APP_ERROR_CODE_SETis set in flags. tx_app_error_code indicates the error code that shut down the sending side of the stream ifDWNX_STREAM_CLOSE_FLAG_TX_APP_ERROR_CODE_SETis set in flags.Because QUIC can close the send and receive sides of a stream independently, this callback has 2 application error codes for both directions. No error code means that its direction of a stream is closed cleanly. For example, a client gets STOP_SENDING frame from a server, and it sends back RESET_STREAM frame with the error code included in STOP_SENDING frame. This error code is reported as tx_app_error_code and
DWNX_STREAM_CLOSE_FLAG_TX_APP_ERROR_CODE_SETis set in flags. Meanwhile, the client receives the response body without any error. ThenDWNX_STREAM_CLOSE_FLAG_RX_APP_ERROR_CODE_SETis not set in flags.The implementation of this callback should return 0 if it succeeds. Returning
DWNX_ERR_CALLBACK_FAILUREmakes the library call return immediately.
-
typedef int (*dwnx_stream_reset)(dwnx_conn *conn, int64_t stream_id, uint64_t final_size, uint64_t app_error_code, void *user_data, void *stream_user_data)
dwnx_stream_resetis invoked when a stream identified by stream_id is reset by a remote endpoint.The implementation of this callback should return 0 if it succeeds. Returning
DWNX_ERR_CALLBACK_FAILUREmakes the library call return immediately.
-
typedef int (*dwnx_stream_stop_sending)(dwnx_conn *conn, int64_t stream_id, uint64_t app_error_code, void *user_data, void *stream_user_data)
dwnx_stream_stop_sendingis invoked when a stream is no longer read by a local endpoint before it receives all stream data. This function is called at most once per stream. app_error_code is the error code passed todwnx_conn_shutdown_stream_read()ordwnx_conn_shutdown_stream().The callback function must return 0 if it succeeds. Returning
DWNX_ERR_CALLBACK_FAILUREmakes the library call return immediately.
-
typedef int (*dwnx_recv_stop_sending)(dwnx_conn *conn, int64_t stream_id, uint64_t app_error_code, void *user_data, void *stream_user_data)
dwnx_recv_stop_sendingis invoked when a STOP_SENDING frame is received from a remote endpoint for a stream identified by stream_id. app_error_code is the application error code carried by the STOP_SENDING frame. This callback is called at most once per stream.The callback function must return 0 if it succeeds. Returning
DWNX_ERR_CALLBACK_FAILUREmakes the library call return immediately.
-
typedef int (*dwnx_extend_max_stream_data)(dwnx_conn *conn, int64_t stream_id, uint64_t max_data, void *user_data, void *stream_user_data)
dwnx_extend_max_stream_datais a callback function which is invoked when max stream data is extended. stream_id identifies the stream. max_data is a cumulative number of bytes an endpoint can send on this stream.The callback function must return 0 if it succeeds. Returning
DWNX_ERR_CALLBACK_FAILUREmakes the library call return immediately.
-
typedef int (*dwnx_extend_max_streams)(dwnx_conn *conn, uint64_t max_streams, void *user_data)
dwnx_extend_max_streamsis a callback function which is called every time max stream ID is strictly extended. max_streams is the cumulative number of streams which an endpoint can open.The callback function must return 0 if it succeeds. Returning
DWNX_ERR_CALLBACK_FAILUREmakes the library call return immediately.
-
typedef void (*dwnx_rand)(uint8_t *dest, size_t destlen)
dwnx_randis a callback function which is invoked when unpredictable data of destlen bytes are needed. The implementation must write unpredictable data of destlen bytes into the buffer pointed by dest.
-
type dwnx_callbacks
dwnx_callbacksholds a set of callback functions.-
dwnx_rand rand
randis a callback function which is invoked when the library needs random data. This callback function must be specified.
-
dwnx_recv_transport_params recv_transport_params
recv_transport_paramsis a callback function which is invoked when transport parameters are received from the remote endpoint.
-
dwnx_recv_stream_data recv_stream_data
recv_stream_datais a callback function which is invoked when stream data, which includes application data, is received. This callback function is optional.
-
dwnx_stream_open stream_open
stream_openis a callback function which is invoked when new remote stream is opened by a remote endpoint. This callback function is optional.
-
dwnx_stream_close stream_close
stream_closeis a callback function which is invoked when a stream is closed. This callback function is optional.
-
dwnx_stream_reset stream_reset
stream_resetis a callback function which is invoked when a stream is reset by a remote endpoint. This callback function is optional.
-
dwnx_stream_stop_sending stream_stop_sending
stream_stop_sendingis a callback function which is invoked when a local endpoint no longer reads from a stream before it receives all stream data. This callback function is optional.
-
dwnx_recv_stop_sending recv_stop_sending
recv_stop_sendingis a callback function which is invoked when a STOP_SENDING frame is received from a remote endpoint. This callback function is optional.
-
dwnx_extend_max_stream_data extend_max_stream_data
extend_max_stream_datais callback function which is invoked when the maximum offset of stream data that a local endpoint can send is increased. This callback function is optional.
-
dwnx_extend_max_streams extend_max_local_streams_bidi
extend_max_local_streams_bidiis a callback function which is invoked when the number of bidirectional stream which a local endpoint can open is increased. This callback function is optional.
-
dwnx_extend_max_streams extend_max_local_streams_uni
extend_max_local_streams_uniis a callback function which is invoked when the number of unidirectional stream which a local endpoint can open is increased. This callback function is optional.
-
dwnx_extend_max_streams extend_max_remote_streams_bidi
extend_max_remote_streams_bidiis a callback function which is invoked when the number of bidirectional streams which a remote endpoint can open is increased. This callback function is optional.
-
dwnx_extend_max_streams extend_max_remote_streams_uni
extend_max_remote_streams_uniis a callback function which is invoked when the number of unidirectional streams which a remote endpoint can open is increased. This callback function is optional.
-
dwnx_rand rand
-
type dwnx_ccerr
dwnx_ccerrcontains connection error code, its type, a frame type that caused this error, and the optional reason phrase.-
dwnx_ccerr_type type
typeis the type of this error.
-
uint64_t error_code
error_codeis the error code for connection closure. Its interpretation depends ontype.
-
uint64_t frame_type
frame_typeis the type of QUIC frame which triggers this connection error. This field is set to 0 if the frame type is unknown.
-
dwnx_ccerr_type type