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
|
|
|
*/
|
|
|
|
|
|
2012-02-29 23:11:04 -06: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>
|
|
|
|
|
#include <glib.h>
|
|
|
|
|
|
|
|
|
|
#include "nm-supplicant-interface.h"
|
|
|
|
|
#include "nm-supplicant-manager.h"
|
2010-04-07 10:13:12 -07:00
|
|
|
#include "nm-logging.h"
|
2007-10-01 21:26:13 +00:00
|
|
|
#include "nm-marshal.h"
|
2006-12-19 19:15:31 +00:00
|
|
|
#include "nm-supplicant-config.h"
|
2006-11-25 15:41:04 +00:00
|
|
|
#include "nm-dbus-manager.h"
|
2007-02-05 12:14:09 +00:00
|
|
|
#include "nm-call-store.h"
|
2008-03-29 21:35:41 +00:00
|
|
|
#include "nm-dbus-glib-types.h"
|
2008-12-31 18:57:36 -05:00
|
|
|
#include "nm-glib-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
|
|
|
|
2010-11-22 08:25:09 -06:00
|
|
|
static void wpas_iface_properties_changed (DBusGProxy *proxy,
|
|
|
|
|
GHashTable *props,
|
|
|
|
|
gpointer user_data);
|
2006-11-25 15:41:04 +00:00
|
|
|
|
2010-11-22 08:25:09 -06:00
|
|
|
static void wpas_iface_scan_done (DBusGProxy *proxy,
|
|
|
|
|
gboolean success,
|
|
|
|
|
gpointer user_data);
|
2006-11-25 15:41:04 +00:00
|
|
|
|
2012-05-02 13:04:23 -05:00
|
|
|
static void wpas_iface_get_props (NMSupplicantInterface *self);
|
|
|
|
|
|
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 */
|
|
|
|
|
enum {
|
|
|
|
|
PROP_0 = 0,
|
2009-05-13 11:16:29 -04:00
|
|
|
PROP_SCANNING,
|
2006-11-25 15:41:04 +00:00
|
|
|
LAST_PROP
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
|
2010-10-06 11:05:21 -05:00
|
|
|
typedef struct {
|
2006-12-03 20:04:11 +00:00
|
|
|
NMSupplicantManager * smgr;
|
2010-10-12 14:18:42 -05:00
|
|
|
gulong smgr_avail_id;
|
2006-12-03 20:04:11 +00:00
|
|
|
NMDBusManager * dbus_mgr;
|
2007-02-05 12:14:09 +00:00
|
|
|
char * dev;
|
|
|
|
|
gboolean is_wireless;
|
2011-12-19 19:47:43 -06:00
|
|
|
gboolean has_credreq; /* Whether querying 802.1x credentials is supported */
|
2012-02-07 23:46:12 -06:00
|
|
|
gboolean fast_supported;
|
2012-05-01 17:59:35 -05:00
|
|
|
guint32 max_scan_ssids;
|
2012-05-02 13:04:23 -05:00
|
|
|
guint32 ready_count;
|
2006-11-25 15:41:04 +00:00
|
|
|
|
2007-08-15 19:55:04 +00:00
|
|
|
char * object_path;
|
2006-12-03 20:04:11 +00:00
|
|
|
guint32 state;
|
2007-02-05 12:14:09 +00:00
|
|
|
NMCallStore * assoc_pcalls;
|
|
|
|
|
NMCallStore * other_pcalls;
|
2006-11-25 15:41:04 +00:00
|
|
|
|
2009-05-13 11:16:29 -04:00
|
|
|
gboolean scanning;
|
2006-12-04 05:45:05 +00:00
|
|
|
|
2010-10-06 11:05:21 -05:00
|
|
|
DBusGProxy * wpas_proxy;
|
2007-02-05 12:14:09 +00:00
|
|
|
DBusGProxy * iface_proxy;
|
2010-11-22 08:25:09 -06:00
|
|
|
DBusGProxy * props_proxy;
|
2010-11-22 09:05:09 -06:00
|
|
|
char * net_path;
|
2010-11-22 22:34:04 -06:00
|
|
|
guint32 blobs_left;
|
2012-02-20 15:06:05 -06:00
|
|
|
GHashTable * bss_proxies;
|
2007-02-05 12:14:09 +00:00
|
|
|
|
2006-12-03 20:04:11 +00:00
|
|
|
guint32 last_scan;
|
2006-11-25 15:41:04 +00:00
|
|
|
|
2006-12-03 20:04:11 +00:00
|
|
|
NMSupplicantConfig * cfg;
|
2006-11-25 15:41:04 +00:00
|
|
|
|
2010-10-05 14:19:43 -05:00
|
|
|
gboolean disposed;
|
2007-02-05 12:14:09 +00:00
|
|
|
} NMSupplicantInterfacePrivate;
|
2006-11-25 15:41:04 +00:00
|
|
|
|
2012-02-22 14:44:05 -06:00
|
|
|
/* FIXME: remove this and just store the standard D-Bus properties
|
|
|
|
|
* proxy object in bss_proxies when we drop support for wpa_supplicant
|
|
|
|
|
* 0.7.x.
|
|
|
|
|
*/
|
|
|
|
|
typedef struct {
|
|
|
|
|
/* Proxy for standard D-Bus Properties interface */
|
|
|
|
|
DBusGProxy *props;
|
|
|
|
|
/* Proxy for old wpa_supplicant-specific PropertiesChanged signal */
|
|
|
|
|
DBusGProxy *old_props;
|
|
|
|
|
} BssProxies;
|
|
|
|
|
|
|
|
|
|
static void
|
|
|
|
|
bss_proxies_free (gpointer data)
|
|
|
|
|
{
|
|
|
|
|
BssProxies *proxies = data;
|
|
|
|
|
|
|
|
|
|
g_object_unref (proxies->props);
|
|
|
|
|
g_object_unref (proxies->old_props);
|
|
|
|
|
memset (proxies, 0, sizeof (*proxies));
|
|
|
|
|
g_free (proxies);
|
|
|
|
|
}
|
|
|
|
|
|
2007-02-05 12:14:09 +00:00
|
|
|
static gboolean
|
|
|
|
|
cancel_all_cb (GObject *object, gpointer call_id, gpointer user_data)
|
2006-11-25 18:23:06 +00:00
|
|
|
{
|
2007-02-05 12:14:09 +00:00
|
|
|
dbus_g_proxy_cancel_call (DBUS_G_PROXY (object), (DBusGProxyCall *) call_id);
|
2006-11-25 18:23:06 +00:00
|
|
|
|
2007-02-05 12:14:09 +00:00
|
|
|
return TRUE;
|
|
|
|
|
}
|
2006-11-25 18:23:06 +00:00
|
|
|
|
2007-02-05 12:14:09 +00:00
|
|
|
static void
|
|
|
|
|
cancel_all_callbacks (NMCallStore *store)
|
|
|
|
|
{
|
|
|
|
|
nm_call_store_foreach (store, NULL, cancel_all_cb, NULL);
|
|
|
|
|
nm_call_store_clear (store);
|
2006-11-25 18:23:06 +00:00
|
|
|
}
|
|
|
|
|
|
2007-02-05 12:14:09 +00:00
|
|
|
typedef struct {
|
|
|
|
|
NMSupplicantInterface *interface;
|
|
|
|
|
DBusGProxy *proxy;
|
|
|
|
|
NMCallStore *store;
|
|
|
|
|
DBusGProxyCall *call;
|
2010-04-14 15:16:48 -07:00
|
|
|
gboolean disposing;
|
2007-02-05 12:14:09 +00:00
|
|
|
} NMSupplicantInfo;
|
|
|
|
|
|
2007-11-26 16:59:47 +00:00
|
|
|
static NMSupplicantInfo *
|
2007-02-05 12:14:09 +00:00
|
|
|
nm_supplicant_info_new (NMSupplicantInterface *interface,
|
2009-04-29 17:08:02 -04:00
|
|
|
DBusGProxy *proxy,
|
|
|
|
|
NMCallStore *store)
|
2006-11-25 18:23:06 +00:00
|
|
|
{
|
2007-02-05 12:14:09 +00:00
|
|
|
NMSupplicantInfo *info;
|
2006-11-25 18:23:06 +00:00
|
|
|
|
2007-02-05 12:14:09 +00:00
|
|
|
info = g_slice_new0 (NMSupplicantInfo);
|
2007-03-02 Tambet Ingo <tambet@ximian.com>
* libnm-glib/nm-device-802-11-wireless.c: Cache networks (bssids) list.
We get signalled when it changes.
* libnm-glib/nm-client.c: Cache NMState and device list, we get signalled
when it changes.
* libnm-glib/nm-device.c: Cache the device state property.
* libnm-glib/nm-access-point.c: Cache the strength property.
* src/nm-device-802-11-wireless.c: Fix wireless device scanning scheduler.
The new algorithm is to start from SCAN_INTERVAL_MIN (currently defined as 0)
and add a SCAN_INTERVAL_STEP (currently 20 seconds) with each successful scan
until SCAN_INTERVAL_MAX (currently 120 seconds) is reached. Do not scan while
the device is down, activating, or activated (in case of A/B/G cards).
Remove some old dead ifdef'ed out code that used to configure wireless devices,
it's all done through supplicant now.
* src/supplicant-manager/nm-supplicant-interface.c: Fix the reference
counting issues with pending calls which caused leaks and crashes when
interface was removed (now that the interface actually gets removed).
* src/nm-call-store.c: Make a copy of data before running a foreach
with user callback on it - The most common usage pattern is to cancel
(and thus remove) all pending calls with foreach which would modify
the hash table we're iterating over.
* src/nm-manager.c: When a device is added, make sure it is "up". When
it's removed or disabled due to disabling wireless or networking, bring
it down.
* include/NetworkManager.h: Add new device state NM_DEVICE_STATE_DOWN.
* src/nm-device-802-11-wireless.c:
* src/nm-device-802-3-ethernet.c:
* src/nm-device.c:
- Remove "init" virtual function, all gobjects have a place for that
already (constructor).
- Replace "start" virtual function with "bring_up", devices can be
brought up and down more than just on startup now.
- Add "is_up" virtual function.
- Implement one way to bring a device down instead of previous 4 different
ways, each of witch did something different.
* src/NetworkManagerUtils.c (nm_dev_sock_open): This doesn't need an NMDevice,
all it needs is the device interface.
Get rid of NMData.dev_list (3 members to go).
Get rif of NMData in a lot of places.
* gnome/libnm_glib/libnm_glib.c: Make it compile again.
git-svn-id: http://svn-archive.gnome.org/svn/NetworkManager/trunk@2395 4912f4e0-d625-0410-9fb7-b9a5a253dbdc
2007-03-02 09:30:48 +00:00
|
|
|
info->interface = g_object_ref (interface);
|
2007-02-05 12:14:09 +00:00
|
|
|
info->proxy = g_object_ref (proxy);
|
|
|
|
|
info->store = store;
|
2006-11-25 18:23:06 +00:00
|
|
|
|
2007-02-05 12:14:09 +00:00
|
|
|
return info;
|
|
|
|
|
}
|
2006-11-25 18:23:06 +00:00
|
|
|
|
2007-02-05 12:14:09 +00:00
|
|
|
static void
|
|
|
|
|
nm_supplicant_info_set_call (NMSupplicantInfo *info, DBusGProxyCall *call)
|
|
|
|
|
{
|
2010-04-14 15:16:48 -07:00
|
|
|
g_return_if_fail (info != NULL);
|
|
|
|
|
g_return_if_fail (call != NULL);
|
|
|
|
|
|
|
|
|
|
nm_call_store_add (info->store, G_OBJECT (info->proxy), (gpointer) call);
|
|
|
|
|
info->call = call;
|
2006-11-25 18:23:06 +00:00
|
|
|
}
|
|
|
|
|
|
2007-02-05 12:14:09 +00:00
|
|
|
static void
|
|
|
|
|
nm_supplicant_info_destroy (gpointer user_data)
|
2006-11-25 18:23:06 +00:00
|
|
|
{
|
2007-02-05 12:14:09 +00:00
|
|
|
NMSupplicantInfo *info = (NMSupplicantInfo *) user_data;
|
2006-11-25 18:23:06 +00:00
|
|
|
|
2010-04-14 15:16:48 -07:00
|
|
|
/* Guard against double-disposal; since DBusGProxy doesn't guard against
|
|
|
|
|
* double-disposal, we could infinite loop here if we're in the middle of
|
|
|
|
|
* some wpa_supplicant D-Bus calls. When the supplicant dies we'll dispose
|
|
|
|
|
* of the proxy, which kills all its pending calls, which brings us here.
|
|
|
|
|
* Then when we unref the proxy here, its dispose() function will get called
|
|
|
|
|
* again, and we get right back here until we segfault because our callstack
|
|
|
|
|
* is too long.
|
|
|
|
|
*/
|
|
|
|
|
if (!info->disposing) {
|
|
|
|
|
info->disposing = TRUE;
|
2006-11-25 18:23:06 +00:00
|
|
|
|
2010-04-14 15:22:48 -07:00
|
|
|
if (info->call) {
|
2010-04-14 15:16:48 -07:00
|
|
|
nm_call_store_remove (info->store, G_OBJECT (info->proxy), info->call);
|
2010-04-14 15:22:48 -07:00
|
|
|
info->call = NULL;
|
|
|
|
|
}
|
2007-02-05 12:14:09 +00:00
|
|
|
|
2010-04-14 15:16:48 -07:00
|
|
|
g_object_unref (info->proxy);
|
2010-04-14 15:22:48 -07:00
|
|
|
info->proxy = NULL;
|
2010-04-14 15:16:48 -07:00
|
|
|
g_object_unref (info->interface);
|
2010-04-14 15:22:48 -07:00
|
|
|
info->interface = NULL;
|
2010-04-14 15:16:48 -07:00
|
|
|
|
2010-04-14 15:22:48 -07:00
|
|
|
memset (info, 0, sizeof (NMSupplicantInfo));
|
2010-04-14 15:16:48 -07:00
|
|
|
g_slice_free (NMSupplicantInfo, info);
|
|
|
|
|
}
|
2006-11-25 18:23:06 +00:00
|
|
|
}
|
|
|
|
|
|
2006-12-19 19:15:31 +00:00
|
|
|
static void
|
2007-02-05 12:14:09 +00:00
|
|
|
emit_error_helper (NMSupplicantInterface *self,
|
|
|
|
|
GError *err)
|
2006-12-19 19:15:31 +00:00
|
|
|
{
|
2007-02-05 12:14:09 +00:00
|
|
|
const char *name = NULL;
|
2006-12-19 19:15:31 +00:00
|
|
|
|
2007-02-05 12:14:09 +00:00
|
|
|
if (err->domain == DBUS_GERROR && err->code == DBUS_GERROR_REMOTE_EXCEPTION)
|
|
|
|
|
name = dbus_g_error_get_name (err);
|
|
|
|
|
|
2010-10-05 14:19:43 -05:00
|
|
|
g_signal_emit (self, signals[CONNECTION_ERROR], 0, name, err->message);
|
2006-12-19 19:15:31 +00:00
|
|
|
}
|
|
|
|
|
|
2012-02-20 15:06:05 -06:00
|
|
|
static void
|
|
|
|
|
signal_new_bss (NMSupplicantInterface *self,
|
|
|
|
|
const char *object_path,
|
|
|
|
|
GHashTable *props)
|
|
|
|
|
{
|
|
|
|
|
g_signal_emit (self, signals[NEW_BSS], 0, object_path, props);
|
|
|
|
|
}
|
|
|
|
|
|
2006-11-25 15:41:04 +00:00
|
|
|
static void
|
2007-02-05 12:14:09 +00:00
|
|
|
bssid_properties_cb (DBusGProxy *proxy, DBusGProxyCall *call_id, gpointer user_data)
|
2006-11-25 15:41:04 +00:00
|
|
|
{
|
2007-02-05 12:14:09 +00:00
|
|
|
NMSupplicantInfo *info = (NMSupplicantInfo *) user_data;
|
2010-11-22 08:25:09 -06:00
|
|
|
GError *error = NULL;
|
|
|
|
|
GHashTable *props = NULL;
|
2007-02-05 12:14:09 +00:00
|
|
|
|
2010-11-22 08:25:09 -06:00
|
|
|
if (dbus_g_proxy_end_call (proxy, call_id, &error,
|
|
|
|
|
DBUS_TYPE_G_MAP_OF_VARIANT, &props,
|
|
|
|
|
G_TYPE_INVALID)) {
|
2012-02-20 15:06:05 -06:00
|
|
|
signal_new_bss (info->interface, dbus_g_proxy_get_path (proxy), props);
|
2010-11-22 08:25:09 -06:00
|
|
|
g_hash_table_destroy (props);
|
|
|
|
|
} else {
|
|
|
|
|
if (!strstr (error->message, "The BSSID requested was invalid")) {
|
2010-04-07 10:13:12 -07:00
|
|
|
nm_log_warn (LOGD_SUPPLICANT, "Couldn't retrieve BSSID properties: %s.",
|
2010-11-22 08:25:09 -06:00
|
|
|
error->message);
|
2010-04-07 10:13:12 -07:00
|
|
|
}
|
2010-11-22 08:25:09 -06:00
|
|
|
g_error_free (error);
|
2006-12-04 19:07:22 +00:00
|
|
|
}
|
2006-11-25 18:23:06 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
static void
|
2012-02-20 15:06:05 -06:00
|
|
|
bss_properties_changed (DBusGProxy *proxy,
|
|
|
|
|
const char *interface,
|
|
|
|
|
GHashTable *props,
|
|
|
|
|
const char **unused,
|
|
|
|
|
gpointer user_data)
|
|
|
|
|
{
|
|
|
|
|
NMSupplicantInterface *self = NM_SUPPLICANT_INTERFACE (user_data);
|
|
|
|
|
|
2012-02-22 14:44:05 -06:00
|
|
|
if (g_strcmp0 (interface, WPAS_DBUS_IFACE_BSS) == 0)
|
|
|
|
|
g_signal_emit (self, signals[BSS_UPDATED], 0, dbus_g_proxy_get_path (proxy), props);
|
|
|
|
|
}
|
2012-02-20 15:06:05 -06:00
|
|
|
|
2012-02-22 14:44:05 -06:00
|
|
|
static void
|
|
|
|
|
old_bss_properties_changed (DBusGProxy *proxy,
|
|
|
|
|
GHashTable *props,
|
|
|
|
|
gpointer user_data)
|
|
|
|
|
{
|
|
|
|
|
NMSupplicantInterface *self = NM_SUPPLICANT_INTERFACE (user_data);
|
|
|
|
|
|
|
|
|
|
g_signal_emit (self, signals[BSS_UPDATED], 0, dbus_g_proxy_get_path (proxy), props);
|
2012-02-20 15:06:05 -06:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
static void
|
|
|
|
|
handle_new_bss (NMSupplicantInterface *self,
|
|
|
|
|
const char *object_path,
|
|
|
|
|
GHashTable *props)
|
2006-11-25 18:23:06 +00:00
|
|
|
{
|
2007-02-05 12:14:09 +00:00
|
|
|
NMSupplicantInterfacePrivate *priv = NM_SUPPLICANT_INTERFACE_GET_PRIVATE (self);
|
2012-02-20 15:06:05 -06:00
|
|
|
NMSupplicantInfo *info;
|
|
|
|
|
DBusGProxyCall *call;
|
2012-02-22 14:44:05 -06:00
|
|
|
BssProxies *proxies;
|
2012-02-20 15:06:05 -06:00
|
|
|
|
|
|
|
|
g_return_if_fail (object_path != NULL);
|
|
|
|
|
|
|
|
|
|
if (g_hash_table_lookup (priv->bss_proxies, object_path))
|
|
|
|
|
return;
|
|
|
|
|
|
2012-02-22 14:44:05 -06:00
|
|
|
proxies = g_malloc0 (sizeof (*proxies));
|
|
|
|
|
proxies->props = dbus_g_proxy_new_for_name (nm_dbus_manager_get_connection (priv->dbus_mgr),
|
|
|
|
|
WPAS_DBUS_SERVICE,
|
|
|
|
|
object_path,
|
|
|
|
|
DBUS_INTERFACE_PROPERTIES);
|
|
|
|
|
proxies->old_props = dbus_g_proxy_new_for_name (nm_dbus_manager_get_connection (priv->dbus_mgr),
|
|
|
|
|
WPAS_DBUS_SERVICE,
|
|
|
|
|
object_path,
|
|
|
|
|
WPAS_DBUS_IFACE_BSS);
|
2012-02-20 15:06:05 -06:00
|
|
|
g_hash_table_insert (priv->bss_proxies,
|
2012-02-22 14:44:05 -06:00
|
|
|
(gpointer) dbus_g_proxy_get_path (proxies->props),
|
|
|
|
|
proxies);
|
2012-02-20 15:06:05 -06:00
|
|
|
|
2012-02-22 14:44:05 -06:00
|
|
|
/* Standard D-Bus PropertiesChanged signal */
|
2012-02-20 15:06:05 -06:00
|
|
|
dbus_g_object_register_marshaller (_nm_marshal_VOID__STRING_BOXED_BOXED,
|
|
|
|
|
G_TYPE_NONE,
|
|
|
|
|
G_TYPE_STRING, DBUS_TYPE_G_MAP_OF_VARIANT, G_TYPE_STRV,
|
|
|
|
|
G_TYPE_INVALID);
|
2012-02-22 14:44:05 -06:00
|
|
|
dbus_g_proxy_add_signal (proxies->props, "PropertiesChanged",
|
2012-02-20 15:06:05 -06:00
|
|
|
G_TYPE_STRING, DBUS_TYPE_G_MAP_OF_VARIANT, G_TYPE_STRV,
|
|
|
|
|
G_TYPE_INVALID);
|
2012-02-22 14:44:05 -06:00
|
|
|
dbus_g_proxy_connect_signal (proxies->props, "PropertiesChanged",
|
2012-02-20 15:06:05 -06:00
|
|
|
G_CALLBACK (bss_properties_changed),
|
|
|
|
|
self, NULL);
|
|
|
|
|
|
2012-02-22 14:44:05 -06:00
|
|
|
/* Old wpa_supplicant-specific PropertiesChanged signal; since it's using
|
|
|
|
|
* a different interface, we have to use a different DBusGProxy
|
|
|
|
|
*/
|
|
|
|
|
dbus_g_object_register_marshaller (g_cclosure_marshal_VOID__BOXED,
|
|
|
|
|
G_TYPE_NONE,
|
|
|
|
|
DBUS_TYPE_G_MAP_OF_VARIANT,
|
|
|
|
|
G_TYPE_INVALID);
|
|
|
|
|
dbus_g_proxy_add_signal (proxies->old_props, "PropertiesChanged",
|
|
|
|
|
DBUS_TYPE_G_MAP_OF_VARIANT,
|
|
|
|
|
G_TYPE_INVALID);
|
|
|
|
|
dbus_g_proxy_connect_signal (proxies->old_props, "PropertiesChanged",
|
|
|
|
|
G_CALLBACK (old_bss_properties_changed),
|
|
|
|
|
self, NULL);
|
|
|
|
|
|
2012-02-20 15:06:05 -06:00
|
|
|
if (props) {
|
|
|
|
|
signal_new_bss (self, object_path, props);
|
|
|
|
|
} else {
|
2012-02-22 14:44:05 -06:00
|
|
|
info = nm_supplicant_info_new (self, proxies->props, priv->other_pcalls);
|
|
|
|
|
call = dbus_g_proxy_begin_call (proxies->props, "GetAll",
|
2012-02-20 15:06:05 -06:00
|
|
|
bssid_properties_cb,
|
|
|
|
|
info,
|
|
|
|
|
nm_supplicant_info_destroy,
|
|
|
|
|
G_TYPE_STRING, WPAS_DBUS_IFACE_BSS,
|
|
|
|
|
G_TYPE_INVALID);
|
2010-11-22 08:25:09 -06:00
|
|
|
nm_supplicant_info_set_call (info, call);
|
2006-11-25 18:23:06 +00:00
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
static void
|
2010-11-22 08:25:09 -06:00
|
|
|
wpas_iface_bss_added (DBusGProxy *proxy,
|
|
|
|
|
const char *object_path,
|
|
|
|
|
GHashTable *props,
|
|
|
|
|
gpointer user_data)
|
2006-11-25 18:23:06 +00:00
|
|
|
{
|
2012-02-20 15:06:05 -06:00
|
|
|
handle_new_bss (NM_SUPPLICANT_INTERFACE (user_data), object_path, props);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
static void
|
|
|
|
|
wpas_iface_bss_removed (DBusGProxy *proxy,
|
|
|
|
|
const char *object_path,
|
|
|
|
|
gpointer user_data)
|
|
|
|
|
{
|
|
|
|
|
NMSupplicantInterface *self = NM_SUPPLICANT_INTERFACE (user_data);
|
|
|
|
|
NMSupplicantInterfacePrivate *priv = NM_SUPPLICANT_INTERFACE_GET_PRIVATE (self);
|
|
|
|
|
|
2012-03-02 18:17:34 -06:00
|
|
|
g_signal_emit (self, signals[BSS_REMOVED], 0, object_path);
|
|
|
|
|
|
2012-02-20 15:06:05 -06:00
|
|
|
g_hash_table_remove (priv->bss_proxies, object_path);
|
2006-11-25 18:23:06 +00:00
|
|
|
}
|
2006-11-25 15:41:04 +00:00
|
|
|
|
2010-10-11 20:35:54 -05:00
|
|
|
static int
|
2010-10-06 11:05:21 -05:00
|
|
|
wpas_state_string_to_enum (const char *str_state)
|
2006-12-04 05:45:05 +00:00
|
|
|
{
|
2012-05-11 17:15:40 -05:00
|
|
|
if (!strcmp (str_state, "interface_disabled"))
|
|
|
|
|
return NM_SUPPLICANT_INTERFACE_STATE_DISABLED;
|
|
|
|
|
else if (!strcmp (str_state, "disconnected"))
|
2010-10-11 20:35:54 -05:00
|
|
|
return NM_SUPPLICANT_INTERFACE_STATE_DISCONNECTED;
|
2010-11-22 08:25:09 -06:00
|
|
|
else if (!strcmp (str_state, "inactive"))
|
2010-10-11 20:35:54 -05:00
|
|
|
return NM_SUPPLICANT_INTERFACE_STATE_INACTIVE;
|
2010-11-22 08:25:09 -06:00
|
|
|
else if (!strcmp (str_state, "scanning"))
|
2010-10-11 20:35:54 -05:00
|
|
|
return NM_SUPPLICANT_INTERFACE_STATE_SCANNING;
|
2011-03-17 12:35:58 -05:00
|
|
|
else if (!strcmp (str_state, "authenticating"))
|
|
|
|
|
return NM_SUPPLICANT_INTERFACE_STATE_AUTHENTICATING;
|
2010-11-22 08:25:09 -06:00
|
|
|
else if (!strcmp (str_state, "associating"))
|
2010-10-11 20:35:54 -05:00
|
|
|
return NM_SUPPLICANT_INTERFACE_STATE_ASSOCIATING;
|
2010-11-22 08:25:09 -06:00
|
|
|
else if (!strcmp (str_state, "associated"))
|
2010-10-11 20:35:54 -05:00
|
|
|
return NM_SUPPLICANT_INTERFACE_STATE_ASSOCIATED;
|
2010-11-22 08:25:09 -06:00
|
|
|
else if (!strcmp (str_state, "4way_handshake"))
|
2010-10-11 20:35:54 -05:00
|
|
|
return NM_SUPPLICANT_INTERFACE_STATE_4WAY_HANDSHAKE;
|
2010-11-22 08:25:09 -06:00
|
|
|
else if (!strcmp (str_state, "group_handshake"))
|
2010-10-11 20:35:54 -05:00
|
|
|
return NM_SUPPLICANT_INTERFACE_STATE_GROUP_HANDSHAKE;
|
2010-11-22 08:25:09 -06:00
|
|
|
else if (!strcmp (str_state, "completed"))
|
2010-10-11 20:35:54 -05:00
|
|
|
return NM_SUPPLICANT_INTERFACE_STATE_COMPLETED;
|
2006-12-04 05:45:05 +00:00
|
|
|
|
2011-03-17 12:35:58 -05:00
|
|
|
nm_log_warn (LOGD_SUPPLICANT, "Unknown supplicant state '%s'", str_state);
|
2010-10-11 20:35:54 -05:00
|
|
|
return -1;
|
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) {
|
|
|
|
|
/* Get properties again to update to the actual wpa_supplicant
|
|
|
|
|
* interface state.
|
|
|
|
|
*/
|
|
|
|
|
wpas_iface_get_props (self);
|
|
|
|
|
} else if (new_state == NM_SUPPLICANT_INTERFACE_STATE_DOWN) {
|
2010-10-06 11:05:21 -05:00
|
|
|
/* Cancel all pending calls when going down */
|
|
|
|
|
cancel_all_callbacks (priv->other_pcalls);
|
|
|
|
|
cancel_all_callbacks (priv->assoc_pcalls);
|
|
|
|
|
|
|
|
|
|
/* Disconnect supplicant manager state listeners since we're done */
|
2010-10-12 14:18:42 -05:00
|
|
|
if (priv->smgr_avail_id) {
|
|
|
|
|
g_signal_handler_disconnect (priv->smgr, priv->smgr_avail_id);
|
|
|
|
|
priv->smgr_avail_id = 0;
|
2010-10-06 11:05:21 -05:00
|
|
|
}
|
2010-10-11 20:30:40 -05:00
|
|
|
|
|
|
|
|
if (priv->iface_proxy) {
|
|
|
|
|
dbus_g_proxy_disconnect_signal (priv->iface_proxy,
|
2010-11-22 08:25:09 -06:00
|
|
|
"PropertiesChanged",
|
|
|
|
|
G_CALLBACK (wpas_iface_properties_changed),
|
2010-10-11 20:30:40 -05:00
|
|
|
self);
|
|
|
|
|
dbus_g_proxy_disconnect_signal (priv->iface_proxy,
|
2010-11-22 08:25:09 -06:00
|
|
|
"ScanDone",
|
|
|
|
|
G_CALLBACK (wpas_iface_scan_done),
|
2010-10-11 20:30:40 -05:00
|
|
|
self);
|
|
|
|
|
dbus_g_proxy_disconnect_signal (priv->iface_proxy,
|
2010-11-22 08:25:09 -06:00
|
|
|
"BSSAdded",
|
|
|
|
|
G_CALLBACK (wpas_iface_bss_added),
|
2010-10-11 20:30:40 -05:00
|
|
|
self);
|
2012-02-20 15:06:05 -06:00
|
|
|
dbus_g_proxy_disconnect_signal (priv->iface_proxy,
|
|
|
|
|
"BSSRemoved",
|
|
|
|
|
G_CALLBACK (wpas_iface_bss_removed),
|
|
|
|
|
self);
|
2010-10-11 20:30:40 -05:00
|
|
|
}
|
2010-10-06 11:05:21 -05:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
priv->state = new_state;
|
|
|
|
|
g_signal_emit (self, signals[STATE], 0, priv->state, old_state);
|
|
|
|
|
}
|
|
|
|
|
|
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);
|
|
|
|
|
GTimeVal cur_time;
|
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 */
|
|
|
|
|
if (priv->scanning == FALSE) {
|
|
|
|
|
g_get_current_time (&cur_time);
|
|
|
|
|
priv->last_scan = cur_time.tv_sec;
|
|
|
|
|
}
|
2010-10-11 20:35:54 -05:00
|
|
|
|
2010-11-22 08:25:09 -06:00
|
|
|
g_object_notify (G_OBJECT (self), "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;
|
|
|
|
|
}
|
|
|
|
|
|
2006-12-12 03:27:35 +00:00
|
|
|
static void
|
2010-11-22 08:25:09 -06:00
|
|
|
wpas_iface_scan_done (DBusGProxy *proxy,
|
|
|
|
|
gboolean success,
|
|
|
|
|
gpointer user_data)
|
2006-12-12 03:27:35 +00:00
|
|
|
{
|
2010-11-22 08:25:09 -06:00
|
|
|
NMSupplicantInterface *self = NM_SUPPLICANT_INTERFACE (user_data);
|
2007-02-05 12:14:09 +00:00
|
|
|
NMSupplicantInterfacePrivate *priv = NM_SUPPLICANT_INTERFACE_GET_PRIVATE (self);
|
2010-11-22 08:25:09 -06:00
|
|
|
GTimeVal cur_time;
|
2007-02-05 12:14:09 +00:00
|
|
|
|
2010-11-22 08:25:09 -06:00
|
|
|
/* Cache last scan completed time */
|
|
|
|
|
g_get_current_time (&cur_time);
|
|
|
|
|
priv->last_scan = cur_time.tv_sec;
|
|
|
|
|
|
|
|
|
|
g_signal_emit (self, signals[SCAN_DONE], 0, success);
|
2006-12-12 03:27:35 +00:00
|
|
|
}
|
2006-11-25 15:41:04 +00:00
|
|
|
|
2012-05-01 17:59:35 -05:00
|
|
|
static void
|
|
|
|
|
parse_capabilities (NMSupplicantInterface *self, GHashTable *props)
|
|
|
|
|
{
|
|
|
|
|
NMSupplicantInterfacePrivate *priv = NM_SUPPLICANT_INTERFACE_GET_PRIVATE (self);
|
|
|
|
|
GValue *value;
|
|
|
|
|
gboolean have_active = FALSE, have_ssid = FALSE;
|
|
|
|
|
|
|
|
|
|
g_return_if_fail (props != NULL);
|
|
|
|
|
|
|
|
|
|
value = g_hash_table_lookup (props, "Scan");
|
|
|
|
|
if (value && G_VALUE_HOLDS (value, G_TYPE_STRV)) {
|
|
|
|
|
const char **vals = g_value_get_boxed (value);
|
|
|
|
|
const char **iter = vals;
|
|
|
|
|
|
|
|
|
|
while (iter && *iter && (!have_active || !have_ssid)) {
|
|
|
|
|
if (g_strcmp0 (*iter, "active") == 0)
|
|
|
|
|
have_active = TRUE;
|
|
|
|
|
else if (g_strcmp0 (*iter, "ssid") == 0)
|
|
|
|
|
have_ssid = TRUE;
|
|
|
|
|
iter++;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
value = g_hash_table_lookup (props, "MaxScanSSID");
|
|
|
|
|
if (value && G_VALUE_HOLDS (value, G_TYPE_INT)) {
|
|
|
|
|
/* We need active scan and SSID probe capabilities to care about MaxScanSSIDs */
|
|
|
|
|
if (have_active && have_ssid) {
|
|
|
|
|
/* 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.
|
|
|
|
|
*/
|
|
|
|
|
priv->max_scan_ssids = CLAMP (g_value_get_int (value), 0, 5);
|
|
|
|
|
nm_log_info (LOGD_SUPPLICANT, "(%s) supports %d scan SSIDs",
|
|
|
|
|
priv->dev, priv->max_scan_ssids);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
2009-05-13 11:16:29 -04:00
|
|
|
static void
|
2010-11-22 08:25:09 -06:00
|
|
|
wpas_iface_properties_changed (DBusGProxy *proxy,
|
|
|
|
|
GHashTable *props,
|
|
|
|
|
gpointer user_data)
|
|
|
|
|
{
|
|
|
|
|
NMSupplicantInterface *self = NM_SUPPLICANT_INTERFACE (user_data);
|
2012-05-02 13:04:23 -05:00
|
|
|
NMSupplicantInterfacePrivate *priv = NM_SUPPLICANT_INTERFACE_GET_PRIVATE (self);
|
2010-11-22 08:25:09 -06:00
|
|
|
GValue *value;
|
|
|
|
|
|
|
|
|
|
value = g_hash_table_lookup (props, "Scanning");
|
|
|
|
|
if (value && G_VALUE_HOLDS_BOOLEAN (value))
|
|
|
|
|
set_scanning (self, g_value_get_boolean (value));
|
|
|
|
|
|
|
|
|
|
value = g_hash_table_lookup (props, "State");
|
2012-05-02 13:04:23 -05:00
|
|
|
if (value && G_VALUE_HOLDS_STRING (value)) {
|
|
|
|
|
if (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, g_value_get_string (value));
|
|
|
|
|
}
|
|
|
|
|
}
|
2010-11-22 08:25:09 -06:00
|
|
|
|
|
|
|
|
value = g_hash_table_lookup (props, "BSSs");
|
2012-02-20 15:06:05 -06:00
|
|
|
if (value && G_VALUE_HOLDS (value, DBUS_TYPE_G_ARRAY_OF_OBJECT_PATH)) {
|
|
|
|
|
GPtrArray *paths = g_value_get_boxed (value);
|
|
|
|
|
int i;
|
|
|
|
|
|
|
|
|
|
for (i = 0; paths && (i < paths->len); i++)
|
|
|
|
|
handle_new_bss (self, g_ptr_array_index (paths, i), NULL);
|
|
|
|
|
}
|
2012-05-01 17:59:35 -05:00
|
|
|
|
|
|
|
|
value = g_hash_table_lookup (props, "Capabilities");
|
|
|
|
|
if (value && G_VALUE_HOLDS (value, DBUS_TYPE_G_MAP_OF_VARIANT))
|
|
|
|
|
parse_capabilities (self, g_value_get_boxed (value));
|
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);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
2010-11-22 08:25:09 -06:00
|
|
|
static void
|
|
|
|
|
iface_get_props_cb (DBusGProxy *proxy, DBusGProxyCall *call_id, gpointer user_data)
|
2009-05-13 11:16:29 -04:00
|
|
|
{
|
|
|
|
|
NMSupplicantInfo *info = (NMSupplicantInfo *) user_data;
|
2010-11-22 08:25:09 -06:00
|
|
|
GHashTable *props = NULL;
|
|
|
|
|
GError *error = NULL;
|
2009-05-13 11:16:29 -04:00
|
|
|
|
2010-11-22 08:25:09 -06:00
|
|
|
if (dbus_g_proxy_end_call (proxy, call_id, &error,
|
|
|
|
|
DBUS_TYPE_G_MAP_OF_VARIANT, &props,
|
|
|
|
|
G_TYPE_INVALID)) {
|
|
|
|
|
wpas_iface_properties_changed (NULL, props, info->interface);
|
2010-12-11 11:59:40 -06:00
|
|
|
g_hash_table_destroy (props);
|
2010-11-22 08:25:09 -06:00
|
|
|
} else {
|
|
|
|
|
nm_log_warn (LOGD_SUPPLICANT, "could not get interface properties: %s.",
|
|
|
|
|
error && error->message ? error->message : "(unknown)");
|
|
|
|
|
g_clear_error (&error);
|
2009-05-13 11:16:29 -04:00
|
|
|
}
|
2012-05-02 13:04:23 -05:00
|
|
|
iface_check_ready (info->interface);
|
2009-05-13 11:16:29 -04:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
static void
|
2010-11-22 08:25:09 -06:00
|
|
|
wpas_iface_get_props (NMSupplicantInterface *self)
|
2009-05-13 11:16:29 -04:00
|
|
|
{
|
|
|
|
|
NMSupplicantInterfacePrivate *priv = NM_SUPPLICANT_INTERFACE_GET_PRIVATE (self);
|
|
|
|
|
NMSupplicantInfo *info;
|
|
|
|
|
DBusGProxyCall *call;
|
|
|
|
|
|
2010-11-22 08:25:09 -06:00
|
|
|
info = nm_supplicant_info_new (self, priv->props_proxy, priv->other_pcalls);
|
|
|
|
|
call = dbus_g_proxy_begin_call (priv->props_proxy, "GetAll",
|
|
|
|
|
iface_get_props_cb,
|
2009-05-13 11:16:29 -04:00
|
|
|
info,
|
|
|
|
|
nm_supplicant_info_destroy,
|
2010-11-22 08:25:09 -06:00
|
|
|
G_TYPE_STRING, WPAS_DBUS_IFACE_INTERFACE,
|
2009-05-13 11:16:29 -04:00
|
|
|
G_TYPE_INVALID);
|
|
|
|
|
nm_supplicant_info_set_call (info, call);
|
|
|
|
|
}
|
|
|
|
|
|
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;
|
|
|
|
|
|
|
|
|
|
g_return_val_if_fail (self != NULL, FALSE);
|
|
|
|
|
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);
|
|
|
|
|
return dbus_g_proxy_call_with_timeout (priv->iface_proxy, "NetworkReply",
|
|
|
|
|
5000,
|
|
|
|
|
error,
|
|
|
|
|
DBUS_TYPE_G_OBJECT_PATH, priv->net_path,
|
|
|
|
|
G_TYPE_STRING, field,
|
|
|
|
|
G_TYPE_STRING, value,
|
|
|
|
|
G_TYPE_INVALID);
|
|
|
|
|
}
|
|
|
|
|
|
2011-12-19 17:21:41 -06:00
|
|
|
static void
|
|
|
|
|
wpas_iface_network_request (DBusGProxy *proxy,
|
|
|
|
|
const char *object_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);
|
|
|
|
|
|
2011-12-19 19:47:43 -06:00
|
|
|
g_return_if_fail (priv->has_credreq == TRUE);
|
|
|
|
|
g_return_if_fail (priv->net_path != NULL);
|
|
|
|
|
g_return_if_fail (g_strcmp0 (object_path, priv->net_path) == 0);
|
2011-12-19 17:21:41 -06:00
|
|
|
|
2011-12-19 19:47:43 -06:00
|
|
|
g_signal_emit (self, signals[CREDENTIALS_REQUEST], 0, field, message);
|
|
|
|
|
}
|
2011-12-19 17:21:41 -06:00
|
|
|
|
|
|
|
|
static void
|
|
|
|
|
iface_check_netreply_cb (DBusGProxy *proxy, DBusGProxyCall *call_id, gpointer user_data)
|
|
|
|
|
{
|
|
|
|
|
NMSupplicantInfo *info = (NMSupplicantInfo *) user_data;
|
|
|
|
|
NMSupplicantInterfacePrivate *priv = NM_SUPPLICANT_INTERFACE_GET_PRIVATE (info->interface);
|
|
|
|
|
GError *error = NULL;
|
|
|
|
|
|
|
|
|
|
if ( dbus_g_proxy_end_call (proxy, call_id, &error, G_TYPE_INVALID)
|
|
|
|
|
|| dbus_g_error_has_name (error, "fi.w1.wpa_supplicant1.InvalidArgs")) {
|
|
|
|
|
/* 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 19:47:43 -06:00
|
|
|
priv->has_credreq = TRUE;
|
2011-12-19 17:21:41 -06:00
|
|
|
|
|
|
|
|
nm_log_dbg (LOGD_SUPPLICANT, "Supplicant %s network credentials requests",
|
2011-12-19 19:47:43 -06:00
|
|
|
priv->has_credreq ? "supports" : "does not support");
|
2011-12-19 17:21:41 -06:00
|
|
|
}
|
|
|
|
|
g_clear_error (&error);
|
2012-05-02 13:04:23 -05:00
|
|
|
|
|
|
|
|
iface_check_ready (info->interface);
|
2011-12-19 17:21:41 -06:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
static void
|
|
|
|
|
wpas_iface_check_network_reply (NMSupplicantInterface *self)
|
|
|
|
|
{
|
|
|
|
|
NMSupplicantInterfacePrivate *priv = NM_SUPPLICANT_INTERFACE_GET_PRIVATE (self);
|
|
|
|
|
NMSupplicantInfo *info;
|
|
|
|
|
DBusGProxyCall *call;
|
|
|
|
|
|
|
|
|
|
info = nm_supplicant_info_new (self, priv->props_proxy, priv->other_pcalls);
|
|
|
|
|
call = dbus_g_proxy_begin_call (priv->iface_proxy, "NetworkReply",
|
|
|
|
|
iface_check_netreply_cb,
|
|
|
|
|
info,
|
|
|
|
|
nm_supplicant_info_destroy,
|
|
|
|
|
DBUS_TYPE_G_OBJECT_PATH, "/foobaraasdfasdf",
|
|
|
|
|
G_TYPE_STRING, "foobar",
|
|
|
|
|
G_TYPE_STRING, "foobar",
|
|
|
|
|
G_TYPE_INVALID);
|
|
|
|
|
nm_supplicant_info_set_call (info, call);
|
|
|
|
|
}
|
|
|
|
|
|
2006-11-25 15:41:04 +00:00
|
|
|
static void
|
2010-10-06 11:05:21 -05:00
|
|
|
interface_add_done (NMSupplicantInterface *self, char *path)
|
|
|
|
|
{
|
|
|
|
|
NMSupplicantInterfacePrivate *priv = NM_SUPPLICANT_INTERFACE_GET_PRIVATE (self);
|
|
|
|
|
|
|
|
|
|
nm_log_dbg (LOGD_SUPPLICANT, "(%s): interface added to supplicant", priv->dev);
|
|
|
|
|
|
|
|
|
|
priv->object_path = path;
|
|
|
|
|
|
|
|
|
|
priv->iface_proxy = dbus_g_proxy_new_for_name (nm_dbus_manager_get_connection (priv->dbus_mgr),
|
|
|
|
|
WPAS_DBUS_SERVICE,
|
|
|
|
|
path,
|
|
|
|
|
WPAS_DBUS_IFACE_INTERFACE);
|
|
|
|
|
|
2010-11-22 08:25:09 -06:00
|
|
|
dbus_g_object_register_marshaller (g_cclosure_marshal_VOID__BOXED,
|
2010-10-06 11:05:21 -05:00
|
|
|
G_TYPE_NONE,
|
2010-11-22 08:25:09 -06:00
|
|
|
DBUS_TYPE_G_MAP_OF_VARIANT,
|
2010-10-06 11:05:21 -05:00
|
|
|
G_TYPE_INVALID);
|
2010-11-22 08:25:09 -06:00
|
|
|
dbus_g_proxy_add_signal (priv->iface_proxy, "PropertiesChanged",
|
|
|
|
|
DBUS_TYPE_G_MAP_OF_VARIANT, G_TYPE_INVALID);
|
|
|
|
|
dbus_g_proxy_connect_signal (priv->iface_proxy, "PropertiesChanged",
|
|
|
|
|
G_CALLBACK (wpas_iface_properties_changed),
|
|
|
|
|
self, NULL);
|
|
|
|
|
|
2011-07-29 08:39:05 -04:00
|
|
|
dbus_g_proxy_add_signal (priv->iface_proxy, "ScanDone",
|
|
|
|
|
G_TYPE_BOOLEAN, G_TYPE_INVALID);
|
2010-11-22 08:25:09 -06:00
|
|
|
dbus_g_proxy_connect_signal (priv->iface_proxy, "ScanDone",
|
|
|
|
|
G_CALLBACK (wpas_iface_scan_done),
|
2010-10-06 11:05:21 -05:00
|
|
|
self,
|
|
|
|
|
NULL);
|
|
|
|
|
|
2010-11-22 08:25:09 -06:00
|
|
|
dbus_g_object_register_marshaller (_nm_marshal_VOID__STRING_BOXED,
|
|
|
|
|
G_TYPE_NONE,
|
2011-07-29 08:39:05 -04:00
|
|
|
DBUS_TYPE_G_OBJECT_PATH, DBUS_TYPE_G_MAP_OF_VARIANT,
|
2010-11-22 08:25:09 -06:00
|
|
|
G_TYPE_INVALID);
|
2011-07-29 08:39:05 -04:00
|
|
|
dbus_g_proxy_add_signal (priv->iface_proxy, "BSSAdded",
|
|
|
|
|
DBUS_TYPE_G_OBJECT_PATH, DBUS_TYPE_G_MAP_OF_VARIANT,
|
|
|
|
|
G_TYPE_INVALID);
|
2010-11-22 08:25:09 -06:00
|
|
|
dbus_g_proxy_connect_signal (priv->iface_proxy, "BSSAdded",
|
|
|
|
|
G_CALLBACK (wpas_iface_bss_added),
|
2010-10-06 11:05:21 -05:00
|
|
|
self,
|
|
|
|
|
NULL);
|
|
|
|
|
|
2012-02-27 16:06:25 +01:00
|
|
|
dbus_g_object_register_marshaller (g_cclosure_marshal_VOID__BOXED,
|
2012-02-20 15:06:05 -06:00
|
|
|
G_TYPE_NONE,
|
|
|
|
|
DBUS_TYPE_G_OBJECT_PATH,
|
|
|
|
|
G_TYPE_INVALID);
|
|
|
|
|
dbus_g_proxy_add_signal (priv->iface_proxy, "BSSRemoved",
|
|
|
|
|
DBUS_TYPE_G_OBJECT_PATH,
|
|
|
|
|
G_TYPE_INVALID);
|
|
|
|
|
dbus_g_proxy_connect_signal (priv->iface_proxy, "BSSRemoved",
|
|
|
|
|
G_CALLBACK (wpas_iface_bss_removed),
|
|
|
|
|
self,
|
|
|
|
|
NULL);
|
|
|
|
|
|
2011-12-19 17:21:41 -06:00
|
|
|
dbus_g_object_register_marshaller (_nm_marshal_VOID__STRING_STRING_STRING,
|
|
|
|
|
G_TYPE_NONE,
|
|
|
|
|
DBUS_TYPE_G_OBJECT_PATH, G_TYPE_STRING, G_TYPE_STRING,
|
|
|
|
|
G_TYPE_INVALID);
|
|
|
|
|
dbus_g_proxy_add_signal (priv->iface_proxy, "NetworkRequest",
|
|
|
|
|
DBUS_TYPE_G_OBJECT_PATH, G_TYPE_STRING, G_TYPE_STRING,
|
|
|
|
|
G_TYPE_INVALID);
|
|
|
|
|
dbus_g_proxy_connect_signal (priv->iface_proxy, "NetworkRequest",
|
|
|
|
|
G_CALLBACK (wpas_iface_network_request),
|
|
|
|
|
self,
|
|
|
|
|
NULL);
|
|
|
|
|
|
2010-11-22 08:25:09 -06:00
|
|
|
priv->props_proxy = dbus_g_proxy_new_for_name (nm_dbus_manager_get_connection (priv->dbus_mgr),
|
|
|
|
|
WPAS_DBUS_SERVICE,
|
|
|
|
|
path,
|
|
|
|
|
DBUS_INTERFACE_PROPERTIES);
|
2012-05-02 13:04:23 -05:00
|
|
|
/* Get initial properties and check whether NetworkReply is supported */
|
2010-11-22 08:25:09 -06:00
|
|
|
wpas_iface_get_props (self);
|
2011-12-19 17:21:41 -06:00
|
|
|
wpas_iface_check_network_reply (self);
|
2012-05-02 13:04:23 -05:00
|
|
|
priv->ready_count = 2;
|
2010-10-06 11:05:21 -05:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
static void
|
|
|
|
|
interface_get_cb (DBusGProxy *proxy,
|
|
|
|
|
DBusGProxyCall *call_id,
|
|
|
|
|
gpointer user_data)
|
2006-11-25 15:41:04 +00:00
|
|
|
{
|
2007-02-05 12:14:09 +00:00
|
|
|
NMSupplicantInfo *info = (NMSupplicantInfo *) user_data;
|
2010-04-07 16:42:29 -07:00
|
|
|
NMSupplicantInterfacePrivate *priv = NM_SUPPLICANT_INTERFACE_GET_PRIVATE (info->interface);
|
2010-10-06 11:05:21 -05:00
|
|
|
GError *error = NULL;
|
2007-02-05 12:14:09 +00:00
|
|
|
char *path = NULL;
|
|
|
|
|
|
2010-10-06 11:05:21 -05:00
|
|
|
if (dbus_g_proxy_end_call (proxy, call_id, &error,
|
|
|
|
|
DBUS_TYPE_G_OBJECT_PATH, &path,
|
|
|
|
|
G_TYPE_INVALID)) {
|
|
|
|
|
interface_add_done (info->interface, path);
|
2007-02-05 12:14:09 +00:00
|
|
|
} else {
|
2010-12-07 13:58:49 -06:00
|
|
|
nm_log_err (LOGD_SUPPLICANT, "(%s): error getting interface: %s",
|
2010-10-06 11:05:21 -05:00
|
|
|
priv->dev, error->message);
|
|
|
|
|
g_clear_error (&error);
|
2010-12-07 13:58:49 -06:00
|
|
|
set_state (info->interface, NM_SUPPLICANT_INTERFACE_STATE_DOWN);
|
2006-11-25 15:41:04 +00:00
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
static void
|
2010-10-06 11:05:21 -05:00
|
|
|
interface_get (NMSupplicantInterface *self)
|
2006-11-25 15:41:04 +00:00
|
|
|
{
|
2007-02-05 12:14:09 +00:00
|
|
|
NMSupplicantInterfacePrivate *priv = NM_SUPPLICANT_INTERFACE_GET_PRIVATE (self);
|
|
|
|
|
NMSupplicantInfo *info;
|
|
|
|
|
DBusGProxyCall *call;
|
|
|
|
|
|
2010-10-06 11:05:21 -05:00
|
|
|
info = nm_supplicant_info_new (self, priv->wpas_proxy, priv->other_pcalls);
|
2010-11-18 17:02:04 -06:00
|
|
|
call = dbus_g_proxy_begin_call (priv->wpas_proxy, "GetInterface",
|
2010-10-06 11:05:21 -05:00
|
|
|
interface_get_cb,
|
|
|
|
|
info,
|
|
|
|
|
nm_supplicant_info_destroy,
|
|
|
|
|
G_TYPE_STRING, priv->dev,
|
|
|
|
|
G_TYPE_INVALID);
|
|
|
|
|
nm_supplicant_info_set_call (info, call);
|
|
|
|
|
}
|
2006-11-25 15:41:04 +00:00
|
|
|
|
2010-10-06 11:05:21 -05:00
|
|
|
static void
|
|
|
|
|
interface_add_cb (DBusGProxy *proxy,
|
|
|
|
|
DBusGProxyCall *call_id,
|
|
|
|
|
gpointer user_data)
|
|
|
|
|
{
|
|
|
|
|
NMSupplicantInfo *info = (NMSupplicantInfo *) user_data;
|
|
|
|
|
NMSupplicantInterfacePrivate *priv = NM_SUPPLICANT_INTERFACE_GET_PRIVATE (info->interface);
|
|
|
|
|
GError *error = NULL;
|
|
|
|
|
char *path = NULL;
|
2006-11-25 15:41:04 +00:00
|
|
|
|
2010-10-06 11:05:21 -05:00
|
|
|
if (dbus_g_proxy_end_call (proxy, call_id, &error,
|
|
|
|
|
DBUS_TYPE_G_OBJECT_PATH, &path,
|
|
|
|
|
G_TYPE_INVALID)) {
|
|
|
|
|
interface_add_done (info->interface, path);
|
|
|
|
|
} else {
|
|
|
|
|
if (dbus_g_error_has_name (error, WPAS_ERROR_EXISTS_ERROR)) {
|
|
|
|
|
/* Interface already added, just get its object path */
|
|
|
|
|
interface_get (info->interface);
|
2010-12-07 13:58:49 -06:00
|
|
|
} else if ( g_error_matches (error, DBUS_GERROR, DBUS_GERROR_SERVICE_UNKNOWN)
|
2011-07-28 09:54:06 -05:00
|
|
|
|| g_error_matches (error, DBUS_GERROR, DBUS_GERROR_SPAWN_EXEC_FAILED)
|
|
|
|
|
|| g_error_matches (error, DBUS_GERROR, DBUS_GERROR_SPAWN_FORK_FAILED)
|
|
|
|
|
|| g_error_matches (error, DBUS_GERROR, DBUS_GERROR_SPAWN_FAILED)
|
2010-12-07 13:58:49 -06:00
|
|
|
|| dbus_g_error_has_name (error, DBUS_ERROR_SPAWN_SERVICE_NOT_FOUND)) {
|
|
|
|
|
/* Supplicant wasn't running and could be launched via service
|
|
|
|
|
* activation. Wait for it to start by moving back to the INIT
|
|
|
|
|
* state.
|
|
|
|
|
*/
|
|
|
|
|
nm_log_dbg (LOGD_SUPPLICANT, "(%s): failed to activate supplicant: %s",
|
|
|
|
|
priv->dev, error->message);
|
|
|
|
|
set_state (info->interface, NM_SUPPLICANT_INTERFACE_STATE_INIT);
|
2010-10-06 11:05:21 -05:00
|
|
|
} else {
|
|
|
|
|
nm_log_err (LOGD_SUPPLICANT, "(%s): error adding interface: %s",
|
|
|
|
|
priv->dev, error->message);
|
2010-12-07 13:58:49 -06:00
|
|
|
set_state (info->interface, NM_SUPPLICANT_INTERFACE_STATE_DOWN);
|
2010-10-06 11:05:21 -05:00
|
|
|
}
|
|
|
|
|
g_clear_error (&error);
|
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
|
2010-10-11 20:30:40 -05:00
|
|
|
interface_add (NMSupplicantInterface *self, gboolean is_wireless)
|
2006-11-25 15:41:04 +00:00
|
|
|
{
|
2007-02-05 12:14:09 +00:00
|
|
|
NMSupplicantInterfacePrivate *priv = NM_SUPPLICANT_INTERFACE_GET_PRIVATE (self);
|
2010-10-06 11:05:21 -05:00
|
|
|
DBusGProxyCall *call;
|
|
|
|
|
NMSupplicantInfo *info;
|
|
|
|
|
GHashTable *hash;
|
2010-11-18 17:02:04 -06:00
|
|
|
GValue *driver, *ifname;
|
2006-11-25 15:41:04 +00:00
|
|
|
|
|
|
|
|
/* Can only start the interface from INIT state */
|
2007-02-05 12:14:09 +00:00
|
|
|
g_return_if_fail (priv->state == NM_SUPPLICANT_INTERFACE_STATE_INIT);
|
2006-11-25 15:41:04 +00:00
|
|
|
|
2010-04-07 16:42:29 -07:00
|
|
|
nm_log_dbg (LOGD_SUPPLICANT, "(%s): adding interface to supplicant", priv->dev);
|
|
|
|
|
|
2010-10-11 20:30:40 -05:00
|
|
|
/* Move to starting to prevent double-calls of interface_add() */
|
|
|
|
|
set_state (self, NM_SUPPLICANT_INTERFACE_STATE_STARTING);
|
|
|
|
|
|
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
|
|
|
|
2010-10-06 11:05:21 -05:00
|
|
|
info = nm_supplicant_info_new (self, priv->wpas_proxy, priv->other_pcalls);
|
2006-11-25 15:41:04 +00:00
|
|
|
|
2010-11-18 17:02:04 -06:00
|
|
|
hash = g_hash_table_new (g_str_hash, g_str_equal);
|
|
|
|
|
|
2010-10-06 11:05:21 -05:00
|
|
|
driver = g_new0 (GValue, 1);
|
|
|
|
|
g_value_init (driver, G_TYPE_STRING);
|
2012-02-29 23:11:04 -06:00
|
|
|
g_value_set_string (driver, is_wireless ? DEFAULT_WIFI_DRIVER : "wired");
|
2010-11-18 17:02:04 -06:00
|
|
|
g_hash_table_insert (hash, "Driver", driver);
|
2006-11-25 15:41:04 +00:00
|
|
|
|
2010-11-18 17:02:04 -06:00
|
|
|
ifname = g_new0 (GValue, 1);
|
|
|
|
|
g_value_init (ifname, G_TYPE_STRING);
|
|
|
|
|
g_value_set_string (ifname, priv->dev);
|
|
|
|
|
g_hash_table_insert (hash, "Ifname", ifname);
|
2006-11-25 15:41:04 +00:00
|
|
|
|
2010-11-18 17:02:04 -06:00
|
|
|
call = dbus_g_proxy_begin_call (priv->wpas_proxy, "CreateInterface",
|
2010-10-06 11:05:21 -05:00
|
|
|
interface_add_cb,
|
|
|
|
|
info,
|
|
|
|
|
nm_supplicant_info_destroy,
|
|
|
|
|
DBUS_TYPE_G_MAP_OF_VARIANT, hash,
|
|
|
|
|
G_TYPE_INVALID);
|
2006-11-25 15:41:04 +00:00
|
|
|
|
2010-10-06 11:05:21 -05:00
|
|
|
g_hash_table_destroy (hash);
|
|
|
|
|
g_value_unset (driver);
|
|
|
|
|
g_free (driver);
|
2010-11-18 17:02:04 -06:00
|
|
|
g_value_unset (ifname);
|
|
|
|
|
g_free (ifname);
|
2006-11-25 15:41:04 +00:00
|
|
|
|
2010-10-06 11:05:21 -05:00
|
|
|
nm_supplicant_info_set_call (info, call);
|
2006-11-25 15:41:04 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
static void
|
2010-10-12 14:18:42 -05:00
|
|
|
smgr_avail_cb (NMSupplicantManager *smgr,
|
|
|
|
|
GParamSpec *pspec,
|
|
|
|
|
gpointer user_data)
|
2006-11-25 15:41:04 +00:00
|
|
|
{
|
2010-10-06 11:05:21 -05:00
|
|
|
NMSupplicantInterface *self = NM_SUPPLICANT_INTERFACE (user_data);
|
|
|
|
|
NMSupplicantInterfacePrivate *priv = NM_SUPPLICANT_INTERFACE_GET_PRIVATE (user_data);
|
|
|
|
|
|
2010-10-12 14:18:42 -05:00
|
|
|
if (nm_supplicant_manager_available (smgr)) {
|
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)
|
|
|
|
|
interface_add (self, priv->is_wireless);
|
|
|
|
|
} 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
|
2007-02-05 12:14:09 +00:00
|
|
|
remove_network_cb (DBusGProxy *proxy, DBusGProxyCall *call_id, gpointer user_data)
|
2006-12-19 19:15:31 +00:00
|
|
|
{
|
2010-12-11 12:31:10 -06:00
|
|
|
GError *error = NULL;
|
2006-12-19 19:15:31 +00:00
|
|
|
|
2010-12-11 12:31:10 -06:00
|
|
|
if (!dbus_g_proxy_end_call (proxy, call_id, &error, G_TYPE_INVALID)) {
|
2010-04-07 10:13:12 -07:00
|
|
|
nm_log_dbg (LOGD_SUPPLICANT, "Couldn't remove network from supplicant interface: %s.",
|
2010-12-11 12:31:10 -06:00
|
|
|
error && error->message ? error->message : "(unknown)");
|
|
|
|
|
g_clear_error (&error);
|
2006-12-19 19:15:31 +00:00
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
static void
|
2007-02-05 12:14:09 +00:00
|
|
|
disconnect_cb (DBusGProxy *proxy, DBusGProxyCall *call_id, gpointer user_data)
|
2006-12-19 19:15:31 +00:00
|
|
|
{
|
2010-12-11 12:31:10 -06:00
|
|
|
GError *error = NULL;
|
2006-12-19 19:15:31 +00:00
|
|
|
|
2010-12-11 12:31:10 -06:00
|
|
|
if (!dbus_g_proxy_end_call (proxy, call_id, &error, G_TYPE_INVALID)) {
|
2010-04-07 10:13:12 -07:00
|
|
|
nm_log_warn (LOGD_SUPPLICANT, "Couldn't disconnect supplicant interface: %s.",
|
2010-12-11 12:31:10 -06:00
|
|
|
error && error->message ? error->message : "(unknown)");
|
|
|
|
|
g_clear_error (&error);
|
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
|
|
|
|
|
|
|
|
/* Clear and cancel all pending calls related to a prior
|
|
|
|
|
* connection attempt.
|
|
|
|
|
*/
|
2007-02-05 12:14:09 +00:00
|
|
|
cancel_all_callbacks (priv->assoc_pcalls);
|
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)) {
|
|
|
|
|
dbus_g_proxy_begin_call (priv->iface_proxy, "Disconnect",
|
|
|
|
|
disconnect_cb,
|
|
|
|
|
NULL, NULL,
|
|
|
|
|
G_TYPE_INVALID);
|
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) {
|
2010-11-22 08:25:09 -06:00
|
|
|
dbus_g_proxy_begin_call (priv->iface_proxy, "RemoveNetwork",
|
2009-04-29 17:08:02 -04:00
|
|
|
remove_network_cb,
|
|
|
|
|
NULL, NULL,
|
2010-11-22 09:05:09 -06:00
|
|
|
DBUS_TYPE_G_OBJECT_PATH, priv->net_path,
|
2009-04-29 17:08:02 -04:00
|
|
|
G_TYPE_INVALID);
|
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
|
2007-02-05 12:14:09 +00:00
|
|
|
select_network_cb (DBusGProxy *proxy, DBusGProxyCall *call_id, gpointer user_data)
|
2006-12-19 19:15:31 +00:00
|
|
|
{
|
2007-02-05 12:14:09 +00:00
|
|
|
NMSupplicantInfo *info = (NMSupplicantInfo *) user_data;
|
|
|
|
|
GError *err = NULL;
|
2006-12-19 19:15:31 +00:00
|
|
|
|
2010-11-22 09:05:09 -06:00
|
|
|
if (!dbus_g_proxy_end_call (proxy, call_id, &err, G_TYPE_INVALID)) {
|
2010-04-07 10:13:12 -07:00
|
|
|
nm_log_warn (LOGD_SUPPLICANT, "Couldn't select network config: %s.", err->message);
|
2007-02-05 12:14:09 +00:00
|
|
|
emit_error_helper (info->interface, err);
|
|
|
|
|
g_error_free (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
|
|
|
DBusGProxyCall *call;
|
2010-11-22 09:05:09 -06:00
|
|
|
NMSupplicantInfo *info;
|
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 */
|
|
|
|
|
if (priv->blobs_left > 0)
|
|
|
|
|
return;
|
|
|
|
|
|
2010-11-22 09:05:09 -06:00
|
|
|
info = nm_supplicant_info_new (self, priv->iface_proxy, priv->assoc_pcalls);
|
|
|
|
|
call = dbus_g_proxy_begin_call (priv->iface_proxy, "SelectNetwork",
|
|
|
|
|
select_network_cb,
|
2009-04-29 17:08:02 -04:00
|
|
|
info,
|
|
|
|
|
nm_supplicant_info_destroy,
|
2010-11-22 09:05:09 -06:00
|
|
|
DBUS_TYPE_G_OBJECT_PATH, priv->net_path,
|
2009-04-29 17:08:02 -04:00
|
|
|
G_TYPE_INVALID);
|
2007-10-20 20:31:29 +00:00
|
|
|
nm_supplicant_info_set_call (info, call);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
static void
|
2010-11-22 22:34:04 -06:00
|
|
|
add_blob_cb (DBusGProxy *proxy, DBusGProxyCall *call_id, gpointer user_data)
|
2007-10-20 20:31:29 +00:00
|
|
|
{
|
|
|
|
|
NMSupplicantInfo *info = (NMSupplicantInfo *) user_data;
|
2010-11-22 22:34:04 -06:00
|
|
|
NMSupplicantInterfacePrivate *priv = NM_SUPPLICANT_INTERFACE_GET_PRIVATE (info->interface);
|
2007-10-20 20:31:29 +00:00
|
|
|
GError *err = NULL;
|
|
|
|
|
guint tmp;
|
|
|
|
|
|
2010-11-22 22:34:04 -06:00
|
|
|
priv->blobs_left--;
|
|
|
|
|
|
2007-10-20 20:31:29 +00:00
|
|
|
if (!dbus_g_proxy_end_call (proxy, call_id, &err, G_TYPE_UINT, &tmp, G_TYPE_INVALID)) {
|
2010-04-07 10:13:12 -07:00
|
|
|
nm_log_warn (LOGD_SUPPLICANT, "Couldn't set network certificates: %s.", err->message);
|
2007-10-20 20:31:29 +00:00
|
|
|
emit_error_helper (info->interface, err);
|
|
|
|
|
g_error_free (err);
|
2010-11-22 09:05:09 -06:00
|
|
|
} else
|
|
|
|
|
call_select_network (info->interface);
|
2007-10-20 20:31:29 +00:00
|
|
|
}
|
|
|
|
|
|
2006-12-19 19:15:31 +00:00
|
|
|
static void
|
2007-02-05 12:14:09 +00:00
|
|
|
add_network_cb (DBusGProxy *proxy, DBusGProxyCall *call_id, gpointer user_data)
|
2006-12-19 19:15:31 +00:00
|
|
|
{
|
2007-02-05 12:14:09 +00:00
|
|
|
NMSupplicantInfo *info = (NMSupplicantInfo *) user_data;
|
2010-11-22 09:05:09 -06:00
|
|
|
NMSupplicantInterfacePrivate *priv = NM_SUPPLICANT_INTERFACE_GET_PRIVATE (info->interface);
|
2007-02-05 12:14:09 +00:00
|
|
|
GError *err = NULL;
|
2010-11-22 09:05:09 -06:00
|
|
|
GHashTable *blobs;
|
2010-11-22 22:34:04 -06:00
|
|
|
GHashTableIter iter;
|
|
|
|
|
gpointer name, data;
|
|
|
|
|
DBusGProxyCall *call;
|
|
|
|
|
NMSupplicantInfo *blob_info;
|
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
|
|
|
|
|
|
|
|
if (!dbus_g_proxy_end_call (proxy, call_id, &err,
|
2010-11-22 09:05:09 -06:00
|
|
|
DBUS_TYPE_G_OBJECT_PATH, &priv->net_path,
|
2009-04-29 17:08:02 -04:00
|
|
|
G_TYPE_INVALID)) {
|
2010-04-07 10:13:12 -07:00
|
|
|
nm_log_warn (LOGD_SUPPLICANT, "Couldn't add a network to the supplicant interface: %s.",
|
|
|
|
|
err->message);
|
2007-02-05 12:14:09 +00:00
|
|
|
emit_error_helper (info->interface, err);
|
|
|
|
|
g_error_free (err);
|
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
|
|
|
|
|
|
|
|
/* Send blobs first; otherwise jump to sending the config settings */
|
|
|
|
|
blobs = nm_supplicant_config_get_blobs (priv->cfg);
|
2010-11-22 22:34:04 -06:00
|
|
|
priv->blobs_left = g_hash_table_size (blobs);
|
|
|
|
|
g_hash_table_iter_init (&iter, blobs);
|
|
|
|
|
while (g_hash_table_iter_next (&iter, &name, &data)) {
|
|
|
|
|
blob_info = nm_supplicant_info_new (info->interface, priv->iface_proxy, priv->assoc_pcalls);
|
|
|
|
|
call = dbus_g_proxy_begin_call (priv->iface_proxy, "AddBlob",
|
|
|
|
|
add_blob_cb,
|
|
|
|
|
blob_info,
|
|
|
|
|
nm_supplicant_info_destroy,
|
|
|
|
|
DBUS_TYPE_STRING, name,
|
|
|
|
|
DBUS_TYPE_G_UCHAR_ARRAY, blobs,
|
|
|
|
|
G_TYPE_INVALID);
|
|
|
|
|
nm_supplicant_info_set_call (blob_info, call);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
call_select_network (info->interface);
|
2006-12-19 19:15:31 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
static void
|
2007-02-05 12:14:09 +00:00
|
|
|
set_ap_scan_cb (DBusGProxy *proxy, DBusGProxyCall *call_id, gpointer user_data)
|
2006-12-19 19:15:31 +00:00
|
|
|
{
|
2007-02-05 12:14:09 +00:00
|
|
|
NMSupplicantInfo *info = (NMSupplicantInfo *) user_data;
|
2010-04-07 10:13:12 -07:00
|
|
|
NMSupplicantInterfacePrivate *priv = NM_SUPPLICANT_INTERFACE_GET_PRIVATE (info->interface);
|
2007-02-05 12:14:09 +00:00
|
|
|
GError *err = NULL;
|
2007-11-21 05:57:54 +00:00
|
|
|
DBusGProxyCall *call;
|
2010-11-22 09:05:09 -06:00
|
|
|
GHashTable *config_hash;
|
2007-02-05 12:14:09 +00:00
|
|
|
|
2010-11-22 09:05:09 -06:00
|
|
|
if (!dbus_g_proxy_end_call (proxy, call_id, &err, G_TYPE_INVALID)) {
|
2010-04-07 10:13:12 -07:00
|
|
|
nm_log_warn (LOGD_SUPPLICANT, "Couldn't send AP scan mode to the supplicant interface: %s.",
|
|
|
|
|
err->message);
|
2007-02-05 12:14:09 +00:00
|
|
|
emit_error_helper (info->interface, err);
|
|
|
|
|
g_error_free (err);
|
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
|
|
|
|
2010-11-22 08:30:13 -06:00
|
|
|
info = nm_supplicant_info_new (info->interface, priv->iface_proxy, info->store);
|
2010-11-22 09:05:09 -06:00
|
|
|
config_hash = nm_supplicant_config_get_hash (priv->cfg);
|
2010-11-22 08:30:13 -06:00
|
|
|
call = dbus_g_proxy_begin_call (priv->iface_proxy, "AddNetwork",
|
2009-04-29 17:08:02 -04:00
|
|
|
add_network_cb,
|
|
|
|
|
info,
|
|
|
|
|
nm_supplicant_info_destroy,
|
2010-11-22 09:05:09 -06:00
|
|
|
DBUS_TYPE_G_MAP_OF_VARIANT, config_hash,
|
2009-04-29 17:08:02 -04:00
|
|
|
G_TYPE_INVALID);
|
2010-11-22 09:05:09 -06:00
|
|
|
g_hash_table_destroy (config_hash);
|
2007-11-21 05:57:54 +00:00
|
|
|
nm_supplicant_info_set_call (info, call);
|
2006-11-25 15:41:04 +00:00
|
|
|
}
|
|
|
|
|
|
2006-12-19 19:15:31 +00:00
|
|
|
gboolean
|
2006-12-03 20:04:11 +00:00
|
|
|
nm_supplicant_interface_set_config (NMSupplicantInterface * self,
|
|
|
|
|
NMSupplicantConfig * cfg)
|
2006-11-25 15:41:04 +00:00
|
|
|
{
|
2007-02-05 12:14:09 +00:00
|
|
|
NMSupplicantInterfacePrivate *priv;
|
|
|
|
|
NMSupplicantInfo *info;
|
|
|
|
|
DBusGProxyCall *call;
|
2010-11-22 09:05:09 -06:00
|
|
|
GValue value = { 0, };
|
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) {
|
|
|
|
|
nm_log_warn (LOGD_SUPPLICANT, "EAP-FAST is not supported by the supplicant");
|
|
|
|
|
return FALSE;
|
|
|
|
|
}
|
|
|
|
|
|
2007-02-05 12:14:09 +00:00
|
|
|
if (priv->cfg)
|
|
|
|
|
g_object_unref (priv->cfg);
|
|
|
|
|
priv->cfg = cfg;
|
2006-12-19 19:15:31 +00:00
|
|
|
|
2007-02-05 12:14:09 +00:00
|
|
|
if (cfg == NULL)
|
|
|
|
|
return TRUE;
|
2006-12-19 19:15:31 +00:00
|
|
|
|
2007-02-05 12:14:09 +00:00
|
|
|
g_object_ref (priv->cfg);
|
2006-12-19 19:15:31 +00:00
|
|
|
|
2010-11-22 09:05:09 -06:00
|
|
|
g_value_init (&value, G_TYPE_UINT);
|
|
|
|
|
g_value_set_uint (&value, nm_supplicant_config_get_ap_scan (priv->cfg));
|
|
|
|
|
|
2010-11-22 08:30:13 -06:00
|
|
|
info = nm_supplicant_info_new (self, priv->props_proxy, priv->other_pcalls);
|
|
|
|
|
call = dbus_g_proxy_begin_call (priv->props_proxy, "Set",
|
2009-04-29 17:08:02 -04:00
|
|
|
set_ap_scan_cb,
|
|
|
|
|
info,
|
|
|
|
|
nm_supplicant_info_destroy,
|
2010-11-22 08:30:13 -06:00
|
|
|
G_TYPE_STRING, WPAS_DBUS_IFACE_INTERFACE,
|
|
|
|
|
G_TYPE_STRING, "ApScan",
|
2010-11-22 09:05:09 -06:00
|
|
|
G_TYPE_VALUE, &value,
|
2009-04-29 17:08:02 -04:00
|
|
|
G_TYPE_INVALID);
|
2007-02-05 12:14:09 +00:00
|
|
|
nm_supplicant_info_set_call (info, call);
|
2006-12-19 19:15:31 +00:00
|
|
|
|
2010-11-22 09:05:09 -06:00
|
|
|
g_value_unset (&value);
|
2007-02-05 12:14:09 +00:00
|
|
|
return call != NULL;
|
2006-11-25 15:41:04 +00: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
|
|
|
static void
|
2007-02-05 12:14:09 +00:00
|
|
|
scan_request_cb (DBusGProxy *proxy, DBusGProxyCall *call_id, gpointer user_data)
|
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
|
|
|
NMSupplicantInfo *info = (NMSupplicantInfo *) user_data;
|
|
|
|
|
GError *err = NULL;
|
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:25:09 -06:00
|
|
|
if (!dbus_g_proxy_end_call (proxy, call_id, &err, G_TYPE_INVALID)) {
|
2010-04-07 10:13:12 -07:00
|
|
|
nm_log_warn (LOGD_SUPPLICANT, "Could not get scan request result: %s", err->message);
|
2007-02-05 12:14:09 +00:00
|
|
|
}
|
2010-11-22 08:25:09 -06:00
|
|
|
g_signal_emit (info->interface, signals[SCAN_DONE], 0, err ? FALSE : TRUE);
|
|
|
|
|
g_clear_error (&err);
|
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
|
|
|
|
|
destroy_gvalue (gpointer data)
|
|
|
|
|
{
|
|
|
|
|
GValue *value = (GValue *) data;
|
|
|
|
|
|
|
|
|
|
g_value_unset (value);
|
|
|
|
|
g_slice_free (GValue, value);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
static GValue *
|
|
|
|
|
string_to_gvalue (const char *str)
|
|
|
|
|
{
|
|
|
|
|
GValue *val = g_slice_new0 (GValue);
|
|
|
|
|
|
|
|
|
|
g_value_init (val, G_TYPE_STRING);
|
|
|
|
|
g_value_set_string (val, str);
|
|
|
|
|
return val;
|
|
|
|
|
}
|
|
|
|
|
|
2012-05-02 11:41:47 -05:00
|
|
|
static GValue *
|
|
|
|
|
byte_array_array_to_gvalue (const GPtrArray *array)
|
|
|
|
|
{
|
|
|
|
|
GValue *val = g_slice_new0 (GValue);
|
|
|
|
|
|
|
|
|
|
g_value_init (val, DBUS_TYPE_G_ARRAY_OF_ARRAY_OF_UCHAR);
|
|
|
|
|
g_value_set_boxed (val, array);
|
|
|
|
|
return val;
|
|
|
|
|
}
|
|
|
|
|
|
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;
|
|
|
|
|
NMSupplicantInfo *info;
|
|
|
|
|
DBusGProxyCall *call;
|
2010-11-22 08:40:21 -06:00
|
|
|
GHashTable *hash;
|
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 */
|
|
|
|
|
hash = g_hash_table_new_full (g_str_hash, g_str_equal, NULL, destroy_gvalue);
|
|
|
|
|
g_hash_table_insert (hash, "Type", string_to_gvalue ("active"));
|
2012-05-02 11:41:47 -05:00
|
|
|
if (ssids)
|
|
|
|
|
g_hash_table_insert (hash, "SSIDs", byte_array_array_to_gvalue (ssids));
|
2010-11-22 08:40:21 -06:00
|
|
|
|
2007-02-05 12:14:09 +00:00
|
|
|
info = nm_supplicant_info_new (self, priv->iface_proxy, priv->other_pcalls);
|
2010-11-22 08:40:21 -06:00
|
|
|
call = dbus_g_proxy_begin_call (priv->iface_proxy, "Scan",
|
2009-04-29 17:08:02 -04:00
|
|
|
scan_request_cb,
|
|
|
|
|
info,
|
|
|
|
|
nm_supplicant_info_destroy,
|
2010-11-22 08:40:21 -06:00
|
|
|
DBUS_TYPE_G_MAP_OF_VARIANT, hash,
|
2009-04-29 17:08:02 -04:00
|
|
|
G_TYPE_INVALID);
|
2010-11-22 08:40:21 -06:00
|
|
|
g_hash_table_destroy (hash);
|
2007-02-05 12:14:09 +00:00
|
|
|
nm_supplicant_info_set_call (info, call);
|
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
|
|
|
return call != NULL;
|
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_device (NMSupplicantInterface * self)
|
|
|
|
|
{
|
|
|
|
|
g_return_val_if_fail (self != NULL, NULL);
|
|
|
|
|
g_return_val_if_fail (NM_IS_SUPPLICANT_INTERFACE (self), NULL);
|
|
|
|
|
|
|
|
|
|
return NM_SUPPLICANT_INTERFACE_GET_PRIVATE (self)->dev;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
const char *
|
|
|
|
|
nm_supplicant_interface_get_object_path (NMSupplicantInterface *self)
|
|
|
|
|
{
|
|
|
|
|
g_return_val_if_fail (self != NULL, NULL);
|
|
|
|
|
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 (self != NULL, NULL);
|
|
|
|
|
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 (self != NULL, 0);
|
|
|
|
|
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 *
|
|
|
|
|
nm_supplicant_interface_new (NMSupplicantManager *smgr,
|
|
|
|
|
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,
|
2010-10-12 14:18:42 -05:00
|
|
|
gboolean start_now)
|
2010-10-05 14:19:43 -05:00
|
|
|
{
|
|
|
|
|
NMSupplicantInterface *self;
|
|
|
|
|
NMSupplicantInterfacePrivate *priv;
|
|
|
|
|
guint id;
|
|
|
|
|
|
|
|
|
|
g_return_val_if_fail (NM_IS_SUPPLICANT_MANAGER (smgr), NULL);
|
|
|
|
|
g_return_val_if_fail (ifname != NULL, NULL);
|
|
|
|
|
|
|
|
|
|
self = g_object_new (NM_TYPE_SUPPLICANT_INTERFACE, NULL);
|
|
|
|
|
if (self) {
|
|
|
|
|
priv = NM_SUPPLICANT_INTERFACE_GET_PRIVATE (self);
|
|
|
|
|
|
|
|
|
|
priv->smgr = g_object_ref (smgr);
|
|
|
|
|
id = g_signal_connect (priv->smgr,
|
2010-10-12 14:18:42 -05:00
|
|
|
"notify::" NM_SUPPLICANT_MANAGER_AVAILABLE,
|
|
|
|
|
G_CALLBACK (smgr_avail_cb),
|
2010-10-05 14:19:43 -05:00
|
|
|
self);
|
2010-10-12 14:18:42 -05:00
|
|
|
priv->smgr_avail_id = id;
|
2010-10-05 14:19:43 -05:00
|
|
|
|
|
|
|
|
priv->dev = g_strdup (ifname);
|
|
|
|
|
priv->is_wireless = is_wireless;
|
2012-02-07 23:46:12 -06:00
|
|
|
priv->fast_supported = fast_supported;
|
2010-10-06 11:05:21 -05:00
|
|
|
|
2010-10-12 14:18:42 -05:00
|
|
|
if (start_now)
|
|
|
|
|
interface_add (self, priv->is_wireless);
|
2010-10-05 14:19:43 -05:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
return self;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
static void
|
|
|
|
|
nm_supplicant_interface_init (NMSupplicantInterface * self)
|
|
|
|
|
{
|
|
|
|
|
NMSupplicantInterfacePrivate *priv = NM_SUPPLICANT_INTERFACE_GET_PRIVATE (self);
|
2010-10-06 11:05:21 -05:00
|
|
|
DBusGConnection *bus;
|
2010-10-05 14:19:43 -05:00
|
|
|
|
|
|
|
|
priv->state = NM_SUPPLICANT_INTERFACE_STATE_INIT;
|
|
|
|
|
priv->assoc_pcalls = nm_call_store_new ();
|
|
|
|
|
priv->other_pcalls = nm_call_store_new ();
|
|
|
|
|
priv->dbus_mgr = nm_dbus_manager_get ();
|
2010-10-06 11:05:21 -05:00
|
|
|
|
|
|
|
|
bus = nm_dbus_manager_get_connection (priv->dbus_mgr);
|
|
|
|
|
priv->wpas_proxy = dbus_g_proxy_new_for_name (bus,
|
|
|
|
|
WPAS_DBUS_SERVICE,
|
|
|
|
|
WPAS_DBUS_PATH,
|
|
|
|
|
WPAS_DBUS_INTERFACE);
|
2012-02-20 15:06:05 -06:00
|
|
|
|
2012-02-22 14:44:05 -06:00
|
|
|
priv->bss_proxies = g_hash_table_new_full (g_str_hash, g_str_equal, NULL, bss_proxies_free);
|
2010-10-05 14:19:43 -05:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
static void
|
|
|
|
|
set_property (GObject *object,
|
|
|
|
|
guint prop_id,
|
|
|
|
|
const GValue *value,
|
|
|
|
|
GParamSpec *pspec)
|
|
|
|
|
{
|
|
|
|
|
switch (prop_id) {
|
|
|
|
|
default:
|
|
|
|
|
G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec);
|
|
|
|
|
break;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
static void
|
|
|
|
|
get_property (GObject *object,
|
|
|
|
|
guint prop_id,
|
|
|
|
|
GValue *value,
|
|
|
|
|
GParamSpec *pspec)
|
|
|
|
|
{
|
|
|
|
|
switch (prop_id) {
|
|
|
|
|
case PROP_SCANNING:
|
|
|
|
|
g_value_set_boolean (value, NM_SUPPLICANT_INTERFACE_GET_PRIVATE (object)->scanning);
|
|
|
|
|
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);
|
|
|
|
|
|
|
|
|
|
if (priv->disposed) {
|
|
|
|
|
G_OBJECT_CLASS (nm_supplicant_interface_parent_class)->dispose (object);
|
|
|
|
|
return;
|
|
|
|
|
}
|
|
|
|
|
priv->disposed = TRUE;
|
|
|
|
|
|
2010-10-11 20:30:40 -05:00
|
|
|
/* Cancel pending calls before unrefing the dbus manager */
|
|
|
|
|
cancel_all_callbacks (priv->other_pcalls);
|
|
|
|
|
nm_call_store_destroy (priv->other_pcalls);
|
|
|
|
|
|
|
|
|
|
cancel_all_callbacks (priv->assoc_pcalls);
|
|
|
|
|
nm_call_store_destroy (priv->assoc_pcalls);
|
|
|
|
|
|
2010-11-22 08:25:09 -06:00
|
|
|
if (priv->props_proxy)
|
|
|
|
|
g_object_unref (priv->props_proxy);
|
|
|
|
|
|
2010-10-05 14:19:43 -05:00
|
|
|
if (priv->iface_proxy)
|
|
|
|
|
g_object_unref (priv->iface_proxy);
|
|
|
|
|
|
2010-11-22 09:05:09 -06:00
|
|
|
g_free (priv->net_path);
|
2010-10-05 14:19:43 -05:00
|
|
|
|
2010-10-06 11:05:21 -05:00
|
|
|
if (priv->wpas_proxy)
|
|
|
|
|
g_object_unref (priv->wpas_proxy);
|
|
|
|
|
|
2012-02-20 15:06:05 -06:00
|
|
|
g_hash_table_destroy (priv->bss_proxies);
|
|
|
|
|
|
2010-10-05 14:19:43 -05:00
|
|
|
if (priv->smgr) {
|
2010-10-12 14:18:42 -05:00
|
|
|
if (priv->smgr_avail_id)
|
|
|
|
|
g_signal_handler_disconnect (priv->smgr, priv->smgr_avail_id);
|
2010-10-05 14:19:43 -05:00
|
|
|
g_object_unref (priv->smgr);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
g_free (priv->dev);
|
|
|
|
|
|
|
|
|
|
if (priv->dbus_mgr)
|
|
|
|
|
g_object_unref (priv->dbus_mgr);
|
|
|
|
|
|
|
|
|
|
if (priv->cfg)
|
|
|
|
|
g_object_unref (priv->cfg);
|
|
|
|
|
|
|
|
|
|
g_free (priv->object_path);
|
|
|
|
|
|
|
|
|
|
/* 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 */
|
|
|
|
|
g_object_class_install_property (object_class, PROP_SCANNING,
|
|
|
|
|
g_param_spec_boolean ("scanning",
|
|
|
|
|
"Scanning",
|
|
|
|
|
"Scanning",
|
|
|
|
|
FALSE,
|
|
|
|
|
G_PARAM_READABLE));
|
|
|
|
|
|
|
|
|
|
/* 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),
|
|
|
|
|
NULL, NULL,
|
|
|
|
|
_nm_marshal_VOID__UINT_UINT,
|
|
|
|
|
G_TYPE_NONE, 2, G_TYPE_UINT, G_TYPE_UINT);
|
|
|
|
|
|
|
|
|
|
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),
|
|
|
|
|
NULL, NULL,
|
|
|
|
|
g_cclosure_marshal_VOID__VOID,
|
|
|
|
|
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),
|
2010-10-05 14:19:43 -05:00
|
|
|
NULL, NULL,
|
2012-02-20 15:06:05 -06:00
|
|
|
_nm_marshal_VOID__STRING_POINTER,
|
|
|
|
|
G_TYPE_NONE, 2, G_TYPE_STRING, G_TYPE_POINTER);
|
|
|
|
|
|
|
|
|
|
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),
|
|
|
|
|
NULL, NULL,
|
|
|
|
|
_nm_marshal_VOID__STRING_POINTER,
|
|
|
|
|
G_TYPE_NONE, 2, G_TYPE_STRING, G_TYPE_POINTER);
|
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),
|
|
|
|
|
NULL, NULL,
|
|
|
|
|
g_cclosure_marshal_VOID__STRING,
|
|
|
|
|
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),
|
2010-10-05 14:19:43 -05:00
|
|
|
NULL, NULL,
|
|
|
|
|
g_cclosure_marshal_VOID__BOOLEAN,
|
|
|
|
|
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),
|
|
|
|
|
NULL, NULL,
|
|
|
|
|
_nm_marshal_VOID__STRING_STRING,
|
|
|
|
|
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),
|
|
|
|
|
NULL, NULL,
|
|
|
|
|
_nm_marshal_VOID__STRING_STRING,
|
|
|
|
|
G_TYPE_NONE, 2, G_TYPE_STRING, G_TYPE_STRING);
|
2010-10-05 14:19:43 -05:00
|
|
|
}
|
|
|
|
|
|