pub struct PhantomPacket {
pub header: PacketHeader,
pub payload: Vec<u8>,
pub extensions: Vec<u8>,
}std only.Expand description
Full packet with header and payload — the single on-wire data packet.
Fields§
§header: PacketHeaderPacket header (15 bytes on the wire; see PacketHeader::SIZE)
payload: Vec<u8>Encrypted payload (or coalesced bundle if COALESCED flag set)
extensions: Vec<u8>Forward-compat TLV headroom — retained for the AEAD-AAD/codec shape but
NOT serialised onto the WIRE v6 data-plane wire: to_wire emits only
header ‖ payload, and from_wire always yields an empty Vec here (see
PhantomPacket::to_wire). Was a length-prefixed wire field pre-v6.
Implementations§
Source§impl PhantomPacket
impl PhantomPacket
Sourcepub fn new(header: PacketHeader, payload: Vec<u8>) -> Self
pub fn new(header: PacketHeader, payload: Vec<u8>) -> Self
Create a new packet (extensions empty by default)
Sourcepub fn ack(
session_id: SessionId,
stream_id: StreamId,
ack_packet_number: u64,
) -> Self
pub fn ack( session_id: SessionId, stream_id: StreamId, ack_packet_number: u64, ) -> Self
Create an ACK packet: ACK flag only, empty payload, unencrypted.
Sourcepub fn wire_size(&self) -> usize
pub fn wire_size(&self) -> usize
Total wire size: the 15-byte header plus the payload (WIRE v6 — no length
prefixes, no extensions on the wire).
Sourcepub fn to_wire(&self) -> Vec<u8> ⓘ
pub fn to_wire(&self) -> Vec<u8> ⓘ
Serialise to the on-wire bytes: header(15) || payload.
WIRE v6 (anti-fingerprint diet): the two cleartext u32 length
prefixes (payload_len / ext_len) are GONE — payload is simply the
message remainder after the 15-byte header. SessionTransport::recv_bytes
is message-framed on every transport (UDP datagram / TCP 4-byte frame /
embedded frame), so the prefixes were pure redundancy and a verifiable
structural fingerprint (ext_len == 0, payload_len == datagram − const).
extensions is no longer carried on the data-plane wire (it was always
empty; the AEAD AAD still binds an empty extensions slice).
This is the cleartext wire image (the 15-byte header still has
session_id off-wire — the AEAD AAD is the separate 47-byte
PacketHeader::to_aad_image). The data plane never puts these bytes on
the wire directly — it calls Self::to_wire_masked to apply header
protection (which now masks the whole 15-byte header, version included).
Sourcepub fn to_wire_masked(&self, mask: &[u8]) -> Vec<u8> ⓘ
pub fn to_wire_masked(&self, mask: &[u8]) -> Vec<u8> ⓘ
Serialise with header protection applied: identical to Self::to_wire,
then the whole [HP_PROTECTED_OFFSET..PacketHeader::SIZE] region (WIRE
v6: the 15 bytes version ‖ packet_number ‖ flags ‖ stream_id ‖ epoch ‖ path_id) is XOR-masked with the caller-supplied HP mask. The mask is
computed from this packet’s payload ciphertext by the session’s
HeaderProtector (mask_send); the payload itself stays cleartext on the
wire (it is the AEAD ciphertext) so the recv path can locate the sample —
at the fixed offset PacketHeader::SIZE — before unmasking (the demux
routes on the outer ConnId). With the version byte now masked too, the
data-plane wire has no constant cleartext byte. Only the first
HP_PROTECTED_LEN bytes of mask are used; a shorter mask masks fewer
bytes rather than panicking (the session always supplies a full 16-byte
mask).
Sourcepub fn from_wire(bytes: &[u8]) -> Result<Self, WireError>
pub fn from_wire(bytes: &[u8]) -> Result<Self, WireError>
Parse a packet from its on-wire bytes — the inverse of Self::to_wire
(WIRE v6): the 15-byte header, then payload is the whole remainder. A
buffer shorter than the header yields WireError::Truncated. extensions
is always empty (off the v6 data-plane wire).
Trait Implementations§
Source§impl Clone for PhantomPacket
impl Clone for PhantomPacket
Source§fn clone(&self) -> PhantomPacket
fn clone(&self) -> PhantomPacket
1.0.0 (const: unstable) · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source. Read moreSource§impl Debug for PhantomPacket
impl Debug for PhantomPacket
impl Eq for PhantomPacket
Source§impl PartialEq for PhantomPacket
impl PartialEq for PhantomPacket
Source§fn eq(&self, other: &PhantomPacket) -> bool
fn eq(&self, other: &PhantomPacket) -> bool
self and other values to be equal, and is used by ==.