xref: /freebsd/contrib/wpa/src/ap/ieee802_11.h (revision 71e72c9e91c4b8007a4292e09669e8b549c29e97)
1 /*
2  * hostapd / IEEE 802.11 Management
3  * Copyright (c) 2002-2009, Jouni Malinen <j@w1.fi>
4  *
5  * This software may be distributed under the terms of the BSD license.
6  * See README for more details.
7  */
8 
9 #ifndef IEEE802_11_H
10 #define IEEE802_11_H
11 
12 #include "utils/list.h"
13 
14 struct hostapd_iface;
15 struct hostapd_data;
16 struct sta_info;
17 struct hostapd_frame_info;
18 struct ieee80211_ht_capabilities;
19 struct ieee80211_vht_capabilities;
20 struct ieee80211_mgmt;
21 struct radius_sta;
22 enum ieee80211_op_mode;
23 enum oper_chan_width;
24 struct ieee802_11_elems;
25 struct sae_pk;
26 struct sae_pt;
27 struct sae_password_entry;
28 struct mld_info;
29 struct mld_link_info;
30 struct rsn_pmksa_cache_entry;
31 
32 enum link_parse_type {
33 	LINK_PARSE_ASSOC,
34 	LINK_PARSE_REASSOC,
35 	LINK_PARSE_RECONF,
36 };
37 
38 #define LINK_RECONF_GROUP_KDE_MAX_LEN 255
39 
40 struct link_reconf_req_info {
41 	struct dl_list list;
42 	u16 status;
43 	u8 link_id;
44 	u8 local_addr[ETH_ALEN];
45 	u8 peer_addr[ETH_ALEN];
46 	size_t sta_prof_len;
47 	u8 sta_prof[];
48 };
49 
50 struct link_reconf_req_list {
51 	u8 sta_mld_addr[ETH_ALEN];
52 	u8 dialog_token;
53 	u16 links_add_ok;
54 	u16 links_del_ok;
55 	u16 new_valid_links;
56 	struct dl_list del_req; /* list of struct link_reconf_req_info */
57 	struct dl_list add_req; /* list of struct link_reconf_req_info */
58 };
59 
60 int ieee802_11_mgmt(struct hostapd_data *hapd, const u8 *buf, size_t len,
61 		    struct hostapd_frame_info *fi);
62 void ieee802_11_mgmt_cb(struct hostapd_data *hapd, const u8 *buf, size_t len,
63 			u16 stype, int ok);
64 void hostapd_2040_coex_action(struct hostapd_data *hapd,
65 			      const struct ieee80211_mgmt *mgmt, size_t len);
66 #ifdef NEED_AP_MLME
67 int ieee802_11_get_mib(struct hostapd_data *hapd, char *buf, size_t buflen);
68 int ieee802_11_get_mib_sta(struct hostapd_data *hapd, struct sta_info *sta,
69 			   char *buf, size_t buflen);
70 #else /* NEED_AP_MLME */
ieee802_11_get_mib(struct hostapd_data * hapd,char * buf,size_t buflen)71 static inline int ieee802_11_get_mib(struct hostapd_data *hapd, char *buf,
72 				     size_t buflen)
73 {
74 	return 0;
75 }
76 
ieee802_11_get_mib_sta(struct hostapd_data * hapd,struct sta_info * sta,char * buf,size_t buflen)77 static inline int ieee802_11_get_mib_sta(struct hostapd_data *hapd,
78 					 struct sta_info *sta,
79 					 char *buf, size_t buflen)
80 {
81 	return 0;
82 }
83 #endif /* NEED_AP_MLME */
84 u16 hostapd_own_capab_info(struct hostapd_data *hapd);
85 void ap_ht2040_timeout(void *eloop_data, void *user_data);
86 u8 * hostapd_eid_ext_capab(struct hostapd_data *hapd, u8 *eid,
87 			   bool mbssid_complete);
88 u8 * hostapd_eid_qos_map_set(struct hostapd_data *hapd, u8 *eid);
89 u8 * hostapd_eid_supp_rates(struct hostapd_data *hapd, u8 *eid);
90 u8 * hostapd_eid_ext_supp_rates(struct hostapd_data *hapd, u8 *eid);
91 u8 * hostapd_eid_rm_enabled_capab(struct hostapd_data *hapd, u8 *eid,
92 				  size_t len);
93 u8 * hostapd_eid_ht_capabilities(struct hostapd_data *hapd, u8 *eid);
94 u8 * hostapd_eid_ht_operation(struct hostapd_data *hapd, u8 *eid);
95 u8 * hostapd_eid_vht_capabilities(struct hostapd_data *hapd, u8 *eid, u32 nsts);
96 u8 * hostapd_eid_vht_operation(struct hostapd_data *hapd, u8 *eid);
97 u8 * hostapd_eid_vendor_vht(struct hostapd_data *hapd, u8 *eid);
98 u8 * hostapd_eid_chsw_wrapper(struct hostapd_data *hapd, u8 *eid);
99 u8 * hostapd_eid_txpower_envelope(struct hostapd_data *hapd, u8 *eid);
100 u8 * hostapd_eid_he_capab(struct hostapd_data *hapd, u8 *eid,
101 			  enum ieee80211_op_mode opmode);
102 u8 * hostapd_eid_he_operation(struct hostapd_data *hapd, u8 *eid);
103 u8 * hostapd_eid_he_mu_edca_parameter_set(struct hostapd_data *hapd, u8 *eid);
104 u8 * hostapd_eid_spatial_reuse(struct hostapd_data *hapd, u8 *eid);
105 u8 * hostapd_eid_he_6ghz_band_cap(struct hostapd_data *hapd, u8 *eid);
106 
107 int hostapd_ht_operation_update(struct hostapd_iface *iface);
108 void ieee802_11_send_sa_query_req(struct hostapd_data *hapd,
109 				  const u8 *addr, const u8 *trans_id);
110 void hostapd_get_ht_capab(struct hostapd_data *hapd,
111 			  struct ieee80211_ht_capabilities *ht_cap,
112 			  struct ieee80211_ht_capabilities *neg_ht_cap);
113 void hostapd_get_vht_capab(struct hostapd_data *hapd,
114 			   struct ieee80211_vht_capabilities *vht_cap,
115 			   struct ieee80211_vht_capabilities *neg_vht_cap);
116 void hostapd_get_he_capab(struct hostapd_data *hapd,
117 			  const struct ieee80211_he_capabilities *he_cap,
118 			  struct ieee80211_he_capabilities *neg_he_cap,
119 			  size_t he_capab_len);
120 void hostapd_get_eht_capab(struct hostapd_data *hapd,
121 			   const struct ieee80211_eht_capabilities *src,
122 			   struct ieee80211_eht_capabilities *dest,
123 			   size_t len);
124 u8 * hostapd_eid_eht_ml_beacon(struct hostapd_data *hapd,
125 			       struct mld_info *mld_info,
126 			       u8 *eid, bool include_mld_id);
127 u8 * hostapd_eid_eht_ml_assoc(struct hostapd_data *hapd, struct sta_info *info,
128 			      u8 *eid);
129 u8 * hostapd_eid_eht_basic_ml_common(struct hostapd_data *hapd,
130 				     u8 *eid, struct mld_info *mld_info,
131 				     bool include_mld_id, bool include_bpcc);
132 size_t hostapd_eid_eht_basic_ml_len(struct hostapd_data *hapd,
133 				    struct sta_info *info,
134 				    bool include_mld_id, bool include_pbcc);
135 size_t hostapd_eid_eht_ml_beacon_len(struct hostapd_data *hapd,
136 				     struct mld_info *info,
137 				     bool include_mld_id);
138 struct wpabuf * hostapd_ml_auth_resp(struct hostapd_data *hapd);
139 const u8 * hostapd_process_ml_auth(struct hostapd_data *hapd,
140 				   const struct ieee80211_mgmt *mgmt,
141 				   size_t len);
142 u16 hostapd_process_ml_assoc_req(struct hostapd_data *hapd,
143 				 struct ieee802_11_elems *elems,
144 				 struct sta_info *sta);
145 int hostapd_process_ml_assoc_req_addr(struct hostapd_data *hapd,
146 				      const u8 *basic_mle, size_t basic_mle_len,
147 				      u8 *mld_addr);
148 int hostapd_get_aid(struct hostapd_data *hapd, struct sta_info *sta);
149 u16 copy_sta_ht_capab(struct hostapd_data *hapd, struct sta_info *sta,
150 		      const u8 *ht_capab);
151 u16 copy_sta_vendor_vht(struct hostapd_data *hapd, struct sta_info *sta,
152 			const u8 *ie, size_t len);
153 
154 int update_ht_state(struct hostapd_data *hapd, struct sta_info *sta);
155 void ht40_intolerant_add(struct hostapd_iface *iface, struct sta_info *sta);
156 void ht40_intolerant_remove(struct hostapd_iface *iface, struct sta_info *sta);
157 u16 copy_sta_vht_capab(struct hostapd_data *hapd, struct sta_info *sta,
158 		       const u8 *vht_capab);
159 u16 copy_sta_vht_oper(struct hostapd_data *hapd, struct sta_info *sta,
160 		      const u8 *vht_oper);
161 u16 set_sta_vht_opmode(struct hostapd_data *hapd, struct sta_info *sta,
162 		       const u8 *vht_opmode);
163 u16 copy_sta_he_capab(struct hostapd_data *hapd, struct sta_info *sta,
164 		      enum ieee80211_op_mode opmode, const u8 *he_capab,
165 		      size_t he_capab_len);
166 u16 copy_sta_he_6ghz_capab(struct hostapd_data *hapd, struct sta_info *sta,
167 			   const u8 *he_6ghz_capab);
168 int hostapd_get_he_twt_responder(struct hostapd_data *hapd,
169 				 enum ieee80211_op_mode mode);
170 bool hostapd_get_ht_vht_twt_responder(struct hostapd_data *hapd);
171 void hostapd_wfa_capab(struct hostapd_data *hapd, struct sta_info *sta,
172 		       const u8 *pos, const u8 *end);
173 u8 * hostapd_eid_cca(struct hostapd_data *hapd, u8 *eid);
174 void hostapd_tx_status(struct hostapd_data *hapd, const u8 *addr,
175 		       const u8 *buf, size_t len, int ack);
176 void ieee802_11_rx_from_unknown(struct hostapd_data *hapd, const u8 *src,
177 				int wds);
178 u8 * hostapd_eid_assoc_comeback_time(struct hostapd_data *hapd,
179 				     struct sta_info *sta, u8 *eid);
180 void ieee802_11_sa_query_action(struct hostapd_data *hapd,
181 				const struct ieee80211_mgmt *mgmt,
182 				size_t len);
183 u8 * hostapd_eid_interworking(struct hostapd_data *hapd, u8 *eid);
184 u8 * hostapd_eid_adv_proto(struct hostapd_data *hapd, u8 *eid);
185 u8 * hostapd_eid_roaming_consortium(struct hostapd_data *hapd, u8 *eid);
186 u8 * hostapd_eid_time_adv(struct hostapd_data *hapd, u8 *eid);
187 u8 * hostapd_eid_time_zone(struct hostapd_data *hapd, u8 *eid);
188 int hostapd_update_time_adv(struct hostapd_data *hapd);
189 void hostapd_client_poll_ok(struct hostapd_data *hapd, const u8 *addr);
190 u8 * hostapd_eid_bss_max_idle_period(struct hostapd_data *hapd, u8 *eid,
191 				     u16 value);
192 
193 int auth_sae_init_committed(struct hostapd_data *hapd, struct sta_info *sta);
194 #ifdef CONFIG_SAE
195 void sae_clear_retransmit_timer(struct hostapd_data *hapd,
196 				struct sta_info *sta);
197 void sae_accept_sta(struct hostapd_data *hapd, struct sta_info *sta);
198 #else /* CONFIG_SAE */
sae_clear_retransmit_timer(struct hostapd_data * hapd,struct sta_info * sta)199 static inline void sae_clear_retransmit_timer(struct hostapd_data *hapd,
200 					      struct sta_info *sta)
201 {
202 }
203 #endif /* CONFIG_SAE */
204 
205 #ifdef CONFIG_MBO
206 
207 u8 * hostapd_eid_mbo(struct hostapd_data *hapd, u8 *eid, size_t len);
208 
209 u8 hostapd_mbo_ie_len(struct hostapd_data *hapd);
210 
211 u8 * hostapd_eid_mbo_rssi_assoc_rej(struct hostapd_data *hapd, u8 *eid,
212 				    size_t len, int delta);
213 
214 #else /* CONFIG_MBO */
215 
hostapd_eid_mbo(struct hostapd_data * hapd,u8 * eid,size_t len)216 static inline u8 * hostapd_eid_mbo(struct hostapd_data *hapd, u8 *eid,
217 				   size_t len)
218 {
219 	return eid;
220 }
221 
hostapd_mbo_ie_len(struct hostapd_data * hapd)222 static inline u8 hostapd_mbo_ie_len(struct hostapd_data *hapd)
223 {
224 	return 0;
225 }
226 
227 #endif /* CONFIG_MBO */
228 
229 void ap_copy_sta_supp_op_classes(struct sta_info *sta,
230 				 const u8 *supp_op_classes,
231 				 size_t supp_op_classes_len);
232 
233 u8 * hostapd_eid_fils_indic(struct hostapd_data *hapd, u8 *eid, int hessid);
234 void ieee802_11_finish_fils_auth(struct hostapd_data *hapd,
235 				 struct sta_info *sta, int success,
236 				 struct wpabuf *erp_resp,
237 				 const u8 *msk, size_t msk_len);
238 u8 * owe_assoc_req_process(struct hostapd_data *hapd, struct sta_info *sta,
239 			   const u8 *owe_dh, u8 owe_dh_len,
240 			   u8 *owe_buf, size_t owe_buf_len, u16 *status);
241 u16 owe_process_rsn_ie(struct hostapd_data *hapd, struct sta_info *sta,
242 		       const u8 *rsn_ie, size_t rsn_ie_len,
243 		       const u8 *owe_dh, size_t owe_dh_len,
244 		       const u8 *link_addr);
245 u16 owe_validate_request(struct hostapd_data *hapd, const u8 *peer,
246 			 const u8 *rsn_ie, size_t rsn_ie_len,
247 			 const u8 *owe_dh, size_t owe_dh_len);
248 void fils_hlp_timeout(void *eloop_ctx, void *eloop_data);
249 void fils_hlp_finish_assoc(struct hostapd_data *hapd, struct sta_info *sta);
250 void handle_auth_fils(struct hostapd_data *hapd, struct sta_info *sta,
251 		      const u8 *pos, size_t len, u16 auth_alg,
252 		      u16 auth_transaction, u16 status_code,
253 		      void (*cb)(struct hostapd_data *hapd,
254 				 struct sta_info *sta,
255 				 u16 resp, struct wpabuf *data, int pub));
256 
257 size_t hostapd_eid_owe_trans_len(struct hostapd_data *hapd);
258 u8 * hostapd_eid_owe_trans(struct hostapd_data *hapd, u8 *eid, size_t len);
259 
260 size_t hostapd_eid_dpp_cc_len(struct hostapd_data *hapd);
261 u8 * hostapd_eid_dpp_cc(struct hostapd_data *hapd, u8 *eid, size_t len);
262 
263 int get_tx_parameters(struct sta_info *sta, int ap_max_chanwidth,
264 		      int ap_seg1_idx, int *bandwidth, int *seg1_idx);
265 
266 void auth_sae_process_commit(void *eloop_ctx, void *user_ctx);
267 u8 * hostapd_eid_rsnxe(struct hostapd_data *hapd, u8 *eid, size_t len);
268 u16 check_ext_capab(struct hostapd_data *hapd, struct sta_info *sta,
269 		    const u8 *ext_capab_ie, size_t ext_capab_ie_len);
270 size_t hostapd_eid_rnr_len(struct hostapd_data *hapd, u32 type,
271 			   bool include_mld_params);
272 u8 * hostapd_eid_rnr(struct hostapd_data *hapd, u8 *eid, u32 type,
273 		     bool include_mld_params);
274 int ieee802_11_set_radius_info(struct hostapd_data *hapd, struct sta_info *sta,
275 			       int res, struct radius_sta *info);
276 size_t hostapd_eid_eht_capab_len(struct hostapd_data *hapd,
277 				 enum ieee80211_op_mode opmode);
278 u8 * hostapd_eid_eht_capab(struct hostapd_data *hapd, u8 *eid,
279 			   enum ieee80211_op_mode opmode);
280 u8 * hostapd_eid_eht_operation(struct hostapd_data *hapd, u8 *eid);
281 u16 copy_sta_eht_capab(struct hostapd_data *hapd, struct sta_info *sta,
282 		       enum ieee80211_op_mode opmode,
283 		       const u8 *he_capab, size_t he_capab_len,
284 		       const u8 *eht_capab, size_t eht_capab_len);
285 size_t hostapd_eid_mbssid_len(struct hostapd_data *hapd, u32 frame_type,
286 			      u8 *elem_count, const u8 *known_bss,
287 			      size_t known_bss_len, size_t *rnr_len);
288 u8 * hostapd_eid_mbssid(struct hostapd_data *hapd, u8 *eid, u8 *end,
289 			unsigned int frame_stype, u8 elem_count,
290 			u8 **elem_offset,
291 			const u8 *known_bss, size_t known_bss_len, u8 *rnr_eid,
292 			u8 *rnr_count, u8 **rnr_offset, size_t rnr_len);
293 bool hostapd_is_multiple_link_mld(struct hostapd_data *hapd);
294 int sae_password_bind(struct hostapd_data *hapd, const u8 *addr,
295 		      const char *password);
296 const char * sae_get_password(struct hostapd_data *hapd,
297 			      struct sta_info *sta, const u8 *rx_id,
298 			      size_t rx_id_len,
299 			      struct sae_password_entry **pw_entry,
300 			      struct sae_pt **s_pt, const struct sae_pk **s_pk);
301 struct sta_info * hostapd_ml_get_assoc_sta(struct hostapd_data *hapd,
302 					   struct sta_info *sta,
303 					   struct hostapd_data **assoc_hapd);
304 int hostapd_process_assoc_ml_info(struct hostapd_data *hapd,
305 				  struct sta_info *sta,
306 				  const u8 *ies, size_t ies_len,
307 				  bool reassoc, int tx_link_status,
308 				  bool offload,
309 				  bool *set_beacon);
310 
311 void ml_deinit_link_reconf_req(struct link_reconf_req_list **req_list_ptr);
312 int ieee80211_ml_process_link(struct hostapd_data *hapd,
313 			      struct sta_info *origin_sta,
314 			      struct mld_link_info *link,
315 			      const u8 *ies, size_t ies_len,
316 			      enum link_parse_type type, bool offload,
317 			      bool *set_beacon);
318 void ieee80211_ml_build_assoc_resp(struct hostapd_data *hapd,
319 				   struct mld_link_info *link);
320 
321 void ieee802_11_rx_protected_eht_action(struct hostapd_data *hapd,
322 					const struct ieee80211_mgmt *mgmt,
323 					size_t len);
324 void hostapd_link_reconf_resp_tx_status(struct hostapd_data *hapd,
325 					struct sta_info *sta,
326 					const struct ieee80211_mgmt *mgmt,
327 					size_t len, int ok);
328 
329 size_t hostapd_eid_eht_ml_tid_to_link_map_len(struct hostapd_data *hapd);
330 u8 * hostapd_eid_eht_ml_tid_to_link_map(struct hostapd_data *hapd, u8 *eid);
331 
332 void ieee80211_send_eap_req(struct hostapd_data *hapd, struct sta_info *sta,
333 			    u8 type, u16 auth_transaction, u16 status,
334 			    struct rsn_pmksa_cache_entry *cached_pmk,
335 			    const u8 *eap_req, size_t eap_req_len);
336 
337 #endif /* IEEE802_11_H */
338