Quic.HandshakeScheduler (elixir_quic v0.16.7)

Copy Markdown View Source

Deterministic handshake packet scheduler.

This module is deliberately socket-free. TLS emissions become retained CRYPTO ranges and protected send effects; local send receipts and peer ACKs are applied separately through Quic.Recovery.

Summary

Functions

Confirm QUIC and retire Handshake after role-specific confirmation.

Consume queued stream events for a manual-delivery stream policy.

Effective frame ceiling after peer negotiation and worst-case packet overhead.

Fold TLS driver effects returned from a CRYPTO receive into the scheduler.

Send HANDSHAKE_DONE after the server completes its TLS handshake.

Install the semantic values of authenticated, validated peer parameters.

Apply a local writer result; this is distinct from packet admission.

Open a locally initiated stream without creating a process per stream.

Queue an ACK frame for the next packet in a packet-number space.

Queue reliable control information, coalescing monotonic credit updates.

Apply an authenticated peer ACK to Recovery.

Process bounded coalesced packets in order, preserving an accepted prefix.

Alias for callers that process one packet rather than a datagram batch.

Reset only the local send direction and discard its pending data ranges.

Drop the QUIC keys, retained packets and CRYPTO storage for an obsolete level.

Whether the packet-number space is permanently retired.

Return the exact retained datagram for retransmission.

Repacketize retained CRYPTO under a fresh packet number without calling TLS.

Schedule all currently pending emissions and queued ACKs.

Admit one unreliable application DATAGRAM frame; loss never requeues it.

Admit one application stream frame into the bounded scheduler queue.

Request cancellation of the receive direction, preserving the send half.

Types

t()

@type t() :: %Quic.HandshakeScheduler{
  acked_stream_fins: term(),
  acked_stream_ranges: term(),
  dcid: term(),
  effects: term(),
  key_update: term(),
  keys: term(),
  local_max_datagram_frame_size: term(),
  max_packet_size: term(),
  max_queue: term(),
  max_queue_bytes: term(),
  min_initial_size: term(),
  original_dcid: term(),
  peer_cids: term(),
  peer_idle_timeout: term(),
  peer_initial_scid: term(),
  peer_max_datagram_frame_size: term(),
  pending: term(),
  pending_acks: term(),
  pending_control: term(),
  queued: term(),
  queued_bytes: term(),
  read_keys: term(),
  recovery: term(),
  retry_scid: term(),
  retry_token: term(),
  role: term(),
  scid: term(),
  streams: term(),
  tls: term()
}

Functions

confirm_handshake(state)

@spec confirm_handshake(t()) :: t()

Confirm QUIC and retire Handshake after role-specific confirmation.

consume_stream(state, id, max_bytes)

Consume queued stream events for a manual-delivery stream policy.

effective_datagram_frame_size(state)

Effective frame ceiling after peer negotiation and worst-case packet overhead.

feed(state, level, offset, bytes)

@spec feed(t(), atom(), non_neg_integer(), binary()) ::
  {:ok, t(), list()} | {:error, term(), t(), list()}

Fold TLS driver effects returned from a CRYPTO receive into the scheduler.

handshake_done(state)

Send HANDSHAKE_DONE after the server completes its TLS handshake.

install_peer_parameters(state, values)

Install the semantic values of authenticated, validated peer parameters.

local_send(state, space, number, result, at)

Apply a local writer result; this is distinct from packet admission.

new(role, opts \\ [])

@spec new(:client | :server, keyword()) ::
  {:ok, t(), list()} | {:error, term()} | {:error, term(), t()}

open_stream(state, kind)

@spec open_stream(t(), :bidi | :uni) ::
  {:ok, t(), non_neg_integer()} | {:blocked, map()} | {:error, term()}

Open a locally initiated stream without creating a process per stream.

queue_ack(state, space, ack)

Queue an ACK frame for the next packet in a packet-number space.

queue_control(state, level, frames)

Queue reliable control information, coalescing monotonic credit updates.

receive_ack(state, space, ack, at)

Apply an authenticated peer ACK to Recovery.

receive_datagram(state, datagram, at \\ 0)

@spec receive_datagram(t(), binary(), integer()) ::
  {:ok, t(), [map()]} | {:error, term(), t()}

Process bounded coalesced packets in order, preserving an accepted prefix.

receive_packet(state, packet, at \\ 0)

Alias for callers that process one packet rather than a datagram batch.

reset_stream(state, id, code)

Reset only the local send direction and discard its pending data ranges.

retire_level(state, level)

@spec retire_level(t(), :initial | :handshake) :: t()

Drop the QUIC keys, retained packets and CRYPTO storage for an obsolete level.

retired?(state, level)

@spec retired?(t(), :initial | :handshake | :application) :: boolean()

Whether the packet-number space is permanently retired.

retransmit(state, space, number)

Return the exact retained datagram for retransmission.

retry_crypto(state, space, number)

Repacketize retained CRYPTO under a fresh packet number without calling TLS.

schedule(state)

@spec schedule(t()) :: {:ok, t(), list()} | {:error, term(), t()}

Schedule all currently pending emissions and queued ACKs.

send_datagram(state, data)

Admit one unreliable application DATAGRAM frame; loss never requeues it.

send_stream(state, id, data, fin \\ false)

@spec send_stream(t(), non_neg_integer(), binary(), boolean()) ::
  {:ok, t(), list()}
  | {:blocked, map() | :send_queue_limit | :send_queue_bytes_limit}
  | {:error, term()}
  | {:error, term(), t()}

Admit one application stream frame into the bounded scheduler queue.

stop_stream(state, id, code)

Request cancellation of the receive direction, preserving the send half.