Documentation ¶
Index ¶
- Constants
- Variables
- func DoNothing([]byte)
- func Ehdr(l int) error
- func FD_ISSET(p *syscall.FdSet, i int) bool
- func FD_SET(p *syscall.FdSet, i int)
- func FD_ZERO(p *syscall.FdSet)
- func FdSetBits() int
- func ForEachAttr(b []byte, do func(uint16, []byte))
- func IndexAttrByType(a [][]byte, b []byte)
- func Int16(b []byte) int16
- func Int32(b []byte) int32
- func Int64(b []byte) int64
- func Int8(b []byte) int8
- func Kstring(b []byte) string
- func NewMessage(hdr Hdr, msg io.Reader, attrs ...Attr) ([]byte, error)
- func Pop(b []byte) (msg, rem []byte, err error)
- func ReadAllAttrs(b []byte, attrs ...Attr) (int, error)
- func Seq() uint32
- func Uint16(b []byte) (v uint16)
- func Uint32(b []byte) (v uint32)
- func Uint64(b []byte) uint64
- func Uint8(b []byte) (v uint8)
- type Align
- type Attr
- type Attrs
- type Be16Attr
- type Be32Attr
- type Be64Attr
- type BytesAttr
- type Hdr
- type Int16Attr
- type Int32Attr
- type Int64Attr
- type Int8Attr
- type KstringAttr
- type NilAttr
- type Nlmsgerr
- type Sock
- type SockReceiver
- type Uint16Attr
- type Uint32Attr
- type Uint64Attr
- type Uint8Attr
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 ForEachAttr ¶
func IndexAttrByType ¶
Parse attribute list to index by type. Use IndexByType(a, Empty) to de-reference attribute data.
Types ¶
type Align ¶
type Align int
const ( PAGE Align = 4 << 10 NLMSG Align = syscall.NLMSG_ALIGNTO NLATTR Align = syscall.RTA_ALIGNTO )
type KstringAttr ¶
type KstringAttr string
type Nlmsgerr ¶
type Nlmsgerr struct { // Unix errno for error. Errno int32 // Header for message with error. Req Hdr }
func NlmsgerrPtr ¶
type Sock ¶
type Sock struct { Pid uint32 RxCh <-chan []byte Err error // contains filtered or unexported fields }
func NewSock ¶
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)
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.
type Uint16Attr ¶
type Uint16Attr uint16
type Uint32Attr ¶
type Uint32Attr uint32
type Uint64Attr ¶
type Uint64Attr uint64
Source Files ¶
Click to show internal directories.
Click to hide internal directories.