diff --git a/src/yggdrasil/tun_bsd.go b/src/yggdrasil/tun_openbsd.go similarity index 91% rename from src/yggdrasil/tun_bsd.go rename to src/yggdrasil/tun_openbsd.go index a6a5adc7..25ca3c3c 100644 --- a/src/yggdrasil/tun_bsd.go +++ b/src/yggdrasil/tun_openbsd.go @@ -1,4 +1,4 @@ -// +build openbsd freebsd solaris netbsd dragonfly +// +build openbsd package yggdrasil @@ -10,12 +10,25 @@ import "golang.org/x/sys/unix" import water "github.com/neilalexander/water" -// This is to catch BSD platforms +// This is to catch OpenBSD + +// Warning! When porting this to other BSDs, the tuninfo struct can appear with +// the fields in a different order, and the consts below might also have +// different values + +type tuninfo struct { + tun_mtu uint16 + tun_type uint32 + tun_flags uint32 + tun_dummy uint16 +} const TUNSIFINFO = (0x80000000) | ((12 & 0x1fff) << 16) | uint32(byte('t'))<<8 | 91 const TUNGIFINFO = (0x40000000) | ((12 & 0x1fff) << 16) | uint32(byte('t'))<<8 | 92 const SIOCAIFADDR_IN6 = (0x80000000) | ((4 & 0x1fff) << 16) | uint32(byte('i'))<<8 | 27 +// Below this point seems to be fairly standard at least... + type in6_addrlifetime struct { ia6t_expire float64 ia6t_preferred float64 @@ -41,13 +54,6 @@ type in6_aliasreq struct { ifra_lifetime in6_addrlifetime } -type tuninfo struct { - tun_mtu uint16 - tun_type uint32 - tun_flags uint32 - tun_dummy uint16 -} - func (tun *tunDevice) setup(ifname string, iftapmode bool, addr string, mtu int) error { var config water.Config switch { diff --git a/src/yggdrasil/tun_other.go b/src/yggdrasil/tun_other.go index 06dc2158..ec56408e 100644 --- a/src/yggdrasil/tun_other.go +++ b/src/yggdrasil/tun_other.go @@ -1,4 +1,4 @@ -// +build !linux,!darwin,!windows,!openbsd,!freebsd,!solaris,!netbsd,!dragonfly +// +build !linux,!darwin,!windows,!openbsd package yggdrasil