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"
28 #ifdef CONFIG_AP /* until needed by something else */
31 * NameOwnerChanged handling
33 * Some services we provide allow an application to register for
34 * a signal that it needs. While it can also unregister, we must
35 * be prepared for the case where the application simply crashes
36 * and thus doesn't clean up properly. The way to handle this in
37 * DBus is to register for the NameOwnerChanged signal which will
38 * signal an owner change to NULL if the peer closes the socket
39 * for whatever reason.
41 * Handle this signal via a filter function whenever necessary.
42 * The code below also handles refcounting in case in the future
43 * there will be multiple instances of this subscription scheme.
45 static const char wpas_dbus_noc_filter_str
[] =
46 "interface=org.freedesktop.DBus,member=NameOwnerChanged";
49 static DBusHandlerResult
noc_filter(DBusConnection
*conn
,
50 DBusMessage
*message
, void *data
)
52 struct wpas_dbus_priv
*priv
= data
;
54 if (dbus_message_get_type(message
) != DBUS_MESSAGE_TYPE_SIGNAL
)
55 return DBUS_HANDLER_RESULT_NOT_YET_HANDLED
;
57 if (dbus_message_is_signal(message
, DBUS_INTERFACE_DBUS
,
58 "NameOwnerChanged")) {
60 const char *prev_owner
;
61 const char *new_owner
;
63 struct wpa_supplicant
*wpa_s
;
65 dbus_error_init(&derr
);
67 if (!dbus_message_get_args(message
, &derr
,
68 DBUS_TYPE_STRING
, &name
,
69 DBUS_TYPE_STRING
, &prev_owner
,
70 DBUS_TYPE_STRING
, &new_owner
,
72 /* Ignore this error */
73 dbus_error_free(&derr
);
74 return DBUS_HANDLER_RESULT_NOT_YET_HANDLED
;
77 for (wpa_s
= priv
->global
->ifaces
; wpa_s
; wpa_s
= wpa_s
->next
)
79 if (wpa_s
->preq_notify_peer
!= NULL
&&
80 os_strcmp(name
, wpa_s
->preq_notify_peer
) == 0 &&
81 (new_owner
== NULL
|| os_strlen(new_owner
) == 0)) {
82 /* probe request owner disconnected */
83 os_free(wpa_s
->preq_notify_peer
);
84 wpa_s
->preq_notify_peer
= NULL
;
85 wpas_dbus_unsubscribe_noc(priv
);
90 return DBUS_HANDLER_RESULT_NOT_YET_HANDLED
;
94 void wpas_dbus_subscribe_noc(struct wpas_dbus_priv
*priv
)
96 priv
->dbus_noc_refcnt
++;
97 if (priv
->dbus_noc_refcnt
> 1)
100 if (!dbus_connection_add_filter(priv
->con
, noc_filter
, priv
, NULL
)) {
101 wpa_printf(MSG_ERROR
, "dbus: failed to add filter");
105 dbus_bus_add_match(priv
->con
, wpas_dbus_noc_filter_str
, NULL
);
109 void wpas_dbus_unsubscribe_noc(struct wpas_dbus_priv
*priv
)
111 priv
->dbus_noc_refcnt
--;
112 if (priv
->dbus_noc_refcnt
> 0)
115 dbus_bus_remove_match(priv
->con
, wpas_dbus_noc_filter_str
, NULL
);
116 dbus_connection_remove_filter(priv
->con
, noc_filter
, priv
);
119 #endif /* CONFIG_AP */
123 * wpas_dbus_signal_interface - Send a interface related event signal
124 * @wpa_s: %wpa_supplicant network interface data
125 * @sig_name: signal name - InterfaceAdded or InterfaceRemoved
126 * @properties: Whether to add second argument with object properties
128 * Notify listeners about event related with interface
130 static void wpas_dbus_signal_interface(struct wpa_supplicant
*wpa_s
,
131 const char *sig_name
, int properties
)
133 struct wpas_dbus_priv
*iface
;
135 DBusMessageIter iter
;
137 iface
= wpa_s
->global
->dbus
;
139 /* Do nothing if the control interface is not turned on */
143 msg
= dbus_message_new_signal(WPAS_DBUS_NEW_PATH
,
144 WPAS_DBUS_NEW_INTERFACE
, sig_name
);
148 dbus_message_iter_init_append(msg
, &iter
);
149 if (!dbus_message_iter_append_basic(&iter
, DBUS_TYPE_OBJECT_PATH
,
150 &wpa_s
->dbus_new_path
))
154 if (!wpa_dbus_get_object_properties(
155 iface
, wpa_s
->dbus_new_path
,
156 WPAS_DBUS_NEW_IFACE_INTERFACE
, &iter
))
160 dbus_connection_send(iface
->con
, msg
, NULL
);
161 dbus_message_unref(msg
);
165 wpa_printf(MSG_ERROR
, "dbus: Failed to construct signal");
166 dbus_message_unref(msg
);
171 * wpas_dbus_signal_interface_added - Send a interface created signal
172 * @wpa_s: %wpa_supplicant network interface data
174 * Notify listeners about creating new interface
176 static void wpas_dbus_signal_interface_added(struct wpa_supplicant
*wpa_s
)
178 wpas_dbus_signal_interface(wpa_s
, "InterfaceAdded", TRUE
);
183 * wpas_dbus_signal_interface_removed - Send a interface removed signal
184 * @wpa_s: %wpa_supplicant network interface data
186 * Notify listeners about removing interface
188 static void wpas_dbus_signal_interface_removed(struct wpa_supplicant
*wpa_s
)
190 wpas_dbus_signal_interface(wpa_s
, "InterfaceRemoved", FALSE
);
196 * wpas_dbus_signal_scan_done - send scan done signal
197 * @wpa_s: %wpa_supplicant network interface data
198 * @success: indicates if scanning succeed or failed
200 * Notify listeners about finishing a scan
202 void wpas_dbus_signal_scan_done(struct wpa_supplicant
*wpa_s
, int success
)
204 struct wpas_dbus_priv
*iface
;
208 iface
= wpa_s
->global
->dbus
;
210 /* Do nothing if the control interface is not turned on */
214 msg
= dbus_message_new_signal(wpa_s
->dbus_new_path
,
215 WPAS_DBUS_NEW_IFACE_INTERFACE
,
220 succ
= success
? TRUE
: FALSE
;
221 if (dbus_message_append_args(msg
, DBUS_TYPE_BOOLEAN
, &succ
,
223 dbus_connection_send(iface
->con
, msg
, NULL
);
225 wpa_printf(MSG_ERROR
, "dbus: Failed to construct signal");
226 dbus_message_unref(msg
);
231 * wpas_dbus_signal_blob - Send a BSS related event signal
232 * @wpa_s: %wpa_supplicant network interface data
233 * @bss_obj_path: BSS object path
234 * @sig_name: signal name - BSSAdded or BSSRemoved
235 * @properties: Whether to add second argument with object properties
237 * Notify listeners about event related with BSS
239 static void wpas_dbus_signal_bss(struct wpa_supplicant
*wpa_s
,
240 const char *bss_obj_path
,
241 const char *sig_name
, int properties
)
243 struct wpas_dbus_priv
*iface
;
245 DBusMessageIter iter
;
247 iface
= wpa_s
->global
->dbus
;
249 /* Do nothing if the control interface is not turned on */
253 msg
= dbus_message_new_signal(wpa_s
->dbus_new_path
,
254 WPAS_DBUS_NEW_IFACE_INTERFACE
,
259 dbus_message_iter_init_append(msg
, &iter
);
260 if (!dbus_message_iter_append_basic(&iter
, DBUS_TYPE_OBJECT_PATH
,
265 if (!wpa_dbus_get_object_properties(iface
, bss_obj_path
,
266 WPAS_DBUS_NEW_IFACE_BSS
,
271 dbus_connection_send(iface
->con
, msg
, NULL
);
272 dbus_message_unref(msg
);
276 wpa_printf(MSG_ERROR
, "dbus: Failed to construct signal");
277 dbus_message_unref(msg
);
282 * wpas_dbus_signal_bss_added - Send a BSS added signal
283 * @wpa_s: %wpa_supplicant network interface data
284 * @bss_obj_path: new BSS object path
286 * Notify listeners about adding new BSS
288 static void wpas_dbus_signal_bss_added(struct wpa_supplicant
*wpa_s
,
289 const char *bss_obj_path
)
291 wpas_dbus_signal_bss(wpa_s
, bss_obj_path
, "BSSAdded", TRUE
);
296 * wpas_dbus_signal_bss_removed - Send a BSS removed signal
297 * @wpa_s: %wpa_supplicant network interface data
298 * @bss_obj_path: BSS object path
300 * Notify listeners about removing BSS
302 static void wpas_dbus_signal_bss_removed(struct wpa_supplicant
*wpa_s
,
303 const char *bss_obj_path
)
305 wpas_dbus_signal_bss(wpa_s
, bss_obj_path
, "BSSRemoved", FALSE
);
310 * wpas_dbus_signal_blob - Send a blob related event signal
311 * @wpa_s: %wpa_supplicant network interface data
313 * @sig_name: signal name - BlobAdded or BlobRemoved
315 * Notify listeners about event related with blob
317 static void wpas_dbus_signal_blob(struct wpa_supplicant
*wpa_s
,
318 const char *name
, const char *sig_name
)
320 struct wpas_dbus_priv
*iface
;
323 iface
= wpa_s
->global
->dbus
;
325 /* Do nothing if the control interface is not turned on */
329 msg
= dbus_message_new_signal(wpa_s
->dbus_new_path
,
330 WPAS_DBUS_NEW_IFACE_INTERFACE
,
335 if (dbus_message_append_args(msg
, DBUS_TYPE_STRING
, &name
,
337 dbus_connection_send(iface
->con
, msg
, NULL
);
339 wpa_printf(MSG_ERROR
, "dbus: Failed to construct signal");
340 dbus_message_unref(msg
);
345 * wpas_dbus_signal_blob_added - Send a blob added signal
346 * @wpa_s: %wpa_supplicant network interface data
349 * Notify listeners about adding a new blob
351 void wpas_dbus_signal_blob_added(struct wpa_supplicant
*wpa_s
,
354 wpas_dbus_signal_blob(wpa_s
, name
, "BlobAdded");
359 * wpas_dbus_signal_blob_removed - Send a blob removed signal
360 * @wpa_s: %wpa_supplicant network interface data
363 * Notify listeners about removing blob
365 void wpas_dbus_signal_blob_removed(struct wpa_supplicant
*wpa_s
,
368 wpas_dbus_signal_blob(wpa_s
, name
, "BlobRemoved");
373 * wpas_dbus_signal_network - Send a network related event signal
374 * @wpa_s: %wpa_supplicant network interface data
375 * @id: new network id
376 * @sig_name: signal name - NetworkAdded, NetworkRemoved or NetworkSelected
377 * @properties: determines if add second argument with object properties
379 * Notify listeners about event related with configured network
381 static void wpas_dbus_signal_network(struct wpa_supplicant
*wpa_s
,
382 int id
, const char *sig_name
,
385 struct wpas_dbus_priv
*iface
;
387 DBusMessageIter iter
;
388 char net_obj_path
[WPAS_DBUS_OBJECT_PATH_MAX
], *path
;
390 iface
= wpa_s
->global
->dbus
;
392 /* Do nothing if the control interface is not turned on */
396 os_snprintf(net_obj_path
, WPAS_DBUS_OBJECT_PATH_MAX
,
397 "%s/" WPAS_DBUS_NEW_NETWORKS_PART
"/%u",
398 wpa_s
->dbus_new_path
, id
);
400 msg
= dbus_message_new_signal(wpa_s
->dbus_new_path
,
401 WPAS_DBUS_NEW_IFACE_INTERFACE
,
406 dbus_message_iter_init_append(msg
, &iter
);
408 if (!dbus_message_iter_append_basic(&iter
, DBUS_TYPE_OBJECT_PATH
,
413 if (!wpa_dbus_get_object_properties(
414 iface
, net_obj_path
, WPAS_DBUS_NEW_IFACE_NETWORK
,
419 dbus_connection_send(iface
->con
, msg
, NULL
);
421 dbus_message_unref(msg
);
425 wpa_printf(MSG_ERROR
, "dbus: Failed to construct signal");
426 dbus_message_unref(msg
);
431 * wpas_dbus_signal_network_added - Send a network added signal
432 * @wpa_s: %wpa_supplicant network interface data
433 * @id: new network id
435 * Notify listeners about adding new network
437 static void wpas_dbus_signal_network_added(struct wpa_supplicant
*wpa_s
,
440 wpas_dbus_signal_network(wpa_s
, id
, "NetworkAdded", TRUE
);
445 * wpas_dbus_signal_network_removed - Send a network removed signal
446 * @wpa_s: %wpa_supplicant network interface data
449 * Notify listeners about removing a network
451 static void wpas_dbus_signal_network_removed(struct wpa_supplicant
*wpa_s
,
454 wpas_dbus_signal_network(wpa_s
, id
, "NetworkRemoved", FALSE
);
459 * wpas_dbus_signal_network_selected - Send a network selected signal
460 * @wpa_s: %wpa_supplicant network interface data
463 * Notify listeners about selecting a network
465 void wpas_dbus_signal_network_selected(struct wpa_supplicant
*wpa_s
, int id
)
467 wpas_dbus_signal_network(wpa_s
, id
, "NetworkSelected", FALSE
);
472 * wpas_dbus_signal_network_request - Indicate that additional information
473 * (EAP password, etc.) is required to complete the association to this SSID
474 * @wpa_s: %wpa_supplicant network interface data
475 * @rtype: The specific additional information required
476 * @default_text: Optional description of required information
478 * Request additional information or passwords to complete an association
481 void wpas_dbus_signal_network_request(struct wpa_supplicant
*wpa_s
,
482 struct wpa_ssid
*ssid
,
483 enum wpa_ctrl_req_type rtype
,
484 const char *default_txt
)
486 struct wpas_dbus_priv
*iface
;
488 DBusMessageIter iter
;
489 char net_obj_path
[WPAS_DBUS_OBJECT_PATH_MAX
];
490 const char *field
, *txt
= NULL
, *net_ptr
;
492 iface
= wpa_s
->global
->dbus
;
494 /* Do nothing if the control interface is not turned on */
498 field
= wpa_supplicant_ctrl_req_to_string(rtype
, default_txt
, &txt
);
502 msg
= dbus_message_new_signal(wpa_s
->dbus_new_path
,
503 WPAS_DBUS_NEW_IFACE_INTERFACE
,
508 os_snprintf(net_obj_path
, WPAS_DBUS_OBJECT_PATH_MAX
,
509 "%s/" WPAS_DBUS_NEW_NETWORKS_PART
"/%u",
510 wpa_s
->dbus_new_path
, ssid
->id
);
511 net_ptr
= &net_obj_path
[0];
513 dbus_message_iter_init_append(msg
, &iter
);
514 if (!dbus_message_iter_append_basic(&iter
, DBUS_TYPE_OBJECT_PATH
,
517 if (!dbus_message_iter_append_basic(&iter
, DBUS_TYPE_STRING
, &field
))
519 if (!dbus_message_iter_append_basic(&iter
, DBUS_TYPE_STRING
, &txt
))
522 dbus_connection_send(iface
->con
, msg
, NULL
);
523 dbus_message_unref(msg
);
527 wpa_printf(MSG_ERROR
, "dbus: Failed to construct signal");
528 dbus_message_unref(msg
);
533 * wpas_dbus_signal_network_enabled_changed - Signals Enabled property changes
534 * @wpa_s: %wpa_supplicant network interface data
535 * @ssid: configured network which Enabled property has changed
537 * Sends PropertyChanged signals containing new value of Enabled property
538 * for specified network
540 void wpas_dbus_signal_network_enabled_changed(struct wpa_supplicant
*wpa_s
,
541 struct wpa_ssid
*ssid
)
544 char path
[WPAS_DBUS_OBJECT_PATH_MAX
];
545 os_snprintf(path
, WPAS_DBUS_OBJECT_PATH_MAX
,
546 "%s/" WPAS_DBUS_NEW_NETWORKS_PART
"/%d",
547 wpa_s
->dbus_new_path
, ssid
->id
);
549 wpa_dbus_mark_property_changed(wpa_s
->global
->dbus
, path
,
550 WPAS_DBUS_NEW_IFACE_NETWORK
, "Enabled");
557 * wpas_dbus_signal_wps_event_success - Signals Success WPS event
558 * @wpa_s: %wpa_supplicant network interface data
560 * Sends Event dbus signal with name "success" and empty dict as arguments
562 void wpas_dbus_signal_wps_event_success(struct wpa_supplicant
*wpa_s
)
566 DBusMessageIter iter
, dict_iter
;
567 struct wpas_dbus_priv
*iface
;
568 char *key
= "success";
570 iface
= wpa_s
->global
->dbus
;
572 /* Do nothing if the control interface is not turned on */
576 msg
= dbus_message_new_signal(wpa_s
->dbus_new_path
,
577 WPAS_DBUS_NEW_IFACE_WPS
, "Event");
581 dbus_message_iter_init_append(msg
, &iter
);
583 if (!dbus_message_iter_append_basic(&iter
, DBUS_TYPE_STRING
, &key
) ||
584 !wpa_dbus_dict_open_write(&iter
, &dict_iter
) ||
585 !wpa_dbus_dict_close_write(&iter
, &dict_iter
))
586 wpa_printf(MSG_ERROR
, "dbus: Failed to construct signal");
588 dbus_connection_send(iface
->con
, msg
, NULL
);
590 dbus_message_unref(msg
);
595 * wpas_dbus_signal_wps_event_fail - Signals Fail WPS event
596 * @wpa_s: %wpa_supplicant network interface data
598 * Sends Event dbus signal with name "fail" and dictionary containing
599 * "msg field with fail message number (int32) as arguments
601 void wpas_dbus_signal_wps_event_fail(struct wpa_supplicant
*wpa_s
,
602 struct wps_event_fail
*fail
)
606 DBusMessageIter iter
, dict_iter
;
607 struct wpas_dbus_priv
*iface
;
610 iface
= wpa_s
->global
->dbus
;
612 /* Do nothing if the control interface is not turned on */
616 msg
= dbus_message_new_signal(wpa_s
->dbus_new_path
,
617 WPAS_DBUS_NEW_IFACE_WPS
, "Event");
621 dbus_message_iter_init_append(msg
, &iter
);
623 if (!dbus_message_iter_append_basic(&iter
, DBUS_TYPE_STRING
, &key
) ||
624 !wpa_dbus_dict_open_write(&iter
, &dict_iter
) ||
625 !wpa_dbus_dict_append_int32(&dict_iter
, "msg", fail
->msg
) ||
626 !wpa_dbus_dict_close_write(&iter
, &dict_iter
))
627 wpa_printf(MSG_ERROR
, "dbus: Failed to construct signal");
629 dbus_connection_send(iface
->con
, msg
, NULL
);
631 dbus_message_unref(msg
);
636 * wpas_dbus_signal_wps_event_m2d - Signals M2D WPS event
637 * @wpa_s: %wpa_supplicant network interface data
639 * Sends Event dbus signal with name "m2d" and dictionary containing
640 * fields of wps_event_m2d structure.
642 void wpas_dbus_signal_wps_event_m2d(struct wpa_supplicant
*wpa_s
,
643 struct wps_event_m2d
*m2d
)
647 DBusMessageIter iter
, dict_iter
;
648 struct wpas_dbus_priv
*iface
;
651 iface
= wpa_s
->global
->dbus
;
653 /* Do nothing if the control interface is not turned on */
657 msg
= dbus_message_new_signal(wpa_s
->dbus_new_path
,
658 WPAS_DBUS_NEW_IFACE_WPS
, "Event");
662 dbus_message_iter_init_append(msg
, &iter
);
664 if (!dbus_message_iter_append_basic(&iter
, DBUS_TYPE_STRING
, &key
) ||
665 !wpa_dbus_dict_open_write(&iter
, &dict_iter
) ||
666 !wpa_dbus_dict_append_uint16(&dict_iter
, "config_methods",
667 m2d
->config_methods
) ||
668 !wpa_dbus_dict_append_byte_array(&dict_iter
, "manufacturer",
669 (const char *) m2d
->manufacturer
,
670 m2d
->manufacturer_len
) ||
671 !wpa_dbus_dict_append_byte_array(&dict_iter
, "model_name",
672 (const char *) m2d
->model_name
,
673 m2d
->model_name_len
) ||
674 !wpa_dbus_dict_append_byte_array(&dict_iter
, "model_number",
675 (const char *) m2d
->model_number
,
676 m2d
->model_number_len
) ||
677 !wpa_dbus_dict_append_byte_array(&dict_iter
, "serial_number",
680 m2d
->serial_number_len
) ||
681 !wpa_dbus_dict_append_byte_array(&dict_iter
, "dev_name",
682 (const char *) m2d
->dev_name
,
683 m2d
->dev_name_len
) ||
684 !wpa_dbus_dict_append_byte_array(&dict_iter
, "primary_dev_type",
686 m2d
->primary_dev_type
, 8) ||
687 !wpa_dbus_dict_append_uint16(&dict_iter
, "config_error",
688 m2d
->config_error
) ||
689 !wpa_dbus_dict_append_uint16(&dict_iter
, "dev_password_id",
690 m2d
->dev_password_id
) ||
691 !wpa_dbus_dict_close_write(&iter
, &dict_iter
))
692 wpa_printf(MSG_ERROR
, "dbus: Failed to construct signal");
694 dbus_connection_send(iface
->con
, msg
, NULL
);
696 dbus_message_unref(msg
);
701 * wpas_dbus_signal_wps_cred - Signals new credentials
702 * @wpa_s: %wpa_supplicant network interface data
704 * Sends signal with credentials in directory argument
706 void wpas_dbus_signal_wps_cred(struct wpa_supplicant
*wpa_s
,
707 const struct wps_credential
*cred
)
710 DBusMessageIter iter
, dict_iter
;
711 struct wpas_dbus_priv
*iface
;
712 char *auth_type
[6]; /* we have six possible authorization types */
714 char *encr_type
[4]; /* we have four possible encryption types */
717 iface
= wpa_s
->global
->dbus
;
719 /* Do nothing if the control interface is not turned on */
723 msg
= dbus_message_new_signal(wpa_s
->dbus_new_path
,
724 WPAS_DBUS_NEW_IFACE_WPS
,
729 dbus_message_iter_init_append(msg
, &iter
);
730 if (!wpa_dbus_dict_open_write(&iter
, &dict_iter
))
733 if (cred
->auth_type
& WPS_AUTH_OPEN
)
734 auth_type
[at_num
++] = "open";
735 if (cred
->auth_type
& WPS_AUTH_WPAPSK
)
736 auth_type
[at_num
++] = "wpa-psk";
737 if (cred
->auth_type
& WPS_AUTH_SHARED
)
738 auth_type
[at_num
++] = "shared";
739 if (cred
->auth_type
& WPS_AUTH_WPA
)
740 auth_type
[at_num
++] = "wpa-eap";
741 if (cred
->auth_type
& WPS_AUTH_WPA2
)
742 auth_type
[at_num
++] = "wpa2-eap";
743 if (cred
->auth_type
& WPS_AUTH_WPA2PSK
)
744 auth_type
[at_num
++] =
747 if (cred
->encr_type
& WPS_ENCR_NONE
)
748 encr_type
[et_num
++] = "none";
749 if (cred
->encr_type
& WPS_ENCR_WEP
)
750 encr_type
[et_num
++] = "wep";
751 if (cred
->encr_type
& WPS_ENCR_TKIP
)
752 encr_type
[et_num
++] = "tkip";
753 if (cred
->encr_type
& WPS_ENCR_AES
)
754 encr_type
[et_num
++] = "aes";
756 if (wpa_s
->current_ssid
) {
757 if (!wpa_dbus_dict_append_byte_array(
759 (const char *) wpa_s
->current_ssid
->bssid
,
764 if (!wpa_dbus_dict_append_byte_array(&dict_iter
, "SSID",
765 (const char *) cred
->ssid
,
767 !wpa_dbus_dict_append_string_array(&dict_iter
, "AuthType",
768 (const char **) auth_type
,
770 !wpa_dbus_dict_append_string_array(&dict_iter
, "EncrType",
771 (const char **) encr_type
,
773 !wpa_dbus_dict_append_byte_array(&dict_iter
, "Key",
774 (const char *) cred
->key
,
776 !wpa_dbus_dict_append_uint32(&dict_iter
, "KeyIndex",
778 !wpa_dbus_dict_close_write(&iter
, &dict_iter
))
781 dbus_connection_send(iface
->con
, msg
, NULL
);
784 dbus_message_unref(msg
);
787 #endif /* CONFIG_WPS */
789 void wpas_dbus_signal_certification(struct wpa_supplicant
*wpa_s
,
790 int depth
, const char *subject
,
791 const char *cert_hash
,
792 const struct wpabuf
*cert
)
794 struct wpas_dbus_priv
*iface
;
796 DBusMessageIter iter
, dict_iter
;
798 iface
= wpa_s
->global
->dbus
;
800 /* Do nothing if the control interface is not turned on */
804 msg
= dbus_message_new_signal(wpa_s
->dbus_new_path
,
805 WPAS_DBUS_NEW_IFACE_INTERFACE
,
810 dbus_message_iter_init_append(msg
, &iter
);
811 if (!wpa_dbus_dict_open_write(&iter
, &dict_iter
))
814 if (!wpa_dbus_dict_append_uint32(&dict_iter
, "depth", depth
) ||
815 !wpa_dbus_dict_append_string(&dict_iter
, "subject", subject
))
819 !wpa_dbus_dict_append_string(&dict_iter
, "cert_hash", cert_hash
))
823 !wpa_dbus_dict_append_byte_array(&dict_iter
, "cert",
828 if (!wpa_dbus_dict_close_write(&iter
, &dict_iter
))
831 dbus_connection_send(iface
->con
, msg
, NULL
);
834 dbus_message_unref(msg
);
838 void wpas_dbus_signal_eap_status(struct wpa_supplicant
*wpa_s
,
839 const char *status
, const char *parameter
)
841 struct wpas_dbus_priv
*iface
;
843 DBusMessageIter iter
;
845 iface
= wpa_s
->global
->dbus
;
847 /* Do nothing if the control interface is not turned on */
851 msg
= dbus_message_new_signal(wpa_s
->dbus_new_path
,
852 WPAS_DBUS_NEW_IFACE_INTERFACE
,
857 dbus_message_iter_init_append(msg
, &iter
);
859 if (!dbus_message_iter_append_basic(&iter
, DBUS_TYPE_STRING
, &status
)
861 !dbus_message_iter_append_basic(&iter
, DBUS_TYPE_STRING
,
865 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 */
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
,
955 DBusMessageIter iter
;
956 struct wpas_dbus_priv
*iface
= wpa_s
->global
->dbus
;
957 char *ifname
= wpa_s
->ifname
;
959 /* Do nothing if the control interface is not turned on */
963 msg
= dbus_message_new_signal(wpa_s
->dbus_new_path
,
964 WPAS_DBUS_NEW_IFACE_P2PDEVICE
,
969 dbus_message_iter_init_append(msg
, &iter
);
971 if (!dbus_message_iter_append_basic(&iter
, DBUS_TYPE_STRING
, &ifname
)) {
972 wpa_printf(MSG_ERROR
, "dbus: Failed to construct GroupFinished"
973 "signal -not enough memory for ifname ");
977 if (!dbus_message_iter_append_basic(&iter
, DBUS_TYPE_STRING
, &role
))
978 wpa_printf(MSG_ERROR
, "dbus: Failed to construct GroupFinished"
979 "signal -not enough memory for role ");
981 dbus_connection_send(iface
->con
, msg
, NULL
);
984 dbus_message_unref(msg
);
989 * wpas_dbus_signal_p2p_provision_discovery - Signals various PD events
991 * @dev_addr - who sent the request or responded to our request.
992 * @request - Will be 1 if request, 0 for response.
993 * @status - valid only in case of response
994 * @config_methods - wps config methods
995 * @generated_pin - pin to be displayed in case of WPS_CONFIG_DISPLAY method
997 * Sends following provision discovery related events:
998 * ProvisionDiscoveryRequestDisplayPin
999 * ProvisionDiscoveryResponseDisplayPin
1000 * ProvisionDiscoveryRequestEnterPin
1001 * ProvisionDiscoveryResponseEnterPin
1002 * ProvisionDiscoveryPBCRequest
1003 * ProvisionDiscoveryPBCResponse
1006 * ProvisionDiscoveryFailure (timeout case)
1008 void wpas_dbus_signal_p2p_provision_discovery(struct wpa_supplicant
*wpa_s
,
1009 const u8
*dev_addr
, int request
,
1010 enum p2p_prov_disc_status status
,
1012 unsigned int generated_pin
)
1015 DBusMessageIter iter
;
1016 struct wpas_dbus_priv
*iface
;
1019 char peer_obj_path
[WPAS_DBUS_OBJECT_PATH_MAX
], *path
;
1021 char pin
[9], *p_pin
= NULL
;
1023 iface
= wpa_s
->global
->dbus
;
1025 /* Do nothing if the control interface is not turned on */
1029 if (request
|| !status
) {
1030 if (config_methods
& WPS_CONFIG_DISPLAY
)
1032 "ProvisionDiscoveryRequestDisplayPin" :
1033 "ProvisionDiscoveryResponseEnterPin";
1034 else if (config_methods
& WPS_CONFIG_KEYPAD
)
1036 "ProvisionDiscoveryRequestEnterPin" :
1037 "ProvisionDiscoveryResponseDisplayPin";
1038 else if (config_methods
& WPS_CONFIG_PUSHBUTTON
)
1039 _signal
= request
? "ProvisionDiscoveryPBCRequest" :
1040 "ProvisionDiscoveryPBCResponse";
1042 return; /* Unknown or un-supported method */
1043 } else if (!request
&& status
)
1044 /* Explicit check for failure response */
1045 _signal
= "ProvisionDiscoveryFailure";
1047 add_pin
= ((request
&& (config_methods
& WPS_CONFIG_DISPLAY
)) ||
1048 (!request
&& !status
&&
1049 (config_methods
& WPS_CONFIG_KEYPAD
)));
1052 os_snprintf(pin
, sizeof(pin
), "%08d", generated_pin
);
1056 msg
= dbus_message_new_signal(wpa_s
->dbus_new_path
,
1057 WPAS_DBUS_NEW_IFACE_P2PDEVICE
, _signal
);
1061 /* Check if this is a known peer */
1062 if (!p2p_peer_known(wpa_s
->global
->p2p
, dev_addr
))
1065 os_snprintf(peer_obj_path
, WPAS_DBUS_OBJECT_PATH_MAX
,
1066 "%s/" WPAS_DBUS_NEW_P2P_PEERS_PART
"/"
1068 wpa_s
->dbus_new_path
, MAC2STR(dev_addr
));
1070 path
= peer_obj_path
;
1072 dbus_message_iter_init_append(msg
, &iter
);
1074 if (!dbus_message_iter_append_basic(&iter
,
1075 DBUS_TYPE_OBJECT_PATH
,
1079 if (!request
&& status
)
1080 /* Attach status to ProvisionDiscoveryFailure */
1081 error_ret
= !dbus_message_iter_append_basic(&iter
,
1085 error_ret
= (add_pin
&&
1086 !dbus_message_iter_append_basic(&iter
,
1092 dbus_connection_send(iface
->con
, msg
, NULL
);
1094 wpa_printf(MSG_ERROR
, "dbus: Failed to construct signal");
1096 dbus_message_unref(msg
);
1100 void wpas_dbus_signal_p2p_go_neg_req(struct wpa_supplicant
*wpa_s
,
1101 const u8
*src
, u16 dev_passwd_id
)
1104 DBusMessageIter iter
;
1105 struct wpas_dbus_priv
*iface
;
1106 char peer_obj_path
[WPAS_DBUS_OBJECT_PATH_MAX
], *path
;
1108 iface
= wpa_s
->global
->dbus
;
1110 /* Do nothing if the control interface is not turned on */
1114 os_snprintf(peer_obj_path
, WPAS_DBUS_OBJECT_PATH_MAX
,
1115 "%s/" WPAS_DBUS_NEW_P2P_PEERS_PART
"/" COMPACT_MACSTR
,
1116 wpa_s
->dbus_new_path
, MAC2STR(src
));
1117 path
= peer_obj_path
;
1119 msg
= dbus_message_new_signal(wpa_s
->dbus_new_path
,
1120 WPAS_DBUS_NEW_IFACE_P2PDEVICE
,
1121 "GONegotiationRequest");
1125 dbus_message_iter_init_append(msg
, &iter
);
1127 if (!dbus_message_iter_append_basic(&iter
, DBUS_TYPE_OBJECT_PATH
,
1129 !dbus_message_iter_append_basic(&iter
, DBUS_TYPE_UINT16
,
1131 wpa_printf(MSG_ERROR
, "dbus: Failed to construct signal");
1133 dbus_connection_send(iface
->con
, msg
, NULL
);
1135 dbus_message_unref(msg
);
1139 static int wpas_dbus_get_group_obj_path(struct wpa_supplicant
*wpa_s
,
1140 const struct wpa_ssid
*ssid
,
1141 char *group_obj_path
)
1145 if (os_memcmp(ssid
->ssid
, P2P_WILDCARD_SSID
, P2P_WILDCARD_SSID_LEN
))
1148 os_memcpy(group_name
, ssid
->ssid
+ P2P_WILDCARD_SSID_LEN
, 2);
1149 group_name
[2] = '\0';
1151 os_snprintf(group_obj_path
, WPAS_DBUS_OBJECT_PATH_MAX
,
1152 "%s/" WPAS_DBUS_NEW_P2P_GROUPS_PART
"/%s",
1153 wpa_s
->dbus_new_path
, group_name
);
1160 * wpas_dbus_signal_p2p_group_started - Signals P2P group has
1161 * started. Emitted when a group is successfully started
1162 * irrespective of the role (client/GO) of the current device
1164 * @wpa_s: %wpa_supplicant network interface data
1165 * @ssid: SSID object
1166 * @client: this device is P2P client
1167 * @network_id: network id of the group started, use instead of ssid->id
1168 * to account for persistent groups
1170 void wpas_dbus_signal_p2p_group_started(struct wpa_supplicant
*wpa_s
,
1171 const struct wpa_ssid
*ssid
,
1172 int client
, int network_id
)
1175 DBusMessageIter iter
, dict_iter
;
1176 struct wpas_dbus_priv
*iface
;
1177 char group_obj_path
[WPAS_DBUS_OBJECT_PATH_MAX
];
1179 iface
= wpa_s
->parent
->global
->dbus
;
1181 /* Do nothing if the control interface is not turned on */
1185 if (wpas_dbus_get_group_obj_path(wpa_s
, ssid
, group_obj_path
) < 0)
1188 /* New interface has been created for this group */
1189 msg
= dbus_message_new_signal(wpa_s
->parent
->dbus_new_path
,
1190 WPAS_DBUS_NEW_IFACE_P2PDEVICE
,
1196 dbus_message_iter_init_append(msg
, &iter
);
1197 if (!wpa_dbus_dict_open_write(&iter
, &dict_iter
))
1201 * In case the device supports creating a separate interface the
1202 * DBus client will need to know the object path for the interface
1203 * object this group was created on, so include it here.
1205 if (!wpa_dbus_dict_append_object_path(&dict_iter
,
1207 wpa_s
->dbus_new_path
))
1210 if (!wpa_dbus_dict_append_string(&dict_iter
, "role",
1211 client
? "client" : "GO"))
1214 if (!wpa_dbus_dict_append_object_path(&dict_iter
, "group_object",
1216 !wpa_dbus_dict_close_write(&iter
, &dict_iter
))
1219 dbus_connection_send(iface
->con
, msg
, NULL
);
1222 dbus_message_unref(msg
);
1228 * Method to emit GONeogtiation Success or Failure signals based
1230 * @status: Status of the GO neg request. 0 for success, other for errors.
1232 void wpas_dbus_signal_p2p_go_neg_resp(struct wpa_supplicant
*wpa_s
,
1233 struct p2p_go_neg_results
*res
)
1236 DBusMessageIter iter
, dict_iter
;
1237 DBusMessageIter iter_dict_entry
, iter_dict_val
, iter_dict_array
;
1238 struct wpas_dbus_priv
*iface
;
1239 char peer_obj_path
[WPAS_DBUS_OBJECT_PATH_MAX
], *path
;
1240 dbus_int32_t freqs
[P2P_MAX_CHANNELS
];
1241 dbus_int32_t
*f_array
= freqs
;
1244 iface
= wpa_s
->global
->dbus
;
1246 os_memset(freqs
, 0, sizeof(freqs
));
1247 /* Do nothing if the control interface is not turned on */
1251 os_snprintf(peer_obj_path
, WPAS_DBUS_OBJECT_PATH_MAX
,
1252 "%s/" WPAS_DBUS_NEW_P2P_PEERS_PART
"/" COMPACT_MACSTR
,
1253 wpa_s
->dbus_new_path
, MAC2STR(res
->peer_device_addr
));
1254 path
= peer_obj_path
;
1256 msg
= dbus_message_new_signal(wpa_s
->dbus_new_path
,
1257 WPAS_DBUS_NEW_IFACE_P2PDEVICE
,
1258 res
->status
? "GONegotiationFailure" :
1259 "GONegotiationSuccess");
1263 dbus_message_iter_init_append(msg
, &iter
);
1264 if (!wpa_dbus_dict_open_write(&iter
, &dict_iter
))
1266 if (!wpa_dbus_dict_append_object_path(&dict_iter
, "peer_object",
1268 !wpa_dbus_dict_append_int32(&dict_iter
, "status", res
->status
))
1273 int freq_list_num
= 0;
1276 if (!wpa_dbus_dict_append_byte_array(
1277 &dict_iter
, "passphrase",
1278 (const char *) res
->passphrase
,
1279 sizeof(res
->passphrase
)))
1283 if (!wpa_dbus_dict_append_string(&dict_iter
, "role_go",
1284 res
->role_go
? "GO" :
1286 !wpa_dbus_dict_append_int32(&dict_iter
, "frequency",
1288 !wpa_dbus_dict_append_byte_array(&dict_iter
, "ssid",
1289 (const char *) res
->ssid
,
1291 !wpa_dbus_dict_append_byte_array(&dict_iter
,
1294 res
->peer_device_addr
,
1296 !wpa_dbus_dict_append_byte_array(&dict_iter
,
1297 "peer_interface_addr",
1299 res
->peer_interface_addr
,
1301 !wpa_dbus_dict_append_string(&dict_iter
, "wps_method",
1302 p2p_wps_method_text(
1306 for (i
= 0; i
< P2P_MAX_CHANNELS
; i
++) {
1307 if (res
->freq_list
[i
]) {
1308 freqs
[i
] = res
->freq_list
[i
];
1313 if (!wpa_dbus_dict_begin_array(&dict_iter
,
1315 DBUS_TYPE_INT32_AS_STRING
,
1321 if (!dbus_message_iter_append_fixed_array(&iter_dict_array
,
1327 if (!wpa_dbus_dict_end_array(&dict_iter
,
1333 if (!wpa_dbus_dict_append_int32(&dict_iter
, "persistent_group",
1334 res
->persistent_group
) ||
1335 !wpa_dbus_dict_append_uint32(&dict_iter
,
1336 "peer_config_timeout",
1337 res
->peer_config_timeout
))
1341 if (!wpa_dbus_dict_close_write(&iter
, &dict_iter
))
1344 dbus_connection_send(iface
->con
, msg
, NULL
);
1346 dbus_message_unref(msg
);
1352 * Method to emit Invitation Result signal based on status and
1354 * @status: Status of the Invite request. 0 for success, other
1356 * @bssid : Basic Service Set Identifier
1358 void wpas_dbus_signal_p2p_invitation_result(struct wpa_supplicant
*wpa_s
,
1359 int status
, const u8
*bssid
)
1362 DBusMessageIter iter
, dict_iter
;
1363 struct wpas_dbus_priv
*iface
;
1365 wpa_printf(MSG_DEBUG
, "%s", __func__
);
1367 iface
= wpa_s
->global
->dbus
;
1368 /* Do nothing if the control interface is not turned on */
1372 msg
= dbus_message_new_signal(wpa_s
->dbus_new_path
,
1373 WPAS_DBUS_NEW_IFACE_P2PDEVICE
,
1374 "InvitationResult");
1379 dbus_message_iter_init_append(msg
, &iter
);
1380 if (!wpa_dbus_dict_open_write(&iter
, &dict_iter
))
1383 if (!wpa_dbus_dict_append_int32(&dict_iter
, "status", status
))
1386 if (!wpa_dbus_dict_append_byte_array(&dict_iter
, "BSSID",
1387 (const char *) bssid
,
1391 if (!wpa_dbus_dict_close_write(&iter
, &dict_iter
))
1394 dbus_connection_send(iface
->con
, msg
, NULL
);
1397 dbus_message_unref(msg
);
1403 * Method to emit a signal for a peer joining the group.
1404 * The signal will carry path to the group member object
1405 * constructed using p2p i/f addr used for connecting.
1407 * @wpa_s: %wpa_supplicant network interface data
1408 * @member_addr: addr (p2p i/f) of the peer joining the group
1410 void wpas_dbus_signal_p2p_peer_joined(struct wpa_supplicant
*wpa_s
,
1413 struct wpas_dbus_priv
*iface
;
1415 DBusMessageIter iter
;
1416 char groupmember_obj_path
[WPAS_DBUS_OBJECT_PATH_MAX
], *path
;
1418 iface
= wpa_s
->global
->dbus
;
1420 /* Do nothing if the control interface is not turned on */
1424 if (!wpa_s
->dbus_groupobj_path
)
1427 os_snprintf(groupmember_obj_path
, WPAS_DBUS_OBJECT_PATH_MAX
,
1428 "%s/" WPAS_DBUS_NEW_P2P_GROUPMEMBERS_PART
"/"
1430 wpa_s
->dbus_groupobj_path
, MAC2STR(member
));
1432 msg
= dbus_message_new_signal(wpa_s
->dbus_groupobj_path
,
1433 WPAS_DBUS_NEW_IFACE_P2P_GROUP
,
1438 dbus_message_iter_init_append(msg
, &iter
);
1439 path
= groupmember_obj_path
;
1440 if (!dbus_message_iter_append_basic(&iter
, DBUS_TYPE_OBJECT_PATH
,
1444 dbus_connection_send(iface
->con
, msg
, NULL
);
1446 dbus_message_unref(msg
);
1450 wpa_printf(MSG_ERROR
, "dbus: Failed to construct signal");
1451 dbus_message_unref(msg
);
1457 * Method to emit a signal for a peer disconnecting the group.
1458 * The signal will carry path to the group member object
1459 * constructed using p2p i/f addr used for connecting.
1461 * @wpa_s: %wpa_supplicant network interface data
1462 * @member_addr: addr (p2p i/f) of the peer joining the group
1464 void wpas_dbus_signal_p2p_peer_disconnected(struct wpa_supplicant
*wpa_s
,
1467 struct wpas_dbus_priv
*iface
;
1469 DBusMessageIter iter
;
1470 char groupmember_obj_path
[WPAS_DBUS_OBJECT_PATH_MAX
], *path
;
1472 iface
= wpa_s
->global
->dbus
;
1474 /* Do nothing if the control interface is not turned on */
1478 if (!wpa_s
->dbus_groupobj_path
)
1481 os_snprintf(groupmember_obj_path
, WPAS_DBUS_OBJECT_PATH_MAX
,
1482 "%s/" WPAS_DBUS_NEW_P2P_GROUPMEMBERS_PART
"/"
1484 wpa_s
->dbus_groupobj_path
, MAC2STR(member
));
1486 msg
= dbus_message_new_signal(wpa_s
->dbus_groupobj_path
,
1487 WPAS_DBUS_NEW_IFACE_P2P_GROUP
,
1488 "PeerDisconnected");
1492 dbus_message_iter_init_append(msg
, &iter
);
1493 path
= groupmember_obj_path
;
1494 if (!dbus_message_iter_append_basic(&iter
, DBUS_TYPE_OBJECT_PATH
,
1498 dbus_connection_send(iface
->con
, msg
, NULL
);
1500 dbus_message_unref(msg
);
1504 wpa_printf(MSG_ERROR
, "dbus: Failed to construct PeerDisconnected "
1506 dbus_message_unref(msg
);
1512 * Method to emit a signal for a service discovery request.
1513 * The signal will carry station address, frequency, dialog token,
1514 * update indicator and it tlvs
1516 * @wpa_s: %wpa_supplicant network interface data
1517 * @sa: station addr (p2p i/f) of the peer
1518 * @dialog_token: service discovery request dialog token
1519 * @update_indic: service discovery request update indicator
1520 * @tlvs: service discovery request genrated byte array of tlvs
1521 * @tlvs_len: service discovery request tlvs length
1523 void wpas_dbus_signal_p2p_sd_request(struct wpa_supplicant
*wpa_s
,
1524 int freq
, const u8
*sa
, u8 dialog_token
,
1525 u16 update_indic
, const u8
*tlvs
,
1529 DBusMessageIter iter
, dict_iter
;
1530 struct wpas_dbus_priv
*iface
;
1531 char peer_obj_path
[WPAS_DBUS_OBJECT_PATH_MAX
], *path
;
1532 iface
= wpa_s
->global
->dbus
;
1534 /* Do nothing if the control interface is not turned on */
1538 msg
= dbus_message_new_signal(wpa_s
->dbus_new_path
,
1539 WPAS_DBUS_NEW_IFACE_P2PDEVICE
,
1540 "ServiceDiscoveryRequest");
1544 /* Check if this is a known peer */
1545 if (!p2p_peer_known(wpa_s
->global
->p2p
, sa
))
1548 os_snprintf(peer_obj_path
, WPAS_DBUS_OBJECT_PATH_MAX
,
1549 "%s/" WPAS_DBUS_NEW_P2P_PEERS_PART
"/"
1550 COMPACT_MACSTR
, wpa_s
->dbus_new_path
, MAC2STR(sa
));
1552 path
= peer_obj_path
;
1554 dbus_message_iter_init_append(msg
, &iter
);
1555 if (!wpa_dbus_dict_open_write(&iter
, &dict_iter
))
1559 if (!wpa_dbus_dict_append_object_path(&dict_iter
, "peer_object",
1561 !wpa_dbus_dict_append_int32(&dict_iter
, "frequency", freq
) ||
1562 !wpa_dbus_dict_append_int32(&dict_iter
, "dialog_token",
1564 !wpa_dbus_dict_append_uint16(&dict_iter
, "update_indicator",
1566 !wpa_dbus_dict_append_byte_array(&dict_iter
, "tlvs",
1567 (const char *) tlvs
,
1569 !wpa_dbus_dict_close_write(&iter
, &dict_iter
))
1572 dbus_connection_send(iface
->con
, msg
, NULL
);
1573 dbus_message_unref(msg
);
1576 wpa_printf(MSG_ERROR
, "dbus: Failed to construct signal");
1577 dbus_message_unref(msg
);
1583 * Method to emit a signal for a service discovery response.
1584 * The signal will carry station address, update indicator and it
1587 * @wpa_s: %wpa_supplicant network interface data
1588 * @sa: station addr (p2p i/f) of the peer
1589 * @update_indic: service discovery request update indicator
1590 * @tlvs: service discovery request genrated byte array of tlvs
1591 * @tlvs_len: service discovery request tlvs length
1593 void wpas_dbus_signal_p2p_sd_response(struct wpa_supplicant
*wpa_s
,
1594 const u8
*sa
, u16 update_indic
,
1595 const u8
*tlvs
, size_t tlvs_len
)
1598 DBusMessageIter iter
, dict_iter
;
1599 struct wpas_dbus_priv
*iface
;
1600 char peer_obj_path
[WPAS_DBUS_OBJECT_PATH_MAX
], *path
;
1601 iface
= wpa_s
->global
->dbus
;
1603 /* Do nothing if the control interface is not turned on */
1607 msg
= dbus_message_new_signal(wpa_s
->dbus_new_path
,
1608 WPAS_DBUS_NEW_IFACE_P2PDEVICE
,
1609 "ServiceDiscoveryResponse");
1613 /* Check if this is a known peer */
1614 if (!p2p_peer_known(wpa_s
->global
->p2p
, sa
))
1617 os_snprintf(peer_obj_path
, WPAS_DBUS_OBJECT_PATH_MAX
,
1618 "%s/" WPAS_DBUS_NEW_P2P_PEERS_PART
"/"
1619 COMPACT_MACSTR
, wpa_s
->dbus_new_path
, MAC2STR(sa
));
1621 path
= peer_obj_path
;
1623 dbus_message_iter_init_append(msg
, &iter
);
1624 if (!wpa_dbus_dict_open_write(&iter
, &dict_iter
))
1627 if (!wpa_dbus_dict_append_object_path(&dict_iter
, "peer_object",
1629 !wpa_dbus_dict_append_uint16(&dict_iter
, "update_indicator",
1631 !wpa_dbus_dict_append_byte_array(&dict_iter
, "tlvs",
1632 (const char *) tlvs
,
1634 !wpa_dbus_dict_close_write(&iter
, &dict_iter
))
1638 dbus_connection_send(iface
->con
, msg
, NULL
);
1639 dbus_message_unref(msg
);
1642 wpa_printf(MSG_ERROR
, "dbus: Failed to construct signal");
1643 dbus_message_unref(msg
);
1647 * wpas_dbus_signal_persistent_group - Send a persistent group related
1649 * @wpa_s: %wpa_supplicant network interface data
1650 * @id: new persistent group id
1651 * @sig_name: signal name - PersistentGroupAdded, PersistentGroupRemoved
1652 * @properties: determines if add second argument with object properties
1654 * Notify listeners about an event related to persistent groups.
1656 static void wpas_dbus_signal_persistent_group(struct wpa_supplicant
*wpa_s
,
1657 int id
, const char *sig_name
,
1660 struct wpas_dbus_priv
*iface
;
1662 DBusMessageIter iter
;
1663 char pgrp_obj_path
[WPAS_DBUS_OBJECT_PATH_MAX
], *path
;
1665 iface
= wpa_s
->global
->dbus
;
1667 /* Do nothing if the control interface is not turned on */
1671 os_snprintf(pgrp_obj_path
, WPAS_DBUS_OBJECT_PATH_MAX
,
1672 "%s/" WPAS_DBUS_NEW_PERSISTENT_GROUPS_PART
"/%u",
1673 wpa_s
->dbus_new_path
, id
);
1675 msg
= dbus_message_new_signal(wpa_s
->dbus_new_path
,
1676 WPAS_DBUS_NEW_IFACE_P2PDEVICE
,
1681 dbus_message_iter_init_append(msg
, &iter
);
1682 path
= pgrp_obj_path
;
1683 if (!dbus_message_iter_append_basic(&iter
, DBUS_TYPE_OBJECT_PATH
,
1688 if (!wpa_dbus_get_object_properties(
1689 iface
, pgrp_obj_path
,
1690 WPAS_DBUS_NEW_IFACE_PERSISTENT_GROUP
, &iter
))
1694 dbus_connection_send(iface
->con
, msg
, NULL
);
1696 dbus_message_unref(msg
);
1700 wpa_printf(MSG_ERROR
, "dbus: Failed to construct signal");
1701 dbus_message_unref(msg
);
1706 * wpas_dbus_signal_persistent_group_added - Send a persistent_group
1708 * @wpa_s: %wpa_supplicant network interface data
1709 * @id: new persistent group id
1711 * Notify listeners about addition of a new persistent group.
1713 static void wpas_dbus_signal_persistent_group_added(
1714 struct wpa_supplicant
*wpa_s
, int id
)
1716 wpas_dbus_signal_persistent_group(wpa_s
, id
, "PersistentGroupAdded",
1722 * wpas_dbus_signal_persistent_group_removed - Send a persistent_group
1724 * @wpa_s: %wpa_supplicant network interface data
1725 * @id: persistent group id
1727 * Notify listeners about removal of a persistent group.
1729 static void wpas_dbus_signal_persistent_group_removed(
1730 struct wpa_supplicant
*wpa_s
, int id
)
1732 wpas_dbus_signal_persistent_group(wpa_s
, id
, "PersistentGroupRemoved",
1738 * wpas_dbus_signal_p2p_wps_failed - Signals WpsFailed event
1739 * @wpa_s: %wpa_supplicant network interface data
1741 * Sends Event dbus signal with name "fail" and dictionary containing
1742 * "msg" field with fail message number (int32) as arguments
1744 void wpas_dbus_signal_p2p_wps_failed(struct wpa_supplicant
*wpa_s
,
1745 struct wps_event_fail
*fail
)
1749 DBusMessageIter iter
, dict_iter
;
1750 struct wpas_dbus_priv
*iface
;
1753 iface
= wpa_s
->global
->dbus
;
1755 /* Do nothing if the control interface is not turned on */
1759 msg
= dbus_message_new_signal(wpa_s
->dbus_new_path
,
1760 WPAS_DBUS_NEW_IFACE_P2PDEVICE
,
1765 dbus_message_iter_init_append(msg
, &iter
);
1767 if (!dbus_message_iter_append_basic(&iter
, DBUS_TYPE_STRING
, &key
) ||
1768 !wpa_dbus_dict_open_write(&iter
, &dict_iter
) ||
1769 !wpa_dbus_dict_append_int32(&dict_iter
, "msg", fail
->msg
) ||
1770 !wpa_dbus_dict_append_int16(&dict_iter
, "config_error",
1771 fail
->config_error
) ||
1772 !wpa_dbus_dict_close_write(&iter
, &dict_iter
))
1773 wpa_printf(MSG_ERROR
, "dbus: Failed to construct signal");
1775 dbus_connection_send(iface
->con
, msg
, NULL
);
1777 dbus_message_unref(msg
);
1780 #endif /*CONFIG_P2P*/
1784 * wpas_dbus_signal_prop_changed - Signals change of property
1785 * @wpa_s: %wpa_supplicant network interface data
1786 * @property: indicates which property has changed
1788 * Sends PropertyChanged signals with path, interface and arguments
1789 * depending on which property has changed.
1791 void wpas_dbus_signal_prop_changed(struct wpa_supplicant
*wpa_s
,
1792 enum wpas_dbus_prop property
)
1797 if (wpa_s
->dbus_new_path
== NULL
)
1798 return; /* Skip signal since D-Bus setup is not yet ready */
1802 case WPAS_DBUS_PROP_AP_SCAN
:
1805 case WPAS_DBUS_PROP_SCANNING
:
1808 case WPAS_DBUS_PROP_STATE
:
1811 case WPAS_DBUS_PROP_CURRENT_BSS
:
1812 prop
= "CurrentBSS";
1814 case WPAS_DBUS_PROP_CURRENT_NETWORK
:
1815 prop
= "CurrentNetwork";
1817 case WPAS_DBUS_PROP_BSSS
:
1820 case WPAS_DBUS_PROP_CURRENT_AUTH_MODE
:
1821 prop
= "CurrentAuthMode";
1823 case WPAS_DBUS_PROP_DISCONNECT_REASON
:
1824 prop
= "DisconnectReason";
1828 wpa_printf(MSG_ERROR
, "dbus: %s: Unknown Property value %d",
1829 __func__
, property
);
1833 wpa_dbus_mark_property_changed(wpa_s
->global
->dbus
,
1834 wpa_s
->dbus_new_path
,
1835 WPAS_DBUS_NEW_IFACE_INTERFACE
, prop
);
1837 wpa_dbus_flush_object_changed_properties(
1838 wpa_s
->global
->dbus
->con
, wpa_s
->dbus_new_path
);
1844 * wpas_dbus_bss_signal_prop_changed - Signals change of BSS property
1845 * @wpa_s: %wpa_supplicant network interface data
1846 * @property: indicates which property has changed
1847 * @id: unique BSS identifier
1849 * Sends PropertyChanged signals with path, interface, and arguments depending
1850 * on which property has changed.
1852 void wpas_dbus_bss_signal_prop_changed(struct wpa_supplicant
*wpa_s
,
1853 enum wpas_dbus_bss_prop property
,
1856 char path
[WPAS_DBUS_OBJECT_PATH_MAX
];
1860 case WPAS_DBUS_BSS_PROP_SIGNAL
:
1863 case WPAS_DBUS_BSS_PROP_FREQ
:
1866 case WPAS_DBUS_BSS_PROP_MODE
:
1869 case WPAS_DBUS_BSS_PROP_PRIVACY
:
1872 case WPAS_DBUS_BSS_PROP_RATES
:
1875 case WPAS_DBUS_BSS_PROP_WPA
:
1878 case WPAS_DBUS_BSS_PROP_RSN
:
1881 case WPAS_DBUS_BSS_PROP_WPS
:
1884 case WPAS_DBUS_BSS_PROP_IES
:
1888 wpa_printf(MSG_ERROR
, "dbus: %s: Unknown Property value %d",
1889 __func__
, property
);
1893 os_snprintf(path
, WPAS_DBUS_OBJECT_PATH_MAX
,
1894 "%s/" WPAS_DBUS_NEW_BSSIDS_PART
"/%u",
1895 wpa_s
->dbus_new_path
, id
);
1897 wpa_dbus_mark_property_changed(wpa_s
->global
->dbus
, path
,
1898 WPAS_DBUS_NEW_IFACE_BSS
, prop
);
1903 * wpas_dbus_signal_debug_level_changed - Signals change of debug param
1904 * @global: wpa_global structure
1906 * Sends PropertyChanged signals informing that debug level has changed.
1908 void wpas_dbus_signal_debug_level_changed(struct wpa_global
*global
)
1910 wpa_dbus_mark_property_changed(global
->dbus
, WPAS_DBUS_NEW_PATH
,
1911 WPAS_DBUS_NEW_INTERFACE
,
1917 * wpas_dbus_signal_debug_timestamp_changed - Signals change of debug param
1918 * @global: wpa_global structure
1920 * Sends PropertyChanged signals informing that debug timestamp has changed.
1922 void wpas_dbus_signal_debug_timestamp_changed(struct wpa_global
*global
)
1924 wpa_dbus_mark_property_changed(global
->dbus
, WPAS_DBUS_NEW_PATH
,
1925 WPAS_DBUS_NEW_INTERFACE
,
1931 * wpas_dbus_signal_debug_show_keys_changed - Signals change of debug param
1932 * @global: wpa_global structure
1934 * Sends PropertyChanged signals informing that debug show_keys has changed.
1936 void wpas_dbus_signal_debug_show_keys_changed(struct wpa_global
*global
)
1938 wpa_dbus_mark_property_changed(global
->dbus
, WPAS_DBUS_NEW_PATH
,
1939 WPAS_DBUS_NEW_INTERFACE
,
1944 static void wpas_dbus_register(struct wpa_dbus_object_desc
*obj_desc
,
1946 WPADBusArgumentFreeFunction priv_free
,
1947 const struct wpa_dbus_method_desc
*methods
,
1948 const struct wpa_dbus_property_desc
*properties
,
1949 const struct wpa_dbus_signal_desc
*signals
)
1953 obj_desc
->user_data
= priv
;
1954 obj_desc
->user_data_free_func
= priv_free
;
1955 obj_desc
->methods
= methods
;
1956 obj_desc
->properties
= properties
;
1957 obj_desc
->signals
= signals
;
1959 for (n
= 0; properties
&& properties
->dbus_property
; properties
++)
1962 obj_desc
->prop_changed_flags
= os_zalloc(n
);
1963 if (!obj_desc
->prop_changed_flags
)
1964 wpa_printf(MSG_DEBUG
, "dbus: %s: can't register handlers",
1969 static const struct wpa_dbus_method_desc wpas_dbus_global_methods
[] = {
1970 { "CreateInterface", WPAS_DBUS_NEW_INTERFACE
,
1971 (WPADBusMethodHandler
) &wpas_dbus_handler_create_interface
,
1973 { "args", "a{sv}", ARG_IN
},
1974 { "path", "o", ARG_OUT
},
1978 { "RemoveInterface", WPAS_DBUS_NEW_INTERFACE
,
1979 (WPADBusMethodHandler
) &wpas_dbus_handler_remove_interface
,
1981 { "path", "o", ARG_IN
},
1985 { "GetInterface", WPAS_DBUS_NEW_INTERFACE
,
1986 (WPADBusMethodHandler
) &wpas_dbus_handler_get_interface
,
1988 { "ifname", "s", ARG_IN
},
1989 { "path", "o", ARG_OUT
},
1993 { NULL
, NULL
, NULL
, { END_ARGS
} }
1996 static const struct wpa_dbus_property_desc wpas_dbus_global_properties
[] = {
1997 { "DebugLevel", WPAS_DBUS_NEW_INTERFACE
, "s",
1998 wpas_dbus_getter_debug_level
,
1999 wpas_dbus_setter_debug_level
2001 { "DebugTimestamp", WPAS_DBUS_NEW_INTERFACE
, "b",
2002 wpas_dbus_getter_debug_timestamp
,
2003 wpas_dbus_setter_debug_timestamp
2005 { "DebugShowKeys", WPAS_DBUS_NEW_INTERFACE
, "b",
2006 wpas_dbus_getter_debug_show_keys
,
2007 wpas_dbus_setter_debug_show_keys
2009 { "Interfaces", WPAS_DBUS_NEW_INTERFACE
, "ao",
2010 wpas_dbus_getter_interfaces
,
2013 { "EapMethods", WPAS_DBUS_NEW_INTERFACE
, "as",
2014 wpas_dbus_getter_eap_methods
,
2017 { "Capabilities", WPAS_DBUS_NEW_INTERFACE
, "as",
2018 wpas_dbus_getter_global_capabilities
,
2021 { NULL
, NULL
, NULL
, NULL
, NULL
}
2024 static const struct wpa_dbus_signal_desc wpas_dbus_global_signals
[] = {
2025 { "InterfaceAdded", WPAS_DBUS_NEW_INTERFACE
,
2027 { "path", "o", ARG_OUT
},
2028 { "properties", "a{sv}", ARG_OUT
},
2032 { "InterfaceRemoved", WPAS_DBUS_NEW_INTERFACE
,
2034 { "path", "o", ARG_OUT
},
2038 { "NetworkRequest", WPAS_DBUS_NEW_IFACE_INTERFACE
,
2040 { "path", "o", ARG_OUT
},
2041 { "field", "s", ARG_OUT
},
2042 { "text", "s", ARG_OUT
},
2046 /* Deprecated: use org.freedesktop.DBus.Properties.PropertiesChanged */
2047 { "PropertiesChanged", WPAS_DBUS_NEW_INTERFACE
,
2049 { "properties", "a{sv}", ARG_OUT
},
2053 { NULL
, NULL
, { END_ARGS
} }
2058 * wpas_dbus_ctrl_iface_init - Initialize dbus control interface
2059 * @global: Pointer to global data from wpa_supplicant_init()
2060 * Returns: 0 on success or -1 on failure
2062 * Initialize the dbus control interface for wpa_supplicantand and start
2063 * receiving commands from external programs over the bus.
2065 int wpas_dbus_ctrl_iface_init(struct wpas_dbus_priv
*priv
)
2067 struct wpa_dbus_object_desc
*obj_desc
;
2070 obj_desc
= os_zalloc(sizeof(struct wpa_dbus_object_desc
));
2072 wpa_printf(MSG_ERROR
, "Not enough memory "
2073 "to create object description");
2077 wpas_dbus_register(obj_desc
, priv
->global
, NULL
,
2078 wpas_dbus_global_methods
,
2079 wpas_dbus_global_properties
,
2080 wpas_dbus_global_signals
);
2082 wpa_printf(MSG_DEBUG
, "dbus: Register D-Bus object '%s'",
2083 WPAS_DBUS_NEW_PATH
);
2084 ret
= wpa_dbus_ctrl_iface_init(priv
, WPAS_DBUS_NEW_PATH
,
2085 WPAS_DBUS_NEW_SERVICE
,
2088 free_dbus_object_desc(obj_desc
);
2090 priv
->dbus_new_initialized
= 1;
2097 * wpas_dbus_ctrl_iface_deinit - Deinitialize dbus ctrl interface for
2099 * @iface: Pointer to dbus private data from wpas_dbus_init()
2101 * Deinitialize the dbus control interface that was initialized with
2102 * wpas_dbus_ctrl_iface_init().
2104 void wpas_dbus_ctrl_iface_deinit(struct wpas_dbus_priv
*iface
)
2106 if (!iface
->dbus_new_initialized
)
2108 wpa_printf(MSG_DEBUG
, "dbus: Unregister D-Bus object '%s'",
2109 WPAS_DBUS_NEW_PATH
);
2110 dbus_connection_unregister_object_path(iface
->con
,
2111 WPAS_DBUS_NEW_PATH
);
2115 static void wpa_dbus_free(void *ptr
)
2121 static const struct wpa_dbus_property_desc wpas_dbus_network_properties
[] = {
2122 { "Properties", WPAS_DBUS_NEW_IFACE_NETWORK
, "a{sv}",
2123 wpas_dbus_getter_network_properties
,
2124 wpas_dbus_setter_network_properties
2126 { "Enabled", WPAS_DBUS_NEW_IFACE_NETWORK
, "b",
2127 wpas_dbus_getter_enabled
,
2128 wpas_dbus_setter_enabled
2130 { NULL
, NULL
, NULL
, NULL
, NULL
}
2134 static const struct wpa_dbus_signal_desc wpas_dbus_network_signals
[] = {
2135 /* Deprecated: use org.freedesktop.DBus.Properties.PropertiesChanged */
2136 { "PropertiesChanged", WPAS_DBUS_NEW_IFACE_NETWORK
,
2138 { "properties", "a{sv}", ARG_OUT
},
2142 { NULL
, NULL
, { END_ARGS
} }
2147 * wpas_dbus_register_network - Register a configured network with dbus
2148 * @wpa_s: wpa_supplicant interface structure
2149 * @ssid: network configuration data
2150 * Returns: 0 on success, -1 on failure
2152 * Registers network representing object with dbus
2154 int wpas_dbus_register_network(struct wpa_supplicant
*wpa_s
,
2155 struct wpa_ssid
*ssid
)
2157 struct wpas_dbus_priv
*ctrl_iface
;
2158 struct wpa_dbus_object_desc
*obj_desc
;
2159 struct network_handler_args
*arg
;
2160 char net_obj_path
[WPAS_DBUS_OBJECT_PATH_MAX
];
2164 * If it is a persistent group register it as such.
2165 * This is to handle cases where an interface is being initialized
2166 * with a list of networks read from config.
2168 if (network_is_persistent_group(ssid
))
2169 return wpas_dbus_register_persistent_group(wpa_s
, ssid
);
2170 #endif /* CONFIG_P2P */
2172 /* Do nothing if the control interface is not turned on */
2173 if (wpa_s
== NULL
|| wpa_s
->global
== NULL
)
2175 ctrl_iface
= wpa_s
->global
->dbus
;
2176 if (ctrl_iface
== NULL
)
2179 os_snprintf(net_obj_path
, WPAS_DBUS_OBJECT_PATH_MAX
,
2180 "%s/" WPAS_DBUS_NEW_NETWORKS_PART
"/%u",
2181 wpa_s
->dbus_new_path
, ssid
->id
);
2183 wpa_printf(MSG_DEBUG
, "dbus: Register network object '%s'",
2185 obj_desc
= os_zalloc(sizeof(struct wpa_dbus_object_desc
));
2187 wpa_printf(MSG_ERROR
, "Not enough memory "
2188 "to create object description");
2192 /* allocate memory for handlers arguments */
2193 arg
= os_zalloc(sizeof(struct network_handler_args
));
2195 wpa_printf(MSG_ERROR
, "Not enough memory "
2196 "to create arguments for method");
2203 wpas_dbus_register(obj_desc
, arg
, wpa_dbus_free
, NULL
,
2204 wpas_dbus_network_properties
,
2205 wpas_dbus_network_signals
);
2207 if (wpa_dbus_register_object_per_iface(ctrl_iface
, net_obj_path
,
2208 wpa_s
->ifname
, obj_desc
))
2211 wpas_dbus_signal_network_added(wpa_s
, ssid
->id
);
2216 free_dbus_object_desc(obj_desc
);
2222 * wpas_dbus_unregister_network - Unregister a configured network from dbus
2223 * @wpa_s: wpa_supplicant interface structure
2225 * Returns: 0 on success, -1 on failure
2227 * Unregisters network representing object from dbus
2229 int wpas_dbus_unregister_network(struct wpa_supplicant
*wpa_s
, int nid
)
2231 struct wpas_dbus_priv
*ctrl_iface
;
2232 char net_obj_path
[WPAS_DBUS_OBJECT_PATH_MAX
];
2235 struct wpa_ssid
*ssid
;
2237 ssid
= wpa_config_get_network(wpa_s
->conf
, nid
);
2239 /* If it is a persistent group unregister it as such */
2240 if (ssid
&& network_is_persistent_group(ssid
))
2241 return wpas_dbus_unregister_persistent_group(wpa_s
, nid
);
2242 #endif /* CONFIG_P2P */
2244 /* Do nothing if the control interface is not turned on */
2245 if (wpa_s
->global
== NULL
|| wpa_s
->dbus_new_path
== NULL
)
2247 ctrl_iface
= wpa_s
->global
->dbus
;
2248 if (ctrl_iface
== NULL
)
2251 os_snprintf(net_obj_path
, WPAS_DBUS_OBJECT_PATH_MAX
,
2252 "%s/" WPAS_DBUS_NEW_NETWORKS_PART
"/%u",
2253 wpa_s
->dbus_new_path
, nid
);
2255 wpa_printf(MSG_DEBUG
, "dbus: Unregister network object '%s'",
2257 ret
= wpa_dbus_unregister_object_per_iface(ctrl_iface
, net_obj_path
);
2260 wpas_dbus_signal_network_removed(wpa_s
, nid
);
2266 static const struct wpa_dbus_property_desc wpas_dbus_bss_properties
[] = {
2267 { "SSID", WPAS_DBUS_NEW_IFACE_BSS
, "ay",
2268 wpas_dbus_getter_bss_ssid
,
2271 { "BSSID", WPAS_DBUS_NEW_IFACE_BSS
, "ay",
2272 wpas_dbus_getter_bss_bssid
,
2275 { "Privacy", WPAS_DBUS_NEW_IFACE_BSS
, "b",
2276 wpas_dbus_getter_bss_privacy
,
2279 { "Mode", WPAS_DBUS_NEW_IFACE_BSS
, "s",
2280 wpas_dbus_getter_bss_mode
,
2283 { "Signal", WPAS_DBUS_NEW_IFACE_BSS
, "n",
2284 wpas_dbus_getter_bss_signal
,
2287 { "Frequency", WPAS_DBUS_NEW_IFACE_BSS
, "q",
2288 wpas_dbus_getter_bss_frequency
,
2291 { "Rates", WPAS_DBUS_NEW_IFACE_BSS
, "au",
2292 wpas_dbus_getter_bss_rates
,
2295 { "WPA", WPAS_DBUS_NEW_IFACE_BSS
, "a{sv}",
2296 wpas_dbus_getter_bss_wpa
,
2299 { "RSN", WPAS_DBUS_NEW_IFACE_BSS
, "a{sv}",
2300 wpas_dbus_getter_bss_rsn
,
2303 { "WPS", WPAS_DBUS_NEW_IFACE_BSS
, "a{sv}",
2304 wpas_dbus_getter_bss_wps
,
2307 { "IEs", WPAS_DBUS_NEW_IFACE_BSS
, "ay",
2308 wpas_dbus_getter_bss_ies
,
2311 { NULL
, NULL
, NULL
, NULL
, NULL
}
2315 static const struct wpa_dbus_signal_desc wpas_dbus_bss_signals
[] = {
2316 /* Deprecated: use org.freedesktop.DBus.Properties.PropertiesChanged */
2317 { "PropertiesChanged", WPAS_DBUS_NEW_IFACE_BSS
,
2319 { "properties", "a{sv}", ARG_OUT
},
2323 { NULL
, NULL
, { END_ARGS
} }
2328 * wpas_dbus_unregister_bss - Unregister a scanned BSS from dbus
2329 * @wpa_s: wpa_supplicant interface structure
2330 * @bssid: scanned network bssid
2331 * @id: unique BSS identifier
2332 * Returns: 0 on success, -1 on failure
2334 * Unregisters BSS representing object from dbus
2336 int wpas_dbus_unregister_bss(struct wpa_supplicant
*wpa_s
,
2337 u8 bssid
[ETH_ALEN
], unsigned int id
)
2339 struct wpas_dbus_priv
*ctrl_iface
;
2340 char bss_obj_path
[WPAS_DBUS_OBJECT_PATH_MAX
];
2342 /* Do nothing if the control interface is not turned on */
2343 if (wpa_s
== NULL
|| wpa_s
->global
== NULL
)
2345 ctrl_iface
= wpa_s
->global
->dbus
;
2346 if (ctrl_iface
== NULL
)
2349 os_snprintf(bss_obj_path
, WPAS_DBUS_OBJECT_PATH_MAX
,
2350 "%s/" WPAS_DBUS_NEW_BSSIDS_PART
"/%u",
2351 wpa_s
->dbus_new_path
, id
);
2353 wpa_printf(MSG_DEBUG
, "dbus: Unregister BSS object '%s'",
2355 if (wpa_dbus_unregister_object_per_iface(ctrl_iface
, bss_obj_path
)) {
2356 wpa_printf(MSG_ERROR
, "dbus: Cannot unregister BSS object %s",
2361 wpas_dbus_signal_bss_removed(wpa_s
, bss_obj_path
);
2362 wpas_dbus_signal_prop_changed(wpa_s
, WPAS_DBUS_PROP_BSSS
);
2369 * wpas_dbus_register_bss - Register a scanned BSS with dbus
2370 * @wpa_s: wpa_supplicant interface structure
2371 * @bssid: scanned network bssid
2372 * @id: unique BSS identifier
2373 * Returns: 0 on success, -1 on failure
2375 * Registers BSS representing object with dbus
2377 int wpas_dbus_register_bss(struct wpa_supplicant
*wpa_s
,
2378 u8 bssid
[ETH_ALEN
], unsigned int id
)
2380 struct wpas_dbus_priv
*ctrl_iface
;
2381 struct wpa_dbus_object_desc
*obj_desc
;
2382 char bss_obj_path
[WPAS_DBUS_OBJECT_PATH_MAX
];
2383 struct bss_handler_args
*arg
;
2385 /* Do nothing if the control interface is not turned on */
2386 if (wpa_s
== NULL
|| wpa_s
->global
== NULL
)
2388 ctrl_iface
= wpa_s
->global
->dbus
;
2389 if (ctrl_iface
== NULL
)
2392 os_snprintf(bss_obj_path
, WPAS_DBUS_OBJECT_PATH_MAX
,
2393 "%s/" WPAS_DBUS_NEW_BSSIDS_PART
"/%u",
2394 wpa_s
->dbus_new_path
, id
);
2396 obj_desc
= os_zalloc(sizeof(struct wpa_dbus_object_desc
));
2398 wpa_printf(MSG_ERROR
, "Not enough memory "
2399 "to create object description");
2403 arg
= os_zalloc(sizeof(struct bss_handler_args
));
2405 wpa_printf(MSG_ERROR
, "Not enough memory "
2406 "to create arguments for handler");
2412 wpas_dbus_register(obj_desc
, arg
, wpa_dbus_free
, NULL
,
2413 wpas_dbus_bss_properties
,
2414 wpas_dbus_bss_signals
);
2416 wpa_printf(MSG_DEBUG
, "dbus: Register BSS object '%s'",
2418 if (wpa_dbus_register_object_per_iface(ctrl_iface
, bss_obj_path
,
2419 wpa_s
->ifname
, obj_desc
)) {
2420 wpa_printf(MSG_ERROR
,
2421 "Cannot register BSSID dbus object %s.",
2426 wpas_dbus_signal_bss_added(wpa_s
, bss_obj_path
);
2427 wpas_dbus_signal_prop_changed(wpa_s
, WPAS_DBUS_PROP_BSSS
);
2432 free_dbus_object_desc(obj_desc
);
2437 static const struct wpa_dbus_method_desc wpas_dbus_interface_methods
[] = {
2438 { "Scan", WPAS_DBUS_NEW_IFACE_INTERFACE
,
2439 (WPADBusMethodHandler
) &wpas_dbus_handler_scan
,
2441 { "args", "a{sv}", ARG_IN
},
2445 { "Disconnect", WPAS_DBUS_NEW_IFACE_INTERFACE
,
2446 (WPADBusMethodHandler
) &wpas_dbus_handler_disconnect
,
2451 { "AddNetwork", WPAS_DBUS_NEW_IFACE_INTERFACE
,
2452 (WPADBusMethodHandler
) &wpas_dbus_handler_add_network
,
2454 { "args", "a{sv}", ARG_IN
},
2455 { "path", "o", ARG_OUT
},
2459 { "Reassociate", WPAS_DBUS_NEW_IFACE_INTERFACE
,
2460 (WPADBusMethodHandler
) &wpas_dbus_handler_reassociate
,
2465 { "RemoveNetwork", WPAS_DBUS_NEW_IFACE_INTERFACE
,
2466 (WPADBusMethodHandler
) &wpas_dbus_handler_remove_network
,
2468 { "path", "o", ARG_IN
},
2472 { "RemoveAllNetworks", WPAS_DBUS_NEW_IFACE_INTERFACE
,
2473 (WPADBusMethodHandler
) &wpas_dbus_handler_remove_all_networks
,
2478 { "SelectNetwork", WPAS_DBUS_NEW_IFACE_INTERFACE
,
2479 (WPADBusMethodHandler
) &wpas_dbus_handler_select_network
,
2481 { "path", "o", ARG_IN
},
2485 { "NetworkReply", WPAS_DBUS_NEW_IFACE_INTERFACE
,
2486 (WPADBusMethodHandler
) &wpas_dbus_handler_network_reply
,
2488 { "path", "o", ARG_IN
},
2489 { "field", "s", ARG_IN
},
2490 { "value", "s", ARG_IN
},
2494 #ifndef CONFIG_NO_CONFIG_BLOBS
2495 { "AddBlob", WPAS_DBUS_NEW_IFACE_INTERFACE
,
2496 (WPADBusMethodHandler
) &wpas_dbus_handler_add_blob
,
2498 { "name", "s", ARG_IN
},
2499 { "data", "ay", ARG_IN
},
2503 { "GetBlob", WPAS_DBUS_NEW_IFACE_INTERFACE
,
2504 (WPADBusMethodHandler
) &wpas_dbus_handler_get_blob
,
2506 { "name", "s", ARG_IN
},
2507 { "data", "ay", ARG_OUT
},
2511 { "RemoveBlob", WPAS_DBUS_NEW_IFACE_INTERFACE
,
2512 (WPADBusMethodHandler
) &wpas_dbus_handler_remove_blob
,
2514 { "name", "s", ARG_IN
},
2518 #endif /* CONFIG_NO_CONFIG_BLOBS */
2519 { "SetPKCS11EngineAndModulePath", WPAS_DBUS_NEW_IFACE_INTERFACE
,
2520 (WPADBusMethodHandler
)
2521 &wpas_dbus_handler_set_pkcs11_engine_and_module_path
,
2523 { "pkcs11_engine_path", "s", ARG_IN
},
2524 { "pkcs11_module_path", "s", ARG_IN
},
2529 { "Start", WPAS_DBUS_NEW_IFACE_WPS
,
2530 (WPADBusMethodHandler
) &wpas_dbus_handler_wps_start
,
2532 { "args", "a{sv}", ARG_IN
},
2533 { "output", "a{sv}", ARG_OUT
},
2537 #endif /* CONFIG_WPS */
2539 { "Find", WPAS_DBUS_NEW_IFACE_P2PDEVICE
,
2540 (WPADBusMethodHandler
)wpas_dbus_handler_p2p_find
,
2542 { "args", "a{sv}", ARG_IN
},
2546 { "StopFind", WPAS_DBUS_NEW_IFACE_P2PDEVICE
,
2547 (WPADBusMethodHandler
)wpas_dbus_handler_p2p_stop_find
,
2552 { "Listen", WPAS_DBUS_NEW_IFACE_P2PDEVICE
,
2553 (WPADBusMethodHandler
)wpas_dbus_handler_p2p_listen
,
2555 { "timeout", "i", ARG_IN
},
2559 { "ExtendedListen", WPAS_DBUS_NEW_IFACE_P2PDEVICE
,
2560 (WPADBusMethodHandler
)wpas_dbus_handler_p2p_extendedlisten
,
2562 { "args", "a{sv}", ARG_IN
},
2566 { "PresenceRequest", WPAS_DBUS_NEW_IFACE_P2PDEVICE
,
2567 (WPADBusMethodHandler
)wpas_dbus_handler_p2p_presence_request
,
2569 { "args", "a{sv}", ARG_IN
},
2573 { "ProvisionDiscoveryRequest", WPAS_DBUS_NEW_IFACE_P2PDEVICE
,
2574 (WPADBusMethodHandler
)wpas_dbus_handler_p2p_prov_disc_req
,
2576 { "peer", "o", ARG_IN
},
2577 { "config_method", "s", ARG_IN
},
2581 { "Connect", WPAS_DBUS_NEW_IFACE_P2PDEVICE
,
2582 (WPADBusMethodHandler
)wpas_dbus_handler_p2p_connect
,
2584 { "args", "a{sv}", ARG_IN
},
2585 { "generated_pin", "s", ARG_OUT
},
2589 { "GroupAdd", WPAS_DBUS_NEW_IFACE_P2PDEVICE
,
2590 (WPADBusMethodHandler
)wpas_dbus_handler_p2p_group_add
,
2592 { "args", "a{sv}", ARG_IN
},
2596 { "Invite", WPAS_DBUS_NEW_IFACE_P2PDEVICE
,
2597 (WPADBusMethodHandler
)wpas_dbus_handler_p2p_invite
,
2599 { "args", "a{sv}", ARG_IN
},
2603 { "Disconnect", WPAS_DBUS_NEW_IFACE_P2PDEVICE
,
2604 (WPADBusMethodHandler
)wpas_dbus_handler_p2p_disconnect
,
2609 { "RejectPeer", WPAS_DBUS_NEW_IFACE_P2PDEVICE
,
2610 (WPADBusMethodHandler
)wpas_dbus_handler_p2p_rejectpeer
,
2612 { "peer", "o", ARG_IN
},
2616 { "Flush", WPAS_DBUS_NEW_IFACE_P2PDEVICE
,
2617 (WPADBusMethodHandler
)wpas_dbus_handler_p2p_flush
,
2622 { "AddService", WPAS_DBUS_NEW_IFACE_P2PDEVICE
,
2623 (WPADBusMethodHandler
)wpas_dbus_handler_p2p_add_service
,
2625 { "args", "a{sv}", ARG_IN
},
2629 { "DeleteService", WPAS_DBUS_NEW_IFACE_P2PDEVICE
,
2630 (WPADBusMethodHandler
)wpas_dbus_handler_p2p_delete_service
,
2632 { "args", "a{sv}", ARG_IN
},
2636 { "FlushService", WPAS_DBUS_NEW_IFACE_P2PDEVICE
,
2637 (WPADBusMethodHandler
)wpas_dbus_handler_p2p_flush_service
,
2642 { "ServiceDiscoveryRequest", WPAS_DBUS_NEW_IFACE_P2PDEVICE
,
2643 (WPADBusMethodHandler
)wpas_dbus_handler_p2p_service_sd_req
,
2645 { "args", "a{sv}", ARG_IN
},
2649 { "ServiceDiscoveryResponse", WPAS_DBUS_NEW_IFACE_P2PDEVICE
,
2650 (WPADBusMethodHandler
)wpas_dbus_handler_p2p_service_sd_res
,
2652 { "args", "a{sv}", ARG_IN
},
2656 { "ServiceDiscoveryCancelRequest", WPAS_DBUS_NEW_IFACE_P2PDEVICE
,
2657 (WPADBusMethodHandler
)wpas_dbus_handler_p2p_service_sd_cancel_req
,
2659 { "args", "t", ARG_IN
},
2663 { "ServiceUpdate", WPAS_DBUS_NEW_IFACE_P2PDEVICE
,
2664 (WPADBusMethodHandler
)wpas_dbus_handler_p2p_service_update
,
2669 { "ServiceDiscoveryExternal", WPAS_DBUS_NEW_IFACE_P2PDEVICE
,
2670 (WPADBusMethodHandler
)wpas_dbus_handler_p2p_serv_disc_external
,
2672 { "arg", "i", ARG_IN
},
2676 { "ServiceDiscoveryExternal", WPAS_DBUS_NEW_IFACE_P2PDEVICE
,
2677 (WPADBusMethodHandler
)wpas_dbus_handler_p2p_serv_disc_external
,
2679 { "arg", "i", ARG_IN
},
2683 { "AddPersistentGroup", WPAS_DBUS_NEW_IFACE_P2PDEVICE
,
2684 (WPADBusMethodHandler
) wpas_dbus_handler_add_persistent_group
,
2686 { "args", "a{sv}", ARG_IN
},
2687 { "path", "o", ARG_OUT
},
2691 { "RemovePersistentGroup", WPAS_DBUS_NEW_IFACE_P2PDEVICE
,
2692 (WPADBusMethodHandler
) wpas_dbus_handler_remove_persistent_group
,
2694 { "path", "o", ARG_IN
},
2698 { "RemoveAllPersistentGroups", WPAS_DBUS_NEW_IFACE_P2PDEVICE
,
2699 (WPADBusMethodHandler
)
2700 wpas_dbus_handler_remove_all_persistent_groups
,
2705 #endif /* CONFIG_P2P */
2706 { "FlushBSS", WPAS_DBUS_NEW_IFACE_INTERFACE
,
2707 (WPADBusMethodHandler
) &wpas_dbus_handler_flush_bss
,
2709 { "age", "u", ARG_IN
},
2714 { "SubscribeProbeReq", WPAS_DBUS_NEW_IFACE_INTERFACE
,
2715 (WPADBusMethodHandler
) wpas_dbus_handler_subscribe_preq
,
2720 { "UnsubscribeProbeReq", WPAS_DBUS_NEW_IFACE_INTERFACE
,
2721 (WPADBusMethodHandler
) wpas_dbus_handler_unsubscribe_preq
,
2726 #endif /* CONFIG_AP */
2727 { "EAPLogoff", WPAS_DBUS_NEW_IFACE_INTERFACE
,
2728 (WPADBusMethodHandler
) &wpas_dbus_handler_eap_logoff
,
2733 { "EAPLogon", WPAS_DBUS_NEW_IFACE_INTERFACE
,
2734 (WPADBusMethodHandler
) &wpas_dbus_handler_eap_logon
,
2739 #ifdef CONFIG_AUTOSCAN
2740 { "AutoScan", WPAS_DBUS_NEW_IFACE_INTERFACE
,
2741 (WPADBusMethodHandler
) &wpas_dbus_handler_autoscan
,
2743 { "arg", "s", ARG_IN
},
2747 #endif /* CONFIG_AUTOSCAN */
2749 { "TDLSDiscover", WPAS_DBUS_NEW_IFACE_INTERFACE
,
2750 (WPADBusMethodHandler
) wpas_dbus_handler_tdls_discover
,
2752 { "peer_address", "s", ARG_IN
},
2756 { "TDLSSetup", WPAS_DBUS_NEW_IFACE_INTERFACE
,
2757 (WPADBusMethodHandler
) wpas_dbus_handler_tdls_setup
,
2759 { "peer_address", "s", ARG_IN
},
2763 { "TDLSStatus", WPAS_DBUS_NEW_IFACE_INTERFACE
,
2764 (WPADBusMethodHandler
) wpas_dbus_handler_tdls_status
,
2766 { "peer_address", "s", ARG_IN
},
2767 { "status", "s", ARG_OUT
},
2771 { "TDLSTeardown", WPAS_DBUS_NEW_IFACE_INTERFACE
,
2772 (WPADBusMethodHandler
) wpas_dbus_handler_tdls_teardown
,
2774 { "peer_address", "s", ARG_IN
},
2778 #endif /* CONFIG_TDLS */
2779 { NULL
, NULL
, NULL
, { END_ARGS
} }
2782 static const struct wpa_dbus_property_desc wpas_dbus_interface_properties
[] = {
2783 { "Capabilities", WPAS_DBUS_NEW_IFACE_INTERFACE
, "a{sv}",
2784 wpas_dbus_getter_capabilities
,
2787 { "State", WPAS_DBUS_NEW_IFACE_INTERFACE
, "s",
2788 wpas_dbus_getter_state
,
2791 { "Scanning", WPAS_DBUS_NEW_IFACE_INTERFACE
, "b",
2792 wpas_dbus_getter_scanning
,
2795 { "ApScan", WPAS_DBUS_NEW_IFACE_INTERFACE
, "u",
2796 wpas_dbus_getter_ap_scan
,
2797 wpas_dbus_setter_ap_scan
2799 { "BSSExpireAge", WPAS_DBUS_NEW_IFACE_INTERFACE
, "u",
2800 wpas_dbus_getter_bss_expire_age
,
2801 wpas_dbus_setter_bss_expire_age
2803 { "BSSExpireCount", WPAS_DBUS_NEW_IFACE_INTERFACE
, "u",
2804 wpas_dbus_getter_bss_expire_count
,
2805 wpas_dbus_setter_bss_expire_count
2807 { "Country", WPAS_DBUS_NEW_IFACE_INTERFACE
, "s",
2808 wpas_dbus_getter_country
,
2809 wpas_dbus_setter_country
2811 { "Ifname", WPAS_DBUS_NEW_IFACE_INTERFACE
, "s",
2812 wpas_dbus_getter_ifname
,
2815 { "Driver", WPAS_DBUS_NEW_IFACE_INTERFACE
, "s",
2816 wpas_dbus_getter_driver
,
2819 { "BridgeIfname", WPAS_DBUS_NEW_IFACE_INTERFACE
, "s",
2820 wpas_dbus_getter_bridge_ifname
,
2823 { "CurrentBSS", WPAS_DBUS_NEW_IFACE_INTERFACE
, "o",
2824 wpas_dbus_getter_current_bss
,
2827 { "CurrentNetwork", WPAS_DBUS_NEW_IFACE_INTERFACE
, "o",
2828 wpas_dbus_getter_current_network
,
2831 { "CurrentAuthMode", WPAS_DBUS_NEW_IFACE_INTERFACE
, "s",
2832 wpas_dbus_getter_current_auth_mode
,
2835 { "Blobs", WPAS_DBUS_NEW_IFACE_INTERFACE
, "a{say}",
2836 wpas_dbus_getter_blobs
,
2839 { "BSSs", WPAS_DBUS_NEW_IFACE_INTERFACE
, "ao",
2840 wpas_dbus_getter_bsss
,
2843 { "Networks", WPAS_DBUS_NEW_IFACE_INTERFACE
, "ao",
2844 wpas_dbus_getter_networks
,
2847 { "FastReauth", WPAS_DBUS_NEW_IFACE_INTERFACE
, "b",
2848 wpas_dbus_getter_fast_reauth
,
2849 wpas_dbus_setter_fast_reauth
2851 { "ScanInterval", WPAS_DBUS_NEW_IFACE_INTERFACE
, "i",
2852 wpas_dbus_getter_scan_interval
,
2853 wpas_dbus_setter_scan_interval
2855 { "PKCS11EnginePath", WPAS_DBUS_NEW_IFACE_INTERFACE
, "s",
2856 wpas_dbus_getter_pkcs11_engine_path
,
2859 { "PKCS11ModulePath", WPAS_DBUS_NEW_IFACE_INTERFACE
, "s",
2860 wpas_dbus_getter_pkcs11_module_path
,
2864 { "ProcessCredentials", WPAS_DBUS_NEW_IFACE_WPS
, "b",
2865 wpas_dbus_getter_process_credentials
,
2866 wpas_dbus_setter_process_credentials
2868 #endif /* CONFIG_WPS */
2870 { "P2PDeviceConfig", WPAS_DBUS_NEW_IFACE_P2PDEVICE
, "a{sv}",
2871 wpas_dbus_getter_p2p_device_config
,
2872 wpas_dbus_setter_p2p_device_config
2874 { "Peers", WPAS_DBUS_NEW_IFACE_P2PDEVICE
, "ao",
2875 wpas_dbus_getter_p2p_peers
,
2878 { "Role", WPAS_DBUS_NEW_IFACE_P2PDEVICE
, "s",
2879 wpas_dbus_getter_p2p_role
,
2882 { "Group", WPAS_DBUS_NEW_IFACE_P2PDEVICE
, "o",
2883 wpas_dbus_getter_p2p_group
,
2886 { "PeerGO", WPAS_DBUS_NEW_IFACE_P2PDEVICE
, "o",
2887 wpas_dbus_getter_p2p_peergo
,
2890 { "PersistentGroups", WPAS_DBUS_NEW_IFACE_P2PDEVICE
, "ao",
2891 wpas_dbus_getter_persistent_groups
,
2894 #endif /* CONFIG_P2P */
2895 { "DisconnectReason", WPAS_DBUS_NEW_IFACE_INTERFACE
, "i",
2896 wpas_dbus_getter_disconnect_reason
,
2899 { NULL
, NULL
, NULL
, NULL
, NULL
}
2902 static const struct wpa_dbus_signal_desc wpas_dbus_interface_signals
[] = {
2903 { "ScanDone", WPAS_DBUS_NEW_IFACE_INTERFACE
,
2905 { "success", "b", ARG_OUT
},
2909 { "BSSAdded", WPAS_DBUS_NEW_IFACE_INTERFACE
,
2911 { "path", "o", ARG_OUT
},
2912 { "properties", "a{sv}", ARG_OUT
},
2916 { "BSSRemoved", WPAS_DBUS_NEW_IFACE_INTERFACE
,
2918 { "path", "o", ARG_OUT
},
2922 { "BlobAdded", WPAS_DBUS_NEW_IFACE_INTERFACE
,
2924 { "name", "s", ARG_OUT
},
2928 { "BlobRemoved", WPAS_DBUS_NEW_IFACE_INTERFACE
,
2930 { "name", "s", ARG_OUT
},
2934 { "NetworkAdded", WPAS_DBUS_NEW_IFACE_INTERFACE
,
2936 { "path", "o", ARG_OUT
},
2937 { "properties", "a{sv}", ARG_OUT
},
2941 { "NetworkRemoved", WPAS_DBUS_NEW_IFACE_INTERFACE
,
2943 { "path", "o", ARG_OUT
},
2947 { "NetworkSelected", WPAS_DBUS_NEW_IFACE_INTERFACE
,
2949 { "path", "o", ARG_OUT
},
2953 /* Deprecated: use org.freedesktop.DBus.Properties.PropertiesChanged */
2954 { "PropertiesChanged", WPAS_DBUS_NEW_IFACE_INTERFACE
,
2956 { "properties", "a{sv}", ARG_OUT
},
2961 { "Event", WPAS_DBUS_NEW_IFACE_WPS
,
2963 { "name", "s", ARG_OUT
},
2964 { "args", "a{sv}", ARG_OUT
},
2968 { "Credentials", WPAS_DBUS_NEW_IFACE_WPS
,
2970 { "credentials", "a{sv}", ARG_OUT
},
2974 /* Deprecated: use org.freedesktop.DBus.Properties.PropertiesChanged */
2975 { "PropertiesChanged", WPAS_DBUS_NEW_IFACE_WPS
,
2977 { "properties", "a{sv}", ARG_OUT
},
2981 #endif /* CONFIG_WPS */
2983 { "P2PStateChanged", WPAS_DBUS_NEW_IFACE_P2PDEVICE
,
2985 { "states", "a{ss}", ARG_OUT
},
2989 { "DeviceFound", WPAS_DBUS_NEW_IFACE_P2PDEVICE
,
2991 { "path", "o", ARG_OUT
},
2992 { "properties", "a{sv}", ARG_OUT
},
2996 { "DeviceLost", WPAS_DBUS_NEW_IFACE_P2PDEVICE
,
2998 { "path", "o", ARG_OUT
},
3002 { "ProvisionDiscoveryRequestDisplayPin", WPAS_DBUS_NEW_IFACE_P2PDEVICE
,
3004 { "peer_object", "o", ARG_OUT
},
3005 { "pin", "s", ARG_OUT
},
3009 { "ProvisionDiscoveryResponseDisplayPin", WPAS_DBUS_NEW_IFACE_P2PDEVICE
,
3011 { "peer_object", "o", ARG_OUT
},
3012 { "pin", "s", ARG_OUT
},
3016 { "ProvisionDiscoveryRequestEnterPin", WPAS_DBUS_NEW_IFACE_P2PDEVICE
,
3018 { "peer_object", "o", ARG_OUT
},
3022 { "ProvisionDiscoveryResponseEnterPin", WPAS_DBUS_NEW_IFACE_P2PDEVICE
,
3024 { "peer_object", "o", ARG_OUT
},
3028 { "ProvisionDiscoveryPBCRequest", WPAS_DBUS_NEW_IFACE_P2PDEVICE
,
3030 { "peer_object", "o", ARG_OUT
},
3034 { "ProvisionDiscoveryPBCResponse", WPAS_DBUS_NEW_IFACE_P2PDEVICE
,
3036 { "peer_object", "o", ARG_OUT
},
3040 { "ProvisionDiscoveryFailure", WPAS_DBUS_NEW_IFACE_P2PDEVICE
,
3042 { "peer_object", "o", ARG_OUT
},
3043 { "status", "i", ARG_OUT
},
3047 { "GroupStarted", WPAS_DBUS_NEW_IFACE_P2PDEVICE
,
3049 { "properties", "a{sv}", ARG_OUT
},
3053 { "GONegotiationSuccess", WPAS_DBUS_NEW_IFACE_P2PDEVICE
,
3058 { "GONegotiationFailure", WPAS_DBUS_NEW_IFACE_P2PDEVICE
,
3060 { "status", "i", ARG_OUT
},
3064 { "GONegotiationRequest", WPAS_DBUS_NEW_IFACE_P2PDEVICE
,
3066 { "path", "o", ARG_OUT
},
3067 { "dev_passwd_id", "i", ARG_OUT
},
3071 { "InvitationResult", WPAS_DBUS_NEW_IFACE_P2PDEVICE
,
3073 { "invite_result", "a{sv}", ARG_OUT
},
3077 { "GroupFinished", WPAS_DBUS_NEW_IFACE_P2PDEVICE
,
3079 { "ifname", "s", ARG_OUT
},
3080 { "role", "s", ARG_OUT
},
3084 { "ServiceDiscoveryRequest", WPAS_DBUS_NEW_IFACE_P2PDEVICE
,
3086 { "sd_request", "a{sv}", ARG_OUT
},
3090 { "ServiceDiscoveryResponse", WPAS_DBUS_NEW_IFACE_P2PDEVICE
,
3092 { "sd_response", "a{sv}", ARG_OUT
},
3096 { "PersistentGroupAdded", WPAS_DBUS_NEW_IFACE_P2PDEVICE
,
3098 { "path", "o", ARG_OUT
},
3099 { "properties", "a{sv}", ARG_OUT
},
3103 { "PersistentGroupRemoved", WPAS_DBUS_NEW_IFACE_P2PDEVICE
,
3105 { "path", "o", ARG_OUT
},
3109 { "WpsFailed", WPAS_DBUS_NEW_IFACE_P2PDEVICE
,
3111 { "name", "s", ARG_OUT
},
3112 { "args", "a{sv}", ARG_OUT
},
3116 #endif /* CONFIG_P2P */
3118 { "ProbeRequest", WPAS_DBUS_NEW_IFACE_INTERFACE
,
3120 { "args", "a{sv}", ARG_OUT
},
3124 #endif /* CONFIG_AP */
3125 { "Certification", WPAS_DBUS_NEW_IFACE_INTERFACE
,
3127 { "certification", "a{sv}", ARG_OUT
},
3131 { "EAP", WPAS_DBUS_NEW_IFACE_INTERFACE
,
3133 { "status", "s", ARG_OUT
},
3134 { "parameter", "s", ARG_OUT
},
3138 { "StaAuthorized", WPAS_DBUS_NEW_IFACE_INTERFACE
,
3140 { "name", "s", ARG_OUT
},
3144 { "StaDeauthorized", WPAS_DBUS_NEW_IFACE_INTERFACE
,
3146 { "name", "s", ARG_OUT
},
3150 { NULL
, NULL
, { END_ARGS
} }
3154 int wpas_dbus_register_interface(struct wpa_supplicant
*wpa_s
)
3157 struct wpa_dbus_object_desc
*obj_desc
= NULL
;
3158 struct wpas_dbus_priv
*ctrl_iface
= wpa_s
->global
->dbus
;
3161 /* Do nothing if the control interface is not turned on */
3162 if (ctrl_iface
== NULL
)
3165 /* Create and set the interface's object path */
3166 wpa_s
->dbus_new_path
= os_zalloc(WPAS_DBUS_OBJECT_PATH_MAX
);
3167 if (wpa_s
->dbus_new_path
== NULL
)
3169 next
= ctrl_iface
->next_objid
++;
3170 os_snprintf(wpa_s
->dbus_new_path
, WPAS_DBUS_OBJECT_PATH_MAX
,
3171 WPAS_DBUS_NEW_PATH_INTERFACES
"/%u",
3174 obj_desc
= os_zalloc(sizeof(struct wpa_dbus_object_desc
));
3176 wpa_printf(MSG_ERROR
, "Not enough memory "
3177 "to create object description");
3181 wpas_dbus_register(obj_desc
, wpa_s
, NULL
, wpas_dbus_interface_methods
,
3182 wpas_dbus_interface_properties
,
3183 wpas_dbus_interface_signals
);
3185 wpa_printf(MSG_DEBUG
, "dbus: Register interface object '%s'",
3186 wpa_s
->dbus_new_path
);
3187 if (wpa_dbus_register_object_per_iface(ctrl_iface
,
3188 wpa_s
->dbus_new_path
,
3189 wpa_s
->ifname
, obj_desc
))
3192 wpas_dbus_signal_interface_added(wpa_s
);
3197 os_free(wpa_s
->dbus_new_path
);
3198 wpa_s
->dbus_new_path
= NULL
;
3199 free_dbus_object_desc(obj_desc
);
3204 int wpas_dbus_unregister_interface(struct wpa_supplicant
*wpa_s
)
3206 struct wpas_dbus_priv
*ctrl_iface
;
3208 /* Do nothing if the control interface is not turned on */
3209 if (wpa_s
== NULL
|| wpa_s
->global
== NULL
)
3211 ctrl_iface
= wpa_s
->global
->dbus
;
3212 if (ctrl_iface
== NULL
)
3215 wpa_printf(MSG_DEBUG
, "dbus: Unregister interface object '%s'",
3216 wpa_s
->dbus_new_path
);
3219 if (wpa_s
->preq_notify_peer
) {
3220 wpas_dbus_unsubscribe_noc(ctrl_iface
);
3221 os_free(wpa_s
->preq_notify_peer
);
3222 wpa_s
->preq_notify_peer
= NULL
;
3224 #endif /* CONFIG_AP */
3226 if (wpa_dbus_unregister_object_per_iface(ctrl_iface
,
3227 wpa_s
->dbus_new_path
))
3230 wpas_dbus_signal_interface_removed(wpa_s
);
3232 os_free(wpa_s
->dbus_new_path
);
3233 wpa_s
->dbus_new_path
= NULL
;
3240 static const struct wpa_dbus_property_desc wpas_dbus_p2p_peer_properties
[] = {
3241 { "DeviceName", WPAS_DBUS_NEW_IFACE_P2P_PEER
, "s",
3242 wpas_dbus_getter_p2p_peer_device_name
,
3245 { "PrimaryDeviceType", WPAS_DBUS_NEW_IFACE_P2P_PEER
, "ay",
3246 wpas_dbus_getter_p2p_peer_primary_device_type
,
3249 { "config_method", WPAS_DBUS_NEW_IFACE_P2P_PEER
, "q",
3250 wpas_dbus_getter_p2p_peer_config_method
,
3253 { "level", WPAS_DBUS_NEW_IFACE_P2P_PEER
, "i",
3254 wpas_dbus_getter_p2p_peer_level
,
3257 { "devicecapability", WPAS_DBUS_NEW_IFACE_P2P_PEER
, "y",
3258 wpas_dbus_getter_p2p_peer_device_capability
,
3261 { "groupcapability", WPAS_DBUS_NEW_IFACE_P2P_PEER
, "y",
3262 wpas_dbus_getter_p2p_peer_group_capability
,
3265 { "SecondaryDeviceTypes", WPAS_DBUS_NEW_IFACE_P2P_PEER
, "aay",
3266 wpas_dbus_getter_p2p_peer_secondary_device_types
,
3269 { "VendorExtension", WPAS_DBUS_NEW_IFACE_P2P_PEER
, "aay",
3270 wpas_dbus_getter_p2p_peer_vendor_extension
,
3273 { "IEs", WPAS_DBUS_NEW_IFACE_P2P_PEER
, "ay",
3274 wpas_dbus_getter_p2p_peer_ies
,
3277 { NULL
, NULL
, NULL
, NULL
, NULL
}
3280 static const struct wpa_dbus_signal_desc wpas_dbus_p2p_peer_signals
[] = {
3282 { NULL
, NULL
, { END_ARGS
} }
3286 * wpas_dbus_signal_peer - Send a peer related event signal
3287 * @wpa_s: %wpa_supplicant network interface data
3288 * @dev: peer device object
3289 * @interface: name of the interface emitting this signal.
3290 * In case of peer objects, it would be emitted by either
3291 * the "interface object" or by "peer objects"
3292 * @sig_name: signal name - DeviceFound
3294 * Notify listeners about event related with newly found p2p peer device
3296 static void wpas_dbus_signal_peer(struct wpa_supplicant
*wpa_s
,
3297 const u8
*dev_addr
, const char *interface
,
3298 const char *sig_name
)
3300 struct wpas_dbus_priv
*iface
;
3302 DBusMessageIter iter
;
3303 char peer_obj_path
[WPAS_DBUS_OBJECT_PATH_MAX
], *path
;
3305 iface
= wpa_s
->global
->dbus
;
3307 /* Do nothing if the control interface is not turned on */
3311 os_snprintf(peer_obj_path
, WPAS_DBUS_OBJECT_PATH_MAX
,
3312 "%s/" WPAS_DBUS_NEW_P2P_PEERS_PART
"/" COMPACT_MACSTR
,
3313 wpa_s
->dbus_new_path
, MAC2STR(dev_addr
));
3315 msg
= dbus_message_new_signal(wpa_s
->dbus_new_path
, interface
,
3320 dbus_message_iter_init_append(msg
, &iter
);
3321 path
= peer_obj_path
;
3322 if (!dbus_message_iter_append_basic(&iter
, DBUS_TYPE_OBJECT_PATH
,
3326 dbus_connection_send(iface
->con
, msg
, NULL
);
3328 dbus_message_unref(msg
);
3332 wpa_printf(MSG_ERROR
, "dbus: Failed to construct signal");
3333 dbus_message_unref(msg
);
3338 * wpas_dbus_signal_peer_found - Send a peer found signal
3339 * @wpa_s: %wpa_supplicant network interface data
3340 * @dev: peer device object
3342 * Notify listeners about find a p2p peer device found
3344 void wpas_dbus_signal_peer_device_found(struct wpa_supplicant
*wpa_s
,
3347 wpas_dbus_signal_peer(wpa_s
, dev_addr
,
3348 WPAS_DBUS_NEW_IFACE_P2PDEVICE
,
3353 * wpas_dbus_signal_peer_lost - Send a peer lost signal
3354 * @wpa_s: %wpa_supplicant network interface data
3355 * @dev: peer device object
3357 * Notify listeners about lost a p2p peer device
3359 void wpas_dbus_signal_peer_device_lost(struct wpa_supplicant
*wpa_s
,
3362 wpas_dbus_signal_peer(wpa_s
, dev_addr
,
3363 WPAS_DBUS_NEW_IFACE_P2PDEVICE
,
3368 * wpas_dbus_register_peer - Register a discovered peer object with dbus
3369 * @wpa_s: wpa_supplicant interface structure
3370 * @ssid: network configuration data
3371 * Returns: 0 on success, -1 on failure
3373 * Registers network representing object with dbus
3375 int wpas_dbus_register_peer(struct wpa_supplicant
*wpa_s
, const u8
*dev_addr
)
3377 struct wpas_dbus_priv
*ctrl_iface
;
3378 struct wpa_dbus_object_desc
*obj_desc
;
3379 struct peer_handler_args
*arg
;
3380 char peer_obj_path
[WPAS_DBUS_OBJECT_PATH_MAX
];
3382 /* Do nothing if the control interface is not turned on */
3383 if (wpa_s
== NULL
|| wpa_s
->global
== NULL
)
3386 ctrl_iface
= wpa_s
->global
->dbus
;
3387 if (ctrl_iface
== NULL
)
3390 os_snprintf(peer_obj_path
, WPAS_DBUS_OBJECT_PATH_MAX
,
3391 "%s/" WPAS_DBUS_NEW_P2P_PEERS_PART
"/" COMPACT_MACSTR
,
3392 wpa_s
->dbus_new_path
, MAC2STR(dev_addr
));
3394 wpa_printf(MSG_INFO
, "dbus: Register peer object '%s'",
3396 obj_desc
= os_zalloc(sizeof(struct wpa_dbus_object_desc
));
3398 wpa_printf(MSG_ERROR
, "Not enough memory "
3399 "to create object description");
3403 /* allocate memory for handlers arguments */
3404 arg
= os_zalloc(sizeof(struct peer_handler_args
));
3406 wpa_printf(MSG_ERROR
, "Not enough memory "
3407 "to create arguments for method");
3412 os_memcpy(arg
->p2p_device_addr
, dev_addr
, ETH_ALEN
);
3414 wpas_dbus_register(obj_desc
, arg
, wpa_dbus_free
,
3416 wpas_dbus_p2p_peer_properties
,
3417 wpas_dbus_p2p_peer_signals
);
3419 if (wpa_dbus_register_object_per_iface(ctrl_iface
, peer_obj_path
,
3420 wpa_s
->ifname
, obj_desc
))
3426 free_dbus_object_desc(obj_desc
);
3431 * wpas_dbus_unregister_peer - Unregister a peer object with dbus
3432 * @wpa_s: wpa_supplicant interface structure
3433 * @dev_addr: p2p device addr
3434 * Returns: 0 on success, -1 on failure
3436 * Registers network representing object with dbus
3438 int wpas_dbus_unregister_peer(struct wpa_supplicant
*wpa_s
,
3441 struct wpas_dbus_priv
*ctrl_iface
;
3442 char peer_obj_path
[WPAS_DBUS_OBJECT_PATH_MAX
];
3445 /* Do nothing if the control interface is not turned on */
3446 if (wpa_s
== NULL
|| wpa_s
->global
== NULL
||
3447 wpa_s
->dbus_new_path
== NULL
)
3449 ctrl_iface
= wpa_s
->global
->dbus
;
3450 if (ctrl_iface
== NULL
)
3453 os_snprintf(peer_obj_path
, WPAS_DBUS_OBJECT_PATH_MAX
,
3454 "%s/" WPAS_DBUS_NEW_P2P_PEERS_PART
"/" COMPACT_MACSTR
,
3455 wpa_s
->dbus_new_path
, MAC2STR(dev_addr
));
3457 wpa_printf(MSG_INFO
, "dbus: Unregister peer object '%s'",
3459 ret
= wpa_dbus_unregister_object_per_iface(ctrl_iface
, peer_obj_path
);
3465 static const struct wpa_dbus_property_desc wpas_dbus_p2p_group_properties
[] = {
3466 { "Members", WPAS_DBUS_NEW_IFACE_P2P_GROUP
, "ao",
3467 wpas_dbus_getter_p2p_group_members
,
3470 { "Group", WPAS_DBUS_NEW_IFACE_P2P_GROUP
, "o",
3471 wpas_dbus_getter_p2p_group
,
3474 { "Role", WPAS_DBUS_NEW_IFACE_P2P_GROUP
, "s",
3475 wpas_dbus_getter_p2p_role
,
3478 { "SSID", WPAS_DBUS_NEW_IFACE_P2P_GROUP
, "ay",
3479 wpas_dbus_getter_p2p_group_ssid
,
3482 { "BSSID", WPAS_DBUS_NEW_IFACE_P2P_GROUP
, "ay",
3483 wpas_dbus_getter_p2p_group_bssid
,
3486 { "Frequency", WPAS_DBUS_NEW_IFACE_P2P_GROUP
, "q",
3487 wpas_dbus_getter_p2p_group_frequency
,
3490 { "Passphrase", WPAS_DBUS_NEW_IFACE_P2P_GROUP
, "s",
3491 wpas_dbus_getter_p2p_group_passphrase
,
3494 { "PSK", WPAS_DBUS_NEW_IFACE_P2P_GROUP
, "ay",
3495 wpas_dbus_getter_p2p_group_psk
,
3498 { "WPSVendorExtensions", WPAS_DBUS_NEW_IFACE_P2P_GROUP
, "aay",
3499 wpas_dbus_getter_p2p_group_vendor_ext
,
3500 wpas_dbus_setter_p2p_group_vendor_ext
3502 { NULL
, NULL
, NULL
, NULL
, NULL
}
3505 static const struct wpa_dbus_signal_desc wpas_dbus_p2p_group_signals
[] = {
3506 { "PeerJoined", WPAS_DBUS_NEW_IFACE_P2P_GROUP
,
3508 { "peer", "o", ARG_OUT
},
3512 { "PeerDisconnected", WPAS_DBUS_NEW_IFACE_P2P_GROUP
,
3514 { "peer", "o", ARG_OUT
},
3518 { NULL
, NULL
, { END_ARGS
} }
3522 * wpas_dbus_register_p2p_group - Register a p2p group object with dbus
3523 * @wpa_s: wpa_supplicant interface structure
3524 * @ssid: SSID struct
3525 * Returns: 0 on success, -1 on failure
3527 * Registers p2p group representing object with dbus
3529 void wpas_dbus_register_p2p_group(struct wpa_supplicant
*wpa_s
,
3530 struct wpa_ssid
*ssid
)
3532 struct wpas_dbus_priv
*ctrl_iface
;
3533 struct wpa_dbus_object_desc
*obj_desc
;
3534 char group_obj_path
[WPAS_DBUS_OBJECT_PATH_MAX
];
3536 /* Do nothing if the control interface is not turned on */
3537 if (wpa_s
== NULL
|| wpa_s
->global
== NULL
)
3540 ctrl_iface
= wpa_s
->global
->dbus
;
3541 if (ctrl_iface
== NULL
)
3544 if (wpa_s
->dbus_groupobj_path
) {
3545 wpa_printf(MSG_INFO
, "%s: Group object '%s' already exists",
3546 __func__
, wpa_s
->dbus_groupobj_path
);
3550 if (wpas_dbus_get_group_obj_path(wpa_s
, ssid
, group_obj_path
) < 0)
3553 wpa_s
->dbus_groupobj_path
= os_strdup(group_obj_path
);
3554 if (wpa_s
->dbus_groupobj_path
== NULL
)
3557 wpa_printf(MSG_INFO
, "dbus: Register group object '%s'",
3559 obj_desc
= os_zalloc(sizeof(struct wpa_dbus_object_desc
));
3561 wpa_printf(MSG_ERROR
, "Not enough memory "
3562 "to create object description");
3566 wpas_dbus_register(obj_desc
, wpa_s
, NULL
, NULL
,
3567 wpas_dbus_p2p_group_properties
,
3568 wpas_dbus_p2p_group_signals
);
3570 if (wpa_dbus_register_object_per_iface(ctrl_iface
, group_obj_path
,
3571 wpa_s
->ifname
, obj_desc
))
3577 if (wpa_s
->dbus_groupobj_path
) {
3578 os_free(wpa_s
->dbus_groupobj_path
);
3579 wpa_s
->dbus_groupobj_path
= NULL
;
3582 free_dbus_object_desc(obj_desc
);
3586 * wpas_dbus_unregister_p2p_group - Unregister a p2p group object from dbus
3587 * @wpa_s: wpa_supplicant interface structure
3588 * @ssid: network name of the p2p group started
3590 void wpas_dbus_unregister_p2p_group(struct wpa_supplicant
*wpa_s
,
3591 const struct wpa_ssid
*ssid
)
3593 struct wpas_dbus_priv
*ctrl_iface
;
3595 /* Do nothing if the control interface is not turned on */
3596 if (wpa_s
== NULL
|| wpa_s
->global
== NULL
)
3599 ctrl_iface
= wpa_s
->global
->dbus
;
3600 if (ctrl_iface
== NULL
)
3603 if (!wpa_s
->dbus_groupobj_path
) {
3604 wpa_printf(MSG_DEBUG
,
3605 "%s: Group object '%s' already unregistered",
3606 __func__
, wpa_s
->dbus_groupobj_path
);
3610 wpa_printf(MSG_DEBUG
, "dbus: Unregister group object '%s'",
3611 wpa_s
->dbus_groupobj_path
);
3613 wpa_dbus_unregister_object_per_iface(ctrl_iface
,
3614 wpa_s
->dbus_groupobj_path
);
3616 os_free(wpa_s
->dbus_groupobj_path
);
3617 wpa_s
->dbus_groupobj_path
= NULL
;
3620 static const struct wpa_dbus_property_desc
3621 wpas_dbus_p2p_groupmember_properties
[] = {
3622 { NULL
, NULL
, NULL
, NULL
, NULL
}
3626 * wpas_dbus_register_p2p_groupmember - Register a p2p groupmember
3628 * @wpa_s: wpa_supplicant interface structure
3629 * @p2p_if_addr: i/f addr of the device joining this group
3631 * Registers p2p groupmember representing object with dbus
3633 void wpas_dbus_register_p2p_groupmember(struct wpa_supplicant
*wpa_s
,
3634 const u8
*p2p_if_addr
)
3636 struct wpas_dbus_priv
*ctrl_iface
;
3637 struct wpa_dbus_object_desc
*obj_desc
= NULL
;
3638 struct groupmember_handler_args
*arg
;
3639 char groupmember_obj_path
[WPAS_DBUS_OBJECT_PATH_MAX
];
3641 /* Do nothing if the control interface is not turned on */
3642 if (wpa_s
== NULL
|| wpa_s
->global
== NULL
)
3645 ctrl_iface
= wpa_s
->global
->dbus
;
3646 if (ctrl_iface
== NULL
)
3649 if (!wpa_s
->dbus_groupobj_path
)
3652 os_snprintf(groupmember_obj_path
, WPAS_DBUS_OBJECT_PATH_MAX
,
3653 "%s/" WPAS_DBUS_NEW_P2P_GROUPMEMBERS_PART
"/" COMPACT_MACSTR
,
3654 wpa_s
->dbus_groupobj_path
, MAC2STR(p2p_if_addr
));
3656 obj_desc
= os_zalloc(sizeof(struct wpa_dbus_object_desc
));
3658 wpa_printf(MSG_ERROR
, "Not enough memory "
3659 "to create object description");
3663 /* allocate memory for handlers arguments */
3664 arg
= os_zalloc(sizeof(struct groupmember_handler_args
));
3666 wpa_printf(MSG_ERROR
, "Not enough memory "
3667 "to create arguments for method");
3672 os_memcpy(arg
->member_addr
, p2p_if_addr
, ETH_ALEN
);
3674 wpas_dbus_register(obj_desc
, arg
, wpa_dbus_free
, NULL
,
3675 wpas_dbus_p2p_groupmember_properties
, NULL
);
3677 if (wpa_dbus_register_object_per_iface(ctrl_iface
, groupmember_obj_path
,
3678 wpa_s
->ifname
, obj_desc
))
3681 wpa_printf(MSG_INFO
,
3682 "dbus: Registered group member object '%s' successfully",
3683 groupmember_obj_path
);
3687 free_dbus_object_desc(obj_desc
);
3691 * wpas_dbus_unregister_p2p_groupmember - Unregister a p2p groupmember
3693 * @wpa_s: wpa_supplicant interface structure
3694 * @p2p_if_addr: i/f addr of the device joining this group
3696 * Unregisters p2p groupmember representing object with dbus
3698 void wpas_dbus_unregister_p2p_groupmember(struct wpa_supplicant
*wpa_s
,
3699 const u8
*p2p_if_addr
)
3701 struct wpas_dbus_priv
*ctrl_iface
;
3702 char groupmember_obj_path
[WPAS_DBUS_OBJECT_PATH_MAX
];
3704 /* Do nothing if the control interface is not turned on */
3705 if (wpa_s
== NULL
|| wpa_s
->global
== NULL
)
3708 ctrl_iface
= wpa_s
->global
->dbus
;
3709 if (ctrl_iface
== NULL
)
3712 if (!wpa_s
->dbus_groupobj_path
)
3715 os_snprintf(groupmember_obj_path
, WPAS_DBUS_OBJECT_PATH_MAX
,
3716 "%s/" WPAS_DBUS_NEW_P2P_GROUPMEMBERS_PART
"/" COMPACT_MACSTR
,
3717 wpa_s
->dbus_groupobj_path
, MAC2STR(p2p_if_addr
));
3719 wpa_dbus_unregister_object_per_iface(ctrl_iface
, groupmember_obj_path
);
3723 static const struct wpa_dbus_property_desc
3724 wpas_dbus_persistent_group_properties
[] = {
3725 { "Properties", WPAS_DBUS_NEW_IFACE_PERSISTENT_GROUP
, "a{sv}",
3726 wpas_dbus_getter_persistent_group_properties
,
3727 wpas_dbus_setter_persistent_group_properties
3729 { NULL
, NULL
, NULL
, NULL
, NULL
}
3732 /* No signals intended for persistent group objects */
3735 * wpas_dbus_register_persistent_group - Register a configured(saved)
3736 * persistent group with dbus
3737 * @wpa_s: wpa_supplicant interface structure
3738 * @ssid: persistent group (still represented as a network within wpa)
3739 * configuration data
3740 * Returns: 0 on success, -1 on failure
3742 * Registers a persistent group representing object with dbus.
3744 int wpas_dbus_register_persistent_group(struct wpa_supplicant
*wpa_s
,
3745 struct wpa_ssid
*ssid
)
3747 struct wpas_dbus_priv
*ctrl_iface
;
3748 struct wpa_dbus_object_desc
*obj_desc
;
3749 struct network_handler_args
*arg
;
3750 char pgrp_obj_path
[WPAS_DBUS_OBJECT_PATH_MAX
];
3752 /* Do nothing if the control interface is not turned on */
3753 if (wpa_s
== NULL
|| wpa_s
->global
== NULL
)
3756 /* Make sure ssid is a persistent group */
3757 if (ssid
->disabled
!= 2 && !ssid
->p2p_persistent_group
)
3758 return -1; /* should we return w/o complaining? */
3760 ctrl_iface
= wpa_s
->global
->dbus
;
3761 if (ctrl_iface
== NULL
)
3765 * Intentionally not coming up with different numbering scheme
3766 * for persistent groups.
3768 os_snprintf(pgrp_obj_path
, WPAS_DBUS_OBJECT_PATH_MAX
,
3769 "%s/" WPAS_DBUS_NEW_PERSISTENT_GROUPS_PART
"/%u",
3770 wpa_s
->dbus_new_path
, ssid
->id
);
3772 wpa_printf(MSG_DEBUG
, "dbus: Register persistent group object '%s'",
3774 obj_desc
= os_zalloc(sizeof(struct wpa_dbus_object_desc
));
3776 wpa_printf(MSG_ERROR
, "dbus: Not enough memory to create "
3777 "object description");
3782 * Reusing the same context structure as that for networks
3783 * since these are represented using same data structure.
3785 /* allocate memory for handlers arguments */
3786 arg
= os_zalloc(sizeof(struct network_handler_args
));
3788 wpa_printf(MSG_ERROR
, "dbus: Not enough memory to create "
3789 "arguments for method");
3796 wpas_dbus_register(obj_desc
, arg
, wpa_dbus_free
, NULL
,
3797 wpas_dbus_persistent_group_properties
,
3800 if (wpa_dbus_register_object_per_iface(ctrl_iface
, pgrp_obj_path
,
3801 wpa_s
->ifname
, obj_desc
))
3804 wpas_dbus_signal_persistent_group_added(wpa_s
, ssid
->id
);
3809 free_dbus_object_desc(obj_desc
);
3815 * wpas_dbus_unregister_persistent_group - Unregister a persistent_group
3817 * @wpa_s: wpa_supplicant interface structure
3819 * Returns: 0 on success, -1 on failure
3821 * Unregisters persistent group representing object from dbus
3823 * NOTE: There is a slight issue with the semantics here. While the
3824 * implementation simply means the persistent group is unloaded from memory,
3825 * it should not get interpreted as the group is actually being erased/removed
3826 * from persistent storage as well.
3828 int wpas_dbus_unregister_persistent_group(struct wpa_supplicant
*wpa_s
,
3831 struct wpas_dbus_priv
*ctrl_iface
;
3832 char pgrp_obj_path
[WPAS_DBUS_OBJECT_PATH_MAX
];
3835 /* Do nothing if the control interface is not turned on */
3836 if (wpa_s
== NULL
|| wpa_s
->global
== NULL
||
3837 wpa_s
->dbus_new_path
== NULL
)
3839 ctrl_iface
= wpa_s
->global
->dbus
;
3840 if (ctrl_iface
== NULL
)
3843 os_snprintf(pgrp_obj_path
, WPAS_DBUS_OBJECT_PATH_MAX
,
3844 "%s/" WPAS_DBUS_NEW_PERSISTENT_GROUPS_PART
"/%u",
3845 wpa_s
->dbus_new_path
, nid
);
3847 wpa_printf(MSG_DEBUG
, "dbus: Unregister persistent group object '%s'",
3849 ret
= wpa_dbus_unregister_object_per_iface(ctrl_iface
, pgrp_obj_path
);
3852 wpas_dbus_signal_persistent_group_removed(wpa_s
, nid
);
3857 #endif /* CONFIG_P2P */