Zephyr API 4.4.99
A Scalable Open Source RTOS
Loading...
Searching...
No Matches

QUIC library . More...

Data Structures

struct  net_stats_quic
 Quic statistics. More...
 
struct  net_stats_quic_global
 Quic global statistics. More...
 
struct  quic_session_transport_params
 Remembered peer transport parameters for resumption. More...
 
struct  quic_session_state
 Resumable QUIC client session state. More...
 

Macros

#define ZSOCK_SOL_QUIC   284
 QUIC socket option level for getsockopt/setsockopt.
 
#define QUIC_SESSION_STATE_VERSION   2U
 Version of struct quic_session_state.
 
#define QUIC_MAX_SESSION_TICKET_LEN   256U
 Maximum serialized ticket length exported through struct quic_session_state.
 
#define QUIC_MAX_RESUMPTION_PSK_LEN   48U
 Maximum resumable PSK length exported through struct quic_session_state.
 

Enumerations

enum  quic_stream_direction { QUIC_STREAM_BIDIRECTIONAL = 0x00 , QUIC_STREAM_UNIDIRECTIONAL = 0x02 }
 Stream direction. More...
 
enum  quic_stream_initiator { QUIC_STREAM_CLIENT = 0x00 , QUIC_STREAM_SERVER = 0x01 }
 Stream initiator. More...
 
enum  {
  ZSOCK_QUIC_SO_STREAM_TYPE = 1 , ZSOCK_QUIC_SO_CERT_CHAIN_ADD = 2 , ZSOCK_QUIC_SO_CERT_CHAIN_DEL = 3 , ZSOCK_QUIC_SO_STOP_SENDING_CODE = 4 ,
  ZSOCK_QUIC_SO_SESSION_STATE = 5 , ZSOCK_QUIC_SO_SESSION_TICKET_ENABLE = 6 , ZSOCK_QUIC_SO_MAX_EARLY_DATA_SIZE = 7 , ZSOCK_QUIC_SO_STREAM_EARLY_DATA = 8
}
 QUIC socket options for use with getsockopt/setsockopt at ZSOCK_SOL_QUIC level. More...
 

Functions

int quic_connection_open (const struct net_sockaddr *remote_addr, const struct net_sockaddr *local_addr)
 Creates a new QUIC connection socket.
 
int quic_connection_close (int sock)
 Closes the QUIC socket.
 
int quic_stream_open (int connection_sock, enum quic_stream_initiator initiator, enum quic_stream_direction direction, uint8_t priority)
 Creates a new QUIC stream socket within an established QUIC connection.
 
int quic_stream_close (int sock)
 Closes the QUIC stream socket.
 
bool quic_is_stream_socket (int sock)
 Checks if the given socket is a QUIC stream socket.
 
bool quic_is_connection_socket (int sock)
 Checks if the given socket is a QUIC connection socket.
 
int quic_stream_get_id (int sock, uint64_t *stream_id)
 Return the stream id associated with the given QUIC stream socket.
 

Detailed Description

QUIC library .

Since
4.5
Version
0.1.0
Note
Server mode sends Version Negotiation for unsupported versions and can enforce the RFC 9000 anti-amplification limit before peer address validation, including Retry and NEW_TOKEN-based address-validation tokens.

Macro Definition Documentation

◆ QUIC_MAX_RESUMPTION_PSK_LEN

#define QUIC_MAX_RESUMPTION_PSK_LEN   48U

#include <zephyr/net/quic.h>

Maximum resumable PSK length exported through struct quic_session_state.

◆ QUIC_MAX_SESSION_TICKET_LEN

#define QUIC_MAX_SESSION_TICKET_LEN   256U

#include <zephyr/net/quic.h>

Maximum serialized ticket length exported through struct quic_session_state.

◆ QUIC_SESSION_STATE_VERSION

#define QUIC_SESSION_STATE_VERSION   2U

#include <zephyr/net/quic.h>

Version of struct quic_session_state.

◆ ZSOCK_SOL_QUIC

#define ZSOCK_SOL_QUIC   284

#include <zephyr/net/quic.h>

QUIC socket option level for getsockopt/setsockopt.

Enumeration Type Documentation

◆ anonymous enum

anonymous enum

#include <zephyr/net/quic.h>

QUIC socket options for use with getsockopt/setsockopt at ZSOCK_SOL_QUIC level.

Enumerator
ZSOCK_QUIC_SO_STREAM_TYPE 

Get stream type (returns combination of direction | initiator bits)

ZSOCK_QUIC_SO_CERT_CHAIN_ADD 

Add an intermediate certificate to the certificate chain.

Option value is a pointer to a sec_tag_t referencing a credential previously registered via tls_credential_add() (with type TLS_CREDENTIAL_CA_CERTIFICATE or TLS_CREDENTIAL_PUBLIC_CERTIFICATE). Option length must be sizeof(sec_tag_t). Call multiple times to add multiple intermediate certificates.

ZSOCK_QUIC_SO_CERT_CHAIN_DEL 

Delete an intermediate certificate from the certificate chain.

Option value is a pointer to a sec_tag_t referencing a credential previously added by ZSOCK_QUIC_SO_CERT_CHAIN_ADD option. Option length must be sizeof(sec_tag_t) or set to 0. If set to 0, the option value can be omitted by setting it to NULL. If set to 0, all intermediate certificates are removed.

ZSOCK_QUIC_SO_STOP_SENDING_CODE 

Set the error code to use when sending STOP_SENDING frame on stream close.

