gonetworkmanager

package module
v0.0.0-...-03a07dc Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Mar 28, 2019 License: MIT Imports: 5 Imported by: 0

README

gonetworkmanager

Go D-Bus bindings for NetworkManager.

Currently tested with NetworkManager 0.9.8.10.

GoDoc

NetworkManager 0.9 D-Bus Spec

Documentation

Index

Constants

View Source
const (
	AccessPointInterface = NetworkManagerInterface + ".AccessPoint"

	AccessPointPropertyFlags      = AccessPointInterface + ".Flags"
	AccessPointPropertyWPAFlags   = AccessPointInterface + ".WpaFlags"
	AccessPointPropertyRSNFlags   = AccessPointInterface + ".RsnFlags"
	AccessPointPropertySSID       = AccessPointInterface + ".Ssid"
	AccessPointPropertyFrequency  = AccessPointInterface + ".Frequency"
	AccessPointPropertyHWAddress  = AccessPointInterface + ".HwAddress"
	AccessPointPropertyMode       = AccessPointInterface + ".Mode"
	AccessPointPropertyMaxBitrate = AccessPointInterface + ".MaxBitrate"
	AccessPointPropertyStrength   = AccessPointInterface + ".Strength"
)
View Source
const (
	ActiveConnectionInterface             = NetworkManagerInterface + ".Connection.Active"
	ActiveConnectionProperyConnection     = ActiveConnectionInterface + ".Connection"
	ActiveConnectionProperySpecificObject = ActiveConnectionInterface + ".SpecificObject"
	ActiveConnectionProperyID             = ActiveConnectionInterface + ".Id"
	ActiveConnectionProperyUUID           = ActiveConnectionInterface + ".Uuid"
	ActiveConnectionProperyType           = ActiveConnectionInterface + ".Type"
	ActiveConnectionProperyDevices        = ActiveConnectionInterface + ".Devices"
	ActiveConnectionProperyState          = ActiveConnectionInterface + ".State"
	ActiveConnectionProperyStateFlags     = ActiveConnectionInterface + ".StateFlags"
	ActiveConnectionProperyDefault        = ActiveConnectionInterface + ".Default"
	ActiveConnectionProperyIP4Config      = ActiveConnectionInterface + ".Ip4Config"
	ActiveConnectionProperyDHCP4Config    = ActiveConnectionInterface + ".Dhcp4Config"
	ActiveConnectionProperyDefault6       = ActiveConnectionInterface + ".Default6"
	ActiveConnectionProperyVPN            = ActiveConnectionInterface + ".Vpn"
	ActiveConnectionProperyMaster         = ActiveConnectionInterface + ".Master"
)
View Source
const (
	ConnectionInterface = SettingsInterface + ".Connection"

	ConnectionGetSettings = ConnectionInterface + ".GetSettings"
	ConnectionDelete      = ConnectionInterface + ".Delete"
)
View Source
const (
	DHCP4ConfigInterface = NetworkManagerInterface + ".DHCP4Config"

	DHCP4ConfigPropertyOptions = DHCP4ConfigInterface + ".Options"
)
View Source
const (
	DeviceInterface = NetworkManagerInterface + ".Device"

	DevicePropertyInterface            = DeviceInterface + ".Interface"
	DevicePropertyIpInterface          = DeviceInterface + ".IpInterface"
	DevicePropertyState                = DeviceInterface + ".State"
	DevicePropertyIP4Config            = DeviceInterface + ".Ip4Config"
	DevicePropertyDeviceType           = DeviceInterface + ".DeviceType"
	DevicePropertyAvailableConnections = DeviceInterface + ".AvailableConnections"
	DevicePropertyDhcp4Config          = DeviceInterface + ".Dhcp4Config"
)
View Source
const (
	IP4ConfigInterface = NetworkManagerInterface + ".IP4Config"

	IP4ConfigPropertyAddresses   = IP4ConfigInterface + ".Addresses"
	IP4ConfigPropertyRoutes      = IP4ConfigInterface + ".Routes"
	IP4ConfigPropertyNameservers = IP4ConfigInterface + ".Nameservers"
	IP4ConfigPropertyDomains     = IP4ConfigInterface + ".Domains"
)
View Source
const (
	NetworkManagerInterface  = "org.freedesktop.NetworkManager"
	NetworkManagerObjectPath = "/org/freedesktop/NetworkManager"

	NetworkManagerGetDevices               = NetworkManagerInterface + ".GetDevices"
	NetworkManagerActivateConnection       = NetworkManagerInterface + ".ActivateConnection"
	NetworkManagerPropertyState            = NetworkManagerInterface + ".State"
	NetworkManagerPropertyActiveConnection = NetworkManagerInterface + ".ActiveConnections"
)
View Source
const (
	SettingsInterface  = NetworkManagerInterface + ".Settings"
	SettingsObjectPath = NetworkManagerObjectPath + "/Settings"

	SettingsListConnections = SettingsInterface + ".ListConnections"
	SettingsAddConnection   = SettingsInterface + ".AddConnection"
)
View Source
const (
	WirelessDeviceInterface = DeviceInterface + ".Wireless"

	WirelessDeviceGetAccessPoints = WirelessDeviceInterface + ".GetAccessPoints"
	WirelessDeviceRequestScan     = WirelessDeviceInterface + ".RequestScan"
)

