net-spider-rpl 0.2.1.0 → 0.2.2.0
raw patch · 4 files changed
+32/−13 lines, 4 filesPVP ok
version bump matches the API change (PVP)
API changes (from Hackage documentation)
+ NetSpider.RPL.ContikiNG: parseFileHandle :: Parser Timestamp -> Handle -> IO ([FoundNodeDIO], [FoundNodeDAO])
Files
- ChangeLog.md +12/−0
- net-spider-rpl.cabal +1/−1
- src/NetSpider/RPL.hs +1/−1
- src/NetSpider/RPL/ContikiNG.hs +18/−11
ChangeLog.md view
@@ -1,5 +1,17 @@ # Revision history for net-spider-rpl +## 0.2.2.0 -- 2019-09-23++### RPL module++* document: change the link to net-spider-rpl-example into+ net-spider-rpl-cli.++### ContikiNG module++* Add `parseFileHandle` function.++ ## 0.2.1.0 -- 2019-07-19 ### DIO module
net-spider-rpl.cabal view
@@ -1,5 +1,5 @@ name: net-spider-rpl-version: 0.2.1.0+version: 0.2.2.0 author: Toshio Ito <debug.ito@gmail.com> maintainer: Toshio Ito <debug.ito@gmail.com> license: BSD3
src/NetSpider/RPL.hs view
@@ -6,7 +6,7 @@ -- -- This module defines NetSpider data model and utility for RPL -- networks.--- For usage example, see [an example program](https://github.com/debug-ito/net-spider/tree/master/net-spider-rpl-example/src/NetSpider/RPL/Example.hs).+-- For usage example, see [net-spider-rpl-cli](https://hackage.haskell.org/package/net-spider-rpl-cli) package. -- -- RPL ( [IPv6 Routing Protocol for Low-Power and Lossy Networks, RFC 6550](https://tools.ietf.org/html/rfc6550) ) -- is a routing protocol for small wireless devices. Each node
src/NetSpider/RPL/ContikiNG.hs view
@@ -11,6 +11,7 @@ module NetSpider.RPL.ContikiNG ( -- * Parser functions parseFile,+ parseFileHandle, -- * Parser components Parser, pCoojaLogHead,@@ -35,7 +36,7 @@ import qualified Net.IPv6 as IPv6 import NetSpider.Found (FoundNode(..), FoundLink(..), LinkState(LinkToTarget)) import NetSpider.Timestamp (Timestamp, fromEpochMillisecond, fromLocalTime, fromZonedTime)-import System.IO (withFile, IOMode(ReadMode), hGetLine, hIsEOF)+import System.IO (withFile, IOMode(ReadMode), hGetLine, hIsEOF, Handle) import qualified Text.ParserCombinators.ReadP as P import Text.Read (readEither) @@ -88,17 +89,23 @@ parseFile :: Parser Timestamp -- ^ Parser for log prefix -> FilePath -- ^ File to read -> IO ([FoundNodeDIO], [FoundNodeDAO])-parseFile pTimestamp input_file = withFile input_file ReadMode $ onHandle+parseFile pt file = withFile file ReadMode $ parseFileHandle pt++-- | Same as 'parseFile' but for a 'Handle'.+--+-- @since 0.2.2.0+parseFileHandle :: Parser Timestamp -- ^ Parser for log prefix+ -> Handle -- ^ File handle to read+ -> IO ([FoundNodeDIO], [FoundNodeDAO])+parseFileHandle pTimestamp handle = go ([], []) where- onHandle h = go ([], [])- where- go (acc_dio, acc_dao) = do- mentry <- parseOneEntry pTimestamp $ tryGetLine h- case mentry of- Nothing -> return (reverse acc_dio, reverse acc_dao)- Just (PEDIO fl) -> go (fl : acc_dio, acc_dao)- Just (PEDAO srs) -> go (acc_dio, srs ++ acc_dao)- Just PEMisc -> go (acc_dio, acc_dao)+ go (acc_dio, acc_dao) = do+ mentry <- parseOneEntry pTimestamp $ tryGetLine handle+ case mentry of+ Nothing -> return (reverse acc_dio, reverse acc_dao)+ Just (PEDIO fl) -> go (fl : acc_dio, acc_dao)+ Just (PEDAO srs) -> go (acc_dio, srs ++ acc_dao)+ Just PEMisc -> go (acc_dio, acc_dao) tryGetLine h = do eof <- hIsEOF h if eof