Implement wpa_supplicant backend
This commit is contained in:
parent
79c28da9c5
commit
04ada45f44
7 changed files with 874 additions and 2 deletions
41
internal/wifi/wpasupplicant/network.go
Normal file
41
internal/wifi/wpasupplicant/network.go
Normal file
|
|
@ -0,0 +1,41 @@
|
|||
package wpasupplicant
|
||||
|
||||
import (
|
||||
"github.com/godbus/dbus/v5"
|
||||
)
|
||||
|
||||
// Network represents a wpa_supplicant Network configuration object
|
||||
type Network struct {
|
||||
path dbus.ObjectPath
|
||||
conn *dbus.Conn
|
||||
obj dbus.BusObject
|
||||
}
|
||||
|
||||
// NewNetwork creates a new Network instance
|
||||
func NewNetwork(conn *dbus.Conn, path dbus.ObjectPath) *Network {
|
||||
return &Network{
|
||||
path: path,
|
||||
conn: conn,
|
||||
obj: conn.Object(Service, path),
|
||||
}
|
||||
}
|
||||
|
||||
// GetPath returns the D-Bus object path for this network
|
||||
func (n *Network) GetPath() dbus.ObjectPath {
|
||||
return n.path
|
||||
}
|
||||
|
||||
// GetProperties returns properties of the network configuration
|
||||
func (n *Network) GetProperties() (map[string]dbus.Variant, error) {
|
||||
prop, err := n.obj.GetProperty(NetworkInterface + ".Properties")
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
|
||||
props, ok := prop.Value().(map[string]dbus.Variant)
|
||||
if !ok {
|
||||
return nil, nil
|
||||
}
|
||||
|
||||
return props, nil
|
||||
}
|
||||
Loading…
Add table
Add a link
Reference in a new issue