ip

package
v0.0.0-...-a131276 Latest Latest
Warning

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

Go to latest
Published: Dec 23, 2017 License: Apache-2.0 Imports: 4 Imported by: 0

Documentation

Overview

The ip package contains yet another IP address (and CIDR) type :-). The types differ from the ones in the net package in that they are backed by fixed-sized arrays of the appropriate size. The key advantage of using a fixed-size array is that it makes the types hashable so they can be used as map keys. In addition, they can be converted to net.IP by slicing.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Addr

type Addr interface {
	// Version returns the IP version; 4 or 6.
	Version() uint8
	// AsNetIP returns a net.IP, which is backed by/shares storage with
	// this object.
	AsNetIP() net.IP
	AsCalicoNetIP() calinet.IP
	String() string
}

Addr represents either an IPv4 or IPv6 IP address.

func FromNetIP

func FromNetIP(netIP net.IP) Addr

func FromString

func FromString(s string) Addr

type CIDR

type CIDR interface {
	Version() uint8
	Addr() Addr
	Prefix() uint8
	String() string
	ToIPNet() net.IPNet
}

func CIDRFromCalicoNet

func CIDRFromCalicoNet(ipNet calinet.IPNet) CIDR

func CIDRFromIPNet

func CIDRFromIPNet(ipNet *net.IPNet) CIDR

func MustParseCIDR

func MustParseCIDR(s string) CIDR

type V4Addr

type V4Addr [4]byte

func (V4Addr) AsCalicoNetIP

func (a V4Addr) AsCalicoNetIP() calinet.IP

func (V4Addr) AsNetIP

func (a V4Addr) AsNetIP() net.IP

func (V4Addr) String

func (a V4Addr) String() string

func (V4Addr) Version

func (a V4Addr) Version() uint8

type V4CIDR

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

func (V4CIDR) Addr

func (c V4CIDR) Addr() Addr

func (V4CIDR) Prefix

func (c V4CIDR) Prefix() uint8

func (V4CIDR) String

func (c V4CIDR) String() string

func (V4CIDR) ToIPNet

func (c V4CIDR) ToIPNet() net.IPNet

func (V4CIDR) Version

func (c V4CIDR) Version() uint8

type V6Addr

type V6Addr [16]byte

func (V6Addr) AsCalicoNetIP

func (a V6Addr) AsCalicoNetIP() calinet.IP

func (V6Addr) AsNetIP

func (a V6Addr) AsNetIP() net.IP

func (V6Addr) String

func (a V6Addr) String() string

func (V6Addr) Version

func (a V6Addr) Version() uint8

type V6CIDR

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

func (V6CIDR) Addr

func (c V6CIDR) Addr() Addr

func (V6CIDR) Prefix

func (c V6CIDR) Prefix() uint8

func (V6CIDR) String

func (c V6CIDR) String() string

func (V6CIDR) ToIPNet

func (c V6CIDR) ToIPNet() net.IPNet

func (V6CIDR) Version

func (c V6CIDR) Version() uint8

Jump to

Keyboard shortcuts

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