iproute 1.3.1 → 1.3.2
raw patch · 4 files changed
+35/−2 lines, 4 filesPVP ok
version bump matches the API change (PVP)
API changes (from Hackage documentation)
+ Data.IP: fromIPv6b :: IPv6 -> [Int]
+ Data.IP: toIPv6b :: [Int] -> IPv6
Files
- Data/IP.hs +1/−1
- Data/IP/Addr.hs +28/−0
- Data/IP/RouteTable/Internal.hs +5/−0
- iproute.cabal +1/−1
Data/IP.hs view
@@ -6,7 +6,7 @@ -- ** IP data IP (..) , IPv4, toIPv4, fromIPv4, fromHostAddress, toHostAddress- , IPv6, toIPv6, fromIPv6, fromHostAddress6, toHostAddress6+ , IPv6, toIPv6, toIPv6b, fromIPv6, fromIPv6b, fromHostAddress6, toHostAddress6 -- ** IP range data , IPRange (..) , AddrRange (addr, mask, mlen)
Data/IP/Addr.hs view
@@ -160,6 +160,22 @@ toWord32 [a1,a2] = fromIntegral $ shift a1 16 + a2 toWord32 _ = error "toWord32" +{-|+ The 'toIPv6b' function takes a list of 'Int'+ where each member repserents a single byte and returns 'IPv6'.++>>> toIPv6b [0x20,0x01,0xD,0xB8,0,0,0,0,0,0,0,0,0,0,0,1]+2001:db8::1+-}+toIPv6b :: [Int] -> IPv6+toIPv6b ad = IP6 (x1,x2,x3,x4)+ where+ [x1,x2,x3,x4] = map toWord32 $ split4 ad+ split4 [] = []+ split4 x = take 4 x : split4 (drop 4 x)+ toWord32 [a1,a2,a3,a4] = fromIntegral $ shift a1 24 + shift a2 16 + shift a3 8 + a4+ toWord32 _ = error "toWord32"+ ---------------------------------------------------------------- -- -- IPToInt@@ -185,6 +201,18 @@ where split :: Word32 -> [Word32] split n = [n `shiftR` 0x10 .&. 0xffff, n .&. 0xffff]++{-|+ The 'fromIPv6b' function converts 'IPv6' to a list of 'Int'+ where each member represents a single byte.++>>> fromIPv6b (toIPv6b [0x20,0x01,0xD,0xB8,0,0,0,0,0,0,0,0,0,0,0,1])+[32,1,13,184,0,0,0,0,0,0,0,0,0,0,0,1]+-}+fromIPv6b :: IPv6 -> [Int]+fromIPv6b (IP6 (w1, w2, w3, w4)) = map fromEnum (concatMap split [w1,w2,w3,w4])+ where+ split n = fmap (\s -> n `shiftR` s .&. 0xff) [24,16,8,0] ---------------------------------------------------------------- --
Data/IP/RouteTable/Internal.hs view
@@ -7,6 +7,7 @@ -} module Data.IP.RouteTable.Internal where +import Control.Applicative ((<$>)) import Control.Monad import Data.Bits import Data.IP.Addr@@ -95,6 +96,10 @@ -} empty :: Routable k => IPRTable k a empty = Nil++instance Functor (IPRTable k) where+ fmap _ Nil = Nil+ fmap f (Node r a mv b1 b2) = Node r a (f <$> mv) (fmap f b1) (fmap f b2) ----------------------------------------------------------------
iproute.cabal view
@@ -1,5 +1,5 @@ Name: iproute-Version: 1.3.1+Version: 1.3.2 Author: Kazu Yamamoto <kazu@iij.ad.jp> Maintainer: Kazu Yamamoto <kazu@iij.ad.jp> License: BSD3