diff --git a/quinn-proto/src/connection/mod.rs b/quinn-proto/src/connection/mod.rs index 0c2e82287..1e67ecbe7 100644 --- a/quinn-proto/src/connection/mod.rs +++ b/quinn-proto/src/connection/mod.rs @@ -23,7 +23,7 @@ use crate::{ frame, frame::{Close, Datagram, FrameStruct}, is_supported_version, - packet::{Header, LongType, Packet, PacketNumber, PartialDecode, PartialEncode, SpaceId}, + packet::{Header, LongType, Packet, PacketNumber, PartialDecode, SpaceId}, range_set::RangeSet, shared::{ ConnectionEvent, ConnectionEventInner, ConnectionId, EcnCodepoint, EndpointEvent, @@ -41,6 +41,10 @@ mod cid_state; use cid_state::CidState; mod pacing; + +mod packet_builder; +use packet_builder::PacketBuilder; + mod paths; use paths::PathData; @@ -3588,27 +3592,6 @@ struct SentFrames { requires_padding: bool, } -struct PacketBuilder { - datagram_start: usize, - space: SpaceId, - partial_encode: PartialEncode, - ack_eliciting: bool, - exact_number: u64, - short_header: bool, - min_size: usize, - max_size: usize, - tag_len: usize, - span: tracing::Span, -} - -impl PacketBuilder { - fn pad_to(&mut self, min_size: u16) { - let prev = self.min_size; - self.min_size = self.datagram_start + (min_size as usize) - self.tag_len; - debug_assert!(self.min_size >= prev, "padding must not shrink datagram"); - } -} - /// Perform key updates this many packets before the AEAD confidentiality limit. /// /// Chosen arbitrarily, intended to be large enough to prevent spurious connection loss. diff --git a/quinn-proto/src/connection/packet_builder.rs b/quinn-proto/src/connection/packet_builder.rs new file mode 100644 index 000000000..de37f83be --- /dev/null +++ b/quinn-proto/src/connection/packet_builder.rs @@ -0,0 +1,22 @@ +use crate::packet::{PartialEncode, SpaceId}; + +pub(super) struct PacketBuilder { + pub datagram_start: usize, + pub space: SpaceId, + pub partial_encode: PartialEncode, + pub ack_eliciting: bool, + pub exact_number: u64, + pub short_header: bool, + pub min_size: usize, + pub max_size: usize, + pub tag_len: usize, + pub span: tracing::Span, +} + +impl PacketBuilder { + pub fn pad_to(&mut self, min_size: u16) { + let prev = self.min_size; + self.min_size = self.datagram_start + (min_size as usize) - self.tag_len; + debug_assert!(self.min_size >= prev, "padding must not shrink datagram"); + } +}