addr

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

Documentation

Overview

Package addr contains types for SCION addressing.

A SCION address is composed of the following parts: ISD (ISolation Domain identifier), AS (Autonomous System idenifier), and Host (the host address).

The allocations and formatting of ISDs and ASes are documented here: https://github.com/scionproto/scion/wiki/ISD-and-AS-numbering. Note that the ':' separator for AS formatting is not used in paths/filenames for compatibility reasons, so '_' is used instead in those contexts.

Index

Constants

View Source
const (
	HostLenNone = 0
	HostLenIPv4 = net.IPv4len
	HostLenIPv6 = net.IPv6len
	HostLenSVC  = 2
)
View Source
const (
	IABytes       = 8
	ISDBits       = 16
	ASBits        = 48
	BGPASBits     = 32
	MaxISD    ISD = (1 << ISDBits) - 1
	MaxAS     AS  = (1 << ASBits) - 1
	MaxBGPAS  AS  = (1 << BGPASBits) - 1

	ISDFmtPrefix = "ISD"
	ASFmtPrefix  = "AS"
)

Variables

View Source
var (
	// ErrBadHostAddrType indicates an invalid host address type.
	ErrBadHostAddrType = serrors.New("unsupported host address type")
	// ErrMalformedHostAddrType indicates a malformed host address type.
	ErrMalformedHostAddrType = serrors.New("malformed host address type")
	// ErrUnsupportedSVCAddress indicates an unsupported SVC address.
	ErrUnsupportedSVCAddress = serrors.New("unsupported SVC address")
)

Functions

func HostLen

func HostLen(htype HostAddrType) (uint8, error)

func HostTypeCheck

func HostTypeCheck(t HostAddrType) bool

Types

type AS

type AS uint64

AS is the Autonomous System idenifier. See formatting and allocations here: https://github.com/scionproto/scion/wiki/ISD-and-AS-numbering#as-numbers

func ASFromFileFmt

func ASFromFileFmt(s string, prefix bool) (AS, error)

ASFromFileFmt parses an AS from a file-format string. This is the same format as ASFromString expects, with ':' replaced by '_'. If prefix is true, an 'AS' prefix is expected and stripped before parsing.

func ASFromString

func ASFromString(s string) (AS, error)

ASFromString parses an AS from a decimal (in the case of the 32bit BGP AS number space) or ipv6-style hex (in the case of SCION-only AS numbers) string.

func (AS) FileFmt

func (as AS) FileFmt() string

FileFmt formats an AS for use in a file name, using '_' instead of ':' as the separator for SCION-only AS numbers.

func (AS) MarshalText added in v0.4.0

func (as AS) MarshalText() ([]byte, error)

func (AS) String

func (as AS) String() string

func (*AS) UnmarshalText added in v0.4.0

func (as *AS) UnmarshalText(text []byte) error

type HostAddr

type HostAddr interface {
	Size() int
	Type() HostAddrType
	Pack() common.RawBytes
	IP() net.IP
	Copy() HostAddr
	Equal(HostAddr) bool
	fmt.Stringer
}

func HostFromIP

func HostFromIP(ip net.IP) HostAddr

func HostFromIPStr added in v0.3.1

func HostFromIPStr(s string) HostAddr

func HostFromRaw

func HostFromRaw(b common.RawBytes, htype HostAddrType) (HostAddr, error)

type HostAddrType

type HostAddrType uint8
const (
	HostTypeNone HostAddrType = iota
	HostTypeIPv4
	HostTypeIPv6
	HostTypeSVC
)

func (HostAddrType) String

func (t HostAddrType) String() string

type HostIPv4

type HostIPv4 net.IP

func (HostIPv4) Copy

func (h HostIPv4) Copy() HostAddr

func (HostIPv4) Equal added in v0.4.0

func (h HostIPv4) Equal(o HostAddr) bool

func (HostIPv4) IP

func (h HostIPv4) IP() net.IP

func (HostIPv4) Pack

func (h HostIPv4) Pack() common.RawBytes

func (HostIPv4) Size

func (h HostIPv4) Size() int

func (HostIPv4) String

func (h HostIPv4) String() string

func (HostIPv4) Type

func (h HostIPv4) Type() HostAddrType

type HostIPv6

type HostIPv6 net.IP

func (HostIPv6) Copy

func (h HostIPv6) Copy() HostAddr

func (HostIPv6) Equal added in v0.4.0

func (h HostIPv6) Equal(o HostAddr) bool

func (HostIPv6) IP

func (h HostIPv6) IP() net.IP

func (HostIPv6) Pack

func (h HostIPv6) Pack() common.RawBytes

func (HostIPv6) Size

func (h HostIPv6) Size() int

func (HostIPv6) String

func (h HostIPv6) String() string

func (HostIPv6) Type

func (h HostIPv6) Type() HostAddrType

type HostNone

type HostNone net.IP

func (HostNone) Copy

func (h HostNone) Copy() HostAddr

func (HostNone) Equal added in v0.4.0

func (h HostNone) Equal(o HostAddr) bool

func (HostNone) IP

