netlink

package
v1.0.12-rc1 Latest Latest
Warning

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

Go to latest
Published: Aug 13, 2018 License: MIT Imports: 8 Imported by: 0

Documentation

Index

Constants

View Source
const (
	LINK_TYPE_BRIDGE = "bridge"
	LINK_TYPE_VETH   = "veth"
	LINK_TYPE_IPVLAN = "ipvlan"
	LINK_TYPE_DUMMY  = "dummy"
)

Link types.

View Source
const (
	IFLA_INFO_KIND   = 1
	IFLA_INFO_DATA   = 2
	IFLA_NET_NS_FD   = 28
	IFLA_IPVLAN_MODE = 1
	IFLA_BRPORT_MODE = 4
	VETH_INFO_PEER   = 1
	DEFAULT_CHANGE   = 0xFFFFFFFF
)

Netlink protocol constants that are not already defined in unix package.

Variables

This section is empty.

Functions

func AddIpAddress

func AddIpAddress(ifName string, ipAddress net.IP, ipNet *net.IPNet) error

AddIpAddress adds an IP address to a network interface.

func AddIpRoute

func AddIpRoute(route *Route) error

AddIpRoute adds an IP route to the route table.

func AddLink(link Link) error

AddLink adds a new network interface of a specified type.

func DeleteIpAddress

func DeleteIpAddress(ifName string, ipAddress net.IP, ipNet *net.IPNet) error

DeleteIpAddress deletes an IP address from a network interface.

func DeleteIpRoute

func DeleteIpRoute(route *Route) error

DeleteIpRoute deletes an IP route from the route table.

func DeleteLink(name string) error

DeleteLink deletes a network interface.

func Echo

func Echo(text string) error

Echo sends a netlink echo request message.

func GetIpAddressFamily

func GetIpAddressFamily(ip net.IP) int

GetIpAddressFamily returns the address family of an IP address.

func ResetSocket

func ResetSocket()

ResetSocket deletes the default netlink socket.

func SetLinkAddress

func SetLinkAddress(ifName string, hwAddress net.HardwareAddr) error

SetLinkAddress sets the link layer hardware address of a network interface.

func SetLinkHairpin

func SetLinkHairpin(bridgeName string, on bool) error

SetLinkHairpin sets the hairpin (reflective relay) mode of a bridged interface.

func SetLinkMaster

func SetLinkMaster(name string, master string) error

SetLinkMaster sets the master (upper) device of a network interface.

func SetLinkName

func SetLinkName(name string, newName string) error

SetLinkName sets the name of a network interface.

func SetLinkNetNs

func SetLinkNetNs(name string, fd uintptr) error

SetLinkNetNs sets the network namespace of a network interface.

func SetLinkPromisc

func SetLinkPromisc(ifName string, on bool) error

SetLinkPromisc sets the promiscuous mode of a network interface.

func SetLinkState

func SetLinkState(name string, up bool) error

SetLinkState sets the operational state of a network interface.

Types

type BridgeLink struct {
	LinkInfo
}

BridgeLink represents an ethernet bridge.

type DummyLink struct {
	LinkInfo
}

DummyLink represents a dummy network interface.

type IPVlanLink struct {
	LinkInfo
	Mode IPVlanMode
}

IPVlanLink represents an IPVlan network interface.

type IPVlanMode

type IPVlanMode uint16

IPVLAN link attributes.

const (
	IPVLAN_MODE_L2 IPVlanMode = iota
	IPVLAN_MODE_L3
	IPVLAN_MODE_L3S
	IPVLAN_MODE_MAX
)
type Link interface {
	Info() *LinkInfo
}

Link represents a network interface.

type LinkInfo

type LinkInfo struct {
	Type        string
	Name        string
	Flags       net.Flags
	MTU         uint
	TxQLen      uint
	ParentIndex int
}

LinkInfo respresents the common properties of all network interfaces.

func (*LinkInfo) Info

func (linkInfo *LinkInfo) Info() *LinkInfo

type Route

type Route struct {
	Family     int
	Dst        *net.IPNet
	Src        net.IP
	Gw         net.IP
	Tos        int
	Table      int
	Protocol   int
	Scope      int
	Type       int
	Flags      int
	Priority   int
	LinkIndex  int
	ILinkIndex int
}

Route represents a netlink route.

func GetIpRoute

func GetIpRoute(filter *Route) ([]*Route, error)

GetIpRoute returns a list of IP routes matching the given filter.

type VEthLink struct {
	LinkInfo
	PeerName string
}

VEthLink represents a virtual ethernet network interface.

Jump to

Keyboard shortcuts

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