diff --git a/core/device/tun/tun_wireguard_linux.go b/core/device/tun/tun_wireguard_linux.go new file mode 100644 index 0000000..dc74bf9 --- /dev/null +++ b/core/device/tun/tun_wireguard_linux.go @@ -0,0 +1,24 @@ +//go:build linux && !(amd64 || arm64) + +package tun + +import ( + "unsafe" +) + +const ( + virtioNetHdrLen = int(unsafe.Sizeof(virtioNetHdr{})) + offset = virtioNetHdrLen + 0 /* NO_PI */ + defaultMTU = 1500 +) + +// virtioNetHdr is defined in the kernel in include/uapi/linux/virtio_net.h. The +// kernel symbol is virtio_net_hdr. +type virtioNetHdr struct { + flags uint8 + gsoType uint8 + hdrLen uint16 + gsoSize uint16 + csumStart uint16 + csumOffset uint16 +} diff --git a/core/device/tun/tun_wireguard_unix.go b/core/device/tun/tun_wireguard_unix.go index 550eb32..5842df3 100644 --- a/core/device/tun/tun_wireguard_unix.go +++ b/core/device/tun/tun_wireguard_unix.go @@ -1,8 +1,7 @@ -//go:build unix +//go:build unix && !linux package tun -//nolint:all const ( offset = 4 /* 4 bytes TUN_PI */ defaultMTU = 1500