• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1 /* SPDX-License-Identifier: (GPL-2.0 OR MPL-1.1) */
2 /*
3  *
4  *
5  * Macros, constants, types, and funcs for p80211 data types
6  *
7  * Copyright (C) 1999 AbsoluteValue Systems, Inc.  All Rights Reserved.
8  * --------------------------------------------------------------------
9  *
10  * linux-wlan
11  *
12  *   The contents of this file are subject to the Mozilla Public
13  *   License Version 1.1 (the "License"); you may not use this file
14  *   except in compliance with the License. You may obtain a copy of
15  *   the License at http://www.mozilla.org/MPL/
16  *
17  *   Software distributed under the License is distributed on an "AS
18  *   IS" basis, WITHOUT WARRANTY OF ANY KIND, either express or
19  *   implied. See the License for the specific language governing
20  *   rights and limitations under the License.
21  *
22  *   Alternatively, the contents of this file may be used under the
23  *   terms of the GNU Public License version 2 (the "GPL"), in which
24  *   case the provisions of the GPL are applicable instead of the
25  *   above.  If you wish to allow the use of your version of this file
26  *   only under the terms of the GPL and not to allow others to use
27  *   your version of this file under the MPL, indicate your decision
28  *   by deleting the provisions above and replace them with the notice
29  *   and other provisions required by the GPL.  If you do not delete
30  *   the provisions above, a recipient may use your version of this
31  *   file under either the MPL or the GPL.
32  *
33  * --------------------------------------------------------------------
34  *
35  * Inquiries regarding the linux-wlan Open Source project can be
36  * made directly to:
37  *
38  * AbsoluteValue Systems Inc.
39  * info@linux-wlan.com
40  * http://www.linux-wlan.com
41  *
42  * --------------------------------------------------------------------
43  *
44  * Portions of the development of this software were funded by
45  * Intersil Corporation as part of PRISM(R) chipset product development.
46  *
47  * --------------------------------------------------------------------
48  *
49  * This file declares some of the constants and types used in various
50  * parts of the linux-wlan system.
51  *
52  * Notes:
53  *   - Constant values are always in HOST byte order.
54  *
55  * All functions and statics declared here are implemented in p80211types.c
56  *   --------------------------------------------------------------------
57  */
58 
59 #ifndef _P80211TYPES_H
60 #define _P80211TYPES_H
61 
62 /*----------------------------------------------------------------*/
63 /* The following constants are indexes into the Mib Category List */
64 /* and the Message Category List */
65 
66 /* Mib Category List */
67 #define P80211_MIB_CAT_DOT11SMT		1
68 #define P80211_MIB_CAT_DOT11MAC		2
69 #define P80211_MIB_CAT_DOT11PHY		3
70 
71 #define P80211SEC_DOT11SMT		P80211_MIB_CAT_DOT11SMT
72 #define P80211SEC_DOT11MAC		P80211_MIB_CAT_DOT11MAC
73 #define P80211SEC_DOT11PHY		P80211_MIB_CAT_DOT11PHY
74 
75 /* Message Category List */
76 #define P80211_MSG_CAT_DOT11REQ		1
77 #define P80211_MSG_CAT_DOT11IND		2
78 
79 /*----------------------------------------------------------------*/
80 /* p80211 enumeration constants.  The value to text mappings for */
81 /*  these is in p80211types.c.  These defines were generated */
82 /*  from the mappings. */
83 
84 /* error codes for lookups */
85 
86 #define P80211ENUM_truth_false			0
87 #define P80211ENUM_truth_true			1
88 #define P80211ENUM_ifstate_disable		0
89 #define P80211ENUM_ifstate_fwload		1
90 #define P80211ENUM_ifstate_enable		2
91 #define P80211ENUM_bsstype_infrastructure	1
92 #define P80211ENUM_bsstype_independent		2
93 #define P80211ENUM_bsstype_any			3
94 #define P80211ENUM_authalg_opensystem		1
95 #define P80211ENUM_authalg_sharedkey		2
96 #define P80211ENUM_scantype_active		1
97 #define P80211ENUM_resultcode_success		1
98 #define P80211ENUM_resultcode_invalid_parameters	2
99 #define P80211ENUM_resultcode_not_supported	3
100 #define P80211ENUM_resultcode_refused		6
101 #define P80211ENUM_resultcode_cant_set_readonly_mib	10
102 #define P80211ENUM_resultcode_implementation_failure	11
103 #define P80211ENUM_resultcode_cant_get_writeonly_mib	12
104 #define P80211ENUM_status_successful		0
105 #define P80211ENUM_status_unspec_failure	1
106 #define P80211ENUM_status_ap_full		17
107 #define P80211ENUM_msgitem_status_data_ok		0
108 #define P80211ENUM_msgitem_status_no_value		1
109 
110 /*----------------------------------------------------------------*/
111 /* p80211 max length constants for the different pascal strings. */
112 
113 #define MAXLEN_PSTR6		(6)	/* pascal array of 6 bytes */
114 #define MAXLEN_PSTR14		(14)	/* pascal array of 14 bytes */
115 #define MAXLEN_PSTR32		(32)	/* pascal array of 32 bytes */
116 #define MAXLEN_PSTR255		(255)	/* pascal array of 255 bytes */
117 #define MAXLEN_MIBATTRIBUTE	(392)	/* maximum mibattribute */
118 					/* where the size of the DATA itself */
119 					/* is a DID-LEN-DATA triple */
120 					/* with a max size of 4+4+384 */
121 
122 /*----------------------------------------------------------------
123  * The following constants and macros are used to construct and
124  * deconstruct the Data ID codes.  The coding is as follows:
125  *
126  *     ...rwtnnnnnnnniiiiiiggggggssssss      s - Section
127  *                                           g - Group
128  *                                           i - Item
129  *                                           n - Index
130  *                                           t - Table flag
131  *                                           w - Write flag
132  *                                           r - Read flag
133  *                                           . - Unused
134  */
135 
136 #define P80211DID_LSB_SECTION		(0)
137 #define P80211DID_LSB_GROUP		(6)
138 #define P80211DID_LSB_ITEM		(12)
139 #define P80211DID_LSB_INDEX		(18)
140 #define P80211DID_LSB_ISTABLE		(26)
141 #define P80211DID_LSB_ACCESS		(27)
142 
143 #define P80211DID_MASK_SECTION		(0x0000003fUL)
144 #define P80211DID_MASK_GROUP		(0x0000003fUL)
145 #define P80211DID_MASK_ITEM		(0x0000003fUL)
146 #define P80211DID_MASK_INDEX		(0x000000ffUL)
147 #define P80211DID_MASK_ISTABLE		(0x00000001UL)
148 #define P80211DID_MASK_ACCESS		(0x00000003UL)
149 
150 #define P80211DID_MK(a, m, l)	((((u32)(a)) & (m)) << (l))
151 
152 #define P80211DID_MKSECTION(a)	P80211DID_MK(a, \
153 					P80211DID_MASK_SECTION, \
154 					P80211DID_LSB_SECTION)
155 #define P80211DID_MKGROUP(a)	P80211DID_MK(a, \
156 					P80211DID_MASK_GROUP, \
157 					P80211DID_LSB_GROUP)
158 #define P80211DID_MKITEM(a)	P80211DID_MK(a, \
159 					P80211DID_MASK_ITEM, \
160 					P80211DID_LSB_ITEM)
161 #define P80211DID_MKINDEX(a)	P80211DID_MK(a, \
162 					P80211DID_MASK_INDEX, \
163 					P80211DID_LSB_INDEX)
164 #define P80211DID_MKISTABLE(a)	P80211DID_MK(a, \
165 					P80211DID_MASK_ISTABLE, \
166 					P80211DID_LSB_ISTABLE)
167 
168 #define P80211DID_MKID(s, g, i, n, t, a)	(P80211DID_MKSECTION(s) | \
169 					P80211DID_MKGROUP(g) | \
170 					P80211DID_MKITEM(i) | \
171 					P80211DID_MKINDEX(n) | \
172 					P80211DID_MKISTABLE(t) | \
173 					(a))
174 
175 #define P80211DID_GET(a, m, l)	((((u32)(a)) >> (l)) & (m))
176 
177 #define P80211DID_SECTION(a)	P80211DID_GET(a, \
178 					P80211DID_MASK_SECTION, \
179 					P80211DID_LSB_SECTION)
180 #define P80211DID_GROUP(a)	P80211DID_GET(a, \
181 					P80211DID_MASK_GROUP, \
182 					P80211DID_LSB_GROUP)
183 #define P80211DID_ITEM(a)	P80211DID_GET(a, \
184 					P80211DID_MASK_ITEM, \
185 					P80211DID_LSB_ITEM)
186 #define P80211DID_INDEX(a)	P80211DID_GET(a, \
187 					P80211DID_MASK_INDEX, \
188 					P80211DID_LSB_INDEX)
189 #define P80211DID_ISTABLE(a)	P80211DID_GET(a, \
190 					P80211DID_MASK_ISTABLE, \
191 					P80211DID_LSB_ISTABLE)
192 #define P80211DID_ACCESS(a)	P80211DID_GET(a, \
193 					P80211DID_MASK_ACCESS, \
194 					P80211DID_LSB_ACCESS)
195 
196 /*----------------------------------------------------------------*/
197 /* The following structure types are used to store data items in */
198 /*  messages. */
199 
200 /* Template pascal string */
201 struct p80211pstr {
202 	u8 len;
203 } __packed;
204 
205 struct p80211pstrd {
206 	u8 len;
207 	u8 data[];
208 } __packed;
209 
210 /* Maximum pascal string */
211 struct p80211pstr255 {
212 	u8 len;
213 	u8 data[MAXLEN_PSTR255];
214 } __packed;
215 
216 /* pascal string for macaddress and bssid */
217 struct p80211pstr6 {
218 	u8 len;
219 	u8 data[MAXLEN_PSTR6];
220 } __packed;
221 
222 /* pascal string for channel list */
223 struct p80211pstr14 {
224 	u8 len;
225 	u8 data[MAXLEN_PSTR14];
226 } __packed;
227 
228 /* pascal string for ssid */
229 struct p80211pstr32 {
230 	u8 len;
231 	u8 data[MAXLEN_PSTR32];
232 } __packed;
233 
234 /* MAC address array */
235 struct p80211macarray {
236 	u32 cnt;
237 	u8 data[1][MAXLEN_PSTR6];
238 } __packed;
239 
240 /* prototype template */
241 struct p80211item {
242 	u32 did;
243 	u16 status;
244 	u16 len;
245 } __packed;
246 
247 /* prototype template w/ data item */
248 struct p80211itemd {
249 	u32 did;
250 	u16 status;
251 	u16 len;
252 	u8 data[];
253 } __packed;
254 
255 /* message data item for int, BOUNDEDINT, ENUMINT */
256 struct p80211item_uint32 {
257 	u32 did;
258 	u16 status;
259 	u16 len;
260 	u32 data;
261 } __packed;
262 
263 /* message data item for OCTETSTR, DISPLAYSTR */
264 struct p80211item_pstr6 {
265 	u32 did;
266 	u16 status;
267 	u16 len;
268 	struct p80211pstr6 data;
269 } __packed;
270 
271 /* message data item for OCTETSTR, DISPLAYSTR */
272 struct p80211item_pstr14 {
273 	u32 did;
274 	u16 status;
275 	u16 len;
276 	struct p80211pstr14 data;
277 } __packed;
278 
279 /* message data item for OCTETSTR, DISPLAYSTR */
280 struct p80211item_pstr32 {
281 	u32 did;
282 	u16 status;
283 	u16 len;
284 	struct p80211pstr32 data;
285 } __packed;
286 
287 /* message data item for OCTETSTR, DISPLAYSTR */
288 struct p80211item_pstr255 {
289 	u32 did;
290 	u16 status;
291 	u16 len;
292 	struct p80211pstr255 data;
293 } __packed;
294 
295 /* message data item for UNK 392, namely mib items */
296 struct p80211item_unk392 {
297 	u32 did;
298 	u16 status;
299 	u16 len;
300 	u8 data[MAXLEN_MIBATTRIBUTE];
301 } __packed;
302 
303 /* message data item for UNK 1025, namely p2 pdas */
304 struct p80211item_unk1024 {
305 	u32 did;
306 	u16 status;
307 	u16 len;
308 	u8 data[1024];
309 } __packed;
310 
311 /* message data item for UNK 4096, namely p2 download chunks */
312 struct p80211item_unk4096 {
313 	u32 did;
314 	u16 status;
315 	u16 len;
316 	u8 data[4096];
317 } __packed;
318 
319 #endif /* _P80211TYPES_H */
320