18d520ff1dc2da35cdca849e982051b86468016d8Dmitry Shmidt/*
28d520ff1dc2da35cdca849e982051b86468016d8Dmitry Shmidt * WPA Supplicant / dbus-based control interface
38d520ff1dc2da35cdca849e982051b86468016d8Dmitry Shmidt * Copyright (c) 2006, Dan Williams <dcbw@redhat.com> and Red Hat, Inc.
48d520ff1dc2da35cdca849e982051b86468016d8Dmitry Shmidt * Copyright (c) 2009-2010, Witold Sowa <witold.sowa@gmail.com>
58d520ff1dc2da35cdca849e982051b86468016d8Dmitry Shmidt * Copyright (c) 2009, Jouni Malinen <j@w1.fi>
68d520ff1dc2da35cdca849e982051b86468016d8Dmitry Shmidt *
704949598a23f501be6eec21697465fd46a28840aDmitry Shmidt * This software may be distributed under the terms of the BSD license.
804949598a23f501be6eec21697465fd46a28840aDmitry Shmidt * See README for more details.
98d520ff1dc2da35cdca849e982051b86468016d8Dmitry Shmidt */
108d520ff1dc2da35cdca849e982051b86468016d8Dmitry Shmidt
118d520ff1dc2da35cdca849e982051b86468016d8Dmitry Shmidt#include "includes.h"
128d520ff1dc2da35cdca849e982051b86468016d8Dmitry Shmidt
138d520ff1dc2da35cdca849e982051b86468016d8Dmitry Shmidt#include "common.h"
1475ecf5267604f166b85a7ee2cf0d9cb682966680Jouni Malinen#include "common/ieee802_11_defs.h"
158d520ff1dc2da35cdca849e982051b86468016d8Dmitry Shmidt#include "wps/wps.h"
168d520ff1dc2da35cdca849e982051b86468016d8Dmitry Shmidt#include "../config.h"
178d520ff1dc2da35cdca849e982051b86468016d8Dmitry Shmidt#include "../wpa_supplicant_i.h"
188d520ff1dc2da35cdca849e982051b86468016d8Dmitry Shmidt#include "../bss.h"
191f69aa52ea2e0a73ac502565df8c666ee49cab6aDmitry Shmidt#include "../wpas_glue.h"
208d520ff1dc2da35cdca849e982051b86468016d8Dmitry Shmidt#include "dbus_new_helpers.h"
218d520ff1dc2da35cdca849e982051b86468016d8Dmitry Shmidt#include "dbus_dict_helpers.h"
228d520ff1dc2da35cdca849e982051b86468016d8Dmitry Shmidt#include "dbus_new.h"
238d520ff1dc2da35cdca849e982051b86468016d8Dmitry Shmidt#include "dbus_new_handlers.h"
248d520ff1dc2da35cdca849e982051b86468016d8Dmitry Shmidt#include "dbus_common_i.h"
2575ecf5267604f166b85a7ee2cf0d9cb682966680Jouni Malinen#include "dbus_new_handlers_p2p.h"
2675ecf5267604f166b85a7ee2cf0d9cb682966680Jouni Malinen#include "p2p/p2p.h"
278d520ff1dc2da35cdca849e982051b86468016d8Dmitry Shmidt
2804949598a23f501be6eec21697465fd46a28840aDmitry Shmidt#ifdef CONFIG_AP /* until needed by something else */
2904949598a23f501be6eec21697465fd46a28840aDmitry Shmidt
3004949598a23f501be6eec21697465fd46a28840aDmitry Shmidt/*
3104949598a23f501be6eec21697465fd46a28840aDmitry Shmidt * NameOwnerChanged handling
3204949598a23f501be6eec21697465fd46a28840aDmitry Shmidt *
3304949598a23f501be6eec21697465fd46a28840aDmitry Shmidt * Some services we provide allow an application to register for
3404949598a23f501be6eec21697465fd46a28840aDmitry Shmidt * a signal that it needs. While it can also unregister, we must
3504949598a23f501be6eec21697465fd46a28840aDmitry Shmidt * be prepared for the case where the application simply crashes
3604949598a23f501be6eec21697465fd46a28840aDmitry Shmidt * and thus doesn't clean up properly. The way to handle this in
3704949598a23f501be6eec21697465fd46a28840aDmitry Shmidt * DBus is to register for the NameOwnerChanged signal which will
3804949598a23f501be6eec21697465fd46a28840aDmitry Shmidt * signal an owner change to NULL if the peer closes the socket
3904949598a23f501be6eec21697465fd46a28840aDmitry Shmidt * for whatever reason.
4004949598a23f501be6eec21697465fd46a28840aDmitry Shmidt *
4104949598a23f501be6eec21697465fd46a28840aDmitry Shmidt * Handle this signal via a filter function whenever necessary.
4204949598a23f501be6eec21697465fd46a28840aDmitry Shmidt * The code below also handles refcounting in case in the future
4304949598a23f501be6eec21697465fd46a28840aDmitry Shmidt * there will be multiple instances of this subscription scheme.
4404949598a23f501be6eec21697465fd46a28840aDmitry Shmidt */
4504949598a23f501be6eec21697465fd46a28840aDmitry Shmidtstatic const char wpas_dbus_noc_filter_str[] =
4604949598a23f501be6eec21697465fd46a28840aDmitry Shmidt	"interface=org.freedesktop.DBus,member=NameOwnerChanged";
4704949598a23f501be6eec21697465fd46a28840aDmitry Shmidt
4804949598a23f501be6eec21697465fd46a28840aDmitry Shmidt
4904949598a23f501be6eec21697465fd46a28840aDmitry Shmidtstatic DBusHandlerResult noc_filter(DBusConnection *conn,
5004949598a23f501be6eec21697465fd46a28840aDmitry Shmidt				    DBusMessage *message, void *data)
5104949598a23f501be6eec21697465fd46a28840aDmitry Shmidt{
5204949598a23f501be6eec21697465fd46a28840aDmitry Shmidt	struct wpas_dbus_priv *priv = data;
5304949598a23f501be6eec21697465fd46a28840aDmitry Shmidt
5404949598a23f501be6eec21697465fd46a28840aDmitry Shmidt	if (dbus_message_get_type(message) != DBUS_MESSAGE_TYPE_SIGNAL)
5504949598a23f501be6eec21697465fd46a28840aDmitry Shmidt		return DBUS_HANDLER_RESULT_NOT_YET_HANDLED;
5604949598a23f501be6eec21697465fd46a28840aDmitry Shmidt
5704949598a23f501be6eec21697465fd46a28840aDmitry Shmidt	if (dbus_message_is_signal(message, DBUS_INTERFACE_DBUS,
5804949598a23f501be6eec21697465fd46a28840aDmitry Shmidt				   "NameOwnerChanged")) {
5904949598a23f501be6eec21697465fd46a28840aDmitry Shmidt		const char *name;
6004949598a23f501be6eec21697465fd46a28840aDmitry Shmidt		const char *prev_owner;
6104949598a23f501be6eec21697465fd46a28840aDmitry Shmidt		const char *new_owner;
6204949598a23f501be6eec21697465fd46a28840aDmitry Shmidt		DBusError derr;
6304949598a23f501be6eec21697465fd46a28840aDmitry Shmidt		struct wpa_supplicant *wpa_s;
6404949598a23f501be6eec21697465fd46a28840aDmitry Shmidt
6504949598a23f501be6eec21697465fd46a28840aDmitry Shmidt		dbus_error_init(&derr);
6604949598a23f501be6eec21697465fd46a28840aDmitry Shmidt
6704949598a23f501be6eec21697465fd46a28840aDmitry Shmidt		if (!dbus_message_get_args(message, &derr,
6804949598a23f501be6eec21697465fd46a28840aDmitry Shmidt					   DBUS_TYPE_STRING, &name,
6904949598a23f501be6eec21697465fd46a28840aDmitry Shmidt					   DBUS_TYPE_STRING, &prev_owner,
7004949598a23f501be6eec21697465fd46a28840aDmitry Shmidt					   DBUS_TYPE_STRING, &new_owner,
7104949598a23f501be6eec21697465fd46a28840aDmitry Shmidt					   DBUS_TYPE_INVALID)) {
7204949598a23f501be6eec21697465fd46a28840aDmitry Shmidt			/* Ignore this error */
7304949598a23f501be6eec21697465fd46a28840aDmitry Shmidt			dbus_error_free(&derr);
7404949598a23f501be6eec21697465fd46a28840aDmitry Shmidt			return DBUS_HANDLER_RESULT_NOT_YET_HANDLED;
7504949598a23f501be6eec21697465fd46a28840aDmitry Shmidt		}
7604949598a23f501be6eec21697465fd46a28840aDmitry Shmidt
7704949598a23f501be6eec21697465fd46a28840aDmitry Shmidt		for (wpa_s = priv->global->ifaces; wpa_s; wpa_s = wpa_s->next)
7804949598a23f501be6eec21697465fd46a28840aDmitry Shmidt		{
7904949598a23f501be6eec21697465fd46a28840aDmitry Shmidt			if (wpa_s->preq_notify_peer != NULL &&
8004949598a23f501be6eec21697465fd46a28840aDmitry Shmidt			    os_strcmp(name, wpa_s->preq_notify_peer) == 0 &&
8104949598a23f501be6eec21697465fd46a28840aDmitry Shmidt			    (new_owner == NULL || os_strlen(new_owner) == 0)) {
8204949598a23f501be6eec21697465fd46a28840aDmitry Shmidt				/* probe request owner disconnected */
8304949598a23f501be6eec21697465fd46a28840aDmitry Shmidt				os_free(wpa_s->preq_notify_peer);
8404949598a23f501be6eec21697465fd46a28840aDmitry Shmidt				wpa_s->preq_notify_peer = NULL;
8504949598a23f501be6eec21697465fd46a28840aDmitry Shmidt				wpas_dbus_unsubscribe_noc(priv);
8604949598a23f501be6eec21697465fd46a28840aDmitry Shmidt			}
8704949598a23f501be6eec21697465fd46a28840aDmitry Shmidt		}
8804949598a23f501be6eec21697465fd46a28840aDmitry Shmidt	}
8904949598a23f501be6eec21697465fd46a28840aDmitry Shmidt
9004949598a23f501be6eec21697465fd46a28840aDmitry Shmidt	return DBUS_HANDLER_RESULT_NOT_YET_HANDLED;
9104949598a23f501be6eec21697465fd46a28840aDmitry Shmidt}
9204949598a23f501be6eec21697465fd46a28840aDmitry Shmidt
9304949598a23f501be6eec21697465fd46a28840aDmitry Shmidt
9404949598a23f501be6eec21697465fd46a28840aDmitry Shmidtvoid wpas_dbus_subscribe_noc(struct wpas_dbus_priv *priv)
9504949598a23f501be6eec21697465fd46a28840aDmitry Shmidt{
9604949598a23f501be6eec21697465fd46a28840aDmitry Shmidt	priv->dbus_noc_refcnt++;
9704949598a23f501be6eec21697465fd46a28840aDmitry Shmidt	if (priv->dbus_noc_refcnt > 1)
9804949598a23f501be6eec21697465fd46a28840aDmitry Shmidt		return;
9904949598a23f501be6eec21697465fd46a28840aDmitry Shmidt
10004949598a23f501be6eec21697465fd46a28840aDmitry Shmidt	if (!dbus_connection_add_filter(priv->con, noc_filter, priv, NULL)) {
10104949598a23f501be6eec21697465fd46a28840aDmitry Shmidt		wpa_printf(MSG_ERROR, "dbus: failed to add filter");
10204949598a23f501be6eec21697465fd46a28840aDmitry Shmidt		return;
10304949598a23f501be6eec21697465fd46a28840aDmitry Shmidt	}
10404949598a23f501be6eec21697465fd46a28840aDmitry Shmidt
10504949598a23f501be6eec21697465fd46a28840aDmitry Shmidt	dbus_bus_add_match(priv->con, wpas_dbus_noc_filter_str, NULL);
10604949598a23f501be6eec21697465fd46a28840aDmitry Shmidt}
10704949598a23f501be6eec21697465fd46a28840aDmitry Shmidt
10804949598a23f501be6eec21697465fd46a28840aDmitry Shmidt
10904949598a23f501be6eec21697465fd46a28840aDmitry Shmidtvoid wpas_dbus_unsubscribe_noc(struct wpas_dbus_priv *priv)
11004949598a23f501be6eec21697465fd46a28840aDmitry Shmidt{
11104949598a23f501be6eec21697465fd46a28840aDmitry Shmidt	priv->dbus_noc_refcnt--;
11204949598a23f501be6eec21697465fd46a28840aDmitry Shmidt	if (priv->dbus_noc_refcnt > 0)
11304949598a23f501be6eec21697465fd46a28840aDmitry Shmidt		return;
11404949598a23f501be6eec21697465fd46a28840aDmitry Shmidt
11504949598a23f501be6eec21697465fd46a28840aDmitry Shmidt	dbus_bus_remove_match(priv->con, wpas_dbus_noc_filter_str, NULL);
11604949598a23f501be6eec21697465fd46a28840aDmitry Shmidt	dbus_connection_remove_filter(priv->con, noc_filter, priv);
11704949598a23f501be6eec21697465fd46a28840aDmitry Shmidt}
11804949598a23f501be6eec21697465fd46a28840aDmitry Shmidt
11904949598a23f501be6eec21697465fd46a28840aDmitry Shmidt#endif /* CONFIG_AP */
12004949598a23f501be6eec21697465fd46a28840aDmitry Shmidt
1218d520ff1dc2da35cdca849e982051b86468016d8Dmitry Shmidt
1228d520ff1dc2da35cdca849e982051b86468016d8Dmitry Shmidt/**
1238d520ff1dc2da35cdca849e982051b86468016d8Dmitry Shmidt * wpas_dbus_signal_interface - Send a interface related event signal
1248d520ff1dc2da35cdca849e982051b86468016d8Dmitry Shmidt * @wpa_s: %wpa_supplicant network interface data
1258d520ff1dc2da35cdca849e982051b86468016d8Dmitry Shmidt * @sig_name: signal name - InterfaceAdded or InterfaceRemoved
1268d520ff1dc2da35cdca849e982051b86468016d8Dmitry Shmidt * @properties: Whether to add second argument with object properties
1278d520ff1dc2da35cdca849e982051b86468016d8Dmitry Shmidt *
1288d520ff1dc2da35cdca849e982051b86468016d8Dmitry Shmidt * Notify listeners about event related with interface
1298d520ff1dc2da35cdca849e982051b86468016d8Dmitry Shmidt */
1308d520ff1dc2da35cdca849e982051b86468016d8Dmitry Shmidtstatic void wpas_dbus_signal_interface(struct wpa_supplicant *wpa_s,
1318d520ff1dc2da35cdca849e982051b86468016d8Dmitry Shmidt				       const char *sig_name, int properties)
1328d520ff1dc2da35cdca849e982051b86468016d8Dmitry Shmidt{
1338d520ff1dc2da35cdca849e982051b86468016d8Dmitry Shmidt	struct wpas_dbus_priv *iface;
1348d520ff1dc2da35cdca849e982051b86468016d8Dmitry Shmidt	DBusMessage *msg;
1351f69aa52ea2e0a73ac502565df8c666ee49cab6aDmitry Shmidt	DBusMessageIter iter;
1368d520ff1dc2da35cdca849e982051b86468016d8Dmitry Shmidt
1378d520ff1dc2da35cdca849e982051b86468016d8Dmitry Shmidt	iface = wpa_s->global->dbus;
1388d520ff1dc2da35cdca849e982051b86468016d8Dmitry Shmidt
1398d520ff1dc2da35cdca849e982051b86468016d8Dmitry Shmidt	/* Do nothing if the control interface is not turned on */
1408d520ff1dc2da35cdca849e982051b86468016d8Dmitry Shmidt	if (iface == NULL)
1418d520ff1dc2da35cdca849e982051b86468016d8Dmitry Shmidt		return;
1428d520ff1dc2da35cdca849e982051b86468016d8Dmitry Shmidt
1438d520ff1dc2da35cdca849e982051b86468016d8Dmitry Shmidt	msg = dbus_message_new_signal(WPAS_DBUS_NEW_PATH,
1448d520ff1dc2da35cdca849e982051b86468016d8Dmitry Shmidt				      WPAS_DBUS_NEW_INTERFACE, sig_name);
1458d520ff1dc2da35cdca849e982051b86468016d8Dmitry Shmidt	if (msg == NULL)
1468d520ff1dc2da35cdca849e982051b86468016d8Dmitry Shmidt		return;
1478d520ff1dc2da35cdca849e982051b86468016d8Dmitry Shmidt
1488d520ff1dc2da35cdca849e982051b86468016d8Dmitry Shmidt	dbus_message_iter_init_append(msg, &iter);
1498d520ff1dc2da35cdca849e982051b86468016d8Dmitry Shmidt	if (!dbus_message_iter_append_basic(&iter, DBUS_TYPE_OBJECT_PATH,
1508d520ff1dc2da35cdca849e982051b86468016d8Dmitry Shmidt					    &wpa_s->dbus_new_path))
1518d520ff1dc2da35cdca849e982051b86468016d8Dmitry Shmidt		goto err;
1528d520ff1dc2da35cdca849e982051b86468016d8Dmitry Shmidt
1538d520ff1dc2da35cdca849e982051b86468016d8Dmitry Shmidt	if (properties) {
1541f69aa52ea2e0a73ac502565df8c666ee49cab6aDmitry Shmidt		if (!wpa_dbus_get_object_properties(
1551f69aa52ea2e0a73ac502565df8c666ee49cab6aDmitry Shmidt			    iface, wpa_s->dbus_new_path,
1561f69aa52ea2e0a73ac502565df8c666ee49cab6aDmitry Shmidt			    WPAS_DBUS_NEW_IFACE_INTERFACE, &iter))
1578d520ff1dc2da35cdca849e982051b86468016d8Dmitry Shmidt			goto err;
1588d520ff1dc2da35cdca849e982051b86468016d8Dmitry Shmidt	}
1598d520ff1dc2da35cdca849e982051b86468016d8Dmitry Shmidt
1608d520ff1dc2da35cdca849e982051b86468016d8Dmitry Shmidt	dbus_connection_send(iface->con, msg, NULL);
1618d520ff1dc2da35cdca849e982051b86468016d8Dmitry Shmidt	dbus_message_unref(msg);
1628d520ff1dc2da35cdca849e982051b86468016d8Dmitry Shmidt	return;
1638d520ff1dc2da35cdca849e982051b86468016d8Dmitry Shmidt
1648d520ff1dc2da35cdca849e982051b86468016d8Dmitry Shmidterr:
1658d520ff1dc2da35cdca849e982051b86468016d8Dmitry Shmidt	wpa_printf(MSG_ERROR, "dbus: Failed to construct signal");
1668d520ff1dc2da35cdca849e982051b86468016d8Dmitry Shmidt	dbus_message_unref(msg);
1678d520ff1dc2da35cdca849e982051b86468016d8Dmitry Shmidt}
1688d520ff1dc2da35cdca849e982051b86468016d8Dmitry Shmidt
1698d520ff1dc2da35cdca849e982051b86468016d8Dmitry Shmidt
1708d520ff1dc2da35cdca849e982051b86468016d8Dmitry Shmidt/**
1718d520ff1dc2da35cdca849e982051b86468016d8Dmitry Shmidt * wpas_dbus_signal_interface_added - Send a interface created signal
1728d520ff1dc2da35cdca849e982051b86468016d8Dmitry Shmidt * @wpa_s: %wpa_supplicant network interface data
1738d520ff1dc2da35cdca849e982051b86468016d8Dmitry Shmidt *
1748d520ff1dc2da35cdca849e982051b86468016d8Dmitry Shmidt * Notify listeners about creating new interface
1758d520ff1dc2da35cdca849e982051b86468016d8Dmitry Shmidt */
1768d520ff1dc2da35cdca849e982051b86468016d8Dmitry Shmidtstatic void wpas_dbus_signal_interface_added(struct wpa_supplicant *wpa_s)
1778d520ff1dc2da35cdca849e982051b86468016d8Dmitry Shmidt{
1788d520ff1dc2da35cdca849e982051b86468016d8Dmitry Shmidt	wpas_dbus_signal_interface(wpa_s, "InterfaceAdded", TRUE);
1798d520ff1dc2da35cdca849e982051b86468016d8Dmitry Shmidt}
1808d520ff1dc2da35cdca849e982051b86468016d8Dmitry Shmidt
1818d520ff1dc2da35cdca849e982051b86468016d8Dmitry Shmidt
1828d520ff1dc2da35cdca849e982051b86468016d8Dmitry Shmidt/**
1838d520ff1dc2da35cdca849e982051b86468016d8Dmitry Shmidt * wpas_dbus_signal_interface_removed - Send a interface removed signal
1848d520ff1dc2da35cdca849e982051b86468016d8Dmitry Shmidt * @wpa_s: %wpa_supplicant network interface data
1858d520ff1dc2da35cdca849e982051b86468016d8Dmitry Shmidt *
1868d520ff1dc2da35cdca849e982051b86468016d8Dmitry Shmidt * Notify listeners about removing interface
1878d520ff1dc2da35cdca849e982051b86468016d8Dmitry Shmidt */
1888d520ff1dc2da35cdca849e982051b86468016d8Dmitry Shmidtstatic void wpas_dbus_signal_interface_removed(struct wpa_supplicant *wpa_s)
1898d520ff1dc2da35cdca849e982051b86468016d8Dmitry Shmidt{
1908d520ff1dc2da35cdca849e982051b86468016d8Dmitry Shmidt	wpas_dbus_signal_interface(wpa_s, "InterfaceRemoved", FALSE);
1918d520ff1dc2da35cdca849e982051b86468016d8Dmitry Shmidt
1928d520ff1dc2da35cdca849e982051b86468016d8Dmitry Shmidt}
1938d520ff1dc2da35cdca849e982051b86468016d8Dmitry Shmidt
1948d520ff1dc2da35cdca849e982051b86468016d8Dmitry Shmidt
1958d520ff1dc2da35cdca849e982051b86468016d8Dmitry Shmidt/**
1968d520ff1dc2da35cdca849e982051b86468016d8Dmitry Shmidt * wpas_dbus_signal_scan_done - send scan done signal
1978d520ff1dc2da35cdca849e982051b86468016d8Dmitry Shmidt * @wpa_s: %wpa_supplicant network interface data
1988d520ff1dc2da35cdca849e982051b86468016d8Dmitry Shmidt * @success: indicates if scanning succeed or failed
1998d520ff1dc2da35cdca849e982051b86468016d8Dmitry Shmidt *
2008d520ff1dc2da35cdca849e982051b86468016d8Dmitry Shmidt * Notify listeners about finishing a scan
2018d520ff1dc2da35cdca849e982051b86468016d8Dmitry Shmidt */
2028d520ff1dc2da35cdca849e982051b86468016d8Dmitry Shmidtvoid wpas_dbus_signal_scan_done(struct wpa_supplicant *wpa_s, int success)
2038d520ff1dc2da35cdca849e982051b86468016d8Dmitry Shmidt{
2048d520ff1dc2da35cdca849e982051b86468016d8Dmitry Shmidt	struct wpas_dbus_priv *iface;
2058d520ff1dc2da35cdca849e982051b86468016d8Dmitry Shmidt	DBusMessage *msg;
2068d520ff1dc2da35cdca849e982051b86468016d8Dmitry Shmidt	dbus_bool_t succ;
2078d520ff1dc2da35cdca849e982051b86468016d8Dmitry Shmidt
2088d520ff1dc2da35cdca849e982051b86468016d8Dmitry Shmidt	iface = wpa_s->global->dbus;
2098d520ff1dc2da35cdca849e982051b86468016d8Dmitry Shmidt
2108d520ff1dc2da35cdca849e982051b86468016d8Dmitry Shmidt	/* Do nothing if the control interface is not turned on */
2118d520ff1dc2da35cdca849e982051b86468016d8Dmitry Shmidt	if (iface == NULL)
2128d520ff1dc2da35cdca849e982051b86468016d8Dmitry Shmidt		return;
2138d520ff1dc2da35cdca849e982051b86468016d8Dmitry Shmidt
2148d520ff1dc2da35cdca849e982051b86468016d8Dmitry Shmidt	msg = dbus_message_new_signal(wpa_s->dbus_new_path,
2158d520ff1dc2da35cdca849e982051b86468016d8Dmitry Shmidt				      WPAS_DBUS_NEW_IFACE_INTERFACE,
2168d520ff1dc2da35cdca849e982051b86468016d8Dmitry Shmidt				      "ScanDone");
2178d520ff1dc2da35cdca849e982051b86468016d8Dmitry Shmidt	if (msg == NULL)
2188d520ff1dc2da35cdca849e982051b86468016d8Dmitry Shmidt		return;
2198d520ff1dc2da35cdca849e982051b86468016d8Dmitry Shmidt
2208d520ff1dc2da35cdca849e982051b86468016d8Dmitry Shmidt	succ = success ? TRUE : FALSE;
2218d520ff1dc2da35cdca849e982051b86468016d8Dmitry Shmidt	if (dbus_message_append_args(msg, DBUS_TYPE_BOOLEAN, &succ,
2228d520ff1dc2da35cdca849e982051b86468016d8Dmitry Shmidt				     DBUS_TYPE_INVALID))
2238d520ff1dc2da35cdca849e982051b86468016d8Dmitry Shmidt		dbus_connection_send(iface->con, msg, NULL);
2248d520ff1dc2da35cdca849e982051b86468016d8Dmitry Shmidt	else
2258d520ff1dc2da35cdca849e982051b86468016d8Dmitry Shmidt		wpa_printf(MSG_ERROR, "dbus: Failed to construct signal");
2268d520ff1dc2da35cdca849e982051b86468016d8Dmitry Shmidt	dbus_message_unref(msg);
2278d520ff1dc2da35cdca849e982051b86468016d8Dmitry Shmidt}
2288d520ff1dc2da35cdca849e982051b86468016d8Dmitry Shmidt
2298d520ff1dc2da35cdca849e982051b86468016d8Dmitry Shmidt
2308d520ff1dc2da35cdca849e982051b86468016d8Dmitry Shmidt/**
2318d520ff1dc2da35cdca849e982051b86468016d8Dmitry Shmidt * wpas_dbus_signal_blob - Send a BSS related event signal
2328d520ff1dc2da35cdca849e982051b86468016d8Dmitry Shmidt * @wpa_s: %wpa_supplicant network interface data
2338d520ff1dc2da35cdca849e982051b86468016d8Dmitry Shmidt * @bss_obj_path: BSS object path
2348d520ff1dc2da35cdca849e982051b86468016d8Dmitry Shmidt * @sig_name: signal name - BSSAdded or BSSRemoved
2358d520ff1dc2da35cdca849e982051b86468016d8Dmitry Shmidt * @properties: Whether to add second argument with object properties
2368d520ff1dc2da35cdca849e982051b86468016d8Dmitry Shmidt *
2378d520ff1dc2da35cdca849e982051b86468016d8Dmitry Shmidt * Notify listeners about event related with BSS
2388d520ff1dc2da35cdca849e982051b86468016d8Dmitry Shmidt */
2398d520ff1dc2da35cdca849e982051b86468016d8Dmitry Shmidtstatic void wpas_dbus_signal_bss(struct wpa_supplicant *wpa_s,
2408d520ff1dc2da35cdca849e982051b86468016d8Dmitry Shmidt				 const char *bss_obj_path,
2418d520ff1dc2da35cdca849e982051b86468016d8Dmitry Shmidt				 const char *sig_name, int properties)
2428d520ff1dc2da35cdca849e982051b86468016d8Dmitry Shmidt{
2438d520ff1dc2da35cdca849e982051b86468016d8Dmitry Shmidt	struct wpas_dbus_priv *iface;
2448d520ff1dc2da35cdca849e982051b86468016d8Dmitry Shmidt	DBusMessage *msg;
2451f69aa52ea2e0a73ac502565df8c666ee49cab6aDmitry Shmidt	DBusMessageIter iter;
2468d520ff1dc2da35cdca849e982051b86468016d8Dmitry Shmidt
2478d520ff1dc2da35cdca849e982051b86468016d8Dmitry Shmidt	iface = wpa_s->global->dbus;
2488d520ff1dc2da35cdca849e982051b86468016d8Dmitry Shmidt
2498d520ff1dc2da35cdca849e982051b86468016d8Dmitry Shmidt	/* Do nothing if the control interface is not turned on */
2508d520ff1dc2da35cdca849e982051b86468016d8Dmitry Shmidt	if (iface == NULL)
2518d520ff1dc2da35cdca849e982051b86468016d8Dmitry Shmidt		return;
2528d520ff1dc2da35cdca849e982051b86468016d8Dmitry Shmidt
2538d520ff1dc2da35cdca849e982051b86468016d8Dmitry Shmidt	msg = dbus_message_new_signal(wpa_s->dbus_new_path,
2548d520ff1dc2da35cdca849e982051b86468016d8Dmitry Shmidt				      WPAS_DBUS_NEW_IFACE_INTERFACE,
2558d520ff1dc2da35cdca849e982051b86468016d8Dmitry Shmidt				      sig_name);
2568d520ff1dc2da35cdca849e982051b86468016d8Dmitry Shmidt	if (msg == NULL)
2578d520ff1dc2da35cdca849e982051b86468016d8Dmitry Shmidt		return;
2588d520ff1dc2da35cdca849e982051b86468016d8Dmitry Shmidt
2598d520ff1dc2da35cdca849e982051b86468016d8Dmitry Shmidt	dbus_message_iter_init_append(msg, &iter);
2608d520ff1dc2da35cdca849e982051b86468016d8Dmitry Shmidt	if (!dbus_message_iter_append_basic(&iter, DBUS_TYPE_OBJECT_PATH,
2618d520ff1dc2da35cdca849e982051b86468016d8Dmitry Shmidt					    &bss_obj_path))
2628d520ff1dc2da35cdca849e982051b86468016d8Dmitry Shmidt		goto err;
2638d520ff1dc2da35cdca849e982051b86468016d8Dmitry Shmidt
2648d520ff1dc2da35cdca849e982051b86468016d8Dmitry Shmidt	if (properties) {
2651f69aa52ea2e0a73ac502565df8c666ee49cab6aDmitry Shmidt		if (!wpa_dbus_get_object_properties(iface, bss_obj_path,
2661f69aa52ea2e0a73ac502565df8c666ee49cab6aDmitry Shmidt						    WPAS_DBUS_NEW_IFACE_BSS,
2671f69aa52ea2e0a73ac502565df8c666ee49cab6aDmitry Shmidt						    &iter))
2688d520ff1dc2da35cdca849e982051b86468016d8Dmitry Shmidt			goto err;
2698d520ff1dc2da35cdca849e982051b86468016d8Dmitry Shmidt	}
2708d520ff1dc2da35cdca849e982051b86468016d8Dmitry Shmidt
2718d520ff1dc2da35cdca849e982051b86468016d8Dmitry Shmidt	dbus_connection_send(iface->con, msg, NULL);
2728d520ff1dc2da35cdca849e982051b86468016d8Dmitry Shmidt	dbus_message_unref(msg);
2738d520ff1dc2da35cdca849e982051b86468016d8Dmitry Shmidt	return;
2748d520ff1dc2da35cdca849e982051b86468016d8Dmitry Shmidt
2758d520ff1dc2da35cdca849e982051b86468016d8Dmitry Shmidterr:
2768d520ff1dc2da35cdca849e982051b86468016d8Dmitry Shmidt	wpa_printf(MSG_ERROR, "dbus: Failed to construct signal");
2778d520ff1dc2da35cdca849e982051b86468016d8Dmitry Shmidt	dbus_message_unref(msg);
2788d520ff1dc2da35cdca849e982051b86468016d8Dmitry Shmidt}
2798d520ff1dc2da35cdca849e982051b86468016d8Dmitry Shmidt
2808d520ff1dc2da35cdca849e982051b86468016d8Dmitry Shmidt
2818d520ff1dc2da35cdca849e982051b86468016d8Dmitry Shmidt/**
2828d520ff1dc2da35cdca849e982051b86468016d8Dmitry Shmidt * wpas_dbus_signal_bss_added - Send a BSS added signal
2838d520ff1dc2da35cdca849e982051b86468016d8Dmitry Shmidt * @wpa_s: %wpa_supplicant network interface data
2848d520ff1dc2da35cdca849e982051b86468016d8Dmitry Shmidt * @bss_obj_path: new BSS object path
2858d520ff1dc2da35cdca849e982051b86468016d8Dmitry Shmidt *
2868d520ff1dc2da35cdca849e982051b86468016d8Dmitry Shmidt * Notify listeners about adding new BSS
2878d520ff1dc2da35cdca849e982051b86468016d8Dmitry Shmidt */
2888d520ff1dc2da35cdca849e982051b86468016d8Dmitry Shmidtstatic void wpas_dbus_signal_bss_added(struct wpa_supplicant *wpa_s,
2898d520ff1dc2da35cdca849e982051b86468016d8Dmitry Shmidt				       const char *bss_obj_path)
2908d520ff1dc2da35cdca849e982051b86468016d8Dmitry Shmidt{
2918d520ff1dc2da35cdca849e982051b86468016d8Dmitry Shmidt	wpas_dbus_signal_bss(wpa_s, bss_obj_path, "BSSAdded", TRUE);
2928d520ff1dc2da35cdca849e982051b86468016d8Dmitry Shmidt}
2938d520ff1dc2da35cdca849e982051b86468016d8Dmitry Shmidt
2948d520ff1dc2da35cdca849e982051b86468016d8Dmitry Shmidt
2958d520ff1dc2da35cdca849e982051b86468016d8Dmitry Shmidt/**
2968d520ff1dc2da35cdca849e982051b86468016d8Dmitry Shmidt * wpas_dbus_signal_bss_removed - Send a BSS removed signal
2978d520ff1dc2da35cdca849e982051b86468016d8Dmitry Shmidt * @wpa_s: %wpa_supplicant network interface data
2988d520ff1dc2da35cdca849e982051b86468016d8Dmitry Shmidt * @bss_obj_path: BSS object path
2998d520ff1dc2da35cdca849e982051b86468016d8Dmitry Shmidt *
3008d520ff1dc2da35cdca849e982051b86468016d8Dmitry Shmidt * Notify listeners about removing BSS
3018d520ff1dc2da35cdca849e982051b86468016d8Dmitry Shmidt */
3028d520ff1dc2da35cdca849e982051b86468016d8Dmitry Shmidtstatic void wpas_dbus_signal_bss_removed(struct wpa_supplicant *wpa_s,
3038d520ff1dc2da35cdca849e982051b86468016d8Dmitry Shmidt					 const char *bss_obj_path)
3048d520ff1dc2da35cdca849e982051b86468016d8Dmitry Shmidt{
3058d520ff1dc2da35cdca849e982051b86468016d8Dmitry Shmidt	wpas_dbus_signal_bss(wpa_s, bss_obj_path, "BSSRemoved", FALSE);
3068d520ff1dc2da35cdca849e982051b86468016d8Dmitry Shmidt}
3078d520ff1dc2da35cdca849e982051b86468016d8Dmitry Shmidt
3088d520ff1dc2da35cdca849e982051b86468016d8Dmitry Shmidt
3098d520ff1dc2da35cdca849e982051b86468016d8Dmitry Shmidt/**
3108d520ff1dc2da35cdca849e982051b86468016d8Dmitry Shmidt * wpas_dbus_signal_blob - Send a blob related event signal
3118d520ff1dc2da35cdca849e982051b86468016d8Dmitry Shmidt * @wpa_s: %wpa_supplicant network interface data
3128d520ff1dc2da35cdca849e982051b86468016d8Dmitry Shmidt * @name: blob name
3138d520ff1dc2da35cdca849e982051b86468016d8Dmitry Shmidt * @sig_name: signal name - BlobAdded or BlobRemoved
3148d520ff1dc2da35cdca849e982051b86468016d8Dmitry Shmidt *
3158d520ff1dc2da35cdca849e982051b86468016d8Dmitry Shmidt * Notify listeners about event related with blob
3168d520ff1dc2da35cdca849e982051b86468016d8Dmitry Shmidt */
3178d520ff1dc2da35cdca849e982051b86468016d8Dmitry Shmidtstatic void wpas_dbus_signal_blob(struct wpa_supplicant *wpa_s,
3188d520ff1dc2da35cdca849e982051b86468016d8Dmitry Shmidt				  const char *name, const char *sig_name)
3198d520ff1dc2da35cdca849e982051b86468016d8Dmitry Shmidt{
3208d520ff1dc2da35cdca849e982051b86468016d8Dmitry Shmidt	struct wpas_dbus_priv *iface;
3218d520ff1dc2da35cdca849e982051b86468016d8Dmitry Shmidt	DBusMessage *msg;
3228d520ff1dc2da35cdca849e982051b86468016d8Dmitry Shmidt
3238d520ff1dc2da35cdca849e982051b86468016d8Dmitry Shmidt	iface = wpa_s->global->dbus;
3248d520ff1dc2da35cdca849e982051b86468016d8Dmitry Shmidt
3258d520ff1dc2da35cdca849e982051b86468016d8Dmitry Shmidt	/* Do nothing if the control interface is not turned on */
3268d520ff1dc2da35cdca849e982051b86468016d8Dmitry Shmidt	if (iface == NULL)
3278d520ff1dc2da35cdca849e982051b86468016d8Dmitry Shmidt		return;
3288d520ff1dc2da35cdca849e982051b86468016d8Dmitry Shmidt
3298d520ff1dc2da35cdca849e982051b86468016d8Dmitry Shmidt	msg = dbus_message_new_signal(wpa_s->dbus_new_path,
3308d520ff1dc2da35cdca849e982051b86468016d8Dmitry Shmidt				      WPAS_DBUS_NEW_IFACE_INTERFACE,
3318d520ff1dc2da35cdca849e982051b86468016d8Dmitry Shmidt				      sig_name);
3328d520ff1dc2da35cdca849e982051b86468016d8Dmitry Shmidt	if (msg == NULL)
3338d520ff1dc2da35cdca849e982051b86468016d8Dmitry Shmidt		return;
3348d520ff1dc2da35cdca849e982051b86468016d8Dmitry Shmidt
3358d520ff1dc2da35cdca849e982051b86468016d8Dmitry Shmidt	if (dbus_message_append_args(msg, DBUS_TYPE_STRING, &name,
3368d520ff1dc2da35cdca849e982051b86468016d8Dmitry Shmidt				     DBUS_TYPE_INVALID))
3378d520ff1dc2da35cdca849e982051b86468016d8Dmitry Shmidt		dbus_connection_send(iface->con, msg, NULL);
3388d520ff1dc2da35cdca849e982051b86468016d8Dmitry Shmidt	else
3398d520ff1dc2da35cdca849e982051b86468016d8Dmitry Shmidt		wpa_printf(MSG_ERROR, "dbus: Failed to construct signal");
3408d520ff1dc2da35cdca849e982051b86468016d8Dmitry Shmidt	dbus_message_unref(msg);
3418d520ff1dc2da35cdca849e982051b86468016d8Dmitry Shmidt}
3428d520ff1dc2da35cdca849e982051b86468016d8Dmitry Shmidt
3438d520ff1dc2da35cdca849e982051b86468016d8Dmitry Shmidt
3448d520ff1dc2da35cdca849e982051b86468016d8Dmitry Shmidt/**
3458d520ff1dc2da35cdca849e982051b86468016d8Dmitry Shmidt * wpas_dbus_signal_blob_added - Send a blob added signal
3468d520ff1dc2da35cdca849e982051b86468016d8Dmitry Shmidt * @wpa_s: %wpa_supplicant network interface data
3478d520ff1dc2da35cdca849e982051b86468016d8Dmitry Shmidt * @name: blob name
3488d520ff1dc2da35cdca849e982051b86468016d8Dmitry Shmidt *
3498d520ff1dc2da35cdca849e982051b86468016d8Dmitry Shmidt * Notify listeners about adding a new blob
3508d520ff1dc2da35cdca849e982051b86468016d8Dmitry Shmidt */
3518d520ff1dc2da35cdca849e982051b86468016d8Dmitry Shmidtvoid wpas_dbus_signal_blob_added(struct wpa_supplicant *wpa_s,
3528d520ff1dc2da35cdca849e982051b86468016d8Dmitry Shmidt				 const char *name)
3538d520ff1dc2da35cdca849e982051b86468016d8Dmitry Shmidt{
3548d520ff1dc2da35cdca849e982051b86468016d8Dmitry Shmidt	wpas_dbus_signal_blob(wpa_s, name, "BlobAdded");
3558d520ff1dc2da35cdca849e982051b86468016d8Dmitry Shmidt}
3568d520ff1dc2da35cdca849e982051b86468016d8Dmitry Shmidt
3578d520ff1dc2da35cdca849e982051b86468016d8Dmitry Shmidt
3588d520ff1dc2da35cdca849e982051b86468016d8Dmitry Shmidt/**
3598d520ff1dc2da35cdca849e982051b86468016d8Dmitry Shmidt * wpas_dbus_signal_blob_removed - Send a blob removed signal
3608d520ff1dc2da35cdca849e982051b86468016d8Dmitry Shmidt * @wpa_s: %wpa_supplicant network interface data
3618d520ff1dc2da35cdca849e982051b86468016d8Dmitry Shmidt * @name: blob name
3628d520ff1dc2da35cdca849e982051b86468016d8Dmitry Shmidt *
3638d520ff1dc2da35cdca849e982051b86468016d8Dmitry Shmidt * Notify listeners about removing blob
3648d520ff1dc2da35cdca849e982051b86468016d8Dmitry Shmidt */
3658d520ff1dc2da35cdca849e982051b86468016d8Dmitry Shmidtvoid wpas_dbus_signal_blob_removed(struct wpa_supplicant *wpa_s,
3668d520ff1dc2da35cdca849e982051b86468016d8Dmitry Shmidt				   const char *name)
3678d520ff1dc2da35cdca849e982051b86468016d8Dmitry Shmidt{
3688d520ff1dc2da35cdca849e982051b86468016d8Dmitry Shmidt	wpas_dbus_signal_blob(wpa_s, name, "BlobRemoved");
3698d520ff1dc2da35cdca849e982051b86468016d8Dmitry Shmidt}
3708d520ff1dc2da35cdca849e982051b86468016d8Dmitry Shmidt
3718d520ff1dc2da35cdca849e982051b86468016d8Dmitry Shmidt
3728d520ff1dc2da35cdca849e982051b86468016d8Dmitry Shmidt/**
3738d520ff1dc2da35cdca849e982051b86468016d8Dmitry Shmidt * wpas_dbus_signal_network - Send a network related event signal
3748d520ff1dc2da35cdca849e982051b86468016d8Dmitry Shmidt * @wpa_s: %wpa_supplicant network interface data
3758d520ff1dc2da35cdca849e982051b86468016d8Dmitry Shmidt * @id: new network id
3768d520ff1dc2da35cdca849e982051b86468016d8Dmitry Shmidt * @sig_name: signal name - NetworkAdded, NetworkRemoved or NetworkSelected
3778d520ff1dc2da35cdca849e982051b86468016d8Dmitry Shmidt * @properties: determines if add second argument with object properties
3788d520ff1dc2da35cdca849e982051b86468016d8Dmitry Shmidt *
3798d520ff1dc2da35cdca849e982051b86468016d8Dmitry Shmidt * Notify listeners about event related with configured network
3808d520ff1dc2da35cdca849e982051b86468016d8Dmitry Shmidt */
3818d520ff1dc2da35cdca849e982051b86468016d8Dmitry Shmidtstatic void wpas_dbus_signal_network(struct wpa_supplicant *wpa_s,
3828d520ff1dc2da35cdca849e982051b86468016d8Dmitry Shmidt				     int id, const char *sig_name,
3838d520ff1dc2da35cdca849e982051b86468016d8Dmitry Shmidt				     int properties)
3848d520ff1dc2da35cdca849e982051b86468016d8Dmitry Shmidt{
3858d520ff1dc2da35cdca849e982051b86468016d8Dmitry Shmidt	struct wpas_dbus_priv *iface;
3868d520ff1dc2da35cdca849e982051b86468016d8Dmitry Shmidt	DBusMessage *msg;
3871f69aa52ea2e0a73ac502565df8c666ee49cab6aDmitry Shmidt	DBusMessageIter iter;
3888d520ff1dc2da35cdca849e982051b86468016d8Dmitry Shmidt	char net_obj_path[WPAS_DBUS_OBJECT_PATH_MAX], *path;
3898d520ff1dc2da35cdca849e982051b86468016d8Dmitry Shmidt
3908d520ff1dc2da35cdca849e982051b86468016d8Dmitry Shmidt	iface = wpa_s->global->dbus;
3918d520ff1dc2da35cdca849e982051b86468016d8Dmitry Shmidt
3928d520ff1dc2da35cdca849e982051b86468016d8Dmitry Shmidt	/* Do nothing if the control interface is not turned on */
3938d520ff1dc2da35cdca849e982051b86468016d8Dmitry Shmidt	if (iface == NULL)
3948d520ff1dc2da35cdca849e982051b86468016d8Dmitry Shmidt		return;
3958d520ff1dc2da35cdca849e982051b86468016d8Dmitry Shmidt
3968d520ff1dc2da35cdca849e982051b86468016d8Dmitry Shmidt	os_snprintf(net_obj_path, WPAS_DBUS_OBJECT_PATH_MAX,
3978d520ff1dc2da35cdca849e982051b86468016d8Dmitry Shmidt		    "%s/" WPAS_DBUS_NEW_NETWORKS_PART "/%u",
3988d520ff1dc2da35cdca849e982051b86468016d8Dmitry Shmidt		    wpa_s->dbus_new_path, id);
3998d520ff1dc2da35cdca849e982051b86468016d8Dmitry Shmidt
4008d520ff1dc2da35cdca849e982051b86468016d8Dmitry Shmidt	msg = dbus_message_new_signal(wpa_s->dbus_new_path,
4018d520ff1dc2da35cdca849e982051b86468016d8Dmitry Shmidt				      WPAS_DBUS_NEW_IFACE_INTERFACE,
4028d520ff1dc2da35cdca849e982051b86468016d8Dmitry Shmidt				      sig_name);
4038d520ff1dc2da35cdca849e982051b86468016d8Dmitry Shmidt	if (msg == NULL)
4048d520ff1dc2da35cdca849e982051b86468016d8Dmitry Shmidt		return;
4058d520ff1dc2da35cdca849e982051b86468016d8Dmitry Shmidt
4068d520ff1dc2da35cdca849e982051b86468016d8Dmitry Shmidt	dbus_message_iter_init_append(msg, &iter);
4078d520ff1dc2da35cdca849e982051b86468016d8Dmitry Shmidt	path = net_obj_path;
4088d520ff1dc2da35cdca849e982051b86468016d8Dmitry Shmidt	if (!dbus_message_iter_append_basic(&iter, DBUS_TYPE_OBJECT_PATH,
4098d520ff1dc2da35cdca849e982051b86468016d8Dmitry Shmidt					    &path))
4108d520ff1dc2da35cdca849e982051b86468016d8Dmitry Shmidt		goto err;
4118d520ff1dc2da35cdca849e982051b86468016d8Dmitry Shmidt
4128d520ff1dc2da35cdca849e982051b86468016d8Dmitry Shmidt	if (properties) {
4131f69aa52ea2e0a73ac502565df8c666ee49cab6aDmitry Shmidt		if (!wpa_dbus_get_object_properties(
4141f69aa52ea2e0a73ac502565df8c666ee49cab6aDmitry Shmidt			    iface, net_obj_path, WPAS_DBUS_NEW_IFACE_NETWORK,
4151f69aa52ea2e0a73ac502565df8c666ee49cab6aDmitry Shmidt			    &iter))
4168d520ff1dc2da35cdca849e982051b86468016d8Dmitry Shmidt			goto err;
4178d520ff1dc2da35cdca849e982051b86468016d8Dmitry Shmidt	}
4188d520ff1dc2da35cdca849e982051b86468016d8Dmitry Shmidt
4198d520ff1dc2da35cdca849e982051b86468016d8Dmitry Shmidt	dbus_connection_send(iface->con, msg, NULL);
4208d520ff1dc2da35cdca849e982051b86468016d8Dmitry Shmidt
4218d520ff1dc2da35cdca849e982051b86468016d8Dmitry Shmidt	dbus_message_unref(msg);
4228d520ff1dc2da35cdca849e982051b86468016d8Dmitry Shmidt	return;
4238d520ff1dc2da35cdca849e982051b86468016d8Dmitry Shmidt
4248d520ff1dc2da35cdca849e982051b86468016d8Dmitry Shmidterr:
4258d520ff1dc2da35cdca849e982051b86468016d8Dmitry Shmidt	wpa_printf(MSG_ERROR, "dbus: Failed to construct signal");
4268d520ff1dc2da35cdca849e982051b86468016d8Dmitry Shmidt	dbus_message_unref(msg);
4278d520ff1dc2da35cdca849e982051b86468016d8Dmitry Shmidt}
4288d520ff1dc2da35cdca849e982051b86468016d8Dmitry Shmidt
4298d520ff1dc2da35cdca849e982051b86468016d8Dmitry Shmidt
4308d520ff1dc2da35cdca849e982051b86468016d8Dmitry Shmidt/**
4318d520ff1dc2da35cdca849e982051b86468016d8Dmitry Shmidt * wpas_dbus_signal_network_added - Send a network added signal
4328d520ff1dc2da35cdca849e982051b86468016d8Dmitry Shmidt * @wpa_s: %wpa_supplicant network interface data
4338d520ff1dc2da35cdca849e982051b86468016d8Dmitry Shmidt * @id: new network id
4348d520ff1dc2da35cdca849e982051b86468016d8Dmitry Shmidt *
4358d520ff1dc2da35cdca849e982051b86468016d8Dmitry Shmidt * Notify listeners about adding new network
4368d520ff1dc2da35cdca849e982051b86468016d8Dmitry Shmidt */
4378d520ff1dc2da35cdca849e982051b86468016d8Dmitry Shmidtstatic void wpas_dbus_signal_network_added(struct wpa_supplicant *wpa_s,
4388d520ff1dc2da35cdca849e982051b86468016d8Dmitry Shmidt					   int id)
4398d520ff1dc2da35cdca849e982051b86468016d8Dmitry Shmidt{
4408d520ff1dc2da35cdca849e982051b86468016d8Dmitry Shmidt	wpas_dbus_signal_network(wpa_s, id, "NetworkAdded", TRUE);
4418d520ff1dc2da35cdca849e982051b86468016d8Dmitry Shmidt}
4428d520ff1dc2da35cdca849e982051b86468016d8Dmitry Shmidt
4438d520ff1dc2da35cdca849e982051b86468016d8Dmitry Shmidt
4448d520ff1dc2da35cdca849e982051b86468016d8Dmitry Shmidt/**
4458d520ff1dc2da35cdca849e982051b86468016d8Dmitry Shmidt * wpas_dbus_signal_network_removed - Send a network removed signal
4468d520ff1dc2da35cdca849e982051b86468016d8Dmitry Shmidt * @wpa_s: %wpa_supplicant network interface data
4478d520ff1dc2da35cdca849e982051b86468016d8Dmitry Shmidt * @id: network id
4488d520ff1dc2da35cdca849e982051b86468016d8Dmitry Shmidt *
4498d520ff1dc2da35cdca849e982051b86468016d8Dmitry Shmidt * Notify listeners about removing a network
4508d520ff1dc2da35cdca849e982051b86468016d8Dmitry Shmidt */
4518d520ff1dc2da35cdca849e982051b86468016d8Dmitry Shmidtstatic void wpas_dbus_signal_network_removed(struct wpa_supplicant *wpa_s,
4528d520ff1dc2da35cdca849e982051b86468016d8Dmitry Shmidt					     int id)
4538d520ff1dc2da35cdca849e982051b86468016d8Dmitry Shmidt{
4548d520ff1dc2da35cdca849e982051b86468016d8Dmitry Shmidt	wpas_dbus_signal_network(wpa_s, id, "NetworkRemoved", FALSE);
4558d520ff1dc2da35cdca849e982051b86468016d8Dmitry Shmidt}
4568d520ff1dc2da35cdca849e982051b86468016d8Dmitry Shmidt
4578d520ff1dc2da35cdca849e982051b86468016d8Dmitry Shmidt
4588d520ff1dc2da35cdca849e982051b86468016d8Dmitry Shmidt/**
4598d520ff1dc2da35cdca849e982051b86468016d8Dmitry Shmidt * wpas_dbus_signal_network_selected - Send a network selected signal
4608d520ff1dc2da35cdca849e982051b86468016d8Dmitry Shmidt * @wpa_s: %wpa_supplicant network interface data
4618d520ff1dc2da35cdca849e982051b86468016d8Dmitry Shmidt * @id: network id
4628d520ff1dc2da35cdca849e982051b86468016d8Dmitry Shmidt *
4638d520ff1dc2da35cdca849e982051b86468016d8Dmitry Shmidt * Notify listeners about selecting a network
4648d520ff1dc2da35cdca849e982051b86468016d8Dmitry Shmidt */
4658d520ff1dc2da35cdca849e982051b86468016d8Dmitry Shmidtvoid wpas_dbus_signal_network_selected(struct wpa_supplicant *wpa_s, int id)
4668d520ff1dc2da35cdca849e982051b86468016d8Dmitry Shmidt{
4678d520ff1dc2da35cdca849e982051b86468016d8Dmitry Shmidt	wpas_dbus_signal_network(wpa_s, id, "NetworkSelected", FALSE);
4688d520ff1dc2da35cdca849e982051b86468016d8Dmitry Shmidt}
4698d520ff1dc2da35cdca849e982051b86468016d8Dmitry Shmidt
4708d520ff1dc2da35cdca849e982051b86468016d8Dmitry Shmidt
4718d520ff1dc2da35cdca849e982051b86468016d8Dmitry Shmidt/**
4721f69aa52ea2e0a73ac502565df8c666ee49cab6aDmitry Shmidt * wpas_dbus_signal_network_request - Indicate that additional information
4731f69aa52ea2e0a73ac502565df8c666ee49cab6aDmitry Shmidt * (EAP password, etc.) is required to complete the association to this SSID
4741f69aa52ea2e0a73ac502565df8c666ee49cab6aDmitry Shmidt * @wpa_s: %wpa_supplicant network interface data
4751f69aa52ea2e0a73ac502565df8c666ee49cab6aDmitry Shmidt * @rtype: The specific additional information required
4761f69aa52ea2e0a73ac502565df8c666ee49cab6aDmitry Shmidt * @default_text: Optional description of required information
4771f69aa52ea2e0a73ac502565df8c666ee49cab6aDmitry Shmidt *
4781f69aa52ea2e0a73ac502565df8c666ee49cab6aDmitry Shmidt * Request additional information or passwords to complete an association
4791f69aa52ea2e0a73ac502565df8c666ee49cab6aDmitry Shmidt * request.
4801f69aa52ea2e0a73ac502565df8c666ee49cab6aDmitry Shmidt */
4811f69aa52ea2e0a73ac502565df8c666ee49cab6aDmitry Shmidtvoid wpas_dbus_signal_network_request(struct wpa_supplicant *wpa_s,
4821f69aa52ea2e0a73ac502565df8c666ee49cab6aDmitry Shmidt				      struct wpa_ssid *ssid,
4831f69aa52ea2e0a73ac502565df8c666ee49cab6aDmitry Shmidt				      enum wpa_ctrl_req_type rtype,
4841f69aa52ea2e0a73ac502565df8c666ee49cab6aDmitry Shmidt				      const char *default_txt)
4851f69aa52ea2e0a73ac502565df8c666ee49cab6aDmitry Shmidt{
4861f69aa52ea2e0a73ac502565df8c666ee49cab6aDmitry Shmidt	struct wpas_dbus_priv *iface;
4871f69aa52ea2e0a73ac502565df8c666ee49cab6aDmitry Shmidt	DBusMessage *msg;
4881f69aa52ea2e0a73ac502565df8c666ee49cab6aDmitry Shmidt	DBusMessageIter iter;
4891f69aa52ea2e0a73ac502565df8c666ee49cab6aDmitry Shmidt	char net_obj_path[WPAS_DBUS_OBJECT_PATH_MAX];
4901f69aa52ea2e0a73ac502565df8c666ee49cab6aDmitry Shmidt	const char *field, *txt = NULL, *net_ptr;
4911f69aa52ea2e0a73ac502565df8c666ee49cab6aDmitry Shmidt
4921f69aa52ea2e0a73ac502565df8c666ee49cab6aDmitry Shmidt	iface = wpa_s->global->dbus;
4931f69aa52ea2e0a73ac502565df8c666ee49cab6aDmitry Shmidt
4941f69aa52ea2e0a73ac502565df8c666ee49cab6aDmitry Shmidt	/* Do nothing if the control interface is not turned on */
4951f69aa52ea2e0a73ac502565df8c666ee49cab6aDmitry Shmidt	if (iface == NULL)
4961f69aa52ea2e0a73ac502565df8c666ee49cab6aDmitry Shmidt		return;
4971f69aa52ea2e0a73ac502565df8c666ee49cab6aDmitry Shmidt
4981f69aa52ea2e0a73ac502565df8c666ee49cab6aDmitry Shmidt	field = wpa_supplicant_ctrl_req_to_string(rtype, default_txt, &txt);
4991f69aa52ea2e0a73ac502565df8c666ee49cab6aDmitry Shmidt	if (field == NULL)
5001f69aa52ea2e0a73ac502565df8c666ee49cab6aDmitry Shmidt		return;
5011f69aa52ea2e0a73ac502565df8c666ee49cab6aDmitry Shmidt
5021f69aa52ea2e0a73ac502565df8c666ee49cab6aDmitry Shmidt	msg = dbus_message_new_signal(wpa_s->dbus_new_path,
5031f69aa52ea2e0a73ac502565df8c666ee49cab6aDmitry Shmidt				      WPAS_DBUS_NEW_IFACE_INTERFACE,
5041f69aa52ea2e0a73ac502565df8c666ee49cab6aDmitry Shmidt				      "NetworkRequest");
5051f69aa52ea2e0a73ac502565df8c666ee49cab6aDmitry Shmidt	if (msg == NULL)
5061f69aa52ea2e0a73ac502565df8c666ee49cab6aDmitry Shmidt		return;
5071f69aa52ea2e0a73ac502565df8c666ee49cab6aDmitry Shmidt
5081f69aa52ea2e0a73ac502565df8c666ee49cab6aDmitry Shmidt	os_snprintf(net_obj_path, WPAS_DBUS_OBJECT_PATH_MAX,
5091f69aa52ea2e0a73ac502565df8c666ee49cab6aDmitry Shmidt		    "%s/" WPAS_DBUS_NEW_NETWORKS_PART "/%u",
5101f69aa52ea2e0a73ac502565df8c666ee49cab6aDmitry Shmidt		    wpa_s->dbus_new_path, ssid->id);
5111f69aa52ea2e0a73ac502565df8c666ee49cab6aDmitry Shmidt	net_ptr = &net_obj_path[0];
5121f69aa52ea2e0a73ac502565df8c666ee49cab6aDmitry Shmidt
5131f69aa52ea2e0a73ac502565df8c666ee49cab6aDmitry Shmidt	dbus_message_iter_init_append(msg, &iter);
5141f69aa52ea2e0a73ac502565df8c666ee49cab6aDmitry Shmidt	if (!dbus_message_iter_append_basic(&iter, DBUS_TYPE_OBJECT_PATH,
5151f69aa52ea2e0a73ac502565df8c666ee49cab6aDmitry Shmidt					    &net_ptr))
5161f69aa52ea2e0a73ac502565df8c666ee49cab6aDmitry Shmidt		goto err;
5171f69aa52ea2e0a73ac502565df8c666ee49cab6aDmitry Shmidt	if (!dbus_message_iter_append_basic(&iter, DBUS_TYPE_STRING, &field))
5181f69aa52ea2e0a73ac502565df8c666ee49cab6aDmitry Shmidt		goto err;
5191f69aa52ea2e0a73ac502565df8c666ee49cab6aDmitry Shmidt	if (!dbus_message_iter_append_basic(&iter, DBUS_TYPE_STRING, &txt))
5201f69aa52ea2e0a73ac502565df8c666ee49cab6aDmitry Shmidt		goto err;
5211f69aa52ea2e0a73ac502565df8c666ee49cab6aDmitry Shmidt
5221f69aa52ea2e0a73ac502565df8c666ee49cab6aDmitry Shmidt	dbus_connection_send(iface->con, msg, NULL);
5231f69aa52ea2e0a73ac502565df8c666ee49cab6aDmitry Shmidt	dbus_message_unref(msg);
5241f69aa52ea2e0a73ac502565df8c666ee49cab6aDmitry Shmidt	return;
5251f69aa52ea2e0a73ac502565df8c666ee49cab6aDmitry Shmidt
5261f69aa52ea2e0a73ac502565df8c666ee49cab6aDmitry Shmidterr:
5271f69aa52ea2e0a73ac502565df8c666ee49cab6aDmitry Shmidt	wpa_printf(MSG_ERROR, "dbus: Failed to construct signal");
5281f69aa52ea2e0a73ac502565df8c666ee49cab6aDmitry Shmidt	dbus_message_unref(msg);
5291f69aa52ea2e0a73ac502565df8c666ee49cab6aDmitry Shmidt}
5301f69aa52ea2e0a73ac502565df8c666ee49cab6aDmitry Shmidt
5311f69aa52ea2e0a73ac502565df8c666ee49cab6aDmitry Shmidt
5321f69aa52ea2e0a73ac502565df8c666ee49cab6aDmitry Shmidt/**
5338d520ff1dc2da35cdca849e982051b86468016d8Dmitry Shmidt * wpas_dbus_signal_network_enabled_changed - Signals Enabled property changes
5348d520ff1dc2da35cdca849e982051b86468016d8Dmitry Shmidt * @wpa_s: %wpa_supplicant network interface data
5358d520ff1dc2da35cdca849e982051b86468016d8Dmitry Shmidt * @ssid: configured network which Enabled property has changed
5368d520ff1dc2da35cdca849e982051b86468016d8Dmitry Shmidt *
5378d520ff1dc2da35cdca849e982051b86468016d8Dmitry Shmidt * Sends PropertyChanged signals containing new value of Enabled property
5388d520ff1dc2da35cdca849e982051b86468016d8Dmitry Shmidt * for specified network
5398d520ff1dc2da35cdca849e982051b86468016d8Dmitry Shmidt */
5408d520ff1dc2da35cdca849e982051b86468016d8Dmitry Shmidtvoid wpas_dbus_signal_network_enabled_changed(struct wpa_supplicant *wpa_s,
5418d520ff1dc2da35cdca849e982051b86468016d8Dmitry Shmidt					      struct wpa_ssid *ssid)
5428d520ff1dc2da35cdca849e982051b86468016d8Dmitry Shmidt{
5438d520ff1dc2da35cdca849e982051b86468016d8Dmitry Shmidt
5448d520ff1dc2da35cdca849e982051b86468016d8Dmitry Shmidt	char path[WPAS_DBUS_OBJECT_PATH_MAX];
5458d520ff1dc2da35cdca849e982051b86468016d8Dmitry Shmidt	os_snprintf(path, WPAS_DBUS_OBJECT_PATH_MAX,
5468d520ff1dc2da35cdca849e982051b86468016d8Dmitry Shmidt		    "%s/" WPAS_DBUS_NEW_NETWORKS_PART "/%d",
5478d520ff1dc2da35cdca849e982051b86468016d8Dmitry Shmidt		    wpa_s->dbus_new_path, ssid->id);
5488d520ff1dc2da35cdca849e982051b86468016d8Dmitry Shmidt
5498d520ff1dc2da35cdca849e982051b86468016d8Dmitry Shmidt	wpa_dbus_mark_property_changed(wpa_s->global->dbus, path,
5508d520ff1dc2da35cdca849e982051b86468016d8Dmitry Shmidt				       WPAS_DBUS_NEW_IFACE_NETWORK, "Enabled");
5518d520ff1dc2da35cdca849e982051b86468016d8Dmitry Shmidt}
5528d520ff1dc2da35cdca849e982051b86468016d8Dmitry Shmidt
5538d520ff1dc2da35cdca849e982051b86468016d8Dmitry Shmidt
5548d520ff1dc2da35cdca849e982051b86468016d8Dmitry Shmidt#ifdef CONFIG_WPS
5558d520ff1dc2da35cdca849e982051b86468016d8Dmitry Shmidt
5568d520ff1dc2da35cdca849e982051b86468016d8Dmitry Shmidt/**
5578d520ff1dc2da35cdca849e982051b86468016d8Dmitry Shmidt * wpas_dbus_signal_wps_event_success - Signals Success WPS event
5588d520ff1dc2da35cdca849e982051b86468016d8Dmitry Shmidt * @wpa_s: %wpa_supplicant network interface data
5598d520ff1dc2da35cdca849e982051b86468016d8Dmitry Shmidt *
5608d520ff1dc2da35cdca849e982051b86468016d8Dmitry Shmidt * Sends Event dbus signal with name "success" and empty dict as arguments
5618d520ff1dc2da35cdca849e982051b86468016d8Dmitry Shmidt */
5628d520ff1dc2da35cdca849e982051b86468016d8Dmitry Shmidtvoid wpas_dbus_signal_wps_event_success(struct wpa_supplicant *wpa_s)
5638d520ff1dc2da35cdca849e982051b86468016d8Dmitry Shmidt{
5648d520ff1dc2da35cdca849e982051b86468016d8Dmitry Shmidt
5658d520ff1dc2da35cdca849e982051b86468016d8Dmitry Shmidt	DBusMessage *msg;
5668d520ff1dc2da35cdca849e982051b86468016d8Dmitry Shmidt	DBusMessageIter iter, dict_iter;
5678d520ff1dc2da35cdca849e982051b86468016d8Dmitry Shmidt	struct wpas_dbus_priv *iface;
5688d520ff1dc2da35cdca849e982051b86468016d8Dmitry Shmidt	char *key = "success";
5698d520ff1dc2da35cdca849e982051b86468016d8Dmitry Shmidt
5708d520ff1dc2da35cdca849e982051b86468016d8Dmitry Shmidt	iface = wpa_s->global->dbus;
5718d520ff1dc2da35cdca849e982051b86468016d8Dmitry Shmidt
5728d520ff1dc2da35cdca849e982051b86468016d8Dmitry Shmidt	/* Do nothing if the control interface is not turned on */
5738d520ff1dc2da35cdca849e982051b86468016d8Dmitry Shmidt	if (iface == NULL)
5748d520ff1dc2da35cdca849e982051b86468016d8Dmitry Shmidt		return;
5758d520ff1dc2da35cdca849e982051b86468016d8Dmitry Shmidt
5768d520ff1dc2da35cdca849e982051b86468016d8Dmitry Shmidt	msg = dbus_message_new_signal(wpa_s->dbus_new_path,
5778d520ff1dc2da35cdca849e982051b86468016d8Dmitry Shmidt				      WPAS_DBUS_NEW_IFACE_WPS, "Event");
5788d520ff1dc2da35cdca849e982051b86468016d8Dmitry Shmidt	if (msg == NULL)
5798d520ff1dc2da35cdca849e982051b86468016d8Dmitry Shmidt		return;
5808d520ff1dc2da35cdca849e982051b86468016d8Dmitry Shmidt
5818d520ff1dc2da35cdca849e982051b86468016d8Dmitry Shmidt	dbus_message_iter_init_append(msg, &iter);
5828d520ff1dc2da35cdca849e982051b86468016d8Dmitry Shmidt
5838d520ff1dc2da35cdca849e982051b86468016d8Dmitry Shmidt	if (!dbus_message_iter_append_basic(&iter, DBUS_TYPE_STRING, &key) ||
5848d520ff1dc2da35cdca849e982051b86468016d8Dmitry Shmidt	    !wpa_dbus_dict_open_write(&iter, &dict_iter) ||
5858d520ff1dc2da35cdca849e982051b86468016d8Dmitry Shmidt	    !wpa_dbus_dict_close_write(&iter, &dict_iter))
5868d520ff1dc2da35cdca849e982051b86468016d8Dmitry Shmidt		wpa_printf(MSG_ERROR, "dbus: Failed to construct signal");
5878d520ff1dc2da35cdca849e982051b86468016d8Dmitry Shmidt	else
5888d520ff1dc2da35cdca849e982051b86468016d8Dmitry Shmidt		dbus_connection_send(iface->con, msg, NULL);
5898d520ff1dc2da35cdca849e982051b86468016d8Dmitry Shmidt
5908d520ff1dc2da35cdca849e982051b86468016d8Dmitry Shmidt	dbus_message_unref(msg);
5918d520ff1dc2da35cdca849e982051b86468016d8Dmitry Shmidt}
5928d520ff1dc2da35cdca849e982051b86468016d8Dmitry Shmidt
5938d520ff1dc2da35cdca849e982051b86468016d8Dmitry Shmidt
5948d520ff1dc2da35cdca849e982051b86468016d8Dmitry Shmidt/**
5958d520ff1dc2da35cdca849e982051b86468016d8Dmitry Shmidt * wpas_dbus_signal_wps_event_fail - Signals Fail WPS event
5968d520ff1dc2da35cdca849e982051b86468016d8Dmitry Shmidt * @wpa_s: %wpa_supplicant network interface data
5978d520ff1dc2da35cdca849e982051b86468016d8Dmitry Shmidt *
5988d520ff1dc2da35cdca849e982051b86468016d8Dmitry Shmidt * Sends Event dbus signal with name "fail" and dictionary containing
5998d520ff1dc2da35cdca849e982051b86468016d8Dmitry Shmidt * "msg field with fail message number (int32) as arguments
6008d520ff1dc2da35cdca849e982051b86468016d8Dmitry Shmidt */
6018d520ff1dc2da35cdca849e982051b86468016d8Dmitry Shmidtvoid wpas_dbus_signal_wps_event_fail(struct wpa_supplicant *wpa_s,
6028d520ff1dc2da35cdca849e982051b86468016d8Dmitry Shmidt				     struct wps_event_fail *fail)
6038d520ff1dc2da35cdca849e982051b86468016d8Dmitry Shmidt{
6048d520ff1dc2da35cdca849e982051b86468016d8Dmitry Shmidt
6058d520ff1dc2da35cdca849e982051b86468016d8Dmitry Shmidt	DBusMessage *msg;
6068d520ff1dc2da35cdca849e982051b86468016d8Dmitry Shmidt	DBusMessageIter iter, dict_iter;
6078d520ff1dc2da35cdca849e982051b86468016d8Dmitry Shmidt	struct wpas_dbus_priv *iface;
6088d520ff1dc2da35cdca849e982051b86468016d8Dmitry Shmidt	char *key = "fail";
6098d520ff1dc2da35cdca849e982051b86468016d8Dmitry Shmidt
6108d520ff1dc2da35cdca849e982051b86468016d8Dmitry Shmidt	iface = wpa_s->global->dbus;
6118d520ff1dc2da35cdca849e982051b86468016d8Dmitry Shmidt
6128d520ff1dc2da35cdca849e982051b86468016d8Dmitry Shmidt	/* Do nothing if the control interface is not turned on */
6138d520ff1dc2da35cdca849e982051b86468016d8Dmitry Shmidt	if (iface == NULL)
6148d520ff1dc2da35cdca849e982051b86468016d8Dmitry Shmidt		return;
6158d520ff1dc2da35cdca849e982051b86468016d8Dmitry Shmidt
6168d520ff1dc2da35cdca849e982051b86468016d8Dmitry Shmidt	msg = dbus_message_new_signal(wpa_s->dbus_new_path,
6178d520ff1dc2da35cdca849e982051b86468016d8Dmitry Shmidt				      WPAS_DBUS_NEW_IFACE_WPS, "Event");
6188d520ff1dc2da35cdca849e982051b86468016d8Dmitry Shmidt	if (msg == NULL)
6198d520ff1dc2da35cdca849e982051b86468016d8Dmitry Shmidt		return;
6208d520ff1dc2da35cdca849e982051b86468016d8Dmitry Shmidt
6218d520ff1dc2da35cdca849e982051b86468016d8Dmitry Shmidt	dbus_message_iter_init_append(msg, &iter);
6228d520ff1dc2da35cdca849e982051b86468016d8Dmitry Shmidt
6238d520ff1dc2da35cdca849e982051b86468016d8Dmitry Shmidt	if (!dbus_message_iter_append_basic(&iter, DBUS_TYPE_STRING, &key) ||
6248d520ff1dc2da35cdca849e982051b86468016d8Dmitry Shmidt	    !wpa_dbus_dict_open_write(&iter, &dict_iter) ||
6258d520ff1dc2da35cdca849e982051b86468016d8Dmitry Shmidt	    !wpa_dbus_dict_append_int32(&dict_iter, "msg", fail->msg) ||
6268d520ff1dc2da35cdca849e982051b86468016d8Dmitry Shmidt	    !wpa_dbus_dict_close_write(&iter, &dict_iter))
6278d520ff1dc2da35cdca849e982051b86468016d8Dmitry Shmidt		wpa_printf(MSG_ERROR, "dbus: Failed to construct signal");
6288d520ff1dc2da35cdca849e982051b86468016d8Dmitry Shmidt	else
6298d520ff1dc2da35cdca849e982051b86468016d8Dmitry Shmidt		dbus_connection_send(iface->con, msg, NULL);
6308d520ff1dc2da35cdca849e982051b86468016d8Dmitry Shmidt
6318d520ff1dc2da35cdca849e982051b86468016d8Dmitry Shmidt	dbus_message_unref(msg);
6328d520ff1dc2da35cdca849e982051b86468016d8Dmitry Shmidt}
6338d520ff1dc2da35cdca849e982051b86468016d8Dmitry Shmidt
6348d520ff1dc2da35cdca849e982051b86468016d8Dmitry Shmidt
6358d520ff1dc2da35cdca849e982051b86468016d8Dmitry Shmidt/**
6368d520ff1dc2da35cdca849e982051b86468016d8Dmitry Shmidt * wpas_dbus_signal_wps_event_m2d - Signals M2D WPS event
6378d520ff1dc2da35cdca849e982051b86468016d8Dmitry Shmidt * @wpa_s: %wpa_supplicant network interface data
6388d520ff1dc2da35cdca849e982051b86468016d8Dmitry Shmidt *
6398d520ff1dc2da35cdca849e982051b86468016d8Dmitry Shmidt * Sends Event dbus signal with name "m2d" and dictionary containing
6408d520ff1dc2da35cdca849e982051b86468016d8Dmitry Shmidt * fields of wps_event_m2d structure.
6418d520ff1dc2da35cdca849e982051b86468016d8Dmitry Shmidt */
6428d520ff1dc2da35cdca849e982051b86468016d8Dmitry Shmidtvoid wpas_dbus_signal_wps_event_m2d(struct wpa_supplicant *wpa_s,
6438d520ff1dc2da35cdca849e982051b86468016d8Dmitry Shmidt				    struct wps_event_m2d *m2d)
6448d520ff1dc2da35cdca849e982051b86468016d8Dmitry Shmidt{
6458d520ff1dc2da35cdca849e982051b86468016d8Dmitry Shmidt
6468d520ff1dc2da35cdca849e982051b86468016d8Dmitry Shmidt	DBusMessage *msg;
6478d520ff1dc2da35cdca849e982051b86468016d8Dmitry Shmidt	DBusMessageIter iter, dict_iter;
6488d520ff1dc2da35cdca849e982051b86468016d8Dmitry Shmidt	struct wpas_dbus_priv *iface;
6498d520ff1dc2da35cdca849e982051b86468016d8Dmitry Shmidt	char *key = "m2d";
6508d520ff1dc2da35cdca849e982051b86468016d8Dmitry Shmidt
6518d520ff1dc2da35cdca849e982051b86468016d8Dmitry Shmidt	iface = wpa_s->global->dbus;
6528d520ff1dc2da35cdca849e982051b86468016d8Dmitry Shmidt
6538d520ff1dc2da35cdca849e982051b86468016d8Dmitry Shmidt	/* Do nothing if the control interface is not turned on */
6548d520ff1dc2da35cdca849e982051b86468016d8Dmitry Shmidt	if (iface == NULL)
6558d520ff1dc2da35cdca849e982051b86468016d8Dmitry Shmidt		return;
6568d520ff1dc2da35cdca849e982051b86468016d8Dmitry Shmidt
6578d520ff1dc2da35cdca849e982051b86468016d8Dmitry Shmidt	msg = dbus_message_new_signal(wpa_s->dbus_new_path,
6588d520ff1dc2da35cdca849e982051b86468016d8Dmitry Shmidt				      WPAS_DBUS_NEW_IFACE_WPS, "Event");
6598d520ff1dc2da35cdca849e982051b86468016d8Dmitry Shmidt	if (msg == NULL)
6608d520ff1dc2da35cdca849e982051b86468016d8Dmitry Shmidt		return;
6618d520ff1dc2da35cdca849e982051b86468016d8Dmitry Shmidt
6628d520ff1dc2da35cdca849e982051b86468016d8Dmitry Shmidt	dbus_message_iter_init_append(msg, &iter);
6638d520ff1dc2da35cdca849e982051b86468016d8Dmitry Shmidt
6648d520ff1dc2da35cdca849e982051b86468016d8Dmitry Shmidt	if (!dbus_message_iter_append_basic(&iter, DBUS_TYPE_STRING, &key) ||
6658d520ff1dc2da35cdca849e982051b86468016d8Dmitry Shmidt	    !wpa_dbus_dict_open_write(&iter, &dict_iter) ||
6668d520ff1dc2da35cdca849e982051b86468016d8Dmitry Shmidt	    !wpa_dbus_dict_append_uint16(&dict_iter, "config_methods",
6678d520ff1dc2da35cdca849e982051b86468016d8Dmitry Shmidt					 m2d->config_methods) ||
6688d520ff1dc2da35cdca849e982051b86468016d8Dmitry Shmidt	    !wpa_dbus_dict_append_byte_array(&dict_iter, "manufacturer",
6698d520ff1dc2da35cdca849e982051b86468016d8Dmitry Shmidt					     (const char *) m2d->manufacturer,
6708d520ff1dc2da35cdca849e982051b86468016d8Dmitry Shmidt					     m2d->manufacturer_len) ||
6718d520ff1dc2da35cdca849e982051b86468016d8Dmitry Shmidt	    !wpa_dbus_dict_append_byte_array(&dict_iter, "model_name",
6728d520ff1dc2da35cdca849e982051b86468016d8Dmitry Shmidt					     (const char *) m2d->model_name,
6738d520ff1dc2da35cdca849e982051b86468016d8Dmitry Shmidt					     m2d->model_name_len) ||
6748d520ff1dc2da35cdca849e982051b86468016d8Dmitry Shmidt	    !wpa_dbus_dict_append_byte_array(&dict_iter, "model_number",
6758d520ff1dc2da35cdca849e982051b86468016d8Dmitry Shmidt					     (const char *) m2d->model_number,
6768d520ff1dc2da35cdca849e982051b86468016d8Dmitry Shmidt					     m2d->model_number_len) ||
6778d520ff1dc2da35cdca849e982051b86468016d8Dmitry Shmidt	    !wpa_dbus_dict_append_byte_array(&dict_iter, "serial_number",
6788d520ff1dc2da35cdca849e982051b86468016d8Dmitry Shmidt					     (const char *)
6798d520ff1dc2da35cdca849e982051b86468016d8Dmitry Shmidt					     m2d->serial_number,
6808d520ff1dc2da35cdca849e982051b86468016d8Dmitry Shmidt					     m2d->serial_number_len) ||
6818d520ff1dc2da35cdca849e982051b86468016d8Dmitry Shmidt	    !wpa_dbus_dict_append_byte_array(&dict_iter, "dev_name",
6828d520ff1dc2da35cdca849e982051b86468016d8Dmitry Shmidt					     (const char *) m2d->dev_name,
6838d520ff1dc2da35cdca849e982051b86468016d8Dmitry Shmidt					     m2d->dev_name_len) ||
6848d520ff1dc2da35cdca849e982051b86468016d8Dmitry Shmidt	    !wpa_dbus_dict_append_byte_array(&dict_iter, "primary_dev_type",
6858d520ff1dc2da35cdca849e982051b86468016d8Dmitry Shmidt					     (const char *)
6868d520ff1dc2da35cdca849e982051b86468016d8Dmitry Shmidt					     m2d->primary_dev_type, 8) ||
6878d520ff1dc2da35cdca849e982051b86468016d8Dmitry Shmidt	    !wpa_dbus_dict_append_uint16(&dict_iter, "config_error",
6888d520ff1dc2da35cdca849e982051b86468016d8Dmitry Shmidt					 m2d->config_error) ||
6898d520ff1dc2da35cdca849e982051b86468016d8Dmitry Shmidt	    !wpa_dbus_dict_append_uint16(&dict_iter, "dev_password_id",
6908d520ff1dc2da35cdca849e982051b86468016d8Dmitry Shmidt					 m2d->dev_password_id) ||
6918d520ff1dc2da35cdca849e982051b86468016d8Dmitry Shmidt	    !wpa_dbus_dict_close_write(&iter, &dict_iter))
6928d520ff1dc2da35cdca849e982051b86468016d8Dmitry Shmidt		wpa_printf(MSG_ERROR, "dbus: Failed to construct signal");
6938d520ff1dc2da35cdca849e982051b86468016d8Dmitry Shmidt	else
6948d520ff1dc2da35cdca849e982051b86468016d8Dmitry Shmidt		dbus_connection_send(iface->con, msg, NULL);
6958d520ff1dc2da35cdca849e982051b86468016d8Dmitry Shmidt
6968d520ff1dc2da35cdca849e982051b86468016d8Dmitry Shmidt	dbus_message_unref(msg);
6978d520ff1dc2da35cdca849e982051b86468016d8Dmitry Shmidt}
6988d520ff1dc2da35cdca849e982051b86468016d8Dmitry Shmidt
6998d520ff1dc2da35cdca849e982051b86468016d8Dmitry Shmidt
7008d520ff1dc2da35cdca849e982051b86468016d8Dmitry Shmidt/**
7018d520ff1dc2da35cdca849e982051b86468016d8Dmitry Shmidt * wpas_dbus_signal_wps_cred - Signals new credentials
7028d520ff1dc2da35cdca849e982051b86468016d8Dmitry Shmidt * @wpa_s: %wpa_supplicant network interface data
7038d520ff1dc2da35cdca849e982051b86468016d8Dmitry Shmidt *
7048d520ff1dc2da35cdca849e982051b86468016d8Dmitry Shmidt * Sends signal with credentials in directory argument
7058d520ff1dc2da35cdca849e982051b86468016d8Dmitry Shmidt */
7068d520ff1dc2da35cdca849e982051b86468016d8Dmitry Shmidtvoid wpas_dbus_signal_wps_cred(struct wpa_supplicant *wpa_s,
7078d520ff1dc2da35cdca849e982051b86468016d8Dmitry Shmidt			       const struct wps_credential *cred)
7088d520ff1dc2da35cdca849e982051b86468016d8Dmitry Shmidt{
7098d520ff1dc2da35cdca849e982051b86468016d8Dmitry Shmidt	DBusMessage *msg;
7108d520ff1dc2da35cdca849e982051b86468016d8Dmitry Shmidt	DBusMessageIter iter, dict_iter;
7118d520ff1dc2da35cdca849e982051b86468016d8Dmitry Shmidt	struct wpas_dbus_priv *iface;
7128d520ff1dc2da35cdca849e982051b86468016d8Dmitry Shmidt	char *auth_type[6]; /* we have six possible authorization types */
7138d520ff1dc2da35cdca849e982051b86468016d8Dmitry Shmidt	int at_num = 0;
7148d520ff1dc2da35cdca849e982051b86468016d8Dmitry Shmidt	char *encr_type[4]; /* we have four possible encryption types */
7158d520ff1dc2da35cdca849e982051b86468016d8Dmitry Shmidt	int et_num = 0;
7168d520ff1dc2da35cdca849e982051b86468016d8Dmitry Shmidt
7178d520ff1dc2da35cdca849e982051b86468016d8Dmitry Shmidt	iface = wpa_s->global->dbus;
7188d520ff1dc2da35cdca849e982051b86468016d8Dmitry Shmidt
7198d520ff1dc2da35cdca849e982051b86468016d8Dmitry Shmidt	/* Do nothing if the control interface is not turned on */
7208d520ff1dc2da35cdca849e982051b86468016d8Dmitry Shmidt	if (iface == NULL)
7218d520ff1dc2da35cdca849e982051b86468016d8Dmitry Shmidt		return;
7228d520ff1dc2da35cdca849e982051b86468016d8Dmitry Shmidt
7238d520ff1dc2da35cdca849e982051b86468016d8Dmitry Shmidt	msg = dbus_message_new_signal(wpa_s->dbus_new_path,
7248d520ff1dc2da35cdca849e982051b86468016d8Dmitry Shmidt				      WPAS_DBUS_NEW_IFACE_WPS,
7258d520ff1dc2da35cdca849e982051b86468016d8Dmitry Shmidt				      "Credentials");
7268d520ff1dc2da35cdca849e982051b86468016d8Dmitry Shmidt	if (msg == NULL)
7278d520ff1dc2da35cdca849e982051b86468016d8Dmitry Shmidt		return;
7288d520ff1dc2da35cdca849e982051b86468016d8Dmitry Shmidt
7298d520ff1dc2da35cdca849e982051b86468016d8Dmitry Shmidt	dbus_message_iter_init_append(msg, &iter);
7308d520ff1dc2da35cdca849e982051b86468016d8Dmitry Shmidt	if (!wpa_dbus_dict_open_write(&iter, &dict_iter))
7318d520ff1dc2da35cdca849e982051b86468016d8Dmitry Shmidt		goto nomem;
7328d520ff1dc2da35cdca849e982051b86468016d8Dmitry Shmidt
7338d520ff1dc2da35cdca849e982051b86468016d8Dmitry Shmidt	if (cred->auth_type & WPS_AUTH_OPEN)
7348d520ff1dc2da35cdca849e982051b86468016d8Dmitry Shmidt		auth_type[at_num++] = "open";
7358d520ff1dc2da35cdca849e982051b86468016d8Dmitry Shmidt	if (cred->auth_type & WPS_AUTH_WPAPSK)
7368d520ff1dc2da35cdca849e982051b86468016d8Dmitry Shmidt		auth_type[at_num++] = "wpa-psk";
7378d520ff1dc2da35cdca849e982051b86468016d8Dmitry Shmidt	if (cred->auth_type & WPS_AUTH_SHARED)
7388d520ff1dc2da35cdca849e982051b86468016d8Dmitry Shmidt		auth_type[at_num++] = "shared";
7398d520ff1dc2da35cdca849e982051b86468016d8Dmitry Shmidt	if (cred->auth_type & WPS_AUTH_WPA)
7408d520ff1dc2da35cdca849e982051b86468016d8Dmitry Shmidt		auth_type[at_num++] = "wpa-eap";
7418d520ff1dc2da35cdca849e982051b86468016d8Dmitry Shmidt	if (cred->auth_type & WPS_AUTH_WPA2)
7428d520ff1dc2da35cdca849e982051b86468016d8Dmitry Shmidt		auth_type[at_num++] = "wpa2-eap";
7438d520ff1dc2da35cdca849e982051b86468016d8Dmitry Shmidt	if (cred->auth_type & WPS_AUTH_WPA2PSK)
7448d520ff1dc2da35cdca849e982051b86468016d8Dmitry Shmidt		auth_type[at_num++] =
7458d520ff1dc2da35cdca849e982051b86468016d8Dmitry Shmidt		"wpa2-psk";
7468d520ff1dc2da35cdca849e982051b86468016d8Dmitry Shmidt
7478d520ff1dc2da35cdca849e982051b86468016d8Dmitry Shmidt	if (cred->encr_type & WPS_ENCR_NONE)
7488d520ff1dc2da35cdca849e982051b86468016d8Dmitry Shmidt		encr_type[et_num++] = "none";
7498d520ff1dc2da35cdca849e982051b86468016d8Dmitry Shmidt	if (cred->encr_type & WPS_ENCR_WEP)
7508d520ff1dc2da35cdca849e982051b86468016d8Dmitry Shmidt		encr_type[et_num++] = "wep";
7518d520ff1dc2da35cdca849e982051b86468016d8Dmitry Shmidt	if (cred->encr_type & WPS_ENCR_TKIP)
7528d520ff1dc2da35cdca849e982051b86468016d8Dmitry Shmidt		encr_type[et_num++] = "tkip";
7538d520ff1dc2da35cdca849e982051b86468016d8Dmitry Shmidt	if (cred->encr_type & WPS_ENCR_AES)
7548d520ff1dc2da35cdca849e982051b86468016d8Dmitry Shmidt		encr_type[et_num++] = "aes";
7558d520ff1dc2da35cdca849e982051b86468016d8Dmitry Shmidt
7568d520ff1dc2da35cdca849e982051b86468016d8Dmitry Shmidt	if (wpa_s->current_ssid) {
7578d520ff1dc2da35cdca849e982051b86468016d8Dmitry Shmidt		if (!wpa_dbus_dict_append_byte_array(
7588d520ff1dc2da35cdca849e982051b86468016d8Dmitry Shmidt			    &dict_iter, "BSSID",
7598d520ff1dc2da35cdca849e982051b86468016d8Dmitry Shmidt			    (const char *) wpa_s->current_ssid->bssid,
7608d520ff1dc2da35cdca849e982051b86468016d8Dmitry Shmidt			    ETH_ALEN))
7618d520ff1dc2da35cdca849e982051b86468016d8Dmitry Shmidt			goto nomem;
7628d520ff1dc2da35cdca849e982051b86468016d8Dmitry Shmidt	}
7638d520ff1dc2da35cdca849e982051b86468016d8Dmitry Shmidt
7648d520ff1dc2da35cdca849e982051b86468016d8Dmitry Shmidt	if (!wpa_dbus_dict_append_byte_array(&dict_iter, "SSID",
7658d520ff1dc2da35cdca849e982051b86468016d8Dmitry Shmidt					     (const char *) cred->ssid,
7668d520ff1dc2da35cdca849e982051b86468016d8Dmitry Shmidt					     cred->ssid_len) ||
7678d520ff1dc2da35cdca849e982051b86468016d8Dmitry Shmidt	    !wpa_dbus_dict_append_string_array(&dict_iter, "AuthType",
7688d520ff1dc2da35cdca849e982051b86468016d8Dmitry Shmidt					       (const char **) auth_type,
7698d520ff1dc2da35cdca849e982051b86468016d8Dmitry Shmidt					       at_num) ||
7708d520ff1dc2da35cdca849e982051b86468016d8Dmitry Shmidt	    !wpa_dbus_dict_append_string_array(&dict_iter, "EncrType",
7718d520ff1dc2da35cdca849e982051b86468016d8Dmitry Shmidt					       (const char **) encr_type,
7728d520ff1dc2da35cdca849e982051b86468016d8Dmitry Shmidt					       et_num) ||
7738d520ff1dc2da35cdca849e982051b86468016d8Dmitry Shmidt	    !wpa_dbus_dict_append_byte_array(&dict_iter, "Key",
7748d520ff1dc2da35cdca849e982051b86468016d8Dmitry Shmidt					     (const char *) cred->key,
7758d520ff1dc2da35cdca849e982051b86468016d8Dmitry Shmidt					     cred->key_len) ||
7768d520ff1dc2da35cdca849e982051b86468016d8Dmitry Shmidt	    !wpa_dbus_dict_append_uint32(&dict_iter, "KeyIndex",
7778d520ff1dc2da35cdca849e982051b86468016d8Dmitry Shmidt					 cred->key_idx) ||
7788d520ff1dc2da35cdca849e982051b86468016d8Dmitry Shmidt	    !wpa_dbus_dict_close_write(&iter, &dict_iter))
7798d520ff1dc2da35cdca849e982051b86468016d8Dmitry Shmidt		goto nomem;
7808d520ff1dc2da35cdca849e982051b86468016d8Dmitry Shmidt
7818d520ff1dc2da35cdca849e982051b86468016d8Dmitry Shmidt	dbus_connection_send(iface->con, msg, NULL);
7828d520ff1dc2da35cdca849e982051b86468016d8Dmitry Shmidt
7838d520ff1dc2da35cdca849e982051b86468016d8Dmitry Shmidtnomem:
7848d520ff1dc2da35cdca849e982051b86468016d8Dmitry Shmidt	dbus_message_unref(msg);
7858d520ff1dc2da35cdca849e982051b86468016d8Dmitry Shmidt}
7868d520ff1dc2da35cdca849e982051b86468016d8Dmitry Shmidt
7878d520ff1dc2da35cdca849e982051b86468016d8Dmitry Shmidt#endif /* CONFIG_WPS */
7888d520ff1dc2da35cdca849e982051b86468016d8Dmitry Shmidt
789c55524ad84d13014e8019491c2b17e5dcf13545aDmitry Shmidtvoid wpas_dbus_signal_certification(struct wpa_supplicant *wpa_s,
790c55524ad84d13014e8019491c2b17e5dcf13545aDmitry Shmidt				    int depth, const char *subject,
791c55524ad84d13014e8019491c2b17e5dcf13545aDmitry Shmidt				    const char *cert_hash,
792c55524ad84d13014e8019491c2b17e5dcf13545aDmitry Shmidt				    const struct wpabuf *cert)
793c55524ad84d13014e8019491c2b17e5dcf13545aDmitry Shmidt{
794c55524ad84d13014e8019491c2b17e5dcf13545aDmitry Shmidt	struct wpas_dbus_priv *iface;
795c55524ad84d13014e8019491c2b17e5dcf13545aDmitry Shmidt	DBusMessage *msg;
796c55524ad84d13014e8019491c2b17e5dcf13545aDmitry Shmidt	DBusMessageIter iter, dict_iter;
797c55524ad84d13014e8019491c2b17e5dcf13545aDmitry Shmidt
798c55524ad84d13014e8019491c2b17e5dcf13545aDmitry Shmidt	iface = wpa_s->global->dbus;
799c55524ad84d13014e8019491c2b17e5dcf13545aDmitry Shmidt
800c55524ad84d13014e8019491c2b17e5dcf13545aDmitry Shmidt	/* Do nothing if the control interface is not turned on */
801c55524ad84d13014e8019491c2b17e5dcf13545aDmitry Shmidt	if (iface == NULL)
802c55524ad84d13014e8019491c2b17e5dcf13545aDmitry Shmidt		return;
803c55524ad84d13014e8019491c2b17e5dcf13545aDmitry Shmidt
804c55524ad84d13014e8019491c2b17e5dcf13545aDmitry Shmidt	msg = dbus_message_new_signal(wpa_s->dbus_new_path,
805c55524ad84d13014e8019491c2b17e5dcf13545aDmitry Shmidt				      WPAS_DBUS_NEW_IFACE_INTERFACE,
806c55524ad84d13014e8019491c2b17e5dcf13545aDmitry Shmidt				      "Certification");
807c55524ad84d13014e8019491c2b17e5dcf13545aDmitry Shmidt	if (msg == NULL)
808c55524ad84d13014e8019491c2b17e5dcf13545aDmitry Shmidt		return;
809c55524ad84d13014e8019491c2b17e5dcf13545aDmitry Shmidt
810c55524ad84d13014e8019491c2b17e5dcf13545aDmitry Shmidt	dbus_message_iter_init_append(msg, &iter);
811c55524ad84d13014e8019491c2b17e5dcf13545aDmitry Shmidt	if (!wpa_dbus_dict_open_write(&iter, &dict_iter))
812c55524ad84d13014e8019491c2b17e5dcf13545aDmitry Shmidt		goto nomem;
813c55524ad84d13014e8019491c2b17e5dcf13545aDmitry Shmidt
814c55524ad84d13014e8019491c2b17e5dcf13545aDmitry Shmidt	if (!wpa_dbus_dict_append_uint32(&dict_iter, "depth", depth) ||
815c55524ad84d13014e8019491c2b17e5dcf13545aDmitry Shmidt	    !wpa_dbus_dict_append_string(&dict_iter, "subject", subject))
816c55524ad84d13014e8019491c2b17e5dcf13545aDmitry Shmidt		goto nomem;
817c55524ad84d13014e8019491c2b17e5dcf13545aDmitry Shmidt
818c55524ad84d13014e8019491c2b17e5dcf13545aDmitry Shmidt	if (cert_hash &&
819c55524ad84d13014e8019491c2b17e5dcf13545aDmitry Shmidt	    !wpa_dbus_dict_append_string(&dict_iter, "cert_hash", cert_hash))
820c55524ad84d13014e8019491c2b17e5dcf13545aDmitry Shmidt		goto nomem;
821c55524ad84d13014e8019491c2b17e5dcf13545aDmitry Shmidt
822c55524ad84d13014e8019491c2b17e5dcf13545aDmitry Shmidt	if (cert &&
823c55524ad84d13014e8019491c2b17e5dcf13545aDmitry Shmidt	    !wpa_dbus_dict_append_byte_array(&dict_iter, "cert",
824c55524ad84d13014e8019491c2b17e5dcf13545aDmitry Shmidt					     wpabuf_head(cert),
825c55524ad84d13014e8019491c2b17e5dcf13545aDmitry Shmidt					     wpabuf_len(cert)))
826c55524ad84d13014e8019491c2b17e5dcf13545aDmitry Shmidt		goto nomem;
827c55524ad84d13014e8019491c2b17e5dcf13545aDmitry Shmidt
828c55524ad84d13014e8019491c2b17e5dcf13545aDmitry Shmidt	if (!wpa_dbus_dict_close_write(&iter, &dict_iter))
829c55524ad84d13014e8019491c2b17e5dcf13545aDmitry Shmidt		goto nomem;
830c55524ad84d13014e8019491c2b17e5dcf13545aDmitry Shmidt
831c55524ad84d13014e8019491c2b17e5dcf13545aDmitry Shmidt	dbus_connection_send(iface->con, msg, NULL);
832c55524ad84d13014e8019491c2b17e5dcf13545aDmitry Shmidt
833c55524ad84d13014e8019491c2b17e5dcf13545aDmitry Shmidtnomem:
834c55524ad84d13014e8019491c2b17e5dcf13545aDmitry Shmidt	dbus_message_unref(msg);
835c55524ad84d13014e8019491c2b17e5dcf13545aDmitry Shmidt}
836c55524ad84d13014e8019491c2b17e5dcf13545aDmitry Shmidt
83704949598a23f501be6eec21697465fd46a28840aDmitry Shmidt
83804949598a23f501be6eec21697465fd46a28840aDmitry Shmidtvoid wpas_dbus_signal_eap_status(struct wpa_supplicant *wpa_s,
83904949598a23f501be6eec21697465fd46a28840aDmitry Shmidt				 const char *status, const char *parameter)
84004949598a23f501be6eec21697465fd46a28840aDmitry Shmidt{
84104949598a23f501be6eec21697465fd46a28840aDmitry Shmidt	struct wpas_dbus_priv *iface;
84204949598a23f501be6eec21697465fd46a28840aDmitry Shmidt	DBusMessage *msg;
84304949598a23f501be6eec21697465fd46a28840aDmitry Shmidt	DBusMessageIter iter;
84404949598a23f501be6eec21697465fd46a28840aDmitry Shmidt
84504949598a23f501be6eec21697465fd46a28840aDmitry Shmidt	iface = wpa_s->global->dbus;
84604949598a23f501be6eec21697465fd46a28840aDmitry Shmidt
84704949598a23f501be6eec21697465fd46a28840aDmitry Shmidt	/* Do nothing if the control interface is not turned on */
84804949598a23f501be6eec21697465fd46a28840aDmitry Shmidt	if (iface == NULL)
84904949598a23f501be6eec21697465fd46a28840aDmitry Shmidt		return;
85004949598a23f501be6eec21697465fd46a28840aDmitry Shmidt
85104949598a23f501be6eec21697465fd46a28840aDmitry Shmidt	msg = dbus_message_new_signal(wpa_s->dbus_new_path,
85204949598a23f501be6eec21697465fd46a28840aDmitry Shmidt				      WPAS_DBUS_NEW_IFACE_INTERFACE,
85304949598a23f501be6eec21697465fd46a28840aDmitry Shmidt				      "EAP");
85404949598a23f501be6eec21697465fd46a28840aDmitry Shmidt	if (msg == NULL)
85504949598a23f501be6eec21697465fd46a28840aDmitry Shmidt		return;
85604949598a23f501be6eec21697465fd46a28840aDmitry Shmidt
85704949598a23f501be6eec21697465fd46a28840aDmitry Shmidt	dbus_message_iter_init_append(msg, &iter);
85804949598a23f501be6eec21697465fd46a28840aDmitry Shmidt
85904949598a23f501be6eec21697465fd46a28840aDmitry Shmidt	if (!dbus_message_iter_append_basic(&iter, DBUS_TYPE_STRING, &status)
86004949598a23f501be6eec21697465fd46a28840aDmitry Shmidt	    ||
86104949598a23f501be6eec21697465fd46a28840aDmitry Shmidt	    !dbus_message_iter_append_basic(&iter, DBUS_TYPE_STRING,
86204949598a23f501be6eec21697465fd46a28840aDmitry Shmidt					    &parameter))
86304949598a23f501be6eec21697465fd46a28840aDmitry Shmidt		goto nomem;
86404949598a23f501be6eec21697465fd46a28840aDmitry Shmidt
86504949598a23f501be6eec21697465fd46a28840aDmitry Shmidt	dbus_connection_send(iface->con, msg, NULL);
86604949598a23f501be6eec21697465fd46a28840aDmitry Shmidt
86704949598a23f501be6eec21697465fd46a28840aDmitry Shmidtnomem:
86804949598a23f501be6eec21697465fd46a28840aDmitry Shmidt	dbus_message_unref(msg);
86904949598a23f501be6eec21697465fd46a28840aDmitry Shmidt}
87004949598a23f501be6eec21697465fd46a28840aDmitry Shmidt
87104949598a23f501be6eec21697465fd46a28840aDmitry Shmidt
87275ecf5267604f166b85a7ee2cf0d9cb682966680Jouni Malinen#ifdef CONFIG_P2P
8738d520ff1dc2da35cdca849e982051b86468016d8Dmitry Shmidt
8748d520ff1dc2da35cdca849e982051b86468016d8Dmitry Shmidt/**
87575ecf5267604f166b85a7ee2cf0d9cb682966680Jouni Malinen * wpas_dbus_signal_p2p_group_removed - Signals P2P group was removed
8768d520ff1dc2da35cdca849e982051b86468016d8Dmitry Shmidt * @wpa_s: %wpa_supplicant network interface data
87775ecf5267604f166b85a7ee2cf0d9cb682966680Jouni Malinen * @role: role of this device (client or GO)
87875ecf5267604f166b85a7ee2cf0d9cb682966680Jouni Malinen * Sends signal with i/f name and role as string arguments
8798d520ff1dc2da35cdca849e982051b86468016d8Dmitry Shmidt */
88075ecf5267604f166b85a7ee2cf0d9cb682966680Jouni Malinenvoid wpas_dbus_signal_p2p_group_removed(struct wpa_supplicant *wpa_s,
88175ecf5267604f166b85a7ee2cf0d9cb682966680Jouni Malinen					const char *role)
8828d520ff1dc2da35cdca849e982051b86468016d8Dmitry Shmidt{
8838d520ff1dc2da35cdca849e982051b86468016d8Dmitry Shmidt
88475ecf5267604f166b85a7ee2cf0d9cb682966680Jouni Malinen	DBusMessage *msg;
88575ecf5267604f166b85a7ee2cf0d9cb682966680Jouni Malinen	DBusMessageIter iter;
88675ecf5267604f166b85a7ee2cf0d9cb682966680Jouni Malinen	struct wpas_dbus_priv *iface = wpa_s->global->dbus;
88775ecf5267604f166b85a7ee2cf0d9cb682966680Jouni Malinen	char *ifname = wpa_s->ifname;
8888d520ff1dc2da35cdca849e982051b86468016d8Dmitry Shmidt
88975ecf5267604f166b85a7ee2cf0d9cb682966680Jouni Malinen	/* Do nothing if the control interface is not turned on */
89075ecf5267604f166b85a7ee2cf0d9cb682966680Jouni Malinen	if (iface == NULL)
8918d520ff1dc2da35cdca849e982051b86468016d8Dmitry Shmidt		return;
89275ecf5267604f166b85a7ee2cf0d9cb682966680Jouni Malinen
89375ecf5267604f166b85a7ee2cf0d9cb682966680Jouni Malinen	msg = dbus_message_new_signal(wpa_s->dbus_new_path,
89475ecf5267604f166b85a7ee2cf0d9cb682966680Jouni Malinen				      WPAS_DBUS_NEW_IFACE_P2PDEVICE,
89575ecf5267604f166b85a7ee2cf0d9cb682966680Jouni Malinen				      "GroupFinished");
89675ecf5267604f166b85a7ee2cf0d9cb682966680Jouni Malinen	if (msg == NULL)
89775ecf5267604f166b85a7ee2cf0d9cb682966680Jouni Malinen		return;
89875ecf5267604f166b85a7ee2cf0d9cb682966680Jouni Malinen
89975ecf5267604f166b85a7ee2cf0d9cb682966680Jouni Malinen	dbus_message_iter_init_append(msg, &iter);
90075ecf5267604f166b85a7ee2cf0d9cb682966680Jouni Malinen
90175ecf5267604f166b85a7ee2cf0d9cb682966680Jouni Malinen	if (!dbus_message_iter_append_basic(&iter, DBUS_TYPE_STRING, &ifname)) {
90275ecf5267604f166b85a7ee2cf0d9cb682966680Jouni Malinen		wpa_printf(MSG_ERROR, "dbus: Failed to construct GroupFinished"
90375ecf5267604f166b85a7ee2cf0d9cb682966680Jouni Malinen				      "signal -not enough memory for ifname ");
90475ecf5267604f166b85a7ee2cf0d9cb682966680Jouni Malinen		goto err;
9058d520ff1dc2da35cdca849e982051b86468016d8Dmitry Shmidt	}
9068d520ff1dc2da35cdca849e982051b86468016d8Dmitry Shmidt
90775ecf5267604f166b85a7ee2cf0d9cb682966680Jouni Malinen	if (!dbus_message_iter_append_basic(&iter, DBUS_TYPE_STRING, &role))
90875ecf5267604f166b85a7ee2cf0d9cb682966680Jouni Malinen		wpa_printf(MSG_ERROR, "dbus: Failed to construct GroupFinished"
90975ecf5267604f166b85a7ee2cf0d9cb682966680Jouni Malinen				      "signal -not enough memory for role ");
91075ecf5267604f166b85a7ee2cf0d9cb682966680Jouni Malinen	else
91175ecf5267604f166b85a7ee2cf0d9cb682966680Jouni Malinen		dbus_connection_send(iface->con, msg, NULL);
91275ecf5267604f166b85a7ee2cf0d9cb682966680Jouni Malinen
91375ecf5267604f166b85a7ee2cf0d9cb682966680Jouni Malinenerr:
91475ecf5267604f166b85a7ee2cf0d9cb682966680Jouni Malinen	dbus_message_unref(msg);
9158d520ff1dc2da35cdca849e982051b86468016d8Dmitry Shmidt}
9168d520ff1dc2da35cdca849e982051b86468016d8Dmitry Shmidt
9178d520ff1dc2da35cdca849e982051b86468016d8Dmitry Shmidt
9188d520ff1dc2da35cdca849e982051b86468016d8Dmitry Shmidt/**
91975ecf5267604f166b85a7ee2cf0d9cb682966680Jouni Malinen * wpas_dbus_signal_p2p_provision_discovery - Signals various PD events
9208d520ff1dc2da35cdca849e982051b86468016d8Dmitry Shmidt *
92175ecf5267604f166b85a7ee2cf0d9cb682966680Jouni Malinen * @dev_addr - who sent the request or responded to our request.
92275ecf5267604f166b85a7ee2cf0d9cb682966680Jouni Malinen * @request - Will be 1 if request, 0 for response.
92375ecf5267604f166b85a7ee2cf0d9cb682966680Jouni Malinen * @status - valid only in case of response
92475ecf5267604f166b85a7ee2cf0d9cb682966680Jouni Malinen * @config_methods - wps config methods
92575ecf5267604f166b85a7ee2cf0d9cb682966680Jouni Malinen * @generated_pin - pin to be displayed in case of WPS_CONFIG_DISPLAY method
92675ecf5267604f166b85a7ee2cf0d9cb682966680Jouni Malinen *
92775ecf5267604f166b85a7ee2cf0d9cb682966680Jouni Malinen * Sends following provision discovery related events:
92875ecf5267604f166b85a7ee2cf0d9cb682966680Jouni Malinen *	ProvisionDiscoveryRequestDisplayPin
92975ecf5267604f166b85a7ee2cf0d9cb682966680Jouni Malinen *	ProvisionDiscoveryResponseDisplayPin
93075ecf5267604f166b85a7ee2cf0d9cb682966680Jouni Malinen *	ProvisionDiscoveryRequestEnterPin
93175ecf5267604f166b85a7ee2cf0d9cb682966680Jouni Malinen *	ProvisionDiscoveryResponseEnterPin
93275ecf5267604f166b85a7ee2cf0d9cb682966680Jouni Malinen *	ProvisionDiscoveryPBCRequest
93375ecf5267604f166b85a7ee2cf0d9cb682966680Jouni Malinen *	ProvisionDiscoveryPBCResponse
93475ecf5267604f166b85a7ee2cf0d9cb682966680Jouni Malinen *
93575ecf5267604f166b85a7ee2cf0d9cb682966680Jouni Malinen *	TODO::
93675ecf5267604f166b85a7ee2cf0d9cb682966680Jouni Malinen *	ProvisionDiscoveryFailure (timeout case)
9378d520ff1dc2da35cdca849e982051b86468016d8Dmitry Shmidt */
93875ecf5267604f166b85a7ee2cf0d9cb682966680Jouni Malinenvoid wpas_dbus_signal_p2p_provision_discovery(struct wpa_supplicant *wpa_s,
93975ecf5267604f166b85a7ee2cf0d9cb682966680Jouni Malinen					      const u8 *dev_addr, int request,
94075ecf5267604f166b85a7ee2cf0d9cb682966680Jouni Malinen					      enum p2p_prov_disc_status status,
94175ecf5267604f166b85a7ee2cf0d9cb682966680Jouni Malinen					      u16 config_methods,
94275ecf5267604f166b85a7ee2cf0d9cb682966680Jouni Malinen					      unsigned int generated_pin)
9438d520ff1dc2da35cdca849e982051b86468016d8Dmitry Shmidt{
94475ecf5267604f166b85a7ee2cf0d9cb682966680Jouni Malinen	DBusMessage *msg;
94575ecf5267604f166b85a7ee2cf0d9cb682966680Jouni Malinen	DBusMessageIter iter;
94675ecf5267604f166b85a7ee2cf0d9cb682966680Jouni Malinen	struct wpas_dbus_priv *iface;
94775ecf5267604f166b85a7ee2cf0d9cb682966680Jouni Malinen	char *_signal;
94875ecf5267604f166b85a7ee2cf0d9cb682966680Jouni Malinen	int add_pin = 0;
94975ecf5267604f166b85a7ee2cf0d9cb682966680Jouni Malinen	char peer_obj_path[WPAS_DBUS_OBJECT_PATH_MAX], *path;
95075ecf5267604f166b85a7ee2cf0d9cb682966680Jouni Malinen	int error_ret = 1;
95175ecf5267604f166b85a7ee2cf0d9cb682966680Jouni Malinen	char pin[9], *p_pin = NULL;
9528d520ff1dc2da35cdca849e982051b86468016d8Dmitry Shmidt
95375ecf5267604f166b85a7ee2cf0d9cb682966680Jouni Malinen	iface = wpa_s->global->dbus;
95475ecf5267604f166b85a7ee2cf0d9cb682966680Jouni Malinen
95575ecf5267604f166b85a7ee2cf0d9cb682966680Jouni Malinen	/* Do nothing if the control interface is not turned on */
95675ecf5267604f166b85a7ee2cf0d9cb682966680Jouni Malinen	if (iface == NULL)
9578d520ff1dc2da35cdca849e982051b86468016d8Dmitry Shmidt		return;
95875ecf5267604f166b85a7ee2cf0d9cb682966680Jouni Malinen
95975ecf5267604f166b85a7ee2cf0d9cb682966680Jouni Malinen	if (request || !status) {
96075ecf5267604f166b85a7ee2cf0d9cb682966680Jouni Malinen		if (config_methods & WPS_CONFIG_DISPLAY)
96175ecf5267604f166b85a7ee2cf0d9cb682966680Jouni Malinen			_signal = request ?
96275ecf5267604f166b85a7ee2cf0d9cb682966680Jouni Malinen				 "ProvisionDiscoveryRequestDisplayPin" :
96375ecf5267604f166b85a7ee2cf0d9cb682966680Jouni Malinen				 "ProvisionDiscoveryResponseEnterPin";
96475ecf5267604f166b85a7ee2cf0d9cb682966680Jouni Malinen		else if (config_methods & WPS_CONFIG_KEYPAD)
96575ecf5267604f166b85a7ee2cf0d9cb682966680Jouni Malinen			_signal = request ?
96675ecf5267604f166b85a7ee2cf0d9cb682966680Jouni Malinen				 "ProvisionDiscoveryRequestEnterPin" :
96775ecf5267604f166b85a7ee2cf0d9cb682966680Jouni Malinen				 "ProvisionDiscoveryResponseDisplayPin";
96875ecf5267604f166b85a7ee2cf0d9cb682966680Jouni Malinen		else if (config_methods & WPS_CONFIG_PUSHBUTTON)
96975ecf5267604f166b85a7ee2cf0d9cb682966680Jouni Malinen			_signal = request ? "ProvisionDiscoveryPBCRequest" :
97075ecf5267604f166b85a7ee2cf0d9cb682966680Jouni Malinen				   "ProvisionDiscoveryPBCResponse";
97175ecf5267604f166b85a7ee2cf0d9cb682966680Jouni Malinen		else
97275ecf5267604f166b85a7ee2cf0d9cb682966680Jouni Malinen			return; /* Unknown or un-supported method */
97375ecf5267604f166b85a7ee2cf0d9cb682966680Jouni Malinen	} else if (!request && status)
97475ecf5267604f166b85a7ee2cf0d9cb682966680Jouni Malinen		/* Explicit check for failure response */
97575ecf5267604f166b85a7ee2cf0d9cb682966680Jouni Malinen		_signal = "ProvisionDiscoveryFailure";
97675ecf5267604f166b85a7ee2cf0d9cb682966680Jouni Malinen
97775ecf5267604f166b85a7ee2cf0d9cb682966680Jouni Malinen	add_pin = ((request && (config_methods & WPS_CONFIG_DISPLAY)) ||
97875ecf5267604f166b85a7ee2cf0d9cb682966680Jouni Malinen		   (!request && !status &&
97975ecf5267604f166b85a7ee2cf0d9cb682966680Jouni Malinen			(config_methods & WPS_CONFIG_KEYPAD)));
98075ecf5267604f166b85a7ee2cf0d9cb682966680Jouni Malinen
98175ecf5267604f166b85a7ee2cf0d9cb682966680Jouni Malinen	if (add_pin) {
98275ecf5267604f166b85a7ee2cf0d9cb682966680Jouni Malinen		os_snprintf(pin, sizeof(pin), "%08d", generated_pin);
98375ecf5267604f166b85a7ee2cf0d9cb682966680Jouni Malinen		p_pin = pin;
9848d520ff1dc2da35cdca849e982051b86468016d8Dmitry Shmidt	}
9858d520ff1dc2da35cdca849e982051b86468016d8Dmitry Shmidt
98675ecf5267604f166b85a7ee2cf0d9cb682966680Jouni Malinen	msg = dbus_message_new_signal(wpa_s->dbus_new_path,
98775ecf5267604f166b85a7ee2cf0d9cb682966680Jouni Malinen				      WPAS_DBUS_NEW_IFACE_P2PDEVICE, _signal);
98875ecf5267604f166b85a7ee2cf0d9cb682966680Jouni Malinen	if (msg == NULL)
98975ecf5267604f166b85a7ee2cf0d9cb682966680Jouni Malinen		return;
9908d520ff1dc2da35cdca849e982051b86468016d8Dmitry Shmidt
99175ecf5267604f166b85a7ee2cf0d9cb682966680Jouni Malinen	/* Check if this is a known peer */
9921f69aa52ea2e0a73ac502565df8c666ee49cab6aDmitry Shmidt	if (!p2p_peer_known(wpa_s->global->p2p, dev_addr))
99375ecf5267604f166b85a7ee2cf0d9cb682966680Jouni Malinen		goto error;
99475ecf5267604f166b85a7ee2cf0d9cb682966680Jouni Malinen
99575ecf5267604f166b85a7ee2cf0d9cb682966680Jouni Malinen	os_snprintf(peer_obj_path, WPAS_DBUS_OBJECT_PATH_MAX,
99675ecf5267604f166b85a7ee2cf0d9cb682966680Jouni Malinen			"%s/" WPAS_DBUS_NEW_P2P_PEERS_PART "/"
99775ecf5267604f166b85a7ee2cf0d9cb682966680Jouni Malinen			COMPACT_MACSTR,
99875ecf5267604f166b85a7ee2cf0d9cb682966680Jouni Malinen			wpa_s->dbus_new_path, MAC2STR(dev_addr));
99975ecf5267604f166b85a7ee2cf0d9cb682966680Jouni Malinen
100075ecf5267604f166b85a7ee2cf0d9cb682966680Jouni Malinen	path = peer_obj_path;
100175ecf5267604f166b85a7ee2cf0d9cb682966680Jouni Malinen
100275ecf5267604f166b85a7ee2cf0d9cb682966680Jouni Malinen	dbus_message_iter_init_append(msg, &iter);
100375ecf5267604f166b85a7ee2cf0d9cb682966680Jouni Malinen
100475ecf5267604f166b85a7ee2cf0d9cb682966680Jouni Malinen	if (!dbus_message_iter_append_basic(&iter,
100575ecf5267604f166b85a7ee2cf0d9cb682966680Jouni Malinen					    DBUS_TYPE_OBJECT_PATH,
100675ecf5267604f166b85a7ee2cf0d9cb682966680Jouni Malinen					    &path))
100775ecf5267604f166b85a7ee2cf0d9cb682966680Jouni Malinen			goto error;
100875ecf5267604f166b85a7ee2cf0d9cb682966680Jouni Malinen
100975ecf5267604f166b85a7ee2cf0d9cb682966680Jouni Malinen	if (!request && status)
101075ecf5267604f166b85a7ee2cf0d9cb682966680Jouni Malinen		/* Attach status to ProvisionDiscoveryFailure */
101175ecf5267604f166b85a7ee2cf0d9cb682966680Jouni Malinen		error_ret = !dbus_message_iter_append_basic(&iter,
101275ecf5267604f166b85a7ee2cf0d9cb682966680Jouni Malinen						    DBUS_TYPE_INT32,
101375ecf5267604f166b85a7ee2cf0d9cb682966680Jouni Malinen						    &status);
101475ecf5267604f166b85a7ee2cf0d9cb682966680Jouni Malinen	else
101575ecf5267604f166b85a7ee2cf0d9cb682966680Jouni Malinen		error_ret = (add_pin &&
101675ecf5267604f166b85a7ee2cf0d9cb682966680Jouni Malinen				 !dbus_message_iter_append_basic(&iter,
101775ecf5267604f166b85a7ee2cf0d9cb682966680Jouni Malinen							DBUS_TYPE_STRING,
101875ecf5267604f166b85a7ee2cf0d9cb682966680Jouni Malinen							&p_pin));
101975ecf5267604f166b85a7ee2cf0d9cb682966680Jouni Malinen
102075ecf5267604f166b85a7ee2cf0d9cb682966680Jouni Malinenerror:
102175ecf5267604f166b85a7ee2cf0d9cb682966680Jouni Malinen	if (!error_ret)
102275ecf5267604f166b85a7ee2cf0d9cb682966680Jouni Malinen		dbus_connection_send(iface->con, msg, NULL);
102375ecf5267604f166b85a7ee2cf0d9cb682966680Jouni Malinen	else
102475ecf5267604f166b85a7ee2cf0d9cb682966680Jouni Malinen		wpa_printf(MSG_ERROR, "dbus: Failed to construct signal");
102575ecf5267604f166b85a7ee2cf0d9cb682966680Jouni Malinen
102675ecf5267604f166b85a7ee2cf0d9cb682966680Jouni Malinen	dbus_message_unref(msg);
10278d520ff1dc2da35cdca849e982051b86468016d8Dmitry Shmidt}
10288d520ff1dc2da35cdca849e982051b86468016d8Dmitry Shmidt
10298d520ff1dc2da35cdca849e982051b86468016d8Dmitry Shmidt
103075ecf5267604f166b85a7ee2cf0d9cb682966680Jouni Malinenvoid wpas_dbus_signal_p2p_go_neg_req(struct wpa_supplicant *wpa_s,
103175ecf5267604f166b85a7ee2cf0d9cb682966680Jouni Malinen				     const u8 *src, u16 dev_passwd_id)
10328d520ff1dc2da35cdca849e982051b86468016d8Dmitry Shmidt{
103375ecf5267604f166b85a7ee2cf0d9cb682966680Jouni Malinen	DBusMessage *msg;
103475ecf5267604f166b85a7ee2cf0d9cb682966680Jouni Malinen	DBusMessageIter iter;
103575ecf5267604f166b85a7ee2cf0d9cb682966680Jouni Malinen	struct wpas_dbus_priv *iface;
103675ecf5267604f166b85a7ee2cf0d9cb682966680Jouni Malinen	char peer_obj_path[WPAS_DBUS_OBJECT_PATH_MAX], *path;
103775ecf5267604f166b85a7ee2cf0d9cb682966680Jouni Malinen
103875ecf5267604f166b85a7ee2cf0d9cb682966680Jouni Malinen	iface = wpa_s->global->dbus;
103975ecf5267604f166b85a7ee2cf0d9cb682966680Jouni Malinen
104075ecf5267604f166b85a7ee2cf0d9cb682966680Jouni Malinen	/* Do nothing if the control interface is not turned on */
104175ecf5267604f166b85a7ee2cf0d9cb682966680Jouni Malinen	if (iface == NULL)
104275ecf5267604f166b85a7ee2cf0d9cb682966680Jouni Malinen		return;
104375ecf5267604f166b85a7ee2cf0d9cb682966680Jouni Malinen
104475ecf5267604f166b85a7ee2cf0d9cb682966680Jouni Malinen	os_snprintf(peer_obj_path, WPAS_DBUS_OBJECT_PATH_MAX,
104575ecf5267604f166b85a7ee2cf0d9cb682966680Jouni Malinen		    "%s/" WPAS_DBUS_NEW_P2P_PEERS_PART "/" COMPACT_MACSTR,
104675ecf5267604f166b85a7ee2cf0d9cb682966680Jouni Malinen		    wpa_s->dbus_new_path, MAC2STR(src));
104775ecf5267604f166b85a7ee2cf0d9cb682966680Jouni Malinen	path = peer_obj_path;
104875ecf5267604f166b85a7ee2cf0d9cb682966680Jouni Malinen
104975ecf5267604f166b85a7ee2cf0d9cb682966680Jouni Malinen	msg = dbus_message_new_signal(wpa_s->dbus_new_path,
105075ecf5267604f166b85a7ee2cf0d9cb682966680Jouni Malinen				      WPAS_DBUS_NEW_IFACE_P2PDEVICE,
105175ecf5267604f166b85a7ee2cf0d9cb682966680Jouni Malinen				      "GONegotiationRequest");
105275ecf5267604f166b85a7ee2cf0d9cb682966680Jouni Malinen	if (msg == NULL)
105375ecf5267604f166b85a7ee2cf0d9cb682966680Jouni Malinen		return;
105475ecf5267604f166b85a7ee2cf0d9cb682966680Jouni Malinen
105575ecf5267604f166b85a7ee2cf0d9cb682966680Jouni Malinen	dbus_message_iter_init_append(msg, &iter);
105675ecf5267604f166b85a7ee2cf0d9cb682966680Jouni Malinen
105775ecf5267604f166b85a7ee2cf0d9cb682966680Jouni Malinen	if (!dbus_message_iter_append_basic(&iter, DBUS_TYPE_OBJECT_PATH,
105875ecf5267604f166b85a7ee2cf0d9cb682966680Jouni Malinen					    &path) ||
105975ecf5267604f166b85a7ee2cf0d9cb682966680Jouni Malinen	    !dbus_message_iter_append_basic(&iter, DBUS_TYPE_UINT16,
106075ecf5267604f166b85a7ee2cf0d9cb682966680Jouni Malinen					    &dev_passwd_id))
106175ecf5267604f166b85a7ee2cf0d9cb682966680Jouni Malinen		wpa_printf(MSG_ERROR, "dbus: Failed to construct signal");
106275ecf5267604f166b85a7ee2cf0d9cb682966680Jouni Malinen	else
106375ecf5267604f166b85a7ee2cf0d9cb682966680Jouni Malinen		dbus_connection_send(iface->con, msg, NULL);
106475ecf5267604f166b85a7ee2cf0d9cb682966680Jouni Malinen
106575ecf5267604f166b85a7ee2cf0d9cb682966680Jouni Malinen	dbus_message_unref(msg);
106675ecf5267604f166b85a7ee2cf0d9cb682966680Jouni Malinen}
106775ecf5267604f166b85a7ee2cf0d9cb682966680Jouni Malinen
106875ecf5267604f166b85a7ee2cf0d9cb682966680Jouni Malinen
106975ecf5267604f166b85a7ee2cf0d9cb682966680Jouni Malinenstatic int wpas_dbus_get_group_obj_path(struct wpa_supplicant *wpa_s,
107075ecf5267604f166b85a7ee2cf0d9cb682966680Jouni Malinen					const struct wpa_ssid *ssid,
107175ecf5267604f166b85a7ee2cf0d9cb682966680Jouni Malinen					char *group_obj_path)
107275ecf5267604f166b85a7ee2cf0d9cb682966680Jouni Malinen{
107375ecf5267604f166b85a7ee2cf0d9cb682966680Jouni Malinen	char group_name[3];
107475ecf5267604f166b85a7ee2cf0d9cb682966680Jouni Malinen
107575ecf5267604f166b85a7ee2cf0d9cb682966680Jouni Malinen	if (os_memcmp(ssid->ssid, P2P_WILDCARD_SSID, P2P_WILDCARD_SSID_LEN))
107675ecf5267604f166b85a7ee2cf0d9cb682966680Jouni Malinen		return -1;
107775ecf5267604f166b85a7ee2cf0d9cb682966680Jouni Malinen
107804949598a23f501be6eec21697465fd46a28840aDmitry Shmidt	os_memcpy(group_name, ssid->ssid + P2P_WILDCARD_SSID_LEN, 2);
107975ecf5267604f166b85a7ee2cf0d9cb682966680Jouni Malinen	group_name[2] = '\0';
108075ecf5267604f166b85a7ee2cf0d9cb682966680Jouni Malinen
108175ecf5267604f166b85a7ee2cf0d9cb682966680Jouni Malinen	os_snprintf(group_obj_path, WPAS_DBUS_OBJECT_PATH_MAX,
108275ecf5267604f166b85a7ee2cf0d9cb682966680Jouni Malinen		    "%s/" WPAS_DBUS_NEW_P2P_GROUPS_PART "/%s",
108375ecf5267604f166b85a7ee2cf0d9cb682966680Jouni Malinen		    wpa_s->dbus_new_path, group_name);
108475ecf5267604f166b85a7ee2cf0d9cb682966680Jouni Malinen
108575ecf5267604f166b85a7ee2cf0d9cb682966680Jouni Malinen	return 0;
10868d520ff1dc2da35cdca849e982051b86468016d8Dmitry Shmidt}
10878d520ff1dc2da35cdca849e982051b86468016d8Dmitry Shmidt
10888d520ff1dc2da35cdca849e982051b86468016d8Dmitry Shmidt
10898d520ff1dc2da35cdca849e982051b86468016d8Dmitry Shmidt/**
109075ecf5267604f166b85a7ee2cf0d9cb682966680Jouni Malinen * wpas_dbus_signal_p2p_group_started - Signals P2P group has
10911f69aa52ea2e0a73ac502565df8c666ee49cab6aDmitry Shmidt * started. Emitted when a group is successfully started
109275ecf5267604f166b85a7ee2cf0d9cb682966680Jouni Malinen * irrespective of the role (client/GO) of the current device
10938d520ff1dc2da35cdca849e982051b86468016d8Dmitry Shmidt *
109475ecf5267604f166b85a7ee2cf0d9cb682966680Jouni Malinen * @wpa_s: %wpa_supplicant network interface data
109575ecf5267604f166b85a7ee2cf0d9cb682966680Jouni Malinen * @ssid: SSID object
109675ecf5267604f166b85a7ee2cf0d9cb682966680Jouni Malinen * @client: this device is P2P client
109775ecf5267604f166b85a7ee2cf0d9cb682966680Jouni Malinen * @network_id: network id of the group started, use instead of ssid->id
109875ecf5267604f166b85a7ee2cf0d9cb682966680Jouni Malinen *	to account for persistent groups
10998d520ff1dc2da35cdca849e982051b86468016d8Dmitry Shmidt */
110075ecf5267604f166b85a7ee2cf0d9cb682966680Jouni Malinenvoid wpas_dbus_signal_p2p_group_started(struct wpa_supplicant *wpa_s,
110175ecf5267604f166b85a7ee2cf0d9cb682966680Jouni Malinen					const struct wpa_ssid *ssid,
110275ecf5267604f166b85a7ee2cf0d9cb682966680Jouni Malinen					int client, int network_id)
11038d520ff1dc2da35cdca849e982051b86468016d8Dmitry Shmidt{
110475ecf5267604f166b85a7ee2cf0d9cb682966680Jouni Malinen	DBusMessage *msg;
110575ecf5267604f166b85a7ee2cf0d9cb682966680Jouni Malinen	DBusMessageIter iter, dict_iter;
110675ecf5267604f166b85a7ee2cf0d9cb682966680Jouni Malinen	struct wpas_dbus_priv *iface;
110775ecf5267604f166b85a7ee2cf0d9cb682966680Jouni Malinen	char group_obj_path[WPAS_DBUS_OBJECT_PATH_MAX];
110875ecf5267604f166b85a7ee2cf0d9cb682966680Jouni Malinen
110975ecf5267604f166b85a7ee2cf0d9cb682966680Jouni Malinen	iface = wpa_s->parent->global->dbus;
111075ecf5267604f166b85a7ee2cf0d9cb682966680Jouni Malinen
111175ecf5267604f166b85a7ee2cf0d9cb682966680Jouni Malinen	/* Do nothing if the control interface is not turned on */
111275ecf5267604f166b85a7ee2cf0d9cb682966680Jouni Malinen	if (iface == NULL)
111375ecf5267604f166b85a7ee2cf0d9cb682966680Jouni Malinen		return;
111475ecf5267604f166b85a7ee2cf0d9cb682966680Jouni Malinen
111575ecf5267604f166b85a7ee2cf0d9cb682966680Jouni Malinen	if (wpas_dbus_get_group_obj_path(wpa_s, ssid, group_obj_path) < 0)
111675ecf5267604f166b85a7ee2cf0d9cb682966680Jouni Malinen		return;
111775ecf5267604f166b85a7ee2cf0d9cb682966680Jouni Malinen
111875ecf5267604f166b85a7ee2cf0d9cb682966680Jouni Malinen	/* New interface has been created for this group */
111975ecf5267604f166b85a7ee2cf0d9cb682966680Jouni Malinen	msg = dbus_message_new_signal(wpa_s->parent->dbus_new_path,
112075ecf5267604f166b85a7ee2cf0d9cb682966680Jouni Malinen				      WPAS_DBUS_NEW_IFACE_P2PDEVICE,
112175ecf5267604f166b85a7ee2cf0d9cb682966680Jouni Malinen				      "GroupStarted");
112275ecf5267604f166b85a7ee2cf0d9cb682966680Jouni Malinen
112375ecf5267604f166b85a7ee2cf0d9cb682966680Jouni Malinen	if (msg == NULL)
112475ecf5267604f166b85a7ee2cf0d9cb682966680Jouni Malinen		return;
112575ecf5267604f166b85a7ee2cf0d9cb682966680Jouni Malinen
112675ecf5267604f166b85a7ee2cf0d9cb682966680Jouni Malinen	dbus_message_iter_init_append(msg, &iter);
112775ecf5267604f166b85a7ee2cf0d9cb682966680Jouni Malinen	if (!wpa_dbus_dict_open_write(&iter, &dict_iter))
112875ecf5267604f166b85a7ee2cf0d9cb682966680Jouni Malinen		goto nomem;
112975ecf5267604f166b85a7ee2cf0d9cb682966680Jouni Malinen
113075ecf5267604f166b85a7ee2cf0d9cb682966680Jouni Malinen	/*
113175ecf5267604f166b85a7ee2cf0d9cb682966680Jouni Malinen	 * In case the device supports creating a separate interface the
113275ecf5267604f166b85a7ee2cf0d9cb682966680Jouni Malinen	 * DBus client will need to know the object path for the interface
113375ecf5267604f166b85a7ee2cf0d9cb682966680Jouni Malinen	 * object this group was created on, so include it here.
113475ecf5267604f166b85a7ee2cf0d9cb682966680Jouni Malinen	 */
113575ecf5267604f166b85a7ee2cf0d9cb682966680Jouni Malinen	if (!wpa_dbus_dict_append_object_path(&dict_iter,
113675ecf5267604f166b85a7ee2cf0d9cb682966680Jouni Malinen					"interface_object",
113775ecf5267604f166b85a7ee2cf0d9cb682966680Jouni Malinen					wpa_s->dbus_new_path))
113875ecf5267604f166b85a7ee2cf0d9cb682966680Jouni Malinen		goto nomem;
113975ecf5267604f166b85a7ee2cf0d9cb682966680Jouni Malinen
114075ecf5267604f166b85a7ee2cf0d9cb682966680Jouni Malinen	if (!wpa_dbus_dict_append_string(&dict_iter, "role",
114175ecf5267604f166b85a7ee2cf0d9cb682966680Jouni Malinen					 client ? "client" : "GO"))
114275ecf5267604f166b85a7ee2cf0d9cb682966680Jouni Malinen		goto nomem;
114375ecf5267604f166b85a7ee2cf0d9cb682966680Jouni Malinen
114475ecf5267604f166b85a7ee2cf0d9cb682966680Jouni Malinen	if (!wpa_dbus_dict_append_object_path(&dict_iter, "group_object",
114575ecf5267604f166b85a7ee2cf0d9cb682966680Jouni Malinen					     group_obj_path) ||
114675ecf5267604f166b85a7ee2cf0d9cb682966680Jouni Malinen	   !wpa_dbus_dict_close_write(&iter, &dict_iter))
114775ecf5267604f166b85a7ee2cf0d9cb682966680Jouni Malinen		goto nomem;
114875ecf5267604f166b85a7ee2cf0d9cb682966680Jouni Malinen
114975ecf5267604f166b85a7ee2cf0d9cb682966680Jouni Malinen	dbus_connection_send(iface->con, msg, NULL);
115075ecf5267604f166b85a7ee2cf0d9cb682966680Jouni Malinen
115175ecf5267604f166b85a7ee2cf0d9cb682966680Jouni Malinennomem:
115275ecf5267604f166b85a7ee2cf0d9cb682966680Jouni Malinen	dbus_message_unref(msg);
11538d520ff1dc2da35cdca849e982051b86468016d8Dmitry Shmidt}
11548d520ff1dc2da35cdca849e982051b86468016d8Dmitry Shmidt
11558d520ff1dc2da35cdca849e982051b86468016d8Dmitry Shmidt
11568d520ff1dc2da35cdca849e982051b86468016d8Dmitry Shmidt/**
11578d520ff1dc2da35cdca849e982051b86468016d8Dmitry Shmidt *
115875ecf5267604f166b85a7ee2cf0d9cb682966680Jouni Malinen * Method to emit GONeogtiation Success or Failure signals based
115975ecf5267604f166b85a7ee2cf0d9cb682966680Jouni Malinen * on status.
116075ecf5267604f166b85a7ee2cf0d9cb682966680Jouni Malinen * @status: Status of the GO neg request. 0 for success, other for errors.
11618d520ff1dc2da35cdca849e982051b86468016d8Dmitry Shmidt */
11621f69aa52ea2e0a73ac502565df8c666ee49cab6aDmitry Shmidtvoid wpas_dbus_signal_p2p_go_neg_resp(struct wpa_supplicant *wpa_s,
11631f69aa52ea2e0a73ac502565df8c666ee49cab6aDmitry Shmidt				      struct p2p_go_neg_results *res)
11648d520ff1dc2da35cdca849e982051b86468016d8Dmitry Shmidt{
116575ecf5267604f166b85a7ee2cf0d9cb682966680Jouni Malinen	DBusMessage *msg;
11661f69aa52ea2e0a73ac502565df8c666ee49cab6aDmitry Shmidt	DBusMessageIter iter, dict_iter;
11671f69aa52ea2e0a73ac502565df8c666ee49cab6aDmitry Shmidt	DBusMessageIter iter_dict_entry, iter_dict_val, iter_dict_array;
116875ecf5267604f166b85a7ee2cf0d9cb682966680Jouni Malinen	struct wpas_dbus_priv *iface;
11691f69aa52ea2e0a73ac502565df8c666ee49cab6aDmitry Shmidt	char peer_obj_path[WPAS_DBUS_OBJECT_PATH_MAX], *path;
11701f69aa52ea2e0a73ac502565df8c666ee49cab6aDmitry Shmidt	dbus_int32_t freqs[P2P_MAX_CHANNELS];
11711f69aa52ea2e0a73ac502565df8c666ee49cab6aDmitry Shmidt	dbus_int32_t *f_array = freqs;
11721f69aa52ea2e0a73ac502565df8c666ee49cab6aDmitry Shmidt
11738d520ff1dc2da35cdca849e982051b86468016d8Dmitry Shmidt
117475ecf5267604f166b85a7ee2cf0d9cb682966680Jouni Malinen	iface = wpa_s->global->dbus;
11758d520ff1dc2da35cdca849e982051b86468016d8Dmitry Shmidt
11761f69aa52ea2e0a73ac502565df8c666ee49cab6aDmitry Shmidt	os_memset(freqs, 0, sizeof(freqs));
117775ecf5267604f166b85a7ee2cf0d9cb682966680Jouni Malinen	/* Do nothing if the control interface is not turned on */
117875ecf5267604f166b85a7ee2cf0d9cb682966680Jouni Malinen	if (iface == NULL)
117975ecf5267604f166b85a7ee2cf0d9cb682966680Jouni Malinen		return;
11808d520ff1dc2da35cdca849e982051b86468016d8Dmitry Shmidt
11811f69aa52ea2e0a73ac502565df8c666ee49cab6aDmitry Shmidt	os_snprintf(peer_obj_path, WPAS_DBUS_OBJECT_PATH_MAX,
11821f69aa52ea2e0a73ac502565df8c666ee49cab6aDmitry Shmidt		    "%s/" WPAS_DBUS_NEW_P2P_PEERS_PART "/" COMPACT_MACSTR,
11831f69aa52ea2e0a73ac502565df8c666ee49cab6aDmitry Shmidt		    wpa_s->dbus_new_path, MAC2STR(res->peer_device_addr));
11841f69aa52ea2e0a73ac502565df8c666ee49cab6aDmitry Shmidt	path = peer_obj_path;
11851f69aa52ea2e0a73ac502565df8c666ee49cab6aDmitry Shmidt
118675ecf5267604f166b85a7ee2cf0d9cb682966680Jouni Malinen	msg = dbus_message_new_signal(wpa_s->dbus_new_path,
118775ecf5267604f166b85a7ee2cf0d9cb682966680Jouni Malinen				      WPAS_DBUS_NEW_IFACE_P2PDEVICE,
11881f69aa52ea2e0a73ac502565df8c666ee49cab6aDmitry Shmidt				      res->status ? "GONegotiationFailure" :
11891f69aa52ea2e0a73ac502565df8c666ee49cab6aDmitry Shmidt						    "GONegotiationSuccess");
119075ecf5267604f166b85a7ee2cf0d9cb682966680Jouni Malinen	if (msg == NULL)
119175ecf5267604f166b85a7ee2cf0d9cb682966680Jouni Malinen		return;
11928d520ff1dc2da35cdca849e982051b86468016d8Dmitry Shmidt
11931f69aa52ea2e0a73ac502565df8c666ee49cab6aDmitry Shmidt	dbus_message_iter_init_append(msg, &iter);
11941f69aa52ea2e0a73ac502565df8c666ee49cab6aDmitry Shmidt	if (!wpa_dbus_dict_open_write(&iter, &dict_iter))
11951f69aa52ea2e0a73ac502565df8c666ee49cab6aDmitry Shmidt		goto err;
11961f69aa52ea2e0a73ac502565df8c666ee49cab6aDmitry Shmidt	if (!wpa_dbus_dict_append_object_path(&dict_iter, "peer_object",
11971f69aa52ea2e0a73ac502565df8c666ee49cab6aDmitry Shmidt					      path) ||
11981f69aa52ea2e0a73ac502565df8c666ee49cab6aDmitry Shmidt	    !wpa_dbus_dict_append_int32(&dict_iter, "status", res->status))
11991f69aa52ea2e0a73ac502565df8c666ee49cab6aDmitry Shmidt		goto err;
12001f69aa52ea2e0a73ac502565df8c666ee49cab6aDmitry Shmidt
12011f69aa52ea2e0a73ac502565df8c666ee49cab6aDmitry Shmidt	if (!res->status) {
12021f69aa52ea2e0a73ac502565df8c666ee49cab6aDmitry Shmidt		int i = 0;
12031f69aa52ea2e0a73ac502565df8c666ee49cab6aDmitry Shmidt		int freq_list_num = 0;
12041f69aa52ea2e0a73ac502565df8c666ee49cab6aDmitry Shmidt
12051f69aa52ea2e0a73ac502565df8c666ee49cab6aDmitry Shmidt		if (res->role_go) {
12061f69aa52ea2e0a73ac502565df8c666ee49cab6aDmitry Shmidt			if (!wpa_dbus_dict_append_byte_array(
12071f69aa52ea2e0a73ac502565df8c666ee49cab6aDmitry Shmidt				    &dict_iter, "passphrase",
12081f69aa52ea2e0a73ac502565df8c666ee49cab6aDmitry Shmidt				    (const char *) res->passphrase,
12091f69aa52ea2e0a73ac502565df8c666ee49cab6aDmitry Shmidt				    sizeof(res->passphrase)))
12101f69aa52ea2e0a73ac502565df8c666ee49cab6aDmitry Shmidt				goto err;
12111f69aa52ea2e0a73ac502565df8c666ee49cab6aDmitry Shmidt		}
12121f69aa52ea2e0a73ac502565df8c666ee49cab6aDmitry Shmidt
12131f69aa52ea2e0a73ac502565df8c666ee49cab6aDmitry Shmidt		if (!wpa_dbus_dict_append_string(&dict_iter, "role_go",
12141f69aa52ea2e0a73ac502565df8c666ee49cab6aDmitry Shmidt						 res->role_go ? "GO" :
12151f69aa52ea2e0a73ac502565df8c666ee49cab6aDmitry Shmidt						 "client") ||
12161f69aa52ea2e0a73ac502565df8c666ee49cab6aDmitry Shmidt		    !wpa_dbus_dict_append_int32(&dict_iter, "frequency",
12171f69aa52ea2e0a73ac502565df8c666ee49cab6aDmitry Shmidt						res->freq) ||
12181f69aa52ea2e0a73ac502565df8c666ee49cab6aDmitry Shmidt		    !wpa_dbus_dict_append_byte_array(&dict_iter, "ssid",
12191f69aa52ea2e0a73ac502565df8c666ee49cab6aDmitry Shmidt						     (const char *) res->ssid,
12201f69aa52ea2e0a73ac502565df8c666ee49cab6aDmitry Shmidt						     res->ssid_len) ||
12211f69aa52ea2e0a73ac502565df8c666ee49cab6aDmitry Shmidt		    !wpa_dbus_dict_append_byte_array(&dict_iter,
12221f69aa52ea2e0a73ac502565df8c666ee49cab6aDmitry Shmidt						     "peer_device_addr",
12231f69aa52ea2e0a73ac502565df8c666ee49cab6aDmitry Shmidt						     (const char *)
12241f69aa52ea2e0a73ac502565df8c666ee49cab6aDmitry Shmidt						     res->peer_device_addr,
12251f69aa52ea2e0a73ac502565df8c666ee49cab6aDmitry Shmidt						     ETH_ALEN) ||
12261f69aa52ea2e0a73ac502565df8c666ee49cab6aDmitry Shmidt		    !wpa_dbus_dict_append_byte_array(&dict_iter,
12271f69aa52ea2e0a73ac502565df8c666ee49cab6aDmitry Shmidt						     "peer_interface_addr",
12281f69aa52ea2e0a73ac502565df8c666ee49cab6aDmitry Shmidt						     (const char *)
12291f69aa52ea2e0a73ac502565df8c666ee49cab6aDmitry Shmidt						     res->peer_interface_addr,
12301f69aa52ea2e0a73ac502565df8c666ee49cab6aDmitry Shmidt						     ETH_ALEN) ||
12311f69aa52ea2e0a73ac502565df8c666ee49cab6aDmitry Shmidt		    !wpa_dbus_dict_append_string(&dict_iter, "wps_method",
12321f69aa52ea2e0a73ac502565df8c666ee49cab6aDmitry Shmidt						 p2p_wps_method_text(
12331f69aa52ea2e0a73ac502565df8c666ee49cab6aDmitry Shmidt							 res->wps_method)))
123475ecf5267604f166b85a7ee2cf0d9cb682966680Jouni Malinen			goto err;
12351f69aa52ea2e0a73ac502565df8c666ee49cab6aDmitry Shmidt
12361f69aa52ea2e0a73ac502565df8c666ee49cab6aDmitry Shmidt		for (i = 0; i < P2P_MAX_CHANNELS; i++) {
12371f69aa52ea2e0a73ac502565df8c666ee49cab6aDmitry Shmidt			if (res->freq_list[i]) {
12381f69aa52ea2e0a73ac502565df8c666ee49cab6aDmitry Shmidt				freqs[i] = res->freq_list[i];
12391f69aa52ea2e0a73ac502565df8c666ee49cab6aDmitry Shmidt				freq_list_num++;
12401f69aa52ea2e0a73ac502565df8c666ee49cab6aDmitry Shmidt			}
124175ecf5267604f166b85a7ee2cf0d9cb682966680Jouni Malinen		}
12421f69aa52ea2e0a73ac502565df8c666ee49cab6aDmitry Shmidt
12431f69aa52ea2e0a73ac502565df8c666ee49cab6aDmitry Shmidt		if (!wpa_dbus_dict_begin_array(&dict_iter,
12441f69aa52ea2e0a73ac502565df8c666ee49cab6aDmitry Shmidt					       "frequency_list",
12451f69aa52ea2e0a73ac502565df8c666ee49cab6aDmitry Shmidt					       DBUS_TYPE_INT32_AS_STRING,
12461f69aa52ea2e0a73ac502565df8c666ee49cab6aDmitry Shmidt					       &iter_dict_entry,
12471f69aa52ea2e0a73ac502565df8c666ee49cab6aDmitry Shmidt					       &iter_dict_val,
12481f69aa52ea2e0a73ac502565df8c666ee49cab6aDmitry Shmidt					       &iter_dict_array))
12491f69aa52ea2e0a73ac502565df8c666ee49cab6aDmitry Shmidt			goto err;
12501f69aa52ea2e0a73ac502565df8c666ee49cab6aDmitry Shmidt
12511f69aa52ea2e0a73ac502565df8c666ee49cab6aDmitry Shmidt		if (!dbus_message_iter_append_fixed_array(&iter_dict_array,
12521f69aa52ea2e0a73ac502565df8c666ee49cab6aDmitry Shmidt							  DBUS_TYPE_INT32,
12531f69aa52ea2e0a73ac502565df8c666ee49cab6aDmitry Shmidt							  &f_array,
12541f69aa52ea2e0a73ac502565df8c666ee49cab6aDmitry Shmidt							  freq_list_num))
12551f69aa52ea2e0a73ac502565df8c666ee49cab6aDmitry Shmidt			goto err;
12561f69aa52ea2e0a73ac502565df8c666ee49cab6aDmitry Shmidt
12571f69aa52ea2e0a73ac502565df8c666ee49cab6aDmitry Shmidt		if (!wpa_dbus_dict_end_array(&dict_iter,
12581f69aa52ea2e0a73ac502565df8c666ee49cab6aDmitry Shmidt					     &iter_dict_entry,
12591f69aa52ea2e0a73ac502565df8c666ee49cab6aDmitry Shmidt					     &iter_dict_val,
12601f69aa52ea2e0a73ac502565df8c666ee49cab6aDmitry Shmidt					     &iter_dict_array))
12611f69aa52ea2e0a73ac502565df8c666ee49cab6aDmitry Shmidt			goto err;
12621f69aa52ea2e0a73ac502565df8c666ee49cab6aDmitry Shmidt
12631f69aa52ea2e0a73ac502565df8c666ee49cab6aDmitry Shmidt		if (!wpa_dbus_dict_append_int32(&dict_iter, "persistent_group",
12641f69aa52ea2e0a73ac502565df8c666ee49cab6aDmitry Shmidt						res->persistent_group) ||
12651f69aa52ea2e0a73ac502565df8c666ee49cab6aDmitry Shmidt		    !wpa_dbus_dict_append_uint32(&dict_iter,
12661f69aa52ea2e0a73ac502565df8c666ee49cab6aDmitry Shmidt						 "peer_config_timeout",
12671f69aa52ea2e0a73ac502565df8c666ee49cab6aDmitry Shmidt						 res->peer_config_timeout))
12681f69aa52ea2e0a73ac502565df8c666ee49cab6aDmitry Shmidt			goto err;
126975ecf5267604f166b85a7ee2cf0d9cb682966680Jouni Malinen	}
12708d520ff1dc2da35cdca849e982051b86468016d8Dmitry Shmidt
12711f69aa52ea2e0a73ac502565df8c666ee49cab6aDmitry Shmidt	if (!wpa_dbus_dict_close_write(&iter, &dict_iter))
12721f69aa52ea2e0a73ac502565df8c666ee49cab6aDmitry Shmidt		goto err;
12731f69aa52ea2e0a73ac502565df8c666ee49cab6aDmitry Shmidt
127475ecf5267604f166b85a7ee2cf0d9cb682966680Jouni Malinen	dbus_connection_send(iface->con, msg, NULL);
127575ecf5267604f166b85a7ee2cf0d9cb682966680Jouni Malinenerr:
127675ecf5267604f166b85a7ee2cf0d9cb682966680Jouni Malinen	dbus_message_unref(msg);
12778d520ff1dc2da35cdca849e982051b86468016d8Dmitry Shmidt}
12788d520ff1dc2da35cdca849e982051b86468016d8Dmitry Shmidt
12798d520ff1dc2da35cdca849e982051b86468016d8Dmitry Shmidt
128075ecf5267604f166b85a7ee2cf0d9cb682966680Jouni Malinen/**
128175ecf5267604f166b85a7ee2cf0d9cb682966680Jouni Malinen *
128275ecf5267604f166b85a7ee2cf0d9cb682966680Jouni Malinen * Method to emit Invitation Result signal based on status and
128375ecf5267604f166b85a7ee2cf0d9cb682966680Jouni Malinen * bssid
128475ecf5267604f166b85a7ee2cf0d9cb682966680Jouni Malinen * @status: Status of the Invite request. 0 for success, other
128575ecf5267604f166b85a7ee2cf0d9cb682966680Jouni Malinen * for errors
128675ecf5267604f166b85a7ee2cf0d9cb682966680Jouni Malinen * @bssid : Basic Service Set Identifier
128775ecf5267604f166b85a7ee2cf0d9cb682966680Jouni Malinen */
128875ecf5267604f166b85a7ee2cf0d9cb682966680Jouni Malinenvoid wpas_dbus_signal_p2p_invitation_result(struct wpa_supplicant *wpa_s,
128975ecf5267604f166b85a7ee2cf0d9cb682966680Jouni Malinen					    int status, const u8 *bssid)
129075ecf5267604f166b85a7ee2cf0d9cb682966680Jouni Malinen{
129175ecf5267604f166b85a7ee2cf0d9cb682966680Jouni Malinen	DBusMessage *msg;
129275ecf5267604f166b85a7ee2cf0d9cb682966680Jouni Malinen	DBusMessageIter iter, dict_iter;
129375ecf5267604f166b85a7ee2cf0d9cb682966680Jouni Malinen	struct wpas_dbus_priv *iface;
129475ecf5267604f166b85a7ee2cf0d9cb682966680Jouni Malinen
129575ecf5267604f166b85a7ee2cf0d9cb682966680Jouni Malinen	wpa_printf(MSG_INFO, "%s\n", __func__);
129675ecf5267604f166b85a7ee2cf0d9cb682966680Jouni Malinen
129775ecf5267604f166b85a7ee2cf0d9cb682966680Jouni Malinen	iface = wpa_s->global->dbus;
129875ecf5267604f166b85a7ee2cf0d9cb682966680Jouni Malinen	/* Do nothing if the control interface is not turned on */
129975ecf5267604f166b85a7ee2cf0d9cb682966680Jouni Malinen	if (iface == NULL)
130075ecf5267604f166b85a7ee2cf0d9cb682966680Jouni Malinen		return;
130175ecf5267604f166b85a7ee2cf0d9cb682966680Jouni Malinen
130275ecf5267604f166b85a7ee2cf0d9cb682966680Jouni Malinen	msg = dbus_message_new_signal(wpa_s->dbus_new_path,
130375ecf5267604f166b85a7ee2cf0d9cb682966680Jouni Malinen				      WPAS_DBUS_NEW_IFACE_P2PDEVICE,
130475ecf5267604f166b85a7ee2cf0d9cb682966680Jouni Malinen				      "InvitationResult");
130575ecf5267604f166b85a7ee2cf0d9cb682966680Jouni Malinen
130675ecf5267604f166b85a7ee2cf0d9cb682966680Jouni Malinen	if (msg == NULL)
130775ecf5267604f166b85a7ee2cf0d9cb682966680Jouni Malinen		return;
130875ecf5267604f166b85a7ee2cf0d9cb682966680Jouni Malinen
130975ecf5267604f166b85a7ee2cf0d9cb682966680Jouni Malinen	dbus_message_iter_init_append(msg, &iter);
131075ecf5267604f166b85a7ee2cf0d9cb682966680Jouni Malinen	if (!wpa_dbus_dict_open_write(&iter, &dict_iter))
131175ecf5267604f166b85a7ee2cf0d9cb682966680Jouni Malinen		goto nomem;
131275ecf5267604f166b85a7ee2cf0d9cb682966680Jouni Malinen
131375ecf5267604f166b85a7ee2cf0d9cb682966680Jouni Malinen	if (!wpa_dbus_dict_append_int32(&dict_iter, "status", status))
131475ecf5267604f166b85a7ee2cf0d9cb682966680Jouni Malinen		goto nomem;
131575ecf5267604f166b85a7ee2cf0d9cb682966680Jouni Malinen	if (bssid) {
131675ecf5267604f166b85a7ee2cf0d9cb682966680Jouni Malinen		if (!wpa_dbus_dict_append_byte_array(&dict_iter, "BSSID",
131775ecf5267604f166b85a7ee2cf0d9cb682966680Jouni Malinen						     (const char *) bssid,
131875ecf5267604f166b85a7ee2cf0d9cb682966680Jouni Malinen						     ETH_ALEN))
131975ecf5267604f166b85a7ee2cf0d9cb682966680Jouni Malinen			goto nomem;
132075ecf5267604f166b85a7ee2cf0d9cb682966680Jouni Malinen	}
132175ecf5267604f166b85a7ee2cf0d9cb682966680Jouni Malinen	if (!wpa_dbus_dict_close_write(&iter, &dict_iter))
132275ecf5267604f166b85a7ee2cf0d9cb682966680Jouni Malinen		goto nomem;
132375ecf5267604f166b85a7ee2cf0d9cb682966680Jouni Malinen
132475ecf5267604f166b85a7ee2cf0d9cb682966680Jouni Malinen	dbus_connection_send(iface->con, msg, NULL);
132575ecf5267604f166b85a7ee2cf0d9cb682966680Jouni Malinen
132675ecf5267604f166b85a7ee2cf0d9cb682966680Jouni Malinennomem:
132775ecf5267604f166b85a7ee2cf0d9cb682966680Jouni Malinen	dbus_message_unref(msg);
132875ecf5267604f166b85a7ee2cf0d9cb682966680Jouni Malinen}
132975ecf5267604f166b85a7ee2cf0d9cb682966680Jouni Malinen
133075ecf5267604f166b85a7ee2cf0d9cb682966680Jouni Malinen
133175ecf5267604f166b85a7ee2cf0d9cb682966680Jouni Malinen/**
133275ecf5267604f166b85a7ee2cf0d9cb682966680Jouni Malinen *
133375ecf5267604f166b85a7ee2cf0d9cb682966680Jouni Malinen * Method to emit a signal for a peer joining the group.
133475ecf5267604f166b85a7ee2cf0d9cb682966680Jouni Malinen * The signal will carry path to the group member object
133575ecf5267604f166b85a7ee2cf0d9cb682966680Jouni Malinen * constructed using p2p i/f addr used for connecting.
133675ecf5267604f166b85a7ee2cf0d9cb682966680Jouni Malinen *
133775ecf5267604f166b85a7ee2cf0d9cb682966680Jouni Malinen * @wpa_s: %wpa_supplicant network interface data
133875ecf5267604f166b85a7ee2cf0d9cb682966680Jouni Malinen * @member_addr: addr (p2p i/f) of the peer joining the group
133975ecf5267604f166b85a7ee2cf0d9cb682966680Jouni Malinen */
134075ecf5267604f166b85a7ee2cf0d9cb682966680Jouni Malinenvoid wpas_dbus_signal_p2p_peer_joined(struct wpa_supplicant *wpa_s,
134175ecf5267604f166b85a7ee2cf0d9cb682966680Jouni Malinen				      const u8 *member)
134275ecf5267604f166b85a7ee2cf0d9cb682966680Jouni Malinen{
134375ecf5267604f166b85a7ee2cf0d9cb682966680Jouni Malinen	struct wpas_dbus_priv *iface;
134475ecf5267604f166b85a7ee2cf0d9cb682966680Jouni Malinen	DBusMessage *msg;
134575ecf5267604f166b85a7ee2cf0d9cb682966680Jouni Malinen	DBusMessageIter iter;
134675ecf5267604f166b85a7ee2cf0d9cb682966680Jouni Malinen	char groupmember_obj_path[WPAS_DBUS_OBJECT_PATH_MAX], *path;
134775ecf5267604f166b85a7ee2cf0d9cb682966680Jouni Malinen
134875ecf5267604f166b85a7ee2cf0d9cb682966680Jouni Malinen	iface = wpa_s->global->dbus;
134975ecf5267604f166b85a7ee2cf0d9cb682966680Jouni Malinen
135075ecf5267604f166b85a7ee2cf0d9cb682966680Jouni Malinen	/* Do nothing if the control interface is not turned on */
135175ecf5267604f166b85a7ee2cf0d9cb682966680Jouni Malinen	if (iface == NULL)
135275ecf5267604f166b85a7ee2cf0d9cb682966680Jouni Malinen		return;
135375ecf5267604f166b85a7ee2cf0d9cb682966680Jouni Malinen
135475ecf5267604f166b85a7ee2cf0d9cb682966680Jouni Malinen	if (!wpa_s->dbus_groupobj_path)
135575ecf5267604f166b85a7ee2cf0d9cb682966680Jouni Malinen		return;
135675ecf5267604f166b85a7ee2cf0d9cb682966680Jouni Malinen
135775ecf5267604f166b85a7ee2cf0d9cb682966680Jouni Malinen	os_snprintf(groupmember_obj_path, WPAS_DBUS_OBJECT_PATH_MAX,
135875ecf5267604f166b85a7ee2cf0d9cb682966680Jouni Malinen			"%s/"  WPAS_DBUS_NEW_P2P_GROUPMEMBERS_PART "/"
135975ecf5267604f166b85a7ee2cf0d9cb682966680Jouni Malinen			COMPACT_MACSTR,
136075ecf5267604f166b85a7ee2cf0d9cb682966680Jouni Malinen			wpa_s->dbus_groupobj_path, MAC2STR(member));
136175ecf5267604f166b85a7ee2cf0d9cb682966680Jouni Malinen
136275ecf5267604f166b85a7ee2cf0d9cb682966680Jouni Malinen	msg = dbus_message_new_signal(wpa_s->dbus_groupobj_path,
136375ecf5267604f166b85a7ee2cf0d9cb682966680Jouni Malinen				      WPAS_DBUS_NEW_IFACE_P2P_GROUP,
136475ecf5267604f166b85a7ee2cf0d9cb682966680Jouni Malinen				      "PeerJoined");
136575ecf5267604f166b85a7ee2cf0d9cb682966680Jouni Malinen	if (msg == NULL)
136675ecf5267604f166b85a7ee2cf0d9cb682966680Jouni Malinen		return;
136775ecf5267604f166b85a7ee2cf0d9cb682966680Jouni Malinen
136875ecf5267604f166b85a7ee2cf0d9cb682966680Jouni Malinen	dbus_message_iter_init_append(msg, &iter);
136975ecf5267604f166b85a7ee2cf0d9cb682966680Jouni Malinen	path = groupmember_obj_path;
137075ecf5267604f166b85a7ee2cf0d9cb682966680Jouni Malinen	if (!dbus_message_iter_append_basic(&iter, DBUS_TYPE_OBJECT_PATH,
137175ecf5267604f166b85a7ee2cf0d9cb682966680Jouni Malinen					    &path))
137275ecf5267604f166b85a7ee2cf0d9cb682966680Jouni Malinen		goto err;
137375ecf5267604f166b85a7ee2cf0d9cb682966680Jouni Malinen
137475ecf5267604f166b85a7ee2cf0d9cb682966680Jouni Malinen	dbus_connection_send(iface->con, msg, NULL);
137575ecf5267604f166b85a7ee2cf0d9cb682966680Jouni Malinen
137675ecf5267604f166b85a7ee2cf0d9cb682966680Jouni Malinen	dbus_message_unref(msg);
137775ecf5267604f166b85a7ee2cf0d9cb682966680Jouni Malinen	return;
137875ecf5267604f166b85a7ee2cf0d9cb682966680Jouni Malinen
137975ecf5267604f166b85a7ee2cf0d9cb682966680Jouni Malinenerr:
138075ecf5267604f166b85a7ee2cf0d9cb682966680Jouni Malinen	wpa_printf(MSG_ERROR, "dbus: Failed to construct signal");
138175ecf5267604f166b85a7ee2cf0d9cb682966680Jouni Malinen	dbus_message_unref(msg);
138275ecf5267604f166b85a7ee2cf0d9cb682966680Jouni Malinen}
138375ecf5267604f166b85a7ee2cf0d9cb682966680Jouni Malinen
138475ecf5267604f166b85a7ee2cf0d9cb682966680Jouni Malinen
138575ecf5267604f166b85a7ee2cf0d9cb682966680Jouni Malinen/**
138675ecf5267604f166b85a7ee2cf0d9cb682966680Jouni Malinen *
138775ecf5267604f166b85a7ee2cf0d9cb682966680Jouni Malinen * Method to emit a signal for a peer disconnecting the group.
138875ecf5267604f166b85a7ee2cf0d9cb682966680Jouni Malinen * The signal will carry path to the group member object
138975ecf5267604f166b85a7ee2cf0d9cb682966680Jouni Malinen * constructed using p2p i/f addr used for connecting.
139075ecf5267604f166b85a7ee2cf0d9cb682966680Jouni Malinen *
139175ecf5267604f166b85a7ee2cf0d9cb682966680Jouni Malinen * @wpa_s: %wpa_supplicant network interface data
139275ecf5267604f166b85a7ee2cf0d9cb682966680Jouni Malinen * @member_addr: addr (p2p i/f) of the peer joining the group
139375ecf5267604f166b85a7ee2cf0d9cb682966680Jouni Malinen */
139475ecf5267604f166b85a7ee2cf0d9cb682966680Jouni Malinenvoid wpas_dbus_signal_p2p_peer_disconnected(struct wpa_supplicant *wpa_s,
139575ecf5267604f166b85a7ee2cf0d9cb682966680Jouni Malinen				      const u8 *member)
139675ecf5267604f166b85a7ee2cf0d9cb682966680Jouni Malinen{
139775ecf5267604f166b85a7ee2cf0d9cb682966680Jouni Malinen	struct wpas_dbus_priv *iface;
139875ecf5267604f166b85a7ee2cf0d9cb682966680Jouni Malinen	DBusMessage *msg;
139975ecf5267604f166b85a7ee2cf0d9cb682966680Jouni Malinen	DBusMessageIter iter;
140075ecf5267604f166b85a7ee2cf0d9cb682966680Jouni Malinen	char groupmember_obj_path[WPAS_DBUS_OBJECT_PATH_MAX], *path;
140175ecf5267604f166b85a7ee2cf0d9cb682966680Jouni Malinen
140275ecf5267604f166b85a7ee2cf0d9cb682966680Jouni Malinen	iface = wpa_s->global->dbus;
140375ecf5267604f166b85a7ee2cf0d9cb682966680Jouni Malinen
140475ecf5267604f166b85a7ee2cf0d9cb682966680Jouni Malinen	/* Do nothing if the control interface is not turned on */
140575ecf5267604f166b85a7ee2cf0d9cb682966680Jouni Malinen	if (iface == NULL)
140675ecf5267604f166b85a7ee2cf0d9cb682966680Jouni Malinen		return;
140775ecf5267604f166b85a7ee2cf0d9cb682966680Jouni Malinen
140875ecf5267604f166b85a7ee2cf0d9cb682966680Jouni Malinen	if (!wpa_s->dbus_groupobj_path)
140975ecf5267604f166b85a7ee2cf0d9cb682966680Jouni Malinen		return;
141075ecf5267604f166b85a7ee2cf0d9cb682966680Jouni Malinen
141175ecf5267604f166b85a7ee2cf0d9cb682966680Jouni Malinen	os_snprintf(groupmember_obj_path, WPAS_DBUS_OBJECT_PATH_MAX,
141275ecf5267604f166b85a7ee2cf0d9cb682966680Jouni Malinen			"%s/"  WPAS_DBUS_NEW_P2P_GROUPMEMBERS_PART "/"
141375ecf5267604f166b85a7ee2cf0d9cb682966680Jouni Malinen			COMPACT_MACSTR,
141475ecf5267604f166b85a7ee2cf0d9cb682966680Jouni Malinen			wpa_s->dbus_groupobj_path, MAC2STR(member));
141575ecf5267604f166b85a7ee2cf0d9cb682966680Jouni Malinen
141675ecf5267604f166b85a7ee2cf0d9cb682966680Jouni Malinen	msg = dbus_message_new_signal(wpa_s->dbus_groupobj_path,
141775ecf5267604f166b85a7ee2cf0d9cb682966680Jouni Malinen				      WPAS_DBUS_NEW_IFACE_P2P_GROUP,
141875ecf5267604f166b85a7ee2cf0d9cb682966680Jouni Malinen				      "PeerDisconnected");
141975ecf5267604f166b85a7ee2cf0d9cb682966680Jouni Malinen	if (msg == NULL)
142075ecf5267604f166b85a7ee2cf0d9cb682966680Jouni Malinen		return;
142175ecf5267604f166b85a7ee2cf0d9cb682966680Jouni Malinen
142275ecf5267604f166b85a7ee2cf0d9cb682966680Jouni Malinen	dbus_message_iter_init_append(msg, &iter);
142375ecf5267604f166b85a7ee2cf0d9cb682966680Jouni Malinen	path = groupmember_obj_path;
142475ecf5267604f166b85a7ee2cf0d9cb682966680Jouni Malinen	if (!dbus_message_iter_append_basic(&iter, DBUS_TYPE_OBJECT_PATH,
142575ecf5267604f166b85a7ee2cf0d9cb682966680Jouni Malinen					    &path))
142675ecf5267604f166b85a7ee2cf0d9cb682966680Jouni Malinen		goto err;
142775ecf5267604f166b85a7ee2cf0d9cb682966680Jouni Malinen
142875ecf5267604f166b85a7ee2cf0d9cb682966680Jouni Malinen	dbus_connection_send(iface->con, msg, NULL);
142975ecf5267604f166b85a7ee2cf0d9cb682966680Jouni Malinen
143075ecf5267604f166b85a7ee2cf0d9cb682966680Jouni Malinen	dbus_message_unref(msg);
143175ecf5267604f166b85a7ee2cf0d9cb682966680Jouni Malinen	return;
143275ecf5267604f166b85a7ee2cf0d9cb682966680Jouni Malinen
143375ecf5267604f166b85a7ee2cf0d9cb682966680Jouni Malinenerr:
143475ecf5267604f166b85a7ee2cf0d9cb682966680Jouni Malinen	wpa_printf(MSG_ERROR, "dbus: Failed to construct PeerDisconnected "
143575ecf5267604f166b85a7ee2cf0d9cb682966680Jouni Malinen			      "signal");
143675ecf5267604f166b85a7ee2cf0d9cb682966680Jouni Malinen	dbus_message_unref(msg);
143775ecf5267604f166b85a7ee2cf0d9cb682966680Jouni Malinen}
143875ecf5267604f166b85a7ee2cf0d9cb682966680Jouni Malinen
143975ecf5267604f166b85a7ee2cf0d9cb682966680Jouni Malinen
144075ecf5267604f166b85a7ee2cf0d9cb682966680Jouni Malinen/**
144175ecf5267604f166b85a7ee2cf0d9cb682966680Jouni Malinen *
144275ecf5267604f166b85a7ee2cf0d9cb682966680Jouni Malinen * Method to emit a signal for a service discovery request.
144375ecf5267604f166b85a7ee2cf0d9cb682966680Jouni Malinen * The signal will carry station address, frequency, dialog token,
144475ecf5267604f166b85a7ee2cf0d9cb682966680Jouni Malinen * update indicator and it tlvs
144575ecf5267604f166b85a7ee2cf0d9cb682966680Jouni Malinen *
144675ecf5267604f166b85a7ee2cf0d9cb682966680Jouni Malinen * @wpa_s: %wpa_supplicant network interface data
144775ecf5267604f166b85a7ee2cf0d9cb682966680Jouni Malinen * @sa: station addr (p2p i/f) of the peer
144875ecf5267604f166b85a7ee2cf0d9cb682966680Jouni Malinen * @dialog_token: service discovery request dialog token
144975ecf5267604f166b85a7ee2cf0d9cb682966680Jouni Malinen * @update_indic: service discovery request update indicator
145075ecf5267604f166b85a7ee2cf0d9cb682966680Jouni Malinen * @tlvs: service discovery request genrated byte array of tlvs
145175ecf5267604f166b85a7ee2cf0d9cb682966680Jouni Malinen * @tlvs_len: service discovery request tlvs length
145275ecf5267604f166b85a7ee2cf0d9cb682966680Jouni Malinen */
145375ecf5267604f166b85a7ee2cf0d9cb682966680Jouni Malinenvoid wpas_dbus_signal_p2p_sd_request(struct wpa_supplicant *wpa_s,
145475ecf5267604f166b85a7ee2cf0d9cb682966680Jouni Malinen				     int freq, const u8 *sa, u8 dialog_token,
145575ecf5267604f166b85a7ee2cf0d9cb682966680Jouni Malinen				     u16 update_indic, const u8 *tlvs,
145675ecf5267604f166b85a7ee2cf0d9cb682966680Jouni Malinen				     size_t tlvs_len)
145775ecf5267604f166b85a7ee2cf0d9cb682966680Jouni Malinen{
145875ecf5267604f166b85a7ee2cf0d9cb682966680Jouni Malinen	DBusMessage *msg;
145975ecf5267604f166b85a7ee2cf0d9cb682966680Jouni Malinen	DBusMessageIter iter, dict_iter;
146075ecf5267604f166b85a7ee2cf0d9cb682966680Jouni Malinen	struct wpas_dbus_priv *iface;
146175ecf5267604f166b85a7ee2cf0d9cb682966680Jouni Malinen	char peer_obj_path[WPAS_DBUS_OBJECT_PATH_MAX], *path;
146275ecf5267604f166b85a7ee2cf0d9cb682966680Jouni Malinen	iface = wpa_s->global->dbus;
146375ecf5267604f166b85a7ee2cf0d9cb682966680Jouni Malinen
146475ecf5267604f166b85a7ee2cf0d9cb682966680Jouni Malinen	/* Do nothing if the control interface is not turned on */
146575ecf5267604f166b85a7ee2cf0d9cb682966680Jouni Malinen	if (iface == NULL)
146675ecf5267604f166b85a7ee2cf0d9cb682966680Jouni Malinen		return;
146775ecf5267604f166b85a7ee2cf0d9cb682966680Jouni Malinen
146875ecf5267604f166b85a7ee2cf0d9cb682966680Jouni Malinen	msg = dbus_message_new_signal(wpa_s->dbus_new_path,
146975ecf5267604f166b85a7ee2cf0d9cb682966680Jouni Malinen				      WPAS_DBUS_NEW_IFACE_P2PDEVICE,
147075ecf5267604f166b85a7ee2cf0d9cb682966680Jouni Malinen				      "ServiceDiscoveryRequest");
147175ecf5267604f166b85a7ee2cf0d9cb682966680Jouni Malinen	if (msg == NULL)
147275ecf5267604f166b85a7ee2cf0d9cb682966680Jouni Malinen		return;
147375ecf5267604f166b85a7ee2cf0d9cb682966680Jouni Malinen
147475ecf5267604f166b85a7ee2cf0d9cb682966680Jouni Malinen	/* Check if this is a known peer */
14751f69aa52ea2e0a73ac502565df8c666ee49cab6aDmitry Shmidt	if (!p2p_peer_known(wpa_s->global->p2p, sa))
147675ecf5267604f166b85a7ee2cf0d9cb682966680Jouni Malinen		goto error;
147775ecf5267604f166b85a7ee2cf0d9cb682966680Jouni Malinen
147875ecf5267604f166b85a7ee2cf0d9cb682966680Jouni Malinen	os_snprintf(peer_obj_path, WPAS_DBUS_OBJECT_PATH_MAX,
147975ecf5267604f166b85a7ee2cf0d9cb682966680Jouni Malinen		    "%s/" WPAS_DBUS_NEW_P2P_PEERS_PART "/"
148075ecf5267604f166b85a7ee2cf0d9cb682966680Jouni Malinen		    COMPACT_MACSTR, wpa_s->dbus_new_path, MAC2STR(sa));
148175ecf5267604f166b85a7ee2cf0d9cb682966680Jouni Malinen
148275ecf5267604f166b85a7ee2cf0d9cb682966680Jouni Malinen	path = peer_obj_path;
148375ecf5267604f166b85a7ee2cf0d9cb682966680Jouni Malinen
148475ecf5267604f166b85a7ee2cf0d9cb682966680Jouni Malinen	dbus_message_iter_init_append(msg, &iter);
148575ecf5267604f166b85a7ee2cf0d9cb682966680Jouni Malinen	if (!wpa_dbus_dict_open_write(&iter, &dict_iter))
148675ecf5267604f166b85a7ee2cf0d9cb682966680Jouni Malinen		goto error;
148775ecf5267604f166b85a7ee2cf0d9cb682966680Jouni Malinen
148875ecf5267604f166b85a7ee2cf0d9cb682966680Jouni Malinen
148975ecf5267604f166b85a7ee2cf0d9cb682966680Jouni Malinen	if (!wpa_dbus_dict_append_object_path(&dict_iter, "peer_object",
149075ecf5267604f166b85a7ee2cf0d9cb682966680Jouni Malinen					      path) ||
149175ecf5267604f166b85a7ee2cf0d9cb682966680Jouni Malinen	    !wpa_dbus_dict_append_int32(&dict_iter, "frequency", freq) ||
149275ecf5267604f166b85a7ee2cf0d9cb682966680Jouni Malinen	    !wpa_dbus_dict_append_int32(&dict_iter, "dialog_token",
149375ecf5267604f166b85a7ee2cf0d9cb682966680Jouni Malinen					dialog_token) ||
149475ecf5267604f166b85a7ee2cf0d9cb682966680Jouni Malinen	    !wpa_dbus_dict_append_uint16(&dict_iter, "update_indicator",
149575ecf5267604f166b85a7ee2cf0d9cb682966680Jouni Malinen					 update_indic) ||
149675ecf5267604f166b85a7ee2cf0d9cb682966680Jouni Malinen	    !wpa_dbus_dict_append_byte_array(&dict_iter, "tlvs",
149775ecf5267604f166b85a7ee2cf0d9cb682966680Jouni Malinen					     (const char *) tlvs,
149875ecf5267604f166b85a7ee2cf0d9cb682966680Jouni Malinen					     tlvs_len) ||
149975ecf5267604f166b85a7ee2cf0d9cb682966680Jouni Malinen	    !wpa_dbus_dict_close_write(&iter, &dict_iter))
150075ecf5267604f166b85a7ee2cf0d9cb682966680Jouni Malinen		goto error;
150175ecf5267604f166b85a7ee2cf0d9cb682966680Jouni Malinen
150275ecf5267604f166b85a7ee2cf0d9cb682966680Jouni Malinen	dbus_connection_send(iface->con, msg, NULL);
150375ecf5267604f166b85a7ee2cf0d9cb682966680Jouni Malinen	dbus_message_unref(msg);
150475ecf5267604f166b85a7ee2cf0d9cb682966680Jouni Malinen	return;
150575ecf5267604f166b85a7ee2cf0d9cb682966680Jouni Malinenerror:
150675ecf5267604f166b85a7ee2cf0d9cb682966680Jouni Malinen	wpa_printf(MSG_ERROR, "dbus: Failed to construct signal");
150775ecf5267604f166b85a7ee2cf0d9cb682966680Jouni Malinen	dbus_message_unref(msg);
150875ecf5267604f166b85a7ee2cf0d9cb682966680Jouni Malinen}
150975ecf5267604f166b85a7ee2cf0d9cb682966680Jouni Malinen
151075ecf5267604f166b85a7ee2cf0d9cb682966680Jouni Malinen
151175ecf5267604f166b85a7ee2cf0d9cb682966680Jouni Malinen/**
151275ecf5267604f166b85a7ee2cf0d9cb682966680Jouni Malinen *
151375ecf5267604f166b85a7ee2cf0d9cb682966680Jouni Malinen * Method to emit a signal for a service discovery response.
151475ecf5267604f166b85a7ee2cf0d9cb682966680Jouni Malinen * The signal will carry station address, update indicator and it
151575ecf5267604f166b85a7ee2cf0d9cb682966680Jouni Malinen * tlvs
151675ecf5267604f166b85a7ee2cf0d9cb682966680Jouni Malinen *
151775ecf5267604f166b85a7ee2cf0d9cb682966680Jouni Malinen * @wpa_s: %wpa_supplicant network interface data
151875ecf5267604f166b85a7ee2cf0d9cb682966680Jouni Malinen * @sa: station addr (p2p i/f) of the peer
151975ecf5267604f166b85a7ee2cf0d9cb682966680Jouni Malinen * @update_indic: service discovery request update indicator
152075ecf5267604f166b85a7ee2cf0d9cb682966680Jouni Malinen * @tlvs: service discovery request genrated byte array of tlvs
152175ecf5267604f166b85a7ee2cf0d9cb682966680Jouni Malinen * @tlvs_len: service discovery request tlvs length
152275ecf5267604f166b85a7ee2cf0d9cb682966680Jouni Malinen */
152375ecf5267604f166b85a7ee2cf0d9cb682966680Jouni Malinenvoid wpas_dbus_signal_p2p_sd_response(struct wpa_supplicant *wpa_s,
152475ecf5267604f166b85a7ee2cf0d9cb682966680Jouni Malinen				      const u8 *sa, u16 update_indic,
152575ecf5267604f166b85a7ee2cf0d9cb682966680Jouni Malinen				      const u8 *tlvs, size_t tlvs_len)
152675ecf5267604f166b85a7ee2cf0d9cb682966680Jouni Malinen{
152775ecf5267604f166b85a7ee2cf0d9cb682966680Jouni Malinen	DBusMessage *msg;
152875ecf5267604f166b85a7ee2cf0d9cb682966680Jouni Malinen	DBusMessageIter iter, dict_iter;
152975ecf5267604f166b85a7ee2cf0d9cb682966680Jouni Malinen	struct wpas_dbus_priv *iface;
153075ecf5267604f166b85a7ee2cf0d9cb682966680Jouni Malinen	char peer_obj_path[WPAS_DBUS_OBJECT_PATH_MAX], *path;
153175ecf5267604f166b85a7ee2cf0d9cb682966680Jouni Malinen	iface = wpa_s->global->dbus;
153275ecf5267604f166b85a7ee2cf0d9cb682966680Jouni Malinen
153375ecf5267604f166b85a7ee2cf0d9cb682966680Jouni Malinen	/* Do nothing if the control interface is not turned on */
153475ecf5267604f166b85a7ee2cf0d9cb682966680Jouni Malinen	if (iface == NULL)
153575ecf5267604f166b85a7ee2cf0d9cb682966680Jouni Malinen		return;
153675ecf5267604f166b85a7ee2cf0d9cb682966680Jouni Malinen
153775ecf5267604f166b85a7ee2cf0d9cb682966680Jouni Malinen	msg = dbus_message_new_signal(wpa_s->dbus_new_path,
153875ecf5267604f166b85a7ee2cf0d9cb682966680Jouni Malinen				      WPAS_DBUS_NEW_IFACE_P2PDEVICE,
153975ecf5267604f166b85a7ee2cf0d9cb682966680Jouni Malinen				"ServiceDiscoveryResponse");
154075ecf5267604f166b85a7ee2cf0d9cb682966680Jouni Malinen	if (msg == NULL)
154175ecf5267604f166b85a7ee2cf0d9cb682966680Jouni Malinen		return;
154275ecf5267604f166b85a7ee2cf0d9cb682966680Jouni Malinen
154375ecf5267604f166b85a7ee2cf0d9cb682966680Jouni Malinen	/* Check if this is a known peer */
15441f69aa52ea2e0a73ac502565df8c666ee49cab6aDmitry Shmidt	if (!p2p_peer_known(wpa_s->global->p2p, sa))
154575ecf5267604f166b85a7ee2cf0d9cb682966680Jouni Malinen		goto error;
154675ecf5267604f166b85a7ee2cf0d9cb682966680Jouni Malinen
154775ecf5267604f166b85a7ee2cf0d9cb682966680Jouni Malinen	os_snprintf(peer_obj_path, WPAS_DBUS_OBJECT_PATH_MAX,
154875ecf5267604f166b85a7ee2cf0d9cb682966680Jouni Malinen		    "%s/" WPAS_DBUS_NEW_P2P_PEERS_PART "/"
154975ecf5267604f166b85a7ee2cf0d9cb682966680Jouni Malinen		    COMPACT_MACSTR, wpa_s->dbus_new_path, MAC2STR(sa));
155075ecf5267604f166b85a7ee2cf0d9cb682966680Jouni Malinen
155175ecf5267604f166b85a7ee2cf0d9cb682966680Jouni Malinen	path = peer_obj_path;
155275ecf5267604f166b85a7ee2cf0d9cb682966680Jouni Malinen
155375ecf5267604f166b85a7ee2cf0d9cb682966680Jouni Malinen	dbus_message_iter_init_append(msg, &iter);
155475ecf5267604f166b85a7ee2cf0d9cb682966680Jouni Malinen	if (!wpa_dbus_dict_open_write(&iter, &dict_iter))
155575ecf5267604f166b85a7ee2cf0d9cb682966680Jouni Malinen		goto error;
155675ecf5267604f166b85a7ee2cf0d9cb682966680Jouni Malinen
155775ecf5267604f166b85a7ee2cf0d9cb682966680Jouni Malinen	if (!wpa_dbus_dict_append_object_path(&dict_iter, "peer_object",
155875ecf5267604f166b85a7ee2cf0d9cb682966680Jouni Malinen					      path) ||
155975ecf5267604f166b85a7ee2cf0d9cb682966680Jouni Malinen	    !wpa_dbus_dict_append_uint16(&dict_iter, "update_indicator",
156075ecf5267604f166b85a7ee2cf0d9cb682966680Jouni Malinen					 update_indic) ||
156175ecf5267604f166b85a7ee2cf0d9cb682966680Jouni Malinen	    !wpa_dbus_dict_append_byte_array(&dict_iter, "tlvs",
156275ecf5267604f166b85a7ee2cf0d9cb682966680Jouni Malinen					     (const char *) tlvs,
156375ecf5267604f166b85a7ee2cf0d9cb682966680Jouni Malinen					     tlvs_len) ||
156475ecf5267604f166b85a7ee2cf0d9cb682966680Jouni Malinen	    !wpa_dbus_dict_close_write(&iter, &dict_iter))
156575ecf5267604f166b85a7ee2cf0d9cb682966680Jouni Malinen		goto error;
156675ecf5267604f166b85a7ee2cf0d9cb682966680Jouni Malinen
156775ecf5267604f166b85a7ee2cf0d9cb682966680Jouni Malinen
156875ecf5267604f166b85a7ee2cf0d9cb682966680Jouni Malinen	dbus_connection_send(iface->con, msg, NULL);
156975ecf5267604f166b85a7ee2cf0d9cb682966680Jouni Malinen	dbus_message_unref(msg);
157075ecf5267604f166b85a7ee2cf0d9cb682966680Jouni Malinen	return;
157175ecf5267604f166b85a7ee2cf0d9cb682966680Jouni Malinenerror:
157275ecf5267604f166b85a7ee2cf0d9cb682966680Jouni Malinen	wpa_printf(MSG_ERROR, "dbus: Failed to construct signal");
157375ecf5267604f166b85a7ee2cf0d9cb682966680Jouni Malinen	dbus_message_unref(msg);
157475ecf5267604f166b85a7ee2cf0d9cb682966680Jouni Malinen}
157575ecf5267604f166b85a7ee2cf0d9cb682966680Jouni Malinen
157675ecf5267604f166b85a7ee2cf0d9cb682966680Jouni Malinen/**
157775ecf5267604f166b85a7ee2cf0d9cb682966680Jouni Malinen * wpas_dbus_signal_persistent_group - Send a persistent group related
157875ecf5267604f166b85a7ee2cf0d9cb682966680Jouni Malinen *	event signal
157975ecf5267604f166b85a7ee2cf0d9cb682966680Jouni Malinen * @wpa_s: %wpa_supplicant network interface data
158075ecf5267604f166b85a7ee2cf0d9cb682966680Jouni Malinen * @id: new persistent group id
158175ecf5267604f166b85a7ee2cf0d9cb682966680Jouni Malinen * @sig_name: signal name - PersistentGroupAdded, PersistentGroupRemoved
158275ecf5267604f166b85a7ee2cf0d9cb682966680Jouni Malinen * @properties: determines if add second argument with object properties
158375ecf5267604f166b85a7ee2cf0d9cb682966680Jouni Malinen *
158475ecf5267604f166b85a7ee2cf0d9cb682966680Jouni Malinen * Notify listeners about an event related to persistent groups.
158575ecf5267604f166b85a7ee2cf0d9cb682966680Jouni Malinen */
158675ecf5267604f166b85a7ee2cf0d9cb682966680Jouni Malinenstatic void wpas_dbus_signal_persistent_group(struct wpa_supplicant *wpa_s,
158775ecf5267604f166b85a7ee2cf0d9cb682966680Jouni Malinen					      int id, const char *sig_name,
158875ecf5267604f166b85a7ee2cf0d9cb682966680Jouni Malinen					      int properties)
158975ecf5267604f166b85a7ee2cf0d9cb682966680Jouni Malinen{
159075ecf5267604f166b85a7ee2cf0d9cb682966680Jouni Malinen	struct wpas_dbus_priv *iface;
159175ecf5267604f166b85a7ee2cf0d9cb682966680Jouni Malinen	DBusMessage *msg;
15921f69aa52ea2e0a73ac502565df8c666ee49cab6aDmitry Shmidt	DBusMessageIter iter;
159375ecf5267604f166b85a7ee2cf0d9cb682966680Jouni Malinen	char pgrp_obj_path[WPAS_DBUS_OBJECT_PATH_MAX], *path;
159475ecf5267604f166b85a7ee2cf0d9cb682966680Jouni Malinen
159575ecf5267604f166b85a7ee2cf0d9cb682966680Jouni Malinen	iface = wpa_s->global->dbus;
159675ecf5267604f166b85a7ee2cf0d9cb682966680Jouni Malinen
159775ecf5267604f166b85a7ee2cf0d9cb682966680Jouni Malinen	/* Do nothing if the control interface is not turned on */
159875ecf5267604f166b85a7ee2cf0d9cb682966680Jouni Malinen	if (iface == NULL)
159975ecf5267604f166b85a7ee2cf0d9cb682966680Jouni Malinen		return;
160075ecf5267604f166b85a7ee2cf0d9cb682966680Jouni Malinen
160175ecf5267604f166b85a7ee2cf0d9cb682966680Jouni Malinen	os_snprintf(pgrp_obj_path, WPAS_DBUS_OBJECT_PATH_MAX,
160275ecf5267604f166b85a7ee2cf0d9cb682966680Jouni Malinen		    "%s/" WPAS_DBUS_NEW_PERSISTENT_GROUPS_PART "/%u",
160375ecf5267604f166b85a7ee2cf0d9cb682966680Jouni Malinen		    wpa_s->dbus_new_path, id);
160475ecf5267604f166b85a7ee2cf0d9cb682966680Jouni Malinen
160575ecf5267604f166b85a7ee2cf0d9cb682966680Jouni Malinen	msg = dbus_message_new_signal(wpa_s->dbus_new_path,
160675ecf5267604f166b85a7ee2cf0d9cb682966680Jouni Malinen				      WPAS_DBUS_NEW_IFACE_P2PDEVICE,
160775ecf5267604f166b85a7ee2cf0d9cb682966680Jouni Malinen				      sig_name);
160875ecf5267604f166b85a7ee2cf0d9cb682966680Jouni Malinen	if (msg == NULL)
160975ecf5267604f166b85a7ee2cf0d9cb682966680Jouni Malinen		return;
161075ecf5267604f166b85a7ee2cf0d9cb682966680Jouni Malinen
161175ecf5267604f166b85a7ee2cf0d9cb682966680Jouni Malinen	dbus_message_iter_init_append(msg, &iter);
161275ecf5267604f166b85a7ee2cf0d9cb682966680Jouni Malinen	path = pgrp_obj_path;
161375ecf5267604f166b85a7ee2cf0d9cb682966680Jouni Malinen	if (!dbus_message_iter_append_basic(&iter, DBUS_TYPE_OBJECT_PATH,
161475ecf5267604f166b85a7ee2cf0d9cb682966680Jouni Malinen					    &path))
161575ecf5267604f166b85a7ee2cf0d9cb682966680Jouni Malinen		goto err;
161675ecf5267604f166b85a7ee2cf0d9cb682966680Jouni Malinen
161775ecf5267604f166b85a7ee2cf0d9cb682966680Jouni Malinen	if (properties) {
16181f69aa52ea2e0a73ac502565df8c666ee49cab6aDmitry Shmidt		if (!wpa_dbus_get_object_properties(
16191f69aa52ea2e0a73ac502565df8c666ee49cab6aDmitry Shmidt			    iface, pgrp_obj_path,
16201f69aa52ea2e0a73ac502565df8c666ee49cab6aDmitry Shmidt			    WPAS_DBUS_NEW_IFACE_PERSISTENT_GROUP, &iter))
162175ecf5267604f166b85a7ee2cf0d9cb682966680Jouni Malinen			goto err;
162275ecf5267604f166b85a7ee2cf0d9cb682966680Jouni Malinen	}
162375ecf5267604f166b85a7ee2cf0d9cb682966680Jouni Malinen
162475ecf5267604f166b85a7ee2cf0d9cb682966680Jouni Malinen	dbus_connection_send(iface->con, msg, NULL);
162575ecf5267604f166b85a7ee2cf0d9cb682966680Jouni Malinen
162675ecf5267604f166b85a7ee2cf0d9cb682966680Jouni Malinen	dbus_message_unref(msg);
162775ecf5267604f166b85a7ee2cf0d9cb682966680Jouni Malinen	return;
162875ecf5267604f166b85a7ee2cf0d9cb682966680Jouni Malinen
162975ecf5267604f166b85a7ee2cf0d9cb682966680Jouni Malinenerr:
163075ecf5267604f166b85a7ee2cf0d9cb682966680Jouni Malinen	wpa_printf(MSG_ERROR, "dbus: Failed to construct signal");
163175ecf5267604f166b85a7ee2cf0d9cb682966680Jouni Malinen	dbus_message_unref(msg);
163275ecf5267604f166b85a7ee2cf0d9cb682966680Jouni Malinen}
163375ecf5267604f166b85a7ee2cf0d9cb682966680Jouni Malinen
163475ecf5267604f166b85a7ee2cf0d9cb682966680Jouni Malinen
163575ecf5267604f166b85a7ee2cf0d9cb682966680Jouni Malinen/**
163675ecf5267604f166b85a7ee2cf0d9cb682966680Jouni Malinen * wpas_dbus_signal_persistent_group_added - Send a persistent_group
163775ecf5267604f166b85a7ee2cf0d9cb682966680Jouni Malinen *	added signal
163875ecf5267604f166b85a7ee2cf0d9cb682966680Jouni Malinen * @wpa_s: %wpa_supplicant network interface data
163975ecf5267604f166b85a7ee2cf0d9cb682966680Jouni Malinen * @id: new persistent group id
164075ecf5267604f166b85a7ee2cf0d9cb682966680Jouni Malinen *
164175ecf5267604f166b85a7ee2cf0d9cb682966680Jouni Malinen * Notify listeners about addition of a new persistent group.
164275ecf5267604f166b85a7ee2cf0d9cb682966680Jouni Malinen */
164375ecf5267604f166b85a7ee2cf0d9cb682966680Jouni Malinenstatic void wpas_dbus_signal_persistent_group_added(
164475ecf5267604f166b85a7ee2cf0d9cb682966680Jouni Malinen	struct wpa_supplicant *wpa_s, int id)
164575ecf5267604f166b85a7ee2cf0d9cb682966680Jouni Malinen{
164675ecf5267604f166b85a7ee2cf0d9cb682966680Jouni Malinen	wpas_dbus_signal_persistent_group(wpa_s, id, "PersistentGroupAdded",
164775ecf5267604f166b85a7ee2cf0d9cb682966680Jouni Malinen					  TRUE);
164875ecf5267604f166b85a7ee2cf0d9cb682966680Jouni Malinen}
164975ecf5267604f166b85a7ee2cf0d9cb682966680Jouni Malinen
165075ecf5267604f166b85a7ee2cf0d9cb682966680Jouni Malinen
165175ecf5267604f166b85a7ee2cf0d9cb682966680Jouni Malinen/**
165275ecf5267604f166b85a7ee2cf0d9cb682966680Jouni Malinen * wpas_dbus_signal_persistent_group_removed - Send a persistent_group
165375ecf5267604f166b85a7ee2cf0d9cb682966680Jouni Malinen *	removed signal
165475ecf5267604f166b85a7ee2cf0d9cb682966680Jouni Malinen * @wpa_s: %wpa_supplicant network interface data
165575ecf5267604f166b85a7ee2cf0d9cb682966680Jouni Malinen * @id: persistent group id
165675ecf5267604f166b85a7ee2cf0d9cb682966680Jouni Malinen *
165775ecf5267604f166b85a7ee2cf0d9cb682966680Jouni Malinen * Notify listeners about removal of a persistent group.
165875ecf5267604f166b85a7ee2cf0d9cb682966680Jouni Malinen */
165975ecf5267604f166b85a7ee2cf0d9cb682966680Jouni Malinenstatic void wpas_dbus_signal_persistent_group_removed(
166075ecf5267604f166b85a7ee2cf0d9cb682966680Jouni Malinen	struct wpa_supplicant *wpa_s, int id)
166175ecf5267604f166b85a7ee2cf0d9cb682966680Jouni Malinen{
166275ecf5267604f166b85a7ee2cf0d9cb682966680Jouni Malinen	wpas_dbus_signal_persistent_group(wpa_s, id, "PersistentGroupRemoved",
166375ecf5267604f166b85a7ee2cf0d9cb682966680Jouni Malinen					  FALSE);
166475ecf5267604f166b85a7ee2cf0d9cb682966680Jouni Malinen}
166575ecf5267604f166b85a7ee2cf0d9cb682966680Jouni Malinen
166675ecf5267604f166b85a7ee2cf0d9cb682966680Jouni Malinen
166775ecf5267604f166b85a7ee2cf0d9cb682966680Jouni Malinen/**
166875ecf5267604f166b85a7ee2cf0d9cb682966680Jouni Malinen * wpas_dbus_signal_p2p_wps_failed - Signals WpsFailed event
166975ecf5267604f166b85a7ee2cf0d9cb682966680Jouni Malinen * @wpa_s: %wpa_supplicant network interface data
167075ecf5267604f166b85a7ee2cf0d9cb682966680Jouni Malinen *
167175ecf5267604f166b85a7ee2cf0d9cb682966680Jouni Malinen * Sends Event dbus signal with name "fail" and dictionary containing
167275ecf5267604f166b85a7ee2cf0d9cb682966680Jouni Malinen * "msg" field with fail message number (int32) as arguments
167375ecf5267604f166b85a7ee2cf0d9cb682966680Jouni Malinen */
167475ecf5267604f166b85a7ee2cf0d9cb682966680Jouni Malinenvoid wpas_dbus_signal_p2p_wps_failed(struct wpa_supplicant *wpa_s,
167575ecf5267604f166b85a7ee2cf0d9cb682966680Jouni Malinen				     struct wps_event_fail *fail)
167675ecf5267604f166b85a7ee2cf0d9cb682966680Jouni Malinen{
167775ecf5267604f166b85a7ee2cf0d9cb682966680Jouni Malinen
167875ecf5267604f166b85a7ee2cf0d9cb682966680Jouni Malinen	DBusMessage *msg;
167975ecf5267604f166b85a7ee2cf0d9cb682966680Jouni Malinen	DBusMessageIter iter, dict_iter;
168075ecf5267604f166b85a7ee2cf0d9cb682966680Jouni Malinen	struct wpas_dbus_priv *iface;
168175ecf5267604f166b85a7ee2cf0d9cb682966680Jouni Malinen	char *key = "fail";
168275ecf5267604f166b85a7ee2cf0d9cb682966680Jouni Malinen
168375ecf5267604f166b85a7ee2cf0d9cb682966680Jouni Malinen	iface = wpa_s->global->dbus;
168475ecf5267604f166b85a7ee2cf0d9cb682966680Jouni Malinen
168575ecf5267604f166b85a7ee2cf0d9cb682966680Jouni Malinen	/* Do nothing if the control interface is not turned on */
168675ecf5267604f166b85a7ee2cf0d9cb682966680Jouni Malinen	if (iface == NULL)
168775ecf5267604f166b85a7ee2cf0d9cb682966680Jouni Malinen		return;
168875ecf5267604f166b85a7ee2cf0d9cb682966680Jouni Malinen
168975ecf5267604f166b85a7ee2cf0d9cb682966680Jouni Malinen	msg = dbus_message_new_signal(wpa_s->dbus_new_path,
169075ecf5267604f166b85a7ee2cf0d9cb682966680Jouni Malinen				      WPAS_DBUS_NEW_IFACE_P2PDEVICE,
169175ecf5267604f166b85a7ee2cf0d9cb682966680Jouni Malinen				      "WpsFailed");
169275ecf5267604f166b85a7ee2cf0d9cb682966680Jouni Malinen	if (msg == NULL)
169375ecf5267604f166b85a7ee2cf0d9cb682966680Jouni Malinen		return;
169475ecf5267604f166b85a7ee2cf0d9cb682966680Jouni Malinen
169575ecf5267604f166b85a7ee2cf0d9cb682966680Jouni Malinen	dbus_message_iter_init_append(msg, &iter);
169675ecf5267604f166b85a7ee2cf0d9cb682966680Jouni Malinen
169775ecf5267604f166b85a7ee2cf0d9cb682966680Jouni Malinen	if (!dbus_message_iter_append_basic(&iter, DBUS_TYPE_STRING, &key) ||
169875ecf5267604f166b85a7ee2cf0d9cb682966680Jouni Malinen	    !wpa_dbus_dict_open_write(&iter, &dict_iter) ||
169975ecf5267604f166b85a7ee2cf0d9cb682966680Jouni Malinen	    !wpa_dbus_dict_append_int32(&dict_iter, "msg", fail->msg) ||
170075ecf5267604f166b85a7ee2cf0d9cb682966680Jouni Malinen	    !wpa_dbus_dict_append_int16(&dict_iter, "config_error",
170175ecf5267604f166b85a7ee2cf0d9cb682966680Jouni Malinen					fail->config_error) ||
170275ecf5267604f166b85a7ee2cf0d9cb682966680Jouni Malinen	    !wpa_dbus_dict_close_write(&iter, &dict_iter))
170375ecf5267604f166b85a7ee2cf0d9cb682966680Jouni Malinen		wpa_printf(MSG_ERROR, "dbus: Failed to construct signal");
170475ecf5267604f166b85a7ee2cf0d9cb682966680Jouni Malinen	else
170575ecf5267604f166b85a7ee2cf0d9cb682966680Jouni Malinen		dbus_connection_send(iface->con, msg, NULL);
170675ecf5267604f166b85a7ee2cf0d9cb682966680Jouni Malinen
170775ecf5267604f166b85a7ee2cf0d9cb682966680Jouni Malinen	dbus_message_unref(msg);
170875ecf5267604f166b85a7ee2cf0d9cb682966680Jouni Malinen}
170975ecf5267604f166b85a7ee2cf0d9cb682966680Jouni Malinen
171075ecf5267604f166b85a7ee2cf0d9cb682966680Jouni Malinen#endif /*CONFIG_P2P*/
171175ecf5267604f166b85a7ee2cf0d9cb682966680Jouni Malinen
171275ecf5267604f166b85a7ee2cf0d9cb682966680Jouni Malinen
171375ecf5267604f166b85a7ee2cf0d9cb682966680Jouni Malinen/**
171475ecf5267604f166b85a7ee2cf0d9cb682966680Jouni Malinen * wpas_dbus_signal_prop_changed - Signals change of property
171575ecf5267604f166b85a7ee2cf0d9cb682966680Jouni Malinen * @wpa_s: %wpa_supplicant network interface data
171675ecf5267604f166b85a7ee2cf0d9cb682966680Jouni Malinen * @property: indicates which property has changed
171775ecf5267604f166b85a7ee2cf0d9cb682966680Jouni Malinen *
171875ecf5267604f166b85a7ee2cf0d9cb682966680Jouni Malinen * Sends PropertyChanged signals with path, interface and arguments
171975ecf5267604f166b85a7ee2cf0d9cb682966680Jouni Malinen * depending on which property has changed.
172075ecf5267604f166b85a7ee2cf0d9cb682966680Jouni Malinen */
172175ecf5267604f166b85a7ee2cf0d9cb682966680Jouni Malinenvoid wpas_dbus_signal_prop_changed(struct wpa_supplicant *wpa_s,
172275ecf5267604f166b85a7ee2cf0d9cb682966680Jouni Malinen				   enum wpas_dbus_prop property)
172375ecf5267604f166b85a7ee2cf0d9cb682966680Jouni Malinen{
172475ecf5267604f166b85a7ee2cf0d9cb682966680Jouni Malinen	char *prop;
172504949598a23f501be6eec21697465fd46a28840aDmitry Shmidt	dbus_bool_t flush;
172675ecf5267604f166b85a7ee2cf0d9cb682966680Jouni Malinen
172775ecf5267604f166b85a7ee2cf0d9cb682966680Jouni Malinen	if (wpa_s->dbus_new_path == NULL)
172875ecf5267604f166b85a7ee2cf0d9cb682966680Jouni Malinen		return; /* Skip signal since D-Bus setup is not yet ready */
172975ecf5267604f166b85a7ee2cf0d9cb682966680Jouni Malinen
173004949598a23f501be6eec21697465fd46a28840aDmitry Shmidt	flush = FALSE;
173175ecf5267604f166b85a7ee2cf0d9cb682966680Jouni Malinen	switch (property) {
173275ecf5267604f166b85a7ee2cf0d9cb682966680Jouni Malinen	case WPAS_DBUS_PROP_AP_SCAN:
173375ecf5267604f166b85a7ee2cf0d9cb682966680Jouni Malinen		prop = "ApScan";
173475ecf5267604f166b85a7ee2cf0d9cb682966680Jouni Malinen		break;
173575ecf5267604f166b85a7ee2cf0d9cb682966680Jouni Malinen	case WPAS_DBUS_PROP_SCANNING:
173675ecf5267604f166b85a7ee2cf0d9cb682966680Jouni Malinen		prop = "Scanning";
173775ecf5267604f166b85a7ee2cf0d9cb682966680Jouni Malinen		break;
173875ecf5267604f166b85a7ee2cf0d9cb682966680Jouni Malinen	case WPAS_DBUS_PROP_STATE:
173975ecf5267604f166b85a7ee2cf0d9cb682966680Jouni Malinen		prop = "State";
174075ecf5267604f166b85a7ee2cf0d9cb682966680Jouni Malinen		break;
174175ecf5267604f166b85a7ee2cf0d9cb682966680Jouni Malinen	case WPAS_DBUS_PROP_CURRENT_BSS:
174275ecf5267604f166b85a7ee2cf0d9cb682966680Jouni Malinen		prop = "CurrentBSS";
174375ecf5267604f166b85a7ee2cf0d9cb682966680Jouni Malinen		break;
174475ecf5267604f166b85a7ee2cf0d9cb682966680Jouni Malinen	case WPAS_DBUS_PROP_CURRENT_NETWORK:
174575ecf5267604f166b85a7ee2cf0d9cb682966680Jouni Malinen		prop = "CurrentNetwork";
174675ecf5267604f166b85a7ee2cf0d9cb682966680Jouni Malinen		break;
174775ecf5267604f166b85a7ee2cf0d9cb682966680Jouni Malinen	case WPAS_DBUS_PROP_BSSS:
174875ecf5267604f166b85a7ee2cf0d9cb682966680Jouni Malinen		prop = "BSSs";
174975ecf5267604f166b85a7ee2cf0d9cb682966680Jouni Malinen		break;
175075ecf5267604f166b85a7ee2cf0d9cb682966680Jouni Malinen	case WPAS_DBUS_PROP_CURRENT_AUTH_MODE:
175175ecf5267604f166b85a7ee2cf0d9cb682966680Jouni Malinen		prop = "CurrentAuthMode";
175275ecf5267604f166b85a7ee2cf0d9cb682966680Jouni Malinen		break;
175304949598a23f501be6eec21697465fd46a28840aDmitry Shmidt	case WPAS_DBUS_PROP_DISCONNECT_REASON:
175404949598a23f501be6eec21697465fd46a28840aDmitry Shmidt		prop = "DisconnectReason";
175504949598a23f501be6eec21697465fd46a28840aDmitry Shmidt		flush = TRUE;
175604949598a23f501be6eec21697465fd46a28840aDmitry Shmidt		break;
175775ecf5267604f166b85a7ee2cf0d9cb682966680Jouni Malinen	default:
175875ecf5267604f166b85a7ee2cf0d9cb682966680Jouni Malinen		wpa_printf(MSG_ERROR, "dbus: %s: Unknown Property value %d",
175975ecf5267604f166b85a7ee2cf0d9cb682966680Jouni Malinen			   __func__, property);
176075ecf5267604f166b85a7ee2cf0d9cb682966680Jouni Malinen		return;
176175ecf5267604f166b85a7ee2cf0d9cb682966680Jouni Malinen	}
176275ecf5267604f166b85a7ee2cf0d9cb682966680Jouni Malinen
176375ecf5267604f166b85a7ee2cf0d9cb682966680Jouni Malinen	wpa_dbus_mark_property_changed(wpa_s->global->dbus,
176475ecf5267604f166b85a7ee2cf0d9cb682966680Jouni Malinen				       wpa_s->dbus_new_path,
176575ecf5267604f166b85a7ee2cf0d9cb682966680Jouni Malinen				       WPAS_DBUS_NEW_IFACE_INTERFACE, prop);
176604949598a23f501be6eec21697465fd46a28840aDmitry Shmidt	if (flush) {
176704949598a23f501be6eec21697465fd46a28840aDmitry Shmidt		wpa_dbus_flush_object_changed_properties(
176804949598a23f501be6eec21697465fd46a28840aDmitry Shmidt			wpa_s->global->dbus->con, wpa_s->dbus_new_path);
176904949598a23f501be6eec21697465fd46a28840aDmitry Shmidt	}
177075ecf5267604f166b85a7ee2cf0d9cb682966680Jouni Malinen}
177175ecf5267604f166b85a7ee2cf0d9cb682966680Jouni Malinen
177275ecf5267604f166b85a7ee2cf0d9cb682966680Jouni Malinen
177375ecf5267604f166b85a7ee2cf0d9cb682966680Jouni Malinen/**
177475ecf5267604f166b85a7ee2cf0d9cb682966680Jouni Malinen * wpas_dbus_bss_signal_prop_changed - Signals change of BSS property
177575ecf5267604f166b85a7ee2cf0d9cb682966680Jouni Malinen * @wpa_s: %wpa_supplicant network interface data
177675ecf5267604f166b85a7ee2cf0d9cb682966680Jouni Malinen * @property: indicates which property has changed
177775ecf5267604f166b85a7ee2cf0d9cb682966680Jouni Malinen * @id: unique BSS identifier
177875ecf5267604f166b85a7ee2cf0d9cb682966680Jouni Malinen *
177975ecf5267604f166b85a7ee2cf0d9cb682966680Jouni Malinen * Sends PropertyChanged signals with path, interface, and arguments depending
178075ecf5267604f166b85a7ee2cf0d9cb682966680Jouni Malinen * on which property has changed.
178175ecf5267604f166b85a7ee2cf0d9cb682966680Jouni Malinen */
178275ecf5267604f166b85a7ee2cf0d9cb682966680Jouni Malinenvoid wpas_dbus_bss_signal_prop_changed(struct wpa_supplicant *wpa_s,
178375ecf5267604f166b85a7ee2cf0d9cb682966680Jouni Malinen				       enum wpas_dbus_bss_prop property,
178475ecf5267604f166b85a7ee2cf0d9cb682966680Jouni Malinen				       unsigned int id)
178575ecf5267604f166b85a7ee2cf0d9cb682966680Jouni Malinen{
178675ecf5267604f166b85a7ee2cf0d9cb682966680Jouni Malinen	char path[WPAS_DBUS_OBJECT_PATH_MAX];
178775ecf5267604f166b85a7ee2cf0d9cb682966680Jouni Malinen	char *prop;
178875ecf5267604f166b85a7ee2cf0d9cb682966680Jouni Malinen
178975ecf5267604f166b85a7ee2cf0d9cb682966680Jouni Malinen	switch (property) {
179075ecf5267604f166b85a7ee2cf0d9cb682966680Jouni Malinen	case WPAS_DBUS_BSS_PROP_SIGNAL:
179175ecf5267604f166b85a7ee2cf0d9cb682966680Jouni Malinen		prop = "Signal";
179275ecf5267604f166b85a7ee2cf0d9cb682966680Jouni Malinen		break;
179375ecf5267604f166b85a7ee2cf0d9cb682966680Jouni Malinen	case WPAS_DBUS_BSS_PROP_FREQ:
179475ecf5267604f166b85a7ee2cf0d9cb682966680Jouni Malinen		prop = "Frequency";
179575ecf5267604f166b85a7ee2cf0d9cb682966680Jouni Malinen		break;
179675ecf5267604f166b85a7ee2cf0d9cb682966680Jouni Malinen	case WPAS_DBUS_BSS_PROP_MODE:
179775ecf5267604f166b85a7ee2cf0d9cb682966680Jouni Malinen		prop = "Mode";
179875ecf5267604f166b85a7ee2cf0d9cb682966680Jouni Malinen		break;
179975ecf5267604f166b85a7ee2cf0d9cb682966680Jouni Malinen	case WPAS_DBUS_BSS_PROP_PRIVACY:
180075ecf5267604f166b85a7ee2cf0d9cb682966680Jouni Malinen		prop = "Privacy";
180175ecf5267604f166b85a7ee2cf0d9cb682966680Jouni Malinen		break;
180275ecf5267604f166b85a7ee2cf0d9cb682966680Jouni Malinen	case WPAS_DBUS_BSS_PROP_RATES:
180375ecf5267604f166b85a7ee2cf0d9cb682966680Jouni Malinen		prop = "Rates";
180475ecf5267604f166b85a7ee2cf0d9cb682966680Jouni Malinen		break;
180575ecf5267604f166b85a7ee2cf0d9cb682966680Jouni Malinen	case WPAS_DBUS_BSS_PROP_WPA:
180675ecf5267604f166b85a7ee2cf0d9cb682966680Jouni Malinen		prop = "WPA";
180775ecf5267604f166b85a7ee2cf0d9cb682966680Jouni Malinen		break;
180875ecf5267604f166b85a7ee2cf0d9cb682966680Jouni Malinen	case WPAS_DBUS_BSS_PROP_RSN:
180975ecf5267604f166b85a7ee2cf0d9cb682966680Jouni Malinen		prop = "RSN";
181075ecf5267604f166b85a7ee2cf0d9cb682966680Jouni Malinen		break;
181175ecf5267604f166b85a7ee2cf0d9cb682966680Jouni Malinen	case WPAS_DBUS_BSS_PROP_IES:
181275ecf5267604f166b85a7ee2cf0d9cb682966680Jouni Malinen		prop = "IEs";
181375ecf5267604f166b85a7ee2cf0d9cb682966680Jouni Malinen		break;
181475ecf5267604f166b85a7ee2cf0d9cb682966680Jouni Malinen	default:
181575ecf5267604f166b85a7ee2cf0d9cb682966680Jouni Malinen		wpa_printf(MSG_ERROR, "dbus: %s: Unknown Property value %d",
181675ecf5267604f166b85a7ee2cf0d9cb682966680Jouni Malinen			   __func__, property);
181775ecf5267604f166b85a7ee2cf0d9cb682966680Jouni Malinen		return;
181875ecf5267604f166b85a7ee2cf0d9cb682966680Jouni Malinen	}
181975ecf5267604f166b85a7ee2cf0d9cb682966680Jouni Malinen
182075ecf5267604f166b85a7ee2cf0d9cb682966680Jouni Malinen	os_snprintf(path, WPAS_DBUS_OBJECT_PATH_MAX,
182175ecf5267604f166b85a7ee2cf0d9cb682966680Jouni Malinen		    "%s/" WPAS_DBUS_NEW_BSSIDS_PART "/%u",
182275ecf5267604f166b85a7ee2cf0d9cb682966680Jouni Malinen		    wpa_s->dbus_new_path, id);
182375ecf5267604f166b85a7ee2cf0d9cb682966680Jouni Malinen
182475ecf5267604f166b85a7ee2cf0d9cb682966680Jouni Malinen	wpa_dbus_mark_property_changed(wpa_s->global->dbus, path,
182575ecf5267604f166b85a7ee2cf0d9cb682966680Jouni Malinen				       WPAS_DBUS_NEW_IFACE_BSS, prop);
182675ecf5267604f166b85a7ee2cf0d9cb682966680Jouni Malinen}
182775ecf5267604f166b85a7ee2cf0d9cb682966680Jouni Malinen
182875ecf5267604f166b85a7ee2cf0d9cb682966680Jouni Malinen
182975ecf5267604f166b85a7ee2cf0d9cb682966680Jouni Malinen/**
183075ecf5267604f166b85a7ee2cf0d9cb682966680Jouni Malinen * wpas_dbus_signal_debug_level_changed - Signals change of debug param
183175ecf5267604f166b85a7ee2cf0d9cb682966680Jouni Malinen * @global: wpa_global structure
183275ecf5267604f166b85a7ee2cf0d9cb682966680Jouni Malinen *
183375ecf5267604f166b85a7ee2cf0d9cb682966680Jouni Malinen * Sends PropertyChanged signals informing that debug level has changed.
183475ecf5267604f166b85a7ee2cf0d9cb682966680Jouni Malinen */
183575ecf5267604f166b85a7ee2cf0d9cb682966680Jouni Malinenvoid wpas_dbus_signal_debug_level_changed(struct wpa_global *global)
183675ecf5267604f166b85a7ee2cf0d9cb682966680Jouni Malinen{
183775ecf5267604f166b85a7ee2cf0d9cb682966680Jouni Malinen	wpa_dbus_mark_property_changed(global->dbus, WPAS_DBUS_NEW_PATH,
183875ecf5267604f166b85a7ee2cf0d9cb682966680Jouni Malinen				       WPAS_DBUS_NEW_INTERFACE,
183975ecf5267604f166b85a7ee2cf0d9cb682966680Jouni Malinen				       "DebugLevel");
184075ecf5267604f166b85a7ee2cf0d9cb682966680Jouni Malinen}
184175ecf5267604f166b85a7ee2cf0d9cb682966680Jouni Malinen
184275ecf5267604f166b85a7ee2cf0d9cb682966680Jouni Malinen
184375ecf5267604f166b85a7ee2cf0d9cb682966680Jouni Malinen/**
184475ecf5267604f166b85a7ee2cf0d9cb682966680Jouni Malinen * wpas_dbus_signal_debug_timestamp_changed - Signals change of debug param
184575ecf5267604f166b85a7ee2cf0d9cb682966680Jouni Malinen * @global: wpa_global structure
184675ecf5267604f166b85a7ee2cf0d9cb682966680Jouni Malinen *
184775ecf5267604f166b85a7ee2cf0d9cb682966680Jouni Malinen * Sends PropertyChanged signals informing that debug timestamp has changed.
184875ecf5267604f166b85a7ee2cf0d9cb682966680Jouni Malinen */
184975ecf5267604f166b85a7ee2cf0d9cb682966680Jouni Malinenvoid wpas_dbus_signal_debug_timestamp_changed(struct wpa_global *global)
185075ecf5267604f166b85a7ee2cf0d9cb682966680Jouni Malinen{
185175ecf5267604f166b85a7ee2cf0d9cb682966680Jouni Malinen	wpa_dbus_mark_property_changed(global->dbus, WPAS_DBUS_NEW_PATH,
185275ecf5267604f166b85a7ee2cf0d9cb682966680Jouni Malinen				       WPAS_DBUS_NEW_INTERFACE,
185375ecf5267604f166b85a7ee2cf0d9cb682966680Jouni Malinen				       "DebugTimestamp");
185475ecf5267604f166b85a7ee2cf0d9cb682966680Jouni Malinen}
185575ecf5267604f166b85a7ee2cf0d9cb682966680Jouni Malinen
185675ecf5267604f166b85a7ee2cf0d9cb682966680Jouni Malinen
185775ecf5267604f166b85a7ee2cf0d9cb682966680Jouni Malinen/**
185875ecf5267604f166b85a7ee2cf0d9cb682966680Jouni Malinen * wpas_dbus_signal_debug_show_keys_changed - Signals change of debug param
185975ecf5267604f166b85a7ee2cf0d9cb682966680Jouni Malinen * @global: wpa_global structure
186075ecf5267604f166b85a7ee2cf0d9cb682966680Jouni Malinen *
186175ecf5267604f166b85a7ee2cf0d9cb682966680Jouni Malinen * Sends PropertyChanged signals informing that debug show_keys has changed.
186275ecf5267604f166b85a7ee2cf0d9cb682966680Jouni Malinen */
186375ecf5267604f166b85a7ee2cf0d9cb682966680Jouni Malinenvoid wpas_dbus_signal_debug_show_keys_changed(struct wpa_global *global)
186475ecf5267604f166b85a7ee2cf0d9cb682966680Jouni Malinen{
186575ecf5267604f166b85a7ee2cf0d9cb682966680Jouni Malinen	wpa_dbus_mark_property_changed(global->dbus, WPAS_DBUS_NEW_PATH,
186675ecf5267604f166b85a7ee2cf0d9cb682966680Jouni Malinen				       WPAS_DBUS_NEW_INTERFACE,
186775ecf5267604f166b85a7ee2cf0d9cb682966680Jouni Malinen				       "DebugShowKeys");
186875ecf5267604f166b85a7ee2cf0d9cb682966680Jouni Malinen}
186975ecf5267604f166b85a7ee2cf0d9cb682966680Jouni Malinen
187075ecf5267604f166b85a7ee2cf0d9cb682966680Jouni Malinen
187175ecf5267604f166b85a7ee2cf0d9cb682966680Jouni Malinenstatic void wpas_dbus_register(struct wpa_dbus_object_desc *obj_desc,
187275ecf5267604f166b85a7ee2cf0d9cb682966680Jouni Malinen			       void *priv,
187375ecf5267604f166b85a7ee2cf0d9cb682966680Jouni Malinen			       WPADBusArgumentFreeFunction priv_free,
187475ecf5267604f166b85a7ee2cf0d9cb682966680Jouni Malinen			       const struct wpa_dbus_method_desc *methods,
187575ecf5267604f166b85a7ee2cf0d9cb682966680Jouni Malinen			       const struct wpa_dbus_property_desc *properties,
187675ecf5267604f166b85a7ee2cf0d9cb682966680Jouni Malinen			       const struct wpa_dbus_signal_desc *signals)
187775ecf5267604f166b85a7ee2cf0d9cb682966680Jouni Malinen{
187875ecf5267604f166b85a7ee2cf0d9cb682966680Jouni Malinen	int n;
187975ecf5267604f166b85a7ee2cf0d9cb682966680Jouni Malinen
188075ecf5267604f166b85a7ee2cf0d9cb682966680Jouni Malinen	obj_desc->user_data = priv;
188175ecf5267604f166b85a7ee2cf0d9cb682966680Jouni Malinen	obj_desc->user_data_free_func = priv_free;
188275ecf5267604f166b85a7ee2cf0d9cb682966680Jouni Malinen	obj_desc->methods = methods;
188375ecf5267604f166b85a7ee2cf0d9cb682966680Jouni Malinen	obj_desc->properties = properties;
188475ecf5267604f166b85a7ee2cf0d9cb682966680Jouni Malinen	obj_desc->signals = signals;
188575ecf5267604f166b85a7ee2cf0d9cb682966680Jouni Malinen
188675ecf5267604f166b85a7ee2cf0d9cb682966680Jouni Malinen	for (n = 0; properties && properties->dbus_property; properties++)
188775ecf5267604f166b85a7ee2cf0d9cb682966680Jouni Malinen		n++;
188875ecf5267604f166b85a7ee2cf0d9cb682966680Jouni Malinen
188975ecf5267604f166b85a7ee2cf0d9cb682966680Jouni Malinen	obj_desc->prop_changed_flags = os_zalloc(n);
189075ecf5267604f166b85a7ee2cf0d9cb682966680Jouni Malinen	if (!obj_desc->prop_changed_flags)
189175ecf5267604f166b85a7ee2cf0d9cb682966680Jouni Malinen		wpa_printf(MSG_DEBUG, "dbus: %s: can't register handlers",
189275ecf5267604f166b85a7ee2cf0d9cb682966680Jouni Malinen			   __func__);
189375ecf5267604f166b85a7ee2cf0d9cb682966680Jouni Malinen}
189475ecf5267604f166b85a7ee2cf0d9cb682966680Jouni Malinen
189575ecf5267604f166b85a7ee2cf0d9cb682966680Jouni Malinen
189675ecf5267604f166b85a7ee2cf0d9cb682966680Jouni Malinenstatic const struct wpa_dbus_method_desc wpas_dbus_global_methods[] = {
18978d520ff1dc2da35cdca849e982051b86468016d8Dmitry Shmidt	{ "CreateInterface", WPAS_DBUS_NEW_INTERFACE,
18988d520ff1dc2da35cdca849e982051b86468016d8Dmitry Shmidt	  (WPADBusMethodHandler) &wpas_dbus_handler_create_interface,
18998d520ff1dc2da35cdca849e982051b86468016d8Dmitry Shmidt	  {
19008d520ff1dc2da35cdca849e982051b86468016d8Dmitry Shmidt		  { "args", "a{sv}", ARG_IN },
19018d520ff1dc2da35cdca849e982051b86468016d8Dmitry Shmidt		  { "path", "o", ARG_OUT },
19028d520ff1dc2da35cdca849e982051b86468016d8Dmitry Shmidt		  END_ARGS
19038d520ff1dc2da35cdca849e982051b86468016d8Dmitry Shmidt	  }
19048d520ff1dc2da35cdca849e982051b86468016d8Dmitry Shmidt	},
19058d520ff1dc2da35cdca849e982051b86468016d8Dmitry Shmidt	{ "RemoveInterface", WPAS_DBUS_NEW_INTERFACE,
19068d520ff1dc2da35cdca849e982051b86468016d8Dmitry Shmidt	  (WPADBusMethodHandler) &wpas_dbus_handler_remove_interface,
19078d520ff1dc2da35cdca849e982051b86468016d8Dmitry Shmidt	  {
19088d520ff1dc2da35cdca849e982051b86468016d8Dmitry Shmidt		  { "path", "o", ARG_IN },
19098d520ff1dc2da35cdca849e982051b86468016d8Dmitry Shmidt		  END_ARGS
19108d520ff1dc2da35cdca849e982051b86468016d8Dmitry Shmidt	  }
19118d520ff1dc2da35cdca849e982051b86468016d8Dmitry Shmidt	},
19128d520ff1dc2da35cdca849e982051b86468016d8Dmitry Shmidt	{ "GetInterface", WPAS_DBUS_NEW_INTERFACE,
19138d520ff1dc2da35cdca849e982051b86468016d8Dmitry Shmidt	  (WPADBusMethodHandler) &wpas_dbus_handler_get_interface,
19148d520ff1dc2da35cdca849e982051b86468016d8Dmitry Shmidt	  {
19158d520ff1dc2da35cdca849e982051b86468016d8Dmitry Shmidt		  { "ifname", "s", ARG_IN },
19168d520ff1dc2da35cdca849e982051b86468016d8Dmitry Shmidt		  { "path", "o", ARG_OUT },
19178d520ff1dc2da35cdca849e982051b86468016d8Dmitry Shmidt		  END_ARGS
19188d520ff1dc2da35cdca849e982051b86468016d8Dmitry Shmidt	  }
19198d520ff1dc2da35cdca849e982051b86468016d8Dmitry Shmidt	},
192004949598a23f501be6eec21697465fd46a28840aDmitry Shmidt#ifdef CONFIG_AUTOSCAN
192104949598a23f501be6eec21697465fd46a28840aDmitry Shmidt	{ "AutoScan", WPAS_DBUS_NEW_IFACE_INTERFACE,
192204949598a23f501be6eec21697465fd46a28840aDmitry Shmidt	  (WPADBusMethodHandler) &wpas_dbus_handler_autoscan,
192304949598a23f501be6eec21697465fd46a28840aDmitry Shmidt	  {
192404949598a23f501be6eec21697465fd46a28840aDmitry Shmidt		  { "arg", "s", ARG_IN },
192504949598a23f501be6eec21697465fd46a28840aDmitry Shmidt		  END_ARGS
192604949598a23f501be6eec21697465fd46a28840aDmitry Shmidt	  }
192704949598a23f501be6eec21697465fd46a28840aDmitry Shmidt	},
192804949598a23f501be6eec21697465fd46a28840aDmitry Shmidt#endif /* CONFIG_AUTOSCAN */
19298d520ff1dc2da35cdca849e982051b86468016d8Dmitry Shmidt	{ NULL, NULL, NULL, { END_ARGS } }
19308d520ff1dc2da35cdca849e982051b86468016d8Dmitry Shmidt};
19318d520ff1dc2da35cdca849e982051b86468016d8Dmitry Shmidt
19328d520ff1dc2da35cdca849e982051b86468016d8Dmitry Shmidtstatic const struct wpa_dbus_property_desc wpas_dbus_global_properties[] = {
19338d520ff1dc2da35cdca849e982051b86468016d8Dmitry Shmidt	{ "DebugLevel", WPAS_DBUS_NEW_INTERFACE, "s",
19341f69aa52ea2e0a73ac502565df8c666ee49cab6aDmitry Shmidt	  wpas_dbus_getter_debug_level,
19351f69aa52ea2e0a73ac502565df8c666ee49cab6aDmitry Shmidt	  wpas_dbus_setter_debug_level
19368d520ff1dc2da35cdca849e982051b86468016d8Dmitry Shmidt	},
19378d520ff1dc2da35cdca849e982051b86468016d8Dmitry Shmidt	{ "DebugTimestamp", WPAS_DBUS_NEW_INTERFACE, "b",
19381f69aa52ea2e0a73ac502565df8c666ee49cab6aDmitry Shmidt	  wpas_dbus_getter_debug_timestamp,
19391f69aa52ea2e0a73ac502565df8c666ee49cab6aDmitry Shmidt	  wpas_dbus_setter_debug_timestamp
19408d520ff1dc2da35cdca849e982051b86468016d8Dmitry Shmidt	},
19418d520ff1dc2da35cdca849e982051b86468016d8Dmitry Shmidt	{ "DebugShowKeys", WPAS_DBUS_NEW_INTERFACE, "b",
19421f69aa52ea2e0a73ac502565df8c666ee49cab6aDmitry Shmidt	  wpas_dbus_getter_debug_show_keys,
19431f69aa52ea2e0a73ac502565df8c666ee49cab6aDmitry Shmidt	  wpas_dbus_setter_debug_show_keys
19448d520ff1dc2da35cdca849e982051b86468016d8Dmitry Shmidt	},
19458d520ff1dc2da35cdca849e982051b86468016d8Dmitry Shmidt	{ "Interfaces", WPAS_DBUS_NEW_INTERFACE, "ao",
19461f69aa52ea2e0a73ac502565df8c666ee49cab6aDmitry Shmidt	  wpas_dbus_getter_interfaces,
19471f69aa52ea2e0a73ac502565df8c666ee49cab6aDmitry Shmidt	  NULL
19488d520ff1dc2da35cdca849e982051b86468016d8Dmitry Shmidt	},
19498d520ff1dc2da35cdca849e982051b86468016d8Dmitry Shmidt	{ "EapMethods", WPAS_DBUS_NEW_INTERFACE, "as",
19501f69aa52ea2e0a73ac502565df8c666ee49cab6aDmitry Shmidt	  wpas_dbus_getter_eap_methods,
19511f69aa52ea2e0a73ac502565df8c666ee49cab6aDmitry Shmidt	  NULL
19528d520ff1dc2da35cdca849e982051b86468016d8Dmitry Shmidt	},
19531f69aa52ea2e0a73ac502565df8c666ee49cab6aDmitry Shmidt	{ NULL, NULL, NULL, NULL, NULL }
19548d520ff1dc2da35cdca849e982051b86468016d8Dmitry Shmidt};
19558d520ff1dc2da35cdca849e982051b86468016d8Dmitry Shmidt
19568d520ff1dc2da35cdca849e982051b86468016d8Dmitry Shmidtstatic const struct wpa_dbus_signal_desc wpas_dbus_global_signals[] = {
19578d520ff1dc2da35cdca849e982051b86468016d8Dmitry Shmidt	{ "InterfaceAdded", WPAS_DBUS_NEW_INTERFACE,
19588d520ff1dc2da35cdca849e982051b86468016d8Dmitry Shmidt	  {
19598d520ff1dc2da35cdca849e982051b86468016d8Dmitry Shmidt		  { "path", "o", ARG_OUT },
19608d520ff1dc2da35cdca849e982051b86468016d8Dmitry Shmidt		  { "properties", "a{sv}", ARG_OUT },
19618d520ff1dc2da35cdca849e982051b86468016d8Dmitry Shmidt		  END_ARGS
19628d520ff1dc2da35cdca849e982051b86468016d8Dmitry Shmidt	  }
19638d520ff1dc2da35cdca849e982051b86468016d8Dmitry Shmidt	},
19648d520ff1dc2da35cdca849e982051b86468016d8Dmitry Shmidt	{ "InterfaceRemoved", WPAS_DBUS_NEW_INTERFACE,
19658d520ff1dc2da35cdca849e982051b86468016d8Dmitry Shmidt	  {
19668d520ff1dc2da35cdca849e982051b86468016d8Dmitry Shmidt		  { "path", "o", ARG_OUT },
19678d520ff1dc2da35cdca849e982051b86468016d8Dmitry Shmidt		  END_ARGS
19688d520ff1dc2da35cdca849e982051b86468016d8Dmitry Shmidt	  }
19698d520ff1dc2da35cdca849e982051b86468016d8Dmitry Shmidt	},
19701f69aa52ea2e0a73ac502565df8c666ee49cab6aDmitry Shmidt	{ "NetworkRequest", WPAS_DBUS_NEW_IFACE_INTERFACE,
19711f69aa52ea2e0a73ac502565df8c666ee49cab6aDmitry Shmidt	  {
19721f69aa52ea2e0a73ac502565df8c666ee49cab6aDmitry Shmidt		  { "path", "o", ARG_OUT },
19731f69aa52ea2e0a73ac502565df8c666ee49cab6aDmitry Shmidt		  { "field", "s", ARG_OUT },
19741f69aa52ea2e0a73ac502565df8c666ee49cab6aDmitry Shmidt		  { "text", "s", ARG_OUT },
19751f69aa52ea2e0a73ac502565df8c666ee49cab6aDmitry Shmidt		  END_ARGS
19761f69aa52ea2e0a73ac502565df8c666ee49cab6aDmitry Shmidt	  }
19771f69aa52ea2e0a73ac502565df8c666ee49cab6aDmitry Shmidt	},
19781f69aa52ea2e0a73ac502565df8c666ee49cab6aDmitry Shmidt	/* Deprecated: use org.freedesktop.DBus.Properties.PropertiesChanged */
19798d520ff1dc2da35cdca849e982051b86468016d8Dmitry Shmidt	{ "PropertiesChanged", WPAS_DBUS_NEW_INTERFACE,
19808d520ff1dc2da35cdca849e982051b86468016d8Dmitry Shmidt	  {
19818d520ff1dc2da35cdca849e982051b86468016d8Dmitry Shmidt		  { "properties", "a{sv}", ARG_OUT },
19828d520ff1dc2da35cdca849e982051b86468016d8Dmitry Shmidt		  END_ARGS
19838d520ff1dc2da35cdca849e982051b86468016d8Dmitry Shmidt	  }
19848d520ff1dc2da35cdca849e982051b86468016d8Dmitry Shmidt	},
19858d520ff1dc2da35cdca849e982051b86468016d8Dmitry Shmidt	{ NULL, NULL, { END_ARGS } }
19868d520ff1dc2da35cdca849e982051b86468016d8Dmitry Shmidt};
19878d520ff1dc2da35cdca849e982051b86468016d8Dmitry Shmidt
19888d520ff1dc2da35cdca849e982051b86468016d8Dmitry Shmidt
19898d520ff1dc2da35cdca849e982051b86468016d8Dmitry Shmidt/**
19908d520ff1dc2da35cdca849e982051b86468016d8Dmitry Shmidt * wpas_dbus_ctrl_iface_init - Initialize dbus control interface
19918d520ff1dc2da35cdca849e982051b86468016d8Dmitry Shmidt * @global: Pointer to global data from wpa_supplicant_init()
19928d520ff1dc2da35cdca849e982051b86468016d8Dmitry Shmidt * Returns: 0 on success or -1 on failure
19938d520ff1dc2da35cdca849e982051b86468016d8Dmitry Shmidt *
19948d520ff1dc2da35cdca849e982051b86468016d8Dmitry Shmidt * Initialize the dbus control interface for wpa_supplicantand and start
19958d520ff1dc2da35cdca849e982051b86468016d8Dmitry Shmidt * receiving commands from external programs over the bus.
19968d520ff1dc2da35cdca849e982051b86468016d8Dmitry Shmidt */
19978d520ff1dc2da35cdca849e982051b86468016d8Dmitry Shmidtint wpas_dbus_ctrl_iface_init(struct wpas_dbus_priv *priv)
19988d520ff1dc2da35cdca849e982051b86468016d8Dmitry Shmidt{
19998d520ff1dc2da35cdca849e982051b86468016d8Dmitry Shmidt	struct wpa_dbus_object_desc *obj_desc;
20008d520ff1dc2da35cdca849e982051b86468016d8Dmitry Shmidt	int ret;
20018d520ff1dc2da35cdca849e982051b86468016d8Dmitry Shmidt
20028d520ff1dc2da35cdca849e982051b86468016d8Dmitry Shmidt	obj_desc = os_zalloc(sizeof(struct wpa_dbus_object_desc));
20038d520ff1dc2da35cdca849e982051b86468016d8Dmitry Shmidt	if (!obj_desc) {
20048d520ff1dc2da35cdca849e982051b86468016d8Dmitry Shmidt		wpa_printf(MSG_ERROR, "Not enough memory "
20058d520ff1dc2da35cdca849e982051b86468016d8Dmitry Shmidt			   "to create object description");
20068d520ff1dc2da35cdca849e982051b86468016d8Dmitry Shmidt		return -1;
20078d520ff1dc2da35cdca849e982051b86468016d8Dmitry Shmidt	}
20088d520ff1dc2da35cdca849e982051b86468016d8Dmitry Shmidt
20098d520ff1dc2da35cdca849e982051b86468016d8Dmitry Shmidt	wpas_dbus_register(obj_desc, priv->global, NULL,
20108d520ff1dc2da35cdca849e982051b86468016d8Dmitry Shmidt			   wpas_dbus_global_methods,
20118d520ff1dc2da35cdca849e982051b86468016d8Dmitry Shmidt			   wpas_dbus_global_properties,
20128d520ff1dc2da35cdca849e982051b86468016d8Dmitry Shmidt			   wpas_dbus_global_signals);
20138d520ff1dc2da35cdca849e982051b86468016d8Dmitry Shmidt
20148d520ff1dc2da35cdca849e982051b86468016d8Dmitry Shmidt	wpa_printf(MSG_DEBUG, "dbus: Register D-Bus object '%s'",
20158d520ff1dc2da35cdca849e982051b86468016d8Dmitry Shmidt		   WPAS_DBUS_NEW_PATH);
20168d520ff1dc2da35cdca849e982051b86468016d8Dmitry Shmidt	ret = wpa_dbus_ctrl_iface_init(priv, WPAS_DBUS_NEW_PATH,
20178d520ff1dc2da35cdca849e982051b86468016d8Dmitry Shmidt				       WPAS_DBUS_NEW_SERVICE,
20188d520ff1dc2da35cdca849e982051b86468016d8Dmitry Shmidt				       obj_desc);
20198d520ff1dc2da35cdca849e982051b86468016d8Dmitry Shmidt	if (ret < 0)
20208d520ff1dc2da35cdca849e982051b86468016d8Dmitry Shmidt		free_dbus_object_desc(obj_desc);
20218d520ff1dc2da35cdca849e982051b86468016d8Dmitry Shmidt	else
20228d520ff1dc2da35cdca849e982051b86468016d8Dmitry Shmidt		priv->dbus_new_initialized = 1;
20238d520ff1dc2da35cdca849e982051b86468016d8Dmitry Shmidt
20248d520ff1dc2da35cdca849e982051b86468016d8Dmitry Shmidt	return ret;
20258d520ff1dc2da35cdca849e982051b86468016d8Dmitry Shmidt}
20268d520ff1dc2da35cdca849e982051b86468016d8Dmitry Shmidt
20278d520ff1dc2da35cdca849e982051b86468016d8Dmitry Shmidt
20288d520ff1dc2da35cdca849e982051b86468016d8Dmitry Shmidt/**
20298d520ff1dc2da35cdca849e982051b86468016d8Dmitry Shmidt * wpas_dbus_ctrl_iface_deinit - Deinitialize dbus ctrl interface for
20308d520ff1dc2da35cdca849e982051b86468016d8Dmitry Shmidt * wpa_supplicant
20318d520ff1dc2da35cdca849e982051b86468016d8Dmitry Shmidt * @iface: Pointer to dbus private data from wpas_dbus_init()
20328d520ff1dc2da35cdca849e982051b86468016d8Dmitry Shmidt *
20338d520ff1dc2da35cdca849e982051b86468016d8Dmitry Shmidt * Deinitialize the dbus control interface that was initialized with
20348d520ff1dc2da35cdca849e982051b86468016d8Dmitry Shmidt * wpas_dbus_ctrl_iface_init().
20358d520ff1dc2da35cdca849e982051b86468016d8Dmitry Shmidt */
20368d520ff1dc2da35cdca849e982051b86468016d8Dmitry Shmidtvoid wpas_dbus_ctrl_iface_deinit(struct wpas_dbus_priv *iface)
20378d520ff1dc2da35cdca849e982051b86468016d8Dmitry Shmidt{
20388d520ff1dc2da35cdca849e982051b86468016d8Dmitry Shmidt	if (!iface->dbus_new_initialized)
20398d520ff1dc2da35cdca849e982051b86468016d8Dmitry Shmidt		return;
20408d520ff1dc2da35cdca849e982051b86468016d8Dmitry Shmidt	wpa_printf(MSG_DEBUG, "dbus: Unregister D-Bus object '%s'",
20418d520ff1dc2da35cdca849e982051b86468016d8Dmitry Shmidt		   WPAS_DBUS_NEW_PATH);
20428d520ff1dc2da35cdca849e982051b86468016d8Dmitry Shmidt	dbus_connection_unregister_object_path(iface->con,
20438d520ff1dc2da35cdca849e982051b86468016d8Dmitry Shmidt					       WPAS_DBUS_NEW_PATH);
20448d520ff1dc2da35cdca849e982051b86468016d8Dmitry Shmidt}
20458d520ff1dc2da35cdca849e982051b86468016d8Dmitry Shmidt
20468d520ff1dc2da35cdca849e982051b86468016d8Dmitry Shmidt
20478d520ff1dc2da35cdca849e982051b86468016d8Dmitry Shmidtstatic void wpa_dbus_free(void *ptr)
20488d520ff1dc2da35cdca849e982051b86468016d8Dmitry Shmidt{
20498d520ff1dc2da35cdca849e982051b86468016d8Dmitry Shmidt	os_free(ptr);
20508d520ff1dc2da35cdca849e982051b86468016d8Dmitry Shmidt}
20518d520ff1dc2da35cdca849e982051b86468016d8Dmitry Shmidt
20528d520ff1dc2da35cdca849e982051b86468016d8Dmitry Shmidt
20538d520ff1dc2da35cdca849e982051b86468016d8Dmitry Shmidtstatic const struct wpa_dbus_property_desc wpas_dbus_network_properties[] = {
20548d520ff1dc2da35cdca849e982051b86468016d8Dmitry Shmidt	{ "Properties", WPAS_DBUS_NEW_IFACE_NETWORK, "a{sv}",
20551f69aa52ea2e0a73ac502565df8c666ee49cab6aDmitry Shmidt	  wpas_dbus_getter_network_properties,
20561f69aa52ea2e0a73ac502565df8c666ee49cab6aDmitry Shmidt	  wpas_dbus_setter_network_properties
20578d520ff1dc2da35cdca849e982051b86468016d8Dmitry Shmidt	},
20588d520ff1dc2da35cdca849e982051b86468016d8Dmitry Shmidt	{ "Enabled", WPAS_DBUS_NEW_IFACE_NETWORK, "b",
20591f69aa52ea2e0a73ac502565df8c666ee49cab6aDmitry Shmidt	  wpas_dbus_getter_enabled,
20601f69aa52ea2e0a73ac502565df8c666ee49cab6aDmitry Shmidt	  wpas_dbus_setter_enabled
20618d520ff1dc2da35cdca849e982051b86468016d8Dmitry Shmidt	},
20621f69aa52ea2e0a73ac502565df8c666ee49cab6aDmitry Shmidt	{ NULL, NULL, NULL, NULL, NULL }
20638d520ff1dc2da35cdca849e982051b86468016d8Dmitry Shmidt};
20648d520ff1dc2da35cdca849e982051b86468016d8Dmitry Shmidt
20658d520ff1dc2da35cdca849e982051b86468016d8Dmitry Shmidt
20668d520ff1dc2da35cdca849e982051b86468016d8Dmitry Shmidtstatic const struct wpa_dbus_signal_desc wpas_dbus_network_signals[] = {
20671f69aa52ea2e0a73ac502565df8c666ee49cab6aDmitry Shmidt	/* Deprecated: use org.freedesktop.DBus.Properties.PropertiesChanged */
20688d520ff1dc2da35cdca849e982051b86468016d8Dmitry Shmidt	{ "PropertiesChanged", WPAS_DBUS_NEW_IFACE_NETWORK,
20698d520ff1dc2da35cdca849e982051b86468016d8Dmitry Shmidt	  {
20708d520ff1dc2da35cdca849e982051b86468016d8Dmitry Shmidt		  { "properties", "a{sv}", ARG_OUT },
20718d520ff1dc2da35cdca849e982051b86468016d8Dmitry Shmidt		  END_ARGS
20728d520ff1dc2da35cdca849e982051b86468016d8Dmitry Shmidt	  }
20738d520ff1dc2da35cdca849e982051b86468016d8Dmitry Shmidt	},
20748d520ff1dc2da35cdca849e982051b86468016d8Dmitry Shmidt	{ NULL, NULL, { END_ARGS } }
20758d520ff1dc2da35cdca849e982051b86468016d8Dmitry Shmidt};
20768d520ff1dc2da35cdca849e982051b86468016d8Dmitry Shmidt
20778d520ff1dc2da35cdca849e982051b86468016d8Dmitry Shmidt
20788d520ff1dc2da35cdca849e982051b86468016d8Dmitry Shmidt/**
20798d520ff1dc2da35cdca849e982051b86468016d8Dmitry Shmidt * wpas_dbus_register_network - Register a configured network with dbus
20808d520ff1dc2da35cdca849e982051b86468016d8Dmitry Shmidt * @wpa_s: wpa_supplicant interface structure
20818d520ff1dc2da35cdca849e982051b86468016d8Dmitry Shmidt * @ssid: network configuration data
20828d520ff1dc2da35cdca849e982051b86468016d8Dmitry Shmidt * Returns: 0 on success, -1 on failure
20838d520ff1dc2da35cdca849e982051b86468016d8Dmitry Shmidt *
20848d520ff1dc2da35cdca849e982051b86468016d8Dmitry Shmidt * Registers network representing object with dbus
20858d520ff1dc2da35cdca849e982051b86468016d8Dmitry Shmidt */
20868d520ff1dc2da35cdca849e982051b86468016d8Dmitry Shmidtint wpas_dbus_register_network(struct wpa_supplicant *wpa_s,
20878d520ff1dc2da35cdca849e982051b86468016d8Dmitry Shmidt			       struct wpa_ssid *ssid)
20888d520ff1dc2da35cdca849e982051b86468016d8Dmitry Shmidt{
20898d520ff1dc2da35cdca849e982051b86468016d8Dmitry Shmidt	struct wpas_dbus_priv *ctrl_iface;
20908d520ff1dc2da35cdca849e982051b86468016d8Dmitry Shmidt	struct wpa_dbus_object_desc *obj_desc;
20918d520ff1dc2da35cdca849e982051b86468016d8Dmitry Shmidt	struct network_handler_args *arg;
20928d520ff1dc2da35cdca849e982051b86468016d8Dmitry Shmidt	char net_obj_path[WPAS_DBUS_OBJECT_PATH_MAX];
20938d520ff1dc2da35cdca849e982051b86468016d8Dmitry Shmidt
2094c55524ad84d13014e8019491c2b17e5dcf13545aDmitry Shmidt#ifdef CONFIG_P2P
209575ecf5267604f166b85a7ee2cf0d9cb682966680Jouni Malinen	/*
209675ecf5267604f166b85a7ee2cf0d9cb682966680Jouni Malinen	 * If it is a persistent group register it as such.
209775ecf5267604f166b85a7ee2cf0d9cb682966680Jouni Malinen	 * This is to handle cases where an interface is being initialized
209875ecf5267604f166b85a7ee2cf0d9cb682966680Jouni Malinen	 * with a list of networks read from config.
209975ecf5267604f166b85a7ee2cf0d9cb682966680Jouni Malinen	 */
210075ecf5267604f166b85a7ee2cf0d9cb682966680Jouni Malinen	if (network_is_persistent_group(ssid))
210175ecf5267604f166b85a7ee2cf0d9cb682966680Jouni Malinen		return wpas_dbus_register_persistent_group(wpa_s, ssid);
2102c55524ad84d13014e8019491c2b17e5dcf13545aDmitry Shmidt#endif /* CONFIG_P2P */
210375ecf5267604f166b85a7ee2cf0d9cb682966680Jouni Malinen
21048d520ff1dc2da35cdca849e982051b86468016d8Dmitry Shmidt	/* Do nothing if the control interface is not turned on */
21058d520ff1dc2da35cdca849e982051b86468016d8Dmitry Shmidt	if (wpa_s == NULL || wpa_s->global == NULL)
21068d520ff1dc2da35cdca849e982051b86468016d8Dmitry Shmidt		return 0;
21078d520ff1dc2da35cdca849e982051b86468016d8Dmitry Shmidt	ctrl_iface = wpa_s->global->dbus;
21088d520ff1dc2da35cdca849e982051b86468016d8Dmitry Shmidt	if (ctrl_iface == NULL)
21098d520ff1dc2da35cdca849e982051b86468016d8Dmitry Shmidt		return 0;
21108d520ff1dc2da35cdca849e982051b86468016d8Dmitry Shmidt
21118d520ff1dc2da35cdca849e982051b86468016d8Dmitry Shmidt	os_snprintf(net_obj_path, WPAS_DBUS_OBJECT_PATH_MAX,
21128d520ff1dc2da35cdca849e982051b86468016d8Dmitry Shmidt		    "%s/" WPAS_DBUS_NEW_NETWORKS_PART "/%u",
21138d520ff1dc2da35cdca849e982051b86468016d8Dmitry Shmidt		    wpa_s->dbus_new_path, ssid->id);
21148d520ff1dc2da35cdca849e982051b86468016d8Dmitry Shmidt
21158d520ff1dc2da35cdca849e982051b86468016d8Dmitry Shmidt	wpa_printf(MSG_DEBUG, "dbus: Register network object '%s'",
21168d520ff1dc2da35cdca849e982051b86468016d8Dmitry Shmidt		   net_obj_path);
21178d520ff1dc2da35cdca849e982051b86468016d8Dmitry Shmidt	obj_desc = os_zalloc(sizeof(struct wpa_dbus_object_desc));
21188d520ff1dc2da35cdca849e982051b86468016d8Dmitry Shmidt	if (!obj_desc) {
21198d520ff1dc2da35cdca849e982051b86468016d8Dmitry Shmidt		wpa_printf(MSG_ERROR, "Not enough memory "
21208d520ff1dc2da35cdca849e982051b86468016d8Dmitry Shmidt			   "to create object description");
21218d520ff1dc2da35cdca849e982051b86468016d8Dmitry Shmidt		goto err;
21228d520ff1dc2da35cdca849e982051b86468016d8Dmitry Shmidt	}
21238d520ff1dc2da35cdca849e982051b86468016d8Dmitry Shmidt
21248d520ff1dc2da35cdca849e982051b86468016d8Dmitry Shmidt	/* allocate memory for handlers arguments */
21258d520ff1dc2da35cdca849e982051b86468016d8Dmitry Shmidt	arg = os_zalloc(sizeof(struct network_handler_args));
21268d520ff1dc2da35cdca849e982051b86468016d8Dmitry Shmidt	if (!arg) {
21278d520ff1dc2da35cdca849e982051b86468016d8Dmitry Shmidt		wpa_printf(MSG_ERROR, "Not enough memory "
21288d520ff1dc2da35cdca849e982051b86468016d8Dmitry Shmidt			   "to create arguments for method");
21298d520ff1dc2da35cdca849e982051b86468016d8Dmitry Shmidt		goto err;
21308d520ff1dc2da35cdca849e982051b86468016d8Dmitry Shmidt	}
21318d520ff1dc2da35cdca849e982051b86468016d8Dmitry Shmidt
21328d520ff1dc2da35cdca849e982051b86468016d8Dmitry Shmidt	arg->wpa_s = wpa_s;
21338d520ff1dc2da35cdca849e982051b86468016d8Dmitry Shmidt	arg->ssid = ssid;
21348d520ff1dc2da35cdca849e982051b86468016d8Dmitry Shmidt
21358d520ff1dc2da35cdca849e982051b86468016d8Dmitry Shmidt	wpas_dbus_register(obj_desc, arg, wpa_dbus_free, NULL,
21368d520ff1dc2da35cdca849e982051b86468016d8Dmitry Shmidt			   wpas_dbus_network_properties,
21378d520ff1dc2da35cdca849e982051b86468016d8Dmitry Shmidt			   wpas_dbus_network_signals);
21388d520ff1dc2da35cdca849e982051b86468016d8Dmitry Shmidt
21398d520ff1dc2da35cdca849e982051b86468016d8Dmitry Shmidt	if (wpa_dbus_register_object_per_iface(ctrl_iface, net_obj_path,
21408d520ff1dc2da35cdca849e982051b86468016d8Dmitry Shmidt					       wpa_s->ifname, obj_desc))
21418d520ff1dc2da35cdca849e982051b86468016d8Dmitry Shmidt		goto err;
21428d520ff1dc2da35cdca849e982051b86468016d8Dmitry Shmidt
21438d520ff1dc2da35cdca849e982051b86468016d8Dmitry Shmidt	wpas_dbus_signal_network_added(wpa_s, ssid->id);
21448d520ff1dc2da35cdca849e982051b86468016d8Dmitry Shmidt
21458d520ff1dc2da35cdca849e982051b86468016d8Dmitry Shmidt	return 0;
21468d520ff1dc2da35cdca849e982051b86468016d8Dmitry Shmidt
21478d520ff1dc2da35cdca849e982051b86468016d8Dmitry Shmidterr:
21488d520ff1dc2da35cdca849e982051b86468016d8Dmitry Shmidt	free_dbus_object_desc(obj_desc);
21498d520ff1dc2da35cdca849e982051b86468016d8Dmitry Shmidt	return -1;
21508d520ff1dc2da35cdca849e982051b86468016d8Dmitry Shmidt}
21518d520ff1dc2da35cdca849e982051b86468016d8Dmitry Shmidt
21528d520ff1dc2da35cdca849e982051b86468016d8Dmitry Shmidt
21538d520ff1dc2da35cdca849e982051b86468016d8Dmitry Shmidt/**
21548d520ff1dc2da35cdca849e982051b86468016d8Dmitry Shmidt * wpas_dbus_unregister_network - Unregister a configured network from dbus
21558d520ff1dc2da35cdca849e982051b86468016d8Dmitry Shmidt * @wpa_s: wpa_supplicant interface structure
21568d520ff1dc2da35cdca849e982051b86468016d8Dmitry Shmidt * @nid: network id
21578d520ff1dc2da35cdca849e982051b86468016d8Dmitry Shmidt * Returns: 0 on success, -1 on failure
21588d520ff1dc2da35cdca849e982051b86468016d8Dmitry Shmidt *
21598d520ff1dc2da35cdca849e982051b86468016d8Dmitry Shmidt * Unregisters network representing object from dbus
21608d520ff1dc2da35cdca849e982051b86468016d8Dmitry Shmidt */
21618d520ff1dc2da35cdca849e982051b86468016d8Dmitry Shmidtint wpas_dbus_unregister_network(struct wpa_supplicant *wpa_s, int nid)
21628d520ff1dc2da35cdca849e982051b86468016d8Dmitry Shmidt{
21638d520ff1dc2da35cdca849e982051b86468016d8Dmitry Shmidt	struct wpas_dbus_priv *ctrl_iface;
21648d520ff1dc2da35cdca849e982051b86468016d8Dmitry Shmidt	char net_obj_path[WPAS_DBUS_OBJECT_PATH_MAX];
21658d520ff1dc2da35cdca849e982051b86468016d8Dmitry Shmidt	int ret;
216604949598a23f501be6eec21697465fd46a28840aDmitry Shmidt#ifdef CONFIG_P2P
216775ecf5267604f166b85a7ee2cf0d9cb682966680Jouni Malinen	struct wpa_ssid *ssid;
216875ecf5267604f166b85a7ee2cf0d9cb682966680Jouni Malinen
216975ecf5267604f166b85a7ee2cf0d9cb682966680Jouni Malinen	ssid = wpa_config_get_network(wpa_s->conf, nid);
217075ecf5267604f166b85a7ee2cf0d9cb682966680Jouni Malinen
217175ecf5267604f166b85a7ee2cf0d9cb682966680Jouni Malinen	/* If it is a persistent group unregister it as such */
217275ecf5267604f166b85a7ee2cf0d9cb682966680Jouni Malinen	if (ssid && network_is_persistent_group(ssid))
217375ecf5267604f166b85a7ee2cf0d9cb682966680Jouni Malinen		return wpas_dbus_unregister_persistent_group(wpa_s, nid);
2174c55524ad84d13014e8019491c2b17e5dcf13545aDmitry Shmidt#endif /* CONFIG_P2P */
21758d520ff1dc2da35cdca849e982051b86468016d8Dmitry Shmidt
21768d520ff1dc2da35cdca849e982051b86468016d8Dmitry Shmidt	/* Do nothing if the control interface is not turned on */
21771f69aa52ea2e0a73ac502565df8c666ee49cab6aDmitry Shmidt	if (wpa_s->global == NULL || wpa_s->dbus_new_path == NULL)
21788d520ff1dc2da35cdca849e982051b86468016d8Dmitry Shmidt		return 0;
21798d520ff1dc2da35cdca849e982051b86468016d8Dmitry Shmidt	ctrl_iface = wpa_s->global->dbus;
21808d520ff1dc2da35cdca849e982051b86468016d8Dmitry Shmidt	if (ctrl_iface == NULL)
21818d520ff1dc2da35cdca849e982051b86468016d8Dmitry Shmidt		return 0;
21828d520ff1dc2da35cdca849e982051b86468016d8Dmitry Shmidt
21838d520ff1dc2da35cdca849e982051b86468016d8Dmitry Shmidt	os_snprintf(net_obj_path, WPAS_DBUS_OBJECT_PATH_MAX,
21848d520ff1dc2da35cdca849e982051b86468016d8Dmitry Shmidt		    "%s/" WPAS_DBUS_NEW_NETWORKS_PART "/%u",
21858d520ff1dc2da35cdca849e982051b86468016d8Dmitry Shmidt		    wpa_s->dbus_new_path, nid);
21868d520ff1dc2da35cdca849e982051b86468016d8Dmitry Shmidt
21878d520ff1dc2da35cdca849e982051b86468016d8Dmitry Shmidt	wpa_printf(MSG_DEBUG, "dbus: Unregister network object '%s'",
21888d520ff1dc2da35cdca849e982051b86468016d8Dmitry Shmidt		   net_obj_path);
21898d520ff1dc2da35cdca849e982051b86468016d8Dmitry Shmidt	ret = wpa_dbus_unregister_object_per_iface(ctrl_iface, net_obj_path);
21908d520ff1dc2da35cdca849e982051b86468016d8Dmitry Shmidt
21918d520ff1dc2da35cdca849e982051b86468016d8Dmitry Shmidt	if (!ret)
21928d520ff1dc2da35cdca849e982051b86468016d8Dmitry Shmidt		wpas_dbus_signal_network_removed(wpa_s, nid);
21938d520ff1dc2da35cdca849e982051b86468016d8Dmitry Shmidt
21948d520ff1dc2da35cdca849e982051b86468016d8Dmitry Shmidt	return ret;
21958d520ff1dc2da35cdca849e982051b86468016d8Dmitry Shmidt}
21968d520ff1dc2da35cdca849e982051b86468016d8Dmitry Shmidt
21978d520ff1dc2da35cdca849e982051b86468016d8Dmitry Shmidt
21988d520ff1dc2da35cdca849e982051b86468016d8Dmitry Shmidtstatic const struct wpa_dbus_property_desc wpas_dbus_bss_properties[] = {
21998d520ff1dc2da35cdca849e982051b86468016d8Dmitry Shmidt	{ "SSID", WPAS_DBUS_NEW_IFACE_BSS, "ay",
22001f69aa52ea2e0a73ac502565df8c666ee49cab6aDmitry Shmidt	  wpas_dbus_getter_bss_ssid,
22011f69aa52ea2e0a73ac502565df8c666ee49cab6aDmitry Shmidt	  NULL
22028d520ff1dc2da35cdca849e982051b86468016d8Dmitry Shmidt	},
22038d520ff1dc2da35cdca849e982051b86468016d8Dmitry Shmidt	{ "BSSID", WPAS_DBUS_NEW_IFACE_BSS, "ay",
22041f69aa52ea2e0a73ac502565df8c666ee49cab6aDmitry Shmidt	  wpas_dbus_getter_bss_bssid,
22051f69aa52ea2e0a73ac502565df8c666ee49cab6aDmitry Shmidt	  NULL
22068d520ff1dc2da35cdca849e982051b86468016d8Dmitry Shmidt	},
22078d520ff1dc2da35cdca849e982051b86468016d8Dmitry Shmidt	{ "Privacy", WPAS_DBUS_NEW_IFACE_BSS, "b",
22081f69aa52ea2e0a73ac502565df8c666ee49cab6aDmitry Shmidt	  wpas_dbus_getter_bss_privacy,
22091f69aa52ea2e0a73ac502565df8c666ee49cab6aDmitry Shmidt	  NULL
22108d520ff1dc2da35cdca849e982051b86468016d8Dmitry Shmidt	},
22118d520ff1dc2da35cdca849e982051b86468016d8Dmitry Shmidt	{ "Mode", WPAS_DBUS_NEW_IFACE_BSS, "s",
22121f69aa52ea2e0a73ac502565df8c666ee49cab6aDmitry Shmidt	  wpas_dbus_getter_bss_mode,
22131f69aa52ea2e0a73ac502565df8c666ee49cab6aDmitry Shmidt	  NULL
22148d520ff1dc2da35cdca849e982051b86468016d8Dmitry Shmidt	},
22158d520ff1dc2da35cdca849e982051b86468016d8Dmitry Shmidt	{ "Signal", WPAS_DBUS_NEW_IFACE_BSS, "n",
22161f69aa52ea2e0a73ac502565df8c666ee49cab6aDmitry Shmidt	  wpas_dbus_getter_bss_signal,
22171f69aa52ea2e0a73ac502565df8c666ee49cab6aDmitry Shmidt	  NULL
22188d520ff1dc2da35cdca849e982051b86468016d8Dmitry Shmidt	},
22198d520ff1dc2da35cdca849e982051b86468016d8Dmitry Shmidt	{ "Frequency", WPAS_DBUS_NEW_IFACE_BSS, "q",
22201f69aa52ea2e0a73ac502565df8c666ee49cab6aDmitry Shmidt	  wpas_dbus_getter_bss_frequency,
22211f69aa52ea2e0a73ac502565df8c666ee49cab6aDmitry Shmidt	  NULL
22228d520ff1dc2da35cdca849e982051b86468016d8Dmitry Shmidt	},
22238d520ff1dc2da35cdca849e982051b86468016d8Dmitry Shmidt	{ "Rates", WPAS_DBUS_NEW_IFACE_BSS, "au",
22241f69aa52ea2e0a73ac502565df8c666ee49cab6aDmitry Shmidt	  wpas_dbus_getter_bss_rates,
22251f69aa52ea2e0a73ac502565df8c666ee49cab6aDmitry Shmidt	  NULL
22268d520ff1dc2da35cdca849e982051b86468016d8Dmitry Shmidt	},
22278d520ff1dc2da35cdca849e982051b86468016d8Dmitry Shmidt	{ "WPA", WPAS_DBUS_NEW_IFACE_BSS, "a{sv}",
22281f69aa52ea2e0a73ac502565df8c666ee49cab6aDmitry Shmidt	  wpas_dbus_getter_bss_wpa,
22291f69aa52ea2e0a73ac502565df8c666ee49cab6aDmitry Shmidt	  NULL
22308d520ff1dc2da35cdca849e982051b86468016d8Dmitry Shmidt	},
22318d520ff1dc2da35cdca849e982051b86468016d8Dmitry Shmidt	{ "RSN", WPAS_DBUS_NEW_IFACE_BSS, "a{sv}",
22321f69aa52ea2e0a73ac502565df8c666ee49cab6aDmitry Shmidt	  wpas_dbus_getter_bss_rsn,
22331f69aa52ea2e0a73ac502565df8c666ee49cab6aDmitry Shmidt	  NULL
22348d520ff1dc2da35cdca849e982051b86468016d8Dmitry Shmidt	},
22358d520ff1dc2da35cdca849e982051b86468016d8Dmitry Shmidt	{ "IEs", WPAS_DBUS_NEW_IFACE_BSS, "ay",
22361f69aa52ea2e0a73ac502565df8c666ee49cab6aDmitry Shmidt	  wpas_dbus_getter_bss_ies,
22371f69aa52ea2e0a73ac502565df8c666ee49cab6aDmitry Shmidt	  NULL
22388d520ff1dc2da35cdca849e982051b86468016d8Dmitry Shmidt	},
22391f69aa52ea2e0a73ac502565df8c666ee49cab6aDmitry Shmidt	{ NULL, NULL, NULL, NULL, NULL }
22408d520ff1dc2da35cdca849e982051b86468016d8Dmitry Shmidt};
22418d520ff1dc2da35cdca849e982051b86468016d8Dmitry Shmidt
22428d520ff1dc2da35cdca849e982051b86468016d8Dmitry Shmidt
22438d520ff1dc2da35cdca849e982051b86468016d8Dmitry Shmidtstatic const struct wpa_dbus_signal_desc wpas_dbus_bss_signals[] = {
22441f69aa52ea2e0a73ac502565df8c666ee49cab6aDmitry Shmidt	/* Deprecated: use org.freedesktop.DBus.Properties.PropertiesChanged */
22458d520ff1dc2da35cdca849e982051b86468016d8Dmitry Shmidt	{ "PropertiesChanged", WPAS_DBUS_NEW_IFACE_BSS,
22468d520ff1dc2da35cdca849e982051b86468016d8Dmitry Shmidt	  {
22478d520ff1dc2da35cdca849e982051b86468016d8Dmitry Shmidt		  { "properties", "a{sv}", ARG_OUT },
22488d520ff1dc2da35cdca849e982051b86468016d8Dmitry Shmidt		  END_ARGS
22498d520ff1dc2da35cdca849e982051b86468016d8Dmitry Shmidt	  }
22508d520ff1dc2da35cdca849e982051b86468016d8Dmitry Shmidt	},
22518d520ff1dc2da35cdca849e982051b86468016d8Dmitry Shmidt	{ NULL, NULL, { END_ARGS } }
22528d520ff1dc2da35cdca849e982051b86468016d8Dmitry Shmidt};
22538d520ff1dc2da35cdca849e982051b86468016d8Dmitry Shmidt
22548d520ff1dc2da35cdca849e982051b86468016d8Dmitry Shmidt
22558d520ff1dc2da35cdca849e982051b86468016d8Dmitry Shmidt/**
22568d520ff1dc2da35cdca849e982051b86468016d8Dmitry Shmidt * wpas_dbus_unregister_bss - Unregister a scanned BSS from dbus
22578d520ff1dc2da35cdca849e982051b86468016d8Dmitry Shmidt * @wpa_s: wpa_supplicant interface structure
22588d520ff1dc2da35cdca849e982051b86468016d8Dmitry Shmidt * @bssid: scanned network bssid
22598d520ff1dc2da35cdca849e982051b86468016d8Dmitry Shmidt * @id: unique BSS identifier
22608d520ff1dc2da35cdca849e982051b86468016d8Dmitry Shmidt * Returns: 0 on success, -1 on failure
22618d520ff1dc2da35cdca849e982051b86468016d8Dmitry Shmidt *
22628d520ff1dc2da35cdca849e982051b86468016d8Dmitry Shmidt * Unregisters BSS representing object from dbus
22638d520ff1dc2da35cdca849e982051b86468016d8Dmitry Shmidt */
22648d520ff1dc2da35cdca849e982051b86468016d8Dmitry Shmidtint wpas_dbus_unregister_bss(struct wpa_supplicant *wpa_s,
22658d520ff1dc2da35cdca849e982051b86468016d8Dmitry Shmidt			     u8 bssid[ETH_ALEN], unsigned int id)
22668d520ff1dc2da35cdca849e982051b86468016d8Dmitry Shmidt{
22678d520ff1dc2da35cdca849e982051b86468016d8Dmitry Shmidt	struct wpas_dbus_priv *ctrl_iface;
22688d520ff1dc2da35cdca849e982051b86468016d8Dmitry Shmidt	char bss_obj_path[WPAS_DBUS_OBJECT_PATH_MAX];
22698d520ff1dc2da35cdca849e982051b86468016d8Dmitry Shmidt
22708d520ff1dc2da35cdca849e982051b86468016d8Dmitry Shmidt	/* Do nothing if the control interface is not turned on */
22718d520ff1dc2da35cdca849e982051b86468016d8Dmitry Shmidt	if (wpa_s == NULL || wpa_s->global == NULL)
22728d520ff1dc2da35cdca849e982051b86468016d8Dmitry Shmidt		return 0;
22738d520ff1dc2da35cdca849e982051b86468016d8Dmitry Shmidt	ctrl_iface = wpa_s->global->dbus;
22748d520ff1dc2da35cdca849e982051b86468016d8Dmitry Shmidt	if (ctrl_iface == NULL)
22758d520ff1dc2da35cdca849e982051b86468016d8Dmitry Shmidt		return 0;
22768d520ff1dc2da35cdca849e982051b86468016d8Dmitry Shmidt
22778d520ff1dc2da35cdca849e982051b86468016d8Dmitry Shmidt	os_snprintf(bss_obj_path, WPAS_DBUS_OBJECT_PATH_MAX,
22788d520ff1dc2da35cdca849e982051b86468016d8Dmitry Shmidt		    "%s/" WPAS_DBUS_NEW_BSSIDS_PART "/%u",
22798d520ff1dc2da35cdca849e982051b86468016d8Dmitry Shmidt		    wpa_s->dbus_new_path, id);
22808d520ff1dc2da35cdca849e982051b86468016d8Dmitry Shmidt
22818d520ff1dc2da35cdca849e982051b86468016d8Dmitry Shmidt	wpa_printf(MSG_DEBUG, "dbus: Unregister BSS object '%s'",
22828d520ff1dc2da35cdca849e982051b86468016d8Dmitry Shmidt		   bss_obj_path);
22838d520ff1dc2da35cdca849e982051b86468016d8Dmitry Shmidt	if (wpa_dbus_unregister_object_per_iface(ctrl_iface, bss_obj_path)) {
22848d520ff1dc2da35cdca849e982051b86468016d8Dmitry Shmidt		wpa_printf(MSG_ERROR, "dbus: Cannot unregister BSS object %s",
22858d520ff1dc2da35cdca849e982051b86468016d8Dmitry Shmidt			   bss_obj_path);
22868d520ff1dc2da35cdca849e982051b86468016d8Dmitry Shmidt		return -1;
22878d520ff1dc2da35cdca849e982051b86468016d8Dmitry Shmidt	}
22888d520ff1dc2da35cdca849e982051b86468016d8Dmitry Shmidt
22898d520ff1dc2da35cdca849e982051b86468016d8Dmitry Shmidt	wpas_dbus_signal_bss_removed(wpa_s, bss_obj_path);
22908d520ff1dc2da35cdca849e982051b86468016d8Dmitry Shmidt	wpas_dbus_signal_prop_changed(wpa_s, WPAS_DBUS_PROP_BSSS);
22918d520ff1dc2da35cdca849e982051b86468016d8Dmitry Shmidt
22928d520ff1dc2da35cdca849e982051b86468016d8Dmitry Shmidt	return 0;
22938d520ff1dc2da35cdca849e982051b86468016d8Dmitry Shmidt}
22948d520ff1dc2da35cdca849e982051b86468016d8Dmitry Shmidt
22958d520ff1dc2da35cdca849e982051b86468016d8Dmitry Shmidt
22968d520ff1dc2da35cdca849e982051b86468016d8Dmitry Shmidt/**
22978d520ff1dc2da35cdca849e982051b86468016d8Dmitry Shmidt * wpas_dbus_register_bss - Register a scanned BSS with dbus
22988d520ff1dc2da35cdca849e982051b86468016d8Dmitry Shmidt * @wpa_s: wpa_supplicant interface structure
22998d520ff1dc2da35cdca849e982051b86468016d8Dmitry Shmidt * @bssid: scanned network bssid
23008d520ff1dc2da35cdca849e982051b86468016d8Dmitry Shmidt * @id: unique BSS identifier
23018d520ff1dc2da35cdca849e982051b86468016d8Dmitry Shmidt * Returns: 0 on success, -1 on failure
23028d520ff1dc2da35cdca849e982051b86468016d8Dmitry Shmidt *
23038d520ff1dc2da35cdca849e982051b86468016d8Dmitry Shmidt * Registers BSS representing object with dbus
23048d520ff1dc2da35cdca849e982051b86468016d8Dmitry Shmidt */
23058d520ff1dc2da35cdca849e982051b86468016d8Dmitry Shmidtint wpas_dbus_register_bss(struct wpa_supplicant *wpa_s,
23068d520ff1dc2da35cdca849e982051b86468016d8Dmitry Shmidt			   u8 bssid[ETH_ALEN], unsigned int id)
23078d520ff1dc2da35cdca849e982051b86468016d8Dmitry Shmidt{
23088d520ff1dc2da35cdca849e982051b86468016d8Dmitry Shmidt	struct wpas_dbus_priv *ctrl_iface;
23098d520ff1dc2da35cdca849e982051b86468016d8Dmitry Shmidt	struct wpa_dbus_object_desc *obj_desc;
23108d520ff1dc2da35cdca849e982051b86468016d8Dmitry Shmidt	char bss_obj_path[WPAS_DBUS_OBJECT_PATH_MAX];
23118d520ff1dc2da35cdca849e982051b86468016d8Dmitry Shmidt	struct bss_handler_args *arg;
23128d520ff1dc2da35cdca849e982051b86468016d8Dmitry Shmidt
23138d520ff1dc2da35cdca849e982051b86468016d8Dmitry Shmidt	/* Do nothing if the control interface is not turned on */
23148d520ff1dc2da35cdca849e982051b86468016d8Dmitry Shmidt	if (wpa_s == NULL || wpa_s->global == NULL)
23158d520ff1dc2da35cdca849e982051b86468016d8Dmitry Shmidt		return 0;
23168d520ff1dc2da35cdca849e982051b86468016d8Dmitry Shmidt	ctrl_iface = wpa_s->global->dbus;
23178d520ff1dc2da35cdca849e982051b86468016d8Dmitry Shmidt	if (ctrl_iface == NULL)
23188d520ff1dc2da35cdca849e982051b86468016d8Dmitry Shmidt		return 0;
23198d520ff1dc2da35cdca849e982051b86468016d8Dmitry Shmidt
23208d520ff1dc2da35cdca849e982051b86468016d8Dmitry Shmidt	os_snprintf(bss_obj_path, WPAS_DBUS_OBJECT_PATH_MAX,
23218d520ff1dc2da35cdca849e982051b86468016d8Dmitry Shmidt		    "%s/" WPAS_DBUS_NEW_BSSIDS_PART "/%u",
23228d520ff1dc2da35cdca849e982051b86468016d8Dmitry Shmidt		    wpa_s->dbus_new_path, id);
23238d520ff1dc2da35cdca849e982051b86468016d8Dmitry Shmidt
23248d520ff1dc2da35cdca849e982051b86468016d8Dmitry Shmidt	obj_desc = os_zalloc(sizeof(struct wpa_dbus_object_desc));
23258d520ff1dc2da35cdca849e982051b86468016d8Dmitry Shmidt	if (!obj_desc) {
23268d520ff1dc2da35cdca849e982051b86468016d8Dmitry Shmidt		wpa_printf(MSG_ERROR, "Not enough memory "
23278d520ff1dc2da35cdca849e982051b86468016d8Dmitry Shmidt			   "to create object description");
23288d520ff1dc2da35cdca849e982051b86468016d8Dmitry Shmidt		goto err;
23298d520ff1dc2da35cdca849e982051b86468016d8Dmitry Shmidt	}
23308d520ff1dc2da35cdca849e982051b86468016d8Dmitry Shmidt
23318d520ff1dc2da35cdca849e982051b86468016d8Dmitry Shmidt	arg = os_zalloc(sizeof(struct bss_handler_args));
23328d520ff1dc2da35cdca849e982051b86468016d8Dmitry Shmidt	if (!arg) {
23338d520ff1dc2da35cdca849e982051b86468016d8Dmitry Shmidt		wpa_printf(MSG_ERROR, "Not enough memory "
23348d520ff1dc2da35cdca849e982051b86468016d8Dmitry Shmidt			   "to create arguments for handler");
23358d520ff1dc2da35cdca849e982051b86468016d8Dmitry Shmidt		goto err;
23368d520ff1dc2da35cdca849e982051b86468016d8Dmitry Shmidt	}
23378d520ff1dc2da35cdca849e982051b86468016d8Dmitry Shmidt	arg->wpa_s = wpa_s;
23388d520ff1dc2da35cdca849e982051b86468016d8Dmitry Shmidt	arg->id = id;
23398d520ff1dc2da35cdca849e982051b86468016d8Dmitry Shmidt
23408d520ff1dc2da35cdca849e982051b86468016d8Dmitry Shmidt	wpas_dbus_register(obj_desc, arg, wpa_dbus_free, NULL,
23418d520ff1dc2da35cdca849e982051b86468016d8Dmitry Shmidt			   wpas_dbus_bss_properties,
23428d520ff1dc2da35cdca849e982051b86468016d8Dmitry Shmidt			   wpas_dbus_bss_signals);
23438d520ff1dc2da35cdca849e982051b86468016d8Dmitry Shmidt
23448d520ff1dc2da35cdca849e982051b86468016d8Dmitry Shmidt	wpa_printf(MSG_DEBUG, "dbus: Register BSS object '%s'",
23458d520ff1dc2da35cdca849e982051b86468016d8Dmitry Shmidt		   bss_obj_path);
23468d520ff1dc2da35cdca849e982051b86468016d8Dmitry Shmidt	if (wpa_dbus_register_object_per_iface(ctrl_iface, bss_obj_path,
23478d520ff1dc2da35cdca849e982051b86468016d8Dmitry Shmidt					       wpa_s->ifname, obj_desc)) {
23488d520ff1dc2da35cdca849e982051b86468016d8Dmitry Shmidt		wpa_printf(MSG_ERROR,
23498d520ff1dc2da35cdca849e982051b86468016d8Dmitry Shmidt			   "Cannot register BSSID dbus object %s.",
23508d520ff1dc2da35cdca849e982051b86468016d8Dmitry Shmidt			   bss_obj_path);
23518d520ff1dc2da35cdca849e982051b86468016d8Dmitry Shmidt		goto err;
23528d520ff1dc2da35cdca849e982051b86468016d8Dmitry Shmidt	}
23538d520ff1dc2da35cdca849e982051b86468016d8Dmitry Shmidt
23548d520ff1dc2da35cdca849e982051b86468016d8Dmitry Shmidt	wpas_dbus_signal_bss_added(wpa_s, bss_obj_path);
23558d520ff1dc2da35cdca849e982051b86468016d8Dmitry Shmidt	wpas_dbus_signal_prop_changed(wpa_s, WPAS_DBUS_PROP_BSSS);
23568d520ff1dc2da35cdca849e982051b86468016d8Dmitry Shmidt
23578d520ff1dc2da35cdca849e982051b86468016d8Dmitry Shmidt	return 0;
23588d520ff1dc2da35cdca849e982051b86468016d8Dmitry Shmidt
23598d520ff1dc2da35cdca849e982051b86468016d8Dmitry Shmidterr:
23608d520ff1dc2da35cdca849e982051b86468016d8Dmitry Shmidt	free_dbus_object_desc(obj_desc);
23618d520ff1dc2da35cdca849e982051b86468016d8Dmitry Shmidt	return -1;
23628d520ff1dc2da35cdca849e982051b86468016d8Dmitry Shmidt}
23638d520ff1dc2da35cdca849e982051b86468016d8Dmitry Shmidt
23648d520ff1dc2da35cdca849e982051b86468016d8Dmitry Shmidt
23658d520ff1dc2da35cdca849e982051b86468016d8Dmitry Shmidtstatic const struct wpa_dbus_method_desc wpas_dbus_interface_methods[] = {
23668d520ff1dc2da35cdca849e982051b86468016d8Dmitry Shmidt	{ "Scan", WPAS_DBUS_NEW_IFACE_INTERFACE,
23678d520ff1dc2da35cdca849e982051b86468016d8Dmitry Shmidt	  (WPADBusMethodHandler) &wpas_dbus_handler_scan,
23688d520ff1dc2da35cdca849e982051b86468016d8Dmitry Shmidt	  {
23698d520ff1dc2da35cdca849e982051b86468016d8Dmitry Shmidt		  { "args", "a{sv}", ARG_IN },
23708d520ff1dc2da35cdca849e982051b86468016d8Dmitry Shmidt		  END_ARGS
23718d520ff1dc2da35cdca849e982051b86468016d8Dmitry Shmidt	  }
23728d520ff1dc2da35cdca849e982051b86468016d8Dmitry Shmidt	},
23738d520ff1dc2da35cdca849e982051b86468016d8Dmitry Shmidt	{ "Disconnect", WPAS_DBUS_NEW_IFACE_INTERFACE,
23748d520ff1dc2da35cdca849e982051b86468016d8Dmitry Shmidt	  (WPADBusMethodHandler) &wpas_dbus_handler_disconnect,
23758d520ff1dc2da35cdca849e982051b86468016d8Dmitry Shmidt	  {
23768d520ff1dc2da35cdca849e982051b86468016d8Dmitry Shmidt		  END_ARGS
23778d520ff1dc2da35cdca849e982051b86468016d8Dmitry Shmidt	  }
23788d520ff1dc2da35cdca849e982051b86468016d8Dmitry Shmidt	},
23798d520ff1dc2da35cdca849e982051b86468016d8Dmitry Shmidt	{ "AddNetwork", WPAS_DBUS_NEW_IFACE_INTERFACE,
23808d520ff1dc2da35cdca849e982051b86468016d8Dmitry Shmidt	  (WPADBusMethodHandler) &wpas_dbus_handler_add_network,
23818d520ff1dc2da35cdca849e982051b86468016d8Dmitry Shmidt	  {
23828d520ff1dc2da35cdca849e982051b86468016d8Dmitry Shmidt		  { "args", "a{sv}", ARG_IN },
23838d520ff1dc2da35cdca849e982051b86468016d8Dmitry Shmidt		  { "path", "o", ARG_OUT },
23848d520ff1dc2da35cdca849e982051b86468016d8Dmitry Shmidt		  END_ARGS
23858d520ff1dc2da35cdca849e982051b86468016d8Dmitry Shmidt	  }
23868d520ff1dc2da35cdca849e982051b86468016d8Dmitry Shmidt	},
238761d9df3e62aaa0e87ad05452fcb95142159a17b6Dmitry Shmidt	{ "Reassociate", WPAS_DBUS_NEW_IFACE_INTERFACE,
238861d9df3e62aaa0e87ad05452fcb95142159a17b6Dmitry Shmidt	  (WPADBusMethodHandler) &wpas_dbus_handler_reassociate,
238961d9df3e62aaa0e87ad05452fcb95142159a17b6Dmitry Shmidt	  {
239061d9df3e62aaa0e87ad05452fcb95142159a17b6Dmitry Shmidt		  END_ARGS
239161d9df3e62aaa0e87ad05452fcb95142159a17b6Dmitry Shmidt	  }
239261d9df3e62aaa0e87ad05452fcb95142159a17b6Dmitry Shmidt	},
23938d520ff1dc2da35cdca849e982051b86468016d8Dmitry Shmidt	{ "RemoveNetwork", WPAS_DBUS_NEW_IFACE_INTERFACE,
23948d520ff1dc2da35cdca849e982051b86468016d8Dmitry Shmidt	  (WPADBusMethodHandler) &wpas_dbus_handler_remove_network,
23958d520ff1dc2da35cdca849e982051b86468016d8Dmitry Shmidt	  {
23968d520ff1dc2da35cdca849e982051b86468016d8Dmitry Shmidt		  { "path", "o", ARG_IN },
23978d520ff1dc2da35cdca849e982051b86468016d8Dmitry Shmidt		  END_ARGS
23988d520ff1dc2da35cdca849e982051b86468016d8Dmitry Shmidt	  }
23998d520ff1dc2da35cdca849e982051b86468016d8Dmitry Shmidt	},
24008d520ff1dc2da35cdca849e982051b86468016d8Dmitry Shmidt	{ "RemoveAllNetworks", WPAS_DBUS_NEW_IFACE_INTERFACE,
24018d520ff1dc2da35cdca849e982051b86468016d8Dmitry Shmidt	  (WPADBusMethodHandler) &wpas_dbus_handler_remove_all_networks,
24028d520ff1dc2da35cdca849e982051b86468016d8Dmitry Shmidt	  {
24038d520ff1dc2da35cdca849e982051b86468016d8Dmitry Shmidt		  END_ARGS
24048d520ff1dc2da35cdca849e982051b86468016d8Dmitry Shmidt	  }
24058d520ff1dc2da35cdca849e982051b86468016d8Dmitry Shmidt	},
24068d520ff1dc2da35cdca849e982051b86468016d8Dmitry Shmidt	{ "SelectNetwork", WPAS_DBUS_NEW_IFACE_INTERFACE,
24078d520ff1dc2da35cdca849e982051b86468016d8Dmitry Shmidt	  (WPADBusMethodHandler) &wpas_dbus_handler_select_network,
24088d520ff1dc2da35cdca849e982051b86468016d8Dmitry Shmidt	  {
24098d520ff1dc2da35cdca849e982051b86468016d8Dmitry Shmidt		  { "path", "o", ARG_IN },
24108d520ff1dc2da35cdca849e982051b86468016d8Dmitry Shmidt		  END_ARGS
24118d520ff1dc2da35cdca849e982051b86468016d8Dmitry Shmidt	  }
24128d520ff1dc2da35cdca849e982051b86468016d8Dmitry Shmidt	},
24131f69aa52ea2e0a73ac502565df8c666ee49cab6aDmitry Shmidt	{ "NetworkReply", WPAS_DBUS_NEW_IFACE_INTERFACE,
24141f69aa52ea2e0a73ac502565df8c666ee49cab6aDmitry Shmidt	  (WPADBusMethodHandler) &wpas_dbus_handler_network_reply,
24151f69aa52ea2e0a73ac502565df8c666ee49cab6aDmitry Shmidt	  {
24161f69aa52ea2e0a73ac502565df8c666ee49cab6aDmitry Shmidt		  { "path", "o", ARG_IN },
24171f69aa52ea2e0a73ac502565df8c666ee49cab6aDmitry Shmidt		  { "field", "s", ARG_IN },
24181f69aa52ea2e0a73ac502565df8c666ee49cab6aDmitry Shmidt		  { "value", "s", ARG_IN },
24191f69aa52ea2e0a73ac502565df8c666ee49cab6aDmitry Shmidt		  END_ARGS
24201f69aa52ea2e0a73ac502565df8c666ee49cab6aDmitry Shmidt	  }
24211f69aa52ea2e0a73ac502565df8c666ee49cab6aDmitry Shmidt	},
24228d520ff1dc2da35cdca849e982051b86468016d8Dmitry Shmidt	{ "AddBlob", WPAS_DBUS_NEW_IFACE_INTERFACE,
24238d520ff1dc2da35cdca849e982051b86468016d8Dmitry Shmidt	  (WPADBusMethodHandler) &wpas_dbus_handler_add_blob,
24248d520ff1dc2da35cdca849e982051b86468016d8Dmitry Shmidt	  {
24258d520ff1dc2da35cdca849e982051b86468016d8Dmitry Shmidt		  { "name", "s", ARG_IN },
24268d520ff1dc2da35cdca849e982051b86468016d8Dmitry Shmidt		  { "data", "ay", ARG_IN },
24278d520ff1dc2da35cdca849e982051b86468016d8Dmitry Shmidt		  END_ARGS
24288d520ff1dc2da35cdca849e982051b86468016d8Dmitry Shmidt	  }
24298d520ff1dc2da35cdca849e982051b86468016d8Dmitry Shmidt	},
24308d520ff1dc2da35cdca849e982051b86468016d8Dmitry Shmidt	{ "GetBlob", WPAS_DBUS_NEW_IFACE_INTERFACE,
24318d520ff1dc2da35cdca849e982051b86468016d8Dmitry Shmidt	  (WPADBusMethodHandler) &wpas_dbus_handler_get_blob,
24328d520ff1dc2da35cdca849e982051b86468016d8Dmitry Shmidt	  {
24338d520ff1dc2da35cdca849e982051b86468016d8Dmitry Shmidt		  { "name", "s", ARG_IN },
24348d520ff1dc2da35cdca849e982051b86468016d8Dmitry Shmidt		  { "data", "ay", ARG_OUT },
24358d520ff1dc2da35cdca849e982051b86468016d8Dmitry Shmidt		  END_ARGS
24368d520ff1dc2da35cdca849e982051b86468016d8Dmitry Shmidt	  }
24378d520ff1dc2da35cdca849e982051b86468016d8Dmitry Shmidt	},
24388d520ff1dc2da35cdca849e982051b86468016d8Dmitry Shmidt	{ "RemoveBlob", WPAS_DBUS_NEW_IFACE_INTERFACE,
24398d520ff1dc2da35cdca849e982051b86468016d8Dmitry Shmidt	  (WPADBusMethodHandler) &wpas_dbus_handler_remove_blob,
24408d520ff1dc2da35cdca849e982051b86468016d8Dmitry Shmidt	  {
24418d520ff1dc2da35cdca849e982051b86468016d8Dmitry Shmidt		  { "name", "s", ARG_IN },
24428d520ff1dc2da35cdca849e982051b86468016d8Dmitry Shmidt		  END_ARGS
24438d520ff1dc2da35cdca849e982051b86468016d8Dmitry Shmidt	  }
24448d520ff1dc2da35cdca849e982051b86468016d8Dmitry Shmidt	},
24458d520ff1dc2da35cdca849e982051b86468016d8Dmitry Shmidt#ifdef CONFIG_WPS
24468d520ff1dc2da35cdca849e982051b86468016d8Dmitry Shmidt	{ "Start", WPAS_DBUS_NEW_IFACE_WPS,
24478d520ff1dc2da35cdca849e982051b86468016d8Dmitry Shmidt	  (WPADBusMethodHandler) &wpas_dbus_handler_wps_start,
24488d520ff1dc2da35cdca849e982051b86468016d8Dmitry Shmidt	  {
24498d520ff1dc2da35cdca849e982051b86468016d8Dmitry Shmidt		  { "args", "a{sv}", ARG_IN },
24508d520ff1dc2da35cdca849e982051b86468016d8Dmitry Shmidt		  { "output", "a{sv}", ARG_OUT },
24518d520ff1dc2da35cdca849e982051b86468016d8Dmitry Shmidt		  END_ARGS
24528d520ff1dc2da35cdca849e982051b86468016d8Dmitry Shmidt	  }
24538d520ff1dc2da35cdca849e982051b86468016d8Dmitry Shmidt	},
24548d520ff1dc2da35cdca849e982051b86468016d8Dmitry Shmidt#endif /* CONFIG_WPS */
245575ecf5267604f166b85a7ee2cf0d9cb682966680Jouni Malinen#ifdef CONFIG_P2P
245675ecf5267604f166b85a7ee2cf0d9cb682966680Jouni Malinen	{ "Find", WPAS_DBUS_NEW_IFACE_P2PDEVICE,
245775ecf5267604f166b85a7ee2cf0d9cb682966680Jouni Malinen	  (WPADBusMethodHandler)wpas_dbus_handler_p2p_find,
245875ecf5267604f166b85a7ee2cf0d9cb682966680Jouni Malinen	  {
245975ecf5267604f166b85a7ee2cf0d9cb682966680Jouni Malinen		  { "args", "a{sv}", ARG_IN },
246075ecf5267604f166b85a7ee2cf0d9cb682966680Jouni Malinen		  END_ARGS
246175ecf5267604f166b85a7ee2cf0d9cb682966680Jouni Malinen	  }
246275ecf5267604f166b85a7ee2cf0d9cb682966680Jouni Malinen	},
246375ecf5267604f166b85a7ee2cf0d9cb682966680Jouni Malinen	{ "StopFind", WPAS_DBUS_NEW_IFACE_P2PDEVICE,
246475ecf5267604f166b85a7ee2cf0d9cb682966680Jouni Malinen	  (WPADBusMethodHandler)wpas_dbus_handler_p2p_stop_find,
246575ecf5267604f166b85a7ee2cf0d9cb682966680Jouni Malinen	  {
246675ecf5267604f166b85a7ee2cf0d9cb682966680Jouni Malinen		  END_ARGS
246775ecf5267604f166b85a7ee2cf0d9cb682966680Jouni Malinen	  }
246875ecf5267604f166b85a7ee2cf0d9cb682966680Jouni Malinen	},
246975ecf5267604f166b85a7ee2cf0d9cb682966680Jouni Malinen	{ "Listen", WPAS_DBUS_NEW_IFACE_P2PDEVICE,
247075ecf5267604f166b85a7ee2cf0d9cb682966680Jouni Malinen	  (WPADBusMethodHandler)wpas_dbus_handler_p2p_listen,
247175ecf5267604f166b85a7ee2cf0d9cb682966680Jouni Malinen	  {
247275ecf5267604f166b85a7ee2cf0d9cb682966680Jouni Malinen		  { "timeout", "i", ARG_IN },
247375ecf5267604f166b85a7ee2cf0d9cb682966680Jouni Malinen		  END_ARGS
247475ecf5267604f166b85a7ee2cf0d9cb682966680Jouni Malinen	  }
247575ecf5267604f166b85a7ee2cf0d9cb682966680Jouni Malinen	},
247675ecf5267604f166b85a7ee2cf0d9cb682966680Jouni Malinen	{ "ExtendedListen", WPAS_DBUS_NEW_IFACE_P2PDEVICE,
247775ecf5267604f166b85a7ee2cf0d9cb682966680Jouni Malinen	  (WPADBusMethodHandler)wpas_dbus_handler_p2p_extendedlisten,
247875ecf5267604f166b85a7ee2cf0d9cb682966680Jouni Malinen	  {
247975ecf5267604f166b85a7ee2cf0d9cb682966680Jouni Malinen		  { "args", "a{sv}", ARG_IN },
248075ecf5267604f166b85a7ee2cf0d9cb682966680Jouni Malinen		  END_ARGS
248175ecf5267604f166b85a7ee2cf0d9cb682966680Jouni Malinen	  }
248275ecf5267604f166b85a7ee2cf0d9cb682966680Jouni Malinen	},
248375ecf5267604f166b85a7ee2cf0d9cb682966680Jouni Malinen	{ "PresenceRequest", WPAS_DBUS_NEW_IFACE_P2PDEVICE,
248475ecf5267604f166b85a7ee2cf0d9cb682966680Jouni Malinen	  (WPADBusMethodHandler)wpas_dbus_handler_p2p_presence_request,
248575ecf5267604f166b85a7ee2cf0d9cb682966680Jouni Malinen	  {
248675ecf5267604f166b85a7ee2cf0d9cb682966680Jouni Malinen		  { "args", "a{sv}", ARG_IN },
248775ecf5267604f166b85a7ee2cf0d9cb682966680Jouni Malinen		  END_ARGS
248875ecf5267604f166b85a7ee2cf0d9cb682966680Jouni Malinen	  }
248975ecf5267604f166b85a7ee2cf0d9cb682966680Jouni Malinen	},
249075ecf5267604f166b85a7ee2cf0d9cb682966680Jouni Malinen	{ "ProvisionDiscoveryRequest", WPAS_DBUS_NEW_IFACE_P2PDEVICE,
249175ecf5267604f166b85a7ee2cf0d9cb682966680Jouni Malinen	  (WPADBusMethodHandler)wpas_dbus_handler_p2p_prov_disc_req,
249275ecf5267604f166b85a7ee2cf0d9cb682966680Jouni Malinen	  {
249375ecf5267604f166b85a7ee2cf0d9cb682966680Jouni Malinen		  { "peer", "o", ARG_IN },
249475ecf5267604f166b85a7ee2cf0d9cb682966680Jouni Malinen		  { "config_method", "s", ARG_IN },
249575ecf5267604f166b85a7ee2cf0d9cb682966680Jouni Malinen		  END_ARGS
249675ecf5267604f166b85a7ee2cf0d9cb682966680Jouni Malinen	  }
249775ecf5267604f166b85a7ee2cf0d9cb682966680Jouni Malinen	},
249875ecf5267604f166b85a7ee2cf0d9cb682966680Jouni Malinen	{ "Connect", WPAS_DBUS_NEW_IFACE_P2PDEVICE,
249975ecf5267604f166b85a7ee2cf0d9cb682966680Jouni Malinen	  (WPADBusMethodHandler)wpas_dbus_handler_p2p_connect,
250075ecf5267604f166b85a7ee2cf0d9cb682966680Jouni Malinen	  {
250175ecf5267604f166b85a7ee2cf0d9cb682966680Jouni Malinen		  { "args", "a{sv}", ARG_IN },
25021f69aa52ea2e0a73ac502565df8c666ee49cab6aDmitry Shmidt		  { "generated_pin", "s", ARG_OUT },
250375ecf5267604f166b85a7ee2cf0d9cb682966680Jouni Malinen		  END_ARGS
250475ecf5267604f166b85a7ee2cf0d9cb682966680Jouni Malinen	  }
250575ecf5267604f166b85a7ee2cf0d9cb682966680Jouni Malinen	},
250675ecf5267604f166b85a7ee2cf0d9cb682966680Jouni Malinen	{ "GroupAdd", WPAS_DBUS_NEW_IFACE_P2PDEVICE,
250775ecf5267604f166b85a7ee2cf0d9cb682966680Jouni Malinen	  (WPADBusMethodHandler)wpas_dbus_handler_p2p_group_add,
250875ecf5267604f166b85a7ee2cf0d9cb682966680Jouni Malinen	  {
250975ecf5267604f166b85a7ee2cf0d9cb682966680Jouni Malinen		  { "args", "a{sv}", ARG_IN },
251075ecf5267604f166b85a7ee2cf0d9cb682966680Jouni Malinen		  END_ARGS
251175ecf5267604f166b85a7ee2cf0d9cb682966680Jouni Malinen	  }
251275ecf5267604f166b85a7ee2cf0d9cb682966680Jouni Malinen	},
251375ecf5267604f166b85a7ee2cf0d9cb682966680Jouni Malinen	{ "Invite", WPAS_DBUS_NEW_IFACE_P2PDEVICE,
251475ecf5267604f166b85a7ee2cf0d9cb682966680Jouni Malinen	  (WPADBusMethodHandler)wpas_dbus_handler_p2p_invite,
251575ecf5267604f166b85a7ee2cf0d9cb682966680Jouni Malinen	  {
251675ecf5267604f166b85a7ee2cf0d9cb682966680Jouni Malinen		  { "args", "a{sv}", ARG_IN },
251775ecf5267604f166b85a7ee2cf0d9cb682966680Jouni Malinen		  END_ARGS
251875ecf5267604f166b85a7ee2cf0d9cb682966680Jouni Malinen	  }
251975ecf5267604f166b85a7ee2cf0d9cb682966680Jouni Malinen	},
252075ecf5267604f166b85a7ee2cf0d9cb682966680Jouni Malinen	{ "Disconnect", WPAS_DBUS_NEW_IFACE_P2PDEVICE,
252175ecf5267604f166b85a7ee2cf0d9cb682966680Jouni Malinen	  (WPADBusMethodHandler)wpas_dbus_handler_p2p_disconnect,
252275ecf5267604f166b85a7ee2cf0d9cb682966680Jouni Malinen	  {
252375ecf5267604f166b85a7ee2cf0d9cb682966680Jouni Malinen		  END_ARGS
252475ecf5267604f166b85a7ee2cf0d9cb682966680Jouni Malinen	  }
252575ecf5267604f166b85a7ee2cf0d9cb682966680Jouni Malinen	},
252675ecf5267604f166b85a7ee2cf0d9cb682966680Jouni Malinen	{ "RejectPeer", WPAS_DBUS_NEW_IFACE_P2PDEVICE,
252775ecf5267604f166b85a7ee2cf0d9cb682966680Jouni Malinen	  (WPADBusMethodHandler)wpas_dbus_handler_p2p_rejectpeer,
252875ecf5267604f166b85a7ee2cf0d9cb682966680Jouni Malinen	  {
252975ecf5267604f166b85a7ee2cf0d9cb682966680Jouni Malinen		  { "peer", "o", ARG_IN },
253075ecf5267604f166b85a7ee2cf0d9cb682966680Jouni Malinen		  END_ARGS
253175ecf5267604f166b85a7ee2cf0d9cb682966680Jouni Malinen	  }
253275ecf5267604f166b85a7ee2cf0d9cb682966680Jouni Malinen	},
253375ecf5267604f166b85a7ee2cf0d9cb682966680Jouni Malinen	{ "Flush", WPAS_DBUS_NEW_IFACE_P2PDEVICE,
253475ecf5267604f166b85a7ee2cf0d9cb682966680Jouni Malinen	  (WPADBusMethodHandler)wpas_dbus_handler_p2p_flush,
253575ecf5267604f166b85a7ee2cf0d9cb682966680Jouni Malinen	  {
253675ecf5267604f166b85a7ee2cf0d9cb682966680Jouni Malinen		  END_ARGS
253775ecf5267604f166b85a7ee2cf0d9cb682966680Jouni Malinen	  }
253875ecf5267604f166b85a7ee2cf0d9cb682966680Jouni Malinen	},
253975ecf5267604f166b85a7ee2cf0d9cb682966680Jouni Malinen	{ "AddService", WPAS_DBUS_NEW_IFACE_P2PDEVICE,
254075ecf5267604f166b85a7ee2cf0d9cb682966680Jouni Malinen	  (WPADBusMethodHandler)wpas_dbus_handler_p2p_add_service,
254175ecf5267604f166b85a7ee2cf0d9cb682966680Jouni Malinen	  {
254275ecf5267604f166b85a7ee2cf0d9cb682966680Jouni Malinen		  { "args", "a{sv}", ARG_IN },
254375ecf5267604f166b85a7ee2cf0d9cb682966680Jouni Malinen		  END_ARGS
254475ecf5267604f166b85a7ee2cf0d9cb682966680Jouni Malinen	  }
254575ecf5267604f166b85a7ee2cf0d9cb682966680Jouni Malinen	},
254675ecf5267604f166b85a7ee2cf0d9cb682966680Jouni Malinen	{ "DeleteService", WPAS_DBUS_NEW_IFACE_P2PDEVICE,
254775ecf5267604f166b85a7ee2cf0d9cb682966680Jouni Malinen	  (WPADBusMethodHandler)wpas_dbus_handler_p2p_delete_service,
254875ecf5267604f166b85a7ee2cf0d9cb682966680Jouni Malinen	  {
254975ecf5267604f166b85a7ee2cf0d9cb682966680Jouni Malinen		  { "args", "a{sv}", ARG_IN },
255075ecf5267604f166b85a7ee2cf0d9cb682966680Jouni Malinen		  END_ARGS
255175ecf5267604f166b85a7ee2cf0d9cb682966680Jouni Malinen	  }
255275ecf5267604f166b85a7ee2cf0d9cb682966680Jouni Malinen	},
255375ecf5267604f166b85a7ee2cf0d9cb682966680Jouni Malinen	{ "FlushService", WPAS_DBUS_NEW_IFACE_P2PDEVICE,
255475ecf5267604f166b85a7ee2cf0d9cb682966680Jouni Malinen	  (WPADBusMethodHandler)wpas_dbus_handler_p2p_flush_service,
255575ecf5267604f166b85a7ee2cf0d9cb682966680Jouni Malinen	  {
255675ecf5267604f166b85a7ee2cf0d9cb682966680Jouni Malinen		  END_ARGS
255775ecf5267604f166b85a7ee2cf0d9cb682966680Jouni Malinen	  }
255875ecf5267604f166b85a7ee2cf0d9cb682966680Jouni Malinen	},
255975ecf5267604f166b85a7ee2cf0d9cb682966680Jouni Malinen	{ "ServiceDiscoveryRequest", WPAS_DBUS_NEW_IFACE_P2PDEVICE,
256075ecf5267604f166b85a7ee2cf0d9cb682966680Jouni Malinen	  (WPADBusMethodHandler)wpas_dbus_handler_p2p_service_sd_req,
256175ecf5267604f166b85a7ee2cf0d9cb682966680Jouni Malinen	  {
256275ecf5267604f166b85a7ee2cf0d9cb682966680Jouni Malinen		  { "args", "a{sv}", ARG_IN },
256375ecf5267604f166b85a7ee2cf0d9cb682966680Jouni Malinen		  END_ARGS
256475ecf5267604f166b85a7ee2cf0d9cb682966680Jouni Malinen	  }
256575ecf5267604f166b85a7ee2cf0d9cb682966680Jouni Malinen	},
256675ecf5267604f166b85a7ee2cf0d9cb682966680Jouni Malinen	{ "ServiceDiscoveryResponse", WPAS_DBUS_NEW_IFACE_P2PDEVICE,
256775ecf5267604f166b85a7ee2cf0d9cb682966680Jouni Malinen	  (WPADBusMethodHandler)wpas_dbus_handler_p2p_service_sd_res,
256875ecf5267604f166b85a7ee2cf0d9cb682966680Jouni Malinen	  {
256975ecf5267604f166b85a7ee2cf0d9cb682966680Jouni Malinen		  { "args", "a{sv}", ARG_IN },
257075ecf5267604f166b85a7ee2cf0d9cb682966680Jouni Malinen		  END_ARGS
257175ecf5267604f166b85a7ee2cf0d9cb682966680Jouni Malinen	  }
257275ecf5267604f166b85a7ee2cf0d9cb682966680Jouni Malinen	},
257375ecf5267604f166b85a7ee2cf0d9cb682966680Jouni Malinen	{ "ServiceDiscoveryCancelRequest", WPAS_DBUS_NEW_IFACE_P2PDEVICE,
257475ecf5267604f166b85a7ee2cf0d9cb682966680Jouni Malinen	  (WPADBusMethodHandler)wpas_dbus_handler_p2p_service_sd_cancel_req,
257575ecf5267604f166b85a7ee2cf0d9cb682966680Jouni Malinen	  {
257675ecf5267604f166b85a7ee2cf0d9cb682966680Jouni Malinen		  { "args", "t", ARG_IN },
257775ecf5267604f166b85a7ee2cf0d9cb682966680Jouni Malinen		  END_ARGS
257875ecf5267604f166b85a7ee2cf0d9cb682966680Jouni Malinen	  }
257975ecf5267604f166b85a7ee2cf0d9cb682966680Jouni Malinen	},
258075ecf5267604f166b85a7ee2cf0d9cb682966680Jouni Malinen	{ "ServiceUpdate", WPAS_DBUS_NEW_IFACE_P2PDEVICE,
258175ecf5267604f166b85a7ee2cf0d9cb682966680Jouni Malinen	  (WPADBusMethodHandler)wpas_dbus_handler_p2p_service_update,
258275ecf5267604f166b85a7ee2cf0d9cb682966680Jouni Malinen	  {
258375ecf5267604f166b85a7ee2cf0d9cb682966680Jouni Malinen		  END_ARGS
258475ecf5267604f166b85a7ee2cf0d9cb682966680Jouni Malinen	  }
258575ecf5267604f166b85a7ee2cf0d9cb682966680Jouni Malinen	},
258675ecf5267604f166b85a7ee2cf0d9cb682966680Jouni Malinen	{ "ServiceDiscoveryExternal", WPAS_DBUS_NEW_IFACE_P2PDEVICE,
258775ecf5267604f166b85a7ee2cf0d9cb682966680Jouni Malinen	  (WPADBusMethodHandler)wpas_dbus_handler_p2p_serv_disc_external,
258875ecf5267604f166b85a7ee2cf0d9cb682966680Jouni Malinen	  {
258975ecf5267604f166b85a7ee2cf0d9cb682966680Jouni Malinen		  { "arg", "i", ARG_IN },
259075ecf5267604f166b85a7ee2cf0d9cb682966680Jouni Malinen		  END_ARGS
259175ecf5267604f166b85a7ee2cf0d9cb682966680Jouni Malinen	  }
259275ecf5267604f166b85a7ee2cf0d9cb682966680Jouni Malinen	},
259375ecf5267604f166b85a7ee2cf0d9cb682966680Jouni Malinen	{ "ServiceDiscoveryExternal", WPAS_DBUS_NEW_IFACE_P2PDEVICE,
259475ecf5267604f166b85a7ee2cf0d9cb682966680Jouni Malinen	  (WPADBusMethodHandler)wpas_dbus_handler_p2p_serv_disc_external,
259575ecf5267604f166b85a7ee2cf0d9cb682966680Jouni Malinen	  {
259675ecf5267604f166b85a7ee2cf0d9cb682966680Jouni Malinen		  { "arg", "i", ARG_IN },
259775ecf5267604f166b85a7ee2cf0d9cb682966680Jouni Malinen		  END_ARGS
259875ecf5267604f166b85a7ee2cf0d9cb682966680Jouni Malinen	  }
259975ecf5267604f166b85a7ee2cf0d9cb682966680Jouni Malinen	},
260075ecf5267604f166b85a7ee2cf0d9cb682966680Jouni Malinen	{ "AddPersistentGroup", WPAS_DBUS_NEW_IFACE_P2PDEVICE,
260175ecf5267604f166b85a7ee2cf0d9cb682966680Jouni Malinen	  (WPADBusMethodHandler) wpas_dbus_handler_add_persistent_group,
260275ecf5267604f166b85a7ee2cf0d9cb682966680Jouni Malinen	  {
260375ecf5267604f166b85a7ee2cf0d9cb682966680Jouni Malinen		  { "args", "a{sv}", ARG_IN },
260475ecf5267604f166b85a7ee2cf0d9cb682966680Jouni Malinen		  { "path", "o", ARG_OUT },
260575ecf5267604f166b85a7ee2cf0d9cb682966680Jouni Malinen		  END_ARGS
260675ecf5267604f166b85a7ee2cf0d9cb682966680Jouni Malinen	  }
260775ecf5267604f166b85a7ee2cf0d9cb682966680Jouni Malinen	},
260875ecf5267604f166b85a7ee2cf0d9cb682966680Jouni Malinen	{ "RemovePersistentGroup", WPAS_DBUS_NEW_IFACE_P2PDEVICE,
260975ecf5267604f166b85a7ee2cf0d9cb682966680Jouni Malinen	  (WPADBusMethodHandler) wpas_dbus_handler_remove_persistent_group,
261075ecf5267604f166b85a7ee2cf0d9cb682966680Jouni Malinen	  {
261175ecf5267604f166b85a7ee2cf0d9cb682966680Jouni Malinen		  { "path", "o", ARG_IN },
261275ecf5267604f166b85a7ee2cf0d9cb682966680Jouni Malinen		  END_ARGS
261375ecf5267604f166b85a7ee2cf0d9cb682966680Jouni Malinen	  }
261475ecf5267604f166b85a7ee2cf0d9cb682966680Jouni Malinen	},
261575ecf5267604f166b85a7ee2cf0d9cb682966680Jouni Malinen	{ "RemoveAllPersistentGroups", WPAS_DBUS_NEW_IFACE_P2PDEVICE,
261675ecf5267604f166b85a7ee2cf0d9cb682966680Jouni Malinen	  (WPADBusMethodHandler)
261775ecf5267604f166b85a7ee2cf0d9cb682966680Jouni Malinen	  wpas_dbus_handler_remove_all_persistent_groups,
261875ecf5267604f166b85a7ee2cf0d9cb682966680Jouni Malinen	  {
261975ecf5267604f166b85a7ee2cf0d9cb682966680Jouni Malinen		  END_ARGS
262075ecf5267604f166b85a7ee2cf0d9cb682966680Jouni Malinen	  }
262175ecf5267604f166b85a7ee2cf0d9cb682966680Jouni Malinen	},
262275ecf5267604f166b85a7ee2cf0d9cb682966680Jouni Malinen#endif /* CONFIG_P2P */
26238d520ff1dc2da35cdca849e982051b86468016d8Dmitry Shmidt	{ "FlushBSS", WPAS_DBUS_NEW_IFACE_INTERFACE,
26248d520ff1dc2da35cdca849e982051b86468016d8Dmitry Shmidt	  (WPADBusMethodHandler) &wpas_dbus_handler_flush_bss,
26258d520ff1dc2da35cdca849e982051b86468016d8Dmitry Shmidt	  {
26268d520ff1dc2da35cdca849e982051b86468016d8Dmitry Shmidt		  { "age", "u", ARG_IN },
26278d520ff1dc2da35cdca849e982051b86468016d8Dmitry Shmidt		  END_ARGS
26288d520ff1dc2da35cdca849e982051b86468016d8Dmitry Shmidt	  }
26298d520ff1dc2da35cdca849e982051b86468016d8Dmitry Shmidt	},
263004949598a23f501be6eec21697465fd46a28840aDmitry Shmidt#ifdef CONFIG_AP
263104949598a23f501be6eec21697465fd46a28840aDmitry Shmidt	{ "SubscribeProbeReq", WPAS_DBUS_NEW_IFACE_INTERFACE,
263204949598a23f501be6eec21697465fd46a28840aDmitry Shmidt	  (WPADBusMethodHandler) wpas_dbus_handler_subscribe_preq,
263304949598a23f501be6eec21697465fd46a28840aDmitry Shmidt	  {
263404949598a23f501be6eec21697465fd46a28840aDmitry Shmidt		  END_ARGS
263504949598a23f501be6eec21697465fd46a28840aDmitry Shmidt	  }
263604949598a23f501be6eec21697465fd46a28840aDmitry Shmidt	},
263704949598a23f501be6eec21697465fd46a28840aDmitry Shmidt	{ "UnsubscribeProbeReq", WPAS_DBUS_NEW_IFACE_INTERFACE,
263804949598a23f501be6eec21697465fd46a28840aDmitry Shmidt	  (WPADBusMethodHandler) wpas_dbus_handler_unsubscribe_preq,
263904949598a23f501be6eec21697465fd46a28840aDmitry Shmidt	  {
264004949598a23f501be6eec21697465fd46a28840aDmitry Shmidt		  END_ARGS
264104949598a23f501be6eec21697465fd46a28840aDmitry Shmidt	  }
264204949598a23f501be6eec21697465fd46a28840aDmitry Shmidt	},
264304949598a23f501be6eec21697465fd46a28840aDmitry Shmidt#endif /* CONFIG_AP */
26448d520ff1dc2da35cdca849e982051b86468016d8Dmitry Shmidt	{ NULL, NULL, NULL, { END_ARGS } }
26458d520ff1dc2da35cdca849e982051b86468016d8Dmitry Shmidt};
26468d520ff1dc2da35cdca849e982051b86468016d8Dmitry Shmidt
26478d520ff1dc2da35cdca849e982051b86468016d8Dmitry Shmidtstatic const struct wpa_dbus_property_desc wpas_dbus_interface_properties[] = {
26488d520ff1dc2da35cdca849e982051b86468016d8Dmitry Shmidt	{ "Capabilities", WPAS_DBUS_NEW_IFACE_INTERFACE, "a{sv}",
26491f69aa52ea2e0a73ac502565df8c666ee49cab6aDmitry Shmidt	  wpas_dbus_getter_capabilities,
26501f69aa52ea2e0a73ac502565df8c666ee49cab6aDmitry Shmidt	  NULL
26518d520ff1dc2da35cdca849e982051b86468016d8Dmitry Shmidt	},
26528d520ff1dc2da35cdca849e982051b86468016d8Dmitry Shmidt	{ "State", WPAS_DBUS_NEW_IFACE_INTERFACE, "s",
26531f69aa52ea2e0a73ac502565df8c666ee49cab6aDmitry Shmidt	  wpas_dbus_getter_state,
26541f69aa52ea2e0a73ac502565df8c666ee49cab6aDmitry Shmidt	  NULL
26558d520ff1dc2da35cdca849e982051b86468016d8Dmitry Shmidt	},
26568d520ff1dc2da35cdca849e982051b86468016d8Dmitry Shmidt	{ "Scanning", WPAS_DBUS_NEW_IFACE_INTERFACE, "b",
26571f69aa52ea2e0a73ac502565df8c666ee49cab6aDmitry Shmidt	  wpas_dbus_getter_scanning,
26581f69aa52ea2e0a73ac502565df8c666ee49cab6aDmitry Shmidt	  NULL
26598d520ff1dc2da35cdca849e982051b86468016d8Dmitry Shmidt	},
26608d520ff1dc2da35cdca849e982051b86468016d8Dmitry Shmidt	{ "ApScan", WPAS_DBUS_NEW_IFACE_INTERFACE, "u",
26611f69aa52ea2e0a73ac502565df8c666ee49cab6aDmitry Shmidt	  wpas_dbus_getter_ap_scan,
26621f69aa52ea2e0a73ac502565df8c666ee49cab6aDmitry Shmidt	  wpas_dbus_setter_ap_scan
26638d520ff1dc2da35cdca849e982051b86468016d8Dmitry Shmidt	},
26648d520ff1dc2da35cdca849e982051b86468016d8Dmitry Shmidt	{ "BSSExpireAge", WPAS_DBUS_NEW_IFACE_INTERFACE, "u",
26651f69aa52ea2e0a73ac502565df8c666ee49cab6aDmitry Shmidt	  wpas_dbus_getter_bss_expire_age,
26661f69aa52ea2e0a73ac502565df8c666ee49cab6aDmitry Shmidt	  wpas_dbus_setter_bss_expire_age
26678d520ff1dc2da35cdca849e982051b86468016d8Dmitry Shmidt	},
26688d520ff1dc2da35cdca849e982051b86468016d8Dmitry Shmidt	{ "BSSExpireCount", WPAS_DBUS_NEW_IFACE_INTERFACE, "u",
26691f69aa52ea2e0a73ac502565df8c666ee49cab6aDmitry Shmidt	  wpas_dbus_getter_bss_expire_count,
26701f69aa52ea2e0a73ac502565df8c666ee49cab6aDmitry Shmidt	  wpas_dbus_setter_bss_expire_count
26718d520ff1dc2da35cdca849e982051b86468016d8Dmitry Shmidt	},
26728d520ff1dc2da35cdca849e982051b86468016d8Dmitry Shmidt	{ "Country", WPAS_DBUS_NEW_IFACE_INTERFACE, "s",
26731f69aa52ea2e0a73ac502565df8c666ee49cab6aDmitry Shmidt	  wpas_dbus_getter_country,
26741f69aa52ea2e0a73ac502565df8c666ee49cab6aDmitry Shmidt	  wpas_dbus_setter_country
26758d520ff1dc2da35cdca849e982051b86468016d8Dmitry Shmidt	},
26768d520ff1dc2da35cdca849e982051b86468016d8Dmitry Shmidt	{ "Ifname", WPAS_DBUS_NEW_IFACE_INTERFACE, "s",
26771f69aa52ea2e0a73ac502565df8c666ee49cab6aDmitry Shmidt	  wpas_dbus_getter_ifname,
26781f69aa52ea2e0a73ac502565df8c666ee49cab6aDmitry Shmidt	  NULL
26798d520ff1dc2da35cdca849e982051b86468016d8Dmitry Shmidt	},
26808d520ff1dc2da35cdca849e982051b86468016d8Dmitry Shmidt	{ "Driver", WPAS_DBUS_NEW_IFACE_INTERFACE, "s",
26811f69aa52ea2e0a73ac502565df8c666ee49cab6aDmitry Shmidt	  wpas_dbus_getter_driver,
26821f69aa52ea2e0a73ac502565df8c666ee49cab6aDmitry Shmidt	  NULL
26838d520ff1dc2da35cdca849e982051b86468016d8Dmitry Shmidt	},
26848d520ff1dc2da35cdca849e982051b86468016d8Dmitry Shmidt	{ "BridgeIfname", WPAS_DBUS_NEW_IFACE_INTERFACE, "s",
26851f69aa52ea2e0a73ac502565df8c666ee49cab6aDmitry Shmidt	  wpas_dbus_getter_bridge_ifname,
26861f69aa52ea2e0a73ac502565df8c666ee49cab6aDmitry Shmidt	  NULL
26878d520ff1dc2da35cdca849e982051b86468016d8Dmitry Shmidt	},
26888d520ff1dc2da35cdca849e982051b86468016d8Dmitry Shmidt	{ "CurrentBSS", WPAS_DBUS_NEW_IFACE_INTERFACE, "o",
26891f69aa52ea2e0a73ac502565df8c666ee49cab6aDmitry Shmidt	  wpas_dbus_getter_current_bss,
26901f69aa52ea2e0a73ac502565df8c666ee49cab6aDmitry Shmidt	  NULL
26918d520ff1dc2da35cdca849e982051b86468016d8Dmitry Shmidt	},
269275ecf5267604f166b85a7ee2cf0d9cb682966680Jouni Malinen	{ "CurrentNetwork", WPAS_DBUS_NEW_IFACE_INTERFACE, "o",
26931f69aa52ea2e0a73ac502565df8c666ee49cab6aDmitry Shmidt	  wpas_dbus_getter_current_network,
26941f69aa52ea2e0a73ac502565df8c666ee49cab6aDmitry Shmidt	  NULL
269575ecf5267604f166b85a7ee2cf0d9cb682966680Jouni Malinen	},
269675ecf5267604f166b85a7ee2cf0d9cb682966680Jouni Malinen	{ "CurrentAuthMode", WPAS_DBUS_NEW_IFACE_INTERFACE, "s",
26971f69aa52ea2e0a73ac502565df8c666ee49cab6aDmitry Shmidt	  wpas_dbus_getter_current_auth_mode,
26981f69aa52ea2e0a73ac502565df8c666ee49cab6aDmitry Shmidt	  NULL
269975ecf5267604f166b85a7ee2cf0d9cb682966680Jouni Malinen	},
270075ecf5267604f166b85a7ee2cf0d9cb682966680Jouni Malinen	{ "Blobs", WPAS_DBUS_NEW_IFACE_INTERFACE, "a{say}",
27011f69aa52ea2e0a73ac502565df8c666ee49cab6aDmitry Shmidt	  wpas_dbus_getter_blobs,
27021f69aa52ea2e0a73ac502565df8c666ee49cab6aDmitry Shmidt	  NULL
270375ecf5267604f166b85a7ee2cf0d9cb682966680Jouni Malinen	},
270475ecf5267604f166b85a7ee2cf0d9cb682966680Jouni Malinen	{ "BSSs", WPAS_DBUS_NEW_IFACE_INTERFACE, "ao",
27051f69aa52ea2e0a73ac502565df8c666ee49cab6aDmitry Shmidt	  wpas_dbus_getter_bsss,
27061f69aa52ea2e0a73ac502565df8c666ee49cab6aDmitry Shmidt	  NULL
270775ecf5267604f166b85a7ee2cf0d9cb682966680Jouni Malinen	},
270875ecf5267604f166b85a7ee2cf0d9cb682966680Jouni Malinen	{ "Networks", WPAS_DBUS_NEW_IFACE_INTERFACE, "ao",
27091f69aa52ea2e0a73ac502565df8c666ee49cab6aDmitry Shmidt	  wpas_dbus_getter_networks,
27101f69aa52ea2e0a73ac502565df8c666ee49cab6aDmitry Shmidt	  NULL
271175ecf5267604f166b85a7ee2cf0d9cb682966680Jouni Malinen	},
2712c5ec7f57ead87efa365800228aa0b09a12d9e6c4Dmitry Shmidt	{ "FastReauth", WPAS_DBUS_NEW_IFACE_INTERFACE, "b",
2713c5ec7f57ead87efa365800228aa0b09a12d9e6c4Dmitry Shmidt	  wpas_dbus_getter_fast_reauth,
2714c5ec7f57ead87efa365800228aa0b09a12d9e6c4Dmitry Shmidt	  wpas_dbus_setter_fast_reauth
2715c5ec7f57ead87efa365800228aa0b09a12d9e6c4Dmitry Shmidt	},
271604949598a23f501be6eec21697465fd46a28840aDmitry Shmidt	{ "ScanInterval", WPAS_DBUS_NEW_IFACE_INTERFACE, "i",
271704949598a23f501be6eec21697465fd46a28840aDmitry Shmidt	  wpas_dbus_getter_scan_interval,
271804949598a23f501be6eec21697465fd46a28840aDmitry Shmidt	  wpas_dbus_setter_scan_interval
271904949598a23f501be6eec21697465fd46a28840aDmitry Shmidt	},
272075ecf5267604f166b85a7ee2cf0d9cb682966680Jouni Malinen#ifdef CONFIG_WPS
272175ecf5267604f166b85a7ee2cf0d9cb682966680Jouni Malinen	{ "ProcessCredentials", WPAS_DBUS_NEW_IFACE_WPS, "b",
27221f69aa52ea2e0a73ac502565df8c666ee49cab6aDmitry Shmidt	  wpas_dbus_getter_process_credentials,
27231f69aa52ea2e0a73ac502565df8c666ee49cab6aDmitry Shmidt	  wpas_dbus_setter_process_credentials
272475ecf5267604f166b85a7ee2cf0d9cb682966680Jouni Malinen	},
272575ecf5267604f166b85a7ee2cf0d9cb682966680Jouni Malinen#endif /* CONFIG_WPS */
272675ecf5267604f166b85a7ee2cf0d9cb682966680Jouni Malinen#ifdef CONFIG_P2P
272704949598a23f501be6eec21697465fd46a28840aDmitry Shmidt	{ "P2PDeviceConfig", WPAS_DBUS_NEW_IFACE_P2PDEVICE, "a{sv}",
272804949598a23f501be6eec21697465fd46a28840aDmitry Shmidt	  wpas_dbus_getter_p2p_device_config,
272904949598a23f501be6eec21697465fd46a28840aDmitry Shmidt	  wpas_dbus_setter_p2p_device_config
273075ecf5267604f166b85a7ee2cf0d9cb682966680Jouni Malinen	},
273175ecf5267604f166b85a7ee2cf0d9cb682966680Jouni Malinen	{ "Peers", WPAS_DBUS_NEW_IFACE_P2PDEVICE, "ao",
27321f69aa52ea2e0a73ac502565df8c666ee49cab6aDmitry Shmidt	  wpas_dbus_getter_p2p_peers,
27331f69aa52ea2e0a73ac502565df8c666ee49cab6aDmitry Shmidt	  NULL
273475ecf5267604f166b85a7ee2cf0d9cb682966680Jouni Malinen	},
273575ecf5267604f166b85a7ee2cf0d9cb682966680Jouni Malinen	{ "Role", WPAS_DBUS_NEW_IFACE_P2PDEVICE, "s",
27361f69aa52ea2e0a73ac502565df8c666ee49cab6aDmitry Shmidt	  wpas_dbus_getter_p2p_role,
27371f69aa52ea2e0a73ac502565df8c666ee49cab6aDmitry Shmidt	  NULL
273875ecf5267604f166b85a7ee2cf0d9cb682966680Jouni Malinen	},
273975ecf5267604f166b85a7ee2cf0d9cb682966680Jouni Malinen	{ "Group", WPAS_DBUS_NEW_IFACE_P2PDEVICE, "o",
27401f69aa52ea2e0a73ac502565df8c666ee49cab6aDmitry Shmidt	  wpas_dbus_getter_p2p_group,
27411f69aa52ea2e0a73ac502565df8c666ee49cab6aDmitry Shmidt	  NULL
274275ecf5267604f166b85a7ee2cf0d9cb682966680Jouni Malinen	},
274375ecf5267604f166b85a7ee2cf0d9cb682966680Jouni Malinen	{ "PeerGO", WPAS_DBUS_NEW_IFACE_P2PDEVICE, "o",
27441f69aa52ea2e0a73ac502565df8c666ee49cab6aDmitry Shmidt	  wpas_dbus_getter_p2p_peergo,
27451f69aa52ea2e0a73ac502565df8c666ee49cab6aDmitry Shmidt	  NULL
274675ecf5267604f166b85a7ee2cf0d9cb682966680Jouni Malinen	},
274775ecf5267604f166b85a7ee2cf0d9cb682966680Jouni Malinen	{ "PersistentGroups", WPAS_DBUS_NEW_IFACE_P2PDEVICE, "ao",
27481f69aa52ea2e0a73ac502565df8c666ee49cab6aDmitry Shmidt	  wpas_dbus_getter_persistent_groups,
27491f69aa52ea2e0a73ac502565df8c666ee49cab6aDmitry Shmidt	  NULL
275075ecf5267604f166b85a7ee2cf0d9cb682966680Jouni Malinen	},
275175ecf5267604f166b85a7ee2cf0d9cb682966680Jouni Malinen#endif /* CONFIG_P2P */
275204949598a23f501be6eec21697465fd46a28840aDmitry Shmidt	{ "DisconnectReason", WPAS_DBUS_NEW_IFACE_INTERFACE, "i",
275304949598a23f501be6eec21697465fd46a28840aDmitry Shmidt	  wpas_dbus_getter_disconnect_reason,
275404949598a23f501be6eec21697465fd46a28840aDmitry Shmidt	  NULL
275504949598a23f501be6eec21697465fd46a28840aDmitry Shmidt	},
27561f69aa52ea2e0a73ac502565df8c666ee49cab6aDmitry Shmidt	{ NULL, NULL, NULL, NULL, NULL }
275775ecf5267604f166b85a7ee2cf0d9cb682966680Jouni Malinen};
275875ecf5267604f166b85a7ee2cf0d9cb682966680Jouni Malinen
275975ecf5267604f166b85a7ee2cf0d9cb682966680Jouni Malinenstatic const struct wpa_dbus_signal_desc wpas_dbus_interface_signals[] = {
276075ecf5267604f166b85a7ee2cf0d9cb682966680Jouni Malinen	{ "ScanDone", WPAS_DBUS_NEW_IFACE_INTERFACE,
276175ecf5267604f166b85a7ee2cf0d9cb682966680Jouni Malinen	  {
276275ecf5267604f166b85a7ee2cf0d9cb682966680Jouni Malinen		  { "success", "b", ARG_OUT },
276375ecf5267604f166b85a7ee2cf0d9cb682966680Jouni Malinen		  END_ARGS
276475ecf5267604f166b85a7ee2cf0d9cb682966680Jouni Malinen	  }
276575ecf5267604f166b85a7ee2cf0d9cb682966680Jouni Malinen	},
276675ecf5267604f166b85a7ee2cf0d9cb682966680Jouni Malinen	{ "BSSAdded", WPAS_DBUS_NEW_IFACE_INTERFACE,
276775ecf5267604f166b85a7ee2cf0d9cb682966680Jouni Malinen	  {
276875ecf5267604f166b85a7ee2cf0d9cb682966680Jouni Malinen		  { "path", "o", ARG_OUT },
276975ecf5267604f166b85a7ee2cf0d9cb682966680Jouni Malinen		  { "properties", "a{sv}", ARG_OUT },
277075ecf5267604f166b85a7ee2cf0d9cb682966680Jouni Malinen		  END_ARGS
277175ecf5267604f166b85a7ee2cf0d9cb682966680Jouni Malinen	  }
277275ecf5267604f166b85a7ee2cf0d9cb682966680Jouni Malinen	},
277375ecf5267604f166b85a7ee2cf0d9cb682966680Jouni Malinen	{ "BSSRemoved", WPAS_DBUS_NEW_IFACE_INTERFACE,
277475ecf5267604f166b85a7ee2cf0d9cb682966680Jouni Malinen	  {
277575ecf5267604f166b85a7ee2cf0d9cb682966680Jouni Malinen		  { "path", "o", ARG_OUT },
277675ecf5267604f166b85a7ee2cf0d9cb682966680Jouni Malinen		  END_ARGS
277775ecf5267604f166b85a7ee2cf0d9cb682966680Jouni Malinen	  }
277875ecf5267604f166b85a7ee2cf0d9cb682966680Jouni Malinen	},
277975ecf5267604f166b85a7ee2cf0d9cb682966680Jouni Malinen	{ "BlobAdded", WPAS_DBUS_NEW_IFACE_INTERFACE,
278075ecf5267604f166b85a7ee2cf0d9cb682966680Jouni Malinen	  {
278175ecf5267604f166b85a7ee2cf0d9cb682966680Jouni Malinen		  { "name", "s", ARG_OUT },
278275ecf5267604f166b85a7ee2cf0d9cb682966680Jouni Malinen		  END_ARGS
278375ecf5267604f166b85a7ee2cf0d9cb682966680Jouni Malinen	  }
278475ecf5267604f166b85a7ee2cf0d9cb682966680Jouni Malinen	},
278575ecf5267604f166b85a7ee2cf0d9cb682966680Jouni Malinen	{ "BlobRemoved", WPAS_DBUS_NEW_IFACE_INTERFACE,
278675ecf5267604f166b85a7ee2cf0d9cb682966680Jouni Malinen	  {
278775ecf5267604f166b85a7ee2cf0d9cb682966680Jouni Malinen		  { "name", "s", ARG_OUT },
278875ecf5267604f166b85a7ee2cf0d9cb682966680Jouni Malinen		  END_ARGS
278975ecf5267604f166b85a7ee2cf0d9cb682966680Jouni Malinen	  }
279075ecf5267604f166b85a7ee2cf0d9cb682966680Jouni Malinen	},
279175ecf5267604f166b85a7ee2cf0d9cb682966680Jouni Malinen	{ "NetworkAdded", WPAS_DBUS_NEW_IFACE_INTERFACE,
279275ecf5267604f166b85a7ee2cf0d9cb682966680Jouni Malinen	  {
279375ecf5267604f166b85a7ee2cf0d9cb682966680Jouni Malinen		  { "path", "o", ARG_OUT },
279475ecf5267604f166b85a7ee2cf0d9cb682966680Jouni Malinen		  { "properties", "a{sv}", ARG_OUT },
279575ecf5267604f166b85a7ee2cf0d9cb682966680Jouni Malinen		  END_ARGS
279675ecf5267604f166b85a7ee2cf0d9cb682966680Jouni Malinen	  }
279775ecf5267604f166b85a7ee2cf0d9cb682966680Jouni Malinen	},
279875ecf5267604f166b85a7ee2cf0d9cb682966680Jouni Malinen	{ "NetworkRemoved", WPAS_DBUS_NEW_IFACE_INTERFACE,
279975ecf5267604f166b85a7ee2cf0d9cb682966680Jouni Malinen	  {
280075ecf5267604f166b85a7ee2cf0d9cb682966680Jouni Malinen		  { "path", "o", ARG_OUT },
280175ecf5267604f166b85a7ee2cf0d9cb682966680Jouni Malinen		  END_ARGS
280275ecf5267604f166b85a7ee2cf0d9cb682966680Jouni Malinen	  }
280375ecf5267604f166b85a7ee2cf0d9cb682966680Jouni Malinen	},
280475ecf5267604f166b85a7ee2cf0d9cb682966680Jouni Malinen	{ "NetworkSelected", WPAS_DBUS_NEW_IFACE_INTERFACE,
280575ecf5267604f166b85a7ee2cf0d9cb682966680Jouni Malinen	  {
280675ecf5267604f166b85a7ee2cf0d9cb682966680Jouni Malinen		  { "path", "o", ARG_OUT },
280775ecf5267604f166b85a7ee2cf0d9cb682966680Jouni Malinen		  END_ARGS
280875ecf5267604f166b85a7ee2cf0d9cb682966680Jouni Malinen	  }
280975ecf5267604f166b85a7ee2cf0d9cb682966680Jouni Malinen	},
28101f69aa52ea2e0a73ac502565df8c666ee49cab6aDmitry Shmidt	/* Deprecated: use org.freedesktop.DBus.Properties.PropertiesChanged */
281175ecf5267604f166b85a7ee2cf0d9cb682966680Jouni Malinen	{ "PropertiesChanged", WPAS_DBUS_NEW_IFACE_INTERFACE,
281275ecf5267604f166b85a7ee2cf0d9cb682966680Jouni Malinen	  {
281375ecf5267604f166b85a7ee2cf0d9cb682966680Jouni Malinen		  { "properties", "a{sv}", ARG_OUT },
281475ecf5267604f166b85a7ee2cf0d9cb682966680Jouni Malinen		  END_ARGS
281575ecf5267604f166b85a7ee2cf0d9cb682966680Jouni Malinen	  }
281675ecf5267604f166b85a7ee2cf0d9cb682966680Jouni Malinen	},
281775ecf5267604f166b85a7ee2cf0d9cb682966680Jouni Malinen#ifdef CONFIG_WPS
281875ecf5267604f166b85a7ee2cf0d9cb682966680Jouni Malinen	{ "Event", WPAS_DBUS_NEW_IFACE_WPS,
281975ecf5267604f166b85a7ee2cf0d9cb682966680Jouni Malinen	  {
282075ecf5267604f166b85a7ee2cf0d9cb682966680Jouni Malinen		  { "name", "s", ARG_OUT },
282175ecf5267604f166b85a7ee2cf0d9cb682966680Jouni Malinen		  { "args", "a{sv}", ARG_OUT },
282275ecf5267604f166b85a7ee2cf0d9cb682966680Jouni Malinen		  END_ARGS
282375ecf5267604f166b85a7ee2cf0d9cb682966680Jouni Malinen	  }
282475ecf5267604f166b85a7ee2cf0d9cb682966680Jouni Malinen	},
282575ecf5267604f166b85a7ee2cf0d9cb682966680Jouni Malinen	{ "Credentials", WPAS_DBUS_NEW_IFACE_WPS,
282675ecf5267604f166b85a7ee2cf0d9cb682966680Jouni Malinen	  {
282775ecf5267604f166b85a7ee2cf0d9cb682966680Jouni Malinen		  { "credentials", "a{sv}", ARG_OUT },
282875ecf5267604f166b85a7ee2cf0d9cb682966680Jouni Malinen		  END_ARGS
282975ecf5267604f166b85a7ee2cf0d9cb682966680Jouni Malinen	  }
283075ecf5267604f166b85a7ee2cf0d9cb682966680Jouni Malinen	},
28311f69aa52ea2e0a73ac502565df8c666ee49cab6aDmitry Shmidt	/* Deprecated: use org.freedesktop.DBus.Properties.PropertiesChanged */
283275ecf5267604f166b85a7ee2cf0d9cb682966680Jouni Malinen	{ "PropertiesChanged", WPAS_DBUS_NEW_IFACE_WPS,
283375ecf5267604f166b85a7ee2cf0d9cb682966680Jouni Malinen	  {
283475ecf5267604f166b85a7ee2cf0d9cb682966680Jouni Malinen		  { "properties", "a{sv}", ARG_OUT },
283575ecf5267604f166b85a7ee2cf0d9cb682966680Jouni Malinen		  END_ARGS
283675ecf5267604f166b85a7ee2cf0d9cb682966680Jouni Malinen	  }
283775ecf5267604f166b85a7ee2cf0d9cb682966680Jouni Malinen	},
283875ecf5267604f166b85a7ee2cf0d9cb682966680Jouni Malinen#endif /* CONFIG_WPS */
283975ecf5267604f166b85a7ee2cf0d9cb682966680Jouni Malinen#ifdef CONFIG_P2P
284075ecf5267604f166b85a7ee2cf0d9cb682966680Jouni Malinen	{ "P2PStateChanged", WPAS_DBUS_NEW_IFACE_P2PDEVICE,
284175ecf5267604f166b85a7ee2cf0d9cb682966680Jouni Malinen	  {
284275ecf5267604f166b85a7ee2cf0d9cb682966680Jouni Malinen		  { "states", "a{ss}", ARG_OUT },
284375ecf5267604f166b85a7ee2cf0d9cb682966680Jouni Malinen		  END_ARGS
284475ecf5267604f166b85a7ee2cf0d9cb682966680Jouni Malinen	  }
284575ecf5267604f166b85a7ee2cf0d9cb682966680Jouni Malinen	},
284675ecf5267604f166b85a7ee2cf0d9cb682966680Jouni Malinen	{ "DeviceFound", WPAS_DBUS_NEW_IFACE_P2PDEVICE,
284775ecf5267604f166b85a7ee2cf0d9cb682966680Jouni Malinen	  {
284875ecf5267604f166b85a7ee2cf0d9cb682966680Jouni Malinen		  { "path", "o", ARG_OUT },
284975ecf5267604f166b85a7ee2cf0d9cb682966680Jouni Malinen		  { "properties", "a{sv}", ARG_OUT },
285075ecf5267604f166b85a7ee2cf0d9cb682966680Jouni Malinen		  END_ARGS
285175ecf5267604f166b85a7ee2cf0d9cb682966680Jouni Malinen	  }
285275ecf5267604f166b85a7ee2cf0d9cb682966680Jouni Malinen	},
285375ecf5267604f166b85a7ee2cf0d9cb682966680Jouni Malinen	{ "DeviceLost", WPAS_DBUS_NEW_IFACE_P2PDEVICE,
285475ecf5267604f166b85a7ee2cf0d9cb682966680Jouni Malinen	  {
285575ecf5267604f166b85a7ee2cf0d9cb682966680Jouni Malinen		  { "path", "o", ARG_OUT },
285675ecf5267604f166b85a7ee2cf0d9cb682966680Jouni Malinen		  END_ARGS
285775ecf5267604f166b85a7ee2cf0d9cb682966680Jouni Malinen	  }
285875ecf5267604f166b85a7ee2cf0d9cb682966680Jouni Malinen	},
285975ecf5267604f166b85a7ee2cf0d9cb682966680Jouni Malinen	{ "ProvisionDiscoveryRequestDisplayPin", WPAS_DBUS_NEW_IFACE_P2PDEVICE,
286075ecf5267604f166b85a7ee2cf0d9cb682966680Jouni Malinen	  {
286175ecf5267604f166b85a7ee2cf0d9cb682966680Jouni Malinen		  { "peer_object", "o", ARG_OUT },
286275ecf5267604f166b85a7ee2cf0d9cb682966680Jouni Malinen		  { "pin", "s", ARG_OUT },
286375ecf5267604f166b85a7ee2cf0d9cb682966680Jouni Malinen		  END_ARGS
286475ecf5267604f166b85a7ee2cf0d9cb682966680Jouni Malinen	  }
28658d520ff1dc2da35cdca849e982051b86468016d8Dmitry Shmidt	},
286675ecf5267604f166b85a7ee2cf0d9cb682966680Jouni Malinen	{ "ProvisionDiscoveryResponseDisplayPin", WPAS_DBUS_NEW_IFACE_P2PDEVICE,
286775ecf5267604f166b85a7ee2cf0d9cb682966680Jouni Malinen	  {
286875ecf5267604f166b85a7ee2cf0d9cb682966680Jouni Malinen		  { "peer_object", "o", ARG_OUT },
286975ecf5267604f166b85a7ee2cf0d9cb682966680Jouni Malinen		  { "pin", "s", ARG_OUT },
287075ecf5267604f166b85a7ee2cf0d9cb682966680Jouni Malinen		  END_ARGS
287175ecf5267604f166b85a7ee2cf0d9cb682966680Jouni Malinen	  }
28728d520ff1dc2da35cdca849e982051b86468016d8Dmitry Shmidt	},
287375ecf5267604f166b85a7ee2cf0d9cb682966680Jouni Malinen	{ "ProvisionDiscoveryRequestEnterPin", WPAS_DBUS_NEW_IFACE_P2PDEVICE,
287475ecf5267604f166b85a7ee2cf0d9cb682966680Jouni Malinen	  {
287575ecf5267604f166b85a7ee2cf0d9cb682966680Jouni Malinen		  { "peer_object", "o", ARG_OUT },
287675ecf5267604f166b85a7ee2cf0d9cb682966680Jouni Malinen		  END_ARGS
287775ecf5267604f166b85a7ee2cf0d9cb682966680Jouni Malinen	  }
28788d520ff1dc2da35cdca849e982051b86468016d8Dmitry Shmidt	},
287975ecf5267604f166b85a7ee2cf0d9cb682966680Jouni Malinen	{ "ProvisionDiscoveryResponseEnterPin", WPAS_DBUS_NEW_IFACE_P2PDEVICE,
288075ecf5267604f166b85a7ee2cf0d9cb682966680Jouni Malinen	  {
288175ecf5267604f166b85a7ee2cf0d9cb682966680Jouni Malinen		  { "peer_object", "o", ARG_OUT },
288275ecf5267604f166b85a7ee2cf0d9cb682966680Jouni Malinen		  END_ARGS
288375ecf5267604f166b85a7ee2cf0d9cb682966680Jouni Malinen	  }
28848d520ff1dc2da35cdca849e982051b86468016d8Dmitry Shmidt	},
288575ecf5267604f166b85a7ee2cf0d9cb682966680Jouni Malinen	{ "ProvisionDiscoveryPBCRequest", WPAS_DBUS_NEW_IFACE_P2PDEVICE,
288675ecf5267604f166b85a7ee2cf0d9cb682966680Jouni Malinen	  {
288775ecf5267604f166b85a7ee2cf0d9cb682966680Jouni Malinen		  { "peer_object", "o", ARG_OUT },
288875ecf5267604f166b85a7ee2cf0d9cb682966680Jouni Malinen		  END_ARGS
288975ecf5267604f166b85a7ee2cf0d9cb682966680Jouni Malinen	  }
28908d520ff1dc2da35cdca849e982051b86468016d8Dmitry Shmidt	},
289175ecf5267604f166b85a7ee2cf0d9cb682966680Jouni Malinen	{ "ProvisionDiscoveryPBCResponse", WPAS_DBUS_NEW_IFACE_P2PDEVICE,
289275ecf5267604f166b85a7ee2cf0d9cb682966680Jouni Malinen	  {
289375ecf5267604f166b85a7ee2cf0d9cb682966680Jouni Malinen		  { "peer_object", "o", ARG_OUT },
289475ecf5267604f166b85a7ee2cf0d9cb682966680Jouni Malinen		  END_ARGS
289575ecf5267604f166b85a7ee2cf0d9cb682966680Jouni Malinen	  }
28968d520ff1dc2da35cdca849e982051b86468016d8Dmitry Shmidt	},
289775ecf5267604f166b85a7ee2cf0d9cb682966680Jouni Malinen	{ "ProvisionDiscoveryFailure", WPAS_DBUS_NEW_IFACE_P2PDEVICE,
28988d520ff1dc2da35cdca849e982051b86468016d8Dmitry Shmidt	  {
289975ecf5267604f166b85a7ee2cf0d9cb682966680Jouni Malinen		  { "peer_object", "o", ARG_OUT },
290075ecf5267604f166b85a7ee2cf0d9cb682966680Jouni Malinen		  { "status", "i", ARG_OUT },
29018d520ff1dc2da35cdca849e982051b86468016d8Dmitry Shmidt		  END_ARGS
29028d520ff1dc2da35cdca849e982051b86468016d8Dmitry Shmidt	  }
29038d520ff1dc2da35cdca849e982051b86468016d8Dmitry Shmidt	},
290475ecf5267604f166b85a7ee2cf0d9cb682966680Jouni Malinen	{ "GroupStarted", WPAS_DBUS_NEW_IFACE_P2PDEVICE,
29058d520ff1dc2da35cdca849e982051b86468016d8Dmitry Shmidt	  {
29068d520ff1dc2da35cdca849e982051b86468016d8Dmitry Shmidt		  { "properties", "a{sv}", ARG_OUT },
29078d520ff1dc2da35cdca849e982051b86468016d8Dmitry Shmidt		  END_ARGS
29088d520ff1dc2da35cdca849e982051b86468016d8Dmitry Shmidt	  }
29098d520ff1dc2da35cdca849e982051b86468016d8Dmitry Shmidt	},
291075ecf5267604f166b85a7ee2cf0d9cb682966680Jouni Malinen	{ "GONegotiationSuccess", WPAS_DBUS_NEW_IFACE_P2PDEVICE,
291175ecf5267604f166b85a7ee2cf0d9cb682966680Jouni Malinen	  {
291275ecf5267604f166b85a7ee2cf0d9cb682966680Jouni Malinen		  END_ARGS
291375ecf5267604f166b85a7ee2cf0d9cb682966680Jouni Malinen	  }
291475ecf5267604f166b85a7ee2cf0d9cb682966680Jouni Malinen	},
291575ecf5267604f166b85a7ee2cf0d9cb682966680Jouni Malinen	{ "GONegotiationFailure", WPAS_DBUS_NEW_IFACE_P2PDEVICE,
291675ecf5267604f166b85a7ee2cf0d9cb682966680Jouni Malinen	  {
291775ecf5267604f166b85a7ee2cf0d9cb682966680Jouni Malinen		  { "status", "i", ARG_OUT },
291875ecf5267604f166b85a7ee2cf0d9cb682966680Jouni Malinen		  END_ARGS
291975ecf5267604f166b85a7ee2cf0d9cb682966680Jouni Malinen	  }
292075ecf5267604f166b85a7ee2cf0d9cb682966680Jouni Malinen	},
292175ecf5267604f166b85a7ee2cf0d9cb682966680Jouni Malinen	{ "GONegotiationRequest", WPAS_DBUS_NEW_IFACE_P2PDEVICE,
29228d520ff1dc2da35cdca849e982051b86468016d8Dmitry Shmidt	  {
29238d520ff1dc2da35cdca849e982051b86468016d8Dmitry Shmidt		  { "path", "o", ARG_OUT },
292475ecf5267604f166b85a7ee2cf0d9cb682966680Jouni Malinen		  { "dev_passwd_id", "i", ARG_OUT },
29258d520ff1dc2da35cdca849e982051b86468016d8Dmitry Shmidt		  END_ARGS
29268d520ff1dc2da35cdca849e982051b86468016d8Dmitry Shmidt	  }
29278d520ff1dc2da35cdca849e982051b86468016d8Dmitry Shmidt	},
292875ecf5267604f166b85a7ee2cf0d9cb682966680Jouni Malinen	{ "InvitationResult", WPAS_DBUS_NEW_IFACE_P2PDEVICE,
29298d520ff1dc2da35cdca849e982051b86468016d8Dmitry Shmidt	  {
293075ecf5267604f166b85a7ee2cf0d9cb682966680Jouni Malinen		  { "invite_result", "a{sv}", ARG_OUT },
29318d520ff1dc2da35cdca849e982051b86468016d8Dmitry Shmidt		  END_ARGS
29328d520ff1dc2da35cdca849e982051b86468016d8Dmitry Shmidt	  }
29338d520ff1dc2da35cdca849e982051b86468016d8Dmitry Shmidt	},
293475ecf5267604f166b85a7ee2cf0d9cb682966680Jouni Malinen	{ "GroupFinished", WPAS_DBUS_NEW_IFACE_P2PDEVICE,
29358d520ff1dc2da35cdca849e982051b86468016d8Dmitry Shmidt	  {
293675ecf5267604f166b85a7ee2cf0d9cb682966680Jouni Malinen		  { "ifname", "s", ARG_OUT },
293775ecf5267604f166b85a7ee2cf0d9cb682966680Jouni Malinen		  { "role", "s", ARG_OUT },
29388d520ff1dc2da35cdca849e982051b86468016d8Dmitry Shmidt		  END_ARGS
29398d520ff1dc2da35cdca849e982051b86468016d8Dmitry Shmidt	  }
29408d520ff1dc2da35cdca849e982051b86468016d8Dmitry Shmidt	},
294175ecf5267604f166b85a7ee2cf0d9cb682966680Jouni Malinen	{ "ServiceDiscoveryRequest", WPAS_DBUS_NEW_IFACE_P2PDEVICE,
29428d520ff1dc2da35cdca849e982051b86468016d8Dmitry Shmidt	  {
294375ecf5267604f166b85a7ee2cf0d9cb682966680Jouni Malinen		  { "sd_request", "a{sv}", ARG_OUT },
29448d520ff1dc2da35cdca849e982051b86468016d8Dmitry Shmidt		  END_ARGS
29458d520ff1dc2da35cdca849e982051b86468016d8Dmitry Shmidt	  }
29468d520ff1dc2da35cdca849e982051b86468016d8Dmitry Shmidt	},
294775ecf5267604f166b85a7ee2cf0d9cb682966680Jouni Malinen	{ "ServiceDiscoveryResponse", WPAS_DBUS_NEW_IFACE_P2PDEVICE,
29488d520ff1dc2da35cdca849e982051b86468016d8Dmitry Shmidt	  {
294975ecf5267604f166b85a7ee2cf0d9cb682966680Jouni Malinen		  { "sd_response", "a{sv}", ARG_OUT },
29508d520ff1dc2da35cdca849e982051b86468016d8Dmitry Shmidt		  END_ARGS
29518d520ff1dc2da35cdca849e982051b86468016d8Dmitry Shmidt	  }
29528d520ff1dc2da35cdca849e982051b86468016d8Dmitry Shmidt	},
295375ecf5267604f166b85a7ee2cf0d9cb682966680Jouni Malinen	{ "PersistentGroupAdded", WPAS_DBUS_NEW_IFACE_P2PDEVICE,
29548d520ff1dc2da35cdca849e982051b86468016d8Dmitry Shmidt	  {
29558d520ff1dc2da35cdca849e982051b86468016d8Dmitry Shmidt		  { "path", "o", ARG_OUT },
295675ecf5267604f166b85a7ee2cf0d9cb682966680Jouni Malinen		  { "properties", "a{sv}", ARG_OUT },
29578d520ff1dc2da35cdca849e982051b86468016d8Dmitry Shmidt		  END_ARGS
29588d520ff1dc2da35cdca849e982051b86468016d8Dmitry Shmidt	  }
29598d520ff1dc2da35cdca849e982051b86468016d8Dmitry Shmidt	},
2960c55524ad84d13014e8019491c2b17e5dcf13545aDmitry Shmidt	{ "PersistentGroupRemoved", WPAS_DBUS_NEW_IFACE_P2PDEVICE,
2961c55524ad84d13014e8019491c2b17e5dcf13545aDmitry Shmidt	  {
2962c55524ad84d13014e8019491c2b17e5dcf13545aDmitry Shmidt		  { "path", "o", ARG_OUT },
2963c55524ad84d13014e8019491c2b17e5dcf13545aDmitry Shmidt		  END_ARGS
2964c55524ad84d13014e8019491c2b17e5dcf13545aDmitry Shmidt	  }
2965c55524ad84d13014e8019491c2b17e5dcf13545aDmitry Shmidt	},
296675ecf5267604f166b85a7ee2cf0d9cb682966680Jouni Malinen	{ "WpsFailed", WPAS_DBUS_NEW_IFACE_P2PDEVICE,
29678d520ff1dc2da35cdca849e982051b86468016d8Dmitry Shmidt	  {
296875ecf5267604f166b85a7ee2cf0d9cb682966680Jouni Malinen		  { "name", "s", ARG_OUT },
296975ecf5267604f166b85a7ee2cf0d9cb682966680Jouni Malinen		  { "args", "a{sv}", ARG_OUT },
29708d520ff1dc2da35cdca849e982051b86468016d8Dmitry Shmidt		  END_ARGS
29718d520ff1dc2da35cdca849e982051b86468016d8Dmitry Shmidt	  }
29728d520ff1dc2da35cdca849e982051b86468016d8Dmitry Shmidt	},
297375ecf5267604f166b85a7ee2cf0d9cb682966680Jouni Malinen#endif /* CONFIG_P2P */
297404949598a23f501be6eec21697465fd46a28840aDmitry Shmidt#ifdef CONFIG_AP
297504949598a23f501be6eec21697465fd46a28840aDmitry Shmidt	{ "ProbeRequest", WPAS_DBUS_NEW_IFACE_INTERFACE,
297604949598a23f501be6eec21697465fd46a28840aDmitry Shmidt	  {
297704949598a23f501be6eec21697465fd46a28840aDmitry Shmidt		  { "args", "a{sv}", ARG_OUT },
297804949598a23f501be6eec21697465fd46a28840aDmitry Shmidt		  END_ARGS
297904949598a23f501be6eec21697465fd46a28840aDmitry Shmidt	  }
298004949598a23f501be6eec21697465fd46a28840aDmitry Shmidt	},
298104949598a23f501be6eec21697465fd46a28840aDmitry Shmidt#endif /* CONFIG_AP */
2982c55524ad84d13014e8019491c2b17e5dcf13545aDmitry Shmidt	{ "Certification", WPAS_DBUS_NEW_IFACE_INTERFACE,
2983c55524ad84d13014e8019491c2b17e5dcf13545aDmitry Shmidt	  {
2984c55524ad84d13014e8019491c2b17e5dcf13545aDmitry Shmidt		  { "certification", "a{sv}", ARG_OUT },
2985c55524ad84d13014e8019491c2b17e5dcf13545aDmitry Shmidt		  END_ARGS
2986c55524ad84d13014e8019491c2b17e5dcf13545aDmitry Shmidt	  }
2987c55524ad84d13014e8019491c2b17e5dcf13545aDmitry Shmidt	},
298804949598a23f501be6eec21697465fd46a28840aDmitry Shmidt	{ "EAP", WPAS_DBUS_NEW_IFACE_INTERFACE,
298904949598a23f501be6eec21697465fd46a28840aDmitry Shmidt	  {
299004949598a23f501be6eec21697465fd46a28840aDmitry Shmidt		  { "status", "s", ARG_OUT },
299104949598a23f501be6eec21697465fd46a28840aDmitry Shmidt		  { "parameter", "s", ARG_OUT },
299204949598a23f501be6eec21697465fd46a28840aDmitry Shmidt		  END_ARGS
299304949598a23f501be6eec21697465fd46a28840aDmitry Shmidt	  }
299404949598a23f501be6eec21697465fd46a28840aDmitry Shmidt	},
299575ecf5267604f166b85a7ee2cf0d9cb682966680Jouni Malinen	{ NULL, NULL, { END_ARGS } }
299675ecf5267604f166b85a7ee2cf0d9cb682966680Jouni Malinen};
299775ecf5267604f166b85a7ee2cf0d9cb682966680Jouni Malinen
299875ecf5267604f166b85a7ee2cf0d9cb682966680Jouni Malinen
299975ecf5267604f166b85a7ee2cf0d9cb682966680Jouni Malinenint wpas_dbus_register_interface(struct wpa_supplicant *wpa_s)
300075ecf5267604f166b85a7ee2cf0d9cb682966680Jouni Malinen{
300175ecf5267604f166b85a7ee2cf0d9cb682966680Jouni Malinen
300275ecf5267604f166b85a7ee2cf0d9cb682966680Jouni Malinen	struct wpa_dbus_object_desc *obj_desc = NULL;
300375ecf5267604f166b85a7ee2cf0d9cb682966680Jouni Malinen	struct wpas_dbus_priv *ctrl_iface = wpa_s->global->dbus;
300475ecf5267604f166b85a7ee2cf0d9cb682966680Jouni Malinen	int next;
300575ecf5267604f166b85a7ee2cf0d9cb682966680Jouni Malinen
300675ecf5267604f166b85a7ee2cf0d9cb682966680Jouni Malinen	/* Do nothing if the control interface is not turned on */
300775ecf5267604f166b85a7ee2cf0d9cb682966680Jouni Malinen	if (ctrl_iface == NULL)
300875ecf5267604f166b85a7ee2cf0d9cb682966680Jouni Malinen		return 0;
300975ecf5267604f166b85a7ee2cf0d9cb682966680Jouni Malinen
301075ecf5267604f166b85a7ee2cf0d9cb682966680Jouni Malinen	/* Create and set the interface's object path */
301175ecf5267604f166b85a7ee2cf0d9cb682966680Jouni Malinen	wpa_s->dbus_new_path = os_zalloc(WPAS_DBUS_OBJECT_PATH_MAX);
301275ecf5267604f166b85a7ee2cf0d9cb682966680Jouni Malinen	if (wpa_s->dbus_new_path == NULL)
301375ecf5267604f166b85a7ee2cf0d9cb682966680Jouni Malinen		return -1;
301475ecf5267604f166b85a7ee2cf0d9cb682966680Jouni Malinen	next = ctrl_iface->next_objid++;
301575ecf5267604f166b85a7ee2cf0d9cb682966680Jouni Malinen	os_snprintf(wpa_s->dbus_new_path, WPAS_DBUS_OBJECT_PATH_MAX,
301675ecf5267604f166b85a7ee2cf0d9cb682966680Jouni Malinen		    WPAS_DBUS_NEW_PATH_INTERFACES "/%u",
301775ecf5267604f166b85a7ee2cf0d9cb682966680Jouni Malinen		    next);
301875ecf5267604f166b85a7ee2cf0d9cb682966680Jouni Malinen
301975ecf5267604f166b85a7ee2cf0d9cb682966680Jouni Malinen	obj_desc = os_zalloc(sizeof(struct wpa_dbus_object_desc));
302075ecf5267604f166b85a7ee2cf0d9cb682966680Jouni Malinen	if (!obj_desc) {
302175ecf5267604f166b85a7ee2cf0d9cb682966680Jouni Malinen		wpa_printf(MSG_ERROR, "Not enough memory "
302275ecf5267604f166b85a7ee2cf0d9cb682966680Jouni Malinen			   "to create object description");
302375ecf5267604f166b85a7ee2cf0d9cb682966680Jouni Malinen		goto err;
302475ecf5267604f166b85a7ee2cf0d9cb682966680Jouni Malinen	}
302575ecf5267604f166b85a7ee2cf0d9cb682966680Jouni Malinen
302675ecf5267604f166b85a7ee2cf0d9cb682966680Jouni Malinen	wpas_dbus_register(obj_desc, wpa_s, NULL, wpas_dbus_interface_methods,
302775ecf5267604f166b85a7ee2cf0d9cb682966680Jouni Malinen			   wpas_dbus_interface_properties,
302875ecf5267604f166b85a7ee2cf0d9cb682966680Jouni Malinen			   wpas_dbus_interface_signals);
302975ecf5267604f166b85a7ee2cf0d9cb682966680Jouni Malinen
303075ecf5267604f166b85a7ee2cf0d9cb682966680Jouni Malinen	wpa_printf(MSG_DEBUG, "dbus: Register interface object '%s'",
303175ecf5267604f166b85a7ee2cf0d9cb682966680Jouni Malinen		   wpa_s->dbus_new_path);
303275ecf5267604f166b85a7ee2cf0d9cb682966680Jouni Malinen	if (wpa_dbus_register_object_per_iface(ctrl_iface,
303375ecf5267604f166b85a7ee2cf0d9cb682966680Jouni Malinen					       wpa_s->dbus_new_path,
303475ecf5267604f166b85a7ee2cf0d9cb682966680Jouni Malinen					       wpa_s->ifname, obj_desc))
303575ecf5267604f166b85a7ee2cf0d9cb682966680Jouni Malinen		goto err;
303675ecf5267604f166b85a7ee2cf0d9cb682966680Jouni Malinen
303775ecf5267604f166b85a7ee2cf0d9cb682966680Jouni Malinen	wpas_dbus_signal_interface_added(wpa_s);
303875ecf5267604f166b85a7ee2cf0d9cb682966680Jouni Malinen
303975ecf5267604f166b85a7ee2cf0d9cb682966680Jouni Malinen	return 0;
304075ecf5267604f166b85a7ee2cf0d9cb682966680Jouni Malinen
304175ecf5267604f166b85a7ee2cf0d9cb682966680Jouni Malinenerr:
304275ecf5267604f166b85a7ee2cf0d9cb682966680Jouni Malinen	os_free(wpa_s->dbus_new_path);
304375ecf5267604f166b85a7ee2cf0d9cb682966680Jouni Malinen	wpa_s->dbus_new_path = NULL;
304475ecf5267604f166b85a7ee2cf0d9cb682966680Jouni Malinen	free_dbus_object_desc(obj_desc);
304575ecf5267604f166b85a7ee2cf0d9cb682966680Jouni Malinen	return -1;
304675ecf5267604f166b85a7ee2cf0d9cb682966680Jouni Malinen}
304775ecf5267604f166b85a7ee2cf0d9cb682966680Jouni Malinen
304875ecf5267604f166b85a7ee2cf0d9cb682966680Jouni Malinen
304975ecf5267604f166b85a7ee2cf0d9cb682966680Jouni Malinenint wpas_dbus_unregister_interface(struct wpa_supplicant *wpa_s)
305075ecf5267604f166b85a7ee2cf0d9cb682966680Jouni Malinen{
305175ecf5267604f166b85a7ee2cf0d9cb682966680Jouni Malinen	struct wpas_dbus_priv *ctrl_iface;
305275ecf5267604f166b85a7ee2cf0d9cb682966680Jouni Malinen
305375ecf5267604f166b85a7ee2cf0d9cb682966680Jouni Malinen	/* Do nothing if the control interface is not turned on */
305475ecf5267604f166b85a7ee2cf0d9cb682966680Jouni Malinen	if (wpa_s == NULL || wpa_s->global == NULL)
305575ecf5267604f166b85a7ee2cf0d9cb682966680Jouni Malinen		return 0;
305675ecf5267604f166b85a7ee2cf0d9cb682966680Jouni Malinen	ctrl_iface = wpa_s->global->dbus;
305775ecf5267604f166b85a7ee2cf0d9cb682966680Jouni Malinen	if (ctrl_iface == NULL)
305875ecf5267604f166b85a7ee2cf0d9cb682966680Jouni Malinen		return 0;
305975ecf5267604f166b85a7ee2cf0d9cb682966680Jouni Malinen
306075ecf5267604f166b85a7ee2cf0d9cb682966680Jouni Malinen	wpa_printf(MSG_DEBUG, "dbus: Unregister interface object '%s'",
306175ecf5267604f166b85a7ee2cf0d9cb682966680Jouni Malinen		   wpa_s->dbus_new_path);
306204949598a23f501be6eec21697465fd46a28840aDmitry Shmidt
306304949598a23f501be6eec21697465fd46a28840aDmitry Shmidt#ifdef CONFIG_AP
306404949598a23f501be6eec21697465fd46a28840aDmitry Shmidt	if (wpa_s->preq_notify_peer) {
306504949598a23f501be6eec21697465fd46a28840aDmitry Shmidt		wpas_dbus_unsubscribe_noc(ctrl_iface);
306604949598a23f501be6eec21697465fd46a28840aDmitry Shmidt		os_free(wpa_s->preq_notify_peer);
306704949598a23f501be6eec21697465fd46a28840aDmitry Shmidt		wpa_s->preq_notify_peer = NULL;
306804949598a23f501be6eec21697465fd46a28840aDmitry Shmidt	}
306904949598a23f501be6eec21697465fd46a28840aDmitry Shmidt#endif /* CONFIG_AP */
307004949598a23f501be6eec21697465fd46a28840aDmitry Shmidt
307175ecf5267604f166b85a7ee2cf0d9cb682966680Jouni Malinen	if (wpa_dbus_unregister_object_per_iface(ctrl_iface,
307275ecf5267604f166b85a7ee2cf0d9cb682966680Jouni Malinen						 wpa_s->dbus_new_path))
307375ecf5267604f166b85a7ee2cf0d9cb682966680Jouni Malinen		return -1;
307475ecf5267604f166b85a7ee2cf0d9cb682966680Jouni Malinen
307575ecf5267604f166b85a7ee2cf0d9cb682966680Jouni Malinen	wpas_dbus_signal_interface_removed(wpa_s);
307675ecf5267604f166b85a7ee2cf0d9cb682966680Jouni Malinen
307775ecf5267604f166b85a7ee2cf0d9cb682966680Jouni Malinen	os_free(wpa_s->dbus_new_path);
307875ecf5267604f166b85a7ee2cf0d9cb682966680Jouni Malinen	wpa_s->dbus_new_path = NULL;
307975ecf5267604f166b85a7ee2cf0d9cb682966680Jouni Malinen
308075ecf5267604f166b85a7ee2cf0d9cb682966680Jouni Malinen	return 0;
308175ecf5267604f166b85a7ee2cf0d9cb682966680Jouni Malinen}
308275ecf5267604f166b85a7ee2cf0d9cb682966680Jouni Malinen
308375ecf5267604f166b85a7ee2cf0d9cb682966680Jouni Malinen#ifdef CONFIG_P2P
308475ecf5267604f166b85a7ee2cf0d9cb682966680Jouni Malinen
308575ecf5267604f166b85a7ee2cf0d9cb682966680Jouni Malinenstatic const struct wpa_dbus_property_desc wpas_dbus_p2p_peer_properties[] = {
3086c5ec7f57ead87efa365800228aa0b09a12d9e6c4Dmitry Shmidt	{ "DeviceName", WPAS_DBUS_NEW_IFACE_P2P_PEER, "s",
3087c5ec7f57ead87efa365800228aa0b09a12d9e6c4Dmitry Shmidt	  wpas_dbus_getter_p2p_peer_device_name,
3088c5ec7f57ead87efa365800228aa0b09a12d9e6c4Dmitry Shmidt	  NULL
3089c5ec7f57ead87efa365800228aa0b09a12d9e6c4Dmitry Shmidt	},
3090c5ec7f57ead87efa365800228aa0b09a12d9e6c4Dmitry Shmidt	{ "PrimaryDeviceType", WPAS_DBUS_NEW_IFACE_P2P_PEER, "ay",
3091c5ec7f57ead87efa365800228aa0b09a12d9e6c4Dmitry Shmidt	  wpas_dbus_getter_p2p_peer_primary_device_type,
3092c5ec7f57ead87efa365800228aa0b09a12d9e6c4Dmitry Shmidt	  NULL
3093c5ec7f57ead87efa365800228aa0b09a12d9e6c4Dmitry Shmidt	},
3094c5ec7f57ead87efa365800228aa0b09a12d9e6c4Dmitry Shmidt	{ "config_method", WPAS_DBUS_NEW_IFACE_P2P_PEER, "q",
3095c5ec7f57ead87efa365800228aa0b09a12d9e6c4Dmitry Shmidt	  wpas_dbus_getter_p2p_peer_config_method,
3096c5ec7f57ead87efa365800228aa0b09a12d9e6c4Dmitry Shmidt	  NULL
3097c5ec7f57ead87efa365800228aa0b09a12d9e6c4Dmitry Shmidt	},
3098c5ec7f57ead87efa365800228aa0b09a12d9e6c4Dmitry Shmidt	{ "level", WPAS_DBUS_NEW_IFACE_P2P_PEER, "i",
3099c5ec7f57ead87efa365800228aa0b09a12d9e6c4Dmitry Shmidt	  wpas_dbus_getter_p2p_peer_level,
3100c5ec7f57ead87efa365800228aa0b09a12d9e6c4Dmitry Shmidt	  NULL
3101c5ec7f57ead87efa365800228aa0b09a12d9e6c4Dmitry Shmidt	},
3102c5ec7f57ead87efa365800228aa0b09a12d9e6c4Dmitry Shmidt	{ "devicecapability", WPAS_DBUS_NEW_IFACE_P2P_PEER, "y",
3103c5ec7f57ead87efa365800228aa0b09a12d9e6c4Dmitry Shmidt	  wpas_dbus_getter_p2p_peer_device_capability,
3104c5ec7f57ead87efa365800228aa0b09a12d9e6c4Dmitry Shmidt	  NULL
3105c5ec7f57ead87efa365800228aa0b09a12d9e6c4Dmitry Shmidt	},
3106c5ec7f57ead87efa365800228aa0b09a12d9e6c4Dmitry Shmidt	{ "groupcapability", WPAS_DBUS_NEW_IFACE_P2P_PEER, "y",
3107c5ec7f57ead87efa365800228aa0b09a12d9e6c4Dmitry Shmidt	  wpas_dbus_getter_p2p_peer_group_capability,
3108c5ec7f57ead87efa365800228aa0b09a12d9e6c4Dmitry Shmidt	  NULL
3109c5ec7f57ead87efa365800228aa0b09a12d9e6c4Dmitry Shmidt	},
311004949598a23f501be6eec21697465fd46a28840aDmitry Shmidt	{ "SecondaryDeviceTypes", WPAS_DBUS_NEW_IFACE_P2P_PEER, "aay",
3111c5ec7f57ead87efa365800228aa0b09a12d9e6c4Dmitry Shmidt	  wpas_dbus_getter_p2p_peer_secondary_device_types,
3112c5ec7f57ead87efa365800228aa0b09a12d9e6c4Dmitry Shmidt	  NULL
3113c5ec7f57ead87efa365800228aa0b09a12d9e6c4Dmitry Shmidt	},
311404949598a23f501be6eec21697465fd46a28840aDmitry Shmidt	{ "VendorExtension", WPAS_DBUS_NEW_IFACE_P2P_PEER, "aay",
3115c5ec7f57ead87efa365800228aa0b09a12d9e6c4Dmitry Shmidt	  wpas_dbus_getter_p2p_peer_vendor_extension,
31161f69aa52ea2e0a73ac502565df8c666ee49cab6aDmitry Shmidt	  NULL
311775ecf5267604f166b85a7ee2cf0d9cb682966680Jouni Malinen	},
311875ecf5267604f166b85a7ee2cf0d9cb682966680Jouni Malinen	{ "IEs", WPAS_DBUS_NEW_IFACE_P2P_PEER, "ay",
31191f69aa52ea2e0a73ac502565df8c666ee49cab6aDmitry Shmidt	  wpas_dbus_getter_p2p_peer_ies,
31201f69aa52ea2e0a73ac502565df8c666ee49cab6aDmitry Shmidt	  NULL
312175ecf5267604f166b85a7ee2cf0d9cb682966680Jouni Malinen	},
31221f69aa52ea2e0a73ac502565df8c666ee49cab6aDmitry Shmidt	{ NULL, NULL, NULL, NULL, NULL }
312375ecf5267604f166b85a7ee2cf0d9cb682966680Jouni Malinen};
312475ecf5267604f166b85a7ee2cf0d9cb682966680Jouni Malinen
312575ecf5267604f166b85a7ee2cf0d9cb682966680Jouni Malinenstatic const struct wpa_dbus_signal_desc wpas_dbus_p2p_peer_signals[] = {
312675ecf5267604f166b85a7ee2cf0d9cb682966680Jouni Malinen
312775ecf5267604f166b85a7ee2cf0d9cb682966680Jouni Malinen	{ NULL, NULL, { END_ARGS } }
312875ecf5267604f166b85a7ee2cf0d9cb682966680Jouni Malinen};
312975ecf5267604f166b85a7ee2cf0d9cb682966680Jouni Malinen
313075ecf5267604f166b85a7ee2cf0d9cb682966680Jouni Malinen/**
313175ecf5267604f166b85a7ee2cf0d9cb682966680Jouni Malinen * wpas_dbus_signal_peer - Send a peer related event signal
313275ecf5267604f166b85a7ee2cf0d9cb682966680Jouni Malinen * @wpa_s: %wpa_supplicant network interface data
313375ecf5267604f166b85a7ee2cf0d9cb682966680Jouni Malinen * @dev: peer device object
313475ecf5267604f166b85a7ee2cf0d9cb682966680Jouni Malinen * @interface: name of the interface emitting this signal.
313575ecf5267604f166b85a7ee2cf0d9cb682966680Jouni Malinen *	In case of peer objects, it would be emitted by either
313675ecf5267604f166b85a7ee2cf0d9cb682966680Jouni Malinen *	the "interface object" or by "peer objects"
313775ecf5267604f166b85a7ee2cf0d9cb682966680Jouni Malinen * @sig_name: signal name - DeviceFound
313875ecf5267604f166b85a7ee2cf0d9cb682966680Jouni Malinen *
313975ecf5267604f166b85a7ee2cf0d9cb682966680Jouni Malinen * Notify listeners about event related with newly found p2p peer device
314075ecf5267604f166b85a7ee2cf0d9cb682966680Jouni Malinen */
314175ecf5267604f166b85a7ee2cf0d9cb682966680Jouni Malinenstatic void wpas_dbus_signal_peer(struct wpa_supplicant *wpa_s,
314275ecf5267604f166b85a7ee2cf0d9cb682966680Jouni Malinen				  const u8 *dev_addr, const char *interface,
314375ecf5267604f166b85a7ee2cf0d9cb682966680Jouni Malinen				  const char *sig_name)
314475ecf5267604f166b85a7ee2cf0d9cb682966680Jouni Malinen{
314575ecf5267604f166b85a7ee2cf0d9cb682966680Jouni Malinen	struct wpas_dbus_priv *iface;
314675ecf5267604f166b85a7ee2cf0d9cb682966680Jouni Malinen	DBusMessage *msg;
314775ecf5267604f166b85a7ee2cf0d9cb682966680Jouni Malinen	DBusMessageIter iter;
314875ecf5267604f166b85a7ee2cf0d9cb682966680Jouni Malinen	char peer_obj_path[WPAS_DBUS_OBJECT_PATH_MAX], *path;
314975ecf5267604f166b85a7ee2cf0d9cb682966680Jouni Malinen
315075ecf5267604f166b85a7ee2cf0d9cb682966680Jouni Malinen	iface = wpa_s->global->dbus;
315175ecf5267604f166b85a7ee2cf0d9cb682966680Jouni Malinen
315275ecf5267604f166b85a7ee2cf0d9cb682966680Jouni Malinen	/* Do nothing if the control interface is not turned on */
315375ecf5267604f166b85a7ee2cf0d9cb682966680Jouni Malinen	if (iface == NULL)
315475ecf5267604f166b85a7ee2cf0d9cb682966680Jouni Malinen		return;
315575ecf5267604f166b85a7ee2cf0d9cb682966680Jouni Malinen
315675ecf5267604f166b85a7ee2cf0d9cb682966680Jouni Malinen	os_snprintf(peer_obj_path, WPAS_DBUS_OBJECT_PATH_MAX,
315775ecf5267604f166b85a7ee2cf0d9cb682966680Jouni Malinen		    "%s/" WPAS_DBUS_NEW_P2P_PEERS_PART "/" COMPACT_MACSTR,
315875ecf5267604f166b85a7ee2cf0d9cb682966680Jouni Malinen		    wpa_s->dbus_new_path, MAC2STR(dev_addr));
315975ecf5267604f166b85a7ee2cf0d9cb682966680Jouni Malinen
316075ecf5267604f166b85a7ee2cf0d9cb682966680Jouni Malinen	msg = dbus_message_new_signal(wpa_s->dbus_new_path, interface,
316175ecf5267604f166b85a7ee2cf0d9cb682966680Jouni Malinen				      sig_name);
316275ecf5267604f166b85a7ee2cf0d9cb682966680Jouni Malinen	if (msg == NULL)
316375ecf5267604f166b85a7ee2cf0d9cb682966680Jouni Malinen		return;
316475ecf5267604f166b85a7ee2cf0d9cb682966680Jouni Malinen
316575ecf5267604f166b85a7ee2cf0d9cb682966680Jouni Malinen	dbus_message_iter_init_append(msg, &iter);
316675ecf5267604f166b85a7ee2cf0d9cb682966680Jouni Malinen	path = peer_obj_path;
316775ecf5267604f166b85a7ee2cf0d9cb682966680Jouni Malinen	if (!dbus_message_iter_append_basic(&iter, DBUS_TYPE_OBJECT_PATH,
316875ecf5267604f166b85a7ee2cf0d9cb682966680Jouni Malinen					    &path))
316975ecf5267604f166b85a7ee2cf0d9cb682966680Jouni Malinen		goto err;
317075ecf5267604f166b85a7ee2cf0d9cb682966680Jouni Malinen
317175ecf5267604f166b85a7ee2cf0d9cb682966680Jouni Malinen	dbus_connection_send(iface->con, msg, NULL);
317275ecf5267604f166b85a7ee2cf0d9cb682966680Jouni Malinen
317375ecf5267604f166b85a7ee2cf0d9cb682966680Jouni Malinen	dbus_message_unref(msg);
317475ecf5267604f166b85a7ee2cf0d9cb682966680Jouni Malinen	return;
317575ecf5267604f166b85a7ee2cf0d9cb682966680Jouni Malinen
317675ecf5267604f166b85a7ee2cf0d9cb682966680Jouni Malinenerr:
317775ecf5267604f166b85a7ee2cf0d9cb682966680Jouni Malinen	wpa_printf(MSG_ERROR, "dbus: Failed to construct signal");
317875ecf5267604f166b85a7ee2cf0d9cb682966680Jouni Malinen	dbus_message_unref(msg);
317975ecf5267604f166b85a7ee2cf0d9cb682966680Jouni Malinen}
318075ecf5267604f166b85a7ee2cf0d9cb682966680Jouni Malinen
318175ecf5267604f166b85a7ee2cf0d9cb682966680Jouni Malinen
318275ecf5267604f166b85a7ee2cf0d9cb682966680Jouni Malinen/**
318375ecf5267604f166b85a7ee2cf0d9cb682966680Jouni Malinen * wpas_dbus_signal_peer_found - Send a peer found signal
318475ecf5267604f166b85a7ee2cf0d9cb682966680Jouni Malinen * @wpa_s: %wpa_supplicant network interface data
318575ecf5267604f166b85a7ee2cf0d9cb682966680Jouni Malinen * @dev: peer device object
318675ecf5267604f166b85a7ee2cf0d9cb682966680Jouni Malinen *
318775ecf5267604f166b85a7ee2cf0d9cb682966680Jouni Malinen * Notify listeners about find a p2p peer device found
318875ecf5267604f166b85a7ee2cf0d9cb682966680Jouni Malinen */
318975ecf5267604f166b85a7ee2cf0d9cb682966680Jouni Malinenvoid wpas_dbus_signal_peer_device_found(struct wpa_supplicant *wpa_s,
319075ecf5267604f166b85a7ee2cf0d9cb682966680Jouni Malinen					const u8 *dev_addr)
319175ecf5267604f166b85a7ee2cf0d9cb682966680Jouni Malinen{
319275ecf5267604f166b85a7ee2cf0d9cb682966680Jouni Malinen	wpas_dbus_signal_peer(wpa_s, dev_addr,
319375ecf5267604f166b85a7ee2cf0d9cb682966680Jouni Malinen			      WPAS_DBUS_NEW_IFACE_P2PDEVICE,
319475ecf5267604f166b85a7ee2cf0d9cb682966680Jouni Malinen			      "DeviceFound");
319575ecf5267604f166b85a7ee2cf0d9cb682966680Jouni Malinen}
319675ecf5267604f166b85a7ee2cf0d9cb682966680Jouni Malinen
319775ecf5267604f166b85a7ee2cf0d9cb682966680Jouni Malinen/**
319875ecf5267604f166b85a7ee2cf0d9cb682966680Jouni Malinen * wpas_dbus_signal_peer_lost - Send a peer lost signal
319975ecf5267604f166b85a7ee2cf0d9cb682966680Jouni Malinen * @wpa_s: %wpa_supplicant network interface data
320075ecf5267604f166b85a7ee2cf0d9cb682966680Jouni Malinen * @dev: peer device object
320175ecf5267604f166b85a7ee2cf0d9cb682966680Jouni Malinen *
320275ecf5267604f166b85a7ee2cf0d9cb682966680Jouni Malinen * Notify listeners about lost a p2p peer device
320375ecf5267604f166b85a7ee2cf0d9cb682966680Jouni Malinen */
320475ecf5267604f166b85a7ee2cf0d9cb682966680Jouni Malinenvoid wpas_dbus_signal_peer_device_lost(struct wpa_supplicant *wpa_s,
320575ecf5267604f166b85a7ee2cf0d9cb682966680Jouni Malinen				       const u8 *dev_addr)
320675ecf5267604f166b85a7ee2cf0d9cb682966680Jouni Malinen{
320775ecf5267604f166b85a7ee2cf0d9cb682966680Jouni Malinen	wpas_dbus_signal_peer(wpa_s, dev_addr,
320875ecf5267604f166b85a7ee2cf0d9cb682966680Jouni Malinen			      WPAS_DBUS_NEW_IFACE_P2PDEVICE,
320975ecf5267604f166b85a7ee2cf0d9cb682966680Jouni Malinen			      "DeviceLost");
321075ecf5267604f166b85a7ee2cf0d9cb682966680Jouni Malinen}
321175ecf5267604f166b85a7ee2cf0d9cb682966680Jouni Malinen
321275ecf5267604f166b85a7ee2cf0d9cb682966680Jouni Malinen/**
321375ecf5267604f166b85a7ee2cf0d9cb682966680Jouni Malinen * wpas_dbus_register_peer - Register a discovered peer object with dbus
321475ecf5267604f166b85a7ee2cf0d9cb682966680Jouni Malinen * @wpa_s: wpa_supplicant interface structure
321575ecf5267604f166b85a7ee2cf0d9cb682966680Jouni Malinen * @ssid: network configuration data
321675ecf5267604f166b85a7ee2cf0d9cb682966680Jouni Malinen * Returns: 0 on success, -1 on failure
321775ecf5267604f166b85a7ee2cf0d9cb682966680Jouni Malinen *
321875ecf5267604f166b85a7ee2cf0d9cb682966680Jouni Malinen * Registers network representing object with dbus
321975ecf5267604f166b85a7ee2cf0d9cb682966680Jouni Malinen */
322075ecf5267604f166b85a7ee2cf0d9cb682966680Jouni Malinenint wpas_dbus_register_peer(struct wpa_supplicant *wpa_s, const u8 *dev_addr)
322175ecf5267604f166b85a7ee2cf0d9cb682966680Jouni Malinen{
322275ecf5267604f166b85a7ee2cf0d9cb682966680Jouni Malinen	struct wpas_dbus_priv *ctrl_iface;
322375ecf5267604f166b85a7ee2cf0d9cb682966680Jouni Malinen	struct wpa_dbus_object_desc *obj_desc;
322475ecf5267604f166b85a7ee2cf0d9cb682966680Jouni Malinen	struct peer_handler_args *arg;
322575ecf5267604f166b85a7ee2cf0d9cb682966680Jouni Malinen	char peer_obj_path[WPAS_DBUS_OBJECT_PATH_MAX];
322675ecf5267604f166b85a7ee2cf0d9cb682966680Jouni Malinen
322775ecf5267604f166b85a7ee2cf0d9cb682966680Jouni Malinen	/* Do nothing if the control interface is not turned on */
322875ecf5267604f166b85a7ee2cf0d9cb682966680Jouni Malinen	if (wpa_s == NULL || wpa_s->global == NULL)
322975ecf5267604f166b85a7ee2cf0d9cb682966680Jouni Malinen		return 0;
323075ecf5267604f166b85a7ee2cf0d9cb682966680Jouni Malinen
323175ecf5267604f166b85a7ee2cf0d9cb682966680Jouni Malinen	ctrl_iface = wpa_s->global->dbus;
323275ecf5267604f166b85a7ee2cf0d9cb682966680Jouni Malinen	if (ctrl_iface == NULL)
323375ecf5267604f166b85a7ee2cf0d9cb682966680Jouni Malinen		return 0;
323475ecf5267604f166b85a7ee2cf0d9cb682966680Jouni Malinen
323575ecf5267604f166b85a7ee2cf0d9cb682966680Jouni Malinen	os_snprintf(peer_obj_path, WPAS_DBUS_OBJECT_PATH_MAX,
323675ecf5267604f166b85a7ee2cf0d9cb682966680Jouni Malinen		    "%s/" WPAS_DBUS_NEW_P2P_PEERS_PART "/" COMPACT_MACSTR,
323775ecf5267604f166b85a7ee2cf0d9cb682966680Jouni Malinen		    wpa_s->dbus_new_path, MAC2STR(dev_addr));
323875ecf5267604f166b85a7ee2cf0d9cb682966680Jouni Malinen
323975ecf5267604f166b85a7ee2cf0d9cb682966680Jouni Malinen	wpa_printf(MSG_INFO, "dbus: Register peer object '%s'",
324075ecf5267604f166b85a7ee2cf0d9cb682966680Jouni Malinen		   peer_obj_path);
324175ecf5267604f166b85a7ee2cf0d9cb682966680Jouni Malinen	obj_desc = os_zalloc(sizeof(struct wpa_dbus_object_desc));
324275ecf5267604f166b85a7ee2cf0d9cb682966680Jouni Malinen	if (!obj_desc) {
324375ecf5267604f166b85a7ee2cf0d9cb682966680Jouni Malinen		wpa_printf(MSG_ERROR, "Not enough memory "
324475ecf5267604f166b85a7ee2cf0d9cb682966680Jouni Malinen			   "to create object description");
324575ecf5267604f166b85a7ee2cf0d9cb682966680Jouni Malinen		goto err;
324675ecf5267604f166b85a7ee2cf0d9cb682966680Jouni Malinen	}
324775ecf5267604f166b85a7ee2cf0d9cb682966680Jouni Malinen
324875ecf5267604f166b85a7ee2cf0d9cb682966680Jouni Malinen	/* allocate memory for handlers arguments */
324975ecf5267604f166b85a7ee2cf0d9cb682966680Jouni Malinen	arg = os_zalloc(sizeof(struct peer_handler_args));
325075ecf5267604f166b85a7ee2cf0d9cb682966680Jouni Malinen	if (!arg) {
325175ecf5267604f166b85a7ee2cf0d9cb682966680Jouni Malinen		wpa_printf(MSG_ERROR, "Not enough memory "
325275ecf5267604f166b85a7ee2cf0d9cb682966680Jouni Malinen			   "to create arguments for method");
325375ecf5267604f166b85a7ee2cf0d9cb682966680Jouni Malinen		goto err;
325475ecf5267604f166b85a7ee2cf0d9cb682966680Jouni Malinen	}
325575ecf5267604f166b85a7ee2cf0d9cb682966680Jouni Malinen
325675ecf5267604f166b85a7ee2cf0d9cb682966680Jouni Malinen	arg->wpa_s = wpa_s;
325775ecf5267604f166b85a7ee2cf0d9cb682966680Jouni Malinen	os_memcpy(arg->p2p_device_addr, dev_addr, ETH_ALEN);
325875ecf5267604f166b85a7ee2cf0d9cb682966680Jouni Malinen
325975ecf5267604f166b85a7ee2cf0d9cb682966680Jouni Malinen	wpas_dbus_register(obj_desc, arg, wpa_dbus_free,
326075ecf5267604f166b85a7ee2cf0d9cb682966680Jouni Malinen			   NULL,
326175ecf5267604f166b85a7ee2cf0d9cb682966680Jouni Malinen			   wpas_dbus_p2p_peer_properties,
326275ecf5267604f166b85a7ee2cf0d9cb682966680Jouni Malinen			   wpas_dbus_p2p_peer_signals);
326375ecf5267604f166b85a7ee2cf0d9cb682966680Jouni Malinen
326475ecf5267604f166b85a7ee2cf0d9cb682966680Jouni Malinen	if (wpa_dbus_register_object_per_iface(ctrl_iface, peer_obj_path,
326575ecf5267604f166b85a7ee2cf0d9cb682966680Jouni Malinen					       wpa_s->ifname, obj_desc))
326675ecf5267604f166b85a7ee2cf0d9cb682966680Jouni Malinen		goto err;
326775ecf5267604f166b85a7ee2cf0d9cb682966680Jouni Malinen
326875ecf5267604f166b85a7ee2cf0d9cb682966680Jouni Malinen	return 0;
326975ecf5267604f166b85a7ee2cf0d9cb682966680Jouni Malinen
327075ecf5267604f166b85a7ee2cf0d9cb682966680Jouni Malinenerr:
327175ecf5267604f166b85a7ee2cf0d9cb682966680Jouni Malinen	free_dbus_object_desc(obj_desc);
327275ecf5267604f166b85a7ee2cf0d9cb682966680Jouni Malinen	return -1;
327375ecf5267604f166b85a7ee2cf0d9cb682966680Jouni Malinen}
327475ecf5267604f166b85a7ee2cf0d9cb682966680Jouni Malinen
327575ecf5267604f166b85a7ee2cf0d9cb682966680Jouni Malinen/**
327675ecf5267604f166b85a7ee2cf0d9cb682966680Jouni Malinen * wpas_dbus_unregister_peer - Unregister a peer object with dbus
327775ecf5267604f166b85a7ee2cf0d9cb682966680Jouni Malinen * @wpa_s: wpa_supplicant interface structure
327875ecf5267604f166b85a7ee2cf0d9cb682966680Jouni Malinen * @dev_addr: p2p device addr
327975ecf5267604f166b85a7ee2cf0d9cb682966680Jouni Malinen * Returns: 0 on success, -1 on failure
328075ecf5267604f166b85a7ee2cf0d9cb682966680Jouni Malinen *
328175ecf5267604f166b85a7ee2cf0d9cb682966680Jouni Malinen * Registers network representing object with dbus
328275ecf5267604f166b85a7ee2cf0d9cb682966680Jouni Malinen */
328375ecf5267604f166b85a7ee2cf0d9cb682966680Jouni Malinenint wpas_dbus_unregister_peer(struct wpa_supplicant *wpa_s,
328475ecf5267604f166b85a7ee2cf0d9cb682966680Jouni Malinen				  const u8 *dev_addr)
328575ecf5267604f166b85a7ee2cf0d9cb682966680Jouni Malinen{
328675ecf5267604f166b85a7ee2cf0d9cb682966680Jouni Malinen	struct wpas_dbus_priv *ctrl_iface;
328775ecf5267604f166b85a7ee2cf0d9cb682966680Jouni Malinen	char peer_obj_path[WPAS_DBUS_OBJECT_PATH_MAX];
328875ecf5267604f166b85a7ee2cf0d9cb682966680Jouni Malinen	int ret;
328975ecf5267604f166b85a7ee2cf0d9cb682966680Jouni Malinen
329075ecf5267604f166b85a7ee2cf0d9cb682966680Jouni Malinen	/* Do nothing if the control interface is not turned on */
329175ecf5267604f166b85a7ee2cf0d9cb682966680Jouni Malinen	if (wpa_s == NULL || wpa_s->global == NULL ||
329275ecf5267604f166b85a7ee2cf0d9cb682966680Jouni Malinen	    wpa_s->dbus_new_path == NULL)
329375ecf5267604f166b85a7ee2cf0d9cb682966680Jouni Malinen		return 0;
329475ecf5267604f166b85a7ee2cf0d9cb682966680Jouni Malinen	ctrl_iface = wpa_s->global->dbus;
329575ecf5267604f166b85a7ee2cf0d9cb682966680Jouni Malinen	if (ctrl_iface == NULL)
329675ecf5267604f166b85a7ee2cf0d9cb682966680Jouni Malinen		return 0;
329775ecf5267604f166b85a7ee2cf0d9cb682966680Jouni Malinen
329875ecf5267604f166b85a7ee2cf0d9cb682966680Jouni Malinen	os_snprintf(peer_obj_path, WPAS_DBUS_OBJECT_PATH_MAX,
329975ecf5267604f166b85a7ee2cf0d9cb682966680Jouni Malinen		    "%s/" WPAS_DBUS_NEW_P2P_PEERS_PART "/" COMPACT_MACSTR,
330075ecf5267604f166b85a7ee2cf0d9cb682966680Jouni Malinen		    wpa_s->dbus_new_path, MAC2STR(dev_addr));
330175ecf5267604f166b85a7ee2cf0d9cb682966680Jouni Malinen
330275ecf5267604f166b85a7ee2cf0d9cb682966680Jouni Malinen	wpa_printf(MSG_INFO, "dbus: Unregister peer object '%s'",
330375ecf5267604f166b85a7ee2cf0d9cb682966680Jouni Malinen		   peer_obj_path);
330475ecf5267604f166b85a7ee2cf0d9cb682966680Jouni Malinen	ret = wpa_dbus_unregister_object_per_iface(ctrl_iface, peer_obj_path);
330575ecf5267604f166b85a7ee2cf0d9cb682966680Jouni Malinen
330675ecf5267604f166b85a7ee2cf0d9cb682966680Jouni Malinen	return ret;
330775ecf5267604f166b85a7ee2cf0d9cb682966680Jouni Malinen}
330875ecf5267604f166b85a7ee2cf0d9cb682966680Jouni Malinen
330975ecf5267604f166b85a7ee2cf0d9cb682966680Jouni Malinen
331075ecf5267604f166b85a7ee2cf0d9cb682966680Jouni Malinenstatic const struct wpa_dbus_property_desc wpas_dbus_p2p_group_properties[] = {
331175ecf5267604f166b85a7ee2cf0d9cb682966680Jouni Malinen	{ "Members", WPAS_DBUS_NEW_IFACE_P2P_GROUP, "ao",
33121f69aa52ea2e0a73ac502565df8c666ee49cab6aDmitry Shmidt	  wpas_dbus_getter_p2p_group_members,
33131f69aa52ea2e0a73ac502565df8c666ee49cab6aDmitry Shmidt	  NULL
331475ecf5267604f166b85a7ee2cf0d9cb682966680Jouni Malinen	},
331504949598a23f501be6eec21697465fd46a28840aDmitry Shmidt	{ "Group", WPAS_DBUS_NEW_IFACE_P2P_GROUP, "o",
331604949598a23f501be6eec21697465fd46a28840aDmitry Shmidt	  wpas_dbus_getter_p2p_group,
331704949598a23f501be6eec21697465fd46a28840aDmitry Shmidt	  NULL
331804949598a23f501be6eec21697465fd46a28840aDmitry Shmidt	},
331904949598a23f501be6eec21697465fd46a28840aDmitry Shmidt	{ "Role", WPAS_DBUS_NEW_IFACE_P2P_GROUP, "s",
332004949598a23f501be6eec21697465fd46a28840aDmitry Shmidt	  wpas_dbus_getter_p2p_role,
332104949598a23f501be6eec21697465fd46a28840aDmitry Shmidt	  NULL
332204949598a23f501be6eec21697465fd46a28840aDmitry Shmidt	},
332304949598a23f501be6eec21697465fd46a28840aDmitry Shmidt	{ "SSID", WPAS_DBUS_NEW_IFACE_P2P_GROUP, "ay",
332404949598a23f501be6eec21697465fd46a28840aDmitry Shmidt	  wpas_dbus_getter_p2p_group_ssid,
332504949598a23f501be6eec21697465fd46a28840aDmitry Shmidt	  NULL
332604949598a23f501be6eec21697465fd46a28840aDmitry Shmidt	},
332704949598a23f501be6eec21697465fd46a28840aDmitry Shmidt	{ "BSSID", WPAS_DBUS_NEW_IFACE_P2P_GROUP, "ay",
332804949598a23f501be6eec21697465fd46a28840aDmitry Shmidt	  wpas_dbus_getter_p2p_group_bssid,
332904949598a23f501be6eec21697465fd46a28840aDmitry Shmidt	  NULL
333004949598a23f501be6eec21697465fd46a28840aDmitry Shmidt	},
333104949598a23f501be6eec21697465fd46a28840aDmitry Shmidt	{ "Frequency", WPAS_DBUS_NEW_IFACE_P2P_GROUP, "q",
333204949598a23f501be6eec21697465fd46a28840aDmitry Shmidt	  wpas_dbus_getter_p2p_group_frequency,
333304949598a23f501be6eec21697465fd46a28840aDmitry Shmidt	  NULL
333404949598a23f501be6eec21697465fd46a28840aDmitry Shmidt	},
333504949598a23f501be6eec21697465fd46a28840aDmitry Shmidt	{ "Passphrase", WPAS_DBUS_NEW_IFACE_P2P_GROUP, "s",
333604949598a23f501be6eec21697465fd46a28840aDmitry Shmidt	  wpas_dbus_getter_p2p_group_passphrase,
333704949598a23f501be6eec21697465fd46a28840aDmitry Shmidt	  NULL
333804949598a23f501be6eec21697465fd46a28840aDmitry Shmidt	},
333904949598a23f501be6eec21697465fd46a28840aDmitry Shmidt	{ "PSK", WPAS_DBUS_NEW_IFACE_P2P_GROUP, "ay",
334004949598a23f501be6eec21697465fd46a28840aDmitry Shmidt	  wpas_dbus_getter_p2p_group_psk,
334104949598a23f501be6eec21697465fd46a28840aDmitry Shmidt	  NULL
334204949598a23f501be6eec21697465fd46a28840aDmitry Shmidt	},
334304949598a23f501be6eec21697465fd46a28840aDmitry Shmidt	{ "WPSVendorExtensions", WPAS_DBUS_NEW_IFACE_P2P_GROUP, "aay",
334404949598a23f501be6eec21697465fd46a28840aDmitry Shmidt	  wpas_dbus_getter_p2p_group_vendor_ext,
334504949598a23f501be6eec21697465fd46a28840aDmitry Shmidt	  wpas_dbus_setter_p2p_group_vendor_ext
33468d520ff1dc2da35cdca849e982051b86468016d8Dmitry Shmidt	},
33471f69aa52ea2e0a73ac502565df8c666ee49cab6aDmitry Shmidt	{ NULL, NULL, NULL, NULL, NULL }
334875ecf5267604f166b85a7ee2cf0d9cb682966680Jouni Malinen};
334975ecf5267604f166b85a7ee2cf0d9cb682966680Jouni Malinen
335075ecf5267604f166b85a7ee2cf0d9cb682966680Jouni Malinenstatic const struct wpa_dbus_signal_desc wpas_dbus_p2p_group_signals[] = {
335175ecf5267604f166b85a7ee2cf0d9cb682966680Jouni Malinen	{ "PeerJoined", WPAS_DBUS_NEW_IFACE_P2P_GROUP,
33528d520ff1dc2da35cdca849e982051b86468016d8Dmitry Shmidt	  {
335375ecf5267604f166b85a7ee2cf0d9cb682966680Jouni Malinen		  { "peer", "o", ARG_OUT },
33548d520ff1dc2da35cdca849e982051b86468016d8Dmitry Shmidt		  END_ARGS
33558d520ff1dc2da35cdca849e982051b86468016d8Dmitry Shmidt	  }
33568d520ff1dc2da35cdca849e982051b86468016d8Dmitry Shmidt	},
335775ecf5267604f166b85a7ee2cf0d9cb682966680Jouni Malinen	{ "PeerDisconnected", WPAS_DBUS_NEW_IFACE_P2P_GROUP,
33588d520ff1dc2da35cdca849e982051b86468016d8Dmitry Shmidt	  {
335975ecf5267604f166b85a7ee2cf0d9cb682966680Jouni Malinen		  { "peer", "o", ARG_OUT },
33608d520ff1dc2da35cdca849e982051b86468016d8Dmitry Shmidt		  END_ARGS
33618d520ff1dc2da35cdca849e982051b86468016d8Dmitry Shmidt	  }
33628d520ff1dc2da35cdca849e982051b86468016d8Dmitry Shmidt	},
33638d520ff1dc2da35cdca849e982051b86468016d8Dmitry Shmidt	{ NULL, NULL, { END_ARGS } }
33648d520ff1dc2da35cdca849e982051b86468016d8Dmitry Shmidt};
33658d520ff1dc2da35cdca849e982051b86468016d8Dmitry Shmidt
336675ecf5267604f166b85a7ee2cf0d9cb682966680Jouni Malinen/**
336775ecf5267604f166b85a7ee2cf0d9cb682966680Jouni Malinen * wpas_dbus_register_p2p_group - Register a p2p group object with dbus
336875ecf5267604f166b85a7ee2cf0d9cb682966680Jouni Malinen * @wpa_s: wpa_supplicant interface structure
336975ecf5267604f166b85a7ee2cf0d9cb682966680Jouni Malinen * @ssid: SSID struct
337075ecf5267604f166b85a7ee2cf0d9cb682966680Jouni Malinen * Returns: 0 on success, -1 on failure
337175ecf5267604f166b85a7ee2cf0d9cb682966680Jouni Malinen *
337275ecf5267604f166b85a7ee2cf0d9cb682966680Jouni Malinen * Registers p2p group representing object with dbus
337375ecf5267604f166b85a7ee2cf0d9cb682966680Jouni Malinen */
337475ecf5267604f166b85a7ee2cf0d9cb682966680Jouni Malinenvoid wpas_dbus_register_p2p_group(struct wpa_supplicant *wpa_s,
337575ecf5267604f166b85a7ee2cf0d9cb682966680Jouni Malinen				  struct wpa_ssid *ssid)
337675ecf5267604f166b85a7ee2cf0d9cb682966680Jouni Malinen{
337775ecf5267604f166b85a7ee2cf0d9cb682966680Jouni Malinen	struct wpas_dbus_priv *ctrl_iface;
337875ecf5267604f166b85a7ee2cf0d9cb682966680Jouni Malinen	struct wpa_dbus_object_desc *obj_desc;
337975ecf5267604f166b85a7ee2cf0d9cb682966680Jouni Malinen	char group_obj_path[WPAS_DBUS_OBJECT_PATH_MAX];
338075ecf5267604f166b85a7ee2cf0d9cb682966680Jouni Malinen
338175ecf5267604f166b85a7ee2cf0d9cb682966680Jouni Malinen	/* Do nothing if the control interface is not turned on */
338275ecf5267604f166b85a7ee2cf0d9cb682966680Jouni Malinen	if (wpa_s == NULL || wpa_s->global == NULL)
338375ecf5267604f166b85a7ee2cf0d9cb682966680Jouni Malinen		return;
33848d520ff1dc2da35cdca849e982051b86468016d8Dmitry Shmidt
338575ecf5267604f166b85a7ee2cf0d9cb682966680Jouni Malinen	ctrl_iface = wpa_s->global->dbus;
338675ecf5267604f166b85a7ee2cf0d9cb682966680Jouni Malinen	if (ctrl_iface == NULL)
338775ecf5267604f166b85a7ee2cf0d9cb682966680Jouni Malinen		return;
338875ecf5267604f166b85a7ee2cf0d9cb682966680Jouni Malinen
338975ecf5267604f166b85a7ee2cf0d9cb682966680Jouni Malinen	if (wpa_s->dbus_groupobj_path) {
339075ecf5267604f166b85a7ee2cf0d9cb682966680Jouni Malinen		wpa_printf(MSG_INFO, "%s: Group object '%s' already exists",
339175ecf5267604f166b85a7ee2cf0d9cb682966680Jouni Malinen			   __func__, wpa_s->dbus_groupobj_path);
339275ecf5267604f166b85a7ee2cf0d9cb682966680Jouni Malinen		return;
339375ecf5267604f166b85a7ee2cf0d9cb682966680Jouni Malinen	}
339475ecf5267604f166b85a7ee2cf0d9cb682966680Jouni Malinen
339575ecf5267604f166b85a7ee2cf0d9cb682966680Jouni Malinen	if (wpas_dbus_get_group_obj_path(wpa_s, ssid, group_obj_path) < 0)
339675ecf5267604f166b85a7ee2cf0d9cb682966680Jouni Malinen		return;
339775ecf5267604f166b85a7ee2cf0d9cb682966680Jouni Malinen
339875ecf5267604f166b85a7ee2cf0d9cb682966680Jouni Malinen	wpa_s->dbus_groupobj_path = os_strdup(group_obj_path);
339975ecf5267604f166b85a7ee2cf0d9cb682966680Jouni Malinen	if (wpa_s->dbus_groupobj_path == NULL)
340075ecf5267604f166b85a7ee2cf0d9cb682966680Jouni Malinen		return;
340175ecf5267604f166b85a7ee2cf0d9cb682966680Jouni Malinen
340275ecf5267604f166b85a7ee2cf0d9cb682966680Jouni Malinen	wpa_printf(MSG_INFO, "dbus: Register group object '%s'",
340375ecf5267604f166b85a7ee2cf0d9cb682966680Jouni Malinen		   group_obj_path);
340475ecf5267604f166b85a7ee2cf0d9cb682966680Jouni Malinen	obj_desc = os_zalloc(sizeof(struct wpa_dbus_object_desc));
340575ecf5267604f166b85a7ee2cf0d9cb682966680Jouni Malinen	if (!obj_desc) {
340675ecf5267604f166b85a7ee2cf0d9cb682966680Jouni Malinen		wpa_printf(MSG_ERROR, "Not enough memory "
340775ecf5267604f166b85a7ee2cf0d9cb682966680Jouni Malinen			   "to create object description");
340875ecf5267604f166b85a7ee2cf0d9cb682966680Jouni Malinen		goto err;
340975ecf5267604f166b85a7ee2cf0d9cb682966680Jouni Malinen	}
341075ecf5267604f166b85a7ee2cf0d9cb682966680Jouni Malinen
341175ecf5267604f166b85a7ee2cf0d9cb682966680Jouni Malinen	wpas_dbus_register(obj_desc, wpa_s, NULL, NULL,
341275ecf5267604f166b85a7ee2cf0d9cb682966680Jouni Malinen			   wpas_dbus_p2p_group_properties,
341375ecf5267604f166b85a7ee2cf0d9cb682966680Jouni Malinen			   wpas_dbus_p2p_group_signals);
341475ecf5267604f166b85a7ee2cf0d9cb682966680Jouni Malinen
341575ecf5267604f166b85a7ee2cf0d9cb682966680Jouni Malinen	if (wpa_dbus_register_object_per_iface(ctrl_iface, group_obj_path,
341675ecf5267604f166b85a7ee2cf0d9cb682966680Jouni Malinen					       wpa_s->ifname, obj_desc))
341775ecf5267604f166b85a7ee2cf0d9cb682966680Jouni Malinen		goto err;
341875ecf5267604f166b85a7ee2cf0d9cb682966680Jouni Malinen
341975ecf5267604f166b85a7ee2cf0d9cb682966680Jouni Malinen	return;
342075ecf5267604f166b85a7ee2cf0d9cb682966680Jouni Malinen
342175ecf5267604f166b85a7ee2cf0d9cb682966680Jouni Malinenerr:
342275ecf5267604f166b85a7ee2cf0d9cb682966680Jouni Malinen	if (wpa_s->dbus_groupobj_path) {
342375ecf5267604f166b85a7ee2cf0d9cb682966680Jouni Malinen		os_free(wpa_s->dbus_groupobj_path);
342475ecf5267604f166b85a7ee2cf0d9cb682966680Jouni Malinen		wpa_s->dbus_groupobj_path = NULL;
342575ecf5267604f166b85a7ee2cf0d9cb682966680Jouni Malinen	}
342675ecf5267604f166b85a7ee2cf0d9cb682966680Jouni Malinen
342775ecf5267604f166b85a7ee2cf0d9cb682966680Jouni Malinen	free_dbus_object_desc(obj_desc);
342875ecf5267604f166b85a7ee2cf0d9cb682966680Jouni Malinen}
342975ecf5267604f166b85a7ee2cf0d9cb682966680Jouni Malinen
343075ecf5267604f166b85a7ee2cf0d9cb682966680Jouni Malinen/**
343175ecf5267604f166b85a7ee2cf0d9cb682966680Jouni Malinen * wpas_dbus_unregister_p2p_group - Unregister a p2p group object from dbus
343275ecf5267604f166b85a7ee2cf0d9cb682966680Jouni Malinen * @wpa_s: wpa_supplicant interface structure
343375ecf5267604f166b85a7ee2cf0d9cb682966680Jouni Malinen * @ssid: network name of the p2p group started
343475ecf5267604f166b85a7ee2cf0d9cb682966680Jouni Malinen */
343575ecf5267604f166b85a7ee2cf0d9cb682966680Jouni Malinenvoid wpas_dbus_unregister_p2p_group(struct wpa_supplicant *wpa_s,
343675ecf5267604f166b85a7ee2cf0d9cb682966680Jouni Malinen				    const struct wpa_ssid *ssid)
34378d520ff1dc2da35cdca849e982051b86468016d8Dmitry Shmidt{
343875ecf5267604f166b85a7ee2cf0d9cb682966680Jouni Malinen	struct wpas_dbus_priv *ctrl_iface;
343975ecf5267604f166b85a7ee2cf0d9cb682966680Jouni Malinen
344075ecf5267604f166b85a7ee2cf0d9cb682966680Jouni Malinen	/* Do nothing if the control interface is not turned on */
344175ecf5267604f166b85a7ee2cf0d9cb682966680Jouni Malinen	if (wpa_s == NULL || wpa_s->global == NULL)
344275ecf5267604f166b85a7ee2cf0d9cb682966680Jouni Malinen		return;
344375ecf5267604f166b85a7ee2cf0d9cb682966680Jouni Malinen
344475ecf5267604f166b85a7ee2cf0d9cb682966680Jouni Malinen	ctrl_iface = wpa_s->global->dbus;
344575ecf5267604f166b85a7ee2cf0d9cb682966680Jouni Malinen	if (ctrl_iface == NULL)
344675ecf5267604f166b85a7ee2cf0d9cb682966680Jouni Malinen		return;
344775ecf5267604f166b85a7ee2cf0d9cb682966680Jouni Malinen
344875ecf5267604f166b85a7ee2cf0d9cb682966680Jouni Malinen	if (!wpa_s->dbus_groupobj_path) {
344975ecf5267604f166b85a7ee2cf0d9cb682966680Jouni Malinen		wpa_printf(MSG_DEBUG,
345075ecf5267604f166b85a7ee2cf0d9cb682966680Jouni Malinen			   "%s: Group object '%s' already unregistered",
345175ecf5267604f166b85a7ee2cf0d9cb682966680Jouni Malinen			   __func__, wpa_s->dbus_groupobj_path);
345275ecf5267604f166b85a7ee2cf0d9cb682966680Jouni Malinen		return;
345375ecf5267604f166b85a7ee2cf0d9cb682966680Jouni Malinen	}
345475ecf5267604f166b85a7ee2cf0d9cb682966680Jouni Malinen
345575ecf5267604f166b85a7ee2cf0d9cb682966680Jouni Malinen	wpa_printf(MSG_DEBUG, "dbus: Unregister group object '%s'",
345675ecf5267604f166b85a7ee2cf0d9cb682966680Jouni Malinen		   wpa_s->dbus_groupobj_path);
345775ecf5267604f166b85a7ee2cf0d9cb682966680Jouni Malinen
345875ecf5267604f166b85a7ee2cf0d9cb682966680Jouni Malinen	wpa_dbus_unregister_object_per_iface(ctrl_iface,
345975ecf5267604f166b85a7ee2cf0d9cb682966680Jouni Malinen					     wpa_s->dbus_groupobj_path);
346075ecf5267604f166b85a7ee2cf0d9cb682966680Jouni Malinen
346175ecf5267604f166b85a7ee2cf0d9cb682966680Jouni Malinen	os_free(wpa_s->dbus_groupobj_path);
346275ecf5267604f166b85a7ee2cf0d9cb682966680Jouni Malinen	wpa_s->dbus_groupobj_path = NULL;
346375ecf5267604f166b85a7ee2cf0d9cb682966680Jouni Malinen}
346475ecf5267604f166b85a7ee2cf0d9cb682966680Jouni Malinen
346575ecf5267604f166b85a7ee2cf0d9cb682966680Jouni Malinenstatic const struct wpa_dbus_property_desc
346675ecf5267604f166b85a7ee2cf0d9cb682966680Jouni Malinenwpas_dbus_p2p_groupmember_properties[] = {
34671f69aa52ea2e0a73ac502565df8c666ee49cab6aDmitry Shmidt	{ NULL, NULL, NULL, NULL, NULL }
346875ecf5267604f166b85a7ee2cf0d9cb682966680Jouni Malinen};
34698d520ff1dc2da35cdca849e982051b86468016d8Dmitry Shmidt
347075ecf5267604f166b85a7ee2cf0d9cb682966680Jouni Malinen/**
347175ecf5267604f166b85a7ee2cf0d9cb682966680Jouni Malinen * wpas_dbus_register_p2p_groupmember - Register a p2p groupmember
347275ecf5267604f166b85a7ee2cf0d9cb682966680Jouni Malinen * object with dbus
347375ecf5267604f166b85a7ee2cf0d9cb682966680Jouni Malinen * @wpa_s: wpa_supplicant interface structure
347475ecf5267604f166b85a7ee2cf0d9cb682966680Jouni Malinen * @p2p_if_addr: i/f addr of the device joining this group
347575ecf5267604f166b85a7ee2cf0d9cb682966680Jouni Malinen *
347675ecf5267604f166b85a7ee2cf0d9cb682966680Jouni Malinen * Registers p2p groupmember representing object with dbus
347775ecf5267604f166b85a7ee2cf0d9cb682966680Jouni Malinen */
347875ecf5267604f166b85a7ee2cf0d9cb682966680Jouni Malinenvoid wpas_dbus_register_p2p_groupmember(struct wpa_supplicant *wpa_s,
347975ecf5267604f166b85a7ee2cf0d9cb682966680Jouni Malinen					const u8 *p2p_if_addr)
348075ecf5267604f166b85a7ee2cf0d9cb682966680Jouni Malinen{
348175ecf5267604f166b85a7ee2cf0d9cb682966680Jouni Malinen	struct wpas_dbus_priv *ctrl_iface;
34828d520ff1dc2da35cdca849e982051b86468016d8Dmitry Shmidt	struct wpa_dbus_object_desc *obj_desc = NULL;
348375ecf5267604f166b85a7ee2cf0d9cb682966680Jouni Malinen	struct groupmember_handler_args *arg;
348475ecf5267604f166b85a7ee2cf0d9cb682966680Jouni Malinen	char groupmember_obj_path[WPAS_DBUS_OBJECT_PATH_MAX];
34858d520ff1dc2da35cdca849e982051b86468016d8Dmitry Shmidt
34868d520ff1dc2da35cdca849e982051b86468016d8Dmitry Shmidt	/* Do nothing if the control interface is not turned on */
348775ecf5267604f166b85a7ee2cf0d9cb682966680Jouni Malinen	if (wpa_s == NULL || wpa_s->global == NULL)
348875ecf5267604f166b85a7ee2cf0d9cb682966680Jouni Malinen		return;
348975ecf5267604f166b85a7ee2cf0d9cb682966680Jouni Malinen
349075ecf5267604f166b85a7ee2cf0d9cb682966680Jouni Malinen	ctrl_iface = wpa_s->global->dbus;
34918d520ff1dc2da35cdca849e982051b86468016d8Dmitry Shmidt	if (ctrl_iface == NULL)
349275ecf5267604f166b85a7ee2cf0d9cb682966680Jouni Malinen		return;
34938d520ff1dc2da35cdca849e982051b86468016d8Dmitry Shmidt
349475ecf5267604f166b85a7ee2cf0d9cb682966680Jouni Malinen	if (!wpa_s->dbus_groupobj_path)
349575ecf5267604f166b85a7ee2cf0d9cb682966680Jouni Malinen		return;
349675ecf5267604f166b85a7ee2cf0d9cb682966680Jouni Malinen
349775ecf5267604f166b85a7ee2cf0d9cb682966680Jouni Malinen	os_snprintf(groupmember_obj_path, WPAS_DBUS_OBJECT_PATH_MAX,
349875ecf5267604f166b85a7ee2cf0d9cb682966680Jouni Malinen		"%s/" WPAS_DBUS_NEW_P2P_GROUPMEMBERS_PART "/" COMPACT_MACSTR,
349975ecf5267604f166b85a7ee2cf0d9cb682966680Jouni Malinen		wpa_s->dbus_groupobj_path, MAC2STR(p2p_if_addr));
35008d520ff1dc2da35cdca849e982051b86468016d8Dmitry Shmidt
35018d520ff1dc2da35cdca849e982051b86468016d8Dmitry Shmidt	obj_desc = os_zalloc(sizeof(struct wpa_dbus_object_desc));
35028d520ff1dc2da35cdca849e982051b86468016d8Dmitry Shmidt	if (!obj_desc) {
35038d520ff1dc2da35cdca849e982051b86468016d8Dmitry Shmidt		wpa_printf(MSG_ERROR, "Not enough memory "
35048d520ff1dc2da35cdca849e982051b86468016d8Dmitry Shmidt			   "to create object description");
35058d520ff1dc2da35cdca849e982051b86468016d8Dmitry Shmidt		goto err;
35068d520ff1dc2da35cdca849e982051b86468016d8Dmitry Shmidt	}
35078d520ff1dc2da35cdca849e982051b86468016d8Dmitry Shmidt
350875ecf5267604f166b85a7ee2cf0d9cb682966680Jouni Malinen	/* allocate memory for handlers arguments */
350975ecf5267604f166b85a7ee2cf0d9cb682966680Jouni Malinen	arg = os_zalloc(sizeof(struct groupmember_handler_args));
351075ecf5267604f166b85a7ee2cf0d9cb682966680Jouni Malinen	if (!arg) {
351175ecf5267604f166b85a7ee2cf0d9cb682966680Jouni Malinen		wpa_printf(MSG_ERROR, "Not enough memory "
351275ecf5267604f166b85a7ee2cf0d9cb682966680Jouni Malinen			   "to create arguments for method");
351375ecf5267604f166b85a7ee2cf0d9cb682966680Jouni Malinen		goto err;
351475ecf5267604f166b85a7ee2cf0d9cb682966680Jouni Malinen	}
35158d520ff1dc2da35cdca849e982051b86468016d8Dmitry Shmidt
351675ecf5267604f166b85a7ee2cf0d9cb682966680Jouni Malinen	arg->wpa_s = wpa_s;
351775ecf5267604f166b85a7ee2cf0d9cb682966680Jouni Malinen	os_memcpy(arg->member_addr, p2p_if_addr, ETH_ALEN);
351875ecf5267604f166b85a7ee2cf0d9cb682966680Jouni Malinen
351975ecf5267604f166b85a7ee2cf0d9cb682966680Jouni Malinen	wpas_dbus_register(obj_desc, arg, wpa_dbus_free, NULL,
352075ecf5267604f166b85a7ee2cf0d9cb682966680Jouni Malinen			   wpas_dbus_p2p_groupmember_properties, NULL);
352175ecf5267604f166b85a7ee2cf0d9cb682966680Jouni Malinen
352275ecf5267604f166b85a7ee2cf0d9cb682966680Jouni Malinen	if (wpa_dbus_register_object_per_iface(ctrl_iface, groupmember_obj_path,
35238d520ff1dc2da35cdca849e982051b86468016d8Dmitry Shmidt					       wpa_s->ifname, obj_desc))
35248d520ff1dc2da35cdca849e982051b86468016d8Dmitry Shmidt		goto err;
35258d520ff1dc2da35cdca849e982051b86468016d8Dmitry Shmidt
352675ecf5267604f166b85a7ee2cf0d9cb682966680Jouni Malinen	wpa_printf(MSG_INFO,
352775ecf5267604f166b85a7ee2cf0d9cb682966680Jouni Malinen		   "dbus: Registered group member object '%s' successfully",
352875ecf5267604f166b85a7ee2cf0d9cb682966680Jouni Malinen		   groupmember_obj_path);
352975ecf5267604f166b85a7ee2cf0d9cb682966680Jouni Malinen	return;
353075ecf5267604f166b85a7ee2cf0d9cb682966680Jouni Malinen
353175ecf5267604f166b85a7ee2cf0d9cb682966680Jouni Malinenerr:
353275ecf5267604f166b85a7ee2cf0d9cb682966680Jouni Malinen	free_dbus_object_desc(obj_desc);
353375ecf5267604f166b85a7ee2cf0d9cb682966680Jouni Malinen}
353475ecf5267604f166b85a7ee2cf0d9cb682966680Jouni Malinen
353575ecf5267604f166b85a7ee2cf0d9cb682966680Jouni Malinen/**
353675ecf5267604f166b85a7ee2cf0d9cb682966680Jouni Malinen * wpas_dbus_unregister_p2p_groupmember - Unregister a p2p groupmember
353775ecf5267604f166b85a7ee2cf0d9cb682966680Jouni Malinen * object with dbus
353875ecf5267604f166b85a7ee2cf0d9cb682966680Jouni Malinen * @wpa_s: wpa_supplicant interface structure
353975ecf5267604f166b85a7ee2cf0d9cb682966680Jouni Malinen * @p2p_if_addr: i/f addr of the device joining this group
354075ecf5267604f166b85a7ee2cf0d9cb682966680Jouni Malinen *
354175ecf5267604f166b85a7ee2cf0d9cb682966680Jouni Malinen * Unregisters p2p groupmember representing object with dbus
354275ecf5267604f166b85a7ee2cf0d9cb682966680Jouni Malinen */
354375ecf5267604f166b85a7ee2cf0d9cb682966680Jouni Malinenvoid wpas_dbus_unregister_p2p_groupmember(struct wpa_supplicant *wpa_s,
354475ecf5267604f166b85a7ee2cf0d9cb682966680Jouni Malinen					  const u8 *p2p_if_addr)
354575ecf5267604f166b85a7ee2cf0d9cb682966680Jouni Malinen{
354675ecf5267604f166b85a7ee2cf0d9cb682966680Jouni Malinen	struct wpas_dbus_priv *ctrl_iface;
354775ecf5267604f166b85a7ee2cf0d9cb682966680Jouni Malinen	char groupmember_obj_path[WPAS_DBUS_OBJECT_PATH_MAX];
354875ecf5267604f166b85a7ee2cf0d9cb682966680Jouni Malinen
354975ecf5267604f166b85a7ee2cf0d9cb682966680Jouni Malinen	/* Do nothing if the control interface is not turned on */
355075ecf5267604f166b85a7ee2cf0d9cb682966680Jouni Malinen	if (wpa_s == NULL || wpa_s->global == NULL)
355175ecf5267604f166b85a7ee2cf0d9cb682966680Jouni Malinen		return;
355275ecf5267604f166b85a7ee2cf0d9cb682966680Jouni Malinen
355375ecf5267604f166b85a7ee2cf0d9cb682966680Jouni Malinen	ctrl_iface = wpa_s->global->dbus;
355475ecf5267604f166b85a7ee2cf0d9cb682966680Jouni Malinen	if (ctrl_iface == NULL)
355575ecf5267604f166b85a7ee2cf0d9cb682966680Jouni Malinen		return;
355675ecf5267604f166b85a7ee2cf0d9cb682966680Jouni Malinen
355775ecf5267604f166b85a7ee2cf0d9cb682966680Jouni Malinen	if (!wpa_s->dbus_groupobj_path)
355875ecf5267604f166b85a7ee2cf0d9cb682966680Jouni Malinen		return;
355975ecf5267604f166b85a7ee2cf0d9cb682966680Jouni Malinen
356075ecf5267604f166b85a7ee2cf0d9cb682966680Jouni Malinen	os_snprintf(groupmember_obj_path, WPAS_DBUS_OBJECT_PATH_MAX,
356175ecf5267604f166b85a7ee2cf0d9cb682966680Jouni Malinen		"%s/" WPAS_DBUS_NEW_P2P_GROUPMEMBERS_PART "/" COMPACT_MACSTR,
356275ecf5267604f166b85a7ee2cf0d9cb682966680Jouni Malinen		wpa_s->dbus_groupobj_path, MAC2STR(p2p_if_addr));
356375ecf5267604f166b85a7ee2cf0d9cb682966680Jouni Malinen
356475ecf5267604f166b85a7ee2cf0d9cb682966680Jouni Malinen	wpa_dbus_unregister_object_per_iface(ctrl_iface, groupmember_obj_path);
356575ecf5267604f166b85a7ee2cf0d9cb682966680Jouni Malinen}
356675ecf5267604f166b85a7ee2cf0d9cb682966680Jouni Malinen
356775ecf5267604f166b85a7ee2cf0d9cb682966680Jouni Malinen
356875ecf5267604f166b85a7ee2cf0d9cb682966680Jouni Malinenstatic const struct wpa_dbus_property_desc
356975ecf5267604f166b85a7ee2cf0d9cb682966680Jouni Malinen	wpas_dbus_persistent_group_properties[] = {
357075ecf5267604f166b85a7ee2cf0d9cb682966680Jouni Malinen	{ "Properties", WPAS_DBUS_NEW_IFACE_PERSISTENT_GROUP, "a{sv}",
357175ecf5267604f166b85a7ee2cf0d9cb682966680Jouni Malinen	  wpas_dbus_getter_persistent_group_properties,
35721f69aa52ea2e0a73ac502565df8c666ee49cab6aDmitry Shmidt	  wpas_dbus_setter_persistent_group_properties
357375ecf5267604f166b85a7ee2cf0d9cb682966680Jouni Malinen	},
35741f69aa52ea2e0a73ac502565df8c666ee49cab6aDmitry Shmidt	{ NULL, NULL, NULL, NULL, NULL }
357575ecf5267604f166b85a7ee2cf0d9cb682966680Jouni Malinen};
357675ecf5267604f166b85a7ee2cf0d9cb682966680Jouni Malinen
357775ecf5267604f166b85a7ee2cf0d9cb682966680Jouni Malinen/* No signals intended for persistent group objects */
357875ecf5267604f166b85a7ee2cf0d9cb682966680Jouni Malinen
357975ecf5267604f166b85a7ee2cf0d9cb682966680Jouni Malinen/**
358075ecf5267604f166b85a7ee2cf0d9cb682966680Jouni Malinen * wpas_dbus_register_persistent_group - Register a configured(saved)
358175ecf5267604f166b85a7ee2cf0d9cb682966680Jouni Malinen *	persistent group with dbus
358275ecf5267604f166b85a7ee2cf0d9cb682966680Jouni Malinen * @wpa_s: wpa_supplicant interface structure
358375ecf5267604f166b85a7ee2cf0d9cb682966680Jouni Malinen * @ssid: persistent group (still represented as a network within wpa)
358475ecf5267604f166b85a7ee2cf0d9cb682966680Jouni Malinen *	  configuration data
358575ecf5267604f166b85a7ee2cf0d9cb682966680Jouni Malinen * Returns: 0 on success, -1 on failure
358675ecf5267604f166b85a7ee2cf0d9cb682966680Jouni Malinen *
358775ecf5267604f166b85a7ee2cf0d9cb682966680Jouni Malinen * Registers a persistent group representing object with dbus.
358875ecf5267604f166b85a7ee2cf0d9cb682966680Jouni Malinen */
358975ecf5267604f166b85a7ee2cf0d9cb682966680Jouni Malinenint wpas_dbus_register_persistent_group(struct wpa_supplicant *wpa_s,
359075ecf5267604f166b85a7ee2cf0d9cb682966680Jouni Malinen					struct wpa_ssid *ssid)
359175ecf5267604f166b85a7ee2cf0d9cb682966680Jouni Malinen{
359275ecf5267604f166b85a7ee2cf0d9cb682966680Jouni Malinen	struct wpas_dbus_priv *ctrl_iface;
359375ecf5267604f166b85a7ee2cf0d9cb682966680Jouni Malinen	struct wpa_dbus_object_desc *obj_desc;
359475ecf5267604f166b85a7ee2cf0d9cb682966680Jouni Malinen	struct network_handler_args *arg;
359575ecf5267604f166b85a7ee2cf0d9cb682966680Jouni Malinen	char pgrp_obj_path[WPAS_DBUS_OBJECT_PATH_MAX];
359675ecf5267604f166b85a7ee2cf0d9cb682966680Jouni Malinen
359775ecf5267604f166b85a7ee2cf0d9cb682966680Jouni Malinen	/* Do nothing if the control interface is not turned on */
359875ecf5267604f166b85a7ee2cf0d9cb682966680Jouni Malinen	if (wpa_s == NULL || wpa_s->global == NULL)
359975ecf5267604f166b85a7ee2cf0d9cb682966680Jouni Malinen		return 0;
360075ecf5267604f166b85a7ee2cf0d9cb682966680Jouni Malinen
360175ecf5267604f166b85a7ee2cf0d9cb682966680Jouni Malinen	/* Make sure ssid is a persistent group */
360275ecf5267604f166b85a7ee2cf0d9cb682966680Jouni Malinen	if (ssid->disabled != 2 && !ssid->p2p_persistent_group)
360375ecf5267604f166b85a7ee2cf0d9cb682966680Jouni Malinen		return -1; /* should we return w/o complaining? */
360475ecf5267604f166b85a7ee2cf0d9cb682966680Jouni Malinen
360575ecf5267604f166b85a7ee2cf0d9cb682966680Jouni Malinen	ctrl_iface = wpa_s->global->dbus;
360675ecf5267604f166b85a7ee2cf0d9cb682966680Jouni Malinen	if (ctrl_iface == NULL)
360775ecf5267604f166b85a7ee2cf0d9cb682966680Jouni Malinen		return 0;
360875ecf5267604f166b85a7ee2cf0d9cb682966680Jouni Malinen
360975ecf5267604f166b85a7ee2cf0d9cb682966680Jouni Malinen	/*
361075ecf5267604f166b85a7ee2cf0d9cb682966680Jouni Malinen	 * Intentionally not coming up with different numbering scheme
361175ecf5267604f166b85a7ee2cf0d9cb682966680Jouni Malinen	 * for persistent groups.
361275ecf5267604f166b85a7ee2cf0d9cb682966680Jouni Malinen	 */
361375ecf5267604f166b85a7ee2cf0d9cb682966680Jouni Malinen	os_snprintf(pgrp_obj_path, WPAS_DBUS_OBJECT_PATH_MAX,
361475ecf5267604f166b85a7ee2cf0d9cb682966680Jouni Malinen		    "%s/" WPAS_DBUS_NEW_PERSISTENT_GROUPS_PART "/%u",
361575ecf5267604f166b85a7ee2cf0d9cb682966680Jouni Malinen		    wpa_s->dbus_new_path, ssid->id);
361675ecf5267604f166b85a7ee2cf0d9cb682966680Jouni Malinen
361775ecf5267604f166b85a7ee2cf0d9cb682966680Jouni Malinen	wpa_printf(MSG_DEBUG, "dbus: Register persistent group object '%s'",
361875ecf5267604f166b85a7ee2cf0d9cb682966680Jouni Malinen		   pgrp_obj_path);
361975ecf5267604f166b85a7ee2cf0d9cb682966680Jouni Malinen	obj_desc = os_zalloc(sizeof(struct wpa_dbus_object_desc));
362075ecf5267604f166b85a7ee2cf0d9cb682966680Jouni Malinen	if (!obj_desc) {
362175ecf5267604f166b85a7ee2cf0d9cb682966680Jouni Malinen		wpa_printf(MSG_ERROR, "dbus: Not enough memory to create "
362275ecf5267604f166b85a7ee2cf0d9cb682966680Jouni Malinen			   "object description");
362375ecf5267604f166b85a7ee2cf0d9cb682966680Jouni Malinen		goto err;
362475ecf5267604f166b85a7ee2cf0d9cb682966680Jouni Malinen	}
362575ecf5267604f166b85a7ee2cf0d9cb682966680Jouni Malinen
362675ecf5267604f166b85a7ee2cf0d9cb682966680Jouni Malinen	/*
362775ecf5267604f166b85a7ee2cf0d9cb682966680Jouni Malinen	 * Reusing the same context structure as that for networks
362875ecf5267604f166b85a7ee2cf0d9cb682966680Jouni Malinen	 * since these are represented using same data structure.
362975ecf5267604f166b85a7ee2cf0d9cb682966680Jouni Malinen	 */
363075ecf5267604f166b85a7ee2cf0d9cb682966680Jouni Malinen	/* allocate memory for handlers arguments */
363175ecf5267604f166b85a7ee2cf0d9cb682966680Jouni Malinen	arg = os_zalloc(sizeof(struct network_handler_args));
363275ecf5267604f166b85a7ee2cf0d9cb682966680Jouni Malinen	if (!arg) {
363375ecf5267604f166b85a7ee2cf0d9cb682966680Jouni Malinen		wpa_printf(MSG_ERROR, "dbus: Not enough memory to create "
363475ecf5267604f166b85a7ee2cf0d9cb682966680Jouni Malinen			   "arguments for method");
363575ecf5267604f166b85a7ee2cf0d9cb682966680Jouni Malinen		goto err;
363675ecf5267604f166b85a7ee2cf0d9cb682966680Jouni Malinen	}
363775ecf5267604f166b85a7ee2cf0d9cb682966680Jouni Malinen
363875ecf5267604f166b85a7ee2cf0d9cb682966680Jouni Malinen	arg->wpa_s = wpa_s;
363975ecf5267604f166b85a7ee2cf0d9cb682966680Jouni Malinen	arg->ssid = ssid;
364075ecf5267604f166b85a7ee2cf0d9cb682966680Jouni Malinen
364175ecf5267604f166b85a7ee2cf0d9cb682966680Jouni Malinen	wpas_dbus_register(obj_desc, arg, wpa_dbus_free, NULL,
364275ecf5267604f166b85a7ee2cf0d9cb682966680Jouni Malinen			   wpas_dbus_persistent_group_properties,
364375ecf5267604f166b85a7ee2cf0d9cb682966680Jouni Malinen			   NULL);
364475ecf5267604f166b85a7ee2cf0d9cb682966680Jouni Malinen
364575ecf5267604f166b85a7ee2cf0d9cb682966680Jouni Malinen	if (wpa_dbus_register_object_per_iface(ctrl_iface, pgrp_obj_path,
364675ecf5267604f166b85a7ee2cf0d9cb682966680Jouni Malinen					       wpa_s->ifname, obj_desc))
364775ecf5267604f166b85a7ee2cf0d9cb682966680Jouni Malinen		goto err;
364875ecf5267604f166b85a7ee2cf0d9cb682966680Jouni Malinen
364975ecf5267604f166b85a7ee2cf0d9cb682966680Jouni Malinen	wpas_dbus_signal_persistent_group_added(wpa_s, ssid->id);
36508d520ff1dc2da35cdca849e982051b86468016d8Dmitry Shmidt
36518d520ff1dc2da35cdca849e982051b86468016d8Dmitry Shmidt	return 0;
36528d520ff1dc2da35cdca849e982051b86468016d8Dmitry Shmidt
36538d520ff1dc2da35cdca849e982051b86468016d8Dmitry Shmidterr:
36548d520ff1dc2da35cdca849e982051b86468016d8Dmitry Shmidt	free_dbus_object_desc(obj_desc);
36558d520ff1dc2da35cdca849e982051b86468016d8Dmitry Shmidt	return -1;
36568d520ff1dc2da35cdca849e982051b86468016d8Dmitry Shmidt}
36578d520ff1dc2da35cdca849e982051b86468016d8Dmitry Shmidt
36588d520ff1dc2da35cdca849e982051b86468016d8Dmitry Shmidt
365975ecf5267604f166b85a7ee2cf0d9cb682966680Jouni Malinen/**
366075ecf5267604f166b85a7ee2cf0d9cb682966680Jouni Malinen * wpas_dbus_unregister_persistent_group - Unregister a persistent_group
366175ecf5267604f166b85a7ee2cf0d9cb682966680Jouni Malinen *	from dbus
366275ecf5267604f166b85a7ee2cf0d9cb682966680Jouni Malinen * @wpa_s: wpa_supplicant interface structure
366375ecf5267604f166b85a7ee2cf0d9cb682966680Jouni Malinen * @nid: network id
366475ecf5267604f166b85a7ee2cf0d9cb682966680Jouni Malinen * Returns: 0 on success, -1 on failure
366575ecf5267604f166b85a7ee2cf0d9cb682966680Jouni Malinen *
366675ecf5267604f166b85a7ee2cf0d9cb682966680Jouni Malinen * Unregisters persistent group representing object from dbus
366775ecf5267604f166b85a7ee2cf0d9cb682966680Jouni Malinen *
366875ecf5267604f166b85a7ee2cf0d9cb682966680Jouni Malinen * NOTE: There is a slight issue with the semantics here. While the
366975ecf5267604f166b85a7ee2cf0d9cb682966680Jouni Malinen * implementation simply means the persistent group is unloaded from memory,
367075ecf5267604f166b85a7ee2cf0d9cb682966680Jouni Malinen * it should not get interpreted as the group is actually being erased/removed
367175ecf5267604f166b85a7ee2cf0d9cb682966680Jouni Malinen * from persistent storage as well.
367275ecf5267604f166b85a7ee2cf0d9cb682966680Jouni Malinen */
367375ecf5267604f166b85a7ee2cf0d9cb682966680Jouni Malinenint wpas_dbus_unregister_persistent_group(struct wpa_supplicant *wpa_s,
367475ecf5267604f166b85a7ee2cf0d9cb682966680Jouni Malinen					  int nid)
36758d520ff1dc2da35cdca849e982051b86468016d8Dmitry Shmidt{
36768d520ff1dc2da35cdca849e982051b86468016d8Dmitry Shmidt	struct wpas_dbus_priv *ctrl_iface;
367775ecf5267604f166b85a7ee2cf0d9cb682966680Jouni Malinen	char pgrp_obj_path[WPAS_DBUS_OBJECT_PATH_MAX];
367875ecf5267604f166b85a7ee2cf0d9cb682966680Jouni Malinen	int ret;
36798d520ff1dc2da35cdca849e982051b86468016d8Dmitry Shmidt
36808d520ff1dc2da35cdca849e982051b86468016d8Dmitry Shmidt	/* Do nothing if the control interface is not turned on */
368175ecf5267604f166b85a7ee2cf0d9cb682966680Jouni Malinen	if (wpa_s == NULL || wpa_s->global == NULL ||
368275ecf5267604f166b85a7ee2cf0d9cb682966680Jouni Malinen	    wpa_s->dbus_new_path == NULL)
36838d520ff1dc2da35cdca849e982051b86468016d8Dmitry Shmidt		return 0;
36848d520ff1dc2da35cdca849e982051b86468016d8Dmitry Shmidt	ctrl_iface = wpa_s->global->dbus;
36858d520ff1dc2da35cdca849e982051b86468016d8Dmitry Shmidt	if (ctrl_iface == NULL)
36868d520ff1dc2da35cdca849e982051b86468016d8Dmitry Shmidt		return 0;
36878d520ff1dc2da35cdca849e982051b86468016d8Dmitry Shmidt
368875ecf5267604f166b85a7ee2cf0d9cb682966680Jouni Malinen	os_snprintf(pgrp_obj_path, WPAS_DBUS_OBJECT_PATH_MAX,
368975ecf5267604f166b85a7ee2cf0d9cb682966680Jouni Malinen		    "%s/" WPAS_DBUS_NEW_PERSISTENT_GROUPS_PART "/%u",
369075ecf5267604f166b85a7ee2cf0d9cb682966680Jouni Malinen		    wpa_s->dbus_new_path, nid);
36918d520ff1dc2da35cdca849e982051b86468016d8Dmitry Shmidt
369275ecf5267604f166b85a7ee2cf0d9cb682966680Jouni Malinen	wpa_printf(MSG_DEBUG, "dbus: Unregister persistent group object '%s'",
369375ecf5267604f166b85a7ee2cf0d9cb682966680Jouni Malinen		   pgrp_obj_path);
369475ecf5267604f166b85a7ee2cf0d9cb682966680Jouni Malinen	ret = wpa_dbus_unregister_object_per_iface(ctrl_iface, pgrp_obj_path);
36958d520ff1dc2da35cdca849e982051b86468016d8Dmitry Shmidt
369675ecf5267604f166b85a7ee2cf0d9cb682966680Jouni Malinen	if (!ret)
369775ecf5267604f166b85a7ee2cf0d9cb682966680Jouni Malinen		wpas_dbus_signal_persistent_group_removed(wpa_s, nid);
36988d520ff1dc2da35cdca849e982051b86468016d8Dmitry Shmidt
369975ecf5267604f166b85a7ee2cf0d9cb682966680Jouni Malinen	return ret;
37008d520ff1dc2da35cdca849e982051b86468016d8Dmitry Shmidt}
370175ecf5267604f166b85a7ee2cf0d9cb682966680Jouni Malinen
370275ecf5267604f166b85a7ee2cf0d9cb682966680Jouni Malinen#endif /* CONFIG_P2P */
3703