sciond

package
v0.3.1 Latest Latest
Warning

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

Go to latest
Published: Sep 24, 2018 License: Apache-2.0 Imports: 22 Imported by: 0

Documentation

Overview

Package sciond queries local SCIOND servers for information.

To query SCIOND, initialize a Service object by passing in the path to the UNIX socket. It is then possible to establish connections to SCIOND by calling Connect or ConnectTimeout on the service. The connections implement interface Connector, whose methods can be used to talk to SCIOND.

Connector method calls return the entire answer of SCIOND.

Fields prefixed with Raw (e.g., RawErrorCode) contain data in the format received from SCIOND. These are used internally, and the accessors without the prefix (e.g., ErrorCode()) should be used instead.

Index

Constants

View Source
const (
	ASInfoTTL  = time.Hour
	IFInfoTTL  = time.Hour
	SVCInfoTTL = 10 * time.Second
	// DefaultSCIONDPath contains the system default for a SCIOND socket.
	DefaultSCIONDPath = "/run/shm/sciond/default.sock"
)

Time to live for cache entries

Variables

This section is empty.

Functions

func GetDefaultSCIONDPath

func GetDefaultSCIONDPath(ia *addr.IA) string

GetDefaultSCIONDPath return default sciond path for a given IA

Types

type ASInfoReply

type ASInfoReply struct {
	Entries []ASInfoReplyEntry
}

type ASInfoReplyEntry

type ASInfoReplyEntry struct {
	RawIsdas addr.IAInt `capnp:"isdas"`
	Mtu      uint16
	IsCore   bool
}

func (*ASInfoReplyEntry) ISD_AS

func (entry *ASInfoReplyEntry) ISD_AS() addr.IA

func (ASInfoReplyEntry) String

func (entry ASInfoReplyEntry) String() string

type ASInfoReq

type ASInfoReq struct {
	Isdas addr.IAInt
}

type Adapter

type Adapter struct{}

func (*Adapter) MsgKey

func (a *Adapter) MsgKey(msg proto.Cerealizable) string

func (*Adapter) MsgToRaw

func (a *Adapter) MsgToRaw(msg proto.Cerealizable) (common.RawBytes, error)

func (*Adapter) RawToMsg

func (a *Adapter) RawToMsg(b common.RawBytes) (proto.Cerealizable, error)

type Connector

type Connector interface {
	// Paths requests from SCIOND a set of end to end paths between src and
	// dst. max specifices the maximum number of paths returned.
	Paths(dst, src addr.IA, max uint16, f PathReqFlags) (*PathReply, error)
	PathsCtx(ctx context.Context, dst, src addr.IA, max uint16, f PathReqFlags) (*PathReply, error)
	// ASInfo requests from SCIOND information about AS ia.
	ASInfo(ia addr.IA) (*ASInfoReply, error)
	ASInfoCtx(ctx context.Context, ia addr.IA) (*ASInfoReply, error)
	// IFInfo requests from SCIOND addresses and ports of interfaces.  Slice
	// ifs contains interface IDs of BRs. If empty, a fresh (i.e., uncached)
	// answer containing all interfaces is returned.
	IFInfo(ifs []common.IFIDType) (*IFInfoReply, error)
	IFInfoCtx(ctx context.Context, ifs []common.IFIDType) (*IFInfoReply, error)
	// SVCInfo requests from SCIOND information about addresses and ports of
	// infrastructure services.  Slice svcTypes contains a list of desired
	// service types. If unset, a fresh (i.e., uncached) answer containing all
	// service types is returned.
	SVCInfo(svcTypes []proto.ServiceType) (*ServiceInfoReply, error)
	SVCInfoCtx(ctx context.Context, svcTypes []proto.ServiceType) (*ServiceInfoReply, error)
	// RevNotification sends a raw revocation to SCIOND, as contained in an
	// SCMP message.
	RevNotificationFromRaw(b []byte) (*RevReply, error)
	RevNotificationFromRawCtx(ctx context.Context, b []byte) (*RevReply, error)
	// RevNotification sends a RevocationInfo message to SCIOND.
	RevNotification(sRevInfo *path_mgmt.SignedRevInfo) (*RevReply, error)
	RevNotificationCtx(ctx context.Context, sRevInfo *path_mgmt.SignedRevInfo) (*RevReply, error)
	// Close shuts down the connection to a SCIOND server.
	Close() error
	CloseCtx(ctx context.Context) error
}

A Connector is used to query SCIOND. The connector maintains an internal cache for interface, service and AS information. All connector methods block until either an error occurs, or the method successfully returns.

type FwdPathMeta

type FwdPathMeta struct {
	FwdPath    []byte
	Mtu        uint16
	Interfaces []PathInterface
	ExpTime    uint32
}

func (*FwdPathMeta) DstIA

func (fpm *FwdPathMeta) DstIA() addr.IA

func (*FwdPathMeta) Expiry

