2021-09-23 12:07:19 +02:00
|
|
|
//go:build darwin || freebsd
|
2019-03-20 21:45:40 +01:00
|
|
|
|
|
|
|
/* SPDX-License-Identifier: MIT
|
|
|
|
*
|
2022-09-20 17:21:32 +02:00
|
|
|
* Copyright (C) 2017-2023 WireGuard LLC. All Rights Reserved.
|
2019-03-20 21:45:40 +01: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())
|
|
|
|
}
|
|
|
|
}
|