packages feed

ip6addr 0.3.1 → 0.3.2

raw patch · 5 files changed

+29/−17 lines, 5 files

Files

ChangeLog view
@@ -1,3 +1,10 @@+2010-10-28      Michel Boucey <michel.boucey@gmail.com>++	- Version 0.3.2 released.+	- Fixed a mis pattern matching in version 0.3.1.+	- Better pattern matching ISATAP adresses to keep+	  their IPv4 dotted representation in IPv6 addresses.+ 2010-10-26      Michel Boucey <michel.boucey@gmail.com>  	- Version 0.3.1 released.
ip6addr.cabal view
@@ -1,11 +1,11 @@ Name:           ip6addr-Version:        0.3.1+Version:        0.3.2 Author:         Michel Boucey <michel.boucey@gmail.com> Maintainer:     Michel Boucey <michel.boucey@gmail.com> Homepage:       http://www.cybervisible.fr/ip6addr Category:       Network,Console Synopsis:       Command-line tools to deal with IPv6 Addresses text representation-Description:    ip6addr consists of two command-line tools: ip6addrcan which filters IPv6 addresses parsed against RFC 4291 and canonized in conformation with RFC 5952. By default, ip6addrcan outputs only validated inputs, i.e. IPv6 addresses, removing CIDR suffix if necessary. Already compressed IPv6 adresses are recomputed. -e option throws out discarded inputs to stderr (which have of course to be redirected). The second command-line tool, ip6addrgen, generates random IPv6 adresses. -p option allows to provide a prefix to all IPv6 adresses to generate. -n option allows to provide the amount of IPv6 addresses to generate. Outputted IPv6 addresses have to be pipelined through ip6addrcan to be canonized.+Description:    ip6addr consists of two command-line tools: ip6addrcan which filters IPv6 addresses parsed against RFC 4291 and canonized them in conformation with RFC 5952. By default, ip6addrcan outputs only validated inputs, i.e. IPv6 addresses, removing CIDR suffix if necessary. Already compressed IPv6 adresses are recomputed. -e option throws out discarded inputs to stderr (which have of course to be redirected). The second command-line tool, ip6addrgen, generates random IPv6 adresses. -p option allows to provide a prefix to all IPv6 adresses to generate. -n option allows to provide the amount of IPv6 addresses to generate. Outputted IPv6 addresses have to be pipelined through ip6addrcan to be canonized. License:        BSD3 License-File:   LICENSE Build-Type:     Simple@@ -17,11 +17,13 @@  Executable ip6addrcan     Hs-Source-Dirs: src +    GHC-Options: -O2     Main-Is:  IP6AddrCan.hs     Build-Depends:  base >= 4 && <= 5  Executable ip6addrgen     Hs-Source-Dirs: src+    GHC-Options: -O2     Main-Is:  IP6AddrGen.hs     Build-Depends:  base >= 4 && <= 5,                     random
src/IP6AddrCan.hs view
@@ -41,7 +41,7 @@         Nothing -> hPutStrLn stderr i >> evalInputsErr is     where a = removeCidrSuffix i 			   -version = "ip6addrcan version 0.3.1"+version = "ip6addrcan version 0.3.2"  help   = "Usage: ip6addrcan [-v|-h] | [-e] [address ...]\n" 
src/IP6AddrGen.hs view
@@ -105,7 +105,7 @@         ([Help],_,_) -> putStrLn (usageInfo help options) >> exit         (_,_,_) -> putStrLn (usageInfo help options) >> exit -version = "ip6addrgen version 0.3.1"+version = "ip6addrgen version 0.3.2"  help = "Usage: ip6addrgen [-v|-h] | [-n] [-p]\n" 
src/IPv6Addr.hs view
@@ -1,7 +1,7 @@ module IPv6Addr where  import Data.Char (intToDigit,isDigit,isHexDigit,toLower)-import Data.List (group,groupBy,intercalate,intersperse,elemIndex)+import Data.List -- (group,groupBy,intercalate,intersperse,elemIndex) import Data.Function (on) import Data.Maybe import Numeric@@ -156,25 +156,28 @@ -- 	ISATAP address like "fe80::5efe:1.2.3.4" ipv4AddrToHex :: [Maybe IPv6AddrToken] -> [Maybe IPv6AddrToken] ipv4AddrToHex [Just DoubleColon,Just (IPv4Addr a)] =-    [Just DoubleColon,Just Colon,Just (IPv4Addr a)]+    [Just DoubleColon,Just (IPv4Addr a)] ipv4AddrToHex [Just DoubleColon,Just (SixteenBits "ffff"),Just Colon,Just (IPv4Addr a)] =     [Just DoubleColon,Just (SixteenBits "ffff"),Just Colon,Just (IPv4Addr a)] ipv4AddrToHex [Just DoubleColon,Just (SixteenBits "ffff"),Just Colon,Just AllZeros,Just Colon,Just (IPv4Addr a)] =     [Just DoubleColon,Just (SixteenBits "ffff"),Just Colon,Just AllZeros,Just Colon,Just (IPv4Addr a)] ipv4AddrToHex [Just (SixteenBits "64"),Just Colon,Just (SixteenBits "ff9b"),Just DoubleColon,Just (IPv4Addr a)] =     [Just (SixteenBits "64"),Just Colon,Just (SixteenBits "ff9b"),Just DoubleColon,Just (IPv4Addr a)]-ipv4AddrToHex [Just (SixteenBits "fe80"),Just DoubleColon,Just (SixteenBits "5efe"),Just Colon,Just (IPv4Addr a)] =-    [Just (SixteenBits "fe80"),Just DoubleColon,Just (SixteenBits "5efe"),Just Colon,Just (IPv4Addr a)] ipv4AddrToHex ts =-    do-        let t = last ts-        case t of-            Just (IPv4Addr a) -> do-                let m = map (\x -> showIntAtBase 16 intToDigit (read x::Int) "")-                        $ filter (/= ".") (a `tokenizedBy` '.')-                init ts ++ [Just (SixteenBits ((!!) m 0 ++ addZero((!!) m 1))),Just Colon,Just (SixteenBits ((!!) m 2 ++ addZero((!!) m 3)))]-                    where-                        addZero s = if length s < 2 then '0':s else s+        case last ts of+            Just (IPv4Addr a) ->+                do+                    let its = init ts+                    if [Just (SixteenBits "200"),Just Colon,Just (SixteenBits "5efe"),Just Colon] `isSuffixOf` its+                       || [Just AllZeros,Just Colon,Just (SixteenBits "5efe"),Just Colon] `isSuffixOf` its+                       || [Just DoubleColon,Just (SixteenBits "5efe"),Just Colon] `isSuffixOf` its+                        then ts+                        else do+                            let m = map (\x -> showIntAtBase 16 intToDigit (read x::Int) "")+                                    $ filter (/= ".") (a `tokenizedBy` '.')+                            its ++ [Just (SixteenBits ((!!) m 0 ++ addZero((!!) m 1))),Just Colon,Just (SixteenBits ((!!) m 2 ++ addZero((!!) m 3)))]+                                where+                                    addZero s = if length s < 2 then '0':s else s             otherwise -> ts  expendDoubleColon :: [Maybe IPv6AddrToken] -> [Maybe IPv6AddrToken]