mirror of https://github.com/deavmi/libtun.git
Throw exception on failure to create tun device
This commit is contained in:
parent
269f81904c
commit
ca5634679c
|
@ -4,7 +4,7 @@ extern (C) int ioctl(int fd, ulong request, void* data);
|
||||||
extern (C) int open(char* path, int flags);
|
extern (C) int open(char* path, int flags);
|
||||||
|
|
||||||
import std.stdio;
|
import std.stdio;
|
||||||
import core.stdc.stdio;
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* TUN maintenance routines in `test.c`
|
* TUN maintenance routines in `test.c`
|
||||||
|
@ -22,10 +22,10 @@ public class TUNAdapter
|
||||||
private void init()
|
private void init()
|
||||||
{
|
{
|
||||||
int tunFD = createTun(cast(char*)"dd", 1);
|
int tunFD = createTun(cast(char*)"dd", 1);
|
||||||
writeln(tunFD);
|
if(tunFD < 0)
|
||||||
writeln();
|
{
|
||||||
writeln(destroyTun(1));
|
throw new TUNException("Error creating tun device");
|
||||||
ioctl(0,0,cast(void*)0);
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public void receive(byte[] buffer)
|
public void receive(byte[] buffer)
|
||||||
|
@ -37,4 +37,12 @@ public class TUNAdapter
|
||||||
{
|
{
|
||||||
|
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public final class TUNException : Exception
|
||||||
|
{
|
||||||
|
this(string msg)
|
||||||
|
{
|
||||||
|
super(msg);
|
||||||
|
}
|
||||||
}
|
}
|
Loading…
Reference in New Issue