From patchwork Tue Jul 7 15:22:39 2015 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Jouni Malinen X-Patchwork-Id: 492334 Return-Path: X-Original-To: patchwork-incoming@ozlabs.org Delivered-To: patchwork-incoming@ozlabs.org Received: from maxx.maxx.shmoo.com (maxx.shmoo.com [205.134.188.171]) by ozlabs.org (Postfix) with ESMTP id C04121402C4 for ; Wed, 8 Jul 2015 01:22:58 +1000 (AEST) Received: from localhost (localhost [127.0.0.1]) by maxx.maxx.shmoo.com (Postfix) with ESMTP id 423BF17C007; Tue, 7 Jul 2015 11:22:56 -0400 (EDT) X-Virus-Scanned: amavisd-new at maxx.shmoo.com Received: from maxx.maxx.shmoo.com ([127.0.0.1]) by localhost (maxx.shmoo.com [127.0.0.1]) (amavisd-new, port 10024) with ESMTP id yF8EGdsDjuMA; Tue, 7 Jul 2015 11:22:56 -0400 (EDT) Received: from maxx.shmoo.com (localhost [127.0.0.1]) by maxx.maxx.shmoo.com (Postfix) with ESMTP id B5D4D17C05B; Tue, 7 Jul 2015 11:22:50 -0400 (EDT) X-Original-To: mailman-post+hostap@maxx.shmoo.com Delivered-To: mailman-post+hostap@maxx.shmoo.com Received: from localhost (localhost [127.0.0.1]) by maxx.maxx.shmoo.com (Postfix) with ESMTP id AC87017C05B for ; Tue, 7 Jul 2015 11:22:48 -0400 (EDT) X-Virus-Scanned: amavisd-new at maxx.shmoo.com Received: from maxx.maxx.shmoo.com ([127.0.0.1]) by localhost (maxx.shmoo.com [127.0.0.1]) (amavisd-new, port 10024) with ESMTP id 1E9Z9jeubG4X for ; Tue, 7 Jul 2015 11:22:42 -0400 (EDT) Received: from li674-96.members.linode.com (mail.w1.fi [212.71.239.96]) by maxx.maxx.shmoo.com (Postfix) with ESMTP id B74B817C007 for ; Tue, 7 Jul 2015 11:22:42 -0400 (EDT) Received: from jm (37-33-41-129.bb.dnainternet.fi [37.33.41.129]) by li674-96.members.linode.com (Postfix) with ESMTPSA id 94C021169B; Tue, 7 Jul 2015 15:22:40 +0000 (UTC) Received: by jm (sSMTP sendmail emulation); Tue, 07 Jul 2015 18:22:39 +0300 Date: Tue, 7 Jul 2015 18:22:39 +0300 From: Jouni Malinen To: Dan Williams Subject: Re: [PATCH v2] Adding disassociate reason as property in dbus Message-ID: <20150707152239.GB1374@w1.fi> Mail-Followup-To: Dan Williams , avichal.a@samsung.com, "hostap@lists.shmoo.com" , Kaushik Saha References: <540294684.1149641434524934782.JavaMail.weblogic@epmlwas06c> <1435769593.23653.3.camel@redhat.com> MIME-Version: 1.0 Content-Disposition: inline In-Reply-To: <1435769593.23653.3.camel@redhat.com> User-Agent: Mutt/1.5.21 (2010-09-15) Cc: "hostap@lists.shmoo.com" , Kaushik Saha X-BeenThere: hostap@lists.shmoo.com X-Mailman-Version: 2.1.11 Precedence: list List-Id: HostAP Project List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Sender: hostap-bounces@lists.shmoo.com Errors-To: hostap-bounces@lists.shmoo.com On Wed, Jul 01, 2015 at 11:53:13AM -0500, Dan Williams wrote: > It gives disassoc_bssid as string and disassoc_reason as integer. > This patch is updated according to the suggestions given by Dan Williams. This commit message needs cleanup.. In addition, calling this "disassociation reason" is very confusing taking into account the changes are using the ASSOC_REJECT event which has nothing to do with disassociation; this event happens before the association is formed. > Avichal: I took the liberty of fixing a few things: ... Thanks! The version below fixes some more issues (a typo in a function name, missing documentation, replace disassoc_bssid string with a 6-octet u8 array and print the string version only if and when needed). I'm not comfortable committing this, though, taken into account the conflict between the name of the D-Bus property and the internal EVENT_ASSOC_REJECT event. Is this patch really trying to make the last EVENT_ASSOC_REJECT event information available through D-Bus? If so, the property should be renamed and the commit message and dbus.doxygen should clearly state what this information is and especially what it is not (it is _not_ showing the reason for disassociation from associated state). From: Avichal Agarwal Subject: [PATCH] D-Bus: Add last ASSOC_REJECT reason as a property This gives the BSSID (as a string) and reason (as an integer) of the last ASSOC_REJECT event from the driver. Signed-off-by: Avichal Agarwal --- doc/dbus.doxygen | 7 +++++- wpa_supplicant/dbus/dbus_new.c | 8 ++++++ wpa_supplicant/dbus/dbus_new.h | 1 + wpa_supplicant/dbus/dbus_new_handlers.c | 44 +++++++++++++++++++++++++++++++++ wpa_supplicant/dbus/dbus_new_handlers.h | 4 +++ wpa_supplicant/events.c | 10 ++++++-- wpa_supplicant/notify.c | 7 ++++++ wpa_supplicant/notify.h | 1 + wpa_supplicant/wpa_supplicant_i.h | 4 +++ 9 files changed, 83 insertions(+), 3 deletions(-) diff --git a/doc/dbus.doxygen b/doc/dbus.doxygen index 3a08ad7..236a9d9 100644 --- a/doc/dbus.doxygen +++ b/doc/dbus.doxygen @@ -673,6 +673,11 @@ fi.w1.wpa_supplicant1.CreateInterface.

