Package org.drasyl.channel.tun.jna
Interface TunDevice
-
- All Superinterfaces:
AutoCloseable
,Closeable
- All Known Implementing Classes:
AbstractTunDevice
,DarwinTunDevice
,LinuxTunDevice
,WindowsTunDevice
public interface TunDevice extends Closeable
Defines a TUN device we can read from/write to.
-
-
Method Summary
All Methods Instance Methods Abstract Methods Modifier and Type Method Description boolean
isClosed()
Returns whether the device is closed or not.TunAddress
localAddress()
The actual name of the device.TunPacket
readPacket(io.netty.buffer.ByteBufAllocator alloc)
Reads and blocks until aTunPacket
has been received by the tun device.void
writePacket(io.netty.buffer.ByteBufAllocator alloc, TunPacket msg)
Writes and blocks until aTunPacket
has been sent by the tun device.
-
-
-
Method Detail
-
localAddress
TunAddress localAddress()
The actual name of the device.- Returns:
- The actual name of the device.
-
readPacket
TunPacket readPacket(io.netty.buffer.ByteBufAllocator alloc) throws IOException
Reads and blocks until aTunPacket
has been received by the tun device.- Parameters:
alloc
-- Returns:
TunPacket
received by the tun device- Throws:
IOException
- if read failed
-
writePacket
void writePacket(io.netty.buffer.ByteBufAllocator alloc, TunPacket msg) throws IOException
Writes and blocks until aTunPacket
has been sent by the tun device.- Parameters:
alloc
-msg
-TunPacket
to write by the tun device- Throws:
IOException
- if write failed
-
isClosed
boolean isClosed()
Returns whether the device is closed or not.- Returns:
true
if the device has been closed.
-
-