rtnetlink-0.1.0.4: Manipulate network devices, addresses, and routes on Linux

Copyright(c) Formaltech Inc. 2017
LicenseBSD3
Maintainerprotob3n@gmail.com
Stabilityexperimental
PortabilityLinux
Safe HaskellNone
LanguageHaskell2010

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.

Synopsis

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.

data NLMsgErr Source #

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 

Fields

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

emptyHeader

Methods

emptyHeader :: h Source #

Default header for a message, if none is specified.

class Header (MessageHeader m) => Message m where Source #

Class of things that can be sent as messages.

Associated Types

type MessageHeader m Source #

The type of header to attach to the message.

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

Message IfInet6Address Source # 
Message IfInetAddress Source # 
Message IfPrefix Source # 
Message IfIndex Source # 
Message AnyInterface Source # 
Message Bridge Source # 
Message Dummy Source # 
Message AnyLink Source # 
Message LinkEther Source # 
Message LinkName Source # 
Message LinkIndex Source # 

class Message id => Change id c where Source #

Class of Messages representing pairs of identifying messages and quality that can be modified.

Minimal complete definition

changeTypeNumber, changeHeader, changeAttrs

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.

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

replyTypeNumbers, fromNLMessage

Associated Types

type ReplyHeader r Source #

The type of header associated with this Reply.

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 # 

Associated Types

type ReplyHeader () :: * 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 # 

Associated Types

type ReplyHeader (r, s) :: * Source #

Methods

replyTypeNumbers :: (r, s) -> [TypeNumber] Source #

fromNLMessage :: NLMessage (ReplyHeader (r, s)) -> Maybe (r, s) Source #