aboutsummaryrefslogtreecommitdiffstats
path: root/src/Network/WireGuard/TunListener.hs
diff options
context:
space:
mode:
authorBin Jin <bjin@ctrl-d.org>2017-03-14 01:00:40 +0800
committerBin Jin <bjin@ctrl-d.org>2017-03-14 01:00:40 +0800
commitaa2728036b67c42796bd7aad50ef1d1eaff90610 (patch)
tree83fb1b7470e03cba3d3ddd4017184deb4292fd42 /src/Network/WireGuard/TunListener.hs
parentTun: use non-blocking fd (diff)
downloadwireguard-hs-aa2728036b67c42796bd7aad50ef1d1eaff90610.tar.xz
wireguard-hs-aa2728036b67c42796bd7aad50ef1d1eaff90610.zip
Tun: rename function to be consistent with the last commit
Diffstat (limited to 'src/Network/WireGuard/TunListener.hs')
-rw-r--r--src/Network/WireGuard/TunListener.hs12
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))