[PATCH] propagate scan failures over d-bus
quiche at chromium.org
quiche
Wed Apr 9 15:10:29 PDT 2014
If we receive a scan request via D-Bus, and wpa_supplicant_scan_trigger
fails, return the failure to the caller over D-Bus.
Signed-hostap: mukesh agrawal <quiche at chromium.org>
---
wpa_supplicant/dbus/dbus_new.h | 7 +++++--
wpa_supplicant/dbus/dbus_new_handlers.c | 31 +++++++++++++++++++++++++++++--
2 files changed, 34 insertions(+), 4 deletions(-)
diff --git a/wpa_supplicant/dbus/dbus_new.h b/wpa_supplicant/dbus/dbus_new.h
index f8092a8..58d98d1 100644
--- a/wpa_supplicant/dbus/dbus_new.h
+++ b/wpa_supplicant/dbus/dbus_new.h
@@ -88,8 +88,8 @@ enum wpas_dbus_bss_prop {
#define WPAS_DBUS_NEW_IFACE_P2P_GROUPMEMBER \
WPAS_DBUS_NEW_INTERFACE ".GroupMember"
-/* Errors */
-#define WPAS_DBUS_ERROR_UNKNOWN_ERROR \
+/* Top-level Errors */
+#define WPAS_DBUS_ERROR_UNKNOWN_ERROR \
WPAS_DBUS_NEW_INTERFACE ".UnknownError"
#define WPAS_DBUS_ERROR_INVALID_ARGS \
WPAS_DBUS_NEW_INTERFACE ".InvalidArgs"
@@ -116,6 +116,9 @@ enum wpas_dbus_bss_prop {
#define WPAS_DBUS_ERROR_BLOB_UNKNOWN \
WPAS_DBUS_NEW_INTERFACE ".BlobUnknown"
+/* Interface-level errors */
+#define WPAS_DBUS_ERROR_IFACE_SCAN_ERROR \
+ WPAS_DBUS_NEW_IFACE_INTERFACE ".ScanError"
#ifdef CONFIG_CTRL_IFACE_DBUS_NEW
diff --git a/wpa_supplicant/dbus/dbus_new_handlers.c b/wpa_supplicant/dbus/dbus_new_handlers.c
index 4d5e109..ef63328 100644
--- a/wpa_supplicant/dbus/dbus_new_handlers.c
+++ b/wpa_supplicant/dbus/dbus_new_handlers.c
@@ -125,6 +125,27 @@ DBusMessage * wpas_dbus_error_invalid_args(DBusMessage *message,
}
+/**
+ * wpas_dbus_error_scan_error - Return a new ScanError error message
+ * @message: Pointer to incoming dbus message this error refers to
+ * @error: Optional string to be used as the error message
+ * Returns: a dbus error message
+ *
+ * Convenience function to create and return a scan error
+ */
+DBusMessage * wpas_dbus_error_scan_error(DBusMessage *message,
+ const char *error)
+{
+ DBusMessage *reply;
+
+ reply = dbus_message_new_error(message,
+ WPAS_DBUS_ERROR_IFACE_SCAN_ERROR,
+ error);
+
+ return reply;
+}
+
+
static const char *dont_quote[] = {
"key_mgmt", "proto", "pairwise", "auth_alg", "group", "eap",
"opensc_engine_path", "pkcs11_engine_path", "pkcs11_module_path",
@@ -1221,7 +1242,10 @@ DBusMessage * wpas_dbus_handler_scan(DBusMessage *message,
"passive scan");
goto out;
} else if (params.freqs && params.freqs[0]) {
- wpa_supplicant_trigger_scan(wpa_s, ¶ms);
+ if (wpa_supplicant_trigger_scan(wpa_s, ¶ms)) {
+ reply = wpas_dbus_error_scan_error(
+ message, "Scan request rejected");
+ }
} else {
wpa_s->scan_req = 2;
wpa_supplicant_req_scan(wpa_s, 0, 0);
@@ -1231,7 +1255,10 @@ DBusMessage * wpas_dbus_handler_scan(DBusMessage *message,
/* Add wildcard ssid */
params.num_ssids++;
}
- wpa_supplicant_trigger_scan(wpa_s, ¶ms);
+ if (wpa_supplicant_trigger_scan(wpa_s, ¶ms)) {
+ reply = wpas_dbus_error_scan_error(
+ message, "Scan request rejected");
+ }
} else {
wpa_printf(MSG_DEBUG, "wpas_dbus_handler_scan[dbus]: "
"Unknown scan type: %s", type);
--
1.9.1.423.g4596e3a
More information about the Hostap
mailing list