netlink

package
v0.0.0-...-78a1b36 Latest Latest
Warning

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

Go to latest
Published: Oct 30, 2014 License: Apache-2.0 Imports: 8 Imported by: 0

Documentation

Overview

Packet netlink provide access to low level Netlink sockets and messages.

Actual implementations are in: netlink_linux.go netlink_darwin.go

Index

Constants

View Source
const (
	IFNAMSIZ          = 16
	DEFAULT_CHANGE    = 0xFFFFFFFF
	IFLA_INFO_KIND    = 1
	IFLA_INFO_DATA    = 2
	VETH_INFO_PEER    = 1
	IFLA_MACVLAN_MODE = 1
	IFLA_ADDRESS      = 1
	IFLA_VLAN_ID      = 1
	IFLA_NET_NS_FD    = 28
)
View Source
const (
	MACVLAN_MODE_PRIVATE = 1 << iota
	MACVLAN_MODE_VEPA
	MACVLAN_MODE_BRIDGE
	MACVLAN_MODE_PASSTHRU
)

Variables

View Source
var (
	ErrWrongSockType = errors.New("Wrong socket type")
	ErrShortResponse = errors.New("Got short response from netlink")
)

Functions

func AddDefaultGw

func AddDefaultGw(ip, device string) error

Add a new default gateway. Identical to: ip route add default via $ip

func AddRoute

func AddRoute(destination, source, gateway, device string) error

Add a new route table entry.

func NetworkChangeName

func NetworkChangeName(iface *net.Interface, newName string) error

if you want to do this with Netlink, you must down the interface, change the name, up it back ip link set IFC down; ip link set IFC name NAME; ip link set NAME up

func NetworkCreateVethPair

func NetworkCreateVethPair(name1, name2 string) error

func NetworkLinkAdd

func NetworkLinkAdd(name string, linkType string) error

Add a new network link of a specified type. This is identical to running: ip add link $name type $linkType

func NetworkLinkAddIp

func NetworkLinkAddIp(iface *net.Interface, ip net.IP, ipNet *net.IPNet) error

Add an Ip address to an interface. This is identical to: ip addr add $ip/$ipNet dev $iface

func NetworkLinkAddMacVlan

func NetworkLinkAddMacVlan(masterDev, macVlanDev string, mode string) error

func NetworkLinkAddVlan

func NetworkLinkAddVlan(masterDev, vlanDev string, vlanId uint16) error

func NetworkLinkDel

func NetworkLinkDel(name string) error

Delete a network link. This is identical to running: ip link del $name

func NetworkLinkDown

func NetworkLinkDown(iface *net.Interface) error

func NetworkLinkUp

func NetworkLinkUp(iface *net.Interface) error

Bring up a particular network interface

func NetworkSetMTU

func NetworkSetMTU(iface *net.Interface, mtu int) error

bridge is a bitch here https://bugs.debian.org/cgi-bin/bugreport.cgi?bug=292088 https://bugzilla.redhat.com/show_bug.cgi?id=697021 this is a bitch ... interfaces do seem to work though! there is a discussion about how to deal with ifcs joining bridge with MTU > 1500

func NetworkSetMacAddress

func NetworkSetMacAddress(iface *net.Interface, macaddr string) error

ip link set dev interface address XX:XX:XX:XX:XX:XX

func NetworkSetMaster

func NetworkSetMaster(iface, master *net.Interface) error

same as ip link set $name master $master

func NetworkSetNoMaster

func NetworkSetNoMaster(iface *net.Interface) error

ip link set dev $name nomaster

func NetworkSetNsFd

func NetworkSetNsFd(iface *net.Interface, fd int) error

func NetworkSetNsPid

func NetworkSetNsPid(iface *net.Interface, nspid int) error

Types

type IfAddrmsg

type IfAddrmsg struct {
	syscall.IfAddrmsg
}

func (*IfAddrmsg) Len

func (msg *IfAddrmsg) Len() int

func (*IfAddrmsg) ToWireFormat

func (msg *IfAddrmsg) ToWireFormat() []byte

type IfInfomsg

type IfInfomsg struct {
	syscall.IfInfomsg
}

func (*IfInfomsg) Len

func (msg *IfInfomsg) Len() int

func (*IfInfomsg) ToWireFormat

func (msg *IfInfomsg) ToWireFormat() []byte

type NetlinkRequest

type NetlinkRequest struct {
	syscall.NlMsghdr
	Data []NetlinkRequestData
}

func (*NetlinkRequest) AddData

func (rr *NetlinkRequest) AddData(data NetlinkRequestData)

func (*NetlinkRequest) ToWireFormat

func (rr *NetlinkRequest) ToWireFormat() []byte

type NetlinkRequestData

type NetlinkRequestData interface {
	Len() int
	ToWireFormat() []byte
}

type NetlinkSocket

type NetlinkSocket struct {
	// contains filtered or unexported fields
}

func (*NetlinkSocket) Close

func (s *NetlinkSocket) Close()

func (*NetlinkSocket) GetPid

func (s *NetlinkSocket) GetPid() (uint32, error)

func (*NetlinkSocket) HandleAck

func (s *NetlinkSocket) HandleAck(seq uint32) error

func (*NetlinkSocket) Receive

func (s *NetlinkSocket) Receive() ([]syscall.NetlinkMessage, error)

func (*NetlinkSocket) Send

func (s *NetlinkSocket) Send(request *NetlinkRequest) error

request ToWireFormat()

type Route

type Route struct {
	*net.IPNet
	Iface   *net.Interface
	Default bool
}

A Route is a subnet associated with the interface to reach it.

func NetworkGetRoutes

func NetworkGetRoutes() ([]Route, error)

Returns an array of IPNet for all the currently routed subnets on ipv4 This is similar to the first column of "ip route" output

type RtAttr

type RtAttr struct {
	syscall.RtAttr
	Data []byte
	// contains filtered or unexported fields
}

func (*RtAttr) Len

func (a *RtAttr) Len() int

func (*RtAttr) ToWireFormat

func (a *RtAttr) ToWireFormat() []byte

type RtMsg

type RtMsg struct {
	syscall.RtMsg
}

func (*RtMsg) Len

func (msg *RtMsg) Len() int

func (*RtMsg) ToWireFormat

func (msg *RtMsg) ToWireFormat() []byte

Jump to

Keyboard shortcuts

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