Loading...
Searching...
No Matches
Functions
quic.c File Reference

QUIC stack implementation. More...

#include <arpa/inet.h>
#include "internal/quic.h"
#include "internal/error.h"
#include "internal/utils.h"
#include "imquic/debug.h"
Include dependency graph for quic.c:

Functions

void imquic_quic_connection_add (imquic_connection *conn, imquic_connection_id *cid)
 Track a Connection ID and map it to a connection.
 
void imquic_quic_connection_remove (imquic_connection_id *cid)
 Stop tracking a Connection ID associated to a connection.
 
void imquic_quic_init (void)
 Initialize the QUIC stack at startup.
 
void imquic_quic_deinit (void)
 Uninitialize the QUIC stack.
 
const char * imquic_long_packet_type_str (imquic_long_packet_type type)
 Helper function to serialize to string the name of a imquic_long_packet_type value.
 
const char * imquic_frame_type_str (imquic_frame_type type)
 Helper function to serialize to string the name of a imquic_frame_type value.
 
const char * imquic_transport_parameter_str (imquic_transport_parameter param)
 Helper function to serialize to string the name of a imquic_transport_parameter value.
 
imquic_frameimquic_frame_create (imquic_frame_type type, uint8_t *buffer, size_t size)
 Helper method to create a imquic_frame instance.
 
void imquic_frame_destroy (imquic_frame *frame)
 Helper method to destroy an existing imquic_frame instance.
 
imquic_packetimquic_packet_create (void)
 Helper method to create a imquic_packet instance.
 
int imquic_packet_long_init (imquic_packet *pkt, imquic_long_packet_type type, imquic_connection_id *src, imquic_connection_id *dest)
 Initialize a imquic_packet instance as a long header packet.
 
int imquic_packet_short_init (imquic_packet *pkt, imquic_connection_id *dest)
 Initialize a imquic_packet instance as a short header packet.
 
void imquic_packet_destroy (imquic_packet *pkt)
 Helper method to destroy an existing imquic_packet instance.
 
void imquic_sent_packet_destroy (imquic_sent_packet *sent_pkt)
 Helper method to destroy an existing imquic_sent_packet instance.
 
int imquic_parse_packet (imquic_network_endpoint *socket, imquic_network_address *sender, imquic_connection **pconn, imquic_packet *pkt, uint8_t *quic, size_t bytes)
 Parse a QUIC packet from an incoming buffer and handle it.
 
int imquic_parse_frames (imquic_connection *conn, imquic_packet *pkt)
 Parse QUIC frames in a QUIC message payload.
 
size_t imquic_payload_parse_ack (imquic_connection *conn, uint8_t *bytes, size_t blen, enum ssl_encryption_level_t level)
 Helper method to process an ACK frame.
 
size_t imquic_payload_parse_reset_stream (imquic_connection *conn, uint8_t *bytes, size_t blen)
 Helper method to process a RESET_STREAM frame.
 
size_t imquic_payload_parse_stop_sending (imquic_connection *conn, uint8_t *bytes, size_t blen)
 Helper method to process a STOP_SENDING frame.
 
size_t imquic_payload_parse_crypto (imquic_connection *conn, uint8_t *bytes, size_t blen, enum ssl_encryption_level_t level)
 Helper method to process a CRYPTO frame, and in case add all chunks to the buffer associated with the related encryption level, so that it can be processed later.
 
size_t imquic_payload_parse_new_token (imquic_connection *conn, uint8_t *bytes, size_t blen)
 Helper method to process a NEW_TOKEN frame.
 
size_t imquic_payload_parse_stream (imquic_connection *conn, uint8_t *bytes, size_t blen)
 Helper method to process a STREAM frame, and handle it accordingly, e.g., by creating the stream locally (if previously unknown), update the associated buffer with the new data, update the state of the stream, and notify the stack using internal callbacks.
 
size_t imquic_payload_parse_max_data (imquic_connection *conn, uint8_t *bytes, size_t blen)
 Helper method to process a MAX_DATA frame.
 
size_t imquic_payload_parse_max_stream_data (imquic_connection *conn, uint8_t *bytes, size_t blen)
 Helper method to process a MAX_STREAM_DATA frame.
 
size_t imquic_payload_parse_max_streams (imquic_connection *conn, uint8_t *bytes, size_t blen)
 Helper method to process a MAX_STREAMS frame.
 
size_t imquic_payload_parse_data_blocked (imquic_connection *conn, uint8_t *bytes, size_t blen)
 Helper method to process a DATA_BLOCKED frame.
 
size_t imquic_payload_parse_stream_data_blocked (imquic_connection *conn, uint8_t *bytes, size_t blen)
 Helper method to process a STREAM_DATA_BLOCKED frame.
 
size_t imquic_payload_parse_streams_blocked (imquic_connection *conn, uint8_t *bytes, size_t blen)
 Helper method to process a STREAMS_BLOCKED frame.
 
size_t imquic_payload_parse_new_connection_id (imquic_connection *conn, uint8_t *bytes, size_t blen)
 Helper method to process a NEW_CONNECTION_ID frame.
 
size_t imquic_payload_parse_retire_connection_id (imquic_connection *conn, uint8_t *bytes, size_t blen)
 Helper method to process a RETIRE_CONNECTION_ID frame.
 
size_t imquic_payload_parse_path_challenge (imquic_connection *conn, uint8_t *bytes, size_t blen)
 Helper method to process a PATH_CHALLENGE frame.
 
size_t imquic_payload_parse_path_response (imquic_connection *conn, uint8_t *bytes, size_t blen)
 Helper method to process a PATH_RESPONSE frame.
 
