Files
tun/device/fd/open_others.go
Shiming Zhang b09240f34d First commit
2022-02-26 04:25:43 +08:00

23 lines
379 B
Go

//go:build !linux && !windows
package fd
import (
"fmt"
"os"
"github.com/wzshiming/tun/device"
)
func open(fd int, mtu uint32) (device.Device, error) {
f := &FD{fd: fd, mtu: mtu}
ep, err := device.New(os.NewFile(uintptr(fd), f.Name()), mtu, 0)
if err != nil {
return nil, fmt.Errorf("create endpoint %s: %w", f.Name(), err)
}
f.LinkEndpoint = ep
return f, nil
}