packages feed

network-data 0.4 → 0.5

raw patch · 2 files changed

+24/−8 lines, 2 files

Files

Data/Ethernet.hs view
@@ -3,11 +3,15 @@ {- |The Data.Ethernet module exports Ethernet header structures.  -} module Data.Ethernet-        ( Ethernet(..)+        ( -- * Types+          Ethernet(..)         , EthernetHeader(..)+        -- * Constants+        , vlanEthertype         ) where  import Control.Monad (sequence, when, liftM)+import Control.Applicative ((<$>), (<*>)) import qualified Data.ByteString as B import Data.Serialize import Data.Serialize.Put@@ -43,17 +47,25 @@ data EthernetHeader =     EthernetHdr { destination  :: !Ethernet,                   source       :: !Ethernet,+                  vlanTag      :: !(Maybe Word16),                   etherType    :: !Word16                 } deriving (Eq, Ord, Show, Read, Data, Typeable) +-- |Two bytes of 'ethertype' if 802.1Q  tag is present.+vlanEthertype :: Word16+vlanEthertype = 0x8100+ instance Serialize EthernetHeader where-  put (EthernetHdr dst src ty) = do put dst-                                    put src-                                    putWord16be ty+  put (EthernetHdr dst src vt ty) = do put dst+                                       put src+                                       maybe (return ()) put vt+                                       putWord16be ty   get = do dst <- get            src <- get            ty  <- getWord16be-           return $ EthernetHdr dst src ty+           if ty == vlanEthertype+              then EthernetHdr dst src <$> get <*> get+              else return $ EthernetHdr dst src Nothing ty  -- Pretty Printing and parsing instances instance Pretty Ethernet where
network-data.cabal view
@@ -1,17 +1,17 @@ name:           network-data-version:        0.4+version:        0.5 license:        BSD3 license-file:   LICENSE author:         Thomas DuBuisson <thomas.dubuisson@gmail.com> maintainer:     Thomas DuBuisson-synopsis:       Library for network data structures (ex: ethernet/ip/udp/tcp headers and helper functions)+synopsis:       Library for network data structures and their serialization. description:    This library includes definitions for common headers such as                 Ethernet, IPv4, IPv6, UDP, TCP, etc. This code is untested for any serious                 work - use at your own risk. category:       Data, Network stability:      stable build-type:     Simple-cabal-version:  >= 1.2+cabal-version:  >= 1.6 tested-with:    GHC == 6.10.1 extra-source-files: @@ -27,3 +27,7 @@   hs-source-dirs:   exposed-modules: Data.Ethernet, Data.IP, Data.IPv6, Data.Header, Data.TCP, Data.UDP, Data.CSum   ghc-options: ++source-repository head+  type:     git+  location: https://github.com/TomMD/network-data.git