summaryrefslogtreecommitdiffhomepage
path: root/netboot/rtnetlink_linux.go
blob: 41f5b3e6159e4794515f724a7d721ed5fb4b6d56 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
package netboot

import "github.com/jsimonetti/rtnetlink"

// getOperState returns the operational state for the given interface index.
func getOperState(iface int) (rtnetlink.OperationalState, error) {
	conn, err := rtnetlink.Dial(nil)
	if err != nil {
		return 0, err
	}
	msg, err := conn.Link.Get(uint32(iface))
	if err != nil {
		return 0, err
	}
	return msg.Attributes.OperationalState, nil
}