]> git.ipfire.org Git - thirdparty/hostap.git/commitdiff
Remove references to time_t/time()
authorPer Ekman <pek@kth.se>
Mon, 12 Sep 2011 19:14:30 +0000 (22:14 +0300)
committerJouni Malinen <j@w1.fi>
Mon, 12 Sep 2011 19:14:30 +0000 (22:14 +0300)
Use os_time() in AP mode instead of direct time() calls.

src/ap/accounting.c
src/ap/ieee802_11_auth.c
src/ap/ieee802_1x.c
src/ap/tkip_countermeasures.c

index dbfb058af02fa8fbd9129e15ae2b3d2117394607..03421b350aeee7d867dd88d8dbb37a09aa9284e4 100644 (file)
@@ -236,6 +236,7 @@ static void accounting_interim_update(void *eloop_ctx, void *timeout_ctx)
 void accounting_sta_start(struct hostapd_data *hapd, struct sta_info *sta)
 {
        struct radius_msg *msg;
+       struct os_time t;
        int interval;
 
        if (sta->acct_session_started)
@@ -247,7 +248,8 @@ void accounting_sta_start(struct hostapd_data *hapd, struct sta_info *sta)
                       "starting accounting session %08X-%08X",
                       sta->acct_session_id_hi, sta->acct_session_id_lo);
 
-       time(&sta->acct_session_start);
+       os_get_time(&t);
+       sta->acct_session_start = t.sec;
        sta->last_rx_bytes = sta->last_tx_bytes = 0;
        sta->acct_input_gigawords = sta->acct_output_gigawords = 0;
        hostapd_drv_sta_clear_stats(hapd, sta->addr);
index b933263b0714509e0e2a85ab881b6f987cb91e12..9b558fa1437acf59e9468c9e232a06e3891bc165 100644 (file)
@@ -241,6 +241,7 @@ int hostapd_allowed_address(struct hostapd_data *hapd, const u8 *addr,
                return HOSTAPD_ACL_REJECT;
 #else /* CONFIG_NO_RADIUS */
                struct hostapd_acl_query_data *query;
+               struct os_time t;
 
                /* Check whether ACL cache has an entry for this station */
                int res = hostapd_acl_cache_get(hapd, addr, session_timeout,
@@ -271,7 +272,8 @@ int hostapd_allowed_address(struct hostapd_data *hapd, const u8 *addr,
                        wpa_printf(MSG_ERROR, "malloc for query data failed");
                        return HOSTAPD_ACL_REJECT;
                }
-               time(&query->timestamp);
+               os_get_time(&t);
+               query->timestamp = t.sec;
                os_memcpy(query->addr, addr, ETH_ALEN);
                if (hostapd_radius_acl_query(hapd, addr, query)) {
                        wpa_printf(MSG_DEBUG, "Failed to send Access-Request "
@@ -397,6 +399,7 @@ hostapd_acl_recv_radius(struct radius_msg *msg, struct radius_msg *req,
        struct hostapd_acl_query_data *query, *prev;
        struct hostapd_cached_radius_acl *cache;
        struct radius_hdr *hdr = radius_msg_get_hdr(msg);
+       struct os_time t;
 
        query = hapd->acl_queries;
        prev = NULL;
@@ -431,7 +434,8 @@ hostapd_acl_recv_radius(struct radius_msg *msg, struct radius_msg *req,
                wpa_printf(MSG_DEBUG, "Failed to add ACL cache entry");
                goto done;
        }
-       time(&cache->timestamp);
+       os_get_time(&t);
+       cache->timestamp = t.sec;
        os_memcpy(cache->addr, query->addr, sizeof(cache->addr));
        if (hdr->code == RADIUS_CODE_ACCESS_ACCEPT) {
                if (radius_msg_get_attr_int32(msg, RADIUS_ATTR_SESSION_TIMEOUT,
index ea8ca11476f7de5fb0ebf972ccce18dc7301ce0f..fa7f72bb6009185ae67dca5f7a1cb92c4ed93e3f 100644 (file)
@@ -1923,6 +1923,7 @@ int ieee802_1x_get_mib_sta(struct hostapd_data *hapd, struct sta_info *sta,
 {
        int len = 0, ret;
        struct eapol_state_machine *sm = sta->eapol_sm;
+       struct os_time t;
 
        if (sm == NULL)
                return 0;
@@ -2037,6 +2038,7 @@ int ieee802_1x_get_mib_sta(struct hostapd_data *hapd, struct sta_info *sta,
        len += ret;
 
        /* dot1xAuthSessionStatsTable */
+       os_get_time(&t);
        ret = os_snprintf(buf + len, buflen - len,
                          /* TODO: dot1xAuthSessionOctetsRx */
                          /* TODO: dot1xAuthSessionOctetsTx */
@@ -2051,8 +2053,7 @@ int ieee802_1x_get_mib_sta(struct hostapd_data *hapd, struct sta_info *sta,
                          (wpa_key_mgmt_wpa_ieee8021x(
                                   wpa_auth_sta_key_mgmt(sta->wpa_sm))) ?
                          1 : 2,
-                         (unsigned int) (time(NULL) -
-                                         sta->acct_session_start),
+                         (unsigned int) (t.sec - sta->acct_session_start),
                          sm->identity);
        if (ret < 0 || (size_t) ret >= buflen - len)
                return len;
index 19252171715fc0da6ea13d9e803c3f5a7d96f904..38e0b2b57204304d971bd2ca80e732cc2a079495 100644 (file)
@@ -62,7 +62,7 @@ static void ieee80211_tkip_countermeasures_start(struct hostapd_data *hapd)
 
 void michael_mic_failure(struct hostapd_data *hapd, const u8 *addr, int local)
 {
-       time_t now;
+       struct os_time now;
 
        if (addr && local) {
                struct sta_info *sta = ap_get_sta(hapd, addr);
@@ -82,13 +82,13 @@ void michael_mic_failure(struct hostapd_data *hapd, const u8 *addr, int local)
                }
        }
 
-       time(&now);
-       if (now > hapd->michael_mic_failure + 60) {
+       os_get_time(&now);
+       if (now.sec > hapd->michael_mic_failure + 60) {
                hapd->michael_mic_failures = 1;
        } else {
                hapd->michael_mic_failures++;
                if (hapd->michael_mic_failures > 1)
                        ieee80211_tkip_countermeasures_start(hapd);
        }
-       hapd->michael_mic_failure = now;
+       hapd->michael_mic_failure = now.sec;
 }