Home | History | Annotate | Download | only in ap

Lines Matching full:hapd

36 static u8 * hostapd_eid_rm_enabled_capab(struct hostapd_data *hapd, u8 *eid,
39 if (!hapd->conf->radio_measurements || len < 2 + 4)
44 *eid++ = (hapd->conf->radio_measurements & BIT(0)) ?
54 static u8 * hostapd_eid_bss_load(struct hostapd_data *hapd, u8 *eid, size_t len)
60 if (hapd->conf->bss_load_test_set) {
63 os_memcpy(eid, hapd->conf->bss_load_test, 5);
68 if (hapd->conf->bss_load_update_period) {
71 WPA_PUT_LE16(eid, hapd->num_sta);
73 *eid++ = hapd->iface->channel_utilization;
81 static u8 ieee802_11_erp_info(struct hostapd_data *hapd)
85 if (hapd->iface->current_mode == NULL ||
86 hapd->iface->current_mode->mode != HOSTAPD_MODE_IEEE80211G)
89 if (hapd->iface->olbc)
91 if (hapd->iface->num_sta_non_erp > 0) {
95 if (hapd->iface->num_sta_no_short_preamble > 0 ||
96 hapd->iconf->preamble == LONG_PREAMBLE)
103 static u8 * hostapd_eid_ds_params(struct hostapd_data *hapd, u8 *eid)
107 *eid++ = hapd->iconf->channel;
112 static u8 * hostapd_eid_erp_info(struct hostapd_data *hapd, u8 *eid)
114 if (hapd->iface->current_mode == NULL ||
115 hapd->iface->current_mode->mode != HOSTAPD_MODE_IEEE80211G)
130 *eid++ = ieee802_11_erp_info(hapd);
136 static u8 * hostapd_eid_pwr_constraint(struct hostapd_data *hapd, u8 *eid)
142 if (hapd->iface->current_mode == NULL ||
143 hapd->iface->current_mode->mode != HOSTAPD_MODE_IEEE80211A)
147 if (hapd->iface->drv_flags & WPA_DRIVER_FLAGS_DFS_OFFLOAD)
154 if (!hapd->iconf->ieee80211h &&
155 hapd->iconf->local_pwr_constraint == -1)
159 dfs = hostapd_is_dfs_required(hapd->iface);
166 if (dfs == 0 && hapd->iconf->local_pwr_constraint == -1)
177 if (hapd->iconf->local_pwr_constraint == -1)
198 *pos++ = hapd->iconf->local_pwr_constraint;
222 static u8 * hostapd_eid_country(struct hostapd_data *hapd, u8 *eid,
232 if (!hapd->iconf->ieee80211d || max_len < 6 ||
233 hapd->iface->current_mode == NULL)
238 os_memcpy(pos, hapd->iconf->country, 3); /* e.g., 'US ' */
241 mode = hapd->iface->current_mode;
284 static u8 * hostapd_eid_wpa(struct hostapd_data *hapd, u8 *eid, size_t len)
289 ie = wpa_auth_get_wpa_ie(hapd->wpa_auth, &ielen);
298 static u8 * hostapd_eid_csa(struct hostapd_data *hapd, u8 *eid)
301 if (hapd->iface->cs_oper_class && hapd->iconf->ecsa_ie_only)
305 if (!hapd->cs_freq_params.channel)
310 *eid++ = hapd->cs_block_tx;
311 *eid++ = hapd->cs_freq_params.channel;
312 *eid++ = hapd->cs_count;
318 static u8 * hostapd_eid_ecsa(struct hostapd_data *hapd, u8 *eid)
320 if (!hapd->cs_freq_params.channel || !hapd->iface->cs_oper_class)
325 *eid++ = hapd->cs_block_tx;
326 *eid++ = hapd->iface->cs_oper_class;
327 *eid++ = hapd->cs_freq_params.channel;
328 *eid++ = hapd->cs_count;
334 static u8 * hostapd_eid_supported_op_classes(struct hostapd_data *hapd, u8 *eid)
338 if (!(hapd->iface->drv_flags & WPA_DRIVER_FLAGS_AP_CSA) ||
339 !hapd->iface->freq)
342 if (ieee80211_freq_to_channel_ext(hapd->iface->freq,
343 hapd->iconf->secondary_channel,
344 hapd->iconf->vht_oper_chwidth,
362 static u8 * hostapd_gen_probe_resp(struct hostapd_data *hapd,
373 if (hapd->wps_probe_resp_ie)
374 buflen += wpabuf_len(hapd->wps_probe_resp_ie);
377 if (hapd->p2p_probe_resp_ie)
378 buflen += wpabuf_len(hapd->p2p_probe_resp_ie);
381 if (hapd->iface->fst_ies)
382 buflen += wpabuf_len(hapd->iface->fst_ies);
384 if (hapd->conf->vendor_elements)
385 buflen += wpabuf_len(hapd->conf->vendor_elements);
386 if (hapd->conf->vendor_vht) {
391 buflen += hostapd_mbo_ie_len(hapd);
403 os_memcpy(resp->sa, hapd->own_addr, ETH_ALEN);
405 os_memcpy(resp->bssid, hapd->own_addr, ETH_ALEN);
407 host_to_le16(hapd->iconf->beacon_int);
411 host_to_le16(hostapd_own_capab_info(hapd));
415 *pos++ = hapd->conf->ssid.ssid_len;
416 os_memcpy(pos, hapd->conf->ssid.ssid, hapd->conf->ssid.ssid_len);
417 pos += hapd->conf->ssid.ssid_len;
420 pos = hostapd_eid_supp_rates(hapd, pos);
423 pos = hostapd_eid_ds_params(hapd, pos);
425 pos = hostapd_eid_country(hapd, pos, epos - pos);
428 pos = hostapd_eid_pwr_constraint(hapd, pos);
431 csa_pos = hostapd_eid_csa(hapd, pos);
433 hapd->cs_c_off_proberesp = csa_pos - (u8 *) resp - 1;
437 pos = hostapd_eid_erp_info(hapd, pos);
440 pos = hostapd_eid_ext_supp_rates(hapd, pos);
443 pos = hostapd_eid_wpa(hapd, pos, epos - pos);
445 pos = hostapd_eid_bss_load(hapd, pos, epos - pos);
447 pos = hostapd_eid_rm_enabled_capab(hapd, pos, epos - pos);
450 csa_pos = hostapd_eid_ecsa(hapd, pos);
452 hapd->cs_c_off_ecsa_proberesp = csa_pos - (u8 *) resp - 1;
455 pos = hostapd_eid_supported_op_classes(hapd, pos);
460 pos = hostapd_eid_secondary_channel(hapd, pos);
462 pos = hostapd_eid_ht_capabilities(hapd, pos);
463 pos = hostapd_eid_ht_operation(hapd, pos);
466 pos = hostapd_eid_ext_capab(hapd, pos);
468 pos = hostapd_eid_time_adv(hapd, pos);
469 pos = hostapd_eid_time_zone(hapd, pos);
471 pos = hostapd_eid_interworking(hapd, pos);
472 pos = hostapd_eid_adv_proto(hapd, pos);
473 pos = hostapd_eid_roaming_consortium(hapd, pos);
476 if (hapd->iface->fst_ies) {
477 os_memcpy(pos, wpabuf_head(hapd->iface->fst_ies),
478 wpabuf_len(hapd->iface->fst_ies));
479 pos += wpabuf_len(hapd->iface->fst_ies);
484 if (hapd->iconf->ieee80211ac && !hapd->conf->disable_11ac) {
485 pos = hostapd_eid_vht_capabilities(hapd, pos);
486 pos = hostapd_eid_vht_operation(hapd, pos);
487 pos = hostapd_eid_txpower_envelope(hapd, pos);
488 pos = hostapd_eid_wb_chsw_wrapper(hapd, pos);
490 if (hapd->conf->vendor_vht)
491 pos = hostapd_eid_vendor_vht(hapd, pos);
495 pos = hostapd_eid_wmm(hapd, pos);
498 if (hapd->conf->wps_state && hapd->wps_probe_resp_ie) {
499 os_memcpy(pos, wpabuf_head(hapd->wps_probe_resp_ie),
500 wpabuf_len(hapd->wps_probe_resp_ie));
501 pos += wpabuf_len(hapd->wps_probe_resp_ie);
506 if ((hapd->conf->p2p & P2P_ENABLED) && is_p2p &&
507 hapd->p2p_probe_resp_ie) {
508 os_memcpy(pos, wpabuf_head(hapd->p2p_probe_resp_ie),
509 wpabuf_len(hapd->p2p_probe_resp_ie));
510 pos += wpabuf_len(hapd->p2p_probe_resp_ie);
514 if ((hapd->conf->p2p & (P2P_MANAGE | P2P_ENABLED | P2P_GROUP_OWNER)) ==
516 pos = hostapd_eid_p2p_manage(hapd, pos);
520 pos = hostapd_eid_hs20_indication(hapd, pos);
521 pos = hostapd_eid_osen(hapd, pos);
524 pos = hostapd_eid_mbo(hapd, pos, (u8 *) resp + buflen - pos);
526 if (hapd->conf->vendor_elements) {
527 os_memcpy(pos, wpabuf_head(hapd->conf->vendor_elements),
528 wpabuf_len(hapd->conf->vendor_elements));
529 pos += wpabuf_len(hapd->conf->vendor_elements);
543 static enum ssid_match_result ssid_match(struct hostapd_data *hapd,
553 if (ssid_len == hapd->conf->ssid.ssid_len &&
554 os_memcmp(ssid, hapd->conf->ssid.ssid, ssid_len) == 0)
567 if (pos[1] == hapd->conf->ssid.ssid_len &&
568 os_memcmp(pos + 2, hapd->conf->ssid.ssid, pos[1]) == 0)
655 struct hostapd_data *hapd = NULL;
659 hapd = iface->bss[j];
660 if (os_strcmp(ifname, hapd->conf->iface) == 0)
662 hapd = NULL;
665 if (hapd && sta_track_get(iface, addr))
666 return hapd;
673 void handle_probe_req(struct hostapd_data *hapd,
691 if (hapd->iconf->track_sta_max_num)
692 sta_track_add(hapd->iface, mgmt->sa);
695 for (i = 0; hapd->probereq_cb && i < hapd->num_probereq_cb; i++)
696 if (hapd->probereq_cb[i].cb(hapd->probereq_cb[i].ctx,
701 if (!hapd->iconf->send_probe_response)
728 hapd->iface->current_mode &&
729 (hapd->iface->current_mode->mode == HOSTAPD_MODE_IEEE80211G ||
730 hapd->iface->current_mode->mode == HOSTAPD_MODE_IEEE80211B) &&
731 hapd->iconf->channel != elems.ds_params[0]) {
734 hapd->iconf->channel, elems.ds_params[0]);
739 if (hapd->p2p && hapd->p2p_group && elems.wps_ie) {
742 if (wps && !p2p_group_match_dev_type(hapd->p2p_group, wps)) {
752 if (hapd->p2p && hapd->p2p_group && elems.p2p) {
755 if (p2p && !p2p_group_match_dev_id(hapd->p2p_group, p2p)) {
765 if (hapd->conf->ignore_broadcast_ssid && elems.ssid_len == 0 &&
773 if ((hapd->conf->p2p & P2P_GROUP_OWNER) &&
782 res = ssid_match(hapd, elems.ssid, elems.ssid_len,
797 if (hapd->conf->interworking &&
801 ant != hapd->conf->access_network_type) {
809 if (hapd->conf->interworking && elems.interworking &&
817 os_memcmp(hessid, hapd->conf->hessid, ETH_ALEN) != 0) {
828 if ((hapd->conf->p2p & P2P_GROUP_OWNER) &&
841 if (hapd->conf->no_probe_resp_if_seen_on &&
844 sta_track_seen_on(hapd->iface, mgmt->sa,
845 hapd->conf->no_probe_resp_if_seen_on)) {
848 hapd->conf->iface, MAC2STR(mgmt->sa),
849 hapd->conf->no_probe_resp_if_seen_on);
853 if (hapd->conf->no_probe_resp_if_max_sta &&
856 hapd->num_sta >= hapd->conf->max_num_sta &&
857 !ap_get_sta(hapd, mgmt->sa)) {
860 hapd->conf->iface, MAC2STR(mgmt->sa));
865 if (hapd->iconf->ignore_probe_probability > 0.0 &&
866 drand48() < hapd->iconf->ignore_probe_probability) {
874 resp = hostapd_gen_probe_resp(hapd, mgmt, elems.p2p != NULL,
887 if (hapd->csa_in_progress) {
888 if (hapd->cs_c_off_proberesp)
890 hapd->cs_c_off_proberesp;
892 if (hapd->cs_c_off_ecsa_proberesp)
894 hapd->cs_c_off_ecsa_proberesp;
897 ret = hostapd_drv_send_mlme_csa(hapd, resp, resp_len, noack,
912 static u8 * hostapd_probe_resp_offloads(struct hostapd_data *hapd,
916 if (!(hapd->iface->drv_flags & WPA_DRIVER_FLAGS_PROBE_RESP_OFFLOAD))
920 if (hapd->conf->wps_state && hapd->wps_probe_resp_ie &&
921 (!(hapd->iface->probe_resp_offloads &
929 if ((hapd->conf->p2p & P2P_ENABLED) && hapd->p2p_probe_resp_ie &&
930 !(hapd->iface->probe_resp_offloads &
936 if (hapd->conf->interworking &&
937 !(hapd->iface->probe_resp_offloads &
944 return hostapd_gen_probe_resp(hapd, NULL, 0, resp_len);
950 int ieee802_11_build_ap_params(struct hostapd_data *hapd,
967 if (hapd->conf->wps_state && hapd->wps_beacon_ie)
968 tail_len += wpabuf_len(hapd->wps_beacon_ie);
971 if (hapd->p2p_beacon_ie)
972 tail_len += wpabuf_len(hapd->p2p_beacon_ie);
975 if (hapd->iface->fst_ies)
976 tail_len += wpabuf_len(hapd->iface->fst_ies);
978 if (hapd->conf->vendor_elements)
979 tail_len += wpabuf_len(hapd->conf->vendor_elements);
982 if (hapd->conf->vendor_vht) {
988 tail_len += hostapd_mbo_ie_len(hapd);
1003 os_memcpy(head->sa, hapd->own_addr, ETH_ALEN);
1004 os_memcpy(head->bssid, hapd->own_addr, ETH_ALEN);
1006 host_to_le16(hapd->iconf->beacon_int);
1009 capab_info = hostapd_own_capab_info(hapd);
1015 if (hapd->conf->ignore_broadcast_ssid == 2) {
1017 *pos++ = hapd->conf->ssid.ssid_len;
1018 os_memset(pos, 0, hapd->conf->ssid.ssid_len);
1019 pos += hapd->conf->ssid.ssid_len;
1020 } else if (hapd->conf->ignore_broadcast_ssid) {
1023 *pos++ = hapd->conf->ssid.ssid_len;
1024 os_memcpy(pos, hapd->conf->ssid.ssid,
1025 hapd->conf->ssid.ssid_len);
1026 pos += hapd->conf->ssid.ssid_len;
1030 pos = hostapd_eid_supp_rates(hapd, pos);
1033 pos = hostapd_eid_ds_params(hapd, pos);
1037 tailpos = hostapd_eid_country(hapd, tailpos,
1041 tailpos = hostapd_eid_pwr_constraint(hapd, tailpos);
1044 csa_pos = hostapd_eid_csa(hapd, tailpos);
1046 hapd->cs_c_off_beacon = csa_pos - tail - 1;
1050 tailpos = hostapd_eid_erp_info(hapd, tailpos);
1053 tailpos = hostapd_eid_ext_supp_rates(hapd, tailpos);
1056 tailpos = hostapd_eid_wpa(hapd, tailpos, tail + BEACON_TAIL_BUF_SIZE -
1059 tailpos = hostapd_eid_rm_enabled_capab(hapd, tailpos,
1063 tailpos = hostapd_eid_bss_load(hapd, tailpos,
1067 csa_pos = hostapd_eid_ecsa(hapd, tailpos);
1069 hapd->cs_c_off_ecsa_beacon = csa_pos - tail - 1;
1072 tailpos = hostapd_eid_supported_op_classes(hapd, tailpos);
1077 tailpos = hostapd_eid_secondary_channel(hapd, tailpos);
1079 tailpos = hostapd_eid_ht_capabilities(hapd, tailpos);
1080 tailpos = hostapd_eid_ht_operation(hapd, tailpos);
1083 tailpos = hostapd_eid_ext_capab(hapd, tailpos);
1089 tailpos = hostapd_eid_time_adv(hapd, tailpos);
1091 tailpos = hostapd_eid_interworking(hapd, tailpos);
1092 tailpos = hostapd_eid_adv_proto(hapd, tailpos);
1093 tailpos = hostapd_eid_roaming_consortium(hapd, tailpos);
1096 if (hapd->iface->fst_ies) {
1097 os_memcpy(tailpos, wpabuf_head(hapd->iface->fst_ies),
1098 wpabuf_len(hapd->iface->fst_ies));
1099 tailpos += wpabuf_len(hapd->iface->fst_ies);
1104 if (hapd->iconf->ieee80211ac && !hapd->conf->disable_11ac) {
1105 tailpos = hostapd_eid_vht_capabilities(hapd, tailpos);
1106 tailpos = hostapd_eid_vht_operation(hapd, tailpos);
1107 tailpos = hostapd_eid_txpower_envelope(hapd, tailpos);
1108 tailpos = hostapd_eid_wb_chsw_wrapper(hapd, tailpos);
1110 if (hapd->conf->vendor_vht)
1111 tailpos = hostapd_eid_vendor_vht(hapd, tailpos);
1115 tailpos = hostapd_eid_wmm(hapd, tailpos);
1118 if (hapd->conf->wps_state && hapd->wps_beacon_ie) {
1119 os_memcpy(tailpos, wpabuf_head(hapd->wps_beacon_ie),
1120 wpabuf_len(hapd->wps_beacon_ie));
1121 tailpos += wpabuf_len(hapd->wps_beacon_ie);
1126 if ((hapd->conf->p2p & P2P_ENABLED) && hapd->p2p_beacon_ie) {
1127 os_memcpy(tailpos, wpabuf_head(hapd->p2p_beacon_ie),
1128 wpabuf_len(hapd->p2p_beacon_ie));
1129 tailpos += wpabuf_len(hapd->p2p_beacon_ie);
1133 if ((hapd->conf->p2p & (P2P_MANAGE | P2P_ENABLED | P2P_GROUP_OWNER)) ==
1135 tailpos = hostapd_eid_p2p_manage(hapd, tailpos);
1139 tailpos = hostapd_eid_hs20_indication(hapd, tailpos);
1140 tailpos = hostapd_eid_osen(hapd, tailpos);
1143 tailpos = hostapd_eid_mbo(hapd, tailpos, tail + tail_len - tailpos);
1145 if (hapd->conf->vendor_elements) {
1146 os_memcpy(tailpos, wpabuf_head(hapd->conf->vendor_elements),
1147 wpabuf_len(hapd->conf->vendor_elements));
1148 tailpos += wpabuf_len(hapd->conf->vendor_elements);
1153 resp = hostapd_probe_resp_offloads(hapd, &resp_len);
1163 params->dtim_period = hapd->conf->dtim_period;
1164 params->beacon_int = hapd->iconf->beacon_int;
1165 params->basic_rates = hapd->iface->basic_rates;
1166 params->ssid = hapd->conf->ssid.ssid;
1167 params->ssid_len = hapd->conf->ssid.ssid_len;
1168 if ((hapd->conf->wpa & (WPA_PROTO_WPA | WPA_PROTO_RSN)) ==
1170 params->pairwise_ciphers = hapd->conf->wpa_pairwise |
1171 hapd->conf->rsn_pairwise;
1172 else if (hapd->conf->wpa & WPA_PROTO_RSN)
1173 params->pairwise_ciphers = hapd->conf->rsn_pairwise;
1174 else if (hapd->conf->wpa & WPA_PROTO_WPA)
1175 params->pairwise_ciphers = hapd->conf->wpa_pairwise;
1176 params->group_cipher = hapd->conf->wpa_group;
1177 params->key_mgmt_suites = hapd->conf->wpa_key_mgmt;
1178 params->auth_algs = hapd->conf->auth_algs;
1179 params->wpa_version = hapd->conf->wpa;
1180 hapd->conf->ssid.wep.keys_set || hapd->conf->wpa ||
1181 (hapd->conf->ieee802_1x &&
1182 (hapd->conf->default_wep_key_len ||
1183 hapd->conf->individual_wep_key_len));
1184 switch (hapd->conf->ignore_broadcast_ssid) {
1195 params->isolate = hapd->conf->isolate;
1196 params->smps_mode = hapd->iconf->ht_capab & HT_CAP_INFO_SMPS_MASK;
1198 params->cts_protect = !!(ieee802_11_erp_info(hapd) &
1200 params->preamble = hapd->iface->num_sta_no_short_preamble == 0 &&
1201 hapd->iconf->preamble == SHORT_PREAMBLE;
1202 if (hapd->iface->current_mode &&
1203 hapd->iface->current_mode->mode == HOSTAPD_MODE_IEEE80211G)
1205 hapd->iface->num_sta_no_short_slot_time > 0 ? 0 : 1;
1208 if (!hapd->iconf->ieee80211n || hapd->conf->disable_11n)
1211 params->ht_opmode = hapd->iface->ht_op_mode;
1213 params->interworking = hapd->conf->interworking;
1214 if (hapd->conf->interworking &&
1215 !is_zero_ether_addr(hapd->conf->hessid))
1216 params->hessid = hapd->conf->hessid;
1217 params->access_network_type = hapd->conf->access_network_type;
1218 params->ap_max_inactivity = hapd->conf->ap_max_inactivity;
1220 params->p2p_go_ctwindow = hapd->iconf->p2p_go_ctwindow;
1223 params->disable_dgaf = hapd->conf->disable_dgaf;
1224 if (hapd->conf->osen) {
1229 params->pbss = hapd->conf->pbss;
1245 int ieee802_11_set_beacon(struct hostapd_data *hapd)
1249 struct hostapd_iface *iface = hapd->iface;
1254 if (hapd->csa_in_progress) {
1259 hapd->beacon_set_done = 1;
1261 if (ieee802_11_build_ap_params(hapd, &params) < 0)
1264 if (hostapd_build_ap_extra_ies(hapd, &beacon, &proberesp, &assocresp) <
1271 params.reenable = hapd->reenable_beacon;
1272 hapd->reenable_beacon = 0;
1285 res = hostapd_drv_set_ap(hapd, &params);
1286 hostapd_free_ap_extra_ies(hapd, beacon, proberesp, assocresp);