Variables

This section is empty.

Functions

This section is empty.

Types

type AccessPoint

type AccessPoint interface {
	GetPath() dbus.ObjectPath

	// GetFlags gets flags describing the capabilities of the access point.
	GetFlags() uint32

	// GetWPAFlags gets flags describing the access point's capabilities
	// according to WPA (Wifi Protected Access).
	GetWPAFlags() uint32

	// GetRSNFlags gets flags describing the access point's capabilities
	// according to the RSN (Robust Secure Network) protocol.
	GetRSNFlags() uint32

	// GetSSID returns the Service Set Identifier identifying the access point.
	GetSSID() string

	// GetFrequency gets the radio channel frequency in use by the access point,
	// in MHz.
	GetFrequency() uint32

	// GetHWAddress gets the hardware address (BSSID) of the access point.
	GetHWAddress() string

	// GetMode describes the operating mode of the access point.
	GetMode() Nm80211Mode

	// GetMaxBitrate gets the maximum bitrate this access point is capable of, in
	// kilobits/second (Kb/s).
	GetMaxBitrate() uint32

	// GetStrength gets the current signal quality of the access point, in
	// percent.
	GetStrength() uint8

	MarshalJSON() ([]byte, error)
}

func NewAccessPoint

func NewAccessPoint(objectPath dbus.ObjectPath) (AccessPoint, error)

type ActiveConnection

type ActiveConnection interface {
	// GetConnection gets connection object of the connection.
	GetConnection() Connection

	// GetSpecificObject gets a specific object associated with the active connection.
	GetSpecificObject() AccessPoint

	// GetID gets the ID of the connection.
	GetID() string

	// GetUUID gets the UUID of the connection.
	GetUUID() string

	// GetType gets the type of the connection.
	GetType() string

	// GetDevices gets array of device objects which are part of this active connection.
	GetDevices() []Device

	// GetState gets the state of the connection.
	GetState() uint32

	// GetStateFlags gets the state flags of the connection.
	GetStateFlags() uint32

	// GetDefault gets the default IPv4 flag of the connection.
	GetDefault() bool

	// GetIP4Config gets the IP4Config of the connection.
	GetIP4Config() IP4Config

	// GetDHCP4Config gets the DHCP4Config of the connection.
	GetDHCP4Config() DHCP4Config

	// GetVPN gets the VPN flag of the connection.
	GetVPN() bool

	// GetMaster gets the master device of the connection.
	GetMaster() Device
}

func NewActiveConnection

func NewActiveConnection(objectPath dbus.ObjectPath) (ActiveConnection, error)

type Connection

type Connection interface {
	GetPath() dbus.ObjectPath

	// GetSettings gets the settings maps describing this network configuration.
	// This will never include any secrets required for connection to the
	// network, as those are often protected. Secrets must be requested
	// separately using the GetSecrets() call.
	GetSettings() ConnectionSettings
	Delete()

	MarshalJSON() ([]byte, error)
}

func NewConnection

func NewConnection(objectPath dbus.ObjectPath) (Connection, error)

type ConnectionSettings

type ConnectionSettings map[string]map[string]interface{}

type ConnectionSettings map[string]map[string]interface{}

type DHCP4Config

type DHCP4Config interface {
	// GetOptions gets options map of configuration returned by the IPv4 DHCP server.
	GetOptions() DHCP4Options

	MarshalJSON() ([]byte, error)
}