size_t imquic_payload_parse_connection_close (imquic_connection *conn, uint8_t *bytes, size_t blen)
 Helper method to process a CONNECTION_CLOSE frame, and handle it accordingly by closing the connection locally too.
 
size_t imquic_payload_parse_datagram (imquic_connection *conn, uint8_t *bytes, size_t blen)
 Helper method to process a DATAGRAM frame, and notify the stack about it via internal callbacks.
 
size_t imquic_payload_add_padding (uint8_t *bytes, size_t blen, size_t padding)
 Helper method to add a PADDING frame to a buffer.
 
size_t imquic_payload_add_ping (uint8_t *bytes, size_t blen)
 Helper method to add a PING frame to a buffer.
 
size_t imquic_payload_add_ack (uint8_t *bytes, size_t blen, GList *received, uint64_t delay, uint64_t *ecn_counts)
 Helper method to add a ACK frame to a buffer.
 
size_t imquic_payload_add_reset_stream (uint8_t *bytes, size_t blen, uint64_t stream_id, uint64_t error_code, uint64_t final_size)
 Helper method to add a RESET_STREAM frame to a buffer.
 
size_t imquic_payload_add_stop_sending (uint8_t *bytes, size_t blen, uint64_t stream_id, uint64_t error_code)
 Helper method to add a STOP_SENDING frame to a buffer.
 
size_t imquic_payload_add_crypto (uint8_t *bytes, size_t blen, uint8_t *crypto, size_t crypto_offset, size_t crypto_length)
 Helper method to add a CRYPTO frame to a buffer.
 
size_t imquic_payload_add_new_token (uint8_t *bytes, size_t blen, uint8_t *token, size_t token_length)
 Helper method to add a NEW_TOKEN frame to a buffer.
 
size_t imquic_payload_add_stream (uint8_t *bytes, size_t blen, uint64_t stream_id, uint8_t *stream, size_t stream_offset, size_t stream_length, gboolean complete, gboolean last)
 Helper method to add a STREAM frame to a buffer.
 
size_t imquic_payload_add_max_data (uint8_t *bytes, size_t blen, uint64_t max_data)
 Helper method to add a MAX_DATA frame to a buffer.
 
size_t imquic_payload_add_max_stream_data (uint8_t *bytes, size_t blen, uint64_t stream_id, uint64_t max_data)
 Helper method to add a MAX_STREAM_DATA frame to a buffer.
 
size_t imquic_payload_add_max_streams (uint8_t *bytes, size_t blen, gboolean bidirectional, uint64_t max_streams)
 Helper method to add a MAX_STREAMS frame to a buffer.
 
size_t imquic_payload_add_data_blocked (uint8_t *bytes, size_t blen, uint64_t max_data)
 Helper method to add a DATA_BLOCKED frame to a buffer.
 
size_t imquic_payload_add_stream_data_blocked (uint8_t *bytes, size_t blen, uint64_t stream_id, uint64_t max_data)
 Helper method to add a STREAM_DATA_BLOCKED frame to a buffer.
 
size_t imquic_payload_add_streams_blocked (uint8_t *bytes, size_t blen, uint64_t max_streams)
 Helper method to add a STREAMS_BLOCKED frame to a buffer.
 
size_t imquic_payload_add_new_connection_id (uint8_t *bytes, size_t blen, uint64_t seqnum, uint64_t retire_prior_to, imquic_connection_id *cid, uint8_t *reset_token)
 Helper method to add a NEW_CONNECTION_ID frame to a buffer.
 
size_t imquic_payload_add_retire_connection_id (uint8_t *bytes, size_t blen, uint64_t seqnum)
 Helper method to add a RETIRE_CONNECTION_ID frame to a buffer.
 
size_t imquic_payload_add_path_challenge (uint8_t *bytes, size_t blen, uint8_t *data)
 Helper method to add a PATH_CHALLENGE frame to a buffer.
 
size_t imquic_payload_add_path_response (uint8_t *bytes, size_t blen, uint8_t *data)
 Helper method to add a PATH_RESPONSE frame to a buffer.
 
size_t imquic_payload_add_connection_close (uint8_t *bytes, size_t blen, imquic_error_code error_code, imquic_frame_type frame_type, const char *reason)
 Helper method to add a CONNECTION_CLOSE frame to a buffer.
 
size_t imquic_payload_add_handshake_done (uint8_t *bytes, size_t blen)
 Helper method to add a HANDSHAKE_DONE frame to a buffer.
 
size_t imquic_payload_add_datagram (uint8_t *bytes, size_t blen, uint8_t *datagram, size_t datagram_length, gboolean last)
 Helper method to add a DATAGRAM frame to a buffer.
 
size_t imquic_transport_parameter_add_novalue (uint8_t *bytes, size_t blen, imquic_transport_parameter param)
 Helper to add a QUIC transport parameter with no value to a buffer.
 
size_t imquic_transport_parameter_add_int (uint8_t *bytes, size_t blen, imquic_transport_parameter param, uint64_t number)
 Helper to add a QUIC transport parameter with a numeric value to a buffer.
 
size_t imquic_transport_parameter_add_data (uint8_t *bytes, size_t blen, imquic_transport_parameter param, uint8_t *buf, size_t buflen)
 Helper to add a QUIC transport parameter with generic data to a buffer.
 
size_t imquic_transport_parameter_add_connection_id (uint8_t *bytes, size_t blen, imquic_transport_parameter param, imquic_connection_id *cid)
 Helper to add a QUIC transport parameter with a Connection ID to a buffer.
 
