[RFC PATCH 1/8] wifi: Move get_connection_iwd_security to nm-wifi-utils.c
- From: Andrew Zaborowski <andrew zaborowski intel com>
- To: networkmanager-list gnome org
- Subject: [RFC PATCH 1/8] wifi: Move get_connection_iwd_security to nm-wifi-utils.c
- Date: Tue, 12 Jun 2018 10:21:35 +0200
Make this function public. I'm not sure if at this point it makes
much sense to add a new file for iwd-specific utilities.
---
src/devices/wifi/nm-device-iwd.c | 35 ++++++-----------------------------
src/devices/wifi/nm-wifi-utils.c | 23 +++++++++++++++++++++++
src/devices/wifi/nm-wifi-utils.h | 3 +++
3 files changed, 32 insertions(+), 29 deletions(-)
diff --git a/src/devices/wifi/nm-device-iwd.c b/src/devices/wifi/nm-device-iwd.c
index d3c5ae9aa..c756f5d35 100644
--- a/src/devices/wifi/nm-device-iwd.c
+++ b/src/devices/wifi/nm-device-iwd.c
@@ -452,29 +452,6 @@ deactivate_async (NMDevice *device,
G_DBUS_CALL_FLAGS_NONE, -1, cancellable, disconnect_cb, ctx);
}
-static NMIwdNetworkSecurity
-get_connection_iwd_security (NMConnection *connection)
-{
- NMSettingWirelessSecurity *s_wireless_sec;
- const char *key_mgmt = NULL;
-
- s_wireless_sec = nm_connection_get_setting_wireless_security (connection);
- if (!s_wireless_sec)
- return NM_IWD_NETWORK_SECURITY_NONE;
-
- key_mgmt = nm_setting_wireless_security_get_key_mgmt (s_wireless_sec);
- nm_assert (key_mgmt);
-
- if (!strcmp (key_mgmt, "none") || !strcmp (key_mgmt, "ieee8021x"))
- return NM_IWD_NETWORK_SECURITY_WEP;
-
- if (!strcmp (key_mgmt, "wpa-psk"))
- return NM_IWD_NETWORK_SECURITY_PSK;
-
- nm_assert (!strcmp (key_mgmt, "wpa-eap"));
- return NM_IWD_NETWORK_SECURITY_8021X;
-}
-
static gboolean
is_connection_known_network (NMConnection *connection)
{
@@ -495,7 +472,7 @@ is_connection_known_network (NMConnection *connection)
return nm_iwd_manager_is_known_network (nm_iwd_manager_get (),
str_ssid,
- get_connection_iwd_security (connection));
+ nm_wifi_connection_get_iwd_security (connection));
}
static gboolean
@@ -549,7 +526,7 @@ check_connection_compatible (NMDevice *device, NMConnection *connection)
/* 8021x networks can only be used if they've been provisioned on the IWD side and
* thus are Known Networks.
*/
- if (get_connection_iwd_security (connection) == NM_IWD_NETWORK_SECURITY_8021X) {
+ if (nm_wifi_connection_get_iwd_security (connection) == NM_IWD_NETWORK_SECURITY_8021X) {
if (!is_connection_known_network (connection))
return FALSE;
}
@@ -583,7 +560,7 @@ check_connection_available (NMDevice *device,
/* 8021x networks can only be used if they've been provisioned on the IWD side and
* thus are Known Networks.
*/
- if (get_connection_iwd_security (connection) == NM_IWD_NETWORK_SECURITY_8021X) {
+ if (nm_wifi_connection_get_iwd_security (connection) == NM_IWD_NETWORK_SECURITY_8021X) {
if (!is_connection_known_network (connection))
return FALSE;
}
@@ -718,7 +695,7 @@ complete_connection (NMDevice *device,
/* 8021x networks can only be used if they've been provisioned on the IWD side and
* thus are Known Networks.
*/
- if (get_connection_iwd_security (connection) == NM_IWD_NETWORK_SECURITY_8021X) {
+ if (nm_wifi_connection_get_iwd_security (connection) == NM_IWD_NETWORK_SECURITY_8021X) {
if (!is_connection_known_network (connection)) {
g_set_error_literal (error,
NM_CONNECTION_ERROR,
@@ -819,7 +796,7 @@ can_auto_connect (NMDevice *device,
/* 8021x networks can only be used if they've been provisioned on the IWD side and
* thus are Known Networks.
*/
- if (get_connection_iwd_security (connection) == NM_IWD_NETWORK_SECURITY_8021X) {
+ if (nm_wifi_connection_get_iwd_security (connection) == NM_IWD_NETWORK_SECURITY_8021X) {
if (!is_connection_known_network (connection))
return FALSE;
}
@@ -1160,7 +1137,7 @@ network_connect_cb (GObject *source, GAsyncResult *res, gpointer user_data)
nm_device_activate_schedule_stage3_ip_config_start (device);
nm_iwd_manager_network_connected (nm_iwd_manager_get (), str_ssid,
- get_connection_iwd_security (connection));
+ nm_wifi_connection_get_iwd_security (connection));
return;
diff --git a/src/devices/wifi/nm-wifi-utils.c b/src/devices/wifi/nm-wifi-utils.c
index 044bd392d..c7bb71963 100644
--- a/src/devices/wifi/nm-wifi-utils.c
+++ b/src/devices/wifi/nm-wifi-utils.c
@@ -814,3 +814,26 @@ nm_wifi_utils_is_manf_default_ssid (const GByteArray *ssid)
}
return FALSE;
}
+
+NMIwdNetworkSecurity
+nm_wifi_connection_get_iwd_security (NMConnection *connection)
+{
+ NMSettingWirelessSecurity *s_wireless_sec;
+ const char *key_mgmt = NULL;
+
+ s_wireless_sec = nm_connection_get_setting_wireless_security (connection);
+ if (!s_wireless_sec)
+ return NM_IWD_NETWORK_SECURITY_NONE;
+
+ key_mgmt = nm_setting_wireless_security_get_key_mgmt (s_wireless_sec);
+ nm_assert (key_mgmt);
+
+ if (!strcmp (key_mgmt, "none") || !strcmp (key_mgmt, "ieee8021x"))
+ return NM_IWD_NETWORK_SECURITY_WEP;
+
+ if (!strcmp (key_mgmt, "wpa-psk"))
+ return NM_IWD_NETWORK_SECURITY_PSK;
+
+ nm_assert (!strcmp (key_mgmt, "wpa-eap"));
+ return NM_IWD_NETWORK_SECURITY_8021X;
+}
diff --git a/src/devices/wifi/nm-wifi-utils.h b/src/devices/wifi/nm-wifi-utils.h
index def64dd6f..c21fc8e80 100644
--- a/src/devices/wifi/nm-wifi-utils.h
+++ b/src/devices/wifi/nm-wifi-utils.h
@@ -26,6 +26,7 @@
#include "nm-setting-wireless.h"
#include "nm-setting-wireless-security.h"
#include "nm-setting-8021x.h"
+#include "nm-iwd-manager.h"
gboolean nm_wifi_utils_complete_connection (const GByteArray *ssid,
const char *bssid,
@@ -41,4 +42,6 @@ guint32 nm_wifi_utils_level_to_quality (gint val);
gboolean nm_wifi_utils_is_manf_default_ssid (const GByteArray *ssid);
+NMIwdNetworkSecurity nm_wifi_connection_get_iwd_security (NMConnection *connection);
+
#endif /* __NM_WIFI_UTILS_H__ */
--
2.14.1
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]