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 */
140 if (iface == NULL || !wpa_s->dbus_new_path)
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 */
203 if (iface == NULL || !wpa_s->dbus_new_path)
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 */
242 if (iface == NULL || !wpa_s->dbus_new_path)
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 */
310 if (iface == NULL || !wpa_s->dbus_new_path)
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 */
377 if (iface == NULL || !wpa_s->dbus_new_path)
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 */
470 if (iface == NULL || !wpa_s->dbus_new_path)
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 if (!wpa_s->dbus_new_path)
516 os_snprintf(path, WPAS_DBUS_OBJECT_PATH_MAX,
517 "%s/" WPAS_DBUS_NEW_NETWORKS_PART "/%d",
518 wpa_s->dbus_new_path, ssid->id);
520 wpa_dbus_mark_property_changed(wpa_s->global->dbus, path,
521 WPAS_DBUS_NEW_IFACE_NETWORK, "Enabled");
528 * wpas_dbus_signal_wps_event_success - Signals Success WPS event
529 * @wpa_s: %wpa_supplicant network interface data
531 * Sends Event dbus signal with name "success" and empty dict as arguments
533 void wpas_dbus_signal_wps_event_success(struct wpa_supplicant *wpa_s)
537 DBusMessageIter iter, dict_iter;
538 struct wpas_dbus_priv *iface;
539 char *key = "success";
541 iface = wpa_s->global->dbus;
543 /* Do nothing if the control interface is not turned on */
544 if (iface == NULL || !wpa_s->dbus_new_path)
547 msg = dbus_message_new_signal(wpa_s->dbus_new_path,
548 WPAS_DBUS_NEW_IFACE_WPS, "Event");
552 dbus_message_iter_init_append(msg, &iter);
554 if (!dbus_message_iter_append_basic(&iter, DBUS_TYPE_STRING, &key) ||
555 !wpa_dbus_dict_open_write(&iter, &dict_iter) ||
556 !wpa_dbus_dict_close_write(&iter, &dict_iter))
557 wpa_printf(MSG_ERROR, "dbus: Failed to construct signal");
559 dbus_connection_send(iface->con, msg, NULL);
561 dbus_message_unref(msg);
566 * wpas_dbus_signal_wps_event_fail - Signals Fail WPS event
567 * @wpa_s: %wpa_supplicant network interface data
569 * Sends Event dbus signal with name "fail" and dictionary containing
570 * "msg field with fail message number (int32) as arguments
572 void wpas_dbus_signal_wps_event_fail(struct wpa_supplicant *wpa_s,
573 struct wps_event_fail *fail)
577 DBusMessageIter iter, dict_iter;
578 struct wpas_dbus_priv *iface;
581 iface = wpa_s->global->dbus;
583 /* Do nothing if the control interface is not turned on */
584 if (iface == NULL || !wpa_s->dbus_new_path)
587 msg = dbus_message_new_signal(wpa_s->dbus_new_path,
588 WPAS_DBUS_NEW_IFACE_WPS, "Event");
592 dbus_message_iter_init_append(msg, &iter);
594 if (!dbus_message_iter_append_basic(&iter, DBUS_TYPE_STRING, &key) ||
595 !wpa_dbus_dict_open_write(&iter, &dict_iter) ||
596 !wpa_dbus_dict_append_int32(&dict_iter, "msg", fail->msg) ||
597 !wpa_dbus_dict_close_write(&iter, &dict_iter))
598 wpa_printf(MSG_ERROR, "dbus: Failed to construct signal");
600 dbus_connection_send(iface->con, msg, NULL);
602 dbus_message_unref(msg);
607 * wpas_dbus_signal_wps_event_m2d - Signals M2D WPS event
608 * @wpa_s: %wpa_supplicant network interface data
610 * Sends Event dbus signal with name "m2d" and dictionary containing
611 * fields of wps_event_m2d structure.
613 void wpas_dbus_signal_wps_event_m2d(struct wpa_supplicant *wpa_s,
614 struct wps_event_m2d *m2d)
618 DBusMessageIter iter, dict_iter;
619 struct wpas_dbus_priv *iface;
622 iface = wpa_s->global->dbus;
624 /* Do nothing if the control interface is not turned on */
625 if (iface == NULL || !wpa_s->dbus_new_path)
628 msg = dbus_message_new_signal(wpa_s->dbus_new_path,
629 WPAS_DBUS_NEW_IFACE_WPS, "Event");
633 dbus_message_iter_init_append(msg, &iter);
635 if (!dbus_message_iter_append_basic(&iter, DBUS_TYPE_STRING, &key) ||
636 !wpa_dbus_dict_open_write(&iter, &dict_iter) ||
637 !wpa_dbus_dict_append_uint16(&dict_iter, "config_methods",
638 m2d->config_methods) ||
639 !wpa_dbus_dict_append_byte_array(&dict_iter, "manufacturer",
640 (const char *) m2d->manufacturer,
641 m2d->manufacturer_len) ||
642 !wpa_dbus_dict_append_byte_array(&dict_iter, "model_name",
643 (const char *) m2d->model_name,
644 m2d->model_name_len) ||
645 !wpa_dbus_dict_append_byte_array(&dict_iter, "model_number",
646 (const char *) m2d->model_number,
647 m2d->model_number_len) ||
648 !wpa_dbus_dict_append_byte_array(&dict_iter, "serial_number",
651 m2d->serial_number_len) ||
652 !wpa_dbus_dict_append_byte_array(&dict_iter, "dev_name",
653 (const char *) m2d->dev_name,
654 m2d->dev_name_len) ||
655 !wpa_dbus_dict_append_byte_array(&dict_iter, "primary_dev_type",
657 m2d->primary_dev_type, 8) ||
658 !wpa_dbus_dict_append_uint16(&dict_iter, "config_error",
659 m2d->config_error) ||
660 !wpa_dbus_dict_append_uint16(&dict_iter, "dev_password_id",
661 m2d->dev_password_id) ||
662 !wpa_dbus_dict_close_write(&iter, &dict_iter))
663 wpa_printf(MSG_ERROR, "dbus: Failed to construct signal");
665 dbus_connection_send(iface->con, msg, NULL);
667 dbus_message_unref(msg);
672 * wpas_dbus_signal_wps_cred - Signals new credentials
673 * @wpa_s: %wpa_supplicant network interface data
675 * Sends signal with credentials in directory argument
677 void wpas_dbus_signal_wps_cred(struct wpa_supplicant *wpa_s,
678 const struct wps_credential *cred)
681 DBusMessageIter iter, dict_iter;
682 struct wpas_dbus_priv *iface;
683 char *auth_type[5]; /* we have five possible authentication types */
685 char *encr_type[3]; /* we have three possible encryption types */
688 iface = wpa_s->global->dbus;
690 /* Do nothing if the control interface is not turned on */
691 if (iface == NULL || !wpa_s->dbus_new_path)
694 msg = dbus_message_new_signal(wpa_s->dbus_new_path,
695 WPAS_DBUS_NEW_IFACE_WPS,
700 dbus_message_iter_init_append(msg, &iter);
701 if (!wpa_dbus_dict_open_write(&iter, &dict_iter))
704 if (cred->auth_type & WPS_AUTH_OPEN)
705 auth_type[at_num++] = "open";
706 if (cred->auth_type & WPS_AUTH_WPAPSK)
707 auth_type[at_num++] = "wpa-psk";
708 if (cred->auth_type & WPS_AUTH_WPA)
709 auth_type[at_num++] = "wpa-eap";
710 if (cred->auth_type & WPS_AUTH_WPA2)
711 auth_type[at_num++] = "wpa2-eap";
712 if (cred->auth_type & WPS_AUTH_WPA2PSK)
713 auth_type[at_num++] = "wpa2-psk";
715 if (cred->encr_type & WPS_ENCR_NONE)
716 encr_type[et_num++] = "none";
717 if (cred->encr_type & WPS_ENCR_TKIP)
718 encr_type[et_num++] = "tkip";
719 if (cred->encr_type & WPS_ENCR_AES)
720 encr_type[et_num++] = "aes";
722 if ((wpa_s->current_ssid &&
723 !wpa_dbus_dict_append_byte_array(
725 (const char *) wpa_s->current_ssid->bssid, ETH_ALEN)) ||
726 !wpa_dbus_dict_append_byte_array(&dict_iter, "SSID",
727 (const char *) cred->ssid,
729 !wpa_dbus_dict_append_string_array(&dict_iter, "AuthType",
730 (const char **) auth_type,
732 !wpa_dbus_dict_append_string_array(&dict_iter, "EncrType",
733 (const char **) encr_type,
735 !wpa_dbus_dict_append_byte_array(&dict_iter, "Key",
736 (const char *) cred->key,
738 !wpa_dbus_dict_append_uint32(&dict_iter, "KeyIndex",
740 !wpa_dbus_dict_close_write(&iter, &dict_iter))
743 dbus_connection_send(iface->con, msg, NULL);
746 dbus_message_unref(msg);
749 #endif /* CONFIG_WPS */
751 void wpas_dbus_signal_certification(struct wpa_supplicant *wpa_s,
752 int depth, const char *subject,
753 const char *altsubject[],
755 const char *cert_hash,
756 const struct wpabuf *cert)
758 struct wpas_dbus_priv *iface;
760 DBusMessageIter iter, dict_iter;
762 iface = wpa_s->global->dbus;
764 /* Do nothing if the control interface is not turned on */
765 if (iface == NULL || !wpa_s->dbus_new_path)
768 msg = dbus_message_new_signal(wpa_s->dbus_new_path,
769 WPAS_DBUS_NEW_IFACE_INTERFACE,
774 dbus_message_iter_init_append(msg, &iter);
775 if (!wpa_dbus_dict_open_write(&iter, &dict_iter) ||
776 !wpa_dbus_dict_append_uint32(&dict_iter, "depth", depth) ||
777 !wpa_dbus_dict_append_string(&dict_iter, "subject", subject) ||
778 (altsubject && num_altsubject &&
779 !wpa_dbus_dict_append_string_array(&dict_iter, "altsubject",
780 altsubject, num_altsubject)) ||
782 !wpa_dbus_dict_append_string(&dict_iter, "cert_hash",
785 !wpa_dbus_dict_append_byte_array(&dict_iter, "cert",
787 wpabuf_len(cert))) ||
788 !wpa_dbus_dict_close_write(&iter, &dict_iter))
789 wpa_printf(MSG_ERROR, "dbus: Failed to construct signal");
791 dbus_connection_send(iface->con, msg, NULL);
792 dbus_message_unref(msg);
796 void wpas_dbus_signal_eap_status(struct wpa_supplicant *wpa_s,
797 const char *status, const char *parameter)
799 struct wpas_dbus_priv *iface;
801 DBusMessageIter iter;
803 iface = wpa_s->global->dbus;
805 /* Do nothing if the control interface is not turned on */
806 if (iface == NULL || !wpa_s->dbus_new_path)
809 msg = dbus_message_new_signal(wpa_s->dbus_new_path,
810 WPAS_DBUS_NEW_IFACE_INTERFACE,
815 dbus_message_iter_init_append(msg, &iter);
817 if (!dbus_message_iter_append_basic(&iter, DBUS_TYPE_STRING, &status) ||
818 !dbus_message_iter_append_basic(&iter, DBUS_TYPE_STRING,
820 wpa_printf(MSG_ERROR, "dbus: Failed to construct signal");
822 dbus_connection_send(iface->con, msg, NULL);
823 dbus_message_unref(msg);
828 * wpas_dbus_signal_sta - Send a station related event signal
829 * @wpa_s: %wpa_supplicant network interface data
830 * @sta: station mac address
831 * @sig_name: signal name - StaAuthorized or StaDeauthorized
833 * Notify listeners about event related with station
835 static void wpas_dbus_signal_sta(struct wpa_supplicant *wpa_s,
836 const u8 *sta, const char *sig_name)
838 struct wpas_dbus_priv *iface;
840 char sta_mac[WPAS_DBUS_OBJECT_PATH_MAX];
843 os_snprintf(sta_mac, WPAS_DBUS_OBJECT_PATH_MAX, MACSTR, MAC2STR(sta));
846 iface = wpa_s->global->dbus;
848 /* Do nothing if the control interface is not turned on */
849 if (iface == NULL || !wpa_s->dbus_new_path)
852 msg = dbus_message_new_signal(wpa_s->dbus_new_path,
853 WPAS_DBUS_NEW_IFACE_INTERFACE, sig_name);
857 if (dbus_message_append_args(msg, DBUS_TYPE_STRING, &dev_mac,
859 dbus_connection_send(iface->con, msg, NULL);
861 wpa_printf(MSG_ERROR, "dbus: Failed to construct signal");
862 dbus_message_unref(msg);
864 wpa_printf(MSG_DEBUG, "dbus: Station MAC address '%s' '%s'",
870 * wpas_dbus_signal_sta_authorized - Send a STA authorized signal
871 * @wpa_s: %wpa_supplicant network interface data
872 * @sta: station mac address
874 * Notify listeners a new station has been authorized
876 void wpas_dbus_signal_sta_authorized(struct wpa_supplicant *wpa_s,
879 wpas_dbus_signal_sta(wpa_s, sta, "StaAuthorized");
884 * wpas_dbus_signal_sta_deauthorized - Send a STA deauthorized signal
885 * @wpa_s: %wpa_supplicant network interface data
886 * @sta: station mac address
888 * Notify listeners a station has been deauthorized
890 void wpas_dbus_signal_sta_deauthorized(struct wpa_supplicant *wpa_s,
893 wpas_dbus_signal_sta(wpa_s, sta, "StaDeauthorized");
900 * wpas_dbus_signal_p2p_group_removed - Signals P2P group was removed
901 * @wpa_s: %wpa_supplicant network interface data
902 * @role: role of this device (client or GO)
903 * Sends signal with i/f name and role as string arguments
905 void wpas_dbus_signal_p2p_group_removed(struct wpa_supplicant *wpa_s,
909 DBusMessageIter iter, dict_iter;
910 struct wpas_dbus_priv *iface = wpa_s->global->dbus;
911 struct wpa_supplicant *parent;
913 /* Do nothing if the control interface is not turned on */
917 parent = wpa_s->parent;
918 if (parent->p2p_mgmt)
919 parent = parent->parent;
921 if (!wpa_s->dbus_groupobj_path || !wpa_s->dbus_new_path ||
922 !parent->dbus_new_path)
925 msg = dbus_message_new_signal(parent->dbus_new_path,
926 WPAS_DBUS_NEW_IFACE_P2PDEVICE,
931 dbus_message_iter_init_append(msg, &iter);
932 if (!wpa_dbus_dict_open_write(&iter, &dict_iter) ||
933 !wpa_dbus_dict_append_object_path(&dict_iter,
935 wpa_s->dbus_new_path) ||
936 !wpa_dbus_dict_append_string(&dict_iter, "role", role) ||
937 !wpa_dbus_dict_append_object_path(&dict_iter, "group_object",
938 wpa_s->dbus_groupobj_path) ||
939 !wpa_dbus_dict_close_write(&iter, &dict_iter))
940 wpa_printf(MSG_ERROR, "dbus: Failed to construct signal");
942 dbus_connection_send(iface->con, msg, NULL);
943 dbus_message_unref(msg);
948 * wpas_dbus_signal_p2p_provision_discovery - Signals various PD events
950 * @dev_addr - who sent the request or responded to our request.
951 * @request - Will be 1 if request, 0 for response.
952 * @status - valid only in case of response
953 * @config_methods - wps config methods
954 * @generated_pin - pin to be displayed in case of WPS_CONFIG_DISPLAY method
956 * Sends following provision discovery related events:
957 * ProvisionDiscoveryRequestDisplayPin
958 * ProvisionDiscoveryResponseDisplayPin
959 * ProvisionDiscoveryRequestEnterPin
960 * ProvisionDiscoveryResponseEnterPin
961 * ProvisionDiscoveryPBCRequest
962 * ProvisionDiscoveryPBCResponse
965 * ProvisionDiscoveryFailure (timeout case)
967 void wpas_dbus_signal_p2p_provision_discovery(struct wpa_supplicant *wpa_s,
968 const u8 *dev_addr, int request,
969 enum p2p_prov_disc_status status,
971 unsigned int generated_pin)
974 DBusMessageIter iter;
975 struct wpas_dbus_priv *iface;
978 char peer_obj_path[WPAS_DBUS_OBJECT_PATH_MAX], *path;
980 char pin[9], *p_pin = NULL;
982 iface = wpa_s->global->dbus;
984 /* Do nothing if the control interface is not turned on */
989 wpa_s = wpa_s->parent;
990 if (!wpa_s->dbus_new_path)
993 if (request || !status) {
994 if (config_methods & WPS_CONFIG_DISPLAY)
996 "ProvisionDiscoveryRequestDisplayPin" :
997 "ProvisionDiscoveryResponseEnterPin";
998 else if (config_methods & WPS_CONFIG_KEYPAD)
1000 "ProvisionDiscoveryRequestEnterPin" :
1001 "ProvisionDiscoveryResponseDisplayPin";
1002 else if (config_methods & WPS_CONFIG_PUSHBUTTON)
1003 _signal = request ? "ProvisionDiscoveryPBCRequest" :
1004 "ProvisionDiscoveryPBCResponse";
1006 return; /* Unknown or un-supported method */
1008 /* Explicit check for failure response */
1009 _signal = "ProvisionDiscoveryFailure";
1012 add_pin = ((request && (config_methods & WPS_CONFIG_DISPLAY)) ||
1013 (!request && !status &&
1014 (config_methods & WPS_CONFIG_KEYPAD)));
1017 os_snprintf(pin, sizeof(pin), "%08d", generated_pin);
1021 msg = dbus_message_new_signal(wpa_s->dbus_new_path,
1022 WPAS_DBUS_NEW_IFACE_P2PDEVICE, _signal);
1026 /* Check if this is a known peer */
1027 if (!p2p_peer_known(wpa_s->global->p2p, dev_addr))
1030 os_snprintf(peer_obj_path, WPAS_DBUS_OBJECT_PATH_MAX,
1031 "%s/" WPAS_DBUS_NEW_P2P_PEERS_PART "/"
1033 wpa_s->dbus_new_path, MAC2STR(dev_addr));
1035 path = peer_obj_path;
1037 dbus_message_iter_init_append(msg, &iter);
1039 if (!dbus_message_iter_append_basic(&iter,
1040 DBUS_TYPE_OBJECT_PATH,
1044 if (!request && status)
1045 /* Attach status to ProvisionDiscoveryFailure */
1046 error_ret = !dbus_message_iter_append_basic(&iter,
1050 error_ret = (add_pin &&
1051 !dbus_message_iter_append_basic(&iter,
1057 dbus_connection_send(iface->con, msg, NULL);
1059 wpa_printf(MSG_ERROR, "dbus: Failed to construct signal");
1061 dbus_message_unref(msg);
1065 void wpas_dbus_signal_p2p_go_neg_req(struct wpa_supplicant *wpa_s,
1066 const u8 *src, u16 dev_passwd_id)
1069 DBusMessageIter iter;
1070 struct wpas_dbus_priv *iface;
1071 char peer_obj_path[WPAS_DBUS_OBJECT_PATH_MAX], *path;
1073 iface = wpa_s->global->dbus;
1075 /* Do nothing if the control interface is not turned on */
1079 if (wpa_s->p2p_mgmt)
1080 wpa_s = wpa_s->parent;
1081 if (!wpa_s->dbus_new_path)
1084 os_snprintf(peer_obj_path, WPAS_DBUS_OBJECT_PATH_MAX,
1085 "%s/" WPAS_DBUS_NEW_P2P_PEERS_PART "/" COMPACT_MACSTR,
1086 wpa_s->dbus_new_path, MAC2STR(src));
1087 path = peer_obj_path;
1089 msg = dbus_message_new_signal(wpa_s->dbus_new_path,
1090 WPAS_DBUS_NEW_IFACE_P2PDEVICE,
1091 "GONegotiationRequest");
1095 dbus_message_iter_init_append(msg, &iter);
1097 if (!dbus_message_iter_append_basic(&iter, DBUS_TYPE_OBJECT_PATH,
1099 !dbus_message_iter_append_basic(&iter, DBUS_TYPE_UINT16,
1101 wpa_printf(MSG_ERROR, "dbus: Failed to construct signal");
1103 dbus_connection_send(iface->con, msg, NULL);
1105 dbus_message_unref(msg);
1109 static int wpas_dbus_get_group_obj_path(struct wpa_supplicant *wpa_s,
1110 const struct wpa_ssid *ssid,
1111 char *group_obj_path)
1115 if (!wpa_s->dbus_new_path ||
1116 os_memcmp(ssid->ssid, P2P_WILDCARD_SSID, P2P_WILDCARD_SSID_LEN))
1119 os_memcpy(group_name, ssid->ssid + P2P_WILDCARD_SSID_LEN, 2);
1120 group_name[2] = '\0';
1122 os_snprintf(group_obj_path, WPAS_DBUS_OBJECT_PATH_MAX,
1123 "%s/" WPAS_DBUS_NEW_P2P_GROUPS_PART "/%s",
1124 wpa_s->dbus_new_path, group_name);
1130 struct group_changed_data {
1131 struct wpa_supplicant *wpa_s;
1132 struct p2p_peer_info *info;
1136 static int match_group_where_peer_is_client(struct p2p_group *group,
1139 struct group_changed_data *data = user_data;
1140 const struct p2p_group_config *cfg;
1141 struct wpa_supplicant *wpa_s_go;
1143 if (!p2p_group_is_client_connected(group, data->info->p2p_device_addr))
1146 cfg = p2p_group_get_config(group);
1148 wpa_s_go = wpas_get_p2p_go_iface(data->wpa_s, cfg->ssid,
1150 if (wpa_s_go != NULL && wpa_s_go == data->wpa_s) {
1151 wpas_dbus_signal_peer_groups_changed(
1152 data->wpa_s->parent, data->info->p2p_device_addr);
1160 static void signal_peer_groups_changed(struct p2p_peer_info *info,
1163 struct group_changed_data *data = user_data;
1164 struct wpa_supplicant *wpa_s_go;
1166 wpa_s_go = wpas_get_p2p_client_iface(data->wpa_s,
1167 info->p2p_device_addr);
1168 if (wpa_s_go != NULL && wpa_s_go == data->wpa_s) {
1169 wpas_dbus_signal_peer_groups_changed(data->wpa_s->parent,
1170 info->p2p_device_addr);
1175 p2p_loop_on_all_groups(data->wpa_s->global->p2p,
1176 match_group_where_peer_is_client, data);
1181 static void peer_groups_changed(struct wpa_supplicant *wpa_s)
1183 struct group_changed_data data;
1185 os_memset(&data, 0, sizeof(data));
1188 p2p_loop_on_known_peers(wpa_s->global->p2p,
1189 signal_peer_groups_changed, &data);
1194 * wpas_dbus_signal_p2p_group_started - Signals P2P group has
1195 * started. Emitted when a group is successfully started
1196 * irrespective of the role (client/GO) of the current device
1198 * @wpa_s: %wpa_supplicant network interface data
1199 * @ssid: SSID object
1200 * @client: this device is P2P client
1201 * @network_id: network id of the group started, use instead of ssid->id
1202 * to account for persistent groups
1204 void wpas_dbus_signal_p2p_group_started(struct wpa_supplicant *wpa_s,
1205 const struct wpa_ssid *ssid,
1206 int client, int network_id)
1209 DBusMessageIter iter, dict_iter;
1210 struct wpas_dbus_priv *iface;
1211 struct wpa_supplicant *parent;
1213 parent = wpa_s->parent;
1214 if (parent->p2p_mgmt)
1215 parent = parent->parent;
1217 iface = parent->global->dbus;
1219 /* Do nothing if the control interface is not turned on */
1220 if (iface == NULL || !parent->dbus_new_path || !wpa_s->dbus_new_path)
1223 if (wpa_s->dbus_groupobj_path == NULL)
1226 /* New interface has been created for this group */
1227 msg = dbus_message_new_signal(parent->dbus_new_path,
1228 WPAS_DBUS_NEW_IFACE_P2PDEVICE,
1233 dbus_message_iter_init_append(msg, &iter);
1235 * In case the device supports creating a separate interface the
1236 * DBus client will need to know the object path for the interface
1237 * object this group was created on, so include it here.
1239 if (!wpa_dbus_dict_open_write(&iter, &dict_iter) ||
1240 !wpa_dbus_dict_append_object_path(&dict_iter,
1242 wpa_s->dbus_new_path) ||
1243 !wpa_dbus_dict_append_string(&dict_iter, "role",
1244 client ? "client" : "GO") ||
1245 !wpa_dbus_dict_append_object_path(&dict_iter, "group_object",
1246 wpa_s->dbus_groupobj_path) ||
1247 !wpa_dbus_dict_close_write(&iter, &dict_iter)) {
1248 wpa_printf(MSG_ERROR, "dbus: Failed to construct signal");
1250 dbus_connection_send(iface->con, msg, NULL);
1252 peer_groups_changed(wpa_s);
1254 dbus_message_unref(msg);
1260 * Method to emit GONegotiation Success or Failure signals based
1262 * @status: Status of the GO neg request. 0 for success, other for errors.
1264 void wpas_dbus_signal_p2p_go_neg_resp(struct wpa_supplicant *wpa_s,
1265 struct p2p_go_neg_results *res)
1268 DBusMessageIter iter, dict_iter;
1269 DBusMessageIter iter_dict_entry, iter_dict_val, iter_dict_array;
1270 struct wpas_dbus_priv *iface;
1271 char peer_obj_path[WPAS_DBUS_OBJECT_PATH_MAX], *path;
1272 dbus_int32_t freqs[P2P_MAX_CHANNELS];
1273 dbus_int32_t *f_array = freqs;
1276 iface = wpa_s->global->dbus;
1278 if (wpa_s->p2p_mgmt)
1279 wpa_s = wpa_s->parent;
1281 os_memset(freqs, 0, sizeof(freqs));
1282 /* Do nothing if the control interface is not turned on */
1283 if (iface == NULL || !wpa_s->dbus_new_path)
1286 os_snprintf(peer_obj_path, WPAS_DBUS_OBJECT_PATH_MAX,
1287 "%s/" WPAS_DBUS_NEW_P2P_PEERS_PART "/" COMPACT_MACSTR,
1288 wpa_s->dbus_new_path, MAC2STR(res->peer_device_addr));
1289 path = peer_obj_path;
1291 msg = dbus_message_new_signal(wpa_s->dbus_new_path,
1292 WPAS_DBUS_NEW_IFACE_P2PDEVICE,
1293 res->status ? "GONegotiationFailure" :
1294 "GONegotiationSuccess");
1298 dbus_message_iter_init_append(msg, &iter);
1299 if (!wpa_dbus_dict_open_write(&iter, &dict_iter) ||
1300 !wpa_dbus_dict_append_object_path(&dict_iter, "peer_object",
1302 !wpa_dbus_dict_append_int32(&dict_iter, "status", res->status))
1307 int freq_list_num = 0;
1309 if ((res->role_go &&
1310 !wpa_dbus_dict_append_string(&dict_iter, "passphrase",
1311 res->passphrase)) ||
1312 !wpa_dbus_dict_append_string(&dict_iter, "role_go",
1313 res->role_go ? "GO" :
1315 !wpa_dbus_dict_append_int32(&dict_iter, "frequency",
1317 !wpa_dbus_dict_append_byte_array(&dict_iter, "ssid",
1318 (const char *) res->ssid,
1320 !wpa_dbus_dict_append_byte_array(&dict_iter,
1323 res->peer_device_addr,
1325 !wpa_dbus_dict_append_byte_array(&dict_iter,
1326 "peer_interface_addr",
1328 res->peer_interface_addr,
1330 !wpa_dbus_dict_append_string(&dict_iter, "wps_method",
1331 p2p_wps_method_text(
1335 for (i = 0; i < P2P_MAX_CHANNELS; i++) {
1336 if (res->freq_list[i]) {
1337 freqs[i] = res->freq_list[i];
1342 if (!wpa_dbus_dict_begin_array(&dict_iter,
1344 DBUS_TYPE_INT32_AS_STRING,
1347 &iter_dict_array) ||
1348 !dbus_message_iter_append_fixed_array(&iter_dict_array,
1352 !wpa_dbus_dict_end_array(&dict_iter,
1355 &iter_dict_array) ||
1356 !wpa_dbus_dict_append_int32(&dict_iter, "persistent_group",
1357 res->persistent_group) ||
1358 !wpa_dbus_dict_append_uint32(&dict_iter,
1359 "peer_config_timeout",
1360 res->peer_config_timeout))
1364 if (!wpa_dbus_dict_close_write(&iter, &dict_iter))
1367 dbus_connection_send(iface->con, msg, NULL);
1369 dbus_message_unref(msg);
1375 * Method to emit Invitation Result signal based on status and
1377 * @status: Status of the Invite request. 0 for success, other
1379 * @bssid : Basic Service Set Identifier
1381 void wpas_dbus_signal_p2p_invitation_result(struct wpa_supplicant *wpa_s,
1382 int status, const u8 *bssid)
1385 DBusMessageIter iter, dict_iter;
1386 struct wpas_dbus_priv *iface;
1388 wpa_printf(MSG_DEBUG, "%s", __func__);
1390 iface = wpa_s->global->dbus;
1391 /* Do nothing if the control interface is not turned on */
1395 if (wpa_s->p2p_mgmt)
1396 wpa_s = wpa_s->parent;
1397 if (!wpa_s->dbus_new_path)
1400 msg = dbus_message_new_signal(wpa_s->dbus_new_path,
1401 WPAS_DBUS_NEW_IFACE_P2PDEVICE,
1402 "InvitationResult");
1407 dbus_message_iter_init_append(msg, &iter);
1408 if (!wpa_dbus_dict_open_write(&iter, &dict_iter) ||
1409 !wpa_dbus_dict_append_int32(&dict_iter, "status", status) ||
1411 !wpa_dbus_dict_append_byte_array(&dict_iter, "BSSID",
1412 (const char *) bssid,
1414 !wpa_dbus_dict_close_write(&iter, &dict_iter))
1415 wpa_printf(MSG_ERROR, "dbus: Failed to construct signal");
1417 dbus_connection_send(iface->con, msg, NULL);
1418 dbus_message_unref(msg);
1424 * Method to emit a signal for a peer joining the group.
1425 * The signal will carry path to the group member object
1426 * constructed using p2p i/f addr used for connecting.
1428 * @wpa_s: %wpa_supplicant network interface data
1429 * @peer_addr: P2P Device Address of the peer joining the group
1431 void wpas_dbus_signal_p2p_peer_joined(struct wpa_supplicant *wpa_s,
1432 const u8 *peer_addr)
1434 struct wpas_dbus_priv *iface;
1436 DBusMessageIter iter;
1437 char peer_obj_path[WPAS_DBUS_OBJECT_PATH_MAX], *path;
1438 struct wpa_supplicant *parent;
1440 iface = wpa_s->global->dbus;
1442 /* Do nothing if the control interface is not turned on */
1446 if (!wpa_s->dbus_groupobj_path)
1449 parent = wpa_s->parent;
1450 if (parent->p2p_mgmt)
1451 parent = parent->parent;
1452 if (!parent->dbus_new_path)
1455 os_snprintf(peer_obj_path, WPAS_DBUS_OBJECT_PATH_MAX,
1456 "%s/" WPAS_DBUS_NEW_P2P_PEERS_PART "/"
1458 parent->dbus_new_path, MAC2STR(peer_addr));
1460 msg = dbus_message_new_signal(wpa_s->dbus_groupobj_path,
1461 WPAS_DBUS_NEW_IFACE_P2P_GROUP,
1466 dbus_message_iter_init_append(msg, &iter);
1467 path = peer_obj_path;
1468 if (!dbus_message_iter_append_basic(&iter, DBUS_TYPE_OBJECT_PATH,
1470 wpa_printf(MSG_ERROR, "dbus: Failed to construct signal");
1472 dbus_connection_send(iface->con, msg, NULL);
1473 wpas_dbus_signal_peer_groups_changed(parent, peer_addr);
1475 dbus_message_unref(msg);
1481 * Method to emit a signal for a peer disconnecting the group.
1482 * The signal will carry path to the group member object
1483 * constructed using the P2P Device Address of the peer.
1485 * @wpa_s: %wpa_supplicant network interface data
1486 * @peer_addr: P2P Device Address of the peer joining the group
1488 void wpas_dbus_signal_p2p_peer_disconnected(struct wpa_supplicant *wpa_s,
1489 const u8 *peer_addr)
1491 struct wpas_dbus_priv *iface;
1493 DBusMessageIter iter;
1494 char peer_obj_path[WPAS_DBUS_OBJECT_PATH_MAX], *path;
1495 struct wpa_supplicant *parent;
1497 iface = wpa_s->global->dbus;
1499 /* Do nothing if the control interface is not turned on */
1503 if (!wpa_s->dbus_groupobj_path)
1506 parent = wpa_s->parent;
1507 if (parent->p2p_mgmt)
1508 parent = parent->parent;
1509 if (!parent->dbus_new_path)
1512 os_snprintf(peer_obj_path, WPAS_DBUS_OBJECT_PATH_MAX,
1513 "%s/" WPAS_DBUS_NEW_P2P_PEERS_PART "/"
1515 parent->dbus_new_path, MAC2STR(peer_addr));
1517 msg = dbus_message_new_signal(wpa_s->dbus_groupobj_path,
1518 WPAS_DBUS_NEW_IFACE_P2P_GROUP,
1519 "PeerDisconnected");
1523 dbus_message_iter_init_append(msg, &iter);
1524 path = peer_obj_path;
1525 if (!dbus_message_iter_append_basic(&iter, DBUS_TYPE_OBJECT_PATH,
1527 wpa_printf(MSG_ERROR,
1528 "dbus: Failed to construct PeerDisconnected signal");
1530 dbus_connection_send(iface->con, msg, NULL);
1531 wpas_dbus_signal_peer_groups_changed(parent, peer_addr);
1533 dbus_message_unref(msg);
1539 * Method to emit a signal for a service discovery request.
1540 * The signal will carry station address, frequency, dialog token,
1541 * update indicator and it tlvs
1543 * @wpa_s: %wpa_supplicant network interface data
1544 * @sa: station addr (p2p i/f) of the peer
1545 * @dialog_token: service discovery request dialog token
1546 * @update_indic: service discovery request update indicator
1547 * @tlvs: service discovery request genrated byte array of tlvs
1548 * @tlvs_len: service discovery request tlvs length
1550 void wpas_dbus_signal_p2p_sd_request(struct wpa_supplicant *wpa_s,
1551 int freq, const u8 *sa, u8 dialog_token,
1552 u16 update_indic, const u8 *tlvs,
1556 DBusMessageIter iter, dict_iter;
1557 struct wpas_dbus_priv *iface;
1558 char peer_obj_path[WPAS_DBUS_OBJECT_PATH_MAX], *path;
1560 iface = wpa_s->global->dbus;
1562 /* Do nothing if the control interface is not turned on */
1566 if (wpa_s->p2p_mgmt)
1567 wpa_s = wpa_s->parent;
1568 if (!wpa_s->dbus_new_path)
1571 /* Check if this is a known peer */
1572 if (!p2p_peer_known(wpa_s->global->p2p, sa))
1575 msg = dbus_message_new_signal(wpa_s->dbus_new_path,
1576 WPAS_DBUS_NEW_IFACE_P2PDEVICE,
1577 "ServiceDiscoveryRequest");
1581 os_snprintf(peer_obj_path, WPAS_DBUS_OBJECT_PATH_MAX,
1582 "%s/" WPAS_DBUS_NEW_P2P_PEERS_PART "/"
1583 COMPACT_MACSTR, wpa_s->dbus_new_path, MAC2STR(sa));
1585 path = peer_obj_path;
1587 dbus_message_iter_init_append(msg, &iter);
1588 if (!wpa_dbus_dict_open_write(&iter, &dict_iter) ||
1589 !wpa_dbus_dict_append_object_path(&dict_iter, "peer_object",
1591 !wpa_dbus_dict_append_int32(&dict_iter, "frequency", freq) ||
1592 !wpa_dbus_dict_append_int32(&dict_iter, "dialog_token",
1594 !wpa_dbus_dict_append_uint16(&dict_iter, "update_indicator",
1596 !wpa_dbus_dict_append_byte_array(&dict_iter, "tlvs",
1597 (const char *) tlvs,
1599 !wpa_dbus_dict_close_write(&iter, &dict_iter))
1600 wpa_printf(MSG_ERROR, "dbus: Failed to construct signal");
1602 dbus_connection_send(iface->con, msg, NULL);
1603 dbus_message_unref(msg);
1609 * Method to emit a signal for a service discovery response.
1610 * The signal will carry station address, update indicator and it
1613 * @wpa_s: %wpa_supplicant network interface data
1614 * @sa: station addr (p2p i/f) of the peer
1615 * @update_indic: service discovery request update indicator
1616 * @tlvs: service discovery request genrated byte array of tlvs
1617 * @tlvs_len: service discovery request tlvs length
1619 void wpas_dbus_signal_p2p_sd_response(struct wpa_supplicant *wpa_s,
1620 const u8 *sa, u16 update_indic,
1621 const u8 *tlvs, size_t tlvs_len)
1624 DBusMessageIter iter, dict_iter;
1625 struct wpas_dbus_priv *iface;
1626 char peer_obj_path[WPAS_DBUS_OBJECT_PATH_MAX], *path;
1628 iface = wpa_s->global->dbus;
1630 /* Do nothing if the control interface is not turned on */
1634 if (wpa_s->p2p_mgmt)
1635 wpa_s = wpa_s->parent;
1636 if (!wpa_s->dbus_new_path)
1639 /* Check if this is a known peer */
1640 if (!p2p_peer_known(wpa_s->global->p2p, sa))
1643 msg = dbus_message_new_signal(wpa_s->dbus_new_path,
1644 WPAS_DBUS_NEW_IFACE_P2PDEVICE,
1645 "ServiceDiscoveryResponse");
1649 os_snprintf(peer_obj_path, WPAS_DBUS_OBJECT_PATH_MAX,
1650 "%s/" WPAS_DBUS_NEW_P2P_PEERS_PART "/"
1651 COMPACT_MACSTR, wpa_s->dbus_new_path, MAC2STR(sa));
1653 path = peer_obj_path;
1655 dbus_message_iter_init_append(msg, &iter);
1656 if (!wpa_dbus_dict_open_write(&iter, &dict_iter) ||
1657 !wpa_dbus_dict_append_object_path(&dict_iter, "peer_object",
1659 !wpa_dbus_dict_append_uint16(&dict_iter, "update_indicator",
1661 !wpa_dbus_dict_append_byte_array(&dict_iter, "tlvs",
1662 (const char *) tlvs,
1664 !wpa_dbus_dict_close_write(&iter, &dict_iter))
1665 wpa_printf(MSG_ERROR, "dbus: Failed to construct signal");
1667 dbus_connection_send(iface->con, msg, NULL);
1668 dbus_message_unref(msg);
1673 * wpas_dbus_signal_persistent_group - Send a persistent group related
1675 * @wpa_s: %wpa_supplicant network interface data
1676 * @id: new persistent group id
1677 * @sig_name: signal name - PersistentGroupAdded, PersistentGroupRemoved
1678 * @properties: determines if add second argument with object properties
1680 * Notify listeners about an event related to persistent groups.
1682 static void wpas_dbus_signal_persistent_group(struct wpa_supplicant *wpa_s,
1683 int id, const char *sig_name,
1686 struct wpas_dbus_priv *iface;
1688 DBusMessageIter iter;
1689 char pgrp_obj_path[WPAS_DBUS_OBJECT_PATH_MAX], *path;
1691 iface = wpa_s->global->dbus;
1693 /* Do nothing if the control interface is not turned on */
1697 if (wpa_s->p2p_mgmt)
1698 wpa_s = wpa_s->parent;
1699 if (!wpa_s->dbus_new_path)
1702 os_snprintf(pgrp_obj_path, WPAS_DBUS_OBJECT_PATH_MAX,
1703 "%s/" WPAS_DBUS_NEW_PERSISTENT_GROUPS_PART "/%u",
1704 wpa_s->dbus_new_path, id);
1706 msg = dbus_message_new_signal(wpa_s->dbus_new_path,
1707 WPAS_DBUS_NEW_IFACE_P2PDEVICE,
1712 dbus_message_iter_init_append(msg, &iter);
1713 path = pgrp_obj_path;
1714 if (!dbus_message_iter_append_basic(&iter, DBUS_TYPE_OBJECT_PATH,
1717 !wpa_dbus_get_object_properties(
1718 iface, pgrp_obj_path,
1719 WPAS_DBUS_NEW_IFACE_PERSISTENT_GROUP, &iter)))
1720 wpa_printf(MSG_ERROR, "dbus: Failed to construct signal");
1722 dbus_connection_send(iface->con, msg, NULL);
1724 dbus_message_unref(msg);
1729 * wpas_dbus_signal_persistent_group_added - Send a persistent_group
1731 * @wpa_s: %wpa_supplicant network interface data
1732 * @id: new persistent group id
1734 * Notify listeners about addition of a new persistent group.
1736 static void wpas_dbus_signal_persistent_group_added(
1737 struct wpa_supplicant *wpa_s, int id)
1739 wpas_dbus_signal_persistent_group(wpa_s, id, "PersistentGroupAdded",
1745 * wpas_dbus_signal_persistent_group_removed - Send a persistent_group
1747 * @wpa_s: %wpa_supplicant network interface data
1748 * @id: persistent group id
1750 * Notify listeners about removal of a persistent group.
1752 static void wpas_dbus_signal_persistent_group_removed(
1753 struct wpa_supplicant *wpa_s, int id)
1755 wpas_dbus_signal_persistent_group(wpa_s, id, "PersistentGroupRemoved",
1761 * wpas_dbus_signal_p2p_wps_failed - Signals WpsFailed event
1762 * @wpa_s: %wpa_supplicant network interface data
1764 * Sends Event dbus signal with name "fail" and dictionary containing
1765 * "msg" field with fail message number (int32) as arguments
1767 void wpas_dbus_signal_p2p_wps_failed(struct wpa_supplicant *wpa_s,
1768 struct wps_event_fail *fail)
1772 DBusMessageIter iter, dict_iter;
1773 struct wpas_dbus_priv *iface;
1776 iface = wpa_s->global->dbus;
1778 /* Do nothing if the control interface is not turned on */
1782 if (wpa_s->p2p_mgmt)
1783 wpa_s = wpa_s->parent;
1785 if (!wpa_s->dbus_new_path)
1787 msg = dbus_message_new_signal(wpa_s->dbus_new_path,
1788 WPAS_DBUS_NEW_IFACE_P2PDEVICE,
1793 dbus_message_iter_init_append(msg, &iter);
1795 if (!dbus_message_iter_append_basic(&iter, DBUS_TYPE_STRING, &key) ||
1796 !wpa_dbus_dict_open_write(&iter, &dict_iter) ||
1797 !wpa_dbus_dict_append_int32(&dict_iter, "msg", fail->msg) ||
1798 !wpa_dbus_dict_append_int16(&dict_iter, "config_error",
1799 fail->config_error) ||
1800 !wpa_dbus_dict_close_write(&iter, &dict_iter))
1801 wpa_printf(MSG_ERROR, "dbus: Failed to construct signal");
1803 dbus_connection_send(iface->con, msg, NULL);
1805 dbus_message_unref(msg);
1808 #endif /* CONFIG_P2P */
1812 * wpas_dbus_signal_prop_changed - Signals change of property
1813 * @wpa_s: %wpa_supplicant network interface data
1814 * @property: indicates which property has changed
1816 * Sends PropertyChanged signals with path, interface and arguments
1817 * depending on which property has changed.
1819 void wpas_dbus_signal_prop_changed(struct wpa_supplicant *wpa_s,
1820 enum wpas_dbus_prop property)
1825 if (wpa_s->dbus_new_path == NULL)
1826 return; /* Skip signal since D-Bus setup is not yet ready */
1830 case WPAS_DBUS_PROP_AP_SCAN:
1833 case WPAS_DBUS_PROP_SCANNING:
1836 case WPAS_DBUS_PROP_STATE:
1839 case WPAS_DBUS_PROP_CURRENT_BSS:
1840 prop = "CurrentBSS";
1842 case WPAS_DBUS_PROP_CURRENT_NETWORK:
1843 prop = "CurrentNetwork";
1845 case WPAS_DBUS_PROP_BSSS:
1848 case WPAS_DBUS_PROP_CURRENT_AUTH_MODE:
1849 prop = "CurrentAuthMode";
1851 case WPAS_DBUS_PROP_DISCONNECT_REASON:
1852 prop = "DisconnectReason";
1856 wpa_printf(MSG_ERROR, "dbus: %s: Unknown Property value %d",
1857 __func__, property);
1861 wpa_dbus_mark_property_changed(wpa_s->global->dbus,
1862 wpa_s->dbus_new_path,
1863 WPAS_DBUS_NEW_IFACE_INTERFACE, prop);
1865 wpa_dbus_flush_object_changed_properties(
1866 wpa_s->global->dbus->con, wpa_s->dbus_new_path);
1872 * wpas_dbus_bss_signal_prop_changed - Signals change of BSS property
1873 * @wpa_s: %wpa_supplicant network interface data
1874 * @property: indicates which property has changed
1875 * @id: unique BSS identifier
1877 * Sends PropertyChanged signals with path, interface, and arguments depending
1878 * on which property has changed.
1880 void wpas_dbus_bss_signal_prop_changed(struct wpa_supplicant *wpa_s,
1881 enum wpas_dbus_bss_prop property,
1884 char path[WPAS_DBUS_OBJECT_PATH_MAX];
1887 if (!wpa_s->dbus_new_path)
1891 case WPAS_DBUS_BSS_PROP_SIGNAL:
1894 case WPAS_DBUS_BSS_PROP_FREQ:
1897 case WPAS_DBUS_BSS_PROP_MODE:
1900 case WPAS_DBUS_BSS_PROP_PRIVACY:
1903 case WPAS_DBUS_BSS_PROP_RATES:
1906 case WPAS_DBUS_BSS_PROP_WPA:
1909 case WPAS_DBUS_BSS_PROP_RSN:
1912 case WPAS_DBUS_BSS_PROP_WPS:
1915 case WPAS_DBUS_BSS_PROP_IES:
1918 case WPAS_DBUS_BSS_PROP_AGE:
1922 wpa_printf(MSG_ERROR, "dbus: %s: Unknown Property value %d",
1923 __func__, property);
1927 os_snprintf(path, WPAS_DBUS_OBJECT_PATH_MAX,
1928 "%s/" WPAS_DBUS_NEW_BSSIDS_PART "/%u",
1929 wpa_s->dbus_new_path, id);
1931 wpa_dbus_mark_property_changed(wpa_s->global->dbus, path,
1932 WPAS_DBUS_NEW_IFACE_BSS, prop);
1937 * wpas_dbus_signal_debug_level_changed - Signals change of debug param
1938 * @global: wpa_global structure
1940 * Sends PropertyChanged signals informing that debug level has changed.
1942 void wpas_dbus_signal_debug_level_changed(struct wpa_global *global)
1944 wpa_dbus_mark_property_changed(global->dbus, WPAS_DBUS_NEW_PATH,
1945 WPAS_DBUS_NEW_INTERFACE,
1951 * wpas_dbus_signal_debug_timestamp_changed - Signals change of debug param
1952 * @global: wpa_global structure
1954 * Sends PropertyChanged signals informing that debug timestamp has changed.
1956 void wpas_dbus_signal_debug_timestamp_changed(struct wpa_global *global)
1958 wpa_dbus_mark_property_changed(global->dbus, WPAS_DBUS_NEW_PATH,
1959 WPAS_DBUS_NEW_INTERFACE,
1965 * wpas_dbus_signal_debug_show_keys_changed - Signals change of debug param
1966 * @global: wpa_global structure
1968 * Sends PropertyChanged signals informing that debug show_keys has changed.
1970 void wpas_dbus_signal_debug_show_keys_changed(struct wpa_global *global)
1972 wpa_dbus_mark_property_changed(global->dbus, WPAS_DBUS_NEW_PATH,
1973 WPAS_DBUS_NEW_INTERFACE,
1978 static void wpas_dbus_register(struct wpa_dbus_object_desc *obj_desc,
1980 WPADBusArgumentFreeFunction priv_free,
1981 const struct wpa_dbus_method_desc *methods,
1982 const struct wpa_dbus_property_desc *properties,
1983 const struct wpa_dbus_signal_desc *signals)
1987 obj_desc->user_data = priv;
1988 obj_desc->user_data_free_func = priv_free;
1989 obj_desc->methods = methods;
1990 obj_desc->properties = properties;
1991 obj_desc->signals = signals;
1993 for (n = 0; properties && properties->dbus_property; properties++)
1996 obj_desc->prop_changed_flags = os_zalloc(n);
1997 if (!obj_desc->prop_changed_flags)
1998 wpa_printf(MSG_DEBUG, "dbus: %s: can't register handlers",
2003 static const struct wpa_dbus_method_desc wpas_dbus_global_methods[] = {
2004 { "CreateInterface", WPAS_DBUS_NEW_INTERFACE,
2005 (WPADBusMethodHandler) wpas_dbus_handler_create_interface,
2007 { "args", "a{sv}", ARG_IN },
2008 { "path", "o", ARG_OUT },
2012 { "RemoveInterface", WPAS_DBUS_NEW_INTERFACE,
2013 (WPADBusMethodHandler) wpas_dbus_handler_remove_interface,
2015 { "path", "o", ARG_IN },
2019 { "GetInterface", WPAS_DBUS_NEW_INTERFACE,
2020 (WPADBusMethodHandler) wpas_dbus_handler_get_interface,
2022 { "ifname", "s", ARG_IN },
2023 { "path", "o", ARG_OUT },
2027 { NULL, NULL, NULL, { END_ARGS } }
2030 static const struct wpa_dbus_property_desc wpas_dbus_global_properties[] = {
2031 { "DebugLevel", WPAS_DBUS_NEW_INTERFACE, "s",
2032 wpas_dbus_getter_debug_level,
2033 wpas_dbus_setter_debug_level
2035 { "DebugTimestamp", WPAS_DBUS_NEW_INTERFACE, "b",
2036 wpas_dbus_getter_debug_timestamp,
2037 wpas_dbus_setter_debug_timestamp
2039 { "DebugShowKeys", WPAS_DBUS_NEW_INTERFACE, "b",
2040 wpas_dbus_getter_debug_show_keys,
2041 wpas_dbus_setter_debug_show_keys
2043 { "Interfaces", WPAS_DBUS_NEW_INTERFACE, "ao",
2044 wpas_dbus_getter_interfaces,
2047 { "EapMethods", WPAS_DBUS_NEW_INTERFACE, "as",
2048 wpas_dbus_getter_eap_methods,
2051 { "Capabilities", WPAS_DBUS_NEW_INTERFACE, "as",
2052 wpas_dbus_getter_global_capabilities,
2055 #ifdef CONFIG_WIFI_DISPLAY
2056 { "WFDIEs", WPAS_DBUS_NEW_INTERFACE, "ay",
2057 wpas_dbus_getter_global_wfd_ies,
2058 wpas_dbus_setter_global_wfd_ies
2060 #endif /* CONFIG_WIFI_DISPLAY */
2061 { NULL, NULL, NULL, NULL, NULL }
2064 static const struct wpa_dbus_signal_desc wpas_dbus_global_signals[] = {
2065 { "InterfaceAdded", WPAS_DBUS_NEW_INTERFACE,
2067 { "path", "o", ARG_OUT },
2068 { "properties", "a{sv}", ARG_OUT },
2072 { "InterfaceRemoved", WPAS_DBUS_NEW_INTERFACE,
2074 { "path", "o", ARG_OUT },
2078 /* Deprecated: use org.freedesktop.DBus.Properties.PropertiesChanged */
2079 { "PropertiesChanged", WPAS_DBUS_NEW_INTERFACE,
2081 { "properties", "a{sv}", ARG_OUT },
2085 { NULL, NULL, { END_ARGS } }
2090 * wpas_dbus_ctrl_iface_init - Initialize dbus control interface
2091 * @global: Pointer to global data from wpa_supplicant_init()
2092 * Returns: 0 on success or -1 on failure
2094 * Initialize the dbus control interface for wpa_supplicantand and start
2095 * receiving commands from external programs over the bus.
2097 int wpas_dbus_ctrl_iface_init(struct wpas_dbus_priv *priv)
2099 struct wpa_dbus_object_desc *obj_desc;
2102 obj_desc = os_zalloc(sizeof(struct wpa_dbus_object_desc));
2104 wpa_printf(MSG_ERROR,
2105 "Not enough memory to create object description");
2109 wpas_dbus_register(obj_desc, priv->global, NULL,
2110 wpas_dbus_global_methods,
2111 wpas_dbus_global_properties,
2112 wpas_dbus_global_signals);
2114 wpa_printf(MSG_DEBUG, "dbus: Register D-Bus object '%s'",
2115 WPAS_DBUS_NEW_PATH);
2116 ret = wpa_dbus_ctrl_iface_init(priv, WPAS_DBUS_NEW_PATH,
2117 WPAS_DBUS_NEW_SERVICE,
2120 free_dbus_object_desc(obj_desc);
2122 priv->dbus_new_initialized = 1;
2129 * wpas_dbus_ctrl_iface_deinit - Deinitialize dbus ctrl interface for
2131 * @iface: Pointer to dbus private data from wpas_dbus_init()
2133 * Deinitialize the dbus control interface that was initialized with
2134 * wpas_dbus_ctrl_iface_init().
2136 void wpas_dbus_ctrl_iface_deinit(struct wpas_dbus_priv *iface)
2138 if (!iface->dbus_new_initialized)
2140 wpa_printf(MSG_DEBUG, "dbus: Unregister D-Bus object '%s'",
2141 WPAS_DBUS_NEW_PATH);
2142 dbus_connection_unregister_object_path(iface->con,
2143 WPAS_DBUS_NEW_PATH);
2147 static void wpa_dbus_free(void *ptr)
2153 static const struct wpa_dbus_property_desc wpas_dbus_network_properties[] = {
2154 { "Properties", WPAS_DBUS_NEW_IFACE_NETWORK, "a{sv}",
2155 wpas_dbus_getter_network_properties,
2156 wpas_dbus_setter_network_properties
2158 { "Enabled", WPAS_DBUS_NEW_IFACE_NETWORK, "b",
2159 wpas_dbus_getter_enabled,
2160 wpas_dbus_setter_enabled
2162 { NULL, NULL, NULL, NULL, NULL }
2166 static const struct wpa_dbus_signal_desc wpas_dbus_network_signals[] = {
2167 /* Deprecated: use org.freedesktop.DBus.Properties.PropertiesChanged */
2168 { "PropertiesChanged", WPAS_DBUS_NEW_IFACE_NETWORK,
2170 { "properties", "a{sv}", ARG_OUT },
2174 { NULL, NULL, { END_ARGS } }
2179 * wpas_dbus_register_network - Register a configured network with dbus
2180 * @wpa_s: wpa_supplicant interface structure
2181 * @ssid: network configuration data
2182 * Returns: 0 on success, -1 on failure
2184 * Registers network representing object with dbus
2186 int wpas_dbus_register_network(struct wpa_supplicant *wpa_s,
2187 struct wpa_ssid *ssid)
2189 struct wpas_dbus_priv *ctrl_iface;
2190 struct wpa_dbus_object_desc *obj_desc;
2191 struct network_handler_args *arg;
2192 char net_obj_path[WPAS_DBUS_OBJECT_PATH_MAX];
2196 * If it is a persistent group register it as such.
2197 * This is to handle cases where an interface is being initialized
2198 * with a list of networks read from config.
2200 if (network_is_persistent_group(ssid))
2201 return wpas_dbus_register_persistent_group(wpa_s, ssid);
2202 #endif /* CONFIG_P2P */
2204 /* Do nothing if the control interface is not turned on */
2205 if (wpa_s == NULL || wpa_s->global == NULL || !wpa_s->dbus_new_path)
2207 ctrl_iface = wpa_s->global->dbus;
2208 if (ctrl_iface == NULL)
2211 os_snprintf(net_obj_path, WPAS_DBUS_OBJECT_PATH_MAX,
2212 "%s/" WPAS_DBUS_NEW_NETWORKS_PART "/%u",
2213 wpa_s->dbus_new_path, ssid->id);
2215 wpa_printf(MSG_DEBUG, "dbus: Register network object '%s'",
2217 obj_desc = os_zalloc(sizeof(struct wpa_dbus_object_desc));
2219 wpa_printf(MSG_ERROR,
2220 "Not enough memory to create object description");
2224 /* allocate memory for handlers arguments */
2225 arg = os_zalloc(sizeof(struct network_handler_args));
2227 wpa_printf(MSG_ERROR,
2228 "Not enough memory to create arguments for method");
2235 wpas_dbus_register(obj_desc, arg, wpa_dbus_free, NULL,
2236 wpas_dbus_network_properties,
2237 wpas_dbus_network_signals);
2239 if (wpa_dbus_register_object_per_iface(ctrl_iface, net_obj_path,
2240 wpa_s->ifname, obj_desc))
2243 wpas_dbus_signal_network_added(wpa_s, ssid->id);
2248 free_dbus_object_desc(obj_desc);
2254 * wpas_dbus_unregister_network - Unregister a configured network from dbus
2255 * @wpa_s: wpa_supplicant interface structure
2257 * Returns: 0 on success, -1 on failure
2259 * Unregisters network representing object from dbus
2261 int wpas_dbus_unregister_network(struct wpa_supplicant *wpa_s, int nid)
2263 struct wpas_dbus_priv *ctrl_iface;
2264 char net_obj_path[WPAS_DBUS_OBJECT_PATH_MAX];
2267 struct wpa_ssid *ssid;
2269 ssid = wpa_config_get_network(wpa_s->conf, nid);
2271 /* If it is a persistent group unregister it as such */
2272 if (ssid && network_is_persistent_group(ssid))
2273 return wpas_dbus_unregister_persistent_group(wpa_s, nid);
2274 #endif /* CONFIG_P2P */
2276 /* Do nothing if the control interface is not turned on */
2277 if (wpa_s->global == NULL || wpa_s->dbus_new_path == NULL)
2279 ctrl_iface = wpa_s->global->dbus;
2280 if (ctrl_iface == NULL)
2283 os_snprintf(net_obj_path, WPAS_DBUS_OBJECT_PATH_MAX,
2284 "%s/" WPAS_DBUS_NEW_NETWORKS_PART "/%u",
2285 wpa_s->dbus_new_path, nid);
2287 wpa_printf(MSG_DEBUG, "dbus: Unregister network object '%s'",
2289 ret = wpa_dbus_unregister_object_per_iface(ctrl_iface, net_obj_path);
2292 wpas_dbus_signal_network_removed(wpa_s, nid);
2298 static const struct wpa_dbus_property_desc wpas_dbus_bss_properties[] = {
2299 { "SSID", WPAS_DBUS_NEW_IFACE_BSS, "ay",
2300 wpas_dbus_getter_bss_ssid,
2303 { "BSSID", WPAS_DBUS_NEW_IFACE_BSS, "ay",
2304 wpas_dbus_getter_bss_bssid,
2307 { "Privacy", WPAS_DBUS_NEW_IFACE_BSS, "b",
2308 wpas_dbus_getter_bss_privacy,
2311 { "Mode", WPAS_DBUS_NEW_IFACE_BSS, "s",
2312 wpas_dbus_getter_bss_mode,
2315 { "Signal", WPAS_DBUS_NEW_IFACE_BSS, "n",
2316 wpas_dbus_getter_bss_signal,
2319 { "Frequency", WPAS_DBUS_NEW_IFACE_BSS, "q",
2320 wpas_dbus_getter_bss_frequency,
2323 { "Rates", WPAS_DBUS_NEW_IFACE_BSS, "au",
2324 wpas_dbus_getter_bss_rates,
2327 { "WPA", WPAS_DBUS_NEW_IFACE_BSS, "a{sv}",
2328 wpas_dbus_getter_bss_wpa,
2331 { "RSN", WPAS_DBUS_NEW_IFACE_BSS, "a{sv}",
2332 wpas_dbus_getter_bss_rsn,
2335 { "WPS", WPAS_DBUS_NEW_IFACE_BSS, "a{sv}",
2336 wpas_dbus_getter_bss_wps,
2339 { "IEs", WPAS_DBUS_NEW_IFACE_BSS, "ay",
2340 wpas_dbus_getter_bss_ies,
2343 { "Age", WPAS_DBUS_NEW_IFACE_BSS, "u",
2344 wpas_dbus_getter_bss_age,
2347 { NULL, NULL, NULL, NULL, NULL }
2351 static const struct wpa_dbus_signal_desc wpas_dbus_bss_signals[] = {
2352 /* Deprecated: use org.freedesktop.DBus.Properties.PropertiesChanged */
2353 { "PropertiesChanged", WPAS_DBUS_NEW_IFACE_BSS,
2355 { "properties", "a{sv}", ARG_OUT },
2359 { NULL, NULL, { END_ARGS } }
2364 * wpas_dbus_unregister_bss - Unregister a scanned BSS from dbus
2365 * @wpa_s: wpa_supplicant interface structure
2366 * @bssid: scanned network bssid
2367 * @id: unique BSS identifier
2368 * Returns: 0 on success, -1 on failure
2370 * Unregisters BSS representing object from dbus
2372 int wpas_dbus_unregister_bss(struct wpa_supplicant *wpa_s,
2373 u8 bssid[ETH_ALEN], unsigned int id)
2375 struct wpas_dbus_priv *ctrl_iface;
2376 char bss_obj_path[WPAS_DBUS_OBJECT_PATH_MAX];
2378 /* Do nothing if the control interface is not turned on */
2379 if (wpa_s == NULL || wpa_s->global == NULL || !wpa_s->dbus_new_path)
2381 ctrl_iface = wpa_s->global->dbus;
2382 if (ctrl_iface == NULL)
2385 os_snprintf(bss_obj_path, WPAS_DBUS_OBJECT_PATH_MAX,
2386 "%s/" WPAS_DBUS_NEW_BSSIDS_PART "/%u",
2387 wpa_s->dbus_new_path, id);
2389 wpa_printf(MSG_DEBUG, "dbus: Unregister BSS object '%s'",
2391 if (wpa_dbus_unregister_object_per_iface(ctrl_iface, bss_obj_path)) {
2392 wpa_printf(MSG_ERROR, "dbus: Cannot unregister BSS object %s",
2397 wpas_dbus_signal_bss_removed(wpa_s, bss_obj_path);
2398 wpas_dbus_signal_prop_changed(wpa_s, WPAS_DBUS_PROP_BSSS);
2405 * wpas_dbus_register_bss - Register a scanned BSS with dbus
2406 * @wpa_s: wpa_supplicant interface structure
2407 * @bssid: scanned network bssid
2408 * @id: unique BSS identifier
2409 * Returns: 0 on success, -1 on failure
2411 * Registers BSS representing object with dbus
2413 int wpas_dbus_register_bss(struct wpa_supplicant *wpa_s,
2414 u8 bssid[ETH_ALEN], unsigned int id)
2416 struct wpas_dbus_priv *ctrl_iface;
2417 struct wpa_dbus_object_desc *obj_desc;
2418 char bss_obj_path[WPAS_DBUS_OBJECT_PATH_MAX];
2419 struct bss_handler_args *arg;
2421 /* Do nothing if the control interface is not turned on */
2422 if (wpa_s == NULL || wpa_s->global == NULL || !wpa_s->dbus_new_path)
2424 ctrl_iface = wpa_s->global->dbus;
2425 if (ctrl_iface == NULL)
2428 os_snprintf(bss_obj_path, WPAS_DBUS_OBJECT_PATH_MAX,
2429 "%s/" WPAS_DBUS_NEW_BSSIDS_PART "/%u",
2430 wpa_s->dbus_new_path, id);
2432 obj_desc = os_zalloc(sizeof(struct wpa_dbus_object_desc));
2434 wpa_printf(MSG_ERROR,
2435 "Not enough memory to create object description");
2439 arg = os_zalloc(sizeof(struct bss_handler_args));
2441 wpa_printf(MSG_ERROR,
2442 "Not enough memory to create arguments for handler");
2448 wpas_dbus_register(obj_desc, arg, wpa_dbus_free, NULL,
2449 wpas_dbus_bss_properties,
2450 wpas_dbus_bss_signals);
2452 wpa_printf(MSG_DEBUG, "dbus: Register BSS object '%s'",
2454 if (wpa_dbus_register_object_per_iface(ctrl_iface, bss_obj_path,
2455 wpa_s->ifname, obj_desc)) {
2456 wpa_printf(MSG_ERROR,
2457 "Cannot register BSSID dbus object %s.",
2462 wpas_dbus_signal_bss_added(wpa_s, bss_obj_path);
2463 wpas_dbus_signal_prop_changed(wpa_s, WPAS_DBUS_PROP_BSSS);
2468 free_dbus_object_desc(obj_desc);
2473 static const struct wpa_dbus_method_desc wpas_dbus_interface_methods[] = {
2474 { "Scan", WPAS_DBUS_NEW_IFACE_INTERFACE,
2475 (WPADBusMethodHandler) wpas_dbus_handler_scan,
2477 { "args", "a{sv}", ARG_IN },
2481 { "SignalPoll", WPAS_DBUS_NEW_IFACE_INTERFACE,
2482 (WPADBusMethodHandler) wpas_dbus_handler_signal_poll,
2484 { "args", "a{sv}", ARG_OUT },
2488 { "Disconnect", WPAS_DBUS_NEW_IFACE_INTERFACE,
2489 (WPADBusMethodHandler) wpas_dbus_handler_disconnect,
2494 { "AddNetwork", WPAS_DBUS_NEW_IFACE_INTERFACE,
2495 (WPADBusMethodHandler) wpas_dbus_handler_add_network,
2497 { "args", "a{sv}", ARG_IN },
2498 { "path", "o", ARG_OUT },
2502 { "Reassociate", WPAS_DBUS_NEW_IFACE_INTERFACE,
2503 (WPADBusMethodHandler) wpas_dbus_handler_reassociate,
2508 { "Reattach", WPAS_DBUS_NEW_IFACE_INTERFACE,
2509 (WPADBusMethodHandler) wpas_dbus_handler_reattach,
2514 { "RemoveNetwork", WPAS_DBUS_NEW_IFACE_INTERFACE,
2515 (WPADBusMethodHandler) wpas_dbus_handler_remove_network,
2517 { "path", "o", ARG_IN },
2521 { "RemoveAllNetworks", WPAS_DBUS_NEW_IFACE_INTERFACE,
2522 (WPADBusMethodHandler) wpas_dbus_handler_remove_all_networks,
2527 { "SelectNetwork", WPAS_DBUS_NEW_IFACE_INTERFACE,
2528 (WPADBusMethodHandler) wpas_dbus_handler_select_network,
2530 { "path", "o", ARG_IN },
2534 { "NetworkReply", WPAS_DBUS_NEW_IFACE_INTERFACE,
2535 (WPADBusMethodHandler) wpas_dbus_handler_network_reply,
2537 { "path", "o", ARG_IN },
2538 { "field", "s", ARG_IN },
2539 { "value", "s", ARG_IN },
2543 #ifndef CONFIG_NO_CONFIG_BLOBS
2544 { "AddBlob", WPAS_DBUS_NEW_IFACE_INTERFACE,
2545 (WPADBusMethodHandler) wpas_dbus_handler_add_blob,
2547 { "name", "s", ARG_IN },
2548 { "data", "ay", ARG_IN },
2552 { "GetBlob", WPAS_DBUS_NEW_IFACE_INTERFACE,
2553 (WPADBusMethodHandler) wpas_dbus_handler_get_blob,
2555 { "name", "s", ARG_IN },
2556 { "data", "ay", ARG_OUT },
2560 { "RemoveBlob", WPAS_DBUS_NEW_IFACE_INTERFACE,
2561 (WPADBusMethodHandler) wpas_dbus_handler_remove_blob,
2563 { "name", "s", ARG_IN },
2567 #endif /* CONFIG_NO_CONFIG_BLOBS */
2568 { "SetPKCS11EngineAndModulePath", WPAS_DBUS_NEW_IFACE_INTERFACE,
2569 (WPADBusMethodHandler)
2570 wpas_dbus_handler_set_pkcs11_engine_and_module_path,
2572 { "pkcs11_engine_path", "s", ARG_IN },
2573 { "pkcs11_module_path", "s", ARG_IN },
2578 { "Start", WPAS_DBUS_NEW_IFACE_WPS,
2579 (WPADBusMethodHandler) wpas_dbus_handler_wps_start,
2581 { "args", "a{sv}", ARG_IN },
2582 { "output", "a{sv}", ARG_OUT },
2586 #endif /* CONFIG_WPS */
2588 { "Find", WPAS_DBUS_NEW_IFACE_P2PDEVICE,
2589 (WPADBusMethodHandler) wpas_dbus_handler_p2p_find,
2591 { "args", "a{sv}", ARG_IN },
2595 { "StopFind", WPAS_DBUS_NEW_IFACE_P2PDEVICE,
2596 (WPADBusMethodHandler) wpas_dbus_handler_p2p_stop_find,
2601 { "Listen", WPAS_DBUS_NEW_IFACE_P2PDEVICE,
2602 (WPADBusMethodHandler) wpas_dbus_handler_p2p_listen,
2604 { "timeout", "i", ARG_IN },
2608 { "ExtendedListen", WPAS_DBUS_NEW_IFACE_P2PDEVICE,
2609 (WPADBusMethodHandler) wpas_dbus_handler_p2p_extendedlisten,
2611 { "args", "a{sv}", ARG_IN },
2615 { "PresenceRequest", WPAS_DBUS_NEW_IFACE_P2PDEVICE,
2616 (WPADBusMethodHandler) wpas_dbus_handler_p2p_presence_request,
2618 { "args", "a{sv}", ARG_IN },
2622 { "ProvisionDiscoveryRequest", WPAS_DBUS_NEW_IFACE_P2PDEVICE,
2623 (WPADBusMethodHandler) wpas_dbus_handler_p2p_prov_disc_req,
2625 { "peer", "o", ARG_IN },
2626 { "config_method", "s", ARG_IN },
2630 { "Connect", WPAS_DBUS_NEW_IFACE_P2PDEVICE,
2631 (WPADBusMethodHandler) wpas_dbus_handler_p2p_connect,
2633 { "args", "a{sv}", ARG_IN },
2634 { "generated_pin", "s", ARG_OUT },
2638 { "GroupAdd", WPAS_DBUS_NEW_IFACE_P2PDEVICE,
2639 (WPADBusMethodHandler) wpas_dbus_handler_p2p_group_add,
2641 { "args", "a{sv}", ARG_IN },
2645 { "Invite", WPAS_DBUS_NEW_IFACE_P2PDEVICE,
2646 (WPADBusMethodHandler) wpas_dbus_handler_p2p_invite,
2648 { "args", "a{sv}", ARG_IN },
2652 { "Disconnect", WPAS_DBUS_NEW_IFACE_P2PDEVICE,
2653 (WPADBusMethodHandler) wpas_dbus_handler_p2p_disconnect,
2658 { "RejectPeer", WPAS_DBUS_NEW_IFACE_P2PDEVICE,
2659 (WPADBusMethodHandler) wpas_dbus_handler_p2p_rejectpeer,
2661 { "peer", "o", ARG_IN },
2665 { "Flush", WPAS_DBUS_NEW_IFACE_P2PDEVICE,
2666 (WPADBusMethodHandler) wpas_dbus_handler_p2p_flush,
2671 { "AddService", WPAS_DBUS_NEW_IFACE_P2PDEVICE,
2672 (WPADBusMethodHandler) wpas_dbus_handler_p2p_add_service,
2674 { "args", "a{sv}", ARG_IN },
2678 { "DeleteService", WPAS_DBUS_NEW_IFACE_P2PDEVICE,
2679 (WPADBusMethodHandler) wpas_dbus_handler_p2p_delete_service,
2681 { "args", "a{sv}", ARG_IN },
2685 { "FlushService", WPAS_DBUS_NEW_IFACE_P2PDEVICE,
2686 (WPADBusMethodHandler) wpas_dbus_handler_p2p_flush_service,
2691 { "ServiceDiscoveryRequest", WPAS_DBUS_NEW_IFACE_P2PDEVICE,
2692 (WPADBusMethodHandler) wpas_dbus_handler_p2p_service_sd_req,
2694 { "args", "a{sv}", ARG_IN },
2695 { "ref", "t", ARG_OUT },
2699 { "ServiceDiscoveryResponse", WPAS_DBUS_NEW_IFACE_P2PDEVICE,
2700 (WPADBusMethodHandler) wpas_dbus_handler_p2p_service_sd_res,
2702 { "args", "a{sv}", ARG_IN },
2706 { "ServiceDiscoveryCancelRequest", WPAS_DBUS_NEW_IFACE_P2PDEVICE,
2707 (WPADBusMethodHandler) wpas_dbus_handler_p2p_service_sd_cancel_req,
2709 { "args", "t", ARG_IN },
2713 { "ServiceUpdate", WPAS_DBUS_NEW_IFACE_P2PDEVICE,
2714 (WPADBusMethodHandler) wpas_dbus_handler_p2p_service_update,
2719 { "ServiceDiscoveryExternal", WPAS_DBUS_NEW_IFACE_P2PDEVICE,
2720 (WPADBusMethodHandler) wpas_dbus_handler_p2p_serv_disc_external,
2722 { "arg", "i", ARG_IN },
2726 { "AddPersistentGroup", WPAS_DBUS_NEW_IFACE_P2PDEVICE,
2727 (WPADBusMethodHandler) wpas_dbus_handler_add_persistent_group,
2729 { "args", "a{sv}", ARG_IN },
2730 { "path", "o", ARG_OUT },
2734 { "RemovePersistentGroup", WPAS_DBUS_NEW_IFACE_P2PDEVICE,
2735 (WPADBusMethodHandler) wpas_dbus_handler_remove_persistent_group,
2737 { "path", "o", ARG_IN },
2741 { "RemoveAllPersistentGroups", WPAS_DBUS_NEW_IFACE_P2PDEVICE,
2742 (WPADBusMethodHandler)
2743 wpas_dbus_handler_remove_all_persistent_groups,
2748 #endif /* CONFIG_P2P */
2749 { "FlushBSS", WPAS_DBUS_NEW_IFACE_INTERFACE,
2750 (WPADBusMethodHandler) wpas_dbus_handler_flush_bss,
2752 { "age", "u", ARG_IN },
2757 { "SubscribeProbeReq", WPAS_DBUS_NEW_IFACE_INTERFACE,
2758 (WPADBusMethodHandler) wpas_dbus_handler_subscribe_preq,
2763 { "UnsubscribeProbeReq", WPAS_DBUS_NEW_IFACE_INTERFACE,
2764 (WPADBusMethodHandler) wpas_dbus_handler_unsubscribe_preq,
2769 #endif /* CONFIG_AP */
2770 { "EAPLogoff", WPAS_DBUS_NEW_IFACE_INTERFACE,
2771 (WPADBusMethodHandler) wpas_dbus_handler_eap_logoff,
2776 { "EAPLogon", WPAS_DBUS_NEW_IFACE_INTERFACE,
2777 (WPADBusMethodHandler) wpas_dbus_handler_eap_logon,
2782 #ifdef CONFIG_AUTOSCAN
2783 { "AutoScan", WPAS_DBUS_NEW_IFACE_INTERFACE,
2784 (WPADBusMethodHandler) wpas_dbus_handler_autoscan,
2786 { "arg", "s", ARG_IN },
2790 #endif /* CONFIG_AUTOSCAN */
2792 { "TDLSDiscover", WPAS_DBUS_NEW_IFACE_INTERFACE,
2793 (WPADBusMethodHandler) wpas_dbus_handler_tdls_discover,
2795 { "peer_address", "s", ARG_IN },
2799 { "TDLSSetup", WPAS_DBUS_NEW_IFACE_INTERFACE,
2800 (WPADBusMethodHandler) wpas_dbus_handler_tdls_setup,
2802 { "peer_address", "s", ARG_IN },
2806 { "TDLSStatus", WPAS_DBUS_NEW_IFACE_INTERFACE,
2807 (WPADBusMethodHandler) wpas_dbus_handler_tdls_status,
2809 { "peer_address", "s", ARG_IN },
2810 { "status", "s", ARG_OUT },
2814 { "TDLSTeardown", WPAS_DBUS_NEW_IFACE_INTERFACE,
2815 (WPADBusMethodHandler) wpas_dbus_handler_tdls_teardown,
2817 { "peer_address", "s", ARG_IN },
2821 #endif /* CONFIG_TDLS */
2822 { NULL, NULL, NULL, { END_ARGS } }
2825 static const struct wpa_dbus_property_desc wpas_dbus_interface_properties[] = {
2826 { "Capabilities", WPAS_DBUS_NEW_IFACE_INTERFACE, "a{sv}",
2827 wpas_dbus_getter_capabilities,
2830 { "State", WPAS_DBUS_NEW_IFACE_INTERFACE, "s",
2831 wpas_dbus_getter_state,
2834 { "Scanning", WPAS_DBUS_NEW_IFACE_INTERFACE, "b",
2835 wpas_dbus_getter_scanning,
2838 { "ApScan", WPAS_DBUS_NEW_IFACE_INTERFACE, "u",
2839 wpas_dbus_getter_ap_scan,
2840 wpas_dbus_setter_ap_scan
2842 { "BSSExpireAge", WPAS_DBUS_NEW_IFACE_INTERFACE, "u",
2843 wpas_dbus_getter_bss_expire_age,
2844 wpas_dbus_setter_bss_expire_age
2846 { "BSSExpireCount", WPAS_DBUS_NEW_IFACE_INTERFACE, "u",
2847 wpas_dbus_getter_bss_expire_count,
2848 wpas_dbus_setter_bss_expire_count
2850 { "Country", WPAS_DBUS_NEW_IFACE_INTERFACE, "s",
2851 wpas_dbus_getter_country,
2852 wpas_dbus_setter_country
2854 { "Ifname", WPAS_DBUS_NEW_IFACE_INTERFACE, "s",
2855 wpas_dbus_getter_ifname,
2858 { "Driver", WPAS_DBUS_NEW_IFACE_INTERFACE, "s",
2859 wpas_dbus_getter_driver,
2862 { "BridgeIfname", WPAS_DBUS_NEW_IFACE_INTERFACE, "s",
2863 wpas_dbus_getter_bridge_ifname,
2866 { "CurrentBSS", WPAS_DBUS_NEW_IFACE_INTERFACE, "o",
2867 wpas_dbus_getter_current_bss,
2870 { "CurrentNetwork", WPAS_DBUS_NEW_IFACE_INTERFACE, "o",
2871 wpas_dbus_getter_current_network,
2874 { "CurrentAuthMode", WPAS_DBUS_NEW_IFACE_INTERFACE, "s",
2875 wpas_dbus_getter_current_auth_mode,
2878 { "Blobs", WPAS_DBUS_NEW_IFACE_INTERFACE, "a{say}",
2879 wpas_dbus_getter_blobs,
2882 { "BSSs", WPAS_DBUS_NEW_IFACE_INTERFACE, "ao",
2883 wpas_dbus_getter_bsss,
2886 { "Networks", WPAS_DBUS_NEW_IFACE_INTERFACE, "ao",
2887 wpas_dbus_getter_networks,
2890 { "FastReauth", WPAS_DBUS_NEW_IFACE_INTERFACE, "b",
2891 wpas_dbus_getter_fast_reauth,
2892 wpas_dbus_setter_fast_reauth
2894 { "ScanInterval", WPAS_DBUS_NEW_IFACE_INTERFACE, "i",
2895 wpas_dbus_getter_scan_interval,
2896 wpas_dbus_setter_scan_interval
2898 { "PKCS11EnginePath", WPAS_DBUS_NEW_IFACE_INTERFACE, "s",
2899 wpas_dbus_getter_pkcs11_engine_path,
2902 { "PKCS11ModulePath", WPAS_DBUS_NEW_IFACE_INTERFACE, "s",
2903 wpas_dbus_getter_pkcs11_module_path,
2907 { "ProcessCredentials", WPAS_DBUS_NEW_IFACE_WPS, "b",
2908 wpas_dbus_getter_process_credentials,
2909 wpas_dbus_setter_process_credentials
2911 { "ConfigMethods", WPAS_DBUS_NEW_IFACE_WPS, "s",
2912 wpas_dbus_getter_config_methods,
2913 wpas_dbus_setter_config_methods
2915 #endif /* CONFIG_WPS */
2917 { "P2PDeviceConfig", WPAS_DBUS_NEW_IFACE_P2PDEVICE, "a{sv}",
2918 wpas_dbus_getter_p2p_device_config,
2919 wpas_dbus_setter_p2p_device_config
2921 { "Peers", WPAS_DBUS_NEW_IFACE_P2PDEVICE, "ao",
2922 wpas_dbus_getter_p2p_peers,
2925 { "Role", WPAS_DBUS_NEW_IFACE_P2PDEVICE, "s",
2926 wpas_dbus_getter_p2p_role,
2929 { "Group", WPAS_DBUS_NEW_IFACE_P2PDEVICE, "o",
2930 wpas_dbus_getter_p2p_group,
2933 { "PeerGO", WPAS_DBUS_NEW_IFACE_P2PDEVICE, "o",
2934 wpas_dbus_getter_p2p_peergo,
2937 { "PersistentGroups", WPAS_DBUS_NEW_IFACE_P2PDEVICE, "ao",
2938 wpas_dbus_getter_persistent_groups,
2941 #endif /* CONFIG_P2P */
2942 { "DisconnectReason", WPAS_DBUS_NEW_IFACE_INTERFACE, "i",
2943 wpas_dbus_getter_disconnect_reason,
2946 { NULL, NULL, NULL, NULL, NULL }
2949 static const struct wpa_dbus_signal_desc wpas_dbus_interface_signals[] = {
2950 { "ScanDone", WPAS_DBUS_NEW_IFACE_INTERFACE,
2952 { "success", "b", ARG_OUT },
2956 { "BSSAdded", WPAS_DBUS_NEW_IFACE_INTERFACE,
2958 { "path", "o", ARG_OUT },
2959 { "properties", "a{sv}", ARG_OUT },
2963 { "BSSRemoved", WPAS_DBUS_NEW_IFACE_INTERFACE,
2965 { "path", "o", ARG_OUT },
2969 { "BlobAdded", WPAS_DBUS_NEW_IFACE_INTERFACE,
2971 { "name", "s", ARG_OUT },
2975 { "BlobRemoved", WPAS_DBUS_NEW_IFACE_INTERFACE,
2977 { "name", "s", ARG_OUT },
2981 { "NetworkAdded", WPAS_DBUS_NEW_IFACE_INTERFACE,
2983 { "path", "o", ARG_OUT },
2984 { "properties", "a{sv}", ARG_OUT },
2988 { "NetworkRemoved", WPAS_DBUS_NEW_IFACE_INTERFACE,
2990 { "path", "o", ARG_OUT },
2994 { "NetworkSelected", WPAS_DBUS_NEW_IFACE_INTERFACE,
2996 { "path", "o", ARG_OUT },
3000 /* Deprecated: use org.freedesktop.DBus.Properties.PropertiesChanged */
3001 { "PropertiesChanged", WPAS_DBUS_NEW_IFACE_INTERFACE,
3003 { "properties", "a{sv}", ARG_OUT },
3008 { "Event", WPAS_DBUS_NEW_IFACE_WPS,
3010 { "name", "s", ARG_OUT },
3011 { "args", "a{sv}", ARG_OUT },
3015 { "Credentials", WPAS_DBUS_NEW_IFACE_WPS,
3017 { "credentials", "a{sv}", ARG_OUT },
3021 /* Deprecated: use org.freedesktop.DBus.Properties.PropertiesChanged */
3022 { "PropertiesChanged", WPAS_DBUS_NEW_IFACE_WPS,
3024 { "properties", "a{sv}", ARG_OUT },
3028 #endif /* CONFIG_WPS */
3030 { "DeviceFound", WPAS_DBUS_NEW_IFACE_P2PDEVICE,
3032 { "path", "o", ARG_OUT },
3036 { "DeviceLost", WPAS_DBUS_NEW_IFACE_P2PDEVICE,
3038 { "path", "o", ARG_OUT },
3042 { "FindStopped", WPAS_DBUS_NEW_IFACE_P2PDEVICE,
3047 { "ProvisionDiscoveryRequestDisplayPin", WPAS_DBUS_NEW_IFACE_P2PDEVICE,
3049 { "peer_object", "o", ARG_OUT },
3050 { "pin", "s", ARG_OUT },
3054 { "ProvisionDiscoveryResponseDisplayPin", WPAS_DBUS_NEW_IFACE_P2PDEVICE,
3056 { "peer_object", "o", ARG_OUT },
3057 { "pin", "s", ARG_OUT },
3061 { "ProvisionDiscoveryRequestEnterPin", WPAS_DBUS_NEW_IFACE_P2PDEVICE,
3063 { "peer_object", "o", ARG_OUT },
3067 { "ProvisionDiscoveryResponseEnterPin", WPAS_DBUS_NEW_IFACE_P2PDEVICE,
3069 { "peer_object", "o", ARG_OUT },
3073 { "ProvisionDiscoveryPBCRequest", WPAS_DBUS_NEW_IFACE_P2PDEVICE,
3075 { "peer_object", "o", ARG_OUT },
3079 { "ProvisionDiscoveryPBCResponse", WPAS_DBUS_NEW_IFACE_P2PDEVICE,
3081 { "peer_object", "o", ARG_OUT },
3085 { "ProvisionDiscoveryFailure", WPAS_DBUS_NEW_IFACE_P2PDEVICE,
3087 { "peer_object", "o", ARG_OUT },
3088 { "status", "i", ARG_OUT },
3092 { "GroupStarted", WPAS_DBUS_NEW_IFACE_P2PDEVICE,
3094 { "properties", "a{sv}", ARG_OUT },
3098 { "GONegotiationSuccess", WPAS_DBUS_NEW_IFACE_P2PDEVICE,
3100 { "properties", "a{sv}", ARG_OUT },
3104 { "GONegotiationFailure", WPAS_DBUS_NEW_IFACE_P2PDEVICE,
3106 { "properties", "a{sv}", ARG_OUT },
3110 { "GONegotiationRequest", WPAS_DBUS_NEW_IFACE_P2PDEVICE,
3112 { "path", "o", ARG_OUT },
3113 { "dev_passwd_id", "i", ARG_OUT },
3117 { "InvitationResult", WPAS_DBUS_NEW_IFACE_P2PDEVICE,
3119 { "invite_result", "a{sv}", ARG_OUT },
3123 { "GroupFinished", WPAS_DBUS_NEW_IFACE_P2PDEVICE,
3125 { "properties", "a{sv}", ARG_OUT },
3129 { "ServiceDiscoveryRequest", WPAS_DBUS_NEW_IFACE_P2PDEVICE,
3131 { "sd_request", "a{sv}", ARG_OUT },
3135 { "ServiceDiscoveryResponse", WPAS_DBUS_NEW_IFACE_P2PDEVICE,
3137 { "sd_response", "a{sv}", ARG_OUT },
3141 { "PersistentGroupAdded", WPAS_DBUS_NEW_IFACE_P2PDEVICE,
3143 { "path", "o", ARG_OUT },
3144 { "properties", "a{sv}", ARG_OUT },
3148 { "PersistentGroupRemoved", WPAS_DBUS_NEW_IFACE_P2PDEVICE,
3150 { "path", "o", ARG_OUT },
3154 { "WpsFailed", WPAS_DBUS_NEW_IFACE_P2PDEVICE,
3156 { "name", "s", ARG_OUT },
3157 { "args", "a{sv}", ARG_OUT },
3161 #endif /* CONFIG_P2P */
3163 { "ProbeRequest", WPAS_DBUS_NEW_IFACE_INTERFACE,
3165 { "args", "a{sv}", ARG_OUT },
3169 #endif /* CONFIG_AP */
3170 { "Certification", WPAS_DBUS_NEW_IFACE_INTERFACE,
3172 { "certification", "a{sv}", ARG_OUT },
3176 { "EAP", WPAS_DBUS_NEW_IFACE_INTERFACE,
3178 { "status", "s", ARG_OUT },
3179 { "parameter", "s", ARG_OUT },
3183 { "StaAuthorized", WPAS_DBUS_NEW_IFACE_INTERFACE,
3185 { "name", "s", ARG_OUT },
3189 { "StaDeauthorized", WPAS_DBUS_NEW_IFACE_INTERFACE,
3191 { "name", "s", ARG_OUT },
3195 { "NetworkRequest", WPAS_DBUS_NEW_IFACE_INTERFACE,
3197 { "path", "o", ARG_OUT },
3198 { "field", "s", ARG_OUT },
3199 { "text", "s", ARG_OUT },
3203 { NULL, NULL, { END_ARGS } }
3207 int wpas_dbus_register_interface(struct wpa_supplicant *wpa_s)
3210 struct wpa_dbus_object_desc *obj_desc = NULL;
3211 struct wpas_dbus_priv *ctrl_iface = wpa_s->global->dbus;
3214 /* Do nothing if the control interface is not turned on */
3215 if (ctrl_iface == NULL)
3218 /* Create and set the interface's object path */
3219 wpa_s->dbus_new_path = os_zalloc(WPAS_DBUS_OBJECT_PATH_MAX);
3220 if (wpa_s->dbus_new_path == NULL)
3222 next = ctrl_iface->next_objid++;
3223 os_snprintf(wpa_s->dbus_new_path, WPAS_DBUS_OBJECT_PATH_MAX,
3224 WPAS_DBUS_NEW_PATH_INTERFACES "/%u",
3227 obj_desc = os_zalloc(sizeof(struct wpa_dbus_object_desc));
3229 wpa_printf(MSG_ERROR,
3230 "Not enough memory to create object description");
3234 wpas_dbus_register(obj_desc, wpa_s, NULL, wpas_dbus_interface_methods,
3235 wpas_dbus_interface_properties,
3236 wpas_dbus_interface_signals);
3238 wpa_printf(MSG_DEBUG, "dbus: Register interface object '%s'",
3239 wpa_s->dbus_new_path);
3240 if (wpa_dbus_register_object_per_iface(ctrl_iface,
3241 wpa_s->dbus_new_path,
3242 wpa_s->ifname, obj_desc))
3245 wpas_dbus_signal_interface_added(wpa_s);
3250 os_free(wpa_s->dbus_new_path);
3251 wpa_s->dbus_new_path = NULL;
3252 free_dbus_object_desc(obj_desc);
3257 int wpas_dbus_unregister_interface(struct wpa_supplicant *wpa_s)
3259 struct wpas_dbus_priv *ctrl_iface;
3261 /* Do nothing if the control interface is not turned on */
3262 if (wpa_s == NULL || wpa_s->global == NULL)
3264 ctrl_iface = wpa_s->global->dbus;
3265 if (ctrl_iface == NULL || wpa_s->dbus_new_path == NULL)
3268 wpa_printf(MSG_DEBUG, "dbus: Unregister interface object '%s'",
3269 wpa_s->dbus_new_path);
3272 if (wpa_s->preq_notify_peer) {
3273 wpas_dbus_unsubscribe_noc(ctrl_iface);
3274 os_free(wpa_s->preq_notify_peer);
3275 wpa_s->preq_notify_peer = NULL;
3277 #endif /* CONFIG_AP */
3279 if (wpa_dbus_unregister_object_per_iface(ctrl_iface,
3280 wpa_s->dbus_new_path))
3283 wpas_dbus_signal_interface_removed(wpa_s);
3285 os_free(wpa_s->dbus_new_path);
3286 wpa_s->dbus_new_path = NULL;
3293 static const struct wpa_dbus_property_desc wpas_dbus_p2p_peer_properties[] = {
3294 { "DeviceName", WPAS_DBUS_NEW_IFACE_P2P_PEER, "s",
3295 wpas_dbus_getter_p2p_peer_device_name,
3298 { "PrimaryDeviceType", WPAS_DBUS_NEW_IFACE_P2P_PEER, "ay",
3299 wpas_dbus_getter_p2p_peer_primary_device_type,
3302 { "config_method", WPAS_DBUS_NEW_IFACE_P2P_PEER, "q",
3303 wpas_dbus_getter_p2p_peer_config_method,
3306 { "level", WPAS_DBUS_NEW_IFACE_P2P_PEER, "i",
3307 wpas_dbus_getter_p2p_peer_level,
3310 { "devicecapability", WPAS_DBUS_NEW_IFACE_P2P_PEER, "y",
3311 wpas_dbus_getter_p2p_peer_device_capability,
3314 { "groupcapability", WPAS_DBUS_NEW_IFACE_P2P_PEER, "y",
3315 wpas_dbus_getter_p2p_peer_group_capability,
3318 { "SecondaryDeviceTypes", WPAS_DBUS_NEW_IFACE_P2P_PEER, "aay",
3319 wpas_dbus_getter_p2p_peer_secondary_device_types,
3322 { "VendorExtension", WPAS_DBUS_NEW_IFACE_P2P_PEER, "aay",
3323 wpas_dbus_getter_p2p_peer_vendor_extension,
3326 { "IEs", WPAS_DBUS_NEW_IFACE_P2P_PEER, "ay",
3327 wpas_dbus_getter_p2p_peer_ies,
3330 { "DeviceAddress", WPAS_DBUS_NEW_IFACE_P2P_PEER, "ay",
3331 wpas_dbus_getter_p2p_peer_device_address,
3334 { "Groups", WPAS_DBUS_NEW_IFACE_P2P_PEER, "ao",
3335 wpas_dbus_getter_p2p_peer_groups,
3338 { NULL, NULL, NULL, NULL, NULL }
3341 static const struct wpa_dbus_signal_desc wpas_dbus_p2p_peer_signals[] = {
3342 /* Deprecated: use org.freedesktop.DBus.Properties.PropertiesChanged */
3343 { "PropertiesChanged", WPAS_DBUS_NEW_IFACE_P2P_PEER,
3345 { "properties", "a{sv}", ARG_OUT },
3349 { NULL, NULL, { END_ARGS } }
3353 * wpas_dbus_signal_peer - Send a peer related event signal
3354 * @wpa_s: %wpa_supplicant network interface data
3355 * @dev: peer device object
3356 * @interface: name of the interface emitting this signal.
3357 * In case of peer objects, it would be emitted by either
3358 * the "interface object" or by "peer objects"
3359 * @sig_name: signal name - DeviceFound
3361 * Notify listeners about event related with newly found p2p peer device
3363 static void wpas_dbus_signal_peer(struct wpa_supplicant *wpa_s,
3364 const u8 *dev_addr, const char *interface,
3365 const char *sig_name)
3367 struct wpas_dbus_priv *iface;
3369 DBusMessageIter iter;
3370 char peer_obj_path[WPAS_DBUS_OBJECT_PATH_MAX], *path;
3372 if (wpa_s->p2p_mgmt)
3373 wpa_s = wpa_s->parent;
3375 iface = wpa_s->global->dbus;
3377 /* Do nothing if the control interface is not turned on */
3378 if (iface == NULL || !wpa_s->dbus_new_path)
3381 os_snprintf(peer_obj_path, WPAS_DBUS_OBJECT_PATH_MAX,
3382 "%s/" WPAS_DBUS_NEW_P2P_PEERS_PART "/" COMPACT_MACSTR,
3383 wpa_s->dbus_new_path, MAC2STR(dev_addr));
3385 msg = dbus_message_new_signal(wpa_s->dbus_new_path, interface,
3390 dbus_message_iter_init_append(msg, &iter);
3391 path = peer_obj_path;
3392 if (!dbus_message_iter_append_basic(&iter, DBUS_TYPE_OBJECT_PATH,
3394 wpa_printf(MSG_ERROR, "dbus: Failed to construct signal");
3396 dbus_connection_send(iface->con, msg, NULL);
3398 dbus_message_unref(msg);
3403 * wpas_dbus_signal_peer_found - Send a peer found signal
3404 * @wpa_s: %wpa_supplicant network interface data
3405 * @dev: peer device object
3407 * Notify listeners about find a p2p peer device found
3409 void wpas_dbus_signal_peer_device_found(struct wpa_supplicant *wpa_s,
3412 wpas_dbus_signal_peer(wpa_s, dev_addr,
3413 WPAS_DBUS_NEW_IFACE_P2PDEVICE,
3418 * wpas_dbus_signal_peer_lost - Send a peer lost signal
3419 * @wpa_s: %wpa_supplicant network interface data
3420 * @dev: peer device object
3422 * Notify listeners about lost a p2p peer device
3424 void wpas_dbus_signal_peer_device_lost(struct wpa_supplicant *wpa_s,
3427 wpas_dbus_signal_peer(wpa_s, dev_addr,
3428 WPAS_DBUS_NEW_IFACE_P2PDEVICE,
3433 * wpas_dbus_register_peer - Register a discovered peer object with dbus
3434 * @wpa_s: wpa_supplicant interface structure
3435 * @ssid: network configuration data
3436 * Returns: 0 on success, -1 on failure
3438 * Registers network representing object with dbus
3440 int wpas_dbus_register_peer(struct wpa_supplicant *wpa_s, const u8 *dev_addr)
3442 struct wpas_dbus_priv *ctrl_iface;
3443 struct wpa_dbus_object_desc *obj_desc;
3444 struct peer_handler_args *arg;
3445 char peer_obj_path[WPAS_DBUS_OBJECT_PATH_MAX];
3447 /* Do nothing if the control interface is not turned on */
3448 if (wpa_s == NULL || wpa_s->global == NULL)
3451 ctrl_iface = wpa_s->global->dbus;
3452 if (ctrl_iface == NULL)
3455 wpa_s = wpa_s->parent->parent;
3456 if (!wpa_s->dbus_new_path)
3459 os_snprintf(peer_obj_path, WPAS_DBUS_OBJECT_PATH_MAX,
3460 "%s/" WPAS_DBUS_NEW_P2P_PEERS_PART "/" COMPACT_MACSTR,
3461 wpa_s->dbus_new_path, MAC2STR(dev_addr));
3463 wpa_printf(MSG_INFO, "dbus: Register peer object '%s'",
3465 obj_desc = os_zalloc(sizeof(struct wpa_dbus_object_desc));
3467 wpa_printf(MSG_ERROR,
3468 "Not enough memory to create object description");
3472 /* allocate memory for handlers arguments */
3473 arg = os_zalloc(sizeof(struct peer_handler_args));
3475 wpa_printf(MSG_ERROR,
3476 "Not enough memory to create arguments for method");
3481 os_memcpy(arg->p2p_device_addr, dev_addr, ETH_ALEN);
3483 wpas_dbus_register(obj_desc, arg, wpa_dbus_free,
3485 wpas_dbus_p2p_peer_properties,
3486 wpas_dbus_p2p_peer_signals);
3488 if (wpa_dbus_register_object_per_iface(ctrl_iface, peer_obj_path,
3489 wpa_s->ifname, obj_desc))
3495 free_dbus_object_desc(obj_desc);
3500 * wpas_dbus_unregister_peer - Unregister a peer object with dbus
3501 * @wpa_s: wpa_supplicant interface structure
3502 * @dev_addr: p2p device addr
3503 * Returns: 0 on success, -1 on failure
3505 * Registers network representing object with dbus
3507 int wpas_dbus_unregister_peer(struct wpa_supplicant *wpa_s,
3510 struct wpas_dbus_priv *ctrl_iface;
3511 char peer_obj_path[WPAS_DBUS_OBJECT_PATH_MAX];
3514 /* Do nothing if the control interface is not turned on */
3515 if (wpa_s == NULL || wpa_s->global == NULL)
3518 wpa_s = wpa_s->parent->parent;
3519 if (!wpa_s->dbus_new_path)
3522 ctrl_iface = wpa_s->global->dbus;
3523 if (ctrl_iface == NULL)
3526 os_snprintf(peer_obj_path, WPAS_DBUS_OBJECT_PATH_MAX,
3527 "%s/" WPAS_DBUS_NEW_P2P_PEERS_PART "/" COMPACT_MACSTR,
3528 wpa_s->dbus_new_path, MAC2STR(dev_addr));
3530 wpa_printf(MSG_INFO, "dbus: Unregister peer object '%s'",
3532 ret = wpa_dbus_unregister_object_per_iface(ctrl_iface, peer_obj_path);
3539 * wpas_dbus_signal_p2p_find_stopped - Send P2P Find stopped signal
3540 * @wpa_s: %wpa_supplicant network interface data
3542 * Notify listeners about P2P Find stopped
3544 void wpas_dbus_signal_p2p_find_stopped(struct wpa_supplicant *wpa_s)
3546 struct wpas_dbus_priv *iface;
3549 iface = wpa_s->global->dbus;
3551 /* Do nothing if the control interface is not turned on */
3552 if (iface == NULL || !wpa_s->dbus_new_path)
3555 msg = dbus_message_new_signal(wpa_s->dbus_new_path,
3556 WPAS_DBUS_NEW_IFACE_P2PDEVICE,
3561 dbus_connection_send(iface->con, msg, NULL);
3563 dbus_message_unref(msg);
3567 void wpas_dbus_signal_peer_groups_changed(struct wpa_supplicant *wpa_s,
3570 char peer_obj_path[WPAS_DBUS_OBJECT_PATH_MAX];
3572 if (wpa_s->p2p_mgmt)
3573 wpa_s = wpa_s->parent;
3575 if (!wpa_s->dbus_new_path)
3577 os_snprintf(peer_obj_path, WPAS_DBUS_OBJECT_PATH_MAX,
3578 "%s/" WPAS_DBUS_NEW_P2P_PEERS_PART "/" COMPACT_MACSTR,
3579 wpa_s->dbus_new_path, MAC2STR(dev_addr));
3581 wpa_dbus_mark_property_changed(wpa_s->global->dbus, peer_obj_path,
3582 WPAS_DBUS_NEW_IFACE_P2P_PEER, "Groups");
3586 static const struct wpa_dbus_property_desc wpas_dbus_p2p_group_properties[] = {
3587 { "Members", WPAS_DBUS_NEW_IFACE_P2P_GROUP, "ao",
3588 wpas_dbus_getter_p2p_group_members,
3591 { "Group", WPAS_DBUS_NEW_IFACE_P2P_GROUP, "o",
3592 wpas_dbus_getter_p2p_group,
3595 { "Role", WPAS_DBUS_NEW_IFACE_P2P_GROUP, "s",
3596 wpas_dbus_getter_p2p_role,
3599 { "SSID", WPAS_DBUS_NEW_IFACE_P2P_GROUP, "ay",
3600 wpas_dbus_getter_p2p_group_ssid,
3603 { "BSSID", WPAS_DBUS_NEW_IFACE_P2P_GROUP, "ay",
3604 wpas_dbus_getter_p2p_group_bssid,
3607 { "Frequency", WPAS_DBUS_NEW_IFACE_P2P_GROUP, "q",
3608 wpas_dbus_getter_p2p_group_frequency,
3611 { "Passphrase", WPAS_DBUS_NEW_IFACE_P2P_GROUP, "s",
3612 wpas_dbus_getter_p2p_group_passphrase,
3615 { "PSK", WPAS_DBUS_NEW_IFACE_P2P_GROUP, "ay",
3616 wpas_dbus_getter_p2p_group_psk,
3619 { "WPSVendorExtensions", WPAS_DBUS_NEW_IFACE_P2P_GROUP, "aay",
3620 wpas_dbus_getter_p2p_group_vendor_ext,
3621 wpas_dbus_setter_p2p_group_vendor_ext
3623 { NULL, NULL, NULL, NULL, NULL }
3626 static const struct wpa_dbus_signal_desc wpas_dbus_p2p_group_signals[] = {
3627 { "PeerJoined", WPAS_DBUS_NEW_IFACE_P2P_GROUP,
3629 { "peer", "o", ARG_OUT },
3633 { "PeerDisconnected", WPAS_DBUS_NEW_IFACE_P2P_GROUP,
3635 { "peer", "o", ARG_OUT },
3639 { NULL, NULL, { END_ARGS } }
3643 * wpas_dbus_register_p2p_group - Register a p2p group object with dbus
3644 * @wpa_s: wpa_supplicant interface structure
3645 * @ssid: SSID struct
3646 * Returns: 0 on success, -1 on failure
3648 * Registers p2p group representing object with dbus
3650 void wpas_dbus_register_p2p_group(struct wpa_supplicant *wpa_s,
3651 struct wpa_ssid *ssid)
3653 struct wpas_dbus_priv *ctrl_iface;
3654 struct wpa_dbus_object_desc *obj_desc;
3655 char group_obj_path[WPAS_DBUS_OBJECT_PATH_MAX];
3657 /* Do nothing if the control interface is not turned on */
3658 if (wpa_s == NULL || wpa_s->global == NULL)
3661 ctrl_iface = wpa_s->global->dbus;
3662 if (ctrl_iface == NULL)
3665 if (wpa_s->dbus_groupobj_path) {
3666 wpa_printf(MSG_INFO, "%s: Group object '%s' already exists",
3667 __func__, wpa_s->dbus_groupobj_path);
3671 if (wpas_dbus_get_group_obj_path(wpa_s, ssid, group_obj_path) < 0)
3674 wpa_s->dbus_groupobj_path = os_strdup(group_obj_path);
3675 if (wpa_s->dbus_groupobj_path == NULL)
3678 wpa_printf(MSG_INFO, "dbus: Register group object '%s'",
3680 obj_desc = os_zalloc(sizeof(struct wpa_dbus_object_desc));
3682 wpa_printf(MSG_ERROR,
3683 "Not enough memory to create object description");
3687 wpas_dbus_register(obj_desc, wpa_s, NULL, NULL,
3688 wpas_dbus_p2p_group_properties,
3689 wpas_dbus_p2p_group_signals);
3691 if (wpa_dbus_register_object_per_iface(ctrl_iface, group_obj_path,
3692 wpa_s->ifname, obj_desc))
3698 if (wpa_s->dbus_groupobj_path) {
3699 os_free(wpa_s->dbus_groupobj_path);
3700 wpa_s->dbus_groupobj_path = NULL;
3703 free_dbus_object_desc(obj_desc);
3707 * wpas_dbus_unregister_p2p_group - Unregister a p2p group object from dbus
3708 * @wpa_s: wpa_supplicant interface structure
3709 * @ssid: network name of the p2p group started
3711 void wpas_dbus_unregister_p2p_group(struct wpa_supplicant *wpa_s,
3712 const struct wpa_ssid *ssid)
3714 struct wpas_dbus_priv *ctrl_iface;
3716 /* Do nothing if the control interface is not turned on */
3717 if (wpa_s == NULL || wpa_s->global == NULL)
3720 if (wpa_s->p2p_mgmt)
3721 wpa_s = wpa_s->parent;
3723 ctrl_iface = wpa_s->global->dbus;
3724 if (ctrl_iface == NULL)
3727 if (!wpa_s->dbus_groupobj_path) {
3728 wpa_printf(MSG_DEBUG,
3729 "%s: Group object '%s' already unregistered",
3730 __func__, wpa_s->dbus_groupobj_path);
3734 peer_groups_changed(wpa_s);
3736 wpa_printf(MSG_DEBUG, "dbus: Unregister group object '%s'",
3737 wpa_s->dbus_groupobj_path);
3739 wpa_dbus_unregister_object_per_iface(ctrl_iface,
3740 wpa_s->dbus_groupobj_path);
3742 os_free(wpa_s->dbus_groupobj_path);
3743 wpa_s->dbus_groupobj_path = NULL;
3746 static const struct wpa_dbus_property_desc
3747 wpas_dbus_persistent_group_properties[] = {
3748 { "Properties", WPAS_DBUS_NEW_IFACE_PERSISTENT_GROUP, "a{sv}",
3749 wpas_dbus_getter_persistent_group_properties,
3750 wpas_dbus_setter_persistent_group_properties
3752 { NULL, NULL, NULL, NULL, NULL }
3755 /* No signals intended for persistent group objects */
3758 * wpas_dbus_register_persistent_group - Register a configured(saved)
3759 * persistent group with dbus
3760 * @wpa_s: wpa_supplicant interface structure
3761 * @ssid: persistent group (still represented as a network within wpa)
3762 * configuration data
3763 * Returns: 0 on success, -1 on failure
3765 * Registers a persistent group representing object with dbus.
3767 int wpas_dbus_register_persistent_group(struct wpa_supplicant *wpa_s,
3768 struct wpa_ssid *ssid)
3770 struct wpas_dbus_priv *ctrl_iface;
3771 struct wpa_dbus_object_desc *obj_desc;
3772 struct network_handler_args *arg;
3773 char pgrp_obj_path[WPAS_DBUS_OBJECT_PATH_MAX];
3775 /* Do nothing if the control interface is not turned on */
3776 if (wpa_s == NULL || wpa_s->global == NULL)
3778 wpa_s = wpa_s->parent->parent;
3779 if (!wpa_s->dbus_new_path)
3782 /* Make sure ssid is a persistent group */
3783 if (ssid->disabled != 2 && !ssid->p2p_persistent_group)
3784 return -1; /* should we return w/o complaining? */
3786 if (wpa_s->p2p_mgmt)
3787 wpa_s = wpa_s->parent;
3789 ctrl_iface = wpa_s->global->dbus;
3790 if (ctrl_iface == NULL)
3794 * Intentionally not coming up with different numbering scheme
3795 * for persistent groups.
3797 os_snprintf(pgrp_obj_path, WPAS_DBUS_OBJECT_PATH_MAX,
3798 "%s/" WPAS_DBUS_NEW_PERSISTENT_GROUPS_PART "/%u",
3799 wpa_s->dbus_new_path, ssid->id);
3801 wpa_printf(MSG_DEBUG, "dbus: Register persistent group object '%s'",
3803 obj_desc = os_zalloc(sizeof(struct wpa_dbus_object_desc));
3805 wpa_printf(MSG_ERROR,
3806 "dbus: Not enough memory to create object description");
3811 * Reusing the same context structure as that for networks
3812 * since these are represented using same data structure.
3814 /* allocate memory for handlers arguments */
3815 arg = os_zalloc(sizeof(struct network_handler_args));
3817 wpa_printf(MSG_ERROR,
3818 "dbus: Not enough memory to create arguments for method");
3825 wpas_dbus_register(obj_desc, arg, wpa_dbus_free, NULL,
3826 wpas_dbus_persistent_group_properties,
3829 if (wpa_dbus_register_object_per_iface(ctrl_iface, pgrp_obj_path,
3830 wpa_s->ifname, obj_desc))
3833 wpas_dbus_signal_persistent_group_added(wpa_s, ssid->id);
3838 free_dbus_object_desc(obj_desc);
3844 * wpas_dbus_unregister_persistent_group - Unregister a persistent_group
3846 * @wpa_s: wpa_supplicant interface structure
3848 * Returns: 0 on success, -1 on failure
3850 * Unregisters persistent group representing object from dbus
3852 * NOTE: There is a slight issue with the semantics here. While the
3853 * implementation simply means the persistent group is unloaded from memory,
3854 * it should not get interpreted as the group is actually being erased/removed
3855 * from persistent storage as well.
3857 int wpas_dbus_unregister_persistent_group(struct wpa_supplicant *wpa_s,
3860 struct wpas_dbus_priv *ctrl_iface;
3861 char pgrp_obj_path[WPAS_DBUS_OBJECT_PATH_MAX];
3864 /* Do nothing if the control interface is not turned on */
3865 if (wpa_s == NULL || wpa_s->global == NULL)
3868 wpa_s = wpa_s->parent->parent;
3870 ctrl_iface = wpa_s->global->dbus;
3871 if (ctrl_iface == NULL || !wpa_s->dbus_new_path)
3874 os_snprintf(pgrp_obj_path, WPAS_DBUS_OBJECT_PATH_MAX,
3875 "%s/" WPAS_DBUS_NEW_PERSISTENT_GROUPS_PART "/%u",
3876 wpa_s->dbus_new_path, nid);
3878 wpa_printf(MSG_DEBUG, "dbus: Unregister persistent group object '%s'",
3880 ret = wpa_dbus_unregister_object_per_iface(ctrl_iface, pgrp_obj_path);
3883 wpas_dbus_signal_persistent_group_removed(wpa_s, nid);
3888 #endif /* CONFIG_P2P */