QUIC stack implementation (headers) More...
#include <sys/socket.h>
#include <glib.h>
#include "../imquic/imquic.h"
#include "connection.h"
#include "stream.h"
#include "utils.h"
Go to the source code of this file.
Data Structures | |
struct | imquic_frame |
A serialized QUIC frame. More... | |
struct | imquic_packet |
Abstraction of a QUIC packet. More... | |
struct | imquic_sent_packet |
Info on a sent packet. More... | |
Typedefs | |
typedef enum imquic_long_packet_type | imquic_long_packet_type |
QUIC long packet types. | |
typedef enum imquic_frame_type | imquic_frame_type |
QUIC frame types. | |
typedef struct imquic_frame | imquic_frame |
A serialized QUIC frame. | |
typedef enum imquic_transport_parameter | imquic_transport_parameter |
QUIC transport parameters. | |
typedef struct imquic_packet | imquic_packet |
Abstraction of a QUIC packet. | |
typedef struct imquic_sent_packet | imquic_sent_packet |
Info on a sent packet. | |
Functions | |
void | imquic_quic_init (void) |
Initialize the QUIC stack at startup. | |
void | imquic_quic_deinit (void) |
Uninitialize the QUIC stack. | |
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. | |
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. | |
imquic_frame * | imquic_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. | |
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_packet * | imquic_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. | |
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. | |
Parsing and processing QUIC messages | |
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. | |
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. | |
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. | |
void | imquic_check_incoming_stream (imquic_connection *conn) |
Helper method to check if we received STREAM frames we need to go process, and handle ourselves or pass to the application layer. | |
Parsing QUIC frames | |
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. | |
Adding QUIC frames to a packet | |
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. | |
Adding QUIC transport parameters 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. | |
Parsing QUIC 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. | |
Sending QUIC messages | |
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. | |
QUIC stack implementation (headers)
Implementation of the QUIC stack itself. This is where message parsing and building is implemented, including connection establishment and (mostly) state management.
typedef struct imquic_frame imquic_frame |
A serialized QUIC frame.
typedef enum imquic_frame_type imquic_frame_type |
QUIC frame types.
typedef enum imquic_long_packet_type imquic_long_packet_type |
QUIC long packet types.
typedef struct imquic_packet imquic_packet |
Abstraction of a QUIC packet.
typedef struct imquic_sent_packet imquic_sent_packet |
Info on a sent packet.
typedef enum imquic_transport_parameter imquic_transport_parameter |
QUIC transport parameters.
enum imquic_frame_type |
QUIC frame types.
QUIC transport parameters.
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.
conn | The imquic_connection to check |
void imquic_check_incoming_stream | ( | imquic_connection * | conn | ) |
Helper method to check if we received STREAM
frames we need to go process, and handle ourselves or pass to the application layer.
conn | The imquic_connection to check |
imquic_frame * imquic_frame_create | ( | imquic_frame_type | type, |
uint8_t * | buffer, | ||
size_t | size ) |
Helper method to create a imquic_frame instance.
type | The type of frame |
buffer | The content of the frame |
size | The size of the frame |
void imquic_frame_destroy | ( | imquic_frame * | frame | ) |
Helper method to destroy an existing imquic_frame instance.
frame | The imquic_frame instanceto destroy |
const char * imquic_frame_type_str | ( | imquic_frame_type | type | ) |
Helper function to serialize to string the name of a imquic_frame_type value.
type | The imquic_frame_type value |
gboolean imquic_handle_event | ( | imquic_connection * | conn | ) |
Callback fired when the event loop has an event for a specific connection.
conn | The imquic_connection instance the event is for |
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.
type | The imquic_long_packet_type value |
imquic_packet * imquic_packet_create | ( | void | ) |
Helper method to create a imquic_packet instance.
void imquic_packet_destroy | ( | imquic_packet * | pkt | ) |
Helper method to destroy an existing imquic_packet instance.
pkt | The imquic_packet instance to destroy |
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.
pkt | The imquic_packet instance to initialize |
type | The imquic_long_packet_type type of long header packet (e.g., Initial) |
src | The Source Connection ID to put in the packet, if any |
dest | The Destination Connection ID to put in the packet, if any |
int imquic_packet_short_init | ( | imquic_packet * | pkt, |
imquic_connection_id * | dest ) |
Initialize a imquic_packet instance as a short header packet.
pkt | The imquic_packet instance to initialize |
dest | The Destination Connection ID to put in the packet, if any |
int imquic_parse_frames | ( | imquic_connection * | conn, |
imquic_packet * | pkt ) |
Parse QUIC frames in a QUIC message payload.
conn | The imquic_connection that received the message |
pkt | The imquic_packet containing the payload to process returns 0 in case of success, a negative integer otherwise |
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.
[in] | socket | The endpoint that received the QUIC packet |
[in] | sender | The network address of who sent this packet |
[out] | pconn | After parsing the packet, this will be filled with the imquic_connection associated with it |
[out] | pkt | The imquic_packet instance to write the result of the parsing to |
[in] | quic | The buffer containing the QUIC packet |
[in] | bytes | Size of the buffer containing the QUIC packet |
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.
conn | The imquic_connection instance to update with the peer parameters |
bytes | The buffer containing the QUIC transport parameters |
blen | The size of the buffer to parse |
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.
bytes | Buffer to add the frame to |
blen | Size of the buffer |
received | The list of packets we did receive |
delay | The value to put in the delay part of the frame |
ecn_counts | Array of three ECN-related properties to put in the frame, if any |
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.
bytes | Buffer to add the frame to |
blen | Size of the buffer |
error_code | Error code to report in the frame |
frame_type | The frame type that caused the connection to be closed |
reason | A verbose description of the error, if any |
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.
bytes | Buffer to add the frame to |
blen | Size of the buffer |
crypto | Buffer containing the TLS data to send |
crypto_offset | Offset this TLS data is at, relatively to the whole CRYPTO exchange |
crypto_length | Size of the TLS data 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.
bytes | Buffer to add the frame to |
blen | Size of the buffer |
max_data | The limit at which the blocking occurred |
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.
bytes | Buffer to add the frame to |
blen | Size of the buffer |
datagram | Buffer containing the datagram data to send |
datagram_length | Size of the datagram data buffer |
last | Whether this is the last frame in the packet, and so we can omit the Length field |
size_t imquic_payload_add_handshake_done | ( | uint8_t * | bytes, |
size_t | blen ) |
Helper method to add a HANDSHAKE_DONE
frame to a buffer.
bytes | Buffer to add the frame to |
blen | Size of the 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.
bytes | Buffer to add the frame to |
blen | Size of the buffer |
max_data | The new value to report |
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.
bytes | Buffer to add the frame to |
blen | Size of the buffer |
stream_id | ID of the stream this new limit applies to |
max_data | The new value to report |
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.
bytes | Buffer to add the frame to |
blen | Size of the buffer |
bidirectional | Whether this impacts bidirectional or unidirectional streams |
max_streams | The new value to report |
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.
bytes | Buffer to add the frame to |
blen | Size of the buffer |
seqnum | Sequence number of the Connection ID |
retire_prior_to | Connection IDs that should be retired |
cid | The Connection ID value |
reset_token | Stateless reset 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.
bytes | Buffer to add the frame to |
blen | Size of the buffer |
token | Buffer containing the token to add |
token_length | Size of the token buffer |
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.
bytes | Buffer to add the frame to |
blen | Size of the buffer |
padding | How many bytes of padding to add |
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.
bytes | Buffer to add the frame to |
blen | Size of the buffer |
data | Data to send as part of the challenge |
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.
bytes | Buffer to add the frame to |
blen | Size of the buffer |
data | Data to send as part of the response |
size_t imquic_payload_add_ping | ( | uint8_t * | bytes, |
size_t | blen ) |
Helper method to add a PING
frame to a buffer.
bytes | Buffer to add the frame to |
blen | Size of the 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.
bytes | Buffer to add the frame to |
blen | Size of the buffer |
stream_id | ID of the stream to reset |
error_code | Error code to report in the frame |
final_size | Final size to report in the frame |
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.
bytes | Buffer to add the frame to |
blen | Size of the buffer |
seqnum | Sequence number of the Connection ID to retire |
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.
bytes | Buffer to add the frame to |
blen | Size of the buffer |
stream_id | ID of the stream whose sending must stop |
error_code | Error code to report in the frame |
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.
bytes | Buffer to add the frame to |
blen | Size of the buffer |
stream_id | ID of the stream this data belongs to |
stream | Buffer containing the stream data to send |
stream_offset | Offset this stream data is at, relatively to the whole STREAM exchange |
stream_length | Size of the stream data buffer |
complete | Whether this data marks the end of the STREAM in this direction |
last | Whether this is the last frame in the packet, and so we can omit the Length field |
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.
bytes | Buffer to add the frame to |
blen | Size of the buffer |
stream_id | ID of the stream that has been blocked |
max_data | The limit at which the blocking occurred |
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.
bytes | Buffer to add the frame to |
blen | Size of the buffer |
max_streams | The limit at which the blocking occurred |
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.
conn | The imquic_connection that received the message |
bytes | Buffer containing the frame |
blen | Size of the buffer containing the frame |
level | Encryption level of the packet containing this 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.
conn | The imquic_connection that received the message |
bytes | Buffer containing the frame |
blen | Size of the buffer containing the 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.
conn | The imquic_connection that received the message |
bytes | Buffer containing the frame |
blen | Size of the buffer containing the frame |
level | Encryption level of the packet containing this 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.
conn | The imquic_connection that received the message |
bytes | Buffer containing the frame |
blen | Size of the buffer containing the frame |
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.
conn | The imquic_connection that received the message |
bytes | Buffer containing the frame |
blen | Size of the buffer containing the frame |
size_t imquic_payload_parse_max_data | ( | imquic_connection * | conn, |
uint8_t * | bytes, | ||
size_t | blen ) |
Helper method to process a MAX_DATA
frame.
conn | The imquic_connection that received the message |
bytes | Buffer containing the frame |
blen | Size of the buffer containing the 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.
conn | The imquic_connection that received the message |
bytes | Buffer containing the frame |
blen | Size of the buffer containing the 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.
conn | The imquic_connection that received the message |
bytes | Buffer containing the frame |
blen | Size of the buffer containing the 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.
conn | The imquic_connection that received the message |
bytes | Buffer containing the frame |
blen | Size of the buffer containing the frame |
size_t imquic_payload_parse_new_token | ( | imquic_connection * | conn, |
uint8_t * | bytes, | ||
size_t | blen ) |
Helper method to process a NEW_TOKEN
frame.
conn | The imquic_connection that received the message |
bytes | Buffer containing the frame |
blen | Size of the buffer containing the 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.
conn | The imquic_connection that received the message |
bytes | Buffer containing the frame |
blen | Size of the buffer containing the 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.
conn | The imquic_connection that received the message |
bytes | Buffer containing the frame |
blen | Size of the buffer containing the 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.
conn | The imquic_connection that received the message |
bytes | Buffer containing the frame |
blen | Size of the buffer containing the 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.
conn | The imquic_connection that received the message |
bytes | Buffer containing the frame |
blen | Size of the buffer containing the 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.
conn | The imquic_connection that received the message |
bytes | Buffer containing the frame |
blen | Size of the buffer containing the 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.
conn | The imquic_connection that received the message |
bytes | Buffer containing the frame |
blen | Size of the buffer containing the 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.
conn | The imquic_connection that received the message |
bytes | Buffer containing the frame |
blen | Size of the buffer containing the 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.
conn | The imquic_connection that received the message |
bytes | Buffer containing the frame |
blen | Size of the buffer containing the frame |
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.
[in] | socket | The endpoint that received the data |
[in] | sender | The network address of who sent this data |
[in] | quic | The buffer containing the data |
[in] | bytes | Size of the buffer containing the data |
void imquic_quic_connection_add | ( | imquic_connection * | conn, |
imquic_connection_id * | cid ) |
Track a Connection ID and map it to a connection.
conn | The imquic_connection instance the ID is associated with |
cid | The imquic_connection_id Connection ID instance |
void imquic_quic_connection_remove | ( | imquic_connection_id * | cid | ) |
Stop tracking a Connection ID associated to a connection.
cid | The imquic_connection_id Connection ID instance |
void imquic_quic_deinit | ( | void | ) |
Uninitialize the QUIC stack.
void imquic_quic_init | ( | void | ) |
Initialize the QUIC stack at startup.
int imquic_retransmit_packet | ( | imquic_connection * | conn, |
imquic_sent_packet * | sent_pkt ) |
Retransmit a previously sent packet.
conn | The imquic_connection to retransmit the message on |
sent_pkt | The imquic_sent_packet containing the packet to retransmit |
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.
conn | The imquic_connection to send the message on |
level | The encryption level at which the message should be sent |
src | The source Connection ID, if any |
dest | The destinatiob Connection ID, if any |
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.
conn | The imquic_connection to send the message on |
error_code | Error code to report in the frame |
frame_type | The frame type that caused the connection to be closed |
reason | A verbose description of the error, if any |
int imquic_send_keepalive | ( | imquic_connection * | conn, |
imquic_connection_id * | dest ) |
Helper method to generate a packet containing a PING
and send it.
conn | The imquic_connection to send the message on |
dest | The destinatiob Connection ID, if any |
int imquic_send_packet | ( | imquic_connection * | conn, |
imquic_packet * | pkt ) |
Send a QUIC packet to the peer.
conn | The imquic_connection to send the message on |
pkt | The imquic_packet containing the packet to send |
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.
conn | The imquic_connection to send the message(s) on |
src | The source Connection ID, if any |
dest | The destinatiob Connection ID, if any |
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.
conn | The imquic_connection to send the message(s) on |
dest | The destinatiob Connection ID, if any |
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.
conn | The imquic_connection to send the message(s) on |
dest | The destinatiob Connection ID, if any |
void imquic_sent_packet_destroy | ( | imquic_sent_packet * | sent_pkt | ) |
Helper method to destroy an existing imquic_sent_packet instance.
sent_pkt | The imquic_sent_packet instance to destroy |
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.
conn | The imquic_connection to serialize the packet for |
pkt | The imquic_packet containing the packet to serialize |
int imquic_start_quic_client | ( | imquic_network_endpoint * | socket | ) |
Helper to start a new client endpoint, and so attempt a connection.
socket | The network endpoint to start the connection from |
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.
bytes | Buffer to add the transport parameter to |
blen | Size of the buffer |
param | ID of the parameter to add |
cid | The Connection ID value of the parameter to add |
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.
bytes | Buffer to add the transport parameter to |
blen | Size of the buffer |
param | ID of the parameter to add |
buf | The data acting as a value for the parameter to add |
buflen | The size of the data value |
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.
bytes | Buffer to add the transport parameter to |
blen | Size of the buffer |
param | ID of the parameter to add |
number | The numeric value of the parameter to add |
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.
bytes | Buffer to add the transport parameter to |
blen | Size of the buffer |
param | ID of the parameter to add |
const char * imquic_transport_parameter_str | ( | imquic_transport_parameter | param | ) |
Helper function to serialize to string the name of a imquic_transport_parameter value.
param | The imquic_transport_parameter value |