-
Notifications
You must be signed in to change notification settings - Fork 3
/
dev_common.go
47 lines (37 loc) · 842 Bytes
/
dev_common.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
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
package nm
import (
"launchpad.net/~jamesh/go-dbus/trunk"
)
func (dev *Device) Mac() (string, error) {
tmp, err := dev.devTypeGet("HwAddress")
if err != nil {
return "", err
}
return tmp.(string), nil
}
func (dev *Device) PermMac() (string, error) {
tmp, err := dev.devTypeGet("PermHwAddress")
if err != nil {
return "", err
}
return tmp.(string), nil
}
func (dev *Device) AvailConnections() ([]*Connection, error) {
tmp, err := dev.Get(NM_DEV_IFACE, "AvailableConnections")
if err != nil {
return nil, err
}
var conns []*Connection
for _, connObjPath := range tmp.([]interface{}) {
conns = append(conns, &Connection{
ObjectPath: connObjPath.(dbus.ObjectPath),
Data: nil,
})
}
for _, conn := range conns {
if err := conn.Refresh(); err != nil {
return nil, err
}
}
return conns, nil
}