Safe Haskell | None |
---|---|
Language | Haskell2010 |
- data ArpTable
- newArpTable :: Config -> IO ArpTable
- addEntry :: ArpTable -> IP4 -> Mac -> IO ()
- markUnreachable :: ArpTable -> IP4 -> IO ()
- lookupEntry :: ArpTable -> IP4 -> IO (Maybe Mac)
- resolveAddr :: ArpTable -> IP4 -> WaitStrategy res -> IO (QueryResult res)
- data QueryResult res
- data WaitStrategy res
- blockingStrategy :: WaitStrategy (MVar (Maybe Mac))
- writeChanStrategy :: Maybe DeviceStats -> (Maybe Mac -> Maybe msg) -> BoundedChan msg -> WaitStrategy ()
Arp Table
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
resolveAddr :: ArpTable -> IP4 -> WaitStrategy res -> IO (QueryResult res) Source #
data WaitStrategy res Source #
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.