int imquic_parse_transport_parameters (imquic_connection *conn, uint8_t *bytes, size_t blen)
 Helper to parse a buffer containing QUIC transport parameters, and update the associated imquic_connection instance accordingly.
 
int imquic_send_ack (imquic_connection *conn, enum ssl_encryption_level_t level, imquic_connection_id *src, imquic_connection_id *dest)
 Helper method to generate a packet containing an ACK and send it.
 
int imquic_send_pending_crypto (imquic_connection *conn, imquic_connection_id *src, imquic_connection_id *dest)
 Helper method to generate one or more packets containing one or more CRYPTO frames and send them.
 
int imquic_send_keepalive (imquic_connection *conn, imquic_connection_id *dest)
 Helper method to generate a packet containing a PING and send it.
 
int imquic_send_pending_stream (imquic_connection *conn, imquic_connection_id *dest)
 Helper method to generate one or more packets containing one or more STREAM frames and send them.
 
int imquic_send_pending_datagram (imquic_connection *conn, imquic_connection_id *dest)
 Helper method to generate one or more packets containing one or more DATAGRAM frames and send them.
 
int imquic_send_close_connection (imquic_connection *conn, imquic_error_code error_code, imquic_frame_type frame_type, const char *reason)
 Helper method to generate a packet containing a CONNECTION_CLOSE and send it.
 
int imquic_serialize_packet (imquic_connection *conn, imquic_packet *pkt)
 Serialize an imquic packet object to a QUIC packet ready to be sent, taking care of header protection and encryption as well.
 
int imquic_send_packet (imquic_connection *conn, imquic_packet *pkt)
 Send a QUIC packet to the peer.
 
int imquic_retransmit_packet (imquic_connection *conn, imquic_sent_packet *sent_pkt)
 Retransmit a previously sent packet.
 
void imquic_process_message (imquic_network_endpoint *socket, imquic_network_address *sender, uint8_t *bytes, size_t blen)
 Process incoming data from the network we've made aware of.
 
void imquic_check_incoming_crypto (imquic_connection *conn)
 Helper method to check if we received CRYPTO frames we need to go through, and in case pass them to the TLS stack for processing.
 
gboolean imquic_handle_event (imquic_connection *conn)
 Callback fired when the event loop has an event for a specific connection.
 
int imquic_start_quic_client (imquic_network_endpoint *socket)
 Helper to start a new client endpoint, and so attempt a connection.
 

Detailed Description

QUIC stack implementation.

Author
Lorenzo Miniero loren.nosp@m.zo@m.nosp@m.eetec.nosp@m.ho.c.nosp@m.om

Implementation of the QUIC stack itself. This is where message parsing and building is implemented, including connection establishment and (mostly) state management.

Function Documentation

◆ imquic_check_incoming_crypto()

void imquic_check_incoming_crypto ( imquic_connection * conn)

Helper method to check if we received CRYPTO frames we need to go through, and in case pass them to the TLS stack for processing.

Parameters
connThe imquic_connection to check

◆ imquic_frame_create()

imquic_frame * imquic_frame_create ( imquic_frame_type type,
uint8_t * buffer,
size_t size )

Helper method to create a imquic_frame instance.

Parameters
typeThe type of frame
bufferThe content of the frame
sizeThe size of the frame
Returns
A pointer to a imquic_frame instance, if successful, or NULL otherwise

◆ imquic_frame_destroy()

void imquic_frame_destroy ( imquic_frame * frame)

Helper method to destroy an existing imquic_frame instance.

Parameters
frameThe imquic_frame instanceto destroy

◆ imquic_frame_type_str()

const char * imquic_frame_type_str ( imquic_frame_type type)

Helper function to serialize to string the name of a imquic_frame_type value.

Parameters
typeThe imquic_frame_type value
Returns
The type name as a string, if valid, or NULL otherwise

◆ imquic_handle_event()

gboolean imquic_handle_event ( imquic_connection * conn)

Callback fired when the event loop has an event for a specific connection.

Note
At the moment, this is used as a way to use the event loop to check if/when we have stuff to send (e.g., ACKs, data, etc.).
Parameters
connThe imquic_connection instance the event is for
Returns
G_SOURCE_CONTINUE if the event should be fired again in the future, G_SOURCE_REMOVE otherwise

◆ imquic_long_packet_type_str()

const char * imquic_long_packet_type_str ( imquic_long_packet_type type)

Helper function to serialize to string the name of a imquic_long_packet_type value.

Parameters
typeThe imquic_long_packet_type value
Returns
The type name as a string, if valid, or NULL otherwise

◆ imquic_packet_create()

imquic_packet * imquic_packet_create ( void )

Helper method to create a imquic_packet instance.

Returns
A pointer to a imquic_packet instance, if successful, or NULL otherwise

◆ imquic_packet_destroy()

void imquic_packet_destroy ( imquic_packet * pkt)

Helper method to destroy an existing imquic_packet instance.

Parameters
pktThe imquic_packet instance to destroy

◆ imquic_packet_long_init()

int imquic_packet_long_init ( imquic_packet * pkt,
imquic_long_packet_type type,
imquic_connection_id * src,
imquic_connection_id * dest )

Initialize a imquic_packet instance as a long header packet.

Parameters
pktThe imquic_packet instance to initialize
typeThe imquic_long_packet_type type of long header packet (e.g., Initial)
srcThe Source Connection ID to put in the packet, if any
destThe Destination Connection ID to put in the packet, if any
Returns
0 in case of success, or a negative integer otherwise

◆ imquic_packet_short_init()

int imquic_packet_short_init ( imquic_packet * pkt,
imquic_connection_id * dest )

