ifaceutil

package
v0.4.7-rc9.2 Latest Latest
Warning

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

Go to latest
Published: Dec 21, 2020 License: Apache-2.0 Imports: 14 Imported by: 1

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func Delete

func Delete(name string, netNS ns.NetNS) error

Delete deletes the named interface if netNS is not nil Exists switch in the network namespace before deleting

func Exists

func Exists(name string, netNS ns.NetNS) bool

Exists test check if the named interface exists if netNS is not nil switch in the network namespace before checking

func GetMAC

func GetMAC(name string, netNS ns.NetNS) (net.HardwareAddr, error)

GetMAC gets the mac address from the Interface

func HardwareAddrFromInputBytes

func HardwareAddrFromInputBytes(b []byte) net.HardwareAddr

HardwareAddrFromInputBytes returns a deterministic hardware address for a given byte slice.

func HasDefaultGW

func HasDefaultGW(link netlink.Link, family int) (bool, net.IP, error)

HasDefaultGW tests if a link as a default gateway configured it return the ip of the gateway if there is one

func HostIPV6Iface

func HostIPV6Iface() (string, error)

HostIPV6Iface return the first physical interface to have an ipv6 public address

func IPv6SuffixFromInputBytes

func IPv6SuffixFromInputBytes(b []byte, n int) []byte

IPv6SuffixFromInputBytes returns a deterministic IPv6 suffix for a given byte slice, with n equals the amount of bytes the suffix has. n has to be within the range of [0, 16].

func IPv6SuffixFromInputBytesAsHex

func IPv6SuffixFromInputBytesAsHex(b []byte, n int) string

IPv6SuffixFromInputBytesAsHex returns a deterministic IPv6 suffix hex-encoded for a given byte slice, with n equals the amount of bytes the suffix has. n has to be within the range of [0, 16].

func IsPlugged

func IsPlugged(inf string) bool

IsPlugged test if an interface has a cable plugged in

func IsPluggedTimeout

func IsPluggedTimeout(name string, duration time.Duration) bool

IsPluggedTimeout is like IsPlugged but retry for duration time before returning

func IsVirtEth

func IsVirtEth(inf string) bool

IsVirtEth tests if an interface is a veth

func LinkFilter

func LinkFilter(links []netlink.Link, types []string) []netlink.Link

LinkFilter list all the links of a certain type

func MakeVethPair

func MakeVethPair(name, master string, mtu int) (netlink.Link, error)

MakeVethPair creates a veth pair

func ParentIface added in v0.4.0

func ParentIface(iface string, netNS ns.NetNS) (netlink.Link, error)

ParentIface return the parent interface fof iface if netNS is not nil, switch to the network namespace before checking iface

func RandomName

func RandomName(prefix string) (string, error)

RandomName generate a random string that can be used for interface or network namespace if prefix is not None, the random name is prefixed with it

func SetLoUp

func SetLoUp() error

SetLoUp brings the lo interface up

func SetMAC

func SetMAC(name string, mac net.HardwareAddr, netNS ns.NetNS) error

SetMAC Sets the mac addr of an interface if netNS is not nil switch in the network namespace before setting

func VethByName added in v0.4.9

func VethByName(name string) (netlink.Link, error)

VethByName loads one end of a veth pair given its name

Types

This section is empty.

Jump to

Keyboard shortcuts

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