aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--src/ap/accounting.c18
-rw-r--r--src/eapol_auth/eapol_auth_sm.c11
-rw-r--r--src/radius/radius.c11
-rw-r--r--src/radius/radius.h2
4 files changed, 21 insertions, 21 deletions
diff --git a/src/ap/accounting.c b/src/ap/accounting.c
index 22684a6..f3ce121 100644
--- a/src/ap/accounting.c
+++ b/src/ap/accounting.c
@@ -379,13 +379,8 @@ void accounting_sta_stop(struct hostapd_data *hapd, struct sta_info *sta)
int accounting_sta_get_id(struct hostapd_data *hapd, struct sta_info *sta)
{
- /*
- * 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.
- */
- return os_get_random((u8 *) &sta->acct_session_id,
- sizeof(sta->acct_session_id));
+ return radius_gen_session_id((u8 *) &sta->acct_session_id,
+ sizeof(sta->acct_session_id));
}
@@ -454,13 +449,8 @@ 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)
+ if (radius_gen_session_id((u8 *) &hapd->acct_session_id,
+ sizeof(hapd->acct_session_id)) < 0)
return -1;
if (radius_client_register(hapd->radius, RADIUS_ACCT,
diff --git a/src/eapol_auth/eapol_auth_sm.c b/src/eapol_auth/eapol_auth_sm.c
index 62db368..ff673bb 100644
--- a/src/eapol_auth/eapol_auth_sm.c
+++ b/src/eapol_auth/eapol_auth_sm.c
@@ -866,16 +866,13 @@ eapol_auth_alloc(struct eapol_authenticator *eapol, const u8 *addr,
sm->radius_cui = wpabuf_alloc_copy(radius_cui,
os_strlen(radius_cui));
- /*
- * Acct-Multi-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 *) &sm->acct_multi_session_id,
- sizeof(sm->acct_multi_session_id)) < 0) {
+#ifndef CONFIG_NO_RADIUS
+ if (radius_gen_session_id((u8 *) &sm->acct_multi_session_id,
+ sizeof(sm->acct_multi_session_id)) < 0) {
eapol_auth_free(sm);
return NULL;
}
+#endif /* CONFIG_NO_RADIUS */
return sm;
}
diff --git a/src/radius/radius.c b/src/radius/radius.c
index d48a4b5..77f9980 100644
--- a/src/radius/radius.c
+++ b/src/radius/radius.c
@@ -1656,3 +1656,14 @@ u8 radius_msg_find_unlisted_attr(struct radius_msg *msg, u8 *attrs)
return 0;
}
+
+
+int radius_gen_session_id(u8 *id, size_t len)
+{
+ /*
+ * Acct-Session-Id and Acct-Multi-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.
+ */
+ return os_get_random(id, len);
+}
diff --git a/src/radius/radius.h b/src/radius/radius.h
index 9218c94..313fc65 100644
--- a/src/radius/radius.h
+++ b/src/radius/radius.h
@@ -319,4 +319,6 @@ int radius_copy_class(struct radius_class_data *dst,
u8 radius_msg_find_unlisted_attr(struct radius_msg *msg, u8 *attrs);
+int radius_gen_session_id(u8 *id, size_t len);
+
#endif /* RADIUS_H */