package socketset
import "github.com/purpleidea/mgmt/util/socketset"
Package socketset is in API for creating a select style netlink socket to receive events from the kernel.
Index ¶
- type SocketSet
- func NewSocketSet(groups uint32, name string, proto int) (*SocketSet, error)
- func (obj *SocketSet) Close() error
- func (obj *SocketSet) ReceiveBytes() ([]byte, error)
- func (obj *SocketSet) ReceiveNetlinkMessages() ([]syscall.NetlinkMessage, error)
- func (obj *SocketSet) ReceiveUEvent() (*UEvent, error)
- func (obj *SocketSet) Shutdown() error
- type UEvent
Types ¶
type SocketSet ¶
type SocketSet struct {
// contains filtered or unexported fields
}
SocketSet is used to receive events from a socket and shut it down cleanly when asked. It contains a socket for events and a pipe socket to unblock receive on shutdown.
func NewSocketSet ¶
NewSocketSet returns a socketSet, initialized with the given parameters.
func (*SocketSet) Close ¶
Close closes the pipe file descriptor. It must only be called after Shutdown has closed fdEvents, and unblocked receive. It should only be called once.
func (*SocketSet) ReceiveBytes ¶
ReceiveBytes waits for bytes from fdEvents and return a byte array truncated to the message length. It will block until an event is produced, or shutdown is called.
func (*SocketSet) ReceiveNetlinkMessages ¶
func (obj *SocketSet) ReceiveNetlinkMessages() ([]syscall.NetlinkMessage, error)
ReceiveNetlinkMessages is a wrapper around ReceiveBytes that parses the bytes from the event and returns an array of NetlinkMessages.
func (*SocketSet) ReceiveUEvent ¶
ReceiveUEvent is a wrapper around ReceiveBytes. Parses the UEvent data received from the socket and puts it into a UEvent struct.
func (*SocketSet) Shutdown ¶
Shutdown closes the event file descriptor and unblocks receive by sending a message to the pipe file descriptor. It must be called before close, and should only be called once.
type UEvent ¶
type UEvent struct { // default keys, as per https://github.com/torvalds/linux/blob/master/lib/kobject_uevent.c Action string Devpath string Subsystem string // every other KV pair Data map[string]string }
UEvent struct has attributes for KOBJECT_NETWORK_UEVENT, passed from the kernel.
Source Files ¶
- Version
- v0.0.0-20250322185616-c50a578426f1 (latest)
- Published
- Mar 22, 2025
- Platform
- linux/amd64
- Imports
- 8 packages
- Last checked
- 4 days ago –
Tools for package owners.