DisconnectReason - i - (read)

The most recent IEEE 802.11 reason code for disconnect. Negative value indicates locally generated disconnection.

+ +
  • +

    DisassociateReason - (is) - (read)

    +

    The most recent disassociation reason and BSSID.

    +
  • \subsection dbus_interface_signals Signals @@ -792,7 +797,7 @@ fi.w1.wpa_supplicant1.CreateInterface.

    Arguments

    a{sv} : properties
    -
    A dictionary with pairs of properties names which have changed and theirs new values. Possible dictionary keys are: "ApScan", "Scanning", "State", "CurrentBSS", "CurrentNetwork"
    +
    A dictionary with pairs of properties names which have changed and theirs new values. Possible dictionary keys are: "ApScan", "Scanning", "State", "CurrentBSS", "CurrentNetwork", "DisassociateReason"
    diff --git a/wpa_supplicant/dbus/dbus_new.c b/wpa_supplicant/dbus/dbus_new.c index 1959ea7..76bdf42 100644 --- a/wpa_supplicant/dbus/dbus_new.c +++ b/wpa_supplicant/dbus/dbus_new.c @@ -1904,6 +1904,10 @@ void wpas_dbus_signal_prop_changed(struct wpa_supplicant *wpa_s, prop = "DisconnectReason"; flush = TRUE; break; + case WPAS_DBUS_PROP_DISASSOCIATE_REASON: + prop = "DisassociateReason"; + flush = TRUE; + break; default: wpa_printf(MSG_ERROR, "dbus: %s: Unknown Property value %d", __func__, property); @@ -3020,6 +3024,10 @@ static const struct wpa_dbus_property_desc wpas_dbus_interface_properties[] = { wpas_dbus_getter_disconnect_reason, NULL }, + { "DisassociateReason", WPAS_DBUS_NEW_IFACE_INTERFACE, "(is)", + wpas_dbus_getter_disassociate_reason, + NULL + }, { NULL, NULL, NULL, NULL, NULL } }; diff --git a/wpa_supplicant/dbus/dbus_new.h b/wpa_supplicant/dbus/dbus_new.h index 7503348..febbdf0 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_DISASSOCIATE_REASON, }; enum wpas_dbus_bss_prop { diff --git a/wpa_supplicant/dbus/dbus_new_handlers.c b/wpa_supplicant/dbus/dbus_new_handlers.c index 1c04e92..7c1c97a 100644 --- a/wpa_supplicant/dbus/dbus_new_handlers.c +++ b/wpa_supplicant/dbus/dbus_new_handlers.c @@ -2797,6 +2797,50 @@ dbus_bool_t wpas_dbus_getter_disconnect_reason(DBusMessageIter *iter, /** + * wpas_dbus_getter_disassociate_reason - Get bssid(string) with status code(int) for ASSOC_REJECT + * @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 "DisassociateReason" property. + */ +dbus_bool_t wpas_dbus_getter_disassociate_reason(DBusMessageIter *iter, + DBusError *error, + void *user_data) +{ + struct wpa_supplicant *wpa_s = user_data; + DBusMessageIter variant_iter; + DBusMessageIter struct_iter; + char bssid[20]; + + if (wpa_s->disassoc_reason) + os_snprintf(bssid, sizeof(bssid), MACSTR, + MAC2STR(wpa_s->disassoc_bssid)); + else + bssid[0] = '\0'; + + if (!dbus_message_iter_open_container(iter, DBUS_TYPE_VARIANT, + "(is)", &variant_iter) || + !dbus_message_iter_open_container(&variant_iter, DBUS_TYPE_STRUCT, + NULL, &struct_iter) || + !dbus_message_iter_append_basic(&struct_iter, DBUS_TYPE_INT32, + &wpa_s->disassoc_reason) || + !dbus_message_iter_append_basic(&struct_iter, DBUS_TYPE_STRING, + &bssid) || + !dbus_message_iter_close_container(&variant_iter, &struct_iter) || + !dbus_message_iter_close_container(iter, &variant_iter)) { + dbus_set_error(error, DBUS_ERROR_FAILED, + "%s: error constructing reply variant", + __func__); + return FALSE; + } + + return TRUE; +} + + +/** * 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 50f72ec..9b6fbd7 100644 --- a/wpa_supplicant/dbus/dbus_new_handlers.h +++ b/wpa_supplicant/dbus/dbus_new_handlers.h @@ -173,6 +173,10 @@ dbus_bool_t wpas_dbus_getter_disconnect_reason(DBusMessageIter *iter, DBusError *error, void *user_data); +dbus_bool_t wpas_dbus_getter_disassociate_reason(DBusMessageIter *iter, + DBusError *error, + void *user_data); + dbus_bool_t wpas_dbus_getter_bss_expire_age(DBusMessageIter *iter, DBusError *error, void *user_data); diff --git a/wpa_supplicant/events.c b/wpa_supplicant/events.c index aa171ef..f171722 100644 --- a/wpa_supplicant/events.c +++ b/wpa_supplicant/events.c @@ -3328,15 +3328,21 @@ void wpa_supplicant_event(void *ctx, enum wpa_event_type event, break; #endif /* CONFIG_IBSS_RSN */ case EVENT_ASSOC_REJECT: - if (data->assoc_reject.bssid) + wpa_s->disassoc_reason = data->assoc_reject.status_code; + os_memset(wpa_s->disassoc_bssid, 0, ETH_ALEN); + if (data->assoc_reject.bssid) { + os_memcpy(wpa_s->disassoc_bssid, + data->assoc_reject.bssid, ETH_ALEN); wpa_msg(wpa_s, MSG_INFO, WPA_EVENT_ASSOC_REJECT "bssid=" MACSTR " status_code=%u", MAC2STR(data->assoc_reject.bssid), data->assoc_reject.status_code); - else + } else { wpa_msg(wpa_s, MSG_INFO, WPA_EVENT_ASSOC_REJECT "status_code=%u", data->assoc_reject.status_code); + } + wpas_notify_disassociate_reason(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 822db74..7fbb62a 100644 --- a/wpa_supplicant/notify.c +++ b/wpa_supplicant/notify.c @@ -117,6 +117,13 @@ void wpas_notify_disconnect_reason(struct wpa_supplicant *wpa_s) } +void wpas_notify_disassociate_reason(struct wpa_supplicant *wpa_s) +{ + wpas_dbus_signal_prop_changed(wpa_s, + WPAS_DBUS_PROP_DISASSOCIATE_REASON); +} + + void wpas_notify_network_changed(struct wpa_supplicant *wpa_s) { if (wpa_s->p2p_mgmt) diff --git a/wpa_supplicant/notify.h b/wpa_supplicant/notify.h index 1aeec47..3912e67 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_disassociate_reason(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 dd5b245..4c3f0cf 100644 --- a/wpa_supplicant/wpa_supplicant_i.h +++ b/wpa_supplicant/wpa_supplicant_i.h @@ -912,6 +912,10 @@ struct wpa_supplicant { /* WLAN_REASON_* reason codes. Negative if locally generated. */ int disconnect_reason; + /* ASSOC_REJECT status code and bssid */ + u8 disassoc_bssid[ETH_ALEN]; + int disassoc_reason; + struct ext_password_data *ext_pw; struct wpabuf *last_gas_resp, *prev_gas_resp;