netutils

package
v0.0.0-...-a17b09b Latest Latest
Warning

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

Go to latest
Published: Sep 22, 2016 License: Apache-2.0 Imports: 15 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func ClearBitsOutsideRange

func ClearBitsOutsideRange(ipAllocMap *bitset.BitSet, ipRange string, subnetLen uint)

ClearBitsOutsideRange sets all IPs outside range as used

func ClearReservedEntries

func ClearReservedEntries(b *bitset.BitSet, subnetLen uint)

ClearReservedEntries clears reserved bits

func ConvertBandwidth

func ConvertBandwidth(bandwidth string) int64

ConvertBandwidth will change the format of the bandwidth to int64 format and return the updated bw. eg:- 2 kb bandwidth will be converted to 2*1024 and the result in Int64 format will be returned.

func CreateBitset

func CreateBitset(numBitsWide uint) *bitset.BitSet

CreateBitset initializes a bit set with 2^numBitsWide bits

func GetFirstLocalAddr

func GetFirstLocalAddr() (string, error)

GetFirstLocalAddr returns the first ip address

func GetHostIntfName

func GetHostIntfName(intf string) string

GetHostIntfName gets the host access interface name

func GetIPAddrRange

func GetIPAddrRange(ipCIDR string, subnetLen uint) string

GetIPAddrRange returns IP CIDR as a ip address range

func GetIPNumber

func GetIPNumber(subnetIP string, subnetLen uint, allocSubnetLen uint, hostIP string) (uint, error)

GetIPNumber obtains the host id from the host IP. SEe `GetSubnetIP` for more information.

func GetIPv6HostID

func GetIPv6HostID(subnetAddr string, subnetLen uint, hostAddr string) (string, error)

GetIPv6HostID obtains the host id from the host IP. SEe `GetSubnetIP` for more information.

func GetInterfaceIP

func GetInterfaceIP(linkName string) (string, error)

GetInterfaceIP obtains the ip addr of a local interface on the host.

func GetLocalAddrList

func GetLocalAddrList() ([]string, error)

GetLocalAddrList returns a list of local IP addresses

func GetMyAddr

func GetMyAddr() (string, error)

GetMyAddr returns ip address of current host

func GetNetlinkAddrList

func GetNetlinkAddrList() ([]string, error)

GetNetlinkAddrList returns a list of local IP addresses

func GetNextIPv6HostID

func GetNextIPv6HostID(hostID, subnetAddr string, subnetLen uint, IPv6AllocMap map[string]bool) (string, error)

GetNextIPv6HostID returns the next available hostId in the AllocMap

func GetSubnetAddr

func GetSubnetAddr(ipStr string, length uint) string

GetSubnetAddr returns a subnet given a subnet range

func GetSubnetIP

func GetSubnetIP(subnetIP string, subnetLen uint, allocSubnetLen, hostID uint) (string, error)

GetSubnetIP given a subnet IP and host identifier, calculates an IP within the subnet for use.

func GetSubnetIPv6

func GetSubnetIPv6(subnetAddr string, subnetLen uint, hostID string) (string, error)

GetSubnetIPv6 given a subnet IP and host identifier, calculates an IPv6 address within the subnet for use.

func HostIfToIP

func HostIfToIP(hostIf string) (string, error)

HostIfToIP gets IP based on ifname

func InitSubnetBitset

func InitSubnetBitset(b *bitset.BitSet, subnetLen uint)

InitSubnetBitset initializes a bit set with 2^(32 - subnetLen) bits

func IsAddrLocal

func IsAddrLocal(findAddr string) bool

IsAddrLocal check if an address is local

func IsIPv6

func IsIPv6(ip string) bool

IsIPv6 Checks if the address string is IPv6 address

func IsOverlappingSubnet

func IsOverlappingSubnet(inputSubnet string, existingSubnet string) bool

IsOverlappingSubnet verifies the Overlapping of subnet

func IsOverlappingSubnetv6

func IsOverlappingSubnetv6(inputIPv6Subnet string, existingIPv6Subnet string) bool

IsOverlappingSubnetv6 verifies the Overlapping of subnet for v6 networks

func ParseCIDR

func ParseCIDR(cidrStr string) (string, uint, error)

ParseCIDR parses a CIDR string into a gateway IP and length.

func PortToHostIPMAC

func PortToHostIPMAC(port int) (string, string)

PortToHostIPMAC gets IP and MAC based on port number

func ReserveIPv6HostID

func ReserveIPv6HostID(hostID string, IPv6AllocMap *map[string]bool)

ReserveIPv6HostID sets the hostId in the AllocMap

func SetBitsOutsideRange

func SetBitsOutsideRange(ipAllocMap *bitset.BitSet, ipRange string, subnetLen uint)

SetBitsOutsideRange sets all IPs outside range as used

func SetIPMasquerade

func SetIPMasquerade(intf, netmask string) error

SetIPMasquerade sets a ip masquerade rule.

func SetInterfaceIP

func SetInterfaceIP(name string, ipstr string) error

SetInterfaceIP : Set IP address of an interface

func SetInterfaceMac

func SetInterfaceMac(name string, macaddr string) error

SetInterfaceMac : Set mac address of an interface

func ValidateNetworkRangeParams

func ValidateNetworkRangeParams(ipRange string, subnetLen uint) error

ValidateNetworkRangeParams verifies the network range format

Types

type TagRange

type TagRange struct {
	Min int
	Max int
}

TagRange represents a range of integers, intended for VLAN and VXLAN tagging.

func ParseTagRanges

func ParseTagRanges(ranges string, tagType string) ([]TagRange, error)

ParseTagRanges takes a string such as 12-24,48-64 and turns it into a series of TagRange.

Jump to

Keyboard shortcuts

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