linuxcalls

package
v2.0.0-alpha+incompatible Latest Latest
Warning

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

Go to latest
Published: Oct 15, 2018 License: Apache-2.0 Imports: 3 Imported by: 0

Documentation

Overview

Package linuxcalls contains wrappers over Netlink APIs related to Linux VETH interfaces or Linux interfaces in general.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type NetLinkHandler

type NetLinkHandler struct {
}

NetLinkHandler is accessor for Netlink methods.

func NewNetLinkHandler

func NewNetLinkHandler() *NetLinkHandler

NewNetLinkHandler creates new instance of Netlink handler.

func (*NetLinkHandler) AddInterfaceIP

func (h *NetLinkHandler) AddInterfaceIP(ifName string, addr *net.IPNet) error

AddInterfaceIP calls AddrAdd Netlink API.

func (*NetLinkHandler) AddVethInterfacePair

func (h *NetLinkHandler) AddVethInterfacePair(ifName, peerIfName string) error

AddVethInterfacePair calls LinkAdd Netlink API for the Netlink.Veth interface type.

func (*NetLinkHandler) DelInterfaceIP

func (h *NetLinkHandler) DelInterfaceIP(ifName string, addr *net.IPNet) error

DelInterfaceIP calls AddrDel Netlink API.

func (*NetLinkHandler) DeleteInterface

func (h *NetLinkHandler) DeleteInterface(ifName string) error

DeleteInterface removes the given interface.

func (*NetLinkHandler) GetAddressList

func (h *NetLinkHandler) GetAddressList(ifName string) ([]netlink.Addr, error)

GetAddressList calls AddrList netlink API

func (*NetLinkHandler) GetInterfaceType

func (h *NetLinkHandler) GetInterfaceType(ifName string) (string, error)

GetInterfaceType returns the type (string representation) of a given interface.

func (*NetLinkHandler) GetLinkByName

func (h *NetLinkHandler) GetLinkByName(ifName string) (netlink.Link, error)

GetLinkByName calls netlink API to get Link type from interface name

func (h *NetLinkHandler) GetLinkList() ([]netlink.Link, error)

GetLinkList calls netlink API to get all Links in namespace

func (*NetLinkHandler) InterfaceExists

func (h *NetLinkHandler) InterfaceExists(ifName string) (bool, error)

InterfaceExists checks if interface with a given name exists.

func (*NetLinkHandler) IsInterfaceEnabled

func (h *NetLinkHandler) IsInterfaceEnabled(ifName string) (bool, error)

IsInterfaceEnabled checks if the interface is UP.

func (*NetLinkHandler) LinkSubscribe

func (h *NetLinkHandler) LinkSubscribe(ch chan<- netlink.LinkUpdate, done <-chan struct{}) error

LinkSubscribe takes a channel to which notifications will be sent when links change. Close the 'done' chan to stop subscription.

func (*NetLinkHandler) RenameInterface

func (h *NetLinkHandler) RenameInterface(ifName string, newName string) error

RenameInterface changes the name of the interface <ifName> to <newName>.

func (*NetLinkHandler) SetInterfaceAlias

func (h *NetLinkHandler) SetInterfaceAlias(ifName, alias string) error

SetInterfaceAlias sets the alias of the given interface. Equivalent to: `ip link set dev $ifName alias $alias`

func (*NetLinkHandler) SetInterfaceDown

func (h *NetLinkHandler) SetInterfaceDown(ifName string) error

SetInterfaceDown calls Netlink API LinkSetDown.

func (*NetLinkHandler) SetInterfaceMTU

func (h *NetLinkHandler) SetInterfaceMTU(ifName string, mtu int) error

SetInterfaceMTU calls LinkSetMTU Netlink API.

func (*NetLinkHandler) SetInterfaceMac

func (h *NetLinkHandler) SetInterfaceMac(ifName string, macAddress string) error

SetInterfaceMac calls LinkSetHardwareAddr netlink API.

func (*NetLinkHandler) SetInterfaceUp

func (h *NetLinkHandler) SetInterfaceUp(ifName string) error

SetInterfaceUp calls Netlink API LinkSetUp.

func (*NetLinkHandler) SetLinkNamespace

func (h *NetLinkHandler) SetLinkNamespace(link netlink.Link, ns netns.NsHandle) (err error)

SetLinkNamespace puts link into a network namespace.

type NetlinkAPI

type NetlinkAPI interface {
	NetlinkAPIWrite
	NetlinkAPIRead
}

NetlinkAPI interface covers all methods inside linux calls package needed to manage linux interfaces.

type NetlinkAPIRead

type NetlinkAPIRead interface {
	// GetLinkByName returns netlink interface type
	GetLinkByName(ifName string) (netlink.Link, error)
	// GetLinkList return all links from namespace
	GetLinkList() ([]netlink.Link, error)
	// LinkSubscribe takes a channel to which notifications will be sent
	// when links change. Close the 'done' chan to stop subscription.
	LinkSubscribe(ch chan<- netlink.LinkUpdate, done <-chan struct{}) error
	// GetAddressList reads all IP addresses
	GetAddressList(ifName string) ([]netlink.Addr, error)
	// InterfaceExists verifies interface existence
	InterfaceExists(ifName string) (bool, error)
	// IsInterfaceEnabled checks if the interface is UP.
	IsInterfaceEnabled(ifName string) (bool, error)
	// GetInterfaceType returns linux interface type
	GetInterfaceType(ifName string) (string, error)
}

NetlinkAPIRead interface covers read methods inside linux calls package needed to manage linux interfaces.

type NetlinkAPIWrite

type NetlinkAPIWrite interface {
	// AddVethInterfacePair configures two connected VETH interfaces
	AddVethInterfacePair(ifName, peerIfName string) error
	// DeleteInterface removes the given interface.
	DeleteInterface(ifName string) error
	// SetInterfaceUp sets interface state to 'up'
	SetInterfaceUp(ifName string) error
	// SetInterfaceDown sets interface state to 'down'
	SetInterfaceDown(ifName string) error
	// AddInterfaceIP adds new IP address
	AddInterfaceIP(ifName string, addr *net.IPNet) error
	// DelInterfaceIP removes IP address from linux interface
	DelInterfaceIP(ifName string, addr *net.IPNet) error
	// SetInterfaceMac sets MAC address
	SetInterfaceMac(ifName string, macAddress string) error
	// SetInterfaceMTU set maximum transmission unit for interface
	SetInterfaceMTU(ifName string, mtu int) error
	// RenameInterface changes interface host name
	RenameInterface(ifName string, newName string) error
	// SetInterfaceAlias sets the alias of the given interface.
	// Equivalent to: `ip link set dev $ifName alias $alias`
	SetInterfaceAlias(ifName, alias string) error
	// SetLinkNamespace puts link into a network namespace.
	SetLinkNamespace(link netlink.Link, ns netns.NsHandle) error
}

NetlinkAPIWrite interface covers write methods inside linux calls package needed to manage linux interfaces.

Jump to

Keyboard shortcuts

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