devices/wifi: Move is_manf_default_ssid to nm-wifi-utils.c

Move the function for easier code reuse.
This commit is contained in:
Andrew Zaborowski 2017-12-09 16:28:09 +01:00 committed by Thomas Haller
parent 0ff9471837
commit 89bbcb816b
3 changed files with 36 additions and 34 deletions

View file

@ -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);

View file

@ -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;
}

View file

@ -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__ */