nl

package module
v1.0.5 Latest Latest
Warning

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

Go to latest
Published: Aug 31, 2022 License: MIT Imports: 7 Imported by: 17

README

go-nl

go-nl provides a netlink library for Go.

License

This software is released under the MIT License, see LICENSE

Documentation

Index

Constants

Variables

This section is empty.

Functions

func DecodeAttrBytes

func DecodeAttrBytes(b []byte) ([]byte, int, error)

func DecodeAttrString

func DecodeAttrString(b []byte) (string, int, error)

func DecodeAttrU8

func DecodeAttrU8(b []byte) (uint8, int, error)

func DecodeAttrU16

func DecodeAttrU16(b []byte) (uint16, int, error)

func DecodeAttrU32

func DecodeAttrU32(b []byte) (uint32, int, error)

func DecodeAttrU64

func DecodeAttrU64(b []byte) (uint64, int, error)

func DecodeMsgError

func DecodeMsgError(b []byte) (error, int, error)

func IfnameToIndex

func IfnameToIndex(name string) (i int, err error)

func NativeEndian

func NativeEndian() binary.ByteOrder

func Recvmsg

func Recvmsg(s int, msg *syscall.Msghdr, flags int) (n int, err error)

func Sendmsg

func Sendmsg(s int, msg *syscall.Msghdr, flags int) (n int, err error)

Types

type Attr

type Attr struct {
	Type uint16

	Value Encoder
	// contains filtered or unexported fields
}

func (*Attr) Encode

func (a *Attr) Encode(b []byte) (int, error)

func (*Attr) Len

func (a *Attr) Len() int

func (*Attr) Nested

func (a *Attr) Nested() bool

type AttrBytes

type AttrBytes []byte

func (AttrBytes) Encode

func (b AttrBytes) Encode(p []byte) (int, error)

func (AttrBytes) Len

func (b AttrBytes) Len() int

type AttrHdr

type AttrHdr struct {
	Len  AttrLen
	Type uint16
}

func DecodeAttrHdr

func DecodeAttrHdr(b []byte) (AttrHdr, int, error)

func (AttrHdr) MaskedType

func (h AttrHdr) MaskedType() int

func (AttrHdr) Nested

func (h AttrHdr) Nested() bool

func (AttrHdr) NetByteorder

func (h AttrHdr) NetByteorder() bool

type AttrLen

type AttrLen uint16

func (AttrLen) Align

func (l AttrLen) Align() int

type AttrList

type AttrList []Attr

func (AttrList) Encode

func (al AttrList) Encode(b []byte) (int, error)

func (AttrList) Len

func (al AttrList) Len() int

type AttrString

type AttrString string

func (AttrString) Encode

func (s AttrString) Encode(b []byte) (int, error)

func (AttrString) Len

func (s AttrString) Len() int

type AttrU8

type AttrU8 uint8

func (AttrU8) Encode

func (u AttrU8) Encode(b []byte) (int, error)

func (AttrU8) Len

func (u AttrU8) Len() int

type AttrU16

type AttrU16 uint16

func (AttrU16) Encode

func (u AttrU16) Encode(b []byte) (int, error)

func (AttrU16) Len

func (u AttrU16) Len() int

type AttrU32

type AttrU32 uint32

func (AttrU32) Encode

func (u AttrU32) Encode(b []byte) (int, error)

func (AttrU32) Len

func (u AttrU32) Len() int

type AttrU64

type AttrU64 uint64

func (AttrU64) Encode

func (u AttrU64) Encode(b []byte) (int, error)

func (AttrU64) Len

func (u AttrU64) Len() int

type Client

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

func NewClient

func NewClient(conn Conner, mux *Mux) *Client

func (*Client) Do

func (c *Client) Do(req *Request) ([]Msg, error)

func (*Client) Handler added in v1.0.5

func (c *Client) Handler(req *Request, ch chan *Msg) HandlerFunc

type Conn

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

func Open

func Open(proto int, groups ...int) (*Conn, error)

func (*Conn) Close

func (c *Conn) Close()

func (*Conn) Fd

func (c *Conn) Fd() int

func (*Conn) Read

func (c *Conn) Read(b []byte) (int, error)

func (*Conn) TakeSeq

func (c *Conn) TakeSeq() int

func (*Conn) Write

func (c *Conn) Write(b []byte) (int, error)

func (*Conn) Writev

func (c *Conn) Writev(iovs []syscall.Iovec) (int, error)

type Conner added in v1.0.2

type Conner interface {
	Fd() int
	Close()
	Read([]byte) (int, error)
	Write([]byte) (int, error)
	Writev([]syscall.Iovec) (int, error)
	TakeSeq() int
}

type Encoder

type Encoder interface {
	Len() int
	Encode([]byte) (int, error)
}

type Encoders

type Encoders []Encoder

func (Encoders) Encode

func (es Encoders) Encode(b []byte) (int, error)

func (Encoders) Len

func (es Encoders) Len() int

type Handler

type Handler interface {
	ServeMsg(*Msg) bool
}

type HandlerFunc

type HandlerFunc func(*Msg) bool

func (HandlerFunc) ServeMsg

func (f HandlerFunc) ServeMsg(msg *Msg) bool

type HandlerStack

type HandlerStack []Handler

func (HandlerStack) ServeMsg

func (hs HandlerStack) ServeMsg(msg *Msg) bool
type Header struct {
	Len   uint32
	Type  uint16
	Flags uint16
	Seq   uint32
	Pid   uint32
}

func DecodeHeader

func DecodeHeader(b []byte) (*Header, int, error)

type Ifreq

type Ifreq struct {
	Name  [syscall.IFNAMSIZ]byte
	Index uint32
}

type Msg

type Msg struct {
	Header Header
	Body   []byte
}

func DecodeMsg

func DecodeMsg(b []byte) (*Msg, int, error)

type Mux

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

func NewMux

func NewMux() (*Mux, error)

func (*Mux) Close

func (m *Mux) Close()

func (*Mux) PopHandler

func (m *Mux) PopHandler(conn Conner)

func (*Mux) PushHandler

func (m *Mux) PushHandler(conn Conner, handler Handler) error

func (*Mux) PushHandlerFunc

func (m *Mux) PushHandlerFunc(conn Conner, f func(msg *Msg) bool) error

func (*Mux) Serve

func (m *Mux) Serve() error

type Request

type Request struct {
	Header    Header
	Iovs      []syscall.Iovec
	ReplyType map[uint16]struct{}
}

func NewRequest

func NewRequest(typ, flags int) *Request

func (*Request) Append

func (r *Request) Append(e Encoder) error

func (*Request) AppendBytes

func (r *Request) AppendBytes(b []byte)

func (*Request) AppendPointer

func (r *Request) AppendPointer(p unsafe.Pointer, length int)

func (*Request) AppendReplyType

func (r *Request) AppendReplyType(typ int)

func (*Request) Commit

func (r *Request) Commit(seq int)

func (*Request) ContainsReplyType

func (r *Request) ContainsReplyType(typ int) bool

func (*Request) NeedAck added in v1.0.4

func (r *Request) NeedAck() bool

Jump to

Keyboard shortcuts

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