path

package
v0.7.0 Latest Latest
Warning

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

Go to latest
Published: Mar 12, 2022 License: Apache-2.0 Imports: 6 Imported by: 0

Documentation

Index

Constants

View Source
const (
	// HopLen is the size of a HopField in bytes.
	HopLen = 12
	// MacLen is the size of the MAC of each HopField.
	MacLen = 6
)
View Source
const InfoLen = 8

InfoLen is the size of an InfoField in bytes.

View Source
const MACBufferSize = 16
View Source
const MaxTTL = 24 * 60 * 60 // One day in seconds

MaxTTL is the maximum age of a HopField in seconds.

Variables

This section is empty.

Functions

func ExpTimeToDuration

func ExpTimeToDuration(expTime uint8) time.Duration

ExpTimeToDuration calculates the relative expiration time in seconds. Note that for a 0 value ExpTime, the minimal duration is expTimeUnit.

func FullMAC added in v0.7.0

func FullMAC(h hash.Hash, info InfoField, hf HopField, buffer []byte) []byte

FullMAC calculates the HopField MAC according to https://scion.docs.anapaya.net/en/latest/protocols/scion-header.html#hop-field-mac-computation this method does not modify info or hf. Modifying the provided buffer after calling this function may change the returned HopField MAC. In contrast to MAC(), FullMAC returns all the 16 bytes instead of only 6 bytes of the MAC.

func MAC

func MAC(h hash.Hash, info InfoField, hf HopField, buffer []byte) [MacLen]byte

MAC calculates the HopField MAC according to https://scion.docs.anapaya.net/en/latest/protocols/scion-header.html#hop-field-mac-computation this method does not modify info or hf. Modifying the provided buffer after calling this function may change the returned HopField MAC.

func MACInput

func MACInput(segID uint16, timestamp uint32, expTime uint8,
	consIngress, consEgress uint16, buffer []byte)

MACInput returns the MAC input data block with the following layout:

 0                   1                   2                   3
 0 1 2 3 4 5 6 7 8 9 0 1 2 3 4 5 6 7 8 9 0 1 2 3 4 5 6 7 8 9 0 1
+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
|               0               |             SegID             |
+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
|                           Timestamp                           |
+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
|       0       |    ExpTime    |          ConsIngress          |
+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
|          ConsEgress           |               0               |
+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+

func RegisterPath

func RegisterPath(pathMeta Metadata)

RegisterPath registers a new SCION path type globally. The PathType passed in must be unique, or a runtime panic will occur.

func StrictDecoding added in v0.7.0

func StrictDecoding(strict bool)

StrictDecoding enables or disables strict path decoding. If enabled, unknown path types fail to decode. If disabled, unknown path types are decoded into a raw path that keeps the encoded path around for re-serialization.

Strict parsing is enabled by default.

Experimental: This function is experimental and might be subject to change.

Types

type HopField

type HopField struct {
	// IngressRouterAlert flag. If the IngressRouterAlert is set, the ingress router (in
	// construction direction) will process the L4 payload in the packet.
	IngressRouterAlert bool
	// EgressRouterAlert flag. If the EgressRouterAlert is set, the egress router (in
	// construction direction) will process the L4 payload in the packet.
	EgressRouterAlert bool
	// Exptime is the expiry time of a HopField. The field is 1-byte long, thus there are 256
	// different values available to express an expiration time. The expiration time expressed by
	// the value of this field is relative, and an absolute expiration time in seconds is computed
	// in combination with the timestamp field (from the corresponding info field) as follows
	//
	// Timestamp + (1 + ExpTime) * (24*60*60)/256
	ExpTime uint8
	// ConsIngress is the ingress interface ID in construction direction.
	ConsIngress uint16
	// ConsEgress is the egress interface ID in construction direction.
	ConsEgress uint16
	// Mac is the 6-byte Message Authentication Code to authenticate the HopField.
	Mac [MacLen]byte
}

