Home | History | Annotate | Download | only in ap

Lines Matching defs:hapd

37 static int hostapd_flush_old_stations(struct hostapd_data *hapd, u16 reason);
38 static int hostapd_setup_encryption(char *iface, struct hostapd_data *hapd);
39 static int hostapd_broadcast_wep_clear(struct hostapd_data *hapd);
62 static void hostapd_reload_bss(struct hostapd_data *hapd)
65 radius_client_reconfig(hapd->radius, hapd->conf->radius);
68 if (hostapd_setup_wpa_psk(hapd->conf)) {
73 if (hapd->conf->ieee802_1x || hapd->conf->wpa)
74 hostapd_set_drv_ieee8021x(hapd, hapd->conf->iface, 1);
76 hostapd_set_drv_ieee8021x(hapd, hapd->conf->iface, 0);
78 if (hapd->conf->wpa && hapd->wpa_auth == NULL) {
79 hostapd_setup_wpa(hapd);
80 if (hapd->wpa_auth)
81 wpa_init_keys(hapd->wpa_auth);
82 } else if (hapd->conf->wpa) {
85 hostapd_reconfig_wpa(hapd);
86 wpa_ie = wpa_auth_get_wpa_ie(hapd->wpa_auth, &wpa_ie_len);
87 if (hostapd_set_generic_elem(hapd, wpa_ie, wpa_ie_len))
90 } else if (hapd->wpa_auth) {
91 wpa_deinit(hapd->wpa_auth);
92 hapd->wpa_auth = NULL;
93 hostapd_set_privacy(hapd, 0);
94 hostapd_setup_encryption(hapd->conf->iface, hapd);
95 hostapd_set_generic_elem(hapd, (u8 *) "", 0);
98 ieee802_11_set_beacon(hapd);
99 hostapd_update_wps(hapd);
101 if (hapd->conf->ssid.ssid_set &&
102 hostapd_set_ssid(hapd, hapd->conf->ssid.ssid,
103 hapd->conf->ssid.ssid_len)) {
107 wpa_printf(MSG_DEBUG, "Reconfigured interface %s", hapd->conf->iface);
135 struct hostapd_data *hapd = iface->bss[0];
156 oldconf = hapd->iconf;
160 hapd = iface->bss[j];
161 hapd->iconf = newconf;
162 hapd->conf = &newconf->bss[j];
163 hostapd_reload_bss(hapd);
173 static void hostapd_broadcast_key_clear_iface(struct hostapd_data *hapd,
179 if (hostapd_drv_set_key(ifname, hapd, WPA_ALG_NONE, NULL, i,
187 if (hapd->conf->ieee80211w) {
189 if (hostapd_drv_set_key(ifname, hapd, WPA_ALG_NONE,
202 static int hostapd_broadcast_wep_clear(struct hostapd_data *hapd)
204 hostapd_broadcast_key_clear_iface(hapd, hapd->conf->iface);
209 static int hostapd_broadcast_wep_set(struct hostapd_data *hapd)
212 struct hostapd_ssid *ssid = &hapd->conf->ssid;
216 hostapd_drv_set_key(hapd->conf->iface,
217 hapd, WPA_ALG_WEP, broadcast_ether_addr, idx,
228 static void hostapd_free_hapd_data(struct hostapd_data *hapd)
230 iapp_deinit(hapd->iapp);
231 hapd->iapp = NULL;
232 accounting_deinit(hapd);
233 hostapd_deinit_wpa(hapd);
234 vlan_deinit(hapd);
235 hostapd_acl_deinit(hapd);
237 radius_client_deinit(hapd->radius);
238 hapd->radius = NULL;
239 radius_das_deinit(hapd->radius_das);
240 hapd->radius_das = NULL;
243 hostapd_deinit_wps(hapd);
245 authsrv_deinit(hapd);
247 if (hapd->interface_added &&
248 hostapd_if_remove(hapd, WPA_IF_AP_BSS, hapd->conf->iface)) {
250 hapd->conf->iface);
253 os_free(hapd->probereq_cb);
254 hapd->probereq_cb = NULL;
257 wpabuf_free(hapd->p2p_beacon_ie);
258 hapd->p2p_beacon_ie = NULL;
259 wpabuf_free(hapd->p2p_probe_resp_ie);
260 hapd->p2p_probe_resp_ie = NULL;
263 wpabuf_free(hapd->time_adv);
266 gas_serv_deinit(hapd);
270 os_free(hapd->tmp_eap_user.identity);
271 os_free(hapd->tmp_eap_user.password);
278 * @hapd: Pointer to BSS data
286 static void hostapd_cleanup(struct hostapd_data *hapd)
288 if (hapd->iface->interfaces &&
289 hapd->iface->interfaces->ctrl_iface_deinit)
290 hapd->iface->interfaces->ctrl_iface_deinit(hapd);
291 hostapd_free_hapd_data(hapd);
338 static void hostapd_clear_wep(struct hostapd_data *hapd)
340 if (hapd->drv_priv) {
341 hostapd_set_privacy(hapd, 0);
342 hostapd_broadcast_wep_clear(hapd);
347 static int hostapd_setup_encryption(char *iface, struct hostapd_data *hapd)
351 hostapd_broadcast_wep_set(hapd);
353 if (hapd->conf->ssid.wep.default_len) {
354 hostapd_set_privacy(hapd, 1);
362 hostapd_drv_set_authmode(hapd, hapd->conf->auth_algs);
365 if (hapd->conf->ssid.wep.key[i] &&
366 hostapd_drv_set_key(iface, hapd, WPA_ALG_WEP, NULL, i,
367 i == hapd->conf->ssid.wep.idx, NULL, 0,
368 hapd->conf->ssid.wep.key[i],
369 hapd->conf->ssid.wep.len[i])) {
374 if (hapd->conf->ssid.wep.key[i] &&
375 i == hapd->conf->ssid.wep.idx)
376 hostapd_set_privacy(hapd, 1);
383 static int hostapd_flush_old_stations(struct hostapd_data *hapd, u16 reason)
388 if (hostapd_drv_none(hapd) || hapd->drv_priv == NULL)
391 wpa_dbg(hapd->msg_ctx, MSG_DEBUG, "Flushing old station entries");
392 if (hostapd_flush(hapd)) {
393 wpa_msg(hapd->msg_ctx, MSG_WARNING, "Could not connect to "
397 wpa_dbg(hapd->msg_ctx, MSG_DEBUG, "Deauthenticate all stations");
399 hostapd_drv_sta_deauth(hapd, addr, reason);
400 hostapd_free_stas(hapd);
416 struct hostapd_data *hapd = iface->bss[0];
420 if (hostapd_drv_none(hapd))
441 hapd->own_addr[i];
485 if ((hapd->own_addr[i] & mask[i]) != hapd->own_addr[i]) {
488 MAC2STR(mask), MAC2STR(hapd->own_addr));
516 static int hostapd_das_nas_mismatch(struct hostapd_data *hapd,
524 static struct sta_info * hostapd_das_find_sta(struct hostapd_data *hapd,
531 sta = ap_get_sta(hapd, attr->sta_addr);
535 for (sta = hapd->sta_list; sta; sta = sta->next) {
545 for (sta = hapd->sta_list; sta; sta = sta->next) {
556 for (sta = hapd->sta_list; sta; sta = sta->next) {
576 struct hostapd_data *hapd = ctx;
579 if (hostapd_das_nas_mismatch(hapd, attr))
582 sta = hostapd_das_find_sta(hapd, attr);
586 hostapd_drv_sta_deauth(hapd, sta->addr,
588 ap_sta_deauthenticate(hapd, sta, WLAN_REASON_PREV_AUTH_NOT_VALID);
598 * @hapd: Pointer to BSS data
606 static int hostapd_setup_bss(struct hostapd_data *hapd, int first)
608 struct hostapd_bss_config *conf = hapd->conf;
615 if (hostapd_mac_comp_empty(hapd->conf->bssid) == 0) {
618 inc_byte_array(hapd->own_addr, ETH_ALEN);
619 } while (mac_in_conf(hapd->iconf, hapd->own_addr));
622 os_memcpy(hapd->own_addr, hapd->conf->bssid, ETH_ALEN);
624 if (hostapd_mac_comp(hapd->own_addr,
625 hapd->iface->bss[0]->own_addr) ==
629 "the radio", hapd->conf->iface);
634 hapd->interface_added = 1;
635 if (hostapd_if_add(hapd->iface->bss[0], WPA_IF_AP_BSS,
636 hapd->conf->iface, hapd->own_addr, hapd,
637 &hapd->drv_priv, force_ifname, if_addr,
638 hapd->conf->bridge[0] ? hapd->conf->bridge :
641 MACSTR ")", MAC2STR(hapd->own_addr));
647 conf->wmm_enabled = hapd->iconf->ieee80211n;
649 hostapd_flush_old_stations(hapd, WLAN_REASON_PREV_AUTH_NOT_VALID);
650 hostapd_set_privacy(hapd, 0);
652 hostapd_broadcast_wep_clear(hapd);
653 if (hostapd_setup_encryption(hapd->conf->iface, hapd))
661 ssid_len = hostapd_get_ssid(hapd, ssid, sizeof(ssid));
684 if (!hostapd_drv_none(hapd)) {
687 hapd->conf->iface, MAC2STR(hapd->own_addr),
688 wpa_ssid_txt(hapd->conf->ssid.ssid,
689 hapd->conf->ssid.ssid_len));
699 if (set_ssid && hostapd_set_ssid(hapd, conf->ssid.ssid,
708 hapd->radius = radius_client_init(hapd, conf->radius);
709 if (hapd->radius == NULL) {
714 if (hapd->conf->radius_das_port) {
717 das_conf.port = hapd->conf->radius_das_port;
718 das_conf.shared_secret = hapd->conf->radius_das_shared_secret;
720 hapd->conf->radius_das_shared_secret_len;
721 das_conf.client_addr = &hapd->conf->radius_das_client_addr;
722 das_conf.time_window = hapd->conf->radius_das_time_window;
724 hapd->conf->radius_das_require_event_timestamp;
725 das_conf.ctx = hapd;
727 hapd->radius_das = radius_das_init(&das_conf);
728 if (hapd->radius_das == NULL) {
736 if (hostapd_acl_init(hapd)) {
740 if (hostapd_init_wps(hapd, conf))
743 if (authsrv_init(hapd) < 0)
746 if (ieee802_1x_init(hapd)) {
751 if (hapd->conf->wpa && hostapd_setup_wpa(hapd))
754 if (accounting_init(hapd)) {
759 if (hapd->conf->ieee802_11f &&
760 (hapd->iapp = iapp_init(hapd, hapd->conf->iapp_iface)) == NULL) {
767 if (gas_serv_init(hapd)) {
773 if (hapd->iface->interfaces &&
774 hapd->iface->interfaces->ctrl_iface_init &&
775 hapd->iface->interfaces->ctrl_iface_init(hapd)) {
780 if (!hostapd_drv_none(hapd) && vlan_init(hapd)) {
785 if (!hapd->conf->start_disabled)
786 ieee802_11_set_beacon(hapd);
788 if (hapd->wpa_auth && wpa_init_keys(hapd->wpa_auth) < 0)
791 if (hapd->driver && hapd->driver->set_operstate)
792 hapd->driver->set_operstate(hapd->drv_priv, 1);
800 struct hostapd_data *hapd = iface->bss[0];
807 if (hostapd_set_tx_queue_params(hapd, i, p->aifs, p->cwmin,
817 static int hostapd_set_acl_list(struct hostapd_data *hapd,
836 err = hostapd_drv_set_acl(hapd, acl_params);
844 static void hostapd_set_acl(struct hostapd_data *hapd)
846 struct hostapd_config *conf = hapd->iconf;
850 if (hapd->iface->drv_max_acl_mac_addrs == 0)
858 err = hostapd_set_acl_list(hapd, conf->bss->accept_mac,
871 err = hostapd_set_acl_list(hapd, conf->bss->deny_mac,
887 struct hostapd_data *hapd = iface->bss[0];
896 iface->bss[i]->driver = hapd->driver;
897 iface->bss[i]->drv_priv = hapd->drv_priv;
903 if (hapd->iconf->country[0] && hapd->iconf->country[1]) {
904 os_memcpy(country, hapd->iconf->country, 3);
906 if (hostapd_set_country(hapd, country) < 0) {
941 struct hostapd_data *hapd = iface->bss[0];
952 if (hapd->iconf->channel) {
953 iface->freq = hostapd_hw_get_freq(hapd, hapd->iconf->channel);
956 hostapd_hw_mode_txt(hapd->iconf->hw_mode),
957 hapd->iconf->channel, iface->freq);
959 if (hostapd_set_freq(hapd, hapd->iconf->hw_mode, iface->freq,
960 hapd->iconf->channel,
961 hapd->iconf->ieee80211n,
962 hapd->iconf->ieee80211ac,
963 hapd->iconf->secondary_channel,
964 hapd->iconf->vht_oper_chwidth,
965 hapd->iconf->vht_oper_centr_freq_seg0_idx,
966 hapd->iconf->vht_oper_centr_freq_seg1_idx)) {
977 hostapd_logger(hapd, NULL, HOSTAPD_MODULE_IEEE80211,
984 if (hapd->iconf->rts_threshold > -1 &&
985 hostapd_set_rts(hapd, hapd->iconf->rts_threshold)) {
991 if (hapd->iconf->fragm_threshold > -1 &&
992 hostapd_set_frag(hapd, hapd->iconf->fragm_threshold)) {
998 prev_addr = hapd->own_addr;
1001 hapd = iface->bss[j];
1003 os_memcpy(hapd->own_addr, prev_addr, ETH_ALEN);
1004 if (hostapd_setup_bss(hapd, j == 0))
1006 if (hostapd_mac_comp_empty(hapd->conf->bssid) == 0)
1007 prev_addr = hapd->own_addr;
1014 hostapd_set_acl(hapd);
1016 if (hostapd_driver_commit(hapd) < 0) {
1033 if (hapd->setup_complete_cb)
1034 hapd->setup_complete_cb(hapd->setup_complete_cb_ctx);
1084 struct hostapd_data *hapd;
1086 hapd = os_zalloc(sizeof(*hapd));
1087 if (hapd == NULL)
1090 hapd->new_assoc_sta_cb = hostapd_new_assoc_sta;
1091 hapd->iconf = conf;
1092 hapd->conf = bss;
1093 hapd->iface = hapd_iface;
1094 hapd->driver = hapd->iconf->driver;
1095 hapd->ctrl_sock = -1;
1097 return hapd;
1110 struct hostapd_data *hapd = iface->bss[j];
1111 hostapd_free_stas(hapd);
1112 hostapd_flush_old_stations(hapd, WLAN_REASON_DEAUTH_LEAVING);
1113 hostapd_clear_wep(hapd);
1114 hostapd_cleanup(hapd);
1204 struct hostapd_data *hapd = hapd_iface->bss[j];
1205 hostapd_free_stas(hapd);
1206 hostapd_flush_old_stations(hapd, WLAN_REASON_DEAUTH_LEAVING);
1207 hostapd_clear_wep(hapd);
1208 hostapd_free_hapd_data(hapd);
1298 struct hostapd_data *hapd;
1309 hapd = hapd_iface->bss[i] =
1312 if (hapd == NULL)
1314 hapd->msg_ctx = hapd;
1417 * @hapd: Pointer to BSS data
1426 void hostapd_new_assoc_sta(struct hostapd_data *hapd, struct sta_info *sta,
1429 if (hapd->tkip_countermeasures) {
1430 hostapd_drv_sta_deauth(hapd, sta->addr,
1435 hostapd_prune_associations(hapd, sta->addr);
1438 if (hapd->conf->ieee802_11f)
1439 iapp_new_station(hapd->iapp, sta);
1444 hapd->num_sta_no_p2p++;
1445 if (hapd->num_sta_no_p2p == 1)
1446 hostapd_p2p_non_p2p_sta_connected(hapd);
1453 if (!hapd->conf->ieee802_1x && !hapd->conf->wpa) {
1455 accounting_sta_start(hapd, sta);
1459 ieee802_1x_new_station(hapd, sta);
1465 wpa_auth_sta_associated(hapd->wpa_auth, sta->wpa_sm);
1470 hapd->conf->ap_max_inactivity);
1471 eloop_cancel_timeout(ap_handle_timer, hapd, sta);
1472 eloop_register_timeout(hapd->conf->ap_max_inactivity, 0,
1473 ap_handle_timer, hapd, sta);