netutils

package
v0.1.0 Latest Latest
Warning

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

Go to latest
Published: Jul 8, 2015 License: Apache-2.0, BSD-2-Clause Imports: 13 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var (
	// ErrNetworkOverlapsWithNameservers preformatted error
	ErrNetworkOverlapsWithNameservers = errors.New("requested network overlaps with nameserver")
	// ErrNetworkOverlaps preformatted error
	ErrNetworkOverlaps = errors.New("requested network overlaps with existing network")
	// ErrNoDefaultRoute preformatted error
	ErrNoDefaultRoute = errors.New("no default route")
)

Functions

func ATo16

func ATo16(array []byte) uint16

ATo16 converts a byte array into a uint16

func ATo32

func ATo32(array []byte) uint32

ATo32 converts a byte array into a uint32

func ATo64

func ATo64(array []byte) uint64

ATo64 converts a byte array into a uint32

func CheckNameserverOverlaps

func CheckNameserverOverlaps(nameservers []string, toCheck *net.IPNet) error

CheckNameserverOverlaps checks whether the passed network overlaps with any of the nameservers

func CheckRouteOverlaps

func CheckRouteOverlaps(toCheck *net.IPNet) error

CheckRouteOverlaps checks whether the passed network overlaps with any existing routes

func GenerateIfaceName

func GenerateIfaceName(prefix string, len int) (string, error)

GenerateIfaceName returns an interface name using the passed in prefix and the length of random bytes. The api ensures that the there are is no interface which exists with that name.

func GenerateRandomMAC

func GenerateRandomMAC() net.HardwareAddr

GenerateRandomMAC returns a new 6-byte(48-bit) hardware address (MAC)

func GenerateRandomName

func GenerateRandomName(prefix string, size int) (string, error)

GenerateRandomName returns a new name joined with a prefix. This size specified is used to truncate the randomly generated value

func GetIfaceAddr

func GetIfaceAddr(name string) (net.Addr, []net.Addr, error)

GetIfaceAddr returns the first IPv4 address and slice of IPv6 addresses for the specified network interface

func IsRunningInContainer

func IsRunningInContainer() bool

IsRunningInContainer returns whether the test is running inside a container.

func NetworkOverlaps

func NetworkOverlaps(netX *net.IPNet, netY *net.IPNet) bool

NetworkOverlaps detects overlap between one IPNet and another

func NetworkRange

func NetworkRange(network *net.IPNet) (net.IP, net.IP)

NetworkRange calculates the first and last IP addresses in an IPNet

func SetupTestNetNS

func SetupTestNetNS(t *testing.T) func()

SetupTestNetNS joins a new network namespace, and returns its associated teardown function.

Example usage:

defer SetupTestNetNS(t)()

func U16ToA

func U16ToA(val uint16) []byte

U16ToA converts a uint64 to a byte array

func U32ToA

func U32ToA(val uint32) []byte

U32ToA converts a uint64 to a byte array

func U64ToA

func U64ToA(val uint64) []byte

U64ToA converts a uint64 to a byte array

Types

This section is empty.

Jump to

Keyboard shortcuts

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