Initialize a imquic_packet instance as a short header packet.

Parameters
pktThe imquic_packet instance to initialize
destThe Destination Connection ID to put in the packet, if any
Returns
0 in case of success, or a negative integer otherwise

◆ imquic_parse_frames()

int imquic_parse_frames ( imquic_connection * conn,
imquic_packet * pkt )

Parse QUIC frames in a QUIC message payload.

Note
The state of the connection will be updated as the message is parsed, as some frames will trigger a change of state, while others will fill some buffers that we may need to process later.
Parameters
connThe imquic_connection that received the message
pktThe imquic_packet containing the payload to process returns 0 in case of success, a negative integer otherwise

◆ imquic_parse_packet()

int imquic_parse_packet ( imquic_network_endpoint * socket,
imquic_network_address * sender,
imquic_connection ** pconn,
imquic_packet * pkt,
uint8_t * quic,
size_t bytes )

Parse a QUIC packet from an incoming buffer and handle it.

Note
Considering a UDP message may contain more than one QUIC message, this function returns the size of the QUIC message it finds at the beginning of the buffer, so that, in case there's still more data to process, the caller can call the function again after shifting the pointer.
Parameters
[in]socketThe endpoint that received the QUIC packet
[in]senderThe network address of who sent this packet
[out]pconnAfter parsing the packet, this will be filled with the imquic_connection associated with it
[out]pktThe imquic_packet instance to write the result of the parsing to
[in]quicThe buffer containing the QUIC packet
[in]bytesSize of the buffer containing the QUIC packet
Returns
The size of the parsed packet, if successfuk, or a negative integer otherwise

◆ imquic_parse_transport_parameters()

int imquic_parse_transport_parameters ( imquic_connection * conn,
uint8_t * bytes,
size_t blen )

Helper to parse a buffer containing QUIC transport parameters, and update the associated imquic_connection instance accordingly.

Parameters
connThe imquic_connection instance to update with the peer parameters
bytesThe buffer containing the QUIC transport parameters
blenThe size of the buffer to parse
Returns
0 in case of success, a negative integer otherwise

◆ imquic_payload_add_ack()

size_t imquic_payload_add_ack ( uint8_t * bytes,
size_t blen,
GList * received,
uint64_t delay,
uint64_t * ecn_counts )

Helper method to add a ACK frame to a buffer.

Parameters
bytesBuffer to add the frame to
blenSize of the buffer
receivedThe list of packets we did receive
delayThe value to put in the delay part of the frame
ecn_countsArray of three ECN-related properties to put in the frame, if any
Returns
The size of the frame, if successful, or 0 otherwise

◆ imquic_payload_add_connection_close()

size_t imquic_payload_add_connection_close ( uint8_t * bytes,
size_t blen,
imquic_error_code error_code,
imquic_frame_type frame_type,
const char * reason )

Helper method to add a CONNECTION_CLOSE frame to a buffer.

Parameters
bytesBuffer to add the frame to
blenSize of the buffer
error_codeError code to report in the frame
frame_typeThe frame type that caused the connection to be closed
reasonA verbose description of the error, if any
Returns
The size of the frame, if successful, or 0 otherwise

◆ imquic_payload_add_crypto()

size_t imquic_payload_add_crypto ( uint8_t * bytes,
size_t blen,
uint8_t * crypto,
size_t crypto_offset,
size_t crypto_length )

Helper method to add a CRYPTO frame to a buffer.

Parameters
bytesBuffer to add the frame to
blenSize of the buffer
cryptoBuffer containing the TLS data to send
crypto_offsetOffset this TLS data is at, relatively to the whole CRYPTO exchange
crypto_lengthSize of the TLS data buffer
Returns
The size of the frame, if successful, or 0 otherwise

◆ imquic_payload_add_data_blocked()

size_t imquic_payload_add_data_blocked ( uint8_t * bytes,
size_t blen,
uint64_t max_data )

Helper method to add a DATA_BLOCKED frame to a buffer.

Parameters
bytesBuffer to add the frame to
blenSize of the buffer
max_dataThe limit at which the blocking occurred
Returns
The size of the frame, if successful, or 0 otherwise

◆ imquic_payload_add_datagram()

size_t imquic_payload_add_datagram ( uint8_t * bytes,
size_t blen,
uint8_t * datagram,
size_t datagram_length,
gboolean last )

Helper method to add a DATAGRAM frame to a buffer.

Parameters
bytesBuffer to add the frame to
blenSize of the buffer
datagramBuffer containing the datagram data to send
datagram_lengthSize of the datagram data buffer
lastWhether this is the last frame in the packet, and so we can omit the Length field
Returns
The size of the frame, if successful, or 0 otherwise

◆ imquic_payload_add_handshake_done()

size_t imquic_payload_add_handshake_done ( uint8_t * bytes,
size_t blen )

Helper method to add a HANDSHAKE_DONE frame to a buffer.

Parameters
bytesBuffer to add the frame to
blenSize of the buffer
Returns
The size of the frame, if successful, or 0 otherwise

◆ imquic_payload_add_max_data()

size_t imquic_payload_add_max_data ( uint8_t * bytes,
size_t blen,
uint64_t max_data )

Helper method to add a MAX_DATA frame to a buffer.

Parameters
bytesBuffer to add the frame to
blenSize of the buffer
max_dataThe new value to report
Returns
The size of the frame, if successful, or 0 otherwise

◆ imquic_payload_add_max_stream_data()

size_t imquic_payload_add_max_stream_data ( uint8_t * bytes,
size_t blen,
uint64_t stream_id,
uint64_t max_data )

