Documentation ¶
Overview ¶
Package addrs contains helpers for ip and mac address conversion.
Index ¶
- func DiffAddr(newConfig []*net.IPNet, oldConfig []*net.IPNet) (toBeDeleted []*net.IPNet, toBeAdded []*net.IPNet)
- func IsIPv6(addr string) (bool, error)
- func MacIntToString(macInt uint64) string
- func ParseIPWithPrefix(input string) (addr *net.IPNet, isIpv6 bool, err error)
- func StrAddrsToStruct(addrs []string) ([]*net.IPNet, error)
- type SortedIPs
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func DiffAddr ¶
func DiffAddr(newConfig []*net.IPNet, oldConfig []*net.IPNet) (toBeDeleted []*net.IPNet, toBeAdded []*net.IPNet)
DiffAddr calculates the difference between two slices of AddrWithPrefix configuration. Returns a list of addresses that should be deleted and added to the current configuration to match newConfig.
func IsIPv6 ¶
IsIPv6 returns true if provided IP address is IPv6, false otherwise
func MacIntToString ¶
MacIntToString converts MAC address string representation xx:xx:xx:xx:xx:xx
func ParseIPWithPrefix ¶
ParseIPWithPrefix parses string representation of ip address into net.IPNet structure. If the prefix is missing default one is added (/32 for IPv4, /128 for IPv6)
Types ¶
type SortedIPs ¶
SortedIPs type is used to implement sort.Interface for slice of IPNet
func (SortedIPs) Len ¶
Returns length of slice Implements sort.Interface
func (SortedIPs) Less ¶
Less returns true if the item in slice at index i in slice should be sorted before the element with index j Implements sort.Interface