Pages
API Documentation
On this page

NetworkManager Namespace

Qt wrapper for NetworkManager API. More...

  • Header: #include <NetworkManager>
  • CMake: find_package(KF6 REQUIRED COMPONENTS NetworkManagerQt)
    target_link_libraries(mytarget PRIVATE KF6::NetworkManagerQt)

Detailed Description

This class allows querying the underlying system to discover the available network interfaces and reachable networks. It has also the responsibility to notify when a network interface appears or disappears.

It is the unique entry point for network management. Applications should use it to find network interfaces, or to be notified about network related changes.

Note that it is implemented as a singleton

Classes

class AccessPoint

Represents an access point.

class ActiveConnection

An active connection.

class AdslDevice

An adsl device interface.

class AdslSetting

Represents adsl setting.

class BluetoothDevice

A bluetooth device interface.

class BluetoothSetting

Represents bluetooth setting.

class BondDevice

A bond device interface.

class BondSetting

Represents bond setting.

class BridgeDevice

A bridge device interface.

class BridgePortSetting

Represents bridge port setting.

class BridgeSetting

Represents bridge setting.

class CdmaSetting

Represents cdma setting.

class Connection

This class represents a single network connection configuration.

class ConnectionSettings

Represents collection of all connection settings.

class DcbSetting

Represents Dcb setting.

class Device

This class represents a common device interface.

class DeviceStateReason

class DeviceStatistics

Represents device statistics interface.

class Dhcp4Config

This class represents dhcp4 configuration.

class Dhcp6Config

This class represents dhcp4 configuration.

class DnsConfiguration

This class represents IP configuration.

class DnsDomain

This class represents the configuration for a DNS domain.

class GenericDevice

A generic device interface.

class GenericSetting

Represents generic setting.

class GsmSetting

Represents gsm setting.

class InfinibandDevice

An infiniband device interface.

class InfinibandSetting

Represents infiniband setting.

class IpAddress

This class represents IP address.

class IpConfig

This class represents IP configuration.

class IpRoute

This class represents IP route.

class IpTunnelDevice

A Ip Tunnel device interface.

class IpTunnelSetting

Represents IpTunnel setting.

class Ipv4Setting

Represents ipv4 setting.

class Ipv6Setting

Represents ipv6 setting.

class MacVlanDevice

A macvlan device interface.

class MacsecSetting

Represents Macsec setting.

class MatchSetting

Represents Match setting.

class ModemDevice

Represents a generic modem device, generally defined by the modemCapabilities() it exposes and at the current point in time by the currentCapabilities().

class Notifier

class OlpcMeshDevice

A OLPC mesh interface.

class OlpcMeshSetting

Represents olpc mesh setting.

class OvsBridgeSetting

Represents ovs-bridge setting.

class OvsInterfaceSetting

Represents ovs-interface setting.

class OvsPatchSetting

Represents OvsPatch setting.

class OvsPortSetting

Represents o setting.

class PppSetting

Represents ppp setting.

class PppoeSetting

Represents pppoe setting.

class ProxySetting

Represents proxy setting.

class SecretAgent

Implementation of a private D-Bus interface used by secret agents that store and provide secrets to NetworkManager.

class Security8021xSetting

Represents 802.1x wireless security setting.

class SerialSetting

Represents serial setting.

class Setting

Base class for all kinds of setting.

class SettingsNotifier

This class manages provides access to connections and notify about new ones.

class TcSetting

Represents Tc setting.

class TeamDevice

A team device interface.

class TeamPortSetting

Represents TeamPort setting.

class TeamSetting

Represents team setting.

class TemplateSetting

Represents generic setting.

class TunDevice

A tun device interface.

class TunSetting

Represents generic setting.

class UserSetting

Represents user setting.

class VethDevice

A veth device interface.

class VlanDevice

A vlan device interface.

class VlanSetting

Represents vlan setting.

class VpnConnection

An active VPN connection.

class VpnPlugin

class VpnSetting

Represents vpn setting.

class VxlanSetting

Represents vxlan setting.

class WifiP2PDevice

WiFi P2P device.

class WifiP2PPeer

Represents a wifip2p peer.

class WifiP2PSetting

Represents wifip2p setting.

class WimaxDevice

Wimax network interface.

class WimaxNsp

Wimax network service provider (access point).

class WimaxSetting

Represents wimax setting.

class WireGuardDevice

