summaryrefslogtreecommitdiffhomepage
path: root/tun/tun_windows.go
diff options
context:
space:
mode:
authorAvery Pennarun <apenwarr@gmail.com>2019-04-20 03:28:06 -0400
committerJason A. Donenfeld <Jason@zx2c4.com>2019-10-17 15:19:20 +0200
commit1b6c8ddbe8f2b9ef0b07b4d5a97443c67ee2e0fd (patch)
tree9fbfc4abd97d6a77d55f5ba5e6889626f8f4818c /tun/tun_windows.go
parent0abb6b668c708aa84daba4b036e536fd76a8b1c5 (diff)
tun: match windows CreateTUN signature to the Linux variant
Signed-off-by: Avery Pennarun <apenwarr@gmail.com> [zx2c4: fix default value]
Diffstat (limited to 'tun/tun_windows.go')
-rw-r--r--tun/tun_windows.go13
1 files changed, 9 insertions, 4 deletions
diff --git a/tun/tun_windows.go b/tun/tun_windows.go
index 4b5da02..daad4aa 100644
--- a/tun/tun_windows.go
+++ b/tun/tun_windows.go
@@ -54,15 +54,15 @@ func nanotime() int64
// CreateTUN creates a Wintun interface with the given name. Should a Wintun
// interface with the same name exist, it is reused.
//
-func CreateTUN(ifname string) (Device, error) {
- return CreateTUNWithRequestedGUID(ifname, nil)
+func CreateTUN(ifname string, mtu int) (Device, error) {
+ return CreateTUNWithRequestedGUID(ifname, nil, mtu)
}
//
// CreateTUNWithRequestedGUID creates a Wintun interface with the given name and
// a requested GUID. Should a Wintun interface with the same name exist, it is reused.
//
-func CreateTUNWithRequestedGUID(ifname string, requestedGUID *windows.GUID) (Device, error) {
+func CreateTUNWithRequestedGUID(ifname string, requestedGUID *windows.GUID, mtu int) (Device, error) {
var err error
var wt *wintun.Interface
@@ -80,12 +80,17 @@ func CreateTUNWithRequestedGUID(ifname string, requestedGUID *windows.GUID) (Dev
return nil, fmt.Errorf("Error creating interface: %v", err)
}
+ forcedMTU := 1420
+ if mtu > 0 {
+ forcedMTU = mtu
+ }
+
tun := &NativeTun{
wt: wt,
handle: windows.InvalidHandle,
events: make(chan Event, 10),
errors: make(chan error, 1),
- forcedMTU: 1500,
+ forcedMTU: forcedMTU,
}
err = tun.rings.Init()