1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61
|
package frame
const (
// offsets for packing/unpacking frames
lengthOffset = 32 + 16
flagsOffset = 32 + 8
typeOffset = 32 + 3
// masks for packing/unpacking frames
lengthMask = 0x3FFF
streamMask = 0x7FFFFFFF
flagsMask = 0xFF
typeMask = 0x1F
wndIncMask = 0x7FFFFFFF
priorityMask = 0x7FFFFFFF
)
// a frameType is a 5-bit integer in the frame header that identifies the type of frame
type FrameType uint8
const (
TypeStreamSyn = 0x1
TypeStreamRst = 0x2
TypeStreamData = 0x3
TypeStreamWndInc = 0x4
TypeStreamPri = 0x5
TypeGoAway = 0x6
)
// a flagsType is an 8-bit integer containing frame-specific flag bits in the frame header
type flagsType uint8
const (
flagFin = 0x1
flagStreamPriority = 0x2
flagStreamType = 0x4
)
func (ft flagsType) IsSet(f flagsType) bool {
return (ft & f) != 0
}
func (ft *flagsType) Set(f flagsType) {
*ft |= f
}
func (ft *flagsType) Unset(f flagsType) {
*ft = *ft &^ f
}
// StreamId is 31-bit integer uniquely identifying a stream within a session
type StreamId uint32
// StreamPriority is 31-bit integer specifying a stream's priority
type StreamPriority uint32
// StreamType is 32-bit integer specifying a stream's type
type StreamType uint32
// ErrorCode is a 32-bit integer indicating a error condition included in rst/goaway frames
type ErrorCode uint32
|