1 /* SPDX-License-Identifier: (GPL-2.0 OR MPL-1.1) */
4 * Macros, types, and functions to handle 802.11 mgmt frames
6 * Copyright (C) 1999 AbsoluteValue Systems, Inc. All Rights Reserved.
7 * --------------------------------------------------------------------
11 * The contents of this file are subject to the Mozilla Public
12 * License Version 1.1 (the "License"); you may not use this file
13 * except in compliance with the License. You may obtain a copy of
14 * the License at http://www.mozilla.org/MPL/
16 * Software distributed under the License is distributed on an "AS
17 * IS" basis, WITHOUT WARRANTY OF ANY KIND, either express or
18 * implied. See the License for the specific language governing
19 * rights and limitations under the License.
21 * Alternatively, the contents of this file may be used under the
22 * terms of the GNU Public License version 2 (the "GPL"), in which
23 * case the provisions of the GPL are applicable instead of the
24 * above. If you wish to allow the use of your version of this file
25 * only under the terms of the GPL and not to allow others to use
26 * your version of this file under the MPL, indicate your decision
27 * by deleting the provisions above and replace them with the notice
28 * and other provisions required by the GPL. If you do not delete
29 * the provisions above, a recipient may use your version of this
30 * file under either the MPL or the GPL.
32 * --------------------------------------------------------------------
34 * Inquiries regarding the linux-wlan Open Source project can be
37 * AbsoluteValue Systems Inc.
39 * http://www.linux-wlan.com
41 * --------------------------------------------------------------------
43 * Portions of the development of this software were funded by
44 * Intersil Corporation as part of PRISM(R) chipset product development.
46 * --------------------------------------------------------------------
48 * This file declares the constants and types used in the interface
49 * between a wlan driver and the user mode utilities.
52 * - Constant values are always in HOST byte order. To assign
53 * values to multi-byte fields they _must_ be converted to
54 * ieee byte order. To retrieve multi-byte values from incoming
55 * frames, they must be converted to host order.
57 * - The len member of the frame structure does NOT!!! include
58 * the MAC CRC. Therefore, the len field on rx'd frames should
59 * have 4 subtracted from it.
61 * All functions declared here are implemented in p80211.c
63 * The types, macros, and functions defined here are primarily
64 * used for encoding and decoding management frames. They are
65 * designed to follow these patterns of use:
68 * 1) a frame of length len is received into buffer b
69 * 2) using the hdr structure and macros, we determine the type
70 * 3) an appropriate mgmt frame structure, mf, is allocated and zeroed
74 * 5) call mgmt_decode( mf )
75 * 6) the frame field pointers in mf are now set. Note that any
76 * multi-byte frame field values accessed using the frame field
77 * pointers are in ieee byte order and will have to be converted
81 * 1) Library client allocates buffer space for maximum length
82 * frame of the desired type
83 * 2) Library client allocates a mgmt frame structure, called mf,
85 * 3) Set the following:
86 * mf.type = <desired type>
87 * mf.buf = <allocated buffer address>
88 * 4) call mgmt_encode( mf )
89 * 5) all of the fixed field pointers and fixed length information element
90 * pointers in mf are now set to their respective locations in the
91 * allocated space (fortunately, all variable length information elements
92 * fall at the end of their respective frames).
93 * 5a) The length field is set to include the last of the fixed and fixed
94 * length fields. It may have to be updated for optional or variable
95 * length information elements.
96 * 6) Optional and variable length information elements are special cases
97 * and must be handled individually by the client code.
98 * --------------------------------------------------------------------
101 #ifndef _P80211MGMT_H
102 #define _P80211MGMT_H
105 #include "p80211hdr.h"
108 /*-- Information Element IDs --------------------*/
109 #define WLAN_EID_SSID 0
110 #define WLAN_EID_SUPP_RATES 1
111 #define WLAN_EID_FH_PARMS 2
112 #define WLAN_EID_DS_PARMS 3
113 #define WLAN_EID_CF_PARMS 4
114 #define WLAN_EID_TIM 5
115 #define WLAN_EID_IBSS_PARMS 6
116 /*-- values 7-15 reserved --*/
117 #define WLAN_EID_CHALLENGE 16
118 /*-- values 17-31 reserved for challenge text extension --*/
119 /*-- values 32-255 reserved --*/
121 /*-- Reason Codes -------------------------------*/
122 #define WLAN_MGMT_REASON_RSVD 0
123 #define WLAN_MGMT_REASON_UNSPEC 1
124 #define WLAN_MGMT_REASON_PRIOR_AUTH_INVALID 2
125 #define WLAN_MGMT_REASON_DEAUTH_LEAVING 3
126 #define WLAN_MGMT_REASON_DISASSOC_INACTIVE 4
127 #define WLAN_MGMT_REASON_DISASSOC_AP_BUSY 5
128 #define WLAN_MGMT_REASON_CLASS2_NONAUTH 6
129 #define WLAN_MGMT_REASON_CLASS3_NONASSOC 7
130 #define WLAN_MGMT_REASON_DISASSOC_STA_HASLEFT 8
131 #define WLAN_MGMT_REASON_CANT_ASSOC_NONAUTH 9
133 /*-- Status Codes -------------------------------*/
134 #define WLAN_MGMT_STATUS_SUCCESS 0
135 #define WLAN_MGMT_STATUS_UNSPEC_FAILURE 1
136 #define WLAN_MGMT_STATUS_CAPS_UNSUPPORTED 10
137 #define WLAN_MGMT_STATUS_REASSOC_NO_ASSOC 11
138 #define WLAN_MGMT_STATUS_ASSOC_DENIED_UNSPEC 12
139 #define WLAN_MGMT_STATUS_UNSUPPORTED_AUTHALG 13
140 #define WLAN_MGMT_STATUS_RX_AUTH_NOSEQ 14
141 #define WLAN_MGMT_STATUS_CHALLENGE_FAIL 15
142 #define WLAN_MGMT_STATUS_AUTH_TIMEOUT 16
143 #define WLAN_MGMT_STATUS_ASSOC_DENIED_BUSY 17
144 #define WLAN_MGMT_STATUS_ASSOC_DENIED_RATES 18
145 /* p80211b additions */
146 #define WLAN_MGMT_STATUS_ASSOC_DENIED_NOSHORT 19
147 #define WLAN_MGMT_STATUS_ASSOC_DENIED_NOPBCC 20
148 #define WLAN_MGMT_STATUS_ASSOC_DENIED_NOAGILITY 21
150 /*-- Auth Algorithm Field ---------------------------*/
151 #define WLAN_AUTH_ALG_OPENSYSTEM 0
152 #define WLAN_AUTH_ALG_SHAREDKEY 1
154 /*-- Management Frame Field Offsets -------------*/
155 /* Note: Not all fields are listed because of variable lengths, */
156 /* see the code in p80211.c to see how we search for fields */
157 /* Note: These offsets are from the start of the frame data */
159 #define WLAN_BEACON_OFF_TS 0
160 #define WLAN_BEACON_OFF_BCN_int 8
161 #define WLAN_BEACON_OFF_CAPINFO 10
162 #define WLAN_BEACON_OFF_SSID 12
164 #define WLAN_DISASSOC_OFF_REASON 0
166 #define WLAN_ASSOCREQ_OFF_CAP_INFO 0
167 #define WLAN_ASSOCREQ_OFF_LISTEN_int 2
168 #define WLAN_ASSOCREQ_OFF_SSID 4
170 #define WLAN_ASSOCRESP_OFF_CAP_INFO 0
171 #define WLAN_ASSOCRESP_OFF_STATUS 2
172 #define WLAN_ASSOCRESP_OFF_AID 4
173 #define WLAN_ASSOCRESP_OFF_SUPP_RATES 6
175 #define WLAN_REASSOCREQ_OFF_CAP_INFO 0
176 #define WLAN_REASSOCREQ_OFF_LISTEN_int 2
177 #define WLAN_REASSOCREQ_OFF_CURR_AP 4
178 #define WLAN_REASSOCREQ_OFF_SSID 10
180 #define WLAN_REASSOCRESP_OFF_CAP_INFO 0
181 #define WLAN_REASSOCRESP_OFF_STATUS 2
182 #define WLAN_REASSOCRESP_OFF_AID 4
183 #define WLAN_REASSOCRESP_OFF_SUPP_RATES 6
185 #define WLAN_PROBEREQ_OFF_SSID 0
187 #define WLAN_PROBERESP_OFF_TS 0
188 #define WLAN_PROBERESP_OFF_BCN_int 8
189 #define WLAN_PROBERESP_OFF_CAP_INFO 10
190 #define WLAN_PROBERESP_OFF_SSID 12
192 #define WLAN_AUTHEN_OFF_AUTH_ALG 0
193 #define WLAN_AUTHEN_OFF_AUTH_SEQ 2
194 #define WLAN_AUTHEN_OFF_STATUS 4
195 #define WLAN_AUTHEN_OFF_CHALLENGE 6
197 #define WLAN_DEAUTHEN_OFF_REASON 0
199 /*-- Capability Field ---------------------------*/
200 #define WLAN_GET_MGMT_CAP_INFO_ESS(n) ((n) & BIT(0))
201 #define WLAN_GET_MGMT_CAP_INFO_IBSS(n) (((n) & BIT(1)) >> 1)
202 #define WLAN_GET_MGMT_CAP_INFO_CFPOLLABLE(n) (((n) & BIT(2)) >> 2)
203 #define WLAN_GET_MGMT_CAP_INFO_CFPOLLREQ(n) (((n) & BIT(3)) >> 3)
204 #define WLAN_GET_MGMT_CAP_INFO_PRIVACY(n) (((n) & BIT(4)) >> 4)
205 /* p80211b additions */
206 #define WLAN_GET_MGMT_CAP_INFO_SHORT(n) (((n) & BIT(5)) >> 5)
207 #define WLAN_GET_MGMT_CAP_INFO_PBCC(n) (((n) & BIT(6)) >> 6)
208 #define WLAN_GET_MGMT_CAP_INFO_AGILITY(n) (((n) & BIT(7)) >> 7)
210 #define WLAN_SET_MGMT_CAP_INFO_ESS(n) (n)
211 #define WLAN_SET_MGMT_CAP_INFO_IBSS(n) ((n) << 1)
212 #define WLAN_SET_MGMT_CAP_INFO_CFPOLLABLE(n) ((n) << 2)
213 #define WLAN_SET_MGMT_CAP_INFO_CFPOLLREQ(n) ((n) << 3)
214 #define WLAN_SET_MGMT_CAP_INFO_PRIVACY(n) ((n) << 4)
215 /* p80211b additions */
216 #define WLAN_SET_MGMT_CAP_INFO_SHORT(n) ((n) << 5)
217 #define WLAN_SET_MGMT_CAP_INFO_PBCC(n) ((n) << 6)
218 #define WLAN_SET_MGMT_CAP_INFO_AGILITY(n) ((n) << 7)
220 /*-- Information Element Types --------------------*/
221 /* prototype structure, all IEs start with these members */
228 /*-- Service Set Identity (SSID) -----------------*/
229 struct wlan_ie_ssid
{
232 u8 ssid
[1]; /* may be zero, ptrs may overlap */
235 /*-- Supported Rates -----------------------------*/
236 struct wlan_ie_supp_rates
{
239 u8 rates
[1]; /* had better be at LEAST one! */
242 /*-- FH Parameter Set ----------------------------*/
243 struct wlan_ie_fh_parms
{
252 /*-- DS Parameter Set ----------------------------*/
253 struct wlan_ie_ds_parms
{
259 /*-- CF Parameter Set ----------------------------*/
261 struct wlan_ie_cf_parms
{
267 u16 cfp_durremaining
;
270 /*-- TIM ------------------------------------------*/
280 /*-- IBSS Parameter Set ---------------------------*/
281 struct wlan_ie_ibss_parms
{
287 /*-- Challenge Text ------------------------------*/
288 struct wlan_ie_challenge
{
294 /*-------------------------------------------------*/
297 /* prototype structure, all mgmt frame types will start with these members */
298 struct wlan_fr_mgmt
{
300 u16 len
; /* DOES NOT include CRC !!!! */
302 union p80211_hdr
*hdr
;
303 /* used for target specific data, skb in Linux */
305 /*-- fixed fields -----------*/
306 /*-- info elements ----------*/
309 /*-- Beacon ---------------------------------------*/
310 struct wlan_fr_beacon
{
314 union p80211_hdr
*hdr
;
315 /* used for target specific data, skb in Linux */
317 /*-- fixed fields -----------*/
321 /*-- info elements ----------*/
322 struct wlan_ie_ssid
*ssid
;
323 struct wlan_ie_supp_rates
*supp_rates
;
324 struct wlan_ie_fh_parms
*fh_parms
;
325 struct wlan_ie_ds_parms
*ds_parms
;
326 struct wlan_ie_cf_parms
*cf_parms
;
327 struct wlan_ie_ibss_parms
*ibss_parms
;
328 struct wlan_ie_tim
*tim
;
332 /*-- IBSS ATIM ------------------------------------*/
333 struct wlan_fr_ibssatim
{
337 union p80211_hdr
*hdr
;
338 /* used for target specific data, skb in Linux */
341 /*-- fixed fields -----------*/
342 /*-- info elements ----------*/
344 /* this frame type has a null body */
348 /*-- Disassociation -------------------------------*/
349 struct wlan_fr_disassoc
{
353 union p80211_hdr
*hdr
;
354 /* used for target specific data, skb in Linux */
356 /*-- fixed fields -----------*/
359 /*-- info elements ----------*/
363 /*-- Association Request --------------------------*/
364 struct wlan_fr_assocreq
{
368 union p80211_hdr
*hdr
;
369 /* used for target specific data, skb in Linux */
371 /*-- fixed fields -----------*/
374 /*-- info elements ----------*/
375 struct wlan_ie_ssid
*ssid
;
376 struct wlan_ie_supp_rates
*supp_rates
;
380 /*-- Association Response -------------------------*/
381 struct wlan_fr_assocresp
{
385 union p80211_hdr
*hdr
;
386 /* used for target specific data, skb in Linux */
388 /*-- fixed fields -----------*/
392 /*-- info elements ----------*/
393 struct wlan_ie_supp_rates
*supp_rates
;
397 /*-- Reassociation Request ------------------------*/
398 struct wlan_fr_reassocreq
{
402 union p80211_hdr
*hdr
;
403 /* used for target specific data, skb in Linux */
405 /*-- fixed fields -----------*/
409 /*-- info elements ----------*/
410 struct wlan_ie_ssid
*ssid
;
411 struct wlan_ie_supp_rates
*supp_rates
;
415 /*-- Reassociation Response -----------------------*/
416 struct wlan_fr_reassocresp
{
420 union p80211_hdr
*hdr
;
421 /* used for target specific data, skb in Linux */
423 /*-- fixed fields -----------*/
427 /*-- info elements ----------*/
428 struct wlan_ie_supp_rates
*supp_rates
;
432 /*-- Probe Request --------------------------------*/
433 struct wlan_fr_probereq
{
437 union p80211_hdr
*hdr
;
438 /* used for target specific data, skb in Linux */
440 /*-- fixed fields -----------*/
441 /*-- info elements ----------*/
442 struct wlan_ie_ssid
*ssid
;
443 struct wlan_ie_supp_rates
*supp_rates
;
447 /*-- Probe Response -------------------------------*/
448 struct wlan_fr_proberesp
{
452 union p80211_hdr
*hdr
;
453 /* used for target specific data, skb in Linux */
455 /*-- fixed fields -----------*/
459 /*-- info elements ----------*/
460 struct wlan_ie_ssid
*ssid
;
461 struct wlan_ie_supp_rates
*supp_rates
;
462 struct wlan_ie_fh_parms
*fh_parms
;
463 struct wlan_ie_ds_parms
*ds_parms
;
464 struct wlan_ie_cf_parms
*cf_parms
;
465 struct wlan_ie_ibss_parms
*ibss_parms
;
468 /*-- Authentication -------------------------------*/
469 struct wlan_fr_authen
{
473 union p80211_hdr
*hdr
;
474 /* used for target specific data, skb in Linux */
476 /*-- fixed fields -----------*/
480 /*-- info elements ----------*/
481 struct wlan_ie_challenge
*challenge
;
485 /*-- Deauthenication -----------------------------*/
486 struct wlan_fr_deauthen
{
490 union p80211_hdr
*hdr
;
491 /* used for target specific data, skb in Linux */
493 /*-- fixed fields -----------*/
496 /*-- info elements ----------*/
500 void wlan_mgmt_encode_beacon(struct wlan_fr_beacon
*f
);
501 void wlan_mgmt_decode_beacon(struct wlan_fr_beacon
*f
);
502 void wlan_mgmt_encode_disassoc(struct wlan_fr_disassoc
*f
);
503 void wlan_mgmt_decode_disassoc(struct wlan_fr_disassoc
*f
);
504 void wlan_mgmt_encode_assocreq(struct wlan_fr_assocreq
*f
);
505 void wlan_mgmt_decode_assocreq(struct wlan_fr_assocreq
*f
);
506 void wlan_mgmt_encode_assocresp(struct wlan_fr_assocresp
*f
);
507 void wlan_mgmt_decode_assocresp(struct wlan_fr_assocresp
*f
);
508 void wlan_mgmt_encode_reassocreq(struct wlan_fr_reassocreq
*f
);
509 void wlan_mgmt_decode_reassocreq(struct wlan_fr_reassocreq
*f
);
510 void wlan_mgmt_encode_reassocresp(struct wlan_fr_reassocresp
*f
);
511 void wlan_mgmt_decode_reassocresp(struct wlan_fr_reassocresp
*f
);
512 void wlan_mgmt_encode_probereq(struct wlan_fr_probereq
*f
);
513 void wlan_mgmt_decode_probereq(struct wlan_fr_probereq
*f
);
514 void wlan_mgmt_encode_proberesp(struct wlan_fr_proberesp
*f
);
515 void wlan_mgmt_decode_proberesp(struct wlan_fr_proberesp
*f
);
516 void wlan_mgmt_encode_authen(struct wlan_fr_authen
*f
);
517 void wlan_mgmt_decode_authen(struct wlan_fr_authen
*f
);
518 void wlan_mgmt_encode_deauthen(struct wlan_fr_deauthen
*f
);
519 void wlan_mgmt_decode_deauthen(struct wlan_fr_deauthen
*f
);
521 #endif /* _P80211MGMT_H */