diff options
author | Bin Jin <bjin@ctrl-d.org> | 2017-03-14 21:18:00 +0800 |
---|---|---|
committer | Bin Jin <bjin@ctrl-d.org> | 2017-03-14 21:18:00 +0800 |
commit | a60988db82aed029b71531e8a4bc5698fa247c02 (patch) | |
tree | bcf9432ac5b0ee14c8e89fb0a4c7e0eece013616 /src/Network/WireGuard/Internal/Util.hs | |
parent | Remove unused language extension pragma (diff) | |
download | wireguard-hs-a60988db82aed029b71531e8a4bc5698fa247c02.tar.xz wireguard-hs-a60988db82aed029b71531e8a4bc5698fa247c02.zip |
Tun: add timestamp for incoming packets
Diffstat (limited to '')
-rw-r--r-- | src/Network/WireGuard/Internal/Util.hs | 10 |
1 files changed, 10 insertions, 0 deletions
diff --git a/src/Network/WireGuard/Internal/Util.hs b/src/Network/WireGuard/Internal/Util.hs index f7ecde5..6aefee7 100644 --- a/src/Network/WireGuard/Internal/Util.hs +++ b/src/Network/WireGuard/Internal/Util.hs @@ -7,6 +7,7 @@ module Network.WireGuard.Internal.Util , catchIOExceptionAnd , catchSomeExceptionAnd , withJust + , dropUntilM , zeroMemory , copyMemory ) where @@ -52,6 +53,15 @@ withJust mma func = do Nothing -> return () Just a -> func a +dropUntilM :: Monad m => (a -> Bool) -> m a -> m a +dropUntilM cond ma = loop + where + loop = do + a <- ma + if cond a + then return a + else loop + zeroMemory :: Ptr a -> CSize -> IO () zeroMemory dest nbytes = memset dest 0 (fromIntegral nbytes) |