A WireGuard device interface.

class WireGuardSetting

Represents generic setting.

class WiredDevice

A wired device interface.

class WiredSetting

Represents wired setting.

class WirelessDevice

A wireless network interface.

class WirelessNetwork

This class represents a wireless network, which aggregates all access points with the same SSID.

class WirelessSecuritySetting

Represents wireless security setting.

class WirelessSetting

Represents wireless setting.

Type Documentation

enum NetworkManager::Connectivity

Describes the network connectivity state.

Constant Value Description
NetworkManager::UnknownConnectivity 0 Network connectivity is unknown.
NetworkManager::NoConnectivity 1 The host is not connected to any network.
NetworkManager::Portal 2 The host is behind a captive portal and cannot reach the full Internet.
NetworkManager::Limited 3 The host is connected to a network, but does not appear to be able to reach the full Internet.
NetworkManager::Full 4 The host is connected to a network, and appears to be able to reach the full Internet.

NetworkManager::IpAddresses

NetworkManager::IpRoutes

enum NetworkManager::LogDomain

flags NetworkManager::LogDomains

Constant Value
NetworkManager::NoChange 0
NetworkManager::None 1
NetworkManager::Hardware 2
NetworkManager::RFKill 3
NetworkManager::Ethernet 4
NetworkManager::WiFi 5
NetworkManager::Bluetooth 6
NetworkManager::MobileBroadBand 7
NetworkManager::DHCP4 8
NetworkManager::DHCP6 9
NetworkManager::PPP 10
NetworkManager::WiFiScan 11
NetworkManager::IPv4 12
NetworkManager::IPv6 13
NetworkManager::AutoIPv4 14
NetworkManager::DNS 15
NetworkManager::VPN 16
NetworkManager::Sharing 17
NetworkManager::Supplicant 18
NetworkManager::UserSet 19
NetworkManager::SysSet 20
NetworkManager::Suspend 21
NetworkManager::Core 22
NetworkManager::Devices 23
NetworkManager::OLPC 24
NetworkManager::Wimax 25 TODO: mark it deprecated somehow?
NetworkManager::Infiniband 26
NetworkManager::Firewall 27
NetworkManager::Adsl 28
NetworkManager::Bond 29
NetworkManager::Vlan 30
NetworkManager::Agents 31
NetworkManager::Settings 32
NetworkManager::Bridge 33
NetworkManager::DbusProps 34
NetworkManager::Team 35
NetworkManager::ConCheck 36
NetworkManager::Dcb 37
NetworkManager::Dispatch 38

The LogDomains type is a typedef for QFlags<LogDomain>. It stores an OR combination of LogDomain values.

enum NetworkManager::LogLevel

Constant Value
NetworkManager::Error 0
NetworkManager::Warning 1
NetworkManager::Info 2
NetworkManager::Debug 3
NetworkManager::Trace 4 = Debug in runtime NM < 0.9.10

enum NetworkManager::Status

Possible device interfaceflags

Constant Value Description
NetworkManager::Unknown 0 the networking system is not active or unable to report its status - proceed with caution
NetworkManager::Asleep 1 networking is inactive and all devices are disabled
NetworkManager::Disconnected 2 the system is not connected to any network
NetworkManager::Disconnecting 3 the system is breaking the connection
NetworkManager::Connecting 4 the system is not connected to any network
NetworkManager::ConnectedLinkLocal 5 a network device is connected, but there is only link-local connectivity
NetworkManager::ConnectedSiteOnly 6 a network device is connected, but there is only site-local connectivity
NetworkManager::Connected 7 the system is currently connected to a network

enum NetworkManager::WirelessSecurityType

Capabilities to pass to secret agents

Constant
NetworkManager::UnknownSecurity -1
NetworkManager::NoneSecurity 0
NetworkManager::StaticWep 1
NetworkManager::DynamicWep 2
NetworkManager::Leap 3
NetworkManager::WpaPsk 4
NetworkManager::WpaEap 5
NetworkManager::Wpa2Psk 6
NetworkManager::Wpa2Eap 7
NetworkManager::SAE 8
NetworkManager::Wpa3SuiteB192 9
NetworkManager::OWE 10

Function Documentation

QDBusPendingReply<QDBusObjectPath> NetworkManager::activateConnection(const QString &connectionUni, const QString &interfaceUni, const QString &connectionParameter)

Activate a connection using the supplied device.

