dbus: Expose authentication status to D-Bus

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>
This commit is contained in:
Alex Khouderchah 2018-07-05 16:29:09 -07:00 committed by Jouni Malinen
parent 80d06d0ca9
commit 38b405c8f0
9 changed files with 53 additions and 0 deletions

View 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>

View 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,

View 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,

View 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

View 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);

View 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

View 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)

View 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);

View 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;