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
- Variables
- func FormatAS(as AS, opts ...FormatOption) string
- func FormatIA(ia IA, opts ...FormatOption) string
- func FormatISD(isd ISD, opts ...FormatOption) string
- func HostLen(htype HostAddrType) (uint8, error)
- func HostTypeCheck(t HostAddrType) bool
- type AS
- type FormatOption
- type HostAddr
- type HostAddrType
- type HostIPv4
- type HostIPv6
- type HostNone
- type HostSVC
- func (h HostSVC) Base() HostSVC
- func (h HostSVC) BaseString() string
- func (h HostSVC) Copy() HostAddr
- func (h HostSVC) Equal(o HostAddr) bool
- func (h HostSVC) IP() net.IP
- func (h HostSVC) IsMulticast() bool
- func (h HostSVC) Multicast() HostSVC
- func (h HostSVC) Network() string
- func (h HostSVC) Pack() []byte
- func (h HostSVC) PackWithPad(pad int) []byte
- func (h HostSVC) Size() int
- func (h HostSVC) String() string
- func (h HostSVC) Type() HostAddrType
- type IA
- type ISD
Constants ¶
const ( HostLenNone = 0 HostLenIPv4 = net.IPv4len HostLenIPv6 = net.IPv6len HostLenSVC = 2 )
Variables ¶
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 FormatAS ¶ added in v0.7.0
func FormatAS(as AS, opts ...FormatOption) string
FormatAS formats the AS number.
func FormatIA ¶ added in v0.7.0
func FormatIA(ia IA, opts ...FormatOption) string
FormatIA formats the ISD-AS.
func FormatISD ¶ added in v0.7.0
func FormatISD(isd ISD, opts ...FormatOption) string
FormatISD formats the ISD number.
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 identifier. See formatting and allocations here: https://github.com/scionproto/scion/wiki/ISD-and-AS-numbering#as-numbers
func ParseAS ¶ added in v0.7.0
ParseAS 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 ParseFormattedAS ¶ added in v0.7.0
func ParseFormattedAS(as string, opts ...FormatOption) (AS, error)
ParseFormattedAS parses an AS number that was formatted with the FormatAS function. The same options must be provided to successfully parse.
func (AS) MarshalText ¶ added in v0.4.0
func (*AS) UnmarshalText ¶ added in v0.4.0
type FormatOption ¶ added in v0.7.0
type FormatOption func(*formatOptions)
func WithDefaultPrefix ¶ added in v0.7.0
func WithDefaultPrefix() FormatOption
WithDefaultPrefix enables the default prefix which depends on the type. For the AS number, the prefix is 'AS'. For the ISD number, the prefix is 'ISD'.
func WithFileSeparator ¶ added in v0.7.0
func WithFileSeparator() FormatOption
WithFileSeparator returns an option that sets the separator to underscore.
func WithSeparator ¶ added in v0.7.0
func WithSeparator(separator string) FormatOption
WithSeparator sets the separator to use for formatting AS numbers. In case of the empty string, the ':' is used.
type HostAddr ¶
type HostAddr interface { Size() int Type() HostAddrType Pack() []byte IP() net.IP Copy() HostAddr Equal(HostAddr) bool fmt.Stringer }
func HostFromIP ¶
func HostFromIPStr ¶ added in v0.3.1
func HostFromRaw ¶
func HostFromRaw(b []byte, 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 HostSVC ¶
type HostSVC uint16
func HostSVCFromString ¶
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) BaseString ¶ added in v0.4.0
BaseString returns the upper case name of the service. For hosts or unrecognized services, it returns UNKNOWN.
func (HostSVC) IsMulticast ¶
func (HostSVC) PackWithPad ¶ added in v0.6.0
func (HostSVC) Type ¶
func (h HostSVC) Type() HostAddrType
type IA ¶
type IA uint64
IA represents the ISD (ISolation Domain) and AS (Autonomous System) Id of a given SCION AS. The highest 16 bit form the ISD number and the lower 48 bits form the AS number.
func MustIAFrom ¶ added in v0.7.0
MustIAFrom creates an IA from the ISD and AS number. It panics if any error is encountered. Callers must ensure that the values passed to this function are valid.
func ParseFormattedIA ¶ added in v0.7.0
func ParseFormattedIA(ia string, opts ...FormatOption) (IA, error)
ParseFormattedIA parses an IA that was formatted with the FormatIA function. The same options must be provided to successfully parse.
func (IA) IsWildcard ¶ added in v0.4.0
IsWildcard returns whether the ia has a wildcard part (isd or as).
func (IA) MarshalText ¶
func (*IA) UnmarshalText ¶
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 ParseFormattedISD ¶ added in v0.7.0
func ParseFormattedISD(isd string, opts ...FormatOption) (ISD, error)
ParseFormattedISD parses an ISD number that was formatted with the FormatISD function. The same options must be provided to successfully parse.