]> git.ipfire.org Git - thirdparty/hostap.git/commitdiff
dbus: Expose authentication status to D-Bus
authorAlex Khouderchah <akhouderchah@chromium.org>
Thu, 5 Jul 2018 23:29:09 +0000 (16:29 -0700)
committerJouni Malinen <j@w1.fi>
Wed, 2 Jan 2019 22:39:12 +0000 (00:39 +0200)
wpa_supplicant currently logs CTRL-EVENT-AUTH-FAILED errors when
authentication fails, but doesn't expose any property to the D-Bus
interface related to this.

This change adds the "AuthStatusCode" property to the interface, which
contains the IEEE 802.11 status code of the last authentication.

Signed-off-by: Alex Khouderchah <akhouderchah@chromium.org>
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 f4584f4f45cb4759fb3cf8d40b9aa84f0d5655e5..87898e4119e24742c74094c075d92e21a24db519 100644 (file)
@@ -769,6 +769,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>AuthStatusCode - i - (read)</h3>
+       <p>The most recent IEEE 802.11 status code for authentication.</p>
+      </li>
+
       <li>
        <h3>AssocStatusCode - i - (read)</h3>
        <p>The most recent IEEE 802.11 status code for association rejection.</p>
index ed2659bad025e6247fa4184a79cae8669b06ff8f..fc2fc2ef1b96e8afcb3df5a7f1d5137e1d99c0f8 100644 (file)
@@ -2231,6 +2231,10 @@ void wpas_dbus_signal_prop_changed(struct wpa_supplicant *wpa_s,
                prop = "DisconnectReason";
                flush = TRUE;
                break;
+       case WPAS_DBUS_PROP_AUTH_STATUS_CODE:
+               prop = "AuthStatusCode";
+               flush = TRUE;
+               break;
        case WPAS_DBUS_PROP_ASSOC_STATUS_CODE:
                prop = "AssocStatusCode";
                flush = TRUE;
@@ -3772,6 +3776,11 @@ static const struct wpa_dbus_property_desc wpas_dbus_interface_properties[] = {
          NULL,
          NULL
        },
+       { "AuthStatusCode", WPAS_DBUS_NEW_IFACE_INTERFACE, "i",
+         wpas_dbus_getter_auth_status_code,
+         NULL,
+         NULL
+       },
        { "AssocStatusCode", WPAS_DBUS_NEW_IFACE_INTERFACE, "i",
          wpas_dbus_getter_assoc_status_code,
          NULL,
index ef16b368234ad01106db95e94f3a7846616080f4..42db3892ed77e639d8d3097e93dff3c4646c2f74 100644 (file)
@@ -30,6 +30,7 @@ enum wpas_dbus_prop {
        WPAS_DBUS_PROP_BSSS,
        WPAS_DBUS_PROP_STATIONS,
        WPAS_DBUS_PROP_DISCONNECT_REASON,
+       WPAS_DBUS_PROP_AUTH_STATUS_CODE,
        WPAS_DBUS_PROP_ASSOC_STATUS_CODE,
        WPAS_DBUS_PROP_ROAM_TIME,
        WPAS_DBUS_PROP_ROAM_COMPLETE,
index 60557db34ebc052407d60eab9f890739fdf69ab7..0d2ddd9747f8292f4bc2d10ddf0480c4ede2bd06 100644 (file)
@@ -3092,6 +3092,27 @@ dbus_bool_t wpas_dbus_getter_disconnect_reason(
 }
 
 
+/**
+ * wpas_dbus_getter_auth_status_code - Get most recent auth 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 "AuthStatusCode" property.
+ */
+dbus_bool_t wpas_dbus_getter_auth_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 reason = wpa_s->auth_status_code;
+
+       return wpas_dbus_simple_property_getter(iter, DBUS_TYPE_INT32,
+                                               &reason, error);
+}
+
+
 /**
  * wpas_dbus_getter_assoc_status_code - Get most recent failed assoc status code
  * @iter: Pointer to incoming dbus message iter
index f14df3e35d6e873caacbb42888e3f3179a5bceba..d922ce1b4189169086eb178e48ce5d7e3f0c56c8 100644 (file)
@@ -150,6 +150,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_auth_status_code);
 DECLARE_ACCESSOR(wpas_dbus_getter_assoc_status_code);
 DECLARE_ACCESSOR(wpas_dbus_getter_roam_time);
 DECLARE_ACCESSOR(wpas_dbus_getter_roam_complete);
index f54ec7acd5bae85a71c369cb85c092422a9c1b1a..bdbe9920b2c56c339a3517bd4fe0dd3ae662e6fc 100644 (file)
@@ -4166,6 +4166,8 @@ void wpa_supplicant_event(void *ctx, enum wpa_event_type event,
                                   "FST: MB IEs updated from auth IE");
 #endif /* CONFIG_FST */
                sme_event_auth(wpa_s, data);
+               wpa_s->auth_status_code = data->auth.status_code;
+               wpas_notify_auth_status_code(wpa_s);
                break;
        case EVENT_ASSOC:
 #ifdef CONFIG_TESTING_OPTIONS
index 530548f9c5f3e43849a2d6ddb5ccf11259cd3d68..e5e45de1880337ed76fef8e0fd9d45421fdc9837 100644 (file)
@@ -140,6 +140,15 @@ void wpas_notify_disconnect_reason(struct wpa_supplicant *wpa_s)
 }
 
 
+void wpas_notify_auth_status_code(struct wpa_supplicant *wpa_s)
+{
+       if (wpa_s->p2p_mgmt)
+               return;
+
+       wpas_dbus_signal_prop_changed(wpa_s, WPAS_DBUS_PROP_AUTH_STATUS_CODE);
+}
+
+
 void wpas_notify_assoc_status_code(struct wpa_supplicant *wpa_s)
 {
        if (wpa_s->p2p_mgmt)
index 9605785cff7779b6c262bcf41f85bbbbbb14c1a7..65f513ea9770803e010610f5109ca60e96428288 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_auth_status_code(struct wpa_supplicant *wpa_s);
 void wpas_notify_assoc_status_code(struct wpa_supplicant *wpa_s);
 void wpas_notify_roam_time(struct wpa_supplicant *wpa_s);
 void wpas_notify_roam_complete(struct wpa_supplicant *wpa_s);
index 2b0b0886c193a73cd02d55bed9e0ec75ab028433..46c4715df1f158862a319ed89b07532e95cca419 100644 (file)
@@ -1024,6 +1024,10 @@ struct wpa_supplicant {
        /* WLAN_REASON_* reason codes. Negative if locally generated. */
        int disconnect_reason;
 
+       /* WLAN_STATUS_* status codes from last received Authentication frame
+        * from the AP. */
+       u16 auth_status_code;
+
        /* WLAN_STATUS_* status codes from (Re)Association Response frame. */
        u16 assoc_status_code;