scion

package
v0.12.0 Latest Latest
Warning

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

Go to latest
Published: Oct 10, 2024 License: Apache-2.0 Imports: 4 Imported by: 1

Documentation

Index

Constants

View Source
const (
	// MaxINFs is the maximum number of info fields in a SCION path.
	MaxINFs = 3
	// MaxHops is the maximum number of hop fields in a SCION path.
	MaxHops = 64

	// MetaLen is the length of the PathMetaHeader.
	MetaLen = 4

	PathType path.Type = 1
)

Variables

This section is empty.

Functions

func RegisterPath

func RegisterPath()

Types

type Base

type Base struct {
	// PathMeta is the SCION path meta header. It is always instantiated when
	// decoding a path from bytes.
	PathMeta MetaHdr
	// NumINF is the number of InfoFields in the path.
	NumINF int
	// NumHops is the number HopFields in the path.
	NumHops int
}

Base holds the basic information that is used by both raw and fully decoded paths.

func (*Base) DecodeFromBytes

func (s *Base) DecodeFromBytes(data []byte) error

func (*Base) IncPath

func (s *Base) IncPath() error

IncPath increases the currHF index and currINF index if appropriate.

func (*Base) IsFirstHopAfterXover added in v0.9.0

func (s *Base) IsFirstHopAfterXover() bool

IsFirstHopAfterXover returns whether this is the first hop field after a crossover point.

func (*Base) IsXover

func (s *Base) IsXover() bool

IsXover returns whether we are at a crossover point. This includes all segment switches, even over a peering link. Note that handling of a regular segment switch and handling of a segment switch over a peering link are fundamentally different. To distinguish the two, you will need to extract the information from the info field.

func (*Base) Len

func (s *Base) Len() int

Len returns the length of the path in bytes. That is, the number of byte required to store it, based on the metadata. The actual number of bytes available to contain it can be inferred from the common header field HdrLen. It may or may not be consistent.

func (*Base) Type

func (s *Base) Type() path.Type

Type returns the type of the path.

type Decoded

type Decoded struct {
	Base
	// InfoFields contains all the InfoFields of the path.
	InfoFields []path.InfoField
	// HopFields contains all the HopFields of the path.
	HopFields []path.HopField
}

Decoded implements the SCION (data-plane) path type. Decoded is intended to be used in non-performance critical code paths, where the convenience of having a fully parsed path trumps the loss of performance.

func (*Decoded) DecodeFromBytes

func (s *Decoded) DecodeFromBytes(data []byte) error

DecodeFromBytes fully decodes the SCION path into the corresponding fields.

func (*Decoded) Reverse

func (s *Decoded) Reverse() (path.Path, error)

Reverse reverses a SCION path.

func (*Decoded) SerializeTo

func (s *Decoded) SerializeTo(b []byte) error

SerializeTo writes the path to a slice. The slice must be big enough to hold the entire data, otherwise an error is returned.

func (*Decoded) ToRaw

func (s *Decoded) ToRaw() (*Raw, error)

ToRaw tranforms scion.Decoded into scion.Raw.

type MetaHdr

type MetaHdr struct {
	CurrINF uint8
	CurrHF  uint8
	SegLen  [3]uint8
}

MetaHdr is the PathMetaHdr of a SCION (data-plane) path type.

func (*MetaHdr) DecodeFromBytes

func (m *MetaHdr) DecodeFromBytes(raw []byte) error

DecodeFromBytes populates the fields from a raw buffer. The buffer must be of length >= scion.MetaLen.

func (*MetaHdr) SerializeTo

func (m *MetaHdr) SerializeTo(b []byte) error

SerializeTo writes the fields into the provided buffer. The buffer must be of length >= scion.MetaLen.

func (MetaHdr) String

func (m MetaHdr) String() string

type Raw

type Raw struct {
	Base
	Raw []byte
}

Raw is a raw representation of the SCION (data-plane) path type. It is designed to parse as little as possible and should be used if performance matters.

func (*Raw) CurrINFMatchesCurrHF added in v0.12.0

func (s *Raw) CurrINFMatchesCurrHF() bool

CurrINFMatchesCurrHF returns whether the the path's current hopfield is in the path's current segment.

func (*Raw) DecodeFromBytes

func (s *Raw) DecodeFromBytes(data []byte) error

DecodeFromBytes only decodes the PathMetaHeader. Otherwise the nothing is decoded and simply kept as raw bytes.

func (*Raw) GetCurrentHopField

func (s *Raw) GetCurrentHopField() (path.HopField, error)

GetCurrentHopField is a convenience method that returns the current hop field pointed to by the CurrHF index in the path meta header.

func (*Raw) GetCurrentInfoField

func (s *Raw) GetCurrentInfoField() (path.InfoField, error)

GetCurrentInfoField is a convenience method that returns the current hop field pointed to by the CurrINF index in the path meta header.

func (*Raw) GetHopField

func (s *Raw) GetHopField(idx int) (path.HopField, error)

GetHopField returns the HopField at a given index.

func (*Raw) GetInfoField

func (s *Raw) GetInfoField(idx int) (path.InfoField, error)

GetInfoField returns the InfoField at a given index.

func (*Raw) IncPath

func (s *Raw) IncPath() error

IncPath increments the path and writes it to the buffer.

func (*Raw) IsFirstHop added in v0.9.0

func (s *Raw) IsFirstHop() bool

IsFirstHop returns whether the current hop is the first hop on the path.

func (*Raw) IsLastHop

func (s *Raw) IsLastHop() bool

IsLastHop returns whether the current hop is the last hop on the path.

func (*Raw) IsPenultimateHop

func (s *Raw) IsPenultimateHop() bool

IsPenultimateHop returns whether the current hop is the penultimate hop on the path.

func (*Raw) Reverse

func (s *Raw) Reverse() (path.Path, error)

Reverse reverses the path such that it can be used in the reverse direction.

func (*Raw) SerializeTo

func (s *Raw) SerializeTo(b []byte) error

SerializeTo writes the path to a slice. The slice must be big enough to hold the entire data, otherwise an error is returned.

func (*Raw) SetHopField

func (s *Raw) SetHopField(hop path.HopField, idx int) error

SetHopField updates the HopField at a given index.

func (*Raw) SetInfoField

func (s *Raw) SetInfoField(info path.InfoField, idx int) error

SetInfoField updates the InfoField at a given index.

func (*Raw) ToDecoded

func (s *Raw) ToDecoded() (*Decoded, error)

ToDecoded transforms a scion.Raw to a scion.Decoded.

Jump to

Keyboard shortcuts

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