1d4f2939cSRui Paulo /*
2d4f2939cSRui Paulo * WPA Supplicant / dbus-based control interface
3d4f2939cSRui Paulo * Copyright (c) 2006, Dan Williams <dcbw@redhat.com> and Red Hat, Inc.
4d4f2939cSRui Paulo * Copyright (c) 2009-2010, Witold Sowa <witold.sowa@gmail.com>
5d4f2939cSRui Paulo * Copyright (c) 2009, Jouni Malinen <j@w1.fi>
6d4f2939cSRui Paulo *
7d4f2939cSRui Paulo * This software may be distributed under the terms of the BSD license.
8d4f2939cSRui Paulo * See README for more details.
9d4f2939cSRui Paulo */
10d4f2939cSRui Paulo
11d4f2939cSRui Paulo #include "includes.h"
12d4f2939cSRui Paulo
13d4f2939cSRui Paulo #include "common.h"
14d4f2939cSRui Paulo #include "common/ieee802_11_defs.h"
15d4f2939cSRui Paulo #include "wps/wps.h"
164bc52338SCy Schubert #include "ap/sta_info.h"
17d4f2939cSRui Paulo #include "../config.h"
18d4f2939cSRui Paulo #include "../wpa_supplicant_i.h"
19d4f2939cSRui Paulo #include "../bss.h"
20d4f2939cSRui Paulo #include "../wpas_glue.h"
21d4f2939cSRui Paulo #include "dbus_new_helpers.h"
22d4f2939cSRui Paulo #include "dbus_dict_helpers.h"
23d4f2939cSRui Paulo #include "dbus_new.h"
24d4f2939cSRui Paulo #include "dbus_new_handlers.h"
25d4f2939cSRui Paulo #include "dbus_common_i.h"
26d4f2939cSRui Paulo #include "dbus_new_handlers_p2p.h"
27d4f2939cSRui Paulo #include "p2p/p2p.h"
285b9c547cSRui Paulo #include "../p2p_supplicant.h"
29d4f2939cSRui Paulo
30d4f2939cSRui Paulo #ifdef CONFIG_AP /* until needed by something else */
31d4f2939cSRui Paulo
32d4f2939cSRui Paulo /*
33d4f2939cSRui Paulo * NameOwnerChanged handling
34d4f2939cSRui Paulo *
35d4f2939cSRui Paulo * Some services we provide allow an application to register for
36d4f2939cSRui Paulo * a signal that it needs. While it can also unregister, we must
37d4f2939cSRui Paulo * be prepared for the case where the application simply crashes
38d4f2939cSRui Paulo * and thus doesn't clean up properly. The way to handle this in
39d4f2939cSRui Paulo * DBus is to register for the NameOwnerChanged signal which will
40d4f2939cSRui Paulo * signal an owner change to NULL if the peer closes the socket
41d4f2939cSRui Paulo * for whatever reason.
42d4f2939cSRui Paulo *
43d4f2939cSRui Paulo * Handle this signal via a filter function whenever necessary.
44d4f2939cSRui Paulo * The code below also handles refcounting in case in the future
45d4f2939cSRui Paulo * there will be multiple instances of this subscription scheme.
46d4f2939cSRui Paulo */
47d4f2939cSRui Paulo static const char wpas_dbus_noc_filter_str[] =
48d4f2939cSRui Paulo "interface=org.freedesktop.DBus,member=NameOwnerChanged";
49d4f2939cSRui Paulo
50d4f2939cSRui Paulo
noc_filter(DBusConnection * conn,DBusMessage * message,void * data)51d4f2939cSRui Paulo static DBusHandlerResult noc_filter(DBusConnection *conn,
52d4f2939cSRui Paulo DBusMessage *message, void *data)
53d4f2939cSRui Paulo {
54d4f2939cSRui Paulo struct wpas_dbus_priv *priv = data;
55d4f2939cSRui Paulo
56d4f2939cSRui Paulo if (dbus_message_get_type(message) != DBUS_MESSAGE_TYPE_SIGNAL)
57d4f2939cSRui Paulo return DBUS_HANDLER_RESULT_NOT_YET_HANDLED;
58d4f2939cSRui Paulo
59d4f2939cSRui Paulo if (dbus_message_is_signal(message, DBUS_INTERFACE_DBUS,
60d4f2939cSRui Paulo "NameOwnerChanged")) {
61d4f2939cSRui Paulo const char *name;
62d4f2939cSRui Paulo const char *prev_owner;
63d4f2939cSRui Paulo const char *new_owner;
64d4f2939cSRui Paulo DBusError derr;
65d4f2939cSRui Paulo struct wpa_supplicant *wpa_s;
66d4f2939cSRui Paulo
67d4f2939cSRui Paulo dbus_error_init(&derr);
68d4f2939cSRui Paulo
69d4f2939cSRui Paulo if (!dbus_message_get_args(message, &derr,
70d4f2939cSRui Paulo DBUS_TYPE_STRING, &name,
71d4f2939cSRui Paulo DBUS_TYPE_STRING, &prev_owner,
72d4f2939cSRui Paulo DBUS_TYPE_STRING, &new_owner,
73d4f2939cSRui Paulo DBUS_TYPE_INVALID)) {
74d4f2939cSRui Paulo /* Ignore this error */
75d4f2939cSRui Paulo dbus_error_free(&derr);
76d4f2939cSRui Paulo return DBUS_HANDLER_RESULT_NOT_YET_HANDLED;
77d4f2939cSRui Paulo }
78d4f2939cSRui Paulo
795b9c547cSRui Paulo for (wpa_s = priv->global->ifaces; wpa_s; wpa_s = wpa_s->next) {
80d4f2939cSRui Paulo if (wpa_s->preq_notify_peer != NULL &&
81d4f2939cSRui Paulo os_strcmp(name, wpa_s->preq_notify_peer) == 0 &&
82d4f2939cSRui Paulo (new_owner == NULL || os_strlen(new_owner) == 0)) {
83d4f2939cSRui Paulo /* probe request owner disconnected */
84d4f2939cSRui Paulo os_free(wpa_s->preq_notify_peer);
85d4f2939cSRui Paulo wpa_s->preq_notify_peer = NULL;
86d4f2939cSRui Paulo wpas_dbus_unsubscribe_noc(priv);
87d4f2939cSRui Paulo }
88d4f2939cSRui Paulo }
89d4f2939cSRui Paulo }
90d4f2939cSRui Paulo
91d4f2939cSRui Paulo return DBUS_HANDLER_RESULT_NOT_YET_HANDLED;
92d4f2939cSRui Paulo }
93d4f2939cSRui Paulo
94d4f2939cSRui Paulo
wpas_dbus_subscribe_noc(struct wpas_dbus_priv * priv)95d4f2939cSRui Paulo void wpas_dbus_subscribe_noc(struct wpas_dbus_priv *priv)
96d4f2939cSRui Paulo {
97d4f2939cSRui Paulo priv->dbus_noc_refcnt++;
98d4f2939cSRui Paulo if (priv->dbus_noc_refcnt > 1)
99d4f2939cSRui Paulo return;
100d4f2939cSRui Paulo
101d4f2939cSRui Paulo if (!dbus_connection_add_filter(priv->con, noc_filter, priv, NULL)) {
102d4f2939cSRui Paulo wpa_printf(MSG_ERROR, "dbus: failed to add filter");
103d4f2939cSRui Paulo return;
104d4f2939cSRui Paulo }
105d4f2939cSRui Paulo
106d4f2939cSRui Paulo dbus_bus_add_match(priv->con, wpas_dbus_noc_filter_str, NULL);
107d4f2939cSRui Paulo }
108d4f2939cSRui Paulo
109d4f2939cSRui Paulo
wpas_dbus_unsubscribe_noc(struct wpas_dbus_priv * priv)110d4f2939cSRui Paulo void wpas_dbus_unsubscribe_noc(struct wpas_dbus_priv *priv)
111d4f2939cSRui Paulo {
112d4f2939cSRui Paulo priv->dbus_noc_refcnt--;
113d4f2939cSRui Paulo if (priv->dbus_noc_refcnt > 0)
114d4f2939cSRui Paulo return;
115d4f2939cSRui Paulo
116d4f2939cSRui Paulo dbus_bus_remove_match(priv->con, wpas_dbus_noc_filter_str, NULL);
117d4f2939cSRui Paulo dbus_connection_remove_filter(priv->con, noc_filter, priv);
118d4f2939cSRui Paulo }
119d4f2939cSRui Paulo
120d4f2939cSRui Paulo #endif /* CONFIG_AP */
121d4f2939cSRui Paulo
122d4f2939cSRui Paulo
123d4f2939cSRui Paulo /**
124d4f2939cSRui Paulo * wpas_dbus_signal_interface - Send a interface related event signal
125d4f2939cSRui Paulo * @wpa_s: %wpa_supplicant network interface data
126d4f2939cSRui Paulo * @sig_name: signal name - InterfaceAdded or InterfaceRemoved
127d4f2939cSRui Paulo * @properties: Whether to add second argument with object properties
128d4f2939cSRui Paulo *
129d4f2939cSRui Paulo * Notify listeners about event related with interface
130d4f2939cSRui Paulo */
wpas_dbus_signal_interface(struct wpa_supplicant * wpa_s,const char * sig_name,dbus_bool_t properties)131d4f2939cSRui Paulo static void wpas_dbus_signal_interface(struct wpa_supplicant *wpa_s,
1324bc52338SCy Schubert const char *sig_name,
1334bc52338SCy Schubert dbus_bool_t properties)
134d4f2939cSRui Paulo {
135d4f2939cSRui Paulo struct wpas_dbus_priv *iface;
136d4f2939cSRui Paulo DBusMessage *msg;
137d4f2939cSRui Paulo DBusMessageIter iter;
138d4f2939cSRui Paulo
139d4f2939cSRui Paulo iface = wpa_s->global->dbus;
140d4f2939cSRui Paulo
141d4f2939cSRui Paulo /* Do nothing if the control interface is not turned on */
142325151a3SRui Paulo if (iface == NULL || !wpa_s->dbus_new_path)
143d4f2939cSRui Paulo return;
144d4f2939cSRui Paulo
145d4f2939cSRui Paulo msg = dbus_message_new_signal(WPAS_DBUS_NEW_PATH,
146d4f2939cSRui Paulo WPAS_DBUS_NEW_INTERFACE, sig_name);
147d4f2939cSRui Paulo if (msg == NULL)
148d4f2939cSRui Paulo return;
149d4f2939cSRui Paulo
150d4f2939cSRui Paulo dbus_message_iter_init_append(msg, &iter);
151d4f2939cSRui Paulo if (!dbus_message_iter_append_basic(&iter, DBUS_TYPE_OBJECT_PATH,
1525b9c547cSRui Paulo &wpa_s->dbus_new_path) ||
1535b9c547cSRui Paulo (properties &&
1545b9c547cSRui Paulo !wpa_dbus_get_object_properties(
155d4f2939cSRui Paulo iface, wpa_s->dbus_new_path,
1565b9c547cSRui Paulo WPAS_DBUS_NEW_IFACE_INTERFACE, &iter)))
157d4f2939cSRui Paulo wpa_printf(MSG_ERROR, "dbus: Failed to construct signal");
1585b9c547cSRui Paulo else
1595b9c547cSRui Paulo dbus_connection_send(iface->con, msg, NULL);
160d4f2939cSRui Paulo dbus_message_unref(msg);
161d4f2939cSRui Paulo }
162d4f2939cSRui Paulo
163d4f2939cSRui Paulo
164d4f2939cSRui Paulo /**
165d4f2939cSRui Paulo * wpas_dbus_signal_interface_added - Send a interface created signal
166d4f2939cSRui Paulo * @wpa_s: %wpa_supplicant network interface data
167d4f2939cSRui Paulo *
168d4f2939cSRui Paulo * Notify listeners about creating new interface
169d4f2939cSRui Paulo */
wpas_dbus_signal_interface_added(struct wpa_supplicant * wpa_s)170d4f2939cSRui Paulo static void wpas_dbus_signal_interface_added(struct wpa_supplicant *wpa_s)
171d4f2939cSRui Paulo {
172d4f2939cSRui Paulo wpas_dbus_signal_interface(wpa_s, "InterfaceAdded", TRUE);
173d4f2939cSRui Paulo }
174d4f2939cSRui Paulo
175d4f2939cSRui Paulo
176d4f2939cSRui Paulo /**
177d4f2939cSRui Paulo * wpas_dbus_signal_interface_removed - Send a interface removed signal
178d4f2939cSRui Paulo * @wpa_s: %wpa_supplicant network interface data
179d4f2939cSRui Paulo *
180d4f2939cSRui Paulo * Notify listeners about removing interface
181d4f2939cSRui Paulo */
wpas_dbus_signal_interface_removed(struct wpa_supplicant * wpa_s)182d4f2939cSRui Paulo static void wpas_dbus_signal_interface_removed(struct wpa_supplicant *wpa_s)
183d4f2939cSRui Paulo {
184d4f2939cSRui Paulo wpas_dbus_signal_interface(wpa_s, "InterfaceRemoved", FALSE);
185d4f2939cSRui Paulo
186d4f2939cSRui Paulo }
187d4f2939cSRui Paulo
188d4f2939cSRui Paulo
189d4f2939cSRui Paulo /**
190d4f2939cSRui Paulo * wpas_dbus_signal_scan_done - send scan done signal
191d4f2939cSRui Paulo * @wpa_s: %wpa_supplicant network interface data
192d4f2939cSRui Paulo * @success: indicates if scanning succeed or failed
193d4f2939cSRui Paulo *
194d4f2939cSRui Paulo * Notify listeners about finishing a scan
195d4f2939cSRui Paulo */
wpas_dbus_signal_scan_done(struct wpa_supplicant * wpa_s,int success)196d4f2939cSRui Paulo void wpas_dbus_signal_scan_done(struct wpa_supplicant *wpa_s, int success)
197d4f2939cSRui Paulo {
198d4f2939cSRui Paulo struct wpas_dbus_priv *iface;
199d4f2939cSRui Paulo DBusMessage *msg;
200d4f2939cSRui Paulo dbus_bool_t succ;
201d4f2939cSRui Paulo
202d4f2939cSRui Paulo iface = wpa_s->global->dbus;
203d4f2939cSRui Paulo
204d4f2939cSRui Paulo /* Do nothing if the control interface is not turned on */
205325151a3SRui Paulo if (iface == NULL || !wpa_s->dbus_new_path)
206d4f2939cSRui Paulo return;
207d4f2939cSRui Paulo
208d4f2939cSRui Paulo msg = dbus_message_new_signal(wpa_s->dbus_new_path,
209d4f2939cSRui Paulo WPAS_DBUS_NEW_IFACE_INTERFACE,
210d4f2939cSRui Paulo "ScanDone");
211d4f2939cSRui Paulo if (msg == NULL)
212d4f2939cSRui Paulo return;
213d4f2939cSRui Paulo
214d4f2939cSRui Paulo succ = success ? TRUE : FALSE;
215d4f2939cSRui Paulo if (dbus_message_append_args(msg, DBUS_TYPE_BOOLEAN, &succ,
216d4f2939cSRui Paulo DBUS_TYPE_INVALID))
217d4f2939cSRui Paulo dbus_connection_send(iface->con, msg, NULL);
218d4f2939cSRui Paulo else
219d4f2939cSRui Paulo wpa_printf(MSG_ERROR, "dbus: Failed to construct signal");
220d4f2939cSRui Paulo dbus_message_unref(msg);
221d4f2939cSRui Paulo }
222d4f2939cSRui Paulo
223d4f2939cSRui Paulo
224d4f2939cSRui Paulo /**
2255b9c547cSRui Paulo * wpas_dbus_signal_bss - Send a BSS related event signal
226d4f2939cSRui Paulo * @wpa_s: %wpa_supplicant network interface data
227d4f2939cSRui Paulo * @bss_obj_path: BSS object path
228d4f2939cSRui Paulo * @sig_name: signal name - BSSAdded or BSSRemoved
229d4f2939cSRui Paulo * @properties: Whether to add second argument with object properties
230d4f2939cSRui Paulo *
231d4f2939cSRui Paulo * Notify listeners about event related with BSS
232d4f2939cSRui Paulo */
wpas_dbus_signal_bss(struct wpa_supplicant * wpa_s,const char * bss_obj_path,const char * sig_name,dbus_bool_t properties)233d4f2939cSRui Paulo static void wpas_dbus_signal_bss(struct wpa_supplicant *wpa_s,
234d4f2939cSRui Paulo const char *bss_obj_path,
2354bc52338SCy Schubert const char *sig_name, dbus_bool_t properties)
236d4f2939cSRui Paulo {
237d4f2939cSRui Paulo struct wpas_dbus_priv *iface;
238d4f2939cSRui Paulo DBusMessage *msg;
239d4f2939cSRui Paulo DBusMessageIter iter;
240d4f2939cSRui Paulo
241d4f2939cSRui Paulo iface = wpa_s->global->dbus;
242d4f2939cSRui Paulo
243d4f2939cSRui Paulo /* Do nothing if the control interface is not turned on */
244325151a3SRui Paulo if (iface == NULL || !wpa_s->dbus_new_path)
245d4f2939cSRui Paulo return;
246d4f2939cSRui Paulo
247d4f2939cSRui Paulo msg = dbus_message_new_signal(wpa_s->dbus_new_path,
248d4f2939cSRui Paulo WPAS_DBUS_NEW_IFACE_INTERFACE,
249d4f2939cSRui Paulo sig_name);
250d4f2939cSRui Paulo if (msg == NULL)
251d4f2939cSRui Paulo return;
252d4f2939cSRui Paulo
253d4f2939cSRui Paulo dbus_message_iter_init_append(msg, &iter);
254d4f2939cSRui Paulo if (!dbus_message_iter_append_basic(&iter, DBUS_TYPE_OBJECT_PATH,
2555b9c547cSRui Paulo &bss_obj_path) ||
2565b9c547cSRui Paulo (properties &&
2575b9c547cSRui Paulo !wpa_dbus_get_object_properties(iface, bss_obj_path,
258d4f2939cSRui Paulo WPAS_DBUS_NEW_IFACE_BSS,
2595b9c547cSRui Paulo &iter)))
260d4f2939cSRui Paulo wpa_printf(MSG_ERROR, "dbus: Failed to construct signal");
2615b9c547cSRui Paulo else
2625b9c547cSRui Paulo dbus_connection_send(iface->con, msg, NULL);
263d4f2939cSRui Paulo dbus_message_unref(msg);
264d4f2939cSRui Paulo }
265d4f2939cSRui Paulo
266d4f2939cSRui Paulo
267d4f2939cSRui Paulo /**
268d4f2939cSRui Paulo * wpas_dbus_signal_bss_added - Send a BSS added signal
269d4f2939cSRui Paulo * @wpa_s: %wpa_supplicant network interface data
270d4f2939cSRui Paulo * @bss_obj_path: new BSS object path
271d4f2939cSRui Paulo *
272d4f2939cSRui Paulo * Notify listeners about adding new BSS
273d4f2939cSRui Paulo */
wpas_dbus_signal_bss_added(struct wpa_supplicant * wpa_s,const char * bss_obj_path)274d4f2939cSRui Paulo static void wpas_dbus_signal_bss_added(struct wpa_supplicant *wpa_s,
275d4f2939cSRui Paulo const char *bss_obj_path)
276d4f2939cSRui Paulo {
277d4f2939cSRui Paulo wpas_dbus_signal_bss(wpa_s, bss_obj_path, "BSSAdded", TRUE);
278d4f2939cSRui Paulo }
279d4f2939cSRui Paulo
280d4f2939cSRui Paulo
281d4f2939cSRui Paulo /**
282d4f2939cSRui Paulo * wpas_dbus_signal_bss_removed - Send a BSS removed signal
283d4f2939cSRui Paulo * @wpa_s: %wpa_supplicant network interface data
284d4f2939cSRui Paulo * @bss_obj_path: BSS object path
285d4f2939cSRui Paulo *
286d4f2939cSRui Paulo * Notify listeners about removing BSS
287d4f2939cSRui Paulo */
wpas_dbus_signal_bss_removed(struct wpa_supplicant * wpa_s,const char * bss_obj_path)288d4f2939cSRui Paulo static void wpas_dbus_signal_bss_removed(struct wpa_supplicant *wpa_s,
289d4f2939cSRui Paulo const char *bss_obj_path)
290d4f2939cSRui Paulo {
291d4f2939cSRui Paulo wpas_dbus_signal_bss(wpa_s, bss_obj_path, "BSSRemoved", FALSE);
292d4f2939cSRui Paulo }
293d4f2939cSRui Paulo
294d4f2939cSRui Paulo
295d4f2939cSRui Paulo /**
296d4f2939cSRui Paulo * wpas_dbus_signal_blob - Send a blob related event signal
297d4f2939cSRui Paulo * @wpa_s: %wpa_supplicant network interface data
298d4f2939cSRui Paulo * @name: blob name
299d4f2939cSRui Paulo * @sig_name: signal name - BlobAdded or BlobRemoved
300d4f2939cSRui Paulo *
301d4f2939cSRui Paulo * Notify listeners about event related with blob
302d4f2939cSRui Paulo */
wpas_dbus_signal_blob(struct wpa_supplicant * wpa_s,const char * name,const char * sig_name)303d4f2939cSRui Paulo static void wpas_dbus_signal_blob(struct wpa_supplicant *wpa_s,
304d4f2939cSRui Paulo const char *name, const char *sig_name)
305d4f2939cSRui Paulo {
306d4f2939cSRui Paulo struct wpas_dbus_priv *iface;
307d4f2939cSRui Paulo DBusMessage *msg;
308d4f2939cSRui Paulo
309d4f2939cSRui Paulo iface = wpa_s->global->dbus;
310d4f2939cSRui Paulo
311d4f2939cSRui Paulo /* Do nothing if the control interface is not turned on */
312325151a3SRui Paulo if (iface == NULL || !wpa_s->dbus_new_path)
313d4f2939cSRui Paulo return;
314d4f2939cSRui Paulo
315d4f2939cSRui Paulo msg = dbus_message_new_signal(wpa_s->dbus_new_path,
316d4f2939cSRui Paulo WPAS_DBUS_NEW_IFACE_INTERFACE,
317d4f2939cSRui Paulo sig_name);
318d4f2939cSRui Paulo if (msg == NULL)
319d4f2939cSRui Paulo return;
320d4f2939cSRui Paulo
321d4f2939cSRui Paulo if (dbus_message_append_args(msg, DBUS_TYPE_STRING, &name,
322d4f2939cSRui Paulo DBUS_TYPE_INVALID))
323d4f2939cSRui Paulo dbus_connection_send(iface->con, msg, NULL);
324d4f2939cSRui Paulo else
325d4f2939cSRui Paulo wpa_printf(MSG_ERROR, "dbus: Failed to construct signal");
326d4f2939cSRui Paulo dbus_message_unref(msg);
327d4f2939cSRui Paulo }
328d4f2939cSRui Paulo
329d4f2939cSRui Paulo
330d4f2939cSRui Paulo /**
331d4f2939cSRui Paulo * wpas_dbus_signal_blob_added - Send a blob added signal
332d4f2939cSRui Paulo * @wpa_s: %wpa_supplicant network interface data
333d4f2939cSRui Paulo * @name: blob name
334d4f2939cSRui Paulo *
335d4f2939cSRui Paulo * Notify listeners about adding a new blob
336d4f2939cSRui Paulo */
wpas_dbus_signal_blob_added(struct wpa_supplicant * wpa_s,const char * name)337d4f2939cSRui Paulo void wpas_dbus_signal_blob_added(struct wpa_supplicant *wpa_s,
338d4f2939cSRui Paulo const char *name)
339d4f2939cSRui Paulo {
340d4f2939cSRui Paulo wpas_dbus_signal_blob(wpa_s, name, "BlobAdded");
341d4f2939cSRui Paulo }
342d4f2939cSRui Paulo
343d4f2939cSRui Paulo
344d4f2939cSRui Paulo /**
345d4f2939cSRui Paulo * wpas_dbus_signal_blob_removed - Send a blob removed signal
346d4f2939cSRui Paulo * @wpa_s: %wpa_supplicant network interface data
347d4f2939cSRui Paulo * @name: blob name
348d4f2939cSRui Paulo *
349d4f2939cSRui Paulo * Notify listeners about removing blob
350d4f2939cSRui Paulo */
wpas_dbus_signal_blob_removed(struct wpa_supplicant * wpa_s,const char * name)351d4f2939cSRui Paulo void wpas_dbus_signal_blob_removed(struct wpa_supplicant *wpa_s,
352d4f2939cSRui Paulo const char *name)
353d4f2939cSRui Paulo {
354d4f2939cSRui Paulo wpas_dbus_signal_blob(wpa_s, name, "BlobRemoved");
355d4f2939cSRui Paulo }
356d4f2939cSRui Paulo
357d4f2939cSRui Paulo
358d4f2939cSRui Paulo /**
359d4f2939cSRui Paulo * wpas_dbus_signal_network - Send a network related event signal
360d4f2939cSRui Paulo * @wpa_s: %wpa_supplicant network interface data
361d4f2939cSRui Paulo * @id: new network id
362d4f2939cSRui Paulo * @sig_name: signal name - NetworkAdded, NetworkRemoved or NetworkSelected
363d4f2939cSRui Paulo * @properties: determines if add second argument with object properties
364d4f2939cSRui Paulo *
365d4f2939cSRui Paulo * Notify listeners about event related with configured network
366d4f2939cSRui Paulo */
wpas_dbus_signal_network(struct wpa_supplicant * wpa_s,int id,const char * sig_name,dbus_bool_t properties)367d4f2939cSRui Paulo static void wpas_dbus_signal_network(struct wpa_supplicant *wpa_s,
368d4f2939cSRui Paulo int id, const char *sig_name,
3694bc52338SCy Schubert dbus_bool_t properties)
370d4f2939cSRui Paulo {
371d4f2939cSRui Paulo struct wpas_dbus_priv *iface;
372d4f2939cSRui Paulo DBusMessage *msg;
373d4f2939cSRui Paulo DBusMessageIter iter;
374d4f2939cSRui Paulo char net_obj_path[WPAS_DBUS_OBJECT_PATH_MAX], *path;
375d4f2939cSRui Paulo
376d4f2939cSRui Paulo iface = wpa_s->global->dbus;
377d4f2939cSRui Paulo
378d4f2939cSRui Paulo /* Do nothing if the control interface is not turned on */
379325151a3SRui Paulo if (iface == NULL || !wpa_s->dbus_new_path)
380d4f2939cSRui Paulo return;
381d4f2939cSRui Paulo
382d4f2939cSRui Paulo os_snprintf(net_obj_path, WPAS_DBUS_OBJECT_PATH_MAX,
383d4f2939cSRui Paulo "%s/" WPAS_DBUS_NEW_NETWORKS_PART "/%u",
384d4f2939cSRui Paulo wpa_s->dbus_new_path, id);
385d4f2939cSRui Paulo
386d4f2939cSRui Paulo msg = dbus_message_new_signal(wpa_s->dbus_new_path,
387d4f2939cSRui Paulo WPAS_DBUS_NEW_IFACE_INTERFACE,
388d4f2939cSRui Paulo sig_name);
389d4f2939cSRui Paulo if (msg == NULL)
390d4f2939cSRui Paulo return;
391d4f2939cSRui Paulo
392d4f2939cSRui Paulo dbus_message_iter_init_append(msg, &iter);
393d4f2939cSRui Paulo path = net_obj_path;
394d4f2939cSRui Paulo if (!dbus_message_iter_append_basic(&iter, DBUS_TYPE_OBJECT_PATH,
3955b9c547cSRui Paulo &path) ||
3965b9c547cSRui Paulo (properties &&
3975b9c547cSRui Paulo !wpa_dbus_get_object_properties(
398d4f2939cSRui Paulo iface, net_obj_path, WPAS_DBUS_NEW_IFACE_NETWORK,
3995b9c547cSRui Paulo &iter)))
400d4f2939cSRui Paulo wpa_printf(MSG_ERROR, "dbus: Failed to construct signal");
4015b9c547cSRui Paulo else
4025b9c547cSRui Paulo dbus_connection_send(iface->con, msg, NULL);
403d4f2939cSRui Paulo dbus_message_unref(msg);
404d4f2939cSRui Paulo }
405d4f2939cSRui Paulo
406d4f2939cSRui Paulo
407d4f2939cSRui Paulo /**
408d4f2939cSRui Paulo * wpas_dbus_signal_network_added - Send a network added signal
409d4f2939cSRui Paulo * @wpa_s: %wpa_supplicant network interface data
410d4f2939cSRui Paulo * @id: new network id
411d4f2939cSRui Paulo *
412d4f2939cSRui Paulo * Notify listeners about adding new network
413d4f2939cSRui Paulo */
wpas_dbus_signal_network_added(struct wpa_supplicant * wpa_s,int id)414d4f2939cSRui Paulo static void wpas_dbus_signal_network_added(struct wpa_supplicant *wpa_s,
415d4f2939cSRui Paulo int id)
416d4f2939cSRui Paulo {
417d4f2939cSRui Paulo wpas_dbus_signal_network(wpa_s, id, "NetworkAdded", TRUE);
418d4f2939cSRui Paulo }
419d4f2939cSRui Paulo
420d4f2939cSRui Paulo
421d4f2939cSRui Paulo /**
422d4f2939cSRui Paulo * wpas_dbus_signal_network_removed - Send a network removed signal
423d4f2939cSRui Paulo * @wpa_s: %wpa_supplicant network interface data
424d4f2939cSRui Paulo * @id: network id
425d4f2939cSRui Paulo *
426d4f2939cSRui Paulo * Notify listeners about removing a network
427d4f2939cSRui Paulo */
wpas_dbus_signal_network_removed(struct wpa_supplicant * wpa_s,int id)428d4f2939cSRui Paulo static void wpas_dbus_signal_network_removed(struct wpa_supplicant *wpa_s,
429d4f2939cSRui Paulo int id)
430d4f2939cSRui Paulo {
431d4f2939cSRui Paulo wpas_dbus_signal_network(wpa_s, id, "NetworkRemoved", FALSE);
432d4f2939cSRui Paulo }
433d4f2939cSRui Paulo
434d4f2939cSRui Paulo
435d4f2939cSRui Paulo /**
436d4f2939cSRui Paulo * wpas_dbus_signal_network_selected - Send a network selected signal
437d4f2939cSRui Paulo * @wpa_s: %wpa_supplicant network interface data
438d4f2939cSRui Paulo * @id: network id
439d4f2939cSRui Paulo *
440d4f2939cSRui Paulo * Notify listeners about selecting a network
441d4f2939cSRui Paulo */
wpas_dbus_signal_network_selected(struct wpa_supplicant * wpa_s,int id)442d4f2939cSRui Paulo void wpas_dbus_signal_network_selected(struct wpa_supplicant *wpa_s, int id)
443d4f2939cSRui Paulo {
444d4f2939cSRui Paulo wpas_dbus_signal_network(wpa_s, id, "NetworkSelected", FALSE);
445d4f2939cSRui Paulo }
446d4f2939cSRui Paulo
447d4f2939cSRui Paulo
448d4f2939cSRui Paulo /**
449d4f2939cSRui Paulo * wpas_dbus_signal_network_request - Indicate that additional information
450d4f2939cSRui Paulo * (EAP password, etc.) is required to complete the association to this SSID
451d4f2939cSRui Paulo * @wpa_s: %wpa_supplicant network interface data
452d4f2939cSRui Paulo * @rtype: The specific additional information required
453d4f2939cSRui Paulo * @default_text: Optional description of required information
454d4f2939cSRui Paulo *
455d4f2939cSRui Paulo * Request additional information or passwords to complete an association
456d4f2939cSRui Paulo * request.
457d4f2939cSRui Paulo */
wpas_dbus_signal_network_request(struct wpa_supplicant * wpa_s,struct wpa_ssid * ssid,enum wpa_ctrl_req_type rtype,const char * default_txt)458d4f2939cSRui Paulo void wpas_dbus_signal_network_request(struct wpa_supplicant *wpa_s,
459d4f2939cSRui Paulo struct wpa_ssid *ssid,
460d4f2939cSRui Paulo enum wpa_ctrl_req_type rtype,
461d4f2939cSRui Paulo const char *default_txt)
462d4f2939cSRui Paulo {
463d4f2939cSRui Paulo struct wpas_dbus_priv *iface;
464d4f2939cSRui Paulo DBusMessage *msg;
465d4f2939cSRui Paulo DBusMessageIter iter;
466d4f2939cSRui Paulo char net_obj_path[WPAS_DBUS_OBJECT_PATH_MAX];
467d4f2939cSRui Paulo const char *field, *txt = NULL, *net_ptr;
468d4f2939cSRui Paulo
469d4f2939cSRui Paulo iface = wpa_s->global->dbus;
470d4f2939cSRui Paulo
471d4f2939cSRui Paulo /* Do nothing if the control interface is not turned on */
472325151a3SRui Paulo if (iface == NULL || !wpa_s->dbus_new_path)
473d4f2939cSRui Paulo return;
474d4f2939cSRui Paulo
475d4f2939cSRui Paulo field = wpa_supplicant_ctrl_req_to_string(rtype, default_txt, &txt);
476d4f2939cSRui Paulo if (field == NULL)
477d4f2939cSRui Paulo return;
478d4f2939cSRui Paulo
479d4f2939cSRui Paulo msg = dbus_message_new_signal(wpa_s->dbus_new_path,
480d4f2939cSRui Paulo WPAS_DBUS_NEW_IFACE_INTERFACE,
481d4f2939cSRui Paulo "NetworkRequest");
482d4f2939cSRui Paulo if (msg == NULL)
483d4f2939cSRui Paulo return;
484d4f2939cSRui Paulo
485d4f2939cSRui Paulo os_snprintf(net_obj_path, WPAS_DBUS_OBJECT_PATH_MAX,
486d4f2939cSRui Paulo "%s/" WPAS_DBUS_NEW_NETWORKS_PART "/%u",
487d4f2939cSRui Paulo wpa_s->dbus_new_path, ssid->id);
488d4f2939cSRui Paulo net_ptr = &net_obj_path[0];
489d4f2939cSRui Paulo
490d4f2939cSRui Paulo dbus_message_iter_init_append(msg, &iter);
491d4f2939cSRui Paulo if (!dbus_message_iter_append_basic(&iter, DBUS_TYPE_OBJECT_PATH,
4925b9c547cSRui Paulo &net_ptr) ||
4935b9c547cSRui Paulo !dbus_message_iter_append_basic(&iter, DBUS_TYPE_STRING, &field) ||
4945b9c547cSRui Paulo !dbus_message_iter_append_basic(&iter, DBUS_TYPE_STRING, &txt))
495d4f2939cSRui Paulo wpa_printf(MSG_ERROR, "dbus: Failed to construct signal");
4965b9c547cSRui Paulo else
4975b9c547cSRui Paulo dbus_connection_send(iface->con, msg, NULL);
498d4f2939cSRui Paulo dbus_message_unref(msg);
499d4f2939cSRui Paulo }
500d4f2939cSRui Paulo
501d4f2939cSRui Paulo
502d4f2939cSRui Paulo /**
503d4f2939cSRui Paulo * wpas_dbus_signal_network_enabled_changed - Signals Enabled property changes
504d4f2939cSRui Paulo * @wpa_s: %wpa_supplicant network interface data
505d4f2939cSRui Paulo * @ssid: configured network which Enabled property has changed
506d4f2939cSRui Paulo *
507d4f2939cSRui Paulo * Sends PropertyChanged signals containing new value of Enabled property
508d4f2939cSRui Paulo * for specified network
509d4f2939cSRui Paulo */
wpas_dbus_signal_network_enabled_changed(struct wpa_supplicant * wpa_s,struct wpa_ssid * ssid)510d4f2939cSRui Paulo void wpas_dbus_signal_network_enabled_changed(struct wpa_supplicant *wpa_s,
511d4f2939cSRui Paulo struct wpa_ssid *ssid)
512d4f2939cSRui Paulo {
513d4f2939cSRui Paulo
514d4f2939cSRui Paulo char path[WPAS_DBUS_OBJECT_PATH_MAX];
5155b9c547cSRui Paulo
516325151a3SRui Paulo if (!wpa_s->dbus_new_path)
517325151a3SRui Paulo return;
518d4f2939cSRui Paulo os_snprintf(path, WPAS_DBUS_OBJECT_PATH_MAX,
519d4f2939cSRui Paulo "%s/" WPAS_DBUS_NEW_NETWORKS_PART "/%d",
520d4f2939cSRui Paulo wpa_s->dbus_new_path, ssid->id);
521d4f2939cSRui Paulo
522d4f2939cSRui Paulo wpa_dbus_mark_property_changed(wpa_s->global->dbus, path,
523d4f2939cSRui Paulo WPAS_DBUS_NEW_IFACE_NETWORK, "Enabled");
524d4f2939cSRui Paulo }
525d4f2939cSRui Paulo
526d4f2939cSRui Paulo
527d4f2939cSRui Paulo #ifdef CONFIG_WPS
528d4f2939cSRui Paulo
529d4f2939cSRui Paulo /**
530325151a3SRui Paulo * wpas_dbus_signal_wps_event_pbc_overlap - Signals PBC overlap WPS event
531325151a3SRui Paulo * @wpa_s: %wpa_supplicant network interface data
532325151a3SRui Paulo *
533325151a3SRui Paulo * Sends Event dbus signal with name "pbc-overlap" and empty dict as arguments
534325151a3SRui Paulo */
wpas_dbus_signal_wps_event_pbc_overlap(struct wpa_supplicant * wpa_s)535325151a3SRui Paulo void wpas_dbus_signal_wps_event_pbc_overlap(struct wpa_supplicant *wpa_s)
536325151a3SRui Paulo {
537325151a3SRui Paulo
538325151a3SRui Paulo DBusMessage *msg;
539325151a3SRui Paulo DBusMessageIter iter, dict_iter;
540325151a3SRui Paulo struct wpas_dbus_priv *iface;
541325151a3SRui Paulo char *key = "pbc-overlap";
542325151a3SRui Paulo
543325151a3SRui Paulo iface = wpa_s->global->dbus;
544325151a3SRui Paulo
545325151a3SRui Paulo /* Do nothing if the control interface is not turned on */
546325151a3SRui Paulo if (iface == NULL || !wpa_s->dbus_new_path)
547325151a3SRui Paulo return;
548325151a3SRui Paulo
549325151a3SRui Paulo msg = dbus_message_new_signal(wpa_s->dbus_new_path,
550325151a3SRui Paulo WPAS_DBUS_NEW_IFACE_WPS, "Event");
551325151a3SRui Paulo if (msg == NULL)
552325151a3SRui Paulo return;
553325151a3SRui Paulo
554325151a3SRui Paulo dbus_message_iter_init_append(msg, &iter);
555325151a3SRui Paulo
556325151a3SRui Paulo if (!dbus_message_iter_append_basic(&iter, DBUS_TYPE_STRING, &key) ||
557325151a3SRui Paulo !wpa_dbus_dict_open_write(&iter, &dict_iter) ||
558325151a3SRui Paulo !wpa_dbus_dict_close_write(&iter, &dict_iter))
559325151a3SRui Paulo wpa_printf(MSG_ERROR, "dbus: Failed to construct signal");
560325151a3SRui Paulo else
561325151a3SRui Paulo dbus_connection_send(iface->con, msg, NULL);
562325151a3SRui Paulo
563325151a3SRui Paulo dbus_message_unref(msg);
564325151a3SRui Paulo }
565325151a3SRui Paulo
566325151a3SRui Paulo
567325151a3SRui Paulo /**
568d4f2939cSRui Paulo * wpas_dbus_signal_wps_event_success - Signals Success WPS event
569d4f2939cSRui Paulo * @wpa_s: %wpa_supplicant network interface data
570d4f2939cSRui Paulo *
571d4f2939cSRui Paulo * Sends Event dbus signal with name "success" and empty dict as arguments
572d4f2939cSRui Paulo */
wpas_dbus_signal_wps_event_success(struct wpa_supplicant * wpa_s)573d4f2939cSRui Paulo void wpas_dbus_signal_wps_event_success(struct wpa_supplicant *wpa_s)
574d4f2939cSRui Paulo {
575d4f2939cSRui Paulo
576d4f2939cSRui Paulo DBusMessage *msg;
577d4f2939cSRui Paulo DBusMessageIter iter, dict_iter;
578d4f2939cSRui Paulo struct wpas_dbus_priv *iface;
579d4f2939cSRui Paulo char *key = "success";
580d4f2939cSRui Paulo
581d4f2939cSRui Paulo iface = wpa_s->global->dbus;
582d4f2939cSRui Paulo
583d4f2939cSRui Paulo /* Do nothing if the control interface is not turned on */
584325151a3SRui Paulo if (iface == NULL || !wpa_s->dbus_new_path)
585d4f2939cSRui Paulo return;
586d4f2939cSRui Paulo
587d4f2939cSRui Paulo msg = dbus_message_new_signal(wpa_s->dbus_new_path,
588d4f2939cSRui Paulo WPAS_DBUS_NEW_IFACE_WPS, "Event");
589d4f2939cSRui Paulo if (msg == NULL)
590d4f2939cSRui Paulo return;
591d4f2939cSRui Paulo
592d4f2939cSRui Paulo dbus_message_iter_init_append(msg, &iter);
593d4f2939cSRui Paulo
594d4f2939cSRui Paulo if (!dbus_message_iter_append_basic(&iter, DBUS_TYPE_STRING, &key) ||
595d4f2939cSRui Paulo !wpa_dbus_dict_open_write(&iter, &dict_iter) ||
596d4f2939cSRui Paulo !wpa_dbus_dict_close_write(&iter, &dict_iter))
597d4f2939cSRui Paulo wpa_printf(MSG_ERROR, "dbus: Failed to construct signal");
598d4f2939cSRui Paulo else
599d4f2939cSRui Paulo dbus_connection_send(iface->con, msg, NULL);
600d4f2939cSRui Paulo
601d4f2939cSRui Paulo dbus_message_unref(msg);
602d4f2939cSRui Paulo }
603d4f2939cSRui Paulo
604d4f2939cSRui Paulo
605d4f2939cSRui Paulo /**
606d4f2939cSRui Paulo * wpas_dbus_signal_wps_event_fail - Signals Fail WPS event
607d4f2939cSRui Paulo * @wpa_s: %wpa_supplicant network interface data
608325151a3SRui Paulo * @fail: WPS failure information
609d4f2939cSRui Paulo *
610d4f2939cSRui Paulo * Sends Event dbus signal with name "fail" and dictionary containing
611d4f2939cSRui Paulo * "msg field with fail message number (int32) as arguments
612d4f2939cSRui Paulo */
wpas_dbus_signal_wps_event_fail(struct wpa_supplicant * wpa_s,struct wps_event_fail * fail)613d4f2939cSRui Paulo void wpas_dbus_signal_wps_event_fail(struct wpa_supplicant *wpa_s,
614d4f2939cSRui Paulo struct wps_event_fail *fail)
615d4f2939cSRui Paulo {
616d4f2939cSRui Paulo
617d4f2939cSRui Paulo DBusMessage *msg;
618d4f2939cSRui Paulo DBusMessageIter iter, dict_iter;
619d4f2939cSRui Paulo struct wpas_dbus_priv *iface;
620d4f2939cSRui Paulo char *key = "fail";
621d4f2939cSRui Paulo
622d4f2939cSRui Paulo iface = wpa_s->global->dbus;
623d4f2939cSRui Paulo
624d4f2939cSRui Paulo /* Do nothing if the control interface is not turned on */
625325151a3SRui Paulo if (iface == NULL || !wpa_s->dbus_new_path)
626d4f2939cSRui Paulo return;
627d4f2939cSRui Paulo
628d4f2939cSRui Paulo msg = dbus_message_new_signal(wpa_s->dbus_new_path,
629d4f2939cSRui Paulo WPAS_DBUS_NEW_IFACE_WPS, "Event");
630d4f2939cSRui Paulo if (msg == NULL)
631d4f2939cSRui Paulo return;
632d4f2939cSRui Paulo
633d4f2939cSRui Paulo dbus_message_iter_init_append(msg, &iter);
634d4f2939cSRui Paulo
635d4f2939cSRui Paulo if (!dbus_message_iter_append_basic(&iter, DBUS_TYPE_STRING, &key) ||
636d4f2939cSRui Paulo !wpa_dbus_dict_open_write(&iter, &dict_iter) ||
637d4f2939cSRui Paulo !wpa_dbus_dict_append_int32(&dict_iter, "msg", fail->msg) ||
638325151a3SRui Paulo !wpa_dbus_dict_append_int32(&dict_iter, "config_error",
639325151a3SRui Paulo fail->config_error) ||
640325151a3SRui Paulo !wpa_dbus_dict_append_int32(&dict_iter, "error_indication",
641325151a3SRui Paulo fail->error_indication) ||
642d4f2939cSRui Paulo !wpa_dbus_dict_close_write(&iter, &dict_iter))
643d4f2939cSRui Paulo wpa_printf(MSG_ERROR, "dbus: Failed to construct signal");
644d4f2939cSRui Paulo else
645d4f2939cSRui Paulo dbus_connection_send(iface->con, msg, NULL);
646d4f2939cSRui Paulo
647d4f2939cSRui Paulo dbus_message_unref(msg);
648d4f2939cSRui Paulo }
649d4f2939cSRui Paulo
650d4f2939cSRui Paulo
651d4f2939cSRui Paulo /**
652d4f2939cSRui Paulo * wpas_dbus_signal_wps_event_m2d - Signals M2D WPS event
653d4f2939cSRui Paulo * @wpa_s: %wpa_supplicant network interface data
654325151a3SRui Paulo * @m2d: M2D event data information
655d4f2939cSRui Paulo *
656d4f2939cSRui Paulo * Sends Event dbus signal with name "m2d" and dictionary containing
657d4f2939cSRui Paulo * fields of wps_event_m2d structure.
658d4f2939cSRui Paulo */
wpas_dbus_signal_wps_event_m2d(struct wpa_supplicant * wpa_s,struct wps_event_m2d * m2d)659d4f2939cSRui Paulo void wpas_dbus_signal_wps_event_m2d(struct wpa_supplicant *wpa_s,
660d4f2939cSRui Paulo struct wps_event_m2d *m2d)
661d4f2939cSRui Paulo {
662d4f2939cSRui Paulo
663d4f2939cSRui Paulo DBusMessage *msg;
664d4f2939cSRui Paulo DBusMessageIter iter, dict_iter;
665d4f2939cSRui Paulo struct wpas_dbus_priv *iface;
666d4f2939cSRui Paulo char *key = "m2d";
667d4f2939cSRui Paulo
668d4f2939cSRui Paulo iface = wpa_s->global->dbus;
669d4f2939cSRui Paulo
670d4f2939cSRui Paulo /* Do nothing if the control interface is not turned on */
671325151a3SRui Paulo if (iface == NULL || !wpa_s->dbus_new_path)
672d4f2939cSRui Paulo return;
673d4f2939cSRui Paulo
674d4f2939cSRui Paulo msg = dbus_message_new_signal(wpa_s->dbus_new_path,
675d4f2939cSRui Paulo WPAS_DBUS_NEW_IFACE_WPS, "Event");
676d4f2939cSRui Paulo if (msg == NULL)
677d4f2939cSRui Paulo return;
678d4f2939cSRui Paulo
679d4f2939cSRui Paulo dbus_message_iter_init_append(msg, &iter);
680d4f2939cSRui Paulo
681d4f2939cSRui Paulo if (!dbus_message_iter_append_basic(&iter, DBUS_TYPE_STRING, &key) ||
682d4f2939cSRui Paulo !wpa_dbus_dict_open_write(&iter, &dict_iter) ||
683d4f2939cSRui Paulo !wpa_dbus_dict_append_uint16(&dict_iter, "config_methods",
684d4f2939cSRui Paulo m2d->config_methods) ||
685d4f2939cSRui Paulo !wpa_dbus_dict_append_byte_array(&dict_iter, "manufacturer",
686d4f2939cSRui Paulo (const char *) m2d->manufacturer,
687d4f2939cSRui Paulo m2d->manufacturer_len) ||
688d4f2939cSRui Paulo !wpa_dbus_dict_append_byte_array(&dict_iter, "model_name",
689d4f2939cSRui Paulo (const char *) m2d->model_name,
690d4f2939cSRui Paulo m2d->model_name_len) ||
691d4f2939cSRui Paulo !wpa_dbus_dict_append_byte_array(&dict_iter, "model_number",
692d4f2939cSRui Paulo (const char *) m2d->model_number,
693d4f2939cSRui Paulo m2d->model_number_len) ||
694d4f2939cSRui Paulo !wpa_dbus_dict_append_byte_array(&dict_iter, "serial_number",
695d4f2939cSRui Paulo (const char *)
696d4f2939cSRui Paulo m2d->serial_number,
697d4f2939cSRui Paulo m2d->serial_number_len) ||
698d4f2939cSRui Paulo !wpa_dbus_dict_append_byte_array(&dict_iter, "dev_name",
699d4f2939cSRui Paulo (const char *) m2d->dev_name,
700d4f2939cSRui Paulo m2d->dev_name_len) ||
701d4f2939cSRui Paulo !wpa_dbus_dict_append_byte_array(&dict_iter, "primary_dev_type",
702d4f2939cSRui Paulo (const char *)
703d4f2939cSRui Paulo m2d->primary_dev_type, 8) ||
704d4f2939cSRui Paulo !wpa_dbus_dict_append_uint16(&dict_iter, "config_error",
705d4f2939cSRui Paulo m2d->config_error) ||
706d4f2939cSRui Paulo !wpa_dbus_dict_append_uint16(&dict_iter, "dev_password_id",
707d4f2939cSRui Paulo m2d->dev_password_id) ||
708d4f2939cSRui Paulo !wpa_dbus_dict_close_write(&iter, &dict_iter))
709d4f2939cSRui Paulo wpa_printf(MSG_ERROR, "dbus: Failed to construct signal");
710d4f2939cSRui Paulo else
711d4f2939cSRui Paulo dbus_connection_send(iface->con, msg, NULL);
712d4f2939cSRui Paulo
713d4f2939cSRui Paulo dbus_message_unref(msg);
714d4f2939cSRui Paulo }
715d4f2939cSRui Paulo
716d4f2939cSRui Paulo
717d4f2939cSRui Paulo /**
718d4f2939cSRui Paulo * wpas_dbus_signal_wps_cred - Signals new credentials
719d4f2939cSRui Paulo * @wpa_s: %wpa_supplicant network interface data
720325151a3SRui Paulo * @cred: WPS Credential information
721d4f2939cSRui Paulo *
722d4f2939cSRui Paulo * Sends signal with credentials in directory argument
723d4f2939cSRui Paulo */
wpas_dbus_signal_wps_cred(struct wpa_supplicant * wpa_s,const struct wps_credential * cred)724d4f2939cSRui Paulo void wpas_dbus_signal_wps_cred(struct wpa_supplicant *wpa_s,
725d4f2939cSRui Paulo const struct wps_credential *cred)
726d4f2939cSRui Paulo {
727d4f2939cSRui Paulo DBusMessage *msg;
728d4f2939cSRui Paulo DBusMessageIter iter, dict_iter;
729d4f2939cSRui Paulo struct wpas_dbus_priv *iface;
7305b9c547cSRui Paulo char *auth_type[5]; /* we have five possible authentication types */
731d4f2939cSRui Paulo int at_num = 0;
7325b9c547cSRui Paulo char *encr_type[3]; /* we have three possible encryption types */
733d4f2939cSRui Paulo int et_num = 0;
734d4f2939cSRui Paulo
735d4f2939cSRui Paulo iface = wpa_s->global->dbus;
736d4f2939cSRui Paulo
737d4f2939cSRui Paulo /* Do nothing if the control interface is not turned on */
738325151a3SRui Paulo if (iface == NULL || !wpa_s->dbus_new_path)
739d4f2939cSRui Paulo return;
740d4f2939cSRui Paulo
741d4f2939cSRui Paulo msg = dbus_message_new_signal(wpa_s->dbus_new_path,
742d4f2939cSRui Paulo WPAS_DBUS_NEW_IFACE_WPS,
743d4f2939cSRui Paulo "Credentials");
744d4f2939cSRui Paulo if (msg == NULL)
745d4f2939cSRui Paulo return;
746d4f2939cSRui Paulo
747d4f2939cSRui Paulo dbus_message_iter_init_append(msg, &iter);
748d4f2939cSRui Paulo if (!wpa_dbus_dict_open_write(&iter, &dict_iter))
749d4f2939cSRui Paulo goto nomem;
750d4f2939cSRui Paulo
751d4f2939cSRui Paulo if (cred->auth_type & WPS_AUTH_OPEN)
752d4f2939cSRui Paulo auth_type[at_num++] = "open";
753c1d255d3SCy Schubert #ifndef CONFIG_NO_TKIP
754d4f2939cSRui Paulo if (cred->auth_type & WPS_AUTH_WPAPSK)
755d4f2939cSRui Paulo auth_type[at_num++] = "wpa-psk";
756d4f2939cSRui Paulo if (cred->auth_type & WPS_AUTH_WPA)
757d4f2939cSRui Paulo auth_type[at_num++] = "wpa-eap";
758c1d255d3SCy Schubert #endif /* CONFIG_NO_TKIP */
759d4f2939cSRui Paulo if (cred->auth_type & WPS_AUTH_WPA2)
760d4f2939cSRui Paulo auth_type[at_num++] = "wpa2-eap";
761d4f2939cSRui Paulo if (cred->auth_type & WPS_AUTH_WPA2PSK)
7625b9c547cSRui Paulo auth_type[at_num++] = "wpa2-psk";
763d4f2939cSRui Paulo
764d4f2939cSRui Paulo if (cred->encr_type & WPS_ENCR_NONE)
765d4f2939cSRui Paulo encr_type[et_num++] = "none";
766c1d255d3SCy Schubert #ifndef CONFIG_NO_TKIP
767d4f2939cSRui Paulo if (cred->encr_type & WPS_ENCR_TKIP)
768d4f2939cSRui Paulo encr_type[et_num++] = "tkip";
769c1d255d3SCy Schubert #endif /* CONFIG_NO_TKIP */
770d4f2939cSRui Paulo if (cred->encr_type & WPS_ENCR_AES)
771d4f2939cSRui Paulo encr_type[et_num++] = "aes";
772d4f2939cSRui Paulo
7735b9c547cSRui Paulo if ((wpa_s->current_ssid &&
7745b9c547cSRui Paulo !wpa_dbus_dict_append_byte_array(
775d4f2939cSRui Paulo &dict_iter, "BSSID",
7765b9c547cSRui Paulo (const char *) wpa_s->current_ssid->bssid, ETH_ALEN)) ||
7775b9c547cSRui Paulo !wpa_dbus_dict_append_byte_array(&dict_iter, "SSID",
778d4f2939cSRui Paulo (const char *) cred->ssid,
779d4f2939cSRui Paulo cred->ssid_len) ||
780d4f2939cSRui Paulo !wpa_dbus_dict_append_string_array(&dict_iter, "AuthType",
781d4f2939cSRui Paulo (const char **) auth_type,
782d4f2939cSRui Paulo at_num) ||
783d4f2939cSRui Paulo !wpa_dbus_dict_append_string_array(&dict_iter, "EncrType",
784d4f2939cSRui Paulo (const char **) encr_type,
785d4f2939cSRui Paulo et_num) ||
786d4f2939cSRui Paulo !wpa_dbus_dict_append_byte_array(&dict_iter, "Key",
787d4f2939cSRui Paulo (const char *) cred->key,
788d4f2939cSRui Paulo cred->key_len) ||
789d4f2939cSRui Paulo !wpa_dbus_dict_append_uint32(&dict_iter, "KeyIndex",
790d4f2939cSRui Paulo cred->key_idx) ||
791d4f2939cSRui Paulo !wpa_dbus_dict_close_write(&iter, &dict_iter))
792d4f2939cSRui Paulo goto nomem;
793d4f2939cSRui Paulo
794d4f2939cSRui Paulo dbus_connection_send(iface->con, msg, NULL);
795d4f2939cSRui Paulo
796d4f2939cSRui Paulo nomem:
797d4f2939cSRui Paulo dbus_message_unref(msg);
798d4f2939cSRui Paulo }
799d4f2939cSRui Paulo
800d4f2939cSRui Paulo #endif /* CONFIG_WPS */
801d4f2939cSRui Paulo
80285732ac8SCy Schubert
80385732ac8SCy Schubert #ifdef CONFIG_MESH
80485732ac8SCy Schubert
wpas_dbus_signal_mesh_group_started(struct wpa_supplicant * wpa_s,struct wpa_ssid * ssid)80585732ac8SCy Schubert void wpas_dbus_signal_mesh_group_started(struct wpa_supplicant *wpa_s,
80685732ac8SCy Schubert struct wpa_ssid *ssid)
80785732ac8SCy Schubert {
80885732ac8SCy Schubert struct wpas_dbus_priv *iface;
80985732ac8SCy Schubert DBusMessage *msg;
81085732ac8SCy Schubert DBusMessageIter iter, dict_iter;
81185732ac8SCy Schubert
81285732ac8SCy Schubert iface = wpa_s->global->dbus;
81385732ac8SCy Schubert
81485732ac8SCy Schubert /* Do nothing if the control interface is not turned on */
81585732ac8SCy Schubert if (!iface || !wpa_s->dbus_new_path)
81685732ac8SCy Schubert return;
81785732ac8SCy Schubert
81885732ac8SCy Schubert msg = dbus_message_new_signal(wpa_s->dbus_new_path,
81985732ac8SCy Schubert WPAS_DBUS_NEW_IFACE_MESH,
82085732ac8SCy Schubert "MeshGroupStarted");
82185732ac8SCy Schubert if (!msg)
82285732ac8SCy Schubert return;
82385732ac8SCy Schubert
82485732ac8SCy Schubert dbus_message_iter_init_append(msg, &iter);
82585732ac8SCy Schubert if (!wpa_dbus_dict_open_write(&iter, &dict_iter) ||
82685732ac8SCy Schubert !wpa_dbus_dict_append_byte_array(&dict_iter, "SSID",
82785732ac8SCy Schubert (const char *) ssid->ssid,
82885732ac8SCy Schubert ssid->ssid_len) ||
82985732ac8SCy Schubert !wpa_dbus_dict_close_write(&iter, &dict_iter))
83085732ac8SCy Schubert wpa_printf(MSG_ERROR, "dbus: Failed to construct signal");
83185732ac8SCy Schubert else
83285732ac8SCy Schubert dbus_connection_send(iface->con, msg, NULL);
83385732ac8SCy Schubert dbus_message_unref(msg);
83485732ac8SCy Schubert }
83585732ac8SCy Schubert
83685732ac8SCy Schubert
wpas_dbus_signal_mesh_group_removed(struct wpa_supplicant * wpa_s,const u8 * meshid,u8 meshid_len,int reason)83785732ac8SCy Schubert void wpas_dbus_signal_mesh_group_removed(struct wpa_supplicant *wpa_s,
83885732ac8SCy Schubert const u8 *meshid, u8 meshid_len,
83985732ac8SCy Schubert int reason)
84085732ac8SCy Schubert {
84185732ac8SCy Schubert struct wpas_dbus_priv *iface;
84285732ac8SCy Schubert DBusMessage *msg;
84385732ac8SCy Schubert DBusMessageIter iter, dict_iter;
84485732ac8SCy Schubert
84585732ac8SCy Schubert iface = wpa_s->global->dbus;
84685732ac8SCy Schubert
84785732ac8SCy Schubert /* Do nothing if the control interface is not turned on */
84885732ac8SCy Schubert if (!iface || !wpa_s->dbus_new_path)
84985732ac8SCy Schubert return;
85085732ac8SCy Schubert
85185732ac8SCy Schubert msg = dbus_message_new_signal(wpa_s->dbus_new_path,
85285732ac8SCy Schubert WPAS_DBUS_NEW_IFACE_MESH,
85385732ac8SCy Schubert "MeshGroupRemoved");
85485732ac8SCy Schubert if (!msg)
85585732ac8SCy Schubert return;
85685732ac8SCy Schubert
85785732ac8SCy Schubert dbus_message_iter_init_append(msg, &iter);
85885732ac8SCy Schubert if (!wpa_dbus_dict_open_write(&iter, &dict_iter) ||
85985732ac8SCy Schubert !wpa_dbus_dict_append_byte_array(&dict_iter, "SSID",
86085732ac8SCy Schubert (const char *) meshid,
86185732ac8SCy Schubert meshid_len) ||
86285732ac8SCy Schubert !wpa_dbus_dict_append_int32(&dict_iter, "DisconnectReason",
86385732ac8SCy Schubert reason) ||
86485732ac8SCy Schubert !wpa_dbus_dict_close_write(&iter, &dict_iter))
86585732ac8SCy Schubert wpa_printf(MSG_ERROR, "dbus: Failed to construct signal");
86685732ac8SCy Schubert else
86785732ac8SCy Schubert dbus_connection_send(iface->con, msg, NULL);
86885732ac8SCy Schubert dbus_message_unref(msg);
86985732ac8SCy Schubert }
87085732ac8SCy Schubert
87185732ac8SCy Schubert
wpas_dbus_signal_mesh_peer_connected(struct wpa_supplicant * wpa_s,const u8 * peer_addr)87285732ac8SCy Schubert void wpas_dbus_signal_mesh_peer_connected(struct wpa_supplicant *wpa_s,
87385732ac8SCy Schubert const u8 *peer_addr)
87485732ac8SCy Schubert {
87585732ac8SCy Schubert struct wpas_dbus_priv *iface;
87685732ac8SCy Schubert DBusMessage *msg;
87785732ac8SCy Schubert DBusMessageIter iter, dict_iter;
87885732ac8SCy Schubert
87985732ac8SCy Schubert iface = wpa_s->global->dbus;
88085732ac8SCy Schubert
88185732ac8SCy Schubert /* Do nothing if the control interface is not turned on */
88285732ac8SCy Schubert if (!iface || !wpa_s->dbus_new_path)
88385732ac8SCy Schubert return;
88485732ac8SCy Schubert
88585732ac8SCy Schubert msg = dbus_message_new_signal(wpa_s->dbus_new_path,
88685732ac8SCy Schubert WPAS_DBUS_NEW_IFACE_MESH,
88785732ac8SCy Schubert "MeshPeerConnected");
88885732ac8SCy Schubert if (!msg)
88985732ac8SCy Schubert return;
89085732ac8SCy Schubert
89185732ac8SCy Schubert dbus_message_iter_init_append(msg, &iter);
89285732ac8SCy Schubert if (!wpa_dbus_dict_open_write(&iter, &dict_iter) ||
89385732ac8SCy Schubert !wpa_dbus_dict_append_byte_array(&dict_iter, "PeerAddress",
89485732ac8SCy Schubert (const char *) peer_addr,
89585732ac8SCy Schubert ETH_ALEN) ||
89685732ac8SCy Schubert !wpa_dbus_dict_close_write(&iter, &dict_iter))
89785732ac8SCy Schubert wpa_printf(MSG_ERROR, "dbus: Failed to construct signal");
89885732ac8SCy Schubert else
89985732ac8SCy Schubert dbus_connection_send(iface->con, msg, NULL);
90085732ac8SCy Schubert dbus_message_unref(msg);
90185732ac8SCy Schubert }
90285732ac8SCy Schubert
90385732ac8SCy Schubert
wpas_dbus_signal_mesh_peer_disconnected(struct wpa_supplicant * wpa_s,const u8 * peer_addr,int reason)90485732ac8SCy Schubert void wpas_dbus_signal_mesh_peer_disconnected(struct wpa_supplicant *wpa_s,
90585732ac8SCy Schubert const u8 *peer_addr, int reason)
90685732ac8SCy Schubert {
90785732ac8SCy Schubert struct wpas_dbus_priv *iface;
90885732ac8SCy Schubert DBusMessage *msg;
90985732ac8SCy Schubert DBusMessageIter iter, dict_iter;
91085732ac8SCy Schubert
91185732ac8SCy Schubert iface = wpa_s->global->dbus;
91285732ac8SCy Schubert
91385732ac8SCy Schubert /* Do nothing if the control interface is not turned on */
91485732ac8SCy Schubert if (!iface || !wpa_s->dbus_new_path)
91585732ac8SCy Schubert return;
91685732ac8SCy Schubert
91785732ac8SCy Schubert msg = dbus_message_new_signal(wpa_s->dbus_new_path,
91885732ac8SCy Schubert WPAS_DBUS_NEW_IFACE_MESH,
91985732ac8SCy Schubert "MeshPeerDisconnected");
92085732ac8SCy Schubert if (!msg)
92185732ac8SCy Schubert return;
92285732ac8SCy Schubert
92385732ac8SCy Schubert dbus_message_iter_init_append(msg, &iter);
92485732ac8SCy Schubert if (!wpa_dbus_dict_open_write(&iter, &dict_iter) ||
92585732ac8SCy Schubert !wpa_dbus_dict_append_byte_array(&dict_iter, "PeerAddress",
92685732ac8SCy Schubert (const char *) peer_addr,
92785732ac8SCy Schubert ETH_ALEN) ||
92885732ac8SCy Schubert !wpa_dbus_dict_append_int32(&dict_iter, "DisconnectReason",
92985732ac8SCy Schubert reason) ||
93085732ac8SCy Schubert !wpa_dbus_dict_close_write(&iter, &dict_iter))
93185732ac8SCy Schubert wpa_printf(MSG_ERROR, "dbus: Failed to construct signal");
93285732ac8SCy Schubert else
93385732ac8SCy Schubert dbus_connection_send(iface->con, msg, NULL);
93485732ac8SCy Schubert dbus_message_unref(msg);
93585732ac8SCy Schubert }
93685732ac8SCy Schubert
93785732ac8SCy Schubert #endif /* CONFIG_MESH */
93885732ac8SCy Schubert
93985732ac8SCy Schubert
94032a95656SCy Schubert #ifdef CONFIG_INTERWORKING
94132a95656SCy Schubert
wpas_dbus_signal_interworking_ap_added(struct wpa_supplicant * wpa_s,struct wpa_bss * bss,struct wpa_cred * cred,const char * type,int excluded,int bh,int bss_load,int conn_capab)94232a95656SCy Schubert void wpas_dbus_signal_interworking_ap_added(struct wpa_supplicant *wpa_s,
94332a95656SCy Schubert struct wpa_bss *bss,
94432a95656SCy Schubert struct wpa_cred *cred,
94532a95656SCy Schubert const char *type,
94632a95656SCy Schubert int excluded,
94732a95656SCy Schubert int bh,
94832a95656SCy Schubert int bss_load,
94932a95656SCy Schubert int conn_capab)
95032a95656SCy Schubert {
95132a95656SCy Schubert struct wpas_dbus_priv *iface;
95232a95656SCy Schubert DBusMessage *msg;
95332a95656SCy Schubert DBusMessageIter iter, dict_iter;
95432a95656SCy Schubert char bss_path[WPAS_DBUS_OBJECT_PATH_MAX], *bss_obj_path;
95532a95656SCy Schubert char cred_path[WPAS_DBUS_OBJECT_PATH_MAX], *cred_obj_path;
95632a95656SCy Schubert
95732a95656SCy Schubert iface = wpa_s->global->dbus;
95832a95656SCy Schubert
95932a95656SCy Schubert /* Do nothing if the control interface is not turned on */
96032a95656SCy Schubert if (!iface || !wpa_s->dbus_new_path)
96132a95656SCy Schubert return;
96232a95656SCy Schubert
96332a95656SCy Schubert msg = dbus_message_new_signal(wpa_s->dbus_new_path,
96432a95656SCy Schubert WPAS_DBUS_NEW_IFACE_INTERFACE,
96532a95656SCy Schubert "InterworkingAPAdded");
96632a95656SCy Schubert if (!msg)
96732a95656SCy Schubert return;
96832a95656SCy Schubert
96932a95656SCy Schubert os_snprintf(bss_path, WPAS_DBUS_OBJECT_PATH_MAX,
97032a95656SCy Schubert "%s/" WPAS_DBUS_NEW_BSSIDS_PART "/%u",
97132a95656SCy Schubert wpa_s->dbus_new_path, bss->id);
97232a95656SCy Schubert bss_obj_path = bss_path;
97332a95656SCy Schubert
97432a95656SCy Schubert os_snprintf(cred_path, WPAS_DBUS_OBJECT_PATH_MAX,
97532a95656SCy Schubert "%s/" WPAS_DBUS_NEW_CREDENTIALS_PART "/%u",
97632a95656SCy Schubert wpa_s->dbus_new_path, cred->id);
97732a95656SCy Schubert cred_obj_path = cred_path;
97832a95656SCy Schubert
97932a95656SCy Schubert dbus_message_iter_init_append(msg, &iter);
98032a95656SCy Schubert if (!dbus_message_iter_append_basic(&iter, DBUS_TYPE_OBJECT_PATH,
98132a95656SCy Schubert &bss_obj_path) ||
98232a95656SCy Schubert !dbus_message_iter_append_basic(&iter, DBUS_TYPE_OBJECT_PATH,
98332a95656SCy Schubert &cred_obj_path) ||
98432a95656SCy Schubert !wpa_dbus_dict_open_write(&iter, &dict_iter) ||
98532a95656SCy Schubert !wpa_dbus_dict_append_string(&dict_iter, "type", type) ||
98632a95656SCy Schubert !wpa_dbus_dict_append_int32(&dict_iter, "excluded", excluded) ||
98732a95656SCy Schubert !wpa_dbus_dict_append_int32(&dict_iter, "priority",
98832a95656SCy Schubert cred->priority) ||
98932a95656SCy Schubert !wpa_dbus_dict_append_int32(&dict_iter, "sp_priority",
99032a95656SCy Schubert cred->sp_priority) ||
99132a95656SCy Schubert !wpa_dbus_dict_append_int32(&dict_iter, "below_min_backhaul", bh) ||
99232a95656SCy Schubert !wpa_dbus_dict_append_int32(&dict_iter, "over_max_bss_load",
99332a95656SCy Schubert bss_load) ||
99432a95656SCy Schubert !wpa_dbus_dict_append_int32(&dict_iter, "conn_capab_missing",
99532a95656SCy Schubert conn_capab) ||
99632a95656SCy Schubert !wpa_dbus_dict_close_write(&iter, &dict_iter))
99732a95656SCy Schubert wpa_printf(MSG_ERROR, "dbus: Failed to construct signal");
99832a95656SCy Schubert else
99932a95656SCy Schubert dbus_connection_send(iface->con, msg, NULL);
100032a95656SCy Schubert dbus_message_unref(msg);
100132a95656SCy Schubert }
100232a95656SCy Schubert
100332a95656SCy Schubert
wpas_dbus_signal_interworking_select_done(struct wpa_supplicant * wpa_s)100432a95656SCy Schubert void wpas_dbus_signal_interworking_select_done(struct wpa_supplicant *wpa_s)
100532a95656SCy Schubert {
100632a95656SCy Schubert struct wpas_dbus_priv *iface;
100732a95656SCy Schubert DBusMessage *msg;
100832a95656SCy Schubert
100932a95656SCy Schubert iface = wpa_s->global->dbus;
101032a95656SCy Schubert
101132a95656SCy Schubert /* Do nothing if the control interface is not turned on */
101232a95656SCy Schubert if (!iface || !wpa_s->dbus_new_path)
101332a95656SCy Schubert return;
101432a95656SCy Schubert
101532a95656SCy Schubert msg = dbus_message_new_signal(wpa_s->dbus_new_path,
101632a95656SCy Schubert WPAS_DBUS_NEW_IFACE_INTERFACE,
101732a95656SCy Schubert "InterworkingSelectDone");
101832a95656SCy Schubert if (!msg)
101932a95656SCy Schubert return;
102032a95656SCy Schubert
102132a95656SCy Schubert dbus_connection_send(iface->con, msg, NULL);
102232a95656SCy Schubert
102332a95656SCy Schubert dbus_message_unref(msg);
102432a95656SCy Schubert }
102532a95656SCy Schubert
1026*a90b9d01SCy Schubert
wpas_dbus_signal_anqp_query_done(struct wpa_supplicant * wpa_s,const u8 * dst,const char * result)1027*a90b9d01SCy Schubert void wpas_dbus_signal_anqp_query_done(struct wpa_supplicant *wpa_s,
1028*a90b9d01SCy Schubert const u8 *dst, const char *result)
1029*a90b9d01SCy Schubert {
1030*a90b9d01SCy Schubert struct wpas_dbus_priv *iface;
1031*a90b9d01SCy Schubert DBusMessage *msg;
1032*a90b9d01SCy Schubert DBusMessageIter iter;
1033*a90b9d01SCy Schubert char addr[WPAS_DBUS_OBJECT_PATH_MAX], *bssid;
1034*a90b9d01SCy Schubert
1035*a90b9d01SCy Schubert os_snprintf(addr, WPAS_DBUS_OBJECT_PATH_MAX, MACSTR, MAC2STR(dst));
1036*a90b9d01SCy Schubert bssid = addr;
1037*a90b9d01SCy Schubert
1038*a90b9d01SCy Schubert iface = wpa_s->global->dbus;
1039*a90b9d01SCy Schubert
1040*a90b9d01SCy Schubert /* Do nothing if the control interface is not turned on */
1041*a90b9d01SCy Schubert if (!iface || !wpa_s->dbus_new_path)
1042*a90b9d01SCy Schubert return;
1043*a90b9d01SCy Schubert
1044*a90b9d01SCy Schubert msg = dbus_message_new_signal(wpa_s->dbus_new_path,
1045*a90b9d01SCy Schubert WPAS_DBUS_NEW_IFACE_INTERFACE,
1046*a90b9d01SCy Schubert "ANQPQueryDone");
1047*a90b9d01SCy Schubert if (!msg)
1048*a90b9d01SCy Schubert return;
1049*a90b9d01SCy Schubert
1050*a90b9d01SCy Schubert dbus_message_iter_init_append(msg, &iter);
1051*a90b9d01SCy Schubert
1052*a90b9d01SCy Schubert if (!dbus_message_iter_append_basic(&iter, DBUS_TYPE_STRING, &bssid) ||
1053*a90b9d01SCy Schubert !dbus_message_iter_append_basic(&iter, DBUS_TYPE_STRING, &result))
1054*a90b9d01SCy Schubert wpa_printf(MSG_ERROR, "dbus: Failed to construct signal");
1055*a90b9d01SCy Schubert else
1056*a90b9d01SCy Schubert dbus_connection_send(iface->con, msg, NULL);
1057*a90b9d01SCy Schubert dbus_message_unref(msg);
1058*a90b9d01SCy Schubert }
1059*a90b9d01SCy Schubert
106032a95656SCy Schubert #endif /* CONFIG_INTERWORKING */
106132a95656SCy Schubert
106232a95656SCy Schubert
wpas_dbus_signal_certification(struct wpa_supplicant * wpa_s,int depth,const char * subject,const char * altsubject[],int num_altsubject,const char * cert_hash,const struct wpabuf * cert)1063d4f2939cSRui Paulo void wpas_dbus_signal_certification(struct wpa_supplicant *wpa_s,
1064d4f2939cSRui Paulo int depth, const char *subject,
10655b9c547cSRui Paulo const char *altsubject[],
10665b9c547cSRui Paulo int num_altsubject,
1067d4f2939cSRui Paulo const char *cert_hash,
1068d4f2939cSRui Paulo const struct wpabuf *cert)
1069d4f2939cSRui Paulo {
1070d4f2939cSRui Paulo struct wpas_dbus_priv *iface;
1071d4f2939cSRui Paulo DBusMessage *msg;
1072d4f2939cSRui Paulo DBusMessageIter iter, dict_iter;
1073d4f2939cSRui Paulo
1074d4f2939cSRui Paulo iface = wpa_s->global->dbus;
1075d4f2939cSRui Paulo
1076d4f2939cSRui Paulo /* Do nothing if the control interface is not turned on */
1077325151a3SRui Paulo if (iface == NULL || !wpa_s->dbus_new_path)
1078d4f2939cSRui Paulo return;
1079d4f2939cSRui Paulo
1080d4f2939cSRui Paulo msg = dbus_message_new_signal(wpa_s->dbus_new_path,
1081d4f2939cSRui Paulo WPAS_DBUS_NEW_IFACE_INTERFACE,
1082d4f2939cSRui Paulo "Certification");
1083d4f2939cSRui Paulo if (msg == NULL)
1084d4f2939cSRui Paulo return;
1085d4f2939cSRui Paulo
1086d4f2939cSRui Paulo dbus_message_iter_init_append(msg, &iter);
10875b9c547cSRui Paulo if (!wpa_dbus_dict_open_write(&iter, &dict_iter) ||
10885b9c547cSRui Paulo !wpa_dbus_dict_append_uint32(&dict_iter, "depth", depth) ||
10895b9c547cSRui Paulo !wpa_dbus_dict_append_string(&dict_iter, "subject", subject) ||
10905b9c547cSRui Paulo (altsubject && num_altsubject &&
10915b9c547cSRui Paulo !wpa_dbus_dict_append_string_array(&dict_iter, "altsubject",
10925b9c547cSRui Paulo altsubject, num_altsubject)) ||
10935b9c547cSRui Paulo (cert_hash &&
10945b9c547cSRui Paulo !wpa_dbus_dict_append_string(&dict_iter, "cert_hash",
10955b9c547cSRui Paulo cert_hash)) ||
10965b9c547cSRui Paulo (cert &&
1097d4f2939cSRui Paulo !wpa_dbus_dict_append_byte_array(&dict_iter, "cert",
1098d4f2939cSRui Paulo wpabuf_head(cert),
10995b9c547cSRui Paulo wpabuf_len(cert))) ||
11005b9c547cSRui Paulo !wpa_dbus_dict_close_write(&iter, &dict_iter))
11015b9c547cSRui Paulo wpa_printf(MSG_ERROR, "dbus: Failed to construct signal");
11025b9c547cSRui Paulo else
1103d4f2939cSRui Paulo dbus_connection_send(iface->con, msg, NULL);
1104d4f2939cSRui Paulo dbus_message_unref(msg);
1105d4f2939cSRui Paulo }
1106d4f2939cSRui Paulo
1107d4f2939cSRui Paulo
wpas_dbus_signal_eap_status(struct wpa_supplicant * wpa_s,const char * status,const char * parameter)1108d4f2939cSRui Paulo void wpas_dbus_signal_eap_status(struct wpa_supplicant *wpa_s,
1109d4f2939cSRui Paulo const char *status, const char *parameter)
1110d4f2939cSRui Paulo {
1111d4f2939cSRui Paulo struct wpas_dbus_priv *iface;
1112d4f2939cSRui Paulo DBusMessage *msg;
1113d4f2939cSRui Paulo DBusMessageIter iter;
1114d4f2939cSRui Paulo
1115d4f2939cSRui Paulo iface = wpa_s->global->dbus;
1116d4f2939cSRui Paulo
1117d4f2939cSRui Paulo /* Do nothing if the control interface is not turned on */
1118325151a3SRui Paulo if (iface == NULL || !wpa_s->dbus_new_path)
1119d4f2939cSRui Paulo return;
1120d4f2939cSRui Paulo
1121d4f2939cSRui Paulo msg = dbus_message_new_signal(wpa_s->dbus_new_path,
1122d4f2939cSRui Paulo WPAS_DBUS_NEW_IFACE_INTERFACE,
1123d4f2939cSRui Paulo "EAP");
1124d4f2939cSRui Paulo if (msg == NULL)
1125d4f2939cSRui Paulo return;
1126d4f2939cSRui Paulo
1127d4f2939cSRui Paulo dbus_message_iter_init_append(msg, &iter);
1128d4f2939cSRui Paulo
11295b9c547cSRui Paulo if (!dbus_message_iter_append_basic(&iter, DBUS_TYPE_STRING, &status) ||
1130d4f2939cSRui Paulo !dbus_message_iter_append_basic(&iter, DBUS_TYPE_STRING,
1131d4f2939cSRui Paulo ¶meter))
11325b9c547cSRui Paulo wpa_printf(MSG_ERROR, "dbus: Failed to construct signal");
11335b9c547cSRui Paulo else
1134d4f2939cSRui Paulo dbus_connection_send(iface->con, msg, NULL);
1135d4f2939cSRui Paulo dbus_message_unref(msg);
1136d4f2939cSRui Paulo }
1137d4f2939cSRui Paulo
1138d4f2939cSRui Paulo
wpas_dbus_signal_psk_mismatch(struct wpa_supplicant * wpa_s)1139*a90b9d01SCy Schubert void wpas_dbus_signal_psk_mismatch(struct wpa_supplicant *wpa_s)
1140*a90b9d01SCy Schubert {
1141*a90b9d01SCy Schubert struct wpas_dbus_priv *iface;
1142*a90b9d01SCy Schubert DBusMessage *msg;
1143*a90b9d01SCy Schubert
1144*a90b9d01SCy Schubert iface = wpa_s->global->dbus;
1145*a90b9d01SCy Schubert
1146*a90b9d01SCy Schubert /* Do nothing if the control interface is not turned on */
1147*a90b9d01SCy Schubert if (!iface || !wpa_s->dbus_new_path)
1148*a90b9d01SCy Schubert return;
1149*a90b9d01SCy Schubert
1150*a90b9d01SCy Schubert msg = dbus_message_new_signal(wpa_s->dbus_new_path,
1151*a90b9d01SCy Schubert WPAS_DBUS_NEW_IFACE_INTERFACE,
1152*a90b9d01SCy Schubert "PskMismatch");
1153*a90b9d01SCy Schubert if (!msg)
1154*a90b9d01SCy Schubert return;
1155*a90b9d01SCy Schubert
1156*a90b9d01SCy Schubert dbus_connection_send(iface->con, msg, NULL);
1157*a90b9d01SCy Schubert
1158*a90b9d01SCy Schubert dbus_message_unref(msg);
1159*a90b9d01SCy Schubert }
1160*a90b9d01SCy Schubert
1161*a90b9d01SCy Schubert
11625b9c547cSRui Paulo /**
11635b9c547cSRui Paulo * wpas_dbus_signal_sta - Send a station related event signal
11645b9c547cSRui Paulo * @wpa_s: %wpa_supplicant network interface data
11655b9c547cSRui Paulo * @sta: station mac address
11665b9c547cSRui Paulo * @sig_name: signal name - StaAuthorized or StaDeauthorized
11675b9c547cSRui Paulo *
11685b9c547cSRui Paulo * Notify listeners about event related with station
11695b9c547cSRui Paulo */
wpas_dbus_signal_sta(struct wpa_supplicant * wpa_s,const u8 * sta,const char * sig_name)11705b9c547cSRui Paulo static void wpas_dbus_signal_sta(struct wpa_supplicant *wpa_s,
11715b9c547cSRui Paulo const u8 *sta, const char *sig_name)
11725b9c547cSRui Paulo {
11735b9c547cSRui Paulo struct wpas_dbus_priv *iface;
11745b9c547cSRui Paulo DBusMessage *msg;
11755b9c547cSRui Paulo char sta_mac[WPAS_DBUS_OBJECT_PATH_MAX];
11765b9c547cSRui Paulo char *dev_mac;
11775b9c547cSRui Paulo
11785b9c547cSRui Paulo os_snprintf(sta_mac, WPAS_DBUS_OBJECT_PATH_MAX, MACSTR, MAC2STR(sta));
11795b9c547cSRui Paulo dev_mac = sta_mac;
11805b9c547cSRui Paulo
11815b9c547cSRui Paulo iface = wpa_s->global->dbus;
11825b9c547cSRui Paulo
11835b9c547cSRui Paulo /* Do nothing if the control interface is not turned on */
1184325151a3SRui Paulo if (iface == NULL || !wpa_s->dbus_new_path)
11855b9c547cSRui Paulo return;
11865b9c547cSRui Paulo
11875b9c547cSRui Paulo msg = dbus_message_new_signal(wpa_s->dbus_new_path,
11885b9c547cSRui Paulo WPAS_DBUS_NEW_IFACE_INTERFACE, sig_name);
11895b9c547cSRui Paulo if (msg == NULL)
11905b9c547cSRui Paulo return;
11915b9c547cSRui Paulo
11925b9c547cSRui Paulo if (dbus_message_append_args(msg, DBUS_TYPE_STRING, &dev_mac,
11935b9c547cSRui Paulo DBUS_TYPE_INVALID))
11945b9c547cSRui Paulo dbus_connection_send(iface->con, msg, NULL);
11955b9c547cSRui Paulo else
11965b9c547cSRui Paulo wpa_printf(MSG_ERROR, "dbus: Failed to construct signal");
11975b9c547cSRui Paulo dbus_message_unref(msg);
11985b9c547cSRui Paulo
11995b9c547cSRui Paulo wpa_printf(MSG_DEBUG, "dbus: Station MAC address '%s' '%s'",
12005b9c547cSRui Paulo sta_mac, sig_name);
12015b9c547cSRui Paulo }
12025b9c547cSRui Paulo
12035b9c547cSRui Paulo
12045b9c547cSRui Paulo /**
12055b9c547cSRui Paulo * wpas_dbus_signal_sta_authorized - Send a STA authorized signal
12065b9c547cSRui Paulo * @wpa_s: %wpa_supplicant network interface data
12075b9c547cSRui Paulo * @sta: station mac address
12085b9c547cSRui Paulo *
12095b9c547cSRui Paulo * Notify listeners a new station has been authorized
12105b9c547cSRui Paulo */
wpas_dbus_signal_sta_authorized(struct wpa_supplicant * wpa_s,const u8 * sta)12115b9c547cSRui Paulo void wpas_dbus_signal_sta_authorized(struct wpa_supplicant *wpa_s,
12125b9c547cSRui Paulo const u8 *sta)
12135b9c547cSRui Paulo {
12145b9c547cSRui Paulo wpas_dbus_signal_sta(wpa_s, sta, "StaAuthorized");
12155b9c547cSRui Paulo }
12165b9c547cSRui Paulo
12175b9c547cSRui Paulo
12185b9c547cSRui Paulo /**
12195b9c547cSRui Paulo * wpas_dbus_signal_sta_deauthorized - Send a STA deauthorized signal
12205b9c547cSRui Paulo * @wpa_s: %wpa_supplicant network interface data
12215b9c547cSRui Paulo * @sta: station mac address
12225b9c547cSRui Paulo *
12235b9c547cSRui Paulo * Notify listeners a station has been deauthorized
12245b9c547cSRui Paulo */
wpas_dbus_signal_sta_deauthorized(struct wpa_supplicant * wpa_s,const u8 * sta)12255b9c547cSRui Paulo void wpas_dbus_signal_sta_deauthorized(struct wpa_supplicant *wpa_s,
12265b9c547cSRui Paulo const u8 *sta)
12275b9c547cSRui Paulo {
12285b9c547cSRui Paulo wpas_dbus_signal_sta(wpa_s, sta, "StaDeauthorized");
12295b9c547cSRui Paulo }
12305b9c547cSRui Paulo
12315b9c547cSRui Paulo
12324bc52338SCy Schubert /**
12334bc52338SCy Schubert * wpas_dbus_signal_station - Send an event signal related to a station object
12344bc52338SCy Schubert * @wpa_s: %wpa_supplicant network interface data
12354bc52338SCy Schubert * @station_obj_path: Station object path
12364bc52338SCy Schubert * @sig_name: signal name - StationAdded or StationRemoved
12374bc52338SCy Schubert * @properties: Whether to add second argument with object properties
12384bc52338SCy Schubert *
12394bc52338SCy Schubert * Notify listeners about event related with station.
12404bc52338SCy Schubert */
wpas_dbus_signal_station(struct wpa_supplicant * wpa_s,const char * station_obj_path,const char * sig_name,dbus_bool_t properties)12414bc52338SCy Schubert static void wpas_dbus_signal_station(struct wpa_supplicant *wpa_s,
12424bc52338SCy Schubert const char *station_obj_path,
12434bc52338SCy Schubert const char *sig_name,
12444bc52338SCy Schubert dbus_bool_t properties)
12454bc52338SCy Schubert {
12464bc52338SCy Schubert struct wpas_dbus_priv *iface;
12474bc52338SCy Schubert DBusMessage *msg;
12484bc52338SCy Schubert DBusMessageIter iter;
12494bc52338SCy Schubert
12504bc52338SCy Schubert iface = wpa_s->global->dbus;
12514bc52338SCy Schubert
12524bc52338SCy Schubert /* Do nothing if the control interface is not turned on */
12534bc52338SCy Schubert if (!iface || !wpa_s->dbus_new_path)
12544bc52338SCy Schubert return;
12554bc52338SCy Schubert
12564bc52338SCy Schubert wpa_printf(MSG_DEBUG, "dbus: STA signal %s", sig_name);
12574bc52338SCy Schubert msg = dbus_message_new_signal(wpa_s->dbus_new_path,
12584bc52338SCy Schubert WPAS_DBUS_NEW_IFACE_INTERFACE, sig_name);
12594bc52338SCy Schubert if (!msg)
12604bc52338SCy Schubert return;
12614bc52338SCy Schubert
12624bc52338SCy Schubert dbus_message_iter_init_append(msg, &iter);
12634bc52338SCy Schubert if (!dbus_message_iter_append_basic(&iter, DBUS_TYPE_OBJECT_PATH,
12644bc52338SCy Schubert &station_obj_path) ||
12654bc52338SCy Schubert (properties &&
12664bc52338SCy Schubert !wpa_dbus_get_object_properties(iface, station_obj_path,
12674bc52338SCy Schubert WPAS_DBUS_NEW_IFACE_STA,
12684bc52338SCy Schubert &iter)))
12694bc52338SCy Schubert wpa_printf(MSG_ERROR, "dbus: Failed to construct signal");
12704bc52338SCy Schubert else
12714bc52338SCy Schubert dbus_connection_send(iface->con, msg, NULL);
12724bc52338SCy Schubert dbus_message_unref(msg);
12734bc52338SCy Schubert }
12744bc52338SCy Schubert
12754bc52338SCy Schubert
12764bc52338SCy Schubert /**
12774bc52338SCy Schubert * wpas_dbus_signal_station_added - Send a Station added signal
12784bc52338SCy Schubert * @wpa_s: %wpa_supplicant network interface data
12794bc52338SCy Schubert * @station_obj_path: new Station object path
12804bc52338SCy Schubert *
12814bc52338SCy Schubert * Notify listeners about adding new Station
12824bc52338SCy Schubert */
wpas_dbus_signal_station_added(struct wpa_supplicant * wpa_s,const char * station_obj_path)12834bc52338SCy Schubert static void wpas_dbus_signal_station_added(struct wpa_supplicant *wpa_s,
12844bc52338SCy Schubert const char *station_obj_path)
12854bc52338SCy Schubert {
12864bc52338SCy Schubert wpas_dbus_signal_station(wpa_s, station_obj_path, "StationAdded", TRUE);
12874bc52338SCy Schubert }
12884bc52338SCy Schubert
12894bc52338SCy Schubert
12904bc52338SCy Schubert /**
12914bc52338SCy Schubert * wpas_dbus_signal_station_removed - Send a Station removed signal
12924bc52338SCy Schubert * @wpa_s: %wpa_supplicant network interface data
12934bc52338SCy Schubert * @station_obj_path: Station object path
12944bc52338SCy Schubert *
12954bc52338SCy Schubert * Notify listeners about removing Station
12964bc52338SCy Schubert */
wpas_dbus_signal_station_removed(struct wpa_supplicant * wpa_s,const char * station_obj_path)12974bc52338SCy Schubert static void wpas_dbus_signal_station_removed(struct wpa_supplicant *wpa_s,
12984bc52338SCy Schubert const char *station_obj_path)
12994bc52338SCy Schubert {
13004bc52338SCy Schubert wpas_dbus_signal_station(wpa_s, station_obj_path, "StationRemoved",
13014bc52338SCy Schubert FALSE);
13024bc52338SCy Schubert }
13034bc52338SCy Schubert
13044bc52338SCy Schubert
1305d4f2939cSRui Paulo #ifdef CONFIG_P2P
1306d4f2939cSRui Paulo
1307d4f2939cSRui Paulo /**
1308d4f2939cSRui Paulo * wpas_dbus_signal_p2p_group_removed - Signals P2P group was removed
1309d4f2939cSRui Paulo * @wpa_s: %wpa_supplicant network interface data
1310d4f2939cSRui Paulo * @role: role of this device (client or GO)
1311d4f2939cSRui Paulo * Sends signal with i/f name and role as string arguments
1312d4f2939cSRui Paulo */
wpas_dbus_signal_p2p_group_removed(struct wpa_supplicant * wpa_s,const char * role)1313d4f2939cSRui Paulo void wpas_dbus_signal_p2p_group_removed(struct wpa_supplicant *wpa_s,
1314d4f2939cSRui Paulo const char *role)
1315d4f2939cSRui Paulo {
1316d4f2939cSRui Paulo DBusMessage *msg;
13175b9c547cSRui Paulo DBusMessageIter iter, dict_iter;
1318d4f2939cSRui Paulo struct wpas_dbus_priv *iface = wpa_s->global->dbus;
13195b9c547cSRui Paulo struct wpa_supplicant *parent;
1320d4f2939cSRui Paulo
1321d4f2939cSRui Paulo /* Do nothing if the control interface is not turned on */
1322d4f2939cSRui Paulo if (iface == NULL)
1323d4f2939cSRui Paulo return;
1324d4f2939cSRui Paulo
13255b9c547cSRui Paulo parent = wpa_s->parent;
13265b9c547cSRui Paulo if (parent->p2p_mgmt)
13275b9c547cSRui Paulo parent = parent->parent;
13285b9c547cSRui Paulo
1329325151a3SRui Paulo if (!wpa_s->dbus_groupobj_path || !wpa_s->dbus_new_path ||
1330325151a3SRui Paulo !parent->dbus_new_path)
13315b9c547cSRui Paulo return;
13325b9c547cSRui Paulo
13335b9c547cSRui Paulo msg = dbus_message_new_signal(parent->dbus_new_path,
1334d4f2939cSRui Paulo WPAS_DBUS_NEW_IFACE_P2PDEVICE,
1335d4f2939cSRui Paulo "GroupFinished");
1336d4f2939cSRui Paulo if (msg == NULL)
1337d4f2939cSRui Paulo return;
1338d4f2939cSRui Paulo
1339d4f2939cSRui Paulo dbus_message_iter_init_append(msg, &iter);
13405b9c547cSRui Paulo if (!wpa_dbus_dict_open_write(&iter, &dict_iter) ||
13415b9c547cSRui Paulo !wpa_dbus_dict_append_object_path(&dict_iter,
13425b9c547cSRui Paulo "interface_object",
13435b9c547cSRui Paulo wpa_s->dbus_new_path) ||
13445b9c547cSRui Paulo !wpa_dbus_dict_append_string(&dict_iter, "role", role) ||
13455b9c547cSRui Paulo !wpa_dbus_dict_append_object_path(&dict_iter, "group_object",
13465b9c547cSRui Paulo wpa_s->dbus_groupobj_path) ||
13475b9c547cSRui Paulo !wpa_dbus_dict_close_write(&iter, &dict_iter))
13485b9c547cSRui Paulo wpa_printf(MSG_ERROR, "dbus: Failed to construct signal");
1349d4f2939cSRui Paulo else
1350d4f2939cSRui Paulo dbus_connection_send(iface->con, msg, NULL);
1351d4f2939cSRui Paulo dbus_message_unref(msg);
1352d4f2939cSRui Paulo }
1353d4f2939cSRui Paulo
1354d4f2939cSRui Paulo
1355d4f2939cSRui Paulo /**
1356d4f2939cSRui Paulo * wpas_dbus_signal_p2p_provision_discovery - Signals various PD events
1357d4f2939cSRui Paulo *
1358d4f2939cSRui Paulo * @dev_addr - who sent the request or responded to our request.
1359d4f2939cSRui Paulo * @request - Will be 1 if request, 0 for response.
1360d4f2939cSRui Paulo * @status - valid only in case of response
1361d4f2939cSRui Paulo * @config_methods - wps config methods
1362d4f2939cSRui Paulo * @generated_pin - pin to be displayed in case of WPS_CONFIG_DISPLAY method
1363d4f2939cSRui Paulo *
1364d4f2939cSRui Paulo * Sends following provision discovery related events:
1365d4f2939cSRui Paulo * ProvisionDiscoveryRequestDisplayPin
1366d4f2939cSRui Paulo * ProvisionDiscoveryResponseDisplayPin
1367d4f2939cSRui Paulo * ProvisionDiscoveryRequestEnterPin
1368d4f2939cSRui Paulo * ProvisionDiscoveryResponseEnterPin
1369d4f2939cSRui Paulo * ProvisionDiscoveryPBCRequest
1370d4f2939cSRui Paulo * ProvisionDiscoveryPBCResponse
1371d4f2939cSRui Paulo *
1372d4f2939cSRui Paulo * TODO::
1373d4f2939cSRui Paulo * ProvisionDiscoveryFailure (timeout case)
1374d4f2939cSRui Paulo */
wpas_dbus_signal_p2p_provision_discovery(struct wpa_supplicant * wpa_s,const u8 * dev_addr,int request,enum p2p_prov_disc_status status,u16 config_methods,unsigned int generated_pin)1375d4f2939cSRui Paulo void wpas_dbus_signal_p2p_provision_discovery(struct wpa_supplicant *wpa_s,
1376d4f2939cSRui Paulo const u8 *dev_addr, int request,
1377d4f2939cSRui Paulo enum p2p_prov_disc_status status,
1378d4f2939cSRui Paulo u16 config_methods,
1379d4f2939cSRui Paulo unsigned int generated_pin)
1380d4f2939cSRui Paulo {
1381d4f2939cSRui Paulo DBusMessage *msg;
1382d4f2939cSRui Paulo DBusMessageIter iter;
1383d4f2939cSRui Paulo struct wpas_dbus_priv *iface;
1384d4f2939cSRui Paulo char *_signal;
1385d4f2939cSRui Paulo int add_pin = 0;
1386d4f2939cSRui Paulo char peer_obj_path[WPAS_DBUS_OBJECT_PATH_MAX], *path;
1387d4f2939cSRui Paulo int error_ret = 1;
1388d4f2939cSRui Paulo char pin[9], *p_pin = NULL;
1389d4f2939cSRui Paulo
1390d4f2939cSRui Paulo iface = wpa_s->global->dbus;
1391d4f2939cSRui Paulo
1392d4f2939cSRui Paulo /* Do nothing if the control interface is not turned on */
1393d4f2939cSRui Paulo if (iface == NULL)
1394d4f2939cSRui Paulo return;
1395d4f2939cSRui Paulo
13965b9c547cSRui Paulo if (wpa_s->p2p_mgmt)
13975b9c547cSRui Paulo wpa_s = wpa_s->parent;
1398325151a3SRui Paulo if (!wpa_s->dbus_new_path)
1399325151a3SRui Paulo return;
14005b9c547cSRui Paulo
1401d4f2939cSRui Paulo if (request || !status) {
1402d4f2939cSRui Paulo if (config_methods & WPS_CONFIG_DISPLAY)
1403d4f2939cSRui Paulo _signal = request ?
1404d4f2939cSRui Paulo "ProvisionDiscoveryRequestDisplayPin" :
1405d4f2939cSRui Paulo "ProvisionDiscoveryResponseEnterPin";
1406d4f2939cSRui Paulo else if (config_methods & WPS_CONFIG_KEYPAD)
1407d4f2939cSRui Paulo _signal = request ?
1408d4f2939cSRui Paulo "ProvisionDiscoveryRequestEnterPin" :
1409d4f2939cSRui Paulo "ProvisionDiscoveryResponseDisplayPin";
1410d4f2939cSRui Paulo else if (config_methods & WPS_CONFIG_PUSHBUTTON)
1411d4f2939cSRui Paulo _signal = request ? "ProvisionDiscoveryPBCRequest" :
1412d4f2939cSRui Paulo "ProvisionDiscoveryPBCResponse";
1413d4f2939cSRui Paulo else
1414d4f2939cSRui Paulo return; /* Unknown or un-supported method */
14155b9c547cSRui Paulo } else {
1416d4f2939cSRui Paulo /* Explicit check for failure response */
1417d4f2939cSRui Paulo _signal = "ProvisionDiscoveryFailure";
14185b9c547cSRui Paulo }
1419d4f2939cSRui Paulo
1420d4f2939cSRui Paulo add_pin = ((request && (config_methods & WPS_CONFIG_DISPLAY)) ||
1421d4f2939cSRui Paulo (!request && !status &&
1422d4f2939cSRui Paulo (config_methods & WPS_CONFIG_KEYPAD)));
1423d4f2939cSRui Paulo
1424d4f2939cSRui Paulo if (add_pin) {
1425d4f2939cSRui Paulo os_snprintf(pin, sizeof(pin), "%08d", generated_pin);
1426d4f2939cSRui Paulo p_pin = pin;
1427d4f2939cSRui Paulo }
1428d4f2939cSRui Paulo
1429d4f2939cSRui Paulo msg = dbus_message_new_signal(wpa_s->dbus_new_path,
1430d4f2939cSRui Paulo WPAS_DBUS_NEW_IFACE_P2PDEVICE, _signal);
1431d4f2939cSRui Paulo if (msg == NULL)
1432d4f2939cSRui Paulo return;
1433d4f2939cSRui Paulo
1434d4f2939cSRui Paulo /* Check if this is a known peer */
1435d4f2939cSRui Paulo if (!p2p_peer_known(wpa_s->global->p2p, dev_addr))
1436d4f2939cSRui Paulo goto error;
1437d4f2939cSRui Paulo
1438d4f2939cSRui Paulo os_snprintf(peer_obj_path, WPAS_DBUS_OBJECT_PATH_MAX,
1439d4f2939cSRui Paulo "%s/" WPAS_DBUS_NEW_P2P_PEERS_PART "/"
1440d4f2939cSRui Paulo COMPACT_MACSTR,
1441d4f2939cSRui Paulo wpa_s->dbus_new_path, MAC2STR(dev_addr));
1442d4f2939cSRui Paulo
1443d4f2939cSRui Paulo path = peer_obj_path;
1444d4f2939cSRui Paulo
1445d4f2939cSRui Paulo dbus_message_iter_init_append(msg, &iter);
1446d4f2939cSRui Paulo
1447d4f2939cSRui Paulo if (!dbus_message_iter_append_basic(&iter,
1448d4f2939cSRui Paulo DBUS_TYPE_OBJECT_PATH,
1449d4f2939cSRui Paulo &path))
1450d4f2939cSRui Paulo goto error;
1451d4f2939cSRui Paulo
1452d4f2939cSRui Paulo if (!request && status)
1453d4f2939cSRui Paulo /* Attach status to ProvisionDiscoveryFailure */
1454d4f2939cSRui Paulo error_ret = !dbus_message_iter_append_basic(&iter,
1455d4f2939cSRui Paulo DBUS_TYPE_INT32,
1456d4f2939cSRui Paulo &status);
1457d4f2939cSRui Paulo else
1458d4f2939cSRui Paulo error_ret = (add_pin &&
1459d4f2939cSRui Paulo !dbus_message_iter_append_basic(&iter,
1460d4f2939cSRui Paulo DBUS_TYPE_STRING,
1461d4f2939cSRui Paulo &p_pin));
1462d4f2939cSRui Paulo
1463d4f2939cSRui Paulo error:
1464d4f2939cSRui Paulo if (!error_ret)
1465d4f2939cSRui Paulo dbus_connection_send(iface->con, msg, NULL);
1466d4f2939cSRui Paulo else
1467d4f2939cSRui Paulo wpa_printf(MSG_ERROR, "dbus: Failed to construct signal");
1468d4f2939cSRui Paulo
1469d4f2939cSRui Paulo dbus_message_unref(msg);
1470d4f2939cSRui Paulo }
1471d4f2939cSRui Paulo
1472d4f2939cSRui Paulo
1473325151a3SRui Paulo /**
1474325151a3SRui Paulo * wpas_dbus_signal_p2p_go_neg_req - Signal P2P GO Negotiation Request RX
1475325151a3SRui Paulo * @wpa_s: %wpa_supplicant network interface data
1476325151a3SRui Paulo * @src: Source address of the message triggering this notification
1477325151a3SRui Paulo * @dev_passwd_id: WPS Device Password Id
1478325151a3SRui Paulo * @go_intent: Peer's GO Intent value
1479325151a3SRui Paulo *
1480325151a3SRui Paulo * Sends signal to notify that a peer P2P Device is requesting group owner
1481325151a3SRui Paulo * negotiation with us.
1482325151a3SRui Paulo */
wpas_dbus_signal_p2p_go_neg_req(struct wpa_supplicant * wpa_s,const u8 * src,u16 dev_passwd_id,u8 go_intent)1483d4f2939cSRui Paulo void wpas_dbus_signal_p2p_go_neg_req(struct wpa_supplicant *wpa_s,
1484325151a3SRui Paulo const u8 *src, u16 dev_passwd_id,
1485325151a3SRui Paulo u8 go_intent)
1486d4f2939cSRui Paulo {
1487d4f2939cSRui Paulo DBusMessage *msg;
1488d4f2939cSRui Paulo DBusMessageIter iter;
1489d4f2939cSRui Paulo struct wpas_dbus_priv *iface;
1490d4f2939cSRui Paulo char peer_obj_path[WPAS_DBUS_OBJECT_PATH_MAX], *path;
1491d4f2939cSRui Paulo
1492d4f2939cSRui Paulo iface = wpa_s->global->dbus;
1493d4f2939cSRui Paulo
1494d4f2939cSRui Paulo /* Do nothing if the control interface is not turned on */
1495d4f2939cSRui Paulo if (iface == NULL)
1496d4f2939cSRui Paulo return;
1497d4f2939cSRui Paulo
14985b9c547cSRui Paulo if (wpa_s->p2p_mgmt)
14995b9c547cSRui Paulo wpa_s = wpa_s->parent;
1500325151a3SRui Paulo if (!wpa_s->dbus_new_path)
1501325151a3SRui Paulo return;
15025b9c547cSRui Paulo
1503d4f2939cSRui Paulo os_snprintf(peer_obj_path, WPAS_DBUS_OBJECT_PATH_MAX,
1504d4f2939cSRui Paulo "%s/" WPAS_DBUS_NEW_P2P_PEERS_PART "/" COMPACT_MACSTR,
1505d4f2939cSRui Paulo wpa_s->dbus_new_path, MAC2STR(src));
1506d4f2939cSRui Paulo path = peer_obj_path;
1507d4f2939cSRui Paulo
1508d4f2939cSRui Paulo msg = dbus_message_new_signal(wpa_s->dbus_new_path,
1509d4f2939cSRui Paulo WPAS_DBUS_NEW_IFACE_P2PDEVICE,
1510d4f2939cSRui Paulo "GONegotiationRequest");
1511d4f2939cSRui Paulo if (msg == NULL)
1512d4f2939cSRui Paulo return;
1513d4f2939cSRui Paulo
1514d4f2939cSRui Paulo dbus_message_iter_init_append(msg, &iter);
1515d4f2939cSRui Paulo
1516d4f2939cSRui Paulo if (!dbus_message_iter_append_basic(&iter, DBUS_TYPE_OBJECT_PATH,
1517d4f2939cSRui Paulo &path) ||
1518d4f2939cSRui Paulo !dbus_message_iter_append_basic(&iter, DBUS_TYPE_UINT16,
1519325151a3SRui Paulo &dev_passwd_id) ||
1520325151a3SRui Paulo !dbus_message_iter_append_basic(&iter, DBUS_TYPE_BYTE,
1521325151a3SRui Paulo &go_intent))
1522d4f2939cSRui Paulo wpa_printf(MSG_ERROR, "dbus: Failed to construct signal");
1523d4f2939cSRui Paulo else
1524d4f2939cSRui Paulo dbus_connection_send(iface->con, msg, NULL);
1525d4f2939cSRui Paulo
1526d4f2939cSRui Paulo dbus_message_unref(msg);
1527d4f2939cSRui Paulo }
1528d4f2939cSRui Paulo
1529d4f2939cSRui Paulo
wpas_dbus_get_group_obj_path(struct wpa_supplicant * wpa_s,const struct wpa_ssid * ssid,char * group_obj_path)1530d4f2939cSRui Paulo static int wpas_dbus_get_group_obj_path(struct wpa_supplicant *wpa_s,
1531d4f2939cSRui Paulo const struct wpa_ssid *ssid,
1532d4f2939cSRui Paulo char *group_obj_path)
1533d4f2939cSRui Paulo {
1534d4f2939cSRui Paulo char group_name[3];
1535d4f2939cSRui Paulo
1536325151a3SRui Paulo if (!wpa_s->dbus_new_path ||
1537325151a3SRui Paulo os_memcmp(ssid->ssid, P2P_WILDCARD_SSID, P2P_WILDCARD_SSID_LEN))
1538d4f2939cSRui Paulo return -1;
1539d4f2939cSRui Paulo
1540d4f2939cSRui Paulo os_memcpy(group_name, ssid->ssid + P2P_WILDCARD_SSID_LEN, 2);
1541d4f2939cSRui Paulo group_name[2] = '\0';
1542d4f2939cSRui Paulo
1543d4f2939cSRui Paulo os_snprintf(group_obj_path, WPAS_DBUS_OBJECT_PATH_MAX,
1544d4f2939cSRui Paulo "%s/" WPAS_DBUS_NEW_P2P_GROUPS_PART "/%s",
1545d4f2939cSRui Paulo wpa_s->dbus_new_path, group_name);
1546d4f2939cSRui Paulo
1547d4f2939cSRui Paulo return 0;
1548d4f2939cSRui Paulo }
1549d4f2939cSRui Paulo
1550d4f2939cSRui Paulo
15515b9c547cSRui Paulo struct group_changed_data {
15525b9c547cSRui Paulo struct wpa_supplicant *wpa_s;
15535b9c547cSRui Paulo struct p2p_peer_info *info;
15545b9c547cSRui Paulo };
15555b9c547cSRui Paulo
15565b9c547cSRui Paulo
match_group_where_peer_is_client(struct p2p_group * group,void * user_data)15575b9c547cSRui Paulo static int match_group_where_peer_is_client(struct p2p_group *group,
15585b9c547cSRui Paulo void *user_data)
15595b9c547cSRui Paulo {
15605b9c547cSRui Paulo struct group_changed_data *data = user_data;
15615b9c547cSRui Paulo const struct p2p_group_config *cfg;
15625b9c547cSRui Paulo struct wpa_supplicant *wpa_s_go;
15635b9c547cSRui Paulo
15645b9c547cSRui Paulo if (!p2p_group_is_client_connected(group, data->info->p2p_device_addr))
15655b9c547cSRui Paulo return 1;
15665b9c547cSRui Paulo
15675b9c547cSRui Paulo cfg = p2p_group_get_config(group);
15685b9c547cSRui Paulo
15695b9c547cSRui Paulo wpa_s_go = wpas_get_p2p_go_iface(data->wpa_s, cfg->ssid,
15705b9c547cSRui Paulo cfg->ssid_len);
15715b9c547cSRui Paulo if (wpa_s_go != NULL && wpa_s_go == data->wpa_s) {
15725b9c547cSRui Paulo wpas_dbus_signal_peer_groups_changed(
1573780fb4a2SCy Schubert data->wpa_s->p2pdev, data->info->p2p_device_addr);
15745b9c547cSRui Paulo return 0;
15755b9c547cSRui Paulo }
15765b9c547cSRui Paulo
15775b9c547cSRui Paulo return 1;
15785b9c547cSRui Paulo }
15795b9c547cSRui Paulo
15805b9c547cSRui Paulo
signal_peer_groups_changed(struct p2p_peer_info * info,void * user_data)15815b9c547cSRui Paulo static void signal_peer_groups_changed(struct p2p_peer_info *info,
15825b9c547cSRui Paulo void *user_data)
15835b9c547cSRui Paulo {
15845b9c547cSRui Paulo struct group_changed_data *data = user_data;
15855b9c547cSRui Paulo struct wpa_supplicant *wpa_s_go;
15865b9c547cSRui Paulo
15875b9c547cSRui Paulo wpa_s_go = wpas_get_p2p_client_iface(data->wpa_s,
15885b9c547cSRui Paulo info->p2p_device_addr);
15895b9c547cSRui Paulo if (wpa_s_go != NULL && wpa_s_go == data->wpa_s) {
1590780fb4a2SCy Schubert wpas_dbus_signal_peer_groups_changed(data->wpa_s->p2pdev,
15915b9c547cSRui Paulo info->p2p_device_addr);
15925b9c547cSRui Paulo return;
15935b9c547cSRui Paulo }
15945b9c547cSRui Paulo
15955b9c547cSRui Paulo data->info = info;
15965b9c547cSRui Paulo p2p_loop_on_all_groups(data->wpa_s->global->p2p,
15975b9c547cSRui Paulo match_group_where_peer_is_client, data);
15985b9c547cSRui Paulo data->info = NULL;
15995b9c547cSRui Paulo }
16005b9c547cSRui Paulo
16015b9c547cSRui Paulo
peer_groups_changed(struct wpa_supplicant * wpa_s)16025b9c547cSRui Paulo static void peer_groups_changed(struct wpa_supplicant *wpa_s)
16035b9c547cSRui Paulo {
16045b9c547cSRui Paulo struct group_changed_data data;
16055b9c547cSRui Paulo
16065b9c547cSRui Paulo os_memset(&data, 0, sizeof(data));
16075b9c547cSRui Paulo data.wpa_s = wpa_s;
16085b9c547cSRui Paulo
16095b9c547cSRui Paulo p2p_loop_on_known_peers(wpa_s->global->p2p,
16105b9c547cSRui Paulo signal_peer_groups_changed, &data);
16115b9c547cSRui Paulo }
16125b9c547cSRui Paulo
16135b9c547cSRui Paulo
1614d4f2939cSRui Paulo /**
1615d4f2939cSRui Paulo * wpas_dbus_signal_p2p_group_started - Signals P2P group has
1616d4f2939cSRui Paulo * started. Emitted when a group is successfully started
1617d4f2939cSRui Paulo * irrespective of the role (client/GO) of the current device
1618d4f2939cSRui Paulo *
1619d4f2939cSRui Paulo * @wpa_s: %wpa_supplicant network interface data
1620d4f2939cSRui Paulo * @client: this device is P2P client
1621780fb4a2SCy Schubert * @persistent: 0 - non persistent group, 1 - persistent group
162285732ac8SCy Schubert * @ip: When group role is client, it contains local IP address, netmask, and
162385732ac8SCy Schubert * GO's IP address, if assigned; otherwise, NULL
1624d4f2939cSRui Paulo */
wpas_dbus_signal_p2p_group_started(struct wpa_supplicant * wpa_s,int client,int persistent,const u8 * ip)1625d4f2939cSRui Paulo void wpas_dbus_signal_p2p_group_started(struct wpa_supplicant *wpa_s,
162685732ac8SCy Schubert int client, int persistent,
162785732ac8SCy Schubert const u8 *ip)
1628d4f2939cSRui Paulo {
1629d4f2939cSRui Paulo DBusMessage *msg;
1630d4f2939cSRui Paulo DBusMessageIter iter, dict_iter;
1631d4f2939cSRui Paulo struct wpas_dbus_priv *iface;
16325b9c547cSRui Paulo struct wpa_supplicant *parent;
1633d4f2939cSRui Paulo
16345b9c547cSRui Paulo parent = wpa_s->parent;
16355b9c547cSRui Paulo if (parent->p2p_mgmt)
16365b9c547cSRui Paulo parent = parent->parent;
16375b9c547cSRui Paulo
16385b9c547cSRui Paulo iface = parent->global->dbus;
1639d4f2939cSRui Paulo
1640d4f2939cSRui Paulo /* Do nothing if the control interface is not turned on */
1641325151a3SRui Paulo if (iface == NULL || !parent->dbus_new_path || !wpa_s->dbus_new_path)
1642d4f2939cSRui Paulo return;
1643d4f2939cSRui Paulo
16445b9c547cSRui Paulo if (wpa_s->dbus_groupobj_path == NULL)
1645d4f2939cSRui Paulo return;
1646d4f2939cSRui Paulo
1647d4f2939cSRui Paulo /* New interface has been created for this group */
16485b9c547cSRui Paulo msg = dbus_message_new_signal(parent->dbus_new_path,
1649d4f2939cSRui Paulo WPAS_DBUS_NEW_IFACE_P2PDEVICE,
1650d4f2939cSRui Paulo "GroupStarted");
1651d4f2939cSRui Paulo if (msg == NULL)
1652d4f2939cSRui Paulo return;
1653d4f2939cSRui Paulo
1654d4f2939cSRui Paulo dbus_message_iter_init_append(msg, &iter);
1655d4f2939cSRui Paulo /*
1656d4f2939cSRui Paulo * In case the device supports creating a separate interface the
1657d4f2939cSRui Paulo * DBus client will need to know the object path for the interface
1658d4f2939cSRui Paulo * object this group was created on, so include it here.
1659d4f2939cSRui Paulo */
16605b9c547cSRui Paulo if (!wpa_dbus_dict_open_write(&iter, &dict_iter) ||
16615b9c547cSRui Paulo !wpa_dbus_dict_append_object_path(&dict_iter,
1662d4f2939cSRui Paulo "interface_object",
16635b9c547cSRui Paulo wpa_s->dbus_new_path) ||
16645b9c547cSRui Paulo !wpa_dbus_dict_append_string(&dict_iter, "role",
16655b9c547cSRui Paulo client ? "client" : "GO") ||
1666*a90b9d01SCy Schubert !wpa_dbus_dict_append_bool(&dict_iter, "persistent",
1667*a90b9d01SCy Schubert !!persistent) ||
16685b9c547cSRui Paulo !wpa_dbus_dict_append_object_path(&dict_iter, "group_object",
16695b9c547cSRui Paulo wpa_s->dbus_groupobj_path) ||
167085732ac8SCy Schubert (ip &&
167185732ac8SCy Schubert (!wpa_dbus_dict_append_byte_array(&dict_iter, "IpAddr",
167285732ac8SCy Schubert (char *) ip, 4) ||
167385732ac8SCy Schubert !wpa_dbus_dict_append_byte_array(&dict_iter, "IpAddrMask",
167485732ac8SCy Schubert (char *) ip + 4, 4) ||
167585732ac8SCy Schubert !wpa_dbus_dict_append_byte_array(&dict_iter, "IpAddrGo",
167685732ac8SCy Schubert (char *) ip + 8, 4))) ||
16775b9c547cSRui Paulo !wpa_dbus_dict_close_write(&iter, &dict_iter)) {
16785b9c547cSRui Paulo wpa_printf(MSG_ERROR, "dbus: Failed to construct signal");
16795b9c547cSRui Paulo } else {
1680d4f2939cSRui Paulo dbus_connection_send(iface->con, msg, NULL);
16815b9c547cSRui Paulo if (client)
16825b9c547cSRui Paulo peer_groups_changed(wpa_s);
16835b9c547cSRui Paulo }
1684d4f2939cSRui Paulo dbus_message_unref(msg);
1685d4f2939cSRui Paulo }
1686d4f2939cSRui Paulo
1687d4f2939cSRui Paulo
1688d4f2939cSRui Paulo /**
1689325151a3SRui Paulo * wpas_dbus_signal_p2p_go_neg_resp - Emit GONegotiation Success/Failure signal
1690325151a3SRui Paulo * @wpa_s: %wpa_supplicant network interface data
1691325151a3SRui Paulo * @res: Result of the GO Neg Request
1692d4f2939cSRui Paulo */
wpas_dbus_signal_p2p_go_neg_resp(struct wpa_supplicant * wpa_s,struct p2p_go_neg_results * res)1693d4f2939cSRui Paulo void wpas_dbus_signal_p2p_go_neg_resp(struct wpa_supplicant *wpa_s,
1694d4f2939cSRui Paulo struct p2p_go_neg_results *res)
1695d4f2939cSRui Paulo {
1696d4f2939cSRui Paulo DBusMessage *msg;
1697d4f2939cSRui Paulo DBusMessageIter iter, dict_iter;
1698d4f2939cSRui Paulo DBusMessageIter iter_dict_entry, iter_dict_val, iter_dict_array;
1699d4f2939cSRui Paulo struct wpas_dbus_priv *iface;
1700d4f2939cSRui Paulo char peer_obj_path[WPAS_DBUS_OBJECT_PATH_MAX], *path;
1701d4f2939cSRui Paulo dbus_int32_t freqs[P2P_MAX_CHANNELS];
1702d4f2939cSRui Paulo dbus_int32_t *f_array = freqs;
1703d4f2939cSRui Paulo
1704d4f2939cSRui Paulo
1705d4f2939cSRui Paulo iface = wpa_s->global->dbus;
1706d4f2939cSRui Paulo
17075b9c547cSRui Paulo if (wpa_s->p2p_mgmt)
17085b9c547cSRui Paulo wpa_s = wpa_s->parent;
17095b9c547cSRui Paulo
1710d4f2939cSRui Paulo os_memset(freqs, 0, sizeof(freqs));
1711d4f2939cSRui Paulo /* Do nothing if the control interface is not turned on */
1712325151a3SRui Paulo if (iface == NULL || !wpa_s->dbus_new_path)
1713d4f2939cSRui Paulo return;
1714d4f2939cSRui Paulo
1715d4f2939cSRui Paulo os_snprintf(peer_obj_path, WPAS_DBUS_OBJECT_PATH_MAX,
1716d4f2939cSRui Paulo "%s/" WPAS_DBUS_NEW_P2P_PEERS_PART "/" COMPACT_MACSTR,
1717d4f2939cSRui Paulo wpa_s->dbus_new_path, MAC2STR(res->peer_device_addr));
1718d4f2939cSRui Paulo path = peer_obj_path;
1719d4f2939cSRui Paulo
1720d4f2939cSRui Paulo msg = dbus_message_new_signal(wpa_s->dbus_new_path,
1721d4f2939cSRui Paulo WPAS_DBUS_NEW_IFACE_P2PDEVICE,
1722d4f2939cSRui Paulo res->status ? "GONegotiationFailure" :
1723d4f2939cSRui Paulo "GONegotiationSuccess");
1724d4f2939cSRui Paulo if (msg == NULL)
1725d4f2939cSRui Paulo return;
1726d4f2939cSRui Paulo
1727d4f2939cSRui Paulo dbus_message_iter_init_append(msg, &iter);
17285b9c547cSRui Paulo if (!wpa_dbus_dict_open_write(&iter, &dict_iter) ||
17295b9c547cSRui Paulo !wpa_dbus_dict_append_object_path(&dict_iter, "peer_object",
1730d4f2939cSRui Paulo path) ||
1731d4f2939cSRui Paulo !wpa_dbus_dict_append_int32(&dict_iter, "status", res->status))
1732d4f2939cSRui Paulo goto err;
1733d4f2939cSRui Paulo
1734d4f2939cSRui Paulo if (!res->status) {
1735d4f2939cSRui Paulo int i = 0;
1736d4f2939cSRui Paulo int freq_list_num = 0;
1737d4f2939cSRui Paulo
17385b9c547cSRui Paulo if ((res->role_go &&
17395b9c547cSRui Paulo !wpa_dbus_dict_append_string(&dict_iter, "passphrase",
17405b9c547cSRui Paulo res->passphrase)) ||
17415b9c547cSRui Paulo !wpa_dbus_dict_append_string(&dict_iter, "role_go",
1742d4f2939cSRui Paulo res->role_go ? "GO" :
1743d4f2939cSRui Paulo "client") ||
1744d4f2939cSRui Paulo !wpa_dbus_dict_append_int32(&dict_iter, "frequency",
1745d4f2939cSRui Paulo res->freq) ||
1746d4f2939cSRui Paulo !wpa_dbus_dict_append_byte_array(&dict_iter, "ssid",
1747d4f2939cSRui Paulo (const char *) res->ssid,
1748d4f2939cSRui Paulo res->ssid_len) ||
1749d4f2939cSRui Paulo !wpa_dbus_dict_append_byte_array(&dict_iter,
1750d4f2939cSRui Paulo "peer_device_addr",
1751d4f2939cSRui Paulo (const char *)
1752d4f2939cSRui Paulo res->peer_device_addr,
1753d4f2939cSRui Paulo ETH_ALEN) ||
1754d4f2939cSRui Paulo !wpa_dbus_dict_append_byte_array(&dict_iter,
1755d4f2939cSRui Paulo "peer_interface_addr",
1756d4f2939cSRui Paulo (const char *)
1757d4f2939cSRui Paulo res->peer_interface_addr,
1758d4f2939cSRui Paulo ETH_ALEN) ||
1759d4f2939cSRui Paulo !wpa_dbus_dict_append_string(&dict_iter, "wps_method",
1760d4f2939cSRui Paulo p2p_wps_method_text(
1761d4f2939cSRui Paulo res->wps_method)))
1762d4f2939cSRui Paulo goto err;
1763d4f2939cSRui Paulo
1764d4f2939cSRui Paulo for (i = 0; i < P2P_MAX_CHANNELS; i++) {
1765d4f2939cSRui Paulo if (res->freq_list[i]) {
1766d4f2939cSRui Paulo freqs[i] = res->freq_list[i];
1767d4f2939cSRui Paulo freq_list_num++;
1768d4f2939cSRui Paulo }
1769d4f2939cSRui Paulo }
1770d4f2939cSRui Paulo
1771d4f2939cSRui Paulo if (!wpa_dbus_dict_begin_array(&dict_iter,
1772d4f2939cSRui Paulo "frequency_list",
1773d4f2939cSRui Paulo DBUS_TYPE_INT32_AS_STRING,
1774d4f2939cSRui Paulo &iter_dict_entry,
1775d4f2939cSRui Paulo &iter_dict_val,
17765b9c547cSRui Paulo &iter_dict_array) ||
17775b9c547cSRui Paulo !dbus_message_iter_append_fixed_array(&iter_dict_array,
1778d4f2939cSRui Paulo DBUS_TYPE_INT32,
1779d4f2939cSRui Paulo &f_array,
17805b9c547cSRui Paulo freq_list_num) ||
17815b9c547cSRui Paulo !wpa_dbus_dict_end_array(&dict_iter,
1782d4f2939cSRui Paulo &iter_dict_entry,
1783d4f2939cSRui Paulo &iter_dict_val,
17845b9c547cSRui Paulo &iter_dict_array) ||
17855b9c547cSRui Paulo !wpa_dbus_dict_append_int32(&dict_iter, "persistent_group",
1786d4f2939cSRui Paulo res->persistent_group) ||
1787d4f2939cSRui Paulo !wpa_dbus_dict_append_uint32(&dict_iter,
1788d4f2939cSRui Paulo "peer_config_timeout",
1789d4f2939cSRui Paulo res->peer_config_timeout))
1790d4f2939cSRui Paulo goto err;
1791d4f2939cSRui Paulo }
1792d4f2939cSRui Paulo
1793d4f2939cSRui Paulo if (!wpa_dbus_dict_close_write(&iter, &dict_iter))
1794d4f2939cSRui Paulo goto err;
1795d4f2939cSRui Paulo
1796d4f2939cSRui Paulo dbus_connection_send(iface->con, msg, NULL);
1797d4f2939cSRui Paulo err:
1798d4f2939cSRui Paulo dbus_message_unref(msg);
1799d4f2939cSRui Paulo }
1800d4f2939cSRui Paulo
1801d4f2939cSRui Paulo
1802d4f2939cSRui Paulo /**
1803325151a3SRui Paulo * wpas_dbus_signal_p2p_invitation_result - Emit InvitationResult signal
1804325151a3SRui Paulo * @wpa_s: %wpa_supplicant network interface data
1805325151a3SRui Paulo * @status: Status of invitation process
1806d4f2939cSRui Paulo * @bssid: Basic Service Set Identifier
1807d4f2939cSRui Paulo */
wpas_dbus_signal_p2p_invitation_result(struct wpa_supplicant * wpa_s,int status,const u8 * bssid)1808d4f2939cSRui Paulo void wpas_dbus_signal_p2p_invitation_result(struct wpa_supplicant *wpa_s,
1809d4f2939cSRui Paulo int status, const u8 *bssid)
1810d4f2939cSRui Paulo {
1811d4f2939cSRui Paulo DBusMessage *msg;
1812d4f2939cSRui Paulo DBusMessageIter iter, dict_iter;
1813d4f2939cSRui Paulo struct wpas_dbus_priv *iface;
1814d4f2939cSRui Paulo
18155b9c547cSRui Paulo wpa_printf(MSG_DEBUG, "%s", __func__);
1816d4f2939cSRui Paulo
1817d4f2939cSRui Paulo iface = wpa_s->global->dbus;
1818d4f2939cSRui Paulo /* Do nothing if the control interface is not turned on */
1819d4f2939cSRui Paulo if (iface == NULL)
1820d4f2939cSRui Paulo return;
1821d4f2939cSRui Paulo
18225b9c547cSRui Paulo if (wpa_s->p2p_mgmt)
18235b9c547cSRui Paulo wpa_s = wpa_s->parent;
1824325151a3SRui Paulo if (!wpa_s->dbus_new_path)
1825325151a3SRui Paulo return;
18265b9c547cSRui Paulo
1827d4f2939cSRui Paulo msg = dbus_message_new_signal(wpa_s->dbus_new_path,
1828d4f2939cSRui Paulo WPAS_DBUS_NEW_IFACE_P2PDEVICE,
1829d4f2939cSRui Paulo "InvitationResult");
1830d4f2939cSRui Paulo
1831d4f2939cSRui Paulo if (msg == NULL)
1832d4f2939cSRui Paulo return;
1833d4f2939cSRui Paulo
1834d4f2939cSRui Paulo dbus_message_iter_init_append(msg, &iter);
18355b9c547cSRui Paulo if (!wpa_dbus_dict_open_write(&iter, &dict_iter) ||
18365b9c547cSRui Paulo !wpa_dbus_dict_append_int32(&dict_iter, "status", status) ||
18375b9c547cSRui Paulo (bssid &&
18385b9c547cSRui Paulo !wpa_dbus_dict_append_byte_array(&dict_iter, "BSSID",
1839d4f2939cSRui Paulo (const char *) bssid,
18405b9c547cSRui Paulo ETH_ALEN)) ||
18415b9c547cSRui Paulo !wpa_dbus_dict_close_write(&iter, &dict_iter))
18425b9c547cSRui Paulo wpa_printf(MSG_ERROR, "dbus: Failed to construct signal");
18435b9c547cSRui Paulo else
1844d4f2939cSRui Paulo dbus_connection_send(iface->con, msg, NULL);
1845d4f2939cSRui Paulo dbus_message_unref(msg);
1846d4f2939cSRui Paulo }
1847d4f2939cSRui Paulo
1848d4f2939cSRui Paulo
1849d4f2939cSRui Paulo /**
1850d4f2939cSRui Paulo *
1851d4f2939cSRui Paulo * Method to emit a signal for a peer joining the group.
1852d4f2939cSRui Paulo * The signal will carry path to the group member object
1853d4f2939cSRui Paulo * constructed using p2p i/f addr used for connecting.
1854d4f2939cSRui Paulo *
1855d4f2939cSRui Paulo * @wpa_s: %wpa_supplicant network interface data
18565b9c547cSRui Paulo * @peer_addr: P2P Device Address of the peer joining the group
1857d4f2939cSRui Paulo */
wpas_dbus_signal_p2p_peer_joined(struct wpa_supplicant * wpa_s,const u8 * peer_addr)1858d4f2939cSRui Paulo void wpas_dbus_signal_p2p_peer_joined(struct wpa_supplicant *wpa_s,
18595b9c547cSRui Paulo const u8 *peer_addr)
1860d4f2939cSRui Paulo {
1861d4f2939cSRui Paulo struct wpas_dbus_priv *iface;
1862d4f2939cSRui Paulo DBusMessage *msg;
1863d4f2939cSRui Paulo DBusMessageIter iter;
18645b9c547cSRui Paulo char peer_obj_path[WPAS_DBUS_OBJECT_PATH_MAX], *path;
18655b9c547cSRui Paulo struct wpa_supplicant *parent;
1866d4f2939cSRui Paulo
1867d4f2939cSRui Paulo iface = wpa_s->global->dbus;
1868d4f2939cSRui Paulo
1869d4f2939cSRui Paulo /* Do nothing if the control interface is not turned on */
1870d4f2939cSRui Paulo if (iface == NULL)
1871d4f2939cSRui Paulo return;
1872d4f2939cSRui Paulo
1873d4f2939cSRui Paulo if (!wpa_s->dbus_groupobj_path)
1874d4f2939cSRui Paulo return;
1875d4f2939cSRui Paulo
18765b9c547cSRui Paulo parent = wpa_s->parent;
18775b9c547cSRui Paulo if (parent->p2p_mgmt)
18785b9c547cSRui Paulo parent = parent->parent;
1879325151a3SRui Paulo if (!parent->dbus_new_path)
1880325151a3SRui Paulo return;
18815b9c547cSRui Paulo
18825b9c547cSRui Paulo os_snprintf(peer_obj_path, WPAS_DBUS_OBJECT_PATH_MAX,
18835b9c547cSRui Paulo "%s/" WPAS_DBUS_NEW_P2P_PEERS_PART "/"
1884d4f2939cSRui Paulo COMPACT_MACSTR,
18855b9c547cSRui Paulo parent->dbus_new_path, MAC2STR(peer_addr));
1886d4f2939cSRui Paulo
1887d4f2939cSRui Paulo msg = dbus_message_new_signal(wpa_s->dbus_groupobj_path,
1888d4f2939cSRui Paulo WPAS_DBUS_NEW_IFACE_P2P_GROUP,
1889d4f2939cSRui Paulo "PeerJoined");
1890d4f2939cSRui Paulo if (msg == NULL)
1891d4f2939cSRui Paulo return;
1892d4f2939cSRui Paulo
1893d4f2939cSRui Paulo dbus_message_iter_init_append(msg, &iter);
18945b9c547cSRui Paulo path = peer_obj_path;
1895d4f2939cSRui Paulo if (!dbus_message_iter_append_basic(&iter, DBUS_TYPE_OBJECT_PATH,
18965b9c547cSRui Paulo &path)) {
1897d4f2939cSRui Paulo wpa_printf(MSG_ERROR, "dbus: Failed to construct signal");
18985b9c547cSRui Paulo } else {
18995b9c547cSRui Paulo dbus_connection_send(iface->con, msg, NULL);
19005b9c547cSRui Paulo wpas_dbus_signal_peer_groups_changed(parent, peer_addr);
19015b9c547cSRui Paulo }
1902d4f2939cSRui Paulo dbus_message_unref(msg);
1903d4f2939cSRui Paulo }
1904d4f2939cSRui Paulo
1905d4f2939cSRui Paulo
1906d4f2939cSRui Paulo /**
1907d4f2939cSRui Paulo *
1908d4f2939cSRui Paulo * Method to emit a signal for a peer disconnecting the group.
1909d4f2939cSRui Paulo * The signal will carry path to the group member object
19105b9c547cSRui Paulo * constructed using the P2P Device Address of the peer.
1911d4f2939cSRui Paulo *
1912d4f2939cSRui Paulo * @wpa_s: %wpa_supplicant network interface data
19135b9c547cSRui Paulo * @peer_addr: P2P Device Address of the peer joining the group
1914d4f2939cSRui Paulo */
wpas_dbus_signal_p2p_peer_disconnected(struct wpa_supplicant * wpa_s,const u8 * peer_addr)1915d4f2939cSRui Paulo void wpas_dbus_signal_p2p_peer_disconnected(struct wpa_supplicant *wpa_s,
19165b9c547cSRui Paulo const u8 *peer_addr)
1917d4f2939cSRui Paulo {
1918d4f2939cSRui Paulo struct wpas_dbus_priv *iface;
1919d4f2939cSRui Paulo DBusMessage *msg;
1920d4f2939cSRui Paulo DBusMessageIter iter;
19215b9c547cSRui Paulo char peer_obj_path[WPAS_DBUS_OBJECT_PATH_MAX], *path;
19225b9c547cSRui Paulo struct wpa_supplicant *parent;
1923d4f2939cSRui Paulo
1924d4f2939cSRui Paulo iface = wpa_s->global->dbus;
1925d4f2939cSRui Paulo
1926d4f2939cSRui Paulo /* Do nothing if the control interface is not turned on */
1927d4f2939cSRui Paulo if (iface == NULL)
1928d4f2939cSRui Paulo return;
1929d4f2939cSRui Paulo
1930d4f2939cSRui Paulo if (!wpa_s->dbus_groupobj_path)
1931d4f2939cSRui Paulo return;
1932d4f2939cSRui Paulo
19335b9c547cSRui Paulo parent = wpa_s->parent;
19345b9c547cSRui Paulo if (parent->p2p_mgmt)
19355b9c547cSRui Paulo parent = parent->parent;
1936325151a3SRui Paulo if (!parent->dbus_new_path)
1937325151a3SRui Paulo return;
19385b9c547cSRui Paulo
19395b9c547cSRui Paulo os_snprintf(peer_obj_path, WPAS_DBUS_OBJECT_PATH_MAX,
19405b9c547cSRui Paulo "%s/" WPAS_DBUS_NEW_P2P_PEERS_PART "/"
1941d4f2939cSRui Paulo COMPACT_MACSTR,
19425b9c547cSRui Paulo parent->dbus_new_path, MAC2STR(peer_addr));
1943d4f2939cSRui Paulo
1944d4f2939cSRui Paulo msg = dbus_message_new_signal(wpa_s->dbus_groupobj_path,
1945d4f2939cSRui Paulo WPAS_DBUS_NEW_IFACE_P2P_GROUP,
1946d4f2939cSRui Paulo "PeerDisconnected");
1947d4f2939cSRui Paulo if (msg == NULL)
1948d4f2939cSRui Paulo return;
1949d4f2939cSRui Paulo
1950d4f2939cSRui Paulo dbus_message_iter_init_append(msg, &iter);
19515b9c547cSRui Paulo path = peer_obj_path;
1952d4f2939cSRui Paulo if (!dbus_message_iter_append_basic(&iter, DBUS_TYPE_OBJECT_PATH,
19535b9c547cSRui Paulo &path)) {
19545b9c547cSRui Paulo wpa_printf(MSG_ERROR,
19555b9c547cSRui Paulo "dbus: Failed to construct PeerDisconnected signal");
19565b9c547cSRui Paulo } else {
1957d4f2939cSRui Paulo dbus_connection_send(iface->con, msg, NULL);
19585b9c547cSRui Paulo wpas_dbus_signal_peer_groups_changed(parent, peer_addr);
19595b9c547cSRui Paulo }
1960d4f2939cSRui Paulo dbus_message_unref(msg);
1961d4f2939cSRui Paulo }
1962d4f2939cSRui Paulo
1963d4f2939cSRui Paulo
1964d4f2939cSRui Paulo /**
1965d4f2939cSRui Paulo *
1966d4f2939cSRui Paulo * Method to emit a signal for a service discovery request.
1967d4f2939cSRui Paulo * The signal will carry station address, frequency, dialog token,
1968d4f2939cSRui Paulo * update indicator and it tlvs
1969d4f2939cSRui Paulo *
1970d4f2939cSRui Paulo * @wpa_s: %wpa_supplicant network interface data
1971d4f2939cSRui Paulo * @sa: station addr (p2p i/f) of the peer
1972d4f2939cSRui Paulo * @dialog_token: service discovery request dialog token
1973d4f2939cSRui Paulo * @update_indic: service discovery request update indicator
1974c1d255d3SCy Schubert * @tlvs: service discovery request generated byte array of tlvs
1975d4f2939cSRui Paulo * @tlvs_len: service discovery request tlvs length
1976d4f2939cSRui Paulo */
wpas_dbus_signal_p2p_sd_request(struct wpa_supplicant * wpa_s,int freq,const u8 * sa,u8 dialog_token,u16 update_indic,const u8 * tlvs,size_t tlvs_len)1977d4f2939cSRui Paulo void wpas_dbus_signal_p2p_sd_request(struct wpa_supplicant *wpa_s,
1978d4f2939cSRui Paulo int freq, const u8 *sa, u8 dialog_token,
1979d4f2939cSRui Paulo u16 update_indic, const u8 *tlvs,
1980d4f2939cSRui Paulo size_t tlvs_len)
1981d4f2939cSRui Paulo {
1982d4f2939cSRui Paulo DBusMessage *msg;
1983d4f2939cSRui Paulo DBusMessageIter iter, dict_iter;
1984d4f2939cSRui Paulo struct wpas_dbus_priv *iface;
1985d4f2939cSRui Paulo char peer_obj_path[WPAS_DBUS_OBJECT_PATH_MAX], *path;
19865b9c547cSRui Paulo
1987d4f2939cSRui Paulo iface = wpa_s->global->dbus;
1988d4f2939cSRui Paulo
1989d4f2939cSRui Paulo /* Do nothing if the control interface is not turned on */
1990d4f2939cSRui Paulo if (iface == NULL)
1991d4f2939cSRui Paulo return;
1992d4f2939cSRui Paulo
19935b9c547cSRui Paulo if (wpa_s->p2p_mgmt)
19945b9c547cSRui Paulo wpa_s = wpa_s->parent;
1995325151a3SRui Paulo if (!wpa_s->dbus_new_path)
1996325151a3SRui Paulo return;
19975b9c547cSRui Paulo
19985b9c547cSRui Paulo /* Check if this is a known peer */
19995b9c547cSRui Paulo if (!p2p_peer_known(wpa_s->global->p2p, sa))
20005b9c547cSRui Paulo return;
20015b9c547cSRui Paulo
2002d4f2939cSRui Paulo msg = dbus_message_new_signal(wpa_s->dbus_new_path,
2003d4f2939cSRui Paulo WPAS_DBUS_NEW_IFACE_P2PDEVICE,
2004d4f2939cSRui Paulo "ServiceDiscoveryRequest");
2005d4f2939cSRui Paulo if (msg == NULL)
2006d4f2939cSRui Paulo return;
2007d4f2939cSRui Paulo
2008d4f2939cSRui Paulo os_snprintf(peer_obj_path, WPAS_DBUS_OBJECT_PATH_MAX,
2009d4f2939cSRui Paulo "%s/" WPAS_DBUS_NEW_P2P_PEERS_PART "/"
2010d4f2939cSRui Paulo COMPACT_MACSTR, wpa_s->dbus_new_path, MAC2STR(sa));
2011d4f2939cSRui Paulo
2012d4f2939cSRui Paulo path = peer_obj_path;
2013d4f2939cSRui Paulo
2014d4f2939cSRui Paulo dbus_message_iter_init_append(msg, &iter);
20155b9c547cSRui Paulo if (!wpa_dbus_dict_open_write(&iter, &dict_iter) ||
20165b9c547cSRui Paulo !wpa_dbus_dict_append_object_path(&dict_iter, "peer_object",
2017d4f2939cSRui Paulo path) ||
2018d4f2939cSRui Paulo !wpa_dbus_dict_append_int32(&dict_iter, "frequency", freq) ||
2019d4f2939cSRui Paulo !wpa_dbus_dict_append_int32(&dict_iter, "dialog_token",
2020d4f2939cSRui Paulo dialog_token) ||
2021d4f2939cSRui Paulo !wpa_dbus_dict_append_uint16(&dict_iter, "update_indicator",
2022d4f2939cSRui Paulo update_indic) ||
2023d4f2939cSRui Paulo !wpa_dbus_dict_append_byte_array(&dict_iter, "tlvs",
2024d4f2939cSRui Paulo (const char *) tlvs,
2025d4f2939cSRui Paulo tlvs_len) ||
2026d4f2939cSRui Paulo !wpa_dbus_dict_close_write(&iter, &dict_iter))
2027d4f2939cSRui Paulo wpa_printf(MSG_ERROR, "dbus: Failed to construct signal");
20285b9c547cSRui Paulo else
20295b9c547cSRui Paulo dbus_connection_send(iface->con, msg, NULL);
2030d4f2939cSRui Paulo dbus_message_unref(msg);
2031d4f2939cSRui Paulo }
2032d4f2939cSRui Paulo
2033d4f2939cSRui Paulo
2034d4f2939cSRui Paulo /**
2035d4f2939cSRui Paulo *
2036d4f2939cSRui Paulo * Method to emit a signal for a service discovery response.
2037d4f2939cSRui Paulo * The signal will carry station address, update indicator and it
2038d4f2939cSRui Paulo * tlvs
2039d4f2939cSRui Paulo *
2040d4f2939cSRui Paulo * @wpa_s: %wpa_supplicant network interface data
2041d4f2939cSRui Paulo * @sa: station addr (p2p i/f) of the peer
2042d4f2939cSRui Paulo * @update_indic: service discovery request update indicator
2043c1d255d3SCy Schubert * @tlvs: service discovery request generated byte array of tlvs
2044d4f2939cSRui Paulo * @tlvs_len: service discovery request tlvs length
2045d4f2939cSRui Paulo */
wpas_dbus_signal_p2p_sd_response(struct wpa_supplicant * wpa_s,const u8 * sa,u16 update_indic,const u8 * tlvs,size_t tlvs_len)2046d4f2939cSRui Paulo void wpas_dbus_signal_p2p_sd_response(struct wpa_supplicant *wpa_s,
2047d4f2939cSRui Paulo const u8 *sa, u16 update_indic,
2048d4f2939cSRui Paulo const u8 *tlvs, size_t tlvs_len)
2049d4f2939cSRui Paulo {
2050d4f2939cSRui Paulo DBusMessage *msg;
2051d4f2939cSRui Paulo DBusMessageIter iter, dict_iter;
2052d4f2939cSRui Paulo struct wpas_dbus_priv *iface;
2053d4f2939cSRui Paulo char peer_obj_path[WPAS_DBUS_OBJECT_PATH_MAX], *path;
20545b9c547cSRui Paulo
2055d4f2939cSRui Paulo iface = wpa_s->global->dbus;
2056d4f2939cSRui Paulo
2057d4f2939cSRui Paulo /* Do nothing if the control interface is not turned on */
2058d4f2939cSRui Paulo if (iface == NULL)
2059d4f2939cSRui Paulo return;
2060d4f2939cSRui Paulo
20615b9c547cSRui Paulo if (wpa_s->p2p_mgmt)
20625b9c547cSRui Paulo wpa_s = wpa_s->parent;
2063325151a3SRui Paulo if (!wpa_s->dbus_new_path)
2064325151a3SRui Paulo return;
20655b9c547cSRui Paulo
20665b9c547cSRui Paulo /* Check if this is a known peer */
20675b9c547cSRui Paulo if (!p2p_peer_known(wpa_s->global->p2p, sa))
20685b9c547cSRui Paulo return;
20695b9c547cSRui Paulo
2070d4f2939cSRui Paulo msg = dbus_message_new_signal(wpa_s->dbus_new_path,
2071d4f2939cSRui Paulo WPAS_DBUS_NEW_IFACE_P2PDEVICE,
2072d4f2939cSRui Paulo "ServiceDiscoveryResponse");
2073d4f2939cSRui Paulo if (msg == NULL)
2074d4f2939cSRui Paulo return;
2075d4f2939cSRui Paulo
2076d4f2939cSRui Paulo os_snprintf(peer_obj_path, WPAS_DBUS_OBJECT_PATH_MAX,
2077d4f2939cSRui Paulo "%s/" WPAS_DBUS_NEW_P2P_PEERS_PART "/"
2078d4f2939cSRui Paulo COMPACT_MACSTR, wpa_s->dbus_new_path, MAC2STR(sa));
2079d4f2939cSRui Paulo
2080d4f2939cSRui Paulo path = peer_obj_path;
2081d4f2939cSRui Paulo
2082d4f2939cSRui Paulo dbus_message_iter_init_append(msg, &iter);
20835b9c547cSRui Paulo if (!wpa_dbus_dict_open_write(&iter, &dict_iter) ||
20845b9c547cSRui Paulo !wpa_dbus_dict_append_object_path(&dict_iter, "peer_object",
2085d4f2939cSRui Paulo path) ||
2086d4f2939cSRui Paulo !wpa_dbus_dict_append_uint16(&dict_iter, "update_indicator",
2087d4f2939cSRui Paulo update_indic) ||
2088d4f2939cSRui Paulo !wpa_dbus_dict_append_byte_array(&dict_iter, "tlvs",
2089d4f2939cSRui Paulo (const char *) tlvs,
2090d4f2939cSRui Paulo tlvs_len) ||
2091d4f2939cSRui Paulo !wpa_dbus_dict_close_write(&iter, &dict_iter))
20925b9c547cSRui Paulo wpa_printf(MSG_ERROR, "dbus: Failed to construct signal");
20935b9c547cSRui Paulo else
2094d4f2939cSRui Paulo dbus_connection_send(iface->con, msg, NULL);
2095d4f2939cSRui Paulo dbus_message_unref(msg);
2096d4f2939cSRui Paulo }
2097d4f2939cSRui Paulo
20985b9c547cSRui Paulo
2099d4f2939cSRui Paulo /**
2100d4f2939cSRui Paulo * wpas_dbus_signal_persistent_group - Send a persistent group related
2101d4f2939cSRui Paulo * event signal
2102d4f2939cSRui Paulo * @wpa_s: %wpa_supplicant network interface data
2103d4f2939cSRui Paulo * @id: new persistent group id
2104d4f2939cSRui Paulo * @sig_name: signal name - PersistentGroupAdded, PersistentGroupRemoved
2105d4f2939cSRui Paulo * @properties: determines if add second argument with object properties
2106d4f2939cSRui Paulo *
2107d4f2939cSRui Paulo * Notify listeners about an event related to persistent groups.
2108d4f2939cSRui Paulo */
wpas_dbus_signal_persistent_group(struct wpa_supplicant * wpa_s,int id,const char * sig_name,dbus_bool_t properties)2109d4f2939cSRui Paulo static void wpas_dbus_signal_persistent_group(struct wpa_supplicant *wpa_s,
2110d4f2939cSRui Paulo int id, const char *sig_name,
21114bc52338SCy Schubert dbus_bool_t properties)
2112d4f2939cSRui Paulo {
2113d4f2939cSRui Paulo struct wpas_dbus_priv *iface;
2114d4f2939cSRui Paulo DBusMessage *msg;
2115d4f2939cSRui Paulo DBusMessageIter iter;
2116d4f2939cSRui Paulo char pgrp_obj_path[WPAS_DBUS_OBJECT_PATH_MAX], *path;
2117d4f2939cSRui Paulo
2118d4f2939cSRui Paulo iface = wpa_s->global->dbus;
2119d4f2939cSRui Paulo
2120d4f2939cSRui Paulo /* Do nothing if the control interface is not turned on */
2121d4f2939cSRui Paulo if (iface == NULL)
2122d4f2939cSRui Paulo return;
2123d4f2939cSRui Paulo
21245b9c547cSRui Paulo if (wpa_s->p2p_mgmt)
21255b9c547cSRui Paulo wpa_s = wpa_s->parent;
2126325151a3SRui Paulo if (!wpa_s->dbus_new_path)
2127325151a3SRui Paulo return;
21285b9c547cSRui Paulo
2129d4f2939cSRui Paulo os_snprintf(pgrp_obj_path, WPAS_DBUS_OBJECT_PATH_MAX,
2130d4f2939cSRui Paulo "%s/" WPAS_DBUS_NEW_PERSISTENT_GROUPS_PART "/%u",
2131d4f2939cSRui Paulo wpa_s->dbus_new_path, id);
2132d4f2939cSRui Paulo
2133d4f2939cSRui Paulo msg = dbus_message_new_signal(wpa_s->dbus_new_path,
2134d4f2939cSRui Paulo WPAS_DBUS_NEW_IFACE_P2PDEVICE,
2135d4f2939cSRui Paulo sig_name);
2136d4f2939cSRui Paulo if (msg == NULL)
2137d4f2939cSRui Paulo return;
2138d4f2939cSRui Paulo
2139d4f2939cSRui Paulo dbus_message_iter_init_append(msg, &iter);
2140d4f2939cSRui Paulo path = pgrp_obj_path;
2141d4f2939cSRui Paulo if (!dbus_message_iter_append_basic(&iter, DBUS_TYPE_OBJECT_PATH,
21425b9c547cSRui Paulo &path) ||
21435b9c547cSRui Paulo (properties &&
21445b9c547cSRui Paulo !wpa_dbus_get_object_properties(
2145d4f2939cSRui Paulo iface, pgrp_obj_path,
21465b9c547cSRui Paulo WPAS_DBUS_NEW_IFACE_PERSISTENT_GROUP, &iter)))
21475b9c547cSRui Paulo wpa_printf(MSG_ERROR, "dbus: Failed to construct signal");
21485b9c547cSRui Paulo else
2149d4f2939cSRui Paulo dbus_connection_send(iface->con, msg, NULL);
2150d4f2939cSRui Paulo
2151d4f2939cSRui Paulo dbus_message_unref(msg);
2152d4f2939cSRui Paulo }
2153d4f2939cSRui Paulo
2154d4f2939cSRui Paulo
2155d4f2939cSRui Paulo /**
2156d4f2939cSRui Paulo * wpas_dbus_signal_persistent_group_added - Send a persistent_group
2157d4f2939cSRui Paulo * added signal
2158d4f2939cSRui Paulo * @wpa_s: %wpa_supplicant network interface data
2159d4f2939cSRui Paulo * @id: new persistent group id
2160d4f2939cSRui Paulo *
2161d4f2939cSRui Paulo * Notify listeners about addition of a new persistent group.
2162d4f2939cSRui Paulo */
wpas_dbus_signal_persistent_group_added(struct wpa_supplicant * wpa_s,int id)2163d4f2939cSRui Paulo static void wpas_dbus_signal_persistent_group_added(
2164d4f2939cSRui Paulo struct wpa_supplicant *wpa_s, int id)
2165d4f2939cSRui Paulo {
2166d4f2939cSRui Paulo wpas_dbus_signal_persistent_group(wpa_s, id, "PersistentGroupAdded",
2167d4f2939cSRui Paulo TRUE);
2168d4f2939cSRui Paulo }
2169d4f2939cSRui Paulo
2170d4f2939cSRui Paulo
2171d4f2939cSRui Paulo /**
2172d4f2939cSRui Paulo * wpas_dbus_signal_persistent_group_removed - Send a persistent_group
2173d4f2939cSRui Paulo * removed signal
2174d4f2939cSRui Paulo * @wpa_s: %wpa_supplicant network interface data
2175d4f2939cSRui Paulo * @id: persistent group id
2176d4f2939cSRui Paulo *
2177d4f2939cSRui Paulo * Notify listeners about removal of a persistent group.
2178d4f2939cSRui Paulo */
wpas_dbus_signal_persistent_group_removed(struct wpa_supplicant * wpa_s,int id)2179d4f2939cSRui Paulo static void wpas_dbus_signal_persistent_group_removed(
2180d4f2939cSRui Paulo struct wpa_supplicant *wpa_s, int id)
2181d4f2939cSRui Paulo {
2182d4f2939cSRui Paulo wpas_dbus_signal_persistent_group(wpa_s, id, "PersistentGroupRemoved",
2183d4f2939cSRui Paulo FALSE);
2184d4f2939cSRui Paulo }
2185d4f2939cSRui Paulo
2186d4f2939cSRui Paulo
2187d4f2939cSRui Paulo /**
2188d4f2939cSRui Paulo * wpas_dbus_signal_p2p_wps_failed - Signals WpsFailed event
2189d4f2939cSRui Paulo * @wpa_s: %wpa_supplicant network interface data
2190325151a3SRui Paulo * @fail: WPS failure information
2191d4f2939cSRui Paulo *
2192d4f2939cSRui Paulo * Sends Event dbus signal with name "fail" and dictionary containing
2193d4f2939cSRui Paulo * "msg" field with fail message number (int32) as arguments
2194d4f2939cSRui Paulo */
wpas_dbus_signal_p2p_wps_failed(struct wpa_supplicant * wpa_s,struct wps_event_fail * fail)2195d4f2939cSRui Paulo void wpas_dbus_signal_p2p_wps_failed(struct wpa_supplicant *wpa_s,
2196d4f2939cSRui Paulo struct wps_event_fail *fail)
2197d4f2939cSRui Paulo {
2198d4f2939cSRui Paulo
2199d4f2939cSRui Paulo DBusMessage *msg;
2200d4f2939cSRui Paulo DBusMessageIter iter, dict_iter;
2201d4f2939cSRui Paulo struct wpas_dbus_priv *iface;
2202d4f2939cSRui Paulo char *key = "fail";
2203d4f2939cSRui Paulo
2204d4f2939cSRui Paulo iface = wpa_s->global->dbus;
2205d4f2939cSRui Paulo
2206d4f2939cSRui Paulo /* Do nothing if the control interface is not turned on */
2207d4f2939cSRui Paulo if (iface == NULL)
2208d4f2939cSRui Paulo return;
2209d4f2939cSRui Paulo
22105b9c547cSRui Paulo if (wpa_s->p2p_mgmt)
22115b9c547cSRui Paulo wpa_s = wpa_s->parent;
22125b9c547cSRui Paulo
2213325151a3SRui Paulo if (!wpa_s->dbus_new_path)
2214325151a3SRui Paulo return;
2215d4f2939cSRui Paulo msg = dbus_message_new_signal(wpa_s->dbus_new_path,
2216d4f2939cSRui Paulo WPAS_DBUS_NEW_IFACE_P2PDEVICE,
2217d4f2939cSRui Paulo "WpsFailed");
2218d4f2939cSRui Paulo if (msg == NULL)
2219d4f2939cSRui Paulo return;
2220d4f2939cSRui Paulo
2221d4f2939cSRui Paulo dbus_message_iter_init_append(msg, &iter);
2222d4f2939cSRui Paulo
2223d4f2939cSRui Paulo if (!dbus_message_iter_append_basic(&iter, DBUS_TYPE_STRING, &key) ||
2224d4f2939cSRui Paulo !wpa_dbus_dict_open_write(&iter, &dict_iter) ||
2225d4f2939cSRui Paulo !wpa_dbus_dict_append_int32(&dict_iter, "msg", fail->msg) ||
2226d4f2939cSRui Paulo !wpa_dbus_dict_append_int16(&dict_iter, "config_error",
2227d4f2939cSRui Paulo fail->config_error) ||
2228d4f2939cSRui Paulo !wpa_dbus_dict_close_write(&iter, &dict_iter))
2229d4f2939cSRui Paulo wpa_printf(MSG_ERROR, "dbus: Failed to construct signal");
2230d4f2939cSRui Paulo else
2231d4f2939cSRui Paulo dbus_connection_send(iface->con, msg, NULL);
2232d4f2939cSRui Paulo
2233d4f2939cSRui Paulo dbus_message_unref(msg);
2234d4f2939cSRui Paulo }
2235d4f2939cSRui Paulo
2236325151a3SRui Paulo
2237325151a3SRui Paulo /**
2238325151a3SRui Paulo * wpas_dbus_signal_p2p_group_formation_failure - Signals GroupFormationFailure event
2239325151a3SRui Paulo * @wpa_s: %wpa_supplicant network interface data
2240325151a3SRui Paulo * @reason: indicates the reason code for group formation failure
2241325151a3SRui Paulo *
2242325151a3SRui Paulo * Sends Event dbus signal and string reason code when available.
2243325151a3SRui Paulo */
wpas_dbus_signal_p2p_group_formation_failure(struct wpa_supplicant * wpa_s,const char * reason)2244325151a3SRui Paulo void wpas_dbus_signal_p2p_group_formation_failure(struct wpa_supplicant *wpa_s,
2245325151a3SRui Paulo const char *reason)
2246325151a3SRui Paulo {
2247325151a3SRui Paulo DBusMessage *msg;
2248325151a3SRui Paulo struct wpas_dbus_priv *iface;
2249325151a3SRui Paulo
2250325151a3SRui Paulo iface = wpa_s->global->dbus;
2251325151a3SRui Paulo
2252325151a3SRui Paulo /* Do nothing if the control interface is not turned on */
2253325151a3SRui Paulo if (iface == NULL)
2254325151a3SRui Paulo return;
2255325151a3SRui Paulo
225685732ac8SCy Schubert if (wpa_s->p2p_mgmt)
225785732ac8SCy Schubert wpa_s = wpa_s->parent;
225885732ac8SCy Schubert
2259325151a3SRui Paulo msg = dbus_message_new_signal(wpa_s->dbus_new_path,
2260325151a3SRui Paulo WPAS_DBUS_NEW_IFACE_P2PDEVICE,
2261325151a3SRui Paulo "GroupFormationFailure");
2262325151a3SRui Paulo if (msg == NULL)
2263325151a3SRui Paulo return;
2264325151a3SRui Paulo
2265325151a3SRui Paulo if (dbus_message_append_args(msg, DBUS_TYPE_STRING, &reason,
2266325151a3SRui Paulo DBUS_TYPE_INVALID))
2267325151a3SRui Paulo dbus_connection_send(iface->con, msg, NULL);
2268325151a3SRui Paulo else
2269325151a3SRui Paulo wpa_printf(MSG_ERROR, "dbus: Failed to construct signal");
2270325151a3SRui Paulo
2271325151a3SRui Paulo dbus_message_unref(msg);
2272325151a3SRui Paulo }
2273325151a3SRui Paulo
2274325151a3SRui Paulo
2275325151a3SRui Paulo /**
2276325151a3SRui Paulo * wpas_dbus_signal_p2p_invitation_received - Emit InvitationReceived signal
2277325151a3SRui Paulo * @wpa_s: %wpa_supplicant network interface data
2278325151a3SRui Paulo * @sa: Source address of the Invitation Request
2279325151a3SRui Paulo * @dev_add: GO Device Address
2280325151a3SRui Paulo * @bssid: P2P Group BSSID or %NULL if not received
2281325151a3SRui Paulo * @id: Persistent group id or %0 if not persistent group
2282325151a3SRui Paulo * @op_freq: Operating frequency for the group
2283325151a3SRui Paulo */
2284325151a3SRui Paulo
wpas_dbus_signal_p2p_invitation_received(struct wpa_supplicant * wpa_s,const u8 * sa,const u8 * dev_addr,const u8 * bssid,int id,int op_freq)2285325151a3SRui Paulo void wpas_dbus_signal_p2p_invitation_received(struct wpa_supplicant *wpa_s,
2286325151a3SRui Paulo const u8 *sa, const u8 *dev_addr,
2287325151a3SRui Paulo const u8 *bssid, int id,
2288325151a3SRui Paulo int op_freq)
2289325151a3SRui Paulo {
2290325151a3SRui Paulo DBusMessage *msg;
2291325151a3SRui Paulo DBusMessageIter iter, dict_iter;
2292325151a3SRui Paulo struct wpas_dbus_priv *iface;
2293325151a3SRui Paulo
2294325151a3SRui Paulo iface = wpa_s->global->dbus;
2295325151a3SRui Paulo
2296325151a3SRui Paulo /* Do nothing if the control interface is not turned on */
2297325151a3SRui Paulo if (iface == NULL)
2298325151a3SRui Paulo return;
2299325151a3SRui Paulo
230085732ac8SCy Schubert if (wpa_s->p2p_mgmt)
230185732ac8SCy Schubert wpa_s = wpa_s->parent;
230285732ac8SCy Schubert
2303325151a3SRui Paulo msg = dbus_message_new_signal(wpa_s->dbus_new_path,
2304325151a3SRui Paulo WPAS_DBUS_NEW_IFACE_P2PDEVICE,
2305325151a3SRui Paulo "InvitationReceived");
2306325151a3SRui Paulo if (msg == NULL)
2307325151a3SRui Paulo return;
2308325151a3SRui Paulo
2309325151a3SRui Paulo dbus_message_iter_init_append(msg, &iter);
2310325151a3SRui Paulo if (!wpa_dbus_dict_open_write(&iter, &dict_iter) ||
2311325151a3SRui Paulo (sa &&
2312325151a3SRui Paulo !wpa_dbus_dict_append_byte_array(&dict_iter, "sa",
2313325151a3SRui Paulo (const char *) sa, ETH_ALEN)) ||
2314325151a3SRui Paulo (dev_addr &&
2315325151a3SRui Paulo !wpa_dbus_dict_append_byte_array(&dict_iter, "go_dev_addr",
2316325151a3SRui Paulo (const char *) dev_addr,
2317325151a3SRui Paulo ETH_ALEN)) ||
2318325151a3SRui Paulo (bssid &&
2319325151a3SRui Paulo !wpa_dbus_dict_append_byte_array(&dict_iter, "bssid",
2320325151a3SRui Paulo (const char *) bssid,
2321325151a3SRui Paulo ETH_ALEN)) ||
2322325151a3SRui Paulo (id &&
2323325151a3SRui Paulo !wpa_dbus_dict_append_int32(&dict_iter, "persistent_id", id)) ||
2324325151a3SRui Paulo !wpa_dbus_dict_append_int32(&dict_iter, "op_freq", op_freq) ||
2325325151a3SRui Paulo !wpa_dbus_dict_close_write(&iter, &dict_iter)) {
2326325151a3SRui Paulo dbus_message_unref(msg);
2327325151a3SRui Paulo return;
2328325151a3SRui Paulo }
2329325151a3SRui Paulo
2330325151a3SRui Paulo dbus_connection_send(iface->con, msg, NULL);
2331780fb4a2SCy Schubert dbus_message_unref(msg);
2332325151a3SRui Paulo }
2333325151a3SRui Paulo
2334325151a3SRui Paulo
2335d4f2939cSRui Paulo #endif /* CONFIG_P2P */
2336d4f2939cSRui Paulo
2337d4f2939cSRui Paulo
2338d4f2939cSRui Paulo /**
2339d4f2939cSRui Paulo * wpas_dbus_signal_prop_changed - Signals change of property
2340d4f2939cSRui Paulo * @wpa_s: %wpa_supplicant network interface data
2341d4f2939cSRui Paulo * @property: indicates which property has changed
2342d4f2939cSRui Paulo *
2343d4f2939cSRui Paulo * Sends PropertyChanged signals with path, interface and arguments
2344d4f2939cSRui Paulo * depending on which property has changed.
2345d4f2939cSRui Paulo */
wpas_dbus_signal_prop_changed(struct wpa_supplicant * wpa_s,enum wpas_dbus_prop property)2346d4f2939cSRui Paulo void wpas_dbus_signal_prop_changed(struct wpa_supplicant *wpa_s,
2347d4f2939cSRui Paulo enum wpas_dbus_prop property)
2348d4f2939cSRui Paulo {
2349d4f2939cSRui Paulo char *prop;
2350d4f2939cSRui Paulo dbus_bool_t flush;
2351d4f2939cSRui Paulo
2352d4f2939cSRui Paulo if (wpa_s->dbus_new_path == NULL)
2353d4f2939cSRui Paulo return; /* Skip signal since D-Bus setup is not yet ready */
2354d4f2939cSRui Paulo
2355d4f2939cSRui Paulo flush = FALSE;
2356d4f2939cSRui Paulo switch (property) {
2357d4f2939cSRui Paulo case WPAS_DBUS_PROP_AP_SCAN:
2358d4f2939cSRui Paulo prop = "ApScan";
2359d4f2939cSRui Paulo break;
2360d4f2939cSRui Paulo case WPAS_DBUS_PROP_SCANNING:
2361d4f2939cSRui Paulo prop = "Scanning";
2362d4f2939cSRui Paulo break;
2363d4f2939cSRui Paulo case WPAS_DBUS_PROP_STATE:
2364d4f2939cSRui Paulo prop = "State";
2365d4f2939cSRui Paulo break;
2366d4f2939cSRui Paulo case WPAS_DBUS_PROP_CURRENT_BSS:
2367d4f2939cSRui Paulo prop = "CurrentBSS";
2368d4f2939cSRui Paulo break;
2369d4f2939cSRui Paulo case WPAS_DBUS_PROP_CURRENT_NETWORK:
2370d4f2939cSRui Paulo prop = "CurrentNetwork";
2371d4f2939cSRui Paulo break;
2372d4f2939cSRui Paulo case WPAS_DBUS_PROP_BSSS:
2373d4f2939cSRui Paulo prop = "BSSs";
2374d4f2939cSRui Paulo break;
23754bc52338SCy Schubert case WPAS_DBUS_PROP_STATIONS:
23764bc52338SCy Schubert prop = "Stations";
23774bc52338SCy Schubert break;
2378d4f2939cSRui Paulo case WPAS_DBUS_PROP_CURRENT_AUTH_MODE:
2379d4f2939cSRui Paulo prop = "CurrentAuthMode";
2380d4f2939cSRui Paulo break;
2381d4f2939cSRui Paulo case WPAS_DBUS_PROP_DISCONNECT_REASON:
2382d4f2939cSRui Paulo prop = "DisconnectReason";
2383d4f2939cSRui Paulo flush = TRUE;
2384d4f2939cSRui Paulo break;
23854bc52338SCy Schubert case WPAS_DBUS_PROP_AUTH_STATUS_CODE:
23864bc52338SCy Schubert prop = "AuthStatusCode";
23874bc52338SCy Schubert flush = TRUE;
23884bc52338SCy Schubert break;
2389780fb4a2SCy Schubert case WPAS_DBUS_PROP_ASSOC_STATUS_CODE:
2390780fb4a2SCy Schubert prop = "AssocStatusCode";
2391780fb4a2SCy Schubert flush = TRUE;
2392780fb4a2SCy Schubert break;
23934bc52338SCy Schubert case WPAS_DBUS_PROP_ROAM_TIME:
23944bc52338SCy Schubert prop = "RoamTime";
23954bc52338SCy Schubert break;
23964bc52338SCy Schubert case WPAS_DBUS_PROP_ROAM_COMPLETE:
23974bc52338SCy Schubert prop = "RoamComplete";
23984bc52338SCy Schubert break;
23994bc52338SCy Schubert case WPAS_DBUS_PROP_SESSION_LENGTH:
24004bc52338SCy Schubert prop = "SessionLength";
24014bc52338SCy Schubert break;
24024bc52338SCy Schubert case WPAS_DBUS_PROP_BSS_TM_STATUS:
24034bc52338SCy Schubert prop = "BSSTMStatus";
24044bc52338SCy Schubert break;
2405*a90b9d01SCy Schubert case WPAS_DBUS_PROP_MAC_ADDRESS:
2406*a90b9d01SCy Schubert prop = "MACAddress";
2407*a90b9d01SCy Schubert break;
2408*a90b9d01SCy Schubert case WPAS_DBUS_PROP_SIGNAL_CHANGE:
2409*a90b9d01SCy Schubert prop = "SignalChange";
2410*a90b9d01SCy Schubert break;
2411d4f2939cSRui Paulo default:
2412d4f2939cSRui Paulo wpa_printf(MSG_ERROR, "dbus: %s: Unknown Property value %d",
2413d4f2939cSRui Paulo __func__, property);
2414d4f2939cSRui Paulo return;
2415d4f2939cSRui Paulo }
2416d4f2939cSRui Paulo
2417d4f2939cSRui Paulo wpa_dbus_mark_property_changed(wpa_s->global->dbus,
2418d4f2939cSRui Paulo wpa_s->dbus_new_path,
2419d4f2939cSRui Paulo WPAS_DBUS_NEW_IFACE_INTERFACE, prop);
2420d4f2939cSRui Paulo if (flush) {
2421d4f2939cSRui Paulo wpa_dbus_flush_object_changed_properties(
2422d4f2939cSRui Paulo wpa_s->global->dbus->con, wpa_s->dbus_new_path);
2423d4f2939cSRui Paulo }
2424d4f2939cSRui Paulo }
2425d4f2939cSRui Paulo
2426d4f2939cSRui Paulo
2427d4f2939cSRui Paulo /**
2428d4f2939cSRui Paulo * wpas_dbus_bss_signal_prop_changed - Signals change of BSS property
2429d4f2939cSRui Paulo * @wpa_s: %wpa_supplicant network interface data
2430d4f2939cSRui Paulo * @property: indicates which property has changed
2431d4f2939cSRui Paulo * @id: unique BSS identifier
2432d4f2939cSRui Paulo *
2433d4f2939cSRui Paulo * Sends PropertyChanged signals with path, interface, and arguments depending
2434d4f2939cSRui Paulo * on which property has changed.
2435d4f2939cSRui Paulo */
wpas_dbus_bss_signal_prop_changed(struct wpa_supplicant * wpa_s,enum wpas_dbus_bss_prop property,unsigned int id)2436d4f2939cSRui Paulo void wpas_dbus_bss_signal_prop_changed(struct wpa_supplicant *wpa_s,
2437d4f2939cSRui Paulo enum wpas_dbus_bss_prop property,
2438d4f2939cSRui Paulo unsigned int id)
2439d4f2939cSRui Paulo {
2440d4f2939cSRui Paulo char path[WPAS_DBUS_OBJECT_PATH_MAX];
2441d4f2939cSRui Paulo char *prop;
2442d4f2939cSRui Paulo
2443325151a3SRui Paulo if (!wpa_s->dbus_new_path)
2444325151a3SRui Paulo return;
2445325151a3SRui Paulo
2446d4f2939cSRui Paulo switch (property) {
2447d4f2939cSRui Paulo case WPAS_DBUS_BSS_PROP_SIGNAL:
2448d4f2939cSRui Paulo prop = "Signal";
2449d4f2939cSRui Paulo break;
2450d4f2939cSRui Paulo case WPAS_DBUS_BSS_PROP_FREQ:
2451d4f2939cSRui Paulo prop = "Frequency";
2452d4f2939cSRui Paulo break;
2453d4f2939cSRui Paulo case WPAS_DBUS_BSS_PROP_MODE:
2454d4f2939cSRui Paulo prop = "Mode";
2455d4f2939cSRui Paulo break;
2456d4f2939cSRui Paulo case WPAS_DBUS_BSS_PROP_PRIVACY:
2457d4f2939cSRui Paulo prop = "Privacy";
2458d4f2939cSRui Paulo break;
2459d4f2939cSRui Paulo case WPAS_DBUS_BSS_PROP_RATES:
2460d4f2939cSRui Paulo prop = "Rates";
2461d4f2939cSRui Paulo break;
2462d4f2939cSRui Paulo case WPAS_DBUS_BSS_PROP_WPA:
2463d4f2939cSRui Paulo prop = "WPA";
2464d4f2939cSRui Paulo break;
2465d4f2939cSRui Paulo case WPAS_DBUS_BSS_PROP_RSN:
2466d4f2939cSRui Paulo prop = "RSN";
2467d4f2939cSRui Paulo break;
24685b9c547cSRui Paulo case WPAS_DBUS_BSS_PROP_WPS:
24695b9c547cSRui Paulo prop = "WPS";
24705b9c547cSRui Paulo break;
2471d4f2939cSRui Paulo case WPAS_DBUS_BSS_PROP_IES:
2472d4f2939cSRui Paulo prop = "IEs";
2473d4f2939cSRui Paulo break;
24745b9c547cSRui Paulo case WPAS_DBUS_BSS_PROP_AGE:
24755b9c547cSRui Paulo prop = "Age";
24765b9c547cSRui Paulo break;
2477*a90b9d01SCy Schubert case WPAS_DBUS_BSS_PROP_ANQP:
2478*a90b9d01SCy Schubert prop = "ANQP";
2479*a90b9d01SCy Schubert break;
2480d4f2939cSRui Paulo default:
2481d4f2939cSRui Paulo wpa_printf(MSG_ERROR, "dbus: %s: Unknown Property value %d",
2482d4f2939cSRui Paulo __func__, property);
2483d4f2939cSRui Paulo return;
2484d4f2939cSRui Paulo }
2485d4f2939cSRui Paulo
2486d4f2939cSRui Paulo os_snprintf(path, WPAS_DBUS_OBJECT_PATH_MAX,
2487d4f2939cSRui Paulo "%s/" WPAS_DBUS_NEW_BSSIDS_PART "/%u",
2488d4f2939cSRui Paulo wpa_s->dbus_new_path, id);
2489d4f2939cSRui Paulo
2490d4f2939cSRui Paulo wpa_dbus_mark_property_changed(wpa_s->global->dbus, path,
2491d4f2939cSRui Paulo WPAS_DBUS_NEW_IFACE_BSS, prop);
2492d4f2939cSRui Paulo }
2493d4f2939cSRui Paulo
2494d4f2939cSRui Paulo
2495d4f2939cSRui Paulo /**
24964bc52338SCy Schubert * wpas_dbus_sta_signal_prop_changed - Signals change of STA property
24974bc52338SCy Schubert * @wpa_s: %wpa_supplicant network interface data
24984bc52338SCy Schubert * @property: indicates which property has changed
24994bc52338SCy Schubert * @address: unique BSS identifier
25004bc52338SCy Schubert *
25014bc52338SCy Schubert * Sends PropertyChanged signals with path, interface, and arguments depending
25024bc52338SCy Schubert * on which property has changed.
25034bc52338SCy Schubert */
wpas_dbus_sta_signal_prop_changed(struct wpa_supplicant * wpa_s,enum wpas_dbus_bss_prop property,u8 address[ETH_ALEN])25044bc52338SCy Schubert void wpas_dbus_sta_signal_prop_changed(struct wpa_supplicant *wpa_s,
25054bc52338SCy Schubert enum wpas_dbus_bss_prop property,
25064bc52338SCy Schubert u8 address[ETH_ALEN])
25074bc52338SCy Schubert {
25084bc52338SCy Schubert char path[WPAS_DBUS_OBJECT_PATH_MAX];
25094bc52338SCy Schubert char *prop;
25104bc52338SCy Schubert
25114bc52338SCy Schubert switch (property) {
25124bc52338SCy Schubert case WPAS_DBUS_STA_PROP_ADDRESS:
25134bc52338SCy Schubert prop = "Address";
25144bc52338SCy Schubert break;
25154bc52338SCy Schubert default:
25164bc52338SCy Schubert wpa_printf(MSG_ERROR, "dbus: %s: Unknown Property value %d",
25174bc52338SCy Schubert __func__, property);
25184bc52338SCy Schubert return;
25194bc52338SCy Schubert }
25204bc52338SCy Schubert
25214bc52338SCy Schubert os_snprintf(path, WPAS_DBUS_OBJECT_PATH_MAX,
25224bc52338SCy Schubert "%s/" WPAS_DBUS_NEW_STAS_PART "/" COMPACT_MACSTR,
25234bc52338SCy Schubert wpa_s->dbus_new_path, MAC2STR(address));
25244bc52338SCy Schubert
25254bc52338SCy Schubert wpa_dbus_mark_property_changed(wpa_s->global->dbus, path,
25264bc52338SCy Schubert WPAS_DBUS_NEW_IFACE_STA, prop);
25274bc52338SCy Schubert }
25284bc52338SCy Schubert
25294bc52338SCy Schubert
25304bc52338SCy Schubert /**
2531d4f2939cSRui Paulo * wpas_dbus_signal_debug_level_changed - Signals change of debug param
2532d4f2939cSRui Paulo * @global: wpa_global structure
2533d4f2939cSRui Paulo *
2534d4f2939cSRui Paulo * Sends PropertyChanged signals informing that debug level has changed.
2535d4f2939cSRui Paulo */
wpas_dbus_signal_debug_level_changed(struct wpa_global * global)2536d4f2939cSRui Paulo void wpas_dbus_signal_debug_level_changed(struct wpa_global *global)
2537d4f2939cSRui Paulo {
2538d4f2939cSRui Paulo wpa_dbus_mark_property_changed(global->dbus, WPAS_DBUS_NEW_PATH,
2539d4f2939cSRui Paulo WPAS_DBUS_NEW_INTERFACE,
2540d4f2939cSRui Paulo "DebugLevel");
2541d4f2939cSRui Paulo }
2542d4f2939cSRui Paulo
2543d4f2939cSRui Paulo
2544d4f2939cSRui Paulo /**
2545d4f2939cSRui Paulo * wpas_dbus_signal_debug_timestamp_changed - Signals change of debug param
2546d4f2939cSRui Paulo * @global: wpa_global structure
2547d4f2939cSRui Paulo *
2548d4f2939cSRui Paulo * Sends PropertyChanged signals informing that debug timestamp has changed.
2549d4f2939cSRui Paulo */
wpas_dbus_signal_debug_timestamp_changed(struct wpa_global * global)2550d4f2939cSRui Paulo void wpas_dbus_signal_debug_timestamp_changed(struct wpa_global *global)
2551d4f2939cSRui Paulo {
2552d4f2939cSRui Paulo wpa_dbus_mark_property_changed(global->dbus, WPAS_DBUS_NEW_PATH,
2553d4f2939cSRui Paulo WPAS_DBUS_NEW_INTERFACE,
2554d4f2939cSRui Paulo "DebugTimestamp");
2555d4f2939cSRui Paulo }
2556d4f2939cSRui Paulo
2557d4f2939cSRui Paulo
2558d4f2939cSRui Paulo /**
2559d4f2939cSRui Paulo * wpas_dbus_signal_debug_show_keys_changed - Signals change of debug param
2560d4f2939cSRui Paulo * @global: wpa_global structure
2561d4f2939cSRui Paulo *
2562d4f2939cSRui Paulo * Sends PropertyChanged signals informing that debug show_keys has changed.
2563d4f2939cSRui Paulo */
wpas_dbus_signal_debug_show_keys_changed(struct wpa_global * global)2564d4f2939cSRui Paulo void wpas_dbus_signal_debug_show_keys_changed(struct wpa_global *global)
2565d4f2939cSRui Paulo {
2566d4f2939cSRui Paulo wpa_dbus_mark_property_changed(global->dbus, WPAS_DBUS_NEW_PATH,
2567d4f2939cSRui Paulo WPAS_DBUS_NEW_INTERFACE,
2568d4f2939cSRui Paulo "DebugShowKeys");
2569d4f2939cSRui Paulo }
2570d4f2939cSRui Paulo
2571d4f2939cSRui Paulo
wpas_dbus_register(struct wpa_dbus_object_desc * obj_desc,void * priv,WPADBusArgumentFreeFunction priv_free,const struct wpa_dbus_method_desc * methods,const struct wpa_dbus_property_desc * properties,const struct wpa_dbus_signal_desc * signals)2572d4f2939cSRui Paulo static void wpas_dbus_register(struct wpa_dbus_object_desc *obj_desc,
2573d4f2939cSRui Paulo void *priv,
2574d4f2939cSRui Paulo WPADBusArgumentFreeFunction priv_free,
2575d4f2939cSRui Paulo const struct wpa_dbus_method_desc *methods,
2576d4f2939cSRui Paulo const struct wpa_dbus_property_desc *properties,
2577d4f2939cSRui Paulo const struct wpa_dbus_signal_desc *signals)
2578d4f2939cSRui Paulo {
2579d4f2939cSRui Paulo int n;
2580d4f2939cSRui Paulo
2581d4f2939cSRui Paulo obj_desc->user_data = priv;
2582d4f2939cSRui Paulo obj_desc->user_data_free_func = priv_free;
2583d4f2939cSRui Paulo obj_desc->methods = methods;
2584d4f2939cSRui Paulo obj_desc->properties = properties;
2585d4f2939cSRui Paulo obj_desc->signals = signals;
2586d4f2939cSRui Paulo
2587d4f2939cSRui Paulo for (n = 0; properties && properties->dbus_property; properties++)
2588d4f2939cSRui Paulo n++;
2589d4f2939cSRui Paulo
2590d4f2939cSRui Paulo obj_desc->prop_changed_flags = os_zalloc(n);
2591d4f2939cSRui Paulo if (!obj_desc->prop_changed_flags)
2592d4f2939cSRui Paulo wpa_printf(MSG_DEBUG, "dbus: %s: can't register handlers",
2593d4f2939cSRui Paulo __func__);
2594d4f2939cSRui Paulo }
2595d4f2939cSRui Paulo
2596d4f2939cSRui Paulo
2597d4f2939cSRui Paulo static const struct wpa_dbus_method_desc wpas_dbus_global_methods[] = {
2598d4f2939cSRui Paulo { "CreateInterface", WPAS_DBUS_NEW_INTERFACE,
25995b9c547cSRui Paulo (WPADBusMethodHandler) wpas_dbus_handler_create_interface,
2600d4f2939cSRui Paulo {
2601d4f2939cSRui Paulo { "args", "a{sv}", ARG_IN },
2602d4f2939cSRui Paulo { "path", "o", ARG_OUT },
2603d4f2939cSRui Paulo END_ARGS
2604d4f2939cSRui Paulo }
2605d4f2939cSRui Paulo },
2606d4f2939cSRui Paulo { "RemoveInterface", WPAS_DBUS_NEW_INTERFACE,
26075b9c547cSRui Paulo (WPADBusMethodHandler) wpas_dbus_handler_remove_interface,
2608d4f2939cSRui Paulo {
2609d4f2939cSRui Paulo { "path", "o", ARG_IN },
2610d4f2939cSRui Paulo END_ARGS
2611d4f2939cSRui Paulo }
2612d4f2939cSRui Paulo },
2613d4f2939cSRui Paulo { "GetInterface", WPAS_DBUS_NEW_INTERFACE,
26145b9c547cSRui Paulo (WPADBusMethodHandler) wpas_dbus_handler_get_interface,
2615d4f2939cSRui Paulo {
2616d4f2939cSRui Paulo { "ifname", "s", ARG_IN },
2617d4f2939cSRui Paulo { "path", "o", ARG_OUT },
2618d4f2939cSRui Paulo END_ARGS
2619d4f2939cSRui Paulo }
2620d4f2939cSRui Paulo },
2621780fb4a2SCy Schubert { "ExpectDisconnect", WPAS_DBUS_NEW_INTERFACE,
2622780fb4a2SCy Schubert (WPADBusMethodHandler) wpas_dbus_handler_expect_disconnect,
2623780fb4a2SCy Schubert {
2624780fb4a2SCy Schubert END_ARGS
2625780fb4a2SCy Schubert }
2626780fb4a2SCy Schubert },
2627d4f2939cSRui Paulo { NULL, NULL, NULL, { END_ARGS } }
2628d4f2939cSRui Paulo };
2629d4f2939cSRui Paulo
2630d4f2939cSRui Paulo static const struct wpa_dbus_property_desc wpas_dbus_global_properties[] = {
2631d4f2939cSRui Paulo { "DebugLevel", WPAS_DBUS_NEW_INTERFACE, "s",
2632d4f2939cSRui Paulo wpas_dbus_getter_debug_level,
2633780fb4a2SCy Schubert wpas_dbus_setter_debug_level,
2634780fb4a2SCy Schubert NULL
2635d4f2939cSRui Paulo },
2636d4f2939cSRui Paulo { "DebugTimestamp", WPAS_DBUS_NEW_INTERFACE, "b",
2637d4f2939cSRui Paulo wpas_dbus_getter_debug_timestamp,
2638780fb4a2SCy Schubert wpas_dbus_setter_debug_timestamp,
2639780fb4a2SCy Schubert NULL
2640d4f2939cSRui Paulo },
2641d4f2939cSRui Paulo { "DebugShowKeys", WPAS_DBUS_NEW_INTERFACE, "b",
2642d4f2939cSRui Paulo wpas_dbus_getter_debug_show_keys,
2643780fb4a2SCy Schubert wpas_dbus_setter_debug_show_keys,
2644780fb4a2SCy Schubert NULL
2645d4f2939cSRui Paulo },
2646d4f2939cSRui Paulo { "Interfaces", WPAS_DBUS_NEW_INTERFACE, "ao",
2647d4f2939cSRui Paulo wpas_dbus_getter_interfaces,
2648780fb4a2SCy Schubert NULL,
2649d4f2939cSRui Paulo NULL
2650d4f2939cSRui Paulo },
2651d4f2939cSRui Paulo { "EapMethods", WPAS_DBUS_NEW_INTERFACE, "as",
2652d4f2939cSRui Paulo wpas_dbus_getter_eap_methods,
2653780fb4a2SCy Schubert NULL,
2654d4f2939cSRui Paulo NULL
2655d4f2939cSRui Paulo },
2656d4f2939cSRui Paulo { "Capabilities", WPAS_DBUS_NEW_INTERFACE, "as",
2657d4f2939cSRui Paulo wpas_dbus_getter_global_capabilities,
2658780fb4a2SCy Schubert NULL,
2659d4f2939cSRui Paulo NULL
2660d4f2939cSRui Paulo },
26615b9c547cSRui Paulo #ifdef CONFIG_WIFI_DISPLAY
26625b9c547cSRui Paulo { "WFDIEs", WPAS_DBUS_NEW_INTERFACE, "ay",
26635b9c547cSRui Paulo wpas_dbus_getter_global_wfd_ies,
2664780fb4a2SCy Schubert wpas_dbus_setter_global_wfd_ies,
2665780fb4a2SCy Schubert NULL
26665b9c547cSRui Paulo },
26675b9c547cSRui Paulo #endif /* CONFIG_WIFI_DISPLAY */
2668780fb4a2SCy Schubert { NULL, NULL, NULL, NULL, NULL, NULL }
2669d4f2939cSRui Paulo };
2670d4f2939cSRui Paulo
2671d4f2939cSRui Paulo static const struct wpa_dbus_signal_desc wpas_dbus_global_signals[] = {
2672d4f2939cSRui Paulo { "InterfaceAdded", WPAS_DBUS_NEW_INTERFACE,
2673d4f2939cSRui Paulo {
2674d4f2939cSRui Paulo { "path", "o", ARG_OUT },
2675d4f2939cSRui Paulo { "properties", "a{sv}", ARG_OUT },
2676d4f2939cSRui Paulo END_ARGS
2677d4f2939cSRui Paulo }
2678d4f2939cSRui Paulo },
2679d4f2939cSRui Paulo { "InterfaceRemoved", WPAS_DBUS_NEW_INTERFACE,
2680d4f2939cSRui Paulo {
2681d4f2939cSRui Paulo { "path", "o", ARG_OUT },
2682d4f2939cSRui Paulo END_ARGS
2683d4f2939cSRui Paulo }
2684d4f2939cSRui Paulo },
2685d4f2939cSRui Paulo /* Deprecated: use org.freedesktop.DBus.Properties.PropertiesChanged */
2686d4f2939cSRui Paulo { "PropertiesChanged", WPAS_DBUS_NEW_INTERFACE,
2687d4f2939cSRui Paulo {
2688d4f2939cSRui Paulo { "properties", "a{sv}", ARG_OUT },
2689d4f2939cSRui Paulo END_ARGS
2690d4f2939cSRui Paulo }
2691d4f2939cSRui Paulo },
2692d4f2939cSRui Paulo { NULL, NULL, { END_ARGS } }
2693d4f2939cSRui Paulo };
2694d4f2939cSRui Paulo
2695d4f2939cSRui Paulo
uscore_to_dbus(const char * uscore)2696780fb4a2SCy Schubert static char * uscore_to_dbus(const char *uscore)
2697780fb4a2SCy Schubert {
2698780fb4a2SCy Schubert const char *p = uscore;
2699780fb4a2SCy Schubert char *str, *s;
2700780fb4a2SCy Schubert dbus_bool_t last_was_uscore = TRUE;
2701780fb4a2SCy Schubert
2702780fb4a2SCy Schubert s = str = os_zalloc(os_strlen(uscore) + 1);
2703780fb4a2SCy Schubert if (!str)
2704780fb4a2SCy Schubert return NULL;
2705780fb4a2SCy Schubert while (p && *p) {
2706780fb4a2SCy Schubert if (*p == '_') {
2707780fb4a2SCy Schubert last_was_uscore = TRUE;
2708780fb4a2SCy Schubert } else {
2709780fb4a2SCy Schubert *s++ = last_was_uscore ? toupper(*p) : *p;
2710780fb4a2SCy Schubert last_was_uscore = FALSE;
2711780fb4a2SCy Schubert }
2712780fb4a2SCy Schubert p++;
2713780fb4a2SCy Schubert }
2714780fb4a2SCy Schubert
2715780fb4a2SCy Schubert return str;
2716780fb4a2SCy Schubert }
2717780fb4a2SCy Schubert
2718780fb4a2SCy Schubert
2719780fb4a2SCy Schubert static int wpa_dbus_ctrl_iface_props_init(struct wpas_dbus_priv *priv);
2720780fb4a2SCy Schubert
2721780fb4a2SCy Schubert
wpa_dbus_ctrl_iface_props_deinit(struct wpas_dbus_priv * priv)2722780fb4a2SCy Schubert static void wpa_dbus_ctrl_iface_props_deinit(struct wpas_dbus_priv *priv)
2723780fb4a2SCy Schubert {
2724780fb4a2SCy Schubert int idx = priv->globals_start;
2725780fb4a2SCy Schubert
2726780fb4a2SCy Schubert /* Free all allocated property values */
2727780fb4a2SCy Schubert while (priv->all_interface_properties[idx].dbus_property)
2728780fb4a2SCy Schubert os_free((char *)
2729780fb4a2SCy Schubert priv->all_interface_properties[idx++].dbus_property);
2730780fb4a2SCy Schubert os_free((char *) priv->all_interface_properties);
2731780fb4a2SCy Schubert }
2732780fb4a2SCy Schubert
2733780fb4a2SCy Schubert
2734d4f2939cSRui Paulo /**
2735d4f2939cSRui Paulo * wpas_dbus_ctrl_iface_init - Initialize dbus control interface
2736d4f2939cSRui Paulo * @global: Pointer to global data from wpa_supplicant_init()
2737d4f2939cSRui Paulo * Returns: 0 on success or -1 on failure
2738d4f2939cSRui Paulo *
2739780fb4a2SCy Schubert * Initialize the dbus control interface for wpa_supplicant and start
2740d4f2939cSRui Paulo * receiving commands from external programs over the bus.
2741d4f2939cSRui Paulo */
wpas_dbus_ctrl_iface_init(struct wpas_dbus_priv * priv)2742d4f2939cSRui Paulo int wpas_dbus_ctrl_iface_init(struct wpas_dbus_priv *priv)
2743d4f2939cSRui Paulo {
2744d4f2939cSRui Paulo struct wpa_dbus_object_desc *obj_desc;
2745d4f2939cSRui Paulo int ret;
2746d4f2939cSRui Paulo
2747780fb4a2SCy Schubert ret = wpa_dbus_ctrl_iface_props_init(priv);
2748780fb4a2SCy Schubert if (ret < 0) {
2749780fb4a2SCy Schubert wpa_printf(MSG_ERROR,
2750780fb4a2SCy Schubert "dbus: Not enough memory to init interface properties");
2751780fb4a2SCy Schubert return -1;
2752780fb4a2SCy Schubert }
2753780fb4a2SCy Schubert
2754d4f2939cSRui Paulo obj_desc = os_zalloc(sizeof(struct wpa_dbus_object_desc));
2755d4f2939cSRui Paulo if (!obj_desc) {
27565b9c547cSRui Paulo wpa_printf(MSG_ERROR,
27575b9c547cSRui Paulo "Not enough memory to create object description");
2758780fb4a2SCy Schubert goto error;
2759d4f2939cSRui Paulo }
2760d4f2939cSRui Paulo
2761d4f2939cSRui Paulo wpas_dbus_register(obj_desc, priv->global, NULL,
2762d4f2939cSRui Paulo wpas_dbus_global_methods,
2763d4f2939cSRui Paulo wpas_dbus_global_properties,
2764d4f2939cSRui Paulo wpas_dbus_global_signals);
2765d4f2939cSRui Paulo
2766d4f2939cSRui Paulo wpa_printf(MSG_DEBUG, "dbus: Register D-Bus object '%s'",
2767d4f2939cSRui Paulo WPAS_DBUS_NEW_PATH);
2768d4f2939cSRui Paulo ret = wpa_dbus_ctrl_iface_init(priv, WPAS_DBUS_NEW_PATH,
2769d4f2939cSRui Paulo WPAS_DBUS_NEW_SERVICE,
2770d4f2939cSRui Paulo obj_desc);
2771780fb4a2SCy Schubert if (ret < 0) {
2772d4f2939cSRui Paulo free_dbus_object_desc(obj_desc);
2773780fb4a2SCy Schubert goto error;
2774780fb4a2SCy Schubert }
2775d4f2939cSRui Paulo
2776780fb4a2SCy Schubert priv->dbus_new_initialized = 1;
2777780fb4a2SCy Schubert return 0;
2778780fb4a2SCy Schubert
2779780fb4a2SCy Schubert error:
2780780fb4a2SCy Schubert wpa_dbus_ctrl_iface_props_deinit(priv);
2781780fb4a2SCy Schubert return -1;
2782d4f2939cSRui Paulo }
2783d4f2939cSRui Paulo
2784d4f2939cSRui Paulo
2785d4f2939cSRui Paulo /**
2786d4f2939cSRui Paulo * wpas_dbus_ctrl_iface_deinit - Deinitialize dbus ctrl interface for
2787d4f2939cSRui Paulo * wpa_supplicant
2788780fb4a2SCy Schubert * @priv: Pointer to dbus private data from wpas_dbus_init()
2789d4f2939cSRui Paulo *
2790d4f2939cSRui Paulo * Deinitialize the dbus control interface that was initialized with
2791d4f2939cSRui Paulo * wpas_dbus_ctrl_iface_init().
2792d4f2939cSRui Paulo */
wpas_dbus_ctrl_iface_deinit(struct wpas_dbus_priv * priv)2793780fb4a2SCy Schubert void wpas_dbus_ctrl_iface_deinit(struct wpas_dbus_priv *priv)
2794d4f2939cSRui Paulo {
2795780fb4a2SCy Schubert if (!priv->dbus_new_initialized)
2796d4f2939cSRui Paulo return;
2797d4f2939cSRui Paulo wpa_printf(MSG_DEBUG, "dbus: Unregister D-Bus object '%s'",
2798d4f2939cSRui Paulo WPAS_DBUS_NEW_PATH);
2799780fb4a2SCy Schubert dbus_connection_unregister_object_path(priv->con, WPAS_DBUS_NEW_PATH);
2800780fb4a2SCy Schubert wpa_dbus_ctrl_iface_props_deinit(priv);
2801d4f2939cSRui Paulo }
2802d4f2939cSRui Paulo
2803d4f2939cSRui Paulo
wpa_dbus_free(void * ptr)2804d4f2939cSRui Paulo static void wpa_dbus_free(void *ptr)
2805d4f2939cSRui Paulo {
2806d4f2939cSRui Paulo os_free(ptr);
2807d4f2939cSRui Paulo }
2808d4f2939cSRui Paulo
2809d4f2939cSRui Paulo
2810d4f2939cSRui Paulo static const struct wpa_dbus_property_desc wpas_dbus_network_properties[] = {
2811d4f2939cSRui Paulo { "Properties", WPAS_DBUS_NEW_IFACE_NETWORK, "a{sv}",
2812d4f2939cSRui Paulo wpas_dbus_getter_network_properties,
2813780fb4a2SCy Schubert wpas_dbus_setter_network_properties,
2814780fb4a2SCy Schubert NULL
2815d4f2939cSRui Paulo },
2816d4f2939cSRui Paulo { "Enabled", WPAS_DBUS_NEW_IFACE_NETWORK, "b",
2817d4f2939cSRui Paulo wpas_dbus_getter_enabled,
2818780fb4a2SCy Schubert wpas_dbus_setter_enabled,
2819780fb4a2SCy Schubert NULL
2820d4f2939cSRui Paulo },
2821780fb4a2SCy Schubert { NULL, NULL, NULL, NULL, NULL, NULL }
2822d4f2939cSRui Paulo };
2823d4f2939cSRui Paulo
2824d4f2939cSRui Paulo
2825d4f2939cSRui Paulo static const struct wpa_dbus_signal_desc wpas_dbus_network_signals[] = {
2826d4f2939cSRui Paulo /* Deprecated: use org.freedesktop.DBus.Properties.PropertiesChanged */
2827d4f2939cSRui Paulo { "PropertiesChanged", WPAS_DBUS_NEW_IFACE_NETWORK,
2828d4f2939cSRui Paulo {
2829d4f2939cSRui Paulo { "properties", "a{sv}", ARG_OUT },
2830d4f2939cSRui Paulo END_ARGS
2831d4f2939cSRui Paulo }
2832d4f2939cSRui Paulo },
2833d4f2939cSRui Paulo { NULL, NULL, { END_ARGS } }
2834d4f2939cSRui Paulo };
2835d4f2939cSRui Paulo
2836d4f2939cSRui Paulo
2837d4f2939cSRui Paulo /**
2838d4f2939cSRui Paulo * wpas_dbus_register_network - Register a configured network with dbus
2839d4f2939cSRui Paulo * @wpa_s: wpa_supplicant interface structure
2840d4f2939cSRui Paulo * @ssid: network configuration data
2841d4f2939cSRui Paulo * Returns: 0 on success, -1 on failure
2842d4f2939cSRui Paulo *
2843d4f2939cSRui Paulo * Registers network representing object with dbus
2844d4f2939cSRui Paulo */
wpas_dbus_register_network(struct wpa_supplicant * wpa_s,struct wpa_ssid * ssid)2845d4f2939cSRui Paulo int wpas_dbus_register_network(struct wpa_supplicant *wpa_s,
2846d4f2939cSRui Paulo struct wpa_ssid *ssid)
2847d4f2939cSRui Paulo {
2848d4f2939cSRui Paulo struct wpas_dbus_priv *ctrl_iface;
2849d4f2939cSRui Paulo struct wpa_dbus_object_desc *obj_desc;
2850d4f2939cSRui Paulo struct network_handler_args *arg;
2851d4f2939cSRui Paulo char net_obj_path[WPAS_DBUS_OBJECT_PATH_MAX];
2852d4f2939cSRui Paulo
2853d4f2939cSRui Paulo #ifdef CONFIG_P2P
2854d4f2939cSRui Paulo /*
2855d4f2939cSRui Paulo * If it is a persistent group register it as such.
2856d4f2939cSRui Paulo * This is to handle cases where an interface is being initialized
2857d4f2939cSRui Paulo * with a list of networks read from config.
2858d4f2939cSRui Paulo */
2859d4f2939cSRui Paulo if (network_is_persistent_group(ssid))
2860d4f2939cSRui Paulo return wpas_dbus_register_persistent_group(wpa_s, ssid);
2861d4f2939cSRui Paulo #endif /* CONFIG_P2P */
2862d4f2939cSRui Paulo
2863d4f2939cSRui Paulo /* Do nothing if the control interface is not turned on */
2864325151a3SRui Paulo if (wpa_s == NULL || wpa_s->global == NULL || !wpa_s->dbus_new_path)
2865d4f2939cSRui Paulo return 0;
2866d4f2939cSRui Paulo ctrl_iface = wpa_s->global->dbus;
2867d4f2939cSRui Paulo if (ctrl_iface == NULL)
2868d4f2939cSRui Paulo return 0;
2869d4f2939cSRui Paulo
2870d4f2939cSRui Paulo os_snprintf(net_obj_path, WPAS_DBUS_OBJECT_PATH_MAX,
2871d4f2939cSRui Paulo "%s/" WPAS_DBUS_NEW_NETWORKS_PART "/%u",
2872d4f2939cSRui Paulo wpa_s->dbus_new_path, ssid->id);
2873d4f2939cSRui Paulo
2874d4f2939cSRui Paulo wpa_printf(MSG_DEBUG, "dbus: Register network object '%s'",
2875d4f2939cSRui Paulo net_obj_path);
2876d4f2939cSRui Paulo obj_desc = os_zalloc(sizeof(struct wpa_dbus_object_desc));
2877d4f2939cSRui Paulo if (!obj_desc) {
28785b9c547cSRui Paulo wpa_printf(MSG_ERROR,
28795b9c547cSRui Paulo "Not enough memory to create object description");
2880d4f2939cSRui Paulo goto err;
2881d4f2939cSRui Paulo }
2882d4f2939cSRui Paulo
2883d4f2939cSRui Paulo /* allocate memory for handlers arguments */
2884d4f2939cSRui Paulo arg = os_zalloc(sizeof(struct network_handler_args));
2885d4f2939cSRui Paulo if (!arg) {
28865b9c547cSRui Paulo wpa_printf(MSG_ERROR,
28875b9c547cSRui Paulo "Not enough memory to create arguments for method");
2888d4f2939cSRui Paulo goto err;
2889d4f2939cSRui Paulo }
2890d4f2939cSRui Paulo
2891d4f2939cSRui Paulo arg->wpa_s = wpa_s;
2892d4f2939cSRui Paulo arg->ssid = ssid;
2893d4f2939cSRui Paulo
2894d4f2939cSRui Paulo wpas_dbus_register(obj_desc, arg, wpa_dbus_free, NULL,
2895d4f2939cSRui Paulo wpas_dbus_network_properties,
2896d4f2939cSRui Paulo wpas_dbus_network_signals);
2897d4f2939cSRui Paulo
2898d4f2939cSRui Paulo if (wpa_dbus_register_object_per_iface(ctrl_iface, net_obj_path,
2899d4f2939cSRui Paulo wpa_s->ifname, obj_desc))
2900d4f2939cSRui Paulo goto err;
2901d4f2939cSRui Paulo
2902d4f2939cSRui Paulo wpas_dbus_signal_network_added(wpa_s, ssid->id);
2903d4f2939cSRui Paulo
2904d4f2939cSRui Paulo return 0;
2905d4f2939cSRui Paulo
2906d4f2939cSRui Paulo err:
2907d4f2939cSRui Paulo free_dbus_object_desc(obj_desc);
2908d4f2939cSRui Paulo return -1;
2909d4f2939cSRui Paulo }
2910d4f2939cSRui Paulo
2911d4f2939cSRui Paulo
2912d4f2939cSRui Paulo /**
2913d4f2939cSRui Paulo * wpas_dbus_unregister_network - Unregister a configured network from dbus
2914d4f2939cSRui Paulo * @wpa_s: wpa_supplicant interface structure
2915d4f2939cSRui Paulo * @nid: network id
2916d4f2939cSRui Paulo * Returns: 0 on success, -1 on failure
2917d4f2939cSRui Paulo *
2918d4f2939cSRui Paulo * Unregisters network representing object from dbus
2919d4f2939cSRui Paulo */
wpas_dbus_unregister_network(struct wpa_supplicant * wpa_s,int nid)2920d4f2939cSRui Paulo int wpas_dbus_unregister_network(struct wpa_supplicant *wpa_s, int nid)
2921d4f2939cSRui Paulo {
2922d4f2939cSRui Paulo struct wpas_dbus_priv *ctrl_iface;
2923d4f2939cSRui Paulo char net_obj_path[WPAS_DBUS_OBJECT_PATH_MAX];
2924d4f2939cSRui Paulo int ret;
2925d4f2939cSRui Paulo #ifdef CONFIG_P2P
2926d4f2939cSRui Paulo struct wpa_ssid *ssid;
2927d4f2939cSRui Paulo
2928d4f2939cSRui Paulo ssid = wpa_config_get_network(wpa_s->conf, nid);
2929d4f2939cSRui Paulo
2930d4f2939cSRui Paulo /* If it is a persistent group unregister it as such */
2931d4f2939cSRui Paulo if (ssid && network_is_persistent_group(ssid))
2932d4f2939cSRui Paulo return wpas_dbus_unregister_persistent_group(wpa_s, nid);
2933d4f2939cSRui Paulo #endif /* CONFIG_P2P */
2934d4f2939cSRui Paulo
2935d4f2939cSRui Paulo /* Do nothing if the control interface is not turned on */
2936d4f2939cSRui Paulo if (wpa_s->global == NULL || wpa_s->dbus_new_path == NULL)
2937d4f2939cSRui Paulo return 0;
2938d4f2939cSRui Paulo ctrl_iface = wpa_s->global->dbus;
2939d4f2939cSRui Paulo if (ctrl_iface == NULL)
2940d4f2939cSRui Paulo return 0;
2941d4f2939cSRui Paulo
2942d4f2939cSRui Paulo os_snprintf(net_obj_path, WPAS_DBUS_OBJECT_PATH_MAX,
2943d4f2939cSRui Paulo "%s/" WPAS_DBUS_NEW_NETWORKS_PART "/%u",
2944d4f2939cSRui Paulo wpa_s->dbus_new_path, nid);
2945d4f2939cSRui Paulo
2946d4f2939cSRui Paulo wpa_printf(MSG_DEBUG, "dbus: Unregister network object '%s'",
2947d4f2939cSRui Paulo net_obj_path);
2948d4f2939cSRui Paulo ret = wpa_dbus_unregister_object_per_iface(ctrl_iface, net_obj_path);
2949d4f2939cSRui Paulo
2950d4f2939cSRui Paulo if (!ret)
2951d4f2939cSRui Paulo wpas_dbus_signal_network_removed(wpa_s, nid);
2952d4f2939cSRui Paulo
2953d4f2939cSRui Paulo return ret;
2954d4f2939cSRui Paulo }
2955d4f2939cSRui Paulo
2956d4f2939cSRui Paulo
2957d4f2939cSRui Paulo static const struct wpa_dbus_property_desc wpas_dbus_bss_properties[] = {
2958d4f2939cSRui Paulo { "SSID", WPAS_DBUS_NEW_IFACE_BSS, "ay",
2959d4f2939cSRui Paulo wpas_dbus_getter_bss_ssid,
2960780fb4a2SCy Schubert NULL,
2961d4f2939cSRui Paulo NULL
2962d4f2939cSRui Paulo },
2963d4f2939cSRui Paulo { "BSSID", WPAS_DBUS_NEW_IFACE_BSS, "ay",
2964d4f2939cSRui Paulo wpas_dbus_getter_bss_bssid,
2965780fb4a2SCy Schubert NULL,
2966d4f2939cSRui Paulo NULL
2967d4f2939cSRui Paulo },
2968d4f2939cSRui Paulo { "Privacy", WPAS_DBUS_NEW_IFACE_BSS, "b",
2969d4f2939cSRui Paulo wpas_dbus_getter_bss_privacy,
2970780fb4a2SCy Schubert NULL,
2971d4f2939cSRui Paulo NULL
2972d4f2939cSRui Paulo },
2973d4f2939cSRui Paulo { "Mode", WPAS_DBUS_NEW_IFACE_BSS, "s",
2974d4f2939cSRui Paulo wpas_dbus_getter_bss_mode,
2975780fb4a2SCy Schubert NULL,
2976d4f2939cSRui Paulo NULL
2977d4f2939cSRui Paulo },
2978d4f2939cSRui Paulo { "Signal", WPAS_DBUS_NEW_IFACE_BSS, "n",
2979d4f2939cSRui Paulo wpas_dbus_getter_bss_signal,
2980780fb4a2SCy Schubert NULL,
2981d4f2939cSRui Paulo NULL
2982d4f2939cSRui Paulo },
2983d4f2939cSRui Paulo { "Frequency", WPAS_DBUS_NEW_IFACE_BSS, "q",
2984d4f2939cSRui Paulo wpas_dbus_getter_bss_frequency,
2985780fb4a2SCy Schubert NULL,
2986d4f2939cSRui Paulo NULL
2987d4f2939cSRui Paulo },
2988d4f2939cSRui Paulo { "Rates", WPAS_DBUS_NEW_IFACE_BSS, "au",
2989d4f2939cSRui Paulo wpas_dbus_getter_bss_rates,
2990780fb4a2SCy Schubert NULL,
2991d4f2939cSRui Paulo NULL
2992d4f2939cSRui Paulo },
2993d4f2939cSRui Paulo { "WPA", WPAS_DBUS_NEW_IFACE_BSS, "a{sv}",
2994d4f2939cSRui Paulo wpas_dbus_getter_bss_wpa,
2995780fb4a2SCy Schubert NULL,
2996d4f2939cSRui Paulo NULL
2997d4f2939cSRui Paulo },
2998d4f2939cSRui Paulo { "RSN", WPAS_DBUS_NEW_IFACE_BSS, "a{sv}",
2999d4f2939cSRui Paulo wpas_dbus_getter_bss_rsn,
3000780fb4a2SCy Schubert NULL,
3001d4f2939cSRui Paulo NULL
3002d4f2939cSRui Paulo },
3003d4f2939cSRui Paulo { "WPS", WPAS_DBUS_NEW_IFACE_BSS, "a{sv}",
3004d4f2939cSRui Paulo wpas_dbus_getter_bss_wps,
3005780fb4a2SCy Schubert NULL,
3006d4f2939cSRui Paulo NULL
3007d4f2939cSRui Paulo },
3008d4f2939cSRui Paulo { "IEs", WPAS_DBUS_NEW_IFACE_BSS, "ay",
3009d4f2939cSRui Paulo wpas_dbus_getter_bss_ies,
3010780fb4a2SCy Schubert NULL,
3011d4f2939cSRui Paulo NULL
3012d4f2939cSRui Paulo },
30135b9c547cSRui Paulo { "Age", WPAS_DBUS_NEW_IFACE_BSS, "u",
30145b9c547cSRui Paulo wpas_dbus_getter_bss_age,
3015780fb4a2SCy Schubert NULL,
30165b9c547cSRui Paulo NULL
30175b9c547cSRui Paulo },
3018*a90b9d01SCy Schubert {"ANQP", WPAS_DBUS_NEW_IFACE_BSS, "a{sv}",
3019*a90b9d01SCy Schubert wpas_dbus_getter_bss_anqp,
3020*a90b9d01SCy Schubert NULL,
3021*a90b9d01SCy Schubert NULL,
3022*a90b9d01SCy Schubert },
3023780fb4a2SCy Schubert { NULL, NULL, NULL, NULL, NULL, NULL }
3024d4f2939cSRui Paulo };
3025d4f2939cSRui Paulo
3026d4f2939cSRui Paulo
3027d4f2939cSRui Paulo static const struct wpa_dbus_signal_desc wpas_dbus_bss_signals[] = {
3028d4f2939cSRui Paulo /* Deprecated: use org.freedesktop.DBus.Properties.PropertiesChanged */
3029d4f2939cSRui Paulo { "PropertiesChanged", WPAS_DBUS_NEW_IFACE_BSS,
3030d4f2939cSRui Paulo {
3031d4f2939cSRui Paulo { "properties", "a{sv}", ARG_OUT },
3032d4f2939cSRui Paulo END_ARGS
3033d4f2939cSRui Paulo }
3034d4f2939cSRui Paulo },
3035d4f2939cSRui Paulo { NULL, NULL, { END_ARGS } }
3036d4f2939cSRui Paulo };
3037d4f2939cSRui Paulo
3038d4f2939cSRui Paulo
3039d4f2939cSRui Paulo /**
3040d4f2939cSRui Paulo * wpas_dbus_unregister_bss - Unregister a scanned BSS from dbus
3041d4f2939cSRui Paulo * @wpa_s: wpa_supplicant interface structure
3042d4f2939cSRui Paulo * @bssid: scanned network bssid
3043d4f2939cSRui Paulo * @id: unique BSS identifier
3044d4f2939cSRui Paulo * Returns: 0 on success, -1 on failure
3045d4f2939cSRui Paulo *
3046d4f2939cSRui Paulo * Unregisters BSS representing object from dbus
3047d4f2939cSRui Paulo */
wpas_dbus_unregister_bss(struct wpa_supplicant * wpa_s,u8 bssid[ETH_ALEN],unsigned int id)3048d4f2939cSRui Paulo int wpas_dbus_unregister_bss(struct wpa_supplicant *wpa_s,
3049d4f2939cSRui Paulo u8 bssid[ETH_ALEN], unsigned int id)
3050d4f2939cSRui Paulo {
3051d4f2939cSRui Paulo struct wpas_dbus_priv *ctrl_iface;
3052d4f2939cSRui Paulo char bss_obj_path[WPAS_DBUS_OBJECT_PATH_MAX];
3053d4f2939cSRui Paulo
3054d4f2939cSRui Paulo /* Do nothing if the control interface is not turned on */
3055325151a3SRui Paulo if (wpa_s == NULL || wpa_s->global == NULL || !wpa_s->dbus_new_path)
3056d4f2939cSRui Paulo return 0;
3057d4f2939cSRui Paulo ctrl_iface = wpa_s->global->dbus;
3058d4f2939cSRui Paulo if (ctrl_iface == NULL)
3059d4f2939cSRui Paulo return 0;
3060d4f2939cSRui Paulo
3061d4f2939cSRui Paulo os_snprintf(bss_obj_path, WPAS_DBUS_OBJECT_PATH_MAX,
3062d4f2939cSRui Paulo "%s/" WPAS_DBUS_NEW_BSSIDS_PART "/%u",
3063d4f2939cSRui Paulo wpa_s->dbus_new_path, id);
3064d4f2939cSRui Paulo
3065d4f2939cSRui Paulo wpa_printf(MSG_DEBUG, "dbus: Unregister BSS object '%s'",
3066d4f2939cSRui Paulo bss_obj_path);
3067d4f2939cSRui Paulo if (wpa_dbus_unregister_object_per_iface(ctrl_iface, bss_obj_path)) {
3068d4f2939cSRui Paulo wpa_printf(MSG_ERROR, "dbus: Cannot unregister BSS object %s",
3069d4f2939cSRui Paulo bss_obj_path);
3070d4f2939cSRui Paulo return -1;
3071d4f2939cSRui Paulo }
3072d4f2939cSRui Paulo
3073d4f2939cSRui Paulo wpas_dbus_signal_bss_removed(wpa_s, bss_obj_path);
3074d4f2939cSRui Paulo wpas_dbus_signal_prop_changed(wpa_s, WPAS_DBUS_PROP_BSSS);
3075d4f2939cSRui Paulo
3076d4f2939cSRui Paulo return 0;
3077d4f2939cSRui Paulo }
3078d4f2939cSRui Paulo
3079d4f2939cSRui Paulo
3080d4f2939cSRui Paulo /**
3081d4f2939cSRui Paulo * wpas_dbus_register_bss - Register a scanned BSS with dbus
3082d4f2939cSRui Paulo * @wpa_s: wpa_supplicant interface structure
3083d4f2939cSRui Paulo * @bssid: scanned network bssid
3084d4f2939cSRui Paulo * @id: unique BSS identifier
3085d4f2939cSRui Paulo * Returns: 0 on success, -1 on failure
3086d4f2939cSRui Paulo *
3087d4f2939cSRui Paulo * Registers BSS representing object with dbus
3088d4f2939cSRui Paulo */
wpas_dbus_register_bss(struct wpa_supplicant * wpa_s,u8 bssid[ETH_ALEN],unsigned int id)3089d4f2939cSRui Paulo int wpas_dbus_register_bss(struct wpa_supplicant *wpa_s,
3090d4f2939cSRui Paulo u8 bssid[ETH_ALEN], unsigned int id)
3091d4f2939cSRui Paulo {
3092d4f2939cSRui Paulo struct wpas_dbus_priv *ctrl_iface;
3093d4f2939cSRui Paulo struct wpa_dbus_object_desc *obj_desc;
3094d4f2939cSRui Paulo char bss_obj_path[WPAS_DBUS_OBJECT_PATH_MAX];
3095d4f2939cSRui Paulo struct bss_handler_args *arg;
3096d4f2939cSRui Paulo
3097d4f2939cSRui Paulo /* Do nothing if the control interface is not turned on */
3098325151a3SRui Paulo if (wpa_s == NULL || wpa_s->global == NULL || !wpa_s->dbus_new_path)
3099d4f2939cSRui Paulo return 0;
3100d4f2939cSRui Paulo ctrl_iface = wpa_s->global->dbus;
3101d4f2939cSRui Paulo if (ctrl_iface == NULL)
3102d4f2939cSRui Paulo return 0;
3103d4f2939cSRui Paulo
3104d4f2939cSRui Paulo os_snprintf(bss_obj_path, WPAS_DBUS_OBJECT_PATH_MAX,
3105d4f2939cSRui Paulo "%s/" WPAS_DBUS_NEW_BSSIDS_PART "/%u",
3106d4f2939cSRui Paulo wpa_s->dbus_new_path, id);
3107d4f2939cSRui Paulo
3108d4f2939cSRui Paulo obj_desc = os_zalloc(sizeof(struct wpa_dbus_object_desc));
3109d4f2939cSRui Paulo if (!obj_desc) {
31105b9c547cSRui Paulo wpa_printf(MSG_ERROR,
31115b9c547cSRui Paulo "Not enough memory to create object description");
3112d4f2939cSRui Paulo goto err;
3113d4f2939cSRui Paulo }
3114d4f2939cSRui Paulo
3115d4f2939cSRui Paulo arg = os_zalloc(sizeof(struct bss_handler_args));
3116d4f2939cSRui Paulo if (!arg) {
31175b9c547cSRui Paulo wpa_printf(MSG_ERROR,
31185b9c547cSRui Paulo "Not enough memory to create arguments for handler");
3119d4f2939cSRui Paulo goto err;
3120d4f2939cSRui Paulo }
3121d4f2939cSRui Paulo arg->wpa_s = wpa_s;
3122d4f2939cSRui Paulo arg->id = id;
3123d4f2939cSRui Paulo
3124d4f2939cSRui Paulo wpas_dbus_register(obj_desc, arg, wpa_dbus_free, NULL,
3125d4f2939cSRui Paulo wpas_dbus_bss_properties,
3126d4f2939cSRui Paulo wpas_dbus_bss_signals);
3127d4f2939cSRui Paulo
3128d4f2939cSRui Paulo wpa_printf(MSG_DEBUG, "dbus: Register BSS object '%s'",
3129d4f2939cSRui Paulo bss_obj_path);
3130d4f2939cSRui Paulo if (wpa_dbus_register_object_per_iface(ctrl_iface, bss_obj_path,
3131d4f2939cSRui Paulo wpa_s->ifname, obj_desc)) {
3132d4f2939cSRui Paulo wpa_printf(MSG_ERROR,
3133d4f2939cSRui Paulo "Cannot register BSSID dbus object %s.",
3134d4f2939cSRui Paulo bss_obj_path);
3135d4f2939cSRui Paulo goto err;
3136d4f2939cSRui Paulo }
3137d4f2939cSRui Paulo
3138d4f2939cSRui Paulo wpas_dbus_signal_bss_added(wpa_s, bss_obj_path);
3139d4f2939cSRui Paulo wpas_dbus_signal_prop_changed(wpa_s, WPAS_DBUS_PROP_BSSS);
3140d4f2939cSRui Paulo
3141d4f2939cSRui Paulo return 0;
3142d4f2939cSRui Paulo
3143d4f2939cSRui Paulo err:
3144d4f2939cSRui Paulo free_dbus_object_desc(obj_desc);
3145d4f2939cSRui Paulo return -1;
3146d4f2939cSRui Paulo }
3147d4f2939cSRui Paulo
3148d4f2939cSRui Paulo
31494bc52338SCy Schubert static const struct wpa_dbus_property_desc wpas_dbus_sta_properties[] = {
31504bc52338SCy Schubert { "Address", WPAS_DBUS_NEW_IFACE_STA, "ay",
31514bc52338SCy Schubert wpas_dbus_getter_sta_address,
31524bc52338SCy Schubert NULL, NULL
31534bc52338SCy Schubert },
31544bc52338SCy Schubert { "AID", WPAS_DBUS_NEW_IFACE_STA, "q",
31554bc52338SCy Schubert wpas_dbus_getter_sta_aid,
31564bc52338SCy Schubert NULL, NULL
31574bc52338SCy Schubert },
31584bc52338SCy Schubert { "Capabilities", WPAS_DBUS_NEW_IFACE_STA, "q",
31594bc52338SCy Schubert wpas_dbus_getter_sta_caps,
31604bc52338SCy Schubert NULL, NULL
31614bc52338SCy Schubert },
31624bc52338SCy Schubert { "RxPackets", WPAS_DBUS_NEW_IFACE_STA, "t",
31634bc52338SCy Schubert wpas_dbus_getter_sta_rx_packets,
31644bc52338SCy Schubert NULL, NULL
31654bc52338SCy Schubert },
31664bc52338SCy Schubert { "TxPackets", WPAS_DBUS_NEW_IFACE_STA, "t",
31674bc52338SCy Schubert wpas_dbus_getter_sta_tx_packets,
31684bc52338SCy Schubert NULL, NULL
31694bc52338SCy Schubert },
31704bc52338SCy Schubert { "RxBytes", WPAS_DBUS_NEW_IFACE_STA, "t",
31714bc52338SCy Schubert wpas_dbus_getter_sta_rx_bytes,
31724bc52338SCy Schubert NULL, NULL
31734bc52338SCy Schubert },
31744bc52338SCy Schubert { "TxBytes", WPAS_DBUS_NEW_IFACE_STA, "t",
31754bc52338SCy Schubert wpas_dbus_getter_sta_tx_bytes,
31764bc52338SCy Schubert NULL, NULL
31774bc52338SCy Schubert },
31784bc52338SCy Schubert { NULL, NULL, NULL, NULL, NULL, NULL }
31794bc52338SCy Schubert };
31804bc52338SCy Schubert
31814bc52338SCy Schubert
31824bc52338SCy Schubert static const struct wpa_dbus_signal_desc wpas_dbus_sta_signals[] = {
31834bc52338SCy Schubert /* Deprecated: use org.freedesktop.DBus.Properties.PropertiesChanged */
31844bc52338SCy Schubert { "PropertiesChanged", WPAS_DBUS_NEW_IFACE_STA,
31854bc52338SCy Schubert {
31864bc52338SCy Schubert { "properties", "a{sv}", ARG_OUT },
31874bc52338SCy Schubert END_ARGS
31884bc52338SCy Schubert }
31894bc52338SCy Schubert },
31904bc52338SCy Schubert { NULL, NULL, { END_ARGS } }
31914bc52338SCy Schubert };
31924bc52338SCy Schubert
31934bc52338SCy Schubert
31944bc52338SCy Schubert /**
31954bc52338SCy Schubert * wpas_dbus_unregister_sta - Unregister a connected station from dbus
31964bc52338SCy Schubert * @wpa_s: wpa_supplicant interface structure
31974bc52338SCy Schubert * @sta: station MAC address
31984bc52338SCy Schubert * Returns: 0 on success, -1 on failure
31994bc52338SCy Schubert *
32004bc52338SCy Schubert * Unregisters STA representing object from dbus.
32014bc52338SCy Schubert */
wpas_dbus_unregister_sta(struct wpa_supplicant * wpa_s,const u8 * sta)32024bc52338SCy Schubert int wpas_dbus_unregister_sta(struct wpa_supplicant *wpa_s, const u8 *sta)
32034bc52338SCy Schubert {
32044bc52338SCy Schubert struct wpas_dbus_priv *ctrl_iface;
32054bc52338SCy Schubert char station_obj_path[WPAS_DBUS_OBJECT_PATH_MAX];
32064bc52338SCy Schubert
32074bc52338SCy Schubert /* Do nothing if the control interface is not turned on */
32084bc52338SCy Schubert if (!wpa_s || !wpa_s->global)
32094bc52338SCy Schubert return 0;
32104bc52338SCy Schubert ctrl_iface = wpa_s->global->dbus;
32114bc52338SCy Schubert if (!ctrl_iface)
32124bc52338SCy Schubert return 0;
32134bc52338SCy Schubert
32144bc52338SCy Schubert os_snprintf(station_obj_path, WPAS_DBUS_OBJECT_PATH_MAX,
32154bc52338SCy Schubert "%s/" WPAS_DBUS_NEW_STAS_PART "/" COMPACT_MACSTR,
32164bc52338SCy Schubert wpa_s->dbus_new_path, MAC2STR(sta));
32174bc52338SCy Schubert
32184bc52338SCy Schubert wpa_printf(MSG_DEBUG, "dbus: Unregister STA object '%s'",
32194bc52338SCy Schubert station_obj_path);
32204bc52338SCy Schubert if (wpa_dbus_unregister_object_per_iface(ctrl_iface,
32214bc52338SCy Schubert station_obj_path)) {
32224bc52338SCy Schubert wpa_printf(MSG_ERROR, "dbus: Cannot unregister STA object %s",
32234bc52338SCy Schubert station_obj_path);
32244bc52338SCy Schubert return -1;
32254bc52338SCy Schubert }
32264bc52338SCy Schubert
32274bc52338SCy Schubert wpas_dbus_signal_station_removed(wpa_s, station_obj_path);
32284bc52338SCy Schubert wpas_dbus_signal_prop_changed(wpa_s, WPAS_DBUS_PROP_STATIONS);
32294bc52338SCy Schubert
32304bc52338SCy Schubert return 0;
32314bc52338SCy Schubert }
32324bc52338SCy Schubert
32334bc52338SCy Schubert
32344bc52338SCy Schubert /**
32354bc52338SCy Schubert * wpas_dbus_register_sta - Register a connected station with dbus
32364bc52338SCy Schubert * @wpa_s: wpa_supplicant interface structure
32374bc52338SCy Schubert * @sta: station MAC address
32384bc52338SCy Schubert * Returns: 0 on success, -1 on failure
32394bc52338SCy Schubert *
32404bc52338SCy Schubert * Registers STA representing object with dbus.
32414bc52338SCy Schubert */
wpas_dbus_register_sta(struct wpa_supplicant * wpa_s,const u8 * sta)32424bc52338SCy Schubert int wpas_dbus_register_sta(struct wpa_supplicant *wpa_s, const u8 *sta)
32434bc52338SCy Schubert {
32444bc52338SCy Schubert struct wpas_dbus_priv *ctrl_iface;
32454bc52338SCy Schubert struct wpa_dbus_object_desc *obj_desc;
32464bc52338SCy Schubert char station_obj_path[WPAS_DBUS_OBJECT_PATH_MAX];
32474bc52338SCy Schubert struct sta_handler_args *arg;
32484bc52338SCy Schubert
32494bc52338SCy Schubert /* Do nothing if the control interface is not turned on */
32504bc52338SCy Schubert if (!wpa_s || !wpa_s->global)
32514bc52338SCy Schubert return 0;
32524bc52338SCy Schubert ctrl_iface = wpa_s->global->dbus;
32534bc52338SCy Schubert if (!ctrl_iface)
32544bc52338SCy Schubert return 0;
32554bc52338SCy Schubert
32564bc52338SCy Schubert os_snprintf(station_obj_path, WPAS_DBUS_OBJECT_PATH_MAX,
32574bc52338SCy Schubert "%s/" WPAS_DBUS_NEW_STAS_PART "/" COMPACT_MACSTR,
32584bc52338SCy Schubert wpa_s->dbus_new_path, MAC2STR(sta));
32594bc52338SCy Schubert
32604bc52338SCy Schubert obj_desc = os_zalloc(sizeof(struct wpa_dbus_object_desc));
32614bc52338SCy Schubert if (!obj_desc) {
32624bc52338SCy Schubert wpa_printf(MSG_ERROR,
32634bc52338SCy Schubert "Not enough memory to create object description");
32644bc52338SCy Schubert goto err;
32654bc52338SCy Schubert }
32664bc52338SCy Schubert
32674bc52338SCy Schubert arg = os_zalloc(sizeof(struct sta_handler_args));
32684bc52338SCy Schubert if (!arg) {
32694bc52338SCy Schubert wpa_printf(MSG_ERROR,
32704bc52338SCy Schubert "Not enough memory to create arguments for handler");
32714bc52338SCy Schubert goto err;
32724bc52338SCy Schubert }
32734bc52338SCy Schubert arg->wpa_s = wpa_s;
32744bc52338SCy Schubert arg->sta = sta;
32754bc52338SCy Schubert
32764bc52338SCy Schubert wpas_dbus_register(obj_desc, arg, wpa_dbus_free, NULL,
32774bc52338SCy Schubert wpas_dbus_sta_properties, wpas_dbus_sta_signals);
32784bc52338SCy Schubert
32794bc52338SCy Schubert wpa_printf(MSG_DEBUG, "dbus: Register STA object '%s'",
32804bc52338SCy Schubert station_obj_path);
32814bc52338SCy Schubert if (wpa_dbus_register_object_per_iface(ctrl_iface, station_obj_path,
32824bc52338SCy Schubert wpa_s->ifname, obj_desc)) {
32834bc52338SCy Schubert wpa_printf(MSG_ERROR,
32844bc52338SCy Schubert "Cannot register STA dbus object %s",
32854bc52338SCy Schubert station_obj_path);
32864bc52338SCy Schubert goto err;
32874bc52338SCy Schubert }
32884bc52338SCy Schubert
32894bc52338SCy Schubert wpas_dbus_signal_station_added(wpa_s, station_obj_path);
32904bc52338SCy Schubert wpas_dbus_signal_prop_changed(wpa_s, WPAS_DBUS_PROP_STATIONS);
32914bc52338SCy Schubert
32924bc52338SCy Schubert return 0;
32934bc52338SCy Schubert
32944bc52338SCy Schubert err:
32954bc52338SCy Schubert free_dbus_object_desc(obj_desc);
32964bc52338SCy Schubert return -1;
32974bc52338SCy Schubert }
32984bc52338SCy Schubert
32994bc52338SCy Schubert
3300d4f2939cSRui Paulo static const struct wpa_dbus_method_desc wpas_dbus_interface_methods[] = {
3301d4f2939cSRui Paulo { "Scan", WPAS_DBUS_NEW_IFACE_INTERFACE,
33025b9c547cSRui Paulo (WPADBusMethodHandler) wpas_dbus_handler_scan,
3303d4f2939cSRui Paulo {
3304d4f2939cSRui Paulo { "args", "a{sv}", ARG_IN },
3305d4f2939cSRui Paulo END_ARGS
3306d4f2939cSRui Paulo }
3307d4f2939cSRui Paulo },
33085b9c547cSRui Paulo { "SignalPoll", WPAS_DBUS_NEW_IFACE_INTERFACE,
33095b9c547cSRui Paulo (WPADBusMethodHandler) wpas_dbus_handler_signal_poll,
33105b9c547cSRui Paulo {
33115b9c547cSRui Paulo { "args", "a{sv}", ARG_OUT },
33125b9c547cSRui Paulo END_ARGS
33135b9c547cSRui Paulo }
33145b9c547cSRui Paulo },
3315d4f2939cSRui Paulo { "Disconnect", WPAS_DBUS_NEW_IFACE_INTERFACE,
33165b9c547cSRui Paulo (WPADBusMethodHandler) wpas_dbus_handler_disconnect,
3317d4f2939cSRui Paulo {
3318d4f2939cSRui Paulo END_ARGS
3319d4f2939cSRui Paulo }
3320d4f2939cSRui Paulo },
3321d4f2939cSRui Paulo { "AddNetwork", WPAS_DBUS_NEW_IFACE_INTERFACE,
33225b9c547cSRui Paulo (WPADBusMethodHandler) wpas_dbus_handler_add_network,
3323d4f2939cSRui Paulo {
3324d4f2939cSRui Paulo { "args", "a{sv}", ARG_IN },
3325d4f2939cSRui Paulo { "path", "o", ARG_OUT },
3326d4f2939cSRui Paulo END_ARGS
3327d4f2939cSRui Paulo }
3328d4f2939cSRui Paulo },
3329d4f2939cSRui Paulo { "Reassociate", WPAS_DBUS_NEW_IFACE_INTERFACE,
33305b9c547cSRui Paulo (WPADBusMethodHandler) wpas_dbus_handler_reassociate,
33315b9c547cSRui Paulo {
33325b9c547cSRui Paulo END_ARGS
33335b9c547cSRui Paulo }
33345b9c547cSRui Paulo },
33355b9c547cSRui Paulo { "Reattach", WPAS_DBUS_NEW_IFACE_INTERFACE,
33365b9c547cSRui Paulo (WPADBusMethodHandler) wpas_dbus_handler_reattach,
3337d4f2939cSRui Paulo {
3338d4f2939cSRui Paulo END_ARGS
3339d4f2939cSRui Paulo }
3340d4f2939cSRui Paulo },
3341325151a3SRui Paulo { "Reconnect", WPAS_DBUS_NEW_IFACE_INTERFACE,
3342325151a3SRui Paulo (WPADBusMethodHandler) wpas_dbus_handler_reconnect,
3343325151a3SRui Paulo {
3344325151a3SRui Paulo END_ARGS
3345325151a3SRui Paulo }
3346325151a3SRui Paulo },
3347d4f2939cSRui Paulo { "RemoveNetwork", WPAS_DBUS_NEW_IFACE_INTERFACE,
33485b9c547cSRui Paulo (WPADBusMethodHandler) wpas_dbus_handler_remove_network,
3349d4f2939cSRui Paulo {
3350d4f2939cSRui Paulo { "path", "o", ARG_IN },
3351d4f2939cSRui Paulo END_ARGS
3352d4f2939cSRui Paulo }
3353d4f2939cSRui Paulo },
3354d4f2939cSRui Paulo { "RemoveAllNetworks", WPAS_DBUS_NEW_IFACE_INTERFACE,
33555b9c547cSRui Paulo (WPADBusMethodHandler) wpas_dbus_handler_remove_all_networks,
3356d4f2939cSRui Paulo {
3357d4f2939cSRui Paulo END_ARGS
3358d4f2939cSRui Paulo }
3359d4f2939cSRui Paulo },
3360d4f2939cSRui Paulo { "SelectNetwork", WPAS_DBUS_NEW_IFACE_INTERFACE,
33615b9c547cSRui Paulo (WPADBusMethodHandler) wpas_dbus_handler_select_network,
3362d4f2939cSRui Paulo {
3363d4f2939cSRui Paulo { "path", "o", ARG_IN },
3364d4f2939cSRui Paulo END_ARGS
3365d4f2939cSRui Paulo }
3366d4f2939cSRui Paulo },
3367d4f2939cSRui Paulo { "NetworkReply", WPAS_DBUS_NEW_IFACE_INTERFACE,
33685b9c547cSRui Paulo (WPADBusMethodHandler) wpas_dbus_handler_network_reply,
3369d4f2939cSRui Paulo {
3370d4f2939cSRui Paulo { "path", "o", ARG_IN },
3371d4f2939cSRui Paulo { "field", "s", ARG_IN },
3372d4f2939cSRui Paulo { "value", "s", ARG_IN },
3373d4f2939cSRui Paulo END_ARGS
3374d4f2939cSRui Paulo }
3375d4f2939cSRui Paulo },
3376c1d255d3SCy Schubert { "Roam", WPAS_DBUS_NEW_IFACE_INTERFACE,
3377c1d255d3SCy Schubert (WPADBusMethodHandler) wpas_dbus_handler_roam,
3378c1d255d3SCy Schubert {
3379c1d255d3SCy Schubert { "addr", "s", ARG_IN },
3380c1d255d3SCy Schubert END_ARGS
3381c1d255d3SCy Schubert }
3382c1d255d3SCy Schubert },
3383c1d255d3SCy Schubert
33845b9c547cSRui Paulo #ifndef CONFIG_NO_CONFIG_BLOBS
3385d4f2939cSRui Paulo { "AddBlob", WPAS_DBUS_NEW_IFACE_INTERFACE,
33865b9c547cSRui Paulo (WPADBusMethodHandler) wpas_dbus_handler_add_blob,
3387d4f2939cSRui Paulo {
3388d4f2939cSRui Paulo { "name", "s", ARG_IN },
3389d4f2939cSRui Paulo { "data", "ay", ARG_IN },
3390d4f2939cSRui Paulo END_ARGS
3391d4f2939cSRui Paulo }
3392d4f2939cSRui Paulo },
3393d4f2939cSRui Paulo { "GetBlob", WPAS_DBUS_NEW_IFACE_INTERFACE,
33945b9c547cSRui Paulo (WPADBusMethodHandler) wpas_dbus_handler_get_blob,
3395d4f2939cSRui Paulo {
3396d4f2939cSRui Paulo { "name", "s", ARG_IN },
3397d4f2939cSRui Paulo { "data", "ay", ARG_OUT },
3398d4f2939cSRui Paulo END_ARGS
3399d4f2939cSRui Paulo }
3400d4f2939cSRui Paulo },
3401d4f2939cSRui Paulo { "RemoveBlob", WPAS_DBUS_NEW_IFACE_INTERFACE,
34025b9c547cSRui Paulo (WPADBusMethodHandler) wpas_dbus_handler_remove_blob,
3403d4f2939cSRui Paulo {
3404d4f2939cSRui Paulo { "name", "s", ARG_IN },
3405d4f2939cSRui Paulo END_ARGS
3406d4f2939cSRui Paulo }
3407d4f2939cSRui Paulo },
34085b9c547cSRui Paulo #endif /* CONFIG_NO_CONFIG_BLOBS */
34095b9c547cSRui Paulo { "SetPKCS11EngineAndModulePath", WPAS_DBUS_NEW_IFACE_INTERFACE,
34105b9c547cSRui Paulo (WPADBusMethodHandler)
34115b9c547cSRui Paulo wpas_dbus_handler_set_pkcs11_engine_and_module_path,
34125b9c547cSRui Paulo {
34135b9c547cSRui Paulo { "pkcs11_engine_path", "s", ARG_IN },
34145b9c547cSRui Paulo { "pkcs11_module_path", "s", ARG_IN },
34155b9c547cSRui Paulo END_ARGS
34165b9c547cSRui Paulo }
34175b9c547cSRui Paulo },
3418d4f2939cSRui Paulo #ifdef CONFIG_WPS
3419d4f2939cSRui Paulo { "Start", WPAS_DBUS_NEW_IFACE_WPS,
34205b9c547cSRui Paulo (WPADBusMethodHandler) wpas_dbus_handler_wps_start,
3421d4f2939cSRui Paulo {
3422d4f2939cSRui Paulo { "args", "a{sv}", ARG_IN },
3423d4f2939cSRui Paulo { "output", "a{sv}", ARG_OUT },
3424d4f2939cSRui Paulo END_ARGS
3425d4f2939cSRui Paulo }
3426d4f2939cSRui Paulo },
3427325151a3SRui Paulo { "Cancel", WPAS_DBUS_NEW_IFACE_WPS,
3428325151a3SRui Paulo (WPADBusMethodHandler) wpas_dbus_handler_wps_cancel,
3429325151a3SRui Paulo {
3430325151a3SRui Paulo END_ARGS
3431325151a3SRui Paulo }
3432325151a3SRui Paulo },
3433d4f2939cSRui Paulo #endif /* CONFIG_WPS */
3434d4f2939cSRui Paulo #ifdef CONFIG_P2P
3435d4f2939cSRui Paulo { "Find", WPAS_DBUS_NEW_IFACE_P2PDEVICE,
3436d4f2939cSRui Paulo (WPADBusMethodHandler) wpas_dbus_handler_p2p_find,
3437d4f2939cSRui Paulo {
3438d4f2939cSRui Paulo { "args", "a{sv}", ARG_IN },
3439d4f2939cSRui Paulo END_ARGS
3440d4f2939cSRui Paulo }
3441d4f2939cSRui Paulo },
3442d4f2939cSRui Paulo { "StopFind", WPAS_DBUS_NEW_IFACE_P2PDEVICE,
3443d4f2939cSRui Paulo (WPADBusMethodHandler) wpas_dbus_handler_p2p_stop_find,
3444d4f2939cSRui Paulo {
3445d4f2939cSRui Paulo END_ARGS
3446d4f2939cSRui Paulo }
3447d4f2939cSRui Paulo },
3448d4f2939cSRui Paulo { "Listen", WPAS_DBUS_NEW_IFACE_P2PDEVICE,
3449d4f2939cSRui Paulo (WPADBusMethodHandler) wpas_dbus_handler_p2p_listen,
3450d4f2939cSRui Paulo {
3451d4f2939cSRui Paulo { "timeout", "i", ARG_IN },
3452d4f2939cSRui Paulo END_ARGS
3453d4f2939cSRui Paulo }
3454d4f2939cSRui Paulo },
3455d4f2939cSRui Paulo { "ExtendedListen", WPAS_DBUS_NEW_IFACE_P2PDEVICE,
3456d4f2939cSRui Paulo (WPADBusMethodHandler) wpas_dbus_handler_p2p_extendedlisten,
3457d4f2939cSRui Paulo {
3458d4f2939cSRui Paulo { "args", "a{sv}", ARG_IN },
3459d4f2939cSRui Paulo END_ARGS
3460d4f2939cSRui Paulo }
3461d4f2939cSRui Paulo },
3462d4f2939cSRui Paulo { "PresenceRequest", WPAS_DBUS_NEW_IFACE_P2PDEVICE,
3463d4f2939cSRui Paulo (WPADBusMethodHandler) wpas_dbus_handler_p2p_presence_request,
3464d4f2939cSRui Paulo {
3465d4f2939cSRui Paulo { "args", "a{sv}", ARG_IN },
3466d4f2939cSRui Paulo END_ARGS
3467d4f2939cSRui Paulo }
3468d4f2939cSRui Paulo },
3469d4f2939cSRui Paulo { "ProvisionDiscoveryRequest", WPAS_DBUS_NEW_IFACE_P2PDEVICE,
3470d4f2939cSRui Paulo (WPADBusMethodHandler) wpas_dbus_handler_p2p_prov_disc_req,
3471d4f2939cSRui Paulo {
3472d4f2939cSRui Paulo { "peer", "o", ARG_IN },
3473d4f2939cSRui Paulo { "config_method", "s", ARG_IN },
3474d4f2939cSRui Paulo END_ARGS
3475d4f2939cSRui Paulo }
3476d4f2939cSRui Paulo },
3477d4f2939cSRui Paulo { "Connect", WPAS_DBUS_NEW_IFACE_P2PDEVICE,
3478d4f2939cSRui Paulo (WPADBusMethodHandler) wpas_dbus_handler_p2p_connect,
3479d4f2939cSRui Paulo {
3480d4f2939cSRui Paulo { "args", "a{sv}", ARG_IN },
3481d4f2939cSRui Paulo { "generated_pin", "s", ARG_OUT },
3482d4f2939cSRui Paulo END_ARGS
3483d4f2939cSRui Paulo }
3484d4f2939cSRui Paulo },
3485d4f2939cSRui Paulo { "GroupAdd", WPAS_DBUS_NEW_IFACE_P2PDEVICE,
3486d4f2939cSRui Paulo (WPADBusMethodHandler) wpas_dbus_handler_p2p_group_add,
3487d4f2939cSRui Paulo {
3488d4f2939cSRui Paulo { "args", "a{sv}", ARG_IN },
3489d4f2939cSRui Paulo END_ARGS
3490d4f2939cSRui Paulo }
3491d4f2939cSRui Paulo },
3492325151a3SRui Paulo { "Cancel", WPAS_DBUS_NEW_IFACE_P2PDEVICE,
3493325151a3SRui Paulo (WPADBusMethodHandler) wpas_dbus_handler_p2p_cancel,
3494325151a3SRui Paulo {
3495325151a3SRui Paulo END_ARGS
3496325151a3SRui Paulo }
3497325151a3SRui Paulo },
3498d4f2939cSRui Paulo { "Invite", WPAS_DBUS_NEW_IFACE_P2PDEVICE,
3499d4f2939cSRui Paulo (WPADBusMethodHandler) wpas_dbus_handler_p2p_invite,
3500d4f2939cSRui Paulo {
3501d4f2939cSRui Paulo { "args", "a{sv}", ARG_IN },
3502d4f2939cSRui Paulo END_ARGS
3503d4f2939cSRui Paulo }
3504d4f2939cSRui Paulo },
3505d4f2939cSRui Paulo { "Disconnect", WPAS_DBUS_NEW_IFACE_P2PDEVICE,
3506d4f2939cSRui Paulo (WPADBusMethodHandler) wpas_dbus_handler_p2p_disconnect,
3507d4f2939cSRui Paulo {
3508d4f2939cSRui Paulo END_ARGS
3509d4f2939cSRui Paulo }
3510d4f2939cSRui Paulo },
3511d4f2939cSRui Paulo { "RejectPeer", WPAS_DBUS_NEW_IFACE_P2PDEVICE,
3512d4f2939cSRui Paulo (WPADBusMethodHandler) wpas_dbus_handler_p2p_rejectpeer,
3513d4f2939cSRui Paulo {
3514d4f2939cSRui Paulo { "peer", "o", ARG_IN },
3515d4f2939cSRui Paulo END_ARGS
3516d4f2939cSRui Paulo }
3517d4f2939cSRui Paulo },
3518325151a3SRui Paulo { "RemoveClient", WPAS_DBUS_NEW_IFACE_P2PDEVICE,
3519325151a3SRui Paulo (WPADBusMethodHandler) wpas_dbus_handler_p2p_remove_client,
3520325151a3SRui Paulo {
3521325151a3SRui Paulo { "args", "a{sv}", ARG_IN },
3522325151a3SRui Paulo END_ARGS
3523325151a3SRui Paulo }
3524325151a3SRui Paulo },
3525d4f2939cSRui Paulo { "Flush", WPAS_DBUS_NEW_IFACE_P2PDEVICE,
3526d4f2939cSRui Paulo (WPADBusMethodHandler) wpas_dbus_handler_p2p_flush,
3527d4f2939cSRui Paulo {
3528d4f2939cSRui Paulo END_ARGS
3529d4f2939cSRui Paulo }
3530d4f2939cSRui Paulo },
3531d4f2939cSRui Paulo { "AddService", WPAS_DBUS_NEW_IFACE_P2PDEVICE,
3532d4f2939cSRui Paulo (WPADBusMethodHandler) wpas_dbus_handler_p2p_add_service,
3533d4f2939cSRui Paulo {
3534d4f2939cSRui Paulo { "args", "a{sv}", ARG_IN },
3535d4f2939cSRui Paulo END_ARGS
3536d4f2939cSRui Paulo }
3537d4f2939cSRui Paulo },
3538d4f2939cSRui Paulo { "DeleteService", WPAS_DBUS_NEW_IFACE_P2PDEVICE,
3539d4f2939cSRui Paulo (WPADBusMethodHandler) wpas_dbus_handler_p2p_delete_service,
3540d4f2939cSRui Paulo {
3541d4f2939cSRui Paulo { "args", "a{sv}", ARG_IN },
3542d4f2939cSRui Paulo END_ARGS
3543d4f2939cSRui Paulo }
3544d4f2939cSRui Paulo },
3545d4f2939cSRui Paulo { "FlushService", WPAS_DBUS_NEW_IFACE_P2PDEVICE,
3546d4f2939cSRui Paulo (WPADBusMethodHandler) wpas_dbus_handler_p2p_flush_service,
3547d4f2939cSRui Paulo {
3548d4f2939cSRui Paulo END_ARGS
3549d4f2939cSRui Paulo }
3550d4f2939cSRui Paulo },
3551d4f2939cSRui Paulo { "ServiceDiscoveryRequest", WPAS_DBUS_NEW_IFACE_P2PDEVICE,
3552d4f2939cSRui Paulo (WPADBusMethodHandler) wpas_dbus_handler_p2p_service_sd_req,
3553d4f2939cSRui Paulo {
3554d4f2939cSRui Paulo { "args", "a{sv}", ARG_IN },
35555b9c547cSRui Paulo { "ref", "t", ARG_OUT },
3556d4f2939cSRui Paulo END_ARGS
3557d4f2939cSRui Paulo }
3558d4f2939cSRui Paulo },
3559d4f2939cSRui Paulo { "ServiceDiscoveryResponse", WPAS_DBUS_NEW_IFACE_P2PDEVICE,
3560d4f2939cSRui Paulo (WPADBusMethodHandler) wpas_dbus_handler_p2p_service_sd_res,
3561d4f2939cSRui Paulo {
3562d4f2939cSRui Paulo { "args", "a{sv}", ARG_IN },
3563d4f2939cSRui Paulo END_ARGS
3564d4f2939cSRui Paulo }
3565d4f2939cSRui Paulo },
3566d4f2939cSRui Paulo { "ServiceDiscoveryCancelRequest", WPAS_DBUS_NEW_IFACE_P2PDEVICE,
3567d4f2939cSRui Paulo (WPADBusMethodHandler) wpas_dbus_handler_p2p_service_sd_cancel_req,
3568d4f2939cSRui Paulo {
3569d4f2939cSRui Paulo { "args", "t", ARG_IN },
3570d4f2939cSRui Paulo END_ARGS
3571d4f2939cSRui Paulo }
3572d4f2939cSRui Paulo },
3573d4f2939cSRui Paulo { "ServiceUpdate", WPAS_DBUS_NEW_IFACE_P2PDEVICE,
3574d4f2939cSRui Paulo (WPADBusMethodHandler) wpas_dbus_handler_p2p_service_update,
3575d4f2939cSRui Paulo {
3576d4f2939cSRui Paulo END_ARGS
3577d4f2939cSRui Paulo }
3578d4f2939cSRui Paulo },
3579d4f2939cSRui Paulo { "ServiceDiscoveryExternal", WPAS_DBUS_NEW_IFACE_P2PDEVICE,
3580d4f2939cSRui Paulo (WPADBusMethodHandler) wpas_dbus_handler_p2p_serv_disc_external,
3581d4f2939cSRui Paulo {
3582d4f2939cSRui Paulo { "arg", "i", ARG_IN },
3583d4f2939cSRui Paulo END_ARGS
3584d4f2939cSRui Paulo }
3585d4f2939cSRui Paulo },
3586d4f2939cSRui Paulo { "AddPersistentGroup", WPAS_DBUS_NEW_IFACE_P2PDEVICE,
3587d4f2939cSRui Paulo (WPADBusMethodHandler) wpas_dbus_handler_add_persistent_group,
3588d4f2939cSRui Paulo {
3589d4f2939cSRui Paulo { "args", "a{sv}", ARG_IN },
3590d4f2939cSRui Paulo { "path", "o", ARG_OUT },
3591d4f2939cSRui Paulo END_ARGS
3592d4f2939cSRui Paulo }
3593d4f2939cSRui Paulo },
3594d4f2939cSRui Paulo { "RemovePersistentGroup", WPAS_DBUS_NEW_IFACE_P2PDEVICE,
3595d4f2939cSRui Paulo (WPADBusMethodHandler) wpas_dbus_handler_remove_persistent_group,
3596d4f2939cSRui Paulo {
3597d4f2939cSRui Paulo { "path", "o", ARG_IN },
3598d4f2939cSRui Paulo END_ARGS
3599d4f2939cSRui Paulo }
3600d4f2939cSRui Paulo },
3601d4f2939cSRui Paulo { "RemoveAllPersistentGroups", WPAS_DBUS_NEW_IFACE_P2PDEVICE,
3602d4f2939cSRui Paulo (WPADBusMethodHandler)
3603d4f2939cSRui Paulo wpas_dbus_handler_remove_all_persistent_groups,
3604d4f2939cSRui Paulo {
3605d4f2939cSRui Paulo END_ARGS
3606d4f2939cSRui Paulo }
3607d4f2939cSRui Paulo },
3608d4f2939cSRui Paulo #endif /* CONFIG_P2P */
3609d4f2939cSRui Paulo { "FlushBSS", WPAS_DBUS_NEW_IFACE_INTERFACE,
36105b9c547cSRui Paulo (WPADBusMethodHandler) wpas_dbus_handler_flush_bss,
3611d4f2939cSRui Paulo {
3612d4f2939cSRui Paulo { "age", "u", ARG_IN },
3613d4f2939cSRui Paulo END_ARGS
3614d4f2939cSRui Paulo }
3615d4f2939cSRui Paulo },
3616d4f2939cSRui Paulo #ifdef CONFIG_AP
3617d4f2939cSRui Paulo { "SubscribeProbeReq", WPAS_DBUS_NEW_IFACE_INTERFACE,
3618d4f2939cSRui Paulo (WPADBusMethodHandler) wpas_dbus_handler_subscribe_preq,
3619d4f2939cSRui Paulo {
3620d4f2939cSRui Paulo END_ARGS
3621d4f2939cSRui Paulo }
3622d4f2939cSRui Paulo },
3623d4f2939cSRui Paulo { "UnsubscribeProbeReq", WPAS_DBUS_NEW_IFACE_INTERFACE,
3624d4f2939cSRui Paulo (WPADBusMethodHandler) wpas_dbus_handler_unsubscribe_preq,
3625d4f2939cSRui Paulo {
3626d4f2939cSRui Paulo END_ARGS
3627d4f2939cSRui Paulo }
3628d4f2939cSRui Paulo },
3629d4f2939cSRui Paulo #endif /* CONFIG_AP */
36305b9c547cSRui Paulo { "EAPLogoff", WPAS_DBUS_NEW_IFACE_INTERFACE,
36315b9c547cSRui Paulo (WPADBusMethodHandler) wpas_dbus_handler_eap_logoff,
36325b9c547cSRui Paulo {
36335b9c547cSRui Paulo END_ARGS
36345b9c547cSRui Paulo }
36355b9c547cSRui Paulo },
36365b9c547cSRui Paulo { "EAPLogon", WPAS_DBUS_NEW_IFACE_INTERFACE,
36375b9c547cSRui Paulo (WPADBusMethodHandler) wpas_dbus_handler_eap_logon,
36385b9c547cSRui Paulo {
36395b9c547cSRui Paulo END_ARGS
36405b9c547cSRui Paulo }
36415b9c547cSRui Paulo },
36425b9c547cSRui Paulo #ifdef CONFIG_AUTOSCAN
36435b9c547cSRui Paulo { "AutoScan", WPAS_DBUS_NEW_IFACE_INTERFACE,
36445b9c547cSRui Paulo (WPADBusMethodHandler) wpas_dbus_handler_autoscan,
36455b9c547cSRui Paulo {
36465b9c547cSRui Paulo { "arg", "s", ARG_IN },
36475b9c547cSRui Paulo END_ARGS
36485b9c547cSRui Paulo }
36495b9c547cSRui Paulo },
36505b9c547cSRui Paulo #endif /* CONFIG_AUTOSCAN */
36515b9c547cSRui Paulo #ifdef CONFIG_TDLS
36525b9c547cSRui Paulo { "TDLSDiscover", WPAS_DBUS_NEW_IFACE_INTERFACE,
36535b9c547cSRui Paulo (WPADBusMethodHandler) wpas_dbus_handler_tdls_discover,
36545b9c547cSRui Paulo {
36555b9c547cSRui Paulo { "peer_address", "s", ARG_IN },
36565b9c547cSRui Paulo END_ARGS
36575b9c547cSRui Paulo }
36585b9c547cSRui Paulo },
36595b9c547cSRui Paulo { "TDLSSetup", WPAS_DBUS_NEW_IFACE_INTERFACE,
36605b9c547cSRui Paulo (WPADBusMethodHandler) wpas_dbus_handler_tdls_setup,
36615b9c547cSRui Paulo {
36625b9c547cSRui Paulo { "peer_address", "s", ARG_IN },
36635b9c547cSRui Paulo END_ARGS
36645b9c547cSRui Paulo }
36655b9c547cSRui Paulo },
36665b9c547cSRui Paulo { "TDLSStatus", WPAS_DBUS_NEW_IFACE_INTERFACE,
36675b9c547cSRui Paulo (WPADBusMethodHandler) wpas_dbus_handler_tdls_status,
36685b9c547cSRui Paulo {
36695b9c547cSRui Paulo { "peer_address", "s", ARG_IN },
36705b9c547cSRui Paulo { "status", "s", ARG_OUT },
36715b9c547cSRui Paulo END_ARGS
36725b9c547cSRui Paulo }
36735b9c547cSRui Paulo },
36745b9c547cSRui Paulo { "TDLSTeardown", WPAS_DBUS_NEW_IFACE_INTERFACE,
36755b9c547cSRui Paulo (WPADBusMethodHandler) wpas_dbus_handler_tdls_teardown,
36765b9c547cSRui Paulo {
36775b9c547cSRui Paulo { "peer_address", "s", ARG_IN },
36785b9c547cSRui Paulo END_ARGS
36795b9c547cSRui Paulo }
36805b9c547cSRui Paulo },
368185732ac8SCy Schubert { "TDLSChannelSwitch", WPAS_DBUS_NEW_IFACE_INTERFACE,
368285732ac8SCy Schubert (WPADBusMethodHandler) wpas_dbus_handler_tdls_channel_switch,
368385732ac8SCy Schubert {
368485732ac8SCy Schubert { "args", "a{sv}", ARG_IN },
368585732ac8SCy Schubert END_ARGS
368685732ac8SCy Schubert }
368785732ac8SCy Schubert },
368885732ac8SCy Schubert { "TDLSCancelChannelSwitch", WPAS_DBUS_NEW_IFACE_INTERFACE,
368985732ac8SCy Schubert (WPADBusMethodHandler) wpas_dbus_handler_tdls_cancel_channel_switch,
369085732ac8SCy Schubert {
369185732ac8SCy Schubert { "peer_address", "s", ARG_IN },
369285732ac8SCy Schubert END_ARGS
369385732ac8SCy Schubert }
369485732ac8SCy Schubert },
36955b9c547cSRui Paulo #endif /* CONFIG_TDLS */
3696780fb4a2SCy Schubert { "VendorElemAdd", WPAS_DBUS_NEW_IFACE_INTERFACE,
3697780fb4a2SCy Schubert (WPADBusMethodHandler) wpas_dbus_handler_vendor_elem_add,
3698780fb4a2SCy Schubert {
3699780fb4a2SCy Schubert { "frame_id", "i", ARG_IN },
3700780fb4a2SCy Schubert { "ielems", "ay", ARG_IN },
3701780fb4a2SCy Schubert END_ARGS
3702780fb4a2SCy Schubert }
3703780fb4a2SCy Schubert },
3704780fb4a2SCy Schubert { "VendorElemGet", WPAS_DBUS_NEW_IFACE_INTERFACE,
3705780fb4a2SCy Schubert (WPADBusMethodHandler) wpas_dbus_handler_vendor_elem_get,
3706780fb4a2SCy Schubert {
3707780fb4a2SCy Schubert { "frame_id", "i", ARG_IN },
3708780fb4a2SCy Schubert { "ielems", "ay", ARG_OUT },
3709780fb4a2SCy Schubert END_ARGS
3710780fb4a2SCy Schubert }
3711780fb4a2SCy Schubert },
3712780fb4a2SCy Schubert { "VendorElemRem", WPAS_DBUS_NEW_IFACE_INTERFACE,
3713780fb4a2SCy Schubert (WPADBusMethodHandler) wpas_dbus_handler_vendor_elem_remove,
3714780fb4a2SCy Schubert {
3715780fb4a2SCy Schubert { "frame_id", "i", ARG_IN },
3716780fb4a2SCy Schubert { "ielems", "ay", ARG_IN },
3717780fb4a2SCy Schubert END_ARGS
3718780fb4a2SCy Schubert }
3719780fb4a2SCy Schubert },
3720780fb4a2SCy Schubert #ifndef CONFIG_NO_CONFIG_WRITE
3721780fb4a2SCy Schubert { "SaveConfig", WPAS_DBUS_NEW_IFACE_INTERFACE,
3722780fb4a2SCy Schubert (WPADBusMethodHandler) wpas_dbus_handler_save_config,
3723780fb4a2SCy Schubert {
3724780fb4a2SCy Schubert END_ARGS
3725780fb4a2SCy Schubert }
3726780fb4a2SCy Schubert },
3727780fb4a2SCy Schubert #endif /* CONFIG_NO_CONFIG_WRITE */
372885732ac8SCy Schubert { "AbortScan", WPAS_DBUS_NEW_IFACE_INTERFACE,
372985732ac8SCy Schubert (WPADBusMethodHandler) wpas_dbus_handler_abort_scan,
373085732ac8SCy Schubert {
373185732ac8SCy Schubert END_ARGS
373285732ac8SCy Schubert }
373385732ac8SCy Schubert },
373432a95656SCy Schubert #ifdef CONFIG_INTERWORKING
373532a95656SCy Schubert { "AddCred", WPAS_DBUS_NEW_IFACE_INTERFACE,
373632a95656SCy Schubert (WPADBusMethodHandler) wpas_dbus_handler_add_cred,
373732a95656SCy Schubert {
373832a95656SCy Schubert { "args", "a{sv}", ARG_IN },
373932a95656SCy Schubert { "path", "o", ARG_OUT },
374032a95656SCy Schubert END_ARGS
374132a95656SCy Schubert }
374232a95656SCy Schubert },
374332a95656SCy Schubert { "RemoveCred", WPAS_DBUS_NEW_IFACE_INTERFACE,
374432a95656SCy Schubert (WPADBusMethodHandler) wpas_dbus_handler_remove_cred,
374532a95656SCy Schubert {
374632a95656SCy Schubert { "path", "o", ARG_IN },
374732a95656SCy Schubert END_ARGS
374832a95656SCy Schubert }
374932a95656SCy Schubert },
375032a95656SCy Schubert { "RemoveAllCreds", WPAS_DBUS_NEW_IFACE_INTERFACE,
375132a95656SCy Schubert (WPADBusMethodHandler) wpas_dbus_handler_remove_all_creds,
375232a95656SCy Schubert {
375332a95656SCy Schubert END_ARGS
375432a95656SCy Schubert }
375532a95656SCy Schubert },
375632a95656SCy Schubert { "InterworkingSelect", WPAS_DBUS_NEW_IFACE_INTERFACE,
375732a95656SCy Schubert (WPADBusMethodHandler) wpas_dbus_handler_interworking_select,
375832a95656SCy Schubert {
375932a95656SCy Schubert END_ARGS
376032a95656SCy Schubert }
376132a95656SCy Schubert },
3762*a90b9d01SCy Schubert {"ANQPGet", WPAS_DBUS_NEW_IFACE_INTERFACE,
3763*a90b9d01SCy Schubert (WPADBusMethodHandler) wpas_dbus_handler_anqp_get,
3764*a90b9d01SCy Schubert {
3765*a90b9d01SCy Schubert { "args", "a{sv}", ARG_IN },
3766*a90b9d01SCy Schubert END_ARGS
3767*a90b9d01SCy Schubert },
3768*a90b9d01SCy Schubert },
376932a95656SCy Schubert #endif /* CONFIG_INTERWORKING */
3770d4f2939cSRui Paulo { NULL, NULL, NULL, { END_ARGS } }
3771d4f2939cSRui Paulo };
3772d4f2939cSRui Paulo
3773d4f2939cSRui Paulo static const struct wpa_dbus_property_desc wpas_dbus_interface_properties[] = {
3774d4f2939cSRui Paulo { "Capabilities", WPAS_DBUS_NEW_IFACE_INTERFACE, "a{sv}",
3775d4f2939cSRui Paulo wpas_dbus_getter_capabilities,
3776780fb4a2SCy Schubert NULL,
3777d4f2939cSRui Paulo NULL
3778d4f2939cSRui Paulo },
3779d4f2939cSRui Paulo { "State", WPAS_DBUS_NEW_IFACE_INTERFACE, "s",
3780d4f2939cSRui Paulo wpas_dbus_getter_state,
3781780fb4a2SCy Schubert NULL,
3782d4f2939cSRui Paulo NULL
3783d4f2939cSRui Paulo },
3784d4f2939cSRui Paulo { "Scanning", WPAS_DBUS_NEW_IFACE_INTERFACE, "b",
3785d4f2939cSRui Paulo wpas_dbus_getter_scanning,
3786780fb4a2SCy Schubert NULL,
3787d4f2939cSRui Paulo NULL
3788d4f2939cSRui Paulo },
3789d4f2939cSRui Paulo { "ApScan", WPAS_DBUS_NEW_IFACE_INTERFACE, "u",
3790d4f2939cSRui Paulo wpas_dbus_getter_ap_scan,
3791780fb4a2SCy Schubert wpas_dbus_setter_ap_scan,
3792780fb4a2SCy Schubert NULL
3793d4f2939cSRui Paulo },
3794d4f2939cSRui Paulo { "BSSExpireAge", WPAS_DBUS_NEW_IFACE_INTERFACE, "u",
3795d4f2939cSRui Paulo wpas_dbus_getter_bss_expire_age,
3796780fb4a2SCy Schubert wpas_dbus_setter_bss_expire_age,
3797780fb4a2SCy Schubert NULL
3798d4f2939cSRui Paulo },
3799d4f2939cSRui Paulo { "BSSExpireCount", WPAS_DBUS_NEW_IFACE_INTERFACE, "u",
3800d4f2939cSRui Paulo wpas_dbus_getter_bss_expire_count,
3801780fb4a2SCy Schubert wpas_dbus_setter_bss_expire_count,
3802780fb4a2SCy Schubert NULL
3803d4f2939cSRui Paulo },
3804d4f2939cSRui Paulo { "Country", WPAS_DBUS_NEW_IFACE_INTERFACE, "s",
3805d4f2939cSRui Paulo wpas_dbus_getter_country,
3806780fb4a2SCy Schubert wpas_dbus_setter_country,
3807780fb4a2SCy Schubert NULL
3808d4f2939cSRui Paulo },
3809d4f2939cSRui Paulo { "Ifname", WPAS_DBUS_NEW_IFACE_INTERFACE, "s",
3810d4f2939cSRui Paulo wpas_dbus_getter_ifname,
3811780fb4a2SCy Schubert NULL,
3812d4f2939cSRui Paulo NULL
3813d4f2939cSRui Paulo },
3814d4f2939cSRui Paulo { "Driver", WPAS_DBUS_NEW_IFACE_INTERFACE, "s",
3815d4f2939cSRui Paulo wpas_dbus_getter_driver,
3816780fb4a2SCy Schubert NULL,
3817d4f2939cSRui Paulo NULL
3818d4f2939cSRui Paulo },
3819d4f2939cSRui Paulo { "BridgeIfname", WPAS_DBUS_NEW_IFACE_INTERFACE, "s",
3820d4f2939cSRui Paulo wpas_dbus_getter_bridge_ifname,
3821c1d255d3SCy Schubert wpas_dbus_setter_bridge_ifname,
3822780fb4a2SCy Schubert NULL
3823780fb4a2SCy Schubert },
3824780fb4a2SCy Schubert { "ConfigFile", WPAS_DBUS_NEW_IFACE_INTERFACE, "s",
3825780fb4a2SCy Schubert wpas_dbus_getter_config_file,
3826780fb4a2SCy Schubert NULL,
3827d4f2939cSRui Paulo NULL
3828d4f2939cSRui Paulo },
3829d4f2939cSRui Paulo { "CurrentBSS", WPAS_DBUS_NEW_IFACE_INTERFACE, "o",
3830d4f2939cSRui Paulo wpas_dbus_getter_current_bss,
3831780fb4a2SCy Schubert NULL,
3832d4f2939cSRui Paulo NULL
3833d4f2939cSRui Paulo },
3834d4f2939cSRui Paulo { "CurrentNetwork", WPAS_DBUS_NEW_IFACE_INTERFACE, "o",
3835d4f2939cSRui Paulo wpas_dbus_getter_current_network,
3836780fb4a2SCy Schubert NULL,
3837d4f2939cSRui Paulo NULL
3838d4f2939cSRui Paulo },
3839d4f2939cSRui Paulo { "CurrentAuthMode", WPAS_DBUS_NEW_IFACE_INTERFACE, "s",
3840d4f2939cSRui Paulo wpas_dbus_getter_current_auth_mode,
3841780fb4a2SCy Schubert NULL,
3842d4f2939cSRui Paulo NULL
3843d4f2939cSRui Paulo },
3844d4f2939cSRui Paulo { "Blobs", WPAS_DBUS_NEW_IFACE_INTERFACE, "a{say}",
3845d4f2939cSRui Paulo wpas_dbus_getter_blobs,
3846780fb4a2SCy Schubert NULL,
3847d4f2939cSRui Paulo NULL
3848d4f2939cSRui Paulo },
3849d4f2939cSRui Paulo { "BSSs", WPAS_DBUS_NEW_IFACE_INTERFACE, "ao",
3850d4f2939cSRui Paulo wpas_dbus_getter_bsss,
3851780fb4a2SCy Schubert NULL,
3852d4f2939cSRui Paulo NULL
3853d4f2939cSRui Paulo },
3854d4f2939cSRui Paulo { "Networks", WPAS_DBUS_NEW_IFACE_INTERFACE, "ao",
3855d4f2939cSRui Paulo wpas_dbus_getter_networks,
3856780fb4a2SCy Schubert NULL,
3857d4f2939cSRui Paulo NULL
3858d4f2939cSRui Paulo },
3859d4f2939cSRui Paulo { "FastReauth", WPAS_DBUS_NEW_IFACE_INTERFACE, "b",
3860d4f2939cSRui Paulo wpas_dbus_getter_fast_reauth,
3861780fb4a2SCy Schubert wpas_dbus_setter_fast_reauth,
3862780fb4a2SCy Schubert NULL
3863d4f2939cSRui Paulo },
3864d4f2939cSRui Paulo { "ScanInterval", WPAS_DBUS_NEW_IFACE_INTERFACE, "i",
3865d4f2939cSRui Paulo wpas_dbus_getter_scan_interval,
3866780fb4a2SCy Schubert wpas_dbus_setter_scan_interval,
3867780fb4a2SCy Schubert NULL
3868d4f2939cSRui Paulo },
38695b9c547cSRui Paulo { "PKCS11EnginePath", WPAS_DBUS_NEW_IFACE_INTERFACE, "s",
38705b9c547cSRui Paulo wpas_dbus_getter_pkcs11_engine_path,
3871780fb4a2SCy Schubert NULL,
38725b9c547cSRui Paulo NULL
38735b9c547cSRui Paulo },
38745b9c547cSRui Paulo { "PKCS11ModulePath", WPAS_DBUS_NEW_IFACE_INTERFACE, "s",
38755b9c547cSRui Paulo wpas_dbus_getter_pkcs11_module_path,
3876780fb4a2SCy Schubert NULL,
38775b9c547cSRui Paulo NULL
38785b9c547cSRui Paulo },
3879d4f2939cSRui Paulo #ifdef CONFIG_WPS
3880d4f2939cSRui Paulo { "ProcessCredentials", WPAS_DBUS_NEW_IFACE_WPS, "b",
3881d4f2939cSRui Paulo wpas_dbus_getter_process_credentials,
3882780fb4a2SCy Schubert wpas_dbus_setter_process_credentials,
3883780fb4a2SCy Schubert NULL
3884d4f2939cSRui Paulo },
38855b9c547cSRui Paulo { "ConfigMethods", WPAS_DBUS_NEW_IFACE_WPS, "s",
38865b9c547cSRui Paulo wpas_dbus_getter_config_methods,
3887780fb4a2SCy Schubert wpas_dbus_setter_config_methods,
3888780fb4a2SCy Schubert NULL
38895b9c547cSRui Paulo },
389085732ac8SCy Schubert {
389185732ac8SCy Schubert "DeviceName", WPAS_DBUS_NEW_IFACE_WPS, "s",
389285732ac8SCy Schubert wpas_dbus_getter_wps_device_name,
389385732ac8SCy Schubert wpas_dbus_setter_wps_device_name,
389485732ac8SCy Schubert NULL
389585732ac8SCy Schubert },
389685732ac8SCy Schubert {
389785732ac8SCy Schubert "Manufacturer", WPAS_DBUS_NEW_IFACE_WPS, "s",
389885732ac8SCy Schubert wpas_dbus_getter_wps_manufacturer,
389985732ac8SCy Schubert wpas_dbus_setter_wps_manufacturer,
390085732ac8SCy Schubert NULL
390185732ac8SCy Schubert },
390285732ac8SCy Schubert {
390385732ac8SCy Schubert "ModelName", WPAS_DBUS_NEW_IFACE_WPS, "s",
390485732ac8SCy Schubert wpas_dbus_getter_wps_device_model_name,
390585732ac8SCy Schubert wpas_dbus_setter_wps_device_model_name,
390685732ac8SCy Schubert NULL
390785732ac8SCy Schubert },
390885732ac8SCy Schubert {
390985732ac8SCy Schubert "ModelNumber", WPAS_DBUS_NEW_IFACE_WPS, "s",
391085732ac8SCy Schubert wpas_dbus_getter_wps_device_model_number,
391185732ac8SCy Schubert wpas_dbus_setter_wps_device_model_number,
391285732ac8SCy Schubert NULL
391385732ac8SCy Schubert },
391485732ac8SCy Schubert {
391585732ac8SCy Schubert "SerialNumber", WPAS_DBUS_NEW_IFACE_WPS, "s",
391685732ac8SCy Schubert wpas_dbus_getter_wps_device_serial_number,
391785732ac8SCy Schubert wpas_dbus_setter_wps_device_serial_number,
391885732ac8SCy Schubert NULL
391985732ac8SCy Schubert },
392085732ac8SCy Schubert {
392185732ac8SCy Schubert "DeviceType", WPAS_DBUS_NEW_IFACE_WPS, "ay",
392285732ac8SCy Schubert wpas_dbus_getter_wps_device_device_type,
392385732ac8SCy Schubert wpas_dbus_setter_wps_device_device_type,
392485732ac8SCy Schubert NULL
392585732ac8SCy Schubert },
3926d4f2939cSRui Paulo #endif /* CONFIG_WPS */
3927d4f2939cSRui Paulo #ifdef CONFIG_P2P
3928d4f2939cSRui Paulo { "P2PDeviceConfig", WPAS_DBUS_NEW_IFACE_P2PDEVICE, "a{sv}",
3929d4f2939cSRui Paulo wpas_dbus_getter_p2p_device_config,
3930780fb4a2SCy Schubert wpas_dbus_setter_p2p_device_config,
3931780fb4a2SCy Schubert NULL
3932d4f2939cSRui Paulo },
3933d4f2939cSRui Paulo { "Peers", WPAS_DBUS_NEW_IFACE_P2PDEVICE, "ao",
3934d4f2939cSRui Paulo wpas_dbus_getter_p2p_peers,
3935780fb4a2SCy Schubert NULL,
3936d4f2939cSRui Paulo NULL
3937d4f2939cSRui Paulo },
3938d4f2939cSRui Paulo { "Role", WPAS_DBUS_NEW_IFACE_P2PDEVICE, "s",
3939d4f2939cSRui Paulo wpas_dbus_getter_p2p_role,
3940780fb4a2SCy Schubert NULL,
3941d4f2939cSRui Paulo NULL
3942d4f2939cSRui Paulo },
3943d4f2939cSRui Paulo { "Group", WPAS_DBUS_NEW_IFACE_P2PDEVICE, "o",
3944d4f2939cSRui Paulo wpas_dbus_getter_p2p_group,
3945780fb4a2SCy Schubert NULL,
3946d4f2939cSRui Paulo NULL
3947d4f2939cSRui Paulo },
3948d4f2939cSRui Paulo { "PeerGO", WPAS_DBUS_NEW_IFACE_P2PDEVICE, "o",
3949d4f2939cSRui Paulo wpas_dbus_getter_p2p_peergo,
3950780fb4a2SCy Schubert NULL,
3951d4f2939cSRui Paulo NULL
3952d4f2939cSRui Paulo },
3953d4f2939cSRui Paulo { "PersistentGroups", WPAS_DBUS_NEW_IFACE_P2PDEVICE, "ao",
3954d4f2939cSRui Paulo wpas_dbus_getter_persistent_groups,
3955780fb4a2SCy Schubert NULL,
3956d4f2939cSRui Paulo NULL
3957d4f2939cSRui Paulo },
3958d4f2939cSRui Paulo #endif /* CONFIG_P2P */
3959d4f2939cSRui Paulo { "DisconnectReason", WPAS_DBUS_NEW_IFACE_INTERFACE, "i",
3960d4f2939cSRui Paulo wpas_dbus_getter_disconnect_reason,
3961780fb4a2SCy Schubert NULL,
3962d4f2939cSRui Paulo NULL
3963d4f2939cSRui Paulo },
39644bc52338SCy Schubert { "AuthStatusCode", WPAS_DBUS_NEW_IFACE_INTERFACE, "i",
39654bc52338SCy Schubert wpas_dbus_getter_auth_status_code,
39664bc52338SCy Schubert NULL,
39674bc52338SCy Schubert NULL
39684bc52338SCy Schubert },
3969780fb4a2SCy Schubert { "AssocStatusCode", WPAS_DBUS_NEW_IFACE_INTERFACE, "i",
3970780fb4a2SCy Schubert wpas_dbus_getter_assoc_status_code,
3971780fb4a2SCy Schubert NULL,
3972780fb4a2SCy Schubert NULL
3973780fb4a2SCy Schubert },
3974c1d255d3SCy Schubert {
3975c1d255d3SCy Schubert "RoamTime", WPAS_DBUS_NEW_IFACE_INTERFACE, "u",
3976c1d255d3SCy Schubert wpas_dbus_getter_roam_time,
3977c1d255d3SCy Schubert NULL,
3978c1d255d3SCy Schubert NULL
3979c1d255d3SCy Schubert },
3980c1d255d3SCy Schubert {
3981c1d255d3SCy Schubert "RoamComplete", WPAS_DBUS_NEW_IFACE_INTERFACE, "b",
3982c1d255d3SCy Schubert wpas_dbus_getter_roam_complete,
3983c1d255d3SCy Schubert NULL,
3984c1d255d3SCy Schubert NULL
3985c1d255d3SCy Schubert },
3986c1d255d3SCy Schubert {
3987c1d255d3SCy Schubert "SessionLength", WPAS_DBUS_NEW_IFACE_INTERFACE, "u",
3988c1d255d3SCy Schubert wpas_dbus_getter_session_length,
3989c1d255d3SCy Schubert NULL,
3990c1d255d3SCy Schubert NULL
3991c1d255d3SCy Schubert },
3992c1d255d3SCy Schubert {
3993c1d255d3SCy Schubert "BSSTMStatus", WPAS_DBUS_NEW_IFACE_INTERFACE, "u",
3994c1d255d3SCy Schubert wpas_dbus_getter_bss_tm_status,
3995c1d255d3SCy Schubert NULL,
3996c1d255d3SCy Schubert NULL
3997c1d255d3SCy Schubert },
399885732ac8SCy Schubert #ifdef CONFIG_MESH
399985732ac8SCy Schubert { "MeshPeers", WPAS_DBUS_NEW_IFACE_MESH, "aay",
400085732ac8SCy Schubert wpas_dbus_getter_mesh_peers,
400185732ac8SCy Schubert NULL,
400285732ac8SCy Schubert NULL
400385732ac8SCy Schubert },
400485732ac8SCy Schubert { "MeshGroup", WPAS_DBUS_NEW_IFACE_MESH, "ay",
400585732ac8SCy Schubert wpas_dbus_getter_mesh_group,
400685732ac8SCy Schubert NULL,
400785732ac8SCy Schubert NULL
400885732ac8SCy Schubert },
400985732ac8SCy Schubert #endif /* CONFIG_MESH */
40104bc52338SCy Schubert { "Stations", WPAS_DBUS_NEW_IFACE_INTERFACE, "ao",
40114bc52338SCy Schubert wpas_dbus_getter_stas,
40124bc52338SCy Schubert NULL,
40134bc52338SCy Schubert NULL
40144bc52338SCy Schubert },
4015c1d255d3SCy Schubert { "MACAddressRandomizationMask", WPAS_DBUS_NEW_IFACE_INTERFACE,
4016c1d255d3SCy Schubert "a{say}",
4017c1d255d3SCy Schubert wpas_dbus_getter_mac_address_randomization_mask,
4018c1d255d3SCy Schubert wpas_dbus_setter_mac_address_randomization_mask,
4019c1d255d3SCy Schubert NULL
4020c1d255d3SCy Schubert },
4021*a90b9d01SCy Schubert { "MACAddress", WPAS_DBUS_NEW_IFACE_INTERFACE, "ay",
4022*a90b9d01SCy Schubert wpas_dbus_getter_mac_address,
4023*a90b9d01SCy Schubert NULL,
4024*a90b9d01SCy Schubert NULL,
4025*a90b9d01SCy Schubert },
4026*a90b9d01SCy Schubert { "SignalChange", WPAS_DBUS_NEW_IFACE_INTERFACE, "a{sv}",
4027*a90b9d01SCy Schubert wpas_dbus_getter_signal_change,
4028*a90b9d01SCy Schubert NULL,
4029*a90b9d01SCy Schubert NULL
4030*a90b9d01SCy Schubert },
4031780fb4a2SCy Schubert { NULL, NULL, NULL, NULL, NULL, NULL }
4032d4f2939cSRui Paulo };
4033d4f2939cSRui Paulo
4034d4f2939cSRui Paulo static const struct wpa_dbus_signal_desc wpas_dbus_interface_signals[] = {
4035d4f2939cSRui Paulo { "ScanDone", WPAS_DBUS_NEW_IFACE_INTERFACE,
4036d4f2939cSRui Paulo {
4037d4f2939cSRui Paulo { "success", "b", ARG_OUT },
4038d4f2939cSRui Paulo END_ARGS
4039d4f2939cSRui Paulo }
4040d4f2939cSRui Paulo },
4041d4f2939cSRui Paulo { "BSSAdded", WPAS_DBUS_NEW_IFACE_INTERFACE,
4042d4f2939cSRui Paulo {
4043d4f2939cSRui Paulo { "path", "o", ARG_OUT },
4044d4f2939cSRui Paulo { "properties", "a{sv}", ARG_OUT },
4045d4f2939cSRui Paulo END_ARGS
4046d4f2939cSRui Paulo }
4047d4f2939cSRui Paulo },
4048d4f2939cSRui Paulo { "BSSRemoved", WPAS_DBUS_NEW_IFACE_INTERFACE,
4049d4f2939cSRui Paulo {
4050d4f2939cSRui Paulo { "path", "o", ARG_OUT },
4051d4f2939cSRui Paulo END_ARGS
4052d4f2939cSRui Paulo }
4053d4f2939cSRui Paulo },
4054d4f2939cSRui Paulo { "BlobAdded", WPAS_DBUS_NEW_IFACE_INTERFACE,
4055d4f2939cSRui Paulo {
4056d4f2939cSRui Paulo { "name", "s", ARG_OUT },
4057d4f2939cSRui Paulo END_ARGS
4058d4f2939cSRui Paulo }
4059d4f2939cSRui Paulo },
4060d4f2939cSRui Paulo { "BlobRemoved", WPAS_DBUS_NEW_IFACE_INTERFACE,
4061d4f2939cSRui Paulo {
4062d4f2939cSRui Paulo { "name", "s", ARG_OUT },
4063d4f2939cSRui Paulo END_ARGS
4064d4f2939cSRui Paulo }
4065d4f2939cSRui Paulo },
4066d4f2939cSRui Paulo { "NetworkAdded", WPAS_DBUS_NEW_IFACE_INTERFACE,
4067d4f2939cSRui Paulo {
4068d4f2939cSRui Paulo { "path", "o", ARG_OUT },
4069d4f2939cSRui Paulo { "properties", "a{sv}", ARG_OUT },
4070d4f2939cSRui Paulo END_ARGS
4071d4f2939cSRui Paulo }
4072d4f2939cSRui Paulo },
4073d4f2939cSRui Paulo { "NetworkRemoved", WPAS_DBUS_NEW_IFACE_INTERFACE,
4074d4f2939cSRui Paulo {
4075d4f2939cSRui Paulo { "path", "o", ARG_OUT },
4076d4f2939cSRui Paulo END_ARGS
4077d4f2939cSRui Paulo }
4078d4f2939cSRui Paulo },
4079d4f2939cSRui Paulo { "NetworkSelected", WPAS_DBUS_NEW_IFACE_INTERFACE,
4080d4f2939cSRui Paulo {
4081d4f2939cSRui Paulo { "path", "o", ARG_OUT },
4082d4f2939cSRui Paulo END_ARGS
4083d4f2939cSRui Paulo }
4084d4f2939cSRui Paulo },
4085d4f2939cSRui Paulo /* Deprecated: use org.freedesktop.DBus.Properties.PropertiesChanged */
4086d4f2939cSRui Paulo { "PropertiesChanged", WPAS_DBUS_NEW_IFACE_INTERFACE,
4087d4f2939cSRui Paulo {
4088d4f2939cSRui Paulo { "properties", "a{sv}", ARG_OUT },
4089d4f2939cSRui Paulo END_ARGS
4090d4f2939cSRui Paulo }
4091d4f2939cSRui Paulo },
4092d4f2939cSRui Paulo #ifdef CONFIG_WPS
4093d4f2939cSRui Paulo { "Event", WPAS_DBUS_NEW_IFACE_WPS,
4094d4f2939cSRui Paulo {
4095d4f2939cSRui Paulo { "name", "s", ARG_OUT },
4096d4f2939cSRui Paulo { "args", "a{sv}", ARG_OUT },
4097d4f2939cSRui Paulo END_ARGS
4098d4f2939cSRui Paulo }
4099d4f2939cSRui Paulo },
4100d4f2939cSRui Paulo { "Credentials", WPAS_DBUS_NEW_IFACE_WPS,
4101d4f2939cSRui Paulo {
4102d4f2939cSRui Paulo { "credentials", "a{sv}", ARG_OUT },
4103d4f2939cSRui Paulo END_ARGS
4104d4f2939cSRui Paulo }
4105d4f2939cSRui Paulo },
4106d4f2939cSRui Paulo /* Deprecated: use org.freedesktop.DBus.Properties.PropertiesChanged */
4107d4f2939cSRui Paulo { "PropertiesChanged", WPAS_DBUS_NEW_IFACE_WPS,
4108d4f2939cSRui Paulo {
4109d4f2939cSRui Paulo { "properties", "a{sv}", ARG_OUT },
4110d4f2939cSRui Paulo END_ARGS
4111d4f2939cSRui Paulo }
4112d4f2939cSRui Paulo },
4113d4f2939cSRui Paulo #endif /* CONFIG_WPS */
4114d4f2939cSRui Paulo #ifdef CONFIG_P2P
4115d4f2939cSRui Paulo { "DeviceFound", WPAS_DBUS_NEW_IFACE_P2PDEVICE,
4116d4f2939cSRui Paulo {
4117d4f2939cSRui Paulo { "path", "o", ARG_OUT },
4118d4f2939cSRui Paulo END_ARGS
4119d4f2939cSRui Paulo }
4120d4f2939cSRui Paulo },
4121780fb4a2SCy Schubert { "DeviceFoundProperties", WPAS_DBUS_NEW_IFACE_P2PDEVICE,
4122780fb4a2SCy Schubert {
4123780fb4a2SCy Schubert { "path", "o", ARG_OUT },
4124780fb4a2SCy Schubert { "properties", "a{sv}", ARG_OUT },
4125780fb4a2SCy Schubert END_ARGS
4126780fb4a2SCy Schubert }
4127780fb4a2SCy Schubert },
4128d4f2939cSRui Paulo { "DeviceLost", WPAS_DBUS_NEW_IFACE_P2PDEVICE,
4129d4f2939cSRui Paulo {
4130d4f2939cSRui Paulo { "path", "o", ARG_OUT },
4131d4f2939cSRui Paulo END_ARGS
4132d4f2939cSRui Paulo }
4133d4f2939cSRui Paulo },
4134325151a3SRui Paulo { "FindStopped", WPAS_DBUS_NEW_IFACE_P2PDEVICE,
4135325151a3SRui Paulo {
4136325151a3SRui Paulo END_ARGS
4137325151a3SRui Paulo }
4138325151a3SRui Paulo },
4139d4f2939cSRui Paulo { "ProvisionDiscoveryRequestDisplayPin", WPAS_DBUS_NEW_IFACE_P2PDEVICE,
4140d4f2939cSRui Paulo {
4141d4f2939cSRui Paulo { "peer_object", "o", ARG_OUT },
4142d4f2939cSRui Paulo { "pin", "s", ARG_OUT },
4143d4f2939cSRui Paulo END_ARGS
4144d4f2939cSRui Paulo }
4145d4f2939cSRui Paulo },
4146d4f2939cSRui Paulo { "ProvisionDiscoveryResponseDisplayPin", WPAS_DBUS_NEW_IFACE_P2PDEVICE,
4147d4f2939cSRui Paulo {
4148d4f2939cSRui Paulo { "peer_object", "o", ARG_OUT },
4149d4f2939cSRui Paulo { "pin", "s", ARG_OUT },
4150d4f2939cSRui Paulo END_ARGS
4151d4f2939cSRui Paulo }
4152d4f2939cSRui Paulo },
4153d4f2939cSRui Paulo { "ProvisionDiscoveryRequestEnterPin", WPAS_DBUS_NEW_IFACE_P2PDEVICE,
4154d4f2939cSRui Paulo {
4155d4f2939cSRui Paulo { "peer_object", "o", ARG_OUT },
4156d4f2939cSRui Paulo END_ARGS
4157d4f2939cSRui Paulo }
4158d4f2939cSRui Paulo },
4159d4f2939cSRui Paulo { "ProvisionDiscoveryResponseEnterPin", WPAS_DBUS_NEW_IFACE_P2PDEVICE,
4160d4f2939cSRui Paulo {
4161d4f2939cSRui Paulo { "peer_object", "o", ARG_OUT },
4162d4f2939cSRui Paulo END_ARGS
4163d4f2939cSRui Paulo }
4164d4f2939cSRui Paulo },
4165d4f2939cSRui Paulo { "ProvisionDiscoveryPBCRequest", WPAS_DBUS_NEW_IFACE_P2PDEVICE,
4166d4f2939cSRui Paulo {
4167d4f2939cSRui Paulo { "peer_object", "o", ARG_OUT },
4168d4f2939cSRui Paulo END_ARGS
4169d4f2939cSRui Paulo }
4170d4f2939cSRui Paulo },
4171d4f2939cSRui Paulo { "ProvisionDiscoveryPBCResponse", WPAS_DBUS_NEW_IFACE_P2PDEVICE,
4172d4f2939cSRui Paulo {
4173d4f2939cSRui Paulo { "peer_object", "o", ARG_OUT },
4174d4f2939cSRui Paulo END_ARGS
4175d4f2939cSRui Paulo }
4176d4f2939cSRui Paulo },
4177d4f2939cSRui Paulo { "ProvisionDiscoveryFailure", WPAS_DBUS_NEW_IFACE_P2PDEVICE,
4178d4f2939cSRui Paulo {
4179d4f2939cSRui Paulo { "peer_object", "o", ARG_OUT },
4180d4f2939cSRui Paulo { "status", "i", ARG_OUT },
4181d4f2939cSRui Paulo END_ARGS
4182d4f2939cSRui Paulo }
4183d4f2939cSRui Paulo },
4184d4f2939cSRui Paulo { "GroupStarted", WPAS_DBUS_NEW_IFACE_P2PDEVICE,
4185d4f2939cSRui Paulo {
4186d4f2939cSRui Paulo { "properties", "a{sv}", ARG_OUT },
4187d4f2939cSRui Paulo END_ARGS
4188d4f2939cSRui Paulo }
4189d4f2939cSRui Paulo },
4190325151a3SRui Paulo { "GroupFormationFailure", WPAS_DBUS_NEW_IFACE_P2PDEVICE,
4191325151a3SRui Paulo {
4192325151a3SRui Paulo { "reason", "s", ARG_OUT },
4193325151a3SRui Paulo END_ARGS
4194325151a3SRui Paulo }
4195325151a3SRui Paulo },
4196d4f2939cSRui Paulo { "GONegotiationSuccess", WPAS_DBUS_NEW_IFACE_P2PDEVICE,
4197d4f2939cSRui Paulo {
41985b9c547cSRui Paulo { "properties", "a{sv}", ARG_OUT },
4199d4f2939cSRui Paulo END_ARGS
4200d4f2939cSRui Paulo }
4201d4f2939cSRui Paulo },
4202d4f2939cSRui Paulo { "GONegotiationFailure", WPAS_DBUS_NEW_IFACE_P2PDEVICE,
4203d4f2939cSRui Paulo {
42045b9c547cSRui Paulo { "properties", "a{sv}", ARG_OUT },
4205d4f2939cSRui Paulo END_ARGS
4206d4f2939cSRui Paulo }
4207d4f2939cSRui Paulo },
4208d4f2939cSRui Paulo { "GONegotiationRequest", WPAS_DBUS_NEW_IFACE_P2PDEVICE,
4209d4f2939cSRui Paulo {
4210d4f2939cSRui Paulo { "path", "o", ARG_OUT },
4211325151a3SRui Paulo { "dev_passwd_id", "q", ARG_OUT },
4212325151a3SRui Paulo { "device_go_intent", "y", ARG_OUT },
4213d4f2939cSRui Paulo END_ARGS
4214d4f2939cSRui Paulo }
4215d4f2939cSRui Paulo },
4216d4f2939cSRui Paulo { "InvitationResult", WPAS_DBUS_NEW_IFACE_P2PDEVICE,
4217d4f2939cSRui Paulo {
4218d4f2939cSRui Paulo { "invite_result", "a{sv}", ARG_OUT },
4219d4f2939cSRui Paulo END_ARGS
4220d4f2939cSRui Paulo }
4221d4f2939cSRui Paulo },
4222d4f2939cSRui Paulo { "GroupFinished", WPAS_DBUS_NEW_IFACE_P2PDEVICE,
4223d4f2939cSRui Paulo {
42245b9c547cSRui Paulo { "properties", "a{sv}", ARG_OUT },
4225d4f2939cSRui Paulo END_ARGS
4226d4f2939cSRui Paulo }
4227d4f2939cSRui Paulo },
4228d4f2939cSRui Paulo { "ServiceDiscoveryRequest", WPAS_DBUS_NEW_IFACE_P2PDEVICE,
4229d4f2939cSRui Paulo {
4230d4f2939cSRui Paulo { "sd_request", "a{sv}", ARG_OUT },
4231d4f2939cSRui Paulo END_ARGS
4232d4f2939cSRui Paulo }
4233d4f2939cSRui Paulo },
4234d4f2939cSRui Paulo { "ServiceDiscoveryResponse", WPAS_DBUS_NEW_IFACE_P2PDEVICE,
4235d4f2939cSRui Paulo {
4236d4f2939cSRui Paulo { "sd_response", "a{sv}", ARG_OUT },
4237d4f2939cSRui Paulo END_ARGS
4238d4f2939cSRui Paulo }
4239d4f2939cSRui Paulo },
4240d4f2939cSRui Paulo { "PersistentGroupAdded", WPAS_DBUS_NEW_IFACE_P2PDEVICE,
4241d4f2939cSRui Paulo {
4242d4f2939cSRui Paulo { "path", "o", ARG_OUT },
4243d4f2939cSRui Paulo { "properties", "a{sv}", ARG_OUT },
4244d4f2939cSRui Paulo END_ARGS
4245d4f2939cSRui Paulo }
4246d4f2939cSRui Paulo },
4247d4f2939cSRui Paulo { "PersistentGroupRemoved", WPAS_DBUS_NEW_IFACE_P2PDEVICE,
4248d4f2939cSRui Paulo {
4249d4f2939cSRui Paulo { "path", "o", ARG_OUT },
4250d4f2939cSRui Paulo END_ARGS
4251d4f2939cSRui Paulo }
4252d4f2939cSRui Paulo },
4253d4f2939cSRui Paulo { "WpsFailed", WPAS_DBUS_NEW_IFACE_P2PDEVICE,
4254d4f2939cSRui Paulo {
4255d4f2939cSRui Paulo { "name", "s", ARG_OUT },
4256d4f2939cSRui Paulo { "args", "a{sv}", ARG_OUT },
4257d4f2939cSRui Paulo END_ARGS
4258d4f2939cSRui Paulo }
4259d4f2939cSRui Paulo },
4260325151a3SRui Paulo { "InvitationReceived", WPAS_DBUS_NEW_IFACE_P2PDEVICE,
4261325151a3SRui Paulo {
4262325151a3SRui Paulo { "properties", "a{sv}", ARG_OUT },
4263325151a3SRui Paulo END_ARGS
4264325151a3SRui Paulo }
4265325151a3SRui Paulo },
4266d4f2939cSRui Paulo #endif /* CONFIG_P2P */
4267d4f2939cSRui Paulo #ifdef CONFIG_AP
4268d4f2939cSRui Paulo { "ProbeRequest", WPAS_DBUS_NEW_IFACE_INTERFACE,
4269d4f2939cSRui Paulo {
4270d4f2939cSRui Paulo { "args", "a{sv}", ARG_OUT },
4271d4f2939cSRui Paulo END_ARGS
4272d4f2939cSRui Paulo }
4273d4f2939cSRui Paulo },
4274d4f2939cSRui Paulo #endif /* CONFIG_AP */
4275d4f2939cSRui Paulo { "Certification", WPAS_DBUS_NEW_IFACE_INTERFACE,
4276d4f2939cSRui Paulo {
4277d4f2939cSRui Paulo { "certification", "a{sv}", ARG_OUT },
4278d4f2939cSRui Paulo END_ARGS
4279d4f2939cSRui Paulo }
4280d4f2939cSRui Paulo },
4281d4f2939cSRui Paulo { "EAP", WPAS_DBUS_NEW_IFACE_INTERFACE,
4282d4f2939cSRui Paulo {
4283d4f2939cSRui Paulo { "status", "s", ARG_OUT },
4284d4f2939cSRui Paulo { "parameter", "s", ARG_OUT },
4285d4f2939cSRui Paulo END_ARGS
4286d4f2939cSRui Paulo }
4287d4f2939cSRui Paulo },
42885b9c547cSRui Paulo { "StaAuthorized", WPAS_DBUS_NEW_IFACE_INTERFACE,
42895b9c547cSRui Paulo {
42905b9c547cSRui Paulo { "name", "s", ARG_OUT },
42915b9c547cSRui Paulo END_ARGS
42925b9c547cSRui Paulo }
42935b9c547cSRui Paulo },
42945b9c547cSRui Paulo { "StaDeauthorized", WPAS_DBUS_NEW_IFACE_INTERFACE,
42955b9c547cSRui Paulo {
42965b9c547cSRui Paulo { "name", "s", ARG_OUT },
42975b9c547cSRui Paulo END_ARGS
42985b9c547cSRui Paulo }
42995b9c547cSRui Paulo },
43004bc52338SCy Schubert { "StationAdded", WPAS_DBUS_NEW_IFACE_INTERFACE,
43014bc52338SCy Schubert {
43024bc52338SCy Schubert { "path", "o", ARG_OUT },
43034bc52338SCy Schubert { "properties", "a{sv}", ARG_OUT },
43044bc52338SCy Schubert END_ARGS
43054bc52338SCy Schubert }
43064bc52338SCy Schubert },
43074bc52338SCy Schubert { "StationRemoved", WPAS_DBUS_NEW_IFACE_INTERFACE,
43084bc52338SCy Schubert {
43094bc52338SCy Schubert { "path", "o", ARG_OUT },
43104bc52338SCy Schubert END_ARGS
43114bc52338SCy Schubert }
43124bc52338SCy Schubert },
43135b9c547cSRui Paulo { "NetworkRequest", WPAS_DBUS_NEW_IFACE_INTERFACE,
43145b9c547cSRui Paulo {
43155b9c547cSRui Paulo { "path", "o", ARG_OUT },
43165b9c547cSRui Paulo { "field", "s", ARG_OUT },
43175b9c547cSRui Paulo { "text", "s", ARG_OUT },
43185b9c547cSRui Paulo END_ARGS
43195b9c547cSRui Paulo }
43205b9c547cSRui Paulo },
432185732ac8SCy Schubert #ifdef CONFIG_MESH
432285732ac8SCy Schubert { "MeshGroupStarted", WPAS_DBUS_NEW_IFACE_MESH,
432385732ac8SCy Schubert {
432485732ac8SCy Schubert { "args", "a{sv}", ARG_OUT },
432585732ac8SCy Schubert END_ARGS
432685732ac8SCy Schubert }
432785732ac8SCy Schubert },
432885732ac8SCy Schubert { "MeshGroupRemoved", WPAS_DBUS_NEW_IFACE_MESH,
432985732ac8SCy Schubert {
433085732ac8SCy Schubert { "args", "a{sv}", ARG_OUT },
433185732ac8SCy Schubert END_ARGS
433285732ac8SCy Schubert }
433385732ac8SCy Schubert },
433485732ac8SCy Schubert { "MeshPeerConnected", WPAS_DBUS_NEW_IFACE_MESH,
433585732ac8SCy Schubert {
433685732ac8SCy Schubert { "args", "a{sv}", ARG_OUT },
433785732ac8SCy Schubert END_ARGS
433885732ac8SCy Schubert }
433985732ac8SCy Schubert },
434085732ac8SCy Schubert { "MeshPeerDisconnected", WPAS_DBUS_NEW_IFACE_MESH,
434185732ac8SCy Schubert {
434285732ac8SCy Schubert { "args", "a{sv}", ARG_OUT },
434385732ac8SCy Schubert END_ARGS
434485732ac8SCy Schubert }
434585732ac8SCy Schubert },
434685732ac8SCy Schubert #endif /* CONFIG_MESH */
434732a95656SCy Schubert #ifdef CONFIG_INTERWORKING
434832a95656SCy Schubert { "InterworkingAPAdded", WPAS_DBUS_NEW_IFACE_INTERFACE,
434932a95656SCy Schubert {
435032a95656SCy Schubert { "bss", "o", ARG_OUT },
435132a95656SCy Schubert { "cred", "o", ARG_OUT },
435232a95656SCy Schubert { "properties", "a{sv}", ARG_OUT },
435332a95656SCy Schubert END_ARGS
435432a95656SCy Schubert }
435532a95656SCy Schubert },
435632a95656SCy Schubert { "InterworkingSelectDone", WPAS_DBUS_NEW_IFACE_INTERFACE,
435732a95656SCy Schubert {
435832a95656SCy Schubert END_ARGS
435932a95656SCy Schubert }
436032a95656SCy Schubert },
4361*a90b9d01SCy Schubert {"ANQPQueryDone", WPAS_DBUS_NEW_IFACE_INTERFACE,
4362*a90b9d01SCy Schubert {
4363*a90b9d01SCy Schubert { "addr", "s", ARG_OUT },
4364*a90b9d01SCy Schubert { "result", "s", ARG_OUT },
4365*a90b9d01SCy Schubert END_ARGS
4366*a90b9d01SCy Schubert }
4367*a90b9d01SCy Schubert },
436832a95656SCy Schubert #endif /* CONFIG_INTERWORKING */
4369*a90b9d01SCy Schubert #ifdef CONFIG_HS20
4370*a90b9d01SCy Schubert { "HS20TermsAndConditions", WPAS_DBUS_NEW_IFACE_INTERFACE,
4371*a90b9d01SCy Schubert {
4372*a90b9d01SCy Schubert { "url", "s", ARG_OUT },
4373*a90b9d01SCy Schubert END_ARGS
4374*a90b9d01SCy Schubert }
4375*a90b9d01SCy Schubert },
4376*a90b9d01SCy Schubert #endif /* CONFIG_HS20 */
4377d4f2939cSRui Paulo { NULL, NULL, { END_ARGS } }
4378d4f2939cSRui Paulo };
4379d4f2939cSRui Paulo
4380d4f2939cSRui Paulo
wpa_dbus_ctrl_iface_props_init(struct wpas_dbus_priv * priv)4381780fb4a2SCy Schubert static int wpa_dbus_ctrl_iface_props_init(struct wpas_dbus_priv *priv)
4382780fb4a2SCy Schubert {
4383780fb4a2SCy Schubert size_t all_size;
4384780fb4a2SCy Schubert unsigned int i, j, count, num_const, num_globals;
4385780fb4a2SCy Schubert const char *global_name;
4386780fb4a2SCy Schubert static const char * const ignored_globals[] = {
4387780fb4a2SCy Schubert "bss_expiration_age", "bss_expiration_scan_count",
4388780fb4a2SCy Schubert "ap_scan", "country", "fast_reauth",
4389780fb4a2SCy Schubert "pkcs11_engine_path", "pkcs11_module_path"
4390780fb4a2SCy Schubert };
4391780fb4a2SCy Schubert
4392780fb4a2SCy Schubert /* wpas_dbus_interface_properties terminates with a NULL element */
4393780fb4a2SCy Schubert num_const = ARRAY_SIZE(wpas_dbus_interface_properties) - 1;
4394780fb4a2SCy Schubert
4395780fb4a2SCy Schubert num_globals = wpa_config_get_num_global_field_names();
4396780fb4a2SCy Schubert priv->globals_start = num_const;
4397780fb4a2SCy Schubert
4398780fb4a2SCy Schubert /* allocate enough for all properties + terminating NULL element */
4399780fb4a2SCy Schubert all_size = (num_globals + num_const + 1) *
4400780fb4a2SCy Schubert sizeof(wpas_dbus_interface_properties[0]);
4401780fb4a2SCy Schubert priv->all_interface_properties = os_zalloc(all_size);
4402780fb4a2SCy Schubert if (!priv->all_interface_properties) {
4403780fb4a2SCy Schubert wpa_printf(MSG_ERROR,
4404780fb4a2SCy Schubert "dbus: Not enough memory for interface properties");
4405780fb4a2SCy Schubert return -1;
4406780fb4a2SCy Schubert }
4407780fb4a2SCy Schubert
4408780fb4a2SCy Schubert /* Copy constant interface properties to the start of the array */
4409780fb4a2SCy Schubert os_memcpy(priv->all_interface_properties,
4410780fb4a2SCy Schubert wpas_dbus_interface_properties,
4411780fb4a2SCy Schubert sizeof(wpas_dbus_interface_properties));
4412780fb4a2SCy Schubert
4413780fb4a2SCy Schubert /* Dynamically construct interface global properties */
4414780fb4a2SCy Schubert for (i = 0, count = num_const; i < num_globals; i++) {
4415780fb4a2SCy Schubert struct wpa_dbus_property_desc *desc;
4416780fb4a2SCy Schubert int no_var = 0;
4417780fb4a2SCy Schubert
4418780fb4a2SCy Schubert /* ignore globals that are actually just methods */
4419780fb4a2SCy Schubert global_name = wpa_config_get_global_field_name(i, &no_var);
4420780fb4a2SCy Schubert if (no_var)
4421780fb4a2SCy Schubert continue;
4422780fb4a2SCy Schubert /* Ignore fields already explicitly exposed */
4423780fb4a2SCy Schubert for (j = 0; j < ARRAY_SIZE(ignored_globals); j++) {
4424780fb4a2SCy Schubert if (os_strcmp(global_name, ignored_globals[j]) == 0)
4425780fb4a2SCy Schubert break;
4426780fb4a2SCy Schubert }
4427780fb4a2SCy Schubert if (j < ARRAY_SIZE(ignored_globals))
4428780fb4a2SCy Schubert continue;
4429780fb4a2SCy Schubert
4430780fb4a2SCy Schubert desc = &priv->all_interface_properties[count++];
4431780fb4a2SCy Schubert desc->dbus_property = uscore_to_dbus(global_name);
4432780fb4a2SCy Schubert if (!desc->dbus_property) {
4433780fb4a2SCy Schubert wpa_printf(MSG_ERROR,
4434780fb4a2SCy Schubert "dbus: Not enough memory for D-Bus property name");
4435780fb4a2SCy Schubert goto error;
4436780fb4a2SCy Schubert }
4437780fb4a2SCy Schubert desc->dbus_interface = WPAS_DBUS_NEW_IFACE_INTERFACE;
4438780fb4a2SCy Schubert desc->type = "s";
4439780fb4a2SCy Schubert desc->getter = wpas_dbus_getter_iface_global;
4440780fb4a2SCy Schubert desc->setter = wpas_dbus_setter_iface_global;
4441780fb4a2SCy Schubert desc->data = global_name;
4442780fb4a2SCy Schubert }
4443780fb4a2SCy Schubert
4444780fb4a2SCy Schubert return 0;
4445780fb4a2SCy Schubert
4446780fb4a2SCy Schubert error:
4447780fb4a2SCy Schubert wpa_dbus_ctrl_iface_props_deinit(priv);
4448780fb4a2SCy Schubert return -1;
4449780fb4a2SCy Schubert }
4450780fb4a2SCy Schubert
4451780fb4a2SCy Schubert
4452325151a3SRui Paulo /**
4453325151a3SRui Paulo * wpas_dbus_register_interface - Register an interface with D-Bus
4454325151a3SRui Paulo * @wpa_s: wpa_supplicant interface structure
4455325151a3SRui Paulo * Returns: 0 on success, -1 on failure
4456325151a3SRui Paulo */
wpas_dbus_register_interface(struct wpa_supplicant * wpa_s)4457d4f2939cSRui Paulo int wpas_dbus_register_interface(struct wpa_supplicant *wpa_s)
4458d4f2939cSRui Paulo {
4459d4f2939cSRui Paulo struct wpa_dbus_object_desc *obj_desc = NULL;
4460d4f2939cSRui Paulo struct wpas_dbus_priv *ctrl_iface = wpa_s->global->dbus;
4461d4f2939cSRui Paulo int next;
4462d4f2939cSRui Paulo
4463d4f2939cSRui Paulo /* Do nothing if the control interface is not turned on */
4464d4f2939cSRui Paulo if (ctrl_iface == NULL)
4465d4f2939cSRui Paulo return 0;
4466d4f2939cSRui Paulo
4467d4f2939cSRui Paulo /* Create and set the interface's object path */
4468d4f2939cSRui Paulo wpa_s->dbus_new_path = os_zalloc(WPAS_DBUS_OBJECT_PATH_MAX);
4469d4f2939cSRui Paulo if (wpa_s->dbus_new_path == NULL)
4470d4f2939cSRui Paulo return -1;
4471d4f2939cSRui Paulo next = ctrl_iface->next_objid++;
4472d4f2939cSRui Paulo os_snprintf(wpa_s->dbus_new_path, WPAS_DBUS_OBJECT_PATH_MAX,
4473d4f2939cSRui Paulo WPAS_DBUS_NEW_PATH_INTERFACES "/%u",
4474d4f2939cSRui Paulo next);
4475d4f2939cSRui Paulo
4476d4f2939cSRui Paulo obj_desc = os_zalloc(sizeof(struct wpa_dbus_object_desc));
4477d4f2939cSRui Paulo if (!obj_desc) {
44785b9c547cSRui Paulo wpa_printf(MSG_ERROR,
44795b9c547cSRui Paulo "Not enough memory to create object description");
4480d4f2939cSRui Paulo goto err;
4481d4f2939cSRui Paulo }
4482d4f2939cSRui Paulo
4483d4f2939cSRui Paulo wpas_dbus_register(obj_desc, wpa_s, NULL, wpas_dbus_interface_methods,
4484780fb4a2SCy Schubert ctrl_iface->all_interface_properties,
4485d4f2939cSRui Paulo wpas_dbus_interface_signals);
4486d4f2939cSRui Paulo
4487d4f2939cSRui Paulo wpa_printf(MSG_DEBUG, "dbus: Register interface object '%s'",
4488d4f2939cSRui Paulo wpa_s->dbus_new_path);
4489d4f2939cSRui Paulo if (wpa_dbus_register_object_per_iface(ctrl_iface,
4490d4f2939cSRui Paulo wpa_s->dbus_new_path,
4491d4f2939cSRui Paulo wpa_s->ifname, obj_desc))
4492d4f2939cSRui Paulo goto err;
4493d4f2939cSRui Paulo
4494d4f2939cSRui Paulo wpas_dbus_signal_interface_added(wpa_s);
4495d4f2939cSRui Paulo
4496d4f2939cSRui Paulo return 0;
4497d4f2939cSRui Paulo
4498d4f2939cSRui Paulo err:
4499d4f2939cSRui Paulo os_free(wpa_s->dbus_new_path);
4500d4f2939cSRui Paulo wpa_s->dbus_new_path = NULL;
4501d4f2939cSRui Paulo free_dbus_object_desc(obj_desc);
4502d4f2939cSRui Paulo return -1;
4503d4f2939cSRui Paulo }
4504d4f2939cSRui Paulo
4505d4f2939cSRui Paulo
4506325151a3SRui Paulo /**
4507325151a3SRui Paulo * wpas_dbus_unregister_interface - Unregister the interface from D-Bus
4508325151a3SRui Paulo * @wpa_s: wpa_supplicant interface structure
4509325151a3SRui Paulo * Returns: 0 on success, -1 on failure
4510325151a3SRui Paulo */
wpas_dbus_unregister_interface(struct wpa_supplicant * wpa_s)4511d4f2939cSRui Paulo int wpas_dbus_unregister_interface(struct wpa_supplicant *wpa_s)
4512d4f2939cSRui Paulo {
4513d4f2939cSRui Paulo struct wpas_dbus_priv *ctrl_iface;
4514d4f2939cSRui Paulo
4515d4f2939cSRui Paulo /* Do nothing if the control interface is not turned on */
4516d4f2939cSRui Paulo if (wpa_s == NULL || wpa_s->global == NULL)
4517d4f2939cSRui Paulo return 0;
4518d4f2939cSRui Paulo ctrl_iface = wpa_s->global->dbus;
45195b9c547cSRui Paulo if (ctrl_iface == NULL || wpa_s->dbus_new_path == NULL)
4520d4f2939cSRui Paulo return 0;
4521d4f2939cSRui Paulo
4522d4f2939cSRui Paulo wpa_printf(MSG_DEBUG, "dbus: Unregister interface object '%s'",
4523d4f2939cSRui Paulo wpa_s->dbus_new_path);
4524d4f2939cSRui Paulo
4525d4f2939cSRui Paulo #ifdef CONFIG_AP
4526d4f2939cSRui Paulo if (wpa_s->preq_notify_peer) {
4527d4f2939cSRui Paulo wpas_dbus_unsubscribe_noc(ctrl_iface);
4528d4f2939cSRui Paulo os_free(wpa_s->preq_notify_peer);
4529d4f2939cSRui Paulo wpa_s->preq_notify_peer = NULL;
4530d4f2939cSRui Paulo }
4531d4f2939cSRui Paulo #endif /* CONFIG_AP */
4532d4f2939cSRui Paulo
4533d4f2939cSRui Paulo if (wpa_dbus_unregister_object_per_iface(ctrl_iface,
4534d4f2939cSRui Paulo wpa_s->dbus_new_path))
4535d4f2939cSRui Paulo return -1;
4536d4f2939cSRui Paulo
4537d4f2939cSRui Paulo wpas_dbus_signal_interface_removed(wpa_s);
4538d4f2939cSRui Paulo
4539d4f2939cSRui Paulo os_free(wpa_s->dbus_new_path);
4540d4f2939cSRui Paulo wpa_s->dbus_new_path = NULL;
4541d4f2939cSRui Paulo
4542d4f2939cSRui Paulo return 0;
4543d4f2939cSRui Paulo }
4544d4f2939cSRui Paulo
4545d4f2939cSRui Paulo #ifdef CONFIG_P2P
4546d4f2939cSRui Paulo
4547d4f2939cSRui Paulo static const struct wpa_dbus_property_desc wpas_dbus_p2p_peer_properties[] = {
4548d4f2939cSRui Paulo { "DeviceName", WPAS_DBUS_NEW_IFACE_P2P_PEER, "s",
4549d4f2939cSRui Paulo wpas_dbus_getter_p2p_peer_device_name,
4550780fb4a2SCy Schubert NULL,
4551d4f2939cSRui Paulo NULL
4552d4f2939cSRui Paulo },
4553325151a3SRui Paulo { "Manufacturer", WPAS_DBUS_NEW_IFACE_P2P_PEER, "s",
4554325151a3SRui Paulo wpas_dbus_getter_p2p_peer_manufacturer,
4555780fb4a2SCy Schubert NULL,
4556325151a3SRui Paulo NULL
4557325151a3SRui Paulo },
4558325151a3SRui Paulo { "ModelName", WPAS_DBUS_NEW_IFACE_P2P_PEER, "s",
4559325151a3SRui Paulo wpas_dbus_getter_p2p_peer_modelname,
4560780fb4a2SCy Schubert NULL,
4561325151a3SRui Paulo NULL
4562325151a3SRui Paulo },
4563325151a3SRui Paulo { "ModelNumber", WPAS_DBUS_NEW_IFACE_P2P_PEER, "s",
4564325151a3SRui Paulo wpas_dbus_getter_p2p_peer_modelnumber,
4565780fb4a2SCy Schubert NULL,
4566325151a3SRui Paulo NULL
4567325151a3SRui Paulo },
4568325151a3SRui Paulo { "SerialNumber", WPAS_DBUS_NEW_IFACE_P2P_PEER, "s",
4569325151a3SRui Paulo wpas_dbus_getter_p2p_peer_serialnumber,
4570780fb4a2SCy Schubert NULL,
4571325151a3SRui Paulo NULL
4572325151a3SRui Paulo },
4573d4f2939cSRui Paulo { "PrimaryDeviceType", WPAS_DBUS_NEW_IFACE_P2P_PEER, "ay",
4574d4f2939cSRui Paulo wpas_dbus_getter_p2p_peer_primary_device_type,
4575780fb4a2SCy Schubert NULL,
4576d4f2939cSRui Paulo NULL
4577d4f2939cSRui Paulo },
4578d4f2939cSRui Paulo { "config_method", WPAS_DBUS_NEW_IFACE_P2P_PEER, "q",
4579d4f2939cSRui Paulo wpas_dbus_getter_p2p_peer_config_method,
4580780fb4a2SCy Schubert NULL,
4581d4f2939cSRui Paulo NULL
4582d4f2939cSRui Paulo },
4583d4f2939cSRui Paulo { "level", WPAS_DBUS_NEW_IFACE_P2P_PEER, "i",
4584d4f2939cSRui Paulo wpas_dbus_getter_p2p_peer_level,
4585780fb4a2SCy Schubert NULL,
4586d4f2939cSRui Paulo NULL
4587d4f2939cSRui Paulo },
4588d4f2939cSRui Paulo { "devicecapability", WPAS_DBUS_NEW_IFACE_P2P_PEER, "y",
4589d4f2939cSRui Paulo wpas_dbus_getter_p2p_peer_device_capability,
4590780fb4a2SCy Schubert NULL,
4591d4f2939cSRui Paulo NULL
4592d4f2939cSRui Paulo },
4593d4f2939cSRui Paulo { "groupcapability", WPAS_DBUS_NEW_IFACE_P2P_PEER, "y",
4594d4f2939cSRui Paulo wpas_dbus_getter_p2p_peer_group_capability,
4595780fb4a2SCy Schubert NULL,
4596d4f2939cSRui Paulo NULL
4597d4f2939cSRui Paulo },
4598d4f2939cSRui Paulo { "SecondaryDeviceTypes", WPAS_DBUS_NEW_IFACE_P2P_PEER, "aay",
4599d4f2939cSRui Paulo wpas_dbus_getter_p2p_peer_secondary_device_types,
4600780fb4a2SCy Schubert NULL,
4601d4f2939cSRui Paulo NULL
4602d4f2939cSRui Paulo },
4603d4f2939cSRui Paulo { "VendorExtension", WPAS_DBUS_NEW_IFACE_P2P_PEER, "aay",
4604d4f2939cSRui Paulo wpas_dbus_getter_p2p_peer_vendor_extension,
4605780fb4a2SCy Schubert NULL,
4606d4f2939cSRui Paulo NULL
4607d4f2939cSRui Paulo },
4608d4f2939cSRui Paulo { "IEs", WPAS_DBUS_NEW_IFACE_P2P_PEER, "ay",
4609d4f2939cSRui Paulo wpas_dbus_getter_p2p_peer_ies,
4610780fb4a2SCy Schubert NULL,
4611d4f2939cSRui Paulo NULL
4612d4f2939cSRui Paulo },
46135b9c547cSRui Paulo { "DeviceAddress", WPAS_DBUS_NEW_IFACE_P2P_PEER, "ay",
46145b9c547cSRui Paulo wpas_dbus_getter_p2p_peer_device_address,
4615780fb4a2SCy Schubert NULL,
46165b9c547cSRui Paulo NULL
46175b9c547cSRui Paulo },
46185b9c547cSRui Paulo { "Groups", WPAS_DBUS_NEW_IFACE_P2P_PEER, "ao",
46195b9c547cSRui Paulo wpas_dbus_getter_p2p_peer_groups,
4620780fb4a2SCy Schubert NULL,
46215b9c547cSRui Paulo NULL
46225b9c547cSRui Paulo },
46234bc52338SCy Schubert { "VSIE", WPAS_DBUS_NEW_IFACE_P2P_PEER, "ay",
46244bc52338SCy Schubert wpas_dbus_getter_p2p_peer_vsie,
46254bc52338SCy Schubert NULL,
46264bc52338SCy Schubert NULL
46274bc52338SCy Schubert },
4628780fb4a2SCy Schubert { NULL, NULL, NULL, NULL, NULL, NULL }
4629d4f2939cSRui Paulo };
4630d4f2939cSRui Paulo
4631d4f2939cSRui Paulo static const struct wpa_dbus_signal_desc wpas_dbus_p2p_peer_signals[] = {
46325b9c547cSRui Paulo /* Deprecated: use org.freedesktop.DBus.Properties.PropertiesChanged */
46335b9c547cSRui Paulo { "PropertiesChanged", WPAS_DBUS_NEW_IFACE_P2P_PEER,
46345b9c547cSRui Paulo {
46355b9c547cSRui Paulo { "properties", "a{sv}", ARG_OUT },
46365b9c547cSRui Paulo END_ARGS
46375b9c547cSRui Paulo }
46385b9c547cSRui Paulo },
4639d4f2939cSRui Paulo { NULL, NULL, { END_ARGS } }
4640d4f2939cSRui Paulo };
4641d4f2939cSRui Paulo
4642d4f2939cSRui Paulo /**
4643d4f2939cSRui Paulo * wpas_dbus_signal_peer - Send a peer related event signal
4644d4f2939cSRui Paulo * @wpa_s: %wpa_supplicant network interface data
4645d4f2939cSRui Paulo * @dev: peer device object
4646d4f2939cSRui Paulo * @interface: name of the interface emitting this signal.
4647d4f2939cSRui Paulo * In case of peer objects, it would be emitted by either
4648d4f2939cSRui Paulo * the "interface object" or by "peer objects"
4649d4f2939cSRui Paulo * @sig_name: signal name - DeviceFound
4650780fb4a2SCy Schubert * @properties: Whether to add a second argument with object properties
4651d4f2939cSRui Paulo *
4652780fb4a2SCy Schubert * Notify listeners about event related with p2p peer device
4653d4f2939cSRui Paulo */
wpas_dbus_signal_peer(struct wpa_supplicant * wpa_s,const u8 * dev_addr,const char * interface,const char * sig_name,dbus_bool_t properties)4654d4f2939cSRui Paulo static void wpas_dbus_signal_peer(struct wpa_supplicant *wpa_s,
4655d4f2939cSRui Paulo const u8 *dev_addr, const char *interface,
46564bc52338SCy Schubert const char *sig_name, dbus_bool_t properties)
4657d4f2939cSRui Paulo {
4658d4f2939cSRui Paulo struct wpas_dbus_priv *iface;
4659d4f2939cSRui Paulo DBusMessage *msg;
4660d4f2939cSRui Paulo DBusMessageIter iter;
4661d4f2939cSRui Paulo char peer_obj_path[WPAS_DBUS_OBJECT_PATH_MAX], *path;
4662d4f2939cSRui Paulo
46635b9c547cSRui Paulo if (wpa_s->p2p_mgmt)
46645b9c547cSRui Paulo wpa_s = wpa_s->parent;
46655b9c547cSRui Paulo
4666d4f2939cSRui Paulo iface = wpa_s->global->dbus;
4667d4f2939cSRui Paulo
4668d4f2939cSRui Paulo /* Do nothing if the control interface is not turned on */
4669325151a3SRui Paulo if (iface == NULL || !wpa_s->dbus_new_path)
4670d4f2939cSRui Paulo return;
4671d4f2939cSRui Paulo
4672d4f2939cSRui Paulo os_snprintf(peer_obj_path, WPAS_DBUS_OBJECT_PATH_MAX,
4673d4f2939cSRui Paulo "%s/" WPAS_DBUS_NEW_P2P_PEERS_PART "/" COMPACT_MACSTR,
4674d4f2939cSRui Paulo wpa_s->dbus_new_path, MAC2STR(dev_addr));
4675d4f2939cSRui Paulo
4676d4f2939cSRui Paulo msg = dbus_message_new_signal(wpa_s->dbus_new_path, interface,
4677d4f2939cSRui Paulo sig_name);
4678d4f2939cSRui Paulo if (msg == NULL)
4679d4f2939cSRui Paulo return;
4680d4f2939cSRui Paulo
4681d4f2939cSRui Paulo dbus_message_iter_init_append(msg, &iter);
4682d4f2939cSRui Paulo path = peer_obj_path;
4683d4f2939cSRui Paulo if (!dbus_message_iter_append_basic(&iter, DBUS_TYPE_OBJECT_PATH,
4684780fb4a2SCy Schubert &path) ||
4685780fb4a2SCy Schubert (properties && !wpa_dbus_get_object_properties(
4686780fb4a2SCy Schubert iface, peer_obj_path, WPAS_DBUS_NEW_IFACE_P2P_PEER,
4687780fb4a2SCy Schubert &iter)))
46885b9c547cSRui Paulo wpa_printf(MSG_ERROR, "dbus: Failed to construct signal");
46895b9c547cSRui Paulo else
4690d4f2939cSRui Paulo dbus_connection_send(iface->con, msg, NULL);
4691d4f2939cSRui Paulo
4692d4f2939cSRui Paulo dbus_message_unref(msg);
4693d4f2939cSRui Paulo }
4694d4f2939cSRui Paulo
4695d4f2939cSRui Paulo
4696d4f2939cSRui Paulo /**
4697d4f2939cSRui Paulo * wpas_dbus_signal_peer_found - Send a peer found signal
4698d4f2939cSRui Paulo * @wpa_s: %wpa_supplicant network interface data
4699325151a3SRui Paulo * @dev_addr: Peer P2P Device Address
4700d4f2939cSRui Paulo *
4701d4f2939cSRui Paulo * Notify listeners about find a p2p peer device found
4702d4f2939cSRui Paulo */
wpas_dbus_signal_peer_device_found(struct wpa_supplicant * wpa_s,const u8 * dev_addr)4703d4f2939cSRui Paulo void wpas_dbus_signal_peer_device_found(struct wpa_supplicant *wpa_s,
4704d4f2939cSRui Paulo const u8 *dev_addr)
4705d4f2939cSRui Paulo {
4706d4f2939cSRui Paulo wpas_dbus_signal_peer(wpa_s, dev_addr,
4707d4f2939cSRui Paulo WPAS_DBUS_NEW_IFACE_P2PDEVICE,
4708780fb4a2SCy Schubert "DeviceFound", FALSE);
4709780fb4a2SCy Schubert
4710780fb4a2SCy Schubert wpas_dbus_signal_peer(wpa_s, dev_addr,
4711780fb4a2SCy Schubert WPAS_DBUS_NEW_IFACE_P2PDEVICE,
4712780fb4a2SCy Schubert "DeviceFoundProperties", TRUE);
4713d4f2939cSRui Paulo }
4714d4f2939cSRui Paulo
4715d4f2939cSRui Paulo /**
4716d4f2939cSRui Paulo * wpas_dbus_signal_peer_lost - Send a peer lost signal
4717d4f2939cSRui Paulo * @wpa_s: %wpa_supplicant network interface data
4718325151a3SRui Paulo * @dev_addr: Peer P2P Device Address
4719d4f2939cSRui Paulo *
4720d4f2939cSRui Paulo * Notify listeners about lost a p2p peer device
4721d4f2939cSRui Paulo */
wpas_dbus_signal_peer_device_lost(struct wpa_supplicant * wpa_s,const u8 * dev_addr)4722d4f2939cSRui Paulo void wpas_dbus_signal_peer_device_lost(struct wpa_supplicant *wpa_s,
4723d4f2939cSRui Paulo const u8 *dev_addr)
4724d4f2939cSRui Paulo {
4725d4f2939cSRui Paulo wpas_dbus_signal_peer(wpa_s, dev_addr,
4726d4f2939cSRui Paulo WPAS_DBUS_NEW_IFACE_P2PDEVICE,
4727780fb4a2SCy Schubert "DeviceLost", FALSE);
4728d4f2939cSRui Paulo }
4729d4f2939cSRui Paulo
4730d4f2939cSRui Paulo /**
4731d4f2939cSRui Paulo * wpas_dbus_register_peer - Register a discovered peer object with dbus
4732d4f2939cSRui Paulo * @wpa_s: wpa_supplicant interface structure
4733325151a3SRui Paulo * @dev_addr: P2P Device Address of the peer
4734d4f2939cSRui Paulo * Returns: 0 on success, -1 on failure
4735d4f2939cSRui Paulo *
4736d4f2939cSRui Paulo * Registers network representing object with dbus
4737d4f2939cSRui Paulo */
wpas_dbus_register_peer(struct wpa_supplicant * wpa_s,const u8 * dev_addr)4738d4f2939cSRui Paulo int wpas_dbus_register_peer(struct wpa_supplicant *wpa_s, const u8 *dev_addr)
4739d4f2939cSRui Paulo {
4740d4f2939cSRui Paulo struct wpas_dbus_priv *ctrl_iface;
4741d4f2939cSRui Paulo struct wpa_dbus_object_desc *obj_desc;
4742d4f2939cSRui Paulo struct peer_handler_args *arg;
4743d4f2939cSRui Paulo char peer_obj_path[WPAS_DBUS_OBJECT_PATH_MAX];
4744d4f2939cSRui Paulo
4745d4f2939cSRui Paulo /* Do nothing if the control interface is not turned on */
4746d4f2939cSRui Paulo if (wpa_s == NULL || wpa_s->global == NULL)
4747d4f2939cSRui Paulo return 0;
4748d4f2939cSRui Paulo
4749d4f2939cSRui Paulo ctrl_iface = wpa_s->global->dbus;
4750d4f2939cSRui Paulo if (ctrl_iface == NULL)
4751d4f2939cSRui Paulo return 0;
4752d4f2939cSRui Paulo
4753325151a3SRui Paulo wpa_s = wpa_s->parent->parent;
4754325151a3SRui Paulo if (!wpa_s->dbus_new_path)
4755325151a3SRui Paulo return 0;
47565b9c547cSRui Paulo
4757d4f2939cSRui Paulo os_snprintf(peer_obj_path, WPAS_DBUS_OBJECT_PATH_MAX,
4758d4f2939cSRui Paulo "%s/" WPAS_DBUS_NEW_P2P_PEERS_PART "/" COMPACT_MACSTR,
4759d4f2939cSRui Paulo wpa_s->dbus_new_path, MAC2STR(dev_addr));
4760d4f2939cSRui Paulo
4761d4f2939cSRui Paulo wpa_printf(MSG_INFO, "dbus: Register peer object '%s'",
4762d4f2939cSRui Paulo peer_obj_path);
4763d4f2939cSRui Paulo obj_desc = os_zalloc(sizeof(struct wpa_dbus_object_desc));
4764d4f2939cSRui Paulo if (!obj_desc) {
47655b9c547cSRui Paulo wpa_printf(MSG_ERROR,
47665b9c547cSRui Paulo "Not enough memory to create object description");
4767d4f2939cSRui Paulo goto err;
4768d4f2939cSRui Paulo }
4769d4f2939cSRui Paulo
4770d4f2939cSRui Paulo /* allocate memory for handlers arguments */
4771d4f2939cSRui Paulo arg = os_zalloc(sizeof(struct peer_handler_args));
4772d4f2939cSRui Paulo if (!arg) {
47735b9c547cSRui Paulo wpa_printf(MSG_ERROR,
47745b9c547cSRui Paulo "Not enough memory to create arguments for method");
4775d4f2939cSRui Paulo goto err;
4776d4f2939cSRui Paulo }
4777d4f2939cSRui Paulo
4778d4f2939cSRui Paulo arg->wpa_s = wpa_s;
4779d4f2939cSRui Paulo os_memcpy(arg->p2p_device_addr, dev_addr, ETH_ALEN);
4780d4f2939cSRui Paulo
4781d4f2939cSRui Paulo wpas_dbus_register(obj_desc, arg, wpa_dbus_free,
4782d4f2939cSRui Paulo NULL,
4783d4f2939cSRui Paulo wpas_dbus_p2p_peer_properties,
4784d4f2939cSRui Paulo wpas_dbus_p2p_peer_signals);
4785d4f2939cSRui Paulo
4786d4f2939cSRui Paulo if (wpa_dbus_register_object_per_iface(ctrl_iface, peer_obj_path,
4787d4f2939cSRui Paulo wpa_s->ifname, obj_desc))
4788d4f2939cSRui Paulo goto err;
4789d4f2939cSRui Paulo
4790d4f2939cSRui Paulo return 0;
4791d4f2939cSRui Paulo
4792d4f2939cSRui Paulo err:
4793d4f2939cSRui Paulo free_dbus_object_desc(obj_desc);
4794d4f2939cSRui Paulo return -1;
4795d4f2939cSRui Paulo }
4796d4f2939cSRui Paulo
4797d4f2939cSRui Paulo /**
4798d4f2939cSRui Paulo * wpas_dbus_unregister_peer - Unregister a peer object with dbus
4799d4f2939cSRui Paulo * @wpa_s: wpa_supplicant interface structure
4800d4f2939cSRui Paulo * @dev_addr: p2p device addr
4801d4f2939cSRui Paulo * Returns: 0 on success, -1 on failure
4802d4f2939cSRui Paulo *
4803d4f2939cSRui Paulo * Registers network representing object with dbus
4804d4f2939cSRui Paulo */
wpas_dbus_unregister_peer(struct wpa_supplicant * wpa_s,const u8 * dev_addr)4805d4f2939cSRui Paulo int wpas_dbus_unregister_peer(struct wpa_supplicant *wpa_s,
4806d4f2939cSRui Paulo const u8 *dev_addr)
4807d4f2939cSRui Paulo {
4808d4f2939cSRui Paulo struct wpas_dbus_priv *ctrl_iface;
4809d4f2939cSRui Paulo char peer_obj_path[WPAS_DBUS_OBJECT_PATH_MAX];
4810d4f2939cSRui Paulo int ret;
4811d4f2939cSRui Paulo
4812d4f2939cSRui Paulo /* Do nothing if the control interface is not turned on */
4813325151a3SRui Paulo if (wpa_s == NULL || wpa_s->global == NULL)
4814d4f2939cSRui Paulo return 0;
48155b9c547cSRui Paulo
4816325151a3SRui Paulo wpa_s = wpa_s->parent->parent;
4817325151a3SRui Paulo if (!wpa_s->dbus_new_path)
4818325151a3SRui Paulo return 0;
48195b9c547cSRui Paulo
4820d4f2939cSRui Paulo ctrl_iface = wpa_s->global->dbus;
4821d4f2939cSRui Paulo if (ctrl_iface == NULL)
4822d4f2939cSRui Paulo return 0;
4823d4f2939cSRui Paulo
4824d4f2939cSRui Paulo os_snprintf(peer_obj_path, WPAS_DBUS_OBJECT_PATH_MAX,
4825d4f2939cSRui Paulo "%s/" WPAS_DBUS_NEW_P2P_PEERS_PART "/" COMPACT_MACSTR,
4826d4f2939cSRui Paulo wpa_s->dbus_new_path, MAC2STR(dev_addr));
4827d4f2939cSRui Paulo
4828d4f2939cSRui Paulo wpa_printf(MSG_INFO, "dbus: Unregister peer object '%s'",
4829d4f2939cSRui Paulo peer_obj_path);
4830d4f2939cSRui Paulo ret = wpa_dbus_unregister_object_per_iface(ctrl_iface, peer_obj_path);
4831d4f2939cSRui Paulo
4832d4f2939cSRui Paulo return ret;
4833d4f2939cSRui Paulo }
4834d4f2939cSRui Paulo
4835d4f2939cSRui Paulo
4836325151a3SRui Paulo /**
4837325151a3SRui Paulo * wpas_dbus_signal_p2p_find_stopped - Send P2P Find stopped signal
4838325151a3SRui Paulo * @wpa_s: %wpa_supplicant network interface data
4839325151a3SRui Paulo *
4840325151a3SRui Paulo * Notify listeners about P2P Find stopped
4841325151a3SRui Paulo */
wpas_dbus_signal_p2p_find_stopped(struct wpa_supplicant * wpa_s)4842325151a3SRui Paulo void wpas_dbus_signal_p2p_find_stopped(struct wpa_supplicant *wpa_s)
4843325151a3SRui Paulo {
4844325151a3SRui Paulo struct wpas_dbus_priv *iface;
4845325151a3SRui Paulo DBusMessage *msg;
4846325151a3SRui Paulo
4847325151a3SRui Paulo iface = wpa_s->global->dbus;
4848325151a3SRui Paulo
4849325151a3SRui Paulo /* Do nothing if the control interface is not turned on */
485085732ac8SCy Schubert if (iface == NULL)
485185732ac8SCy Schubert return;
485285732ac8SCy Schubert
485385732ac8SCy Schubert if (wpa_s->p2p_mgmt)
485485732ac8SCy Schubert wpa_s = wpa_s->parent;
485585732ac8SCy Schubert
485685732ac8SCy Schubert if (!wpa_s->dbus_new_path)
4857325151a3SRui Paulo return;
4858325151a3SRui Paulo
4859325151a3SRui Paulo msg = dbus_message_new_signal(wpa_s->dbus_new_path,
4860325151a3SRui Paulo WPAS_DBUS_NEW_IFACE_P2PDEVICE,
4861325151a3SRui Paulo "FindStopped");
4862325151a3SRui Paulo if (msg == NULL)
4863325151a3SRui Paulo return;
4864325151a3SRui Paulo
4865325151a3SRui Paulo dbus_connection_send(iface->con, msg, NULL);
4866325151a3SRui Paulo
4867325151a3SRui Paulo dbus_message_unref(msg);
4868325151a3SRui Paulo }
4869325151a3SRui Paulo
4870325151a3SRui Paulo
4871325151a3SRui Paulo /**
4872325151a3SRui Paulo * wpas_dbus_signal_peer_groups_changed - Send peer group change property signal
4873325151a3SRui Paulo * @wpa_s: %wpa_supplicant network interface data
4874325151a3SRui Paulo * @dev_addr: P2P Device Address
4875325151a3SRui Paulo *
4876325151a3SRui Paulo * Notify listeners about peer Groups property changes.
4877325151a3SRui Paulo */
wpas_dbus_signal_peer_groups_changed(struct wpa_supplicant * wpa_s,const u8 * dev_addr)48785b9c547cSRui Paulo void wpas_dbus_signal_peer_groups_changed(struct wpa_supplicant *wpa_s,
48795b9c547cSRui Paulo const u8 *dev_addr)
48805b9c547cSRui Paulo {
48815b9c547cSRui Paulo char peer_obj_path[WPAS_DBUS_OBJECT_PATH_MAX];
48825b9c547cSRui Paulo
48835b9c547cSRui Paulo if (wpa_s->p2p_mgmt)
48845b9c547cSRui Paulo wpa_s = wpa_s->parent;
48855b9c547cSRui Paulo
4886325151a3SRui Paulo if (!wpa_s->dbus_new_path)
4887325151a3SRui Paulo return;
48885b9c547cSRui Paulo os_snprintf(peer_obj_path, WPAS_DBUS_OBJECT_PATH_MAX,
48895b9c547cSRui Paulo "%s/" WPAS_DBUS_NEW_P2P_PEERS_PART "/" COMPACT_MACSTR,
48905b9c547cSRui Paulo wpa_s->dbus_new_path, MAC2STR(dev_addr));
48915b9c547cSRui Paulo
48925b9c547cSRui Paulo wpa_dbus_mark_property_changed(wpa_s->global->dbus, peer_obj_path,
48935b9c547cSRui Paulo WPAS_DBUS_NEW_IFACE_P2P_PEER, "Groups");
48945b9c547cSRui Paulo }
48955b9c547cSRui Paulo
48965b9c547cSRui Paulo
4897d4f2939cSRui Paulo static const struct wpa_dbus_property_desc wpas_dbus_p2p_group_properties[] = {
4898d4f2939cSRui Paulo { "Members", WPAS_DBUS_NEW_IFACE_P2P_GROUP, "ao",
4899d4f2939cSRui Paulo wpas_dbus_getter_p2p_group_members,
4900780fb4a2SCy Schubert NULL,
4901d4f2939cSRui Paulo NULL
4902d4f2939cSRui Paulo },
4903d4f2939cSRui Paulo { "Group", WPAS_DBUS_NEW_IFACE_P2P_GROUP, "o",
4904d4f2939cSRui Paulo wpas_dbus_getter_p2p_group,
4905780fb4a2SCy Schubert NULL,
4906d4f2939cSRui Paulo NULL
4907d4f2939cSRui Paulo },
4908d4f2939cSRui Paulo { "Role", WPAS_DBUS_NEW_IFACE_P2P_GROUP, "s",
4909d4f2939cSRui Paulo wpas_dbus_getter_p2p_role,
4910780fb4a2SCy Schubert NULL,
4911d4f2939cSRui Paulo NULL
4912d4f2939cSRui Paulo },
4913d4f2939cSRui Paulo { "SSID", WPAS_DBUS_NEW_IFACE_P2P_GROUP, "ay",
4914d4f2939cSRui Paulo wpas_dbus_getter_p2p_group_ssid,
4915780fb4a2SCy Schubert NULL,
4916d4f2939cSRui Paulo NULL
4917d4f2939cSRui Paulo },
4918d4f2939cSRui Paulo { "BSSID", WPAS_DBUS_NEW_IFACE_P2P_GROUP, "ay",
4919d4f2939cSRui Paulo wpas_dbus_getter_p2p_group_bssid,
4920780fb4a2SCy Schubert NULL,
4921d4f2939cSRui Paulo NULL
4922d4f2939cSRui Paulo },
4923d4f2939cSRui Paulo { "Frequency", WPAS_DBUS_NEW_IFACE_P2P_GROUP, "q",
4924d4f2939cSRui Paulo wpas_dbus_getter_p2p_group_frequency,
4925780fb4a2SCy Schubert NULL,
4926d4f2939cSRui Paulo NULL
4927d4f2939cSRui Paulo },
4928d4f2939cSRui Paulo { "Passphrase", WPAS_DBUS_NEW_IFACE_P2P_GROUP, "s",
4929d4f2939cSRui Paulo wpas_dbus_getter_p2p_group_passphrase,
4930780fb4a2SCy Schubert NULL,
4931d4f2939cSRui Paulo NULL
4932d4f2939cSRui Paulo },
4933d4f2939cSRui Paulo { "PSK", WPAS_DBUS_NEW_IFACE_P2P_GROUP, "ay",
4934d4f2939cSRui Paulo wpas_dbus_getter_p2p_group_psk,
4935780fb4a2SCy Schubert NULL,
4936d4f2939cSRui Paulo NULL
4937d4f2939cSRui Paulo },
4938d4f2939cSRui Paulo { "WPSVendorExtensions", WPAS_DBUS_NEW_IFACE_P2P_GROUP, "aay",
4939d4f2939cSRui Paulo wpas_dbus_getter_p2p_group_vendor_ext,
4940780fb4a2SCy Schubert wpas_dbus_setter_p2p_group_vendor_ext,
4941780fb4a2SCy Schubert NULL
4942d4f2939cSRui Paulo },
4943780fb4a2SCy Schubert { NULL, NULL, NULL, NULL, NULL, NULL }
4944d4f2939cSRui Paulo };
4945d4f2939cSRui Paulo
4946d4f2939cSRui Paulo static const struct wpa_dbus_signal_desc wpas_dbus_p2p_group_signals[] = {
4947d4f2939cSRui Paulo { "PeerJoined", WPAS_DBUS_NEW_IFACE_P2P_GROUP,
4948d4f2939cSRui Paulo {
4949d4f2939cSRui Paulo { "peer", "o", ARG_OUT },
4950d4f2939cSRui Paulo END_ARGS
4951d4f2939cSRui Paulo }
4952d4f2939cSRui Paulo },
4953d4f2939cSRui Paulo { "PeerDisconnected", WPAS_DBUS_NEW_IFACE_P2P_GROUP,
4954d4f2939cSRui Paulo {
4955d4f2939cSRui Paulo { "peer", "o", ARG_OUT },
4956d4f2939cSRui Paulo END_ARGS
4957d4f2939cSRui Paulo }
4958d4f2939cSRui Paulo },
4959d4f2939cSRui Paulo { NULL, NULL, { END_ARGS } }
4960d4f2939cSRui Paulo };
4961d4f2939cSRui Paulo
4962d4f2939cSRui Paulo /**
4963d4f2939cSRui Paulo * wpas_dbus_register_p2p_group - Register a p2p group object with dbus
4964d4f2939cSRui Paulo * @wpa_s: wpa_supplicant interface structure
4965d4f2939cSRui Paulo * @ssid: SSID struct
4966d4f2939cSRui Paulo * Returns: 0 on success, -1 on failure
4967d4f2939cSRui Paulo *
4968d4f2939cSRui Paulo * Registers p2p group representing object with dbus
4969d4f2939cSRui Paulo */
wpas_dbus_register_p2p_group(struct wpa_supplicant * wpa_s,struct wpa_ssid * ssid)4970d4f2939cSRui Paulo void wpas_dbus_register_p2p_group(struct wpa_supplicant *wpa_s,
4971d4f2939cSRui Paulo struct wpa_ssid *ssid)
4972d4f2939cSRui Paulo {
4973d4f2939cSRui Paulo struct wpas_dbus_priv *ctrl_iface;
4974d4f2939cSRui Paulo struct wpa_dbus_object_desc *obj_desc;
4975d4f2939cSRui Paulo char group_obj_path[WPAS_DBUS_OBJECT_PATH_MAX];
4976d4f2939cSRui Paulo
4977d4f2939cSRui Paulo /* Do nothing if the control interface is not turned on */
4978d4f2939cSRui Paulo if (wpa_s == NULL || wpa_s->global == NULL)
4979d4f2939cSRui Paulo return;
4980d4f2939cSRui Paulo
4981d4f2939cSRui Paulo ctrl_iface = wpa_s->global->dbus;
4982d4f2939cSRui Paulo if (ctrl_iface == NULL)
4983d4f2939cSRui Paulo return;
4984d4f2939cSRui Paulo
4985d4f2939cSRui Paulo if (wpa_s->dbus_groupobj_path) {
4986d4f2939cSRui Paulo wpa_printf(MSG_INFO, "%s: Group object '%s' already exists",
4987d4f2939cSRui Paulo __func__, wpa_s->dbus_groupobj_path);
4988d4f2939cSRui Paulo return;
4989d4f2939cSRui Paulo }
4990d4f2939cSRui Paulo
4991d4f2939cSRui Paulo if (wpas_dbus_get_group_obj_path(wpa_s, ssid, group_obj_path) < 0)
4992d4f2939cSRui Paulo return;
4993d4f2939cSRui Paulo
4994d4f2939cSRui Paulo wpa_s->dbus_groupobj_path = os_strdup(group_obj_path);
4995d4f2939cSRui Paulo if (wpa_s->dbus_groupobj_path == NULL)
4996d4f2939cSRui Paulo return;
4997d4f2939cSRui Paulo
4998d4f2939cSRui Paulo wpa_printf(MSG_INFO, "dbus: Register group object '%s'",
4999d4f2939cSRui Paulo group_obj_path);
5000d4f2939cSRui Paulo obj_desc = os_zalloc(sizeof(struct wpa_dbus_object_desc));
5001d4f2939cSRui Paulo if (!obj_desc) {
50025b9c547cSRui Paulo wpa_printf(MSG_ERROR,
50035b9c547cSRui Paulo "Not enough memory to create object description");
5004d4f2939cSRui Paulo goto err;
5005d4f2939cSRui Paulo }
5006d4f2939cSRui Paulo
5007d4f2939cSRui Paulo wpas_dbus_register(obj_desc, wpa_s, NULL, NULL,
5008d4f2939cSRui Paulo wpas_dbus_p2p_group_properties,
5009d4f2939cSRui Paulo wpas_dbus_p2p_group_signals);
5010d4f2939cSRui Paulo
5011d4f2939cSRui Paulo if (wpa_dbus_register_object_per_iface(ctrl_iface, group_obj_path,
5012d4f2939cSRui Paulo wpa_s->ifname, obj_desc))
5013d4f2939cSRui Paulo goto err;
5014d4f2939cSRui Paulo
5015d4f2939cSRui Paulo return;
5016d4f2939cSRui Paulo
5017d4f2939cSRui Paulo err:
5018d4f2939cSRui Paulo if (wpa_s->dbus_groupobj_path) {
5019d4f2939cSRui Paulo os_free(wpa_s->dbus_groupobj_path);
5020d4f2939cSRui Paulo wpa_s->dbus_groupobj_path = NULL;
5021d4f2939cSRui Paulo }
5022d4f2939cSRui Paulo
5023d4f2939cSRui Paulo free_dbus_object_desc(obj_desc);
5024d4f2939cSRui Paulo }
5025d4f2939cSRui Paulo
5026d4f2939cSRui Paulo /**
5027d4f2939cSRui Paulo * wpas_dbus_unregister_p2p_group - Unregister a p2p group object from dbus
5028d4f2939cSRui Paulo * @wpa_s: wpa_supplicant interface structure
5029d4f2939cSRui Paulo * @ssid: network name of the p2p group started
5030d4f2939cSRui Paulo */
wpas_dbus_unregister_p2p_group(struct wpa_supplicant * wpa_s,const struct wpa_ssid * ssid)5031d4f2939cSRui Paulo void wpas_dbus_unregister_p2p_group(struct wpa_supplicant *wpa_s,
5032d4f2939cSRui Paulo const struct wpa_ssid *ssid)
5033d4f2939cSRui Paulo {
5034d4f2939cSRui Paulo struct wpas_dbus_priv *ctrl_iface;
5035d4f2939cSRui Paulo
5036d4f2939cSRui Paulo /* Do nothing if the control interface is not turned on */
5037d4f2939cSRui Paulo if (wpa_s == NULL || wpa_s->global == NULL)
5038d4f2939cSRui Paulo return;
5039d4f2939cSRui Paulo
50405b9c547cSRui Paulo if (wpa_s->p2p_mgmt)
50415b9c547cSRui Paulo wpa_s = wpa_s->parent;
50425b9c547cSRui Paulo
5043d4f2939cSRui Paulo ctrl_iface = wpa_s->global->dbus;
5044d4f2939cSRui Paulo if (ctrl_iface == NULL)
5045d4f2939cSRui Paulo return;
5046d4f2939cSRui Paulo
5047d4f2939cSRui Paulo if (!wpa_s->dbus_groupobj_path) {
5048d4f2939cSRui Paulo wpa_printf(MSG_DEBUG,
5049c1d255d3SCy Schubert "%s: Group object has already unregistered",
5050c1d255d3SCy Schubert __func__);
5051d4f2939cSRui Paulo return;
5052d4f2939cSRui Paulo }
5053d4f2939cSRui Paulo
50545b9c547cSRui Paulo peer_groups_changed(wpa_s);
50555b9c547cSRui Paulo
5056d4f2939cSRui Paulo wpa_printf(MSG_DEBUG, "dbus: Unregister group object '%s'",
5057d4f2939cSRui Paulo wpa_s->dbus_groupobj_path);
5058d4f2939cSRui Paulo
5059d4f2939cSRui Paulo wpa_dbus_unregister_object_per_iface(ctrl_iface,
5060d4f2939cSRui Paulo wpa_s->dbus_groupobj_path);
5061d4f2939cSRui Paulo
5062d4f2939cSRui Paulo os_free(wpa_s->dbus_groupobj_path);
5063d4f2939cSRui Paulo wpa_s->dbus_groupobj_path = NULL;
5064d4f2939cSRui Paulo }
5065d4f2939cSRui Paulo
5066d4f2939cSRui Paulo static const struct wpa_dbus_property_desc
5067d4f2939cSRui Paulo wpas_dbus_persistent_group_properties[] = {
5068d4f2939cSRui Paulo { "Properties", WPAS_DBUS_NEW_IFACE_PERSISTENT_GROUP, "a{sv}",
5069d4f2939cSRui Paulo wpas_dbus_getter_persistent_group_properties,
5070780fb4a2SCy Schubert wpas_dbus_setter_persistent_group_properties,
5071780fb4a2SCy Schubert NULL
5072d4f2939cSRui Paulo },
5073780fb4a2SCy Schubert { NULL, NULL, NULL, NULL, NULL, NULL }
5074d4f2939cSRui Paulo };
5075d4f2939cSRui Paulo
5076d4f2939cSRui Paulo /* No signals intended for persistent group objects */
5077d4f2939cSRui Paulo
5078d4f2939cSRui Paulo /**
5079d4f2939cSRui Paulo * wpas_dbus_register_persistent_group - Register a configured(saved)
5080d4f2939cSRui Paulo * persistent group with dbus
5081d4f2939cSRui Paulo * @wpa_s: wpa_supplicant interface structure
5082d4f2939cSRui Paulo * @ssid: persistent group (still represented as a network within wpa)
5083d4f2939cSRui Paulo * configuration data
5084d4f2939cSRui Paulo * Returns: 0 on success, -1 on failure
5085d4f2939cSRui Paulo *
5086d4f2939cSRui Paulo * Registers a persistent group representing object with dbus.
5087d4f2939cSRui Paulo */
wpas_dbus_register_persistent_group(struct wpa_supplicant * wpa_s,struct wpa_ssid * ssid)5088d4f2939cSRui Paulo int wpas_dbus_register_persistent_group(struct wpa_supplicant *wpa_s,
5089d4f2939cSRui Paulo struct wpa_ssid *ssid)
5090d4f2939cSRui Paulo {
5091d4f2939cSRui Paulo struct wpas_dbus_priv *ctrl_iface;
5092d4f2939cSRui Paulo struct wpa_dbus_object_desc *obj_desc;
5093d4f2939cSRui Paulo struct network_handler_args *arg;
5094d4f2939cSRui Paulo char pgrp_obj_path[WPAS_DBUS_OBJECT_PATH_MAX];
5095d4f2939cSRui Paulo
5096d4f2939cSRui Paulo /* Do nothing if the control interface is not turned on */
5097d4f2939cSRui Paulo if (wpa_s == NULL || wpa_s->global == NULL)
5098d4f2939cSRui Paulo return 0;
5099325151a3SRui Paulo wpa_s = wpa_s->parent->parent;
5100325151a3SRui Paulo if (!wpa_s->dbus_new_path)
5101325151a3SRui Paulo return 0;
5102d4f2939cSRui Paulo
5103d4f2939cSRui Paulo /* Make sure ssid is a persistent group */
5104d4f2939cSRui Paulo if (ssid->disabled != 2 && !ssid->p2p_persistent_group)
5105d4f2939cSRui Paulo return -1; /* should we return w/o complaining? */
5106d4f2939cSRui Paulo
51075b9c547cSRui Paulo if (wpa_s->p2p_mgmt)
51085b9c547cSRui Paulo wpa_s = wpa_s->parent;
51095b9c547cSRui Paulo
5110d4f2939cSRui Paulo ctrl_iface = wpa_s->global->dbus;
5111d4f2939cSRui Paulo if (ctrl_iface == NULL)
5112d4f2939cSRui Paulo return 0;
5113d4f2939cSRui Paulo
5114d4f2939cSRui Paulo /*
5115d4f2939cSRui Paulo * Intentionally not coming up with different numbering scheme
5116d4f2939cSRui Paulo * for persistent groups.
5117d4f2939cSRui Paulo */
5118d4f2939cSRui Paulo os_snprintf(pgrp_obj_path, WPAS_DBUS_OBJECT_PATH_MAX,
5119d4f2939cSRui Paulo "%s/" WPAS_DBUS_NEW_PERSISTENT_GROUPS_PART "/%u",
5120d4f2939cSRui Paulo wpa_s->dbus_new_path, ssid->id);
5121d4f2939cSRui Paulo
5122d4f2939cSRui Paulo wpa_printf(MSG_DEBUG, "dbus: Register persistent group object '%s'",
5123d4f2939cSRui Paulo pgrp_obj_path);
5124d4f2939cSRui Paulo obj_desc = os_zalloc(sizeof(struct wpa_dbus_object_desc));
5125d4f2939cSRui Paulo if (!obj_desc) {
51265b9c547cSRui Paulo wpa_printf(MSG_ERROR,
51275b9c547cSRui Paulo "dbus: Not enough memory to create object description");
5128d4f2939cSRui Paulo goto err;
5129d4f2939cSRui Paulo }
5130d4f2939cSRui Paulo
5131d4f2939cSRui Paulo /*
5132d4f2939cSRui Paulo * Reusing the same context structure as that for networks
5133d4f2939cSRui Paulo * since these are represented using same data structure.
5134d4f2939cSRui Paulo */
5135d4f2939cSRui Paulo /* allocate memory for handlers arguments */
5136d4f2939cSRui Paulo arg = os_zalloc(sizeof(struct network_handler_args));
5137d4f2939cSRui Paulo if (!arg) {
51385b9c547cSRui Paulo wpa_printf(MSG_ERROR,
51395b9c547cSRui Paulo "dbus: Not enough memory to create arguments for method");
5140d4f2939cSRui Paulo goto err;
5141d4f2939cSRui Paulo }
5142d4f2939cSRui Paulo
5143d4f2939cSRui Paulo arg->wpa_s = wpa_s;
5144d4f2939cSRui Paulo arg->ssid = ssid;
5145d4f2939cSRui Paulo
5146d4f2939cSRui Paulo wpas_dbus_register(obj_desc, arg, wpa_dbus_free, NULL,
5147d4f2939cSRui Paulo wpas_dbus_persistent_group_properties,
5148d4f2939cSRui Paulo NULL);
5149d4f2939cSRui Paulo
5150d4f2939cSRui Paulo if (wpa_dbus_register_object_per_iface(ctrl_iface, pgrp_obj_path,
5151d4f2939cSRui Paulo wpa_s->ifname, obj_desc))
5152d4f2939cSRui Paulo goto err;
5153d4f2939cSRui Paulo
5154d4f2939cSRui Paulo wpas_dbus_signal_persistent_group_added(wpa_s, ssid->id);
5155d4f2939cSRui Paulo
5156d4f2939cSRui Paulo return 0;
5157d4f2939cSRui Paulo
5158d4f2939cSRui Paulo err:
5159d4f2939cSRui Paulo free_dbus_object_desc(obj_desc);
5160d4f2939cSRui Paulo return -1;
5161d4f2939cSRui Paulo }
5162d4f2939cSRui Paulo
5163d4f2939cSRui Paulo
5164d4f2939cSRui Paulo /**
5165d4f2939cSRui Paulo * wpas_dbus_unregister_persistent_group - Unregister a persistent_group
5166d4f2939cSRui Paulo * from dbus
5167d4f2939cSRui Paulo * @wpa_s: wpa_supplicant interface structure
5168d4f2939cSRui Paulo * @nid: network id
5169d4f2939cSRui Paulo * Returns: 0 on success, -1 on failure
5170d4f2939cSRui Paulo *
5171d4f2939cSRui Paulo * Unregisters persistent group representing object from dbus
5172d4f2939cSRui Paulo *
5173d4f2939cSRui Paulo * NOTE: There is a slight issue with the semantics here. While the
5174d4f2939cSRui Paulo * implementation simply means the persistent group is unloaded from memory,
5175d4f2939cSRui Paulo * it should not get interpreted as the group is actually being erased/removed
5176d4f2939cSRui Paulo * from persistent storage as well.
5177d4f2939cSRui Paulo */
wpas_dbus_unregister_persistent_group(struct wpa_supplicant * wpa_s,int nid)5178d4f2939cSRui Paulo int wpas_dbus_unregister_persistent_group(struct wpa_supplicant *wpa_s,
5179d4f2939cSRui Paulo int nid)
5180d4f2939cSRui Paulo {
5181d4f2939cSRui Paulo struct wpas_dbus_priv *ctrl_iface;
5182d4f2939cSRui Paulo char pgrp_obj_path[WPAS_DBUS_OBJECT_PATH_MAX];
5183d4f2939cSRui Paulo int ret;
5184d4f2939cSRui Paulo
5185d4f2939cSRui Paulo /* Do nothing if the control interface is not turned on */
5186325151a3SRui Paulo if (wpa_s == NULL || wpa_s->global == NULL)
5187d4f2939cSRui Paulo return 0;
51885b9c547cSRui Paulo
5189325151a3SRui Paulo wpa_s = wpa_s->parent->parent;
51905b9c547cSRui Paulo
5191d4f2939cSRui Paulo ctrl_iface = wpa_s->global->dbus;
5192325151a3SRui Paulo if (ctrl_iface == NULL || !wpa_s->dbus_new_path)
5193d4f2939cSRui Paulo return 0;
5194d4f2939cSRui Paulo
5195d4f2939cSRui Paulo os_snprintf(pgrp_obj_path, WPAS_DBUS_OBJECT_PATH_MAX,
5196d4f2939cSRui Paulo "%s/" WPAS_DBUS_NEW_PERSISTENT_GROUPS_PART "/%u",
5197d4f2939cSRui Paulo wpa_s->dbus_new_path, nid);
5198d4f2939cSRui Paulo
5199d4f2939cSRui Paulo wpa_printf(MSG_DEBUG, "dbus: Unregister persistent group object '%s'",
5200d4f2939cSRui Paulo pgrp_obj_path);
5201d4f2939cSRui Paulo ret = wpa_dbus_unregister_object_per_iface(ctrl_iface, pgrp_obj_path);
5202d4f2939cSRui Paulo
5203d4f2939cSRui Paulo if (!ret)
5204d4f2939cSRui Paulo wpas_dbus_signal_persistent_group_removed(wpa_s, nid);
5205d4f2939cSRui Paulo
5206d4f2939cSRui Paulo return ret;
5207d4f2939cSRui Paulo }
5208d4f2939cSRui Paulo
5209d4f2939cSRui Paulo #endif /* CONFIG_P2P */
5210*a90b9d01SCy Schubert
5211*a90b9d01SCy Schubert
5212*a90b9d01SCy Schubert #ifdef CONFIG_HS20
5213*a90b9d01SCy Schubert /**
5214*a90b9d01SCy Schubert * wpas_dbus_signal_hs20_t_c_acceptance - Signals a terms and conditions was
5215*a90b9d01SCy Schubert * received.
5216*a90b9d01SCy Schubert *
5217*a90b9d01SCy Schubert * @wpa_s: %wpa_supplicant network interface data
5218*a90b9d01SCy Schubert * @url: URL of the terms and conditions acceptance page.
5219*a90b9d01SCy Schubert */
wpas_dbus_signal_hs20_t_c_acceptance(struct wpa_supplicant * wpa_s,const char * url)5220*a90b9d01SCy Schubert void wpas_dbus_signal_hs20_t_c_acceptance(struct wpa_supplicant *wpa_s,
5221*a90b9d01SCy Schubert const char *url)
5222*a90b9d01SCy Schubert {
5223*a90b9d01SCy Schubert struct wpas_dbus_priv *iface;
5224*a90b9d01SCy Schubert DBusMessage *msg;
5225*a90b9d01SCy Schubert
5226*a90b9d01SCy Schubert iface = wpa_s->global->dbus;
5227*a90b9d01SCy Schubert
5228*a90b9d01SCy Schubert /* Do nothing if the control interface is not turned on */
5229*a90b9d01SCy Schubert if (!iface || !wpa_s->dbus_new_path)
5230*a90b9d01SCy Schubert return;
5231*a90b9d01SCy Schubert
5232*a90b9d01SCy Schubert msg = dbus_message_new_signal(wpa_s->dbus_new_path,
5233*a90b9d01SCy Schubert WPAS_DBUS_NEW_IFACE_INTERFACE,
5234*a90b9d01SCy Schubert "HS20TermsAndConditions");
5235*a90b9d01SCy Schubert if (!msg)
5236*a90b9d01SCy Schubert return;
5237*a90b9d01SCy Schubert
5238*a90b9d01SCy Schubert if (dbus_message_append_args(msg, DBUS_TYPE_STRING, &url,
5239*a90b9d01SCy Schubert DBUS_TYPE_INVALID))
5240*a90b9d01SCy Schubert dbus_connection_send(iface->con, msg, NULL);
5241*a90b9d01SCy Schubert else
5242*a90b9d01SCy Schubert wpa_printf(MSG_ERROR, "dbus: Failed to construct signal");
5243*a90b9d01SCy Schubert dbus_message_unref(msg);
5244*a90b9d01SCy Schubert }
5245*a90b9d01SCy Schubert #endif /* CONFIG_HS20 */
5246