Lines Matching refs:radius

233 radius_change_server(struct radius_client_data *radius,
237 static int radius_client_init_acct(struct radius_client_data *radius);
238 static int radius_client_init_auth(struct radius_client_data *radius);
239 static void radius_client_auth_failover(struct radius_client_data *radius);
240 static void radius_client_acct_failover(struct radius_client_data *radius);
266 int radius_client_register(struct radius_client_data *radius, in radius_client_register() argument
279 handlers = &radius->acct_handlers; in radius_client_register()
280 num = &radius->num_acct_handlers; in radius_client_register()
282 handlers = &radius->auth_handlers; in radius_client_register()
283 num = &radius->num_auth_handlers; in radius_client_register()
304 static int radius_client_handle_send_error(struct radius_client_data *radius, in radius_client_handle_send_error() argument
312 hostapd_logger(radius->ctx, NULL, HOSTAPD_MODULE_RADIUS, in radius_client_handle_send_error()
318 radius_client_init_acct(radius); in radius_client_handle_send_error()
321 radius_client_init_auth(radius); in radius_client_handle_send_error()
331 static int radius_client_retransmit(struct radius_client_data *radius, in radius_client_retransmit() argument
335 struct hostapd_radius_servers *conf = radius->conf; in radius_client_retransmit()
342 if (radius->acct_sock < 0) in radius_client_retransmit()
343 radius_client_init_acct(radius); in radius_client_retransmit()
344 if (radius->acct_sock < 0 && conf->num_acct_servers > 1) { in radius_client_retransmit()
345 prev_num_msgs = radius->num_msgs; in radius_client_retransmit()
346 radius_client_acct_failover(radius); in radius_client_retransmit()
347 if (prev_num_msgs != radius->num_msgs) in radius_client_retransmit()
350 s = radius->acct_sock; in radius_client_retransmit()
358 if (radius->auth_sock < 0) in radius_client_retransmit()
359 radius_client_init_auth(radius); in radius_client_retransmit()
360 if (radius->auth_sock < 0 && conf->num_auth_servers > 1) { in radius_client_retransmit()
361 prev_num_msgs = radius->num_msgs; in radius_client_retransmit()
362 radius_client_auth_failover(radius); in radius_client_retransmit()
363 if (prev_num_msgs != radius->num_msgs) in radius_client_retransmit()
366 s = radius->auth_sock; in radius_client_retransmit()
382 hostapd_logger(radius->ctx, entry->addr, HOSTAPD_MODULE_RADIUS, in radius_client_retransmit()
389 if (radius_client_handle_send_error(radius, s, entry->msg_type) in radius_client_retransmit()
409 struct radius_client_data *radius = eloop_ctx; in radius_client_timer() local
410 struct hostapd_radius_servers *conf = radius->conf; in radius_client_timer()
418 entry = radius->msgs; in radius_client_timer()
427 prev_num_msgs = radius->num_msgs; in radius_client_timer()
429 radius_client_retransmit(radius, entry, now.sec)) { in radius_client_timer()
433 radius->msgs = entry->next; in radius_client_timer()
438 radius->num_msgs--; in radius_client_timer()
442 if (prev_num_msgs != radius->num_msgs) { in radius_client_timer()
445 entry = radius->msgs; in radius_client_timer()
450 s = entry->msg_type == RADIUS_AUTH ? radius->auth_sock : in radius_client_timer()
451 radius->acct_sock; in radius_client_timer()
468 if (radius->msgs) { in radius_client_timer()
472 radius_client_timer, radius, NULL); in radius_client_timer()
473 hostapd_logger(radius->ctx, NULL, HOSTAPD_MODULE_RADIUS, in radius_client_timer()
480 radius_client_auth_failover(radius); in radius_client_timer()
483 radius_client_acct_failover(radius); in radius_client_timer()
487 static void radius_client_auth_failover(struct radius_client_data *radius) in radius_client_auth_failover() argument
489 struct hostapd_radius_servers *conf = radius->conf; in radius_client_auth_failover()
495 hostapd_logger(radius->ctx, NULL, HOSTAPD_MODULE_RADIUS, in radius_client_auth_failover()
501 for (entry = radius->msgs; entry; entry = entry->next) { in radius_client_auth_failover()
510 radius_change_server(radius, next, old, in radius_client_auth_failover()
511 radius->auth_serv_sock, in radius_client_auth_failover()
512 radius->auth_serv_sock6, 1); in radius_client_auth_failover()
516 static void radius_client_acct_failover(struct radius_client_data *radius) in radius_client_acct_failover() argument
518 struct hostapd_radius_servers *conf = radius->conf; in radius_client_acct_failover()
524 hostapd_logger(radius->ctx, NULL, HOSTAPD_MODULE_RADIUS, in radius_client_acct_failover()
530 for (entry = radius->msgs; entry; entry = entry->next) { in radius_client_acct_failover()
540 radius_change_server(radius, next, old, in radius_client_acct_failover()
541 radius->acct_serv_sock, in radius_client_acct_failover()
542 radius->acct_serv_sock6, 0); in radius_client_acct_failover()
546 static void radius_client_update_timeout(struct radius_client_data *radius) in radius_client_update_timeout() argument
552 eloop_cancel_timeout(radius_client_timer, radius, NULL); in radius_client_update_timeout()
554 if (radius->msgs == NULL) { in radius_client_update_timeout()
559 for (entry = radius->msgs; entry; entry = entry->next) { in radius_client_update_timeout()
567 eloop_register_timeout(first - now.sec, 0, radius_client_timer, radius, in radius_client_update_timeout()
569 hostapd_logger(radius->ctx, NULL, HOSTAPD_MODULE_RADIUS, in radius_client_update_timeout()
575 static void radius_client_list_add(struct radius_client_data *radius, in radius_client_list_add() argument
608 entry->next = radius->msgs; in radius_client_list_add()
609 radius->msgs = entry; in radius_client_list_add()
610 radius_client_update_timeout(radius); in radius_client_list_add()
612 if (radius->num_msgs >= RADIUS_CLIENT_MAX_ENTRIES) { in radius_client_list_add()
624 radius->num_msgs++; in radius_client_list_add()
628 static void radius_client_list_del(struct radius_client_data *radius, in radius_client_list_del() argument
636 entry = radius->msgs; in radius_client_list_del()
644 radius->msgs = entry->next; in radius_client_list_del()
647 hostapd_logger(radius->ctx, addr, in radius_client_list_del()
652 radius->num_msgs--; in radius_client_list_del()
683 int radius_client_send(struct radius_client_data *radius, in radius_client_send() argument
687 struct hostapd_radius_servers *conf = radius->conf; in radius_client_send()
696 radius_client_list_del(radius, msg_type, addr); in radius_client_send()
700 if (conf->acct_server && radius->acct_sock < 0) in radius_client_send()
701 radius_client_init_acct(radius); in radius_client_send()
703 if (conf->acct_server == NULL || radius->acct_sock < 0 || in radius_client_send()
705 hostapd_logger(radius->ctx, NULL, in radius_client_send()
715 s = radius->acct_sock; in radius_client_send()
718 if (conf->auth_server && radius->auth_sock < 0) in radius_client_send()
719 radius_client_init_auth(radius); in radius_client_send()
721 if (conf->auth_server == NULL || radius->auth_sock < 0 || in radius_client_send()
723 hostapd_logger(radius->ctx, NULL, in radius_client_send()
733 s = radius->auth_sock; in radius_client_send()
737 hostapd_logger(radius->ctx, NULL, HOSTAPD_MODULE_RADIUS, in radius_client_send()
746 radius_client_handle_send_error(radius, s, msg_type); in radius_client_send()
748 radius_client_list_add(radius, msg, msg_type, shared_secret, in radius_client_send()
757 struct radius_client_data *radius = eloop_ctx; in radius_client_receive() local
758 struct hostapd_radius_servers *conf = radius->conf; in radius_client_receive()
772 handlers = radius->acct_handlers; in radius_client_receive()
773 num_handlers = radius->num_acct_handlers; in radius_client_receive()
776 handlers = radius->auth_handlers; in radius_client_receive()
777 num_handlers = radius->num_auth_handlers; in radius_client_receive()
786 hostapd_logger(radius->ctx, NULL, HOSTAPD_MODULE_RADIUS, in radius_client_receive()
802 hostapd_logger(radius->ctx, NULL, HOSTAPD_MODULE_RADIUS, in radius_client_receive()
823 req = radius->msgs; in radius_client_receive()
839 hostapd_logger(radius->ctx, NULL, HOSTAPD_MODULE_RADIUS, in radius_client_receive()
850 hostapd_logger(radius->ctx, req->addr, HOSTAPD_MODULE_RADIUS, in radius_client_receive()
861 radius->msgs = req->next; in radius_client_receive()
862 radius->num_msgs--; in radius_client_receive()
889 hostapd_logger(radius->ctx, req->addr, HOSTAPD_MODULE_RADIUS, in radius_client_receive()
910 u8 radius_client_get_id(struct radius_client_data *radius) in radius_client_get_id() argument
913 u8 id = radius->next_radius_identifier++; in radius_client_get_id()
917 entry = radius->msgs; in radius_client_get_id()
921 hostapd_logger(radius->ctx, entry->addr, in radius_client_get_id()
929 radius->msgs = entry->next; in radius_client_get_id()
950 void radius_client_flush(struct radius_client_data *radius, int only_auth) in radius_client_flush() argument
954 if (!radius) in radius_client_flush()
958 entry = radius->msgs; in radius_client_flush()
965 radius->msgs = entry->next; in radius_client_flush()
970 radius->num_msgs--; in radius_client_flush()
977 if (radius->msgs == NULL) in radius_client_flush()
978 eloop_cancel_timeout(radius_client_timer, radius, NULL); in radius_client_flush()
982 static void radius_client_update_acct_msgs(struct radius_client_data *radius, in radius_client_update_acct_msgs() argument
988 if (!radius) in radius_client_update_acct_msgs()
991 for (entry = radius->msgs; entry; entry = entry->next) { in radius_client_update_acct_msgs()
1003 radius_change_server(struct radius_client_data *radius, in radius_change_server() argument
1017 struct hostapd_radius_servers *conf = radius->conf; in radius_change_server()
1019 hostapd_logger(radius->ctx, NULL, HOSTAPD_MODULE_RADIUS, in radius_change_server()
1038 radius_client_flush(radius, 1); in radius_change_server()
1041 radius, nserv->shared_secret, in radius_change_server()
1047 for (entry = radius->msgs; oserv && oserv != nserv && entry; in radius_change_server()
1057 if (radius->msgs) { in radius_change_server()
1058 eloop_cancel_timeout(radius_client_timer, radius, NULL); in radius_change_server()
1060 radius_client_timer, radius, NULL); in radius_change_server()
1161 radius->auth_sock = sel_sock; in radius_change_server()
1163 radius->acct_sock = sel_sock; in radius_change_server()
1171 struct radius_client_data *radius = eloop_ctx; in radius_retry_primary_timer() local
1172 struct hostapd_radius_servers *conf = radius->conf; in radius_retry_primary_timer()
1175 if (radius->auth_sock >= 0 && conf->auth_servers && in radius_retry_primary_timer()
1179 if (radius_change_server(radius, conf->auth_server, oserv, in radius_retry_primary_timer()
1180 radius->auth_serv_sock, in radius_retry_primary_timer()
1181 radius->auth_serv_sock6, 1) < 0) { in radius_retry_primary_timer()
1183 radius_change_server(radius, oserv, conf->auth_server, in radius_retry_primary_timer()
1184 radius->auth_serv_sock, in radius_retry_primary_timer()
1185 radius->auth_serv_sock6, 1); in radius_retry_primary_timer()
1189 if (radius->acct_sock >= 0 && conf->acct_servers && in radius_retry_primary_timer()
1193 if (radius_change_server(radius, conf->acct_server, oserv, in radius_retry_primary_timer()
1194 radius->acct_serv_sock, in radius_retry_primary_timer()
1195 radius->acct_serv_sock6, 0) < 0) { in radius_retry_primary_timer()
1197 radius_change_server(radius, oserv, conf->acct_server, in radius_retry_primary_timer()
1198 radius->acct_serv_sock, in radius_retry_primary_timer()
1199 radius->acct_serv_sock6, 0); in radius_retry_primary_timer()
1205 radius_retry_primary_timer, radius, in radius_retry_primary_timer()
1226 static void radius_close_auth_sockets(struct radius_client_data *radius) in radius_close_auth_sockets() argument
1228 radius->auth_sock = -1; in radius_close_auth_sockets()
1230 if (radius->auth_serv_sock >= 0) { in radius_close_auth_sockets()
1231 eloop_unregister_read_sock(radius->auth_serv_sock); in radius_close_auth_sockets()
1232 close(radius->auth_serv_sock); in radius_close_auth_sockets()
1233 radius->auth_serv_sock = -1; in radius_close_auth_sockets()
1236 if (radius->auth_serv_sock6 >= 0) { in radius_close_auth_sockets()
1237 eloop_unregister_read_sock(radius->auth_serv_sock6); in radius_close_auth_sockets()
1238 close(radius->auth_serv_sock6); in radius_close_auth_sockets()
1239 radius->auth_serv_sock6 = -1; in radius_close_auth_sockets()
1245 static void radius_close_acct_sockets(struct radius_client_data *radius) in radius_close_acct_sockets() argument
1247 radius->acct_sock = -1; in radius_close_acct_sockets()
1249 if (radius->acct_serv_sock >= 0) { in radius_close_acct_sockets()
1250 eloop_unregister_read_sock(radius->acct_serv_sock); in radius_close_acct_sockets()
1251 close(radius->acct_serv_sock); in radius_close_acct_sockets()
1252 radius->acct_serv_sock = -1; in radius_close_acct_sockets()
1255 if (radius->acct_serv_sock6 >= 0) { in radius_close_acct_sockets()
1256 eloop_unregister_read_sock(radius->acct_serv_sock6); in radius_close_acct_sockets()
1257 close(radius->acct_serv_sock6); in radius_close_acct_sockets()
1258 radius->acct_serv_sock6 = -1; in radius_close_acct_sockets()
1264 static int radius_client_init_auth(struct radius_client_data *radius) in radius_client_init_auth() argument
1266 struct hostapd_radius_servers *conf = radius->conf; in radius_client_init_auth()
1269 radius_close_auth_sockets(radius); in radius_client_init_auth()
1271 radius->auth_serv_sock = socket(PF_INET, SOCK_DGRAM, 0); in radius_client_init_auth()
1272 if (radius->auth_serv_sock < 0) in radius_client_init_auth()
1276 radius_client_disable_pmtu_discovery(radius->auth_serv_sock); in radius_client_init_auth()
1281 radius->auth_serv_sock6 = socket(PF_INET6, SOCK_DGRAM, 0); in radius_client_init_auth()
1282 if (radius->auth_serv_sock6 < 0) in radius_client_init_auth()
1292 radius_change_server(radius, conf->auth_server, NULL, in radius_client_init_auth()
1293 radius->auth_serv_sock, radius->auth_serv_sock6, in radius_client_init_auth()
1296 if (radius->auth_serv_sock >= 0 && in radius_client_init_auth()
1297 eloop_register_read_sock(radius->auth_serv_sock, in radius_client_init_auth()
1298 radius_client_receive, radius, in radius_client_init_auth()
1301 radius_close_auth_sockets(radius); in radius_client_init_auth()
1306 if (radius->auth_serv_sock6 >= 0 && in radius_client_init_auth()
1307 eloop_register_read_sock(radius->auth_serv_sock6, in radius_client_init_auth()
1308 radius_client_receive, radius, in radius_client_init_auth()
1311 radius_close_auth_sockets(radius); in radius_client_init_auth()
1320 static int radius_client_init_acct(struct radius_client_data *radius) in radius_client_init_acct() argument
1322 struct hostapd_radius_servers *conf = radius->conf; in radius_client_init_acct()
1325 radius_close_acct_sockets(radius); in radius_client_init_acct()
1327 radius->acct_serv_sock = socket(PF_INET, SOCK_DGRAM, 0); in radius_client_init_acct()
1328 if (radius->acct_serv_sock < 0) in radius_client_init_acct()
1332 radius_client_disable_pmtu_discovery(radius->acct_serv_sock); in radius_client_init_acct()
1337 radius->acct_serv_sock6 = socket(PF_INET6, SOCK_DGRAM, 0); in radius_client_init_acct()
1338 if (radius->acct_serv_sock6 < 0) in radius_client_init_acct()
1348 radius_change_server(radius, conf->acct_server, NULL, in radius_client_init_acct()
1349 radius->acct_serv_sock, radius->acct_serv_sock6, in radius_client_init_acct()
1352 if (radius->acct_serv_sock >= 0 && in radius_client_init_acct()
1353 eloop_register_read_sock(radius->acct_serv_sock, in radius_client_init_acct()
1354 radius_client_receive, radius, in radius_client_init_acct()
1357 radius_close_acct_sockets(radius); in radius_client_init_acct()
1362 if (radius->acct_serv_sock6 >= 0 && in radius_client_init_acct()
1363 eloop_register_read_sock(radius->acct_serv_sock6, in radius_client_init_acct()
1364 radius_client_receive, radius, in radius_client_init_acct()
1367 radius_close_acct_sockets(radius); in radius_client_init_acct()
1389 struct radius_client_data *radius; in radius_client_init() local
1391 radius = os_zalloc(sizeof(struct radius_client_data)); in radius_client_init()
1392 if (radius == NULL) in radius_client_init()
1395 radius->ctx = ctx; in radius_client_init()
1396 radius->conf = conf; in radius_client_init()
1397 radius->auth_serv_sock = radius->acct_serv_sock = in radius_client_init()
1398 radius->auth_serv_sock6 = radius->acct_serv_sock6 = in radius_client_init()
1399 radius->auth_sock = radius->acct_sock = -1; in radius_client_init()
1401 if (conf->auth_server && radius_client_init_auth(radius)) { in radius_client_init()
1402 radius_client_deinit(radius); in radius_client_init()
1406 if (conf->acct_server && radius_client_init_acct(radius)) { in radius_client_init()
1407 radius_client_deinit(radius); in radius_client_init()
1413 radius_retry_primary_timer, radius, in radius_client_init()
1416 return radius; in radius_client_init()
1424 void radius_client_deinit(struct radius_client_data *radius) in radius_client_deinit() argument
1426 if (!radius) in radius_client_deinit()
1429 radius_close_auth_sockets(radius); in radius_client_deinit()
1430 radius_close_acct_sockets(radius); in radius_client_deinit()
1432 eloop_cancel_timeout(radius_retry_primary_timer, radius, NULL); in radius_client_deinit()
1434 radius_client_flush(radius, 0); in radius_client_deinit()
1435 os_free(radius->auth_handlers); in radius_client_deinit()
1436 os_free(radius->acct_handlers); in radius_client_deinit()
1437 os_free(radius); in radius_client_deinit()
1451 void radius_client_flush_auth(struct radius_client_data *radius, in radius_client_flush_auth() argument
1457 entry = radius->msgs; in radius_client_flush_auth()
1461 hostapd_logger(radius->ctx, addr, in radius_client_flush_auth()
1470 radius->msgs = entry->next; in radius_client_flush_auth()
1475 radius->num_msgs--; in radius_client_flush_auth()
1587 int radius_client_get_mib(struct radius_client_data *radius, char *buf, in radius_client_get_mib() argument
1590 struct hostapd_radius_servers *conf = radius->conf; in radius_client_get_mib()
1601 radius : NULL); in radius_client_get_mib()
1611 radius : NULL); in radius_client_get_mib()
1619 void radius_client_reconfig(struct radius_client_data *radius, in radius_client_reconfig() argument
1622 if (radius) in radius_client_reconfig()
1623 radius->conf = conf; in radius_client_reconfig()