scmp

package
v0.0.0-...-c8fc2fc Latest Latest
Warning

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

Go to latest
Published: Mar 2, 2018 License: Apache-2.0 Imports: 9 Imported by: 0

Documentation

Index

Constants

View Source
const (
	ExtnErrorFlag = 0x1
	ExtnHBHFlag   = 0x2
)
View Source
const (
	ErrorSCMPHdrUnpack = "Failed to unpack SCMP header"
)
View Source
const (
	HdrLen = 16
)
View Source
const (
	MetaLen = 8
)

Variables

This section is empty.

Functions

func NewError

func NewError(class Class, type_ Type, info Info, e error) error

NewError creates a new SCMP Error with the specified scmp Class/Type/Info, and optional nested error.

Types

type Class

type Class uint16
const (
	C_General Class = iota
	C_Routing
	C_CmnHdr
	C_Path
	C_Ext
	C_Sibra
)

func (Class) String

func (c Class) String() string

type ClassType

type ClassType struct {
	Class Class
	Type  Type
}

func (ClassType) String

func (ct ClassType) String() string

type Error

type Error struct {
	CT   ClassType
	Info Info
	Err  error
}

Error represents an SCMP error, with an optional nested error.

func ToError

func ToError(e error) *Error

ToError converts an e to an Error. If that fails, it recurses on the nested error, if any, and otherwise returns nil.

func (*Error) Error

func (e *Error) Error() string

func (*Error) GetErr

func (e *Error) GetErr() error

func (*Error) TopError

func (e *Error) TopError() string

type Extn

type Extn struct {
	Error    bool
	HopByHop bool
}

func ExtnFromRaw

func ExtnFromRaw(b common.RawBytes) (*Extn, error)

func (*Extn) Class

func (e *Extn) Class() common.L4ProtocolType

func (*Extn) Copy

func (e *Extn) Copy() common.Extension

func (*Extn) Len

func (e *Extn) Len() int

func (*Extn) Pack

func (e *Extn) Pack() (common.RawBytes, error)

func (*Extn) Reverse

func (e *Extn) Reverse() (bool, error)

func (*Extn) String

func (e *Extn) String() string

func (*Extn) Type

func (e *Extn) Type() common.ExtnType

func (*Extn) Write

func (e *Extn) Write(b common.RawBytes) error

type Hdr

type Hdr struct {
	Class     Class           // SCMP message class
	Type      Type            // SCMP message type
	TotalLen  uint16          // Length of SCMP header + payload
	Checksum  common.RawBytes `struct:"[2]byte"`
	Timestamp uint64          // Time in µs since unix epoch
}

func HdrFromRaw

func HdrFromRaw(b common.RawBytes) (*Hdr, error)

func NewHdr

func NewHdr(ct ClassType, len int) *Hdr

func (*Hdr) Copy

func (h *Hdr) Copy() l4.L4Header

func (*Hdr) GetCSum

func (h *Hdr) GetCSum() common.RawBytes

func (*Hdr) L4Len

func (h *Hdr) L4Len() int

func (*Hdr) L4Type

func (h *Hdr) L4Type() common.L4ProtocolType

func (*Hdr) Pack

func (h *Hdr) Pack(csum bool) (common.RawBytes, error)

func (*Hdr) Reverse

func (h *Hdr) Reverse()

func (*Hdr) SetCSum

func (h *Hdr) SetCSum(csum common.RawBytes)

func (*Hdr) SetPldLen

func (h *Hdr) SetPldLen(l int)

func (*Hdr) String

func (h *Hdr) String() string

func (*Hdr) Validate

func (h *Hdr) Validate(plen int) error

func (*Hdr) Write

func (h *Hdr) Write(b common.RawBytes) error

type Info

type Info interface {
	fmt.Stringer
	Copy() Info
	Len() int
	Write(b common.RawBytes) (int, error)
}

func ParseInfo

func ParseInfo(b common.RawBytes, ct ClassType) (Info, error)

type InfoEcho

type InfoEcho struct {
	Id  uint16
	Seq uint16
}

func InfoEchoFromRaw

func InfoEchoFromRaw(b common.RawBytes) (*InfoEcho, error)

func (*InfoEcho) Copy

func (e *InfoEcho) Copy() Info

func (*InfoEcho) Len

func (e *InfoEcho) Len() int

func (*InfoEcho) String

func (e *InfoEcho) String() string

func (*InfoEcho) Write

func (e *InfoEcho) Write(b common.RawBytes) (int, error)

type InfoExtIdx

type InfoExtIdx struct {
	Idx uint8
}

func InfoExtIdxFromRaw

func InfoExtIdxFromRaw(b common.RawBytes) (*InfoExtIdx, error)

func (*InfoExtIdx) Copy

func (e *InfoExtIdx) Copy() Info

func (*InfoExtIdx) Len

func (r *InfoExtIdx) Len() int

func (*InfoExtIdx) String

func (e *InfoExtIdx) String() string

func (*InfoExtIdx) Write

func (e *InfoExtIdx) Write(b common.RawBytes) (int, error)

type InfoPathOffsets

type InfoPathOffsets struct {
	InfoF   uint16
	HopF    uint16
	IfID    uint16
	Ingress bool
}

func InfoPathOffsetsFromRaw

