framing

package
v0.0.0-...-738e6fc Latest Latest
Warning

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

Go to latest
Published: Dec 14, 2021 License: MIT Imports: 8 Imported by: 0

Documentation

Overview

Package framing implements Google SPDY™ protocol framing layer.

Index

Constants

View Source
const (
	FRAME_SYN_STREAM    uint16 = 1
	FRAME_SYN_RELY      uint16 = 2
	FRAME_RST_STREAM    uint16 = 3
	FRAME_SETTINGS      uint16 = 4
	FRAME_NOOP          uint16 = 5
	FRAME_PING          uint16 = 6
	FRAME_GOAWAY        uint16 = 7
	FRAME_HEADERS       uint16 = 8
	FRAME_WINDOW_UPDATE uint16 = 9
	FRAME_CREDENTIAL    uint16 = 0x1011
)

Control frame types.

View Source
const (
	FLAG_NONE                                         byte = 0
	FLAG_FIN                                          byte = 0x01
	FLAG_UNIDIRECTIONAL                               byte = 0x02
	FLAG_SETTINGS_CLEAR_SETTINGS                      byte = 0x1
	FLAG_SETTINGS_CLEAR_PREVIOUSLY_PERSISTED_SETTINGS      = FLAG_SETTINGS_CLEAR_SETTINGS
)
View Source
const (
	STATUS_PROTOCOL_ERROR        uint32 = 1
	STATUS_INVALID_STREAM        uint32 = 2
	STATUS_REFUSED_STREAM        uint32 = 3
	STATUS_UNSUPPORTED_VERSION   uint32 = 4
	STATUS_CANCEL                uint32 = 5
	STATUS_INTERNAL_ERROR        uint32 = 6
	STATUS_FLOW_CONTROL_ERROR    uint32 = 7
	STATUS_STREAM_IN_USE         uint32 = 8
	STATUS_STREAM_ALREADY_CLOSED uint32 = 9
	STATUS_INVALID_CREDENTIALS   uint32 = 10
	STATUS_FRAME_TOO_LARGE       uint32 = 11
)

RstStream status codes.

View Source
const (
	STATUS_GOAWAY_OK             uint32 = 0
	STATUS_GOAWAY_PROTOCOL_ERROR uint32 = 1
	STATUS_GOAWAY_INTERNAL_ERROR uint32 = 2
)

V3 GoAway status code.

View Source
const (
	ID_SETTINGS_UPLOAD_BANDWIDTH               uint32 = 1
	ID_SETTINGS_DOWNLOAD_BANDWIDTH             uint32 = 2
	ID_SETTINGS_ROUND_TRIP_TIME                uint32 = 3
	ID_SETTINGS_MAX_CONCURRENT_STREAMS         uint32 = 4
	ID_SETTINGS_CURRENT_CWND                   uint32 = 5
	ID_SETTINGS_DOWNLOAD_RETRANS_RATE          uint32 = 6
	ID_SETTINGS_INITIAL_WINDOW_SIZE            uint32 = 7
	ID_SETTINGS_CLIENT_CERTIFICATE_VECTOR_SIZE uint32 = 8
)

Setting IDs.

View Source
const (
	FLAG_SETTINGS_PERSIST_VALUE byte = 0x1
	FLAG_SETTINGS_PERSISTED     byte = 0x2
)

Setting flags.

View Source
const (
	MIN_PRIORITY    byte = 0
	MAX_PRIORITY_V3 byte = 7
	MAX_PRIORITY_V2 byte = 3
)

SynStream priority range.

View Source
const (
	MIN_DELTA_WINDOW_SIZE uint32 = 1
	MAX_DELTA_WINDOW_SIZE uint32 = 0x7FFFFFFF //  2^31 - 1
)
View Source
const MAX_STREAM_ID uint32 = 0x8FFFFFFF

Variables

View Source
var (
	ErrInvalidVersion          = errors.New("Invalid version")
	ErrInvalidControlFrameType = errors.New("Invalid conrol frame type")
	ErrUnsupportedVersion      = errors.New("Unsupported version")
	ErrInvalidFlags            = errors.New("Invalid flags")
	ErrInvalidStreamID         = errors.New("Invalid stream ID")
	ErrInvalidPriority         = errors.New("Invalid priority")
	ErrInvalidStatausCode      = errors.New("Invalid status code")
	ErrInvalidSettingID        = errors.New("Invalid setting ID")
	ErrInvalidSettingFlags     = errors.New("Invalid setting flags")
	ErrSetingIDExists          = errors.New("Setting ID already exists in frame")
	ErrInvalidDeltaWindowSize  = errors.New("Invalid delta window size")
	ErrInvalidSlot             = errors.New("Invalid slot")
	ErrInvalidHeaderName       = errors.New("Invalid header name")
	ErrInvalidHeaderValue      = errors.New("Invalid header value")
	ErrInvalidFrameLength      = errors.New("Invalid frame length")
	ErrFrameTooLarge           = errors.New("Frame too large")
)

Functions

func StatusCodeStreamAlreadyClosed

func StatusCodeStreamAlreadyClosed(version uint16) uint32

func StatusCodeStreamInUse

func StatusCodeStreamInUse(version uint16) uint32

func WriteFrame

