seg

package
v0.4.0 Latest Latest
Warning

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

Go to latest
Published: Nov 14, 2019 License: Apache-2.0 Imports: 14 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type ASEntry

type ASEntry struct {
	RawIA      addr.IAInt `capnp:"isdas"`
	TrcVer     scrypto.Version
	CertVer    scrypto.Version
	IfIDSize   uint8
	HopEntries []*HopEntry `capnp:"hops"`
	MTU        uint16      `capnp:"mtu"`
	Exts       struct {
		RoutingPolicy common.RawBytes    `capnp:"-"` // Not supported yet
		Sibra         common.RawBytes    `capnp:"-"` // Not supported yet
		HiddenPathSeg *HiddenPathSegExtn `capnp:"hiddenPathSeg"`
	}
}

func NewASEntryFromRaw

func NewASEntryFromRaw(b common.RawBytes) (*ASEntry, error)

func (*ASEntry) IA

func (ase *ASEntry) IA() addr.IA

func (*ASEntry) Pack

func (ase *ASEntry) Pack() (common.RawBytes, error)

func (*ASEntry) ProtoId

func (ase *ASEntry) ProtoId() proto.ProtoIdType

func (*ASEntry) String

func (ase *ASEntry) String() string

func (*ASEntry) Validate

func (ase *ASEntry) Validate(prevIA addr.IA, nextIA addr.IA, ignoreNext bool) error

type Beacon added in v0.4.0

type Beacon struct {
	Segment *PathSegment `capnp:"pathSeg"`
}

Beacon is kept for compatibility with python code. Before using the enclosed segment, the beacon should be parsed.

func (*Beacon) Parse added in v0.4.0

func (b *Beacon) Parse() error

Parse parses and validates the enclosed path segment.

func (*Beacon) ProtoId added in v0.4.0

func (b *Beacon) ProtoId() proto.ProtoIdType

func (*Beacon) String added in v0.4.0

func (b *Beacon) String() string

type HiddenPathSegExtn added in v0.4.0

type HiddenPathSegExtn struct {
	Set bool
}

func NewHiddenPathSegExtn added in v0.4.0

func NewHiddenPathSegExtn() *HiddenPathSegExtn

func (*HiddenPathSegExtn) ProtoId added in v0.4.0

func (hpExt *HiddenPathSegExtn) ProtoId() proto.ProtoIdType

func (*HiddenPathSegExtn) String added in v0.4.0

func (hpExt *HiddenPathSegExtn) String() string

type HopEntry

type HopEntry struct {
	RawInIA     addr.IAInt `capnp:"inIA"`
	RemoteInIF  common.IFIDType
	InMTU       uint16     `capnp:"inMTU"`
	RawOutIA    addr.IAInt `capnp:"outIA"`
	RemoteOutIF common.IFIDType
	RawHopField []byte `capnp:"hopF"`
}

func (*HopEntry) HopField

func (e *HopEntry) HopField() (*spath.HopField, error)

func (*HopEntry) InIA

func (e *HopEntry) InIA() addr.IA

func (*HopEntry) OutIA

func (e *HopEntry) OutIA() addr.IA

type Meta

type Meta struct {
	Type    proto.PathSegType
	Segment *PathSegment `capnp:"pathSeg"`
}

func NewMeta added in v0.3.0

func NewMeta(s *PathSegment, t proto.PathSegType) *Meta

func (*Meta) String

func (m *Meta) String() string

type PathSegment

type PathSegment struct {
	RawSData     common.RawBytes        `capnp:"sdata"`
	SData        *PathSegmentSignedData `capnp:"-"`
	RawASEntries []*proto.SignedBlobS   `capnp:"asEntries"`
	// ASEntries contains the AS entries.
	// WARNING: Should never be modified! Use AddASEntry or create a new Segment instead.
	ASEntries []*ASEntry `capnp:"-"`
	// contains filtered or unexported fields
}

func NewBeaconFromRaw added in v0.4.0

func NewBeaconFromRaw(b common.RawBytes) (*PathSegment, error)

NewBeaconFromRaw creates a segment from raw data. The last AS entry is not assumed to terminate the path segment.

func NewSeg

func NewSeg(infoF *spath.InfoField) (*PathSegment, error)

NewSeg creates a new path segment with the specified info field. The AS entries are empty and should be added using AddASEntry.

func NewSegFromRaw

func NewSegFromRaw(b common.RawBytes) (*PathSegment, error)

NewSegFromRaw creates a segment from raw data.

func (*PathSegment) AddASEntry

func (ps *PathSegment) AddASEntry(ase *ASEntry, signer Signer) error

AddASEntry adds the AS entry and signs the resulting path segment.

func (*PathSegment) ContainsInterface

func (ps *PathSegment) ContainsInterface(ia addr.IA, ifid common.IFIDType) bool

func (*PathSegment) FirstIA added in v0.3.0

func (ps *PathSegment) FirstIA() addr.IA

FirstIA returns the IA of the first ASEntry. Note that if the seg contains no ASEntries this method will panic.

func (*PathSegment) FullId added in v0.4.0

func (ps *PathSegment) FullId() (common.RawBytes, error)

FullId returns a hash of the segment covering all hops including peerings.

func (*PathSegment) GetLoggingID added in v0.4.0

func (ps *PathSegment) GetLoggingID() string

func (*PathSegment) ID

func (ps *PathSegment) ID() (common.RawBytes, error)

ID returns a hash of the segment covering all hops, except for peerings.

func (*PathSegment) InfoF

func (ps *PathSegment) InfoF() (*spath.InfoField, error)

