spath

package
v0.3.1 Latest Latest
Warning

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

Go to latest
Published: Sep 24, 2018 License: Apache-2.0 Imports: 7 Imported by: 0

Documentation

Index

Constants

View Source
const (
	HopFieldLength    = common.LineLen
	DefaultHopFExpiry = ExpTimeType(63)
	MacLen            = 3
	ErrorHopFTooShort = "HopF too short"
	ErrorHopFBadMac   = "Bad HopF MAC"
	XoverMask         = 0x01
	VerifyOnlyMask    = 0x02
	RecurseMask       = 0x04
)
View Source
const (
	InfoFieldLength    = common.LineLen
	ErrorInfoFTooShort = "InfoF too short"
)
View Source
const (
	MaxTTL      = 24 * 60 * 60 // One day in seconds
	ExpTimeUnit = MaxTTL / (1 << 8)

	MaxTimestamp = ^uint32(0)
)

Variables

This section is empty.

Functions

This section is empty.

Types

type ExpTimeType added in v0.2.0

type ExpTimeType uint8

func (ExpTimeType) ToDuration added in v0.2.0

func (e ExpTimeType) ToDuration() time.Duration

type HopField

type HopField struct {
	Xover      bool
	VerifyOnly bool
	Recurse    bool
	// ExpTime defines for how long this HopField is valid,
	// relative to the PathSegments's InfoField.Timestamp().
	ExpTime ExpTimeType
	// ConsIngress is the interface the PCB entered the AS during path construction.
	ConsIngress common.IFIDType
	// ConsEgress is the interface the PCB exited the AS during path construction.
	ConsEgress common.IFIDType
	// Mac is the message authentication code of this HF,
	// see CalcMac() to see how it should be calculated.
	Mac common.RawBytes
	// contains filtered or unexported fields
}

func HopFFromRaw

func HopFFromRaw(b []byte) (*HopField, error)

HopFFromRaw returns a HopField object from the raw content in b.

The new HopField object takes ownership of the first HopFieldLength bytes in b. Changing fields in the new object and calling Write will mutate the initial bytes in b.

func NewHopField

func NewHopField(b common.RawBytes, in common.IFIDType,
	out common.IFIDType, expTime ExpTimeType) *HopField

func (*HopField) CalcMac

func (h *HopField) CalcMac(mac hash.Hash, tsInt uint32,
	prev common.RawBytes) (common.RawBytes, error)

CalcMac calculates the MAC of a HopField and its preceeding HopField, if any.

func (*HopField) Len

func (h *HopField) Len() int

Len returns the length (in bytes)

func (*HopField) String

func (h *HopField) String() string

func (*HopField) Verify

func (h *HopField) Verify(mac hash.Hash, tsInt uint32, prev common.RawBytes) error

func (*HopField) Write

func (h *HopField) Write()

func (*HopField) WriteTo

func (h *HopField) WriteTo(w io.Writer) (int64, error)

WriteTo implements the io.WriterTo interface.

type InfoField

type InfoField struct {
	// Previously Up, ConsDir = !Up
	ConsDir  bool
	Shortcut bool
	Peer     bool
	// TsInt is the timestamp that denotes when the propagation of a path segment started.
	// Use Timestamp() to get a time.Time value.
	TsInt uint32
	// ISD denotes the origin ISD of a path segment.
	ISD  uint16
	Hops uint8
}

func InfoFFromRaw

func InfoFFromRaw(b []byte) (*InfoField, error)

func (*InfoField) String

func (inf *InfoField) String() string

func (*InfoField) Timestamp

func (inf *InfoField) Timestamp() time.Time

Timestamp returns TsInt as a time.Time.

func (*InfoField) Write

func (inf *InfoField) Write(b common.RawBytes)

func (*InfoField) WriteTo

func (inf *InfoField) WriteTo(w io.Writer) (int64, error)

WriteTo implements the io.WriterTo interface.

type Path

type Path struct {
	Raw    common.RawBytes
	InfOff int // Offset of current Info Field
	HopOff int // Offset of current Hop Field
}

func New

func New(raw common.RawBytes) *Path

func (*Path) Copy

func (p *Path) Copy() *Path

func (*Path) GetHopField

func (path *Path) GetHopField(offset int) (*HopField, error)

func (*Path) GetInfoField

func (path *Path) GetInfoField(offset int) (*InfoField, error)

func (*Path) IncOffsets

func (path *Path) IncOffsets() error

IncOffsets updates the info and hop indices to the next routing field, while skipping verify only fields.

func (*Path) InitOffsets

func (path *Path) InitOffsets() error

InitOffsets computes the initial Hop Field offset (in bytes) for a newly created packet.

func (*Path) IsEmpty added in v0.3.0

func (path *Path) IsEmpty() bool

IsEmpty returns true if the path is nil or empty (no raw data).

func (*Path) Reverse

func (p *Path) Reverse() error

Directories

Path Synopsis
Package spathmeta implements basic types for working with SCIOND paths.
Package spathmeta implements basic types for working with SCIOND paths.

Jump to

Keyboard shortcuts

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