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_pbc_overlap - Signals PBC overlap WPS event
529 * @wpa_s: %wpa_supplicant network interface data
531 * Sends Event dbus signal with name "pbc-overlap" and empty dict as arguments
533 void wpas_dbus_signal_wps_event_pbc_overlap(struct wpa_supplicant *wpa_s)
537 DBusMessageIter iter, dict_iter;
538 struct wpas_dbus_priv *iface;
539 char *key = "pbc-overlap";
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_success - Signals Success WPS event
567 * @wpa_s: %wpa_supplicant network interface data
569 * Sends Event dbus signal with name "success" and empty dict as arguments
571 void wpas_dbus_signal_wps_event_success(struct wpa_supplicant *wpa_s)
575 DBusMessageIter iter, dict_iter;
576 struct wpas_dbus_priv *iface;
577 char *key = "success";
579 iface = wpa_s->global->dbus;
581 /* Do nothing if the control interface is not turned on */
582 if (iface == NULL || !wpa_s->dbus_new_path)
585 msg = dbus_message_new_signal(wpa_s->dbus_new_path,
586 WPAS_DBUS_NEW_IFACE_WPS, "Event");
590 dbus_message_iter_init_append(msg, &iter);
592 if (!dbus_message_iter_append_basic(&iter, DBUS_TYPE_STRING, &key) ||
593 !wpa_dbus_dict_open_write(&iter, &dict_iter) ||
594 !wpa_dbus_dict_close_write(&iter, &dict_iter))
595 wpa_printf(MSG_ERROR, "dbus: Failed to construct signal");
597 dbus_connection_send(iface->con, msg, NULL);
599 dbus_message_unref(msg);
604 * wpas_dbus_signal_wps_event_fail - Signals Fail WPS event
605 * @wpa_s: %wpa_supplicant network interface data
606 * @fail: WPS failure information
608 * Sends Event dbus signal with name "fail" and dictionary containing
609 * "msg field with fail message number (int32) as arguments
611 void wpas_dbus_signal_wps_event_fail(struct wpa_supplicant *wpa_s,
612 struct wps_event_fail *fail)
616 DBusMessageIter iter, dict_iter;
617 struct wpas_dbus_priv *iface;
620 iface = wpa_s->global->dbus;
622 /* Do nothing if the control interface is not turned on */
623 if (iface == NULL || !wpa_s->dbus_new_path)
626 msg = dbus_message_new_signal(wpa_s->dbus_new_path,
627 WPAS_DBUS_NEW_IFACE_WPS, "Event");
631 dbus_message_iter_init_append(msg, &iter);
633 if (!dbus_message_iter_append_basic(&iter, DBUS_TYPE_STRING, &key) ||
634 !wpa_dbus_dict_open_write(&iter, &dict_iter) ||
635 !wpa_dbus_dict_append_int32(&dict_iter, "msg", fail->msg) ||
636 !wpa_dbus_dict_append_int32(&dict_iter, "config_error",
637 fail->config_error) ||
638 !wpa_dbus_dict_append_int32(&dict_iter, "error_indication",
639 fail->error_indication) ||
640 !wpa_dbus_dict_close_write(&iter, &dict_iter))
641 wpa_printf(MSG_ERROR, "dbus: Failed to construct signal");
643 dbus_connection_send(iface->con, msg, NULL);
645 dbus_message_unref(msg);
650 * wpas_dbus_signal_wps_event_m2d - Signals M2D WPS event
651 * @wpa_s: %wpa_supplicant network interface data
652 * @m2d: M2D event data information
654 * Sends Event dbus signal with name "m2d" and dictionary containing
655 * fields of wps_event_m2d structure.
657 void wpas_dbus_signal_wps_event_m2d(struct wpa_supplicant *wpa_s,
658 struct wps_event_m2d *m2d)
662 DBusMessageIter iter, dict_iter;
663 struct wpas_dbus_priv *iface;
666 iface = wpa_s->global->dbus;
668 /* Do nothing if the control interface is not turned on */
669 if (iface == NULL || !wpa_s->dbus_new_path)
672 msg = dbus_message_new_signal(wpa_s->dbus_new_path,
673 WPAS_DBUS_NEW_IFACE_WPS, "Event");
677 dbus_message_iter_init_append(msg, &iter);
679 if (!dbus_message_iter_append_basic(&iter, DBUS_TYPE_STRING, &key) ||
680 !wpa_dbus_dict_open_write(&iter, &dict_iter) ||
681 !wpa_dbus_dict_append_uint16(&dict_iter, "config_methods",
682 m2d->config_methods) ||
683 !wpa_dbus_dict_append_byte_array(&dict_iter, "manufacturer",
684 (const char *) m2d->manufacturer,
685 m2d->manufacturer_len) ||
686 !wpa_dbus_dict_append_byte_array(&dict_iter, "model_name",
687 (const char *) m2d->model_name,
688 m2d->model_name_len) ||
689 !wpa_dbus_dict_append_byte_array(&dict_iter, "model_number",
690 (const char *) m2d->model_number,
691 m2d->model_number_len) ||
692 !wpa_dbus_dict_append_byte_array(&dict_iter, "serial_number",
695 m2d->serial_number_len) ||
696 !wpa_dbus_dict_append_byte_array(&dict_iter, "dev_name",
697 (const char *) m2d->dev_name,
698 m2d->dev_name_len) ||
699 !wpa_dbus_dict_append_byte_array(&dict_iter, "primary_dev_type",
701 m2d->primary_dev_type, 8) ||
702 !wpa_dbus_dict_append_uint16(&dict_iter, "config_error",
703 m2d->config_error) ||
704 !wpa_dbus_dict_append_uint16(&dict_iter, "dev_password_id",
705 m2d->dev_password_id) ||
706 !wpa_dbus_dict_close_write(&iter, &dict_iter))
707 wpa_printf(MSG_ERROR, "dbus: Failed to construct signal");
709 dbus_connection_send(iface->con, msg, NULL);
711 dbus_message_unref(msg);
716 * wpas_dbus_signal_wps_cred - Signals new credentials
717 * @wpa_s: %wpa_supplicant network interface data
718 * @cred: WPS Credential information
720 * Sends signal with credentials in directory argument
722 void wpas_dbus_signal_wps_cred(struct wpa_supplicant *wpa_s,
723 const struct wps_credential *cred)
726 DBusMessageIter iter, dict_iter;
727 struct wpas_dbus_priv *iface;
728 char *auth_type[5]; /* we have five possible authentication types */
730 char *encr_type[3]; /* we have three possible encryption types */
733 iface = wpa_s->global->dbus;
735 /* Do nothing if the control interface is not turned on */
736 if (iface == NULL || !wpa_s->dbus_new_path)
739 msg = dbus_message_new_signal(wpa_s->dbus_new_path,
740 WPAS_DBUS_NEW_IFACE_WPS,
745 dbus_message_iter_init_append(msg, &iter);
746 if (!wpa_dbus_dict_open_write(&iter, &dict_iter))
749 if (cred->auth_type & WPS_AUTH_OPEN)
750 auth_type[at_num++] = "open";
751 if (cred->auth_type & WPS_AUTH_WPAPSK)
752 auth_type[at_num++] = "wpa-psk";
753 if (cred->auth_type & WPS_AUTH_WPA)
754 auth_type[at_num++] = "wpa-eap";
755 if (cred->auth_type & WPS_AUTH_WPA2)
756 auth_type[at_num++] = "wpa2-eap";
757 if (cred->auth_type & WPS_AUTH_WPA2PSK)
758 auth_type[at_num++] = "wpa2-psk";
760 if (cred->encr_type & WPS_ENCR_NONE)
761 encr_type[et_num++] = "none";
762 if (cred->encr_type & WPS_ENCR_TKIP)
763 encr_type[et_num++] = "tkip";
764 if (cred->encr_type & WPS_ENCR_AES)
765 encr_type[et_num++] = "aes";
767 if ((wpa_s->current_ssid &&
768 !wpa_dbus_dict_append_byte_array(
770 (const char *) wpa_s->current_ssid->bssid, ETH_ALEN)) ||
771 !wpa_dbus_dict_append_byte_array(&dict_iter, "SSID",
772 (const char *) cred->ssid,
774 !wpa_dbus_dict_append_string_array(&dict_iter, "AuthType",
775 (const char **) auth_type,
777 !wpa_dbus_dict_append_string_array(&dict_iter, "EncrType",
778 (const char **) encr_type,
780 !wpa_dbus_dict_append_byte_array(&dict_iter, "Key",
781 (const char *) cred->key,
783 !wpa_dbus_dict_append_uint32(&dict_iter, "KeyIndex",
785 !wpa_dbus_dict_close_write(&iter, &dict_iter))
788 dbus_connection_send(iface->con, msg, NULL);
791 dbus_message_unref(msg);
794 #endif /* CONFIG_WPS */
796 void wpas_dbus_signal_certification(struct wpa_supplicant *wpa_s,
797 int depth, const char *subject,
798 const char *altsubject[],
800 const char *cert_hash,
801 const struct wpabuf *cert)
803 struct wpas_dbus_priv *iface;
805 DBusMessageIter iter, dict_iter;
807 iface = wpa_s->global->dbus;
809 /* Do nothing if the control interface is not turned on */
810 if (iface == NULL || !wpa_s->dbus_new_path)
813 msg = dbus_message_new_signal(wpa_s->dbus_new_path,
814 WPAS_DBUS_NEW_IFACE_INTERFACE,
819 dbus_message_iter_init_append(msg, &iter);
820 if (!wpa_dbus_dict_open_write(&iter, &dict_iter) ||
821 !wpa_dbus_dict_append_uint32(&dict_iter, "depth", depth) ||
822 !wpa_dbus_dict_append_string(&dict_iter, "subject", subject) ||
823 (altsubject && num_altsubject &&
824 !wpa_dbus_dict_append_string_array(&dict_iter, "altsubject",
825 altsubject, num_altsubject)) ||
827 !wpa_dbus_dict_append_string(&dict_iter, "cert_hash",
830 !wpa_dbus_dict_append_byte_array(&dict_iter, "cert",
832 wpabuf_len(cert))) ||
833 !wpa_dbus_dict_close_write(&iter, &dict_iter))
834 wpa_printf(MSG_ERROR, "dbus: Failed to construct signal");
836 dbus_connection_send(iface->con, msg, NULL);
837 dbus_message_unref(msg);
841 void wpas_dbus_signal_eap_status(struct wpa_supplicant *wpa_s,
842 const char *status, const char *parameter)
844 struct wpas_dbus_priv *iface;
846 DBusMessageIter iter;
848 iface = wpa_s->global->dbus;
850 /* Do nothing if the control interface is not turned on */
851 if (iface == NULL || !wpa_s->dbus_new_path)
854 msg = dbus_message_new_signal(wpa_s->dbus_new_path,
855 WPAS_DBUS_NEW_IFACE_INTERFACE,
860 dbus_message_iter_init_append(msg, &iter);
862 if (!dbus_message_iter_append_basic(&iter, DBUS_TYPE_STRING, &status) ||
863 !dbus_message_iter_append_basic(&iter, DBUS_TYPE_STRING,
865 wpa_printf(MSG_ERROR, "dbus: Failed to construct signal");
867 dbus_connection_send(iface->con, msg, NULL);
868 dbus_message_unref(msg);
873 * wpas_dbus_signal_sta - Send a station related event signal
874 * @wpa_s: %wpa_supplicant network interface data
875 * @sta: station mac address
876 * @sig_name: signal name - StaAuthorized or StaDeauthorized
878 * Notify listeners about event related with station
880 static void wpas_dbus_signal_sta(struct wpa_supplicant *wpa_s,
881 const u8 *sta, const char *sig_name)
883 struct wpas_dbus_priv *iface;
885 char sta_mac[WPAS_DBUS_OBJECT_PATH_MAX];
888 os_snprintf(sta_mac, WPAS_DBUS_OBJECT_PATH_MAX, MACSTR, MAC2STR(sta));
891 iface = wpa_s->global->dbus;
893 /* Do nothing if the control interface is not turned on */
894 if (iface == NULL || !wpa_s->dbus_new_path)
897 msg = dbus_message_new_signal(wpa_s->dbus_new_path,
898 WPAS_DBUS_NEW_IFACE_INTERFACE, sig_name);
902 if (dbus_message_append_args(msg, DBUS_TYPE_STRING, &dev_mac,
904 dbus_connection_send(iface->con, msg, NULL);
906 wpa_printf(MSG_ERROR, "dbus: Failed to construct signal");
907 dbus_message_unref(msg);
909 wpa_printf(MSG_DEBUG, "dbus: Station MAC address '%s' '%s'",
915 * wpas_dbus_signal_sta_authorized - Send a STA authorized signal
916 * @wpa_s: %wpa_supplicant network interface data
917 * @sta: station mac address
919 * Notify listeners a new station has been authorized
921 void wpas_dbus_signal_sta_authorized(struct wpa_supplicant *wpa_s,
924 wpas_dbus_signal_sta(wpa_s, sta, "StaAuthorized");
929 * wpas_dbus_signal_sta_deauthorized - Send a STA deauthorized signal
930 * @wpa_s: %wpa_supplicant network interface data
931 * @sta: station mac address
933 * Notify listeners a station has been deauthorized
935 void wpas_dbus_signal_sta_deauthorized(struct wpa_supplicant *wpa_s,
938 wpas_dbus_signal_sta(wpa_s, sta, "StaDeauthorized");
945 * wpas_dbus_signal_p2p_group_removed - Signals P2P group was removed
946 * @wpa_s: %wpa_supplicant network interface data
947 * @role: role of this device (client or GO)
948 * Sends signal with i/f name and role as string arguments
950 void wpas_dbus_signal_p2p_group_removed(struct wpa_supplicant *wpa_s,
954 DBusMessageIter iter, dict_iter;
955 struct wpas_dbus_priv *iface = wpa_s->global->dbus;
956 struct wpa_supplicant *parent;
958 /* Do nothing if the control interface is not turned on */
962 parent = wpa_s->parent;
963 if (parent->p2p_mgmt)
964 parent = parent->parent;
966 if (!wpa_s->dbus_groupobj_path || !wpa_s->dbus_new_path ||
967 !parent->dbus_new_path)
970 msg = dbus_message_new_signal(parent->dbus_new_path,
971 WPAS_DBUS_NEW_IFACE_P2PDEVICE,
976 dbus_message_iter_init_append(msg, &iter);
977 if (!wpa_dbus_dict_open_write(&iter, &dict_iter) ||
978 !wpa_dbus_dict_append_object_path(&dict_iter,
980 wpa_s->dbus_new_path) ||
981 !wpa_dbus_dict_append_string(&dict_iter, "role", role) ||
982 !wpa_dbus_dict_append_object_path(&dict_iter, "group_object",
983 wpa_s->dbus_groupobj_path) ||
984 !wpa_dbus_dict_close_write(&iter, &dict_iter))
985 wpa_printf(MSG_ERROR, "dbus: Failed to construct signal");
987 dbus_connection_send(iface->con, msg, NULL);
988 dbus_message_unref(msg);
993 * wpas_dbus_signal_p2p_provision_discovery - Signals various PD events
995 * @dev_addr - who sent the request or responded to our request.
996 * @request - Will be 1 if request, 0 for response.
997 * @status - valid only in case of response
998 * @config_methods - wps config methods
999 * @generated_pin - pin to be displayed in case of WPS_CONFIG_DISPLAY method
1001 * Sends following provision discovery related events:
1002 * ProvisionDiscoveryRequestDisplayPin
1003 * ProvisionDiscoveryResponseDisplayPin
1004 * ProvisionDiscoveryRequestEnterPin
1005 * ProvisionDiscoveryResponseEnterPin
1006 * ProvisionDiscoveryPBCRequest
1007 * ProvisionDiscoveryPBCResponse
1010 * ProvisionDiscoveryFailure (timeout case)
1012 void wpas_dbus_signal_p2p_provision_discovery(struct wpa_supplicant *wpa_s,
1013 const u8 *dev_addr, int request,
1014 enum p2p_prov_disc_status status,
1016 unsigned int generated_pin)
1019 DBusMessageIter iter;
1020 struct wpas_dbus_priv *iface;
1023 char peer_obj_path[WPAS_DBUS_OBJECT_PATH_MAX], *path;
1025 char pin[9], *p_pin = NULL;
1027 iface = wpa_s->global->dbus;
1029 /* Do nothing if the control interface is not turned on */
1033 if (wpa_s->p2p_mgmt)
1034 wpa_s = wpa_s->parent;
1035 if (!wpa_s->dbus_new_path)
1038 if (request || !status) {
1039 if (config_methods & WPS_CONFIG_DISPLAY)
1041 "ProvisionDiscoveryRequestDisplayPin" :
1042 "ProvisionDiscoveryResponseEnterPin";
1043 else if (config_methods & WPS_CONFIG_KEYPAD)
1045 "ProvisionDiscoveryRequestEnterPin" :
1046 "ProvisionDiscoveryResponseDisplayPin";
1047 else if (config_methods & WPS_CONFIG_PUSHBUTTON)
1048 _signal = request ? "ProvisionDiscoveryPBCRequest" :
1049 "ProvisionDiscoveryPBCResponse";
1051 return; /* Unknown or un-supported method */
1053 /* Explicit check for failure response */
1054 _signal = "ProvisionDiscoveryFailure";
1057 add_pin = ((request && (config_methods & WPS_CONFIG_DISPLAY)) ||
1058 (!request && !status &&
1059 (config_methods & WPS_CONFIG_KEYPAD)));
1062 os_snprintf(pin, sizeof(pin), "%08d", generated_pin);
1066 msg = dbus_message_new_signal(wpa_s->dbus_new_path,
1067 WPAS_DBUS_NEW_IFACE_P2PDEVICE, _signal);
1071 /* Check if this is a known peer */
1072 if (!p2p_peer_known(wpa_s->global->p2p, dev_addr))
1075 os_snprintf(peer_obj_path, WPAS_DBUS_OBJECT_PATH_MAX,
1076 "%s/" WPAS_DBUS_NEW_P2P_PEERS_PART "/"
1078 wpa_s->dbus_new_path, MAC2STR(dev_addr));
1080 path = peer_obj_path;
1082 dbus_message_iter_init_append(msg, &iter);
1084 if (!dbus_message_iter_append_basic(&iter,
1085 DBUS_TYPE_OBJECT_PATH,
1089 if (!request && status)
1090 /* Attach status to ProvisionDiscoveryFailure */
1091 error_ret = !dbus_message_iter_append_basic(&iter,
1095 error_ret = (add_pin &&
1096 !dbus_message_iter_append_basic(&iter,
1102 dbus_connection_send(iface->con, msg, NULL);
1104 wpa_printf(MSG_ERROR, "dbus: Failed to construct signal");
1106 dbus_message_unref(msg);
1111 * wpas_dbus_signal_p2p_go_neg_req - Signal P2P GO Negotiation Request RX
1112 * @wpa_s: %wpa_supplicant network interface data
1113 * @src: Source address of the message triggering this notification
1114 * @dev_passwd_id: WPS Device Password Id
1115 * @go_intent: Peer's GO Intent value
1117 * Sends signal to notify that a peer P2P Device is requesting group owner
1118 * negotiation with us.
1120 void wpas_dbus_signal_p2p_go_neg_req(struct wpa_supplicant *wpa_s,
1121 const u8 *src, u16 dev_passwd_id,
1125 DBusMessageIter iter;
1126 struct wpas_dbus_priv *iface;
1127 char peer_obj_path[WPAS_DBUS_OBJECT_PATH_MAX], *path;
1129 iface = wpa_s->global->dbus;
1131 /* Do nothing if the control interface is not turned on */
1135 if (wpa_s->p2p_mgmt)
1136 wpa_s = wpa_s->parent;
1137 if (!wpa_s->dbus_new_path)
1140 os_snprintf(peer_obj_path, WPAS_DBUS_OBJECT_PATH_MAX,
1141 "%s/" WPAS_DBUS_NEW_P2P_PEERS_PART "/" COMPACT_MACSTR,
1142 wpa_s->dbus_new_path, MAC2STR(src));
1143 path = peer_obj_path;
1145 msg = dbus_message_new_signal(wpa_s->dbus_new_path,
1146 WPAS_DBUS_NEW_IFACE_P2PDEVICE,
1147 "GONegotiationRequest");
1151 dbus_message_iter_init_append(msg, &iter);
1153 if (!dbus_message_iter_append_basic(&iter, DBUS_TYPE_OBJECT_PATH,
1155 !dbus_message_iter_append_basic(&iter, DBUS_TYPE_UINT16,
1157 !dbus_message_iter_append_basic(&iter, DBUS_TYPE_BYTE,
1159 wpa_printf(MSG_ERROR, "dbus: Failed to construct signal");
1161 dbus_connection_send(iface->con, msg, NULL);
1163 dbus_message_unref(msg);
1167 static int wpas_dbus_get_group_obj_path(struct wpa_supplicant *wpa_s,
1168 const struct wpa_ssid *ssid,
1169 char *group_obj_path)
1173 if (!wpa_s->dbus_new_path ||
1174 os_memcmp(ssid->ssid, P2P_WILDCARD_SSID, P2P_WILDCARD_SSID_LEN))
1177 os_memcpy(group_name, ssid->ssid + P2P_WILDCARD_SSID_LEN, 2);
1178 group_name[2] = '\0';
1180 os_snprintf(group_obj_path, WPAS_DBUS_OBJECT_PATH_MAX,
1181 "%s/" WPAS_DBUS_NEW_P2P_GROUPS_PART "/%s",
1182 wpa_s->dbus_new_path, group_name);
1188 struct group_changed_data {
1189 struct wpa_supplicant *wpa_s;
1190 struct p2p_peer_info *info;
1194 static int match_group_where_peer_is_client(struct p2p_group *group,
1197 struct group_changed_data *data = user_data;
1198 const struct p2p_group_config *cfg;
1199 struct wpa_supplicant *wpa_s_go;
1201 if (!p2p_group_is_client_connected(group, data->info->p2p_device_addr))
1204 cfg = p2p_group_get_config(group);
1206 wpa_s_go = wpas_get_p2p_go_iface(data->wpa_s, cfg->ssid,
1208 if (wpa_s_go != NULL && wpa_s_go == data->wpa_s) {
1209 wpas_dbus_signal_peer_groups_changed(
1210 data->wpa_s->parent, data->info->p2p_device_addr);
1218 static void signal_peer_groups_changed(struct p2p_peer_info *info,
1221 struct group_changed_data *data = user_data;
1222 struct wpa_supplicant *wpa_s_go;
1224 wpa_s_go = wpas_get_p2p_client_iface(data->wpa_s,
1225 info->p2p_device_addr);
1226 if (wpa_s_go != NULL && wpa_s_go == data->wpa_s) {
1227 wpas_dbus_signal_peer_groups_changed(data->wpa_s->parent,
1228 info->p2p_device_addr);
1233 p2p_loop_on_all_groups(data->wpa_s->global->p2p,
1234 match_group_where_peer_is_client, data);
1239 static void peer_groups_changed(struct wpa_supplicant *wpa_s)
1241 struct group_changed_data data;
1243 os_memset(&data, 0, sizeof(data));
1246 p2p_loop_on_known_peers(wpa_s->global->p2p,
1247 signal_peer_groups_changed, &data);
1252 * wpas_dbus_signal_p2p_group_started - Signals P2P group has
1253 * started. Emitted when a group is successfully started
1254 * irrespective of the role (client/GO) of the current device
1256 * @wpa_s: %wpa_supplicant network interface data
1257 * @ssid: SSID object
1258 * @client: this device is P2P client
1259 * @network_id: network id of the group started, use instead of ssid->id
1260 * to account for persistent groups
1262 void wpas_dbus_signal_p2p_group_started(struct wpa_supplicant *wpa_s,
1263 const struct wpa_ssid *ssid,
1264 int client, int network_id)
1267 DBusMessageIter iter, dict_iter;
1268 struct wpas_dbus_priv *iface;
1269 struct wpa_supplicant *parent;
1271 parent = wpa_s->parent;
1272 if (parent->p2p_mgmt)
1273 parent = parent->parent;
1275 iface = parent->global->dbus;
1277 /* Do nothing if the control interface is not turned on */
1278 if (iface == NULL || !parent->dbus_new_path || !wpa_s->dbus_new_path)
1281 if (wpa_s->dbus_groupobj_path == NULL)
1284 /* New interface has been created for this group */
1285 msg = dbus_message_new_signal(parent->dbus_new_path,
1286 WPAS_DBUS_NEW_IFACE_P2PDEVICE,
1291 dbus_message_iter_init_append(msg, &iter);
1293 * In case the device supports creating a separate interface the
1294 * DBus client will need to know the object path for the interface
1295 * object this group was created on, so include it here.
1297 if (!wpa_dbus_dict_open_write(&iter, &dict_iter) ||
1298 !wpa_dbus_dict_append_object_path(&dict_iter,
1300 wpa_s->dbus_new_path) ||
1301 !wpa_dbus_dict_append_string(&dict_iter, "role",
1302 client ? "client" : "GO") ||
1303 !wpa_dbus_dict_append_object_path(&dict_iter, "group_object",
1304 wpa_s->dbus_groupobj_path) ||
1305 !wpa_dbus_dict_close_write(&iter, &dict_iter)) {
1306 wpa_printf(MSG_ERROR, "dbus: Failed to construct signal");
1308 dbus_connection_send(iface->con, msg, NULL);
1310 peer_groups_changed(wpa_s);
1312 dbus_message_unref(msg);
1317 * wpas_dbus_signal_p2p_go_neg_resp - Emit GONegotiation Success/Failure signal
1318 * @wpa_s: %wpa_supplicant network interface data
1319 * @res: Result of the GO Neg Request
1321 void wpas_dbus_signal_p2p_go_neg_resp(struct wpa_supplicant *wpa_s,
1322 struct p2p_go_neg_results *res)
1325 DBusMessageIter iter, dict_iter;
1326 DBusMessageIter iter_dict_entry, iter_dict_val, iter_dict_array;
1327 struct wpas_dbus_priv *iface;
1328 char peer_obj_path[WPAS_DBUS_OBJECT_PATH_MAX], *path;
1329 dbus_int32_t freqs[P2P_MAX_CHANNELS];
1330 dbus_int32_t *f_array = freqs;
1333 iface = wpa_s->global->dbus;
1335 if (wpa_s->p2p_mgmt)
1336 wpa_s = wpa_s->parent;
1338 os_memset(freqs, 0, sizeof(freqs));
1339 /* Do nothing if the control interface is not turned on */
1340 if (iface == NULL || !wpa_s->dbus_new_path)
1343 os_snprintf(peer_obj_path, WPAS_DBUS_OBJECT_PATH_MAX,
1344 "%s/" WPAS_DBUS_NEW_P2P_PEERS_PART "/" COMPACT_MACSTR,
1345 wpa_s->dbus_new_path, MAC2STR(res->peer_device_addr));
1346 path = peer_obj_path;
1348 msg = dbus_message_new_signal(wpa_s->dbus_new_path,
1349 WPAS_DBUS_NEW_IFACE_P2PDEVICE,
1350 res->status ? "GONegotiationFailure" :
1351 "GONegotiationSuccess");
1355 dbus_message_iter_init_append(msg, &iter);
1356 if (!wpa_dbus_dict_open_write(&iter, &dict_iter) ||
1357 !wpa_dbus_dict_append_object_path(&dict_iter, "peer_object",
1359 !wpa_dbus_dict_append_int32(&dict_iter, "status", res->status))
1364 int freq_list_num = 0;
1366 if ((res->role_go &&
1367 !wpa_dbus_dict_append_string(&dict_iter, "passphrase",
1368 res->passphrase)) ||
1369 !wpa_dbus_dict_append_string(&dict_iter, "role_go",
1370 res->role_go ? "GO" :
1372 !wpa_dbus_dict_append_int32(&dict_iter, "frequency",
1374 !wpa_dbus_dict_append_byte_array(&dict_iter, "ssid",
1375 (const char *) res->ssid,
1377 !wpa_dbus_dict_append_byte_array(&dict_iter,
1380 res->peer_device_addr,
1382 !wpa_dbus_dict_append_byte_array(&dict_iter,
1383 "peer_interface_addr",
1385 res->peer_interface_addr,
1387 !wpa_dbus_dict_append_string(&dict_iter, "wps_method",
1388 p2p_wps_method_text(
1392 for (i = 0; i < P2P_MAX_CHANNELS; i++) {
1393 if (res->freq_list[i]) {
1394 freqs[i] = res->freq_list[i];
1399 if (!wpa_dbus_dict_begin_array(&dict_iter,
1401 DBUS_TYPE_INT32_AS_STRING,
1404 &iter_dict_array) ||
1405 !dbus_message_iter_append_fixed_array(&iter_dict_array,
1409 !wpa_dbus_dict_end_array(&dict_iter,
1412 &iter_dict_array) ||
1413 !wpa_dbus_dict_append_int32(&dict_iter, "persistent_group",
1414 res->persistent_group) ||
1415 !wpa_dbus_dict_append_uint32(&dict_iter,
1416 "peer_config_timeout",
1417 res->peer_config_timeout))
1421 if (!wpa_dbus_dict_close_write(&iter, &dict_iter))
1424 dbus_connection_send(iface->con, msg, NULL);
1426 dbus_message_unref(msg);
1431 * wpas_dbus_signal_p2p_invitation_result - Emit InvitationResult signal
1432 * @wpa_s: %wpa_supplicant network interface data
1433 * @status: Status of invitation process
1434 * @bssid: Basic Service Set Identifier
1436 void wpas_dbus_signal_p2p_invitation_result(struct wpa_supplicant *wpa_s,
1437 int status, const u8 *bssid)
1440 DBusMessageIter iter, dict_iter;
1441 struct wpas_dbus_priv *iface;
1443 wpa_printf(MSG_DEBUG, "%s", __func__);
1445 iface = wpa_s->global->dbus;
1446 /* Do nothing if the control interface is not turned on */
1450 if (wpa_s->p2p_mgmt)
1451 wpa_s = wpa_s->parent;
1452 if (!wpa_s->dbus_new_path)
1455 msg = dbus_message_new_signal(wpa_s->dbus_new_path,
1456 WPAS_DBUS_NEW_IFACE_P2PDEVICE,
1457 "InvitationResult");
1462 dbus_message_iter_init_append(msg, &iter);
1463 if (!wpa_dbus_dict_open_write(&iter, &dict_iter) ||
1464 !wpa_dbus_dict_append_int32(&dict_iter, "status", status) ||
1466 !wpa_dbus_dict_append_byte_array(&dict_iter, "BSSID",
1467 (const char *) bssid,
1469 !wpa_dbus_dict_close_write(&iter, &dict_iter))
1470 wpa_printf(MSG_ERROR, "dbus: Failed to construct signal");
1472 dbus_connection_send(iface->con, msg, NULL);
1473 dbus_message_unref(msg);
1479 * Method to emit a signal for a peer joining the group.
1480 * The signal will carry path to the group member object
1481 * constructed using p2p i/f addr used for connecting.
1483 * @wpa_s: %wpa_supplicant network interface data
1484 * @peer_addr: P2P Device Address of the peer joining the group
1486 void wpas_dbus_signal_p2p_peer_joined(struct wpa_supplicant *wpa_s,
1487 const u8 *peer_addr)
1489 struct wpas_dbus_priv *iface;
1491 DBusMessageIter iter;
1492 char peer_obj_path[WPAS_DBUS_OBJECT_PATH_MAX], *path;
1493 struct wpa_supplicant *parent;
1495 iface = wpa_s->global->dbus;
1497 /* Do nothing if the control interface is not turned on */
1501 if (!wpa_s->dbus_groupobj_path)
1504 parent = wpa_s->parent;
1505 if (parent->p2p_mgmt)
1506 parent = parent->parent;
1507 if (!parent->dbus_new_path)
1510 os_snprintf(peer_obj_path, WPAS_DBUS_OBJECT_PATH_MAX,
1511 "%s/" WPAS_DBUS_NEW_P2P_PEERS_PART "/"
1513 parent->dbus_new_path, MAC2STR(peer_addr));
1515 msg = dbus_message_new_signal(wpa_s->dbus_groupobj_path,
1516 WPAS_DBUS_NEW_IFACE_P2P_GROUP,
1521 dbus_message_iter_init_append(msg, &iter);
1522 path = peer_obj_path;
1523 if (!dbus_message_iter_append_basic(&iter, DBUS_TYPE_OBJECT_PATH,
1525 wpa_printf(MSG_ERROR, "dbus: Failed to construct signal");
1527 dbus_connection_send(iface->con, msg, NULL);
1528 wpas_dbus_signal_peer_groups_changed(parent, peer_addr);
1530 dbus_message_unref(msg);
1536 * Method to emit a signal for a peer disconnecting the group.
1537 * The signal will carry path to the group member object
1538 * constructed using the P2P Device Address of the peer.
1540 * @wpa_s: %wpa_supplicant network interface data
1541 * @peer_addr: P2P Device Address of the peer joining the group
1543 void wpas_dbus_signal_p2p_peer_disconnected(struct wpa_supplicant *wpa_s,
1544 const u8 *peer_addr)
1546 struct wpas_dbus_priv *iface;
1548 DBusMessageIter iter;
1549 char peer_obj_path[WPAS_DBUS_OBJECT_PATH_MAX], *path;
1550 struct wpa_supplicant *parent;
1552 iface = wpa_s->global->dbus;
1554 /* Do nothing if the control interface is not turned on */
1558 if (!wpa_s->dbus_groupobj_path)
1561 parent = wpa_s->parent;
1562 if (parent->p2p_mgmt)
1563 parent = parent->parent;
1564 if (!parent->dbus_new_path)
1567 os_snprintf(peer_obj_path, WPAS_DBUS_OBJECT_PATH_MAX,
1568 "%s/" WPAS_DBUS_NEW_P2P_PEERS_PART "/"
1570 parent->dbus_new_path, MAC2STR(peer_addr));
1572 msg = dbus_message_new_signal(wpa_s->dbus_groupobj_path,
1573 WPAS_DBUS_NEW_IFACE_P2P_GROUP,
1574 "PeerDisconnected");
1578 dbus_message_iter_init_append(msg, &iter);
1579 path = peer_obj_path;
1580 if (!dbus_message_iter_append_basic(&iter, DBUS_TYPE_OBJECT_PATH,
1582 wpa_printf(MSG_ERROR,
1583 "dbus: Failed to construct PeerDisconnected signal");
1585 dbus_connection_send(iface->con, msg, NULL);
1586 wpas_dbus_signal_peer_groups_changed(parent, peer_addr);
1588 dbus_message_unref(msg);
1594 * Method to emit a signal for a service discovery request.
1595 * The signal will carry station address, frequency, dialog token,
1596 * update indicator and it tlvs
1598 * @wpa_s: %wpa_supplicant network interface data
1599 * @sa: station addr (p2p i/f) of the peer
1600 * @dialog_token: service discovery request dialog token
1601 * @update_indic: service discovery request update indicator
1602 * @tlvs: service discovery request genrated byte array of tlvs
1603 * @tlvs_len: service discovery request tlvs length
1605 void wpas_dbus_signal_p2p_sd_request(struct wpa_supplicant *wpa_s,
1606 int freq, const u8 *sa, u8 dialog_token,
1607 u16 update_indic, const u8 *tlvs,
1611 DBusMessageIter iter, dict_iter;
1612 struct wpas_dbus_priv *iface;
1613 char peer_obj_path[WPAS_DBUS_OBJECT_PATH_MAX], *path;
1615 iface = wpa_s->global->dbus;
1617 /* Do nothing if the control interface is not turned on */
1621 if (wpa_s->p2p_mgmt)
1622 wpa_s = wpa_s->parent;
1623 if (!wpa_s->dbus_new_path)
1626 /* Check if this is a known peer */
1627 if (!p2p_peer_known(wpa_s->global->p2p, sa))
1630 msg = dbus_message_new_signal(wpa_s->dbus_new_path,
1631 WPAS_DBUS_NEW_IFACE_P2PDEVICE,
1632 "ServiceDiscoveryRequest");
1636 os_snprintf(peer_obj_path, WPAS_DBUS_OBJECT_PATH_MAX,
1637 "%s/" WPAS_DBUS_NEW_P2P_PEERS_PART "/"
1638 COMPACT_MACSTR, wpa_s->dbus_new_path, MAC2STR(sa));
1640 path = peer_obj_path;
1642 dbus_message_iter_init_append(msg, &iter);
1643 if (!wpa_dbus_dict_open_write(&iter, &dict_iter) ||
1644 !wpa_dbus_dict_append_object_path(&dict_iter, "peer_object",
1646 !wpa_dbus_dict_append_int32(&dict_iter, "frequency", freq) ||
1647 !wpa_dbus_dict_append_int32(&dict_iter, "dialog_token",
1649 !wpa_dbus_dict_append_uint16(&dict_iter, "update_indicator",
1651 !wpa_dbus_dict_append_byte_array(&dict_iter, "tlvs",
1652 (const char *) tlvs,
1654 !wpa_dbus_dict_close_write(&iter, &dict_iter))
1655 wpa_printf(MSG_ERROR, "dbus: Failed to construct signal");
1657 dbus_connection_send(iface->con, msg, NULL);
1658 dbus_message_unref(msg);
1664 * Method to emit a signal for a service discovery response.
1665 * The signal will carry station address, update indicator and it
1668 * @wpa_s: %wpa_supplicant network interface data
1669 * @sa: station addr (p2p i/f) of the peer
1670 * @update_indic: service discovery request update indicator
1671 * @tlvs: service discovery request genrated byte array of tlvs
1672 * @tlvs_len: service discovery request tlvs length
1674 void wpas_dbus_signal_p2p_sd_response(struct wpa_supplicant *wpa_s,
1675 const u8 *sa, u16 update_indic,
1676 const u8 *tlvs, size_t tlvs_len)
1679 DBusMessageIter iter, dict_iter;
1680 struct wpas_dbus_priv *iface;
1681 char peer_obj_path[WPAS_DBUS_OBJECT_PATH_MAX], *path;
1683 iface = wpa_s->global->dbus;
1685 /* Do nothing if the control interface is not turned on */
1689 if (wpa_s->p2p_mgmt)
1690 wpa_s = wpa_s->parent;
1691 if (!wpa_s->dbus_new_path)
1694 /* Check if this is a known peer */
1695 if (!p2p_peer_known(wpa_s->global->p2p, sa))
1698 msg = dbus_message_new_signal(wpa_s->dbus_new_path,
1699 WPAS_DBUS_NEW_IFACE_P2PDEVICE,
1700 "ServiceDiscoveryResponse");
1704 os_snprintf(peer_obj_path, WPAS_DBUS_OBJECT_PATH_MAX,
1705 "%s/" WPAS_DBUS_NEW_P2P_PEERS_PART "/"
1706 COMPACT_MACSTR, wpa_s->dbus_new_path, MAC2STR(sa));
1708 path = peer_obj_path;
1710 dbus_message_iter_init_append(msg, &iter);
1711 if (!wpa_dbus_dict_open_write(&iter, &dict_iter) ||
1712 !wpa_dbus_dict_append_object_path(&dict_iter, "peer_object",
1714 !wpa_dbus_dict_append_uint16(&dict_iter, "update_indicator",
1716 !wpa_dbus_dict_append_byte_array(&dict_iter, "tlvs",
1717 (const char *) tlvs,
1719 !wpa_dbus_dict_close_write(&iter, &dict_iter))
1720 wpa_printf(MSG_ERROR, "dbus: Failed to construct signal");
1722 dbus_connection_send(iface->con, msg, NULL);
1723 dbus_message_unref(msg);
1728 * wpas_dbus_signal_persistent_group - Send a persistent group related
1730 * @wpa_s: %wpa_supplicant network interface data
1731 * @id: new persistent group id
1732 * @sig_name: signal name - PersistentGroupAdded, PersistentGroupRemoved
1733 * @properties: determines if add second argument with object properties
1735 * Notify listeners about an event related to persistent groups.
1737 static void wpas_dbus_signal_persistent_group(struct wpa_supplicant *wpa_s,
1738 int id, const char *sig_name,
1741 struct wpas_dbus_priv *iface;
1743 DBusMessageIter iter;
1744 char pgrp_obj_path[WPAS_DBUS_OBJECT_PATH_MAX], *path;
1746 iface = wpa_s->global->dbus;
1748 /* Do nothing if the control interface is not turned on */
1752 if (wpa_s->p2p_mgmt)
1753 wpa_s = wpa_s->parent;
1754 if (!wpa_s->dbus_new_path)
1757 os_snprintf(pgrp_obj_path, WPAS_DBUS_OBJECT_PATH_MAX,
1758 "%s/" WPAS_DBUS_NEW_PERSISTENT_GROUPS_PART "/%u",
1759 wpa_s->dbus_new_path, id);
1761 msg = dbus_message_new_signal(wpa_s->dbus_new_path,
1762 WPAS_DBUS_NEW_IFACE_P2PDEVICE,
1767 dbus_message_iter_init_append(msg, &iter);
1768 path = pgrp_obj_path;
1769 if (!dbus_message_iter_append_basic(&iter, DBUS_TYPE_OBJECT_PATH,
1772 !wpa_dbus_get_object_properties(
1773 iface, pgrp_obj_path,
1774 WPAS_DBUS_NEW_IFACE_PERSISTENT_GROUP, &iter)))
1775 wpa_printf(MSG_ERROR, "dbus: Failed to construct signal");
1777 dbus_connection_send(iface->con, msg, NULL);
1779 dbus_message_unref(msg);
1784 * wpas_dbus_signal_persistent_group_added - Send a persistent_group
1786 * @wpa_s: %wpa_supplicant network interface data
1787 * @id: new persistent group id
1789 * Notify listeners about addition of a new persistent group.
1791 static void wpas_dbus_signal_persistent_group_added(
1792 struct wpa_supplicant *wpa_s, int id)
1794 wpas_dbus_signal_persistent_group(wpa_s, id, "PersistentGroupAdded",
1800 * wpas_dbus_signal_persistent_group_removed - Send a persistent_group
1802 * @wpa_s: %wpa_supplicant network interface data
1803 * @id: persistent group id
1805 * Notify listeners about removal of a persistent group.
1807 static void wpas_dbus_signal_persistent_group_removed(
1808 struct wpa_supplicant *wpa_s, int id)
1810 wpas_dbus_signal_persistent_group(wpa_s, id, "PersistentGroupRemoved",
1816 * wpas_dbus_signal_p2p_wps_failed - Signals WpsFailed event
1817 * @wpa_s: %wpa_supplicant network interface data
1818 * @fail: WPS failure information
1820 * Sends Event dbus signal with name "fail" and dictionary containing
1821 * "msg" field with fail message number (int32) as arguments
1823 void wpas_dbus_signal_p2p_wps_failed(struct wpa_supplicant *wpa_s,
1824 struct wps_event_fail *fail)
1828 DBusMessageIter iter, dict_iter;
1829 struct wpas_dbus_priv *iface;
1832 iface = wpa_s->global->dbus;
1834 /* Do nothing if the control interface is not turned on */
1838 if (wpa_s->p2p_mgmt)
1839 wpa_s = wpa_s->parent;
1841 if (!wpa_s->dbus_new_path)
1843 msg = dbus_message_new_signal(wpa_s->dbus_new_path,
1844 WPAS_DBUS_NEW_IFACE_P2PDEVICE,
1849 dbus_message_iter_init_append(msg, &iter);
1851 if (!dbus_message_iter_append_basic(&iter, DBUS_TYPE_STRING, &key) ||
1852 !wpa_dbus_dict_open_write(&iter, &dict_iter) ||
1853 !wpa_dbus_dict_append_int32(&dict_iter, "msg", fail->msg) ||
1854 !wpa_dbus_dict_append_int16(&dict_iter, "config_error",
1855 fail->config_error) ||
1856 !wpa_dbus_dict_close_write(&iter, &dict_iter))
1857 wpa_printf(MSG_ERROR, "dbus: Failed to construct signal");
1859 dbus_connection_send(iface->con, msg, NULL);
1861 dbus_message_unref(msg);
1866 * wpas_dbus_signal_p2p_group_formation_failure - Signals GroupFormationFailure event
1867 * @wpa_s: %wpa_supplicant network interface data
1868 * @reason: indicates the reason code for group formation failure
1870 * Sends Event dbus signal and string reason code when available.
1872 void wpas_dbus_signal_p2p_group_formation_failure(struct wpa_supplicant *wpa_s,
1876 struct wpas_dbus_priv *iface;
1878 iface = wpa_s->global->dbus;
1880 /* Do nothing if the control interface is not turned on */
1884 msg = dbus_message_new_signal(wpa_s->dbus_new_path,
1885 WPAS_DBUS_NEW_IFACE_P2PDEVICE,
1886 "GroupFormationFailure");
1890 if (dbus_message_append_args(msg, DBUS_TYPE_STRING, &reason,
1892 dbus_connection_send(iface->con, msg, NULL);
1894 wpa_printf(MSG_ERROR, "dbus: Failed to construct signal");
1896 dbus_message_unref(msg);
1899 #endif /* CONFIG_P2P */
1903 * wpas_dbus_signal_prop_changed - Signals change of property
1904 * @wpa_s: %wpa_supplicant network interface data
1905 * @property: indicates which property has changed
1907 * Sends PropertyChanged signals with path, interface and arguments
1908 * depending on which property has changed.
1910 void wpas_dbus_signal_prop_changed(struct wpa_supplicant *wpa_s,
1911 enum wpas_dbus_prop property)
1916 if (wpa_s->dbus_new_path == NULL)
1917 return; /* Skip signal since D-Bus setup is not yet ready */
1921 case WPAS_DBUS_PROP_AP_SCAN:
1924 case WPAS_DBUS_PROP_SCANNING:
1927 case WPAS_DBUS_PROP_STATE:
1930 case WPAS_DBUS_PROP_CURRENT_BSS:
1931 prop = "CurrentBSS";
1933 case WPAS_DBUS_PROP_CURRENT_NETWORK:
1934 prop = "CurrentNetwork";
1936 case WPAS_DBUS_PROP_BSSS:
1939 case WPAS_DBUS_PROP_CURRENT_AUTH_MODE:
1940 prop = "CurrentAuthMode";
1942 case WPAS_DBUS_PROP_DISCONNECT_REASON:
1943 prop = "DisconnectReason";
1947 wpa_printf(MSG_ERROR, "dbus: %s: Unknown Property value %d",
1948 __func__, property);
1952 wpa_dbus_mark_property_changed(wpa_s->global->dbus,
1953 wpa_s->dbus_new_path,
1954 WPAS_DBUS_NEW_IFACE_INTERFACE, prop);
1956 wpa_dbus_flush_object_changed_properties(
1957 wpa_s->global->dbus->con, wpa_s->dbus_new_path);
1963 * wpas_dbus_bss_signal_prop_changed - Signals change of BSS property
1964 * @wpa_s: %wpa_supplicant network interface data
1965 * @property: indicates which property has changed
1966 * @id: unique BSS identifier
1968 * Sends PropertyChanged signals with path, interface, and arguments depending
1969 * on which property has changed.
1971 void wpas_dbus_bss_signal_prop_changed(struct wpa_supplicant *wpa_s,
1972 enum wpas_dbus_bss_prop property,
1975 char path[WPAS_DBUS_OBJECT_PATH_MAX];
1978 if (!wpa_s->dbus_new_path)
1982 case WPAS_DBUS_BSS_PROP_SIGNAL:
1985 case WPAS_DBUS_BSS_PROP_FREQ:
1988 case WPAS_DBUS_BSS_PROP_MODE:
1991 case WPAS_DBUS_BSS_PROP_PRIVACY:
1994 case WPAS_DBUS_BSS_PROP_RATES:
1997 case WPAS_DBUS_BSS_PROP_WPA:
2000 case WPAS_DBUS_BSS_PROP_RSN:
2003 case WPAS_DBUS_BSS_PROP_WPS:
2006 case WPAS_DBUS_BSS_PROP_IES:
2009 case WPAS_DBUS_BSS_PROP_AGE:
2013 wpa_printf(MSG_ERROR, "dbus: %s: Unknown Property value %d",
2014 __func__, property);
2018 os_snprintf(path, WPAS_DBUS_OBJECT_PATH_MAX,
2019 "%s/" WPAS_DBUS_NEW_BSSIDS_PART "/%u",
2020 wpa_s->dbus_new_path, id);
2022 wpa_dbus_mark_property_changed(wpa_s->global->dbus, path,
2023 WPAS_DBUS_NEW_IFACE_BSS, prop);
2028 * wpas_dbus_signal_debug_level_changed - Signals change of debug param
2029 * @global: wpa_global structure
2031 * Sends PropertyChanged signals informing that debug level has changed.
2033 void wpas_dbus_signal_debug_level_changed(struct wpa_global *global)
2035 wpa_dbus_mark_property_changed(global->dbus, WPAS_DBUS_NEW_PATH,
2036 WPAS_DBUS_NEW_INTERFACE,
2042 * wpas_dbus_signal_debug_timestamp_changed - Signals change of debug param
2043 * @global: wpa_global structure
2045 * Sends PropertyChanged signals informing that debug timestamp has changed.
2047 void wpas_dbus_signal_debug_timestamp_changed(struct wpa_global *global)
2049 wpa_dbus_mark_property_changed(global->dbus, WPAS_DBUS_NEW_PATH,
2050 WPAS_DBUS_NEW_INTERFACE,
2056 * wpas_dbus_signal_debug_show_keys_changed - Signals change of debug param
2057 * @global: wpa_global structure
2059 * Sends PropertyChanged signals informing that debug show_keys has changed.
2061 void wpas_dbus_signal_debug_show_keys_changed(struct wpa_global *global)
2063 wpa_dbus_mark_property_changed(global->dbus, WPAS_DBUS_NEW_PATH,
2064 WPAS_DBUS_NEW_INTERFACE,
2069 static void wpas_dbus_register(struct wpa_dbus_object_desc *obj_desc,
2071 WPADBusArgumentFreeFunction priv_free,
2072 const struct wpa_dbus_method_desc *methods,
2073 const struct wpa_dbus_property_desc *properties,
2074 const struct wpa_dbus_signal_desc *signals)
2078 obj_desc->user_data = priv;
2079 obj_desc->user_data_free_func = priv_free;
2080 obj_desc->methods = methods;
2081 obj_desc->properties = properties;
2082 obj_desc->signals = signals;
2084 for (n = 0; properties && properties->dbus_property; properties++)
2087 obj_desc->prop_changed_flags = os_zalloc(n);
2088 if (!obj_desc->prop_changed_flags)
2089 wpa_printf(MSG_DEBUG, "dbus: %s: can't register handlers",
2094 static const struct wpa_dbus_method_desc wpas_dbus_global_methods[] = {
2095 { "CreateInterface", WPAS_DBUS_NEW_INTERFACE,
2096 (WPADBusMethodHandler) wpas_dbus_handler_create_interface,
2098 { "args", "a{sv}", ARG_IN },
2099 { "path", "o", ARG_OUT },
2103 { "RemoveInterface", WPAS_DBUS_NEW_INTERFACE,
2104 (WPADBusMethodHandler) wpas_dbus_handler_remove_interface,
2106 { "path", "o", ARG_IN },
2110 { "GetInterface", WPAS_DBUS_NEW_INTERFACE,
2111 (WPADBusMethodHandler) wpas_dbus_handler_get_interface,
2113 { "ifname", "s", ARG_IN },
2114 { "path", "o", ARG_OUT },
2118 { NULL, NULL, NULL, { END_ARGS } }
2121 static const struct wpa_dbus_property_desc wpas_dbus_global_properties[] = {
2122 { "DebugLevel", WPAS_DBUS_NEW_INTERFACE, "s",
2123 wpas_dbus_getter_debug_level,
2124 wpas_dbus_setter_debug_level
2126 { "DebugTimestamp", WPAS_DBUS_NEW_INTERFACE, "b",
2127 wpas_dbus_getter_debug_timestamp,
2128 wpas_dbus_setter_debug_timestamp
2130 { "DebugShowKeys", WPAS_DBUS_NEW_INTERFACE, "b",
2131 wpas_dbus_getter_debug_show_keys,
2132 wpas_dbus_setter_debug_show_keys
2134 { "Interfaces", WPAS_DBUS_NEW_INTERFACE, "ao",
2135 wpas_dbus_getter_interfaces,
2138 { "EapMethods", WPAS_DBUS_NEW_INTERFACE, "as",
2139 wpas_dbus_getter_eap_methods,
2142 { "Capabilities", WPAS_DBUS_NEW_INTERFACE, "as",
2143 wpas_dbus_getter_global_capabilities,
2146 #ifdef CONFIG_WIFI_DISPLAY
2147 { "WFDIEs", WPAS_DBUS_NEW_INTERFACE, "ay",
2148 wpas_dbus_getter_global_wfd_ies,
2149 wpas_dbus_setter_global_wfd_ies
2151 #endif /* CONFIG_WIFI_DISPLAY */
2152 { NULL, NULL, NULL, NULL, NULL }
2155 static const struct wpa_dbus_signal_desc wpas_dbus_global_signals[] = {
2156 { "InterfaceAdded", WPAS_DBUS_NEW_INTERFACE,
2158 { "path", "o", ARG_OUT },
2159 { "properties", "a{sv}", ARG_OUT },
2163 { "InterfaceRemoved", WPAS_DBUS_NEW_INTERFACE,
2165 { "path", "o", ARG_OUT },
2169 /* Deprecated: use org.freedesktop.DBus.Properties.PropertiesChanged */
2170 { "PropertiesChanged", WPAS_DBUS_NEW_INTERFACE,
2172 { "properties", "a{sv}", ARG_OUT },
2176 { NULL, NULL, { END_ARGS } }
2181 * wpas_dbus_ctrl_iface_init - Initialize dbus control interface
2182 * @global: Pointer to global data from wpa_supplicant_init()
2183 * Returns: 0 on success or -1 on failure
2185 * Initialize the dbus control interface for wpa_supplicantand and start
2186 * receiving commands from external programs over the bus.
2188 int wpas_dbus_ctrl_iface_init(struct wpas_dbus_priv *priv)
2190 struct wpa_dbus_object_desc *obj_desc;
2193 obj_desc = os_zalloc(sizeof(struct wpa_dbus_object_desc));
2195 wpa_printf(MSG_ERROR,
2196 "Not enough memory to create object description");
2200 wpas_dbus_register(obj_desc, priv->global, NULL,
2201 wpas_dbus_global_methods,
2202 wpas_dbus_global_properties,
2203 wpas_dbus_global_signals);
2205 wpa_printf(MSG_DEBUG, "dbus: Register D-Bus object '%s'",
2206 WPAS_DBUS_NEW_PATH);
2207 ret = wpa_dbus_ctrl_iface_init(priv, WPAS_DBUS_NEW_PATH,
2208 WPAS_DBUS_NEW_SERVICE,
2211 free_dbus_object_desc(obj_desc);
2213 priv->dbus_new_initialized = 1;
2220 * wpas_dbus_ctrl_iface_deinit - Deinitialize dbus ctrl interface for
2222 * @iface: Pointer to dbus private data from wpas_dbus_init()
2224 * Deinitialize the dbus control interface that was initialized with
2225 * wpas_dbus_ctrl_iface_init().
2227 void wpas_dbus_ctrl_iface_deinit(struct wpas_dbus_priv *iface)
2229 if (!iface->dbus_new_initialized)
2231 wpa_printf(MSG_DEBUG, "dbus: Unregister D-Bus object '%s'",
2232 WPAS_DBUS_NEW_PATH);
2233 dbus_connection_unregister_object_path(iface->con,
2234 WPAS_DBUS_NEW_PATH);
2238 static void wpa_dbus_free(void *ptr)
2244 static const struct wpa_dbus_property_desc wpas_dbus_network_properties[] = {
2245 { "Properties", WPAS_DBUS_NEW_IFACE_NETWORK, "a{sv}",
2246 wpas_dbus_getter_network_properties,
2247 wpas_dbus_setter_network_properties
2249 { "Enabled", WPAS_DBUS_NEW_IFACE_NETWORK, "b",
2250 wpas_dbus_getter_enabled,
2251 wpas_dbus_setter_enabled
2253 { NULL, NULL, NULL, NULL, NULL }
2257 static const struct wpa_dbus_signal_desc wpas_dbus_network_signals[] = {
2258 /* Deprecated: use org.freedesktop.DBus.Properties.PropertiesChanged */
2259 { "PropertiesChanged", WPAS_DBUS_NEW_IFACE_NETWORK,
2261 { "properties", "a{sv}", ARG_OUT },
2265 { NULL, NULL, { END_ARGS } }
2270 * wpas_dbus_register_network - Register a configured network with dbus
2271 * @wpa_s: wpa_supplicant interface structure
2272 * @ssid: network configuration data
2273 * Returns: 0 on success, -1 on failure
2275 * Registers network representing object with dbus
2277 int wpas_dbus_register_network(struct wpa_supplicant *wpa_s,
2278 struct wpa_ssid *ssid)
2280 struct wpas_dbus_priv *ctrl_iface;
2281 struct wpa_dbus_object_desc *obj_desc;
2282 struct network_handler_args *arg;
2283 char net_obj_path[WPAS_DBUS_OBJECT_PATH_MAX];
2287 * If it is a persistent group register it as such.
2288 * This is to handle cases where an interface is being initialized
2289 * with a list of networks read from config.
2291 if (network_is_persistent_group(ssid))
2292 return wpas_dbus_register_persistent_group(wpa_s, ssid);
2293 #endif /* CONFIG_P2P */
2295 /* Do nothing if the control interface is not turned on */
2296 if (wpa_s == NULL || wpa_s->global == NULL || !wpa_s->dbus_new_path)
2298 ctrl_iface = wpa_s->global->dbus;
2299 if (ctrl_iface == NULL)
2302 os_snprintf(net_obj_path, WPAS_DBUS_OBJECT_PATH_MAX,
2303 "%s/" WPAS_DBUS_NEW_NETWORKS_PART "/%u",
2304 wpa_s->dbus_new_path, ssid->id);
2306 wpa_printf(MSG_DEBUG, "dbus: Register network object '%s'",
2308 obj_desc = os_zalloc(sizeof(struct wpa_dbus_object_desc));
2310 wpa_printf(MSG_ERROR,
2311 "Not enough memory to create object description");
2315 /* allocate memory for handlers arguments */
2316 arg = os_zalloc(sizeof(struct network_handler_args));
2318 wpa_printf(MSG_ERROR,
2319 "Not enough memory to create arguments for method");
2326 wpas_dbus_register(obj_desc, arg, wpa_dbus_free, NULL,
2327 wpas_dbus_network_properties,
2328 wpas_dbus_network_signals);
2330 if (wpa_dbus_register_object_per_iface(ctrl_iface, net_obj_path,
2331 wpa_s->ifname, obj_desc))
2334 wpas_dbus_signal_network_added(wpa_s, ssid->id);
2339 free_dbus_object_desc(obj_desc);
2345 * wpas_dbus_unregister_network - Unregister a configured network from dbus
2346 * @wpa_s: wpa_supplicant interface structure
2348 * Returns: 0 on success, -1 on failure
2350 * Unregisters network representing object from dbus
2352 int wpas_dbus_unregister_network(struct wpa_supplicant *wpa_s, int nid)
2354 struct wpas_dbus_priv *ctrl_iface;
2355 char net_obj_path[WPAS_DBUS_OBJECT_PATH_MAX];
2358 struct wpa_ssid *ssid;
2360 ssid = wpa_config_get_network(wpa_s->conf, nid);
2362 /* If it is a persistent group unregister it as such */
2363 if (ssid && network_is_persistent_group(ssid))
2364 return wpas_dbus_unregister_persistent_group(wpa_s, nid);
2365 #endif /* CONFIG_P2P */
2367 /* Do nothing if the control interface is not turned on */
2368 if (wpa_s->global == NULL || wpa_s->dbus_new_path == NULL)
2370 ctrl_iface = wpa_s->global->dbus;
2371 if (ctrl_iface == NULL)
2374 os_snprintf(net_obj_path, WPAS_DBUS_OBJECT_PATH_MAX,
2375 "%s/" WPAS_DBUS_NEW_NETWORKS_PART "/%u",
2376 wpa_s->dbus_new_path, nid);
2378 wpa_printf(MSG_DEBUG, "dbus: Unregister network object '%s'",
2380 ret = wpa_dbus_unregister_object_per_iface(ctrl_iface, net_obj_path);
2383 wpas_dbus_signal_network_removed(wpa_s, nid);
2389 static const struct wpa_dbus_property_desc wpas_dbus_bss_properties[] = {
2390 { "SSID", WPAS_DBUS_NEW_IFACE_BSS, "ay",
2391 wpas_dbus_getter_bss_ssid,
2394 { "BSSID", WPAS_DBUS_NEW_IFACE_BSS, "ay",
2395 wpas_dbus_getter_bss_bssid,
2398 { "Privacy", WPAS_DBUS_NEW_IFACE_BSS, "b",
2399 wpas_dbus_getter_bss_privacy,
2402 { "Mode", WPAS_DBUS_NEW_IFACE_BSS, "s",
2403 wpas_dbus_getter_bss_mode,
2406 { "Signal", WPAS_DBUS_NEW_IFACE_BSS, "n",
2407 wpas_dbus_getter_bss_signal,
2410 { "Frequency", WPAS_DBUS_NEW_IFACE_BSS, "q",
2411 wpas_dbus_getter_bss_frequency,
2414 { "Rates", WPAS_DBUS_NEW_IFACE_BSS, "au",
2415 wpas_dbus_getter_bss_rates,
2418 { "WPA", WPAS_DBUS_NEW_IFACE_BSS, "a{sv}",
2419 wpas_dbus_getter_bss_wpa,
2422 { "RSN", WPAS_DBUS_NEW_IFACE_BSS, "a{sv}",
2423 wpas_dbus_getter_bss_rsn,
2426 { "WPS", WPAS_DBUS_NEW_IFACE_BSS, "a{sv}",
2427 wpas_dbus_getter_bss_wps,
2430 { "IEs", WPAS_DBUS_NEW_IFACE_BSS, "ay",
2431 wpas_dbus_getter_bss_ies,
2434 { "Age", WPAS_DBUS_NEW_IFACE_BSS, "u",
2435 wpas_dbus_getter_bss_age,
2438 { NULL, NULL, NULL, NULL, NULL }
2442 static const struct wpa_dbus_signal_desc wpas_dbus_bss_signals[] = {
2443 /* Deprecated: use org.freedesktop.DBus.Properties.PropertiesChanged */
2444 { "PropertiesChanged", WPAS_DBUS_NEW_IFACE_BSS,
2446 { "properties", "a{sv}", ARG_OUT },
2450 { NULL, NULL, { END_ARGS } }
2455 * wpas_dbus_unregister_bss - Unregister a scanned BSS from dbus
2456 * @wpa_s: wpa_supplicant interface structure
2457 * @bssid: scanned network bssid
2458 * @id: unique BSS identifier
2459 * Returns: 0 on success, -1 on failure
2461 * Unregisters BSS representing object from dbus
2463 int wpas_dbus_unregister_bss(struct wpa_supplicant *wpa_s,
2464 u8 bssid[ETH_ALEN], unsigned int id)
2466 struct wpas_dbus_priv *ctrl_iface;
2467 char bss_obj_path[WPAS_DBUS_OBJECT_PATH_MAX];
2469 /* Do nothing if the control interface is not turned on */
2470 if (wpa_s == NULL || wpa_s->global == NULL || !wpa_s->dbus_new_path)
2472 ctrl_iface = wpa_s->global->dbus;
2473 if (ctrl_iface == NULL)
2476 os_snprintf(bss_obj_path, WPAS_DBUS_OBJECT_PATH_MAX,
2477 "%s/" WPAS_DBUS_NEW_BSSIDS_PART "/%u",
2478 wpa_s->dbus_new_path, id);
2480 wpa_printf(MSG_DEBUG, "dbus: Unregister BSS object '%s'",
2482 if (wpa_dbus_unregister_object_per_iface(ctrl_iface, bss_obj_path)) {
2483 wpa_printf(MSG_ERROR, "dbus: Cannot unregister BSS object %s",
2488 wpas_dbus_signal_bss_removed(wpa_s, bss_obj_path);
2489 wpas_dbus_signal_prop_changed(wpa_s, WPAS_DBUS_PROP_BSSS);
2496 * wpas_dbus_register_bss - Register a scanned BSS with dbus
2497 * @wpa_s: wpa_supplicant interface structure
2498 * @bssid: scanned network bssid
2499 * @id: unique BSS identifier
2500 * Returns: 0 on success, -1 on failure
2502 * Registers BSS representing object with dbus
2504 int wpas_dbus_register_bss(struct wpa_supplicant *wpa_s,
2505 u8 bssid[ETH_ALEN], unsigned int id)
2507 struct wpas_dbus_priv *ctrl_iface;
2508 struct wpa_dbus_object_desc *obj_desc;
2509 char bss_obj_path[WPAS_DBUS_OBJECT_PATH_MAX];
2510 struct bss_handler_args *arg;
2512 /* Do nothing if the control interface is not turned on */
2513 if (wpa_s == NULL || wpa_s->global == NULL || !wpa_s->dbus_new_path)
2515 ctrl_iface = wpa_s->global->dbus;
2516 if (ctrl_iface == NULL)
2519 os_snprintf(bss_obj_path, WPAS_DBUS_OBJECT_PATH_MAX,
2520 "%s/" WPAS_DBUS_NEW_BSSIDS_PART "/%u",
2521 wpa_s->dbus_new_path, id);
2523 obj_desc = os_zalloc(sizeof(struct wpa_dbus_object_desc));
2525 wpa_printf(MSG_ERROR,
2526 "Not enough memory to create object description");
2530 arg = os_zalloc(sizeof(struct bss_handler_args));
2532 wpa_printf(MSG_ERROR,
2533 "Not enough memory to create arguments for handler");
2539 wpas_dbus_register(obj_desc, arg, wpa_dbus_free, NULL,
2540 wpas_dbus_bss_properties,
2541 wpas_dbus_bss_signals);
2543 wpa_printf(MSG_DEBUG, "dbus: Register BSS object '%s'",
2545 if (wpa_dbus_register_object_per_iface(ctrl_iface, bss_obj_path,
2546 wpa_s->ifname, obj_desc)) {
2547 wpa_printf(MSG_ERROR,
2548 "Cannot register BSSID dbus object %s.",
2553 wpas_dbus_signal_bss_added(wpa_s, bss_obj_path);
2554 wpas_dbus_signal_prop_changed(wpa_s, WPAS_DBUS_PROP_BSSS);
2559 free_dbus_object_desc(obj_desc);
2564 static const struct wpa_dbus_method_desc wpas_dbus_interface_methods[] = {
2565 { "Scan", WPAS_DBUS_NEW_IFACE_INTERFACE,
2566 (WPADBusMethodHandler) wpas_dbus_handler_scan,
2568 { "args", "a{sv}", ARG_IN },
2572 { "SignalPoll", WPAS_DBUS_NEW_IFACE_INTERFACE,
2573 (WPADBusMethodHandler) wpas_dbus_handler_signal_poll,
2575 { "args", "a{sv}", ARG_OUT },
2579 { "Disconnect", WPAS_DBUS_NEW_IFACE_INTERFACE,
2580 (WPADBusMethodHandler) wpas_dbus_handler_disconnect,
2585 { "AddNetwork", WPAS_DBUS_NEW_IFACE_INTERFACE,
2586 (WPADBusMethodHandler) wpas_dbus_handler_add_network,
2588 { "args", "a{sv}", ARG_IN },
2589 { "path", "o", ARG_OUT },
2593 { "Reassociate", WPAS_DBUS_NEW_IFACE_INTERFACE,
2594 (WPADBusMethodHandler) wpas_dbus_handler_reassociate,
2599 { "Reattach", WPAS_DBUS_NEW_IFACE_INTERFACE,
2600 (WPADBusMethodHandler) wpas_dbus_handler_reattach,
2605 { "Reconnect", WPAS_DBUS_NEW_IFACE_INTERFACE,
2606 (WPADBusMethodHandler) wpas_dbus_handler_reconnect,
2611 { "RemoveNetwork", WPAS_DBUS_NEW_IFACE_INTERFACE,
2612 (WPADBusMethodHandler) wpas_dbus_handler_remove_network,
2614 { "path", "o", ARG_IN },
2618 { "RemoveAllNetworks", WPAS_DBUS_NEW_IFACE_INTERFACE,
2619 (WPADBusMethodHandler) wpas_dbus_handler_remove_all_networks,
2624 { "SelectNetwork", WPAS_DBUS_NEW_IFACE_INTERFACE,
2625 (WPADBusMethodHandler) wpas_dbus_handler_select_network,
2627 { "path", "o", ARG_IN },
2631 { "NetworkReply", WPAS_DBUS_NEW_IFACE_INTERFACE,
2632 (WPADBusMethodHandler) wpas_dbus_handler_network_reply,
2634 { "path", "o", ARG_IN },
2635 { "field", "s", ARG_IN },
2636 { "value", "s", ARG_IN },
2640 #ifndef CONFIG_NO_CONFIG_BLOBS
2641 { "AddBlob", WPAS_DBUS_NEW_IFACE_INTERFACE,
2642 (WPADBusMethodHandler) wpas_dbus_handler_add_blob,
2644 { "name", "s", ARG_IN },
2645 { "data", "ay", ARG_IN },
2649 { "GetBlob", WPAS_DBUS_NEW_IFACE_INTERFACE,
2650 (WPADBusMethodHandler) wpas_dbus_handler_get_blob,
2652 { "name", "s", ARG_IN },
2653 { "data", "ay", ARG_OUT },
2657 { "RemoveBlob", WPAS_DBUS_NEW_IFACE_INTERFACE,
2658 (WPADBusMethodHandler) wpas_dbus_handler_remove_blob,
2660 { "name", "s", ARG_IN },
2664 #endif /* CONFIG_NO_CONFIG_BLOBS */
2665 { "SetPKCS11EngineAndModulePath", WPAS_DBUS_NEW_IFACE_INTERFACE,
2666 (WPADBusMethodHandler)
2667 wpas_dbus_handler_set_pkcs11_engine_and_module_path,
2669 { "pkcs11_engine_path", "s", ARG_IN },
2670 { "pkcs11_module_path", "s", ARG_IN },
2675 { "Start", WPAS_DBUS_NEW_IFACE_WPS,
2676 (WPADBusMethodHandler) wpas_dbus_handler_wps_start,
2678 { "args", "a{sv}", ARG_IN },
2679 { "output", "a{sv}", ARG_OUT },
2683 { "Cancel", WPAS_DBUS_NEW_IFACE_WPS,
2684 (WPADBusMethodHandler) wpas_dbus_handler_wps_cancel,
2689 #endif /* CONFIG_WPS */
2691 { "Find", WPAS_DBUS_NEW_IFACE_P2PDEVICE,
2692 (WPADBusMethodHandler) wpas_dbus_handler_p2p_find,
2694 { "args", "a{sv}", ARG_IN },
2698 { "StopFind", WPAS_DBUS_NEW_IFACE_P2PDEVICE,
2699 (WPADBusMethodHandler) wpas_dbus_handler_p2p_stop_find,
2704 { "Listen", WPAS_DBUS_NEW_IFACE_P2PDEVICE,
2705 (WPADBusMethodHandler) wpas_dbus_handler_p2p_listen,
2707 { "timeout", "i", ARG_IN },
2711 { "ExtendedListen", WPAS_DBUS_NEW_IFACE_P2PDEVICE,
2712 (WPADBusMethodHandler) wpas_dbus_handler_p2p_extendedlisten,
2714 { "args", "a{sv}", ARG_IN },
2718 { "PresenceRequest", WPAS_DBUS_NEW_IFACE_P2PDEVICE,
2719 (WPADBusMethodHandler) wpas_dbus_handler_p2p_presence_request,
2721 { "args", "a{sv}", ARG_IN },
2725 { "ProvisionDiscoveryRequest", WPAS_DBUS_NEW_IFACE_P2PDEVICE,
2726 (WPADBusMethodHandler) wpas_dbus_handler_p2p_prov_disc_req,
2728 { "peer", "o", ARG_IN },
2729 { "config_method", "s", ARG_IN },
2733 { "Connect", WPAS_DBUS_NEW_IFACE_P2PDEVICE,
2734 (WPADBusMethodHandler) wpas_dbus_handler_p2p_connect,
2736 { "args", "a{sv}", ARG_IN },
2737 { "generated_pin", "s", ARG_OUT },
2741 { "GroupAdd", WPAS_DBUS_NEW_IFACE_P2PDEVICE,
2742 (WPADBusMethodHandler) wpas_dbus_handler_p2p_group_add,
2744 { "args", "a{sv}", ARG_IN },
2748 { "Cancel", WPAS_DBUS_NEW_IFACE_P2PDEVICE,
2749 (WPADBusMethodHandler) wpas_dbus_handler_p2p_cancel,
2754 { "Invite", WPAS_DBUS_NEW_IFACE_P2PDEVICE,
2755 (WPADBusMethodHandler) wpas_dbus_handler_p2p_invite,
2757 { "args", "a{sv}", ARG_IN },
2761 { "Disconnect", WPAS_DBUS_NEW_IFACE_P2PDEVICE,
2762 (WPADBusMethodHandler) wpas_dbus_handler_p2p_disconnect,
2767 { "RejectPeer", WPAS_DBUS_NEW_IFACE_P2PDEVICE,
2768 (WPADBusMethodHandler) wpas_dbus_handler_p2p_rejectpeer,
2770 { "peer", "o", ARG_IN },
2774 { "RemoveClient", WPAS_DBUS_NEW_IFACE_P2PDEVICE,
2775 (WPADBusMethodHandler) wpas_dbus_handler_p2p_remove_client,
2777 { "args", "a{sv}", ARG_IN },
2781 { "Flush", WPAS_DBUS_NEW_IFACE_P2PDEVICE,
2782 (WPADBusMethodHandler) wpas_dbus_handler_p2p_flush,
2787 { "AddService", WPAS_DBUS_NEW_IFACE_P2PDEVICE,
2788 (WPADBusMethodHandler) wpas_dbus_handler_p2p_add_service,
2790 { "args", "a{sv}", ARG_IN },
2794 { "DeleteService", WPAS_DBUS_NEW_IFACE_P2PDEVICE,
2795 (WPADBusMethodHandler) wpas_dbus_handler_p2p_delete_service,
2797 { "args", "a{sv}", ARG_IN },
2801 { "FlushService", WPAS_DBUS_NEW_IFACE_P2PDEVICE,
2802 (WPADBusMethodHandler) wpas_dbus_handler_p2p_flush_service,
2807 { "ServiceDiscoveryRequest", WPAS_DBUS_NEW_IFACE_P2PDEVICE,
2808 (WPADBusMethodHandler) wpas_dbus_handler_p2p_service_sd_req,
2810 { "args", "a{sv}", ARG_IN },
2811 { "ref", "t", ARG_OUT },
2815 { "ServiceDiscoveryResponse", WPAS_DBUS_NEW_IFACE_P2PDEVICE,
2816 (WPADBusMethodHandler) wpas_dbus_handler_p2p_service_sd_res,
2818 { "args", "a{sv}", ARG_IN },
2822 { "ServiceDiscoveryCancelRequest", WPAS_DBUS_NEW_IFACE_P2PDEVICE,
2823 (WPADBusMethodHandler) wpas_dbus_handler_p2p_service_sd_cancel_req,
2825 { "args", "t", ARG_IN },
2829 { "ServiceUpdate", WPAS_DBUS_NEW_IFACE_P2PDEVICE,
2830 (WPADBusMethodHandler) wpas_dbus_handler_p2p_service_update,
2835 { "ServiceDiscoveryExternal", WPAS_DBUS_NEW_IFACE_P2PDEVICE,
2836 (WPADBusMethodHandler) wpas_dbus_handler_p2p_serv_disc_external,
2838 { "arg", "i", ARG_IN },
2842 { "AddPersistentGroup", WPAS_DBUS_NEW_IFACE_P2PDEVICE,
2843 (WPADBusMethodHandler) wpas_dbus_handler_add_persistent_group,
2845 { "args", "a{sv}", ARG_IN },
2846 { "path", "o", ARG_OUT },
2850 { "RemovePersistentGroup", WPAS_DBUS_NEW_IFACE_P2PDEVICE,
2851 (WPADBusMethodHandler) wpas_dbus_handler_remove_persistent_group,
2853 { "path", "o", ARG_IN },
2857 { "RemoveAllPersistentGroups", WPAS_DBUS_NEW_IFACE_P2PDEVICE,
2858 (WPADBusMethodHandler)
2859 wpas_dbus_handler_remove_all_persistent_groups,
2864 #endif /* CONFIG_P2P */
2865 { "FlushBSS", WPAS_DBUS_NEW_IFACE_INTERFACE,
2866 (WPADBusMethodHandler) wpas_dbus_handler_flush_bss,
2868 { "age", "u", ARG_IN },
2873 { "SubscribeProbeReq", WPAS_DBUS_NEW_IFACE_INTERFACE,
2874 (WPADBusMethodHandler) wpas_dbus_handler_subscribe_preq,
2879 { "UnsubscribeProbeReq", WPAS_DBUS_NEW_IFACE_INTERFACE,
2880 (WPADBusMethodHandler) wpas_dbus_handler_unsubscribe_preq,
2885 #endif /* CONFIG_AP */
2886 { "EAPLogoff", WPAS_DBUS_NEW_IFACE_INTERFACE,
2887 (WPADBusMethodHandler) wpas_dbus_handler_eap_logoff,
2892 { "EAPLogon", WPAS_DBUS_NEW_IFACE_INTERFACE,
2893 (WPADBusMethodHandler) wpas_dbus_handler_eap_logon,
2898 #ifdef CONFIG_AUTOSCAN
2899 { "AutoScan", WPAS_DBUS_NEW_IFACE_INTERFACE,
2900 (WPADBusMethodHandler) wpas_dbus_handler_autoscan,
2902 { "arg", "s", ARG_IN },
2906 #endif /* CONFIG_AUTOSCAN */
2908 { "TDLSDiscover", WPAS_DBUS_NEW_IFACE_INTERFACE,
2909 (WPADBusMethodHandler) wpas_dbus_handler_tdls_discover,
2911 { "peer_address", "s", ARG_IN },
2915 { "TDLSSetup", WPAS_DBUS_NEW_IFACE_INTERFACE,
2916 (WPADBusMethodHandler) wpas_dbus_handler_tdls_setup,
2918 { "peer_address", "s", ARG_IN },
2922 { "TDLSStatus", WPAS_DBUS_NEW_IFACE_INTERFACE,
2923 (WPADBusMethodHandler) wpas_dbus_handler_tdls_status,
2925 { "peer_address", "s", ARG_IN },
2926 { "status", "s", ARG_OUT },
2930 { "TDLSTeardown", WPAS_DBUS_NEW_IFACE_INTERFACE,
2931 (WPADBusMethodHandler) wpas_dbus_handler_tdls_teardown,
2933 { "peer_address", "s", ARG_IN },
2937 #endif /* CONFIG_TDLS */
2938 { NULL, NULL, NULL, { END_ARGS } }
2941 static const struct wpa_dbus_property_desc wpas_dbus_interface_properties[] = {
2942 { "Capabilities", WPAS_DBUS_NEW_IFACE_INTERFACE, "a{sv}",
2943 wpas_dbus_getter_capabilities,
2946 { "State", WPAS_DBUS_NEW_IFACE_INTERFACE, "s",
2947 wpas_dbus_getter_state,
2950 { "Scanning", WPAS_DBUS_NEW_IFACE_INTERFACE, "b",
2951 wpas_dbus_getter_scanning,
2954 { "ApScan", WPAS_DBUS_NEW_IFACE_INTERFACE, "u",
2955 wpas_dbus_getter_ap_scan,
2956 wpas_dbus_setter_ap_scan
2958 { "BSSExpireAge", WPAS_DBUS_NEW_IFACE_INTERFACE, "u",
2959 wpas_dbus_getter_bss_expire_age,
2960 wpas_dbus_setter_bss_expire_age
2962 { "BSSExpireCount", WPAS_DBUS_NEW_IFACE_INTERFACE, "u",
2963 wpas_dbus_getter_bss_expire_count,
2964 wpas_dbus_setter_bss_expire_count
2966 { "Country", WPAS_DBUS_NEW_IFACE_INTERFACE, "s",
2967 wpas_dbus_getter_country,
2968 wpas_dbus_setter_country
2970 { "Ifname", WPAS_DBUS_NEW_IFACE_INTERFACE, "s",
2971 wpas_dbus_getter_ifname,
2974 { "Driver", WPAS_DBUS_NEW_IFACE_INTERFACE, "s",
2975 wpas_dbus_getter_driver,
2978 { "BridgeIfname", WPAS_DBUS_NEW_IFACE_INTERFACE, "s",
2979 wpas_dbus_getter_bridge_ifname,
2982 { "CurrentBSS", WPAS_DBUS_NEW_IFACE_INTERFACE, "o",
2983 wpas_dbus_getter_current_bss,
2986 { "CurrentNetwork", WPAS_DBUS_NEW_IFACE_INTERFACE, "o",
2987 wpas_dbus_getter_current_network,
2990 { "CurrentAuthMode", WPAS_DBUS_NEW_IFACE_INTERFACE, "s",
2991 wpas_dbus_getter_current_auth_mode,
2994 { "Blobs", WPAS_DBUS_NEW_IFACE_INTERFACE, "a{say}",
2995 wpas_dbus_getter_blobs,
2998 { "BSSs", WPAS_DBUS_NEW_IFACE_INTERFACE, "ao",
2999 wpas_dbus_getter_bsss,
3002 { "Networks", WPAS_DBUS_NEW_IFACE_INTERFACE, "ao",
3003 wpas_dbus_getter_networks,
3006 { "FastReauth", WPAS_DBUS_NEW_IFACE_INTERFACE, "b",
3007 wpas_dbus_getter_fast_reauth,
3008 wpas_dbus_setter_fast_reauth
3010 { "ScanInterval", WPAS_DBUS_NEW_IFACE_INTERFACE, "i",
3011 wpas_dbus_getter_scan_interval,
3012 wpas_dbus_setter_scan_interval
3014 { "PKCS11EnginePath", WPAS_DBUS_NEW_IFACE_INTERFACE, "s",
3015 wpas_dbus_getter_pkcs11_engine_path,
3018 { "PKCS11ModulePath", WPAS_DBUS_NEW_IFACE_INTERFACE, "s",
3019 wpas_dbus_getter_pkcs11_module_path,
3023 { "ProcessCredentials", WPAS_DBUS_NEW_IFACE_WPS, "b",
3024 wpas_dbus_getter_process_credentials,
3025 wpas_dbus_setter_process_credentials
3027 { "ConfigMethods", WPAS_DBUS_NEW_IFACE_WPS, "s",
3028 wpas_dbus_getter_config_methods,
3029 wpas_dbus_setter_config_methods
3031 #endif /* CONFIG_WPS */
3033 { "P2PDeviceConfig", WPAS_DBUS_NEW_IFACE_P2PDEVICE, "a{sv}",
3034 wpas_dbus_getter_p2p_device_config,
3035 wpas_dbus_setter_p2p_device_config
3037 { "Peers", WPAS_DBUS_NEW_IFACE_P2PDEVICE, "ao",
3038 wpas_dbus_getter_p2p_peers,
3041 { "Role", WPAS_DBUS_NEW_IFACE_P2PDEVICE, "s",
3042 wpas_dbus_getter_p2p_role,
3045 { "Group", WPAS_DBUS_NEW_IFACE_P2PDEVICE, "o",
3046 wpas_dbus_getter_p2p_group,
3049 { "PeerGO", WPAS_DBUS_NEW_IFACE_P2PDEVICE, "o",
3050 wpas_dbus_getter_p2p_peergo,
3053 { "PersistentGroups", WPAS_DBUS_NEW_IFACE_P2PDEVICE, "ao",
3054 wpas_dbus_getter_persistent_groups,
3057 #endif /* CONFIG_P2P */
3058 { "DisconnectReason", WPAS_DBUS_NEW_IFACE_INTERFACE, "i",
3059 wpas_dbus_getter_disconnect_reason,
3062 { NULL, NULL, NULL, NULL, NULL }
3065 static const struct wpa_dbus_signal_desc wpas_dbus_interface_signals[] = {
3066 { "ScanDone", WPAS_DBUS_NEW_IFACE_INTERFACE,
3068 { "success", "b", ARG_OUT },
3072 { "BSSAdded", WPAS_DBUS_NEW_IFACE_INTERFACE,
3074 { "path", "o", ARG_OUT },
3075 { "properties", "a{sv}", ARG_OUT },
3079 { "BSSRemoved", WPAS_DBUS_NEW_IFACE_INTERFACE,
3081 { "path", "o", ARG_OUT },
3085 { "BlobAdded", WPAS_DBUS_NEW_IFACE_INTERFACE,
3087 { "name", "s", ARG_OUT },
3091 { "BlobRemoved", WPAS_DBUS_NEW_IFACE_INTERFACE,
3093 { "name", "s", ARG_OUT },
3097 { "NetworkAdded", WPAS_DBUS_NEW_IFACE_INTERFACE,
3099 { "path", "o", ARG_OUT },
3100 { "properties", "a{sv}", ARG_OUT },
3104 { "NetworkRemoved", WPAS_DBUS_NEW_IFACE_INTERFACE,
3106 { "path", "o", ARG_OUT },
3110 { "NetworkSelected", WPAS_DBUS_NEW_IFACE_INTERFACE,
3112 { "path", "o", ARG_OUT },
3116 /* Deprecated: use org.freedesktop.DBus.Properties.PropertiesChanged */
3117 { "PropertiesChanged", WPAS_DBUS_NEW_IFACE_INTERFACE,
3119 { "properties", "a{sv}", ARG_OUT },
3124 { "Event", WPAS_DBUS_NEW_IFACE_WPS,
3126 { "name", "s", ARG_OUT },
3127 { "args", "a{sv}", ARG_OUT },
3131 { "Credentials", WPAS_DBUS_NEW_IFACE_WPS,
3133 { "credentials", "a{sv}", ARG_OUT },
3137 /* Deprecated: use org.freedesktop.DBus.Properties.PropertiesChanged */
3138 { "PropertiesChanged", WPAS_DBUS_NEW_IFACE_WPS,
3140 { "properties", "a{sv}", ARG_OUT },
3144 #endif /* CONFIG_WPS */
3146 { "DeviceFound", WPAS_DBUS_NEW_IFACE_P2PDEVICE,
3148 { "path", "o", ARG_OUT },
3152 { "DeviceLost", WPAS_DBUS_NEW_IFACE_P2PDEVICE,
3154 { "path", "o", ARG_OUT },
3158 { "FindStopped", WPAS_DBUS_NEW_IFACE_P2PDEVICE,
3163 { "ProvisionDiscoveryRequestDisplayPin", WPAS_DBUS_NEW_IFACE_P2PDEVICE,
3165 { "peer_object", "o", ARG_OUT },
3166 { "pin", "s", ARG_OUT },
3170 { "ProvisionDiscoveryResponseDisplayPin", WPAS_DBUS_NEW_IFACE_P2PDEVICE,
3172 { "peer_object", "o", ARG_OUT },
3173 { "pin", "s", ARG_OUT },
3177 { "ProvisionDiscoveryRequestEnterPin", WPAS_DBUS_NEW_IFACE_P2PDEVICE,
3179 { "peer_object", "o", ARG_OUT },
3183 { "ProvisionDiscoveryResponseEnterPin", WPAS_DBUS_NEW_IFACE_P2PDEVICE,
3185 { "peer_object", "o", ARG_OUT },
3189 { "ProvisionDiscoveryPBCRequest", WPAS_DBUS_NEW_IFACE_P2PDEVICE,
3191 { "peer_object", "o", ARG_OUT },
3195 { "ProvisionDiscoveryPBCResponse", WPAS_DBUS_NEW_IFACE_P2PDEVICE,
3197 { "peer_object", "o", ARG_OUT },
3201 { "ProvisionDiscoveryFailure", WPAS_DBUS_NEW_IFACE_P2PDEVICE,
3203 { "peer_object", "o", ARG_OUT },
3204 { "status", "i", ARG_OUT },
3208 { "GroupStarted", WPAS_DBUS_NEW_IFACE_P2PDEVICE,
3210 { "properties", "a{sv}", ARG_OUT },
3214 { "GroupFormationFailure", WPAS_DBUS_NEW_IFACE_P2PDEVICE,
3216 { "reason", "s", ARG_OUT },
3220 { "GONegotiationSuccess", WPAS_DBUS_NEW_IFACE_P2PDEVICE,
3222 { "properties", "a{sv}", ARG_OUT },
3226 { "GONegotiationFailure", WPAS_DBUS_NEW_IFACE_P2PDEVICE,
3228 { "properties", "a{sv}", ARG_OUT },
3232 { "GONegotiationRequest", WPAS_DBUS_NEW_IFACE_P2PDEVICE,
3234 { "path", "o", ARG_OUT },
3235 { "dev_passwd_id", "q", ARG_OUT },
3236 { "device_go_intent", "y", ARG_OUT },
3240 { "InvitationResult", WPAS_DBUS_NEW_IFACE_P2PDEVICE,
3242 { "invite_result", "a{sv}", ARG_OUT },
3246 { "GroupFinished", WPAS_DBUS_NEW_IFACE_P2PDEVICE,
3248 { "properties", "a{sv}", ARG_OUT },
3252 { "ServiceDiscoveryRequest", WPAS_DBUS_NEW_IFACE_P2PDEVICE,
3254 { "sd_request", "a{sv}", ARG_OUT },
3258 { "ServiceDiscoveryResponse", WPAS_DBUS_NEW_IFACE_P2PDEVICE,
3260 { "sd_response", "a{sv}", ARG_OUT },
3264 { "PersistentGroupAdded", WPAS_DBUS_NEW_IFACE_P2PDEVICE,
3266 { "path", "o", ARG_OUT },
3267 { "properties", "a{sv}", ARG_OUT },
3271 { "PersistentGroupRemoved", WPAS_DBUS_NEW_IFACE_P2PDEVICE,
3273 { "path", "o", ARG_OUT },
3277 { "WpsFailed", WPAS_DBUS_NEW_IFACE_P2PDEVICE,
3279 { "name", "s", ARG_OUT },
3280 { "args", "a{sv}", ARG_OUT },
3284 #endif /* CONFIG_P2P */
3286 { "ProbeRequest", WPAS_DBUS_NEW_IFACE_INTERFACE,
3288 { "args", "a{sv}", ARG_OUT },
3292 #endif /* CONFIG_AP */
3293 { "Certification", WPAS_DBUS_NEW_IFACE_INTERFACE,
3295 { "certification", "a{sv}", ARG_OUT },
3299 { "EAP", WPAS_DBUS_NEW_IFACE_INTERFACE,
3301 { "status", "s", ARG_OUT },
3302 { "parameter", "s", ARG_OUT },
3306 { "StaAuthorized", WPAS_DBUS_NEW_IFACE_INTERFACE,
3308 { "name", "s", ARG_OUT },
3312 { "StaDeauthorized", WPAS_DBUS_NEW_IFACE_INTERFACE,
3314 { "name", "s", ARG_OUT },
3318 { "NetworkRequest", WPAS_DBUS_NEW_IFACE_INTERFACE,
3320 { "path", "o", ARG_OUT },
3321 { "field", "s", ARG_OUT },
3322 { "text", "s", ARG_OUT },
3326 { NULL, NULL, { END_ARGS } }
3331 * wpas_dbus_register_interface - Register an interface with D-Bus
3332 * @wpa_s: wpa_supplicant interface structure
3333 * Returns: 0 on success, -1 on failure
3335 int wpas_dbus_register_interface(struct wpa_supplicant *wpa_s)
3338 struct wpa_dbus_object_desc *obj_desc = NULL;
3339 struct wpas_dbus_priv *ctrl_iface = wpa_s->global->dbus;
3342 /* Do nothing if the control interface is not turned on */
3343 if (ctrl_iface == NULL)
3346 /* Create and set the interface's object path */
3347 wpa_s->dbus_new_path = os_zalloc(WPAS_DBUS_OBJECT_PATH_MAX);
3348 if (wpa_s->dbus_new_path == NULL)
3350 next = ctrl_iface->next_objid++;
3351 os_snprintf(wpa_s->dbus_new_path, WPAS_DBUS_OBJECT_PATH_MAX,
3352 WPAS_DBUS_NEW_PATH_INTERFACES "/%u",
3355 obj_desc = os_zalloc(sizeof(struct wpa_dbus_object_desc));
3357 wpa_printf(MSG_ERROR,
3358 "Not enough memory to create object description");
3362 wpas_dbus_register(obj_desc, wpa_s, NULL, wpas_dbus_interface_methods,
3363 wpas_dbus_interface_properties,
3364 wpas_dbus_interface_signals);
3366 wpa_printf(MSG_DEBUG, "dbus: Register interface object '%s'",
3367 wpa_s->dbus_new_path);
3368 if (wpa_dbus_register_object_per_iface(ctrl_iface,
3369 wpa_s->dbus_new_path,
3370 wpa_s->ifname, obj_desc))
3373 wpas_dbus_signal_interface_added(wpa_s);
3378 os_free(wpa_s->dbus_new_path);
3379 wpa_s->dbus_new_path = NULL;
3380 free_dbus_object_desc(obj_desc);
3386 * wpas_dbus_unregister_interface - Unregister the interface from D-Bus
3387 * @wpa_s: wpa_supplicant interface structure
3388 * Returns: 0 on success, -1 on failure
3390 int wpas_dbus_unregister_interface(struct wpa_supplicant *wpa_s)
3392 struct wpas_dbus_priv *ctrl_iface;
3394 /* Do nothing if the control interface is not turned on */
3395 if (wpa_s == NULL || wpa_s->global == NULL)
3397 ctrl_iface = wpa_s->global->dbus;
3398 if (ctrl_iface == NULL || wpa_s->dbus_new_path == NULL)
3401 wpa_printf(MSG_DEBUG, "dbus: Unregister interface object '%s'",
3402 wpa_s->dbus_new_path);
3405 if (wpa_s->preq_notify_peer) {
3406 wpas_dbus_unsubscribe_noc(ctrl_iface);
3407 os_free(wpa_s->preq_notify_peer);
3408 wpa_s->preq_notify_peer = NULL;
3410 #endif /* CONFIG_AP */
3412 if (wpa_dbus_unregister_object_per_iface(ctrl_iface,
3413 wpa_s->dbus_new_path))
3416 wpas_dbus_signal_interface_removed(wpa_s);
3418 os_free(wpa_s->dbus_new_path);
3419 wpa_s->dbus_new_path = NULL;
3426 static const struct wpa_dbus_property_desc wpas_dbus_p2p_peer_properties[] = {
3427 { "DeviceName", WPAS_DBUS_NEW_IFACE_P2P_PEER, "s",
3428 wpas_dbus_getter_p2p_peer_device_name,
3431 { "Manufacturer", WPAS_DBUS_NEW_IFACE_P2P_PEER, "s",
3432 wpas_dbus_getter_p2p_peer_manufacturer,
3435 { "ModelName", WPAS_DBUS_NEW_IFACE_P2P_PEER, "s",
3436 wpas_dbus_getter_p2p_peer_modelname,
3439 { "ModelNumber", WPAS_DBUS_NEW_IFACE_P2P_PEER, "s",
3440 wpas_dbus_getter_p2p_peer_modelnumber,
3443 { "SerialNumber", WPAS_DBUS_NEW_IFACE_P2P_PEER, "s",
3444 wpas_dbus_getter_p2p_peer_serialnumber,
3447 { "PrimaryDeviceType", WPAS_DBUS_NEW_IFACE_P2P_PEER, "ay",
3448 wpas_dbus_getter_p2p_peer_primary_device_type,
3451 { "config_method", WPAS_DBUS_NEW_IFACE_P2P_PEER, "q",
3452 wpas_dbus_getter_p2p_peer_config_method,
3455 { "level", WPAS_DBUS_NEW_IFACE_P2P_PEER, "i",
3456 wpas_dbus_getter_p2p_peer_level,
3459 { "devicecapability", WPAS_DBUS_NEW_IFACE_P2P_PEER, "y",
3460 wpas_dbus_getter_p2p_peer_device_capability,
3463 { "groupcapability", WPAS_DBUS_NEW_IFACE_P2P_PEER, "y",
3464 wpas_dbus_getter_p2p_peer_group_capability,
3467 { "SecondaryDeviceTypes", WPAS_DBUS_NEW_IFACE_P2P_PEER, "aay",
3468 wpas_dbus_getter_p2p_peer_secondary_device_types,
3471 { "VendorExtension", WPAS_DBUS_NEW_IFACE_P2P_PEER, "aay",
3472 wpas_dbus_getter_p2p_peer_vendor_extension,
3475 { "IEs", WPAS_DBUS_NEW_IFACE_P2P_PEER, "ay",
3476 wpas_dbus_getter_p2p_peer_ies,
3479 { "DeviceAddress", WPAS_DBUS_NEW_IFACE_P2P_PEER, "ay",
3480 wpas_dbus_getter_p2p_peer_device_address,
3483 { "Groups", WPAS_DBUS_NEW_IFACE_P2P_PEER, "ao",
3484 wpas_dbus_getter_p2p_peer_groups,
3487 { NULL, NULL, NULL, NULL, NULL }
3490 static const struct wpa_dbus_signal_desc wpas_dbus_p2p_peer_signals[] = {
3491 /* Deprecated: use org.freedesktop.DBus.Properties.PropertiesChanged */
3492 { "PropertiesChanged", WPAS_DBUS_NEW_IFACE_P2P_PEER,
3494 { "properties", "a{sv}", ARG_OUT },
3498 { NULL, NULL, { END_ARGS } }
3502 * wpas_dbus_signal_peer - Send a peer related event signal
3503 * @wpa_s: %wpa_supplicant network interface data
3504 * @dev: peer device object
3505 * @interface: name of the interface emitting this signal.
3506 * In case of peer objects, it would be emitted by either
3507 * the "interface object" or by "peer objects"
3508 * @sig_name: signal name - DeviceFound
3510 * Notify listeners about event related with newly found p2p peer device
3512 static void wpas_dbus_signal_peer(struct wpa_supplicant *wpa_s,
3513 const u8 *dev_addr, const char *interface,
3514 const char *sig_name)
3516 struct wpas_dbus_priv *iface;
3518 DBusMessageIter iter;
3519 char peer_obj_path[WPAS_DBUS_OBJECT_PATH_MAX], *path;
3521 if (wpa_s->p2p_mgmt)
3522 wpa_s = wpa_s->parent;
3524 iface = wpa_s->global->dbus;
3526 /* Do nothing if the control interface is not turned on */
3527 if (iface == NULL || !wpa_s->dbus_new_path)
3530 os_snprintf(peer_obj_path, WPAS_DBUS_OBJECT_PATH_MAX,
3531 "%s/" WPAS_DBUS_NEW_P2P_PEERS_PART "/" COMPACT_MACSTR,
3532 wpa_s->dbus_new_path, MAC2STR(dev_addr));
3534 msg = dbus_message_new_signal(wpa_s->dbus_new_path, interface,
3539 dbus_message_iter_init_append(msg, &iter);
3540 path = peer_obj_path;
3541 if (!dbus_message_iter_append_basic(&iter, DBUS_TYPE_OBJECT_PATH,
3543 wpa_printf(MSG_ERROR, "dbus: Failed to construct signal");
3545 dbus_connection_send(iface->con, msg, NULL);
3547 dbus_message_unref(msg);
3552 * wpas_dbus_signal_peer_found - Send a peer found signal
3553 * @wpa_s: %wpa_supplicant network interface data
3554 * @dev_addr: Peer P2P Device Address
3556 * Notify listeners about find a p2p peer device found
3558 void wpas_dbus_signal_peer_device_found(struct wpa_supplicant *wpa_s,
3561 wpas_dbus_signal_peer(wpa_s, dev_addr,
3562 WPAS_DBUS_NEW_IFACE_P2PDEVICE,
3567 * wpas_dbus_signal_peer_lost - Send a peer lost signal
3568 * @wpa_s: %wpa_supplicant network interface data
3569 * @dev_addr: Peer P2P Device Address
3571 * Notify listeners about lost a p2p peer device
3573 void wpas_dbus_signal_peer_device_lost(struct wpa_supplicant *wpa_s,
3576 wpas_dbus_signal_peer(wpa_s, dev_addr,
3577 WPAS_DBUS_NEW_IFACE_P2PDEVICE,
3582 * wpas_dbus_register_peer - Register a discovered peer object with dbus
3583 * @wpa_s: wpa_supplicant interface structure
3584 * @dev_addr: P2P Device Address of the peer
3585 * Returns: 0 on success, -1 on failure
3587 * Registers network representing object with dbus
3589 int wpas_dbus_register_peer(struct wpa_supplicant *wpa_s, const u8 *dev_addr)
3591 struct wpas_dbus_priv *ctrl_iface;
3592 struct wpa_dbus_object_desc *obj_desc;
3593 struct peer_handler_args *arg;
3594 char peer_obj_path[WPAS_DBUS_OBJECT_PATH_MAX];
3596 /* Do nothing if the control interface is not turned on */
3597 if (wpa_s == NULL || wpa_s->global == NULL)
3600 ctrl_iface = wpa_s->global->dbus;
3601 if (ctrl_iface == NULL)
3604 wpa_s = wpa_s->parent->parent;
3605 if (!wpa_s->dbus_new_path)
3608 os_snprintf(peer_obj_path, WPAS_DBUS_OBJECT_PATH_MAX,
3609 "%s/" WPAS_DBUS_NEW_P2P_PEERS_PART "/" COMPACT_MACSTR,
3610 wpa_s->dbus_new_path, MAC2STR(dev_addr));
3612 wpa_printf(MSG_INFO, "dbus: Register peer object '%s'",
3614 obj_desc = os_zalloc(sizeof(struct wpa_dbus_object_desc));
3616 wpa_printf(MSG_ERROR,
3617 "Not enough memory to create object description");
3621 /* allocate memory for handlers arguments */
3622 arg = os_zalloc(sizeof(struct peer_handler_args));
3624 wpa_printf(MSG_ERROR,
3625 "Not enough memory to create arguments for method");
3630 os_memcpy(arg->p2p_device_addr, dev_addr, ETH_ALEN);
3632 wpas_dbus_register(obj_desc, arg, wpa_dbus_free,
3634 wpas_dbus_p2p_peer_properties,
3635 wpas_dbus_p2p_peer_signals);
3637 if (wpa_dbus_register_object_per_iface(ctrl_iface, peer_obj_path,
3638 wpa_s->ifname, obj_desc))
3644 free_dbus_object_desc(obj_desc);
3649 * wpas_dbus_unregister_peer - Unregister a peer object with dbus
3650 * @wpa_s: wpa_supplicant interface structure
3651 * @dev_addr: p2p device addr
3652 * Returns: 0 on success, -1 on failure
3654 * Registers network representing object with dbus
3656 int wpas_dbus_unregister_peer(struct wpa_supplicant *wpa_s,
3659 struct wpas_dbus_priv *ctrl_iface;
3660 char peer_obj_path[WPAS_DBUS_OBJECT_PATH_MAX];
3663 /* Do nothing if the control interface is not turned on */
3664 if (wpa_s == NULL || wpa_s->global == NULL)
3667 wpa_s = wpa_s->parent->parent;
3668 if (!wpa_s->dbus_new_path)
3671 ctrl_iface = wpa_s->global->dbus;
3672 if (ctrl_iface == NULL)
3675 os_snprintf(peer_obj_path, WPAS_DBUS_OBJECT_PATH_MAX,
3676 "%s/" WPAS_DBUS_NEW_P2P_PEERS_PART "/" COMPACT_MACSTR,
3677 wpa_s->dbus_new_path, MAC2STR(dev_addr));
3679 wpa_printf(MSG_INFO, "dbus: Unregister peer object '%s'",
3681 ret = wpa_dbus_unregister_object_per_iface(ctrl_iface, peer_obj_path);
3688 * wpas_dbus_signal_p2p_find_stopped - Send P2P Find stopped signal
3689 * @wpa_s: %wpa_supplicant network interface data
3691 * Notify listeners about P2P Find stopped
3693 void wpas_dbus_signal_p2p_find_stopped(struct wpa_supplicant *wpa_s)
3695 struct wpas_dbus_priv *iface;
3698 iface = wpa_s->global->dbus;
3700 /* Do nothing if the control interface is not turned on */
3701 if (iface == NULL || !wpa_s->dbus_new_path)
3704 msg = dbus_message_new_signal(wpa_s->dbus_new_path,
3705 WPAS_DBUS_NEW_IFACE_P2PDEVICE,
3710 dbus_connection_send(iface->con, msg, NULL);
3712 dbus_message_unref(msg);
3717 * wpas_dbus_signal_peer_groups_changed - Send peer group change property signal
3718 * @wpa_s: %wpa_supplicant network interface data
3719 * @dev_addr: P2P Device Address
3721 * Notify listeners about peer Groups property changes.
3723 void wpas_dbus_signal_peer_groups_changed(struct wpa_supplicant *wpa_s,
3726 char peer_obj_path[WPAS_DBUS_OBJECT_PATH_MAX];
3728 if (wpa_s->p2p_mgmt)
3729 wpa_s = wpa_s->parent;
3731 if (!wpa_s->dbus_new_path)
3733 os_snprintf(peer_obj_path, WPAS_DBUS_OBJECT_PATH_MAX,
3734 "%s/" WPAS_DBUS_NEW_P2P_PEERS_PART "/" COMPACT_MACSTR,
3735 wpa_s->dbus_new_path, MAC2STR(dev_addr));
3737 wpa_dbus_mark_property_changed(wpa_s->global->dbus, peer_obj_path,
3738 WPAS_DBUS_NEW_IFACE_P2P_PEER, "Groups");
3742 static const struct wpa_dbus_property_desc wpas_dbus_p2p_group_properties[] = {
3743 { "Members", WPAS_DBUS_NEW_IFACE_P2P_GROUP, "ao",
3744 wpas_dbus_getter_p2p_group_members,
3747 { "Group", WPAS_DBUS_NEW_IFACE_P2P_GROUP, "o",
3748 wpas_dbus_getter_p2p_group,
3751 { "Role", WPAS_DBUS_NEW_IFACE_P2P_GROUP, "s",
3752 wpas_dbus_getter_p2p_role,
3755 { "SSID", WPAS_DBUS_NEW_IFACE_P2P_GROUP, "ay",
3756 wpas_dbus_getter_p2p_group_ssid,
3759 { "BSSID", WPAS_DBUS_NEW_IFACE_P2P_GROUP, "ay",
3760 wpas_dbus_getter_p2p_group_bssid,
3763 { "Frequency", WPAS_DBUS_NEW_IFACE_P2P_GROUP, "q",
3764 wpas_dbus_getter_p2p_group_frequency,
3767 { "Passphrase", WPAS_DBUS_NEW_IFACE_P2P_GROUP, "s",
3768 wpas_dbus_getter_p2p_group_passphrase,
3771 { "PSK", WPAS_DBUS_NEW_IFACE_P2P_GROUP, "ay",
3772 wpas_dbus_getter_p2p_group_psk,
3775 { "WPSVendorExtensions", WPAS_DBUS_NEW_IFACE_P2P_GROUP, "aay",
3776 wpas_dbus_getter_p2p_group_vendor_ext,
3777 wpas_dbus_setter_p2p_group_vendor_ext
3779 { NULL, NULL, NULL, NULL, NULL }
3782 static const struct wpa_dbus_signal_desc wpas_dbus_p2p_group_signals[] = {
3783 { "PeerJoined", WPAS_DBUS_NEW_IFACE_P2P_GROUP,
3785 { "peer", "o", ARG_OUT },
3789 { "PeerDisconnected", WPAS_DBUS_NEW_IFACE_P2P_GROUP,
3791 { "peer", "o", ARG_OUT },
3795 { NULL, NULL, { END_ARGS } }
3799 * wpas_dbus_register_p2p_group - Register a p2p group object with dbus
3800 * @wpa_s: wpa_supplicant interface structure
3801 * @ssid: SSID struct
3802 * Returns: 0 on success, -1 on failure
3804 * Registers p2p group representing object with dbus
3806 void wpas_dbus_register_p2p_group(struct wpa_supplicant *wpa_s,
3807 struct wpa_ssid *ssid)
3809 struct wpas_dbus_priv *ctrl_iface;
3810 struct wpa_dbus_object_desc *obj_desc;
3811 char group_obj_path[WPAS_DBUS_OBJECT_PATH_MAX];
3813 /* Do nothing if the control interface is not turned on */
3814 if (wpa_s == NULL || wpa_s->global == NULL)
3817 ctrl_iface = wpa_s->global->dbus;
3818 if (ctrl_iface == NULL)
3821 if (wpa_s->dbus_groupobj_path) {
3822 wpa_printf(MSG_INFO, "%s: Group object '%s' already exists",
3823 __func__, wpa_s->dbus_groupobj_path);
3827 if (wpas_dbus_get_group_obj_path(wpa_s, ssid, group_obj_path) < 0)
3830 wpa_s->dbus_groupobj_path = os_strdup(group_obj_path);
3831 if (wpa_s->dbus_groupobj_path == NULL)
3834 wpa_printf(MSG_INFO, "dbus: Register group object '%s'",
3836 obj_desc = os_zalloc(sizeof(struct wpa_dbus_object_desc));
3838 wpa_printf(MSG_ERROR,
3839 "Not enough memory to create object description");
3843 wpas_dbus_register(obj_desc, wpa_s, NULL, NULL,
3844 wpas_dbus_p2p_group_properties,
3845 wpas_dbus_p2p_group_signals);
3847 if (wpa_dbus_register_object_per_iface(ctrl_iface, group_obj_path,
3848 wpa_s->ifname, obj_desc))
3854 if (wpa_s->dbus_groupobj_path) {
3855 os_free(wpa_s->dbus_groupobj_path);
3856 wpa_s->dbus_groupobj_path = NULL;
3859 free_dbus_object_desc(obj_desc);
3863 * wpas_dbus_unregister_p2p_group - Unregister a p2p group object from dbus
3864 * @wpa_s: wpa_supplicant interface structure
3865 * @ssid: network name of the p2p group started
3867 void wpas_dbus_unregister_p2p_group(struct wpa_supplicant *wpa_s,
3868 const struct wpa_ssid *ssid)
3870 struct wpas_dbus_priv *ctrl_iface;
3872 /* Do nothing if the control interface is not turned on */
3873 if (wpa_s == NULL || wpa_s->global == NULL)
3876 if (wpa_s->p2p_mgmt)
3877 wpa_s = wpa_s->parent;
3879 ctrl_iface = wpa_s->global->dbus;
3880 if (ctrl_iface == NULL)
3883 if (!wpa_s->dbus_groupobj_path) {
3884 wpa_printf(MSG_DEBUG,
3885 "%s: Group object '%s' already unregistered",
3886 __func__, wpa_s->dbus_groupobj_path);
3890 peer_groups_changed(wpa_s);
3892 wpa_printf(MSG_DEBUG, "dbus: Unregister group object '%s'",
3893 wpa_s->dbus_groupobj_path);
3895 wpa_dbus_unregister_object_per_iface(ctrl_iface,
3896 wpa_s->dbus_groupobj_path);
3898 os_free(wpa_s->dbus_groupobj_path);
3899 wpa_s->dbus_groupobj_path = NULL;
3902 static const struct wpa_dbus_property_desc
3903 wpas_dbus_persistent_group_properties[] = {
3904 { "Properties", WPAS_DBUS_NEW_IFACE_PERSISTENT_GROUP, "a{sv}",
3905 wpas_dbus_getter_persistent_group_properties,
3906 wpas_dbus_setter_persistent_group_properties
3908 { NULL, NULL, NULL, NULL, NULL }
3911 /* No signals intended for persistent group objects */
3914 * wpas_dbus_register_persistent_group - Register a configured(saved)
3915 * persistent group with dbus
3916 * @wpa_s: wpa_supplicant interface structure
3917 * @ssid: persistent group (still represented as a network within wpa)
3918 * configuration data
3919 * Returns: 0 on success, -1 on failure
3921 * Registers a persistent group representing object with dbus.
3923 int wpas_dbus_register_persistent_group(struct wpa_supplicant *wpa_s,
3924 struct wpa_ssid *ssid)
3926 struct wpas_dbus_priv *ctrl_iface;
3927 struct wpa_dbus_object_desc *obj_desc;
3928 struct network_handler_args *arg;
3929 char pgrp_obj_path[WPAS_DBUS_OBJECT_PATH_MAX];
3931 /* Do nothing if the control interface is not turned on */
3932 if (wpa_s == NULL || wpa_s->global == NULL)
3934 wpa_s = wpa_s->parent->parent;
3935 if (!wpa_s->dbus_new_path)
3938 /* Make sure ssid is a persistent group */
3939 if (ssid->disabled != 2 && !ssid->p2p_persistent_group)
3940 return -1; /* should we return w/o complaining? */
3942 if (wpa_s->p2p_mgmt)
3943 wpa_s = wpa_s->parent;
3945 ctrl_iface = wpa_s->global->dbus;
3946 if (ctrl_iface == NULL)
3950 * Intentionally not coming up with different numbering scheme
3951 * for persistent groups.
3953 os_snprintf(pgrp_obj_path, WPAS_DBUS_OBJECT_PATH_MAX,
3954 "%s/" WPAS_DBUS_NEW_PERSISTENT_GROUPS_PART "/%u",
3955 wpa_s->dbus_new_path, ssid->id);
3957 wpa_printf(MSG_DEBUG, "dbus: Register persistent group object '%s'",
3959 obj_desc = os_zalloc(sizeof(struct wpa_dbus_object_desc));
3961 wpa_printf(MSG_ERROR,
3962 "dbus: Not enough memory to create object description");
3967 * Reusing the same context structure as that for networks
3968 * since these are represented using same data structure.
3970 /* allocate memory for handlers arguments */
3971 arg = os_zalloc(sizeof(struct network_handler_args));
3973 wpa_printf(MSG_ERROR,
3974 "dbus: Not enough memory to create arguments for method");
3981 wpas_dbus_register(obj_desc, arg, wpa_dbus_free, NULL,
3982 wpas_dbus_persistent_group_properties,
3985 if (wpa_dbus_register_object_per_iface(ctrl_iface, pgrp_obj_path,
3986 wpa_s->ifname, obj_desc))
3989 wpas_dbus_signal_persistent_group_added(wpa_s, ssid->id);
3994 free_dbus_object_desc(obj_desc);
4000 * wpas_dbus_unregister_persistent_group - Unregister a persistent_group
4002 * @wpa_s: wpa_supplicant interface structure
4004 * Returns: 0 on success, -1 on failure
4006 * Unregisters persistent group representing object from dbus
4008 * NOTE: There is a slight issue with the semantics here. While the
4009 * implementation simply means the persistent group is unloaded from memory,
4010 * it should not get interpreted as the group is actually being erased/removed
4011 * from persistent storage as well.
4013 int wpas_dbus_unregister_persistent_group(struct wpa_supplicant *wpa_s,
4016 struct wpas_dbus_priv *ctrl_iface;
4017 char pgrp_obj_path[WPAS_DBUS_OBJECT_PATH_MAX];
4020 /* Do nothing if the control interface is not turned on */
4021 if (wpa_s == NULL || wpa_s->global == NULL)
4024 wpa_s = wpa_s->parent->parent;
4026 ctrl_iface = wpa_s->global->dbus;
4027 if (ctrl_iface == NULL || !wpa_s->dbus_new_path)
4030 os_snprintf(pgrp_obj_path, WPAS_DBUS_OBJECT_PATH_MAX,
4031 "%s/" WPAS_DBUS_NEW_PERSISTENT_GROUPS_PART "/%u",
4032 wpa_s->dbus_new_path, nid);
4034 wpa_printf(MSG_DEBUG, "dbus: Unregister persistent group object '%s'",
4036 ret = wpa_dbus_unregister_object_per_iface(ctrl_iface, pgrp_obj_path);
4039 wpas_dbus_signal_persistent_group_removed(wpa_s, nid);
4044 #endif /* CONFIG_P2P */