packages feed

network-data 0.0.1 → 0.0.2

raw patch · 3 files changed

+8/−9 lines, 3 files

Files

Data/Header.hs view
@@ -6,10 +6,9 @@  import Data.Binary (encode, Binary) import qualified Data.ByteString.Lazy as B-import Data.CSum as C  -- |A class of network headers that assumes a checksum is present.-class (Binary h) => L3Header h a c | h -> a, a -> h, h -> c where+class (Num c,Binary h) => L3Header h a c | h -> a, a -> h, h -> c where 	-- |Returns the checksum from the header 	getChecksum :: h -> c @@ -28,7 +27,6 @@  	-- |Computes the checksum 	computeChecksum :: h -> c-	computeChecksum h = C.csum16 (encode (zeroChecksum h))  	-- |Computes the checksum, returns a header with the proper checksum 	fillChecksum :: h -> h@@ -40,14 +38,14 @@  	-- |Returns True iff the checksum is valid 	valid :: h -> Bool-	valid h = zeroCSum == getChecksum h || computeChecksum h == getChecksum h+	valid h = computeChecksum h == getChecksum h  -- |A class of network addresses that assumes there is a 'broadcast' concept. class (Binary a) => L3Address a h | a -> h, h -> a where 	localBroadcast :: a -> a 	globalBroadcast :: a -class (Binary a) => L4Header h p where-	fixChecksum :: L3Header => h -> l3 -> h+class (Binary h, Binary p) => L4Header h p | h -> p where+	fixChecksum :: (L3Header l3 a c) => h -> l3 -> h 	srcPort	:: h -> p 	dstPort :: h -> p
Data/IP.hs view
@@ -120,8 +120,9 @@ 		put (src h) 		put (dst h) 		putWord8 0-		pw8 (protocol h)-		pw16 (payloadLength h))+		pW8 $ fromIntegral (protocol h)+		pW16 (payloadLength h))+	computeChecksum h = csum16 (encode (zeroChecksum h))  instance L3Address IPv4 IPv4Header where 	localBroadcast (IPv4 a) = IPv4 $ B.concat [B.pack [0xFF], B.drop 1 a]
network-data.cabal view
@@ -1,5 +1,5 @@ name:		network-data-version:	0.0.1+version:	0.0.2 license:	BSD3 license-file:	LICENSE author:		Thomas DuBuisson <thomas.dubuisson@gmail.com>