Helper method to add a MAX_STREAM_DATA frame to a buffer.

Parameters
bytesBuffer to add the frame to
blenSize of the buffer
stream_idID of the stream this new limit applies to
max_dataThe new value to report
Returns
The size of the frame, if successful, or 0 otherwise

◆ imquic_payload_add_max_streams()

size_t imquic_payload_add_max_streams ( uint8_t * bytes,
size_t blen,
gboolean bidirectional,
uint64_t max_streams )

Helper method to add a MAX_STREAMS frame to a buffer.

Parameters
bytesBuffer to add the frame to
blenSize of the buffer
bidirectionalWhether this impacts bidirectional or unidirectional streams
max_streamsThe new value to report
Returns
The size of the frame, if successful, or 0 otherwise

◆ imquic_payload_add_new_connection_id()

size_t imquic_payload_add_new_connection_id ( uint8_t * bytes,
size_t blen,
uint64_t seqnum,
uint64_t retire_prior_to,
imquic_connection_id * cid,
uint8_t * reset_token )

Helper method to add a NEW_CONNECTION_ID frame to a buffer.

Parameters
bytesBuffer to add the frame to
blenSize of the buffer
seqnumSequence number of the Connection ID
retire_prior_toConnection IDs that should be retired
cidThe Connection ID value
reset_tokenStateless reset token
Returns
The size of the frame, if successful, or 0 otherwise

◆ imquic_payload_add_new_token()

size_t imquic_payload_add_new_token ( uint8_t * bytes,
size_t blen,
uint8_t * token,
size_t token_length )

Helper method to add a NEW_TOKEN frame to a buffer.

Parameters
bytesBuffer to add the frame to
blenSize of the buffer
tokenBuffer containing the token to add
token_lengthSize of the token buffer
Returns
The size of the frame, if successful, or 0 otherwise

◆ imquic_payload_add_padding()

size_t imquic_payload_add_padding ( uint8_t * bytes,
size_t blen,
size_t padding )

Helper method to add a PADDING frame to a buffer.

Parameters
bytesBuffer to add the frame to
blenSize of the buffer
paddingHow many bytes of padding to add
Returns
The size of the frame, if successful, or 0 otherwise

◆ imquic_payload_add_path_challenge()

size_t imquic_payload_add_path_challenge ( uint8_t * bytes,
size_t blen,
uint8_t * data )

Helper method to add a PATH_CHALLENGE frame to a buffer.

Parameters
bytesBuffer to add the frame to
blenSize of the buffer
dataData to send as part of the challenge
Returns
The size of the frame, if successful, or 0 otherwise

◆ imquic_payload_add_path_response()

size_t imquic_payload_add_path_response ( uint8_t * bytes,
size_t blen,
uint8_t * data )

Helper method to add a PATH_RESPONSE frame to a buffer.

Parameters
bytesBuffer to add the frame to
blenSize of the buffer
dataData to send as part of the response
Returns
The size of the frame, if successful, or 0 otherwise

◆ imquic_payload_add_ping()

size_t imquic_payload_add_ping ( uint8_t * bytes,
size_t blen )

Helper method to add a PING frame to a buffer.

Parameters
bytesBuffer to add the frame to
blenSize of the buffer
Returns
The size of the frame, if successful, or 0 otherwise

◆ imquic_payload_add_reset_stream()

size_t imquic_payload_add_reset_stream ( uint8_t * bytes,
size_t blen,
uint64_t stream_id,
uint64_t error_code,
uint64_t final_size )

Helper method to add a RESET_STREAM frame to a buffer.

Parameters
bytesBuffer to add the frame to
blenSize of the buffer
stream_idID of the stream to reset
error_codeError code to report in the frame
final_sizeFinal size to report in the frame
Returns
The size of the frame, if successful, or 0 otherwise

◆ imquic_payload_add_retire_connection_id()

size_t imquic_payload_add_retire_connection_id ( uint8_t * bytes,
size_t blen,
uint64_t seqnum )

Helper method to add a RETIRE_CONNECTION_ID frame to a buffer.

Parameters
bytesBuffer to add the frame to
blenSize of the buffer
seqnumSequence number of the Connection ID to retire
Returns
The size of the frame, if successful, or 0 otherwise

◆ imquic_payload_add_stop_sending()

size_t imquic_payload_add_stop_sending ( uint8_t * bytes,
size_t blen,
uint64_t stream_id,
uint64_t error_code )

Helper method to add a STOP_SENDING frame to a buffer.

Parameters
bytesBuffer to add the frame to
blenSize of the buffer
stream_idID of the stream whose sending must stop
error_codeError code to report in the frame
Returns
The size of the frame, if successful, or 0 otherwise

◆ imquic_payload_add_stream()

size_t imquic_payload_add_stream ( uint8_t * bytes,
size_t blen,
uint64_t stream_id,
uint8_t * stream,
size_t stream_offset,
size_t stream_length,
gboolean complete,
gboolean last )

Helper method to add a STREAM frame to a buffer.

Parameters
bytesBuffer to add the frame to
blenSize of the buffer
stream_idID of the stream this data belongs to
streamBuffer containing the stream data to send
stream_offsetOffset this stream data is at, relatively to the whole STREAM exchange
stream_lengthSize of the stream data buffer
completeWhether this data marks the end of the STREAM in this direction
lastWhether this is the last frame in the packet, and so we can omit the Length field
Returns
The size of the frame, if successful, or 0 otherwise

◆ imquic_payload_add_stream_data_blocked()

size_t imquic_payload_add_stream_data_blocked ( uint8_t * bytes,
size_t blen,
uint64_t stream_id,
uint64_t max_data )

