Commit 24bc9531 authored by Thomas Haller's avatar Thomas Haller
parents 8c0dfd71 af6f2e49
...@@ -2703,6 +2703,14 @@ src_devices_wifi_libnm_device_plugin_wifi_la_SOURCES = \ ...@@ -2703,6 +2703,14 @@ src_devices_wifi_libnm_device_plugin_wifi_la_SOURCES = \
src/devices/wifi/nm-device-olpc-mesh.c \ src/devices/wifi/nm-device-olpc-mesh.c \
src/devices/wifi/nm-device-olpc-mesh.h src/devices/wifi/nm-device-olpc-mesh.h
if WITH_IWD
src_devices_wifi_libnm_device_plugin_wifi_la_SOURCES += \
src/devices/wifi/nm-device-iwd.c \
src/devices/wifi/nm-device-iwd.h \
src/devices/wifi/nm-iwd-manager.c \
src/devices/wifi/nm-iwd-manager.h
endif
src_devices_wifi_libnm_device_plugin_wifi_la_CPPFLAGS = \ src_devices_wifi_libnm_device_plugin_wifi_la_CPPFLAGS = \
-I$(srcdir)/src \ -I$(srcdir)/src \
-I$(builddir)/src \ -I$(builddir)/src \
......
...@@ -279,6 +279,26 @@ else ...@@ -279,6 +279,26 @@ else
AC_DEFINE(HAVE_NL80211_CRITICAL_PROTOCOL_CMDS, 0, [Define if nl80211 has critical protocol support]) AC_DEFINE(HAVE_NL80211_CRITICAL_PROTOCOL_CMDS, 0, [Define if nl80211 has critical protocol support])
fi fi
dnl
dnl Default to using wpa_supplicant but allow IWD as wifi backend
dnl
AC_ARG_WITH(iwd,
AS_HELP_STRING([--with-iwd=yes],
[Support IWD as wifi-backend in addition to wpa_supplicant (experimental)]),
ac_with_iwd=$withval, ac_with_iwd="no")
if test "$ac_with_iwd" != 'no'; then
ac_with_iwd='yes'
fi
if test x"$ac_with_iwd" = x"yes"; then
if test "$enable_wifi" != "yes"; then
AC_MSG_ERROR(Enabling IWD support and disabling Wi-Fi makes no sense)
fi
AC_DEFINE(WITH_IWD, 1, [Define to compile with the IWD wifi-backend])
else
AC_DEFINE(WITH_IWD, 0, [Define to compile without the IWD wifi-backend])
fi
AM_CONDITIONAL(WITH_IWD, test x"${ac_with_iwd}" = x"yes")
dnl dnl
dnl Check for newer VLAN flags dnl Check for newer VLAN flags
dnl dnl
...@@ -1417,6 +1437,7 @@ echo " ovs: $enable_ovs" ...@@ -1417,6 +1437,7 @@ echo " ovs: $enable_ovs"
echo " libnm-glib: $with_libnm_glib" echo " libnm-glib: $with_libnm_glib"
echo " nmcli: $build_nmcli" echo " nmcli: $build_nmcli"
echo " nmtui: $build_nmtui" echo " nmtui: $build_nmtui"
echo " iwd: $ac_with_iwd"
echo echo
echo "Configuration plugins (main.plugins=${config_plugins_default})" echo "Configuration plugins (main.plugins=${config_plugins_default})"
......
This diff is collapsed.
/* -*- Mode: C; tab-width: 4; indent-tabs-mode: t; c-basic-offset: 4 -*- */
/* NetworkManager -- Network link manager
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 2 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License along
* with this program; if not, write to the Free Software Foundation, Inc.,
* 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
*
* Copyright (C) 2017 Intel Corporation
*/
#ifndef __NETWORKMANAGER_DEVICE_IWD_H__
#define __NETWORKMANAGER_DEVICE_IWD_H__
#include "devices/nm-device.h"
#include "nm-wifi-ap.h"
#include "nm-device-wifi.h"
#define NM_TYPE_DEVICE_IWD (nm_device_iwd_get_type ())
#define NM_DEVICE_IWD(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), NM_TYPE_DEVICE_IWD, NMDeviceIwd))
#define NM_DEVICE_IWD_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST ((klass), NM_TYPE_DEVICE_IWD, NMDeviceIwdClass))
#define NM_IS_DEVICE_IWD(obj) (G_TYPE_CHECK_INSTANCE_TYPE ((obj), NM_TYPE_DEVICE_IWD))
#define NM_IS_DEVICE_IWD_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((klass), NM_TYPE_DEVICE_IWD))
#define NM_DEVICE_IWD_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS ((obj), NM_TYPE_DEVICE_IWD, NMDeviceIwdClass))
#define NM_DEVICE_IWD_MODE NM_DEVICE_WIFI_MODE
#define NM_DEVICE_IWD_BITRATE NM_DEVICE_WIFI_BITRATE
#define NM_DEVICE_IWD_ACCESS_POINTS NM_DEVICE_WIFI_ACCESS_POINTS
#define NM_DEVICE_IWD_ACTIVE_ACCESS_POINT NM_DEVICE_WIFI_ACTIVE_ACCESS_POINT
#define NM_DEVICE_IWD_CAPABILITIES NM_DEVICE_WIFI_CAPABILITIES
#define NM_DEVICE_IWD_SCANNING NM_DEVICE_WIFI_SCANNING
/* signals */
#define NM_DEVICE_IWD_ACCESS_POINT_ADDED NM_DEVICE_WIFI_ACCESS_POINT_ADDED
#define NM_DEVICE_IWD_ACCESS_POINT_REMOVED NM_DEVICE_WIFI_ACCESS_POINT_REMOVED
/* internal signals */
#define NM_DEVICE_IWD_SCANNING_PROHIBITED NM_DEVICE_WIFI_SCANNING_PROHIBITED
typedef struct _NMDeviceIwd NMDeviceIwd;
typedef struct _NMDeviceIwdClass NMDeviceIwdClass;
GType nm_device_iwd_get_type (void);
NMDevice *nm_device_iwd_new (const char *iface, NMDeviceWifiCapabilities capabilities);
void nm_device_iwd_set_dbus_object (NMDeviceIwd *device, GDBusObject *object);
const gchar *nm_device_iwd_agent_psk_query (NMDeviceIwd *device);
#endif /* __NETWORKMANAGER_DEVICE_IWD_H__ */
...@@ -48,6 +48,7 @@ ...@@ -48,6 +48,7 @@
#include "nm-auth-utils.h" #include "nm-auth-utils.h"
#include "settings/nm-settings-connection.h" #include "settings/nm-settings-connection.h"
#include "settings/nm-settings.h" #include "settings/nm-settings.h"
#include "nm-wifi-utils.h"
#include "nm-core-internal.h" #include "nm-core-internal.h"
#include "nm-config.h" #include "nm-config.h"
...@@ -680,35 +681,14 @@ check_connection_compatible (NMDevice *device, NMConnection *connection) ...@@ -680,35 +681,14 @@ check_connection_compatible (NMDevice *device, NMConnection *connection)
return TRUE; return TRUE;
} }
static NMWifiAP *
find_first_compatible_ap (NMDeviceWifi *self,
NMConnection *connection,
gboolean allow_unstable_order)
{
GHashTableIter iter;
NMWifiAP *ap;
NMWifiAP *cand_ap = NULL;
g_return_val_if_fail (connection != NULL, NULL);
g_hash_table_iter_init (&iter, NM_DEVICE_WIFI_GET_PRIVATE (self)->aps);
while (g_hash_table_iter_next (&iter, NULL, (gpointer) &ap)) {
if (!nm_wifi_ap_check_compatible (ap, connection))
continue;
if (allow_unstable_order)
return ap;
if (!cand_ap || (nm_wifi_ap_get_id (cand_ap) < nm_wifi_ap_get_id (ap)))
cand_ap = ap;
}
return cand_ap;
}
static gboolean static gboolean
check_connection_available (NMDevice *device, check_connection_available (NMDevice *device,
NMConnection *connection, NMConnection *connection,
NMDeviceCheckConAvailableFlags flags, NMDeviceCheckConAvailableFlags flags,
const char *specific_object) const char *specific_object)
{ {
NMDeviceWifi *self = NM_DEVICE_WIFI (device);
NMDeviceWifiPrivate *priv = NM_DEVICE_WIFI_GET_PRIVATE (self);
NMSettingWireless *s_wifi; NMSettingWireless *s_wifi;
const char *mode; const char *mode;
...@@ -721,7 +701,7 @@ check_connection_available (NMDevice *device, ...@@ -721,7 +701,7 @@ check_connection_available (NMDevice *device,
if (specific_object) { if (specific_object) {
NMWifiAP *ap; NMWifiAP *ap;
ap = get_ap_by_path (NM_DEVICE_WIFI (device), specific_object); ap = get_ap_by_path (self, specific_object);
return ap ? nm_wifi_ap_check_compatible (ap, connection) : FALSE; return ap ? nm_wifi_ap_check_compatible (ap, connection) : FALSE;
} }
...@@ -745,40 +725,7 @@ check_connection_available (NMDevice *device, ...@@ -745,40 +725,7 @@ check_connection_available (NMDevice *device,
return TRUE; return TRUE;
/* check at least one AP is compatible with this connection */ /* check at least one AP is compatible with this connection */
return !!find_first_compatible_ap (NM_DEVICE_WIFI (device), connection, TRUE); 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 static gboolean
...@@ -789,6 +736,7 @@ complete_connection (NMDevice *device, ...@@ -789,6 +736,7 @@ complete_connection (NMDevice *device,
GError **error) GError **error)
{ {
NMDeviceWifi *self = NM_DEVICE_WIFI (device); NMDeviceWifi *self = NM_DEVICE_WIFI (device);
NMDeviceWifiPrivate *priv = NM_DEVICE_WIFI_GET_PRIVATE (self);
NMSettingWireless *s_wifi; NMSettingWireless *s_wifi;
const char *setting_mac; const char *setting_mac;
char *str_ssid = NULL; char *str_ssid = NULL;
...@@ -825,7 +773,7 @@ complete_connection (NMDevice *device, ...@@ -825,7 +773,7 @@ complete_connection (NMDevice *device,
if (!nm_streq0 (mode, NM_SETTING_WIRELESS_MODE_AP)) { if (!nm_streq0 (mode, NM_SETTING_WIRELESS_MODE_AP)) {
/* Find a compatible AP in the scan list */ /* Find a compatible AP in the scan list */
ap = find_first_compatible_ap (self, connection, FALSE); ap = nm_wifi_aps_find_first_compatible (priv->aps, connection, FALSE);
/* If we still don't have an AP, then the WiFI settings needs to be /* If we still don't have an AP, then the WiFI settings needs to be
* fully specified by the client. Might not be able to find an AP * fully specified by the client. Might not be able to find an AP
...@@ -900,7 +848,7 @@ complete_connection (NMDevice *device, ...@@ -900,7 +848,7 @@ complete_connection (NMDevice *device,
*/ */
if (!nm_wifi_ap_complete_connection (ap, if (!nm_wifi_ap_complete_connection (ap,
connection, connection,
is_manf_default_ssid (ssid), nm_wifi_utils_is_manf_default_ssid (ssid),
error)) { error)) {
if (tmp_ssid) if (tmp_ssid)
g_byte_array_unref (tmp_ssid); g_byte_array_unref (tmp_ssid);
...@@ -1007,6 +955,7 @@ can_auto_connect (NMDevice *device, ...@@ -1007,6 +955,7 @@ can_auto_connect (NMDevice *device,
char **specific_object) char **specific_object)
{ {
NMDeviceWifi *self = NM_DEVICE_WIFI (device); NMDeviceWifi *self = NM_DEVICE_WIFI (device);
NMDeviceWifiPrivate *priv = NM_DEVICE_WIFI_GET_PRIVATE (self);
NMSettingWireless *s_wifi; NMSettingWireless *s_wifi;
NMWifiAP *ap; NMWifiAP *ap;
const char *method, *mode; const char *method, *mode;
...@@ -1038,7 +987,7 @@ can_auto_connect (NMDevice *device, ...@@ -1038,7 +987,7 @@ can_auto_connect (NMDevice *device,
return FALSE; return FALSE;
} }
ap = find_first_compatible_ap (self, connection, FALSE); ap = nm_wifi_aps_find_first_compatible (priv->aps, connection, FALSE);
if (ap) { if (ap) {
/* All good; connection is usable */ /* All good; connection is usable */
NM_SET_OUT (specific_object, g_strdup (nm_exported_object_get_path (NM_EXPORTED_OBJECT (ap)))); NM_SET_OUT (specific_object, g_strdup (nm_exported_object_get_path (NM_EXPORTED_OBJECT (ap))));
...@@ -1048,78 +997,15 @@ can_auto_connect (NMDevice *device, ...@@ -1048,78 +997,15 @@ can_auto_connect (NMDevice *device,
return FALSE; return FALSE;
} }
static int
ap_id_compare (gconstpointer p_a, gconstpointer p_b, gpointer user_data)
{
guint64 a_id = nm_wifi_ap_get_id (*((NMWifiAP **) p_a));
guint64 b_id = nm_wifi_ap_get_id (*((NMWifiAP **) p_b));
return a_id < b_id ? -1 : (a_id == b_id ? 0 : 1);
}
static NMWifiAP **
ap_list_get_sorted (NMDeviceWifi *self, gboolean include_without_ssid)
{
NMDeviceWifiPrivate *priv;
NMWifiAP **list;
GHashTableIter iter;
NMWifiAP *ap;
gsize i, n;
priv = NM_DEVICE_WIFI_GET_PRIVATE (self);
n = g_hash_table_size (priv->aps);
list = g_new (NMWifiAP *, n + 1);
i = 0;
if (n > 0) {
g_hash_table_iter_init (&iter, priv->aps);
while (g_hash_table_iter_next (&iter, NULL, (gpointer) &ap)) {
nm_assert (i < n);
if ( include_without_ssid
|| nm_wifi_ap_get_ssid (ap))
list[i++] = ap;
}
nm_assert (i <= n);
nm_assert (!include_without_ssid || i == n);
g_qsort_with_data (list,
i,
sizeof (gpointer),
ap_id_compare,
NULL);
}
list[i] = NULL;
return list;
}
static const char **
ap_list_get_sorted_paths (NMDeviceWifi *self, gboolean include_without_ssid)
{
gpointer *list;
gsize i, j;
list = (gpointer *) ap_list_get_sorted (self, include_without_ssid);
for (i = 0, j = 0; list[i]; i++) {
NMWifiAP *ap = list[i];
const char *path;
/* update @list inplace to hold instead the export-path. */
path = nm_exported_object_get_path (NM_EXPORTED_OBJECT (ap));
nm_assert (path);
list[j++] = (gpointer) path;
}
return (const char **) list;
}
static void static void
impl_device_wifi_get_access_points (NMDeviceWifi *self, impl_device_wifi_get_access_points (NMDeviceWifi *self,
GDBusMethodInvocation *context) GDBusMethodInvocation *context)
{ {
NMDeviceWifiPrivate *priv = NM_DEVICE_WIFI_GET_PRIVATE (self);
gs_free const char **list = NULL; gs_free const char **list = NULL;
GVariant *v; GVariant *v;
list = ap_list_get_sorted_paths (self, FALSE); list = nm_wifi_aps_get_sorted_paths (priv->aps, FALSE);
v = g_variant_new_objv (list, -1); v = g_variant_new_objv (list, -1);
g_dbus_method_invocation_return_value (context, g_variant_new_tuple (&v, 1)); g_dbus_method_invocation_return_value (context, g_variant_new_tuple (&v, 1));
} }
...@@ -1128,10 +1014,11 @@ static void ...@@ -1128,10 +1014,11 @@ static void
impl_device_wifi_get_all_access_points (NMDeviceWifi *self, impl_device_wifi_get_all_access_points (NMDeviceWifi *self,
GDBusMethodInvocation *context) GDBusMethodInvocation *context)
{ {
NMDeviceWifiPrivate *priv = NM_DEVICE_WIFI_GET_PRIVATE (self);
gs_free const char **list = NULL; gs_free const char **list = NULL;
GVariant *v; GVariant *v;
list = ap_list_get_sorted_paths (self, TRUE); list = nm_wifi_aps_get_sorted_paths (priv->aps, TRUE);
v = g_variant_new_objv (list, -1); v = g_variant_new_objv (list, -1);
g_dbus_method_invocation_return_value (context, g_variant_new_tuple (&v, 1)); g_dbus_method_invocation_return_value (context, g_variant_new_tuple (&v, 1));
} }
...@@ -1616,7 +1503,7 @@ ap_list_dump (gpointer user_data) ...@@ -1616,7 +1503,7 @@ ap_list_dump (gpointer user_data)
now_s, now_s,
priv->last_scan, priv->last_scan,
priv->scheduled_scan_time); priv->scheduled_scan_time);
list = ap_list_get_sorted (self, TRUE); list = nm_wifi_aps_get_sorted (priv->aps, TRUE);
for (i = 0; list[i]; i++) for (i = 0; list[i]; i++)
_ap_dump (self, LOGL_DEBUG, list[i], "dump", now_s); _ap_dump (self, LOGL_DEBUG, list[i], "dump", now_s);
} }
...@@ -2658,7 +2545,7 @@ act_stage1_prepare (NMDevice *device, NMDeviceStateReason *out_failure_reason) ...@@ -2658,7 +2545,7 @@ act_stage1_prepare (NMDevice *device, NMDeviceStateReason *out_failure_reason)
if (ap) if (ap)
goto done; goto done;
ap = find_first_compatible_ap (self, connection, FALSE); ap = nm_wifi_aps_find_first_compatible (priv->aps, connection, FALSE);
} }
if (ap) { if (ap) {
...@@ -3291,7 +3178,7 @@ get_property (GObject *object, guint prop_id, ...@@ -3291,7 +3178,7 @@ get_property (GObject *object, guint prop_id,
g_value_set_uint (value, priv->capabilities); g_value_set_uint (value, priv->capabilities);
break; break;
case PROP_ACCESS_POINTS: case PROP_ACCESS_POINTS:
list = (char **) ap_list_get_sorted_paths (self, TRUE); list = (char **) nm_wifi_aps_get_sorted_paths (priv->aps, TRUE);
for (i = 0; list[i]; i++) for (i = 0; list[i]; i++)
list[i] = g_strdup (list[i]); list[i] = g_strdup (list[i]);
g_value_take_boxed (value, list); g_value_take_boxed (value, list);
......
This diff is collapsed.
/* -*- Mode: C; tab-width: 4; indent-tabs-mode: t; c-basic-offset: 4 -*- */
/* NetworkManager -- Network link manager
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 2 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License along
* with this program; if not, write to the Free Software Foundation, Inc.,
* 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
*
* Copyright (C) 2017 Intel Corporation
*/
#ifndef __NETWORKMANAGER_IWD_MANAGER_H__
#define __NETWORKMANAGER_IWD_MANAGER_H__
#include "devices/nm-device.h"
#define NM_IWD_BUS_TYPE G_BUS_TYPE_SYSTEM
#define NM_IWD_SERVICE "net.connman.iwd"
#define NM_IWD_AGENT_MANAGER_INTERFACE "net.connman.iwd.AgentManager"
#define NM_IWD_WIPHY_INTERFACE "net.connman.iwd.Adapter"
#define NM_IWD_DEVICE_INTERFACE "net.connman.iwd.Device"
#define NM_IWD_NETWORK_INTERFACE "net.connman.iwd.Network"
#define NM_IWD_AGENT_INTERFACE "net.connman.iwd.Agent"
#define NM_IWD_WSC_INTERFACE \
"net.connman.iwd.WiFiSimpleConfiguration"
#define NM_IWD_KNOWN_NETWORKS_INTERFACE "net.connman.iwd.KnownNetworks"
#define NM_IWD_SIGNAL_AGENT_INTERFACE "net.connman.iwd.SignalLevelAgent"
#define NM_TYPE_IWD_MANAGER (nm_iwd_manager_get_type ())
#define NM_IWD_MANAGER(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), NM_TYPE_IWD_MANAGER, NMIwdManager))
#define NM_IWD_MANAGER_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST ((klass), NM_TYPE_IWD_MANAGER, NMIwdManagerClass))
#define NM_IS_IWD_MANAGER(obj) (G_TYPE_CHECK_INSTANCE_TYPE ((obj), NM_TYPE_IWD_MANAGER))
#define NM_IS_IWD_MANAGER_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((klass), NM_TYPE_IWD_MANAGER))
#define NM_IWD_MANAGER_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS ((obj), NM_TYPE_IWD_MANAGER, NMIwdManagerClass))
typedef struct _NMIwdManager NMIwdManager;
typedef struct _NMIwdManagerClass NMIwdManagerClass;
GType nm_iwd_manager_get_type (void);
NMIwdManager *nm_iwd_manager_get (void);
#endif /* __NETWORKMANAGER_IWD_MANAGER_H__ */
...@@ -1430,3 +1430,88 @@ nm_wifi_ap_class_init (NMWifiAPClass *ap_class) ...@@ -1430,3 +1430,88 @@ nm_wifi_ap_class_init (NMWifiAPClass *ap_class)
NULL); NULL);
} }
/*****************************************************************************/
static int
ap_id_compare (gconstpointer p_a, gconstpointer p_b, gpointer user_data)
{
guint64 a_id = nm_wifi_ap_get_id (*((NMWifiAP **) p_a));
guint64 b_id = nm_wifi_ap_get_id (*((NMWifiAP **) p_b));
return a_id < b_id ? -1 : (a_id == b_id ? 0 : 1);
}
NMWifiAP **
nm_wifi_aps_get_sorted (GHashTable *aps, gboolean include_without_ssid)
{
NMWifiAP **list;
GHashTableIter iter;
NMWifiAP *ap;
gsize i, n;
n = g_hash_table_size (aps);
list = g_new (NMWifiAP *, n + 1);
i = 0;
if (n > 0) {
g_hash_table_iter_init (&iter, aps);
while (g_hash_table_iter_next (&iter, NULL, (gpointer) &ap)) {
nm_assert (i < n);
if ( include_without_ssid
|| nm_wifi_ap_get_ssid (ap))
list[i++] = ap;
}
nm_assert (i <= n);
nm_assert (!include_without_ssid || i == n);
g_qsort_with_data (list,
i,
sizeof (gpointer),
ap_id_compare,
NULL);
}
list[i] = NULL;
return list;
}
const char **
nm_wifi_aps_get_sorted_paths (GHashTable *aps, gboolean include_without_ssid)
{
gpointer *list;
gsize i, j;
list = (gpointer *) nm_wifi_aps_get_sorted (aps, include_without_ssid);
for (i = 0, j = 0; list[i]; i++) {
NMWifiAP *ap = list[i];
const char *path;
/* update @list inplace to hold instead the export-path. */
path = nm_exported_object_get_path (NM_EXPORTED_OBJECT (ap));
nm_assert (path);
list[j++] = (gpointer) path;
}
return (const char **) list;
}
NMWifiAP *
nm_wifi_aps_find_first_compatible (GHashTable *aps,
NMConnection *connection,
gboolean allow_unstable_order)
{
GHashTableIter iter;
NMWifiAP *ap;
NMWifiAP *cand_ap = NULL;
g_return_val_if_fail (connection != NULL, NULL);
g_hash_table_iter_init (&iter, aps);
while (g_hash_table_iter_next (&iter, NULL, (gpointer) &ap)) {
if (!nm_wifi_ap_check_compatible (ap, connection))
continue;
if (allow_unstable_order)
return ap;
if (!cand_ap || (nm_wifi_ap_get_id (cand_ap) < nm_wifi_ap_get_id (ap)))
cand_ap = ap;
}
return cand_ap;
}
...@@ -95,4 +95,12 @@ const char *nm_wifi_ap_to_string (const NMWifiAP *self, ...@@ -95,4 +95,12 @@ const char *nm_wifi_ap_to_string (const NMWifiAP *self,
gulong buf_len, gulong buf_len,
gint32 now_s); gint32 now_s);
NMWifiAP **nm_wifi_aps_get_sorted (GHashTable *aps,
gboolean include_without_ssid);
const char **nm_wifi_aps_get_sorted_paths (GHashTable *aps,
gboolean include_without_ssid);
NMWifiAP *nm_wifi_aps_find_first_compatible (GHashTable *aps,
NMConnection *connection,
gboolean allow_unstable_order);
#endif /* __NM_WIFI_AP_H__ */ #endif /* __NM_WIFI_AP_H__ */
...@@ -27,8 +27,10 @@ ...@@ -27,8 +27,10 @@
#include "nm-setting-olpc-mesh.h" #include "nm-setting-olpc-mesh.h"
#include "nm-device-wifi.h" #include "nm-device-wifi.h"
#include "nm-device-olpc-mesh.h" #include "nm-device-olpc-mesh.h"
#include "nm-device-iwd.h"
#include "settings/nm-settings-connection.h" #include "settings/nm-settings-connection.h"
#include "platform/nm-platform.h" #include "platform/nm-platform.h"
#include "nm-config.h"
/*****************************************************************************/ /*****************************************************************************/
...@@ -75,6 +77,7 @@ create_device (NMDeviceFactory *factory, ...@@ -75,6 +77,7 @@ create_device (NMDeviceFactory *factory,
{ {
NMDeviceWifiCapabilities capabilities; NMDeviceWifiCapabilities capabilities;
NM80211Mode mode; NM80211Mode mode;
gs_free char *backend = NULL;
g_return_val_if_fail (iface != NULL, NULL); g_return_val_if_fail (iface != NULL, NULL);
g_return_val_if_fail (plink != NULL, NULL); g_return_val_if_fail (plink != NULL, NULL);
...@@ -98,10 +101,24 @@ create_device (NMDeviceFactory *factory, ...@@ -98,10 +101,24 @@ create_device (NMDeviceFactory *factory,
return NULL; return NULL;
} }
if (plink->type == NM_LINK_TYPE_WIFI) if (plink->type != NM_LINK_TYPE_WIFI)
return nm_device_wifi_new (iface, capabilities);
else
return nm_device_olpc_mesh_new (iface); return nm_device_olpc_mesh_new (iface);
backend = nm_config_data_get_value (NM_CONFIG_GET_DATA,
NM_CONFIG_KEYFILE_GROUP_MAIN,
NM_CONFIG_KEYFILE_KEY_MAIN_WIFI_BACKEND,
NM_CONFIG_GET_VALUE_STRIP);
nm_log_dbg (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;
} }
/*****************************************************************************/ /*****************************************************************************/
......