Set adapter type

This commit is contained in:
Tristan B. Velloza Kildaire 2021-10-24 19:41:21 +02:00
parent b936afb809
commit 002fef91f9
1 changed files with 5 additions and 5 deletions

View File

@ -26,12 +26,12 @@ public class TUNAdapter
this(string interfaceName, AdapterType adapterType = AdapterType.TAP) this(string interfaceName, AdapterType adapterType = AdapterType.TAP)
{ {
init(interfaceName); init(interfaceName, adapterType);
} }
private void init(string interfaceName) private void init(string interfaceName, AdapterType adapterType)
{ {
tunFD = createTun(cast(char*)interfaceName, 4096|2); tunFD = createTun(cast(char*)interfaceName, 4096|adapterType);
if(tunFD < 0) if(tunFD < 0)
{ {
throw new TUNException("Error creating tun device"); throw new TUNException("Error creating tun device");
@ -128,8 +128,8 @@ public final class TUNException : Exception
} }
} }
public enum AdapterType : ushort public enum AdapterType : byte
{ {
TUN = 1, TUN = 1,
TAP = 0 TAP = 2
} }