2 * WPA Supplicant / dbus-based control interface
3 * Copyright (c) 2006, Dan Williams <dcbw@redhat.com> and Red Hat, Inc.
4 * Copyright (c) 2009-2010, Witold Sowa <witold.sowa@gmail.com>
5 * Copyright (c) 2009, Jouni Malinen <j@w1.fi>
7 * This software may be distributed under the terms of the BSD license.
8 * See README for more details.
14 #include "common/ieee802_11_defs.h"
16 #include "../config.h"
17 #include "../wpa_supplicant_i.h"
19 #include "../wpas_glue.h"
20 #include "dbus_new_helpers.h"
21 #include "dbus_dict_helpers.h"
23 #include "dbus_new_handlers.h"
24 #include "dbus_common_i.h"
25 #include "dbus_new_handlers_p2p.h"
27 #include "../p2p_supplicant.h"
29 #ifdef CONFIG_AP /* until needed by something else */
32 * NameOwnerChanged handling
34 * Some services we provide allow an application to register for
35 * a signal that it needs. While it can also unregister, we must
36 * be prepared for the case where the application simply crashes
37 * and thus doesn't clean up properly. The way to handle this in
38 * DBus is to register for the NameOwnerChanged signal which will
39 * signal an owner change to NULL if the peer closes the socket
40 * for whatever reason.
42 * Handle this signal via a filter function whenever necessary.
43 * The code below also handles refcounting in case in the future
44 * there will be multiple instances of this subscription scheme.
46 static const char wpas_dbus_noc_filter_str[] =
47 "interface=org.freedesktop.DBus,member=NameOwnerChanged";
50 static DBusHandlerResult noc_filter(DBusConnection *conn,
51 DBusMessage *message, void *data)
53 struct wpas_dbus_priv *priv = data;
55 if (dbus_message_get_type(message) != DBUS_MESSAGE_TYPE_SIGNAL)
56 return DBUS_HANDLER_RESULT_NOT_YET_HANDLED;
58 if (dbus_message_is_signal(message, DBUS_INTERFACE_DBUS,
59 "NameOwnerChanged")) {
61 const char *prev_owner;
62 const char *new_owner;
64 struct wpa_supplicant *wpa_s;
66 dbus_error_init(&derr);
68 if (!dbus_message_get_args(message, &derr,
69 DBUS_TYPE_STRING, &name,
70 DBUS_TYPE_STRING, &prev_owner,
71 DBUS_TYPE_STRING, &new_owner,
73 /* Ignore this error */
74 dbus_error_free(&derr);
75 return DBUS_HANDLER_RESULT_NOT_YET_HANDLED;
78 for (wpa_s = priv->global->ifaces; wpa_s; wpa_s = wpa_s->next) {
79 if (wpa_s->preq_notify_peer != NULL &&
80 os_strcmp(name, wpa_s->preq_notify_peer) == 0 &&
81 (new_owner == NULL || os_strlen(new_owner) == 0)) {
82 /* probe request owner disconnected */
83 os_free(wpa_s->preq_notify_peer);
84 wpa_s->preq_notify_peer = NULL;
85 wpas_dbus_unsubscribe_noc(priv);
90 return DBUS_HANDLER_RESULT_NOT_YET_HANDLED;
94 void wpas_dbus_subscribe_noc(struct wpas_dbus_priv *priv)
96 priv->dbus_noc_refcnt++;
97 if (priv->dbus_noc_refcnt > 1)
100 if (!dbus_connection_add_filter(priv->con, noc_filter, priv, NULL)) {
101 wpa_printf(MSG_ERROR, "dbus: failed to add filter");
105 dbus_bus_add_match(priv->con, wpas_dbus_noc_filter_str, NULL);
109 void wpas_dbus_unsubscribe_noc(struct wpas_dbus_priv *priv)
111 priv->dbus_noc_refcnt--;
112 if (priv->dbus_noc_refcnt > 0)
115 dbus_bus_remove_match(priv->con, wpas_dbus_noc_filter_str, NULL);
116 dbus_connection_remove_filter(priv->con, noc_filter, priv);
119 #endif /* CONFIG_AP */
123 * wpas_dbus_signal_interface - Send a interface related event signal
124 * @wpa_s: %wpa_supplicant network interface data
125 * @sig_name: signal name - InterfaceAdded or InterfaceRemoved
126 * @properties: Whether to add second argument with object properties
128 * Notify listeners about event related with interface
130 static void wpas_dbus_signal_interface(struct wpa_supplicant *wpa_s,
131 const char *sig_name, int properties)
133 struct wpas_dbus_priv *iface;
135 DBusMessageIter iter;
137 iface = wpa_s->global->dbus;
139 /* Do nothing if the control interface is not turned on */
143 msg = dbus_message_new_signal(WPAS_DBUS_NEW_PATH,
144 WPAS_DBUS_NEW_INTERFACE, sig_name);
148 dbus_message_iter_init_append(msg, &iter);
149 if (!dbus_message_iter_append_basic(&iter, DBUS_TYPE_OBJECT_PATH,
150 &wpa_s->dbus_new_path) ||
152 !wpa_dbus_get_object_properties(
153 iface, wpa_s->dbus_new_path,
154 WPAS_DBUS_NEW_IFACE_INTERFACE, &iter)))
155 wpa_printf(MSG_ERROR, "dbus: Failed to construct signal");
157 dbus_connection_send(iface->con, msg, NULL);
158 dbus_message_unref(msg);
163 * wpas_dbus_signal_interface_added - Send a interface created signal
164 * @wpa_s: %wpa_supplicant network interface data
166 * Notify listeners about creating new interface
168 static void wpas_dbus_signal_interface_added(struct wpa_supplicant *wpa_s)
170 wpas_dbus_signal_interface(wpa_s, "InterfaceAdded", TRUE);
175 * wpas_dbus_signal_interface_removed - Send a interface removed signal
176 * @wpa_s: %wpa_supplicant network interface data
178 * Notify listeners about removing interface
180 static void wpas_dbus_signal_interface_removed(struct wpa_supplicant *wpa_s)
182 wpas_dbus_signal_interface(wpa_s, "InterfaceRemoved", FALSE);
188 * wpas_dbus_signal_scan_done - send scan done signal
189 * @wpa_s: %wpa_supplicant network interface data
190 * @success: indicates if scanning succeed or failed
192 * Notify listeners about finishing a scan
194 void wpas_dbus_signal_scan_done(struct wpa_supplicant *wpa_s, int success)
196 struct wpas_dbus_priv *iface;
200 iface = wpa_s->global->dbus;
202 /* Do nothing if the control interface is not turned on */
206 msg = dbus_message_new_signal(wpa_s->dbus_new_path,
207 WPAS_DBUS_NEW_IFACE_INTERFACE,
212 succ = success ? TRUE : FALSE;
213 if (dbus_message_append_args(msg, DBUS_TYPE_BOOLEAN, &succ,
215 dbus_connection_send(iface->con, msg, NULL);
217 wpa_printf(MSG_ERROR, "dbus: Failed to construct signal");
218 dbus_message_unref(msg);
223 * wpas_dbus_signal_bss - Send a BSS related event signal
224 * @wpa_s: %wpa_supplicant network interface data
225 * @bss_obj_path: BSS object path
226 * @sig_name: signal name - BSSAdded or BSSRemoved
227 * @properties: Whether to add second argument with object properties
229 * Notify listeners about event related with BSS
231 static void wpas_dbus_signal_bss(struct wpa_supplicant *wpa_s,
232 const char *bss_obj_path,
233 const char *sig_name, int properties)
235 struct wpas_dbus_priv *iface;
237 DBusMessageIter iter;
239 iface = wpa_s->global->dbus;
241 /* Do nothing if the control interface is not turned on */
245 msg = dbus_message_new_signal(wpa_s->dbus_new_path,
246 WPAS_DBUS_NEW_IFACE_INTERFACE,
251 dbus_message_iter_init_append(msg, &iter);
252 if (!dbus_message_iter_append_basic(&iter, DBUS_TYPE_OBJECT_PATH,
255 !wpa_dbus_get_object_properties(iface, bss_obj_path,
256 WPAS_DBUS_NEW_IFACE_BSS,
258 wpa_printf(MSG_ERROR, "dbus: Failed to construct signal");
260 dbus_connection_send(iface->con, msg, NULL);
261 dbus_message_unref(msg);
266 * wpas_dbus_signal_bss_added - Send a BSS added signal
267 * @wpa_s: %wpa_supplicant network interface data
268 * @bss_obj_path: new BSS object path
270 * Notify listeners about adding new BSS
272 static void wpas_dbus_signal_bss_added(struct wpa_supplicant *wpa_s,
273 const char *bss_obj_path)
275 wpas_dbus_signal_bss(wpa_s, bss_obj_path, "BSSAdded", TRUE);
280 * wpas_dbus_signal_bss_removed - Send a BSS removed signal
281 * @wpa_s: %wpa_supplicant network interface data
282 * @bss_obj_path: BSS object path
284 * Notify listeners about removing BSS
286 static void wpas_dbus_signal_bss_removed(struct wpa_supplicant *wpa_s,
287 const char *bss_obj_path)
289 wpas_dbus_signal_bss(wpa_s, bss_obj_path, "BSSRemoved", FALSE);
294 * wpas_dbus_signal_blob - Send a blob related event signal
295 * @wpa_s: %wpa_supplicant network interface data
297 * @sig_name: signal name - BlobAdded or BlobRemoved
299 * Notify listeners about event related with blob
301 static void wpas_dbus_signal_blob(struct wpa_supplicant *wpa_s,
302 const char *name, const char *sig_name)
304 struct wpas_dbus_priv *iface;
307 iface = wpa_s->global->dbus;
309 /* Do nothing if the control interface is not turned on */
313 msg = dbus_message_new_signal(wpa_s->dbus_new_path,
314 WPAS_DBUS_NEW_IFACE_INTERFACE,
319 if (dbus_message_append_args(msg, DBUS_TYPE_STRING, &name,
321 dbus_connection_send(iface->con, msg, NULL);
323 wpa_printf(MSG_ERROR, "dbus: Failed to construct signal");
324 dbus_message_unref(msg);
329 * wpas_dbus_signal_blob_added - Send a blob added signal
330 * @wpa_s: %wpa_supplicant network interface data
333 * Notify listeners about adding a new blob
335 void wpas_dbus_signal_blob_added(struct wpa_supplicant *wpa_s,
338 wpas_dbus_signal_blob(wpa_s, name, "BlobAdded");
343 * wpas_dbus_signal_blob_removed - Send a blob removed signal
344 * @wpa_s: %wpa_supplicant network interface data
347 * Notify listeners about removing blob
349 void wpas_dbus_signal_blob_removed(struct wpa_supplicant *wpa_s,
352 wpas_dbus_signal_blob(wpa_s, name, "BlobRemoved");
357 * wpas_dbus_signal_network - Send a network related event signal
358 * @wpa_s: %wpa_supplicant network interface data
359 * @id: new network id
360 * @sig_name: signal name - NetworkAdded, NetworkRemoved or NetworkSelected
361 * @properties: determines if add second argument with object properties
363 * Notify listeners about event related with configured network
365 static void wpas_dbus_signal_network(struct wpa_supplicant *wpa_s,
366 int id, const char *sig_name,
369 struct wpas_dbus_priv *iface;
371 DBusMessageIter iter;
372 char net_obj_path[WPAS_DBUS_OBJECT_PATH_MAX], *path;
374 iface = wpa_s->global->dbus;
376 /* Do nothing if the control interface is not turned on */
380 os_snprintf(net_obj_path, WPAS_DBUS_OBJECT_PATH_MAX,
381 "%s/" WPAS_DBUS_NEW_NETWORKS_PART "/%u",
382 wpa_s->dbus_new_path, id);
384 msg = dbus_message_new_signal(wpa_s->dbus_new_path,
385 WPAS_DBUS_NEW_IFACE_INTERFACE,
390 dbus_message_iter_init_append(msg, &iter);
392 if (!dbus_message_iter_append_basic(&iter, DBUS_TYPE_OBJECT_PATH,
395 !wpa_dbus_get_object_properties(
396 iface, net_obj_path, WPAS_DBUS_NEW_IFACE_NETWORK,
398 wpa_printf(MSG_ERROR, "dbus: Failed to construct signal");
400 dbus_connection_send(iface->con, msg, NULL);
401 dbus_message_unref(msg);
406 * wpas_dbus_signal_network_added - Send a network added signal
407 * @wpa_s: %wpa_supplicant network interface data
408 * @id: new network id
410 * Notify listeners about adding new network
412 static void wpas_dbus_signal_network_added(struct wpa_supplicant *wpa_s,
415 wpas_dbus_signal_network(wpa_s, id, "NetworkAdded", TRUE);
420 * wpas_dbus_signal_network_removed - Send a network removed signal
421 * @wpa_s: %wpa_supplicant network interface data
424 * Notify listeners about removing a network
426 static void wpas_dbus_signal_network_removed(struct wpa_supplicant *wpa_s,
429 wpas_dbus_signal_network(wpa_s, id, "NetworkRemoved", FALSE);
434 * wpas_dbus_signal_network_selected - Send a network selected signal
435 * @wpa_s: %wpa_supplicant network interface data
438 * Notify listeners about selecting a network
440 void wpas_dbus_signal_network_selected(struct wpa_supplicant *wpa_s, int id)
442 wpas_dbus_signal_network(wpa_s, id, "NetworkSelected", FALSE);
447 * wpas_dbus_signal_network_request - Indicate that additional information
448 * (EAP password, etc.) is required to complete the association to this SSID
449 * @wpa_s: %wpa_supplicant network interface data
450 * @rtype: The specific additional information required
451 * @default_text: Optional description of required information
453 * Request additional information or passwords to complete an association
456 void wpas_dbus_signal_network_request(struct wpa_supplicant *wpa_s,
457 struct wpa_ssid *ssid,
458 enum wpa_ctrl_req_type rtype,
459 const char *default_txt)
461 struct wpas_dbus_priv *iface;
463 DBusMessageIter iter;
464 char net_obj_path[WPAS_DBUS_OBJECT_PATH_MAX];
465 const char *field, *txt = NULL, *net_ptr;
467 iface = wpa_s->global->dbus;
469 /* Do nothing if the control interface is not turned on */
473 field = wpa_supplicant_ctrl_req_to_string(rtype, default_txt, &txt);
477 msg = dbus_message_new_signal(wpa_s->dbus_new_path,
478 WPAS_DBUS_NEW_IFACE_INTERFACE,
483 os_snprintf(net_obj_path, WPAS_DBUS_OBJECT_PATH_MAX,
484 "%s/" WPAS_DBUS_NEW_NETWORKS_PART "/%u",
485 wpa_s->dbus_new_path, ssid->id);
486 net_ptr = &net_obj_path[0];
488 dbus_message_iter_init_append(msg, &iter);
489 if (!dbus_message_iter_append_basic(&iter, DBUS_TYPE_OBJECT_PATH,
491 !dbus_message_iter_append_basic(&iter, DBUS_TYPE_STRING, &field) ||
492 !dbus_message_iter_append_basic(&iter, DBUS_TYPE_STRING, &txt))
493 wpa_printf(MSG_ERROR, "dbus: Failed to construct signal");
495 dbus_connection_send(iface->con, msg, NULL);
496 dbus_message_unref(msg);
501 * wpas_dbus_signal_network_enabled_changed - Signals Enabled property changes
502 * @wpa_s: %wpa_supplicant network interface data
503 * @ssid: configured network which Enabled property has changed
505 * Sends PropertyChanged signals containing new value of Enabled property
506 * for specified network
508 void wpas_dbus_signal_network_enabled_changed(struct wpa_supplicant *wpa_s,
509 struct wpa_ssid *ssid)
512 char path[WPAS_DBUS_OBJECT_PATH_MAX];
514 os_snprintf(path, WPAS_DBUS_OBJECT_PATH_MAX,
515 "%s/" WPAS_DBUS_NEW_NETWORKS_PART "/%d",
516 wpa_s->dbus_new_path, ssid->id);
518 wpa_dbus_mark_property_changed(wpa_s->global->dbus, path,
519 WPAS_DBUS_NEW_IFACE_NETWORK, "Enabled");
526 * wpas_dbus_signal_wps_event_success - Signals Success WPS event
527 * @wpa_s: %wpa_supplicant network interface data
529 * Sends Event dbus signal with name "success" and empty dict as arguments
531 void wpas_dbus_signal_wps_event_success(struct wpa_supplicant *wpa_s)
535 DBusMessageIter iter, dict_iter;
536 struct wpas_dbus_priv *iface;
537 char *key = "success";
539 iface = wpa_s->global->dbus;
541 /* Do nothing if the control interface is not turned on */
545 msg = dbus_message_new_signal(wpa_s->dbus_new_path,
546 WPAS_DBUS_NEW_IFACE_WPS, "Event");
550 dbus_message_iter_init_append(msg, &iter);
552 if (!dbus_message_iter_append_basic(&iter, DBUS_TYPE_STRING, &key) ||
553 !wpa_dbus_dict_open_write(&iter, &dict_iter) ||
554 !wpa_dbus_dict_close_write(&iter, &dict_iter))
555 wpa_printf(MSG_ERROR, "dbus: Failed to construct signal");
557 dbus_connection_send(iface->con, msg, NULL);
559 dbus_message_unref(msg);
564 * wpas_dbus_signal_wps_event_fail - Signals Fail WPS event
565 * @wpa_s: %wpa_supplicant network interface data
567 * Sends Event dbus signal with name "fail" and dictionary containing
568 * "msg field with fail message number (int32) as arguments
570 void wpas_dbus_signal_wps_event_fail(struct wpa_supplicant *wpa_s,
571 struct wps_event_fail *fail)
575 DBusMessageIter iter, dict_iter;
576 struct wpas_dbus_priv *iface;
579 iface = wpa_s->global->dbus;
581 /* Do nothing if the control interface is not turned on */
585 msg = dbus_message_new_signal(wpa_s->dbus_new_path,
586 WPAS_DBUS_NEW_IFACE_WPS, "Event");
590 dbus_message_iter_init_append(msg, &iter);
592 if (!dbus_message_iter_append_basic(&iter, DBUS_TYPE_STRING, &key) ||
593 !wpa_dbus_dict_open_write(&iter, &dict_iter) ||
594 !wpa_dbus_dict_append_int32(&dict_iter, "msg", fail->msg) ||
595 !wpa_dbus_dict_close_write(&iter, &dict_iter))
596 wpa_printf(MSG_ERROR, "dbus: Failed to construct signal");
598 dbus_connection_send(iface->con, msg, NULL);
600 dbus_message_unref(msg);
605 * wpas_dbus_signal_wps_event_m2d - Signals M2D WPS event
606 * @wpa_s: %wpa_supplicant network interface data
608 * Sends Event dbus signal with name "m2d" and dictionary containing
609 * fields of wps_event_m2d structure.
611 void wpas_dbus_signal_wps_event_m2d(struct wpa_supplicant *wpa_s,
612 struct wps_event_m2d *m2d)
616 DBusMessageIter iter, dict_iter;
617 struct wpas_dbus_priv *iface;
620 iface = wpa_s->global->dbus;
622 /* Do nothing if the control interface is not turned on */
626 msg = dbus_message_new_signal(wpa_s->dbus_new_path,
627 WPAS_DBUS_NEW_IFACE_WPS, "Event");
631 dbus_message_iter_init_append(msg, &iter);
633 if (!dbus_message_iter_append_basic(&iter, DBUS_TYPE_STRING, &key) ||
634 !wpa_dbus_dict_open_write(&iter, &dict_iter) ||
635 !wpa_dbus_dict_append_uint16(&dict_iter, "config_methods",
636 m2d->config_methods) ||
637 !wpa_dbus_dict_append_byte_array(&dict_iter, "manufacturer",
638 (const char *) m2d->manufacturer,
639 m2d->manufacturer_len) ||
640 !wpa_dbus_dict_append_byte_array(&dict_iter, "model_name",
641 (const char *) m2d->model_name,
642 m2d->model_name_len) ||
643 !wpa_dbus_dict_append_byte_array(&dict_iter, "model_number",
644 (const char *) m2d->model_number,
645 m2d->model_number_len) ||
646 !wpa_dbus_dict_append_byte_array(&dict_iter, "serial_number",
649 m2d->serial_number_len) ||
650 !wpa_dbus_dict_append_byte_array(&dict_iter, "dev_name",
651 (const char *) m2d->dev_name,
652 m2d->dev_name_len) ||
653 !wpa_dbus_dict_append_byte_array(&dict_iter, "primary_dev_type",
655 m2d->primary_dev_type, 8) ||
656 !wpa_dbus_dict_append_uint16(&dict_iter, "config_error",
657 m2d->config_error) ||
658 !wpa_dbus_dict_append_uint16(&dict_iter, "dev_password_id",
659 m2d->dev_password_id) ||
660 !wpa_dbus_dict_close_write(&iter, &dict_iter))
661 wpa_printf(MSG_ERROR, "dbus: Failed to construct signal");
663 dbus_connection_send(iface->con, msg, NULL);
665 dbus_message_unref(msg);
670 * wpas_dbus_signal_wps_cred - Signals new credentials
671 * @wpa_s: %wpa_supplicant network interface data
673 * Sends signal with credentials in directory argument
675 void wpas_dbus_signal_wps_cred(struct wpa_supplicant *wpa_s,
676 const struct wps_credential *cred)
679 DBusMessageIter iter, dict_iter;
680 struct wpas_dbus_priv *iface;
681 char *auth_type[5]; /* we have five possible authentication types */
683 char *encr_type[3]; /* we have three possible encryption types */
686 iface = wpa_s->global->dbus;
688 /* Do nothing if the control interface is not turned on */
692 msg = dbus_message_new_signal(wpa_s->dbus_new_path,
693 WPAS_DBUS_NEW_IFACE_WPS,
698 dbus_message_iter_init_append(msg, &iter);
699 if (!wpa_dbus_dict_open_write(&iter, &dict_iter))
702 if (cred->auth_type & WPS_AUTH_OPEN)
703 auth_type[at_num++] = "open";
704 if (cred->auth_type & WPS_AUTH_WPAPSK)
705 auth_type[at_num++] = "wpa-psk";
706 if (cred->auth_type & WPS_AUTH_WPA)
707 auth_type[at_num++] = "wpa-eap";
708 if (cred->auth_type & WPS_AUTH_WPA2)
709 auth_type[at_num++] = "wpa2-eap";
710 if (cred->auth_type & WPS_AUTH_WPA2PSK)
711 auth_type[at_num++] = "wpa2-psk";
713 if (cred->encr_type & WPS_ENCR_NONE)
714 encr_type[et_num++] = "none";
715 if (cred->encr_type & WPS_ENCR_TKIP)
716 encr_type[et_num++] = "tkip";
717 if (cred->encr_type & WPS_ENCR_AES)
718 encr_type[et_num++] = "aes";
720 if ((wpa_s->current_ssid &&
721 !wpa_dbus_dict_append_byte_array(
723 (const char *) wpa_s->current_ssid->bssid, ETH_ALEN)) ||
724 !wpa_dbus_dict_append_byte_array(&dict_iter, "SSID",
725 (const char *) cred->ssid,
727 !wpa_dbus_dict_append_string_array(&dict_iter, "AuthType",
728 (const char **) auth_type,
730 !wpa_dbus_dict_append_string_array(&dict_iter, "EncrType",
731 (const char **) encr_type,
733 !wpa_dbus_dict_append_byte_array(&dict_iter, "Key",
734 (const char *) cred->key,
736 !wpa_dbus_dict_append_uint32(&dict_iter, "KeyIndex",
738 !wpa_dbus_dict_close_write(&iter, &dict_iter))
741 dbus_connection_send(iface->con, msg, NULL);
744 dbus_message_unref(msg);
747 #endif /* CONFIG_WPS */
749 void wpas_dbus_signal_certification(struct wpa_supplicant *wpa_s,
750 int depth, const char *subject,
751 const char *cert_hash,
752 const struct wpabuf *cert)
754 struct wpas_dbus_priv *iface;
756 DBusMessageIter iter, dict_iter;
758 iface = wpa_s->global->dbus;
760 /* Do nothing if the control interface is not turned on */
764 msg = dbus_message_new_signal(wpa_s->dbus_new_path,
765 WPAS_DBUS_NEW_IFACE_INTERFACE,
770 dbus_message_iter_init_append(msg, &iter);
771 if (!wpa_dbus_dict_open_write(&iter, &dict_iter) ||
772 !wpa_dbus_dict_append_uint32(&dict_iter, "depth", depth) ||
773 !wpa_dbus_dict_append_string(&dict_iter, "subject", subject) ||
775 !wpa_dbus_dict_append_string(&dict_iter, "cert_hash",
778 !wpa_dbus_dict_append_byte_array(&dict_iter, "cert",
780 wpabuf_len(cert))) ||
781 !wpa_dbus_dict_close_write(&iter, &dict_iter))
782 wpa_printf(MSG_ERROR, "dbus: Failed to construct signal");
784 dbus_connection_send(iface->con, msg, NULL);
785 dbus_message_unref(msg);
789 void wpas_dbus_signal_eap_status(struct wpa_supplicant *wpa_s,
790 const char *status, const char *parameter)
792 struct wpas_dbus_priv *iface;
794 DBusMessageIter iter;
796 iface = wpa_s->global->dbus;
798 /* Do nothing if the control interface is not turned on */
802 msg = dbus_message_new_signal(wpa_s->dbus_new_path,
803 WPAS_DBUS_NEW_IFACE_INTERFACE,
808 dbus_message_iter_init_append(msg, &iter);
810 if (!dbus_message_iter_append_basic(&iter, DBUS_TYPE_STRING, &status) ||
811 !dbus_message_iter_append_basic(&iter, DBUS_TYPE_STRING,
813 wpa_printf(MSG_ERROR, "dbus: Failed to construct signal");
815 dbus_connection_send(iface->con, msg, NULL);
816 dbus_message_unref(msg);
821 * wpas_dbus_signal_sta - Send a station related event signal
822 * @wpa_s: %wpa_supplicant network interface data
823 * @sta: station mac address
824 * @sig_name: signal name - StaAuthorized or StaDeauthorized
826 * Notify listeners about event related with station
828 static void wpas_dbus_signal_sta(struct wpa_supplicant *wpa_s,
829 const u8 *sta, const char *sig_name)
831 struct wpas_dbus_priv *iface;
833 char sta_mac[WPAS_DBUS_OBJECT_PATH_MAX];
836 os_snprintf(sta_mac, WPAS_DBUS_OBJECT_PATH_MAX, MACSTR, MAC2STR(sta));
839 iface = wpa_s->global->dbus;
841 /* Do nothing if the control interface is not turned on */
845 msg = dbus_message_new_signal(wpa_s->dbus_new_path,
846 WPAS_DBUS_NEW_IFACE_INTERFACE, sig_name);
850 if (dbus_message_append_args(msg, DBUS_TYPE_STRING, &dev_mac,
852 dbus_connection_send(iface->con, msg, NULL);
854 wpa_printf(MSG_ERROR, "dbus: Failed to construct signal");
855 dbus_message_unref(msg);
857 wpa_printf(MSG_DEBUG, "dbus: Station MAC address '%s' '%s'",
863 * wpas_dbus_signal_sta_authorized - Send a STA authorized signal
864 * @wpa_s: %wpa_supplicant network interface data
865 * @sta: station mac address
867 * Notify listeners a new station has been authorized
869 void wpas_dbus_signal_sta_authorized(struct wpa_supplicant *wpa_s,
872 wpas_dbus_signal_sta(wpa_s, sta, "StaAuthorized");
877 * wpas_dbus_signal_sta_deauthorized - Send a STA deauthorized signal
878 * @wpa_s: %wpa_supplicant network interface data
879 * @sta: station mac address
881 * Notify listeners a station has been deauthorized
883 void wpas_dbus_signal_sta_deauthorized(struct wpa_supplicant *wpa_s,
886 wpas_dbus_signal_sta(wpa_s, sta, "StaDeauthorized");
893 * wpas_dbus_signal_p2p_group_removed - Signals P2P group was removed
894 * @wpa_s: %wpa_supplicant network interface data
895 * @role: role of this device (client or GO)
896 * Sends signal with i/f name and role as string arguments
898 void wpas_dbus_signal_p2p_group_removed(struct wpa_supplicant *wpa_s,
902 DBusMessageIter iter, dict_iter;
903 struct wpas_dbus_priv *iface = wpa_s->global->dbus;
904 struct wpa_supplicant *parent;
906 /* Do nothing if the control interface is not turned on */
910 parent = wpa_s->parent;
911 if (parent->p2p_mgmt)
912 parent = parent->parent;
914 if (!wpa_s->dbus_groupobj_path)
917 msg = dbus_message_new_signal(parent->dbus_new_path,
918 WPAS_DBUS_NEW_IFACE_P2PDEVICE,
923 dbus_message_iter_init_append(msg, &iter);
924 if (!wpa_dbus_dict_open_write(&iter, &dict_iter) ||
925 !wpa_dbus_dict_append_object_path(&dict_iter,
927 wpa_s->dbus_new_path) ||
928 !wpa_dbus_dict_append_string(&dict_iter, "role", role) ||
929 !wpa_dbus_dict_append_object_path(&dict_iter, "group_object",
930 wpa_s->dbus_groupobj_path) ||
931 !wpa_dbus_dict_close_write(&iter, &dict_iter))
932 wpa_printf(MSG_ERROR, "dbus: Failed to construct signal");
934 dbus_connection_send(iface->con, msg, NULL);
935 dbus_message_unref(msg);
940 * wpas_dbus_signal_p2p_provision_discovery - Signals various PD events
942 * @dev_addr - who sent the request or responded to our request.
943 * @request - Will be 1 if request, 0 for response.
944 * @status - valid only in case of response
945 * @config_methods - wps config methods
946 * @generated_pin - pin to be displayed in case of WPS_CONFIG_DISPLAY method
948 * Sends following provision discovery related events:
949 * ProvisionDiscoveryRequestDisplayPin
950 * ProvisionDiscoveryResponseDisplayPin
951 * ProvisionDiscoveryRequestEnterPin
952 * ProvisionDiscoveryResponseEnterPin
953 * ProvisionDiscoveryPBCRequest
954 * ProvisionDiscoveryPBCResponse
957 * ProvisionDiscoveryFailure (timeout case)
959 void wpas_dbus_signal_p2p_provision_discovery(struct wpa_supplicant *wpa_s,
960 const u8 *dev_addr, int request,
961 enum p2p_prov_disc_status status,
963 unsigned int generated_pin)
966 DBusMessageIter iter;
967 struct wpas_dbus_priv *iface;
970 char peer_obj_path[WPAS_DBUS_OBJECT_PATH_MAX], *path;
972 char pin[9], *p_pin = NULL;
974 iface = wpa_s->global->dbus;
976 /* Do nothing if the control interface is not turned on */
981 wpa_s = wpa_s->parent;
983 if (request || !status) {
984 if (config_methods & WPS_CONFIG_DISPLAY)
986 "ProvisionDiscoveryRequestDisplayPin" :
987 "ProvisionDiscoveryResponseEnterPin";
988 else if (config_methods & WPS_CONFIG_KEYPAD)
990 "ProvisionDiscoveryRequestEnterPin" :
991 "ProvisionDiscoveryResponseDisplayPin";
992 else if (config_methods & WPS_CONFIG_PUSHBUTTON)
993 _signal = request ? "ProvisionDiscoveryPBCRequest" :
994 "ProvisionDiscoveryPBCResponse";
996 return; /* Unknown or un-supported method */
998 /* Explicit check for failure response */
999 _signal = "ProvisionDiscoveryFailure";
1002 add_pin = ((request && (config_methods & WPS_CONFIG_DISPLAY)) ||
1003 (!request && !status &&
1004 (config_methods & WPS_CONFIG_KEYPAD)));
1007 os_snprintf(pin, sizeof(pin), "%08d", generated_pin);
1011 msg = dbus_message_new_signal(wpa_s->dbus_new_path,
1012 WPAS_DBUS_NEW_IFACE_P2PDEVICE, _signal);
1016 /* Check if this is a known peer */
1017 if (!p2p_peer_known(wpa_s->global->p2p, dev_addr))
1020 os_snprintf(peer_obj_path, WPAS_DBUS_OBJECT_PATH_MAX,
1021 "%s/" WPAS_DBUS_NEW_P2P_PEERS_PART "/"
1023 wpa_s->dbus_new_path, MAC2STR(dev_addr));
1025 path = peer_obj_path;
1027 dbus_message_iter_init_append(msg, &iter);
1029 if (!dbus_message_iter_append_basic(&iter,
1030 DBUS_TYPE_OBJECT_PATH,
1034 if (!request && status)
1035 /* Attach status to ProvisionDiscoveryFailure */
1036 error_ret = !dbus_message_iter_append_basic(&iter,
1040 error_ret = (add_pin &&
1041 !dbus_message_iter_append_basic(&iter,
1047 dbus_connection_send(iface->con, msg, NULL);
1049 wpa_printf(MSG_ERROR, "dbus: Failed to construct signal");
1051 dbus_message_unref(msg);
1055 void wpas_dbus_signal_p2p_go_neg_req(struct wpa_supplicant *wpa_s,
1056 const u8 *src, u16 dev_passwd_id)
1059 DBusMessageIter iter;
1060 struct wpas_dbus_priv *iface;
1061 char peer_obj_path[WPAS_DBUS_OBJECT_PATH_MAX], *path;
1063 iface = wpa_s->global->dbus;
1065 /* Do nothing if the control interface is not turned on */
1069 if (wpa_s->p2p_mgmt)
1070 wpa_s = wpa_s->parent;
1072 os_snprintf(peer_obj_path, WPAS_DBUS_OBJECT_PATH_MAX,
1073 "%s/" WPAS_DBUS_NEW_P2P_PEERS_PART "/" COMPACT_MACSTR,
1074 wpa_s->dbus_new_path, MAC2STR(src));
1075 path = peer_obj_path;
1077 msg = dbus_message_new_signal(wpa_s->dbus_new_path,
1078 WPAS_DBUS_NEW_IFACE_P2PDEVICE,
1079 "GONegotiationRequest");
1083 dbus_message_iter_init_append(msg, &iter);
1085 if (!dbus_message_iter_append_basic(&iter, DBUS_TYPE_OBJECT_PATH,
1087 !dbus_message_iter_append_basic(&iter, DBUS_TYPE_UINT16,
1089 wpa_printf(MSG_ERROR, "dbus: Failed to construct signal");
1091 dbus_connection_send(iface->con, msg, NULL);
1093 dbus_message_unref(msg);
1097 static int wpas_dbus_get_group_obj_path(struct wpa_supplicant *wpa_s,
1098 const struct wpa_ssid *ssid,
1099 char *group_obj_path)
1103 if (os_memcmp(ssid->ssid, P2P_WILDCARD_SSID, P2P_WILDCARD_SSID_LEN))
1106 os_memcpy(group_name, ssid->ssid + P2P_WILDCARD_SSID_LEN, 2);
1107 group_name[2] = '\0';
1109 os_snprintf(group_obj_path, WPAS_DBUS_OBJECT_PATH_MAX,
1110 "%s/" WPAS_DBUS_NEW_P2P_GROUPS_PART "/%s",
1111 wpa_s->dbus_new_path, group_name);
1117 struct group_changed_data {
1118 struct wpa_supplicant *wpa_s;
1119 struct p2p_peer_info *info;
1123 static int match_group_where_peer_is_client(struct p2p_group *group,
1126 struct group_changed_data *data = user_data;
1127 const struct p2p_group_config *cfg;
1128 struct wpa_supplicant *wpa_s_go;
1130 if (!p2p_group_is_client_connected(group, data->info->p2p_device_addr))
1133 cfg = p2p_group_get_config(group);
1135 wpa_s_go = wpas_get_p2p_go_iface(data->wpa_s, cfg->ssid,
1137 if (wpa_s_go != NULL && wpa_s_go == data->wpa_s) {
1138 wpas_dbus_signal_peer_groups_changed(
1139 data->wpa_s->parent, data->info->p2p_device_addr);
1147 static void signal_peer_groups_changed(struct p2p_peer_info *info,
1150 struct group_changed_data *data = user_data;
1151 struct wpa_supplicant *wpa_s_go;
1153 wpa_s_go = wpas_get_p2p_client_iface(data->wpa_s,
1154 info->p2p_device_addr);
1155 if (wpa_s_go != NULL && wpa_s_go == data->wpa_s) {
1156 wpas_dbus_signal_peer_groups_changed(data->wpa_s->parent,
1157 info->p2p_device_addr);
1162 p2p_loop_on_all_groups(data->wpa_s->global->p2p,
1163 match_group_where_peer_is_client, data);
1168 static void peer_groups_changed(struct wpa_supplicant *wpa_s)
1170 struct group_changed_data data;
1172 os_memset(&data, 0, sizeof(data));
1175 p2p_loop_on_known_peers(wpa_s->global->p2p,
1176 signal_peer_groups_changed, &data);
1181 * wpas_dbus_signal_p2p_group_started - Signals P2P group has
1182 * started. Emitted when a group is successfully started
1183 * irrespective of the role (client/GO) of the current device
1185 * @wpa_s: %wpa_supplicant network interface data
1186 * @ssid: SSID object
1187 * @client: this device is P2P client
1188 * @network_id: network id of the group started, use instead of ssid->id
1189 * to account for persistent groups
1191 void wpas_dbus_signal_p2p_group_started(struct wpa_supplicant *wpa_s,
1192 const struct wpa_ssid *ssid,
1193 int client, int network_id)
1196 DBusMessageIter iter, dict_iter;
1197 struct wpas_dbus_priv *iface;
1198 struct wpa_supplicant *parent;
1200 parent = wpa_s->parent;
1201 if (parent->p2p_mgmt)
1202 parent = parent->parent;
1204 iface = parent->global->dbus;
1206 /* Do nothing if the control interface is not turned on */
1210 if (wpa_s->dbus_groupobj_path == NULL)
1213 /* New interface has been created for this group */
1214 msg = dbus_message_new_signal(parent->dbus_new_path,
1215 WPAS_DBUS_NEW_IFACE_P2PDEVICE,
1220 dbus_message_iter_init_append(msg, &iter);
1222 * In case the device supports creating a separate interface the
1223 * DBus client will need to know the object path for the interface
1224 * object this group was created on, so include it here.
1226 if (!wpa_dbus_dict_open_write(&iter, &dict_iter) ||
1227 !wpa_dbus_dict_append_object_path(&dict_iter,
1229 wpa_s->dbus_new_path) ||
1230 !wpa_dbus_dict_append_string(&dict_iter, "role",
1231 client ? "client" : "GO") ||
1232 !wpa_dbus_dict_append_object_path(&dict_iter, "group_object",
1233 wpa_s->dbus_groupobj_path) ||
1234 !wpa_dbus_dict_close_write(&iter, &dict_iter)) {
1235 wpa_printf(MSG_ERROR, "dbus: Failed to construct signal");
1237 dbus_connection_send(iface->con, msg, NULL);
1239 peer_groups_changed(wpa_s);
1241 dbus_message_unref(msg);
1247 * Method to emit GONegotiation Success or Failure signals based
1249 * @status: Status of the GO neg request. 0 for success, other for errors.
1251 void wpas_dbus_signal_p2p_go_neg_resp(struct wpa_supplicant *wpa_s,
1252 struct p2p_go_neg_results *res)
1255 DBusMessageIter iter, dict_iter;
1256 DBusMessageIter iter_dict_entry, iter_dict_val, iter_dict_array;
1257 struct wpas_dbus_priv *iface;
1258 char peer_obj_path[WPAS_DBUS_OBJECT_PATH_MAX], *path;
1259 dbus_int32_t freqs[P2P_MAX_CHANNELS];
1260 dbus_int32_t *f_array = freqs;
1263 iface = wpa_s->global->dbus;
1265 if (wpa_s->p2p_mgmt)
1266 wpa_s = wpa_s->parent;
1268 os_memset(freqs, 0, sizeof(freqs));
1269 /* Do nothing if the control interface is not turned on */
1273 os_snprintf(peer_obj_path, WPAS_DBUS_OBJECT_PATH_MAX,
1274 "%s/" WPAS_DBUS_NEW_P2P_PEERS_PART "/" COMPACT_MACSTR,
1275 wpa_s->dbus_new_path, MAC2STR(res->peer_device_addr));
1276 path = peer_obj_path;
1278 msg = dbus_message_new_signal(wpa_s->dbus_new_path,
1279 WPAS_DBUS_NEW_IFACE_P2PDEVICE,
1280 res->status ? "GONegotiationFailure" :
1281 "GONegotiationSuccess");
1285 dbus_message_iter_init_append(msg, &iter);
1286 if (!wpa_dbus_dict_open_write(&iter, &dict_iter) ||
1287 !wpa_dbus_dict_append_object_path(&dict_iter, "peer_object",
1289 !wpa_dbus_dict_append_int32(&dict_iter, "status", res->status))
1294 int freq_list_num = 0;
1296 if ((res->role_go &&
1297 !wpa_dbus_dict_append_string(&dict_iter, "passphrase",
1298 res->passphrase)) ||
1299 !wpa_dbus_dict_append_string(&dict_iter, "role_go",
1300 res->role_go ? "GO" :
1302 !wpa_dbus_dict_append_int32(&dict_iter, "frequency",
1304 !wpa_dbus_dict_append_byte_array(&dict_iter, "ssid",
1305 (const char *) res->ssid,
1307 !wpa_dbus_dict_append_byte_array(&dict_iter,
1310 res->peer_device_addr,
1312 !wpa_dbus_dict_append_byte_array(&dict_iter,
1313 "peer_interface_addr",
1315 res->peer_interface_addr,
1317 !wpa_dbus_dict_append_string(&dict_iter, "wps_method",
1318 p2p_wps_method_text(
1322 for (i = 0; i < P2P_MAX_CHANNELS; i++) {
1323 if (res->freq_list[i]) {
1324 freqs[i] = res->freq_list[i];
1329 if (!wpa_dbus_dict_begin_array(&dict_iter,
1331 DBUS_TYPE_INT32_AS_STRING,
1334 &iter_dict_array) ||
1335 !dbus_message_iter_append_fixed_array(&iter_dict_array,
1339 !wpa_dbus_dict_end_array(&dict_iter,
1342 &iter_dict_array) ||
1343 !wpa_dbus_dict_append_int32(&dict_iter, "persistent_group",
1344 res->persistent_group) ||
1345 !wpa_dbus_dict_append_uint32(&dict_iter,
1346 "peer_config_timeout",
1347 res->peer_config_timeout))
1351 if (!wpa_dbus_dict_close_write(&iter, &dict_iter))
1354 dbus_connection_send(iface->con, msg, NULL);
1356 dbus_message_unref(msg);
1362 * Method to emit Invitation Result signal based on status and
1364 * @status: Status of the Invite request. 0 for success, other
1366 * @bssid : Basic Service Set Identifier
1368 void wpas_dbus_signal_p2p_invitation_result(struct wpa_supplicant *wpa_s,
1369 int status, const u8 *bssid)
1372 DBusMessageIter iter, dict_iter;
1373 struct wpas_dbus_priv *iface;
1375 wpa_printf(MSG_DEBUG, "%s", __func__);
1377 iface = wpa_s->global->dbus;
1378 /* Do nothing if the control interface is not turned on */
1382 if (wpa_s->p2p_mgmt)
1383 wpa_s = wpa_s->parent;
1385 msg = dbus_message_new_signal(wpa_s->dbus_new_path,
1386 WPAS_DBUS_NEW_IFACE_P2PDEVICE,
1387 "InvitationResult");
1392 dbus_message_iter_init_append(msg, &iter);
1393 if (!wpa_dbus_dict_open_write(&iter, &dict_iter) ||
1394 !wpa_dbus_dict_append_int32(&dict_iter, "status", status) ||
1396 !wpa_dbus_dict_append_byte_array(&dict_iter, "BSSID",
1397 (const char *) bssid,
1399 !wpa_dbus_dict_close_write(&iter, &dict_iter))
1400 wpa_printf(MSG_ERROR, "dbus: Failed to construct signal");
1402 dbus_connection_send(iface->con, msg, NULL);
1403 dbus_message_unref(msg);
1409 * Method to emit a signal for a peer joining the group.
1410 * The signal will carry path to the group member object
1411 * constructed using p2p i/f addr used for connecting.
1413 * @wpa_s: %wpa_supplicant network interface data
1414 * @peer_addr: P2P Device Address of the peer joining the group
1416 void wpas_dbus_signal_p2p_peer_joined(struct wpa_supplicant *wpa_s,
1417 const u8 *peer_addr)
1419 struct wpas_dbus_priv *iface;
1421 DBusMessageIter iter;
1422 char peer_obj_path[WPAS_DBUS_OBJECT_PATH_MAX], *path;
1423 struct wpa_supplicant *parent;
1425 iface = wpa_s->global->dbus;
1427 /* Do nothing if the control interface is not turned on */
1431 if (!wpa_s->dbus_groupobj_path)
1434 parent = wpa_s->parent;
1435 if (parent->p2p_mgmt)
1436 parent = parent->parent;
1438 os_snprintf(peer_obj_path, WPAS_DBUS_OBJECT_PATH_MAX,
1439 "%s/" WPAS_DBUS_NEW_P2P_PEERS_PART "/"
1441 parent->dbus_new_path, MAC2STR(peer_addr));
1443 msg = dbus_message_new_signal(wpa_s->dbus_groupobj_path,
1444 WPAS_DBUS_NEW_IFACE_P2P_GROUP,
1449 dbus_message_iter_init_append(msg, &iter);
1450 path = peer_obj_path;
1451 if (!dbus_message_iter_append_basic(&iter, DBUS_TYPE_OBJECT_PATH,
1453 wpa_printf(MSG_ERROR, "dbus: Failed to construct signal");
1455 dbus_connection_send(iface->con, msg, NULL);
1456 wpas_dbus_signal_peer_groups_changed(parent, peer_addr);
1458 dbus_message_unref(msg);
1464 * Method to emit a signal for a peer disconnecting the group.
1465 * The signal will carry path to the group member object
1466 * constructed using the P2P Device Address of the peer.
1468 * @wpa_s: %wpa_supplicant network interface data
1469 * @peer_addr: P2P Device Address of the peer joining the group
1471 void wpas_dbus_signal_p2p_peer_disconnected(struct wpa_supplicant *wpa_s,
1472 const u8 *peer_addr)
1474 struct wpas_dbus_priv *iface;
1476 DBusMessageIter iter;
1477 char peer_obj_path[WPAS_DBUS_OBJECT_PATH_MAX], *path;
1478 struct wpa_supplicant *parent;
1480 iface = wpa_s->global->dbus;
1482 /* Do nothing if the control interface is not turned on */
1486 if (!wpa_s->dbus_groupobj_path)
1489 parent = wpa_s->parent;
1490 if (parent->p2p_mgmt)
1491 parent = parent->parent;
1493 os_snprintf(peer_obj_path, WPAS_DBUS_OBJECT_PATH_MAX,
1494 "%s/" WPAS_DBUS_NEW_P2P_PEERS_PART "/"
1496 parent->dbus_new_path, MAC2STR(peer_addr));
1498 msg = dbus_message_new_signal(wpa_s->dbus_groupobj_path,
1499 WPAS_DBUS_NEW_IFACE_P2P_GROUP,
1500 "PeerDisconnected");
1504 dbus_message_iter_init_append(msg, &iter);
1505 path = peer_obj_path;
1506 if (!dbus_message_iter_append_basic(&iter, DBUS_TYPE_OBJECT_PATH,
1508 wpa_printf(MSG_ERROR,
1509 "dbus: Failed to construct PeerDisconnected signal");
1511 dbus_connection_send(iface->con, msg, NULL);
1512 wpas_dbus_signal_peer_groups_changed(parent, peer_addr);
1514 dbus_message_unref(msg);
1520 * Method to emit a signal for a service discovery request.
1521 * The signal will carry station address, frequency, dialog token,
1522 * update indicator and it tlvs
1524 * @wpa_s: %wpa_supplicant network interface data
1525 * @sa: station addr (p2p i/f) of the peer
1526 * @dialog_token: service discovery request dialog token
1527 * @update_indic: service discovery request update indicator
1528 * @tlvs: service discovery request genrated byte array of tlvs
1529 * @tlvs_len: service discovery request tlvs length
1531 void wpas_dbus_signal_p2p_sd_request(struct wpa_supplicant *wpa_s,
1532 int freq, const u8 *sa, u8 dialog_token,
1533 u16 update_indic, const u8 *tlvs,
1537 DBusMessageIter iter, dict_iter;
1538 struct wpas_dbus_priv *iface;
1539 char peer_obj_path[WPAS_DBUS_OBJECT_PATH_MAX], *path;
1541 iface = wpa_s->global->dbus;
1543 /* Do nothing if the control interface is not turned on */
1547 if (wpa_s->p2p_mgmt)
1548 wpa_s = wpa_s->parent;
1550 /* Check if this is a known peer */
1551 if (!p2p_peer_known(wpa_s->global->p2p, sa))
1554 msg = dbus_message_new_signal(wpa_s->dbus_new_path,
1555 WPAS_DBUS_NEW_IFACE_P2PDEVICE,
1556 "ServiceDiscoveryRequest");
1560 os_snprintf(peer_obj_path, WPAS_DBUS_OBJECT_PATH_MAX,
1561 "%s/" WPAS_DBUS_NEW_P2P_PEERS_PART "/"
1562 COMPACT_MACSTR, wpa_s->dbus_new_path, MAC2STR(sa));
1564 path = peer_obj_path;
1566 dbus_message_iter_init_append(msg, &iter);
1567 if (!wpa_dbus_dict_open_write(&iter, &dict_iter) ||
1568 !wpa_dbus_dict_append_object_path(&dict_iter, "peer_object",
1570 !wpa_dbus_dict_append_int32(&dict_iter, "frequency", freq) ||
1571 !wpa_dbus_dict_append_int32(&dict_iter, "dialog_token",
1573 !wpa_dbus_dict_append_uint16(&dict_iter, "update_indicator",
1575 !wpa_dbus_dict_append_byte_array(&dict_iter, "tlvs",
1576 (const char *) tlvs,
1578 !wpa_dbus_dict_close_write(&iter, &dict_iter))
1579 wpa_printf(MSG_ERROR, "dbus: Failed to construct signal");
1581 dbus_connection_send(iface->con, msg, NULL);
1582 dbus_message_unref(msg);
1588 * Method to emit a signal for a service discovery response.
1589 * The signal will carry station address, update indicator and it
1592 * @wpa_s: %wpa_supplicant network interface data
1593 * @sa: station addr (p2p i/f) of the peer
1594 * @update_indic: service discovery request update indicator
1595 * @tlvs: service discovery request genrated byte array of tlvs
1596 * @tlvs_len: service discovery request tlvs length
1598 void wpas_dbus_signal_p2p_sd_response(struct wpa_supplicant *wpa_s,
1599 const u8 *sa, u16 update_indic,
1600 const u8 *tlvs, size_t tlvs_len)
1603 DBusMessageIter iter, dict_iter;
1604 struct wpas_dbus_priv *iface;
1605 char peer_obj_path[WPAS_DBUS_OBJECT_PATH_MAX], *path;
1607 iface = wpa_s->global->dbus;
1609 /* Do nothing if the control interface is not turned on */
1613 if (wpa_s->p2p_mgmt)
1614 wpa_s = wpa_s->parent;
1616 /* Check if this is a known peer */
1617 if (!p2p_peer_known(wpa_s->global->p2p, sa))
1620 msg = dbus_message_new_signal(wpa_s->dbus_new_path,
1621 WPAS_DBUS_NEW_IFACE_P2PDEVICE,
1622 "ServiceDiscoveryResponse");
1626 os_snprintf(peer_obj_path, WPAS_DBUS_OBJECT_PATH_MAX,
1627 "%s/" WPAS_DBUS_NEW_P2P_PEERS_PART "/"
1628 COMPACT_MACSTR, wpa_s->dbus_new_path, MAC2STR(sa));
1630 path = peer_obj_path;
1632 dbus_message_iter_init_append(msg, &iter);
1633 if (!wpa_dbus_dict_open_write(&iter, &dict_iter) ||
1634 !wpa_dbus_dict_append_object_path(&dict_iter, "peer_object",
1636 !wpa_dbus_dict_append_uint16(&dict_iter, "update_indicator",
1638 !wpa_dbus_dict_append_byte_array(&dict_iter, "tlvs",
1639 (const char *) tlvs,
1641 !wpa_dbus_dict_close_write(&iter, &dict_iter))
1642 wpa_printf(MSG_ERROR, "dbus: Failed to construct signal");
1644 dbus_connection_send(iface->con, msg, NULL);
1645 dbus_message_unref(msg);
1650 * wpas_dbus_signal_persistent_group - Send a persistent group related
1652 * @wpa_s: %wpa_supplicant network interface data
1653 * @id: new persistent group id
1654 * @sig_name: signal name - PersistentGroupAdded, PersistentGroupRemoved
1655 * @properties: determines if add second argument with object properties
1657 * Notify listeners about an event related to persistent groups.
1659 static void wpas_dbus_signal_persistent_group(struct wpa_supplicant *wpa_s,
1660 int id, const char *sig_name,
1663 struct wpas_dbus_priv *iface;
1665 DBusMessageIter iter;
1666 char pgrp_obj_path[WPAS_DBUS_OBJECT_PATH_MAX], *path;
1668 iface = wpa_s->global->dbus;
1670 /* Do nothing if the control interface is not turned on */
1674 if (wpa_s->p2p_mgmt)
1675 wpa_s = wpa_s->parent;
1677 os_snprintf(pgrp_obj_path, WPAS_DBUS_OBJECT_PATH_MAX,
1678 "%s/" WPAS_DBUS_NEW_PERSISTENT_GROUPS_PART "/%u",
1679 wpa_s->dbus_new_path, id);
1681 msg = dbus_message_new_signal(wpa_s->dbus_new_path,
1682 WPAS_DBUS_NEW_IFACE_P2PDEVICE,
1687 dbus_message_iter_init_append(msg, &iter);
1688 path = pgrp_obj_path;
1689 if (!dbus_message_iter_append_basic(&iter, DBUS_TYPE_OBJECT_PATH,
1692 !wpa_dbus_get_object_properties(
1693 iface, pgrp_obj_path,
1694 WPAS_DBUS_NEW_IFACE_PERSISTENT_GROUP, &iter)))
1695 wpa_printf(MSG_ERROR, "dbus: Failed to construct signal");
1697 dbus_connection_send(iface->con, msg, NULL);
1699 dbus_message_unref(msg);
1704 * wpas_dbus_signal_persistent_group_added - Send a persistent_group
1706 * @wpa_s: %wpa_supplicant network interface data
1707 * @id: new persistent group id
1709 * Notify listeners about addition of a new persistent group.
1711 static void wpas_dbus_signal_persistent_group_added(
1712 struct wpa_supplicant *wpa_s, int id)
1714 wpas_dbus_signal_persistent_group(wpa_s, id, "PersistentGroupAdded",
1720 * wpas_dbus_signal_persistent_group_removed - Send a persistent_group
1722 * @wpa_s: %wpa_supplicant network interface data
1723 * @id: persistent group id
1725 * Notify listeners about removal of a persistent group.
1727 static void wpas_dbus_signal_persistent_group_removed(
1728 struct wpa_supplicant *wpa_s, int id)
1730 wpas_dbus_signal_persistent_group(wpa_s, id, "PersistentGroupRemoved",
1736 * wpas_dbus_signal_p2p_wps_failed - Signals WpsFailed event
1737 * @wpa_s: %wpa_supplicant network interface data
1739 * Sends Event dbus signal with name "fail" and dictionary containing
1740 * "msg" field with fail message number (int32) as arguments
1742 void wpas_dbus_signal_p2p_wps_failed(struct wpa_supplicant *wpa_s,
1743 struct wps_event_fail *fail)
1747 DBusMessageIter iter, dict_iter;
1748 struct wpas_dbus_priv *iface;
1751 iface = wpa_s->global->dbus;
1753 /* Do nothing if the control interface is not turned on */
1757 if (wpa_s->p2p_mgmt)
1758 wpa_s = wpa_s->parent;
1760 msg = dbus_message_new_signal(wpa_s->dbus_new_path,
1761 WPAS_DBUS_NEW_IFACE_P2PDEVICE,
1766 dbus_message_iter_init_append(msg, &iter);
1768 if (!dbus_message_iter_append_basic(&iter, DBUS_TYPE_STRING, &key) ||
1769 !wpa_dbus_dict_open_write(&iter, &dict_iter) ||
1770 !wpa_dbus_dict_append_int32(&dict_iter, "msg", fail->msg) ||
1771 !wpa_dbus_dict_append_int16(&dict_iter, "config_error",
1772 fail->config_error) ||
1773 !wpa_dbus_dict_close_write(&iter, &dict_iter))
1774 wpa_printf(MSG_ERROR, "dbus: Failed to construct signal");
1776 dbus_connection_send(iface->con, msg, NULL);
1778 dbus_message_unref(msg);
1781 #endif /* CONFIG_P2P */
1785 * wpas_dbus_signal_prop_changed - Signals change of property
1786 * @wpa_s: %wpa_supplicant network interface data
1787 * @property: indicates which property has changed
1789 * Sends PropertyChanged signals with path, interface and arguments
1790 * depending on which property has changed.
1792 void wpas_dbus_signal_prop_changed(struct wpa_supplicant *wpa_s,
1793 enum wpas_dbus_prop property)
1798 if (wpa_s->dbus_new_path == NULL)
1799 return; /* Skip signal since D-Bus setup is not yet ready */
1803 case WPAS_DBUS_PROP_AP_SCAN:
1806 case WPAS_DBUS_PROP_SCANNING:
1809 case WPAS_DBUS_PROP_STATE:
1812 case WPAS_DBUS_PROP_CURRENT_BSS:
1813 prop = "CurrentBSS";
1815 case WPAS_DBUS_PROP_CURRENT_NETWORK:
1816 prop = "CurrentNetwork";
1818 case WPAS_DBUS_PROP_BSSS:
1821 case WPAS_DBUS_PROP_CURRENT_AUTH_MODE:
1822 prop = "CurrentAuthMode";
1824 case WPAS_DBUS_PROP_DISCONNECT_REASON:
1825 prop = "DisconnectReason";
1829 wpa_printf(MSG_ERROR, "dbus: %s: Unknown Property value %d",
1830 __func__, property);
1834 wpa_dbus_mark_property_changed(wpa_s->global->dbus,
1835 wpa_s->dbus_new_path,
1836 WPAS_DBUS_NEW_IFACE_INTERFACE, prop);
1838 wpa_dbus_flush_object_changed_properties(
1839 wpa_s->global->dbus->con, wpa_s->dbus_new_path);
1845 * wpas_dbus_bss_signal_prop_changed - Signals change of BSS property
1846 * @wpa_s: %wpa_supplicant network interface data
1847 * @property: indicates which property has changed
1848 * @id: unique BSS identifier
1850 * Sends PropertyChanged signals with path, interface, and arguments depending
1851 * on which property has changed.
1853 void wpas_dbus_bss_signal_prop_changed(struct wpa_supplicant *wpa_s,
1854 enum wpas_dbus_bss_prop property,
1857 char path[WPAS_DBUS_OBJECT_PATH_MAX];
1861 case WPAS_DBUS_BSS_PROP_SIGNAL:
1864 case WPAS_DBUS_BSS_PROP_FREQ:
1867 case WPAS_DBUS_BSS_PROP_MODE:
1870 case WPAS_DBUS_BSS_PROP_PRIVACY:
1873 case WPAS_DBUS_BSS_PROP_RATES:
1876 case WPAS_DBUS_BSS_PROP_WPA:
1879 case WPAS_DBUS_BSS_PROP_RSN:
1882 case WPAS_DBUS_BSS_PROP_WPS:
1885 case WPAS_DBUS_BSS_PROP_IES:
1888 case WPAS_DBUS_BSS_PROP_AGE:
1892 wpa_printf(MSG_ERROR, "dbus: %s: Unknown Property value %d",
1893 __func__, property);
1897 os_snprintf(path, WPAS_DBUS_OBJECT_PATH_MAX,
1898 "%s/" WPAS_DBUS_NEW_BSSIDS_PART "/%u",
1899 wpa_s->dbus_new_path, id);
1901 wpa_dbus_mark_property_changed(wpa_s->global->dbus, path,
1902 WPAS_DBUS_NEW_IFACE_BSS, prop);
1907 * wpas_dbus_signal_debug_level_changed - Signals change of debug param
1908 * @global: wpa_global structure
1910 * Sends PropertyChanged signals informing that debug level has changed.
1912 void wpas_dbus_signal_debug_level_changed(struct wpa_global *global)
1914 wpa_dbus_mark_property_changed(global->dbus, WPAS_DBUS_NEW_PATH,
1915 WPAS_DBUS_NEW_INTERFACE,
1921 * wpas_dbus_signal_debug_timestamp_changed - Signals change of debug param
1922 * @global: wpa_global structure
1924 * Sends PropertyChanged signals informing that debug timestamp has changed.
1926 void wpas_dbus_signal_debug_timestamp_changed(struct wpa_global *global)
1928 wpa_dbus_mark_property_changed(global->dbus, WPAS_DBUS_NEW_PATH,
1929 WPAS_DBUS_NEW_INTERFACE,
1935 * wpas_dbus_signal_debug_show_keys_changed - Signals change of debug param
1936 * @global: wpa_global structure
1938 * Sends PropertyChanged signals informing that debug show_keys has changed.
1940 void wpas_dbus_signal_debug_show_keys_changed(struct wpa_global *global)
1942 wpa_dbus_mark_property_changed(global->dbus, WPAS_DBUS_NEW_PATH,
1943 WPAS_DBUS_NEW_INTERFACE,
1948 static void wpas_dbus_register(struct wpa_dbus_object_desc *obj_desc,
1950 WPADBusArgumentFreeFunction priv_free,
1951 const struct wpa_dbus_method_desc *methods,
1952 const struct wpa_dbus_property_desc *properties,
1953 const struct wpa_dbus_signal_desc *signals)
1957 obj_desc->user_data = priv;
1958 obj_desc->user_data_free_func = priv_free;
1959 obj_desc->methods = methods;
1960 obj_desc->properties = properties;
1961 obj_desc->signals = signals;
1963 for (n = 0; properties && properties->dbus_property; properties++)
1966 obj_desc->prop_changed_flags = os_zalloc(n);
1967 if (!obj_desc->prop_changed_flags)
1968 wpa_printf(MSG_DEBUG, "dbus: %s: can't register handlers",
1973 static const struct wpa_dbus_method_desc wpas_dbus_global_methods[] = {
1974 { "CreateInterface", WPAS_DBUS_NEW_INTERFACE,
1975 (WPADBusMethodHandler) wpas_dbus_handler_create_interface,
1977 { "args", "a{sv}", ARG_IN },
1978 { "path", "o", ARG_OUT },
1982 { "RemoveInterface", WPAS_DBUS_NEW_INTERFACE,
1983 (WPADBusMethodHandler) wpas_dbus_handler_remove_interface,
1985 { "path", "o", ARG_IN },
1989 { "GetInterface", WPAS_DBUS_NEW_INTERFACE,
1990 (WPADBusMethodHandler) wpas_dbus_handler_get_interface,
1992 { "ifname", "s", ARG_IN },
1993 { "path", "o", ARG_OUT },
1997 { NULL, NULL, NULL, { END_ARGS } }
2000 static const struct wpa_dbus_property_desc wpas_dbus_global_properties[] = {
2001 { "DebugLevel", WPAS_DBUS_NEW_INTERFACE, "s",
2002 wpas_dbus_getter_debug_level,
2003 wpas_dbus_setter_debug_level
2005 { "DebugTimestamp", WPAS_DBUS_NEW_INTERFACE, "b",
2006 wpas_dbus_getter_debug_timestamp,
2007 wpas_dbus_setter_debug_timestamp
2009 { "DebugShowKeys", WPAS_DBUS_NEW_INTERFACE, "b",
2010 wpas_dbus_getter_debug_show_keys,
2011 wpas_dbus_setter_debug_show_keys
2013 { "Interfaces", WPAS_DBUS_NEW_INTERFACE, "ao",
2014 wpas_dbus_getter_interfaces,
2017 { "EapMethods", WPAS_DBUS_NEW_INTERFACE, "as",
2018 wpas_dbus_getter_eap_methods,
2021 { "Capabilities", WPAS_DBUS_NEW_INTERFACE, "as",
2022 wpas_dbus_getter_global_capabilities,
2025 #ifdef CONFIG_WIFI_DISPLAY
2026 { "WFDIEs", WPAS_DBUS_NEW_INTERFACE, "ay",
2027 wpas_dbus_getter_global_wfd_ies,
2028 wpas_dbus_setter_global_wfd_ies
2030 #endif /* CONFIG_WIFI_DISPLAY */
2031 { NULL, NULL, NULL, NULL, NULL }
2034 static const struct wpa_dbus_signal_desc wpas_dbus_global_signals[] = {
2035 { "InterfaceAdded", WPAS_DBUS_NEW_INTERFACE,
2037 { "path", "o", ARG_OUT },
2038 { "properties", "a{sv}", ARG_OUT },
2042 { "InterfaceRemoved", WPAS_DBUS_NEW_INTERFACE,
2044 { "path", "o", ARG_OUT },
2048 { "NetworkRequest", WPAS_DBUS_NEW_IFACE_INTERFACE,
2050 { "path", "o", ARG_OUT },
2051 { "field", "s", ARG_OUT },
2052 { "text", "s", ARG_OUT },
2056 /* Deprecated: use org.freedesktop.DBus.Properties.PropertiesChanged */
2057 { "PropertiesChanged", WPAS_DBUS_NEW_INTERFACE,
2059 { "properties", "a{sv}", ARG_OUT },
2063 { NULL, NULL, { END_ARGS } }
2068 * wpas_dbus_ctrl_iface_init - Initialize dbus control interface
2069 * @global: Pointer to global data from wpa_supplicant_init()
2070 * Returns: 0 on success or -1 on failure
2072 * Initialize the dbus control interface for wpa_supplicantand and start
2073 * receiving commands from external programs over the bus.
2075 int wpas_dbus_ctrl_iface_init(struct wpas_dbus_priv *priv)
2077 struct wpa_dbus_object_desc *obj_desc;
2080 obj_desc = os_zalloc(sizeof(struct wpa_dbus_object_desc));
2082 wpa_printf(MSG_ERROR,
2083 "Not enough memory to create object description");
2087 wpas_dbus_register(obj_desc, priv->global, NULL,
2088 wpas_dbus_global_methods,
2089 wpas_dbus_global_properties,
2090 wpas_dbus_global_signals);
2092 wpa_printf(MSG_DEBUG, "dbus: Register D-Bus object '%s'",
2093 WPAS_DBUS_NEW_PATH);
2094 ret = wpa_dbus_ctrl_iface_init(priv, WPAS_DBUS_NEW_PATH,
2095 WPAS_DBUS_NEW_SERVICE,
2098 free_dbus_object_desc(obj_desc);
2100 priv->dbus_new_initialized = 1;
2107 * wpas_dbus_ctrl_iface_deinit - Deinitialize dbus ctrl interface for
2109 * @iface: Pointer to dbus private data from wpas_dbus_init()
2111 * Deinitialize the dbus control interface that was initialized with
2112 * wpas_dbus_ctrl_iface_init().
2114 void wpas_dbus_ctrl_iface_deinit(struct wpas_dbus_priv *iface)
2116 if (!iface->dbus_new_initialized)
2118 wpa_printf(MSG_DEBUG, "dbus: Unregister D-Bus object '%s'",
2119 WPAS_DBUS_NEW_PATH);
2120 dbus_connection_unregister_object_path(iface->con,
2121 WPAS_DBUS_NEW_PATH);
2125 static void wpa_dbus_free(void *ptr)
2131 static const struct wpa_dbus_property_desc wpas_dbus_network_properties[] = {
2132 { "Properties", WPAS_DBUS_NEW_IFACE_NETWORK, "a{sv}",
2133 wpas_dbus_getter_network_properties,
2134 wpas_dbus_setter_network_properties
2136 { "Enabled", WPAS_DBUS_NEW_IFACE_NETWORK, "b",
2137 wpas_dbus_getter_enabled,
2138 wpas_dbus_setter_enabled
2140 { NULL, NULL, NULL, NULL, NULL }
2144 static const struct wpa_dbus_signal_desc wpas_dbus_network_signals[] = {
2145 /* Deprecated: use org.freedesktop.DBus.Properties.PropertiesChanged */
2146 { "PropertiesChanged", WPAS_DBUS_NEW_IFACE_NETWORK,
2148 { "properties", "a{sv}", ARG_OUT },
2152 { NULL, NULL, { END_ARGS } }
2157 * wpas_dbus_register_network - Register a configured network with dbus
2158 * @wpa_s: wpa_supplicant interface structure
2159 * @ssid: network configuration data
2160 * Returns: 0 on success, -1 on failure
2162 * Registers network representing object with dbus
2164 int wpas_dbus_register_network(struct wpa_supplicant *wpa_s,
2165 struct wpa_ssid *ssid)
2167 struct wpas_dbus_priv *ctrl_iface;
2168 struct wpa_dbus_object_desc *obj_desc;
2169 struct network_handler_args *arg;
2170 char net_obj_path[WPAS_DBUS_OBJECT_PATH_MAX];
2174 * If it is a persistent group register it as such.
2175 * This is to handle cases where an interface is being initialized
2176 * with a list of networks read from config.
2178 if (network_is_persistent_group(ssid))
2179 return wpas_dbus_register_persistent_group(wpa_s, ssid);
2180 #endif /* CONFIG_P2P */
2182 /* Do nothing if the control interface is not turned on */
2183 if (wpa_s == NULL || wpa_s->global == NULL)
2185 ctrl_iface = wpa_s->global->dbus;
2186 if (ctrl_iface == NULL)
2189 os_snprintf(net_obj_path, WPAS_DBUS_OBJECT_PATH_MAX,
2190 "%s/" WPAS_DBUS_NEW_NETWORKS_PART "/%u",
2191 wpa_s->dbus_new_path, ssid->id);
2193 wpa_printf(MSG_DEBUG, "dbus: Register network object '%s'",
2195 obj_desc = os_zalloc(sizeof(struct wpa_dbus_object_desc));
2197 wpa_printf(MSG_ERROR,
2198 "Not enough memory to create object description");
2202 /* allocate memory for handlers arguments */
2203 arg = os_zalloc(sizeof(struct network_handler_args));
2205 wpa_printf(MSG_ERROR,
2206 "Not enough memory to create arguments for method");
2213 wpas_dbus_register(obj_desc, arg, wpa_dbus_free, NULL,
2214 wpas_dbus_network_properties,
2215 wpas_dbus_network_signals);
2217 if (wpa_dbus_register_object_per_iface(ctrl_iface, net_obj_path,
2218 wpa_s->ifname, obj_desc))
2221 wpas_dbus_signal_network_added(wpa_s, ssid->id);
2226 free_dbus_object_desc(obj_desc);
2232 * wpas_dbus_unregister_network - Unregister a configured network from dbus
2233 * @wpa_s: wpa_supplicant interface structure
2235 * Returns: 0 on success, -1 on failure
2237 * Unregisters network representing object from dbus
2239 int wpas_dbus_unregister_network(struct wpa_supplicant *wpa_s, int nid)
2241 struct wpas_dbus_priv *ctrl_iface;
2242 char net_obj_path[WPAS_DBUS_OBJECT_PATH_MAX];
2245 struct wpa_ssid *ssid;
2247 ssid = wpa_config_get_network(wpa_s->conf, nid);
2249 /* If it is a persistent group unregister it as such */
2250 if (ssid && network_is_persistent_group(ssid))
2251 return wpas_dbus_unregister_persistent_group(wpa_s, nid);
2252 #endif /* CONFIG_P2P */
2254 /* Do nothing if the control interface is not turned on */
2255 if (wpa_s->global == NULL || wpa_s->dbus_new_path == NULL)
2257 ctrl_iface = wpa_s->global->dbus;
2258 if (ctrl_iface == NULL)
2261 os_snprintf(net_obj_path, WPAS_DBUS_OBJECT_PATH_MAX,
2262 "%s/" WPAS_DBUS_NEW_NETWORKS_PART "/%u",
2263 wpa_s->dbus_new_path, nid);
2265 wpa_printf(MSG_DEBUG, "dbus: Unregister network object '%s'",
2267 ret = wpa_dbus_unregister_object_per_iface(ctrl_iface, net_obj_path);
2270 wpas_dbus_signal_network_removed(wpa_s, nid);
2276 static const struct wpa_dbus_property_desc wpas_dbus_bss_properties[] = {
2277 { "SSID", WPAS_DBUS_NEW_IFACE_BSS, "ay",
2278 wpas_dbus_getter_bss_ssid,
2281 { "BSSID", WPAS_DBUS_NEW_IFACE_BSS, "ay",
2282 wpas_dbus_getter_bss_bssid,
2285 { "Privacy", WPAS_DBUS_NEW_IFACE_BSS, "b",
2286 wpas_dbus_getter_bss_privacy,
2289 { "Mode", WPAS_DBUS_NEW_IFACE_BSS, "s",
2290 wpas_dbus_getter_bss_mode,
2293 { "Signal", WPAS_DBUS_NEW_IFACE_BSS, "n",
2294 wpas_dbus_getter_bss_signal,
2297 { "Frequency", WPAS_DBUS_NEW_IFACE_BSS, "q",
2298 wpas_dbus_getter_bss_frequency,
2301 { "Rates", WPAS_DBUS_NEW_IFACE_BSS, "au",
2302 wpas_dbus_getter_bss_rates,
2305 { "WPA", WPAS_DBUS_NEW_IFACE_BSS, "a{sv}",
2306 wpas_dbus_getter_bss_wpa,
2309 { "RSN", WPAS_DBUS_NEW_IFACE_BSS, "a{sv}",
2310 wpas_dbus_getter_bss_rsn,
2313 { "WPS", WPAS_DBUS_NEW_IFACE_BSS, "a{sv}",
2314 wpas_dbus_getter_bss_wps,
2317 { "IEs", WPAS_DBUS_NEW_IFACE_BSS, "ay",
2318 wpas_dbus_getter_bss_ies,
2321 { "Age", WPAS_DBUS_NEW_IFACE_BSS, "u",
2322 wpas_dbus_getter_bss_age,
2325 { NULL, NULL, NULL, NULL, NULL }
2329 static const struct wpa_dbus_signal_desc wpas_dbus_bss_signals[] = {
2330 /* Deprecated: use org.freedesktop.DBus.Properties.PropertiesChanged */
2331 { "PropertiesChanged", WPAS_DBUS_NEW_IFACE_BSS,
2333 { "properties", "a{sv}", ARG_OUT },
2337 { NULL, NULL, { END_ARGS } }
2342 * wpas_dbus_unregister_bss - Unregister a scanned BSS from dbus
2343 * @wpa_s: wpa_supplicant interface structure
2344 * @bssid: scanned network bssid
2345 * @id: unique BSS identifier
2346 * Returns: 0 on success, -1 on failure
2348 * Unregisters BSS representing object from dbus
2350 int wpas_dbus_unregister_bss(struct wpa_supplicant *wpa_s,
2351 u8 bssid[ETH_ALEN], unsigned int id)
2353 struct wpas_dbus_priv *ctrl_iface;
2354 char bss_obj_path[WPAS_DBUS_OBJECT_PATH_MAX];
2356 /* Do nothing if the control interface is not turned on */
2357 if (wpa_s == NULL || wpa_s->global == NULL)
2359 ctrl_iface = wpa_s->global->dbus;
2360 if (ctrl_iface == NULL)
2363 os_snprintf(bss_obj_path, WPAS_DBUS_OBJECT_PATH_MAX,
2364 "%s/" WPAS_DBUS_NEW_BSSIDS_PART "/%u",
2365 wpa_s->dbus_new_path, id);
2367 wpa_printf(MSG_DEBUG, "dbus: Unregister BSS object '%s'",
2369 if (wpa_dbus_unregister_object_per_iface(ctrl_iface, bss_obj_path)) {
2370 wpa_printf(MSG_ERROR, "dbus: Cannot unregister BSS object %s",
2375 wpas_dbus_signal_bss_removed(wpa_s, bss_obj_path);
2376 wpas_dbus_signal_prop_changed(wpa_s, WPAS_DBUS_PROP_BSSS);
2383 * wpas_dbus_register_bss - Register a scanned BSS with dbus
2384 * @wpa_s: wpa_supplicant interface structure
2385 * @bssid: scanned network bssid
2386 * @id: unique BSS identifier
2387 * Returns: 0 on success, -1 on failure
2389 * Registers BSS representing object with dbus
2391 int wpas_dbus_register_bss(struct wpa_supplicant *wpa_s,
2392 u8 bssid[ETH_ALEN], unsigned int id)
2394 struct wpas_dbus_priv *ctrl_iface;
2395 struct wpa_dbus_object_desc *obj_desc;
2396 char bss_obj_path[WPAS_DBUS_OBJECT_PATH_MAX];
2397 struct bss_handler_args *arg;
2399 /* Do nothing if the control interface is not turned on */
2400 if (wpa_s == NULL || wpa_s->global == NULL)
2402 ctrl_iface = wpa_s->global->dbus;
2403 if (ctrl_iface == NULL)
2406 os_snprintf(bss_obj_path, WPAS_DBUS_OBJECT_PATH_MAX,
2407 "%s/" WPAS_DBUS_NEW_BSSIDS_PART "/%u",
2408 wpa_s->dbus_new_path, id);
2410 obj_desc = os_zalloc(sizeof(struct wpa_dbus_object_desc));
2412 wpa_printf(MSG_ERROR,
2413 "Not enough memory to create object description");
2417 arg = os_zalloc(sizeof(struct bss_handler_args));
2419 wpa_printf(MSG_ERROR,
2420 "Not enough memory to create arguments for handler");
2426 wpas_dbus_register(obj_desc, arg, wpa_dbus_free, NULL,
2427 wpas_dbus_bss_properties,
2428 wpas_dbus_bss_signals);
2430 wpa_printf(MSG_DEBUG, "dbus: Register BSS object '%s'",
2432 if (wpa_dbus_register_object_per_iface(ctrl_iface, bss_obj_path,
2433 wpa_s->ifname, obj_desc)) {
2434 wpa_printf(MSG_ERROR,
2435 "Cannot register BSSID dbus object %s.",
2440 wpas_dbus_signal_bss_added(wpa_s, bss_obj_path);
2441 wpas_dbus_signal_prop_changed(wpa_s, WPAS_DBUS_PROP_BSSS);
2446 free_dbus_object_desc(obj_desc);
2451 static const struct wpa_dbus_method_desc wpas_dbus_interface_methods[] = {
2452 { "Scan", WPAS_DBUS_NEW_IFACE_INTERFACE,
2453 (WPADBusMethodHandler) wpas_dbus_handler_scan,
2455 { "args", "a{sv}", ARG_IN },
2459 { "SignalPoll", WPAS_DBUS_NEW_IFACE_INTERFACE,
2460 (WPADBusMethodHandler) wpas_dbus_handler_signal_poll,
2462 { "args", "a{sv}", ARG_OUT },
2466 { "Disconnect", WPAS_DBUS_NEW_IFACE_INTERFACE,
2467 (WPADBusMethodHandler) wpas_dbus_handler_disconnect,
2472 { "AddNetwork", WPAS_DBUS_NEW_IFACE_INTERFACE,
2473 (WPADBusMethodHandler) wpas_dbus_handler_add_network,
2475 { "args", "a{sv}", ARG_IN },
2476 { "path", "o", ARG_OUT },
2480 { "Reassociate", WPAS_DBUS_NEW_IFACE_INTERFACE,
2481 (WPADBusMethodHandler) wpas_dbus_handler_reassociate,
2486 { "Reattach", WPAS_DBUS_NEW_IFACE_INTERFACE,
2487 (WPADBusMethodHandler) wpas_dbus_handler_reattach,
2492 { "RemoveNetwork", WPAS_DBUS_NEW_IFACE_INTERFACE,
2493 (WPADBusMethodHandler) wpas_dbus_handler_remove_network,
2495 { "path", "o", ARG_IN },
2499 { "RemoveAllNetworks", WPAS_DBUS_NEW_IFACE_INTERFACE,
2500 (WPADBusMethodHandler) wpas_dbus_handler_remove_all_networks,
2505 { "SelectNetwork", WPAS_DBUS_NEW_IFACE_INTERFACE,
2506 (WPADBusMethodHandler) wpas_dbus_handler_select_network,
2508 { "path", "o", ARG_IN },
2512 { "NetworkReply", WPAS_DBUS_NEW_IFACE_INTERFACE,
2513 (WPADBusMethodHandler) wpas_dbus_handler_network_reply,
2515 { "path", "o", ARG_IN },
2516 { "field", "s", ARG_IN },
2517 { "value", "s", ARG_IN },
2521 #ifndef CONFIG_NO_CONFIG_BLOBS
2522 { "AddBlob", WPAS_DBUS_NEW_IFACE_INTERFACE,
2523 (WPADBusMethodHandler) wpas_dbus_handler_add_blob,
2525 { "name", "s", ARG_IN },
2526 { "data", "ay", ARG_IN },
2530 { "GetBlob", WPAS_DBUS_NEW_IFACE_INTERFACE,
2531 (WPADBusMethodHandler) wpas_dbus_handler_get_blob,
2533 { "name", "s", ARG_IN },
2534 { "data", "ay", ARG_OUT },
2538 { "RemoveBlob", WPAS_DBUS_NEW_IFACE_INTERFACE,
2539 (WPADBusMethodHandler) wpas_dbus_handler_remove_blob,
2541 { "name", "s", ARG_IN },
2545 #endif /* CONFIG_NO_CONFIG_BLOBS */
2546 { "SetPKCS11EngineAndModulePath", WPAS_DBUS_NEW_IFACE_INTERFACE,
2547 (WPADBusMethodHandler)
2548 wpas_dbus_handler_set_pkcs11_engine_and_module_path,
2550 { "pkcs11_engine_path", "s", ARG_IN },
2551 { "pkcs11_module_path", "s", ARG_IN },
2556 { "Start", WPAS_DBUS_NEW_IFACE_WPS,
2557 (WPADBusMethodHandler) wpas_dbus_handler_wps_start,
2559 { "args", "a{sv}", ARG_IN },
2560 { "output", "a{sv}", ARG_OUT },
2564 #endif /* CONFIG_WPS */
2566 { "Find", WPAS_DBUS_NEW_IFACE_P2PDEVICE,
2567 (WPADBusMethodHandler) wpas_dbus_handler_p2p_find,
2569 { "args", "a{sv}", ARG_IN },
2573 { "StopFind", WPAS_DBUS_NEW_IFACE_P2PDEVICE,
2574 (WPADBusMethodHandler) wpas_dbus_handler_p2p_stop_find,
2579 { "Listen", WPAS_DBUS_NEW_IFACE_P2PDEVICE,
2580 (WPADBusMethodHandler) wpas_dbus_handler_p2p_listen,
2582 { "timeout", "i", ARG_IN },
2586 { "ExtendedListen", WPAS_DBUS_NEW_IFACE_P2PDEVICE,
2587 (WPADBusMethodHandler) wpas_dbus_handler_p2p_extendedlisten,
2589 { "args", "a{sv}", ARG_IN },
2593 { "PresenceRequest", WPAS_DBUS_NEW_IFACE_P2PDEVICE,
2594 (WPADBusMethodHandler) wpas_dbus_handler_p2p_presence_request,
2596 { "args", "a{sv}", ARG_IN },
2600 { "ProvisionDiscoveryRequest", WPAS_DBUS_NEW_IFACE_P2PDEVICE,
2601 (WPADBusMethodHandler) wpas_dbus_handler_p2p_prov_disc_req,
2603 { "peer", "o", ARG_IN },
2604 { "config_method", "s", ARG_IN },
2608 { "Connect", WPAS_DBUS_NEW_IFACE_P2PDEVICE,
2609 (WPADBusMethodHandler) wpas_dbus_handler_p2p_connect,
2611 { "args", "a{sv}", ARG_IN },
2612 { "generated_pin", "s", ARG_OUT },
2616 { "GroupAdd", WPAS_DBUS_NEW_IFACE_P2PDEVICE,
2617 (WPADBusMethodHandler) wpas_dbus_handler_p2p_group_add,
2619 { "args", "a{sv}", ARG_IN },
2623 { "Invite", WPAS_DBUS_NEW_IFACE_P2PDEVICE,
2624 (WPADBusMethodHandler) wpas_dbus_handler_p2p_invite,
2626 { "args", "a{sv}", ARG_IN },
2630 { "Disconnect", WPAS_DBUS_NEW_IFACE_P2PDEVICE,
2631 (WPADBusMethodHandler) wpas_dbus_handler_p2p_disconnect,
2636 { "RejectPeer", WPAS_DBUS_NEW_IFACE_P2PDEVICE,
2637 (WPADBusMethodHandler) wpas_dbus_handler_p2p_rejectpeer,
2639 { "peer", "o", ARG_IN },
2643 { "Flush", WPAS_DBUS_NEW_IFACE_P2PDEVICE,
2644 (WPADBusMethodHandler) wpas_dbus_handler_p2p_flush,
2649 { "AddService", WPAS_DBUS_NEW_IFACE_P2PDEVICE,
2650 (WPADBusMethodHandler) wpas_dbus_handler_p2p_add_service,
2652 { "args", "a{sv}", ARG_IN },
2656 { "DeleteService", WPAS_DBUS_NEW_IFACE_P2PDEVICE,
2657 (WPADBusMethodHandler) wpas_dbus_handler_p2p_delete_service,
2659 { "args", "a{sv}", ARG_IN },
2663 { "FlushService", WPAS_DBUS_NEW_IFACE_P2PDEVICE,
2664 (WPADBusMethodHandler) wpas_dbus_handler_p2p_flush_service,
2669 { "ServiceDiscoveryRequest", WPAS_DBUS_NEW_IFACE_P2PDEVICE,
2670 (WPADBusMethodHandler) wpas_dbus_handler_p2p_service_sd_req,
2672 { "args", "a{sv}", ARG_IN },
2673 { "ref", "t", ARG_OUT },
2677 { "ServiceDiscoveryResponse", WPAS_DBUS_NEW_IFACE_P2PDEVICE,
2678 (WPADBusMethodHandler) wpas_dbus_handler_p2p_service_sd_res,
2680 { "args", "a{sv}", ARG_IN },
2684 { "ServiceDiscoveryCancelRequest", WPAS_DBUS_NEW_IFACE_P2PDEVICE,
2685 (WPADBusMethodHandler) wpas_dbus_handler_p2p_service_sd_cancel_req,
2687 { "args", "t", ARG_IN },
2691 { "ServiceUpdate", WPAS_DBUS_NEW_IFACE_P2PDEVICE,
2692 (WPADBusMethodHandler) wpas_dbus_handler_p2p_service_update,
2697 { "ServiceDiscoveryExternal", WPAS_DBUS_NEW_IFACE_P2PDEVICE,
2698 (WPADBusMethodHandler) wpas_dbus_handler_p2p_serv_disc_external,
2700 { "arg", "i", ARG_IN },
2704 { "AddPersistentGroup", WPAS_DBUS_NEW_IFACE_P2PDEVICE,
2705 (WPADBusMethodHandler) wpas_dbus_handler_add_persistent_group,
2707 { "args", "a{sv}", ARG_IN },
2708 { "path", "o", ARG_OUT },
2712 { "RemovePersistentGroup", WPAS_DBUS_NEW_IFACE_P2PDEVICE,
2713 (WPADBusMethodHandler) wpas_dbus_handler_remove_persistent_group,
2715 { "path", "o", ARG_IN },
2719 { "RemoveAllPersistentGroups", WPAS_DBUS_NEW_IFACE_P2PDEVICE,
2720 (WPADBusMethodHandler)
2721 wpas_dbus_handler_remove_all_persistent_groups,
2726 #endif /* CONFIG_P2P */
2727 { "FlushBSS", WPAS_DBUS_NEW_IFACE_INTERFACE,
2728 (WPADBusMethodHandler) wpas_dbus_handler_flush_bss,
2730 { "age", "u", ARG_IN },
2735 { "SubscribeProbeReq", WPAS_DBUS_NEW_IFACE_INTERFACE,
2736 (WPADBusMethodHandler) wpas_dbus_handler_subscribe_preq,
2741 { "UnsubscribeProbeReq", WPAS_DBUS_NEW_IFACE_INTERFACE,
2742 (WPADBusMethodHandler) wpas_dbus_handler_unsubscribe_preq,
2747 #endif /* CONFIG_AP */
2748 { "EAPLogoff", WPAS_DBUS_NEW_IFACE_INTERFACE,
2749 (WPADBusMethodHandler) wpas_dbus_handler_eap_logoff,
2754 { "EAPLogon", WPAS_DBUS_NEW_IFACE_INTERFACE,
2755 (WPADBusMethodHandler) wpas_dbus_handler_eap_logon,
2760 #ifdef CONFIG_AUTOSCAN
2761 { "AutoScan", WPAS_DBUS_NEW_IFACE_INTERFACE,
2762 (WPADBusMethodHandler) wpas_dbus_handler_autoscan,
2764 { "arg", "s", ARG_IN },
2768 #endif /* CONFIG_AUTOSCAN */
2770 { "TDLSDiscover", WPAS_DBUS_NEW_IFACE_INTERFACE,
2771 (WPADBusMethodHandler) wpas_dbus_handler_tdls_discover,
2773 { "peer_address", "s", ARG_IN },
2777 { "TDLSSetup", WPAS_DBUS_NEW_IFACE_INTERFACE,
2778 (WPADBusMethodHandler) wpas_dbus_handler_tdls_setup,
2780 { "peer_address", "s", ARG_IN },
2784 { "TDLSStatus", WPAS_DBUS_NEW_IFACE_INTERFACE,
2785 (WPADBusMethodHandler) wpas_dbus_handler_tdls_status,
2787 { "peer_address", "s", ARG_IN },
2788 { "status", "s", ARG_OUT },
2792 { "TDLSTeardown", WPAS_DBUS_NEW_IFACE_INTERFACE,
2793 (WPADBusMethodHandler) wpas_dbus_handler_tdls_teardown,
2795 { "peer_address", "s", ARG_IN },
2799 #endif /* CONFIG_TDLS */
2800 { NULL, NULL, NULL, { END_ARGS } }
2803 static const struct wpa_dbus_property_desc wpas_dbus_interface_properties[] = {
2804 { "Capabilities", WPAS_DBUS_NEW_IFACE_INTERFACE, "a{sv}",
2805 wpas_dbus_getter_capabilities,
2808 { "State", WPAS_DBUS_NEW_IFACE_INTERFACE, "s",
2809 wpas_dbus_getter_state,
2812 { "Scanning", WPAS_DBUS_NEW_IFACE_INTERFACE, "b",
2813 wpas_dbus_getter_scanning,
2816 { "ApScan", WPAS_DBUS_NEW_IFACE_INTERFACE, "u",
2817 wpas_dbus_getter_ap_scan,
2818 wpas_dbus_setter_ap_scan
2820 { "BSSExpireAge", WPAS_DBUS_NEW_IFACE_INTERFACE, "u",
2821 wpas_dbus_getter_bss_expire_age,
2822 wpas_dbus_setter_bss_expire_age
2824 { "BSSExpireCount", WPAS_DBUS_NEW_IFACE_INTERFACE, "u",
2825 wpas_dbus_getter_bss_expire_count,
2826 wpas_dbus_setter_bss_expire_count
2828 { "Country", WPAS_DBUS_NEW_IFACE_INTERFACE, "s",
2829 wpas_dbus_getter_country,
2830 wpas_dbus_setter_country
2832 { "Ifname", WPAS_DBUS_NEW_IFACE_INTERFACE, "s",
2833 wpas_dbus_getter_ifname,
2836 { "Driver", WPAS_DBUS_NEW_IFACE_INTERFACE, "s",
2837 wpas_dbus_getter_driver,
2840 { "BridgeIfname", WPAS_DBUS_NEW_IFACE_INTERFACE, "s",
2841 wpas_dbus_getter_bridge_ifname,
2844 { "CurrentBSS", WPAS_DBUS_NEW_IFACE_INTERFACE, "o",
2845 wpas_dbus_getter_current_bss,
2848 { "CurrentNetwork", WPAS_DBUS_NEW_IFACE_INTERFACE, "o",
2849 wpas_dbus_getter_current_network,
2852 { "CurrentAuthMode", WPAS_DBUS_NEW_IFACE_INTERFACE, "s",
2853 wpas_dbus_getter_current_auth_mode,
2856 { "Blobs", WPAS_DBUS_NEW_IFACE_INTERFACE, "a{say}",
2857 wpas_dbus_getter_blobs,
2860 { "BSSs", WPAS_DBUS_NEW_IFACE_INTERFACE, "ao",
2861 wpas_dbus_getter_bsss,
2864 { "Networks", WPAS_DBUS_NEW_IFACE_INTERFACE, "ao",
2865 wpas_dbus_getter_networks,
2868 { "FastReauth", WPAS_DBUS_NEW_IFACE_INTERFACE, "b",
2869 wpas_dbus_getter_fast_reauth,
2870 wpas_dbus_setter_fast_reauth
2872 { "ScanInterval", WPAS_DBUS_NEW_IFACE_INTERFACE, "i",
2873 wpas_dbus_getter_scan_interval,
2874 wpas_dbus_setter_scan_interval
2876 { "PKCS11EnginePath", WPAS_DBUS_NEW_IFACE_INTERFACE, "s",
2877 wpas_dbus_getter_pkcs11_engine_path,
2880 { "PKCS11ModulePath", WPAS_DBUS_NEW_IFACE_INTERFACE, "s",
2881 wpas_dbus_getter_pkcs11_module_path,
2885 { "ProcessCredentials", WPAS_DBUS_NEW_IFACE_WPS, "b",
2886 wpas_dbus_getter_process_credentials,
2887 wpas_dbus_setter_process_credentials
2889 { "ConfigMethods", WPAS_DBUS_NEW_IFACE_WPS, "s",
2890 wpas_dbus_getter_config_methods,
2891 wpas_dbus_setter_config_methods
2893 #endif /* CONFIG_WPS */
2895 { "P2PDeviceConfig", WPAS_DBUS_NEW_IFACE_P2PDEVICE, "a{sv}",
2896 wpas_dbus_getter_p2p_device_config,
2897 wpas_dbus_setter_p2p_device_config
2899 { "Peers", WPAS_DBUS_NEW_IFACE_P2PDEVICE, "ao",
2900 wpas_dbus_getter_p2p_peers,
2903 { "Role", WPAS_DBUS_NEW_IFACE_P2PDEVICE, "s",
2904 wpas_dbus_getter_p2p_role,
2907 { "Group", WPAS_DBUS_NEW_IFACE_P2PDEVICE, "o",
2908 wpas_dbus_getter_p2p_group,
2911 { "PeerGO", WPAS_DBUS_NEW_IFACE_P2PDEVICE, "o",
2912 wpas_dbus_getter_p2p_peergo,
2915 { "PersistentGroups", WPAS_DBUS_NEW_IFACE_P2PDEVICE, "ao",
2916 wpas_dbus_getter_persistent_groups,
2919 #endif /* CONFIG_P2P */
2920 { "DisconnectReason", WPAS_DBUS_NEW_IFACE_INTERFACE, "i",
2921 wpas_dbus_getter_disconnect_reason,
2924 { NULL, NULL, NULL, NULL, NULL }
2927 static const struct wpa_dbus_signal_desc wpas_dbus_interface_signals[] = {
2928 { "ScanDone", WPAS_DBUS_NEW_IFACE_INTERFACE,
2930 { "success", "b", ARG_OUT },
2934 { "BSSAdded", WPAS_DBUS_NEW_IFACE_INTERFACE,
2936 { "path", "o", ARG_OUT },
2937 { "properties", "a{sv}", ARG_OUT },
2941 { "BSSRemoved", WPAS_DBUS_NEW_IFACE_INTERFACE,
2943 { "path", "o", ARG_OUT },
2947 { "BlobAdded", WPAS_DBUS_NEW_IFACE_INTERFACE,
2949 { "name", "s", ARG_OUT },
2953 { "BlobRemoved", WPAS_DBUS_NEW_IFACE_INTERFACE,
2955 { "name", "s", ARG_OUT },
2959 { "NetworkAdded", WPAS_DBUS_NEW_IFACE_INTERFACE,
2961 { "path", "o", ARG_OUT },
2962 { "properties", "a{sv}", ARG_OUT },
2966 { "NetworkRemoved", WPAS_DBUS_NEW_IFACE_INTERFACE,
2968 { "path", "o", ARG_OUT },
2972 { "NetworkSelected", WPAS_DBUS_NEW_IFACE_INTERFACE,
2974 { "path", "o", ARG_OUT },
2978 /* Deprecated: use org.freedesktop.DBus.Properties.PropertiesChanged */
2979 { "PropertiesChanged", WPAS_DBUS_NEW_IFACE_INTERFACE,
2981 { "properties", "a{sv}", ARG_OUT },
2986 { "Event", WPAS_DBUS_NEW_IFACE_WPS,
2988 { "name", "s", ARG_OUT },
2989 { "args", "a{sv}", ARG_OUT },
2993 { "Credentials", WPAS_DBUS_NEW_IFACE_WPS,
2995 { "credentials", "a{sv}", ARG_OUT },
2999 /* Deprecated: use org.freedesktop.DBus.Properties.PropertiesChanged */
3000 { "PropertiesChanged", WPAS_DBUS_NEW_IFACE_WPS,
3002 { "properties", "a{sv}", ARG_OUT },
3006 #endif /* CONFIG_WPS */
3008 { "P2PStateChanged", WPAS_DBUS_NEW_IFACE_P2PDEVICE,
3010 { "states", "a{ss}", ARG_OUT },
3014 { "DeviceFound", WPAS_DBUS_NEW_IFACE_P2PDEVICE,
3016 { "path", "o", ARG_OUT },
3020 { "DeviceLost", WPAS_DBUS_NEW_IFACE_P2PDEVICE,
3022 { "path", "o", ARG_OUT },
3026 { "ProvisionDiscoveryRequestDisplayPin", WPAS_DBUS_NEW_IFACE_P2PDEVICE,
3028 { "peer_object", "o", ARG_OUT },
3029 { "pin", "s", ARG_OUT },
3033 { "ProvisionDiscoveryResponseDisplayPin", WPAS_DBUS_NEW_IFACE_P2PDEVICE,
3035 { "peer_object", "o", ARG_OUT },
3036 { "pin", "s", ARG_OUT },
3040 { "ProvisionDiscoveryRequestEnterPin", WPAS_DBUS_NEW_IFACE_P2PDEVICE,
3042 { "peer_object", "o", ARG_OUT },
3046 { "ProvisionDiscoveryResponseEnterPin", WPAS_DBUS_NEW_IFACE_P2PDEVICE,
3048 { "peer_object", "o", ARG_OUT },
3052 { "ProvisionDiscoveryPBCRequest", WPAS_DBUS_NEW_IFACE_P2PDEVICE,
3054 { "peer_object", "o", ARG_OUT },
3058 { "ProvisionDiscoveryPBCResponse", WPAS_DBUS_NEW_IFACE_P2PDEVICE,
3060 { "peer_object", "o", ARG_OUT },
3064 { "ProvisionDiscoveryFailure", WPAS_DBUS_NEW_IFACE_P2PDEVICE,
3066 { "peer_object", "o", ARG_OUT },
3067 { "status", "i", ARG_OUT },
3071 { "GroupStarted", WPAS_DBUS_NEW_IFACE_P2PDEVICE,
3073 { "properties", "a{sv}", ARG_OUT },
3077 { "GONegotiationSuccess", WPAS_DBUS_NEW_IFACE_P2PDEVICE,
3079 { "properties", "a{sv}", ARG_OUT },
3083 { "GONegotiationFailure", WPAS_DBUS_NEW_IFACE_P2PDEVICE,
3085 { "properties", "a{sv}", ARG_OUT },
3089 { "GONegotiationRequest", WPAS_DBUS_NEW_IFACE_P2PDEVICE,
3091 { "path", "o", ARG_OUT },
3092 { "dev_passwd_id", "i", ARG_OUT },
3096 { "InvitationResult", WPAS_DBUS_NEW_IFACE_P2PDEVICE,
3098 { "invite_result", "a{sv}", ARG_OUT },
3102 { "GroupFinished", WPAS_DBUS_NEW_IFACE_P2PDEVICE,
3104 { "properties", "a{sv}", ARG_OUT },
3108 { "ServiceDiscoveryRequest", WPAS_DBUS_NEW_IFACE_P2PDEVICE,
3110 { "sd_request", "a{sv}", ARG_OUT },
3114 { "ServiceDiscoveryResponse", WPAS_DBUS_NEW_IFACE_P2PDEVICE,
3116 { "sd_response", "a{sv}", ARG_OUT },
3120 { "PersistentGroupAdded", WPAS_DBUS_NEW_IFACE_P2PDEVICE,
3122 { "path", "o", ARG_OUT },
3123 { "properties", "a{sv}", ARG_OUT },
3127 { "PersistentGroupRemoved", WPAS_DBUS_NEW_IFACE_P2PDEVICE,
3129 { "path", "o", ARG_OUT },
3133 { "WpsFailed", WPAS_DBUS_NEW_IFACE_P2PDEVICE,
3135 { "name", "s", ARG_OUT },
3136 { "args", "a{sv}", ARG_OUT },
3140 #endif /* CONFIG_P2P */
3142 { "ProbeRequest", WPAS_DBUS_NEW_IFACE_INTERFACE,
3144 { "args", "a{sv}", ARG_OUT },
3148 #endif /* CONFIG_AP */
3149 { "Certification", WPAS_DBUS_NEW_IFACE_INTERFACE,
3151 { "certification", "a{sv}", ARG_OUT },
3155 { "EAP", WPAS_DBUS_NEW_IFACE_INTERFACE,
3157 { "status", "s", ARG_OUT },
3158 { "parameter", "s", ARG_OUT },
3162 { "StaAuthorized", WPAS_DBUS_NEW_IFACE_INTERFACE,
3164 { "name", "s", ARG_OUT },
3168 { "StaDeauthorized", WPAS_DBUS_NEW_IFACE_INTERFACE,
3170 { "name", "s", ARG_OUT },
3174 { NULL, NULL, { END_ARGS } }
3178 int wpas_dbus_register_interface(struct wpa_supplicant *wpa_s)
3181 struct wpa_dbus_object_desc *obj_desc = NULL;
3182 struct wpas_dbus_priv *ctrl_iface = wpa_s->global->dbus;
3185 /* Do nothing if the control interface is not turned on */
3186 if (ctrl_iface == NULL)
3189 /* Create and set the interface's object path */
3190 wpa_s->dbus_new_path = os_zalloc(WPAS_DBUS_OBJECT_PATH_MAX);
3191 if (wpa_s->dbus_new_path == NULL)
3193 next = ctrl_iface->next_objid++;
3194 os_snprintf(wpa_s->dbus_new_path, WPAS_DBUS_OBJECT_PATH_MAX,
3195 WPAS_DBUS_NEW_PATH_INTERFACES "/%u",
3198 obj_desc = os_zalloc(sizeof(struct wpa_dbus_object_desc));
3200 wpa_printf(MSG_ERROR,
3201 "Not enough memory to create object description");
3205 wpas_dbus_register(obj_desc, wpa_s, NULL, wpas_dbus_interface_methods,
3206 wpas_dbus_interface_properties,
3207 wpas_dbus_interface_signals);
3209 wpa_printf(MSG_DEBUG, "dbus: Register interface object '%s'",
3210 wpa_s->dbus_new_path);
3211 if (wpa_dbus_register_object_per_iface(ctrl_iface,
3212 wpa_s->dbus_new_path,
3213 wpa_s->ifname, obj_desc))
3216 wpas_dbus_signal_interface_added(wpa_s);
3221 os_free(wpa_s->dbus_new_path);
3222 wpa_s->dbus_new_path = NULL;
3223 free_dbus_object_desc(obj_desc);
3228 int wpas_dbus_unregister_interface(struct wpa_supplicant *wpa_s)
3230 struct wpas_dbus_priv *ctrl_iface;
3232 /* Do nothing if the control interface is not turned on */
3233 if (wpa_s == NULL || wpa_s->global == NULL)
3235 ctrl_iface = wpa_s->global->dbus;
3236 if (ctrl_iface == NULL)
3239 wpa_printf(MSG_DEBUG, "dbus: Unregister interface object '%s'",
3240 wpa_s->dbus_new_path);
3243 if (wpa_s->preq_notify_peer) {
3244 wpas_dbus_unsubscribe_noc(ctrl_iface);
3245 os_free(wpa_s->preq_notify_peer);
3246 wpa_s->preq_notify_peer = NULL;
3248 #endif /* CONFIG_AP */
3250 if (wpa_dbus_unregister_object_per_iface(ctrl_iface,
3251 wpa_s->dbus_new_path))
3254 wpas_dbus_signal_interface_removed(wpa_s);
3256 os_free(wpa_s->dbus_new_path);
3257 wpa_s->dbus_new_path = NULL;
3264 static const struct wpa_dbus_property_desc wpas_dbus_p2p_peer_properties[] = {
3265 { "DeviceName", WPAS_DBUS_NEW_IFACE_P2P_PEER, "s",
3266 wpas_dbus_getter_p2p_peer_device_name,
3269 { "PrimaryDeviceType", WPAS_DBUS_NEW_IFACE_P2P_PEER, "ay",
3270 wpas_dbus_getter_p2p_peer_primary_device_type,
3273 { "config_method", WPAS_DBUS_NEW_IFACE_P2P_PEER, "q",
3274 wpas_dbus_getter_p2p_peer_config_method,
3277 { "level", WPAS_DBUS_NEW_IFACE_P2P_PEER, "i",
3278 wpas_dbus_getter_p2p_peer_level,
3281 { "devicecapability", WPAS_DBUS_NEW_IFACE_P2P_PEER, "y",
3282 wpas_dbus_getter_p2p_peer_device_capability,
3285 { "groupcapability", WPAS_DBUS_NEW_IFACE_P2P_PEER, "y",
3286 wpas_dbus_getter_p2p_peer_group_capability,
3289 { "SecondaryDeviceTypes", WPAS_DBUS_NEW_IFACE_P2P_PEER, "aay",
3290 wpas_dbus_getter_p2p_peer_secondary_device_types,
3293 { "VendorExtension", WPAS_DBUS_NEW_IFACE_P2P_PEER, "aay",
3294 wpas_dbus_getter_p2p_peer_vendor_extension,
3297 { "IEs", WPAS_DBUS_NEW_IFACE_P2P_PEER, "ay",
3298 wpas_dbus_getter_p2p_peer_ies,
3301 { "DeviceAddress", WPAS_DBUS_NEW_IFACE_P2P_PEER, "ay",
3302 wpas_dbus_getter_p2p_peer_device_address,
3305 { "Groups", WPAS_DBUS_NEW_IFACE_P2P_PEER, "ao",
3306 wpas_dbus_getter_p2p_peer_groups,
3309 { NULL, NULL, NULL, NULL, NULL }
3312 static const struct wpa_dbus_signal_desc wpas_dbus_p2p_peer_signals[] = {
3313 /* Deprecated: use org.freedesktop.DBus.Properties.PropertiesChanged */
3314 { "PropertiesChanged", WPAS_DBUS_NEW_IFACE_P2P_PEER,
3316 { "properties", "a{sv}", ARG_OUT },
3320 { NULL, NULL, { END_ARGS } }
3324 * wpas_dbus_signal_peer - Send a peer related event signal
3325 * @wpa_s: %wpa_supplicant network interface data
3326 * @dev: peer device object
3327 * @interface: name of the interface emitting this signal.
3328 * In case of peer objects, it would be emitted by either
3329 * the "interface object" or by "peer objects"
3330 * @sig_name: signal name - DeviceFound
3332 * Notify listeners about event related with newly found p2p peer device
3334 static void wpas_dbus_signal_peer(struct wpa_supplicant *wpa_s,
3335 const u8 *dev_addr, const char *interface,
3336 const char *sig_name)
3338 struct wpas_dbus_priv *iface;
3340 DBusMessageIter iter;
3341 char peer_obj_path[WPAS_DBUS_OBJECT_PATH_MAX], *path;
3343 if (wpa_s->p2p_mgmt)
3344 wpa_s = wpa_s->parent;
3346 iface = wpa_s->global->dbus;
3348 /* Do nothing if the control interface is not turned on */
3352 os_snprintf(peer_obj_path, WPAS_DBUS_OBJECT_PATH_MAX,
3353 "%s/" WPAS_DBUS_NEW_P2P_PEERS_PART "/" COMPACT_MACSTR,
3354 wpa_s->dbus_new_path, MAC2STR(dev_addr));
3356 msg = dbus_message_new_signal(wpa_s->dbus_new_path, interface,
3361 dbus_message_iter_init_append(msg, &iter);
3362 path = peer_obj_path;
3363 if (!dbus_message_iter_append_basic(&iter, DBUS_TYPE_OBJECT_PATH,
3365 wpa_printf(MSG_ERROR, "dbus: Failed to construct signal");
3367 dbus_connection_send(iface->con, msg, NULL);
3369 dbus_message_unref(msg);
3374 * wpas_dbus_signal_peer_found - Send a peer found signal
3375 * @wpa_s: %wpa_supplicant network interface data
3376 * @dev: peer device object
3378 * Notify listeners about find a p2p peer device found
3380 void wpas_dbus_signal_peer_device_found(struct wpa_supplicant *wpa_s,
3383 wpas_dbus_signal_peer(wpa_s, dev_addr,
3384 WPAS_DBUS_NEW_IFACE_P2PDEVICE,
3389 * wpas_dbus_signal_peer_lost - Send a peer lost signal
3390 * @wpa_s: %wpa_supplicant network interface data
3391 * @dev: peer device object
3393 * Notify listeners about lost a p2p peer device
3395 void wpas_dbus_signal_peer_device_lost(struct wpa_supplicant *wpa_s,
3398 wpas_dbus_signal_peer(wpa_s, dev_addr,
3399 WPAS_DBUS_NEW_IFACE_P2PDEVICE,
3404 * wpas_dbus_register_peer - Register a discovered peer object with dbus
3405 * @wpa_s: wpa_supplicant interface structure
3406 * @ssid: network configuration data
3407 * Returns: 0 on success, -1 on failure
3409 * Registers network representing object with dbus
3411 int wpas_dbus_register_peer(struct wpa_supplicant *wpa_s, const u8 *dev_addr)
3413 struct wpas_dbus_priv *ctrl_iface;
3414 struct wpa_dbus_object_desc *obj_desc;
3415 struct peer_handler_args *arg;
3416 char peer_obj_path[WPAS_DBUS_OBJECT_PATH_MAX];
3418 /* Do nothing if the control interface is not turned on */
3419 if (wpa_s == NULL || wpa_s->global == NULL)
3422 ctrl_iface = wpa_s->global->dbus;
3423 if (ctrl_iface == NULL)
3426 if (wpa_s->p2p_mgmt)
3427 wpa_s = wpa_s->parent;
3429 os_snprintf(peer_obj_path, WPAS_DBUS_OBJECT_PATH_MAX,
3430 "%s/" WPAS_DBUS_NEW_P2P_PEERS_PART "/" COMPACT_MACSTR,
3431 wpa_s->dbus_new_path, MAC2STR(dev_addr));
3433 wpa_printf(MSG_INFO, "dbus: Register peer object '%s'",
3435 obj_desc = os_zalloc(sizeof(struct wpa_dbus_object_desc));
3437 wpa_printf(MSG_ERROR,
3438 "Not enough memory to create object description");
3442 /* allocate memory for handlers arguments */
3443 arg = os_zalloc(sizeof(struct peer_handler_args));
3445 wpa_printf(MSG_ERROR,
3446 "Not enough memory to create arguments for method");
3451 os_memcpy(arg->p2p_device_addr, dev_addr, ETH_ALEN);
3453 wpas_dbus_register(obj_desc, arg, wpa_dbus_free,
3455 wpas_dbus_p2p_peer_properties,
3456 wpas_dbus_p2p_peer_signals);
3458 if (wpa_dbus_register_object_per_iface(ctrl_iface, peer_obj_path,
3459 wpa_s->ifname, obj_desc))
3465 free_dbus_object_desc(obj_desc);
3470 * wpas_dbus_unregister_peer - Unregister a peer object with dbus
3471 * @wpa_s: wpa_supplicant interface structure
3472 * @dev_addr: p2p device addr
3473 * Returns: 0 on success, -1 on failure
3475 * Registers network representing object with dbus
3477 int wpas_dbus_unregister_peer(struct wpa_supplicant *wpa_s,
3480 struct wpas_dbus_priv *ctrl_iface;
3481 char peer_obj_path[WPAS_DBUS_OBJECT_PATH_MAX];
3484 /* Do nothing if the control interface is not turned on */
3485 if (wpa_s == NULL || wpa_s->global == NULL ||
3486 wpa_s->dbus_new_path == NULL)
3489 if (wpa_s->p2p_mgmt)
3490 wpa_s = wpa_s->parent;
3492 ctrl_iface = wpa_s->global->dbus;
3493 if (ctrl_iface == NULL)
3496 os_snprintf(peer_obj_path, WPAS_DBUS_OBJECT_PATH_MAX,
3497 "%s/" WPAS_DBUS_NEW_P2P_PEERS_PART "/" COMPACT_MACSTR,
3498 wpa_s->dbus_new_path, MAC2STR(dev_addr));
3500 wpa_printf(MSG_INFO, "dbus: Unregister peer object '%s'",
3502 ret = wpa_dbus_unregister_object_per_iface(ctrl_iface, peer_obj_path);
3508 void wpas_dbus_signal_peer_groups_changed(struct wpa_supplicant *wpa_s,
3511 char peer_obj_path[WPAS_DBUS_OBJECT_PATH_MAX];
3513 if (wpa_s->p2p_mgmt)
3514 wpa_s = wpa_s->parent;
3516 os_snprintf(peer_obj_path, WPAS_DBUS_OBJECT_PATH_MAX,
3517 "%s/" WPAS_DBUS_NEW_P2P_PEERS_PART "/" COMPACT_MACSTR,
3518 wpa_s->dbus_new_path, MAC2STR(dev_addr));
3520 wpa_dbus_mark_property_changed(wpa_s->global->dbus, peer_obj_path,
3521 WPAS_DBUS_NEW_IFACE_P2P_PEER, "Groups");
3525 static const struct wpa_dbus_property_desc wpas_dbus_p2p_group_properties[] = {
3526 { "Members", WPAS_DBUS_NEW_IFACE_P2P_GROUP, "ao",
3527 wpas_dbus_getter_p2p_group_members,
3530 { "Group", WPAS_DBUS_NEW_IFACE_P2P_GROUP, "o",
3531 wpas_dbus_getter_p2p_group,
3534 { "Role", WPAS_DBUS_NEW_IFACE_P2P_GROUP, "s",
3535 wpas_dbus_getter_p2p_role,
3538 { "SSID", WPAS_DBUS_NEW_IFACE_P2P_GROUP, "ay",
3539 wpas_dbus_getter_p2p_group_ssid,
3542 { "BSSID", WPAS_DBUS_NEW_IFACE_P2P_GROUP, "ay",
3543 wpas_dbus_getter_p2p_group_bssid,
3546 { "Frequency", WPAS_DBUS_NEW_IFACE_P2P_GROUP, "q",
3547 wpas_dbus_getter_p2p_group_frequency,
3550 { "Passphrase", WPAS_DBUS_NEW_IFACE_P2P_GROUP, "s",
3551 wpas_dbus_getter_p2p_group_passphrase,
3554 { "PSK", WPAS_DBUS_NEW_IFACE_P2P_GROUP, "ay",
3555 wpas_dbus_getter_p2p_group_psk,
3558 { "WPSVendorExtensions", WPAS_DBUS_NEW_IFACE_P2P_GROUP, "aay",
3559 wpas_dbus_getter_p2p_group_vendor_ext,
3560 wpas_dbus_setter_p2p_group_vendor_ext
3562 { NULL, NULL, NULL, NULL, NULL }
3565 static const struct wpa_dbus_signal_desc wpas_dbus_p2p_group_signals[] = {
3566 { "PeerJoined", WPAS_DBUS_NEW_IFACE_P2P_GROUP,
3568 { "peer", "o", ARG_OUT },
3572 { "PeerDisconnected", WPAS_DBUS_NEW_IFACE_P2P_GROUP,
3574 { "peer", "o", ARG_OUT },
3578 { NULL, NULL, { END_ARGS } }
3582 * wpas_dbus_register_p2p_group - Register a p2p group object with dbus
3583 * @wpa_s: wpa_supplicant interface structure
3584 * @ssid: SSID struct
3585 * Returns: 0 on success, -1 on failure
3587 * Registers p2p group representing object with dbus
3589 void wpas_dbus_register_p2p_group(struct wpa_supplicant *wpa_s,
3590 struct wpa_ssid *ssid)
3592 struct wpas_dbus_priv *ctrl_iface;
3593 struct wpa_dbus_object_desc *obj_desc;
3594 char group_obj_path[WPAS_DBUS_OBJECT_PATH_MAX];
3596 /* Do nothing if the control interface is not turned on */
3597 if (wpa_s == NULL || wpa_s->global == NULL)
3600 ctrl_iface = wpa_s->global->dbus;
3601 if (ctrl_iface == NULL)
3604 if (wpa_s->dbus_groupobj_path) {
3605 wpa_printf(MSG_INFO, "%s: Group object '%s' already exists",
3606 __func__, wpa_s->dbus_groupobj_path);
3610 if (wpas_dbus_get_group_obj_path(wpa_s, ssid, group_obj_path) < 0)
3613 wpa_s->dbus_groupobj_path = os_strdup(group_obj_path);
3614 if (wpa_s->dbus_groupobj_path == NULL)
3617 wpa_printf(MSG_INFO, "dbus: Register group object '%s'",
3619 obj_desc = os_zalloc(sizeof(struct wpa_dbus_object_desc));
3621 wpa_printf(MSG_ERROR,
3622 "Not enough memory to create object description");
3626 wpas_dbus_register(obj_desc, wpa_s, NULL, NULL,
3627 wpas_dbus_p2p_group_properties,
3628 wpas_dbus_p2p_group_signals);
3630 if (wpa_dbus_register_object_per_iface(ctrl_iface, group_obj_path,
3631 wpa_s->ifname, obj_desc))
3637 if (wpa_s->dbus_groupobj_path) {
3638 os_free(wpa_s->dbus_groupobj_path);
3639 wpa_s->dbus_groupobj_path = NULL;
3642 free_dbus_object_desc(obj_desc);
3646 * wpas_dbus_unregister_p2p_group - Unregister a p2p group object from dbus
3647 * @wpa_s: wpa_supplicant interface structure
3648 * @ssid: network name of the p2p group started
3650 void wpas_dbus_unregister_p2p_group(struct wpa_supplicant *wpa_s,
3651 const struct wpa_ssid *ssid)
3653 struct wpas_dbus_priv *ctrl_iface;
3655 /* Do nothing if the control interface is not turned on */
3656 if (wpa_s == NULL || wpa_s->global == NULL)
3659 if (wpa_s->p2p_mgmt)
3660 wpa_s = wpa_s->parent;
3662 ctrl_iface = wpa_s->global->dbus;
3663 if (ctrl_iface == NULL)
3666 if (!wpa_s->dbus_groupobj_path) {
3667 wpa_printf(MSG_DEBUG,
3668 "%s: Group object '%s' already unregistered",
3669 __func__, wpa_s->dbus_groupobj_path);
3673 peer_groups_changed(wpa_s);
3675 wpa_printf(MSG_DEBUG, "dbus: Unregister group object '%s'",
3676 wpa_s->dbus_groupobj_path);
3678 wpa_dbus_unregister_object_per_iface(ctrl_iface,
3679 wpa_s->dbus_groupobj_path);
3681 os_free(wpa_s->dbus_groupobj_path);
3682 wpa_s->dbus_groupobj_path = NULL;
3685 static const struct wpa_dbus_property_desc
3686 wpas_dbus_persistent_group_properties[] = {
3687 { "Properties", WPAS_DBUS_NEW_IFACE_PERSISTENT_GROUP, "a{sv}",
3688 wpas_dbus_getter_persistent_group_properties,
3689 wpas_dbus_setter_persistent_group_properties
3691 { NULL, NULL, NULL, NULL, NULL }
3694 /* No signals intended for persistent group objects */
3697 * wpas_dbus_register_persistent_group - Register a configured(saved)
3698 * persistent group with dbus
3699 * @wpa_s: wpa_supplicant interface structure
3700 * @ssid: persistent group (still represented as a network within wpa)
3701 * configuration data
3702 * Returns: 0 on success, -1 on failure
3704 * Registers a persistent group representing object with dbus.
3706 int wpas_dbus_register_persistent_group(struct wpa_supplicant *wpa_s,
3707 struct wpa_ssid *ssid)
3709 struct wpas_dbus_priv *ctrl_iface;
3710 struct wpa_dbus_object_desc *obj_desc;
3711 struct network_handler_args *arg;
3712 char pgrp_obj_path[WPAS_DBUS_OBJECT_PATH_MAX];
3714 /* Do nothing if the control interface is not turned on */
3715 if (wpa_s == NULL || wpa_s->global == NULL)
3718 /* Make sure ssid is a persistent group */
3719 if (ssid->disabled != 2 && !ssid->p2p_persistent_group)
3720 return -1; /* should we return w/o complaining? */
3722 if (wpa_s->p2p_mgmt)
3723 wpa_s = wpa_s->parent;
3725 ctrl_iface = wpa_s->global->dbus;
3726 if (ctrl_iface == NULL)
3730 * Intentionally not coming up with different numbering scheme
3731 * for persistent groups.
3733 os_snprintf(pgrp_obj_path, WPAS_DBUS_OBJECT_PATH_MAX,
3734 "%s/" WPAS_DBUS_NEW_PERSISTENT_GROUPS_PART "/%u",
3735 wpa_s->dbus_new_path, ssid->id);
3737 wpa_printf(MSG_DEBUG, "dbus: Register persistent group object '%s'",
3739 obj_desc = os_zalloc(sizeof(struct wpa_dbus_object_desc));
3741 wpa_printf(MSG_ERROR,
3742 "dbus: Not enough memory to create object description");
3747 * Reusing the same context structure as that for networks
3748 * since these are represented using same data structure.
3750 /* allocate memory for handlers arguments */
3751 arg = os_zalloc(sizeof(struct network_handler_args));
3753 wpa_printf(MSG_ERROR,
3754 "dbus: Not enough memory to create arguments for method");
3761 wpas_dbus_register(obj_desc, arg, wpa_dbus_free, NULL,
3762 wpas_dbus_persistent_group_properties,
3765 if (wpa_dbus_register_object_per_iface(ctrl_iface, pgrp_obj_path,
3766 wpa_s->ifname, obj_desc))
3769 wpas_dbus_signal_persistent_group_added(wpa_s, ssid->id);
3774 free_dbus_object_desc(obj_desc);
3780 * wpas_dbus_unregister_persistent_group - Unregister a persistent_group
3782 * @wpa_s: wpa_supplicant interface structure
3784 * Returns: 0 on success, -1 on failure
3786 * Unregisters persistent group representing object from dbus
3788 * NOTE: There is a slight issue with the semantics here. While the
3789 * implementation simply means the persistent group is unloaded from memory,
3790 * it should not get interpreted as the group is actually being erased/removed
3791 * from persistent storage as well.
3793 int wpas_dbus_unregister_persistent_group(struct wpa_supplicant *wpa_s,
3796 struct wpas_dbus_priv *ctrl_iface;
3797 char pgrp_obj_path[WPAS_DBUS_OBJECT_PATH_MAX];
3800 /* Do nothing if the control interface is not turned on */
3801 if (wpa_s == NULL || wpa_s->global == NULL ||
3802 wpa_s->dbus_new_path == NULL)
3805 if (wpa_s->p2p_mgmt)
3806 wpa_s = wpa_s->parent;
3808 ctrl_iface = wpa_s->global->dbus;
3809 if (ctrl_iface == NULL)
3812 os_snprintf(pgrp_obj_path, WPAS_DBUS_OBJECT_PATH_MAX,
3813 "%s/" WPAS_DBUS_NEW_PERSISTENT_GROUPS_PART "/%u",
3814 wpa_s->dbus_new_path, nid);
3816 wpa_printf(MSG_DEBUG, "dbus: Unregister persistent group object '%s'",
3818 ret = wpa_dbus_unregister_object_per_iface(ctrl_iface, pgrp_obj_path);
3821 wpas_dbus_signal_persistent_group_removed(wpa_s, nid);
3826 #endif /* CONFIG_P2P */