[PATCH 3/8] AP: use monotonic time for STA connected time

Johannes Berg johannes
Mon Nov 25 12:56:04 PST 2013


From: Johannes Berg <johannes.berg at intel.com>

Connected time is relative, so should be using monotonic time
rather than time of day.

Signed-hostap: Johannes Berg <johannes.berg at intel.com>
---
 src/ap/ctrl_iface_ap.c | 5 ++---
 src/ap/hostapd.c       | 2 +-
 src/ap/ieee802_1x.c    | 2 +-
 src/ap/sta_info.h      | 2 +-
 4 files changed, 5 insertions(+), 6 deletions(-)

diff --git a/src/ap/ctrl_iface_ap.c b/src/ap/ctrl_iface_ap.c
index ac33068..4125fd5 100644
--- a/src/ap/ctrl_iface_ap.c
+++ b/src/ap/ctrl_iface_ap.c
@@ -24,14 +24,13 @@
 static int hostapd_get_sta_conn_time(struct sta_info *sta,
 				     char *buf, size_t buflen)
 {
-	struct os_time now, age;
+	struct os_reltime age;
 	int len = 0, ret;
 
 	if (!sta->connected_time.sec)
 		return 0;
 
-	os_get_time(&now);
-	os_time_sub(&now, &sta->connected_time, &age);
+	os_reltime_age(&sta->connected_time, &age);
 
 	ret = os_snprintf(buf + len, buflen - len, "connected_time=%u\n",
 			  (unsigned int) age.sec);
diff --git a/src/ap/hostapd.c b/src/ap/hostapd.c
index 492861e..6fe2956 100644
--- a/src/ap/hostapd.c
+++ b/src/ap/hostapd.c
@@ -1967,7 +1967,7 @@ void hostapd_new_assoc_sta(struct hostapd_data *hapd, struct sta_info *sta,
 	 * IEEE 802.1X/WPA code will start accounting after the station has
 	 * been authorized. */
 	if (!hapd->conf->ieee802_1x && !hapd->conf->wpa) {
-		os_get_time(&sta->connected_time);
+		os_get_reltime(&sta->connected_time);
 		accounting_sta_start(hapd, sta);
 	}
 
diff --git a/src/ap/ieee802_1x.c b/src/ap/ieee802_1x.c
index 26685ef..2ce2ed9 100644
--- a/src/ap/ieee802_1x.c
+++ b/src/ap/ieee802_1x.c
@@ -102,7 +102,7 @@ void ieee802_1x_set_sta_authorized(struct hostapd_data *hapd,
 	}
 
 	if (authorized) {
-		os_get_time(&sta->connected_time);
+		os_get_reltime(&sta->connected_time);
 		accounting_sta_start(hapd, sta);
 	}
 }
diff --git a/src/ap/sta_info.h b/src/ap/sta_info.h
index 047b8f0..e60bff2 100644
--- a/src/ap/sta_info.h
+++ b/src/ap/sta_info.h
@@ -126,7 +126,7 @@ struct sta_info {
 	struct wpabuf *p2p_ie; /* P2P IE from (Re)Association Request */
 	struct wpabuf *hs20_ie; /* HS 2.0 IE from (Re)Association Request */
 
-	struct os_time connected_time;
+	struct os_reltime connected_time;
 
 #ifdef CONFIG_SAE
 	struct sae_data *sae;
-- 
1.8.4.rc3




More information about the Hostap mailing list