summaryrefslogtreecommitdiffstats
path: root/tdecore/tdehw/networkbackends
diff options
context:
space:
mode:
authorSlávek Banko <slavek.banko@axis.cz>2017-06-17 12:57:10 +0200
committerSlávek Banko <slavek.banko@axis.cz>2017-06-17 12:57:10 +0200
commite0fd34a1bd2c6412171bcceb19520d129bbcb66d (patch)
tree2043092f6f3f3c8075ea802f9e6ba1b1d543f59c /tdecore/tdehw/networkbackends
parenteb6f8213d42aac2911c7b8880628c786b0223935 (diff)
downloadtdelibs-e0fd34a1bd2c6412171bcceb19520d129bbcb66d.tar.gz
tdelibs-e0fd34a1bd2c6412171bcceb19520d129bbcb66d.zip
tdehwlib: Use TDENetworkDevice in TDENetworkConnectionManager instead of MAC address
Use interface name in TDENetworkConnectionManager_BackendNM instead of MAC address This relates to bug 2748 The name of the network interface seems to be a more stable identifier than the MAC address because the MAC address can be changed easily or even automatically - see randomization of MAC addresses on wireless interfaces. Therefore, the use of the MAC address as a network interface identifier was abandoned. Beware, this change is an API / ABI change! However, most changes are internal and the only one affected is application TDENetworkManager. Signed-off-by: Slávek Banko <slavek.banko@axis.cz>
Diffstat (limited to 'tdecore/tdehw/networkbackends')
-rw-r--r--tdecore/tdehw/networkbackends/network-manager/network-manager.cpp157
-rw-r--r--tdecore/tdehw/networkbackends/network-manager/network-manager.h4
2 files changed, 22 insertions, 139 deletions
diff --git a/tdecore/tdehw/networkbackends/network-manager/network-manager.cpp b/tdecore/tdehw/networkbackends/network-manager/network-manager.cpp
index 2a0354105..2f11dd59b 100644
--- a/tdecore/tdehw/networkbackends/network-manager/network-manager.cpp
+++ b/tdecore/tdehw/networkbackends/network-manager/network-manager.cpp
@@ -1137,7 +1137,7 @@ TQString tdeIBTransportToNMIBTransport(TDENetworkInfinibandTransportMode::TDENet
return ret;
}
-TQString TDENetworkConnectionManager_BackendNM::deviceInterfaceString(TQString macAddress) {
+TQString TDENetworkConnectionManager_BackendNM::deviceInterfaceString(TQString deviceNode) {
if (d->m_networkManagerProxy) {
TQT_DBusObjectPathList devices;
TQT_DBusError error;
@@ -1148,74 +1148,15 @@ TQString TDENetworkConnectionManager_BackendNM::deviceInterfaceString(TQString m
for (it = devices.begin(); it != devices.end(); ++it) {
DBus::DeviceProxy genericDevice(NM_DBUS_SERVICE, (*it));
genericDevice.setConnection(TQT_DBusConnection::systemBus());
- TDENetworkDeviceType::TDENetworkDeviceType deviceType = nmDeviceTypeToTDEDeviceType(genericDevice.getDeviceType(error));
+ TQString deviceInterface = genericDevice.getInterface(error);
if (error.isValid()) {
// Error!
PRINT_ERROR((error.name() + ": " + error.message()))
break;
}
- else if (deviceType == TDENetworkDeviceType::WiredEthernet) {
- DBus::EthernetDeviceProxy ethernetDevice(NM_DBUS_SERVICE, (*it));
- ethernetDevice.setConnection(TQT_DBusConnection::systemBus());
- TQString candidateMACAddress = ethernetDevice.getPermHwAddress(error);
- if (!error.isValid()) {
- if (candidateMACAddress.lower() == macAddress.lower()) {
- return (*it);
- }
- }
- }
- else if (deviceType == TDENetworkDeviceType::Infiniband) {
- DBus::InfinibandDeviceProxy infinibandDevice(NM_DBUS_SERVICE, (*it));
- infinibandDevice.setConnection(TQT_DBusConnection::systemBus());
- TQString candidateMACAddress = infinibandDevice.getHwAddress(error);
- if (!error.isValid()) {
- if (candidateMACAddress.lower() == macAddress.lower()) {
- return (*it);
- }
- }
- }
- else if (deviceType == TDENetworkDeviceType::WiFi) {
- DBus::WiFiDeviceProxy wiFiDevice(NM_DBUS_SERVICE, (*it));
- wiFiDevice.setConnection(TQT_DBusConnection::systemBus());
- TQString candidateMACAddress = wiFiDevice.getPermHwAddress(error);
- if (!error.isValid()) {
- if (candidateMACAddress.lower() == macAddress.lower()) {
- return (*it);
- }
- }
- }
- else if (deviceType == TDENetworkDeviceType::WiMax) {
- DBus::WiMaxDeviceProxy wiMaxDevice(NM_DBUS_SERVICE, (*it));
- wiMaxDevice.setConnection(TQT_DBusConnection::systemBus());
- TQString candidateMACAddress = wiMaxDevice.getHwAddress(error);
- if (!error.isValid()) {
- if (candidateMACAddress.lower() == macAddress.lower()) {
- return (*it);
- }
- }
+ else if (deviceInterface == deviceNode) {
+ return (*it);
}
- else if (deviceType == TDENetworkDeviceType::OLPCMesh) {
- DBus::OlpcMeshDeviceProxy olpcMeshDevice(NM_DBUS_SERVICE, (*it));
- olpcMeshDevice.setConnection(TQT_DBusConnection::systemBus());
- TQString candidateMACAddress = olpcMeshDevice.getHwAddress(error);
- if (!error.isValid()) {
- if (candidateMACAddress.lower() == macAddress.lower()) {
- return (*it);
- }
- }
- }
- else if (deviceType == TDENetworkDeviceType::Bluetooth) {
- DBus::BluetoothDeviceProxy bluetoothDevice(NM_DBUS_SERVICE, (*it));
- bluetoothDevice.setConnection(TQT_DBusConnection::systemBus());
- TQString candidateMACAddress = bluetoothDevice.getHwAddress(error);
- if (!error.isValid()) {
- if (candidateMACAddress.lower() == macAddress.lower()) {
- return (*it);
- }
- }
- }
- // FIXME
- // Add other supported device types here
}
return "";
}
@@ -1230,72 +1171,15 @@ TQString TDENetworkConnectionManager_BackendNM::deviceInterfaceString(TQString m
}
}
-TQString macAddressForGenericDevice(TQT_DBusObjectPath path) {
+TQString tdeDeviceUUIDForGenericDevice(TQT_DBusObjectPath path) {
TQT_DBusError error;
-
DBus::DeviceProxy genericDevice(NM_DBUS_SERVICE, path);
genericDevice.setConnection(TQT_DBusConnection::systemBus());
- TQ_UINT32 deviceType = genericDevice.getDeviceType(error);
+ TQString deviceInterface = genericDevice.getInterface(error);
if (error.isValid()) {
- // Error!
- PRINT_ERROR((error.name() + ": " + error.message()))
- return TQString();
- }
- else if (deviceType == NM_DEVICE_TYPE_ETHERNET) {
- DBus::EthernetDeviceProxy ethernetDevice(NM_DBUS_SERVICE, path);
- ethernetDevice.setConnection(TQT_DBusConnection::systemBus());
- TQString candidateMACAddress = ethernetDevice.getPermHwAddress(error);
- if (!error.isValid()) {
- return candidateMACAddress.lower();
- }
- }
- else if (deviceType == NM_DEVICE_TYPE_INFINIBAND) {
- DBus::InfinibandDeviceProxy infinibandDevice(NM_DBUS_SERVICE, path);
- infinibandDevice.setConnection(TQT_DBusConnection::systemBus());
- TQString candidateMACAddress = infinibandDevice.getHwAddress(error);
- if (!error.isValid()) {
- return candidateMACAddress.lower();
- }
- }
- else if (deviceType == NM_DEVICE_TYPE_WIFI) {
- DBus::WiFiDeviceProxy wiFiDevice(NM_DBUS_SERVICE, path);
- wiFiDevice.setConnection(TQT_DBusConnection::systemBus());
- TQString candidateMACAddress = wiFiDevice.getPermHwAddress(error);
- if (!error.isValid()) {
- return candidateMACAddress.lower();
- }
- }
- else if (deviceType == NM_DEVICE_TYPE_WIMAX) {
- DBus::WiMaxDeviceProxy wiMaxDevice(NM_DBUS_SERVICE, path);
- wiMaxDevice.setConnection(TQT_DBusConnection::systemBus());
- TQString candidateMACAddress = wiMaxDevice.getHwAddress(error);
- if (!error.isValid()) {
- return candidateMACAddress.lower();
- }
- }
- else if (deviceType == NM_DEVICE_TYPE_OLPC_MESH) {
- DBus::OlpcMeshDeviceProxy olpcMeshDevice(NM_DBUS_SERVICE, path);
- olpcMeshDevice.setConnection(TQT_DBusConnection::systemBus());
- TQString candidateMACAddress = olpcMeshDevice.getHwAddress(error);
- if (!error.isValid()) {
- return candidateMACAddress.lower();
- }
- }
- else if (deviceType == NM_DEVICE_TYPE_BT) {
- DBus::BluetoothDeviceProxy bluetoothDevice(NM_DBUS_SERVICE, path);
- bluetoothDevice.setConnection(TQT_DBusConnection::systemBus());
- TQString candidateMACAddress = bluetoothDevice.getHwAddress(error);
- if (!error.isValid()) {
- return candidateMACAddress.lower();
- }
+ return TQString::null;
}
- // FIXME
- // Add other supported device types here
-
- return TQString::null;
-}
-TQString tdeDeviceUUIDForMACAddress(TQString macAddress) {
TDEHardwareDevices *hwdevices = TDEGlobal::hardwareDevices();
if (!hwdevices) {
return TQString::null;
@@ -1305,7 +1189,7 @@ TQString tdeDeviceUUIDForMACAddress(TQString macAddress) {
for (TDEGenericHardwareList::iterator it = devices.begin(); it != devices.end(); ++it) {
TDENetworkDevice* dev = dynamic_cast<TDENetworkDevice*>(*it);
if (dev) {
- if (macAddress.lower() == dev->macAddress().lower()) {
+ if (deviceInterface == dev->deviceNode()) {
return dev->uniqueID();
}
}
@@ -1355,7 +1239,7 @@ void TDENetworkConnectionManager_BackendNM_DBusSignalReceiver::dbusSignal(const
}
}
-TDENetworkConnectionManager_BackendNM::TDENetworkConnectionManager_BackendNM(TQString macAddress) : TDENetworkConnectionManager(macAddress) {
+TDENetworkConnectionManager_BackendNM::TDENetworkConnectionManager_BackendNM(TDENetworkDevice* networkDevice) : TDENetworkConnectionManager(networkDevice) {
d = new TDENetworkConnectionManager_BackendNMPrivate(this);
// Set up proxy interfaces
@@ -1366,7 +1250,7 @@ TDENetworkConnectionManager_BackendNM::TDENetworkConnectionManager_BackendNM(TQS
d->m_vpnProxy = new DBus::VPNPluginProxy(NM_VPN_DBUS_PLUGIN_SERVICE, NM_VPN_DBUS_PLUGIN_PATH);
d->m_vpnProxy->setConnection(TQT_DBusConnection::systemBus());
- d->m_dbusDeviceString = deviceInterfaceString(macAddress);
+ d->m_dbusDeviceString = deviceInterfaceString(deviceNode());
if (d->m_dbusDeviceString != "") {
d->m_networkDeviceProxy = new DBus::DeviceProxy(NM_DBUS_SERVICE, d->m_dbusDeviceString);
d->m_networkDeviceProxy->setConnection(TQT_DBusConnection::systemBus());
@@ -1618,7 +1502,7 @@ void TDENetworkConnectionManager_BackendNMPrivate::internalProcessDeviceStateCha
m_parent->internalNetworkDeviceEvent(TDENetworkDeviceEventType::Failure, errorString);
}
- m_parent->internalNetworkDeviceStateChanged(nmDeviceStateToTDEDeviceState(newState), m_parent->m_macAddress);
+ m_parent->internalNetworkDeviceStateChanged(nmDeviceStateToTDEDeviceState(newState), m_parent->deviceNode());
}
void TDENetworkConnectionManager_BackendNMPrivate::internalProcessWiFiAccessPointAdded(const TQT_DBusObjectPath& dbuspath) {
@@ -1682,14 +1566,14 @@ void TDENetworkConnectionManager_BackendNMPrivate::internalProcessAPPropertiesCh
}
TDENetworkDeviceType::TDENetworkDeviceType TDENetworkConnectionManager_BackendNM::deviceType() {
- if (m_macAddress == "") {
+ if (!m_networkDevice) {
return TDENetworkDeviceType::BackendOnly;
}
else {
if (d->m_dbusDeviceString != "") {
// Query NM for the device type
TQT_DBusError error;
- d->m_dbusDeviceString = deviceInterfaceString(m_macAddress);
+ d->m_dbusDeviceString = deviceInterfaceString(deviceNode());
DBus::DeviceProxy genericDevice(NM_DBUS_SERVICE, d->m_dbusDeviceString);
genericDevice.setConnection(TQT_DBusConnection::systemBus());
TDENetworkDeviceType::TDENetworkDeviceType ret = nmDeviceTypeToTDEDeviceType(genericDevice.getDeviceType(error));
@@ -1981,7 +1865,7 @@ void TDENetworkConnectionManager_BackendNM::loadConnectionInformation() {
d->nonReentrantCallActive = true;
TDEMACAddress deviceMACAddress;
- deviceMACAddress.fromString(m_macAddress);
+ deviceMACAddress.fromString(this->deviceMACAddress());
if (d->m_networkManagerSettings) {
clearTDENetworkConnectionList();
@@ -4953,11 +4837,11 @@ TDENetworkConnectionStatus::TDENetworkConnectionStatus TDENetworkConnectionManag
if ((d->m_networkManagerSettings) && (d->m_networkManagerProxy)) {
ret = d->m_networkManagerSettings->GetConnectionByUuid(uuid, existingConnection, error);
if (ret) {
- if (m_macAddress == "") {
+ if (!m_networkDevice) {
d->m_dbusDeviceString = "/";
}
else {
- d->m_dbusDeviceString = deviceInterfaceString(m_macAddress);
+ d->m_dbusDeviceString = deviceInterfaceString(deviceNode());
}
#ifndef USE_ASYNC_DBUS_CONNECTION_COMMAND_CALLS
TQT_DBusObjectPath active_connection;
@@ -5087,8 +4971,7 @@ TQStringList TDENetworkConnectionManager_BackendNM::connectionPhysicalDeviceUUID
TQValueList<TQT_DBusObjectPath> deviceList = activeConnection.getDevices(error);
TQT_DBusObjectPathList::iterator it2;
for (it2 = deviceList.begin(); it2 != deviceList.end(); ++it2) {
- TQString macAddress = macAddressForGenericDevice(*it2);
- TQString devUUID = tdeDeviceUUIDForMACAddress(macAddress);
+ TQString devUUID = tdeDeviceUUIDForGenericDevice(*it2);
if (devUUID != "") {
ret.append(devUUID);
}
@@ -5147,11 +5030,11 @@ TDENetworkConnectionStatus::TDENetworkConnectionStatus TDENetworkConnectionManag
if ((d->m_networkManagerSettings) && (d->m_networkManagerProxy)) {
existingConnection = getActiveConnectionPath(uuid);
if (existingConnection.isValid()) {
- if (m_macAddress == "") {
+ if (!m_networkDevice) {
d->m_dbusDeviceString = "/";
}
else {
- d->m_dbusDeviceString = deviceInterfaceString(m_macAddress);
+ d->m_dbusDeviceString = deviceInterfaceString(deviceNode());
}
#ifndef USE_ASYNC_DBUS_CONNECTION_COMMAND_CALLS
ret = d->m_networkManagerProxy->DeactivateConnection(existingConnection, error);
@@ -5435,7 +5318,7 @@ TDENetworkHWNeighborList* TDENetworkConnectionManager_BackendNM::siteSurvey() {
bool ret;
TDENetworkDeviceType::TDENetworkDeviceType myDeviceType = deviceType();
- d->m_dbusDeviceString = deviceInterfaceString(m_macAddress);
+ d->m_dbusDeviceString = deviceInterfaceString(deviceNode());
clearTDENetworkHWNeighborList();
if (myDeviceType == TDENetworkDeviceType::WiFi) {
diff --git a/tdecore/tdehw/networkbackends/network-manager/network-manager.h b/tdecore/tdehw/networkbackends/network-manager/network-manager.h
index 0de184706..92b4b0a37 100644
--- a/tdecore/tdehw/networkbackends/network-manager/network-manager.h
+++ b/tdecore/tdehw/networkbackends/network-manager/network-manager.h
@@ -213,7 +213,7 @@ class TDECORE_EXPORT TDENetworkConnectionManager_BackendNM : public TDENetworkCo
Q_OBJECT
public:
- TDENetworkConnectionManager_BackendNM(TQString macAddress);
+ TDENetworkConnectionManager_BackendNM(TDENetworkDevice* networkDevice);
~TDENetworkConnectionManager_BackendNM();
virtual TQString backendName();
@@ -249,7 +249,7 @@ class TDECORE_EXPORT TDENetworkConnectionManager_BackendNM : public TDENetworkCo
private:
TDENetworkDeviceType::TDENetworkDeviceType nmDeviceTypeToTDEDeviceType(TQ_UINT32 nmType);
- TQString deviceInterfaceString(TQString macAddress);
+ TQString deviceInterfaceString(TQString deviceNode);
bool loadConnectionSecretsForGroup(TQString uuid, TQString group);
TDENetworkWiFiAPInfo* getAccessPointDetails(TQString dbusPath);
TDENetworkConnectionType::TDENetworkConnectionType connectionType(TQString dbusPath);