dbus: Export roam time, roam complete, and session length

Add new Interface properties "RoamTime", "RoamComplete", and
"SessionLength". "RoamTime" carries the roam time of the most recent
roam in milliseconds. "RoamComplete" carries True or False corresponding
to the success status of the most recent roam. "SessionLength" carries
the number of milliseconds corresponding to how long the connection to
the last AP was before a roam or disconnect happened.

Signed-off-by: Matthew Wang <matthewmwang@chromium.org>
This commit is contained in:
Matthew Wang 2018-06-20 16:42:45 -07:00 committed by Jouni Malinen
parent fef133e99c
commit 2bbad1c7c9
10 changed files with 183 additions and 0 deletions

View file

@ -774,6 +774,21 @@ fi.w1.wpa_supplicant1.CreateInterface.
<p>The most recent IEEE 802.11 status code for association rejection.</p>
</li>
<li>
<h3>RoamTime - u - (read)</h3>
<p>The most recent roam time in milliseconds.</p>
</li>
<li>
<h3>RoamComplete - b - (read)</h3>
<p>The most recent roam success or failure.</p>
</li>
<li>
<h3>SessionLength - u - (read)</h3>
<p>The most recent BSS session length in milliseconds.</p>
</li>
<li>
<h3>EapolVersion - s - (read/write)</h3>
<p>IEEE 802.1X/EAPOL version number</p>

View file

@ -2235,6 +2235,15 @@ void wpas_dbus_signal_prop_changed(struct wpa_supplicant *wpa_s,
prop = "AssocStatusCode";
flush = TRUE;
break;
case WPAS_DBUS_PROP_ROAM_TIME:
prop = "RoamTime";
break;
case WPAS_DBUS_PROP_ROAM_COMPLETE:
prop = "RoamComplete";
break;
case WPAS_DBUS_PROP_SESSION_LENGTH:
prop = "SessionLength";
break;
default:
wpa_printf(MSG_ERROR, "dbus: %s: Unknown Property value %d",
__func__, property);
@ -2839,6 +2848,24 @@ static const struct wpa_dbus_property_desc wpas_dbus_bss_properties[] = {
NULL,
NULL
},
{
"RoamTime", WPAS_DBUS_NEW_IFACE_INTERFACE, "u",
wpas_dbus_getter_roam_time,
NULL,
NULL
},
{
"RoamComplete", WPAS_DBUS_NEW_IFACE_INTERFACE, "b",
wpas_dbus_getter_roam_complete,
NULL,
NULL
},
{
"SessionLength", WPAS_DBUS_NEW_IFACE_INTERFACE, "u",
wpas_dbus_getter_session_length,
NULL,
NULL
},
{ NULL, NULL, NULL, NULL, NULL, NULL }
};

View file

