diff --git a/hostapd/accounting.c b/hostapd/accounting.c index 7fda7bcec..eb766b7a4 100644 --- a/hostapd/accounting.c +++ b/hostapd/accounting.c @@ -1,6 +1,6 @@ /* * hostapd / RADIUS Accounting - * Copyright (c) 2002-2007, Jouni Malinen + * Copyright (c) 2002-2008, Jouni Malinen * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License version 2 as @@ -32,6 +32,9 @@ const char *radius_mode_txt(struct hostapd_data *hapd); int radius_sta_rate(struct hostapd_data *hapd, struct sta_info *sta); +static void accounting_sta_get_id(struct hostapd_data *hapd, + struct sta_info *sta); + static struct radius_msg * accounting_msg(struct hostapd_data *hapd, struct sta_info *sta, @@ -234,6 +237,12 @@ void accounting_sta_start(struct hostapd_data *hapd, struct sta_info *sta) if (sta->acct_session_started) return; + accounting_sta_get_id(hapd, sta); + hostapd_logger(hapd, sta->addr, HOSTAPD_MODULE_RADIUS, + HOSTAPD_LEVEL_INFO, + "starting accounting session %08X-%08X", + sta->acct_session_id_hi, sta->acct_session_id_lo); + time(&sta->acct_session_start); sta->last_rx_bytes = sta->last_tx_bytes = 0; sta->acct_input_gigawords = sta->acct_output_gigawords = 0; @@ -370,12 +379,18 @@ void accounting_sta_stop(struct hostapd_data *hapd, struct sta_info *sta) if (sta->acct_session_started) { accounting_sta_report(hapd, sta, 1); eloop_cancel_timeout(accounting_interim_update, hapd, sta); + hostapd_logger(hapd, sta->addr, HOSTAPD_MODULE_RADIUS, + HOSTAPD_LEVEL_INFO, + "stopped accounting session %08X-%08X", + sta->acct_session_id_hi, + sta->acct_session_id_lo); sta->acct_session_started = 0; } } -void accounting_sta_get_id(struct hostapd_data *hapd, struct sta_info *sta) +static void accounting_sta_get_id(struct hostapd_data *hapd, + struct sta_info *sta) { sta->acct_session_id_lo = hapd->acct_session_id_lo++; if (hapd->acct_session_id_lo == 0) { diff --git a/hostapd/accounting.h b/hostapd/accounting.h index ee2ee64e3..51e6b4d49 100644 --- a/hostapd/accounting.h +++ b/hostapd/accounting.h @@ -18,7 +18,6 @@ void accounting_sta_start(struct hostapd_data *hapd, struct sta_info *sta); void accounting_sta_interim(struct hostapd_data *hapd, struct sta_info *sta); void accounting_sta_stop(struct hostapd_data *hapd, struct sta_info *sta); -void accounting_sta_get_id(struct hostapd_data *hapd, struct sta_info *sta); int accounting_init(struct hostapd_data *hapd); void accounting_deinit(struct hostapd_data *hapd); int accounting_reconfig(struct hostapd_data *hapd, diff --git a/hostapd/ctrl_iface.c b/hostapd/ctrl_iface.c index 781c9f33b..b978f9618 100644 --- a/hostapd/ctrl_iface.c +++ b/hostapd/ctrl_iface.c @@ -213,7 +213,6 @@ static int hostapd_ctrl_iface_new_sta(struct hostapd_data *hapd, return -1; hostapd_new_assoc_sta(hapd, sta, 0); - accounting_sta_get_id(hapd, sta); return 0; } diff --git a/hostapd/driver_madwifi.c b/hostapd/driver_madwifi.c index 9ddd03322..d7d604106 100644 --- a/hostapd/driver_madwifi.c +++ b/hostapd/driver_madwifi.c @@ -831,7 +831,6 @@ madwifi_new_sta(struct madwifi_driver_data *drv, u8 addr[IEEE80211_ADDR_LEN]) memset(drv->acct_mac, 0, ETH_ALEN); memset(&drv->acct_data, 0, sizeof(drv->acct_data)); } - accounting_sta_get_id(hapd, sta); if (hapd->conf->wpa) { if (madwifi_process_wpa_ie(drv, sta)) diff --git a/hostapd/driver_test.c b/hostapd/driver_test.c index 64380e980..fb7bf058d 100644 --- a/hostapd/driver_test.c +++ b/hostapd/driver_test.c @@ -410,7 +410,6 @@ static int test_driver_new_sta(struct test_driver_data *drv, if (sta == NULL) return -1; } - accounting_sta_get_id(hapd, sta); if (hapd->conf->wpa) { if (ie == NULL || ielen == 0) { diff --git a/hostapd/driver_wired.c b/hostapd/driver_wired.c index ab9707128..61cb667cc 100644 --- a/hostapd/driver_wired.c +++ b/hostapd/driver_wired.c @@ -85,7 +85,6 @@ static void wired_possible_new_sta(struct hostapd_data *hapd, u8 *addr) sta = ap_sta_add(hapd, addr); if (sta) { hostapd_new_assoc_sta(hapd, sta, 0); - accounting_sta_get_id(hapd, sta); } else { wpa_printf(MSG_DEBUG, "Failed to add STA entry for " MACSTR, MAC2STR(addr)); diff --git a/hostapd/ieee802_11.c b/hostapd/ieee802_11.c index 4b50217a2..19dd6809d 100644 --- a/hostapd/ieee802_11.c +++ b/hostapd/ieee802_11.c @@ -1461,13 +1461,11 @@ static void handle_assoc_cb(struct hostapd_data *hapd, /* Stop previous accounting session, if one is started, and allocate * new session id for the new session. */ accounting_sta_stop(hapd, sta); - accounting_sta_get_id(hapd, sta); hostapd_logger(hapd, sta->addr, HOSTAPD_MODULE_IEEE80211, HOSTAPD_LEVEL_INFO, - "associated (aid %d, accounting session %08X-%08X)", - sta->aid, sta->acct_session_id_hi, - sta->acct_session_id_lo); + "associated (aid %d)", + sta->aid); if (sta->flags & WLAN_STA_ASSOC) new_assoc = 0; diff --git a/hostapd/ieee802_1x.c b/hostapd/ieee802_1x.c index 9d331ae51..59c2d8c7a 100644 --- a/hostapd/ieee802_1x.c +++ b/hostapd/ieee802_1x.c @@ -767,7 +767,6 @@ void ieee802_1x_receive(struct hostapd_data *hapd, const u8 *sa, const u8 *buf, sta->acct_terminate_cause = RADIUS_ACCT_TERMINATE_CAUSE_USER_REQUEST; accounting_sta_stop(hapd, sta); - accounting_sta_get_id(hapd, sta); sta->eapol_sm->eapolLogoff = TRUE; sta->eapol_sm->dot1xAuthEapolLogoffFramesRx++; break;