[PATCH] assoc response status code in case of failure
naveen at nestlabs.com
naveen at nestlabs.com
Wed Mar 2 17:24:41 PST 2016
From: Naveen Singh <nasingh at google.com>
Assoc response with status code other than 0 is now notified
over DBUS as a part of PropertiesChanged Signal. This can be used
by application in case AP is denying association with status code 17
(band steering) so that it does not interfere in the BSSID selection
logic of wpa_supplicant.
---
wpa_supplicant/dbus/dbus_new.c | 10 +++++++++-
wpa_supplicant/dbus/dbus_new.h | 1 +
wpa_supplicant/dbus/dbus_new_handlers.c | 20 ++++++++++++++++++++
wpa_supplicant/dbus/dbus_new_handlers.h | 1 +
wpa_supplicant/events.c | 2 ++
wpa_supplicant/notify.c | 5 +++++
wpa_supplicant/notify.h | 1 +
wpa_supplicant/wpa_supplicant_i.h | 1 +
8 files changed, 40 insertions(+), 1 deletion(-)
diff --git a/wpa_supplicant/dbus/dbus_new.c b/wpa_supplicant/dbus/dbus_new.c
index d74630e..433f3ef 100644
--- a/wpa_supplicant/dbus/dbus_new.c
+++ b/wpa_supplicant/dbus/dbus_new.c
@@ -2001,6 +2001,10 @@ void wpas_dbus_signal_prop_changed(struct wpa_supplicant *wpa_s,
prop = "DisconnectReason";
flush = TRUE;
break;
+ case WPAS_DBUS_PROP_ASSOC_STATUS_CODE:
+ prop = "AssocStatusCode";
+ flush = TRUE;
+ break;
default:
wpa_printf(MSG_ERROR, "dbus: %s: Unknown Property value %d",
__func__, property);
@@ -3255,7 +3259,11 @@ static const struct wpa_dbus_property_desc wpas_dbus_interface_properties[] = {
NULL,
NULL
},
- { NULL, NULL, NULL, NULL, NULL, NULL }
+ { "AssocStatusCode", WPAS_DBUS_NEW_IFACE_INTERFACE, "i",
+ wpas_dbus_getter_assoc_staus_code,
+ NULL
+ },
+ { NULL, NULL, NULL, NULL, NULL }
};
static const struct wpa_dbus_signal_desc wpas_dbus_interface_signals[] = {
diff --git a/wpa_supplicant/dbus/dbus_new.h b/wpa_supplicant/dbus/dbus_new.h
index 6d240ff..3ac66db 100644
--- a/wpa_supplicant/dbus/dbus_new.h
+++ b/wpa_supplicant/dbus/dbus_new.h
@@ -29,6 +29,7 @@ enum wpas_dbus_prop {
WPAS_DBUS_PROP_CURRENT_AUTH_MODE,
WPAS_DBUS_PROP_BSSS,
WPAS_DBUS_PROP_DISCONNECT_REASON,
+ WPAS_DBUS_PROP_ASSOC_STATUS_CODE,
};
enum wpas_dbus_bss_prop {
diff --git a/wpa_supplicant/dbus/dbus_new_handlers.c b/wpa_supplicant/dbus/dbus_new_handlers.c
index 09461c5..fe4cefc 100644
--- a/wpa_supplicant/dbus/dbus_new_handlers.c
+++ b/wpa_supplicant/dbus/dbus_new_handlers.c
@@ -2858,6 +2858,26 @@ dbus_bool_t wpas_dbus_getter_disconnect_reason(
/**
+ * wpas_dbus_getter_assoc_staus_code - Get most recent failed assoc status code
+ * @iter: Pointer to incoming dbus message iter
+ * @error: Location to store error on failure
+ * @user_data: Function specific data
+ * Returns: TRUE on success, FALSE on failure
+ *
+ * Getter for "AssocStatus" property.
+ */
+dbus_bool_t wpas_dbus_getter_assoc_staus_code(
+ const struct wpa_dbus_property_desc *property_desc,
+ DBusMessageIter *iter, DBusError *error, void *user_data)
+{
+ struct wpa_supplicant *wpa_s = user_data;
+ dbus_int32_t status_code = wpa_s->assoc_status_code;
+ return wpas_dbus_simple_property_getter(iter, DBUS_TYPE_INT32,
+ &status_code, error);
+}
+
+
+/**
* wpas_dbus_getter_bss_expire_age - Get BSS entry expiration age
* @iter: Pointer to incoming dbus message iter
* @error: Location to store error on failure
diff --git a/wpa_supplicant/dbus/dbus_new_handlers.h b/wpa_supplicant/dbus/dbus_new_handlers.h
index 31b92d1..ebbcf4a 100644
--- a/wpa_supplicant/dbus/dbus_new_handlers.h
+++ b/wpa_supplicant/dbus/dbus_new_handlers.h
@@ -138,6 +138,7 @@ DECLARE_ACCESSOR(wpas_dbus_getter_fast_reauth);
DECLARE_ACCESSOR(wpas_dbus_setter_fast_reauth);
DECLARE_ACCESSOR(wpas_dbus_getter_disconnect_reason);
DECLARE_ACCESSOR(wpas_dbus_getter_disassociate_reason);
+DECLARE_ACCESSOR(wpas_dbus_getter_assoc_staus_code);
DECLARE_ACCESSOR(wpas_dbus_getter_bss_expire_age);
DECLARE_ACCESSOR(wpas_dbus_setter_bss_expire_age);
DECLARE_ACCESSOR(wpas_dbus_getter_bss_expire_count);
diff --git a/wpa_supplicant/events.c b/wpa_supplicant/events.c
index 318aad7..509e56c 100644
--- a/wpa_supplicant/events.c
+++ b/wpa_supplicant/events.c
@@ -3492,6 +3492,8 @@ void wpa_supplicant_event(void *ctx, enum wpa_event_type event,
wpa_msg(wpa_s, MSG_INFO, WPA_EVENT_ASSOC_REJECT
"status_code=%u",
data->assoc_reject.status_code);
+ wpa_s->assoc_status_code = data->assoc_reject.status_code;
+ wpas_notify_assoc_status_code(wpa_s);
if (wpa_s->drv_flags & WPA_DRIVER_FLAGS_SME)
sme_event_assoc_reject(wpa_s, data);
else {
diff --git a/wpa_supplicant/notify.c b/wpa_supplicant/notify.c
index 45d06bf..e5b6c8c 100644
--- a/wpa_supplicant/notify.c
+++ b/wpa_supplicant/notify.c
@@ -127,6 +127,11 @@ void wpas_notify_disconnect_reason(struct wpa_supplicant *wpa_s)
wpas_dbus_signal_prop_changed(wpa_s, WPAS_DBUS_PROP_DISCONNECT_REASON);
}
+void wpas_notify_assoc_status_code(struct wpa_supplicant *wpa_s)
+{
+ wpas_dbus_signal_prop_changed(wpa_s, WPAS_DBUS_PROP_ASSOC_STATUS_CODE);
+}
+
void wpas_notify_network_changed(struct wpa_supplicant *wpa_s)
{
diff --git a/wpa_supplicant/notify.h b/wpa_supplicant/notify.h
index d9f0f5a..1b7f04d 100644
--- a/wpa_supplicant/notify.h
+++ b/wpa_supplicant/notify.h
@@ -23,6 +23,7 @@ void wpas_notify_state_changed(struct wpa_supplicant *wpa_s,
enum wpa_states new_state,
enum wpa_states old_state);
void wpas_notify_disconnect_reason(struct wpa_supplicant *wpa_s);
+void wpas_notify_assoc_status_code(struct wpa_supplicant *wpa_s);
void wpas_notify_network_changed(struct wpa_supplicant *wpa_s);
void wpas_notify_ap_scan_changed(struct wpa_supplicant *wpa_s);
void wpas_notify_bssid_changed(struct wpa_supplicant *wpa_s);
diff --git a/wpa_supplicant/wpa_supplicant_i.h b/wpa_supplicant/wpa_supplicant_i.h
index 1ec2cd8..1b4dd41 100644
--- a/wpa_supplicant/wpa_supplicant_i.h
+++ b/wpa_supplicant/wpa_supplicant_i.h
@@ -951,6 +951,7 @@ struct wpa_supplicant {
/* WLAN_REASON_* reason codes. Negative if locally generated. */
int disconnect_reason;
+ int assoc_status_code;
struct ext_password_data *ext_pw;
--
2.7.0.rc3.207.g0ac5344
More information about the Hostap
mailing list