bos / pcap

Haskell bindings for the pcap library, which provides a low level interface to packet capture systems.
http://bitbucket.org/bos/pcap
Other
27 stars 11 forks source link

fix: Network.Pcap.statistics to throw on non-live Pcap handles #6

Open vlm opened 9 years ago

vlm commented 9 years ago

Avoid making Haskell treat C int as long (Haskell's Int). Without this patch:

Prelude Network.Pcap> openOffline "test/empty.pcap" >>= statistics 
Statistics {statReceived = 129485792, statDropped = 1, statIfaceDropped = 129485816}
Prelude Network.Pcap> openOffline "test/empty.pcap" >>= statistics 
Statistics {statReceived = 129683784, statDropped = 1, statIfaceDropped = 115781272}
Prelude Network.Pcap> 

(returns different garbage every time it is called).

With this patch: > cabal repl --ghc-options="-lpcap"

Prelude Network.Pcap> openOffline "test/empty.pcap" >>= statistics
*** Exception: user error (Statistics aren't available from savefiles)
Prelude Network.Pcap> 

Bryan, thank you for maintaining this package!