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.
21 #include "../config.h"
22 #include "../wpa_supplicant_i.h"
24 #include "dbus_new_helpers.h"
25 #include "dbus_dict_helpers.h"
27 #include "dbus_new_handlers.h"
28 #include "dbus_common.h"
29 #include "dbus_common_i.h"
33 * wpas_dbus_signal_interface - Send a interface related event signal
34 * @wpa_s: %wpa_supplicant network interface data
35 * @sig_name: signal name - InterfaceAdded or InterfaceRemoved
36 * @properties: Whether to add second argument with object properties
38 * Notify listeners about event related with interface
40 static void wpas_dbus_signal_interface(struct wpa_supplicant
*wpa_s
,
41 const char *sig_name
, int properties
)
43 struct wpas_dbus_priv
*iface
;
45 DBusMessageIter iter
, iter_dict
;
47 iface
= wpa_s
->global
->dbus
;
49 /* Do nothing if the control interface is not turned on */
53 msg
= dbus_message_new_signal(WPAS_DBUS_NEW_PATH
,
54 WPAS_DBUS_NEW_INTERFACE
, sig_name
);
58 dbus_message_iter_init_append(msg
, &iter
);
59 if (!dbus_message_iter_append_basic(&iter
, DBUS_TYPE_OBJECT_PATH
,
60 &wpa_s
->dbus_new_path
))
64 if (!wpa_dbus_dict_open_write(&iter
, &iter_dict
))
67 wpa_dbus_get_object_properties(iface
, wpa_s
->dbus_new_path
,
68 WPAS_DBUS_NEW_IFACE_INTERFACE
,
71 if (!wpa_dbus_dict_close_write(&iter
, &iter_dict
))
75 dbus_connection_send(iface
->con
, msg
, NULL
);
76 dbus_message_unref(msg
);
80 wpa_printf(MSG_ERROR
, "dbus: Failed to construct signal");
81 dbus_message_unref(msg
);
86 * wpas_dbus_signal_interface_added - Send a interface created signal
87 * @wpa_s: %wpa_supplicant network interface data
89 * Notify listeners about creating new interface
91 static void wpas_dbus_signal_interface_added(struct wpa_supplicant
*wpa_s
)
93 wpas_dbus_signal_interface(wpa_s
, "InterfaceAdded", TRUE
);
98 * wpas_dbus_signal_interface_removed - Send a interface removed signal
99 * @wpa_s: %wpa_supplicant network interface data
101 * Notify listeners about removing interface
103 static void wpas_dbus_signal_interface_removed(struct wpa_supplicant
*wpa_s
)
105 wpas_dbus_signal_interface(wpa_s
, "InterfaceRemoved", FALSE
);
111 * wpas_dbus_signal_scan_done - send scan done signal
112 * @wpa_s: %wpa_supplicant network interface data
113 * @success: indicates if scanning succeed or failed
115 * Notify listeners about finishing a scan
117 void wpas_dbus_signal_scan_done(struct wpa_supplicant
*wpa_s
, int success
)
119 struct wpas_dbus_priv
*iface
;
123 iface
= wpa_s
->global
->dbus
;
125 /* Do nothing if the control interface is not turned on */
129 msg
= dbus_message_new_signal(wpa_s
->dbus_new_path
,
130 WPAS_DBUS_NEW_IFACE_INTERFACE
,
135 succ
= success
? TRUE
: FALSE
;
136 if (dbus_message_append_args(msg
, DBUS_TYPE_BOOLEAN
, &succ
,
138 dbus_connection_send(iface
->con
, msg
, NULL
);
140 wpa_printf(MSG_ERROR
, "dbus: Failed to construct signal");
141 dbus_message_unref(msg
);
146 * wpas_dbus_signal_blob - Send a BSS related event signal
147 * @wpa_s: %wpa_supplicant network interface data
148 * @bss_obj_path: BSS object path
149 * @sig_name: signal name - BSSAdded or BSSRemoved
150 * @properties: Whether to add second argument with object properties
152 * Notify listeners about event related with BSS
154 static void wpas_dbus_signal_bss(struct wpa_supplicant
*wpa_s
,
155 const char *bss_obj_path
,
156 const char *sig_name
, int properties
)
158 struct wpas_dbus_priv
*iface
;
160 DBusMessageIter iter
, iter_dict
;
162 iface
= wpa_s
->global
->dbus
;
164 /* Do nothing if the control interface is not turned on */
168 msg
= dbus_message_new_signal(wpa_s
->dbus_new_path
,
169 WPAS_DBUS_NEW_IFACE_INTERFACE
,
174 dbus_message_iter_init_append(msg
, &iter
);
175 if (!dbus_message_iter_append_basic(&iter
, DBUS_TYPE_OBJECT_PATH
,
180 if (!wpa_dbus_dict_open_write(&iter
, &iter_dict
))
183 wpa_dbus_get_object_properties(iface
, bss_obj_path
,
184 WPAS_DBUS_NEW_IFACE_BSS
,
187 if (!wpa_dbus_dict_close_write(&iter
, &iter_dict
))
191 dbus_connection_send(iface
->con
, msg
, NULL
);
192 dbus_message_unref(msg
);
196 wpa_printf(MSG_ERROR
, "dbus: Failed to construct signal");
197 dbus_message_unref(msg
);
202 * wpas_dbus_signal_bss_added - Send a BSS added signal
203 * @wpa_s: %wpa_supplicant network interface data
204 * @bss_obj_path: new BSS object path
206 * Notify listeners about adding new BSS
208 static void wpas_dbus_signal_bss_added(struct wpa_supplicant
*wpa_s
,
209 const char *bss_obj_path
)
211 wpas_dbus_signal_bss(wpa_s
, bss_obj_path
, "BSSAdded", TRUE
);
216 * wpas_dbus_signal_bss_removed - Send a BSS removed signal
217 * @wpa_s: %wpa_supplicant network interface data
218 * @bss_obj_path: BSS object path
220 * Notify listeners about removing BSS
222 static void wpas_dbus_signal_bss_removed(struct wpa_supplicant
*wpa_s
,
223 const char *bss_obj_path
)
225 wpas_dbus_signal_bss(wpa_s
, bss_obj_path
, "BSSRemoved", FALSE
);
230 * wpas_dbus_signal_blob - Send a blob related event signal
231 * @wpa_s: %wpa_supplicant network interface data
233 * @sig_name: signal name - BlobAdded or BlobRemoved
235 * Notify listeners about event related with blob
237 static void wpas_dbus_signal_blob(struct wpa_supplicant
*wpa_s
,
238 const char *name
, const char *sig_name
)
240 struct wpas_dbus_priv
*iface
;
243 iface
= wpa_s
->global
->dbus
;
245 /* Do nothing if the control interface is not turned on */
249 msg
= dbus_message_new_signal(wpa_s
->dbus_new_path
,
250 WPAS_DBUS_NEW_IFACE_INTERFACE
,
255 if (dbus_message_append_args(msg
, DBUS_TYPE_STRING
, &name
,
257 dbus_connection_send(iface
->con
, msg
, NULL
);
259 wpa_printf(MSG_ERROR
, "dbus: Failed to construct signal");
260 dbus_message_unref(msg
);
265 * wpas_dbus_signal_blob_added - Send a blob added signal
266 * @wpa_s: %wpa_supplicant network interface data
269 * Notify listeners about adding a new blob
271 void wpas_dbus_signal_blob_added(struct wpa_supplicant
*wpa_s
,
274 wpas_dbus_signal_blob(wpa_s
, name
, "BlobAdded");
279 * wpas_dbus_signal_blob_removed - Send a blob removed signal
280 * @wpa_s: %wpa_supplicant network interface data
283 * Notify listeners about removing blob
285 void wpas_dbus_signal_blob_removed(struct wpa_supplicant
*wpa_s
,
288 wpas_dbus_signal_blob(wpa_s
, name
, "BlobRemoved");
293 * wpas_dbus_signal_network - Send a network related event signal
294 * @wpa_s: %wpa_supplicant network interface data
295 * @id: new network id
296 * @sig_name: signal name - NetworkAdded, NetworkRemoved or NetworkSelected
297 * @properties: determines if add second argument with object properties
299 * Notify listeners about event related with configured network
301 static void wpas_dbus_signal_network(struct wpa_supplicant
*wpa_s
,
302 int id
, const char *sig_name
,
305 struct wpas_dbus_priv
*iface
;
307 DBusMessageIter iter
, iter_dict
;
308 char net_obj_path
[WPAS_DBUS_OBJECT_PATH_MAX
], *path
;
310 iface
= wpa_s
->global
->dbus
;
312 /* Do nothing if the control interface is not turned on */
316 os_snprintf(net_obj_path
, WPAS_DBUS_OBJECT_PATH_MAX
,
317 "%s/" WPAS_DBUS_NEW_NETWORKS_PART
"/%u",
318 wpa_s
->dbus_new_path
, id
);
320 msg
= dbus_message_new_signal(wpa_s
->dbus_new_path
,
321 WPAS_DBUS_NEW_IFACE_INTERFACE
,
326 dbus_message_iter_init_append(msg
, &iter
);
328 if (!dbus_message_iter_append_basic(&iter
, DBUS_TYPE_OBJECT_PATH
,
333 if (!wpa_dbus_dict_open_write(&iter
, &iter_dict
))
336 wpa_dbus_get_object_properties(iface
, net_obj_path
,
337 WPAS_DBUS_NEW_IFACE_NETWORK
,
340 if (!wpa_dbus_dict_close_write(&iter
, &iter_dict
))
344 dbus_connection_send(iface
->con
, msg
, NULL
);
346 dbus_message_unref(msg
);
350 wpa_printf(MSG_ERROR
, "dbus: Failed to construct signal");
351 dbus_message_unref(msg
);
356 * wpas_dbus_signal_network_added - Send a network added signal
357 * @wpa_s: %wpa_supplicant network interface data
358 * @id: new network id
360 * Notify listeners about adding new network
362 static void wpas_dbus_signal_network_added(struct wpa_supplicant
*wpa_s
,
365 wpas_dbus_signal_network(wpa_s
, id
, "NetworkAdded", TRUE
);
370 * wpas_dbus_signal_network_removed - Send a network removed signal
371 * @wpa_s: %wpa_supplicant network interface data
374 * Notify listeners about removing a network
376 static void wpas_dbus_signal_network_removed(struct wpa_supplicant
*wpa_s
,
379 wpas_dbus_signal_network(wpa_s
, id
, "NetworkRemoved", FALSE
);
384 * wpas_dbus_signal_network_selected - Send a network selected signal
385 * @wpa_s: %wpa_supplicant network interface data
388 * Notify listeners about selecting a network
390 void wpas_dbus_signal_network_selected(struct wpa_supplicant
*wpa_s
, int id
)
392 wpas_dbus_signal_network(wpa_s
, id
, "NetworkSelected", FALSE
);
397 * wpas_dbus_signal_network_enabled_changed - Signals Enabled property changes
398 * @wpa_s: %wpa_supplicant network interface data
399 * @ssid: configured network which Enabled property has changed
401 * Sends PropertyChanged signals containing new value of Enabled property
402 * for specified network
404 void wpas_dbus_signal_network_enabled_changed(struct wpa_supplicant
*wpa_s
,
405 struct wpa_ssid
*ssid
)
408 char path
[WPAS_DBUS_OBJECT_PATH_MAX
];
409 os_snprintf(path
, WPAS_DBUS_OBJECT_PATH_MAX
,
410 "%s/" WPAS_DBUS_NEW_NETWORKS_PART
"/%d",
411 wpa_s
->dbus_new_path
, ssid
->id
);
413 wpa_dbus_mark_property_changed(wpa_s
->global
->dbus
, path
,
414 WPAS_DBUS_NEW_IFACE_NETWORK
, "Enabled");
421 * wpas_dbus_signal_wps_event_success - Signals Success WPS event
422 * @wpa_s: %wpa_supplicant network interface data
424 * Sends Event dbus signal with name "success" and empty dict as arguments
426 void wpas_dbus_signal_wps_event_success(struct wpa_supplicant
*wpa_s
)
430 DBusMessageIter iter
, dict_iter
;
431 struct wpas_dbus_priv
*iface
;
432 char *key
= "success";
434 iface
= wpa_s
->global
->dbus
;
436 /* Do nothing if the control interface is not turned on */
440 msg
= dbus_message_new_signal(wpa_s
->dbus_new_path
,
441 WPAS_DBUS_NEW_IFACE_WPS
, "Event");
445 dbus_message_iter_init_append(msg
, &iter
);
447 if (!dbus_message_iter_append_basic(&iter
, DBUS_TYPE_STRING
, &key
) ||
448 !wpa_dbus_dict_open_write(&iter
, &dict_iter
) ||
449 !wpa_dbus_dict_close_write(&iter
, &dict_iter
))
450 wpa_printf(MSG_ERROR
, "dbus: Failed to construct signal");
452 dbus_connection_send(iface
->con
, msg
, NULL
);
454 dbus_message_unref(msg
);
459 * wpas_dbus_signal_wps_event_fail - Signals Fail WPS event
460 * @wpa_s: %wpa_supplicant network interface data
462 * Sends Event dbus signal with name "fail" and dictionary containing
463 * "msg field with fail message number (int32) as arguments
465 void wpas_dbus_signal_wps_event_fail(struct wpa_supplicant
*wpa_s
,
466 struct wps_event_fail
*fail
)
470 DBusMessageIter iter
, dict_iter
;
471 struct wpas_dbus_priv
*iface
;
474 iface
= wpa_s
->global
->dbus
;
476 /* Do nothing if the control interface is not turned on */
480 msg
= dbus_message_new_signal(wpa_s
->dbus_new_path
,
481 WPAS_DBUS_NEW_IFACE_WPS
, "Event");
485 dbus_message_iter_init_append(msg
, &iter
);
487 if (!dbus_message_iter_append_basic(&iter
, DBUS_TYPE_STRING
, &key
) ||
488 !wpa_dbus_dict_open_write(&iter
, &dict_iter
) ||
489 !wpa_dbus_dict_append_int32(&dict_iter
, "msg", fail
->msg
) ||
490 !wpa_dbus_dict_close_write(&iter
, &dict_iter
))
491 wpa_printf(MSG_ERROR
, "dbus: Failed to construct signal");
493 dbus_connection_send(iface
->con
, msg
, NULL
);
495 dbus_message_unref(msg
);
500 * wpas_dbus_signal_wps_event_m2d - Signals M2D WPS event
501 * @wpa_s: %wpa_supplicant network interface data
503 * Sends Event dbus signal with name "m2d" and dictionary containing
504 * fields of wps_event_m2d structure.
506 void wpas_dbus_signal_wps_event_m2d(struct wpa_supplicant
*wpa_s
,
507 struct wps_event_m2d
*m2d
)
511 DBusMessageIter iter
, dict_iter
;
512 struct wpas_dbus_priv
*iface
;
515 iface
= wpa_s
->global
->dbus
;
517 /* Do nothing if the control interface is not turned on */
521 msg
= dbus_message_new_signal(wpa_s
->dbus_new_path
,
522 WPAS_DBUS_NEW_IFACE_WPS
, "Event");
526 dbus_message_iter_init_append(msg
, &iter
);
528 if (!dbus_message_iter_append_basic(&iter
, DBUS_TYPE_STRING
, &key
) ||
529 !wpa_dbus_dict_open_write(&iter
, &dict_iter
) ||
530 !wpa_dbus_dict_append_uint16(&dict_iter
, "config_methods",
531 m2d
->config_methods
) ||
532 !wpa_dbus_dict_append_byte_array(&dict_iter
, "manufacturer",
533 (const char *) m2d
->manufacturer
,
534 m2d
->manufacturer_len
) ||
535 !wpa_dbus_dict_append_byte_array(&dict_iter
, "model_name",
536 (const char *) m2d
->model_name
,
537 m2d
->model_name_len
) ||
538 !wpa_dbus_dict_append_byte_array(&dict_iter
, "model_number",
539 (const char *) m2d
->model_number
,
540 m2d
->model_number_len
) ||
541 !wpa_dbus_dict_append_byte_array(&dict_iter
, "serial_number",
544 m2d
->serial_number_len
) ||
545 !wpa_dbus_dict_append_byte_array(&dict_iter
, "dev_name",
546 (const char *) m2d
->dev_name
,
547 m2d
->dev_name_len
) ||
548 !wpa_dbus_dict_append_byte_array(&dict_iter
, "primary_dev_type",
550 m2d
->primary_dev_type
, 8) ||
551 !wpa_dbus_dict_append_uint16(&dict_iter
, "config_error",
552 m2d
->config_error
) ||
553 !wpa_dbus_dict_append_uint16(&dict_iter
, "dev_password_id",
554 m2d
->dev_password_id
) ||
555 !wpa_dbus_dict_close_write(&iter
, &dict_iter
))
556 wpa_printf(MSG_ERROR
, "dbus: Failed to construct signal");
558 dbus_connection_send(iface
->con
, msg
, NULL
);
560 dbus_message_unref(msg
);
565 * wpas_dbus_signal_wps_cred - Signals new credentials
566 * @wpa_s: %wpa_supplicant network interface data
568 * Sends signal with credentials in directory argument
570 void wpas_dbus_signal_wps_cred(struct wpa_supplicant
*wpa_s
,
571 const struct wps_credential
*cred
)
574 DBusMessageIter iter
, dict_iter
;
575 struct wpas_dbus_priv
*iface
;
576 char *auth_type
[6]; /* we have six possible authorization types */
578 char *encr_type
[4]; /* we have four possible encryption types */
581 iface
= wpa_s
->global
->dbus
;
583 /* Do nothing if the control interface is not turned on */
587 msg
= dbus_message_new_signal(wpa_s
->dbus_new_path
,
588 WPAS_DBUS_NEW_IFACE_WPS
,
593 dbus_message_iter_init_append(msg
, &iter
);
594 if (!wpa_dbus_dict_open_write(&iter
, &dict_iter
))
597 if (cred
->auth_type
& WPS_AUTH_OPEN
)
598 auth_type
[at_num
++] = "open";
599 if (cred
->auth_type
& WPS_AUTH_WPAPSK
)
600 auth_type
[at_num
++] = "wpa-psk";
601 if (cred
->auth_type
& WPS_AUTH_SHARED
)
602 auth_type
[at_num
++] = "shared";
603 if (cred
->auth_type
& WPS_AUTH_WPA
)
604 auth_type
[at_num
++] = "wpa-eap";
605 if (cred
->auth_type
& WPS_AUTH_WPA2
)
606 auth_type
[at_num
++] = "wpa2-eap";
607 if (cred
->auth_type
& WPS_AUTH_WPA2PSK
)
608 auth_type
[at_num
++] =
611 if (cred
->encr_type
& WPS_ENCR_NONE
)
612 encr_type
[et_num
++] = "none";
613 if (cred
->encr_type
& WPS_ENCR_WEP
)
614 encr_type
[et_num
++] = "wep";
615 if (cred
->encr_type
& WPS_ENCR_TKIP
)
616 encr_type
[et_num
++] = "tkip";
617 if (cred
->encr_type
& WPS_ENCR_AES
)
618 encr_type
[et_num
++] = "aes";
620 if (wpa_s
->current_ssid
) {
621 if (!wpa_dbus_dict_append_byte_array(
623 (const char *) wpa_s
->current_ssid
->bssid
,
628 if (!wpa_dbus_dict_append_byte_array(&dict_iter
, "SSID",
629 (const char *) cred
->ssid
,
631 !wpa_dbus_dict_append_string_array(&dict_iter
, "AuthType",
632 (const char **) auth_type
,
634 !wpa_dbus_dict_append_string_array(&dict_iter
, "EncrType",
635 (const char **) encr_type
,
637 !wpa_dbus_dict_append_byte_array(&dict_iter
, "Key",
638 (const char *) cred
->key
,
640 !wpa_dbus_dict_append_uint32(&dict_iter
, "KeyIndex",
642 !wpa_dbus_dict_close_write(&iter
, &dict_iter
))
645 dbus_connection_send(iface
->con
, msg
, NULL
);
648 dbus_message_unref(msg
);
651 #endif /* CONFIG_WPS */
655 * wpas_dbus_signal_prop_changed - Signals change of property
656 * @wpa_s: %wpa_supplicant network interface data
657 * @property: indicates which property has changed
659 * Sends ProertyChanged signals with path, interface and arguments
660 * depending on which property has changed.
662 void wpas_dbus_signal_prop_changed(struct wpa_supplicant
*wpa_s
,
663 enum wpas_dbus_prop property
)
665 WPADBusPropertyAccessor getter
;
668 if (wpa_s
->dbus_new_path
== NULL
)
669 return; /* Skip signal since D-Bus setup is not yet ready */
672 case WPAS_DBUS_PROP_AP_SCAN
:
673 getter
= (WPADBusPropertyAccessor
) wpas_dbus_getter_ap_scan
;
676 case WPAS_DBUS_PROP_SCANNING
:
677 getter
= (WPADBusPropertyAccessor
) wpas_dbus_getter_scanning
;
680 case WPAS_DBUS_PROP_STATE
:
681 getter
= (WPADBusPropertyAccessor
) wpas_dbus_getter_state
;
684 case WPAS_DBUS_PROP_CURRENT_BSS
:
685 getter
= (WPADBusPropertyAccessor
)
686 wpas_dbus_getter_current_bss
;
689 case WPAS_DBUS_PROP_CURRENT_NETWORK
:
690 getter
= (WPADBusPropertyAccessor
)
691 wpas_dbus_getter_current_network
;
692 prop
= "CurrentNetwork";
695 wpa_printf(MSG_ERROR
, "dbus: %s: Unknown Property value %d",
700 wpa_dbus_mark_property_changed(wpa_s
->global
->dbus
,
701 wpa_s
->dbus_new_path
,
702 WPAS_DBUS_NEW_IFACE_INTERFACE
, prop
);
707 * wpas_dbus_bss_signal_prop_changed - Signals change of BSS property
708 * @wpa_s: %wpa_supplicant network interface data
709 * @property: indicates which property has changed
710 * @id: unique BSS identifier
712 * Sends PropertyChanged signals with path, interface, and arguments depending
713 * on which property has changed.
715 void wpas_dbus_bss_signal_prop_changed(struct wpa_supplicant
*wpa_s
,
716 enum wpas_dbus_bss_prop property
,
719 char path
[WPAS_DBUS_OBJECT_PATH_MAX
];
723 case WPAS_DBUS_BSS_PROP_SIGNAL
:
726 case WPAS_DBUS_BSS_PROP_FREQ
:
729 case WPAS_DBUS_BSS_PROP_MODE
:
732 case WPAS_DBUS_BSS_PROP_PRIVACY
:
735 case WPAS_DBUS_BSS_PROP_RATES
:
738 case WPAS_DBUS_BSS_PROP_WPA
:
741 case WPAS_DBUS_BSS_PROP_RSN
:
744 case WPAS_DBUS_BSS_PROP_IES
:
748 wpa_printf(MSG_ERROR
, "dbus: %s: Unknown Property value %d",
753 os_snprintf(path
, WPAS_DBUS_OBJECT_PATH_MAX
,
754 "%s/" WPAS_DBUS_NEW_BSSIDS_PART
"/%u",
755 wpa_s
->dbus_new_path
, id
);
757 wpa_dbus_mark_property_changed(wpa_s
->global
->dbus
, path
,
758 WPAS_DBUS_NEW_IFACE_BSS
, prop
);
763 * wpas_dbus_signal_debug_level_changed - Signals change of debug param
764 * @global: wpa_global structure
766 * Sends ProertyChanged signals informing that debug level has changed.
768 void wpas_dbus_signal_debug_level_changed(struct wpa_global
*global
)
770 wpa_dbus_mark_property_changed(global
->dbus
, WPAS_DBUS_NEW_PATH
,
771 WPAS_DBUS_NEW_INTERFACE
,
777 * wpas_dbus_signal_debug_timestamp_changed - Signals change of debug param
778 * @global: wpa_global structure
780 * Sends ProertyChanged signals informing that debug timestamp has changed.
782 void wpas_dbus_signal_debug_timestamp_changed(struct wpa_global
*global
)
784 wpa_dbus_mark_property_changed(global
->dbus
, WPAS_DBUS_NEW_PATH
,
785 WPAS_DBUS_NEW_INTERFACE
,
791 * wpas_dbus_signal_debug_show_keys_changed - Signals change of debug param
792 * @global: wpa_global structure
794 * Sends ProertyChanged signals informing that debug show_keys has changed.
796 void wpas_dbus_signal_debug_show_keys_changed(struct wpa_global
*global
)
798 wpa_dbus_mark_property_changed(global
->dbus
, WPAS_DBUS_NEW_PATH
,
799 WPAS_DBUS_NEW_INTERFACE
,
804 static void wpas_dbus_register(struct wpa_dbus_object_desc
*obj_desc
,
806 WPADBusArgumentFreeFunction priv_free
,
807 const struct wpa_dbus_method_desc
*methods
,
808 const struct wpa_dbus_property_desc
*properties
,
809 const struct wpa_dbus_signal_desc
*signals
)
813 obj_desc
->user_data
= priv
;
814 obj_desc
->user_data_free_func
= priv_free
;
815 obj_desc
->methods
= methods
;
816 obj_desc
->properties
= properties
;
817 obj_desc
->signals
= signals
;
819 for (n
= 0; properties
&& properties
->dbus_property
; properties
++)
822 obj_desc
->prop_changed_flags
= os_zalloc(n
);
823 if (!obj_desc
->prop_changed_flags
)
824 wpa_printf(MSG_DEBUG
, "dbus: %s: can't register handlers",
829 static const struct wpa_dbus_method_desc wpas_dbus_global_methods
[] = {
830 { "CreateInterface", WPAS_DBUS_NEW_INTERFACE
,
831 (WPADBusMethodHandler
) &wpas_dbus_handler_create_interface
,
833 { "args", "a{sv}", ARG_IN
},
834 { "path", "o", ARG_OUT
},
838 { "RemoveInterface", WPAS_DBUS_NEW_INTERFACE
,
839 (WPADBusMethodHandler
) &wpas_dbus_handler_remove_interface
,
841 { "path", "o", ARG_IN
},
845 { "GetInterface", WPAS_DBUS_NEW_INTERFACE
,
846 (WPADBusMethodHandler
) &wpas_dbus_handler_get_interface
,
848 { "ifname", "s", ARG_IN
},
849 { "path", "o", ARG_OUT
},
853 { NULL
, NULL
, NULL
, { END_ARGS
} }
856 static const struct wpa_dbus_property_desc wpas_dbus_global_properties
[] = {
857 { "DebugLevel", WPAS_DBUS_NEW_INTERFACE
, "s",
858 (WPADBusPropertyAccessor
) wpas_dbus_getter_debug_level
,
859 (WPADBusPropertyAccessor
) wpas_dbus_setter_debug_level
,
862 { "DebugTimestamp", WPAS_DBUS_NEW_INTERFACE
, "b",
863 (WPADBusPropertyAccessor
) wpas_dbus_getter_debug_timestamp
,
864 (WPADBusPropertyAccessor
) wpas_dbus_setter_debug_timestamp
,
867 { "DebugShowKeys", WPAS_DBUS_NEW_INTERFACE
, "b",
868 (WPADBusPropertyAccessor
) wpas_dbus_getter_debug_show_keys
,
869 (WPADBusPropertyAccessor
) wpas_dbus_setter_debug_show_keys
,
872 { "Interfaces", WPAS_DBUS_NEW_INTERFACE
, "ao",
873 (WPADBusPropertyAccessor
) &wpas_dbus_getter_interfaces
,
877 { "EapMethods", WPAS_DBUS_NEW_INTERFACE
, "as",
878 (WPADBusPropertyAccessor
) wpas_dbus_getter_eap_methods
,
882 { NULL
, NULL
, NULL
, NULL
, NULL
, 0 }
885 static const struct wpa_dbus_signal_desc wpas_dbus_global_signals
[] = {
886 { "InterfaceAdded", WPAS_DBUS_NEW_INTERFACE
,
888 { "path", "o", ARG_OUT
},
889 { "properties", "a{sv}", ARG_OUT
},
893 { "InterfaceRemoved", WPAS_DBUS_NEW_INTERFACE
,
895 { "path", "o", ARG_OUT
},
899 { "PropertiesChanged", WPAS_DBUS_NEW_INTERFACE
,
901 { "properties", "a{sv}", ARG_OUT
},
905 { NULL
, NULL
, { END_ARGS
} }
910 * wpas_dbus_ctrl_iface_init - Initialize dbus control interface
911 * @global: Pointer to global data from wpa_supplicant_init()
912 * Returns: 0 on success or -1 on failure
914 * Initialize the dbus control interface for wpa_supplicantand and start
915 * receiving commands from external programs over the bus.
917 int wpas_dbus_ctrl_iface_init(struct wpas_dbus_priv
*priv
)
919 struct wpa_dbus_object_desc
*obj_desc
;
922 obj_desc
= os_zalloc(sizeof(struct wpa_dbus_object_desc
));
924 wpa_printf(MSG_ERROR
, "Not enough memory "
925 "to create object description");
929 wpas_dbus_register(obj_desc
, priv
->global
, NULL
,
930 wpas_dbus_global_methods
,
931 wpas_dbus_global_properties
,
932 wpas_dbus_global_signals
);
934 wpa_printf(MSG_DEBUG
, "dbus: Register D-Bus object '%s'",
936 ret
= wpa_dbus_ctrl_iface_init(priv
, WPAS_DBUS_NEW_PATH
,
937 WPAS_DBUS_NEW_SERVICE
,
940 free_dbus_object_desc(obj_desc
);
942 priv
->dbus_new_initialized
= 1;
949 * wpas_dbus_ctrl_iface_deinit - Deinitialize dbus ctrl interface for
951 * @iface: Pointer to dbus private data from wpas_dbus_init()
953 * Deinitialize the dbus control interface that was initialized with
954 * wpas_dbus_ctrl_iface_init().
956 void wpas_dbus_ctrl_iface_deinit(struct wpas_dbus_priv
*iface
)
958 if (!iface
->dbus_new_initialized
)
960 wpa_printf(MSG_DEBUG
, "dbus: Unregister D-Bus object '%s'",
962 dbus_connection_unregister_object_path(iface
->con
,
967 static void wpa_dbus_free(void *ptr
)
973 static const struct wpa_dbus_property_desc wpas_dbus_network_properties
[] = {
974 { "Properties", WPAS_DBUS_NEW_IFACE_NETWORK
, "a{sv}",
975 (WPADBusPropertyAccessor
) wpas_dbus_getter_network_properties
,
976 (WPADBusPropertyAccessor
) wpas_dbus_setter_network_properties
,
979 { "Enabled", WPAS_DBUS_NEW_IFACE_NETWORK
, "b",
980 (WPADBusPropertyAccessor
) wpas_dbus_getter_enabled
,
981 (WPADBusPropertyAccessor
) wpas_dbus_setter_enabled
,
984 { NULL
, NULL
, NULL
, NULL
, NULL
, 0 }
988 static const struct wpa_dbus_signal_desc wpas_dbus_network_signals
[] = {
989 { "PropertiesChanged", WPAS_DBUS_NEW_IFACE_NETWORK
,
991 { "properties", "a{sv}", ARG_OUT
},
995 { NULL
, NULL
, { END_ARGS
} }
1000 * wpas_dbus_register_network - Register a configured network with dbus
1001 * @wpa_s: wpa_supplicant interface structure
1002 * @ssid: network configuration data
1003 * Returns: 0 on success, -1 on failure
1005 * Registers network representing object with dbus
1007 int wpas_dbus_register_network(struct wpa_supplicant
*wpa_s
,
1008 struct wpa_ssid
*ssid
)
1010 struct wpas_dbus_priv
*ctrl_iface
;
1011 struct wpa_dbus_object_desc
*obj_desc
;
1012 struct network_handler_args
*arg
;
1013 char net_obj_path
[WPAS_DBUS_OBJECT_PATH_MAX
];
1015 /* Do nothing if the control interface is not turned on */
1016 if (wpa_s
== NULL
|| wpa_s
->global
== NULL
)
1018 ctrl_iface
= wpa_s
->global
->dbus
;
1019 if (ctrl_iface
== NULL
)
1022 os_snprintf(net_obj_path
, WPAS_DBUS_OBJECT_PATH_MAX
,
1023 "%s/" WPAS_DBUS_NEW_NETWORKS_PART
"/%u",
1024 wpa_s
->dbus_new_path
, ssid
->id
);
1026 wpa_printf(MSG_DEBUG
, "dbus: Register network object '%s'",
1028 obj_desc
= os_zalloc(sizeof(struct wpa_dbus_object_desc
));
1030 wpa_printf(MSG_ERROR
, "Not enough memory "
1031 "to create object description");
1035 /* allocate memory for handlers arguments */
1036 arg
= os_zalloc(sizeof(struct network_handler_args
));
1038 wpa_printf(MSG_ERROR
, "Not enough memory "
1039 "to create arguments for method");
1046 wpas_dbus_register(obj_desc
, arg
, wpa_dbus_free
, NULL
,
1047 wpas_dbus_network_properties
,
1048 wpas_dbus_network_signals
);
1050 if (wpa_dbus_register_object_per_iface(ctrl_iface
, net_obj_path
,
1051 wpa_s
->ifname
, obj_desc
))
1054 wpas_dbus_signal_network_added(wpa_s
, ssid
->id
);
1059 free_dbus_object_desc(obj_desc
);
1065 * wpas_dbus_unregister_network - Unregister a configured network from dbus
1066 * @wpa_s: wpa_supplicant interface structure
1068 * Returns: 0 on success, -1 on failure
1070 * Unregisters network representing object from dbus
1072 int wpas_dbus_unregister_network(struct wpa_supplicant
*wpa_s
, int nid
)
1074 struct wpas_dbus_priv
*ctrl_iface
;
1075 char net_obj_path
[WPAS_DBUS_OBJECT_PATH_MAX
];
1078 /* Do nothing if the control interface is not turned on */
1079 if (wpa_s
== NULL
|| wpa_s
->global
== NULL
||
1080 wpa_s
->dbus_new_path
== NULL
)
1082 ctrl_iface
= wpa_s
->global
->dbus
;
1083 if (ctrl_iface
== NULL
)
1086 os_snprintf(net_obj_path
, WPAS_DBUS_OBJECT_PATH_MAX
,
1087 "%s/" WPAS_DBUS_NEW_NETWORKS_PART
"/%u",
1088 wpa_s
->dbus_new_path
, nid
);
1090 wpa_printf(MSG_DEBUG
, "dbus: Unregister network object '%s'",
1092 ret
= wpa_dbus_unregister_object_per_iface(ctrl_iface
, net_obj_path
);
1095 wpas_dbus_signal_network_removed(wpa_s
, nid
);
1101 static const struct wpa_dbus_property_desc wpas_dbus_bss_properties
[] = {
1102 { "SSID", WPAS_DBUS_NEW_IFACE_BSS
, "ay",
1103 (WPADBusPropertyAccessor
) wpas_dbus_getter_bss_ssid
,
1107 { "BSSID", WPAS_DBUS_NEW_IFACE_BSS
, "ay",
1108 (WPADBusPropertyAccessor
) wpas_dbus_getter_bss_bssid
,
1112 { "Privacy", WPAS_DBUS_NEW_IFACE_BSS
, "b",
1113 (WPADBusPropertyAccessor
) wpas_dbus_getter_bss_privacy
,
1117 { "Mode", WPAS_DBUS_NEW_IFACE_BSS
, "s",
1118 (WPADBusPropertyAccessor
) wpas_dbus_getter_bss_mode
,
1122 { "Signal", WPAS_DBUS_NEW_IFACE_BSS
, "n",
1123 (WPADBusPropertyAccessor
) wpas_dbus_getter_bss_signal
,
1127 { "Frequency", WPAS_DBUS_NEW_IFACE_BSS
, "q",
1128 (WPADBusPropertyAccessor
) wpas_dbus_getter_bss_frequency
,
1132 { "Rates", WPAS_DBUS_NEW_IFACE_BSS
, "au",
1133 (WPADBusPropertyAccessor
) wpas_dbus_getter_bss_rates
,
1137 { "WPA", WPAS_DBUS_NEW_IFACE_BSS
, "a{sv}",
1138 (WPADBusPropertyAccessor
) wpas_dbus_getter_bss_wpa
,
1142 { "RSN", WPAS_DBUS_NEW_IFACE_BSS
, "a{sv}",
1143 (WPADBusPropertyAccessor
) wpas_dbus_getter_bss_rsn
,
1147 { "IEs", WPAS_DBUS_NEW_IFACE_BSS
, "ay",
1148 (WPADBusPropertyAccessor
) wpas_dbus_getter_bss_ies
,
1152 { NULL
, NULL
, NULL
, NULL
, NULL
, 0 }
1156 static const struct wpa_dbus_signal_desc wpas_dbus_bss_signals
[] = {
1157 { "PropertiesChanged", WPAS_DBUS_NEW_IFACE_BSS
,
1159 { "properties", "a{sv}", ARG_OUT
},
1163 { NULL
, NULL
, { END_ARGS
} }
1168 * wpas_dbus_unregister_bss - Unregister a scanned BSS from dbus
1169 * @wpa_s: wpa_supplicant interface structure
1170 * @bssid: scanned network bssid
1171 * @id: unique BSS identifier
1172 * Returns: 0 on success, -1 on failure
1174 * Unregisters BSS representing object from dbus
1176 int wpas_dbus_unregister_bss(struct wpa_supplicant
*wpa_s
,
1177 u8 bssid
[ETH_ALEN
], unsigned int id
)
1179 struct wpas_dbus_priv
*ctrl_iface
;
1180 char bss_obj_path
[WPAS_DBUS_OBJECT_PATH_MAX
];
1182 /* Do nothing if the control interface is not turned on */
1183 if (wpa_s
== NULL
|| wpa_s
->global
== NULL
)
1185 ctrl_iface
= wpa_s
->global
->dbus
;
1186 if (ctrl_iface
== NULL
)
1189 os_snprintf(bss_obj_path
, WPAS_DBUS_OBJECT_PATH_MAX
,
1190 "%s/" WPAS_DBUS_NEW_BSSIDS_PART
"/%u",
1191 wpa_s
->dbus_new_path
, id
);
1193 wpa_printf(MSG_DEBUG
, "dbus: Unregister BSS object '%s'",
1195 if (wpa_dbus_unregister_object_per_iface(ctrl_iface
, bss_obj_path
)) {
1196 wpa_printf(MSG_ERROR
, "dbus: Cannot unregister BSS object %s",
1201 wpas_dbus_signal_bss_removed(wpa_s
, bss_obj_path
);
1208 * wpas_dbus_register_bss - Register a scanned BSS with dbus
1209 * @wpa_s: wpa_supplicant interface structure
1210 * @bssid: scanned network bssid
1211 * @id: unique BSS identifier
1212 * Returns: 0 on success, -1 on failure
1214 * Registers BSS representing object with dbus
1216 int wpas_dbus_register_bss(struct wpa_supplicant
*wpa_s
,
1217 u8 bssid
[ETH_ALEN
], unsigned int id
)
1219 struct wpas_dbus_priv
*ctrl_iface
;
1220 struct wpa_dbus_object_desc
*obj_desc
;
1221 char bss_obj_path
[WPAS_DBUS_OBJECT_PATH_MAX
];
1222 struct bss_handler_args
*arg
;
1224 /* Do nothing if the control interface is not turned on */
1225 if (wpa_s
== NULL
|| wpa_s
->global
== NULL
)
1227 ctrl_iface
= wpa_s
->global
->dbus
;
1228 if (ctrl_iface
== NULL
)
1231 os_snprintf(bss_obj_path
, WPAS_DBUS_OBJECT_PATH_MAX
,
1232 "%s/" WPAS_DBUS_NEW_BSSIDS_PART
"/%u",
1233 wpa_s
->dbus_new_path
, id
);
1235 obj_desc
= os_zalloc(sizeof(struct wpa_dbus_object_desc
));
1237 wpa_printf(MSG_ERROR
, "Not enough memory "
1238 "to create object description");
1242 arg
= os_zalloc(sizeof(struct bss_handler_args
));
1244 wpa_printf(MSG_ERROR
, "Not enough memory "
1245 "to create arguments for handler");
1251 wpas_dbus_register(obj_desc
, arg
, wpa_dbus_free
, NULL
,
1252 wpas_dbus_bss_properties
,
1253 wpas_dbus_bss_signals
);
1255 wpa_printf(MSG_DEBUG
, "dbus: Register BSS object '%s'",
1257 if (wpa_dbus_register_object_per_iface(ctrl_iface
, bss_obj_path
,
1258 wpa_s
->ifname
, obj_desc
)) {
1259 wpa_printf(MSG_ERROR
,
1260 "Cannot register BSSID dbus object %s.",
1265 wpas_dbus_signal_bss_added(wpa_s
, bss_obj_path
);
1270 free_dbus_object_desc(obj_desc
);
1275 static const struct wpa_dbus_method_desc wpas_dbus_interface_methods
[] = {
1276 { "Scan", WPAS_DBUS_NEW_IFACE_INTERFACE
,
1277 (WPADBusMethodHandler
) &wpas_dbus_handler_scan
,
1279 { "args", "a{sv}", ARG_IN
},
1283 { "Disconnect", WPAS_DBUS_NEW_IFACE_INTERFACE
,
1284 (WPADBusMethodHandler
) &wpas_dbus_handler_disconnect
,
1289 { "AddNetwork", WPAS_DBUS_NEW_IFACE_INTERFACE
,
1290 (WPADBusMethodHandler
) &wpas_dbus_handler_add_network
,
1292 { "args", "a{sv}", ARG_IN
},
1293 { "path", "o", ARG_OUT
},
1297 { "RemoveNetwork", WPAS_DBUS_NEW_IFACE_INTERFACE
,
1298 (WPADBusMethodHandler
) &wpas_dbus_handler_remove_network
,
1300 { "path", "o", ARG_IN
},
1304 { "SelectNetwork", WPAS_DBUS_NEW_IFACE_INTERFACE
,
1305 (WPADBusMethodHandler
) &wpas_dbus_handler_select_network
,
1307 { "path", "o", ARG_IN
},
1311 { "AddBlob", WPAS_DBUS_NEW_IFACE_INTERFACE
,
1312 (WPADBusMethodHandler
) &wpas_dbus_handler_add_blob
,
1314 { "name", "s", ARG_IN
},
1315 { "data", "ay", ARG_IN
},
1319 { "GetBlob", WPAS_DBUS_NEW_IFACE_INTERFACE
,
1320 (WPADBusMethodHandler
) &wpas_dbus_handler_get_blob
,
1322 { "name", "s", ARG_IN
},
1323 { "data", "ay", ARG_OUT
},
1327 { "RemoveBlob", WPAS_DBUS_NEW_IFACE_INTERFACE
,
1328 (WPADBusMethodHandler
) &wpas_dbus_handler_remove_blob
,
1330 { "name", "s", ARG_IN
},
1335 { "Start", WPAS_DBUS_NEW_IFACE_WPS
,
1336 (WPADBusMethodHandler
) &wpas_dbus_handler_wps_start
,
1338 { "args", "a{sv}", ARG_IN
},
1339 { "output", "a{sv}", ARG_OUT
},
1343 #endif /* CONFIG_WPS */
1344 { NULL
, NULL
, NULL
, { END_ARGS
} }
1347 static const struct wpa_dbus_property_desc wpas_dbus_interface_properties
[] = {
1348 { "Capabilities", WPAS_DBUS_NEW_IFACE_INTERFACE
, "a{sv}",
1349 (WPADBusPropertyAccessor
) wpas_dbus_getter_capabilities
,
1352 { "State", WPAS_DBUS_NEW_IFACE_INTERFACE
, "s",
1353 (WPADBusPropertyAccessor
) wpas_dbus_getter_state
,
1356 { "Scanning", WPAS_DBUS_NEW_IFACE_INTERFACE
, "b",
1357 (WPADBusPropertyAccessor
) wpas_dbus_getter_scanning
,
1360 { "ApScan", WPAS_DBUS_NEW_IFACE_INTERFACE
, "u",
1361 (WPADBusPropertyAccessor
) wpas_dbus_getter_ap_scan
,
1362 (WPADBusPropertyAccessor
) wpas_dbus_setter_ap_scan
,
1365 { "Ifname", WPAS_DBUS_NEW_IFACE_INTERFACE
, "s",
1366 (WPADBusPropertyAccessor
) wpas_dbus_getter_ifname
,
1369 { "Driver", WPAS_DBUS_NEW_IFACE_INTERFACE
, "s",
1370 (WPADBusPropertyAccessor
) wpas_dbus_getter_driver
,
1373 { "BridgeIfname", WPAS_DBUS_NEW_IFACE_INTERFACE
, "s",
1374 (WPADBusPropertyAccessor
) wpas_dbus_getter_bridge_ifname
,
1377 { "CurrentBSS", WPAS_DBUS_NEW_IFACE_INTERFACE
, "o",
1378 (WPADBusPropertyAccessor
) wpas_dbus_getter_current_bss
,
1381 { "CurrentNetwork", WPAS_DBUS_NEW_IFACE_INTERFACE
, "o",
1382 (WPADBusPropertyAccessor
) wpas_dbus_getter_current_network
,
1385 { "Blobs", WPAS_DBUS_NEW_IFACE_INTERFACE
, "a{say}",
1386 (WPADBusPropertyAccessor
) wpas_dbus_getter_blobs
,
1389 { "BSSs", WPAS_DBUS_NEW_IFACE_INTERFACE
, "ao",
1390 (WPADBusPropertyAccessor
) wpas_dbus_getter_bsss
,
1393 { "Networks", WPAS_DBUS_NEW_IFACE_INTERFACE
, "ao",
1394 (WPADBusPropertyAccessor
) wpas_dbus_getter_networks
,
1398 { "ProcessCredentials", WPAS_DBUS_NEW_IFACE_WPS
, "b",
1399 (WPADBusPropertyAccessor
) wpas_dbus_getter_process_credentials
,
1400 (WPADBusPropertyAccessor
) wpas_dbus_setter_process_credentials
,
1403 #endif /* CONFIG_WPS */
1404 { NULL
, NULL
, NULL
, NULL
, NULL
, 0 }
1407 static const struct wpa_dbus_signal_desc wpas_dbus_interface_signals
[] = {
1408 { "ScanDone", WPAS_DBUS_NEW_IFACE_INTERFACE
,
1410 { "success", "b", ARG_OUT
},
1414 { "BSSAdded", WPAS_DBUS_NEW_IFACE_INTERFACE
,
1416 { "path", "o", ARG_OUT
},
1417 { "properties", "a{sv}", ARG_OUT
},
1421 { "BSSRemoved", WPAS_DBUS_NEW_IFACE_INTERFACE
,
1423 { "path", "o", ARG_OUT
},
1427 { "BlobAdded", WPAS_DBUS_NEW_IFACE_INTERFACE
,
1429 { "name", "s", ARG_OUT
},
1433 { "BlobRemoved", WPAS_DBUS_NEW_IFACE_INTERFACE
,
1435 { "name", "s", ARG_OUT
},
1439 { "NetworkAdded", WPAS_DBUS_NEW_IFACE_INTERFACE
,
1441 { "path", "o", ARG_OUT
},
1442 { "properties", "a{sv}", ARG_OUT
},
1446 { "NetworkRemoved", WPAS_DBUS_NEW_IFACE_INTERFACE
,
1448 { "path", "o", ARG_OUT
},
1452 { "NetworkSelected", WPAS_DBUS_NEW_IFACE_INTERFACE
,
1454 { "path", "o", ARG_OUT
},
1458 { "PropertiesChanged", WPAS_DBUS_NEW_IFACE_INTERFACE
,
1460 { "properties", "a{sv}", ARG_OUT
},
1465 { "Event", WPAS_DBUS_NEW_IFACE_WPS
,
1467 { "name", "s", ARG_OUT
},
1468 { "args", "a{sv}", ARG_OUT
},
1472 { "Credentials", WPAS_DBUS_NEW_IFACE_WPS
,
1474 { "credentials", "a{sv}", ARG_OUT
},
1478 { "PropertiesChanged", WPAS_DBUS_NEW_IFACE_WPS
,
1480 { "properties", "a{sv}", ARG_OUT
},
1484 #endif /* CONFIG_WPS */
1485 { NULL
, NULL
, { END_ARGS
} }
1489 int wpas_dbus_register_interface(struct wpa_supplicant
*wpa_s
)
1492 struct wpa_dbus_object_desc
*obj_desc
= NULL
;
1493 struct wpas_dbus_priv
*ctrl_iface
= wpa_s
->global
->dbus
;
1496 /* Do nothing if the control interface is not turned on */
1497 if (ctrl_iface
== NULL
)
1500 /* Create and set the interface's object path */
1501 wpa_s
->dbus_new_path
= os_zalloc(WPAS_DBUS_OBJECT_PATH_MAX
);
1502 if (wpa_s
->dbus_new_path
== NULL
)
1504 next
= ctrl_iface
->next_objid
++;
1505 os_snprintf(wpa_s
->dbus_new_path
, WPAS_DBUS_OBJECT_PATH_MAX
,
1506 WPAS_DBUS_NEW_PATH_INTERFACES
"/%u",
1509 obj_desc
= os_zalloc(sizeof(struct wpa_dbus_object_desc
));
1511 wpa_printf(MSG_ERROR
, "Not enough memory "
1512 "to create object description");
1516 wpas_dbus_register(obj_desc
, wpa_s
, NULL
, wpas_dbus_interface_methods
,
1517 wpas_dbus_interface_properties
,
1518 wpas_dbus_interface_signals
);
1520 wpa_printf(MSG_DEBUG
, "dbus: Register interface object '%s'",
1521 wpa_s
->dbus_new_path
);
1522 if (wpa_dbus_register_object_per_iface(ctrl_iface
,
1523 wpa_s
->dbus_new_path
,
1524 wpa_s
->ifname
, obj_desc
))
1527 wpas_dbus_signal_interface_added(wpa_s
);
1532 os_free(wpa_s
->dbus_new_path
);
1533 wpa_s
->dbus_new_path
= NULL
;
1534 free_dbus_object_desc(obj_desc
);
1539 int wpas_dbus_unregister_interface(struct wpa_supplicant
*wpa_s
)
1541 struct wpas_dbus_priv
*ctrl_iface
;
1543 /* Do nothing if the control interface is not turned on */
1544 if (wpa_s
== NULL
|| wpa_s
->global
== NULL
)
1546 ctrl_iface
= wpa_s
->global
->dbus
;
1547 if (ctrl_iface
== NULL
)
1550 wpa_printf(MSG_DEBUG
, "dbus: Unregister interface object '%s'",
1551 wpa_s
->dbus_new_path
);
1552 if (wpa_dbus_unregister_object_per_iface(ctrl_iface
,
1553 wpa_s
->dbus_new_path
))
1556 wpas_dbus_signal_interface_removed(wpa_s
);
1558 os_free(wpa_s
->dbus_new_path
);
1559 wpa_s
->dbus_new_path
= NULL
;