wire

package
v0.0.0-...-c0caacf Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Aug 19, 2022 License: MIT Imports: 11 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var (
	// ErrInvalidAckRanges occurs when a client sends inconsistent ACK ranges
	ErrInvalidAckRanges = errors.New("AckFrame: ACK frame contains invalid ACK ranges")
	// ErrInvalidFirstAckRange occurs when the first ACK range contains no packets
	ErrInvalidFirstAckRange = errors.New("AckFrame: ACK frame has invalid first ACK range")
)
View Source
var (
	ErrTooManyPaths = errors.New("PathsFrame: more paths than the maximum enabled")
	ErrPathsNumber  = errors.New("PathsFrame: number of paths advertised and # of paths do not match")
	ErrMissingRTT   = errors.New("PathsFrame: number of paths IDs and number of remote RTTs do not match")
)
View Source
var (
	// ErrPacketWithUnknownVersion occurs when a packet with an unknown version is parsed.
	// This can happen when the server is restarted. The client will send a packet without a version number.
	ErrPacketWithUnknownVersion = errors.New("PublicHeader: Received a packet without version number, that we don't know the version for")
)
View Source
var (
	ErrUnknownIPVersion = errors.New("AddAddressFrame: unknown IP version")
)

Functions

func ComposeVersionNegotiation

func ComposeVersionNegotiation(connectionID protocol.ConnectionID, versions []protocol.VersionNumber) []byte

ComposeVersionNegotiation composes a Version Negotiation Packet

func LogFrame

func LogFrame(frame Frame, sent bool)

LogFrame logs a frame, either sent or received

func PeekConnectionID

func PeekConnectionID(b *bytes.Reader, packetSentBy protocol.Perspective) (protocol.ConnectionID, error)

PeekConnectionID parses the connection ID from a QUIC packet's public header. If no error occurs, it restores the read position in the bytes.Reader.

func WritePublicReset

func WritePublicReset(connectionID protocol.ConnectionID, rejectedPacketNumber protocol.PacketNumber, nonceProof uint64) []byte

WritePublicReset writes a Public Reset

Types

type AckFrame

type AckFrame struct {
	PathID       protocol.PathID
	LargestAcked protocol.PacketNumber
	LowestAcked  protocol.PacketNumber
	AckRanges    []AckRange // has to be ordered. The highest ACK range goes first, the lowest ACK range goes last

	// time when the LargestAcked was receiveid
	// this field Will not be set for received ACKs frames
	PacketReceivedTime time.Time
	DelayTime          time.Duration
}

An AckFrame is an ACK frame in QUIC

func ParseAckFrame

func ParseAckFrame(r *bytes.Reader, version protocol.VersionNumber) (*AckFrame, error)

ParseAckFrame reads 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

func (f *AckFrame) HasMissingRanges() bool

HasMissingRanges returns if this frame reports any missing packets

func (*AckFrame) MinLength

func (f *AckFrame) MinLength(version protocol.VersionNumber) (protocol.ByteCount, error)

MinLength of a written frame

func (*AckFrame) Write

func (f *AckFrame) Write(b *bytes.Buffer, version protocol.VersionNumber) error

Write writes an ACK frame.

type AckRange

type AckRange struct {
	First protocol.PacketNumber
	Last  protocol.PacketNumber
}

AckRange is an ACK range

type AddAddressFrame

type AddAddressFrame struct {
	IPVersion uint8
	Addr      net.UDPAddr
}

A AddAddressFrame in QUIC

func ParseAddAddressFrame

func ParseAddAddressFrame(r *bytes.Reader, version protocol.VersionNumber) (*AddAddressFrame, error)

func (*AddAddressFrame) MinLength

func (f *AddAddressFrame) MinLength(version protocol.VersionNumber) (protocol.ByteCount, error)

func (*AddAddressFrame) Write

func (f *AddAddressFrame) Write(b *bytes.Buffer, version protocol.VersionNumber) error

type BlockedFrame

type BlockedFrame struct {
	StreamID protocol.StreamID
}

A BlockedFrame in QUIC

func ParseBlockedFrame

func ParseBlockedFrame(r *bytes.Reader, version protocol.VersionNumber) (*BlockedFrame, error)

ParseBlockedFrame parses a BLOCKED frame

func (*BlockedFrame) MinLength

func (f *BlockedFrame) MinLength(version protocol.VersionNumber) (protocol.ByteCount, error)

MinLength of a written frame

func (*BlockedFrame) Write

