2021-09-23 10:07:19 +00:00
|
|
|
//go:build darwin || freebsd
|
|
|
|
// +build darwin freebsd
|
2019-03-20 20:45:40 +00:00
|
|
|
|
|
|
|
/* SPDX-License-Identifier: MIT
|
|
|
|
*
|
2021-01-28 16:52:15 +00:00
|
|
|
* Copyright (C) 2017-2021 WireGuard LLC. All Rights Reserved.
|
2019-03-20 20:45:40 +00:00
|
|
|
*/
|
|
|
|
|
|
|
|
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())
|
|
|
|
}
|
|
|
|
}
|