connectionUni unique identifier for the connection to be activated interfaceUni unique identifier of the network interface to be activated connectionParameter can be used to specify extra parameters not specific to the NetworkInterface or the connection, eg which AP to use when several present with same ESSID in range (because ESSID does not guarantee that the AP is part of the network you want to join!)

ActiveConnection::Ptr NetworkManager::activatingConnection()

Returns an active connection that is currently being activated and which is expected to become the new primaryConnection() when it finishes activating.

ActiveConnection::List NetworkManager::activeConnections()

Access the list of any active connections

Returns a list of valid ActiveConnection objects

QStringList NetworkManager::activeConnectionsPaths()

Access the list of any active connections paths

Returns a list of valid ActiveConnection paths

QDBusPendingReply<QDBusObjectPath, QDBusObjectPath, QVariantMap> NetworkManager::addAndActivateConnection2(const NMVariantMapMap &connection, const QString &interfaceUni, const QString &connectionParameter, const QVariantMap &options)

* Adds a new connection using the given details (if any) as a template (automatically filling in missing settings with the capabilities of the given device and * specific object), then activate the new connection. Cannot be used for VPN connections at this time. * * connection connection definition to be added and activated * interfaceUni unique identifier of the network interface to be activated * connectionParameter can be used to specify extra parameters not specific to the NetworkInterface or the connection, eg which AP to use when several * present with same ESSID in range (because ESSID does not guarantee that the AP is part of the network you want to join!) * options further options for the method call. * * This method extends AddAndActivateConnection to allow passing further * parameters. At this time the following options are supported: * * * persist: A string value of either "disk" (default), "memory" or "volatile". If "memory" is passed, the connection will not be saved to disk. If * "volatile" is passed, the connection will not be saved to disk and will be destroyed when disconnected. * * bind-activation: Bind the activation lifetime. Set to "dbus-name" to automatically disconnect when the requesting process disappears from the bus. * The default of "none" means the connection is kept activated normally. * * ote will call AddAndActivateConnection(connection, interfaceUni, connectionParameter) instead when NetworkManager is older than 1.16, which means that the * options property is ignored

QDBusPendingReply<QDBusObjectPath, QDBusObjectPath> NetworkManager::addAndActivateConnection(const NMVariantMapMap &connection, const QString &interfaceUni, const QString &connectionParameter)

Adds a new connection using the given details (if any) as a template (automatically filling in missing settings with the capabilities of the given device and specific object), then activate the new connection. Cannot be used for VPN connections at this time.

connection connection definition to be added and activated interfaceUni unique identifier of the network interface to be activated connectionParameter can be used to specify extra parameters not specific to the NetworkInterface or the connection, eg which AP to use when several present with same ESSID in range (because ESSID does not guarantee that the AP is part of the network you want to join!)

QDBusPendingReply<QDBusObjectPath> NetworkManager::addConnection(const NMVariantMapMap &settings)

Add new connection and save it to disk. This operation does not start the network connection unless (1) device is idle and able to connect to the network described by the new connection, and (2) the connection is allowed to be started automatically. Once the connection has been added, you will get a notification through SettingsNotifier::connectionAddComplete()

Returns Uuid of the new connection that was just added.

QDBusPendingReply<QDBusObjectPath> NetworkManager::addConnectionUnsaved(const NMVariantMapMap &settings)

Add new connection but do not save it to disk immediately. This operation does not start the network connection unless (1) device is idle and able to connect to the network described by the new connection, and (2) the connection is allowed to be started automatically.

Use the 'Save' method on the connection to save these changes to disk. Note that unsaved changes will be lost if the connection is reloaded from disk (either automatically on file change or due to an explicit ReloadConnections call).

Once the connection has been added, you will get a notification through SettingsNotifier::connectionAddComplete()

Returns Uuid of the new connection that was just added.

bool NetworkManager::canModify()

Returns true if the user can modify the settings

QDBusPendingReply<uint> NetworkManager::checkConnectivity()

Re-check the network connectivity state.

See also connectivity()

bool NetworkManager::checkVersion(const int x, const int y, const int z)

Checks if NetworkManager version is at least x.y.z Returns true if NetworkManager's version is greater or equal, false otherwise

QDateTime NetworkManager::clockBootTimeToDateTime(qlonglong clockBootime)

int NetworkManager::compareVersion(const QString &version)

