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:
Harshal Sheth 2015-11-07 19:20:00 -05:00
parent d2ac4607bb
commit e3fcc2a155
4 changed files with 37 additions and 36 deletions

22
if.go
View file

@ -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;