Documentation ¶
Overview ¶
Package netlink provides a Go interface to netlink via the libnl library.
Index ¶
- Constants
- func Family(name string) (int, error)
- func SendMessage(command, family, flags int) error
- func SendMessageCallback(command, family, flags int, cb CallbackFunc, arg interface{}) error
- func SendMessageMarshalled(command, family, flags int, v interface{}) error
- func SendMessageUnmarshal(command, family, flags int, v interface{}) error
- type CallbackFunc
- type Error
- type Marshaler
- type Message
- type Unmarshaler
Constants ¶
const ( MFRequest = C.NLM_F_REQUEST MFMulti = C.NLM_F_MULTI MFACK = C.NLM_F_ACK MFEcho = C.NLM_F_ECHO MFDumpIntr = C.NLM_F_DUMP_INTR MFRoot = C.NLM_F_ROOT MFMatch = C.NLM_F_MATCH MFAtomic = C.NLM_F_ATOMIC MFDump = C.NLM_F_DUMP MFReplace = C.NLM_F_REPLACE MFExcl = C.NLM_F_EXCL MFCreate = C.NLM_F_CREATE MFAppend = C.NLM_F_APPEND )
Netlink message flags.
Variables ¶
This section is empty.
Functions ¶
func SendMessage ¶
SendMessage creates and sends a netlink message.
func SendMessageCallback ¶
func SendMessageCallback(command, family, flags int, cb CallbackFunc, arg interface{}) error
SendMessageCallback creates and sends a netlink message. The specified callback function will be called for each message that is received in response.
func SendMessageMarshalled ¶
SendMessageMarshalled creates a netlink message and marshals the given struct into the message, before sending it.
func SendMessageUnmarshal ¶
SendMessageUnmarshal creates and sends a netlink message. All messages received in response will be unmarshalled into the given struct.
Types ¶
type CallbackFunc ¶
CallbackFunc is a netlink message callback function.
type Error ¶
type Error struct {
// contains filtered or unexported fields
}
Error represents a netlink error.
type Marshaler ¶
type Marshaler interface { // Bytes returns a byte slice containing the netlink representation of // the given type. Bytes() []byte }
Marshaler represents a type that is capable of marshaling itself into its netlink representation.
type Message ¶
type Message struct {
// contains filtered or unexported fields
}
Message represents a netlink message.
func NewMessage ¶
NewMessage returns an initialised netlink message.
func NewMessageFromBytes ¶
NewMessageFromBytes returns a netlink message that is initialised from the given byte slice.
func (*Message) Free ¶
func (m *Message) Free()
Free frees resources associated with a netlink message.
func (*Message) Marshal ¶
Marshal converts the given struct into a netlink message. Each field within the struct is added as netlink data, with structs and pointers to structs being recursively added as nested data.
Supported data types and their netlink mappings are as follows:
uint8: NLA_U8 uint16: NLA_U16 uint32: NLA_U32 uint64: NLA_U64 string: NLA_STRING byte array: NLA_UNSPEC struct: NLA_NESTED net.IP: NLA_UNSPEC
Each field must have a `netlink' tag, which can contain the following comma separated options:
attr:x specify the netlink attribute for this field (required) network value will be converted to its network byte order omitempty if the field has a zero value it will be omitted optional mark the field as being an optional (for unmarshalling)
Other Go data types are unsupported and an error will be returned if one is encountered.
func (*Message) SendCallback ¶
func (m *Message) SendCallback(fn CallbackFunc, arg interface{}) error
SendCallback sends the netlink message. The specified callback function will be called for each message that is received in response.
type Unmarshaler ¶
type Unmarshaler interface { // SetBytes sets the value of the given type from a byte slice that // contains its netlink representation. SetBytes([]byte) }
Unmarshaler represents a type that is capable of unmarshaling itself from its netlink representation.