Documentation ¶
Index ¶
- Variables
- func AppendShortHeader(b []byte, connID protocol.ConnectionID, pn protocol.PacketNumber, ...) ([]byte, error)
- func ComposeVersionNegotiation(destConnID, srcConnID protocol.ArbitraryLenConnectionID, ...) []byte
- func Is0RTTPacket(b []byte) bool
- func IsLongHeaderPacket(firstByte byte) bool
- func IsPotentialQUICPacket(firstByte byte) bool
- func IsVersionNegotiationPacket(b []byte) bool
- func LogFrame(logger utils.Logger, frame Frame, sent bool)
- func LogShortHeader(logger utils.Logger, dest protocol.ConnectionID, pn protocol.PacketNumber, ...)
- func ParseArbitraryLenConnectionIDs(data []byte) (bytesParsed int, dest, src protocol.ArbitraryLenConnectionID, _ error)
- func ParseConnectionID(data []byte, shortHeaderConnIDLen int) (protocol.ConnectionID, error)
- func ParseShortHeader(data []byte, connIDLen int) (length int, _ protocol.PacketNumber, _ protocol.PacketNumberLen, ...)
- func ParseVersion(data []byte) (protocol.Version, error)
- func ParseVersionNegotiationPacket(b []byte) (dest, src protocol.ArbitraryLenConnectionID, _ []protocol.Version, _ error)
- func ShortHeaderLen(dest protocol.ConnectionID, pnLen protocol.PacketNumberLen) protocol.ByteCount
- type AckFrame
- func (f *AckFrame) AcksPacket(p protocol.PacketNumber) bool
- func (f *AckFrame) Append(b []byte, _ protocol.Version) ([]byte, error)
- func (f *AckFrame) HasMissingRanges() bool
- func (f *AckFrame) LargestAcked() protocol.PacketNumber
- func (f *AckFrame) Length(_ protocol.Version) protocol.ByteCount
- func (f *AckFrame) LowestAcked() protocol.PacketNumber
- func (f *AckFrame) Reset()
- func (f *AckFrame) UpdateAckRanges(conn packet_setting.QuicConnection)
- type AckRange
- type ConnectionCloseFrame
- type CryptoFrame
- func (f *CryptoFrame) Append(b []byte, _ protocol.Version) ([]byte, error)
- func (f *CryptoFrame) Length(_ protocol.Version) protocol.ByteCount
- func (f *CryptoFrame) MaxDataLen(maxSize protocol.ByteCount) protocol.ByteCount
- func (f *CryptoFrame) MaybeSplitOffFrame(maxSize protocol.ByteCount, version protocol.Version) (*CryptoFrame, bool)
- type DataBlockedFrame
- type DatagramFrame
- type ExtendedHeader
- type Frame
- type FrameParser
- type HandshakeDoneFrame
- type Header
- type MaxDataFrame
- type MaxStreamDataFrame
- type MaxStreamsFrame
- type NewConnectionIDFrame
- type NewTokenFrame
- type PathChallengeFrame
- type PathResponseFrame
- type PingFrame
- type PreferredAddress
- type ResetStreamFrame
- type RetireConnectionIDFrame
- type StopSendingFrame
- type StreamDataBlockedFrame
- type StreamFrame
- func (f *StreamFrame) Append(b []byte, _ protocol.Version) ([]byte, error)
- func (f *StreamFrame) DataLen() protocol.ByteCount
- func (f *StreamFrame) Length(version protocol.Version) protocol.ByteCount
- func (f *StreamFrame) MaxDataLen(maxSize protocol.ByteCount, version protocol.Version) protocol.ByteCount
- func (f *StreamFrame) MaybeSplitOffFrame(maxSize protocol.ByteCount, version protocol.Version) (*StreamFrame, bool)
- func (f *StreamFrame) PutBack()
- type StreamsBlockedFrame
- type TransportParameters
- func (p *TransportParameters) Marshal(pers protocol.Perspective) []byte
- func (p *TransportParameters) MarshalForSessionTicket(b []byte) []byte
- func (p *TransportParameters) String() string
- func (p *TransportParameters) Unmarshal(data []byte, sentBy protocol.Perspective) error
- func (p *TransportParameters) UnmarshalFromSessionTicket(r *bytes.Reader) error
- func (p *TransportParameters) ValidFor0RTT(saved *TransportParameters) bool
- func (p *TransportParameters) ValidForUpdate(saved *TransportParameters) bool
Constants ¶
This section is empty.
Variables ¶
var AdditionalTransportParametersClient map[uint64][]byte
AdditionalTransportParametersClient are additional transport parameters that will be added to the client's transport parameters. This is not intended for production use, but _only_ to increase the size of the ClientHello beyond the usual size of less than 1 MTU.
var ErrInvalidReservedBits = errors.New("invalid reserved bits")
ErrInvalidReservedBits is returned when the reserved bits are incorrect. When this error is returned, parsing continues, and an ExtendedHeader is returned. This is necessary because we need to decrypt the packet in that case, in order to avoid a timing side-channel.
var ErrUnsupportedVersion = errors.New("unsupported version")
var MaxDatagramSize protocol.ByteCount = 16383
MaxDatagramSize is the maximum size of a DATAGRAM frame (RFC 9221). By setting it to a large value, we allow all datagrams that fit into a QUIC packet. The value is chosen such that it can still be encoded as a 2 byte varint. This is a var and not a const so it can be set in tests.
Functions ¶
func AppendShortHeader ¶
func AppendShortHeader(b []byte, connID protocol.ConnectionID, pn protocol.PacketNumber, pnLen protocol.PacketNumberLen, kp protocol.KeyPhaseBit) ([]byte, error)
AppendShortHeader writes a short header.
func ComposeVersionNegotiation ¶
func ComposeVersionNegotiation(destConnID, srcConnID protocol.ArbitraryLenConnectionID, versions []protocol.Version) []byte
ComposeVersionNegotiation composes a Version Negotiation
func Is0RTTPacket ¶
Is0RTTPacket says if this is a 0-RTT packet. A packet sent with a version we don't understand can never be a 0-RTT packet.
func IsLongHeaderPacket ¶
IsLongHeaderPacket says if this is a Long Header packet
func IsPotentialQUICPacket ¶
func IsVersionNegotiationPacket ¶
IsVersionNegotiationPacket says if this is a version negotiation packet
func LogShortHeader ¶
func LogShortHeader(logger utils.Logger, dest protocol.ConnectionID, pn protocol.PacketNumber, pnLen protocol.PacketNumberLen, kp protocol.KeyPhaseBit)
func ParseArbitraryLenConnectionIDs ¶
func ParseArbitraryLenConnectionIDs(data []byte) (bytesParsed int, dest, src protocol.ArbitraryLenConnectionID, _ error)
ParseArbitraryLenConnectionIDs parses the most general form of a Long Header packet, using only the version-independent packet format as described in Section 5.1 of RFC 8999: https://datatracker.ietf.org/doc/html/rfc8999#section-5.1. This function should only be called on Long Header packets for which we don't support the version.
func ParseConnectionID ¶
func ParseConnectionID(data []byte, shortHeaderConnIDLen int) (protocol.ConnectionID, error)
ParseConnectionID parses the destination connection ID of a packet.
func ParseShortHeader ¶
func ParseShortHeader(data []byte, connIDLen int) (length int, _ protocol.PacketNumber, _ protocol.PacketNumberLen, _ protocol.KeyPhaseBit, _ error)
ParseShortHeader parses a short header packet. It must be called after header protection was removed. Otherwise, the check for the reserved bits will (most likely) fail.
func ParseVersion ¶
ParseVersion parses the QUIC version. It should only be called for Long Header packets (Short Header packets don't contain a version number).
func ParseVersionNegotiationPacket ¶
func ParseVersionNegotiationPacket(b []byte) (dest, src protocol.ArbitraryLenConnectionID, _ []protocol.Version, _ error)
ParseVersionNegotiationPacket parses a Version Negotiation packet.
func ShortHeaderLen ¶
func ShortHeaderLen(dest protocol.ConnectionID, pnLen protocol.PacketNumberLen) protocol.ByteCount
Types ¶
type AckFrame ¶
type AckFrame struct { AckRanges []AckRange // has to be ordered. The highest ACK range goes first, the lowest ACK range goes last DelayTime time.Duration ECT0, ECT1, ECNCE uint64 }
An AckFrame is an ACK frame
func (*AckFrame) AcksPacket ¶
func (f *AckFrame) AcksPacket(p protocol.PacketNumber) bool
AcksPacket determines if this ACK frame acks a certain packet number
func (*AckFrame) HasMissingRanges ¶
HasMissingRanges returns if this frame reports any missing packets
func (*AckFrame) LargestAcked ¶
func (f *AckFrame) LargestAcked() protocol.PacketNumber
LargestAcked is the largest acked packet number
func (*AckFrame) LowestAcked ¶
func (f *AckFrame) LowestAcked() protocol.PacketNumber
LowestAcked is the lowest acked packet number
func (*AckFrame) UpdateAckRanges ¶
func (f *AckFrame) UpdateAckRanges(conn packet_setting.QuicConnection)
BPF_MAP_TAG
type AckRange ¶
type AckRange struct { Smallest protocol.PacketNumber Largest protocol.PacketNumber }
AckRange is an ACK range
func (AckRange) Len ¶
func (r AckRange) Len() protocol.PacketNumber
Len returns the number of packets contained in this ACK range
type ConnectionCloseFrame ¶
type ConnectionCloseFrame struct { IsApplicationError bool ErrorCode uint64 FrameType uint64 ReasonPhrase string }
A ConnectionCloseFrame is a CONNECTION_CLOSE frame
type CryptoFrame ¶
A CryptoFrame is a CRYPTO frame
func (*CryptoFrame) Length ¶
func (f *CryptoFrame) Length(_ protocol.Version) protocol.ByteCount
Length of a written frame
func (*CryptoFrame) MaxDataLen ¶
func (f *CryptoFrame) MaxDataLen(maxSize protocol.ByteCount) protocol.ByteCount
MaxDataLen returns the maximum data length
func (*CryptoFrame) MaybeSplitOffFrame ¶
func (f *CryptoFrame) MaybeSplitOffFrame(maxSize protocol.ByteCount, version protocol.Version) (*CryptoFrame, bool)
MaybeSplitOffFrame splits a frame such that it is not bigger than n bytes. It returns if the frame was actually split. The frame might not be split if: * the size is large enough to fit the whole frame * the size is too small to fit even a 1-byte frame. In that case, the frame returned is nil.
type DataBlockedFrame ¶
A DataBlockedFrame is a DATA_BLOCKED frame
type DatagramFrame ¶
type DatagramFrame struct { DataLenPresent bool Data []byte // DATAGRAM_PRIO_TAG Priority priority_setting.Priority }
A DatagramFrame is a DATAGRAM frame
func (*DatagramFrame) Length ¶
func (f *DatagramFrame) Length(_ protocol.Version) protocol.ByteCount
Length of a written frame
func (*DatagramFrame) MaxDataLen ¶
func (f *DatagramFrame) MaxDataLen(maxSize protocol.ByteCount, version protocol.Version) protocol.ByteCount
MaxDataLen returns the maximum data length
type ExtendedHeader ¶
type ExtendedHeader struct { Header KeyPhase protocol.KeyPhaseBit PacketNumberLen protocol.PacketNumberLen PacketNumber protocol.PacketNumber // contains filtered or unexported fields }
ExtendedHeader is the header of a QUIC packet.
func (*ExtendedHeader) GetLength ¶
func (h *ExtendedHeader) GetLength(_ protocol.Version) protocol.ByteCount
GetLength determines the length of the Header.
func (*ExtendedHeader) ParsedLen ¶
func (h *ExtendedHeader) ParsedLen() protocol.ByteCount
ParsedLen returns the number of bytes that were consumed when parsing the header
type Frame ¶
type Frame interface { Append(b []byte, version protocol.Version) ([]byte, error) Length(version protocol.Version) protocol.ByteCount }
A Frame in QUIC
type FrameParser ¶
type FrameParser struct {
// contains filtered or unexported fields
}
The FrameParser parses QUIC frames, one by one.
func NewFrameParser ¶
func NewFrameParser(supportsDatagrams bool) *FrameParser
NewFrameParser creates a new frame parser.
func (*FrameParser) ParseNext ¶
func (p *FrameParser) ParseNext(data []byte, encLevel protocol.EncryptionLevel, v protocol.Version) (int, Frame, error)
ParseNext parses the next frame. It skips PADDING frames.
func (*FrameParser) SetAckDelayExponent ¶
func (p *FrameParser) SetAckDelayExponent(exp uint8)
SetAckDelayExponent sets the acknowledgment delay exponent (sent in the transport parameters). This value is used to scale the ACK Delay field in the ACK frame.
type HandshakeDoneFrame ¶
type HandshakeDoneFrame struct{}
A HandshakeDoneFrame is a HANDSHAKE_DONE frame
type Header ¶
type Header struct { Type protocol.PacketType Version protocol.Version SrcConnectionID protocol.ConnectionID DestConnectionID protocol.ConnectionID Length protocol.ByteCount Token []byte // contains filtered or unexported fields }
The Header is the version independent part of the header
func ParsePacket ¶
ParsePacket parses a packet. If the packet has a long header, the packet is cut according to the length field. If we understand the version, the packet is header up unto the packet number. Otherwise, only the invariant part of the header is parsed.
func (*Header) PacketType ¶
PacketType is the type of the packet, for logging purposes
func (*Header) ParseExtended ¶
ParseExtended parses the version dependent part of the header. The Reader has to be set such that it points to the first byte of the header.
type MaxDataFrame ¶
A MaxDataFrame carries flow control information for the connection
type MaxStreamDataFrame ¶
A MaxStreamDataFrame is a MAX_STREAM_DATA frame
type MaxStreamsFrame ¶
type MaxStreamsFrame struct { Type protocol.StreamType MaxStreamNum protocol.StreamNum }
A MaxStreamsFrame is a MAX_STREAMS frame
type NewConnectionIDFrame ¶
type NewConnectionIDFrame struct { SequenceNumber uint64 RetirePriorTo uint64 ConnectionID protocol.ConnectionID StatelessResetToken protocol.StatelessResetToken }
A NewConnectionIDFrame is a NEW_CONNECTION_ID frame
type NewTokenFrame ¶
type NewTokenFrame struct {
Token []byte
}
A NewTokenFrame is a NEW_TOKEN frame
type PathChallengeFrame ¶
type PathChallengeFrame struct {
Data [8]byte
}
A PathChallengeFrame is a PATH_CHALLENGE frame
type PathResponseFrame ¶
type PathResponseFrame struct {
Data [8]byte
}
A PathResponseFrame is a PATH_RESPONSE frame
type PreferredAddress ¶
type PreferredAddress struct {
IPv4, IPv6 netip.AddrPort
ConnectionID protocol.ConnectionID
StatelessResetToken protocol.StatelessResetToken
}
PreferredAddress is the value encoding in the preferred_address transport parameter
type ResetStreamFrame ¶
type ResetStreamFrame struct { StreamID protocol.StreamID ErrorCode qerr.StreamErrorCode FinalSize protocol.ByteCount }
A ResetStreamFrame is a RESET_STREAM frame in QUIC
type RetireConnectionIDFrame ¶
type RetireConnectionIDFrame struct {
SequenceNumber uint64
}
A RetireConnectionIDFrame is a RETIRE_CONNECTION_ID frame
type StopSendingFrame ¶
type StopSendingFrame struct { StreamID protocol.StreamID ErrorCode qerr.StreamErrorCode }
A StopSendingFrame is a STOP_SENDING frame
type StreamDataBlockedFrame ¶
type StreamDataBlockedFrame struct { StreamID protocol.StreamID MaximumStreamData protocol.ByteCount }
A StreamDataBlockedFrame is a STREAM_DATA_BLOCKED frame
type StreamFrame ¶
type StreamFrame struct { StreamID protocol.StreamID Offset protocol.ByteCount Data []byte Fin bool DataLenPresent bool // contains filtered or unexported fields }
A StreamFrame of QUIC
func GetStreamFrame ¶
func GetStreamFrame() *StreamFrame
func (*StreamFrame) DataLen ¶
func (f *StreamFrame) DataLen() protocol.ByteCount
DataLen gives the length of data in bytes
func (*StreamFrame) Length ¶
func (f *StreamFrame) Length(version protocol.Version) protocol.ByteCount
Length returns the total length of the STREAM frame
func (*StreamFrame) MaxDataLen ¶
func (f *StreamFrame) MaxDataLen(maxSize protocol.ByteCount, version protocol.Version) protocol.ByteCount
MaxDataLen returns the maximum data length If 0 is returned, writing will fail (a STREAM frame must contain at least 1 byte of data).
func (*StreamFrame) MaybeSplitOffFrame ¶
func (f *StreamFrame) MaybeSplitOffFrame(maxSize protocol.ByteCount, version protocol.Version) (*StreamFrame, bool)
MaybeSplitOffFrame splits a frame such that it is not bigger than n bytes. It returns if the frame was actually split. The frame might not be split if: * the size is large enough to fit the whole frame * the size is too small to fit even a 1-byte frame. In that case, the frame returned is nil.
func (*StreamFrame) PutBack ¶
func (f *StreamFrame) PutBack()
type StreamsBlockedFrame ¶
type StreamsBlockedFrame struct { Type protocol.StreamType StreamLimit protocol.StreamNum }
A StreamsBlockedFrame is a STREAMS_BLOCKED frame
type TransportParameters ¶
type TransportParameters struct { InitialMaxStreamDataBidiLocal protocol.ByteCount InitialMaxStreamDataBidiRemote protocol.ByteCount InitialMaxStreamDataUni protocol.ByteCount InitialMaxData protocol.ByteCount MaxAckDelay time.Duration AckDelayExponent uint8 DisableActiveMigration bool MaxUDPPayloadSize protocol.ByteCount MaxUniStreamNum protocol.StreamNum MaxBidiStreamNum protocol.StreamNum MaxIdleTimeout time.Duration PreferredAddress *PreferredAddress OriginalDestinationConnectionID protocol.ConnectionID InitialSourceConnectionID protocol.ConnectionID RetrySourceConnectionID *protocol.ConnectionID // use a pointer here to distinguish zero-length connection IDs from missing transport parameters StatelessResetToken *protocol.StatelessResetToken ActiveConnectionIDLimit uint64 MaxDatagramFrameSize protocol.ByteCount }
TransportParameters are parameters sent to the peer during the handshake
func (*TransportParameters) Marshal ¶
func (p *TransportParameters) Marshal(pers protocol.Perspective) []byte
Marshal the transport parameters
func (*TransportParameters) MarshalForSessionTicket ¶
func (p *TransportParameters) MarshalForSessionTicket(b []byte) []byte
MarshalForSessionTicket marshals the transport parameters we save in the session ticket. When sending a 0-RTT enabled TLS session tickets, we need to save the transport parameters. The client will remember the transport parameters used in the last session, and apply those to the 0-RTT data it sends. Saving the transport parameters in the ticket gives the server the option to reject 0-RTT if the transport parameters changed. Since the session ticket is encrypted, the serialization format is defined by the server. For convenience, we use the same format that we also use for sending the transport parameters.
func (*TransportParameters) String ¶
func (p *TransportParameters) String() string
String returns a string representation, intended for logging.
func (*TransportParameters) Unmarshal ¶
func (p *TransportParameters) Unmarshal(data []byte, sentBy protocol.Perspective) error
Unmarshal the transport parameters
func (*TransportParameters) UnmarshalFromSessionTicket ¶
func (p *TransportParameters) UnmarshalFromSessionTicket(r *bytes.Reader) error
UnmarshalFromSessionTicket unmarshals transport parameters from a session ticket.
func (*TransportParameters) ValidFor0RTT ¶
func (p *TransportParameters) ValidFor0RTT(saved *TransportParameters) bool
ValidFor0RTT checks if the transport parameters match those saved in the session ticket.
func (*TransportParameters) ValidForUpdate ¶
func (p *TransportParameters) ValidForUpdate(saved *TransportParameters) bool
ValidForUpdate checks that the new transport parameters don't reduce limits after resuming a 0-RTT connection. It is only used on the client side.
Source Files ¶
- ack_frame.go
- ack_range.go
- connection_close_frame.go
- crypto_frame.go
- data_blocked_frame.go
- datagram_frame.go
- extended_header.go
- frame_parser.go
- handshake_done_frame.go
- header.go
- interface.go
- log.go
- max_data_frame.go
- max_stream_data_frame.go
- max_streams_frame.go
- new_connection_id_frame.go
- new_token_frame.go
- path_challenge_frame.go
- path_response_frame.go
- ping_frame.go
- pool.go
- reset_stream_frame.go
- retire_connection_id_frame.go
- short_header.go
- stop_sending_frame.go
- stream_data_blocked_frame.go
- stream_frame.go
- streams_blocked_frame.go
- transport_parameters.go
- version_negotiation.go