Line data Source code
1 : /*
2 : * hostapd / IEEE 802.11 Management
3 : * Copyright (c) 2002-2012, 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 : #include "utils/includes.h"
10 :
11 : #include "utils/common.h"
12 : #include "common/ieee802_11_defs.h"
13 : #include "hostapd.h"
14 : #include "sta_info.h"
15 : #include "ap_config.h"
16 : #include "ap_drv_ops.h"
17 : #include "ieee802_11.h"
18 :
19 :
20 : #ifdef CONFIG_IEEE80211W
21 :
22 4 : u8 * hostapd_eid_assoc_comeback_time(struct hostapd_data *hapd,
23 : struct sta_info *sta, u8 *eid)
24 : {
25 4 : u8 *pos = eid;
26 : u32 timeout, tu;
27 : struct os_reltime now, passed;
28 :
29 4 : *pos++ = WLAN_EID_TIMEOUT_INTERVAL;
30 4 : *pos++ = 5;
31 4 : *pos++ = WLAN_TIMEOUT_ASSOC_COMEBACK;
32 4 : os_get_reltime(&now);
33 4 : os_reltime_sub(&now, &sta->sa_query_start, &passed);
34 4 : tu = (passed.sec * 1000000 + passed.usec) / 1024;
35 4 : if (hapd->conf->assoc_sa_query_max_timeout > tu)
36 3 : timeout = hapd->conf->assoc_sa_query_max_timeout - tu;
37 : else
38 1 : timeout = 0;
39 4 : if (timeout < hapd->conf->assoc_sa_query_max_timeout)
40 4 : timeout++; /* add some extra time for local timers */
41 4 : WPA_PUT_LE32(pos, timeout);
42 4 : pos += 4;
43 :
44 4 : return pos;
45 : }
46 :
47 :
48 : /* MLME-SAQuery.request */
49 19 : void ieee802_11_send_sa_query_req(struct hostapd_data *hapd,
50 : const u8 *addr, const u8 *trans_id)
51 : {
52 : struct ieee80211_mgmt mgmt;
53 : u8 *end;
54 :
55 114 : wpa_printf(MSG_DEBUG, "IEEE 802.11: Sending SA Query Request to "
56 114 : MACSTR, MAC2STR(addr));
57 19 : wpa_hexdump(MSG_DEBUG, "IEEE 802.11: SA Query Transaction ID",
58 : trans_id, WLAN_SA_QUERY_TR_ID_LEN);
59 :
60 19 : os_memset(&mgmt, 0, sizeof(mgmt));
61 19 : mgmt.frame_control = IEEE80211_FC(WLAN_FC_TYPE_MGMT,
62 : WLAN_FC_STYPE_ACTION);
63 19 : os_memcpy(mgmt.da, addr, ETH_ALEN);
64 19 : os_memcpy(mgmt.sa, hapd->own_addr, ETH_ALEN);
65 19 : os_memcpy(mgmt.bssid, hapd->own_addr, ETH_ALEN);
66 19 : mgmt.u.action.category = WLAN_ACTION_SA_QUERY;
67 19 : mgmt.u.action.u.sa_query_req.action = WLAN_SA_QUERY_REQUEST;
68 19 : os_memcpy(mgmt.u.action.u.sa_query_req.trans_id, trans_id,
69 : WLAN_SA_QUERY_TR_ID_LEN);
70 19 : end = mgmt.u.action.u.sa_query_req.trans_id + WLAN_SA_QUERY_TR_ID_LEN;
71 19 : if (hostapd_drv_send_mlme(hapd, &mgmt, end - (u8 *) &mgmt, 0) < 0)
72 8 : wpa_printf(MSG_INFO, "ieee802_11_send_sa_query_req: send failed");
73 19 : }
74 :
75 :
76 3 : static void ieee802_11_send_sa_query_resp(struct hostapd_data *hapd,
77 : const u8 *sa, const u8 *trans_id)
78 : {
79 : struct sta_info *sta;
80 : struct ieee80211_mgmt resp;
81 : u8 *end;
82 :
83 18 : wpa_printf(MSG_DEBUG, "IEEE 802.11: Received SA Query Request from "
84 18 : MACSTR, MAC2STR(sa));
85 3 : wpa_hexdump(MSG_DEBUG, "IEEE 802.11: SA Query Transaction ID",
86 : trans_id, WLAN_SA_QUERY_TR_ID_LEN);
87 :
88 3 : sta = ap_get_sta(hapd, sa);
89 3 : if (sta == NULL || !(sta->flags & WLAN_STA_ASSOC)) {
90 0 : wpa_printf(MSG_DEBUG, "IEEE 802.11: Ignore SA Query Request "
91 0 : "from unassociated STA " MACSTR, MAC2STR(sa));
92 3 : return;
93 : }
94 :
95 18 : wpa_printf(MSG_DEBUG, "IEEE 802.11: Sending SA Query Response to "
96 18 : MACSTR, MAC2STR(sa));
97 :
98 3 : os_memset(&resp, 0, sizeof(resp));
99 3 : resp.frame_control = IEEE80211_FC(WLAN_FC_TYPE_MGMT,
100 : WLAN_FC_STYPE_ACTION);
101 3 : os_memcpy(resp.da, sa, ETH_ALEN);
102 3 : os_memcpy(resp.sa, hapd->own_addr, ETH_ALEN);
103 3 : os_memcpy(resp.bssid, hapd->own_addr, ETH_ALEN);
104 3 : resp.u.action.category = WLAN_ACTION_SA_QUERY;
105 3 : resp.u.action.u.sa_query_req.action = WLAN_SA_QUERY_RESPONSE;
106 3 : os_memcpy(resp.u.action.u.sa_query_req.trans_id, trans_id,
107 : WLAN_SA_QUERY_TR_ID_LEN);
108 3 : end = resp.u.action.u.sa_query_req.trans_id + WLAN_SA_QUERY_TR_ID_LEN;
109 3 : if (hostapd_drv_send_mlme(hapd, &resp, end - (u8 *) &resp, 0) < 0)
110 0 : wpa_printf(MSG_INFO, "ieee80211_mgmt_sa_query_request: send failed");
111 : }
112 :
113 :
114 5 : void ieee802_11_sa_query_action(struct hostapd_data *hapd, const u8 *sa,
115 : const u8 action_type, const u8 *trans_id)
116 : {
117 : struct sta_info *sta;
118 : int i;
119 :
120 5 : if (action_type == WLAN_SA_QUERY_REQUEST) {
121 3 : ieee802_11_send_sa_query_resp(hapd, sa, trans_id);
122 3 : return;
123 : }
124 :
125 2 : if (action_type != WLAN_SA_QUERY_RESPONSE) {
126 0 : wpa_printf(MSG_DEBUG, "IEEE 802.11: Unexpected SA Query "
127 : "Action %d", action_type);
128 0 : return;
129 : }
130 :
131 12 : wpa_printf(MSG_DEBUG, "IEEE 802.11: Received SA Query Response from "
132 12 : MACSTR, MAC2STR(sa));
133 2 : wpa_hexdump(MSG_DEBUG, "IEEE 802.11: SA Query Transaction ID",
134 : trans_id, WLAN_SA_QUERY_TR_ID_LEN);
135 :
136 : /* MLME-SAQuery.confirm */
137 :
138 2 : sta = ap_get_sta(hapd, sa);
139 2 : if (sta == NULL || sta->sa_query_trans_id == NULL) {
140 2 : wpa_printf(MSG_DEBUG, "IEEE 802.11: No matching STA with "
141 : "pending SA Query request found");
142 2 : return;
143 : }
144 :
145 0 : for (i = 0; i < sta->sa_query_count; i++) {
146 0 : if (os_memcmp(sta->sa_query_trans_id +
147 : i * WLAN_SA_QUERY_TR_ID_LEN,
148 : trans_id, WLAN_SA_QUERY_TR_ID_LEN) == 0)
149 0 : break;
150 : }
151 :
152 0 : if (i >= sta->sa_query_count) {
153 0 : wpa_printf(MSG_DEBUG, "IEEE 802.11: No matching SA Query "
154 : "transaction identifier found");
155 0 : return;
156 : }
157 :
158 0 : hostapd_logger(hapd, sta->addr, HOSTAPD_MODULE_IEEE80211,
159 : HOSTAPD_LEVEL_DEBUG,
160 : "Reply to pending SA Query received");
161 0 : ap_sta_stop_sa_query(hapd, sta);
162 : }
163 :
164 : #endif /* CONFIG_IEEE80211W */
165 :
166 :
167 162619 : static void hostapd_ext_capab_byte(struct hostapd_data *hapd, u8 *pos, int idx)
168 : {
169 162619 : *pos = 0x00;
170 :
171 162619 : switch (idx) {
172 : case 0: /* Bits 0-7 */
173 20339 : if (hapd->iconf->obss_interval)
174 32 : *pos |= 0x01; /* Bit 0 - Coexistence management */
175 20339 : if (hapd->iface->drv_flags & WPA_DRIVER_FLAGS_AP_CSA)
176 20315 : *pos |= 0x04; /* Bit 2 - Extended Channel Switching */
177 20339 : break;
178 : case 1: /* Bits 8-15 */
179 20339 : if (hapd->conf->proxy_arp)
180 69 : *pos |= 0x10; /* Bit 12 - Proxy ARP */
181 20339 : break;
182 : case 2: /* Bits 16-23 */
183 20339 : if (hapd->conf->wnm_sleep_mode)
184 44 : *pos |= 0x02; /* Bit 17 - WNM-Sleep Mode */
185 20339 : if (hapd->conf->bss_transition)
186 175 : *pos |= 0x08; /* Bit 19 - BSS Transition */
187 20339 : break;
188 : case 3: /* Bits 24-31 */
189 : #ifdef CONFIG_WNM
190 20339 : *pos |= 0x02; /* Bit 25 - SSID List */
191 : #endif /* CONFIG_WNM */
192 20339 : if (hapd->conf->time_advertisement == 2)
193 28 : *pos |= 0x08; /* Bit 27 - UTC TSF Offset */
194 20339 : if (hapd->conf->interworking)
195 1038 : *pos |= 0x80; /* Bit 31 - Interworking */
196 20339 : break;
197 : case 4: /* Bits 32-39 */
198 20315 : if (hapd->conf->qos_map_set_len)
199 4 : *pos |= 0x01; /* Bit 32 - QoS Map */
200 20315 : if (hapd->conf->tdls & TDLS_PROHIBIT)
201 0 : *pos |= 0x40; /* Bit 38 - TDLS Prohibited */
202 20315 : if (hapd->conf->tdls & TDLS_PROHIBIT_CHAN_SWITCH) {
203 : /* Bit 39 - TDLS Channel Switching Prohibited */
204 0 : *pos |= 0x80;
205 : }
206 20315 : break;
207 : case 5: /* Bits 40-47 */
208 : #ifdef CONFIG_HS20
209 20315 : if (hapd->conf->hs20)
210 1028 : *pos |= 0x40; /* Bit 46 - WNM-Notification */
211 : #endif /* CONFIG_HS20 */
212 : #ifdef CONFIG_MBO
213 20315 : if (hapd->conf->mbo_enabled)
214 93 : *pos |= 0x40; /* Bit 46 - WNM-Notification */
215 : #endif /* CONFIG_MBO */
216 20315 : break;
217 : case 6: /* Bits 48-55 */
218 20315 : if (hapd->conf->ssid.utf8_ssid)
219 6 : *pos |= 0x01; /* Bit 48 - UTF-8 SSID */
220 20315 : break;
221 : case 8: /* Bits 64-71 */
222 3 : if (hapd->conf->ftm_responder)
223 3 : *pos |= 0x40; /* Bit 70 - FTM responder */
224 3 : if (hapd->conf->ftm_initiator)
225 3 : *pos |= 0x80; /* Bit 71 - FTM initiator */
226 3 : break;
227 : }
228 162619 : }
229 :
230 :
231 20339 : u8 * hostapd_eid_ext_capab(struct hostapd_data *hapd, u8 *eid)
232 : {
233 20339 : u8 *pos = eid;
234 20339 : u8 len = 0, i;
235 :
236 20339 : if (hapd->conf->tdls & (TDLS_PROHIBIT | TDLS_PROHIBIT_CHAN_SWITCH))
237 0 : len = 5;
238 20339 : if (len < 4 && hapd->conf->interworking)
239 1038 : len = 4;
240 20339 : if (len < 3 && hapd->conf->wnm_sleep_mode)
241 44 : len = 3;
242 20339 : if (len < 1 && hapd->iconf->obss_interval)
243 32 : len = 1;
244 20339 : if (len < 7 && hapd->conf->ssid.utf8_ssid)
245 6 : len = 7;
246 40678 : if (len < 9 &&
247 40675 : (hapd->conf->ftm_initiator || hapd->conf->ftm_responder))
248 3 : len = 9;
249 : #ifdef CONFIG_WNM
250 20339 : if (len < 4)
251 19292 : len = 4;
252 : #endif /* CONFIG_WNM */
253 : #ifdef CONFIG_HS20
254 20339 : if (hapd->conf->hs20 && len < 6)
255 1028 : len = 6;
256 : #endif /* CONFIG_HS20 */
257 : #ifdef CONFIG_MBO
258 20339 : if (hapd->conf->mbo_enabled && len < 6)
259 93 : len = 6;
260 : #endif /* CONFIG_MBO */
261 20339 : if (len < hapd->iface->extended_capa_len)
262 20312 : len = hapd->iface->extended_capa_len;
263 20339 : if (len == 0)
264 0 : return eid;
265 :
266 20339 : *pos++ = WLAN_EID_EXT_CAPAB;
267 20339 : *pos++ = len;
268 182958 : for (i = 0; i < len; i++, pos++) {
269 162619 : hostapd_ext_capab_byte(hapd, pos, i);
270 :
271 162619 : if (i < hapd->iface->extended_capa_len) {
272 162520 : *pos &= ~hapd->iface->extended_capa_mask[i];
273 162520 : *pos |= hapd->iface->extended_capa[i];
274 : }
275 : }
276 :
277 40678 : while (len > 0 && eid[1 + len] == 0) {
278 0 : len--;
279 0 : eid[1] = len;
280 : }
281 20339 : if (len == 0)
282 0 : return eid;
283 :
284 20339 : return eid + 2 + len;
285 : }
286 :
287 :
288 4669 : u8 * hostapd_eid_qos_map_set(struct hostapd_data *hapd, u8 *eid)
289 : {
290 4669 : u8 *pos = eid;
291 4669 : u8 len = hapd->conf->qos_map_set_len;
292 :
293 4669 : if (!len)
294 4668 : return eid;
295 :
296 1 : *pos++ = WLAN_EID_QOS_MAP_SET;
297 1 : *pos++ = len;
298 1 : os_memcpy(pos, hapd->conf->qos_map_set, len);
299 1 : pos += len;
300 :
301 1 : return pos;
302 : }
303 :
304 :
305 15533 : u8 * hostapd_eid_interworking(struct hostapd_data *hapd, u8 *eid)
306 : {
307 15533 : u8 *pos = eid;
308 : #ifdef CONFIG_INTERWORKING
309 : u8 *len;
310 :
311 15533 : if (!hapd->conf->interworking)
312 14616 : return eid;
313 :
314 917 : *pos++ = WLAN_EID_INTERWORKING;
315 917 : len = pos++;
316 :
317 917 : *pos = hapd->conf->access_network_type;
318 917 : if (hapd->conf->internet)
319 907 : *pos |= INTERWORKING_ANO_INTERNET;
320 917 : if (hapd->conf->asra)
321 3 : *pos |= INTERWORKING_ANO_ASRA;
322 917 : if (hapd->conf->esr)
323 3 : *pos |= INTERWORKING_ANO_ESR;
324 917 : if (hapd->conf->uesa)
325 3 : *pos |= INTERWORKING_ANO_UESA;
326 917 : pos++;
327 :
328 917 : if (hapd->conf->venue_info_set) {
329 903 : *pos++ = hapd->conf->venue_group;
330 903 : *pos++ = hapd->conf->venue_type;
331 : }
332 :
333 917 : if (!is_zero_ether_addr(hapd->conf->hessid)) {
334 475 : os_memcpy(pos, hapd->conf->hessid, ETH_ALEN);
335 475 : pos += ETH_ALEN;
336 : }
337 :
338 917 : *len = pos - len - 1;
339 : #endif /* CONFIG_INTERWORKING */
340 :
341 917 : return pos;
342 : }
343 :
344 :
345 15533 : u8 * hostapd_eid_adv_proto(struct hostapd_data *hapd, u8 *eid)
346 : {
347 15533 : u8 *pos = eid;
348 : #ifdef CONFIG_INTERWORKING
349 :
350 : /* TODO: Separate configuration for ANQP? */
351 15533 : if (!hapd->conf->interworking)
352 14616 : return eid;
353 :
354 917 : *pos++ = WLAN_EID_ADV_PROTO;
355 917 : *pos++ = 2;
356 917 : *pos++ = 0x7F; /* Query Response Length Limit | PAME-BI */
357 917 : *pos++ = ACCESS_NETWORK_QUERY_PROTOCOL;
358 : #endif /* CONFIG_INTERWORKING */
359 :
360 917 : return pos;
361 : }
362 :
363 :
364 15533 : u8 * hostapd_eid_roaming_consortium(struct hostapd_data *hapd, u8 *eid)
365 : {
366 15533 : u8 *pos = eid;
367 : #ifdef CONFIG_INTERWORKING
368 : u8 *len;
369 : unsigned int i, count;
370 :
371 16450 : if (!hapd->conf->interworking ||
372 1810 : hapd->conf->roaming_consortium == NULL ||
373 893 : hapd->conf->roaming_consortium_count == 0)
374 14640 : return eid;
375 :
376 893 : *pos++ = WLAN_EID_ROAMING_CONSORTIUM;
377 893 : len = pos++;
378 :
379 : /* Number of ANQP OIs (in addition to the max 3 listed here) */
380 893 : if (hapd->conf->roaming_consortium_count > 3 + 255)
381 0 : *pos++ = 255;
382 893 : else if (hapd->conf->roaming_consortium_count > 3)
383 871 : *pos++ = hapd->conf->roaming_consortium_count - 3;
384 : else
385 22 : *pos++ = 0;
386 :
387 : /* OU #1 and #2 Lengths */
388 893 : *pos = hapd->conf->roaming_consortium[0].len;
389 893 : if (hapd->conf->roaming_consortium_count > 1)
390 871 : *pos |= hapd->conf->roaming_consortium[1].len << 4;
391 893 : pos++;
392 :
393 893 : if (hapd->conf->roaming_consortium_count > 3)
394 871 : count = 3;
395 : else
396 22 : count = hapd->conf->roaming_consortium_count;
397 :
398 3528 : for (i = 0; i < count; i++) {
399 2635 : os_memcpy(pos, hapd->conf->roaming_consortium[i].oi,
400 : hapd->conf->roaming_consortium[i].len);
401 2635 : pos += hapd->conf->roaming_consortium[i].len;
402 : }
403 :
404 893 : *len = pos - len - 1;
405 : #endif /* CONFIG_INTERWORKING */
406 :
407 893 : return pos;
408 : }
409 :
410 :
411 15533 : u8 * hostapd_eid_time_adv(struct hostapd_data *hapd, u8 *eid)
412 : {
413 15533 : if (hapd->conf->time_advertisement != 2)
414 15511 : return eid;
415 :
416 28 : if (hapd->time_adv == NULL &&
417 6 : hostapd_update_time_adv(hapd) < 0)
418 0 : return eid;
419 :
420 22 : if (hapd->time_adv == NULL)
421 0 : return eid;
422 :
423 22 : os_memcpy(eid, wpabuf_head(hapd->time_adv),
424 : wpabuf_len(hapd->time_adv));
425 22 : eid += wpabuf_len(hapd->time_adv);
426 :
427 22 : return eid;
428 : }
429 :
430 :
431 10167 : u8 * hostapd_eid_time_zone(struct hostapd_data *hapd, u8 *eid)
432 : {
433 : size_t len;
434 :
435 10167 : if (hapd->conf->time_advertisement != 2)
436 10151 : return eid;
437 :
438 16 : len = os_strlen(hapd->conf->time_zone);
439 :
440 16 : *eid++ = WLAN_EID_TIME_ZONE;
441 16 : *eid++ = len;
442 16 : os_memcpy(eid, hapd->conf->time_zone, len);
443 16 : eid += len;
444 :
445 16 : return eid;
446 : }
447 :
448 :
449 6 : int hostapd_update_time_adv(struct hostapd_data *hapd)
450 : {
451 6 : const int elen = 2 + 1 + 10 + 5 + 1;
452 : struct os_time t;
453 : struct os_tm tm;
454 : u8 *pos;
455 :
456 6 : if (hapd->conf->time_advertisement != 2)
457 0 : return 0;
458 :
459 6 : if (os_get_time(&t) < 0 || os_gmtime(t.sec, &tm) < 0)
460 0 : return -1;
461 :
462 6 : if (!hapd->time_adv) {
463 6 : hapd->time_adv = wpabuf_alloc(elen);
464 6 : if (hapd->time_adv == NULL)
465 0 : return -1;
466 6 : pos = wpabuf_put(hapd->time_adv, elen);
467 : } else
468 0 : pos = wpabuf_mhead_u8(hapd->time_adv);
469 :
470 6 : *pos++ = WLAN_EID_TIME_ADVERTISEMENT;
471 6 : *pos++ = 1 + 10 + 5 + 1;
472 :
473 6 : *pos++ = 2; /* UTC time at which the TSF timer is 0 */
474 :
475 : /* Time Value at TSF 0 */
476 : /* FIX: need to calculate this based on the current TSF value */
477 6 : WPA_PUT_LE16(pos, tm.year); /* Year */
478 6 : pos += 2;
479 6 : *pos++ = tm.month; /* Month */
480 6 : *pos++ = tm.day; /* Day of month */
481 6 : *pos++ = tm.hour; /* Hours */
482 6 : *pos++ = tm.min; /* Minutes */
483 6 : *pos++ = tm.sec; /* Seconds */
484 6 : WPA_PUT_LE16(pos, 0); /* Milliseconds (not used) */
485 6 : pos += 2;
486 6 : *pos++ = 0; /* Reserved */
487 :
488 : /* Time Error */
489 : /* TODO: fill in an estimate on the error */
490 6 : *pos++ = 0;
491 6 : *pos++ = 0;
492 6 : *pos++ = 0;
493 6 : *pos++ = 0;
494 6 : *pos++ = 0;
495 :
496 6 : *pos++ = hapd->time_update_counter++;
497 :
498 6 : return 0;
499 : }
500 :
501 :
502 4806 : u8 * hostapd_eid_bss_max_idle_period(struct hostapd_data *hapd, u8 *eid)
503 : {
504 4806 : u8 *pos = eid;
505 :
506 : #ifdef CONFIG_WNM
507 4806 : if (hapd->conf->ap_max_inactivity > 0) {
508 : unsigned int val;
509 4806 : *pos++ = WLAN_EID_BSS_MAX_IDLE_PERIOD;
510 4806 : *pos++ = 3;
511 4806 : val = hapd->conf->ap_max_inactivity;
512 4806 : if (val > 68000)
513 0 : val = 68000;
514 4806 : val *= 1000;
515 4806 : val /= 1024;
516 4806 : if (val == 0)
517 6 : val = 1;
518 4806 : if (val > 65535)
519 0 : val = 65535;
520 4806 : WPA_PUT_LE16(pos, val);
521 4806 : pos += 2;
522 4806 : *pos++ = 0x00; /* TODO: Protected Keep-Alive Required */
523 : }
524 : #endif /* CONFIG_WNM */
525 :
526 4806 : return pos;
527 : }
528 :
529 :
530 : #ifdef CONFIG_MBO
531 :
532 14998 : u8 * hostapd_eid_mbo(struct hostapd_data *hapd, u8 *eid, size_t len)
533 : {
534 14998 : u8 mbo[6], *mbo_pos = mbo;
535 14998 : u8 *pos = eid;
536 :
537 14998 : if (!hapd->conf->mbo_enabled)
538 14905 : return eid;
539 :
540 93 : *mbo_pos++ = MBO_ATTR_ID_AP_CAPA_IND;
541 93 : *mbo_pos++ = 1;
542 : /* Not Cellular aware */
543 93 : *mbo_pos++ = 0;
544 :
545 93 : if (hapd->mbo_assoc_disallow) {
546 11 : *mbo_pos++ = MBO_ATTR_ID_ASSOC_DISALLOW;
547 11 : *mbo_pos++ = 1;
548 11 : *mbo_pos++ = hapd->mbo_assoc_disallow;
549 : }
550 :
551 93 : pos += mbo_add_ie(pos, len, mbo, mbo_pos - mbo);
552 :
553 93 : return pos;
554 : }
555 :
556 :
557 10169 : u8 hostapd_mbo_ie_len(struct hostapd_data *hapd)
558 : {
559 10169 : if (!hapd->conf->mbo_enabled)
560 10121 : return 0;
561 :
562 : /*
563 : * MBO IE header (6) + Capability Indication attribute (3) +
564 : * Association Disallowed attribute (3) = 12
565 : */
566 48 : return 6 + 3 + (hapd->mbo_assoc_disallow ? 3 : 0);
567 : }
568 :
569 : #endif /* CONFIG_MBO */
570 :
571 :
572 4756 : void ap_copy_sta_supp_op_classes(struct sta_info *sta,
573 : const u8 *supp_op_classes,
574 : size_t supp_op_classes_len)
575 : {
576 4756 : if (!supp_op_classes)
577 4737 : return;
578 19 : os_free(sta->supp_op_classes);
579 19 : sta->supp_op_classes = os_malloc(1 + supp_op_classes_len);
580 19 : if (!sta->supp_op_classes)
581 0 : return;
582 :
583 19 : sta->supp_op_classes[0] = supp_op_classes_len;
584 19 : os_memcpy(sta->supp_op_classes + 1, supp_op_classes,
585 : supp_op_classes_len);
586 : }
|