Documentation ¶
Overview ¶
netlink is a basic wrapper for the linux netlink kernel module, designed to be interacted with from userspace.
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type Connection ¶
type Connection struct {
// contains filtered or unexported fields
}
Connection is a wrapper to the underlying linux socket that communicates with the kernel module. Despite its name, the underyling communication is not a long lived. Binds to the socket only happen when the Connection is ready to poll, and they are closed once they are read (or a timeout is hit)
func New ¶
func New() (*Connection, error)
Net returns a new Connection instance that will bind to the kernel socket using the AF_NETLINK and RTMGRP_IPV4_ROUTE flags
func NewWithOpts ¶
func NewWithOpts(opts *ConnectionOptions) (*Connection, error)
NewWithOpts returns a new Connection instance that will bind to the kernel socket using the specified parameter flags
func (*Connection) Close ¶
func (z *Connection) Close() error
Close instructs the running routines to terminate
func (*Connection) Handle ¶
func (z *Connection) Handle(h MessageHandler)
Handle registers a function callback that all incoming messages will be passed to. Notify takes precedence over handle, and this method will not be called if a notify channel has been registered (and will also stop being called after a notify channel has been registered)
func (*Connection) Notify ¶
func (z *Connection) Notify(c chan *Message)
Notify registers a provided chan *Message that the connection will write all incoming requests to. Notify takes precedence over Handle
func (*Connection) SendMessage ¶
func (z *Connection) SendMessage(m *Message) error
SendMessage marshals a payload and delivers it to the kernel socket. Currently not implemented
type ConnectionOptions ¶
ConnectionOptions defines the flag passed at bind time to the kernel socket. It contains the necessary parameters to define which messages and sub-modules should be available to this socket
type Message ¶
Message is a basic type wrapper that extends a header with the corresponding data body (if present)
func DecodeMessge ¶
DecodeMessage unmarshals a byte slice into a Message pointer, returning an error if the raw bytes cannot be unmarshalled correctly
type MessageHandler ¶
type MessageHandler func(*Message)
MessageHandler is a function type that defines a basic callback type