]> git.ipfire.org Git - thirdparty/hostap.git/commitdiff
D-Bus: Add association response status code property for failure cases
authorNaveen Singh <nasingh@google.com>
Thu, 3 Mar 2016 18:48:09 +0000 (10:48 -0800)
committerJouni Malinen <j@w1.fi>
Sun, 6 Mar 2016 18:44:51 +0000 (20:44 +0200)
(Re)Association Response frame 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.

Signed-off-by: Naveen Singh <nasingh@google.com>
doc/dbus.doxygen
wpa_supplicant/dbus/dbus_new.c
wpa_supplicant/dbus/dbus_new.h
wpa_supplicant/dbus/dbus_new_handlers.c
wpa_supplicant/dbus/dbus_new_handlers.h
wpa_supplicant/events.c
wpa_supplicant/notify.c
wpa_supplicant/notify.h
wpa_supplicant/wpa_supplicant_i.h

index 1989eea03f93ffee437e8e8e6fe0ba43556a600c..28ee37188c72800e120101581016ea99c7d59f8c 100644 (file)
@@ -735,6 +735,11 @@ fi.w1.wpa_supplicant1.CreateInterface.
        <p>The most recent IEEE 802.11 reason code for disconnect. Negative value indicates locally generated disconnection.</p>
       </li>
 
+      <li>
+       <h3>AssocStatusCode - i - (read)</h3>
+       <p>The most recent IEEE 802.11 status code for association rejection.</p>
+      </li>
+
       <li>
        <h3>EapolVersion - s - (read/write)</h3>
        <p>IEEE 802.1X/EAPOL version number</p>
index d74630ee799d6244057e0fa1184cc3b7a61ced66..d894f6ae8d9009ecb6254186dc97f7b4648ab870 100644 (file)
@@ -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,6 +3259,11 @@ static const struct wpa_dbus_property_desc wpas_dbus_interface_properties[] = {
          NULL,
          NULL
        },
+       { "AssocStatusCode", WPAS_DBUS_NEW_IFACE_INTERFACE, "i",
+         wpas_dbus_getter_assoc_status_code,
+         NULL,
+         NULL
+       },
        { NULL, NULL, NULL, NULL, NULL, NULL }
 };
 
index 6d240fffce786fecb79b2fb57d7d81a07fc9cd8c..3ac66db1a0df020a6c1c7861d8618f6f4dfbfac3 100644 (file)
@@ -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 {
index 09461c5d49343634b684937a3bc811b07362e1d3..da90ea1c30f5b346ce237122cde2f14590dc8855 100644 (file)
@@ -2857,6 +2857,27 @@ dbus_bool_t wpas_dbus_getter_disconnect_reason(
 }
 
 
+/**
+ * wpas_dbus_getter_assoc_status_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 "AssocStatusCode" property.
+ */
+dbus_bool_t wpas_dbus_getter_assoc_status_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
index 31b92d19543d196c95b23ce6afb47b94af2d5d52..cd299c050c09f87851d3162c6fba95d021cb1198 100644 (file)
@@ -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_status_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);
index c39315d35f1cffe0229b2e38a9a26a5d378a38a4..ac3c118464712d48d15665046c24b1842bdb1497 100644 (file)
@@ -3501,6 +3501,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 {
index 45d06bf3574464adcb98a90826d66b9777e1c1a9..325883dd97285a14e16fd7606760f97f8314c891 100644 (file)
@@ -128,6 +128,15 @@ void wpas_notify_disconnect_reason(struct wpa_supplicant *wpa_s)
 }
 
 
+void wpas_notify_assoc_status_code(struct wpa_supplicant *wpa_s)
+{
+       if (wpa_s->p2p_mgmt)
+               return;
+
+       wpas_dbus_signal_prop_changed(wpa_s, WPAS_DBUS_PROP_ASSOC_STATUS_CODE);
+}
+
+
 void wpas_notify_network_changed(struct wpa_supplicant *wpa_s)
 {
        if (wpa_s->p2p_mgmt)
index d9f0f5a967323ea59d736d5392125337149cb42b..1b7f04d2572ef535a864e0332e19e1ddf895390b 100644 (file)
@@ -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);
index 1b16d281ab84ee3eaf43eb208707e6b3f0942f99..269bac0f918b26eec5d89c8e18f4b28e51f85543 100644 (file)
@@ -950,6 +950,9 @@ struct wpa_supplicant {
        /* WLAN_REASON_* reason codes. Negative if locally generated. */
        int disconnect_reason;
 
+       /* WLAN_STATUS_* status codes from (Re)Association Response frame. */
+       u16 assoc_status_code;
+
        struct ext_password_data *ext_pw;
 
        struct wpabuf *last_gas_resp, *prev_gas_resp;