static void radius_client_timer(void *eloop_ctx, void *timeout_ctx) { struct radius_client_data *radius = eloop_ctx; struct os_reltime now; os_time_t first; struct radius_msg_list *entry, *prev, *tmp; int auth_failover = 0, acct_failover = 0; size_t prev_num_msgs; int s; entry = radius->msgs; if (!entry) return; os_get_reltime(&now); first = 0; prev = NULL; while (entry) { prev_num_msgs = radius->num_msgs; if (now.sec >= entry->next_try && radius_client_retransmit(radius, entry, now.sec)) { if (prev) prev->next = entry->next; else radius->msgs = entry->next; tmp = entry; entry = entry->next; radius_client_msg_free(tmp); radius->num_msgs--; continue; } if (prev_num_msgs != radius->num_msgs) { wpa_printf(MSG_DEBUG, "RADIUS: Message removed from queue - restart from beginning"); entry = radius->msgs; prev = NULL; continue; } s = entry->msg_type == RADIUS_AUTH ? radius->auth_sock : radius->acct_sock; if (entry->attempts > RADIUS_CLIENT_NUM_FAILOVER || (s < 0 && entry->attempts > 0)) { if (entry->msg_type == RADIUS_ACCT || entry->msg_type == RADIUS_ACCT_INTERIM) acct_failover++; else auth_failover++; } if (first == 0 || entry->next_try < first) first = entry->next_try; prev = entry; entry = entry->next; } if (radius->msgs) { if (first < now.sec) first = now.sec; eloop_register_timeout(first - now.sec, 0, radius_client_timer, radius, NULL); hostapd_logger(radius->ctx, NULL, HOSTAPD_MODULE_RADIUS, HOSTAPD_LEVEL_DEBUG, "Next RADIUS client " "retransmit in %ld seconds", (long int) (first - now.sec)); } if (auth_failover) radius_client_auth_failover(radius); if (acct_failover) radius_client_acct_failover(radius); }
static void radius_client_timer(void *eloop_ctx, void *timeout_ctx) { struct radius_client_data *radius = eloop_ctx; struct hostapd_data *hapd = radius->hapd; time_t now, first; struct radius_msg_list *entry, *prev, *tmp; int auth_failover = 0, acct_failover = 0; entry = radius->msgs; if (!entry) return; time(&now); first = 0; prev = NULL; while (entry) { if (now >= entry->next_try && radius_client_retransmit(radius, entry, now)) { if (prev) prev->next = entry->next; else radius->msgs = entry->next; tmp = entry; entry = entry->next; radius_client_msg_free(tmp); radius->num_msgs--; continue; } if (entry->attempts > RADIUS_CLIENT_NUM_FAILOVER) { if (entry->msg_type == RADIUS_ACCT || entry->msg_type == RADIUS_ACCT_INTERIM) acct_failover++; else auth_failover++; } if (first == 0 || entry->next_try < first) first = entry->next_try; prev = entry; entry = entry->next; } if (radius->msgs) { if (first < now) first = now; eloop_register_timeout(first - now, 0, radius_client_timer, radius, NULL); HOSTAPD_DEBUG(HOSTAPD_DEBUG_MINIMAL, "Next RADIUS client " "retransmit in %ld seconds\n", (long int) (first - now)); } if (auth_failover && hapd->conf->num_auth_servers > 1) { struct hostapd_radius_server *next, *old; old = hapd->conf->auth_server; hostapd_logger(hapd, NULL, HOSTAPD_MODULE_RADIUS, HOSTAPD_LEVEL_NOTICE, "No response from Authentication server " "%s:%d - failover", inet_ntoa(old->addr), old->port); for (entry = radius->msgs; entry; entry = entry->next) { if (entry->msg_type == RADIUS_AUTH) old->timeouts++; } next = old + 1; if (next > &(hapd->conf->auth_servers [hapd->conf->num_auth_servers - 1])) next = hapd->conf->auth_servers; hapd->conf->auth_server = next; radius_change_server(radius, next, old, radius->auth_serv_sock, 1); } if (acct_failover && hapd->conf->num_acct_servers > 1) { struct hostapd_radius_server *next, *old; old = hapd->conf->acct_server; hostapd_logger(hapd, NULL, HOSTAPD_MODULE_RADIUS, HOSTAPD_LEVEL_NOTICE, "No response from Accounting server " "%s:%d - failover", inet_ntoa(old->addr), old->port); for (entry = radius->msgs; entry; entry = entry->next) { if (entry->msg_type == RADIUS_ACCT || entry->msg_type == RADIUS_ACCT_INTERIM) old->timeouts++; } next = old + 1; if (next > &hapd->conf->acct_servers [hapd->conf->num_acct_servers - 1]) next = hapd->conf->acct_servers; hapd->conf->acct_server = next; radius_change_server(radius, next, old, radius->acct_serv_sock, 0); } }
static void radius_client_timer(void *eloop_ctx, void *timeout_ctx) { struct radius_client_data *radius = eloop_ctx; struct hostapd_radius_servers *conf = radius->conf; struct os_time now; os_time_t first; struct radius_msg_list *entry, *prev, *tmp; int auth_failover = 0, acct_failover = 0; char abuf[50]; entry = radius->msgs; if (!entry) return; os_get_time(&now); first = 0; prev = NULL; while (entry) { if (now.sec >= entry->next_try && radius_client_retransmit(radius, entry, now.sec)) { if (prev) prev->next = entry->next; else radius->msgs = entry->next; tmp = entry; entry = entry->next; radius_client_msg_free(tmp); radius->num_msgs--; continue; } if (entry->attempts > RADIUS_CLIENT_NUM_FAILOVER) { if (entry->msg_type == RADIUS_ACCT || entry->msg_type == RADIUS_ACCT_INTERIM) acct_failover++; else auth_failover++; } if (first == 0 || entry->next_try < first) first = entry->next_try; prev = entry; entry = entry->next; } if (radius->msgs) { if (first < now.sec) first = now.sec; eloop_register_timeout(first - now.sec, 0, radius_client_timer, radius, NULL); hostapd_logger(radius->ctx, NULL, HOSTAPD_MODULE_RADIUS, HOSTAPD_LEVEL_DEBUG, "Next RADIUS client " "retransmit in %ld seconds", (long int) (first - now.sec)); } if (auth_failover && conf->num_auth_servers > 1) { struct hostapd_radius_server *next, *old; old = conf->auth_server; hostapd_logger(radius->ctx, NULL, HOSTAPD_MODULE_RADIUS, HOSTAPD_LEVEL_NOTICE, "No response from Authentication server " "%s:%d - failover", hostapd_ip_txt(&old->addr, abuf, sizeof(abuf)), old->port); for (entry = radius->msgs; entry; entry = entry->next) { if (entry->msg_type == RADIUS_AUTH) old->timeouts++; } next = old + 1; if (next > &(conf->auth_servers[conf->num_auth_servers - 1])) next = conf->auth_servers; conf->auth_server = next; radius_change_server(radius, next, old, radius->auth_serv_sock, radius->auth_serv_sock6, 1); } if (acct_failover && conf->num_acct_servers > 1) { struct hostapd_radius_server *next, *old; old = conf->acct_server; hostapd_logger(radius->ctx, NULL, HOSTAPD_MODULE_RADIUS, HOSTAPD_LEVEL_NOTICE, "No response from Accounting server " "%s:%d - failover", hostapd_ip_txt(&old->addr, abuf, sizeof(abuf)), old->port); for (entry = radius->msgs; entry; entry = entry->next) { if (entry->msg_type == RADIUS_ACCT || entry->msg_type == RADIUS_ACCT_INTERIM) old->timeouts++; } next = old + 1; if (next > &conf->acct_servers[conf->num_acct_servers - 1]) next = conf->acct_servers; conf->acct_server = next; radius_change_server(radius, next, old, radius->acct_serv_sock, radius->acct_serv_sock6, 0); } }
static void radius_client_timer(void *eloop_ctx, void *timeout_ctx) { struct wpa_supplicant *wpa_s = eloop_ctx; time_t now, first; struct radius_msg_list *entry, *prev, *tmp; int auth_failover = 0, acct_failover = 0; entry = wpa_s->radius->msgs; if (!entry) return; time(&now); first = 0; prev = NULL; while (entry) { if (now >= entry->next_try && radius_client_retransmit(wpa_s, entry, now)) { if (prev) prev->next = entry->next; else wpa_s->radius->msgs = entry->next; tmp = entry; entry = entry->next; radius_client_msg_free(tmp); wpa_s->radius->num_msgs--; continue; } if (entry->attempts > RADIUS_CLIENT_NUM_FAILOVER) { if (entry->msg_type == RADIUS_ACCT || entry->msg_type == RADIUS_ACCT_INTERIM) acct_failover++; else auth_failover++; } if (first == 0 || entry->next_try < first) first = entry->next_try; prev = entry; entry = entry->next; } if (wpa_s->radius->msgs) { if (first < now) first = now; eloop_register_timeout(first - now, 0, radius_client_timer, wpa_s, NULL); } if (auth_failover && wpa_s->num_auth_servers > 1) { struct hostapd_radius_server *next, *old; old = wpa_s->auth_server; hostapd_logger(wpa_s, NULL, HOSTAPD_MODULE_RADIUS, HOSTAPD_LEVEL_NOTICE, "No response from Authentication server " "%s:%d - failover", inet_ntoa(old->addr), old->port); next = old + 1; if (next > &(wpa_s->auth_servers [wpa_s->num_auth_servers - 1])) next = wpa_s->auth_servers; wpa_s->auth_server = next; radius_change_server(wpa_s, next, old, wpa_s->radius->auth_serv_sock, 1); } if (acct_failover && wpa_s->num_acct_servers > 1) { struct hostapd_radius_server *next, *old; old = wpa_s->acct_server; hostapd_logger(wpa_s, NULL, HOSTAPD_MODULE_RADIUS, HOSTAPD_LEVEL_NOTICE, "No response from Accounting server " "%s:%d - failover", inet_ntoa(old->addr), old->port); next = old + 1; if (next > &wpa_s->acct_servers [wpa_s->num_acct_servers - 1]) next = wpa_s->acct_servers; wpa_s->acct_server = next; radius_change_server(wpa_s, next, old, wpa_s->radius->acct_serv_sock, 0); } }