Compare commits

...

4 Commits

2 changed files with 14 additions and 19 deletions

View File

@ -11,3 +11,12 @@ Regardless of whether they implement queuoing or not, it would be nice
if that was allowed. And if tuntap did it. THEN I could make a system
that doesn't allocate something huge and THEN I could go ahead
and also PEEK read.
## TODO
- [ ] Adapter settings
- [ ] `up`/`down` interface
- [ ] Set address on interface
- [ ] For source address selection
- [ ] For possible automatic route addition

View File

@ -1,20 +1,6 @@
module libtun.adapter;
extern (C) int ioctl(int fd, ulong request, void* data);
extern (C) int open(char* path, int flags);
import core.stdc.stdio;
/**
* TUN maintenance routines in `tunctl.c`
* TODO: Use import C here
*/
import libtun.tunctl;
// extern (C) int createTun(char* interfaceName, int iffFlags);
// extern (C) int destroyTun(int fd);
// extern (C) int tunWrite(int fd, char* data, int length);
// extern (C) int tunRead(int fd, char* data, int amount);
public class Adapter
{
@ -45,7 +31,7 @@ public class Adapter
tunFD = createTun(cast(char*)interfaceName, 4096|adapterType);
if(tunFD < 0)
{
throw new TUNException("Error creating tun device");
throw new AdapterException("Error creating tun device");
}
/* TODO: Get device MTU and add functions for setting it */
@ -57,7 +43,7 @@ public class Adapter
{
if(isClosed)
{
throw new TUNException("Cannot operate on closed tunnel device");
throw new AdapterException("Cannot operate on closed tunnel device");
}
}
@ -109,7 +95,7 @@ public class Adapter
if(status < 0)
{
throw new TUNException("Read failed");
throw new AdapterException("Read failed");
}
else if(status == 0)
{
@ -149,7 +135,7 @@ public class Adapter
}
public final class TUNException : Exception
public final class AdapterException : Exception
{
this(string msg)
{