nquic_packet_io (nquic v1.0.0)

View Source

Packet construction, encryption, and sending for QUIC connections.

This module handles the common logic for building and sending QUIC packets across all packet types (Initial, Handshake, 1-RTT).

Summary

Functions

Send a 1-RTT packet with the specified frame.

Send a CONNECTION_CLOSE frame.

Send a Handshake packet with the specified frames.

Send an Initial packet with the specified frames.

Functions

find_highest_key_level(Keys)

-spec find_highest_key_level(map()) -> application | handshake | initial.

hp_sample/3

-spec hp_sample(binary(), binary(), non_neg_integer()) -> binary().

send_app_packet/5

-spec send_app_packet(nquic_socket:t(),
                      nquic_socket:sockaddr(),
                      nquic:connection_id(),
                      #{key := binary(), iv := binary(), hp := binary(), atom() => term()},
                      {nquic_packet_number:t(), nquic_frame:t()}) ->
                         {ok, iodata(), non_neg_integer()} | {error, term()}.

Send a 1-RTT packet with the specified frame.

send_close_frame(Socket, Peer, Params)

-spec send_close_frame(nquic_socket:t(),
                       nquic_socket:sockaddr(),
                       #{dcid := nquic:connection_id(),
                         scid := nquic:connection_id(),
                         keys := map(),
                         pn_spaces := map(),
                         role := client | server,
                         frame :=
                             #connection_close{error_code :: non_neg_integer(),
                                               frame_type :: non_neg_integer(),
                                               reason_phrase :: binary(),
                                               is_application :: boolean()}}) ->
                          ok | {error, term()}.

Send a CONNECTION_CLOSE frame.

send_handshake_packet(Socket, Peer, DCID, SCID, Keys, PNFrames)

-spec send_handshake_packet(nquic_socket:t(),
                            nquic_socket:sockaddr(),
                            nquic:connection_id(),
                            nquic:connection_id(),
                            #{key := binary(), iv := binary(), hp := binary(), atom() => term()},
                            {nquic_packet_number:t(), [nquic_frame:t()]}) ->
                               {ok, iodata(), non_neg_integer()} | {error, term()}.

Send a Handshake packet with the specified frames.

send_handshake_packet/7

-spec send_handshake_packet(nquic_socket:t(),
                            nquic_socket:sockaddr(),
                            nquic:connection_id(),
                            nquic:connection_id(),
                            #{key := binary(), iv := binary(), hp := binary(), atom() => term()},
                            {nquic_packet_number:t(), [nquic_frame:t()]},
                            non_neg_integer()) ->
                               {ok, iodata(), non_neg_integer()} | {error, term()}.

send_initial_packet(Socket, Peer, DCID, SCID, Keys, PNFrames)

-spec send_initial_packet(nquic_socket:t(),
                          nquic_socket:sockaddr(),
                          nquic:connection_id(),
                          nquic:connection_id(),
                          #{key := binary(), iv := binary(), hp := binary(), atom() => term()},
                          {nquic_packet_number:t(), [nquic_frame:t()]}) ->
                             {ok, iodata(), non_neg_integer()} | {error, term()}.

Send an Initial packet with the specified frames.

send_initial_packet/7

-spec send_initial_packet(nquic_socket:t(),
                          nquic_socket:sockaddr(),
                          nquic:connection_id(),
                          nquic:connection_id(),
                          #{key := binary(), iv := binary(), hp := binary(), atom() => term()},
                          {nquic_packet_number:t(), [nquic_frame:t()]},
                          non_neg_integer()) ->
                             {ok, iodata(), non_neg_integer()} | {error, term()}.