func NewDHCP4Config

func NewDHCP4Config(objectPath dbus.ObjectPath) (DHCP4Config, error)

type DHCP4Options

type DHCP4Options map[string]interface{}

type Device

type Device interface {
	GetPath() dbus.ObjectPath

	// GetInterface gets the name of the device's control (and often data)
	// interface.
	GetInterface() string

	// GetIpInterface gets the IP interface name of the device.
	GetIpInterface() string

	// GetState gets the current state of the device.
	GetState() NmDeviceState

	// GetIP4Config gets the Ip4Config object describing the configuration of the
	// device. Only valid when the device is in the NM_DEVICE_STATE_ACTIVATED
	// state.
	GetIP4Config() IP4Config

	// GetDHCP4Config gets the Dhcp4Config object describing the configuration of the
	// device. Only valid when the device is in the NM_DEVICE_STATE_ACTIVATED
	// state.
	GetDHCP4Config() DHCP4Config

	// GetDeviceType gets the general type of the network device; ie Ethernet,
	// WiFi, etc.
	GetDeviceType() NmDeviceType

	// GetAvailableConnections gets an array of object paths of every configured
	// connection that is currently 'available' through this device.
	GetAvailableConnections() []Connection

	MarshalJSON() ([]byte, error)
}

func DeviceFactory

func DeviceFactory(objectPath dbus.ObjectPath) (Device, error)

func NewDevice

func NewDevice(objectPath dbus.ObjectPath) (Device, error)

type IP4Address

type IP4Address struct {
	Address string
	Prefix  uint8
	Gateway string
}

type IP4Config

type IP4Config interface {
	// GetAddresses gets an array of tuples of IPv4 address/prefix/gateway. All 3
	// elements of each tuple are in network byte order. Essentially: [(addr,
	// prefix, gateway), (addr, prefix, gateway), ...]
	GetAddresses() []IP4Address

	// GetRoutes gets tuples 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), ...]
	GetRoutes() []IP4Route

	// GetNameservers gets the nameservers in use.
	GetNameservers() []string

	// GetDomains gets a list of domains this address belongs to.
	GetDomains() []string

	MarshalJSON() ([]byte, error)
}

func NewIP4Config

func NewIP4Config(objectPath dbus.ObjectPath) (IP4Config, error)

type IP4Route

type IP4Route struct {
	Route   string
	Prefix  uint8
	NextHop string
	Metric  uint8
}

type NetworkManager

type NetworkManager interface {

	// GetDevices gets the list of network devices.
	GetDevices() []Device

	// GetState returns the overall networking state as determined by the
	// NetworkManager daemon, based on the state of network devices under it's
	// management.
	GetState() NmState

	// GetActiveConnections returns the active connection of network devices.
	GetActiveConnections() []ActiveConnection

	// ActivateWirelessConnection requests activating access point to network device
	ActivateWirelessConnection(connection Connection, device Device, accessPoint AccessPoint) ActiveConnection
	ActivateWiredConnection(connection Connection, device Device) ActiveConnection

	Subscribe() <-chan *dbus.Signal
	Unsubscribe()

	MarshalJSON() ([]byte, error)
}

func NewNetworkManager

func NewNetworkManager() (NetworkManager, error)

type Nm80211APFlags

type Nm80211APFlags uint32
const (
	Nm80211APFlagsNone    Nm80211APFlags = 0x0
	Nm80211APFlagsPrivacy Nm80211APFlags = 0x1
)

func (Nm80211APFlags) String

func (i Nm80211APFlags) String() string

type Nm80211APSec

type Nm80211APSec uint32
const (
	Nm80211APSecNone         Nm80211APSec = 0x0
	Nm80211APSecPairWEP40    Nm80211APSec = 0x1
	Nm80211APSecPairWEP104   Nm80211APSec = 0x2
	Nm80211APSecPairTKIP     Nm80211APSec = 0x4
	Nm80211APSecPairCCMP     Nm80211APSec = 0x8
	Nm80211APSecGroupWEP40   Nm80211APSec = 0x10
	Nm80211APSecGroupWEP104  Nm80211APSec = 0x20
	Nm80211APSecGroupTKIP    Nm80211APSec = 0x40
	Nm80211APSecGroupCCMP    Nm80211APSec = 0x80
	Nm80211APSecKeyMgmtPSK   Nm80211APSec = 0x100
	Nm80211APSecKeyMgmt8021X Nm80211APSec = 0x200
)

