Replace direct calls in AP mode code with os_*() wrappers.
struct radius_msg *msg;
int cause = sta->acct_terminate_cause;
struct hostap_sta_driver_data data;
+ struct os_time now;
u32 gigawords;
if (!hapd->conf->radius->acct_server)
return;
}
+ os_get_time(&now);
if (!radius_msg_add_attr_int32(msg, RADIUS_ATTR_ACCT_SESSION_TIME,
- time(NULL) - sta->acct_session_start)) {
+ now.sec - sta->acct_session_start)) {
printf("Could not add Acct-Session-Time\n");
goto fail;
}
}
if (!radius_msg_add_attr_int32(msg, RADIUS_ATTR_EVENT_TIMESTAMP,
- time(NULL))) {
+ now.sec)) {
printf("Could not add Event-Timestamp\n");
goto fail;
}
*/
int accounting_init(struct hostapd_data *hapd)
{
+ struct os_time now;
+
/* Acct-Session-Id should be unique over reboots. If reliable clock is
* not available, this could be replaced with reboot counter, etc. */
- hapd->acct_session_id_hi = time(NULL);
+ os_get_time(&now);
+ hapd->acct_session_id_hi = now.sec;
if (radius_client_register(hapd->radius, RADIUS_ACCT,
accounting_receive, hapd))
struct hostapd_frame_info *fi)
{
struct ap_info *ap;
+ struct os_time now;
int new_ap = 0;
size_t len;
int set_beacon = 0;
ap->ht_support = 0;
ap->num_beacons++;
- time(&ap->last_beacon);
+ os_get_time(&now);
+ ap->last_beacon = now.sec;
if (fi) {
ap->ssi_signal = fi->ssi_signal;
ap->datarate = fi->datarate;
static void ap_list_timer(void *eloop_ctx, void *timeout_ctx)
{
struct hostapd_iface *iface = eloop_ctx;
- time_t now;
+ struct os_time now;
struct ap_info *ap;
int set_beacon = 0;
if (!iface->ap_list)
return;
- time(&now);
+ os_get_time(&now);
while (iface->ap_list) {
ap = iface->ap_list->prev;
if (ap->last_beacon + iface->conf->ap_table_expiration_time >=
- now)
+ now.sec)
break;
ap_free_ap(iface, ap);
int ht_support;
unsigned int num_beacons; /* number of beacon frames received */
- time_t last_beacon;
+ os_time_t last_beacon;
int already_seen; /* whether API call AP-NEW has already fetched
* information about this AP */
if (!sta->challenge) {
/* Generate a pseudo-random challenge */
u8 key[8];
- time_t now;
+ struct os_time now;
int r;
sta->challenge = os_zalloc(WLAN_AUTH_CHALLENGE_LEN);
if (sta->challenge == NULL)
return WLAN_STATUS_UNSPECIFIED_FAILURE;
- now = time(NULL);
- r = random();
- os_memcpy(key, &now, 4);
+ os_get_time(&now);
+ r = os_random();
+ os_memcpy(key, &now.sec, 4);
os_memcpy(key + 4, &r, 4);
rc4_skip(key, sizeof(key), 0,
sta->challenge, WLAN_AUTH_CHALLENGE_LEN);
struct hostapd_cached_radius_acl {
- time_t timestamp;
+ os_time_t timestamp;
macaddr addr;
int accepted; /* HOSTAPD_ACL_* */
struct hostapd_cached_radius_acl *next;
struct hostapd_acl_query_data {
- time_t timestamp;
+ os_time_t timestamp;
u8 radius_id;
macaddr addr;
u8 *auth_msg; /* IEEE 802.11 authentication frame from station */
u32 *acct_interim_interval, int *vlan_id)
{
struct hostapd_cached_radius_acl *entry;
- time_t now;
+ struct os_time now;
- time(&now);
+ os_get_time(&now);
entry = hapd->acl_cache;
while (entry) {
if (os_memcmp(entry->addr, addr, ETH_ALEN) == 0) {
- if (now - entry->timestamp > RADIUS_ACL_TIMEOUT)
+ if (now.sec - entry->timestamp > RADIUS_ACL_TIMEOUT)
return -1; /* entry has expired */
if (entry->accepted == HOSTAPD_ACL_ACCEPT_TIMEOUT)
if (session_timeout)
#ifndef CONFIG_NO_RADIUS
-static void hostapd_acl_expire_cache(struct hostapd_data *hapd, time_t now)
+static void hostapd_acl_expire_cache(struct hostapd_data *hapd, os_time_t now)
{
struct hostapd_cached_radius_acl *prev, *entry, *tmp;
}
-static void hostapd_acl_expire_queries(struct hostapd_data *hapd, time_t now)
+static void hostapd_acl_expire_queries(struct hostapd_data *hapd,
+ os_time_t now)
{
struct hostapd_acl_query_data *prev, *entry, *tmp;
static void hostapd_acl_expire(void *eloop_ctx, void *timeout_ctx)
{
struct hostapd_data *hapd = eloop_ctx;
- time_t now;
+ struct os_time now;
- time(&now);
- hostapd_acl_expire_cache(hapd, now);
- hostapd_acl_expire_queries(hapd, now);
+ os_get_time(&now);
+ hostapd_acl_expire_cache(hapd, now.sec);
+ hostapd_acl_expire_queries(hapd, now.sec);
eloop_register_timeout(10, 0, hostapd_acl_expire, hapd, NULL);
}