From 89bbcb816b70cfa86a4d5bb4b0967ef85000f2a1 Mon Sep 17 00:00:00 2001 From: Andrew Zaborowski Date: Sat, 9 Dec 2017 16:28:09 +0100 Subject: devices/wifi: Move is_manf_default_ssid to nm-wifi-utils.c Move the function for easier code reuse. --- src/devices/wifi/nm-device-wifi.c | 36 ++---------------------------------- src/devices/wifi/nm-wifi-utils.c | 32 ++++++++++++++++++++++++++++++++ src/devices/wifi/nm-wifi-utils.h | 2 ++ 3 files changed, 36 insertions(+), 34 deletions(-) diff --git a/src/devices/wifi/nm-device-wifi.c b/src/devices/wifi/nm-device-wifi.c index e5315a09df..68749ee224 100644 --- a/src/devices/wifi/nm-device-wifi.c +++ b/src/devices/wifi/nm-device-wifi.c @@ -48,6 +48,7 @@ #include "nm-auth-utils.h" #include "settings/nm-settings-connection.h" #include "settings/nm-settings.h" +#include "nm-wifi-utils.h" #include "nm-core-internal.h" #include "nm-config.h" @@ -727,39 +728,6 @@ check_connection_available (NMDevice *device, return !!nm_wifi_aps_find_first_compatible (priv->aps, connection, TRUE); } -static gboolean -is_manf_default_ssid (const GByteArray *ssid) -{ - int i; - /* - * List of manufacturer default SSIDs that are often unchanged by users. - * - * NOTE: this list should *not* contain networks that you would like to - * automatically roam to like "Starbucks" or "AT&T" or "T-Mobile HotSpot". - */ - static const char *manf_defaults[] = { - "linksys", - "linksys-a", - "linksys-g", - "default", - "belkin54g", - "NETGEAR", - "o2DSL", - "WLAN", - "ALICE-WLAN", - "Speedport W 501V", - "TURBONETT", - }; - - for (i = 0; i < G_N_ELEMENTS (manf_defaults); i++) { - if (ssid->len == strlen (manf_defaults[i])) { - if (memcmp (manf_defaults[i], ssid->data, ssid->len) == 0) - return TRUE; - } - } - return FALSE; -} - static gboolean complete_connection (NMDevice *device, NMConnection *connection, @@ -880,7 +848,7 @@ complete_connection (NMDevice *device, */ if (!nm_wifi_ap_complete_connection (ap, connection, - is_manf_default_ssid (ssid), + nm_wifi_utils_is_manf_default_ssid (ssid), error)) { if (tmp_ssid) g_byte_array_unref (tmp_ssid); diff --git a/src/devices/wifi/nm-wifi-utils.c b/src/devices/wifi/nm-wifi-utils.c index 3ff82004d0..044bd392dd 100644 --- a/src/devices/wifi/nm-wifi-utils.c +++ b/src/devices/wifi/nm-wifi-utils.c @@ -782,3 +782,35 @@ nm_wifi_utils_level_to_quality (gint val) return CLAMP (val, 0, 100); } +gboolean +nm_wifi_utils_is_manf_default_ssid (const GByteArray *ssid) +{ + int i; + /* + * List of manufacturer default SSIDs that are often unchanged by users. + * + * NOTE: this list should *not* contain networks that you would like to + * automatically roam to like "Starbucks" or "AT&T" or "T-Mobile HotSpot". + */ + static const char *manf_defaults[] = { + "linksys", + "linksys-a", + "linksys-g", + "default", + "belkin54g", + "NETGEAR", + "o2DSL", + "WLAN", + "ALICE-WLAN", + "Speedport W 501V", + "TURBONETT", + }; + + for (i = 0; i < G_N_ELEMENTS (manf_defaults); i++) { + if (ssid->len == strlen (manf_defaults[i])) { + if (memcmp (manf_defaults[i], ssid->data, ssid->len) == 0) + return TRUE; + } + } + return FALSE; +} diff --git a/src/devices/wifi/nm-wifi-utils.h b/src/devices/wifi/nm-wifi-utils.h index 1b6c2f4bfb..def64dd6ff 100644 --- a/src/devices/wifi/nm-wifi-utils.h +++ b/src/devices/wifi/nm-wifi-utils.h @@ -39,4 +39,6 @@ gboolean nm_wifi_utils_complete_connection (const GByteArray *ssid, guint32 nm_wifi_utils_level_to_quality (gint val); +gboolean nm_wifi_utils_is_manf_default_ssid (const GByteArray *ssid); + #endif /* __NM_WIFI_UTILS_H__ */ -- cgit v1.2.1