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.h"
31 #include "dbus_common_i.h"
32 #include "dbus_new_handlers_p2p.h"
37 * wpas_dbus_signal_interface - Send a interface related event signal
38 * @wpa_s: %wpa_supplicant network interface data
39 * @sig_name: signal name - InterfaceAdded or InterfaceRemoved
40 * @properties: Whether to add second argument with object properties
42 * Notify listeners about event related with interface
44 static void wpas_dbus_signal_interface(struct wpa_supplicant
*wpa_s
,
45 const char *sig_name
, int properties
)
47 struct wpas_dbus_priv
*iface
;
51 iface
= wpa_s
->global
->dbus
;
53 /* Do nothing if the control interface is not turned on */
57 msg
= dbus_message_new_signal(WPAS_DBUS_NEW_PATH
,
58 WPAS_DBUS_NEW_INTERFACE
, sig_name
);
62 dbus_message_iter_init_append(msg
, &iter
);
63 if (!dbus_message_iter_append_basic(&iter
, DBUS_TYPE_OBJECT_PATH
,
64 &wpa_s
->dbus_new_path
))
68 if (!wpa_dbus_get_object_properties(
69 iface
, wpa_s
->dbus_new_path
,
70 WPAS_DBUS_NEW_IFACE_INTERFACE
, &iter
))
74 dbus_connection_send(iface
->con
, msg
, NULL
);
75 dbus_message_unref(msg
);
79 wpa_printf(MSG_ERROR
, "dbus: Failed to construct signal");
80 dbus_message_unref(msg
);
85 * wpas_dbus_signal_interface_added - Send a interface created signal
86 * @wpa_s: %wpa_supplicant network interface data
88 * Notify listeners about creating new interface
90 static void wpas_dbus_signal_interface_added(struct wpa_supplicant
*wpa_s
)
92 wpas_dbus_signal_interface(wpa_s
, "InterfaceAdded", TRUE
);
97 * wpas_dbus_signal_interface_removed - Send a interface removed signal
98 * @wpa_s: %wpa_supplicant network interface data
100 * Notify listeners about removing interface
102 static void wpas_dbus_signal_interface_removed(struct wpa_supplicant
*wpa_s
)
104 wpas_dbus_signal_interface(wpa_s
, "InterfaceRemoved", FALSE
);
110 * wpas_dbus_signal_scan_done - send scan done signal
111 * @wpa_s: %wpa_supplicant network interface data
112 * @success: indicates if scanning succeed or failed
114 * Notify listeners about finishing a scan
116 void wpas_dbus_signal_scan_done(struct wpa_supplicant
*wpa_s
, int success
)
118 struct wpas_dbus_priv
*iface
;
122 iface
= wpa_s
->global
->dbus
;
124 /* Do nothing if the control interface is not turned on */
128 msg
= dbus_message_new_signal(wpa_s
->dbus_new_path
,
129 WPAS_DBUS_NEW_IFACE_INTERFACE
,
134 succ
= success
? TRUE
: FALSE
;
135 if (dbus_message_append_args(msg
, DBUS_TYPE_BOOLEAN
, &succ
,
137 dbus_connection_send(iface
->con
, msg
, NULL
);
139 wpa_printf(MSG_ERROR
, "dbus: Failed to construct signal");
140 dbus_message_unref(msg
);
145 * wpas_dbus_signal_blob - Send a BSS related event signal
146 * @wpa_s: %wpa_supplicant network interface data
147 * @bss_obj_path: BSS object path
148 * @sig_name: signal name - BSSAdded or BSSRemoved
149 * @properties: Whether to add second argument with object properties
151 * Notify listeners about event related with BSS
153 static void wpas_dbus_signal_bss(struct wpa_supplicant
*wpa_s
,
154 const char *bss_obj_path
,
155 const char *sig_name
, int properties
)
157 struct wpas_dbus_priv
*iface
;
159 DBusMessageIter iter
;
161 iface
= wpa_s
->global
->dbus
;
163 /* Do nothing if the control interface is not turned on */
167 msg
= dbus_message_new_signal(wpa_s
->dbus_new_path
,
168 WPAS_DBUS_NEW_IFACE_INTERFACE
,
173 dbus_message_iter_init_append(msg
, &iter
);
174 if (!dbus_message_iter_append_basic(&iter
, DBUS_TYPE_OBJECT_PATH
,
179 if (!wpa_dbus_get_object_properties(iface
, bss_obj_path
,
180 WPAS_DBUS_NEW_IFACE_BSS
,
185 dbus_connection_send(iface
->con
, msg
, NULL
);
186 dbus_message_unref(msg
);
190 wpa_printf(MSG_ERROR
, "dbus: Failed to construct signal");
191 dbus_message_unref(msg
);
196 * wpas_dbus_signal_bss_added - Send a BSS added signal
197 * @wpa_s: %wpa_supplicant network interface data
198 * @bss_obj_path: new BSS object path
200 * Notify listeners about adding new BSS
202 static void wpas_dbus_signal_bss_added(struct wpa_supplicant
*wpa_s
,
203 const char *bss_obj_path
)
205 wpas_dbus_signal_bss(wpa_s
, bss_obj_path
, "BSSAdded", TRUE
);
210 * wpas_dbus_signal_bss_removed - Send a BSS removed signal
211 * @wpa_s: %wpa_supplicant network interface data
212 * @bss_obj_path: BSS object path
214 * Notify listeners about removing BSS
216 static void wpas_dbus_signal_bss_removed(struct wpa_supplicant
*wpa_s
,
217 const char *bss_obj_path
)
219 wpas_dbus_signal_bss(wpa_s
, bss_obj_path
, "BSSRemoved", FALSE
);
224 * wpas_dbus_signal_blob - Send a blob related event signal
225 * @wpa_s: %wpa_supplicant network interface data
227 * @sig_name: signal name - BlobAdded or BlobRemoved
229 * Notify listeners about event related with blob
231 static void wpas_dbus_signal_blob(struct wpa_supplicant
*wpa_s
,
232 const char *name
, const char *sig_name
)
234 struct wpas_dbus_priv
*iface
;
237 iface
= wpa_s
->global
->dbus
;
239 /* Do nothing if the control interface is not turned on */
243 msg
= dbus_message_new_signal(wpa_s
->dbus_new_path
,
244 WPAS_DBUS_NEW_IFACE_INTERFACE
,
249 if (dbus_message_append_args(msg
, DBUS_TYPE_STRING
, &name
,
251 dbus_connection_send(iface
->con
, msg
, NULL
);
253 wpa_printf(MSG_ERROR
, "dbus: Failed to construct signal");
254 dbus_message_unref(msg
);
259 * wpas_dbus_signal_blob_added - Send a blob added signal
260 * @wpa_s: %wpa_supplicant network interface data
263 * Notify listeners about adding a new blob
265 void wpas_dbus_signal_blob_added(struct wpa_supplicant
*wpa_s
,
268 wpas_dbus_signal_blob(wpa_s
, name
, "BlobAdded");
273 * wpas_dbus_signal_blob_removed - Send a blob removed signal
274 * @wpa_s: %wpa_supplicant network interface data
277 * Notify listeners about removing blob
279 void wpas_dbus_signal_blob_removed(struct wpa_supplicant
*wpa_s
,
282 wpas_dbus_signal_blob(wpa_s
, name
, "BlobRemoved");
287 * wpas_dbus_signal_network - Send a network related event signal
288 * @wpa_s: %wpa_supplicant network interface data
289 * @id: new network id
290 * @sig_name: signal name - NetworkAdded, NetworkRemoved or NetworkSelected
291 * @properties: determines if add second argument with object properties
293 * Notify listeners about event related with configured network
295 static void wpas_dbus_signal_network(struct wpa_supplicant
*wpa_s
,
296 int id
, const char *sig_name
,
299 struct wpas_dbus_priv
*iface
;
301 DBusMessageIter iter
;
302 char net_obj_path
[WPAS_DBUS_OBJECT_PATH_MAX
], *path
;
304 iface
= wpa_s
->global
->dbus
;
306 /* Do nothing if the control interface is not turned on */
310 os_snprintf(net_obj_path
, WPAS_DBUS_OBJECT_PATH_MAX
,
311 "%s/" WPAS_DBUS_NEW_NETWORKS_PART
"/%u",
312 wpa_s
->dbus_new_path
, id
);
314 msg
= dbus_message_new_signal(wpa_s
->dbus_new_path
,
315 WPAS_DBUS_NEW_IFACE_INTERFACE
,
320 dbus_message_iter_init_append(msg
, &iter
);
322 if (!dbus_message_iter_append_basic(&iter
, DBUS_TYPE_OBJECT_PATH
,
327 if (!wpa_dbus_get_object_properties(
328 iface
, net_obj_path
, WPAS_DBUS_NEW_IFACE_NETWORK
,
333 dbus_connection_send(iface
->con
, msg
, NULL
);
335 dbus_message_unref(msg
);
339 wpa_printf(MSG_ERROR
, "dbus: Failed to construct signal");
340 dbus_message_unref(msg
);
345 * wpas_dbus_signal_network_added - Send a network added signal
346 * @wpa_s: %wpa_supplicant network interface data
347 * @id: new network id
349 * Notify listeners about adding new network
351 static void wpas_dbus_signal_network_added(struct wpa_supplicant
*wpa_s
,
354 wpas_dbus_signal_network(wpa_s
, id
, "NetworkAdded", TRUE
);
359 * wpas_dbus_signal_network_removed - Send a network removed signal
360 * @wpa_s: %wpa_supplicant network interface data
363 * Notify listeners about removing a network
365 static void wpas_dbus_signal_network_removed(struct wpa_supplicant
*wpa_s
,
368 wpas_dbus_signal_network(wpa_s
, id
, "NetworkRemoved", FALSE
);
373 * wpas_dbus_signal_network_selected - Send a network selected signal
374 * @wpa_s: %wpa_supplicant network interface data
377 * Notify listeners about selecting a network
379 void wpas_dbus_signal_network_selected(struct wpa_supplicant
*wpa_s
, int id
)
381 wpas_dbus_signal_network(wpa_s
, id
, "NetworkSelected", FALSE
);
386 * wpas_dbus_signal_network_request - Indicate that additional information
387 * (EAP password, etc.) is required to complete the association to this SSID
388 * @wpa_s: %wpa_supplicant network interface data
389 * @rtype: The specific additional information required
390 * @default_text: Optional description of required information
392 * Request additional information or passwords to complete an association
395 void wpas_dbus_signal_network_request(struct wpa_supplicant
*wpa_s
,
396 struct wpa_ssid
*ssid
,
397 enum wpa_ctrl_req_type rtype
,
398 const char *default_txt
)
400 struct wpas_dbus_priv
*iface
;
402 DBusMessageIter iter
;
403 char net_obj_path
[WPAS_DBUS_OBJECT_PATH_MAX
];
404 const char *field
, *txt
= NULL
, *net_ptr
;
406 iface
= wpa_s
->global
->dbus
;
408 /* Do nothing if the control interface is not turned on */
412 field
= wpa_supplicant_ctrl_req_to_string(rtype
, default_txt
, &txt
);
416 msg
= dbus_message_new_signal(wpa_s
->dbus_new_path
,
417 WPAS_DBUS_NEW_IFACE_INTERFACE
,
422 os_snprintf(net_obj_path
, WPAS_DBUS_OBJECT_PATH_MAX
,
423 "%s/" WPAS_DBUS_NEW_NETWORKS_PART
"/%u",
424 wpa_s
->dbus_new_path
, ssid
->id
);
425 net_ptr
= &net_obj_path
[0];
427 dbus_message_iter_init_append(msg
, &iter
);
428 if (!dbus_message_iter_append_basic(&iter
, DBUS_TYPE_OBJECT_PATH
,
431 if (!dbus_message_iter_append_basic(&iter
, DBUS_TYPE_STRING
, &field
))
433 if (!dbus_message_iter_append_basic(&iter
, DBUS_TYPE_STRING
, &txt
))
436 dbus_connection_send(iface
->con
, msg
, NULL
);
437 dbus_message_unref(msg
);
441 wpa_printf(MSG_ERROR
, "dbus: Failed to construct signal");
442 dbus_message_unref(msg
);
447 * wpas_dbus_signal_network_enabled_changed - Signals Enabled property changes
448 * @wpa_s: %wpa_supplicant network interface data
449 * @ssid: configured network which Enabled property has changed
451 * Sends PropertyChanged signals containing new value of Enabled property
452 * for specified network
454 void wpas_dbus_signal_network_enabled_changed(struct wpa_supplicant
*wpa_s
,
455 struct wpa_ssid
*ssid
)
458 char path
[WPAS_DBUS_OBJECT_PATH_MAX
];
459 os_snprintf(path
, WPAS_DBUS_OBJECT_PATH_MAX
,
460 "%s/" WPAS_DBUS_NEW_NETWORKS_PART
"/%d",
461 wpa_s
->dbus_new_path
, ssid
->id
);
463 wpa_dbus_mark_property_changed(wpa_s
->global
->dbus
, path
,
464 WPAS_DBUS_NEW_IFACE_NETWORK
, "Enabled");
471 * wpas_dbus_signal_wps_event_success - Signals Success WPS event
472 * @wpa_s: %wpa_supplicant network interface data
474 * Sends Event dbus signal with name "success" and empty dict as arguments
476 void wpas_dbus_signal_wps_event_success(struct wpa_supplicant
*wpa_s
)
480 DBusMessageIter iter
, dict_iter
;
481 struct wpas_dbus_priv
*iface
;
482 char *key
= "success";
484 iface
= wpa_s
->global
->dbus
;
486 /* Do nothing if the control interface is not turned on */
490 msg
= dbus_message_new_signal(wpa_s
->dbus_new_path
,
491 WPAS_DBUS_NEW_IFACE_WPS
, "Event");
495 dbus_message_iter_init_append(msg
, &iter
);
497 if (!dbus_message_iter_append_basic(&iter
, DBUS_TYPE_STRING
, &key
) ||
498 !wpa_dbus_dict_open_write(&iter
, &dict_iter
) ||
499 !wpa_dbus_dict_close_write(&iter
, &dict_iter
))
500 wpa_printf(MSG_ERROR
, "dbus: Failed to construct signal");
502 dbus_connection_send(iface
->con
, msg
, NULL
);
504 dbus_message_unref(msg
);
509 * wpas_dbus_signal_wps_event_fail - Signals Fail WPS event
510 * @wpa_s: %wpa_supplicant network interface data
512 * Sends Event dbus signal with name "fail" and dictionary containing
513 * "msg field with fail message number (int32) as arguments
515 void wpas_dbus_signal_wps_event_fail(struct wpa_supplicant
*wpa_s
,
516 struct wps_event_fail
*fail
)
520 DBusMessageIter iter
, dict_iter
;
521 struct wpas_dbus_priv
*iface
;
524 iface
= wpa_s
->global
->dbus
;
526 /* Do nothing if the control interface is not turned on */
530 msg
= dbus_message_new_signal(wpa_s
->dbus_new_path
,
531 WPAS_DBUS_NEW_IFACE_WPS
, "Event");
535 dbus_message_iter_init_append(msg
, &iter
);
537 if (!dbus_message_iter_append_basic(&iter
, DBUS_TYPE_STRING
, &key
) ||
538 !wpa_dbus_dict_open_write(&iter
, &dict_iter
) ||
539 !wpa_dbus_dict_append_int32(&dict_iter
, "msg", fail
->msg
) ||
540 !wpa_dbus_dict_close_write(&iter
, &dict_iter
))
541 wpa_printf(MSG_ERROR
, "dbus: Failed to construct signal");
543 dbus_connection_send(iface
->con
, msg
, NULL
);
545 dbus_message_unref(msg
);
550 * wpas_dbus_signal_wps_event_m2d - Signals M2D WPS event
551 * @wpa_s: %wpa_supplicant network interface data
553 * Sends Event dbus signal with name "m2d" and dictionary containing
554 * fields of wps_event_m2d structure.
556 void wpas_dbus_signal_wps_event_m2d(struct wpa_supplicant
*wpa_s
,
557 struct wps_event_m2d
*m2d
)
561 DBusMessageIter iter
, dict_iter
;
562 struct wpas_dbus_priv
*iface
;
565 iface
= wpa_s
->global
->dbus
;
567 /* Do nothing if the control interface is not turned on */
571 msg
= dbus_message_new_signal(wpa_s
->dbus_new_path
,
572 WPAS_DBUS_NEW_IFACE_WPS
, "Event");
576 dbus_message_iter_init_append(msg
, &iter
);
578 if (!dbus_message_iter_append_basic(&iter
, DBUS_TYPE_STRING
, &key
) ||
579 !wpa_dbus_dict_open_write(&iter
, &dict_iter
) ||
580 !wpa_dbus_dict_append_uint16(&dict_iter
, "config_methods",
581 m2d
->config_methods
) ||
582 !wpa_dbus_dict_append_byte_array(&dict_iter
, "manufacturer",
583 (const char *) m2d
->manufacturer
,
584 m2d
->manufacturer_len
) ||
585 !wpa_dbus_dict_append_byte_array(&dict_iter
, "model_name",
586 (const char *) m2d
->model_name
,
587 m2d
->model_name_len
) ||
588 !wpa_dbus_dict_append_byte_array(&dict_iter
, "model_number",
589 (const char *) m2d
->model_number
,
590 m2d
->model_number_len
) ||
591 !wpa_dbus_dict_append_byte_array(&dict_iter
, "serial_number",
594 m2d
->serial_number_len
) ||
595 !wpa_dbus_dict_append_byte_array(&dict_iter
, "dev_name",
596 (const char *) m2d
->dev_name
,
597 m2d
->dev_name_len
) ||
598 !wpa_dbus_dict_append_byte_array(&dict_iter
, "primary_dev_type",
600 m2d
->primary_dev_type
, 8) ||
601 !wpa_dbus_dict_append_uint16(&dict_iter
, "config_error",
602 m2d
->config_error
) ||
603 !wpa_dbus_dict_append_uint16(&dict_iter
, "dev_password_id",
604 m2d
->dev_password_id
) ||
605 !wpa_dbus_dict_close_write(&iter
, &dict_iter
))
606 wpa_printf(MSG_ERROR
, "dbus: Failed to construct signal");
608 dbus_connection_send(iface
->con
, msg
, NULL
);
610 dbus_message_unref(msg
);
615 * wpas_dbus_signal_wps_cred - Signals new credentials
616 * @wpa_s: %wpa_supplicant network interface data
618 * Sends signal with credentials in directory argument
620 void wpas_dbus_signal_wps_cred(struct wpa_supplicant
*wpa_s
,
621 const struct wps_credential
*cred
)
624 DBusMessageIter iter
, dict_iter
;
625 struct wpas_dbus_priv
*iface
;
626 char *auth_type
[6]; /* we have six possible authorization types */
628 char *encr_type
[4]; /* we have four possible encryption types */
631 iface
= wpa_s
->global
->dbus
;
633 /* Do nothing if the control interface is not turned on */
637 msg
= dbus_message_new_signal(wpa_s
->dbus_new_path
,
638 WPAS_DBUS_NEW_IFACE_WPS
,
643 dbus_message_iter_init_append(msg
, &iter
);
644 if (!wpa_dbus_dict_open_write(&iter
, &dict_iter
))
647 if (cred
->auth_type
& WPS_AUTH_OPEN
)
648 auth_type
[at_num
++] = "open";
649 if (cred
->auth_type
& WPS_AUTH_WPAPSK
)
650 auth_type
[at_num
++] = "wpa-psk";
651 if (cred
->auth_type
& WPS_AUTH_SHARED
)
652 auth_type
[at_num
++] = "shared";
653 if (cred
->auth_type
& WPS_AUTH_WPA
)
654 auth_type
[at_num
++] = "wpa-eap";
655 if (cred
->auth_type
& WPS_AUTH_WPA2
)
656 auth_type
[at_num
++] = "wpa2-eap";
657 if (cred
->auth_type
& WPS_AUTH_WPA2PSK
)
658 auth_type
[at_num
++] =
661 if (cred
->encr_type
& WPS_ENCR_NONE
)
662 encr_type
[et_num
++] = "none";
663 if (cred
->encr_type
& WPS_ENCR_WEP
)
664 encr_type
[et_num
++] = "wep";
665 if (cred
->encr_type
& WPS_ENCR_TKIP
)
666 encr_type
[et_num
++] = "tkip";
667 if (cred
->encr_type
& WPS_ENCR_AES
)
668 encr_type
[et_num
++] = "aes";
670 if (wpa_s
->current_ssid
) {
671 if (!wpa_dbus_dict_append_byte_array(
673 (const char *) wpa_s
->current_ssid
->bssid
,
678 if (!wpa_dbus_dict_append_byte_array(&dict_iter
, "SSID",
679 (const char *) cred
->ssid
,
681 !wpa_dbus_dict_append_string_array(&dict_iter
, "AuthType",
682 (const char **) auth_type
,
684 !wpa_dbus_dict_append_string_array(&dict_iter
, "EncrType",
685 (const char **) encr_type
,
687 !wpa_dbus_dict_append_byte_array(&dict_iter
, "Key",
688 (const char *) cred
->key
,
690 !wpa_dbus_dict_append_uint32(&dict_iter
, "KeyIndex",
692 !wpa_dbus_dict_close_write(&iter
, &dict_iter
))
695 dbus_connection_send(iface
->con
, msg
, NULL
);
698 dbus_message_unref(msg
);
701 #endif /* CONFIG_WPS */
703 void wpas_dbus_signal_certification(struct wpa_supplicant
*wpa_s
,
704 int depth
, const char *subject
,
705 const char *cert_hash
,
706 const struct wpabuf
*cert
)
708 struct wpas_dbus_priv
*iface
;
710 DBusMessageIter iter
, dict_iter
;
712 iface
= wpa_s
->global
->dbus
;
714 /* Do nothing if the control interface is not turned on */
718 msg
= dbus_message_new_signal(wpa_s
->dbus_new_path
,
719 WPAS_DBUS_NEW_IFACE_INTERFACE
,
724 dbus_message_iter_init_append(msg
, &iter
);
725 if (!wpa_dbus_dict_open_write(&iter
, &dict_iter
))
728 if (!wpa_dbus_dict_append_uint32(&dict_iter
, "depth", depth
) ||
729 !wpa_dbus_dict_append_string(&dict_iter
, "subject", subject
))
733 !wpa_dbus_dict_append_string(&dict_iter
, "cert_hash", cert_hash
))
737 !wpa_dbus_dict_append_byte_array(&dict_iter
, "cert",
742 if (!wpa_dbus_dict_close_write(&iter
, &dict_iter
))
745 dbus_connection_send(iface
->con
, msg
, NULL
);
748 dbus_message_unref(msg
);
754 * wpas_dbus_signal_p2p_group_removed - Signals P2P group was removed
755 * @wpa_s: %wpa_supplicant network interface data
756 * @role: role of this device (client or GO)
757 * Sends signal with i/f name and role as string arguments
759 void wpas_dbus_signal_p2p_group_removed(struct wpa_supplicant
*wpa_s
,
764 DBusMessageIter iter
;
765 struct wpas_dbus_priv
*iface
= wpa_s
->global
->dbus
;
766 char *ifname
= wpa_s
->ifname
;
768 /* Do nothing if the control interface is not turned on */
772 msg
= dbus_message_new_signal(wpa_s
->dbus_new_path
,
773 WPAS_DBUS_NEW_IFACE_P2PDEVICE
,
778 dbus_message_iter_init_append(msg
, &iter
);
780 if (!dbus_message_iter_append_basic(&iter
, DBUS_TYPE_STRING
, &ifname
)) {
781 wpa_printf(MSG_ERROR
, "dbus: Failed to construct GroupFinished"
782 "signal -not enough memory for ifname ");
786 if (!dbus_message_iter_append_basic(&iter
, DBUS_TYPE_STRING
, &role
))
787 wpa_printf(MSG_ERROR
, "dbus: Failed to construct GroupFinished"
788 "signal -not enough memory for role ");
790 dbus_connection_send(iface
->con
, msg
, NULL
);
793 dbus_message_unref(msg
);
798 * wpas_dbus_signal_p2p_provision_discovery - Signals various PD events
800 * @dev_addr - who sent the request or responded to our request.
801 * @request - Will be 1 if request, 0 for response.
802 * @status - valid only in case of response
803 * @config_methods - wps config methods
804 * @generated_pin - pin to be displayed in case of WPS_CONFIG_DISPLAY method
806 * Sends following provision discovery related events:
807 * ProvisionDiscoveryRequestDisplayPin
808 * ProvisionDiscoveryResponseDisplayPin
809 * ProvisionDiscoveryRequestEnterPin
810 * ProvisionDiscoveryResponseEnterPin
811 * ProvisionDiscoveryPBCRequest
812 * ProvisionDiscoveryPBCResponse
815 * ProvisionDiscoveryFailure (timeout case)
817 void wpas_dbus_signal_p2p_provision_discovery(struct wpa_supplicant
*wpa_s
,
818 const u8
*dev_addr
, int request
,
819 enum p2p_prov_disc_status status
,
821 unsigned int generated_pin
)
824 DBusMessageIter iter
;
825 struct wpas_dbus_priv
*iface
;
828 char peer_obj_path
[WPAS_DBUS_OBJECT_PATH_MAX
], *path
;
830 char pin
[9], *p_pin
= NULL
;
832 iface
= wpa_s
->global
->dbus
;
834 /* Do nothing if the control interface is not turned on */
838 if (request
|| !status
) {
839 if (config_methods
& WPS_CONFIG_DISPLAY
)
841 "ProvisionDiscoveryRequestDisplayPin" :
842 "ProvisionDiscoveryResponseEnterPin";
843 else if (config_methods
& WPS_CONFIG_KEYPAD
)
845 "ProvisionDiscoveryRequestEnterPin" :
846 "ProvisionDiscoveryResponseDisplayPin";
847 else if (config_methods
& WPS_CONFIG_PUSHBUTTON
)
848 _signal
= request
? "ProvisionDiscoveryPBCRequest" :
849 "ProvisionDiscoveryPBCResponse";
851 return; /* Unknown or un-supported method */
852 } else if (!request
&& status
)
853 /* Explicit check for failure response */
854 _signal
= "ProvisionDiscoveryFailure";
856 add_pin
= ((request
&& (config_methods
& WPS_CONFIG_DISPLAY
)) ||
857 (!request
&& !status
&&
858 (config_methods
& WPS_CONFIG_KEYPAD
)));
861 os_snprintf(pin
, sizeof(pin
), "%08d", generated_pin
);
865 msg
= dbus_message_new_signal(wpa_s
->dbus_new_path
,
866 WPAS_DBUS_NEW_IFACE_P2PDEVICE
, _signal
);
870 /* Check if this is a known peer */
871 if (p2p_get_peer_info(wpa_s
->global
->p2p
, dev_addr
, 0, NULL
, 0) < 0)
874 os_snprintf(peer_obj_path
, WPAS_DBUS_OBJECT_PATH_MAX
,
875 "%s/" WPAS_DBUS_NEW_P2P_PEERS_PART
"/"
877 wpa_s
->dbus_new_path
, MAC2STR(dev_addr
));
879 path
= peer_obj_path
;
881 dbus_message_iter_init_append(msg
, &iter
);
883 if (!dbus_message_iter_append_basic(&iter
,
884 DBUS_TYPE_OBJECT_PATH
,
888 if (!request
&& status
)
889 /* Attach status to ProvisionDiscoveryFailure */
890 error_ret
= !dbus_message_iter_append_basic(&iter
,
894 error_ret
= (add_pin
&&
895 !dbus_message_iter_append_basic(&iter
,
901 dbus_connection_send(iface
->con
, msg
, NULL
);
903 wpa_printf(MSG_ERROR
, "dbus: Failed to construct signal");
905 dbus_message_unref(msg
);
909 void wpas_dbus_signal_p2p_go_neg_req(struct wpa_supplicant
*wpa_s
,
910 const u8
*src
, u16 dev_passwd_id
)
913 DBusMessageIter iter
;
914 struct wpas_dbus_priv
*iface
;
915 char peer_obj_path
[WPAS_DBUS_OBJECT_PATH_MAX
], *path
;
917 iface
= wpa_s
->global
->dbus
;
919 /* Do nothing if the control interface is not turned on */
923 os_snprintf(peer_obj_path
, WPAS_DBUS_OBJECT_PATH_MAX
,
924 "%s/" WPAS_DBUS_NEW_P2P_PEERS_PART
"/" COMPACT_MACSTR
,
925 wpa_s
->dbus_new_path
, MAC2STR(src
));
926 path
= peer_obj_path
;
928 msg
= dbus_message_new_signal(wpa_s
->dbus_new_path
,
929 WPAS_DBUS_NEW_IFACE_P2PDEVICE
,
930 "GONegotiationRequest");
934 dbus_message_iter_init_append(msg
, &iter
);
936 if (!dbus_message_iter_append_basic(&iter
, DBUS_TYPE_OBJECT_PATH
,
938 !dbus_message_iter_append_basic(&iter
, DBUS_TYPE_UINT16
,
940 wpa_printf(MSG_ERROR
, "dbus: Failed to construct signal");
942 dbus_connection_send(iface
->con
, msg
, NULL
);
944 dbus_message_unref(msg
);
948 static int wpas_dbus_get_group_obj_path(struct wpa_supplicant
*wpa_s
,
949 const struct wpa_ssid
*ssid
,
950 char *group_obj_path
)
954 if (os_memcmp(ssid
->ssid
, P2P_WILDCARD_SSID
, P2P_WILDCARD_SSID_LEN
))
957 memcpy(group_name
, ssid
->ssid
+ P2P_WILDCARD_SSID_LEN
, 2);
958 group_name
[2] = '\0';
960 os_snprintf(group_obj_path
, WPAS_DBUS_OBJECT_PATH_MAX
,
961 "%s/" WPAS_DBUS_NEW_P2P_GROUPS_PART
"/%s",
962 wpa_s
->dbus_new_path
, group_name
);
969 * wpas_dbus_signal_p2p_group_started - Signals P2P group has
970 * started. Emitted when a group is successfully started
971 * irrespective of the role (client/GO) of the current device
973 * @wpa_s: %wpa_supplicant network interface data
975 * @client: this device is P2P client
976 * @network_id: network id of the group started, use instead of ssid->id
977 * to account for persistent groups
979 void wpas_dbus_signal_p2p_group_started(struct wpa_supplicant
*wpa_s
,
980 const struct wpa_ssid
*ssid
,
981 int client
, int network_id
)
984 DBusMessageIter iter
, dict_iter
;
985 struct wpas_dbus_priv
*iface
;
986 char net_obj_path
[WPAS_DBUS_OBJECT_PATH_MAX
];
987 char group_obj_path
[WPAS_DBUS_OBJECT_PATH_MAX
];
989 iface
= wpa_s
->parent
->global
->dbus
;
991 /* Do nothing if the control interface is not turned on */
995 if (wpas_dbus_get_group_obj_path(wpa_s
, ssid
, group_obj_path
) < 0)
998 /* New interface has been created for this group */
999 msg
= dbus_message_new_signal(wpa_s
->parent
->dbus_new_path
,
1000 WPAS_DBUS_NEW_IFACE_P2PDEVICE
,
1006 dbus_message_iter_init_append(msg
, &iter
);
1007 if (!wpa_dbus_dict_open_write(&iter
, &dict_iter
))
1011 * In case the device supports creating a separate interface the
1012 * DBus client will need to know the object path for the interface
1013 * object this group was created on, so include it here.
1015 if (!wpa_dbus_dict_append_object_path(&dict_iter
,
1017 wpa_s
->dbus_new_path
))
1020 if (!wpa_dbus_dict_append_string(&dict_iter
, "role",
1021 client
? "client" : "GO"))
1024 os_snprintf(net_obj_path
, WPAS_DBUS_OBJECT_PATH_MAX
,
1025 "%s/" WPAS_DBUS_NEW_NETWORKS_PART
"/%u",
1026 wpa_s
->parent
->dbus_new_path
, network_id
);
1028 if (!wpa_dbus_dict_append_object_path(&dict_iter
, "group_object",
1030 !wpa_dbus_dict_append_object_path(&dict_iter
, "network_object",
1032 !wpa_dbus_dict_close_write(&iter
, &dict_iter
))
1035 dbus_connection_send(iface
->con
, msg
, NULL
);
1038 dbus_message_unref(msg
);
1044 * Method to emit GONeogtiation Success or Failure signals based
1046 * @status: Status of the GO neg request. 0 for success, other for errors.
1048 void wpas_dbus_signal_p2p_go_neg_resp(struct wpa_supplicant
*wpa_s
, int status
)
1051 DBusMessageIter iter
;
1052 struct wpas_dbus_priv
*iface
;
1054 iface
= wpa_s
->global
->dbus
;
1056 /* Do nothing if the control interface is not turned on */
1060 msg
= dbus_message_new_signal(wpa_s
->dbus_new_path
,
1061 WPAS_DBUS_NEW_IFACE_P2PDEVICE
,
1062 status
? "GONegotiationFailure" :
1063 "GONegotiationSuccess");
1068 dbus_message_iter_init_append(msg
, &iter
);
1069 if (!dbus_message_iter_append_basic(&iter
, DBUS_TYPE_INT32
,
1071 wpa_printf(MSG_ERROR
,
1072 "dbus: Failed to construct signal");
1077 dbus_connection_send(iface
->con
, msg
, NULL
);
1079 dbus_message_unref(msg
);
1085 * Method to emit Invitation Result signal based on status and
1087 * @status: Status of the Invite request. 0 for success, other
1089 * @bssid : Basic Service Set Identifier
1091 void wpas_dbus_signal_p2p_invitation_result(struct wpa_supplicant
*wpa_s
,
1092 int status
, const u8
*bssid
)
1095 DBusMessageIter iter
, dict_iter
;
1096 struct wpas_dbus_priv
*iface
;
1098 wpa_printf(MSG_INFO
, "%s\n", __func__
);
1100 iface
= wpa_s
->global
->dbus
;
1101 /* Do nothing if the control interface is not turned on */
1105 msg
= dbus_message_new_signal(wpa_s
->dbus_new_path
,
1106 WPAS_DBUS_NEW_IFACE_P2PDEVICE
,
1107 "InvitationResult");
1112 dbus_message_iter_init_append(msg
, &iter
);
1113 if (!wpa_dbus_dict_open_write(&iter
, &dict_iter
))
1116 if (!wpa_dbus_dict_append_int32(&dict_iter
, "status", status
))
1119 if (!wpa_dbus_dict_append_byte_array(&dict_iter
, "BSSID",
1120 (const char *) bssid
,
1124 if (!wpa_dbus_dict_close_write(&iter
, &dict_iter
))
1127 dbus_connection_send(iface
->con
, msg
, NULL
);
1130 dbus_message_unref(msg
);
1136 * Method to emit a signal for a peer joining the group.
1137 * The signal will carry path to the group member object
1138 * constructed using p2p i/f addr used for connecting.
1140 * @wpa_s: %wpa_supplicant network interface data
1141 * @member_addr: addr (p2p i/f) of the peer joining the group
1143 void wpas_dbus_signal_p2p_peer_joined(struct wpa_supplicant
*wpa_s
,
1146 struct wpas_dbus_priv
*iface
;
1148 DBusMessageIter iter
;
1149 char groupmember_obj_path
[WPAS_DBUS_OBJECT_PATH_MAX
], *path
;
1151 iface
= wpa_s
->global
->dbus
;
1153 /* Do nothing if the control interface is not turned on */
1157 if (!wpa_s
->dbus_groupobj_path
)
1160 os_snprintf(groupmember_obj_path
, WPAS_DBUS_OBJECT_PATH_MAX
,
1161 "%s/" WPAS_DBUS_NEW_P2P_GROUPMEMBERS_PART
"/"
1163 wpa_s
->dbus_groupobj_path
, MAC2STR(member
));
1165 msg
= dbus_message_new_signal(wpa_s
->dbus_groupobj_path
,
1166 WPAS_DBUS_NEW_IFACE_P2P_GROUP
,
1171 dbus_message_iter_init_append(msg
, &iter
);
1172 path
= groupmember_obj_path
;
1173 if (!dbus_message_iter_append_basic(&iter
, DBUS_TYPE_OBJECT_PATH
,
1177 dbus_connection_send(iface
->con
, msg
, NULL
);
1179 dbus_message_unref(msg
);
1183 wpa_printf(MSG_ERROR
, "dbus: Failed to construct signal");
1184 dbus_message_unref(msg
);
1190 * Method to emit a signal for a peer disconnecting the group.
1191 * The signal will carry path to the group member object
1192 * constructed using p2p i/f addr used for connecting.
1194 * @wpa_s: %wpa_supplicant network interface data
1195 * @member_addr: addr (p2p i/f) of the peer joining the group
1197 void wpas_dbus_signal_p2p_peer_disconnected(struct wpa_supplicant
*wpa_s
,
1200 struct wpas_dbus_priv
*iface
;
1202 DBusMessageIter iter
;
1203 char groupmember_obj_path
[WPAS_DBUS_OBJECT_PATH_MAX
], *path
;
1205 iface
= wpa_s
->global
->dbus
;
1207 /* Do nothing if the control interface is not turned on */
1211 if (!wpa_s
->dbus_groupobj_path
)
1214 os_snprintf(groupmember_obj_path
, WPAS_DBUS_OBJECT_PATH_MAX
,
1215 "%s/" WPAS_DBUS_NEW_P2P_GROUPMEMBERS_PART
"/"
1217 wpa_s
->dbus_groupobj_path
, MAC2STR(member
));
1219 msg
= dbus_message_new_signal(wpa_s
->dbus_groupobj_path
,
1220 WPAS_DBUS_NEW_IFACE_P2P_GROUP
,
1221 "PeerDisconnected");
1225 dbus_message_iter_init_append(msg
, &iter
);
1226 path
= groupmember_obj_path
;
1227 if (!dbus_message_iter_append_basic(&iter
, DBUS_TYPE_OBJECT_PATH
,
1231 dbus_connection_send(iface
->con
, msg
, NULL
);
1233 dbus_message_unref(msg
);
1237 wpa_printf(MSG_ERROR
, "dbus: Failed to construct PeerDisconnected "
1239 dbus_message_unref(msg
);
1245 * Method to emit a signal for a service discovery request.
1246 * The signal will carry station address, frequency, dialog token,
1247 * update indicator and it tlvs
1249 * @wpa_s: %wpa_supplicant network interface data
1250 * @sa: station addr (p2p i/f) of the peer
1251 * @dialog_token: service discovery request dialog token
1252 * @update_indic: service discovery request update indicator
1253 * @tlvs: service discovery request genrated byte array of tlvs
1254 * @tlvs_len: service discovery request tlvs length
1256 void wpas_dbus_signal_p2p_sd_request(struct wpa_supplicant
*wpa_s
,
1257 int freq
, const u8
*sa
, u8 dialog_token
,
1258 u16 update_indic
, const u8
*tlvs
,
1262 DBusMessageIter iter
, dict_iter
;
1263 struct wpas_dbus_priv
*iface
;
1264 char peer_obj_path
[WPAS_DBUS_OBJECT_PATH_MAX
], *path
;
1265 iface
= wpa_s
->global
->dbus
;
1267 /* Do nothing if the control interface is not turned on */
1271 msg
= dbus_message_new_signal(wpa_s
->dbus_new_path
,
1272 WPAS_DBUS_NEW_IFACE_P2PDEVICE
,
1273 "ServiceDiscoveryRequest");
1277 /* Check if this is a known peer */
1278 if (p2p_get_peer_info(wpa_s
->global
->p2p
, sa
, 0, NULL
, 0) < 0)
1281 os_snprintf(peer_obj_path
, WPAS_DBUS_OBJECT_PATH_MAX
,
1282 "%s/" WPAS_DBUS_NEW_P2P_PEERS_PART
"/"
1283 COMPACT_MACSTR
, wpa_s
->dbus_new_path
, MAC2STR(sa
));
1285 path
= peer_obj_path
;
1287 dbus_message_iter_init_append(msg
, &iter
);
1288 if (!wpa_dbus_dict_open_write(&iter
, &dict_iter
))
1292 if (!wpa_dbus_dict_append_object_path(&dict_iter
, "peer_object",
1294 !wpa_dbus_dict_append_int32(&dict_iter
, "frequency", freq
) ||
1295 !wpa_dbus_dict_append_int32(&dict_iter
, "dialog_token",
1297 !wpa_dbus_dict_append_uint16(&dict_iter
, "update_indicator",
1299 !wpa_dbus_dict_append_byte_array(&dict_iter
, "tlvs",
1300 (const char *) tlvs
,
1302 !wpa_dbus_dict_close_write(&iter
, &dict_iter
))
1305 dbus_connection_send(iface
->con
, msg
, NULL
);
1306 dbus_message_unref(msg
);
1309 wpa_printf(MSG_ERROR
, "dbus: Failed to construct signal");
1310 dbus_message_unref(msg
);
1316 * Method to emit a signal for a service discovery response.
1317 * The signal will carry station address, update indicator and it
1320 * @wpa_s: %wpa_supplicant network interface data
1321 * @sa: station addr (p2p i/f) of the peer
1322 * @update_indic: service discovery request update indicator
1323 * @tlvs: service discovery request genrated byte array of tlvs
1324 * @tlvs_len: service discovery request tlvs length
1326 void wpas_dbus_signal_p2p_sd_response(struct wpa_supplicant
*wpa_s
,
1327 const u8
*sa
, u16 update_indic
,
1328 const u8
*tlvs
, size_t tlvs_len
)
1331 DBusMessageIter iter
, dict_iter
;
1332 struct wpas_dbus_priv
*iface
;
1333 char peer_obj_path
[WPAS_DBUS_OBJECT_PATH_MAX
], *path
;
1334 iface
= wpa_s
->global
->dbus
;
1336 /* Do nothing if the control interface is not turned on */
1340 msg
= dbus_message_new_signal(wpa_s
->dbus_new_path
,
1341 WPAS_DBUS_NEW_IFACE_P2PDEVICE
,
1342 "ServiceDiscoveryResponse");
1346 /* Check if this is a known peer */
1347 if (p2p_get_peer_info(wpa_s
->global
->p2p
, sa
, 0, NULL
, 0) < 0)
1350 os_snprintf(peer_obj_path
, WPAS_DBUS_OBJECT_PATH_MAX
,
1351 "%s/" WPAS_DBUS_NEW_P2P_PEERS_PART
"/"
1352 COMPACT_MACSTR
, wpa_s
->dbus_new_path
, MAC2STR(sa
));
1354 path
= peer_obj_path
;
1356 dbus_message_iter_init_append(msg
, &iter
);
1357 if (!wpa_dbus_dict_open_write(&iter
, &dict_iter
))
1360 if (!wpa_dbus_dict_append_object_path(&dict_iter
, "peer_object",
1362 !wpa_dbus_dict_append_uint16(&dict_iter
, "update_indicator",
1364 !wpa_dbus_dict_append_byte_array(&dict_iter
, "tlvs",
1365 (const char *) tlvs
,
1367 !wpa_dbus_dict_close_write(&iter
, &dict_iter
))
1371 dbus_connection_send(iface
->con
, msg
, NULL
);
1372 dbus_message_unref(msg
);
1375 wpa_printf(MSG_ERROR
, "dbus: Failed to construct signal");
1376 dbus_message_unref(msg
);
1380 * wpas_dbus_signal_persistent_group - Send a persistent group related
1382 * @wpa_s: %wpa_supplicant network interface data
1383 * @id: new persistent group id
1384 * @sig_name: signal name - PersistentGroupAdded, PersistentGroupRemoved
1385 * @properties: determines if add second argument with object properties
1387 * Notify listeners about an event related to persistent groups.
1389 static void wpas_dbus_signal_persistent_group(struct wpa_supplicant
*wpa_s
,
1390 int id
, const char *sig_name
,
1393 struct wpas_dbus_priv
*iface
;
1395 DBusMessageIter iter
;
1396 char pgrp_obj_path
[WPAS_DBUS_OBJECT_PATH_MAX
], *path
;
1398 iface
= wpa_s
->global
->dbus
;
1400 /* Do nothing if the control interface is not turned on */
1404 os_snprintf(pgrp_obj_path
, WPAS_DBUS_OBJECT_PATH_MAX
,
1405 "%s/" WPAS_DBUS_NEW_PERSISTENT_GROUPS_PART
"/%u",
1406 wpa_s
->dbus_new_path
, id
);
1408 msg
= dbus_message_new_signal(wpa_s
->dbus_new_path
,
1409 WPAS_DBUS_NEW_IFACE_P2PDEVICE
,
1414 dbus_message_iter_init_append(msg
, &iter
);
1415 path
= pgrp_obj_path
;
1416 if (!dbus_message_iter_append_basic(&iter
, DBUS_TYPE_OBJECT_PATH
,
1421 if (!wpa_dbus_get_object_properties(
1422 iface
, pgrp_obj_path
,
1423 WPAS_DBUS_NEW_IFACE_PERSISTENT_GROUP
, &iter
))
1427 dbus_connection_send(iface
->con
, msg
, NULL
);
1429 dbus_message_unref(msg
);
1433 wpa_printf(MSG_ERROR
, "dbus: Failed to construct signal");
1434 dbus_message_unref(msg
);
1439 * wpas_dbus_signal_persistent_group_added - Send a persistent_group
1441 * @wpa_s: %wpa_supplicant network interface data
1442 * @id: new persistent group id
1444 * Notify listeners about addition of a new persistent group.
1446 static void wpas_dbus_signal_persistent_group_added(
1447 struct wpa_supplicant
*wpa_s
, int id
)
1449 wpas_dbus_signal_persistent_group(wpa_s
, id
, "PersistentGroupAdded",
1455 * wpas_dbus_signal_persistent_group_removed - Send a persistent_group
1457 * @wpa_s: %wpa_supplicant network interface data
1458 * @id: persistent group id
1460 * Notify listeners about removal of a persistent group.
1462 static void wpas_dbus_signal_persistent_group_removed(
1463 struct wpa_supplicant
*wpa_s
, int id
)
1465 wpas_dbus_signal_persistent_group(wpa_s
, id
, "PersistentGroupRemoved",
1471 * wpas_dbus_signal_p2p_wps_failed - Signals WpsFailed event
1472 * @wpa_s: %wpa_supplicant network interface data
1474 * Sends Event dbus signal with name "fail" and dictionary containing
1475 * "msg" field with fail message number (int32) as arguments
1477 void wpas_dbus_signal_p2p_wps_failed(struct wpa_supplicant
*wpa_s
,
1478 struct wps_event_fail
*fail
)
1482 DBusMessageIter iter
, dict_iter
;
1483 struct wpas_dbus_priv
*iface
;
1486 iface
= wpa_s
->global
->dbus
;
1488 /* Do nothing if the control interface is not turned on */
1492 msg
= dbus_message_new_signal(wpa_s
->dbus_new_path
,
1493 WPAS_DBUS_NEW_IFACE_P2PDEVICE
,
1498 dbus_message_iter_init_append(msg
, &iter
);
1500 if (!dbus_message_iter_append_basic(&iter
, DBUS_TYPE_STRING
, &key
) ||
1501 !wpa_dbus_dict_open_write(&iter
, &dict_iter
) ||
1502 !wpa_dbus_dict_append_int32(&dict_iter
, "msg", fail
->msg
) ||
1503 !wpa_dbus_dict_append_int16(&dict_iter
, "config_error",
1504 fail
->config_error
) ||
1505 !wpa_dbus_dict_close_write(&iter
, &dict_iter
))
1506 wpa_printf(MSG_ERROR
, "dbus: Failed to construct signal");
1508 dbus_connection_send(iface
->con
, msg
, NULL
);
1510 dbus_message_unref(msg
);
1513 #endif /*CONFIG_P2P*/
1517 * wpas_dbus_signal_prop_changed - Signals change of property
1518 * @wpa_s: %wpa_supplicant network interface data
1519 * @property: indicates which property has changed
1521 * Sends PropertyChanged signals with path, interface and arguments
1522 * depending on which property has changed.
1524 void wpas_dbus_signal_prop_changed(struct wpa_supplicant
*wpa_s
,
1525 enum wpas_dbus_prop property
)
1529 if (wpa_s
->dbus_new_path
== NULL
)
1530 return; /* Skip signal since D-Bus setup is not yet ready */
1533 case WPAS_DBUS_PROP_AP_SCAN
:
1536 case WPAS_DBUS_PROP_SCANNING
:
1539 case WPAS_DBUS_PROP_STATE
:
1542 case WPAS_DBUS_PROP_CURRENT_BSS
:
1543 prop
= "CurrentBSS";
1545 case WPAS_DBUS_PROP_CURRENT_NETWORK
:
1546 prop
= "CurrentNetwork";
1548 case WPAS_DBUS_PROP_BSSS
:
1551 case WPAS_DBUS_PROP_CURRENT_AUTH_MODE
:
1552 prop
= "CurrentAuthMode";
1555 wpa_printf(MSG_ERROR
, "dbus: %s: Unknown Property value %d",
1556 __func__
, property
);
1560 wpa_dbus_mark_property_changed(wpa_s
->global
->dbus
,
1561 wpa_s
->dbus_new_path
,
1562 WPAS_DBUS_NEW_IFACE_INTERFACE
, prop
);
1567 * wpas_dbus_bss_signal_prop_changed - Signals change of BSS property
1568 * @wpa_s: %wpa_supplicant network interface data
1569 * @property: indicates which property has changed
1570 * @id: unique BSS identifier
1572 * Sends PropertyChanged signals with path, interface, and arguments depending
1573 * on which property has changed.
1575 void wpas_dbus_bss_signal_prop_changed(struct wpa_supplicant
*wpa_s
,
1576 enum wpas_dbus_bss_prop property
,
1579 char path
[WPAS_DBUS_OBJECT_PATH_MAX
];
1583 case WPAS_DBUS_BSS_PROP_SIGNAL
:
1586 case WPAS_DBUS_BSS_PROP_FREQ
:
1589 case WPAS_DBUS_BSS_PROP_MODE
:
1592 case WPAS_DBUS_BSS_PROP_PRIVACY
:
1595 case WPAS_DBUS_BSS_PROP_RATES
:
1598 case WPAS_DBUS_BSS_PROP_WPA
:
1601 case WPAS_DBUS_BSS_PROP_RSN
:
1604 case WPAS_DBUS_BSS_PROP_IES
:
1608 wpa_printf(MSG_ERROR
, "dbus: %s: Unknown Property value %d",
1609 __func__
, property
);
1613 os_snprintf(path
, WPAS_DBUS_OBJECT_PATH_MAX
,
1614 "%s/" WPAS_DBUS_NEW_BSSIDS_PART
"/%u",
1615 wpa_s
->dbus_new_path
, id
);
1617 wpa_dbus_mark_property_changed(wpa_s
->global
->dbus
, path
,
1618 WPAS_DBUS_NEW_IFACE_BSS
, prop
);
1623 * wpas_dbus_signal_debug_level_changed - Signals change of debug param
1624 * @global: wpa_global structure
1626 * Sends PropertyChanged signals informing that debug level has changed.
1628 void wpas_dbus_signal_debug_level_changed(struct wpa_global
*global
)
1630 wpa_dbus_mark_property_changed(global
->dbus
, WPAS_DBUS_NEW_PATH
,
1631 WPAS_DBUS_NEW_INTERFACE
,
1637 * wpas_dbus_signal_debug_timestamp_changed - Signals change of debug param
1638 * @global: wpa_global structure
1640 * Sends PropertyChanged signals informing that debug timestamp has changed.
1642 void wpas_dbus_signal_debug_timestamp_changed(struct wpa_global
*global
)
1644 wpa_dbus_mark_property_changed(global
->dbus
, WPAS_DBUS_NEW_PATH
,
1645 WPAS_DBUS_NEW_INTERFACE
,
1651 * wpas_dbus_signal_debug_show_keys_changed - Signals change of debug param
1652 * @global: wpa_global structure
1654 * Sends PropertyChanged signals informing that debug show_keys has changed.
1656 void wpas_dbus_signal_debug_show_keys_changed(struct wpa_global
*global
)
1658 wpa_dbus_mark_property_changed(global
->dbus
, WPAS_DBUS_NEW_PATH
,
1659 WPAS_DBUS_NEW_INTERFACE
,
1664 static void wpas_dbus_register(struct wpa_dbus_object_desc
*obj_desc
,
1666 WPADBusArgumentFreeFunction priv_free
,
1667 const struct wpa_dbus_method_desc
*methods
,
1668 const struct wpa_dbus_property_desc
*properties
,
1669 const struct wpa_dbus_signal_desc
*signals
)
1673 obj_desc
->user_data
= priv
;
1674 obj_desc
->user_data_free_func
= priv_free
;
1675 obj_desc
->methods
= methods
;
1676 obj_desc
->properties
= properties
;
1677 obj_desc
->signals
= signals
;
1679 for (n
= 0; properties
&& properties
->dbus_property
; properties
++)
1682 obj_desc
->prop_changed_flags
= os_zalloc(n
);
1683 if (!obj_desc
->prop_changed_flags
)
1684 wpa_printf(MSG_DEBUG
, "dbus: %s: can't register handlers",
1689 static const struct wpa_dbus_method_desc wpas_dbus_global_methods
[] = {
1690 { "CreateInterface", WPAS_DBUS_NEW_INTERFACE
,
1691 (WPADBusMethodHandler
) &wpas_dbus_handler_create_interface
,
1693 { "args", "a{sv}", ARG_IN
},
1694 { "path", "o", ARG_OUT
},
1698 { "RemoveInterface", WPAS_DBUS_NEW_INTERFACE
,
1699 (WPADBusMethodHandler
) &wpas_dbus_handler_remove_interface
,
1701 { "path", "o", ARG_IN
},
1705 { "GetInterface", WPAS_DBUS_NEW_INTERFACE
,
1706 (WPADBusMethodHandler
) &wpas_dbus_handler_get_interface
,
1708 { "ifname", "s", ARG_IN
},
1709 { "path", "o", ARG_OUT
},
1713 { NULL
, NULL
, NULL
, { END_ARGS
} }
1716 static const struct wpa_dbus_property_desc wpas_dbus_global_properties
[] = {
1717 { "DebugLevel", WPAS_DBUS_NEW_INTERFACE
, "s",
1718 wpas_dbus_getter_debug_level
,
1719 wpas_dbus_setter_debug_level
1721 { "DebugTimestamp", WPAS_DBUS_NEW_INTERFACE
, "b",
1722 wpas_dbus_getter_debug_timestamp
,
1723 wpas_dbus_setter_debug_timestamp
1725 { "DebugShowKeys", WPAS_DBUS_NEW_INTERFACE
, "b",
1726 wpas_dbus_getter_debug_show_keys
,
1727 wpas_dbus_setter_debug_show_keys
1729 { "Interfaces", WPAS_DBUS_NEW_INTERFACE
, "ao",
1730 wpas_dbus_getter_interfaces
,
1733 { "EapMethods", WPAS_DBUS_NEW_INTERFACE
, "as",
1734 wpas_dbus_getter_eap_methods
,
1737 { NULL
, NULL
, NULL
, NULL
, NULL
}
1740 static const struct wpa_dbus_signal_desc wpas_dbus_global_signals
[] = {
1741 { "InterfaceAdded", WPAS_DBUS_NEW_INTERFACE
,
1743 { "path", "o", ARG_OUT
},
1744 { "properties", "a{sv}", ARG_OUT
},
1748 { "InterfaceRemoved", WPAS_DBUS_NEW_INTERFACE
,
1750 { "path", "o", ARG_OUT
},
1754 { "NetworkRequest", WPAS_DBUS_NEW_IFACE_INTERFACE
,
1756 { "path", "o", ARG_OUT
},
1757 { "field", "s", ARG_OUT
},
1758 { "text", "s", ARG_OUT
},
1762 /* Deprecated: use org.freedesktop.DBus.Properties.PropertiesChanged */
1763 { "PropertiesChanged", WPAS_DBUS_NEW_INTERFACE
,
1765 { "properties", "a{sv}", ARG_OUT
},
1769 { NULL
, NULL
, { END_ARGS
} }
1774 * wpas_dbus_ctrl_iface_init - Initialize dbus control interface
1775 * @global: Pointer to global data from wpa_supplicant_init()
1776 * Returns: 0 on success or -1 on failure
1778 * Initialize the dbus control interface for wpa_supplicantand and start
1779 * receiving commands from external programs over the bus.
1781 int wpas_dbus_ctrl_iface_init(struct wpas_dbus_priv
*priv
)
1783 struct wpa_dbus_object_desc
*obj_desc
;
1786 obj_desc
= os_zalloc(sizeof(struct wpa_dbus_object_desc
));
1788 wpa_printf(MSG_ERROR
, "Not enough memory "
1789 "to create object description");
1793 wpas_dbus_register(obj_desc
, priv
->global
, NULL
,
1794 wpas_dbus_global_methods
,
1795 wpas_dbus_global_properties
,
1796 wpas_dbus_global_signals
);
1798 wpa_printf(MSG_DEBUG
, "dbus: Register D-Bus object '%s'",
1799 WPAS_DBUS_NEW_PATH
);
1800 ret
= wpa_dbus_ctrl_iface_init(priv
, WPAS_DBUS_NEW_PATH
,
1801 WPAS_DBUS_NEW_SERVICE
,
1804 free_dbus_object_desc(obj_desc
);
1806 priv
->dbus_new_initialized
= 1;
1813 * wpas_dbus_ctrl_iface_deinit - Deinitialize dbus ctrl interface for
1815 * @iface: Pointer to dbus private data from wpas_dbus_init()
1817 * Deinitialize the dbus control interface that was initialized with
1818 * wpas_dbus_ctrl_iface_init().
1820 void wpas_dbus_ctrl_iface_deinit(struct wpas_dbus_priv
*iface
)
1822 if (!iface
->dbus_new_initialized
)
1824 wpa_printf(MSG_DEBUG
, "dbus: Unregister D-Bus object '%s'",
1825 WPAS_DBUS_NEW_PATH
);
1826 dbus_connection_unregister_object_path(iface
->con
,
1827 WPAS_DBUS_NEW_PATH
);
1831 static void wpa_dbus_free(void *ptr
)
1837 static const struct wpa_dbus_property_desc wpas_dbus_network_properties
[] = {
1838 { "Properties", WPAS_DBUS_NEW_IFACE_NETWORK
, "a{sv}",
1839 wpas_dbus_getter_network_properties
,
1840 wpas_dbus_setter_network_properties
1842 { "Enabled", WPAS_DBUS_NEW_IFACE_NETWORK
, "b",
1843 wpas_dbus_getter_enabled
,
1844 wpas_dbus_setter_enabled
1846 { NULL
, NULL
, NULL
, NULL
, NULL
}
1850 static const struct wpa_dbus_signal_desc wpas_dbus_network_signals
[] = {
1851 /* Deprecated: use org.freedesktop.DBus.Properties.PropertiesChanged */
1852 { "PropertiesChanged", WPAS_DBUS_NEW_IFACE_NETWORK
,
1854 { "properties", "a{sv}", ARG_OUT
},
1858 { NULL
, NULL
, { END_ARGS
} }
1863 * wpas_dbus_register_network - Register a configured network with dbus
1864 * @wpa_s: wpa_supplicant interface structure
1865 * @ssid: network configuration data
1866 * Returns: 0 on success, -1 on failure
1868 * Registers network representing object with dbus
1870 int wpas_dbus_register_network(struct wpa_supplicant
*wpa_s
,
1871 struct wpa_ssid
*ssid
)
1873 struct wpas_dbus_priv
*ctrl_iface
;
1874 struct wpa_dbus_object_desc
*obj_desc
;
1875 struct network_handler_args
*arg
;
1876 char net_obj_path
[WPAS_DBUS_OBJECT_PATH_MAX
];
1880 * If it is a persistent group register it as such.
1881 * This is to handle cases where an interface is being initialized
1882 * with a list of networks read from config.
1884 if (network_is_persistent_group(ssid
))
1885 return wpas_dbus_register_persistent_group(wpa_s
, ssid
);
1886 #endif /* CONFIG_P2P */
1888 /* Do nothing if the control interface is not turned on */
1889 if (wpa_s
== NULL
|| wpa_s
->global
== NULL
)
1891 ctrl_iface
= wpa_s
->global
->dbus
;
1892 if (ctrl_iface
== NULL
)
1895 os_snprintf(net_obj_path
, WPAS_DBUS_OBJECT_PATH_MAX
,
1896 "%s/" WPAS_DBUS_NEW_NETWORKS_PART
"/%u",
1897 wpa_s
->dbus_new_path
, ssid
->id
);
1899 wpa_printf(MSG_DEBUG
, "dbus: Register network object '%s'",
1901 obj_desc
= os_zalloc(sizeof(struct wpa_dbus_object_desc
));
1903 wpa_printf(MSG_ERROR
, "Not enough memory "
1904 "to create object description");
1908 /* allocate memory for handlers arguments */
1909 arg
= os_zalloc(sizeof(struct network_handler_args
));
1911 wpa_printf(MSG_ERROR
, "Not enough memory "
1912 "to create arguments for method");
1919 wpas_dbus_register(obj_desc
, arg
, wpa_dbus_free
, NULL
,
1920 wpas_dbus_network_properties
,
1921 wpas_dbus_network_signals
);
1923 if (wpa_dbus_register_object_per_iface(ctrl_iface
, net_obj_path
,
1924 wpa_s
->ifname
, obj_desc
))
1927 wpas_dbus_signal_network_added(wpa_s
, ssid
->id
);
1932 free_dbus_object_desc(obj_desc
);
1938 * wpas_dbus_unregister_network - Unregister a configured network from dbus
1939 * @wpa_s: wpa_supplicant interface structure
1941 * Returns: 0 on success, -1 on failure
1943 * Unregisters network representing object from dbus
1945 int wpas_dbus_unregister_network(struct wpa_supplicant
*wpa_s
, int nid
)
1947 struct wpas_dbus_priv
*ctrl_iface
;
1948 char net_obj_path
[WPAS_DBUS_OBJECT_PATH_MAX
];
1950 struct wpa_ssid
*ssid
;
1952 ssid
= wpa_config_get_network(wpa_s
->conf
, nid
);
1955 /* If it is a persistent group unregister it as such */
1956 if (ssid
&& network_is_persistent_group(ssid
))
1957 return wpas_dbus_unregister_persistent_group(wpa_s
, nid
);
1958 #endif /* CONFIG_P2P */
1960 /* Do nothing if the control interface is not turned on */
1961 if (wpa_s
->global
== NULL
|| wpa_s
->dbus_new_path
== NULL
)
1963 ctrl_iface
= wpa_s
->global
->dbus
;
1964 if (ctrl_iface
== NULL
)
1967 os_snprintf(net_obj_path
, WPAS_DBUS_OBJECT_PATH_MAX
,
1968 "%s/" WPAS_DBUS_NEW_NETWORKS_PART
"/%u",
1969 wpa_s
->dbus_new_path
, nid
);
1971 wpa_printf(MSG_DEBUG
, "dbus: Unregister network object '%s'",
1973 ret
= wpa_dbus_unregister_object_per_iface(ctrl_iface
, net_obj_path
);
1976 wpas_dbus_signal_network_removed(wpa_s
, nid
);
1982 static const struct wpa_dbus_property_desc wpas_dbus_bss_properties
[] = {
1983 { "SSID", WPAS_DBUS_NEW_IFACE_BSS
, "ay",
1984 wpas_dbus_getter_bss_ssid
,
1987 { "BSSID", WPAS_DBUS_NEW_IFACE_BSS
, "ay",
1988 wpas_dbus_getter_bss_bssid
,
1991 { "Privacy", WPAS_DBUS_NEW_IFACE_BSS
, "b",
1992 wpas_dbus_getter_bss_privacy
,
1995 { "Mode", WPAS_DBUS_NEW_IFACE_BSS
, "s",
1996 wpas_dbus_getter_bss_mode
,
1999 { "Signal", WPAS_DBUS_NEW_IFACE_BSS
, "n",
2000 wpas_dbus_getter_bss_signal
,
2003 { "Frequency", WPAS_DBUS_NEW_IFACE_BSS
, "q",
2004 wpas_dbus_getter_bss_frequency
,
2007 { "Rates", WPAS_DBUS_NEW_IFACE_BSS
, "au",
2008 wpas_dbus_getter_bss_rates
,
2011 { "WPA", WPAS_DBUS_NEW_IFACE_BSS
, "a{sv}",
2012 wpas_dbus_getter_bss_wpa
,
2015 { "RSN", WPAS_DBUS_NEW_IFACE_BSS
, "a{sv}",
2016 wpas_dbus_getter_bss_rsn
,
2019 { "IEs", WPAS_DBUS_NEW_IFACE_BSS
, "ay",
2020 wpas_dbus_getter_bss_ies
,
2023 { NULL
, NULL
, NULL
, NULL
, NULL
}
2027 static const struct wpa_dbus_signal_desc wpas_dbus_bss_signals
[] = {
2028 /* Deprecated: use org.freedesktop.DBus.Properties.PropertiesChanged */
2029 { "PropertiesChanged", WPAS_DBUS_NEW_IFACE_BSS
,
2031 { "properties", "a{sv}", ARG_OUT
},
2035 { NULL
, NULL
, { END_ARGS
} }
2040 * wpas_dbus_unregister_bss - Unregister a scanned BSS from dbus
2041 * @wpa_s: wpa_supplicant interface structure
2042 * @bssid: scanned network bssid
2043 * @id: unique BSS identifier
2044 * Returns: 0 on success, -1 on failure
2046 * Unregisters BSS representing object from dbus
2048 int wpas_dbus_unregister_bss(struct wpa_supplicant
*wpa_s
,
2049 u8 bssid
[ETH_ALEN
], unsigned int id
)
2051 struct wpas_dbus_priv
*ctrl_iface
;
2052 char bss_obj_path
[WPAS_DBUS_OBJECT_PATH_MAX
];
2054 /* Do nothing if the control interface is not turned on */
2055 if (wpa_s
== NULL
|| wpa_s
->global
== NULL
)
2057 ctrl_iface
= wpa_s
->global
->dbus
;
2058 if (ctrl_iface
== NULL
)
2061 os_snprintf(bss_obj_path
, WPAS_DBUS_OBJECT_PATH_MAX
,
2062 "%s/" WPAS_DBUS_NEW_BSSIDS_PART
"/%u",
2063 wpa_s
->dbus_new_path
, id
);
2065 wpa_printf(MSG_DEBUG
, "dbus: Unregister BSS object '%s'",
2067 if (wpa_dbus_unregister_object_per_iface(ctrl_iface
, bss_obj_path
)) {
2068 wpa_printf(MSG_ERROR
, "dbus: Cannot unregister BSS object %s",
2073 wpas_dbus_signal_bss_removed(wpa_s
, bss_obj_path
);
2074 wpas_dbus_signal_prop_changed(wpa_s
, WPAS_DBUS_PROP_BSSS
);
2081 * wpas_dbus_register_bss - Register a scanned BSS with dbus
2082 * @wpa_s: wpa_supplicant interface structure
2083 * @bssid: scanned network bssid
2084 * @id: unique BSS identifier
2085 * Returns: 0 on success, -1 on failure
2087 * Registers BSS representing object with dbus
2089 int wpas_dbus_register_bss(struct wpa_supplicant
*wpa_s
,
2090 u8 bssid
[ETH_ALEN
], unsigned int id
)
2092 struct wpas_dbus_priv
*ctrl_iface
;
2093 struct wpa_dbus_object_desc
*obj_desc
;
2094 char bss_obj_path
[WPAS_DBUS_OBJECT_PATH_MAX
];
2095 struct bss_handler_args
*arg
;
2097 /* Do nothing if the control interface is not turned on */
2098 if (wpa_s
== NULL
|| wpa_s
->global
== NULL
)
2100 ctrl_iface
= wpa_s
->global
->dbus
;
2101 if (ctrl_iface
== NULL
)
2104 os_snprintf(bss_obj_path
, WPAS_DBUS_OBJECT_PATH_MAX
,
2105 "%s/" WPAS_DBUS_NEW_BSSIDS_PART
"/%u",
2106 wpa_s
->dbus_new_path
, id
);
2108 obj_desc
= os_zalloc(sizeof(struct wpa_dbus_object_desc
));
2110 wpa_printf(MSG_ERROR
, "Not enough memory "
2111 "to create object description");
2115 arg
= os_zalloc(sizeof(struct bss_handler_args
));
2117 wpa_printf(MSG_ERROR
, "Not enough memory "
2118 "to create arguments for handler");
2124 wpas_dbus_register(obj_desc
, arg
, wpa_dbus_free
, NULL
,
2125 wpas_dbus_bss_properties
,
2126 wpas_dbus_bss_signals
);
2128 wpa_printf(MSG_DEBUG
, "dbus: Register BSS object '%s'",
2130 if (wpa_dbus_register_object_per_iface(ctrl_iface
, bss_obj_path
,
2131 wpa_s
->ifname
, obj_desc
)) {
2132 wpa_printf(MSG_ERROR
,
2133 "Cannot register BSSID dbus object %s.",
2138 wpas_dbus_signal_bss_added(wpa_s
, bss_obj_path
);
2139 wpas_dbus_signal_prop_changed(wpa_s
, WPAS_DBUS_PROP_BSSS
);
2144 free_dbus_object_desc(obj_desc
);
2149 static const struct wpa_dbus_method_desc wpas_dbus_interface_methods
[] = {
2150 { "Scan", WPAS_DBUS_NEW_IFACE_INTERFACE
,
2151 (WPADBusMethodHandler
) &wpas_dbus_handler_scan
,
2153 { "args", "a{sv}", ARG_IN
},
2157 { "Disconnect", WPAS_DBUS_NEW_IFACE_INTERFACE
,
2158 (WPADBusMethodHandler
) &wpas_dbus_handler_disconnect
,
2163 { "AddNetwork", WPAS_DBUS_NEW_IFACE_INTERFACE
,
2164 (WPADBusMethodHandler
) &wpas_dbus_handler_add_network
,
2166 { "args", "a{sv}", ARG_IN
},
2167 { "path", "o", ARG_OUT
},
2171 { "RemoveNetwork", WPAS_DBUS_NEW_IFACE_INTERFACE
,
2172 (WPADBusMethodHandler
) &wpas_dbus_handler_remove_network
,
2174 { "path", "o", ARG_IN
},
2178 { "RemoveAllNetworks", WPAS_DBUS_NEW_IFACE_INTERFACE
,
2179 (WPADBusMethodHandler
) &wpas_dbus_handler_remove_all_networks
,
2184 { "SelectNetwork", WPAS_DBUS_NEW_IFACE_INTERFACE
,
2185 (WPADBusMethodHandler
) &wpas_dbus_handler_select_network
,
2187 { "path", "o", ARG_IN
},
2191 { "NetworkReply", WPAS_DBUS_NEW_IFACE_INTERFACE
,
2192 (WPADBusMethodHandler
) &wpas_dbus_handler_network_reply
,
2194 { "path", "o", ARG_IN
},
2195 { "field", "s", ARG_IN
},
2196 { "value", "s", ARG_IN
},
2200 { "AddBlob", WPAS_DBUS_NEW_IFACE_INTERFACE
,
2201 (WPADBusMethodHandler
) &wpas_dbus_handler_add_blob
,
2203 { "name", "s", ARG_IN
},
2204 { "data", "ay", ARG_IN
},
2208 { "GetBlob", WPAS_DBUS_NEW_IFACE_INTERFACE
,
2209 (WPADBusMethodHandler
) &wpas_dbus_handler_get_blob
,
2211 { "name", "s", ARG_IN
},
2212 { "data", "ay", ARG_OUT
},
2216 { "RemoveBlob", WPAS_DBUS_NEW_IFACE_INTERFACE
,
2217 (WPADBusMethodHandler
) &wpas_dbus_handler_remove_blob
,
2219 { "name", "s", ARG_IN
},
2224 { "Start", WPAS_DBUS_NEW_IFACE_WPS
,
2225 (WPADBusMethodHandler
) &wpas_dbus_handler_wps_start
,
2227 { "args", "a{sv}", ARG_IN
},
2228 { "output", "a{sv}", ARG_OUT
},
2232 #endif /* CONFIG_WPS */
2234 { "Find", WPAS_DBUS_NEW_IFACE_P2PDEVICE
,
2235 (WPADBusMethodHandler
)wpas_dbus_handler_p2p_find
,
2237 { "args", "a{sv}", ARG_IN
},
2241 { "StopFind", WPAS_DBUS_NEW_IFACE_P2PDEVICE
,
2242 (WPADBusMethodHandler
)wpas_dbus_handler_p2p_stop_find
,
2247 { "Listen", WPAS_DBUS_NEW_IFACE_P2PDEVICE
,
2248 (WPADBusMethodHandler
)wpas_dbus_handler_p2p_listen
,
2250 { "timeout", "i", ARG_IN
},
2254 { "ExtendedListen", WPAS_DBUS_NEW_IFACE_P2PDEVICE
,
2255 (WPADBusMethodHandler
)wpas_dbus_handler_p2p_extendedlisten
,
2257 { "args", "a{sv}", ARG_IN
},
2261 { "PresenceRequest", WPAS_DBUS_NEW_IFACE_P2PDEVICE
,
2262 (WPADBusMethodHandler
)wpas_dbus_handler_p2p_presence_request
,
2264 { "args", "a{sv}", ARG_IN
},
2268 { "ProvisionDiscoveryRequest", WPAS_DBUS_NEW_IFACE_P2PDEVICE
,
2269 (WPADBusMethodHandler
)wpas_dbus_handler_p2p_prov_disc_req
,
2271 { "peer", "o", ARG_IN
},
2272 { "config_method", "s", ARG_IN
},
2276 { "Connect", WPAS_DBUS_NEW_IFACE_P2PDEVICE
,
2277 (WPADBusMethodHandler
)wpas_dbus_handler_p2p_connect
,
2279 { "args", "a{sv}", ARG_IN
},
2280 { "generated_pin", "s", ARG_OUT
},
2284 { "GroupAdd", WPAS_DBUS_NEW_IFACE_P2PDEVICE
,
2285 (WPADBusMethodHandler
)wpas_dbus_handler_p2p_group_add
,
2287 { "args", "a{sv}", ARG_IN
},
2291 { "Invite", WPAS_DBUS_NEW_IFACE_P2PDEVICE
,
2292 (WPADBusMethodHandler
)wpas_dbus_handler_p2p_invite
,
2294 { "args", "a{sv}", ARG_IN
},
2298 { "Disconnect", WPAS_DBUS_NEW_IFACE_P2PDEVICE
,
2299 (WPADBusMethodHandler
)wpas_dbus_handler_p2p_disconnect
,
2304 { "RejectPeer", WPAS_DBUS_NEW_IFACE_P2PDEVICE
,
2305 (WPADBusMethodHandler
)wpas_dbus_handler_p2p_rejectpeer
,
2307 { "peer", "o", ARG_IN
},
2311 { "Flush", WPAS_DBUS_NEW_IFACE_P2PDEVICE
,
2312 (WPADBusMethodHandler
)wpas_dbus_handler_p2p_flush
,
2317 { "AddService", WPAS_DBUS_NEW_IFACE_P2PDEVICE
,
2318 (WPADBusMethodHandler
)wpas_dbus_handler_p2p_add_service
,
2320 { "args", "a{sv}", ARG_IN
},
2324 { "DeleteService", WPAS_DBUS_NEW_IFACE_P2PDEVICE
,
2325 (WPADBusMethodHandler
)wpas_dbus_handler_p2p_delete_service
,
2327 { "args", "a{sv}", ARG_IN
},
2331 { "FlushService", WPAS_DBUS_NEW_IFACE_P2PDEVICE
,
2332 (WPADBusMethodHandler
)wpas_dbus_handler_p2p_flush_service
,
2337 { "ServiceDiscoveryRequest", WPAS_DBUS_NEW_IFACE_P2PDEVICE
,
2338 (WPADBusMethodHandler
)wpas_dbus_handler_p2p_service_sd_req
,
2340 { "args", "a{sv}", ARG_IN
},
2344 { "ServiceDiscoveryResponse", WPAS_DBUS_NEW_IFACE_P2PDEVICE
,
2345 (WPADBusMethodHandler
)wpas_dbus_handler_p2p_service_sd_res
,
2347 { "args", "a{sv}", ARG_IN
},
2351 { "ServiceDiscoveryCancelRequest", WPAS_DBUS_NEW_IFACE_P2PDEVICE
,
2352 (WPADBusMethodHandler
)wpas_dbus_handler_p2p_service_sd_cancel_req
,
2354 { "args", "t", ARG_IN
},
2358 { "ServiceUpdate", WPAS_DBUS_NEW_IFACE_P2PDEVICE
,
2359 (WPADBusMethodHandler
)wpas_dbus_handler_p2p_service_update
,
2364 { "ServiceDiscoveryExternal", WPAS_DBUS_NEW_IFACE_P2PDEVICE
,
2365 (WPADBusMethodHandler
)wpas_dbus_handler_p2p_serv_disc_external
,
2367 { "arg", "i", ARG_IN
},
2371 { "ServiceDiscoveryExternal", WPAS_DBUS_NEW_IFACE_P2PDEVICE
,
2372 (WPADBusMethodHandler
)wpas_dbus_handler_p2p_serv_disc_external
,
2374 { "arg", "i", ARG_IN
},
2378 { "AddPersistentGroup", WPAS_DBUS_NEW_IFACE_P2PDEVICE
,
2379 (WPADBusMethodHandler
) wpas_dbus_handler_add_persistent_group
,
2381 { "args", "a{sv}", ARG_IN
},
2382 { "path", "o", ARG_OUT
},
2386 { "RemovePersistentGroup", WPAS_DBUS_NEW_IFACE_P2PDEVICE
,
2387 (WPADBusMethodHandler
) wpas_dbus_handler_remove_persistent_group
,
2389 { "path", "o", ARG_IN
},
2393 { "RemoveAllPersistentGroups", WPAS_DBUS_NEW_IFACE_P2PDEVICE
,
2394 (WPADBusMethodHandler
)
2395 wpas_dbus_handler_remove_all_persistent_groups
,
2400 #endif /* CONFIG_P2P */
2401 { "FlushBSS", WPAS_DBUS_NEW_IFACE_INTERFACE
,
2402 (WPADBusMethodHandler
) &wpas_dbus_handler_flush_bss
,
2404 { "age", "u", ARG_IN
},
2408 { NULL
, NULL
, NULL
, { END_ARGS
} }
2411 static const struct wpa_dbus_property_desc wpas_dbus_interface_properties
[] = {
2412 { "Capabilities", WPAS_DBUS_NEW_IFACE_INTERFACE
, "a{sv}",
2413 wpas_dbus_getter_capabilities
,
2416 { "State", WPAS_DBUS_NEW_IFACE_INTERFACE
, "s",
2417 wpas_dbus_getter_state
,
2420 { "Scanning", WPAS_DBUS_NEW_IFACE_INTERFACE
, "b",
2421 wpas_dbus_getter_scanning
,
2424 { "ApScan", WPAS_DBUS_NEW_IFACE_INTERFACE
, "u",
2425 wpas_dbus_getter_ap_scan
,
2426 wpas_dbus_setter_ap_scan
2428 { "BSSExpireAge", WPAS_DBUS_NEW_IFACE_INTERFACE
, "u",
2429 wpas_dbus_getter_bss_expire_age
,
2430 wpas_dbus_setter_bss_expire_age
2432 { "BSSExpireCount", WPAS_DBUS_NEW_IFACE_INTERFACE
, "u",
2433 wpas_dbus_getter_bss_expire_count
,
2434 wpas_dbus_setter_bss_expire_count
2436 { "Country", WPAS_DBUS_NEW_IFACE_INTERFACE
, "s",
2437 wpas_dbus_getter_country
,
2438 wpas_dbus_setter_country
2440 { "Ifname", WPAS_DBUS_NEW_IFACE_INTERFACE
, "s",
2441 wpas_dbus_getter_ifname
,
2444 { "Driver", WPAS_DBUS_NEW_IFACE_INTERFACE
, "s",
2445 wpas_dbus_getter_driver
,
2448 { "BridgeIfname", WPAS_DBUS_NEW_IFACE_INTERFACE
, "s",
2449 wpas_dbus_getter_bridge_ifname
,
2452 { "CurrentBSS", WPAS_DBUS_NEW_IFACE_INTERFACE
, "o",
2453 wpas_dbus_getter_current_bss
,
2456 { "CurrentNetwork", WPAS_DBUS_NEW_IFACE_INTERFACE
, "o",
2457 wpas_dbus_getter_current_network
,
2460 { "CurrentAuthMode", WPAS_DBUS_NEW_IFACE_INTERFACE
, "s",
2461 wpas_dbus_getter_current_auth_mode
,
2464 { "Blobs", WPAS_DBUS_NEW_IFACE_INTERFACE
, "a{say}",
2465 wpas_dbus_getter_blobs
,
2468 { "BSSs", WPAS_DBUS_NEW_IFACE_INTERFACE
, "ao",
2469 wpas_dbus_getter_bsss
,
2472 { "Networks", WPAS_DBUS_NEW_IFACE_INTERFACE
, "ao",
2473 wpas_dbus_getter_networks
,
2477 { "ProcessCredentials", WPAS_DBUS_NEW_IFACE_WPS
, "b",
2478 wpas_dbus_getter_process_credentials
,
2479 wpas_dbus_setter_process_credentials
2481 #endif /* CONFIG_WPS */
2483 { "P2PDeviceProperties", WPAS_DBUS_NEW_IFACE_P2PDEVICE
, "a{sv}",
2484 wpas_dbus_getter_p2p_device_properties
,
2485 wpas_dbus_setter_p2p_device_properties
2487 { "Peers", WPAS_DBUS_NEW_IFACE_P2PDEVICE
, "ao",
2488 wpas_dbus_getter_p2p_peers
,
2491 { "Role", WPAS_DBUS_NEW_IFACE_P2PDEVICE
, "s",
2492 wpas_dbus_getter_p2p_role
,
2495 { "Group", WPAS_DBUS_NEW_IFACE_P2PDEVICE
, "o",
2496 wpas_dbus_getter_p2p_group
,
2499 { "PeerGO", WPAS_DBUS_NEW_IFACE_P2PDEVICE
, "o",
2500 wpas_dbus_getter_p2p_peergo
,
2503 { "PersistentGroups", WPAS_DBUS_NEW_IFACE_P2PDEVICE
, "ao",
2504 wpas_dbus_getter_persistent_groups
,
2507 #endif /* CONFIG_P2P */
2508 { NULL
, NULL
, NULL
, NULL
, NULL
}
2511 static const struct wpa_dbus_signal_desc wpas_dbus_interface_signals
[] = {
2512 { "ScanDone", WPAS_DBUS_NEW_IFACE_INTERFACE
,
2514 { "success", "b", ARG_OUT
},
2518 { "BSSAdded", WPAS_DBUS_NEW_IFACE_INTERFACE
,
2520 { "path", "o", ARG_OUT
},
2521 { "properties", "a{sv}", ARG_OUT
},
2525 { "BSSRemoved", WPAS_DBUS_NEW_IFACE_INTERFACE
,
2527 { "path", "o", ARG_OUT
},
2531 { "BlobAdded", WPAS_DBUS_NEW_IFACE_INTERFACE
,
2533 { "name", "s", ARG_OUT
},
2537 { "BlobRemoved", WPAS_DBUS_NEW_IFACE_INTERFACE
,
2539 { "name", "s", ARG_OUT
},
2543 { "NetworkAdded", WPAS_DBUS_NEW_IFACE_INTERFACE
,
2545 { "path", "o", ARG_OUT
},
2546 { "properties", "a{sv}", ARG_OUT
},
2550 { "NetworkRemoved", WPAS_DBUS_NEW_IFACE_INTERFACE
,
2552 { "path", "o", ARG_OUT
},
2556 { "NetworkSelected", WPAS_DBUS_NEW_IFACE_INTERFACE
,
2558 { "path", "o", ARG_OUT
},
2562 /* Deprecated: use org.freedesktop.DBus.Properties.PropertiesChanged */
2563 { "PropertiesChanged", WPAS_DBUS_NEW_IFACE_INTERFACE
,
2565 { "properties", "a{sv}", ARG_OUT
},
2570 { "Event", WPAS_DBUS_NEW_IFACE_WPS
,
2572 { "name", "s", ARG_OUT
},
2573 { "args", "a{sv}", ARG_OUT
},
2577 { "Credentials", WPAS_DBUS_NEW_IFACE_WPS
,
2579 { "credentials", "a{sv}", ARG_OUT
},
2583 /* Deprecated: use org.freedesktop.DBus.Properties.PropertiesChanged */
2584 { "PropertiesChanged", WPAS_DBUS_NEW_IFACE_WPS
,
2586 { "properties", "a{sv}", ARG_OUT
},
2590 #endif /* CONFIG_WPS */
2592 { "P2PStateChanged", WPAS_DBUS_NEW_IFACE_P2PDEVICE
,
2594 { "states", "a{ss}", ARG_OUT
},
2598 { "DeviceFound", WPAS_DBUS_NEW_IFACE_P2PDEVICE
,
2600 { "path", "o", ARG_OUT
},
2601 { "properties", "a{sv}", ARG_OUT
},
2605 { "DeviceLost", WPAS_DBUS_NEW_IFACE_P2PDEVICE
,
2607 { "path", "o", ARG_OUT
},
2611 { "ProvisionDiscoveryRequestDisplayPin", WPAS_DBUS_NEW_IFACE_P2PDEVICE
,
2613 { "peer_object", "o", ARG_OUT
},
2614 { "pin", "s", ARG_OUT
},
2618 { "ProvisionDiscoveryResponseDisplayPin", WPAS_DBUS_NEW_IFACE_P2PDEVICE
,
2620 { "peer_object", "o", ARG_OUT
},
2621 { "pin", "s", ARG_OUT
},
2625 { "ProvisionDiscoveryRequestEnterPin", WPAS_DBUS_NEW_IFACE_P2PDEVICE
,
2627 { "peer_object", "o", ARG_OUT
},
2631 { "ProvisionDiscoveryResponseEnterPin", WPAS_DBUS_NEW_IFACE_P2PDEVICE
,
2633 { "peer_object", "o", ARG_OUT
},
2637 { "ProvisionDiscoveryPBCRequest", WPAS_DBUS_NEW_IFACE_P2PDEVICE
,
2639 { "peer_object", "o", ARG_OUT
},
2643 { "ProvisionDiscoveryPBCResponse", WPAS_DBUS_NEW_IFACE_P2PDEVICE
,
2645 { "peer_object", "o", ARG_OUT
},
2649 { "ProvisionDiscoveryFailure", WPAS_DBUS_NEW_IFACE_P2PDEVICE
,
2651 { "peer_object", "o", ARG_OUT
},
2652 { "status", "i", ARG_OUT
},
2656 { "GroupStarted", WPAS_DBUS_NEW_IFACE_P2PDEVICE
,
2658 { "properties", "a{sv}", ARG_OUT
},
2662 { "GONegotiationSuccess", WPAS_DBUS_NEW_IFACE_P2PDEVICE
,
2667 { "GONegotiationFailure", WPAS_DBUS_NEW_IFACE_P2PDEVICE
,
2669 { "status", "i", ARG_OUT
},
2673 { "GONegotiationRequest", WPAS_DBUS_NEW_IFACE_P2PDEVICE
,
2675 { "path", "o", ARG_OUT
},
2676 { "dev_passwd_id", "i", ARG_OUT
},
2680 { "InvitationResult", WPAS_DBUS_NEW_IFACE_P2PDEVICE
,
2682 { "invite_result", "a{sv}", ARG_OUT
},
2686 { "GroupFinished", WPAS_DBUS_NEW_IFACE_P2PDEVICE
,
2688 { "ifname", "s", ARG_OUT
},
2689 { "role", "s", ARG_OUT
},
2693 { "ServiceDiscoveryRequest", WPAS_DBUS_NEW_IFACE_P2PDEVICE
,
2695 { "sd_request", "a{sv}", ARG_OUT
},
2699 { "ServiceDiscoveryResponse", WPAS_DBUS_NEW_IFACE_P2PDEVICE
,
2701 { "sd_response", "a{sv}", ARG_OUT
},
2705 { "PersistentGroupAdded", WPAS_DBUS_NEW_IFACE_P2PDEVICE
,
2707 { "path", "o", ARG_OUT
},
2708 { "properties", "a{sv}", ARG_OUT
},
2712 { "PersistentGroupRemoved", WPAS_DBUS_NEW_IFACE_P2PDEVICE
,
2714 { "path", "o", ARG_OUT
},
2718 { "WpsFailed", WPAS_DBUS_NEW_IFACE_P2PDEVICE
,
2720 { "name", "s", ARG_OUT
},
2721 { "args", "a{sv}", ARG_OUT
},
2725 #endif /* CONFIG_P2P */
2726 { "Certification", WPAS_DBUS_NEW_IFACE_INTERFACE
,
2728 { "certification", "a{sv}", ARG_OUT
},
2732 { NULL
, NULL
, { END_ARGS
} }
2736 int wpas_dbus_register_interface(struct wpa_supplicant
*wpa_s
)
2739 struct wpa_dbus_object_desc
*obj_desc
= NULL
;
2740 struct wpas_dbus_priv
*ctrl_iface
= wpa_s
->global
->dbus
;
2743 /* Do nothing if the control interface is not turned on */
2744 if (ctrl_iface
== NULL
)
2747 /* Create and set the interface's object path */
2748 wpa_s
->dbus_new_path
= os_zalloc(WPAS_DBUS_OBJECT_PATH_MAX
);
2749 if (wpa_s
->dbus_new_path
== NULL
)
2751 next
= ctrl_iface
->next_objid
++;
2752 os_snprintf(wpa_s
->dbus_new_path
, WPAS_DBUS_OBJECT_PATH_MAX
,
2753 WPAS_DBUS_NEW_PATH_INTERFACES
"/%u",
2756 obj_desc
= os_zalloc(sizeof(struct wpa_dbus_object_desc
));
2758 wpa_printf(MSG_ERROR
, "Not enough memory "
2759 "to create object description");
2763 wpas_dbus_register(obj_desc
, wpa_s
, NULL
, wpas_dbus_interface_methods
,
2764 wpas_dbus_interface_properties
,
2765 wpas_dbus_interface_signals
);
2767 wpa_printf(MSG_DEBUG
, "dbus: Register interface object '%s'",
2768 wpa_s
->dbus_new_path
);
2769 if (wpa_dbus_register_object_per_iface(ctrl_iface
,
2770 wpa_s
->dbus_new_path
,
2771 wpa_s
->ifname
, obj_desc
))
2774 wpas_dbus_signal_interface_added(wpa_s
);
2779 os_free(wpa_s
->dbus_new_path
);
2780 wpa_s
->dbus_new_path
= NULL
;
2781 free_dbus_object_desc(obj_desc
);
2786 int wpas_dbus_unregister_interface(struct wpa_supplicant
*wpa_s
)
2788 struct wpas_dbus_priv
*ctrl_iface
;
2790 /* Do nothing if the control interface is not turned on */
2791 if (wpa_s
== NULL
|| wpa_s
->global
== NULL
)
2793 ctrl_iface
= wpa_s
->global
->dbus
;
2794 if (ctrl_iface
== NULL
)
2797 wpa_printf(MSG_DEBUG
, "dbus: Unregister interface object '%s'",
2798 wpa_s
->dbus_new_path
);
2799 if (wpa_dbus_unregister_object_per_iface(ctrl_iface
,
2800 wpa_s
->dbus_new_path
))
2803 wpas_dbus_signal_interface_removed(wpa_s
);
2805 os_free(wpa_s
->dbus_new_path
);
2806 wpa_s
->dbus_new_path
= NULL
;
2813 static const struct wpa_dbus_property_desc wpas_dbus_p2p_peer_properties
[] = {
2814 { "Properties", WPAS_DBUS_NEW_IFACE_P2P_PEER
, "a{sv}",
2815 wpas_dbus_getter_p2p_peer_properties
,
2818 { "IEs", WPAS_DBUS_NEW_IFACE_P2P_PEER
, "ay",
2819 wpas_dbus_getter_p2p_peer_ies
,
2822 { NULL
, NULL
, NULL
, NULL
, NULL
}
2825 static const struct wpa_dbus_signal_desc wpas_dbus_p2p_peer_signals
[] = {
2827 { NULL
, NULL
, { END_ARGS
} }
2831 * wpas_dbus_signal_peer - Send a peer related event signal
2832 * @wpa_s: %wpa_supplicant network interface data
2833 * @dev: peer device object
2834 * @interface: name of the interface emitting this signal.
2835 * In case of peer objects, it would be emitted by either
2836 * the "interface object" or by "peer objects"
2837 * @sig_name: signal name - DeviceFound
2839 * Notify listeners about event related with newly found p2p peer device
2841 static void wpas_dbus_signal_peer(struct wpa_supplicant
*wpa_s
,
2842 const u8
*dev_addr
, const char *interface
,
2843 const char *sig_name
)
2845 struct wpas_dbus_priv
*iface
;
2847 DBusMessageIter iter
;
2848 char peer_obj_path
[WPAS_DBUS_OBJECT_PATH_MAX
], *path
;
2850 iface
= wpa_s
->global
->dbus
;
2852 /* Do nothing if the control interface is not turned on */
2856 os_snprintf(peer_obj_path
, WPAS_DBUS_OBJECT_PATH_MAX
,
2857 "%s/" WPAS_DBUS_NEW_P2P_PEERS_PART
"/" COMPACT_MACSTR
,
2858 wpa_s
->dbus_new_path
, MAC2STR(dev_addr
));
2860 msg
= dbus_message_new_signal(wpa_s
->dbus_new_path
, interface
,
2865 dbus_message_iter_init_append(msg
, &iter
);
2866 path
= peer_obj_path
;
2867 if (!dbus_message_iter_append_basic(&iter
, DBUS_TYPE_OBJECT_PATH
,
2871 dbus_connection_send(iface
->con
, msg
, NULL
);
2873 dbus_message_unref(msg
);
2877 wpa_printf(MSG_ERROR
, "dbus: Failed to construct signal");
2878 dbus_message_unref(msg
);
2883 * wpas_dbus_signal_peer_found - Send a peer found signal
2884 * @wpa_s: %wpa_supplicant network interface data
2885 * @dev: peer device object
2887 * Notify listeners about find a p2p peer device found
2889 void wpas_dbus_signal_peer_device_found(struct wpa_supplicant
*wpa_s
,
2892 wpas_dbus_signal_peer(wpa_s
, dev_addr
,
2893 WPAS_DBUS_NEW_IFACE_P2PDEVICE
,
2898 * wpas_dbus_signal_peer_lost - Send a peer lost signal
2899 * @wpa_s: %wpa_supplicant network interface data
2900 * @dev: peer device object
2902 * Notify listeners about lost a p2p peer device
2904 void wpas_dbus_signal_peer_device_lost(struct wpa_supplicant
*wpa_s
,
2907 wpas_dbus_signal_peer(wpa_s
, dev_addr
,
2908 WPAS_DBUS_NEW_IFACE_P2PDEVICE
,
2913 * wpas_dbus_register_peer - Register a discovered peer object with dbus
2914 * @wpa_s: wpa_supplicant interface structure
2915 * @ssid: network configuration data
2916 * Returns: 0 on success, -1 on failure
2918 * Registers network representing object with dbus
2920 int wpas_dbus_register_peer(struct wpa_supplicant
*wpa_s
, const u8
*dev_addr
)
2922 struct wpas_dbus_priv
*ctrl_iface
;
2923 struct wpa_dbus_object_desc
*obj_desc
;
2924 struct peer_handler_args
*arg
;
2925 char peer_obj_path
[WPAS_DBUS_OBJECT_PATH_MAX
];
2927 /* Do nothing if the control interface is not turned on */
2928 if (wpa_s
== NULL
|| wpa_s
->global
== NULL
)
2931 ctrl_iface
= wpa_s
->global
->dbus
;
2932 if (ctrl_iface
== NULL
)
2935 os_snprintf(peer_obj_path
, WPAS_DBUS_OBJECT_PATH_MAX
,
2936 "%s/" WPAS_DBUS_NEW_P2P_PEERS_PART
"/" COMPACT_MACSTR
,
2937 wpa_s
->dbus_new_path
, MAC2STR(dev_addr
));
2939 wpa_printf(MSG_INFO
, "dbus: Register peer object '%s'",
2941 obj_desc
= os_zalloc(sizeof(struct wpa_dbus_object_desc
));
2943 wpa_printf(MSG_ERROR
, "Not enough memory "
2944 "to create object description");
2948 /* allocate memory for handlers arguments */
2949 arg
= os_zalloc(sizeof(struct peer_handler_args
));
2951 wpa_printf(MSG_ERROR
, "Not enough memory "
2952 "to create arguments for method");
2957 os_memcpy(arg
->p2p_device_addr
, dev_addr
, ETH_ALEN
);
2959 wpas_dbus_register(obj_desc
, arg
, wpa_dbus_free
,
2961 wpas_dbus_p2p_peer_properties
,
2962 wpas_dbus_p2p_peer_signals
);
2964 if (wpa_dbus_register_object_per_iface(ctrl_iface
, peer_obj_path
,
2965 wpa_s
->ifname
, obj_desc
))
2971 free_dbus_object_desc(obj_desc
);
2976 * wpas_dbus_unregister_peer - Unregister a peer object with dbus
2977 * @wpa_s: wpa_supplicant interface structure
2978 * @dev_addr: p2p device addr
2979 * Returns: 0 on success, -1 on failure
2981 * Registers network representing object with dbus
2983 int wpas_dbus_unregister_peer(struct wpa_supplicant
*wpa_s
,
2986 struct wpas_dbus_priv
*ctrl_iface
;
2987 char peer_obj_path
[WPAS_DBUS_OBJECT_PATH_MAX
];
2990 /* Do nothing if the control interface is not turned on */
2991 if (wpa_s
== NULL
|| wpa_s
->global
== NULL
||
2992 wpa_s
->dbus_new_path
== NULL
)
2994 ctrl_iface
= wpa_s
->global
->dbus
;
2995 if (ctrl_iface
== NULL
)
2998 os_snprintf(peer_obj_path
, WPAS_DBUS_OBJECT_PATH_MAX
,
2999 "%s/" WPAS_DBUS_NEW_P2P_PEERS_PART
"/" COMPACT_MACSTR
,
3000 wpa_s
->dbus_new_path
, MAC2STR(dev_addr
));
3002 wpa_printf(MSG_INFO
, "dbus: Unregister peer object '%s'",
3004 ret
= wpa_dbus_unregister_object_per_iface(ctrl_iface
, peer_obj_path
);
3010 static const struct wpa_dbus_property_desc wpas_dbus_p2p_group_properties
[] = {
3011 { "Members", WPAS_DBUS_NEW_IFACE_P2P_GROUP
, "ao",
3012 wpas_dbus_getter_p2p_group_members
,
3016 WPAS_DBUS_NEW_IFACE_P2P_GROUP
, "a{sv}",
3017 wpas_dbus_getter_p2p_group_properties
,
3018 wpas_dbus_setter_p2p_group_properties
3020 { NULL
, NULL
, NULL
, NULL
, NULL
}
3023 static const struct wpa_dbus_signal_desc wpas_dbus_p2p_group_signals
[] = {
3024 { "PeerJoined", WPAS_DBUS_NEW_IFACE_P2P_GROUP
,
3026 { "peer", "o", ARG_OUT
},
3030 { "PeerDisconnected", WPAS_DBUS_NEW_IFACE_P2P_GROUP
,
3032 { "peer", "o", ARG_OUT
},
3036 { NULL
, NULL
, { END_ARGS
} }
3040 * wpas_dbus_register_p2p_group - Register a p2p group object with dbus
3041 * @wpa_s: wpa_supplicant interface structure
3042 * @ssid: SSID struct
3043 * Returns: 0 on success, -1 on failure
3045 * Registers p2p group representing object with dbus
3047 void wpas_dbus_register_p2p_group(struct wpa_supplicant
*wpa_s
,
3048 struct wpa_ssid
*ssid
)
3050 struct wpas_dbus_priv
*ctrl_iface
;
3051 struct wpa_dbus_object_desc
*obj_desc
;
3052 char group_obj_path
[WPAS_DBUS_OBJECT_PATH_MAX
];
3054 /* Do nothing if the control interface is not turned on */
3055 if (wpa_s
== NULL
|| wpa_s
->global
== NULL
)
3058 ctrl_iface
= wpa_s
->global
->dbus
;
3059 if (ctrl_iface
== NULL
)
3062 if (wpa_s
->dbus_groupobj_path
) {
3063 wpa_printf(MSG_INFO
, "%s: Group object '%s' already exists",
3064 __func__
, wpa_s
->dbus_groupobj_path
);
3068 if (wpas_dbus_get_group_obj_path(wpa_s
, ssid
, group_obj_path
) < 0)
3071 wpa_s
->dbus_groupobj_path
= os_strdup(group_obj_path
);
3072 if (wpa_s
->dbus_groupobj_path
== NULL
)
3075 wpa_printf(MSG_INFO
, "dbus: Register group object '%s'",
3077 obj_desc
= os_zalloc(sizeof(struct wpa_dbus_object_desc
));
3079 wpa_printf(MSG_ERROR
, "Not enough memory "
3080 "to create object description");
3084 wpas_dbus_register(obj_desc
, wpa_s
, NULL
, NULL
,
3085 wpas_dbus_p2p_group_properties
,
3086 wpas_dbus_p2p_group_signals
);
3088 if (wpa_dbus_register_object_per_iface(ctrl_iface
, group_obj_path
,
3089 wpa_s
->ifname
, obj_desc
))
3095 if (wpa_s
->dbus_groupobj_path
) {
3096 os_free(wpa_s
->dbus_groupobj_path
);
3097 wpa_s
->dbus_groupobj_path
= NULL
;
3100 free_dbus_object_desc(obj_desc
);
3104 * wpas_dbus_unregister_p2p_group - Unregister a p2p group object from dbus
3105 * @wpa_s: wpa_supplicant interface structure
3106 * @ssid: network name of the p2p group started
3108 void wpas_dbus_unregister_p2p_group(struct wpa_supplicant
*wpa_s
,
3109 const struct wpa_ssid
*ssid
)
3111 struct wpas_dbus_priv
*ctrl_iface
;
3113 /* Do nothing if the control interface is not turned on */
3114 if (wpa_s
== NULL
|| wpa_s
->global
== NULL
)
3117 ctrl_iface
= wpa_s
->global
->dbus
;
3118 if (ctrl_iface
== NULL
)
3121 if (!wpa_s
->dbus_groupobj_path
) {
3122 wpa_printf(MSG_DEBUG
,
3123 "%s: Group object '%s' already unregistered",
3124 __func__
, wpa_s
->dbus_groupobj_path
);
3128 wpa_printf(MSG_DEBUG
, "dbus: Unregister group object '%s'",
3129 wpa_s
->dbus_groupobj_path
);
3131 wpa_dbus_unregister_object_per_iface(ctrl_iface
,
3132 wpa_s
->dbus_groupobj_path
);
3134 os_free(wpa_s
->dbus_groupobj_path
);
3135 wpa_s
->dbus_groupobj_path
= NULL
;
3138 static const struct wpa_dbus_property_desc
3139 wpas_dbus_p2p_groupmember_properties
[] = {
3140 { "Properties", WPAS_DBUS_NEW_IFACE_P2P_GROUPMEMBER
, "a{sv}",
3141 wpas_dbus_getter_p2p_group_properties
,
3144 { NULL
, NULL
, NULL
, NULL
, NULL
}
3148 * wpas_dbus_register_p2p_groupmember - Register a p2p groupmember
3150 * @wpa_s: wpa_supplicant interface structure
3151 * @p2p_if_addr: i/f addr of the device joining this group
3153 * Registers p2p groupmember representing object with dbus
3155 void wpas_dbus_register_p2p_groupmember(struct wpa_supplicant
*wpa_s
,
3156 const u8
*p2p_if_addr
)
3158 struct wpas_dbus_priv
*ctrl_iface
;
3159 struct wpa_dbus_object_desc
*obj_desc
= NULL
;
3160 struct groupmember_handler_args
*arg
;
3161 char groupmember_obj_path
[WPAS_DBUS_OBJECT_PATH_MAX
];
3163 /* Do nothing if the control interface is not turned on */
3164 if (wpa_s
== NULL
|| wpa_s
->global
== NULL
)
3167 ctrl_iface
= wpa_s
->global
->dbus
;
3168 if (ctrl_iface
== NULL
)
3171 if (!wpa_s
->dbus_groupobj_path
)
3174 os_snprintf(groupmember_obj_path
, WPAS_DBUS_OBJECT_PATH_MAX
,
3175 "%s/" WPAS_DBUS_NEW_P2P_GROUPMEMBERS_PART
"/" COMPACT_MACSTR
,
3176 wpa_s
->dbus_groupobj_path
, MAC2STR(p2p_if_addr
));
3178 obj_desc
= os_zalloc(sizeof(struct wpa_dbus_object_desc
));
3180 wpa_printf(MSG_ERROR
, "Not enough memory "
3181 "to create object description");
3185 /* allocate memory for handlers arguments */
3186 arg
= os_zalloc(sizeof(struct groupmember_handler_args
));
3188 wpa_printf(MSG_ERROR
, "Not enough memory "
3189 "to create arguments for method");
3194 os_memcpy(arg
->member_addr
, p2p_if_addr
, ETH_ALEN
);
3196 wpas_dbus_register(obj_desc
, arg
, wpa_dbus_free
, NULL
,
3197 wpas_dbus_p2p_groupmember_properties
, NULL
);
3199 if (wpa_dbus_register_object_per_iface(ctrl_iface
, groupmember_obj_path
,
3200 wpa_s
->ifname
, obj_desc
))
3203 wpa_printf(MSG_INFO
,
3204 "dbus: Registered group member object '%s' successfully",
3205 groupmember_obj_path
);
3209 free_dbus_object_desc(obj_desc
);
3213 * wpas_dbus_unregister_p2p_groupmember - Unregister a p2p groupmember
3215 * @wpa_s: wpa_supplicant interface structure
3216 * @p2p_if_addr: i/f addr of the device joining this group
3218 * Unregisters p2p groupmember representing object with dbus
3220 void wpas_dbus_unregister_p2p_groupmember(struct wpa_supplicant
*wpa_s
,
3221 const u8
*p2p_if_addr
)
3223 struct wpas_dbus_priv
*ctrl_iface
;
3224 char groupmember_obj_path
[WPAS_DBUS_OBJECT_PATH_MAX
];
3226 /* Do nothing if the control interface is not turned on */
3227 if (wpa_s
== NULL
|| wpa_s
->global
== NULL
)
3230 ctrl_iface
= wpa_s
->global
->dbus
;
3231 if (ctrl_iface
== NULL
)
3234 if (!wpa_s
->dbus_groupobj_path
)
3237 os_snprintf(groupmember_obj_path
, WPAS_DBUS_OBJECT_PATH_MAX
,
3238 "%s/" WPAS_DBUS_NEW_P2P_GROUPMEMBERS_PART
"/" COMPACT_MACSTR
,
3239 wpa_s
->dbus_groupobj_path
, MAC2STR(p2p_if_addr
));
3241 wpa_dbus_unregister_object_per_iface(ctrl_iface
, groupmember_obj_path
);
3245 static const struct wpa_dbus_property_desc
3246 wpas_dbus_persistent_group_properties
[] = {
3247 { "Properties", WPAS_DBUS_NEW_IFACE_PERSISTENT_GROUP
, "a{sv}",
3248 wpas_dbus_getter_persistent_group_properties
,
3249 wpas_dbus_setter_persistent_group_properties
3251 { NULL
, NULL
, NULL
, NULL
, NULL
}
3254 /* No signals intended for persistent group objects */
3257 * wpas_dbus_register_persistent_group - Register a configured(saved)
3258 * persistent group with dbus
3259 * @wpa_s: wpa_supplicant interface structure
3260 * @ssid: persistent group (still represented as a network within wpa)
3261 * configuration data
3262 * Returns: 0 on success, -1 on failure
3264 * Registers a persistent group representing object with dbus.
3266 int wpas_dbus_register_persistent_group(struct wpa_supplicant
*wpa_s
,
3267 struct wpa_ssid
*ssid
)
3269 struct wpas_dbus_priv
*ctrl_iface
;
3270 struct wpa_dbus_object_desc
*obj_desc
;
3271 struct network_handler_args
*arg
;
3272 char pgrp_obj_path
[WPAS_DBUS_OBJECT_PATH_MAX
];
3274 /* Do nothing if the control interface is not turned on */
3275 if (wpa_s
== NULL
|| wpa_s
->global
== NULL
)
3278 /* Make sure ssid is a persistent group */
3279 if (ssid
->disabled
!= 2 && !ssid
->p2p_persistent_group
)
3280 return -1; /* should we return w/o complaining? */
3282 ctrl_iface
= wpa_s
->global
->dbus
;
3283 if (ctrl_iface
== NULL
)
3287 * Intentionally not coming up with different numbering scheme
3288 * for persistent groups.
3290 os_snprintf(pgrp_obj_path
, WPAS_DBUS_OBJECT_PATH_MAX
,
3291 "%s/" WPAS_DBUS_NEW_PERSISTENT_GROUPS_PART
"/%u",
3292 wpa_s
->dbus_new_path
, ssid
->id
);
3294 wpa_printf(MSG_DEBUG
, "dbus: Register persistent group object '%s'",
3296 obj_desc
= os_zalloc(sizeof(struct wpa_dbus_object_desc
));
3298 wpa_printf(MSG_ERROR
, "dbus: Not enough memory to create "
3299 "object description");
3304 * Reusing the same context structure as that for networks
3305 * since these are represented using same data structure.
3307 /* allocate memory for handlers arguments */
3308 arg
= os_zalloc(sizeof(struct network_handler_args
));
3310 wpa_printf(MSG_ERROR
, "dbus: Not enough memory to create "
3311 "arguments for method");
3318 wpas_dbus_register(obj_desc
, arg
, wpa_dbus_free
, NULL
,
3319 wpas_dbus_persistent_group_properties
,
3322 if (wpa_dbus_register_object_per_iface(ctrl_iface
, pgrp_obj_path
,
3323 wpa_s
->ifname
, obj_desc
))
3326 wpas_dbus_signal_persistent_group_added(wpa_s
, ssid
->id
);
3331 free_dbus_object_desc(obj_desc
);
3337 * wpas_dbus_unregister_persistent_group - Unregister a persistent_group
3339 * @wpa_s: wpa_supplicant interface structure
3341 * Returns: 0 on success, -1 on failure
3343 * Unregisters persistent group representing object from dbus
3345 * NOTE: There is a slight issue with the semantics here. While the
3346 * implementation simply means the persistent group is unloaded from memory,
3347 * it should not get interpreted as the group is actually being erased/removed
3348 * from persistent storage as well.
3350 int wpas_dbus_unregister_persistent_group(struct wpa_supplicant
*wpa_s
,
3353 struct wpas_dbus_priv
*ctrl_iface
;
3354 char pgrp_obj_path
[WPAS_DBUS_OBJECT_PATH_MAX
];
3357 /* Do nothing if the control interface is not turned on */
3358 if (wpa_s
== NULL
|| wpa_s
->global
== NULL
||
3359 wpa_s
->dbus_new_path
== NULL
)
3361 ctrl_iface
= wpa_s
->global
->dbus
;
3362 if (ctrl_iface
== NULL
)
3365 os_snprintf(pgrp_obj_path
, WPAS_DBUS_OBJECT_PATH_MAX
,
3366 "%s/" WPAS_DBUS_NEW_PERSISTENT_GROUPS_PART
"/%u",
3367 wpa_s
->dbus_new_path
, nid
);
3369 wpa_printf(MSG_DEBUG
, "dbus: Unregister persistent group object '%s'",
3371 ret
= wpa_dbus_unregister_object_per_iface(ctrl_iface
, pgrp_obj_path
);
3374 wpas_dbus_signal_persistent_group_removed(wpa_s
, nid
);
3379 #endif /* CONFIG_P2P */