1 /*
2  * IEEE 802.11 Common routines
3  * Copyright (c) 2002-2019, 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_COMMON_H
10 #define IEEE802_11_COMMON_H
11 
12 #include "defs.h"
13 #include "ieee802_11_defs.h"
14 #include "esp_wifi_driver.h"
15 
16 struct element {
17 	u8 id;
18 	u8 datalen;
19 	u8 data[];
20 } STRUCT_PACKED;
21 
22 /* element iteration helpers */
23 #define for_each_element(_elem, _data, _datalen)                        \
24 	for (_elem = (const struct element *) (_data);                  \
25 			(const u8 *) (_data) + (_datalen) - (const u8 *) _elem >=  \
26 			(int) sizeof(*_elem) &&                                 \
27 			(const u8 *) (_data) + (_datalen) - (const u8 *) _elem >=  \
28 			(int) sizeof(*_elem) + _elem->datalen;                  \
29 			_elem = (const struct element *) (_elem->data + _elem->datalen))
30 
31 #define for_each_element_id(element, _id, data, datalen)                \
32 	for_each_element(element, data, datalen)                        \
33 	if (element->id == (_id))
34 
35 struct wpa_supplicant;
36 
37 int ieee802_11_parse_candidate_list(const char *pos, u8 *nei_rep,
38 				    size_t nei_rep_len);
39 const u8 * get_ie(const u8 *ies, size_t len, u8 eid);
40 int ieee802_11_parse_elems(struct wpa_supplicant *wpa_s, const u8 *start, size_t len);
41 int ieee802_11_ext_capab(const u8 *ie, unsigned int capab);
42 const u8 * get_vendor_ie(const u8 *ies, size_t len, u32 vendor_type);
43 size_t mbo_add_ie(u8 *buf, size_t len, const u8 *attr, size_t attr_len);
44 u8 get_operating_class(u8 chan, int sec_channel);
45 #endif /* IEEE802_11_COMMON_H */
46