Implement better error handling for properties
This commit is contained in:
parent
dfa13818d7
commit
2a9ef418e6
18 changed files with 800 additions and 621 deletions
|
@ -9,7 +9,7 @@ import (
|
||||||
const (
|
const (
|
||||||
AccessPointInterface = NetworkManagerInterface + ".AccessPoint"
|
AccessPointInterface = NetworkManagerInterface + ".AccessPoint"
|
||||||
|
|
||||||
/* Property */
|
/* Properties */
|
||||||
AccessPointPropertyFlags = AccessPointInterface + ".Flags" // readable u
|
AccessPointPropertyFlags = AccessPointInterface + ".Flags" // readable u
|
||||||
AccessPointPropertyWpaFlags = AccessPointInterface + ".WpaFlags" // readable u
|
AccessPointPropertyWpaFlags = AccessPointInterface + ".WpaFlags" // readable u
|
||||||
AccessPointPropertyRsnFlags = AccessPointInterface + ".RsnFlags" // readable u
|
AccessPointPropertyRsnFlags = AccessPointInterface + ".RsnFlags" // readable u
|
||||||
|
@ -26,36 +26,36 @@ type AccessPoint interface {
|
||||||
GetPath() dbus.ObjectPath
|
GetPath() dbus.ObjectPath
|
||||||
|
|
||||||
// GetFlags gets flags describing the capabilities of the access point.
|
// GetFlags gets flags describing the capabilities of the access point.
|
||||||
GetFlags() uint32
|
GetPropertyFlags() (uint32, error)
|
||||||
|
|
||||||
// GetWPAFlags gets flags describing the access point's capabilities
|
// GetWPAFlags gets flags describing the access point's capabilities
|
||||||
// according to WPA (Wifi Protected Access).
|
// according to WPA (Wifi Protected Access).
|
||||||
GetWPAFlags() uint32
|
GetPropertyWPAFlags() (uint32, error)
|
||||||
|
|
||||||
// GetRSNFlags gets flags describing the access point's capabilities
|
// GetRSNFlags gets flags describing the access point's capabilities
|
||||||
// according to the RSN (Robust Secure Network) protocol.
|
// according to the RSN (Robust Secure Network) protocol.
|
||||||
GetRSNFlags() uint32
|
GetPropertyRSNFlags() (uint32, error)
|
||||||
|
|
||||||
// GetSSID returns the Service Set Identifier identifying the access point.
|
// GetSSID returns the Service Set Identifier identifying the access point.
|
||||||
GetSSID() string
|
GetPropertySSID() (string, error)
|
||||||
|
|
||||||
// GetFrequency gets the radio channel frequency in use by the access point,
|
// GetFrequency gets the radio channel frequency in use by the access point,
|
||||||
// in MHz.
|
// in MHz.
|
||||||
GetFrequency() uint32
|
GetPropertyFrequency() (uint32, error)
|
||||||
|
|
||||||
// GetHWAddress gets the hardware address (BSSID) of the access point.
|
// GetHWAddress gets the hardware address (BSSID) of the access point.
|
||||||
GetHWAddress() string
|
GetPropertyHWAddress() (string, error)
|
||||||
|
|
||||||
// GetMode describes the operating mode of the access point.
|
// GetMode describes the operating mode of the access point.
|
||||||
GetMode() Nm80211Mode
|
GetPropertyMode() (Nm80211Mode, error)
|
||||||
|
|
||||||
// GetMaxBitrate gets the maximum bitrate this access point is capable of, in
|
// GetMaxBitrate gets the maximum bitrate this access point is capable of, in
|
||||||
// kilobits/second (Kb/s).
|
// kilobits/second (Kb/s).
|
||||||
GetMaxBitrate() uint32
|
GetPropertyMaxBitrate() (uint32, error)
|
||||||
|
|
||||||
// GetStrength gets the current signal quality of the access point, in
|
// GetStrength gets the current signal quality of the access point, in
|
||||||
// percent.
|
// percent.
|
||||||
GetStrength() uint8
|
GetPropertyStrength() (uint8, error)
|
||||||
|
|
||||||
MarshalJSON() ([]byte, error)
|
MarshalJSON() ([]byte, error)
|
||||||
}
|
}
|
||||||
|
@ -73,52 +73,58 @@ func (a *accessPoint) GetPath() dbus.ObjectPath {
|
||||||
return a.obj.Path()
|
return a.obj.Path()
|
||||||
}
|
}
|
||||||
|
|
||||||
func (a *accessPoint) GetFlags() uint32 {
|
func (a *accessPoint) GetPropertyFlags() (uint32, error) {
|
||||||
return a.getUint32Property(AccessPointPropertyFlags)
|
return a.getUint32Property(AccessPointPropertyFlags)
|
||||||
}
|
}
|
||||||
|
|
||||||
func (a *accessPoint) GetWPAFlags() uint32 {
|
func (a *accessPoint) GetPropertyWPAFlags() (uint32, error) {
|
||||||
return a.getUint32Property(AccessPointPropertyWpaFlags)
|
return a.getUint32Property(AccessPointPropertyWpaFlags)
|
||||||
}
|
}
|
||||||
|
|
||||||
func (a *accessPoint) GetRSNFlags() uint32 {
|
func (a *accessPoint) GetPropertyRSNFlags() (uint32, error) {
|
||||||
return a.getUint32Property(AccessPointPropertyRsnFlags)
|
return a.getUint32Property(AccessPointPropertyRsnFlags)
|
||||||
}
|
}
|
||||||
|
|
||||||
func (a *accessPoint) GetSSID() string {
|
func (a *accessPoint) GetPropertySSID() (string, error) {
|
||||||
return string(a.getSliceByteProperty(AccessPointPropertySsid))
|
v, err := a.getSliceByteProperty(AccessPointPropertySsid)
|
||||||
|
return string(v), err
|
||||||
}
|
}
|
||||||
|
|
||||||
func (a *accessPoint) GetFrequency() uint32 {
|
func (a *accessPoint) GetPropertyFrequency() (uint32, error) {
|
||||||
return a.getUint32Property(AccessPointPropertyFrequency)
|
return a.getUint32Property(AccessPointPropertyFrequency)
|
||||||
}
|
}
|
||||||
|
|
||||||
func (a *accessPoint) GetHWAddress() string {
|
func (a *accessPoint) GetPropertyHWAddress() (string, error) {
|
||||||
return a.getStringProperty(AccessPointPropertyHwAddress)
|
return a.getStringProperty(AccessPointPropertyHwAddress)
|
||||||
}
|
}
|
||||||
|
|
||||||
func (a *accessPoint) GetMode() Nm80211Mode {
|
func (a *accessPoint) GetPropertyMode() (Nm80211Mode, error) {
|
||||||
return Nm80211Mode(a.getUint32Property(AccessPointPropertyMode))
|
v, err := a.getUint32Property(AccessPointPropertyMode)
|
||||||
|
return Nm80211Mode(v), err
|
||||||
}
|
}
|
||||||
|
|
||||||
func (a *accessPoint) GetMaxBitrate() uint32 {
|
func (a *accessPoint) GetPropertyMaxBitrate() (uint32, error) {
|
||||||
return a.getUint32Property(AccessPointPropertyMaxBitrate)
|
return a.getUint32Property(AccessPointPropertyMaxBitrate)
|
||||||
}
|
}
|
||||||
|
|
||||||
func (a *accessPoint) GetStrength() uint8 {
|
func (a *accessPoint) GetPropertyStrength() (uint8, error) {
|
||||||
return a.getUint8Property(AccessPointPropertyStrength)
|
return a.getUint8Property(AccessPointPropertyStrength)
|
||||||
}
|
}
|
||||||
|
|
||||||
func (a *accessPoint) MarshalJSON() ([]byte, error) {
|
func (a *accessPoint) MarshalJSON() ([]byte, error) {
|
||||||
return json.Marshal(map[string]interface{}{
|
m := make(map[string]interface{})
|
||||||
"Flags": a.GetFlags(),
|
|
||||||
"WPAFlags": a.GetWPAFlags(),
|
m["Flags"], _ = a.GetPropertyFlags()
|
||||||
"RSNFlags": a.GetRSNFlags(),
|
m["WPAFlags"], _ = a.GetPropertyWPAFlags()
|
||||||
"SSID": a.GetSSID(),
|
m["RSNFlags"], _ = a.GetPropertyRSNFlags()
|
||||||
"Frequency": a.GetFrequency(),
|
m["SSID"], _ = a.GetPropertySSID()
|
||||||
"HWAddress": a.GetHWAddress(),
|
m["Frequency"], _ = a.GetPropertyFrequency()
|
||||||
"Mode": a.GetMode().String(),
|
m["HWAddress"], _ = a.GetPropertyHWAddress()
|
||||||
"MaxBitrate": a.GetMaxBitrate(),
|
m["MaxBitrate"], _ = a.GetPropertyMaxBitrate()
|
||||||
"Strength": a.GetStrength(),
|
m["Strength"], _ = a.GetPropertyStrength()
|
||||||
})
|
|
||||||
|
mode, _ := a.GetPropertyMode()
|
||||||
|
m["Mode"] = mode.String()
|
||||||
|
|
||||||
|
return json.Marshal(m)
|
||||||
}
|
}
|
||||||
|
|
|
@ -7,7 +7,7 @@ import (
|
||||||
const (
|
const (
|
||||||
ActiveConnectionInterface = NetworkManagerInterface + ".Connection.Active"
|
ActiveConnectionInterface = NetworkManagerInterface + ".Connection.Active"
|
||||||
|
|
||||||
/* Property */
|
/* Properties */
|
||||||
ActiveConnectionPropertyConnection = ActiveConnectionInterface + ".Connection" // readable o
|
ActiveConnectionPropertyConnection = ActiveConnectionInterface + ".Connection" // readable o
|
||||||
ActiveConnectionPropertySpecificObject = ActiveConnectionInterface + ".SpecificObject" // readable o
|
ActiveConnectionPropertySpecificObject = ActiveConnectionInterface + ".SpecificObject" // readable o
|
||||||
ActiveConnectionPropertyId = ActiveConnectionInterface + ".Id" // readable s
|
ActiveConnectionPropertyId = ActiveConnectionInterface + ".Id" // readable s
|
||||||
|
@ -30,52 +30,52 @@ type ActiveConnection interface {
|
||||||
GetPath() dbus.ObjectPath
|
GetPath() dbus.ObjectPath
|
||||||
|
|
||||||
// GetConnectionSettings gets connection object of the connection.
|
// GetConnectionSettings gets connection object of the connection.
|
||||||
GetConnection() Connection
|
GetPropertyConnection() (Connection, error)
|
||||||
|
|
||||||
// GetSpecificObject gets a specific object associated with the active connection.
|
// GetSpecificObject gets a specific object associated with the active connection.
|
||||||
GetSpecificObject() AccessPoint
|
GetPropertySpecificObject() (AccessPoint, error)
|
||||||
|
|
||||||
// GetID gets the ID of the connection.
|
// GetID gets the ID of the connection.
|
||||||
GetID() string
|
GetPropertyID() (string, error)
|
||||||
|
|
||||||
// GetUUID gets the UUID of the connection.
|
// GetUUID gets the UUID of the connection.
|
||||||
GetUUID() string
|
GetPropertyUUID() (string, error)
|
||||||
|
|
||||||
// GetType gets the type of the connection.
|
// GetType gets the type of the connection.
|
||||||
GetType() string
|
GetPropertyType() (string, error)
|
||||||
|
|
||||||
// GetDevices gets array of device objects which are part of this active connection.
|
// GetDevices gets array of device objects which are part of this active connection.
|
||||||
GetDevices() []Device
|
GetPropertyDevices() ([]Device, error)
|
||||||
|
|
||||||
// GetState gets the state of the connection.
|
// GetState gets the state of the connection.
|
||||||
GetState() NmActiveConnectionState
|
GetPropertyState() (NmActiveConnectionState, error)
|
||||||
|
|
||||||
// GetStateFlags gets the state flags of the connection.
|
// GetStateFlags gets the state flags of the connection.
|
||||||
GetStateFlags() uint32
|
GetPropertyStateFlags() (uint32, error)
|
||||||
|
|
||||||
// GetDefault gets the default IPv4 flag of the connection.
|
// GetDefault gets the default IPv4 flag of the connection.
|
||||||
GetDefault() bool
|
GetPropertyDefault() (bool, error)
|
||||||
|
|
||||||
// GetIP4Config gets the IP4Config of the connection.
|
// GetIP4Config gets the IP4Config of the connection.
|
||||||
GetIP4Config() IP4Config
|
GetPropertyIP4Config() (IP4Config, error)
|
||||||
|
|
||||||
// GetDHCP4Config gets the DHCP6Config of the connection.
|
// GetDHCP4Config gets the DHCP6Config of the connection.
|
||||||
GetDHCP4Config() DHCP4Config
|
GetPropertyDHCP4Config() (DHCP4Config, error)
|
||||||
|
|
||||||
// GetDefault gets the default IPv6 flag of the connection.
|
// GetDefault gets the default IPv6 flag of the connection.
|
||||||
GetDefault6() bool
|
GetPropertyDefault6() (bool, error)
|
||||||
|
|
||||||
// GetIP6Config gets the IP6Config of the connection.
|
// GetIP6Config gets the IP6Config of the connection.
|
||||||
GetIP6Config() IP6Config
|
GetPropertyIP6Config() (IP6Config, error)
|
||||||
|
|
||||||
// GetDHCP6Config gets the DHCP4Config of the connection.
|
// GetDHCP6Config gets the DHCP4Config of the connection.
|
||||||
GetDHCP6Config() DHCP6Config
|
GetPropertyDHCP6Config() (DHCP6Config, error)
|
||||||
|
|
||||||
// GetVPN gets the VPN flag of the connection.
|
// GetVPN gets the VPN flag of the connection.
|
||||||
GetVPN() bool
|
GetPropertyVPN() (bool, error)
|
||||||
|
|
||||||
// GetMaster gets the master device of the connection.
|
// GetMaster gets the master device of the connection.
|
||||||
GetMaster() Device
|
GetPropertyMaster() (Device, error)
|
||||||
}
|
}
|
||||||
|
|
||||||
func NewActiveConnection(objectPath dbus.ObjectPath) (ActiveConnection, error) {
|
func NewActiveConnection(objectPath dbus.ObjectPath) (ActiveConnection, error) {
|
||||||
|
@ -91,129 +91,114 @@ func (a *activeConnection) GetPath() dbus.ObjectPath {
|
||||||
return a.obj.Path()
|
return a.obj.Path()
|
||||||
}
|
}
|
||||||
|
|
||||||
func (a *activeConnection) GetConnection() Connection {
|
func (a *activeConnection) GetPropertyConnection() (Connection, error) {
|
||||||
path := a.getObjectProperty(ActiveConnectionPropertyConnection)
|
path, err := a.getObjectProperty(ActiveConnectionPropertyConnection)
|
||||||
con, err := NewConnection(path)
|
|
||||||
if err != nil {
|
if err != nil {
|
||||||
panic(err)
|
return nil, err
|
||||||
}
|
}
|
||||||
return con
|
|
||||||
|
return NewConnection(path)
|
||||||
}
|
}
|
||||||
|
|
||||||
func (a *activeConnection) GetSpecificObject() AccessPoint {
|
func (a *activeConnection) GetPropertySpecificObject() (AccessPoint, error) {
|
||||||
path := a.getObjectProperty(ActiveConnectionPropertySpecificObject)
|
path, err := a.getObjectProperty(ActiveConnectionPropertySpecificObject)
|
||||||
ap, err := NewAccessPoint(path)
|
|
||||||
if err != nil {
|
if err != nil {
|
||||||
panic(err)
|
return nil, err
|
||||||
}
|
}
|
||||||
return ap
|
|
||||||
|
return NewAccessPoint(path)
|
||||||
}
|
}
|
||||||
|
|
||||||
func (a *activeConnection) GetID() string {
|
func (a *activeConnection) GetPropertyID() (string, error) {
|
||||||
return a.getStringProperty(ActiveConnectionPropertyId)
|
return a.getStringProperty(ActiveConnectionPropertyId)
|
||||||
}
|
}
|
||||||
|
|
||||||
func (a *activeConnection) GetUUID() string {
|
func (a *activeConnection) GetPropertyUUID() (string, error) {
|
||||||
return a.getStringProperty(ActiveConnectionPropertyUuid)
|
return a.getStringProperty(ActiveConnectionPropertyUuid)
|
||||||
}
|
}
|
||||||
|
|
||||||
func (a *activeConnection) GetType() string {
|
func (a *activeConnection) GetPropertyType() (string, error) {
|
||||||
return a.getStringProperty(ActiveConnectionPropertyType)
|
return a.getStringProperty(ActiveConnectionPropertyType)
|
||||||
}
|
}
|
||||||
|
|
||||||
func (a *activeConnection) GetDevices() []Device {
|
func (a *activeConnection) GetPropertyDevices() ([]Device, error) {
|
||||||
paths := a.getSliceObjectProperty(ActiveConnectionPropertyDevices)
|
paths, err := a.getSliceObjectProperty(ActiveConnectionPropertyDevices)
|
||||||
|
if err != nil {
|
||||||
|
return nil, err
|
||||||
|
}
|
||||||
|
|
||||||
devices := make([]Device, len(paths))
|
devices := make([]Device, len(paths))
|
||||||
var err error
|
|
||||||
for i, path := range paths {
|
for i, path := range paths {
|
||||||
devices[i], err = DeviceFactory(path)
|
devices[i], err = DeviceFactory(path)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
panic(err)
|
return devices, err
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
return devices
|
return devices, nil
|
||||||
}
|
}
|
||||||
|
|
||||||
func (a *activeConnection) GetState() NmActiveConnectionState {
|
func (a *activeConnection) GetPropertyState() (NmActiveConnectionState, error) {
|
||||||
return NmActiveConnectionState(a.getUint32Property(ActiveConnectionPropertyState))
|
v, err := a.getUint32Property(ActiveConnectionPropertyState)
|
||||||
|
return NmActiveConnectionState(v), err
|
||||||
}
|
}
|
||||||
|
|
||||||
func (a *activeConnection) GetStateFlags() uint32 {
|
func (a *activeConnection) GetPropertyStateFlags() (uint32, error) {
|
||||||
return a.getUint32Property(ActiveConnectionPropertyStateFlags)
|
return a.getUint32Property(ActiveConnectionPropertyStateFlags)
|
||||||
}
|
}
|
||||||
|
|
||||||
func (a *activeConnection) GetDefault() bool {
|
func (a *activeConnection) GetPropertyDefault() (bool, error) {
|
||||||
b := a.getProperty(ActiveConnectionPropertyDefault)
|
return a.getBoolProperty(ActiveConnectionPropertyDefault)
|
||||||
return b.(bool)
|
|
||||||
}
|
}
|
||||||
|
|
||||||
func (a *activeConnection) GetIP4Config() IP4Config {
|
func (a *activeConnection) GetPropertyIP4Config() (IP4Config, error) {
|
||||||
path := a.getObjectProperty(ActiveConnectionPropertyIp4Config)
|
path, err := a.getObjectProperty(ActiveConnectionPropertyIp4Config)
|
||||||
if path == "/" {
|
if err != nil || path == "/" {
|
||||||
return nil
|
return nil, err
|
||||||
}
|
}
|
||||||
|
|
||||||
r, err := NewIP4Config(path)
|
return NewIP4Config(path)
|
||||||
|
}
|
||||||
|
|
||||||
|
func (a *activeConnection) GetPropertyDHCP4Config() (DHCP4Config, error) {
|
||||||
|
path, err := a.getObjectProperty(ActiveConnectionPropertyDhcp4Config)
|
||||||
|
if err != nil || path == "/" {
|
||||||
|
return nil, err
|
||||||
|
}
|
||||||
|
|
||||||
|
return NewDHCP4Config(path)
|
||||||
|
}
|
||||||
|
|
||||||
|
func (a *activeConnection) GetPropertyDefault6() (bool, error) {
|
||||||
|
return a.getBoolProperty(ActiveConnectionPropertyDefault6)
|
||||||
|
}
|
||||||
|
|
||||||
|
func (a *activeConnection) GetPropertyIP6Config() (IP6Config, error) {
|
||||||
|
path, err := a.getObjectProperty(ActiveConnectionPropertyIp6Config)
|
||||||
|
if err != nil || path == "/" {
|
||||||
|
return nil, err
|
||||||
|
}
|
||||||
|
|
||||||
|
return NewIP6Config(path)
|
||||||
|
}
|
||||||
|
|
||||||
|
func (a *activeConnection) GetPropertyDHCP6Config() (DHCP6Config, error) {
|
||||||
|
path, err := a.getObjectProperty(ActiveConnectionPropertyDhcp6Config)
|
||||||
|
if err != nil || path == "/" {
|
||||||
|
return nil, err
|
||||||
|
}
|
||||||
|
|
||||||
|
return NewDHCP6Config(path)
|
||||||
|
}
|
||||||
|
|
||||||
|
func (a *activeConnection) GetPropertyVPN() (bool, error) {
|
||||||
|
return a.getBoolProperty(ActiveConnectionPropertyVpn)
|
||||||
|
}
|
||||||
|
|
||||||
|
func (a *activeConnection) GetPropertyMaster() (Device, error) {
|
||||||
|
path, err := a.getObjectProperty(ActiveConnectionPropertyMaster)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
panic(err)
|
return nil, err
|
||||||
}
|
}
|
||||||
return r
|
|
||||||
}
|
return DeviceFactory(path)
|
||||||
|
|
||||||
func (a *activeConnection) GetDHCP4Config() DHCP4Config {
|
|
||||||
path := a.getObjectProperty(ActiveConnectionPropertyDhcp4Config)
|
|
||||||
if path == "/" {
|
|
||||||
return nil
|
|
||||||
}
|
|
||||||
|
|
||||||
r, err := NewDHCP4Config(path)
|
|
||||||
if err != nil {
|
|
||||||
panic(err)
|
|
||||||
}
|
|
||||||
return r
|
|
||||||
}
|
|
||||||
|
|
||||||
func (a *activeConnection) GetDefault6() bool {
|
|
||||||
b := a.getProperty(ActiveConnectionPropertyDefault6)
|
|
||||||
return b.(bool)
|
|
||||||
}
|
|
||||||
|
|
||||||
func (a *activeConnection) GetIP6Config() IP6Config {
|
|
||||||
path := a.getObjectProperty(ActiveConnectionPropertyIp6Config)
|
|
||||||
if path == "/" {
|
|
||||||
return nil
|
|
||||||
}
|
|
||||||
|
|
||||||
r, err := NewIP6Config(path)
|
|
||||||
if err != nil {
|
|
||||||
panic(err)
|
|
||||||
}
|
|
||||||
return r
|
|
||||||
}
|
|
||||||
|
|
||||||
func (a *activeConnection) GetDHCP6Config() DHCP6Config {
|
|
||||||
path := a.getObjectProperty(ActiveConnectionPropertyDhcp6Config)
|
|
||||||
if path == "/" {
|
|
||||||
return nil
|
|
||||||
}
|
|
||||||
|
|
||||||
r, err := NewDHCP6Config(path)
|
|
||||||
if err != nil {
|
|
||||||
panic(err)
|
|
||||||
}
|
|
||||||
return r
|
|
||||||
}
|
|
||||||
|
|
||||||
func (a *activeConnection) GetVPN() bool {
|
|
||||||
ret := a.getProperty(ActiveConnectionPropertyVpn)
|
|
||||||
return ret.(bool)
|
|
||||||
}
|
|
||||||
|
|
||||||
func (a *activeConnection) GetMaster() Device {
|
|
||||||
path := a.getObjectProperty(ActiveConnectionPropertyMaster)
|
|
||||||
r, err := DeviceFactory(path)
|
|
||||||
if err != nil {
|
|
||||||
panic(err)
|
|
||||||
}
|
|
||||||
return r
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -2,6 +2,7 @@ package gonetworkmanager
|
||||||
|
|
||||||
import (
|
import (
|
||||||
"encoding/json"
|
"encoding/json"
|
||||||
|
|
||||||
"github.com/godbus/dbus"
|
"github.com/godbus/dbus"
|
||||||
)
|
)
|
||||||
|
|
||||||
|
@ -18,13 +19,13 @@ type Checkpoint interface {
|
||||||
GetPath() dbus.ObjectPath
|
GetPath() dbus.ObjectPath
|
||||||
|
|
||||||
// Array of object paths for devices which are part of this checkpoint.
|
// Array of object paths for devices which are part of this checkpoint.
|
||||||
GetPropertyDevices() []Device
|
GetPropertyDevices() ([]Device, error)
|
||||||
|
|
||||||
// The timestamp (in CLOCK_BOOTTIME milliseconds) of checkpoint creation.
|
// The timestamp (in CLOCK_BOOTTIME milliseconds) of checkpoint creation.
|
||||||
GetPropertyCreated() int64
|
GetPropertyCreated() (int64, error)
|
||||||
|
|
||||||
// Timeout in seconds for automatic rollback, or zero.
|
// Timeout in seconds for automatic rollback, or zero.
|
||||||
GetPropertyRollbackTimeout() uint32
|
GetPropertyRollbackTimeout() (uint32, error)
|
||||||
|
|
||||||
MarshalJSON() ([]byte, error)
|
MarshalJSON() ([]byte, error)
|
||||||
}
|
}
|
||||||
|
@ -38,26 +39,28 @@ type checkpoint struct {
|
||||||
dbusBase
|
dbusBase
|
||||||
}
|
}
|
||||||
|
|
||||||
func (c *checkpoint) GetPropertyDevices() []Device {
|
func (c *checkpoint) GetPropertyDevices() ([]Device, error) {
|
||||||
devicesPaths := c.getSliceObjectProperty(CheckpointPropertyDevices)
|
devicesPaths, err := c.getSliceObjectProperty(CheckpointPropertyDevices)
|
||||||
devices := make([]Device, len(devicesPaths))
|
if err != nil {
|
||||||
|
return nil, err
|
||||||
|
}
|
||||||
|
|
||||||
var err error
|
devices := make([]Device, len(devicesPaths))
|
||||||
for i, path := range devicesPaths {
|
for i, path := range devicesPaths {
|
||||||
devices[i], err = NewDevice(path)
|
devices[i], err = NewDevice(path)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
panic(err)
|
return devices, err
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
return devices
|
return devices, nil
|
||||||
}
|
}
|
||||||
|
|
||||||
func (c *checkpoint) GetPropertyCreated() int64 {
|
func (c *checkpoint) GetPropertyCreated() (int64, error) {
|
||||||
return c.getInt64Property(CheckpointPropertyCreated)
|
return c.getInt64Property(CheckpointPropertyCreated)
|
||||||
}
|
}
|
||||||
|
|
||||||
func (c *checkpoint) GetPropertyRollbackTimeout() uint32 {
|
func (c *checkpoint) GetPropertyRollbackTimeout() (uint32, error) {
|
||||||
return c.getUint32Property(CheckpointPropertyRollbackTimeout)
|
return c.getUint32Property(CheckpointPropertyRollbackTimeout)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -65,14 +68,12 @@ func (c *checkpoint) GetPath() dbus.ObjectPath {
|
||||||
return c.obj.Path()
|
return c.obj.Path()
|
||||||
}
|
}
|
||||||
|
|
||||||
func (c *checkpoint) marshalMap() map[string]interface{} {
|
|
||||||
return map[string]interface{}{
|
|
||||||
"Devices": c.GetPropertyDevices(),
|
|
||||||
"Created": c.GetPropertyCreated(),
|
|
||||||
"RollbackTimeout": c.GetPropertyRollbackTimeout(),
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
func (c *checkpoint) MarshalJSON() ([]byte, error) {
|
func (c *checkpoint) MarshalJSON() ([]byte, error) {
|
||||||
return json.Marshal(c.marshalMap())
|
m := make(map[string]interface{})
|
||||||
|
|
||||||
|
m["Devices"], _ = c.GetPropertyDevices()
|
||||||
|
m["Created"], _ = c.GetPropertyCreated()
|
||||||
|
m["RollbackTimeout"], _ = c.GetPropertyRollbackTimeout()
|
||||||
|
|
||||||
|
return json.Marshal(m)
|
||||||
}
|
}
|
||||||
|
|
|
@ -53,13 +53,13 @@ type Connection interface {
|
||||||
Save() error
|
Save() error
|
||||||
|
|
||||||
// If set, indicates that the in-memory state of the connection does not match the on-disk state. This flag will be set when UpdateUnsaved() is called or when any connection details change, and cleared when the connection is saved to disk via Save() or from internal operations.
|
// If set, indicates that the in-memory state of the connection does not match the on-disk state. This flag will be set when UpdateUnsaved() is called or when any connection details change, and cleared when the connection is saved to disk via Save() or from internal operations.
|
||||||
GetUnsaved() bool
|
GetPropertyUnsaved() (bool, error)
|
||||||
|
|
||||||
// Additional flags of the connection profile.
|
// Additional flags of the connection profile.
|
||||||
GetFlags() uint32
|
GetPropertyFlags() (uint32, error)
|
||||||
|
|
||||||
// File that stores the connection in case the connection is file-backed.
|
// File that stores the connection in case the connection is file-backed.
|
||||||
GetFilename() string
|
GetPropertyFilename() (string, error)
|
||||||
|
|
||||||
MarshalJSON() ([]byte, error)
|
MarshalJSON() ([]byte, error)
|
||||||
}
|
}
|
||||||
|
@ -114,15 +114,15 @@ func (c *connection) Save() error {
|
||||||
return c.call(ConnectionSave)
|
return c.call(ConnectionSave)
|
||||||
}
|
}
|
||||||
|
|
||||||
func (c *connection) GetUnsaved() bool {
|
func (c *connection) GetPropertyUnsaved() (bool, error) {
|
||||||
return c.getBoolProperty(ConnectionPropertyUnsaved)
|
return c.getBoolProperty(ConnectionPropertyUnsaved)
|
||||||
}
|
}
|
||||||
|
|
||||||
func (c *connection) GetFlags() uint32 {
|
func (c *connection) GetPropertyFlags() (uint32, error) {
|
||||||
return c.getUint32Property(ConnectionPropertyFlags)
|
return c.getUint32Property(ConnectionPropertyFlags)
|
||||||
}
|
}
|
||||||
|
|
||||||
func (c *connection) GetFilename() string {
|
func (c *connection) GetPropertyFilename() (string, error) {
|
||||||
return c.getStringProperty(ConnectionPropertyFilename)
|
return c.getStringProperty(ConnectionPropertyFilename)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -9,6 +9,7 @@ import (
|
||||||
const (
|
const (
|
||||||
DHCP4ConfigInterface = NetworkManagerInterface + ".DHCP4Config"
|
DHCP4ConfigInterface = NetworkManagerInterface + ".DHCP4Config"
|
||||||
|
|
||||||
|
// Properties
|
||||||
DHCP4ConfigPropertyOptions = DHCP4ConfigInterface + ".Options"
|
DHCP4ConfigPropertyOptions = DHCP4ConfigInterface + ".Options"
|
||||||
)
|
)
|
||||||
|
|
||||||
|
@ -16,7 +17,7 @@ type DHCP4Options map[string]interface{}
|
||||||
|
|
||||||
type DHCP4Config interface {
|
type DHCP4Config interface {
|
||||||
// GetOptions gets options map of configuration returned by the IPv4 DHCP server.
|
// GetOptions gets options map of configuration returned by the IPv4 DHCP server.
|
||||||
GetOptions() DHCP4Options
|
GetPropertyOptions() (DHCP4Options, error)
|
||||||
|
|
||||||
MarshalJSON() ([]byte, error)
|
MarshalJSON() ([]byte, error)
|
||||||
}
|
}
|
||||||
|
@ -30,19 +31,23 @@ type dhcp4Config struct {
|
||||||
dbusBase
|
dbusBase
|
||||||
}
|
}
|
||||||
|
|
||||||
func (c *dhcp4Config) GetOptions() DHCP4Options {
|
func (c *dhcp4Config) GetPropertyOptions() (DHCP4Options, error) {
|
||||||
options := c.getMapStringVariantProperty(DHCP4ConfigPropertyOptions)
|
options, err := c.getMapStringVariantProperty(DHCP4ConfigPropertyOptions)
|
||||||
rv := make(DHCP4Options)
|
rv := make(DHCP4Options)
|
||||||
|
if err != nil {
|
||||||
|
return rv, err
|
||||||
|
}
|
||||||
|
|
||||||
for k, v := range options {
|
for k, v := range options {
|
||||||
rv[k] = v.Value()
|
rv[k] = v.Value()
|
||||||
}
|
}
|
||||||
|
|
||||||
return rv
|
return rv, nil
|
||||||
}
|
}
|
||||||
|
|
||||||
func (c *dhcp4Config) MarshalJSON() ([]byte, error) {
|
func (c *dhcp4Config) MarshalJSON() ([]byte, error) {
|
||||||
return json.Marshal(map[string]interface{}{
|
m := make(map[string]interface{})
|
||||||
"Options": c.GetOptions(),
|
m["Options"], _ = c.GetPropertyOptions()
|
||||||
})
|
|
||||||
|
return json.Marshal(m)
|
||||||
}
|
}
|
||||||
|
|
|
@ -9,6 +9,7 @@ import (
|
||||||
const (
|
const (
|
||||||
DHCP6ConfigInterface = NetworkManagerInterface + ".DHCP6Config"
|
DHCP6ConfigInterface = NetworkManagerInterface + ".DHCP6Config"
|
||||||
|
|
||||||
|
// Properties
|
||||||
DHCP6ConfigPropertyOptions = DHCP6ConfigInterface + ".Options"
|
DHCP6ConfigPropertyOptions = DHCP6ConfigInterface + ".Options"
|
||||||
)
|
)
|
||||||
|
|
||||||
|
@ -16,7 +17,7 @@ type DHCP6Options map[string]interface{}
|
||||||
|
|
||||||
type DHCP6Config interface {
|
type DHCP6Config interface {
|
||||||
// GetOptions gets options map of configuration returned by the IPv4 DHCP server.
|
// GetOptions gets options map of configuration returned by the IPv4 DHCP server.
|
||||||
GetOptions() DHCP6Options
|
GetPropertyOptions() (DHCP6Options, error)
|
||||||
|
|
||||||
MarshalJSON() ([]byte, error)
|
MarshalJSON() ([]byte, error)
|
||||||
}
|
}
|
||||||
|
@ -30,19 +31,24 @@ type dhcp6Config struct {
|
||||||
dbusBase
|
dbusBase
|
||||||
}
|
}
|
||||||
|
|
||||||
func (c *dhcp6Config) GetOptions() DHCP6Options {
|
func (c *dhcp6Config) GetPropertyOptions() (DHCP6Options, error) {
|
||||||
options := c.getMapStringVariantProperty(DHCP6ConfigPropertyOptions)
|
options, err := c.getMapStringVariantProperty(DHCP6ConfigPropertyOptions)
|
||||||
rv := make(DHCP6Options)
|
rv := make(DHCP6Options)
|
||||||
|
|
||||||
|
if err != nil {
|
||||||
|
return rv, err
|
||||||
|
}
|
||||||
|
|
||||||
for k, v := range options {
|
for k, v := range options {
|
||||||
rv[k] = v.Value()
|
rv[k] = v.Value()
|
||||||
}
|
}
|
||||||
|
|
||||||
return rv
|
return rv, nil
|
||||||
}
|
}
|
||||||
|
|
||||||
func (c *dhcp6Config) MarshalJSON() ([]byte, error) {
|
func (c *dhcp6Config) MarshalJSON() ([]byte, error) {
|
||||||
return json.Marshal(map[string]interface{}{
|
m := make(map[string]interface{})
|
||||||
"Options": c.GetOptions(),
|
m["Options"], _ = c.GetPropertyOptions()
|
||||||
})
|
|
||||||
|
return json.Marshal(m)
|
||||||
}
|
}
|
||||||
|
|
181
Device.go
181
Device.go
|
@ -50,7 +50,12 @@ func DeviceFactory(objectPath dbus.ObjectPath) (Device, error) {
|
||||||
return nil, err
|
return nil, err
|
||||||
}
|
}
|
||||||
|
|
||||||
switch d.GetDeviceType() {
|
deviceType, err := d.GetPropertyDeviceType()
|
||||||
|
if err != nil {
|
||||||
|
return nil, err
|
||||||
|
}
|
||||||
|
|
||||||
|
switch deviceType {
|
||||||
case NmDeviceTypeDummy:
|
case NmDeviceTypeDummy:
|
||||||
return NewDeviceDummy(objectPath)
|
return NewDeviceDummy(objectPath)
|
||||||
case NmDeviceTypeGeneric:
|
case NmDeviceTypeGeneric:
|
||||||
|
@ -76,64 +81,64 @@ type Device interface {
|
||||||
Delete() error
|
Delete() error
|
||||||
|
|
||||||
// Operating-system specific transient device hardware identifier. This is an opaque string representing the underlying hardware for the device, and shouldn't be used to keep track of individual devices. For some device types (Bluetooth, Modems) it is an identifier used by the hardware service (ie bluez or ModemManager) to refer to that device, and client programs use it get additional information from those services which NM does not provide. The Udi is not guaranteed to be consistent across reboots or hotplugs of the hardware. If you're looking for a way to uniquely track each device in your application, use the object path. If you're looking for a way to track a specific piece of hardware across reboot or hotplug, use a MAC address or USB serial number.
|
// Operating-system specific transient device hardware identifier. This is an opaque string representing the underlying hardware for the device, and shouldn't be used to keep track of individual devices. For some device types (Bluetooth, Modems) it is an identifier used by the hardware service (ie bluez or ModemManager) to refer to that device, and client programs use it get additional information from those services which NM does not provide. The Udi is not guaranteed to be consistent across reboots or hotplugs of the hardware. If you're looking for a way to uniquely track each device in your application, use the object path. If you're looking for a way to track a specific piece of hardware across reboot or hotplug, use a MAC address or USB serial number.
|
||||||
GetUdi() string
|
GetPropertyUdi() (string, error)
|
||||||
|
|
||||||
// The name of the device's control (and often data) interface. Note that non UTF-8 characters are backslash escaped, so the resulting name may be longer then 15 characters. Use g_strcompress() to revert the escaping.
|
// The name of the device's control (and often data) interface. Note that non UTF-8 characters are backslash escaped, so the resulting name may be longer then 15 characters. Use g_strcompress() to revert the escaping.
|
||||||
GetInterface() string
|
GetPropertyInterface() (string, error)
|
||||||
|
|
||||||
// The name of the device's data interface when available. This property may not refer to the actual data interface until the device has successfully established a data connection, indicated by the device's State becoming ACTIVATED. Note that non UTF-8 characters are backslash escaped, so the resulting name may be longer then 15 characters. Use g_strcompress() to revert the escaping.
|
// The name of the device's data interface when available. This property may not refer to the actual data interface until the device has successfully established a data connection, indicated by the device's State becoming ACTIVATED. Note that non UTF-8 characters are backslash escaped, so the resulting name may be longer then 15 characters. Use g_strcompress() to revert the escaping.
|
||||||
GetIpInterface() string
|
GetPropertyIpInterface() (string, error)
|
||||||
|
|
||||||
// The driver handling the device. Non-UTF-8 sequences are backslash escaped. Use g_strcompress() to revert.
|
// The driver handling the device. Non-UTF-8 sequences are backslash escaped. Use g_strcompress() to revert.
|
||||||
GetDriver() string
|
GetPropertyDriver() (string, error)
|
||||||
|
|
||||||
// The version of the driver handling the device. Non-UTF-8 sequences are backslash escaped. Use g_strcompress() to revert.
|
// The version of the driver handling the device. Non-UTF-8 sequences are backslash escaped. Use g_strcompress() to revert.
|
||||||
GetDriverVersion() string
|
GetPropertyDriverVersion() (string, error)
|
||||||
|
|
||||||
// The firmware version for the device. Non-UTF-8 sequences are backslash escaped. Use g_strcompress() to revert.
|
// The firmware version for the device. Non-UTF-8 sequences are backslash escaped. Use g_strcompress() to revert.
|
||||||
GetFirmwareVersion() string
|
GetPropertyFirmwareVersion() (string, error)
|
||||||
|
|
||||||
// The current state of the device.
|
// The current state of the device.
|
||||||
GetState() NmDeviceState
|
GetPropertyState() (NmDeviceState, error)
|
||||||
|
|
||||||
// Object path of the Ip4Config object describing the configuration of the device. Only valid when the device is in the NM_DEVICE_STATE_ACTIVATED state.
|
// Object path of the Ip4Config object describing the configuration of the device. Only valid when the device is in the NM_DEVICE_STATE_ACTIVATED state.
|
||||||
GetIP4Config() IP4Config
|
GetPropertyIP4Config() (IP4Config, error)
|
||||||
|
|
||||||
// Object path of the Dhcp4Config object describing the DHCP options returned by the DHCP server. Only valid when the device is in the NM_DEVICE_STATE_ACTIVATED state.
|
// Object path of the Dhcp4Config object describing the DHCP options returned by the DHCP server. Only valid when the device is in the NM_DEVICE_STATE_ACTIVATED state.
|
||||||
GetDHCP4Config() DHCP4Config
|
GetPropertyDHCP4Config() (DHCP4Config, error)
|
||||||
|
|
||||||
// Object path of the Ip6Config object describing the configuration of the device. Only valid when the device is in the NM_DEVICE_STATE_ACTIVATED state.
|
// Object path of the Ip6Config object describing the configuration of the device. Only valid when the device is in the NM_DEVICE_STATE_ACTIVATED state.
|
||||||
GetIP6Config() IP6Config
|
GetPropertyIP6Config() (IP6Config, error)
|
||||||
|
|
||||||
// Object path of the Dhcp6Config object describing the DHCP options returned by the DHCP server. Only valid when the device is in the NM_DEVICE_STATE_ACTIVATED state.
|
// Object path of the Dhcp6Config object describing the DHCP options returned by the DHCP server. Only valid when the device is in the NM_DEVICE_STATE_ACTIVATED state.
|
||||||
GetDHCP6Config() DHCP6Config
|
GetPropertyDHCP6Config() (DHCP6Config, error)
|
||||||
|
|
||||||
// Whether or not this device is managed by NetworkManager. Setting this property has a similar effect to configuring the device as unmanaged via the keyfile.unmanaged-devices setting in NetworkManager.conf. Changes to this value are not persistent and lost after NetworkManager restart.
|
// Whether or not this device is managed by NetworkManager. Setting this property has a similar effect to configuring the device as unmanaged via the keyfile.unmanaged-devices setting in NetworkManager.conf. Changes to this value are not persistent and lost after NetworkManager restart.
|
||||||
GetManaged() bool
|
GetPropertyManaged() (bool, error)
|
||||||
|
|
||||||
// If TRUE, indicates the device is allowed to autoconnect. If FALSE, manual intervention is required before the device will automatically connect to a known network, such as activating a connection using the device, or setting this property to TRUE. This property cannot be set to TRUE for default-unmanaged devices, since they never autoconnect.
|
// If TRUE, indicates the device is allowed to autoconnect. If FALSE, manual intervention is required before the device will automatically connect to a known network, such as activating a connection using the device, or setting this property to TRUE. This property cannot be set to TRUE for default-unmanaged devices, since they never autoconnect.
|
||||||
GetAutoConnect() bool
|
GetPropertyAutoConnect() (bool, error)
|
||||||
|
|
||||||
// If TRUE, indicates the device is likely missing firmware necessary for its operation.
|
// If TRUE, indicates the device is likely missing firmware necessary for its operation.
|
||||||
GetFirmwareMissing() bool
|
GetPropertyFirmwareMissing() (bool, error)
|
||||||
|
|
||||||
// If TRUE, indicates the NetworkManager plugin for the device is likely missing or misconfigured.
|
// If TRUE, indicates the NetworkManager plugin for the device is likely missing or misconfigured.
|
||||||
GetNmPluginMissing() bool
|
GetPropertyNmPluginMissing() (bool, error)
|
||||||
|
|
||||||
// The general type of the network device; ie Ethernet, Wi-Fi, etc.
|
// The general type of the network device; ie Ethernet, Wi-Fi, etc.
|
||||||
GetDeviceType() NmDeviceType
|
GetPropertyDeviceType() (NmDeviceType, error)
|
||||||
|
|
||||||
// An array of object paths of every configured connection that is currently 'available' through this device.
|
// An array of object paths of every configured connection that is currently 'available' through this device.
|
||||||
GetAvailableConnections() []Connection
|
GetPropertyAvailableConnections() ([]Connection, error)
|
||||||
|
|
||||||
// If non-empty, an (opaque) indicator of the physical network port associated with the device. This can be used to recognize when two seemingly-separate hardware devices are actually just different virtual interfaces to the same physical port.
|
// If non-empty, an (opaque) indicator of the physical network port associated with the device. This can be used to recognize when two seemingly-separate hardware devices are actually just different virtual interfaces to the same physical port.
|
||||||
GetPhysicalPortId() string
|
GetPropertyPhysicalPortId() (string, error)
|
||||||
|
|
||||||
// The device MTU (maximum transmission unit).
|
// The device MTU (maximum transmission unit).
|
||||||
GetMtu() uint32
|
GetPropertyMtu() (uint32, error)
|
||||||
|
|
||||||
// True if the device exists, or False for placeholder devices that do not yet exist but could be automatically created by NetworkManager if one of their AvailableConnections was activated.
|
// True if the device exists, or False for placeholder devices that do not yet exist but could be automatically created by NetworkManager if one of their AvailableConnections was activated.
|
||||||
GetReal() bool
|
GetPropertyReal() (bool, error)
|
||||||
|
|
||||||
MarshalJSON() ([]byte, error)
|
MarshalJSON() ([]byte, error)
|
||||||
}
|
}
|
||||||
|
@ -159,147 +164,137 @@ func (d *device) Delete() error {
|
||||||
return d.call(DeviceDelete)
|
return d.call(DeviceDelete)
|
||||||
}
|
}
|
||||||
|
|
||||||
func (d *device) GetUdi() string {
|
func (d *device) GetPropertyUdi() (string, error) {
|
||||||
return d.getStringProperty(DevicePropertyUdi)
|
return d.getStringProperty(DevicePropertyUdi)
|
||||||
}
|
}
|
||||||
|
|
||||||
func (d *device) GetInterface() string {
|
func (d *device) GetPropertyInterface() (string, error) {
|
||||||
return d.getStringProperty(DevicePropertyInterface)
|
return d.getStringProperty(DevicePropertyInterface)
|
||||||
}
|
}
|
||||||
|
|
||||||
func (d *device) GetIpInterface() string {
|
func (d *device) GetPropertyIpInterface() (string, error) {
|
||||||
return d.getStringProperty(DevicePropertyIpInterface)
|
return d.getStringProperty(DevicePropertyIpInterface)
|
||||||
}
|
}
|
||||||
|
|
||||||
func (d *device) GetDriver() string {
|
func (d *device) GetPropertyDriver() (string, error) {
|
||||||
return d.getStringProperty(DevicePropertyDriver)
|
return d.getStringProperty(DevicePropertyDriver)
|
||||||
}
|
}
|
||||||
|
|
||||||
func (d *device) GetDriverVersion() string {
|
func (d *device) GetPropertyDriverVersion() (string, error) {
|
||||||
return d.getStringProperty(DevicePropertyDriverVersion)
|
return d.getStringProperty(DevicePropertyDriverVersion)
|
||||||
}
|
}
|
||||||
|
|
||||||
func (d *device) GetFirmwareVersion() string {
|
func (d *device) GetPropertyFirmwareVersion() (string, error) {
|
||||||
return d.getStringProperty(DevicePropertyFirmwareVersion)
|
return d.getStringProperty(DevicePropertyFirmwareVersion)
|
||||||
}
|
}
|
||||||
|
|
||||||
func (d *device) GetState() NmDeviceState {
|
func (d *device) GetPropertyState() (NmDeviceState, error) {
|
||||||
return NmDeviceState(d.getUint32Property(DevicePropertyState))
|
v, err := d.getUint32Property(DevicePropertyState)
|
||||||
|
return NmDeviceState(v), err
|
||||||
}
|
}
|
||||||
|
|
||||||
func (d *device) GetIP4Config() IP4Config {
|
func (d *device) GetPropertyIP4Config() (IP4Config, error) {
|
||||||
path := d.getObjectProperty(DevicePropertyIp4Config)
|
path, err := d.getObjectProperty(DevicePropertyIp4Config)
|
||||||
if path == "/" {
|
if err != nil || path == "/" {
|
||||||
return nil
|
return nil, err
|
||||||
}
|
}
|
||||||
|
|
||||||
cfg, err := NewIP4Config(path)
|
return NewIP4Config(path)
|
||||||
if err != nil {
|
|
||||||
panic(err)
|
|
||||||
}
|
|
||||||
|
|
||||||
return cfg
|
|
||||||
}
|
}
|
||||||
|
|
||||||
func (d *device) GetDHCP4Config() DHCP4Config {
|
func (d *device) GetPropertyDHCP4Config() (DHCP4Config, error) {
|
||||||
path := d.getObjectProperty(DevicePropertyDhcp4Config)
|
path, err := d.getObjectProperty(DevicePropertyDhcp4Config)
|
||||||
if path == "/" {
|
if err != nil || path == "/" {
|
||||||
return nil
|
return nil, err
|
||||||
}
|
}
|
||||||
|
|
||||||
cfg, err := NewDHCP4Config(path)
|
return NewDHCP4Config(path)
|
||||||
if err != nil {
|
|
||||||
panic(err)
|
|
||||||
}
|
|
||||||
|
|
||||||
return cfg
|
|
||||||
}
|
}
|
||||||
|
|
||||||
func (d *device) GetIP6Config() IP6Config {
|
func (d *device) GetPropertyIP6Config() (IP6Config, error) {
|
||||||
path := d.getObjectProperty(DevicePropertyIp6Config)
|
path, err := d.getObjectProperty(DevicePropertyIp6Config)
|
||||||
if path == "/" {
|
if err != nil || path == "/" {
|
||||||
return nil
|
return nil, err
|
||||||
}
|
}
|
||||||
|
|
||||||
cfg, err := NewIP6Config(path)
|
return NewIP6Config(path)
|
||||||
if err != nil {
|
|
||||||
panic(err)
|
|
||||||
}
|
|
||||||
|
|
||||||
return cfg
|
|
||||||
}
|
}
|
||||||
|
|
||||||
func (d *device) GetDHCP6Config() DHCP6Config {
|
func (d *device) GetPropertyDHCP6Config() (DHCP6Config, error) {
|
||||||
path := d.getObjectProperty(DevicePropertyDhcp6Config)
|
path, err := d.getObjectProperty(DevicePropertyDhcp6Config)
|
||||||
if path == "/" {
|
if err != nil || path == "/" {
|
||||||
return nil
|
return nil, err
|
||||||
}
|
}
|
||||||
|
|
||||||
cfg, err := NewDHCP6Config(path)
|
return NewDHCP6Config(path)
|
||||||
if err != nil {
|
|
||||||
panic(err)
|
|
||||||
}
|
|
||||||
|
|
||||||
return cfg
|
|
||||||
}
|
}
|
||||||
|
|
||||||
func (d *device) GetManaged() bool {
|
func (d *device) GetPropertyManaged() (bool, error) {
|
||||||
return d.getBoolProperty(DevicePropertyManaged)
|
return d.getBoolProperty(DevicePropertyManaged)
|
||||||
}
|
}
|
||||||
|
|
||||||
func (d *device) GetAutoConnect() bool {
|
func (d *device) GetPropertyAutoConnect() (bool, error) {
|
||||||
return d.getBoolProperty(DevicePropertyAutoconnect)
|
return d.getBoolProperty(DevicePropertyAutoconnect)
|
||||||
}
|
}
|
||||||
|
|
||||||
func (d *device) GetFirmwareMissing() bool {
|
func (d *device) GetPropertyFirmwareMissing() (bool, error) {
|
||||||
return d.getBoolProperty(DevicePropertyFirmwareMissing)
|
return d.getBoolProperty(DevicePropertyFirmwareMissing)
|
||||||
}
|
}
|
||||||
|
|
||||||
func (d *device) GetNmPluginMissing() bool {
|
func (d *device) GetPropertyNmPluginMissing() (bool, error) {
|
||||||
return d.getBoolProperty(DevicePropertyNmPluginMissing)
|
return d.getBoolProperty(DevicePropertyNmPluginMissing)
|
||||||
}
|
}
|
||||||
|
|
||||||
func (d *device) GetDeviceType() NmDeviceType {
|
func (d *device) GetPropertyDeviceType() (NmDeviceType, error) {
|
||||||
return NmDeviceType(d.getUint32Property(DevicePropertyDeviceType))
|
v, err := d.getUint32Property(DevicePropertyDeviceType)
|
||||||
|
return NmDeviceType(v), err
|
||||||
}
|
}
|
||||||
|
|
||||||
func (d *device) GetAvailableConnections() []Connection {
|
func (d *device) GetPropertyAvailableConnections() ([]Connection, error) {
|
||||||
connPaths := d.getSliceObjectProperty(DevicePropertyAvailableConnections)
|
connPaths, err := d.getSliceObjectProperty(DevicePropertyAvailableConnections)
|
||||||
conns := make([]Connection, len(connPaths))
|
if err != nil {
|
||||||
|
return nil, err
|
||||||
|
}
|
||||||
|
|
||||||
var err error
|
conns := make([]Connection, len(connPaths))
|
||||||
for i, path := range connPaths {
|
for i, path := range connPaths {
|
||||||
conns[i], err = NewConnection(path)
|
conns[i], err = NewConnection(path)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
panic(err)
|
return conns, err
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
return conns
|
return conns, nil
|
||||||
}
|
}
|
||||||
|
|
||||||
func (d *device) GetPhysicalPortId() string {
|
func (d *device) GetPropertyPhysicalPortId() (string, error) {
|
||||||
return d.getStringProperty(DevicePropertyPhysicalPortId)
|
return d.getStringProperty(DevicePropertyPhysicalPortId)
|
||||||
}
|
}
|
||||||
|
|
||||||
func (d *device) GetMtu() uint32 {
|
func (d *device) GetPropertyMtu() (uint32, error) {
|
||||||
return d.getUint32Property(DevicePropertyMtu)
|
return d.getUint32Property(DevicePropertyMtu)
|
||||||
}
|
}
|
||||||
|
|
||||||
func (d *device) GetReal() bool {
|
func (d *device) GetPropertyReal() (bool, error) {
|
||||||
return d.getBoolProperty(DevicePropertyReal)
|
return d.getBoolProperty(DevicePropertyReal)
|
||||||
}
|
}
|
||||||
|
|
||||||
func (d *device) marshalMap() map[string]interface{} {
|
func (d *device) marshalMap() map[string]interface{} {
|
||||||
return map[string]interface{}{
|
m := make(map[string]interface{})
|
||||||
"Interface": d.GetInterface(),
|
|
||||||
"IP interface": d.GetIpInterface(),
|
m["Interface"], _ = d.GetPropertyInterface()
|
||||||
"State": d.GetState().String(),
|
m["IPInterface"], _ = d.GetPropertyIpInterface()
|
||||||
"IP4Config": d.GetIP4Config(),
|
m["IP4Config"], _ = d.GetPropertyIP4Config()
|
||||||
"DHCP4Config": d.GetDHCP4Config(),
|
m["DHCP4Config"], _ = d.GetPropertyDHCP4Config()
|
||||||
"DeviceType": d.GetDeviceType().String(),
|
m["AvailableConnections"], _ = d.GetPropertyAvailableConnections()
|
||||||
"AvailableConnections": d.GetAvailableConnections(),
|
|
||||||
}
|
state, _ := d.GetPropertyState()
|
||||||
|
m["State"] = state.String()
|
||||||
|
|
||||||
|
deviceType, _ := d.GetPropertyDeviceType()
|
||||||
|
m["DeviceType"] = deviceType.String()
|
||||||
|
|
||||||
|
return m
|
||||||
}
|
}
|
||||||
|
|
||||||
func (d *device) MarshalJSON() ([]byte, error) {
|
func (d *device) MarshalJSON() ([]byte, error) {
|
||||||
|
|
|
@ -9,6 +9,7 @@ import (
|
||||||
const (
|
const (
|
||||||
DeviceDummyInterface = DeviceInterface + ".Dummy"
|
DeviceDummyInterface = DeviceInterface + ".Dummy"
|
||||||
|
|
||||||
|
/* Properties */
|
||||||
DeviceDummyPropertyHwAddress = DeviceDummyInterface + ".HwAddress" // readable s
|
DeviceDummyPropertyHwAddress = DeviceDummyInterface + ".HwAddress" // readable s
|
||||||
)
|
)
|
||||||
|
|
||||||
|
@ -16,7 +17,7 @@ type DeviceDummy interface {
|
||||||
Device
|
Device
|
||||||
|
|
||||||
// Hardware address of the device.
|
// Hardware address of the device.
|
||||||
GetHwAddress() string
|
GetPropertyHwAddress() (string, error)
|
||||||
}
|
}
|
||||||
|
|
||||||
func NewDeviceDummy(objectPath dbus.ObjectPath) (DeviceDummy, error) {
|
func NewDeviceDummy(objectPath dbus.ObjectPath) (DeviceDummy, error) {
|
||||||
|
@ -28,12 +29,12 @@ type deviceDummy struct {
|
||||||
device
|
device
|
||||||
}
|
}
|
||||||
|
|
||||||
func (d *deviceDummy) GetHwAddress() string {
|
func (d *deviceDummy) GetPropertyHwAddress() (string, error) {
|
||||||
return d.getStringProperty(DeviceDummyPropertyHwAddress)
|
return d.getStringProperty(DeviceDummyPropertyHwAddress)
|
||||||
}
|
}
|
||||||
|
|
||||||
func (d *deviceDummy) MarshalJSON() ([]byte, error) {
|
func (d *deviceDummy) MarshalJSON() ([]byte, error) {
|
||||||
m := d.device.marshalMap()
|
m := d.device.marshalMap()
|
||||||
m["HwAddress"] = d.GetHwAddress()
|
m["HwAddress"], _ = d.GetPropertyHwAddress()
|
||||||
return json.Marshal(m)
|
return json.Marshal(m)
|
||||||
}
|
}
|
||||||
|
|
|
@ -9,6 +9,7 @@ import (
|
||||||
const (
|
const (
|
||||||
DeviceGenericInterface = DeviceInterface + ".Generic"
|
DeviceGenericInterface = DeviceInterface + ".Generic"
|
||||||
|
|
||||||
|
// Properties
|
||||||
DeviceGenericPropertyHwAddress = DeviceGenericInterface + ".HwAddress" // readable s
|
DeviceGenericPropertyHwAddress = DeviceGenericInterface + ".HwAddress" // readable s
|
||||||
DeviceGenericPropertyTypeDescription = DeviceGenericInterface + ".TypeDescription" // readable s
|
DeviceGenericPropertyTypeDescription = DeviceGenericInterface + ".TypeDescription" // readable s
|
||||||
)
|
)
|
||||||
|
@ -17,10 +18,10 @@ type DeviceGeneric interface {
|
||||||
Device
|
Device
|
||||||
|
|
||||||
// Active hardware address of the device.
|
// Active hardware address of the device.
|
||||||
GetHwAddress() string
|
GetPropertyHwAddress() (string, error)
|
||||||
|
|
||||||
// A (non-localized) description of the interface type, if known.
|
// A (non-localized) description of the interface type, if known.
|
||||||
GetTypeDescription() string
|
GetPropertyTypeDescription() (string, error)
|
||||||
}
|
}
|
||||||
|
|
||||||
func NewDeviceGeneric(objectPath dbus.ObjectPath) (DeviceGeneric, error) {
|
func NewDeviceGeneric(objectPath dbus.ObjectPath) (DeviceGeneric, error) {
|
||||||
|
@ -32,17 +33,17 @@ type deviceGeneric struct {
|
||||||
device
|
device
|
||||||
}
|
}
|
||||||
|
|
||||||
func (d *deviceGeneric) GetHwAddress() string {
|
func (d *deviceGeneric) GetPropertyHwAddress() (string, error) {
|
||||||
return d.getStringProperty(DeviceGenericPropertyHwAddress)
|
return d.getStringProperty(DeviceGenericPropertyHwAddress)
|
||||||
}
|
}
|
||||||
|
|
||||||
func (d *deviceGeneric) GetTypeDescription() string {
|
func (d *deviceGeneric) GetPropertyTypeDescription() (string, error) {
|
||||||
return d.getStringProperty(DeviceGenericPropertyTypeDescription)
|
return d.getStringProperty(DeviceGenericPropertyTypeDescription)
|
||||||
}
|
}
|
||||||
|
|
||||||
func (d *deviceGeneric) MarshalJSON() ([]byte, error) {
|
func (d *deviceGeneric) MarshalJSON() ([]byte, error) {
|
||||||
m := d.device.marshalMap()
|
m := d.device.marshalMap()
|
||||||
m["HwAddress"] = d.GetHwAddress()
|
m["HwAddress"], _ = d.GetPropertyHwAddress()
|
||||||
m["TypeDescription"] = d.GetTypeDescription()
|
m["TypeDescription"], _ = d.GetPropertyTypeDescription()
|
||||||
return json.Marshal(m)
|
return json.Marshal(m)
|
||||||
}
|
}
|
||||||
|
|
|
@ -2,14 +2,15 @@ package gonetworkmanager
|
||||||
|
|
||||||
import (
|
import (
|
||||||
"encoding/json"
|
"encoding/json"
|
||||||
|
|
||||||
"github.com/godbus/dbus"
|
"github.com/godbus/dbus"
|
||||||
)
|
)
|
||||||
|
|
||||||
const (
|
const (
|
||||||
DeviceIpTunnelInterface = DeviceInterface + ".IPTunnel"
|
DeviceIpTunnelInterface = DeviceInterface + ".IPTunnel"
|
||||||
|
|
||||||
|
// Properties
|
||||||
DeviceIpTunnelPropertyHwAddress = DeviceIpTunnelInterface + "HwAddress" // readable s
|
DeviceIpTunnelPropertyHwAddress = DeviceIpTunnelInterface + "HwAddress" // readable s
|
||||||
|
|
||||||
DeviceIpTunnelPropertyMode = DeviceIpTunnelInterface + ".Mode" // readable u
|
DeviceIpTunnelPropertyMode = DeviceIpTunnelInterface + ".Mode" // readable u
|
||||||
DeviceIpTunnelPropertyParent = DeviceIpTunnelInterface + ".Parent" // readable o
|
DeviceIpTunnelPropertyParent = DeviceIpTunnelInterface + ".Parent" // readable o
|
||||||
DeviceIpTunnelPropertyLocal = DeviceIpTunnelInterface + ".Local" // readable s
|
DeviceIpTunnelPropertyLocal = DeviceIpTunnelInterface + ".Local" // readable s
|
||||||
|
@ -29,40 +30,40 @@ type DeviceIpTunnel interface {
|
||||||
Device
|
Device
|
||||||
|
|
||||||
// The tunneling mode
|
// The tunneling mode
|
||||||
GetMode() uint32
|
GetPropertyMode() (uint32, error)
|
||||||
|
|
||||||
// The object path of the parent device.
|
// The object path of the parent device.
|
||||||
GetParent() Device
|
GetPropertyParent() (Device, error)
|
||||||
|
|
||||||
// The local endpoint of the tunnel.
|
// The local endpoint of the tunnel.
|
||||||
GetLocal() string
|
GetPropertyLocal() (string, error)
|
||||||
|
|
||||||
// The remote endpoint of the tunnel.
|
// The remote endpoint of the tunnel.
|
||||||
GetRemote() string
|
GetPropertyRemote() (string, error)
|
||||||
|
|
||||||
// The TTL assigned to tunneled packets. 0 is a special value meaning that packets inherit the TTL value
|
// The TTL assigned to tunneled packets. 0 is a special value meaning that packets inherit the TTL value
|
||||||
GetTtl() uint8
|
GetPropertyTtl() (uint8, error)
|
||||||
|
|
||||||
// The type of service (IPv4) or traffic class (IPv6) assigned to tunneled packets.
|
// The type of service (IPv4) or traffic class (IPv6) assigned to tunneled packets.
|
||||||
GetTos() uint8
|
GetPropertyTos() (uint8, error)
|
||||||
|
|
||||||
// Whether path MTU discovery is enabled on this tunnel.
|
// Whether path MTU discovery is enabled on this tunnel.
|
||||||
GetPathMtuDiscovery() bool
|
GetPropertyPathMtuDiscovery() (bool, error)
|
||||||
|
|
||||||
// The key used for incoming packets.
|
// The key used for incoming packets.
|
||||||
GetInputKey() string
|
GetPropertyInputKey() (string, error)
|
||||||
|
|
||||||
// The key used for outgoing packets.
|
// The key used for outgoing packets.
|
||||||
GetOutputKey() string
|
GetPropertyOutputKey() (string, error)
|
||||||
|
|
||||||
// How many additional levels of encapsulation are permitted to be prepended to packets. This property applies only to IPv6 tunnels.
|
// How many additional levels of encapsulation are permitted to be prepended to packets. This property applies only to IPv6 tunnels.
|
||||||
GetEncapsulationLimit() uint8
|
GetPropertyEncapsulationLimit() (uint8, error)
|
||||||
|
|
||||||
// The flow label to assign to tunnel packets. This property applies only to IPv6 tunnels.
|
// The flow label to assign to tunnel packets. This property applies only to IPv6 tunnels.
|
||||||
GetFlowLabel() uint32
|
GetPropertyFlowLabel() (uint32, error)
|
||||||
|
|
||||||
// Tunnel flags.
|
// Tunnel flags.
|
||||||
GetFlags() uint32
|
GetPropertyFlags() (uint32, error)
|
||||||
}
|
}
|
||||||
|
|
||||||
func NewDeviceIpTunnel(objectPath dbus.ObjectPath) (DeviceIpTunnel, error) {
|
func NewDeviceIpTunnel(objectPath dbus.ObjectPath) (DeviceIpTunnel, error) {
|
||||||
|
@ -74,76 +75,72 @@ type deviceIpTunnel struct {
|
||||||
device
|
device
|
||||||
}
|
}
|
||||||
|
|
||||||
func (d *deviceIpTunnel) GetMode() uint32 {
|
func (d *deviceIpTunnel) GetPropertyMode() (uint32, error) {
|
||||||
return d.getUint32Property(DeviceIpTunnelPropertyMode)
|
return d.getUint32Property(DeviceIpTunnelPropertyMode)
|
||||||
}
|
}
|
||||||
|
|
||||||
func (d *deviceIpTunnel) GetParent() Device {
|
func (d *deviceIpTunnel) GetPropertyParent() (Device, error) {
|
||||||
path := d.getObjectProperty(DeviceIpTunnelPropertyParent)
|
path, err := d.getObjectProperty(DeviceIpTunnelPropertyParent)
|
||||||
if path == "/" {
|
if err != nil || path == "/" {
|
||||||
return nil
|
return nil, err
|
||||||
}
|
}
|
||||||
|
|
||||||
r, err := DeviceFactory(path)
|
return DeviceFactory(path)
|
||||||
if err != nil {
|
|
||||||
panic(err)
|
|
||||||
}
|
|
||||||
return r
|
|
||||||
}
|
}
|
||||||
|
|
||||||
func (d *deviceIpTunnel) GetLocal() string {
|
func (d *deviceIpTunnel) GetPropertyLocal() (string, error) {
|
||||||
return d.getStringProperty(DeviceIpTunnelPropertyLocal)
|
return d.getStringProperty(DeviceIpTunnelPropertyLocal)
|
||||||
}
|
}
|
||||||
|
|
||||||
func (d *deviceIpTunnel) GetRemote() string {
|
func (d *deviceIpTunnel) GetPropertyRemote() (string, error) {
|
||||||
return d.getStringProperty(DeviceIpTunnelPropertyRemote)
|
return d.getStringProperty(DeviceIpTunnelPropertyRemote)
|
||||||
}
|
}
|
||||||
|
|
||||||
func (d *deviceIpTunnel) GetTtl() uint8 {
|
func (d *deviceIpTunnel) GetPropertyTtl() (uint8, error) {
|
||||||
return d.getUint8Property(DeviceIpTunnelPropertyTtl)
|
return d.getUint8Property(DeviceIpTunnelPropertyTtl)
|
||||||
}
|
}
|
||||||
|
|
||||||
func (d *deviceIpTunnel) GetTos() uint8 {
|
func (d *deviceIpTunnel) GetPropertyTos() (uint8, error) {
|
||||||
return d.getUint8Property(DeviceIpTunnelPropertyTos)
|
return d.getUint8Property(DeviceIpTunnelPropertyTos)
|
||||||
}
|
}
|
||||||
|
|
||||||
func (d *deviceIpTunnel) GetPathMtuDiscovery() bool {
|
func (d *deviceIpTunnel) GetPropertyPathMtuDiscovery() (bool, error) {
|
||||||
return d.getBoolProperty(DeviceIpTunnelPropertyPathMtuDiscovery)
|
return d.getBoolProperty(DeviceIpTunnelPropertyPathMtuDiscovery)
|
||||||
}
|
}
|
||||||
|
|
||||||
func (d *deviceIpTunnel) GetInputKey() string {
|
func (d *deviceIpTunnel) GetPropertyInputKey() (string, error) {
|
||||||
return d.getStringProperty(DeviceIpTunnelPropertyInputKey)
|
return d.getStringProperty(DeviceIpTunnelPropertyInputKey)
|
||||||
}
|
}
|
||||||
|
|
||||||
func (d *deviceIpTunnel) GetOutputKey() string {
|
func (d *deviceIpTunnel) GetPropertyOutputKey() (string, error) {
|
||||||
return d.getStringProperty(DeviceIpTunnelPropertyOutputKey)
|
return d.getStringProperty(DeviceIpTunnelPropertyOutputKey)
|
||||||
}
|
}
|
||||||
|
|
||||||
func (d *deviceIpTunnel) GetEncapsulationLimit() uint8 {
|
func (d *deviceIpTunnel) GetPropertyEncapsulationLimit() (uint8, error) {
|
||||||
return d.getUint8Property(DeviceIpTunnelPropertyEncapsulationLimit)
|
return d.getUint8Property(DeviceIpTunnelPropertyEncapsulationLimit)
|
||||||
}
|
}
|
||||||
|
|
||||||
func (d *deviceIpTunnel) GetFlowLabel() uint32 {
|
func (d *deviceIpTunnel) GetPropertyFlowLabel() (uint32, error) {
|
||||||
return d.getUint32Property(DeviceIpTunnelPropertyFlowLabel)
|
return d.getUint32Property(DeviceIpTunnelPropertyFlowLabel)
|
||||||
}
|
}
|
||||||
|
|
||||||
func (d *deviceIpTunnel) GetFlags() uint32 {
|
func (d *deviceIpTunnel) GetPropertyFlags() (uint32, error) {
|
||||||
return d.getUint32Property(DeviceIpTunnelPropertyFlags)
|
return d.getUint32Property(DeviceIpTunnelPropertyFlags)
|
||||||
}
|
}
|
||||||
|
|
||||||
func (d *deviceIpTunnel) MarshalJSON() ([]uint8, error) {
|
func (d *deviceIpTunnel) MarshalJSON() ([]uint8, error) {
|
||||||
m := d.device.marshalMap()
|
m := d.device.marshalMap()
|
||||||
m["Mode"] = d.GetMode()
|
m["Mode"], _ = d.GetPropertyMode()
|
||||||
m["Parent"] = d.GetParent()
|
m["Parent"], _ = d.GetPropertyParent()
|
||||||
m["Local"] = d.GetLocal()
|
m["Local"], _ = d.GetPropertyLocal()
|
||||||
m["Remote"] = d.GetRemote()
|
m["Remote"], _ = d.GetPropertyRemote()
|
||||||
m["Ttl"] = d.GetTtl()
|
m["Ttl"], _ = d.GetPropertyTtl()
|
||||||
m["Tos"] = d.GetTos()
|
m["Tos"], _ = d.GetPropertyTos()
|
||||||
m["PathMtuDiscovery"] = d.GetPathMtuDiscovery()
|
m["PathMtuDiscovery"], _ = d.GetPropertyPathMtuDiscovery()
|
||||||
m["InputKey"] = d.GetInputKey()
|
m["InputKey"], _ = d.GetPropertyInputKey()
|
||||||
m["OutputKey"] = d.GetOutputKey()
|
m["OutputKey"], _ = d.GetPropertyOutputKey()
|
||||||
m["EncapsulationLimit"] = d.GetEncapsulationLimit()
|
m["EncapsulationLimit"], _ = d.GetPropertyEncapsulationLimit()
|
||||||
m["FlowLabel"] = d.GetFlowLabel()
|
m["FlowLabel"], _ = d.GetPropertyFlowLabel()
|
||||||
m["Flags"] = d.GetFlags()
|
m["Flags"], _ = d.GetPropertyFlags()
|
||||||
return json.Marshal(m)
|
return json.Marshal(m)
|
||||||
}
|
}
|
||||||
|
|
|
@ -9,6 +9,7 @@ import (
|
||||||
const (
|
const (
|
||||||
DeviceStatisticsInterface = DeviceInterface + ".Statistics"
|
DeviceStatisticsInterface = DeviceInterface + ".Statistics"
|
||||||
|
|
||||||
|
// Properties
|
||||||
DeviceStatisticsPropertyRefreshRateMs = DeviceStatisticsInterface + ".RefreshRateMs" // readwrite u
|
DeviceStatisticsPropertyRefreshRateMs = DeviceStatisticsInterface + ".RefreshRateMs" // readwrite u
|
||||||
DeviceStatisticsPropertyTxBytes = DeviceStatisticsInterface + ".TxBytes" // readable t
|
DeviceStatisticsPropertyTxBytes = DeviceStatisticsInterface + ".TxBytes" // readable t
|
||||||
DeviceStatisticsPropertyRxBytes = DeviceStatisticsInterface + ".RxBytes" // readable t
|
DeviceStatisticsPropertyRxBytes = DeviceStatisticsInterface + ".RxBytes" // readable t
|
||||||
|
@ -18,13 +19,13 @@ type DeviceStatistics interface {
|
||||||
GetPath() dbus.ObjectPath
|
GetPath() dbus.ObjectPath
|
||||||
|
|
||||||
// Refresh rate of the rest of properties of this interface. The properties are guaranteed to be refreshed each RefreshRateMs milliseconds in case the underlying counter has changed too. If zero, there is no guaranteed refresh rate of the properties.
|
// Refresh rate of the rest of properties of this interface. The properties are guaranteed to be refreshed each RefreshRateMs milliseconds in case the underlying counter has changed too. If zero, there is no guaranteed refresh rate of the properties.
|
||||||
GetPropertyRefreshRateMs() uint32
|
GetPropertyRefreshRateMs() (uint32, error)
|
||||||
|
|
||||||
// Number of transmitted bytes
|
// Number of transmitted bytes
|
||||||
GetPropertyTxBytes() uint64
|
GetPropertyTxBytes() (uint64, error)
|
||||||
|
|
||||||
// Number of received bytes
|
// Number of received bytes
|
||||||
GetPropertyRxBytes() uint64
|
GetPropertyRxBytes() (uint64, error)
|
||||||
}
|
}
|
||||||
|
|
||||||
func NewDeviceStatistics(objectPath dbus.ObjectPath) (DeviceStatistics, error) {
|
func NewDeviceStatistics(objectPath dbus.ObjectPath) (DeviceStatistics, error) {
|
||||||
|
@ -40,26 +41,28 @@ func (d *deviceStatistics) GetPath() dbus.ObjectPath {
|
||||||
return d.obj.Path()
|
return d.obj.Path()
|
||||||
}
|
}
|
||||||
|
|
||||||
func (d *deviceStatistics) GetPropertyRefreshRateMs() uint32 {
|
func (d *deviceStatistics) GetPropertyRefreshRateMs() (uint32, error) {
|
||||||
return d.getUint32Property(DeviceStatisticsPropertyRefreshRateMs)
|
return d.getUint32Property(DeviceStatisticsPropertyRefreshRateMs)
|
||||||
}
|
}
|
||||||
|
|
||||||
func (d *deviceStatistics) GetPropertyTxBytes() uint64 {
|
func (d *deviceStatistics) GetPropertyTxBytes() (uint64, error) {
|
||||||
return d.getUint64Property(DeviceStatisticsPropertyTxBytes)
|
return d.getUint64Property(DeviceStatisticsPropertyTxBytes)
|
||||||
}
|
}
|
||||||
|
|
||||||
func (d *deviceStatistics) GetPropertyRxBytes() uint64 {
|
func (d *deviceStatistics) GetPropertyRxBytes() (uint64, error) {
|
||||||
return d.getUint64Property(DeviceStatisticsPropertyRxBytes)
|
return d.getUint64Property(DeviceStatisticsPropertyRxBytes)
|
||||||
}
|
}
|
||||||
|
|
||||||
func (d *deviceStatistics) marshalMap() map[string]interface{} {
|
func (d *deviceStatistics) marshalMap() map[string]interface{} {
|
||||||
return map[string]interface{}{
|
return map[string]interface{}{}
|
||||||
"RefreshRateMs": d.GetPropertyRefreshRateMs(),
|
|
||||||
"TxBytes": d.GetPropertyTxBytes(),
|
|
||||||
"RxBytes": d.GetPropertyRxBytes(),
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
func (d *deviceStatistics) MarshalJSON() ([]byte, error) {
|
func (d *deviceStatistics) MarshalJSON() ([]byte, error) {
|
||||||
return json.Marshal(d.marshalMap())
|
m := make(map[string]interface{})
|
||||||
|
|
||||||
|
m["RefreshRateMs"], _ = d.GetPropertyRefreshRateMs()
|
||||||
|
m["TxBytes"], _ = d.GetPropertyTxBytes()
|
||||||
|
m["RxBytes"], _ = d.GetPropertyRxBytes()
|
||||||
|
|
||||||
|
return json.Marshal(m)
|
||||||
}
|
}
|
||||||
|
|
|
@ -9,6 +9,7 @@ import (
|
||||||
const (
|
const (
|
||||||
DeviceWiredInterface = DeviceInterface + ".Wired"
|
DeviceWiredInterface = DeviceInterface + ".Wired"
|
||||||
|
|
||||||
|
// Properties
|
||||||
DeviceWiredPropertyHwAddress = DeviceWiredInterface + ".HwAddress" // readable s
|
DeviceWiredPropertyHwAddress = DeviceWiredInterface + ".HwAddress" // readable s
|
||||||
DeviceWiredPropertyPermHwAddress = DeviceWiredInterface + ".PermHwAddress" // readable s
|
DeviceWiredPropertyPermHwAddress = DeviceWiredInterface + ".PermHwAddress" // readable s
|
||||||
DeviceWiredPropertySpeed = DeviceWiredInterface + ".Speed" // readable u
|
DeviceWiredPropertySpeed = DeviceWiredInterface + ".Speed" // readable u
|
||||||
|
@ -20,19 +21,19 @@ type DeviceWired interface {
|
||||||
Device
|
Device
|
||||||
|
|
||||||
// Active hardware address of the device.
|
// Active hardware address of the device.
|
||||||
GetHwAddress() string
|
GetPropertyHwAddress() (string, error)
|
||||||
|
|
||||||
// Permanent hardware address of the device.
|
// Permanent hardware address of the device.
|
||||||
GetPermHwAddress() string
|
GetPropertyPermHwAddress() (string, error)
|
||||||
|
|
||||||
// Design speed of the device, in megabits/second (Mb/s).
|
// Design speed of the device, in megabits/second (Mb/s).
|
||||||
GetSpeed() uint32
|
GetPropertySpeed() (uint32, error)
|
||||||
|
|
||||||
// Array of S/390 subchannels for S/390 or z/Architecture devices.
|
// Array of S/390 subchannels for S/390 or z/Architecture devices.
|
||||||
GetS390Subchannels() []string
|
GetPropertyS390Subchannels() ([]string, error)
|
||||||
|
|
||||||
// Indicates whether the physical carrier is found (e.g. whether a cable is plugged in or not).
|
// Indicates whether the physical carrier is found (e.g. whether a cable is plugged in or not).
|
||||||
GetCarrier() bool
|
GetPropertyCarrier() (bool, error)
|
||||||
}
|
}
|
||||||
|
|
||||||
func NewDeviceWired(objectPath dbus.ObjectPath) (DeviceWired, error) {
|
func NewDeviceWired(objectPath dbus.ObjectPath) (DeviceWired, error) {
|
||||||
|
@ -44,32 +45,32 @@ type deviceWired struct {
|
||||||
device
|
device
|
||||||
}
|
}
|
||||||
|
|
||||||
func (d *deviceWired) GetHwAddress() string {
|
func (d *deviceWired) GetPropertyHwAddress() (string, error) {
|
||||||
return d.getStringProperty(DeviceWiredPropertyHwAddress)
|
return d.getStringProperty(DeviceWiredPropertyHwAddress)
|
||||||
}
|
}
|
||||||
|
|
||||||
func (d *deviceWired) GetPermHwAddress() string {
|
func (d *deviceWired) GetPropertyPermHwAddress() (string, error) {
|
||||||
return d.getStringProperty(DeviceWiredPropertyPermHwAddress)
|
return d.getStringProperty(DeviceWiredPropertyPermHwAddress)
|
||||||
}
|
}
|
||||||
|
|
||||||
func (d *deviceWired) GetSpeed() uint32 {
|
func (d *deviceWired) GetPropertySpeed() (uint32, error) {
|
||||||
return d.getUint32Property(DeviceWiredPropertySpeed)
|
return d.getUint32Property(DeviceWiredPropertySpeed)
|
||||||
}
|
}
|
||||||
|
|
||||||
func (d *deviceWired) GetS390Subchannels() []string {
|
func (d *deviceWired) GetPropertyS390Subchannels() ([]string, error) {
|
||||||
return d.getSliceStringProperty(DeviceWiredPropertyS390Subchannels)
|
return d.getSliceStringProperty(DeviceWiredPropertyS390Subchannels)
|
||||||
}
|
}
|
||||||
|
|
||||||
func (d *deviceWired) GetCarrier() bool {
|
func (d *deviceWired) GetPropertyCarrier() (bool, error) {
|
||||||
return d.getBoolProperty(DeviceWiredPropertyCarrier)
|
return d.getBoolProperty(DeviceWiredPropertyCarrier)
|
||||||
}
|
}
|
||||||
|
|
||||||
func (d *deviceWired) MarshalJSON() ([]byte, error) {
|
func (d *deviceWired) MarshalJSON() ([]byte, error) {
|
||||||
m := d.device.marshalMap()
|
m := d.device.marshalMap()
|
||||||
m["HwAddress"] = d.GetHwAddress()
|
m["HwAddress"], _ = d.GetPropertyHwAddress()
|
||||||
m["PermHwAddress"] = d.GetPermHwAddress()
|
m["PermHwAddress"], _ = d.GetPropertyPermHwAddress()
|
||||||
m["Speed"] = d.GetSpeed()
|
m["Speed"], _ = d.GetPropertySpeed()
|
||||||
m["S390Subchannels"] = d.GetS390Subchannels()
|
m["S390Subchannels"], _ = d.GetPropertyS390Subchannels()
|
||||||
m["Carrier"] = d.GetCarrier()
|
m["Carrier"], _ = d.GetPropertyCarrier()
|
||||||
return json.Marshal(m)
|
return json.Marshal(m)
|
||||||
}
|
}
|
||||||
|
|
|
@ -9,6 +9,7 @@ import (
|
||||||
const (
|
const (
|
||||||
DeviceWirelessInterface = DeviceInterface + ".Wireless"
|
DeviceWirelessInterface = DeviceInterface + ".Wireless"
|
||||||
|
|
||||||
|
// Methods
|
||||||
DeviceWirelessGetAccessPoints = DeviceWirelessInterface + ".GetAccessPoints"
|
DeviceWirelessGetAccessPoints = DeviceWirelessInterface + ".GetAccessPoints"
|
||||||
DeviceWirelessRequestScan = DeviceWirelessInterface + ".RequestScan"
|
DeviceWirelessRequestScan = DeviceWirelessInterface + ".RequestScan"
|
||||||
)
|
)
|
||||||
|
|
160
IP4Config.go
160
IP4Config.go
|
@ -2,6 +2,8 @@ package gonetworkmanager
|
||||||
|
|
||||||
import (
|
import (
|
||||||
"encoding/json"
|
"encoding/json"
|
||||||
|
"errors"
|
||||||
|
|
||||||
"github.com/godbus/dbus"
|
"github.com/godbus/dbus"
|
||||||
)
|
)
|
||||||
|
|
||||||
|
@ -59,42 +61,42 @@ type IP4NameserverData struct {
|
||||||
type IP4Config interface {
|
type IP4Config interface {
|
||||||
// Array of arrays of IPv4 address/prefix/gateway. All 3 elements of each array are in network byte order. Essentially: [(addr, prefix, gateway), (addr, prefix, gateway), ...]
|
// Array of arrays of IPv4 address/prefix/gateway. All 3 elements of each array are in network byte order. Essentially: [(addr, prefix, gateway), (addr, prefix, gateway), ...]
|
||||||
// Deprecated: use AddressData and Gateway
|
// Deprecated: use AddressData and Gateway
|
||||||
GetAddresses() []IP4Address
|
GetPropertyAddresses() ([]IP4Address, error)
|
||||||
|
|
||||||
// Array of IP address data objects. All addresses will include "address" (an IP address string), and "prefix" (a uint). Some addresses may include additional attributes.
|
// Array of IP address data objects. All addresses will include "address" (an IP address string), and "prefix" (a uint). Some addresses may include additional attributes.
|
||||||
GetAddressData() []IP4AddressData
|
GetPropertyAddressData() ([]IP4AddressData, error)
|
||||||
|
|
||||||
// The gateway in use.
|
// The gateway in use.
|
||||||
GetGateway() string
|
GetPropertyGateway() (string, error)
|
||||||
|
|
||||||
// Arrays of IPv4 route/prefix/next-hop/metric. All 4 elements of each tuple are in network byte order. 'route' and 'next hop' are IPv4 addresses, while prefix and metric are simple unsigned integers. Essentially: [(route, prefix, next-hop, metric), (route, prefix, next-hop, metric), ...]
|
// Arrays of IPv4 route/prefix/next-hop/metric. All 4 elements of each tuple are in network byte order. 'route' and 'next hop' are IPv4 addresses, while prefix and metric are simple unsigned integers. Essentially: [(route, prefix, next-hop, metric), (route, prefix, next-hop, metric), ...]
|
||||||
// Deprecated: use RouteData
|
// Deprecated: use RouteData
|
||||||
GetRoutes() []IP4Route
|
GetPropertyRoutes() ([]IP4Route, error)
|
||||||
|
|
||||||
// Array of IP route data objects. All routes will include "dest" (an IP address string) and "prefix" (a uint). Some routes may include "next-hop" (an IP address string), "metric" (a uint), and additional attributes.
|
// Array of IP route data objects. All routes will include "dest" (an IP address string) and "prefix" (a uint). Some routes may include "next-hop" (an IP address string), "metric" (a uint), and additional attributes.
|
||||||
GetRouteData() []IP4RouteData
|
GetPropertyRouteData() ([]IP4RouteData, error)
|
||||||
|
|
||||||
// The nameservers in use.
|
// The nameservers in use.
|
||||||
// Deprecated: use NameserverData
|
// Deprecated: use NameserverData
|
||||||
GetNameservers() []string
|
GetPropertyNameservers() ([]string, error)
|
||||||
|
|
||||||
// The nameservers in use. Currently only the value "address" is recognized (with an IP address string).
|
// The nameservers in use. Currently only the value "address" is recognized (with an IP address string).
|
||||||
GetNameserverData() []IP4NameserverData
|
GetPropertyNameserverData() ([]IP4NameserverData, error)
|
||||||
|
|
||||||
// A list of domains this address belongs to.
|
// A list of domains this address belongs to.
|
||||||
GetDomains() []string
|
GetPropertyDomains() ([]string, error)
|
||||||
|
|
||||||
// A list of dns searches.
|
// A list of dns searches.
|
||||||
GetSearches() []string
|
GetPropertySearches() ([]string, error)
|
||||||
|
|
||||||
// A list of DNS options that modify the behavior of the DNS resolver. See resolv.conf(5) manual page for the list of supported options.
|
// A list of DNS options that modify the behavior of the DNS resolver. See resolv.conf(5) manual page for the list of supported options.
|
||||||
GetDnsOptions() []string
|
GetPropertyDnsOptions() ([]string, error)
|
||||||
|
|
||||||
// The relative priority of DNS servers.
|
// The relative priority of DNS servers.
|
||||||
GetDnsPriority() uint32
|
GetPropertyDnsPriority() (uint32, error)
|
||||||
|
|
||||||
// The Windows Internet Name Service servers associated with the connection.
|
// The Windows Internet Name Service servers associated with the connection.
|
||||||
GetWinsServerData() []string
|
GetPropertyWinsServerData() ([]string, error)
|
||||||
|
|
||||||
MarshalJSON() ([]byte, error)
|
MarshalJSON() ([]byte, error)
|
||||||
}
|
}
|
||||||
|
@ -108,11 +110,15 @@ type ip4Config struct {
|
||||||
dbusBase
|
dbusBase
|
||||||
}
|
}
|
||||||
|
|
||||||
// Deprecated: use GetAddressData
|
// Deprecated: use GetPropertyAddressData
|
||||||
func (c *ip4Config) GetAddresses() []IP4Address {
|
func (c *ip4Config) GetPropertyAddresses() ([]IP4Address, error) {
|
||||||
addresses := c.getSliceSliceUint32Property(IP4ConfigPropertyAddresses)
|
addresses, err := c.getSliceSliceUint32Property(IP4ConfigPropertyAddresses)
|
||||||
ret := make([]IP4Address, len(addresses))
|
ret := make([]IP4Address, len(addresses))
|
||||||
|
|
||||||
|
if err != nil {
|
||||||
|
return ret, err
|
||||||
|
}
|
||||||
|
|
||||||
for i, parts := range addresses {
|
for i, parts := range addresses {
|
||||||
ret[i] = IP4Address{
|
ret[i] = IP4Address{
|
||||||
Address: ip4ToString(parts[0]),
|
Address: ip4ToString(parts[0]),
|
||||||
|
@ -121,33 +127,50 @@ func (c *ip4Config) GetAddresses() []IP4Address {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
return ret
|
return ret, nil
|
||||||
}
|
}
|
||||||
|
|
||||||
func (c *ip4Config) GetAddressData() []IP4AddressData {
|
func (c *ip4Config) GetPropertyAddressData() ([]IP4AddressData, error) {
|
||||||
addresses := c.getSliceMapStringVariantProperty(IP4ConfigPropertyAddressData)
|
addresses, err := c.getSliceMapStringVariantProperty(IP4ConfigPropertyAddressData)
|
||||||
ret := make([]IP4AddressData, len(addresses))
|
ret := make([]IP4AddressData, len(addresses))
|
||||||
|
|
||||||
|
if err != nil {
|
||||||
|
return ret, err
|
||||||
|
}
|
||||||
|
|
||||||
for i, address := range addresses {
|
for i, address := range addresses {
|
||||||
prefix := address["prefix"].Value().(uint32)
|
prefix, ok := address["prefix"].Value().(uint32)
|
||||||
|
if !ok {
|
||||||
|
return ret, errors.New("unexpected variant type for address prefix")
|
||||||
|
}
|
||||||
|
|
||||||
|
address, ok := address["address"].Value().(string)
|
||||||
|
if !ok {
|
||||||
|
return ret, errors.New("unexpected variant type for address")
|
||||||
|
}
|
||||||
|
|
||||||
ret[i] = IP4AddressData{
|
ret[i] = IP4AddressData{
|
||||||
Address: address["address"].Value().(string),
|
Address: address,
|
||||||
Prefix: uint8(prefix),
|
Prefix: uint8(prefix),
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
return ret
|
|
||||||
|
return ret, nil
|
||||||
}
|
}
|
||||||
|
|
||||||
func (c *ip4Config) GetGateway() string {
|
func (c *ip4Config) GetPropertyGateway() (string, error) {
|
||||||
return c.getStringProperty(IP4ConfigPropertyGateway)
|
return c.getStringProperty(IP4ConfigPropertyGateway)
|
||||||
}
|
}
|
||||||
|
|
||||||
// Deprecated: use GetRouteData
|
// Deprecated: use GetPropertyRouteData
|
||||||
func (c *ip4Config) GetRoutes() []IP4Route {
|
func (c *ip4Config) GetPropertyRoutes() ([]IP4Route, error) {
|
||||||
routes := c.getSliceSliceUint32Property(IP4ConfigPropertyRoutes)
|
routes, err := c.getSliceSliceUint32Property(IP4ConfigPropertyRoutes)
|
||||||
ret := make([]IP4Route, len(routes))
|
ret := make([]IP4Route, len(routes))
|
||||||
|
|
||||||
|
if err != nil {
|
||||||
|
return ret, err
|
||||||
|
}
|
||||||
|
|
||||||
for i, parts := range routes {
|
for i, parts := range routes {
|
||||||
ret[i] = IP4Route{
|
ret[i] = IP4Route{
|
||||||
Route: ip4ToString(parts[0]),
|
Route: ip4ToString(parts[0]),
|
||||||
|
@ -157,13 +180,17 @@ func (c *ip4Config) GetRoutes() []IP4Route {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
return ret
|
return ret, nil
|
||||||
}
|
}
|
||||||
|
|
||||||
func (c *ip4Config) GetRouteData() []IP4RouteData {
|
func (c *ip4Config) GetPropertyRouteData() ([]IP4RouteData, error) {
|
||||||
routesData := c.getSliceMapStringVariantProperty(IP4ConfigPropertyRouteData)
|
routesData, err := c.getSliceMapStringVariantProperty(IP4ConfigPropertyRouteData)
|
||||||
routes := make([]IP4RouteData, len(routesData))
|
routes := make([]IP4RouteData, len(routesData))
|
||||||
|
|
||||||
|
if err != nil {
|
||||||
|
return routes, err
|
||||||
|
}
|
||||||
|
|
||||||
for _, routeData := range routesData {
|
for _, routeData := range routesData {
|
||||||
|
|
||||||
route := IP4RouteData{}
|
route := IP4RouteData{}
|
||||||
|
@ -171,14 +198,28 @@ func (c *ip4Config) GetRouteData() []IP4RouteData {
|
||||||
for routeDataAttributeName, routeDataAttribute := range routeData {
|
for routeDataAttributeName, routeDataAttribute := range routeData {
|
||||||
switch routeDataAttributeName {
|
switch routeDataAttributeName {
|
||||||
case "dest":
|
case "dest":
|
||||||
route.Destination = routeDataAttribute.Value().(string)
|
destination, ok := routeDataAttribute.Value().(string)
|
||||||
|
if !ok {
|
||||||
|
return routes, errors.New("unexpected variant type for dest")
|
||||||
|
}
|
||||||
|
route.Destination = destination
|
||||||
case "prefix":
|
case "prefix":
|
||||||
prefix, _ := routeDataAttribute.Value().(uint32)
|
prefix, ok := routeDataAttribute.Value().(uint32)
|
||||||
|
if !ok {
|
||||||
|
return routes, errors.New("unexpected variant type for prefix")
|
||||||
|
}
|
||||||
route.Prefix = uint8(prefix)
|
route.Prefix = uint8(prefix)
|
||||||
case "next-hop":
|
case "next-hop":
|
||||||
route.NextHop = routeDataAttribute.Value().(string)
|
nextHop, ok := routeDataAttribute.Value().(string)
|
||||||
|
if !ok {
|
||||||
|
return routes, errors.New("unexpected variant type for next-hop")
|
||||||
|
}
|
||||||
|
route.NextHop = nextHop
|
||||||
case "metric":
|
case "metric":
|
||||||
metric := routeDataAttribute.Value().(uint32)
|
metric, ok := routeDataAttribute.Value().(uint32)
|
||||||
|
if !ok {
|
||||||
|
return routes, errors.New("unexpected variant type for metric")
|
||||||
|
}
|
||||||
route.Metric = uint8(metric)
|
route.Metric = uint8(metric)
|
||||||
default:
|
default:
|
||||||
route.AdditionalAttributes[routeDataAttributeName] = routeDataAttribute.String()
|
route.AdditionalAttributes[routeDataAttributeName] = routeDataAttribute.String()
|
||||||
|
@ -187,61 +228,76 @@ func (c *ip4Config) GetRouteData() []IP4RouteData {
|
||||||
|
|
||||||
routes = append(routes, route)
|
routes = append(routes, route)
|
||||||
}
|
}
|
||||||
return routes
|
return routes, nil
|
||||||
}
|
}
|
||||||
|
|
||||||
// Deprecated: use GetNameserverData
|
// Deprecated: use GetPropertyNameserverData
|
||||||
func (c *ip4Config) GetNameservers() []string {
|
func (c *ip4Config) GetPropertyNameservers() ([]string, error) {
|
||||||
nameservers := c.getSliceUint32Property(IP4ConfigPropertyNameservers)
|
nameservers, err := c.getSliceUint32Property(IP4ConfigPropertyNameservers)
|
||||||
ret := make([]string, len(nameservers))
|
ret := make([]string, len(nameservers))
|
||||||
|
|
||||||
|
if err != nil {
|
||||||
|
return ret, err
|
||||||
|
}
|
||||||
|
|
||||||
for i, ns := range nameservers {
|
for i, ns := range nameservers {
|
||||||
ret[i] = ip4ToString(ns)
|
ret[i] = ip4ToString(ns)
|
||||||
}
|
}
|
||||||
|
|
||||||
return ret
|
return ret, nil
|
||||||
}
|
}
|
||||||
|
|
||||||
func (c *ip4Config) GetNameserverData() []IP4NameserverData {
|
func (c *ip4Config) GetPropertyNameserverData() ([]IP4NameserverData, error) {
|
||||||
nameserversData := c.getSliceMapStringVariantProperty(IP4ConfigPropertyNameserverData)
|
nameserversData, err := c.getSliceMapStringVariantProperty(IP4ConfigPropertyNameserverData)
|
||||||
nameservers := make([]IP4NameserverData, len(nameserversData))
|
nameservers := make([]IP4NameserverData, len(nameserversData))
|
||||||
|
|
||||||
|
if err != nil {
|
||||||
|
return nameservers, err
|
||||||
|
}
|
||||||
|
|
||||||
for _, nameserverData := range nameserversData {
|
for _, nameserverData := range nameserversData {
|
||||||
|
address, ok := nameserverData["address"].Value().(string)
|
||||||
|
|
||||||
|
if !ok {
|
||||||
|
return nameservers, errors.New("unexpected variant type for address")
|
||||||
|
}
|
||||||
|
|
||||||
nameserver := IP4NameserverData{
|
nameserver := IP4NameserverData{
|
||||||
Address: nameserverData["address"].Value().(string),
|
Address: address,
|
||||||
}
|
}
|
||||||
|
|
||||||
nameservers = append(nameservers, nameserver)
|
nameservers = append(nameservers, nameserver)
|
||||||
}
|
}
|
||||||
return nameservers
|
return nameservers, nil
|
||||||
}
|
}
|
||||||
|
|
||||||
func (c *ip4Config) GetDomains() []string {
|
func (c *ip4Config) GetPropertyDomains() ([]string, error) {
|
||||||
return c.getSliceStringProperty(IP4ConfigPropertyDomains)
|
return c.getSliceStringProperty(IP4ConfigPropertyDomains)
|
||||||
}
|
}
|
||||||
|
|
||||||
func (c *ip4Config) GetSearches() []string {
|
func (c *ip4Config) GetPropertySearches() ([]string, error) {
|
||||||
return c.getSliceStringProperty(IP4ConfigPropertySearches)
|
return c.getSliceStringProperty(IP4ConfigPropertySearches)
|
||||||
}
|
}
|
||||||
|
|
||||||
func (c *ip4Config) GetDnsOptions() []string {
|
func (c *ip4Config) GetPropertyDnsOptions() ([]string, error) {
|
||||||
return c.getSliceStringProperty(IP4ConfigPropertyDnsOptions)
|
return c.getSliceStringProperty(IP4ConfigPropertyDnsOptions)
|
||||||
}
|
}
|
||||||
|
|
||||||
func (c *ip4Config) GetDnsPriority() uint32 {
|
func (c *ip4Config) GetPropertyDnsPriority() (uint32, error) {
|
||||||
return c.getUint32Property(IP4ConfigPropertyDnsPriority)
|
return c.getUint32Property(IP4ConfigPropertyDnsPriority)
|
||||||
}
|
}
|
||||||
|
|
||||||
func (c *ip4Config) GetWinsServerData() []string {
|
func (c *ip4Config) GetPropertyWinsServerData() ([]string, error) {
|
||||||
return c.getSliceStringProperty(IP4ConfigPropertyWinsServerData)
|
return c.getSliceStringProperty(IP4ConfigPropertyWinsServerData)
|
||||||
}
|
}
|
||||||
|
|
||||||
func (c *ip4Config) MarshalJSON() ([]byte, error) {
|
func (c *ip4Config) MarshalJSON() ([]byte, error) {
|
||||||
return json.Marshal(map[string]interface{}{
|
m := make(map[string]interface{})
|
||||||
"Addresses": c.GetAddressData(),
|
|
||||||
"Routes": c.GetRouteData(),
|
m["Addresses"], _ = c.GetPropertyAddressData()
|
||||||
"Nameservers": c.GetNameserverData(),
|
m["Routes"], _ = c.GetPropertyRouteData()
|
||||||
"Domains": c.GetDomains(),
|
m["Nameservers"], _ = c.GetPropertyNameserverData()
|
||||||
})
|
m["Domains"], _ = c.GetPropertyDomains()
|
||||||
|
|
||||||
|
return json.Marshal(m)
|
||||||
}
|
}
|
||||||
|
|
108
IP6Config.go
108
IP6Config.go
|
@ -2,6 +2,8 @@ package gonetworkmanager
|
||||||
|
|
||||||
import (
|
import (
|
||||||
"encoding/json"
|
"encoding/json"
|
||||||
|
"errors"
|
||||||
|
|
||||||
"github.com/godbus/dbus"
|
"github.com/godbus/dbus"
|
||||||
)
|
)
|
||||||
|
|
||||||
|
@ -52,28 +54,28 @@ type IP6RouteData struct {
|
||||||
type IP6Config interface {
|
type IP6Config interface {
|
||||||
|
|
||||||
// Array of IP address data objects. All addresses will include "address" (an IP address string), and "prefix" (a uint). Some addresses may include additional attributes.
|
// Array of IP address data objects. All addresses will include "address" (an IP address string), and "prefix" (a uint). Some addresses may include additional attributes.
|
||||||
GetAddressData() []IP6AddressData
|
GetPropertyAddressData() ([]IP6AddressData, error)
|
||||||
|
|
||||||
// The gateway in use.
|
// The gateway in use.
|
||||||
GetGateway() string
|
GetPropertyGateway() (string, error)
|
||||||
|
|
||||||
// Array of IP route data objects. All routes will include "dest" (an IP address string) and "prefix" (a uint). Some routes may include "next-hop" (an IP address string), "metric" (a uint), and additional attributes.
|
// Array of IP route data objects. All routes will include "dest" (an IP address string) and "prefix" (a uint). Some routes may include "next-hop" (an IP address string), "metric" (a uint), and additional attributes.
|
||||||
GetRouteData() []IP6RouteData
|
GetPropertyRouteData() ([]IP6RouteData, error)
|
||||||
|
|
||||||
// GetNameservers gets the nameservers in use.
|
// GetNameservers gets the nameservers in use.
|
||||||
GetNameservers() []string
|
GetPropertyNameservers() ([]string, error)
|
||||||
|
|
||||||
// A list of domains this address belongs to.
|
// A list of domains this address belongs to.
|
||||||
GetDomains() []string
|
GetPropertyDomains() ([]string, error)
|
||||||
|
|
||||||
// A list of dns searches.
|
// A list of dns searches.
|
||||||
GetSearches() []string
|
GetPropertySearches() ([]string, error)
|
||||||
|
|
||||||
// A list of DNS options that modify the behavior of the DNS resolver. See resolv.conf(5) manual page for the list of supported options.
|
// A list of DNS options that modify the behavior of the DNS resolver. See resolv.conf(5) manual page for the list of supported options.
|
||||||
GetDnsOptions() []string
|
GetPropertyDnsOptions() ([]string, error)
|
||||||
|
|
||||||
// The relative priority of DNS servers.
|
// The relative priority of DNS servers.
|
||||||
GetDnsPriority() uint32
|
GetPropertyDnsPriority() (uint32, error)
|
||||||
|
|
||||||
MarshalJSON() ([]byte, error)
|
MarshalJSON() ([]byte, error)
|
||||||
}
|
}
|
||||||
|
@ -87,30 +89,46 @@ type ip6Config struct {
|
||||||
dbusBase
|
dbusBase
|
||||||
}
|
}
|
||||||
|
|
||||||
func (c *ip6Config) GetAddressData() []IP6AddressData {
|
func (c *ip6Config) GetPropertyAddressData() ([]IP6AddressData, error) {
|
||||||
|
addresses, err := c.getSliceMapStringVariantProperty(IP6ConfigPropertyAddressData)
|
||||||
addresses := c.getSliceMapStringVariantProperty(IP6ConfigPropertyAddressData)
|
|
||||||
ret := make([]IP6AddressData, len(addresses))
|
ret := make([]IP6AddressData, len(addresses))
|
||||||
|
|
||||||
|
if err != nil {
|
||||||
|
return ret, err
|
||||||
|
}
|
||||||
|
|
||||||
for i, address := range addresses {
|
for i, address := range addresses {
|
||||||
prefix := address["prefix"].Value().(uint32)
|
prefix, ok := address["prefix"].Value().(uint32)
|
||||||
|
if !ok {
|
||||||
|
return ret, errors.New("unexpected variant type for prefix")
|
||||||
|
}
|
||||||
|
|
||||||
|
address, ok := address["address"].Value().(string)
|
||||||
|
if !ok {
|
||||||
|
return ret, errors.New("unexpected variant type for address")
|
||||||
|
}
|
||||||
|
|
||||||
ret[i] = IP6AddressData{
|
ret[i] = IP6AddressData{
|
||||||
Address: address["address"].Value().(string),
|
Address: address,
|
||||||
Prefix: uint8(prefix),
|
Prefix: uint8(prefix),
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
return ret
|
|
||||||
|
return ret, nil
|
||||||
}
|
}
|
||||||
|
|
||||||
func (c *ip6Config) GetGateway() string {
|
func (c *ip6Config) GetPropertyGateway() (string, error) {
|
||||||
return c.getStringProperty(IP6ConfigPropertyGateway)
|
return c.getStringProperty(IP6ConfigPropertyGateway)
|
||||||
}
|
}
|
||||||
|
|
||||||
func (c *ip6Config) GetRouteData() []IP6RouteData {
|
func (c *ip6Config) GetPropertyRouteData() ([]IP6RouteData, error) {
|
||||||
routesData := c.getSliceMapStringVariantProperty(IP6ConfigPropertyRouteData)
|
routesData, err := c.getSliceMapStringVariantProperty(IP6ConfigPropertyRouteData)
|
||||||
routes := make([]IP6RouteData, len(routesData))
|
routes := make([]IP6RouteData, len(routesData))
|
||||||
|
|
||||||
|
if err != nil {
|
||||||
|
return routes, err
|
||||||
|
}
|
||||||
|
|
||||||
for _, routeData := range routesData {
|
for _, routeData := range routesData {
|
||||||
|
|
||||||
route := IP6RouteData{}
|
route := IP6RouteData{}
|
||||||
|
@ -118,14 +136,28 @@ func (c *ip6Config) GetRouteData() []IP6RouteData {
|
||||||
for routeDataAttributeName, routeDataAttribute := range routeData {
|
for routeDataAttributeName, routeDataAttribute := range routeData {
|
||||||
switch routeDataAttributeName {
|
switch routeDataAttributeName {
|
||||||
case "dest":
|
case "dest":
|
||||||
route.Destination = routeDataAttribute.Value().(string)
|
destination, ok := routeDataAttribute.Value().(string)
|
||||||
|
if !ok {
|
||||||
|
return routes, errors.New("unexpected variant type for dest")
|
||||||
|
}
|
||||||
|
route.Destination = destination
|
||||||
case "prefix":
|
case "prefix":
|
||||||
prefix, _ := routeDataAttribute.Value().(uint32)
|
prefix, ok := routeDataAttribute.Value().(uint32)
|
||||||
|
if !ok {
|
||||||
|
return routes, errors.New("unexpected variant type for prefix")
|
||||||
|
}
|
||||||
route.Prefix = uint8(prefix)
|
route.Prefix = uint8(prefix)
|
||||||
case "next-hop":
|
case "next-hop":
|
||||||
route.NextHop = routeDataAttribute.Value().(string)
|
nextHop, ok := routeDataAttribute.Value().(string)
|
||||||
|
if !ok {
|
||||||
|
return routes, errors.New("unexpected variant type for next-hop")
|
||||||
|
}
|
||||||
|
route.NextHop = nextHop
|
||||||
case "metric":
|
case "metric":
|
||||||
metric := routeDataAttribute.Value().(uint32)
|
metric, ok := routeDataAttribute.Value().(uint32)
|
||||||
|
if !ok {
|
||||||
|
return routes, errors.New("unexpected variant type for metric")
|
||||||
|
}
|
||||||
route.Metric = uint8(metric)
|
route.Metric = uint8(metric)
|
||||||
default:
|
default:
|
||||||
route.AdditionalAttributes[routeDataAttributeName] = routeDataAttribute.String()
|
route.AdditionalAttributes[routeDataAttributeName] = routeDataAttribute.String()
|
||||||
|
@ -134,41 +166,47 @@ func (c *ip6Config) GetRouteData() []IP6RouteData {
|
||||||
|
|
||||||
routes = append(routes, route)
|
routes = append(routes, route)
|
||||||
}
|
}
|
||||||
return routes
|
return routes, nil
|
||||||
}
|
}
|
||||||
|
|
||||||
func (c *ip6Config) GetNameservers() []string {
|
func (c *ip6Config) GetPropertyNameservers() ([]string, error) {
|
||||||
nameservers := c.getSliceSliceByteProperty(IP6ConfigPropertyNameservers)
|
nameservers, err := c.getSliceSliceByteProperty(IP6ConfigPropertyNameservers)
|
||||||
ret := make([]string, len(nameservers))
|
ret := make([]string, len(nameservers))
|
||||||
|
|
||||||
|
if err != nil {
|
||||||
|
return ret, err
|
||||||
|
}
|
||||||
|
|
||||||
for i, nameserver := range nameservers {
|
for i, nameserver := range nameservers {
|
||||||
ret[i] = string(nameserver)
|
ret[i] = string(nameserver)
|
||||||
}
|
}
|
||||||
|
|
||||||
return ret
|
return ret, nil
|
||||||
}
|
}
|
||||||
|
|
||||||
func (c *ip6Config) GetDomains() []string {
|
func (c *ip6Config) GetPropertyDomains() ([]string, error) {
|
||||||
return c.getSliceStringProperty(IP6ConfigPropertyDomains)
|
return c.getSliceStringProperty(IP6ConfigPropertyDomains)
|
||||||
}
|
}
|
||||||
|
|
||||||
func (c *ip6Config) GetSearches() []string {
|
func (c *ip6Config) GetPropertySearches() ([]string, error) {
|
||||||
return c.getSliceStringProperty(IP6ConfigPropertySearches)
|
return c.getSliceStringProperty(IP6ConfigPropertySearches)
|
||||||
}
|
}
|
||||||
|
|
||||||
func (c *ip6Config) GetDnsOptions() []string {
|
func (c *ip6Config) GetPropertyDnsOptions() ([]string, error) {
|
||||||
return c.getSliceStringProperty(IP6ConfigPropertyDnsOptions)
|
return c.getSliceStringProperty(IP6ConfigPropertyDnsOptions)
|
||||||
}
|
}
|
||||||
|
|
||||||
func (c *ip6Config) GetDnsPriority() uint32 {
|
func (c *ip6Config) GetPropertyDnsPriority() (uint32, error) {
|
||||||
return c.getUint32Property(IP6ConfigPropertyDnsPriority)
|
return c.getUint32Property(IP6ConfigPropertyDnsPriority)
|
||||||
}
|
}
|
||||||
|
|
||||||
func (c *ip6Config) MarshalJSON() ([]byte, error) {
|
func (c *ip6Config) MarshalJSON() ([]byte, error) {
|
||||||
return json.Marshal(map[string]interface{}{
|
m := make(map[string]interface{})
|
||||||
"Addresses": c.GetAddressData(),
|
|
||||||
"Routes": c.GetRouteData(),
|
m["Addresses"], _ = c.GetPropertyAddressData()
|
||||||
"Nameservers": c.GetNameservers(),
|
m["Routes"], _ = c.GetPropertyRouteData()
|
||||||
"Domains": c.GetDomains(),
|
m["Nameservers"], _ = c.GetPropertyNameservers()
|
||||||
})
|
m["Domains"], _ = c.GetPropertyDomains()
|
||||||
|
|
||||||
|
return json.Marshal(m)
|
||||||
}
|
}
|
||||||
|
|
|
@ -2,6 +2,7 @@ package gonetworkmanager
|
||||||
|
|
||||||
import (
|
import (
|
||||||
"encoding/json"
|
"encoding/json"
|
||||||
|
|
||||||
"github.com/godbus/dbus"
|
"github.com/godbus/dbus"
|
||||||
)
|
)
|
||||||
|
|
||||||
|
@ -132,75 +133,75 @@ type NetworkManager interface {
|
||||||
/* PROPERTIES */
|
/* PROPERTIES */
|
||||||
|
|
||||||
// The list of realized network devices. Realized devices are those which have backing resources (eg from the kernel or a management daemon like ModemManager, teamd, etc).
|
// The list of realized network devices. Realized devices are those which have backing resources (eg from the kernel or a management daemon like ModemManager, teamd, etc).
|
||||||
GetPropertyDevices() []Device
|
GetPropertyDevices() ([]Device, error)
|
||||||
|
|
||||||
// The list of both realized and un-realized network devices. Un-realized devices are software devices which do not yet have backing resources, but for which backing resources can be created if the device is activated.
|
// The list of both realized and un-realized network devices. Un-realized devices are software devices which do not yet have backing resources, but for which backing resources can be created if the device is activated.
|
||||||
GetPropertyAllDevices() []Device
|
GetPropertyAllDevices() ([]Device, error)
|
||||||
|
|
||||||
// The list of active checkpoints.
|
// The list of active checkpoints.
|
||||||
GetPropertyCheckpoints() []Checkpoint
|
GetPropertyCheckpoints() ([]Checkpoint, error)
|
||||||
|
|
||||||
// Indicates if overall networking is currently enabled or not. See the Enable() method.
|
// Indicates if overall networking is currently enabled or not. See the Enable() method.
|
||||||
GetPropertyNetworkingEnabled() bool
|
GetPropertyNetworkingEnabled() (bool, error)
|
||||||
|
|
||||||
// Indicates if wireless is currently enabled or not.
|
// Indicates if wireless is currently enabled or not.
|
||||||
GetPropertyWirelessEnabled() bool
|
GetPropertyWirelessEnabled() (bool, error)
|
||||||
|
|
||||||
// Indicates if the wireless hardware is currently enabled, i.e. the state of the RF kill switch.
|
// Indicates if the wireless hardware is currently enabled, i.e. the state of the RF kill switch.
|
||||||
GetPropertyWirelessHardwareEnabled() bool
|
GetPropertyWirelessHardwareEnabled() (bool, error)
|
||||||
|
|
||||||
// Indicates if mobile broadband devices are currently enabled or not.
|
// Indicates if mobile broadband devices are currently enabled or not.
|
||||||
GetPropertyWwanEnabled() bool
|
GetPropertyWwanEnabled() (bool, error)
|
||||||
|
|
||||||
// Indicates if the mobile broadband hardware is currently enabled, i.e. the state of the RF kill switch.
|
// Indicates if the mobile broadband hardware is currently enabled, i.e. the state of the RF kill switch.
|
||||||
GetPropertyWwanHardwareEnabled() bool
|
GetPropertyWwanHardwareEnabled() (bool, error)
|
||||||
|
|
||||||
// Indicates if WiMAX devices are currently enabled or not.
|
// Indicates if WiMAX devices are currently enabled or not.
|
||||||
GetPropertyWimaxEnabled() bool
|
GetPropertyWimaxEnabled() (bool, error)
|
||||||
|
|
||||||
// Indicates if the WiMAX hardware is currently enabled, i.e. the state of the RF kill switch.
|
// Indicates if the WiMAX hardware is currently enabled, i.e. the state of the RF kill switch.
|
||||||
GetPropertyWimaxHardwareEnabled() bool
|
GetPropertyWimaxHardwareEnabled() (bool, error)
|
||||||
|
|
||||||
// List of active connection object paths.
|
// List of active connection object paths.
|
||||||
GetPropertyActiveConnections() []ActiveConnection
|
GetPropertyActiveConnections() ([]ActiveConnection, error)
|
||||||
|
|
||||||
// The object path of the "primary" active connection being used to access the network. In particular, if there is no VPN active, or the VPN does not have the default route, then this indicates the connection that has the default route. If there is a VPN active with the default route, then this indicates the connection that contains the route to the VPN endpoint.
|
// The object path of the "primary" active connection being used to access the network. In particular, if there is no VPN active, or the VPN does not have the default route, then this indicates the connection that has the default route. If there is a VPN active with the default route, then this indicates the connection that contains the route to the VPN endpoint.
|
||||||
GetPropertyPrimaryConnection() Connection
|
GetPropertyPrimaryConnection() (Connection, error)
|
||||||
|
|
||||||
// The connection type of the "primary" active connection being used to access the network. This is the same as the Type property on the object indicated by PrimaryConnection.
|
// The connection type of the "primary" active connection being used to access the network. This is the same as the Type property on the object indicated by PrimaryConnection.
|
||||||
GetPropertyPrimaryConnectionType() string
|
GetPropertyPrimaryConnectionType() (string, error)
|
||||||
|
|
||||||
// Indicates whether the connectivity is metered. This is equivalent to the metered property of the device associated with the primary connection.
|
// Indicates whether the connectivity is metered. This is equivalent to the metered property of the device associated with the primary connection.
|
||||||
GetPropertyMetered() NmMetered
|
GetPropertyMetered() (NmMetered, error)
|
||||||
|
|
||||||
// The object path of an active connection that is currently being activated and which is expected to become the new PrimaryConnection when it finishes activating.
|
// The object path of an active connection that is currently being activated and which is expected to become the new PrimaryConnection when it finishes activating.
|
||||||
GetPropertyActivatingConnection() ActiveConnection
|
GetPropertyActivatingConnection() (ActiveConnection, error)
|
||||||
|
|
||||||
// Indicates whether NM is still starting up; this becomes FALSE when NM has finished attempting to activate every connection that it might be able to activate at startup.
|
// Indicates whether NM is still starting up; this becomes FALSE when NM has finished attempting to activate every connection that it might be able to activate at startup.
|
||||||
GetPropertyStartup() bool
|
GetPropertyStartup() (bool, error)
|
||||||
|
|
||||||
// NetworkManager version.
|
// NetworkManager version.
|
||||||
GetPropertyVersion() string
|
GetPropertyVersion() (string, error)
|
||||||
|
|
||||||
// The current set of capabilities. See NMCapability for currently defined capability numbers. The array is guaranteed to be sorted in ascending order without duplicates.
|
// The current set of capabilities. See NMCapability for currently defined capability numbers. The array is guaranteed to be sorted in ascending order without duplicates.
|
||||||
GetPropertyCapabilities() []NmCapability
|
GetPropertyCapabilities() ([]NmCapability, error)
|
||||||
|
|
||||||
// The overall state of the NetworkManager daemon.
|
// The overall state of the NetworkManager daemon.
|
||||||
// This takes state of all active connections and the connectivity state into account to produce a single indicator of the network accessibility status.
|
// This takes state of all active connections and the connectivity state into account to produce a single indicator of the network accessibility status.
|
||||||
// The graphical shells may use this property to provide network connection status indication and applications may use this to check if Internet connection is accessible. Shell that is able to cope with captive portals should use the "Connectivity" property to decide whether to present a captive portal authentication dialog.
|
// The graphical shells may use this property to provide network connection status indication and applications may use this to check if Internet connection is accessible. Shell that is able to cope with captive portals should use the "Connectivity" property to decide whether to present a captive portal authentication dialog.
|
||||||
GetPropertyState() NmState
|
GetPropertyState() (NmState, error)
|
||||||
|
|
||||||
// The result of the last connectivity check. The connectivity check is triggered automatically when a default connection becomes available, periodically and by calling a CheckConnectivity() method.
|
// The result of the last connectivity check. The connectivity check is triggered automatically when a default connection becomes available, periodically and by calling a CheckConnectivity() method.
|
||||||
// This property is in general useful for the graphical shell to determine whether the Internet access is being hijacked by an authentication gateway (a "captive portal"). In such case it would typically present a web browser window to give the user a chance to authenticate and call CheckConnectivity() when the user submits a form or dismisses the window.
|
// This property is in general useful for the graphical shell to determine whether the Internet access is being hijacked by an authentication gateway (a "captive portal"). In such case it would typically present a web browser window to give the user a chance to authenticate and call CheckConnectivity() when the user submits a form or dismisses the window.
|
||||||
// To determine the whether the user is able to access the Internet without dealing with captive portals (e.g. to provide a network connection indicator or disable controls that require Internet access), the "State" property is more suitable.
|
// To determine the whether the user is able to access the Internet without dealing with captive portals (e.g. to provide a network connection indicator or disable controls that require Internet access), the "State" property is more suitable.
|
||||||
GetPropertyConnectivity() NmConnectivity
|
GetPropertyConnectivity() (NmConnectivity, error)
|
||||||
|
|
||||||
// Indicates whether connectivity checking service has been configured. This may return true even if the service is not currently enabled.
|
// Indicates whether connectivity checking service has been configured. This may return true even if the service is not currently enabled.
|
||||||
// This is primarily intended for use in a privacy control panel, as a way to determine whether to show an option to enable/disable the feature.
|
// This is primarily intended for use in a privacy control panel, as a way to determine whether to show an option to enable/disable the feature.
|
||||||
GetPropertyConnectivityCheckAvailable() bool
|
GetPropertyConnectivityCheckAvailable() (bool, error)
|
||||||
|
|
||||||
// Indicates whether connectivity checking is enabled. This property can also be written to to disable connectivity checking (as a privacy control panel might want to do).
|
// Indicates whether connectivity checking is enabled. This property can also be written to to disable connectivity checking (as a privacy control panel might want to do).
|
||||||
GetPropertyConnectivityCheckEnabled() bool
|
GetPropertyConnectivityCheckEnabled() (bool, error)
|
||||||
|
|
||||||
// Dictionary of global DNS settings where the key is one of "searches", "options" and "domains". The values for the "searches" and "options" keys are string arrays describing the list of search domains and resolver options, respectively. The value of the "domains" key is a second-level dictionary, where each key is a domain name, and each key's value is a third-level dictionary with the keys "servers" and "options". "servers" is a string array of DNS servers, "options" is a string array of domain-specific options.
|
// Dictionary of global DNS settings where the key is one of "searches", "options" and "domains". The values for the "searches" and "options" keys are string arrays describing the list of search domains and resolver options, respectively. The value of the "domains" key is a second-level dictionary, where each key is a domain name, and each key's value is a third-level dictionary with the keys "servers" and "options". "servers" is a string array of DNS servers, "options" is a string array of domain-specific options.
|
||||||
//GetPropertyGlobalDnsConfiguration() []interface{}
|
//GetPropertyGlobalDnsConfiguration() []interface{}
|
||||||
|
@ -379,142 +380,152 @@ func (nm *networkManager) CheckpointAdjustRollbackTimeout(checkpoint Checkpoint,
|
||||||
|
|
||||||
/* PROPERTIES */
|
/* PROPERTIES */
|
||||||
|
|
||||||
func (nm *networkManager) GetPropertyDevices() []Device {
|
func (nm *networkManager) GetPropertyDevices() ([]Device, error) {
|
||||||
devicesPaths := nm.getSliceObjectProperty(NetworkManagerPropertyDevices)
|
devicesPaths, err := nm.getSliceObjectProperty(NetworkManagerPropertyDevices)
|
||||||
devices := make([]Device, len(devicesPaths))
|
if err != nil {
|
||||||
|
return nil, err
|
||||||
|
}
|
||||||
|
|
||||||
var err error
|
devices := make([]Device, len(devicesPaths))
|
||||||
for i, path := range devicesPaths {
|
for i, path := range devicesPaths {
|
||||||
devices[i], err = NewDevice(path)
|
devices[i], err = NewDevice(path)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
panic(err)
|
return devices, err
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
return devices
|
return devices, nil
|
||||||
}
|
}
|
||||||
|
|
||||||
func (nm *networkManager) GetPropertyAllDevices() []Device {
|
func (nm *networkManager) GetPropertyAllDevices() ([]Device, error) {
|
||||||
devicesPaths := nm.getSliceObjectProperty(NetworkManagerPropertyAllDevices)
|
devicesPaths, err := nm.getSliceObjectProperty(NetworkManagerPropertyAllDevices)
|
||||||
devices := make([]Device, len(devicesPaths))
|
if err != nil {
|
||||||
|
return nil, err
|
||||||
|
}
|
||||||
|
|
||||||
var err error
|
devices := make([]Device, len(devicesPaths))
|
||||||
for i, path := range devicesPaths {
|
for i, path := range devicesPaths {
|
||||||
devices[i], err = NewDevice(path)
|
devices[i], err = NewDevice(path)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
panic(err)
|
return devices, err
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
return devices
|
return devices, nil
|
||||||
}
|
}
|
||||||
|
|
||||||
func (nm *networkManager) GetPropertyCheckpoints() []Checkpoint {
|
func (nm *networkManager) GetPropertyCheckpoints() ([]Checkpoint, error) {
|
||||||
checkpointsPaths := nm.getSliceObjectProperty(NetworkManagerPropertyAllDevices)
|
checkpointsPaths, err := nm.getSliceObjectProperty(NetworkManagerPropertyAllDevices)
|
||||||
|
if err != nil {
|
||||||
|
return nil, err
|
||||||
|
}
|
||||||
|
|
||||||
checkpoints := make([]Checkpoint, len(checkpointsPaths))
|
checkpoints := make([]Checkpoint, len(checkpointsPaths))
|
||||||
|
|
||||||
var err error
|
|
||||||
for i, path := range checkpointsPaths {
|
for i, path := range checkpointsPaths {
|
||||||
checkpoints[i], err = NewCheckpoint(path)
|
checkpoints[i], err = NewCheckpoint(path)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
panic(err)
|
return checkpoints, err
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
return checkpoints
|
return checkpoints, nil
|
||||||
}
|
}
|
||||||
|
|
||||||
func (nm *networkManager) GetPropertyNetworkingEnabled() bool {
|
func (nm *networkManager) GetPropertyNetworkingEnabled() (bool, error) {
|
||||||
return nm.getBoolProperty(NetworkManagerPropertyNetworkingEnabled)
|
return nm.getBoolProperty(NetworkManagerPropertyNetworkingEnabled)
|
||||||
}
|
}
|
||||||
|
|
||||||
func (nm *networkManager) GetPropertyWirelessEnabled() bool {
|
func (nm *networkManager) GetPropertyWirelessEnabled() (bool, error) {
|
||||||
return nm.getBoolProperty(NetworkManagerPropertyWirelessEnabled)
|
return nm.getBoolProperty(NetworkManagerPropertyWirelessEnabled)
|
||||||
}
|
}
|
||||||
|
|
||||||
func (nm *networkManager) GetPropertyWirelessHardwareEnabled() bool {
|
func (nm *networkManager) GetPropertyWirelessHardwareEnabled() (bool, error) {
|
||||||
return nm.getBoolProperty(NetworkManagerPropertyWirelessHardwareEnabled)
|
return nm.getBoolProperty(NetworkManagerPropertyWirelessHardwareEnabled)
|
||||||
}
|
}
|
||||||
|
|
||||||
func (nm *networkManager) GetPropertyWwanEnabled() bool {
|
func (nm *networkManager) GetPropertyWwanEnabled() (bool, error) {
|
||||||
return nm.getBoolProperty(NetworkManagerPropertyWwanEnabled)
|
return nm.getBoolProperty(NetworkManagerPropertyWwanEnabled)
|
||||||
}
|
}
|
||||||
|
|
||||||
func (nm *networkManager) GetPropertyWwanHardwareEnabled() bool {
|
func (nm *networkManager) GetPropertyWwanHardwareEnabled() (bool, error) {
|
||||||
return nm.getBoolProperty(NetworkManagerPropertyWwanHardwareEnabled)
|
return nm.getBoolProperty(NetworkManagerPropertyWwanHardwareEnabled)
|
||||||
}
|
}
|
||||||
|
|
||||||
func (nm *networkManager) GetPropertyWimaxEnabled() bool {
|
func (nm *networkManager) GetPropertyWimaxEnabled() (bool, error) {
|
||||||
return nm.getBoolProperty(NetworkManagerPropertyWimaxEnabled)
|
return nm.getBoolProperty(NetworkManagerPropertyWimaxEnabled)
|
||||||
}
|
}
|
||||||
|
|
||||||
func (nm *networkManager) GetPropertyWimaxHardwareEnabled() bool {
|
func (nm *networkManager) GetPropertyWimaxHardwareEnabled() (bool, error) {
|
||||||
return nm.getBoolProperty(NetworkManagerPropertyWimaxHardwareEnabled)
|
return nm.getBoolProperty(NetworkManagerPropertyWimaxHardwareEnabled)
|
||||||
}
|
}
|
||||||
|
|
||||||
func (nm *networkManager) GetPropertyActiveConnections() []ActiveConnection {
|
func (nm *networkManager) GetPropertyActiveConnections() ([]ActiveConnection, error) {
|
||||||
acPaths := nm.getSliceObjectProperty(NetworkManagerPropertyActiveConnections)
|
acPaths, err := nm.getSliceObjectProperty(NetworkManagerPropertyActiveConnections)
|
||||||
ac := make([]ActiveConnection, len(acPaths))
|
if err != nil {
|
||||||
|
return nil, err
|
||||||
|
}
|
||||||
|
|
||||||
var err error
|
ac := make([]ActiveConnection, len(acPaths))
|
||||||
for i, path := range acPaths {
|
for i, path := range acPaths {
|
||||||
ac[i], err = NewActiveConnection(path)
|
ac[i], err = NewActiveConnection(path)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
panic(err)
|
return ac, err
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
return ac
|
return ac, nil
|
||||||
}
|
}
|
||||||
|
|
||||||
func (nm *networkManager) GetPropertyPrimaryConnection() Connection {
|
func (nm *networkManager) GetPropertyPrimaryConnection() (Connection, error) {
|
||||||
connectionPath := nm.getObjectProperty(NetworkManagerPropertyPrimaryConnection)
|
connectionPath, err := nm.getObjectProperty(NetworkManagerPropertyPrimaryConnection)
|
||||||
|
|
||||||
connection, err := NewConnection(connectionPath)
|
|
||||||
if err != nil {
|
if err != nil {
|
||||||
panic(err)
|
return nil, err
|
||||||
}
|
}
|
||||||
|
|
||||||
return connection
|
return NewConnection(connectionPath)
|
||||||
}
|
}
|
||||||
|
|
||||||
func (nm *networkManager) GetPropertyPrimaryConnectionType() string {
|
func (nm *networkManager) GetPropertyPrimaryConnectionType() (string, error) {
|
||||||
return nm.getStringProperty(NetworkManagerPropertyPrimaryConnectionType)
|
return nm.getStringProperty(NetworkManagerPropertyPrimaryConnectionType)
|
||||||
}
|
}
|
||||||
|
|
||||||
func (nm *networkManager) GetPropertyMetered() NmMetered {
|
func (nm *networkManager) GetPropertyMetered() (NmMetered, error) {
|
||||||
return NmMetered(nm.getUint32Property(NetworkManagerPropertyMetered))
|
v, err := nm.getUint32Property(NetworkManagerPropertyMetered)
|
||||||
|
return NmMetered(v), err
|
||||||
}
|
}
|
||||||
|
|
||||||
func (nm *networkManager) GetPropertyActivatingConnection() ActiveConnection {
|
func (nm *networkManager) GetPropertyActivatingConnection() (ActiveConnection, error) {
|
||||||
panic("implement me")
|
panic("implement me")
|
||||||
}
|
}
|
||||||
|
|
||||||
func (nm *networkManager) GetPropertyStartup() bool {
|
func (nm *networkManager) GetPropertyStartup() (bool, error) {
|
||||||
return nm.getBoolProperty(NetworkManagerPropertyStartup)
|
return nm.getBoolProperty(NetworkManagerPropertyStartup)
|
||||||
}
|
}
|
||||||
|
|
||||||
func (nm *networkManager) GetPropertyVersion() string {
|
func (nm *networkManager) GetPropertyVersion() (string, error) {
|
||||||
return nm.getStringProperty(NetworkManagerPropertyVersion)
|
return nm.getStringProperty(NetworkManagerPropertyVersion)
|
||||||
}
|
}
|
||||||
|
|
||||||
func (nm *networkManager) GetPropertyCapabilities() []NmCapability {
|
func (nm *networkManager) GetPropertyCapabilities() ([]NmCapability, error) {
|
||||||
panic("implement me")
|
panic("implement me")
|
||||||
}
|
}
|
||||||
|
|
||||||
func (nm *networkManager) GetPropertyState() NmState {
|
func (nm *networkManager) GetPropertyState() (NmState, error) {
|
||||||
return NmState(nm.getUint32Property(NetworkManagerPropertyState))
|
v, err := nm.getUint32Property(NetworkManagerPropertyState)
|
||||||
|
return NmState(v), err
|
||||||
}
|
}
|
||||||
|
|
||||||
func (nm *networkManager) GetPropertyConnectivity() NmConnectivity {
|
func (nm *networkManager) GetPropertyConnectivity() (NmConnectivity, error) {
|
||||||
return NmConnectivity(nm.getUint32Property(NetworkManagerPropertyConnectivity))
|
v, err := nm.getUint32Property(NetworkManagerPropertyConnectivity)
|
||||||
|
return NmConnectivity(v), err
|
||||||
}
|
}
|
||||||
|
|
||||||
func (nm *networkManager) GetPropertyConnectivityCheckAvailable() bool {
|
func (nm *networkManager) GetPropertyConnectivityCheckAvailable() (bool, error) {
|
||||||
return nm.getBoolProperty(NetworkManagerPropertyConnectivityCheckAvailable)
|
return nm.getBoolProperty(NetworkManagerPropertyConnectivityCheckAvailable)
|
||||||
}
|
}
|
||||||
|
|
||||||
func (nm *networkManager) GetPropertyConnectivityCheckEnabled() bool {
|
func (nm *networkManager) GetPropertyConnectivityCheckEnabled() (bool, error) {
|
||||||
return nm.getBoolProperty(NetworkManagerPropertyConnectivityCheckEnabled)
|
return nm.getBoolProperty(NetworkManagerPropertyConnectivityCheckEnabled)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -536,28 +547,30 @@ func (nm *networkManager) Unsubscribe() {
|
||||||
}
|
}
|
||||||
|
|
||||||
func (nm *networkManager) MarshalJSON() ([]byte, error) {
|
func (nm *networkManager) MarshalJSON() ([]byte, error) {
|
||||||
return json.Marshal(map[string]interface{}{
|
m := make(map[string]interface{})
|
||||||
"Devices": nm.GetPropertyDevices(),
|
|
||||||
"AllDevices": nm.GetPropertyAllDevices(),
|
m["Devices"], _ = nm.GetPropertyDevices()
|
||||||
"Checkpoints": nm.GetPropertyCheckpoints(),
|
m["AllDevices"], _ = nm.GetPropertyAllDevices()
|
||||||
"NetworkingEnabled": nm.GetPropertyNetworkingEnabled(),
|
m["Checkpoints"], _ = nm.GetPropertyCheckpoints()
|
||||||
"WirelessEnabled": nm.GetPropertyWirelessEnabled(),
|
m["NetworkingEnabled"], _ = nm.GetPropertyNetworkingEnabled()
|
||||||
"WirelessHardwareEnabled": nm.GetPropertyWirelessHardwareEnabled(),
|
m["WirelessEnabled"], _ = nm.GetPropertyWirelessEnabled()
|
||||||
"WwanEnabled": nm.GetPropertyWwanEnabled(),
|
m["WirelessHardwareEnabled"], _ = nm.GetPropertyWirelessHardwareEnabled()
|
||||||
"WwanHardwareEnabled": nm.GetPropertyWwanHardwareEnabled(),
|
m["WwanEnabled"], _ = nm.GetPropertyWwanEnabled()
|
||||||
"WimaxEnabled": nm.GetPropertyWimaxEnabled(),
|
m["WwanHardwareEnabled"], _ = nm.GetPropertyWwanHardwareEnabled()
|
||||||
"WimaxHardwareEnabled": nm.GetPropertyWimaxHardwareEnabled(),
|
m["WimaxEnabled"], _ = nm.GetPropertyWimaxEnabled()
|
||||||
"ActiveConnections": nm.GetPropertyActiveConnections(),
|
m["WimaxHardwareEnabled"], _ = nm.GetPropertyWimaxHardwareEnabled()
|
||||||
"PrimaryConnection": nm.GetPropertyPrimaryConnection(),
|
m["ActiveConnections"], _ = nm.GetPropertyActiveConnections()
|
||||||
"PrimaryConnectionType": nm.GetPropertyPrimaryConnectionType(),
|
m["PrimaryConnection"], _ = nm.GetPropertyPrimaryConnection()
|
||||||
"Metered": nm.GetPropertyMetered(),
|
m["PrimaryConnectionType"], _ = nm.GetPropertyPrimaryConnectionType()
|
||||||
"ActivatingConnection": nm.GetPropertyActivatingConnection(),
|
m["Metered"], _ = nm.GetPropertyMetered()
|
||||||
"Startup": nm.GetPropertyStartup(),
|
m["ActivatingConnection"], _ = nm.GetPropertyActivatingConnection()
|
||||||
"Version": nm.GetPropertyVersion(),
|
m["Startup"], _ = nm.GetPropertyStartup()
|
||||||
"Capabilities": nm.GetPropertyCapabilities(),
|
m["Version"], _ = nm.GetPropertyVersion()
|
||||||
"State": nm.GetPropertyState(),
|
m["Capabilities"], _ = nm.GetPropertyCapabilities()
|
||||||
"Connectivity": nm.GetPropertyConnectivity(),
|
m["State"], _ = nm.GetPropertyState()
|
||||||
"ConnectivityCheckAvailable": nm.GetPropertyConnectivityCheckAvailable(),
|
m["Connectivity"], _ = nm.GetPropertyConnectivity()
|
||||||
"ConnectivityCheckEnabled": nm.GetPropertyConnectivityCheckEnabled(),
|
m["ConnectivityCheckAvailable"], _ = nm.GetPropertyConnectivityCheckAvailable()
|
||||||
})
|
m["ConnectivityCheckEnabled"], _ = nm.GetPropertyConnectivityCheckEnabled()
|
||||||
|
|
||||||
|
return json.Marshal(m)
|
||||||
}
|
}
|
||||||
|
|
12
Settings.go
12
Settings.go
|
@ -37,10 +37,10 @@ type Settings interface {
|
||||||
SaveHostname(hostname string)
|
SaveHostname(hostname string)
|
||||||
|
|
||||||
// If true, adding and modifying connections is supported.
|
// If true, adding and modifying connections is supported.
|
||||||
CanModify() bool
|
GetPropertyCanModify() (bool, error)
|
||||||
|
|
||||||
// The machine hostname stored in persistent configuration.
|
// The machine hostname stored in persistent configuration.
|
||||||
Hostname() string
|
GetPropertyHostname() (string, error)
|
||||||
}
|
}
|
||||||
|
|
||||||
func NewSettings() (Settings, error) {
|
func NewSettings() (Settings, error) {
|
||||||
|
@ -96,12 +96,10 @@ func (s *settings) SaveHostname(hostname string) {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
func (s *settings) Hostname() string {
|
func (s *settings) GetPropertyHostname() (string, error) {
|
||||||
hostname := s.getStringProperty(SettingsPropertyHostname)
|
return s.getStringProperty(SettingsPropertyHostname)
|
||||||
|
|
||||||
return hostname
|
|
||||||
}
|
}
|
||||||
|
|
||||||
func (s *settings) CanModify() bool {
|
func (s *settings) GetPropertyCanModify() (bool, error) {
|
||||||
return s.getBoolProperty(SettingsPropertyCanModify)
|
return s.getBoolProperty(SettingsPropertyCanModify)
|
||||||
}
|
}
|
||||||
|
|
230
utils.go
230
utils.go
|
@ -60,132 +60,204 @@ func (d *dbusBase) subscribeNamespace(namespace string) {
|
||||||
d.conn.BusObject().Call(dbusMethodAddMatch, 0, rule)
|
d.conn.BusObject().Call(dbusMethodAddMatch, 0, rule)
|
||||||
}
|
}
|
||||||
|
|
||||||
func (d *dbusBase) getProperty(iface string) interface{} {
|
func (d *dbusBase) getProperty(iface string) (interface{}, error) {
|
||||||
variant, err := d.obj.GetProperty(iface)
|
variant, err := d.obj.GetProperty(iface)
|
||||||
|
return variant.Value(), err
|
||||||
|
}
|
||||||
|
|
||||||
|
func (d *dbusBase) getObjectProperty(iface string) (value dbus.ObjectPath, err error) {
|
||||||
|
prop, err := d.getProperty(iface)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
panic(err)
|
return
|
||||||
}
|
}
|
||||||
return variant.Value()
|
value, ok := prop.(dbus.ObjectPath)
|
||||||
|
if !ok {
|
||||||
|
err = makeErrVariantType(iface)
|
||||||
|
return
|
||||||
|
}
|
||||||
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
func (d *dbusBase) getObjectProperty(iface string) dbus.ObjectPath {
|
func (d *dbusBase) getSliceObjectProperty(iface string) (value []dbus.ObjectPath, err error) {
|
||||||
value, ok := d.getProperty(iface).(dbus.ObjectPath)
|
prop, err := d.getProperty(iface)
|
||||||
if !ok {
|
if err != nil {
|
||||||
panic(makeErrVariantType(iface))
|
return
|
||||||
}
|
}
|
||||||
return value
|
value, ok := prop.([]dbus.ObjectPath)
|
||||||
|
if !ok {
|
||||||
|
err = makeErrVariantType(iface)
|
||||||
|
return
|
||||||
|
}
|
||||||
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
func (d *dbusBase) getSliceObjectProperty(iface string) []dbus.ObjectPath {
|
func (d *dbusBase) getBoolProperty(iface string) (value bool, err error) {
|
||||||
value, ok := d.getProperty(iface).([]dbus.ObjectPath)
|
prop, err := d.getProperty(iface)
|
||||||
if !ok {
|
if err != nil {
|
||||||
panic(makeErrVariantType(iface))
|
return
|
||||||
}
|
}
|
||||||
return value
|
value, ok := prop.(bool)
|
||||||
|
if !ok {
|
||||||
|
err = makeErrVariantType(iface)
|
||||||
|
return
|
||||||
|
}
|
||||||
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
func (d *dbusBase) getBoolProperty(iface string) bool {
|
func (d *dbusBase) getStringProperty(iface string) (value string, err error) {
|
||||||
value, ok := d.getProperty(iface).(bool)
|
prop, err := d.getProperty(iface)
|
||||||
if !ok {
|
if err != nil {
|
||||||
panic(makeErrVariantType(iface))
|
return
|
||||||
}
|
}
|
||||||
return value
|
value, ok := prop.(string)
|
||||||
|
if !ok {
|
||||||
|
err = makeErrVariantType(iface)
|
||||||
|
return
|
||||||
|
}
|
||||||
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
func (d *dbusBase) getStringProperty(iface string) string {
|
func (d *dbusBase) getSliceStringProperty(iface string) (value []string, err error) {
|
||||||
value, ok := d.getProperty(iface).(string)
|
prop, err := d.getProperty(iface)
|
||||||
if !ok {
|
if err != nil {
|
||||||
panic(makeErrVariantType(iface))
|
return
|
||||||
}
|
}
|
||||||
return value
|
value, ok := prop.([]string)
|
||||||
|
if !ok {
|
||||||
|
err = makeErrVariantType(iface)
|
||||||
|
return
|
||||||
|
}
|
||||||
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
func (d *dbusBase) getSliceStringProperty(iface string) []string {
|
func (d *dbusBase) getSliceSliceByteProperty(iface string) (value [][]byte, err error) {
|
||||||
value, ok := d.getProperty(iface).([]string)
|
prop, err := d.getProperty(iface)
|
||||||
if !ok {
|
if err != nil {
|
||||||
panic(makeErrVariantType(iface))
|
return
|
||||||
}
|
}
|
||||||
return value
|
value, ok := prop.([][]byte)
|
||||||
|
if !ok {
|
||||||
|
err = makeErrVariantType(iface)
|
||||||
|
return
|
||||||
|
}
|
||||||
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
func (d *dbusBase) getSliceSliceByteProperty(iface string) [][]byte {
|
func (d *dbusBase) getMapStringVariantProperty(iface string) (value map[string]dbus.Variant, err error) {
|
||||||
value, ok := d.getProperty(iface).([][]byte)
|
prop, err := d.getProperty(iface)
|
||||||
if !ok {
|
if err != nil {
|
||||||
panic(makeErrVariantType(iface))
|
return
|
||||||
}
|
}
|
||||||
return value
|
value, ok := prop.(map[string]dbus.Variant)
|
||||||
|
if !ok {
|
||||||
|
err = makeErrVariantType(iface)
|
||||||
|
return
|
||||||
|
}
|
||||||
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
func (d *dbusBase) getMapStringVariantProperty(iface string) map[string]dbus.Variant {
|
func (d *dbusBase) getUint8Property(iface string) (value uint8, err error) {
|
||||||
value, ok := d.getProperty(iface).(map[string]dbus.Variant)
|
prop, err := d.getProperty(iface)
|
||||||
if !ok {
|
if err != nil {
|
||||||
panic(makeErrVariantType(iface))
|
return
|
||||||
}
|
}
|
||||||
return value
|
value, ok := prop.(uint8)
|
||||||
|
if !ok {
|
||||||
|
err = makeErrVariantType(iface)
|
||||||
|
return
|
||||||
|
}
|
||||||
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
func (d *dbusBase) getUint8Property(iface string) uint8 {
|
func (d *dbusBase) getUint32Property(iface string) (value uint32, err error) {
|
||||||
value, ok := d.getProperty(iface).(uint8)
|
prop, err := d.getProperty(iface)
|
||||||
if !ok {
|
if err != nil {
|
||||||
panic(makeErrVariantType(iface))
|
return
|
||||||
}
|
}
|
||||||
return value
|
value, ok := prop.(uint32)
|
||||||
|
if !ok {
|
||||||
|
err = makeErrVariantType(iface)
|
||||||
|
return
|
||||||
|
}
|
||||||
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
func (d *dbusBase) getUint32Property(iface string) uint32 {
|
func (d *dbusBase) getInt64Property(iface string) (value int64, err error) {
|
||||||
value, ok := d.getProperty(iface).(uint32)
|
prop, err := d.getProperty(iface)
|
||||||
if !ok {
|
if err != nil {
|
||||||
panic(makeErrVariantType(iface))
|
return
|
||||||
}
|
}
|
||||||
return value
|
value, ok := prop.(int64)
|
||||||
|
if !ok {
|
||||||
|
err = makeErrVariantType(iface)
|
||||||
|
return
|
||||||
|
}
|
||||||
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
func (d *dbusBase) getInt64Property(iface string) int64 {
|
func (d *dbusBase) getUint64Property(iface string) (value uint64, err error) {
|
||||||
value, ok := d.getProperty(iface).(int64)
|
prop, err := d.getProperty(iface)
|
||||||
if !ok {
|
if err != nil {
|
||||||
panic(makeErrVariantType(iface))
|
return
|
||||||
}
|
}
|
||||||
return value
|
value, ok := prop.(uint64)
|
||||||
|
if !ok {
|
||||||
|
err = makeErrVariantType(iface)
|
||||||
|
return
|
||||||
|
}
|
||||||
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
func (d *dbusBase) getUint64Property(iface string) uint64 {
|
func (d *dbusBase) getSliceUint32Property(iface string) (value []uint32, err error) {
|
||||||
value, ok := d.getProperty(iface).(uint64)
|
prop, err := d.getProperty(iface)
|
||||||
if !ok {
|
if err != nil {
|
||||||
panic(makeErrVariantType(iface))
|
return
|
||||||
}
|
}
|
||||||
return value
|
value, ok := prop.([]uint32)
|
||||||
|
if !ok {
|
||||||
|
err = makeErrVariantType(iface)
|
||||||
|
return
|
||||||
|
}
|
||||||
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
func (d *dbusBase) getSliceUint32Property(iface string) []uint32 {
|
func (d *dbusBase) getSliceSliceUint32Property(iface string) (value [][]uint32, err error) {
|
||||||
value, ok := d.getProperty(iface).([]uint32)
|
prop, err := d.getProperty(iface)
|
||||||
if !ok {
|
if err != nil {
|
||||||
panic(makeErrVariantType(iface))
|
return
|
||||||
}
|
}
|
||||||
return value
|
value, ok := prop.([][]uint32)
|
||||||
|
if !ok {
|
||||||
|
err = makeErrVariantType(iface)
|
||||||
|
return
|
||||||
|
}
|
||||||
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
func (d *dbusBase) getSliceSliceUint32Property(iface string) [][]uint32 {
|
func (d *dbusBase) getSliceMapStringVariantProperty(iface string) (value []map[string]dbus.Variant, err error) {
|
||||||
value, ok := d.getProperty(iface).([][]uint32)
|
prop, err := d.getProperty(iface)
|
||||||
if !ok {
|
if err != nil {
|
||||||
panic(makeErrVariantType(iface))
|
return
|
||||||
}
|
}
|
||||||
return value
|
value, ok := prop.([]map[string]dbus.Variant)
|
||||||
|
if !ok {
|
||||||
|
err = makeErrVariantType(iface)
|
||||||
|
return
|
||||||
|
}
|
||||||
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
func (d *dbusBase) getSliceMapStringVariantProperty(iface string) []map[string]dbus.Variant {
|
func (d *dbusBase) getSliceByteProperty(iface string) (value []byte, err error) {
|
||||||
value, ok := d.getProperty(iface).([]map[string]dbus.Variant)
|
prop, err := d.getProperty(iface)
|
||||||
if !ok {
|
if err != nil {
|
||||||
panic(makeErrVariantType(iface))
|
return
|
||||||
}
|
}
|
||||||
return value
|
value, ok := prop.([]byte)
|
||||||
}
|
|
||||||
|
|
||||||
func (d *dbusBase) getSliceByteProperty(iface string) []byte {
|
|
||||||
value, ok := d.getProperty(iface).([]byte)
|
|
||||||
if !ok {
|
if !ok {
|
||||||
panic(makeErrVariantType(iface))
|
err = makeErrVariantType(iface)
|
||||||
|
return
|
||||||
}
|
}
|
||||||
return value
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
func makeErrVariantType(iface string) error {
|
func makeErrVariantType(iface string) error {
|
||||||
|
|
Reference in a new issue