Commit | Line | Data |
---|---|---|
8318d78a JB |
1 | /* |
2 | * Wireless utility functions | |
3 | * | |
d3236553 | 4 | * Copyright 2007-2009 Johannes Berg <johannes@sipsolutions.net> |
8318d78a | 5 | */ |
bc3b2d7f | 6 | #include <linux/export.h> |
d3236553 | 7 | #include <linux/bitops.h> |
e31a16d6 | 8 | #include <linux/etherdevice.h> |
5a0e3ad6 | 9 | #include <linux/slab.h> |
d3236553 | 10 | #include <net/cfg80211.h> |
e31a16d6 | 11 | #include <net/ip.h> |
b156579b | 12 | #include <net/dsfield.h> |
c6ca5e28 | 13 | #include <linux/if_vlan.h> |
960d97f9 | 14 | #include <linux/mpls.h> |
8318d78a | 15 | #include "core.h" |
e35e4d28 HG |
16 | #include "rdev-ops.h" |
17 | ||
8318d78a | 18 | |
bd815252 JB |
19 | struct ieee80211_rate * |
20 | ieee80211_get_response_rate(struct ieee80211_supported_band *sband, | |
881d948c | 21 | u32 basic_rates, int bitrate) |
bd815252 JB |
22 | { |
23 | struct ieee80211_rate *result = &sband->bitrates[0]; | |
24 | int i; | |
25 | ||
26 | for (i = 0; i < sband->n_bitrates; i++) { | |
27 | if (!(basic_rates & BIT(i))) | |
28 | continue; | |
29 | if (sband->bitrates[i].bitrate > bitrate) | |
30 | continue; | |
31 | result = &sband->bitrates[i]; | |
32 | } | |
33 | ||
34 | return result; | |
35 | } | |
36 | EXPORT_SYMBOL(ieee80211_get_response_rate); | |
37 | ||
74608aca SW |
38 | u32 ieee80211_mandatory_rates(struct ieee80211_supported_band *sband, |
39 | enum nl80211_bss_scan_width scan_width) | |
b422c6cd AN |
40 | { |
41 | struct ieee80211_rate *bitrates; | |
42 | u32 mandatory_rates = 0; | |
43 | enum ieee80211_rate_flags mandatory_flag; | |
44 | int i; | |
45 | ||
46 | if (WARN_ON(!sband)) | |
47 | return 1; | |
48 | ||
74608aca SW |
49 | if (sband->band == IEEE80211_BAND_2GHZ) { |
50 | if (scan_width == NL80211_BSS_CHAN_WIDTH_5 || | |
51 | scan_width == NL80211_BSS_CHAN_WIDTH_10) | |
52 | mandatory_flag = IEEE80211_RATE_MANDATORY_G; | |
53 | else | |
54 | mandatory_flag = IEEE80211_RATE_MANDATORY_B; | |
55 | } else { | |
b422c6cd | 56 | mandatory_flag = IEEE80211_RATE_MANDATORY_A; |
74608aca | 57 | } |
b422c6cd AN |
58 | |
59 | bitrates = sband->bitrates; | |
60 | for (i = 0; i < sband->n_bitrates; i++) | |
61 | if (bitrates[i].flags & mandatory_flag) | |
62 | mandatory_rates |= BIT(i); | |
63 | return mandatory_rates; | |
64 | } | |
65 | EXPORT_SYMBOL(ieee80211_mandatory_rates); | |
66 | ||
59eb21a6 | 67 | int ieee80211_channel_to_frequency(int chan, enum ieee80211_band band) |
8318d78a | 68 | { |
59eb21a6 BR |
69 | /* see 802.11 17.3.8.3.2 and Annex J |
70 | * there are overlapping channel numbers in 5GHz and 2GHz bands */ | |
3a0c52a6 VK |
71 | if (chan <= 0) |
72 | return 0; /* not supported */ | |
73 | switch (band) { | |
74 | case IEEE80211_BAND_2GHZ: | |
59eb21a6 BR |
75 | if (chan == 14) |
76 | return 2484; | |
77 | else if (chan < 14) | |
78 | return 2407 + chan * 5; | |
3a0c52a6 VK |
79 | break; |
80 | case IEEE80211_BAND_5GHZ: | |
81 | if (chan >= 182 && chan <= 196) | |
82 | return 4000 + chan * 5; | |
59eb21a6 | 83 | else |
3a0c52a6 VK |
84 | return 5000 + chan * 5; |
85 | break; | |
86 | case IEEE80211_BAND_60GHZ: | |
87 | if (chan < 5) | |
88 | return 56160 + chan * 2160; | |
89 | break; | |
90 | default: | |
91 | ; | |
59eb21a6 | 92 | } |
3a0c52a6 | 93 | return 0; /* not supported */ |
8318d78a JB |
94 | } |
95 | EXPORT_SYMBOL(ieee80211_channel_to_frequency); | |
96 | ||
97 | int ieee80211_frequency_to_channel(int freq) | |
98 | { | |
59eb21a6 | 99 | /* see 802.11 17.3.8.3.2 and Annex J */ |
8318d78a JB |
100 | if (freq == 2484) |
101 | return 14; | |
59eb21a6 | 102 | else if (freq < 2484) |
8318d78a | 103 | return (freq - 2407) / 5; |
59eb21a6 BR |
104 | else if (freq >= 4910 && freq <= 4980) |
105 | return (freq - 4000) / 5; | |
3a0c52a6 | 106 | else if (freq <= 45000) /* DMG band lower limit */ |
59eb21a6 | 107 | return (freq - 5000) / 5; |
3a0c52a6 VK |
108 | else if (freq >= 58320 && freq <= 64800) |
109 | return (freq - 56160) / 2160; | |
110 | else | |
111 | return 0; | |
8318d78a JB |
112 | } |
113 | EXPORT_SYMBOL(ieee80211_frequency_to_channel); | |
114 | ||
6c507cd0 JB |
115 | struct ieee80211_channel *__ieee80211_get_channel(struct wiphy *wiphy, |
116 | int freq) | |
906c730a JB |
117 | { |
118 | enum ieee80211_band band; | |
119 | struct ieee80211_supported_band *sband; | |
120 | int i; | |
121 | ||
122 | for (band = 0; band < IEEE80211_NUM_BANDS; band++) { | |
123 | sband = wiphy->bands[band]; | |
124 | ||
125 | if (!sband) | |
126 | continue; | |
127 | ||
128 | for (i = 0; i < sband->n_channels; i++) { | |
129 | if (sband->channels[i].center_freq == freq) | |
130 | return &sband->channels[i]; | |
131 | } | |
132 | } | |
133 | ||
134 | return NULL; | |
135 | } | |
6c507cd0 | 136 | EXPORT_SYMBOL(__ieee80211_get_channel); |
906c730a | 137 | |
8318d78a JB |
138 | static void set_mandatory_flags_band(struct ieee80211_supported_band *sband, |
139 | enum ieee80211_band band) | |
140 | { | |
141 | int i, want; | |
142 | ||
143 | switch (band) { | |
144 | case IEEE80211_BAND_5GHZ: | |
145 | want = 3; | |
146 | for (i = 0; i < sband->n_bitrates; i++) { | |
147 | if (sband->bitrates[i].bitrate == 60 || | |
148 | sband->bitrates[i].bitrate == 120 || | |
149 | sband->bitrates[i].bitrate == 240) { | |
150 | sband->bitrates[i].flags |= | |
151 | IEEE80211_RATE_MANDATORY_A; | |
152 | want--; | |
153 | } | |
154 | } | |
155 | WARN_ON(want); | |
156 | break; | |
157 | case IEEE80211_BAND_2GHZ: | |
158 | want = 7; | |
159 | for (i = 0; i < sband->n_bitrates; i++) { | |
160 | if (sband->bitrates[i].bitrate == 10) { | |
161 | sband->bitrates[i].flags |= | |
162 | IEEE80211_RATE_MANDATORY_B | | |
163 | IEEE80211_RATE_MANDATORY_G; | |
164 | want--; | |
165 | } | |
166 | ||
167 | if (sband->bitrates[i].bitrate == 20 || | |
168 | sband->bitrates[i].bitrate == 55 || | |
169 | sband->bitrates[i].bitrate == 110 || | |
170 | sband->bitrates[i].bitrate == 60 || | |
171 | sband->bitrates[i].bitrate == 120 || | |
172 | sband->bitrates[i].bitrate == 240) { | |
173 | sband->bitrates[i].flags |= | |
174 | IEEE80211_RATE_MANDATORY_G; | |
175 | want--; | |
176 | } | |
177 | ||
aac09fbf JB |
178 | if (sband->bitrates[i].bitrate != 10 && |
179 | sband->bitrates[i].bitrate != 20 && | |
180 | sband->bitrates[i].bitrate != 55 && | |
181 | sband->bitrates[i].bitrate != 110) | |
8318d78a JB |
182 | sband->bitrates[i].flags |= |
183 | IEEE80211_RATE_ERP_G; | |
184 | } | |
406f2388 | 185 | WARN_ON(want != 0 && want != 3 && want != 6); |
8318d78a | 186 | break; |
3a0c52a6 VK |
187 | case IEEE80211_BAND_60GHZ: |
188 | /* check for mandatory HT MCS 1..4 */ | |
189 | WARN_ON(!sband->ht_cap.ht_supported); | |
190 | WARN_ON((sband->ht_cap.mcs.rx_mask[0] & 0x1e) != 0x1e); | |
191 | break; | |
8318d78a JB |
192 | case IEEE80211_NUM_BANDS: |
193 | WARN_ON(1); | |
194 | break; | |
195 | } | |
196 | } | |
197 | ||
198 | void ieee80211_set_bitrate_flags(struct wiphy *wiphy) | |
199 | { | |
200 | enum ieee80211_band band; | |
201 | ||
202 | for (band = 0; band < IEEE80211_NUM_BANDS; band++) | |
203 | if (wiphy->bands[band]) | |
204 | set_mandatory_flags_band(wiphy->bands[band], band); | |
205 | } | |
08645126 | 206 | |
38ba3c57 JM |
207 | bool cfg80211_supported_cipher_suite(struct wiphy *wiphy, u32 cipher) |
208 | { | |
209 | int i; | |
210 | for (i = 0; i < wiphy->n_cipher_suites; i++) | |
211 | if (cipher == wiphy->cipher_suites[i]) | |
212 | return true; | |
213 | return false; | |
214 | } | |
215 | ||
fffd0934 JB |
216 | int cfg80211_validate_key_settings(struct cfg80211_registered_device *rdev, |
217 | struct key_params *params, int key_idx, | |
e31b8213 | 218 | bool pairwise, const u8 *mac_addr) |
08645126 JB |
219 | { |
220 | if (key_idx > 5) | |
221 | return -EINVAL; | |
222 | ||
e31b8213 JB |
223 | if (!pairwise && mac_addr && !(rdev->wiphy.flags & WIPHY_FLAG_IBSS_RSN)) |
224 | return -EINVAL; | |
225 | ||
226 | if (pairwise && !mac_addr) | |
227 | return -EINVAL; | |
228 | ||
08645126 JB |
229 | /* |
230 | * Disallow pairwise keys with non-zero index unless it's WEP | |
45cbad6a JO |
231 | * or a vendor specific cipher (because current deployments use |
232 | * pairwise WEP keys with non-zero indices and for vendor specific | |
233 | * ciphers this should be validated in the driver or hardware level | |
234 | * - but 802.11i clearly specifies to use zero) | |
08645126 | 235 | */ |
e31b8213 | 236 | if (pairwise && key_idx && |
45cbad6a JO |
237 | ((params->cipher == WLAN_CIPHER_SUITE_TKIP) || |
238 | (params->cipher == WLAN_CIPHER_SUITE_CCMP) || | |
239 | (params->cipher == WLAN_CIPHER_SUITE_AES_CMAC))) | |
08645126 JB |
240 | return -EINVAL; |
241 | ||
08645126 JB |
242 | switch (params->cipher) { |
243 | case WLAN_CIPHER_SUITE_WEP40: | |
8fc0fee0 | 244 | if (params->key_len != WLAN_KEY_LEN_WEP40) |
08645126 JB |
245 | return -EINVAL; |
246 | break; | |
247 | case WLAN_CIPHER_SUITE_TKIP: | |
8fc0fee0 | 248 | if (params->key_len != WLAN_KEY_LEN_TKIP) |
08645126 JB |
249 | return -EINVAL; |
250 | break; | |
251 | case WLAN_CIPHER_SUITE_CCMP: | |
8fc0fee0 | 252 | if (params->key_len != WLAN_KEY_LEN_CCMP) |
08645126 JB |
253 | return -EINVAL; |
254 | break; | |
255 | case WLAN_CIPHER_SUITE_WEP104: | |
8fc0fee0 | 256 | if (params->key_len != WLAN_KEY_LEN_WEP104) |
08645126 JB |
257 | return -EINVAL; |
258 | break; | |
259 | case WLAN_CIPHER_SUITE_AES_CMAC: | |
8fc0fee0 | 260 | if (params->key_len != WLAN_KEY_LEN_AES_CMAC) |
08645126 JB |
261 | return -EINVAL; |
262 | break; | |
263 | default: | |
7d64b7cc JB |
264 | /* |
265 | * We don't know anything about this algorithm, | |
266 | * allow using it -- but the driver must check | |
267 | * all parameters! We still check below whether | |
268 | * or not the driver supports this algorithm, | |
269 | * of course. | |
270 | */ | |
271 | break; | |
08645126 JB |
272 | } |
273 | ||
9f26a952 JM |
274 | if (params->seq) { |
275 | switch (params->cipher) { | |
276 | case WLAN_CIPHER_SUITE_WEP40: | |
277 | case WLAN_CIPHER_SUITE_WEP104: | |
278 | /* These ciphers do not use key sequence */ | |
279 | return -EINVAL; | |
280 | case WLAN_CIPHER_SUITE_TKIP: | |
281 | case WLAN_CIPHER_SUITE_CCMP: | |
282 | case WLAN_CIPHER_SUITE_AES_CMAC: | |
283 | if (params->seq_len != 6) | |
284 | return -EINVAL; | |
285 | break; | |
286 | } | |
287 | } | |
288 | ||
38ba3c57 | 289 | if (!cfg80211_supported_cipher_suite(&rdev->wiphy, params->cipher)) |
fffd0934 JB |
290 | return -EINVAL; |
291 | ||
08645126 JB |
292 | return 0; |
293 | } | |
e31a16d6 | 294 | |
633adf1a | 295 | unsigned int __attribute_const__ ieee80211_hdrlen(__le16 fc) |
e31a16d6 ZY |
296 | { |
297 | unsigned int hdrlen = 24; | |
298 | ||
299 | if (ieee80211_is_data(fc)) { | |
300 | if (ieee80211_has_a4(fc)) | |
301 | hdrlen = 30; | |
d0dd2de0 | 302 | if (ieee80211_is_data_qos(fc)) { |
e31a16d6 | 303 | hdrlen += IEEE80211_QOS_CTL_LEN; |
d0dd2de0 AT |
304 | if (ieee80211_has_order(fc)) |
305 | hdrlen += IEEE80211_HT_CTL_LEN; | |
306 | } | |
e31a16d6 ZY |
307 | goto out; |
308 | } | |
309 | ||
310 | if (ieee80211_is_ctl(fc)) { | |
311 | /* | |
312 | * ACK and CTS are 10 bytes, all others 16. To see how | |
313 | * to get this condition consider | |
314 | * subtype mask: 0b0000000011110000 (0x00F0) | |
315 | * ACK subtype: 0b0000000011010000 (0x00D0) | |
316 | * CTS subtype: 0b0000000011000000 (0x00C0) | |
317 | * bits that matter: ^^^ (0x00E0) | |
318 | * value of those: 0b0000000011000000 (0x00C0) | |
319 | */ | |
320 | if ((fc & cpu_to_le16(0x00E0)) == cpu_to_le16(0x00C0)) | |
321 | hdrlen = 10; | |
322 | else | |
323 | hdrlen = 16; | |
324 | } | |
325 | out: | |
326 | return hdrlen; | |
327 | } | |
328 | EXPORT_SYMBOL(ieee80211_hdrlen); | |
329 | ||
330 | unsigned int ieee80211_get_hdrlen_from_skb(const struct sk_buff *skb) | |
331 | { | |
332 | const struct ieee80211_hdr *hdr = | |
333 | (const struct ieee80211_hdr *)skb->data; | |
334 | unsigned int hdrlen; | |
335 | ||
336 | if (unlikely(skb->len < 10)) | |
337 | return 0; | |
338 | hdrlen = ieee80211_hdrlen(hdr->frame_control); | |
339 | if (unlikely(hdrlen > skb->len)) | |
340 | return 0; | |
341 | return hdrlen; | |
342 | } | |
343 | EXPORT_SYMBOL(ieee80211_get_hdrlen_from_skb); | |
344 | ||
9b395bc3 | 345 | unsigned int ieee80211_get_mesh_hdrlen(struct ieee80211s_hdr *meshhdr) |
e31a16d6 ZY |
346 | { |
347 | int ae = meshhdr->flags & MESH_FLAGS_AE; | |
7dd111e8 | 348 | /* 802.11-2012, 8.2.4.7.3 */ |
e31a16d6 | 349 | switch (ae) { |
7dd111e8 | 350 | default: |
e31a16d6 ZY |
351 | case 0: |
352 | return 6; | |
3c5772a5 | 353 | case MESH_FLAGS_AE_A4: |
e31a16d6 | 354 | return 12; |
3c5772a5 | 355 | case MESH_FLAGS_AE_A5_A6: |
e31a16d6 | 356 | return 18; |
e31a16d6 ZY |
357 | } |
358 | } | |
9b395bc3 | 359 | EXPORT_SYMBOL(ieee80211_get_mesh_hdrlen); |
e31a16d6 | 360 | |
eaf85ca7 | 361 | int ieee80211_data_to_8023(struct sk_buff *skb, const u8 *addr, |
e31a16d6 ZY |
362 | enum nl80211_iftype iftype) |
363 | { | |
364 | struct ieee80211_hdr *hdr = (struct ieee80211_hdr *) skb->data; | |
365 | u16 hdrlen, ethertype; | |
366 | u8 *payload; | |
367 | u8 dst[ETH_ALEN]; | |
368 | u8 src[ETH_ALEN] __aligned(2); | |
369 | ||
370 | if (unlikely(!ieee80211_is_data_present(hdr->frame_control))) | |
371 | return -1; | |
372 | ||
373 | hdrlen = ieee80211_hdrlen(hdr->frame_control); | |
374 | ||
375 | /* convert IEEE 802.11 header + possible LLC headers into Ethernet | |
376 | * header | |
377 | * IEEE 802.11 address fields: | |
378 | * ToDS FromDS Addr1 Addr2 Addr3 Addr4 | |
379 | * 0 0 DA SA BSSID n/a | |
380 | * 0 1 DA BSSID SA n/a | |
381 | * 1 0 BSSID SA DA n/a | |
382 | * 1 1 RA TA DA SA | |
383 | */ | |
384 | memcpy(dst, ieee80211_get_DA(hdr), ETH_ALEN); | |
385 | memcpy(src, ieee80211_get_SA(hdr), ETH_ALEN); | |
386 | ||
387 | switch (hdr->frame_control & | |
388 | cpu_to_le16(IEEE80211_FCTL_TODS | IEEE80211_FCTL_FROMDS)) { | |
389 | case cpu_to_le16(IEEE80211_FCTL_TODS): | |
390 | if (unlikely(iftype != NL80211_IFTYPE_AP && | |
074ac8df JB |
391 | iftype != NL80211_IFTYPE_AP_VLAN && |
392 | iftype != NL80211_IFTYPE_P2P_GO)) | |
e31a16d6 ZY |
393 | return -1; |
394 | break; | |
395 | case cpu_to_le16(IEEE80211_FCTL_TODS | IEEE80211_FCTL_FROMDS): | |
396 | if (unlikely(iftype != NL80211_IFTYPE_WDS && | |
f14543ee FF |
397 | iftype != NL80211_IFTYPE_MESH_POINT && |
398 | iftype != NL80211_IFTYPE_AP_VLAN && | |
399 | iftype != NL80211_IFTYPE_STATION)) | |
e31a16d6 ZY |
400 | return -1; |
401 | if (iftype == NL80211_IFTYPE_MESH_POINT) { | |
402 | struct ieee80211s_hdr *meshdr = | |
403 | (struct ieee80211s_hdr *) (skb->data + hdrlen); | |
e3cf8b3f ZY |
404 | /* make sure meshdr->flags is on the linear part */ |
405 | if (!pskb_may_pull(skb, hdrlen + 1)) | |
406 | return -1; | |
7dd111e8 JB |
407 | if (meshdr->flags & MESH_FLAGS_AE_A4) |
408 | return -1; | |
e31a16d6 | 409 | if (meshdr->flags & MESH_FLAGS_AE_A5_A6) { |
e3cf8b3f ZY |
410 | skb_copy_bits(skb, hdrlen + |
411 | offsetof(struct ieee80211s_hdr, eaddr1), | |
412 | dst, ETH_ALEN); | |
413 | skb_copy_bits(skb, hdrlen + | |
414 | offsetof(struct ieee80211s_hdr, eaddr2), | |
415 | src, ETH_ALEN); | |
e31a16d6 | 416 | } |
e3cf8b3f | 417 | hdrlen += ieee80211_get_mesh_hdrlen(meshdr); |
e31a16d6 ZY |
418 | } |
419 | break; | |
420 | case cpu_to_le16(IEEE80211_FCTL_FROMDS): | |
3c5772a5 | 421 | if ((iftype != NL80211_IFTYPE_STATION && |
074ac8df JB |
422 | iftype != NL80211_IFTYPE_P2P_CLIENT && |
423 | iftype != NL80211_IFTYPE_MESH_POINT) || | |
e31a16d6 | 424 | (is_multicast_ether_addr(dst) && |
4c764729 | 425 | ether_addr_equal(src, addr))) |
e31a16d6 | 426 | return -1; |
3c5772a5 JC |
427 | if (iftype == NL80211_IFTYPE_MESH_POINT) { |
428 | struct ieee80211s_hdr *meshdr = | |
429 | (struct ieee80211s_hdr *) (skb->data + hdrlen); | |
e3cf8b3f ZY |
430 | /* make sure meshdr->flags is on the linear part */ |
431 | if (!pskb_may_pull(skb, hdrlen + 1)) | |
432 | return -1; | |
7dd111e8 JB |
433 | if (meshdr->flags & MESH_FLAGS_AE_A5_A6) |
434 | return -1; | |
3c5772a5 | 435 | if (meshdr->flags & MESH_FLAGS_AE_A4) |
e3cf8b3f ZY |
436 | skb_copy_bits(skb, hdrlen + |
437 | offsetof(struct ieee80211s_hdr, eaddr1), | |
438 | src, ETH_ALEN); | |
439 | hdrlen += ieee80211_get_mesh_hdrlen(meshdr); | |
3c5772a5 | 440 | } |
e31a16d6 ZY |
441 | break; |
442 | case cpu_to_le16(0): | |
941c93cd AN |
443 | if (iftype != NL80211_IFTYPE_ADHOC && |
444 | iftype != NL80211_IFTYPE_STATION) | |
445 | return -1; | |
e31a16d6 ZY |
446 | break; |
447 | } | |
448 | ||
e3cf8b3f | 449 | if (!pskb_may_pull(skb, hdrlen + 8)) |
e31a16d6 ZY |
450 | return -1; |
451 | ||
452 | payload = skb->data + hdrlen; | |
453 | ethertype = (payload[6] << 8) | payload[7]; | |
454 | ||
4c764729 | 455 | if (likely((ether_addr_equal(payload, rfc1042_header) && |
e31a16d6 | 456 | ethertype != ETH_P_AARP && ethertype != ETH_P_IPX) || |
4c764729 | 457 | ether_addr_equal(payload, bridge_tunnel_header))) { |
e31a16d6 ZY |
458 | /* remove RFC1042 or Bridge-Tunnel encapsulation and |
459 | * replace EtherType */ | |
460 | skb_pull(skb, hdrlen + 6); | |
461 | memcpy(skb_push(skb, ETH_ALEN), src, ETH_ALEN); | |
462 | memcpy(skb_push(skb, ETH_ALEN), dst, ETH_ALEN); | |
463 | } else { | |
464 | struct ethhdr *ehdr; | |
465 | __be16 len; | |
466 | ||
467 | skb_pull(skb, hdrlen); | |
468 | len = htons(skb->len); | |
469 | ehdr = (struct ethhdr *) skb_push(skb, sizeof(struct ethhdr)); | |
470 | memcpy(ehdr->h_dest, dst, ETH_ALEN); | |
471 | memcpy(ehdr->h_source, src, ETH_ALEN); | |
472 | ehdr->h_proto = len; | |
473 | } | |
474 | return 0; | |
475 | } | |
476 | EXPORT_SYMBOL(ieee80211_data_to_8023); | |
477 | ||
eaf85ca7 | 478 | int ieee80211_data_from_8023(struct sk_buff *skb, const u8 *addr, |
e31a16d6 ZY |
479 | enum nl80211_iftype iftype, u8 *bssid, bool qos) |
480 | { | |
481 | struct ieee80211_hdr hdr; | |
482 | u16 hdrlen, ethertype; | |
483 | __le16 fc; | |
484 | const u8 *encaps_data; | |
485 | int encaps_len, skip_header_bytes; | |
486 | int nh_pos, h_pos; | |
487 | int head_need; | |
488 | ||
489 | if (unlikely(skb->len < ETH_HLEN)) | |
490 | return -EINVAL; | |
491 | ||
492 | nh_pos = skb_network_header(skb) - skb->data; | |
493 | h_pos = skb_transport_header(skb) - skb->data; | |
494 | ||
495 | /* convert Ethernet header to proper 802.11 header (based on | |
496 | * operation mode) */ | |
497 | ethertype = (skb->data[12] << 8) | skb->data[13]; | |
498 | fc = cpu_to_le16(IEEE80211_FTYPE_DATA | IEEE80211_STYPE_DATA); | |
499 | ||
500 | switch (iftype) { | |
501 | case NL80211_IFTYPE_AP: | |
502 | case NL80211_IFTYPE_AP_VLAN: | |
074ac8df | 503 | case NL80211_IFTYPE_P2P_GO: |
e31a16d6 ZY |
504 | fc |= cpu_to_le16(IEEE80211_FCTL_FROMDS); |
505 | /* DA BSSID SA */ | |
506 | memcpy(hdr.addr1, skb->data, ETH_ALEN); | |
507 | memcpy(hdr.addr2, addr, ETH_ALEN); | |
508 | memcpy(hdr.addr3, skb->data + ETH_ALEN, ETH_ALEN); | |
509 | hdrlen = 24; | |
510 | break; | |
511 | case NL80211_IFTYPE_STATION: | |
074ac8df | 512 | case NL80211_IFTYPE_P2P_CLIENT: |
e31a16d6 ZY |
513 | fc |= cpu_to_le16(IEEE80211_FCTL_TODS); |
514 | /* BSSID SA DA */ | |
515 | memcpy(hdr.addr1, bssid, ETH_ALEN); | |
516 | memcpy(hdr.addr2, skb->data + ETH_ALEN, ETH_ALEN); | |
517 | memcpy(hdr.addr3, skb->data, ETH_ALEN); | |
518 | hdrlen = 24; | |
519 | break; | |
520 | case NL80211_IFTYPE_ADHOC: | |
521 | /* DA SA BSSID */ | |
522 | memcpy(hdr.addr1, skb->data, ETH_ALEN); | |
523 | memcpy(hdr.addr2, skb->data + ETH_ALEN, ETH_ALEN); | |
524 | memcpy(hdr.addr3, bssid, ETH_ALEN); | |
525 | hdrlen = 24; | |
526 | break; | |
527 | default: | |
528 | return -EOPNOTSUPP; | |
529 | } | |
530 | ||
531 | if (qos) { | |
532 | fc |= cpu_to_le16(IEEE80211_STYPE_QOS_DATA); | |
533 | hdrlen += 2; | |
534 | } | |
535 | ||
536 | hdr.frame_control = fc; | |
537 | hdr.duration_id = 0; | |
538 | hdr.seq_ctrl = 0; | |
539 | ||
540 | skip_header_bytes = ETH_HLEN; | |
541 | if (ethertype == ETH_P_AARP || ethertype == ETH_P_IPX) { | |
542 | encaps_data = bridge_tunnel_header; | |
543 | encaps_len = sizeof(bridge_tunnel_header); | |
544 | skip_header_bytes -= 2; | |
e5c5d22e | 545 | } else if (ethertype >= ETH_P_802_3_MIN) { |
e31a16d6 ZY |
546 | encaps_data = rfc1042_header; |
547 | encaps_len = sizeof(rfc1042_header); | |
548 | skip_header_bytes -= 2; | |
549 | } else { | |
550 | encaps_data = NULL; | |
551 | encaps_len = 0; | |
552 | } | |
553 | ||
554 | skb_pull(skb, skip_header_bytes); | |
555 | nh_pos -= skip_header_bytes; | |
556 | h_pos -= skip_header_bytes; | |
557 | ||
558 | head_need = hdrlen + encaps_len - skb_headroom(skb); | |
559 | ||
560 | if (head_need > 0 || skb_cloned(skb)) { | |
561 | head_need = max(head_need, 0); | |
562 | if (head_need) | |
563 | skb_orphan(skb); | |
564 | ||
24616152 | 565 | if (pskb_expand_head(skb, head_need, 0, GFP_ATOMIC)) |
e31a16d6 | 566 | return -ENOMEM; |
24616152 | 567 | |
e31a16d6 ZY |
568 | skb->truesize += head_need; |
569 | } | |
570 | ||
571 | if (encaps_data) { | |
572 | memcpy(skb_push(skb, encaps_len), encaps_data, encaps_len); | |
573 | nh_pos += encaps_len; | |
574 | h_pos += encaps_len; | |
575 | } | |
576 | ||
577 | memcpy(skb_push(skb, hdrlen), &hdr, hdrlen); | |
578 | ||
579 | nh_pos += hdrlen; | |
580 | h_pos += hdrlen; | |
581 | ||
582 | /* Update skb pointers to various headers since this modified frame | |
583 | * is going to go through Linux networking code that may potentially | |
584 | * need things like pointer to IP header. */ | |
585 | skb_set_mac_header(skb, 0); | |
586 | skb_set_network_header(skb, nh_pos); | |
587 | skb_set_transport_header(skb, h_pos); | |
588 | ||
589 | return 0; | |
590 | } | |
591 | EXPORT_SYMBOL(ieee80211_data_from_8023); | |
592 | ||
eaf85ca7 ZY |
593 | |
594 | void ieee80211_amsdu_to_8023s(struct sk_buff *skb, struct sk_buff_head *list, | |
595 | const u8 *addr, enum nl80211_iftype iftype, | |
8b3becad YAP |
596 | const unsigned int extra_headroom, |
597 | bool has_80211_header) | |
eaf85ca7 ZY |
598 | { |
599 | struct sk_buff *frame = NULL; | |
600 | u16 ethertype; | |
601 | u8 *payload; | |
602 | const struct ethhdr *eth; | |
603 | int remaining, err; | |
604 | u8 dst[ETH_ALEN], src[ETH_ALEN]; | |
605 | ||
8b3becad YAP |
606 | if (has_80211_header) { |
607 | err = ieee80211_data_to_8023(skb, addr, iftype); | |
608 | if (err) | |
609 | goto out; | |
eaf85ca7 | 610 | |
8b3becad YAP |
611 | /* skip the wrapping header */ |
612 | eth = (struct ethhdr *) skb_pull(skb, sizeof(struct ethhdr)); | |
613 | if (!eth) | |
614 | goto out; | |
615 | } else { | |
616 | eth = (struct ethhdr *) skb->data; | |
617 | } | |
eaf85ca7 ZY |
618 | |
619 | while (skb != frame) { | |
620 | u8 padding; | |
621 | __be16 len = eth->h_proto; | |
622 | unsigned int subframe_len = sizeof(struct ethhdr) + ntohs(len); | |
623 | ||
624 | remaining = skb->len; | |
625 | memcpy(dst, eth->h_dest, ETH_ALEN); | |
626 | memcpy(src, eth->h_source, ETH_ALEN); | |
627 | ||
628 | padding = (4 - subframe_len) & 0x3; | |
629 | /* the last MSDU has no padding */ | |
630 | if (subframe_len > remaining) | |
631 | goto purge; | |
632 | ||
633 | skb_pull(skb, sizeof(struct ethhdr)); | |
634 | /* reuse skb for the last subframe */ | |
635 | if (remaining <= subframe_len + padding) | |
636 | frame = skb; | |
637 | else { | |
638 | unsigned int hlen = ALIGN(extra_headroom, 4); | |
639 | /* | |
640 | * Allocate and reserve two bytes more for payload | |
641 | * alignment since sizeof(struct ethhdr) is 14. | |
642 | */ | |
643 | frame = dev_alloc_skb(hlen + subframe_len + 2); | |
644 | if (!frame) | |
645 | goto purge; | |
646 | ||
647 | skb_reserve(frame, hlen + sizeof(struct ethhdr) + 2); | |
648 | memcpy(skb_put(frame, ntohs(len)), skb->data, | |
649 | ntohs(len)); | |
650 | ||
651 | eth = (struct ethhdr *)skb_pull(skb, ntohs(len) + | |
652 | padding); | |
653 | if (!eth) { | |
654 | dev_kfree_skb(frame); | |
655 | goto purge; | |
656 | } | |
657 | } | |
658 | ||
659 | skb_reset_network_header(frame); | |
660 | frame->dev = skb->dev; | |
661 | frame->priority = skb->priority; | |
662 | ||
663 | payload = frame->data; | |
664 | ethertype = (payload[6] << 8) | payload[7]; | |
665 | ||
ac422d3c | 666 | if (likely((ether_addr_equal(payload, rfc1042_header) && |
eaf85ca7 | 667 | ethertype != ETH_P_AARP && ethertype != ETH_P_IPX) || |
ac422d3c | 668 | ether_addr_equal(payload, bridge_tunnel_header))) { |
eaf85ca7 ZY |
669 | /* remove RFC1042 or Bridge-Tunnel |
670 | * encapsulation and replace EtherType */ | |
671 | skb_pull(frame, 6); | |
672 | memcpy(skb_push(frame, ETH_ALEN), src, ETH_ALEN); | |
673 | memcpy(skb_push(frame, ETH_ALEN), dst, ETH_ALEN); | |
674 | } else { | |
675 | memcpy(skb_push(frame, sizeof(__be16)), &len, | |
676 | sizeof(__be16)); | |
677 | memcpy(skb_push(frame, ETH_ALEN), src, ETH_ALEN); | |
678 | memcpy(skb_push(frame, ETH_ALEN), dst, ETH_ALEN); | |
679 | } | |
680 | __skb_queue_tail(list, frame); | |
681 | } | |
682 | ||
683 | return; | |
684 | ||
685 | purge: | |
686 | __skb_queue_purge(list); | |
687 | out: | |
688 | dev_kfree_skb(skb); | |
689 | } | |
690 | EXPORT_SYMBOL(ieee80211_amsdu_to_8023s); | |
691 | ||
e31a16d6 | 692 | /* Given a data frame determine the 802.1p/1d tag to use. */ |
fa9ffc74 KP |
693 | unsigned int cfg80211_classify8021d(struct sk_buff *skb, |
694 | struct cfg80211_qos_map *qos_map) | |
e31a16d6 ZY |
695 | { |
696 | unsigned int dscp; | |
c6ca5e28 | 697 | unsigned char vlan_priority; |
e31a16d6 ZY |
698 | |
699 | /* skb->priority values from 256->263 are magic values to | |
700 | * directly indicate a specific 802.1d priority. This is used | |
701 | * to allow 802.1d priority to be passed directly in from VLAN | |
702 | * tags, etc. | |
703 | */ | |
704 | if (skb->priority >= 256 && skb->priority <= 263) | |
705 | return skb->priority - 256; | |
706 | ||
c6ca5e28 V |
707 | if (vlan_tx_tag_present(skb)) { |
708 | vlan_priority = (vlan_tx_tag_get(skb) & VLAN_PRIO_MASK) | |
709 | >> VLAN_PRIO_SHIFT; | |
710 | if (vlan_priority > 0) | |
711 | return vlan_priority; | |
712 | } | |
713 | ||
e31a16d6 ZY |
714 | switch (skb->protocol) { |
715 | case htons(ETH_P_IP): | |
b156579b DT |
716 | dscp = ipv4_get_dsfield(ip_hdr(skb)) & 0xfc; |
717 | break; | |
718 | case htons(ETH_P_IPV6): | |
719 | dscp = ipv6_get_dsfield(ipv6_hdr(skb)) & 0xfc; | |
e31a16d6 | 720 | break; |
960d97f9 SW |
721 | case htons(ETH_P_MPLS_UC): |
722 | case htons(ETH_P_MPLS_MC): { | |
723 | struct mpls_label mpls_tmp, *mpls; | |
724 | ||
725 | mpls = skb_header_pointer(skb, sizeof(struct ethhdr), | |
726 | sizeof(*mpls), &mpls_tmp); | |
727 | if (!mpls) | |
728 | return 0; | |
729 | ||
730 | return (ntohl(mpls->entry) & MPLS_LS_TC_MASK) | |
731 | >> MPLS_LS_TC_SHIFT; | |
732 | } | |
733 | case htons(ETH_P_80221): | |
734 | /* 802.21 is always network control traffic */ | |
735 | return 7; | |
e31a16d6 ZY |
736 | default: |
737 | return 0; | |
738 | } | |
739 | ||
fa9ffc74 KP |
740 | if (qos_map) { |
741 | unsigned int i, tmp_dscp = dscp >> 2; | |
742 | ||
743 | for (i = 0; i < qos_map->num_des; i++) { | |
744 | if (tmp_dscp == qos_map->dscp_exception[i].dscp) | |
745 | return qos_map->dscp_exception[i].up; | |
746 | } | |
747 | ||
748 | for (i = 0; i < 8; i++) { | |
749 | if (tmp_dscp >= qos_map->up[i].low && | |
750 | tmp_dscp <= qos_map->up[i].high) | |
751 | return i; | |
752 | } | |
753 | } | |
754 | ||
e31a16d6 ZY |
755 | return dscp >> 5; |
756 | } | |
757 | EXPORT_SYMBOL(cfg80211_classify8021d); | |
517357c6 JB |
758 | |
759 | const u8 *ieee80211_bss_get_ie(struct cfg80211_bss *bss, u8 ie) | |
760 | { | |
9caf0364 JB |
761 | const struct cfg80211_bss_ies *ies; |
762 | ||
763 | ies = rcu_dereference(bss->ies); | |
764 | if (!ies) | |
517357c6 | 765 | return NULL; |
9caf0364 JB |
766 | |
767 | return cfg80211_find_ie(ie, ies->data, ies->len); | |
517357c6 JB |
768 | } |
769 | EXPORT_SYMBOL(ieee80211_bss_get_ie); | |
fffd0934 JB |
770 | |
771 | void cfg80211_upload_connect_keys(struct wireless_dev *wdev) | |
772 | { | |
f26cbf40 | 773 | struct cfg80211_registered_device *rdev = wiphy_to_rdev(wdev->wiphy); |
fffd0934 JB |
774 | struct net_device *dev = wdev->netdev; |
775 | int i; | |
776 | ||
777 | if (!wdev->connect_keys) | |
778 | return; | |
779 | ||
780 | for (i = 0; i < 6; i++) { | |
781 | if (!wdev->connect_keys->params[i].cipher) | |
782 | continue; | |
e35e4d28 HG |
783 | if (rdev_add_key(rdev, dev, i, false, NULL, |
784 | &wdev->connect_keys->params[i])) { | |
e9c0268f | 785 | netdev_err(dev, "failed to set key %d\n", i); |
1e056665 ZY |
786 | continue; |
787 | } | |
fffd0934 | 788 | if (wdev->connect_keys->def == i) |
e35e4d28 | 789 | if (rdev_set_default_key(rdev, dev, i, true, true)) { |
e9c0268f | 790 | netdev_err(dev, "failed to set defkey %d\n", i); |
1e056665 ZY |
791 | continue; |
792 | } | |
fffd0934 | 793 | if (wdev->connect_keys->defmgmt == i) |
e35e4d28 | 794 | if (rdev_set_default_mgmt_key(rdev, dev, i)) |
e9c0268f | 795 | netdev_err(dev, "failed to set mgtdef %d\n", i); |
fffd0934 JB |
796 | } |
797 | ||
798 | kfree(wdev->connect_keys); | |
799 | wdev->connect_keys = NULL; | |
800 | } | |
3d54d255 | 801 | |
1f6fc43e | 802 | void cfg80211_process_wdev_events(struct wireless_dev *wdev) |
3d54d255 JB |
803 | { |
804 | struct cfg80211_event *ev; | |
805 | unsigned long flags; | |
806 | const u8 *bssid = NULL; | |
807 | ||
808 | spin_lock_irqsave(&wdev->event_lock, flags); | |
809 | while (!list_empty(&wdev->event_list)) { | |
810 | ev = list_first_entry(&wdev->event_list, | |
811 | struct cfg80211_event, list); | |
812 | list_del(&ev->list); | |
813 | spin_unlock_irqrestore(&wdev->event_lock, flags); | |
814 | ||
815 | wdev_lock(wdev); | |
816 | switch (ev->type) { | |
817 | case EVENT_CONNECT_RESULT: | |
818 | if (!is_zero_ether_addr(ev->cr.bssid)) | |
819 | bssid = ev->cr.bssid; | |
820 | __cfg80211_connect_result( | |
821 | wdev->netdev, bssid, | |
822 | ev->cr.req_ie, ev->cr.req_ie_len, | |
823 | ev->cr.resp_ie, ev->cr.resp_ie_len, | |
824 | ev->cr.status, | |
825 | ev->cr.status == WLAN_STATUS_SUCCESS, | |
826 | NULL); | |
827 | break; | |
828 | case EVENT_ROAMED: | |
adbde344 VT |
829 | __cfg80211_roamed(wdev, ev->rm.bss, ev->rm.req_ie, |
830 | ev->rm.req_ie_len, ev->rm.resp_ie, | |
831 | ev->rm.resp_ie_len); | |
3d54d255 JB |
832 | break; |
833 | case EVENT_DISCONNECTED: | |
834 | __cfg80211_disconnected(wdev->netdev, | |
835 | ev->dc.ie, ev->dc.ie_len, | |
836 | ev->dc.reason, true); | |
837 | break; | |
838 | case EVENT_IBSS_JOINED: | |
fe94f3a4 AQ |
839 | __cfg80211_ibss_joined(wdev->netdev, ev->ij.bssid, |
840 | ev->ij.channel); | |
3d54d255 | 841 | break; |
f04c2203 MK |
842 | case EVENT_STOPPED: |
843 | __cfg80211_leave(wiphy_to_rdev(wdev->wiphy), wdev); | |
844 | break; | |
3d54d255 JB |
845 | } |
846 | wdev_unlock(wdev); | |
847 | ||
848 | kfree(ev); | |
849 | ||
850 | spin_lock_irqsave(&wdev->event_lock, flags); | |
851 | } | |
852 | spin_unlock_irqrestore(&wdev->event_lock, flags); | |
853 | } | |
854 | ||
855 | void cfg80211_process_rdev_events(struct cfg80211_registered_device *rdev) | |
856 | { | |
857 | struct wireless_dev *wdev; | |
858 | ||
859 | ASSERT_RTNL(); | |
3d54d255 | 860 | |
89a54e48 | 861 | list_for_each_entry(wdev, &rdev->wdev_list, list) |
3d54d255 | 862 | cfg80211_process_wdev_events(wdev); |
3d54d255 JB |
863 | } |
864 | ||
865 | int cfg80211_change_iface(struct cfg80211_registered_device *rdev, | |
866 | struct net_device *dev, enum nl80211_iftype ntype, | |
867 | u32 *flags, struct vif_params *params) | |
868 | { | |
869 | int err; | |
870 | enum nl80211_iftype otype = dev->ieee80211_ptr->iftype; | |
871 | ||
73fb08e2 | 872 | ASSERT_RTNL(); |
3d54d255 JB |
873 | |
874 | /* don't support changing VLANs, you just re-create them */ | |
875 | if (otype == NL80211_IFTYPE_AP_VLAN) | |
876 | return -EOPNOTSUPP; | |
877 | ||
98104fde JB |
878 | /* cannot change into P2P device type */ |
879 | if (ntype == NL80211_IFTYPE_P2P_DEVICE) | |
880 | return -EOPNOTSUPP; | |
881 | ||
3d54d255 JB |
882 | if (!rdev->ops->change_virtual_intf || |
883 | !(rdev->wiphy.interface_modes & (1 << ntype))) | |
884 | return -EOPNOTSUPP; | |
885 | ||
ad4bb6f8 | 886 | /* if it's part of a bridge, reject changing type to station/ibss */ |
f350a0a8 | 887 | if ((dev->priv_flags & IFF_BRIDGE_PORT) && |
074ac8df JB |
888 | (ntype == NL80211_IFTYPE_ADHOC || |
889 | ntype == NL80211_IFTYPE_STATION || | |
890 | ntype == NL80211_IFTYPE_P2P_CLIENT)) | |
ad4bb6f8 JB |
891 | return -EBUSY; |
892 | ||
f8cdddb8 | 893 | if (ntype != otype && netif_running(dev)) { |
9bc383de | 894 | dev->ieee80211_ptr->use_4addr = false; |
29cbe68c | 895 | dev->ieee80211_ptr->mesh_id_up_len = 0; |
194ff52d | 896 | wdev_lock(dev->ieee80211_ptr); |
fa9ffc74 | 897 | rdev_set_qos_map(rdev, dev, NULL); |
194ff52d | 898 | wdev_unlock(dev->ieee80211_ptr); |
9bc383de | 899 | |
3d54d255 | 900 | switch (otype) { |
ac800140 | 901 | case NL80211_IFTYPE_AP: |
7c8d5e03 | 902 | cfg80211_stop_ap(rdev, dev, true); |
ac800140 | 903 | break; |
3d54d255 JB |
904 | case NL80211_IFTYPE_ADHOC: |
905 | cfg80211_leave_ibss(rdev, dev, false); | |
906 | break; | |
907 | case NL80211_IFTYPE_STATION: | |
074ac8df | 908 | case NL80211_IFTYPE_P2P_CLIENT: |
83739b03 | 909 | wdev_lock(dev->ieee80211_ptr); |
3d54d255 JB |
910 | cfg80211_disconnect(rdev, dev, |
911 | WLAN_REASON_DEAUTH_LEAVING, true); | |
83739b03 | 912 | wdev_unlock(dev->ieee80211_ptr); |
3d54d255 JB |
913 | break; |
914 | case NL80211_IFTYPE_MESH_POINT: | |
915 | /* mesh should be handled? */ | |
916 | break; | |
917 | default: | |
918 | break; | |
919 | } | |
920 | ||
921 | cfg80211_process_rdev_events(rdev); | |
922 | } | |
923 | ||
e35e4d28 | 924 | err = rdev_change_virtual_intf(rdev, dev, ntype, flags, params); |
3d54d255 JB |
925 | |
926 | WARN_ON(!err && dev->ieee80211_ptr->iftype != ntype); | |
927 | ||
9bc383de JB |
928 | if (!err && params && params->use_4addr != -1) |
929 | dev->ieee80211_ptr->use_4addr = params->use_4addr; | |
930 | ||
ad4bb6f8 JB |
931 | if (!err) { |
932 | dev->priv_flags &= ~IFF_DONT_BRIDGE; | |
933 | switch (ntype) { | |
934 | case NL80211_IFTYPE_STATION: | |
935 | if (dev->ieee80211_ptr->use_4addr) | |
936 | break; | |
937 | /* fall through */ | |
074ac8df | 938 | case NL80211_IFTYPE_P2P_CLIENT: |
ad4bb6f8 JB |
939 | case NL80211_IFTYPE_ADHOC: |
940 | dev->priv_flags |= IFF_DONT_BRIDGE; | |
941 | break; | |
074ac8df | 942 | case NL80211_IFTYPE_P2P_GO: |
ad4bb6f8 JB |
943 | case NL80211_IFTYPE_AP: |
944 | case NL80211_IFTYPE_AP_VLAN: | |
945 | case NL80211_IFTYPE_WDS: | |
946 | case NL80211_IFTYPE_MESH_POINT: | |
947 | /* bridging OK */ | |
948 | break; | |
949 | case NL80211_IFTYPE_MONITOR: | |
950 | /* monitor can't bridge anyway */ | |
951 | break; | |
952 | case NL80211_IFTYPE_UNSPECIFIED: | |
2e161f78 | 953 | case NUM_NL80211_IFTYPES: |
ad4bb6f8 JB |
954 | /* not happening */ |
955 | break; | |
98104fde JB |
956 | case NL80211_IFTYPE_P2P_DEVICE: |
957 | WARN_ON(1); | |
958 | break; | |
ad4bb6f8 JB |
959 | } |
960 | } | |
961 | ||
dbbae26a MK |
962 | if (!err && ntype != otype && netif_running(dev)) { |
963 | cfg80211_update_iface_num(rdev, ntype, 1); | |
964 | cfg80211_update_iface_num(rdev, otype, -1); | |
965 | } | |
966 | ||
3d54d255 JB |
967 | return err; |
968 | } | |
254416aa | 969 | |
95ddc1fc VK |
970 | static u32 cfg80211_calculate_bitrate_60g(struct rate_info *rate) |
971 | { | |
972 | static const u32 __mcs2bitrate[] = { | |
973 | /* control PHY */ | |
974 | [0] = 275, | |
975 | /* SC PHY */ | |
976 | [1] = 3850, | |
977 | [2] = 7700, | |
978 | [3] = 9625, | |
979 | [4] = 11550, | |
980 | [5] = 12512, /* 1251.25 mbps */ | |
981 | [6] = 15400, | |
982 | [7] = 19250, | |
983 | [8] = 23100, | |
984 | [9] = 25025, | |
985 | [10] = 30800, | |
986 | [11] = 38500, | |
987 | [12] = 46200, | |
988 | /* OFDM PHY */ | |
989 | [13] = 6930, | |
990 | [14] = 8662, /* 866.25 mbps */ | |
991 | [15] = 13860, | |
992 | [16] = 17325, | |
993 | [17] = 20790, | |
994 | [18] = 27720, | |
995 | [19] = 34650, | |
996 | [20] = 41580, | |
997 | [21] = 45045, | |
998 | [22] = 51975, | |
999 | [23] = 62370, | |
1000 | [24] = 67568, /* 6756.75 mbps */ | |
1001 | /* LP-SC PHY */ | |
1002 | [25] = 6260, | |
1003 | [26] = 8340, | |
1004 | [27] = 11120, | |
1005 | [28] = 12510, | |
1006 | [29] = 16680, | |
1007 | [30] = 22240, | |
1008 | [31] = 25030, | |
1009 | }; | |
1010 | ||
1011 | if (WARN_ON_ONCE(rate->mcs >= ARRAY_SIZE(__mcs2bitrate))) | |
1012 | return 0; | |
1013 | ||
1014 | return __mcs2bitrate[rate->mcs]; | |
1015 | } | |
1016 | ||
db9c64cf JB |
1017 | static u32 cfg80211_calculate_bitrate_vht(struct rate_info *rate) |
1018 | { | |
1019 | static const u32 base[4][10] = { | |
1020 | { 6500000, | |
1021 | 13000000, | |
1022 | 19500000, | |
1023 | 26000000, | |
1024 | 39000000, | |
1025 | 52000000, | |
1026 | 58500000, | |
1027 | 65000000, | |
1028 | 78000000, | |
1029 | 0, | |
1030 | }, | |
1031 | { 13500000, | |
1032 | 27000000, | |
1033 | 40500000, | |
1034 | 54000000, | |
1035 | 81000000, | |
1036 | 108000000, | |
1037 | 121500000, | |
1038 | 135000000, | |
1039 | 162000000, | |
1040 | 180000000, | |
1041 | }, | |
1042 | { 29300000, | |
1043 | 58500000, | |
1044 | 87800000, | |
1045 | 117000000, | |
1046 | 175500000, | |
1047 | 234000000, | |
1048 | 263300000, | |
1049 | 292500000, | |
1050 | 351000000, | |
1051 | 390000000, | |
1052 | }, | |
1053 | { 58500000, | |
1054 | 117000000, | |
1055 | 175500000, | |
1056 | 234000000, | |
1057 | 351000000, | |
1058 | 468000000, | |
1059 | 526500000, | |
1060 | 585000000, | |
1061 | 702000000, | |
1062 | 780000000, | |
1063 | }, | |
1064 | }; | |
1065 | u32 bitrate; | |
1066 | int idx; | |
1067 | ||
1068 | if (WARN_ON_ONCE(rate->mcs > 9)) | |
1069 | return 0; | |
1070 | ||
1071 | idx = rate->flags & (RATE_INFO_FLAGS_160_MHZ_WIDTH | | |
1072 | RATE_INFO_FLAGS_80P80_MHZ_WIDTH) ? 3 : | |
1073 | rate->flags & RATE_INFO_FLAGS_80_MHZ_WIDTH ? 2 : | |
1074 | rate->flags & RATE_INFO_FLAGS_40_MHZ_WIDTH ? 1 : 0; | |
1075 | ||
1076 | bitrate = base[idx][rate->mcs]; | |
1077 | bitrate *= rate->nss; | |
1078 | ||
1079 | if (rate->flags & RATE_INFO_FLAGS_SHORT_GI) | |
1080 | bitrate = (bitrate / 9) * 10; | |
1081 | ||
1082 | /* do NOT round down here */ | |
1083 | return (bitrate + 50000) / 100000; | |
1084 | } | |
1085 | ||
8eb41c8d | 1086 | u32 cfg80211_calculate_bitrate(struct rate_info *rate) |
254416aa JL |
1087 | { |
1088 | int modulation, streams, bitrate; | |
1089 | ||
db9c64cf JB |
1090 | if (!(rate->flags & RATE_INFO_FLAGS_MCS) && |
1091 | !(rate->flags & RATE_INFO_FLAGS_VHT_MCS)) | |
254416aa | 1092 | return rate->legacy; |
95ddc1fc VK |
1093 | if (rate->flags & RATE_INFO_FLAGS_60G) |
1094 | return cfg80211_calculate_bitrate_60g(rate); | |
db9c64cf JB |
1095 | if (rate->flags & RATE_INFO_FLAGS_VHT_MCS) |
1096 | return cfg80211_calculate_bitrate_vht(rate); | |
254416aa JL |
1097 | |
1098 | /* the formula below does only work for MCS values smaller than 32 */ | |
2615f375 | 1099 | if (WARN_ON_ONCE(rate->mcs >= 32)) |
254416aa JL |
1100 | return 0; |
1101 | ||
1102 | modulation = rate->mcs & 7; | |
1103 | streams = (rate->mcs >> 3) + 1; | |
1104 | ||
1105 | bitrate = (rate->flags & RATE_INFO_FLAGS_40_MHZ_WIDTH) ? | |
1106 | 13500000 : 6500000; | |
1107 | ||
1108 | if (modulation < 4) | |
1109 | bitrate *= (modulation + 1); | |
1110 | else if (modulation == 4) | |
1111 | bitrate *= (modulation + 2); | |
1112 | else | |
1113 | bitrate *= (modulation + 3); | |
1114 | ||
1115 | bitrate *= streams; | |
1116 | ||
1117 | if (rate->flags & RATE_INFO_FLAGS_SHORT_GI) | |
1118 | bitrate = (bitrate / 9) * 10; | |
1119 | ||
1120 | /* do NOT round down here */ | |
1121 | return (bitrate + 50000) / 100000; | |
1122 | } | |
8097e149 | 1123 | EXPORT_SYMBOL(cfg80211_calculate_bitrate); |
56d1893d | 1124 | |
c216e641 AS |
1125 | int cfg80211_get_p2p_attr(const u8 *ies, unsigned int len, |
1126 | enum ieee80211_p2p_attr_id attr, | |
1127 | u8 *buf, unsigned int bufsize) | |
0ee45355 JB |
1128 | { |
1129 | u8 *out = buf; | |
1130 | u16 attr_remaining = 0; | |
1131 | bool desired_attr = false; | |
1132 | u16 desired_len = 0; | |
1133 | ||
1134 | while (len > 0) { | |
1135 | unsigned int iedatalen; | |
1136 | unsigned int copy; | |
1137 | const u8 *iedata; | |
1138 | ||
1139 | if (len < 2) | |
1140 | return -EILSEQ; | |
1141 | iedatalen = ies[1]; | |
1142 | if (iedatalen + 2 > len) | |
1143 | return -EILSEQ; | |
1144 | ||
1145 | if (ies[0] != WLAN_EID_VENDOR_SPECIFIC) | |
1146 | goto cont; | |
1147 | ||
1148 | if (iedatalen < 4) | |
1149 | goto cont; | |
1150 | ||
1151 | iedata = ies + 2; | |
1152 | ||
1153 | /* check WFA OUI, P2P subtype */ | |
1154 | if (iedata[0] != 0x50 || iedata[1] != 0x6f || | |
1155 | iedata[2] != 0x9a || iedata[3] != 0x09) | |
1156 | goto cont; | |
1157 | ||
1158 | iedatalen -= 4; | |
1159 | iedata += 4; | |
1160 | ||
1161 | /* check attribute continuation into this IE */ | |
1162 | copy = min_t(unsigned int, attr_remaining, iedatalen); | |
1163 | if (copy && desired_attr) { | |
1164 | desired_len += copy; | |
1165 | if (out) { | |
1166 | memcpy(out, iedata, min(bufsize, copy)); | |
1167 | out += min(bufsize, copy); | |
1168 | bufsize -= min(bufsize, copy); | |
1169 | } | |
1170 | ||
1171 | ||
1172 | if (copy == attr_remaining) | |
1173 | return desired_len; | |
1174 | } | |
1175 | ||
1176 | attr_remaining -= copy; | |
1177 | if (attr_remaining) | |
1178 | goto cont; | |
1179 | ||
1180 | iedatalen -= copy; | |
1181 | iedata += copy; | |
1182 | ||
1183 | while (iedatalen > 0) { | |
1184 | u16 attr_len; | |
1185 | ||
1186 | /* P2P attribute ID & size must fit */ | |
1187 | if (iedatalen < 3) | |
1188 | return -EILSEQ; | |
1189 | desired_attr = iedata[0] == attr; | |
1190 | attr_len = get_unaligned_le16(iedata + 1); | |
1191 | iedatalen -= 3; | |
1192 | iedata += 3; | |
1193 | ||
1194 | copy = min_t(unsigned int, attr_len, iedatalen); | |
1195 | ||
1196 | if (desired_attr) { | |
1197 | desired_len += copy; | |
1198 | if (out) { | |
1199 | memcpy(out, iedata, min(bufsize, copy)); | |
1200 | out += min(bufsize, copy); | |
1201 | bufsize -= min(bufsize, copy); | |
1202 | } | |
1203 | ||
1204 | if (copy == attr_len) | |
1205 | return desired_len; | |
1206 | } | |
1207 | ||
1208 | iedata += copy; | |
1209 | iedatalen -= copy; | |
1210 | attr_remaining = attr_len - copy; | |
1211 | } | |
1212 | ||
1213 | cont: | |
1214 | len -= ies[1] + 2; | |
1215 | ies += ies[1] + 2; | |
1216 | } | |
1217 | ||
1218 | if (attr_remaining && desired_attr) | |
1219 | return -EILSEQ; | |
1220 | ||
1221 | return -ENOENT; | |
1222 | } | |
1223 | EXPORT_SYMBOL(cfg80211_get_p2p_attr); | |
1224 | ||
1ce3e82b JB |
1225 | bool ieee80211_operating_class_to_band(u8 operating_class, |
1226 | enum ieee80211_band *band) | |
1227 | { | |
1228 | switch (operating_class) { | |
1229 | case 112: | |
1230 | case 115 ... 127: | |
1231 | *band = IEEE80211_BAND_5GHZ; | |
1232 | return true; | |
1233 | case 81: | |
1234 | case 82: | |
1235 | case 83: | |
1236 | case 84: | |
1237 | *band = IEEE80211_BAND_2GHZ; | |
1238 | return true; | |
55300a13 VK |
1239 | case 180: |
1240 | *band = IEEE80211_BAND_60GHZ; | |
1241 | return true; | |
1ce3e82b JB |
1242 | } |
1243 | ||
1244 | return false; | |
1245 | } | |
1246 | EXPORT_SYMBOL(ieee80211_operating_class_to_band); | |
1247 | ||
56d1893d JB |
1248 | int cfg80211_validate_beacon_int(struct cfg80211_registered_device *rdev, |
1249 | u32 beacon_int) | |
1250 | { | |
1251 | struct wireless_dev *wdev; | |
1252 | int res = 0; | |
1253 | ||
1254 | if (!beacon_int) | |
1255 | return -EINVAL; | |
1256 | ||
89a54e48 | 1257 | list_for_each_entry(wdev, &rdev->wdev_list, list) { |
56d1893d JB |
1258 | if (!wdev->beacon_interval) |
1259 | continue; | |
1260 | if (wdev->beacon_interval != beacon_int) { | |
1261 | res = -EINVAL; | |
1262 | break; | |
1263 | } | |
1264 | } | |
1265 | ||
56d1893d JB |
1266 | return res; |
1267 | } | |
7527a782 | 1268 | |
65a124dd MK |
1269 | int cfg80211_iter_combinations(struct wiphy *wiphy, |
1270 | const int num_different_channels, | |
1271 | const u8 radar_detect, | |
1272 | const int iftype_num[NUM_NL80211_IFTYPES], | |
1273 | void (*iter)(const struct ieee80211_iface_combination *c, | |
1274 | void *data), | |
1275 | void *data) | |
cb2d956d | 1276 | { |
8c48b50a FF |
1277 | const struct ieee80211_regdomain *regdom; |
1278 | enum nl80211_dfs_regions region = 0; | |
cb2d956d LC |
1279 | int i, j, iftype; |
1280 | int num_interfaces = 0; | |
1281 | u32 used_iftypes = 0; | |
1282 | ||
8c48b50a FF |
1283 | if (radar_detect) { |
1284 | rcu_read_lock(); | |
1285 | regdom = rcu_dereference(cfg80211_regdomain); | |
1286 | if (regdom) | |
1287 | region = regdom->dfs_region; | |
1288 | rcu_read_unlock(); | |
1289 | } | |
1290 | ||
cb2d956d LC |
1291 | for (iftype = 0; iftype < NUM_NL80211_IFTYPES; iftype++) { |
1292 | num_interfaces += iftype_num[iftype]; | |
1293 | if (iftype_num[iftype] > 0 && | |
1294 | !(wiphy->software_iftypes & BIT(iftype))) | |
1295 | used_iftypes |= BIT(iftype); | |
1296 | } | |
1297 | ||
1298 | for (i = 0; i < wiphy->n_iface_combinations; i++) { | |
1299 | const struct ieee80211_iface_combination *c; | |
1300 | struct ieee80211_iface_limit *limits; | |
1301 | u32 all_iftypes = 0; | |
1302 | ||
1303 | c = &wiphy->iface_combinations[i]; | |
1304 | ||
1305 | if (num_interfaces > c->max_interfaces) | |
1306 | continue; | |
1307 | if (num_different_channels > c->num_different_channels) | |
1308 | continue; | |
1309 | ||
1310 | limits = kmemdup(c->limits, sizeof(limits[0]) * c->n_limits, | |
1311 | GFP_KERNEL); | |
1312 | if (!limits) | |
1313 | return -ENOMEM; | |
1314 | ||
1315 | for (iftype = 0; iftype < NUM_NL80211_IFTYPES; iftype++) { | |
1316 | if (wiphy->software_iftypes & BIT(iftype)) | |
1317 | continue; | |
1318 | for (j = 0; j < c->n_limits; j++) { | |
1319 | all_iftypes |= limits[j].types; | |
1320 | if (!(limits[j].types & BIT(iftype))) | |
1321 | continue; | |
1322 | if (limits[j].max < iftype_num[iftype]) | |
1323 | goto cont; | |
1324 | limits[j].max -= iftype_num[iftype]; | |
1325 | } | |
1326 | } | |
1327 | ||
65d26f29 | 1328 | if (radar_detect != (c->radar_detect_widths & radar_detect)) |
cb2d956d LC |
1329 | goto cont; |
1330 | ||
8c48b50a FF |
1331 | if (radar_detect && c->radar_detect_regions && |
1332 | !(c->radar_detect_regions & BIT(region))) | |
1333 | goto cont; | |
1334 | ||
cb2d956d LC |
1335 | /* Finally check that all iftypes that we're currently |
1336 | * using are actually part of this combination. If they | |
1337 | * aren't then we can't use this combination and have | |
1338 | * to continue to the next. | |
1339 | */ | |
1340 | if ((all_iftypes & used_iftypes) != used_iftypes) | |
1341 | goto cont; | |
1342 | ||
1343 | /* This combination covered all interface types and | |
1344 | * supported the requested numbers, so we're good. | |
1345 | */ | |
65a124dd MK |
1346 | |
1347 | (*iter)(c, data); | |
cb2d956d LC |
1348 | cont: |
1349 | kfree(limits); | |
1350 | } | |
1351 | ||
65a124dd MK |
1352 | return 0; |
1353 | } | |
1354 | EXPORT_SYMBOL(cfg80211_iter_combinations); | |
1355 | ||
1356 | static void | |
1357 | cfg80211_iter_sum_ifcombs(const struct ieee80211_iface_combination *c, | |
1358 | void *data) | |
1359 | { | |
1360 | int *num = data; | |
1361 | (*num)++; | |
1362 | } | |
1363 | ||
1364 | int cfg80211_check_combinations(struct wiphy *wiphy, | |
1365 | const int num_different_channels, | |
1366 | const u8 radar_detect, | |
1367 | const int iftype_num[NUM_NL80211_IFTYPES]) | |
1368 | { | |
1369 | int err, num = 0; | |
1370 | ||
1371 | err = cfg80211_iter_combinations(wiphy, num_different_channels, | |
1372 | radar_detect, iftype_num, | |
1373 | cfg80211_iter_sum_ifcombs, &num); | |
1374 | if (err) | |
1375 | return err; | |
1376 | if (num == 0) | |
1377 | return -EBUSY; | |
1378 | ||
1379 | return 0; | |
cb2d956d LC |
1380 | } |
1381 | EXPORT_SYMBOL(cfg80211_check_combinations); | |
1382 | ||
d4e50c59 MK |
1383 | int cfg80211_can_use_iftype_chan(struct cfg80211_registered_device *rdev, |
1384 | struct wireless_dev *wdev, | |
1385 | enum nl80211_iftype iftype, | |
1386 | struct ieee80211_channel *chan, | |
11c4a075 SW |
1387 | enum cfg80211_chan_mode chanmode, |
1388 | u8 radar_detect) | |
7527a782 JB |
1389 | { |
1390 | struct wireless_dev *wdev_iter; | |
1391 | int num[NUM_NL80211_IFTYPES]; | |
d4e50c59 MK |
1392 | struct ieee80211_channel |
1393 | *used_channels[CFG80211_MAX_NUM_DIFFERENT_CHANNELS]; | |
1394 | struct ieee80211_channel *ch; | |
1395 | enum cfg80211_chan_mode chmode; | |
1396 | int num_different_channels = 0; | |
7527a782 | 1397 | int total = 1; |
cb2d956d | 1398 | int i; |
7527a782 JB |
1399 | |
1400 | ASSERT_RTNL(); | |
1401 | ||
11c4a075 SW |
1402 | if (WARN_ON(hweight32(radar_detect) > 1)) |
1403 | return -EINVAL; | |
1404 | ||
7b2106ae | 1405 | if (WARN_ON(iftype >= NUM_NL80211_IFTYPES)) |
11c4a075 SW |
1406 | return -EINVAL; |
1407 | ||
7527a782 | 1408 | /* Always allow software iftypes */ |
11c4a075 SW |
1409 | if (rdev->wiphy.software_iftypes & BIT(iftype)) { |
1410 | if (radar_detect) | |
1411 | return -EINVAL; | |
7527a782 | 1412 | return 0; |
11c4a075 | 1413 | } |
7527a782 | 1414 | |
7527a782 | 1415 | memset(num, 0, sizeof(num)); |
d4e50c59 | 1416 | memset(used_channels, 0, sizeof(used_channels)); |
7527a782 JB |
1417 | |
1418 | num[iftype] = 1; | |
1419 | ||
73de86a3 LC |
1420 | /* TODO: We'll probably not need this anymore, since this |
1421 | * should only be called with CHAN_MODE_UNDEFINED. There are | |
1422 | * still a couple of pending calls where other chanmodes are | |
1423 | * used, but we should get rid of them. | |
1424 | */ | |
d4e50c59 MK |
1425 | switch (chanmode) { |
1426 | case CHAN_MODE_UNDEFINED: | |
1427 | break; | |
1428 | case CHAN_MODE_SHARED: | |
1429 | WARN_ON(!chan); | |
1430 | used_channels[0] = chan; | |
1431 | num_different_channels++; | |
1432 | break; | |
1433 | case CHAN_MODE_EXCLUSIVE: | |
1434 | num_different_channels++; | |
1435 | break; | |
1436 | } | |
1437 | ||
89a54e48 | 1438 | list_for_each_entry(wdev_iter, &rdev->wdev_list, list) { |
7527a782 JB |
1439 | if (wdev_iter == wdev) |
1440 | continue; | |
6e3ab554 | 1441 | if (wdev_iter->iftype == NL80211_IFTYPE_P2P_DEVICE) { |
98104fde JB |
1442 | if (!wdev_iter->p2p_started) |
1443 | continue; | |
6e3ab554 JB |
1444 | } else if (wdev_iter->netdev) { |
1445 | if (!netif_running(wdev_iter->netdev)) | |
1446 | continue; | |
98104fde JB |
1447 | } else { |
1448 | WARN_ON(1); | |
1449 | } | |
7527a782 JB |
1450 | |
1451 | if (rdev->wiphy.software_iftypes & BIT(wdev_iter->iftype)) | |
1452 | continue; | |
1453 | ||
8e95ea49 JB |
1454 | /* |
1455 | * We may be holding the "wdev" mutex, but now need to lock | |
1456 | * wdev_iter. This is OK because once we get here wdev_iter | |
1457 | * is not wdev (tested above), but we need to use the nested | |
1458 | * locking for lockdep. | |
1459 | */ | |
1460 | mutex_lock_nested(&wdev_iter->mtx, 1); | |
1461 | __acquire(wdev_iter->mtx); | |
9e0e2961 | 1462 | cfg80211_get_chan_state(wdev_iter, &ch, &chmode, &radar_detect); |
8e95ea49 | 1463 | wdev_unlock(wdev_iter); |
d4e50c59 MK |
1464 | |
1465 | switch (chmode) { | |
1466 | case CHAN_MODE_UNDEFINED: | |
1467 | break; | |
1468 | case CHAN_MODE_SHARED: | |
1469 | for (i = 0; i < CFG80211_MAX_NUM_DIFFERENT_CHANNELS; i++) | |
1470 | if (!used_channels[i] || used_channels[i] == ch) | |
1471 | break; | |
1472 | ||
e4e32459 | 1473 | if (i == CFG80211_MAX_NUM_DIFFERENT_CHANNELS) |
d4e50c59 | 1474 | return -EBUSY; |
d4e50c59 MK |
1475 | |
1476 | if (used_channels[i] == NULL) { | |
1477 | used_channels[i] = ch; | |
1478 | num_different_channels++; | |
1479 | } | |
1480 | break; | |
1481 | case CHAN_MODE_EXCLUSIVE: | |
1482 | num_different_channels++; | |
1483 | break; | |
1484 | } | |
1485 | ||
7527a782 JB |
1486 | num[wdev_iter->iftype]++; |
1487 | total++; | |
1488 | } | |
7527a782 | 1489 | |
11c4a075 | 1490 | if (total == 1 && !radar_detect) |
8e8b41f9 JB |
1491 | return 0; |
1492 | ||
cb2d956d LC |
1493 | return cfg80211_check_combinations(&rdev->wiphy, num_different_channels, |
1494 | radar_detect, num); | |
7527a782 | 1495 | } |
34850ab2 JB |
1496 | |
1497 | int ieee80211_get_ratemask(struct ieee80211_supported_band *sband, | |
1498 | const u8 *rates, unsigned int n_rates, | |
1499 | u32 *mask) | |
1500 | { | |
1501 | int i, j; | |
1502 | ||
a401d2bb JB |
1503 | if (!sband) |
1504 | return -EINVAL; | |
1505 | ||
34850ab2 JB |
1506 | if (n_rates == 0 || n_rates > NL80211_MAX_SUPP_RATES) |
1507 | return -EINVAL; | |
1508 | ||
1509 | *mask = 0; | |
1510 | ||
1511 | for (i = 0; i < n_rates; i++) { | |
1512 | int rate = (rates[i] & 0x7f) * 5; | |
1513 | bool found = false; | |
1514 | ||
1515 | for (j = 0; j < sband->n_bitrates; j++) { | |
1516 | if (sband->bitrates[j].bitrate == rate) { | |
1517 | found = true; | |
1518 | *mask |= BIT(j); | |
1519 | break; | |
1520 | } | |
1521 | } | |
1522 | if (!found) | |
1523 | return -EINVAL; | |
1524 | } | |
1525 | ||
1526 | /* | |
1527 | * mask must have at least one bit set here since we | |
1528 | * didn't accept a 0-length rates array nor allowed | |
1529 | * entries in the array that didn't exist | |
1530 | */ | |
1531 | ||
1532 | return 0; | |
1533 | } | |
11a2a357 | 1534 | |
bdfbec2d IP |
1535 | unsigned int ieee80211_get_num_supported_channels(struct wiphy *wiphy) |
1536 | { | |
1537 | enum ieee80211_band band; | |
1538 | unsigned int n_channels = 0; | |
1539 | ||
1540 | for (band = 0; band < IEEE80211_NUM_BANDS; band++) | |
1541 | if (wiphy->bands[band]) | |
1542 | n_channels += wiphy->bands[band]->n_channels; | |
1543 | ||
1544 | return n_channels; | |
1545 | } | |
1546 | EXPORT_SYMBOL(ieee80211_get_num_supported_channels); | |
1547 | ||
11a2a357 JB |
1548 | /* See IEEE 802.1H for LLC/SNAP encapsulation/decapsulation */ |
1549 | /* Ethernet-II snap header (RFC1042 for most EtherTypes) */ | |
1550 | const unsigned char rfc1042_header[] __aligned(2) = | |
1551 | { 0xaa, 0xaa, 0x03, 0x00, 0x00, 0x00 }; | |
1552 | EXPORT_SYMBOL(rfc1042_header); | |
1553 | ||
1554 | /* Bridge-Tunnel header (for EtherTypes ETH_P_AARP and ETH_P_IPX) */ | |
1555 | const unsigned char bridge_tunnel_header[] __aligned(2) = | |
1556 | { 0xaa, 0xaa, 0x03, 0x00, 0x00, 0xf8 }; | |
1557 | EXPORT_SYMBOL(bridge_tunnel_header); |