Compares NetworkManager's version to the parameter version. returns 1, -1 or 0 if NetworkManager's version is greater, less or equal to parameter.

int NetworkManager::compareVersion(const int x, const int y, const int z)

Compares NetworkManager version to x.y.z. returns 1, -1 or 0 if NetworkManager's version is greater, less or equal to x.y.z.

NetworkManager::Connectivity NetworkManager::connectivity()

Returns the network connectivity state

[since 6.10.0] QString NetworkManager::connectivityCheckUri()

Returns the URI used for connectivity check

This function was introduced in Qt 6.10.0.

QDBusPendingReply<> NetworkManager::deactivateConnection(const QString &activeConnection)

Deactivate this network interface, if active

activeConnection identifier of the connection to deactivate

bool NetworkManager::deviceSupportsApCiphers(NetworkManager::WirelessDevice::Capabilities, NetworkManager::AccessPoint::WpaFlags ciphers, NetworkManager::WirelessSecurityType type)

ActiveConnection::Ptr NetworkManager::findActiveConnection(const QString &uni)

Find an ActiveConnection object for an active connection id

uni the id of the ActiveConnection Returns a valid ActiveConnection object

NetworkManager::WirelessSecurityType NetworkManager::findBestWirelessSecurity(NetworkManager::WirelessDevice::Capabilities, bool haveAp, bool adHoc, NetworkManager::AccessPoint::Capabilities apCaps, NetworkManager::AccessPoint::WpaFlags apWpa, NetworkManager::AccessPoint::WpaFlags apRsn)

int NetworkManager::findChannel(int freq)

freq frequency of a wireless network

Returns The frequency channel.

NetworkManager::Connection::Ptr NetworkManager::findConnection(const QString &path)

Retrieves the connection for the given path, returns null if not found

NetworkManager::Connection::Ptr NetworkManager::findConnectionByUuid(const QString &uuid)

Retrieves the connection for the given uuid, returns null if not found

Device::Ptr NetworkManager::findDeviceByIpFace(const QString &iface)

Return the network device referenced by its IP interface name. This is not system independent so programs that will use this method will not be portable.

NetworkManager::WirelessSetting::FrequencyBand NetworkManager::findFrequencyBand(int freq)

Device::Ptr NetworkManager::findNetworkInterface(const QString &uni)

Find a new NetworkInterface object given its UNI. This pointer is owned by the Solid infrastructure.

uni the identifier of the network interface to find Returns a valid NetworkInterface object if there's a device having the given UNI, an invalid one otherwise

QList<QPair<int, int>> NetworkManager::getAFreqs()

QList<QPair<int, int>> NetworkManager::getBFreqs()

QDBusPendingReply<QString, QString> NetworkManager::getLogging()

Get current logging verbosity level and operations domains

NetworkManager::DnsConfiguration NetworkManager::globalDnsConfiguration()

Returns Gets the global DNS configuration.

See also setGlobalDnsConfiguration()

QString NetworkManager::hostname()

Returns hostname of the machine

QHostAddress NetworkManager::ipv6AddressAsHostAddress(const QByteArray &address)

Returns QHostAddress representation of an ipv6 address

address byte array containing the binary representation of the address

QByteArray NetworkManager::ipv6AddressFromHostAddress(const QHostAddress &address)

Returns binary representation of an ipv6 address

address qhostaddress containing the address

[since 6.10.0] bool NetworkManager::isConnectivityCheckAvailable()

Returns whether the connectivity check is available

This function was introduced in Qt 6.10.0.

[since 6.10.0] bool NetworkManager::isConnectivityCheckEnabled()

Returns whether the connectivity check is enabled

This function was introduced in Qt 6.10.0.

bool NetworkManager::isNetworkingEnabled()

Retrieves the status of networking (as a whole) in the system. This is distinct from whether the system's networking is online or offline. To check that, see status().

Returns true if this networking is enabled, false otherwise

bool NetworkManager::isStartingUp()

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.

bool NetworkManager::isWirelessEnabled()

Retrieves the activation status of wireless networking in the system.

Returns true if this wireless networking is enabled, false otherwise

bool NetworkManager::isWirelessHardwareEnabled()

Retrieves the status of wireless hardware in the system. This is typically controlled by a physical switch so there is no way to set this in software.

Returns true if this wireless networking is enabled, false otherwise

bool NetworkManager::isWwanEnabled()

