netlink

package
v1.0.16 Latest Latest
Warning

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

Go to latest
Published: Jan 10, 2019 License: MIT Imports: 8 Imported by: 0

Documentation

Index

Constants

View Source
const (
	RT_SCOPE_UNIVERSE = 0
	RT_SCOPE_SITE     = 200
	RT_SCOPE_LINK     = 253
	RT_SCOPE_HOST     = 254
	RT_SCOPE_NOWHERE  = 255
)
View Source
const (
	LINK_TYPE_BRIDGE = "bridge"
	LINK_TYPE_VETH   = "veth"
	LINK_TYPE_IPVLAN = "ipvlan"
	LINK_TYPE_DUMMY  = "dummy"
)

Link types.

View Source
const (
	ADD = iota
	REMOVE
)
View Source
const (
	NDA_UNSPEC = iota
	NDA_DST
	NDA_LLADDR
	NDA_CACHEINFO
	NDA_PROBES
	NDA_VLAN
	NDA_PORT
	NDA_VNI
	NDA_IFINDEX
	NDA_MAX = NDA_IFINDEX
)
View Source
const (
	NUD_NONE       = 0x00
	NUD_INCOMPLETE = 0x01
	NUD_REACHABLE  = 0x02
	NUD_STALE      = 0x04
	NUD_DELAY      = 0x08
	NUD_PROBE      = 0x10
	NUD_FAILED     = 0x20
	NUD_NOARP      = 0x40
	NUD_PERMANENT  = 0x80
)

Neighbor Cache Entry States.

View Source
const (
	NTF_USE    = 0x01
	NTF_SELF   = 0x02
	NTF_MASTER = 0x04
	NTF_PROXY  = 0x08
	NTF_ROUTER = 0x80
)

Neighbor Flags

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.

View Source
const (
	RTPROT_KERNEL = 2
)

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 AddOrRemoveStaticArp added in v1.0.15

func AddOrRemoveStaticArp(mode int, name string, ipaddr net.IP, mac net.HardwareAddr) error

AddOrRemoveStaticArp sets/removes static arp entry based on mode

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