packages feed

iproute 1.7.5 → 1.7.6

raw patch · 4 files changed

+32/−1 lines, 4 files

Files

Data/IP/Internal.hs view
@@ -1,6 +1,8 @@ module Data.IP.Internal ( IPv4(..)                         , IPv6(..)                         , AddrRange(..)+                        , IPv4Addr+                        , IPv6Addr                         ) where  import Data.IP.Addr
Data/IP/RouteTable.hs view
@@ -18,6 +18,7 @@   , empty, insert, delete   , I.lookup   , I.lookupKeyValue+  , I.lookupAll   , findMatch   , fromList, toList   , foldlWithKey
Data/IP/RouteTable/Internal.hs view
@@ -266,6 +266,34 @@                     search k1 r $ Just (k2, vl)   | otherwise = res +{-|+  'lookupAll' is a version of 'lookup' that returns all entries matching the+   given key, not just the longest match.++>>> :set -XOverloadedStrings+>>> let rt = fromList ([("192.168.0.0/24", 1), ("10.10.0.0/16", 2), ("10.0.0.0/8", 3)] :: [(AddrRange IPv4, Int)])+>>> lookupAll "127.0.0.1" rt+[]+>>> lookupAll "192.168.0.1" rt+[(192.168.0.0/24,1)]+>>> lookupAll "10.10.0.1" rt+[(10.10.0.0/16,2),(10.0.0.0/8,3)]+-}++lookupAll :: Routable k => AddrRange k -> IPRTable k a -> [(AddrRange k, a)]+lookupAll range = go []+  where+    go acc Nil = acc+    go acc (Node k tb Nothing l r)+      | k == range = acc+      | k >:> range = go acc $ if isLeft range tb then l else r+      | otherwise = acc+    go acc (Node k tb (Just v) l r)+      | k == range = (k,v):acc+      | k >:> range = go ((k,v):acc) $ if isLeft range tb then l else r+      | otherwise = acc++ ----------------------------------------------------------------  {-|
iproute.cabal view
@@ -1,5 +1,5 @@ Name:                   iproute-Version:                1.7.5+Version:                1.7.6 Author:                 Kazu Yamamoto <kazu@iij.ad.jp> Maintainer:             Kazu Yamamoto <kazu@iij.ad.jp> License:                BSD3