Lines Matching +full:update +full:- +full:interval

3  * Copyright (c) 2002-2009, 2012-2015, Jouni Malinen <j@w1.fi>
25 /* Default interval in seconds for polling TX/RX octets from the driver if
27 * input/output octets and updates Acct-{Input,Output}-Gigawords. */
47 radius_client_get_id(hapd->radius)); in accounting_msg()
55 wpa_printf(MSG_INFO, "Could not add Acct-Status-Type"); in accounting_msg()
61 hapd->conf->radius_acct_req_attr, in accounting_msg()
64 hapd->conf->ieee802_1x ? in accounting_msg()
67 wpa_printf(MSG_INFO, "Could not add Acct-Authentic"); in accounting_msg()
72 val = ieee802_1x_get_identity(sta->eapol_sm, &len); in accounting_msg()
75 if (!val && sta->identity) { in accounting_msg()
76 val = (u8 *) sta->identity; in accounting_msg()
77 len = os_strlen(sta->identity); in accounting_msg()
84 MAC2STR(sta->addr)); in accounting_msg()
91 wpa_printf(MSG_INFO, "Could not add User-Name"); in accounting_msg()
96 if (add_common_radius_attr(hapd, hapd->conf->radius_acct_req_attr, sta, in accounting_msg()
105 val = ieee802_1x_get_radius_class(sta->eapol_sm, &len, in accounting_msg()
117 b = ieee802_1x_get_radius_cui(sta->eapol_sm); in accounting_msg()
126 if (!b && sta->radius_cui && in accounting_msg()
129 (u8 *) sta->radius_cui, in accounting_msg()
130 os_strlen(sta->radius_cui))) { in accounting_msg()
135 if (sta->ipaddr && in accounting_msg()
138 be_to_host32(sta->ipaddr))) { in accounting_msg()
140 "Could not add Framed-IP-Address"); in accounting_msg()
149 wpa_printf(MSG_INFO, "Could not add Event-Timestamp"); in accounting_msg()
154 * Add Acct-Delay-Time with zero value for the first transmission. This in accounting_msg()
158 wpa_printf(MSG_INFO, "Could not add Acct-Delay-Time"); in accounting_msg()
174 if (hostapd_drv_read_sta_data(hapd, data, sta->addr)) in accounting_sta_update_stats()
175 return -1; in accounting_sta_update_stats()
177 if (!data->bytes_64bit) { in accounting_sta_update_stats()
178 /* Extend 32-bit counters from the driver to 64-bit counters */ in accounting_sta_update_stats()
179 if (sta->last_rx_bytes_lo > data->rx_bytes) in accounting_sta_update_stats()
180 sta->last_rx_bytes_hi++; in accounting_sta_update_stats()
181 sta->last_rx_bytes_lo = data->rx_bytes; in accounting_sta_update_stats()
183 if (sta->last_tx_bytes_lo > data->tx_bytes) in accounting_sta_update_stats()
184 sta->last_tx_bytes_hi++; in accounting_sta_update_stats()
185 sta->last_tx_bytes_lo = data->tx_bytes; in accounting_sta_update_stats()
188 hostapd_logger(hapd, sta->addr, HOSTAPD_MODULE_RADIUS, in accounting_sta_update_stats()
191 data->rx_bytes, sta->last_rx_bytes_hi, in accounting_sta_update_stats()
192 sta->last_rx_bytes_lo, in accounting_sta_update_stats()
193 data->tx_bytes, sta->last_tx_bytes_hi, in accounting_sta_update_stats()
194 sta->last_tx_bytes_lo, in accounting_sta_update_stats()
195 data->bytes_64bit); in accounting_sta_update_stats()
205 int interval; in accounting_interim_update() local
207 if (sta->acct_interim_interval) { in accounting_interim_update()
209 interval = sta->acct_interim_interval; in accounting_interim_update()
213 interval = ACCT_DEFAULT_UPDATE_INTERVAL; in accounting_interim_update()
216 eloop_register_timeout(interval, 0, accounting_interim_update, in accounting_interim_update()
222 * accounting_sta_start - Start STA accounting
229 int interval; in accounting_sta_start() local
231 if (sta->acct_session_started) in accounting_sta_start()
234 hostapd_logger(hapd, sta->addr, HOSTAPD_MODULE_RADIUS, in accounting_sta_start()
237 (unsigned long long) sta->acct_session_id); in accounting_sta_start()
239 os_get_reltime(&sta->acct_session_start); in accounting_sta_start()
240 sta->last_rx_bytes_hi = 0; in accounting_sta_start()
241 sta->last_rx_bytes_lo = 0; in accounting_sta_start()
242 sta->last_tx_bytes_hi = 0; in accounting_sta_start()
243 sta->last_tx_bytes_lo = 0; in accounting_sta_start()
244 hostapd_drv_sta_clear_stats(hapd, sta->addr); in accounting_sta_start()
246 if (!hapd->conf->radius->acct_server) in accounting_sta_start()
249 if (sta->acct_interim_interval) in accounting_sta_start()
250 interval = sta->acct_interim_interval; in accounting_sta_start()
252 interval = ACCT_DEFAULT_UPDATE_INTERVAL; in accounting_sta_start()
253 eloop_register_timeout(interval, 0, accounting_interim_update, in accounting_sta_start()
258 radius_client_send(hapd->radius, msg, RADIUS_ACCT, sta->addr) < 0) in accounting_sta_start()
261 sta->acct_session_started = 1; in accounting_sta_start()
269 int cause = sta->acct_terminate_cause; in accounting_sta_report()
274 if (!hapd->conf->radius->acct_server) in accounting_sta_report()
286 os_reltime_sub(&now_r, &sta->acct_session_start, &diff); in accounting_sta_report()
289 wpa_printf(MSG_INFO, "Could not add Acct-Session-Time"); in accounting_sta_report()
297 wpa_printf(MSG_INFO, "Could not add Acct-Input-Packets"); in accounting_sta_report()
303 wpa_printf(MSG_INFO, "Could not add Acct-Output-Packets"); in accounting_sta_report()
309 bytes = ((u64) sta->last_rx_bytes_hi << 32) | in accounting_sta_report()
310 sta->last_rx_bytes_lo; in accounting_sta_report()
314 wpa_printf(MSG_INFO, "Could not add Acct-Input-Octets"); in accounting_sta_report()
320 wpa_printf(MSG_INFO, "Could not add Acct-Input-Gigawords"); in accounting_sta_report()
326 bytes = ((u64) sta->last_tx_bytes_hi << 32) | in accounting_sta_report()
327 sta->last_tx_bytes_lo; in accounting_sta_report()
331 wpa_printf(MSG_INFO, "Could not add Acct-Output-Octets"); in accounting_sta_report()
337 wpa_printf(MSG_INFO, "Could not add Acct-Output-Gigawords"); in accounting_sta_report()
348 wpa_printf(MSG_INFO, "Could not add Acct-Terminate-Cause"); in accounting_sta_report()
352 if (radius_client_send(hapd->radius, msg, in accounting_sta_report()
354 sta->addr) < 0) in accounting_sta_report()
364 * accounting_sta_interim - Send a interim STA accounting report
371 if (sta->acct_session_started) in accounting_sta_interim()
377 * accounting_sta_stop - Stop STA accounting
383 if (sta->acct_session_started) { in accounting_sta_stop()
386 hostapd_logger(hapd, sta->addr, HOSTAPD_MODULE_RADIUS, in accounting_sta_stop()
389 (unsigned long long) sta->acct_session_id); in accounting_sta_stop()
390 sta->acct_session_started = 0; in accounting_sta_stop()
397 return radius_gen_session_id((u8 *) &sta->acct_session_id, in accounting_sta_get_id()
398 sizeof(sta->acct_session_id)); in accounting_sta_get_id()
403 * accounting_receive - Process the RADIUS frames from Accounting Server
416 if (radius_msg_get_hdr(msg)->code != RADIUS_CODE_ACCOUNTING_RESPONSE) { in accounting_receive()
422 wpa_printf(MSG_INFO, "Incoming RADIUS packet did not have correct Authenticator - dropped"); in accounting_receive()
434 if (!hapd->conf->radius->acct_server || hapd->radius == NULL) in accounting_report_state()
445 if (hapd->acct_session_id) { in accounting_report_state()
449 (unsigned long long) hapd->acct_session_id); in accounting_report_state()
452 wpa_printf(MSG_ERROR, "Could not add Acct-Session-Id"); in accounting_report_state()
455 if (radius_client_send(hapd->radius, msg, RADIUS_ACCT, NULL) < 0) in accounting_report_state()
470 sta->acct_interim_errors++; in accounting_interim_error_cb()
471 if (sta->acct_interim_errors > 10 /* RADIUS_CLIENT_MAX_RETRIES */) { in accounting_interim_error_cb()
473 "Interim RADIUS accounting update failed for " MACSTR in accounting_interim_error_cb()
474 " - too many errors, abandon this interim accounting update", in accounting_interim_error_cb()
476 sta->acct_interim_errors = 0; in accounting_interim_error_cb()
477 /* Next update will be tried after normal update interval */ in accounting_interim_error_cb()
482 * Use a shorter update interval as an improved retransmission mechanism in accounting_interim_error_cb()
490 if (sta->acct_interim_errors == 1) { in accounting_interim_error_cb()
494 for (i = 1; i < sta->acct_interim_errors; i++) in accounting_interim_error_cb()
501 "Interim RADIUS accounting update failed for " MACSTR in accounting_interim_error_cb()
502 " (error count: %u) - schedule next update in %u seconds", in accounting_interim_error_cb()
503 MAC2STR(addr), sta->acct_interim_errors, wait_time); in accounting_interim_error_cb()
506 "Interim RADIUS accounting update failed for " MACSTR in accounting_interim_error_cb()
508 sta->acct_interim_errors); in accounting_interim_error_cb()
511 "Interim RADIUS accounting update failed for " MACSTR in accounting_interim_error_cb()
512 " (error count: %u) - no timer found", MAC2STR(addr), in accounting_interim_error_cb()
513 sta->acct_interim_errors); in accounting_interim_error_cb()
520 * Returns: 0 on success, -1 on failure
524 if (radius_gen_session_id((u8 *) &hapd->acct_session_id, in accounting_init()
525 sizeof(hapd->acct_session_id)) < 0) in accounting_init()
526 return -1; in accounting_init()
528 if (radius_client_register(hapd->radius, RADIUS_ACCT, in accounting_init()
530 return -1; in accounting_init()
531 radius_client_set_interim_error_cb(hapd->radius, in accounting_init()