func (*PathSegment) LastIA added in v0.3.0

func (ps *PathSegment) LastIA() addr.IA

LastIA returns the IA of the last ASEntry. Note that if the seg contains no ASEntries this method will panic.

func (*PathSegment) MaxAEIdx

func (ps *PathSegment) MaxAEIdx() int

func (*PathSegment) MaxExpiry added in v0.3.0

func (ps *PathSegment) MaxExpiry() time.Time

MaxExpiry returns the maximum expiry of all hop fields. Assumes segment is validated.

func (*PathSegment) MinExpiry added in v0.3.0

func (ps *PathSegment) MinExpiry() time.Time

MinExpiry returns the minimum expiry of all hop fields. Assumes segment is validated.

func (*PathSegment) Pack

func (ps *PathSegment) Pack() (common.RawBytes, error)

func (*PathSegment) ParseRaw

func (ps *PathSegment) ParseRaw(validationMethod ValidationMethod) error

func (*PathSegment) ProtoId

func (ps *PathSegment) ProtoId() proto.ProtoIdType

func (*PathSegment) RawWriteTo added in v0.3.0

func (ps *PathSegment) RawWriteTo(w io.Writer) (int64, error)

RawWriteTo writes the PathSegment to the writer in a form that is understood by spath/Path.

func (*PathSegment) ShallowCopy added in v0.4.0

func (ps *PathSegment) ShallowCopy() *PathSegment

ShallowCopy creates a shallow copy of the path segment.

func (*PathSegment) String

func (ps *PathSegment) String() string

func (*PathSegment) Validate

func (ps *PathSegment) Validate(validationMethod ValidationMethod) error

Validate validates that remote ingress and egress ISD-AS for each AS entry are consistent with the segment. In case a beacon is validated, the egress ISD-AS of the last AS entry is ignored.

func (*PathSegment) VerifyASEntry

func (ps *PathSegment) VerifyASEntry(ctx context.Context, verifier Verifier, idx int) error

VerifyASEntry verifies the AS Entry at the specified index.

func (*PathSegment) WalkHopEntries

func (ps *PathSegment) WalkHopEntries() error

WalkHopEntries iterates through the hop entries of asEntries, checking that the hop fields within can be parsed. If an parse error is found, the function immediately returns with an error.

func (*PathSegment) Write

func (ps *PathSegment) Write(b common.RawBytes) (int, error)

type PathSegmentSignedData

type PathSegmentSignedData struct {
	RawInfo common.RawBytes `capnp:"infoF"`
}

func NewPathSegmentSignedDataFromRaw

func NewPathSegmentSignedDataFromRaw(b common.RawBytes) (*PathSegmentSignedData, error)

func (*PathSegmentSignedData) InfoF

func (pss *PathSegmentSignedData) InfoF() (*spath.InfoField, error)

func (*PathSegmentSignedData) ProtoId

func (pss *PathSegmentSignedData) ProtoId() proto.ProtoIdType

func (*PathSegmentSignedData) String

func (pss *PathSegmentSignedData) String() string

func (*PathSegmentSignedData) Validate added in v0.3.0

func (pss *PathSegmentSignedData) Validate() error

type Segments added in v0.3.0

type Segments []*PathSegment

Segments is just a helper type to have additional methods on top of a slice of PathSegments.

func (*Segments) FilterSegs added in v0.3.0

func (segs *Segments) FilterSegs(keep func(*PathSegment) bool) int

FilterSegs filters the given segs and only keeps the segments for which keep returns true. Modifies segs in-place. Returns the number of segments filtered out.

func (*Segments) FilterSegsErr added in v0.4.0

func (segs *Segments) FilterSegsErr(keep func(*PathSegment) (bool, error)) (int, error)

FilterSegsErr filters the given segs and only keeps the segments for which keep returns true. Modifies segs in-place. Returns the number of segments filtered out. If keep returns an error the method is aborted and the error is returned, segs might have been modified.

func (Segments) FirstIAs added in v0.3.0

func (segs Segments) FirstIAs() []addr.IA

FirstIAs returns the slice of FirstIAs in the given segments. Each FirstIA appears just once.

func (Segments) LastIAs added in v0.3.0

func (segs Segments) LastIAs() []addr.IA

LastIAs returns the slice of LastIAs in the given segments. Each LastIA appears just once.

type Signer added in v0.4.0

type Signer interface {
	// Sign signs the packed segment and returns the signature meta data.
	Sign(packedSegment common.RawBytes) (*proto.SignS, error)
}

Signer signs path segments.

type ValidationMethod added in v0.4.0

type ValidationMethod bool

ValidationMethod is the method that is used during validation.

const (
	// ValidateSegment validates that remote ingress and egress ISD-AS for
	// each AS entry are consistent with the segment. The ingress ISD-AS of
	// the first entry, and the egress ISD-AS of the last entry must be the
	// zero value. Additionally, it is validated that each hop field is
	// parsable.
	ValidateSegment ValidationMethod = false
	// ValidateBeacon validates the segment in the same manner as
	// ValidateSegment, except for the last AS entry. The egress values for
	// the last AS entry are ignored, since they are under construction in
	// a beacon.
	ValidateBeacon ValidationMethod = true
)

type Verifier added in v0.4.0

type Verifier interface {
	// Verify verifies the packed segment based on the signature meta data.
	Verify(ctx context.Context, packedSegment common.RawBytes, sign *proto.SignS) error
}

Verifier verifies path segments.

Directories

Path Synopsis
Package mock_seg is a generated GoMock package.
Package mock_seg is a generated GoMock package.

Jump to

Keyboard shortcuts

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