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 "dbus_new_helpers.h"
26 #include "dbus_dict_helpers.h"
28 #include "dbus_new_handlers.h"
29 #include "dbus_common.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_enabled_changed - Signals Enabled property changes
386 * @wpa_s: %wpa_supplicant network interface data
387 * @ssid: configured network which Enabled property has changed
389 * Sends PropertyChanged signals containing new value of Enabled property
390 * for specified network
392 void wpas_dbus_signal_network_enabled_changed(struct wpa_supplicant
*wpa_s
,
393 struct wpa_ssid
*ssid
)
396 char path
[WPAS_DBUS_OBJECT_PATH_MAX
];
397 os_snprintf(path
, WPAS_DBUS_OBJECT_PATH_MAX
,
398 "%s/" WPAS_DBUS_NEW_NETWORKS_PART
"/%d",
399 wpa_s
->dbus_new_path
, ssid
->id
);
401 wpa_dbus_mark_property_changed(wpa_s
->global
->dbus
, path
,
402 WPAS_DBUS_NEW_IFACE_NETWORK
, "Enabled");
409 * wpas_dbus_signal_wps_event_success - Signals Success WPS event
410 * @wpa_s: %wpa_supplicant network interface data
412 * Sends Event dbus signal with name "success" and empty dict as arguments
414 void wpas_dbus_signal_wps_event_success(struct wpa_supplicant
*wpa_s
)
418 DBusMessageIter iter
, dict_iter
;
419 struct wpas_dbus_priv
*iface
;
420 char *key
= "success";
422 iface
= wpa_s
->global
->dbus
;
424 /* Do nothing if the control interface is not turned on */
428 msg
= dbus_message_new_signal(wpa_s
->dbus_new_path
,
429 WPAS_DBUS_NEW_IFACE_WPS
, "Event");
433 dbus_message_iter_init_append(msg
, &iter
);
435 if (!dbus_message_iter_append_basic(&iter
, DBUS_TYPE_STRING
, &key
) ||
436 !wpa_dbus_dict_open_write(&iter
, &dict_iter
) ||
437 !wpa_dbus_dict_close_write(&iter
, &dict_iter
))
438 wpa_printf(MSG_ERROR
, "dbus: Failed to construct signal");
440 dbus_connection_send(iface
->con
, msg
, NULL
);
442 dbus_message_unref(msg
);
447 * wpas_dbus_signal_wps_event_fail - Signals Fail WPS event
448 * @wpa_s: %wpa_supplicant network interface data
450 * Sends Event dbus signal with name "fail" and dictionary containing
451 * "msg field with fail message number (int32) as arguments
453 void wpas_dbus_signal_wps_event_fail(struct wpa_supplicant
*wpa_s
,
454 struct wps_event_fail
*fail
)
458 DBusMessageIter iter
, dict_iter
;
459 struct wpas_dbus_priv
*iface
;
462 iface
= wpa_s
->global
->dbus
;
464 /* Do nothing if the control interface is not turned on */
468 msg
= dbus_message_new_signal(wpa_s
->dbus_new_path
,
469 WPAS_DBUS_NEW_IFACE_WPS
, "Event");
473 dbus_message_iter_init_append(msg
, &iter
);
475 if (!dbus_message_iter_append_basic(&iter
, DBUS_TYPE_STRING
, &key
) ||
476 !wpa_dbus_dict_open_write(&iter
, &dict_iter
) ||
477 !wpa_dbus_dict_append_int32(&dict_iter
, "msg", fail
->msg
) ||
478 !wpa_dbus_dict_close_write(&iter
, &dict_iter
))
479 wpa_printf(MSG_ERROR
, "dbus: Failed to construct signal");
481 dbus_connection_send(iface
->con
, msg
, NULL
);
483 dbus_message_unref(msg
);
488 * wpas_dbus_signal_wps_event_m2d - Signals M2D WPS event
489 * @wpa_s: %wpa_supplicant network interface data
491 * Sends Event dbus signal with name "m2d" and dictionary containing
492 * fields of wps_event_m2d structure.
494 void wpas_dbus_signal_wps_event_m2d(struct wpa_supplicant
*wpa_s
,
495 struct wps_event_m2d
*m2d
)
499 DBusMessageIter iter
, dict_iter
;
500 struct wpas_dbus_priv
*iface
;
503 iface
= wpa_s
->global
->dbus
;
505 /* Do nothing if the control interface is not turned on */
509 msg
= dbus_message_new_signal(wpa_s
->dbus_new_path
,
510 WPAS_DBUS_NEW_IFACE_WPS
, "Event");
514 dbus_message_iter_init_append(msg
, &iter
);
516 if (!dbus_message_iter_append_basic(&iter
, DBUS_TYPE_STRING
, &key
) ||
517 !wpa_dbus_dict_open_write(&iter
, &dict_iter
) ||
518 !wpa_dbus_dict_append_uint16(&dict_iter
, "config_methods",
519 m2d
->config_methods
) ||
520 !wpa_dbus_dict_append_byte_array(&dict_iter
, "manufacturer",
521 (const char *) m2d
->manufacturer
,
522 m2d
->manufacturer_len
) ||
523 !wpa_dbus_dict_append_byte_array(&dict_iter
, "model_name",
524 (const char *) m2d
->model_name
,
525 m2d
->model_name_len
) ||
526 !wpa_dbus_dict_append_byte_array(&dict_iter
, "model_number",
527 (const char *) m2d
->model_number
,
528 m2d
->model_number_len
) ||
529 !wpa_dbus_dict_append_byte_array(&dict_iter
, "serial_number",
532 m2d
->serial_number_len
) ||
533 !wpa_dbus_dict_append_byte_array(&dict_iter
, "dev_name",
534 (const char *) m2d
->dev_name
,
535 m2d
->dev_name_len
) ||
536 !wpa_dbus_dict_append_byte_array(&dict_iter
, "primary_dev_type",
538 m2d
->primary_dev_type
, 8) ||
539 !wpa_dbus_dict_append_uint16(&dict_iter
, "config_error",
540 m2d
->config_error
) ||
541 !wpa_dbus_dict_append_uint16(&dict_iter
, "dev_password_id",
542 m2d
->dev_password_id
) ||
543 !wpa_dbus_dict_close_write(&iter
, &dict_iter
))
544 wpa_printf(MSG_ERROR
, "dbus: Failed to construct signal");
546 dbus_connection_send(iface
->con
, msg
, NULL
);
548 dbus_message_unref(msg
);
553 * wpas_dbus_signal_wps_cred - Signals new credentials
554 * @wpa_s: %wpa_supplicant network interface data
556 * Sends signal with credentials in directory argument
558 void wpas_dbus_signal_wps_cred(struct wpa_supplicant
*wpa_s
,
559 const struct wps_credential
*cred
)
562 DBusMessageIter iter
, dict_iter
;
563 struct wpas_dbus_priv
*iface
;
564 char *auth_type
[6]; /* we have six possible authorization types */
566 char *encr_type
[4]; /* we have four possible encryption types */
569 iface
= wpa_s
->global
->dbus
;
571 /* Do nothing if the control interface is not turned on */
575 msg
= dbus_message_new_signal(wpa_s
->dbus_new_path
,
576 WPAS_DBUS_NEW_IFACE_WPS
,
581 dbus_message_iter_init_append(msg
, &iter
);
582 if (!wpa_dbus_dict_open_write(&iter
, &dict_iter
))
585 if (cred
->auth_type
& WPS_AUTH_OPEN
)
586 auth_type
[at_num
++] = "open";
587 if (cred
->auth_type
& WPS_AUTH_WPAPSK
)
588 auth_type
[at_num
++] = "wpa-psk";
589 if (cred
->auth_type
& WPS_AUTH_SHARED
)
590 auth_type
[at_num
++] = "shared";
591 if (cred
->auth_type
& WPS_AUTH_WPA
)
592 auth_type
[at_num
++] = "wpa-eap";
593 if (cred
->auth_type
& WPS_AUTH_WPA2
)
594 auth_type
[at_num
++] = "wpa2-eap";
595 if (cred
->auth_type
& WPS_AUTH_WPA2PSK
)
596 auth_type
[at_num
++] =
599 if (cred
->encr_type
& WPS_ENCR_NONE
)
600 encr_type
[et_num
++] = "none";
601 if (cred
->encr_type
& WPS_ENCR_WEP
)
602 encr_type
[et_num
++] = "wep";
603 if (cred
->encr_type
& WPS_ENCR_TKIP
)
604 encr_type
[et_num
++] = "tkip";
605 if (cred
->encr_type
& WPS_ENCR_AES
)
606 encr_type
[et_num
++] = "aes";
608 if (wpa_s
->current_ssid
) {
609 if (!wpa_dbus_dict_append_byte_array(
611 (const char *) wpa_s
->current_ssid
->bssid
,
616 if (!wpa_dbus_dict_append_byte_array(&dict_iter
, "SSID",
617 (const char *) cred
->ssid
,
619 !wpa_dbus_dict_append_string_array(&dict_iter
, "AuthType",
620 (const char **) auth_type
,
622 !wpa_dbus_dict_append_string_array(&dict_iter
, "EncrType",
623 (const char **) encr_type
,
625 !wpa_dbus_dict_append_byte_array(&dict_iter
, "Key",
626 (const char *) cred
->key
,
628 !wpa_dbus_dict_append_uint32(&dict_iter
, "KeyIndex",
630 !wpa_dbus_dict_close_write(&iter
, &dict_iter
))
633 dbus_connection_send(iface
->con
, msg
, NULL
);
636 dbus_message_unref(msg
);
639 #endif /* CONFIG_WPS */
641 void wpas_dbus_signal_certification(struct wpa_supplicant
*wpa_s
,
642 int depth
, const char *subject
,
643 const char *cert_hash
,
644 const struct wpabuf
*cert
)
646 struct wpas_dbus_priv
*iface
;
648 DBusMessageIter iter
, dict_iter
;
650 iface
= wpa_s
->global
->dbus
;
652 /* Do nothing if the control interface is not turned on */
656 msg
= dbus_message_new_signal(wpa_s
->dbus_new_path
,
657 WPAS_DBUS_NEW_IFACE_INTERFACE
,
662 dbus_message_iter_init_append(msg
, &iter
);
663 if (!wpa_dbus_dict_open_write(&iter
, &dict_iter
))
666 if (!wpa_dbus_dict_append_uint32(&dict_iter
, "depth", depth
) ||
667 !wpa_dbus_dict_append_string(&dict_iter
, "subject", subject
))
671 !wpa_dbus_dict_append_string(&dict_iter
, "cert_hash", cert_hash
))
675 !wpa_dbus_dict_append_byte_array(&dict_iter
, "cert",
680 if (!wpa_dbus_dict_close_write(&iter
, &dict_iter
))
683 dbus_connection_send(iface
->con
, msg
, NULL
);
686 dbus_message_unref(msg
);
692 * wpas_dbus_signal_p2p_group_removed - Signals P2P group was removed
693 * @wpa_s: %wpa_supplicant network interface data
694 * @role: role of this device (client or GO)
695 * Sends signal with i/f name and role as string arguments
697 void wpas_dbus_signal_p2p_group_removed(struct wpa_supplicant
*wpa_s
,
702 DBusMessageIter iter
;
703 struct wpas_dbus_priv
*iface
= wpa_s
->global
->dbus
;
704 char *ifname
= wpa_s
->ifname
;
706 /* Do nothing if the control interface is not turned on */
710 msg
= dbus_message_new_signal(wpa_s
->dbus_new_path
,
711 WPAS_DBUS_NEW_IFACE_P2PDEVICE
,
716 dbus_message_iter_init_append(msg
, &iter
);
718 if (!dbus_message_iter_append_basic(&iter
, DBUS_TYPE_STRING
, &ifname
)) {
719 wpa_printf(MSG_ERROR
, "dbus: Failed to construct GroupFinished"
720 "signal -not enough memory for ifname ");
724 if (!dbus_message_iter_append_basic(&iter
, DBUS_TYPE_STRING
, &role
))
725 wpa_printf(MSG_ERROR
, "dbus: Failed to construct GroupFinished"
726 "signal -not enough memory for role ");
728 dbus_connection_send(iface
->con
, msg
, NULL
);
731 dbus_message_unref(msg
);
736 * wpas_dbus_signal_p2p_provision_discovery - Signals various PD events
738 * @dev_addr - who sent the request or responded to our request.
739 * @request - Will be 1 if request, 0 for response.
740 * @status - valid only in case of response
741 * @config_methods - wps config methods
742 * @generated_pin - pin to be displayed in case of WPS_CONFIG_DISPLAY method
744 * Sends following provision discovery related events:
745 * ProvisionDiscoveryRequestDisplayPin
746 * ProvisionDiscoveryResponseDisplayPin
747 * ProvisionDiscoveryRequestEnterPin
748 * ProvisionDiscoveryResponseEnterPin
749 * ProvisionDiscoveryPBCRequest
750 * ProvisionDiscoveryPBCResponse
753 * ProvisionDiscoveryFailure (timeout case)
755 void wpas_dbus_signal_p2p_provision_discovery(struct wpa_supplicant
*wpa_s
,
756 const u8
*dev_addr
, int request
,
757 enum p2p_prov_disc_status status
,
759 unsigned int generated_pin
)
762 DBusMessageIter iter
;
763 struct wpas_dbus_priv
*iface
;
766 char peer_obj_path
[WPAS_DBUS_OBJECT_PATH_MAX
], *path
;
768 char pin
[9], *p_pin
= NULL
;
770 iface
= wpa_s
->global
->dbus
;
772 /* Do nothing if the control interface is not turned on */
776 if (request
|| !status
) {
777 if (config_methods
& WPS_CONFIG_DISPLAY
)
779 "ProvisionDiscoveryRequestDisplayPin" :
780 "ProvisionDiscoveryResponseEnterPin";
781 else if (config_methods
& WPS_CONFIG_KEYPAD
)
783 "ProvisionDiscoveryRequestEnterPin" :
784 "ProvisionDiscoveryResponseDisplayPin";
785 else if (config_methods
& WPS_CONFIG_PUSHBUTTON
)
786 _signal
= request
? "ProvisionDiscoveryPBCRequest" :
787 "ProvisionDiscoveryPBCResponse";
789 return; /* Unknown or un-supported method */
790 } else if (!request
&& status
)
791 /* Explicit check for failure response */
792 _signal
= "ProvisionDiscoveryFailure";
794 add_pin
= ((request
&& (config_methods
& WPS_CONFIG_DISPLAY
)) ||
795 (!request
&& !status
&&
796 (config_methods
& WPS_CONFIG_KEYPAD
)));
799 os_snprintf(pin
, sizeof(pin
), "%08d", generated_pin
);
803 msg
= dbus_message_new_signal(wpa_s
->dbus_new_path
,
804 WPAS_DBUS_NEW_IFACE_P2PDEVICE
, _signal
);
808 /* Check if this is a known peer */
809 if (p2p_get_peer_info(wpa_s
->global
->p2p
, dev_addr
, 0, NULL
, 0) < 0)
812 os_snprintf(peer_obj_path
, WPAS_DBUS_OBJECT_PATH_MAX
,
813 "%s/" WPAS_DBUS_NEW_P2P_PEERS_PART
"/"
815 wpa_s
->dbus_new_path
, MAC2STR(dev_addr
));
817 path
= peer_obj_path
;
819 dbus_message_iter_init_append(msg
, &iter
);
821 if (!dbus_message_iter_append_basic(&iter
,
822 DBUS_TYPE_OBJECT_PATH
,
826 if (!request
&& status
)
827 /* Attach status to ProvisionDiscoveryFailure */
828 error_ret
= !dbus_message_iter_append_basic(&iter
,
832 error_ret
= (add_pin
&&
833 !dbus_message_iter_append_basic(&iter
,
839 dbus_connection_send(iface
->con
, msg
, NULL
);
841 wpa_printf(MSG_ERROR
, "dbus: Failed to construct signal");
843 dbus_message_unref(msg
);
847 void wpas_dbus_signal_p2p_go_neg_req(struct wpa_supplicant
*wpa_s
,
848 const u8
*src
, u16 dev_passwd_id
)
851 DBusMessageIter iter
;
852 struct wpas_dbus_priv
*iface
;
853 char peer_obj_path
[WPAS_DBUS_OBJECT_PATH_MAX
], *path
;
855 iface
= wpa_s
->global
->dbus
;
857 /* Do nothing if the control interface is not turned on */
861 os_snprintf(peer_obj_path
, WPAS_DBUS_OBJECT_PATH_MAX
,
862 "%s/" WPAS_DBUS_NEW_P2P_PEERS_PART
"/" COMPACT_MACSTR
,
863 wpa_s
->dbus_new_path
, MAC2STR(src
));
864 path
= peer_obj_path
;
866 msg
= dbus_message_new_signal(wpa_s
->dbus_new_path
,
867 WPAS_DBUS_NEW_IFACE_P2PDEVICE
,
868 "GONegotiationRequest");
872 dbus_message_iter_init_append(msg
, &iter
);
874 if (!dbus_message_iter_append_basic(&iter
, DBUS_TYPE_OBJECT_PATH
,
876 !dbus_message_iter_append_basic(&iter
, DBUS_TYPE_UINT16
,
878 wpa_printf(MSG_ERROR
, "dbus: Failed to construct signal");
880 dbus_connection_send(iface
->con
, msg
, NULL
);
882 dbus_message_unref(msg
);
886 static int wpas_dbus_get_group_obj_path(struct wpa_supplicant
*wpa_s
,
887 const struct wpa_ssid
*ssid
,
888 char *group_obj_path
)
892 if (os_memcmp(ssid
->ssid
, P2P_WILDCARD_SSID
, P2P_WILDCARD_SSID_LEN
))
895 memcpy(group_name
, ssid
->ssid
+ P2P_WILDCARD_SSID_LEN
, 2);
896 group_name
[2] = '\0';
898 os_snprintf(group_obj_path
, WPAS_DBUS_OBJECT_PATH_MAX
,
899 "%s/" WPAS_DBUS_NEW_P2P_GROUPS_PART
"/%s",
900 wpa_s
->dbus_new_path
, group_name
);
907 * wpas_dbus_signal_p2p_group_started - Signals P2P group has
908 * started. Emitted when a group is successfully started
909 * irrespective of the role (client/GO) of the current device
911 * @wpa_s: %wpa_supplicant network interface data
913 * @client: this device is P2P client
914 * @network_id: network id of the group started, use instead of ssid->id
915 * to account for persistent groups
917 void wpas_dbus_signal_p2p_group_started(struct wpa_supplicant
*wpa_s
,
918 const struct wpa_ssid
*ssid
,
919 int client
, int network_id
)
922 DBusMessageIter iter
, dict_iter
;
923 struct wpas_dbus_priv
*iface
;
924 char net_obj_path
[WPAS_DBUS_OBJECT_PATH_MAX
];
925 char group_obj_path
[WPAS_DBUS_OBJECT_PATH_MAX
];
927 iface
= wpa_s
->parent
->global
->dbus
;
929 /* Do nothing if the control interface is not turned on */
933 if (wpas_dbus_get_group_obj_path(wpa_s
, ssid
, group_obj_path
) < 0)
936 /* New interface has been created for this group */
937 msg
= dbus_message_new_signal(wpa_s
->parent
->dbus_new_path
,
938 WPAS_DBUS_NEW_IFACE_P2PDEVICE
,
944 dbus_message_iter_init_append(msg
, &iter
);
945 if (!wpa_dbus_dict_open_write(&iter
, &dict_iter
))
949 * In case the device supports creating a separate interface the
950 * DBus client will need to know the object path for the interface
951 * object this group was created on, so include it here.
953 if (!wpa_dbus_dict_append_object_path(&dict_iter
,
955 wpa_s
->dbus_new_path
))
958 if (!wpa_dbus_dict_append_string(&dict_iter
, "role",
959 client
? "client" : "GO"))
962 os_snprintf(net_obj_path
, WPAS_DBUS_OBJECT_PATH_MAX
,
963 "%s/" WPAS_DBUS_NEW_NETWORKS_PART
"/%u",
964 wpa_s
->parent
->dbus_new_path
, network_id
);
966 if (!wpa_dbus_dict_append_object_path(&dict_iter
, "group_object",
968 !wpa_dbus_dict_append_object_path(&dict_iter
, "network_object",
970 !wpa_dbus_dict_close_write(&iter
, &dict_iter
))
973 dbus_connection_send(iface
->con
, msg
, NULL
);
976 dbus_message_unref(msg
);
982 * Method to emit GONeogtiation Success or Failure signals based
984 * @status: Status of the GO neg request. 0 for success, other for errors.
986 void wpas_dbus_signal_p2p_go_neg_resp(struct wpa_supplicant
*wpa_s
, int status
)
989 DBusMessageIter iter
;
990 struct wpas_dbus_priv
*iface
;
992 iface
= wpa_s
->global
->dbus
;
994 /* Do nothing if the control interface is not turned on */
998 msg
= dbus_message_new_signal(wpa_s
->dbus_new_path
,
999 WPAS_DBUS_NEW_IFACE_P2PDEVICE
,
1000 status
? "GONegotiationFailure" :
1001 "GONegotiationSuccess");
1006 dbus_message_iter_init_append(msg
, &iter
);
1007 if (!dbus_message_iter_append_basic(&iter
, DBUS_TYPE_INT32
,
1009 wpa_printf(MSG_ERROR
,
1010 "dbus: Failed to construct signal");
1015 dbus_connection_send(iface
->con
, msg
, NULL
);
1017 dbus_message_unref(msg
);
1023 * Method to emit Invitation Result signal based on status and
1025 * @status: Status of the Invite request. 0 for success, other
1027 * @bssid : Basic Service Set Identifier
1029 void wpas_dbus_signal_p2p_invitation_result(struct wpa_supplicant
*wpa_s
,
1030 int status
, const u8
*bssid
)
1033 DBusMessageIter iter
, dict_iter
;
1034 struct wpas_dbus_priv
*iface
;
1036 wpa_printf(MSG_INFO
, "%s\n", __func__
);
1038 iface
= wpa_s
->global
->dbus
;
1039 /* Do nothing if the control interface is not turned on */
1043 msg
= dbus_message_new_signal(wpa_s
->dbus_new_path
,
1044 WPAS_DBUS_NEW_IFACE_P2PDEVICE
,
1045 "InvitationResult");
1050 dbus_message_iter_init_append(msg
, &iter
);
1051 if (!wpa_dbus_dict_open_write(&iter
, &dict_iter
))
1054 if (!wpa_dbus_dict_append_int32(&dict_iter
, "status", status
))
1057 if (!wpa_dbus_dict_append_byte_array(&dict_iter
, "BSSID",
1058 (const char *) bssid
,
1062 if (!wpa_dbus_dict_close_write(&iter
, &dict_iter
))
1065 dbus_connection_send(iface
->con
, msg
, NULL
);
1068 dbus_message_unref(msg
);
1074 * Method to emit a signal for a peer joining the group.
1075 * The signal will carry path to the group member object
1076 * constructed using p2p i/f addr used for connecting.
1078 * @wpa_s: %wpa_supplicant network interface data
1079 * @member_addr: addr (p2p i/f) of the peer joining the group
1081 void wpas_dbus_signal_p2p_peer_joined(struct wpa_supplicant
*wpa_s
,
1084 struct wpas_dbus_priv
*iface
;
1086 DBusMessageIter iter
;
1087 char groupmember_obj_path
[WPAS_DBUS_OBJECT_PATH_MAX
], *path
;
1089 iface
= wpa_s
->global
->dbus
;
1091 /* Do nothing if the control interface is not turned on */
1095 if (!wpa_s
->dbus_groupobj_path
)
1098 os_snprintf(groupmember_obj_path
, WPAS_DBUS_OBJECT_PATH_MAX
,
1099 "%s/" WPAS_DBUS_NEW_P2P_GROUPMEMBERS_PART
"/"
1101 wpa_s
->dbus_groupobj_path
, MAC2STR(member
));
1103 msg
= dbus_message_new_signal(wpa_s
->dbus_groupobj_path
,
1104 WPAS_DBUS_NEW_IFACE_P2P_GROUP
,
1109 dbus_message_iter_init_append(msg
, &iter
);
1110 path
= groupmember_obj_path
;
1111 if (!dbus_message_iter_append_basic(&iter
, DBUS_TYPE_OBJECT_PATH
,
1115 dbus_connection_send(iface
->con
, msg
, NULL
);
1117 dbus_message_unref(msg
);
1121 wpa_printf(MSG_ERROR
, "dbus: Failed to construct signal");
1122 dbus_message_unref(msg
);
1128 * Method to emit a signal for a peer disconnecting the group.
1129 * The signal will carry path to the group member object
1130 * constructed using p2p i/f addr used for connecting.
1132 * @wpa_s: %wpa_supplicant network interface data
1133 * @member_addr: addr (p2p i/f) of the peer joining the group
1135 void wpas_dbus_signal_p2p_peer_disconnected(struct wpa_supplicant
*wpa_s
,
1138 struct wpas_dbus_priv
*iface
;
1140 DBusMessageIter iter
;
1141 char groupmember_obj_path
[WPAS_DBUS_OBJECT_PATH_MAX
], *path
;
1143 iface
= wpa_s
->global
->dbus
;
1145 /* Do nothing if the control interface is not turned on */
1149 if (!wpa_s
->dbus_groupobj_path
)
1152 os_snprintf(groupmember_obj_path
, WPAS_DBUS_OBJECT_PATH_MAX
,
1153 "%s/" WPAS_DBUS_NEW_P2P_GROUPMEMBERS_PART
"/"
1155 wpa_s
->dbus_groupobj_path
, MAC2STR(member
));
1157 msg
= dbus_message_new_signal(wpa_s
->dbus_groupobj_path
,
1158 WPAS_DBUS_NEW_IFACE_P2P_GROUP
,
1159 "PeerDisconnected");
1163 dbus_message_iter_init_append(msg
, &iter
);
1164 path
= groupmember_obj_path
;
1165 if (!dbus_message_iter_append_basic(&iter
, DBUS_TYPE_OBJECT_PATH
,
1169 dbus_connection_send(iface
->con
, msg
, NULL
);
1171 dbus_message_unref(msg
);
1175 wpa_printf(MSG_ERROR
, "dbus: Failed to construct PeerDisconnected "
1177 dbus_message_unref(msg
);
1183 * Method to emit a signal for a service discovery request.
1184 * The signal will carry station address, frequency, dialog token,
1185 * update indicator and it tlvs
1187 * @wpa_s: %wpa_supplicant network interface data
1188 * @sa: station addr (p2p i/f) of the peer
1189 * @dialog_token: service discovery request dialog token
1190 * @update_indic: service discovery request update indicator
1191 * @tlvs: service discovery request genrated byte array of tlvs
1192 * @tlvs_len: service discovery request tlvs length
1194 void wpas_dbus_signal_p2p_sd_request(struct wpa_supplicant
*wpa_s
,
1195 int freq
, const u8
*sa
, u8 dialog_token
,
1196 u16 update_indic
, const u8
*tlvs
,
1200 DBusMessageIter iter
, dict_iter
;
1201 struct wpas_dbus_priv
*iface
;
1202 char peer_obj_path
[WPAS_DBUS_OBJECT_PATH_MAX
], *path
;
1203 iface
= wpa_s
->global
->dbus
;
1205 /* Do nothing if the control interface is not turned on */
1209 msg
= dbus_message_new_signal(wpa_s
->dbus_new_path
,
1210 WPAS_DBUS_NEW_IFACE_P2PDEVICE
,
1211 "ServiceDiscoveryRequest");
1215 /* Check if this is a known peer */
1216 if (p2p_get_peer_info(wpa_s
->global
->p2p
, sa
, 0, NULL
, 0) < 0)
1219 os_snprintf(peer_obj_path
, WPAS_DBUS_OBJECT_PATH_MAX
,
1220 "%s/" WPAS_DBUS_NEW_P2P_PEERS_PART
"/"
1221 COMPACT_MACSTR
, wpa_s
->dbus_new_path
, MAC2STR(sa
));
1223 path
= peer_obj_path
;
1225 dbus_message_iter_init_append(msg
, &iter
);
1226 if (!wpa_dbus_dict_open_write(&iter
, &dict_iter
))
1230 if (!wpa_dbus_dict_append_object_path(&dict_iter
, "peer_object",
1232 !wpa_dbus_dict_append_int32(&dict_iter
, "frequency", freq
) ||
1233 !wpa_dbus_dict_append_int32(&dict_iter
, "dialog_token",
1235 !wpa_dbus_dict_append_uint16(&dict_iter
, "update_indicator",
1237 !wpa_dbus_dict_append_byte_array(&dict_iter
, "tlvs",
1238 (const char *) tlvs
,
1240 !wpa_dbus_dict_close_write(&iter
, &dict_iter
))
1243 dbus_connection_send(iface
->con
, msg
, NULL
);
1244 dbus_message_unref(msg
);
1247 wpa_printf(MSG_ERROR
, "dbus: Failed to construct signal");
1248 dbus_message_unref(msg
);
1254 * Method to emit a signal for a service discovery response.
1255 * The signal will carry station address, update indicator and it
1258 * @wpa_s: %wpa_supplicant network interface data
1259 * @sa: station addr (p2p i/f) of the peer
1260 * @update_indic: service discovery request update indicator
1261 * @tlvs: service discovery request genrated byte array of tlvs
1262 * @tlvs_len: service discovery request tlvs length
1264 void wpas_dbus_signal_p2p_sd_response(struct wpa_supplicant
*wpa_s
,
1265 const u8
*sa
, u16 update_indic
,
1266 const u8
*tlvs
, size_t tlvs_len
)
1269 DBusMessageIter iter
, dict_iter
;
1270 struct wpas_dbus_priv
*iface
;
1271 char peer_obj_path
[WPAS_DBUS_OBJECT_PATH_MAX
], *path
;
1272 iface
= wpa_s
->global
->dbus
;
1274 /* Do nothing if the control interface is not turned on */
1278 msg
= dbus_message_new_signal(wpa_s
->dbus_new_path
,
1279 WPAS_DBUS_NEW_IFACE_P2PDEVICE
,
1280 "ServiceDiscoveryResponse");
1284 /* Check if this is a known peer */
1285 if (p2p_get_peer_info(wpa_s
->global
->p2p
, sa
, 0, NULL
, 0) < 0)
1288 os_snprintf(peer_obj_path
, WPAS_DBUS_OBJECT_PATH_MAX
,
1289 "%s/" WPAS_DBUS_NEW_P2P_PEERS_PART
"/"
1290 COMPACT_MACSTR
, wpa_s
->dbus_new_path
, MAC2STR(sa
));
1292 path
= peer_obj_path
;
1294 dbus_message_iter_init_append(msg
, &iter
);
1295 if (!wpa_dbus_dict_open_write(&iter
, &dict_iter
))
1298 if (!wpa_dbus_dict_append_object_path(&dict_iter
, "peer_object",
1300 !wpa_dbus_dict_append_uint16(&dict_iter
, "update_indicator",
1302 !wpa_dbus_dict_append_byte_array(&dict_iter
, "tlvs",
1303 (const char *) tlvs
,
1305 !wpa_dbus_dict_close_write(&iter
, &dict_iter
))
1309 dbus_connection_send(iface
->con
, msg
, NULL
);
1310 dbus_message_unref(msg
);
1313 wpa_printf(MSG_ERROR
, "dbus: Failed to construct signal");
1314 dbus_message_unref(msg
);
1318 * wpas_dbus_signal_persistent_group - Send a persistent group related
1320 * @wpa_s: %wpa_supplicant network interface data
1321 * @id: new persistent group id
1322 * @sig_name: signal name - PersistentGroupAdded, PersistentGroupRemoved
1323 * @properties: determines if add second argument with object properties
1325 * Notify listeners about an event related to persistent groups.
1327 static void wpas_dbus_signal_persistent_group(struct wpa_supplicant
*wpa_s
,
1328 int id
, const char *sig_name
,
1331 struct wpas_dbus_priv
*iface
;
1333 DBusMessageIter iter
;
1334 char pgrp_obj_path
[WPAS_DBUS_OBJECT_PATH_MAX
], *path
;
1336 iface
= wpa_s
->global
->dbus
;
1338 /* Do nothing if the control interface is not turned on */
1342 os_snprintf(pgrp_obj_path
, WPAS_DBUS_OBJECT_PATH_MAX
,
1343 "%s/" WPAS_DBUS_NEW_PERSISTENT_GROUPS_PART
"/%u",
1344 wpa_s
->dbus_new_path
, id
);
1346 msg
= dbus_message_new_signal(wpa_s
->dbus_new_path
,
1347 WPAS_DBUS_NEW_IFACE_P2PDEVICE
,
1352 dbus_message_iter_init_append(msg
, &iter
);
1353 path
= pgrp_obj_path
;
1354 if (!dbus_message_iter_append_basic(&iter
, DBUS_TYPE_OBJECT_PATH
,
1359 if (!wpa_dbus_get_object_properties(
1360 iface
, pgrp_obj_path
,
1361 WPAS_DBUS_NEW_IFACE_PERSISTENT_GROUP
, &iter
))
1365 dbus_connection_send(iface
->con
, msg
, NULL
);
1367 dbus_message_unref(msg
);
1371 wpa_printf(MSG_ERROR
, "dbus: Failed to construct signal");
1372 dbus_message_unref(msg
);
1377 * wpas_dbus_signal_persistent_group_added - Send a persistent_group
1379 * @wpa_s: %wpa_supplicant network interface data
1380 * @id: new persistent group id
1382 * Notify listeners about addition of a new persistent group.
1384 static void wpas_dbus_signal_persistent_group_added(
1385 struct wpa_supplicant
*wpa_s
, int id
)
1387 wpas_dbus_signal_persistent_group(wpa_s
, id
, "PersistentGroupAdded",
1393 * wpas_dbus_signal_persistent_group_removed - Send a persistent_group
1395 * @wpa_s: %wpa_supplicant network interface data
1396 * @id: persistent group id
1398 * Notify listeners about removal of a persistent group.
1400 static void wpas_dbus_signal_persistent_group_removed(
1401 struct wpa_supplicant
*wpa_s
, int id
)
1403 wpas_dbus_signal_persistent_group(wpa_s
, id
, "PersistentGroupRemoved",
1409 * wpas_dbus_signal_p2p_wps_failed - Signals WpsFailed event
1410 * @wpa_s: %wpa_supplicant network interface data
1412 * Sends Event dbus signal with name "fail" and dictionary containing
1413 * "msg" field with fail message number (int32) as arguments
1415 void wpas_dbus_signal_p2p_wps_failed(struct wpa_supplicant
*wpa_s
,
1416 struct wps_event_fail
*fail
)
1420 DBusMessageIter iter
, dict_iter
;
1421 struct wpas_dbus_priv
*iface
;
1424 iface
= wpa_s
->global
->dbus
;
1426 /* Do nothing if the control interface is not turned on */
1430 msg
= dbus_message_new_signal(wpa_s
->dbus_new_path
,
1431 WPAS_DBUS_NEW_IFACE_P2PDEVICE
,
1436 dbus_message_iter_init_append(msg
, &iter
);
1438 if (!dbus_message_iter_append_basic(&iter
, DBUS_TYPE_STRING
, &key
) ||
1439 !wpa_dbus_dict_open_write(&iter
, &dict_iter
) ||
1440 !wpa_dbus_dict_append_int32(&dict_iter
, "msg", fail
->msg
) ||
1441 !wpa_dbus_dict_append_int16(&dict_iter
, "config_error",
1442 fail
->config_error
) ||
1443 !wpa_dbus_dict_close_write(&iter
, &dict_iter
))
1444 wpa_printf(MSG_ERROR
, "dbus: Failed to construct signal");
1446 dbus_connection_send(iface
->con
, msg
, NULL
);
1448 dbus_message_unref(msg
);
1451 #endif /*CONFIG_P2P*/
1455 * wpas_dbus_signal_prop_changed - Signals change of property
1456 * @wpa_s: %wpa_supplicant network interface data
1457 * @property: indicates which property has changed
1459 * Sends PropertyChanged signals with path, interface and arguments
1460 * depending on which property has changed.
1462 void wpas_dbus_signal_prop_changed(struct wpa_supplicant
*wpa_s
,
1463 enum wpas_dbus_prop property
)
1465 WPADBusPropertyAccessor getter
;
1468 if (wpa_s
->dbus_new_path
== NULL
)
1469 return; /* Skip signal since D-Bus setup is not yet ready */
1472 case WPAS_DBUS_PROP_AP_SCAN
:
1473 getter
= wpas_dbus_getter_ap_scan
;
1476 case WPAS_DBUS_PROP_SCANNING
:
1477 getter
= wpas_dbus_getter_scanning
;
1480 case WPAS_DBUS_PROP_STATE
:
1481 getter
= wpas_dbus_getter_state
;
1484 case WPAS_DBUS_PROP_CURRENT_BSS
:
1485 getter
= wpas_dbus_getter_current_bss
;
1486 prop
= "CurrentBSS";
1488 case WPAS_DBUS_PROP_CURRENT_NETWORK
:
1489 getter
= wpas_dbus_getter_current_network
;
1490 prop
= "CurrentNetwork";
1492 case WPAS_DBUS_PROP_BSSS
:
1493 getter
= wpas_dbus_getter_bsss
;
1496 case WPAS_DBUS_PROP_CURRENT_AUTH_MODE
:
1497 getter
= wpas_dbus_getter_current_auth_mode
;
1498 prop
= "CurrentAuthMode";
1501 wpa_printf(MSG_ERROR
, "dbus: %s: Unknown Property value %d",
1502 __func__
, property
);
1506 wpa_dbus_mark_property_changed(wpa_s
->global
->dbus
,
1507 wpa_s
->dbus_new_path
,
1508 WPAS_DBUS_NEW_IFACE_INTERFACE
, prop
);
1513 * wpas_dbus_bss_signal_prop_changed - Signals change of BSS property
1514 * @wpa_s: %wpa_supplicant network interface data
1515 * @property: indicates which property has changed
1516 * @id: unique BSS identifier
1518 * Sends PropertyChanged signals with path, interface, and arguments depending
1519 * on which property has changed.
1521 void wpas_dbus_bss_signal_prop_changed(struct wpa_supplicant
*wpa_s
,
1522 enum wpas_dbus_bss_prop property
,
1525 char path
[WPAS_DBUS_OBJECT_PATH_MAX
];
1529 case WPAS_DBUS_BSS_PROP_SIGNAL
:
1532 case WPAS_DBUS_BSS_PROP_FREQ
:
1535 case WPAS_DBUS_BSS_PROP_MODE
:
1538 case WPAS_DBUS_BSS_PROP_PRIVACY
:
1541 case WPAS_DBUS_BSS_PROP_RATES
:
1544 case WPAS_DBUS_BSS_PROP_WPA
:
1547 case WPAS_DBUS_BSS_PROP_RSN
:
1550 case WPAS_DBUS_BSS_PROP_IES
:
1554 wpa_printf(MSG_ERROR
, "dbus: %s: Unknown Property value %d",
1555 __func__
, property
);
1559 os_snprintf(path
, WPAS_DBUS_OBJECT_PATH_MAX
,
1560 "%s/" WPAS_DBUS_NEW_BSSIDS_PART
"/%u",
1561 wpa_s
->dbus_new_path
, id
);
1563 wpa_dbus_mark_property_changed(wpa_s
->global
->dbus
, path
,
1564 WPAS_DBUS_NEW_IFACE_BSS
, prop
);
1569 * wpas_dbus_signal_debug_level_changed - Signals change of debug param
1570 * @global: wpa_global structure
1572 * Sends PropertyChanged signals informing that debug level has changed.
1574 void wpas_dbus_signal_debug_level_changed(struct wpa_global
*global
)
1576 wpa_dbus_mark_property_changed(global
->dbus
, WPAS_DBUS_NEW_PATH
,
1577 WPAS_DBUS_NEW_INTERFACE
,
1583 * wpas_dbus_signal_debug_timestamp_changed - Signals change of debug param
1584 * @global: wpa_global structure
1586 * Sends PropertyChanged signals informing that debug timestamp has changed.
1588 void wpas_dbus_signal_debug_timestamp_changed(struct wpa_global
*global
)
1590 wpa_dbus_mark_property_changed(global
->dbus
, WPAS_DBUS_NEW_PATH
,
1591 WPAS_DBUS_NEW_INTERFACE
,
1597 * wpas_dbus_signal_debug_show_keys_changed - Signals change of debug param
1598 * @global: wpa_global structure
1600 * Sends PropertyChanged signals informing that debug show_keys has changed.
1602 void wpas_dbus_signal_debug_show_keys_changed(struct wpa_global
*global
)
1604 wpa_dbus_mark_property_changed(global
->dbus
, WPAS_DBUS_NEW_PATH
,
1605 WPAS_DBUS_NEW_INTERFACE
,
1610 static void wpas_dbus_register(struct wpa_dbus_object_desc
*obj_desc
,
1612 WPADBusArgumentFreeFunction priv_free
,
1613 const struct wpa_dbus_method_desc
*methods
,
1614 const struct wpa_dbus_property_desc
*properties
,
1615 const struct wpa_dbus_signal_desc
*signals
)
1619 obj_desc
->user_data
= priv
;
1620 obj_desc
->user_data_free_func
= priv_free
;
1621 obj_desc
->methods
= methods
;
1622 obj_desc
->properties
= properties
;
1623 obj_desc
->signals
= signals
;
1625 for (n
= 0; properties
&& properties
->dbus_property
; properties
++)
1628 obj_desc
->prop_changed_flags
= os_zalloc(n
);
1629 if (!obj_desc
->prop_changed_flags
)
1630 wpa_printf(MSG_DEBUG
, "dbus: %s: can't register handlers",
1635 static const struct wpa_dbus_method_desc wpas_dbus_global_methods
[] = {
1636 { "CreateInterface", WPAS_DBUS_NEW_INTERFACE
,
1637 (WPADBusMethodHandler
) &wpas_dbus_handler_create_interface
,
1639 { "args", "a{sv}", ARG_IN
},
1640 { "path", "o", ARG_OUT
},
1644 { "RemoveInterface", WPAS_DBUS_NEW_INTERFACE
,
1645 (WPADBusMethodHandler
) &wpas_dbus_handler_remove_interface
,
1647 { "path", "o", ARG_IN
},
1651 { "GetInterface", WPAS_DBUS_NEW_INTERFACE
,
1652 (WPADBusMethodHandler
) &wpas_dbus_handler_get_interface
,
1654 { "ifname", "s", ARG_IN
},
1655 { "path", "o", ARG_OUT
},
1659 { NULL
, NULL
, NULL
, { END_ARGS
} }
1662 static const struct wpa_dbus_property_desc wpas_dbus_global_properties
[] = {
1663 { "DebugLevel", WPAS_DBUS_NEW_INTERFACE
, "s",
1664 wpas_dbus_getter_debug_level
,
1665 wpas_dbus_setter_debug_level
1667 { "DebugTimestamp", WPAS_DBUS_NEW_INTERFACE
, "b",
1668 wpas_dbus_getter_debug_timestamp
,
1669 wpas_dbus_setter_debug_timestamp
1671 { "DebugShowKeys", WPAS_DBUS_NEW_INTERFACE
, "b",
1672 wpas_dbus_getter_debug_show_keys
,
1673 wpas_dbus_setter_debug_show_keys
1675 { "Interfaces", WPAS_DBUS_NEW_INTERFACE
, "ao",
1676 wpas_dbus_getter_interfaces
,
1679 { "EapMethods", WPAS_DBUS_NEW_INTERFACE
, "as",
1680 wpas_dbus_getter_eap_methods
,
1683 { NULL
, NULL
, NULL
, NULL
, NULL
}
1686 static const struct wpa_dbus_signal_desc wpas_dbus_global_signals
[] = {
1687 { "InterfaceAdded", WPAS_DBUS_NEW_INTERFACE
,
1689 { "path", "o", ARG_OUT
},
1690 { "properties", "a{sv}", ARG_OUT
},
1694 { "InterfaceRemoved", WPAS_DBUS_NEW_INTERFACE
,
1696 { "path", "o", ARG_OUT
},
1700 { "PropertiesChanged", WPAS_DBUS_NEW_INTERFACE
,
1702 { "properties", "a{sv}", ARG_OUT
},
1706 { NULL
, NULL
, { END_ARGS
} }
1711 * wpas_dbus_ctrl_iface_init - Initialize dbus control interface
1712 * @global: Pointer to global data from wpa_supplicant_init()
1713 * Returns: 0 on success or -1 on failure
1715 * Initialize the dbus control interface for wpa_supplicantand and start
1716 * receiving commands from external programs over the bus.
1718 int wpas_dbus_ctrl_iface_init(struct wpas_dbus_priv
*priv
)
1720 struct wpa_dbus_object_desc
*obj_desc
;
1723 obj_desc
= os_zalloc(sizeof(struct wpa_dbus_object_desc
));
1725 wpa_printf(MSG_ERROR
, "Not enough memory "
1726 "to create object description");
1730 wpas_dbus_register(obj_desc
, priv
->global
, NULL
,
1731 wpas_dbus_global_methods
,
1732 wpas_dbus_global_properties
,
1733 wpas_dbus_global_signals
);
1735 wpa_printf(MSG_DEBUG
, "dbus: Register D-Bus object '%s'",
1736 WPAS_DBUS_NEW_PATH
);
1737 ret
= wpa_dbus_ctrl_iface_init(priv
, WPAS_DBUS_NEW_PATH
,
1738 WPAS_DBUS_NEW_SERVICE
,
1741 free_dbus_object_desc(obj_desc
);
1743 priv
->dbus_new_initialized
= 1;
1750 * wpas_dbus_ctrl_iface_deinit - Deinitialize dbus ctrl interface for
1752 * @iface: Pointer to dbus private data from wpas_dbus_init()
1754 * Deinitialize the dbus control interface that was initialized with
1755 * wpas_dbus_ctrl_iface_init().
1757 void wpas_dbus_ctrl_iface_deinit(struct wpas_dbus_priv
*iface
)
1759 if (!iface
->dbus_new_initialized
)
1761 wpa_printf(MSG_DEBUG
, "dbus: Unregister D-Bus object '%s'",
1762 WPAS_DBUS_NEW_PATH
);
1763 dbus_connection_unregister_object_path(iface
->con
,
1764 WPAS_DBUS_NEW_PATH
);
1768 static void wpa_dbus_free(void *ptr
)
1774 static const struct wpa_dbus_property_desc wpas_dbus_network_properties
[] = {
1775 { "Properties", WPAS_DBUS_NEW_IFACE_NETWORK
, "a{sv}",
1776 wpas_dbus_getter_network_properties
,
1777 wpas_dbus_setter_network_properties
1779 { "Enabled", WPAS_DBUS_NEW_IFACE_NETWORK
, "b",
1780 wpas_dbus_getter_enabled
,
1781 wpas_dbus_setter_enabled
1783 { NULL
, NULL
, NULL
, NULL
, NULL
}
1787 static const struct wpa_dbus_signal_desc wpas_dbus_network_signals
[] = {
1788 { "PropertiesChanged", WPAS_DBUS_NEW_IFACE_NETWORK
,
1790 { "properties", "a{sv}", ARG_OUT
},
1794 { NULL
, NULL
, { END_ARGS
} }
1799 * wpas_dbus_register_network - Register a configured network with dbus
1800 * @wpa_s: wpa_supplicant interface structure
1801 * @ssid: network configuration data
1802 * Returns: 0 on success, -1 on failure
1804 * Registers network representing object with dbus
1806 int wpas_dbus_register_network(struct wpa_supplicant
*wpa_s
,
1807 struct wpa_ssid
*ssid
)
1809 struct wpas_dbus_priv
*ctrl_iface
;
1810 struct wpa_dbus_object_desc
*obj_desc
;
1811 struct network_handler_args
*arg
;
1812 char net_obj_path
[WPAS_DBUS_OBJECT_PATH_MAX
];
1816 * If it is a persistent group register it as such.
1817 * This is to handle cases where an interface is being initialized
1818 * with a list of networks read from config.
1820 if (network_is_persistent_group(ssid
))
1821 return wpas_dbus_register_persistent_group(wpa_s
, ssid
);
1822 #endif /* CONFIG_P2P */
1824 /* Do nothing if the control interface is not turned on */
1825 if (wpa_s
== NULL
|| wpa_s
->global
== NULL
)
1827 ctrl_iface
= wpa_s
->global
->dbus
;
1828 if (ctrl_iface
== NULL
)
1831 os_snprintf(net_obj_path
, WPAS_DBUS_OBJECT_PATH_MAX
,
1832 "%s/" WPAS_DBUS_NEW_NETWORKS_PART
"/%u",
1833 wpa_s
->dbus_new_path
, ssid
->id
);
1835 wpa_printf(MSG_DEBUG
, "dbus: Register network object '%s'",
1837 obj_desc
= os_zalloc(sizeof(struct wpa_dbus_object_desc
));
1839 wpa_printf(MSG_ERROR
, "Not enough memory "
1840 "to create object description");
1844 /* allocate memory for handlers arguments */
1845 arg
= os_zalloc(sizeof(struct network_handler_args
));
1847 wpa_printf(MSG_ERROR
, "Not enough memory "
1848 "to create arguments for method");
1855 wpas_dbus_register(obj_desc
, arg
, wpa_dbus_free
, NULL
,
1856 wpas_dbus_network_properties
,
1857 wpas_dbus_network_signals
);
1859 if (wpa_dbus_register_object_per_iface(ctrl_iface
, net_obj_path
,
1860 wpa_s
->ifname
, obj_desc
))
1863 wpas_dbus_signal_network_added(wpa_s
, ssid
->id
);
1868 free_dbus_object_desc(obj_desc
);
1874 * wpas_dbus_unregister_network - Unregister a configured network from dbus
1875 * @wpa_s: wpa_supplicant interface structure
1877 * Returns: 0 on success, -1 on failure
1879 * Unregisters network representing object from dbus
1881 int wpas_dbus_unregister_network(struct wpa_supplicant
*wpa_s
, int nid
)
1883 struct wpas_dbus_priv
*ctrl_iface
;
1884 char net_obj_path
[WPAS_DBUS_OBJECT_PATH_MAX
];
1886 struct wpa_ssid
*ssid
;
1888 ssid
= wpa_config_get_network(wpa_s
->conf
, nid
);
1891 /* If it is a persistent group unregister it as such */
1892 if (ssid
&& network_is_persistent_group(ssid
))
1893 return wpas_dbus_unregister_persistent_group(wpa_s
, nid
);
1894 #endif /* CONFIG_P2P */
1896 /* Do nothing if the control interface is not turned on */
1897 if (wpa_s
== NULL
|| wpa_s
->global
== NULL
||
1898 wpa_s
->dbus_new_path
== NULL
)
1900 ctrl_iface
= wpa_s
->global
->dbus
;
1901 if (ctrl_iface
== NULL
)
1904 os_snprintf(net_obj_path
, WPAS_DBUS_OBJECT_PATH_MAX
,
1905 "%s/" WPAS_DBUS_NEW_NETWORKS_PART
"/%u",
1906 wpa_s
->dbus_new_path
, nid
);
1908 wpa_printf(MSG_DEBUG
, "dbus: Unregister network object '%s'",
1910 ret
= wpa_dbus_unregister_object_per_iface(ctrl_iface
, net_obj_path
);
1913 wpas_dbus_signal_network_removed(wpa_s
, nid
);
1919 static const struct wpa_dbus_property_desc wpas_dbus_bss_properties
[] = {
1920 { "SSID", WPAS_DBUS_NEW_IFACE_BSS
, "ay",
1921 wpas_dbus_getter_bss_ssid
,
1924 { "BSSID", WPAS_DBUS_NEW_IFACE_BSS
, "ay",
1925 wpas_dbus_getter_bss_bssid
,
1928 { "Privacy", WPAS_DBUS_NEW_IFACE_BSS
, "b",
1929 wpas_dbus_getter_bss_privacy
,
1932 { "Mode", WPAS_DBUS_NEW_IFACE_BSS
, "s",
1933 wpas_dbus_getter_bss_mode
,
1936 { "Signal", WPAS_DBUS_NEW_IFACE_BSS
, "n",
1937 wpas_dbus_getter_bss_signal
,
1940 { "Frequency", WPAS_DBUS_NEW_IFACE_BSS
, "q",
1941 wpas_dbus_getter_bss_frequency
,
1944 { "Rates", WPAS_DBUS_NEW_IFACE_BSS
, "au",
1945 wpas_dbus_getter_bss_rates
,
1948 { "WPA", WPAS_DBUS_NEW_IFACE_BSS
, "a{sv}",
1949 wpas_dbus_getter_bss_wpa
,
1952 { "RSN", WPAS_DBUS_NEW_IFACE_BSS
, "a{sv}",
1953 wpas_dbus_getter_bss_rsn
,
1956 { "IEs", WPAS_DBUS_NEW_IFACE_BSS
, "ay",
1957 wpas_dbus_getter_bss_ies
,
1960 { NULL
, NULL
, NULL
, NULL
, NULL
}
1964 static const struct wpa_dbus_signal_desc wpas_dbus_bss_signals
[] = {
1965 { "PropertiesChanged", WPAS_DBUS_NEW_IFACE_BSS
,
1967 { "properties", "a{sv}", ARG_OUT
},
1971 { NULL
, NULL
, { END_ARGS
} }
1976 * wpas_dbus_unregister_bss - Unregister a scanned BSS from dbus
1977 * @wpa_s: wpa_supplicant interface structure
1978 * @bssid: scanned network bssid
1979 * @id: unique BSS identifier
1980 * Returns: 0 on success, -1 on failure
1982 * Unregisters BSS representing object from dbus
1984 int wpas_dbus_unregister_bss(struct wpa_supplicant
*wpa_s
,
1985 u8 bssid
[ETH_ALEN
], unsigned int id
)
1987 struct wpas_dbus_priv
*ctrl_iface
;
1988 char bss_obj_path
[WPAS_DBUS_OBJECT_PATH_MAX
];
1990 /* Do nothing if the control interface is not turned on */
1991 if (wpa_s
== NULL
|| wpa_s
->global
== NULL
)
1993 ctrl_iface
= wpa_s
->global
->dbus
;
1994 if (ctrl_iface
== NULL
)
1997 os_snprintf(bss_obj_path
, WPAS_DBUS_OBJECT_PATH_MAX
,
1998 "%s/" WPAS_DBUS_NEW_BSSIDS_PART
"/%u",
1999 wpa_s
->dbus_new_path
, id
);
2001 wpa_printf(MSG_DEBUG
, "dbus: Unregister BSS object '%s'",
2003 if (wpa_dbus_unregister_object_per_iface(ctrl_iface
, bss_obj_path
)) {
2004 wpa_printf(MSG_ERROR
, "dbus: Cannot unregister BSS object %s",
2009 wpas_dbus_signal_bss_removed(wpa_s
, bss_obj_path
);
2010 wpas_dbus_signal_prop_changed(wpa_s
, WPAS_DBUS_PROP_BSSS
);
2017 * wpas_dbus_register_bss - Register a scanned BSS with dbus
2018 * @wpa_s: wpa_supplicant interface structure
2019 * @bssid: scanned network bssid
2020 * @id: unique BSS identifier
2021 * Returns: 0 on success, -1 on failure
2023 * Registers BSS representing object with dbus
2025 int wpas_dbus_register_bss(struct wpa_supplicant
*wpa_s
,
2026 u8 bssid
[ETH_ALEN
], unsigned int id
)
2028 struct wpas_dbus_priv
*ctrl_iface
;
2029 struct wpa_dbus_object_desc
*obj_desc
;
2030 char bss_obj_path
[WPAS_DBUS_OBJECT_PATH_MAX
];
2031 struct bss_handler_args
*arg
;
2033 /* Do nothing if the control interface is not turned on */
2034 if (wpa_s
== NULL
|| wpa_s
->global
== NULL
)
2036 ctrl_iface
= wpa_s
->global
->dbus
;
2037 if (ctrl_iface
== NULL
)
2040 os_snprintf(bss_obj_path
, WPAS_DBUS_OBJECT_PATH_MAX
,
2041 "%s/" WPAS_DBUS_NEW_BSSIDS_PART
"/%u",
2042 wpa_s
->dbus_new_path
, id
);
2044 obj_desc
= os_zalloc(sizeof(struct wpa_dbus_object_desc
));
2046 wpa_printf(MSG_ERROR
, "Not enough memory "
2047 "to create object description");
2051 arg
= os_zalloc(sizeof(struct bss_handler_args
));
2053 wpa_printf(MSG_ERROR
, "Not enough memory "
2054 "to create arguments for handler");
2060 wpas_dbus_register(obj_desc
, arg
, wpa_dbus_free
, NULL
,
2061 wpas_dbus_bss_properties
,
2062 wpas_dbus_bss_signals
);
2064 wpa_printf(MSG_DEBUG
, "dbus: Register BSS object '%s'",
2066 if (wpa_dbus_register_object_per_iface(ctrl_iface
, bss_obj_path
,
2067 wpa_s
->ifname
, obj_desc
)) {
2068 wpa_printf(MSG_ERROR
,
2069 "Cannot register BSSID dbus object %s.",
2074 wpas_dbus_signal_bss_added(wpa_s
, bss_obj_path
);
2075 wpas_dbus_signal_prop_changed(wpa_s
, WPAS_DBUS_PROP_BSSS
);
2080 free_dbus_object_desc(obj_desc
);
2085 static const struct wpa_dbus_method_desc wpas_dbus_interface_methods
[] = {
2086 { "Scan", WPAS_DBUS_NEW_IFACE_INTERFACE
,
2087 (WPADBusMethodHandler
) &wpas_dbus_handler_scan
,
2089 { "args", "a{sv}", ARG_IN
},
2093 { "Disconnect", WPAS_DBUS_NEW_IFACE_INTERFACE
,
2094 (WPADBusMethodHandler
) &wpas_dbus_handler_disconnect
,
2099 { "AddNetwork", WPAS_DBUS_NEW_IFACE_INTERFACE
,
2100 (WPADBusMethodHandler
) &wpas_dbus_handler_add_network
,
2102 { "args", "a{sv}", ARG_IN
},
2103 { "path", "o", ARG_OUT
},
2107 { "RemoveNetwork", WPAS_DBUS_NEW_IFACE_INTERFACE
,
2108 (WPADBusMethodHandler
) &wpas_dbus_handler_remove_network
,
2110 { "path", "o", ARG_IN
},
2114 { "RemoveAllNetworks", WPAS_DBUS_NEW_IFACE_INTERFACE
,
2115 (WPADBusMethodHandler
) &wpas_dbus_handler_remove_all_networks
,
2120 { "SelectNetwork", WPAS_DBUS_NEW_IFACE_INTERFACE
,
2121 (WPADBusMethodHandler
) &wpas_dbus_handler_select_network
,
2123 { "path", "o", ARG_IN
},
2127 { "AddBlob", WPAS_DBUS_NEW_IFACE_INTERFACE
,
2128 (WPADBusMethodHandler
) &wpas_dbus_handler_add_blob
,
2130 { "name", "s", ARG_IN
},
2131 { "data", "ay", ARG_IN
},
2135 { "GetBlob", WPAS_DBUS_NEW_IFACE_INTERFACE
,
2136 (WPADBusMethodHandler
) &wpas_dbus_handler_get_blob
,
2138 { "name", "s", ARG_IN
},
2139 { "data", "ay", ARG_OUT
},
2143 { "RemoveBlob", WPAS_DBUS_NEW_IFACE_INTERFACE
,
2144 (WPADBusMethodHandler
) &wpas_dbus_handler_remove_blob
,
2146 { "name", "s", ARG_IN
},
2151 { "Start", WPAS_DBUS_NEW_IFACE_WPS
,
2152 (WPADBusMethodHandler
) &wpas_dbus_handler_wps_start
,
2154 { "args", "a{sv}", ARG_IN
},
2155 { "output", "a{sv}", ARG_OUT
},
2159 #endif /* CONFIG_WPS */
2161 { "Find", WPAS_DBUS_NEW_IFACE_P2PDEVICE
,
2162 (WPADBusMethodHandler
)wpas_dbus_handler_p2p_find
,
2164 { "args", "a{sv}", ARG_IN
},
2168 { "StopFind", WPAS_DBUS_NEW_IFACE_P2PDEVICE
,
2169 (WPADBusMethodHandler
)wpas_dbus_handler_p2p_stop_find
,
2174 { "Listen", WPAS_DBUS_NEW_IFACE_P2PDEVICE
,
2175 (WPADBusMethodHandler
)wpas_dbus_handler_p2p_listen
,
2177 { "timeout", "i", ARG_IN
},
2181 { "ExtendedListen", WPAS_DBUS_NEW_IFACE_P2PDEVICE
,
2182 (WPADBusMethodHandler
)wpas_dbus_handler_p2p_extendedlisten
,
2184 { "args", "a{sv}", ARG_IN
},
2188 { "PresenceRequest", WPAS_DBUS_NEW_IFACE_P2PDEVICE
,
2189 (WPADBusMethodHandler
)wpas_dbus_handler_p2p_presence_request
,
2191 { "args", "a{sv}", ARG_IN
},
2195 { "ProvisionDiscoveryRequest", WPAS_DBUS_NEW_IFACE_P2PDEVICE
,
2196 (WPADBusMethodHandler
)wpas_dbus_handler_p2p_prov_disc_req
,
2198 { "peer", "o", ARG_IN
},
2199 { "config_method", "s", ARG_IN
},
2203 { "Connect", WPAS_DBUS_NEW_IFACE_P2PDEVICE
,
2204 (WPADBusMethodHandler
)wpas_dbus_handler_p2p_connect
,
2206 { "args", "a{sv}", ARG_IN
},
2207 { "generated_pin", "s", ARG_OUT
},
2211 { "GroupAdd", WPAS_DBUS_NEW_IFACE_P2PDEVICE
,
2212 (WPADBusMethodHandler
)wpas_dbus_handler_p2p_group_add
,
2214 { "args", "a{sv}", ARG_IN
},
2218 { "Invite", WPAS_DBUS_NEW_IFACE_P2PDEVICE
,
2219 (WPADBusMethodHandler
)wpas_dbus_handler_p2p_invite
,
2221 { "args", "a{sv}", ARG_IN
},
2225 { "Disconnect", WPAS_DBUS_NEW_IFACE_P2PDEVICE
,
2226 (WPADBusMethodHandler
)wpas_dbus_handler_p2p_disconnect
,
2231 { "RejectPeer", WPAS_DBUS_NEW_IFACE_P2PDEVICE
,
2232 (WPADBusMethodHandler
)wpas_dbus_handler_p2p_rejectpeer
,
2234 { "peer", "o", ARG_IN
},
2238 { "Flush", WPAS_DBUS_NEW_IFACE_P2PDEVICE
,
2239 (WPADBusMethodHandler
)wpas_dbus_handler_p2p_flush
,
2244 { "AddService", WPAS_DBUS_NEW_IFACE_P2PDEVICE
,
2245 (WPADBusMethodHandler
)wpas_dbus_handler_p2p_add_service
,
2247 { "args", "a{sv}", ARG_IN
},
2251 { "DeleteService", WPAS_DBUS_NEW_IFACE_P2PDEVICE
,
2252 (WPADBusMethodHandler
)wpas_dbus_handler_p2p_delete_service
,
2254 { "args", "a{sv}", ARG_IN
},
2258 { "FlushService", WPAS_DBUS_NEW_IFACE_P2PDEVICE
,
2259 (WPADBusMethodHandler
)wpas_dbus_handler_p2p_flush_service
,
2264 { "ServiceDiscoveryRequest", WPAS_DBUS_NEW_IFACE_P2PDEVICE
,
2265 (WPADBusMethodHandler
)wpas_dbus_handler_p2p_service_sd_req
,
2267 { "args", "a{sv}", ARG_IN
},
2271 { "ServiceDiscoveryResponse", WPAS_DBUS_NEW_IFACE_P2PDEVICE
,
2272 (WPADBusMethodHandler
)wpas_dbus_handler_p2p_service_sd_res
,
2274 { "args", "a{sv}", ARG_IN
},
2278 { "ServiceDiscoveryCancelRequest", WPAS_DBUS_NEW_IFACE_P2PDEVICE
,
2279 (WPADBusMethodHandler
)wpas_dbus_handler_p2p_service_sd_cancel_req
,
2281 { "args", "t", ARG_IN
},
2285 { "ServiceUpdate", WPAS_DBUS_NEW_IFACE_P2PDEVICE
,
2286 (WPADBusMethodHandler
)wpas_dbus_handler_p2p_service_update
,
2291 { "ServiceDiscoveryExternal", WPAS_DBUS_NEW_IFACE_P2PDEVICE
,
2292 (WPADBusMethodHandler
)wpas_dbus_handler_p2p_serv_disc_external
,
2294 { "arg", "i", ARG_IN
},
2298 { "ServiceDiscoveryExternal", WPAS_DBUS_NEW_IFACE_P2PDEVICE
,
2299 (WPADBusMethodHandler
)wpas_dbus_handler_p2p_serv_disc_external
,
2301 { "arg", "i", ARG_IN
},
2305 { "AddPersistentGroup", WPAS_DBUS_NEW_IFACE_P2PDEVICE
,
2306 (WPADBusMethodHandler
) wpas_dbus_handler_add_persistent_group
,
2308 { "args", "a{sv}", ARG_IN
},
2309 { "path", "o", ARG_OUT
},
2313 { "RemovePersistentGroup", WPAS_DBUS_NEW_IFACE_P2PDEVICE
,
2314 (WPADBusMethodHandler
) wpas_dbus_handler_remove_persistent_group
,
2316 { "path", "o", ARG_IN
},
2320 { "RemoveAllPersistentGroups", WPAS_DBUS_NEW_IFACE_P2PDEVICE
,
2321 (WPADBusMethodHandler
)
2322 wpas_dbus_handler_remove_all_persistent_groups
,
2327 #endif /* CONFIG_P2P */
2328 { "FlushBSS", WPAS_DBUS_NEW_IFACE_INTERFACE
,
2329 (WPADBusMethodHandler
) &wpas_dbus_handler_flush_bss
,
2331 { "age", "u", ARG_IN
},
2335 { NULL
, NULL
, NULL
, { END_ARGS
} }
2338 static const struct wpa_dbus_property_desc wpas_dbus_interface_properties
[] = {
2339 { "Capabilities", WPAS_DBUS_NEW_IFACE_INTERFACE
, "a{sv}",
2340 wpas_dbus_getter_capabilities
,
2343 { "State", WPAS_DBUS_NEW_IFACE_INTERFACE
, "s",
2344 wpas_dbus_getter_state
,
2347 { "Scanning", WPAS_DBUS_NEW_IFACE_INTERFACE
, "b",
2348 wpas_dbus_getter_scanning
,
2351 { "ApScan", WPAS_DBUS_NEW_IFACE_INTERFACE
, "u",
2352 wpas_dbus_getter_ap_scan
,
2353 wpas_dbus_setter_ap_scan
2355 { "BSSExpireAge", WPAS_DBUS_NEW_IFACE_INTERFACE
, "u",
2356 wpas_dbus_getter_bss_expire_age
,
2357 wpas_dbus_setter_bss_expire_age
2359 { "BSSExpireCount", WPAS_DBUS_NEW_IFACE_INTERFACE
, "u",
2360 wpas_dbus_getter_bss_expire_count
,
2361 wpas_dbus_setter_bss_expire_count
2363 { "Country", WPAS_DBUS_NEW_IFACE_INTERFACE
, "s",
2364 wpas_dbus_getter_country
,
2365 wpas_dbus_setter_country
2367 { "Ifname", WPAS_DBUS_NEW_IFACE_INTERFACE
, "s",
2368 wpas_dbus_getter_ifname
,
2371 { "Driver", WPAS_DBUS_NEW_IFACE_INTERFACE
, "s",
2372 wpas_dbus_getter_driver
,
2375 { "BridgeIfname", WPAS_DBUS_NEW_IFACE_INTERFACE
, "s",
2376 wpas_dbus_getter_bridge_ifname
,
2379 { "CurrentBSS", WPAS_DBUS_NEW_IFACE_INTERFACE
, "o",
2380 wpas_dbus_getter_current_bss
,
2383 { "CurrentNetwork", WPAS_DBUS_NEW_IFACE_INTERFACE
, "o",
2384 wpas_dbus_getter_current_network
,
2387 { "CurrentAuthMode", WPAS_DBUS_NEW_IFACE_INTERFACE
, "s",
2388 wpas_dbus_getter_current_auth_mode
,
2391 { "Blobs", WPAS_DBUS_NEW_IFACE_INTERFACE
, "a{say}",
2392 wpas_dbus_getter_blobs
,
2395 { "BSSs", WPAS_DBUS_NEW_IFACE_INTERFACE
, "ao",
2396 wpas_dbus_getter_bsss
,
2399 { "Networks", WPAS_DBUS_NEW_IFACE_INTERFACE
, "ao",
2400 wpas_dbus_getter_networks
,
2404 { "ProcessCredentials", WPAS_DBUS_NEW_IFACE_WPS
, "b",
2405 wpas_dbus_getter_process_credentials
,
2406 wpas_dbus_setter_process_credentials
2408 #endif /* CONFIG_WPS */
2410 { "P2PDeviceProperties", WPAS_DBUS_NEW_IFACE_P2PDEVICE
, "a{sv}",
2411 wpas_dbus_getter_p2p_device_properties
,
2412 wpas_dbus_setter_p2p_device_properties
2414 { "Peers", WPAS_DBUS_NEW_IFACE_P2PDEVICE
, "ao",
2415 wpas_dbus_getter_p2p_peers
,
2418 { "Role", WPAS_DBUS_NEW_IFACE_P2PDEVICE
, "s",
2419 wpas_dbus_getter_p2p_role
,
2422 { "Group", WPAS_DBUS_NEW_IFACE_P2PDEVICE
, "o",
2423 wpas_dbus_getter_p2p_group
,
2426 { "PeerGO", WPAS_DBUS_NEW_IFACE_P2PDEVICE
, "o",
2427 wpas_dbus_getter_p2p_peergo
,
2430 { "PersistentGroups", WPAS_DBUS_NEW_IFACE_P2PDEVICE
, "ao",
2431 wpas_dbus_getter_persistent_groups
,
2434 #endif /* CONFIG_P2P */
2435 { NULL
, NULL
, NULL
, NULL
, NULL
}
2438 static const struct wpa_dbus_signal_desc wpas_dbus_interface_signals
[] = {
2439 { "ScanDone", WPAS_DBUS_NEW_IFACE_INTERFACE
,
2441 { "success", "b", ARG_OUT
},
2445 { "BSSAdded", WPAS_DBUS_NEW_IFACE_INTERFACE
,
2447 { "path", "o", ARG_OUT
},
2448 { "properties", "a{sv}", ARG_OUT
},
2452 { "BSSRemoved", WPAS_DBUS_NEW_IFACE_INTERFACE
,
2454 { "path", "o", ARG_OUT
},
2458 { "BlobAdded", WPAS_DBUS_NEW_IFACE_INTERFACE
,
2460 { "name", "s", ARG_OUT
},
2464 { "BlobRemoved", WPAS_DBUS_NEW_IFACE_INTERFACE
,
2466 { "name", "s", ARG_OUT
},
2470 { "NetworkAdded", WPAS_DBUS_NEW_IFACE_INTERFACE
,
2472 { "path", "o", ARG_OUT
},
2473 { "properties", "a{sv}", ARG_OUT
},
2477 { "NetworkRemoved", WPAS_DBUS_NEW_IFACE_INTERFACE
,
2479 { "path", "o", ARG_OUT
},
2483 { "NetworkSelected", WPAS_DBUS_NEW_IFACE_INTERFACE
,
2485 { "path", "o", ARG_OUT
},
2489 { "PropertiesChanged", WPAS_DBUS_NEW_IFACE_INTERFACE
,
2491 { "properties", "a{sv}", ARG_OUT
},
2496 { "Event", WPAS_DBUS_NEW_IFACE_WPS
,
2498 { "name", "s", ARG_OUT
},
2499 { "args", "a{sv}", ARG_OUT
},
2503 { "Credentials", WPAS_DBUS_NEW_IFACE_WPS
,
2505 { "credentials", "a{sv}", ARG_OUT
},
2509 { "PropertiesChanged", WPAS_DBUS_NEW_IFACE_WPS
,
2511 { "properties", "a{sv}", ARG_OUT
},
2515 #endif /* CONFIG_WPS */
2517 { "P2PStateChanged", WPAS_DBUS_NEW_IFACE_P2PDEVICE
,
2519 { "states", "a{ss}", ARG_OUT
},
2523 { "DeviceFound", WPAS_DBUS_NEW_IFACE_P2PDEVICE
,
2525 { "path", "o", ARG_OUT
},
2526 { "properties", "a{sv}", ARG_OUT
},
2530 { "DeviceLost", WPAS_DBUS_NEW_IFACE_P2PDEVICE
,
2532 { "path", "o", ARG_OUT
},
2536 { "ProvisionDiscoveryRequestDisplayPin", WPAS_DBUS_NEW_IFACE_P2PDEVICE
,
2538 { "peer_object", "o", ARG_OUT
},
2539 { "pin", "s", ARG_OUT
},
2543 { "ProvisionDiscoveryResponseDisplayPin", WPAS_DBUS_NEW_IFACE_P2PDEVICE
,
2545 { "peer_object", "o", ARG_OUT
},
2546 { "pin", "s", ARG_OUT
},
2550 { "ProvisionDiscoveryRequestEnterPin", WPAS_DBUS_NEW_IFACE_P2PDEVICE
,
2552 { "peer_object", "o", ARG_OUT
},
2556 { "ProvisionDiscoveryResponseEnterPin", WPAS_DBUS_NEW_IFACE_P2PDEVICE
,
2558 { "peer_object", "o", ARG_OUT
},
2562 { "ProvisionDiscoveryPBCRequest", WPAS_DBUS_NEW_IFACE_P2PDEVICE
,
2564 { "peer_object", "o", ARG_OUT
},
2568 { "ProvisionDiscoveryPBCResponse", WPAS_DBUS_NEW_IFACE_P2PDEVICE
,
2570 { "peer_object", "o", ARG_OUT
},
2574 { "ProvisionDiscoveryFailure", WPAS_DBUS_NEW_IFACE_P2PDEVICE
,
2576 { "peer_object", "o", ARG_OUT
},
2577 { "status", "i", ARG_OUT
},
2581 { "GroupStarted", WPAS_DBUS_NEW_IFACE_P2PDEVICE
,
2583 { "properties", "a{sv}", ARG_OUT
},
2587 { "GONegotiationSuccess", WPAS_DBUS_NEW_IFACE_P2PDEVICE
,
2592 { "GONegotiationFailure", WPAS_DBUS_NEW_IFACE_P2PDEVICE
,
2594 { "status", "i", ARG_OUT
},
2598 { "GONegotiationRequest", WPAS_DBUS_NEW_IFACE_P2PDEVICE
,
2600 { "path", "o", ARG_OUT
},
2601 { "dev_passwd_id", "i", ARG_OUT
},
2605 { "InvitationResult", WPAS_DBUS_NEW_IFACE_P2PDEVICE
,
2607 { "invite_result", "a{sv}", ARG_OUT
},
2611 { "GroupFinished", WPAS_DBUS_NEW_IFACE_P2PDEVICE
,
2613 { "ifname", "s", ARG_OUT
},
2614 { "role", "s", ARG_OUT
},
2618 { "ServiceDiscoveryRequest", WPAS_DBUS_NEW_IFACE_P2PDEVICE
,
2620 { "sd_request", "a{sv}", ARG_OUT
},
2624 { "ServiceDiscoveryResponse", WPAS_DBUS_NEW_IFACE_P2PDEVICE
,
2626 { "sd_response", "a{sv}", ARG_OUT
},
2630 { "PersistentGroupAdded", WPAS_DBUS_NEW_IFACE_P2PDEVICE
,
2632 { "path", "o", ARG_OUT
},
2633 { "properties", "a{sv}", ARG_OUT
},
2637 { "PersistentGroupRemoved", WPAS_DBUS_NEW_IFACE_P2PDEVICE
,
2639 { "path", "o", ARG_OUT
},
2643 { "WpsFailed", WPAS_DBUS_NEW_IFACE_P2PDEVICE
,
2645 { "name", "s", ARG_OUT
},
2646 { "args", "a{sv}", ARG_OUT
},
2650 #endif /* CONFIG_P2P */
2651 { "Certification", WPAS_DBUS_NEW_IFACE_INTERFACE
,
2653 { "certification", "a{sv}", ARG_OUT
},
2657 { NULL
, NULL
, { END_ARGS
} }
2661 int wpas_dbus_register_interface(struct wpa_supplicant
*wpa_s
)
2664 struct wpa_dbus_object_desc
*obj_desc
= NULL
;
2665 struct wpas_dbus_priv
*ctrl_iface
= wpa_s
->global
->dbus
;
2668 /* Do nothing if the control interface is not turned on */
2669 if (ctrl_iface
== NULL
)
2672 /* Create and set the interface's object path */
2673 wpa_s
->dbus_new_path
= os_zalloc(WPAS_DBUS_OBJECT_PATH_MAX
);
2674 if (wpa_s
->dbus_new_path
== NULL
)
2676 next
= ctrl_iface
->next_objid
++;
2677 os_snprintf(wpa_s
->dbus_new_path
, WPAS_DBUS_OBJECT_PATH_MAX
,
2678 WPAS_DBUS_NEW_PATH_INTERFACES
"/%u",
2681 obj_desc
= os_zalloc(sizeof(struct wpa_dbus_object_desc
));
2683 wpa_printf(MSG_ERROR
, "Not enough memory "
2684 "to create object description");
2688 wpas_dbus_register(obj_desc
, wpa_s
, NULL
, wpas_dbus_interface_methods
,
2689 wpas_dbus_interface_properties
,
2690 wpas_dbus_interface_signals
);
2692 wpa_printf(MSG_DEBUG
, "dbus: Register interface object '%s'",
2693 wpa_s
->dbus_new_path
);
2694 if (wpa_dbus_register_object_per_iface(ctrl_iface
,
2695 wpa_s
->dbus_new_path
,
2696 wpa_s
->ifname
, obj_desc
))
2699 wpas_dbus_signal_interface_added(wpa_s
);
2704 os_free(wpa_s
->dbus_new_path
);
2705 wpa_s
->dbus_new_path
= NULL
;
2706 free_dbus_object_desc(obj_desc
);
2711 int wpas_dbus_unregister_interface(struct wpa_supplicant
*wpa_s
)
2713 struct wpas_dbus_priv
*ctrl_iface
;
2715 /* Do nothing if the control interface is not turned on */
2716 if (wpa_s
== NULL
|| wpa_s
->global
== NULL
)
2718 ctrl_iface
= wpa_s
->global
->dbus
;
2719 if (ctrl_iface
== NULL
)
2722 wpa_printf(MSG_DEBUG
, "dbus: Unregister interface object '%s'",
2723 wpa_s
->dbus_new_path
);
2724 if (wpa_dbus_unregister_object_per_iface(ctrl_iface
,
2725 wpa_s
->dbus_new_path
))
2728 wpas_dbus_signal_interface_removed(wpa_s
);
2730 os_free(wpa_s
->dbus_new_path
);
2731 wpa_s
->dbus_new_path
= NULL
;
2738 static const struct wpa_dbus_property_desc wpas_dbus_p2p_peer_properties
[] = {
2739 { "Properties", WPAS_DBUS_NEW_IFACE_P2P_PEER
, "a{sv}",
2740 wpas_dbus_getter_p2p_peer_properties
,
2743 { "IEs", WPAS_DBUS_NEW_IFACE_P2P_PEER
, "ay",
2744 wpas_dbus_getter_p2p_peer_ies
,
2747 { NULL
, NULL
, NULL
, NULL
, NULL
}
2750 static const struct wpa_dbus_signal_desc wpas_dbus_p2p_peer_signals
[] = {
2752 { NULL
, NULL
, { END_ARGS
} }
2756 * wpas_dbus_signal_peer - Send a peer related event signal
2757 * @wpa_s: %wpa_supplicant network interface data
2758 * @dev: peer device object
2759 * @interface: name of the interface emitting this signal.
2760 * In case of peer objects, it would be emitted by either
2761 * the "interface object" or by "peer objects"
2762 * @sig_name: signal name - DeviceFound
2764 * Notify listeners about event related with newly found p2p peer device
2766 static void wpas_dbus_signal_peer(struct wpa_supplicant
*wpa_s
,
2767 const u8
*dev_addr
, const char *interface
,
2768 const char *sig_name
)
2770 struct wpas_dbus_priv
*iface
;
2772 DBusMessageIter iter
;
2773 char peer_obj_path
[WPAS_DBUS_OBJECT_PATH_MAX
], *path
;
2775 iface
= wpa_s
->global
->dbus
;
2777 /* Do nothing if the control interface is not turned on */
2781 os_snprintf(peer_obj_path
, WPAS_DBUS_OBJECT_PATH_MAX
,
2782 "%s/" WPAS_DBUS_NEW_P2P_PEERS_PART
"/" COMPACT_MACSTR
,
2783 wpa_s
->dbus_new_path
, MAC2STR(dev_addr
));
2785 msg
= dbus_message_new_signal(wpa_s
->dbus_new_path
, interface
,
2790 dbus_message_iter_init_append(msg
, &iter
);
2791 path
= peer_obj_path
;
2792 if (!dbus_message_iter_append_basic(&iter
, DBUS_TYPE_OBJECT_PATH
,
2796 dbus_connection_send(iface
->con
, msg
, NULL
);
2798 dbus_message_unref(msg
);
2802 wpa_printf(MSG_ERROR
, "dbus: Failed to construct signal");
2803 dbus_message_unref(msg
);
2808 * wpas_dbus_signal_peer_found - Send a peer found signal
2809 * @wpa_s: %wpa_supplicant network interface data
2810 * @dev: peer device object
2812 * Notify listeners about find a p2p peer device found
2814 void wpas_dbus_signal_peer_device_found(struct wpa_supplicant
*wpa_s
,
2817 wpas_dbus_signal_peer(wpa_s
, dev_addr
,
2818 WPAS_DBUS_NEW_IFACE_P2PDEVICE
,
2823 * wpas_dbus_signal_peer_lost - Send a peer lost signal
2824 * @wpa_s: %wpa_supplicant network interface data
2825 * @dev: peer device object
2827 * Notify listeners about lost a p2p peer device
2829 void wpas_dbus_signal_peer_device_lost(struct wpa_supplicant
*wpa_s
,
2832 wpas_dbus_signal_peer(wpa_s
, dev_addr
,
2833 WPAS_DBUS_NEW_IFACE_P2PDEVICE
,
2838 * wpas_dbus_register_peer - Register a discovered peer object with dbus
2839 * @wpa_s: wpa_supplicant interface structure
2840 * @ssid: network configuration data
2841 * Returns: 0 on success, -1 on failure
2843 * Registers network representing object with dbus
2845 int wpas_dbus_register_peer(struct wpa_supplicant
*wpa_s
, const u8
*dev_addr
)
2847 struct wpas_dbus_priv
*ctrl_iface
;
2848 struct wpa_dbus_object_desc
*obj_desc
;
2849 struct peer_handler_args
*arg
;
2850 char peer_obj_path
[WPAS_DBUS_OBJECT_PATH_MAX
];
2852 /* Do nothing if the control interface is not turned on */
2853 if (wpa_s
== NULL
|| wpa_s
->global
== NULL
)
2856 ctrl_iface
= wpa_s
->global
->dbus
;
2857 if (ctrl_iface
== NULL
)
2860 os_snprintf(peer_obj_path
, WPAS_DBUS_OBJECT_PATH_MAX
,
2861 "%s/" WPAS_DBUS_NEW_P2P_PEERS_PART
"/" COMPACT_MACSTR
,
2862 wpa_s
->dbus_new_path
, MAC2STR(dev_addr
));
2864 wpa_printf(MSG_INFO
, "dbus: Register peer object '%s'",
2866 obj_desc
= os_zalloc(sizeof(struct wpa_dbus_object_desc
));
2868 wpa_printf(MSG_ERROR
, "Not enough memory "
2869 "to create object description");
2873 /* allocate memory for handlers arguments */
2874 arg
= os_zalloc(sizeof(struct peer_handler_args
));
2876 wpa_printf(MSG_ERROR
, "Not enough memory "
2877 "to create arguments for method");
2882 os_memcpy(arg
->p2p_device_addr
, dev_addr
, ETH_ALEN
);
2884 wpas_dbus_register(obj_desc
, arg
, wpa_dbus_free
,
2886 wpas_dbus_p2p_peer_properties
,
2887 wpas_dbus_p2p_peer_signals
);
2889 if (wpa_dbus_register_object_per_iface(ctrl_iface
, peer_obj_path
,
2890 wpa_s
->ifname
, obj_desc
))
2896 free_dbus_object_desc(obj_desc
);
2901 * wpas_dbus_unregister_peer - Unregister a peer object with dbus
2902 * @wpa_s: wpa_supplicant interface structure
2903 * @dev_addr: p2p device addr
2904 * Returns: 0 on success, -1 on failure
2906 * Registers network representing object with dbus
2908 int wpas_dbus_unregister_peer(struct wpa_supplicant
*wpa_s
,
2911 struct wpas_dbus_priv
*ctrl_iface
;
2912 char peer_obj_path
[WPAS_DBUS_OBJECT_PATH_MAX
];
2915 /* Do nothing if the control interface is not turned on */
2916 if (wpa_s
== NULL
|| wpa_s
->global
== NULL
||
2917 wpa_s
->dbus_new_path
== NULL
)
2919 ctrl_iface
= wpa_s
->global
->dbus
;
2920 if (ctrl_iface
== NULL
)
2923 os_snprintf(peer_obj_path
, WPAS_DBUS_OBJECT_PATH_MAX
,
2924 "%s/" WPAS_DBUS_NEW_P2P_PEERS_PART
"/" COMPACT_MACSTR
,
2925 wpa_s
->dbus_new_path
, MAC2STR(dev_addr
));
2927 wpa_printf(MSG_INFO
, "dbus: Unregister peer object '%s'",
2929 ret
= wpa_dbus_unregister_object_per_iface(ctrl_iface
, peer_obj_path
);
2935 static const struct wpa_dbus_property_desc wpas_dbus_p2p_group_properties
[] = {
2936 { "Members", WPAS_DBUS_NEW_IFACE_P2P_GROUP
, "ao",
2937 wpas_dbus_getter_p2p_group_members
,
2941 WPAS_DBUS_NEW_IFACE_P2P_GROUP
, "a{sv}",
2942 wpas_dbus_getter_p2p_group_properties
,
2943 wpas_dbus_setter_p2p_group_properties
2945 { NULL
, NULL
, NULL
, NULL
, NULL
}
2948 static const struct wpa_dbus_signal_desc wpas_dbus_p2p_group_signals
[] = {
2949 { "PeerJoined", WPAS_DBUS_NEW_IFACE_P2P_GROUP
,
2951 { "peer", "o", ARG_OUT
},
2955 { "PeerDisconnected", WPAS_DBUS_NEW_IFACE_P2P_GROUP
,
2957 { "peer", "o", ARG_OUT
},
2961 { NULL
, NULL
, { END_ARGS
} }
2965 * wpas_dbus_register_p2p_group - Register a p2p group object with dbus
2966 * @wpa_s: wpa_supplicant interface structure
2967 * @ssid: SSID struct
2968 * Returns: 0 on success, -1 on failure
2970 * Registers p2p group representing object with dbus
2972 void wpas_dbus_register_p2p_group(struct wpa_supplicant
*wpa_s
,
2973 struct wpa_ssid
*ssid
)
2975 struct wpas_dbus_priv
*ctrl_iface
;
2976 struct wpa_dbus_object_desc
*obj_desc
;
2977 char group_obj_path
[WPAS_DBUS_OBJECT_PATH_MAX
];
2979 /* Do nothing if the control interface is not turned on */
2980 if (wpa_s
== NULL
|| wpa_s
->global
== NULL
)
2983 ctrl_iface
= wpa_s
->global
->dbus
;
2984 if (ctrl_iface
== NULL
)
2987 if (wpa_s
->dbus_groupobj_path
) {
2988 wpa_printf(MSG_INFO
, "%s: Group object '%s' already exists",
2989 __func__
, wpa_s
->dbus_groupobj_path
);
2993 if (wpas_dbus_get_group_obj_path(wpa_s
, ssid
, group_obj_path
) < 0)
2996 wpa_s
->dbus_groupobj_path
= os_strdup(group_obj_path
);
2997 if (wpa_s
->dbus_groupobj_path
== NULL
)
3000 wpa_printf(MSG_INFO
, "dbus: Register group object '%s'",
3002 obj_desc
= os_zalloc(sizeof(struct wpa_dbus_object_desc
));
3004 wpa_printf(MSG_ERROR
, "Not enough memory "
3005 "to create object description");
3009 wpas_dbus_register(obj_desc
, wpa_s
, NULL
, NULL
,
3010 wpas_dbus_p2p_group_properties
,
3011 wpas_dbus_p2p_group_signals
);
3013 if (wpa_dbus_register_object_per_iface(ctrl_iface
, group_obj_path
,
3014 wpa_s
->ifname
, obj_desc
))
3020 if (wpa_s
->dbus_groupobj_path
) {
3021 os_free(wpa_s
->dbus_groupobj_path
);
3022 wpa_s
->dbus_groupobj_path
= NULL
;
3025 free_dbus_object_desc(obj_desc
);
3029 * wpas_dbus_unregister_p2p_group - Unregister a p2p group object from dbus
3030 * @wpa_s: wpa_supplicant interface structure
3031 * @ssid: network name of the p2p group started
3033 void wpas_dbus_unregister_p2p_group(struct wpa_supplicant
*wpa_s
,
3034 const struct wpa_ssid
*ssid
)
3036 struct wpas_dbus_priv
*ctrl_iface
;
3038 /* Do nothing if the control interface is not turned on */
3039 if (wpa_s
== NULL
|| wpa_s
->global
== NULL
)
3042 ctrl_iface
= wpa_s
->global
->dbus
;
3043 if (ctrl_iface
== NULL
)
3046 if (!wpa_s
->dbus_groupobj_path
) {
3047 wpa_printf(MSG_DEBUG
,
3048 "%s: Group object '%s' already unregistered",
3049 __func__
, wpa_s
->dbus_groupobj_path
);
3053 wpa_printf(MSG_DEBUG
, "dbus: Unregister group object '%s'",
3054 wpa_s
->dbus_groupobj_path
);
3056 wpa_dbus_unregister_object_per_iface(ctrl_iface
,
3057 wpa_s
->dbus_groupobj_path
);
3059 os_free(wpa_s
->dbus_groupobj_path
);
3060 wpa_s
->dbus_groupobj_path
= NULL
;
3063 static const struct wpa_dbus_property_desc
3064 wpas_dbus_p2p_groupmember_properties
[] = {
3065 { "Properties", WPAS_DBUS_NEW_IFACE_P2P_GROUPMEMBER
, "a{sv}",
3066 wpas_dbus_getter_p2p_group_properties
,
3069 { NULL
, NULL
, NULL
, NULL
, NULL
}
3073 * wpas_dbus_register_p2p_groupmember - Register a p2p groupmember
3075 * @wpa_s: wpa_supplicant interface structure
3076 * @p2p_if_addr: i/f addr of the device joining this group
3078 * Registers p2p groupmember representing object with dbus
3080 void wpas_dbus_register_p2p_groupmember(struct wpa_supplicant
*wpa_s
,
3081 const u8
*p2p_if_addr
)
3083 struct wpas_dbus_priv
*ctrl_iface
;
3084 struct wpa_dbus_object_desc
*obj_desc
= NULL
;
3085 struct groupmember_handler_args
*arg
;
3086 char groupmember_obj_path
[WPAS_DBUS_OBJECT_PATH_MAX
];
3088 /* Do nothing if the control interface is not turned on */
3089 if (wpa_s
== NULL
|| wpa_s
->global
== NULL
)
3092 ctrl_iface
= wpa_s
->global
->dbus
;
3093 if (ctrl_iface
== NULL
)
3096 if (!wpa_s
->dbus_groupobj_path
)
3099 os_snprintf(groupmember_obj_path
, WPAS_DBUS_OBJECT_PATH_MAX
,
3100 "%s/" WPAS_DBUS_NEW_P2P_GROUPMEMBERS_PART
"/" COMPACT_MACSTR
,
3101 wpa_s
->dbus_groupobj_path
, MAC2STR(p2p_if_addr
));
3103 obj_desc
= os_zalloc(sizeof(struct wpa_dbus_object_desc
));
3105 wpa_printf(MSG_ERROR
, "Not enough memory "
3106 "to create object description");
3110 /* allocate memory for handlers arguments */
3111 arg
= os_zalloc(sizeof(struct groupmember_handler_args
));
3113 wpa_printf(MSG_ERROR
, "Not enough memory "
3114 "to create arguments for method");
3119 os_memcpy(arg
->member_addr
, p2p_if_addr
, ETH_ALEN
);
3121 wpas_dbus_register(obj_desc
, arg
, wpa_dbus_free
, NULL
,
3122 wpas_dbus_p2p_groupmember_properties
, NULL
);
3124 if (wpa_dbus_register_object_per_iface(ctrl_iface
, groupmember_obj_path
,
3125 wpa_s
->ifname
, obj_desc
))
3128 wpa_printf(MSG_INFO
,
3129 "dbus: Registered group member object '%s' successfully",
3130 groupmember_obj_path
);
3134 free_dbus_object_desc(obj_desc
);
3138 * wpas_dbus_unregister_p2p_groupmember - Unregister a p2p groupmember
3140 * @wpa_s: wpa_supplicant interface structure
3141 * @p2p_if_addr: i/f addr of the device joining this group
3143 * Unregisters p2p groupmember representing object with dbus
3145 void wpas_dbus_unregister_p2p_groupmember(struct wpa_supplicant
*wpa_s
,
3146 const u8
*p2p_if_addr
)
3148 struct wpas_dbus_priv
*ctrl_iface
;
3149 char groupmember_obj_path
[WPAS_DBUS_OBJECT_PATH_MAX
];
3151 /* Do nothing if the control interface is not turned on */
3152 if (wpa_s
== NULL
|| wpa_s
->global
== NULL
)
3155 ctrl_iface
= wpa_s
->global
->dbus
;
3156 if (ctrl_iface
== NULL
)
3159 if (!wpa_s
->dbus_groupobj_path
)
3162 os_snprintf(groupmember_obj_path
, WPAS_DBUS_OBJECT_PATH_MAX
,
3163 "%s/" WPAS_DBUS_NEW_P2P_GROUPMEMBERS_PART
"/" COMPACT_MACSTR
,
3164 wpa_s
->dbus_groupobj_path
, MAC2STR(p2p_if_addr
));
3166 wpa_dbus_unregister_object_per_iface(ctrl_iface
, groupmember_obj_path
);
3170 static const struct wpa_dbus_property_desc
3171 wpas_dbus_persistent_group_properties
[] = {
3172 { "Properties", WPAS_DBUS_NEW_IFACE_PERSISTENT_GROUP
, "a{sv}",
3173 wpas_dbus_getter_persistent_group_properties
,
3174 wpas_dbus_setter_persistent_group_properties
3176 { NULL
, NULL
, NULL
, NULL
, NULL
}
3179 /* No signals intended for persistent group objects */
3182 * wpas_dbus_register_persistent_group - Register a configured(saved)
3183 * persistent group with dbus
3184 * @wpa_s: wpa_supplicant interface structure
3185 * @ssid: persistent group (still represented as a network within wpa)
3186 * configuration data
3187 * Returns: 0 on success, -1 on failure
3189 * Registers a persistent group representing object with dbus.
3191 int wpas_dbus_register_persistent_group(struct wpa_supplicant
*wpa_s
,
3192 struct wpa_ssid
*ssid
)
3194 struct wpas_dbus_priv
*ctrl_iface
;
3195 struct wpa_dbus_object_desc
*obj_desc
;
3196 struct network_handler_args
*arg
;
3197 char pgrp_obj_path
[WPAS_DBUS_OBJECT_PATH_MAX
];
3199 /* Do nothing if the control interface is not turned on */
3200 if (wpa_s
== NULL
|| wpa_s
->global
== NULL
)
3203 /* Make sure ssid is a persistent group */
3204 if (ssid
->disabled
!= 2 && !ssid
->p2p_persistent_group
)
3205 return -1; /* should we return w/o complaining? */
3207 ctrl_iface
= wpa_s
->global
->dbus
;
3208 if (ctrl_iface
== NULL
)
3212 * Intentionally not coming up with different numbering scheme
3213 * for persistent groups.
3215 os_snprintf(pgrp_obj_path
, WPAS_DBUS_OBJECT_PATH_MAX
,
3216 "%s/" WPAS_DBUS_NEW_PERSISTENT_GROUPS_PART
"/%u",
3217 wpa_s
->dbus_new_path
, ssid
->id
);
3219 wpa_printf(MSG_DEBUG
, "dbus: Register persistent group object '%s'",
3221 obj_desc
= os_zalloc(sizeof(struct wpa_dbus_object_desc
));
3223 wpa_printf(MSG_ERROR
, "dbus: Not enough memory to create "
3224 "object description");
3229 * Reusing the same context structure as that for networks
3230 * since these are represented using same data structure.
3232 /* allocate memory for handlers arguments */
3233 arg
= os_zalloc(sizeof(struct network_handler_args
));
3235 wpa_printf(MSG_ERROR
, "dbus: Not enough memory to create "
3236 "arguments for method");
3243 wpas_dbus_register(obj_desc
, arg
, wpa_dbus_free
, NULL
,
3244 wpas_dbus_persistent_group_properties
,
3247 if (wpa_dbus_register_object_per_iface(ctrl_iface
, pgrp_obj_path
,
3248 wpa_s
->ifname
, obj_desc
))
3251 wpas_dbus_signal_persistent_group_added(wpa_s
, ssid
->id
);
3256 free_dbus_object_desc(obj_desc
);
3262 * wpas_dbus_unregister_persistent_group - Unregister a persistent_group
3264 * @wpa_s: wpa_supplicant interface structure
3266 * Returns: 0 on success, -1 on failure
3268 * Unregisters persistent group representing object from dbus
3270 * NOTE: There is a slight issue with the semantics here. While the
3271 * implementation simply means the persistent group is unloaded from memory,
3272 * it should not get interpreted as the group is actually being erased/removed
3273 * from persistent storage as well.
3275 int wpas_dbus_unregister_persistent_group(struct wpa_supplicant
*wpa_s
,
3278 struct wpas_dbus_priv
*ctrl_iface
;
3279 char pgrp_obj_path
[WPAS_DBUS_OBJECT_PATH_MAX
];
3282 /* Do nothing if the control interface is not turned on */
3283 if (wpa_s
== NULL
|| wpa_s
->global
== NULL
||
3284 wpa_s
->dbus_new_path
== NULL
)
3286 ctrl_iface
= wpa_s
->global
->dbus
;
3287 if (ctrl_iface
== NULL
)
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
, nid
);
3294 wpa_printf(MSG_DEBUG
, "dbus: Unregister persistent group object '%s'",
3296 ret
= wpa_dbus_unregister_object_per_iface(ctrl_iface
, pgrp_obj_path
);
3299 wpas_dbus_signal_persistent_group_removed(wpa_s
, nid
);
3304 #endif /* CONFIG_P2P */