Copyright | (c) Formaltech Inc. 2017 |
---|---|
License | BSD3 |
Maintainer | [email protected] |
Stability | experimental |
Portability | Linux |
Safe Haskell | None |
Language | Haskell2010 |
System.Linux.RTNetlink.Message
Description
A netlink packet contains a top-level header (struct nlmsghdr
from
linux/netlink.h
), a second-level header that depends on the message type
(e.g., struct ifinfomsg
from linux/if_link.h
), and a possibly nested
collection of attributes (see System.Linux.RTNetlink.Packet).
The way to create a netlink packet in RTNetlink is to instantiate either the
Message
or the Reply
class, which entails specifying what the header type
should be. You can then instantiate any of the Create
, Destroy
, Change
,
or Request
classes to indicate which kinds of actions the message can be used
to perform.
- type SequenceNumber = Word32
- sequenceNumber :: ByteString -> SequenceNumber
- data NLMsgErr = NLMsgErr {}
- class (Show h, Eq h, Sized h, Serialize h) => Header h where
- class Header (MessageHeader m) => Message m where
- type MessageHeader m
- class Message c => Create c where
- class Message d => Destroy d where
- class Message id => Change id c where
- class Message r => Request r where
- dumpNLFlags :: NLFlags
- class Header (ReplyHeader r) => Reply r where
- type ReplyHeader r
Documentation
type SequenceNumber = Word32 Source #
Sequence number for an NlMsgHdr
.
sequenceNumber :: ByteString -> SequenceNumber Source #
Get the sequence number of a message started by an NLMsgHdr
.
The header of an error sent in response to a bad netlink message. The
numeric values correspond to negated values from Foreign.C.Error. Try
running man 3 errno
for more information.
Constructors
NLMsgErr | |
class (Show h, Eq h, Sized h, Serialize h) => Header h where Source #
Class of things that can be used as second-level netlink headers.
Minimal complete definition
class Header (MessageHeader m) => Message m where Source #
Class of things that can be sent as messages.
Methods
messageHeader :: m -> MessageHeader m Source #
Construct a header corresponding to a message. Defaults to emptyHeader
.
messageAttrs :: m -> AttributeList Source #
Construct netlink attributes corresponding to a message. Defaults to mempty
.
toNLMessage :: m -> TypeNumber -> NLFlags -> SequenceNumber -> NLMessage (MessageHeader m) Source #
Produce an NLMessage suitable for sending over the wire.
Instances
class Message c => Create c where Source #
Class of Message
s representing things that can be created.
Minimal complete definition
Methods
createTypeNumber :: c -> TypeNumber Source #
The top-level type number associated with creating with this message.
createNLMessage :: c -> SequenceNumber -> NLMessage (MessageHeader c) Source #
Produce an NLMessage suitable for sending over the wire.
class Message d => Destroy d where Source #
Class of Message
s representing things that can be destroyed.
Minimal complete definition
Methods
destroyTypeNumber :: d -> TypeNumber Source #
The top-level type number associated with destroying with this message.
destroyNLMessage :: d -> SequenceNumber -> NLMessage (MessageHeader d) Source #
Produce an NLMessage suitable for sending over the wire.
class Message id => Change id c where Source #
Class of Message
s representing pairs of identifying messages and
quality that can be modified.
Minimal complete definition
Methods
changeTypeNumber :: id -> c -> TypeNumber Source #
The top-level type number associated with changing things with this message.
changeHeader :: id -> c -> MessageHeader id Source #
Construct a header from an identifier and a quality. Should probably
use the identifying message's messageHeader
.
changeAttrs :: id -> c -> AttributeList Source #
Construct aattributes from an identifier and a quality. Should
probably use the identifying message's messageAttrs
.
changeNLMessage :: id -> c -> SequenceNumber -> NLMessage (MessageHeader id) Source #
Produce an NLMessage suitable for sending over the wire.
class Message r => Request r where Source #
Class of Message
s that can serve as requests.
Minimal complete definition
Methods
requestTypeNumber :: r -> TypeNumber Source #
The top-level type number associated with requesting things with this message.
requestNLFlags :: r -> NLFlags Source #
The top-level flags associated with this request.
requestNLMessage :: r -> SequenceNumber -> NLMessage (MessageHeader r) Source #
Produce an NLMessage suitable for sending over the wire.
dumpNLFlags :: NLFlags Source #
The default request flags assume that the request identifies a single
entity. When requesting information for multiple entities, overload
requestNLFlags
with these.
class Header (ReplyHeader r) => Reply r where Source #
Class of things that can be received.
Minimal complete definition
Methods
replyTypeNumbers :: r -> [TypeNumber] Source #
The expected top-level type number(s) that mark a packet this reply can be parsed from.
fromNLMessage :: NLMessage (ReplyHeader r) -> Maybe r Source #
Interpret a received NLMessage.
Instances
Reply () Source # | |
Reply Errno Source # | |
Reply IfInet6Address Source # | |
Reply IfInetAddress Source # | |
Reply IfPrefix Source # | |
Reply IfIndex Source # | |
Reply LinkState Source # | |
Reply LinkEther Source # | |
Reply LinkName Source # | |
Reply LinkIndex Source # | |
(Reply r, Reply s, (~) * (ReplyHeader r) (ReplyHeader s)) => Reply (r, s) Source # | |