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 program is free software; you can redistribute it and/or modify
8 * it under the terms of the GNU General Public License version 2 as
9 * published by the Free Software Foundation.
11 * Alternatively, this software may be distributed under the terms of BSD
14 * See README and COPYING for more details.
20 #include "common/ieee802_11_defs.h"
22 #include "../config.h"
23 #include "../wpa_supplicant_i.h"
25 #include "../wpas_glue.h"
26 #include "dbus_new_helpers.h"
27 #include "dbus_dict_helpers.h"
29 #include "dbus_new_handlers.h"
30 #include "dbus_common_i.h"
31 #include "dbus_new_handlers_p2p.h"
36 * wpas_dbus_signal_interface - Send a interface related event signal
37 * @wpa_s: %wpa_supplicant network interface data
38 * @sig_name: signal name - InterfaceAdded or InterfaceRemoved
39 * @properties: Whether to add second argument with object properties
41 * Notify listeners about event related with interface
43 static void wpas_dbus_signal_interface(struct wpa_supplicant
*wpa_s
,
44 const char *sig_name
, int properties
)
46 struct wpas_dbus_priv
*iface
;
50 iface
= wpa_s
->global
->dbus
;
52 /* Do nothing if the control interface is not turned on */
56 msg
= dbus_message_new_signal(WPAS_DBUS_NEW_PATH
,
57 WPAS_DBUS_NEW_INTERFACE
, sig_name
);
61 dbus_message_iter_init_append(msg
, &iter
);
62 if (!dbus_message_iter_append_basic(&iter
, DBUS_TYPE_OBJECT_PATH
,
63 &wpa_s
->dbus_new_path
))
67 if (!wpa_dbus_get_object_properties(
68 iface
, wpa_s
->dbus_new_path
,
69 WPAS_DBUS_NEW_IFACE_INTERFACE
, &iter
))
73 dbus_connection_send(iface
->con
, msg
, NULL
);
74 dbus_message_unref(msg
);
78 wpa_printf(MSG_ERROR
, "dbus: Failed to construct signal");
79 dbus_message_unref(msg
);
84 * wpas_dbus_signal_interface_added - Send a interface created signal
85 * @wpa_s: %wpa_supplicant network interface data
87 * Notify listeners about creating new interface
89 static void wpas_dbus_signal_interface_added(struct wpa_supplicant
*wpa_s
)
91 wpas_dbus_signal_interface(wpa_s
, "InterfaceAdded", TRUE
);
96 * wpas_dbus_signal_interface_removed - Send a interface removed signal
97 * @wpa_s: %wpa_supplicant network interface data
99 * Notify listeners about removing interface
101 static void wpas_dbus_signal_interface_removed(struct wpa_supplicant
*wpa_s
)
103 wpas_dbus_signal_interface(wpa_s
, "InterfaceRemoved", FALSE
);
109 * wpas_dbus_signal_scan_done - send scan done signal
110 * @wpa_s: %wpa_supplicant network interface data
111 * @success: indicates if scanning succeed or failed
113 * Notify listeners about finishing a scan
115 void wpas_dbus_signal_scan_done(struct wpa_supplicant
*wpa_s
, int success
)
117 struct wpas_dbus_priv
*iface
;
121 iface
= wpa_s
->global
->dbus
;
123 /* Do nothing if the control interface is not turned on */
127 msg
= dbus_message_new_signal(wpa_s
->dbus_new_path
,
128 WPAS_DBUS_NEW_IFACE_INTERFACE
,
133 succ
= success
? TRUE
: FALSE
;
134 if (dbus_message_append_args(msg
, DBUS_TYPE_BOOLEAN
, &succ
,
136 dbus_connection_send(iface
->con
, msg
, NULL
);
138 wpa_printf(MSG_ERROR
, "dbus: Failed to construct signal");
139 dbus_message_unref(msg
);
144 * wpas_dbus_signal_blob - Send a BSS related event signal
145 * @wpa_s: %wpa_supplicant network interface data
146 * @bss_obj_path: BSS object path
147 * @sig_name: signal name - BSSAdded or BSSRemoved
148 * @properties: Whether to add second argument with object properties
150 * Notify listeners about event related with BSS
152 static void wpas_dbus_signal_bss(struct wpa_supplicant
*wpa_s
,
153 const char *bss_obj_path
,
154 const char *sig_name
, int properties
)
156 struct wpas_dbus_priv
*iface
;
158 DBusMessageIter iter
;
160 iface
= wpa_s
->global
->dbus
;
162 /* Do nothing if the control interface is not turned on */
166 msg
= dbus_message_new_signal(wpa_s
->dbus_new_path
,
167 WPAS_DBUS_NEW_IFACE_INTERFACE
,
172 dbus_message_iter_init_append(msg
, &iter
);
173 if (!dbus_message_iter_append_basic(&iter
, DBUS_TYPE_OBJECT_PATH
,
178 if (!wpa_dbus_get_object_properties(iface
, bss_obj_path
,
179 WPAS_DBUS_NEW_IFACE_BSS
,
184 dbus_connection_send(iface
->con
, msg
, NULL
);
185 dbus_message_unref(msg
);
189 wpa_printf(MSG_ERROR
, "dbus: Failed to construct signal");
190 dbus_message_unref(msg
);
195 * wpas_dbus_signal_bss_added - Send a BSS added signal
196 * @wpa_s: %wpa_supplicant network interface data
197 * @bss_obj_path: new BSS object path
199 * Notify listeners about adding new BSS
201 static void wpas_dbus_signal_bss_added(struct wpa_supplicant
*wpa_s
,
202 const char *bss_obj_path
)
204 wpas_dbus_signal_bss(wpa_s
, bss_obj_path
, "BSSAdded", TRUE
);
209 * wpas_dbus_signal_bss_removed - Send a BSS removed signal
210 * @wpa_s: %wpa_supplicant network interface data
211 * @bss_obj_path: BSS object path
213 * Notify listeners about removing BSS
215 static void wpas_dbus_signal_bss_removed(struct wpa_supplicant
*wpa_s
,
216 const char *bss_obj_path
)
218 wpas_dbus_signal_bss(wpa_s
, bss_obj_path
, "BSSRemoved", FALSE
);
223 * wpas_dbus_signal_blob - Send a blob related event signal
224 * @wpa_s: %wpa_supplicant network interface data
226 * @sig_name: signal name - BlobAdded or BlobRemoved
228 * Notify listeners about event related with blob
230 static void wpas_dbus_signal_blob(struct wpa_supplicant
*wpa_s
,
231 const char *name
, const char *sig_name
)
233 struct wpas_dbus_priv
*iface
;
236 iface
= wpa_s
->global
->dbus
;
238 /* Do nothing if the control interface is not turned on */
242 msg
= dbus_message_new_signal(wpa_s
->dbus_new_path
,
243 WPAS_DBUS_NEW_IFACE_INTERFACE
,
248 if (dbus_message_append_args(msg
, DBUS_TYPE_STRING
, &name
,
250 dbus_connection_send(iface
->con
, msg
, NULL
);
252 wpa_printf(MSG_ERROR
, "dbus: Failed to construct signal");
253 dbus_message_unref(msg
);
258 * wpas_dbus_signal_blob_added - Send a blob added signal
259 * @wpa_s: %wpa_supplicant network interface data
262 * Notify listeners about adding a new blob
264 void wpas_dbus_signal_blob_added(struct wpa_supplicant
*wpa_s
,
267 wpas_dbus_signal_blob(wpa_s
, name
, "BlobAdded");
272 * wpas_dbus_signal_blob_removed - Send a blob removed signal
273 * @wpa_s: %wpa_supplicant network interface data
276 * Notify listeners about removing blob
278 void wpas_dbus_signal_blob_removed(struct wpa_supplicant
*wpa_s
,
281 wpas_dbus_signal_blob(wpa_s
, name
, "BlobRemoved");
286 * wpas_dbus_signal_network - Send a network related event signal
287 * @wpa_s: %wpa_supplicant network interface data
288 * @id: new network id
289 * @sig_name: signal name - NetworkAdded, NetworkRemoved or NetworkSelected
290 * @properties: determines if add second argument with object properties
292 * Notify listeners about event related with configured network
294 static void wpas_dbus_signal_network(struct wpa_supplicant
*wpa_s
,
295 int id
, const char *sig_name
,
298 struct wpas_dbus_priv
*iface
;
300 DBusMessageIter iter
;
301 char net_obj_path
[WPAS_DBUS_OBJECT_PATH_MAX
], *path
;
303 iface
= wpa_s
->global
->dbus
;
305 /* Do nothing if the control interface is not turned on */
309 os_snprintf(net_obj_path
, WPAS_DBUS_OBJECT_PATH_MAX
,
310 "%s/" WPAS_DBUS_NEW_NETWORKS_PART
"/%u",
311 wpa_s
->dbus_new_path
, id
);
313 msg
= dbus_message_new_signal(wpa_s
->dbus_new_path
,
314 WPAS_DBUS_NEW_IFACE_INTERFACE
,
319 dbus_message_iter_init_append(msg
, &iter
);
321 if (!dbus_message_iter_append_basic(&iter
, DBUS_TYPE_OBJECT_PATH
,
326 if (!wpa_dbus_get_object_properties(
327 iface
, net_obj_path
, WPAS_DBUS_NEW_IFACE_NETWORK
,
332 dbus_connection_send(iface
->con
, msg
, NULL
);
334 dbus_message_unref(msg
);
338 wpa_printf(MSG_ERROR
, "dbus: Failed to construct signal");
339 dbus_message_unref(msg
);
344 * wpas_dbus_signal_network_added - Send a network added signal
345 * @wpa_s: %wpa_supplicant network interface data
346 * @id: new network id
348 * Notify listeners about adding new network
350 static void wpas_dbus_signal_network_added(struct wpa_supplicant
*wpa_s
,
353 wpas_dbus_signal_network(wpa_s
, id
, "NetworkAdded", TRUE
);
358 * wpas_dbus_signal_network_removed - Send a network removed signal
359 * @wpa_s: %wpa_supplicant network interface data
362 * Notify listeners about removing a network
364 static void wpas_dbus_signal_network_removed(struct wpa_supplicant
*wpa_s
,
367 wpas_dbus_signal_network(wpa_s
, id
, "NetworkRemoved", FALSE
);
372 * wpas_dbus_signal_network_selected - Send a network selected signal
373 * @wpa_s: %wpa_supplicant network interface data
376 * Notify listeners about selecting a network
378 void wpas_dbus_signal_network_selected(struct wpa_supplicant
*wpa_s
, int id
)
380 wpas_dbus_signal_network(wpa_s
, id
, "NetworkSelected", FALSE
);
385 * wpas_dbus_signal_network_request - Indicate that additional information
386 * (EAP password, etc.) is required to complete the association to this SSID
387 * @wpa_s: %wpa_supplicant network interface data
388 * @rtype: The specific additional information required
389 * @default_text: Optional description of required information
391 * Request additional information or passwords to complete an association
394 void wpas_dbus_signal_network_request(struct wpa_supplicant
*wpa_s
,
395 struct wpa_ssid
*ssid
,
396 enum wpa_ctrl_req_type rtype
,
397 const char *default_txt
)
399 struct wpas_dbus_priv
*iface
;
401 DBusMessageIter iter
;
402 char net_obj_path
[WPAS_DBUS_OBJECT_PATH_MAX
];
403 const char *field
, *txt
= NULL
, *net_ptr
;
405 iface
= wpa_s
->global
->dbus
;
407 /* Do nothing if the control interface is not turned on */
411 field
= wpa_supplicant_ctrl_req_to_string(rtype
, default_txt
, &txt
);
415 msg
= dbus_message_new_signal(wpa_s
->dbus_new_path
,
416 WPAS_DBUS_NEW_IFACE_INTERFACE
,
421 os_snprintf(net_obj_path
, WPAS_DBUS_OBJECT_PATH_MAX
,
422 "%s/" WPAS_DBUS_NEW_NETWORKS_PART
"/%u",
423 wpa_s
->dbus_new_path
, ssid
->id
);
424 net_ptr
= &net_obj_path
[0];
426 dbus_message_iter_init_append(msg
, &iter
);
427 if (!dbus_message_iter_append_basic(&iter
, DBUS_TYPE_OBJECT_PATH
,
430 if (!dbus_message_iter_append_basic(&iter
, DBUS_TYPE_STRING
, &field
))
432 if (!dbus_message_iter_append_basic(&iter
, DBUS_TYPE_STRING
, &txt
))
435 dbus_connection_send(iface
->con
, msg
, NULL
);
436 dbus_message_unref(msg
);
440 wpa_printf(MSG_ERROR
, "dbus: Failed to construct signal");
441 dbus_message_unref(msg
);
446 * wpas_dbus_signal_network_enabled_changed - Signals Enabled property changes
447 * @wpa_s: %wpa_supplicant network interface data
448 * @ssid: configured network which Enabled property has changed
450 * Sends PropertyChanged signals containing new value of Enabled property
451 * for specified network
453 void wpas_dbus_signal_network_enabled_changed(struct wpa_supplicant
*wpa_s
,
454 struct wpa_ssid
*ssid
)
457 char path
[WPAS_DBUS_OBJECT_PATH_MAX
];
458 os_snprintf(path
, WPAS_DBUS_OBJECT_PATH_MAX
,
459 "%s/" WPAS_DBUS_NEW_NETWORKS_PART
"/%d",
460 wpa_s
->dbus_new_path
, ssid
->id
);
462 wpa_dbus_mark_property_changed(wpa_s
->global
->dbus
, path
,
463 WPAS_DBUS_NEW_IFACE_NETWORK
, "Enabled");
470 * wpas_dbus_signal_wps_event_success - Signals Success WPS event
471 * @wpa_s: %wpa_supplicant network interface data
473 * Sends Event dbus signal with name "success" and empty dict as arguments
475 void wpas_dbus_signal_wps_event_success(struct wpa_supplicant
*wpa_s
)
479 DBusMessageIter iter
, dict_iter
;
480 struct wpas_dbus_priv
*iface
;
481 char *key
= "success";
483 iface
= wpa_s
->global
->dbus
;
485 /* Do nothing if the control interface is not turned on */
489 msg
= dbus_message_new_signal(wpa_s
->dbus_new_path
,
490 WPAS_DBUS_NEW_IFACE_WPS
, "Event");
494 dbus_message_iter_init_append(msg
, &iter
);
496 if (!dbus_message_iter_append_basic(&iter
, DBUS_TYPE_STRING
, &key
) ||
497 !wpa_dbus_dict_open_write(&iter
, &dict_iter
) ||
498 !wpa_dbus_dict_close_write(&iter
, &dict_iter
))
499 wpa_printf(MSG_ERROR
, "dbus: Failed to construct signal");
501 dbus_connection_send(iface
->con
, msg
, NULL
);
503 dbus_message_unref(msg
);
508 * wpas_dbus_signal_wps_event_fail - Signals Fail WPS event
509 * @wpa_s: %wpa_supplicant network interface data
511 * Sends Event dbus signal with name "fail" and dictionary containing
512 * "msg field with fail message number (int32) as arguments
514 void wpas_dbus_signal_wps_event_fail(struct wpa_supplicant
*wpa_s
,
515 struct wps_event_fail
*fail
)
519 DBusMessageIter iter
, dict_iter
;
520 struct wpas_dbus_priv
*iface
;
523 iface
= wpa_s
->global
->dbus
;
525 /* Do nothing if the control interface is not turned on */
529 msg
= dbus_message_new_signal(wpa_s
->dbus_new_path
,
530 WPAS_DBUS_NEW_IFACE_WPS
, "Event");
534 dbus_message_iter_init_append(msg
, &iter
);
536 if (!dbus_message_iter_append_basic(&iter
, DBUS_TYPE_STRING
, &key
) ||
537 !wpa_dbus_dict_open_write(&iter
, &dict_iter
) ||
538 !wpa_dbus_dict_append_int32(&dict_iter
, "msg", fail
->msg
) ||
539 !wpa_dbus_dict_close_write(&iter
, &dict_iter
))
540 wpa_printf(MSG_ERROR
, "dbus: Failed to construct signal");
542 dbus_connection_send(iface
->con
, msg
, NULL
);
544 dbus_message_unref(msg
);
549 * wpas_dbus_signal_wps_event_m2d - Signals M2D WPS event
550 * @wpa_s: %wpa_supplicant network interface data
552 * Sends Event dbus signal with name "m2d" and dictionary containing
553 * fields of wps_event_m2d structure.
555 void wpas_dbus_signal_wps_event_m2d(struct wpa_supplicant
*wpa_s
,
556 struct wps_event_m2d
*m2d
)
560 DBusMessageIter iter
, dict_iter
;
561 struct wpas_dbus_priv
*iface
;
564 iface
= wpa_s
->global
->dbus
;
566 /* Do nothing if the control interface is not turned on */
570 msg
= dbus_message_new_signal(wpa_s
->dbus_new_path
,
571 WPAS_DBUS_NEW_IFACE_WPS
, "Event");
575 dbus_message_iter_init_append(msg
, &iter
);
577 if (!dbus_message_iter_append_basic(&iter
, DBUS_TYPE_STRING
, &key
) ||
578 !wpa_dbus_dict_open_write(&iter
, &dict_iter
) ||
579 !wpa_dbus_dict_append_uint16(&dict_iter
, "config_methods",
580 m2d
->config_methods
) ||
581 !wpa_dbus_dict_append_byte_array(&dict_iter
, "manufacturer",
582 (const char *) m2d
->manufacturer
,
583 m2d
->manufacturer_len
) ||
584 !wpa_dbus_dict_append_byte_array(&dict_iter
, "model_name",
585 (const char *) m2d
->model_name
,
586 m2d
->model_name_len
) ||
587 !wpa_dbus_dict_append_byte_array(&dict_iter
, "model_number",
588 (const char *) m2d
->model_number
,
589 m2d
->model_number_len
) ||
590 !wpa_dbus_dict_append_byte_array(&dict_iter
, "serial_number",
593 m2d
->serial_number_len
) ||
594 !wpa_dbus_dict_append_byte_array(&dict_iter
, "dev_name",
595 (const char *) m2d
->dev_name
,
596 m2d
->dev_name_len
) ||
597 !wpa_dbus_dict_append_byte_array(&dict_iter
, "primary_dev_type",
599 m2d
->primary_dev_type
, 8) ||
600 !wpa_dbus_dict_append_uint16(&dict_iter
, "config_error",
601 m2d
->config_error
) ||
602 !wpa_dbus_dict_append_uint16(&dict_iter
, "dev_password_id",
603 m2d
->dev_password_id
) ||
604 !wpa_dbus_dict_close_write(&iter
, &dict_iter
))
605 wpa_printf(MSG_ERROR
, "dbus: Failed to construct signal");
607 dbus_connection_send(iface
->con
, msg
, NULL
);
609 dbus_message_unref(msg
);
614 * wpas_dbus_signal_wps_cred - Signals new credentials
615 * @wpa_s: %wpa_supplicant network interface data
617 * Sends signal with credentials in directory argument
619 void wpas_dbus_signal_wps_cred(struct wpa_supplicant
*wpa_s
,
620 const struct wps_credential
*cred
)
623 DBusMessageIter iter
, dict_iter
;
624 struct wpas_dbus_priv
*iface
;
625 char *auth_type
[6]; /* we have six possible authorization types */
627 char *encr_type
[4]; /* we have four possible encryption types */
630 iface
= wpa_s
->global
->dbus
;
632 /* Do nothing if the control interface is not turned on */
636 msg
= dbus_message_new_signal(wpa_s
->dbus_new_path
,
637 WPAS_DBUS_NEW_IFACE_WPS
,
642 dbus_message_iter_init_append(msg
, &iter
);
643 if (!wpa_dbus_dict_open_write(&iter
, &dict_iter
))
646 if (cred
->auth_type
& WPS_AUTH_OPEN
)
647 auth_type
[at_num
++] = "open";
648 if (cred
->auth_type
& WPS_AUTH_WPAPSK
)
649 auth_type
[at_num
++] = "wpa-psk";
650 if (cred
->auth_type
& WPS_AUTH_SHARED
)
651 auth_type
[at_num
++] = "shared";
652 if (cred
->auth_type
& WPS_AUTH_WPA
)
653 auth_type
[at_num
++] = "wpa-eap";
654 if (cred
->auth_type
& WPS_AUTH_WPA2
)
655 auth_type
[at_num
++] = "wpa2-eap";
656 if (cred
->auth_type
& WPS_AUTH_WPA2PSK
)
657 auth_type
[at_num
++] =
660 if (cred
->encr_type
& WPS_ENCR_NONE
)
661 encr_type
[et_num
++] = "none";
662 if (cred
->encr_type
& WPS_ENCR_WEP
)
663 encr_type
[et_num
++] = "wep";
664 if (cred
->encr_type
& WPS_ENCR_TKIP
)
665 encr_type
[et_num
++] = "tkip";
666 if (cred
->encr_type
& WPS_ENCR_AES
)
667 encr_type
[et_num
++] = "aes";
669 if (wpa_s
->current_ssid
) {
670 if (!wpa_dbus_dict_append_byte_array(
672 (const char *) wpa_s
->current_ssid
->bssid
,
677 if (!wpa_dbus_dict_append_byte_array(&dict_iter
, "SSID",
678 (const char *) cred
->ssid
,
680 !wpa_dbus_dict_append_string_array(&dict_iter
, "AuthType",
681 (const char **) auth_type
,
683 !wpa_dbus_dict_append_string_array(&dict_iter
, "EncrType",
684 (const char **) encr_type
,
686 !wpa_dbus_dict_append_byte_array(&dict_iter
, "Key",
687 (const char *) cred
->key
,
689 !wpa_dbus_dict_append_uint32(&dict_iter
, "KeyIndex",
691 !wpa_dbus_dict_close_write(&iter
, &dict_iter
))
694 dbus_connection_send(iface
->con
, msg
, NULL
);
697 dbus_message_unref(msg
);
700 #endif /* CONFIG_WPS */
702 void wpas_dbus_signal_certification(struct wpa_supplicant
*wpa_s
,
703 int depth
, const char *subject
,
704 const char *cert_hash
,
705 const struct wpabuf
*cert
)
707 struct wpas_dbus_priv
*iface
;
709 DBusMessageIter iter
, dict_iter
;
711 iface
= wpa_s
->global
->dbus
;
713 /* Do nothing if the control interface is not turned on */
717 msg
= dbus_message_new_signal(wpa_s
->dbus_new_path
,
718 WPAS_DBUS_NEW_IFACE_INTERFACE
,
723 dbus_message_iter_init_append(msg
, &iter
);
724 if (!wpa_dbus_dict_open_write(&iter
, &dict_iter
))
727 if (!wpa_dbus_dict_append_uint32(&dict_iter
, "depth", depth
) ||
728 !wpa_dbus_dict_append_string(&dict_iter
, "subject", subject
))
732 !wpa_dbus_dict_append_string(&dict_iter
, "cert_hash", cert_hash
))
736 !wpa_dbus_dict_append_byte_array(&dict_iter
, "cert",
741 if (!wpa_dbus_dict_close_write(&iter
, &dict_iter
))
744 dbus_connection_send(iface
->con
, msg
, NULL
);
747 dbus_message_unref(msg
);
753 * wpas_dbus_signal_p2p_group_removed - Signals P2P group was removed
754 * @wpa_s: %wpa_supplicant network interface data
755 * @role: role of this device (client or GO)
756 * Sends signal with i/f name and role as string arguments
758 void wpas_dbus_signal_p2p_group_removed(struct wpa_supplicant
*wpa_s
,
763 DBusMessageIter iter
;
764 struct wpas_dbus_priv
*iface
= wpa_s
->global
->dbus
;
765 char *ifname
= wpa_s
->ifname
;
767 /* Do nothing if the control interface is not turned on */
771 msg
= dbus_message_new_signal(wpa_s
->dbus_new_path
,
772 WPAS_DBUS_NEW_IFACE_P2PDEVICE
,
777 dbus_message_iter_init_append(msg
, &iter
);
779 if (!dbus_message_iter_append_basic(&iter
, DBUS_TYPE_STRING
, &ifname
)) {
780 wpa_printf(MSG_ERROR
, "dbus: Failed to construct GroupFinished"
781 "signal -not enough memory for ifname ");
785 if (!dbus_message_iter_append_basic(&iter
, DBUS_TYPE_STRING
, &role
))
786 wpa_printf(MSG_ERROR
, "dbus: Failed to construct GroupFinished"
787 "signal -not enough memory for role ");
789 dbus_connection_send(iface
->con
, msg
, NULL
);
792 dbus_message_unref(msg
);
797 * wpas_dbus_signal_p2p_provision_discovery - Signals various PD events
799 * @dev_addr - who sent the request or responded to our request.
800 * @request - Will be 1 if request, 0 for response.
801 * @status - valid only in case of response
802 * @config_methods - wps config methods
803 * @generated_pin - pin to be displayed in case of WPS_CONFIG_DISPLAY method
805 * Sends following provision discovery related events:
806 * ProvisionDiscoveryRequestDisplayPin
807 * ProvisionDiscoveryResponseDisplayPin
808 * ProvisionDiscoveryRequestEnterPin
809 * ProvisionDiscoveryResponseEnterPin
810 * ProvisionDiscoveryPBCRequest
811 * ProvisionDiscoveryPBCResponse
814 * ProvisionDiscoveryFailure (timeout case)
816 void wpas_dbus_signal_p2p_provision_discovery(struct wpa_supplicant
*wpa_s
,
817 const u8
*dev_addr
, int request
,
818 enum p2p_prov_disc_status status
,
820 unsigned int generated_pin
)
823 DBusMessageIter iter
;
824 struct wpas_dbus_priv
*iface
;
827 char peer_obj_path
[WPAS_DBUS_OBJECT_PATH_MAX
], *path
;
829 char pin
[9], *p_pin
= NULL
;
831 iface
= wpa_s
->global
->dbus
;
833 /* Do nothing if the control interface is not turned on */
837 if (request
|| !status
) {
838 if (config_methods
& WPS_CONFIG_DISPLAY
)
840 "ProvisionDiscoveryRequestDisplayPin" :
841 "ProvisionDiscoveryResponseEnterPin";
842 else if (config_methods
& WPS_CONFIG_KEYPAD
)
844 "ProvisionDiscoveryRequestEnterPin" :
845 "ProvisionDiscoveryResponseDisplayPin";
846 else if (config_methods
& WPS_CONFIG_PUSHBUTTON
)
847 _signal
= request
? "ProvisionDiscoveryPBCRequest" :
848 "ProvisionDiscoveryPBCResponse";
850 return; /* Unknown or un-supported method */
851 } else if (!request
&& status
)
852 /* Explicit check for failure response */
853 _signal
= "ProvisionDiscoveryFailure";
855 add_pin
= ((request
&& (config_methods
& WPS_CONFIG_DISPLAY
)) ||
856 (!request
&& !status
&&
857 (config_methods
& WPS_CONFIG_KEYPAD
)));
860 os_snprintf(pin
, sizeof(pin
), "%08d", generated_pin
);
864 msg
= dbus_message_new_signal(wpa_s
->dbus_new_path
,
865 WPAS_DBUS_NEW_IFACE_P2PDEVICE
, _signal
);
869 /* Check if this is a known peer */
870 if (!p2p_peer_known(wpa_s
->global
->p2p
, dev_addr
))
873 os_snprintf(peer_obj_path
, WPAS_DBUS_OBJECT_PATH_MAX
,
874 "%s/" WPAS_DBUS_NEW_P2P_PEERS_PART
"/"
876 wpa_s
->dbus_new_path
, MAC2STR(dev_addr
));
878 path
= peer_obj_path
;
880 dbus_message_iter_init_append(msg
, &iter
);
882 if (!dbus_message_iter_append_basic(&iter
,
883 DBUS_TYPE_OBJECT_PATH
,
887 if (!request
&& status
)
888 /* Attach status to ProvisionDiscoveryFailure */
889 error_ret
= !dbus_message_iter_append_basic(&iter
,
893 error_ret
= (add_pin
&&
894 !dbus_message_iter_append_basic(&iter
,
900 dbus_connection_send(iface
->con
, msg
, NULL
);
902 wpa_printf(MSG_ERROR
, "dbus: Failed to construct signal");
904 dbus_message_unref(msg
);
908 void wpas_dbus_signal_p2p_go_neg_req(struct wpa_supplicant
*wpa_s
,
909 const u8
*src
, u16 dev_passwd_id
)
912 DBusMessageIter iter
;
913 struct wpas_dbus_priv
*iface
;
914 char peer_obj_path
[WPAS_DBUS_OBJECT_PATH_MAX
], *path
;
916 iface
= wpa_s
->global
->dbus
;
918 /* Do nothing if the control interface is not turned on */
922 os_snprintf(peer_obj_path
, WPAS_DBUS_OBJECT_PATH_MAX
,
923 "%s/" WPAS_DBUS_NEW_P2P_PEERS_PART
"/" COMPACT_MACSTR
,
924 wpa_s
->dbus_new_path
, MAC2STR(src
));
925 path
= peer_obj_path
;
927 msg
= dbus_message_new_signal(wpa_s
->dbus_new_path
,
928 WPAS_DBUS_NEW_IFACE_P2PDEVICE
,
929 "GONegotiationRequest");
933 dbus_message_iter_init_append(msg
, &iter
);
935 if (!dbus_message_iter_append_basic(&iter
, DBUS_TYPE_OBJECT_PATH
,
937 !dbus_message_iter_append_basic(&iter
, DBUS_TYPE_UINT16
,
939 wpa_printf(MSG_ERROR
, "dbus: Failed to construct signal");
941 dbus_connection_send(iface
->con
, msg
, NULL
);
943 dbus_message_unref(msg
);
947 static int wpas_dbus_get_group_obj_path(struct wpa_supplicant
*wpa_s
,
948 const struct wpa_ssid
*ssid
,
949 char *group_obj_path
)
953 if (os_memcmp(ssid
->ssid
, P2P_WILDCARD_SSID
, P2P_WILDCARD_SSID_LEN
))
956 os_memcpy(group_name
, ssid
->ssid
+ P2P_WILDCARD_SSID_LEN
, 2);
957 group_name
[2] = '\0';
959 os_snprintf(group_obj_path
, WPAS_DBUS_OBJECT_PATH_MAX
,
960 "%s/" WPAS_DBUS_NEW_P2P_GROUPS_PART
"/%s",
961 wpa_s
->dbus_new_path
, group_name
);
968 * wpas_dbus_signal_p2p_group_started - Signals P2P group has
969 * started. Emitted when a group is successfully started
970 * irrespective of the role (client/GO) of the current device
972 * @wpa_s: %wpa_supplicant network interface data
974 * @client: this device is P2P client
975 * @network_id: network id of the group started, use instead of ssid->id
976 * to account for persistent groups
978 void wpas_dbus_signal_p2p_group_started(struct wpa_supplicant
*wpa_s
,
979 const struct wpa_ssid
*ssid
,
980 int client
, int network_id
)
983 DBusMessageIter iter
, dict_iter
;
984 struct wpas_dbus_priv
*iface
;
985 char net_obj_path
[WPAS_DBUS_OBJECT_PATH_MAX
];
986 char group_obj_path
[WPAS_DBUS_OBJECT_PATH_MAX
];
988 iface
= wpa_s
->parent
->global
->dbus
;
990 /* Do nothing if the control interface is not turned on */
994 if (wpas_dbus_get_group_obj_path(wpa_s
, ssid
, group_obj_path
) < 0)
997 /* New interface has been created for this group */
998 msg
= dbus_message_new_signal(wpa_s
->parent
->dbus_new_path
,
999 WPAS_DBUS_NEW_IFACE_P2PDEVICE
,
1005 dbus_message_iter_init_append(msg
, &iter
);
1006 if (!wpa_dbus_dict_open_write(&iter
, &dict_iter
))
1010 * In case the device supports creating a separate interface the
1011 * DBus client will need to know the object path for the interface
1012 * object this group was created on, so include it here.
1014 if (!wpa_dbus_dict_append_object_path(&dict_iter
,
1016 wpa_s
->dbus_new_path
))
1019 if (!wpa_dbus_dict_append_string(&dict_iter
, "role",
1020 client
? "client" : "GO"))
1023 os_snprintf(net_obj_path
, WPAS_DBUS_OBJECT_PATH_MAX
,
1024 "%s/" WPAS_DBUS_NEW_NETWORKS_PART
"/%u",
1025 wpa_s
->parent
->dbus_new_path
, network_id
);
1027 if (!wpa_dbus_dict_append_object_path(&dict_iter
, "group_object",
1029 !wpa_dbus_dict_append_object_path(&dict_iter
, "network_object",
1031 !wpa_dbus_dict_close_write(&iter
, &dict_iter
))
1034 dbus_connection_send(iface
->con
, msg
, NULL
);
1037 dbus_message_unref(msg
);
1043 * Method to emit GONeogtiation Success or Failure signals based
1045 * @status: Status of the GO neg request. 0 for success, other for errors.
1047 void wpas_dbus_signal_p2p_go_neg_resp(struct wpa_supplicant
*wpa_s
,
1048 struct p2p_go_neg_results
*res
)
1051 DBusMessageIter iter
, dict_iter
;
1052 DBusMessageIter iter_dict_entry
, iter_dict_val
, iter_dict_array
;
1053 struct wpas_dbus_priv
*iface
;
1054 char peer_obj_path
[WPAS_DBUS_OBJECT_PATH_MAX
], *path
;
1055 dbus_int32_t freqs
[P2P_MAX_CHANNELS
];
1056 dbus_int32_t
*f_array
= freqs
;
1059 iface
= wpa_s
->global
->dbus
;
1061 os_memset(freqs
, 0, sizeof(freqs
));
1062 /* Do nothing if the control interface is not turned on */
1066 os_snprintf(peer_obj_path
, WPAS_DBUS_OBJECT_PATH_MAX
,
1067 "%s/" WPAS_DBUS_NEW_P2P_PEERS_PART
"/" COMPACT_MACSTR
,
1068 wpa_s
->dbus_new_path
, MAC2STR(res
->peer_device_addr
));
1069 path
= peer_obj_path
;
1071 msg
= dbus_message_new_signal(wpa_s
->dbus_new_path
,
1072 WPAS_DBUS_NEW_IFACE_P2PDEVICE
,
1073 res
->status
? "GONegotiationFailure" :
1074 "GONegotiationSuccess");
1078 dbus_message_iter_init_append(msg
, &iter
);
1079 if (!wpa_dbus_dict_open_write(&iter
, &dict_iter
))
1081 if (!wpa_dbus_dict_append_object_path(&dict_iter
, "peer_object",
1083 !wpa_dbus_dict_append_int32(&dict_iter
, "status", res
->status
))
1088 int freq_list_num
= 0;
1091 if (!wpa_dbus_dict_append_byte_array(
1092 &dict_iter
, "passphrase",
1093 (const char *) res
->passphrase
,
1094 sizeof(res
->passphrase
)))
1098 if (!wpa_dbus_dict_append_string(&dict_iter
, "role_go",
1099 res
->role_go
? "GO" :
1101 !wpa_dbus_dict_append_int32(&dict_iter
, "frequency",
1103 !wpa_dbus_dict_append_byte_array(&dict_iter
, "ssid",
1104 (const char *) res
->ssid
,
1106 !wpa_dbus_dict_append_byte_array(&dict_iter
,
1109 res
->peer_device_addr
,
1111 !wpa_dbus_dict_append_byte_array(&dict_iter
,
1112 "peer_interface_addr",
1114 res
->peer_interface_addr
,
1116 !wpa_dbus_dict_append_string(&dict_iter
, "wps_method",
1117 p2p_wps_method_text(
1121 for (i
= 0; i
< P2P_MAX_CHANNELS
; i
++) {
1122 if (res
->freq_list
[i
]) {
1123 freqs
[i
] = res
->freq_list
[i
];
1128 if (!wpa_dbus_dict_begin_array(&dict_iter
,
1130 DBUS_TYPE_INT32_AS_STRING
,
1136 if (!dbus_message_iter_append_fixed_array(&iter_dict_array
,
1142 if (!wpa_dbus_dict_end_array(&dict_iter
,
1148 if (!wpa_dbus_dict_append_int32(&dict_iter
, "persistent_group",
1149 res
->persistent_group
) ||
1150 !wpa_dbus_dict_append_uint32(&dict_iter
,
1151 "peer_config_timeout",
1152 res
->peer_config_timeout
))
1156 if (!wpa_dbus_dict_close_write(&iter
, &dict_iter
))
1159 dbus_connection_send(iface
->con
, msg
, NULL
);
1161 dbus_message_unref(msg
);
1167 * Method to emit Invitation Result signal based on status and
1169 * @status: Status of the Invite request. 0 for success, other
1171 * @bssid : Basic Service Set Identifier
1173 void wpas_dbus_signal_p2p_invitation_result(struct wpa_supplicant
*wpa_s
,
1174 int status
, const u8
*bssid
)
1177 DBusMessageIter iter
, dict_iter
;
1178 struct wpas_dbus_priv
*iface
;
1180 wpa_printf(MSG_INFO
, "%s\n", __func__
);
1182 iface
= wpa_s
->global
->dbus
;
1183 /* Do nothing if the control interface is not turned on */
1187 msg
= dbus_message_new_signal(wpa_s
->dbus_new_path
,
1188 WPAS_DBUS_NEW_IFACE_P2PDEVICE
,
1189 "InvitationResult");
1194 dbus_message_iter_init_append(msg
, &iter
);
1195 if (!wpa_dbus_dict_open_write(&iter
, &dict_iter
))
1198 if (!wpa_dbus_dict_append_int32(&dict_iter
, "status", status
))
1201 if (!wpa_dbus_dict_append_byte_array(&dict_iter
, "BSSID",
1202 (const char *) bssid
,
1206 if (!wpa_dbus_dict_close_write(&iter
, &dict_iter
))
1209 dbus_connection_send(iface
->con
, msg
, NULL
);
1212 dbus_message_unref(msg
);
1218 * Method to emit a signal for a peer joining the group.
1219 * The signal will carry path to the group member object
1220 * constructed using p2p i/f addr used for connecting.
1222 * @wpa_s: %wpa_supplicant network interface data
1223 * @member_addr: addr (p2p i/f) of the peer joining the group
1225 void wpas_dbus_signal_p2p_peer_joined(struct wpa_supplicant
*wpa_s
,
1228 struct wpas_dbus_priv
*iface
;
1230 DBusMessageIter iter
;
1231 char groupmember_obj_path
[WPAS_DBUS_OBJECT_PATH_MAX
], *path
;
1233 iface
= wpa_s
->global
->dbus
;
1235 /* Do nothing if the control interface is not turned on */
1239 if (!wpa_s
->dbus_groupobj_path
)
1242 os_snprintf(groupmember_obj_path
, WPAS_DBUS_OBJECT_PATH_MAX
,
1243 "%s/" WPAS_DBUS_NEW_P2P_GROUPMEMBERS_PART
"/"
1245 wpa_s
->dbus_groupobj_path
, MAC2STR(member
));
1247 msg
= dbus_message_new_signal(wpa_s
->dbus_groupobj_path
,
1248 WPAS_DBUS_NEW_IFACE_P2P_GROUP
,
1253 dbus_message_iter_init_append(msg
, &iter
);
1254 path
= groupmember_obj_path
;
1255 if (!dbus_message_iter_append_basic(&iter
, DBUS_TYPE_OBJECT_PATH
,
1259 dbus_connection_send(iface
->con
, msg
, NULL
);
1261 dbus_message_unref(msg
);
1265 wpa_printf(MSG_ERROR
, "dbus: Failed to construct signal");
1266 dbus_message_unref(msg
);
1272 * Method to emit a signal for a peer disconnecting the group.
1273 * The signal will carry path to the group member object
1274 * constructed using p2p i/f addr used for connecting.
1276 * @wpa_s: %wpa_supplicant network interface data
1277 * @member_addr: addr (p2p i/f) of the peer joining the group
1279 void wpas_dbus_signal_p2p_peer_disconnected(struct wpa_supplicant
*wpa_s
,
1282 struct wpas_dbus_priv
*iface
;
1284 DBusMessageIter iter
;
1285 char groupmember_obj_path
[WPAS_DBUS_OBJECT_PATH_MAX
], *path
;
1287 iface
= wpa_s
->global
->dbus
;
1289 /* Do nothing if the control interface is not turned on */
1293 if (!wpa_s
->dbus_groupobj_path
)
1296 os_snprintf(groupmember_obj_path
, WPAS_DBUS_OBJECT_PATH_MAX
,
1297 "%s/" WPAS_DBUS_NEW_P2P_GROUPMEMBERS_PART
"/"
1299 wpa_s
->dbus_groupobj_path
, MAC2STR(member
));
1301 msg
= dbus_message_new_signal(wpa_s
->dbus_groupobj_path
,
1302 WPAS_DBUS_NEW_IFACE_P2P_GROUP
,
1303 "PeerDisconnected");
1307 dbus_message_iter_init_append(msg
, &iter
);
1308 path
= groupmember_obj_path
;
1309 if (!dbus_message_iter_append_basic(&iter
, DBUS_TYPE_OBJECT_PATH
,
1313 dbus_connection_send(iface
->con
, msg
, NULL
);
1315 dbus_message_unref(msg
);
1319 wpa_printf(MSG_ERROR
, "dbus: Failed to construct PeerDisconnected "
1321 dbus_message_unref(msg
);
1327 * Method to emit a signal for a service discovery request.
1328 * The signal will carry station address, frequency, dialog token,
1329 * update indicator and it tlvs
1331 * @wpa_s: %wpa_supplicant network interface data
1332 * @sa: station addr (p2p i/f) of the peer
1333 * @dialog_token: service discovery request dialog token
1334 * @update_indic: service discovery request update indicator
1335 * @tlvs: service discovery request genrated byte array of tlvs
1336 * @tlvs_len: service discovery request tlvs length
1338 void wpas_dbus_signal_p2p_sd_request(struct wpa_supplicant
*wpa_s
,
1339 int freq
, const u8
*sa
, u8 dialog_token
,
1340 u16 update_indic
, const u8
*tlvs
,
1344 DBusMessageIter iter
, dict_iter
;
1345 struct wpas_dbus_priv
*iface
;
1346 char peer_obj_path
[WPAS_DBUS_OBJECT_PATH_MAX
], *path
;
1347 iface
= wpa_s
->global
->dbus
;
1349 /* Do nothing if the control interface is not turned on */
1353 msg
= dbus_message_new_signal(wpa_s
->dbus_new_path
,
1354 WPAS_DBUS_NEW_IFACE_P2PDEVICE
,
1355 "ServiceDiscoveryRequest");
1359 /* Check if this is a known peer */
1360 if (!p2p_peer_known(wpa_s
->global
->p2p
, sa
))
1363 os_snprintf(peer_obj_path
, WPAS_DBUS_OBJECT_PATH_MAX
,
1364 "%s/" WPAS_DBUS_NEW_P2P_PEERS_PART
"/"
1365 COMPACT_MACSTR
, wpa_s
->dbus_new_path
, MAC2STR(sa
));
1367 path
= peer_obj_path
;
1369 dbus_message_iter_init_append(msg
, &iter
);
1370 if (!wpa_dbus_dict_open_write(&iter
, &dict_iter
))
1374 if (!wpa_dbus_dict_append_object_path(&dict_iter
, "peer_object",
1376 !wpa_dbus_dict_append_int32(&dict_iter
, "frequency", freq
) ||
1377 !wpa_dbus_dict_append_int32(&dict_iter
, "dialog_token",
1379 !wpa_dbus_dict_append_uint16(&dict_iter
, "update_indicator",
1381 !wpa_dbus_dict_append_byte_array(&dict_iter
, "tlvs",
1382 (const char *) tlvs
,
1384 !wpa_dbus_dict_close_write(&iter
, &dict_iter
))
1387 dbus_connection_send(iface
->con
, msg
, NULL
);
1388 dbus_message_unref(msg
);
1391 wpa_printf(MSG_ERROR
, "dbus: Failed to construct signal");
1392 dbus_message_unref(msg
);
1398 * Method to emit a signal for a service discovery response.
1399 * The signal will carry station address, update indicator and it
1402 * @wpa_s: %wpa_supplicant network interface data
1403 * @sa: station addr (p2p i/f) of the peer
1404 * @update_indic: service discovery request update indicator
1405 * @tlvs: service discovery request genrated byte array of tlvs
1406 * @tlvs_len: service discovery request tlvs length
1408 void wpas_dbus_signal_p2p_sd_response(struct wpa_supplicant
*wpa_s
,
1409 const u8
*sa
, u16 update_indic
,
1410 const u8
*tlvs
, size_t tlvs_len
)
1413 DBusMessageIter iter
, dict_iter
;
1414 struct wpas_dbus_priv
*iface
;
1415 char peer_obj_path
[WPAS_DBUS_OBJECT_PATH_MAX
], *path
;
1416 iface
= wpa_s
->global
->dbus
;
1418 /* Do nothing if the control interface is not turned on */
1422 msg
= dbus_message_new_signal(wpa_s
->dbus_new_path
,
1423 WPAS_DBUS_NEW_IFACE_P2PDEVICE
,
1424 "ServiceDiscoveryResponse");
1428 /* Check if this is a known peer */
1429 if (!p2p_peer_known(wpa_s
->global
->p2p
, sa
))
1432 os_snprintf(peer_obj_path
, WPAS_DBUS_OBJECT_PATH_MAX
,
1433 "%s/" WPAS_DBUS_NEW_P2P_PEERS_PART
"/"
1434 COMPACT_MACSTR
, wpa_s
->dbus_new_path
, MAC2STR(sa
));
1436 path
= peer_obj_path
;
1438 dbus_message_iter_init_append(msg
, &iter
);
1439 if (!wpa_dbus_dict_open_write(&iter
, &dict_iter
))
1442 if (!wpa_dbus_dict_append_object_path(&dict_iter
, "peer_object",
1444 !wpa_dbus_dict_append_uint16(&dict_iter
, "update_indicator",
1446 !wpa_dbus_dict_append_byte_array(&dict_iter
, "tlvs",
1447 (const char *) tlvs
,
1449 !wpa_dbus_dict_close_write(&iter
, &dict_iter
))
1453 dbus_connection_send(iface
->con
, msg
, NULL
);
1454 dbus_message_unref(msg
);
1457 wpa_printf(MSG_ERROR
, "dbus: Failed to construct signal");
1458 dbus_message_unref(msg
);
1462 * wpas_dbus_signal_persistent_group - Send a persistent group related
1464 * @wpa_s: %wpa_supplicant network interface data
1465 * @id: new persistent group id
1466 * @sig_name: signal name - PersistentGroupAdded, PersistentGroupRemoved
1467 * @properties: determines if add second argument with object properties
1469 * Notify listeners about an event related to persistent groups.
1471 static void wpas_dbus_signal_persistent_group(struct wpa_supplicant
*wpa_s
,
1472 int id
, const char *sig_name
,
1475 struct wpas_dbus_priv
*iface
;
1477 DBusMessageIter iter
;
1478 char pgrp_obj_path
[WPAS_DBUS_OBJECT_PATH_MAX
], *path
;
1480 iface
= wpa_s
->global
->dbus
;
1482 /* Do nothing if the control interface is not turned on */
1486 os_snprintf(pgrp_obj_path
, WPAS_DBUS_OBJECT_PATH_MAX
,
1487 "%s/" WPAS_DBUS_NEW_PERSISTENT_GROUPS_PART
"/%u",
1488 wpa_s
->dbus_new_path
, id
);
1490 msg
= dbus_message_new_signal(wpa_s
->dbus_new_path
,
1491 WPAS_DBUS_NEW_IFACE_P2PDEVICE
,
1496 dbus_message_iter_init_append(msg
, &iter
);
1497 path
= pgrp_obj_path
;
1498 if (!dbus_message_iter_append_basic(&iter
, DBUS_TYPE_OBJECT_PATH
,
1503 if (!wpa_dbus_get_object_properties(
1504 iface
, pgrp_obj_path
,
1505 WPAS_DBUS_NEW_IFACE_PERSISTENT_GROUP
, &iter
))
1509 dbus_connection_send(iface
->con
, msg
, NULL
);
1511 dbus_message_unref(msg
);
1515 wpa_printf(MSG_ERROR
, "dbus: Failed to construct signal");
1516 dbus_message_unref(msg
);
1521 * wpas_dbus_signal_persistent_group_added - Send a persistent_group
1523 * @wpa_s: %wpa_supplicant network interface data
1524 * @id: new persistent group id
1526 * Notify listeners about addition of a new persistent group.
1528 static void wpas_dbus_signal_persistent_group_added(
1529 struct wpa_supplicant
*wpa_s
, int id
)
1531 wpas_dbus_signal_persistent_group(wpa_s
, id
, "PersistentGroupAdded",
1537 * wpas_dbus_signal_persistent_group_removed - Send a persistent_group
1539 * @wpa_s: %wpa_supplicant network interface data
1540 * @id: persistent group id
1542 * Notify listeners about removal of a persistent group.
1544 static void wpas_dbus_signal_persistent_group_removed(
1545 struct wpa_supplicant
*wpa_s
, int id
)
1547 wpas_dbus_signal_persistent_group(wpa_s
, id
, "PersistentGroupRemoved",
1553 * wpas_dbus_signal_p2p_wps_failed - Signals WpsFailed event
1554 * @wpa_s: %wpa_supplicant network interface data
1556 * Sends Event dbus signal with name "fail" and dictionary containing
1557 * "msg" field with fail message number (int32) as arguments
1559 void wpas_dbus_signal_p2p_wps_failed(struct wpa_supplicant
*wpa_s
,
1560 struct wps_event_fail
*fail
)
1564 DBusMessageIter iter
, dict_iter
;
1565 struct wpas_dbus_priv
*iface
;
1568 iface
= wpa_s
->global
->dbus
;
1570 /* Do nothing if the control interface is not turned on */
1574 msg
= dbus_message_new_signal(wpa_s
->dbus_new_path
,
1575 WPAS_DBUS_NEW_IFACE_P2PDEVICE
,
1580 dbus_message_iter_init_append(msg
, &iter
);
1582 if (!dbus_message_iter_append_basic(&iter
, DBUS_TYPE_STRING
, &key
) ||
1583 !wpa_dbus_dict_open_write(&iter
, &dict_iter
) ||
1584 !wpa_dbus_dict_append_int32(&dict_iter
, "msg", fail
->msg
) ||
1585 !wpa_dbus_dict_append_int16(&dict_iter
, "config_error",
1586 fail
->config_error
) ||
1587 !wpa_dbus_dict_close_write(&iter
, &dict_iter
))
1588 wpa_printf(MSG_ERROR
, "dbus: Failed to construct signal");
1590 dbus_connection_send(iface
->con
, msg
, NULL
);
1592 dbus_message_unref(msg
);
1595 #endif /*CONFIG_P2P*/
1599 * wpas_dbus_signal_prop_changed - Signals change of property
1600 * @wpa_s: %wpa_supplicant network interface data
1601 * @property: indicates which property has changed
1603 * Sends PropertyChanged signals with path, interface and arguments
1604 * depending on which property has changed.
1606 void wpas_dbus_signal_prop_changed(struct wpa_supplicant
*wpa_s
,
1607 enum wpas_dbus_prop property
)
1611 if (wpa_s
->dbus_new_path
== NULL
)
1612 return; /* Skip signal since D-Bus setup is not yet ready */
1615 case WPAS_DBUS_PROP_AP_SCAN
:
1618 case WPAS_DBUS_PROP_SCANNING
:
1621 case WPAS_DBUS_PROP_STATE
:
1624 case WPAS_DBUS_PROP_CURRENT_BSS
:
1625 prop
= "CurrentBSS";
1627 case WPAS_DBUS_PROP_CURRENT_NETWORK
:
1628 prop
= "CurrentNetwork";
1630 case WPAS_DBUS_PROP_BSSS
:
1633 case WPAS_DBUS_PROP_CURRENT_AUTH_MODE
:
1634 prop
= "CurrentAuthMode";
1637 wpa_printf(MSG_ERROR
, "dbus: %s: Unknown Property value %d",
1638 __func__
, property
);
1642 wpa_dbus_mark_property_changed(wpa_s
->global
->dbus
,
1643 wpa_s
->dbus_new_path
,
1644 WPAS_DBUS_NEW_IFACE_INTERFACE
, prop
);
1649 * wpas_dbus_bss_signal_prop_changed - Signals change of BSS property
1650 * @wpa_s: %wpa_supplicant network interface data
1651 * @property: indicates which property has changed
1652 * @id: unique BSS identifier
1654 * Sends PropertyChanged signals with path, interface, and arguments depending
1655 * on which property has changed.
1657 void wpas_dbus_bss_signal_prop_changed(struct wpa_supplicant
*wpa_s
,
1658 enum wpas_dbus_bss_prop property
,
1661 char path
[WPAS_DBUS_OBJECT_PATH_MAX
];
1665 case WPAS_DBUS_BSS_PROP_SIGNAL
:
1668 case WPAS_DBUS_BSS_PROP_FREQ
:
1671 case WPAS_DBUS_BSS_PROP_MODE
:
1674 case WPAS_DBUS_BSS_PROP_PRIVACY
:
1677 case WPAS_DBUS_BSS_PROP_RATES
:
1680 case WPAS_DBUS_BSS_PROP_WPA
:
1683 case WPAS_DBUS_BSS_PROP_RSN
:
1686 case WPAS_DBUS_BSS_PROP_IES
:
1690 wpa_printf(MSG_ERROR
, "dbus: %s: Unknown Property value %d",
1691 __func__
, property
);
1695 os_snprintf(path
, WPAS_DBUS_OBJECT_PATH_MAX
,
1696 "%s/" WPAS_DBUS_NEW_BSSIDS_PART
"/%u",
1697 wpa_s
->dbus_new_path
, id
);
1699 wpa_dbus_mark_property_changed(wpa_s
->global
->dbus
, path
,
1700 WPAS_DBUS_NEW_IFACE_BSS
, prop
);
1705 * wpas_dbus_signal_debug_level_changed - Signals change of debug param
1706 * @global: wpa_global structure
1708 * Sends PropertyChanged signals informing that debug level has changed.
1710 void wpas_dbus_signal_debug_level_changed(struct wpa_global
*global
)
1712 wpa_dbus_mark_property_changed(global
->dbus
, WPAS_DBUS_NEW_PATH
,
1713 WPAS_DBUS_NEW_INTERFACE
,
1719 * wpas_dbus_signal_debug_timestamp_changed - Signals change of debug param
1720 * @global: wpa_global structure
1722 * Sends PropertyChanged signals informing that debug timestamp has changed.
1724 void wpas_dbus_signal_debug_timestamp_changed(struct wpa_global
*global
)
1726 wpa_dbus_mark_property_changed(global
->dbus
, WPAS_DBUS_NEW_PATH
,
1727 WPAS_DBUS_NEW_INTERFACE
,
1733 * wpas_dbus_signal_debug_show_keys_changed - Signals change of debug param
1734 * @global: wpa_global structure
1736 * Sends PropertyChanged signals informing that debug show_keys has changed.
1738 void wpas_dbus_signal_debug_show_keys_changed(struct wpa_global
*global
)
1740 wpa_dbus_mark_property_changed(global
->dbus
, WPAS_DBUS_NEW_PATH
,
1741 WPAS_DBUS_NEW_INTERFACE
,
1746 static void wpas_dbus_register(struct wpa_dbus_object_desc
*obj_desc
,
1748 WPADBusArgumentFreeFunction priv_free
,
1749 const struct wpa_dbus_method_desc
*methods
,
1750 const struct wpa_dbus_property_desc
*properties
,
1751 const struct wpa_dbus_signal_desc
*signals
)
1755 obj_desc
->user_data
= priv
;
1756 obj_desc
->user_data_free_func
= priv_free
;
1757 obj_desc
->methods
= methods
;
1758 obj_desc
->properties
= properties
;
1759 obj_desc
->signals
= signals
;
1761 for (n
= 0; properties
&& properties
->dbus_property
; properties
++)
1764 obj_desc
->prop_changed_flags
= os_zalloc(n
);
1765 if (!obj_desc
->prop_changed_flags
)
1766 wpa_printf(MSG_DEBUG
, "dbus: %s: can't register handlers",
1771 static const struct wpa_dbus_method_desc wpas_dbus_global_methods
[] = {
1772 { "CreateInterface", WPAS_DBUS_NEW_INTERFACE
,
1773 (WPADBusMethodHandler
) &wpas_dbus_handler_create_interface
,
1775 { "args", "a{sv}", ARG_IN
},
1776 { "path", "o", ARG_OUT
},
1780 { "RemoveInterface", WPAS_DBUS_NEW_INTERFACE
,
1781 (WPADBusMethodHandler
) &wpas_dbus_handler_remove_interface
,
1783 { "path", "o", ARG_IN
},
1787 { "GetInterface", WPAS_DBUS_NEW_INTERFACE
,
1788 (WPADBusMethodHandler
) &wpas_dbus_handler_get_interface
,
1790 { "ifname", "s", ARG_IN
},
1791 { "path", "o", ARG_OUT
},
1795 { NULL
, NULL
, NULL
, { END_ARGS
} }
1798 static const struct wpa_dbus_property_desc wpas_dbus_global_properties
[] = {
1799 { "DebugLevel", WPAS_DBUS_NEW_INTERFACE
, "s",
1800 wpas_dbus_getter_debug_level
,
1801 wpas_dbus_setter_debug_level
1803 { "DebugTimestamp", WPAS_DBUS_NEW_INTERFACE
, "b",
1804 wpas_dbus_getter_debug_timestamp
,
1805 wpas_dbus_setter_debug_timestamp
1807 { "DebugShowKeys", WPAS_DBUS_NEW_INTERFACE
, "b",
1808 wpas_dbus_getter_debug_show_keys
,
1809 wpas_dbus_setter_debug_show_keys
1811 { "Interfaces", WPAS_DBUS_NEW_INTERFACE
, "ao",
1812 wpas_dbus_getter_interfaces
,
1815 { "EapMethods", WPAS_DBUS_NEW_INTERFACE
, "as",
1816 wpas_dbus_getter_eap_methods
,
1819 { NULL
, NULL
, NULL
, NULL
, NULL
}
1822 static const struct wpa_dbus_signal_desc wpas_dbus_global_signals
[] = {
1823 { "InterfaceAdded", WPAS_DBUS_NEW_INTERFACE
,
1825 { "path", "o", ARG_OUT
},
1826 { "properties", "a{sv}", ARG_OUT
},
1830 { "InterfaceRemoved", WPAS_DBUS_NEW_INTERFACE
,
1832 { "path", "o", ARG_OUT
},
1836 { "NetworkRequest", WPAS_DBUS_NEW_IFACE_INTERFACE
,
1838 { "path", "o", ARG_OUT
},
1839 { "field", "s", ARG_OUT
},
1840 { "text", "s", ARG_OUT
},
1844 /* Deprecated: use org.freedesktop.DBus.Properties.PropertiesChanged */
1845 { "PropertiesChanged", WPAS_DBUS_NEW_INTERFACE
,
1847 { "properties", "a{sv}", ARG_OUT
},
1851 { NULL
, NULL
, { END_ARGS
} }
1856 * wpas_dbus_ctrl_iface_init - Initialize dbus control interface
1857 * @global: Pointer to global data from wpa_supplicant_init()
1858 * Returns: 0 on success or -1 on failure
1860 * Initialize the dbus control interface for wpa_supplicantand and start
1861 * receiving commands from external programs over the bus.
1863 int wpas_dbus_ctrl_iface_init(struct wpas_dbus_priv
*priv
)
1865 struct wpa_dbus_object_desc
*obj_desc
;
1868 obj_desc
= os_zalloc(sizeof(struct wpa_dbus_object_desc
));
1870 wpa_printf(MSG_ERROR
, "Not enough memory "
1871 "to create object description");
1875 wpas_dbus_register(obj_desc
, priv
->global
, NULL
,
1876 wpas_dbus_global_methods
,
1877 wpas_dbus_global_properties
,
1878 wpas_dbus_global_signals
);
1880 wpa_printf(MSG_DEBUG
, "dbus: Register D-Bus object '%s'",
1881 WPAS_DBUS_NEW_PATH
);
1882 ret
= wpa_dbus_ctrl_iface_init(priv
, WPAS_DBUS_NEW_PATH
,
1883 WPAS_DBUS_NEW_SERVICE
,
1886 free_dbus_object_desc(obj_desc
);
1888 priv
->dbus_new_initialized
= 1;
1895 * wpas_dbus_ctrl_iface_deinit - Deinitialize dbus ctrl interface for
1897 * @iface: Pointer to dbus private data from wpas_dbus_init()
1899 * Deinitialize the dbus control interface that was initialized with
1900 * wpas_dbus_ctrl_iface_init().
1902 void wpas_dbus_ctrl_iface_deinit(struct wpas_dbus_priv
*iface
)
1904 if (!iface
->dbus_new_initialized
)
1906 wpa_printf(MSG_DEBUG
, "dbus: Unregister D-Bus object '%s'",
1907 WPAS_DBUS_NEW_PATH
);
1908 dbus_connection_unregister_object_path(iface
->con
,
1909 WPAS_DBUS_NEW_PATH
);
1913 static void wpa_dbus_free(void *ptr
)
1919 static const struct wpa_dbus_property_desc wpas_dbus_network_properties
[] = {
1920 { "Properties", WPAS_DBUS_NEW_IFACE_NETWORK
, "a{sv}",
1921 wpas_dbus_getter_network_properties
,
1922 wpas_dbus_setter_network_properties
1924 { "Enabled", WPAS_DBUS_NEW_IFACE_NETWORK
, "b",
1925 wpas_dbus_getter_enabled
,
1926 wpas_dbus_setter_enabled
1928 { NULL
, NULL
, NULL
, NULL
, NULL
}
1932 static const struct wpa_dbus_signal_desc wpas_dbus_network_signals
[] = {
1933 /* Deprecated: use org.freedesktop.DBus.Properties.PropertiesChanged */
1934 { "PropertiesChanged", WPAS_DBUS_NEW_IFACE_NETWORK
,
1936 { "properties", "a{sv}", ARG_OUT
},
1940 { NULL
, NULL
, { END_ARGS
} }
1945 * wpas_dbus_register_network - Register a configured network with dbus
1946 * @wpa_s: wpa_supplicant interface structure
1947 * @ssid: network configuration data
1948 * Returns: 0 on success, -1 on failure
1950 * Registers network representing object with dbus
1952 int wpas_dbus_register_network(struct wpa_supplicant
*wpa_s
,
1953 struct wpa_ssid
*ssid
)
1955 struct wpas_dbus_priv
*ctrl_iface
;
1956 struct wpa_dbus_object_desc
*obj_desc
;
1957 struct network_handler_args
*arg
;
1958 char net_obj_path
[WPAS_DBUS_OBJECT_PATH_MAX
];
1962 * If it is a persistent group register it as such.
1963 * This is to handle cases where an interface is being initialized
1964 * with a list of networks read from config.
1966 if (network_is_persistent_group(ssid
))
1967 return wpas_dbus_register_persistent_group(wpa_s
, ssid
);
1968 #endif /* CONFIG_P2P */
1970 /* Do nothing if the control interface is not turned on */
1971 if (wpa_s
== NULL
|| wpa_s
->global
== NULL
)
1973 ctrl_iface
= wpa_s
->global
->dbus
;
1974 if (ctrl_iface
== NULL
)
1977 os_snprintf(net_obj_path
, WPAS_DBUS_OBJECT_PATH_MAX
,
1978 "%s/" WPAS_DBUS_NEW_NETWORKS_PART
"/%u",
1979 wpa_s
->dbus_new_path
, ssid
->id
);
1981 wpa_printf(MSG_DEBUG
, "dbus: Register network object '%s'",
1983 obj_desc
= os_zalloc(sizeof(struct wpa_dbus_object_desc
));
1985 wpa_printf(MSG_ERROR
, "Not enough memory "
1986 "to create object description");
1990 /* allocate memory for handlers arguments */
1991 arg
= os_zalloc(sizeof(struct network_handler_args
));
1993 wpa_printf(MSG_ERROR
, "Not enough memory "
1994 "to create arguments for method");
2001 wpas_dbus_register(obj_desc
, arg
, wpa_dbus_free
, NULL
,
2002 wpas_dbus_network_properties
,
2003 wpas_dbus_network_signals
);
2005 if (wpa_dbus_register_object_per_iface(ctrl_iface
, net_obj_path
,
2006 wpa_s
->ifname
, obj_desc
))
2009 wpas_dbus_signal_network_added(wpa_s
, ssid
->id
);
2014 free_dbus_object_desc(obj_desc
);
2020 * wpas_dbus_unregister_network - Unregister a configured network from dbus
2021 * @wpa_s: wpa_supplicant interface structure
2023 * Returns: 0 on success, -1 on failure
2025 * Unregisters network representing object from dbus
2027 int wpas_dbus_unregister_network(struct wpa_supplicant
*wpa_s
, int nid
)
2029 struct wpas_dbus_priv
*ctrl_iface
;
2030 char net_obj_path
[WPAS_DBUS_OBJECT_PATH_MAX
];
2032 struct wpa_ssid
*ssid
;
2034 ssid
= wpa_config_get_network(wpa_s
->conf
, nid
);
2037 /* If it is a persistent group unregister it as such */
2038 if (ssid
&& network_is_persistent_group(ssid
))
2039 return wpas_dbus_unregister_persistent_group(wpa_s
, nid
);
2040 #endif /* CONFIG_P2P */
2042 /* Do nothing if the control interface is not turned on */
2043 if (wpa_s
->global
== NULL
|| wpa_s
->dbus_new_path
== NULL
)
2045 ctrl_iface
= wpa_s
->global
->dbus
;
2046 if (ctrl_iface
== NULL
)
2049 os_snprintf(net_obj_path
, WPAS_DBUS_OBJECT_PATH_MAX
,
2050 "%s/" WPAS_DBUS_NEW_NETWORKS_PART
"/%u",
2051 wpa_s
->dbus_new_path
, nid
);
2053 wpa_printf(MSG_DEBUG
, "dbus: Unregister network object '%s'",
2055 ret
= wpa_dbus_unregister_object_per_iface(ctrl_iface
, net_obj_path
);
2058 wpas_dbus_signal_network_removed(wpa_s
, nid
);
2064 static const struct wpa_dbus_property_desc wpas_dbus_bss_properties
[] = {
2065 { "SSID", WPAS_DBUS_NEW_IFACE_BSS
, "ay",
2066 wpas_dbus_getter_bss_ssid
,
2069 { "BSSID", WPAS_DBUS_NEW_IFACE_BSS
, "ay",
2070 wpas_dbus_getter_bss_bssid
,
2073 { "Privacy", WPAS_DBUS_NEW_IFACE_BSS
, "b",
2074 wpas_dbus_getter_bss_privacy
,
2077 { "Mode", WPAS_DBUS_NEW_IFACE_BSS
, "s",
2078 wpas_dbus_getter_bss_mode
,
2081 { "Signal", WPAS_DBUS_NEW_IFACE_BSS
, "n",
2082 wpas_dbus_getter_bss_signal
,
2085 { "Frequency", WPAS_DBUS_NEW_IFACE_BSS
, "q",
2086 wpas_dbus_getter_bss_frequency
,
2089 { "Rates", WPAS_DBUS_NEW_IFACE_BSS
, "au",
2090 wpas_dbus_getter_bss_rates
,
2093 { "WPA", WPAS_DBUS_NEW_IFACE_BSS
, "a{sv}",
2094 wpas_dbus_getter_bss_wpa
,
2097 { "RSN", WPAS_DBUS_NEW_IFACE_BSS
, "a{sv}",
2098 wpas_dbus_getter_bss_rsn
,
2101 { "IEs", WPAS_DBUS_NEW_IFACE_BSS
, "ay",
2102 wpas_dbus_getter_bss_ies
,
2105 { NULL
, NULL
, NULL
, NULL
, NULL
}
2109 static const struct wpa_dbus_signal_desc wpas_dbus_bss_signals
[] = {
2110 /* Deprecated: use org.freedesktop.DBus.Properties.PropertiesChanged */
2111 { "PropertiesChanged", WPAS_DBUS_NEW_IFACE_BSS
,
2113 { "properties", "a{sv}", ARG_OUT
},
2117 { NULL
, NULL
, { END_ARGS
} }
2122 * wpas_dbus_unregister_bss - Unregister a scanned BSS from dbus
2123 * @wpa_s: wpa_supplicant interface structure
2124 * @bssid: scanned network bssid
2125 * @id: unique BSS identifier
2126 * Returns: 0 on success, -1 on failure
2128 * Unregisters BSS representing object from dbus
2130 int wpas_dbus_unregister_bss(struct wpa_supplicant
*wpa_s
,
2131 u8 bssid
[ETH_ALEN
], unsigned int id
)
2133 struct wpas_dbus_priv
*ctrl_iface
;
2134 char bss_obj_path
[WPAS_DBUS_OBJECT_PATH_MAX
];
2136 /* Do nothing if the control interface is not turned on */
2137 if (wpa_s
== NULL
|| wpa_s
->global
== NULL
)
2139 ctrl_iface
= wpa_s
->global
->dbus
;
2140 if (ctrl_iface
== NULL
)
2143 os_snprintf(bss_obj_path
, WPAS_DBUS_OBJECT_PATH_MAX
,
2144 "%s/" WPAS_DBUS_NEW_BSSIDS_PART
"/%u",
2145 wpa_s
->dbus_new_path
, id
);
2147 wpa_printf(MSG_DEBUG
, "dbus: Unregister BSS object '%s'",
2149 if (wpa_dbus_unregister_object_per_iface(ctrl_iface
, bss_obj_path
)) {
2150 wpa_printf(MSG_ERROR
, "dbus: Cannot unregister BSS object %s",
2155 wpas_dbus_signal_bss_removed(wpa_s
, bss_obj_path
);
2156 wpas_dbus_signal_prop_changed(wpa_s
, WPAS_DBUS_PROP_BSSS
);
2163 * wpas_dbus_register_bss - Register a scanned BSS with dbus
2164 * @wpa_s: wpa_supplicant interface structure
2165 * @bssid: scanned network bssid
2166 * @id: unique BSS identifier
2167 * Returns: 0 on success, -1 on failure
2169 * Registers BSS representing object with dbus
2171 int wpas_dbus_register_bss(struct wpa_supplicant
*wpa_s
,
2172 u8 bssid
[ETH_ALEN
], unsigned int id
)
2174 struct wpas_dbus_priv
*ctrl_iface
;
2175 struct wpa_dbus_object_desc
*obj_desc
;
2176 char bss_obj_path
[WPAS_DBUS_OBJECT_PATH_MAX
];
2177 struct bss_handler_args
*arg
;
2179 /* Do nothing if the control interface is not turned on */
2180 if (wpa_s
== NULL
|| wpa_s
->global
== NULL
)
2182 ctrl_iface
= wpa_s
->global
->dbus
;
2183 if (ctrl_iface
== NULL
)
2186 os_snprintf(bss_obj_path
, WPAS_DBUS_OBJECT_PATH_MAX
,
2187 "%s/" WPAS_DBUS_NEW_BSSIDS_PART
"/%u",
2188 wpa_s
->dbus_new_path
, id
);
2190 obj_desc
= os_zalloc(sizeof(struct wpa_dbus_object_desc
));
2192 wpa_printf(MSG_ERROR
, "Not enough memory "
2193 "to create object description");
2197 arg
= os_zalloc(sizeof(struct bss_handler_args
));
2199 wpa_printf(MSG_ERROR
, "Not enough memory "
2200 "to create arguments for handler");
2206 wpas_dbus_register(obj_desc
, arg
, wpa_dbus_free
, NULL
,
2207 wpas_dbus_bss_properties
,
2208 wpas_dbus_bss_signals
);
2210 wpa_printf(MSG_DEBUG
, "dbus: Register BSS object '%s'",
2212 if (wpa_dbus_register_object_per_iface(ctrl_iface
, bss_obj_path
,
2213 wpa_s
->ifname
, obj_desc
)) {
2214 wpa_printf(MSG_ERROR
,
2215 "Cannot register BSSID dbus object %s.",
2220 wpas_dbus_signal_bss_added(wpa_s
, bss_obj_path
);
2221 wpas_dbus_signal_prop_changed(wpa_s
, WPAS_DBUS_PROP_BSSS
);
2226 free_dbus_object_desc(obj_desc
);
2231 static const struct wpa_dbus_method_desc wpas_dbus_interface_methods
[] = {
2232 { "Scan", WPAS_DBUS_NEW_IFACE_INTERFACE
,
2233 (WPADBusMethodHandler
) &wpas_dbus_handler_scan
,
2235 { "args", "a{sv}", ARG_IN
},
2239 { "Disconnect", WPAS_DBUS_NEW_IFACE_INTERFACE
,
2240 (WPADBusMethodHandler
) &wpas_dbus_handler_disconnect
,
2245 { "AddNetwork", WPAS_DBUS_NEW_IFACE_INTERFACE
,
2246 (WPADBusMethodHandler
) &wpas_dbus_handler_add_network
,
2248 { "args", "a{sv}", ARG_IN
},
2249 { "path", "o", ARG_OUT
},
2253 { "RemoveNetwork", WPAS_DBUS_NEW_IFACE_INTERFACE
,
2254 (WPADBusMethodHandler
) &wpas_dbus_handler_remove_network
,
2256 { "path", "o", ARG_IN
},
2260 { "RemoveAllNetworks", WPAS_DBUS_NEW_IFACE_INTERFACE
,
2261 (WPADBusMethodHandler
) &wpas_dbus_handler_remove_all_networks
,
2266 { "SelectNetwork", WPAS_DBUS_NEW_IFACE_INTERFACE
,
2267 (WPADBusMethodHandler
) &wpas_dbus_handler_select_network
,
2269 { "path", "o", ARG_IN
},
2273 { "NetworkReply", WPAS_DBUS_NEW_IFACE_INTERFACE
,
2274 (WPADBusMethodHandler
) &wpas_dbus_handler_network_reply
,
2276 { "path", "o", ARG_IN
},
2277 { "field", "s", ARG_IN
},
2278 { "value", "s", ARG_IN
},
2282 { "AddBlob", WPAS_DBUS_NEW_IFACE_INTERFACE
,
2283 (WPADBusMethodHandler
) &wpas_dbus_handler_add_blob
,
2285 { "name", "s", ARG_IN
},
2286 { "data", "ay", ARG_IN
},
2290 { "GetBlob", WPAS_DBUS_NEW_IFACE_INTERFACE
,
2291 (WPADBusMethodHandler
) &wpas_dbus_handler_get_blob
,
2293 { "name", "s", ARG_IN
},
2294 { "data", "ay", ARG_OUT
},
2298 { "RemoveBlob", WPAS_DBUS_NEW_IFACE_INTERFACE
,
2299 (WPADBusMethodHandler
) &wpas_dbus_handler_remove_blob
,
2301 { "name", "s", ARG_IN
},
2306 { "Start", WPAS_DBUS_NEW_IFACE_WPS
,
2307 (WPADBusMethodHandler
) &wpas_dbus_handler_wps_start
,
2309 { "args", "a{sv}", ARG_IN
},
2310 { "output", "a{sv}", ARG_OUT
},
2314 #endif /* CONFIG_WPS */
2316 { "Find", WPAS_DBUS_NEW_IFACE_P2PDEVICE
,
2317 (WPADBusMethodHandler
)wpas_dbus_handler_p2p_find
,
2319 { "args", "a{sv}", ARG_IN
},
2323 { "StopFind", WPAS_DBUS_NEW_IFACE_P2PDEVICE
,
2324 (WPADBusMethodHandler
)wpas_dbus_handler_p2p_stop_find
,
2329 { "Listen", WPAS_DBUS_NEW_IFACE_P2PDEVICE
,
2330 (WPADBusMethodHandler
)wpas_dbus_handler_p2p_listen
,
2332 { "timeout", "i", ARG_IN
},
2336 { "ExtendedListen", WPAS_DBUS_NEW_IFACE_P2PDEVICE
,
2337 (WPADBusMethodHandler
)wpas_dbus_handler_p2p_extendedlisten
,
2339 { "args", "a{sv}", ARG_IN
},
2343 { "PresenceRequest", WPAS_DBUS_NEW_IFACE_P2PDEVICE
,
2344 (WPADBusMethodHandler
)wpas_dbus_handler_p2p_presence_request
,
2346 { "args", "a{sv}", ARG_IN
},
2350 { "ProvisionDiscoveryRequest", WPAS_DBUS_NEW_IFACE_P2PDEVICE
,
2351 (WPADBusMethodHandler
)wpas_dbus_handler_p2p_prov_disc_req
,
2353 { "peer", "o", ARG_IN
},
2354 { "config_method", "s", ARG_IN
},
2358 { "Connect", WPAS_DBUS_NEW_IFACE_P2PDEVICE
,
2359 (WPADBusMethodHandler
)wpas_dbus_handler_p2p_connect
,
2361 { "args", "a{sv}", ARG_IN
},
2362 { "generated_pin", "s", ARG_OUT
},
2366 { "GroupAdd", WPAS_DBUS_NEW_IFACE_P2PDEVICE
,
2367 (WPADBusMethodHandler
)wpas_dbus_handler_p2p_group_add
,
2369 { "args", "a{sv}", ARG_IN
},
2373 { "Invite", WPAS_DBUS_NEW_IFACE_P2PDEVICE
,
2374 (WPADBusMethodHandler
)wpas_dbus_handler_p2p_invite
,
2376 { "args", "a{sv}", ARG_IN
},
2380 { "Disconnect", WPAS_DBUS_NEW_IFACE_P2PDEVICE
,
2381 (WPADBusMethodHandler
)wpas_dbus_handler_p2p_disconnect
,
2386 { "RejectPeer", WPAS_DBUS_NEW_IFACE_P2PDEVICE
,
2387 (WPADBusMethodHandler
)wpas_dbus_handler_p2p_rejectpeer
,
2389 { "peer", "o", ARG_IN
},
2393 { "Flush", WPAS_DBUS_NEW_IFACE_P2PDEVICE
,
2394 (WPADBusMethodHandler
)wpas_dbus_handler_p2p_flush
,
2399 { "AddService", WPAS_DBUS_NEW_IFACE_P2PDEVICE
,
2400 (WPADBusMethodHandler
)wpas_dbus_handler_p2p_add_service
,
2402 { "args", "a{sv}", ARG_IN
},
2406 { "DeleteService", WPAS_DBUS_NEW_IFACE_P2PDEVICE
,
2407 (WPADBusMethodHandler
)wpas_dbus_handler_p2p_delete_service
,
2409 { "args", "a{sv}", ARG_IN
},
2413 { "FlushService", WPAS_DBUS_NEW_IFACE_P2PDEVICE
,
2414 (WPADBusMethodHandler
)wpas_dbus_handler_p2p_flush_service
,
2419 { "ServiceDiscoveryRequest", WPAS_DBUS_NEW_IFACE_P2PDEVICE
,
2420 (WPADBusMethodHandler
)wpas_dbus_handler_p2p_service_sd_req
,
2422 { "args", "a{sv}", ARG_IN
},
2426 { "ServiceDiscoveryResponse", WPAS_DBUS_NEW_IFACE_P2PDEVICE
,
2427 (WPADBusMethodHandler
)wpas_dbus_handler_p2p_service_sd_res
,
2429 { "args", "a{sv}", ARG_IN
},
2433 { "ServiceDiscoveryCancelRequest", WPAS_DBUS_NEW_IFACE_P2PDEVICE
,
2434 (WPADBusMethodHandler
)wpas_dbus_handler_p2p_service_sd_cancel_req
,
2436 { "args", "t", ARG_IN
},
2440 { "ServiceUpdate", WPAS_DBUS_NEW_IFACE_P2PDEVICE
,
2441 (WPADBusMethodHandler
)wpas_dbus_handler_p2p_service_update
,
2446 { "ServiceDiscoveryExternal", WPAS_DBUS_NEW_IFACE_P2PDEVICE
,
2447 (WPADBusMethodHandler
)wpas_dbus_handler_p2p_serv_disc_external
,
2449 { "arg", "i", ARG_IN
},
2453 { "ServiceDiscoveryExternal", WPAS_DBUS_NEW_IFACE_P2PDEVICE
,
2454 (WPADBusMethodHandler
)wpas_dbus_handler_p2p_serv_disc_external
,
2456 { "arg", "i", ARG_IN
},
2460 { "AddPersistentGroup", WPAS_DBUS_NEW_IFACE_P2PDEVICE
,
2461 (WPADBusMethodHandler
) wpas_dbus_handler_add_persistent_group
,
2463 { "args", "a{sv}", ARG_IN
},
2464 { "path", "o", ARG_OUT
},
2468 { "RemovePersistentGroup", WPAS_DBUS_NEW_IFACE_P2PDEVICE
,
2469 (WPADBusMethodHandler
) wpas_dbus_handler_remove_persistent_group
,
2471 { "path", "o", ARG_IN
},
2475 { "RemoveAllPersistentGroups", WPAS_DBUS_NEW_IFACE_P2PDEVICE
,
2476 (WPADBusMethodHandler
)
2477 wpas_dbus_handler_remove_all_persistent_groups
,
2482 #endif /* CONFIG_P2P */
2483 { "FlushBSS", WPAS_DBUS_NEW_IFACE_INTERFACE
,
2484 (WPADBusMethodHandler
) &wpas_dbus_handler_flush_bss
,
2486 { "age", "u", ARG_IN
},
2490 { NULL
, NULL
, NULL
, { END_ARGS
} }
2493 static const struct wpa_dbus_property_desc wpas_dbus_interface_properties
[] = {
2494 { "Capabilities", WPAS_DBUS_NEW_IFACE_INTERFACE
, "a{sv}",
2495 wpas_dbus_getter_capabilities
,
2498 { "State", WPAS_DBUS_NEW_IFACE_INTERFACE
, "s",
2499 wpas_dbus_getter_state
,
2502 { "Scanning", WPAS_DBUS_NEW_IFACE_INTERFACE
, "b",
2503 wpas_dbus_getter_scanning
,
2506 { "ApScan", WPAS_DBUS_NEW_IFACE_INTERFACE
, "u",
2507 wpas_dbus_getter_ap_scan
,
2508 wpas_dbus_setter_ap_scan
2510 { "BSSExpireAge", WPAS_DBUS_NEW_IFACE_INTERFACE
, "u",
2511 wpas_dbus_getter_bss_expire_age
,
2512 wpas_dbus_setter_bss_expire_age
2514 { "BSSExpireCount", WPAS_DBUS_NEW_IFACE_INTERFACE
, "u",
2515 wpas_dbus_getter_bss_expire_count
,
2516 wpas_dbus_setter_bss_expire_count
2518 { "Country", WPAS_DBUS_NEW_IFACE_INTERFACE
, "s",
2519 wpas_dbus_getter_country
,
2520 wpas_dbus_setter_country
2522 { "Ifname", WPAS_DBUS_NEW_IFACE_INTERFACE
, "s",
2523 wpas_dbus_getter_ifname
,
2526 { "Driver", WPAS_DBUS_NEW_IFACE_INTERFACE
, "s",
2527 wpas_dbus_getter_driver
,
2530 { "BridgeIfname", WPAS_DBUS_NEW_IFACE_INTERFACE
, "s",
2531 wpas_dbus_getter_bridge_ifname
,
2534 { "CurrentBSS", WPAS_DBUS_NEW_IFACE_INTERFACE
, "o",
2535 wpas_dbus_getter_current_bss
,
2538 { "CurrentNetwork", WPAS_DBUS_NEW_IFACE_INTERFACE
, "o",
2539 wpas_dbus_getter_current_network
,
2542 { "CurrentAuthMode", WPAS_DBUS_NEW_IFACE_INTERFACE
, "s",
2543 wpas_dbus_getter_current_auth_mode
,
2546 { "Blobs", WPAS_DBUS_NEW_IFACE_INTERFACE
, "a{say}",
2547 wpas_dbus_getter_blobs
,
2550 { "BSSs", WPAS_DBUS_NEW_IFACE_INTERFACE
, "ao",
2551 wpas_dbus_getter_bsss
,
2554 { "Networks", WPAS_DBUS_NEW_IFACE_INTERFACE
, "ao",
2555 wpas_dbus_getter_networks
,
2558 { "FastReauth", WPAS_DBUS_NEW_IFACE_INTERFACE
, "b",
2559 wpas_dbus_getter_fast_reauth
,
2560 wpas_dbus_setter_fast_reauth
2563 { "ProcessCredentials", WPAS_DBUS_NEW_IFACE_WPS
, "b",
2564 wpas_dbus_getter_process_credentials
,
2565 wpas_dbus_setter_process_credentials
2567 #endif /* CONFIG_WPS */
2569 { "P2PDeviceProperties", WPAS_DBUS_NEW_IFACE_P2PDEVICE
, "a{sv}",
2570 wpas_dbus_getter_p2p_device_properties
,
2571 wpas_dbus_setter_p2p_device_properties
2573 { "Peers", WPAS_DBUS_NEW_IFACE_P2PDEVICE
, "ao",
2574 wpas_dbus_getter_p2p_peers
,
2577 { "Role", WPAS_DBUS_NEW_IFACE_P2PDEVICE
, "s",
2578 wpas_dbus_getter_p2p_role
,
2581 { "Group", WPAS_DBUS_NEW_IFACE_P2PDEVICE
, "o",
2582 wpas_dbus_getter_p2p_group
,
2585 { "PeerGO", WPAS_DBUS_NEW_IFACE_P2PDEVICE
, "o",
2586 wpas_dbus_getter_p2p_peergo
,
2589 { "PersistentGroups", WPAS_DBUS_NEW_IFACE_P2PDEVICE
, "ao",
2590 wpas_dbus_getter_persistent_groups
,
2593 #endif /* CONFIG_P2P */
2594 { NULL
, NULL
, NULL
, NULL
, NULL
}
2597 static const struct wpa_dbus_signal_desc wpas_dbus_interface_signals
[] = {
2598 { "ScanDone", WPAS_DBUS_NEW_IFACE_INTERFACE
,
2600 { "success", "b", ARG_OUT
},
2604 { "BSSAdded", WPAS_DBUS_NEW_IFACE_INTERFACE
,
2606 { "path", "o", ARG_OUT
},
2607 { "properties", "a{sv}", ARG_OUT
},
2611 { "BSSRemoved", WPAS_DBUS_NEW_IFACE_INTERFACE
,
2613 { "path", "o", ARG_OUT
},
2617 { "BlobAdded", WPAS_DBUS_NEW_IFACE_INTERFACE
,
2619 { "name", "s", ARG_OUT
},
2623 { "BlobRemoved", WPAS_DBUS_NEW_IFACE_INTERFACE
,
2625 { "name", "s", ARG_OUT
},
2629 { "NetworkAdded", WPAS_DBUS_NEW_IFACE_INTERFACE
,
2631 { "path", "o", ARG_OUT
},
2632 { "properties", "a{sv}", ARG_OUT
},
2636 { "NetworkRemoved", WPAS_DBUS_NEW_IFACE_INTERFACE
,
2638 { "path", "o", ARG_OUT
},
2642 { "NetworkSelected", WPAS_DBUS_NEW_IFACE_INTERFACE
,
2644 { "path", "o", ARG_OUT
},
2648 /* Deprecated: use org.freedesktop.DBus.Properties.PropertiesChanged */
2649 { "PropertiesChanged", WPAS_DBUS_NEW_IFACE_INTERFACE
,
2651 { "properties", "a{sv}", ARG_OUT
},
2656 { "Event", WPAS_DBUS_NEW_IFACE_WPS
,
2658 { "name", "s", ARG_OUT
},
2659 { "args", "a{sv}", ARG_OUT
},
2663 { "Credentials", WPAS_DBUS_NEW_IFACE_WPS
,
2665 { "credentials", "a{sv}", ARG_OUT
},
2669 /* Deprecated: use org.freedesktop.DBus.Properties.PropertiesChanged */
2670 { "PropertiesChanged", WPAS_DBUS_NEW_IFACE_WPS
,
2672 { "properties", "a{sv}", ARG_OUT
},
2676 #endif /* CONFIG_WPS */
2678 { "P2PStateChanged", WPAS_DBUS_NEW_IFACE_P2PDEVICE
,
2680 { "states", "a{ss}", ARG_OUT
},
2684 { "DeviceFound", WPAS_DBUS_NEW_IFACE_P2PDEVICE
,
2686 { "path", "o", ARG_OUT
},
2687 { "properties", "a{sv}", ARG_OUT
},
2691 { "DeviceLost", WPAS_DBUS_NEW_IFACE_P2PDEVICE
,
2693 { "path", "o", ARG_OUT
},
2697 { "ProvisionDiscoveryRequestDisplayPin", WPAS_DBUS_NEW_IFACE_P2PDEVICE
,
2699 { "peer_object", "o", ARG_OUT
},
2700 { "pin", "s", ARG_OUT
},
2704 { "ProvisionDiscoveryResponseDisplayPin", WPAS_DBUS_NEW_IFACE_P2PDEVICE
,
2706 { "peer_object", "o", ARG_OUT
},
2707 { "pin", "s", ARG_OUT
},
2711 { "ProvisionDiscoveryRequestEnterPin", WPAS_DBUS_NEW_IFACE_P2PDEVICE
,
2713 { "peer_object", "o", ARG_OUT
},
2717 { "ProvisionDiscoveryResponseEnterPin", WPAS_DBUS_NEW_IFACE_P2PDEVICE
,
2719 { "peer_object", "o", ARG_OUT
},
2723 { "ProvisionDiscoveryPBCRequest", WPAS_DBUS_NEW_IFACE_P2PDEVICE
,
2725 { "peer_object", "o", ARG_OUT
},
2729 { "ProvisionDiscoveryPBCResponse", WPAS_DBUS_NEW_IFACE_P2PDEVICE
,
2731 { "peer_object", "o", ARG_OUT
},
2735 { "ProvisionDiscoveryFailure", WPAS_DBUS_NEW_IFACE_P2PDEVICE
,
2737 { "peer_object", "o", ARG_OUT
},
2738 { "status", "i", ARG_OUT
},
2742 { "GroupStarted", WPAS_DBUS_NEW_IFACE_P2PDEVICE
,
2744 { "properties", "a{sv}", ARG_OUT
},
2748 { "GONegotiationSuccess", WPAS_DBUS_NEW_IFACE_P2PDEVICE
,
2753 { "GONegotiationFailure", WPAS_DBUS_NEW_IFACE_P2PDEVICE
,
2755 { "status", "i", ARG_OUT
},
2759 { "GONegotiationRequest", WPAS_DBUS_NEW_IFACE_P2PDEVICE
,
2761 { "path", "o", ARG_OUT
},
2762 { "dev_passwd_id", "i", ARG_OUT
},
2766 { "InvitationResult", WPAS_DBUS_NEW_IFACE_P2PDEVICE
,
2768 { "invite_result", "a{sv}", ARG_OUT
},
2772 { "GroupFinished", WPAS_DBUS_NEW_IFACE_P2PDEVICE
,
2774 { "ifname", "s", ARG_OUT
},
2775 { "role", "s", ARG_OUT
},
2779 { "ServiceDiscoveryRequest", WPAS_DBUS_NEW_IFACE_P2PDEVICE
,
2781 { "sd_request", "a{sv}", ARG_OUT
},
2785 { "ServiceDiscoveryResponse", WPAS_DBUS_NEW_IFACE_P2PDEVICE
,
2787 { "sd_response", "a{sv}", ARG_OUT
},
2791 { "PersistentGroupAdded", WPAS_DBUS_NEW_IFACE_P2PDEVICE
,
2793 { "path", "o", ARG_OUT
},
2794 { "properties", "a{sv}", ARG_OUT
},
2798 { "PersistentGroupRemoved", WPAS_DBUS_NEW_IFACE_P2PDEVICE
,
2800 { "path", "o", ARG_OUT
},
2804 { "WpsFailed", WPAS_DBUS_NEW_IFACE_P2PDEVICE
,
2806 { "name", "s", ARG_OUT
},
2807 { "args", "a{sv}", ARG_OUT
},
2811 #endif /* CONFIG_P2P */
2812 { "Certification", WPAS_DBUS_NEW_IFACE_INTERFACE
,
2814 { "certification", "a{sv}", ARG_OUT
},
2818 { NULL
, NULL
, { END_ARGS
} }
2822 int wpas_dbus_register_interface(struct wpa_supplicant
*wpa_s
)
2825 struct wpa_dbus_object_desc
*obj_desc
= NULL
;
2826 struct wpas_dbus_priv
*ctrl_iface
= wpa_s
->global
->dbus
;
2829 /* Do nothing if the control interface is not turned on */
2830 if (ctrl_iface
== NULL
)
2833 /* Create and set the interface's object path */
2834 wpa_s
->dbus_new_path
= os_zalloc(WPAS_DBUS_OBJECT_PATH_MAX
);
2835 if (wpa_s
->dbus_new_path
== NULL
)
2837 next
= ctrl_iface
->next_objid
++;
2838 os_snprintf(wpa_s
->dbus_new_path
, WPAS_DBUS_OBJECT_PATH_MAX
,
2839 WPAS_DBUS_NEW_PATH_INTERFACES
"/%u",
2842 obj_desc
= os_zalloc(sizeof(struct wpa_dbus_object_desc
));
2844 wpa_printf(MSG_ERROR
, "Not enough memory "
2845 "to create object description");
2849 wpas_dbus_register(obj_desc
, wpa_s
, NULL
, wpas_dbus_interface_methods
,
2850 wpas_dbus_interface_properties
,
2851 wpas_dbus_interface_signals
);
2853 wpa_printf(MSG_DEBUG
, "dbus: Register interface object '%s'",
2854 wpa_s
->dbus_new_path
);
2855 if (wpa_dbus_register_object_per_iface(ctrl_iface
,
2856 wpa_s
->dbus_new_path
,
2857 wpa_s
->ifname
, obj_desc
))
2860 wpas_dbus_signal_interface_added(wpa_s
);
2865 os_free(wpa_s
->dbus_new_path
);
2866 wpa_s
->dbus_new_path
= NULL
;
2867 free_dbus_object_desc(obj_desc
);
2872 int wpas_dbus_unregister_interface(struct wpa_supplicant
*wpa_s
)
2874 struct wpas_dbus_priv
*ctrl_iface
;
2876 /* Do nothing if the control interface is not turned on */
2877 if (wpa_s
== NULL
|| wpa_s
->global
== NULL
)
2879 ctrl_iface
= wpa_s
->global
->dbus
;
2880 if (ctrl_iface
== NULL
)
2883 wpa_printf(MSG_DEBUG
, "dbus: Unregister interface object '%s'",
2884 wpa_s
->dbus_new_path
);
2885 if (wpa_dbus_unregister_object_per_iface(ctrl_iface
,
2886 wpa_s
->dbus_new_path
))
2889 wpas_dbus_signal_interface_removed(wpa_s
);
2891 os_free(wpa_s
->dbus_new_path
);
2892 wpa_s
->dbus_new_path
= NULL
;
2899 static const struct wpa_dbus_property_desc wpas_dbus_p2p_peer_properties
[] = {
2900 { "DeviceName", WPAS_DBUS_NEW_IFACE_P2P_PEER
, "s",
2901 wpas_dbus_getter_p2p_peer_device_name
,
2904 { "PrimaryDeviceType", WPAS_DBUS_NEW_IFACE_P2P_PEER
, "ay",
2905 wpas_dbus_getter_p2p_peer_primary_device_type
,
2908 { "config_method", WPAS_DBUS_NEW_IFACE_P2P_PEER
, "q",
2909 wpas_dbus_getter_p2p_peer_config_method
,
2912 { "level", WPAS_DBUS_NEW_IFACE_P2P_PEER
, "i",
2913 wpas_dbus_getter_p2p_peer_level
,
2916 { "devicecapability", WPAS_DBUS_NEW_IFACE_P2P_PEER
, "y",
2917 wpas_dbus_getter_p2p_peer_device_capability
,
2920 { "groupcapability", WPAS_DBUS_NEW_IFACE_P2P_PEER
, "y",
2921 wpas_dbus_getter_p2p_peer_group_capability
,
2924 { "SecondaryDeviceTypes", WPAS_DBUS_NEW_IFACE_P2P_PEER
, "aay",
2925 wpas_dbus_getter_p2p_peer_secondary_device_types
,
2928 { "VendorExtension", WPAS_DBUS_NEW_IFACE_P2P_PEER
, "aay",
2929 wpas_dbus_getter_p2p_peer_vendor_extension
,
2932 { "IEs", WPAS_DBUS_NEW_IFACE_P2P_PEER
, "ay",
2933 wpas_dbus_getter_p2p_peer_ies
,
2936 { NULL
, NULL
, NULL
, NULL
, NULL
}
2939 static const struct wpa_dbus_signal_desc wpas_dbus_p2p_peer_signals
[] = {
2941 { NULL
, NULL
, { END_ARGS
} }
2945 * wpas_dbus_signal_peer - Send a peer related event signal
2946 * @wpa_s: %wpa_supplicant network interface data
2947 * @dev: peer device object
2948 * @interface: name of the interface emitting this signal.
2949 * In case of peer objects, it would be emitted by either
2950 * the "interface object" or by "peer objects"
2951 * @sig_name: signal name - DeviceFound
2953 * Notify listeners about event related with newly found p2p peer device
2955 static void wpas_dbus_signal_peer(struct wpa_supplicant
*wpa_s
,
2956 const u8
*dev_addr
, const char *interface
,
2957 const char *sig_name
)
2959 struct wpas_dbus_priv
*iface
;
2961 DBusMessageIter iter
;
2962 char peer_obj_path
[WPAS_DBUS_OBJECT_PATH_MAX
], *path
;
2964 iface
= wpa_s
->global
->dbus
;
2966 /* Do nothing if the control interface is not turned on */
2970 os_snprintf(peer_obj_path
, WPAS_DBUS_OBJECT_PATH_MAX
,
2971 "%s/" WPAS_DBUS_NEW_P2P_PEERS_PART
"/" COMPACT_MACSTR
,
2972 wpa_s
->dbus_new_path
, MAC2STR(dev_addr
));
2974 msg
= dbus_message_new_signal(wpa_s
->dbus_new_path
, interface
,
2979 dbus_message_iter_init_append(msg
, &iter
);
2980 path
= peer_obj_path
;
2981 if (!dbus_message_iter_append_basic(&iter
, DBUS_TYPE_OBJECT_PATH
,
2985 dbus_connection_send(iface
->con
, msg
, NULL
);
2987 dbus_message_unref(msg
);
2991 wpa_printf(MSG_ERROR
, "dbus: Failed to construct signal");
2992 dbus_message_unref(msg
);
2997 * wpas_dbus_signal_peer_found - Send a peer found signal
2998 * @wpa_s: %wpa_supplicant network interface data
2999 * @dev: peer device object
3001 * Notify listeners about find a p2p peer device found
3003 void wpas_dbus_signal_peer_device_found(struct wpa_supplicant
*wpa_s
,
3006 wpas_dbus_signal_peer(wpa_s
, dev_addr
,
3007 WPAS_DBUS_NEW_IFACE_P2PDEVICE
,
3012 * wpas_dbus_signal_peer_lost - Send a peer lost signal
3013 * @wpa_s: %wpa_supplicant network interface data
3014 * @dev: peer device object
3016 * Notify listeners about lost a p2p peer device
3018 void wpas_dbus_signal_peer_device_lost(struct wpa_supplicant
*wpa_s
,
3021 wpas_dbus_signal_peer(wpa_s
, dev_addr
,
3022 WPAS_DBUS_NEW_IFACE_P2PDEVICE
,
3027 * wpas_dbus_register_peer - Register a discovered peer object with dbus
3028 * @wpa_s: wpa_supplicant interface structure
3029 * @ssid: network configuration data
3030 * Returns: 0 on success, -1 on failure
3032 * Registers network representing object with dbus
3034 int wpas_dbus_register_peer(struct wpa_supplicant
*wpa_s
, const u8
*dev_addr
)
3036 struct wpas_dbus_priv
*ctrl_iface
;
3037 struct wpa_dbus_object_desc
*obj_desc
;
3038 struct peer_handler_args
*arg
;
3039 char peer_obj_path
[WPAS_DBUS_OBJECT_PATH_MAX
];
3041 /* Do nothing if the control interface is not turned on */
3042 if (wpa_s
== NULL
|| wpa_s
->global
== NULL
)
3045 ctrl_iface
= wpa_s
->global
->dbus
;
3046 if (ctrl_iface
== NULL
)
3049 os_snprintf(peer_obj_path
, WPAS_DBUS_OBJECT_PATH_MAX
,
3050 "%s/" WPAS_DBUS_NEW_P2P_PEERS_PART
"/" COMPACT_MACSTR
,
3051 wpa_s
->dbus_new_path
, MAC2STR(dev_addr
));
3053 wpa_printf(MSG_INFO
, "dbus: Register peer object '%s'",
3055 obj_desc
= os_zalloc(sizeof(struct wpa_dbus_object_desc
));
3057 wpa_printf(MSG_ERROR
, "Not enough memory "
3058 "to create object description");
3062 /* allocate memory for handlers arguments */
3063 arg
= os_zalloc(sizeof(struct peer_handler_args
));
3065 wpa_printf(MSG_ERROR
, "Not enough memory "
3066 "to create arguments for method");
3071 os_memcpy(arg
->p2p_device_addr
, dev_addr
, ETH_ALEN
);
3073 wpas_dbus_register(obj_desc
, arg
, wpa_dbus_free
,
3075 wpas_dbus_p2p_peer_properties
,
3076 wpas_dbus_p2p_peer_signals
);
3078 if (wpa_dbus_register_object_per_iface(ctrl_iface
, peer_obj_path
,
3079 wpa_s
->ifname
, obj_desc
))
3085 free_dbus_object_desc(obj_desc
);
3090 * wpas_dbus_unregister_peer - Unregister a peer object with dbus
3091 * @wpa_s: wpa_supplicant interface structure
3092 * @dev_addr: p2p device addr
3093 * Returns: 0 on success, -1 on failure
3095 * Registers network representing object with dbus
3097 int wpas_dbus_unregister_peer(struct wpa_supplicant
*wpa_s
,
3100 struct wpas_dbus_priv
*ctrl_iface
;
3101 char peer_obj_path
[WPAS_DBUS_OBJECT_PATH_MAX
];
3104 /* Do nothing if the control interface is not turned on */
3105 if (wpa_s
== NULL
|| wpa_s
->global
== NULL
||
3106 wpa_s
->dbus_new_path
== NULL
)
3108 ctrl_iface
= wpa_s
->global
->dbus
;
3109 if (ctrl_iface
== NULL
)
3112 os_snprintf(peer_obj_path
, WPAS_DBUS_OBJECT_PATH_MAX
,
3113 "%s/" WPAS_DBUS_NEW_P2P_PEERS_PART
"/" COMPACT_MACSTR
,
3114 wpa_s
->dbus_new_path
, MAC2STR(dev_addr
));
3116 wpa_printf(MSG_INFO
, "dbus: Unregister peer object '%s'",
3118 ret
= wpa_dbus_unregister_object_per_iface(ctrl_iface
, peer_obj_path
);
3124 static const struct wpa_dbus_property_desc wpas_dbus_p2p_group_properties
[] = {
3125 { "Members", WPAS_DBUS_NEW_IFACE_P2P_GROUP
, "ao",
3126 wpas_dbus_getter_p2p_group_members
,
3129 { "Group", WPAS_DBUS_NEW_IFACE_P2P_GROUP
, "o",
3130 wpas_dbus_getter_p2p_group
,
3133 { "Role", WPAS_DBUS_NEW_IFACE_P2P_GROUP
, "s",
3134 wpas_dbus_getter_p2p_role
,
3137 { "SSID", WPAS_DBUS_NEW_IFACE_P2P_GROUP
, "ay",
3138 wpas_dbus_getter_p2p_group_ssid
,
3141 { "BSSID", WPAS_DBUS_NEW_IFACE_P2P_GROUP
, "ay",
3142 wpas_dbus_getter_p2p_group_bssid
,
3145 { "Frequency", WPAS_DBUS_NEW_IFACE_P2P_GROUP
, "q",
3146 wpas_dbus_getter_p2p_group_frequency
,
3149 { "Passphrase", WPAS_DBUS_NEW_IFACE_P2P_GROUP
, "s",
3150 wpas_dbus_getter_p2p_group_passphrase
,
3153 { "PSK", WPAS_DBUS_NEW_IFACE_P2P_GROUP
, "ay",
3154 wpas_dbus_getter_p2p_group_psk
,
3157 { "WPSVendorExtensions", WPAS_DBUS_NEW_IFACE_P2P_GROUP
, "aay",
3158 wpas_dbus_getter_p2p_group_vendor_ext
,
3159 wpas_dbus_setter_p2p_group_vendor_ext
3161 { NULL
, NULL
, NULL
, NULL
, NULL
}
3164 static const struct wpa_dbus_signal_desc wpas_dbus_p2p_group_signals
[] = {
3165 { "PeerJoined", WPAS_DBUS_NEW_IFACE_P2P_GROUP
,
3167 { "peer", "o", ARG_OUT
},
3171 { "PeerDisconnected", WPAS_DBUS_NEW_IFACE_P2P_GROUP
,
3173 { "peer", "o", ARG_OUT
},
3177 { NULL
, NULL
, { END_ARGS
} }
3181 * wpas_dbus_register_p2p_group - Register a p2p group object with dbus
3182 * @wpa_s: wpa_supplicant interface structure
3183 * @ssid: SSID struct
3184 * Returns: 0 on success, -1 on failure
3186 * Registers p2p group representing object with dbus
3188 void wpas_dbus_register_p2p_group(struct wpa_supplicant
*wpa_s
,
3189 struct wpa_ssid
*ssid
)
3191 struct wpas_dbus_priv
*ctrl_iface
;
3192 struct wpa_dbus_object_desc
*obj_desc
;
3193 char group_obj_path
[WPAS_DBUS_OBJECT_PATH_MAX
];
3195 /* Do nothing if the control interface is not turned on */
3196 if (wpa_s
== NULL
|| wpa_s
->global
== NULL
)
3199 ctrl_iface
= wpa_s
->global
->dbus
;
3200 if (ctrl_iface
== NULL
)
3203 if (wpa_s
->dbus_groupobj_path
) {
3204 wpa_printf(MSG_INFO
, "%s: Group object '%s' already exists",
3205 __func__
, wpa_s
->dbus_groupobj_path
);
3209 if (wpas_dbus_get_group_obj_path(wpa_s
, ssid
, group_obj_path
) < 0)
3212 wpa_s
->dbus_groupobj_path
= os_strdup(group_obj_path
);
3213 if (wpa_s
->dbus_groupobj_path
== NULL
)
3216 wpa_printf(MSG_INFO
, "dbus: Register group object '%s'",
3218 obj_desc
= os_zalloc(sizeof(struct wpa_dbus_object_desc
));
3220 wpa_printf(MSG_ERROR
, "Not enough memory "
3221 "to create object description");
3225 wpas_dbus_register(obj_desc
, wpa_s
, NULL
, NULL
,
3226 wpas_dbus_p2p_group_properties
,
3227 wpas_dbus_p2p_group_signals
);
3229 if (wpa_dbus_register_object_per_iface(ctrl_iface
, group_obj_path
,
3230 wpa_s
->ifname
, obj_desc
))
3236 if (wpa_s
->dbus_groupobj_path
) {
3237 os_free(wpa_s
->dbus_groupobj_path
);
3238 wpa_s
->dbus_groupobj_path
= NULL
;
3241 free_dbus_object_desc(obj_desc
);
3245 * wpas_dbus_unregister_p2p_group - Unregister a p2p group object from dbus
3246 * @wpa_s: wpa_supplicant interface structure
3247 * @ssid: network name of the p2p group started
3249 void wpas_dbus_unregister_p2p_group(struct wpa_supplicant
*wpa_s
,
3250 const struct wpa_ssid
*ssid
)
3252 struct wpas_dbus_priv
*ctrl_iface
;
3254 /* Do nothing if the control interface is not turned on */
3255 if (wpa_s
== NULL
|| wpa_s
->global
== NULL
)
3258 ctrl_iface
= wpa_s
->global
->dbus
;
3259 if (ctrl_iface
== NULL
)
3262 if (!wpa_s
->dbus_groupobj_path
) {
3263 wpa_printf(MSG_DEBUG
,
3264 "%s: Group object '%s' already unregistered",
3265 __func__
, wpa_s
->dbus_groupobj_path
);
3269 wpa_printf(MSG_DEBUG
, "dbus: Unregister group object '%s'",
3270 wpa_s
->dbus_groupobj_path
);
3272 wpa_dbus_unregister_object_per_iface(ctrl_iface
,
3273 wpa_s
->dbus_groupobj_path
);
3275 os_free(wpa_s
->dbus_groupobj_path
);
3276 wpa_s
->dbus_groupobj_path
= NULL
;
3279 static const struct wpa_dbus_property_desc
3280 wpas_dbus_p2p_groupmember_properties
[] = {
3281 { NULL
, NULL
, NULL
, NULL
, NULL
}
3285 * wpas_dbus_register_p2p_groupmember - Register a p2p groupmember
3287 * @wpa_s: wpa_supplicant interface structure
3288 * @p2p_if_addr: i/f addr of the device joining this group
3290 * Registers p2p groupmember representing object with dbus
3292 void wpas_dbus_register_p2p_groupmember(struct wpa_supplicant
*wpa_s
,
3293 const u8
*p2p_if_addr
)
3295 struct wpas_dbus_priv
*ctrl_iface
;
3296 struct wpa_dbus_object_desc
*obj_desc
= NULL
;
3297 struct groupmember_handler_args
*arg
;
3298 char groupmember_obj_path
[WPAS_DBUS_OBJECT_PATH_MAX
];
3300 /* Do nothing if the control interface is not turned on */
3301 if (wpa_s
== NULL
|| wpa_s
->global
== NULL
)
3304 ctrl_iface
= wpa_s
->global
->dbus
;
3305 if (ctrl_iface
== NULL
)
3308 if (!wpa_s
->dbus_groupobj_path
)
3311 os_snprintf(groupmember_obj_path
, WPAS_DBUS_OBJECT_PATH_MAX
,
3312 "%s/" WPAS_DBUS_NEW_P2P_GROUPMEMBERS_PART
"/" COMPACT_MACSTR
,
3313 wpa_s
->dbus_groupobj_path
, MAC2STR(p2p_if_addr
));
3315 obj_desc
= os_zalloc(sizeof(struct wpa_dbus_object_desc
));
3317 wpa_printf(MSG_ERROR
, "Not enough memory "
3318 "to create object description");
3322 /* allocate memory for handlers arguments */
3323 arg
= os_zalloc(sizeof(struct groupmember_handler_args
));
3325 wpa_printf(MSG_ERROR
, "Not enough memory "
3326 "to create arguments for method");
3331 os_memcpy(arg
->member_addr
, p2p_if_addr
, ETH_ALEN
);
3333 wpas_dbus_register(obj_desc
, arg
, wpa_dbus_free
, NULL
,
3334 wpas_dbus_p2p_groupmember_properties
, NULL
);
3336 if (wpa_dbus_register_object_per_iface(ctrl_iface
, groupmember_obj_path
,
3337 wpa_s
->ifname
, obj_desc
))
3340 wpa_printf(MSG_INFO
,
3341 "dbus: Registered group member object '%s' successfully",
3342 groupmember_obj_path
);
3346 free_dbus_object_desc(obj_desc
);
3350 * wpas_dbus_unregister_p2p_groupmember - Unregister a p2p groupmember
3352 * @wpa_s: wpa_supplicant interface structure
3353 * @p2p_if_addr: i/f addr of the device joining this group
3355 * Unregisters p2p groupmember representing object with dbus
3357 void wpas_dbus_unregister_p2p_groupmember(struct wpa_supplicant
*wpa_s
,
3358 const u8
*p2p_if_addr
)
3360 struct wpas_dbus_priv
*ctrl_iface
;
3361 char groupmember_obj_path
[WPAS_DBUS_OBJECT_PATH_MAX
];
3363 /* Do nothing if the control interface is not turned on */
3364 if (wpa_s
== NULL
|| wpa_s
->global
== NULL
)
3367 ctrl_iface
= wpa_s
->global
->dbus
;
3368 if (ctrl_iface
== NULL
)
3371 if (!wpa_s
->dbus_groupobj_path
)
3374 os_snprintf(groupmember_obj_path
, WPAS_DBUS_OBJECT_PATH_MAX
,
3375 "%s/" WPAS_DBUS_NEW_P2P_GROUPMEMBERS_PART
"/" COMPACT_MACSTR
,
3376 wpa_s
->dbus_groupobj_path
, MAC2STR(p2p_if_addr
));
3378 wpa_dbus_unregister_object_per_iface(ctrl_iface
, groupmember_obj_path
);
3382 static const struct wpa_dbus_property_desc
3383 wpas_dbus_persistent_group_properties
[] = {
3384 { "Properties", WPAS_DBUS_NEW_IFACE_PERSISTENT_GROUP
, "a{sv}",
3385 wpas_dbus_getter_persistent_group_properties
,
3386 wpas_dbus_setter_persistent_group_properties
3388 { NULL
, NULL
, NULL
, NULL
, NULL
}
3391 /* No signals intended for persistent group objects */
3394 * wpas_dbus_register_persistent_group - Register a configured(saved)
3395 * persistent group with dbus
3396 * @wpa_s: wpa_supplicant interface structure
3397 * @ssid: persistent group (still represented as a network within wpa)
3398 * configuration data
3399 * Returns: 0 on success, -1 on failure
3401 * Registers a persistent group representing object with dbus.
3403 int wpas_dbus_register_persistent_group(struct wpa_supplicant
*wpa_s
,
3404 struct wpa_ssid
*ssid
)
3406 struct wpas_dbus_priv
*ctrl_iface
;
3407 struct wpa_dbus_object_desc
*obj_desc
;
3408 struct network_handler_args
*arg
;
3409 char pgrp_obj_path
[WPAS_DBUS_OBJECT_PATH_MAX
];
3411 /* Do nothing if the control interface is not turned on */
3412 if (wpa_s
== NULL
|| wpa_s
->global
== NULL
)
3415 /* Make sure ssid is a persistent group */
3416 if (ssid
->disabled
!= 2 && !ssid
->p2p_persistent_group
)
3417 return -1; /* should we return w/o complaining? */
3419 ctrl_iface
= wpa_s
->global
->dbus
;
3420 if (ctrl_iface
== NULL
)
3424 * Intentionally not coming up with different numbering scheme
3425 * for persistent groups.
3427 os_snprintf(pgrp_obj_path
, WPAS_DBUS_OBJECT_PATH_MAX
,
3428 "%s/" WPAS_DBUS_NEW_PERSISTENT_GROUPS_PART
"/%u",
3429 wpa_s
->dbus_new_path
, ssid
->id
);
3431 wpa_printf(MSG_DEBUG
, "dbus: Register persistent group object '%s'",
3433 obj_desc
= os_zalloc(sizeof(struct wpa_dbus_object_desc
));
3435 wpa_printf(MSG_ERROR
, "dbus: Not enough memory to create "
3436 "object description");
3441 * Reusing the same context structure as that for networks
3442 * since these are represented using same data structure.
3444 /* allocate memory for handlers arguments */
3445 arg
= os_zalloc(sizeof(struct network_handler_args
));
3447 wpa_printf(MSG_ERROR
, "dbus: Not enough memory to create "
3448 "arguments for method");
3455 wpas_dbus_register(obj_desc
, arg
, wpa_dbus_free
, NULL
,
3456 wpas_dbus_persistent_group_properties
,
3459 if (wpa_dbus_register_object_per_iface(ctrl_iface
, pgrp_obj_path
,
3460 wpa_s
->ifname
, obj_desc
))
3463 wpas_dbus_signal_persistent_group_added(wpa_s
, ssid
->id
);
3468 free_dbus_object_desc(obj_desc
);
3474 * wpas_dbus_unregister_persistent_group - Unregister a persistent_group
3476 * @wpa_s: wpa_supplicant interface structure
3478 * Returns: 0 on success, -1 on failure
3480 * Unregisters persistent group representing object from dbus
3482 * NOTE: There is a slight issue with the semantics here. While the
3483 * implementation simply means the persistent group is unloaded from memory,
3484 * it should not get interpreted as the group is actually being erased/removed
3485 * from persistent storage as well.
3487 int wpas_dbus_unregister_persistent_group(struct wpa_supplicant
*wpa_s
,
3490 struct wpas_dbus_priv
*ctrl_iface
;
3491 char pgrp_obj_path
[WPAS_DBUS_OBJECT_PATH_MAX
];
3494 /* Do nothing if the control interface is not turned on */
3495 if (wpa_s
== NULL
|| wpa_s
->global
== NULL
||
3496 wpa_s
->dbus_new_path
== NULL
)
3498 ctrl_iface
= wpa_s
->global
->dbus
;
3499 if (ctrl_iface
== NULL
)
3502 os_snprintf(pgrp_obj_path
, WPAS_DBUS_OBJECT_PATH_MAX
,
3503 "%s/" WPAS_DBUS_NEW_PERSISTENT_GROUPS_PART
"/%u",
3504 wpa_s
->dbus_new_path
, nid
);
3506 wpa_printf(MSG_DEBUG
, "dbus: Unregister persistent group object '%s'",
3508 ret
= wpa_dbus_unregister_object_per_iface(ctrl_iface
, pgrp_obj_path
);
3511 wpas_dbus_signal_persistent_group_removed(wpa_s
, nid
);
3516 #endif /* CONFIG_P2P */