func InfoPathOffsetsFromRaw(b common.RawBytes) (*InfoPathOffsets, error)

func (*InfoPathOffsets) Copy

func (p *InfoPathOffsets) Copy() Info

func (*InfoPathOffsets) Len

func (p *InfoPathOffsets) Len() int

func (*InfoPathOffsets) String

func (p *InfoPathOffsets) String() string

func (*InfoPathOffsets) Write

func (p *InfoPathOffsets) Write(b common.RawBytes) (int, error)

type InfoPktSize

type InfoPktSize struct {
	Size uint16
	MTU  uint16
}

func InfoPktSizeFromRaw

func InfoPktSizeFromRaw(b common.RawBytes) (*InfoPktSize, error)

func (*InfoPktSize) Copy

func (p *InfoPktSize) Copy() Info

func (*InfoPktSize) Len

func (p *InfoPktSize) Len() int

func (*InfoPktSize) String

func (p *InfoPktSize) String() string

func (*InfoPktSize) Write

func (p *InfoPktSize) Write(b common.RawBytes) (int, error)

type InfoRevocation

type InfoRevocation struct {
	*InfoPathOffsets
	RevToken common.RawBytes
}

func InfoRevocationFromRaw

func InfoRevocationFromRaw(b common.RawBytes) (*InfoRevocation, error)

func NewInfoRevocation

func NewInfoRevocation(infoF, hopF, ifID uint16, ingress bool,
	revToken common.RawBytes) *InfoRevocation

func (*InfoRevocation) Copy

func (r *InfoRevocation) Copy() Info

func (*InfoRevocation) Len

func (r *InfoRevocation) Len() int

func (*InfoRevocation) String

func (r *InfoRevocation) String() string

func (*InfoRevocation) Write

func (r *InfoRevocation) Write(b common.RawBytes) (int, error)

type InfoString

type InfoString string

func (InfoString) Copy

func (s InfoString) Copy() Info

func (InfoString) Len

func (s InfoString) Len() int

func (InfoString) String

func (s InfoString) String() string

func (InfoString) Write

func (s InfoString) Write(b common.RawBytes) (int, error)

type Meta

type Meta struct {
	InfoLen    uint8
	CmnHdrLen  uint8
	AddrHdrLen uint8
	PathHdrLen uint8
	ExtHdrsLen uint8
	L4HdrLen   uint8
	L4Proto    common.L4ProtocolType
}

func MetaFromRaw

func MetaFromRaw(b []byte) (*Meta, error)

func (*Meta) Copy

func (m *Meta) Copy() *Meta

func (*Meta) String

func (m *Meta) String() string

func (*Meta) Write

func (m *Meta) Write(b common.RawBytes) error

type Payload

type Payload struct {
	Meta    *Meta
	Info    Info
	CmnHdr  common.RawBytes
	AddrHdr common.RawBytes
	PathHdr common.RawBytes
	ExtHdrs common.RawBytes
	L4Hdr   common.RawBytes
	// contains filtered or unexported fields
}

func PldFromQuotes

func PldFromQuotes(ct ClassType, info Info, l4 common.L4ProtocolType, f QuoteFunc) *Payload

func PldFromRaw

func PldFromRaw(b common.RawBytes, ct ClassType) (*Payload, error)

func (*Payload) Copy

func (p *Payload) Copy() (common.Payload, error)

func (*Payload) Len

func (p *Payload) Len() int

func (*Payload) String

func (p *Payload) String() string

func (*Payload) WritePld

func (p *Payload) WritePld(b common.RawBytes) (int, error)

type QuoteFunc

type QuoteFunc func(RawBlock) common.RawBytes

type RawBlock

type RawBlock int

Used to specify parts of packets to quote

const (
	RawCmnHdr RawBlock = iota
	RawAddrHdr
	RawPathHdr
	RawExtHdrs
	RawL4Hdr
)

type Type

type Type uint16
const (
	T_G_Unspecified Type = iota
	T_G_EchoRequest
	T_G_EchoReply
)

C_General types

const (
	T_R_UnreachNet Type = iota
	T_R_UnreachHost
	T_R_L2Error
	T_R_UnreachProto
	T_R_UnreachPort
	T_R_UnknownHost
	T_R_BadHost
	T_R_OversizePkt
	T_R_AdminDenied
)

C_Routing types

const (
	T_C_BadVersion Type = iota
	T_C_BadDstType
	T_C_BadSrcType
	T_C_BadPktLen
	T_C_BadInfoFOffset
	T_C_BadHopFOffset
)

C_CmnHdr types

const (
	T_P_PathRequired Type = iota
	T_P_BadMac
	T_P_ExpiredHopF
	T_P_BadIF
	T_P_RevokedIF
	T_P_NonRoutingHopF
	T_P_DeliveryFwdOnly
	T_P_DeliveryNonLocal
	T_P_BadSegment
	T_P_BadInfoField
	T_P_BadHopField
)

C_Path types

const (
	T_E_TooManyHopbyHop Type = iota
	T_E_BadExtOrder
	T_E_BadHopByHop
	T_E_BadEnd2End
)

C_Ext types

const (
	T_S_BadVersion Type = iota
	T_S_SetupNoReq
)

C_Sibra types

func (Type) Name

func (t Type) Name(c Class) string

Jump to

Keyboard shortcuts

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