From 6440f010eec82abb9c999771a8f493af44c6b937 Mon Sep 17 00:00:00 2001 From: "Jason A. Donenfeld" Date: Thu, 21 Mar 2019 14:43:04 -0600 Subject: receive: implement flush semantics --- tun/operateonfd.go | 24 ++++++++++++++++++++++++ 1 file changed, 24 insertions(+) create mode 100644 tun/operateonfd.go (limited to 'tun/operateonfd.go') 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()) + } +} -- cgit v1.2.3-59-g8ed1b