topology

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: 12 Imported by: 0

Documentation

Overview

Package topology wraps two versions of the topology. The first is RawTopo (in raw.go), which closely matches the JSON format. It is mainly used for loading the topology from disk. The second data structure is Topo. It is used by Go code directly and thus has a different structure and stricter types.

Index

Constants

View Source
const (
	ErrUnsupportedOverlay   common.ErrMsg = "Unsupported overlay"
	ErrUnsupportedAddrType  common.ErrMsg = "Unsupported address type"
	ErrInvalidPub           common.ErrMsg = "Invalid public address"
	ErrInvalidBind          common.ErrMsg = "Invalid bind address"
	ErrAtLeastOnePub        common.ErrMsg = "Overlay requires at least one public address"
	ErrOverlayPort          common.ErrMsg = "Overlay port set for non-UDP overlay"
	ErrBindAddrEqPubAddr    common.ErrMsg = "Bind address equal to Public address"
	ErrMismatchOverlayAddr  common.ErrMsg = "Mismatch overlay type and address"
	ErrMismatchPubAddrType  common.ErrMsg = "Mismatch public address and type "
	ErrMismatchBindAddrType common.ErrMsg = "Mismatch bind address and type"
)
View Source
const (
	ErrOpen    common.ErrMsg = "Unable to open topology"
	ErrParse   common.ErrMsg = "Unable to parse topology from JSON"
	ErrConvert common.ErrMsg = "Unable to convert RawTopo to Topo"
)
View Source
const (
	// CoreLinkName indicates a link going to a neighboring core AS.
	CoreLinkName = "CORE"
	// ParentLinkName indicates a link to a parent AS.
	ParentLinkName = "PARENT"
	// ChildLinkName indicates a link to a child AS.
	ChildLinkName = "CHILD"
	// PeerLinkName indicates a link to a neighboring peer AS.
	PeerLinkName = "PEER"
)
View Source
const CfgName = "topology.json"

Variables

This section is empty.

Functions

func LinkTypeFromString

func LinkTypeFromString(s string) (proto.LinkType, error)

LinkTypeFromString parses the link type.

func StripBind

func StripBind(rt *RawTopo)

func StripServices

func StripServices(rt *RawTopo)

Types

type BRInfo

type BRInfo struct {
	Name string
	// CtrlAddrs are the local control-plane addresses.
	CtrlAddrs *TopoAddr
	// InternalAddrs are the local data-plane addresses.
	InternalAddrs *TopoBRAddr
	// IFIDs is a sorted list of the interface IDs.
	IFIDs []common.IFIDType
	// IFs is a map of interface IDs.
	IFs map[common.IFIDType]*IFInfo
}

BRInfo is a list of AS-wide unique interface IDs for a router. These IDs are also used to point to the specific internal address clients should send their traffic to in order to use that interface, via the IFInfoMap member of the Topo struct.

type IDAddrMap added in v0.3.0

type IDAddrMap map[string]TopoAddr

func (IDAddrMap) GetById added in v0.3.0

func (m IDAddrMap) GetById(id string) *TopoAddr

GetById returns the TopoAddr for the given ID, or nil if there is none.

type IFInfo

type IFInfo struct {
	// Id is the interface ID. It is unique per AS.
	Id            common.IFIDType
	BRName        string
	CtrlAddrs     *TopoAddr
	Overlay       overlay.Type
	InternalAddrs *TopoBRAddr
	Local         *TopoBRAddr
	Remote        *overlay.OverlayAddr
	RemoteIFID    common.IFIDType
	Bandwidth     int
	ISD_AS        addr.IA
	LinkType      proto.LinkType
	MTU           int
}

IFInfo describes a border router link to another AS, including the internal address applications should send traffic for the link to (InternalAddrs) and information about the link itself and the remote side of it.

func (IFInfo) String

func (i IFInfo) String() string

func (IFInfo) Verify added in v0.3.0

func (i IFInfo) Verify(isCore bool, brName string) error

type IfInfoMap added in v0.4.0

type IfInfoMap map[common.IFIDType]IFInfo

IfInfoMap maps interface ids to the interface information.

type OverBindAddr added in v0.4.0

type OverBindAddr struct {
	PublicOverlay *overlay.OverlayAddr
	BindOverlay   *overlay.OverlayAddr
}

func (*OverBindAddr) BindOrPublicOverlay added in v0.4.0

func (t *OverBindAddr) BindOrPublicOverlay() *overlay.OverlayAddr

func (*OverBindAddr) Equal added in v0.4.0

func (t1 *OverBindAddr) Equal(t2 *OverBindAddr) bool

func (*OverBindAddr) String added in v0.4.0

func (a *OverBindAddr) String() string

type Provider added in v0.4.0

type Provider interface {
	// Get returns a topology. The returned topology is guaranteed to not be
	// nil.
	Get() *Topo
}

Provider provides a topology.

type RawAddr added in v0.3.0

type RawAddr struct {
	Addr string
}

func (RawAddr) String added in v0.3.0

func (a RawAddr) String() string

type RawAddrMap added in v0.3.0

type RawAddrMap map[string]*RawPubBindOverlay

func (RawAddrMap) String added in v0.3.0

func (ram RawAddrMap) String() string

func (RawAddrMap) ToTopoAddr added in v0.3.0

func (ram RawAddrMap) ToTopoAddr(ot overlay.Type) (t *TopoAddr, err error)

type RawAddrOverlay added in v0.3.0

type RawAddrOverlay struct {
	Addr        string
	OverlayPort int `json:",omitempty"`
}

func (RawAddrOverlay) String added in v0.3.0

func (a RawAddrOverlay) String() string

type RawAddrPort

type RawAddrPort struct {
	Addr   string
	L4Port int
}

func (RawAddrPort) String

func (a RawAddrPort) String() string

type RawAddrPortOverlay

type RawAddrPortOverlay struct {
	RawAddrPort
	OverlayPort int `json:",omitempty"`
}

Since Public addresses may be associated with an Overlay port, extend the structure used for Bind addresses.

func (RawAddrPortOverlay) String

func (a RawAddrPortOverlay) String() string

type RawBRAddrMap added in v0.3.0

type RawBRAddrMap map[string]*RawOverlayBind

func (RawBRAddrMap) String added in v0.3.0

func (roa RawBRAddrMap) String() string

func (RawBRAddrMap) ToTopoBRAddr added in v0.3.0

func (roa RawBRAddrMap) ToTopoBRAddr(ot overlay.Type) (t *TopoBRAddr, err error)

type RawBRInfo

type RawBRInfo struct {
	InternalAddrs RawBRAddrMap
	CtrlAddr      RawAddrMap
	Interfaces    map[common.IFIDType]*RawBRIntf
}

RawBRInfo contains Border Router specific information.

func (RawBRInfo) String

func (b RawBRInfo) String() string

type RawBRIntf

type RawBRIntf struct {
	Overlay       string          `json:",omitempty"`
	PublicOverlay *RawAddrOverlay `json:",omitempty"`
	BindOverlay   *RawAddr        `json:",omitempty"`
	RemoteOverlay *RawAddrOverlay `json:",omitempty"`
	Bandwidth     int
	ISD_AS        string
	LinkTo        string
	MTU           int
}

type RawOverlayBind added in v0.3.0

type RawOverlayBind struct {
	PublicOverlay RawAddrOverlay
	BindOverlay   *RawAddr `json:",omitempty"`
}

func (RawOverlayBind) String added in v0.3.0

func (b RawOverlayBind) String() string

type RawPubBindOverlay added in v0.3.0

type RawPubBindOverlay struct {
	Public RawAddrPortOverlay
	Bind   *RawAddrPort `json:",omitempty"`
}

func (RawPubBindOverlay) String added in v0.3.0

func (rpbo RawPubBindOverlay) String() string

type RawSrvInfo added in v0.3.0

type RawSrvInfo struct {
	Addrs RawAddrMap
}

func (RawSrvInfo) String added in v0.3.0

func (ras RawSrvInfo) String() string

type RawTopo

type RawTopo struct {
	Timestamp          int64
	TimestampHuman     string
	TTL                uint32
	ISD_AS             string
	Overlay            string
	MTU                int
	Core               bool
	BorderRouters      map[string]*RawBRInfo  `json:",omitempty"`
	ZookeeperService   map[int]*RawAddrPort   `json:",omitempty"`
	BeaconService      map[string]*RawSrvInfo `json:",omitempty"`
	CertificateService map[string]*RawSrvInfo `json:",omitempty"`
	PathService        map[string]*RawSrvInfo `json:",omitempty"`
	SibraService       map[string]*RawSrvInfo `json:",omitempty"`
	RainsService       map[string]*RawSrvInfo `json:",omitempty"`
	SIG                map[string]*RawSrvInfo `json:",omitempty"`
	DiscoveryService   map[string]*RawSrvInfo `json:",omitempty"`
}

RawTopo is used to un/marshal from/to JSON and should usually not be used by Go code directly. Use Topo (from lib/topology/topology.go) instead.

func LoadRaw

func LoadRaw(b common.RawBytes) (*RawTopo, error)

func LoadRawFromFile

func LoadRawFromFile(path string) (*RawTopo, error)

type ServiceNames added in v0.3.0

type ServiceNames []string

func (ServiceNames) GetRandom added in v0.3.0

func (s ServiceNames) GetRandom() (string, error)

GetRandom returns a random entry, or an error if the slice is empty.

type Topo

type Topo struct {
	Timestamp      time.Time
	TimestampHuman string // This can vary wildly in format and is only for informational purposes.
	TTL            time.Duration
	ISD_AS         addr.IA
	Overlay        overlay.Type
	MTU            int
	Core           bool

	BR      map[string]BRInfo
	BRNames []string
	// This maps Interface IDs to internal addresses. Clients use this to
	// figure out which internal BR address they have to send their traffic to
	// if they want to use a given interface.
	IFInfoMap IfInfoMap

	BS       IDAddrMap
	BSNames  ServiceNames
	CS       IDAddrMap
	CSNames  ServiceNames
	PS       IDAddrMap
	PSNames  ServiceNames
	SB       IDAddrMap
	SBNames  ServiceNames
	RS       IDAddrMap
	RSNames  ServiceNames
	DS       IDAddrMap
	DSNames  ServiceNames
	SIG      IDAddrMap
	SIGNames ServiceNames

	ZK map[int]*addr.AppAddr
}

Topo is the main struct encompassing topology information for use in Go code. The first section contains metadata about the topology. All of these fields should be self-explanatory. The unit of TTL is seconds, with the zero value indicating an infinite TTL.

The second section concerns the Border routers. BRNames is just a sorted slice of the names of the BRs in this topolgy. Its contents is exactly the same as the keys in the BR map.

The BR map points from border router names to BRInfo structs, which in turn are lists of IFID type slices, thus defines the IFIDs that belong to a particular border router. The IFInfoMap points from interface IDs to IFInfo structs.

The third section in Topo concerns the SCION-specific services in the topology. The structure is identical between the various elements. For each service, there is again a sorted slice of names of the servers that provide the service. Additionally, there is a map from those names to TopoAddr structs.

func Load

func Load(b common.RawBytes) (*Topo, error)

func LoadFromFile

func LoadFromFile(path string) (*Topo, error)

func NewTopo

func NewTopo() *Topo

NewTopo creates new empty Topo object, including all possible service maps etc.

func TopoFromRaw

func TopoFromRaw(raw *RawTopo) (*Topo, error)

TopoFromRaw converts a JSON-filled RawTopo to a Topo usable by Go code.

func (*Topo) Active added in v0.4.0

func (t *Topo) Active(now time.Time) bool

func (*Topo) Expiry added in v0.4.0

func (t *Topo) Expiry() time.Time

Expiry returns the expiration time of the topology. If TTL is zero, the zero value is returned.

func (*Topo) GetAllTopoAddrs added in v0.3.1

func (t *Topo) GetAllTopoAddrs(svc proto.ServiceType) ([]TopoAddr, error)

func (*Topo) GetAnyTopoAddr added in v0.4.0

func (t *Topo) GetAnyTopoAddr(svc proto.ServiceType) (*TopoAddr, error)

func (*Topo) GetTopoAddr

func (t *Topo) GetTopoAddr(id string, svc proto.ServiceType) (*TopoAddr, error)

type TopoAddr

type TopoAddr struct {
	IPv4    *pubBindAddr
	IPv6    *pubBindAddr
	Overlay overlay.Type
}

TopoAddr wraps the possible addresses of a SCION service and describes the overlay to be used for contacting said service.

func TestTopoAddr added in v0.3.1

func TestTopoAddr(v4AppAddr, v6AppAddr *addr.AppAddr,
	v4OverlayAddr, v6OverlayAddr *overlay.OverlayAddr) TopoAddr

TestTopoAddr creates a new TopoAddr. This is only for testing and should never be used by apps.

func (*TopoAddr) BindAddr added in v0.2.0

func (t *TopoAddr) BindAddr(ot overlay.Type) *addr.AppAddr

func (*TopoAddr) BindOrPublic added in v0.2.0

func (t *TopoAddr) BindOrPublic(ot overlay.Type) *addr.AppAddr

func (*TopoAddr) Equal

func (t *TopoAddr) Equal(o *TopoAddr) bool

func (*TopoAddr) OverlayAddr added in v0.2.0

func (t *TopoAddr) OverlayAddr(ot overlay.Type) *overlay.OverlayAddr

func (*TopoAddr) PublicAddr added in v0.2.0

func (t *TopoAddr) PublicAddr(ot overlay.Type) *addr.AppAddr

func (*TopoAddr) String

func (t *TopoAddr) String() string

type TopoBRAddr added in v0.3.0

type TopoBRAddr struct {
	IPv4    *OverBindAddr
	IPv6    *OverBindAddr
	Overlay overlay.Type
}

func (*TopoBRAddr) BindOrPublicOverlay added in v0.3.0

func (t *TopoBRAddr) BindOrPublicOverlay(ot overlay.Type) *overlay.OverlayAddr

func (*TopoBRAddr) BindOverlay added in v0.3.0

func (t *TopoBRAddr) BindOverlay(ot overlay.Type) *overlay.OverlayAddr

func (*TopoBRAddr) Equal added in v0.3.0

func (t *TopoBRAddr) Equal(o *TopoBRAddr) bool

func (*TopoBRAddr) PublicOverlay added in v0.3.0

func (t *TopoBRAddr) PublicOverlay(ot overlay.Type) *overlay.OverlayAddr

func (*TopoBRAddr) String added in v0.3.0

func (t *TopoBRAddr) String() string

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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