Copyright | (c) Formaltech Inc. 2017 |
---|---|
License | BSD3 |
Maintainer | protob3n@gmail.com |
Stability | experimental |
Portability | Linux |
Safe Haskell | None |
Language | Haskell2010 |
Synopsis
- data NLMsgHdr = NLMsgHdr {
- nlMsgLength :: Word32
- nlMsgType :: Word16
- nlMsgFlags :: Word16
- nlMsgSeqNum :: Word32
- nlMsgPid :: Word32
- nlMsgHdrIsError :: ByteString -> Bool
- splitMessages :: ByteString -> [ByteString]
- data Attribute
- newtype AttributeList = AttributeList [Attribute]
- type AttributeType = Word16
- attributeType :: Attribute -> AttributeType
- attributeData :: Attribute -> Maybe ByteString
- findAttribute :: [AttributeType] -> AttributeList -> Maybe Attribute
- findAttributeData :: [AttributeType] -> AttributeList -> Maybe ByteString
- findAttributeDecode :: Serialize a => [AttributeType] -> AttributeList -> Maybe a
- findAttributeGet :: Get a -> [AttributeType] -> AttributeList -> Maybe a
- findAttributeCString :: [AttributeType] -> AttributeList -> Maybe ByteString
- cStringAttr :: AttributeType -> ByteString -> Attribute
- word32Attr :: AttributeType -> Word32 -> Attribute
- word32AttrPart :: AttributeType -> Word32 -> Word32 -> Attribute
- word16Attr :: AttributeType -> Word16 -> Attribute
- word16AttrPart :: AttributeType -> Word16 -> Word16 -> Attribute
- class Sized s where
- size :: Integral i => s -> i
- sizeAligned :: Integral a => a -> s -> a
- putAligned :: Integral a => a -> Putter ByteString
- data ChangeFlags a = ChangeFlags {}
- applyChangeFlags :: Bits a => ChangeFlags a -> a -> a
- applyChangeFlags' :: Bits a => ChangeFlags a -> a
- setChangeFlags :: Bits a => a -> ChangeFlags a
Low-level headers
ADT corresponding to struct nlmsghdr
from linux/netlink.h
.
NLMsgHdr | |
|
nlMsgHdrIsError :: ByteString -> Bool Source #
Return True
iff the message is an error, assuming the provided
ByteString
is headed by an NLMsgHdr
.
splitMessages :: ByteString -> [ByteString] Source #
Split a ByteString into multiple messages using their NLMsgHdr
s.
Attributes
ADT representing a possibly nested netlink attribute.
Attribute AttributeType ByteString | Simple attribute. |
AttributeNest AttributeType [Attribute] | Nested attribute. |
AttributePart AttributeType ByteString ByteString | Composable attribute. |
newtype AttributeList Source #
A collection of netlink attributes.
Instances
type AttributeType = Word16 Source #
Type identifier for an Attribute
.
attributeType :: Attribute -> AttributeType Source #
Get the type of an Attribute
.
attributeData :: Attribute -> Maybe ByteString Source #
Get the data from a simple Attribute
.
findAttribute :: [AttributeType] -> AttributeList -> Maybe Attribute Source #
Search for an Attribute
in a possibly nested list using the
AttributeType
to look for at each level. Unfortunately, the kernel does
not presently seem to set NLA_F_NESTED on nested attribute types. Until
this is changed in the kernel, we need to traverse nested elements manually.
findAttributeData :: [AttributeType] -> AttributeList -> Maybe ByteString Source #
Search for an Attribute
and return its data field.
findAttributeDecode :: Serialize a => [AttributeType] -> AttributeList -> Maybe a Source #
Search for an Attribute
; decode and return its data field.
findAttributeGet :: Get a -> [AttributeType] -> AttributeList -> Maybe a Source #
Search for an Attribute
, run a getter on it, and return the result.
findAttributeCString :: [AttributeType] -> AttributeList -> Maybe ByteString Source #
Search for an Attribute
and return its data field, minus any null bytes.
cStringAttr :: AttributeType -> ByteString -> Attribute Source #
Construct an Attribute
with a null-byte-terminated string as data.
word32Attr :: AttributeType -> Word32 -> Attribute Source #
Construct an Attribute
with a 32-bit word in host byte-order as data.
word32AttrPart :: AttributeType -> Word32 -> Word32 -> Attribute Source #
word16Attr :: AttributeType -> Word16 -> Attribute Source #
Construct an Attribute
with a 16-bit word in host byte-order as data.
word16AttrPart :: AttributeType -> Word16 -> Word16 -> Attribute Source #
Sized data
Typeclass for data with a defined size. This lets us get sizes to use for constructing headers.
size :: Integral i => s -> i Source #
Size of data.
sizeAligned :: Integral a => a -> s -> a Source #
Size of data with alignment padding added.
Instances
Sized () Source # | |
Defined in System.Linux.RTNetlink.Packet | |
Sized ByteString Source # | |
Defined in System.Linux.RTNetlink.Packet size :: Integral i => ByteString -> i Source # sizeAligned :: Integral a => a -> ByteString -> a Source # | |
Sized AttributeList Source # | |
Defined in System.Linux.RTNetlink.Packet size :: Integral i => AttributeList -> i Source # sizeAligned :: Integral a => a -> AttributeList -> a Source # | |
Sized Attribute Source # | |
Sized NLMsgHdr Source # | |
Sized NLMsgErr Source # | |
Sized IfInfoMsg Source # | |
Sized IfAddrMsg Source # | |
Sized header => Sized (NLMessage header) Source # | |
putAligned :: Integral a => a -> Putter ByteString Source #
Pad a ByteString
to a given alignment.
Monoidal bit flags
data ChangeFlags a Source #
A flags bitfield encoded as a set of changes to an initial value, which can
can be combined using the Monoid
instance. This Monoid
instance is *not*
commutative. Flags set or cleared on the right will override those on the
left.
Instances
Bits a => Eq (ChangeFlags a) Source # | |
Defined in System.Linux.RTNetlink.Packet (==) :: ChangeFlags a -> ChangeFlags a -> Bool # (/=) :: ChangeFlags a -> ChangeFlags a -> Bool # | |
Show a => Show (ChangeFlags a) Source # | |
Defined in System.Linux.RTNetlink.Packet showsPrec :: Int -> ChangeFlags a -> ShowS # show :: ChangeFlags a -> String # showList :: [ChangeFlags a] -> ShowS # | |
(Bits a, FiniteBits a) => Semigroup (ChangeFlags a) Source # | |
Defined in System.Linux.RTNetlink.Packet (<>) :: ChangeFlags a -> ChangeFlags a -> ChangeFlags a # sconcat :: NonEmpty (ChangeFlags a) -> ChangeFlags a # stimes :: Integral b => b -> ChangeFlags a -> ChangeFlags a # | |
(Bits a, FiniteBits a) => Monoid (ChangeFlags a) Source # | |
Defined in System.Linux.RTNetlink.Packet mempty :: ChangeFlags a # mappend :: ChangeFlags a -> ChangeFlags a -> ChangeFlags a # mconcat :: [ChangeFlags a] -> ChangeFlags a # |
applyChangeFlags :: Bits a => ChangeFlags a -> a -> a Source #
Apply a change to an existing flags bitfield.
applyChangeFlags' :: Bits a => ChangeFlags a -> a Source #
Apply a change to the all-zeroes bit field.
setChangeFlags :: Bits a => a -> ChangeFlags a Source #