diff options
author | Bin Jin <bjin@ctrl-d.org> | 2017-03-14 01:00:40 +0800 |
---|---|---|
committer | Bin Jin <bjin@ctrl-d.org> | 2017-03-14 01:00:40 +0800 |
commit | aa2728036b67c42796bd7aad50ef1d1eaff90610 (patch) | |
tree | 83fb1b7470e03cba3d3ddd4017184deb4292fd42 | |
parent | Tun: use non-blocking fd (diff) | |
download | wireguard-hs-aa2728036b67c42796bd7aad50ef1d1eaff90610.tar.xz wireguard-hs-aa2728036b67c42796bd7aad50ef1d1eaff90610.zip |
Tun: rename function to be consistent with the last commit
-rw-r--r-- | src/Network/WireGuard/TunListener.hs | 12 |
1 files changed, 6 insertions, 6 deletions
diff --git a/src/Network/WireGuard/TunListener.hs b/src/Network/WireGuard/TunListener.hs index 46c290f..83f848f 100644 --- a/src/Network/WireGuard/TunListener.hs +++ b/src/Network/WireGuard/TunListener.hs @@ -31,18 +31,18 @@ runTunListener fds readTunChan writeTunChan = loop fds [] handleRead :: PacketQueue TunPacket -> Fd -> IO () handleRead readTunChan fd = allocaBytes tunReadBufferLength $ \buf -> - forever (readFd buf fd >>= atomically . pushPacketQueue readTunChan) + forever (readTun buf fd >>= atomically . pushPacketQueue readTunChan) handleWrite :: PacketQueue TunPacket -> Fd -> IO () handleWrite writeTunChan fd = - forever (atomically (popPacketQueue writeTunChan) >>= writeFd fd) + forever (atomically (popPacketQueue writeTunChan) >>= writeTun fd) -readFd :: BA.ByteArray ba => Ptr Word8 -> Fd -> IO ba -readFd buf fd = do +readTun :: BA.ByteArray ba => Ptr Word8 -> Fd -> IO ba +readTun buf fd = do nbytes <- tunReadBuf fd buf (fromIntegral tunReadBufferLength) snd <$> BA.allocRet (fromIntegral nbytes) (\ptr -> copyMemory ptr buf nbytes >> zeroMemory buf nbytes) -writeFd :: BA.ByteArrayAccess ba => Fd -> ba -> IO () -writeFd fd ba = BA.withByteArray ba $ \ptr -> do +writeTun :: BA.ByteArrayAccess ba => Fd -> ba -> IO () +writeTun fd ba = BA.withByteArray ba $ \ptr -> do void $ tunWriteBuf fd ptr (fromIntegral (BA.length ba)) |