[PATCH 5/6] devices/wifi: Add the wifi-backend config option
- From: Andrew Zaborowski <andrew zaborowski intel com>
- To: networkmanager-list gnome org
- Subject: [PATCH 5/6] devices/wifi: Add the wifi-backend config option
- Date: Sat, 9 Dec 2017 16:28:12 +0100
Let the config file select between creating classes of NMDeviceWifi
(for the usual wpa_supplicant based devices) and NMDeviceIwd depending
on the new NetworkManager.conf setting.
---
src/devices/wifi/nm-wifi-factory.c | 23 ++++++++++++++++++++---
src/nm-config.h | 1 +
2 files changed, 21 insertions(+), 3 deletions(-)
diff --git a/src/devices/wifi/nm-wifi-factory.c b/src/devices/wifi/nm-wifi-factory.c
index a1752634b..6c6984eab 100644
--- a/src/devices/wifi/nm-wifi-factory.c
+++ b/src/devices/wifi/nm-wifi-factory.c
@@ -27,8 +27,10 @@
#include "nm-setting-olpc-mesh.h"
#include "nm-device-wifi.h"
#include "nm-device-olpc-mesh.h"
+#include "nm-device-iwd.h"
#include "settings/nm-settings-connection.h"
#include "platform/nm-platform.h"
+#include "nm-config.h"
/*****************************************************************************/
@@ -75,6 +77,7 @@ create_device (NMDeviceFactory *factory,
{
NMDeviceWifiCapabilities capabilities;
NM80211Mode mode;
+ const char *backend;
g_return_val_if_fail (iface != NULL, NULL);
g_return_val_if_fail (plink != NULL, NULL);
@@ -98,10 +101,24 @@ create_device (NMDeviceFactory *factory,
return NULL;
}
- if (plink->type == NM_LINK_TYPE_WIFI)
- return nm_device_wifi_new (iface, capabilities);
- else
+ if (plink->type != NM_LINK_TYPE_WIFI)
return nm_device_olpc_mesh_new (iface);
+
+ backend = nm_config_data_get_value (NM_CONFIG_GET_DATA_ORIG,
+ NM_CONFIG_KEYFILE_GROUP_MAIN,
+ NM_CONFIG_KEYFILE_KEY_MAIN_WIFI_BACKEND,
+ NM_CONFIG_GET_VALUE_STRIP);
+
+ nm_log_warn (LOGD_PLATFORM | LOGD_WIFI, "(%s) config: backend is %s, %i", iface, backend, WITH_IWD);
+ if (!backend || !strcasecmp (backend, "wpa_supplicant"))
+ return nm_device_wifi_new (iface, capabilities);
+#if WITH_IWD
+ else if (!strcasecmp (backend, "iwd"))
+ return nm_device_iwd_new (iface, capabilities);
+#endif
+
+ nm_log_warn (LOGD_PLATFORM | LOGD_WIFI, "(%s) config: unknown or unsupported wifi-backend %s", iface,
backend);
+ return NULL;
}
/*****************************************************************************/
diff --git a/src/nm-config.h b/src/nm-config.h
index 47e929884..d94a279ca 100644
--- a/src/nm-config.h
+++ b/src/nm-config.h
@@ -64,6 +64,7 @@
#define NM_CONFIG_KEYFILE_KEY_MAIN_DEBUG "debug"
#define NM_CONFIG_KEYFILE_KEY_MAIN_HOSTNAME_MODE "hostname-mode"
#define NM_CONFIG_KEYFILE_KEY_MAIN_SLAVES_ORDER "slaves-order"
+#define NM_CONFIG_KEYFILE_KEY_MAIN_WIFI_BACKEND "wifi-backend"
#define NM_CONFIG_KEYFILE_KEY_LOGGING_BACKEND "backend"
#define NM_CONFIG_KEYFILE_KEY_CONFIG_ENABLE "enable"
#define NM_CONFIG_KEYFILE_KEY_ATOMIC_SECTION_WAS ".was"
--
2.11.0
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]