Helper method to add a STREAM_DATA_BLOCKED frame to a buffer.

Parameters
bytesBuffer to add the frame to
blenSize of the buffer
stream_idID of the stream that has been blocked
max_dataThe limit at which the blocking occurred
Returns
The size of the frame, if successful, or 0 otherwise

◆ imquic_payload_add_streams_blocked()

size_t imquic_payload_add_streams_blocked ( uint8_t * bytes,
size_t blen,
uint64_t max_streams )

Helper method to add a STREAMS_BLOCKED frame to a buffer.

Parameters
bytesBuffer to add the frame to
blenSize of the buffer
max_streamsThe limit at which the blocking occurred
Returns
The size of the frame, if successful, or 0 otherwise

◆ imquic_payload_parse_ack()

size_t imquic_payload_parse_ack ( imquic_connection * conn,
uint8_t * bytes,
size_t blen,
enum ssl_encryption_level_t level )

Helper method to process an ACK frame.

Parameters
connThe imquic_connection that received the message
bytesBuffer containing the frame
blenSize of the buffer containing the frame
levelEncryption level of the packet containing this frame
Returns
The size of the frame, if successful, or 0 otherwise

◆ imquic_payload_parse_connection_close()

size_t imquic_payload_parse_connection_close ( imquic_connection * conn,
uint8_t * bytes,
size_t blen )

Helper method to process a CONNECTION_CLOSE frame, and handle it accordingly by closing the connection locally too.

Parameters
connThe imquic_connection that received the message
bytesBuffer containing the frame
blenSize of the buffer containing the frame
Returns
The size of the frame, if successful, or 0 otherwise

◆ imquic_payload_parse_crypto()

size_t imquic_payload_parse_crypto ( imquic_connection * conn,
uint8_t * bytes,
size_t blen,
enum ssl_encryption_level_t level )

Helper method to process a CRYPTO frame, and in case add all chunks to the buffer associated with the related encryption level, so that it can be processed later.

Parameters
connThe imquic_connection that received the message
bytesBuffer containing the frame
blenSize of the buffer containing the frame
levelEncryption level of the packet containing this frame
Returns
The size of the frame, if successful, or 0 otherwise

◆ imquic_payload_parse_data_blocked()

size_t imquic_payload_parse_data_blocked ( imquic_connection * conn,
uint8_t * bytes,
size_t blen )

Helper method to process a DATA_BLOCKED frame.

Parameters
connThe imquic_connection that received the message
bytesBuffer containing the frame
blenSize of the buffer containing the frame
Returns
The size of the frame, if successful, or 0 otherwise

◆ imquic_payload_parse_datagram()

size_t imquic_payload_parse_datagram ( imquic_connection * conn,
uint8_t * bytes,
size_t blen )

Helper method to process a DATAGRAM frame, and notify the stack about it via internal callbacks.

Parameters
connThe imquic_connection that received the message
bytesBuffer containing the frame
blenSize of the buffer containing the frame
Returns
The size of the frame, if successful, or 0 otherwise

◆ imquic_payload_parse_max_data()

size_t imquic_payload_parse_max_data ( imquic_connection * conn,
uint8_t * bytes,
size_t blen )

Helper method to process a MAX_DATA frame.

Parameters
connThe imquic_connection that received the message
bytesBuffer containing the frame
blenSize of the buffer containing the frame
Returns
The size of the frame, if successful, or 0 otherwise

◆ imquic_payload_parse_max_stream_data()

size_t imquic_payload_parse_max_stream_data ( imquic_connection * conn,
uint8_t * bytes,
size_t blen )

Helper method to process a MAX_STREAM_DATA frame.

Parameters
connThe imquic_connection that received the message
bytesBuffer containing the frame
blenSize of the buffer containing the frame
Returns
The size of the frame, if successful, or 0 otherwise

◆ imquic_payload_parse_max_streams()

size_t imquic_payload_parse_max_streams ( imquic_connection * conn,
uint8_t * bytes,
size_t blen )

Helper method to process a MAX_STREAMS frame.

Parameters
connThe imquic_connection that received the message
bytesBuffer containing the frame
blenSize of the buffer containing the frame
Returns
The size of the frame, if successful, or 0 otherwise

◆ imquic_payload_parse_new_connection_id()

size_t imquic_payload_parse_new_connection_id ( imquic_connection * conn,
uint8_t * bytes,
size_t blen )

Helper method to process a NEW_CONNECTION_ID frame.

Parameters
connThe imquic_connection that received the message
bytesBuffer containing the frame
blenSize of the buffer containing the frame
Returns
The size of the frame, if successful, or 0 otherwise

◆ imquic_payload_parse_new_token()

size_t imquic_payload_parse_new_token ( imquic_connection * conn,
uint8_t * bytes,
size_t blen )

Helper method to process a NEW_TOKEN frame.

Parameters
connThe imquic_connection that received the message
bytesBuffer containing the frame
blenSize of the buffer containing the frame
Returns
The size of the frame, if successful, or 0 otherwise

◆ imquic_payload_parse_path_challenge()

size_t imquic_payload_parse_path_challenge ( imquic_connection * conn,
uint8_t * bytes,
size_t blen )

Helper method to process a PATH_CHALLENGE frame.

Parameters
connThe imquic_connection that received the message
bytesBuffer containing the frame
blenSize of the buffer containing the frame
Returns
The size of the frame, if successful, or 0 otherwise

◆ imquic_payload_parse_path_response()

size_t imquic_payload_parse_path_response ( imquic_connection * conn,
uint8_t * bytes,
size_t blen )