@ -31,6 +31,9 @@ enum wpas_dbus_prop {
WPAS_DBUS_PROP_STATIONS,
WPAS_DBUS_PROP_DISCONNECT_REASON,
WPAS_DBUS_PROP_ASSOC_STATUS_CODE,
WPAS_DBUS_PROP_ROAM_TIME,
WPAS_DBUS_PROP_ROAM_COMPLETE,
WPAS_DBUS_PROP_SESSION_LENGTH,
};
enum wpas_dbus_bss_prop {

View file

@ -3113,6 +3113,71 @@ dbus_bool_t wpas_dbus_getter_assoc_status_code(
}
/**
* wpas_dbus_getter_roam_time - Get most recent roam time
* @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 "RoamTime" property.
*/
dbus_bool_t wpas_dbus_getter_roam_time(
const struct wpa_dbus_property_desc *property_desc,
DBusMessageIter *iter, DBusError *error, void *user_data)
{
struct wpa_supplicant *wpa_s = user_data;
dbus_uint32_t roam_time = wpa_s->roam_time.sec * 1000 +
wpa_s->roam_time.usec / 1000;
return wpas_dbus_simple_property_getter(iter, DBUS_TYPE_UINT32,
&roam_time, error);
}
/**
* wpas_dbus_getter_roam_complete - Get most recent roam success or failure
* @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 "RoamComplete" property.
*/
dbus_bool_t wpas_dbus_getter_roam_complete(
const struct wpa_dbus_property_desc *property_desc,
DBusMessageIter *iter, DBusError *error, void *user_data)
{
struct wpa_supplicant *wpa_s = user_data;
dbus_bool_t roam_complete = os_reltime_initialized(&wpa_s->roam_time);
return wpas_dbus_simple_property_getter(iter, DBUS_TYPE_BOOLEAN,
&roam_complete, error);
}
/**
* wpas_dbus_getter_session_length - Get most recent BSS session length
* @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 "SessionLength" property.
*/
dbus_bool_t wpas_dbus_getter_session_length(
const struct wpa_dbus_property_desc *property_desc,
DBusMessageIter *iter, DBusError *error, void *user_data)
{
struct wpa_supplicant *wpa_s = user_data;
dbus_uint32_t session_length = wpa_s->session_length.sec * 1000 +
wpa_s->session_length.usec / 1000;
return wpas_dbus_simple_property_getter(iter, DBUS_TYPE_UINT32,
&session_length, error);
}
/**
* wpas_dbus_getter_bss_expire_age - Get BSS entry expiration age
* @iter: Pointer to incoming dbus message iter

View file

@ -151,6 +151,9 @@ 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_roam_time);
DECLARE_ACCESSOR(wpas_dbus_getter_roam_complete);
DECLARE_ACCESSOR(wpas_dbus_getter_session_length);
DECLARE_ACCESSOR(wpas_dbus_getter_bss_expire_age);
DECLARE_ACCESSOR(wpas_dbus_setter_bss_expire_age);
DECLARE_ACCESSOR(wpas_dbus_getter_bss_expire_count);

View file

@ -293,6 +293,13 @@ void wpa_supplicant_mark_disassoc(struct wpa_supplicant *wpa_s)
if (wpa_s->wpa_state == WPA_INTERFACE_DISABLED)
return;
if (os_reltime_initialized(&wpa_s->session_start)) {
os_reltime_age(&wpa_s->session_start, &wpa_s->session_length);
wpa_s->session_start.sec = 0;
wpa_s->session_start.usec = 0;
wpas_notify_session_length(wpa_s);
}
wpa_supplicant_set_state(wpa_s, WPA_DISCONNECTED);
bssid_changed = !is_zero_ether_addr(wpa_s->bssid);
os_memset(wpa_s->bssid, 0, ETH_ALEN);
@ -2698,6 +2705,16 @@ static void wpa_supplicant_event_assoc(struct wpa_supplicant *wpa_s,
wpa_supplicant_set_state(wpa_s, WPA_ASSOCIATED);
if (os_memcmp(bssid, wpa_s->bssid, ETH_ALEN) != 0) {
if (os_reltime_initialized(&wpa_s->session_start)) {
os_reltime_age(&wpa_s->session_start,
&wpa_s->session_length);
wpa_s->session_start.sec = 0;
wpa_s->session_start.usec = 0;
wpas_notify_session_length(wpa_s);
} else {
wpas_notify_auth_changed(wpa_s);
os_get_reltime(&wpa_s->session_start);
}
wpa_dbg(wpa_s, MSG_DEBUG, "Associated to a new BSS: BSSID="
MACSTR, MAC2STR(bssid));
new_bss = 1;

View file

@ -149,6 +149,33 @@ void wpas_notify_assoc_status_code(struct wpa_supplicant *wpa_s)
}
void wpas_notify_roam_time(struct wpa_supplicant *wpa_s)
{
if (wpa_s->p2p_mgmt)
return;
wpas_dbus_signal_prop_changed(wpa_s, WPAS_DBUS_PROP_ROAM_TIME);
}
void wpas_notify_roam_complete(struct wpa_supplicant *wpa_s)
{
if (wpa_s->p2p_mgmt)
return;
wpas_dbus_signal_prop_changed(wpa_s, WPAS_DBUS_PROP_ROAM_COMPLETE);
}
void wpas_notify_session_length(struct wpa_supplicant *wpa_s)
{
if (wpa_s->p2p_mgmt)
return;
wpas_dbus_signal_prop_changed(wpa_s, WPAS_DBUS_PROP_SESSION_LENGTH);
}
void wpas_notify_network_changed(struct wpa_supplicant *wpa_s)
{
if (wpa_s->p2p_mgmt)

View file

@ -24,6 +24,9 @@ void wpas_notify_state_changed(struct wpa_supplicant *wpa_s,
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_roam_time(struct wpa_supplicant *wpa_s);
void wpas_notify_roam_complete(struct wpa_supplicant *wpa_s);
void wpas_notify_session_length(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);

View file

@ -846,6 +846,23 @@ void wpa_supplicant_set_state(struct wpa_supplicant *wpa_s,
wpa_supplicant_state_txt(wpa_s->wpa_state),
wpa_supplicant_state_txt(state));
if (state == WPA_COMPLETED &&
os_reltime_initialized(&wpa_s->roam_start)) {
os_reltime_age(&wpa_s->roam_start, &wpa_s->roam_time);
wpa_s->roam_start.sec = 0;
wpa_s->roam_start.usec = 0;
wpas_notify_auth_changed(wpa_s);
wpas_notify_roam_time(wpa_s);
wpas_notify_roam_complete(wpa_s);
} else if (state == WPA_DISCONNECTED &&
os_reltime_initialized(&wpa_s->roam_start)) {
wpa_s->roam_start.sec = 0;
wpa_s->roam_start.usec = 0;
wpa_s->roam_time.sec = 0;
wpa_s->roam_time.usec = 0;
wpas_notify_roam_complete(wpa_s);
}
if (state == WPA_INTERFACE_DISABLED) {
/* Assure normal scan when interface is restored */
wpa_s->normal_scans = 0;
@ -1904,6 +1921,8 @@ void wpa_supplicant_associate(struct wpa_supplicant *wpa_s,
if (wpa_s->current_bss && wpa_s->current_bss == bss) {
wmm_ac_save_tspecs(wpa_s);
wpa_s->reassoc_same_bss = 1;
} else if (wpa_s->current_bss && wpa_s->current_bss != bss) {
os_get_reltime(&wpa_s->roam_start);
}
}

View file

@ -494,6 +494,10 @@ struct wpa_supplicant {
struct wpa_supplicant *next;
struct l2_packet_data *l2;
struct l2_packet_data *l2_br;
struct os_reltime roam_start;
struct os_reltime roam_time;
struct os_reltime session_start;
struct os_reltime session_length;
unsigned char own_addr[ETH_ALEN];
unsigned char perm_addr[ETH_ALEN];
char ifname[100];