Allow customizing MTU

Signed-off-by: Jason A. Donenfeld <Jason@zx2c4.com>
This commit is contained in:
Jason A. Donenfeld
2018-10-27 01:03:28 +02:00
parent e1ebe64a47
commit 95fefbdb39
4 changed files with 16 additions and 8 deletions
+9 -2
View File
@@ -26,10 +26,17 @@ type nativeTun struct {
ctx unsafe.Pointer
}
func CreateTUN(mtu int, readFn unsafe.Pointer, writeFn unsafe.Pointer, ctx unsafe.Pointer) TUNDevice {
func CreateTUN(mtu uint16, readFn unsafe.Pointer, writeFn unsafe.Pointer, ctx unsafe.Pointer) TUNDevice {
if mtu == 0 {
/* 0 means automatic MTU, which iOS makes outerMTU-80-15. The 80 is for
* WireGuard and the 15 ensures our padding will work. Therefore, it's
* safe to have this code assume a massive MTU.
*/
mtu = ^mtu
}
tun := &nativeTun{
events: make(chan TUNEvent, 10),
mtu: mtu,
mtu: int(mtu),
readFn: readFn,
writeFn: writeFn,
ctx: ctx,