1 | /* SPDX-License-Identifier: (GPL-2.0 OR MPL-1.1) */ |
2 | /* |
3 | * |
4 | * Macros, types, and functions to handle 802.11 mgmt frames |
5 | * |
6 | * Copyright (C) 1999 AbsoluteValue Systems, Inc. All Rights Reserved. |
7 | * -------------------------------------------------------------------- |
8 | * |
9 | * linux-wlan |
10 | * |
11 | * -------------------------------------------------------------------- |
12 | * |
13 | * Inquiries regarding the linux-wlan Open Source project can be |
14 | * made directly to: |
15 | * |
16 | * AbsoluteValue Systems Inc. |
17 | * info@linux-wlan.com |
18 | * http://www.linux-wlan.com |
19 | * |
20 | * -------------------------------------------------------------------- |
21 | * |
22 | * Portions of the development of this software were funded by |
23 | * Intersil Corporation as part of PRISM(R) chipset product development. |
24 | * |
25 | * -------------------------------------------------------------------- |
26 | * |
27 | * This file declares the constants and types used in the interface |
28 | * between a wlan driver and the user mode utilities. |
29 | * |
30 | * Notes: |
31 | * - Constant values are always in HOST byte order. To assign |
32 | * values to multi-byte fields they _must_ be converted to |
33 | * ieee byte order. To retrieve multi-byte values from incoming |
34 | * frames, they must be converted to host order. |
35 | * |
36 | * - The len member of the frame structure does NOT!!! include |
37 | * the MAC CRC. Therefore, the len field on rx'd frames should |
38 | * have 4 subtracted from it. |
39 | * |
40 | * All functions declared here are implemented in p80211.c |
41 | * |
42 | * The types, macros, and functions defined here are primarily |
43 | * used for encoding and decoding management frames. They are |
44 | * designed to follow these patterns of use: |
45 | * |
46 | * DECODE: |
47 | * 1) a frame of length len is received into buffer b |
48 | * 2) using the hdr structure and macros, we determine the type |
49 | * 3) an appropriate mgmt frame structure, mf, is allocated and zeroed |
50 | * 4) mf.hdr = b |
51 | * mf.buf = b |
52 | * mf.len = len |
53 | * 5) call mgmt_decode( mf ) |
54 | * 6) the frame field pointers in mf are now set. Note that any |
55 | * multi-byte frame field values accessed using the frame field |
56 | * pointers are in ieee byte order and will have to be converted |
57 | * to host order. |
58 | * |
59 | * ENCODE: |
60 | * 1) Library client allocates buffer space for maximum length |
61 | * frame of the desired type |
62 | * 2) Library client allocates a mgmt frame structure, called mf, |
63 | * of the desired type |
64 | * 3) Set the following: |
65 | * mf.type = <desired type> |
66 | * mf.buf = <allocated buffer address> |
67 | * 4) call mgmt_encode( mf ) |
68 | * 5) all of the fixed field pointers and fixed length information element |
69 | * pointers in mf are now set to their respective locations in the |
70 | * allocated space (fortunately, all variable length information elements |
71 | * fall at the end of their respective frames). |
72 | * 5a) The length field is set to include the last of the fixed and fixed |
73 | * length fields. It may have to be updated for optional or variable |
74 | * length information elements. |
75 | * 6) Optional and variable length information elements are special cases |
76 | * and must be handled individually by the client code. |
77 | * -------------------------------------------------------------------- |
78 | */ |
79 | |
80 | #ifndef _P80211MGMT_H |
81 | #define _P80211MGMT_H |
82 | |
83 | #ifndef _P80211HDR_H |
84 | #include "p80211hdr.h" |
85 | #endif |
86 | |
87 | /*-- Information Element IDs --------------------*/ |
88 | #define WLAN_EID_SSID 0 |
89 | #define WLAN_EID_SUPP_RATES 1 |
90 | #define WLAN_EID_FH_PARMS 2 |
91 | #define WLAN_EID_DS_PARMS 3 |
92 | #define WLAN_EID_CF_PARMS 4 |
93 | #define WLAN_EID_TIM 5 |
94 | #define WLAN_EID_IBSS_PARMS 6 |
95 | /*-- values 7-15 reserved --*/ |
96 | #define WLAN_EID_CHALLENGE 16 |
97 | /*-- values 17-31 reserved for challenge text extension --*/ |
98 | /*-- values 32-255 reserved --*/ |
99 | |
100 | /*-- Reason Codes -------------------------------*/ |
101 | #define WLAN_MGMT_REASON_RSVD 0 |
102 | #define WLAN_MGMT_REASON_UNSPEC 1 |
103 | #define WLAN_MGMT_REASON_PRIOR_AUTH_INVALID 2 |
104 | #define WLAN_MGMT_REASON_DEAUTH_LEAVING 3 |
105 | #define WLAN_MGMT_REASON_DISASSOC_INACTIVE 4 |
106 | #define WLAN_MGMT_REASON_DISASSOC_AP_BUSY 5 |
107 | #define WLAN_MGMT_REASON_CLASS2_NONAUTH 6 |
108 | #define WLAN_MGMT_REASON_CLASS3_NONASSOC 7 |
109 | #define WLAN_MGMT_REASON_DISASSOC_STA_HASLEFT 8 |
110 | #define WLAN_MGMT_REASON_CANT_ASSOC_NONAUTH 9 |
111 | |
112 | /*-- Status Codes -------------------------------*/ |
113 | #define WLAN_MGMT_STATUS_SUCCESS 0 |
114 | #define WLAN_MGMT_STATUS_UNSPEC_FAILURE 1 |
115 | #define WLAN_MGMT_STATUS_CAPS_UNSUPPORTED 10 |
116 | #define WLAN_MGMT_STATUS_REASSOC_NO_ASSOC 11 |
117 | #define WLAN_MGMT_STATUS_ASSOC_DENIED_UNSPEC 12 |
118 | #define WLAN_MGMT_STATUS_UNSUPPORTED_AUTHALG 13 |
119 | #define WLAN_MGMT_STATUS_RX_AUTH_NOSEQ 14 |
120 | #define WLAN_MGMT_STATUS_CHALLENGE_FAIL 15 |
121 | #define WLAN_MGMT_STATUS_AUTH_TIMEOUT 16 |
122 | #define WLAN_MGMT_STATUS_ASSOC_DENIED_BUSY 17 |
123 | #define WLAN_MGMT_STATUS_ASSOC_DENIED_RATES 18 |
124 | /* p80211b additions */ |
125 | #define WLAN_MGMT_STATUS_ASSOC_DENIED_NOSHORT 19 |
126 | #define WLAN_MGMT_STATUS_ASSOC_DENIED_NOPBCC 20 |
127 | #define WLAN_MGMT_STATUS_ASSOC_DENIED_NOAGILITY 21 |
128 | |
129 | /*-- Auth Algorithm Field ---------------------------*/ |
130 | #define WLAN_AUTH_ALG_OPENSYSTEM 0 |
131 | #define WLAN_AUTH_ALG_SHAREDKEY 1 |
132 | |
133 | /*-- Management Frame Field Offsets -------------*/ |
134 | /* Note: Not all fields are listed because of variable lengths, */ |
135 | /* see the code in p80211.c to see how we search for fields */ |
136 | /* Note: These offsets are from the start of the frame data */ |
137 | |
138 | #define WLAN_BEACON_OFF_TS 0 |
139 | #define WLAN_BEACON_OFF_BCN_int 8 |
140 | #define WLAN_BEACON_OFF_CAPINFO 10 |
141 | #define WLAN_BEACON_OFF_SSID 12 |
142 | |
143 | #define WLAN_DISASSOC_OFF_REASON 0 |
144 | |
145 | #define WLAN_ASSOCREQ_OFF_CAP_INFO 0 |
146 | #define WLAN_ASSOCREQ_OFF_LISTEN_int 2 |
147 | #define WLAN_ASSOCREQ_OFF_SSID 4 |
148 | |
149 | #define WLAN_ASSOCRESP_OFF_CAP_INFO 0 |
150 | #define WLAN_ASSOCRESP_OFF_STATUS 2 |
151 | #define WLAN_ASSOCRESP_OFF_AID 4 |
152 | #define WLAN_ASSOCRESP_OFF_SUPP_RATES 6 |
153 | |
154 | #define WLAN_REASSOCREQ_OFF_CAP_INFO 0 |
155 | #define WLAN_REASSOCREQ_OFF_LISTEN_int 2 |
156 | #define WLAN_REASSOCREQ_OFF_CURR_AP 4 |
157 | #define WLAN_REASSOCREQ_OFF_SSID 10 |
158 | |
159 | #define WLAN_REASSOCRESP_OFF_CAP_INFO 0 |
160 | #define WLAN_REASSOCRESP_OFF_STATUS 2 |
161 | #define WLAN_REASSOCRESP_OFF_AID 4 |
162 | #define WLAN_REASSOCRESP_OFF_SUPP_RATES 6 |
163 | |
164 | #define WLAN_PROBEREQ_OFF_SSID 0 |
165 | |
166 | #define WLAN_PROBERESP_OFF_TS 0 |
167 | #define WLAN_PROBERESP_OFF_BCN_int 8 |
168 | #define WLAN_PROBERESP_OFF_CAP_INFO 10 |
169 | #define WLAN_PROBERESP_OFF_SSID 12 |
170 | |
171 | #define WLAN_AUTHEN_OFF_AUTH_ALG 0 |
172 | #define WLAN_AUTHEN_OFF_AUTH_SEQ 2 |
173 | #define WLAN_AUTHEN_OFF_STATUS 4 |
174 | #define WLAN_AUTHEN_OFF_CHALLENGE 6 |
175 | |
176 | #define WLAN_DEAUTHEN_OFF_REASON 0 |
177 | |
178 | /*-- Capability Field ---------------------------*/ |
179 | #define WLAN_GET_MGMT_CAP_INFO_ESS(n) ((n) & BIT(0)) |
180 | #define WLAN_GET_MGMT_CAP_INFO_IBSS(n) (((n) & BIT(1)) >> 1) |
181 | #define WLAN_GET_MGMT_CAP_INFO_CFPOLLABLE(n) (((n) & BIT(2)) >> 2) |
182 | #define WLAN_GET_MGMT_CAP_INFO_CFPOLLREQ(n) (((n) & BIT(3)) >> 3) |
183 | #define WLAN_GET_MGMT_CAP_INFO_PRIVACY(n) (((n) & BIT(4)) >> 4) |
184 | /* p80211b additions */ |
185 | #define WLAN_GET_MGMT_CAP_INFO_SHORT(n) (((n) & BIT(5)) >> 5) |
186 | #define WLAN_GET_MGMT_CAP_INFO_PBCC(n) (((n) & BIT(6)) >> 6) |
187 | #define WLAN_GET_MGMT_CAP_INFO_AGILITY(n) (((n) & BIT(7)) >> 7) |
188 | |
189 | #define WLAN_SET_MGMT_CAP_INFO_ESS(n) (n) |
190 | #define WLAN_SET_MGMT_CAP_INFO_IBSS(n) ((n) << 1) |
191 | #define WLAN_SET_MGMT_CAP_INFO_CFPOLLABLE(n) ((n) << 2) |
192 | #define WLAN_SET_MGMT_CAP_INFO_CFPOLLREQ(n) ((n) << 3) |
193 | #define WLAN_SET_MGMT_CAP_INFO_PRIVACY(n) ((n) << 4) |
194 | /* p80211b additions */ |
195 | #define WLAN_SET_MGMT_CAP_INFO_SHORT(n) ((n) << 5) |
196 | #define WLAN_SET_MGMT_CAP_INFO_PBCC(n) ((n) << 6) |
197 | #define WLAN_SET_MGMT_CAP_INFO_AGILITY(n) ((n) << 7) |
198 | |
199 | #endif /* _P80211MGMT_H */ |
200 | |