mirror of https://github.com/deavmi/libtun.git
Compare commits
4 Commits
76991d7082
...
d5a92a315c
Author | SHA1 | Date |
---|---|---|
Tristan B. Velloza Kildaire | d5a92a315c | |
Tristan B. Velloza Kildaire | 1357f7cb25 | |
Tristan B. Velloza Kildaire | 87bfb3f1e6 | |
Tristan B. Velloza Kildaire | 2a8ab6f285 |
11
notes.md
11
notes.md
|
@ -10,4 +10,13 @@ It appears you canot use PEEK on fd's that are not sockets.
|
|||
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.
|
||||
and also PEEK read.
|
||||
|
||||
|
||||
## TODO
|
||||
|
||||
- [ ] Adapter settings
|
||||
- [ ] `up`/`down` interface
|
||||
- [ ] Set address on interface
|
||||
- [ ] For source address selection
|
||||
- [ ] For possible automatic route addition
|
|
@ -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)
|
||||
{
|
||||
|
|
Loading…
Reference in New Issue