func (fpm *FwdPathMeta) Expiry() time.Time

func (*FwdPathMeta) SrcIA

func (fpm *FwdPathMeta) SrcIA() addr.IA

func (*FwdPathMeta) String

func (fpm *FwdPathMeta) String() string

type HostInfo

type HostInfo struct {
	Port  uint16
	Addrs struct {
		Ipv4 []byte
		Ipv6 []byte
	}
}

func HostInfoFromHostAddr

func HostInfoFromHostAddr(host addr.HostAddr, port uint16) *HostInfo

func HostInfoFromTopoAddr added in v0.3.1

func HostInfoFromTopoAddr(topoAddr topology.TopoAddr) HostInfo

func HostInfoFromTopoBRAddr added in v0.3.1

func HostInfoFromTopoBRAddr(topoBRAddr topology.TopoBRAddr) HostInfo

func (*HostInfo) Host

func (h *HostInfo) Host() addr.HostAddr

func (*HostInfo) Overlay added in v0.2.0

func (h *HostInfo) Overlay() (*overlay.OverlayAddr, error)

func (*HostInfo) String added in v0.2.0

func (h *HostInfo) String() string

type IFInfoReply

type IFInfoReply struct {
	RawEntries []IFInfoReplyEntry `capnp:"entries"`
}

func (*IFInfoReply) Entries

func (reply *IFInfoReply) Entries() map[common.IFIDType]HostInfo

Entries maps IFIDs to their addresses and ports; the map is rebuilt each time.

type IFInfoReplyEntry

type IFInfoReplyEntry struct {
	IfID     common.IFIDType
	HostInfo HostInfo
}

type IFInfoRequest

type IFInfoRequest struct {
	IfIDs []common.IFIDType
}

type MockConn

type MockConn struct {
	// contains filtered or unexported fields
}

MockConn represents a mock SCIOND Connector. See the documentation of MockService for more information about how to use MockConn. MockConn is safe for use from multiple goroutines.

func (*MockConn) ASInfo

func (m *MockConn) ASInfo(ia addr.IA) (*ASInfoReply, error)

ASInfo is not implemented.

func (*MockConn) ASInfoCtx added in v0.2.0

func (m *MockConn) ASInfoCtx(ctx context.Context, ia addr.IA) (*ASInfoReply, error)

ASInfoCtx is not implemented.

func (*MockConn) Close

func (m *MockConn) Close() error

Close is a no-op.

func (*MockConn) CloseCtx added in v0.2.0

func (m *MockConn) CloseCtx(ctx context.Context) error

CloseCtx is a no-op.

func (*MockConn) IFInfo

func (m *MockConn) IFInfo(ifs []common.IFIDType) (*IFInfoReply, error)

IFInfo is not implemented.

func (*MockConn) IFInfoCtx added in v0.2.0

func (m *MockConn) IFInfoCtx(ctx context.Context, ifs []common.IFIDType) (*IFInfoReply, error)

IFInfoCtx is not implemented.

func (*MockConn) Paths

func (m *MockConn) Paths(dst, src addr.IA, max uint16, f PathReqFlags) (*PathReply, error)

Paths returns the minimum-length paths from src to dst. If no path exists, the error code in the PathReply is set to ErrorNoPaths. If more than one minimum-length path exists, all minimum-length paths are returned.

Paths does not guarantee to represent a consistent snapshot of the SCION network if the backing multigraph is modified while Paths is running.

func (*MockConn) PathsCtx added in v0.2.0

func (m *MockConn) PathsCtx(ctx context.Context, dst, src addr.IA, max uint16,
	f PathReqFlags) (*PathReply, error)

PathsCtx is not implemented.

func (*MockConn) RevNotification

func (m *MockConn) RevNotification(sRevInfo *path_mgmt.SignedRevInfo) (*RevReply, error)

RevNotification deletes the edge containing revInfo.IfID from the multigraph. RevNotification does not perform any validation of revInfo.

func (*MockConn) RevNotificationCtx added in v0.2.0

func (m *MockConn) RevNotificationCtx(ctx context.Context,
	sRevInfo *path_mgmt.SignedRevInfo) (*RevReply, error)

RevNotificationCtx is not implemented.

func (*MockConn) RevNotificationFromRaw

func (m *MockConn) RevNotificationFromRaw(b []byte) (*RevReply, error)

RevNotificationFromRaw is not implemented.

func (*MockConn) RevNotificationFromRawCtx added in v0.2.0

func (m *MockConn) RevNotificationFromRawCtx(ctx context.Context, b []byte) (*RevReply, error)

RevNotificationFromRawCtx is not implemented.

func (*MockConn) SVCInfo

func (m *MockConn) SVCInfo(svcTypes []proto.ServiceType) (*ServiceInfoReply, error)

SVCInfo is not implemented.

func (*MockConn) SVCInfoCtx added in v0.2.0

func (m *MockConn) SVCInfoCtx(ctx context.Context,
	svcTypes []proto.ServiceType) (*ServiceInfoReply, error)

