aboutsummaryrefslogtreecommitdiffstats
path: root/tun/operateonfd.go
diff options
context:
space:
mode:
authorJason A. Donenfeld <Jason@zx2c4.com>2019-03-21 14:43:04 -0600
committerJason A. Donenfeld <Jason@zx2c4.com>2019-03-21 14:45:41 -0600
commit6440f010eec82abb9c999771a8f493af44c6b937 (patch)
tree187207b768cb2bb477879a1abfad8b732bbece45 /tun/operateonfd.go
parenttun: windows: add dummy overlapped events back (diff)
downloadwireguard-go-6440f010eec82abb9c999771a8f493af44c6b937.tar.xz
wireguard-go-6440f010eec82abb9c999771a8f493af44c6b937.zip
receive: implement flush semantics
Diffstat (limited to 'tun/operateonfd.go')
-rw-r--r--tun/operateonfd.go24
1 files changed, 24 insertions, 0 deletions
diff --git a/tun/operateonfd.go b/tun/operateonfd.go
new file mode 100644
index 0000000..31747a2
--- /dev/null
+++ b/tun/operateonfd.go
@@ -0,0 +1,24 @@
+// +build !windows
+
+/* SPDX-License-Identifier: MIT
+ *
+ * Copyright (C) 2017-2019 WireGuard LLC. All Rights Reserved.
+ */
+
+package tun
+
+import (
+ "fmt"
+)
+
+func (tun *NativeTun) operateOnFd(fn func(fd uintptr)) {
+ sysconn, err := tun.tunFile.SyscallConn()
+ if err != nil {
+ tun.errors <- fmt.Errorf("unable to find sysconn for tunfile: %s", err.Error())
+ return
+ }
+ err = sysconn.Control(fn)
+ if err != nil {
+ tun.errors <- fmt.Errorf("unable to control sysconn for tunfile: %s", err.Error())
+ }
+}