forked from 0xef53/go-tuntap
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathlink.go
29 lines (26 loc) · 789 Bytes
/
link.go
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
package tuntap
import "syscall"
// SetInterfaceUp changes the state of a given interface to UP.
//
// ifName should not exceed 16 bytes.
//
// This is identical to running: ip link set up dev $ifName
//
// If there is an error, it will be of type *os.SyscallError.
func SetInterfaceUp(ifName string) error {
var req ifReq
copy(req.Name[:(syscall.IFNAMSIZ-1)], ifName)
return ifaceLinkUpIoctl(&req)
}
// SetInterfaceDown changes the state of a given interface to DOWN.
//
// ifName should not exceed 16 bytes.
//
// This is identical to running: ip link set down dev $ifName
//
// If there is an error, it will be of type *os.SyscallError.
func SetInterfaceDown(ifName string) error {
var req ifReq
copy(req.Name[:(syscall.IFNAMSIZ-1)], ifName)
return ifaceLinkDownIoctl(&req)
}