Lines Matching refs:radius
248 radius_change_server(struct radius_client_data *radius,
252 static int radius_client_init_acct(struct radius_client_data *radius);
253 static int radius_client_init_auth(struct radius_client_data *radius);
254 static void radius_client_auth_failover(struct radius_client_data *radius);
255 static void radius_client_acct_failover(struct radius_client_data *radius);
281 int radius_client_register(struct radius_client_data *radius, in radius_client_register() argument
294 handlers = &radius->acct_handlers; in radius_client_register()
295 num = &radius->num_acct_handlers; in radius_client_register()
297 handlers = &radius->auth_handlers; in radius_client_register()
298 num = &radius->num_auth_handlers; in radius_client_register()
325 void radius_client_set_interim_error_cb(struct radius_client_data *radius, in radius_client_set_interim_error_cb() argument
329 radius->interim_error_cb = cb; in radius_client_set_interim_error_cb()
330 radius->interim_error_cb_ctx = ctx; in radius_client_set_interim_error_cb()
338 static int radius_client_handle_send_error(struct radius_client_data *radius, in radius_client_handle_send_error() argument
346 hostapd_logger(radius->ctx, NULL, HOSTAPD_MODULE_RADIUS, in radius_client_handle_send_error()
352 radius_client_init_acct(radius); in radius_client_handle_send_error()
355 radius_client_init_auth(radius); in radius_client_handle_send_error()
365 static int radius_client_retransmit(struct radius_client_data *radius, in radius_client_retransmit() argument
369 struct hostapd_radius_servers *conf = radius->conf; in radius_client_retransmit()
380 if (radius->acct_sock < 0) in radius_client_retransmit()
381 radius_client_init_acct(radius); in radius_client_retransmit()
382 if (radius->acct_sock < 0 && conf->num_acct_servers > 1) { in radius_client_retransmit()
383 prev_num_msgs = radius->num_msgs; in radius_client_retransmit()
384 radius_client_acct_failover(radius); in radius_client_retransmit()
385 if (prev_num_msgs != radius->num_msgs) in radius_client_retransmit()
388 s = radius->acct_sock; in radius_client_retransmit()
397 if (radius->auth_sock < 0) in radius_client_retransmit()
398 radius_client_init_auth(radius); in radius_client_retransmit()
399 if (radius->auth_sock < 0 && conf->num_auth_servers > 1) { in radius_client_retransmit()
400 prev_num_msgs = radius->num_msgs; in radius_client_retransmit()
401 radius_client_auth_failover(radius); in radius_client_retransmit()
402 if (prev_num_msgs != radius->num_msgs) in radius_client_retransmit()
405 s = radius->auth_sock; in radius_client_retransmit()
419 if (radius->interim_error_cb) in radius_client_retransmit()
420 radius->interim_error_cb(entry->addr, in radius_client_retransmit()
421 radius->interim_error_cb_ctx); in radius_client_retransmit()
444 hdr->identifier = radius_client_get_id(radius); in radius_client_retransmit()
455 if (radius->conf->msg_dumps) in radius_client_retransmit()
469 hostapd_logger(radius->ctx, entry->addr, HOSTAPD_MODULE_RADIUS, in radius_client_retransmit()
476 if (radius_client_handle_send_error(radius, s, entry->msg_type) in radius_client_retransmit()
492 struct radius_client_data *radius = eloop_ctx; in radius_client_timer() local
500 entry = radius->msgs; in radius_client_timer()
508 s = entry->msg_type == RADIUS_AUTH ? radius->auth_sock : in radius_client_timer()
509 radius->acct_sock; in radius_client_timer()
523 radius_client_auth_failover(radius); in radius_client_timer()
526 radius_client_acct_failover(radius); in radius_client_timer()
528 entry = radius->msgs; in radius_client_timer()
533 prev_num_msgs = radius->num_msgs; in radius_client_timer()
535 radius_client_retransmit(radius, entry, now.sec)) { in radius_client_timer()
539 radius->msgs = entry->next; in radius_client_timer()
544 radius->num_msgs--; in radius_client_timer()
548 if (prev_num_msgs != radius->num_msgs) { in radius_client_timer()
551 entry = radius->msgs; in radius_client_timer()
563 if (radius->msgs) { in radius_client_timer()
566 eloop_cancel_timeout(radius_client_timer, radius, NULL); in radius_client_timer()
568 radius_client_timer, radius, NULL); in radius_client_timer()
569 hostapd_logger(radius->ctx, NULL, HOSTAPD_MODULE_RADIUS, in radius_client_timer()
577 static void radius_client_auth_failover(struct radius_client_data *radius) in radius_client_auth_failover() argument
579 struct hostapd_radius_servers *conf = radius->conf; in radius_client_auth_failover()
585 hostapd_logger(radius->ctx, NULL, HOSTAPD_MODULE_RADIUS, in radius_client_auth_failover()
591 for (entry = radius->msgs; entry; entry = entry->next) { in radius_client_auth_failover()
600 radius_change_server(radius, next, old, in radius_client_auth_failover()
601 radius->auth_serv_sock, in radius_client_auth_failover()
602 radius->auth_serv_sock6, 1); in radius_client_auth_failover()
606 static void radius_client_acct_failover(struct radius_client_data *radius) in radius_client_acct_failover() argument
608 struct hostapd_radius_servers *conf = radius->conf; in radius_client_acct_failover()
614 hostapd_logger(radius->ctx, NULL, HOSTAPD_MODULE_RADIUS, in radius_client_acct_failover()
620 for (entry = radius->msgs; entry; entry = entry->next) { in radius_client_acct_failover()
630 radius_change_server(radius, next, old, in radius_client_acct_failover()
631 radius->acct_serv_sock, in radius_client_acct_failover()
632 radius->acct_serv_sock6, 0); in radius_client_acct_failover()
636 static void radius_client_update_timeout(struct radius_client_data *radius) in radius_client_update_timeout() argument
642 eloop_cancel_timeout(radius_client_timer, radius, NULL); in radius_client_update_timeout()
644 if (radius->msgs == NULL) { in radius_client_update_timeout()
649 for (entry = radius->msgs; entry; entry = entry->next) { in radius_client_update_timeout()
657 eloop_register_timeout(first - now.sec, 0, radius_client_timer, radius, in radius_client_update_timeout()
659 hostapd_logger(radius->ctx, NULL, HOSTAPD_MODULE_RADIUS, in radius_client_update_timeout()
665 static void radius_client_list_add(struct radius_client_data *radius, in radius_client_list_add() argument
701 entry->next = radius->msgs; in radius_client_list_add()
702 radius->msgs = entry; in radius_client_list_add()
703 radius_client_update_timeout(radius); in radius_client_list_add()
705 if (radius->num_msgs >= RADIUS_CLIENT_MAX_ENTRIES) { in radius_client_list_add()
717 radius->num_msgs++; in radius_client_list_add()
746 int radius_client_send(struct radius_client_data *radius, in radius_client_send() argument
750 struct hostapd_radius_servers *conf = radius->conf; in radius_client_send()
758 if (conf->acct_server && radius->acct_sock < 0) in radius_client_send()
759 radius_client_init_acct(radius); in radius_client_send()
761 if (conf->acct_server == NULL || radius->acct_sock < 0 || in radius_client_send()
763 hostapd_logger(radius->ctx, NULL, in radius_client_send()
773 s = radius->acct_sock; in radius_client_send()
776 if (conf->auth_server && radius->auth_sock < 0) in radius_client_send()
777 radius_client_init_auth(radius); in radius_client_send()
779 if (conf->auth_server == NULL || radius->auth_sock < 0 || in radius_client_send()
781 hostapd_logger(radius->ctx, NULL, in radius_client_send()
791 s = radius->auth_sock; in radius_client_send()
795 hostapd_logger(radius->ctx, NULL, HOSTAPD_MODULE_RADIUS, in radius_client_send()
804 radius_client_handle_send_error(radius, s, msg_type); in radius_client_send()
806 radius_client_list_add(radius, msg, msg_type, shared_secret, in radius_client_send()
815 struct radius_client_data *radius = eloop_ctx; in radius_client_receive() local
816 struct hostapd_radius_servers *conf = radius->conf; in radius_client_receive()
830 handlers = radius->acct_handlers; in radius_client_receive()
831 num_handlers = radius->num_acct_handlers; in radius_client_receive()
834 handlers = radius->auth_handlers; in radius_client_receive()
835 num_handlers = radius->num_auth_handlers; in radius_client_receive()
844 hostapd_logger(radius->ctx, NULL, HOSTAPD_MODULE_RADIUS, in radius_client_receive()
860 hostapd_logger(radius->ctx, NULL, HOSTAPD_MODULE_RADIUS, in radius_client_receive()
881 req = radius->msgs; in radius_client_receive()
897 hostapd_logger(radius->ctx, NULL, HOSTAPD_MODULE_RADIUS, in radius_client_receive()
908 hostapd_logger(radius->ctx, req->addr, HOSTAPD_MODULE_RADIUS, in radius_client_receive()
919 radius->msgs = req->next; in radius_client_receive()
920 radius->num_msgs--; in radius_client_receive()
947 hostapd_logger(radius->ctx, req->addr, HOSTAPD_MODULE_RADIUS, in radius_client_receive()
968 u8 radius_client_get_id(struct radius_client_data *radius) in radius_client_get_id() argument
971 u8 id = radius->next_radius_identifier++; in radius_client_get_id()
975 entry = radius->msgs; in radius_client_get_id()
979 hostapd_logger(radius->ctx, entry->addr, in radius_client_get_id()
987 radius->msgs = entry->next; in radius_client_get_id()
1008 void radius_client_flush(struct radius_client_data *radius, int only_auth) in radius_client_flush() argument
1012 if (!radius) in radius_client_flush()
1016 entry = radius->msgs; in radius_client_flush()
1023 radius->msgs = entry->next; in radius_client_flush()
1028 radius->num_msgs--; in radius_client_flush()
1035 if (radius->msgs == NULL) in radius_client_flush()
1036 eloop_cancel_timeout(radius_client_timer, radius, NULL); in radius_client_flush()
1040 static void radius_client_update_acct_msgs(struct radius_client_data *radius, in radius_client_update_acct_msgs() argument
1046 if (!radius) in radius_client_update_acct_msgs()
1049 for (entry = radius->msgs; entry; entry = entry->next) { in radius_client_update_acct_msgs()
1061 radius_change_server(struct radius_client_data *radius, in radius_change_server() argument
1075 struct hostapd_radius_servers *conf = radius->conf; in radius_change_server()
1080 hostapd_logger(radius->ctx, NULL, HOSTAPD_MODULE_RADIUS, in radius_change_server()
1090 radius_client_flush(radius, 1); in radius_change_server()
1105 radius_client_flush(radius, 1); in radius_change_server()
1108 radius, nserv->shared_secret, in radius_change_server()
1114 for (entry = radius->msgs; oserv && entry; entry = entry->next) { in radius_change_server()
1123 if (radius->msgs) { in radius_change_server()
1124 eloop_cancel_timeout(radius_client_timer, radius, NULL); in radius_change_server()
1126 radius_client_timer, radius, NULL); in radius_change_server()
1232 radius->auth_sock = sel_sock; in radius_change_server()
1234 radius->acct_sock = sel_sock; in radius_change_server()
1242 struct radius_client_data *radius = eloop_ctx; in radius_retry_primary_timer() local
1243 struct hostapd_radius_servers *conf = radius->conf; in radius_retry_primary_timer()
1246 if (radius->auth_sock >= 0 && conf->auth_servers && in radius_retry_primary_timer()
1250 if (radius_change_server(radius, conf->auth_server, oserv, in radius_retry_primary_timer()
1251 radius->auth_serv_sock, in radius_retry_primary_timer()
1252 radius->auth_serv_sock6, 1) < 0) { in radius_retry_primary_timer()
1254 radius_change_server(radius, oserv, conf->auth_server, in radius_retry_primary_timer()
1255 radius->auth_serv_sock, in radius_retry_primary_timer()
1256 radius->auth_serv_sock6, 1); in radius_retry_primary_timer()
1260 if (radius->acct_sock >= 0 && conf->acct_servers && in radius_retry_primary_timer()
1264 if (radius_change_server(radius, conf->acct_server, oserv, in radius_retry_primary_timer()
1265 radius->acct_serv_sock, in radius_retry_primary_timer()
1266 radius->acct_serv_sock6, 0) < 0) { in radius_retry_primary_timer()
1268 radius_change_server(radius, oserv, conf->acct_server, in radius_retry_primary_timer()
1269 radius->acct_serv_sock, in radius_retry_primary_timer()
1270 radius->acct_serv_sock6, 0); in radius_retry_primary_timer()
1276 radius_retry_primary_timer, radius, in radius_retry_primary_timer()
1297 static void radius_close_auth_sockets(struct radius_client_data *radius) in radius_close_auth_sockets() argument
1299 radius->auth_sock = -1; in radius_close_auth_sockets()
1301 if (radius->auth_serv_sock >= 0) { in radius_close_auth_sockets()
1302 eloop_unregister_read_sock(radius->auth_serv_sock); in radius_close_auth_sockets()
1303 close(radius->auth_serv_sock); in radius_close_auth_sockets()
1304 radius->auth_serv_sock = -1; in radius_close_auth_sockets()
1307 if (radius->auth_serv_sock6 >= 0) { in radius_close_auth_sockets()
1308 eloop_unregister_read_sock(radius->auth_serv_sock6); in radius_close_auth_sockets()
1309 close(radius->auth_serv_sock6); in radius_close_auth_sockets()
1310 radius->auth_serv_sock6 = -1; in radius_close_auth_sockets()
1316 static void radius_close_acct_sockets(struct radius_client_data *radius) in radius_close_acct_sockets() argument
1318 radius->acct_sock = -1; in radius_close_acct_sockets()
1320 if (radius->acct_serv_sock >= 0) { in radius_close_acct_sockets()
1321 eloop_unregister_read_sock(radius->acct_serv_sock); in radius_close_acct_sockets()
1322 close(radius->acct_serv_sock); in radius_close_acct_sockets()
1323 radius->acct_serv_sock = -1; in radius_close_acct_sockets()
1326 if (radius->acct_serv_sock6 >= 0) { in radius_close_acct_sockets()
1327 eloop_unregister_read_sock(radius->acct_serv_sock6); in radius_close_acct_sockets()
1328 close(radius->acct_serv_sock6); in radius_close_acct_sockets()
1329 radius->acct_serv_sock6 = -1; in radius_close_acct_sockets()
1335 static int radius_client_init_auth(struct radius_client_data *radius) in radius_client_init_auth() argument
1337 struct hostapd_radius_servers *conf = radius->conf; in radius_client_init_auth()
1340 radius_close_auth_sockets(radius); in radius_client_init_auth()
1342 radius->auth_serv_sock = socket(PF_INET, SOCK_DGRAM, 0); in radius_client_init_auth()
1343 if (radius->auth_serv_sock < 0) in radius_client_init_auth()
1347 radius_client_disable_pmtu_discovery(radius->auth_serv_sock); in radius_client_init_auth()
1352 radius->auth_serv_sock6 = socket(PF_INET6, SOCK_DGRAM, 0); in radius_client_init_auth()
1353 if (radius->auth_serv_sock6 < 0) in radius_client_init_auth()
1363 radius_change_server(radius, conf->auth_server, NULL, in radius_client_init_auth()
1364 radius->auth_serv_sock, radius->auth_serv_sock6, in radius_client_init_auth()
1367 if (radius->auth_serv_sock >= 0 && in radius_client_init_auth()
1368 eloop_register_read_sock(radius->auth_serv_sock, in radius_client_init_auth()
1369 radius_client_receive, radius, in radius_client_init_auth()
1372 radius_close_auth_sockets(radius); in radius_client_init_auth()
1377 if (radius->auth_serv_sock6 >= 0 && in radius_client_init_auth()
1378 eloop_register_read_sock(radius->auth_serv_sock6, in radius_client_init_auth()
1379 radius_client_receive, radius, in radius_client_init_auth()
1382 radius_close_auth_sockets(radius); in radius_client_init_auth()
1391 static int radius_client_init_acct(struct radius_client_data *radius) in radius_client_init_acct() argument
1393 struct hostapd_radius_servers *conf = radius->conf; in radius_client_init_acct()
1396 radius_close_acct_sockets(radius); in radius_client_init_acct()
1398 radius->acct_serv_sock = socket(PF_INET, SOCK_DGRAM, 0); in radius_client_init_acct()
1399 if (radius->acct_serv_sock < 0) in radius_client_init_acct()
1403 radius_client_disable_pmtu_discovery(radius->acct_serv_sock); in radius_client_init_acct()
1408 radius->acct_serv_sock6 = socket(PF_INET6, SOCK_DGRAM, 0); in radius_client_init_acct()
1409 if (radius->acct_serv_sock6 < 0) in radius_client_init_acct()
1419 radius_change_server(radius, conf->acct_server, NULL, in radius_client_init_acct()
1420 radius->acct_serv_sock, radius->acct_serv_sock6, in radius_client_init_acct()
1423 if (radius->acct_serv_sock >= 0 && in radius_client_init_acct()
1424 eloop_register_read_sock(radius->acct_serv_sock, in radius_client_init_acct()
1425 radius_client_receive, radius, in radius_client_init_acct()
1428 radius_close_acct_sockets(radius); in radius_client_init_acct()
1433 if (radius->acct_serv_sock6 >= 0 && in radius_client_init_acct()
1434 eloop_register_read_sock(radius->acct_serv_sock6, in radius_client_init_acct()
1435 radius_client_receive, radius, in radius_client_init_acct()
1438 radius_close_acct_sockets(radius); in radius_client_init_acct()
1460 struct radius_client_data *radius; in radius_client_init() local
1462 radius = os_zalloc(sizeof(struct radius_client_data)); in radius_client_init()
1463 if (radius == NULL) in radius_client_init()
1466 radius->ctx = ctx; in radius_client_init()
1467 radius->conf = conf; in radius_client_init()
1468 radius->auth_serv_sock = radius->acct_serv_sock = in radius_client_init()
1469 radius->auth_serv_sock6 = radius->acct_serv_sock6 = in radius_client_init()
1470 radius->auth_sock = radius->acct_sock = -1; in radius_client_init()
1472 if (conf->auth_server && radius_client_init_auth(radius)) { in radius_client_init()
1473 radius_client_deinit(radius); in radius_client_init()
1477 if (conf->acct_server && radius_client_init_acct(radius)) { in radius_client_init()
1478 radius_client_deinit(radius); in radius_client_init()
1484 radius_retry_primary_timer, radius, in radius_client_init()
1487 return radius; in radius_client_init()
1495 void radius_client_deinit(struct radius_client_data *radius) in radius_client_deinit() argument
1497 if (!radius) in radius_client_deinit()
1500 radius_close_auth_sockets(radius); in radius_client_deinit()
1501 radius_close_acct_sockets(radius); in radius_client_deinit()
1503 eloop_cancel_timeout(radius_retry_primary_timer, radius, NULL); in radius_client_deinit()
1505 radius_client_flush(radius, 0); in radius_client_deinit()
1506 os_free(radius->auth_handlers); in radius_client_deinit()
1507 os_free(radius->acct_handlers); in radius_client_deinit()
1508 os_free(radius); in radius_client_deinit()
1522 void radius_client_flush_auth(struct radius_client_data *radius, in radius_client_flush_auth() argument
1528 entry = radius->msgs; in radius_client_flush_auth()
1532 hostapd_logger(radius->ctx, addr, in radius_client_flush_auth()
1541 radius->msgs = entry->next; in radius_client_flush_auth()
1546 radius->num_msgs--; in radius_client_flush_auth()
1658 int radius_client_get_mib(struct radius_client_data *radius, char *buf, in radius_client_get_mib() argument
1666 if (!radius) in radius_client_get_mib()
1669 conf = radius->conf; in radius_client_get_mib()
1677 radius : NULL); in radius_client_get_mib()
1687 radius : NULL); in radius_client_get_mib()
1695 void radius_client_reconfig(struct radius_client_data *radius, in radius_client_reconfig() argument
1698 if (radius) in radius_client_reconfig()
1699 radius->conf = conf; in radius_client_reconfig()