Commit 89bbcb81 authored by Andrew Zaborowski's avatar Andrew Zaborowski Committed by Thomas Haller

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

Move the function for easier code reuse.
parent 0ff94718
......@@ -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);
......
......@@ -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;
}
......@@ -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__ */
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment