#include "common.h"
#include "config.h"
#include "wpa_supplicant_i.h"
+#include "driver_i.h"
#include "ctrl_iface_dbus.h"
#include "ctrl_iface_dbus_handlers.h"
#include "eap_peer/eap_methods.h"
#include "dbus_dict_helpers.h"
#include "ieee802_11_defs.h"
+#include "wpas_glue.h"
+#include "eapol_supp/eapol_supp_sm.h"
+#include "wps_supplicant.h"
+extern int wpa_debug_level;
+extern int wpa_debug_show_keys;
+extern int wpa_debug_timestamp;
/**
* wpas_dbus_new_invalid_opts_error - Return a new invalid options error message
* Try to get the wpa_supplicant record for this iface, return
* an error if we already control it.
*/
- if (wpa_supplicant_get_iface(global, iface.ifname) != 0) {
+ if (wpa_supplicant_get_iface(global, iface.ifname) != NULL) {
reply = dbus_message_new_error(message,
WPAS_ERROR_EXISTS_ERROR,
"wpa_supplicant already "
return reply;
}
+/**
+ * wpas_dbus_global_set_debugparams- Set the debug params
+ * @message: Pointer to incoming dbus message
+ * @global: %wpa_supplicant global data structure
+ * Returns: a dbus message containing a UINT32 indicating success (1) or
+ * failure (0), or returns a dbus error message with more information
+ *
+ * Handler function for "setDebugParams" method call. Handles requests
+ * by dbus clients for the object path of an specific network interface.
+ */
+DBusMessage * wpas_dbus_global_set_debugparams(DBusMessage *message,
+ struct wpa_global *global)
+{
+ DBusMessage *reply = NULL;
+ int debug_level;
+ dbus_bool_t debug_timestamp;
+ dbus_bool_t debug_show_keys;
+
+ if (!dbus_message_get_args(message, NULL,
+ DBUS_TYPE_INT32, &debug_level,
+ DBUS_TYPE_BOOLEAN, &debug_timestamp,
+ DBUS_TYPE_BOOLEAN, &debug_show_keys,
+ DBUS_TYPE_INVALID)) {
+ reply = wpas_dbus_new_invalid_opts_error(message, NULL);
+ goto out;
+ }
+
+ /* check for allowed debuglevels */
+ if (debug_level != MSG_MSGDUMP &&
+ debug_level != MSG_DEBUG &&
+ debug_level != MSG_INFO &&
+ debug_level != MSG_WARNING &&
+ debug_level != MSG_ERROR) {
+ reply = wpas_dbus_new_invalid_opts_error(message, NULL);
+ goto out;
+ }
+
+ wpa_debug_level = debug_level;
+ wpa_debug_timestamp = debug_timestamp ? 1 : 0;
+ wpa_debug_show_keys = debug_show_keys ? 1 : 0;
+ reply = wpas_dbus_new_success_reply(message);
+
+out:
+ return reply;
+}
/**
* wpas_dbus_iface_scan - Request a wireless scan on an interface
goto error;
}
+ ie = wpa_scan_get_vendor_ie(res, WPS_IE_VENDOR_TYPE);
+ if (ie) {
+ if (!wpa_dbus_dict_append_byte_array(&iter_dict, "wpsie",
+ (const char *) ie,
+ ie[1] + 2))
+ goto error;
+ }
+
if (res->freq) {
if (!wpa_dbus_dict_append_int32(&iter_dict, "frequency",
res->freq))
if (!wpa_dbus_dict_append_uint16(&iter_dict, "capabilities",
res->caps))
goto error;
- if (!wpa_dbus_dict_append_int32(&iter_dict, "quality", res->qual))
+ if (!(res->flags & WPA_SCAN_QUAL_INVALID) &&
+ !wpa_dbus_dict_append_int32(&iter_dict, "quality", res->qual))
goto error;
- if (!wpa_dbus_dict_append_int32(&iter_dict, "noise", res->noise))
+ if (!(res->flags & WPA_SCAN_NOISE_INVALID) &&
+ !wpa_dbus_dict_append_int32(&iter_dict, "noise", res->noise))
goto error;
- if (!wpa_dbus_dict_append_int32(&iter_dict, "level", res->level))
+ if (!(res->flags & WPA_SCAN_LEVEL_INVALID) &&
+ !wpa_dbus_dict_append_int32(&iter_dict, "level", res->level))
goto error;
if (!wpa_dbus_dict_append_int32(&iter_dict, "maxrate",
- wpa_scan_get_max_rate(res)))
+ wpa_scan_get_max_rate(res) * 500000))
goto error;
if (!wpa_dbus_dict_close_write(&iter, &iter_dict))
/**
+ * wpas_dbus_iface_set_smartcard_modules - Set smartcard related module paths
+ * @message: Pointer to incoming dbus message
+ * @wpa_s: wpa_supplicant structure for a network interface
+ * Returns: A dbus message containing a UINT32 indicating success (1) or
+ * failure (0)
+ *
+ * Handler function for "setSmartcardModules" method call.
+ */
+DBusMessage * wpas_dbus_iface_set_smartcard_modules(
+ DBusMessage *message, struct wpa_supplicant *wpa_s)
+{
+ DBusMessageIter iter, iter_dict;
+ char *opensc_engine_path = NULL;
+ char *pkcs11_engine_path = NULL;
+ char *pkcs11_module_path = NULL;
+ struct wpa_dbus_dict_entry entry;
+
+ if (!dbus_message_iter_init(message, &iter))
+ goto error;
+
+ if (!wpa_dbus_dict_open_read(&iter, &iter_dict))
+ goto error;
+
+ while (wpa_dbus_dict_has_dict_entry(&iter_dict)) {
+ if (!wpa_dbus_dict_get_entry(&iter_dict, &entry))
+ goto error;
+ if (!strcmp(entry.key, "opensc_engine_path") &&
+ (entry.type == DBUS_TYPE_STRING)) {
+ opensc_engine_path = os_strdup(entry.str_value);
+ if (opensc_engine_path == NULL)
+ goto error;
+ } else if (!strcmp(entry.key, "pkcs11_engine_path") &&
+ (entry.type == DBUS_TYPE_STRING)) {
+ pkcs11_engine_path = os_strdup(entry.str_value);
+ if (pkcs11_engine_path == NULL)
+ goto error;
+ } else if (!strcmp(entry.key, "pkcs11_module_path") &&
+ (entry.type == DBUS_TYPE_STRING)) {
+ pkcs11_module_path = os_strdup(entry.str_value);
+ if (pkcs11_module_path == NULL)
+ goto error;
+ } else {
+ wpa_dbus_dict_entry_clear(&entry);
+ goto error;
+ }
+ wpa_dbus_dict_entry_clear(&entry);
+ }
+
+#ifdef EAP_TLS_OPENSSL
+ os_free(wpa_s->conf->opensc_engine_path);
+ wpa_s->conf->opensc_engine_path = opensc_engine_path;
+ os_free(wpa_s->conf->pkcs11_engine_path);
+ wpa_s->conf->pkcs11_engine_path = pkcs11_engine_path;
+ os_free(wpa_s->conf->pkcs11_module_path);
+ wpa_s->conf->pkcs11_module_path = pkcs11_module_path;
+#endif /* EAP_TLS_OPENSSL */
+
+ eapol_sm_deinit(wpa_s->eapol);
+ wpa_supplicant_init_eapol(wpa_s);
+
+ return wpas_dbus_new_success_reply(message);
+
+error:
+ os_free(opensc_engine_path);
+ os_free(pkcs11_engine_path);
+ os_free(pkcs11_module_path);
+ return wpas_dbus_new_invalid_opts_error(message, NULL);
+}
+
+/**
* wpas_dbus_iface_get_state - Get interface state
* @message: Pointer to incoming dbus message
* @wpa_s: wpa_supplicant structure for a network interface
/**
* wpas_dbus_iface_set_blobs - Store named binary blobs (ie, for certificates)
* @message: Pointer to incoming dbus message
- * @global: %wpa_supplicant global data structure
+ * @wpa_s: %wpa_supplicant data structure
* Returns: A dbus message containing a UINT32 indicating success (1) or
* failure (0)
*
/**
* wpas_dbus_iface_remove_blob - Remove named binary blobs
* @message: Pointer to incoming dbus message
- * @global: %wpa_supplicant global data structure
+ * @wpa_s: %wpa_supplicant data structure
* Returns: A dbus message containing a UINT32 indicating success (1) or
* failure (0)
*
return wpas_dbus_new_success_reply(message);
}
+
+
+#ifdef CONFIG_WPS
+
+/**
+ * wpas_dbus_iface_wps_pbc - Request credentials using WPS PBC method
+ * @message: Pointer to incoming dbus message
+ * @wpa_s: %wpa_supplicant data structure
+ * Returns: A dbus message containing a UINT32 indicating success (1) or
+ * failure (0)
+ *
+ * Handler function for "wpsPbc" method call
+ */
+DBusMessage * wpas_dbus_iface_wps_pbc(DBusMessage *message,
+ struct wpa_supplicant *wpa_s)
+{
+ char *arg_bssid = NULL;
+ u8 bssid[ETH_ALEN];
+ int ret = 0;
+
+ if (!dbus_message_get_args(message, NULL, DBUS_TYPE_STRING, &arg_bssid,
+ DBUS_TYPE_INVALID))
+ return wpas_dbus_new_invalid_opts_error(message, NULL);
+
+ if (!os_strcmp(arg_bssid, "any"))
+ ret = wpas_wps_start_pbc(wpa_s, NULL);
+ else if (!hwaddr_aton(arg_bssid, bssid))
+ ret = wpas_wps_start_pbc(wpa_s, bssid);
+ else {
+ return wpas_dbus_new_invalid_opts_error(message,
+ "Invalid BSSID");
+ }
+
+ if (ret < 0) {
+ return dbus_message_new_error(message,
+ WPAS_ERROR_WPS_PBC_ERROR,
+ "Could not start PBC "
+ "negotiation");
+ }
+
+ return wpas_dbus_new_success_reply(message);
+}
+
+
+/**
+ * wpas_dbus_iface_wps_pin - Establish the PIN number of the enrollee
+ * @message: Pointer to incoming dbus message
+ * @wpa_s: %wpa_supplicant data structure
+ * Returns: A dbus message containing a UINT32 indicating success (1) or
+ * failure (0)
+ *
+ * Handler function for "wpsPin" method call
+ */
+DBusMessage * wpas_dbus_iface_wps_pin(DBusMessage *message,
+ struct wpa_supplicant *wpa_s)
+{
+ DBusMessage *reply = NULL;
+ char *arg_bssid;
+ char *pin = NULL;
+ u8 bssid[ETH_ALEN], *_bssid = NULL;
+ int ret = 0;
+
+ if (!dbus_message_get_args(message, NULL, DBUS_TYPE_STRING, &arg_bssid,
+ DBUS_TYPE_STRING, &pin, DBUS_TYPE_INVALID))
+ return wpas_dbus_new_invalid_opts_error(message, NULL);
+
+ if (!os_strcmp(arg_bssid, "any"))
+ _bssid = NULL;
+ else if (!hwaddr_aton(arg_bssid, bssid))
+ _bssid = bssid;
+ else {
+ return wpas_dbus_new_invalid_opts_error(message,
+ "Invalid BSSID");
+ }
+
+ if (os_strlen(pin) > 0)
+ ret = wpas_wps_start_pin(wpa_s, _bssid, pin);
+ else
+ ret = wpas_wps_start_pin(wpa_s, _bssid, NULL);
+
+ if (ret < 0) {
+ return dbus_message_new_error(message,
+ WPAS_ERROR_WPS_PIN_ERROR,
+ "Could not init PIN");
+ }
+
+ reply = dbus_message_new_method_return(message);
+ if (reply == NULL)
+ return NULL;
+
+ if (ret == 0) {
+ dbus_message_append_args(reply, DBUS_TYPE_STRING, &pin,
+ DBUS_TYPE_INVALID);
+ } else {
+ char npin[9];
+ sprintf(npin, "%08d", ret);
+ dbus_message_append_args(reply, DBUS_TYPE_STRING, &npin,
+ DBUS_TYPE_INVALID);
+ }
+ return reply;
+}
+
+
+/**
+ * wpas_dbus_iface_wps_reg - Request credentials using the PIN of the AP
+ * @message: Pointer to incoming dbus message
+ * @wpa_s: %wpa_supplicant data structure
+ * Returns: A dbus message containing a UINT32 indicating success (1) or
+ * failure (0)
+ *
+ * Handler function for "wpsReg" method call
+ */
+DBusMessage * wpas_dbus_iface_wps_reg(DBusMessage *message,
+ struct wpa_supplicant *wpa_s)
+{
+ char *arg_bssid;
+ char *pin = NULL;
+ u8 bssid[ETH_ALEN];
+ int ret = 0;
+
+ if (!dbus_message_get_args(message, NULL, DBUS_TYPE_STRING, &arg_bssid,
+ DBUS_TYPE_STRING, &pin, DBUS_TYPE_INVALID))
+ return wpas_dbus_new_invalid_opts_error(message, NULL);
+
+ if (!os_strcmp(arg_bssid, "any"))
+ ret = wpas_wps_start_reg(wpa_s, NULL, pin);
+ else if (!hwaddr_aton(arg_bssid, bssid))
+ ret = wpas_wps_start_reg(wpa_s, bssid, pin);
+ else {
+ return wpas_dbus_new_invalid_opts_error(message,
+ "Invalid BSSID");
+ }
+
+ if (ret < 0) {
+ return dbus_message_new_error(message,
+ WPAS_ERROR_WPS_PBC_ERROR,
+ "Could not request credentials");
+ }
+
+ return wpas_dbus_new_success_reply(message);
+}
+
+#endif /* CONFIG_WPS */