ZSOCK_QUIC_SO_SESSION_STATE 

Export or import resumable client session state.

The option value is a pointer to struct quic_session_state. Use getsockopt() on a connected client connection socket after a NewSessionTicket has been received, then pass the returned state to setsockopt() on a new client connection socket before opening the first stream to attempt session resumption and, when permitted, 0-RTT. Since 0-RTT data can be replayed or rejected by the peer, applications must only send replay-safe early data and be prepared to retry after the handshake completes. When CONFIG_QUIC_0RTT is disabled, imported session state still resumes at 1-RTT but does not arm early data.

ZSOCK_QUIC_SO_SESSION_TICKET_ENABLE 

Enable or disable server-side session ticket issuance.

The option value is a pointer to an int. Set a non-zero value on a listening or server-side connection socket before the handshake to have the server send NewSessionTicket after the handshake completes.

ZSOCK_QUIC_SO_MAX_EARLY_DATA_SIZE 

Enable 0-RTT early data on tickets this server issues.

The option value is a pointer to a uint32_t. Set it on a listening or server-side connection socket before the handshake. A value of 0 keeps 0-RTT disabled for newly issued tickets; any non-zero value enables it. Per RFC 9001 4.6.1 the ticket always advertises the fixed 0xffffffff sentinel and the amount of early data a resuming client may send is bounded by the connection's flow-control (transport-parameter) limits, not by this value; the option is therefore only an enable switch, not a byte cap. This only affects newly issued tickets; applications must still treat accepted early data as replayable at the protocol level. Non-zero values require CONFIG_QUIC_0RTT; otherwise setsockopt() fails with ENOTSUP.

ZSOCK_QUIC_SO_STREAM_EARLY_DATA 

Query whether a QUIC stream has received accepted 0-RTT data.

The option value is a pointer to an int and is only valid on QUIC stream sockets. A non-zero result means the receive side of that stream has already carried accepted early data on this connection.

◆ quic_stream_direction

#include <zephyr/net/quic.h>

Stream direction.

Enumerator
QUIC_STREAM_BIDIRECTIONAL 

Bidirectional stream.

QUIC_STREAM_UNIDIRECTIONAL 

Unidirectional stream.

◆ quic_stream_initiator

#include <zephyr/net/quic.h>

Stream initiator.

Enumerator
QUIC_STREAM_CLIENT 

Client initiated stream.

QUIC_STREAM_SERVER 

Server initiated stream.

Function Documentation

◆ quic_connection_close()

int quic_connection_close ( int sock)

#include <zephyr/net/quic.h>

Closes the QUIC socket.

Closes the connection and terminates the TLS session. Does the same thing as zsock_close for a connection socket.

Parameters
sockQUIC connection socket to close.
Returns
0 success, <0 on failure.

◆ quic_connection_open()

int quic_connection_open ( const struct net_sockaddr * remote_addr,
const struct net_sockaddr * local_addr )

#include <zephyr/net/quic.h>

Creates a new QUIC connection socket.

Creates a new QUIC connection context. This serves as a foundation for all subsequent communication.

Parameters
remote_addrRemote connection endpoint address. In client mode, this is the server address to connect to. In server mode, this is NULL or unspecified if binding a listener.
local_addrLocal connection endpoint address. In client mode, if set to NULL, the system will auto-bind the socket to an ephemeral port and select the local address. In server mode, this is the address to listen on.
Returns
New QUIC connection socket on success, <0 on failure.

◆ quic_is_connection_socket()

bool quic_is_connection_socket ( int sock)

#include <zephyr/net/quic.h>

Checks if the given socket is a QUIC connection socket.

Parameters
sockSocket to check.
Returns
true if the socket is a QUIC connection socket, false otherwise.

◆ quic_is_stream_socket()

bool quic_is_stream_socket ( int sock)

#include <zephyr/net/quic.h>

Checks if the given socket is a QUIC stream socket.

Parameters
sockSocket to check.
Returns
true if the socket is a QUIC stream socket, false otherwise.

◆ quic_stream_close()

int quic_stream_close ( int sock)

#include <zephyr/net/quic.h>

Closes the QUIC stream socket.

Parameters
sockQUIC stream socket to close.

Closes a specific stream without closing the underlying connection. Does the same thing as zsock_close for a stream socket.

Returns
0 success, <0 on failure.

◆ quic_stream_get_id()

int quic_stream_get_id ( int sock,
uint64_t * stream_id )

#include <zephyr/net/quic.h>

Return the stream id associated with the given QUIC stream socket.

Parameters
sockSocket to check.
stream_idPointer to store the stream id.
Returns
0 on success, <0 on failure.

◆ quic_stream_open()

int quic_stream_open ( int connection_sock,
enum quic_stream_initiator initiator,
enum quic_stream_direction direction,
uint8_t priority )

#include <zephyr/net/quic.h>

Creates a new QUIC stream socket within an established QUIC connection.

Parameters
connection_sockConnection to create the stream on. This is the socket id returned by quic_connection_open().
initiatorStream initiator (client or server). This is either QUIC_STREAM_CLIENT or QUIC_STREAM_SERVER.
directionStream direction (uni- or bidirectional). If set to QUIC_STREAM_BIDIRECTIONAL, then both sides can read/write. If set to QUIC_STREAM_UNIDIRECTIONAL, then only the initiator can write.
priorityPriority level (0-255) for scheduling stream data.
Returns
New QUIC stream socket on success, <0 on failure.