func (Nm80211APSec) String

func (i Nm80211APSec) String() string

type Nm80211Mode

type Nm80211Mode uint32
const (
	Nm80211ModeUnknown Nm80211Mode = 0
	Nm80211ModeAdhoc   Nm80211Mode = 1
	Nm80211ModeInfra   Nm80211Mode = 2
	Nm80211ModeAp      Nm80211Mode = 3
)

func (Nm80211Mode) String

func (i Nm80211Mode) String() string

type NmConnectivity

type NmConnectivity uint32
const (
	NmConnectivityUnknown NmConnectivity = 0
	NmConnectivityNone    NmConnectivity = 1
	NmConnectivityPortal  NmConnectivity = 2
	NmConnectivityLimited NmConnectivity = 3
	NmConnectivityFull    NmConnectivity = 4
)

func (NmConnectivity) String

func (i NmConnectivity) String() string

type NmDeviceState

type NmDeviceState uint32
const (
	NmDeviceStateUnknown      NmDeviceState = 0
	NmDeviceStateUnmanaged    NmDeviceState = 10
	NmDeviceStateUnavailable  NmDeviceState = 20
	NmDeviceStateDisconnected NmDeviceState = 30
	NmDeviceStatePrepare      NmDeviceState = 40
	NmDeviceStateConfig       NmDeviceState = 50
	NmDeviceStateNeed_auth    NmDeviceState = 60
	NmDeviceStateIp_config    NmDeviceState = 70
	NmDeviceStateIp_check     NmDeviceState = 80
	NmDeviceStateSecondaries  NmDeviceState = 90
	NmDeviceStateActivated    NmDeviceState = 100
	NmDeviceStateDeactivating NmDeviceState = 110
	NmDeviceStateFailed       NmDeviceState = 120
)

func (NmDeviceState) String

func (i NmDeviceState) String() string

type NmDeviceType

type NmDeviceType uint32
const (
	NmDeviceTypeUnknown    NmDeviceType = 0
	NmDeviceTypeEthernet   NmDeviceType = 1
	NmDeviceTypeWifi       NmDeviceType = 2
	NmDeviceTypeUnused1    NmDeviceType = 3
	NmDeviceTypeUnused2    NmDeviceType = 4
	NmDeviceTypeBt         NmDeviceType = 5
	NmDeviceTypeOlpcMesh   NmDeviceType = 6
	NmDeviceTypeWimax      NmDeviceType = 7
	NmDeviceTypeModem      NmDeviceType = 8
	NmDeviceTypeInfiniband NmDeviceType = 9
	NmDeviceTypeBond       NmDeviceType = 10
	NmDeviceTypeVlan       NmDeviceType = 11
	NmDeviceTypeAdsl       NmDeviceType = 12
	NmDeviceTypeBridge     NmDeviceType = 13
	NmDeviceTypeGeneric    NmDeviceType = 14
	NmDeviceTypeTeam       NmDeviceType = 15
)

func (NmDeviceType) String

func (i NmDeviceType) String() string

type NmState

type NmState uint32
const (
	NmStateUnknown         NmState = 0
	NmStateAsleep          NmState = 10
	NmStateDisconnected    NmState = 20
	NmStateDisconnecting   NmState = 30
	NmStateConnecting      NmState = 40
	NmStateConnectedLocal  NmState = 50
	NmStateConnectedSite   NmState = 60
	NmStateConnectedGlobal NmState = 70
)

func (NmState) String

func (i NmState) String() string

type Settings

type Settings interface {

	// ListConnections gets list the saved network connections known to NetworkManager
	ListConnections() []Connection

	// AddConnection call new connection and save it to disk.
	AddConnection(settings ConnectionSettings) Connection
}

func NewSettings

func NewSettings() (Settings, error)

type WirelessDevice

type WirelessDevice interface {
	Device

	// GetAccessPoints gets the list of access points visible to this device.
	// Note that this list does not include access points which hide their SSID.
	// To retrieve a list of all access points (including hidden ones) use the
	// GetAllAccessPoints() method.
	GetAccessPoints() []AccessPoint

	RequestScan()
}

func NewWirelessDevice

func NewWirelessDevice(objectPath dbus.ObjectPath) (WirelessDevice, error)

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL