-- Hoogle documentation, generated by Haddock -- See Hoogle, http://www.haskell.org/hoogle/ -- | Manipulate network devices, addresses, and routes on Linux -- -- A high-level, extensible, pure Haskell interface to the ROUTE_NETLINK -- subsystem of netlink for manipulating network devices on Linux. -- RTNetlink provides the RTNL monad to simplify sending and receiving -- messages, pre-built types for manipulating devices and addresses, and -- typeclasses for creating your own messages, based on linux/netlink.h, -- linux/rtnetlink.h, et al. @package rtnetlink @version 0.1.0.2 module System.Socket.Family.Netlink -- | Netlink socket family. data Netlink -- | The SocketAddress type is a data family. This allows to -- provide different data constructors depending on the socket family -- without knowing all of them in advance or the need to extend this core -- library. -- --
-- SocketAddressInet inetLoopback 8080 :: SocketAddress Inet -- SocketAddressInet6 inet6Loopback 8080 0 0 :: SocketAddress Inet6 ---- | Class of netlink groups. This is extensible because groups vary by -- netlink subsystem. class NetlinkGroup g netlinkGroupNumber :: NetlinkGroup g => g -> Word32 -- | Construct a netlink socket from a collection of groups. netlinkAddress :: NetlinkGroup g => [g] -> IO (SocketAddress Netlink) -- | Like netlinkAddress, but with a configurable source address. netlinkAddressPid :: NetlinkGroup g => Word32 -> [g] -> SocketAddress Netlink -- | The kernel's address. netlinkKernel :: SocketAddress Netlink instance GHC.Classes.Eq (System.Socket.Internal.Socket.SocketAddress System.Socket.Family.Netlink.Netlink) instance GHC.Show.Show (System.Socket.Internal.Socket.SocketAddress System.Socket.Family.Netlink.Netlink) instance GHC.Read.Read (System.Socket.Internal.Socket.SocketAddress System.Socket.Family.Netlink.Netlink) instance System.Socket.Internal.Socket.Family System.Socket.Family.Netlink.Netlink instance Data.Serialize.Serialize (System.Socket.Internal.Socket.SocketAddress System.Socket.Family.Netlink.Netlink) instance Foreign.Storable.Storable (System.Socket.Internal.Socket.SocketAddress System.Socket.Family.Netlink.Netlink) module System.Socket.Protocol.RTNetlink -- | Protocol for the ROUTE_NETLINK subsystem of netlink. data RTNetlink -- | Multicast groups the user of an RTNetlink socket can subscribe to. data RTNetlinkGroup RTNetlinkGroupNone :: RTNetlinkGroup RTNetlinkGroupLink :: RTNetlinkGroup RTNetlinkGroupNotify :: RTNetlinkGroup RTNetlinkGroupNeighbor :: RTNetlinkGroup RTNetlinkGroupTC :: RTNetlinkGroup RTNetlinkGroupIPv4IfAddr :: RTNetlinkGroup RTNetlinkGroupIPv4MRoute :: RTNetlinkGroup RTNetlinkGroupIPv4Route :: RTNetlinkGroup RTNetlinkGroupIPv4Rule :: RTNetlinkGroup RTNetlinkGroupIPv6IfAddr :: RTNetlinkGroup RTNetlinkGroupIPv6MRoute :: RTNetlinkGroup RTNetlinkGroupIPv6Route :: RTNetlinkGroup RTNetlinkGroupIPv6IfInfo :: RTNetlinkGroup RTNetlinkGroupDECnetIfAddr :: RTNetlinkGroup RTNetlinkGroupDECnetRoute :: RTNetlinkGroup RTNetlinkGroupDECnetRule :: RTNetlinkGroup RTNetlinkGroupIPv6Prefix :: RTNetlinkGroup RTNetlinkGroupIPv6Rule :: RTNetlinkGroup RTNetlinkGroupNDUserOpt :: RTNetlinkGroup RTNetlinkGroupPhonetIfAddr :: RTNetlinkGroup RTNetlinkGroupPhonetRoute :: RTNetlinkGroup RTNetlinkGroupDCB :: RTNetlinkGroup RTNetlinkGroupIPv4Netconf :: RTNetlinkGroup RTNetlinkGroupIPv6Netconf :: RTNetlinkGroup RTNetlinkGroupMDB :: RTNetlinkGroup RTNetlinkGroupMPLSRoute :: RTNetlinkGroup RTNetlinkGroupNSID :: RTNetlinkGroup instance GHC.Classes.Eq System.Socket.Protocol.RTNetlink.RTNetlinkGroup instance GHC.Show.Show System.Socket.Protocol.RTNetlink.RTNetlinkGroup instance GHC.Read.Read System.Socket.Protocol.RTNetlink.RTNetlinkGroup instance System.Socket.Internal.Socket.Protocol System.Socket.Protocol.RTNetlink.RTNetlink instance System.Socket.Family.Netlink.NetlinkGroup System.Socket.Protocol.RTNetlink.RTNetlinkGroup module System.Linux.RTNetlink.Packet -- | ADT corresponding to struct nlmsghdr from -- linux/netlink.h. data NLMsgHdr NLMsgHdr :: Word32 -> Word16 -> Word16 -> Word32 -> Word32 -> NLMsgHdr -- | Total message length (nlmsg_len). [nlMsgLength] :: NLMsgHdr -> Word32 -- | Message type (nlmsg_type). [nlMsgType] :: NLMsgHdr -> Word16 -- | Top-level flags (nlmsg_flags). [nlMsgFlags] :: NLMsgHdr -> Word16 -- | Sequence number (nlmsg_seq). [nlMsgSeqNum] :: NLMsgHdr -> Word32 -- | Destination address (nlmsg_pid). [nlMsgPid] :: NLMsgHdr -> Word32 -- | Return True iff the message is an error, assuming the -- provided ByteString is headed by an NLMsgHdr. nlMsgHdrIsError :: ByteString -> Bool -- | Split a ByteString into multiple messages using their -- NLMsgHdrs. splitMessages :: ByteString -> [ByteString] -- | ADT representing a possibly nested netlink attribute. data Attribute -- | Simple attribute. Attribute :: AttributeType -> ByteString -> Attribute -- | Nested attribute. AttributeNest :: AttributeType -> [Attribute] -> Attribute -- | A collection of netlink attributes. newtype AttributeList AttributeList :: [Attribute] -> AttributeList -- | Type identifier for an Attribute. type AttributeType = Word16 -- | Get the type of an Attribute. attributeType :: Attribute -> AttributeType -- | Get the data from a simple Attribute. attributeData :: Attribute -> Maybe ByteString -- | Search for an Attribute in a possibly nested list using the -- AttributeType to look for at each level. findAttribute :: [AttributeType] -> AttributeList -> Maybe Attribute -- | Construct an Attribute with a null-byte-terminated string as -- data. cStringAttr :: AttributeType -> ByteString -> Attribute -- | Construct an Attribute with a 32-bit word as data. word32Attr :: AttributeType -> Word32 -> Attribute -- | Construct an Attribute with a 16-bit word as data. word16Attr :: AttributeType -> Word16 -> Attribute -- | Typeclass for data with a defined size. This lets us get sizes to use -- for constructing headers. class Sized s where sizeAligned a s = ((size s + (a - 1)) `div` a) * a -- | Size of data. size :: (Sized s, Integral i) => s -> i -- | Size of data with alignment padding added. sizeAligned :: (Sized s, Integral a) => a -> s -> a -- | Pad a ByteString to a given alignment. putAligned :: Integral a => a -> Putter ByteString instance GHC.Classes.Eq System.Linux.RTNetlink.Packet.AttributeList instance GHC.Show.Show System.Linux.RTNetlink.Packet.AttributeList instance GHC.Classes.Eq System.Linux.RTNetlink.Packet.Attribute instance GHC.Show.Show System.Linux.RTNetlink.Packet.Attribute instance GHC.Classes.Eq System.Linux.RTNetlink.Packet.NLMsgHdr instance GHC.Show.Show System.Linux.RTNetlink.Packet.NLMsgHdr instance System.Linux.RTNetlink.Packet.Sized System.Linux.RTNetlink.Packet.NLMsgHdr instance Data.Serialize.Serialize System.Linux.RTNetlink.Packet.NLMsgHdr instance System.Linux.RTNetlink.Packet.Sized () instance System.Linux.RTNetlink.Packet.Sized Data.ByteString.Internal.ByteString instance System.Linux.RTNetlink.Packet.Sized System.Linux.RTNetlink.Packet.Attribute instance Data.Serialize.Serialize System.Linux.RTNetlink.Packet.Attribute instance System.Linux.RTNetlink.Packet.Sized System.Linux.RTNetlink.Packet.AttributeList instance Data.Serialize.Serialize System.Linux.RTNetlink.Packet.AttributeList instance GHC.Base.Monoid System.Linux.RTNetlink.Packet.AttributeList -- | 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. module System.Linux.RTNetlink.Message -- | Sequence number for an NlMsgHdr. type SequenceNumber = Word32 -- | Get the sequence number of a message started by an NLMsgHdr. sequenceNumber :: ByteString -> SequenceNumber -- | 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. data NLMsgErr NLMsgErr :: Int32 -> NLMsgHdr -> NLMsgErr -- | Negated numeric error code. [nleError] :: NLMsgErr -> Int32 -- | The header of the offending message. [nleHeader] :: NLMsgErr -> NLMsgHdr -- | Class of things that can be used as second-level netlink headers. class (Show h, Eq h, Sized h, Serialize h) => Header h -- | Default header for a message, if none is specified. emptyHeader :: Header h => h -- | Class of things that can be sent as messages. class Header (MessageHeader m) => Message m where type MessageHeader m messageHeader = const emptyHeader messageAttrs = mempty toNLMessage m = NLMessage (messageHeader m) (messageAttrs m) where { type family MessageHeader m; } -- | Construct a header corresponding to a message. Defaults to -- emptyHeader. messageHeader :: Message m => m -> MessageHeader m -- | Construct netlink attributes corresponding to a message. Defaults to -- mempty. messageAttrs :: Message m => m -> AttributeList -- | Produce an NLMessage suitable for sending over the wire. toNLMessage :: Message m => m -> TypeNumber -> NLFlags -> SequenceNumber -> NLMessage (MessageHeader m) -- | Class of Messages representing things that can be created. class Message c => Create c where createNLMessage c = toNLMessage c (createTypeNumber c) flags where flags = 1541 -- | The top-level type number associated with creating with this message. createTypeNumber :: Create c => c -> TypeNumber -- | Produce an NLMessage suitable for sending over the wire. createNLMessage :: Create c => c -> SequenceNumber -> NLMessage (MessageHeader c) -- | Class of Messages representing things that can be destroyed. class Message d => Destroy d where destroyNLMessage d = toNLMessage d (destroyTypeNumber d) flags where flags = 5 -- | The top-level type number associated with destroying with this -- message. destroyTypeNumber :: Destroy d => d -> TypeNumber -- | Produce an NLMessage suitable for sending over the wire. destroyNLMessage :: Destroy d => d -> SequenceNumber -> NLMessage (MessageHeader d) -- | Class of Messages representing pairs of identifying messages -- and quality that can be modified. class Message id => Change id c where changeNLMessage i c = NLMessage (changeHeader i c) (changeAttrs i c) (changeTypeNumber i c) flags where flags = 5 -- | The top-level type number associated with changing things with this -- message. changeTypeNumber :: Change id c => id -> c -> TypeNumber -- | Construct a header from an identifier and a quality. Should probably -- use the identifying message's messageHeader. changeHeader :: Change id c => id -> c -> MessageHeader id -- | Construct aattributes from an identifier and a quality. Should -- probably use the identifying message's messageAttrs. changeAttrs :: Change id c => id -> c -> AttributeList -- | Produce an NLMessage suitable for sending over the wire. changeNLMessage :: Change id c => id -> c -> SequenceNumber -> NLMessage (MessageHeader id) -- | Class of Messages that can serve as requests. class Message r => Request r where requestNLFlags = const 1 requestNLMessage r = toNLMessage r (requestTypeNumber r) (requestNLFlags r) -- | The top-level type number associated with requesting things with this -- message. requestTypeNumber :: Request r => r -> TypeNumber -- | The top-level flags associated with this request. requestNLFlags :: Request r => r -> NLFlags -- | Produce an NLMessage suitable for sending over the wire. requestNLMessage :: Request r => r -> SequenceNumber -> NLMessage (MessageHeader r) -- | The default request flags assume that the request identifies a single -- entity. When requesting information for multiple entities, overload -- requestNLFlags with these. dumpNLFlags :: NLFlags -- | Class of things that can be received. class Header (ReplyHeader r) => Reply r where type ReplyHeader r where { type family ReplyHeader r; } -- | The expected top-level type number(s) that mark a packet this reply -- can be parsed from. replyTypeNumbers :: Reply r => r -> [TypeNumber] -- | Interpret a received NLMessage. fromNLMessage :: Reply r => NLMessage (ReplyHeader r) -> Maybe r instance GHC.Classes.Eq System.Linux.RTNetlink.Message.NLMsgErr instance GHC.Show.Show System.Linux.RTNetlink.Message.NLMsgErr instance GHC.Classes.Eq header => GHC.Classes.Eq (System.Linux.RTNetlink.Message.NLMessage header) instance GHC.Show.Show header => GHC.Show.Show (System.Linux.RTNetlink.Message.NLMessage header) instance System.Linux.RTNetlink.Packet.Sized header => System.Linux.RTNetlink.Packet.Sized (System.Linux.RTNetlink.Message.NLMessage header) instance (System.Linux.RTNetlink.Packet.Sized header, Data.Serialize.Serialize header) => Data.Serialize.Serialize (System.Linux.RTNetlink.Message.NLMessage header) instance System.Linux.RTNetlink.Packet.Sized System.Linux.RTNetlink.Message.NLMsgErr instance Data.Serialize.Serialize System.Linux.RTNetlink.Message.NLMsgErr instance System.Linux.RTNetlink.Message.Header System.Linux.RTNetlink.Message.NLMsgErr instance System.Linux.RTNetlink.Message.Header () instance System.Linux.RTNetlink.Message.Reply () instance (System.Linux.RTNetlink.Message.Reply r, System.Linux.RTNetlink.Message.Reply s, System.Linux.RTNetlink.Message.ReplyHeader r ~ System.Linux.RTNetlink.Message.ReplyHeader s) => System.Linux.RTNetlink.Message.Reply (r, s) instance System.Linux.RTNetlink.Message.Reply Foreign.C.Error.Errno module System.Linux.RTNetlink.Address -- | An ipv4 address and netmask associated with an interface. data IfInetAddress IfInetAddress :: InetAddress -> IfPrefix -> IfIndex -> IfInetAddress -- | The ip4v address itself. [ifInetAddress] :: IfInetAddress -> InetAddress -- | The netmask in CIDR notation. [ifInetPrefix] :: IfInetAddress -> IfPrefix -- | Index of the associated interface. [ifInetIfIndex] :: IfInetAddress -> IfIndex -- | An ipv6 address and netmask associated with an interface. data IfInet6Address IfInet6Address :: Inet6Address -> IfPrefix -> IfIndex -> IfInet6Address -- | The ip4v address itself. [ifInet6Address] :: IfInet6Address -> Inet6Address -- | The netmask in CIDR notation. [ifInet6Prefix] :: IfInet6Address -> IfPrefix -- | Index of the associated interface. [ifInet6IfIndex] :: IfInet6Address -> IfIndex -- | The index of a layer-3 interface. newtype IfIndex IfIndex :: Int -> IfIndex [ifIndex] :: IfIndex -> Int -- | A netmask in CIDR notation. newtype IfPrefix IfPrefix :: Word8 -> IfPrefix [ifPrefix] :: IfPrefix -> Word8 -- | Interface wildcard. Use this to get information about all layer-3 -- interfaces. data AnyInterface AnyInterface :: AnyInterface -- | The header corresponding to address messages, based on 'struct -- ifaddrmsg' from 'linux/if_addr.h'. data IfAddrMsg IfAddrMsg :: Word8 -> Word8 -> Word8 -> Word8 -> Word32 -> IfAddrMsg -- | Address family (AF_* from sys/socket.h) [addrFamily] :: IfAddrMsg -> Word8 -- | CIDR netmask for this address. [addrPrefix] :: IfAddrMsg -> Word8 -- | Operational flags for this address. [addrFlags] :: IfAddrMsg -> Word8 -- | Address scope. [addrScope] :: IfAddrMsg -> Word8 -- | Index of the associated interface. [addrIndex] :: IfAddrMsg -> Word32 -- | To avoid errors with endianess it was decided to keep this type -- abstract. -- -- Use inetAddressFromTuple and inetAddressToTuple for -- constructing and deconstructing custom addresses. -- -- Hint: Use the Storable instance. It exposes it exactly as found -- within an IP packet (big endian if you insist on interpreting it as a -- number). -- -- Another hint: Use getAddressInfo for parsing and suppress -- nameserver lookups: -- --
-- > getAddressInfo (Just "127.0.0.1") Nothing aiNumericHost :: IO [AddressInfo Inet Stream TCP]
-- [AddressInfo {addressInfoFlags = AddressInfoFlags 4, socketAddress = SocketAddressInet {inetAddress = InetAddress 127.0.0.1, inetPort = InetPort 0}, canonicalName = Nothing}]
--
data InetAddress :: *
-- | To avoid errors with endianess it was decided to keep this type
-- abstract.
--
-- Use inet6AddressFromTuple and inet6AddressToTuple for
-- constructing and deconstructing custom addresses.
--
-- Hint: Use the Storable instance. It exposes it exactly as found
-- within an IP packet (big endian if you insist on interpreting it as a
-- number).
--
-- Another hint: Use getAddressInfo for parsing and suppress
-- nameserver lookups:
--
--
-- > getAddressInfo (Just "::1") Nothing aiNumericHost :: IO [AddressInfo SocketAddressInet6 Stream TCP]
-- [AddressInfo {
-- addressInfoFlags = AddressInfoFlags 4,
-- socketAddress = SocketAddressInet6 {inet6Address = Inet6Address 0000:0000:0000:0000:0000:0000:0000:0001, inet6Port = Inet6Port 0, inet6FlowInfo = Inet6FlowInfo 0, inet6ScopeId = Inet6ScopeId 0},
-- canonicalName = Nothing }]
--
data Inet6Address :: *
instance GHC.Classes.Eq System.Linux.RTNetlink.Address.IfAddrMsg
instance GHC.Show.Show System.Linux.RTNetlink.Address.IfAddrMsg
instance GHC.Classes.Eq System.Linux.RTNetlink.Address.IfInet6Address
instance GHC.Show.Show System.Linux.RTNetlink.Address.IfInet6Address
instance GHC.Classes.Eq System.Linux.RTNetlink.Address.IfInetAddress
instance GHC.Show.Show System.Linux.RTNetlink.Address.IfInetAddress
instance GHC.Classes.Ord System.Linux.RTNetlink.Address.IfPrefix
instance GHC.Num.Num System.Linux.RTNetlink.Address.IfPrefix
instance GHC.Classes.Eq System.Linux.RTNetlink.Address.IfPrefix
instance GHC.Show.Show System.Linux.RTNetlink.Address.IfPrefix
instance GHC.Classes.Ord System.Linux.RTNetlink.Address.IfIndex
instance GHC.Num.Num System.Linux.RTNetlink.Address.IfIndex
instance GHC.Classes.Eq System.Linux.RTNetlink.Address.IfIndex
instance GHC.Show.Show System.Linux.RTNetlink.Address.IfIndex
instance GHC.Classes.Eq System.Linux.RTNetlink.Address.AnyInterface
instance GHC.Show.Show System.Linux.RTNetlink.Address.AnyInterface
instance System.Linux.RTNetlink.Message.Message System.Socket.Family.Inet.InetAddress
instance System.Linux.RTNetlink.Message.Reply System.Socket.Family.Inet.InetAddress
instance System.Linux.RTNetlink.Message.Message System.Socket.Family.Inet6.Inet6Address
instance System.Linux.RTNetlink.Message.Reply System.Socket.Family.Inet6.Inet6Address
instance System.Linux.RTNetlink.Message.Message System.Linux.RTNetlink.Address.AnyInterface
instance System.Linux.RTNetlink.Message.Request System.Linux.RTNetlink.Address.AnyInterface
instance System.Linux.RTNetlink.Message.Message System.Linux.RTNetlink.Address.IfIndex
instance System.Linux.RTNetlink.Message.Reply System.Linux.RTNetlink.Address.IfIndex
instance System.Linux.RTNetlink.Message.Message System.Linux.RTNetlink.Address.IfPrefix
instance System.Linux.RTNetlink.Message.Reply System.Linux.RTNetlink.Address.IfPrefix
instance System.Linux.RTNetlink.Message.Message System.Linux.RTNetlink.Address.IfInetAddress
instance System.Linux.RTNetlink.Message.Create System.Linux.RTNetlink.Address.IfInetAddress
instance System.Linux.RTNetlink.Message.Destroy System.Linux.RTNetlink.Address.IfInetAddress
instance System.Linux.RTNetlink.Message.Reply System.Linux.RTNetlink.Address.IfInetAddress
instance System.Linux.RTNetlink.Message.Message System.Linux.RTNetlink.Address.IfInet6Address
instance System.Linux.RTNetlink.Message.Create System.Linux.RTNetlink.Address.IfInet6Address
instance System.Linux.RTNetlink.Message.Destroy System.Linux.RTNetlink.Address.IfInet6Address
instance System.Linux.RTNetlink.Message.Reply System.Linux.RTNetlink.Address.IfInet6Address
instance System.Linux.RTNetlink.Packet.Sized System.Linux.RTNetlink.Address.IfAddrMsg
instance Data.Serialize.Serialize System.Linux.RTNetlink.Address.IfAddrMsg
instance System.Linux.RTNetlink.Message.Header System.Linux.RTNetlink.Address.IfAddrMsg
module System.Linux.RTNetlink.Link
-- | A link identified by its index.
newtype LinkIndex
LinkIndex :: Int -> LinkIndex
-- | A link identified by its name.
newtype LinkName
LinkName :: ByteString -> LinkName
-- | An ethernet address.
data LinkEther
LinkEther :: Word8 -> Word8 -> Word8 -> Word8 -> Word8 -> Word8 -> LinkEther
-- | Link wildcard.
data AnyLink
AnyLink :: AnyLink
-- | A dummy interface.
newtype Dummy
Dummy :: LinkName -> Dummy
-- | A bridge interface.
newtype Bridge
Bridge :: LinkName -> Bridge
-- | The state of a link.
data LinkState
Up :: LinkState
Down :: LinkState
-- | The header corresponding to link messages, based on 'struct ifinfomsg'
-- from 'linux/if_link.h'.
data IfInfoMsg
IfInfoMsg :: Int32 -> Word32 -> Word32 -> IfInfoMsg
-- | The index of the link.
[ifIndex] :: IfInfoMsg -> Int32
-- | Operational flags of the link.
[ifFlags] :: IfInfoMsg -> Word32
-- | Change mask for link flags.
[ifChange] :: IfInfoMsg -> Word32
instance GHC.Classes.Eq System.Linux.RTNetlink.Link.IfInfoMsg
instance GHC.Show.Show System.Linux.RTNetlink.Link.IfInfoMsg
instance GHC.Classes.Eq System.Linux.RTNetlink.Link.LinkState
instance GHC.Show.Show System.Linux.RTNetlink.Link.LinkState
instance GHC.Classes.Eq System.Linux.RTNetlink.Link.Bridge
instance GHC.Show.Show System.Linux.RTNetlink.Link.Bridge
instance GHC.Classes.Eq System.Linux.RTNetlink.Link.Dummy
instance GHC.Show.Show System.Linux.RTNetlink.Link.Dummy
instance GHC.Classes.Eq System.Linux.RTNetlink.Link.AnyLink
instance GHC.Show.Show System.Linux.RTNetlink.Link.AnyLink
instance GHC.Classes.Eq System.Linux.RTNetlink.Link.LinkEther
instance GHC.Classes.Eq System.Linux.RTNetlink.Link.LinkName
instance GHC.Show.Show System.Linux.RTNetlink.Link.LinkName
instance GHC.Classes.Ord System.Linux.RTNetlink.Link.LinkIndex
instance GHC.Num.Num System.Linux.RTNetlink.Link.LinkIndex
instance GHC.Classes.Eq System.Linux.RTNetlink.Link.LinkIndex
instance GHC.Show.Show System.Linux.RTNetlink.Link.LinkIndex
instance System.Linux.RTNetlink.Message.Message System.Linux.RTNetlink.Link.LinkIndex
instance System.Linux.RTNetlink.Message.Destroy System.Linux.RTNetlink.Link.LinkIndex
instance System.Linux.RTNetlink.Message.Request System.Linux.RTNetlink.Link.LinkIndex
instance System.Linux.RTNetlink.Message.Reply System.Linux.RTNetlink.Link.LinkIndex
instance System.Linux.RTNetlink.Message.Message System.Linux.RTNetlink.Link.LinkName
instance System.Linux.RTNetlink.Message.Destroy System.Linux.RTNetlink.Link.LinkName
instance System.Linux.RTNetlink.Message.Request System.Linux.RTNetlink.Link.LinkName
instance System.Linux.RTNetlink.Message.Reply System.Linux.RTNetlink.Link.LinkName
instance GHC.Show.Show System.Linux.RTNetlink.Link.LinkEther
instance Data.Serialize.Serialize System.Linux.RTNetlink.Link.LinkEther
instance System.Linux.RTNetlink.Message.Message System.Linux.RTNetlink.Link.LinkEther
instance System.Linux.RTNetlink.Message.Reply System.Linux.RTNetlink.Link.LinkEther
instance System.Linux.RTNetlink.Message.Message System.Linux.RTNetlink.Link.AnyLink
instance System.Linux.RTNetlink.Message.Request System.Linux.RTNetlink.Link.AnyLink
instance System.Linux.RTNetlink.Message.Message System.Linux.RTNetlink.Link.Dummy
instance System.Linux.RTNetlink.Message.Create System.Linux.RTNetlink.Link.Dummy
instance System.Linux.RTNetlink.Message.Message System.Linux.RTNetlink.Link.Bridge
instance System.Linux.RTNetlink.Message.Create System.Linux.RTNetlink.Link.Bridge
instance System.Linux.RTNetlink.Message.Reply System.Linux.RTNetlink.Link.LinkState
instance System.Linux.RTNetlink.Message.Change System.Linux.RTNetlink.Link.LinkName System.Linux.RTNetlink.Link.LinkState
instance System.Linux.RTNetlink.Message.Change System.Linux.RTNetlink.Link.LinkIndex System.Linux.RTNetlink.Link.LinkState
instance System.Linux.RTNetlink.Packet.Sized System.Linux.RTNetlink.Link.IfInfoMsg
instance Data.Serialize.Serialize System.Linux.RTNetlink.Link.IfInfoMsg
instance System.Linux.RTNetlink.Message.Header System.Linux.RTNetlink.Link.IfInfoMsg
-- | RTNetlink is an extensible, high-level, pure Haskell interface for
-- manipulating network interfaces on Linux: creating and destroying
-- interfaces, changing and dumping interface settings, adding and
-- removing addresses.
--
-- The core interface of RTNetlink is the RTNL monad. RTNL
-- handles the heavy lifting of opening and closing netlink sockets,
-- incrementing sequence numbers, and getting the responses for the
-- current sequence number behind the scenes. Messages not that are not
-- responses to a sent message, such as those sent to group subscribers,
-- are stored in the backlog and can be retrieved with getBacklog.
--
-- The basic way to use RTNL is to use the create,
-- destroy, dump, and change convenience functions.
-- If you want more control, you can use talk and talk_.
-- Import modules like System.Linux.RTNetlink.Link to get access
-- to prefab instances of Create and Destroy messages, etc.
-- Or import System.Linux.RTNetlink.Message to get access to the
-- core typeclasses and create your own messages.
-- System.Linux.RTNetlink.Packet has a number of functions to make
-- this easier.
--
-- -- -- module Main where -- -- import System.Linux.RTNetlink -- import System.Linux.RTNetlink.Link -- import Control.Monad (when) -- -- main :: IO () -- main = runRTNL $ do -- let mybridge = LinkName "mybridge" -- create (Bridge mybridge) -- change mybridge Up -- state <- dump mybridge -- when (head state == Up) $ -- liftIO (putStrLn "I did it, mom!") -- destroy mybridge --module System.Linux.RTNetlink -- | RTNL monad to simplify netlink communication. data RTNL a -- | Run an RTNL function and catch all IOErrors. This means that -- functions in this module are guaranteed not to throw uncaught -- exceptions. tryRTNL :: RTNL a -> IO (Either String a) -- | Run an RTNL function. RTNL functions in this module throw exclusively -- IOErrors. runRTNL :: RTNL a -> IO a -- | Run an RTNL function and specify some groups to subscribe to. runRTNLGroups :: [RTNetlinkGroup] -> RTNL a -> IO a -- | Send a Create message and ignore non-error Replys. create :: Create c => c -> RTNL () -- | Send a Destroy message and ignore non-error Replys. destroy :: Destroy d => d -> RTNL () -- | Send a Request and receive the associated Replys. dump :: (Request q, Reply r) => q -> RTNL [r] -- | Send a Change message and ignore non-error Replys. change :: Change id c => id -> c -> RTNL () -- | Get all the Replys of a particular type in the backlog and -- queued on the socket. getBacklog :: Reply r => RTNL [r] -- | Clear the backlog. clearBacklog :: RTNL () -- | Send any NLMessage and receive a list of Replys. -- -- If the ReplyTypeNumbers of the return type do not include -- NLM_ERROR, any non-zero error messages received will be thrown as -- IOErrors. Responses that don't parse as the return type will -- be ignored. talk :: (Header h, Reply r) => (SequenceNumber -> NLMessage h) -> RTNL [r] -- | Like talk, but discards non-error Replys. talk_ :: Header h => (SequenceNumber -> NLMessage h) -> RTNL () -- | Lowest-level RTNL function. Send a BytsString and receive all -- responses and queued messages as ByteStrings. -- -- _Note:_ This function does nothing to manage sequence numbers or -- distinguish between responses and queued messages. Nothing will be -- added to the backlog. talkRaw :: ByteString -> RTNL [ByteString] -- | Lift a computation from the IO monad. liftIO :: MonadIO m => forall a. IO a -> m a instance Control.Monad.State.Class.MonadState System.Linux.RTNetlink.Handle System.Linux.RTNetlink.RTNL instance Control.Monad.IO.Class.MonadIO System.Linux.RTNetlink.RTNL instance GHC.Base.Monad System.Linux.RTNetlink.RTNL instance GHC.Base.Applicative System.Linux.RTNetlink.RTNL instance GHC.Base.Functor System.Linux.RTNetlink.RTNL