func WriteFrame(encoder *fields.Encoder, frame Frame) (err error)

Types

type ControlFrame

type ControlFrame interface {
	Frame
	Version() uint16
	Type() uint16
	// contains filtered or unexported methods
}

type ControlFrameWithFlags

type ControlFrameWithFlags interface {
	ControlFrame
	Flags() byte
}

type ControlFrameWithHeaders

type ControlFrameWithHeaders interface {
	ControlFrame
	Headers() HeaderBlock
}

type ControlFrameWithSetFlags

type ControlFrameWithSetFlags interface {
	ControlFrameWithFlags
	SetFlags(byte) error
}

type ControlFrameWithSetStatusCode

type ControlFrameWithSetStatusCode interface {
	ControlFrame
	StatusCode() uint32
	SetStatusCode(statusCode uint32) error
}

type ControlFrameWithStatusCode

type ControlFrameWithStatusCode interface {
	ControlFrame
	StatusCode() uint32
}

type DataFrame

type DataFrame struct {
	io.Reader
	// contains filtered or unexported fields
}

func NewDataFrame

func NewDataFrame(streamID uint32, r io.Reader, len uint32) *DataFrame

func NewDataFrameBytes

func NewDataFrameBytes(streamID uint32, p []byte) *DataFrame

func NewDataFrameString

func NewDataFrameString(streamID uint32, s string) *DataFrame

func (*DataFrame) Close

func (d *DataFrame) Close() (err error)

func (*DataFrame) Flags

func (d *DataFrame) Flags() byte

func (*DataFrame) IsControl

func (d *DataFrame) IsControl() bool

IsControl returns false.

func (*DataFrame) Len

func (d *DataFrame) Len() uint32

func (*DataFrame) SetFlags

func (d *DataFrame) SetFlags(flags byte) (err error)

func (*DataFrame) SetLen

func (d *DataFrame) SetLen(len uint32)

func (*DataFrame) SetStreamID

func (d *DataFrame) SetStreamID(id uint32) (err error)

func (*DataFrame) StreamID

func (d *DataFrame) StreamID() uint32

type Frame

type Frame interface {
	// Whether a control frame.
	IsControl() bool
}

func ReadFrame

func ReadFrame(decoder *fields.Decoder) (f Frame, err error)

type FrameWithStreamID

type FrameWithStreamID interface {
	StreamID() uint32
}

type GoAway

type GoAway interface {
	ControlFrame
	LastGoodStreamID() uint32
}

func NewGoAway

func NewGoAway(version uint16, lastGoodStreamID uint32) (f GoAway, err error)

type HeaderBlock

type HeaderBlock interface {
	// Add a header
	Add(name string, value ...string) error
	// Get the first header with this name.
	GetFirst(name string) string
	// Get all headers with this name.
	Get(name string) []string
	// Names returns all names of headers.
	Names() (names []string)
}

type Headers

type Headers interface {
	ControlFrame
	StreamID() uint32
	Flags() byte
	Headers() HeaderBlock
}

func NewHeaders

func NewHeaders(version uint16, streamID uint32, flags byte) (f Headers, err error)

type Noop

type Noop interface {
	ControlFrame
}

func NewNoop

func NewNoop(version uint16) (f Noop, err error)

type Ping

type Ping interface {
	ControlFrame
	ID() uint32
}

func NewPing

func NewPing(version uint16, ID uint32) (f Ping, err error)

type RstStream

type RstStream interface {
	ControlFrame
	StreamID() uint32
	StatusCode() uint32
}

func NewRstStream

func NewRstStream(version uint16, streamID uint32, statusCode uint32) (f RstStream, err error)

type SettingEntries

type SettingEntries interface {
	// A single SETTINGS frame MUST not contain multiple values for the same ID.
	Set(ID uint32, flags byte, value uint32) error
	Get(ID uint32) (flags byte, value uint32, exists bool)
	IDs() (IDs []uint32)
}

type Settings

type Settings interface {
	ControlFrame
	Flags() byte
	Entries() SettingEntries
}

func NewSettings

func NewSettings(version uint16, flags byte) (f Settings, err error)

type SynReply

type SynReply interface {
	ControlFrame
	Flags() byte
	SetFlags(flags byte) error
	StreamID() uint32
	Headers() HeaderBlock
}

func NewSynReply

func NewSynReply(version uint16, streamID uint32) (f SynReply, err error)

type SynStream

type SynStream interface {
	ControlFrame
	Flags() byte
	StreamID() uint32
	AssociatedToStreamID() uint32
	SetAssociatedToStreamID(to uint32) error
	// See MIN_PRIORITY, MAX_PRIORITY_Vx
	Priority() byte
	SetPriority(pri byte) error
	Headers() HeaderBlock
}

func NewSynStream

func NewSynStream(version uint16, streamID uint32, flags byte) (f SynStream, err error)

type WindowUpdate

type WindowUpdate interface {
	ControlFrame
	StreamID() uint32
	DeltaWindowSize() uint32
}

func NewWindowUpdate

func NewWindowUpdate(version uint16, streamID uint32, deltaWindowSize uint32) (f WindowUpdate, err error)

Directories

Path Synopsis
Package fields implements wire format decoding and encoding.
Package fields implements wire format decoding and encoding.

Jump to

Keyboard shortcuts

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