2009-11-09 22:51:59 +01:00
|
|
|
/*
|
|
|
|
* WPA Supplicant / dbus-based control interface
|
|
|
|
* Copyright (c) 2006, Dan Williams <dcbw@redhat.com> and Red Hat, Inc.
|
2010-01-09 10:40:15 +01:00
|
|
|
* Copyright (c) 2009-2010, Witold Sowa <witold.sowa@gmail.com>
|
2009-12-28 00:10:07 +01:00
|
|
|
* Copyright (c) 2009, Jouni Malinen <j@w1.fi>
|
2009-11-09 22:51:59 +01:00
|
|
|
*
|
|
|
|
* This program is free software; you can redistribute it and/or modify
|
|
|
|
* it under the terms of the GNU General Public License version 2 as
|
|
|
|
* published by the Free Software Foundation.
|
|
|
|
*
|
|
|
|
* Alternatively, this software may be distributed under the terms of BSD
|
|
|
|
* license.
|
|
|
|
*
|
|
|
|
* See README and COPYING for more details.
|
|
|
|
*/
|
|
|
|
|
|
|
|
#include "includes.h"
|
|
|
|
|
|
|
|
#include "common.h"
|
|
|
|
#include "wps/wps.h"
|
2009-12-20 20:11:35 +01:00
|
|
|
#include "../config.h"
|
|
|
|
#include "../wpa_supplicant_i.h"
|
2009-12-28 00:10:07 +01:00
|
|
|
#include "../bss.h"
|
2009-12-20 20:11:35 +01:00
|
|
|
#include "dbus_new_helpers.h"
|
2009-11-09 22:51:59 +01:00
|
|
|
#include "dbus_dict_helpers.h"
|
2009-12-20 20:11:35 +01:00
|
|
|
#include "dbus_new.h"
|
|
|
|
#include "dbus_new_handlers.h"
|
2009-12-30 23:15:56 +01:00
|
|
|
#include "dbus_common.h"
|
|
|
|
#include "dbus_common_i.h"
|
2009-11-09 22:51:59 +01:00
|
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
* wpas_dbus_signal_interface - Send a interface related event signal
|
|
|
|
* @wpa_s: %wpa_supplicant network interface data
|
|
|
|
* @sig_name: signal name - InterfaceAdded or InterfaceRemoved
|
2010-01-02 11:06:44 +01:00
|
|
|
* @properties: Whether to add second argument with object properties
|
2009-11-09 22:51:59 +01:00
|
|
|
*
|
|
|
|
* Notify listeners about event related with interface
|
|
|
|
*/
|
|
|
|
static void wpas_dbus_signal_interface(struct wpa_supplicant *wpa_s,
|
2010-01-01 11:47:59 +01:00
|
|
|
const char *sig_name, int properties)
|
2009-11-09 22:51:59 +01:00
|
|
|
{
|
2009-12-30 23:15:56 +01:00
|
|
|
struct wpas_dbus_priv *iface;
|
2010-01-02 11:06:44 +01:00
|
|
|
DBusMessage *msg;
|
2010-01-01 11:47:59 +01:00
|
|
|
DBusMessageIter iter, iter_dict;
|
2009-11-09 22:51:59 +01:00
|
|
|
|
2009-12-30 23:15:56 +01:00
|
|
|
iface = wpa_s->global->dbus;
|
2009-11-09 22:51:59 +01:00
|
|
|
|
|
|
|
/* Do nothing if the control interface is not turned on */
|
|
|
|
if (iface == NULL)
|
|
|
|
return;
|
|
|
|
|
2010-01-02 11:06:44 +01:00
|
|
|
msg = dbus_message_new_signal(WPAS_DBUS_NEW_PATH,
|
|
|
|
WPAS_DBUS_NEW_INTERFACE, sig_name);
|
|
|
|
if (msg == NULL)
|
2009-11-09 22:51:59 +01:00
|
|
|
return;
|
2010-01-01 11:47:59 +01:00
|
|
|
|
2010-01-02 11:06:44 +01:00
|
|
|
dbus_message_iter_init_append(msg, &iter);
|
2010-01-01 18:12:31 +01:00
|
|
|
if (!dbus_message_iter_append_basic(&iter, DBUS_TYPE_OBJECT_PATH,
|
2010-01-02 11:06:44 +01:00
|
|
|
&wpa_s->dbus_new_path))
|
2010-01-01 11:47:59 +01:00
|
|
|
goto err;
|
|
|
|
|
|
|
|
if (properties) {
|
|
|
|
if (!wpa_dbus_dict_open_write(&iter, &iter_dict))
|
|
|
|
goto err;
|
|
|
|
|
2010-01-02 11:06:44 +01:00
|
|
|
wpa_dbus_get_object_properties(iface, wpa_s->dbus_new_path,
|
2010-01-01 11:47:59 +01:00
|
|
|
WPAS_DBUS_NEW_IFACE_INTERFACE,
|
|
|
|
&iter_dict);
|
|
|
|
|
|
|
|
if (!wpa_dbus_dict_close_write(&iter, &iter_dict))
|
|
|
|
goto err;
|
2009-11-09 22:51:59 +01:00
|
|
|
}
|
2010-01-01 11:47:59 +01:00
|
|
|
|
2010-01-02 11:06:44 +01:00
|
|
|
dbus_connection_send(iface->con, msg, NULL);
|
|
|
|
dbus_message_unref(msg);
|
2010-01-01 11:47:59 +01:00
|
|
|
return;
|
|
|
|
|
|
|
|
err:
|
2010-01-02 11:06:44 +01:00
|
|
|
wpa_printf(MSG_ERROR, "dbus: Failed to construct signal");
|
|
|
|
dbus_message_unref(msg);
|
2009-11-09 22:51:59 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
/**
|
2010-01-01 11:49:27 +01:00
|
|
|
* wpas_dbus_signal_interface_added - Send a interface created signal
|
2009-11-09 22:51:59 +01:00
|
|
|
* @wpa_s: %wpa_supplicant network interface data
|
|
|
|
*
|
|
|
|
* Notify listeners about creating new interface
|
|
|
|
*/
|
2010-01-01 11:49:27 +01:00
|
|
|
static void wpas_dbus_signal_interface_added(struct wpa_supplicant *wpa_s)
|
2009-11-09 22:51:59 +01:00
|
|
|
{
|
2010-01-01 11:49:27 +01:00
|
|
|
wpas_dbus_signal_interface(wpa_s, "InterfaceAdded", TRUE);
|
2009-11-09 22:51:59 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
* wpas_dbus_signal_interface_removed - Send a interface removed signal
|
|
|
|
* @wpa_s: %wpa_supplicant network interface data
|
|
|
|
*
|
|
|
|
* Notify listeners about removing interface
|
|
|
|
*/
|
|
|
|
static void wpas_dbus_signal_interface_removed(struct wpa_supplicant *wpa_s)
|
|
|
|
{
|
2010-01-01 11:47:59 +01:00
|
|
|
wpas_dbus_signal_interface(wpa_s, "InterfaceRemoved", FALSE);
|
2009-11-09 22:51:59 +01:00
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
* wpas_dbus_signal_scan_done - send scan done signal
|
|
|
|
* @wpa_s: %wpa_supplicant network interface data
|
|
|
|
* @success: indicates if scanning succeed or failed
|
|
|
|
*
|
|
|
|
* Notify listeners about finishing a scan
|
|
|
|
*/
|
2010-01-01 17:45:29 +01:00
|
|
|
void wpas_dbus_signal_scan_done(struct wpa_supplicant *wpa_s, int success)
|
2009-11-09 22:51:59 +01:00
|
|
|
{
|
2009-12-30 23:15:56 +01:00
|
|
|
struct wpas_dbus_priv *iface;
|
2010-01-02 11:06:44 +01:00
|
|
|
DBusMessage *msg;
|
2009-11-09 22:51:59 +01:00
|
|
|
dbus_bool_t succ;
|
|
|
|
|
2009-12-30 23:15:56 +01:00
|
|
|
iface = wpa_s->global->dbus;
|
2009-11-09 22:51:59 +01:00
|
|
|
|
|
|
|
/* Do nothing if the control interface is not turned on */
|
|
|
|
if (iface == NULL)
|
|
|
|
return;
|
|
|
|
|
2010-01-02 11:06:44 +01:00
|
|
|
msg = dbus_message_new_signal(wpa_s->dbus_new_path,
|
|
|
|
WPAS_DBUS_NEW_IFACE_INTERFACE,
|
|
|
|
"ScanDone");
|
|
|
|
if (msg == NULL)
|
2009-11-09 22:51:59 +01:00
|
|
|
return;
|
|
|
|
|
|
|
|
succ = success ? TRUE : FALSE;
|
2010-01-02 11:06:44 +01:00
|
|
|
if (dbus_message_append_args(msg, DBUS_TYPE_BOOLEAN, &succ,
|
|
|
|
DBUS_TYPE_INVALID))
|
|
|
|
dbus_connection_send(iface->con, msg, NULL);
|
|
|
|
else
|
|
|
|
wpa_printf(MSG_ERROR, "dbus: Failed to construct signal");
|
|
|
|
dbus_message_unref(msg);
|
2009-11-09 22:51:59 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
* wpas_dbus_signal_blob - Send a BSS related event signal
|
|
|
|
* @wpa_s: %wpa_supplicant network interface data
|
|
|
|
* @bss_obj_path: BSS object path
|
|
|
|
* @sig_name: signal name - BSSAdded or BSSRemoved
|
2010-01-02 11:06:44 +01:00
|
|
|
* @properties: Whether to add second argument with object properties
|
2009-11-09 22:51:59 +01:00
|
|
|
*
|
|
|
|
* Notify listeners about event related with BSS
|
|
|
|
*/
|
|
|
|
static void wpas_dbus_signal_bss(struct wpa_supplicant *wpa_s,
|
|
|
|
const char *bss_obj_path,
|
2010-01-01 11:47:59 +01:00
|
|
|
const char *sig_name, int properties)
|
2009-11-09 22:51:59 +01:00
|
|
|
{
|
2009-12-30 23:15:56 +01:00
|
|
|
struct wpas_dbus_priv *iface;
|
2010-01-02 11:06:44 +01:00
|
|
|
DBusMessage *msg;
|
2010-01-01 11:47:59 +01:00
|
|
|
DBusMessageIter iter, iter_dict;
|
2009-11-09 22:51:59 +01:00
|
|
|
|
2009-12-30 23:15:56 +01:00
|
|
|
iface = wpa_s->global->dbus;
|
2009-11-09 22:51:59 +01:00
|
|
|
|
|
|
|
/* Do nothing if the control interface is not turned on */
|
|
|
|
if (iface == NULL)
|
|
|
|
return;
|
|
|
|
|
2010-01-02 11:06:44 +01:00
|
|
|
msg = dbus_message_new_signal(wpa_s->dbus_new_path,
|
|
|
|
WPAS_DBUS_NEW_IFACE_INTERFACE,
|
|
|
|
sig_name);
|
|
|
|
if (msg == NULL)
|
2009-11-09 22:51:59 +01:00
|
|
|
return;
|
2010-01-01 11:47:59 +01:00
|
|
|
|
2010-01-02 11:06:44 +01:00
|
|
|
dbus_message_iter_init_append(msg, &iter);
|
2010-01-01 11:47:59 +01:00
|
|
|
if (!dbus_message_iter_append_basic(&iter, DBUS_TYPE_OBJECT_PATH,
|
|
|
|
&bss_obj_path))
|
|
|
|
goto err;
|
|
|
|
|
|
|
|
if (properties) {
|
|
|
|
if (!wpa_dbus_dict_open_write(&iter, &iter_dict))
|
|
|
|
goto err;
|
|
|
|
|
|
|
|
wpa_dbus_get_object_properties(iface, bss_obj_path,
|
2010-01-09 10:40:15 +01:00
|
|
|
WPAS_DBUS_NEW_IFACE_BSS,
|
2010-01-01 11:47:59 +01:00
|
|
|
&iter_dict);
|
|
|
|
|
|
|
|
if (!wpa_dbus_dict_close_write(&iter, &iter_dict))
|
|
|
|
goto err;
|
2009-11-09 22:51:59 +01:00
|
|
|
}
|
2010-01-01 11:47:59 +01:00
|
|
|
|
2010-01-02 11:06:44 +01:00
|
|
|
dbus_connection_send(iface->con, msg, NULL);
|
|
|
|
dbus_message_unref(msg);
|
2010-01-01 11:47:59 +01:00
|
|
|
return;
|
|
|
|
|
|
|
|
err:
|
2010-01-02 11:06:44 +01:00
|
|
|
wpa_printf(MSG_ERROR, "dbus: Failed to construct signal");
|
|
|
|
dbus_message_unref(msg);
|
2009-11-09 22:51:59 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
* wpas_dbus_signal_bss_added - Send a BSS added signal
|
|
|
|
* @wpa_s: %wpa_supplicant network interface data
|
|
|
|
* @bss_obj_path: new BSS object path
|
|
|
|
*
|
|
|
|
* Notify listeners about adding new BSS
|
|
|
|
*/
|
|
|
|
static void wpas_dbus_signal_bss_added(struct wpa_supplicant *wpa_s,
|
|
|
|
const char *bss_obj_path)
|
|
|
|
{
|
2010-01-01 11:47:59 +01:00
|
|
|
wpas_dbus_signal_bss(wpa_s, bss_obj_path, "BSSAdded", TRUE);
|
2009-11-09 22:51:59 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
* wpas_dbus_signal_bss_removed - Send a BSS removed signal
|
|
|
|
* @wpa_s: %wpa_supplicant network interface data
|
|
|
|
* @bss_obj_path: BSS object path
|
|
|
|
*
|
|
|
|
* Notify listeners about removing BSS
|
|
|
|
*/
|
|
|
|
static void wpas_dbus_signal_bss_removed(struct wpa_supplicant *wpa_s,
|
|
|
|
const char *bss_obj_path)
|
|
|
|
{
|
2010-01-01 11:47:59 +01:00
|
|
|
wpas_dbus_signal_bss(wpa_s, bss_obj_path, "BSSRemoved", FALSE);
|
2009-11-09 22:51:59 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
* wpas_dbus_signal_blob - Send a blob related event signal
|
|
|
|
* @wpa_s: %wpa_supplicant network interface data
|
|
|
|
* @name: blob name
|
|
|
|
* @sig_name: signal name - BlobAdded or BlobRemoved
|
|
|
|
*
|
|
|
|
* Notify listeners about event related with blob
|
|
|
|
*/
|
|
|
|
static void wpas_dbus_signal_blob(struct wpa_supplicant *wpa_s,
|
|
|
|
const char *name, const char *sig_name)
|
|
|
|
{
|
2009-12-30 23:15:56 +01:00
|
|
|
struct wpas_dbus_priv *iface;
|
2010-01-02 11:06:44 +01:00
|
|
|
DBusMessage *msg;
|
2009-11-09 22:51:59 +01:00
|
|
|
|
2009-12-30 23:15:56 +01:00
|
|
|
iface = wpa_s->global->dbus;
|
2009-11-09 22:51:59 +01:00
|
|
|
|
|
|
|
/* Do nothing if the control interface is not turned on */
|
|
|
|
if (iface == NULL)
|
|
|
|
return;
|
|
|
|
|
2010-01-02 11:06:44 +01:00
|
|
|
msg = dbus_message_new_signal(wpa_s->dbus_new_path,
|
|
|
|
WPAS_DBUS_NEW_IFACE_INTERFACE,
|
|
|
|
sig_name);
|
|
|
|
if (msg == NULL)
|
2009-11-09 22:51:59 +01:00
|
|
|
return;
|
|
|
|
|
2010-01-02 11:06:44 +01:00
|
|
|
if (dbus_message_append_args(msg, DBUS_TYPE_STRING, &name,
|
|
|
|
DBUS_TYPE_INVALID))
|
|
|
|
dbus_connection_send(iface->con, msg, NULL);
|
|
|
|
else
|
|
|
|
wpa_printf(MSG_ERROR, "dbus: Failed to construct signal");
|
|
|
|
dbus_message_unref(msg);
|
2009-11-09 22:51:59 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
* wpas_dbus_signal_blob_added - Send a blob added signal
|
|
|
|
* @wpa_s: %wpa_supplicant network interface data
|
|
|
|
* @name: blob name
|
|
|
|
*
|
|
|
|
* Notify listeners about adding a new blob
|
|
|
|
*/
|
2010-01-01 17:45:29 +01:00
|
|
|
void wpas_dbus_signal_blob_added(struct wpa_supplicant *wpa_s,
|
|
|
|
const char *name)
|
2009-11-09 22:51:59 +01:00
|
|
|
{
|
|
|
|
wpas_dbus_signal_blob(wpa_s, name, "BlobAdded");
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
* wpas_dbus_signal_blob_removed - Send a blob removed signal
|
|
|
|
* @wpa_s: %wpa_supplicant network interface data
|
|
|
|
* @name: blob name
|
|
|
|
*
|
|
|
|
* Notify listeners about removing blob
|
|
|
|
*/
|
2010-01-01 17:45:29 +01:00
|
|
|
void wpas_dbus_signal_blob_removed(struct wpa_supplicant *wpa_s,
|
|
|
|
const char *name)
|
2009-11-09 22:51:59 +01:00
|
|
|
{
|
|
|
|
wpas_dbus_signal_blob(wpa_s, name, "BlobRemoved");
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
* wpas_dbus_signal_network - Send a network related event signal
|
|
|
|
* @wpa_s: %wpa_supplicant network interface data
|
|
|
|
* @id: new network id
|
|
|
|
* @sig_name: signal name - NetworkAdded, NetworkRemoved or NetworkSelected
|
2010-01-01 11:47:59 +01:00
|
|
|
* @properties: determines if add second argument with object properties
|
2009-11-09 22:51:59 +01:00
|
|
|
*
|
|
|
|
* Notify listeners about event related with configured network
|
|
|
|
*/
|
|
|
|
static void wpas_dbus_signal_network(struct wpa_supplicant *wpa_s,
|
2010-01-01 11:47:59 +01:00
|
|
|
int id, const char *sig_name,
|
|
|
|
int properties)
|
2009-11-09 22:51:59 +01:00
|
|
|
{
|
2009-12-30 23:15:56 +01:00
|
|
|
struct wpas_dbus_priv *iface;
|
2010-01-02 11:06:44 +01:00
|
|
|
DBusMessage *msg;
|
2010-01-01 11:47:59 +01:00
|
|
|
DBusMessageIter iter, iter_dict;
|
2010-01-02 11:06:44 +01:00
|
|
|
char net_obj_path[WPAS_DBUS_OBJECT_PATH_MAX], *path;
|
2009-11-09 22:51:59 +01:00
|
|
|
|
2009-12-30 23:15:56 +01:00
|
|
|
iface = wpa_s->global->dbus;
|
2009-11-09 22:51:59 +01:00
|
|
|
|
|
|
|
/* Do nothing if the control interface is not turned on */
|
|
|
|
if (iface == NULL)
|
|
|
|
return;
|
|
|
|
|
|
|
|
os_snprintf(net_obj_path, WPAS_DBUS_OBJECT_PATH_MAX,
|
2010-01-01 18:12:31 +01:00
|
|
|
"%s/" WPAS_DBUS_NEW_NETWORKS_PART "/%u",
|
|
|
|
wpa_s->dbus_new_path, id);
|
2009-11-09 22:51:59 +01:00
|
|
|
|
2010-01-02 11:06:44 +01:00
|
|
|
msg = dbus_message_new_signal(wpa_s->dbus_new_path,
|
|
|
|
WPAS_DBUS_NEW_IFACE_INTERFACE,
|
|
|
|
sig_name);
|
|
|
|
if (msg == NULL)
|
2009-11-09 22:51:59 +01:00
|
|
|
return;
|
2010-01-01 11:47:59 +01:00
|
|
|
|
2010-01-02 11:06:44 +01:00
|
|
|
dbus_message_iter_init_append(msg, &iter);
|
|
|
|
path = net_obj_path;
|
2010-01-01 11:47:59 +01:00
|
|
|
if (!dbus_message_iter_append_basic(&iter, DBUS_TYPE_OBJECT_PATH,
|
2010-01-02 11:06:44 +01:00
|
|
|
&path))
|
2010-01-01 11:47:59 +01:00
|
|
|
goto err;
|
|
|
|
|
|
|
|
if (properties) {
|
|
|
|
if (!wpa_dbus_dict_open_write(&iter, &iter_dict))
|
|
|
|
goto err;
|
|
|
|
|
|
|
|
wpa_dbus_get_object_properties(iface, net_obj_path,
|
|
|
|
WPAS_DBUS_NEW_IFACE_NETWORK,
|
|
|
|
&iter_dict);
|
|
|
|
|
|
|
|
if (!wpa_dbus_dict_close_write(&iter, &iter_dict))
|
|
|
|
goto err;
|
2009-11-09 22:51:59 +01:00
|
|
|
}
|
|
|
|
|
2010-01-02 11:06:44 +01:00
|
|
|
dbus_connection_send(iface->con, msg, NULL);
|
2010-01-01 11:47:59 +01:00
|
|
|
|
2010-01-02 11:06:44 +01:00
|
|
|
dbus_message_unref(msg);
|
2010-01-01 11:47:59 +01:00
|
|
|
return;
|
|
|
|
|
|
|
|
err:
|
2010-01-02 11:06:44 +01:00
|
|
|
wpa_printf(MSG_ERROR, "dbus: Failed to construct signal");
|
|
|
|
dbus_message_unref(msg);
|
2009-11-09 22:51:59 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
* wpas_dbus_signal_network_added - Send a network added signal
|
|
|
|
* @wpa_s: %wpa_supplicant network interface data
|
|
|
|
* @id: new network id
|
|
|
|
*
|
|
|
|
* Notify listeners about adding new network
|
|
|
|
*/
|
|
|
|
static void wpas_dbus_signal_network_added(struct wpa_supplicant *wpa_s,
|
|
|
|
int id)
|
|
|
|
{
|
2010-01-01 11:47:59 +01:00
|
|
|
wpas_dbus_signal_network(wpa_s, id, "NetworkAdded", TRUE);
|
2009-11-09 22:51:59 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
/**
|
2009-11-14 14:57:02 +01:00
|
|
|
* wpas_dbus_signal_network_removed - Send a network removed signal
|
2009-11-09 22:51:59 +01:00
|
|
|
* @wpa_s: %wpa_supplicant network interface data
|
|
|
|
* @id: network id
|
|
|
|
*
|
|
|
|
* Notify listeners about removing a network
|
|
|
|
*/
|
|
|
|
static void wpas_dbus_signal_network_removed(struct wpa_supplicant *wpa_s,
|
|
|
|
int id)
|
|
|
|
{
|
2010-01-01 11:47:59 +01:00
|
|
|
wpas_dbus_signal_network(wpa_s, id, "NetworkRemoved", FALSE);
|
2009-11-09 22:51:59 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
* wpas_dbus_signal_network_selected - Send a network selected signal
|
|
|
|
* @wpa_s: %wpa_supplicant network interface data
|
|
|
|
* @id: network id
|
|
|
|
*
|
|
|
|
* Notify listeners about selecting a network
|
|
|
|
*/
|
2010-01-01 17:45:29 +01:00
|
|
|
void wpas_dbus_signal_network_selected(struct wpa_supplicant *wpa_s, int id)
|
2009-11-09 22:51:59 +01:00
|
|
|
{
|
2010-01-01 11:47:59 +01:00
|
|
|
wpas_dbus_signal_network(wpa_s, id, "NetworkSelected", FALSE);
|
2009-11-09 22:51:59 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
/**
|
2009-11-14 14:57:02 +01:00
|
|
|
* wpas_dbus_signal_network_enabled_changed - Signals Enabled property changes
|
2009-11-09 22:51:59 +01:00
|
|
|
* @wpa_s: %wpa_supplicant network interface data
|
|
|
|
* @ssid: configured network which Enabled property has changed
|
|
|
|
*
|
|
|
|
* Sends PropertyChanged signals containing new value of Enabled property
|
|
|
|
* for specified network
|
|
|
|
*/
|
2010-01-01 17:45:29 +01:00
|
|
|
void wpas_dbus_signal_network_enabled_changed(struct wpa_supplicant *wpa_s,
|
|
|
|
struct wpa_ssid *ssid)
|
2009-11-09 22:51:59 +01:00
|
|
|
{
|
|
|
|
|
|
|
|
char path[WPAS_DBUS_OBJECT_PATH_MAX];
|
|
|
|
os_snprintf(path, WPAS_DBUS_OBJECT_PATH_MAX,
|
|
|
|
"%s/" WPAS_DBUS_NEW_NETWORKS_PART "/%d",
|
2010-01-01 18:12:31 +01:00
|
|
|
wpa_s->dbus_new_path, ssid->id);
|
2009-11-09 22:51:59 +01:00
|
|
|
|
2010-01-04 16:15:57 +01:00
|
|
|
wpa_dbus_mark_property_changed(wpa_s->global->dbus, path,
|
|
|
|
WPAS_DBUS_NEW_IFACE_NETWORK, "Enabled");
|
2009-11-09 22:51:59 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
#ifdef CONFIG_WPS
|
|
|
|
|
|
|
|
/**
|
|
|
|
* wpas_dbus_signal_wps_event_success - Signals Success WPS event
|
|
|
|
* @wpa_s: %wpa_supplicant network interface data
|
|
|
|
*
|
|
|
|
* Sends Event dbus signal with name "success" and empty dict as arguments
|
|
|
|
*/
|
2010-01-01 17:45:29 +01:00
|
|
|
void wpas_dbus_signal_wps_event_success(struct wpa_supplicant *wpa_s)
|
2009-11-09 22:51:59 +01:00
|
|
|
{
|
|
|
|
|
2010-01-02 11:06:44 +01:00
|
|
|
DBusMessage *msg;
|
2009-11-09 22:51:59 +01:00
|
|
|
DBusMessageIter iter, dict_iter;
|
2009-12-30 23:15:56 +01:00
|
|
|
struct wpas_dbus_priv *iface;
|
2009-11-09 22:51:59 +01:00
|
|
|
char *key = "success";
|
|
|
|
|
2009-12-30 23:15:56 +01:00
|
|
|
iface = wpa_s->global->dbus;
|
2009-11-09 22:51:59 +01:00
|
|
|
|
|
|
|
/* Do nothing if the control interface is not turned on */
|
|
|
|
if (iface == NULL)
|
|
|
|
return;
|
|
|
|
|
2010-01-02 11:06:44 +01:00
|
|
|
msg = dbus_message_new_signal(wpa_s->dbus_new_path,
|
|
|
|
WPAS_DBUS_NEW_IFACE_WPS, "Event");
|
|
|
|
if (msg == NULL)
|
2009-11-09 22:51:59 +01:00
|
|
|
return;
|
|
|
|
|
2010-01-02 11:06:44 +01:00
|
|
|
dbus_message_iter_init_append(msg, &iter);
|
2009-11-09 22:51:59 +01:00
|
|
|
|
|
|
|
if (!dbus_message_iter_append_basic(&iter, DBUS_TYPE_STRING, &key) ||
|
|
|
|
!wpa_dbus_dict_open_write(&iter, &dict_iter) ||
|
2010-01-02 11:06:44 +01:00
|
|
|
!wpa_dbus_dict_close_write(&iter, &dict_iter))
|
|
|
|
wpa_printf(MSG_ERROR, "dbus: Failed to construct signal");
|
|
|
|
else
|
|
|
|
dbus_connection_send(iface->con, msg, NULL);
|
2009-11-09 22:51:59 +01:00
|
|
|
|
2010-01-02 11:06:44 +01:00
|
|
|
dbus_message_unref(msg);
|
2009-11-09 22:51:59 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
* wpas_dbus_signal_wps_event_fail - Signals Fail WPS event
|
|
|
|
* @wpa_s: %wpa_supplicant network interface data
|
|
|
|
*
|
|
|
|
* Sends Event dbus signal with name "fail" and dictionary containing
|
|
|
|
* "msg field with fail message number (int32) as arguments
|
|
|
|
*/
|
2010-01-01 17:45:29 +01:00
|
|
|
void wpas_dbus_signal_wps_event_fail(struct wpa_supplicant *wpa_s,
|
|
|
|
struct wps_event_fail *fail)
|
2009-11-09 22:51:59 +01:00
|
|
|
{
|
|
|
|
|
2010-01-02 11:06:44 +01:00
|
|
|
DBusMessage *msg;
|
2009-11-09 22:51:59 +01:00
|
|
|
DBusMessageIter iter, dict_iter;
|
2009-12-30 23:15:56 +01:00
|
|
|
struct wpas_dbus_priv *iface;
|
2009-11-14 15:02:01 +01:00
|
|
|
char *key = "fail";
|
2009-11-09 22:51:59 +01:00
|
|
|
|
2009-12-30 23:15:56 +01:00
|
|
|
iface = wpa_s->global->dbus;
|
2009-11-09 22:51:59 +01:00
|
|
|
|
|
|
|
/* Do nothing if the control interface is not turned on */
|
|
|
|
if (iface == NULL)
|
|
|
|
return;
|
|
|
|
|
2010-01-02 11:06:44 +01:00
|
|
|
msg = dbus_message_new_signal(wpa_s->dbus_new_path,
|
|
|
|
WPAS_DBUS_NEW_IFACE_WPS, "Event");
|
|
|
|
if (msg == NULL)
|
2009-11-09 22:51:59 +01:00
|
|
|
return;
|
|
|
|
|
2010-01-02 11:06:44 +01:00
|
|
|
dbus_message_iter_init_append(msg, &iter);
|
2009-11-09 22:51:59 +01:00
|
|
|
|
|
|
|
if (!dbus_message_iter_append_basic(&iter, DBUS_TYPE_STRING, &key) ||
|
|
|
|
!wpa_dbus_dict_open_write(&iter, &dict_iter) ||
|
|
|
|
!wpa_dbus_dict_append_int32(&dict_iter, "msg", fail->msg) ||
|
2010-01-02 11:06:44 +01:00
|
|
|
!wpa_dbus_dict_close_write(&iter, &dict_iter))
|
|
|
|
wpa_printf(MSG_ERROR, "dbus: Failed to construct signal");
|
|
|
|
else
|
|
|
|
dbus_connection_send(iface->con, msg, NULL);
|
2009-11-09 22:51:59 +01:00
|
|
|
|
2010-01-02 11:06:44 +01:00
|
|
|
dbus_message_unref(msg);
|
2009-11-09 22:51:59 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
* wpas_dbus_signal_wps_event_m2d - Signals M2D WPS event
|
|
|
|
* @wpa_s: %wpa_supplicant network interface data
|
|
|
|
*
|
|
|
|
* Sends Event dbus signal with name "m2d" and dictionary containing
|
|
|
|
* fields of wps_event_m2d structure.
|
|
|
|
*/
|
2010-01-01 17:45:29 +01:00
|
|
|
void wpas_dbus_signal_wps_event_m2d(struct wpa_supplicant *wpa_s,
|
|
|
|
struct wps_event_m2d *m2d)
|
2009-11-09 22:51:59 +01:00
|
|
|
{
|
|
|
|
|
2010-01-02 11:06:44 +01:00
|
|
|
DBusMessage *msg;
|
2009-11-09 22:51:59 +01:00
|
|
|
DBusMessageIter iter, dict_iter;
|
2009-12-30 23:15:56 +01:00
|
|
|
struct wpas_dbus_priv *iface;
|
2009-11-14 15:02:01 +01:00
|
|
|
char *key = "m2d";
|
2009-11-09 22:51:59 +01:00
|
|
|
|
2009-12-30 23:15:56 +01:00
|
|
|
iface = wpa_s->global->dbus;
|
2009-11-09 22:51:59 +01:00
|
|
|
|
|
|
|
/* Do nothing if the control interface is not turned on */
|
|
|
|
if (iface == NULL)
|
|
|
|
return;
|
|
|
|
|
2010-01-02 11:06:44 +01:00
|
|
|
msg = dbus_message_new_signal(wpa_s->dbus_new_path,
|
|
|
|
WPAS_DBUS_NEW_IFACE_WPS, "Event");
|
|
|
|
if (msg == NULL)
|
2009-11-09 22:51:59 +01:00
|
|
|
return;
|
|
|
|
|
2010-01-02 11:06:44 +01:00
|
|
|
dbus_message_iter_init_append(msg, &iter);
|
2009-11-09 22:51:59 +01:00
|
|
|
|
2010-01-02 11:06:44 +01:00
|
|
|
if (!dbus_message_iter_append_basic(&iter, DBUS_TYPE_STRING, &key) ||
|
|
|
|
!wpa_dbus_dict_open_write(&iter, &dict_iter) ||
|
|
|
|
!wpa_dbus_dict_append_uint16(&dict_iter, "config_methods",
|
|
|
|
m2d->config_methods) ||
|
|
|
|
!wpa_dbus_dict_append_byte_array(&dict_iter, "manufacturer",
|
|
|
|
(const char *) m2d->manufacturer,
|
|
|
|
m2d->manufacturer_len) ||
|
|
|
|
!wpa_dbus_dict_append_byte_array(&dict_iter, "model_name",
|
|
|
|
(const char *) m2d->model_name,
|
|
|
|
m2d->model_name_len) ||
|
|
|
|
!wpa_dbus_dict_append_byte_array(&dict_iter, "model_number",
|
|
|
|
(const char *) m2d->model_number,
|
|
|
|
m2d->model_number_len) ||
|
|
|
|
!wpa_dbus_dict_append_byte_array(&dict_iter, "serial_number",
|
|
|
|
(const char *)
|
|
|
|
m2d->serial_number,
|
|
|
|
m2d->serial_number_len) ||
|
|
|
|
!wpa_dbus_dict_append_byte_array(&dict_iter, "dev_name",
|
|
|
|
(const char *) m2d->dev_name,
|
|
|
|
m2d->dev_name_len) ||
|
|
|
|
!wpa_dbus_dict_append_byte_array(&dict_iter, "primary_dev_type",
|
|
|
|
(const char *)
|
|
|
|
m2d->primary_dev_type, 8) ||
|
|
|
|
!wpa_dbus_dict_append_uint16(&dict_iter, "config_error",
|
|
|
|
m2d->config_error) ||
|
|
|
|
!wpa_dbus_dict_append_uint16(&dict_iter, "dev_password_id",
|
|
|
|
m2d->dev_password_id) ||
|
|
|
|
!wpa_dbus_dict_close_write(&iter, &dict_iter))
|
|
|
|
wpa_printf(MSG_ERROR, "dbus: Failed to construct signal");
|
|
|
|
else
|
|
|
|
dbus_connection_send(iface->con, msg, NULL);
|
|
|
|
|
|
|
|
dbus_message_unref(msg);
|
2009-11-09 22:51:59 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
* wpas_dbus_signal_wps_cred - Signals new credentials
|
|
|
|
* @wpa_s: %wpa_supplicant network interface data
|
|
|
|
*
|
|
|
|
* Sends signal with credentials in directory argument
|
|
|
|
*/
|
2010-01-01 17:45:29 +01:00
|
|
|
void wpas_dbus_signal_wps_cred(struct wpa_supplicant *wpa_s,
|
|
|
|
const struct wps_credential *cred)
|
2009-11-09 22:51:59 +01:00
|
|
|
{
|
2010-01-02 11:06:44 +01:00
|
|
|
DBusMessage *msg;
|
2009-11-09 22:51:59 +01:00
|
|
|
DBusMessageIter iter, dict_iter;
|
2009-12-30 23:15:56 +01:00
|
|
|
struct wpas_dbus_priv *iface;
|
2009-11-09 22:51:59 +01:00
|
|
|
char *auth_type[6]; /* we have six possible authorization types */
|
|
|
|
int at_num = 0;
|
|
|
|
char *encr_type[4]; /* we have four possible encryption types */
|
|
|
|
int et_num = 0;
|
|
|
|
|
2009-12-30 23:15:56 +01:00
|
|
|
iface = wpa_s->global->dbus;
|
2009-11-09 22:51:59 +01:00
|
|
|
|
|
|
|
/* Do nothing if the control interface is not turned on */
|
|
|
|
if (iface == NULL)
|
|
|
|
return;
|
|
|
|
|
2010-01-02 11:06:44 +01:00
|
|
|
msg = dbus_message_new_signal(wpa_s->dbus_new_path,
|
|
|
|
WPAS_DBUS_NEW_IFACE_WPS,
|
|
|
|
"Credentials");
|
|
|
|
if (msg == NULL)
|
2009-11-09 22:51:59 +01:00
|
|
|
return;
|
|
|
|
|
2010-01-02 11:06:44 +01:00
|
|
|
dbus_message_iter_init_append(msg, &iter);
|
2010-01-01 19:50:12 +01:00
|
|
|
if (!wpa_dbus_dict_open_write(&iter, &dict_iter))
|
2009-11-09 22:51:59 +01:00
|
|
|
goto nomem;
|
|
|
|
|
|
|
|
if (cred->auth_type & WPS_AUTH_OPEN)
|
|
|
|
auth_type[at_num++] = "open";
|
|
|
|
if (cred->auth_type & WPS_AUTH_WPAPSK)
|
|
|
|
auth_type[at_num++] = "wpa-psk";
|
|
|
|
if (cred->auth_type & WPS_AUTH_SHARED)
|
|
|
|
auth_type[at_num++] = "shared";
|
|
|
|
if (cred->auth_type & WPS_AUTH_WPA)
|
|
|
|
auth_type[at_num++] = "wpa-eap";
|
|
|
|
if (cred->auth_type & WPS_AUTH_WPA2)
|
|
|
|
auth_type[at_num++] = "wpa2-eap";
|
|
|
|
if (cred->auth_type & WPS_AUTH_WPA2PSK)
|
|
|
|
auth_type[at_num++] =
|
|
|
|
"wpa2-psk";
|
|
|
|
|
|
|
|
if (cred->encr_type & WPS_ENCR_NONE)
|
|
|
|
encr_type[et_num++] = "none";
|
|
|
|
if (cred->encr_type & WPS_ENCR_WEP)
|
|
|
|
encr_type[et_num++] = "wep";
|
|
|
|
if (cred->encr_type & WPS_ENCR_TKIP)
|
|
|
|
encr_type[et_num++] = "tkip";
|
|
|
|
if (cred->encr_type & WPS_ENCR_AES)
|
|
|
|
encr_type[et_num++] = "aes";
|
|
|
|
|
|
|
|
if (wpa_s->current_ssid) {
|
|
|
|
if (!wpa_dbus_dict_append_byte_array(
|
|
|
|
&dict_iter, "BSSID",
|
|
|
|
(const char *) wpa_s->current_ssid->bssid,
|
2010-01-01 19:50:12 +01:00
|
|
|
ETH_ALEN))
|
2009-11-09 22:51:59 +01:00
|
|
|
goto nomem;
|
|
|
|
}
|
|
|
|
|
2010-01-02 11:06:44 +01:00
|
|
|
if (!wpa_dbus_dict_append_byte_array(&dict_iter, "SSID",
|
|
|
|
(const char *) cred->ssid,
|
|
|
|
cred->ssid_len) ||
|
|
|
|
!wpa_dbus_dict_append_string_array(&dict_iter, "AuthType",
|
|
|
|
(const char **) auth_type,
|
|
|
|
at_num) ||
|
|
|
|
!wpa_dbus_dict_append_string_array(&dict_iter, "EncrType",
|
|
|
|
(const char **) encr_type,
|
|
|
|
et_num) ||
|
|
|
|
!wpa_dbus_dict_append_byte_array(&dict_iter, "Key",
|
|
|
|
(const char *) cred->key,
|
|
|
|
cred->key_len) ||
|
|
|
|
!wpa_dbus_dict_append_uint32(&dict_iter, "KeyIndex",
|
|
|
|
cred->key_idx) ||
|
|
|
|
!wpa_dbus_dict_close_write(&iter, &dict_iter))
|
2009-11-09 22:51:59 +01:00
|
|
|
goto nomem;
|
|
|
|
|
2010-01-02 11:06:44 +01:00
|
|
|
dbus_connection_send(iface->con, msg, NULL);
|
2009-11-09 22:51:59 +01:00
|
|
|
|
|
|
|
nomem:
|
2010-01-02 11:06:44 +01:00
|
|
|
dbus_message_unref(msg);
|
2009-11-09 22:51:59 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
#endif /* CONFIG_WPS */
|
|
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
* wpas_dbus_signal_prop_changed - Signals change of property
|
|
|
|
* @wpa_s: %wpa_supplicant network interface data
|
|
|
|
* @property: indicates which property has changed
|
|
|
|
*
|
|
|
|
* Sends ProertyChanged signals with path, interface and arguments
|
|
|
|
* depending on which property has changed.
|
|
|
|
*/
|
2010-01-01 17:45:29 +01:00
|
|
|
void wpas_dbus_signal_prop_changed(struct wpa_supplicant *wpa_s,
|
|
|
|
enum wpas_dbus_prop property)
|
2009-11-09 22:51:59 +01:00
|
|
|
{
|
|
|
|
WPADBusPropertyAccessor getter;
|
|
|
|
char *prop;
|
|
|
|
|
2010-05-23 19:23:11 +02:00
|
|
|
if (wpa_s->dbus_new_path == NULL)
|
|
|
|
return; /* Skip signal since D-Bus setup is not yet ready */
|
|
|
|
|
2009-11-09 22:51:59 +01:00
|
|
|
switch (property) {
|
|
|
|
case WPAS_DBUS_PROP_AP_SCAN:
|
|
|
|
getter = (WPADBusPropertyAccessor) wpas_dbus_getter_ap_scan;
|
|
|
|
prop = "ApScan";
|
|
|
|
break;
|
|
|
|
case WPAS_DBUS_PROP_SCANNING:
|
|
|
|
getter = (WPADBusPropertyAccessor) wpas_dbus_getter_scanning;
|
|
|
|
prop = "Scanning";
|
|
|
|
break;
|
2010-01-04 15:33:44 +01:00
|
|
|
case WPAS_DBUS_PROP_STATE:
|
|
|
|
getter = (WPADBusPropertyAccessor) wpas_dbus_getter_state;
|
|
|
|
prop = "State";
|
|
|
|
break;
|
2009-11-09 22:51:59 +01:00
|
|
|
case WPAS_DBUS_PROP_CURRENT_BSS:
|
|
|
|
getter = (WPADBusPropertyAccessor)
|
|
|
|
wpas_dbus_getter_current_bss;
|
|
|
|
prop = "CurrentBSS";
|
|
|
|
break;
|
|
|
|
case WPAS_DBUS_PROP_CURRENT_NETWORK:
|
|
|
|
getter = (WPADBusPropertyAccessor)
|
|
|
|
wpas_dbus_getter_current_network;
|
|
|
|
prop = "CurrentNetwork";
|
|
|
|
break;
|
|
|
|
default:
|
2010-01-02 11:06:44 +01:00
|
|
|
wpa_printf(MSG_ERROR, "dbus: %s: Unknown Property value %d",
|
|
|
|
__func__, property);
|
2009-11-09 22:51:59 +01:00
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
2010-01-04 16:15:57 +01:00
|
|
|
wpa_dbus_mark_property_changed(wpa_s->global->dbus,
|
|
|
|
wpa_s->dbus_new_path,
|
|
|
|
WPAS_DBUS_NEW_IFACE_INTERFACE, prop);
|
2009-11-09 22:51:59 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
|
2010-01-06 19:03:01 +01:00
|
|
|
/**
|
|
|
|
* wpas_dbus_bss_signal_prop_changed - Signals change of BSS property
|
|
|
|
* @wpa_s: %wpa_supplicant network interface data
|
|
|
|
* @property: indicates which property has changed
|
|
|
|
* @id: unique BSS identifier
|
|
|
|
*
|
|
|
|
* Sends PropertyChanged signals with path, interface, and arguments depending
|
|
|
|
* on which property has changed.
|
|
|
|
*/
|
|
|
|
void wpas_dbus_bss_signal_prop_changed(struct wpa_supplicant *wpa_s,
|
|
|
|
enum wpas_dbus_bss_prop property,
|
|
|
|
unsigned int id)
|
|
|
|
{
|
|
|
|
char path[WPAS_DBUS_OBJECT_PATH_MAX];
|
|
|
|
char *prop;
|
|
|
|
|
|
|
|
switch (property) {
|
|
|
|
case WPAS_DBUS_BSS_PROP_SIGNAL:
|
|
|
|
prop = "Signal";
|
|
|
|
break;
|
|
|
|
case WPAS_DBUS_BSS_PROP_FREQ:
|
|
|
|
prop = "Frequency";
|
|
|
|
break;
|
|
|
|
case WPAS_DBUS_BSS_PROP_MODE:
|
|
|
|
prop = "Mode";
|
|
|
|
break;
|
|
|
|
case WPAS_DBUS_BSS_PROP_PRIVACY:
|
|
|
|
prop = "Privacy";
|
|
|
|
break;
|
|
|
|
case WPAS_DBUS_BSS_PROP_RATES:
|
|
|
|
prop = "Rates";
|
|
|
|
break;
|
2010-01-16 15:37:37 +01:00
|
|
|
case WPAS_DBUS_BSS_PROP_WPA:
|
|
|
|
prop = "WPA";
|
2010-01-06 19:03:01 +01:00
|
|
|
break;
|
2010-01-16 15:37:37 +01:00
|
|
|
case WPAS_DBUS_BSS_PROP_RSN:
|
|
|
|
prop = "RSN";
|
2010-01-06 19:03:01 +01:00
|
|
|
break;
|
2010-01-16 15:37:37 +01:00
|
|
|
case WPAS_DBUS_BSS_PROP_IES:
|
|
|
|
prop = "IEs";
|
2010-01-06 19:03:01 +01:00
|
|
|
break;
|
|
|
|
default:
|
|
|
|
wpa_printf(MSG_ERROR, "dbus: %s: Unknown Property value %d",
|
|
|
|
__func__, property);
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
|
|
|
os_snprintf(path, WPAS_DBUS_OBJECT_PATH_MAX,
|
|
|
|
"%s/" WPAS_DBUS_NEW_BSSIDS_PART "/%u",
|
|
|
|
wpa_s->dbus_new_path, id);
|
|
|
|
|
|
|
|
wpa_dbus_mark_property_changed(wpa_s->global->dbus, path,
|
2010-01-09 10:40:15 +01:00
|
|
|
WPAS_DBUS_NEW_IFACE_BSS, prop);
|
2010-01-06 19:03:01 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
|
2009-11-09 22:51:59 +01:00
|
|
|
/**
|
2010-01-01 12:00:22 +01:00
|
|
|
* wpas_dbus_signal_debug_level_changed - Signals change of debug param
|
2009-11-09 22:51:59 +01:00
|
|
|
* @global: wpa_global structure
|
|
|
|
*
|
2010-01-01 12:00:22 +01:00
|
|
|
* Sends ProertyChanged signals informing that debug level has changed.
|
2009-11-09 22:51:59 +01:00
|
|
|
*/
|
2010-01-01 17:45:29 +01:00
|
|
|
void wpas_dbus_signal_debug_level_changed(struct wpa_global *global)
|
2009-11-09 22:51:59 +01:00
|
|
|
{
|
2010-01-04 16:15:57 +01:00
|
|
|
wpa_dbus_mark_property_changed(global->dbus, WPAS_DBUS_NEW_PATH,
|
|
|
|
WPAS_DBUS_NEW_INTERFACE,
|
|
|
|
"DebugLevel");
|
2010-01-01 12:00:22 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
* wpas_dbus_signal_debug_timestamp_changed - Signals change of debug param
|
|
|
|
* @global: wpa_global structure
|
|
|
|
*
|
|
|
|
* Sends ProertyChanged signals informing that debug timestamp has changed.
|
|
|
|
*/
|
2010-01-01 17:45:29 +01:00
|
|
|
void wpas_dbus_signal_debug_timestamp_changed(struct wpa_global *global)
|
2010-01-01 12:00:22 +01:00
|
|
|
{
|
2010-01-04 16:15:57 +01:00
|
|
|
wpa_dbus_mark_property_changed(global->dbus, WPAS_DBUS_NEW_PATH,
|
|
|
|
WPAS_DBUS_NEW_INTERFACE,
|
|
|
|
"DebugTimestamp");
|
2010-01-01 12:00:22 +01:00
|
|
|
}
|
|
|
|
|
2009-11-09 22:51:59 +01:00
|
|
|
|
2010-01-01 12:00:22 +01:00
|
|
|
/**
|
|
|
|
* wpas_dbus_signal_debug_show_keys_changed - Signals change of debug param
|
|
|
|
* @global: wpa_global structure
|
|
|
|
*
|
|
|
|
* Sends ProertyChanged signals informing that debug show_keys has changed.
|
|
|
|
*/
|
2010-01-01 17:45:29 +01:00
|
|
|
void wpas_dbus_signal_debug_show_keys_changed(struct wpa_global *global)
|
2010-01-01 12:00:22 +01:00
|
|
|
{
|
2010-01-04 16:15:57 +01:00
|
|
|
wpa_dbus_mark_property_changed(global->dbus, WPAS_DBUS_NEW_PATH,
|
|
|
|
WPAS_DBUS_NEW_INTERFACE,
|
|
|
|
"DebugShowKeys");
|
2009-11-09 22:51:59 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
|
2009-11-14 17:18:07 +01:00
|
|
|
static void wpas_dbus_register(struct wpa_dbus_object_desc *obj_desc,
|
|
|
|
void *priv,
|
2010-01-01 10:33:41 +01:00
|
|
|
WPADBusArgumentFreeFunction priv_free,
|
2010-01-02 23:52:30 +01:00
|
|
|
const struct wpa_dbus_method_desc *methods,
|
|
|
|
const struct wpa_dbus_property_desc *properties,
|
|
|
|
const struct wpa_dbus_signal_desc *signals)
|
2009-11-14 15:57:07 +01:00
|
|
|
{
|
2010-01-04 16:15:57 +01:00
|
|
|
int n;
|
|
|
|
|
2010-01-01 10:33:41 +01:00
|
|
|
obj_desc->user_data = priv;
|
|
|
|
obj_desc->user_data_free_func = priv_free;
|
2010-01-02 23:52:30 +01:00
|
|
|
obj_desc->methods = methods;
|
|
|
|
obj_desc->properties = properties;
|
|
|
|
obj_desc->signals = signals;
|
2010-01-04 16:15:57 +01:00
|
|
|
|
2010-01-06 10:55:21 +01:00
|
|
|
for (n = 0; properties && properties->dbus_property; properties++)
|
2010-01-04 16:15:57 +01:00
|
|
|
n++;
|
|
|
|
|
|
|
|
obj_desc->prop_changed_flags = os_zalloc(n);
|
|
|
|
if (!obj_desc->prop_changed_flags)
|
|
|
|
wpa_printf(MSG_DEBUG, "dbus: %s: can't register handlers",
|
|
|
|
__func__);
|
2009-11-14 15:57:07 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
|
2010-01-02 23:52:30 +01:00
|
|
|
static const struct wpa_dbus_method_desc wpas_dbus_global_methods[] = {
|
2009-11-14 17:18:07 +01:00
|
|
|
{ "CreateInterface", WPAS_DBUS_NEW_INTERFACE,
|
|
|
|
(WPADBusMethodHandler) &wpas_dbus_handler_create_interface,
|
|
|
|
{
|
|
|
|
{ "args", "a{sv}", ARG_IN },
|
|
|
|
{ "path", "o", ARG_OUT },
|
|
|
|
END_ARGS
|
|
|
|
}
|
|
|
|
},
|
|
|
|
{ "RemoveInterface", WPAS_DBUS_NEW_INTERFACE,
|
|
|
|
(WPADBusMethodHandler) &wpas_dbus_handler_remove_interface,
|
|
|
|
{
|
|
|
|
{ "path", "o", ARG_IN },
|
|
|
|
END_ARGS
|
|
|
|
}
|
|
|
|
},
|
|
|
|
{ "GetInterface", WPAS_DBUS_NEW_INTERFACE,
|
|
|
|
(WPADBusMethodHandler) &wpas_dbus_handler_get_interface,
|
|
|
|
{
|
|
|
|
{ "ifname", "s", ARG_IN },
|
|
|
|
{ "path", "o", ARG_OUT },
|
|
|
|
END_ARGS
|
|
|
|
}
|
|
|
|
},
|
|
|
|
{ NULL, NULL, NULL, { END_ARGS } }
|
|
|
|
};
|
|
|
|
|
2010-01-02 23:52:30 +01:00
|
|
|
static const struct wpa_dbus_property_desc wpas_dbus_global_properties[] = {
|
2010-01-04 15:22:26 +01:00
|
|
|
{ "DebugLevel", WPAS_DBUS_NEW_INTERFACE, "s",
|
2010-01-01 12:00:22 +01:00
|
|
|
(WPADBusPropertyAccessor) wpas_dbus_getter_debug_level,
|
|
|
|
(WPADBusPropertyAccessor) wpas_dbus_setter_debug_level,
|
|
|
|
RW
|
|
|
|
},
|
|
|
|
{ "DebugTimestamp", WPAS_DBUS_NEW_INTERFACE, "b",
|
|
|
|
(WPADBusPropertyAccessor) wpas_dbus_getter_debug_timestamp,
|
|
|
|
(WPADBusPropertyAccessor) wpas_dbus_setter_debug_timestamp,
|
|
|
|
RW
|
|
|
|
},
|
|
|
|
{ "DebugShowKeys", WPAS_DBUS_NEW_INTERFACE, "b",
|
|
|
|
(WPADBusPropertyAccessor) wpas_dbus_getter_debug_show_keys,
|
|
|
|
(WPADBusPropertyAccessor) wpas_dbus_setter_debug_show_keys,
|
2009-11-14 17:18:07 +01:00
|
|
|
RW
|
|
|
|
},
|
|
|
|
{ "Interfaces", WPAS_DBUS_NEW_INTERFACE, "ao",
|
|
|
|
(WPADBusPropertyAccessor) &wpas_dbus_getter_interfaces,
|
|
|
|
NULL,
|
|
|
|
R
|
|
|
|
},
|
|
|
|
{ "EapMethods", WPAS_DBUS_NEW_INTERFACE, "as",
|
2010-01-01 11:47:59 +01:00
|
|
|
(WPADBusPropertyAccessor) wpas_dbus_getter_eap_methods,
|
2009-11-14 17:18:07 +01:00
|
|
|
NULL,
|
|
|
|
R
|
|
|
|
},
|
|
|
|
{ NULL, NULL, NULL, NULL, NULL, 0 }
|
|
|
|
};
|
|
|
|
|
2010-01-02 23:52:30 +01:00
|
|
|
static const struct wpa_dbus_signal_desc wpas_dbus_global_signals[] = {
|
2009-11-14 17:18:07 +01:00
|
|
|
{ "InterfaceAdded", WPAS_DBUS_NEW_INTERFACE,
|
|
|
|
{
|
|
|
|
{ "path", "o", ARG_OUT },
|
2010-01-01 11:47:59 +01:00
|
|
|
{ "properties", "a{sv}", ARG_OUT },
|
2009-11-14 17:18:07 +01:00
|
|
|
END_ARGS
|
|
|
|
}
|
|
|
|
},
|
|
|
|
{ "InterfaceRemoved", WPAS_DBUS_NEW_INTERFACE,
|
|
|
|
{
|
|
|
|
{ "path", "o", ARG_OUT },
|
|
|
|
END_ARGS
|
|
|
|
}
|
|
|
|
},
|
|
|
|
{ "PropertiesChanged", WPAS_DBUS_NEW_INTERFACE,
|
|
|
|
{
|
|
|
|
{ "properties", "a{sv}", ARG_OUT },
|
|
|
|
END_ARGS
|
|
|
|
}
|
|
|
|
},
|
|
|
|
{ NULL, NULL, { END_ARGS } }
|
|
|
|
};
|
2009-11-14 15:57:07 +01:00
|
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
* wpas_dbus_ctrl_iface_init - Initialize dbus control interface
|
|
|
|
* @global: Pointer to global data from wpa_supplicant_init()
|
2009-12-30 23:15:56 +01:00
|
|
|
* Returns: 0 on success or -1 on failure
|
2009-11-14 15:57:07 +01:00
|
|
|
*
|
|
|
|
* Initialize the dbus control interface for wpa_supplicantand and start
|
|
|
|
* receiving commands from external programs over the bus.
|
|
|
|
*/
|
2009-12-30 23:15:56 +01:00
|
|
|
int wpas_dbus_ctrl_iface_init(struct wpas_dbus_priv *priv)
|
2009-11-14 15:57:07 +01:00
|
|
|
{
|
|
|
|
struct wpa_dbus_object_desc *obj_desc;
|
2009-12-30 23:15:56 +01:00
|
|
|
int ret;
|
2009-11-09 22:51:59 +01:00
|
|
|
|
|
|
|
obj_desc = os_zalloc(sizeof(struct wpa_dbus_object_desc));
|
|
|
|
if (!obj_desc) {
|
|
|
|
wpa_printf(MSG_ERROR, "Not enough memory "
|
|
|
|
"to create object description");
|
2009-12-30 23:15:56 +01:00
|
|
|
return -1;
|
2009-11-09 22:51:59 +01:00
|
|
|
}
|
|
|
|
|
2010-01-01 10:33:41 +01:00
|
|
|
wpas_dbus_register(obj_desc, priv->global, NULL,
|
|
|
|
wpas_dbus_global_methods,
|
2009-11-14 17:18:07 +01:00
|
|
|
wpas_dbus_global_properties,
|
|
|
|
wpas_dbus_global_signals);
|
2009-11-09 22:51:59 +01:00
|
|
|
|
2009-12-29 21:17:18 +01:00
|
|
|
wpa_printf(MSG_DEBUG, "dbus: Register D-Bus object '%s'",
|
|
|
|
WPAS_DBUS_NEW_PATH);
|
2009-12-30 23:15:56 +01:00
|
|
|
ret = wpa_dbus_ctrl_iface_init(priv, WPAS_DBUS_NEW_PATH,
|
|
|
|
WPAS_DBUS_NEW_SERVICE,
|
|
|
|
obj_desc);
|
|
|
|
if (ret < 0)
|
2009-11-09 22:51:59 +01:00
|
|
|
free_dbus_object_desc(obj_desc);
|
2009-12-31 20:50:12 +01:00
|
|
|
else
|
|
|
|
priv->dbus_new_initialized = 1;
|
2009-11-09 22:51:59 +01:00
|
|
|
|
2009-12-30 23:15:56 +01:00
|
|
|
return ret;
|
2009-11-09 22:51:59 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
* wpas_dbus_ctrl_iface_deinit - Deinitialize dbus ctrl interface for
|
|
|
|
* wpa_supplicant
|
2009-12-30 23:15:56 +01:00
|
|
|
* @iface: Pointer to dbus private data from wpas_dbus_init()
|
2009-11-09 22:51:59 +01:00
|
|
|
*
|
|
|
|
* Deinitialize the dbus control interface that was initialized with
|
|
|
|
* wpas_dbus_ctrl_iface_init().
|
|
|
|
*/
|
2009-12-30 23:15:56 +01:00
|
|
|
void wpas_dbus_ctrl_iface_deinit(struct wpas_dbus_priv *iface)
|
2009-11-09 22:51:59 +01:00
|
|
|
{
|
2009-12-31 20:50:12 +01:00
|
|
|
if (!iface->dbus_new_initialized)
|
|
|
|
return;
|
2009-12-30 23:15:56 +01:00
|
|
|
wpa_printf(MSG_DEBUG, "dbus: Unregister D-Bus object '%s'",
|
|
|
|
WPAS_DBUS_NEW_PATH);
|
|
|
|
dbus_connection_unregister_object_path(iface->con,
|
|
|
|
WPAS_DBUS_NEW_PATH);
|
2009-11-09 22:51:59 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
|
2009-12-26 15:20:37 +01:00
|
|
|
static void wpa_dbus_free(void *ptr)
|
|
|
|
{
|
|
|
|
os_free(ptr);
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2010-01-02 23:52:30 +01:00
|
|
|
static const struct wpa_dbus_property_desc wpas_dbus_network_properties[] = {
|
2010-01-01 10:33:41 +01:00
|
|
|
{ "Properties", WPAS_DBUS_NEW_IFACE_NETWORK, "a{sv}",
|
|
|
|
(WPADBusPropertyAccessor) wpas_dbus_getter_network_properties,
|
|
|
|
(WPADBusPropertyAccessor) wpas_dbus_setter_network_properties,
|
|
|
|
RW
|
|
|
|
},
|
|
|
|
{ "Enabled", WPAS_DBUS_NEW_IFACE_NETWORK, "b",
|
|
|
|
(WPADBusPropertyAccessor) wpas_dbus_getter_enabled,
|
|
|
|
(WPADBusPropertyAccessor) wpas_dbus_setter_enabled,
|
|
|
|
RW
|
|
|
|
},
|
|
|
|
{ NULL, NULL, NULL, NULL, NULL, 0 }
|
|
|
|
};
|
|
|
|
|
|
|
|
|
2010-01-02 23:52:30 +01:00
|
|
|
static const struct wpa_dbus_signal_desc wpas_dbus_network_signals[] = {
|
2010-01-01 10:33:41 +01:00
|
|
|
{ "PropertiesChanged", WPAS_DBUS_NEW_IFACE_NETWORK,
|
|
|
|
{
|
|
|
|
{ "properties", "a{sv}", ARG_OUT },
|
|
|
|
END_ARGS
|
|
|
|
}
|
|
|
|
},
|
|
|
|
{ NULL, NULL, { END_ARGS } }
|
|
|
|
};
|
|
|
|
|
|
|
|
|
2009-11-09 22:51:59 +01:00
|
|
|
/**
|
|
|
|
* wpas_dbus_register_network - Register a configured network with dbus
|
|
|
|
* @wpa_s: wpa_supplicant interface structure
|
|
|
|
* @ssid: network configuration data
|
|
|
|
* Returns: 0 on success, -1 on failure
|
|
|
|
*
|
|
|
|
* Registers network representing object with dbus
|
|
|
|
*/
|
2010-01-01 17:45:29 +01:00
|
|
|
int wpas_dbus_register_network(struct wpa_supplicant *wpa_s,
|
|
|
|
struct wpa_ssid *ssid)
|
2009-11-09 22:51:59 +01:00
|
|
|
{
|
2009-12-30 23:15:56 +01:00
|
|
|
struct wpas_dbus_priv *ctrl_iface;
|
2009-11-09 22:51:59 +01:00
|
|
|
struct wpa_dbus_object_desc *obj_desc;
|
2010-01-03 00:01:56 +01:00
|
|
|
struct network_handler_args *arg;
|
2010-01-02 16:17:00 +01:00
|
|
|
char net_obj_path[WPAS_DBUS_OBJECT_PATH_MAX];
|
2009-11-09 22:51:59 +01:00
|
|
|
|
|
|
|
/* Do nothing if the control interface is not turned on */
|
|
|
|
if (wpa_s == NULL || wpa_s->global == NULL)
|
|
|
|
return 0;
|
2009-12-30 23:15:56 +01:00
|
|
|
ctrl_iface = wpa_s->global->dbus;
|
2009-11-09 22:51:59 +01:00
|
|
|
if (ctrl_iface == NULL)
|
|
|
|
return 0;
|
|
|
|
|
|
|
|
os_snprintf(net_obj_path, WPAS_DBUS_OBJECT_PATH_MAX,
|
2009-11-10 17:20:12 +01:00
|
|
|
"%s/" WPAS_DBUS_NEW_NETWORKS_PART "/%u",
|
2010-01-01 18:12:31 +01:00
|
|
|
wpa_s->dbus_new_path, ssid->id);
|
2009-11-09 22:51:59 +01:00
|
|
|
|
2009-12-29 21:17:18 +01:00
|
|
|
wpa_printf(MSG_DEBUG, "dbus: Register network object '%s'",
|
|
|
|
net_obj_path);
|
2009-11-09 22:51:59 +01:00
|
|
|
obj_desc = os_zalloc(sizeof(struct wpa_dbus_object_desc));
|
|
|
|
if (!obj_desc) {
|
|
|
|
wpa_printf(MSG_ERROR, "Not enough memory "
|
|
|
|
"to create object description");
|
|
|
|
goto err;
|
|
|
|
}
|
|
|
|
|
|
|
|
/* allocate memory for handlers arguments */
|
2010-01-01 10:33:41 +01:00
|
|
|
arg = os_zalloc(sizeof(struct network_handler_args));
|
|
|
|
if (!arg) {
|
2009-11-09 22:51:59 +01:00
|
|
|
wpa_printf(MSG_ERROR, "Not enough memory "
|
|
|
|
"to create arguments for method");
|
|
|
|
goto err;
|
|
|
|
}
|
|
|
|
|
2010-01-01 10:33:41 +01:00
|
|
|
arg->wpa_s = wpa_s;
|
|
|
|
arg->ssid = ssid;
|
|
|
|
|
|
|
|
wpas_dbus_register(obj_desc, arg, wpa_dbus_free, NULL,
|
|
|
|
wpas_dbus_network_properties,
|
|
|
|
wpas_dbus_network_signals);
|
2009-11-09 22:51:59 +01:00
|
|
|
|
|
|
|
if (wpa_dbus_register_object_per_iface(ctrl_iface, net_obj_path,
|
|
|
|
wpa_s->ifname, obj_desc))
|
|
|
|
goto err;
|
|
|
|
|
|
|
|
wpas_dbus_signal_network_added(wpa_s, ssid->id);
|
|
|
|
|
|
|
|
return 0;
|
|
|
|
|
|
|
|
err:
|
2010-01-03 00:01:56 +01:00
|
|
|
free_dbus_object_desc(obj_desc);
|
2009-11-09 22:51:59 +01:00
|
|
|
return -1;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
* wpas_dbus_unregister_network - Unregister a configured network from dbus
|
|
|
|
* @wpa_s: wpa_supplicant interface structure
|
|
|
|
* @nid: network id
|
|
|
|
* Returns: 0 on success, -1 on failure
|
|
|
|
*
|
|
|
|
* Unregisters network representing object from dbus
|
|
|
|
*/
|
2010-01-01 17:45:29 +01:00
|
|
|
int wpas_dbus_unregister_network(struct wpa_supplicant *wpa_s, int nid)
|
2009-11-09 22:51:59 +01:00
|
|
|
{
|
2009-12-30 23:15:56 +01:00
|
|
|
struct wpas_dbus_priv *ctrl_iface;
|
2010-01-02 16:17:00 +01:00
|
|
|
char net_obj_path[WPAS_DBUS_OBJECT_PATH_MAX];
|
2009-11-09 22:51:59 +01:00
|
|
|
int ret;
|
|
|
|
|
|
|
|
/* Do nothing if the control interface is not turned on */
|
2010-01-06 20:31:13 +01:00
|
|
|
if (wpa_s == NULL || wpa_s->global == NULL ||
|
|
|
|
wpa_s->dbus_new_path == NULL)
|
2009-11-09 22:51:59 +01:00
|
|
|
return 0;
|
2009-12-30 23:15:56 +01:00
|
|
|
ctrl_iface = wpa_s->global->dbus;
|
2009-11-09 22:51:59 +01:00
|
|
|
if (ctrl_iface == NULL)
|
|
|
|
return 0;
|
|
|
|
|
|
|
|
os_snprintf(net_obj_path, WPAS_DBUS_OBJECT_PATH_MAX,
|
2009-11-10 17:20:12 +01:00
|
|
|
"%s/" WPAS_DBUS_NEW_NETWORKS_PART "/%u",
|
2010-01-01 18:12:31 +01:00
|
|
|
wpa_s->dbus_new_path, nid);
|
2009-11-09 22:51:59 +01:00
|
|
|
|
2009-12-29 21:17:18 +01:00
|
|
|
wpa_printf(MSG_DEBUG, "dbus: Unregister network object '%s'",
|
|
|
|
net_obj_path);
|
2009-11-09 22:51:59 +01:00
|
|
|
ret = wpa_dbus_unregister_object_per_iface(ctrl_iface, net_obj_path);
|
|
|
|
|
|
|
|
if (!ret)
|
|
|
|
wpas_dbus_signal_network_removed(wpa_s, nid);
|
|
|
|
|
|
|
|
return ret;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2010-01-02 23:52:30 +01:00
|
|
|
static const struct wpa_dbus_property_desc wpas_dbus_bss_properties[] = {
|
2010-01-09 10:40:15 +01:00
|
|
|
{ "SSID", WPAS_DBUS_NEW_IFACE_BSS, "ay",
|
2010-01-01 11:28:24 +01:00
|
|
|
(WPADBusPropertyAccessor) wpas_dbus_getter_bss_ssid,
|
|
|
|
NULL,
|
|
|
|
R
|
|
|
|
},
|
2010-01-09 10:40:15 +01:00
|
|
|
{ "BSSID", WPAS_DBUS_NEW_IFACE_BSS, "ay",
|
2010-01-01 11:28:24 +01:00
|
|
|
(WPADBusPropertyAccessor) wpas_dbus_getter_bss_bssid,
|
|
|
|
NULL,
|
|
|
|
R
|
|
|
|
},
|
2010-01-09 10:40:15 +01:00
|
|
|
{ "Privacy", WPAS_DBUS_NEW_IFACE_BSS, "b",
|
2010-01-01 11:28:24 +01:00
|
|
|
(WPADBusPropertyAccessor) wpas_dbus_getter_bss_privacy,
|
|
|
|
NULL,
|
|
|
|
R
|
|
|
|
},
|
2010-01-09 10:40:15 +01:00
|
|
|
{ "Mode", WPAS_DBUS_NEW_IFACE_BSS, "s",
|
2010-01-01 11:28:24 +01:00
|
|
|
(WPADBusPropertyAccessor) wpas_dbus_getter_bss_mode,
|
|
|
|
NULL,
|
|
|
|
R
|
|
|
|
},
|
2010-01-09 10:40:15 +01:00
|
|
|
{ "Signal", WPAS_DBUS_NEW_IFACE_BSS, "n",
|
2010-01-01 11:28:24 +01:00
|
|
|
(WPADBusPropertyAccessor) wpas_dbus_getter_bss_signal,
|
|
|
|
NULL,
|
|
|
|
R
|
|
|
|
},
|
2010-01-09 10:40:15 +01:00
|
|
|
{ "Frequency", WPAS_DBUS_NEW_IFACE_BSS, "q",
|
2010-01-01 11:28:24 +01:00
|
|
|
(WPADBusPropertyAccessor) wpas_dbus_getter_bss_frequency,
|
|
|
|
NULL,
|
|
|
|
R
|
|
|
|
},
|
2010-01-09 10:40:15 +01:00
|
|
|
{ "Rates", WPAS_DBUS_NEW_IFACE_BSS, "au",
|
2010-01-04 15:52:30 +01:00
|
|
|
(WPADBusPropertyAccessor) wpas_dbus_getter_bss_rates,
|
2010-01-01 11:28:24 +01:00
|
|
|
NULL,
|
|
|
|
R
|
|
|
|
},
|
2010-01-16 15:37:37 +01:00
|
|
|
{ "WPA", WPAS_DBUS_NEW_IFACE_BSS, "a{sv}",
|
|
|
|
(WPADBusPropertyAccessor) wpas_dbus_getter_bss_wpa,
|
2010-01-01 11:28:24 +01:00
|
|
|
NULL,
|
|
|
|
R
|
|
|
|
},
|
2010-01-16 15:37:37 +01:00
|
|
|
{ "RSN", WPAS_DBUS_NEW_IFACE_BSS, "a{sv}",
|
|
|
|
(WPADBusPropertyAccessor) wpas_dbus_getter_bss_rsn,
|
2010-01-01 11:28:24 +01:00
|
|
|
NULL,
|
|
|
|
R
|
|
|
|
},
|
2010-01-16 15:37:37 +01:00
|
|
|
{ "IEs", WPAS_DBUS_NEW_IFACE_BSS, "ay",
|
|
|
|
(WPADBusPropertyAccessor) wpas_dbus_getter_bss_ies,
|
2010-01-01 10:33:41 +01:00
|
|
|
NULL,
|
|
|
|
R
|
|
|
|
},
|
|
|
|
{ NULL, NULL, NULL, NULL, NULL, 0 }
|
|
|
|
};
|
|
|
|
|
|
|
|
|
2010-01-02 23:52:30 +01:00
|
|
|
static const struct wpa_dbus_signal_desc wpas_dbus_bss_signals[] = {
|
2010-01-09 10:40:15 +01:00
|
|
|
{ "PropertiesChanged", WPAS_DBUS_NEW_IFACE_BSS,
|
2010-01-01 10:33:41 +01:00
|
|
|
{
|
|
|
|
{ "properties", "a{sv}", ARG_OUT },
|
|
|
|
END_ARGS
|
|
|
|
}
|
|
|
|
},
|
|
|
|
{ NULL, NULL, { END_ARGS } }
|
|
|
|
};
|
|
|
|
|
|
|
|
|
2009-11-09 22:51:59 +01:00
|
|
|
/**
|
2009-11-14 14:57:02 +01:00
|
|
|
* wpas_dbus_unregister_bss - Unregister a scanned BSS from dbus
|
2009-11-09 22:51:59 +01:00
|
|
|
* @wpa_s: wpa_supplicant interface structure
|
|
|
|
* @bssid: scanned network bssid
|
2009-12-28 00:10:07 +01:00
|
|
|
* @id: unique BSS identifier
|
2009-11-09 22:51:59 +01:00
|
|
|
* Returns: 0 on success, -1 on failure
|
|
|
|
*
|
2009-11-14 14:57:02 +01:00
|
|
|
* Unregisters BSS representing object from dbus
|
2009-11-09 22:51:59 +01:00
|
|
|
*/
|
2010-01-01 17:45:29 +01:00
|
|
|
int wpas_dbus_unregister_bss(struct wpa_supplicant *wpa_s,
|
|
|
|
u8 bssid[ETH_ALEN], unsigned int id)
|
2009-11-09 22:51:59 +01:00
|
|
|
{
|
2009-12-30 23:15:56 +01:00
|
|
|
struct wpas_dbus_priv *ctrl_iface;
|
2010-01-02 16:17:00 +01:00
|
|
|
char bss_obj_path[WPAS_DBUS_OBJECT_PATH_MAX];
|
2009-11-09 22:51:59 +01:00
|
|
|
|
|
|
|
/* Do nothing if the control interface is not turned on */
|
|
|
|
if (wpa_s == NULL || wpa_s->global == NULL)
|
|
|
|
return 0;
|
2009-12-30 23:15:56 +01:00
|
|
|
ctrl_iface = wpa_s->global->dbus;
|
2009-11-09 22:51:59 +01:00
|
|
|
if (ctrl_iface == NULL)
|
|
|
|
return 0;
|
|
|
|
|
|
|
|
os_snprintf(bss_obj_path, WPAS_DBUS_OBJECT_PATH_MAX,
|
2009-12-28 00:10:07 +01:00
|
|
|
"%s/" WPAS_DBUS_NEW_BSSIDS_PART "/%u",
|
2010-01-01 18:12:31 +01:00
|
|
|
wpa_s->dbus_new_path, id);
|
2009-11-09 22:51:59 +01:00
|
|
|
|
2009-12-29 21:17:18 +01:00
|
|
|
wpa_printf(MSG_DEBUG, "dbus: Unregister BSS object '%s'",
|
|
|
|
bss_obj_path);
|
2009-11-09 22:51:59 +01:00
|
|
|
if (wpa_dbus_unregister_object_per_iface(ctrl_iface, bss_obj_path)) {
|
2010-01-02 16:17:00 +01:00
|
|
|
wpa_printf(MSG_ERROR, "dbus: Cannot unregister BSS object %s",
|
2009-11-09 22:51:59 +01:00
|
|
|
bss_obj_path);
|
|
|
|
return -1;
|
|
|
|
}
|
|
|
|
|
|
|
|
wpas_dbus_signal_bss_removed(wpa_s, bss_obj_path);
|
|
|
|
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2009-11-14 14:57:02 +01:00
|
|
|
/**
|
|
|
|
* wpas_dbus_register_bss - Register a scanned BSS with dbus
|
|
|
|
* @wpa_s: wpa_supplicant interface structure
|
|
|
|
* @bssid: scanned network bssid
|
2009-12-28 00:10:07 +01:00
|
|
|
* @id: unique BSS identifier
|
2009-11-14 14:57:02 +01:00
|
|
|
* Returns: 0 on success, -1 on failure
|
|
|
|
*
|
|
|
|
* Registers BSS representing object with dbus
|
|
|
|
*/
|
2010-01-01 17:45:29 +01:00
|
|
|
int wpas_dbus_register_bss(struct wpa_supplicant *wpa_s,
|
|
|
|
u8 bssid[ETH_ALEN], unsigned int id)
|
2009-11-09 22:51:59 +01:00
|
|
|
{
|
2009-12-30 23:15:56 +01:00
|
|
|
struct wpas_dbus_priv *ctrl_iface;
|
2009-11-09 22:51:59 +01:00
|
|
|
struct wpa_dbus_object_desc *obj_desc;
|
2010-01-02 16:17:00 +01:00
|
|
|
char bss_obj_path[WPAS_DBUS_OBJECT_PATH_MAX];
|
2010-01-03 00:01:56 +01:00
|
|
|
struct bss_handler_args *arg;
|
2009-11-09 22:51:59 +01:00
|
|
|
|
|
|
|
/* Do nothing if the control interface is not turned on */
|
|
|
|
if (wpa_s == NULL || wpa_s->global == NULL)
|
|
|
|
return 0;
|
2009-12-30 23:15:56 +01:00
|
|
|
ctrl_iface = wpa_s->global->dbus;
|
2009-11-09 22:51:59 +01:00
|
|
|
if (ctrl_iface == NULL)
|
|
|
|
return 0;
|
|
|
|
|
|
|
|
os_snprintf(bss_obj_path, WPAS_DBUS_OBJECT_PATH_MAX,
|
2009-12-28 00:10:07 +01:00
|
|
|
"%s/" WPAS_DBUS_NEW_BSSIDS_PART "/%u",
|
2010-01-01 18:12:31 +01:00
|
|
|
wpa_s->dbus_new_path, id);
|
2009-11-09 22:51:59 +01:00
|
|
|
|
|
|
|
obj_desc = os_zalloc(sizeof(struct wpa_dbus_object_desc));
|
|
|
|
if (!obj_desc) {
|
|
|
|
wpa_printf(MSG_ERROR, "Not enough memory "
|
|
|
|
"to create object description");
|
|
|
|
goto err;
|
|
|
|
}
|
|
|
|
|
|
|
|
arg = os_zalloc(sizeof(struct bss_handler_args));
|
|
|
|
if (!arg) {
|
|
|
|
wpa_printf(MSG_ERROR, "Not enough memory "
|
|
|
|
"to create arguments for handler");
|
|
|
|
goto err;
|
|
|
|
}
|
|
|
|
arg->wpa_s = wpa_s;
|
2009-12-28 00:10:07 +01:00
|
|
|
arg->id = id;
|
2009-11-09 22:51:59 +01:00
|
|
|
|
2010-01-01 10:33:41 +01:00
|
|
|
wpas_dbus_register(obj_desc, arg, wpa_dbus_free, NULL,
|
|
|
|
wpas_dbus_bss_properties,
|
|
|
|
wpas_dbus_bss_signals);
|
2009-11-09 22:51:59 +01:00
|
|
|
|
2009-12-29 21:17:18 +01:00
|
|
|
wpa_printf(MSG_DEBUG, "dbus: Register BSS object '%s'",
|
|
|
|
bss_obj_path);
|
2009-11-09 22:51:59 +01:00
|
|
|
if (wpa_dbus_register_object_per_iface(ctrl_iface, bss_obj_path,
|
|
|
|
wpa_s->ifname, obj_desc)) {
|
|
|
|
wpa_printf(MSG_ERROR,
|
|
|
|
"Cannot register BSSID dbus object %s.",
|
|
|
|
bss_obj_path);
|
|
|
|
goto err;
|
|
|
|
}
|
|
|
|
|
|
|
|
wpas_dbus_signal_bss_added(wpa_s, bss_obj_path);
|
|
|
|
|
|
|
|
return 0;
|
|
|
|
|
|
|
|
err:
|
2010-01-03 00:01:56 +01:00
|
|
|
free_dbus_object_desc(obj_desc);
|
2009-11-09 22:51:59 +01:00
|
|
|
return -1;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2010-01-02 23:52:30 +01:00
|
|
|
static const struct wpa_dbus_method_desc wpas_dbus_interface_methods[] = {
|
2009-11-14 17:18:07 +01:00
|
|
|
{ "Scan", WPAS_DBUS_NEW_IFACE_INTERFACE,
|
|
|
|
(WPADBusMethodHandler) &wpas_dbus_handler_scan,
|
|
|
|
{
|
|
|
|
{ "args", "a{sv}", ARG_IN },
|
|
|
|
END_ARGS
|
|
|
|
}
|
|
|
|
},
|
|
|
|
{ "Disconnect", WPAS_DBUS_NEW_IFACE_INTERFACE,
|
|
|
|
(WPADBusMethodHandler) &wpas_dbus_handler_disconnect,
|
|
|
|
{
|
|
|
|
END_ARGS
|
|
|
|
}
|
|
|
|
},
|
|
|
|
{ "AddNetwork", WPAS_DBUS_NEW_IFACE_INTERFACE,
|
|
|
|
(WPADBusMethodHandler) &wpas_dbus_handler_add_network,
|
|
|
|
{
|
|
|
|
{ "args", "a{sv}", ARG_IN },
|
|
|
|
{ "path", "o", ARG_OUT },
|
|
|
|
END_ARGS
|
|
|
|
}
|
|
|
|
},
|
|
|
|
{ "RemoveNetwork", WPAS_DBUS_NEW_IFACE_INTERFACE,
|
|
|
|
(WPADBusMethodHandler) &wpas_dbus_handler_remove_network,
|
|
|
|
{
|
|
|
|
{ "path", "o", ARG_IN },
|
|
|
|
END_ARGS
|
|
|
|
}
|
|
|
|
},
|
|
|
|
{ "SelectNetwork", WPAS_DBUS_NEW_IFACE_INTERFACE,
|
|
|
|
(WPADBusMethodHandler) &wpas_dbus_handler_select_network,
|
|
|
|
{
|
|
|
|
{ "path", "o", ARG_IN },
|
|
|
|
END_ARGS
|
|
|
|
}
|
|
|
|
},
|
|
|
|
{ "AddBlob", WPAS_DBUS_NEW_IFACE_INTERFACE,
|
|
|
|
(WPADBusMethodHandler) &wpas_dbus_handler_add_blob,
|
|
|
|
{
|
|
|
|
{ "name", "s", ARG_IN },
|
|
|
|
{ "data", "ay", ARG_IN },
|
|
|
|
END_ARGS
|
|
|
|
}
|
|
|
|
},
|
|
|
|
{ "GetBlob", WPAS_DBUS_NEW_IFACE_INTERFACE,
|
|
|
|
(WPADBusMethodHandler) &wpas_dbus_handler_get_blob,
|
|
|
|
{
|
|
|
|
{ "name", "s", ARG_IN },
|
|
|
|
{ "data", "ay", ARG_OUT },
|
|
|
|
END_ARGS
|
|
|
|
}
|
|
|
|
},
|
|
|
|
{ "RemoveBlob", WPAS_DBUS_NEW_IFACE_INTERFACE,
|
|
|
|
(WPADBusMethodHandler) &wpas_dbus_handler_remove_blob,
|
|
|
|
{
|
|
|
|
{ "name", "s", ARG_IN },
|
|
|
|
END_ARGS
|
|
|
|
}
|
|
|
|
},
|
|
|
|
#ifdef CONFIG_WPS
|
|
|
|
{ "Start", WPAS_DBUS_NEW_IFACE_WPS,
|
|
|
|
(WPADBusMethodHandler) &wpas_dbus_handler_wps_start,
|
|
|
|
{
|
|
|
|
{ "args", "a{sv}", ARG_IN },
|
|
|
|
{ "output", "a{sv}", ARG_OUT },
|
|
|
|
END_ARGS
|
|
|
|
}
|
|
|
|
},
|
|
|
|
#endif /* CONFIG_WPS */
|
|
|
|
{ NULL, NULL, NULL, { END_ARGS } }
|
|
|
|
};
|
|
|
|
|
2010-01-02 23:52:30 +01:00
|
|
|
static const struct wpa_dbus_property_desc wpas_dbus_interface_properties[] = {
|
2009-11-14 17:18:07 +01:00
|
|
|
{ "Capabilities", WPAS_DBUS_NEW_IFACE_INTERFACE, "a{sv}",
|
|
|
|
(WPADBusPropertyAccessor) wpas_dbus_getter_capabilities,
|
|
|
|
NULL, R
|
|
|
|
},
|
|
|
|
{ "State", WPAS_DBUS_NEW_IFACE_INTERFACE, "s",
|
|
|
|
(WPADBusPropertyAccessor) wpas_dbus_getter_state,
|
|
|
|
NULL, R
|
|
|
|
},
|
|
|
|
{ "Scanning", WPAS_DBUS_NEW_IFACE_INTERFACE, "b",
|
|
|
|
(WPADBusPropertyAccessor) wpas_dbus_getter_scanning,
|
|
|
|
NULL, R
|
|
|
|
},
|
|
|
|
{ "ApScan", WPAS_DBUS_NEW_IFACE_INTERFACE, "u",
|
|
|
|
(WPADBusPropertyAccessor) wpas_dbus_getter_ap_scan,
|
|
|
|
(WPADBusPropertyAccessor) wpas_dbus_setter_ap_scan,
|
|
|
|
RW
|
|
|
|
},
|
|
|
|
{ "Ifname", WPAS_DBUS_NEW_IFACE_INTERFACE, "s",
|
|
|
|
(WPADBusPropertyAccessor) wpas_dbus_getter_ifname,
|
|
|
|
NULL, R
|
|
|
|
},
|
|
|
|
{ "Driver", WPAS_DBUS_NEW_IFACE_INTERFACE, "s",
|
|
|
|
(WPADBusPropertyAccessor) wpas_dbus_getter_driver,
|
|
|
|
NULL, R
|
|
|
|
},
|
|
|
|
{ "BridgeIfname", WPAS_DBUS_NEW_IFACE_INTERFACE, "s",
|
|
|
|
(WPADBusPropertyAccessor) wpas_dbus_getter_bridge_ifname,
|
|
|
|
NULL, R
|
|
|
|
},
|
|
|
|
{ "CurrentBSS", WPAS_DBUS_NEW_IFACE_INTERFACE, "o",
|
|
|
|
(WPADBusPropertyAccessor) wpas_dbus_getter_current_bss,
|
|
|
|
NULL, R
|
|
|
|
},
|
|
|
|
{ "CurrentNetwork", WPAS_DBUS_NEW_IFACE_INTERFACE, "o",
|
|
|
|
(WPADBusPropertyAccessor) wpas_dbus_getter_current_network,
|
|
|
|
NULL, R
|
|
|
|
},
|
|
|
|
{ "Blobs", WPAS_DBUS_NEW_IFACE_INTERFACE, "a{say}",
|
|
|
|
(WPADBusPropertyAccessor) wpas_dbus_getter_blobs,
|
|
|
|
NULL, R
|
|
|
|
},
|
|
|
|
{ "BSSs", WPAS_DBUS_NEW_IFACE_INTERFACE, "ao",
|
|
|
|
(WPADBusPropertyAccessor) wpas_dbus_getter_bsss,
|
|
|
|
NULL, R
|
|
|
|
},
|
|
|
|
{ "Networks", WPAS_DBUS_NEW_IFACE_INTERFACE, "ao",
|
|
|
|
(WPADBusPropertyAccessor) wpas_dbus_getter_networks,
|
|
|
|
NULL, R
|
|
|
|
},
|
|
|
|
#ifdef CONFIG_WPS
|
|
|
|
{ "ProcessCredentials", WPAS_DBUS_NEW_IFACE_WPS, "b",
|
|
|
|
(WPADBusPropertyAccessor) wpas_dbus_getter_process_credentials,
|
|
|
|
(WPADBusPropertyAccessor) wpas_dbus_setter_process_credentials,
|
|
|
|
RW
|
|
|
|
},
|
|
|
|
#endif /* CONFIG_WPS */
|
|
|
|
{ NULL, NULL, NULL, NULL, NULL, 0 }
|
|
|
|
};
|
|
|
|
|
2010-01-02 23:52:30 +01:00
|
|
|
static const struct wpa_dbus_signal_desc wpas_dbus_interface_signals[] = {
|
2009-11-14 17:18:07 +01:00
|
|
|
{ "ScanDone", WPAS_DBUS_NEW_IFACE_INTERFACE,
|
|
|
|
{
|
|
|
|
{ "success", "b", ARG_OUT },
|
|
|
|
END_ARGS
|
|
|
|
}
|
|
|
|
},
|
|
|
|
{ "BSSAdded", WPAS_DBUS_NEW_IFACE_INTERFACE,
|
|
|
|
{
|
|
|
|
{ "path", "o", ARG_OUT },
|
2010-01-01 11:47:59 +01:00
|
|
|
{ "properties", "a{sv}", ARG_OUT },
|
2009-11-14 17:18:07 +01:00
|
|
|
END_ARGS
|
|
|
|
}
|
|
|
|
},
|
|
|
|
{ "BSSRemoved", WPAS_DBUS_NEW_IFACE_INTERFACE,
|
|
|
|
{
|
|
|
|
{ "path", "o", ARG_OUT },
|
|
|
|
END_ARGS
|
|
|
|
}
|
|
|
|
},
|
|
|
|
{ "BlobAdded", WPAS_DBUS_NEW_IFACE_INTERFACE,
|
|
|
|
{
|
|
|
|
{ "name", "s", ARG_OUT },
|
|
|
|
END_ARGS
|
|
|
|
}
|
|
|
|
},
|
|
|
|
{ "BlobRemoved", WPAS_DBUS_NEW_IFACE_INTERFACE,
|
|
|
|
{
|
|
|
|
{ "name", "s", ARG_OUT },
|
|
|
|
END_ARGS
|
|
|
|
}
|
|
|
|
},
|
|
|
|
{ "NetworkAdded", WPAS_DBUS_NEW_IFACE_INTERFACE,
|
|
|
|
{
|
|
|
|
{ "path", "o", ARG_OUT },
|
2010-01-01 11:47:59 +01:00
|
|
|
{ "properties", "a{sv}", ARG_OUT },
|
2009-11-14 17:18:07 +01:00
|
|
|
END_ARGS
|
|
|
|
}
|
|
|
|
},
|
|
|
|
{ "NetworkRemoved", WPAS_DBUS_NEW_IFACE_INTERFACE,
|
|
|
|
{
|
|
|
|
{ "path", "o", ARG_OUT },
|
|
|
|
END_ARGS
|
|
|
|
}
|
|
|
|
},
|
|
|
|
{ "NetworkSelected", WPAS_DBUS_NEW_IFACE_INTERFACE,
|
|
|
|
{
|
|
|
|
{ "path", "o", ARG_OUT },
|
|
|
|
END_ARGS
|
|
|
|
}
|
|
|
|
},
|
|
|
|
{ "PropertiesChanged", WPAS_DBUS_NEW_IFACE_INTERFACE,
|
|
|
|
{
|
|
|
|
{ "properties", "a{sv}", ARG_OUT },
|
|
|
|
END_ARGS
|
|
|
|
}
|
|
|
|
},
|
|
|
|
#ifdef CONFIG_WPS
|
|
|
|
{ "Event", WPAS_DBUS_NEW_IFACE_WPS,
|
|
|
|
{
|
|
|
|
{ "name", "s", ARG_OUT },
|
|
|
|
{ "args", "a{sv}", ARG_OUT },
|
|
|
|
END_ARGS
|
|
|
|
}
|
|
|
|
},
|
|
|
|
{ "Credentials", WPAS_DBUS_NEW_IFACE_WPS,
|
|
|
|
{
|
|
|
|
{ "credentials", "a{sv}", ARG_OUT },
|
|
|
|
END_ARGS
|
|
|
|
}
|
|
|
|
},
|
|
|
|
{ "PropertiesChanged", WPAS_DBUS_NEW_IFACE_WPS,
|
|
|
|
{
|
|
|
|
{ "properties", "a{sv}", ARG_OUT },
|
|
|
|
END_ARGS
|
|
|
|
}
|
|
|
|
},
|
|
|
|
#endif /* CONFIG_WPS */
|
|
|
|
{ NULL, NULL, { END_ARGS } }
|
|
|
|
};
|
|
|
|
|
|
|
|
|
2010-01-01 17:45:29 +01:00
|
|
|
int wpas_dbus_register_interface(struct wpa_supplicant *wpa_s)
|
2009-11-09 22:51:59 +01:00
|
|
|
{
|
|
|
|
|
|
|
|
struct wpa_dbus_object_desc *obj_desc = NULL;
|
2009-12-30 23:15:56 +01:00
|
|
|
struct wpas_dbus_priv *ctrl_iface = wpa_s->global->dbus;
|
2009-11-09 22:51:59 +01:00
|
|
|
int next;
|
|
|
|
|
|
|
|
/* Do nothing if the control interface is not turned on */
|
|
|
|
if (ctrl_iface == NULL)
|
|
|
|
return 0;
|
|
|
|
|
|
|
|
/* Create and set the interface's object path */
|
2010-01-01 17:56:07 +01:00
|
|
|
wpa_s->dbus_new_path = os_zalloc(WPAS_DBUS_OBJECT_PATH_MAX);
|
|
|
|
if (wpa_s->dbus_new_path == NULL)
|
2009-11-09 22:51:59 +01:00
|
|
|
return -1;
|
2009-12-30 23:15:56 +01:00
|
|
|
next = ctrl_iface->next_objid++;
|
2010-01-01 17:56:07 +01:00
|
|
|
os_snprintf(wpa_s->dbus_new_path, WPAS_DBUS_OBJECT_PATH_MAX,
|
2009-11-09 22:51:59 +01:00
|
|
|
WPAS_DBUS_NEW_PATH_INTERFACES "/%u",
|
|
|
|
next);
|
|
|
|
|
|
|
|
obj_desc = os_zalloc(sizeof(struct wpa_dbus_object_desc));
|
|
|
|
if (!obj_desc) {
|
|
|
|
wpa_printf(MSG_ERROR, "Not enough memory "
|
|
|
|
"to create object description");
|
|
|
|
goto err;
|
|
|
|
}
|
|
|
|
|
2010-01-01 10:33:41 +01:00
|
|
|
wpas_dbus_register(obj_desc, wpa_s, NULL, wpas_dbus_interface_methods,
|
2009-11-14 17:18:07 +01:00
|
|
|
wpas_dbus_interface_properties,
|
|
|
|
wpas_dbus_interface_signals);
|
2009-11-09 22:51:59 +01:00
|
|
|
|
2010-01-01 17:56:07 +01:00
|
|
|
wpa_printf(MSG_DEBUG, "dbus: Register interface object '%s'",
|
|
|
|
wpa_s->dbus_new_path);
|
|
|
|
if (wpa_dbus_register_object_per_iface(ctrl_iface,
|
|
|
|
wpa_s->dbus_new_path,
|
|
|
|
wpa_s->ifname, obj_desc))
|
2009-11-09 22:51:59 +01:00
|
|
|
goto err;
|
|
|
|
|
2010-01-01 11:49:27 +01:00
|
|
|
wpas_dbus_signal_interface_added(wpa_s);
|
2009-11-09 22:51:59 +01:00
|
|
|
|
|
|
|
return 0;
|
|
|
|
|
|
|
|
err:
|
2010-01-01 17:56:07 +01:00
|
|
|
os_free(wpa_s->dbus_new_path);
|
|
|
|
wpa_s->dbus_new_path = NULL;
|
2010-01-03 00:01:56 +01:00
|
|
|
free_dbus_object_desc(obj_desc);
|
2009-11-09 22:51:59 +01:00
|
|
|
return -1;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2010-01-01 17:45:29 +01:00
|
|
|
int wpas_dbus_unregister_interface(struct wpa_supplicant *wpa_s)
|
2009-11-09 22:51:59 +01:00
|
|
|
{
|
2009-12-30 23:15:56 +01:00
|
|
|
struct wpas_dbus_priv *ctrl_iface;
|
2009-11-09 22:51:59 +01:00
|
|
|
|
|
|
|
/* Do nothing if the control interface is not turned on */
|
|
|
|
if (wpa_s == NULL || wpa_s->global == NULL)
|
|
|
|
return 0;
|
2009-12-30 23:15:56 +01:00
|
|
|
ctrl_iface = wpa_s->global->dbus;
|
2009-11-09 22:51:59 +01:00
|
|
|
if (ctrl_iface == NULL)
|
|
|
|
return 0;
|
|
|
|
|
2009-12-29 21:17:18 +01:00
|
|
|
wpa_printf(MSG_DEBUG, "dbus: Unregister interface object '%s'",
|
2010-01-01 18:12:31 +01:00
|
|
|
wpa_s->dbus_new_path);
|
2009-11-10 17:20:12 +01:00
|
|
|
if (wpa_dbus_unregister_object_per_iface(ctrl_iface,
|
2010-01-01 18:12:31 +01:00
|
|
|
wpa_s->dbus_new_path))
|
2009-11-09 22:51:59 +01:00
|
|
|
return -1;
|
|
|
|
|
|
|
|
wpas_dbus_signal_interface_removed(wpa_s);
|
|
|
|
|
|
|
|
os_free(wpa_s->dbus_new_path);
|
|
|
|
wpa_s->dbus_new_path = NULL;
|
|
|
|
|
|
|
|
return 0;
|
|
|
|
}
|