SVCInfoCtx is not implemented.

func (*MockConn) SetDeadline

func (m *MockConn) SetDeadline(t time.Time) error

SetDeadline is a no-op.

type MockService

type MockService struct {
	// contains filtered or unexported fields
}

MockService represents a mock SCIOND service for use in testing, backed by an undirected multigraph. Connectors returned by method Connect will respond to Paths queries by exploring the graph. The graph does not care about AS types, so any connected sequence of ASes is a valid path. The shortest path is always returned. If multiple shortest paths exist, they are all returned. Cycles are not allowed in returned paths.

Revocations are supported. The mock considers all revocations valid without checking, and revoking an IFID results in its corresponding edge being deleted from the graph.

The graph is concurrency safe, so it is also possible to directly add or delete edges as the test is running (e.g., to manually force path changes or revocations).

For an example, see go/lib/pathmgr/pathmgr_test.go.

func NewMockService

func NewMockService(g *graph.Graph) *MockService

NewMockService returns a mock SCIOND service on top of a SCION network graph.

func (*MockService) Connect

func (m *MockService) Connect() (Connector, error)

func (*MockService) ConnectTimeout

func (m *MockService) ConnectTimeout(timeout time.Duration) (Connector, error)

type PathErrorCode

type PathErrorCode uint16
const (
	ErrorOk PathErrorCode = iota
	ErrorNoPaths
	ErrorPSTimeout
	ErrorInternal
	ErrorBadSrcIA
	ErrorBadDstIA
)

func (PathErrorCode) String

func (c PathErrorCode) String() string

type PathInterface

type PathInterface struct {
	RawIsdas addr.IAInt `capnp:"isdas"`
	IfID     common.IFIDType
}

func (*PathInterface) ISD_AS

func (iface *PathInterface) ISD_AS() addr.IA

func (PathInterface) String

func (iface PathInterface) String() string

type PathReply

type PathReply struct {
	ErrorCode PathErrorCode
	Entries   []PathReplyEntry
}

type PathReplyEntry

type PathReplyEntry struct {
	Path     *FwdPathMeta
	HostInfo HostInfo
}

type PathReq

type PathReq struct {
	Dst      addr.IAInt
	Src      addr.IAInt
	MaxPaths uint16
	Flags    PathReqFlags
}

func (*PathReq) Copy

func (pathReq *PathReq) Copy() *PathReq

type PathReqFlags

type PathReqFlags struct {
	Refresh bool
}

type Pld

type Pld struct {
	Id                 uint64
	Which              proto.SCIONDMsg_Which
	PathReq            PathReq
	PathReply          PathReply
	AsInfoReq          ASInfoReq
	AsInfoReply        ASInfoReply
	RevNotification    RevNotification
	RevReply           RevReply
	IfInfoRequest      IFInfoRequest
	IfInfoReply        IFInfoReply
	ServiceInfoRequest ServiceInfoRequest
	ServiceInfoReply   ServiceInfoReply
}

func NewPldFromRaw

func NewPldFromRaw(b common.RawBytes) (*Pld, error)

func (*Pld) ProtoId

func (p *Pld) ProtoId() proto.ProtoIdType

func (*Pld) String

func (p *Pld) String() string

type RevNotification

type RevNotification struct {
	SRevInfo *path_mgmt.SignedRevInfo
}

type RevReply

type RevReply struct {
	Result RevResult
}

type RevResult

type RevResult uint16
const (
	RevValid RevResult = iota
	RevStale
	RevInvalid
	RevUnknown
)

func (RevResult) String

func (c RevResult) String() string

type Service

type Service interface {
	// Connect connects to the SCIOND server described by Service. Future
	// method calls on the returned Connector request information from SCIOND.
	// The information is not guaranteed to be fresh, as the returned connector
	// caches ASInfo replies for ASInfoTTL time, IFInfo replies for IFInfoTTL
	// time and SVCInfo for SVCInfoTTL time.
	Connect() (Connector, error)
	// ConnectTimeout acts like Connect but takes a timeout.
	//
	// A negative timeout means infinite timeout.
	//
	// To check for timeout errors, type assert the returned error to
	// *net.OpError and call method Timeout().
	ConnectTimeout(timeout time.Duration) (Connector, error)
}

Service describes a SCIOND endpoint. New connections to SCIOND can be initialized via Connect and ConnectTimeout.

func NewService

func NewService(name string) Service

type ServiceInfoReply

type ServiceInfoReply struct {
	Entries []ServiceInfoReplyEntry
}

type ServiceInfoReplyEntry

type ServiceInfoReplyEntry struct {
	ServiceType proto.ServiceType
	Ttl         uint32
	HostInfos   []HostInfo
}

type ServiceInfoRequest

type ServiceInfoRequest struct {
	ServiceTypes []proto.ServiceType
}

Jump to

Keyboard shortcuts

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