HopField is the HopField used in the SCION and OneHop path types.

The Hop Field has the following format:

 0                   1                   2                   3
 0 1 2 3 4 5 6 7 8 9 0 1 2 3 4 5 6 7 8 9 0 1 2 3 4 5 6 7 8 9 0 1
+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
|r r r r r r I E|    ExpTime    |           ConsIngress         |
+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
|        ConsEgress             |                               |
+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+                               +
|                              MAC                              |
+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+

func (*HopField) DecodeFromBytes

func (h *HopField) DecodeFromBytes(raw []byte) error

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

func (*HopField) SerializeTo

func (h *HopField) SerializeTo(b []byte) error

SerializeTo writes the fields into the provided buffer. The buffer must be of length >= path.HopLen.

type InfoField

type InfoField struct {
	// Peer is the peering flag. If set to true, then the forwarding path is built as a peering
	// path, which requires special processing on the dataplane.
	Peer bool
	// ConsDir is the construction direction flag. If set to true then the hop fields are arranged
	// in the direction they have been constructed during beaconing.
	ConsDir bool
	// SegID is a updatable field that is required for the MAC-chaining mechanism.
	SegID uint16
	// Timestamp created by the initiator of the corresponding beacon. The timestamp is expressed in
	// Unix time, and is encoded as an unsigned integer within 4 bytes with 1-second time
	// granularity.  This timestamp enables validation of the hop field by verification of the
	// expiration time and MAC.
	Timestamp uint32
}

InfoField is the InfoField used in the SCION and OneHop path types.

InfoField has the following format:

 0                   1                   2                   3
 0 1 2 3 4 5 6 7 8 9 0 1 2 3 4 5 6 7 8 9 0 1 2 3 4 5 6 7 8 9 0 1
+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
|r r r r r r P C|      RSV      |             SegID             |
+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
|                           Timestamp                           |
+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+

func (*InfoField) DecodeFromBytes

func (inf *InfoField) DecodeFromBytes(raw []byte) error

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

func (*InfoField) SerializeTo

func (inf *InfoField) SerializeTo(b []byte) error

SerializeTo writes the fields into the provided buffer. The buffer must be of length >= path.InfoLen.

func (InfoField) String

func (inf InfoField) String() string

func (*InfoField) UpdateSegID

func (inf *InfoField) UpdateSegID(hfMac [MacLen]byte)

UpdateSegID updates the SegID field by XORing the SegID field with the 2 first bytes of the MAC. It is the beta calculation according to https://scion.docs.anapaya.net/en/latest/protocols/scion-header.html#hop-field-mac-computation

type Metadata

type Metadata struct {
	// Type is a unique value for the path.
	Type Type
	// Desc is the description/name of the path.
	Desc string
	// New is a path constructor function.
	New func() Path
}

Metadata defines a new SCION path type, used for dynamic SICON path type registration.

type Path

type Path interface {
	// SerializeTo serializes the path into the provided buffer.
	SerializeTo(b []byte) error
	// DecodesFromBytes decodes the path from the provided buffer.
	DecodeFromBytes(b []byte) error
	// Reverse reverses a path such that it can be used in the reversed direction.
	//
	// XXX(shitz): This method should possibly be moved to a higher-level path manipulation package.
	Reverse() (Path, error)
	// Len returns the length of a path in bytes.
	Len() int
	// Type returns the type of a path.
	Type() Type
}

Path is the path contained in the SCION header.

func NewPath

func NewPath(pathType Type) (Path, error)

NewPath returns a new path object of pathType.

func NewRawPath added in v0.7.0

func NewRawPath() Path

NewRawPath returns a new raw path that can hold any path type.

type Type

type Type uint8

Type indicates the type of the path contained in the SCION header.

func (Type) String

func (t Type) String() string

Directories

Path Synopsis
Package epic implements the Path interface for the EPIC path type.
Package epic implements the Path interface for the EPIC path type.

Jump to

Keyboard shortcuts

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