monky-2.1.0.0: A system state collecting library and application

PortabilityLinux
Stabilityexperimental
Maintainerongy
Safe HaskellNone

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

getSocketSource

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 
Show IP 

getRawFd :: IPHandle -> FdSource

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.

handleNextSource

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.