func (h HostNone) IP() net.IP

func (HostNone) Pack

func (h HostNone) Pack() common.RawBytes

func (HostNone) Size

func (h HostNone) Size() int

func (HostNone) String

func (h HostNone) String() string

func (HostNone) Type

func (h HostNone) Type() HostAddrType

type HostSVC

type HostSVC uint16
const (
	SvcDS       HostSVC = 0x0001
	SvcCS       HostSVC = 0x0002
	SvcSB       HostSVC = 0x0003
	SvcSIG      HostSVC = 0x0004
	SvcHPS      HostSVC = 0x0005
	SvcWildcard HostSVC = 0x0010
	SvcNone     HostSVC = 0xffff

	SVCMcast HostSVC = 0x8000
)

func HostSVCFromString

func HostSVCFromString(str string) HostSVC

HostSVCFromString returns the SVC address corresponding to str. For anycast SVC addresses, use BS_A, PS_A, CS_A, and SB_A; shorthand versions without the _A suffix (e.g., PS) also return anycast SVC addresses. For multicast, use BS_M, PS_M, CS_M, and SB_M.

func (HostSVC) Base

func (h HostSVC) Base() HostSVC

func (HostSVC) BaseString added in v0.4.0

func (h HostSVC) BaseString() string

BaseString returns the upper case name of the service. For hosts or unrecognized services, it returns UNKNOWN.

func (HostSVC) Copy

func (h HostSVC) Copy() HostAddr

func (HostSVC) Equal added in v0.4.0

func (h HostSVC) Equal(o HostAddr) bool

func (HostSVC) IP

func (h HostSVC) IP() net.IP

func (HostSVC) IsMulticast

func (h HostSVC) IsMulticast() bool

func (HostSVC) Multicast

func (h HostSVC) Multicast() HostSVC

func (HostSVC) Network added in v0.6.0

func (h HostSVC) Network() string

func (HostSVC) Pack

func (h HostSVC) Pack() common.RawBytes

func (HostSVC) PackWithPad added in v0.6.0

func (h HostSVC) PackWithPad(pad int) []byte

func (HostSVC) Size

func (h HostSVC) Size() int

func (HostSVC) String

func (h HostSVC) String() string

func (HostSVC) Type

func (h HostSVC) Type() HostAddrType

type IA

type IA struct {
	I ISD
	A AS
}

IA represents the ISD (ISolation Domain) and AS (Autonomous System) Id of a given SCION AS.

func IAFromFileFmt

func IAFromFileFmt(s string, prefixes bool) (IA, error)

IAFromFileFmt parses an IA from a file-format

func IAFromRaw

func IAFromRaw(b common.RawBytes) IA

func IAFromString

func IAFromString(s string) (IA, error)

IAFromString parses an IA from a string of the format 'ia-as'.

func (IA) Equal added in v0.4.0

func (ia IA) Equal(other IA) bool

func (IA) FileFmt

func (ia IA) FileFmt(prefixes bool) string

FileFmt returns a file-system friendly representation of ia. If prefixes is true, the format will be in the form of ISD%d-AS%d. If it is false, the format is just %d-%d.

func (IA) IAInt

func (ia IA) IAInt() IAInt

func (IA) IsWildcard added in v0.4.0

func (ia IA) IsWildcard() bool

IsWildcard returns whether the ia has a wildcard part (isd or as).

func (IA) IsZero

func (ia IA) IsZero() bool

func (IA) MarshalText

func (ia IA) MarshalText() ([]byte, error)

func (*IA) Parse

func (ia *IA) Parse(b common.RawBytes)

func (*IA) Set added in v0.4.0

func (ia *IA) Set(s string) error

Set implements flag.Value interface

func (IA) String

func (ia IA) String() string

func (*IA) UnmarshalText

func (ia *IA) UnmarshalText(text []byte) error

UnmarshalText allows IA to be used as a map key in JSON.

func (IA) Write

func (ia IA) Write(b common.RawBytes)

type IAInt

type IAInt uint64

IAInt is an integer representation of an ISD-AS.

func (IAInt) IA

func (iaI IAInt) IA() IA

func (IAInt) MarshalText added in v0.6.0

func (ia IAInt) MarshalText() ([]byte, error)

func (IAInt) String added in v0.2.0

func (iaI IAInt) String() string

func (*IAInt) UnmarshalText added in v0.6.0

func (ia *IAInt) UnmarshalText(b []byte) error

type ISD

type ISD uint16

ISD is the ISolation Domain identifier. See formatting and allocations here: https://github.com/scionproto/scion/wiki/ISD-and-AS-numbering#isd-numbers

func ISDFromFileFmt

func ISDFromFileFmt(s string, prefix bool) (ISD, error)

ISDFromFileFmt parses an ISD from a file-format string. If prefix is true, an 'ISD' prefix is expected and stripped before parsing.

func ISDFromString

func ISDFromString(s string) (ISD, error)

ISDFromString parses an ISD from a decimal string.

func (ISD) String added in v0.4.0

func (isd ISD) String() string

Jump to

Keyboard shortcuts

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