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));
}
*/
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,
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;
}
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);
+}