hans-3.0.1: Network Stack

Safe HaskellNone
LanguageHaskell2010

Hans.IP4.ArpTable

Contents

Synopsis

Arp Table

data ArpTable Source #

The Arp table consists of a map of IP4 to Mac, as well as a heap that orders the IP4 addresses according to when their corresponding entries should be expired.

NOTE: There's currently no way to limit the memory use of the arp table, but that might not be a huge problem as the entries are added based on requests from higher layers.

INVARIANT: there should never be entries in the map that aren't also in the heap.

Update

addEntry :: ArpTable -> IP4 -> Mac -> IO () Source #

Insert an entry into the Arp table, and unblock any waiting actions.

markUnreachable :: ArpTable -> IP4 -> IO () Source #

If nobody has responded to queries for this address, notify any waiters that there is no mac associated.

NOTE: in the future, it might be nice to keep an entry in the table that indicates that this host is unreachable.

Query

lookupEntry :: ArpTable -> IP4 -> IO (Maybe Mac) Source #

Lookup an entry in the Arp table.

resolveAddr :: ArpTable -> IP4 -> WaitStrategy res -> IO (QueryResult res) Source #

Returns either the address, or an empty MVar that will eventually contain the Mac, or Nothing if the Arp request fails.

data QueryResult res Source #

Constructors

Known !Mac 
Unknown !Bool res 

blockingStrategy :: WaitStrategy (MVar (Maybe Mac)) Source #

Have the entry block on a

writeChanStrategy :: Maybe DeviceStats -> (Maybe Mac -> Maybe msg) -> BoundedChan msg -> WaitStrategy () Source #

Write the discovered Mac to a bounded channel, passing it through a filtering function first.