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
- func LinkTypeFromString(s string) (proto.LinkType, error)
- func StripBind(rt *RawTopo)
- func StripServices(rt *RawTopo)
- type BRInfo
- type IDAddrMap
- type IFInfo
- type RawAddr
- type RawAddrMap
- type RawAddrOverlay
- type RawAddrPort
- type RawAddrPortOverlay
- type RawBRAddrMap
- type RawBRInfo
- type RawBRIntf
- type RawOverlayBind
- type RawPubBindOverlay
- type RawSrvInfo
- type RawTopo
- type SVCInfo
- type ServiceNames
- type Topo
- type TopoAddr
- func (t *TopoAddr) BindAddr(ot overlay.Type) *addr.AppAddr
- func (t *TopoAddr) BindOrPublic(ot overlay.Type) *addr.AppAddr
- func (t *TopoAddr) Equal(o *TopoAddr) bool
- func (t *TopoAddr) OverlayAddr(ot overlay.Type) *overlay.OverlayAddr
- func (t *TopoAddr) PublicAddr(ot overlay.Type) *addr.AppAddr
- func (t *TopoAddr) String() string
- type TopoBRAddr
- func (t *TopoBRAddr) BindOrPublicOverlay(ot overlay.Type) *overlay.OverlayAddr
- func (t *TopoBRAddr) BindOverlay(ot overlay.Type) *overlay.OverlayAddr
- func (t *TopoBRAddr) Equal(o *TopoBRAddr) bool
- func (t *TopoBRAddr) PublicOverlay(ot overlay.Type) *overlay.OverlayAddr
- func (t *TopoBRAddr) String() string
Constants ¶
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" )
const ( ErrorOpen = "Unable to open topology" ErrorParse = "Unable to parse topology from JSON" ErrorConvert = "Unable to convert RawTopo to Topo" )
const ( CoreLinkName = "CORE" ParentLinkName = "PARENT" ChildLinkName = "CHILD" PeerLinkName = "PEER" )
const CfgName = "topology.json"
Variables ¶
This section is empty.
Functions ¶
func StripServices ¶
func StripServices(rt *RawTopo)
Types ¶
type BRInfo ¶
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 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.
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
func (RawAddrOverlay) String ¶ added in v0.3.0
func (a RawAddrOverlay) String() string
type RawAddrPort ¶
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.
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 LoadRawFromFile ¶
type SVCInfo ¶ added in v0.3.1
type SVCInfo struct {
// contains filtered or unexported fields
}
SVCInfo contains topology information for a single SCION service
func (*SVCInfo) GetAllTopoAddrs ¶ added in v0.3.1
func (*SVCInfo) GetAnyTopoAddr ¶ added in v0.3.1
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 LoadFromFile ¶
func NewTopo ¶
func NewTopo() *Topo
Create new empty Topo object, including all possible service maps etc.
func TopoFromRaw ¶
Convert a JSON-filled RawTopo to a Topo usabled by Go code.
func (*Topo) GetAllTopoAddrs ¶ added in v0.3.1
func (t *Topo) GetAllTopoAddrs(svc proto.ServiceType) ([]TopoAddr, error)
func (*Topo) GetSvcInfo ¶ added in v0.3.1
func (t *Topo) GetSvcInfo(svc proto.ServiceType) (*SVCInfo, error)
type TopoAddr ¶
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) BindOrPublic ¶ added in v0.2.0
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
type TopoBRAddr ¶ added in v0.3.0
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