ip

package
v0.19.14 Latest Latest
Warning

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

Go to latest
Published: Sep 5, 2022 License: Apache-2.0 Imports: 11 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var NativeEndian binary.ByteOrder

NativeEndian is the ByteOrder of the current system.

Functions

func CheckIPv6Subnet added in v0.18.101

func CheckIPv6Subnet(subnetIP *IP6, mask *big.Int) bool

func DirectRouting added in v0.10.0

func DirectRouting(ip net.IP) (bool, error)
func EnsureV4AddressOnLink(ipa IP4Net, ipn IP4Net, link netlink.Link) error

EnsureV4AddressOnLink ensures that there is only one v4 Addr on `link` within the `ipn` address space and it equals `ipa`.

func EnsureV6AddressOnLink(ipa IP6Net, ipn IP6Net, link netlink.Link) error

EnsureV6AddressOnLink ensures that there is only one v6 Addr on `link` and it equals `ipn`. If there exist multiple addresses on link, it returns an error message to tell callers to remove additional address.

func GetDefaultGatewayInterface added in v0.18.101

func GetDefaultGatewayInterface() (*net.Interface, error)

func GetDefaultV6GatewayInterface added in v0.18.101

func GetDefaultV6GatewayInterface() (*net.Interface, error)

func GetInterfaceByIP

func GetInterfaceByIP(ip net.IP) (*net.Interface, error)

func GetInterfaceByIP6 added in v0.18.101

func GetInterfaceByIP6(ip net.IP) (*net.Interface, error)

func GetInterfaceBySpecificIPRouting added in v0.18.101

func GetInterfaceBySpecificIPRouting(ip net.IP) (*net.Interface, net.IP, error)

func GetInterfaceIP4AddrMatch added in v0.18.101

func GetInterfaceIP4AddrMatch(iface *net.Interface, matchAddr net.IP) error

func GetInterfaceIP4Addrs added in v0.18.101

func GetInterfaceIP4Addrs(iface *net.Interface) ([]net.IP, error)

func GetInterfaceIP6AddrMatch added in v0.18.101

func GetInterfaceIP6AddrMatch(iface *net.Interface, matchAddr net.IP) error

func GetInterfaceIP6Addrs added in v0.18.101

func GetInterfaceIP6Addrs(iface *net.Interface) ([]net.IP, error)

func IsEmpty added in v0.18.101

func IsEmpty(subnet *IP6) bool

func Mask added in v0.18.101

func Mask(prefixLen int) *big.Int

func NativelyLittle

func NativelyLittle() bool

func OpenTun

func OpenTun(name string) (*os.File, string, error)

Types

type IP4

type IP4 uint32

func FromBytes

func FromBytes(ip []byte) IP4

func FromIP

func FromIP(ip net.IP) IP4

func MustParseIP4 added in v0.5.6

func MustParseIP4(s string) IP4

func ParseIP4

func ParseIP4(s string) (IP4, error)

func (IP4) IsPrivate added in v0.18.101

func (ip IP4) IsPrivate() bool

IsPrivate reports whether ip is a private address, according to RFC 1918 (IPv4 addresses)

func (IP4) MarshalJSON

func (ip IP4) MarshalJSON() ([]byte, error)

MarshalJSON: json.Marshaler impl

func (IP4) NetworkOrder

func (ip IP4) NetworkOrder() uint32

func (IP4) Octets

func (ip IP4) Octets() (a, b, c, d byte)

func (IP4) String

func (ip IP4) String() string

func (IP4) StringSep

func (ip IP4) StringSep(sep string) string

func (IP4) ToIP

func (ip IP4) ToIP() net.IP

func (*IP4) UnmarshalJSON

func (ip *IP4) UnmarshalJSON(j []byte) error

UnmarshalJSON: json.Unmarshaler impl

type IP4Net

type IP4Net struct {
	IP        IP4
	PrefixLen uint
}

similar to net.IPNet but has uint based representation

func FromIPNet

func FromIPNet(n *net.IPNet) IP4Net

func (IP4Net) Contains

func (n IP4Net) Contains(ip IP4) bool

func (IP4Net) Empty added in v0.8.0

func (n IP4Net) Empty() bool

func (IP4Net) Equal

func (n IP4Net) Equal(other IP4Net) bool

func (*IP4Net) IncrementIP added in v0.18.101

func (n *IP4Net) IncrementIP()

IncrementIP() increments the IP of IP4Net CIDR by 1

func (IP4Net) MarshalJSON

func (n IP4Net) MarshalJSON() ([]byte, error)

MarshalJSON: json.Marshaler impl

func (IP4Net) Mask

func (n IP4Net) Mask() uint32

func (IP4Net) Network

func (n IP4Net) Network() IP4Net

func (IP4Net) Next

func (n IP4Net) Next() IP4Net

func (IP4Net) Overlaps

func (n IP4Net) Overlaps(other IP4Net) bool

func (IP4Net) String

func (n IP4Net) String() string

func (IP4Net) StringSep

func (n IP4Net) StringSep(octetSep, prefixSep string) string

func (IP4Net) ToIPNet

func (n IP4Net) ToIPNet() *net.IPNet

func (*IP4Net) UnmarshalJSON

func (n *IP4Net) UnmarshalJSON(j []byte) error

UnmarshalJSON: json.Unmarshaler impl

type IP6 added in v0.18.101

type IP6 big.Int

func FromIP16Bytes added in v0.18.101

func FromIP16Bytes(ip []byte) *IP6

func FromIP6 added in v0.18.101

func FromIP6(ip net.IP) *IP6

func GetIPv6SubnetMax added in v0.18.101

func GetIPv6SubnetMax(networkIP *IP6, subnetSize *big.Int) *IP6

func GetIPv6SubnetMin added in v0.18.101

func GetIPv6SubnetMin(networkIP *IP6, subnetSize *big.Int) *IP6

func MustParseIP6 added in v0.18.101

func MustParseIP6(s string) *IP6

func ParseIP6 added in v0.18.101

func ParseIP6(s string) (*IP6, error)

func (*IP6) Cmp added in v0.18.101

func (ip6 *IP6) Cmp(other *IP6) int

func (*IP6) IsPrivate added in v0.18.101

func (ip6 *IP6) IsPrivate() bool

IsPrivate reports whether ip is a private address, according to RFC 4193 (IPv6 addresses).

func (IP6) MarshalJSON added in v0.18.101

func (ip6 IP6) MarshalJSON() ([]byte, error)

MarshalJSON: json.Marshaler impl

func (IP6) String added in v0.18.101

func (ip6 IP6) String() string

func (*IP6) ToIP added in v0.18.101

func (ip6 *IP6) ToIP() net.IP

func (*IP6) UnmarshalJSON added in v0.18.101

func (ip6 *IP6) UnmarshalJSON(j []byte) error

UnmarshalJSON: json.Unmarshaler impl

type IP6Net added in v0.18.101

type IP6Net struct {
	IP        *IP6
	PrefixLen uint
}

similar to net.IPNet but has uint based representation

func FromIP6Net added in v0.18.101

func FromIP6Net(n *net.IPNet) IP6Net

func (IP6Net) Contains added in v0.18.101

func (n IP6Net) Contains(ip *IP6) bool

func (IP6Net) Empty added in v0.18.101

func (n IP6Net) Empty() bool

func (IP6Net) Equal added in v0.18.101

func (n IP6Net) Equal(other IP6Net) bool

func (*IP6Net) IncrementIP added in v0.18.101

func (n *IP6Net) IncrementIP()

IncrementIP() increments the IP of IP6Net CIDR by 1

func (IP6Net) MarshalJSON added in v0.18.101

func (n IP6Net) MarshalJSON() ([]byte, error)

MarshalJSON: json.Marshaler impl

func (IP6Net) Mask added in v0.18.101

func (n IP6Net) Mask() *big.Int

func (IP6Net) Network added in v0.18.101

func (n IP6Net) Network() IP6Net

func (IP6Net) Next added in v0.18.101

func (n IP6Net) Next() IP6Net

func (IP6Net) Overlaps added in v0.18.101

func (n IP6Net) Overlaps(other IP6Net) bool

func (IP6Net) String added in v0.18.101

func (n IP6Net) String() string

func (IP6Net) StringSep added in v0.18.101

func (n IP6Net) StringSep(hexSep, prefixSep string) string

func (IP6Net) ToIPNet added in v0.18.101

func (n IP6Net) ToIPNet() *net.IPNet

func (*IP6Net) UnmarshalJSON added in v0.18.101

func (n *IP6Net) UnmarshalJSON(j []byte) error

UnmarshalJSON: json.Unmarshaler impl

Jump to

Keyboard shortcuts

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