Maintainer | ongy |
---|---|
Stability | experimental |
Portability | Linux |
Safe Haskell | None |
Language | Haskell2010 |
Some of this should (and will) move to the netlink package at some point in time.
This mostly exists, because both i3-status and conky have modules like this. IPs have become complicated and I don't really know how to sanely display IP in formation for an interface. Feel free to create issues/contact me on IRC if you want to use this and need a better interface (maybe network length information?)
- data IPHandle
- getSocket :: String -> AddressFamily -> IO IPHandle
- getAddresses :: IPHandle -> IO [IP]
- data AddressFamily
- data IP
- getRawFd :: IPHandle -> Fd
- subscribeToEvents :: IPHandle -> IO ()
- handleNext :: IPHandle -> (IP -> IO ()) -> (IP -> IO ()) -> IO ()
Documentation
:: String | The interface to monitor |
-> AddressFamily | The AddressFamily to use |
-> IO IPHandle |
Get an IPHandle to gather information about IPs on the system.
getAddresses :: IPHandle -> IO [IP] Source #
Get all addresses on the system (filtered by interface and type, see getSocket
)
Datatype for IP addresses, abstracts over v4/v6
getRawFd :: IPHandle -> Fd Source #
Get the raw Fd
used by this handle. This can be used to block in RTS controlled manner
subscribeToEvents :: IPHandle -> IO () Source #
Subscribe to the multicast group(s) for this handle. This has to be called ONCE before handleNext
can be used.
:: IPHandle | The handle to use |
-> (IP -> IO ()) | Function to call with new ip addresses |
-> (IP -> IO ()) | Function to call with removed addresses |
-> IO () |
Handle the next event from Netlink
This will handle the next event reported by the handle.
Before this ever does anything subscribeToEvents
has to be called ONCE!
This function can then be called as often as needed and should be called
in a main loop.
The functions passed may be called multiple times, and sometimes both may be called. This is a limitation by the netlink api, that cannot be avoided without user space buffers.