monky-2.2.0.0: A system state collecting library and application

Maintainerongy
Stabilityexperimental
PortabilityLinux
Safe HaskellNone
LanguageHaskell2010

Monky.IP

Description

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?)

Synopsis

Documentation

data IPHandle Source #

Handle to access information about the IPs on the system

getSocket Source #

Arguments

:: 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)

data AddressFamily Source #

AddressFamilies support for libraries

Constructors

AF_UNSPEC 
AF_INET 
AF_INET6 

data IP Source #

Datatype for IP addresses, abstracts over v4/v6

Constructors

IPv4 IP4 
IPv6 IP6 

Instances

Eq IP Source # 

Methods

(==) :: IP -> IP -> Bool #

(/=) :: IP -> IP -> Bool #

Show IP Source # 

Methods

showsPrec :: Int -> IP -> ShowS #

show :: IP -> String #

showList :: [IP] -> ShowS #

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.

handleNext Source #

Arguments

:: 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.