common

package
v0.6.0 Latest Latest
Warning

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

Go to latest
Published: Dec 4, 2020 License: Apache-2.0 Imports: 7 Imported by: 0

Documentation

Index

Constants

View Source
const (
	// LineLen is the number of bytes that all SCION headers are padded to a multiple of.
	LineLen     = 8
	MinMTU      = 1280
	MaxMTU      = (1 << 16) - 1
	TimeFmt     = "2006-01-02 15:04:05.000000-0700"
	TimeFmtSecs = "2006-01-02 15:04:05-0700"
)
View Source
const (
	CPService = "Control Plane Service"
)

Variables

View Source
var (
	NativeOrder binary.ByteOrder
	IsBigEndian bool
)
View Source
var L4Protocols = map[L4ProtocolType]bool{
	L4SCMP: true, L4TCP: true, L4UDP: true,
}

Functions

func FmtError

func FmtError(e error) string

FmtError formats e for logging. It walks through all nested errors, putting each on a new line, and indenting multi-line errors.

func FmtErrors added in v0.4.0

func FmtErrors(es []error) string

FmtErrors formats a slice of errors for logging.

func GetNestedError

func GetNestedError(e error) error

GetNestedError returns the nested error, if any. Returns nil otherwise.

func TypeOf

func TypeOf(v interface{}) string

Types

type ErrMsg added in v0.4.0

type ErrMsg string

ErrMsg should be used for error string constants. The constant can then be used for Is checking in the calling code.

func (ErrMsg) Error added in v0.4.0

func (e ErrMsg) Error() string

type ErrorMsger

type ErrorMsger interface {
	error
	GetMsg() string
}

ErrorMsger allows extracting the message from an error. This means a caller can determine the type of error by comparing the returned message with a const error string. E.g.:

if GetErrorMsg(err) == addr.ErrorBadHostAddrType {
   // Handle bad host addr error
}

type ErrorNester

type ErrorNester interface {
	error
	TopError() string // should not include the nested error
	GetErr() error
}

ErrorNester allows recursing into nested errors.

type IFIDType deprecated

type IFIDType uint64

IFIDType is the type for interface IDs.

Deprecated: with version 2 of the SCION header, there is no interface ID type anymore. Use the appropriate type depending on the path type.

func (IFIDType) String

func (ifid IFIDType) String() string

func (*IFIDType) UnmarshalJSON added in v0.5.0

func (ifid *IFIDType) UnmarshalJSON(data []byte) error

UnmarshalJSON unmarshals the JSON data into the IfID.

func (*IFIDType) UnmarshalText added in v0.4.0

func (ifid *IFIDType) UnmarshalText(text []byte) error

UnmarshalText unmarshals the text into the IfID.

type L4ProtocolType

type L4ProtocolType uint8
const (
	L4None L4ProtocolType = 0
	L4TCP  L4ProtocolType = 6
	L4UDP  L4ProtocolType = 17
	L4SCMP L4ProtocolType = 202
	L4BFD  L4ProtocolType = 203

	HopByHopClass L4ProtocolType = 200
	End2EndClass  L4ProtocolType = 201
)

func (L4ProtocolType) String

func (p L4ProtocolType) String() string

type RawBytes

type RawBytes []byte

func (RawBytes) Copy

func (r RawBytes) Copy() (RawBytes, error)

func (RawBytes) Len

func (r RawBytes) Len() int

func (RawBytes) String

func (r RawBytes) String() string

func (RawBytes) WritePld

func (r RawBytes) WritePld(b RawBytes) (int, error)

func (RawBytes) Zero

func (r RawBytes) Zero()

Jump to

Keyboard shortcuts

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