func (f *BlockedFrame) Write(b *bytes.Buffer, version protocol.VersionNumber) error

Write writes a BlockedFrame frame

type ClosePathFrame

type ClosePathFrame struct {
	PathID       protocol.PathID
	LargestAcked protocol.PacketNumber
	LowestAcked  protocol.PacketNumber
	AckRanges    []AckRange // has to be ordered. The ACK range with the highest First goes first, the ACK range with the lowest First goes last
}

A ClosePathFrame in (IETF) QUIC

func ParseClosePathFrame

func ParseClosePathFrame(r *bytes.Reader, version protocol.VersionNumber) (*ClosePathFrame, error)

func (*ClosePathFrame) AcksPacket

func (f *ClosePathFrame) AcksPacket(p protocol.PacketNumber) bool

AcksPacket determines if this ClosePath frame acks a certain packet number

func (*ClosePathFrame) HasMissingRanges

func (f *ClosePathFrame) HasMissingRanges() bool

func (*ClosePathFrame) MinLength

func (f *ClosePathFrame) MinLength(version protocol.VersionNumber) (protocol.ByteCount, error)

func (*ClosePathFrame) Write

func (f *ClosePathFrame) Write(b *bytes.Buffer, version protocol.VersionNumber) error

type ConnectionCloseFrame

type ConnectionCloseFrame struct {
	ErrorCode    qerr.ErrorCode
	ReasonPhrase string
}

A ConnectionCloseFrame in QUIC

func ParseConnectionCloseFrame

func ParseConnectionCloseFrame(r *bytes.Reader, version protocol.VersionNumber) (*ConnectionCloseFrame, error)

ParseConnectionCloseFrame reads a CONNECTION_CLOSE frame

func (*ConnectionCloseFrame) MinLength

MinLength of a written frame

func (*ConnectionCloseFrame) Write

Write writes an CONNECTION_CLOSE frame.

type Frame

type Frame interface {
	Write(b *bytes.Buffer, version protocol.VersionNumber) error
	MinLength(version protocol.VersionNumber) (protocol.ByteCount, error)
}

A Frame in QUIC

type GoawayFrame

type GoawayFrame struct {
	ErrorCode      qerr.ErrorCode
	LastGoodStream protocol.StreamID
	ReasonPhrase   string
}

A GoawayFrame is a GOAWAY frame

func ParseGoawayFrame

func ParseGoawayFrame(r *bytes.Reader, version protocol.VersionNumber) (*GoawayFrame, error)

ParseGoawayFrame parses a GOAWAY frame

func (*GoawayFrame) MinLength

func (f *GoawayFrame) MinLength(version protocol.VersionNumber) (protocol.ByteCount, error)

MinLength of a written frame

func (*GoawayFrame) Write

func (f *GoawayFrame) Write(b *bytes.Buffer, version protocol.VersionNumber) error

type PathsFrame

type PathsFrame struct {
	MaxNumPaths uint8
	NumPaths    uint8
	PathIDs     []protocol.PathID
	RemoteRTTs  []time.Duration
}

A PathsFrame in QUIC

func ParsePathsFrame

func ParsePathsFrame(r *bytes.Reader, version protocol.VersionNumber) (*PathsFrame, error)

func (*PathsFrame) MinLength

func (f *PathsFrame) MinLength(version protocol.VersionNumber) (protocol.ByteCount, error)

func (*PathsFrame) Write

func (f *PathsFrame) Write(b *bytes.Buffer, version protocol.VersionNumber) error

type PingFrame

type PingFrame struct{}

A PingFrame is a ping frame

func ParsePingFrame

func ParsePingFrame(r *bytes.Reader, version protocol.VersionNumber) (*PingFrame, error)

ParsePingFrame parses a Ping frame

func (*PingFrame) MinLength

func (f *PingFrame) MinLength(version protocol.VersionNumber) (protocol.ByteCount, error)

MinLength of a written frame

func (*PingFrame) Write

func (f *PingFrame) Write(b *bytes.Buffer, version protocol.VersionNumber) error

type PublicHeader

type PublicHeader struct {
	Raw                  []byte
	ConnectionID         protocol.ConnectionID
	PathID               protocol.PathID
	VersionFlag          bool
	ResetFlag            bool
	TruncateConnectionID bool
	MultipathFlag        bool
	PacketNumberLen      protocol.PacketNumberLen
	PacketNumber         protocol.PacketNumber
	VersionNumber        protocol.VersionNumber   // VersionNumber sent by the client
	SupportedVersions    []protocol.VersionNumber // VersionNumbers sent by the server
	DiversificationNonce []byte
}

