ip

package
v1.15.0 Latest Latest
Warning

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

Go to latest
Published: Jan 27, 2024 License: Apache-2.0 Imports: 7 Imported by: 0

Documentation

Index

Constants

View Source
const (
	V4BitLen = 8 * net.IPv4len
	V6BitLen = 8 * net.IPv6len
)
View Source
const (
	ICMPProtocol   = 1
	IGMPProtocol   = 2
	TCPProtocol    = 6
	UDPProtocol    = 17
	ICMPv6Protocol = 58
	SCTPProtocol   = 132
)

Variables

This section is empty.

Functions

func AppendPortIfMissing added in v1.7.0

func AppendPortIfMissing(addr, port string) string

AppendPortIfMissing appends the given port to the address if the address doesn't contain any port.

func DiffFromCIDRs

func DiffFromCIDRs(allowCIDR *net.IPNet, exceptCIDRs []*net.IPNet) ([]*net.IPNet, error)

This function takes in one allow CIDR and multiple except CIDRs and gives diff CIDRs in allowCIDR eliminating except CIDRs. It currently supports only IPv4. except CIDR input can be changed.

func GetLocalBroadcastIP added in v1.4.0

func GetLocalBroadcastIP(ipNet *net.IPNet) net.IP

GetLocalBroadcastIP returns the last IP address in a subnet. This IP is always working as the broadcast address in the subnet on Windows, and an active route entry that uses it as the destination is added by default when a new IP is configured on the interface.

func IPNetContains added in v1.11.4

func IPNetContains(ipNet1, ipNet2 *net.IPNet) bool

IPNetContains returns if the first IPNet contains the second IPNet. For example:

10.0.0.0/24 contains 10.0.0.0/24. 10.0.0.0/24 contains 10.0.0.0/25. 10.0.0.0/24 contains 10.0.0.128/25. 10.0.0.0/24 does not contain 10.0.0.0/23. 10.0.0.0/24 does not contain 10.0.1.0/25.

func IPNetEqual added in v1.11.4

func IPNetEqual(ipNet1, ipNet2 *net.IPNet) bool

IPNetEqual returns if the provided IPNets are the same subnet.

func IPNetToNetIPNet

func IPNetToNetIPNet(ipNet *v1beta2.IPNet) *net.IPNet

IPNetToNetIPNet converts Antrea IPNet to *net.IPNet. Note that K8s allows non-standard CIDRs to be specified (e.g. 10.0.1.1/16, fe80::7015:efff:fe9a:146b/64). However, OVS will report OFPBMC_BAD_WILDCARDS error if using them in the OpenFlow messages. The function will normalize the CIDR if it's non-standard.

func IPProtocolNumberToString

func IPProtocolNumberToString(protocolNum uint8, defaultValue string) string

IPProtocolNumberToString returns the string name of the IP protocol with number protocolNum. If the number does not match a "known" protocol, we return the defaultValue string.

func MustIPv6 added in v1.3.0

func MustIPv6(s string) net.IP

func MustParseCIDR added in v1.2.1

func MustParseCIDR(cidr string) *net.IPNet

MustParseCIDR turns the given string into IPNet or panics, for tests or other cases where the string must be valid.

func MustParseMAC added in v1.12.3

func MustParseMAC(mac string) net.HardwareAddr

Types

type DualStackIPs added in v1.3.0

type DualStackIPs struct {
	IPv4 net.IP
	IPv6 net.IP
}

func (DualStackIPs) Equal added in v1.3.0

func (ips DualStackIPs) Equal(x DualStackIPs) bool

Jump to

Keyboard shortcuts

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