Helper method to process a PATH_RESPONSE frame.

Parameters
connThe imquic_connection that received the message
bytesBuffer containing the frame
blenSize of the buffer containing the frame
Returns
The size of the frame, if successful, or 0 otherwise

◆ imquic_payload_parse_reset_stream()

size_t imquic_payload_parse_reset_stream ( imquic_connection * conn,
uint8_t * bytes,
size_t blen )

Helper method to process a RESET_STREAM frame.

Parameters
connThe imquic_connection that received the message
bytesBuffer containing the frame
blenSize of the buffer containing the frame
Returns
The size of the frame, if successful, or 0 otherwise

◆ imquic_payload_parse_retire_connection_id()

size_t imquic_payload_parse_retire_connection_id ( imquic_connection * conn,
uint8_t * bytes,
size_t blen )

Helper method to process a RETIRE_CONNECTION_ID frame.

Parameters
connThe imquic_connection that received the message
bytesBuffer containing the frame
blenSize of the buffer containing the frame
Returns
The size of the frame, if successful, or 0 otherwise

◆ imquic_payload_parse_stop_sending()

size_t imquic_payload_parse_stop_sending ( imquic_connection * conn,
uint8_t * bytes,
size_t blen )

Helper method to process a STOP_SENDING frame.

Parameters
connThe imquic_connection that received the message
bytesBuffer containing the frame
blenSize of the buffer containing the frame
Returns
The size of the frame, if successful, or 0 otherwise

◆ imquic_payload_parse_stream()

size_t imquic_payload_parse_stream ( imquic_connection * conn,
uint8_t * bytes,
size_t blen )

Helper method to process a STREAM frame, and handle it accordingly, e.g., by creating the stream locally (if previously unknown), update the associated buffer with the new data, update the state of the stream, and notify the stack using internal callbacks.

Parameters
connThe imquic_connection that received the message
bytesBuffer containing the frame
blenSize of the buffer containing the frame
Returns
The size of the frame, if successful, or 0 otherwise

◆ imquic_payload_parse_stream_data_blocked()

size_t imquic_payload_parse_stream_data_blocked ( imquic_connection * conn,
uint8_t * bytes,
size_t blen )

Helper method to process a STREAM_DATA_BLOCKED frame.

Parameters
connThe imquic_connection that received the message
bytesBuffer containing the frame
blenSize of the buffer containing the frame
Returns
The size of the frame, if successful, or 0 otherwise

◆ imquic_payload_parse_streams_blocked()

size_t imquic_payload_parse_streams_blocked ( imquic_connection * conn,
uint8_t * bytes,
size_t blen )

Helper method to process a STREAMS_BLOCKED frame.

Parameters
connThe imquic_connection that received the message
bytesBuffer containing the frame
blenSize of the buffer containing the frame
Returns
The size of the frame, if successful, or 0 otherwise

◆ imquic_process_message()

void imquic_process_message ( imquic_network_endpoint * socket,
imquic_network_address * sender,
uint8_t * quic,
size_t bytes )

Process incoming data from the network we've made aware of.

Note
A client or server endpoint will receive data regularly: it's this function's responsability to traverse the buffers that are received, to parse one or more messages that may be in a UDP message using potentially multiple calls to imquic_parse_packet.
Parameters
[in]socketThe endpoint that received the data
[in]senderThe network address of who sent this data
[in]quicThe buffer containing the data
[in]bytesSize of the buffer containing the data

◆ imquic_quic_connection_add()

void imquic_quic_connection_add ( imquic_connection * conn,
imquic_connection_id * cid )

Track a Connection ID and map it to a connection.

Note
This will add a reference to the connections
Parameters
connThe imquic_connection instance the ID is associated with
cidThe imquic_connection_id Connection ID instance

◆ imquic_quic_connection_remove()

void imquic_quic_connection_remove ( imquic_connection_id * cid)

Stop tracking a Connection ID associated to a connection.

Note
This will unref the connection, if a mapping exists
Parameters
cidThe imquic_connection_id Connection ID instance

◆ imquic_quic_deinit()

void imquic_quic_deinit ( void )

Uninitialize the QUIC stack.

◆ imquic_quic_init()

void imquic_quic_init ( void )

Initialize the QUIC stack at startup.

◆ imquic_retransmit_packet()

int imquic_retransmit_packet ( imquic_connection * conn,
imquic_sent_packet * sent_pkt )

Retransmit a previously sent packet.

Parameters
connThe imquic_connection to retransmit the message on
sent_pktThe imquic_sent_packet containing the packet to retransmit
Returns
0 in case of success, or a negative integer otherwise

◆ imquic_send_ack()

int imquic_send_ack ( imquic_connection * conn,
enum ssl_encryption_level_t level,
imquic_connection_id * src,
imquic_connection_id * dest )

Helper method to generate a packet containing an ACK and send it.

Note
This may include a few other frames too, in case the stack thinks they're needed
Parameters
connThe imquic_connection to send the message on
levelThe encryption level at which the message should be sent
srcThe source Connection ID, if any
destThe destinatiob Connection ID, if any
Returns
0 in case of success, or a negative integer otherwise

◆ imquic_send_close_connection()

int imquic_send_close_connection ( imquic_connection * conn,
imquic_error_code error_code,
imquic_frame_type frame_type,
const char * reason )

Helper method to generate a packet containing a CONNECTION_CLOSE and send it.

Note
This may include a few other frames too, in case the stack thinks they're neede
Parameters
connThe imquic_connection to send the message on
error_codeError code to report in the frame
frame_typeThe frame type that caused the connection to be closed
reasonA verbose description of the error, if any
Returns
0 in case of success, or a negative integer otherwise