The PublicHeader of a QUIC packet. Warning: This struct should not be considered stable and will change soon.

func ParsePublicHeader

func ParsePublicHeader(b *bytes.Reader, packetSentBy protocol.Perspective, version protocol.VersionNumber) (*PublicHeader, error)

ParsePublicHeader parses a QUIC packet's public header. The packetSentBy is the perspective of the peer that sent this PublicHeader, i.e. if we're the server, packetSentBy should be PerspectiveClient. Warning: This API should not be considered stable and will change soon.

func (*PublicHeader) GetLength

func (h *PublicHeader) GetLength(pers protocol.Perspective) (protocol.ByteCount, error)

GetLength gets the length of the publicHeader in bytes. It can only be called for regular packets.

func (*PublicHeader) Write

Write writes a public header. Warning: This API should not be considered stable and will change soon.

type PublicReset

type PublicReset struct {
	RejectedPacketNumber protocol.PacketNumber
	Nonce                uint64
}

A PublicReset is a PUBLIC_RESET

func ParsePublicReset

func ParsePublicReset(r *bytes.Reader) (*PublicReset, error)

ParsePublicReset parses a Public Reset

type RstStreamFrame

type RstStreamFrame struct {
	StreamID   protocol.StreamID
	ErrorCode  uint32
	ByteOffset protocol.ByteCount
}

A RstStreamFrame in QUIC

func ParseRstStreamFrame

func ParseRstStreamFrame(r *bytes.Reader, version protocol.VersionNumber) (*RstStreamFrame, error)

ParseRstStreamFrame parses a RST_STREAM frame

func (*RstStreamFrame) MinLength

func (f *RstStreamFrame) MinLength(version protocol.VersionNumber) (protocol.ByteCount, error)

MinLength of a written frame

func (*RstStreamFrame) Write

func (f *RstStreamFrame) Write(b *bytes.Buffer, version protocol.VersionNumber) error

Write writes a RST_STREAM frame

type StopWaitingFrame

type StopWaitingFrame struct {
	LeastUnacked    protocol.PacketNumber
	PacketNumberLen protocol.PacketNumberLen
	// PacketNumber is the packet number of the packet that this StopWaitingFrame will be sent with
	PacketNumber protocol.PacketNumber
}

A StopWaitingFrame in QUIC

func ParseStopWaitingFrame

func ParseStopWaitingFrame(r *bytes.Reader, packetNumber protocol.PacketNumber, packetNumberLen protocol.PacketNumberLen, version protocol.VersionNumber) (*StopWaitingFrame, error)

ParseStopWaitingFrame parses a StopWaiting frame

func (*StopWaitingFrame) MinLength

MinLength of a written frame

func (*StopWaitingFrame) Write

func (f *StopWaitingFrame) Write(b *bytes.Buffer, version protocol.VersionNumber) error

type StreamFrame

type StreamFrame struct {
	StreamID       protocol.StreamID
	FinBit         bool
	DataLenPresent bool
	Offset         protocol.ByteCount
	Data           []byte
}

A StreamFrame of QUIC

func ParseStreamFrame

func ParseStreamFrame(r *bytes.Reader, version protocol.VersionNumber) (*StreamFrame, error)

ParseStreamFrame reads a stream frame. The type byte must not have been read yet.

func (*StreamFrame) DataLen

func (f *StreamFrame) DataLen() protocol.ByteCount

DataLen gives the length of data in bytes

func (*StreamFrame) MinLength

MinLength returns the length of the header of a StreamFrame the total length of the StreamFrame is frame.MinLength() + frame.DataLen()

func (*StreamFrame) Write

func (f *StreamFrame) Write(b *bytes.Buffer, version protocol.VersionNumber) error

WriteStreamFrame writes a stream frame.

type WindowUpdateFrame

type WindowUpdateFrame struct {
	StreamID   protocol.StreamID
	ByteOffset protocol.ByteCount
}

A WindowUpdateFrame in QUIC

func ParseWindowUpdateFrame

func ParseWindowUpdateFrame(r *bytes.Reader, version protocol.VersionNumber) (*WindowUpdateFrame, error)

ParseWindowUpdateFrame parses a RST_STREAM frame

func (*WindowUpdateFrame) MinLength

MinLength of a written frame

func (*WindowUpdateFrame) Write

func (f *WindowUpdateFrame) Write(b *bytes.Buffer, version protocol.VersionNumber) error

Write writes a RST_STREAM frame

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL