topology

package
v0.3.0 Latest Latest
Warning

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

Go to latest
Published: Sep 19, 2018 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   = "Unsupported overlay"
	ErrUnsupportedAddrType  = "Unsupported address type"
	ErrInvalidPub           = "Invalid public address"
	ErrInvalidBind          = "Invalid bind adress"
	ErrAtLeastOnePub        = "Overlay requires at least one public address"
	ErrOverlayPort          = "Overlay port set for non-UDP overlay"
	ErrBindAddrEqPubAddr    = "Bind address equal to Public address"
	ErrMismatchOverlayAddr  = "Mismatch overlay type and address"
	ErrMismatchPubAddrType  = "Mismatch public address and type "
	ErrMismatchBindAddrType = "Mismatch bind address and type"
)
View Source
const (
	ErrorOpen    = "Unable to open topology"
	ErrorParse   = "Unable to parse topology from JSON"
	ErrorConvert = "Unable to convert RawTopo to Topo"
)
View Source
const (
	CoreLinkName   = "CORE"
	ParentLinkName = "PARENT"
	ChildLinkName  = "CHILD"
	PeerLinkName   = "PEER"
)
View Source
const CfgName = "topology.json"

Variables

This section is empty.

Functions

func LinkTypeFromString

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

func StripBind

func StripBind(rt *RawTopo)

func StripServices

func StripServices(rt *RawTopo)

Types

type BRInfo

type BRInfo struct {
	IFIDs []common.IFIDType
}

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 {
	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 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
	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"`
	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.
	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 map[common.IFIDType]IFInfo

	BS      IDAddrMap
	BSNames ServiceNames
	CS      IDAddrMap
	CSNames ServiceNames
	PS      IDAddrMap
	PSNames ServiceNames
	SB      IDAddrMap
	SBNames ServiceNames
	RS      IDAddrMap
	RSNames ServiceNames
	DS      IDAddrMap
	DSNames 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 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

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

func TopoFromRaw

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

Convert a JSON-filled RawTopo to a Topo usabled by Go code.

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 (*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

Jump to

Keyboard shortcuts

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