Retrieves the status of wireless broadband (Wireless WAN) in the system.

Returns true if this type of wireless networking is enabled, false otherwise

bool NetworkManager::isWwanHardwareEnabled()

Retrieves the status of wireless broadband (Wireless WAN) hardware in the system. This is typically controlled by a physical switch so there is no way to set this in software.

Returns true if this broddband hardware is enabled, false otherwise

NetworkManager::Connection::List NetworkManager::listConnections()

Retrieves the list of connections.

QDBusPendingReply<bool, QStringList> NetworkManager::loadConnections(const QStringList &filenames)

Loads or reloads the indicated connections from disk. You should call this after making changes directly to an on-disk connection file to make sure that NetworkManager sees the changes. (If "monitor-connection-files" in NetworkManager.conf is "true", then this will have no real effect, but is harmless.) As with AddConnection(), this operation does not necessarily start the network connection.

Returns Success or failure of the operation as a whole. True if NetworkManager at least tried to load the indicated connections, even if it did not succeed. False if an error occurred before trying to load the connections (eg, permission denied).

Returns Paths of connection files that could not be loaded.

QString NetworkManager::macAddressAsString(const QByteArray &ba)

Returns String representation of a mac address.

ba byte array containing the binary repesentation of the address

QByteArray NetworkManager::macAddressFromString(const QString &s)

Returns binary repesentation of a mac address.

s string representation of the address

bool NetworkManager::macAddressIsValid(const QByteArray &macAddress)

bool NetworkManager::macAddressIsValid(const QString &macAddress)

NetworkManager::Device::MeteredStatus NetworkManager::metered()

Returns Indicates whether the connectivity is metered.

Device::List NetworkManager::networkInterfaces()

Retrieves the list of all the network interfaces in the system. It includes both hardware and virtual devices.

Returns the list of network interfaces available in this system

NetworkManager::Notifier *NetworkManager::notifier()

NMStringMap NetworkManager::permissions()

ActiveConnection::Ptr NetworkManager::primaryConnection()

Returns 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.

NetworkManager::ConnectionSettings::ConnectionType NetworkManager::primaryConnectionType()

Returns 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.

QDBusPendingReply<bool> NetworkManager::reloadConnections()

Tells NetworkManager to reload all connection files from disk, including noticing any added or deleted connection files. By default, connections are re-read automatically any time they change, so you only need to use this command if you have set "monitor-connection-files=false" in NetworkManager.conf.

Returns Success or failure.

void NetworkManager::saveHostname(const QString &hostname)

Configure the following hostname

bool NetworkManager::securityIsValid(NetworkManager::WirelessSecurityType type, NetworkManager::WirelessDevice::Capabilities interfaceCaps, bool haveAp, bool adHoc, NetworkManager::AccessPoint::Capabilities apCaps, NetworkManager::AccessPoint::WpaFlags apWpa, NetworkManager::AccessPoint::WpaFlags apRsn)

NetworkManager::WirelessSecurityType NetworkManager::securityTypeFromConnectionSetting(const NetworkManager::ConnectionSettings::Ptr &settings)

void NetworkManager::setGlobalDnsConfiguration(const NetworkManager::DnsConfiguration &configuration)

Returns Sets the global DNS configuration.

See also globalDnsConfiguration()

void NetworkManager::setLogging(NetworkManager::LogLevel, NetworkManager::LogDomains)

void NetworkManager::setNetworkingEnabled(bool enabled)

See also isNetworkingEnabled()

void NetworkManager::setWirelessEnabled(bool enabled)

See also isWirelessEnabled()

void NetworkManager::setWwanEnabled(bool enabled)

See also isWwanEnabled()

NetworkManager::SettingsNotifier *NetworkManager::settingsNotifier()

Notifier object for connecting signals

void NetworkManager::sleep(bool sleep)

NetworkManager::Status NetworkManager::status()

Get the manager connection state

Device::Types NetworkManager::supportedInterfaceTypes()

Retrieves the interface types supported by this network manager.

Returns the interface types supported by the network manager

QString NetworkManager::version()

Get the NetworkManager version

bool NetworkManager::wepKeyIsValid(const QString &key, NetworkManager::WirelessSecuritySetting::WepKeyType type)

bool NetworkManager::wpaPskIsValid(const QString &psk)

We use cookies to personalize content and to analyze our traffic. Please decide if you are willing to accept cookies from our website.