addrs

package
v2.2.0+incompatible Latest Latest
Warning

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

Go to latest
Published: Aug 23, 2019 License: Apache-2.0 Imports: 6 Imported by: 0

Documentation

Overview

Package addrs contains helpers for ip and mac address conversion.

Index

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

func IsIPv6(addr string) (bool, error)

IsIPv6 returns true if provided IP address is IPv6, false otherwise

func MacIntToString

func MacIntToString(macInt uint64) string

MacIntToString converts MAC address string representation xx:xx:xx:xx:xx:xx

func ParseIPWithPrefix

func ParseIPWithPrefix(input string) (addr *net.IPNet, isIpv6 bool, err error)

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)

func StrAddrsToStruct

func StrAddrsToStruct(addrs []string) ([]*net.IPNet, error)

StrAddrsToStruct converts slice of strings representing ipv4 addresses to IPNet structures

Types

type SortedIPs

type SortedIPs []*net.IPNet

SortedIPs type is used to implement sort.Interface for slice of IPNet

func (SortedIPs) Len

func (arr SortedIPs) Len() int

Returns length of slice Implements sort.Interface

func (SortedIPs) Less

func (arr SortedIPs) Less(i, j int) bool

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

func (SortedIPs) Swap

func (arr SortedIPs) Swap(i, j int)

Swap swaps two items in slice identified by indexes Implements sort.Interface

Jump to

Keyboard shortcuts

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