diff options
Diffstat (limited to 'src/Network/WireGuard/TunListener.hs')
-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)) |