static void Handle_reload_config( rtapd *rtapd) { struct rtapd_config *newconf; #if MULTIPLE_RADIUS int i; #endif // MULTIPLE_RADIUS // DBGPRINT(RT_DEBUG_TRACE, "Reloading configuration\n"); /* create new config */ newconf = Config_read(rtapd->ioctl_sock, rtapd->prefix_wlan_name); if (newconf == NULL) { DBGPRINT(RT_DEBUG_ERROR, "Failed to read new configuration file - continuing with old.\n"); return; } /* TODO: update dynamic data based on changed configuration * items (e.g., open/close sockets, remove stations added to * deny list, etc.) */ Radius_client_flush(rtapd); Config_free(rtapd->conf); rtapd->conf = newconf; Apd_free_stas(rtapd); /* when reStartAP, no need to reallocate sock for (i = 0; i < rtapd->conf->SsidNum; i++) { if (rtapd->sock[i] >= 0) close(rtapd->sock[i]); rtapd->sock[i] = socket(PF_PACKET, SOCK_RAW, htons(ETH_P_ALL)); if (rtapd->sock[i] < 0) { perror("socket[PF_PACKET,SOCK_RAW]"); return; } }*/ #if MULTIPLE_RADIUS for (i = 0; i < MAX_MBSSID_NUM; i++) rtapd->radius->mbss_auth_serv_sock[i] = -1; #else rtapd->radius->auth_serv_sock = -1; #endif if (Radius_client_init(rtapd)) { DBGPRINT(RT_DEBUG_ERROR,"RADIUS client initialization failed.\n"); return; } #if MULTIPLE_RADIUS for (i = 0; i < rtapd->conf->SsidNum; i++) DBGPRINT(RT_DEBUG_TRACE, "auth_serv_sock[%d] = %d\n", i, rtapd->radius->mbss_auth_serv_sock[i]); #else DBGPRINT(RT_DEBUG_TRACE,"rtapd->radius->auth_serv_sock = %d\n",rtapd->radius->auth_serv_sock); #endif }
static int Radius_change_server(rtapd *rtapd, struct hostapd_radius_server *nserv, struct hostapd_radius_server *oserv, int sock, int auth) { struct sockaddr_in serv; int port = 1812; if (!oserv || nserv->shared_secret_len != oserv->shared_secret_len || memcmp(nserv->shared_secret, oserv->shared_secret, nserv->shared_secret_len) != 0) { /* Pending RADIUS packets used different shared * secret, so they would need to be modified. Could * update all message authenticators and * User-Passwords, etc. and retry with new server. For * now, just drop all pending packets. */ Radius_client_flush(rtapd); } else { /* Reset retry counters for the new server */ struct radius_msg_list *entry; entry = rtapd->radius->msgs; while (entry) { entry->next_try = entry->first_try + RADIUS_CLIENT_FIRST_WAIT; entry->attempts = 0; entry->next_wait = RADIUS_CLIENT_FIRST_WAIT * 2; entry = entry->next; } if (rtapd->radius->msgs) { eloop_cancel_timeout(Radius_client_timer, rtapd, NULL); eloop_register_timeout(RADIUS_CLIENT_FIRST_WAIT, 0, Radius_client_timer, rtapd, NULL); } } // bind before connect to assign local port /*Comment by rory memset(&serv, 0, sizeof(serv)); port = 2048; serv.sin_family = AF_INET; //serv.sin_addr.s_addr = inet_addr("192.168.1.138"); serv.sin_addr.s_addr = rtapd->conf->own_ip_addr.s_addr; serv.sin_port = htons(port); if (bind(sock, (struct sockaddr *) &serv, sizeof(serv)) < 0) { perror("bind"); return -1; }*/ memset(&serv, 0, sizeof(serv)); serv.sin_family = AF_INET; serv.sin_addr.s_addr = nserv->addr.s_addr; port = rtapd->conf->auth_server->port; serv.sin_port = htons(port); if (connect(sock, (struct sockaddr *) &serv, sizeof(serv)) < 0) { perror("connect[radius]"); return -1; } return 0; }
void Radius_client_deinit(rtapd *rtapd) { if (!rtapd->radius) return; eloop_cancel_timeout(Radius_retry_primary_timer, rtapd, NULL); Radius_client_flush(rtapd); free(rtapd->radius->auth_handlers); free(rtapd->radius); rtapd->radius = NULL; }
static void Handle_usr1(int sig, void *eloop_ctx, void *signal_ctx) { struct hapd_interfaces *rtapds = (struct hapd_interfaces *) eloop_ctx; struct rtapd_config *newconf; int i; DBGPRINT(RT_DEBUG_TRACE,"Reloading configuration\n"); for (i = 0; i < rtapds->count; i++) { rtapd *rtapd = rtapds->rtapd[i]; newconf = Config_read(rtapd->config_fname,0); if (newconf == NULL) { DBGPRINT(RT_DEBUG_ERROR,"Failed to read new configuration file - continuing with old.\n"); continue; } /* TODO: update dynamic data based on changed configuration * items (e.g., open/close sockets, remove stations added to * deny list, etc.) */ Radius_client_flush(rtapd); Config_free(rtapd->conf); rtapd->conf = newconf; Apd_free_stas(rtapd); /* when reStartAP, no need to reallocate sock for (i = 0; i < rtapd->conf->SsidNum; i++) { if (rtapd->sock[i] >= 0) close(rtapd->sock[i]); rtapd->sock[i] = socket(PF_PACKET, SOCK_RAW, htons(ETH_P_ALL)); if (rtapd->sock[i] < 0) { perror("socket[PF_PACKET,SOCK_RAW]"); return; } }*/ if (Radius_client_init(rtapd)) { DBGPRINT(RT_DEBUG_ERROR,"RADIUS client initialization failed.\n"); return; } #if MULTIPLE_RADIUS for (i = 0; i < rtapd->conf->SsidNum; i++) DBGPRINT(RT_DEBUG_TRACE, "auth_serv_sock[%d] = %d\n", i, rtapd->radius->mbss_auth_serv_sock[i]); #else DBGPRINT(RT_DEBUG_TRACE,"rtapd->radius->auth_serv_sock = %d\n",rtapd->radius->auth_serv_sock); #endif } }
static void Handle_usr1(int sig, void *eloop_ctx, void *signal_ctx) { struct hapd_interfaces *rtapds = (struct hapd_interfaces *) eloop_ctx; struct rtapd_config *newconf; int i; DBGPRINT(RT_DEBUG_TRACE,"Reloading configuration\n"); for (i = 0; i < rtapds->count; i++) { rtapd *rtapd = rtapds->rtapd[i]; newconf = Config_read(rtapd->ioctl_sock, rtapd->prefix_wlan_name); if (newconf == NULL) { DBGPRINT(RT_DEBUG_ERROR,"Failed to read new configuration file - continuing with old.\n"); continue; } /* TODO: update dynamic data based on changed configuration * items (e.g., open/close sockets, remove stations added to * deny list, etc.) */ Radius_client_flush(rtapd); Config_free(rtapd->conf); rtapd->conf = newconf; Apd_free_stas(rtapd); #if MULTIPLE_RADIUS for (i = 0; i < MAX_MBSSID_NUM; i++) rtapd->radius->mbss_auth_serv_sock[i] = -1; #else rtapd->radius->auth_serv_sock = -1; #endif if (Radius_client_init(rtapd)) { DBGPRINT(RT_DEBUG_ERROR,"RADIUS client initialization failed.\n"); return; } #if MULTIPLE_RADIUS for (i = 0; i < rtapd->conf->SsidNum; i++) DBGPRINT(RT_DEBUG_TRACE, "auth_serv_sock[%d] = %d\n", i, rtapd->radius->mbss_auth_serv_sock[i]); #else DBGPRINT(RT_DEBUG_TRACE,"rtapd->radius->auth_serv_sock = %d\n",rtapd->radius->auth_serv_sock); #endif } }