nl

package
v1.18.9-rc0 Latest Latest
Warning

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

Go to latest
Published: Feb 17, 2021 License: GPL-2.0, GPL-2.0-or-later Imports: 9 Imported by: 0

Documentation

Index

Constants

View Source
const (
	NLM_F_ACK     uint16 = syscall.NLM_F_ACK
	NLM_F_APPEND  uint16 = syscall.NLM_F_APPEND
	NLM_F_ATOMIC  uint16 = syscall.NLM_F_ATOMIC
	NLM_F_CREATE  uint16 = syscall.NLM_F_CREATE
	NLM_F_DUMP    uint16 = syscall.NLM_F_DUMP
	NLM_F_ECHO    uint16 = syscall.NLM_F_ECHO
	NLM_F_EXCL    uint16 = syscall.NLM_F_EXCL
	NLM_F_MATCH   uint16 = syscall.NLM_F_MATCH
	NLM_F_MULTI   uint16 = syscall.NLM_F_MULTI
	NLM_F_REPLACE uint16 = syscall.NLM_F_REPLACE
	NLM_F_REQUEST uint16 = syscall.NLM_F_REQUEST
	NLM_F_ROOT    uint16 = syscall.NLM_F_ROOT
)
View Source
const (
	NLMSG_NOOP    uint16 = syscall.NLMSG_NOOP
	NLMSG_ERROR   uint16 = syscall.NLMSG_ERROR
	NLMSG_DONE    uint16 = syscall.NLMSG_DONE
	NLMSG_OVERRUN uint16 = syscall.NLMSG_OVERRUN

	// User defined nlmsg_types.
	// rtmon generated timestamp
	NLMSG_TSTAMP uint16 = syscall.NLMSG_MIN_TYPE - 1
	// rtnl generated message containing NSID from out-of-band control.
	NLMSG_NSID uint16 = NLMSG_TSTAMP - 1

	NLMSG_MIN_TYPE uint16 = syscall.NLMSG_MIN_TYPE
)
View Source
const (
	NETLINK_ROUTE    = syscall.NETLINK_ROUTE
	NETLINK_UNUSED   = syscall.NETLINK_UNUSED
	NETLINK_USERSOCK = syscall.NETLINK_USERSOCK
	NETLINK_FIREWALL = syscall.NETLINK_FIREWALL
	// NETLINK_SOCK_DIAG      = syscall.NETLINK_SOCK_DIAG
	NETLINK_NFLOG          = syscall.NETLINK_NFLOG
	NETLINK_XFRM           = syscall.NETLINK_XFRM
	NETLINK_SELINUX        = syscall.NETLINK_SELINUX
	NETLINK_ISCSI          = syscall.NETLINK_ISCSI
	NETLINK_AUDIT          = syscall.NETLINK_AUDIT
	NETLINK_FIB_LOOKUP     = syscall.NETLINK_FIB_LOOKUP
	NETLINK_CONNECTOR      = syscall.NETLINK_CONNECTOR
	NETLINK_NETFILTER      = syscall.NETLINK_NETFILTER
	NETLINK_IP6_FW         = syscall.NETLINK_IP6_FW
	NETLINK_DNRTMSG        = syscall.NETLINK_DNRTMSG
	NETLINK_KOBJECT_UEVENT = syscall.NETLINK_KOBJECT_UEVENT
	NETLINK_GENERIC        = syscall.NETLINK_GENERIC
	NETLINK_SCSITRANSPORT  = syscall.NETLINK_SCSITRANSPORT
	NETLINK_ECRYPTFS       = syscall.NETLINK_ECRYPTFS
)
View Source
const (
	NETLINK_ADD_MEMBERSHIP = iota + 1
	NETLINK_DROP_MEMBERSHIP
	NETLINK_PKTINFO
	NETLINK_BROADCAST_ERROR
	NETLINK_NO_ENOBUFS
	NETLINK_RX_RING
	NETLINK_TX_RING
	NETLINK_LISTEN_ALL_NSID
	NETLINK_LIST_MEMBERSHIPS
	NETLINK_CAP_ACK
)
View Source
const SOL_NETLINK = 270
View Source
const SizeofHdr = syscall.NLMSG_HDRLEN
View Source
const SizeofNlmsgerr = 4 + SizeofHdr
View Source
const SizeofRtAttr = syscall.SizeofRtAttr

Variables

View Source
var Eclosed = errors.New("already closed")
View Source
var Empty = []byte{}
View Source
var PrintSockGrps = func(uint32) {}

Functions

func DoNothing

func DoNothing([]byte)

func Ehdr

func Ehdr(l int) error

func FD_ISSET

func FD_ISSET(p *syscall.FdSet, i int) bool

func FD_SET

func FD_SET(p *syscall.FdSet, i int)

func FD_ZERO

func FD_ZERO(p *syscall.FdSet)

func FdSetBits

func FdSetBits() int

func ForEachAttr

func ForEachAttr(b []byte, do func(uint16, []byte))

func IndexAttrByType

func IndexAttrByType(a [][]byte, b []byte)

Parse attribute list to index by type. Use IndexByType(a, Empty) to de-reference attribute data.

func Int16

func Int16(b []byte) int16

func Int32

func Int32(b []byte) int32

func Int64

func Int64(b []byte) int64

func Int8

func Int8(b []byte) int8

func Kstring

func Kstring(b []byte) string

func NewMessage

func NewMessage(hdr Hdr, msg io.Reader, attrs ...Attr) ([]byte, error)

func Pop

func Pop(b []byte) (msg, rem []byte, err error)

Pop next message from front of buffer and return rem[ainder].

func ReadAllAttrs

func ReadAllAttrs(b []byte, attrs ...Attr) (int, error)

