mirror of
https://github.com/yggdrasil-network/water.git
synced 2025-05-19 16:35:10 +03:00
Moved linux specific code to the syscalls_linux.go file. Also removed unneeded constants from the syscalls_other.go file.
This commit is contained in:
parent
d2ac4607bb
commit
e3fcc2a155
4 changed files with 37 additions and 36 deletions
22
if.go
22
if.go
|
@ -15,32 +15,14 @@ type Interface struct {
|
|||
// If ifName is empty, a default name (tap0, tap1, ... ) will be assigned.
|
||||
// ifName should not exceed 16 bytes.
|
||||
func NewTAP(ifName string) (ifce *Interface, err error) {
|
||||
file, err := os.OpenFile("/dev/net/tun", os.O_RDWR, 0)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
name, err := createInterface(file.Fd(), ifName, cIFF_TAP|cIFF_NO_PI)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
ifce = &Interface{isTAP: true, file: file, name: name}
|
||||
return
|
||||
return newTAP(ifName)
|
||||
}
|
||||
|
||||
// Create a new TUN interface whose name is ifName.
|
||||
// If ifName is empty, a default name (tap0, tap1, ... ) will be assigned.
|
||||
// ifName should not exceed 16 bytes.
|
||||
func NewTUN(ifName string) (ifce *Interface, err error) {
|
||||
file, err := os.OpenFile("/dev/net/tun", os.O_RDWR, 0)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
name, err := createInterface(file.Fd(), ifName, cIFF_TUN|cIFF_NO_PI)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
ifce = &Interface{isTAP: false, file: file, name: name}
|
||||
return
|
||||
return newTUN(ifName)
|
||||
}
|
||||
|
||||
// Returns true if ifce is a TUN interface, otherwise returns false;
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue