netlink

package
v1.0.0 Latest Latest
Warning

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

Go to latest
Published: Jun 8, 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_NET_NS_FD = 28
	SIOC_BRADDBR   = 0x89a0
	SIOC_BRADDIF   = 0x89a2
)

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 added in v0.12.0

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

Add a new route table entry.

func AddToBridge added in v0.11.0

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

Add a slave to abridge device. This is more backward-compatible than netlink.NetworkSetMaster and works on RHEL 6.

func CreateBridge added in v0.10.0

func CreateBridge(name string, setMacAddr bool) error

Create the actual bridge device. This is more backward-compatible than netlink.NetworkLinkAdd and works on RHEL 6.

func NetworkChangeName added in v0.9.0

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

func NetworkCreateVethPair added in v0.9.0

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 NetworkLinkDown added in v0.9.0

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

func NetworkSetMaster added in v0.9.0

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

same as ip link set $name master $master

func NetworkSetNsFd added in v0.9.0

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

func NetworkSetNsPid added in v0.9.0

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

Types

type IfAddrmsg

type IfAddrmsg struct {
	syscall.IfAddrmsg
}

func (*IfAddrmsg) Len added in v0.9.0

func (msg *IfAddrmsg) Len() int

func (*IfAddrmsg) ToWireFormat

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

type IfInfomsg

type IfInfomsg struct {
	syscall.IfInfomsg
}

func (*IfInfomsg) Len added in v0.9.0

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 added in v0.7.5

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

func (*NetlinkSocket) Send

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

type Route added in v0.8.0

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 added in v0.9.0

func (a *RtAttr) Len() int

func (*RtAttr) ToWireFormat

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

type RtMsg

type RtMsg struct {
	syscall.RtMsg
}

func (*RtMsg) Len added in v0.9.0

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