2008-11-04 22:36:51 +00:00
|
|
|
/* -*- Mode: C; tab-width: 4; indent-tabs-mode: t; c-basic-offset: 4 -*- */
|
2006-11-25 15:41:04 +00:00
|
|
|
/* 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.
|
|
|
|
|
*
|
2008-06-26 18:31:52 +00:00
|
|
|
* 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.
|
2006-11-25 15:41:04 +00:00
|
|
|
*
|
2012-02-20 15:06:05 -06:00
|
|
|
* Copyright (C) 2006 - 2012 Red Hat, Inc.
|
2008-11-04 22:36:51 +00:00
|
|
|
* Copyright (C) 2006 - 2008 Novell, Inc.
|
2006-11-25 15:41:04 +00:00
|
|
|
*/
|
|
|
|
|
|
2014-11-13 10:07:02 -05:00
|
|
|
#include "config.h"
|
|
|
|
|
|
2007-02-05 12:14:09 +00:00
|
|
|
#include <stdio.h>
|
2006-11-25 15:41:04 +00:00
|
|
|
#include <string.h>
|
|
|
|
|
|
2015-07-17 14:38:54 +02:00
|
|
|
#include "nm-default.h"
|
2013-12-10 16:18:17 +01:00
|
|
|
#include "NetworkManagerUtils.h"
|
2006-11-25 15:41:04 +00:00
|
|
|
#include "nm-supplicant-interface.h"
|
2006-12-19 19:15:31 +00:00
|
|
|
#include "nm-supplicant-config.h"
|
2015-02-02 02:31:30 -06:00
|
|
|
#include "nm-core-internal.h"
|
2015-04-13 10:28:17 -04:00
|
|
|
#include "nm-dbus-compat.h"
|
2006-11-25 15:41:04 +00:00
|
|
|
|
2006-11-25 18:23:06 +00:00
|
|
|
#define WPAS_DBUS_IFACE_INTERFACE WPAS_DBUS_INTERFACE ".Interface"
|
2010-11-22 08:25:09 -06:00
|
|
|
#define WPAS_DBUS_IFACE_BSS WPAS_DBUS_INTERFACE ".BSS"
|
2007-02-05 12:14:09 +00:00
|
|
|
#define WPAS_DBUS_IFACE_NETWORK WPAS_DBUS_INTERFACE ".Network"
|
|
|
|
|
#define WPAS_ERROR_INVALID_IFACE WPAS_DBUS_INTERFACE ".InvalidInterface"
|
2010-11-18 17:02:04 -06:00
|
|
|
#define WPAS_ERROR_EXISTS_ERROR WPAS_DBUS_INTERFACE ".InterfaceExists"
|
2007-02-05 12:14:09 +00:00
|
|
|
|
2010-11-22 08:25:09 -06:00
|
|
|
G_DEFINE_TYPE (NMSupplicantInterface, nm_supplicant_interface, G_TYPE_OBJECT)
|
2007-02-05 12:14:09 +00:00
|
|
|
|
2006-11-25 15:41:04 +00:00
|
|
|
#define NM_SUPPLICANT_INTERFACE_GET_PRIVATE(o) (G_TYPE_INSTANCE_GET_PRIVATE ((o), \
|
|
|
|
|
NM_TYPE_SUPPLICANT_INTERFACE, \
|
|
|
|
|
NMSupplicantInterfacePrivate))
|
|
|
|
|
|
|
|
|
|
/* Signals */
|
|
|
|
|
enum {
|
2011-12-19 19:47:43 -06:00
|
|
|
STATE, /* change in the interface's state */
|
|
|
|
|
REMOVED, /* interface was removed by the supplicant */
|
|
|
|
|
NEW_BSS, /* interface saw a new access point from a scan */
|
2012-02-20 15:06:05 -06:00
|
|
|
BSS_UPDATED, /* a BSS property changed */
|
2012-03-02 18:17:34 -06:00
|
|
|
BSS_REMOVED, /* supplicant removed BSS from its scan list */
|
2011-12-19 19:47:43 -06:00
|
|
|
SCAN_DONE, /* wifi scan is complete */
|
|
|
|
|
CONNECTION_ERROR, /* an error occurred during a connection request */
|
|
|
|
|
CREDENTIALS_REQUEST, /* 802.1x identity or password requested */
|
2006-11-25 15:41:04 +00:00
|
|
|
LAST_SIGNAL
|
|
|
|
|
};
|
2010-10-05 14:19:43 -05:00
|
|
|
static guint signals[LAST_SIGNAL] = { 0 };
|
2006-11-25 15:41:04 +00:00
|
|
|
|
|
|
|
|
|
|
|
|
|
/* Properties */
|
2016-01-19 16:08:29 +01:00
|
|
|
NM_GOBJECT_PROPERTIES_DEFINE (NMSupplicantInterface,
|
|
|
|
|
PROP_IFACE,
|
2009-05-13 11:16:29 -04:00
|
|
|
PROP_SCANNING,
|
2015-04-05 23:31:02 -05:00
|
|
|
PROP_CURRENT_BSS,
|
2016-01-19 16:08:29 +01:00
|
|
|
PROP_IS_WIRELESS,
|
|
|
|
|
PROP_FAST_SUPPORTED,
|
|
|
|
|
PROP_AP_SUPPORT,
|
|
|
|
|
);
|
2006-11-25 15:41:04 +00:00
|
|
|
|
2010-10-06 11:05:21 -05:00
|
|
|
typedef struct {
|
2015-02-01 03:19:32 -06:00
|
|
|
char * dev;
|
2016-01-19 16:08:29 +01:00
|
|
|
bool is_wireless;
|
|
|
|
|
bool fast_supported;
|
2015-02-01 03:19:32 -06:00
|
|
|
gboolean has_credreq; /* Whether querying 802.1x credentials is supported */
|
2015-10-06 20:02:40 -05:00
|
|
|
NMSupplicantFeature ap_support; /* Lightweight AP mode support */
|
2015-10-06 21:31:04 -05:00
|
|
|
NMSupplicantFeature mac_randomization_support;
|
2015-02-01 03:19:32 -06:00
|
|
|
guint32 max_scan_ssids;
|
|
|
|
|
guint32 ready_count;
|
|
|
|
|
|
|
|
|
|
char * object_path;
|
|
|
|
|
guint32 state;
|
|
|
|
|
int disconnect_reason;
|
|
|
|
|
|
|
|
|
|
gboolean scanning;
|
|
|
|
|
|
2015-02-02 02:31:30 -06:00
|
|
|
GDBusProxy * wpas_proxy;
|
|
|
|
|
GCancellable * init_cancellable;
|
|
|
|
|
GDBusProxy * iface_proxy;
|
|
|
|
|
GCancellable * other_cancellable;
|
|
|
|
|
GCancellable * assoc_cancellable;
|
2015-02-01 03:19:32 -06:00
|
|
|
char * net_path;
|
|
|
|
|
guint32 blobs_left;
|
|
|
|
|
GHashTable * bss_proxies;
|
2015-04-05 23:31:02 -05:00
|
|
|
char * current_bss;
|
2015-02-01 03:19:32 -06:00
|
|
|
|
|
|
|
|
gint32 last_scan; /* timestamp as returned by nm_utils_get_monotonic_timestamp_s() */
|
|
|
|
|
|
|
|
|
|
NMSupplicantConfig *cfg;
|
2007-02-05 12:14:09 +00:00
|
|
|
} NMSupplicantInterfacePrivate;
|
2006-11-25 15:41:04 +00:00
|
|
|
|
2015-02-02 02:31:30 -06:00
|
|
|
/***************************************************************/
|
2006-12-19 19:15:31 +00:00
|
|
|
|
2012-02-20 15:06:05 -06:00
|
|
|
static void
|
2015-02-02 02:31:30 -06:00
|
|
|
emit_error_helper (NMSupplicantInterface *self, GError *error)
|
2012-02-20 15:06:05 -06:00
|
|
|
{
|
2015-02-02 02:31:30 -06:00
|
|
|
char *name = NULL;
|
2012-02-20 15:06:05 -06:00
|
|
|
|
2015-02-02 02:31:30 -06:00
|
|
|
if (g_dbus_error_is_remote_error (error))
|
|
|
|
|
name = g_dbus_error_get_remote_error (error);
|
|
|
|
|
|
|
|
|
|
g_signal_emit (self, signals[CONNECTION_ERROR], 0, name, error->message);
|
|
|
|
|
g_free (name);
|
2006-11-25 18:23:06 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
static void
|
2015-02-02 02:31:30 -06:00
|
|
|
bss_props_changed_cb (GDBusProxy *proxy,
|
|
|
|
|
GVariant *changed_properties,
|
|
|
|
|
char **invalidated_properties,
|
|
|
|
|
gpointer user_data)
|
2012-02-20 15:06:05 -06:00
|
|
|
{
|
|
|
|
|
NMSupplicantInterface *self = NM_SUPPLICANT_INTERFACE (user_data);
|
2012-06-07 15:04:14 -05:00
|
|
|
NMSupplicantInterfacePrivate *priv = NM_SUPPLICANT_INTERFACE_GET_PRIVATE (self);
|
|
|
|
|
|
|
|
|
|
if (priv->scanning)
|
2013-12-10 16:18:17 +01:00
|
|
|
priv->last_scan = nm_utils_get_monotonic_timestamp_s ();
|
2012-02-20 15:06:05 -06:00
|
|
|
|
2015-02-02 02:31:30 -06:00
|
|
|
g_signal_emit (self, signals[BSS_UPDATED], 0,
|
|
|
|
|
g_dbus_proxy_get_object_path (proxy),
|
|
|
|
|
changed_properties);
|
2012-02-22 14:44:05 -06:00
|
|
|
}
|
2012-02-20 15:06:05 -06:00
|
|
|
|
2015-09-30 17:05:40 +02:00
|
|
|
static GVariant *
|
|
|
|
|
_get_bss_proxy_properties (NMSupplicantInterface *self, GDBusProxy *proxy)
|
|
|
|
|
{
|
|
|
|
|
gs_strfreev char **properties = NULL;
|
|
|
|
|
GVariantBuilder builder;
|
|
|
|
|
char **iter;
|
|
|
|
|
|
|
|
|
|
iter = properties = g_dbus_proxy_get_cached_property_names (proxy);
|
|
|
|
|
if (!iter)
|
|
|
|
|
return NULL;
|
|
|
|
|
|
|
|
|
|
g_variant_builder_init (&builder, G_VARIANT_TYPE ("a{sv}"));
|
|
|
|
|
while (*iter) {
|
|
|
|
|
GVariant *copy = g_dbus_proxy_get_cached_property (proxy, *iter);
|
|
|
|
|
|
|
|
|
|
g_variant_builder_add (&builder, "{sv}", *iter++, copy);
|
|
|
|
|
g_variant_unref (copy);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
return g_variant_builder_end (&builder);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
#define BSS_PROXY_INITED "bss-proxy-inited"
|
|
|
|
|
|
2012-02-20 15:06:05 -06:00
|
|
|
static void
|
2015-02-02 02:31:30 -06:00
|
|
|
on_bss_proxy_acquired (GDBusProxy *proxy, GAsyncResult *result, gpointer user_data)
|
2006-11-25 18:23:06 +00:00
|
|
|
{
|
2015-02-02 02:31:30 -06:00
|
|
|
NMSupplicantInterface *self;
|
|
|
|
|
gs_free_error GError *error = NULL;
|
|
|
|
|
gs_unref_variant GVariant *props = NULL;
|
|
|
|
|
|
|
|
|
|
if (!g_async_initable_init_finish (G_ASYNC_INITABLE (proxy), result, &error)) {
|
|
|
|
|
if (!g_error_matches (error, G_IO_ERROR, G_IO_ERROR_CANCELLED)) {
|
|
|
|
|
nm_log_dbg (LOGD_SUPPLICANT, "Failed to acquire BSS proxy: (%s)", error->message);
|
|
|
|
|
g_hash_table_remove (NM_SUPPLICANT_INTERFACE_GET_PRIVATE (user_data)->bss_proxies,
|
|
|
|
|
g_dbus_proxy_get_object_path (proxy));
|
|
|
|
|
}
|
2012-02-20 15:06:05 -06:00
|
|
|
return;
|
2015-02-02 02:31:30 -06:00
|
|
|
}
|
2012-02-20 15:06:05 -06:00
|
|
|
|
2015-02-02 02:31:30 -06:00
|
|
|
self = NM_SUPPLICANT_INTERFACE (user_data);
|
2015-09-30 17:05:40 +02:00
|
|
|
props = _get_bss_proxy_properties (self, proxy);
|
|
|
|
|
if (!props)
|
|
|
|
|
return;
|
2012-06-07 15:04:14 -05:00
|
|
|
|
2015-09-30 17:05:40 +02:00
|
|
|
g_object_set_data (G_OBJECT (proxy), BSS_PROXY_INITED, GUINT_TO_POINTER (TRUE));
|
2012-06-07 15:04:14 -05:00
|
|
|
|
2015-02-02 02:31:30 -06:00
|
|
|
g_signal_emit (self, signals[NEW_BSS], 0,
|
|
|
|
|
g_dbus_proxy_get_object_path (proxy),
|
|
|
|
|
g_variant_ref_sink (props));
|
2012-02-20 15:06:05 -06:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
static void
|
2015-02-02 02:31:30 -06:00
|
|
|
handle_new_bss (NMSupplicantInterface *self, const char *object_path)
|
2012-02-20 15:06:05 -06:00
|
|
|
{
|
|
|
|
|
NMSupplicantInterfacePrivate *priv = NM_SUPPLICANT_INTERFACE_GET_PRIVATE (self);
|
2015-02-02 02:31:30 -06:00
|
|
|
GDBusProxy *bss_proxy;
|
2012-02-20 15:06:05 -06:00
|
|
|
|
2015-02-02 02:31:30 -06:00
|
|
|
g_return_if_fail (object_path != NULL);
|
2006-11-25 15:41:04 +00:00
|
|
|
|
2015-02-02 02:31:30 -06:00
|
|
|
if (g_hash_table_lookup (priv->bss_proxies, object_path))
|
|
|
|
|
return;
|
2006-12-04 05:45:05 +00:00
|
|
|
|
2015-02-02 02:31:30 -06:00
|
|
|
bss_proxy = g_object_new (G_TYPE_DBUS_PROXY,
|
|
|
|
|
"g-bus-type", G_BUS_TYPE_SYSTEM,
|
|
|
|
|
"g-flags", G_DBUS_PROXY_FLAGS_NONE,
|
|
|
|
|
"g-name", WPAS_DBUS_SERVICE,
|
|
|
|
|
"g-object-path", object_path,
|
|
|
|
|
"g-interface-name", WPAS_DBUS_IFACE_BSS,
|
|
|
|
|
NULL);
|
|
|
|
|
g_hash_table_insert (priv->bss_proxies,
|
|
|
|
|
(char *) g_dbus_proxy_get_object_path (bss_proxy),
|
|
|
|
|
bss_proxy);
|
|
|
|
|
g_signal_connect (bss_proxy, "g-properties-changed", G_CALLBACK (bss_props_changed_cb), self);
|
|
|
|
|
g_async_initable_init_async (G_ASYNC_INITABLE (bss_proxy),
|
|
|
|
|
G_PRIORITY_DEFAULT,
|
|
|
|
|
priv->other_cancellable,
|
|
|
|
|
(GAsyncReadyCallback) on_bss_proxy_acquired,
|
|
|
|
|
self);
|
2006-12-04 05:45:05 +00:00
|
|
|
}
|
|
|
|
|
|
2010-10-06 11:05:21 -05:00
|
|
|
static void
|
|
|
|
|
set_state (NMSupplicantInterface *self, guint32 new_state)
|
|
|
|
|
{
|
|
|
|
|
NMSupplicantInterfacePrivate *priv = NM_SUPPLICANT_INTERFACE_GET_PRIVATE (self);
|
|
|
|
|
guint32 old_state = priv->state;
|
|
|
|
|
|
|
|
|
|
g_return_if_fail (new_state < NM_SUPPLICANT_INTERFACE_STATE_LAST);
|
|
|
|
|
|
|
|
|
|
if (new_state == priv->state)
|
|
|
|
|
return;
|
|
|
|
|
|
|
|
|
|
/* DOWN is a terminal state */
|
|
|
|
|
g_return_if_fail (priv->state != NM_SUPPLICANT_INTERFACE_STATE_DOWN);
|
|
|
|
|
|
2010-12-07 13:58:49 -06:00
|
|
|
/* Cannot regress to READY, STARTING, or INIT from higher states */
|
|
|
|
|
if (priv->state >= NM_SUPPLICANT_INTERFACE_STATE_READY)
|
2010-12-11 12:33:15 -06:00
|
|
|
g_return_if_fail (new_state > NM_SUPPLICANT_INTERFACE_STATE_READY);
|
2010-10-06 11:05:21 -05:00
|
|
|
|
2012-05-02 13:04:23 -05:00
|
|
|
if (new_state == NM_SUPPLICANT_INTERFACE_STATE_READY) {
|
2015-02-02 02:31:30 -06:00
|
|
|
if (priv->other_cancellable) {
|
|
|
|
|
g_warn_if_fail (priv->other_cancellable == NULL);
|
|
|
|
|
g_cancellable_cancel (priv->other_cancellable);
|
|
|
|
|
g_clear_object (&priv->other_cancellable);
|
2010-10-11 20:30:40 -05:00
|
|
|
}
|
2015-02-02 02:31:30 -06:00
|
|
|
priv->other_cancellable = g_cancellable_new ();
|
|
|
|
|
} else if (new_state == NM_SUPPLICANT_INTERFACE_STATE_DOWN) {
|
|
|
|
|
if (priv->init_cancellable)
|
|
|
|
|
g_cancellable_cancel (priv->init_cancellable);
|
|
|
|
|
g_clear_object (&priv->init_cancellable);
|
|
|
|
|
|
|
|
|
|
if (priv->other_cancellable)
|
|
|
|
|
g_cancellable_cancel (priv->other_cancellable);
|
|
|
|
|
g_clear_object (&priv->other_cancellable);
|
|
|
|
|
|
|
|
|
|
if (priv->iface_proxy)
|
|
|
|
|
g_signal_handlers_disconnect_by_data (priv->iface_proxy, self);
|
2010-10-06 11:05:21 -05:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
priv->state = new_state;
|
2012-06-07 15:04:14 -05:00
|
|
|
|
|
|
|
|
if ( priv->state == NM_SUPPLICANT_INTERFACE_STATE_SCANNING
|
|
|
|
|
|| old_state == NM_SUPPLICANT_INTERFACE_STATE_SCANNING)
|
2013-12-10 16:18:17 +01:00
|
|
|
priv->last_scan = nm_utils_get_monotonic_timestamp_s ();
|
2012-06-07 15:04:14 -05:00
|
|
|
|
2012-09-12 11:58:41 -05:00
|
|
|
/* Disconnect reason is no longer relevant when not in the DISCONNECTED state */
|
|
|
|
|
if (priv->state != NM_SUPPLICANT_INTERFACE_STATE_DISCONNECTED)
|
|
|
|
|
priv->disconnect_reason = 0;
|
|
|
|
|
|
|
|
|
|
g_signal_emit (self, signals[STATE], 0,
|
|
|
|
|
priv->state,
|
|
|
|
|
old_state,
|
|
|
|
|
priv->disconnect_reason);
|
2010-10-06 11:05:21 -05:00
|
|
|
}
|
|
|
|
|
|
2015-02-02 02:31:30 -06:00
|
|
|
static int
|
|
|
|
|
wpas_state_string_to_enum (const char *str_state)
|
|
|
|
|
{
|
|
|
|
|
if (!strcmp (str_state, "interface_disabled"))
|
|
|
|
|
return NM_SUPPLICANT_INTERFACE_STATE_DISABLED;
|
|
|
|
|
else if (!strcmp (str_state, "disconnected"))
|
|
|
|
|
return NM_SUPPLICANT_INTERFACE_STATE_DISCONNECTED;
|
|
|
|
|
else if (!strcmp (str_state, "inactive"))
|
|
|
|
|
return NM_SUPPLICANT_INTERFACE_STATE_INACTIVE;
|
|
|
|
|
else if (!strcmp (str_state, "scanning"))
|
|
|
|
|
return NM_SUPPLICANT_INTERFACE_STATE_SCANNING;
|
|
|
|
|
else if (!strcmp (str_state, "authenticating"))
|
|
|
|
|
return NM_SUPPLICANT_INTERFACE_STATE_AUTHENTICATING;
|
|
|
|
|
else if (!strcmp (str_state, "associating"))
|
|
|
|
|
return NM_SUPPLICANT_INTERFACE_STATE_ASSOCIATING;
|
|
|
|
|
else if (!strcmp (str_state, "associated"))
|
|
|
|
|
return NM_SUPPLICANT_INTERFACE_STATE_ASSOCIATED;
|
|
|
|
|
else if (!strcmp (str_state, "4way_handshake"))
|
|
|
|
|
return NM_SUPPLICANT_INTERFACE_STATE_4WAY_HANDSHAKE;
|
|
|
|
|
else if (!strcmp (str_state, "group_handshake"))
|
|
|
|
|
return NM_SUPPLICANT_INTERFACE_STATE_GROUP_HANDSHAKE;
|
|
|
|
|
else if (!strcmp (str_state, "completed"))
|
|
|
|
|
return NM_SUPPLICANT_INTERFACE_STATE_COMPLETED;
|
|
|
|
|
|
|
|
|
|
nm_log_warn (LOGD_SUPPLICANT, "Unknown supplicant state '%s'", str_state);
|
|
|
|
|
return -1;
|
|
|
|
|
}
|
|
|
|
|
|
2006-12-04 05:45:05 +00:00
|
|
|
static void
|
2010-11-22 08:25:09 -06:00
|
|
|
set_state_from_string (NMSupplicantInterface *self, const char *new_state)
|
2006-12-04 05:45:05 +00:00
|
|
|
{
|
2010-11-22 08:25:09 -06:00
|
|
|
int state;
|
2010-10-11 20:35:54 -05:00
|
|
|
|
2010-11-22 08:25:09 -06:00
|
|
|
state = wpas_state_string_to_enum (new_state);
|
|
|
|
|
g_warn_if_fail (state > 0);
|
|
|
|
|
if (state > 0)
|
|
|
|
|
set_state (self, (guint32) state);
|
2006-12-04 05:45:05 +00:00
|
|
|
}
|
|
|
|
|
|
2006-12-12 03:27:35 +00:00
|
|
|
static void
|
2010-11-22 08:25:09 -06:00
|
|
|
set_scanning (NMSupplicantInterface *self, gboolean new_scanning)
|
2006-12-12 03:27:35 +00:00
|
|
|
{
|
2010-11-22 08:25:09 -06:00
|
|
|
NMSupplicantInterfacePrivate *priv = NM_SUPPLICANT_INTERFACE_GET_PRIVATE (self);
|
2007-02-05 12:14:09 +00:00
|
|
|
|
2010-11-22 08:25:09 -06:00
|
|
|
if (priv->scanning != new_scanning) {
|
|
|
|
|
priv->scanning = new_scanning;
|
|
|
|
|
|
|
|
|
|
/* Cache time of last scan completion */
|
2012-06-07 13:45:51 -05:00
|
|
|
if (priv->scanning == FALSE)
|
2013-12-10 16:18:17 +01:00
|
|
|
priv->last_scan = nm_utils_get_monotonic_timestamp_s ();
|
2010-10-11 20:35:54 -05:00
|
|
|
|
2016-01-19 16:08:29 +01:00
|
|
|
_notify (self, PROP_SCANNING);
|
2006-12-12 03:27:35 +00:00
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
2010-11-22 08:25:09 -06:00
|
|
|
gboolean
|
|
|
|
|
nm_supplicant_interface_get_scanning (NMSupplicantInterface *self)
|
|
|
|
|
{
|
|
|
|
|
NMSupplicantInterfacePrivate *priv;
|
|
|
|
|
|
|
|
|
|
g_return_val_if_fail (self != NULL, FALSE);
|
|
|
|
|
|
|
|
|
|
priv = NM_SUPPLICANT_INTERFACE_GET_PRIVATE (self);
|
|
|
|
|
if (priv->scanning)
|
|
|
|
|
return TRUE;
|
|
|
|
|
if (priv->state == NM_SUPPLICANT_INTERFACE_STATE_SCANNING)
|
|
|
|
|
return TRUE;
|
|
|
|
|
return FALSE;
|
|
|
|
|
}
|
|
|
|
|
|
2015-04-05 23:31:02 -05:00
|
|
|
const char *
|
|
|
|
|
nm_supplicant_interface_get_current_bss (NMSupplicantInterface *self)
|
|
|
|
|
{
|
|
|
|
|
NMSupplicantInterfacePrivate *priv;
|
|
|
|
|
|
|
|
|
|
g_return_val_if_fail (self != NULL, FALSE);
|
|
|
|
|
|
|
|
|
|
priv = NM_SUPPLICANT_INTERFACE_GET_PRIVATE (self);
|
|
|
|
|
return priv->state >= NM_SUPPLICANT_INTERFACE_STATE_READY ? priv->current_bss : NULL;
|
|
|
|
|
}
|
|
|
|
|
|
2013-12-10 16:18:17 +01:00
|
|
|
gint32
|
2012-06-07 15:04:14 -05:00
|
|
|
nm_supplicant_interface_get_last_scan_time (NMSupplicantInterface *self)
|
|
|
|
|
{
|
|
|
|
|
return NM_SUPPLICANT_INTERFACE_GET_PRIVATE (self)->last_scan;
|
|
|
|
|
}
|
|
|
|
|
|
2015-02-02 02:31:30 -06:00
|
|
|
#define MATCH_PROPERTY(p, n, v, t) (!strcmp (p, n) && g_variant_is_of_type (v, t))
|
2006-11-25 15:41:04 +00:00
|
|
|
|
2012-05-01 17:59:35 -05:00
|
|
|
static void
|
2015-02-02 02:31:30 -06:00
|
|
|
parse_capabilities (NMSupplicantInterface *self, GVariant *capabilities)
|
2012-05-01 17:59:35 -05:00
|
|
|
{
|
|
|
|
|
NMSupplicantInterfacePrivate *priv = NM_SUPPLICANT_INTERFACE_GET_PRIVATE (self);
|
|
|
|
|
gboolean have_active = FALSE, have_ssid = FALSE;
|
2015-02-02 02:31:30 -06:00
|
|
|
gint32 max_scan_ssids = -1;
|
|
|
|
|
const char **array;
|
2012-05-01 17:59:35 -05:00
|
|
|
|
2015-02-02 02:31:30 -06:00
|
|
|
g_return_if_fail (capabilities && g_variant_is_of_type (capabilities, G_VARIANT_TYPE_VARDICT));
|
2012-05-01 17:59:35 -05:00
|
|
|
|
2015-02-02 02:31:30 -06:00
|
|
|
if (g_variant_lookup (capabilities, "Scan", "^a&s", &array)) {
|
|
|
|
|
if (_nm_utils_string_in_list ("active", array))
|
|
|
|
|
have_active = TRUE;
|
|
|
|
|
if (_nm_utils_string_in_list ("ssid", array))
|
|
|
|
|
have_ssid = TRUE;
|
|
|
|
|
g_free (array);
|
2012-05-01 17:59:35 -05:00
|
|
|
}
|
|
|
|
|
|
2015-02-02 02:31:30 -06:00
|
|
|
if (g_variant_lookup (capabilities, "MaxScanSSID", "i", &max_scan_ssids)) {
|
2012-05-01 17:59:35 -05:00
|
|
|
/* We need active scan and SSID probe capabilities to care about MaxScanSSIDs */
|
2015-02-02 02:31:30 -06:00
|
|
|
if (max_scan_ssids > 0 && have_active && have_ssid) {
|
2012-05-01 17:59:35 -05:00
|
|
|
/* wpa_supplicant's WPAS_MAX_SCAN_SSIDS value is 16, but for speed
|
|
|
|
|
* and to ensure we don't disclose too many SSIDs from the hidden
|
|
|
|
|
* list, we'll limit to 5.
|
|
|
|
|
*/
|
2015-02-02 02:31:30 -06:00
|
|
|
priv->max_scan_ssids = CLAMP (max_scan_ssids, 0, 5);
|
2012-05-01 17:59:35 -05:00
|
|
|
nm_log_info (LOGD_SUPPLICANT, "(%s) supports %d scan SSIDs",
|
2016-01-19 22:10:14 +01:00
|
|
|
priv->dev, priv->max_scan_ssids);
|
2012-09-12 11:58:41 -05:00
|
|
|
}
|
|
|
|
|
}
|
2010-11-22 08:25:09 -06:00
|
|
|
}
|
|
|
|
|
|
2012-05-02 13:04:23 -05:00
|
|
|
static void
|
|
|
|
|
iface_check_ready (NMSupplicantInterface *self)
|
|
|
|
|
{
|
|
|
|
|
NMSupplicantInterfacePrivate *priv = NM_SUPPLICANT_INTERFACE_GET_PRIVATE (self);
|
|
|
|
|
|
|
|
|
|
if (priv->ready_count && priv->state < NM_SUPPLICANT_INTERFACE_STATE_READY) {
|
|
|
|
|
priv->ready_count--;
|
|
|
|
|
if (priv->ready_count == 0)
|
|
|
|
|
set_state (self, NM_SUPPLICANT_INTERFACE_STATE_READY);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
2011-12-19 19:47:43 -06:00
|
|
|
gboolean
|
|
|
|
|
nm_supplicant_interface_credentials_reply (NMSupplicantInterface *self,
|
|
|
|
|
const char *field,
|
|
|
|
|
const char *value,
|
|
|
|
|
GError **error)
|
|
|
|
|
{
|
|
|
|
|
NMSupplicantInterfacePrivate *priv;
|
2015-02-02 02:31:30 -06:00
|
|
|
gs_unref_variant GVariant *reply = NULL;
|
2011-12-19 19:47:43 -06:00
|
|
|
|
|
|
|
|
g_return_val_if_fail (NM_IS_SUPPLICANT_INTERFACE (self), FALSE);
|
|
|
|
|
g_return_val_if_fail (field != NULL, FALSE);
|
|
|
|
|
g_return_val_if_fail (value != NULL, FALSE);
|
|
|
|
|
|
|
|
|
|
priv = NM_SUPPLICANT_INTERFACE_GET_PRIVATE (self);
|
|
|
|
|
g_return_val_if_fail (priv->has_credreq == TRUE, FALSE);
|
|
|
|
|
|
|
|
|
|
/* Need a network block object path */
|
|
|
|
|
g_return_val_if_fail (priv->net_path, FALSE);
|
2015-02-02 02:31:30 -06:00
|
|
|
reply = g_dbus_proxy_call_sync (priv->iface_proxy,
|
|
|
|
|
"NetworkReply",
|
|
|
|
|
g_variant_new ("(oss)",
|
|
|
|
|
priv->net_path,
|
|
|
|
|
field,
|
|
|
|
|
value),
|
|
|
|
|
G_DBUS_CALL_FLAGS_NONE,
|
|
|
|
|
5000,
|
|
|
|
|
NULL,
|
|
|
|
|
error);
|
2015-04-21 09:52:25 -04:00
|
|
|
if (error && *error)
|
|
|
|
|
g_dbus_error_strip_remote_error (*error);
|
|
|
|
|
|
2015-02-02 02:31:30 -06:00
|
|
|
return !!reply;
|
2011-12-19 19:47:43 -06:00
|
|
|
}
|
|
|
|
|
|
2011-12-19 17:21:41 -06:00
|
|
|
static void
|
2015-02-02 02:31:30 -06:00
|
|
|
iface_check_netreply_cb (GDBusProxy *proxy, GAsyncResult *result, gpointer user_data)
|
2011-12-19 17:21:41 -06:00
|
|
|
{
|
2015-02-02 02:31:30 -06:00
|
|
|
NMSupplicantInterface *self;
|
|
|
|
|
NMSupplicantInterfacePrivate *priv;
|
|
|
|
|
gs_unref_variant GVariant *variant = NULL;
|
|
|
|
|
gs_free_error GError *error = NULL;
|
|
|
|
|
|
|
|
|
|
/* We know NetworkReply is supported if the NetworkReply method returned
|
|
|
|
|
* successfully (which is unexpected since we sent a bogus network
|
|
|
|
|
* object path) or if we got an "InvalidArgs" (which indicates NetworkReply
|
|
|
|
|
* is supported). We know it's not supported if we get an
|
|
|
|
|
* "UnknownMethod" error.
|
|
|
|
|
*/
|
2011-12-19 17:21:41 -06:00
|
|
|
|
2015-02-02 02:31:30 -06:00
|
|
|
variant = g_dbus_proxy_call_finish (proxy, result, &error);
|
|
|
|
|
if (g_error_matches (error, G_IO_ERROR, G_IO_ERROR_CANCELLED))
|
|
|
|
|
return;
|
2012-05-02 13:04:23 -05:00
|
|
|
|
2015-02-02 02:31:30 -06:00
|
|
|
self = NM_SUPPLICANT_INTERFACE (user_data);
|
|
|
|
|
priv = NM_SUPPLICANT_INTERFACE_GET_PRIVATE (self);
|
2011-12-19 17:21:41 -06:00
|
|
|
|
2015-03-27 09:04:41 -04:00
|
|
|
if (variant || _nm_dbus_error_has_name (error, "fi.w1.wpa_supplicant1.InvalidArgs"))
|
2015-02-02 02:31:30 -06:00
|
|
|
priv->has_credreq = TRUE;
|
2011-12-19 17:21:41 -06:00
|
|
|
|
2015-02-02 02:31:30 -06:00
|
|
|
nm_log_dbg (LOGD_SUPPLICANT, "Supplicant %s network credentials requests",
|
|
|
|
|
priv->has_credreq ? "supports" : "does not support");
|
|
|
|
|
|
|
|
|
|
iface_check_ready (self);
|
2011-12-19 17:21:41 -06:00
|
|
|
}
|
|
|
|
|
|
2015-10-06 20:02:40 -05:00
|
|
|
NMSupplicantFeature
|
2012-09-18 17:33:57 -05:00
|
|
|
nm_supplicant_interface_get_ap_support (NMSupplicantInterface *self)
|
|
|
|
|
{
|
|
|
|
|
return NM_SUPPLICANT_INTERFACE_GET_PRIVATE (self)->ap_support;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
void
|
|
|
|
|
nm_supplicant_interface_set_ap_support (NMSupplicantInterface *self,
|
2015-10-06 20:02:40 -05:00
|
|
|
NMSupplicantFeature ap_support)
|
2012-09-18 17:33:57 -05:00
|
|
|
{
|
|
|
|
|
NMSupplicantInterfacePrivate *priv = NM_SUPPLICANT_INTERFACE_GET_PRIVATE (self);
|
|
|
|
|
|
|
|
|
|
/* Use the best indicator of support between the supplicant global
|
|
|
|
|
* Capabilities property and the interface's introspection data.
|
|
|
|
|
*/
|
|
|
|
|
if (ap_support > priv->ap_support)
|
|
|
|
|
priv->ap_support = ap_support;
|
|
|
|
|
}
|
|
|
|
|
|
2015-10-06 21:31:04 -05:00
|
|
|
NMSupplicantFeature
|
|
|
|
|
nm_supplicant_interface_get_mac_randomization_support (NMSupplicantInterface *self)
|
|
|
|
|
{
|
|
|
|
|
return NM_SUPPLICANT_INTERFACE_GET_PRIVATE (self)->mac_randomization_support;
|
|
|
|
|
}
|
|
|
|
|
|
2015-10-07 16:03:16 -05:00
|
|
|
static void
|
|
|
|
|
set_preassoc_scan_mac_cb (GDBusProxy *proxy, GAsyncResult *result, gpointer user_data)
|
|
|
|
|
{
|
|
|
|
|
gs_unref_variant GVariant *variant = NULL;
|
|
|
|
|
gs_free_error GError *error = NULL;
|
|
|
|
|
|
|
|
|
|
variant = _nm_dbus_proxy_call_finish (proxy, result,
|
|
|
|
|
G_VARIANT_TYPE ("()"),
|
|
|
|
|
&error);
|
|
|
|
|
if (g_error_matches (error, G_IO_ERROR, G_IO_ERROR_CANCELLED))
|
|
|
|
|
return;
|
|
|
|
|
if (error)
|
|
|
|
|
nm_log_warn (LOGD_SUPPLICANT, "Failed to enable scan MAC address randomization");
|
|
|
|
|
|
|
|
|
|
iface_check_ready (NM_SUPPLICANT_INTERFACE (user_data));
|
|
|
|
|
}
|
|
|
|
|
|
2012-09-18 17:33:57 -05:00
|
|
|
static void
|
2015-10-06 21:31:04 -05:00
|
|
|
iface_introspect_cb (GDBusProxy *proxy, GAsyncResult *result, gpointer user_data)
|
2012-09-18 17:33:57 -05:00
|
|
|
{
|
2015-02-02 02:31:30 -06:00
|
|
|
NMSupplicantInterface *self;
|
|
|
|
|
NMSupplicantInterfacePrivate *priv;
|
|
|
|
|
gs_unref_variant GVariant *variant = NULL;
|
|
|
|
|
gs_free_error GError *error = NULL;
|
|
|
|
|
const char *data;
|
2012-09-18 17:33:57 -05:00
|
|
|
|
2015-03-27 08:45:35 -04:00
|
|
|
variant = _nm_dbus_proxy_call_finish (proxy, result,
|
|
|
|
|
G_VARIANT_TYPE ("(s)"),
|
|
|
|
|
&error);
|
2015-02-02 02:31:30 -06:00
|
|
|
if (g_error_matches (error, G_IO_ERROR, G_IO_ERROR_CANCELLED))
|
|
|
|
|
return;
|
|
|
|
|
|
|
|
|
|
self = NM_SUPPLICANT_INTERFACE (user_data);
|
|
|
|
|
priv = NM_SUPPLICANT_INTERFACE_GET_PRIVATE (self);
|
|
|
|
|
|
2015-03-27 08:45:35 -04:00
|
|
|
if (variant) {
|
2015-02-02 02:31:30 -06:00
|
|
|
g_variant_get (variant, "(&s)", &data);
|
2015-10-06 21:31:04 -05:00
|
|
|
|
|
|
|
|
/* The ProbeRequest method only exists if AP mode has been enabled */
|
2015-02-02 02:31:30 -06:00
|
|
|
if (strstr (data, "ProbeRequest"))
|
2015-10-06 20:02:40 -05:00
|
|
|
priv->ap_support = NM_SUPPLICANT_FEATURE_YES;
|
2015-10-06 21:31:04 -05:00
|
|
|
|
2015-10-07 16:03:16 -05:00
|
|
|
if (strstr (data, "PreassocMacAddr")) {
|
2015-10-06 21:31:04 -05:00
|
|
|
priv->mac_randomization_support = NM_SUPPLICANT_FEATURE_YES;
|
2015-10-07 16:03:16 -05:00
|
|
|
|
|
|
|
|
/* Turn on MAC randomization during scans by default */
|
|
|
|
|
priv->ready_count++;
|
|
|
|
|
g_dbus_proxy_call (priv->iface_proxy,
|
|
|
|
|
DBUS_INTERFACE_PROPERTIES ".Set",
|
|
|
|
|
g_variant_new ("(ssv)",
|
|
|
|
|
WPAS_DBUS_IFACE_INTERFACE,
|
|
|
|
|
"PreassocMacAddr",
|
|
|
|
|
g_variant_new_string ("1")),
|
|
|
|
|
G_DBUS_CALL_FLAGS_NONE,
|
|
|
|
|
-1,
|
|
|
|
|
priv->init_cancellable,
|
|
|
|
|
(GAsyncReadyCallback) set_preassoc_scan_mac_cb,
|
|
|
|
|
self);
|
|
|
|
|
}
|
2012-09-18 17:33:57 -05:00
|
|
|
}
|
|
|
|
|
|
2013-06-05 08:01:46 -05:00
|
|
|
iface_check_ready (self);
|
2012-09-18 17:33:57 -05:00
|
|
|
}
|
|
|
|
|
|
2015-03-27 08:03:22 -04:00
|
|
|
static void
|
|
|
|
|
wpas_iface_scan_done (GDBusProxy *proxy,
|
|
|
|
|
gboolean success,
|
|
|
|
|
gpointer user_data)
|
|
|
|
|
{
|
|
|
|
|
NMSupplicantInterface *self = NM_SUPPLICANT_INTERFACE (user_data);
|
|
|
|
|
NMSupplicantInterfacePrivate *priv = NM_SUPPLICANT_INTERFACE_GET_PRIVATE (self);
|
2015-09-30 17:05:40 +02:00
|
|
|
GVariant *props;
|
|
|
|
|
GHashTableIter iter;
|
|
|
|
|
char *bss_path;
|
|
|
|
|
GDBusProxy *bss_proxy;
|
2015-03-27 08:03:22 -04:00
|
|
|
|
|
|
|
|
/* Cache last scan completed time */
|
|
|
|
|
priv->last_scan = nm_utils_get_monotonic_timestamp_s ();
|
|
|
|
|
|
|
|
|
|
g_signal_emit (self, signals[SCAN_DONE], 0, success);
|
2015-09-30 17:05:40 +02:00
|
|
|
|
|
|
|
|
/* Emit NEW_BSS so that wifi device has the APs (in case it removed them) */
|
|
|
|
|
g_hash_table_iter_init (&iter, priv->bss_proxies);
|
|
|
|
|
while (g_hash_table_iter_next (&iter, (gpointer) &bss_path, (gpointer) &bss_proxy)) {
|
|
|
|
|
if (g_object_get_data (G_OBJECT (bss_proxy), BSS_PROXY_INITED)) {
|
|
|
|
|
props = _get_bss_proxy_properties (self, bss_proxy);
|
|
|
|
|
if (props) {
|
|
|
|
|
g_signal_emit (self, signals[NEW_BSS], 0,
|
|
|
|
|
bss_path,
|
|
|
|
|
g_variant_ref_sink (props));
|
|
|
|
|
g_variant_unref (props);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
2015-03-27 08:03:22 -04:00
|
|
|
}
|
2015-02-02 02:31:30 -06:00
|
|
|
|
2012-09-18 17:33:57 -05:00
|
|
|
static void
|
2015-03-27 08:03:22 -04:00
|
|
|
wpas_iface_bss_added (GDBusProxy *proxy,
|
|
|
|
|
const char *path,
|
|
|
|
|
GVariant *props,
|
|
|
|
|
gpointer user_data)
|
2012-09-18 17:33:57 -05:00
|
|
|
{
|
2015-02-02 02:31:30 -06:00
|
|
|
NMSupplicantInterface *self = NM_SUPPLICANT_INTERFACE (user_data);
|
2012-09-18 17:33:57 -05:00
|
|
|
NMSupplicantInterfacePrivate *priv = NM_SUPPLICANT_INTERFACE_GET_PRIVATE (self);
|
|
|
|
|
|
2015-03-27 08:03:22 -04:00
|
|
|
if (priv->scanning)
|
2015-02-02 02:31:30 -06:00
|
|
|
priv->last_scan = nm_utils_get_monotonic_timestamp_s ();
|
2012-09-18 17:33:57 -05:00
|
|
|
|
2015-03-27 08:03:22 -04:00
|
|
|
handle_new_bss (self, path);
|
|
|
|
|
}
|
2015-02-02 02:31:30 -06:00
|
|
|
|
2015-03-27 08:03:22 -04:00
|
|
|
static void
|
|
|
|
|
wpas_iface_bss_removed (GDBusProxy *proxy,
|
|
|
|
|
const char *path,
|
|
|
|
|
gpointer user_data)
|
|
|
|
|
{
|
|
|
|
|
NMSupplicantInterface *self = NM_SUPPLICANT_INTERFACE (user_data);
|
|
|
|
|
NMSupplicantInterfacePrivate *priv = NM_SUPPLICANT_INTERFACE_GET_PRIVATE (self);
|
|
|
|
|
|
|
|
|
|
g_signal_emit (self, signals[BSS_REMOVED], 0, path);
|
|
|
|
|
g_hash_table_remove (priv->bss_proxies, path);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
static void
|
|
|
|
|
wpas_iface_network_request (GDBusProxy *proxy,
|
|
|
|
|
const char *path,
|
|
|
|
|
const char *field,
|
|
|
|
|
const char *message,
|
|
|
|
|
gpointer user_data)
|
|
|
|
|
{
|
|
|
|
|
NMSupplicantInterface *self = NM_SUPPLICANT_INTERFACE (user_data);
|
|
|
|
|
NMSupplicantInterfacePrivate *priv = NM_SUPPLICANT_INTERFACE_GET_PRIVATE (self);
|
|
|
|
|
|
|
|
|
|
if (priv->has_credreq && priv->net_path && !g_strcmp0 (path, priv->net_path))
|
|
|
|
|
g_signal_emit (self, signals[CREDENTIALS_REQUEST], 0, field, message);
|
2012-09-18 17:33:57 -05:00
|
|
|
}
|
|
|
|
|
|
2006-11-25 15:41:04 +00:00
|
|
|
static void
|
2015-02-02 02:31:30 -06:00
|
|
|
props_changed_cb (GDBusProxy *proxy,
|
|
|
|
|
GVariant *changed_properties,
|
|
|
|
|
GStrv invalidated_properties,
|
|
|
|
|
gpointer user_data)
|
2010-10-06 11:05:21 -05:00
|
|
|
{
|
2015-02-02 02:31:30 -06:00
|
|
|
NMSupplicantInterface *self = NM_SUPPLICANT_INTERFACE (user_data);
|
2010-10-06 11:05:21 -05:00
|
|
|
NMSupplicantInterfacePrivate *priv = NM_SUPPLICANT_INTERFACE_GET_PRIVATE (self);
|
2015-02-02 02:31:30 -06:00
|
|
|
const char *s, **array, **iter;
|
|
|
|
|
gboolean b = FALSE;
|
|
|
|
|
gint32 i32;
|
|
|
|
|
GVariant *v;
|
|
|
|
|
|
2015-04-05 23:31:02 -05:00
|
|
|
g_object_freeze_notify (G_OBJECT (self));
|
|
|
|
|
|
2015-02-02 02:31:30 -06:00
|
|
|
if (g_variant_lookup (changed_properties, "Scanning", "b", &b))
|
|
|
|
|
set_scanning (self, b);
|
|
|
|
|
|
|
|
|
|
if ( g_variant_lookup (changed_properties, "State", "&s", &s)
|
|
|
|
|
&& priv->state >= NM_SUPPLICANT_INTERFACE_STATE_READY) {
|
|
|
|
|
/* Only transition to actual wpa_supplicant interface states (ie,
|
|
|
|
|
* anything > READY) after the NMSupplicantInterface has had a
|
|
|
|
|
* chance to initialize, which is signalled by entering the READY
|
|
|
|
|
* state.
|
|
|
|
|
*/
|
|
|
|
|
set_state_from_string (self, s);
|
|
|
|
|
}
|
2010-10-06 11:05:21 -05:00
|
|
|
|
2015-09-30 13:08:05 +02:00
|
|
|
if (g_variant_lookup (changed_properties, "BSSs", "^a&o", &array)) {
|
2015-02-02 02:31:30 -06:00
|
|
|
iter = array;
|
|
|
|
|
while (*iter)
|
|
|
|
|
handle_new_bss (self, *iter++);
|
|
|
|
|
g_free (array);
|
|
|
|
|
}
|
2010-10-06 11:05:21 -05:00
|
|
|
|
2015-04-05 23:31:02 -05:00
|
|
|
if (g_variant_lookup (changed_properties, "CurrentBSS", "&o", &s)) {
|
|
|
|
|
if (strcmp (s, "/") == 0)
|
|
|
|
|
s = NULL;
|
|
|
|
|
if (g_strcmp0 (s, priv->current_bss) != 0) {
|
|
|
|
|
g_free (priv->current_bss);
|
|
|
|
|
priv->current_bss = g_strdup (s);
|
2016-01-19 16:08:29 +01:00
|
|
|
_notify (self, PROP_CURRENT_BSS);
|
2015-04-05 23:31:02 -05:00
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
2015-02-02 02:31:30 -06:00
|
|
|
v = g_variant_lookup_value (changed_properties, "Capabilities", G_VARIANT_TYPE_VARDICT);
|
|
|
|
|
if (v) {
|
|
|
|
|
parse_capabilities (self, v);
|
|
|
|
|
g_variant_unref (v);
|
|
|
|
|
}
|
2012-09-18 17:33:57 -05:00
|
|
|
|
2015-02-02 02:31:30 -06:00
|
|
|
if (g_variant_lookup (changed_properties, "DisconnectReason", "i", &i32)) {
|
|
|
|
|
/* Disconnect reason is currently only given for deauthentication events,
|
|
|
|
|
* not disassociation; currently they are IEEE 802.11 "reason codes",
|
|
|
|
|
* defined by (IEEE 802.11-2007, 7.3.1.7, Table 7-22). Any locally caused
|
|
|
|
|
* deauthentication will be negative, while authentications caused by the
|
|
|
|
|
* AP will be positive.
|
|
|
|
|
*/
|
|
|
|
|
priv->disconnect_reason = i32;
|
|
|
|
|
if (priv->disconnect_reason != 0) {
|
|
|
|
|
nm_log_warn (LOGD_SUPPLICANT, "Connection disconnected (reason %d)",
|
|
|
|
|
priv->disconnect_reason);
|
|
|
|
|
}
|
|
|
|
|
}
|
2015-04-05 23:31:02 -05:00
|
|
|
|
|
|
|
|
g_object_thaw_notify (G_OBJECT (self));
|
2010-10-06 11:05:21 -05:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
static void
|
2015-02-02 02:31:30 -06:00
|
|
|
on_iface_proxy_acquired (GDBusProxy *proxy, GAsyncResult *result, gpointer user_data)
|
2006-11-25 15:41:04 +00:00
|
|
|
{
|
2015-02-02 02:31:30 -06:00
|
|
|
NMSupplicantInterface *self;
|
|
|
|
|
NMSupplicantInterfacePrivate *priv;
|
|
|
|
|
gs_free_error GError *error = NULL;
|
2007-02-05 12:14:09 +00:00
|
|
|
|
2015-02-02 02:31:30 -06:00
|
|
|
if (!g_async_initable_init_finish (G_ASYNC_INITABLE (proxy), result, &error)) {
|
|
|
|
|
if (!g_error_matches (error, G_IO_ERROR, G_IO_ERROR_CANCELLED)) {
|
|
|
|
|
nm_log_warn (LOGD_SUPPLICANT, "Failed to acquire wpa_supplicant interface proxy: (%s)", error->message);
|
|
|
|
|
set_state (NM_SUPPLICANT_INTERFACE (user_data), NM_SUPPLICANT_INTERFACE_STATE_DOWN);
|
|
|
|
|
}
|
|
|
|
|
return;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
self = NM_SUPPLICANT_INTERFACE (user_data);
|
|
|
|
|
priv = NM_SUPPLICANT_INTERFACE_GET_PRIVATE (self);
|
|
|
|
|
|
2015-03-27 08:03:22 -04:00
|
|
|
_nm_dbus_signal_connect (priv->iface_proxy, "ScanDone", G_VARIANT_TYPE ("(b)"),
|
|
|
|
|
G_CALLBACK (wpas_iface_scan_done), self);
|
|
|
|
|
_nm_dbus_signal_connect (priv->iface_proxy, "BSSAdded", G_VARIANT_TYPE ("(oa{sv})"),
|
|
|
|
|
G_CALLBACK (wpas_iface_bss_added), self);
|
|
|
|
|
_nm_dbus_signal_connect (priv->iface_proxy, "BSSRemoved", G_VARIANT_TYPE ("(o)"),
|
|
|
|
|
G_CALLBACK (wpas_iface_bss_removed), self);
|
|
|
|
|
_nm_dbus_signal_connect (priv->iface_proxy, "NetworkRequest", G_VARIANT_TYPE ("(oss)"),
|
|
|
|
|
G_CALLBACK (wpas_iface_network_request), self);
|
2015-02-02 02:31:30 -06:00
|
|
|
|
2015-04-16 12:05:05 -05:00
|
|
|
/* Scan result aging parameters */
|
|
|
|
|
g_dbus_proxy_call (priv->iface_proxy,
|
|
|
|
|
"org.freedesktop.DBus.Properties.Set",
|
|
|
|
|
g_variant_new ("(ssv)",
|
|
|
|
|
WPAS_DBUS_IFACE_INTERFACE,
|
|
|
|
|
"BSSExpireAge",
|
|
|
|
|
g_variant_new_uint32 (250)),
|
|
|
|
|
G_DBUS_CALL_FLAGS_NONE,
|
|
|
|
|
-1,
|
|
|
|
|
priv->init_cancellable,
|
|
|
|
|
NULL,
|
|
|
|
|
NULL);
|
|
|
|
|
g_dbus_proxy_call (priv->iface_proxy,
|
|
|
|
|
"org.freedesktop.DBus.Properties.Set",
|
|
|
|
|
g_variant_new ("(ssv)",
|
|
|
|
|
WPAS_DBUS_IFACE_INTERFACE,
|
|
|
|
|
"BSSExpireCount",
|
|
|
|
|
g_variant_new_uint32 (2)),
|
|
|
|
|
G_DBUS_CALL_FLAGS_NONE,
|
|
|
|
|
-1,
|
|
|
|
|
priv->init_cancellable,
|
|
|
|
|
NULL,
|
|
|
|
|
NULL);
|
|
|
|
|
|
2015-02-02 02:31:30 -06:00
|
|
|
/* Check whether NetworkReply and AP mode are supported */
|
|
|
|
|
priv->ready_count = 1;
|
|
|
|
|
g_dbus_proxy_call (priv->iface_proxy,
|
|
|
|
|
"NetworkReply",
|
|
|
|
|
g_variant_new ("(oss)",
|
|
|
|
|
"/fff",
|
|
|
|
|
"foobar",
|
|
|
|
|
"foobar"),
|
|
|
|
|
G_DBUS_CALL_FLAGS_NONE,
|
|
|
|
|
-1,
|
|
|
|
|
priv->init_cancellable,
|
|
|
|
|
(GAsyncReadyCallback) iface_check_netreply_cb,
|
|
|
|
|
self);
|
|
|
|
|
|
2015-10-06 21:31:04 -05:00
|
|
|
if (priv->ap_support == NM_SUPPLICANT_FEATURE_UNKNOWN ||
|
|
|
|
|
priv->mac_randomization_support == NM_SUPPLICANT_FEATURE_UNKNOWN) {
|
2015-02-02 02:31:30 -06:00
|
|
|
/* If the global supplicant capabilities property is not present, we can
|
|
|
|
|
* fall back to checking whether the ProbeRequest method is supported. If
|
|
|
|
|
* neither of these works we have no way of determining if AP mode is
|
|
|
|
|
* supported or not. hostap 1.0 and earlier don't support either of these.
|
|
|
|
|
*/
|
|
|
|
|
priv->ready_count++;
|
|
|
|
|
g_dbus_proxy_call (priv->iface_proxy,
|
2015-04-13 10:28:17 -04:00
|
|
|
DBUS_INTERFACE_INTROSPECTABLE ".Introspect",
|
2015-02-02 02:31:30 -06:00
|
|
|
NULL,
|
|
|
|
|
G_DBUS_CALL_FLAGS_NONE,
|
|
|
|
|
-1,
|
|
|
|
|
priv->init_cancellable,
|
2015-10-06 21:31:04 -05:00
|
|
|
(GAsyncReadyCallback) iface_introspect_cb,
|
2015-02-02 02:31:30 -06:00
|
|
|
self);
|
2006-11-25 15:41:04 +00:00
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
static void
|
2015-02-02 02:31:30 -06:00
|
|
|
interface_add_done (NMSupplicantInterface *self, const char *path)
|
2006-11-25 15:41:04 +00:00
|
|
|
{
|
2007-02-05 12:14:09 +00:00
|
|
|
NMSupplicantInterfacePrivate *priv = NM_SUPPLICANT_INTERFACE_GET_PRIVATE (self);
|
|
|
|
|
|
2015-02-02 02:31:30 -06:00
|
|
|
nm_log_dbg (LOGD_SUPPLICANT, "(%s): interface added to supplicant", priv->dev);
|
|
|
|
|
|
|
|
|
|
priv->object_path = g_strdup (path);
|
|
|
|
|
priv->iface_proxy = g_object_new (G_TYPE_DBUS_PROXY,
|
|
|
|
|
"g-bus-type", G_BUS_TYPE_SYSTEM,
|
|
|
|
|
"g-flags", G_DBUS_PROXY_FLAGS_NONE,
|
|
|
|
|
"g-name", WPAS_DBUS_SERVICE,
|
|
|
|
|
"g-object-path", priv->object_path,
|
|
|
|
|
"g-interface-name", WPAS_DBUS_IFACE_INTERFACE,
|
|
|
|
|
NULL);
|
|
|
|
|
g_signal_connect (priv->iface_proxy, "g-properties-changed", G_CALLBACK (props_changed_cb), self);
|
|
|
|
|
g_async_initable_init_async (G_ASYNC_INITABLE (priv->iface_proxy),
|
|
|
|
|
G_PRIORITY_DEFAULT,
|
|
|
|
|
priv->init_cancellable,
|
|
|
|
|
(GAsyncReadyCallback) on_iface_proxy_acquired,
|
|
|
|
|
self);
|
2010-10-06 11:05:21 -05:00
|
|
|
}
|
2006-11-25 15:41:04 +00:00
|
|
|
|
2010-10-06 11:05:21 -05:00
|
|
|
static void
|
2015-02-02 02:31:30 -06:00
|
|
|
interface_get_cb (GDBusProxy *proxy, GAsyncResult *result, gpointer user_data)
|
2010-10-06 11:05:21 -05:00
|
|
|
{
|
2015-02-02 02:31:30 -06:00
|
|
|
NMSupplicantInterface *self;
|
|
|
|
|
NMSupplicantInterfacePrivate *priv;
|
|
|
|
|
gs_unref_variant GVariant *variant = NULL;
|
|
|
|
|
gs_free_error GError *error = NULL;
|
2015-03-27 08:45:35 -04:00
|
|
|
const char *path;
|
2015-02-02 02:31:30 -06:00
|
|
|
|
2015-03-27 08:45:35 -04:00
|
|
|
variant = _nm_dbus_proxy_call_finish (proxy, result,
|
|
|
|
|
G_VARIANT_TYPE ("(o)"),
|
|
|
|
|
&error);
|
2015-02-02 02:31:30 -06:00
|
|
|
if (g_error_matches (error, G_IO_ERROR, G_IO_ERROR_CANCELLED))
|
|
|
|
|
return;
|
2006-11-25 15:41:04 +00:00
|
|
|
|
2015-02-02 02:31:30 -06:00
|
|
|
self = NM_SUPPLICANT_INTERFACE (user_data);
|
|
|
|
|
priv = NM_SUPPLICANT_INTERFACE_GET_PRIVATE (self);
|
|
|
|
|
|
2015-03-27 08:45:35 -04:00
|
|
|
if (variant) {
|
|
|
|
|
g_variant_get (variant, "(&o)", &path);
|
2013-06-05 08:01:46 -05:00
|
|
|
interface_add_done (self, path);
|
2010-10-06 11:05:21 -05:00
|
|
|
} else {
|
2015-04-21 09:52:25 -04:00
|
|
|
g_dbus_error_strip_remote_error (error);
|
2015-02-02 02:31:30 -06:00
|
|
|
nm_log_err (LOGD_SUPPLICANT, "(%s): error getting interface: %s", priv->dev, error->message);
|
|
|
|
|
set_state (self, NM_SUPPLICANT_INTERFACE_STATE_DOWN);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
static void
|
|
|
|
|
interface_add_cb (GDBusProxy *proxy, GAsyncResult *result, gpointer user_data)
|
|
|
|
|
{
|
|
|
|
|
NMSupplicantInterface *self;
|
|
|
|
|
NMSupplicantInterfacePrivate *priv;
|
|
|
|
|
gs_free_error GError *error = NULL;
|
|
|
|
|
gs_unref_variant GVariant *variant = NULL;
|
2015-03-27 08:45:35 -04:00
|
|
|
const char *path;
|
2015-02-02 02:31:30 -06:00
|
|
|
|
2015-03-27 08:45:35 -04:00
|
|
|
variant = _nm_dbus_proxy_call_finish (proxy, result,
|
|
|
|
|
G_VARIANT_TYPE ("(o)"),
|
|
|
|
|
&error);
|
2015-02-02 02:31:30 -06:00
|
|
|
if (g_error_matches (error, G_IO_ERROR, G_IO_ERROR_CANCELLED))
|
|
|
|
|
return;
|
|
|
|
|
|
|
|
|
|
self = NM_SUPPLICANT_INTERFACE (user_data);
|
|
|
|
|
priv = NM_SUPPLICANT_INTERFACE_GET_PRIVATE (self);
|
|
|
|
|
|
2015-03-27 08:45:35 -04:00
|
|
|
if (variant) {
|
|
|
|
|
g_variant_get (variant, "(&o)", &path);
|
2015-02-02 02:31:30 -06:00
|
|
|
interface_add_done (self, path);
|
2015-03-27 09:04:41 -04:00
|
|
|
} else if (_nm_dbus_error_has_name (error, WPAS_ERROR_EXISTS_ERROR)) {
|
2015-02-02 02:31:30 -06:00
|
|
|
/* Interface already added, just get its object path */
|
|
|
|
|
g_dbus_proxy_call (priv->wpas_proxy,
|
|
|
|
|
"GetInterface",
|
|
|
|
|
g_variant_new ("(s)", priv->dev),
|
|
|
|
|
G_DBUS_CALL_FLAGS_NONE,
|
|
|
|
|
-1,
|
|
|
|
|
priv->init_cancellable,
|
|
|
|
|
(GAsyncReadyCallback) interface_get_cb,
|
|
|
|
|
self);
|
|
|
|
|
} else if ( g_error_matches (error, G_DBUS_ERROR, G_DBUS_ERROR_SERVICE_UNKNOWN)
|
|
|
|
|
|| g_error_matches (error, G_DBUS_ERROR, G_DBUS_ERROR_SPAWN_EXEC_FAILED)
|
|
|
|
|
|| g_error_matches (error, G_DBUS_ERROR, G_DBUS_ERROR_SPAWN_FORK_FAILED)
|
|
|
|
|
|| g_error_matches (error, G_DBUS_ERROR, G_DBUS_ERROR_SPAWN_FAILED)
|
|
|
|
|
|| g_error_matches (error, G_DBUS_ERROR, G_DBUS_ERROR_TIMEOUT)
|
|
|
|
|
|| g_error_matches (error, G_DBUS_ERROR, G_DBUS_ERROR_NO_REPLY)
|
|
|
|
|
|| g_error_matches (error, G_DBUS_ERROR, G_DBUS_ERROR_TIMED_OUT)
|
|
|
|
|
|| g_error_matches (error, G_DBUS_ERROR, G_DBUS_ERROR_SPAWN_SERVICE_NOT_FOUND)) {
|
|
|
|
|
/* Supplicant wasn't running and could not be launched via service
|
|
|
|
|
* activation. Wait for it to start by moving back to the INIT
|
|
|
|
|
* state.
|
|
|
|
|
*/
|
2015-04-21 09:52:25 -04:00
|
|
|
g_dbus_error_strip_remote_error (error);
|
2015-02-02 02:31:30 -06:00
|
|
|
nm_log_dbg (LOGD_SUPPLICANT, "(%s): failed to activate supplicant: %s",
|
|
|
|
|
priv->dev, error->message);
|
|
|
|
|
set_state (self, NM_SUPPLICANT_INTERFACE_STATE_INIT);
|
|
|
|
|
} else {
|
2015-04-21 09:52:25 -04:00
|
|
|
g_dbus_error_strip_remote_error (error);
|
2015-02-02 02:31:30 -06:00
|
|
|
nm_log_err (LOGD_SUPPLICANT, "(%s): error adding interface: %s", priv->dev, error->message);
|
|
|
|
|
set_state (self, NM_SUPPLICANT_INTERFACE_STATE_DOWN);
|
2006-11-25 15:41:04 +00:00
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
2012-02-29 23:11:04 -06:00
|
|
|
#if HAVE_WEXT
|
|
|
|
|
#define DEFAULT_WIFI_DRIVER "nl80211,wext"
|
|
|
|
|
#else
|
|
|
|
|
#define DEFAULT_WIFI_DRIVER "nl80211"
|
|
|
|
|
#endif
|
|
|
|
|
|
2006-11-25 15:41:04 +00:00
|
|
|
static void
|
2015-02-02 02:31:30 -06:00
|
|
|
on_wpas_proxy_acquired (GDBusProxy *proxy, GAsyncResult *result, gpointer user_data)
|
2006-11-25 15:41:04 +00:00
|
|
|
{
|
2015-02-02 02:31:30 -06:00
|
|
|
NMSupplicantInterface *self;
|
|
|
|
|
NMSupplicantInterfacePrivate *priv;
|
|
|
|
|
gs_free_error GError *error = NULL;
|
|
|
|
|
GDBusProxy *wpas_proxy;
|
|
|
|
|
GVariantBuilder props;
|
|
|
|
|
|
|
|
|
|
wpas_proxy = g_dbus_proxy_new_for_bus_finish (result, &error);
|
|
|
|
|
if (!wpas_proxy) {
|
|
|
|
|
if (!g_error_matches (error, G_IO_ERROR, G_IO_ERROR_CANCELLED)) {
|
|
|
|
|
nm_log_warn (LOGD_SUPPLICANT, "Failed to acquire wpa_supplicant proxy: (%s)",
|
|
|
|
|
error ? error->message : "unknown");
|
|
|
|
|
set_state (NM_SUPPLICANT_INTERFACE (user_data), NM_SUPPLICANT_INTERFACE_STATE_DOWN);
|
|
|
|
|
}
|
|
|
|
|
return;
|
|
|
|
|
}
|
2006-11-25 15:41:04 +00:00
|
|
|
|
2015-02-02 02:31:30 -06:00
|
|
|
self = NM_SUPPLICANT_INTERFACE (user_data);
|
|
|
|
|
priv = NM_SUPPLICANT_INTERFACE_GET_PRIVATE (self);
|
2006-11-25 15:41:04 +00:00
|
|
|
|
2015-02-02 02:31:30 -06:00
|
|
|
priv->wpas_proxy = wpas_proxy;
|
2010-10-11 20:30:40 -05:00
|
|
|
|
2010-10-06 11:05:21 -05:00
|
|
|
/* Try to add the interface to the supplicant. If the supplicant isn't
|
|
|
|
|
* running, this will start it via D-Bus activation and return the response
|
|
|
|
|
* when the supplicant has started.
|
|
|
|
|
*/
|
2006-11-25 15:41:04 +00:00
|
|
|
|
2015-02-02 02:31:30 -06:00
|
|
|
g_variant_builder_init (&props, G_VARIANT_TYPE_VARDICT);
|
|
|
|
|
g_variant_builder_add (&props, "{sv}",
|
|
|
|
|
"Driver",
|
|
|
|
|
g_variant_new_string (priv->is_wireless ? DEFAULT_WIFI_DRIVER : "wired"));
|
|
|
|
|
g_variant_builder_add (&props, "{sv}",
|
|
|
|
|
"Ifname",
|
|
|
|
|
g_variant_new_string (priv->dev));
|
|
|
|
|
|
|
|
|
|
g_dbus_proxy_call (priv->wpas_proxy,
|
|
|
|
|
"CreateInterface",
|
|
|
|
|
g_variant_new ("(a{sv})", &props),
|
|
|
|
|
G_DBUS_CALL_FLAGS_NONE,
|
|
|
|
|
-1,
|
|
|
|
|
priv->init_cancellable,
|
|
|
|
|
(GAsyncReadyCallback) interface_add_cb,
|
|
|
|
|
self);
|
|
|
|
|
}
|
2010-11-18 17:02:04 -06:00
|
|
|
|
2015-02-02 02:31:30 -06:00
|
|
|
static void
|
2016-01-19 22:10:14 +01:00
|
|
|
interface_add (NMSupplicantInterface *self)
|
2015-02-02 02:31:30 -06:00
|
|
|
{
|
|
|
|
|
NMSupplicantInterfacePrivate *priv = NM_SUPPLICANT_INTERFACE_GET_PRIVATE (self);
|
2006-11-25 15:41:04 +00:00
|
|
|
|
2015-02-02 02:31:30 -06:00
|
|
|
/* Can only start the interface from INIT state */
|
|
|
|
|
g_return_if_fail (priv->state == NM_SUPPLICANT_INTERFACE_STATE_INIT);
|
2006-11-25 15:41:04 +00:00
|
|
|
|
2015-02-02 02:31:30 -06:00
|
|
|
nm_log_dbg (LOGD_SUPPLICANT, "(%s): adding interface to supplicant", priv->dev);
|
2006-11-25 15:41:04 +00:00
|
|
|
|
2015-02-02 02:31:30 -06:00
|
|
|
/* Move to starting to prevent double-calls of interface_add() */
|
|
|
|
|
set_state (self, NM_SUPPLICANT_INTERFACE_STATE_STARTING);
|
|
|
|
|
|
|
|
|
|
g_warn_if_fail (priv->init_cancellable == NULL);
|
|
|
|
|
g_clear_object (&priv->init_cancellable);
|
|
|
|
|
priv->init_cancellable = g_cancellable_new ();
|
|
|
|
|
|
|
|
|
|
g_dbus_proxy_new_for_bus (G_BUS_TYPE_SYSTEM,
|
|
|
|
|
G_DBUS_PROXY_FLAGS_DO_NOT_LOAD_PROPERTIES |
|
|
|
|
|
G_DBUS_PROXY_FLAGS_DO_NOT_CONNECT_SIGNALS,
|
|
|
|
|
NULL,
|
|
|
|
|
WPAS_DBUS_SERVICE,
|
|
|
|
|
WPAS_DBUS_PATH,
|
|
|
|
|
WPAS_DBUS_INTERFACE,
|
|
|
|
|
priv->init_cancellable,
|
|
|
|
|
(GAsyncReadyCallback) on_wpas_proxy_acquired,
|
|
|
|
|
self);
|
2006-11-25 15:41:04 +00:00
|
|
|
}
|
|
|
|
|
|
2015-02-01 03:08:16 -06:00
|
|
|
void
|
|
|
|
|
nm_supplicant_interface_set_supplicant_available (NMSupplicantInterface *self,
|
|
|
|
|
gboolean available)
|
2006-11-25 15:41:04 +00:00
|
|
|
{
|
2016-01-19 22:10:14 +01:00
|
|
|
NMSupplicantInterfacePrivate *priv;
|
|
|
|
|
|
|
|
|
|
g_return_if_fail (NM_IS_SUPPLICANT_INTERFACE (self));
|
|
|
|
|
|
|
|
|
|
priv = NM_SUPPLICANT_INTERFACE_GET_PRIVATE (self);
|
2010-10-06 11:05:21 -05:00
|
|
|
|
2015-02-01 03:08:16 -06:00
|
|
|
if (available) {
|
2010-10-06 11:05:21 -05:00
|
|
|
/* This can happen if the supplicant couldn't be activated but
|
|
|
|
|
* for some reason was started after the activation failure.
|
|
|
|
|
*/
|
|
|
|
|
if (priv->state == NM_SUPPLICANT_INTERFACE_STATE_INIT)
|
2016-01-19 22:10:14 +01:00
|
|
|
interface_add (self);
|
2010-10-06 11:05:21 -05:00
|
|
|
} else {
|
|
|
|
|
/* The supplicant stopped; so we must tear down the interface */
|
|
|
|
|
set_state (self, NM_SUPPLICANT_INTERFACE_STATE_DOWN);
|
2006-11-25 15:41:04 +00:00
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
static void
|
2015-02-02 02:31:30 -06:00
|
|
|
log_result_cb (GDBusProxy *proxy, GAsyncResult *result, gpointer user_data)
|
2006-12-19 19:15:31 +00:00
|
|
|
{
|
2015-02-02 02:31:30 -06:00
|
|
|
gs_unref_variant GVariant *reply = NULL;
|
|
|
|
|
gs_free_error GError *error = NULL;
|
2006-12-19 19:15:31 +00:00
|
|
|
|
2015-02-02 02:31:30 -06:00
|
|
|
reply = g_dbus_proxy_call_finish (proxy, result, &error);
|
2015-04-06 11:00:20 -05:00
|
|
|
if ( !reply
|
|
|
|
|
&& !g_error_matches (error, G_IO_ERROR, G_IO_ERROR_CANCELLED)
|
2015-04-21 09:52:25 -04:00
|
|
|
&& !strstr (error->message, "fi.w1.wpa_supplicant1.NotConnected")) {
|
|
|
|
|
g_dbus_error_strip_remote_error (error);
|
2015-04-06 11:00:20 -05:00
|
|
|
nm_log_warn (LOGD_SUPPLICANT, "Failed to %s: %s.", (char *) user_data, error->message);
|
2015-04-21 09:52:25 -04:00
|
|
|
}
|
2007-02-05 12:14:09 +00:00
|
|
|
}
|
2006-12-19 19:15:31 +00:00
|
|
|
|
|
|
|
|
void
|
|
|
|
|
nm_supplicant_interface_disconnect (NMSupplicantInterface * self)
|
|
|
|
|
{
|
2007-02-05 12:14:09 +00:00
|
|
|
NMSupplicantInterfacePrivate *priv;
|
|
|
|
|
|
|
|
|
|
g_return_if_fail (NM_IS_SUPPLICANT_INTERFACE (self));
|
2006-12-19 19:15:31 +00:00
|
|
|
|
2007-02-05 12:14:09 +00:00
|
|
|
priv = NM_SUPPLICANT_INTERFACE_GET_PRIVATE (self);
|
2006-12-19 19:15:31 +00:00
|
|
|
|
2015-02-02 02:31:30 -06:00
|
|
|
/* Cancel all pending calls related to a prior connection attempt */
|
|
|
|
|
if (priv->assoc_cancellable) {
|
|
|
|
|
g_cancellable_cancel (priv->assoc_cancellable);
|
|
|
|
|
g_clear_object (&priv->assoc_cancellable);
|
|
|
|
|
}
|
2006-12-19 19:15:31 +00:00
|
|
|
|
|
|
|
|
/* Don't do anything if there is no connection to the supplicant yet. */
|
2007-02-05 12:14:09 +00:00
|
|
|
if (!priv->iface_proxy)
|
2006-12-19 19:15:31 +00:00
|
|
|
return;
|
|
|
|
|
|
2011-06-29 18:15:05 -05:00
|
|
|
/* Disconnect from the current AP */
|
|
|
|
|
if ( (priv->state >= NM_SUPPLICANT_INTERFACE_STATE_SCANNING)
|
|
|
|
|
&& (priv->state <= NM_SUPPLICANT_INTERFACE_STATE_COMPLETED)) {
|
2015-02-02 02:31:30 -06:00
|
|
|
g_dbus_proxy_call (priv->iface_proxy,
|
|
|
|
|
"Disconnect",
|
|
|
|
|
NULL,
|
|
|
|
|
G_DBUS_CALL_FLAGS_NONE,
|
|
|
|
|
-1,
|
|
|
|
|
NULL,
|
|
|
|
|
(GAsyncReadyCallback) log_result_cb,
|
|
|
|
|
"disconnect");
|
2006-12-19 19:15:31 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/* Remove any network that was added by NetworkManager */
|
2010-11-22 09:05:09 -06:00
|
|
|
if (priv->net_path) {
|
2015-02-02 02:31:30 -06:00
|
|
|
g_dbus_proxy_call (priv->iface_proxy,
|
|
|
|
|
"RemoveNetwork",
|
|
|
|
|
g_variant_new ("(o)", priv->net_path),
|
|
|
|
|
G_DBUS_CALL_FLAGS_NONE,
|
|
|
|
|
-1,
|
|
|
|
|
priv->other_cancellable,
|
|
|
|
|
(GAsyncReadyCallback) log_result_cb,
|
|
|
|
|
"remove network");
|
2010-11-22 09:05:09 -06:00
|
|
|
g_free (priv->net_path);
|
|
|
|
|
priv->net_path = NULL;
|
2007-02-05 12:14:09 +00:00
|
|
|
}
|
2006-12-19 19:15:31 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
static void
|
2015-02-02 02:31:30 -06:00
|
|
|
select_network_cb (GDBusProxy *proxy, GAsyncResult *result, gpointer user_data)
|
2006-12-19 19:15:31 +00:00
|
|
|
{
|
2015-02-02 02:31:30 -06:00
|
|
|
gs_unref_variant GVariant *reply = NULL;
|
|
|
|
|
gs_free_error GError *err = NULL;
|
2006-12-19 19:15:31 +00:00
|
|
|
|
2015-02-02 02:31:30 -06:00
|
|
|
reply = g_dbus_proxy_call_finish (proxy, result, &err);
|
|
|
|
|
if (!reply && !g_error_matches (err, G_IO_ERROR, G_IO_ERROR_CANCELLED)) {
|
2015-04-21 09:52:25 -04:00
|
|
|
g_dbus_error_strip_remote_error (err);
|
2010-04-07 10:13:12 -07:00
|
|
|
nm_log_warn (LOGD_SUPPLICANT, "Couldn't select network config: %s.", err->message);
|
2015-02-02 02:31:30 -06:00
|
|
|
emit_error_helper (NM_SUPPLICANT_INTERFACE (user_data), err);
|
2006-12-19 19:15:31 +00:00
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
static void
|
2010-11-22 09:05:09 -06:00
|
|
|
call_select_network (NMSupplicantInterface *self)
|
2006-11-25 15:41:04 +00:00
|
|
|
{
|
2010-11-22 09:05:09 -06:00
|
|
|
NMSupplicantInterfacePrivate *priv = NM_SUPPLICANT_INTERFACE_GET_PRIVATE (self);
|
2007-10-20 20:31:29 +00:00
|
|
|
|
2010-11-22 22:34:04 -06:00
|
|
|
/* We only select the network after all blobs (if any) have been set */
|
2013-06-05 08:01:46 -05:00
|
|
|
if (priv->blobs_left == 0) {
|
2015-02-02 02:31:30 -06:00
|
|
|
g_dbus_proxy_call (priv->iface_proxy,
|
|
|
|
|
"SelectNetwork",
|
|
|
|
|
g_variant_new ("(o)", priv->net_path),
|
|
|
|
|
G_DBUS_CALL_FLAGS_NONE,
|
|
|
|
|
-1,
|
|
|
|
|
priv->assoc_cancellable,
|
|
|
|
|
(GAsyncReadyCallback) select_network_cb,
|
|
|
|
|
self);
|
2013-06-05 08:01:46 -05:00
|
|
|
}
|
2007-10-20 20:31:29 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
static void
|
2015-02-02 02:31:30 -06:00
|
|
|
add_blob_cb (GDBusProxy *proxy, GAsyncResult *result, gpointer user_data)
|
2007-10-20 20:31:29 +00:00
|
|
|
{
|
2015-02-02 02:31:30 -06:00
|
|
|
NMSupplicantInterface *self;
|
|
|
|
|
NMSupplicantInterfacePrivate *priv;
|
|
|
|
|
gs_unref_variant GVariant *reply = NULL;
|
|
|
|
|
gs_free_error GError *err = NULL;
|
2007-10-20 20:31:29 +00:00
|
|
|
|
2015-02-02 02:31:30 -06:00
|
|
|
reply = g_dbus_proxy_call_finish (proxy, result, &err);
|
|
|
|
|
if (g_error_matches (err, G_IO_ERROR, G_IO_ERROR_CANCELLED))
|
|
|
|
|
return;
|
|
|
|
|
|
|
|
|
|
self = NM_SUPPLICANT_INTERFACE (user_data);
|
|
|
|
|
priv = NM_SUPPLICANT_INTERFACE_GET_PRIVATE (self);
|
2010-11-22 22:34:04 -06:00
|
|
|
|
2015-02-02 02:31:30 -06:00
|
|
|
priv->blobs_left--;
|
|
|
|
|
if (reply)
|
|
|
|
|
call_select_network (self);
|
|
|
|
|
else {
|
2015-04-21 09:52:25 -04:00
|
|
|
g_dbus_error_strip_remote_error (err);
|
2010-04-07 10:13:12 -07:00
|
|
|
nm_log_warn (LOGD_SUPPLICANT, "Couldn't set network certificates: %s.", err->message);
|
2013-06-05 08:01:46 -05:00
|
|
|
emit_error_helper (self, err);
|
2015-02-02 02:31:30 -06:00
|
|
|
}
|
2007-10-20 20:31:29 +00:00
|
|
|
}
|
|
|
|
|
|
2006-12-19 19:15:31 +00:00
|
|
|
static void
|
2015-02-02 02:31:30 -06:00
|
|
|
add_network_cb (GDBusProxy *proxy, GAsyncResult *result, gpointer user_data)
|
2006-12-19 19:15:31 +00:00
|
|
|
{
|
2015-02-02 02:31:30 -06:00
|
|
|
NMSupplicantInterface *self;
|
|
|
|
|
NMSupplicantInterfacePrivate *priv;
|
|
|
|
|
gs_unref_variant GVariant *reply = NULL;
|
|
|
|
|
gs_free_error GError *error = NULL;
|
2010-11-22 09:05:09 -06:00
|
|
|
GHashTable *blobs;
|
2010-11-22 22:34:04 -06:00
|
|
|
GHashTableIter iter;
|
2015-02-02 02:31:30 -06:00
|
|
|
const char *blob_name;
|
|
|
|
|
GByteArray *blob_data;
|
|
|
|
|
|
2015-03-27 08:45:35 -04:00
|
|
|
reply = _nm_dbus_proxy_call_finish (proxy, result,
|
|
|
|
|
G_VARIANT_TYPE ("(o)"),
|
|
|
|
|
&error);
|
2015-02-02 02:31:30 -06:00
|
|
|
if (g_error_matches (error, G_IO_ERROR, G_IO_ERROR_CANCELLED))
|
|
|
|
|
return;
|
|
|
|
|
|
|
|
|
|
self = NM_SUPPLICANT_INTERFACE (user_data);
|
|
|
|
|
priv = NM_SUPPLICANT_INTERFACE_GET_PRIVATE (self);
|
|
|
|
|
|
2010-11-22 09:05:09 -06:00
|
|
|
g_free (priv->net_path);
|
|
|
|
|
priv->net_path = NULL;
|
2007-02-05 12:14:09 +00:00
|
|
|
|
2015-02-02 02:31:30 -06:00
|
|
|
if (error) {
|
2015-04-21 09:52:25 -04:00
|
|
|
g_dbus_error_strip_remote_error (error);
|
2015-02-02 02:31:30 -06:00
|
|
|
nm_log_warn (LOGD_SUPPLICANT, "Adding network to supplicant failed: %s.", error->message);
|
|
|
|
|
emit_error_helper (self, error);
|
2010-11-22 09:05:09 -06:00
|
|
|
return;
|
2006-12-19 19:15:31 +00:00
|
|
|
}
|
2010-11-22 09:05:09 -06:00
|
|
|
|
2015-02-02 02:31:30 -06:00
|
|
|
g_variant_get (reply, "(o)", &priv->net_path);
|
|
|
|
|
|
|
|
|
|
/* Send blobs first; otherwise jump to selecting the network */
|
2010-11-22 09:05:09 -06:00
|
|
|
blobs = nm_supplicant_config_get_blobs (priv->cfg);
|
2010-11-22 22:34:04 -06:00
|
|
|
priv->blobs_left = g_hash_table_size (blobs);
|
2015-02-02 02:31:30 -06:00
|
|
|
|
2010-11-22 22:34:04 -06:00
|
|
|
g_hash_table_iter_init (&iter, blobs);
|
2015-02-02 02:31:30 -06:00
|
|
|
while (g_hash_table_iter_next (&iter, (gpointer) &blob_name, (gpointer) &blob_data)) {
|
|
|
|
|
g_dbus_proxy_call (priv->iface_proxy,
|
|
|
|
|
"AddBlob",
|
|
|
|
|
g_variant_new ("(s@ay)",
|
|
|
|
|
blob_name,
|
|
|
|
|
g_variant_new_fixed_array (G_VARIANT_TYPE_BYTE,
|
|
|
|
|
blob_data->data, blob_data->len, 1)),
|
|
|
|
|
G_DBUS_CALL_FLAGS_NONE,
|
|
|
|
|
-1,
|
|
|
|
|
priv->assoc_cancellable,
|
|
|
|
|
(GAsyncReadyCallback) add_blob_cb,
|
|
|
|
|
self);
|
2010-11-22 22:34:04 -06:00
|
|
|
}
|
|
|
|
|
|
2013-06-05 08:01:46 -05:00
|
|
|
call_select_network (self);
|
2006-12-19 19:15:31 +00:00
|
|
|
}
|
|
|
|
|
|
2015-10-07 16:03:16 -05:00
|
|
|
static void
|
|
|
|
|
add_network (NMSupplicantInterface *self)
|
|
|
|
|
{
|
|
|
|
|
NMSupplicantInterfacePrivate *priv = NM_SUPPLICANT_INTERFACE_GET_PRIVATE (self);
|
|
|
|
|
|
|
|
|
|
g_dbus_proxy_call (priv->iface_proxy,
|
|
|
|
|
"AddNetwork",
|
|
|
|
|
g_variant_new ("(@a{sv})", nm_supplicant_config_to_variant (priv->cfg)),
|
|
|
|
|
G_DBUS_CALL_FLAGS_NONE,
|
|
|
|
|
-1,
|
|
|
|
|
priv->assoc_cancellable,
|
|
|
|
|
(GAsyncReadyCallback) add_network_cb,
|
|
|
|
|
self);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
static void
|
|
|
|
|
set_mac_randomization_cb (GDBusProxy *proxy, GAsyncResult *result, gpointer user_data)
|
|
|
|
|
{
|
|
|
|
|
NMSupplicantInterface *self;
|
|
|
|
|
NMSupplicantInterfacePrivate *priv;
|
|
|
|
|
gs_unref_variant GVariant *reply = NULL;
|
|
|
|
|
gs_free_error GError *error = NULL;
|
|
|
|
|
|
|
|
|
|
reply = g_dbus_proxy_call_finish (proxy, result, &error);
|
|
|
|
|
if (g_error_matches (error, G_IO_ERROR, G_IO_ERROR_CANCELLED))
|
|
|
|
|
return;
|
|
|
|
|
|
|
|
|
|
self = NM_SUPPLICANT_INTERFACE (user_data);
|
|
|
|
|
priv = NM_SUPPLICANT_INTERFACE_GET_PRIVATE (self);
|
|
|
|
|
|
|
|
|
|
if (!reply) {
|
|
|
|
|
g_dbus_error_strip_remote_error (error);
|
|
|
|
|
nm_log_warn (LOGD_SUPPLICANT, "Couldn't send MAC randomization mode to "
|
|
|
|
|
"the supplicant interface: %s.",
|
|
|
|
|
error->message);
|
|
|
|
|
emit_error_helper (self, error);
|
|
|
|
|
return;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
nm_log_info (LOGD_SUPPLICANT, "Config: set MAC randomization to %s",
|
|
|
|
|
nm_supplicant_config_get_mac_randomization (priv->cfg));
|
|
|
|
|
|
|
|
|
|
add_network (self);
|
|
|
|
|
}
|
|
|
|
|
|
2006-12-19 19:15:31 +00:00
|
|
|
static void
|
2015-02-02 02:31:30 -06:00
|
|
|
set_ap_scan_cb (GDBusProxy *proxy, GAsyncResult *result, gpointer user_data)
|
2006-12-19 19:15:31 +00:00
|
|
|
{
|
2015-02-02 02:31:30 -06:00
|
|
|
NMSupplicantInterface *self;
|
|
|
|
|
NMSupplicantInterfacePrivate *priv;
|
|
|
|
|
gs_unref_variant GVariant *reply = NULL;
|
|
|
|
|
gs_free_error GError *error = NULL;
|
2007-02-05 12:14:09 +00:00
|
|
|
|
2015-02-02 02:31:30 -06:00
|
|
|
reply = g_dbus_proxy_call_finish (proxy, result, &error);
|
|
|
|
|
if (g_error_matches (error, G_IO_ERROR, G_IO_ERROR_CANCELLED))
|
|
|
|
|
return;
|
|
|
|
|
|
|
|
|
|
self = NM_SUPPLICANT_INTERFACE (user_data);
|
|
|
|
|
priv = NM_SUPPLICANT_INTERFACE_GET_PRIVATE (self);
|
|
|
|
|
|
|
|
|
|
if (!reply) {
|
2015-04-21 09:52:25 -04:00
|
|
|
g_dbus_error_strip_remote_error (error);
|
2010-04-07 10:13:12 -07:00
|
|
|
nm_log_warn (LOGD_SUPPLICANT, "Couldn't send AP scan mode to the supplicant interface: %s.",
|
2015-02-02 02:31:30 -06:00
|
|
|
error->message);
|
|
|
|
|
emit_error_helper (self, error);
|
2007-11-21 05:57:54 +00:00
|
|
|
return;
|
2006-11-25 15:41:04 +00:00
|
|
|
}
|
2007-11-21 05:57:54 +00:00
|
|
|
|
2010-04-07 10:13:12 -07:00
|
|
|
nm_log_info (LOGD_SUPPLICANT, "Config: set interface ap_scan to %d",
|
|
|
|
|
nm_supplicant_config_get_ap_scan (priv->cfg));
|
2007-11-21 05:57:54 +00:00
|
|
|
|
2015-10-07 16:03:16 -05:00
|
|
|
if (priv->mac_randomization_support == NM_SUPPLICANT_FEATURE_YES) {
|
|
|
|
|
const char *mac_randomization = nm_supplicant_config_get_mac_randomization (priv->cfg);
|
|
|
|
|
|
|
|
|
|
/* Enable/disable association MAC address randomization */
|
|
|
|
|
g_dbus_proxy_call (priv->iface_proxy,
|
|
|
|
|
DBUS_INTERFACE_PROPERTIES ".Set",
|
|
|
|
|
g_variant_new ("(ssv)",
|
|
|
|
|
WPAS_DBUS_IFACE_INTERFACE,
|
|
|
|
|
"MacAddr",
|
|
|
|
|
g_variant_new_string (mac_randomization)),
|
|
|
|
|
G_DBUS_CALL_FLAGS_NONE,
|
|
|
|
|
-1,
|
|
|
|
|
priv->assoc_cancellable,
|
|
|
|
|
(GAsyncReadyCallback) set_mac_randomization_cb,
|
|
|
|
|
self);
|
|
|
|
|
} else {
|
|
|
|
|
add_network (self);
|
|
|
|
|
}
|
2006-11-25 15:41:04 +00:00
|
|
|
}
|
|
|
|
|
|
2006-12-19 19:15:31 +00:00
|
|
|
gboolean
|
2013-06-05 08:01:46 -05:00
|
|
|
nm_supplicant_interface_set_config (NMSupplicantInterface *self,
|
2015-11-18 22:03:00 +01:00
|
|
|
NMSupplicantConfig *cfg,
|
|
|
|
|
GError **error)
|
2006-11-25 15:41:04 +00:00
|
|
|
{
|
2007-02-05 12:14:09 +00:00
|
|
|
NMSupplicantInterfacePrivate *priv;
|
2006-12-19 19:15:31 +00:00
|
|
|
|
2007-02-05 12:14:09 +00:00
|
|
|
g_return_val_if_fail (NM_IS_SUPPLICANT_INTERFACE (self), FALSE);
|
2006-11-25 15:41:04 +00:00
|
|
|
|
2007-02-05 12:14:09 +00:00
|
|
|
priv = NM_SUPPLICANT_INTERFACE_GET_PRIVATE (self);
|
2006-12-19 19:15:31 +00:00
|
|
|
|
2007-02-05 12:14:09 +00:00
|
|
|
nm_supplicant_interface_disconnect (self);
|
2012-02-07 23:46:12 -06:00
|
|
|
|
|
|
|
|
/* Make sure the supplicant supports EAP-FAST before trying to send
|
|
|
|
|
* it an EAP-FAST configuration.
|
|
|
|
|
*/
|
|
|
|
|
if (nm_supplicant_config_fast_required (cfg) && !priv->fast_supported) {
|
2015-11-18 22:03:00 +01:00
|
|
|
g_set_error (error, NM_SUPPLICANT_ERROR, NM_SUPPLICANT_ERROR_CONFIG,
|
|
|
|
|
"EAP-FAST is not supported by the supplicant");
|
2012-02-07 23:46:12 -06:00
|
|
|
return FALSE;
|
|
|
|
|
}
|
|
|
|
|
|
2015-02-02 02:31:30 -06:00
|
|
|
g_clear_object (&priv->cfg);
|
|
|
|
|
if (cfg) {
|
|
|
|
|
priv->cfg = g_object_ref (cfg);
|
|
|
|
|
g_dbus_proxy_call (priv->iface_proxy,
|
2015-04-13 10:28:17 -04:00
|
|
|
DBUS_INTERFACE_PROPERTIES ".Set",
|
2015-02-02 02:31:30 -06:00
|
|
|
g_variant_new ("(ssv)",
|
|
|
|
|
WPAS_DBUS_IFACE_INTERFACE,
|
|
|
|
|
"ApScan",
|
|
|
|
|
g_variant_new_uint32 (nm_supplicant_config_get_ap_scan (priv->cfg))),
|
|
|
|
|
G_DBUS_CALL_FLAGS_NONE,
|
|
|
|
|
-1,
|
|
|
|
|
priv->assoc_cancellable,
|
|
|
|
|
(GAsyncReadyCallback) set_ap_scan_cb,
|
|
|
|
|
self);
|
|
|
|
|
}
|
|
|
|
|
return TRUE;
|
2006-11-26 Dan Williams <dcbw@redhat.com>
Scan using wpa_supplicant over DBus.
* src/nm-device-802-11-wireless.c
- remove wireless extensions netlink event handler bits
(wireless_event_helper, nm_device_802_11_wireless_event)
- remove wireless extensions scan event handler bits
(process_scan_results, add_new_ap_to_device_list, hexstr2bin,
hex2byte, hex2num, request_and_convert_scan_results,
free_process_scan_cb_data, scan_results_timeout,
schedule_scan_results_timeout, cancel_scan_results_timeout)
- Rename nm_device_802_11_wireless_scan() -> request_wireless_scan()
and request scans from the supplicant interface rather than directly
- Move functionality of convert_scan_results() to cull_scan_list() and
supplicant_iface_scanned_ap_cb()
- (supplicant_iface_scan_result_cb): new function; schedule a new scan
at the scan interval when the current scan has finished
- (supplicant_iface_state_cb): start scanning when the supplicant
interface enters the READY state, and stop scanning when it
enters the DOWN state
- (cull_scan_list): weed out old access points from the scan list
- (supplicant_iface_scanned_ap_cb): convert a supplicant scanned access
point into an NMAccessPoint and merge it into the device's scan list
* src/supplicant-manager/nm-supplicant-interface.c
src/supplicant-manager/nm-supplicant-interface.h
- Add a new signal "scan-result" which is issued when the supplicant
notifies NM that a scan has completed
- Add a new signal "scanned-ap" that notifies listeners of a new access
point found in the scan. Called once for each access point that
the supplicant interface object receives from the supplicant as a
result of the "scanResults" method call
- (wpas_iface_query_scan_results): don't wait 4s before querying
for the initial scan results
- (scan_request_cb): new function; send listeners the result
(success, error) of a wireless scan request
- (nm_supplicant_interface_request_scan): new function; ask the
supplicant to perform an immediate wireless scan
git-svn-id: http://svn-archive.gnome.org/svn/NetworkManager/trunk@2128 4912f4e0-d625-0410-9fb7-b9a5a253dbdc
2006-11-26 20:49:48 +00:00
|
|
|
}
|
|
|
|
|
|
2010-11-22 08:40:21 -06:00
|
|
|
static void
|
2015-02-02 02:31:30 -06:00
|
|
|
scan_request_cb (GDBusProxy *proxy, GAsyncResult *result, gpointer user_data)
|
2010-11-22 08:40:21 -06:00
|
|
|
{
|
2015-02-02 02:31:30 -06:00
|
|
|
gs_unref_variant GVariant *reply = NULL;
|
|
|
|
|
gs_free_error GError *error = NULL;
|
2010-11-22 08:40:21 -06:00
|
|
|
|
2015-02-02 02:31:30 -06:00
|
|
|
reply = g_dbus_proxy_call_finish (proxy, result, &error);
|
|
|
|
|
if (g_error_matches (error, G_IO_ERROR, G_IO_ERROR_CANCELLED))
|
|
|
|
|
return;
|
2012-05-02 11:41:47 -05:00
|
|
|
|
2015-04-21 09:52:25 -04:00
|
|
|
if (error) {
|
2015-08-18 11:25:33 +02:00
|
|
|
if (_nm_dbus_error_has_name (error, "fi.w1.wpa_supplicant1.Interface.ScanError"))
|
|
|
|
|
nm_log_dbg (LOGD_SUPPLICANT, "Could not get scan request result: %s", error->message);
|
|
|
|
|
else {
|
|
|
|
|
g_dbus_error_strip_remote_error (error);
|
|
|
|
|
nm_log_warn (LOGD_SUPPLICANT, "Could not get scan request result: %s", error->message);
|
|
|
|
|
}
|
2015-04-21 09:52:25 -04:00
|
|
|
}
|
2015-02-02 02:31:30 -06:00
|
|
|
g_signal_emit (NM_SUPPLICANT_INTERFACE (user_data), signals[SCAN_DONE], 0, error ? FALSE : TRUE);
|
2012-05-02 11:41:47 -05:00
|
|
|
}
|
|
|
|
|
|
2006-11-26 Dan Williams <dcbw@redhat.com>
Scan using wpa_supplicant over DBus.
* src/nm-device-802-11-wireless.c
- remove wireless extensions netlink event handler bits
(wireless_event_helper, nm_device_802_11_wireless_event)
- remove wireless extensions scan event handler bits
(process_scan_results, add_new_ap_to_device_list, hexstr2bin,
hex2byte, hex2num, request_and_convert_scan_results,
free_process_scan_cb_data, scan_results_timeout,
schedule_scan_results_timeout, cancel_scan_results_timeout)
- Rename nm_device_802_11_wireless_scan() -> request_wireless_scan()
and request scans from the supplicant interface rather than directly
- Move functionality of convert_scan_results() to cull_scan_list() and
supplicant_iface_scanned_ap_cb()
- (supplicant_iface_scan_result_cb): new function; schedule a new scan
at the scan interval when the current scan has finished
- (supplicant_iface_state_cb): start scanning when the supplicant
interface enters the READY state, and stop scanning when it
enters the DOWN state
- (cull_scan_list): weed out old access points from the scan list
- (supplicant_iface_scanned_ap_cb): convert a supplicant scanned access
point into an NMAccessPoint and merge it into the device's scan list
* src/supplicant-manager/nm-supplicant-interface.c
src/supplicant-manager/nm-supplicant-interface.h
- Add a new signal "scan-result" which is issued when the supplicant
notifies NM that a scan has completed
- Add a new signal "scanned-ap" that notifies listeners of a new access
point found in the scan. Called once for each access point that
the supplicant interface object receives from the supplicant as a
result of the "scanResults" method call
- (wpas_iface_query_scan_results): don't wait 4s before querying
for the initial scan results
- (scan_request_cb): new function; send listeners the result
(success, error) of a wireless scan request
- (nm_supplicant_interface_request_scan): new function; ask the
supplicant to perform an immediate wireless scan
git-svn-id: http://svn-archive.gnome.org/svn/NetworkManager/trunk@2128 4912f4e0-d625-0410-9fb7-b9a5a253dbdc
2006-11-26 20:49:48 +00:00
|
|
|
gboolean
|
2012-05-02 11:41:47 -05:00
|
|
|
nm_supplicant_interface_request_scan (NMSupplicantInterface *self, const GPtrArray *ssids)
|
2006-11-26 Dan Williams <dcbw@redhat.com>
Scan using wpa_supplicant over DBus.
* src/nm-device-802-11-wireless.c
- remove wireless extensions netlink event handler bits
(wireless_event_helper, nm_device_802_11_wireless_event)
- remove wireless extensions scan event handler bits
(process_scan_results, add_new_ap_to_device_list, hexstr2bin,
hex2byte, hex2num, request_and_convert_scan_results,
free_process_scan_cb_data, scan_results_timeout,
schedule_scan_results_timeout, cancel_scan_results_timeout)
- Rename nm_device_802_11_wireless_scan() -> request_wireless_scan()
and request scans from the supplicant interface rather than directly
- Move functionality of convert_scan_results() to cull_scan_list() and
supplicant_iface_scanned_ap_cb()
- (supplicant_iface_scan_result_cb): new function; schedule a new scan
at the scan interval when the current scan has finished
- (supplicant_iface_state_cb): start scanning when the supplicant
interface enters the READY state, and stop scanning when it
enters the DOWN state
- (cull_scan_list): weed out old access points from the scan list
- (supplicant_iface_scanned_ap_cb): convert a supplicant scanned access
point into an NMAccessPoint and merge it into the device's scan list
* src/supplicant-manager/nm-supplicant-interface.c
src/supplicant-manager/nm-supplicant-interface.h
- Add a new signal "scan-result" which is issued when the supplicant
notifies NM that a scan has completed
- Add a new signal "scanned-ap" that notifies listeners of a new access
point found in the scan. Called once for each access point that
the supplicant interface object receives from the supplicant as a
result of the "scanResults" method call
- (wpas_iface_query_scan_results): don't wait 4s before querying
for the initial scan results
- (scan_request_cb): new function; send listeners the result
(success, error) of a wireless scan request
- (nm_supplicant_interface_request_scan): new function; ask the
supplicant to perform an immediate wireless scan
git-svn-id: http://svn-archive.gnome.org/svn/NetworkManager/trunk@2128 4912f4e0-d625-0410-9fb7-b9a5a253dbdc
2006-11-26 20:49:48 +00:00
|
|
|
{
|
2007-02-05 12:14:09 +00:00
|
|
|
NMSupplicantInterfacePrivate *priv;
|
2015-02-02 02:31:30 -06:00
|
|
|
GVariantBuilder builder;
|
|
|
|
|
guint i;
|
2006-11-26 Dan Williams <dcbw@redhat.com>
Scan using wpa_supplicant over DBus.
* src/nm-device-802-11-wireless.c
- remove wireless extensions netlink event handler bits
(wireless_event_helper, nm_device_802_11_wireless_event)
- remove wireless extensions scan event handler bits
(process_scan_results, add_new_ap_to_device_list, hexstr2bin,
hex2byte, hex2num, request_and_convert_scan_results,
free_process_scan_cb_data, scan_results_timeout,
schedule_scan_results_timeout, cancel_scan_results_timeout)
- Rename nm_device_802_11_wireless_scan() -> request_wireless_scan()
and request scans from the supplicant interface rather than directly
- Move functionality of convert_scan_results() to cull_scan_list() and
supplicant_iface_scanned_ap_cb()
- (supplicant_iface_scan_result_cb): new function; schedule a new scan
at the scan interval when the current scan has finished
- (supplicant_iface_state_cb): start scanning when the supplicant
interface enters the READY state, and stop scanning when it
enters the DOWN state
- (cull_scan_list): weed out old access points from the scan list
- (supplicant_iface_scanned_ap_cb): convert a supplicant scanned access
point into an NMAccessPoint and merge it into the device's scan list
* src/supplicant-manager/nm-supplicant-interface.c
src/supplicant-manager/nm-supplicant-interface.h
- Add a new signal "scan-result" which is issued when the supplicant
notifies NM that a scan has completed
- Add a new signal "scanned-ap" that notifies listeners of a new access
point found in the scan. Called once for each access point that
the supplicant interface object receives from the supplicant as a
result of the "scanResults" method call
- (wpas_iface_query_scan_results): don't wait 4s before querying
for the initial scan results
- (scan_request_cb): new function; send listeners the result
(success, error) of a wireless scan request
- (nm_supplicant_interface_request_scan): new function; ask the
supplicant to perform an immediate wireless scan
git-svn-id: http://svn-archive.gnome.org/svn/NetworkManager/trunk@2128 4912f4e0-d625-0410-9fb7-b9a5a253dbdc
2006-11-26 20:49:48 +00:00
|
|
|
|
2007-02-05 12:14:09 +00:00
|
|
|
g_return_val_if_fail (NM_IS_SUPPLICANT_INTERFACE (self), FALSE);
|
2006-11-26 Dan Williams <dcbw@redhat.com>
Scan using wpa_supplicant over DBus.
* src/nm-device-802-11-wireless.c
- remove wireless extensions netlink event handler bits
(wireless_event_helper, nm_device_802_11_wireless_event)
- remove wireless extensions scan event handler bits
(process_scan_results, add_new_ap_to_device_list, hexstr2bin,
hex2byte, hex2num, request_and_convert_scan_results,
free_process_scan_cb_data, scan_results_timeout,
schedule_scan_results_timeout, cancel_scan_results_timeout)
- Rename nm_device_802_11_wireless_scan() -> request_wireless_scan()
and request scans from the supplicant interface rather than directly
- Move functionality of convert_scan_results() to cull_scan_list() and
supplicant_iface_scanned_ap_cb()
- (supplicant_iface_scan_result_cb): new function; schedule a new scan
at the scan interval when the current scan has finished
- (supplicant_iface_state_cb): start scanning when the supplicant
interface enters the READY state, and stop scanning when it
enters the DOWN state
- (cull_scan_list): weed out old access points from the scan list
- (supplicant_iface_scanned_ap_cb): convert a supplicant scanned access
point into an NMAccessPoint and merge it into the device's scan list
* src/supplicant-manager/nm-supplicant-interface.c
src/supplicant-manager/nm-supplicant-interface.h
- Add a new signal "scan-result" which is issued when the supplicant
notifies NM that a scan has completed
- Add a new signal "scanned-ap" that notifies listeners of a new access
point found in the scan. Called once for each access point that
the supplicant interface object receives from the supplicant as a
result of the "scanResults" method call
- (wpas_iface_query_scan_results): don't wait 4s before querying
for the initial scan results
- (scan_request_cb): new function; send listeners the result
(success, error) of a wireless scan request
- (nm_supplicant_interface_request_scan): new function; ask the
supplicant to perform an immediate wireless scan
git-svn-id: http://svn-archive.gnome.org/svn/NetworkManager/trunk@2128 4912f4e0-d625-0410-9fb7-b9a5a253dbdc
2006-11-26 20:49:48 +00:00
|
|
|
|
2007-02-05 12:14:09 +00:00
|
|
|
priv = NM_SUPPLICANT_INTERFACE_GET_PRIVATE (self);
|
|
|
|
|
|
2010-11-22 08:40:21 -06:00
|
|
|
/* Scan parameters */
|
2015-02-02 02:31:30 -06:00
|
|
|
g_variant_builder_init (&builder, G_VARIANT_TYPE_VARDICT);
|
|
|
|
|
g_variant_builder_add (&builder, "{sv}", "Type", g_variant_new_string ("active"));
|
|
|
|
|
if (ssids) {
|
|
|
|
|
GVariantBuilder ssids_builder;
|
|
|
|
|
|
|
|
|
|
g_variant_builder_init (&ssids_builder, G_VARIANT_TYPE_BYTESTRING_ARRAY);
|
|
|
|
|
for (i = 0; i < ssids->len; i++) {
|
|
|
|
|
GByteArray *ssid = g_ptr_array_index (ssids, i);
|
|
|
|
|
g_variant_builder_add (&ssids_builder, "@ay",
|
|
|
|
|
g_variant_new_fixed_array (G_VARIANT_TYPE_BYTE,
|
|
|
|
|
ssid->data, ssid->len, 1));
|
|
|
|
|
}
|
|
|
|
|
g_variant_builder_add (&builder, "{sv}", "SSIDs", g_variant_builder_end (&ssids_builder));
|
|
|
|
|
}
|
2006-11-26 Dan Williams <dcbw@redhat.com>
Scan using wpa_supplicant over DBus.
* src/nm-device-802-11-wireless.c
- remove wireless extensions netlink event handler bits
(wireless_event_helper, nm_device_802_11_wireless_event)
- remove wireless extensions scan event handler bits
(process_scan_results, add_new_ap_to_device_list, hexstr2bin,
hex2byte, hex2num, request_and_convert_scan_results,
free_process_scan_cb_data, scan_results_timeout,
schedule_scan_results_timeout, cancel_scan_results_timeout)
- Rename nm_device_802_11_wireless_scan() -> request_wireless_scan()
and request scans from the supplicant interface rather than directly
- Move functionality of convert_scan_results() to cull_scan_list() and
supplicant_iface_scanned_ap_cb()
- (supplicant_iface_scan_result_cb): new function; schedule a new scan
at the scan interval when the current scan has finished
- (supplicant_iface_state_cb): start scanning when the supplicant
interface enters the READY state, and stop scanning when it
enters the DOWN state
- (cull_scan_list): weed out old access points from the scan list
- (supplicant_iface_scanned_ap_cb): convert a supplicant scanned access
point into an NMAccessPoint and merge it into the device's scan list
* src/supplicant-manager/nm-supplicant-interface.c
src/supplicant-manager/nm-supplicant-interface.h
- Add a new signal "scan-result" which is issued when the supplicant
notifies NM that a scan has completed
- Add a new signal "scanned-ap" that notifies listeners of a new access
point found in the scan. Called once for each access point that
the supplicant interface object receives from the supplicant as a
result of the "scanResults" method call
- (wpas_iface_query_scan_results): don't wait 4s before querying
for the initial scan results
- (scan_request_cb): new function; send listeners the result
(success, error) of a wireless scan request
- (nm_supplicant_interface_request_scan): new function; ask the
supplicant to perform an immediate wireless scan
git-svn-id: http://svn-archive.gnome.org/svn/NetworkManager/trunk@2128 4912f4e0-d625-0410-9fb7-b9a5a253dbdc
2006-11-26 20:49:48 +00:00
|
|
|
|
2015-02-02 02:31:30 -06:00
|
|
|
g_dbus_proxy_call (priv->iface_proxy,
|
|
|
|
|
"Scan",
|
|
|
|
|
g_variant_new ("(a{sv})", &builder),
|
|
|
|
|
G_DBUS_CALL_FLAGS_NONE,
|
|
|
|
|
-1,
|
|
|
|
|
priv->other_cancellable,
|
|
|
|
|
(GAsyncReadyCallback) scan_request_cb,
|
|
|
|
|
self);
|
|
|
|
|
return TRUE;
|
2006-11-26 Dan Williams <dcbw@redhat.com>
Scan using wpa_supplicant over DBus.
* src/nm-device-802-11-wireless.c
- remove wireless extensions netlink event handler bits
(wireless_event_helper, nm_device_802_11_wireless_event)
- remove wireless extensions scan event handler bits
(process_scan_results, add_new_ap_to_device_list, hexstr2bin,
hex2byte, hex2num, request_and_convert_scan_results,
free_process_scan_cb_data, scan_results_timeout,
schedule_scan_results_timeout, cancel_scan_results_timeout)
- Rename nm_device_802_11_wireless_scan() -> request_wireless_scan()
and request scans from the supplicant interface rather than directly
- Move functionality of convert_scan_results() to cull_scan_list() and
supplicant_iface_scanned_ap_cb()
- (supplicant_iface_scan_result_cb): new function; schedule a new scan
at the scan interval when the current scan has finished
- (supplicant_iface_state_cb): start scanning when the supplicant
interface enters the READY state, and stop scanning when it
enters the DOWN state
- (cull_scan_list): weed out old access points from the scan list
- (supplicant_iface_scanned_ap_cb): convert a supplicant scanned access
point into an NMAccessPoint and merge it into the device's scan list
* src/supplicant-manager/nm-supplicant-interface.c
src/supplicant-manager/nm-supplicant-interface.h
- Add a new signal "scan-result" which is issued when the supplicant
notifies NM that a scan has completed
- Add a new signal "scanned-ap" that notifies listeners of a new access
point found in the scan. Called once for each access point that
the supplicant interface object receives from the supplicant as a
result of the "scanResults" method call
- (wpas_iface_query_scan_results): don't wait 4s before querying
for the initial scan results
- (scan_request_cb): new function; send listeners the result
(success, error) of a wireless scan request
- (nm_supplicant_interface_request_scan): new function; ask the
supplicant to perform an immediate wireless scan
git-svn-id: http://svn-archive.gnome.org/svn/NetworkManager/trunk@2128 4912f4e0-d625-0410-9fb7-b9a5a253dbdc
2006-11-26 20:49:48 +00:00
|
|
|
}
|
2006-12-04 05:45:05 +00:00
|
|
|
|
2006-12-04 19:09:44 +00:00
|
|
|
guint32
|
|
|
|
|
nm_supplicant_interface_get_state (NMSupplicantInterface * self)
|
|
|
|
|
{
|
2007-02-05 12:14:09 +00:00
|
|
|
g_return_val_if_fail (NM_IS_SUPPLICANT_INTERFACE (self), NM_SUPPLICANT_INTERFACE_STATE_DOWN);
|
2006-12-04 19:09:44 +00:00
|
|
|
|
2007-02-05 12:14:09 +00:00
|
|
|
return NM_SUPPLICANT_INTERFACE_GET_PRIVATE (self)->state;
|
2006-12-04 19:09:44 +00:00
|
|
|
}
|
|
|
|
|
|
2008-10-26 16:32:29 +00:00
|
|
|
const char *
|
|
|
|
|
nm_supplicant_interface_state_to_string (guint32 state)
|
|
|
|
|
{
|
|
|
|
|
switch (state) {
|
|
|
|
|
case NM_SUPPLICANT_INTERFACE_STATE_INIT:
|
|
|
|
|
return "init";
|
2010-10-11 20:30:40 -05:00
|
|
|
case NM_SUPPLICANT_INTERFACE_STATE_STARTING:
|
|
|
|
|
return "starting";
|
2008-10-26 16:32:29 +00:00
|
|
|
case NM_SUPPLICANT_INTERFACE_STATE_READY:
|
|
|
|
|
return "ready";
|
2012-05-11 17:15:40 -05:00
|
|
|
case NM_SUPPLICANT_INTERFACE_STATE_DISABLED:
|
|
|
|
|
return "disabled";
|
2010-10-06 11:05:21 -05:00
|
|
|
case NM_SUPPLICANT_INTERFACE_STATE_DISCONNECTED:
|
2008-10-26 16:32:29 +00:00
|
|
|
return "disconnected";
|
2010-10-06 11:05:21 -05:00
|
|
|
case NM_SUPPLICANT_INTERFACE_STATE_INACTIVE:
|
2008-10-26 16:32:29 +00:00
|
|
|
return "inactive";
|
2010-10-06 11:05:21 -05:00
|
|
|
case NM_SUPPLICANT_INTERFACE_STATE_SCANNING:
|
2008-10-26 16:32:29 +00:00
|
|
|
return "scanning";
|
2011-03-17 12:35:58 -05:00
|
|
|
case NM_SUPPLICANT_INTERFACE_STATE_AUTHENTICATING:
|
|
|
|
|
return "authenticating";
|
2010-10-06 11:05:21 -05:00
|
|
|
case NM_SUPPLICANT_INTERFACE_STATE_ASSOCIATING:
|
2008-10-26 16:32:29 +00:00
|
|
|
return "associating";
|
2010-10-06 11:05:21 -05:00
|
|
|
case NM_SUPPLICANT_INTERFACE_STATE_ASSOCIATED:
|
2008-10-26 16:32:29 +00:00
|
|
|
return "associated";
|
2010-10-06 11:05:21 -05:00
|
|
|
case NM_SUPPLICANT_INTERFACE_STATE_4WAY_HANDSHAKE:
|
2008-10-26 16:32:29 +00:00
|
|
|
return "4-way handshake";
|
2010-10-06 11:05:21 -05:00
|
|
|
case NM_SUPPLICANT_INTERFACE_STATE_GROUP_HANDSHAKE:
|
2008-10-26 16:32:29 +00:00
|
|
|
return "group handshake";
|
2010-10-06 11:05:21 -05:00
|
|
|
case NM_SUPPLICANT_INTERFACE_STATE_COMPLETED:
|
2008-10-26 16:32:29 +00:00
|
|
|
return "completed";
|
2010-10-06 11:05:21 -05:00
|
|
|
case NM_SUPPLICANT_INTERFACE_STATE_DOWN:
|
|
|
|
|
return "down";
|
2008-10-26 16:32:29 +00:00
|
|
|
default:
|
|
|
|
|
break;
|
|
|
|
|
}
|
|
|
|
|
return "unknown";
|
|
|
|
|
}
|
|
|
|
|
|
2010-10-06 11:05:21 -05:00
|
|
|
const char *
|
|
|
|
|
nm_supplicant_interface_get_object_path (NMSupplicantInterface *self)
|
|
|
|
|
{
|
|
|
|
|
g_return_val_if_fail (NM_IS_SUPPLICANT_INTERFACE (self), NULL);
|
|
|
|
|
|
|
|
|
|
return NM_SUPPLICANT_INTERFACE_GET_PRIVATE (self)->object_path;
|
|
|
|
|
}
|
|
|
|
|
|
2010-10-05 14:19:56 -05:00
|
|
|
const char *
|
|
|
|
|
nm_supplicant_interface_get_ifname (NMSupplicantInterface *self)
|
|
|
|
|
{
|
2011-03-14 01:05:51 -05:00
|
|
|
g_return_val_if_fail (NM_IS_SUPPLICANT_INTERFACE (self), NULL);
|
2010-10-05 14:19:56 -05:00
|
|
|
|
|
|
|
|
return NM_SUPPLICANT_INTERFACE_GET_PRIVATE (self)->dev;
|
|
|
|
|
}
|
|
|
|
|
|
2012-05-01 17:59:35 -05:00
|
|
|
guint
|
|
|
|
|
nm_supplicant_interface_get_max_scan_ssids (NMSupplicantInterface *self)
|
|
|
|
|
{
|
|
|
|
|
g_return_val_if_fail (NM_IS_SUPPLICANT_INTERFACE (self), 0);
|
|
|
|
|
|
|
|
|
|
return NM_SUPPLICANT_INTERFACE_GET_PRIVATE (self)->max_scan_ssids;
|
|
|
|
|
}
|
|
|
|
|
|
2010-10-05 14:19:43 -05:00
|
|
|
/*******************************************************************/
|
|
|
|
|
|
|
|
|
|
NMSupplicantInterface *
|
2015-02-01 03:08:16 -06:00
|
|
|
nm_supplicant_interface_new (const char *ifname,
|
2010-10-12 14:18:42 -05:00
|
|
|
gboolean is_wireless,
|
2012-02-07 23:46:12 -06:00
|
|
|
gboolean fast_supported,
|
2016-01-19 22:00:53 +01:00
|
|
|
NMSupplicantFeature ap_support)
|
2010-10-05 14:19:43 -05:00
|
|
|
{
|
|
|
|
|
g_return_val_if_fail (ifname != NULL, NULL);
|
|
|
|
|
|
2016-01-19 16:08:29 +01:00
|
|
|
return g_object_new (NM_TYPE_SUPPLICANT_INTERFACE,
|
|
|
|
|
NM_SUPPLICANT_INTERFACE_IFACE, ifname,
|
|
|
|
|
NM_SUPPLICANT_INTERFACE_IS_WIRELESS, is_wireless,
|
|
|
|
|
NM_SUPPLICANT_INTERFACE_FAST_SUPPORTED, fast_supported,
|
|
|
|
|
NM_SUPPLICANT_INTERFACE_AP_SUPPORT, (int) ap_support,
|
|
|
|
|
NULL);
|
2010-10-05 14:19:43 -05:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
static void
|
|
|
|
|
nm_supplicant_interface_init (NMSupplicantInterface * self)
|
|
|
|
|
{
|
|
|
|
|
NMSupplicantInterfacePrivate *priv = NM_SUPPLICANT_INTERFACE_GET_PRIVATE (self);
|
|
|
|
|
|
|
|
|
|
priv->state = NM_SUPPLICANT_INTERFACE_STATE_INIT;
|
2013-06-04 18:06:18 -05:00
|
|
|
priv->bss_proxies = g_hash_table_new_full (g_str_hash, g_str_equal, NULL, g_object_unref);
|
2010-10-05 14:19:43 -05:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
static void
|
|
|
|
|
set_property (GObject *object,
|
|
|
|
|
guint prop_id,
|
|
|
|
|
const GValue *value,
|
|
|
|
|
GParamSpec *pspec)
|
|
|
|
|
{
|
2016-01-19 16:08:29 +01:00
|
|
|
NMSupplicantInterfacePrivate *priv = NM_SUPPLICANT_INTERFACE_GET_PRIVATE (object);
|
|
|
|
|
|
|
|
|
|
switch (prop_id) {
|
|
|
|
|
case PROP_IFACE:
|
|
|
|
|
/* construct-only */
|
|
|
|
|
priv->dev = g_value_dup_string (value);
|
|
|
|
|
g_return_if_fail (priv->dev);
|
|
|
|
|
break;
|
|
|
|
|
case PROP_IS_WIRELESS:
|
|
|
|
|
/* construct-only */
|
|
|
|
|
priv->is_wireless = g_value_get_boolean (value);
|
|
|
|
|
break;
|
|
|
|
|
case PROP_FAST_SUPPORTED:
|
|
|
|
|
/* construct-only */
|
|
|
|
|
priv->fast_supported = g_value_get_boolean (value);
|
|
|
|
|
break;
|
|
|
|
|
case PROP_AP_SUPPORT:
|
|
|
|
|
/* construct-only */
|
|
|
|
|
priv->ap_support = g_value_get_int (value);
|
|
|
|
|
break;
|
|
|
|
|
default:
|
|
|
|
|
G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec);
|
|
|
|
|
break;
|
|
|
|
|
}
|
2010-10-05 14:19:43 -05:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
static void
|
|
|
|
|
get_property (GObject *object,
|
|
|
|
|
guint prop_id,
|
|
|
|
|
GValue *value,
|
|
|
|
|
GParamSpec *pspec)
|
|
|
|
|
{
|
2015-04-05 23:31:02 -05:00
|
|
|
NMSupplicantInterfacePrivate *priv = NM_SUPPLICANT_INTERFACE_GET_PRIVATE (object);
|
|
|
|
|
|
2010-10-05 14:19:43 -05:00
|
|
|
switch (prop_id) {
|
|
|
|
|
case PROP_SCANNING:
|
2015-04-05 23:31:02 -05:00
|
|
|
g_value_set_boolean (value, priv->scanning);
|
|
|
|
|
break;
|
|
|
|
|
case PROP_CURRENT_BSS:
|
|
|
|
|
g_value_set_string (value, priv->current_bss);
|
2010-10-05 14:19:43 -05:00
|
|
|
break;
|
|
|
|
|
default:
|
|
|
|
|
G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec);
|
|
|
|
|
break;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
static void
|
|
|
|
|
dispose (GObject *object)
|
|
|
|
|
{
|
|
|
|
|
NMSupplicantInterfacePrivate *priv = NM_SUPPLICANT_INTERFACE_GET_PRIVATE (object);
|
|
|
|
|
|
2015-03-10 08:36:34 -05:00
|
|
|
if (priv->iface_proxy)
|
|
|
|
|
g_signal_handlers_disconnect_by_data (priv->iface_proxy, NM_SUPPLICANT_INTERFACE (object));
|
2015-02-01 01:16:45 -06:00
|
|
|
g_clear_object (&priv->iface_proxy);
|
2010-10-05 14:19:43 -05:00
|
|
|
|
2015-02-02 02:31:30 -06:00
|
|
|
if (priv->init_cancellable)
|
|
|
|
|
g_cancellable_cancel (priv->init_cancellable);
|
|
|
|
|
g_clear_object (&priv->init_cancellable);
|
2010-10-05 14:19:43 -05:00
|
|
|
|
2015-02-02 02:31:30 -06:00
|
|
|
if (priv->other_cancellable)
|
|
|
|
|
g_cancellable_cancel (priv->other_cancellable);
|
|
|
|
|
g_clear_object (&priv->other_cancellable);
|
2012-02-20 15:06:05 -06:00
|
|
|
|
2015-02-02 02:31:30 -06:00
|
|
|
g_clear_object (&priv->wpas_proxy);
|
|
|
|
|
g_clear_pointer (&priv->bss_proxies, (GDestroyNotify) g_hash_table_destroy);
|
2010-10-05 14:19:43 -05:00
|
|
|
|
2015-02-02 02:31:30 -06:00
|
|
|
g_clear_pointer (&priv->net_path, g_free);
|
|
|
|
|
g_clear_pointer (&priv->dev, g_free);
|
|
|
|
|
g_clear_pointer (&priv->object_path, g_free);
|
2015-04-05 23:31:02 -05:00
|
|
|
g_clear_pointer (&priv->current_bss, g_free);
|
2010-10-05 14:19:43 -05:00
|
|
|
|
2015-02-01 01:16:45 -06:00
|
|
|
g_clear_object (&priv->cfg);
|
2010-10-05 14:19:43 -05:00
|
|
|
|
|
|
|
|
/* Chain up to the parent class */
|
|
|
|
|
G_OBJECT_CLASS (nm_supplicant_interface_parent_class)->dispose (object);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
static void
|
|
|
|
|
nm_supplicant_interface_class_init (NMSupplicantInterfaceClass *klass)
|
|
|
|
|
{
|
|
|
|
|
GObjectClass *object_class = G_OBJECT_CLASS (klass);
|
|
|
|
|
|
|
|
|
|
g_type_class_add_private (object_class, sizeof (NMSupplicantInterfacePrivate));
|
|
|
|
|
|
|
|
|
|
object_class->dispose = dispose;
|
|
|
|
|
object_class->set_property = set_property;
|
|
|
|
|
object_class->get_property = get_property;
|
|
|
|
|
|
|
|
|
|
/* Properties */
|
2016-01-19 16:08:29 +01:00
|
|
|
obj_properties[PROP_SCANNING] =
|
|
|
|
|
g_param_spec_boolean (NM_SUPPLICANT_INTERFACE_SCANNING, "", "",
|
|
|
|
|
FALSE,
|
|
|
|
|
G_PARAM_READABLE |
|
|
|
|
|
G_PARAM_STATIC_STRINGS);
|
|
|
|
|
obj_properties[PROP_CURRENT_BSS] =
|
|
|
|
|
g_param_spec_string (NM_SUPPLICANT_INTERFACE_CURRENT_BSS, "", "",
|
|
|
|
|
NULL,
|
|
|
|
|
G_PARAM_READABLE |
|
|
|
|
|
G_PARAM_STATIC_STRINGS);
|
|
|
|
|
obj_properties[PROP_IFACE] =
|
|
|
|
|
g_param_spec_string (NM_SUPPLICANT_INTERFACE_IFACE, "", "",
|
|
|
|
|
NULL,
|
|
|
|
|
G_PARAM_WRITABLE |
|
|
|
|
|
G_PARAM_CONSTRUCT_ONLY |
|
|
|
|
|
G_PARAM_STATIC_STRINGS);
|
|
|
|
|
obj_properties[PROP_IS_WIRELESS] =
|
|
|
|
|
g_param_spec_boolean (NM_SUPPLICANT_INTERFACE_IS_WIRELESS, "", "",
|
|
|
|
|
TRUE,
|
|
|
|
|
G_PARAM_WRITABLE |
|
|
|
|
|
G_PARAM_CONSTRUCT_ONLY |
|
|
|
|
|
G_PARAM_STATIC_STRINGS);
|
|
|
|
|
obj_properties[PROP_FAST_SUPPORTED] =
|
|
|
|
|
g_param_spec_boolean (NM_SUPPLICANT_INTERFACE_FAST_SUPPORTED, "", "",
|
|
|
|
|
TRUE,
|
|
|
|
|
G_PARAM_WRITABLE |
|
|
|
|
|
G_PARAM_CONSTRUCT_ONLY |
|
|
|
|
|
G_PARAM_STATIC_STRINGS);
|
|
|
|
|
obj_properties[PROP_AP_SUPPORT] =
|
|
|
|
|
g_param_spec_int (NM_SUPPLICANT_INTERFACE_AP_SUPPORT, "", "",
|
|
|
|
|
NM_SUPPLICANT_FEATURE_UNKNOWN,
|
|
|
|
|
NM_SUPPLICANT_FEATURE_YES,
|
|
|
|
|
NM_SUPPLICANT_FEATURE_UNKNOWN,
|
|
|
|
|
G_PARAM_WRITABLE |
|
|
|
|
|
G_PARAM_CONSTRUCT_ONLY |
|
|
|
|
|
G_PARAM_STATIC_STRINGS);
|
|
|
|
|
|
|
|
|
|
g_object_class_install_properties (object_class, _PROPERTY_ENUMS_LAST, obj_properties);
|
2015-04-05 23:31:02 -05:00
|
|
|
|
2010-10-05 14:19:43 -05:00
|
|
|
/* Signals */
|
|
|
|
|
signals[STATE] =
|
2010-11-22 08:25:09 -06:00
|
|
|
g_signal_new (NM_SUPPLICANT_INTERFACE_STATE,
|
2010-10-05 14:19:43 -05:00
|
|
|
G_OBJECT_CLASS_TYPE (object_class),
|
|
|
|
|
G_SIGNAL_RUN_LAST,
|
|
|
|
|
G_STRUCT_OFFSET (NMSupplicantInterfaceClass, state),
|
2013-05-06 13:37:25 -04:00
|
|
|
NULL, NULL, NULL,
|
2012-09-12 11:58:41 -05:00
|
|
|
G_TYPE_NONE, 3, G_TYPE_UINT, G_TYPE_UINT, G_TYPE_INT);
|
2010-10-05 14:19:43 -05:00
|
|
|
|
|
|
|
|
signals[REMOVED] =
|
2010-11-22 08:25:09 -06:00
|
|
|
g_signal_new (NM_SUPPLICANT_INTERFACE_REMOVED,
|
2010-10-05 14:19:43 -05:00
|
|
|
G_OBJECT_CLASS_TYPE (object_class),
|
|
|
|
|
G_SIGNAL_RUN_LAST,
|
|
|
|
|
G_STRUCT_OFFSET (NMSupplicantInterfaceClass, removed),
|
2013-05-06 13:37:25 -04:00
|
|
|
NULL, NULL, NULL,
|
2010-10-05 14:19:43 -05:00
|
|
|
G_TYPE_NONE, 0);
|
|
|
|
|
|
2010-11-22 08:25:09 -06:00
|
|
|
signals[NEW_BSS] =
|
|
|
|
|
g_signal_new (NM_SUPPLICANT_INTERFACE_NEW_BSS,
|
2010-10-05 14:19:43 -05:00
|
|
|
G_OBJECT_CLASS_TYPE (object_class),
|
|
|
|
|
G_SIGNAL_RUN_LAST,
|
2010-11-22 08:25:09 -06:00
|
|
|
G_STRUCT_OFFSET (NMSupplicantInterfaceClass, new_bss),
|
2013-05-06 13:37:25 -04:00
|
|
|
NULL, NULL, NULL,
|
2015-02-02 02:31:30 -06:00
|
|
|
G_TYPE_NONE, 2, G_TYPE_STRING, G_TYPE_VARIANT);
|
2012-02-20 15:06:05 -06:00
|
|
|
|
|
|
|
|
signals[BSS_UPDATED] =
|
|
|
|
|
g_signal_new (NM_SUPPLICANT_INTERFACE_BSS_UPDATED,
|
|
|
|
|
G_OBJECT_CLASS_TYPE (object_class),
|
|
|
|
|
G_SIGNAL_RUN_LAST,
|
|
|
|
|
G_STRUCT_OFFSET (NMSupplicantInterfaceClass, bss_updated),
|
2013-05-06 13:37:25 -04:00
|
|
|
NULL, NULL, NULL,
|
2015-04-06 16:09:18 -04:00
|
|
|
G_TYPE_NONE, 2, G_TYPE_STRING, G_TYPE_VARIANT);
|
2010-10-05 14:19:43 -05:00
|
|
|
|
2012-03-02 18:17:34 -06:00
|
|
|
signals[BSS_REMOVED] =
|
|
|
|
|
g_signal_new (NM_SUPPLICANT_INTERFACE_BSS_REMOVED,
|
|
|
|
|
G_OBJECT_CLASS_TYPE (object_class),
|
|
|
|
|
G_SIGNAL_RUN_LAST,
|
|
|
|
|
G_STRUCT_OFFSET (NMSupplicantInterfaceClass, bss_removed),
|
2013-05-06 13:37:25 -04:00
|
|
|
NULL, NULL, NULL,
|
2012-03-02 18:17:34 -06:00
|
|
|
G_TYPE_NONE, 1, G_TYPE_STRING);
|
|
|
|
|
|
2010-11-22 08:25:09 -06:00
|
|
|
signals[SCAN_DONE] =
|
|
|
|
|
g_signal_new (NM_SUPPLICANT_INTERFACE_SCAN_DONE,
|
2010-10-05 14:19:43 -05:00
|
|
|
G_OBJECT_CLASS_TYPE (object_class),
|
|
|
|
|
G_SIGNAL_RUN_LAST,
|
2010-11-22 08:25:09 -06:00
|
|
|
G_STRUCT_OFFSET (NMSupplicantInterfaceClass, scan_done),
|
2013-05-06 13:37:25 -04:00
|
|
|
NULL, NULL, NULL,
|
2010-10-05 14:19:43 -05:00
|
|
|
G_TYPE_NONE, 1, G_TYPE_BOOLEAN);
|
|
|
|
|
|
|
|
|
|
signals[CONNECTION_ERROR] =
|
2010-11-22 08:25:09 -06:00
|
|
|
g_signal_new (NM_SUPPLICANT_INTERFACE_CONNECTION_ERROR,
|
2010-10-05 14:19:43 -05:00
|
|
|
G_OBJECT_CLASS_TYPE (object_class),
|
|
|
|
|
G_SIGNAL_RUN_LAST,
|
|
|
|
|
G_STRUCT_OFFSET (NMSupplicantInterfaceClass, connection_error),
|
2013-05-06 13:37:25 -04:00
|
|
|
NULL, NULL, NULL,
|
2010-10-05 14:19:43 -05:00
|
|
|
G_TYPE_NONE, 2, G_TYPE_STRING, G_TYPE_STRING);
|
2011-12-19 19:47:43 -06:00
|
|
|
|
|
|
|
|
signals[CREDENTIALS_REQUEST] =
|
|
|
|
|
g_signal_new (NM_SUPPLICANT_INTERFACE_CREDENTIALS_REQUEST,
|
|
|
|
|
G_OBJECT_CLASS_TYPE (object_class),
|
|
|
|
|
G_SIGNAL_RUN_LAST,
|
|
|
|
|
G_STRUCT_OFFSET (NMSupplicantInterfaceClass, credentials_request),
|
2013-05-06 13:37:25 -04:00
|
|
|
NULL, NULL, NULL,
|
2011-12-19 19:47:43 -06:00
|
|
|
G_TYPE_NONE, 2, G_TYPE_STRING, G_TYPE_STRING);
|
2010-10-05 14:19:43 -05:00
|
|
|
}
|
|
|
|
|
|