net

package
v0.0.3-pre7 Latest Latest
Warning

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

Go to latest
Published: Jan 22, 2021 License: Apache-2.0 Imports: 12 Imported by: 18

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func BigEndianToLocal

func BigEndianToLocal(input []byte) []byte

BigEndianToLocal converts input from big endian to "local" endian

func Htons

func Htons(x uint16) uint16

Htons converts a local short uint to an network order short uint

func StrToAddr

func StrToAddr(x string) (uint32, error)

StrToAddr converts an IP address string to it's uint32 representation

Types

type IP

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

IP represents an IPv4 or IPv6 address

func IPFromBytes

func IPFromBytes(b []byte) (IP, error)

IPFromBytes returns an IP address for a byte slice

func IPFromProtoIP

func IPFromProtoIP(addr *api.IP) *IP

IPFromProtoIP creates an IP address from a proto IP

func IPFromString

func IPFromString(str string) (IP, error)

IPFromString returns an IP address for a given string

func IPv4

func IPv4(val uint32) IP

IPv4 returns a new `IP` representing an IPv4 address

func IPv4FromBytes

func IPv4FromBytes(b []byte) IP

IPv4FromBytes creates an IPv4 Address from one or more bytes. Missing bytes are filled with zero bytes.

func IPv4FromOctets

func IPv4FromOctets(o1, o2, o3, o4 uint8) IP

IPv4FromOctets returns an IPv4 address for the given 4 octets

func IPv6

func IPv6(higher, lower uint64) IP

IPv6 returns a new `IP` representing an IPv6 address

func IPv6FromBlocks

func IPv6FromBlocks(b1, b2, b3, b4, b5, b6, b7, b8 uint16) IP

IPv6FromBlocks returns an IPv6 address for the given 8 blocks

func (*IP) BitAtPosition

func (ip *IP) BitAtPosition(pos uint8) bool

BitAtPosition returns the bit at position pos

func (*IP) Bytes

func (ip *IP) Bytes() []byte

Bytes returns the byte representation of an IP address

func (*IP) Compare

func (ip *IP) Compare(other *IP) int8

Compare compares two IP addresses (returns 0 if equal, -1 if `ip` is smaller than `other`, 1 if `ip` is greater than `other`)

func (IP) Dedup

func (ip IP) Dedup() *IP

Dedup gets a copy of IP from the cache

func (*IP) Equal

func (ip *IP) Equal(other *IP) bool

Equal returns true if ip is equal to other

func (*IP) Higher

func (ip *IP) Higher() uint64

Higher gets the higher half of the IP address

func (*IP) IsIPv4

func (ip *IP) IsIPv4() bool

IsIPv4 returns if the `IP` is of address family IPv4

func (*IP) Lower

func (ip *IP) Lower() uint64

Lower gets the lower half of the IP address

func (*IP) MaskLastNBits

func (ip *IP) MaskLastNBits(n uint8) *IP

MaskLastNBits masks the last n bits of an IP address

func (*IP) Next

func (ip *IP) Next() *IP

Next gets the next ip address

func (IP) Ptr

func (ip IP) Ptr() *IP

Ptr returns a pointer to ip

func (*IP) SizeBytes

func (ip *IP) SizeBytes() uint8

SizeBytes returns the number of bytes required to represent the `IP`

func (*IP) String

func (ip *IP) String() string

String returns string representation of an IP address

func (*IP) ToNetIP

func (ip *IP) ToNetIP() net.IP

ToNetIP converts the IP address in a `net.IP`

func (IP) ToProto

func (ip IP) ToProto() *api.IP

ToProto converts an IP to a proto IP

func (*IP) ToUint32

func (ip *IP) ToUint32() uint32

ToUint32 return the rightmost 32 bits of an 'IP'

type Prefix

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

Prefix represents an IPv4 prefix

func NewPfx

func NewPfx(addr IP, pfxlen uint8) Prefix

NewPfx creates a new Prefix

func NewPfxFromIPNet

func NewPfxFromIPNet(ipNet *gonet.IPNet) *Prefix

NewPfxFromIPNet creates a Prefix object from an gonet.IPNet object

func NewPrefixFromProtoPrefix

func NewPrefixFromProtoPrefix(pfx *api.Prefix) *Prefix

NewPrefixFromProtoPrefix creates a Prefix from a proto Prefix

func PrefixFromString

func PrefixFromString(s string) (*Prefix, error)

PrefixFromString converts prefix from string representation to Prefix

func (*Prefix) Addr

func (pfx *Prefix) Addr() *IP

Addr returns the address of the prefix

func (*Prefix) BaseAddr

func (p *Prefix) BaseAddr() *IP

BaseAddr gets the base address of the prefix

func (*Prefix) Contains

func (pfx *Prefix) Contains(x *Prefix) bool

Contains checks if x is a subnet of or equal to pfx

func (Prefix) Dedup

func (p Prefix) Dedup() *Prefix

Dedup gets a copy of Prefix from the cache. If Prefix is not in the cache it gets added.

func (*Prefix) Equal

func (pfx *Prefix) Equal(x *Prefix) bool

Equal checks if pfx and x are equal

func (*Prefix) GetIPNet

func (pfx *Prefix) GetIPNet() *gonet.IPNet

GetIPNet returns the gonet.IP object for a Prefix object

func (*Prefix) GetSupernet

func (pfx *Prefix) GetSupernet(x *Prefix) Prefix

GetSupernet gets the next common supernet of pfx and x

func (*Prefix) Pfxlen

func (pfx *Prefix) Pfxlen() uint8

Pfxlen returns the length of the prefix

func (Prefix) Ptr

func (p Prefix) Ptr() *Prefix

Ptr returns a pointer to p

func (*Prefix) String

func (pfx *Prefix) String() string

String returns a string representation of pfx

func (Prefix) ToProto

func (p Prefix) ToProto() *api.Prefix

ToProto converts prefix to proto prefix

func (*Prefix) Valid

func (p *Prefix) Valid() bool

Valid checks if all bits outside of the prefix lengths range are zero (no host bit set)

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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