func Seq

func Seq() uint32

func Uint16

func Uint16(b []byte) (v uint16)

func Uint32

func Uint32(b []byte) (v uint32)

func Uint64

func Uint64(b []byte) uint64

func Uint8

func Uint8(b []byte) (v uint8)

Types

type Align

type Align int
const (
	PAGE   Align = 4 << 10
	NLMSG  Align = syscall.NLMSG_ALIGNTO
	NLATTR Align = syscall.RTA_ALIGNTO
)

func (Align) Align

func (to Align) Align(i int) int

func (Align) Size

func (to Align) Size() int

type Attr

type Attr struct {
	Type  uint16
	Value io.Reader
}

func (Attr) Read

func (attr Attr) Read(b []byte) (int, error)

type Attrs

type Attrs []Attr

func (Attrs) Read

func (attrs Attrs) Read(b []byte) (int, error)

type Be16Attr

type Be16Attr uint16

big-endian

func (Be16Attr) Read

func (v Be16Attr) Read(b []byte) (int, error)

type Be32Attr

type Be32Attr uint32

func (Be32Attr) Read

func (v Be32Attr) Read(b []byte) (int, error)

type Be64Attr

type Be64Attr uint64

func (Be64Attr) Read

func (v Be64Attr) Read(b []byte) (int, error)

type BytesAttr

type BytesAttr []byte

func (BytesAttr) Read

func (v BytesAttr) Read(b []byte) (int, error)

type Hdr

type Hdr syscall.NlMsghdr

func HdrPtr

func HdrPtr(b []byte) *Hdr

func (*Hdr) Elen

func (hdr *Hdr) Elen() error

func (*Hdr) Epid

func (hdr *Hdr) Epid() error

func (*Hdr) Eseq

func (hdr *Hdr) Eseq() error

func (*Hdr) Read

func (hdr *Hdr) Read(b []byte) (int, error)

type Int16Attr

type Int16Attr int16

func (Int16Attr) Read

func (v Int16Attr) Read(b []byte) (int, error)

type Int32Attr

type Int32Attr int32

func (Int32Attr) Read

func (v Int32Attr) Read(b []byte) (int, error)

type Int64Attr

type Int64Attr int64

func (Int64Attr) Read

func (v Int64Attr) Read(b []byte) (int, error)

type Int8Attr

type Int8Attr int8

func (Int8Attr) Read

func (v Int8Attr) Read(b []byte) (int, error)

type KstringAttr

type KstringAttr string

func (KstringAttr) Read

func (v KstringAttr) Read(b []byte) (int, error)

type NilAttr

type NilAttr struct{}

func (NilAttr) Read

func (v NilAttr) Read(b []byte) (int, error)

type Nlmsgerr

type Nlmsgerr struct {
	// Unix errno for error.
	Errno int32
	// Header for message with error.
	Req Hdr
}

func NlmsgerrPtr

func NlmsgerrPtr(b []byte) *Nlmsgerr

func (Nlmsgerr) Read

func (msg Nlmsgerr) Read(b []byte) (int, error)

type Sock

type Sock struct {
	Pid  uint32
	RxCh <-chan []byte

	Err error
	// contains filtered or unexported fields
}

func NewSock

func NewSock(opts ...interface{}) (*Sock, error)

This creates cascaded channels and attendant go-routines to pack received netlink messages into a page, if possible; otherwise, one per oversized buffer.

Usage: NewSock([proto int[, depth int[, groups uint32[, allnsid bool[,

sorcvbuf[, sosndbuf int]]]]]])

e.g.

NewSock()
NewSock(NETLINK_ROUTE, 16)
NewSock(NETLINK_GENERIC, 16, RTNLGRP_NEIGH.Bit())
NewSock(NETLINK_GENERIC, 16, groups, true)
NewSock(NETLINK_GENERIC, 16, groups, false, 4 << 20)
NewSock(NETLINK_GENERIC, 16, groups, false, 4 << 20, 1 << 20)

proto	default, NETLINK_ROUTE
depth	of Rx buffer channel (default, 4)
groups	to listen (default, none)
allnsid	listen in all identified net namespaces (default, false)
sorcvbuf, sosndbuf
	respective receive and send socket buffer size
	(default, kernel config)

func (*Sock) Close

func (sock *Sock) Close() error

func (*Sock) Send

func (sock *Sock) Send(b []byte) error

type SockReceiver

type SockReceiver struct {
	*Sock
	// contains filtered or unexported fields
}

A SockReceiver wraps a Sock to pop packed received messages.

func NewSockReceiver

func NewSockReceiver(sock *Sock, opts ...interface{}) *SockReceiver

Usage: NewSockReceiver(sock[, dontwait bool])

func (*SockReceiver) Recv

func (sr *SockReceiver) Recv() (msg []byte, err error)

Pop next message from packed buffer received from channel.

func (*SockReceiver) UntilDone

func (sr *SockReceiver) UntilDone(req []byte, do func([]byte)) error

After setting the sequence number, send the request to netlink and call the given handler for each received message until DONE or ERROR.

type Uint16Attr

type Uint16Attr uint16

func (Uint16Attr) Read

func (v Uint16Attr) Read(b []byte) (int, error)

type Uint32Attr

type Uint32Attr uint32

func (Uint32Attr) Read

func (v Uint32Attr) Read(b []byte) (int, error)

type Uint64Attr

type Uint64Attr uint64

func (Uint64Attr) Read

func (v Uint64Attr) Read(b []byte) (int, error)

type Uint8Attr

type Uint8Attr uint8

func (Uint8Attr) Read

func (v Uint8Attr) Read(b []byte) (int, error)

Directories

Path Synopsis
fou

Jump to

Keyboard shortcuts

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