From aa2728036b67c42796bd7aad50ef1d1eaff90610 Mon Sep 17 00:00:00 2001 From: Bin Jin Date: Tue, 14 Mar 2017 01:00:40 +0800 Subject: Tun: rename function to be consistent with the last commit --- src/Network/WireGuard/TunListener.hs | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) (limited to 'src/Network/WireGuard') 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)) -- cgit v1.2.3-59-g8ed1b