addr

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: 7 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    = (1 << ISDBits) - 1
	MaxAS     = (1 << ASBits) - 1
	MaxBGPAS  = (1 << BGPASBits) - 1

	ISDFmtPrefix = "ISD"
	ASFmtPrefix  = "AS"
)
View Source
const (
	ErrorBadHostAddrType = "Unsupported host address type"
)
View Source
const SVCMcast = 0x8000

Variables

This section is empty.

Functions

func HostLen

func HostLen(htype HostAddrType) (uint8, error)

func HostTypeCheck

func HostTypeCheck(t HostAddrType) bool

func IsIPv4

func IsIPv4(ip net.IP) bool

IsIPv4 returns whether the ip is IPv4 or not. This has the side effect in Go that if the ip passed was the direct result of net.IPv4(), it will fail to detect it as an IPv4 given that the underlying byte buffer is 16B.

func IsIPv6

func IsIPv6(ip net.IP) 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) String

func (as AS) String() string

type AppAddr added in v0.2.0

type AppAddr struct {
	L3 HostAddr
	L4 L4Info
}

func NewSVCUDPAppAddr added in v0.2.0

func NewSVCUDPAppAddr(svc HostSVC) *AppAddr

func (*AppAddr) Copy added in v0.2.0

func (a *AppAddr) Copy() *AppAddr

func (*AppAddr) Eq added in v0.2.0

func (a *AppAddr) Eq(o *AppAddr) bool

func (*AppAddr) EqType added in v0.2.0

func (a *AppAddr) EqType(o *AppAddr) bool

func (*AppAddr) Network added in v0.2.0

func (a *AppAddr) Network() string

func (*AppAddr) String added in v0.2.0

func (a *AppAddr) String() string

type HostAddr

type HostAddr interface {
	Size() int
	Type() HostAddrType
	Pack() common.RawBytes
	IP() net.IP
	Copy() HostAddr
	Eq(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) Eq added in v0.2.0

func (h HostIPv4) Eq(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) Eq added in v0.2.0

func (h HostIPv6) Eq(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) Eq added in v0.2.0

func (h HostNone) Eq(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 (
	SvcBS   HostSVC = 0x0000
	SvcPS   HostSVC = 0x0001
	SvcCS   HostSVC = 0x0002
	SvcSB   HostSVC = 0x0003
	SvcNone HostSVC = 0xffff
)

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) Copy

func (h HostSVC) Copy() HostAddr

func (HostSVC) Eq added in v0.2.0

func (h HostSVC) Eq(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) Pack

func (h HostSVC) Pack() common.RawBytes

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) Eq

func (ia IA) Eq(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) 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) String

func (ia IA) String() string

func (*IA) UnmarshalText

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

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) String added in v0.2.0

func (iaI IAInt) String() string

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.

type L4Info added in v0.2.0

type L4Info interface {
	Size() int
	Type() common.L4ProtocolType
	Port() uint16
	Copy() L4Info
	Eq(L4Info) bool
	String() string
}

func NewL4SCMPInfo added in v0.2.0

func NewL4SCMPInfo() L4Info

func NewL4TCPInfo added in v0.3.0

func NewL4TCPInfo(p uint16) L4Info

func NewL4UDPInfo added in v0.2.0

func NewL4UDPInfo(p uint16) L4Info

Jump to

Keyboard shortcuts

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