aboutsummaryrefslogtreecommitdiffstats
path: root/conn/boundif_windows.go
diff options
context:
space:
mode:
authorJason A. Donenfeld <Jason@zx2c4.com>2021-02-22 18:47:41 +0100
committerJason A. Donenfeld <Jason@zx2c4.com>2021-02-25 15:08:08 +0100
commit3c11c0308e4e9fae76e1531f4f49a39f1ae24253 (patch)
tree6fbc8fba7161b0835e9e1bfba6d68bc82ad78301 /conn/boundif_windows.go
parentglobal: remove TODO name graffiti (diff)
downloadwireguard-go-3c11c0308e4e9fae76e1531f4f49a39f1ae24253.tar.xz
wireguard-go-3c11c0308e4e9fae76e1531f4f49a39f1ae24253.zip
conn: implement RIO for fast Windows UDP sockets
Signed-off-by: Jason A. Donenfeld <Jason@zx2c4.com>
Diffstat (limited to 'conn/boundif_windows.go')
-rw-r--r--conn/boundif_windows.go59
1 files changed, 0 insertions, 59 deletions
diff --git a/conn/boundif_windows.go b/conn/boundif_windows.go
deleted file mode 100644
index 6f6fdd8..0000000
--- a/conn/boundif_windows.go
+++ /dev/null
@@ -1,59 +0,0 @@
-/* SPDX-License-Identifier: MIT
- *
- * Copyright (C) 2017-2021 WireGuard LLC. All Rights Reserved.
- */
-
-package conn
-
-import (
- "encoding/binary"
- "unsafe"
-
- "golang.org/x/sys/windows"
-)
-
-const (
- sockoptIP_UNICAST_IF = 31
- sockoptIPV6_UNICAST_IF = 31
-)
-
-func (bind *StdNetBind) BindSocketToInterface4(interfaceIndex uint32, blackhole bool) error {
- /* MSDN says for IPv4 this needs to be in net byte order, so that it's like an IP address with leading zeros. */
- bytes := make([]byte, 4)
- binary.BigEndian.PutUint32(bytes, interfaceIndex)
- interfaceIndex = *(*uint32)(unsafe.Pointer(&bytes[0]))
-
- sysconn, err := bind.ipv4.SyscallConn()
- if err != nil {
- return err
- }
- err2 := sysconn.Control(func(fd uintptr) {
- err = windows.SetsockoptInt(windows.Handle(fd), windows.IPPROTO_IP, sockoptIP_UNICAST_IF, int(interfaceIndex))
- })
- if err2 != nil {
- return err2
- }
- if err != nil {
- return err
- }
- bind.blackhole4 = blackhole
- return nil
-}
-
-func (bind *StdNetBind) BindSocketToInterface6(interfaceIndex uint32, blackhole bool) error {
- sysconn, err := bind.ipv6.SyscallConn()
- if err != nil {
- return err
- }
- err2 := sysconn.Control(func(fd uintptr) {
- err = windows.SetsockoptInt(windows.Handle(fd), windows.IPPROTO_IPV6, sockoptIPV6_UNICAST_IF, int(interfaceIndex))
- })
- if err2 != nil {
- return err2
- }
- if err != nil {
- return err
- }
- bind.blackhole6 = blackhole
- return nil
-}