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
;
48 DBusMessageIter iter
, iter_dict
;
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_dict_open_write(&iter
, &iter_dict
))
70 wpa_dbus_get_object_properties(iface
, wpa_s
->dbus_new_path
,
71 WPAS_DBUS_NEW_IFACE_INTERFACE
,
74 if (!wpa_dbus_dict_close_write(&iter
, &iter_dict
))
78 dbus_connection_send(iface
->con
, msg
, NULL
);
79 dbus_message_unref(msg
);
83 wpa_printf(MSG_ERROR
, "dbus: Failed to construct signal");
84 dbus_message_unref(msg
);
89 * wpas_dbus_signal_interface_added - Send a interface created signal
90 * @wpa_s: %wpa_supplicant network interface data
92 * Notify listeners about creating new interface
94 static void wpas_dbus_signal_interface_added(struct wpa_supplicant
*wpa_s
)
96 wpas_dbus_signal_interface(wpa_s
, "InterfaceAdded", TRUE
);
101 * wpas_dbus_signal_interface_removed - Send a interface removed signal
102 * @wpa_s: %wpa_supplicant network interface data
104 * Notify listeners about removing interface
106 static void wpas_dbus_signal_interface_removed(struct wpa_supplicant
*wpa_s
)
108 wpas_dbus_signal_interface(wpa_s
, "InterfaceRemoved", FALSE
);
114 * wpas_dbus_signal_scan_done - send scan done signal
115 * @wpa_s: %wpa_supplicant network interface data
116 * @success: indicates if scanning succeed or failed
118 * Notify listeners about finishing a scan
120 void wpas_dbus_signal_scan_done(struct wpa_supplicant
*wpa_s
, int success
)
122 struct wpas_dbus_priv
*iface
;
126 iface
= wpa_s
->global
->dbus
;
128 /* Do nothing if the control interface is not turned on */
132 msg
= dbus_message_new_signal(wpa_s
->dbus_new_path
,
133 WPAS_DBUS_NEW_IFACE_INTERFACE
,
138 succ
= success
? TRUE
: FALSE
;
139 if (dbus_message_append_args(msg
, DBUS_TYPE_BOOLEAN
, &succ
,
141 dbus_connection_send(iface
->con
, msg
, NULL
);
143 wpa_printf(MSG_ERROR
, "dbus: Failed to construct signal");
144 dbus_message_unref(msg
);
149 * wpas_dbus_signal_blob - Send a BSS related event signal
150 * @wpa_s: %wpa_supplicant network interface data
151 * @bss_obj_path: BSS object path
152 * @sig_name: signal name - BSSAdded or BSSRemoved
153 * @properties: Whether to add second argument with object properties
155 * Notify listeners about event related with BSS
157 static void wpas_dbus_signal_bss(struct wpa_supplicant
*wpa_s
,
158 const char *bss_obj_path
,
159 const char *sig_name
, int properties
)
161 struct wpas_dbus_priv
*iface
;
163 DBusMessageIter iter
, iter_dict
;
165 iface
= wpa_s
->global
->dbus
;
167 /* Do nothing if the control interface is not turned on */
171 msg
= dbus_message_new_signal(wpa_s
->dbus_new_path
,
172 WPAS_DBUS_NEW_IFACE_INTERFACE
,
177 dbus_message_iter_init_append(msg
, &iter
);
178 if (!dbus_message_iter_append_basic(&iter
, DBUS_TYPE_OBJECT_PATH
,
183 if (!wpa_dbus_dict_open_write(&iter
, &iter_dict
))
186 wpa_dbus_get_object_properties(iface
, bss_obj_path
,
187 WPAS_DBUS_NEW_IFACE_BSS
,
190 if (!wpa_dbus_dict_close_write(&iter
, &iter_dict
))
194 dbus_connection_send(iface
->con
, msg
, NULL
);
195 dbus_message_unref(msg
);
199 wpa_printf(MSG_ERROR
, "dbus: Failed to construct signal");
200 dbus_message_unref(msg
);
205 * wpas_dbus_signal_bss_added - Send a BSS added signal
206 * @wpa_s: %wpa_supplicant network interface data
207 * @bss_obj_path: new BSS object path
209 * Notify listeners about adding new BSS
211 static void wpas_dbus_signal_bss_added(struct wpa_supplicant
*wpa_s
,
212 const char *bss_obj_path
)
214 wpas_dbus_signal_bss(wpa_s
, bss_obj_path
, "BSSAdded", TRUE
);
219 * wpas_dbus_signal_bss_removed - Send a BSS removed signal
220 * @wpa_s: %wpa_supplicant network interface data
221 * @bss_obj_path: BSS object path
223 * Notify listeners about removing BSS
225 static void wpas_dbus_signal_bss_removed(struct wpa_supplicant
*wpa_s
,
226 const char *bss_obj_path
)
228 wpas_dbus_signal_bss(wpa_s
, bss_obj_path
, "BSSRemoved", FALSE
);
233 * wpas_dbus_signal_blob - Send a blob related event signal
234 * @wpa_s: %wpa_supplicant network interface data
236 * @sig_name: signal name - BlobAdded or BlobRemoved
238 * Notify listeners about event related with blob
240 static void wpas_dbus_signal_blob(struct wpa_supplicant
*wpa_s
,
241 const char *name
, const char *sig_name
)
243 struct wpas_dbus_priv
*iface
;
246 iface
= wpa_s
->global
->dbus
;
248 /* Do nothing if the control interface is not turned on */
252 msg
= dbus_message_new_signal(wpa_s
->dbus_new_path
,
253 WPAS_DBUS_NEW_IFACE_INTERFACE
,
258 if (dbus_message_append_args(msg
, DBUS_TYPE_STRING
, &name
,
260 dbus_connection_send(iface
->con
, msg
, NULL
);
262 wpa_printf(MSG_ERROR
, "dbus: Failed to construct signal");
263 dbus_message_unref(msg
);
268 * wpas_dbus_signal_blob_added - Send a blob added signal
269 * @wpa_s: %wpa_supplicant network interface data
272 * Notify listeners about adding a new blob
274 void wpas_dbus_signal_blob_added(struct wpa_supplicant
*wpa_s
,
277 wpas_dbus_signal_blob(wpa_s
, name
, "BlobAdded");
282 * wpas_dbus_signal_blob_removed - Send a blob removed signal
283 * @wpa_s: %wpa_supplicant network interface data
286 * Notify listeners about removing blob
288 void wpas_dbus_signal_blob_removed(struct wpa_supplicant
*wpa_s
,
291 wpas_dbus_signal_blob(wpa_s
, name
, "BlobRemoved");
296 * wpas_dbus_signal_network - Send a network related event signal
297 * @wpa_s: %wpa_supplicant network interface data
298 * @id: new network id
299 * @sig_name: signal name - NetworkAdded, NetworkRemoved or NetworkSelected
300 * @properties: determines if add second argument with object properties
302 * Notify listeners about event related with configured network
304 static void wpas_dbus_signal_network(struct wpa_supplicant
*wpa_s
,
305 int id
, const char *sig_name
,
308 struct wpas_dbus_priv
*iface
;
310 DBusMessageIter iter
, iter_dict
;
311 char net_obj_path
[WPAS_DBUS_OBJECT_PATH_MAX
], *path
;
313 iface
= wpa_s
->global
->dbus
;
315 /* Do nothing if the control interface is not turned on */
319 os_snprintf(net_obj_path
, WPAS_DBUS_OBJECT_PATH_MAX
,
320 "%s/" WPAS_DBUS_NEW_NETWORKS_PART
"/%u",
321 wpa_s
->dbus_new_path
, id
);
323 msg
= dbus_message_new_signal(wpa_s
->dbus_new_path
,
324 WPAS_DBUS_NEW_IFACE_INTERFACE
,
329 dbus_message_iter_init_append(msg
, &iter
);
331 if (!dbus_message_iter_append_basic(&iter
, DBUS_TYPE_OBJECT_PATH
,
336 if (!wpa_dbus_dict_open_write(&iter
, &iter_dict
))
339 wpa_dbus_get_object_properties(iface
, net_obj_path
,
340 WPAS_DBUS_NEW_IFACE_NETWORK
,
343 if (!wpa_dbus_dict_close_write(&iter
, &iter_dict
))
347 dbus_connection_send(iface
->con
, msg
, NULL
);
349 dbus_message_unref(msg
);
353 wpa_printf(MSG_ERROR
, "dbus: Failed to construct signal");
354 dbus_message_unref(msg
);
359 * wpas_dbus_signal_network_added - Send a network added signal
360 * @wpa_s: %wpa_supplicant network interface data
361 * @id: new network id
363 * Notify listeners about adding new network
365 static void wpas_dbus_signal_network_added(struct wpa_supplicant
*wpa_s
,
368 wpas_dbus_signal_network(wpa_s
, id
, "NetworkAdded", TRUE
);
373 * wpas_dbus_signal_network_removed - Send a network removed signal
374 * @wpa_s: %wpa_supplicant network interface data
377 * Notify listeners about removing a network
379 static void wpas_dbus_signal_network_removed(struct wpa_supplicant
*wpa_s
,
382 wpas_dbus_signal_network(wpa_s
, id
, "NetworkRemoved", FALSE
);
387 * wpas_dbus_signal_network_selected - Send a network selected signal
388 * @wpa_s: %wpa_supplicant network interface data
391 * Notify listeners about selecting a network
393 void wpas_dbus_signal_network_selected(struct wpa_supplicant
*wpa_s
, int id
)
395 wpas_dbus_signal_network(wpa_s
, id
, "NetworkSelected", FALSE
);
400 * wpas_dbus_signal_network_enabled_changed - Signals Enabled property changes
401 * @wpa_s: %wpa_supplicant network interface data
402 * @ssid: configured network which Enabled property has changed
404 * Sends PropertyChanged signals containing new value of Enabled property
405 * for specified network
407 void wpas_dbus_signal_network_enabled_changed(struct wpa_supplicant
*wpa_s
,
408 struct wpa_ssid
*ssid
)
411 char path
[WPAS_DBUS_OBJECT_PATH_MAX
];
412 os_snprintf(path
, WPAS_DBUS_OBJECT_PATH_MAX
,
413 "%s/" WPAS_DBUS_NEW_NETWORKS_PART
"/%d",
414 wpa_s
->dbus_new_path
, ssid
->id
);
416 wpa_dbus_mark_property_changed(wpa_s
->global
->dbus
, path
,
417 WPAS_DBUS_NEW_IFACE_NETWORK
, "Enabled");
424 * wpas_dbus_signal_wps_event_success - Signals Success WPS event
425 * @wpa_s: %wpa_supplicant network interface data
427 * Sends Event dbus signal with name "success" and empty dict as arguments
429 void wpas_dbus_signal_wps_event_success(struct wpa_supplicant
*wpa_s
)
433 DBusMessageIter iter
, dict_iter
;
434 struct wpas_dbus_priv
*iface
;
435 char *key
= "success";
437 iface
= wpa_s
->global
->dbus
;
439 /* Do nothing if the control interface is not turned on */
443 msg
= dbus_message_new_signal(wpa_s
->dbus_new_path
,
444 WPAS_DBUS_NEW_IFACE_WPS
, "Event");
448 dbus_message_iter_init_append(msg
, &iter
);
450 if (!dbus_message_iter_append_basic(&iter
, DBUS_TYPE_STRING
, &key
) ||
451 !wpa_dbus_dict_open_write(&iter
, &dict_iter
) ||
452 !wpa_dbus_dict_close_write(&iter
, &dict_iter
))
453 wpa_printf(MSG_ERROR
, "dbus: Failed to construct signal");
455 dbus_connection_send(iface
->con
, msg
, NULL
);
457 dbus_message_unref(msg
);
462 * wpas_dbus_signal_wps_event_fail - Signals Fail WPS event
463 * @wpa_s: %wpa_supplicant network interface data
465 * Sends Event dbus signal with name "fail" and dictionary containing
466 * "msg field with fail message number (int32) as arguments
468 void wpas_dbus_signal_wps_event_fail(struct wpa_supplicant
*wpa_s
,
469 struct wps_event_fail
*fail
)
473 DBusMessageIter iter
, dict_iter
;
474 struct wpas_dbus_priv
*iface
;
477 iface
= wpa_s
->global
->dbus
;
479 /* Do nothing if the control interface is not turned on */
483 msg
= dbus_message_new_signal(wpa_s
->dbus_new_path
,
484 WPAS_DBUS_NEW_IFACE_WPS
, "Event");
488 dbus_message_iter_init_append(msg
, &iter
);
490 if (!dbus_message_iter_append_basic(&iter
, DBUS_TYPE_STRING
, &key
) ||
491 !wpa_dbus_dict_open_write(&iter
, &dict_iter
) ||
492 !wpa_dbus_dict_append_int32(&dict_iter
, "msg", fail
->msg
) ||
493 !wpa_dbus_dict_close_write(&iter
, &dict_iter
))
494 wpa_printf(MSG_ERROR
, "dbus: Failed to construct signal");
496 dbus_connection_send(iface
->con
, msg
, NULL
);
498 dbus_message_unref(msg
);
503 * wpas_dbus_signal_wps_event_m2d - Signals M2D WPS event
504 * @wpa_s: %wpa_supplicant network interface data
506 * Sends Event dbus signal with name "m2d" and dictionary containing
507 * fields of wps_event_m2d structure.
509 void wpas_dbus_signal_wps_event_m2d(struct wpa_supplicant
*wpa_s
,
510 struct wps_event_m2d
*m2d
)
514 DBusMessageIter iter
, dict_iter
;
515 struct wpas_dbus_priv
*iface
;
518 iface
= wpa_s
->global
->dbus
;
520 /* Do nothing if the control interface is not turned on */
524 msg
= dbus_message_new_signal(wpa_s
->dbus_new_path
,
525 WPAS_DBUS_NEW_IFACE_WPS
, "Event");
529 dbus_message_iter_init_append(msg
, &iter
);
531 if (!dbus_message_iter_append_basic(&iter
, DBUS_TYPE_STRING
, &key
) ||
532 !wpa_dbus_dict_open_write(&iter
, &dict_iter
) ||
533 !wpa_dbus_dict_append_uint16(&dict_iter
, "config_methods",
534 m2d
->config_methods
) ||
535 !wpa_dbus_dict_append_byte_array(&dict_iter
, "manufacturer",
536 (const char *) m2d
->manufacturer
,
537 m2d
->manufacturer_len
) ||
538 !wpa_dbus_dict_append_byte_array(&dict_iter
, "model_name",
539 (const char *) m2d
->model_name
,
540 m2d
->model_name_len
) ||
541 !wpa_dbus_dict_append_byte_array(&dict_iter
, "model_number",
542 (const char *) m2d
->model_number
,
543 m2d
->model_number_len
) ||
544 !wpa_dbus_dict_append_byte_array(&dict_iter
, "serial_number",
547 m2d
->serial_number_len
) ||
548 !wpa_dbus_dict_append_byte_array(&dict_iter
, "dev_name",
549 (const char *) m2d
->dev_name
,
550 m2d
->dev_name_len
) ||
551 !wpa_dbus_dict_append_byte_array(&dict_iter
, "primary_dev_type",
553 m2d
->primary_dev_type
, 8) ||
554 !wpa_dbus_dict_append_uint16(&dict_iter
, "config_error",
555 m2d
->config_error
) ||
556 !wpa_dbus_dict_append_uint16(&dict_iter
, "dev_password_id",
557 m2d
->dev_password_id
) ||
558 !wpa_dbus_dict_close_write(&iter
, &dict_iter
))
559 wpa_printf(MSG_ERROR
, "dbus: Failed to construct signal");
561 dbus_connection_send(iface
->con
, msg
, NULL
);
563 dbus_message_unref(msg
);
568 * wpas_dbus_signal_wps_cred - Signals new credentials
569 * @wpa_s: %wpa_supplicant network interface data
571 * Sends signal with credentials in directory argument
573 void wpas_dbus_signal_wps_cred(struct wpa_supplicant
*wpa_s
,
574 const struct wps_credential
*cred
)
577 DBusMessageIter iter
, dict_iter
;
578 struct wpas_dbus_priv
*iface
;
579 char *auth_type
[6]; /* we have six possible authorization types */
581 char *encr_type
[4]; /* we have four possible encryption types */
584 iface
= wpa_s
->global
->dbus
;
586 /* Do nothing if the control interface is not turned on */
590 msg
= dbus_message_new_signal(wpa_s
->dbus_new_path
,
591 WPAS_DBUS_NEW_IFACE_WPS
,
596 dbus_message_iter_init_append(msg
, &iter
);
597 if (!wpa_dbus_dict_open_write(&iter
, &dict_iter
))
600 if (cred
->auth_type
& WPS_AUTH_OPEN
)
601 auth_type
[at_num
++] = "open";
602 if (cred
->auth_type
& WPS_AUTH_WPAPSK
)
603 auth_type
[at_num
++] = "wpa-psk";
604 if (cred
->auth_type
& WPS_AUTH_SHARED
)
605 auth_type
[at_num
++] = "shared";
606 if (cred
->auth_type
& WPS_AUTH_WPA
)
607 auth_type
[at_num
++] = "wpa-eap";
608 if (cred
->auth_type
& WPS_AUTH_WPA2
)
609 auth_type
[at_num
++] = "wpa2-eap";
610 if (cred
->auth_type
& WPS_AUTH_WPA2PSK
)
611 auth_type
[at_num
++] =
614 if (cred
->encr_type
& WPS_ENCR_NONE
)
615 encr_type
[et_num
++] = "none";
616 if (cred
->encr_type
& WPS_ENCR_WEP
)
617 encr_type
[et_num
++] = "wep";
618 if (cred
->encr_type
& WPS_ENCR_TKIP
)
619 encr_type
[et_num
++] = "tkip";
620 if (cred
->encr_type
& WPS_ENCR_AES
)
621 encr_type
[et_num
++] = "aes";
623 if (wpa_s
->current_ssid
) {
624 if (!wpa_dbus_dict_append_byte_array(
626 (const char *) wpa_s
->current_ssid
->bssid
,
631 if (!wpa_dbus_dict_append_byte_array(&dict_iter
, "SSID",
632 (const char *) cred
->ssid
,
634 !wpa_dbus_dict_append_string_array(&dict_iter
, "AuthType",
635 (const char **) auth_type
,
637 !wpa_dbus_dict_append_string_array(&dict_iter
, "EncrType",
638 (const char **) encr_type
,
640 !wpa_dbus_dict_append_byte_array(&dict_iter
, "Key",
641 (const char *) cred
->key
,
643 !wpa_dbus_dict_append_uint32(&dict_iter
, "KeyIndex",
645 !wpa_dbus_dict_close_write(&iter
, &dict_iter
))
648 dbus_connection_send(iface
->con
, msg
, NULL
);
651 dbus_message_unref(msg
);
654 #endif /* CONFIG_WPS */
659 * wpas_dbus_signal_p2p_group_removed - Signals P2P group was removed
660 * @wpa_s: %wpa_supplicant network interface data
661 * @role: role of this device (client or GO)
662 * Sends signal with i/f name and role as string arguments
664 void wpas_dbus_signal_p2p_group_removed(struct wpa_supplicant
*wpa_s
,
669 DBusMessageIter iter
;
670 struct wpas_dbus_priv
*iface
= wpa_s
->global
->dbus
;
671 char *ifname
= wpa_s
->ifname
;
673 /* Do nothing if the control interface is not turned on */
677 msg
= dbus_message_new_signal(wpa_s
->dbus_new_path
,
678 WPAS_DBUS_NEW_IFACE_P2PDEVICE
,
683 dbus_message_iter_init_append(msg
, &iter
);
685 if (!dbus_message_iter_append_basic(&iter
, DBUS_TYPE_STRING
, &ifname
)) {
686 wpa_printf(MSG_ERROR
, "dbus: Failed to construct GroupFinished"
687 "signal -not enough memory for ifname ");
691 if (!dbus_message_iter_append_basic(&iter
, DBUS_TYPE_STRING
, &role
))
692 wpa_printf(MSG_ERROR
, "dbus: Failed to construct GroupFinished"
693 "signal -not enough memory for role ");
695 dbus_connection_send(iface
->con
, msg
, NULL
);
698 dbus_message_unref(msg
);
703 * wpas_dbus_signal_p2p_provision_discovery - Signals various PD events
705 * @dev_addr - who sent the request or responded to our request.
706 * @request - Will be 1 if request, 0 for response.
707 * @status - valid only in case of response
708 * @config_methods - wps config methods
709 * @generated_pin - pin to be displayed in case of WPS_CONFIG_DISPLAY method
711 * Sends following provision discovery related events:
712 * ProvisionDiscoveryRequestDisplayPin
713 * ProvisionDiscoveryResponseDisplayPin
714 * ProvisionDiscoveryRequestEnterPin
715 * ProvisionDiscoveryResponseEnterPin
716 * ProvisionDiscoveryPBCRequest
717 * ProvisionDiscoveryPBCResponse
720 * ProvisionDiscoveryFailure (timeout case)
722 void wpas_dbus_signal_p2p_provision_discovery(struct wpa_supplicant
*wpa_s
,
723 const u8
*dev_addr
, int request
,
724 enum p2p_prov_disc_status status
,
726 unsigned int generated_pin
)
729 DBusMessageIter iter
;
730 struct wpas_dbus_priv
*iface
;
733 char peer_obj_path
[WPAS_DBUS_OBJECT_PATH_MAX
], *path
;
735 char pin
[9], *p_pin
= NULL
;
737 iface
= wpa_s
->global
->dbus
;
739 /* Do nothing if the control interface is not turned on */
743 if (request
|| !status
) {
744 if (config_methods
& WPS_CONFIG_DISPLAY
)
746 "ProvisionDiscoveryRequestDisplayPin" :
747 "ProvisionDiscoveryResponseEnterPin";
748 else if (config_methods
& WPS_CONFIG_KEYPAD
)
750 "ProvisionDiscoveryRequestEnterPin" :
751 "ProvisionDiscoveryResponseDisplayPin";
752 else if (config_methods
& WPS_CONFIG_PUSHBUTTON
)
753 _signal
= request
? "ProvisionDiscoveryPBCRequest" :
754 "ProvisionDiscoveryPBCResponse";
756 return; /* Unknown or un-supported method */
757 } else if (!request
&& status
)
758 /* Explicit check for failure response */
759 _signal
= "ProvisionDiscoveryFailure";
761 add_pin
= ((request
&& (config_methods
& WPS_CONFIG_DISPLAY
)) ||
762 (!request
&& !status
&&
763 (config_methods
& WPS_CONFIG_KEYPAD
)));
766 os_snprintf(pin
, sizeof(pin
), "%08d", generated_pin
);
770 msg
= dbus_message_new_signal(wpa_s
->dbus_new_path
,
771 WPAS_DBUS_NEW_IFACE_P2PDEVICE
, _signal
);
775 /* Check if this is a known peer */
776 if (p2p_get_peer_info(wpa_s
->global
->p2p
, dev_addr
, 0, NULL
, 0) < 0)
779 os_snprintf(peer_obj_path
, WPAS_DBUS_OBJECT_PATH_MAX
,
780 "%s/" WPAS_DBUS_NEW_P2P_PEERS_PART
"/"
782 wpa_s
->dbus_new_path
, MAC2STR(dev_addr
));
784 path
= peer_obj_path
;
786 dbus_message_iter_init_append(msg
, &iter
);
788 if (!dbus_message_iter_append_basic(&iter
,
789 DBUS_TYPE_OBJECT_PATH
,
793 if (!request
&& status
)
794 /* Attach status to ProvisionDiscoveryFailure */
795 error_ret
= !dbus_message_iter_append_basic(&iter
,
799 error_ret
= (add_pin
&&
800 !dbus_message_iter_append_basic(&iter
,
806 dbus_connection_send(iface
->con
, msg
, NULL
);
808 wpa_printf(MSG_ERROR
, "dbus: Failed to construct signal");
810 dbus_message_unref(msg
);
814 void wpas_dbus_signal_p2p_go_neg_req(struct wpa_supplicant
*wpa_s
,
815 const u8
*src
, u16 dev_passwd_id
)
818 DBusMessageIter iter
;
819 struct wpas_dbus_priv
*iface
;
820 char peer_obj_path
[WPAS_DBUS_OBJECT_PATH_MAX
], *path
;
822 iface
= wpa_s
->global
->dbus
;
824 /* Do nothing if the control interface is not turned on */
828 os_snprintf(peer_obj_path
, WPAS_DBUS_OBJECT_PATH_MAX
,
829 "%s/" WPAS_DBUS_NEW_P2P_PEERS_PART
"/" COMPACT_MACSTR
,
830 wpa_s
->dbus_new_path
, MAC2STR(src
));
831 path
= peer_obj_path
;
833 msg
= dbus_message_new_signal(wpa_s
->dbus_new_path
,
834 WPAS_DBUS_NEW_IFACE_P2PDEVICE
,
835 "GONegotiationRequest");
839 dbus_message_iter_init_append(msg
, &iter
);
841 if (!dbus_message_iter_append_basic(&iter
, DBUS_TYPE_OBJECT_PATH
,
843 !dbus_message_iter_append_basic(&iter
, DBUS_TYPE_UINT16
,
845 wpa_printf(MSG_ERROR
, "dbus: Failed to construct signal");
847 dbus_connection_send(iface
->con
, msg
, NULL
);
849 dbus_message_unref(msg
);
853 static int wpas_dbus_get_group_obj_path(struct wpa_supplicant
*wpa_s
,
854 const struct wpa_ssid
*ssid
,
855 char *group_obj_path
)
859 if (os_memcmp(ssid
->ssid
, P2P_WILDCARD_SSID
, P2P_WILDCARD_SSID_LEN
))
862 memcpy(group_name
, ssid
->ssid
+ P2P_WILDCARD_SSID_LEN
, 2);
863 group_name
[2] = '\0';
865 os_snprintf(group_obj_path
, WPAS_DBUS_OBJECT_PATH_MAX
,
866 "%s/" WPAS_DBUS_NEW_P2P_GROUPS_PART
"/%s",
867 wpa_s
->dbus_new_path
, group_name
);
874 * wpas_dbus_signal_p2p_group_started - Signals P2P group has
875 * started.Emitted when a group is succesfully started
876 * irrespective of the role (client/GO) of the current device
878 * @wpa_s: %wpa_supplicant network interface data
880 * @client: this device is P2P client
881 * @network_id: network id of the group started, use instead of ssid->id
882 * to account for persistent groups
884 void wpas_dbus_signal_p2p_group_started(struct wpa_supplicant
*wpa_s
,
885 const struct wpa_ssid
*ssid
,
886 int client
, int network_id
)
889 DBusMessageIter iter
, dict_iter
;
890 struct wpas_dbus_priv
*iface
;
891 char net_obj_path
[WPAS_DBUS_OBJECT_PATH_MAX
];
892 char group_obj_path
[WPAS_DBUS_OBJECT_PATH_MAX
];
894 iface
= wpa_s
->parent
->global
->dbus
;
896 /* Do nothing if the control interface is not turned on */
900 if (wpas_dbus_get_group_obj_path(wpa_s
, ssid
, group_obj_path
) < 0)
903 /* New interface has been created for this group */
904 msg
= dbus_message_new_signal(wpa_s
->parent
->dbus_new_path
,
905 WPAS_DBUS_NEW_IFACE_P2PDEVICE
,
911 dbus_message_iter_init_append(msg
, &iter
);
912 if (!wpa_dbus_dict_open_write(&iter
, &dict_iter
))
916 * In case the device supports creating a separate interface the
917 * DBus client will need to know the object path for the interface
918 * object this group was created on, so include it here.
920 if (!wpa_dbus_dict_append_object_path(&dict_iter
,
922 wpa_s
->dbus_new_path
))
925 if (!wpa_dbus_dict_append_string(&dict_iter
, "role",
926 client
? "client" : "GO"))
929 os_snprintf(net_obj_path
, WPAS_DBUS_OBJECT_PATH_MAX
,
930 "%s/" WPAS_DBUS_NEW_NETWORKS_PART
"/%u",
931 wpa_s
->parent
->dbus_new_path
, network_id
);
933 if (!wpa_dbus_dict_append_object_path(&dict_iter
, "group_object",
935 !wpa_dbus_dict_append_object_path(&dict_iter
, "network_object",
937 !wpa_dbus_dict_close_write(&iter
, &dict_iter
))
940 dbus_connection_send(iface
->con
, msg
, NULL
);
943 dbus_message_unref(msg
);
949 * Method to emit GONeogtiation Success or Failure signals based
951 * @status: Status of the GO neg request. 0 for success, other for errors.
953 void wpas_dbus_signal_p2p_go_neg_resp(struct wpa_supplicant
*wpa_s
, int status
)
956 DBusMessageIter iter
;
957 struct wpas_dbus_priv
*iface
;
959 iface
= wpa_s
->global
->dbus
;
961 /* Do nothing if the control interface is not turned on */
965 msg
= dbus_message_new_signal(wpa_s
->dbus_new_path
,
966 WPAS_DBUS_NEW_IFACE_P2PDEVICE
,
967 status
? "GONegotiationFailure" :
968 "GONegotiationSuccess");
973 dbus_message_iter_init_append(msg
, &iter
);
974 if (!dbus_message_iter_append_basic(&iter
, DBUS_TYPE_INT32
,
976 wpa_printf(MSG_ERROR
,
977 "dbus: Failed to construct signal");
982 dbus_connection_send(iface
->con
, msg
, NULL
);
984 dbus_message_unref(msg
);
990 * Method to emit Invitation Result signal based on status and
992 * @status: Status of the Invite request. 0 for success, other
994 * @bssid : Basic Service Set Identifier
996 void wpas_dbus_signal_p2p_invitation_result(struct wpa_supplicant
*wpa_s
,
997 int status
, const u8
*bssid
)
1000 DBusMessageIter iter
, dict_iter
;
1001 struct wpas_dbus_priv
*iface
;
1003 wpa_printf(MSG_INFO
, "%s\n", __func__
);
1005 iface
= wpa_s
->global
->dbus
;
1006 /* Do nothing if the control interface is not turned on */
1010 msg
= dbus_message_new_signal(wpa_s
->dbus_new_path
,
1011 WPAS_DBUS_NEW_IFACE_P2PDEVICE
,
1012 "InvitationResult");
1017 dbus_message_iter_init_append(msg
, &iter
);
1018 if (!wpa_dbus_dict_open_write(&iter
, &dict_iter
))
1021 if (!wpa_dbus_dict_append_int32(&dict_iter
, "status", status
))
1024 if (!wpa_dbus_dict_append_byte_array(&dict_iter
, "BSSID",
1025 (const char *) bssid
,
1029 if (!wpa_dbus_dict_close_write(&iter
, &dict_iter
))
1032 dbus_connection_send(iface
->con
, msg
, NULL
);
1035 dbus_message_unref(msg
);
1041 * Method to emit a signal for a peer joining the group.
1042 * The signal will carry path to the group member object
1043 * constructed using p2p i/f addr used for connecting.
1045 * @wpa_s: %wpa_supplicant network interface data
1046 * @member_addr: addr (p2p i/f) of the peer joining the group
1048 void wpas_dbus_signal_p2p_peer_joined(struct wpa_supplicant
*wpa_s
,
1051 struct wpas_dbus_priv
*iface
;
1053 DBusMessageIter iter
;
1054 char groupmember_obj_path
[WPAS_DBUS_OBJECT_PATH_MAX
], *path
;
1056 iface
= wpa_s
->global
->dbus
;
1058 /* Do nothing if the control interface is not turned on */
1062 if (!wpa_s
->dbus_groupobj_path
)
1065 os_snprintf(groupmember_obj_path
, WPAS_DBUS_OBJECT_PATH_MAX
,
1066 "%s/" WPAS_DBUS_NEW_P2P_GROUPMEMBERS_PART
"/"
1068 wpa_s
->dbus_groupobj_path
, MAC2STR(member
));
1070 msg
= dbus_message_new_signal(wpa_s
->dbus_groupobj_path
,
1071 WPAS_DBUS_NEW_IFACE_P2P_GROUP
,
1076 dbus_message_iter_init_append(msg
, &iter
);
1077 path
= groupmember_obj_path
;
1078 if (!dbus_message_iter_append_basic(&iter
, DBUS_TYPE_OBJECT_PATH
,
1082 dbus_connection_send(iface
->con
, msg
, NULL
);
1084 dbus_message_unref(msg
);
1088 wpa_printf(MSG_ERROR
, "dbus: Failed to construct signal");
1089 dbus_message_unref(msg
);
1095 * Method to emit a signal for a peer disconnecting the group.
1096 * The signal will carry path to the group member object
1097 * constructed using p2p i/f addr used for connecting.
1099 * @wpa_s: %wpa_supplicant network interface data
1100 * @member_addr: addr (p2p i/f) of the peer joining the group
1102 void wpas_dbus_signal_p2p_peer_disconnected(struct wpa_supplicant
*wpa_s
,
1105 struct wpas_dbus_priv
*iface
;
1107 DBusMessageIter iter
;
1108 char groupmember_obj_path
[WPAS_DBUS_OBJECT_PATH_MAX
], *path
;
1110 iface
= wpa_s
->global
->dbus
;
1112 /* Do nothing if the control interface is not turned on */
1116 if (!wpa_s
->dbus_groupobj_path
)
1119 os_snprintf(groupmember_obj_path
, WPAS_DBUS_OBJECT_PATH_MAX
,
1120 "%s/" WPAS_DBUS_NEW_P2P_GROUPMEMBERS_PART
"/"
1122 wpa_s
->dbus_groupobj_path
, MAC2STR(member
));
1124 msg
= dbus_message_new_signal(wpa_s
->dbus_groupobj_path
,
1125 WPAS_DBUS_NEW_IFACE_P2P_GROUP
,
1126 "PeerDisconnected");
1130 dbus_message_iter_init_append(msg
, &iter
);
1131 path
= groupmember_obj_path
;
1132 if (!dbus_message_iter_append_basic(&iter
, DBUS_TYPE_OBJECT_PATH
,
1136 dbus_connection_send(iface
->con
, msg
, NULL
);
1138 dbus_message_unref(msg
);
1142 wpa_printf(MSG_ERROR
, "dbus: Failed to construct PeerDisconnected "
1144 dbus_message_unref(msg
);
1150 * Method to emit a signal for a service discovery request.
1151 * The signal will carry station address, frequency, dialog token,
1152 * update indicator and it tlvs
1154 * @wpa_s: %wpa_supplicant network interface data
1155 * @sa: station addr (p2p i/f) of the peer
1156 * @dialog_token: service discovery request dialog token
1157 * @update_indic: service discovery request update indicator
1158 * @tlvs: service discovery request genrated byte array of tlvs
1159 * @tlvs_len: service discovery request tlvs length
1161 void wpas_dbus_signal_p2p_sd_request(struct wpa_supplicant
*wpa_s
,
1162 int freq
, const u8
*sa
, u8 dialog_token
,
1163 u16 update_indic
, const u8
*tlvs
,
1167 DBusMessageIter iter
, dict_iter
;
1168 struct wpas_dbus_priv
*iface
;
1169 char peer_obj_path
[WPAS_DBUS_OBJECT_PATH_MAX
], *path
;
1170 iface
= wpa_s
->global
->dbus
;
1172 /* Do nothing if the control interface is not turned on */
1176 msg
= dbus_message_new_signal(wpa_s
->dbus_new_path
,
1177 WPAS_DBUS_NEW_IFACE_P2PDEVICE
,
1178 "ServiceDiscoveryRequest");
1182 /* Check if this is a known peer */
1183 if (p2p_get_peer_info(wpa_s
->global
->p2p
, sa
, 0, NULL
, 0) < 0)
1186 os_snprintf(peer_obj_path
, WPAS_DBUS_OBJECT_PATH_MAX
,
1187 "%s/" WPAS_DBUS_NEW_P2P_PEERS_PART
"/"
1188 COMPACT_MACSTR
, wpa_s
->dbus_new_path
, MAC2STR(sa
));
1190 path
= peer_obj_path
;
1192 dbus_message_iter_init_append(msg
, &iter
);
1193 if (!wpa_dbus_dict_open_write(&iter
, &dict_iter
))
1197 if (!wpa_dbus_dict_append_object_path(&dict_iter
, "peer_object",
1199 !wpa_dbus_dict_append_int32(&dict_iter
, "frequency", freq
) ||
1200 !wpa_dbus_dict_append_int32(&dict_iter
, "dialog_token",
1202 !wpa_dbus_dict_append_uint16(&dict_iter
, "update_indicator",
1204 !wpa_dbus_dict_append_byte_array(&dict_iter
, "tlvs",
1205 (const char *) tlvs
,
1207 !wpa_dbus_dict_close_write(&iter
, &dict_iter
))
1210 dbus_connection_send(iface
->con
, msg
, NULL
);
1211 dbus_message_unref(msg
);
1214 wpa_printf(MSG_ERROR
, "dbus: Failed to construct signal");
1215 dbus_message_unref(msg
);
1221 * Method to emit a signal for a service discovery response.
1222 * The signal will carry station address, update indicator and it
1225 * @wpa_s: %wpa_supplicant network interface data
1226 * @sa: station addr (p2p i/f) of the peer
1227 * @update_indic: service discovery request update indicator
1228 * @tlvs: service discovery request genrated byte array of tlvs
1229 * @tlvs_len: service discovery request tlvs length
1231 void wpas_dbus_signal_p2p_sd_response(struct wpa_supplicant
*wpa_s
,
1232 const u8
*sa
, u16 update_indic
,
1233 const u8
*tlvs
, size_t tlvs_len
)
1236 DBusMessageIter iter
, dict_iter
;
1237 struct wpas_dbus_priv
*iface
;
1238 char peer_obj_path
[WPAS_DBUS_OBJECT_PATH_MAX
], *path
;
1239 iface
= wpa_s
->global
->dbus
;
1241 /* Do nothing if the control interface is not turned on */
1245 msg
= dbus_message_new_signal(wpa_s
->dbus_new_path
,
1246 WPAS_DBUS_NEW_IFACE_P2PDEVICE
,
1247 "ServiceDiscoveryResponse");
1251 /* Check if this is a known peer */
1252 if (p2p_get_peer_info(wpa_s
->global
->p2p
, sa
, 0, NULL
, 0) < 0)
1255 os_snprintf(peer_obj_path
, WPAS_DBUS_OBJECT_PATH_MAX
,
1256 "%s/" WPAS_DBUS_NEW_P2P_PEERS_PART
"/"
1257 COMPACT_MACSTR
, wpa_s
->dbus_new_path
, MAC2STR(sa
));
1259 path
= peer_obj_path
;
1261 dbus_message_iter_init_append(msg
, &iter
);
1262 if (!wpa_dbus_dict_open_write(&iter
, &dict_iter
))
1265 if (!wpa_dbus_dict_append_object_path(&dict_iter
, "peer_object",
1267 !wpa_dbus_dict_append_uint16(&dict_iter
, "update_indicator",
1269 !wpa_dbus_dict_append_byte_array(&dict_iter
, "tlvs",
1270 (const char *) tlvs
,
1272 !wpa_dbus_dict_close_write(&iter
, &dict_iter
))
1276 dbus_connection_send(iface
->con
, msg
, NULL
);
1277 dbus_message_unref(msg
);
1280 wpa_printf(MSG_ERROR
, "dbus: Failed to construct signal");
1281 dbus_message_unref(msg
);
1284 #endif /*CONFIG_P2P*/
1288 * wpas_dbus_signal_prop_changed - Signals change of property
1289 * @wpa_s: %wpa_supplicant network interface data
1290 * @property: indicates which property has changed
1292 * Sends ProertyChanged signals with path, interface and arguments
1293 * depending on which property has changed.
1295 void wpas_dbus_signal_prop_changed(struct wpa_supplicant
*wpa_s
,
1296 enum wpas_dbus_prop property
)
1298 WPADBusPropertyAccessor getter
;
1301 if (wpa_s
->dbus_new_path
== NULL
)
1302 return; /* Skip signal since D-Bus setup is not yet ready */
1305 case WPAS_DBUS_PROP_AP_SCAN
:
1306 getter
= (WPADBusPropertyAccessor
) wpas_dbus_getter_ap_scan
;
1309 case WPAS_DBUS_PROP_SCANNING
:
1310 getter
= (WPADBusPropertyAccessor
) wpas_dbus_getter_scanning
;
1313 case WPAS_DBUS_PROP_STATE
:
1314 getter
= (WPADBusPropertyAccessor
) wpas_dbus_getter_state
;
1317 case WPAS_DBUS_PROP_CURRENT_BSS
:
1318 getter
= (WPADBusPropertyAccessor
)
1319 wpas_dbus_getter_current_bss
;
1320 prop
= "CurrentBSS";
1322 case WPAS_DBUS_PROP_CURRENT_NETWORK
:
1323 getter
= (WPADBusPropertyAccessor
)
1324 wpas_dbus_getter_current_network
;
1325 prop
= "CurrentNetwork";
1327 case WPAS_DBUS_PROP_BSSS
:
1328 getter
= (WPADBusPropertyAccessor
) wpas_dbus_getter_bsss
;
1331 case WPAS_DBUS_PROP_CURRENT_AUTH_MODE
:
1332 getter
= (WPADBusPropertyAccessor
)
1333 wpas_dbus_getter_current_auth_mode
;
1334 prop
= "CurrentAuthMode";
1337 wpa_printf(MSG_ERROR
, "dbus: %s: Unknown Property value %d",
1338 __func__
, property
);
1342 wpa_dbus_mark_property_changed(wpa_s
->global
->dbus
,
1343 wpa_s
->dbus_new_path
,
1344 WPAS_DBUS_NEW_IFACE_INTERFACE
, prop
);
1349 * wpas_dbus_bss_signal_prop_changed - Signals change of BSS property
1350 * @wpa_s: %wpa_supplicant network interface data
1351 * @property: indicates which property has changed
1352 * @id: unique BSS identifier
1354 * Sends PropertyChanged signals with path, interface, and arguments depending
1355 * on which property has changed.
1357 void wpas_dbus_bss_signal_prop_changed(struct wpa_supplicant
*wpa_s
,
1358 enum wpas_dbus_bss_prop property
,
1361 char path
[WPAS_DBUS_OBJECT_PATH_MAX
];
1365 case WPAS_DBUS_BSS_PROP_SIGNAL
:
1368 case WPAS_DBUS_BSS_PROP_FREQ
:
1371 case WPAS_DBUS_BSS_PROP_MODE
:
1374 case WPAS_DBUS_BSS_PROP_PRIVACY
:
1377 case WPAS_DBUS_BSS_PROP_RATES
:
1380 case WPAS_DBUS_BSS_PROP_WPA
:
1383 case WPAS_DBUS_BSS_PROP_RSN
:
1386 case WPAS_DBUS_BSS_PROP_IES
:
1390 wpa_printf(MSG_ERROR
, "dbus: %s: Unknown Property value %d",
1391 __func__
, property
);
1395 os_snprintf(path
, WPAS_DBUS_OBJECT_PATH_MAX
,
1396 "%s/" WPAS_DBUS_NEW_BSSIDS_PART
"/%u",
1397 wpa_s
->dbus_new_path
, id
);
1399 wpa_dbus_mark_property_changed(wpa_s
->global
->dbus
, path
,
1400 WPAS_DBUS_NEW_IFACE_BSS
, prop
);
1405 * wpas_dbus_signal_debug_level_changed - Signals change of debug param
1406 * @global: wpa_global structure
1408 * Sends ProertyChanged signals informing that debug level has changed.
1410 void wpas_dbus_signal_debug_level_changed(struct wpa_global
*global
)
1412 wpa_dbus_mark_property_changed(global
->dbus
, WPAS_DBUS_NEW_PATH
,
1413 WPAS_DBUS_NEW_INTERFACE
,
1419 * wpas_dbus_signal_debug_timestamp_changed - Signals change of debug param
1420 * @global: wpa_global structure
1422 * Sends ProertyChanged signals informing that debug timestamp has changed.
1424 void wpas_dbus_signal_debug_timestamp_changed(struct wpa_global
*global
)
1426 wpa_dbus_mark_property_changed(global
->dbus
, WPAS_DBUS_NEW_PATH
,
1427 WPAS_DBUS_NEW_INTERFACE
,
1433 * wpas_dbus_signal_debug_show_keys_changed - Signals change of debug param
1434 * @global: wpa_global structure
1436 * Sends ProertyChanged signals informing that debug show_keys has changed.
1438 void wpas_dbus_signal_debug_show_keys_changed(struct wpa_global
*global
)
1440 wpa_dbus_mark_property_changed(global
->dbus
, WPAS_DBUS_NEW_PATH
,
1441 WPAS_DBUS_NEW_INTERFACE
,
1446 static void wpas_dbus_register(struct wpa_dbus_object_desc
*obj_desc
,
1448 WPADBusArgumentFreeFunction priv_free
,
1449 const struct wpa_dbus_method_desc
*methods
,
1450 const struct wpa_dbus_property_desc
*properties
,
1451 const struct wpa_dbus_signal_desc
*signals
)
1455 obj_desc
->user_data
= priv
;
1456 obj_desc
->user_data_free_func
= priv_free
;
1457 obj_desc
->methods
= methods
;
1458 obj_desc
->properties
= properties
;
1459 obj_desc
->signals
= signals
;
1461 for (n
= 0; properties
&& properties
->dbus_property
; properties
++)
1464 obj_desc
->prop_changed_flags
= os_zalloc(n
);
1465 if (!obj_desc
->prop_changed_flags
)
1466 wpa_printf(MSG_DEBUG
, "dbus: %s: can't register handlers",
1471 static const struct wpa_dbus_method_desc wpas_dbus_global_methods
[] = {
1472 { "CreateInterface", WPAS_DBUS_NEW_INTERFACE
,
1473 (WPADBusMethodHandler
) &wpas_dbus_handler_create_interface
,
1475 { "args", "a{sv}", ARG_IN
},
1476 { "path", "o", ARG_OUT
},
1480 { "RemoveInterface", WPAS_DBUS_NEW_INTERFACE
,
1481 (WPADBusMethodHandler
) &wpas_dbus_handler_remove_interface
,
1483 { "path", "o", ARG_IN
},
1487 { "GetInterface", WPAS_DBUS_NEW_INTERFACE
,
1488 (WPADBusMethodHandler
) &wpas_dbus_handler_get_interface
,
1490 { "ifname", "s", ARG_IN
},
1491 { "path", "o", ARG_OUT
},
1495 { NULL
, NULL
, NULL
, { END_ARGS
} }
1498 static const struct wpa_dbus_property_desc wpas_dbus_global_properties
[] = {
1499 { "DebugLevel", WPAS_DBUS_NEW_INTERFACE
, "s",
1500 (WPADBusPropertyAccessor
) wpas_dbus_getter_debug_level
,
1501 (WPADBusPropertyAccessor
) wpas_dbus_setter_debug_level
,
1504 { "DebugTimestamp", WPAS_DBUS_NEW_INTERFACE
, "b",
1505 (WPADBusPropertyAccessor
) wpas_dbus_getter_debug_timestamp
,
1506 (WPADBusPropertyAccessor
) wpas_dbus_setter_debug_timestamp
,
1509 { "DebugShowKeys", WPAS_DBUS_NEW_INTERFACE
, "b",
1510 (WPADBusPropertyAccessor
) wpas_dbus_getter_debug_show_keys
,
1511 (WPADBusPropertyAccessor
) wpas_dbus_setter_debug_show_keys
,
1514 { "Interfaces", WPAS_DBUS_NEW_INTERFACE
, "ao",
1515 (WPADBusPropertyAccessor
) &wpas_dbus_getter_interfaces
,
1519 { "EapMethods", WPAS_DBUS_NEW_INTERFACE
, "as",
1520 (WPADBusPropertyAccessor
) wpas_dbus_getter_eap_methods
,
1524 { NULL
, NULL
, NULL
, NULL
, NULL
, 0 }
1527 static const struct wpa_dbus_signal_desc wpas_dbus_global_signals
[] = {
1528 { "InterfaceAdded", WPAS_DBUS_NEW_INTERFACE
,
1530 { "path", "o", ARG_OUT
},
1531 { "properties", "a{sv}", ARG_OUT
},
1535 { "InterfaceRemoved", WPAS_DBUS_NEW_INTERFACE
,
1537 { "path", "o", ARG_OUT
},
1541 { "PropertiesChanged", WPAS_DBUS_NEW_INTERFACE
,
1543 { "properties", "a{sv}", ARG_OUT
},
1547 { NULL
, NULL
, { END_ARGS
} }
1552 * wpas_dbus_ctrl_iface_init - Initialize dbus control interface
1553 * @global: Pointer to global data from wpa_supplicant_init()
1554 * Returns: 0 on success or -1 on failure
1556 * Initialize the dbus control interface for wpa_supplicantand and start
1557 * receiving commands from external programs over the bus.
1559 int wpas_dbus_ctrl_iface_init(struct wpas_dbus_priv
*priv
)
1561 struct wpa_dbus_object_desc
*obj_desc
;
1564 obj_desc
= os_zalloc(sizeof(struct wpa_dbus_object_desc
));
1566 wpa_printf(MSG_ERROR
, "Not enough memory "
1567 "to create object description");
1571 wpas_dbus_register(obj_desc
, priv
->global
, NULL
,
1572 wpas_dbus_global_methods
,
1573 wpas_dbus_global_properties
,
1574 wpas_dbus_global_signals
);
1576 wpa_printf(MSG_DEBUG
, "dbus: Register D-Bus object '%s'",
1577 WPAS_DBUS_NEW_PATH
);
1578 ret
= wpa_dbus_ctrl_iface_init(priv
, WPAS_DBUS_NEW_PATH
,
1579 WPAS_DBUS_NEW_SERVICE
,
1582 free_dbus_object_desc(obj_desc
);
1584 priv
->dbus_new_initialized
= 1;
1591 * wpas_dbus_ctrl_iface_deinit - Deinitialize dbus ctrl interface for
1593 * @iface: Pointer to dbus private data from wpas_dbus_init()
1595 * Deinitialize the dbus control interface that was initialized with
1596 * wpas_dbus_ctrl_iface_init().
1598 void wpas_dbus_ctrl_iface_deinit(struct wpas_dbus_priv
*iface
)
1600 if (!iface
->dbus_new_initialized
)
1602 wpa_printf(MSG_DEBUG
, "dbus: Unregister D-Bus object '%s'",
1603 WPAS_DBUS_NEW_PATH
);
1604 dbus_connection_unregister_object_path(iface
->con
,
1605 WPAS_DBUS_NEW_PATH
);
1609 static void wpa_dbus_free(void *ptr
)
1615 static const struct wpa_dbus_property_desc wpas_dbus_network_properties
[] = {
1616 { "Properties", WPAS_DBUS_NEW_IFACE_NETWORK
, "a{sv}",
1617 (WPADBusPropertyAccessor
) wpas_dbus_getter_network_properties
,
1618 (WPADBusPropertyAccessor
) wpas_dbus_setter_network_properties
,
1621 { "Enabled", WPAS_DBUS_NEW_IFACE_NETWORK
, "b",
1622 (WPADBusPropertyAccessor
) wpas_dbus_getter_enabled
,
1623 (WPADBusPropertyAccessor
) wpas_dbus_setter_enabled
,
1626 { NULL
, NULL
, NULL
, NULL
, NULL
, 0 }
1630 static const struct wpa_dbus_signal_desc wpas_dbus_network_signals
[] = {
1631 { "PropertiesChanged", WPAS_DBUS_NEW_IFACE_NETWORK
,
1633 { "properties", "a{sv}", ARG_OUT
},
1637 { NULL
, NULL
, { END_ARGS
} }
1642 * wpas_dbus_register_network - Register a configured network with dbus
1643 * @wpa_s: wpa_supplicant interface structure
1644 * @ssid: network configuration data
1645 * Returns: 0 on success, -1 on failure
1647 * Registers network representing object with dbus
1649 int wpas_dbus_register_network(struct wpa_supplicant
*wpa_s
,
1650 struct wpa_ssid
*ssid
)
1652 struct wpas_dbus_priv
*ctrl_iface
;
1653 struct wpa_dbus_object_desc
*obj_desc
;
1654 struct network_handler_args
*arg
;
1655 char net_obj_path
[WPAS_DBUS_OBJECT_PATH_MAX
];
1657 /* Do nothing if the control interface is not turned on */
1658 if (wpa_s
== NULL
|| wpa_s
->global
== NULL
)
1660 ctrl_iface
= wpa_s
->global
->dbus
;
1661 if (ctrl_iface
== NULL
)
1664 os_snprintf(net_obj_path
, WPAS_DBUS_OBJECT_PATH_MAX
,
1665 "%s/" WPAS_DBUS_NEW_NETWORKS_PART
"/%u",
1666 wpa_s
->dbus_new_path
, ssid
->id
);
1668 wpa_printf(MSG_DEBUG
, "dbus: Register network object '%s'",
1670 obj_desc
= os_zalloc(sizeof(struct wpa_dbus_object_desc
));
1672 wpa_printf(MSG_ERROR
, "Not enough memory "
1673 "to create object description");
1677 /* allocate memory for handlers arguments */
1678 arg
= os_zalloc(sizeof(struct network_handler_args
));
1680 wpa_printf(MSG_ERROR
, "Not enough memory "
1681 "to create arguments for method");
1688 wpas_dbus_register(obj_desc
, arg
, wpa_dbus_free
, NULL
,
1689 wpas_dbus_network_properties
,
1690 wpas_dbus_network_signals
);
1692 if (wpa_dbus_register_object_per_iface(ctrl_iface
, net_obj_path
,
1693 wpa_s
->ifname
, obj_desc
))
1696 wpas_dbus_signal_network_added(wpa_s
, ssid
->id
);
1701 free_dbus_object_desc(obj_desc
);
1707 * wpas_dbus_unregister_network - Unregister a configured network from dbus
1708 * @wpa_s: wpa_supplicant interface structure
1710 * Returns: 0 on success, -1 on failure
1712 * Unregisters network representing object from dbus
1714 int wpas_dbus_unregister_network(struct wpa_supplicant
*wpa_s
, int nid
)
1716 struct wpas_dbus_priv
*ctrl_iface
;
1717 char net_obj_path
[WPAS_DBUS_OBJECT_PATH_MAX
];
1720 /* Do nothing if the control interface is not turned on */
1721 if (wpa_s
== NULL
|| wpa_s
->global
== NULL
||
1722 wpa_s
->dbus_new_path
== NULL
)
1724 ctrl_iface
= wpa_s
->global
->dbus
;
1725 if (ctrl_iface
== NULL
)
1728 os_snprintf(net_obj_path
, WPAS_DBUS_OBJECT_PATH_MAX
,
1729 "%s/" WPAS_DBUS_NEW_NETWORKS_PART
"/%u",
1730 wpa_s
->dbus_new_path
, nid
);
1732 wpa_printf(MSG_DEBUG
, "dbus: Unregister network object '%s'",
1734 ret
= wpa_dbus_unregister_object_per_iface(ctrl_iface
, net_obj_path
);
1737 wpas_dbus_signal_network_removed(wpa_s
, nid
);
1743 static const struct wpa_dbus_property_desc wpas_dbus_bss_properties
[] = {
1744 { "SSID", WPAS_DBUS_NEW_IFACE_BSS
, "ay",
1745 (WPADBusPropertyAccessor
) wpas_dbus_getter_bss_ssid
,
1749 { "BSSID", WPAS_DBUS_NEW_IFACE_BSS
, "ay",
1750 (WPADBusPropertyAccessor
) wpas_dbus_getter_bss_bssid
,
1754 { "Privacy", WPAS_DBUS_NEW_IFACE_BSS
, "b",
1755 (WPADBusPropertyAccessor
) wpas_dbus_getter_bss_privacy
,
1759 { "Mode", WPAS_DBUS_NEW_IFACE_BSS
, "s",
1760 (WPADBusPropertyAccessor
) wpas_dbus_getter_bss_mode
,
1764 { "Signal", WPAS_DBUS_NEW_IFACE_BSS
, "n",
1765 (WPADBusPropertyAccessor
) wpas_dbus_getter_bss_signal
,
1769 { "Frequency", WPAS_DBUS_NEW_IFACE_BSS
, "q",
1770 (WPADBusPropertyAccessor
) wpas_dbus_getter_bss_frequency
,
1774 { "Rates", WPAS_DBUS_NEW_IFACE_BSS
, "au",
1775 (WPADBusPropertyAccessor
) wpas_dbus_getter_bss_rates
,
1779 { "WPA", WPAS_DBUS_NEW_IFACE_BSS
, "a{sv}",
1780 (WPADBusPropertyAccessor
) wpas_dbus_getter_bss_wpa
,
1784 { "RSN", WPAS_DBUS_NEW_IFACE_BSS
, "a{sv}",
1785 (WPADBusPropertyAccessor
) wpas_dbus_getter_bss_rsn
,
1789 { "IEs", WPAS_DBUS_NEW_IFACE_BSS
, "ay",
1790 (WPADBusPropertyAccessor
) wpas_dbus_getter_bss_ies
,
1794 { NULL
, NULL
, NULL
, NULL
, NULL
, 0 }
1798 static const struct wpa_dbus_signal_desc wpas_dbus_bss_signals
[] = {
1799 { "PropertiesChanged", WPAS_DBUS_NEW_IFACE_BSS
,
1801 { "properties", "a{sv}", ARG_OUT
},
1805 { NULL
, NULL
, { END_ARGS
} }
1810 * wpas_dbus_unregister_bss - Unregister a scanned BSS from dbus
1811 * @wpa_s: wpa_supplicant interface structure
1812 * @bssid: scanned network bssid
1813 * @id: unique BSS identifier
1814 * Returns: 0 on success, -1 on failure
1816 * Unregisters BSS representing object from dbus
1818 int wpas_dbus_unregister_bss(struct wpa_supplicant
*wpa_s
,
1819 u8 bssid
[ETH_ALEN
], unsigned int id
)
1821 struct wpas_dbus_priv
*ctrl_iface
;
1822 char bss_obj_path
[WPAS_DBUS_OBJECT_PATH_MAX
];
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(bss_obj_path
, WPAS_DBUS_OBJECT_PATH_MAX
,
1832 "%s/" WPAS_DBUS_NEW_BSSIDS_PART
"/%u",
1833 wpa_s
->dbus_new_path
, id
);
1835 wpa_printf(MSG_DEBUG
, "dbus: Unregister BSS object '%s'",
1837 if (wpa_dbus_unregister_object_per_iface(ctrl_iface
, bss_obj_path
)) {
1838 wpa_printf(MSG_ERROR
, "dbus: Cannot unregister BSS object %s",
1843 wpas_dbus_signal_bss_removed(wpa_s
, bss_obj_path
);
1844 wpas_dbus_signal_prop_changed(wpa_s
, WPAS_DBUS_PROP_BSSS
);
1851 * wpas_dbus_register_bss - Register a scanned BSS with dbus
1852 * @wpa_s: wpa_supplicant interface structure
1853 * @bssid: scanned network bssid
1854 * @id: unique BSS identifier
1855 * Returns: 0 on success, -1 on failure
1857 * Registers BSS representing object with dbus
1859 int wpas_dbus_register_bss(struct wpa_supplicant
*wpa_s
,
1860 u8 bssid
[ETH_ALEN
], unsigned int id
)
1862 struct wpas_dbus_priv
*ctrl_iface
;
1863 struct wpa_dbus_object_desc
*obj_desc
;
1864 char bss_obj_path
[WPAS_DBUS_OBJECT_PATH_MAX
];
1865 struct bss_handler_args
*arg
;
1867 /* Do nothing if the control interface is not turned on */
1868 if (wpa_s
== NULL
|| wpa_s
->global
== NULL
)
1870 ctrl_iface
= wpa_s
->global
->dbus
;
1871 if (ctrl_iface
== NULL
)
1874 os_snprintf(bss_obj_path
, WPAS_DBUS_OBJECT_PATH_MAX
,
1875 "%s/" WPAS_DBUS_NEW_BSSIDS_PART
"/%u",
1876 wpa_s
->dbus_new_path
, id
);
1878 obj_desc
= os_zalloc(sizeof(struct wpa_dbus_object_desc
));
1880 wpa_printf(MSG_ERROR
, "Not enough memory "
1881 "to create object description");
1885 arg
= os_zalloc(sizeof(struct bss_handler_args
));
1887 wpa_printf(MSG_ERROR
, "Not enough memory "
1888 "to create arguments for handler");
1894 wpas_dbus_register(obj_desc
, arg
, wpa_dbus_free
, NULL
,
1895 wpas_dbus_bss_properties
,
1896 wpas_dbus_bss_signals
);
1898 wpa_printf(MSG_DEBUG
, "dbus: Register BSS object '%s'",
1900 if (wpa_dbus_register_object_per_iface(ctrl_iface
, bss_obj_path
,
1901 wpa_s
->ifname
, obj_desc
)) {
1902 wpa_printf(MSG_ERROR
,
1903 "Cannot register BSSID dbus object %s.",
1908 wpas_dbus_signal_bss_added(wpa_s
, bss_obj_path
);
1909 wpas_dbus_signal_prop_changed(wpa_s
, WPAS_DBUS_PROP_BSSS
);
1914 free_dbus_object_desc(obj_desc
);
1919 static const struct wpa_dbus_method_desc wpas_dbus_interface_methods
[] = {
1920 { "Scan", WPAS_DBUS_NEW_IFACE_INTERFACE
,
1921 (WPADBusMethodHandler
) &wpas_dbus_handler_scan
,
1923 { "args", "a{sv}", ARG_IN
},
1927 { "Disconnect", WPAS_DBUS_NEW_IFACE_INTERFACE
,
1928 (WPADBusMethodHandler
) &wpas_dbus_handler_disconnect
,
1933 { "AddNetwork", WPAS_DBUS_NEW_IFACE_INTERFACE
,
1934 (WPADBusMethodHandler
) &wpas_dbus_handler_add_network
,
1936 { "args", "a{sv}", ARG_IN
},
1937 { "path", "o", ARG_OUT
},
1941 { "RemoveNetwork", WPAS_DBUS_NEW_IFACE_INTERFACE
,
1942 (WPADBusMethodHandler
) &wpas_dbus_handler_remove_network
,
1944 { "path", "o", ARG_IN
},
1948 { "RemoveAllNetworks", WPAS_DBUS_NEW_IFACE_INTERFACE
,
1949 (WPADBusMethodHandler
) &wpas_dbus_handler_remove_all_networks
,
1954 { "SelectNetwork", WPAS_DBUS_NEW_IFACE_INTERFACE
,
1955 (WPADBusMethodHandler
) &wpas_dbus_handler_select_network
,
1957 { "path", "o", ARG_IN
},
1961 { "AddBlob", WPAS_DBUS_NEW_IFACE_INTERFACE
,
1962 (WPADBusMethodHandler
) &wpas_dbus_handler_add_blob
,
1964 { "name", "s", ARG_IN
},
1965 { "data", "ay", ARG_IN
},
1969 { "GetBlob", WPAS_DBUS_NEW_IFACE_INTERFACE
,
1970 (WPADBusMethodHandler
) &wpas_dbus_handler_get_blob
,
1972 { "name", "s", ARG_IN
},
1973 { "data", "ay", ARG_OUT
},
1977 { "RemoveBlob", WPAS_DBUS_NEW_IFACE_INTERFACE
,
1978 (WPADBusMethodHandler
) &wpas_dbus_handler_remove_blob
,
1980 { "name", "s", ARG_IN
},
1985 { "Start", WPAS_DBUS_NEW_IFACE_WPS
,
1986 (WPADBusMethodHandler
) &wpas_dbus_handler_wps_start
,
1988 { "args", "a{sv}", ARG_IN
},
1989 { "output", "a{sv}", ARG_OUT
},
1993 #endif /* CONFIG_WPS */
1995 { "Find", WPAS_DBUS_NEW_IFACE_P2PDEVICE
,
1996 (WPADBusMethodHandler
)wpas_dbus_handler_p2p_find
,
1998 { "args", "a{sv}", ARG_IN
},
2002 { "StopFind", WPAS_DBUS_NEW_IFACE_P2PDEVICE
,
2003 (WPADBusMethodHandler
)wpas_dbus_handler_p2p_stop_find
,
2008 { "Listen", WPAS_DBUS_NEW_IFACE_P2PDEVICE
,
2009 (WPADBusMethodHandler
)wpas_dbus_handler_p2p_listen
,
2011 { "timeout", "i", ARG_IN
},
2015 { "ExtendedListen", WPAS_DBUS_NEW_IFACE_P2PDEVICE
,
2016 (WPADBusMethodHandler
)wpas_dbus_handler_p2p_extendedlisten
,
2018 { "args", "a{sv}", ARG_IN
},
2022 { "PresenceRequest", WPAS_DBUS_NEW_IFACE_P2PDEVICE
,
2023 (WPADBusMethodHandler
)wpas_dbus_handler_p2p_presence_request
,
2025 { "args", "a{sv}", ARG_IN
},
2029 { "ProvisionDiscoveryRequest", WPAS_DBUS_NEW_IFACE_P2PDEVICE
,
2030 (WPADBusMethodHandler
)wpas_dbus_handler_p2p_prov_disc_req
,
2032 { "peer", "o", ARG_IN
},
2033 { "config_method", "s", ARG_IN
},
2037 { "Connect", WPAS_DBUS_NEW_IFACE_P2PDEVICE
,
2038 (WPADBusMethodHandler
)wpas_dbus_handler_p2p_connect
,
2040 { "args", "a{sv}", ARG_IN
},
2041 { "generated_pin", "i", ARG_OUT
},
2045 { "GroupAdd", WPAS_DBUS_NEW_IFACE_P2PDEVICE
,
2046 (WPADBusMethodHandler
)wpas_dbus_handler_p2p_group_add
,
2048 { "args", "a{sv}", ARG_IN
},
2052 { "Invite", WPAS_DBUS_NEW_IFACE_P2PDEVICE
,
2053 (WPADBusMethodHandler
)wpas_dbus_handler_p2p_invite
,
2055 { "args", "a{sv}", ARG_IN
},
2059 { "Disconnect", WPAS_DBUS_NEW_IFACE_P2PDEVICE
,
2060 (WPADBusMethodHandler
)wpas_dbus_handler_p2p_disconnect
,
2065 { "RejectPeer", WPAS_DBUS_NEW_IFACE_P2PDEVICE
,
2066 (WPADBusMethodHandler
)wpas_dbus_handler_p2p_rejectpeer
,
2068 { "peer", "o", ARG_IN
},
2072 { "Flush", WPAS_DBUS_NEW_IFACE_P2PDEVICE
,
2073 (WPADBusMethodHandler
)wpas_dbus_handler_p2p_flush
,
2078 { "AddService", WPAS_DBUS_NEW_IFACE_P2PDEVICE
,
2079 (WPADBusMethodHandler
)wpas_dbus_handler_p2p_add_service
,
2081 { "args", "a{sv}", ARG_IN
},
2085 { "DeleteService", WPAS_DBUS_NEW_IFACE_P2PDEVICE
,
2086 (WPADBusMethodHandler
)wpas_dbus_handler_p2p_delete_service
,
2088 { "args", "a{sv}", ARG_IN
},
2092 { "FlushService", WPAS_DBUS_NEW_IFACE_P2PDEVICE
,
2093 (WPADBusMethodHandler
)wpas_dbus_handler_p2p_flush_service
,
2098 { "ServiceDiscoveryRequest", WPAS_DBUS_NEW_IFACE_P2PDEVICE
,
2099 (WPADBusMethodHandler
)wpas_dbus_handler_p2p_service_sd_req
,
2101 { "args", "a{sv}", ARG_IN
},
2105 { "ServiceDiscoveryResponse", WPAS_DBUS_NEW_IFACE_P2PDEVICE
,
2106 (WPADBusMethodHandler
)wpas_dbus_handler_p2p_service_sd_res
,
2108 { "args", "a{sv}", ARG_IN
},
2112 { "ServiceDiscoveryCancelRequest", WPAS_DBUS_NEW_IFACE_P2PDEVICE
,
2113 (WPADBusMethodHandler
)wpas_dbus_handler_p2p_service_sd_cancel_req
,
2115 { "args", "t", ARG_IN
},
2119 { "ServiceUpdate", WPAS_DBUS_NEW_IFACE_P2PDEVICE
,
2120 (WPADBusMethodHandler
)wpas_dbus_handler_p2p_service_update
,
2125 { "ServiceDiscoveryExternal", WPAS_DBUS_NEW_IFACE_P2PDEVICE
,
2126 (WPADBusMethodHandler
)wpas_dbus_handler_p2p_serv_disc_external
,
2128 { "arg", "i", ARG_IN
},
2132 { "ServiceDiscoveryExternal", WPAS_DBUS_NEW_IFACE_P2PDEVICE
,
2133 (WPADBusMethodHandler
)wpas_dbus_handler_p2p_serv_disc_external
,
2135 { "arg", "i", ARG_IN
},
2139 #endif /* CONFIG_P2P */
2140 { "FlushBSS", WPAS_DBUS_NEW_IFACE_INTERFACE
,
2141 (WPADBusMethodHandler
) &wpas_dbus_handler_flush_bss
,
2143 { "age", "u", ARG_IN
},
2147 { NULL
, NULL
, NULL
, { END_ARGS
} }
2150 static const struct wpa_dbus_property_desc wpas_dbus_interface_properties
[] = {
2151 { "Capabilities", WPAS_DBUS_NEW_IFACE_INTERFACE
, "a{sv}",
2152 (WPADBusPropertyAccessor
) wpas_dbus_getter_capabilities
,
2155 { "State", WPAS_DBUS_NEW_IFACE_INTERFACE
, "s",
2156 (WPADBusPropertyAccessor
) wpas_dbus_getter_state
,
2159 { "Scanning", WPAS_DBUS_NEW_IFACE_INTERFACE
, "b",
2160 (WPADBusPropertyAccessor
) wpas_dbus_getter_scanning
,
2163 { "ApScan", WPAS_DBUS_NEW_IFACE_INTERFACE
, "u",
2164 (WPADBusPropertyAccessor
) wpas_dbus_getter_ap_scan
,
2165 (WPADBusPropertyAccessor
) wpas_dbus_setter_ap_scan
,
2168 { "BSSExpireAge", WPAS_DBUS_NEW_IFACE_INTERFACE
, "u",
2169 (WPADBusPropertyAccessor
) wpas_dbus_getter_bss_expire_age
,
2170 (WPADBusPropertyAccessor
) wpas_dbus_setter_bss_expire_age
,
2173 { "BSSExpireCount", WPAS_DBUS_NEW_IFACE_INTERFACE
, "u",
2174 (WPADBusPropertyAccessor
) wpas_dbus_getter_bss_expire_count
,
2175 (WPADBusPropertyAccessor
) wpas_dbus_setter_bss_expire_count
,
2178 { "Country", WPAS_DBUS_NEW_IFACE_INTERFACE
, "s",
2179 (WPADBusPropertyAccessor
) wpas_dbus_getter_country
,
2180 (WPADBusPropertyAccessor
) wpas_dbus_setter_country
,
2183 { "Ifname", WPAS_DBUS_NEW_IFACE_INTERFACE
, "s",
2184 (WPADBusPropertyAccessor
) wpas_dbus_getter_ifname
,
2187 { "Driver", WPAS_DBUS_NEW_IFACE_INTERFACE
, "s",
2188 (WPADBusPropertyAccessor
) wpas_dbus_getter_driver
,
2191 { "BridgeIfname", WPAS_DBUS_NEW_IFACE_INTERFACE
, "s",
2192 (WPADBusPropertyAccessor
) wpas_dbus_getter_bridge_ifname
,
2195 { "CurrentBSS", WPAS_DBUS_NEW_IFACE_INTERFACE
, "o",
2196 (WPADBusPropertyAccessor
) wpas_dbus_getter_current_bss
,
2199 { "CurrentNetwork", WPAS_DBUS_NEW_IFACE_INTERFACE
, "o",
2200 (WPADBusPropertyAccessor
) wpas_dbus_getter_current_network
,
2203 { "CurrentAuthMode", WPAS_DBUS_NEW_IFACE_INTERFACE
, "s",
2204 (WPADBusPropertyAccessor
) wpas_dbus_getter_current_auth_mode
,
2207 { "Blobs", WPAS_DBUS_NEW_IFACE_INTERFACE
, "a{say}",
2208 (WPADBusPropertyAccessor
) wpas_dbus_getter_blobs
,
2211 { "BSSs", WPAS_DBUS_NEW_IFACE_INTERFACE
, "ao",
2212 (WPADBusPropertyAccessor
) wpas_dbus_getter_bsss
,
2215 { "Networks", WPAS_DBUS_NEW_IFACE_INTERFACE
, "ao",
2216 (WPADBusPropertyAccessor
) wpas_dbus_getter_networks
,
2220 { "ProcessCredentials", WPAS_DBUS_NEW_IFACE_WPS
, "b",
2221 (WPADBusPropertyAccessor
) wpas_dbus_getter_process_credentials
,
2222 (WPADBusPropertyAccessor
) wpas_dbus_setter_process_credentials
,
2225 #endif /* CONFIG_WPS */
2227 { "P2PDeviceProperties", WPAS_DBUS_NEW_IFACE_P2PDEVICE
, "a{sv}",
2228 (WPADBusPropertyAccessor
) wpas_dbus_getter_p2p_device_properties
,
2229 (WPADBusPropertyAccessor
) wpas_dbus_setter_p2p_device_properties
,
2232 { "Peers", WPAS_DBUS_NEW_IFACE_P2PDEVICE
, "ao",
2233 (WPADBusPropertyAccessor
) wpas_dbus_getter_p2p_peers
,
2236 { "Role", WPAS_DBUS_NEW_IFACE_P2PDEVICE
, "s",
2237 (WPADBusPropertyAccessor
) wpas_dbus_getter_p2p_role
,
2240 { "Group", WPAS_DBUS_NEW_IFACE_P2PDEVICE
, "o",
2241 (WPADBusPropertyAccessor
) wpas_dbus_getter_p2p_group
,
2244 { "PeerGO", WPAS_DBUS_NEW_IFACE_P2PDEVICE
, "o",
2245 (WPADBusPropertyAccessor
) wpas_dbus_getter_p2p_peergo
,
2248 #endif /* CONFIG_P2P */
2249 { NULL
, NULL
, NULL
, NULL
, NULL
, 0 }
2252 static const struct wpa_dbus_signal_desc wpas_dbus_interface_signals
[] = {
2253 { "ScanDone", WPAS_DBUS_NEW_IFACE_INTERFACE
,
2255 { "success", "b", ARG_OUT
},
2259 { "BSSAdded", WPAS_DBUS_NEW_IFACE_INTERFACE
,
2261 { "path", "o", ARG_OUT
},
2262 { "properties", "a{sv}", ARG_OUT
},
2266 { "BSSRemoved", WPAS_DBUS_NEW_IFACE_INTERFACE
,
2268 { "path", "o", ARG_OUT
},
2272 { "BlobAdded", WPAS_DBUS_NEW_IFACE_INTERFACE
,
2274 { "name", "s", ARG_OUT
},
2278 { "BlobRemoved", WPAS_DBUS_NEW_IFACE_INTERFACE
,
2280 { "name", "s", ARG_OUT
},
2284 { "NetworkAdded", WPAS_DBUS_NEW_IFACE_INTERFACE
,
2286 { "path", "o", ARG_OUT
},
2287 { "properties", "a{sv}", ARG_OUT
},
2291 { "NetworkRemoved", WPAS_DBUS_NEW_IFACE_INTERFACE
,
2293 { "path", "o", ARG_OUT
},
2297 { "NetworkSelected", WPAS_DBUS_NEW_IFACE_INTERFACE
,
2299 { "path", "o", ARG_OUT
},
2303 { "PropertiesChanged", WPAS_DBUS_NEW_IFACE_INTERFACE
,
2305 { "properties", "a{sv}", ARG_OUT
},
2310 { "Event", WPAS_DBUS_NEW_IFACE_WPS
,
2312 { "name", "s", ARG_OUT
},
2313 { "args", "a{sv}", ARG_OUT
},
2317 { "Credentials", WPAS_DBUS_NEW_IFACE_WPS
,
2319 { "credentials", "a{sv}", ARG_OUT
},
2323 { "PropertiesChanged", WPAS_DBUS_NEW_IFACE_WPS
,
2325 { "properties", "a{sv}", ARG_OUT
},
2329 #endif /* CONFIG_WPS */
2331 { "P2PStateChanged", WPAS_DBUS_NEW_IFACE_P2PDEVICE
,
2333 { "states", "a{ss}", ARG_OUT
},
2337 { "DeviceFound", WPAS_DBUS_NEW_IFACE_P2PDEVICE
,
2339 { "path", "o", ARG_OUT
},
2340 { "properties", "a{sv}", ARG_OUT
},
2344 { "DeviceLost", WPAS_DBUS_NEW_IFACE_P2PDEVICE
,
2346 { "path", "o", ARG_OUT
},
2350 { "ProvisionDiscoveryRequestDisplayPin", WPAS_DBUS_NEW_IFACE_P2PDEVICE
,
2352 { "peer_object", "o", ARG_OUT
},
2353 { "pin", "s", ARG_OUT
},
2357 { "ProvisionDiscoveryResponseDisplayPin", WPAS_DBUS_NEW_IFACE_P2PDEVICE
,
2359 { "peer_object", "o", ARG_OUT
},
2360 { "pin", "s", ARG_OUT
},
2364 { "ProvisionDiscoveryRequestEnterPin", WPAS_DBUS_NEW_IFACE_P2PDEVICE
,
2366 { "peer_object", "o", ARG_OUT
},
2370 { "ProvisionDiscoveryResponseEnterPin", WPAS_DBUS_NEW_IFACE_P2PDEVICE
,
2372 { "peer_object", "o", ARG_OUT
},
2376 { "ProvisionDiscoveryPBCRequest", WPAS_DBUS_NEW_IFACE_P2PDEVICE
,
2378 { "peer_object", "o", ARG_OUT
},
2382 { "ProvisionDiscoveryPBCResponse", WPAS_DBUS_NEW_IFACE_P2PDEVICE
,
2384 { "peer_object", "o", ARG_OUT
},
2388 { "ProvisionDiscoveryFailure", WPAS_DBUS_NEW_IFACE_P2PDEVICE
,
2390 { "peer_object", "o", ARG_OUT
},
2391 { "status", "i", ARG_OUT
},
2395 { "GroupStarted", WPAS_DBUS_NEW_IFACE_P2PDEVICE
,
2397 { "properties", "a{sv}", ARG_OUT
},
2401 { "GONegotiationSuccess", WPAS_DBUS_NEW_IFACE_P2PDEVICE
,
2406 { "GONegotiationFailure", WPAS_DBUS_NEW_IFACE_P2PDEVICE
,
2408 { "status", "i", ARG_OUT
},
2412 { "GONegotiationRequest", WPAS_DBUS_NEW_IFACE_P2PDEVICE
,
2414 { "path", "o", ARG_OUT
},
2415 { "dev_passwd_id", "i", ARG_OUT
},
2419 { "InvitationResult", WPAS_DBUS_NEW_IFACE_P2PDEVICE
,
2421 { "invite_result", "a{sv}", ARG_OUT
},
2425 { "GroupFinished", WPAS_DBUS_NEW_IFACE_P2PDEVICE
,
2427 { "ifname", "s", ARG_OUT
},
2428 { "role", "s", ARG_OUT
},
2432 { "ServiceDiscoveryRequest", WPAS_DBUS_NEW_IFACE_P2PDEVICE
,
2434 { "sd_request", "a{sv}", ARG_OUT
},
2438 { "ServiceDiscoveryResponse", WPAS_DBUS_NEW_IFACE_P2PDEVICE
,
2440 { "sd_response", "a{sv}", ARG_OUT
},
2444 #endif /* CONFIG_P2P */
2445 { NULL
, NULL
, { END_ARGS
} }
2449 int wpas_dbus_register_interface(struct wpa_supplicant
*wpa_s
)
2452 struct wpa_dbus_object_desc
*obj_desc
= NULL
;
2453 struct wpas_dbus_priv
*ctrl_iface
= wpa_s
->global
->dbus
;
2456 /* Do nothing if the control interface is not turned on */
2457 if (ctrl_iface
== NULL
)
2460 /* Create and set the interface's object path */
2461 wpa_s
->dbus_new_path
= os_zalloc(WPAS_DBUS_OBJECT_PATH_MAX
);
2462 if (wpa_s
->dbus_new_path
== NULL
)
2464 next
= ctrl_iface
->next_objid
++;
2465 os_snprintf(wpa_s
->dbus_new_path
, WPAS_DBUS_OBJECT_PATH_MAX
,
2466 WPAS_DBUS_NEW_PATH_INTERFACES
"/%u",
2469 obj_desc
= os_zalloc(sizeof(struct wpa_dbus_object_desc
));
2471 wpa_printf(MSG_ERROR
, "Not enough memory "
2472 "to create object description");
2476 wpas_dbus_register(obj_desc
, wpa_s
, NULL
, wpas_dbus_interface_methods
,
2477 wpas_dbus_interface_properties
,
2478 wpas_dbus_interface_signals
);
2480 wpa_printf(MSG_DEBUG
, "dbus: Register interface object '%s'",
2481 wpa_s
->dbus_new_path
);
2482 if (wpa_dbus_register_object_per_iface(ctrl_iface
,
2483 wpa_s
->dbus_new_path
,
2484 wpa_s
->ifname
, obj_desc
))
2487 wpas_dbus_signal_interface_added(wpa_s
);
2492 os_free(wpa_s
->dbus_new_path
);
2493 wpa_s
->dbus_new_path
= NULL
;
2494 free_dbus_object_desc(obj_desc
);
2499 int wpas_dbus_unregister_interface(struct wpa_supplicant
*wpa_s
)
2501 struct wpas_dbus_priv
*ctrl_iface
;
2503 /* Do nothing if the control interface is not turned on */
2504 if (wpa_s
== NULL
|| wpa_s
->global
== NULL
)
2506 ctrl_iface
= wpa_s
->global
->dbus
;
2507 if (ctrl_iface
== NULL
)
2510 wpa_printf(MSG_DEBUG
, "dbus: Unregister interface object '%s'",
2511 wpa_s
->dbus_new_path
);
2512 if (wpa_dbus_unregister_object_per_iface(ctrl_iface
,
2513 wpa_s
->dbus_new_path
))
2516 wpas_dbus_signal_interface_removed(wpa_s
);
2518 os_free(wpa_s
->dbus_new_path
);
2519 wpa_s
->dbus_new_path
= NULL
;
2526 static const struct wpa_dbus_property_desc wpas_dbus_p2p_peer_properties
[] = {
2527 { "Properties", WPAS_DBUS_NEW_IFACE_P2P_PEER
, "a{sv}",
2528 (WPADBusPropertyAccessor
) wpas_dbus_getter_p2p_peer_properties
,
2531 { "IEs", WPAS_DBUS_NEW_IFACE_P2P_PEER
, "ay",
2532 (WPADBusPropertyAccessor
) wpas_dbus_getter_p2p_peer_ies
,
2535 { NULL
, NULL
, NULL
, NULL
, NULL
, 0 }
2538 static const struct wpa_dbus_signal_desc wpas_dbus_p2p_peer_signals
[] = {
2540 { NULL
, NULL
, { END_ARGS
} }
2544 * wpas_dbus_signal_peer - Send a peer related event signal
2545 * @wpa_s: %wpa_supplicant network interface data
2546 * @dev: peer device object
2547 * @interface: name of the interface emitting this signal.
2548 * In case of peer objects, it would be emitted by either
2549 * the "interface object" or by "peer objects"
2550 * @sig_name: signal name - DeviceFound
2552 * Notify listeners about event related with newly found p2p peer device
2554 static void wpas_dbus_signal_peer(struct wpa_supplicant
*wpa_s
,
2555 const u8
*dev_addr
, const char *interface
,
2556 const char *sig_name
)
2558 struct wpas_dbus_priv
*iface
;
2560 DBusMessageIter iter
;
2561 char peer_obj_path
[WPAS_DBUS_OBJECT_PATH_MAX
], *path
;
2563 iface
= wpa_s
->global
->dbus
;
2565 /* Do nothing if the control interface is not turned on */
2569 os_snprintf(peer_obj_path
, WPAS_DBUS_OBJECT_PATH_MAX
,
2570 "%s/" WPAS_DBUS_NEW_P2P_PEERS_PART
"/" COMPACT_MACSTR
,
2571 wpa_s
->dbus_new_path
, MAC2STR(dev_addr
));
2573 msg
= dbus_message_new_signal(wpa_s
->dbus_new_path
, interface
,
2578 dbus_message_iter_init_append(msg
, &iter
);
2579 path
= peer_obj_path
;
2580 if (!dbus_message_iter_append_basic(&iter
, DBUS_TYPE_OBJECT_PATH
,
2584 dbus_connection_send(iface
->con
, msg
, NULL
);
2586 dbus_message_unref(msg
);
2590 wpa_printf(MSG_ERROR
, "dbus: Failed to construct signal");
2591 dbus_message_unref(msg
);
2596 * wpas_dbus_signal_peer_found - Send a peer found signal
2597 * @wpa_s: %wpa_supplicant network interface data
2598 * @dev: peer device object
2600 * Notify listeners about find a p2p peer device found
2602 void wpas_dbus_signal_peer_device_found(struct wpa_supplicant
*wpa_s
,
2605 wpas_dbus_signal_peer(wpa_s
, dev_addr
,
2606 WPAS_DBUS_NEW_IFACE_P2PDEVICE
,
2611 * wpas_dbus_signal_peer_lost - Send a peer lost signal
2612 * @wpa_s: %wpa_supplicant network interface data
2613 * @dev: peer device object
2615 * Notify listeners about lost a p2p peer device
2617 void wpas_dbus_signal_peer_device_lost(struct wpa_supplicant
*wpa_s
,
2620 wpas_dbus_signal_peer(wpa_s
, dev_addr
,
2621 WPAS_DBUS_NEW_IFACE_P2PDEVICE
,
2626 * wpas_dbus_register_peer - Register a discovered peer object with dbus
2627 * @wpa_s: wpa_supplicant interface structure
2628 * @ssid: network configuration data
2629 * Returns: 0 on success, -1 on failure
2631 * Registers network representing object with dbus
2633 int wpas_dbus_register_peer(struct wpa_supplicant
*wpa_s
, const u8
*dev_addr
)
2635 struct wpas_dbus_priv
*ctrl_iface
;
2636 struct wpa_dbus_object_desc
*obj_desc
;
2637 struct peer_handler_args
*arg
;
2638 char peer_obj_path
[WPAS_DBUS_OBJECT_PATH_MAX
];
2640 /* Do nothing if the control interface is not turned on */
2641 if (wpa_s
== NULL
|| wpa_s
->global
== NULL
)
2644 ctrl_iface
= wpa_s
->global
->dbus
;
2645 if (ctrl_iface
== NULL
)
2648 os_snprintf(peer_obj_path
, WPAS_DBUS_OBJECT_PATH_MAX
,
2649 "%s/" WPAS_DBUS_NEW_P2P_PEERS_PART
"/" COMPACT_MACSTR
,
2650 wpa_s
->dbus_new_path
, MAC2STR(dev_addr
));
2652 wpa_printf(MSG_INFO
, "dbus: Register peer object '%s'",
2654 obj_desc
= os_zalloc(sizeof(struct wpa_dbus_object_desc
));
2656 wpa_printf(MSG_ERROR
, "Not enough memory "
2657 "to create object description");
2661 /* allocate memory for handlers arguments */
2662 arg
= os_zalloc(sizeof(struct peer_handler_args
));
2664 wpa_printf(MSG_ERROR
, "Not enough memory "
2665 "to create arguments for method");
2670 os_memcpy(arg
->p2p_device_addr
, dev_addr
, ETH_ALEN
);
2672 wpas_dbus_register(obj_desc
, arg
, wpa_dbus_free
,
2674 wpas_dbus_p2p_peer_properties
,
2675 wpas_dbus_p2p_peer_signals
);
2677 if (wpa_dbus_register_object_per_iface(ctrl_iface
, peer_obj_path
,
2678 wpa_s
->ifname
, obj_desc
))
2684 free_dbus_object_desc(obj_desc
);
2689 * wpas_dbus_unregister_peer - Unregister a peer object with dbus
2690 * @wpa_s: wpa_supplicant interface structure
2691 * @dev_addr: p2p device addr
2692 * Returns: 0 on success, -1 on failure
2694 * Registers network representing object with dbus
2696 int wpas_dbus_unregister_peer(struct wpa_supplicant
*wpa_s
,
2699 struct wpas_dbus_priv
*ctrl_iface
;
2700 char peer_obj_path
[WPAS_DBUS_OBJECT_PATH_MAX
];
2703 /* Do nothing if the control interface is not turned on */
2704 if (wpa_s
== NULL
|| wpa_s
->global
== NULL
||
2705 wpa_s
->dbus_new_path
== NULL
)
2707 ctrl_iface
= wpa_s
->global
->dbus
;
2708 if (ctrl_iface
== NULL
)
2711 os_snprintf(peer_obj_path
, WPAS_DBUS_OBJECT_PATH_MAX
,
2712 "%s/" WPAS_DBUS_NEW_P2P_PEERS_PART
"/" COMPACT_MACSTR
,
2713 wpa_s
->dbus_new_path
, MAC2STR(dev_addr
));
2715 wpa_printf(MSG_INFO
, "dbus: Unregister peer object '%s'",
2717 ret
= wpa_dbus_unregister_object_per_iface(ctrl_iface
, peer_obj_path
);
2723 static const struct wpa_dbus_property_desc wpas_dbus_p2p_group_properties
[] = {
2724 { "Members", WPAS_DBUS_NEW_IFACE_P2P_GROUP
, "ao",
2725 (WPADBusPropertyAccessor
) wpas_dbus_getter_p2p_group_members
,
2729 WPAS_DBUS_NEW_IFACE_P2P_GROUP
, "a{sv}",
2730 (WPADBusPropertyAccessor
) wpas_dbus_getter_p2p_group_properties
,
2731 (WPADBusPropertyAccessor
) wpas_dbus_setter_p2p_group_properties
,
2734 { NULL
, NULL
, NULL
, NULL
, NULL
, 0 }
2737 static const struct wpa_dbus_signal_desc wpas_dbus_p2p_group_signals
[] = {
2738 { "PeerJoined", WPAS_DBUS_NEW_IFACE_P2P_GROUP
,
2740 { "peer", "o", ARG_OUT
},
2744 { "PeerDisconnected", WPAS_DBUS_NEW_IFACE_P2P_GROUP
,
2746 { "peer", "o", ARG_OUT
},
2750 { NULL
, NULL
, { END_ARGS
} }
2754 * wpas_dbus_register_p2p_group - Register a p2p group object with dbus
2755 * @wpa_s: wpa_supplicant interface structure
2756 * @ssid: SSID struct
2757 * Returns: 0 on success, -1 on failure
2759 * Registers p2p group representing object with dbus
2761 void wpas_dbus_register_p2p_group(struct wpa_supplicant
*wpa_s
,
2762 struct wpa_ssid
*ssid
)
2764 struct wpas_dbus_priv
*ctrl_iface
;
2765 struct wpa_dbus_object_desc
*obj_desc
;
2766 char group_obj_path
[WPAS_DBUS_OBJECT_PATH_MAX
];
2768 /* Do nothing if the control interface is not turned on */
2769 if (wpa_s
== NULL
|| wpa_s
->global
== NULL
)
2772 ctrl_iface
= wpa_s
->global
->dbus
;
2773 if (ctrl_iface
== NULL
)
2776 if (wpa_s
->dbus_groupobj_path
) {
2777 wpa_printf(MSG_INFO
, "%s: Group object '%s' already exists",
2778 __func__
, wpa_s
->dbus_groupobj_path
);
2782 if (wpas_dbus_get_group_obj_path(wpa_s
, ssid
, group_obj_path
) < 0)
2785 wpa_s
->dbus_groupobj_path
= os_strdup(group_obj_path
);
2786 if (wpa_s
->dbus_groupobj_path
== NULL
)
2789 wpa_printf(MSG_INFO
, "dbus: Register group object '%s'",
2791 obj_desc
= os_zalloc(sizeof(struct wpa_dbus_object_desc
));
2793 wpa_printf(MSG_ERROR
, "Not enough memory "
2794 "to create object description");
2798 wpas_dbus_register(obj_desc
, wpa_s
, NULL
, NULL
,
2799 wpas_dbus_p2p_group_properties
,
2800 wpas_dbus_p2p_group_signals
);
2802 if (wpa_dbus_register_object_per_iface(ctrl_iface
, group_obj_path
,
2803 wpa_s
->ifname
, obj_desc
))
2809 if (wpa_s
->dbus_groupobj_path
) {
2810 os_free(wpa_s
->dbus_groupobj_path
);
2811 wpa_s
->dbus_groupobj_path
= NULL
;
2814 free_dbus_object_desc(obj_desc
);
2818 * wpas_dbus_unregister_p2p_group - Unregister a p2p group object from dbus
2819 * @wpa_s: wpa_supplicant interface structure
2820 * @ssid: network name of the p2p group started
2822 void wpas_dbus_unregister_p2p_group(struct wpa_supplicant
*wpa_s
,
2823 const struct wpa_ssid
*ssid
)
2825 struct wpas_dbus_priv
*ctrl_iface
;
2827 /* Do nothing if the control interface is not turned on */
2828 if (wpa_s
== NULL
|| wpa_s
->global
== NULL
)
2831 ctrl_iface
= wpa_s
->global
->dbus
;
2832 if (ctrl_iface
== NULL
)
2835 if (!wpa_s
->dbus_groupobj_path
) {
2836 wpa_printf(MSG_DEBUG
,
2837 "%s: Group object '%s' already unregistered",
2838 __func__
, wpa_s
->dbus_groupobj_path
);
2842 wpa_printf(MSG_DEBUG
, "dbus: Unregister group object '%s'",
2843 wpa_s
->dbus_groupobj_path
);
2845 wpa_dbus_unregister_object_per_iface(ctrl_iface
,
2846 wpa_s
->dbus_groupobj_path
);
2848 os_free(wpa_s
->dbus_groupobj_path
);
2849 wpa_s
->dbus_groupobj_path
= NULL
;
2852 static const struct wpa_dbus_property_desc
2853 wpas_dbus_p2p_groupmember_properties
[] = {
2854 { "Properties", WPAS_DBUS_NEW_IFACE_P2P_GROUPMEMBER
, "a{sv}",
2855 (WPADBusPropertyAccessor
) wpas_dbus_getter_p2p_group_properties
,
2858 { NULL
, NULL
, NULL
, NULL
, NULL
, 0 }
2862 * wpas_dbus_register_p2p_groupmember - Register a p2p groupmember
2864 * @wpa_s: wpa_supplicant interface structure
2865 * @p2p_if_addr: i/f addr of the device joining this group
2867 * Registers p2p groupmember representing object with dbus
2869 void wpas_dbus_register_p2p_groupmember(struct wpa_supplicant
*wpa_s
,
2870 const u8
*p2p_if_addr
)
2872 struct wpas_dbus_priv
*ctrl_iface
;
2873 struct wpa_dbus_object_desc
*obj_desc
= NULL
;
2874 struct groupmember_handler_args
*arg
;
2875 char groupmember_obj_path
[WPAS_DBUS_OBJECT_PATH_MAX
];
2877 /* Do nothing if the control interface is not turned on */
2878 if (wpa_s
== NULL
|| wpa_s
->global
== NULL
)
2881 ctrl_iface
= wpa_s
->global
->dbus
;
2882 if (ctrl_iface
== NULL
)
2885 if (!wpa_s
->dbus_groupobj_path
)
2888 os_snprintf(groupmember_obj_path
, WPAS_DBUS_OBJECT_PATH_MAX
,
2889 "%s/" WPAS_DBUS_NEW_P2P_GROUPMEMBERS_PART
"/" COMPACT_MACSTR
,
2890 wpa_s
->dbus_groupobj_path
, MAC2STR(p2p_if_addr
));
2892 obj_desc
= os_zalloc(sizeof(struct wpa_dbus_object_desc
));
2894 wpa_printf(MSG_ERROR
, "Not enough memory "
2895 "to create object description");
2899 /* allocate memory for handlers arguments */
2900 arg
= os_zalloc(sizeof(struct groupmember_handler_args
));
2902 wpa_printf(MSG_ERROR
, "Not enough memory "
2903 "to create arguments for method");
2908 os_memcpy(arg
->member_addr
, p2p_if_addr
, ETH_ALEN
);
2910 wpas_dbus_register(obj_desc
, arg
, wpa_dbus_free
, NULL
,
2911 wpas_dbus_p2p_groupmember_properties
, NULL
);
2913 if (wpa_dbus_register_object_per_iface(ctrl_iface
, groupmember_obj_path
,
2914 wpa_s
->ifname
, obj_desc
))
2917 wpa_printf(MSG_INFO
,
2918 "dbus: Registered group member object '%s' successfully",
2919 groupmember_obj_path
);
2923 free_dbus_object_desc(obj_desc
);
2927 * wpas_dbus_unregister_p2p_groupmember - Unregister a p2p groupmember
2929 * @wpa_s: wpa_supplicant interface structure
2930 * @p2p_if_addr: i/f addr of the device joining this group
2932 * Unregisters p2p groupmember representing object with dbus
2934 void wpas_dbus_unregister_p2p_groupmember(struct wpa_supplicant
*wpa_s
,
2935 const u8
*p2p_if_addr
)
2937 struct wpas_dbus_priv
*ctrl_iface
;
2938 char groupmember_obj_path
[WPAS_DBUS_OBJECT_PATH_MAX
];
2940 /* Do nothing if the control interface is not turned on */
2941 if (wpa_s
== NULL
|| wpa_s
->global
== NULL
)
2944 ctrl_iface
= wpa_s
->global
->dbus
;
2945 if (ctrl_iface
== NULL
)
2948 if (!wpa_s
->dbus_groupobj_path
)
2951 os_snprintf(groupmember_obj_path
, WPAS_DBUS_OBJECT_PATH_MAX
,
2952 "%s/" WPAS_DBUS_NEW_P2P_GROUPMEMBERS_PART
"/" COMPACT_MACSTR
,
2953 wpa_s
->dbus_groupobj_path
, MAC2STR(p2p_if_addr
));
2955 wpa_dbus_unregister_object_per_iface(ctrl_iface
, groupmember_obj_path
);
2957 #endif /* CONFIG_P2P */