deassociate status code on dbus as "disassociateReason" property

Avichal Agarwal avichal.a
Sun Jun 7 22:28:20 PDT 2015


From: Avichal Agarwal <avichal.a at samsung.com>
Date: Mon, 8 Jun 2015 10:14:43 +0530
Subject: [PATCH 2/2] 
Sending deassociate status code on dbus as "disassociateReason" property
Signed-off-by: Avichal Agarwal <avichal.a at samsung.com>
---
 wpa_supplicant/dbus/dbus_new.c          |    8 ++++++++
 wpa_supplicant/dbus/dbus_new.h          |    1 +
 wpa_supplicant/dbus/dbus_new_handlers.c |   22 ++++++++++++++++++++++
 wpa_supplicant/dbus/dbus_new_handlers.h |    3 +++
 wpa_supplicant/events.c                 |    2 ++
 wpa_supplicant/notify.c                 |   11 +++++++++++
 wpa_supplicant/notify.h                 |    1 +
 wpa_supplicant/wpa_supplicant_i.h       |    2 +-
 8 files changed, 49 insertions(+), 1 deletion(-)
diff --git a/wpa_supplicant/dbus/dbus_new.c b/wpa_supplicant/dbus/dbus_new.c
index 79da8ff..cc864f0 100644
--- a/wpa_supplicant/dbus/dbus_new.c
+++ b/wpa_supplicant/dbus/dbus_new.c
@@ -1891,6 +1891,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);
@@ -2994,6 +2998,10 @@ static const struct wpa_dbus_property_desc wpas_dbus_interface_properties[] = {
    wpas_dbus_getter_disconnect_reason,
    NULL
  },
+ { "DisassociateReason", WPAS_DBUS_NEW_IFACE_INTERFACE, "i",
+   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 fac4c51..fd66901 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 97db9a8..d8fed69 100644
--- a/wpa_supplicant/dbus/dbus_new_handlers.c
+++ b/wpa_supplicant/dbus/dbus_new_handlers.c
@@ -2773,6 +2773,28 @@ dbus_bool_t wpas_dbus_getter_disconnect_reason(DBusMessageIter *iter,
 
 
 /**
+ * wpas_dbus_getter_disassociate_reason - Get  status code of deassociate
+ * @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;
+ dbus_int32_t reason = wpa_s->diassoc_reason;
+
+
+ return wpas_dbus_simple_property_getter(iter, DBUS_TYPE_INT32,
+      &reason, 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 9afdc05..fc67a4e 100644
--- a/wpa_supplicant/dbus/dbus_new_handlers.h
+++ b/wpa_supplicant/dbus/dbus_new_handlers.h
@@ -169,6 +169,9 @@ dbus_bool_t wpas_dbus_setter_fast_reauth(DBusMessageIter *iter,
 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 053b2ef..bbfd0cb 100644
--- a/wpa_supplicant/events.c
+++ b/wpa_supplicant/events.c
@@ -3295,6 +3295,8 @@ void wpa_supplicant_event(void *ctx, enum wpa_event_type event,
   break;
 #endif /* CONFIG_IBSS_RSN */
  case EVENT_ASSOC_REJECT:
+  wpa_s->diassoc_reason = data->assoc_reject.status_code;
+  wpas_notify_diassociate_reason(wpa_s);
   if (data->assoc_reject.bssid)
    wpa_msg(wpa_s, MSG_INFO, WPA_EVENT_ASSOC_REJECT
     "bssid=" MACSTR " status_code=%u",
diff --git a/wpa_supplicant/notify.c b/wpa_supplicant/notify.c
index fc0c059..64cde41 100644
--- a/wpa_supplicant/notify.c
+++ b/wpa_supplicant/notify.c
@@ -117,6 +117,17 @@ void wpas_notify_disconnect_reason(struct wpa_supplicant *wpa_s)
 }
 
 
+void wpas_notify_diassociate_reason(struct wpa_supplicant *wpa_s)
+{
+ if (wpa_s->p2p_mgmt)
+ {
+  return;
+ }
+ else
+ {
+  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 a122705..dcc794e 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_diassociate_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 ffda53d..26e3220 100644
--- a/wpa_supplicant/wpa_supplicant_i.h
+++ b/wpa_supplicant/wpa_supplicant_i.h
@@ -904,7 +904,7 @@ struct wpa_supplicant {
 
  /* WLAN_REASON_* reason codes. Negative if locally generated. */
  int disconnect_reason;
-
+    int diassoc_reason;
  struct ext_password_data *ext_pw;
 
  struct wpabuf *last_gas_resp, *prev_gas_resp;
-- 
1.7.9.5



More information about the Hostap mailing list