 Documentation
      ¶
      Documentation
      ¶
    
    
  
    
  
    Index ¶
- Constants
- func ExpTimeToDuration(expTime uint8) time.Duration
- func MAC(h hash.Hash, info *InfoField, hf *HopField) []byte
- func MACInput(segID uint16, timestamp uint32, expTime uint8, consIngress, consEgress uint16) []byte
- func RegisterPath(pathMeta Metadata)
- func VerifyMAC(h hash.Hash, info *InfoField, hf *HopField) error
- type HopField
- type InfoField
- type Metadata
- type Path
- type Type
Constants ¶
const ( // HopLen is the size of a HopField in bytes. HopLen = 12 // MacLen is the size of the MAC of each HopField. MacLen = 6 )
const InfoLen = 8
    InfoLen is the size of an InfoField in bytes.
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 ¶
ExpTimeToDuration calculates the relative expiration time in seconds. Note that for a 0 value ExpTime, the minimal duration is expTimeUnit.
func MAC ¶
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.
func MACInput ¶
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.
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 []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 ¶
DecodeFromBytes populates the fields from a raw buffer. The buffer must be of length >= path.HopLen
func (*HopField) SerializeTo ¶
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 ¶
DecodeFromBytes populates the fields from a raw buffer. The buffer must be of length >= path.InfoLen
func (*InfoField) SerializeTo ¶
SerializeTo writes the fields into the provided buffer. The buffer must be of length >= path.InfoLen
func (*InfoField) UpdateSegID ¶
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.