◆ imquic_send_keepalive()

int imquic_send_keepalive ( imquic_connection * conn,
imquic_connection_id * dest )

Helper method to generate a packet containing a PING and send it.

Note
This may include a few other frames too, in case the stack thinks they're neede
Parameters
connThe imquic_connection to send the message on
destThe destinatiob Connection ID, if any
Returns
0 in case of success, or a negative integer otherwise

◆ imquic_send_packet()

int imquic_send_packet ( imquic_connection * conn,
imquic_packet * pkt )

Send a QUIC packet to the peer.

Note
The imquic_packet instance should not be accessed after this call, as it will either be freed (not needed anymore), or stored in a map in case we need to retransmit it later if ACKs tell us to
Parameters
connThe imquic_connection to send the message on
pktThe imquic_packet containing the packet to send
Returns
0 in case of success, or a negative integer otherwise

◆ imquic_send_pending_crypto()

int imquic_send_pending_crypto ( imquic_connection * conn,
imquic_connection_id * src,
imquic_connection_id * dest )

Helper method to generate one or more packets containing one or more CRYPTO frames and send them.

Note
This may include a few other frames too, in case the stack thinks they're needed
Parameters
connThe imquic_connection to send the message(s) on
srcThe source Connection ID, if any
destThe destinatiob Connection ID, if any
Returns
0 in case of success, or a negative integer otherwise

◆ imquic_send_pending_datagram()

int imquic_send_pending_datagram ( imquic_connection * conn,
imquic_connection_id * dest )

Helper method to generate one or more packets containing one or more DATAGRAM frames and send them.

Note
This may include a few other frames too, in case the stack thinks they're neede
Parameters
connThe imquic_connection to send the message(s) on
destThe destinatiob Connection ID, if any
Returns
0 in case of success, or a negative integer otherwise

◆ imquic_send_pending_stream()

int imquic_send_pending_stream ( imquic_connection * conn,
imquic_connection_id * dest )

Helper method to generate one or more packets containing one or more STREAM frames and send them.

Note
This may include a few other frames too, in case the stack thinks they're neede
Parameters
connThe imquic_connection to send the message(s) on
destThe destinatiob Connection ID, if any
Returns
0 in case of success, or a negative integer otherwise

◆ imquic_sent_packet_destroy()

void imquic_sent_packet_destroy ( imquic_sent_packet * sent_pkt)

Helper method to destroy an existing imquic_sent_packet instance.

Parameters
sent_pktThe imquic_sent_packet instance to destroy

◆ imquic_serialize_packet()

int imquic_serialize_packet ( imquic_connection * conn,
imquic_packet * pkt )

Serialize an imquic packet object to a QUIC packet ready to be sent, taking care of header protection and encryption as well.

Parameters
connThe imquic_connection to serialize the packet for
pktThe imquic_packet containing the packet to serialize
Returns
0 in case of success, or a negative integer otherwise

◆ imquic_start_quic_client()

int imquic_start_quic_client ( imquic_network_endpoint * socket)

Helper to start a new client endpoint, and so attempt a connection.

Note
This is not a blocking method: it will only kickstart the connection process, but it will not wait for it to succeed or fail. There will be asynchronous callbacks fired to handle those events instead.
Parameters
socketThe network endpoint to start the connection from
Returns
0 in case of success, a negative integer otherwise

◆ imquic_transport_parameter_add_connection_id()

size_t imquic_transport_parameter_add_connection_id ( uint8_t * bytes,
size_t blen,
imquic_transport_parameter param,
imquic_connection_id * cid )

Helper to add a QUIC transport parameter with a Connection ID to a buffer.

Parameters
bytesBuffer to add the transport parameter to
blenSize of the buffer
paramID of the parameter to add
cidThe Connection ID value of the parameter to add
Returns
The size of the parameter, if successful, or 0 otherwise

◆ imquic_transport_parameter_add_data()

size_t imquic_transport_parameter_add_data ( uint8_t * bytes,
size_t blen,
imquic_transport_parameter param,
uint8_t * buf,
size_t buflen )

Helper to add a QUIC transport parameter with generic data to a buffer.

Parameters
bytesBuffer to add the transport parameter to
blenSize of the buffer
paramID of the parameter to add
bufThe data acting as a value for the parameter to add
buflenThe size of the data value
Returns
The size of the parameter, if successful, or 0 otherwise

◆ imquic_transport_parameter_add_int()

size_t imquic_transport_parameter_add_int ( uint8_t * bytes,
size_t blen,
imquic_transport_parameter param,
uint64_t number )

Helper to add a QUIC transport parameter with a numeric value to a buffer.

Parameters
bytesBuffer to add the transport parameter to
blenSize of the buffer
paramID of the parameter to add
numberThe numeric value of the parameter to add
Returns
The size of the parameter, if successful, or 0 otherwise

◆ imquic_transport_parameter_add_novalue()

size_t imquic_transport_parameter_add_novalue ( uint8_t * bytes,
size_t blen,
imquic_transport_parameter param )

Helper to add a QUIC transport parameter with no value to a buffer.

Parameters
bytesBuffer to add the transport parameter to
blenSize of the buffer
paramID of the parameter to add
Returns
The size of the parameter, if successful, or 0 otherwise

◆ imquic_transport_parameter_str()

const char * imquic_transport_parameter_str ( imquic_transport_parameter param)

Helper function to serialize to string the name of a imquic_transport_parameter value.

Parameters
paramThe imquic_transport_parameter value
Returns
The param name as a string, if valid, or NULL otherwise