2 * WPA Supplicant / dbus-based control interface
3 * Copyright (c) 2006, Dan Williams <dcbw@redhat.com> and Red Hat, Inc.
5 * This program is free software; you can redistribute it and/or modify
6 * it under the terms of the GNU General Public License version 2 as
7 * published by the Free Software Foundation.
9 * Alternatively, this software may be distributed under the terms of BSD
12 * See README and COPYING for more details.
19 #include "wpa_supplicant_i.h"
21 #include "ctrl_iface_dbus.h"
22 #include "ctrl_iface_dbus_handlers.h"
24 #include "eap_peer/eap_methods.h"
25 #include "dbus_dict_helpers.h"
26 #include "ieee802_11_defs.h"
27 #include "wpas_glue.h"
28 #include "eapol_supp/eapol_supp_sm.h"
29 #include "wps_supplicant.h"
31 extern int wpa_debug_level
;
32 extern int wpa_debug_show_keys
;
33 extern int wpa_debug_timestamp
;
36 * wpas_dbus_new_invalid_opts_error - Return a new invalid options error message
37 * @message: Pointer to incoming dbus message this error refers to
38 * Returns: a dbus error message
40 * Convenience function to create and return an invalid options error
42 static DBusMessage
* wpas_dbus_new_invalid_opts_error(DBusMessage
*message
,
47 reply
= dbus_message_new_error(message
, WPAS_ERROR_INVALID_OPTS
,
48 "Did not receive correct message "
51 dbus_message_append_args(reply
, DBUS_TYPE_STRING
, &arg
,
59 * wpas_dbus_new_success_reply - Return a new success reply message
60 * @message: Pointer to incoming dbus message this reply refers to
61 * Returns: a dbus message containing a single UINT32 that indicates
62 * success (ie, a value of 1)
64 * Convenience function to create and return a success reply message
66 static DBusMessage
* wpas_dbus_new_success_reply(DBusMessage
*message
)
69 unsigned int success
= 1;
71 reply
= dbus_message_new_method_return(message
);
72 dbus_message_append_args(reply
, DBUS_TYPE_UINT32
, &success
,
78 static void wpas_dbus_free_wpa_interface(struct wpa_interface
*iface
)
80 free((char *) iface
->driver
);
81 free((char *) iface
->driver_param
);
82 free((char *) iface
->confname
);
83 free((char *) iface
->bridge_ifname
);
88 * wpas_dbus_global_add_interface - Request registration of a network interface
89 * @message: Pointer to incoming dbus message
90 * @global: %wpa_supplicant global data structure
91 * Returns: The object path of the new interface object,
92 * or a dbus error message with more information
94 * Handler function for "addInterface" method call. Handles requests
95 * by dbus clients to register a network interface that wpa_supplicant
98 DBusMessage
* wpas_dbus_global_add_interface(DBusMessage
*message
,
99 struct wpa_global
*global
)
101 struct wpa_interface iface
;
103 DBusMessage
*reply
= NULL
;
104 DBusMessageIter iter
;
106 memset(&iface
, 0, sizeof(iface
));
108 dbus_message_iter_init(message
, &iter
);
110 /* First argument: interface name (DBUS_TYPE_STRING)
111 * Required; must be non-zero length
113 if (dbus_message_iter_get_arg_type(&iter
) != DBUS_TYPE_STRING
)
115 dbus_message_iter_get_basic(&iter
, &ifname
);
118 iface
.ifname
= ifname
;
120 /* Second argument: dict of options */
121 if (dbus_message_iter_next(&iter
)) {
122 DBusMessageIter iter_dict
;
123 struct wpa_dbus_dict_entry entry
;
125 if (!wpa_dbus_dict_open_read(&iter
, &iter_dict
))
127 while (wpa_dbus_dict_has_dict_entry(&iter_dict
)) {
128 if (!wpa_dbus_dict_get_entry(&iter_dict
, &entry
))
130 if (!strcmp(entry
.key
, "driver") &&
131 (entry
.type
== DBUS_TYPE_STRING
)) {
132 iface
.driver
= strdup(entry
.str_value
);
133 if (iface
.driver
== NULL
)
135 } else if (!strcmp(entry
.key
, "driver-params") &&
136 (entry
.type
== DBUS_TYPE_STRING
)) {
137 iface
.driver_param
= strdup(entry
.str_value
);
138 if (iface
.driver_param
== NULL
)
140 } else if (!strcmp(entry
.key
, "config-file") &&
141 (entry
.type
== DBUS_TYPE_STRING
)) {
142 iface
.confname
= strdup(entry
.str_value
);
143 if (iface
.confname
== NULL
)
145 } else if (!strcmp(entry
.key
, "bridge-ifname") &&
146 (entry
.type
== DBUS_TYPE_STRING
)) {
147 iface
.bridge_ifname
= strdup(entry
.str_value
);
148 if (iface
.bridge_ifname
== NULL
)
151 wpa_dbus_dict_entry_clear(&entry
);
154 wpa_dbus_dict_entry_clear(&entry
);
159 * Try to get the wpa_supplicant record for this iface, return
160 * an error if we already control it.
162 if (wpa_supplicant_get_iface(global
, iface
.ifname
) != NULL
) {
163 reply
= dbus_message_new_error(message
,
164 WPAS_ERROR_EXISTS_ERROR
,
165 "wpa_supplicant already "
166 "controls this interface.");
168 struct wpa_supplicant
*wpa_s
;
169 /* Otherwise, have wpa_supplicant attach to it. */
170 if ((wpa_s
= wpa_supplicant_add_iface(global
, &iface
))) {
171 const char *path
= wpa_supplicant_get_dbus_path(wpa_s
);
172 reply
= dbus_message_new_method_return(message
);
173 dbus_message_append_args(reply
, DBUS_TYPE_OBJECT_PATH
,
174 &path
, DBUS_TYPE_INVALID
);
176 reply
= dbus_message_new_error(message
,
177 WPAS_ERROR_ADD_ERROR
,
179 "couldn't grab this "
183 wpas_dbus_free_wpa_interface(&iface
);
187 wpas_dbus_free_wpa_interface(&iface
);
188 return wpas_dbus_new_invalid_opts_error(message
, NULL
);
193 * wpas_dbus_global_remove_interface - Request deregistration of an interface
194 * @message: Pointer to incoming dbus message
195 * @global: wpa_supplicant global data structure
196 * Returns: a dbus message containing a UINT32 indicating success (1) or
197 * failure (0), or returns a dbus error message with more information
199 * Handler function for "removeInterface" method call. Handles requests
200 * by dbus clients to deregister a network interface that wpa_supplicant
203 DBusMessage
* wpas_dbus_global_remove_interface(DBusMessage
*message
,
204 struct wpa_global
*global
)
206 struct wpa_supplicant
*wpa_s
;
208 DBusMessage
*reply
= NULL
;
210 if (!dbus_message_get_args(message
, NULL
,
211 DBUS_TYPE_OBJECT_PATH
, &path
,
212 DBUS_TYPE_INVALID
)) {
213 reply
= wpas_dbus_new_invalid_opts_error(message
, NULL
);
217 wpa_s
= wpa_supplicant_get_iface_by_dbus_path(global
, path
);
219 reply
= wpas_dbus_new_invalid_iface_error(message
);
223 if (!wpa_supplicant_remove_iface(global
, wpa_s
)) {
224 reply
= wpas_dbus_new_success_reply(message
);
226 reply
= dbus_message_new_error(message
,
227 WPAS_ERROR_REMOVE_ERROR
,
228 "wpa_supplicant couldn't "
229 "remove this interface.");
238 * wpas_dbus_global_get_interface - Get the object path for an interface name
239 * @message: Pointer to incoming dbus message
240 * @global: %wpa_supplicant global data structure
241 * Returns: The object path of the interface object,
242 * or a dbus error message with more information
244 * Handler function for "getInterface" method call. Handles requests
245 * by dbus clients for the object path of an specific network interface.
247 DBusMessage
* wpas_dbus_global_get_interface(DBusMessage
*message
,
248 struct wpa_global
*global
)
250 DBusMessage
*reply
= NULL
;
253 struct wpa_supplicant
*wpa_s
;
255 if (!dbus_message_get_args(message
, NULL
,
256 DBUS_TYPE_STRING
, &ifname
,
257 DBUS_TYPE_INVALID
)) {
258 reply
= wpas_dbus_new_invalid_opts_error(message
, NULL
);
262 wpa_s
= wpa_supplicant_get_iface(global
, ifname
);
264 reply
= wpas_dbus_new_invalid_iface_error(message
);
268 path
= wpa_supplicant_get_dbus_path(wpa_s
);
270 reply
= dbus_message_new_error(message
,
271 WPAS_ERROR_INTERNAL_ERROR
,
272 "an internal error occurred "
273 "getting the interface.");
277 reply
= dbus_message_new_method_return(message
);
278 dbus_message_append_args(reply
,
279 DBUS_TYPE_OBJECT_PATH
, &path
,
287 * wpas_dbus_global_set_debugparams- Set the debug params
288 * @message: Pointer to incoming dbus message
289 * @global: %wpa_supplicant global data structure
290 * Returns: a dbus message containing a UINT32 indicating success (1) or
291 * failure (0), or returns a dbus error message with more information
293 * Handler function for "setDebugParams" method call. Handles requests
294 * by dbus clients for the object path of an specific network interface.
296 DBusMessage
* wpas_dbus_global_set_debugparams(DBusMessage
*message
,
297 struct wpa_global
*global
)
299 DBusMessage
*reply
= NULL
;
301 dbus_bool_t debug_timestamp
;
302 dbus_bool_t debug_show_keys
;
304 if (!dbus_message_get_args(message
, NULL
,
305 DBUS_TYPE_INT32
, &debug_level
,
306 DBUS_TYPE_BOOLEAN
, &debug_timestamp
,
307 DBUS_TYPE_BOOLEAN
, &debug_show_keys
,
308 DBUS_TYPE_INVALID
)) {
309 reply
= wpas_dbus_new_invalid_opts_error(message
, NULL
);
313 if (wpa_supplicant_set_debug_params(global
, debug_level
,
314 debug_timestamp
? 1 : 0,
315 debug_show_keys
? 1 : 0)) {
316 reply
= wpas_dbus_new_invalid_opts_error(message
, NULL
);
320 reply
= wpas_dbus_new_success_reply(message
);
327 * wpas_dbus_iface_scan - Request a wireless scan on an interface
328 * @message: Pointer to incoming dbus message
329 * @wpa_s: wpa_supplicant structure for a network interface
330 * Returns: a dbus message containing a UINT32 indicating success (1) or
333 * Handler function for "scan" method call of a network device. Requests
334 * that wpa_supplicant perform a wireless scan as soon as possible
335 * on a particular wireless interface.
337 DBusMessage
* wpas_dbus_iface_scan(DBusMessage
*message
,
338 struct wpa_supplicant
*wpa_s
)
341 wpa_supplicant_req_scan(wpa_s
, 0, 0);
342 return wpas_dbus_new_success_reply(message
);
347 * wpas_dbus_iface_scan_results - Get the results of a recent scan request
348 * @message: Pointer to incoming dbus message
349 * @wpa_s: wpa_supplicant structure for a network interface
350 * Returns: a dbus message containing a dbus array of objects paths, or returns
351 * a dbus error message if not scan results could be found
353 * Handler function for "scanResults" method call of a network device. Returns
354 * a dbus message containing the object paths of wireless networks found.
356 DBusMessage
* wpas_dbus_iface_scan_results(DBusMessage
*message
,
357 struct wpa_supplicant
*wpa_s
)
359 DBusMessage
*reply
= NULL
;
360 DBusMessageIter iter
;
361 DBusMessageIter sub_iter
;
364 /* Ensure we've actually got scan results to return */
365 if (wpa_s
->scan_res
== NULL
&&
366 wpa_supplicant_get_scan_results(wpa_s
) < 0) {
367 reply
= dbus_message_new_error(message
, WPAS_ERROR_SCAN_ERROR
,
368 "An error ocurred getting scan "
373 /* Create and initialize the return message */
374 reply
= dbus_message_new_method_return(message
);
375 dbus_message_iter_init_append(reply
, &iter
);
376 dbus_message_iter_open_container(&iter
, DBUS_TYPE_ARRAY
,
377 DBUS_TYPE_OBJECT_PATH_AS_STRING
,
380 /* Loop through scan results and append each result's object path */
381 for (i
= 0; i
< wpa_s
->scan_res
->num
; i
++) {
382 struct wpa_scan_res
*res
= wpa_s
->scan_res
->res
[i
];
385 path
= os_zalloc(WPAS_DBUS_OBJECT_PATH_MAX
);
387 perror("wpas_dbus_iface_scan_results[dbus]: out of "
389 wpa_printf(MSG_ERROR
, "dbus control interface: not "
390 "enough memory to send scan results "
394 /* Construct the object path for this network. Note that ':'
395 * is not a valid character in dbus object paths.
397 snprintf(path
, WPAS_DBUS_OBJECT_PATH_MAX
,
398 "%s/" WPAS_DBUS_BSSIDS_PART
"/"
399 WPAS_DBUS_BSSID_FORMAT
,
400 wpa_supplicant_get_dbus_path(wpa_s
),
401 MAC2STR(res
->bssid
));
402 dbus_message_iter_append_basic(&sub_iter
,
403 DBUS_TYPE_OBJECT_PATH
, &path
);
407 dbus_message_iter_close_container(&iter
, &sub_iter
);
415 * wpas_dbus_bssid_properties - Return the properties of a scanned network
416 * @message: Pointer to incoming dbus message
417 * @wpa_s: wpa_supplicant structure for a network interface
418 * @res: wpa_supplicant scan result for which to get properties
419 * Returns: a dbus message containing the properties for the requested network
421 * Handler function for "properties" method call of a scanned network.
422 * Returns a dbus message containing the the properties.
424 DBusMessage
* wpas_dbus_bssid_properties(DBusMessage
*message
,
425 struct wpa_supplicant
*wpa_s
,
426 struct wpa_scan_res
*res
)
428 DBusMessage
*reply
= NULL
;
429 DBusMessageIter iter
, iter_dict
;
432 /* Dump the properties into a dbus message */
433 reply
= dbus_message_new_method_return(message
);
435 dbus_message_iter_init_append(reply
, &iter
);
436 if (!wpa_dbus_dict_open_write(&iter
, &iter_dict
))
439 if (!wpa_dbus_dict_append_byte_array(&iter_dict
, "bssid",
440 (const char *) res
->bssid
,
444 ie
= wpa_scan_get_ie(res
, WLAN_EID_SSID
);
446 if (!wpa_dbus_dict_append_byte_array(&iter_dict
, "ssid",
447 (const char *) (ie
+ 2),
452 ie
= wpa_scan_get_vendor_ie(res
, WPA_IE_VENDOR_TYPE
);
454 if (!wpa_dbus_dict_append_byte_array(&iter_dict
, "wpaie",
460 ie
= wpa_scan_get_ie(res
, WLAN_EID_RSN
);
462 if (!wpa_dbus_dict_append_byte_array(&iter_dict
, "rsnie",
468 ie
= wpa_scan_get_vendor_ie(res
, WPS_IE_VENDOR_TYPE
);
470 if (!wpa_dbus_dict_append_byte_array(&iter_dict
, "wpsie",
477 if (!wpa_dbus_dict_append_int32(&iter_dict
, "frequency",
481 if (!wpa_dbus_dict_append_uint16(&iter_dict
, "capabilities",
484 if (!(res
->flags
& WPA_SCAN_QUAL_INVALID
) &&
485 !wpa_dbus_dict_append_int32(&iter_dict
, "quality", res
->qual
))
487 if (!(res
->flags
& WPA_SCAN_NOISE_INVALID
) &&
488 !wpa_dbus_dict_append_int32(&iter_dict
, "noise", res
->noise
))
490 if (!(res
->flags
& WPA_SCAN_LEVEL_INVALID
) &&
491 !wpa_dbus_dict_append_int32(&iter_dict
, "level", res
->level
))
493 if (!wpa_dbus_dict_append_int32(&iter_dict
, "maxrate",
494 wpa_scan_get_max_rate(res
) * 500000))
497 if (!wpa_dbus_dict_close_write(&iter
, &iter_dict
))
504 dbus_message_unref(reply
);
505 return dbus_message_new_error(message
, WPAS_ERROR_INTERNAL_ERROR
,
506 "an internal error occurred returning "
507 "BSSID properties.");
512 * wpas_dbus_iface_capabilities - Return interface capabilities
513 * @message: Pointer to incoming dbus message
514 * @wpa_s: wpa_supplicant structure for a network interface
515 * Returns: A dbus message containing a dict of strings
517 * Handler function for "capabilities" method call of an interface.
519 DBusMessage
* wpas_dbus_iface_capabilities(DBusMessage
*message
,
520 struct wpa_supplicant
*wpa_s
)
522 DBusMessage
*reply
= NULL
;
523 struct wpa_driver_capa capa
;
525 DBusMessageIter iter
, iter_dict
;
528 dbus_bool_t strict
= FALSE
;
529 DBusMessageIter iter_dict_entry
, iter_dict_val
, iter_array
;
531 if (!dbus_message_get_args(message
, NULL
,
532 DBUS_TYPE_BOOLEAN
, &strict
,
536 reply
= dbus_message_new_method_return(message
);
538 dbus_message_iter_init_append(reply
, &iter
);
539 if (!wpa_dbus_dict_open_write(&iter
, &iter_dict
))
543 eap_methods
= eap_get_names_as_string_array(&num_items
);
545 dbus_bool_t success
= FALSE
;
548 success
= wpa_dbus_dict_append_string_array(
549 &iter_dict
, "eap", (const char **) eap_methods
,
552 /* free returned method array */
553 while (eap_methods
[i
])
554 free(eap_methods
[i
++]);
561 res
= wpa_drv_get_capa(wpa_s
, &capa
);
563 /***** pairwise cipher */
566 const char *args
[] = {"CCMP", "TKIP", "NONE"};
567 if (!wpa_dbus_dict_append_string_array(
568 &iter_dict
, "pairwise", args
,
569 sizeof(args
) / sizeof(char*)))
573 if (!wpa_dbus_dict_begin_string_array(&iter_dict
, "pairwise",
579 if (capa
.enc
& WPA_DRIVER_CAPA_ENC_CCMP
) {
580 if (!wpa_dbus_dict_string_array_add_element(
581 &iter_array
, "CCMP"))
585 if (capa
.enc
& WPA_DRIVER_CAPA_ENC_TKIP
) {
586 if (!wpa_dbus_dict_string_array_add_element(
587 &iter_array
, "TKIP"))
591 if (capa
.key_mgmt
& WPA_DRIVER_CAPA_KEY_MGMT_WPA_NONE
) {
592 if (!wpa_dbus_dict_string_array_add_element(
593 &iter_array
, "NONE"))
597 if (!wpa_dbus_dict_end_string_array(&iter_dict
,
604 /***** group cipher */
607 const char *args
[] = {
608 "CCMP", "TKIP", "WEP104", "WEP40"
610 if (!wpa_dbus_dict_append_string_array(
611 &iter_dict
, "group", args
,
612 sizeof(args
) / sizeof(char*)))
616 if (!wpa_dbus_dict_begin_string_array(&iter_dict
, "group",
622 if (capa
.enc
& WPA_DRIVER_CAPA_ENC_CCMP
) {
623 if (!wpa_dbus_dict_string_array_add_element(
624 &iter_array
, "CCMP"))
628 if (capa
.enc
& WPA_DRIVER_CAPA_ENC_TKIP
) {
629 if (!wpa_dbus_dict_string_array_add_element(
630 &iter_array
, "TKIP"))
634 if (capa
.enc
& WPA_DRIVER_CAPA_ENC_WEP104
) {
635 if (!wpa_dbus_dict_string_array_add_element(
636 &iter_array
, "WEP104"))
640 if (capa
.enc
& WPA_DRIVER_CAPA_ENC_WEP40
) {
641 if (!wpa_dbus_dict_string_array_add_element(
642 &iter_array
, "WEP40"))
646 if (!wpa_dbus_dict_end_string_array(&iter_dict
,
653 /***** key management */
656 const char *args
[] = {
657 "WPA-PSK", "WPA-EAP", "IEEE8021X", "WPA-NONE",
660 if (!wpa_dbus_dict_append_string_array(
661 &iter_dict
, "key_mgmt", args
,
662 sizeof(args
) / sizeof(char*)))
666 if (!wpa_dbus_dict_begin_string_array(&iter_dict
, "key_mgmt",
672 if (!wpa_dbus_dict_string_array_add_element(&iter_array
,
676 if (!wpa_dbus_dict_string_array_add_element(&iter_array
,
680 if (capa
.key_mgmt
& (WPA_DRIVER_CAPA_KEY_MGMT_WPA
|
681 WPA_DRIVER_CAPA_KEY_MGMT_WPA2
)) {
682 if (!wpa_dbus_dict_string_array_add_element(
683 &iter_array
, "WPA-EAP"))
687 if (capa
.key_mgmt
& (WPA_DRIVER_CAPA_KEY_MGMT_WPA_PSK
|
688 WPA_DRIVER_CAPA_KEY_MGMT_WPA2_PSK
)) {
689 if (!wpa_dbus_dict_string_array_add_element(
690 &iter_array
, "WPA-PSK"))
694 if (capa
.key_mgmt
& WPA_DRIVER_CAPA_KEY_MGMT_WPA_NONE
) {
695 if (!wpa_dbus_dict_string_array_add_element(
696 &iter_array
, "WPA-NONE"))
700 if (!wpa_dbus_dict_end_string_array(&iter_dict
,
707 /***** WPA protocol */
710 const char *args
[] = { "RSN", "WPA" };
711 if (!wpa_dbus_dict_append_string_array(
712 &iter_dict
, "proto", args
,
713 sizeof(args
) / sizeof(char*)))
717 if (!wpa_dbus_dict_begin_string_array(&iter_dict
, "proto",
723 if (capa
.key_mgmt
& (WPA_DRIVER_CAPA_KEY_MGMT_WPA2
|
724 WPA_DRIVER_CAPA_KEY_MGMT_WPA2_PSK
)) {
725 if (!wpa_dbus_dict_string_array_add_element(
730 if (capa
.key_mgmt
& (WPA_DRIVER_CAPA_KEY_MGMT_WPA
|
731 WPA_DRIVER_CAPA_KEY_MGMT_WPA_PSK
)) {
732 if (!wpa_dbus_dict_string_array_add_element(
737 if (!wpa_dbus_dict_end_string_array(&iter_dict
,
747 const char *args
[] = { "OPEN", "SHARED", "LEAP" };
748 if (!wpa_dbus_dict_append_string_array(
749 &iter_dict
, "auth_alg", args
,
750 sizeof(args
) / sizeof(char*)))
754 if (!wpa_dbus_dict_begin_string_array(&iter_dict
, "auth_alg",
760 if (capa
.auth
& (WPA_DRIVER_AUTH_OPEN
)) {
761 if (!wpa_dbus_dict_string_array_add_element(
762 &iter_array
, "OPEN"))
766 if (capa
.auth
& (WPA_DRIVER_AUTH_SHARED
)) {
767 if (!wpa_dbus_dict_string_array_add_element(
768 &iter_array
, "SHARED"))
772 if (capa
.auth
& (WPA_DRIVER_AUTH_LEAP
)) {
773 if (!wpa_dbus_dict_string_array_add_element(
774 &iter_array
, "LEAP"))
778 if (!wpa_dbus_dict_end_string_array(&iter_dict
,
785 if (!wpa_dbus_dict_close_write(&iter
, &iter_dict
))
792 dbus_message_unref(reply
);
793 return dbus_message_new_error(message
, WPAS_ERROR_INTERNAL_ERROR
,
794 "an internal error occurred returning "
795 "interface capabilities.");
800 * wpas_dbus_iface_add_network - Add a new configured network
801 * @message: Pointer to incoming dbus message
802 * @wpa_s: wpa_supplicant structure for a network interface
803 * Returns: A dbus message containing the object path of the new network
805 * Handler function for "addNetwork" method call of a network interface.
807 DBusMessage
* wpas_dbus_iface_add_network(DBusMessage
*message
,
808 struct wpa_supplicant
*wpa_s
)
810 DBusMessage
*reply
= NULL
;
811 struct wpa_ssid
*ssid
;
814 path
= os_zalloc(WPAS_DBUS_OBJECT_PATH_MAX
);
816 perror("wpas_dbus_iface_scan_results[dbus]: out of "
818 wpa_printf(MSG_ERROR
, "dbus control interface: not "
819 "enough memory to send scan results "
824 ssid
= wpa_config_add_network(wpa_s
->conf
);
826 reply
= dbus_message_new_error(message
,
827 WPAS_ERROR_ADD_NETWORK_ERROR
,
828 "wpa_supplicant could not add "
829 "a network on this interface.");
832 wpas_notify_network_added(wpa_s
, ssid
);
834 wpa_config_set_network_defaults(ssid
);
836 /* Construct the object path for this network. */
837 snprintf(path
, WPAS_DBUS_OBJECT_PATH_MAX
,
838 "%s/" WPAS_DBUS_NETWORKS_PART
"/%d",
839 wpa_supplicant_get_dbus_path(wpa_s
),
842 reply
= dbus_message_new_method_return(message
);
843 dbus_message_append_args(reply
, DBUS_TYPE_OBJECT_PATH
,
844 &path
, DBUS_TYPE_INVALID
);
853 * wpas_dbus_iface_remove_network - Remove a configured network
854 * @message: Pointer to incoming dbus message
855 * @wpa_s: wpa_supplicant structure for a network interface
856 * Returns: A dbus message containing a UINT32 indicating success (1) or
859 * Handler function for "removeNetwork" method call of a network interface.
861 DBusMessage
* wpas_dbus_iface_remove_network(DBusMessage
*message
,
862 struct wpa_supplicant
*wpa_s
)
864 DBusMessage
*reply
= NULL
;
866 char *iface
= NULL
, *net_id
= NULL
;
868 struct wpa_ssid
*ssid
;
870 if (!dbus_message_get_args(message
, NULL
,
871 DBUS_TYPE_OBJECT_PATH
, &op
,
872 DBUS_TYPE_INVALID
)) {
873 reply
= wpas_dbus_new_invalid_opts_error(message
, NULL
);
877 /* Extract the network ID */
878 iface
= wpas_dbus_decompose_object_path(op
, &net_id
, NULL
);
880 reply
= wpas_dbus_new_invalid_network_error(message
);
883 /* Ensure the network is actually a child of this interface */
884 if (strcmp(iface
, wpa_supplicant_get_dbus_path(wpa_s
)) != 0) {
885 reply
= wpas_dbus_new_invalid_network_error(message
);
889 id
= strtoul(net_id
, NULL
, 10);
890 ssid
= wpa_config_get_network(wpa_s
->conf
, id
);
892 reply
= wpas_dbus_new_invalid_network_error(message
);
896 wpas_notify_network_removed(wpa_s
, ssid
);
898 if (wpa_config_remove_network(wpa_s
->conf
, id
) < 0) {
899 reply
= dbus_message_new_error(message
,
900 WPAS_ERROR_REMOVE_NETWORK_ERROR
,
901 "error removing the specified "
902 "on this interface.");
906 if (ssid
== wpa_s
->current_ssid
)
907 wpa_supplicant_disassociate(wpa_s
, WLAN_REASON_DEAUTH_LEAVING
);
908 reply
= wpas_dbus_new_success_reply(message
);
917 static const char *dont_quote
[] = {
918 "key_mgmt", "proto", "pairwise", "auth_alg", "group", "eap",
919 "opensc_engine_path", "pkcs11_engine_path", "pkcs11_module_path",
923 static dbus_bool_t
should_quote_opt(const char *key
)
926 while (dont_quote
[i
] != NULL
) {
927 if (strcmp(key
, dont_quote
[i
]) == 0)
935 * wpas_dbus_iface_set_network - Set options for a configured network
936 * @message: Pointer to incoming dbus message
937 * @wpa_s: wpa_supplicant structure for a network interface
938 * @ssid: wpa_ssid structure for a configured network
939 * Returns: a dbus message containing a UINT32 indicating success (1) or
942 * Handler function for "set" method call of a configured network.
944 DBusMessage
* wpas_dbus_iface_set_network(DBusMessage
*message
,
945 struct wpa_supplicant
*wpa_s
,
946 struct wpa_ssid
*ssid
)
948 DBusMessage
*reply
= NULL
;
949 struct wpa_dbus_dict_entry entry
= { .type
= DBUS_TYPE_STRING
};
950 DBusMessageIter iter
, iter_dict
;
952 dbus_message_iter_init(message
, &iter
);
954 if (!wpa_dbus_dict_open_read(&iter
, &iter_dict
)) {
955 reply
= wpas_dbus_new_invalid_opts_error(message
, NULL
);
959 while (wpa_dbus_dict_has_dict_entry(&iter_dict
)) {
964 if (!wpa_dbus_dict_get_entry(&iter_dict
, &entry
)) {
965 reply
= wpas_dbus_new_invalid_opts_error(message
,
970 /* Type conversions, since wpa_supplicant wants strings */
971 if (entry
.type
== DBUS_TYPE_ARRAY
&&
972 entry
.array_type
== DBUS_TYPE_BYTE
) {
973 if (entry
.array_len
<= 0)
976 size
= entry
.array_len
* 2 + 1;
977 value
= os_zalloc(size
);
980 ret
= wpa_snprintf_hex(value
, size
,
981 (u8
*) entry
.bytearray_value
,
985 } else if (entry
.type
== DBUS_TYPE_STRING
) {
986 if (should_quote_opt(entry
.key
)) {
987 size
= strlen(entry
.str_value
);
988 /* Zero-length option check */
991 size
+= 3; /* For quotes and terminator */
992 value
= os_zalloc(size
);
995 ret
= snprintf(value
, size
, "\"%s\"",
997 if (ret
< 0 || (size_t) ret
!= (size
- 1))
1000 value
= strdup(entry
.str_value
);
1004 } else if (entry
.type
== DBUS_TYPE_UINT32
) {
1005 value
= os_zalloc(size
);
1008 ret
= snprintf(value
, size
, "%u", entry
.uint32_value
);
1011 } else if (entry
.type
== DBUS_TYPE_INT32
) {
1012 value
= os_zalloc(size
);
1015 ret
= snprintf(value
, size
, "%d", entry
.int32_value
);
1021 if (wpa_config_set(ssid
, entry
.key
, value
, 0) < 0)
1024 if ((strcmp(entry
.key
, "psk") == 0 &&
1025 value
[0] == '"' && ssid
->ssid_len
) ||
1026 (strcmp(entry
.key
, "ssid") == 0 && ssid
->passphrase
))
1027 wpa_config_update_psk(ssid
);
1030 wpa_dbus_dict_entry_clear(&entry
);
1035 reply
= wpas_dbus_new_invalid_opts_error(message
, entry
.key
);
1036 wpa_dbus_dict_entry_clear(&entry
);
1041 reply
= wpas_dbus_new_success_reply(message
);
1049 * wpas_dbus_iface_enable_network - Mark a configured network as enabled
1050 * @message: Pointer to incoming dbus message
1051 * @wpa_s: wpa_supplicant structure for a network interface
1052 * @ssid: wpa_ssid structure for a configured network
1053 * Returns: A dbus message containing a UINT32 indicating success (1) or
1056 * Handler function for "enable" method call of a configured network.
1058 DBusMessage
* wpas_dbus_iface_enable_network(DBusMessage
*message
,
1059 struct wpa_supplicant
*wpa_s
,
1060 struct wpa_ssid
*ssid
)
1062 wpa_supplicant_enable_network(wpa_s
, ssid
);
1063 return wpas_dbus_new_success_reply(message
);
1068 * wpas_dbus_iface_disable_network - Mark a configured network as disabled
1069 * @message: Pointer to incoming dbus message
1070 * @wpa_s: wpa_supplicant structure for a network interface
1071 * @ssid: wpa_ssid structure for a configured network
1072 * Returns: A dbus message containing a UINT32 indicating success (1) or
1075 * Handler function for "disable" method call of a configured network.
1077 DBusMessage
* wpas_dbus_iface_disable_network(DBusMessage
*message
,
1078 struct wpa_supplicant
*wpa_s
,
1079 struct wpa_ssid
*ssid
)
1081 wpa_supplicant_disable_network(wpa_s
, ssid
);
1082 return wpas_dbus_new_success_reply(message
);
1087 * wpas_dbus_iface_select_network - Attempt association with a configured network
1088 * @message: Pointer to incoming dbus message
1089 * @wpa_s: wpa_supplicant structure for a network interface
1090 * Returns: A dbus message containing a UINT32 indicating success (1) or
1093 * Handler function for "selectNetwork" method call of network interface.
1095 DBusMessage
* wpas_dbus_iface_select_network(DBusMessage
*message
,
1096 struct wpa_supplicant
*wpa_s
)
1098 DBusMessage
*reply
= NULL
;
1100 struct wpa_ssid
*ssid
;
1101 char *iface_obj_path
= NULL
;
1102 char *network
= NULL
;
1104 if (strlen(dbus_message_get_signature(message
)) == 0) {
1108 const char *obj_path
;
1111 if (!dbus_message_get_args(message
, NULL
,
1112 DBUS_TYPE_OBJECT_PATH
, &op
,
1113 DBUS_TYPE_INVALID
)) {
1114 reply
= wpas_dbus_new_invalid_opts_error(message
,
1119 /* Extract the network number */
1120 iface_obj_path
= wpas_dbus_decompose_object_path(op
,
1123 if (iface_obj_path
== NULL
) {
1124 reply
= wpas_dbus_new_invalid_iface_error(message
);
1127 /* Ensure the object path really points to this interface */
1128 obj_path
= wpa_supplicant_get_dbus_path(wpa_s
);
1129 if (strcmp(iface_obj_path
, obj_path
) != 0) {
1130 reply
= wpas_dbus_new_invalid_network_error(message
);
1134 nid
= strtoul(network
, NULL
, 10);
1135 if (errno
== EINVAL
) {
1136 reply
= wpas_dbus_new_invalid_network_error(message
);
1140 ssid
= wpa_config_get_network(wpa_s
->conf
, nid
);
1142 reply
= wpas_dbus_new_invalid_network_error(message
);
1147 /* Finally, associate with the network */
1148 wpa_supplicant_select_network(wpa_s
, ssid
);
1150 reply
= wpas_dbus_new_success_reply(message
);
1153 free(iface_obj_path
);
1160 * wpas_dbus_iface_disconnect - Terminate the current connection
1161 * @message: Pointer to incoming dbus message
1162 * @wpa_s: wpa_supplicant structure for a network interface
1163 * Returns: A dbus message containing a UINT32 indicating success (1) or
1166 * Handler function for "disconnect" method call of network interface.
1168 DBusMessage
* wpas_dbus_iface_disconnect(DBusMessage
*message
,
1169 struct wpa_supplicant
*wpa_s
)
1171 wpa_s
->disconnected
= 1;
1172 wpa_supplicant_disassociate(wpa_s
, WLAN_REASON_DEAUTH_LEAVING
);
1174 return wpas_dbus_new_success_reply(message
);
1179 * wpas_dbus_iface_set_ap_scan - Control roaming mode
1180 * @message: Pointer to incoming dbus message
1181 * @wpa_s: wpa_supplicant structure for a network interface
1182 * Returns: A dbus message containing a UINT32 indicating success (1) or
1185 * Handler function for "setAPScan" method call.
1187 DBusMessage
* wpas_dbus_iface_set_ap_scan(DBusMessage
*message
,
1188 struct wpa_supplicant
*wpa_s
)
1190 DBusMessage
*reply
= NULL
;
1191 dbus_uint32_t ap_scan
= 1;
1193 if (!dbus_message_get_args(message
, NULL
, DBUS_TYPE_UINT32
, &ap_scan
,
1194 DBUS_TYPE_INVALID
)) {
1195 reply
= wpas_dbus_new_invalid_opts_error(message
, NULL
);
1199 if (wpa_supplicant_set_ap_scan(wpa_s
, ap_scan
)) {
1200 reply
= wpas_dbus_new_invalid_opts_error(message
, NULL
);
1204 reply
= wpas_dbus_new_success_reply(message
);
1212 * wpas_dbus_iface_set_smartcard_modules - Set smartcard related module paths
1213 * @message: Pointer to incoming dbus message
1214 * @wpa_s: wpa_supplicant structure for a network interface
1215 * Returns: A dbus message containing a UINT32 indicating success (1) or
1218 * Handler function for "setSmartcardModules" method call.
1220 DBusMessage
* wpas_dbus_iface_set_smartcard_modules(
1221 DBusMessage
*message
, struct wpa_supplicant
*wpa_s
)
1223 DBusMessageIter iter
, iter_dict
;
1224 char *opensc_engine_path
= NULL
;
1225 char *pkcs11_engine_path
= NULL
;
1226 char *pkcs11_module_path
= NULL
;
1227 struct wpa_dbus_dict_entry entry
;
1229 if (!dbus_message_iter_init(message
, &iter
))
1232 if (!wpa_dbus_dict_open_read(&iter
, &iter_dict
))
1235 while (wpa_dbus_dict_has_dict_entry(&iter_dict
)) {
1236 if (!wpa_dbus_dict_get_entry(&iter_dict
, &entry
))
1238 if (!strcmp(entry
.key
, "opensc_engine_path") &&
1239 (entry
.type
== DBUS_TYPE_STRING
)) {
1240 opensc_engine_path
= os_strdup(entry
.str_value
);
1241 if (opensc_engine_path
== NULL
)
1243 } else if (!strcmp(entry
.key
, "pkcs11_engine_path") &&
1244 (entry
.type
== DBUS_TYPE_STRING
)) {
1245 pkcs11_engine_path
= os_strdup(entry
.str_value
);
1246 if (pkcs11_engine_path
== NULL
)
1248 } else if (!strcmp(entry
.key
, "pkcs11_module_path") &&
1249 (entry
.type
== DBUS_TYPE_STRING
)) {
1250 pkcs11_module_path
= os_strdup(entry
.str_value
);
1251 if (pkcs11_module_path
== NULL
)
1254 wpa_dbus_dict_entry_clear(&entry
);
1257 wpa_dbus_dict_entry_clear(&entry
);
1260 #ifdef EAP_TLS_OPENSSL
1261 os_free(wpa_s
->conf
->opensc_engine_path
);
1262 wpa_s
->conf
->opensc_engine_path
= opensc_engine_path
;
1263 os_free(wpa_s
->conf
->pkcs11_engine_path
);
1264 wpa_s
->conf
->pkcs11_engine_path
= pkcs11_engine_path
;
1265 os_free(wpa_s
->conf
->pkcs11_module_path
);
1266 wpa_s
->conf
->pkcs11_module_path
= pkcs11_module_path
;
1267 #endif /* EAP_TLS_OPENSSL */
1269 eapol_sm_deinit(wpa_s
->eapol
);
1270 wpa_supplicant_init_eapol(wpa_s
);
1272 return wpas_dbus_new_success_reply(message
);
1275 os_free(opensc_engine_path
);
1276 os_free(pkcs11_engine_path
);
1277 os_free(pkcs11_module_path
);
1278 return wpas_dbus_new_invalid_opts_error(message
, NULL
);
1282 * wpas_dbus_iface_get_state - Get interface state
1283 * @message: Pointer to incoming dbus message
1284 * @wpa_s: wpa_supplicant structure for a network interface
1285 * Returns: A dbus message containing a STRING representing the current
1288 * Handler function for "state" method call.
1290 DBusMessage
* wpas_dbus_iface_get_state(DBusMessage
*message
,
1291 struct wpa_supplicant
*wpa_s
)
1293 DBusMessage
*reply
= NULL
;
1294 const char *str_state
;
1296 reply
= dbus_message_new_method_return(message
);
1297 if (reply
!= NULL
) {
1298 str_state
= wpa_supplicant_state_txt(wpa_s
->wpa_state
);
1299 dbus_message_append_args(reply
, DBUS_TYPE_STRING
, &str_state
,
1308 * wpas_dbus_iface_get_scanning - Get interface scanning state
1309 * @message: Pointer to incoming dbus message
1310 * @wpa_s: wpa_supplicant structure for a network interface
1311 * Returns: A dbus message containing whether the interface is scanning
1313 * Handler function for "scanning" method call.
1315 DBusMessage
* wpas_dbus_iface_get_scanning(DBusMessage
*message
,
1316 struct wpa_supplicant
*wpa_s
)
1318 DBusMessage
*reply
= NULL
;
1319 dbus_bool_t scanning
= wpa_s
->scanning
? TRUE
: FALSE
;
1321 reply
= dbus_message_new_method_return(message
);
1322 if (reply
!= NULL
) {
1323 dbus_message_append_args(reply
, DBUS_TYPE_BOOLEAN
, &scanning
,
1326 perror("wpas_dbus_iface_get_scanning[dbus]: out of "
1328 wpa_printf(MSG_ERROR
, "dbus control interface: not enough "
1329 "memory to return scanning state.");
1337 * wpas_dbus_iface_set_blobs - Store named binary blobs (ie, for certificates)
1338 * @message: Pointer to incoming dbus message
1339 * @wpa_s: %wpa_supplicant data structure
1340 * Returns: A dbus message containing a UINT32 indicating success (1) or
1343 * Asks wpa_supplicant to internally store a one or more binary blobs.
1345 DBusMessage
* wpas_dbus_iface_set_blobs(DBusMessage
*message
,
1346 struct wpa_supplicant
*wpa_s
)
1348 DBusMessage
*reply
= NULL
;
1349 struct wpa_dbus_dict_entry entry
= { .type
= DBUS_TYPE_STRING
};
1350 DBusMessageIter iter
, iter_dict
;
1352 dbus_message_iter_init(message
, &iter
);
1354 if (!wpa_dbus_dict_open_read(&iter
, &iter_dict
))
1355 return wpas_dbus_new_invalid_opts_error(message
, NULL
);
1357 while (wpa_dbus_dict_has_dict_entry(&iter_dict
)) {
1358 struct wpa_config_blob
*blob
;
1360 if (!wpa_dbus_dict_get_entry(&iter_dict
, &entry
)) {
1361 reply
= wpas_dbus_new_invalid_opts_error(message
,
1366 if (entry
.type
!= DBUS_TYPE_ARRAY
||
1367 entry
.array_type
!= DBUS_TYPE_BYTE
) {
1368 reply
= wpas_dbus_new_invalid_opts_error(
1369 message
, "Byte array expected.");
1373 if ((entry
.array_len
<= 0) || (entry
.array_len
> 65536) ||
1374 !strlen(entry
.key
)) {
1375 reply
= wpas_dbus_new_invalid_opts_error(
1376 message
, "Invalid array size.");
1380 blob
= os_zalloc(sizeof(*blob
));
1382 reply
= dbus_message_new_error(
1383 message
, WPAS_ERROR_ADD_ERROR
,
1384 "Not enough memory to add blob.");
1387 blob
->data
= os_zalloc(entry
.array_len
);
1388 if (blob
->data
== NULL
) {
1389 reply
= dbus_message_new_error(
1390 message
, WPAS_ERROR_ADD_ERROR
,
1391 "Not enough memory to add blob data.");
1396 blob
->name
= os_strdup(entry
.key
);
1397 blob
->len
= entry
.array_len
;
1398 os_memcpy(blob
->data
, (u8
*) entry
.bytearray_value
,
1400 if (blob
->name
== NULL
|| blob
->data
== NULL
) {
1401 wpa_config_free_blob(blob
);
1402 reply
= dbus_message_new_error(
1403 message
, WPAS_ERROR_ADD_ERROR
,
1404 "Error adding blob.");
1409 if (!wpa_config_remove_blob(wpa_s
->conf
, blob
->name
))
1410 wpas_notify_blob_removed(wpa_s
, blob
->name
);
1411 wpa_config_set_blob(wpa_s
->conf
, blob
);
1412 wpas_notify_blob_added(wpa_s
, blob
->name
);
1414 wpa_dbus_dict_entry_clear(&entry
);
1416 wpa_dbus_dict_entry_clear(&entry
);
1418 return reply
? reply
: wpas_dbus_new_success_reply(message
);
1423 * wpas_dbus_iface_remove_blob - Remove named binary blobs
1424 * @message: Pointer to incoming dbus message
1425 * @wpa_s: %wpa_supplicant data structure
1426 * Returns: A dbus message containing a UINT32 indicating success (1) or
1429 * Asks wpa_supplicant to remove one or more previously stored binary blobs.
1431 DBusMessage
* wpas_dbus_iface_remove_blobs(DBusMessage
*message
,
1432 struct wpa_supplicant
*wpa_s
)
1434 DBusMessageIter iter
, array
;
1435 char *err_msg
= NULL
;
1437 dbus_message_iter_init(message
, &iter
);
1439 if ((dbus_message_iter_get_arg_type (&iter
) != DBUS_TYPE_ARRAY
) ||
1440 (dbus_message_iter_get_element_type (&iter
) != DBUS_TYPE_STRING
))
1441 return wpas_dbus_new_invalid_opts_error(message
, NULL
);
1443 dbus_message_iter_recurse(&iter
, &array
);
1444 while (dbus_message_iter_get_arg_type(&array
) == DBUS_TYPE_STRING
) {
1447 dbus_message_iter_get_basic(&array
, &name
);
1449 err_msg
= "Invalid blob name.";
1451 if (wpa_config_remove_blob(wpa_s
->conf
, name
) != 0)
1452 err_msg
= "Error removing blob.";
1454 wpas_notify_blob_removed(wpa_s
, name
);
1455 dbus_message_iter_next(&array
);
1459 return dbus_message_new_error(message
, WPAS_ERROR_REMOVE_ERROR
,
1463 return wpas_dbus_new_success_reply(message
);
1470 * wpas_dbus_iface_wps_pbc - Request credentials using WPS PBC method
1471 * @message: Pointer to incoming dbus message
1472 * @wpa_s: %wpa_supplicant data structure
1473 * Returns: A dbus message containing a UINT32 indicating success (1) or
1476 * Handler function for "wpsPbc" method call
1478 DBusMessage
* wpas_dbus_iface_wps_pbc(DBusMessage
*message
,
1479 struct wpa_supplicant
*wpa_s
)
1481 char *arg_bssid
= NULL
;
1485 if (!dbus_message_get_args(message
, NULL
, DBUS_TYPE_STRING
, &arg_bssid
,
1487 return wpas_dbus_new_invalid_opts_error(message
, NULL
);
1489 if (!os_strcmp(arg_bssid
, "any"))
1490 ret
= wpas_wps_start_pbc(wpa_s
, NULL
);
1491 else if (!hwaddr_aton(arg_bssid
, bssid
))
1492 ret
= wpas_wps_start_pbc(wpa_s
, bssid
);
1494 return wpas_dbus_new_invalid_opts_error(message
,
1499 return dbus_message_new_error(message
,
1500 WPAS_ERROR_WPS_PBC_ERROR
,
1501 "Could not start PBC "
1505 return wpas_dbus_new_success_reply(message
);
1510 * wpas_dbus_iface_wps_pin - Establish the PIN number of the enrollee
1511 * @message: Pointer to incoming dbus message
1512 * @wpa_s: %wpa_supplicant data structure
1513 * Returns: A dbus message containing a UINT32 indicating success (1) or
1516 * Handler function for "wpsPin" method call
1518 DBusMessage
* wpas_dbus_iface_wps_pin(DBusMessage
*message
,
1519 struct wpa_supplicant
*wpa_s
)
1521 DBusMessage
*reply
= NULL
;
1524 u8 bssid
[ETH_ALEN
], *_bssid
= NULL
;
1527 if (!dbus_message_get_args(message
, NULL
, DBUS_TYPE_STRING
, &arg_bssid
,
1528 DBUS_TYPE_STRING
, &pin
, DBUS_TYPE_INVALID
))
1529 return wpas_dbus_new_invalid_opts_error(message
, NULL
);
1531 if (!os_strcmp(arg_bssid
, "any"))
1533 else if (!hwaddr_aton(arg_bssid
, bssid
))
1536 return wpas_dbus_new_invalid_opts_error(message
,
1540 if (os_strlen(pin
) > 0)
1541 ret
= wpas_wps_start_pin(wpa_s
, _bssid
, pin
);
1543 ret
= wpas_wps_start_pin(wpa_s
, _bssid
, NULL
);
1546 return dbus_message_new_error(message
,
1547 WPAS_ERROR_WPS_PIN_ERROR
,
1548 "Could not init PIN");
1551 reply
= dbus_message_new_method_return(message
);
1556 dbus_message_append_args(reply
, DBUS_TYPE_STRING
, &pin
,
1560 sprintf(npin
, "%08d", ret
);
1561 dbus_message_append_args(reply
, DBUS_TYPE_STRING
, &npin
,
1569 * wpas_dbus_iface_wps_reg - Request credentials using the PIN of the AP
1570 * @message: Pointer to incoming dbus message
1571 * @wpa_s: %wpa_supplicant data structure
1572 * Returns: A dbus message containing a UINT32 indicating success (1) or
1575 * Handler function for "wpsReg" method call
1577 DBusMessage
* wpas_dbus_iface_wps_reg(DBusMessage
*message
,
1578 struct wpa_supplicant
*wpa_s
)
1585 if (!dbus_message_get_args(message
, NULL
, DBUS_TYPE_STRING
, &arg_bssid
,
1586 DBUS_TYPE_STRING
, &pin
, DBUS_TYPE_INVALID
))
1587 return wpas_dbus_new_invalid_opts_error(message
, NULL
);
1589 if (!os_strcmp(arg_bssid
, "any"))
1590 ret
= wpas_wps_start_reg(wpa_s
, NULL
, pin
, NULL
);
1591 else if (!hwaddr_aton(arg_bssid
, bssid
))
1592 ret
= wpas_wps_start_reg(wpa_s
, bssid
, pin
, NULL
);
1594 return wpas_dbus_new_invalid_opts_error(message
,
1599 return dbus_message_new_error(message
,
1600 WPAS_ERROR_WPS_PBC_ERROR
,
1601 "Could not request credentials");
1604 return wpas_dbus_new_success_reply(message
);
1607 #endif /* CONFIG_WPS */