aboutsummaryrefslogtreecommitdiffstats
path: root/src/ap/accounting.c
diff options
context:
space:
mode:
authorNick Lowe <nick.lowe@lugatech.com>2016-01-24 11:38:40 (GMT)
committerJouni Malinen <j@w1.fi>2016-02-05 23:24:59 (GMT)
commit9b6177a8911771df6063405a13f841a4d93ad43b (patch)
treefb75c5098c0ce5538d7b302bea38ce9b48d8fa20 /src/ap/accounting.c
parentd179089b6d3f3e42b3863285d4638c66f45211ef (diff)
downloadhostap-9b6177a8911771df6063405a13f841a4d93ad43b.zip
hostap-9b6177a8911771df6063405a13f841a4d93ad43b.tar.gz
hostap-9b6177a8911771df6063405a13f841a4d93ad43b.tar.bz2
Add Event-Timestamp to all Accounting-Request packets
Event-Timestamp should be sent for all Accounting-Request packets and only after the system clock has a sane value, not where there's a value close to the Unix time epoch. Signed-off-by: Nick Lowe <nick.lowe@lugatech.com>
Diffstat (limited to 'src/ap/accounting.c')
-rw-r--r--src/ap/accounting.c17
1 files changed, 9 insertions, 8 deletions
diff --git a/src/ap/accounting.c b/src/ap/accounting.c
index c4aea40..abf3cf1 100644
--- a/src/ap/accounting.c
+++ b/src/ap/accounting.c
@@ -41,6 +41,7 @@ static struct radius_msg * accounting_msg(struct hostapd_data *hapd,
size_t len;
int i;
struct wpabuf *b;
+ struct os_time now;
msg = radius_msg_new(RADIUS_CODE_ACCOUNTING_REQUEST,
radius_client_get_id(hapd->radius));
@@ -159,6 +160,14 @@ static struct radius_msg * accounting_msg(struct hostapd_data *hapd,
}
}
+ os_get_time(&now);
+ if (now.sec > 1000000000 &&
+ !radius_msg_add_attr_int32(msg, RADIUS_ATTR_EVENT_TIMESTAMP,
+ now.sec)) {
+ wpa_printf(MSG_INFO, "Could not add Event-Timestamp");
+ goto fail;
+ }
+
return msg;
fail:
@@ -261,7 +270,6 @@ static void accounting_sta_report(struct hostapd_data *hapd,
int cause = sta->acct_terminate_cause;
struct hostap_sta_driver_data data;
struct os_reltime now_r, diff;
- struct os_time now;
u32 gigawords;
if (!hapd->conf->radius->acct_server)
@@ -276,7 +284,6 @@ static void accounting_sta_report(struct hostapd_data *hapd,
}
os_get_reltime(&now_r);
- os_get_time(&now);
os_reltime_sub(&now_r, &sta->acct_session_start, &diff);
if (!radius_msg_add_attr_int32(msg, RADIUS_ATTR_ACCT_SESSION_TIME,
diff.sec)) {
@@ -333,12 +340,6 @@ static void accounting_sta_report(struct hostapd_data *hapd,
}
}
- if (!radius_msg_add_attr_int32(msg, RADIUS_ATTR_EVENT_TIMESTAMP,
- now.sec)) {
- wpa_printf(MSG_INFO, "Could not add Event-Timestamp");
- goto fail;
- }
-
if (eloop_terminated())
cause = RADIUS_ACCT_TERMINATE_CAUSE_ADMIN_REBOOT;