aboutsummaryrefslogtreecommitdiffstats
path: root/src/ap/accounting.c
diff options
context:
space:
mode:
authorNick Lowe <nick.lowe@lugatech.com>2016-01-25 10:43:33 (GMT)
committerJouni Malinen <j@w1.fi>2016-02-06 15:11:01 (GMT)
commit4260e1a1ff148af48c6676413cf210c898e8aa0b (patch)
tree41a51b60a6aa548c8120f196d8d25f45cfd42afd /src/ap/accounting.c
parentd72a00539ca793ecd3137ae308bc173271d8b882 (diff)
downloadhostap-4260e1a1ff148af48c6676413cf210c898e8aa0b.zip
hostap-4260e1a1ff148af48c6676413cf210c898e8aa0b.tar.gz
hostap-4260e1a1ff148af48c6676413cf210c898e8aa0b.tar.bz2
Add Acct-Session-Id to Accounting-On/Off
An Acct-Session-Id is required on Accounting-On and Accounting-Off forms of Accounting-Request. Signed-off-by: Nick Lowe <nick.lowe@lugatech.com>
Diffstat (limited to 'src/ap/accounting.c')
-rw-r--r--src/ap/accounting.c19
1 files changed, 19 insertions, 0 deletions
diff --git a/src/ap/accounting.c b/src/ap/accounting.c
index 962a869..87ab5f9 100644
--- a/src/ap/accounting.c
+++ b/src/ap/accounting.c
@@ -448,6 +448,16 @@ static void accounting_report_state(struct hostapd_data *hapd, int on)
if (!msg)
return;
+ if (hapd->acct_session_id) {
+ char buf[20];
+
+ os_snprintf(buf, sizeof(buf), "%016lX",
+ (long unsigned int) hapd->acct_session_id);
+ if (!radius_msg_add_attr(msg, RADIUS_ATTR_ACCT_SESSION_ID,
+ (u8 *) buf, os_strlen(buf)))
+ wpa_printf(MSG_ERROR, "Could not add Acct-Session-Id");
+ }
+
if (radius_client_send(hapd->radius, msg, RADIUS_ACCT, NULL) < 0)
radius_msg_free(msg);
}
@@ -460,6 +470,15 @@ static void accounting_report_state(struct hostapd_data *hapd, int on)
*/
int accounting_init(struct hostapd_data *hapd)
{
+ /*
+ * Acct-Session-Id should be globally and temporarily unique.
+ * A high quality random number is required therefore.
+ * This could be be improved by switching to a GUID.
+ */
+ if (os_get_random((u8 *) &hapd->acct_session_id,
+ sizeof(hapd->acct_session_id)) < 0)
+ return -1;
+
if (radius_client_register(hapd->radius, RADIUS_ACCT,
accounting_receive, hapd))
return -1;