Commit 0a35d36d6f019bde6c98812456798275b02e5aee

Authored by Javier Cardona
Committed by John W. Linville
1 parent 915b5c50f8

cfg80211: Use capability info to detect mesh beacons.

Mesh beacons no longer use all-zeroes BSSID.  Beacon frames for MBSS,
infrastructure BSS, or IBSS are differentiated by the Capability
Information field in the Beacon frame.  A mesh STA sets the ESS and IBSS
subfields to 0 in transmitted Beacon or Probe Response management
frames.

Signed-off-by: Javier Cardona <javier@cozybit.com>
Signed-off-by: John W. Linville <linville@tuxdriver.com>

Showing 2 changed files with 12 additions and 7 deletions Inline Diff

include/linux/ieee80211.h
1 /* 1 /*
2 * IEEE 802.11 defines 2 * IEEE 802.11 defines
3 * 3 *
4 * Copyright (c) 2001-2002, SSH Communications Security Corp and Jouni Malinen 4 * Copyright (c) 2001-2002, SSH Communications Security Corp and Jouni Malinen
5 * <jkmaline@cc.hut.fi> 5 * <jkmaline@cc.hut.fi>
6 * Copyright (c) 2002-2003, Jouni Malinen <jkmaline@cc.hut.fi> 6 * Copyright (c) 2002-2003, Jouni Malinen <jkmaline@cc.hut.fi>
7 * Copyright (c) 2005, Devicescape Software, Inc. 7 * Copyright (c) 2005, Devicescape Software, Inc.
8 * Copyright (c) 2006, Michael Wu <flamingice@sourmilk.net> 8 * Copyright (c) 2006, Michael Wu <flamingice@sourmilk.net>
9 * 9 *
10 * This program is free software; you can redistribute it and/or modify 10 * This program is free software; you can redistribute it and/or modify
11 * it under the terms of the GNU General Public License version 2 as 11 * it under the terms of the GNU General Public License version 2 as
12 * published by the Free Software Foundation. 12 * published by the Free Software Foundation.
13 */ 13 */
14 14
15 #ifndef LINUX_IEEE80211_H 15 #ifndef LINUX_IEEE80211_H
16 #define LINUX_IEEE80211_H 16 #define LINUX_IEEE80211_H
17 17
18 #include <linux/types.h> 18 #include <linux/types.h>
19 #include <asm/byteorder.h> 19 #include <asm/byteorder.h>
20 20
21 /* 21 /*
22 * DS bit usage 22 * DS bit usage
23 * 23 *
24 * TA = transmitter address 24 * TA = transmitter address
25 * RA = receiver address 25 * RA = receiver address
26 * DA = destination address 26 * DA = destination address
27 * SA = source address 27 * SA = source address
28 * 28 *
29 * ToDS FromDS A1(RA) A2(TA) A3 A4 Use 29 * ToDS FromDS A1(RA) A2(TA) A3 A4 Use
30 * ----------------------------------------------------------------- 30 * -----------------------------------------------------------------
31 * 0 0 DA SA BSSID - IBSS/DLS 31 * 0 0 DA SA BSSID - IBSS/DLS
32 * 0 1 DA BSSID SA - AP -> STA 32 * 0 1 DA BSSID SA - AP -> STA
33 * 1 0 BSSID SA DA - AP <- STA 33 * 1 0 BSSID SA DA - AP <- STA
34 * 1 1 RA TA DA SA unspecified (WDS) 34 * 1 1 RA TA DA SA unspecified (WDS)
35 */ 35 */
36 36
37 #define FCS_LEN 4 37 #define FCS_LEN 4
38 38
39 #define IEEE80211_FCTL_VERS 0x0003 39 #define IEEE80211_FCTL_VERS 0x0003
40 #define IEEE80211_FCTL_FTYPE 0x000c 40 #define IEEE80211_FCTL_FTYPE 0x000c
41 #define IEEE80211_FCTL_STYPE 0x00f0 41 #define IEEE80211_FCTL_STYPE 0x00f0
42 #define IEEE80211_FCTL_TODS 0x0100 42 #define IEEE80211_FCTL_TODS 0x0100
43 #define IEEE80211_FCTL_FROMDS 0x0200 43 #define IEEE80211_FCTL_FROMDS 0x0200
44 #define IEEE80211_FCTL_MOREFRAGS 0x0400 44 #define IEEE80211_FCTL_MOREFRAGS 0x0400
45 #define IEEE80211_FCTL_RETRY 0x0800 45 #define IEEE80211_FCTL_RETRY 0x0800
46 #define IEEE80211_FCTL_PM 0x1000 46 #define IEEE80211_FCTL_PM 0x1000
47 #define IEEE80211_FCTL_MOREDATA 0x2000 47 #define IEEE80211_FCTL_MOREDATA 0x2000
48 #define IEEE80211_FCTL_PROTECTED 0x4000 48 #define IEEE80211_FCTL_PROTECTED 0x4000
49 #define IEEE80211_FCTL_ORDER 0x8000 49 #define IEEE80211_FCTL_ORDER 0x8000
50 50
51 #define IEEE80211_SCTL_FRAG 0x000F 51 #define IEEE80211_SCTL_FRAG 0x000F
52 #define IEEE80211_SCTL_SEQ 0xFFF0 52 #define IEEE80211_SCTL_SEQ 0xFFF0
53 53
54 #define IEEE80211_FTYPE_MGMT 0x0000 54 #define IEEE80211_FTYPE_MGMT 0x0000
55 #define IEEE80211_FTYPE_CTL 0x0004 55 #define IEEE80211_FTYPE_CTL 0x0004
56 #define IEEE80211_FTYPE_DATA 0x0008 56 #define IEEE80211_FTYPE_DATA 0x0008
57 57
58 /* management */ 58 /* management */
59 #define IEEE80211_STYPE_ASSOC_REQ 0x0000 59 #define IEEE80211_STYPE_ASSOC_REQ 0x0000
60 #define IEEE80211_STYPE_ASSOC_RESP 0x0010 60 #define IEEE80211_STYPE_ASSOC_RESP 0x0010
61 #define IEEE80211_STYPE_REASSOC_REQ 0x0020 61 #define IEEE80211_STYPE_REASSOC_REQ 0x0020
62 #define IEEE80211_STYPE_REASSOC_RESP 0x0030 62 #define IEEE80211_STYPE_REASSOC_RESP 0x0030
63 #define IEEE80211_STYPE_PROBE_REQ 0x0040 63 #define IEEE80211_STYPE_PROBE_REQ 0x0040
64 #define IEEE80211_STYPE_PROBE_RESP 0x0050 64 #define IEEE80211_STYPE_PROBE_RESP 0x0050
65 #define IEEE80211_STYPE_BEACON 0x0080 65 #define IEEE80211_STYPE_BEACON 0x0080
66 #define IEEE80211_STYPE_ATIM 0x0090 66 #define IEEE80211_STYPE_ATIM 0x0090
67 #define IEEE80211_STYPE_DISASSOC 0x00A0 67 #define IEEE80211_STYPE_DISASSOC 0x00A0
68 #define IEEE80211_STYPE_AUTH 0x00B0 68 #define IEEE80211_STYPE_AUTH 0x00B0
69 #define IEEE80211_STYPE_DEAUTH 0x00C0 69 #define IEEE80211_STYPE_DEAUTH 0x00C0
70 #define IEEE80211_STYPE_ACTION 0x00D0 70 #define IEEE80211_STYPE_ACTION 0x00D0
71 71
72 /* control */ 72 /* control */
73 #define IEEE80211_STYPE_BACK_REQ 0x0080 73 #define IEEE80211_STYPE_BACK_REQ 0x0080
74 #define IEEE80211_STYPE_BACK 0x0090 74 #define IEEE80211_STYPE_BACK 0x0090
75 #define IEEE80211_STYPE_PSPOLL 0x00A0 75 #define IEEE80211_STYPE_PSPOLL 0x00A0
76 #define IEEE80211_STYPE_RTS 0x00B0 76 #define IEEE80211_STYPE_RTS 0x00B0
77 #define IEEE80211_STYPE_CTS 0x00C0 77 #define IEEE80211_STYPE_CTS 0x00C0
78 #define IEEE80211_STYPE_ACK 0x00D0 78 #define IEEE80211_STYPE_ACK 0x00D0
79 #define IEEE80211_STYPE_CFEND 0x00E0 79 #define IEEE80211_STYPE_CFEND 0x00E0
80 #define IEEE80211_STYPE_CFENDACK 0x00F0 80 #define IEEE80211_STYPE_CFENDACK 0x00F0
81 81
82 /* data */ 82 /* data */
83 #define IEEE80211_STYPE_DATA 0x0000 83 #define IEEE80211_STYPE_DATA 0x0000
84 #define IEEE80211_STYPE_DATA_CFACK 0x0010 84 #define IEEE80211_STYPE_DATA_CFACK 0x0010
85 #define IEEE80211_STYPE_DATA_CFPOLL 0x0020 85 #define IEEE80211_STYPE_DATA_CFPOLL 0x0020
86 #define IEEE80211_STYPE_DATA_CFACKPOLL 0x0030 86 #define IEEE80211_STYPE_DATA_CFACKPOLL 0x0030
87 #define IEEE80211_STYPE_NULLFUNC 0x0040 87 #define IEEE80211_STYPE_NULLFUNC 0x0040
88 #define IEEE80211_STYPE_CFACK 0x0050 88 #define IEEE80211_STYPE_CFACK 0x0050
89 #define IEEE80211_STYPE_CFPOLL 0x0060 89 #define IEEE80211_STYPE_CFPOLL 0x0060
90 #define IEEE80211_STYPE_CFACKPOLL 0x0070 90 #define IEEE80211_STYPE_CFACKPOLL 0x0070
91 #define IEEE80211_STYPE_QOS_DATA 0x0080 91 #define IEEE80211_STYPE_QOS_DATA 0x0080
92 #define IEEE80211_STYPE_QOS_DATA_CFACK 0x0090 92 #define IEEE80211_STYPE_QOS_DATA_CFACK 0x0090
93 #define IEEE80211_STYPE_QOS_DATA_CFPOLL 0x00A0 93 #define IEEE80211_STYPE_QOS_DATA_CFPOLL 0x00A0
94 #define IEEE80211_STYPE_QOS_DATA_CFACKPOLL 0x00B0 94 #define IEEE80211_STYPE_QOS_DATA_CFACKPOLL 0x00B0
95 #define IEEE80211_STYPE_QOS_NULLFUNC 0x00C0 95 #define IEEE80211_STYPE_QOS_NULLFUNC 0x00C0
96 #define IEEE80211_STYPE_QOS_CFACK 0x00D0 96 #define IEEE80211_STYPE_QOS_CFACK 0x00D0
97 #define IEEE80211_STYPE_QOS_CFPOLL 0x00E0 97 #define IEEE80211_STYPE_QOS_CFPOLL 0x00E0
98 #define IEEE80211_STYPE_QOS_CFACKPOLL 0x00F0 98 #define IEEE80211_STYPE_QOS_CFACKPOLL 0x00F0
99 99
100 100
101 /* miscellaneous IEEE 802.11 constants */ 101 /* miscellaneous IEEE 802.11 constants */
102 #define IEEE80211_MAX_FRAG_THRESHOLD 2352 102 #define IEEE80211_MAX_FRAG_THRESHOLD 2352
103 #define IEEE80211_MAX_RTS_THRESHOLD 2353 103 #define IEEE80211_MAX_RTS_THRESHOLD 2353
104 #define IEEE80211_MAX_AID 2007 104 #define IEEE80211_MAX_AID 2007
105 #define IEEE80211_MAX_TIM_LEN 251 105 #define IEEE80211_MAX_TIM_LEN 251
106 /* Maximum size for the MA-UNITDATA primitive, 802.11 standard section 106 /* Maximum size for the MA-UNITDATA primitive, 802.11 standard section
107 6.2.1.1.2. 107 6.2.1.1.2.
108 108
109 802.11e clarifies the figure in section 7.1.2. The frame body is 109 802.11e clarifies the figure in section 7.1.2. The frame body is
110 up to 2304 octets long (maximum MSDU size) plus any crypt overhead. */ 110 up to 2304 octets long (maximum MSDU size) plus any crypt overhead. */
111 #define IEEE80211_MAX_DATA_LEN 2304 111 #define IEEE80211_MAX_DATA_LEN 2304
112 /* 30 byte 4 addr hdr, 2 byte QoS, 2304 byte MSDU, 12 byte crypt, 4 byte FCS */ 112 /* 30 byte 4 addr hdr, 2 byte QoS, 2304 byte MSDU, 12 byte crypt, 4 byte FCS */
113 #define IEEE80211_MAX_FRAME_LEN 2352 113 #define IEEE80211_MAX_FRAME_LEN 2352
114 114
115 #define IEEE80211_MAX_SSID_LEN 32 115 #define IEEE80211_MAX_SSID_LEN 32
116 116
117 #define IEEE80211_MAX_MESH_ID_LEN 32 117 #define IEEE80211_MAX_MESH_ID_LEN 32
118 118
119 #define IEEE80211_QOS_CTL_LEN 2 119 #define IEEE80211_QOS_CTL_LEN 2
120 #define IEEE80211_QOS_CTL_TID_MASK 0x000F 120 #define IEEE80211_QOS_CTL_TID_MASK 0x000F
121 #define IEEE80211_QOS_CTL_TAG1D_MASK 0x0007 121 #define IEEE80211_QOS_CTL_TAG1D_MASK 0x0007
122 122
123 /* U-APSD queue for WMM IEs sent by AP */ 123 /* U-APSD queue for WMM IEs sent by AP */
124 #define IEEE80211_WMM_IE_AP_QOSINFO_UAPSD (1<<7) 124 #define IEEE80211_WMM_IE_AP_QOSINFO_UAPSD (1<<7)
125 #define IEEE80211_WMM_IE_AP_QOSINFO_PARAM_SET_CNT_MASK 0x0f 125 #define IEEE80211_WMM_IE_AP_QOSINFO_PARAM_SET_CNT_MASK 0x0f
126 126
127 /* U-APSD queues for WMM IEs sent by STA */ 127 /* U-APSD queues for WMM IEs sent by STA */
128 #define IEEE80211_WMM_IE_STA_QOSINFO_AC_VO (1<<0) 128 #define IEEE80211_WMM_IE_STA_QOSINFO_AC_VO (1<<0)
129 #define IEEE80211_WMM_IE_STA_QOSINFO_AC_VI (1<<1) 129 #define IEEE80211_WMM_IE_STA_QOSINFO_AC_VI (1<<1)
130 #define IEEE80211_WMM_IE_STA_QOSINFO_AC_BK (1<<2) 130 #define IEEE80211_WMM_IE_STA_QOSINFO_AC_BK (1<<2)
131 #define IEEE80211_WMM_IE_STA_QOSINFO_AC_BE (1<<3) 131 #define IEEE80211_WMM_IE_STA_QOSINFO_AC_BE (1<<3)
132 #define IEEE80211_WMM_IE_STA_QOSINFO_AC_MASK 0x0f 132 #define IEEE80211_WMM_IE_STA_QOSINFO_AC_MASK 0x0f
133 133
134 /* U-APSD max SP length for WMM IEs sent by STA */ 134 /* U-APSD max SP length for WMM IEs sent by STA */
135 #define IEEE80211_WMM_IE_STA_QOSINFO_SP_ALL 0x00 135 #define IEEE80211_WMM_IE_STA_QOSINFO_SP_ALL 0x00
136 #define IEEE80211_WMM_IE_STA_QOSINFO_SP_2 0x01 136 #define IEEE80211_WMM_IE_STA_QOSINFO_SP_2 0x01
137 #define IEEE80211_WMM_IE_STA_QOSINFO_SP_4 0x02 137 #define IEEE80211_WMM_IE_STA_QOSINFO_SP_4 0x02
138 #define IEEE80211_WMM_IE_STA_QOSINFO_SP_6 0x03 138 #define IEEE80211_WMM_IE_STA_QOSINFO_SP_6 0x03
139 #define IEEE80211_WMM_IE_STA_QOSINFO_SP_MASK 0x03 139 #define IEEE80211_WMM_IE_STA_QOSINFO_SP_MASK 0x03
140 #define IEEE80211_WMM_IE_STA_QOSINFO_SP_SHIFT 5 140 #define IEEE80211_WMM_IE_STA_QOSINFO_SP_SHIFT 5
141 141
142 #define IEEE80211_HT_CTL_LEN 4 142 #define IEEE80211_HT_CTL_LEN 4
143 143
144 struct ieee80211_hdr { 144 struct ieee80211_hdr {
145 __le16 frame_control; 145 __le16 frame_control;
146 __le16 duration_id; 146 __le16 duration_id;
147 u8 addr1[6]; 147 u8 addr1[6];
148 u8 addr2[6]; 148 u8 addr2[6];
149 u8 addr3[6]; 149 u8 addr3[6];
150 __le16 seq_ctrl; 150 __le16 seq_ctrl;
151 u8 addr4[6]; 151 u8 addr4[6];
152 } __attribute__ ((packed)); 152 } __attribute__ ((packed));
153 153
154 struct ieee80211_hdr_3addr { 154 struct ieee80211_hdr_3addr {
155 __le16 frame_control; 155 __le16 frame_control;
156 __le16 duration_id; 156 __le16 duration_id;
157 u8 addr1[6]; 157 u8 addr1[6];
158 u8 addr2[6]; 158 u8 addr2[6];
159 u8 addr3[6]; 159 u8 addr3[6];
160 __le16 seq_ctrl; 160 __le16 seq_ctrl;
161 } __attribute__ ((packed)); 161 } __attribute__ ((packed));
162 162
163 struct ieee80211_qos_hdr { 163 struct ieee80211_qos_hdr {
164 __le16 frame_control; 164 __le16 frame_control;
165 __le16 duration_id; 165 __le16 duration_id;
166 u8 addr1[6]; 166 u8 addr1[6];
167 u8 addr2[6]; 167 u8 addr2[6];
168 u8 addr3[6]; 168 u8 addr3[6];
169 __le16 seq_ctrl; 169 __le16 seq_ctrl;
170 __le16 qos_ctrl; 170 __le16 qos_ctrl;
171 } __attribute__ ((packed)); 171 } __attribute__ ((packed));
172 172
173 /** 173 /**
174 * ieee80211_has_tods - check if IEEE80211_FCTL_TODS is set 174 * ieee80211_has_tods - check if IEEE80211_FCTL_TODS is set
175 * @fc: frame control bytes in little-endian byteorder 175 * @fc: frame control bytes in little-endian byteorder
176 */ 176 */
177 static inline int ieee80211_has_tods(__le16 fc) 177 static inline int ieee80211_has_tods(__le16 fc)
178 { 178 {
179 return (fc & cpu_to_le16(IEEE80211_FCTL_TODS)) != 0; 179 return (fc & cpu_to_le16(IEEE80211_FCTL_TODS)) != 0;
180 } 180 }
181 181
182 /** 182 /**
183 * ieee80211_has_fromds - check if IEEE80211_FCTL_FROMDS is set 183 * ieee80211_has_fromds - check if IEEE80211_FCTL_FROMDS is set
184 * @fc: frame control bytes in little-endian byteorder 184 * @fc: frame control bytes in little-endian byteorder
185 */ 185 */
186 static inline int ieee80211_has_fromds(__le16 fc) 186 static inline int ieee80211_has_fromds(__le16 fc)
187 { 187 {
188 return (fc & cpu_to_le16(IEEE80211_FCTL_FROMDS)) != 0; 188 return (fc & cpu_to_le16(IEEE80211_FCTL_FROMDS)) != 0;
189 } 189 }
190 190
191 /** 191 /**
192 * ieee80211_has_a4 - check if IEEE80211_FCTL_TODS and IEEE80211_FCTL_FROMDS are set 192 * ieee80211_has_a4 - check if IEEE80211_FCTL_TODS and IEEE80211_FCTL_FROMDS are set
193 * @fc: frame control bytes in little-endian byteorder 193 * @fc: frame control bytes in little-endian byteorder
194 */ 194 */
195 static inline int ieee80211_has_a4(__le16 fc) 195 static inline int ieee80211_has_a4(__le16 fc)
196 { 196 {
197 __le16 tmp = cpu_to_le16(IEEE80211_FCTL_TODS | IEEE80211_FCTL_FROMDS); 197 __le16 tmp = cpu_to_le16(IEEE80211_FCTL_TODS | IEEE80211_FCTL_FROMDS);
198 return (fc & tmp) == tmp; 198 return (fc & tmp) == tmp;
199 } 199 }
200 200
201 /** 201 /**
202 * ieee80211_has_morefrags - check if IEEE80211_FCTL_MOREFRAGS is set 202 * ieee80211_has_morefrags - check if IEEE80211_FCTL_MOREFRAGS is set
203 * @fc: frame control bytes in little-endian byteorder 203 * @fc: frame control bytes in little-endian byteorder
204 */ 204 */
205 static inline int ieee80211_has_morefrags(__le16 fc) 205 static inline int ieee80211_has_morefrags(__le16 fc)
206 { 206 {
207 return (fc & cpu_to_le16(IEEE80211_FCTL_MOREFRAGS)) != 0; 207 return (fc & cpu_to_le16(IEEE80211_FCTL_MOREFRAGS)) != 0;
208 } 208 }
209 209
210 /** 210 /**
211 * ieee80211_has_retry - check if IEEE80211_FCTL_RETRY is set 211 * ieee80211_has_retry - check if IEEE80211_FCTL_RETRY is set
212 * @fc: frame control bytes in little-endian byteorder 212 * @fc: frame control bytes in little-endian byteorder
213 */ 213 */
214 static inline int ieee80211_has_retry(__le16 fc) 214 static inline int ieee80211_has_retry(__le16 fc)
215 { 215 {
216 return (fc & cpu_to_le16(IEEE80211_FCTL_RETRY)) != 0; 216 return (fc & cpu_to_le16(IEEE80211_FCTL_RETRY)) != 0;
217 } 217 }
218 218
219 /** 219 /**
220 * ieee80211_has_pm - check if IEEE80211_FCTL_PM is set 220 * ieee80211_has_pm - check if IEEE80211_FCTL_PM is set
221 * @fc: frame control bytes in little-endian byteorder 221 * @fc: frame control bytes in little-endian byteorder
222 */ 222 */
223 static inline int ieee80211_has_pm(__le16 fc) 223 static inline int ieee80211_has_pm(__le16 fc)
224 { 224 {
225 return (fc & cpu_to_le16(IEEE80211_FCTL_PM)) != 0; 225 return (fc & cpu_to_le16(IEEE80211_FCTL_PM)) != 0;
226 } 226 }
227 227
228 /** 228 /**
229 * ieee80211_has_moredata - check if IEEE80211_FCTL_MOREDATA is set 229 * ieee80211_has_moredata - check if IEEE80211_FCTL_MOREDATA is set
230 * @fc: frame control bytes in little-endian byteorder 230 * @fc: frame control bytes in little-endian byteorder
231 */ 231 */
232 static inline int ieee80211_has_moredata(__le16 fc) 232 static inline int ieee80211_has_moredata(__le16 fc)
233 { 233 {
234 return (fc & cpu_to_le16(IEEE80211_FCTL_MOREDATA)) != 0; 234 return (fc & cpu_to_le16(IEEE80211_FCTL_MOREDATA)) != 0;
235 } 235 }
236 236
237 /** 237 /**
238 * ieee80211_has_protected - check if IEEE80211_FCTL_PROTECTED is set 238 * ieee80211_has_protected - check if IEEE80211_FCTL_PROTECTED is set
239 * @fc: frame control bytes in little-endian byteorder 239 * @fc: frame control bytes in little-endian byteorder
240 */ 240 */
241 static inline int ieee80211_has_protected(__le16 fc) 241 static inline int ieee80211_has_protected(__le16 fc)
242 { 242 {
243 return (fc & cpu_to_le16(IEEE80211_FCTL_PROTECTED)) != 0; 243 return (fc & cpu_to_le16(IEEE80211_FCTL_PROTECTED)) != 0;
244 } 244 }
245 245
246 /** 246 /**
247 * ieee80211_has_order - check if IEEE80211_FCTL_ORDER is set 247 * ieee80211_has_order - check if IEEE80211_FCTL_ORDER is set
248 * @fc: frame control bytes in little-endian byteorder 248 * @fc: frame control bytes in little-endian byteorder
249 */ 249 */
250 static inline int ieee80211_has_order(__le16 fc) 250 static inline int ieee80211_has_order(__le16 fc)
251 { 251 {
252 return (fc & cpu_to_le16(IEEE80211_FCTL_ORDER)) != 0; 252 return (fc & cpu_to_le16(IEEE80211_FCTL_ORDER)) != 0;
253 } 253 }
254 254
255 /** 255 /**
256 * ieee80211_is_mgmt - check if type is IEEE80211_FTYPE_MGMT 256 * ieee80211_is_mgmt - check if type is IEEE80211_FTYPE_MGMT
257 * @fc: frame control bytes in little-endian byteorder 257 * @fc: frame control bytes in little-endian byteorder
258 */ 258 */
259 static inline int ieee80211_is_mgmt(__le16 fc) 259 static inline int ieee80211_is_mgmt(__le16 fc)
260 { 260 {
261 return (fc & cpu_to_le16(IEEE80211_FCTL_FTYPE)) == 261 return (fc & cpu_to_le16(IEEE80211_FCTL_FTYPE)) ==
262 cpu_to_le16(IEEE80211_FTYPE_MGMT); 262 cpu_to_le16(IEEE80211_FTYPE_MGMT);
263 } 263 }
264 264
265 /** 265 /**
266 * ieee80211_is_ctl - check if type is IEEE80211_FTYPE_CTL 266 * ieee80211_is_ctl - check if type is IEEE80211_FTYPE_CTL
267 * @fc: frame control bytes in little-endian byteorder 267 * @fc: frame control bytes in little-endian byteorder
268 */ 268 */
269 static inline int ieee80211_is_ctl(__le16 fc) 269 static inline int ieee80211_is_ctl(__le16 fc)
270 { 270 {
271 return (fc & cpu_to_le16(IEEE80211_FCTL_FTYPE)) == 271 return (fc & cpu_to_le16(IEEE80211_FCTL_FTYPE)) ==
272 cpu_to_le16(IEEE80211_FTYPE_CTL); 272 cpu_to_le16(IEEE80211_FTYPE_CTL);
273 } 273 }
274 274
275 /** 275 /**
276 * ieee80211_is_data - check if type is IEEE80211_FTYPE_DATA 276 * ieee80211_is_data - check if type is IEEE80211_FTYPE_DATA
277 * @fc: frame control bytes in little-endian byteorder 277 * @fc: frame control bytes in little-endian byteorder
278 */ 278 */
279 static inline int ieee80211_is_data(__le16 fc) 279 static inline int ieee80211_is_data(__le16 fc)
280 { 280 {
281 return (fc & cpu_to_le16(IEEE80211_FCTL_FTYPE)) == 281 return (fc & cpu_to_le16(IEEE80211_FCTL_FTYPE)) ==
282 cpu_to_le16(IEEE80211_FTYPE_DATA); 282 cpu_to_le16(IEEE80211_FTYPE_DATA);
283 } 283 }
284 284
285 /** 285 /**
286 * ieee80211_is_data_qos - check if type is IEEE80211_FTYPE_DATA and IEEE80211_STYPE_QOS_DATA is set 286 * ieee80211_is_data_qos - check if type is IEEE80211_FTYPE_DATA and IEEE80211_STYPE_QOS_DATA is set
287 * @fc: frame control bytes in little-endian byteorder 287 * @fc: frame control bytes in little-endian byteorder
288 */ 288 */
289 static inline int ieee80211_is_data_qos(__le16 fc) 289 static inline int ieee80211_is_data_qos(__le16 fc)
290 { 290 {
291 /* 291 /*
292 * mask with QOS_DATA rather than IEEE80211_FCTL_STYPE as we just need 292 * mask with QOS_DATA rather than IEEE80211_FCTL_STYPE as we just need
293 * to check the one bit 293 * to check the one bit
294 */ 294 */
295 return (fc & cpu_to_le16(IEEE80211_FCTL_FTYPE | IEEE80211_STYPE_QOS_DATA)) == 295 return (fc & cpu_to_le16(IEEE80211_FCTL_FTYPE | IEEE80211_STYPE_QOS_DATA)) ==
296 cpu_to_le16(IEEE80211_FTYPE_DATA | IEEE80211_STYPE_QOS_DATA); 296 cpu_to_le16(IEEE80211_FTYPE_DATA | IEEE80211_STYPE_QOS_DATA);
297 } 297 }
298 298
299 /** 299 /**
300 * ieee80211_is_data_present - check if type is IEEE80211_FTYPE_DATA and has data 300 * ieee80211_is_data_present - check if type is IEEE80211_FTYPE_DATA and has data
301 * @fc: frame control bytes in little-endian byteorder 301 * @fc: frame control bytes in little-endian byteorder
302 */ 302 */
303 static inline int ieee80211_is_data_present(__le16 fc) 303 static inline int ieee80211_is_data_present(__le16 fc)
304 { 304 {
305 /* 305 /*
306 * mask with 0x40 and test that that bit is clear to only return true 306 * mask with 0x40 and test that that bit is clear to only return true
307 * for the data-containing substypes. 307 * for the data-containing substypes.
308 */ 308 */
309 return (fc & cpu_to_le16(IEEE80211_FCTL_FTYPE | 0x40)) == 309 return (fc & cpu_to_le16(IEEE80211_FCTL_FTYPE | 0x40)) ==
310 cpu_to_le16(IEEE80211_FTYPE_DATA); 310 cpu_to_le16(IEEE80211_FTYPE_DATA);
311 } 311 }
312 312
313 /** 313 /**
314 * ieee80211_is_assoc_req - check if IEEE80211_FTYPE_MGMT && IEEE80211_STYPE_ASSOC_REQ 314 * ieee80211_is_assoc_req - check if IEEE80211_FTYPE_MGMT && IEEE80211_STYPE_ASSOC_REQ
315 * @fc: frame control bytes in little-endian byteorder 315 * @fc: frame control bytes in little-endian byteorder
316 */ 316 */
317 static inline int ieee80211_is_assoc_req(__le16 fc) 317 static inline int ieee80211_is_assoc_req(__le16 fc)
318 { 318 {
319 return (fc & cpu_to_le16(IEEE80211_FCTL_FTYPE | IEEE80211_FCTL_STYPE)) == 319 return (fc & cpu_to_le16(IEEE80211_FCTL_FTYPE | IEEE80211_FCTL_STYPE)) ==
320 cpu_to_le16(IEEE80211_FTYPE_MGMT | IEEE80211_STYPE_ASSOC_REQ); 320 cpu_to_le16(IEEE80211_FTYPE_MGMT | IEEE80211_STYPE_ASSOC_REQ);
321 } 321 }
322 322
323 /** 323 /**
324 * ieee80211_is_assoc_resp - check if IEEE80211_FTYPE_MGMT && IEEE80211_STYPE_ASSOC_RESP 324 * ieee80211_is_assoc_resp - check if IEEE80211_FTYPE_MGMT && IEEE80211_STYPE_ASSOC_RESP
325 * @fc: frame control bytes in little-endian byteorder 325 * @fc: frame control bytes in little-endian byteorder
326 */ 326 */
327 static inline int ieee80211_is_assoc_resp(__le16 fc) 327 static inline int ieee80211_is_assoc_resp(__le16 fc)
328 { 328 {
329 return (fc & cpu_to_le16(IEEE80211_FCTL_FTYPE | IEEE80211_FCTL_STYPE)) == 329 return (fc & cpu_to_le16(IEEE80211_FCTL_FTYPE | IEEE80211_FCTL_STYPE)) ==
330 cpu_to_le16(IEEE80211_FTYPE_MGMT | IEEE80211_STYPE_ASSOC_RESP); 330 cpu_to_le16(IEEE80211_FTYPE_MGMT | IEEE80211_STYPE_ASSOC_RESP);
331 } 331 }
332 332
333 /** 333 /**
334 * ieee80211_is_reassoc_req - check if IEEE80211_FTYPE_MGMT && IEEE80211_STYPE_REASSOC_REQ 334 * ieee80211_is_reassoc_req - check if IEEE80211_FTYPE_MGMT && IEEE80211_STYPE_REASSOC_REQ
335 * @fc: frame control bytes in little-endian byteorder 335 * @fc: frame control bytes in little-endian byteorder
336 */ 336 */
337 static inline int ieee80211_is_reassoc_req(__le16 fc) 337 static inline int ieee80211_is_reassoc_req(__le16 fc)
338 { 338 {
339 return (fc & cpu_to_le16(IEEE80211_FCTL_FTYPE | IEEE80211_FCTL_STYPE)) == 339 return (fc & cpu_to_le16(IEEE80211_FCTL_FTYPE | IEEE80211_FCTL_STYPE)) ==
340 cpu_to_le16(IEEE80211_FTYPE_MGMT | IEEE80211_STYPE_REASSOC_REQ); 340 cpu_to_le16(IEEE80211_FTYPE_MGMT | IEEE80211_STYPE_REASSOC_REQ);
341 } 341 }
342 342
343 /** 343 /**
344 * ieee80211_is_reassoc_resp - check if IEEE80211_FTYPE_MGMT && IEEE80211_STYPE_REASSOC_RESP 344 * ieee80211_is_reassoc_resp - check if IEEE80211_FTYPE_MGMT && IEEE80211_STYPE_REASSOC_RESP
345 * @fc: frame control bytes in little-endian byteorder 345 * @fc: frame control bytes in little-endian byteorder
346 */ 346 */
347 static inline int ieee80211_is_reassoc_resp(__le16 fc) 347 static inline int ieee80211_is_reassoc_resp(__le16 fc)
348 { 348 {
349 return (fc & cpu_to_le16(IEEE80211_FCTL_FTYPE | IEEE80211_FCTL_STYPE)) == 349 return (fc & cpu_to_le16(IEEE80211_FCTL_FTYPE | IEEE80211_FCTL_STYPE)) ==
350 cpu_to_le16(IEEE80211_FTYPE_MGMT | IEEE80211_STYPE_REASSOC_RESP); 350 cpu_to_le16(IEEE80211_FTYPE_MGMT | IEEE80211_STYPE_REASSOC_RESP);
351 } 351 }
352 352
353 /** 353 /**
354 * ieee80211_is_probe_req - check if IEEE80211_FTYPE_MGMT && IEEE80211_STYPE_PROBE_REQ 354 * ieee80211_is_probe_req - check if IEEE80211_FTYPE_MGMT && IEEE80211_STYPE_PROBE_REQ
355 * @fc: frame control bytes in little-endian byteorder 355 * @fc: frame control bytes in little-endian byteorder
356 */ 356 */
357 static inline int ieee80211_is_probe_req(__le16 fc) 357 static inline int ieee80211_is_probe_req(__le16 fc)
358 { 358 {
359 return (fc & cpu_to_le16(IEEE80211_FCTL_FTYPE | IEEE80211_FCTL_STYPE)) == 359 return (fc & cpu_to_le16(IEEE80211_FCTL_FTYPE | IEEE80211_FCTL_STYPE)) ==
360 cpu_to_le16(IEEE80211_FTYPE_MGMT | IEEE80211_STYPE_PROBE_REQ); 360 cpu_to_le16(IEEE80211_FTYPE_MGMT | IEEE80211_STYPE_PROBE_REQ);
361 } 361 }
362 362
363 /** 363 /**
364 * ieee80211_is_probe_resp - check if IEEE80211_FTYPE_MGMT && IEEE80211_STYPE_PROBE_RESP 364 * ieee80211_is_probe_resp - check if IEEE80211_FTYPE_MGMT && IEEE80211_STYPE_PROBE_RESP
365 * @fc: frame control bytes in little-endian byteorder 365 * @fc: frame control bytes in little-endian byteorder
366 */ 366 */
367 static inline int ieee80211_is_probe_resp(__le16 fc) 367 static inline int ieee80211_is_probe_resp(__le16 fc)
368 { 368 {
369 return (fc & cpu_to_le16(IEEE80211_FCTL_FTYPE | IEEE80211_FCTL_STYPE)) == 369 return (fc & cpu_to_le16(IEEE80211_FCTL_FTYPE | IEEE80211_FCTL_STYPE)) ==
370 cpu_to_le16(IEEE80211_FTYPE_MGMT | IEEE80211_STYPE_PROBE_RESP); 370 cpu_to_le16(IEEE80211_FTYPE_MGMT | IEEE80211_STYPE_PROBE_RESP);
371 } 371 }
372 372
373 /** 373 /**
374 * ieee80211_is_beacon - check if IEEE80211_FTYPE_MGMT && IEEE80211_STYPE_BEACON 374 * ieee80211_is_beacon - check if IEEE80211_FTYPE_MGMT && IEEE80211_STYPE_BEACON
375 * @fc: frame control bytes in little-endian byteorder 375 * @fc: frame control bytes in little-endian byteorder
376 */ 376 */
377 static inline int ieee80211_is_beacon(__le16 fc) 377 static inline int ieee80211_is_beacon(__le16 fc)
378 { 378 {
379 return (fc & cpu_to_le16(IEEE80211_FCTL_FTYPE | IEEE80211_FCTL_STYPE)) == 379 return (fc & cpu_to_le16(IEEE80211_FCTL_FTYPE | IEEE80211_FCTL_STYPE)) ==
380 cpu_to_le16(IEEE80211_FTYPE_MGMT | IEEE80211_STYPE_BEACON); 380 cpu_to_le16(IEEE80211_FTYPE_MGMT | IEEE80211_STYPE_BEACON);
381 } 381 }
382 382
383 /** 383 /**
384 * ieee80211_is_atim - check if IEEE80211_FTYPE_MGMT && IEEE80211_STYPE_ATIM 384 * ieee80211_is_atim - check if IEEE80211_FTYPE_MGMT && IEEE80211_STYPE_ATIM
385 * @fc: frame control bytes in little-endian byteorder 385 * @fc: frame control bytes in little-endian byteorder
386 */ 386 */
387 static inline int ieee80211_is_atim(__le16 fc) 387 static inline int ieee80211_is_atim(__le16 fc)
388 { 388 {
389 return (fc & cpu_to_le16(IEEE80211_FCTL_FTYPE | IEEE80211_FCTL_STYPE)) == 389 return (fc & cpu_to_le16(IEEE80211_FCTL_FTYPE | IEEE80211_FCTL_STYPE)) ==
390 cpu_to_le16(IEEE80211_FTYPE_MGMT | IEEE80211_STYPE_ATIM); 390 cpu_to_le16(IEEE80211_FTYPE_MGMT | IEEE80211_STYPE_ATIM);
391 } 391 }
392 392
393 /** 393 /**
394 * ieee80211_is_disassoc - check if IEEE80211_FTYPE_MGMT && IEEE80211_STYPE_DISASSOC 394 * ieee80211_is_disassoc - check if IEEE80211_FTYPE_MGMT && IEEE80211_STYPE_DISASSOC
395 * @fc: frame control bytes in little-endian byteorder 395 * @fc: frame control bytes in little-endian byteorder
396 */ 396 */
397 static inline int ieee80211_is_disassoc(__le16 fc) 397 static inline int ieee80211_is_disassoc(__le16 fc)
398 { 398 {
399 return (fc & cpu_to_le16(IEEE80211_FCTL_FTYPE | IEEE80211_FCTL_STYPE)) == 399 return (fc & cpu_to_le16(IEEE80211_FCTL_FTYPE | IEEE80211_FCTL_STYPE)) ==
400 cpu_to_le16(IEEE80211_FTYPE_MGMT | IEEE80211_STYPE_DISASSOC); 400 cpu_to_le16(IEEE80211_FTYPE_MGMT | IEEE80211_STYPE_DISASSOC);
401 } 401 }
402 402
403 /** 403 /**
404 * ieee80211_is_auth - check if IEEE80211_FTYPE_MGMT && IEEE80211_STYPE_AUTH 404 * ieee80211_is_auth - check if IEEE80211_FTYPE_MGMT && IEEE80211_STYPE_AUTH
405 * @fc: frame control bytes in little-endian byteorder 405 * @fc: frame control bytes in little-endian byteorder
406 */ 406 */
407 static inline int ieee80211_is_auth(__le16 fc) 407 static inline int ieee80211_is_auth(__le16 fc)
408 { 408 {
409 return (fc & cpu_to_le16(IEEE80211_FCTL_FTYPE | IEEE80211_FCTL_STYPE)) == 409 return (fc & cpu_to_le16(IEEE80211_FCTL_FTYPE | IEEE80211_FCTL_STYPE)) ==
410 cpu_to_le16(IEEE80211_FTYPE_MGMT | IEEE80211_STYPE_AUTH); 410 cpu_to_le16(IEEE80211_FTYPE_MGMT | IEEE80211_STYPE_AUTH);
411 } 411 }
412 412
413 /** 413 /**
414 * ieee80211_is_deauth - check if IEEE80211_FTYPE_MGMT && IEEE80211_STYPE_DEAUTH 414 * ieee80211_is_deauth - check if IEEE80211_FTYPE_MGMT && IEEE80211_STYPE_DEAUTH
415 * @fc: frame control bytes in little-endian byteorder 415 * @fc: frame control bytes in little-endian byteorder
416 */ 416 */
417 static inline int ieee80211_is_deauth(__le16 fc) 417 static inline int ieee80211_is_deauth(__le16 fc)
418 { 418 {
419 return (fc & cpu_to_le16(IEEE80211_FCTL_FTYPE | IEEE80211_FCTL_STYPE)) == 419 return (fc & cpu_to_le16(IEEE80211_FCTL_FTYPE | IEEE80211_FCTL_STYPE)) ==
420 cpu_to_le16(IEEE80211_FTYPE_MGMT | IEEE80211_STYPE_DEAUTH); 420 cpu_to_le16(IEEE80211_FTYPE_MGMT | IEEE80211_STYPE_DEAUTH);
421 } 421 }
422 422
423 /** 423 /**
424 * ieee80211_is_action - check if IEEE80211_FTYPE_MGMT && IEEE80211_STYPE_ACTION 424 * ieee80211_is_action - check if IEEE80211_FTYPE_MGMT && IEEE80211_STYPE_ACTION
425 * @fc: frame control bytes in little-endian byteorder 425 * @fc: frame control bytes in little-endian byteorder
426 */ 426 */
427 static inline int ieee80211_is_action(__le16 fc) 427 static inline int ieee80211_is_action(__le16 fc)
428 { 428 {
429 return (fc & cpu_to_le16(IEEE80211_FCTL_FTYPE | IEEE80211_FCTL_STYPE)) == 429 return (fc & cpu_to_le16(IEEE80211_FCTL_FTYPE | IEEE80211_FCTL_STYPE)) ==
430 cpu_to_le16(IEEE80211_FTYPE_MGMT | IEEE80211_STYPE_ACTION); 430 cpu_to_le16(IEEE80211_FTYPE_MGMT | IEEE80211_STYPE_ACTION);
431 } 431 }
432 432
433 /** 433 /**
434 * ieee80211_is_back_req - check if IEEE80211_FTYPE_CTL && IEEE80211_STYPE_BACK_REQ 434 * ieee80211_is_back_req - check if IEEE80211_FTYPE_CTL && IEEE80211_STYPE_BACK_REQ
435 * @fc: frame control bytes in little-endian byteorder 435 * @fc: frame control bytes in little-endian byteorder
436 */ 436 */
437 static inline int ieee80211_is_back_req(__le16 fc) 437 static inline int ieee80211_is_back_req(__le16 fc)
438 { 438 {
439 return (fc & cpu_to_le16(IEEE80211_FCTL_FTYPE | IEEE80211_FCTL_STYPE)) == 439 return (fc & cpu_to_le16(IEEE80211_FCTL_FTYPE | IEEE80211_FCTL_STYPE)) ==
440 cpu_to_le16(IEEE80211_FTYPE_CTL | IEEE80211_STYPE_BACK_REQ); 440 cpu_to_le16(IEEE80211_FTYPE_CTL | IEEE80211_STYPE_BACK_REQ);
441 } 441 }
442 442
443 /** 443 /**
444 * ieee80211_is_back - check if IEEE80211_FTYPE_CTL && IEEE80211_STYPE_BACK 444 * ieee80211_is_back - check if IEEE80211_FTYPE_CTL && IEEE80211_STYPE_BACK
445 * @fc: frame control bytes in little-endian byteorder 445 * @fc: frame control bytes in little-endian byteorder
446 */ 446 */
447 static inline int ieee80211_is_back(__le16 fc) 447 static inline int ieee80211_is_back(__le16 fc)
448 { 448 {
449 return (fc & cpu_to_le16(IEEE80211_FCTL_FTYPE | IEEE80211_FCTL_STYPE)) == 449 return (fc & cpu_to_le16(IEEE80211_FCTL_FTYPE | IEEE80211_FCTL_STYPE)) ==
450 cpu_to_le16(IEEE80211_FTYPE_CTL | IEEE80211_STYPE_BACK); 450 cpu_to_le16(IEEE80211_FTYPE_CTL | IEEE80211_STYPE_BACK);
451 } 451 }
452 452
453 /** 453 /**
454 * ieee80211_is_pspoll - check if IEEE80211_FTYPE_CTL && IEEE80211_STYPE_PSPOLL 454 * ieee80211_is_pspoll - check if IEEE80211_FTYPE_CTL && IEEE80211_STYPE_PSPOLL
455 * @fc: frame control bytes in little-endian byteorder 455 * @fc: frame control bytes in little-endian byteorder
456 */ 456 */
457 static inline int ieee80211_is_pspoll(__le16 fc) 457 static inline int ieee80211_is_pspoll(__le16 fc)
458 { 458 {
459 return (fc & cpu_to_le16(IEEE80211_FCTL_FTYPE | IEEE80211_FCTL_STYPE)) == 459 return (fc & cpu_to_le16(IEEE80211_FCTL_FTYPE | IEEE80211_FCTL_STYPE)) ==
460 cpu_to_le16(IEEE80211_FTYPE_CTL | IEEE80211_STYPE_PSPOLL); 460 cpu_to_le16(IEEE80211_FTYPE_CTL | IEEE80211_STYPE_PSPOLL);
461 } 461 }
462 462
463 /** 463 /**
464 * ieee80211_is_rts - check if IEEE80211_FTYPE_CTL && IEEE80211_STYPE_RTS 464 * ieee80211_is_rts - check if IEEE80211_FTYPE_CTL && IEEE80211_STYPE_RTS
465 * @fc: frame control bytes in little-endian byteorder 465 * @fc: frame control bytes in little-endian byteorder
466 */ 466 */
467 static inline int ieee80211_is_rts(__le16 fc) 467 static inline int ieee80211_is_rts(__le16 fc)
468 { 468 {
469 return (fc & cpu_to_le16(IEEE80211_FCTL_FTYPE | IEEE80211_FCTL_STYPE)) == 469 return (fc & cpu_to_le16(IEEE80211_FCTL_FTYPE | IEEE80211_FCTL_STYPE)) ==
470 cpu_to_le16(IEEE80211_FTYPE_CTL | IEEE80211_STYPE_RTS); 470 cpu_to_le16(IEEE80211_FTYPE_CTL | IEEE80211_STYPE_RTS);
471 } 471 }
472 472
473 /** 473 /**
474 * ieee80211_is_cts - check if IEEE80211_FTYPE_CTL && IEEE80211_STYPE_CTS 474 * ieee80211_is_cts - check if IEEE80211_FTYPE_CTL && IEEE80211_STYPE_CTS
475 * @fc: frame control bytes in little-endian byteorder 475 * @fc: frame control bytes in little-endian byteorder
476 */ 476 */
477 static inline int ieee80211_is_cts(__le16 fc) 477 static inline int ieee80211_is_cts(__le16 fc)
478 { 478 {
479 return (fc & cpu_to_le16(IEEE80211_FCTL_FTYPE | IEEE80211_FCTL_STYPE)) == 479 return (fc & cpu_to_le16(IEEE80211_FCTL_FTYPE | IEEE80211_FCTL_STYPE)) ==
480 cpu_to_le16(IEEE80211_FTYPE_CTL | IEEE80211_STYPE_CTS); 480 cpu_to_le16(IEEE80211_FTYPE_CTL | IEEE80211_STYPE_CTS);
481 } 481 }
482 482
483 /** 483 /**
484 * ieee80211_is_ack - check if IEEE80211_FTYPE_CTL && IEEE80211_STYPE_ACK 484 * ieee80211_is_ack - check if IEEE80211_FTYPE_CTL && IEEE80211_STYPE_ACK
485 * @fc: frame control bytes in little-endian byteorder 485 * @fc: frame control bytes in little-endian byteorder
486 */ 486 */
487 static inline int ieee80211_is_ack(__le16 fc) 487 static inline int ieee80211_is_ack(__le16 fc)
488 { 488 {
489 return (fc & cpu_to_le16(IEEE80211_FCTL_FTYPE | IEEE80211_FCTL_STYPE)) == 489 return (fc & cpu_to_le16(IEEE80211_FCTL_FTYPE | IEEE80211_FCTL_STYPE)) ==
490 cpu_to_le16(IEEE80211_FTYPE_CTL | IEEE80211_STYPE_ACK); 490 cpu_to_le16(IEEE80211_FTYPE_CTL | IEEE80211_STYPE_ACK);
491 } 491 }
492 492
493 /** 493 /**
494 * ieee80211_is_cfend - check if IEEE80211_FTYPE_CTL && IEEE80211_STYPE_CFEND 494 * ieee80211_is_cfend - check if IEEE80211_FTYPE_CTL && IEEE80211_STYPE_CFEND
495 * @fc: frame control bytes in little-endian byteorder 495 * @fc: frame control bytes in little-endian byteorder
496 */ 496 */
497 static inline int ieee80211_is_cfend(__le16 fc) 497 static inline int ieee80211_is_cfend(__le16 fc)
498 { 498 {
499 return (fc & cpu_to_le16(IEEE80211_FCTL_FTYPE | IEEE80211_FCTL_STYPE)) == 499 return (fc & cpu_to_le16(IEEE80211_FCTL_FTYPE | IEEE80211_FCTL_STYPE)) ==
500 cpu_to_le16(IEEE80211_FTYPE_CTL | IEEE80211_STYPE_CFEND); 500 cpu_to_le16(IEEE80211_FTYPE_CTL | IEEE80211_STYPE_CFEND);
501 } 501 }
502 502
503 /** 503 /**
504 * ieee80211_is_cfendack - check if IEEE80211_FTYPE_CTL && IEEE80211_STYPE_CFENDACK 504 * ieee80211_is_cfendack - check if IEEE80211_FTYPE_CTL && IEEE80211_STYPE_CFENDACK
505 * @fc: frame control bytes in little-endian byteorder 505 * @fc: frame control bytes in little-endian byteorder
506 */ 506 */
507 static inline int ieee80211_is_cfendack(__le16 fc) 507 static inline int ieee80211_is_cfendack(__le16 fc)
508 { 508 {
509 return (fc & cpu_to_le16(IEEE80211_FCTL_FTYPE | IEEE80211_FCTL_STYPE)) == 509 return (fc & cpu_to_le16(IEEE80211_FCTL_FTYPE | IEEE80211_FCTL_STYPE)) ==
510 cpu_to_le16(IEEE80211_FTYPE_CTL | IEEE80211_STYPE_CFENDACK); 510 cpu_to_le16(IEEE80211_FTYPE_CTL | IEEE80211_STYPE_CFENDACK);
511 } 511 }
512 512
513 /** 513 /**
514 * ieee80211_is_nullfunc - check if frame is a regular (non-QoS) nullfunc frame 514 * ieee80211_is_nullfunc - check if frame is a regular (non-QoS) nullfunc frame
515 * @fc: frame control bytes in little-endian byteorder 515 * @fc: frame control bytes in little-endian byteorder
516 */ 516 */
517 static inline int ieee80211_is_nullfunc(__le16 fc) 517 static inline int ieee80211_is_nullfunc(__le16 fc)
518 { 518 {
519 return (fc & cpu_to_le16(IEEE80211_FCTL_FTYPE | IEEE80211_FCTL_STYPE)) == 519 return (fc & cpu_to_le16(IEEE80211_FCTL_FTYPE | IEEE80211_FCTL_STYPE)) ==
520 cpu_to_le16(IEEE80211_FTYPE_DATA | IEEE80211_STYPE_NULLFUNC); 520 cpu_to_le16(IEEE80211_FTYPE_DATA | IEEE80211_STYPE_NULLFUNC);
521 } 521 }
522 522
523 /** 523 /**
524 * ieee80211_is_qos_nullfunc - check if frame is a QoS nullfunc frame 524 * ieee80211_is_qos_nullfunc - check if frame is a QoS nullfunc frame
525 * @fc: frame control bytes in little-endian byteorder 525 * @fc: frame control bytes in little-endian byteorder
526 */ 526 */
527 static inline int ieee80211_is_qos_nullfunc(__le16 fc) 527 static inline int ieee80211_is_qos_nullfunc(__le16 fc)
528 { 528 {
529 return (fc & cpu_to_le16(IEEE80211_FCTL_FTYPE | IEEE80211_FCTL_STYPE)) == 529 return (fc & cpu_to_le16(IEEE80211_FCTL_FTYPE | IEEE80211_FCTL_STYPE)) ==
530 cpu_to_le16(IEEE80211_FTYPE_DATA | IEEE80211_STYPE_QOS_NULLFUNC); 530 cpu_to_le16(IEEE80211_FTYPE_DATA | IEEE80211_STYPE_QOS_NULLFUNC);
531 } 531 }
532 532
533 struct ieee80211s_hdr { 533 struct ieee80211s_hdr {
534 u8 flags; 534 u8 flags;
535 u8 ttl; 535 u8 ttl;
536 __le32 seqnum; 536 __le32 seqnum;
537 u8 eaddr1[6]; 537 u8 eaddr1[6];
538 u8 eaddr2[6]; 538 u8 eaddr2[6];
539 } __attribute__ ((packed)); 539 } __attribute__ ((packed));
540 540
541 /* Mesh flags */ 541 /* Mesh flags */
542 #define MESH_FLAGS_AE_A4 0x1 542 #define MESH_FLAGS_AE_A4 0x1
543 #define MESH_FLAGS_AE_A5_A6 0x2 543 #define MESH_FLAGS_AE_A5_A6 0x2
544 #define MESH_FLAGS_AE 0x3 544 #define MESH_FLAGS_AE 0x3
545 #define MESH_FLAGS_PS_DEEP 0x4 545 #define MESH_FLAGS_PS_DEEP 0x4
546 546
547 /** 547 /**
548 * struct ieee80211_quiet_ie 548 * struct ieee80211_quiet_ie
549 * 549 *
550 * This structure refers to "Quiet information element" 550 * This structure refers to "Quiet information element"
551 */ 551 */
552 struct ieee80211_quiet_ie { 552 struct ieee80211_quiet_ie {
553 u8 count; 553 u8 count;
554 u8 period; 554 u8 period;
555 __le16 duration; 555 __le16 duration;
556 __le16 offset; 556 __le16 offset;
557 } __attribute__ ((packed)); 557 } __attribute__ ((packed));
558 558
559 /** 559 /**
560 * struct ieee80211_msrment_ie 560 * struct ieee80211_msrment_ie
561 * 561 *
562 * This structure refers to "Measurement Request/Report information element" 562 * This structure refers to "Measurement Request/Report information element"
563 */ 563 */
564 struct ieee80211_msrment_ie { 564 struct ieee80211_msrment_ie {
565 u8 token; 565 u8 token;
566 u8 mode; 566 u8 mode;
567 u8 type; 567 u8 type;
568 u8 request[0]; 568 u8 request[0];
569 } __attribute__ ((packed)); 569 } __attribute__ ((packed));
570 570
571 /** 571 /**
572 * struct ieee80211_channel_sw_ie 572 * struct ieee80211_channel_sw_ie
573 * 573 *
574 * This structure refers to "Channel Switch Announcement information element" 574 * This structure refers to "Channel Switch Announcement information element"
575 */ 575 */
576 struct ieee80211_channel_sw_ie { 576 struct ieee80211_channel_sw_ie {
577 u8 mode; 577 u8 mode;
578 u8 new_ch_num; 578 u8 new_ch_num;
579 u8 count; 579 u8 count;
580 } __attribute__ ((packed)); 580 } __attribute__ ((packed));
581 581
582 /** 582 /**
583 * struct ieee80211_tim 583 * struct ieee80211_tim
584 * 584 *
585 * This structure refers to "Traffic Indication Map information element" 585 * This structure refers to "Traffic Indication Map information element"
586 */ 586 */
587 struct ieee80211_tim_ie { 587 struct ieee80211_tim_ie {
588 u8 dtim_count; 588 u8 dtim_count;
589 u8 dtim_period; 589 u8 dtim_period;
590 u8 bitmap_ctrl; 590 u8 bitmap_ctrl;
591 /* variable size: 1 - 251 bytes */ 591 /* variable size: 1 - 251 bytes */
592 u8 virtual_map[1]; 592 u8 virtual_map[1];
593 } __attribute__ ((packed)); 593 } __attribute__ ((packed));
594 594
595 /** 595 /**
596 * struct ieee80211_meshconf_ie 596 * struct ieee80211_meshconf_ie
597 * 597 *
598 * This structure refers to "Mesh Configuration information element" 598 * This structure refers to "Mesh Configuration information element"
599 */ 599 */
600 struct ieee80211_meshconf_ie { 600 struct ieee80211_meshconf_ie {
601 u8 meshconf_psel; 601 u8 meshconf_psel;
602 u8 meshconf_pmetric; 602 u8 meshconf_pmetric;
603 u8 meshconf_congest; 603 u8 meshconf_congest;
604 u8 meshconf_synch; 604 u8 meshconf_synch;
605 u8 meshconf_auth; 605 u8 meshconf_auth;
606 u8 meshconf_form; 606 u8 meshconf_form;
607 u8 meshconf_cap; 607 u8 meshconf_cap;
608 } __attribute__ ((packed)); 608 } __attribute__ ((packed));
609 609
610 /** 610 /**
611 * struct ieee80211_rann_ie 611 * struct ieee80211_rann_ie
612 * 612 *
613 * This structure refers to "Root Announcement information element" 613 * This structure refers to "Root Announcement information element"
614 */ 614 */
615 struct ieee80211_rann_ie { 615 struct ieee80211_rann_ie {
616 u8 rann_flags; 616 u8 rann_flags;
617 u8 rann_hopcount; 617 u8 rann_hopcount;
618 u8 rann_ttl; 618 u8 rann_ttl;
619 u8 rann_addr[6]; 619 u8 rann_addr[6];
620 u32 rann_seq; 620 u32 rann_seq;
621 u32 rann_metric; 621 u32 rann_metric;
622 } __attribute__ ((packed)); 622 } __attribute__ ((packed));
623 623
624 #define WLAN_SA_QUERY_TR_ID_LEN 2 624 #define WLAN_SA_QUERY_TR_ID_LEN 2
625 625
626 struct ieee80211_mgmt { 626 struct ieee80211_mgmt {
627 __le16 frame_control; 627 __le16 frame_control;
628 __le16 duration; 628 __le16 duration;
629 u8 da[6]; 629 u8 da[6];
630 u8 sa[6]; 630 u8 sa[6];
631 u8 bssid[6]; 631 u8 bssid[6];
632 __le16 seq_ctrl; 632 __le16 seq_ctrl;
633 union { 633 union {
634 struct { 634 struct {
635 __le16 auth_alg; 635 __le16 auth_alg;
636 __le16 auth_transaction; 636 __le16 auth_transaction;
637 __le16 status_code; 637 __le16 status_code;
638 /* possibly followed by Challenge text */ 638 /* possibly followed by Challenge text */
639 u8 variable[0]; 639 u8 variable[0];
640 } __attribute__ ((packed)) auth; 640 } __attribute__ ((packed)) auth;
641 struct { 641 struct {
642 __le16 reason_code; 642 __le16 reason_code;
643 } __attribute__ ((packed)) deauth; 643 } __attribute__ ((packed)) deauth;
644 struct { 644 struct {
645 __le16 capab_info; 645 __le16 capab_info;
646 __le16 listen_interval; 646 __le16 listen_interval;
647 /* followed by SSID and Supported rates */ 647 /* followed by SSID and Supported rates */
648 u8 variable[0]; 648 u8 variable[0];
649 } __attribute__ ((packed)) assoc_req; 649 } __attribute__ ((packed)) assoc_req;
650 struct { 650 struct {
651 __le16 capab_info; 651 __le16 capab_info;
652 __le16 status_code; 652 __le16 status_code;
653 __le16 aid; 653 __le16 aid;
654 /* followed by Supported rates */ 654 /* followed by Supported rates */
655 u8 variable[0]; 655 u8 variable[0];
656 } __attribute__ ((packed)) assoc_resp, reassoc_resp; 656 } __attribute__ ((packed)) assoc_resp, reassoc_resp;
657 struct { 657 struct {
658 __le16 capab_info; 658 __le16 capab_info;
659 __le16 listen_interval; 659 __le16 listen_interval;
660 u8 current_ap[6]; 660 u8 current_ap[6];
661 /* followed by SSID and Supported rates */ 661 /* followed by SSID and Supported rates */
662 u8 variable[0]; 662 u8 variable[0];
663 } __attribute__ ((packed)) reassoc_req; 663 } __attribute__ ((packed)) reassoc_req;
664 struct { 664 struct {
665 __le16 reason_code; 665 __le16 reason_code;
666 } __attribute__ ((packed)) disassoc; 666 } __attribute__ ((packed)) disassoc;
667 struct { 667 struct {
668 __le64 timestamp; 668 __le64 timestamp;
669 __le16 beacon_int; 669 __le16 beacon_int;
670 __le16 capab_info; 670 __le16 capab_info;
671 /* followed by some of SSID, Supported rates, 671 /* followed by some of SSID, Supported rates,
672 * FH Params, DS Params, CF Params, IBSS Params, TIM */ 672 * FH Params, DS Params, CF Params, IBSS Params, TIM */
673 u8 variable[0]; 673 u8 variable[0];
674 } __attribute__ ((packed)) beacon; 674 } __attribute__ ((packed)) beacon;
675 struct { 675 struct {
676 /* only variable items: SSID, Supported rates */ 676 /* only variable items: SSID, Supported rates */
677 u8 variable[0]; 677 u8 variable[0];
678 } __attribute__ ((packed)) probe_req; 678 } __attribute__ ((packed)) probe_req;
679 struct { 679 struct {
680 __le64 timestamp; 680 __le64 timestamp;
681 __le16 beacon_int; 681 __le16 beacon_int;
682 __le16 capab_info; 682 __le16 capab_info;
683 /* followed by some of SSID, Supported rates, 683 /* followed by some of SSID, Supported rates,
684 * FH Params, DS Params, CF Params, IBSS Params */ 684 * FH Params, DS Params, CF Params, IBSS Params */
685 u8 variable[0]; 685 u8 variable[0];
686 } __attribute__ ((packed)) probe_resp; 686 } __attribute__ ((packed)) probe_resp;
687 struct { 687 struct {
688 u8 category; 688 u8 category;
689 union { 689 union {
690 struct { 690 struct {
691 u8 action_code; 691 u8 action_code;
692 u8 dialog_token; 692 u8 dialog_token;
693 u8 status_code; 693 u8 status_code;
694 u8 variable[0]; 694 u8 variable[0];
695 } __attribute__ ((packed)) wme_action; 695 } __attribute__ ((packed)) wme_action;
696 struct{ 696 struct{
697 u8 action_code; 697 u8 action_code;
698 u8 element_id; 698 u8 element_id;
699 u8 length; 699 u8 length;
700 struct ieee80211_channel_sw_ie sw_elem; 700 struct ieee80211_channel_sw_ie sw_elem;
701 } __attribute__((packed)) chan_switch; 701 } __attribute__((packed)) chan_switch;
702 struct{ 702 struct{
703 u8 action_code; 703 u8 action_code;
704 u8 dialog_token; 704 u8 dialog_token;
705 u8 element_id; 705 u8 element_id;
706 u8 length; 706 u8 length;
707 struct ieee80211_msrment_ie msr_elem; 707 struct ieee80211_msrment_ie msr_elem;
708 } __attribute__((packed)) measurement; 708 } __attribute__((packed)) measurement;
709 struct{ 709 struct{
710 u8 action_code; 710 u8 action_code;
711 u8 dialog_token; 711 u8 dialog_token;
712 __le16 capab; 712 __le16 capab;
713 __le16 timeout; 713 __le16 timeout;
714 __le16 start_seq_num; 714 __le16 start_seq_num;
715 } __attribute__((packed)) addba_req; 715 } __attribute__((packed)) addba_req;
716 struct{ 716 struct{
717 u8 action_code; 717 u8 action_code;
718 u8 dialog_token; 718 u8 dialog_token;
719 __le16 status; 719 __le16 status;
720 __le16 capab; 720 __le16 capab;
721 __le16 timeout; 721 __le16 timeout;
722 } __attribute__((packed)) addba_resp; 722 } __attribute__((packed)) addba_resp;
723 struct{ 723 struct{
724 u8 action_code; 724 u8 action_code;
725 __le16 params; 725 __le16 params;
726 __le16 reason_code; 726 __le16 reason_code;
727 } __attribute__((packed)) delba; 727 } __attribute__((packed)) delba;
728 struct{ 728 struct{
729 u8 action_code; 729 u8 action_code;
730 /* capab_info for open and confirm, 730 /* capab_info for open and confirm,
731 * reason for close 731 * reason for close
732 */ 732 */
733 __le16 aux; 733 __le16 aux;
734 /* Followed in plink_confirm by status 734 /* Followed in plink_confirm by status
735 * code, AID and supported rates, 735 * code, AID and supported rates,
736 * and directly by supported rates in 736 * and directly by supported rates in
737 * plink_open and plink_close 737 * plink_open and plink_close
738 */ 738 */
739 u8 variable[0]; 739 u8 variable[0];
740 } __attribute__((packed)) plink_action; 740 } __attribute__((packed)) plink_action;
741 struct{ 741 struct{
742 u8 action_code; 742 u8 action_code;
743 u8 variable[0]; 743 u8 variable[0];
744 } __attribute__((packed)) mesh_action; 744 } __attribute__((packed)) mesh_action;
745 struct { 745 struct {
746 u8 action; 746 u8 action;
747 u8 trans_id[WLAN_SA_QUERY_TR_ID_LEN]; 747 u8 trans_id[WLAN_SA_QUERY_TR_ID_LEN];
748 } __attribute__ ((packed)) sa_query; 748 } __attribute__ ((packed)) sa_query;
749 struct { 749 struct {
750 u8 action; 750 u8 action;
751 u8 smps_control; 751 u8 smps_control;
752 } __attribute__ ((packed)) ht_smps; 752 } __attribute__ ((packed)) ht_smps;
753 } u; 753 } u;
754 } __attribute__ ((packed)) action; 754 } __attribute__ ((packed)) action;
755 } u; 755 } u;
756 } __attribute__ ((packed)); 756 } __attribute__ ((packed));
757 757
758 /* mgmt header + 1 byte category code */ 758 /* mgmt header + 1 byte category code */
759 #define IEEE80211_MIN_ACTION_SIZE offsetof(struct ieee80211_mgmt, u.action.u) 759 #define IEEE80211_MIN_ACTION_SIZE offsetof(struct ieee80211_mgmt, u.action.u)
760 760
761 761
762 /* Management MIC information element (IEEE 802.11w) */ 762 /* Management MIC information element (IEEE 802.11w) */
763 struct ieee80211_mmie { 763 struct ieee80211_mmie {
764 u8 element_id; 764 u8 element_id;
765 u8 length; 765 u8 length;
766 __le16 key_id; 766 __le16 key_id;
767 u8 sequence_number[6]; 767 u8 sequence_number[6];
768 u8 mic[8]; 768 u8 mic[8];
769 } __attribute__ ((packed)); 769 } __attribute__ ((packed));
770 770
771 /* Control frames */ 771 /* Control frames */
772 struct ieee80211_rts { 772 struct ieee80211_rts {
773 __le16 frame_control; 773 __le16 frame_control;
774 __le16 duration; 774 __le16 duration;
775 u8 ra[6]; 775 u8 ra[6];
776 u8 ta[6]; 776 u8 ta[6];
777 } __attribute__ ((packed)); 777 } __attribute__ ((packed));
778 778
779 struct ieee80211_cts { 779 struct ieee80211_cts {
780 __le16 frame_control; 780 __le16 frame_control;
781 __le16 duration; 781 __le16 duration;
782 u8 ra[6]; 782 u8 ra[6];
783 } __attribute__ ((packed)); 783 } __attribute__ ((packed));
784 784
785 struct ieee80211_pspoll { 785 struct ieee80211_pspoll {
786 __le16 frame_control; 786 __le16 frame_control;
787 __le16 aid; 787 __le16 aid;
788 u8 bssid[6]; 788 u8 bssid[6];
789 u8 ta[6]; 789 u8 ta[6];
790 } __attribute__ ((packed)); 790 } __attribute__ ((packed));
791 791
792 /** 792 /**
793 * struct ieee80211_bar - HT Block Ack Request 793 * struct ieee80211_bar - HT Block Ack Request
794 * 794 *
795 * This structure refers to "HT BlockAckReq" as 795 * This structure refers to "HT BlockAckReq" as
796 * described in 802.11n draft section 7.2.1.7.1 796 * described in 802.11n draft section 7.2.1.7.1
797 */ 797 */
798 struct ieee80211_bar { 798 struct ieee80211_bar {
799 __le16 frame_control; 799 __le16 frame_control;
800 __le16 duration; 800 __le16 duration;
801 __u8 ra[6]; 801 __u8 ra[6];
802 __u8 ta[6]; 802 __u8 ta[6];
803 __le16 control; 803 __le16 control;
804 __le16 start_seq_num; 804 __le16 start_seq_num;
805 } __attribute__((packed)); 805 } __attribute__((packed));
806 806
807 /* 802.11 BAR control masks */ 807 /* 802.11 BAR control masks */
808 #define IEEE80211_BAR_CTRL_ACK_POLICY_NORMAL 0x0000 808 #define IEEE80211_BAR_CTRL_ACK_POLICY_NORMAL 0x0000
809 #define IEEE80211_BAR_CTRL_CBMTID_COMPRESSED_BA 0x0004 809 #define IEEE80211_BAR_CTRL_CBMTID_COMPRESSED_BA 0x0004
810 810
811 811
812 #define IEEE80211_HT_MCS_MASK_LEN 10 812 #define IEEE80211_HT_MCS_MASK_LEN 10
813 813
814 /** 814 /**
815 * struct ieee80211_mcs_info - MCS information 815 * struct ieee80211_mcs_info - MCS information
816 * @rx_mask: RX mask 816 * @rx_mask: RX mask
817 * @rx_highest: highest supported RX rate. If set represents 817 * @rx_highest: highest supported RX rate. If set represents
818 * the highest supported RX data rate in units of 1 Mbps. 818 * the highest supported RX data rate in units of 1 Mbps.
819 * If this field is 0 this value should not be used to 819 * If this field is 0 this value should not be used to
820 * consider the highest RX data rate supported. 820 * consider the highest RX data rate supported.
821 * @tx_params: TX parameters 821 * @tx_params: TX parameters
822 */ 822 */
823 struct ieee80211_mcs_info { 823 struct ieee80211_mcs_info {
824 u8 rx_mask[IEEE80211_HT_MCS_MASK_LEN]; 824 u8 rx_mask[IEEE80211_HT_MCS_MASK_LEN];
825 __le16 rx_highest; 825 __le16 rx_highest;
826 u8 tx_params; 826 u8 tx_params;
827 u8 reserved[3]; 827 u8 reserved[3];
828 } __attribute__((packed)); 828 } __attribute__((packed));
829 829
830 /* 802.11n HT capability MSC set */ 830 /* 802.11n HT capability MSC set */
831 #define IEEE80211_HT_MCS_RX_HIGHEST_MASK 0x3ff 831 #define IEEE80211_HT_MCS_RX_HIGHEST_MASK 0x3ff
832 #define IEEE80211_HT_MCS_TX_DEFINED 0x01 832 #define IEEE80211_HT_MCS_TX_DEFINED 0x01
833 #define IEEE80211_HT_MCS_TX_RX_DIFF 0x02 833 #define IEEE80211_HT_MCS_TX_RX_DIFF 0x02
834 /* value 0 == 1 stream etc */ 834 /* value 0 == 1 stream etc */
835 #define IEEE80211_HT_MCS_TX_MAX_STREAMS_MASK 0x0C 835 #define IEEE80211_HT_MCS_TX_MAX_STREAMS_MASK 0x0C
836 #define IEEE80211_HT_MCS_TX_MAX_STREAMS_SHIFT 2 836 #define IEEE80211_HT_MCS_TX_MAX_STREAMS_SHIFT 2
837 #define IEEE80211_HT_MCS_TX_MAX_STREAMS 4 837 #define IEEE80211_HT_MCS_TX_MAX_STREAMS 4
838 #define IEEE80211_HT_MCS_TX_UNEQUAL_MODULATION 0x10 838 #define IEEE80211_HT_MCS_TX_UNEQUAL_MODULATION 0x10
839 839
840 /* 840 /*
841 * 802.11n D5.0 20.3.5 / 20.6 says: 841 * 802.11n D5.0 20.3.5 / 20.6 says:
842 * - indices 0 to 7 and 32 are single spatial stream 842 * - indices 0 to 7 and 32 are single spatial stream
843 * - 8 to 31 are multiple spatial streams using equal modulation 843 * - 8 to 31 are multiple spatial streams using equal modulation
844 * [8..15 for two streams, 16..23 for three and 24..31 for four] 844 * [8..15 for two streams, 16..23 for three and 24..31 for four]
845 * - remainder are multiple spatial streams using unequal modulation 845 * - remainder are multiple spatial streams using unequal modulation
846 */ 846 */
847 #define IEEE80211_HT_MCS_UNEQUAL_MODULATION_START 33 847 #define IEEE80211_HT_MCS_UNEQUAL_MODULATION_START 33
848 #define IEEE80211_HT_MCS_UNEQUAL_MODULATION_START_BYTE \ 848 #define IEEE80211_HT_MCS_UNEQUAL_MODULATION_START_BYTE \
849 (IEEE80211_HT_MCS_UNEQUAL_MODULATION_START / 8) 849 (IEEE80211_HT_MCS_UNEQUAL_MODULATION_START / 8)
850 850
851 /** 851 /**
852 * struct ieee80211_ht_cap - HT capabilities 852 * struct ieee80211_ht_cap - HT capabilities
853 * 853 *
854 * This structure is the "HT capabilities element" as 854 * This structure is the "HT capabilities element" as
855 * described in 802.11n D5.0 7.3.2.57 855 * described in 802.11n D5.0 7.3.2.57
856 */ 856 */
857 struct ieee80211_ht_cap { 857 struct ieee80211_ht_cap {
858 __le16 cap_info; 858 __le16 cap_info;
859 u8 ampdu_params_info; 859 u8 ampdu_params_info;
860 860
861 /* 16 bytes MCS information */ 861 /* 16 bytes MCS information */
862 struct ieee80211_mcs_info mcs; 862 struct ieee80211_mcs_info mcs;
863 863
864 __le16 extended_ht_cap_info; 864 __le16 extended_ht_cap_info;
865 __le32 tx_BF_cap_info; 865 __le32 tx_BF_cap_info;
866 u8 antenna_selection_info; 866 u8 antenna_selection_info;
867 } __attribute__ ((packed)); 867 } __attribute__ ((packed));
868 868
869 /* 802.11n HT capabilities masks (for cap_info) */ 869 /* 802.11n HT capabilities masks (for cap_info) */
870 #define IEEE80211_HT_CAP_LDPC_CODING 0x0001 870 #define IEEE80211_HT_CAP_LDPC_CODING 0x0001
871 #define IEEE80211_HT_CAP_SUP_WIDTH_20_40 0x0002 871 #define IEEE80211_HT_CAP_SUP_WIDTH_20_40 0x0002
872 #define IEEE80211_HT_CAP_SM_PS 0x000C 872 #define IEEE80211_HT_CAP_SM_PS 0x000C
873 #define IEEE80211_HT_CAP_SM_PS_SHIFT 2 873 #define IEEE80211_HT_CAP_SM_PS_SHIFT 2
874 #define IEEE80211_HT_CAP_GRN_FLD 0x0010 874 #define IEEE80211_HT_CAP_GRN_FLD 0x0010
875 #define IEEE80211_HT_CAP_SGI_20 0x0020 875 #define IEEE80211_HT_CAP_SGI_20 0x0020
876 #define IEEE80211_HT_CAP_SGI_40 0x0040 876 #define IEEE80211_HT_CAP_SGI_40 0x0040
877 #define IEEE80211_HT_CAP_TX_STBC 0x0080 877 #define IEEE80211_HT_CAP_TX_STBC 0x0080
878 #define IEEE80211_HT_CAP_RX_STBC 0x0300 878 #define IEEE80211_HT_CAP_RX_STBC 0x0300
879 #define IEEE80211_HT_CAP_RX_STBC_SHIFT 8 879 #define IEEE80211_HT_CAP_RX_STBC_SHIFT 8
880 #define IEEE80211_HT_CAP_DELAY_BA 0x0400 880 #define IEEE80211_HT_CAP_DELAY_BA 0x0400
881 #define IEEE80211_HT_CAP_MAX_AMSDU 0x0800 881 #define IEEE80211_HT_CAP_MAX_AMSDU 0x0800
882 #define IEEE80211_HT_CAP_DSSSCCK40 0x1000 882 #define IEEE80211_HT_CAP_DSSSCCK40 0x1000
883 #define IEEE80211_HT_CAP_RESERVED 0x2000 883 #define IEEE80211_HT_CAP_RESERVED 0x2000
884 #define IEEE80211_HT_CAP_40MHZ_INTOLERANT 0x4000 884 #define IEEE80211_HT_CAP_40MHZ_INTOLERANT 0x4000
885 #define IEEE80211_HT_CAP_LSIG_TXOP_PROT 0x8000 885 #define IEEE80211_HT_CAP_LSIG_TXOP_PROT 0x8000
886 886
887 /* 802.11n HT extended capabilities masks (for extended_ht_cap_info) */ 887 /* 802.11n HT extended capabilities masks (for extended_ht_cap_info) */
888 #define IEEE80211_HT_EXT_CAP_PCO 0x0001 888 #define IEEE80211_HT_EXT_CAP_PCO 0x0001
889 #define IEEE80211_HT_EXT_CAP_PCO_TIME 0x0006 889 #define IEEE80211_HT_EXT_CAP_PCO_TIME 0x0006
890 #define IEEE80211_HT_EXT_CAP_PCO_TIME_SHIFT 1 890 #define IEEE80211_HT_EXT_CAP_PCO_TIME_SHIFT 1
891 #define IEEE80211_HT_EXT_CAP_MCS_FB 0x0300 891 #define IEEE80211_HT_EXT_CAP_MCS_FB 0x0300
892 #define IEEE80211_HT_EXT_CAP_MCS_FB_SHIFT 8 892 #define IEEE80211_HT_EXT_CAP_MCS_FB_SHIFT 8
893 #define IEEE80211_HT_EXT_CAP_HTC_SUP 0x0400 893 #define IEEE80211_HT_EXT_CAP_HTC_SUP 0x0400
894 #define IEEE80211_HT_EXT_CAP_RD_RESPONDER 0x0800 894 #define IEEE80211_HT_EXT_CAP_RD_RESPONDER 0x0800
895 895
896 /* 802.11n HT capability AMPDU settings (for ampdu_params_info) */ 896 /* 802.11n HT capability AMPDU settings (for ampdu_params_info) */
897 #define IEEE80211_HT_AMPDU_PARM_FACTOR 0x03 897 #define IEEE80211_HT_AMPDU_PARM_FACTOR 0x03
898 #define IEEE80211_HT_AMPDU_PARM_DENSITY 0x1C 898 #define IEEE80211_HT_AMPDU_PARM_DENSITY 0x1C
899 #define IEEE80211_HT_AMPDU_PARM_DENSITY_SHIFT 2 899 #define IEEE80211_HT_AMPDU_PARM_DENSITY_SHIFT 2
900 900
901 /* 901 /*
902 * Maximum length of AMPDU that the STA can receive. 902 * Maximum length of AMPDU that the STA can receive.
903 * Length = 2 ^ (13 + max_ampdu_length_exp) - 1 (octets) 903 * Length = 2 ^ (13 + max_ampdu_length_exp) - 1 (octets)
904 */ 904 */
905 enum ieee80211_max_ampdu_length_exp { 905 enum ieee80211_max_ampdu_length_exp {
906 IEEE80211_HT_MAX_AMPDU_8K = 0, 906 IEEE80211_HT_MAX_AMPDU_8K = 0,
907 IEEE80211_HT_MAX_AMPDU_16K = 1, 907 IEEE80211_HT_MAX_AMPDU_16K = 1,
908 IEEE80211_HT_MAX_AMPDU_32K = 2, 908 IEEE80211_HT_MAX_AMPDU_32K = 2,
909 IEEE80211_HT_MAX_AMPDU_64K = 3 909 IEEE80211_HT_MAX_AMPDU_64K = 3
910 }; 910 };
911 911
912 #define IEEE80211_HT_MAX_AMPDU_FACTOR 13 912 #define IEEE80211_HT_MAX_AMPDU_FACTOR 13
913 913
914 /* Minimum MPDU start spacing */ 914 /* Minimum MPDU start spacing */
915 enum ieee80211_min_mpdu_spacing { 915 enum ieee80211_min_mpdu_spacing {
916 IEEE80211_HT_MPDU_DENSITY_NONE = 0, /* No restriction */ 916 IEEE80211_HT_MPDU_DENSITY_NONE = 0, /* No restriction */
917 IEEE80211_HT_MPDU_DENSITY_0_25 = 1, /* 1/4 usec */ 917 IEEE80211_HT_MPDU_DENSITY_0_25 = 1, /* 1/4 usec */
918 IEEE80211_HT_MPDU_DENSITY_0_5 = 2, /* 1/2 usec */ 918 IEEE80211_HT_MPDU_DENSITY_0_5 = 2, /* 1/2 usec */
919 IEEE80211_HT_MPDU_DENSITY_1 = 3, /* 1 usec */ 919 IEEE80211_HT_MPDU_DENSITY_1 = 3, /* 1 usec */
920 IEEE80211_HT_MPDU_DENSITY_2 = 4, /* 2 usec */ 920 IEEE80211_HT_MPDU_DENSITY_2 = 4, /* 2 usec */
921 IEEE80211_HT_MPDU_DENSITY_4 = 5, /* 4 usec */ 921 IEEE80211_HT_MPDU_DENSITY_4 = 5, /* 4 usec */
922 IEEE80211_HT_MPDU_DENSITY_8 = 6, /* 8 usec */ 922 IEEE80211_HT_MPDU_DENSITY_8 = 6, /* 8 usec */
923 IEEE80211_HT_MPDU_DENSITY_16 = 7 /* 16 usec */ 923 IEEE80211_HT_MPDU_DENSITY_16 = 7 /* 16 usec */
924 }; 924 };
925 925
926 /** 926 /**
927 * struct ieee80211_ht_info - HT information 927 * struct ieee80211_ht_info - HT information
928 * 928 *
929 * This structure is the "HT information element" as 929 * This structure is the "HT information element" as
930 * described in 802.11n D5.0 7.3.2.58 930 * described in 802.11n D5.0 7.3.2.58
931 */ 931 */
932 struct ieee80211_ht_info { 932 struct ieee80211_ht_info {
933 u8 control_chan; 933 u8 control_chan;
934 u8 ht_param; 934 u8 ht_param;
935 __le16 operation_mode; 935 __le16 operation_mode;
936 __le16 stbc_param; 936 __le16 stbc_param;
937 u8 basic_set[16]; 937 u8 basic_set[16];
938 } __attribute__ ((packed)); 938 } __attribute__ ((packed));
939 939
940 /* for ht_param */ 940 /* for ht_param */
941 #define IEEE80211_HT_PARAM_CHA_SEC_OFFSET 0x03 941 #define IEEE80211_HT_PARAM_CHA_SEC_OFFSET 0x03
942 #define IEEE80211_HT_PARAM_CHA_SEC_NONE 0x00 942 #define IEEE80211_HT_PARAM_CHA_SEC_NONE 0x00
943 #define IEEE80211_HT_PARAM_CHA_SEC_ABOVE 0x01 943 #define IEEE80211_HT_PARAM_CHA_SEC_ABOVE 0x01
944 #define IEEE80211_HT_PARAM_CHA_SEC_BELOW 0x03 944 #define IEEE80211_HT_PARAM_CHA_SEC_BELOW 0x03
945 #define IEEE80211_HT_PARAM_CHAN_WIDTH_ANY 0x04 945 #define IEEE80211_HT_PARAM_CHAN_WIDTH_ANY 0x04
946 #define IEEE80211_HT_PARAM_RIFS_MODE 0x08 946 #define IEEE80211_HT_PARAM_RIFS_MODE 0x08
947 #define IEEE80211_HT_PARAM_SPSMP_SUPPORT 0x10 947 #define IEEE80211_HT_PARAM_SPSMP_SUPPORT 0x10
948 #define IEEE80211_HT_PARAM_SERV_INTERVAL_GRAN 0xE0 948 #define IEEE80211_HT_PARAM_SERV_INTERVAL_GRAN 0xE0
949 949
950 /* for operation_mode */ 950 /* for operation_mode */
951 #define IEEE80211_HT_OP_MODE_PROTECTION 0x0003 951 #define IEEE80211_HT_OP_MODE_PROTECTION 0x0003
952 #define IEEE80211_HT_OP_MODE_PROTECTION_NONE 0 952 #define IEEE80211_HT_OP_MODE_PROTECTION_NONE 0
953 #define IEEE80211_HT_OP_MODE_PROTECTION_NONMEMBER 1 953 #define IEEE80211_HT_OP_MODE_PROTECTION_NONMEMBER 1
954 #define IEEE80211_HT_OP_MODE_PROTECTION_20MHZ 2 954 #define IEEE80211_HT_OP_MODE_PROTECTION_20MHZ 2
955 #define IEEE80211_HT_OP_MODE_PROTECTION_NONHT_MIXED 3 955 #define IEEE80211_HT_OP_MODE_PROTECTION_NONHT_MIXED 3
956 #define IEEE80211_HT_OP_MODE_NON_GF_STA_PRSNT 0x0004 956 #define IEEE80211_HT_OP_MODE_NON_GF_STA_PRSNT 0x0004
957 #define IEEE80211_HT_OP_MODE_NON_HT_STA_PRSNT 0x0010 957 #define IEEE80211_HT_OP_MODE_NON_HT_STA_PRSNT 0x0010
958 958
959 /* for stbc_param */ 959 /* for stbc_param */
960 #define IEEE80211_HT_STBC_PARAM_DUAL_BEACON 0x0040 960 #define IEEE80211_HT_STBC_PARAM_DUAL_BEACON 0x0040
961 #define IEEE80211_HT_STBC_PARAM_DUAL_CTS_PROT 0x0080 961 #define IEEE80211_HT_STBC_PARAM_DUAL_CTS_PROT 0x0080
962 #define IEEE80211_HT_STBC_PARAM_STBC_BEACON 0x0100 962 #define IEEE80211_HT_STBC_PARAM_STBC_BEACON 0x0100
963 #define IEEE80211_HT_STBC_PARAM_LSIG_TXOP_FULLPROT 0x0200 963 #define IEEE80211_HT_STBC_PARAM_LSIG_TXOP_FULLPROT 0x0200
964 #define IEEE80211_HT_STBC_PARAM_PCO_ACTIVE 0x0400 964 #define IEEE80211_HT_STBC_PARAM_PCO_ACTIVE 0x0400
965 #define IEEE80211_HT_STBC_PARAM_PCO_PHASE 0x0800 965 #define IEEE80211_HT_STBC_PARAM_PCO_PHASE 0x0800
966 966
967 967
968 /* block-ack parameters */ 968 /* block-ack parameters */
969 #define IEEE80211_ADDBA_PARAM_POLICY_MASK 0x0002 969 #define IEEE80211_ADDBA_PARAM_POLICY_MASK 0x0002
970 #define IEEE80211_ADDBA_PARAM_TID_MASK 0x003C 970 #define IEEE80211_ADDBA_PARAM_TID_MASK 0x003C
971 #define IEEE80211_ADDBA_PARAM_BUF_SIZE_MASK 0xFFC0 971 #define IEEE80211_ADDBA_PARAM_BUF_SIZE_MASK 0xFFC0
972 #define IEEE80211_DELBA_PARAM_TID_MASK 0xF000 972 #define IEEE80211_DELBA_PARAM_TID_MASK 0xF000
973 #define IEEE80211_DELBA_PARAM_INITIATOR_MASK 0x0800 973 #define IEEE80211_DELBA_PARAM_INITIATOR_MASK 0x0800
974 974
975 /* 975 /*
976 * A-PMDU buffer sizes 976 * A-PMDU buffer sizes
977 * According to IEEE802.11n spec size varies from 8K to 64K (in powers of 2) 977 * According to IEEE802.11n spec size varies from 8K to 64K (in powers of 2)
978 */ 978 */
979 #define IEEE80211_MIN_AMPDU_BUF 0x8 979 #define IEEE80211_MIN_AMPDU_BUF 0x8
980 #define IEEE80211_MAX_AMPDU_BUF 0x40 980 #define IEEE80211_MAX_AMPDU_BUF 0x40
981 981
982 982
983 /* Spatial Multiplexing Power Save Modes (for capability) */ 983 /* Spatial Multiplexing Power Save Modes (for capability) */
984 #define WLAN_HT_CAP_SM_PS_STATIC 0 984 #define WLAN_HT_CAP_SM_PS_STATIC 0
985 #define WLAN_HT_CAP_SM_PS_DYNAMIC 1 985 #define WLAN_HT_CAP_SM_PS_DYNAMIC 1
986 #define WLAN_HT_CAP_SM_PS_INVALID 2 986 #define WLAN_HT_CAP_SM_PS_INVALID 2
987 #define WLAN_HT_CAP_SM_PS_DISABLED 3 987 #define WLAN_HT_CAP_SM_PS_DISABLED 3
988 988
989 /* for SM power control field lower two bits */ 989 /* for SM power control field lower two bits */
990 #define WLAN_HT_SMPS_CONTROL_DISABLED 0 990 #define WLAN_HT_SMPS_CONTROL_DISABLED 0
991 #define WLAN_HT_SMPS_CONTROL_STATIC 1 991 #define WLAN_HT_SMPS_CONTROL_STATIC 1
992 #define WLAN_HT_SMPS_CONTROL_DYNAMIC 3 992 #define WLAN_HT_SMPS_CONTROL_DYNAMIC 3
993 993
994 /* Authentication algorithms */ 994 /* Authentication algorithms */
995 #define WLAN_AUTH_OPEN 0 995 #define WLAN_AUTH_OPEN 0
996 #define WLAN_AUTH_SHARED_KEY 1 996 #define WLAN_AUTH_SHARED_KEY 1
997 #define WLAN_AUTH_FT 2 997 #define WLAN_AUTH_FT 2
998 #define WLAN_AUTH_SAE 3 998 #define WLAN_AUTH_SAE 3
999 #define WLAN_AUTH_LEAP 128 999 #define WLAN_AUTH_LEAP 128
1000 1000
1001 #define WLAN_AUTH_CHALLENGE_LEN 128 1001 #define WLAN_AUTH_CHALLENGE_LEN 128
1002 1002
1003 #define WLAN_CAPABILITY_ESS (1<<0) 1003 #define WLAN_CAPABILITY_ESS (1<<0)
1004 #define WLAN_CAPABILITY_IBSS (1<<1) 1004 #define WLAN_CAPABILITY_IBSS (1<<1)
1005
1006 /* A mesh STA sets the ESS and IBSS capability bits to zero */
1007 #define WLAN_CAPABILITY_IS_MBSS(cap) \
1008 (!((cap) & (WLAN_CAPABILITY_ESS | WLAN_CAPABILITY_IBSS)))
1009
1005 #define WLAN_CAPABILITY_CF_POLLABLE (1<<2) 1010 #define WLAN_CAPABILITY_CF_POLLABLE (1<<2)
1006 #define WLAN_CAPABILITY_CF_POLL_REQUEST (1<<3) 1011 #define WLAN_CAPABILITY_CF_POLL_REQUEST (1<<3)
1007 #define WLAN_CAPABILITY_PRIVACY (1<<4) 1012 #define WLAN_CAPABILITY_PRIVACY (1<<4)
1008 #define WLAN_CAPABILITY_SHORT_PREAMBLE (1<<5) 1013 #define WLAN_CAPABILITY_SHORT_PREAMBLE (1<<5)
1009 #define WLAN_CAPABILITY_PBCC (1<<6) 1014 #define WLAN_CAPABILITY_PBCC (1<<6)
1010 #define WLAN_CAPABILITY_CHANNEL_AGILITY (1<<7) 1015 #define WLAN_CAPABILITY_CHANNEL_AGILITY (1<<7)
1011 1016
1012 /* 802.11h */ 1017 /* 802.11h */
1013 #define WLAN_CAPABILITY_SPECTRUM_MGMT (1<<8) 1018 #define WLAN_CAPABILITY_SPECTRUM_MGMT (1<<8)
1014 #define WLAN_CAPABILITY_QOS (1<<9) 1019 #define WLAN_CAPABILITY_QOS (1<<9)
1015 #define WLAN_CAPABILITY_SHORT_SLOT_TIME (1<<10) 1020 #define WLAN_CAPABILITY_SHORT_SLOT_TIME (1<<10)
1016 #define WLAN_CAPABILITY_DSSS_OFDM (1<<13) 1021 #define WLAN_CAPABILITY_DSSS_OFDM (1<<13)
1017 /* measurement */ 1022 /* measurement */
1018 #define IEEE80211_SPCT_MSR_RPRT_MODE_LATE (1<<0) 1023 #define IEEE80211_SPCT_MSR_RPRT_MODE_LATE (1<<0)
1019 #define IEEE80211_SPCT_MSR_RPRT_MODE_INCAPABLE (1<<1) 1024 #define IEEE80211_SPCT_MSR_RPRT_MODE_INCAPABLE (1<<1)
1020 #define IEEE80211_SPCT_MSR_RPRT_MODE_REFUSED (1<<2) 1025 #define IEEE80211_SPCT_MSR_RPRT_MODE_REFUSED (1<<2)
1021 1026
1022 #define IEEE80211_SPCT_MSR_RPRT_TYPE_BASIC 0 1027 #define IEEE80211_SPCT_MSR_RPRT_TYPE_BASIC 0
1023 #define IEEE80211_SPCT_MSR_RPRT_TYPE_CCA 1 1028 #define IEEE80211_SPCT_MSR_RPRT_TYPE_CCA 1
1024 #define IEEE80211_SPCT_MSR_RPRT_TYPE_RPI 2 1029 #define IEEE80211_SPCT_MSR_RPRT_TYPE_RPI 2
1025 1030
1026 1031
1027 /* 802.11g ERP information element */ 1032 /* 802.11g ERP information element */
1028 #define WLAN_ERP_NON_ERP_PRESENT (1<<0) 1033 #define WLAN_ERP_NON_ERP_PRESENT (1<<0)
1029 #define WLAN_ERP_USE_PROTECTION (1<<1) 1034 #define WLAN_ERP_USE_PROTECTION (1<<1)
1030 #define WLAN_ERP_BARKER_PREAMBLE (1<<2) 1035 #define WLAN_ERP_BARKER_PREAMBLE (1<<2)
1031 1036
1032 /* WLAN_ERP_BARKER_PREAMBLE values */ 1037 /* WLAN_ERP_BARKER_PREAMBLE values */
1033 enum { 1038 enum {
1034 WLAN_ERP_PREAMBLE_SHORT = 0, 1039 WLAN_ERP_PREAMBLE_SHORT = 0,
1035 WLAN_ERP_PREAMBLE_LONG = 1, 1040 WLAN_ERP_PREAMBLE_LONG = 1,
1036 }; 1041 };
1037 1042
1038 /* Status codes */ 1043 /* Status codes */
1039 enum ieee80211_statuscode { 1044 enum ieee80211_statuscode {
1040 WLAN_STATUS_SUCCESS = 0, 1045 WLAN_STATUS_SUCCESS = 0,
1041 WLAN_STATUS_UNSPECIFIED_FAILURE = 1, 1046 WLAN_STATUS_UNSPECIFIED_FAILURE = 1,
1042 WLAN_STATUS_CAPS_UNSUPPORTED = 10, 1047 WLAN_STATUS_CAPS_UNSUPPORTED = 10,
1043 WLAN_STATUS_REASSOC_NO_ASSOC = 11, 1048 WLAN_STATUS_REASSOC_NO_ASSOC = 11,
1044 WLAN_STATUS_ASSOC_DENIED_UNSPEC = 12, 1049 WLAN_STATUS_ASSOC_DENIED_UNSPEC = 12,
1045 WLAN_STATUS_NOT_SUPPORTED_AUTH_ALG = 13, 1050 WLAN_STATUS_NOT_SUPPORTED_AUTH_ALG = 13,
1046 WLAN_STATUS_UNKNOWN_AUTH_TRANSACTION = 14, 1051 WLAN_STATUS_UNKNOWN_AUTH_TRANSACTION = 14,
1047 WLAN_STATUS_CHALLENGE_FAIL = 15, 1052 WLAN_STATUS_CHALLENGE_FAIL = 15,
1048 WLAN_STATUS_AUTH_TIMEOUT = 16, 1053 WLAN_STATUS_AUTH_TIMEOUT = 16,
1049 WLAN_STATUS_AP_UNABLE_TO_HANDLE_NEW_STA = 17, 1054 WLAN_STATUS_AP_UNABLE_TO_HANDLE_NEW_STA = 17,
1050 WLAN_STATUS_ASSOC_DENIED_RATES = 18, 1055 WLAN_STATUS_ASSOC_DENIED_RATES = 18,
1051 /* 802.11b */ 1056 /* 802.11b */
1052 WLAN_STATUS_ASSOC_DENIED_NOSHORTPREAMBLE = 19, 1057 WLAN_STATUS_ASSOC_DENIED_NOSHORTPREAMBLE = 19,
1053 WLAN_STATUS_ASSOC_DENIED_NOPBCC = 20, 1058 WLAN_STATUS_ASSOC_DENIED_NOPBCC = 20,
1054 WLAN_STATUS_ASSOC_DENIED_NOAGILITY = 21, 1059 WLAN_STATUS_ASSOC_DENIED_NOAGILITY = 21,
1055 /* 802.11h */ 1060 /* 802.11h */
1056 WLAN_STATUS_ASSOC_DENIED_NOSPECTRUM = 22, 1061 WLAN_STATUS_ASSOC_DENIED_NOSPECTRUM = 22,
1057 WLAN_STATUS_ASSOC_REJECTED_BAD_POWER = 23, 1062 WLAN_STATUS_ASSOC_REJECTED_BAD_POWER = 23,
1058 WLAN_STATUS_ASSOC_REJECTED_BAD_SUPP_CHAN = 24, 1063 WLAN_STATUS_ASSOC_REJECTED_BAD_SUPP_CHAN = 24,
1059 /* 802.11g */ 1064 /* 802.11g */
1060 WLAN_STATUS_ASSOC_DENIED_NOSHORTTIME = 25, 1065 WLAN_STATUS_ASSOC_DENIED_NOSHORTTIME = 25,
1061 WLAN_STATUS_ASSOC_DENIED_NODSSSOFDM = 26, 1066 WLAN_STATUS_ASSOC_DENIED_NODSSSOFDM = 26,
1062 /* 802.11w */ 1067 /* 802.11w */
1063 WLAN_STATUS_ASSOC_REJECTED_TEMPORARILY = 30, 1068 WLAN_STATUS_ASSOC_REJECTED_TEMPORARILY = 30,
1064 WLAN_STATUS_ROBUST_MGMT_FRAME_POLICY_VIOLATION = 31, 1069 WLAN_STATUS_ROBUST_MGMT_FRAME_POLICY_VIOLATION = 31,
1065 /* 802.11i */ 1070 /* 802.11i */
1066 WLAN_STATUS_INVALID_IE = 40, 1071 WLAN_STATUS_INVALID_IE = 40,
1067 WLAN_STATUS_INVALID_GROUP_CIPHER = 41, 1072 WLAN_STATUS_INVALID_GROUP_CIPHER = 41,
1068 WLAN_STATUS_INVALID_PAIRWISE_CIPHER = 42, 1073 WLAN_STATUS_INVALID_PAIRWISE_CIPHER = 42,
1069 WLAN_STATUS_INVALID_AKMP = 43, 1074 WLAN_STATUS_INVALID_AKMP = 43,
1070 WLAN_STATUS_UNSUPP_RSN_VERSION = 44, 1075 WLAN_STATUS_UNSUPP_RSN_VERSION = 44,
1071 WLAN_STATUS_INVALID_RSN_IE_CAP = 45, 1076 WLAN_STATUS_INVALID_RSN_IE_CAP = 45,
1072 WLAN_STATUS_CIPHER_SUITE_REJECTED = 46, 1077 WLAN_STATUS_CIPHER_SUITE_REJECTED = 46,
1073 /* 802.11e */ 1078 /* 802.11e */
1074 WLAN_STATUS_UNSPECIFIED_QOS = 32, 1079 WLAN_STATUS_UNSPECIFIED_QOS = 32,
1075 WLAN_STATUS_ASSOC_DENIED_NOBANDWIDTH = 33, 1080 WLAN_STATUS_ASSOC_DENIED_NOBANDWIDTH = 33,
1076 WLAN_STATUS_ASSOC_DENIED_LOWACK = 34, 1081 WLAN_STATUS_ASSOC_DENIED_LOWACK = 34,
1077 WLAN_STATUS_ASSOC_DENIED_UNSUPP_QOS = 35, 1082 WLAN_STATUS_ASSOC_DENIED_UNSUPP_QOS = 35,
1078 WLAN_STATUS_REQUEST_DECLINED = 37, 1083 WLAN_STATUS_REQUEST_DECLINED = 37,
1079 WLAN_STATUS_INVALID_QOS_PARAM = 38, 1084 WLAN_STATUS_INVALID_QOS_PARAM = 38,
1080 WLAN_STATUS_CHANGE_TSPEC = 39, 1085 WLAN_STATUS_CHANGE_TSPEC = 39,
1081 WLAN_STATUS_WAIT_TS_DELAY = 47, 1086 WLAN_STATUS_WAIT_TS_DELAY = 47,
1082 WLAN_STATUS_NO_DIRECT_LINK = 48, 1087 WLAN_STATUS_NO_DIRECT_LINK = 48,
1083 WLAN_STATUS_STA_NOT_PRESENT = 49, 1088 WLAN_STATUS_STA_NOT_PRESENT = 49,
1084 WLAN_STATUS_STA_NOT_QSTA = 50, 1089 WLAN_STATUS_STA_NOT_QSTA = 50,
1085 /* 802.11s */ 1090 /* 802.11s */
1086 WLAN_STATUS_ANTI_CLOG_REQUIRED = 76, 1091 WLAN_STATUS_ANTI_CLOG_REQUIRED = 76,
1087 WLAN_STATUS_FCG_NOT_SUPP = 78, 1092 WLAN_STATUS_FCG_NOT_SUPP = 78,
1088 WLAN_STATUS_STA_NO_TBTT = 78, 1093 WLAN_STATUS_STA_NO_TBTT = 78,
1089 }; 1094 };
1090 1095
1091 1096
1092 /* Reason codes */ 1097 /* Reason codes */
1093 enum ieee80211_reasoncode { 1098 enum ieee80211_reasoncode {
1094 WLAN_REASON_UNSPECIFIED = 1, 1099 WLAN_REASON_UNSPECIFIED = 1,
1095 WLAN_REASON_PREV_AUTH_NOT_VALID = 2, 1100 WLAN_REASON_PREV_AUTH_NOT_VALID = 2,
1096 WLAN_REASON_DEAUTH_LEAVING = 3, 1101 WLAN_REASON_DEAUTH_LEAVING = 3,
1097 WLAN_REASON_DISASSOC_DUE_TO_INACTIVITY = 4, 1102 WLAN_REASON_DISASSOC_DUE_TO_INACTIVITY = 4,
1098 WLAN_REASON_DISASSOC_AP_BUSY = 5, 1103 WLAN_REASON_DISASSOC_AP_BUSY = 5,
1099 WLAN_REASON_CLASS2_FRAME_FROM_NONAUTH_STA = 6, 1104 WLAN_REASON_CLASS2_FRAME_FROM_NONAUTH_STA = 6,
1100 WLAN_REASON_CLASS3_FRAME_FROM_NONASSOC_STA = 7, 1105 WLAN_REASON_CLASS3_FRAME_FROM_NONASSOC_STA = 7,
1101 WLAN_REASON_DISASSOC_STA_HAS_LEFT = 8, 1106 WLAN_REASON_DISASSOC_STA_HAS_LEFT = 8,
1102 WLAN_REASON_STA_REQ_ASSOC_WITHOUT_AUTH = 9, 1107 WLAN_REASON_STA_REQ_ASSOC_WITHOUT_AUTH = 9,
1103 /* 802.11h */ 1108 /* 802.11h */
1104 WLAN_REASON_DISASSOC_BAD_POWER = 10, 1109 WLAN_REASON_DISASSOC_BAD_POWER = 10,
1105 WLAN_REASON_DISASSOC_BAD_SUPP_CHAN = 11, 1110 WLAN_REASON_DISASSOC_BAD_SUPP_CHAN = 11,
1106 /* 802.11i */ 1111 /* 802.11i */
1107 WLAN_REASON_INVALID_IE = 13, 1112 WLAN_REASON_INVALID_IE = 13,
1108 WLAN_REASON_MIC_FAILURE = 14, 1113 WLAN_REASON_MIC_FAILURE = 14,
1109 WLAN_REASON_4WAY_HANDSHAKE_TIMEOUT = 15, 1114 WLAN_REASON_4WAY_HANDSHAKE_TIMEOUT = 15,
1110 WLAN_REASON_GROUP_KEY_HANDSHAKE_TIMEOUT = 16, 1115 WLAN_REASON_GROUP_KEY_HANDSHAKE_TIMEOUT = 16,
1111 WLAN_REASON_IE_DIFFERENT = 17, 1116 WLAN_REASON_IE_DIFFERENT = 17,
1112 WLAN_REASON_INVALID_GROUP_CIPHER = 18, 1117 WLAN_REASON_INVALID_GROUP_CIPHER = 18,
1113 WLAN_REASON_INVALID_PAIRWISE_CIPHER = 19, 1118 WLAN_REASON_INVALID_PAIRWISE_CIPHER = 19,
1114 WLAN_REASON_INVALID_AKMP = 20, 1119 WLAN_REASON_INVALID_AKMP = 20,
1115 WLAN_REASON_UNSUPP_RSN_VERSION = 21, 1120 WLAN_REASON_UNSUPP_RSN_VERSION = 21,
1116 WLAN_REASON_INVALID_RSN_IE_CAP = 22, 1121 WLAN_REASON_INVALID_RSN_IE_CAP = 22,
1117 WLAN_REASON_IEEE8021X_FAILED = 23, 1122 WLAN_REASON_IEEE8021X_FAILED = 23,
1118 WLAN_REASON_CIPHER_SUITE_REJECTED = 24, 1123 WLAN_REASON_CIPHER_SUITE_REJECTED = 24,
1119 /* 802.11e */ 1124 /* 802.11e */
1120 WLAN_REASON_DISASSOC_UNSPECIFIED_QOS = 32, 1125 WLAN_REASON_DISASSOC_UNSPECIFIED_QOS = 32,
1121 WLAN_REASON_DISASSOC_QAP_NO_BANDWIDTH = 33, 1126 WLAN_REASON_DISASSOC_QAP_NO_BANDWIDTH = 33,
1122 WLAN_REASON_DISASSOC_LOW_ACK = 34, 1127 WLAN_REASON_DISASSOC_LOW_ACK = 34,
1123 WLAN_REASON_DISASSOC_QAP_EXCEED_TXOP = 35, 1128 WLAN_REASON_DISASSOC_QAP_EXCEED_TXOP = 35,
1124 WLAN_REASON_QSTA_LEAVE_QBSS = 36, 1129 WLAN_REASON_QSTA_LEAVE_QBSS = 36,
1125 WLAN_REASON_QSTA_NOT_USE = 37, 1130 WLAN_REASON_QSTA_NOT_USE = 37,
1126 WLAN_REASON_QSTA_REQUIRE_SETUP = 38, 1131 WLAN_REASON_QSTA_REQUIRE_SETUP = 38,
1127 WLAN_REASON_QSTA_TIMEOUT = 39, 1132 WLAN_REASON_QSTA_TIMEOUT = 39,
1128 WLAN_REASON_QSTA_CIPHER_NOT_SUPP = 45, 1133 WLAN_REASON_QSTA_CIPHER_NOT_SUPP = 45,
1129 /* 802.11s */ 1134 /* 802.11s */
1130 WLAN_REASON_MESH_PEER_CANCELED = 52, 1135 WLAN_REASON_MESH_PEER_CANCELED = 52,
1131 WLAN_REASON_MESH_MAX_PEERS = 53, 1136 WLAN_REASON_MESH_MAX_PEERS = 53,
1132 WLAN_REASON_MESH_CONFIG = 54, 1137 WLAN_REASON_MESH_CONFIG = 54,
1133 WLAN_REASON_MESH_CLOSE = 55, 1138 WLAN_REASON_MESH_CLOSE = 55,
1134 WLAN_REASON_MESH_MAX_RETRIES = 56, 1139 WLAN_REASON_MESH_MAX_RETRIES = 56,
1135 WLAN_REASON_MESH_CONFIRM_TIMEOUT = 57, 1140 WLAN_REASON_MESH_CONFIRM_TIMEOUT = 57,
1136 WLAN_REASON_MESH_INVALID_GTK = 58, 1141 WLAN_REASON_MESH_INVALID_GTK = 58,
1137 WLAN_REASON_MESH_INCONSISTENT_PARAM = 59, 1142 WLAN_REASON_MESH_INCONSISTENT_PARAM = 59,
1138 WLAN_REASON_MESH_INVALID_SECURITY = 60, 1143 WLAN_REASON_MESH_INVALID_SECURITY = 60,
1139 WLAN_REASON_MESH_PATH_ERROR = 61, 1144 WLAN_REASON_MESH_PATH_ERROR = 61,
1140 WLAN_REASON_MESH_PATH_NOFORWARD = 62, 1145 WLAN_REASON_MESH_PATH_NOFORWARD = 62,
1141 WLAN_REASON_MESH_PATH_DEST_UNREACHABLE = 63, 1146 WLAN_REASON_MESH_PATH_DEST_UNREACHABLE = 63,
1142 WLAN_REASON_MAC_EXISTS_IN_MBSS = 64, 1147 WLAN_REASON_MAC_EXISTS_IN_MBSS = 64,
1143 WLAN_REASON_MESH_CHAN_REGULATORY = 65, 1148 WLAN_REASON_MESH_CHAN_REGULATORY = 65,
1144 WLAN_REASON_MESH_CHAN = 66, 1149 WLAN_REASON_MESH_CHAN = 66,
1145 }; 1150 };
1146 1151
1147 1152
1148 /* Information Element IDs */ 1153 /* Information Element IDs */
1149 enum ieee80211_eid { 1154 enum ieee80211_eid {
1150 WLAN_EID_SSID = 0, 1155 WLAN_EID_SSID = 0,
1151 WLAN_EID_SUPP_RATES = 1, 1156 WLAN_EID_SUPP_RATES = 1,
1152 WLAN_EID_FH_PARAMS = 2, 1157 WLAN_EID_FH_PARAMS = 2,
1153 WLAN_EID_DS_PARAMS = 3, 1158 WLAN_EID_DS_PARAMS = 3,
1154 WLAN_EID_CF_PARAMS = 4, 1159 WLAN_EID_CF_PARAMS = 4,
1155 WLAN_EID_TIM = 5, 1160 WLAN_EID_TIM = 5,
1156 WLAN_EID_IBSS_PARAMS = 6, 1161 WLAN_EID_IBSS_PARAMS = 6,
1157 WLAN_EID_CHALLENGE = 16, 1162 WLAN_EID_CHALLENGE = 16,
1158 1163
1159 WLAN_EID_COUNTRY = 7, 1164 WLAN_EID_COUNTRY = 7,
1160 WLAN_EID_HP_PARAMS = 8, 1165 WLAN_EID_HP_PARAMS = 8,
1161 WLAN_EID_HP_TABLE = 9, 1166 WLAN_EID_HP_TABLE = 9,
1162 WLAN_EID_REQUEST = 10, 1167 WLAN_EID_REQUEST = 10,
1163 1168
1164 WLAN_EID_QBSS_LOAD = 11, 1169 WLAN_EID_QBSS_LOAD = 11,
1165 WLAN_EID_EDCA_PARAM_SET = 12, 1170 WLAN_EID_EDCA_PARAM_SET = 12,
1166 WLAN_EID_TSPEC = 13, 1171 WLAN_EID_TSPEC = 13,
1167 WLAN_EID_TCLAS = 14, 1172 WLAN_EID_TCLAS = 14,
1168 WLAN_EID_SCHEDULE = 15, 1173 WLAN_EID_SCHEDULE = 15,
1169 WLAN_EID_TS_DELAY = 43, 1174 WLAN_EID_TS_DELAY = 43,
1170 WLAN_EID_TCLAS_PROCESSING = 44, 1175 WLAN_EID_TCLAS_PROCESSING = 44,
1171 WLAN_EID_QOS_CAPA = 46, 1176 WLAN_EID_QOS_CAPA = 46,
1172 /* 802.11s */ 1177 /* 802.11s */
1173 WLAN_EID_MESH_CONFIG = 113, 1178 WLAN_EID_MESH_CONFIG = 113,
1174 WLAN_EID_MESH_ID = 114, 1179 WLAN_EID_MESH_ID = 114,
1175 WLAN_EID_LINK_METRIC_REPORT = 115, 1180 WLAN_EID_LINK_METRIC_REPORT = 115,
1176 WLAN_EID_CONGESTION_NOTIFICATION = 116, 1181 WLAN_EID_CONGESTION_NOTIFICATION = 116,
1177 /* Note that the Peer Link IE has been replaced with the similar 1182 /* Note that the Peer Link IE has been replaced with the similar
1178 * Peer Management IE. We will keep the former definition until mesh 1183 * Peer Management IE. We will keep the former definition until mesh
1179 * code is changed to comply with latest 802.11s drafts. 1184 * code is changed to comply with latest 802.11s drafts.
1180 */ 1185 */
1181 WLAN_EID_PEER_LINK = 55, /* no longer in 802.11s drafts */ 1186 WLAN_EID_PEER_LINK = 55, /* no longer in 802.11s drafts */
1182 WLAN_EID_PEER_MGMT = 117, 1187 WLAN_EID_PEER_MGMT = 117,
1183 WLAN_EID_CHAN_SWITCH_PARAM = 118, 1188 WLAN_EID_CHAN_SWITCH_PARAM = 118,
1184 WLAN_EID_MESH_AWAKE_WINDOW = 119, 1189 WLAN_EID_MESH_AWAKE_WINDOW = 119,
1185 WLAN_EID_BEACON_TIMING = 120, 1190 WLAN_EID_BEACON_TIMING = 120,
1186 WLAN_EID_MCCAOP_SETUP_REQ = 121, 1191 WLAN_EID_MCCAOP_SETUP_REQ = 121,
1187 WLAN_EID_MCCAOP_SETUP_RESP = 122, 1192 WLAN_EID_MCCAOP_SETUP_RESP = 122,
1188 WLAN_EID_MCCAOP_ADVERT = 123, 1193 WLAN_EID_MCCAOP_ADVERT = 123,
1189 WLAN_EID_MCCAOP_TEARDOWN = 124, 1194 WLAN_EID_MCCAOP_TEARDOWN = 124,
1190 WLAN_EID_GANN = 125, 1195 WLAN_EID_GANN = 125,
1191 WLAN_EID_RANN = 126, 1196 WLAN_EID_RANN = 126,
1192 WLAN_EID_PREQ = 130, 1197 WLAN_EID_PREQ = 130,
1193 WLAN_EID_PREP = 131, 1198 WLAN_EID_PREP = 131,
1194 WLAN_EID_PERR = 132, 1199 WLAN_EID_PERR = 132,
1195 WLAN_EID_PXU = 137, 1200 WLAN_EID_PXU = 137,
1196 WLAN_EID_PXUC = 138, 1201 WLAN_EID_PXUC = 138,
1197 WLAN_EID_AUTH_MESH_PEER_EXCH = 139, 1202 WLAN_EID_AUTH_MESH_PEER_EXCH = 139,
1198 WLAN_EID_MIC = 140, 1203 WLAN_EID_MIC = 140,
1199 1204
1200 WLAN_EID_PWR_CONSTRAINT = 32, 1205 WLAN_EID_PWR_CONSTRAINT = 32,
1201 WLAN_EID_PWR_CAPABILITY = 33, 1206 WLAN_EID_PWR_CAPABILITY = 33,
1202 WLAN_EID_TPC_REQUEST = 34, 1207 WLAN_EID_TPC_REQUEST = 34,
1203 WLAN_EID_TPC_REPORT = 35, 1208 WLAN_EID_TPC_REPORT = 35,
1204 WLAN_EID_SUPPORTED_CHANNELS = 36, 1209 WLAN_EID_SUPPORTED_CHANNELS = 36,
1205 WLAN_EID_CHANNEL_SWITCH = 37, 1210 WLAN_EID_CHANNEL_SWITCH = 37,
1206 WLAN_EID_MEASURE_REQUEST = 38, 1211 WLAN_EID_MEASURE_REQUEST = 38,
1207 WLAN_EID_MEASURE_REPORT = 39, 1212 WLAN_EID_MEASURE_REPORT = 39,
1208 WLAN_EID_QUIET = 40, 1213 WLAN_EID_QUIET = 40,
1209 WLAN_EID_IBSS_DFS = 41, 1214 WLAN_EID_IBSS_DFS = 41,
1210 1215
1211 WLAN_EID_ERP_INFO = 42, 1216 WLAN_EID_ERP_INFO = 42,
1212 WLAN_EID_EXT_SUPP_RATES = 50, 1217 WLAN_EID_EXT_SUPP_RATES = 50,
1213 1218
1214 WLAN_EID_HT_CAPABILITY = 45, 1219 WLAN_EID_HT_CAPABILITY = 45,
1215 WLAN_EID_HT_INFORMATION = 61, 1220 WLAN_EID_HT_INFORMATION = 61,
1216 1221
1217 WLAN_EID_RSN = 48, 1222 WLAN_EID_RSN = 48,
1218 WLAN_EID_MMIE = 76, 1223 WLAN_EID_MMIE = 76,
1219 WLAN_EID_WPA = 221, 1224 WLAN_EID_WPA = 221,
1220 WLAN_EID_GENERIC = 221, 1225 WLAN_EID_GENERIC = 221,
1221 WLAN_EID_VENDOR_SPECIFIC = 221, 1226 WLAN_EID_VENDOR_SPECIFIC = 221,
1222 WLAN_EID_QOS_PARAMETER = 222, 1227 WLAN_EID_QOS_PARAMETER = 222,
1223 1228
1224 WLAN_EID_AP_CHAN_REPORT = 51, 1229 WLAN_EID_AP_CHAN_REPORT = 51,
1225 WLAN_EID_NEIGHBOR_REPORT = 52, 1230 WLAN_EID_NEIGHBOR_REPORT = 52,
1226 WLAN_EID_RCPI = 53, 1231 WLAN_EID_RCPI = 53,
1227 WLAN_EID_BSS_AVG_ACCESS_DELAY = 63, 1232 WLAN_EID_BSS_AVG_ACCESS_DELAY = 63,
1228 WLAN_EID_ANTENNA_INFO = 64, 1233 WLAN_EID_ANTENNA_INFO = 64,
1229 WLAN_EID_RSNI = 65, 1234 WLAN_EID_RSNI = 65,
1230 WLAN_EID_MEASUREMENT_PILOT_TX_INFO = 66, 1235 WLAN_EID_MEASUREMENT_PILOT_TX_INFO = 66,
1231 WLAN_EID_BSS_AVAILABLE_CAPACITY = 67, 1236 WLAN_EID_BSS_AVAILABLE_CAPACITY = 67,
1232 WLAN_EID_BSS_AC_ACCESS_DELAY = 68, 1237 WLAN_EID_BSS_AC_ACCESS_DELAY = 68,
1233 WLAN_EID_RRM_ENABLED_CAPABILITIES = 70, 1238 WLAN_EID_RRM_ENABLED_CAPABILITIES = 70,
1234 WLAN_EID_MULTIPLE_BSSID = 71, 1239 WLAN_EID_MULTIPLE_BSSID = 71,
1235 WLAN_EID_BSS_COEX_2040 = 72, 1240 WLAN_EID_BSS_COEX_2040 = 72,
1236 WLAN_EID_OVERLAP_BSS_SCAN_PARAM = 74, 1241 WLAN_EID_OVERLAP_BSS_SCAN_PARAM = 74,
1237 WLAN_EID_EXT_CAPABILITY = 127, 1242 WLAN_EID_EXT_CAPABILITY = 127,
1238 1243
1239 WLAN_EID_MOBILITY_DOMAIN = 54, 1244 WLAN_EID_MOBILITY_DOMAIN = 54,
1240 WLAN_EID_FAST_BSS_TRANSITION = 55, 1245 WLAN_EID_FAST_BSS_TRANSITION = 55,
1241 WLAN_EID_TIMEOUT_INTERVAL = 56, 1246 WLAN_EID_TIMEOUT_INTERVAL = 56,
1242 WLAN_EID_RIC_DATA = 57, 1247 WLAN_EID_RIC_DATA = 57,
1243 WLAN_EID_RIC_DESCRIPTOR = 75, 1248 WLAN_EID_RIC_DESCRIPTOR = 75,
1244 1249
1245 WLAN_EID_DSE_REGISTERED_LOCATION = 58, 1250 WLAN_EID_DSE_REGISTERED_LOCATION = 58,
1246 WLAN_EID_SUPPORTED_REGULATORY_CLASSES = 59, 1251 WLAN_EID_SUPPORTED_REGULATORY_CLASSES = 59,
1247 WLAN_EID_EXT_CHANSWITCH_ANN = 60, 1252 WLAN_EID_EXT_CHANSWITCH_ANN = 60,
1248 }; 1253 };
1249 1254
1250 /* Action category code */ 1255 /* Action category code */
1251 enum ieee80211_category { 1256 enum ieee80211_category {
1252 WLAN_CATEGORY_SPECTRUM_MGMT = 0, 1257 WLAN_CATEGORY_SPECTRUM_MGMT = 0,
1253 WLAN_CATEGORY_QOS = 1, 1258 WLAN_CATEGORY_QOS = 1,
1254 WLAN_CATEGORY_DLS = 2, 1259 WLAN_CATEGORY_DLS = 2,
1255 WLAN_CATEGORY_BACK = 3, 1260 WLAN_CATEGORY_BACK = 3,
1256 WLAN_CATEGORY_PUBLIC = 4, 1261 WLAN_CATEGORY_PUBLIC = 4,
1257 WLAN_CATEGORY_HT = 7, 1262 WLAN_CATEGORY_HT = 7,
1258 WLAN_CATEGORY_SA_QUERY = 8, 1263 WLAN_CATEGORY_SA_QUERY = 8,
1259 WLAN_CATEGORY_PROTECTED_DUAL_OF_ACTION = 9, 1264 WLAN_CATEGORY_PROTECTED_DUAL_OF_ACTION = 9,
1260 WLAN_CATEGORY_MESH_ACTION = 13, 1265 WLAN_CATEGORY_MESH_ACTION = 13,
1261 WLAN_CATEGORY_MULTIHOP_ACTION = 14, 1266 WLAN_CATEGORY_MULTIHOP_ACTION = 14,
1262 WLAN_CATEGORY_SELF_PROTECTED = 15, 1267 WLAN_CATEGORY_SELF_PROTECTED = 15,
1263 WLAN_CATEGORY_WMM = 17, 1268 WLAN_CATEGORY_WMM = 17,
1264 /* TODO: remove MESH_PATH_SEL after mesh is updated 1269 /* TODO: remove MESH_PATH_SEL after mesh is updated
1265 * to current 802.11s draft */ 1270 * to current 802.11s draft */
1266 WLAN_CATEGORY_MESH_PATH_SEL = 32, 1271 WLAN_CATEGORY_MESH_PATH_SEL = 32,
1267 WLAN_CATEGORY_VENDOR_SPECIFIC_PROTECTED = 126, 1272 WLAN_CATEGORY_VENDOR_SPECIFIC_PROTECTED = 126,
1268 WLAN_CATEGORY_VENDOR_SPECIFIC = 127, 1273 WLAN_CATEGORY_VENDOR_SPECIFIC = 127,
1269 }; 1274 };
1270 1275
1271 /* SPECTRUM_MGMT action code */ 1276 /* SPECTRUM_MGMT action code */
1272 enum ieee80211_spectrum_mgmt_actioncode { 1277 enum ieee80211_spectrum_mgmt_actioncode {
1273 WLAN_ACTION_SPCT_MSR_REQ = 0, 1278 WLAN_ACTION_SPCT_MSR_REQ = 0,
1274 WLAN_ACTION_SPCT_MSR_RPRT = 1, 1279 WLAN_ACTION_SPCT_MSR_RPRT = 1,
1275 WLAN_ACTION_SPCT_TPC_REQ = 2, 1280 WLAN_ACTION_SPCT_TPC_REQ = 2,
1276 WLAN_ACTION_SPCT_TPC_RPRT = 3, 1281 WLAN_ACTION_SPCT_TPC_RPRT = 3,
1277 WLAN_ACTION_SPCT_CHL_SWITCH = 4, 1282 WLAN_ACTION_SPCT_CHL_SWITCH = 4,
1278 }; 1283 };
1279 1284
1280 /* HT action codes */ 1285 /* HT action codes */
1281 enum ieee80211_ht_actioncode { 1286 enum ieee80211_ht_actioncode {
1282 WLAN_HT_ACTION_NOTIFY_CHANWIDTH = 0, 1287 WLAN_HT_ACTION_NOTIFY_CHANWIDTH = 0,
1283 WLAN_HT_ACTION_SMPS = 1, 1288 WLAN_HT_ACTION_SMPS = 1,
1284 WLAN_HT_ACTION_PSMP = 2, 1289 WLAN_HT_ACTION_PSMP = 2,
1285 WLAN_HT_ACTION_PCO_PHASE = 3, 1290 WLAN_HT_ACTION_PCO_PHASE = 3,
1286 WLAN_HT_ACTION_CSI = 4, 1291 WLAN_HT_ACTION_CSI = 4,
1287 WLAN_HT_ACTION_NONCOMPRESSED_BF = 5, 1292 WLAN_HT_ACTION_NONCOMPRESSED_BF = 5,
1288 WLAN_HT_ACTION_COMPRESSED_BF = 6, 1293 WLAN_HT_ACTION_COMPRESSED_BF = 6,
1289 WLAN_HT_ACTION_ASEL_IDX_FEEDBACK = 7, 1294 WLAN_HT_ACTION_ASEL_IDX_FEEDBACK = 7,
1290 }; 1295 };
1291 1296
1292 /* Security key length */ 1297 /* Security key length */
1293 enum ieee80211_key_len { 1298 enum ieee80211_key_len {
1294 WLAN_KEY_LEN_WEP40 = 5, 1299 WLAN_KEY_LEN_WEP40 = 5,
1295 WLAN_KEY_LEN_WEP104 = 13, 1300 WLAN_KEY_LEN_WEP104 = 13,
1296 WLAN_KEY_LEN_CCMP = 16, 1301 WLAN_KEY_LEN_CCMP = 16,
1297 WLAN_KEY_LEN_TKIP = 32, 1302 WLAN_KEY_LEN_TKIP = 32,
1298 WLAN_KEY_LEN_AES_CMAC = 16, 1303 WLAN_KEY_LEN_AES_CMAC = 16,
1299 }; 1304 };
1300 1305
1301 /** 1306 /**
1302 * enum - mesh path selection protocol identifier 1307 * enum - mesh path selection protocol identifier
1303 * 1308 *
1304 * @IEEE80211_PATH_PROTOCOL_HWMP: the default path selection protocol 1309 * @IEEE80211_PATH_PROTOCOL_HWMP: the default path selection protocol
1305 * @IEEE80211_PATH_PROTOCOL_VENDOR: a vendor specific protocol that will 1310 * @IEEE80211_PATH_PROTOCOL_VENDOR: a vendor specific protocol that will
1306 * be specified in a vendor specific information element 1311 * be specified in a vendor specific information element
1307 */ 1312 */
1308 enum { 1313 enum {
1309 IEEE80211_PATH_PROTOCOL_HWMP = 0, 1314 IEEE80211_PATH_PROTOCOL_HWMP = 0,
1310 IEEE80211_PATH_PROTOCOL_VENDOR = 255, 1315 IEEE80211_PATH_PROTOCOL_VENDOR = 255,
1311 }; 1316 };
1312 1317
1313 /** 1318 /**
1314 * enum - mesh path selection metric identifier 1319 * enum - mesh path selection metric identifier
1315 * 1320 *
1316 * @IEEE80211_PATH_METRIC_AIRTIME: the default path selection metric 1321 * @IEEE80211_PATH_METRIC_AIRTIME: the default path selection metric
1317 * @IEEE80211_PATH_METRIC_VENDOR: a vendor specific metric that will be 1322 * @IEEE80211_PATH_METRIC_VENDOR: a vendor specific metric that will be
1318 * specified in a vendor specific information element 1323 * specified in a vendor specific information element
1319 */ 1324 */
1320 enum { 1325 enum {
1321 IEEE80211_PATH_METRIC_AIRTIME = 0, 1326 IEEE80211_PATH_METRIC_AIRTIME = 0,
1322 IEEE80211_PATH_METRIC_VENDOR = 255, 1327 IEEE80211_PATH_METRIC_VENDOR = 255,
1323 }; 1328 };
1324 1329
1325 1330
1326 /* 1331 /*
1327 * IEEE 802.11-2007 7.3.2.9 Country information element 1332 * IEEE 802.11-2007 7.3.2.9 Country information element
1328 * 1333 *
1329 * Minimum length is 8 octets, ie len must be evenly 1334 * Minimum length is 8 octets, ie len must be evenly
1330 * divisible by 2 1335 * divisible by 2
1331 */ 1336 */
1332 1337
1333 /* Although the spec says 8 I'm seeing 6 in practice */ 1338 /* Although the spec says 8 I'm seeing 6 in practice */
1334 #define IEEE80211_COUNTRY_IE_MIN_LEN 6 1339 #define IEEE80211_COUNTRY_IE_MIN_LEN 6
1335 1340
1336 /* The Country String field of the element shall be 3 octets in length */ 1341 /* The Country String field of the element shall be 3 octets in length */
1337 #define IEEE80211_COUNTRY_STRING_LEN 3 1342 #define IEEE80211_COUNTRY_STRING_LEN 3
1338 1343
1339 /* 1344 /*
1340 * For regulatory extension stuff see IEEE 802.11-2007 1345 * For regulatory extension stuff see IEEE 802.11-2007
1341 * Annex I (page 1141) and Annex J (page 1147). Also 1346 * Annex I (page 1141) and Annex J (page 1147). Also
1342 * review 7.3.2.9. 1347 * review 7.3.2.9.
1343 * 1348 *
1344 * When dot11RegulatoryClassesRequired is true and the 1349 * When dot11RegulatoryClassesRequired is true and the
1345 * first_channel/reg_extension_id is >= 201 then the IE 1350 * first_channel/reg_extension_id is >= 201 then the IE
1346 * compromises of the 'ext' struct represented below: 1351 * compromises of the 'ext' struct represented below:
1347 * 1352 *
1348 * - Regulatory extension ID - when generating IE this just needs 1353 * - Regulatory extension ID - when generating IE this just needs
1349 * to be monotonically increasing for each triplet passed in 1354 * to be monotonically increasing for each triplet passed in
1350 * the IE 1355 * the IE
1351 * - Regulatory class - index into set of rules 1356 * - Regulatory class - index into set of rules
1352 * - Coverage class - index into air propagation time (Table 7-27), 1357 * - Coverage class - index into air propagation time (Table 7-27),
1353 * in microseconds, you can compute the air propagation time from 1358 * in microseconds, you can compute the air propagation time from
1354 * the index by multiplying by 3, so index 10 yields a propagation 1359 * the index by multiplying by 3, so index 10 yields a propagation
1355 * of 10 us. Valid values are 0-31, values 32-255 are not defined 1360 * of 10 us. Valid values are 0-31, values 32-255 are not defined
1356 * yet. A value of 0 inicates air propagation of <= 1 us. 1361 * yet. A value of 0 inicates air propagation of <= 1 us.
1357 * 1362 *
1358 * See also Table I.2 for Emission limit sets and table 1363 * See also Table I.2 for Emission limit sets and table
1359 * I.3 for Behavior limit sets. Table J.1 indicates how to map 1364 * I.3 for Behavior limit sets. Table J.1 indicates how to map
1360 * a reg_class to an emission limit set and behavior limit set. 1365 * a reg_class to an emission limit set and behavior limit set.
1361 */ 1366 */
1362 #define IEEE80211_COUNTRY_EXTENSION_ID 201 1367 #define IEEE80211_COUNTRY_EXTENSION_ID 201
1363 1368
1364 /* 1369 /*
1365 * Channels numbers in the IE must be monotonically increasing 1370 * Channels numbers in the IE must be monotonically increasing
1366 * if dot11RegulatoryClassesRequired is not true. 1371 * if dot11RegulatoryClassesRequired is not true.
1367 * 1372 *
1368 * If dot11RegulatoryClassesRequired is true consecutive 1373 * If dot11RegulatoryClassesRequired is true consecutive
1369 * subband triplets following a regulatory triplet shall 1374 * subband triplets following a regulatory triplet shall
1370 * have monotonically increasing first_channel number fields. 1375 * have monotonically increasing first_channel number fields.
1371 * 1376 *
1372 * Channel numbers shall not overlap. 1377 * Channel numbers shall not overlap.
1373 * 1378 *
1374 * Note that max_power is signed. 1379 * Note that max_power is signed.
1375 */ 1380 */
1376 struct ieee80211_country_ie_triplet { 1381 struct ieee80211_country_ie_triplet {
1377 union { 1382 union {
1378 struct { 1383 struct {
1379 u8 first_channel; 1384 u8 first_channel;
1380 u8 num_channels; 1385 u8 num_channels;
1381 s8 max_power; 1386 s8 max_power;
1382 } __attribute__ ((packed)) chans; 1387 } __attribute__ ((packed)) chans;
1383 struct { 1388 struct {
1384 u8 reg_extension_id; 1389 u8 reg_extension_id;
1385 u8 reg_class; 1390 u8 reg_class;
1386 u8 coverage_class; 1391 u8 coverage_class;
1387 } __attribute__ ((packed)) ext; 1392 } __attribute__ ((packed)) ext;
1388 }; 1393 };
1389 } __attribute__ ((packed)); 1394 } __attribute__ ((packed));
1390 1395
1391 enum ieee80211_timeout_interval_type { 1396 enum ieee80211_timeout_interval_type {
1392 WLAN_TIMEOUT_REASSOC_DEADLINE = 1 /* 802.11r */, 1397 WLAN_TIMEOUT_REASSOC_DEADLINE = 1 /* 802.11r */,
1393 WLAN_TIMEOUT_KEY_LIFETIME = 2 /* 802.11r */, 1398 WLAN_TIMEOUT_KEY_LIFETIME = 2 /* 802.11r */,
1394 WLAN_TIMEOUT_ASSOC_COMEBACK = 3 /* 802.11w */, 1399 WLAN_TIMEOUT_ASSOC_COMEBACK = 3 /* 802.11w */,
1395 }; 1400 };
1396 1401
1397 /* BACK action code */ 1402 /* BACK action code */
1398 enum ieee80211_back_actioncode { 1403 enum ieee80211_back_actioncode {
1399 WLAN_ACTION_ADDBA_REQ = 0, 1404 WLAN_ACTION_ADDBA_REQ = 0,
1400 WLAN_ACTION_ADDBA_RESP = 1, 1405 WLAN_ACTION_ADDBA_RESP = 1,
1401 WLAN_ACTION_DELBA = 2, 1406 WLAN_ACTION_DELBA = 2,
1402 }; 1407 };
1403 1408
1404 /* BACK (block-ack) parties */ 1409 /* BACK (block-ack) parties */
1405 enum ieee80211_back_parties { 1410 enum ieee80211_back_parties {
1406 WLAN_BACK_RECIPIENT = 0, 1411 WLAN_BACK_RECIPIENT = 0,
1407 WLAN_BACK_INITIATOR = 1, 1412 WLAN_BACK_INITIATOR = 1,
1408 }; 1413 };
1409 1414
1410 /* SA Query action */ 1415 /* SA Query action */
1411 enum ieee80211_sa_query_action { 1416 enum ieee80211_sa_query_action {
1412 WLAN_ACTION_SA_QUERY_REQUEST = 0, 1417 WLAN_ACTION_SA_QUERY_REQUEST = 0,
1413 WLAN_ACTION_SA_QUERY_RESPONSE = 1, 1418 WLAN_ACTION_SA_QUERY_RESPONSE = 1,
1414 }; 1419 };
1415 1420
1416 1421
1417 /* A-MSDU 802.11n */ 1422 /* A-MSDU 802.11n */
1418 #define IEEE80211_QOS_CONTROL_A_MSDU_PRESENT 0x0080 1423 #define IEEE80211_QOS_CONTROL_A_MSDU_PRESENT 0x0080
1419 1424
1420 /* cipher suite selectors */ 1425 /* cipher suite selectors */
1421 #define WLAN_CIPHER_SUITE_USE_GROUP 0x000FAC00 1426 #define WLAN_CIPHER_SUITE_USE_GROUP 0x000FAC00
1422 #define WLAN_CIPHER_SUITE_WEP40 0x000FAC01 1427 #define WLAN_CIPHER_SUITE_WEP40 0x000FAC01
1423 #define WLAN_CIPHER_SUITE_TKIP 0x000FAC02 1428 #define WLAN_CIPHER_SUITE_TKIP 0x000FAC02
1424 /* reserved: 0x000FAC03 */ 1429 /* reserved: 0x000FAC03 */
1425 #define WLAN_CIPHER_SUITE_CCMP 0x000FAC04 1430 #define WLAN_CIPHER_SUITE_CCMP 0x000FAC04
1426 #define WLAN_CIPHER_SUITE_WEP104 0x000FAC05 1431 #define WLAN_CIPHER_SUITE_WEP104 0x000FAC05
1427 #define WLAN_CIPHER_SUITE_AES_CMAC 0x000FAC06 1432 #define WLAN_CIPHER_SUITE_AES_CMAC 0x000FAC06
1428 1433
1429 /* AKM suite selectors */ 1434 /* AKM suite selectors */
1430 #define WLAN_AKM_SUITE_8021X 0x000FAC01 1435 #define WLAN_AKM_SUITE_8021X 0x000FAC01
1431 #define WLAN_AKM_SUITE_PSK 0x000FAC02 1436 #define WLAN_AKM_SUITE_PSK 0x000FAC02
1432 #define WLAN_AKM_SUITE_SAE 0x000FAC08 1437 #define WLAN_AKM_SUITE_SAE 0x000FAC08
1433 #define WLAN_AKM_SUITE_FT_OVER_SAE 0x000FAC09 1438 #define WLAN_AKM_SUITE_FT_OVER_SAE 0x000FAC09
1434 1439
1435 #define WLAN_MAX_KEY_LEN 32 1440 #define WLAN_MAX_KEY_LEN 32
1436 1441
1437 #define WLAN_PMKID_LEN 16 1442 #define WLAN_PMKID_LEN 16
1438 1443
1439 /** 1444 /**
1440 * ieee80211_get_qos_ctl - get pointer to qos control bytes 1445 * ieee80211_get_qos_ctl - get pointer to qos control bytes
1441 * @hdr: the frame 1446 * @hdr: the frame
1442 * 1447 *
1443 * The qos ctrl bytes come after the frame_control, duration, seq_num 1448 * The qos ctrl bytes come after the frame_control, duration, seq_num
1444 * and 3 or 4 addresses of length ETH_ALEN. 1449 * and 3 or 4 addresses of length ETH_ALEN.
1445 * 3 addr: 2 + 2 + 2 + 3*6 = 24 1450 * 3 addr: 2 + 2 + 2 + 3*6 = 24
1446 * 4 addr: 2 + 2 + 2 + 4*6 = 30 1451 * 4 addr: 2 + 2 + 2 + 4*6 = 30
1447 */ 1452 */
1448 static inline u8 *ieee80211_get_qos_ctl(struct ieee80211_hdr *hdr) 1453 static inline u8 *ieee80211_get_qos_ctl(struct ieee80211_hdr *hdr)
1449 { 1454 {
1450 if (ieee80211_has_a4(hdr->frame_control)) 1455 if (ieee80211_has_a4(hdr->frame_control))
1451 return (u8 *)hdr + 30; 1456 return (u8 *)hdr + 30;
1452 else 1457 else
1453 return (u8 *)hdr + 24; 1458 return (u8 *)hdr + 24;
1454 } 1459 }
1455 1460
1456 /** 1461 /**
1457 * ieee80211_get_SA - get pointer to SA 1462 * ieee80211_get_SA - get pointer to SA
1458 * @hdr: the frame 1463 * @hdr: the frame
1459 * 1464 *
1460 * Given an 802.11 frame, this function returns the offset 1465 * Given an 802.11 frame, this function returns the offset
1461 * to the source address (SA). It does not verify that the 1466 * to the source address (SA). It does not verify that the
1462 * header is long enough to contain the address, and the 1467 * header is long enough to contain the address, and the
1463 * header must be long enough to contain the frame control 1468 * header must be long enough to contain the frame control
1464 * field. 1469 * field.
1465 */ 1470 */
1466 static inline u8 *ieee80211_get_SA(struct ieee80211_hdr *hdr) 1471 static inline u8 *ieee80211_get_SA(struct ieee80211_hdr *hdr)
1467 { 1472 {
1468 if (ieee80211_has_a4(hdr->frame_control)) 1473 if (ieee80211_has_a4(hdr->frame_control))
1469 return hdr->addr4; 1474 return hdr->addr4;
1470 if (ieee80211_has_fromds(hdr->frame_control)) 1475 if (ieee80211_has_fromds(hdr->frame_control))
1471 return hdr->addr3; 1476 return hdr->addr3;
1472 return hdr->addr2; 1477 return hdr->addr2;
1473 } 1478 }
1474 1479
1475 /** 1480 /**
1476 * ieee80211_get_DA - get pointer to DA 1481 * ieee80211_get_DA - get pointer to DA
1477 * @hdr: the frame 1482 * @hdr: the frame
1478 * 1483 *
1479 * Given an 802.11 frame, this function returns the offset 1484 * Given an 802.11 frame, this function returns the offset
1480 * to the destination address (DA). It does not verify that 1485 * to the destination address (DA). It does not verify that
1481 * the header is long enough to contain the address, and the 1486 * the header is long enough to contain the address, and the
1482 * header must be long enough to contain the frame control 1487 * header must be long enough to contain the frame control
1483 * field. 1488 * field.
1484 */ 1489 */
1485 static inline u8 *ieee80211_get_DA(struct ieee80211_hdr *hdr) 1490 static inline u8 *ieee80211_get_DA(struct ieee80211_hdr *hdr)
1486 { 1491 {
1487 if (ieee80211_has_tods(hdr->frame_control)) 1492 if (ieee80211_has_tods(hdr->frame_control))
1488 return hdr->addr3; 1493 return hdr->addr3;
1489 else 1494 else
1490 return hdr->addr1; 1495 return hdr->addr1;
1491 } 1496 }
1492 1497
1493 /** 1498 /**
1494 * ieee80211_is_robust_mgmt_frame - check if frame is a robust management frame 1499 * ieee80211_is_robust_mgmt_frame - check if frame is a robust management frame
1495 * @hdr: the frame (buffer must include at least the first octet of payload) 1500 * @hdr: the frame (buffer must include at least the first octet of payload)
1496 */ 1501 */
1497 static inline bool ieee80211_is_robust_mgmt_frame(struct ieee80211_hdr *hdr) 1502 static inline bool ieee80211_is_robust_mgmt_frame(struct ieee80211_hdr *hdr)
1498 { 1503 {
1499 if (ieee80211_is_disassoc(hdr->frame_control) || 1504 if (ieee80211_is_disassoc(hdr->frame_control) ||
1500 ieee80211_is_deauth(hdr->frame_control)) 1505 ieee80211_is_deauth(hdr->frame_control))
1501 return true; 1506 return true;
1502 1507
1503 if (ieee80211_is_action(hdr->frame_control)) { 1508 if (ieee80211_is_action(hdr->frame_control)) {
1504 u8 *category; 1509 u8 *category;
1505 1510
1506 /* 1511 /*
1507 * Action frames, excluding Public Action frames, are Robust 1512 * Action frames, excluding Public Action frames, are Robust
1508 * Management Frames. However, if we are looking at a Protected 1513 * Management Frames. However, if we are looking at a Protected
1509 * frame, skip the check since the data may be encrypted and 1514 * frame, skip the check since the data may be encrypted and
1510 * the frame has already been found to be a Robust Management 1515 * the frame has already been found to be a Robust Management
1511 * Frame (by the other end). 1516 * Frame (by the other end).
1512 */ 1517 */
1513 if (ieee80211_has_protected(hdr->frame_control)) 1518 if (ieee80211_has_protected(hdr->frame_control))
1514 return true; 1519 return true;
1515 category = ((u8 *) hdr) + 24; 1520 category = ((u8 *) hdr) + 24;
1516 return *category != WLAN_CATEGORY_PUBLIC && 1521 return *category != WLAN_CATEGORY_PUBLIC &&
1517 *category != WLAN_CATEGORY_HT && 1522 *category != WLAN_CATEGORY_HT &&
1518 *category != WLAN_CATEGORY_VENDOR_SPECIFIC; 1523 *category != WLAN_CATEGORY_VENDOR_SPECIFIC;
1519 } 1524 }
1520 1525
1521 return false; 1526 return false;
1522 } 1527 }
1523 1528
1524 /** 1529 /**
1525 * ieee80211_fhss_chan_to_freq - get channel frequency 1530 * ieee80211_fhss_chan_to_freq - get channel frequency
1526 * @channel: the FHSS channel 1531 * @channel: the FHSS channel
1527 * 1532 *
1528 * Convert IEEE802.11 FHSS channel to frequency (MHz) 1533 * Convert IEEE802.11 FHSS channel to frequency (MHz)
1529 * Ref IEEE 802.11-2007 section 14.6 1534 * Ref IEEE 802.11-2007 section 14.6
1530 */ 1535 */
1531 static inline int ieee80211_fhss_chan_to_freq(int channel) 1536 static inline int ieee80211_fhss_chan_to_freq(int channel)
1532 { 1537 {
1533 if ((channel > 1) && (channel < 96)) 1538 if ((channel > 1) && (channel < 96))
1534 return channel + 2400; 1539 return channel + 2400;
1535 else 1540 else
1536 return -1; 1541 return -1;
1537 } 1542 }
1538 1543
1539 /** 1544 /**
1540 * ieee80211_freq_to_fhss_chan - get channel 1545 * ieee80211_freq_to_fhss_chan - get channel
1541 * @freq: the channels frequency 1546 * @freq: the channels frequency
1542 * 1547 *
1543 * Convert frequency (MHz) to IEEE802.11 FHSS channel 1548 * Convert frequency (MHz) to IEEE802.11 FHSS channel
1544 * Ref IEEE 802.11-2007 section 14.6 1549 * Ref IEEE 802.11-2007 section 14.6
1545 */ 1550 */
1546 static inline int ieee80211_freq_to_fhss_chan(int freq) 1551 static inline int ieee80211_freq_to_fhss_chan(int freq)
1547 { 1552 {
1548 if ((freq > 2401) && (freq < 2496)) 1553 if ((freq > 2401) && (freq < 2496))
1549 return freq - 2400; 1554 return freq - 2400;
1550 else 1555 else
1551 return -1; 1556 return -1;
1552 } 1557 }
1553 1558
1554 /** 1559 /**
1555 * ieee80211_dsss_chan_to_freq - get channel center frequency 1560 * ieee80211_dsss_chan_to_freq - get channel center frequency
1556 * @channel: the DSSS channel 1561 * @channel: the DSSS channel
1557 * 1562 *
1558 * Convert IEEE802.11 DSSS channel to the center frequency (MHz). 1563 * Convert IEEE802.11 DSSS channel to the center frequency (MHz).
1559 * Ref IEEE 802.11-2007 section 15.6 1564 * Ref IEEE 802.11-2007 section 15.6
1560 */ 1565 */
1561 static inline int ieee80211_dsss_chan_to_freq(int channel) 1566 static inline int ieee80211_dsss_chan_to_freq(int channel)
1562 { 1567 {
1563 if ((channel > 0) && (channel < 14)) 1568 if ((channel > 0) && (channel < 14))
1564 return 2407 + (channel * 5); 1569 return 2407 + (channel * 5);
1565 else if (channel == 14) 1570 else if (channel == 14)
1566 return 2484; 1571 return 2484;
1567 else 1572 else
1568 return -1; 1573 return -1;
1569 } 1574 }
1570 1575
1571 /** 1576 /**
1572 * ieee80211_freq_to_dsss_chan - get channel 1577 * ieee80211_freq_to_dsss_chan - get channel
1573 * @freq: the frequency 1578 * @freq: the frequency
1574 * 1579 *
1575 * Convert frequency (MHz) to IEEE802.11 DSSS channel 1580 * Convert frequency (MHz) to IEEE802.11 DSSS channel
1576 * Ref IEEE 802.11-2007 section 15.6 1581 * Ref IEEE 802.11-2007 section 15.6
1577 * 1582 *
1578 * This routine selects the channel with the closest center frequency. 1583 * This routine selects the channel with the closest center frequency.
1579 */ 1584 */
1580 static inline int ieee80211_freq_to_dsss_chan(int freq) 1585 static inline int ieee80211_freq_to_dsss_chan(int freq)
1581 { 1586 {
1582 if ((freq >= 2410) && (freq < 2475)) 1587 if ((freq >= 2410) && (freq < 2475))
1583 return (freq - 2405) / 5; 1588 return (freq - 2405) / 5;
1584 else if ((freq >= 2482) && (freq < 2487)) 1589 else if ((freq >= 2482) && (freq < 2487))
1585 return 14; 1590 return 14;
1586 else 1591 else
1587 return -1; 1592 return -1;
1588 } 1593 }
1589 1594
1590 /* Convert IEEE802.11 HR DSSS channel to frequency (MHz) and back 1595 /* Convert IEEE802.11 HR DSSS channel to frequency (MHz) and back
1591 * Ref IEEE 802.11-2007 section 18.4.6.2 1596 * Ref IEEE 802.11-2007 section 18.4.6.2
1592 * 1597 *
1593 * The channels and frequencies are the same as those defined for DSSS 1598 * The channels and frequencies are the same as those defined for DSSS
1594 */ 1599 */
1595 #define ieee80211_hr_chan_to_freq(chan) ieee80211_dsss_chan_to_freq(chan) 1600 #define ieee80211_hr_chan_to_freq(chan) ieee80211_dsss_chan_to_freq(chan)
1596 #define ieee80211_freq_to_hr_chan(freq) ieee80211_freq_to_dsss_chan(freq) 1601 #define ieee80211_freq_to_hr_chan(freq) ieee80211_freq_to_dsss_chan(freq)
1597 1602
1598 /* Convert IEEE802.11 ERP channel to frequency (MHz) and back 1603 /* Convert IEEE802.11 ERP channel to frequency (MHz) and back
1599 * Ref IEEE 802.11-2007 section 19.4.2 1604 * Ref IEEE 802.11-2007 section 19.4.2
1600 */ 1605 */
1601 #define ieee80211_erp_chan_to_freq(chan) ieee80211_hr_chan_to_freq(chan) 1606 #define ieee80211_erp_chan_to_freq(chan) ieee80211_hr_chan_to_freq(chan)
1602 #define ieee80211_freq_to_erp_chan(freq) ieee80211_freq_to_hr_chan(freq) 1607 #define ieee80211_freq_to_erp_chan(freq) ieee80211_freq_to_hr_chan(freq)
1603 1608
1604 /** 1609 /**
1605 * ieee80211_ofdm_chan_to_freq - get channel center frequency 1610 * ieee80211_ofdm_chan_to_freq - get channel center frequency
1606 * @s_freq: starting frequency == (dotChannelStartingFactor/2) MHz 1611 * @s_freq: starting frequency == (dotChannelStartingFactor/2) MHz
1607 * @channel: the OFDM channel 1612 * @channel: the OFDM channel
1608 * 1613 *
1609 * Convert IEEE802.11 OFDM channel to center frequency (MHz) 1614 * Convert IEEE802.11 OFDM channel to center frequency (MHz)
1610 * Ref IEEE 802.11-2007 section 17.3.8.3.2 1615 * Ref IEEE 802.11-2007 section 17.3.8.3.2
1611 */ 1616 */
1612 static inline int ieee80211_ofdm_chan_to_freq(int s_freq, int channel) 1617 static inline int ieee80211_ofdm_chan_to_freq(int s_freq, int channel)
1613 { 1618 {
1614 if ((channel > 0) && (channel <= 200) && 1619 if ((channel > 0) && (channel <= 200) &&
1615 (s_freq >= 4000)) 1620 (s_freq >= 4000))
1616 return s_freq + (channel * 5); 1621 return s_freq + (channel * 5);
1617 else 1622 else
1618 return -1; 1623 return -1;
1619 } 1624 }
1620 1625
1621 /** 1626 /**
1622 * ieee80211_freq_to_ofdm_channel - get channel 1627 * ieee80211_freq_to_ofdm_channel - get channel
1623 * @s_freq: starting frequency == (dotChannelStartingFactor/2) MHz 1628 * @s_freq: starting frequency == (dotChannelStartingFactor/2) MHz
1624 * @freq: the frequency 1629 * @freq: the frequency
1625 * 1630 *
1626 * Convert frequency (MHz) to IEEE802.11 OFDM channel 1631 * Convert frequency (MHz) to IEEE802.11 OFDM channel
1627 * Ref IEEE 802.11-2007 section 17.3.8.3.2 1632 * Ref IEEE 802.11-2007 section 17.3.8.3.2
1628 * 1633 *
1629 * This routine selects the channel with the closest center frequency. 1634 * This routine selects the channel with the closest center frequency.
1630 */ 1635 */
1631 static inline int ieee80211_freq_to_ofdm_chan(int s_freq, int freq) 1636 static inline int ieee80211_freq_to_ofdm_chan(int s_freq, int freq)
1632 { 1637 {
1633 if ((freq > (s_freq + 2)) && (freq <= (s_freq + 1202)) && 1638 if ((freq > (s_freq + 2)) && (freq <= (s_freq + 1202)) &&
1634 (s_freq >= 4000)) 1639 (s_freq >= 4000))
1635 return (freq + 2 - s_freq) / 5; 1640 return (freq + 2 - s_freq) / 5;
1636 else 1641 else
1637 return -1; 1642 return -1;
1638 } 1643 }
1639 1644
1640 /** 1645 /**
1641 * ieee80211_tu_to_usec - convert time units (TU) to microseconds 1646 * ieee80211_tu_to_usec - convert time units (TU) to microseconds
1642 * @tu: the TUs 1647 * @tu: the TUs
1643 */ 1648 */
1644 static inline unsigned long ieee80211_tu_to_usec(unsigned long tu) 1649 static inline unsigned long ieee80211_tu_to_usec(unsigned long tu)
1645 { 1650 {
1646 return 1024 * tu; 1651 return 1024 * tu;
1647 } 1652 }
1648 1653
1649 /** 1654 /**
1650 * ieee80211_check_tim - check if AID bit is set in TIM 1655 * ieee80211_check_tim - check if AID bit is set in TIM
1651 * @tim: the TIM IE 1656 * @tim: the TIM IE
1652 * @tim_len: length of the TIM IE 1657 * @tim_len: length of the TIM IE
1653 * @aid: the AID to look for 1658 * @aid: the AID to look for
1654 */ 1659 */
1655 static inline bool ieee80211_check_tim(struct ieee80211_tim_ie *tim, 1660 static inline bool ieee80211_check_tim(struct ieee80211_tim_ie *tim,
1656 u8 tim_len, u16 aid) 1661 u8 tim_len, u16 aid)
1657 { 1662 {
1658 u8 mask; 1663 u8 mask;
1659 u8 index, indexn1, indexn2; 1664 u8 index, indexn1, indexn2;
1660 1665
1661 if (unlikely(!tim || tim_len < sizeof(*tim))) 1666 if (unlikely(!tim || tim_len < sizeof(*tim)))
1662 return false; 1667 return false;
1663 1668
1664 aid &= 0x3fff; 1669 aid &= 0x3fff;
1665 index = aid / 8; 1670 index = aid / 8;
1666 mask = 1 << (aid & 7); 1671 mask = 1 << (aid & 7);
1667 1672
1668 indexn1 = tim->bitmap_ctrl & 0xfe; 1673 indexn1 = tim->bitmap_ctrl & 0xfe;
1669 indexn2 = tim_len + indexn1 - 4; 1674 indexn2 = tim_len + indexn1 - 4;
1670 1675
1671 if (index < indexn1 || index > indexn2) 1676 if (index < indexn1 || index > indexn2)
1672 return false; 1677 return false;
1673 1678
1674 index -= indexn1; 1679 index -= indexn1;
1675 1680
1676 return !!(tim->virtual_map[index] & mask); 1681 return !!(tim->virtual_map[index] & mask);
1677 } 1682 }
1678 1683
1679 #endif /* LINUX_IEEE80211_H */ 1684 #endif /* LINUX_IEEE80211_H */
1680 1685
1 /* 1 /*
2 * cfg80211 scan result handling 2 * cfg80211 scan result handling
3 * 3 *
4 * Copyright 2008 Johannes Berg <johannes@sipsolutions.net> 4 * Copyright 2008 Johannes Berg <johannes@sipsolutions.net>
5 */ 5 */
6 #include <linux/kernel.h> 6 #include <linux/kernel.h>
7 #include <linux/slab.h> 7 #include <linux/slab.h>
8 #include <linux/module.h> 8 #include <linux/module.h>
9 #include <linux/netdevice.h> 9 #include <linux/netdevice.h>
10 #include <linux/wireless.h> 10 #include <linux/wireless.h>
11 #include <linux/nl80211.h> 11 #include <linux/nl80211.h>
12 #include <linux/etherdevice.h> 12 #include <linux/etherdevice.h>
13 #include <net/arp.h> 13 #include <net/arp.h>
14 #include <net/cfg80211.h> 14 #include <net/cfg80211.h>
15 #include <net/iw_handler.h> 15 #include <net/iw_handler.h>
16 #include "core.h" 16 #include "core.h"
17 #include "nl80211.h" 17 #include "nl80211.h"
18 #include "wext-compat.h" 18 #include "wext-compat.h"
19 19
20 #define IEEE80211_SCAN_RESULT_EXPIRE (15 * HZ) 20 #define IEEE80211_SCAN_RESULT_EXPIRE (15 * HZ)
21 21
22 void ___cfg80211_scan_done(struct cfg80211_registered_device *rdev, bool leak) 22 void ___cfg80211_scan_done(struct cfg80211_registered_device *rdev, bool leak)
23 { 23 {
24 struct cfg80211_scan_request *request; 24 struct cfg80211_scan_request *request;
25 struct net_device *dev; 25 struct net_device *dev;
26 #ifdef CONFIG_CFG80211_WEXT 26 #ifdef CONFIG_CFG80211_WEXT
27 union iwreq_data wrqu; 27 union iwreq_data wrqu;
28 #endif 28 #endif
29 29
30 ASSERT_RDEV_LOCK(rdev); 30 ASSERT_RDEV_LOCK(rdev);
31 31
32 request = rdev->scan_req; 32 request = rdev->scan_req;
33 33
34 if (!request) 34 if (!request)
35 return; 35 return;
36 36
37 dev = request->dev; 37 dev = request->dev;
38 38
39 /* 39 /*
40 * This must be before sending the other events! 40 * This must be before sending the other events!
41 * Otherwise, wpa_supplicant gets completely confused with 41 * Otherwise, wpa_supplicant gets completely confused with
42 * wext events. 42 * wext events.
43 */ 43 */
44 cfg80211_sme_scan_done(dev); 44 cfg80211_sme_scan_done(dev);
45 45
46 if (request->aborted) 46 if (request->aborted)
47 nl80211_send_scan_aborted(rdev, dev); 47 nl80211_send_scan_aborted(rdev, dev);
48 else 48 else
49 nl80211_send_scan_done(rdev, dev); 49 nl80211_send_scan_done(rdev, dev);
50 50
51 #ifdef CONFIG_CFG80211_WEXT 51 #ifdef CONFIG_CFG80211_WEXT
52 if (!request->aborted) { 52 if (!request->aborted) {
53 memset(&wrqu, 0, sizeof(wrqu)); 53 memset(&wrqu, 0, sizeof(wrqu));
54 54
55 wireless_send_event(dev, SIOCGIWSCAN, &wrqu, NULL); 55 wireless_send_event(dev, SIOCGIWSCAN, &wrqu, NULL);
56 } 56 }
57 #endif 57 #endif
58 58
59 dev_put(dev); 59 dev_put(dev);
60 60
61 rdev->scan_req = NULL; 61 rdev->scan_req = NULL;
62 62
63 /* 63 /*
64 * OK. If this is invoked with "leak" then we can't 64 * OK. If this is invoked with "leak" then we can't
65 * free this ... but we've cleaned it up anyway. The 65 * free this ... but we've cleaned it up anyway. The
66 * driver failed to call the scan_done callback, so 66 * driver failed to call the scan_done callback, so
67 * all bets are off, it might still be trying to use 67 * all bets are off, it might still be trying to use
68 * the scan request or not ... if it accesses the dev 68 * the scan request or not ... if it accesses the dev
69 * in there (it shouldn't anyway) then it may crash. 69 * in there (it shouldn't anyway) then it may crash.
70 */ 70 */
71 if (!leak) 71 if (!leak)
72 kfree(request); 72 kfree(request);
73 } 73 }
74 74
75 void __cfg80211_scan_done(struct work_struct *wk) 75 void __cfg80211_scan_done(struct work_struct *wk)
76 { 76 {
77 struct cfg80211_registered_device *rdev; 77 struct cfg80211_registered_device *rdev;
78 78
79 rdev = container_of(wk, struct cfg80211_registered_device, 79 rdev = container_of(wk, struct cfg80211_registered_device,
80 scan_done_wk); 80 scan_done_wk);
81 81
82 cfg80211_lock_rdev(rdev); 82 cfg80211_lock_rdev(rdev);
83 ___cfg80211_scan_done(rdev, false); 83 ___cfg80211_scan_done(rdev, false);
84 cfg80211_unlock_rdev(rdev); 84 cfg80211_unlock_rdev(rdev);
85 } 85 }
86 86
87 void cfg80211_scan_done(struct cfg80211_scan_request *request, bool aborted) 87 void cfg80211_scan_done(struct cfg80211_scan_request *request, bool aborted)
88 { 88 {
89 WARN_ON(request != wiphy_to_dev(request->wiphy)->scan_req); 89 WARN_ON(request != wiphy_to_dev(request->wiphy)->scan_req);
90 90
91 request->aborted = aborted; 91 request->aborted = aborted;
92 queue_work(cfg80211_wq, &wiphy_to_dev(request->wiphy)->scan_done_wk); 92 queue_work(cfg80211_wq, &wiphy_to_dev(request->wiphy)->scan_done_wk);
93 } 93 }
94 EXPORT_SYMBOL(cfg80211_scan_done); 94 EXPORT_SYMBOL(cfg80211_scan_done);
95 95
96 static void bss_release(struct kref *ref) 96 static void bss_release(struct kref *ref)
97 { 97 {
98 struct cfg80211_internal_bss *bss; 98 struct cfg80211_internal_bss *bss;
99 99
100 bss = container_of(ref, struct cfg80211_internal_bss, ref); 100 bss = container_of(ref, struct cfg80211_internal_bss, ref);
101 if (bss->pub.free_priv) 101 if (bss->pub.free_priv)
102 bss->pub.free_priv(&bss->pub); 102 bss->pub.free_priv(&bss->pub);
103 103
104 if (bss->beacon_ies_allocated) 104 if (bss->beacon_ies_allocated)
105 kfree(bss->pub.beacon_ies); 105 kfree(bss->pub.beacon_ies);
106 if (bss->proberesp_ies_allocated) 106 if (bss->proberesp_ies_allocated)
107 kfree(bss->pub.proberesp_ies); 107 kfree(bss->pub.proberesp_ies);
108 108
109 BUG_ON(atomic_read(&bss->hold)); 109 BUG_ON(atomic_read(&bss->hold));
110 110
111 kfree(bss); 111 kfree(bss);
112 } 112 }
113 113
114 /* must hold dev->bss_lock! */ 114 /* must hold dev->bss_lock! */
115 void cfg80211_bss_age(struct cfg80211_registered_device *dev, 115 void cfg80211_bss_age(struct cfg80211_registered_device *dev,
116 unsigned long age_secs) 116 unsigned long age_secs)
117 { 117 {
118 struct cfg80211_internal_bss *bss; 118 struct cfg80211_internal_bss *bss;
119 unsigned long age_jiffies = msecs_to_jiffies(age_secs * MSEC_PER_SEC); 119 unsigned long age_jiffies = msecs_to_jiffies(age_secs * MSEC_PER_SEC);
120 120
121 list_for_each_entry(bss, &dev->bss_list, list) { 121 list_for_each_entry(bss, &dev->bss_list, list) {
122 bss->ts -= age_jiffies; 122 bss->ts -= age_jiffies;
123 } 123 }
124 } 124 }
125 125
126 /* must hold dev->bss_lock! */ 126 /* must hold dev->bss_lock! */
127 static void __cfg80211_unlink_bss(struct cfg80211_registered_device *dev, 127 static void __cfg80211_unlink_bss(struct cfg80211_registered_device *dev,
128 struct cfg80211_internal_bss *bss) 128 struct cfg80211_internal_bss *bss)
129 { 129 {
130 list_del_init(&bss->list); 130 list_del_init(&bss->list);
131 rb_erase(&bss->rbn, &dev->bss_tree); 131 rb_erase(&bss->rbn, &dev->bss_tree);
132 kref_put(&bss->ref, bss_release); 132 kref_put(&bss->ref, bss_release);
133 } 133 }
134 134
135 /* must hold dev->bss_lock! */ 135 /* must hold dev->bss_lock! */
136 void cfg80211_bss_expire(struct cfg80211_registered_device *dev) 136 void cfg80211_bss_expire(struct cfg80211_registered_device *dev)
137 { 137 {
138 struct cfg80211_internal_bss *bss, *tmp; 138 struct cfg80211_internal_bss *bss, *tmp;
139 bool expired = false; 139 bool expired = false;
140 140
141 list_for_each_entry_safe(bss, tmp, &dev->bss_list, list) { 141 list_for_each_entry_safe(bss, tmp, &dev->bss_list, list) {
142 if (atomic_read(&bss->hold)) 142 if (atomic_read(&bss->hold))
143 continue; 143 continue;
144 if (!time_after(jiffies, bss->ts + IEEE80211_SCAN_RESULT_EXPIRE)) 144 if (!time_after(jiffies, bss->ts + IEEE80211_SCAN_RESULT_EXPIRE))
145 continue; 145 continue;
146 __cfg80211_unlink_bss(dev, bss); 146 __cfg80211_unlink_bss(dev, bss);
147 expired = true; 147 expired = true;
148 } 148 }
149 149
150 if (expired) 150 if (expired)
151 dev->bss_generation++; 151 dev->bss_generation++;
152 } 152 }
153 153
154 const u8 *cfg80211_find_ie(u8 eid, const u8 *ies, int len) 154 const u8 *cfg80211_find_ie(u8 eid, const u8 *ies, int len)
155 { 155 {
156 while (len > 2 && ies[0] != eid) { 156 while (len > 2 && ies[0] != eid) {
157 len -= ies[1] + 2; 157 len -= ies[1] + 2;
158 ies += ies[1] + 2; 158 ies += ies[1] + 2;
159 } 159 }
160 if (len < 2) 160 if (len < 2)
161 return NULL; 161 return NULL;
162 if (len < 2 + ies[1]) 162 if (len < 2 + ies[1])
163 return NULL; 163 return NULL;
164 return ies; 164 return ies;
165 } 165 }
166 EXPORT_SYMBOL(cfg80211_find_ie); 166 EXPORT_SYMBOL(cfg80211_find_ie);
167 167
168 static int cmp_ies(u8 num, u8 *ies1, size_t len1, u8 *ies2, size_t len2) 168 static int cmp_ies(u8 num, u8 *ies1, size_t len1, u8 *ies2, size_t len2)
169 { 169 {
170 const u8 *ie1 = cfg80211_find_ie(num, ies1, len1); 170 const u8 *ie1 = cfg80211_find_ie(num, ies1, len1);
171 const u8 *ie2 = cfg80211_find_ie(num, ies2, len2); 171 const u8 *ie2 = cfg80211_find_ie(num, ies2, len2);
172 int r; 172 int r;
173 173
174 if (!ie1 && !ie2) 174 if (!ie1 && !ie2)
175 return 0; 175 return 0;
176 if (!ie1 || !ie2) 176 if (!ie1 || !ie2)
177 return -1; 177 return -1;
178 178
179 r = memcmp(ie1 + 2, ie2 + 2, min(ie1[1], ie2[1])); 179 r = memcmp(ie1 + 2, ie2 + 2, min(ie1[1], ie2[1]));
180 if (r == 0 && ie1[1] != ie2[1]) 180 if (r == 0 && ie1[1] != ie2[1])
181 return ie2[1] - ie1[1]; 181 return ie2[1] - ie1[1];
182 return r; 182 return r;
183 } 183 }
184 184
185 static bool is_bss(struct cfg80211_bss *a, 185 static bool is_bss(struct cfg80211_bss *a,
186 const u8 *bssid, 186 const u8 *bssid,
187 const u8 *ssid, size_t ssid_len) 187 const u8 *ssid, size_t ssid_len)
188 { 188 {
189 const u8 *ssidie; 189 const u8 *ssidie;
190 190
191 if (bssid && compare_ether_addr(a->bssid, bssid)) 191 if (bssid && compare_ether_addr(a->bssid, bssid))
192 return false; 192 return false;
193 193
194 if (!ssid) 194 if (!ssid)
195 return true; 195 return true;
196 196
197 ssidie = cfg80211_find_ie(WLAN_EID_SSID, 197 ssidie = cfg80211_find_ie(WLAN_EID_SSID,
198 a->information_elements, 198 a->information_elements,
199 a->len_information_elements); 199 a->len_information_elements);
200 if (!ssidie) 200 if (!ssidie)
201 return false; 201 return false;
202 if (ssidie[1] != ssid_len) 202 if (ssidie[1] != ssid_len)
203 return false; 203 return false;
204 return memcmp(ssidie + 2, ssid, ssid_len) == 0; 204 return memcmp(ssidie + 2, ssid, ssid_len) == 0;
205 } 205 }
206 206
207 static bool is_mesh(struct cfg80211_bss *a, 207 static bool is_mesh(struct cfg80211_bss *a,
208 const u8 *meshid, size_t meshidlen, 208 const u8 *meshid, size_t meshidlen,
209 const u8 *meshcfg) 209 const u8 *meshcfg)
210 { 210 {
211 const u8 *ie; 211 const u8 *ie;
212 212
213 if (!is_zero_ether_addr(a->bssid)) 213 if (!WLAN_CAPABILITY_IS_MBSS(a->capability))
214 return false; 214 return false;
215 215
216 ie = cfg80211_find_ie(WLAN_EID_MESH_ID, 216 ie = cfg80211_find_ie(WLAN_EID_MESH_ID,
217 a->information_elements, 217 a->information_elements,
218 a->len_information_elements); 218 a->len_information_elements);
219 if (!ie) 219 if (!ie)
220 return false; 220 return false;
221 if (ie[1] != meshidlen) 221 if (ie[1] != meshidlen)
222 return false; 222 return false;
223 if (memcmp(ie + 2, meshid, meshidlen)) 223 if (memcmp(ie + 2, meshid, meshidlen))
224 return false; 224 return false;
225 225
226 ie = cfg80211_find_ie(WLAN_EID_MESH_CONFIG, 226 ie = cfg80211_find_ie(WLAN_EID_MESH_CONFIG,
227 a->information_elements, 227 a->information_elements,
228 a->len_information_elements); 228 a->len_information_elements);
229 if (!ie) 229 if (!ie)
230 return false; 230 return false;
231 if (ie[1] != sizeof(struct ieee80211_meshconf_ie)) 231 if (ie[1] != sizeof(struct ieee80211_meshconf_ie))
232 return false; 232 return false;
233 233
234 /* 234 /*
235 * Ignore mesh capability (last two bytes of the IE) when 235 * Ignore mesh capability (last two bytes of the IE) when
236 * comparing since that may differ between stations taking 236 * comparing since that may differ between stations taking
237 * part in the same mesh. 237 * part in the same mesh.
238 */ 238 */
239 return memcmp(ie + 2, meshcfg, 239 return memcmp(ie + 2, meshcfg,
240 sizeof(struct ieee80211_meshconf_ie) - 2) == 0; 240 sizeof(struct ieee80211_meshconf_ie) - 2) == 0;
241 } 241 }
242 242
243 static int cmp_bss(struct cfg80211_bss *a, 243 static int cmp_bss(struct cfg80211_bss *a,
244 struct cfg80211_bss *b) 244 struct cfg80211_bss *b)
245 { 245 {
246 int r; 246 int r;
247 247
248 if (a->channel != b->channel) 248 if (a->channel != b->channel)
249 return b->channel->center_freq - a->channel->center_freq; 249 return b->channel->center_freq - a->channel->center_freq;
250 250
251 r = memcmp(a->bssid, b->bssid, ETH_ALEN); 251 if (WLAN_CAPABILITY_IS_MBSS(a->capability | b->capability)) {
252 if (r)
253 return r;
254
255 if (is_zero_ether_addr(a->bssid)) {
256 r = cmp_ies(WLAN_EID_MESH_ID, 252 r = cmp_ies(WLAN_EID_MESH_ID,
257 a->information_elements, 253 a->information_elements,
258 a->len_information_elements, 254 a->len_information_elements,
259 b->information_elements, 255 b->information_elements,
260 b->len_information_elements); 256 b->len_information_elements);
261 if (r) 257 if (r)
262 return r; 258 return r;
263 return cmp_ies(WLAN_EID_MESH_CONFIG, 259 return cmp_ies(WLAN_EID_MESH_CONFIG,
264 a->information_elements, 260 a->information_elements,
265 a->len_information_elements, 261 a->len_information_elements,
266 b->information_elements, 262 b->information_elements,
267 b->len_information_elements); 263 b->len_information_elements);
268 } 264 }
269 265
266 r = memcmp(a->bssid, b->bssid, ETH_ALEN);
267 if (r)
268 return r;
269
270 return cmp_ies(WLAN_EID_SSID, 270 return cmp_ies(WLAN_EID_SSID,
271 a->information_elements, 271 a->information_elements,
272 a->len_information_elements, 272 a->len_information_elements,
273 b->information_elements, 273 b->information_elements,
274 b->len_information_elements); 274 b->len_information_elements);
275 } 275 }
276 276
277 struct cfg80211_bss *cfg80211_get_bss(struct wiphy *wiphy, 277 struct cfg80211_bss *cfg80211_get_bss(struct wiphy *wiphy,
278 struct ieee80211_channel *channel, 278 struct ieee80211_channel *channel,
279 const u8 *bssid, 279 const u8 *bssid,
280 const u8 *ssid, size_t ssid_len, 280 const u8 *ssid, size_t ssid_len,
281 u16 capa_mask, u16 capa_val) 281 u16 capa_mask, u16 capa_val)
282 { 282 {
283 struct cfg80211_registered_device *dev = wiphy_to_dev(wiphy); 283 struct cfg80211_registered_device *dev = wiphy_to_dev(wiphy);
284 struct cfg80211_internal_bss *bss, *res = NULL; 284 struct cfg80211_internal_bss *bss, *res = NULL;
285 unsigned long now = jiffies; 285 unsigned long now = jiffies;
286 286
287 spin_lock_bh(&dev->bss_lock); 287 spin_lock_bh(&dev->bss_lock);
288 288
289 list_for_each_entry(bss, &dev->bss_list, list) { 289 list_for_each_entry(bss, &dev->bss_list, list) {
290 if ((bss->pub.capability & capa_mask) != capa_val) 290 if ((bss->pub.capability & capa_mask) != capa_val)
291 continue; 291 continue;
292 if (channel && bss->pub.channel != channel) 292 if (channel && bss->pub.channel != channel)
293 continue; 293 continue;
294 /* Don't get expired BSS structs */ 294 /* Don't get expired BSS structs */
295 if (time_after(now, bss->ts + IEEE80211_SCAN_RESULT_EXPIRE) && 295 if (time_after(now, bss->ts + IEEE80211_SCAN_RESULT_EXPIRE) &&
296 !atomic_read(&bss->hold)) 296 !atomic_read(&bss->hold))
297 continue; 297 continue;
298 if (is_bss(&bss->pub, bssid, ssid, ssid_len)) { 298 if (is_bss(&bss->pub, bssid, ssid, ssid_len)) {
299 res = bss; 299 res = bss;
300 kref_get(&res->ref); 300 kref_get(&res->ref);
301 break; 301 break;
302 } 302 }
303 } 303 }
304 304
305 spin_unlock_bh(&dev->bss_lock); 305 spin_unlock_bh(&dev->bss_lock);
306 if (!res) 306 if (!res)
307 return NULL; 307 return NULL;
308 return &res->pub; 308 return &res->pub;
309 } 309 }
310 EXPORT_SYMBOL(cfg80211_get_bss); 310 EXPORT_SYMBOL(cfg80211_get_bss);
311 311
312 struct cfg80211_bss *cfg80211_get_mesh(struct wiphy *wiphy, 312 struct cfg80211_bss *cfg80211_get_mesh(struct wiphy *wiphy,
313 struct ieee80211_channel *channel, 313 struct ieee80211_channel *channel,
314 const u8 *meshid, size_t meshidlen, 314 const u8 *meshid, size_t meshidlen,
315 const u8 *meshcfg) 315 const u8 *meshcfg)
316 { 316 {
317 struct cfg80211_registered_device *dev = wiphy_to_dev(wiphy); 317 struct cfg80211_registered_device *dev = wiphy_to_dev(wiphy);
318 struct cfg80211_internal_bss *bss, *res = NULL; 318 struct cfg80211_internal_bss *bss, *res = NULL;
319 319
320 spin_lock_bh(&dev->bss_lock); 320 spin_lock_bh(&dev->bss_lock);
321 321
322 list_for_each_entry(bss, &dev->bss_list, list) { 322 list_for_each_entry(bss, &dev->bss_list, list) {
323 if (channel && bss->pub.channel != channel) 323 if (channel && bss->pub.channel != channel)
324 continue; 324 continue;
325 if (is_mesh(&bss->pub, meshid, meshidlen, meshcfg)) { 325 if (is_mesh(&bss->pub, meshid, meshidlen, meshcfg)) {
326 res = bss; 326 res = bss;
327 kref_get(&res->ref); 327 kref_get(&res->ref);
328 break; 328 break;
329 } 329 }
330 } 330 }
331 331
332 spin_unlock_bh(&dev->bss_lock); 332 spin_unlock_bh(&dev->bss_lock);
333 if (!res) 333 if (!res)
334 return NULL; 334 return NULL;
335 return &res->pub; 335 return &res->pub;
336 } 336 }
337 EXPORT_SYMBOL(cfg80211_get_mesh); 337 EXPORT_SYMBOL(cfg80211_get_mesh);
338 338
339 339
340 static void rb_insert_bss(struct cfg80211_registered_device *dev, 340 static void rb_insert_bss(struct cfg80211_registered_device *dev,
341 struct cfg80211_internal_bss *bss) 341 struct cfg80211_internal_bss *bss)
342 { 342 {
343 struct rb_node **p = &dev->bss_tree.rb_node; 343 struct rb_node **p = &dev->bss_tree.rb_node;
344 struct rb_node *parent = NULL; 344 struct rb_node *parent = NULL;
345 struct cfg80211_internal_bss *tbss; 345 struct cfg80211_internal_bss *tbss;
346 int cmp; 346 int cmp;
347 347
348 while (*p) { 348 while (*p) {
349 parent = *p; 349 parent = *p;
350 tbss = rb_entry(parent, struct cfg80211_internal_bss, rbn); 350 tbss = rb_entry(parent, struct cfg80211_internal_bss, rbn);
351 351
352 cmp = cmp_bss(&bss->pub, &tbss->pub); 352 cmp = cmp_bss(&bss->pub, &tbss->pub);
353 353
354 if (WARN_ON(!cmp)) { 354 if (WARN_ON(!cmp)) {
355 /* will sort of leak this BSS */ 355 /* will sort of leak this BSS */
356 return; 356 return;
357 } 357 }
358 358
359 if (cmp < 0) 359 if (cmp < 0)
360 p = &(*p)->rb_left; 360 p = &(*p)->rb_left;
361 else 361 else
362 p = &(*p)->rb_right; 362 p = &(*p)->rb_right;
363 } 363 }
364 364
365 rb_link_node(&bss->rbn, parent, p); 365 rb_link_node(&bss->rbn, parent, p);
366 rb_insert_color(&bss->rbn, &dev->bss_tree); 366 rb_insert_color(&bss->rbn, &dev->bss_tree);
367 } 367 }
368 368
369 static struct cfg80211_internal_bss * 369 static struct cfg80211_internal_bss *
370 rb_find_bss(struct cfg80211_registered_device *dev, 370 rb_find_bss(struct cfg80211_registered_device *dev,
371 struct cfg80211_internal_bss *res) 371 struct cfg80211_internal_bss *res)
372 { 372 {
373 struct rb_node *n = dev->bss_tree.rb_node; 373 struct rb_node *n = dev->bss_tree.rb_node;
374 struct cfg80211_internal_bss *bss; 374 struct cfg80211_internal_bss *bss;
375 int r; 375 int r;
376 376
377 while (n) { 377 while (n) {
378 bss = rb_entry(n, struct cfg80211_internal_bss, rbn); 378 bss = rb_entry(n, struct cfg80211_internal_bss, rbn);
379 r = cmp_bss(&res->pub, &bss->pub); 379 r = cmp_bss(&res->pub, &bss->pub);
380 380
381 if (r == 0) 381 if (r == 0)
382 return bss; 382 return bss;
383 else if (r < 0) 383 else if (r < 0)
384 n = n->rb_left; 384 n = n->rb_left;
385 else 385 else
386 n = n->rb_right; 386 n = n->rb_right;
387 } 387 }
388 388
389 return NULL; 389 return NULL;
390 } 390 }
391 391
392 static struct cfg80211_internal_bss * 392 static struct cfg80211_internal_bss *
393 cfg80211_bss_update(struct cfg80211_registered_device *dev, 393 cfg80211_bss_update(struct cfg80211_registered_device *dev,
394 struct cfg80211_internal_bss *res) 394 struct cfg80211_internal_bss *res)
395 { 395 {
396 struct cfg80211_internal_bss *found = NULL; 396 struct cfg80211_internal_bss *found = NULL;
397 const u8 *meshid, *meshcfg; 397 const u8 *meshid, *meshcfg;
398 398
399 /* 399 /*
400 * The reference to "res" is donated to this function. 400 * The reference to "res" is donated to this function.
401 */ 401 */
402 402
403 if (WARN_ON(!res->pub.channel)) { 403 if (WARN_ON(!res->pub.channel)) {
404 kref_put(&res->ref, bss_release); 404 kref_put(&res->ref, bss_release);
405 return NULL; 405 return NULL;
406 } 406 }
407 407
408 res->ts = jiffies; 408 res->ts = jiffies;
409 409
410 if (is_zero_ether_addr(res->pub.bssid)) { 410 if (WLAN_CAPABILITY_IS_MBSS(res->pub.capability)) {
411 /* must be mesh, verify */ 411 /* must be mesh, verify */
412 meshid = cfg80211_find_ie(WLAN_EID_MESH_ID, 412 meshid = cfg80211_find_ie(WLAN_EID_MESH_ID,
413 res->pub.information_elements, 413 res->pub.information_elements,
414 res->pub.len_information_elements); 414 res->pub.len_information_elements);
415 meshcfg = cfg80211_find_ie(WLAN_EID_MESH_CONFIG, 415 meshcfg = cfg80211_find_ie(WLAN_EID_MESH_CONFIG,
416 res->pub.information_elements, 416 res->pub.information_elements,
417 res->pub.len_information_elements); 417 res->pub.len_information_elements);
418 if (!meshid || !meshcfg || 418 if (!meshid || !meshcfg ||
419 meshcfg[1] != sizeof(struct ieee80211_meshconf_ie)) { 419 meshcfg[1] != sizeof(struct ieee80211_meshconf_ie)) {
420 /* bogus mesh */ 420 /* bogus mesh */
421 kref_put(&res->ref, bss_release); 421 kref_put(&res->ref, bss_release);
422 return NULL; 422 return NULL;
423 } 423 }
424 } 424 }
425 425
426 spin_lock_bh(&dev->bss_lock); 426 spin_lock_bh(&dev->bss_lock);
427 427
428 found = rb_find_bss(dev, res); 428 found = rb_find_bss(dev, res);
429 429
430 if (found) { 430 if (found) {
431 found->pub.beacon_interval = res->pub.beacon_interval; 431 found->pub.beacon_interval = res->pub.beacon_interval;
432 found->pub.tsf = res->pub.tsf; 432 found->pub.tsf = res->pub.tsf;
433 found->pub.signal = res->pub.signal; 433 found->pub.signal = res->pub.signal;
434 found->pub.capability = res->pub.capability; 434 found->pub.capability = res->pub.capability;
435 found->ts = res->ts; 435 found->ts = res->ts;
436 436
437 /* Update IEs */ 437 /* Update IEs */
438 if (res->pub.proberesp_ies) { 438 if (res->pub.proberesp_ies) {
439 size_t used = dev->wiphy.bss_priv_size + sizeof(*res); 439 size_t used = dev->wiphy.bss_priv_size + sizeof(*res);
440 size_t ielen = res->pub.len_proberesp_ies; 440 size_t ielen = res->pub.len_proberesp_ies;
441 441
442 if (found->pub.proberesp_ies && 442 if (found->pub.proberesp_ies &&
443 !found->proberesp_ies_allocated && 443 !found->proberesp_ies_allocated &&
444 ksize(found) >= used + ielen) { 444 ksize(found) >= used + ielen) {
445 memcpy(found->pub.proberesp_ies, 445 memcpy(found->pub.proberesp_ies,
446 res->pub.proberesp_ies, ielen); 446 res->pub.proberesp_ies, ielen);
447 found->pub.len_proberesp_ies = ielen; 447 found->pub.len_proberesp_ies = ielen;
448 } else { 448 } else {
449 u8 *ies = found->pub.proberesp_ies; 449 u8 *ies = found->pub.proberesp_ies;
450 450
451 if (found->proberesp_ies_allocated) 451 if (found->proberesp_ies_allocated)
452 ies = krealloc(ies, ielen, GFP_ATOMIC); 452 ies = krealloc(ies, ielen, GFP_ATOMIC);
453 else 453 else
454 ies = kmalloc(ielen, GFP_ATOMIC); 454 ies = kmalloc(ielen, GFP_ATOMIC);
455 455
456 if (ies) { 456 if (ies) {
457 memcpy(ies, res->pub.proberesp_ies, 457 memcpy(ies, res->pub.proberesp_ies,
458 ielen); 458 ielen);
459 found->proberesp_ies_allocated = true; 459 found->proberesp_ies_allocated = true;
460 found->pub.proberesp_ies = ies; 460 found->pub.proberesp_ies = ies;
461 found->pub.len_proberesp_ies = ielen; 461 found->pub.len_proberesp_ies = ielen;
462 } 462 }
463 } 463 }
464 464
465 /* Override possible earlier Beacon frame IEs */ 465 /* Override possible earlier Beacon frame IEs */
466 found->pub.information_elements = 466 found->pub.information_elements =
467 found->pub.proberesp_ies; 467 found->pub.proberesp_ies;
468 found->pub.len_information_elements = 468 found->pub.len_information_elements =
469 found->pub.len_proberesp_ies; 469 found->pub.len_proberesp_ies;
470 } 470 }
471 if (res->pub.beacon_ies) { 471 if (res->pub.beacon_ies) {
472 size_t used = dev->wiphy.bss_priv_size + sizeof(*res); 472 size_t used = dev->wiphy.bss_priv_size + sizeof(*res);
473 size_t ielen = res->pub.len_beacon_ies; 473 size_t ielen = res->pub.len_beacon_ies;
474 bool information_elements_is_beacon_ies = 474 bool information_elements_is_beacon_ies =
475 (found->pub.information_elements == 475 (found->pub.information_elements ==
476 found->pub.beacon_ies); 476 found->pub.beacon_ies);
477 477
478 if (found->pub.beacon_ies && 478 if (found->pub.beacon_ies &&
479 !found->beacon_ies_allocated && 479 !found->beacon_ies_allocated &&
480 ksize(found) >= used + ielen) { 480 ksize(found) >= used + ielen) {
481 memcpy(found->pub.beacon_ies, 481 memcpy(found->pub.beacon_ies,
482 res->pub.beacon_ies, ielen); 482 res->pub.beacon_ies, ielen);
483 found->pub.len_beacon_ies = ielen; 483 found->pub.len_beacon_ies = ielen;
484 } else { 484 } else {
485 u8 *ies = found->pub.beacon_ies; 485 u8 *ies = found->pub.beacon_ies;
486 486
487 if (found->beacon_ies_allocated) 487 if (found->beacon_ies_allocated)
488 ies = krealloc(ies, ielen, GFP_ATOMIC); 488 ies = krealloc(ies, ielen, GFP_ATOMIC);
489 else 489 else
490 ies = kmalloc(ielen, GFP_ATOMIC); 490 ies = kmalloc(ielen, GFP_ATOMIC);
491 491
492 if (ies) { 492 if (ies) {
493 memcpy(ies, res->pub.beacon_ies, 493 memcpy(ies, res->pub.beacon_ies,
494 ielen); 494 ielen);
495 found->beacon_ies_allocated = true; 495 found->beacon_ies_allocated = true;
496 found->pub.beacon_ies = ies; 496 found->pub.beacon_ies = ies;
497 found->pub.len_beacon_ies = ielen; 497 found->pub.len_beacon_ies = ielen;
498 } 498 }
499 } 499 }
500 500
501 /* Override IEs if they were from a beacon before */ 501 /* Override IEs if they were from a beacon before */
502 if (information_elements_is_beacon_ies) { 502 if (information_elements_is_beacon_ies) {
503 found->pub.information_elements = 503 found->pub.information_elements =
504 found->pub.beacon_ies; 504 found->pub.beacon_ies;
505 found->pub.len_information_elements = 505 found->pub.len_information_elements =
506 found->pub.len_beacon_ies; 506 found->pub.len_beacon_ies;
507 } 507 }
508 } 508 }
509 509
510 kref_put(&res->ref, bss_release); 510 kref_put(&res->ref, bss_release);
511 } else { 511 } else {
512 /* this "consumes" the reference */ 512 /* this "consumes" the reference */
513 list_add_tail(&res->list, &dev->bss_list); 513 list_add_tail(&res->list, &dev->bss_list);
514 rb_insert_bss(dev, res); 514 rb_insert_bss(dev, res);
515 found = res; 515 found = res;
516 } 516 }
517 517
518 dev->bss_generation++; 518 dev->bss_generation++;
519 spin_unlock_bh(&dev->bss_lock); 519 spin_unlock_bh(&dev->bss_lock);
520 520
521 kref_get(&found->ref); 521 kref_get(&found->ref);
522 return found; 522 return found;
523 } 523 }
524 524
525 struct cfg80211_bss* 525 struct cfg80211_bss*
526 cfg80211_inform_bss(struct wiphy *wiphy, 526 cfg80211_inform_bss(struct wiphy *wiphy,
527 struct ieee80211_channel *channel, 527 struct ieee80211_channel *channel,
528 const u8 *bssid, 528 const u8 *bssid,
529 u64 timestamp, u16 capability, u16 beacon_interval, 529 u64 timestamp, u16 capability, u16 beacon_interval,
530 const u8 *ie, size_t ielen, 530 const u8 *ie, size_t ielen,
531 s32 signal, gfp_t gfp) 531 s32 signal, gfp_t gfp)
532 { 532 {
533 struct cfg80211_internal_bss *res; 533 struct cfg80211_internal_bss *res;
534 size_t privsz; 534 size_t privsz;
535 535
536 if (WARN_ON(!wiphy)) 536 if (WARN_ON(!wiphy))
537 return NULL; 537 return NULL;
538 538
539 privsz = wiphy->bss_priv_size; 539 privsz = wiphy->bss_priv_size;
540 540
541 if (WARN_ON(wiphy->signal_type == CFG80211_SIGNAL_TYPE_UNSPEC && 541 if (WARN_ON(wiphy->signal_type == CFG80211_SIGNAL_TYPE_UNSPEC &&
542 (signal < 0 || signal > 100))) 542 (signal < 0 || signal > 100)))
543 return NULL; 543 return NULL;
544 544
545 res = kzalloc(sizeof(*res) + privsz + ielen, gfp); 545 res = kzalloc(sizeof(*res) + privsz + ielen, gfp);
546 if (!res) 546 if (!res)
547 return NULL; 547 return NULL;
548 548
549 memcpy(res->pub.bssid, bssid, ETH_ALEN); 549 memcpy(res->pub.bssid, bssid, ETH_ALEN);
550 res->pub.channel = channel; 550 res->pub.channel = channel;
551 res->pub.signal = signal; 551 res->pub.signal = signal;
552 res->pub.tsf = timestamp; 552 res->pub.tsf = timestamp;
553 res->pub.beacon_interval = beacon_interval; 553 res->pub.beacon_interval = beacon_interval;
554 res->pub.capability = capability; 554 res->pub.capability = capability;
555 /* 555 /*
556 * Since we do not know here whether the IEs are from a Beacon or Probe 556 * Since we do not know here whether the IEs are from a Beacon or Probe
557 * Response frame, we need to pick one of the options and only use it 557 * Response frame, we need to pick one of the options and only use it
558 * with the driver that does not provide the full Beacon/Probe Response 558 * with the driver that does not provide the full Beacon/Probe Response
559 * frame. Use Beacon frame pointer to avoid indicating that this should 559 * frame. Use Beacon frame pointer to avoid indicating that this should
560 * override the information_elements pointer should we have received an 560 * override the information_elements pointer should we have received an
561 * earlier indication of Probe Response data. 561 * earlier indication of Probe Response data.
562 * 562 *
563 * The initial buffer for the IEs is allocated with the BSS entry and 563 * The initial buffer for the IEs is allocated with the BSS entry and
564 * is located after the private area. 564 * is located after the private area.
565 */ 565 */
566 res->pub.beacon_ies = (u8 *)res + sizeof(*res) + privsz; 566 res->pub.beacon_ies = (u8 *)res + sizeof(*res) + privsz;
567 memcpy(res->pub.beacon_ies, ie, ielen); 567 memcpy(res->pub.beacon_ies, ie, ielen);
568 res->pub.len_beacon_ies = ielen; 568 res->pub.len_beacon_ies = ielen;
569 res->pub.information_elements = res->pub.beacon_ies; 569 res->pub.information_elements = res->pub.beacon_ies;
570 res->pub.len_information_elements = res->pub.len_beacon_ies; 570 res->pub.len_information_elements = res->pub.len_beacon_ies;
571 571
572 kref_init(&res->ref); 572 kref_init(&res->ref);
573 573
574 res = cfg80211_bss_update(wiphy_to_dev(wiphy), res); 574 res = cfg80211_bss_update(wiphy_to_dev(wiphy), res);
575 if (!res) 575 if (!res)
576 return NULL; 576 return NULL;
577 577
578 if (res->pub.capability & WLAN_CAPABILITY_ESS) 578 if (res->pub.capability & WLAN_CAPABILITY_ESS)
579 regulatory_hint_found_beacon(wiphy, channel, gfp); 579 regulatory_hint_found_beacon(wiphy, channel, gfp);
580 580
581 /* cfg80211_bss_update gives us a referenced result */ 581 /* cfg80211_bss_update gives us a referenced result */
582 return &res->pub; 582 return &res->pub;
583 } 583 }
584 EXPORT_SYMBOL(cfg80211_inform_bss); 584 EXPORT_SYMBOL(cfg80211_inform_bss);
585 585
586 struct cfg80211_bss * 586 struct cfg80211_bss *
587 cfg80211_inform_bss_frame(struct wiphy *wiphy, 587 cfg80211_inform_bss_frame(struct wiphy *wiphy,
588 struct ieee80211_channel *channel, 588 struct ieee80211_channel *channel,
589 struct ieee80211_mgmt *mgmt, size_t len, 589 struct ieee80211_mgmt *mgmt, size_t len,
590 s32 signal, gfp_t gfp) 590 s32 signal, gfp_t gfp)
591 { 591 {
592 struct cfg80211_internal_bss *res; 592 struct cfg80211_internal_bss *res;
593 size_t ielen = len - offsetof(struct ieee80211_mgmt, 593 size_t ielen = len - offsetof(struct ieee80211_mgmt,
594 u.probe_resp.variable); 594 u.probe_resp.variable);
595 size_t privsz; 595 size_t privsz;
596 596
597 if (WARN_ON(!mgmt)) 597 if (WARN_ON(!mgmt))
598 return NULL; 598 return NULL;
599 599
600 if (WARN_ON(!wiphy)) 600 if (WARN_ON(!wiphy))
601 return NULL; 601 return NULL;
602 602
603 if (WARN_ON(wiphy->signal_type == CFG80211_SIGNAL_TYPE_UNSPEC && 603 if (WARN_ON(wiphy->signal_type == CFG80211_SIGNAL_TYPE_UNSPEC &&
604 (signal < 0 || signal > 100))) 604 (signal < 0 || signal > 100)))
605 return NULL; 605 return NULL;
606 606
607 if (WARN_ON(len < offsetof(struct ieee80211_mgmt, u.probe_resp.variable))) 607 if (WARN_ON(len < offsetof(struct ieee80211_mgmt, u.probe_resp.variable)))
608 return NULL; 608 return NULL;
609 609
610 privsz = wiphy->bss_priv_size; 610 privsz = wiphy->bss_priv_size;
611 611
612 res = kzalloc(sizeof(*res) + privsz + ielen, gfp); 612 res = kzalloc(sizeof(*res) + privsz + ielen, gfp);
613 if (!res) 613 if (!res)
614 return NULL; 614 return NULL;
615 615
616 memcpy(res->pub.bssid, mgmt->bssid, ETH_ALEN); 616 memcpy(res->pub.bssid, mgmt->bssid, ETH_ALEN);
617 res->pub.channel = channel; 617 res->pub.channel = channel;
618 res->pub.signal = signal; 618 res->pub.signal = signal;
619 res->pub.tsf = le64_to_cpu(mgmt->u.probe_resp.timestamp); 619 res->pub.tsf = le64_to_cpu(mgmt->u.probe_resp.timestamp);
620 res->pub.beacon_interval = le16_to_cpu(mgmt->u.probe_resp.beacon_int); 620 res->pub.beacon_interval = le16_to_cpu(mgmt->u.probe_resp.beacon_int);
621 res->pub.capability = le16_to_cpu(mgmt->u.probe_resp.capab_info); 621 res->pub.capability = le16_to_cpu(mgmt->u.probe_resp.capab_info);
622 /* 622 /*
623 * The initial buffer for the IEs is allocated with the BSS entry and 623 * The initial buffer for the IEs is allocated with the BSS entry and
624 * is located after the private area. 624 * is located after the private area.
625 */ 625 */
626 if (ieee80211_is_probe_resp(mgmt->frame_control)) { 626 if (ieee80211_is_probe_resp(mgmt->frame_control)) {
627 res->pub.proberesp_ies = (u8 *) res + sizeof(*res) + privsz; 627 res->pub.proberesp_ies = (u8 *) res + sizeof(*res) + privsz;
628 memcpy(res->pub.proberesp_ies, mgmt->u.probe_resp.variable, 628 memcpy(res->pub.proberesp_ies, mgmt->u.probe_resp.variable,
629 ielen); 629 ielen);
630 res->pub.len_proberesp_ies = ielen; 630 res->pub.len_proberesp_ies = ielen;
631 res->pub.information_elements = res->pub.proberesp_ies; 631 res->pub.information_elements = res->pub.proberesp_ies;
632 res->pub.len_information_elements = res->pub.len_proberesp_ies; 632 res->pub.len_information_elements = res->pub.len_proberesp_ies;
633 } else { 633 } else {
634 res->pub.beacon_ies = (u8 *) res + sizeof(*res) + privsz; 634 res->pub.beacon_ies = (u8 *) res + sizeof(*res) + privsz;
635 memcpy(res->pub.beacon_ies, mgmt->u.beacon.variable, ielen); 635 memcpy(res->pub.beacon_ies, mgmt->u.beacon.variable, ielen);
636 res->pub.len_beacon_ies = ielen; 636 res->pub.len_beacon_ies = ielen;
637 res->pub.information_elements = res->pub.beacon_ies; 637 res->pub.information_elements = res->pub.beacon_ies;
638 res->pub.len_information_elements = res->pub.len_beacon_ies; 638 res->pub.len_information_elements = res->pub.len_beacon_ies;
639 } 639 }
640 640
641 kref_init(&res->ref); 641 kref_init(&res->ref);
642 642
643 res = cfg80211_bss_update(wiphy_to_dev(wiphy), res); 643 res = cfg80211_bss_update(wiphy_to_dev(wiphy), res);
644 if (!res) 644 if (!res)
645 return NULL; 645 return NULL;
646 646
647 if (res->pub.capability & WLAN_CAPABILITY_ESS) 647 if (res->pub.capability & WLAN_CAPABILITY_ESS)
648 regulatory_hint_found_beacon(wiphy, channel, gfp); 648 regulatory_hint_found_beacon(wiphy, channel, gfp);
649 649
650 /* cfg80211_bss_update gives us a referenced result */ 650 /* cfg80211_bss_update gives us a referenced result */
651 return &res->pub; 651 return &res->pub;
652 } 652 }
653 EXPORT_SYMBOL(cfg80211_inform_bss_frame); 653 EXPORT_SYMBOL(cfg80211_inform_bss_frame);
654 654
655 void cfg80211_put_bss(struct cfg80211_bss *pub) 655 void cfg80211_put_bss(struct cfg80211_bss *pub)
656 { 656 {
657 struct cfg80211_internal_bss *bss; 657 struct cfg80211_internal_bss *bss;
658 658
659 if (!pub) 659 if (!pub)
660 return; 660 return;
661 661
662 bss = container_of(pub, struct cfg80211_internal_bss, pub); 662 bss = container_of(pub, struct cfg80211_internal_bss, pub);
663 kref_put(&bss->ref, bss_release); 663 kref_put(&bss->ref, bss_release);
664 } 664 }
665 EXPORT_SYMBOL(cfg80211_put_bss); 665 EXPORT_SYMBOL(cfg80211_put_bss);
666 666
667 void cfg80211_unlink_bss(struct wiphy *wiphy, struct cfg80211_bss *pub) 667 void cfg80211_unlink_bss(struct wiphy *wiphy, struct cfg80211_bss *pub)
668 { 668 {
669 struct cfg80211_registered_device *dev = wiphy_to_dev(wiphy); 669 struct cfg80211_registered_device *dev = wiphy_to_dev(wiphy);
670 struct cfg80211_internal_bss *bss; 670 struct cfg80211_internal_bss *bss;
671 671
672 if (WARN_ON(!pub)) 672 if (WARN_ON(!pub))
673 return; 673 return;
674 674
675 bss = container_of(pub, struct cfg80211_internal_bss, pub); 675 bss = container_of(pub, struct cfg80211_internal_bss, pub);
676 676
677 spin_lock_bh(&dev->bss_lock); 677 spin_lock_bh(&dev->bss_lock);
678 if (!list_empty(&bss->list)) { 678 if (!list_empty(&bss->list)) {
679 __cfg80211_unlink_bss(dev, bss); 679 __cfg80211_unlink_bss(dev, bss);
680 dev->bss_generation++; 680 dev->bss_generation++;
681 } 681 }
682 spin_unlock_bh(&dev->bss_lock); 682 spin_unlock_bh(&dev->bss_lock);
683 } 683 }
684 EXPORT_SYMBOL(cfg80211_unlink_bss); 684 EXPORT_SYMBOL(cfg80211_unlink_bss);
685 685
686 #ifdef CONFIG_CFG80211_WEXT 686 #ifdef CONFIG_CFG80211_WEXT
687 int cfg80211_wext_siwscan(struct net_device *dev, 687 int cfg80211_wext_siwscan(struct net_device *dev,
688 struct iw_request_info *info, 688 struct iw_request_info *info,
689 union iwreq_data *wrqu, char *extra) 689 union iwreq_data *wrqu, char *extra)
690 { 690 {
691 struct cfg80211_registered_device *rdev; 691 struct cfg80211_registered_device *rdev;
692 struct wiphy *wiphy; 692 struct wiphy *wiphy;
693 struct iw_scan_req *wreq = NULL; 693 struct iw_scan_req *wreq = NULL;
694 struct cfg80211_scan_request *creq = NULL; 694 struct cfg80211_scan_request *creq = NULL;
695 int i, err, n_channels = 0; 695 int i, err, n_channels = 0;
696 enum ieee80211_band band; 696 enum ieee80211_band band;
697 697
698 if (!netif_running(dev)) 698 if (!netif_running(dev))
699 return -ENETDOWN; 699 return -ENETDOWN;
700 700
701 if (wrqu->data.length == sizeof(struct iw_scan_req)) 701 if (wrqu->data.length == sizeof(struct iw_scan_req))
702 wreq = (struct iw_scan_req *)extra; 702 wreq = (struct iw_scan_req *)extra;
703 703
704 rdev = cfg80211_get_dev_from_ifindex(dev_net(dev), dev->ifindex); 704 rdev = cfg80211_get_dev_from_ifindex(dev_net(dev), dev->ifindex);
705 705
706 if (IS_ERR(rdev)) 706 if (IS_ERR(rdev))
707 return PTR_ERR(rdev); 707 return PTR_ERR(rdev);
708 708
709 if (rdev->scan_req) { 709 if (rdev->scan_req) {
710 err = -EBUSY; 710 err = -EBUSY;
711 goto out; 711 goto out;
712 } 712 }
713 713
714 wiphy = &rdev->wiphy; 714 wiphy = &rdev->wiphy;
715 715
716 /* Determine number of channels, needed to allocate creq */ 716 /* Determine number of channels, needed to allocate creq */
717 if (wreq && wreq->num_channels) 717 if (wreq && wreq->num_channels)
718 n_channels = wreq->num_channels; 718 n_channels = wreq->num_channels;
719 else { 719 else {
720 for (band = 0; band < IEEE80211_NUM_BANDS; band++) 720 for (band = 0; band < IEEE80211_NUM_BANDS; band++)
721 if (wiphy->bands[band]) 721 if (wiphy->bands[band])
722 n_channels += wiphy->bands[band]->n_channels; 722 n_channels += wiphy->bands[band]->n_channels;
723 } 723 }
724 724
725 creq = kzalloc(sizeof(*creq) + sizeof(struct cfg80211_ssid) + 725 creq = kzalloc(sizeof(*creq) + sizeof(struct cfg80211_ssid) +
726 n_channels * sizeof(void *), 726 n_channels * sizeof(void *),
727 GFP_ATOMIC); 727 GFP_ATOMIC);
728 if (!creq) { 728 if (!creq) {
729 err = -ENOMEM; 729 err = -ENOMEM;
730 goto out; 730 goto out;
731 } 731 }
732 732
733 creq->wiphy = wiphy; 733 creq->wiphy = wiphy;
734 creq->dev = dev; 734 creq->dev = dev;
735 /* SSIDs come after channels */ 735 /* SSIDs come after channels */
736 creq->ssids = (void *)&creq->channels[n_channels]; 736 creq->ssids = (void *)&creq->channels[n_channels];
737 creq->n_channels = n_channels; 737 creq->n_channels = n_channels;
738 creq->n_ssids = 1; 738 creq->n_ssids = 1;
739 739
740 /* translate "Scan on frequencies" request */ 740 /* translate "Scan on frequencies" request */
741 i = 0; 741 i = 0;
742 for (band = 0; band < IEEE80211_NUM_BANDS; band++) { 742 for (band = 0; band < IEEE80211_NUM_BANDS; band++) {
743 int j; 743 int j;
744 744
745 if (!wiphy->bands[band]) 745 if (!wiphy->bands[band])
746 continue; 746 continue;
747 747
748 for (j = 0; j < wiphy->bands[band]->n_channels; j++) { 748 for (j = 0; j < wiphy->bands[band]->n_channels; j++) {
749 /* ignore disabled channels */ 749 /* ignore disabled channels */
750 if (wiphy->bands[band]->channels[j].flags & 750 if (wiphy->bands[band]->channels[j].flags &
751 IEEE80211_CHAN_DISABLED) 751 IEEE80211_CHAN_DISABLED)
752 continue; 752 continue;
753 753
754 /* If we have a wireless request structure and the 754 /* If we have a wireless request structure and the
755 * wireless request specifies frequencies, then search 755 * wireless request specifies frequencies, then search
756 * for the matching hardware channel. 756 * for the matching hardware channel.
757 */ 757 */
758 if (wreq && wreq->num_channels) { 758 if (wreq && wreq->num_channels) {
759 int k; 759 int k;
760 int wiphy_freq = wiphy->bands[band]->channels[j].center_freq; 760 int wiphy_freq = wiphy->bands[band]->channels[j].center_freq;
761 for (k = 0; k < wreq->num_channels; k++) { 761 for (k = 0; k < wreq->num_channels; k++) {
762 int wext_freq = cfg80211_wext_freq(wiphy, &wreq->channel_list[k]); 762 int wext_freq = cfg80211_wext_freq(wiphy, &wreq->channel_list[k]);
763 if (wext_freq == wiphy_freq) 763 if (wext_freq == wiphy_freq)
764 goto wext_freq_found; 764 goto wext_freq_found;
765 } 765 }
766 goto wext_freq_not_found; 766 goto wext_freq_not_found;
767 } 767 }
768 768
769 wext_freq_found: 769 wext_freq_found:
770 creq->channels[i] = &wiphy->bands[band]->channels[j]; 770 creq->channels[i] = &wiphy->bands[band]->channels[j];
771 i++; 771 i++;
772 wext_freq_not_found: ; 772 wext_freq_not_found: ;
773 } 773 }
774 } 774 }
775 /* No channels found? */ 775 /* No channels found? */
776 if (!i) { 776 if (!i) {
777 err = -EINVAL; 777 err = -EINVAL;
778 goto out; 778 goto out;
779 } 779 }
780 780
781 /* Set real number of channels specified in creq->channels[] */ 781 /* Set real number of channels specified in creq->channels[] */
782 creq->n_channels = i; 782 creq->n_channels = i;
783 783
784 /* translate "Scan for SSID" request */ 784 /* translate "Scan for SSID" request */
785 if (wreq) { 785 if (wreq) {
786 if (wrqu->data.flags & IW_SCAN_THIS_ESSID) { 786 if (wrqu->data.flags & IW_SCAN_THIS_ESSID) {
787 if (wreq->essid_len > IEEE80211_MAX_SSID_LEN) { 787 if (wreq->essid_len > IEEE80211_MAX_SSID_LEN) {
788 err = -EINVAL; 788 err = -EINVAL;
789 goto out; 789 goto out;
790 } 790 }
791 memcpy(creq->ssids[0].ssid, wreq->essid, wreq->essid_len); 791 memcpy(creq->ssids[0].ssid, wreq->essid, wreq->essid_len);
792 creq->ssids[0].ssid_len = wreq->essid_len; 792 creq->ssids[0].ssid_len = wreq->essid_len;
793 } 793 }
794 if (wreq->scan_type == IW_SCAN_TYPE_PASSIVE) 794 if (wreq->scan_type == IW_SCAN_TYPE_PASSIVE)
795 creq->n_ssids = 0; 795 creq->n_ssids = 0;
796 } 796 }
797 797
798 rdev->scan_req = creq; 798 rdev->scan_req = creq;
799 err = rdev->ops->scan(wiphy, dev, creq); 799 err = rdev->ops->scan(wiphy, dev, creq);
800 if (err) { 800 if (err) {
801 rdev->scan_req = NULL; 801 rdev->scan_req = NULL;
802 /* creq will be freed below */ 802 /* creq will be freed below */
803 } else { 803 } else {
804 nl80211_send_scan_start(rdev, dev); 804 nl80211_send_scan_start(rdev, dev);
805 /* creq now owned by driver */ 805 /* creq now owned by driver */
806 creq = NULL; 806 creq = NULL;
807 dev_hold(dev); 807 dev_hold(dev);
808 } 808 }
809 out: 809 out:
810 kfree(creq); 810 kfree(creq);
811 cfg80211_unlock_rdev(rdev); 811 cfg80211_unlock_rdev(rdev);
812 return err; 812 return err;
813 } 813 }
814 EXPORT_SYMBOL_GPL(cfg80211_wext_siwscan); 814 EXPORT_SYMBOL_GPL(cfg80211_wext_siwscan);
815 815
816 static void ieee80211_scan_add_ies(struct iw_request_info *info, 816 static void ieee80211_scan_add_ies(struct iw_request_info *info,
817 struct cfg80211_bss *bss, 817 struct cfg80211_bss *bss,
818 char **current_ev, char *end_buf) 818 char **current_ev, char *end_buf)
819 { 819 {
820 u8 *pos, *end, *next; 820 u8 *pos, *end, *next;
821 struct iw_event iwe; 821 struct iw_event iwe;
822 822
823 if (!bss->information_elements || 823 if (!bss->information_elements ||
824 !bss->len_information_elements) 824 !bss->len_information_elements)
825 return; 825 return;
826 826
827 /* 827 /*
828 * If needed, fragment the IEs buffer (at IE boundaries) into short 828 * If needed, fragment the IEs buffer (at IE boundaries) into short
829 * enough fragments to fit into IW_GENERIC_IE_MAX octet messages. 829 * enough fragments to fit into IW_GENERIC_IE_MAX octet messages.
830 */ 830 */
831 pos = bss->information_elements; 831 pos = bss->information_elements;
832 end = pos + bss->len_information_elements; 832 end = pos + bss->len_information_elements;
833 833
834 while (end - pos > IW_GENERIC_IE_MAX) { 834 while (end - pos > IW_GENERIC_IE_MAX) {
835 next = pos + 2 + pos[1]; 835 next = pos + 2 + pos[1];
836 while (next + 2 + next[1] - pos < IW_GENERIC_IE_MAX) 836 while (next + 2 + next[1] - pos < IW_GENERIC_IE_MAX)
837 next = next + 2 + next[1]; 837 next = next + 2 + next[1];
838 838
839 memset(&iwe, 0, sizeof(iwe)); 839 memset(&iwe, 0, sizeof(iwe));
840 iwe.cmd = IWEVGENIE; 840 iwe.cmd = IWEVGENIE;
841 iwe.u.data.length = next - pos; 841 iwe.u.data.length = next - pos;
842 *current_ev = iwe_stream_add_point(info, *current_ev, 842 *current_ev = iwe_stream_add_point(info, *current_ev,
843 end_buf, &iwe, pos); 843 end_buf, &iwe, pos);
844 844
845 pos = next; 845 pos = next;
846 } 846 }
847 847
848 if (end > pos) { 848 if (end > pos) {
849 memset(&iwe, 0, sizeof(iwe)); 849 memset(&iwe, 0, sizeof(iwe));
850 iwe.cmd = IWEVGENIE; 850 iwe.cmd = IWEVGENIE;
851 iwe.u.data.length = end - pos; 851 iwe.u.data.length = end - pos;
852 *current_ev = iwe_stream_add_point(info, *current_ev, 852 *current_ev = iwe_stream_add_point(info, *current_ev,
853 end_buf, &iwe, pos); 853 end_buf, &iwe, pos);
854 } 854 }
855 } 855 }
856 856
857 static inline unsigned int elapsed_jiffies_msecs(unsigned long start) 857 static inline unsigned int elapsed_jiffies_msecs(unsigned long start)
858 { 858 {
859 unsigned long end = jiffies; 859 unsigned long end = jiffies;
860 860
861 if (end >= start) 861 if (end >= start)
862 return jiffies_to_msecs(end - start); 862 return jiffies_to_msecs(end - start);
863 863
864 return jiffies_to_msecs(end + (MAX_JIFFY_OFFSET - start) + 1); 864 return jiffies_to_msecs(end + (MAX_JIFFY_OFFSET - start) + 1);
865 } 865 }
866 866
867 static char * 867 static char *
868 ieee80211_bss(struct wiphy *wiphy, struct iw_request_info *info, 868 ieee80211_bss(struct wiphy *wiphy, struct iw_request_info *info,
869 struct cfg80211_internal_bss *bss, char *current_ev, 869 struct cfg80211_internal_bss *bss, char *current_ev,
870 char *end_buf) 870 char *end_buf)
871 { 871 {
872 struct iw_event iwe; 872 struct iw_event iwe;
873 u8 *buf, *cfg, *p; 873 u8 *buf, *cfg, *p;
874 u8 *ie = bss->pub.information_elements; 874 u8 *ie = bss->pub.information_elements;
875 int rem = bss->pub.len_information_elements, i, sig; 875 int rem = bss->pub.len_information_elements, i, sig;
876 bool ismesh = false; 876 bool ismesh = false;
877 877
878 memset(&iwe, 0, sizeof(iwe)); 878 memset(&iwe, 0, sizeof(iwe));
879 iwe.cmd = SIOCGIWAP; 879 iwe.cmd = SIOCGIWAP;
880 iwe.u.ap_addr.sa_family = ARPHRD_ETHER; 880 iwe.u.ap_addr.sa_family = ARPHRD_ETHER;
881 memcpy(iwe.u.ap_addr.sa_data, bss->pub.bssid, ETH_ALEN); 881 memcpy(iwe.u.ap_addr.sa_data, bss->pub.bssid, ETH_ALEN);
882 current_ev = iwe_stream_add_event(info, current_ev, end_buf, &iwe, 882 current_ev = iwe_stream_add_event(info, current_ev, end_buf, &iwe,
883 IW_EV_ADDR_LEN); 883 IW_EV_ADDR_LEN);
884 884
885 memset(&iwe, 0, sizeof(iwe)); 885 memset(&iwe, 0, sizeof(iwe));
886 iwe.cmd = SIOCGIWFREQ; 886 iwe.cmd = SIOCGIWFREQ;
887 iwe.u.freq.m = ieee80211_frequency_to_channel(bss->pub.channel->center_freq); 887 iwe.u.freq.m = ieee80211_frequency_to_channel(bss->pub.channel->center_freq);
888 iwe.u.freq.e = 0; 888 iwe.u.freq.e = 0;
889 current_ev = iwe_stream_add_event(info, current_ev, end_buf, &iwe, 889 current_ev = iwe_stream_add_event(info, current_ev, end_buf, &iwe,
890 IW_EV_FREQ_LEN); 890 IW_EV_FREQ_LEN);
891 891
892 memset(&iwe, 0, sizeof(iwe)); 892 memset(&iwe, 0, sizeof(iwe));
893 iwe.cmd = SIOCGIWFREQ; 893 iwe.cmd = SIOCGIWFREQ;
894 iwe.u.freq.m = bss->pub.channel->center_freq; 894 iwe.u.freq.m = bss->pub.channel->center_freq;
895 iwe.u.freq.e = 6; 895 iwe.u.freq.e = 6;
896 current_ev = iwe_stream_add_event(info, current_ev, end_buf, &iwe, 896 current_ev = iwe_stream_add_event(info, current_ev, end_buf, &iwe,
897 IW_EV_FREQ_LEN); 897 IW_EV_FREQ_LEN);
898 898
899 if (wiphy->signal_type != CFG80211_SIGNAL_TYPE_NONE) { 899 if (wiphy->signal_type != CFG80211_SIGNAL_TYPE_NONE) {
900 memset(&iwe, 0, sizeof(iwe)); 900 memset(&iwe, 0, sizeof(iwe));
901 iwe.cmd = IWEVQUAL; 901 iwe.cmd = IWEVQUAL;
902 iwe.u.qual.updated = IW_QUAL_LEVEL_UPDATED | 902 iwe.u.qual.updated = IW_QUAL_LEVEL_UPDATED |
903 IW_QUAL_NOISE_INVALID | 903 IW_QUAL_NOISE_INVALID |
904 IW_QUAL_QUAL_UPDATED; 904 IW_QUAL_QUAL_UPDATED;
905 switch (wiphy->signal_type) { 905 switch (wiphy->signal_type) {
906 case CFG80211_SIGNAL_TYPE_MBM: 906 case CFG80211_SIGNAL_TYPE_MBM:
907 sig = bss->pub.signal / 100; 907 sig = bss->pub.signal / 100;
908 iwe.u.qual.level = sig; 908 iwe.u.qual.level = sig;
909 iwe.u.qual.updated |= IW_QUAL_DBM; 909 iwe.u.qual.updated |= IW_QUAL_DBM;
910 if (sig < -110) /* rather bad */ 910 if (sig < -110) /* rather bad */
911 sig = -110; 911 sig = -110;
912 else if (sig > -40) /* perfect */ 912 else if (sig > -40) /* perfect */
913 sig = -40; 913 sig = -40;
914 /* will give a range of 0 .. 70 */ 914 /* will give a range of 0 .. 70 */
915 iwe.u.qual.qual = sig + 110; 915 iwe.u.qual.qual = sig + 110;
916 break; 916 break;
917 case CFG80211_SIGNAL_TYPE_UNSPEC: 917 case CFG80211_SIGNAL_TYPE_UNSPEC:
918 iwe.u.qual.level = bss->pub.signal; 918 iwe.u.qual.level = bss->pub.signal;
919 /* will give range 0 .. 100 */ 919 /* will give range 0 .. 100 */
920 iwe.u.qual.qual = bss->pub.signal; 920 iwe.u.qual.qual = bss->pub.signal;
921 break; 921 break;
922 default: 922 default:
923 /* not reached */ 923 /* not reached */
924 break; 924 break;
925 } 925 }
926 current_ev = iwe_stream_add_event(info, current_ev, end_buf, 926 current_ev = iwe_stream_add_event(info, current_ev, end_buf,
927 &iwe, IW_EV_QUAL_LEN); 927 &iwe, IW_EV_QUAL_LEN);
928 } 928 }
929 929
930 memset(&iwe, 0, sizeof(iwe)); 930 memset(&iwe, 0, sizeof(iwe));
931 iwe.cmd = SIOCGIWENCODE; 931 iwe.cmd = SIOCGIWENCODE;
932 if (bss->pub.capability & WLAN_CAPABILITY_PRIVACY) 932 if (bss->pub.capability & WLAN_CAPABILITY_PRIVACY)
933 iwe.u.data.flags = IW_ENCODE_ENABLED | IW_ENCODE_NOKEY; 933 iwe.u.data.flags = IW_ENCODE_ENABLED | IW_ENCODE_NOKEY;
934 else 934 else
935 iwe.u.data.flags = IW_ENCODE_DISABLED; 935 iwe.u.data.flags = IW_ENCODE_DISABLED;
936 iwe.u.data.length = 0; 936 iwe.u.data.length = 0;
937 current_ev = iwe_stream_add_point(info, current_ev, end_buf, 937 current_ev = iwe_stream_add_point(info, current_ev, end_buf,
938 &iwe, ""); 938 &iwe, "");
939 939
940 while (rem >= 2) { 940 while (rem >= 2) {
941 /* invalid data */ 941 /* invalid data */
942 if (ie[1] > rem - 2) 942 if (ie[1] > rem - 2)
943 break; 943 break;
944 944
945 switch (ie[0]) { 945 switch (ie[0]) {
946 case WLAN_EID_SSID: 946 case WLAN_EID_SSID:
947 memset(&iwe, 0, sizeof(iwe)); 947 memset(&iwe, 0, sizeof(iwe));
948 iwe.cmd = SIOCGIWESSID; 948 iwe.cmd = SIOCGIWESSID;
949 iwe.u.data.length = ie[1]; 949 iwe.u.data.length = ie[1];
950 iwe.u.data.flags = 1; 950 iwe.u.data.flags = 1;
951 current_ev = iwe_stream_add_point(info, current_ev, end_buf, 951 current_ev = iwe_stream_add_point(info, current_ev, end_buf,
952 &iwe, ie + 2); 952 &iwe, ie + 2);
953 break; 953 break;
954 case WLAN_EID_MESH_ID: 954 case WLAN_EID_MESH_ID:
955 memset(&iwe, 0, sizeof(iwe)); 955 memset(&iwe, 0, sizeof(iwe));
956 iwe.cmd = SIOCGIWESSID; 956 iwe.cmd = SIOCGIWESSID;
957 iwe.u.data.length = ie[1]; 957 iwe.u.data.length = ie[1];
958 iwe.u.data.flags = 1; 958 iwe.u.data.flags = 1;
959 current_ev = iwe_stream_add_point(info, current_ev, end_buf, 959 current_ev = iwe_stream_add_point(info, current_ev, end_buf,
960 &iwe, ie + 2); 960 &iwe, ie + 2);
961 break; 961 break;
962 case WLAN_EID_MESH_CONFIG: 962 case WLAN_EID_MESH_CONFIG:
963 ismesh = true; 963 ismesh = true;
964 if (ie[1] != sizeof(struct ieee80211_meshconf_ie)) 964 if (ie[1] != sizeof(struct ieee80211_meshconf_ie))
965 break; 965 break;
966 buf = kmalloc(50, GFP_ATOMIC); 966 buf = kmalloc(50, GFP_ATOMIC);
967 if (!buf) 967 if (!buf)
968 break; 968 break;
969 cfg = ie + 2; 969 cfg = ie + 2;
970 memset(&iwe, 0, sizeof(iwe)); 970 memset(&iwe, 0, sizeof(iwe));
971 iwe.cmd = IWEVCUSTOM; 971 iwe.cmd = IWEVCUSTOM;
972 sprintf(buf, "Mesh Network Path Selection Protocol ID: " 972 sprintf(buf, "Mesh Network Path Selection Protocol ID: "
973 "0x%02X", cfg[0]); 973 "0x%02X", cfg[0]);
974 iwe.u.data.length = strlen(buf); 974 iwe.u.data.length = strlen(buf);
975 current_ev = iwe_stream_add_point(info, current_ev, 975 current_ev = iwe_stream_add_point(info, current_ev,
976 end_buf, 976 end_buf,
977 &iwe, buf); 977 &iwe, buf);
978 sprintf(buf, "Path Selection Metric ID: 0x%02X", 978 sprintf(buf, "Path Selection Metric ID: 0x%02X",
979 cfg[1]); 979 cfg[1]);
980 iwe.u.data.length = strlen(buf); 980 iwe.u.data.length = strlen(buf);
981 current_ev = iwe_stream_add_point(info, current_ev, 981 current_ev = iwe_stream_add_point(info, current_ev,
982 end_buf, 982 end_buf,
983 &iwe, buf); 983 &iwe, buf);
984 sprintf(buf, "Congestion Control Mode ID: 0x%02X", 984 sprintf(buf, "Congestion Control Mode ID: 0x%02X",
985 cfg[2]); 985 cfg[2]);
986 iwe.u.data.length = strlen(buf); 986 iwe.u.data.length = strlen(buf);
987 current_ev = iwe_stream_add_point(info, current_ev, 987 current_ev = iwe_stream_add_point(info, current_ev,
988 end_buf, 988 end_buf,
989 &iwe, buf); 989 &iwe, buf);
990 sprintf(buf, "Synchronization ID: 0x%02X", cfg[3]); 990 sprintf(buf, "Synchronization ID: 0x%02X", cfg[3]);
991 iwe.u.data.length = strlen(buf); 991 iwe.u.data.length = strlen(buf);
992 current_ev = iwe_stream_add_point(info, current_ev, 992 current_ev = iwe_stream_add_point(info, current_ev,
993 end_buf, 993 end_buf,
994 &iwe, buf); 994 &iwe, buf);
995 sprintf(buf, "Authentication ID: 0x%02X", cfg[4]); 995 sprintf(buf, "Authentication ID: 0x%02X", cfg[4]);
996 iwe.u.data.length = strlen(buf); 996 iwe.u.data.length = strlen(buf);
997 current_ev = iwe_stream_add_point(info, current_ev, 997 current_ev = iwe_stream_add_point(info, current_ev,
998 end_buf, 998 end_buf,
999 &iwe, buf); 999 &iwe, buf);
1000 sprintf(buf, "Formation Info: 0x%02X", cfg[5]); 1000 sprintf(buf, "Formation Info: 0x%02X", cfg[5]);
1001 iwe.u.data.length = strlen(buf); 1001 iwe.u.data.length = strlen(buf);
1002 current_ev = iwe_stream_add_point(info, current_ev, 1002 current_ev = iwe_stream_add_point(info, current_ev,
1003 end_buf, 1003 end_buf,
1004 &iwe, buf); 1004 &iwe, buf);
1005 sprintf(buf, "Capabilities: 0x%02X", cfg[6]); 1005 sprintf(buf, "Capabilities: 0x%02X", cfg[6]);
1006 iwe.u.data.length = strlen(buf); 1006 iwe.u.data.length = strlen(buf);
1007 current_ev = iwe_stream_add_point(info, current_ev, 1007 current_ev = iwe_stream_add_point(info, current_ev,
1008 end_buf, 1008 end_buf,
1009 &iwe, buf); 1009 &iwe, buf);
1010 kfree(buf); 1010 kfree(buf);
1011 break; 1011 break;
1012 case WLAN_EID_SUPP_RATES: 1012 case WLAN_EID_SUPP_RATES:
1013 case WLAN_EID_EXT_SUPP_RATES: 1013 case WLAN_EID_EXT_SUPP_RATES:
1014 /* display all supported rates in readable format */ 1014 /* display all supported rates in readable format */
1015 p = current_ev + iwe_stream_lcp_len(info); 1015 p = current_ev + iwe_stream_lcp_len(info);
1016 1016
1017 memset(&iwe, 0, sizeof(iwe)); 1017 memset(&iwe, 0, sizeof(iwe));
1018 iwe.cmd = SIOCGIWRATE; 1018 iwe.cmd = SIOCGIWRATE;
1019 /* Those two flags are ignored... */ 1019 /* Those two flags are ignored... */
1020 iwe.u.bitrate.fixed = iwe.u.bitrate.disabled = 0; 1020 iwe.u.bitrate.fixed = iwe.u.bitrate.disabled = 0;
1021 1021
1022 for (i = 0; i < ie[1]; i++) { 1022 for (i = 0; i < ie[1]; i++) {
1023 iwe.u.bitrate.value = 1023 iwe.u.bitrate.value =
1024 ((ie[i + 2] & 0x7f) * 500000); 1024 ((ie[i + 2] & 0x7f) * 500000);
1025 p = iwe_stream_add_value(info, current_ev, p, 1025 p = iwe_stream_add_value(info, current_ev, p,
1026 end_buf, &iwe, IW_EV_PARAM_LEN); 1026 end_buf, &iwe, IW_EV_PARAM_LEN);
1027 } 1027 }
1028 current_ev = p; 1028 current_ev = p;
1029 break; 1029 break;
1030 } 1030 }
1031 rem -= ie[1] + 2; 1031 rem -= ie[1] + 2;
1032 ie += ie[1] + 2; 1032 ie += ie[1] + 2;
1033 } 1033 }
1034 1034
1035 if (bss->pub.capability & (WLAN_CAPABILITY_ESS | WLAN_CAPABILITY_IBSS) || 1035 if (bss->pub.capability & (WLAN_CAPABILITY_ESS | WLAN_CAPABILITY_IBSS) ||
1036 ismesh) { 1036 ismesh) {
1037 memset(&iwe, 0, sizeof(iwe)); 1037 memset(&iwe, 0, sizeof(iwe));
1038 iwe.cmd = SIOCGIWMODE; 1038 iwe.cmd = SIOCGIWMODE;
1039 if (ismesh) 1039 if (ismesh)
1040 iwe.u.mode = IW_MODE_MESH; 1040 iwe.u.mode = IW_MODE_MESH;
1041 else if (bss->pub.capability & WLAN_CAPABILITY_ESS) 1041 else if (bss->pub.capability & WLAN_CAPABILITY_ESS)
1042 iwe.u.mode = IW_MODE_MASTER; 1042 iwe.u.mode = IW_MODE_MASTER;
1043 else 1043 else
1044 iwe.u.mode = IW_MODE_ADHOC; 1044 iwe.u.mode = IW_MODE_ADHOC;
1045 current_ev = iwe_stream_add_event(info, current_ev, end_buf, 1045 current_ev = iwe_stream_add_event(info, current_ev, end_buf,
1046 &iwe, IW_EV_UINT_LEN); 1046 &iwe, IW_EV_UINT_LEN);
1047 } 1047 }
1048 1048
1049 buf = kmalloc(30, GFP_ATOMIC); 1049 buf = kmalloc(30, GFP_ATOMIC);
1050 if (buf) { 1050 if (buf) {
1051 memset(&iwe, 0, sizeof(iwe)); 1051 memset(&iwe, 0, sizeof(iwe));
1052 iwe.cmd = IWEVCUSTOM; 1052 iwe.cmd = IWEVCUSTOM;
1053 sprintf(buf, "tsf=%016llx", (unsigned long long)(bss->pub.tsf)); 1053 sprintf(buf, "tsf=%016llx", (unsigned long long)(bss->pub.tsf));
1054 iwe.u.data.length = strlen(buf); 1054 iwe.u.data.length = strlen(buf);
1055 current_ev = iwe_stream_add_point(info, current_ev, end_buf, 1055 current_ev = iwe_stream_add_point(info, current_ev, end_buf,
1056 &iwe, buf); 1056 &iwe, buf);
1057 memset(&iwe, 0, sizeof(iwe)); 1057 memset(&iwe, 0, sizeof(iwe));
1058 iwe.cmd = IWEVCUSTOM; 1058 iwe.cmd = IWEVCUSTOM;
1059 sprintf(buf, " Last beacon: %ums ago", 1059 sprintf(buf, " Last beacon: %ums ago",
1060 elapsed_jiffies_msecs(bss->ts)); 1060 elapsed_jiffies_msecs(bss->ts));
1061 iwe.u.data.length = strlen(buf); 1061 iwe.u.data.length = strlen(buf);
1062 current_ev = iwe_stream_add_point(info, current_ev, 1062 current_ev = iwe_stream_add_point(info, current_ev,
1063 end_buf, &iwe, buf); 1063 end_buf, &iwe, buf);
1064 kfree(buf); 1064 kfree(buf);
1065 } 1065 }
1066 1066
1067 ieee80211_scan_add_ies(info, &bss->pub, &current_ev, end_buf); 1067 ieee80211_scan_add_ies(info, &bss->pub, &current_ev, end_buf);
1068 1068
1069 return current_ev; 1069 return current_ev;
1070 } 1070 }
1071 1071
1072 1072
1073 static int ieee80211_scan_results(struct cfg80211_registered_device *dev, 1073 static int ieee80211_scan_results(struct cfg80211_registered_device *dev,
1074 struct iw_request_info *info, 1074 struct iw_request_info *info,
1075 char *buf, size_t len) 1075 char *buf, size_t len)
1076 { 1076 {
1077 char *current_ev = buf; 1077 char *current_ev = buf;
1078 char *end_buf = buf + len; 1078 char *end_buf = buf + len;
1079 struct cfg80211_internal_bss *bss; 1079 struct cfg80211_internal_bss *bss;
1080 1080
1081 spin_lock_bh(&dev->bss_lock); 1081 spin_lock_bh(&dev->bss_lock);
1082 cfg80211_bss_expire(dev); 1082 cfg80211_bss_expire(dev);
1083 1083
1084 list_for_each_entry(bss, &dev->bss_list, list) { 1084 list_for_each_entry(bss, &dev->bss_list, list) {
1085 if (buf + len - current_ev <= IW_EV_ADDR_LEN) { 1085 if (buf + len - current_ev <= IW_EV_ADDR_LEN) {
1086 spin_unlock_bh(&dev->bss_lock); 1086 spin_unlock_bh(&dev->bss_lock);
1087 return -E2BIG; 1087 return -E2BIG;
1088 } 1088 }
1089 current_ev = ieee80211_bss(&dev->wiphy, info, bss, 1089 current_ev = ieee80211_bss(&dev->wiphy, info, bss,
1090 current_ev, end_buf); 1090 current_ev, end_buf);
1091 } 1091 }
1092 spin_unlock_bh(&dev->bss_lock); 1092 spin_unlock_bh(&dev->bss_lock);
1093 return current_ev - buf; 1093 return current_ev - buf;
1094 } 1094 }
1095 1095
1096 1096
1097 int cfg80211_wext_giwscan(struct net_device *dev, 1097 int cfg80211_wext_giwscan(struct net_device *dev,
1098 struct iw_request_info *info, 1098 struct iw_request_info *info,
1099 struct iw_point *data, char *extra) 1099 struct iw_point *data, char *extra)
1100 { 1100 {
1101 struct cfg80211_registered_device *rdev; 1101 struct cfg80211_registered_device *rdev;
1102 int res; 1102 int res;
1103 1103
1104 if (!netif_running(dev)) 1104 if (!netif_running(dev))
1105 return -ENETDOWN; 1105 return -ENETDOWN;
1106 1106
1107 rdev = cfg80211_get_dev_from_ifindex(dev_net(dev), dev->ifindex); 1107 rdev = cfg80211_get_dev_from_ifindex(dev_net(dev), dev->ifindex);
1108 1108
1109 if (IS_ERR(rdev)) 1109 if (IS_ERR(rdev))
1110 return PTR_ERR(rdev); 1110 return PTR_ERR(rdev);
1111 1111
1112 if (rdev->scan_req) { 1112 if (rdev->scan_req) {
1113 res = -EAGAIN; 1113 res = -EAGAIN;
1114 goto out; 1114 goto out;
1115 } 1115 }
1116 1116
1117 res = ieee80211_scan_results(rdev, info, extra, data->length); 1117 res = ieee80211_scan_results(rdev, info, extra, data->length);
1118 data->length = 0; 1118 data->length = 0;
1119 if (res >= 0) { 1119 if (res >= 0) {
1120 data->length = res; 1120 data->length = res;
1121 res = 0; 1121 res = 0;
1122 } 1122 }
1123 1123
1124 out: 1124 out:
1125 cfg80211_unlock_rdev(rdev); 1125 cfg80211_unlock_rdev(rdev);
1126 return res; 1126 return res;