seg

package
v0.6.0 Latest Latest
Warning

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

Go to latest
Published: Dec 4, 2020 License: Apache-2.0 Imports: 16 Imported by: 0

Documentation

Index

Constants

Path segment types.

Variables

This section is empty.

Functions

func PathSegmentToPB added in v0.6.0

func PathSegmentToPB(ps *PathSegment) *cppb.PathSegment

PathSegmentToPB translates a path segment to the protobuf encoding.

Types

type ASEntry

type ASEntry struct {
	// Signed contains the signed ASentry. It is used for signature input.
	Signed *cryptopb.SignedMessage
	// Local is the ISD-AS of the AS correspoding to this entry.
	Local addr.IA
	// Next is the ISD-AS of the downstream AS.
	Next addr.IA
	// HopEntry is the entry to create regular data plane paths.
	HopEntry HopEntry
	// PeerEntries is a list of entries to create peering data plane paths.
	PeerEntries []PeerEntry
	// MTU is the AS internal MTU.
	MTU int
	// Extensions holds all the beaconing extensions.
	Extensions Extensions
}

func ASEntryFromPB added in v0.6.0

func ASEntryFromPB(pb *cppb.ASEntry) (ASEntry, error)

ASEntryFromPB creates an AS entry from the protobuf representation.

type Extensions added in v0.6.0

type Extensions struct {
	HiddenPath HiddenPathExtension
	StaticInfo *staticinfo.Extension
}

type HiddenPathExtension added in v0.6.0

type HiddenPathExtension struct {
	IsHidden bool
}

type HopEntry

type HopEntry struct {
	// HopField contains the necessary information to create a data-plane hop.
	HopField HopField
	// IngressMTU is the MTU on the ingress link.
	IngressMTU int
}

type HopField added in v0.6.0

type HopField struct {
	ExpTime     uint8
	ConsIngress uint16
	ConsEgress  uint16
	MAC         []byte
}

type Info added in v0.6.0

type Info struct {
	// Raw contains the encoded path segment information. It is used for
	// signature input and must not be modified.
	Raw []byte
	// Timestamp is the path segment creation time.
	Timestamp time.Time
	// SegmentID is the segment ID used in data plane hop field computation.
	SegmentID uint16
}

Info represents the path segment information.

func NewInfo added in v0.6.0

func NewInfo(timestamp time.Time, segmentID uint16) (Info, error)

NewInfo creates a new path segment info.

func (Info) String added in v0.6.0

func (info Info) String() string

type Meta

type Meta struct {
	Segment *PathSegment
	Type    Type
}

Meta holds the path segment with its type.

type PathSegment

type PathSegment struct {
	Info Info
	// ASEntries is the list of AS entries. Call AddASEntry to extend the list.
	ASEntries []ASEntry
}

func BeaconFromPB added in v0.6.0

func BeaconFromPB(pb *cppb.PathSegment) (*PathSegment, error)

BeaconFromPB translates a protobuf path Beacon.

func CreateSegment added in v0.6.0

func CreateSegment(timestamp time.Time, segID uint16) (*PathSegment, error)

CreateSegment creates a new path segment. The AS entries should be added using AddASEntry.

func SegmentFromPB added in v0.6.0

func SegmentFromPB(pb *cppb.PathSegment) (*PathSegment, error)

SegmentFromPB translates a protobuf path segment.

func (*PathSegment) AddASEntry

func (ps *PathSegment) AddASEntry(ctx context.Context, asEntry ASEntry, signer Signer) error

AddASEntry adds the AS entry and signs the resulting path segment. The signature is created and does not need to be attached to the input AS entry.

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 path segment contains no ASEntries this method will panic.

func (*PathSegment) FullID added in v0.6.0

func (ps *PathSegment) FullID() []byte

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() []byte

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

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 path segment contains no ASEntries this method will panic.

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) MaxIdx added in v0.6.0

func (ps *PathSegment) MaxIdx() int

MaxIdx returns the index of the last AS entry.

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) 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) Verify added in v0.6.0

func (ps *PathSegment) Verify(ctx context.Context, verifier Verifier) error

Verify verifies each AS entry.

func (*PathSegment) VerifyASEntry

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

VerifyASEntry verifies the AS Entry at the specified index.

type PeerEntry added in v0.6.0

type PeerEntry struct {
	// HopField contains the necessary information to create a data-plane hop.
	HopField HopField
	// Peer is the ISD-AS of the peering AS.
	Peer addr.IA
	// PeerInterface is the interface ID of the peering link on the remote
	// peering AS side.
	PeerInterface uint16
	// PeerMTU is the MTU on the peering link.
	PeerMTU int
}

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, error)) (int, error)

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. 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 AS entry and returns the signature meta data.
	Sign(ctx context.Context, msg []byte, associatedData ...[]byte) (*cryptopb.SignedMessage, error)
}

Signer signs path segments.

type Type added in v0.6.0

type Type int

Type is the path segment type.

func (Type) String added in v0.6.0

func (t Type) String() string

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 AS entry based on the signature meta data.
	Verify(ctx context.Context, signedMsg *cryptopb.SignedMessage,
		associatedData ...[]byte) (*signed.Message, error)
}

Verifier verifies path segments.

Directories

Path Synopsis
extensions
staticinfo
Package staticinfo contains the internal representation of the StaticInfoExtension path segment extension, and conversion from and to the corresponding protobuf representation.
Package staticinfo contains the internal representation of the StaticInfoExtension path segment extension, and conversion from and to the corresponding protobuf representation.
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