Book a Demo!
CoCalc Logo Icon
StoreFeaturesDocsShareSupportNewsAboutPoliciesSign UpSign In
nu11secur1ty
GitHub Repository: nu11secur1ty/Kali-Linux
Path: blob/master/ALFA-W1F1/RTL8814AU/core/rtw_ieee80211.c
1307 views
1
/******************************************************************************
2
*
3
* Copyright(c) 2007 - 2017 Realtek Corporation.
4
*
5
* This program is free software; you can redistribute it and/or modify it
6
* under the terms of version 2 of the GNU General Public License as
7
* published by the Free Software Foundation.
8
*
9
* This program is distributed in the hope that it will be useful, but WITHOUT
10
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
11
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for
12
* more details.
13
*
14
*****************************************************************************/
15
#define _IEEE80211_C
16
17
#ifdef CONFIG_PLATFORM_INTEL_BYT
18
#include <linux/fs.h>
19
#endif
20
#include <drv_types.h>
21
22
23
u8 RTW_WPA_OUI_TYPE[] = { 0x00, 0x50, 0xf2, 1 };
24
u16 RTW_WPA_VERSION = 1;
25
u8 WPA_AUTH_KEY_MGMT_NONE[] = { 0x00, 0x50, 0xf2, 0 };
26
u8 WPA_AUTH_KEY_MGMT_UNSPEC_802_1X[] = { 0x00, 0x50, 0xf2, 1 };
27
u8 WPA_AUTH_KEY_MGMT_PSK_OVER_802_1X[] = { 0x00, 0x50, 0xf2, 2 };
28
u8 WPA_CIPHER_SUITE_NONE[] = { 0x00, 0x50, 0xf2, 0 };
29
u8 WPA_CIPHER_SUITE_WEP40[] = { 0x00, 0x50, 0xf2, 1 };
30
u8 WPA_CIPHER_SUITE_TKIP[] = { 0x00, 0x50, 0xf2, 2 };
31
u8 WPA_CIPHER_SUITE_WRAP[] = { 0x00, 0x50, 0xf2, 3 };
32
u8 WPA_CIPHER_SUITE_CCMP[] = { 0x00, 0x50, 0xf2, 4 };
33
u8 WPA_CIPHER_SUITE_WEP104[] = { 0x00, 0x50, 0xf2, 5 };
34
35
u16 RSN_VERSION_BSD = 1;
36
u8 RSN_CIPHER_SUITE_NONE[] = { 0x00, 0x0f, 0xac, 0 };
37
u8 RSN_CIPHER_SUITE_WEP40[] = { 0x00, 0x0f, 0xac, 1 };
38
u8 RSN_CIPHER_SUITE_TKIP[] = { 0x00, 0x0f, 0xac, 2 };
39
u8 RSN_CIPHER_SUITE_WRAP[] = { 0x00, 0x0f, 0xac, 3 };
40
u8 RSN_CIPHER_SUITE_CCMP[] = { 0x00, 0x0f, 0xac, 4 };
41
u8 RSN_CIPHER_SUITE_WEP104[] = { 0x00, 0x0f, 0xac, 5 };
42
43
u8 WLAN_AKM_8021X[] = {0x00, 0x0f, 0xac, 1};
44
u8 WLAN_AKM_PSK[] = {0x00, 0x0f, 0xac, 2};
45
u8 WLAN_AKM_FT_8021X[] = {0x00, 0x0f, 0xac, 3};
46
u8 WLAN_AKM_FT_PSK[] = {0x00, 0x0f, 0xac, 4};
47
u8 WLAN_AKM_8021X_SHA256[] = {0x00, 0x0f, 0xac, 5};
48
u8 WLAN_AKM_PSK_SHA256[] = {0x00, 0x0f, 0xac, 6};
49
u8 WLAN_AKM_TDLS[] = {0x00, 0x0f, 0xac, 7};
50
u8 WLAN_AKM_SAE[] = {0x00, 0x0f, 0xac, 8};
51
u8 WLAN_AKM_FT_OVER_SAE[] = {0x00, 0x0f, 0xac, 9};
52
u8 WLAN_AKM_8021X_SUITE_B[] = {0x00, 0x0f, 0xac, 11};
53
u8 WLAN_AKM_8021X_SUITE_B_192[] = {0x00, 0x0f, 0xac, 12};
54
u8 WLAN_AKM_FILS_SHA256[] = {0x00, 0x0f, 0xac, 14};
55
u8 WLAN_AKM_FILS_SHA384[] = {0x00, 0x0f, 0xac, 15};
56
u8 WLAN_AKM_FT_FILS_SHA256[] = {0x00, 0x0f, 0xac, 16};
57
u8 WLAN_AKM_FT_FILS_SHA384[] = {0x00, 0x0f, 0xac, 17};
58
/* -----------------------------------------------------------
59
* for adhoc-master to generate ie and provide supported-rate to fw
60
* ----------------------------------------------------------- */
61
62
u8 WIFI_CCKRATES[] = {
63
(IEEE80211_CCK_RATE_1MB | IEEE80211_BASIC_RATE_MASK),
64
(IEEE80211_CCK_RATE_2MB | IEEE80211_BASIC_RATE_MASK),
65
(IEEE80211_CCK_RATE_5MB | IEEE80211_BASIC_RATE_MASK),
66
(IEEE80211_CCK_RATE_11MB | IEEE80211_BASIC_RATE_MASK)
67
};
68
69
u8 WIFI_OFDMRATES[] = {
70
(IEEE80211_OFDM_RATE_6MB),
71
(IEEE80211_OFDM_RATE_9MB),
72
(IEEE80211_OFDM_RATE_12MB),
73
(IEEE80211_OFDM_RATE_18MB),
74
(IEEE80211_OFDM_RATE_24MB),
75
IEEE80211_OFDM_RATE_36MB,
76
IEEE80211_OFDM_RATE_48MB,
77
IEEE80211_OFDM_RATE_54MB
78
};
79
80
u8 mgn_rates_cck[4] = {MGN_1M, MGN_2M, MGN_5_5M, MGN_11M};
81
u8 mgn_rates_ofdm[8] = {MGN_6M, MGN_9M, MGN_12M, MGN_18M, MGN_24M, MGN_36M, MGN_48M, MGN_54M};
82
u8 mgn_rates_mcs0_7[8] = {MGN_MCS0, MGN_MCS1, MGN_MCS2, MGN_MCS3, MGN_MCS4, MGN_MCS5, MGN_MCS6, MGN_MCS7};
83
u8 mgn_rates_mcs8_15[8] = {MGN_MCS8, MGN_MCS9, MGN_MCS10, MGN_MCS11, MGN_MCS12, MGN_MCS13, MGN_MCS14, MGN_MCS15};
84
u8 mgn_rates_mcs16_23[8] = {MGN_MCS16, MGN_MCS17, MGN_MCS18, MGN_MCS19, MGN_MCS20, MGN_MCS21, MGN_MCS22, MGN_MCS23};
85
u8 mgn_rates_mcs24_31[8] = {MGN_MCS24, MGN_MCS25, MGN_MCS26, MGN_MCS27, MGN_MCS28, MGN_MCS29, MGN_MCS30, MGN_MCS31};
86
u8 mgn_rates_vht1ss[10] = {MGN_VHT1SS_MCS0, MGN_VHT1SS_MCS1, MGN_VHT1SS_MCS2, MGN_VHT1SS_MCS3, MGN_VHT1SS_MCS4
87
, MGN_VHT1SS_MCS5, MGN_VHT1SS_MCS6, MGN_VHT1SS_MCS7, MGN_VHT1SS_MCS8, MGN_VHT1SS_MCS9
88
};
89
u8 mgn_rates_vht2ss[10] = {MGN_VHT2SS_MCS0, MGN_VHT2SS_MCS1, MGN_VHT2SS_MCS2, MGN_VHT2SS_MCS3, MGN_VHT2SS_MCS4
90
, MGN_VHT2SS_MCS5, MGN_VHT2SS_MCS6, MGN_VHT2SS_MCS7, MGN_VHT2SS_MCS8, MGN_VHT2SS_MCS9
91
};
92
u8 mgn_rates_vht3ss[10] = {MGN_VHT3SS_MCS0, MGN_VHT3SS_MCS1, MGN_VHT3SS_MCS2, MGN_VHT3SS_MCS3, MGN_VHT3SS_MCS4
93
, MGN_VHT3SS_MCS5, MGN_VHT3SS_MCS6, MGN_VHT3SS_MCS7, MGN_VHT3SS_MCS8, MGN_VHT3SS_MCS9
94
};
95
u8 mgn_rates_vht4ss[10] = {MGN_VHT4SS_MCS0, MGN_VHT4SS_MCS1, MGN_VHT4SS_MCS2, MGN_VHT4SS_MCS3, MGN_VHT4SS_MCS4
96
, MGN_VHT4SS_MCS5, MGN_VHT4SS_MCS6, MGN_VHT4SS_MCS7, MGN_VHT4SS_MCS8, MGN_VHT4SS_MCS9
97
};
98
99
static const char *const _rate_section_str[] = {
100
"CCK",
101
"OFDM",
102
"HT_1SS",
103
"HT_2SS",
104
"HT_3SS",
105
"HT_4SS",
106
"VHT_1SS",
107
"VHT_2SS",
108
"VHT_3SS",
109
"VHT_4SS",
110
"RATE_SECTION_UNKNOWN",
111
};
112
113
const char *rate_section_str(u8 section)
114
{
115
section = (section >= RATE_SECTION_NUM) ? RATE_SECTION_NUM : section;
116
return _rate_section_str[section];
117
}
118
119
struct rate_section_ent rates_by_sections[RATE_SECTION_NUM] = {
120
{RF_1TX, 4, mgn_rates_cck},
121
{RF_1TX, 8, mgn_rates_ofdm},
122
{RF_1TX, 8, mgn_rates_mcs0_7},
123
{RF_2TX, 8, mgn_rates_mcs8_15},
124
{RF_3TX, 8, mgn_rates_mcs16_23},
125
{RF_4TX, 8, mgn_rates_mcs24_31},
126
{RF_1TX, 10, mgn_rates_vht1ss},
127
{RF_2TX, 10, mgn_rates_vht2ss},
128
{RF_3TX, 10, mgn_rates_vht3ss},
129
{RF_4TX, 10, mgn_rates_vht4ss},
130
};
131
132
int rtw_get_bit_value_from_ieee_value(u8 val)
133
{
134
unsigned char dot11_rate_table[] = {2, 4, 11, 22, 12, 18, 24, 36, 48, 72, 96, 108, 0}; /* last element must be zero!! */
135
136
int i = 0;
137
while (dot11_rate_table[i] != 0) {
138
if (dot11_rate_table[i] == val)
139
return BIT(i);
140
i++;
141
}
142
return 0;
143
}
144
uint rtw_get_cckrate_size(u8 *rate, u32 rate_length)
145
{
146
int i = 0;
147
while(i < rate_length){
148
RTW_DBG("%s, rate[%d]=%u\n", __FUNCTION__, i, rate[i]);
149
if (((rate[i] & 0x7f) == 2) || ((rate[i] & 0x7f) == 4) ||
150
((rate[i] & 0x7f) == 11) || ((rate[i] & 0x7f) == 22))
151
i++;
152
else
153
break;
154
}
155
return i;
156
}
157
158
uint rtw_is_cckrates_included(u8 *rate)
159
{
160
u32 i = 0;
161
162
while (rate[i] != 0) {
163
if ((((rate[i]) & 0x7f) == 2) || (((rate[i]) & 0x7f) == 4) ||
164
(((rate[i]) & 0x7f) == 11) || (((rate[i]) & 0x7f) == 22))
165
return _TRUE;
166
i++;
167
}
168
169
return _FALSE;
170
}
171
172
uint rtw_is_cckratesonly_included(u8 *rate)
173
{
174
u32 i = 0;
175
176
177
while (rate[i] != 0) {
178
if ((((rate[i]) & 0x7f) != 2) && (((rate[i]) & 0x7f) != 4) &&
179
(((rate[i]) & 0x7f) != 11) && (((rate[i]) & 0x7f) != 22))
180
return _FALSE;
181
182
i++;
183
}
184
185
return _TRUE;
186
187
}
188
189
int rtw_check_network_type(unsigned char *rate, int ratelen, int channel)
190
{
191
if (channel > 14) {
192
if ((rtw_is_cckrates_included(rate)) == _TRUE)
193
return WIRELESS_INVALID;
194
else
195
return WIRELESS_11A;
196
} else { /* could be pure B, pure G, or B/G */
197
if ((rtw_is_cckratesonly_included(rate)) == _TRUE)
198
return WIRELESS_11B;
199
else if ((rtw_is_cckrates_included(rate)) == _TRUE)
200
return WIRELESS_11BG;
201
else
202
return WIRELESS_11G;
203
}
204
205
}
206
207
u8 *rtw_set_fixed_ie(unsigned char *pbuf, unsigned int len, unsigned char *source,
208
unsigned int *frlen)
209
{
210
_rtw_memcpy((void *)pbuf, (void *)source, len);
211
*frlen = *frlen + len;
212
return pbuf + len;
213
}
214
215
/* rtw_set_ie will update frame length */
216
u8 *rtw_set_ie
217
(
218
u8 *pbuf,
219
sint index,
220
uint len,
221
const u8 *source,
222
uint *frlen /* frame length */
223
)
224
{
225
*pbuf = (u8)index;
226
227
*(pbuf + 1) = (u8)len;
228
229
if (len > 0)
230
_rtw_memcpy((void *)(pbuf + 2), (void *)source, len);
231
232
if (frlen)
233
*frlen = *frlen + (len + 2);
234
235
return pbuf + len + 2;
236
}
237
238
inline u8 *rtw_set_ie_ch_switch(u8 *buf, u32 *buf_len, u8 ch_switch_mode,
239
u8 new_ch, u8 ch_switch_cnt)
240
{
241
u8 ie_data[3];
242
243
ie_data[0] = ch_switch_mode;
244
ie_data[1] = new_ch;
245
ie_data[2] = ch_switch_cnt;
246
return rtw_set_ie(buf, WLAN_EID_CHANNEL_SWITCH, 3, ie_data, buf_len);
247
}
248
249
inline u8 secondary_ch_offset_to_hal_ch_offset(u8 ch_offset)
250
{
251
if (ch_offset == SCN)
252
return HAL_PRIME_CHNL_OFFSET_DONT_CARE;
253
else if (ch_offset == SCA)
254
return HAL_PRIME_CHNL_OFFSET_LOWER;
255
else if (ch_offset == SCB)
256
return HAL_PRIME_CHNL_OFFSET_UPPER;
257
258
return HAL_PRIME_CHNL_OFFSET_DONT_CARE;
259
}
260
261
inline u8 hal_ch_offset_to_secondary_ch_offset(u8 ch_offset)
262
{
263
if (ch_offset == HAL_PRIME_CHNL_OFFSET_DONT_CARE)
264
return SCN;
265
else if (ch_offset == HAL_PRIME_CHNL_OFFSET_LOWER)
266
return SCA;
267
else if (ch_offset == HAL_PRIME_CHNL_OFFSET_UPPER)
268
return SCB;
269
270
return SCN;
271
}
272
273
inline u8 *rtw_set_ie_secondary_ch_offset(u8 *buf, u32 *buf_len, u8 secondary_ch_offset)
274
{
275
return rtw_set_ie(buf, WLAN_EID_SECONDARY_CHANNEL_OFFSET, 1, &secondary_ch_offset, buf_len);
276
}
277
278
inline u8 *rtw_set_ie_mesh_ch_switch_parm(u8 *buf, u32 *buf_len, u8 ttl,
279
u8 flags, u16 reason, u16 precedence)
280
{
281
u8 ie_data[6];
282
283
ie_data[0] = ttl;
284
ie_data[1] = flags;
285
RTW_PUT_LE16((u8 *)&ie_data[2], reason);
286
RTW_PUT_LE16((u8 *)&ie_data[4], precedence);
287
288
return rtw_set_ie(buf, 0x118, 6, ie_data, buf_len);
289
}
290
291
/*----------------------------------------------------------------------------
292
index: the information element id index, limit is the limit for search
293
-----------------------------------------------------------------------------*/
294
u8 *rtw_get_ie(const u8 *pbuf, sint index, sint *len, sint limit)
295
{
296
sint tmp, i;
297
const u8 *p;
298
if (limit < 1) {
299
return NULL;
300
}
301
302
p = pbuf;
303
i = 0;
304
*len = 0;
305
while (1) {
306
if (*p == index) {
307
*len = *(p + 1);
308
return (u8 *)p;
309
} else {
310
tmp = *(p + 1);
311
p += (tmp + 2);
312
i += (tmp + 2);
313
}
314
if (i >= limit)
315
break;
316
}
317
return NULL;
318
}
319
320
/**
321
* rtw_get_ie_ex - Search specific IE from a series of IEs
322
* @in_ie: Address of IEs to search
323
* @in_len: Length limit from in_ie
324
* @eid: Element ID to match
325
* @oui: OUI to match
326
* @oui_len: OUI length
327
* @ie: If not NULL and the specific IE is found, the IE will be copied to the buf starting from the specific IE
328
* @ielen: If not NULL and the specific IE is found, will set to the length of the entire IE
329
*
330
* Returns: The address of the specific IE found, or NULL
331
*/
332
u8 *rtw_get_ie_ex(const u8 *in_ie, uint in_len, u8 eid, const u8 *oui, u8 oui_len, u8 *ie, uint *ielen)
333
{
334
uint cnt;
335
const u8 *target_ie = NULL;
336
337
338
if (ielen)
339
*ielen = 0;
340
341
if (!in_ie || in_len <= 0)
342
return (u8 *)target_ie;
343
344
cnt = 0;
345
346
while (cnt < in_len) {
347
if (eid == in_ie[cnt]
348
&& (!oui || _rtw_memcmp(&in_ie[cnt + 2], oui, oui_len) == _TRUE)) {
349
target_ie = &in_ie[cnt];
350
351
if (ie)
352
_rtw_memcpy(ie, &in_ie[cnt], in_ie[cnt + 1] + 2);
353
354
if (ielen)
355
*ielen = in_ie[cnt + 1] + 2;
356
357
break;
358
} else {
359
cnt += in_ie[cnt + 1] + 2; /* goto next */
360
}
361
362
}
363
364
return (u8 *)target_ie;
365
}
366
367
/**
368
* rtw_ies_remove_ie - Find matching IEs and remove
369
* @ies: Address of IEs to search
370
* @ies_len: Pointer of length of ies, will update to new length
371
* @offset: The offset to start scarch
372
* @eid: Element ID to match
373
* @oui: OUI to match
374
* @oui_len: OUI length
375
*
376
* Returns: _SUCCESS: ies is updated, _FAIL: not updated
377
*/
378
int rtw_ies_remove_ie(u8 *ies, uint *ies_len, uint offset, u8 eid, u8 *oui, u8 oui_len)
379
{
380
int ret = _FAIL;
381
u8 *target_ie;
382
u32 target_ielen;
383
u8 *start;
384
uint search_len;
385
386
if (!ies || !ies_len || *ies_len <= offset)
387
goto exit;
388
389
start = ies + offset;
390
search_len = *ies_len - offset;
391
392
while (1) {
393
target_ie = rtw_get_ie_ex(start, search_len, eid, oui, oui_len, NULL, &target_ielen);
394
if (target_ie && target_ielen) {
395
u8 *remain_ies = target_ie + target_ielen;
396
uint remain_len = search_len - (remain_ies - start);
397
398
_rtw_memmove(target_ie, remain_ies, remain_len);
399
*ies_len = *ies_len - target_ielen;
400
ret = _SUCCESS;
401
402
start = target_ie;
403
search_len = remain_len;
404
} else
405
break;
406
}
407
exit:
408
return ret;
409
}
410
411
void rtw_set_supported_rate(u8 *SupportedRates, uint mode)
412
{
413
414
_rtw_memset(SupportedRates, 0, NDIS_802_11_LENGTH_RATES_EX);
415
416
switch (mode) {
417
case WIRELESS_11B:
418
_rtw_memcpy(SupportedRates, WIFI_CCKRATES, IEEE80211_CCK_RATE_LEN);
419
break;
420
421
case WIRELESS_11G:
422
case WIRELESS_11A:
423
case WIRELESS_11_5N:
424
case WIRELESS_11A_5N: /* Todo: no basic rate for ofdm ? */
425
case WIRELESS_11_5AC:
426
_rtw_memcpy(SupportedRates, WIFI_OFDMRATES, IEEE80211_NUM_OFDM_RATESLEN);
427
break;
428
429
case WIRELESS_11BG:
430
case WIRELESS_11G_24N:
431
case WIRELESS_11_24N:
432
case WIRELESS_11BG_24N:
433
_rtw_memcpy(SupportedRates, WIFI_CCKRATES, IEEE80211_CCK_RATE_LEN);
434
_rtw_memcpy(SupportedRates + IEEE80211_CCK_RATE_LEN, WIFI_OFDMRATES, IEEE80211_NUM_OFDM_RATESLEN);
435
break;
436
437
}
438
}
439
440
void rtw_filter_suppport_rateie(WLAN_BSSID_EX *pbss_network, u8 keep)
441
{
442
u8 i, idx = 0, new_rate[NDIS_802_11_LENGTH_RATES_EX], *p;
443
uint iscck, isofdm, ie_orilen = 0, remain_len;
444
u8 *remain_ies;
445
446
p = rtw_get_ie(pbss_network->IEs + _BEACON_IE_OFFSET_, _SUPPORTEDRATES_IE_, &ie_orilen, (pbss_network->IELength - _BEACON_IE_OFFSET_));
447
if (!p)
448
return;
449
450
_rtw_memset(new_rate, 0, NDIS_802_11_LENGTH_RATES_EX);
451
for (i=0; i < ie_orilen; i++) {
452
iscck = rtw_is_cck_rate(p[i+2]);
453
isofdm= rtw_is_ofdm_rate(p[i+2]);
454
if (((keep == CCK) && iscck)
455
|| ((keep == OFDM) && isofdm))
456
new_rate[idx++]= rtw_is_basic_rate_ofdm(p[i+2]) ? p[i+2]|IEEE80211_BASIC_RATE_MASK : p[i+2];
457
}
458
/* update rate ie */
459
p[1] = idx;
460
_rtw_memcpy(p+2, new_rate, idx);
461
/* update remain ie & IELength*/
462
remain_ies = p + 2 + ie_orilen;
463
remain_len = pbss_network->IELength - (remain_ies - pbss_network->IEs);
464
_rtw_memmove(p+2+idx, remain_ies, remain_len);
465
pbss_network->IELength -= (ie_orilen - idx);
466
}
467
468
469
/*
470
Adjust those items by given wireless_mode
471
1. pbss_network->IELength
472
2. pbss_network->IE (SUPPORTRATE & EXT_SUPPORTRATE)
473
3. pbss_network->SupportedRates
474
*/
475
476
u8 rtw_update_rate_bymode(WLAN_BSSID_EX *pbss_network, u32 mode)
477
{
478
u8 network_type, *p, *ie = pbss_network->IEs;
479
sint ie_len;
480
uint network_ielen = pbss_network->IELength;
481
482
if (mode == WIRELESS_11B) {
483
/*only keep CCK in support_rate IE and remove whole ext_support_rate IE*/
484
rtw_filter_suppport_rateie(pbss_network, CCK);
485
p = rtw_get_ie(ie + _BEACON_IE_OFFSET_, _EXT_SUPPORTEDRATES_IE_, &ie_len, pbss_network->IELength - _BEACON_IE_OFFSET_);
486
if (p) {
487
rtw_ies_remove_ie(ie , &network_ielen, _BEACON_IE_OFFSET_, _EXT_SUPPORTEDRATES_IE_, NULL, 0);
488
pbss_network->IELength -= ie_len;
489
}
490
network_type = WIRELESS_11B;
491
} else if ((mode & WIRELESS_11B) == 0) {
492
/* Remove CCK in support_rate IE */
493
rtw_filter_suppport_rateie(pbss_network, OFDM);
494
if (pbss_network->Configuration.DSConfig > 14)
495
network_type = WIRELESS_11A;
496
else
497
network_type = WIRELESS_11G;
498
} else
499
network_type = WIRELESS_11BG; /* do nothing */
500
501
rtw_set_supported_rate(pbss_network->SupportedRates, network_type);
502
return network_type;
503
}
504
505
uint rtw_get_rateset_len(u8 *rateset)
506
{
507
uint i = 0;
508
while (1) {
509
if ((rateset[i]) == 0)
510
break;
511
512
if (i > 12)
513
break;
514
515
i++;
516
}
517
return i;
518
}
519
520
int rtw_generate_ie(struct registry_priv *pregistrypriv)
521
{
522
u8 wireless_mode;
523
int sz = 0, rateLen;
524
WLAN_BSSID_EX *pdev_network = &pregistrypriv->dev_network;
525
u8 *ie = pdev_network->IEs;
526
527
528
/* timestamp will be inserted by hardware */
529
sz += 8;
530
ie += sz;
531
532
/* beacon interval : 2bytes */
533
*(u16 *)ie = cpu_to_le16((u16)pdev_network->Configuration.BeaconPeriod); /* BCN_INTERVAL; */
534
sz += 2;
535
ie += 2;
536
537
/* capability info */
538
*(u16 *)ie = 0;
539
540
*(u16 *)ie |= cpu_to_le16(cap_IBSS);
541
542
if (pregistrypriv->preamble == PREAMBLE_SHORT)
543
*(u16 *)ie |= cpu_to_le16(cap_ShortPremble);
544
545
if (pdev_network->Privacy)
546
*(u16 *)ie |= cpu_to_le16(cap_Privacy);
547
548
sz += 2;
549
ie += 2;
550
551
/* SSID */
552
ie = rtw_set_ie(ie, _SSID_IE_, pdev_network->Ssid.SsidLength, pdev_network->Ssid.Ssid, &sz);
553
554
/* supported rates */
555
if (pregistrypriv->wireless_mode == WIRELESS_11ABGN) {
556
if (pdev_network->Configuration.DSConfig > 14)
557
wireless_mode = WIRELESS_11A_5N;
558
else
559
wireless_mode = WIRELESS_11BG_24N;
560
} else if (pregistrypriv->wireless_mode == WIRELESS_MODE_MAX) { /* WIRELESS_11ABGN | WIRELESS_11AC */
561
if (pdev_network->Configuration.DSConfig > 14)
562
wireless_mode = WIRELESS_11_5AC;
563
else
564
wireless_mode = WIRELESS_11BG_24N;
565
} else
566
wireless_mode = pregistrypriv->wireless_mode;
567
568
rtw_set_supported_rate(pdev_network->SupportedRates, wireless_mode) ;
569
570
rateLen = rtw_get_rateset_len(pdev_network->SupportedRates);
571
572
if (rateLen > 8) {
573
ie = rtw_set_ie(ie, _SUPPORTEDRATES_IE_, 8, pdev_network->SupportedRates, &sz);
574
/* ie = rtw_set_ie(ie, _EXT_SUPPORTEDRATES_IE_, (rateLen - 8), (pdev_network->SupportedRates + 8), &sz); */
575
} else
576
ie = rtw_set_ie(ie, _SUPPORTEDRATES_IE_, rateLen, pdev_network->SupportedRates, &sz);
577
578
/* DS parameter set */
579
ie = rtw_set_ie(ie, _DSSET_IE_, 1, (u8 *)&(pdev_network->Configuration.DSConfig), &sz);
580
581
582
/* IBSS Parameter Set */
583
584
ie = rtw_set_ie(ie, _IBSS_PARA_IE_, 2, (u8 *)&(pdev_network->Configuration.ATIMWindow), &sz);
585
586
if (rateLen > 8)
587
ie = rtw_set_ie(ie, _EXT_SUPPORTEDRATES_IE_, (rateLen - 8), (pdev_network->SupportedRates + 8), &sz);
588
589
#ifdef CONFIG_80211N_HT
590
/* HT Cap. */
591
if (is_supported_ht(pregistrypriv->wireless_mode)
592
&& (pregistrypriv->ht_enable == _TRUE)) {
593
/* todo: */
594
}
595
#endif /* CONFIG_80211N_HT */
596
597
/* pdev_network->IELength = sz; */ /* update IELength */
598
599
600
/* return _SUCCESS; */
601
602
return sz;
603
604
}
605
606
unsigned char *rtw_get_wpa_ie(unsigned char *pie, int *wpa_ie_len, int limit)
607
{
608
int len;
609
u16 val16;
610
unsigned char wpa_oui_type[] = {0x00, 0x50, 0xf2, 0x01};
611
u8 *pbuf = pie;
612
int limit_new = limit;
613
614
while (1) {
615
pbuf = rtw_get_ie(pbuf, _WPA_IE_ID_, &len, limit_new);
616
617
if (pbuf) {
618
619
/* check if oui matches... */
620
if (_rtw_memcmp((pbuf + 2), wpa_oui_type, sizeof(wpa_oui_type)) == _FALSE)
621
622
goto check_next_ie;
623
624
/* check version... */
625
_rtw_memcpy((u8 *)&val16, (pbuf + 6), sizeof(val16));
626
627
val16 = le16_to_cpu(val16);
628
if (val16 != 0x0001)
629
goto check_next_ie;
630
631
*wpa_ie_len = *(pbuf + 1);
632
633
return pbuf;
634
635
} else {
636
637
*wpa_ie_len = 0;
638
return NULL;
639
}
640
641
check_next_ie:
642
643
limit_new = limit - (pbuf - pie) - 2 - len;
644
645
if (limit_new <= 0)
646
break;
647
648
pbuf += (2 + len);
649
650
}
651
652
*wpa_ie_len = 0;
653
654
return NULL;
655
656
}
657
658
unsigned char *rtw_get_wpa2_ie(unsigned char *pie, int *rsn_ie_len, int limit)
659
{
660
661
return rtw_get_ie(pie, _WPA2_IE_ID_, rsn_ie_len, limit);
662
663
}
664
665
int rtw_get_wpa_cipher_suite(u8 *s)
666
{
667
if (_rtw_memcmp(s, WPA_CIPHER_SUITE_NONE, WPA_SELECTOR_LEN) == _TRUE)
668
return WPA_CIPHER_NONE;
669
if (_rtw_memcmp(s, WPA_CIPHER_SUITE_WEP40, WPA_SELECTOR_LEN) == _TRUE)
670
return WPA_CIPHER_WEP40;
671
if (_rtw_memcmp(s, WPA_CIPHER_SUITE_TKIP, WPA_SELECTOR_LEN) == _TRUE)
672
return WPA_CIPHER_TKIP;
673
if (_rtw_memcmp(s, WPA_CIPHER_SUITE_CCMP, WPA_SELECTOR_LEN) == _TRUE)
674
return WPA_CIPHER_CCMP;
675
if (_rtw_memcmp(s, WPA_CIPHER_SUITE_WEP104, WPA_SELECTOR_LEN) == _TRUE)
676
return WPA_CIPHER_WEP104;
677
678
return 0;
679
}
680
681
int rtw_get_wpa2_cipher_suite(u8 *s)
682
{
683
if (_rtw_memcmp(s, RSN_CIPHER_SUITE_NONE, RSN_SELECTOR_LEN) == _TRUE)
684
return WPA_CIPHER_NONE;
685
if (_rtw_memcmp(s, RSN_CIPHER_SUITE_WEP40, RSN_SELECTOR_LEN) == _TRUE)
686
return WPA_CIPHER_WEP40;
687
if (_rtw_memcmp(s, RSN_CIPHER_SUITE_TKIP, RSN_SELECTOR_LEN) == _TRUE)
688
return WPA_CIPHER_TKIP;
689
if (_rtw_memcmp(s, RSN_CIPHER_SUITE_CCMP, RSN_SELECTOR_LEN) == _TRUE)
690
return WPA_CIPHER_CCMP;
691
if (_rtw_memcmp(s, RSN_CIPHER_SUITE_WEP104, RSN_SELECTOR_LEN) == _TRUE)
692
return WPA_CIPHER_WEP104;
693
694
return 0;
695
}
696
697
u32 rtw_get_akm_suite_bitmap(u8 *s)
698
{
699
if (_rtw_memcmp(s, WLAN_AKM_8021X, RSN_SELECTOR_LEN) == _TRUE)
700
return WLAN_AKM_TYPE_8021X;
701
if (_rtw_memcmp(s, WLAN_AKM_PSK, RSN_SELECTOR_LEN) == _TRUE)
702
return WLAN_AKM_TYPE_PSK;
703
if (_rtw_memcmp(s, WLAN_AKM_FT_8021X, RSN_SELECTOR_LEN) == _TRUE)
704
return WLAN_AKM_TYPE_FT_8021X;
705
if (_rtw_memcmp(s, WLAN_AKM_FT_PSK, RSN_SELECTOR_LEN) == _TRUE)
706
return WLAN_AKM_TYPE_FT_PSK;
707
if (_rtw_memcmp(s, WLAN_AKM_8021X_SHA256, RSN_SELECTOR_LEN) == _TRUE)
708
return WLAN_AKM_TYPE_8021X_SHA256;
709
if (_rtw_memcmp(s, WLAN_AKM_PSK_SHA256, RSN_SELECTOR_LEN) == _TRUE)
710
return WLAN_AKM_TYPE_PSK_SHA256;
711
if (_rtw_memcmp(s, WLAN_AKM_TDLS, RSN_SELECTOR_LEN) == _TRUE)
712
return WLAN_AKM_TYPE_TDLS;
713
if (_rtw_memcmp(s, WLAN_AKM_SAE, RSN_SELECTOR_LEN) == _TRUE)
714
return WLAN_AKM_TYPE_SAE;
715
if (_rtw_memcmp(s, WLAN_AKM_FT_OVER_SAE, RSN_SELECTOR_LEN) == _TRUE)
716
return WLAN_AKM_TYPE_FT_OVER_SAE;
717
if (_rtw_memcmp(s, WLAN_AKM_8021X_SUITE_B, RSN_SELECTOR_LEN) == _TRUE)
718
return WLAN_AKM_TYPE_8021X_SUITE_B;
719
if (_rtw_memcmp(s, WLAN_AKM_8021X_SUITE_B_192, RSN_SELECTOR_LEN) == _TRUE)
720
return WLAN_AKM_TYPE_8021X_SUITE_B_192;
721
if (_rtw_memcmp(s, WLAN_AKM_FILS_SHA256, RSN_SELECTOR_LEN) == _TRUE)
722
return WLAN_AKM_TYPE_FILS_SHA256;
723
if (_rtw_memcmp(s, WLAN_AKM_FILS_SHA384, RSN_SELECTOR_LEN) == _TRUE)
724
return WLAN_AKM_TYPE_FILS_SHA384;
725
if (_rtw_memcmp(s, WLAN_AKM_FT_FILS_SHA256, RSN_SELECTOR_LEN) == _TRUE)
726
return WLAN_AKM_TYPE_FT_FILS_SHA256;
727
if (_rtw_memcmp(s, WLAN_AKM_FT_FILS_SHA384, RSN_SELECTOR_LEN) == _TRUE)
728
return WLAN_AKM_TYPE_FT_FILS_SHA384;
729
730
return 0;
731
}
732
733
int rtw_parse_wpa_ie(u8 *wpa_ie, int wpa_ie_len, int *group_cipher,
734
int *pairwise_cipher, u32 *akm)
735
{
736
int i, ret = _SUCCESS;
737
int left, count;
738
u8 *pos;
739
u8 SUITE_1X[4] = {0x00, 0x50, 0xf2, 1};
740
741
if (wpa_ie_len <= 0) {
742
/* No WPA IE - fail silently */
743
return _FAIL;
744
}
745
746
747
if ((*wpa_ie != _WPA_IE_ID_) || (*(wpa_ie + 1) != (u8)(wpa_ie_len - 2)) ||
748
(_rtw_memcmp(wpa_ie + 2, RTW_WPA_OUI_TYPE, WPA_SELECTOR_LEN) != _TRUE))
749
return _FAIL;
750
751
pos = wpa_ie;
752
753
pos += 8;
754
left = wpa_ie_len - 8;
755
756
757
/* group_cipher */
758
if (left >= WPA_SELECTOR_LEN) {
759
760
*group_cipher = rtw_get_wpa_cipher_suite(pos);
761
762
pos += WPA_SELECTOR_LEN;
763
left -= WPA_SELECTOR_LEN;
764
765
} else if (left > 0) {
766
767
return _FAIL;
768
}
769
770
771
/* pairwise_cipher */
772
if (left >= 2) {
773
/* count = le16_to_cpu(*(u16*)pos); */
774
count = RTW_GET_LE16(pos);
775
pos += 2;
776
left -= 2;
777
778
if (count == 0 || left < count * WPA_SELECTOR_LEN) {
779
return _FAIL;
780
}
781
782
for (i = 0; i < count; i++) {
783
*pairwise_cipher |= rtw_get_wpa_cipher_suite(pos);
784
785
pos += WPA_SELECTOR_LEN;
786
left -= WPA_SELECTOR_LEN;
787
}
788
789
} else if (left == 1) {
790
return _FAIL;
791
}
792
793
if (akm) {
794
if (left >= 6) {
795
pos += 2;
796
if (_rtw_memcmp(pos, SUITE_1X, 4) == 1) {
797
*akm = WLAN_AKM_TYPE_8021X;
798
}
799
}
800
}
801
802
return ret;
803
804
}
805
806
int rtw_rsne_info_parse(const u8 *ie, uint ie_len, struct rsne_info *info)
807
{
808
const u8 *pos = ie;
809
u16 cnt;
810
811
_rtw_memset(info, 0, sizeof(struct rsne_info));
812
813
if (ie + ie_len < pos + 4)
814
goto err;
815
816
if (*ie != WLAN_EID_RSN || *(ie + 1) != ie_len - 2)
817
goto err;
818
pos += 2 + 2;
819
820
/* Group CS */
821
if (ie + ie_len < pos + 4) {
822
if (ie + ie_len != pos)
823
goto err;
824
goto exit;
825
}
826
info->gcs = (u8 *)pos;
827
pos += 4;
828
829
/* Pairwise CS */
830
if (ie + ie_len < pos + 2) {
831
if (ie + ie_len != pos)
832
goto err;
833
goto exit;
834
}
835
cnt = RTW_GET_LE16(pos);
836
pos += 2;
837
if (ie + ie_len < pos + 4 * cnt) {
838
if (ie + ie_len != pos)
839
goto err;
840
goto exit;
841
}
842
info->pcs_cnt = cnt;
843
info->pcs_list = (u8 *)pos;
844
pos += 4 * cnt;
845
846
/* AKM */
847
if (ie + ie_len < pos + 2) {
848
if (ie + ie_len != pos)
849
goto err;
850
goto exit;
851
}
852
cnt = RTW_GET_LE16(pos);
853
pos += 2;
854
if (ie + ie_len < pos + 4 * cnt) {
855
if (ie + ie_len != pos)
856
goto err;
857
goto exit;
858
}
859
info->akm_cnt = cnt;
860
info->akm_list = (u8 *)pos;
861
pos += 4 * cnt;
862
863
/* RSN cap */
864
if (ie + ie_len < pos + 2) {
865
if (ie + ie_len != pos)
866
goto err;
867
goto exit;
868
}
869
info->cap = (u8 *)pos;
870
pos += 2;
871
872
/* PMKID */
873
if (ie + ie_len < pos + 2) {
874
if (ie + ie_len != pos)
875
goto err;
876
goto exit;
877
}
878
cnt = RTW_GET_LE16(pos);
879
pos += 2;
880
if (ie + ie_len < pos + 16 * cnt) {
881
if (ie + ie_len != pos)
882
goto err;
883
goto exit;
884
}
885
info->pmkid_cnt = cnt;
886
info->pmkid_list = (u8 *)pos;
887
pos += 16 * cnt;
888
889
/* Group Mgmt CS */
890
if (ie + ie_len < pos + 4) {
891
if (ie + ie_len != pos)
892
goto err;
893
goto exit;
894
}
895
info->gmcs = (u8 *)pos;
896
897
exit:
898
return _SUCCESS;
899
900
err:
901
info->err = 1;
902
return _FAIL;
903
}
904
905
int rtw_parse_wpa2_ie(u8 *rsn_ie, int rsn_ie_len, int *group_cipher,
906
int *pairwise_cipher, u32 *akm, u8 *mfp_opt)
907
{
908
struct rsne_info info;
909
int i, ret = _SUCCESS;
910
911
ret = rtw_rsne_info_parse(rsn_ie, rsn_ie_len, &info);
912
if (ret != _SUCCESS)
913
goto exit;
914
915
if (group_cipher) {
916
if (info.gcs)
917
*group_cipher = rtw_get_wpa2_cipher_suite(info.gcs);
918
else
919
*group_cipher = 0;
920
}
921
922
if (pairwise_cipher) {
923
*pairwise_cipher = 0;
924
for (i = 0; i < info.pcs_cnt; i++)
925
*pairwise_cipher |= rtw_get_wpa2_cipher_suite(info.pcs_list + 4 * i);
926
}
927
928
if (akm) {
929
*akm = 0;
930
for (i = 0; i < info.akm_cnt; i++)
931
*akm |= rtw_get_akm_suite_bitmap(info.akm_list + 4 * i);
932
}
933
934
if (mfp_opt) {
935
*mfp_opt = MFP_NO;
936
if (info.cap)
937
*mfp_opt = GET_RSN_CAP_MFP_OPTION(info.cap);
938
}
939
940
exit:
941
return ret;
942
}
943
944
/* #ifdef CONFIG_WAPI_SUPPORT */
945
int rtw_get_wapi_ie(u8 *in_ie, uint in_len, u8 *wapi_ie, u16 *wapi_len)
946
{
947
int len = 0;
948
u8 authmode;
949
uint cnt;
950
u8 wapi_oui1[4] = {0x0, 0x14, 0x72, 0x01};
951
u8 wapi_oui2[4] = {0x0, 0x14, 0x72, 0x02};
952
953
954
if (wapi_len)
955
*wapi_len = 0;
956
957
if (!in_ie || in_len <= 0)
958
return len;
959
960
cnt = (_TIMESTAMP_ + _BEACON_ITERVAL_ + _CAPABILITY_);
961
962
while (cnt < in_len) {
963
authmode = in_ie[cnt];
964
965
/* if(authmode==_WAPI_IE_) */
966
if (authmode == _WAPI_IE_ && (_rtw_memcmp(&in_ie[cnt + 6], wapi_oui1, 4) == _TRUE ||
967
_rtw_memcmp(&in_ie[cnt + 6], wapi_oui2, 4) == _TRUE)) {
968
if (wapi_ie)
969
_rtw_memcpy(wapi_ie, &in_ie[cnt], in_ie[cnt + 1] + 2);
970
971
if (wapi_len)
972
*wapi_len = in_ie[cnt + 1] + 2;
973
974
cnt += in_ie[cnt + 1] + 2; /* get next */
975
} else {
976
cnt += in_ie[cnt + 1] + 2; /* get next */
977
}
978
}
979
980
if (wapi_len)
981
len = *wapi_len;
982
983
984
return len;
985
986
}
987
/* #endif */
988
989
int rtw_get_sec_ie(u8 *in_ie, uint in_len, u8 *rsn_ie, u16 *rsn_len, u8 *wpa_ie, u16 *wpa_len)
990
{
991
u8 authmode, sec_idx;
992
u8 wpa_oui[4] = {0x0, 0x50, 0xf2, 0x01};
993
uint cnt;
994
995
996
/* Search required WPA or WPA2 IE and copy to sec_ie[ ] */
997
998
cnt = (_TIMESTAMP_ + _BEACON_ITERVAL_ + _CAPABILITY_);
999
1000
sec_idx = 0;
1001
1002
while (cnt < in_len) {
1003
authmode = in_ie[cnt];
1004
1005
if ((authmode == _WPA_IE_ID_) && (_rtw_memcmp(&in_ie[cnt + 2], &wpa_oui[0], 4) == _TRUE)) {
1006
1007
if (wpa_ie)
1008
_rtw_memcpy(wpa_ie, &in_ie[cnt], in_ie[cnt + 1] + 2);
1009
1010
*wpa_len = in_ie[cnt + 1] + 2;
1011
cnt += in_ie[cnt + 1] + 2; /* get next */
1012
} else {
1013
if (authmode == _WPA2_IE_ID_) {
1014
1015
if (rsn_ie)
1016
_rtw_memcpy(rsn_ie, &in_ie[cnt], in_ie[cnt + 1] + 2);
1017
1018
*rsn_len = in_ie[cnt + 1] + 2;
1019
cnt += in_ie[cnt + 1] + 2; /* get next */
1020
} else {
1021
cnt += in_ie[cnt + 1] + 2; /* get next */
1022
}
1023
}
1024
1025
}
1026
1027
1028
return *rsn_len + *wpa_len;
1029
1030
}
1031
1032
u8 rtw_is_wps_ie(u8 *ie_ptr, uint *wps_ielen)
1033
{
1034
u8 match = _FALSE;
1035
u8 eid, wps_oui[4] = {0x0, 0x50, 0xf2, 0x04};
1036
1037
if (ie_ptr == NULL)
1038
return match;
1039
1040
eid = ie_ptr[0];
1041
1042
if ((eid == _WPA_IE_ID_) && (_rtw_memcmp(&ie_ptr[2], wps_oui, 4) == _TRUE)) {
1043
/* RTW_INFO("==> found WPS_IE.....\n"); */
1044
*wps_ielen = ie_ptr[1] + 2;
1045
match = _TRUE;
1046
}
1047
return match;
1048
}
1049
1050
u8 *rtw_get_wps_ie_from_scan_queue(u8 *in_ie, uint in_len, u8 *wps_ie, uint *wps_ielen, enum bss_type frame_type)
1051
{
1052
u8 *wps = NULL;
1053
1054
RTW_INFO("[%s] frame_type = %d\n", __FUNCTION__, frame_type);
1055
switch (frame_type) {
1056
case BSS_TYPE_BCN:
1057
case BSS_TYPE_PROB_RSP: {
1058
/* Beacon or Probe Response */
1059
wps = rtw_get_wps_ie(in_ie + _PROBERSP_IE_OFFSET_, in_len - _PROBERSP_IE_OFFSET_, wps_ie, wps_ielen);
1060
break;
1061
}
1062
case BSS_TYPE_PROB_REQ: {
1063
/* Probe Request */
1064
wps = rtw_get_wps_ie(in_ie + _PROBEREQ_IE_OFFSET_ , in_len - _PROBEREQ_IE_OFFSET_ , wps_ie, wps_ielen);
1065
break;
1066
}
1067
default:
1068
case BSS_TYPE_UNDEF:
1069
break;
1070
}
1071
return wps;
1072
}
1073
1074
/**
1075
* rtw_get_wps_ie - Search WPS IE from a series of IEs
1076
* @in_ie: Address of IEs to search
1077
* @in_len: Length limit from in_ie
1078
* @wps_ie: If not NULL and WPS IE is found, WPS IE will be copied to the buf starting from wps_ie
1079
* @wps_ielen: If not NULL and WPS IE is found, will set to the length of the entire WPS IE
1080
*
1081
* Returns: The address of the WPS IE found, or NULL
1082
*/
1083
u8 *rtw_get_wps_ie(const u8 *in_ie, uint in_len, u8 *wps_ie, uint *wps_ielen)
1084
{
1085
uint cnt;
1086
const u8 *wpsie_ptr = NULL;
1087
u8 eid, wps_oui[4] = {0x00, 0x50, 0xf2, 0x04};
1088
1089
if (wps_ielen)
1090
*wps_ielen = 0;
1091
1092
if (!in_ie) {
1093
rtw_warn_on(1);
1094
return (u8 *)wpsie_ptr;
1095
}
1096
1097
if (in_len <= 0)
1098
return (u8 *)wpsie_ptr;
1099
1100
cnt = 0;
1101
1102
while (cnt + 1 + 4 < in_len) {
1103
eid = in_ie[cnt];
1104
1105
if (cnt + 1 + 4 >= MAX_IE_SZ) {
1106
rtw_warn_on(1);
1107
return NULL;
1108
}
1109
1110
if (eid == WLAN_EID_VENDOR_SPECIFIC && _rtw_memcmp(&in_ie[cnt + 2], wps_oui, 4) == _TRUE) {
1111
wpsie_ptr = in_ie + cnt;
1112
1113
if (wps_ie)
1114
_rtw_memcpy(wps_ie, &in_ie[cnt], in_ie[cnt + 1] + 2);
1115
1116
if (wps_ielen)
1117
*wps_ielen = in_ie[cnt + 1] + 2;
1118
1119
break;
1120
} else
1121
cnt += in_ie[cnt + 1] + 2;
1122
1123
}
1124
1125
return (u8 *)wpsie_ptr;
1126
}
1127
1128
/**
1129
* rtw_get_wps_attr - Search a specific WPS attribute from a given WPS IE
1130
* @wps_ie: Address of WPS IE to search
1131
* @wps_ielen: Length limit from wps_ie
1132
* @target_attr_id: The attribute ID of WPS attribute to search
1133
* @buf_attr: If not NULL and the WPS attribute is found, WPS attribute will be copied to the buf starting from buf_attr
1134
* @len_attr: If not NULL and the WPS attribute is found, will set to the length of the entire WPS attribute
1135
*
1136
* Returns: the address of the specific WPS attribute found, or NULL
1137
*/
1138
u8 *rtw_get_wps_attr(u8 *wps_ie, uint wps_ielen, u16 target_attr_id , u8 *buf_attr, u32 *len_attr)
1139
{
1140
u8 *attr_ptr = NULL;
1141
u8 *target_attr_ptr = NULL;
1142
u8 wps_oui[4] = {0x00, 0x50, 0xF2, 0x04};
1143
1144
if (len_attr)
1145
*len_attr = 0;
1146
1147
if ((wps_ie[0] != _VENDOR_SPECIFIC_IE_) ||
1148
(_rtw_memcmp(wps_ie + 2, wps_oui , 4) != _TRUE))
1149
return attr_ptr;
1150
1151
/* 6 = 1(Element ID) + 1(Length) + 4(WPS OUI) */
1152
attr_ptr = wps_ie + 6; /* goto first attr */
1153
1154
while (attr_ptr - wps_ie < wps_ielen) {
1155
/* 4 = 2(Attribute ID) + 2(Length) */
1156
u16 attr_id = RTW_GET_BE16(attr_ptr);
1157
u16 attr_data_len = RTW_GET_BE16(attr_ptr + 2);
1158
u16 attr_len = attr_data_len + 4;
1159
1160
/* RTW_INFO("%s attr_ptr:%p, id:%u, length:%u\n", __FUNCTION__, attr_ptr, attr_id, attr_data_len); */
1161
if (attr_id == target_attr_id) {
1162
target_attr_ptr = attr_ptr;
1163
1164
if (buf_attr)
1165
_rtw_memcpy(buf_attr, attr_ptr, attr_len);
1166
1167
if (len_attr)
1168
*len_attr = attr_len;
1169
1170
break;
1171
} else {
1172
attr_ptr += attr_len; /* goto next */
1173
}
1174
1175
}
1176
1177
return target_attr_ptr;
1178
}
1179
1180
/**
1181
* rtw_get_wps_attr_content - Search a specific WPS attribute content from a given WPS IE
1182
* @wps_ie: Address of WPS IE to search
1183
* @wps_ielen: Length limit from wps_ie
1184
* @target_attr_id: The attribute ID of WPS attribute to search
1185
* @buf_content: If not NULL and the WPS attribute is found, WPS attribute content will be copied to the buf starting from buf_content
1186
* @len_content: If not NULL and the WPS attribute is found, will set to the length of the WPS attribute content
1187
*
1188
* Returns: the address of the specific WPS attribute content found, or NULL
1189
*/
1190
u8 *rtw_get_wps_attr_content(u8 *wps_ie, uint wps_ielen, u16 target_attr_id , u8 *buf_content, uint *len_content)
1191
{
1192
u8 *attr_ptr;
1193
u32 attr_len;
1194
1195
if (len_content)
1196
*len_content = 0;
1197
1198
attr_ptr = rtw_get_wps_attr(wps_ie, wps_ielen, target_attr_id, NULL, &attr_len);
1199
1200
if (attr_ptr && attr_len) {
1201
if (buf_content)
1202
_rtw_memcpy(buf_content, attr_ptr + 4, attr_len - 4);
1203
1204
if (len_content)
1205
*len_content = attr_len - 4;
1206
1207
return attr_ptr + 4;
1208
}
1209
1210
return NULL;
1211
}
1212
1213
static int rtw_ieee802_11_parse_vendor_specific(u8 *pos, uint elen,
1214
struct rtw_ieee802_11_elems *elems,
1215
int show_errors)
1216
{
1217
unsigned int oui;
1218
1219
/* first 3 bytes in vendor specific information element are the IEEE
1220
* OUI of the vendor. The following byte is used a vendor specific
1221
* sub-type. */
1222
if (elen < 4) {
1223
if (show_errors) {
1224
RTW_INFO("short vendor specific "
1225
"information element ignored (len=%lu)\n",
1226
(unsigned long) elen);
1227
}
1228
return -1;
1229
}
1230
1231
oui = RTW_GET_BE24(pos);
1232
switch (oui) {
1233
case OUI_MICROSOFT:
1234
/* Microsoft/Wi-Fi information elements are further typed and
1235
* subtyped */
1236
switch (pos[3]) {
1237
case 1:
1238
/* Microsoft OUI (00:50:F2) with OUI Type 1:
1239
* real WPA information element */
1240
elems->wpa_ie = pos;
1241
elems->wpa_ie_len = elen;
1242
break;
1243
case WME_OUI_TYPE: /* this is a Wi-Fi WME info. element */
1244
if (elen < 5) {
1245
RTW_DBG("short WME "
1246
"information element ignored "
1247
"(len=%lu)\n",
1248
(unsigned long) elen);
1249
return -1;
1250
}
1251
switch (pos[4]) {
1252
case WME_OUI_SUBTYPE_INFORMATION_ELEMENT:
1253
case WME_OUI_SUBTYPE_PARAMETER_ELEMENT:
1254
elems->wme = pos;
1255
elems->wme_len = elen;
1256
break;
1257
case WME_OUI_SUBTYPE_TSPEC_ELEMENT:
1258
elems->wme_tspec = pos;
1259
elems->wme_tspec_len = elen;
1260
break;
1261
default:
1262
RTW_DBG("unknown WME "
1263
"information element ignored "
1264
"(subtype=%d len=%lu)\n",
1265
pos[4], (unsigned long) elen);
1266
return -1;
1267
}
1268
break;
1269
case 4:
1270
/* Wi-Fi Protected Setup (WPS) IE */
1271
elems->wps_ie = pos;
1272
elems->wps_ie_len = elen;
1273
break;
1274
default:
1275
RTW_DBG("Unknown Microsoft "
1276
"information element ignored "
1277
"(type=%d len=%lu)\n",
1278
pos[3], (unsigned long) elen);
1279
return -1;
1280
}
1281
break;
1282
1283
case OUI_BROADCOM:
1284
switch (pos[3]) {
1285
case VENDOR_HT_CAPAB_OUI_TYPE:
1286
elems->vendor_ht_cap = pos;
1287
elems->vendor_ht_cap_len = elen;
1288
break;
1289
default:
1290
RTW_DBG("Unknown Broadcom "
1291
"information element ignored "
1292
"(type=%d len=%lu)\n",
1293
pos[3], (unsigned long) elen);
1294
return -1;
1295
}
1296
break;
1297
1298
default:
1299
RTW_DBG("unknown vendor specific information "
1300
"element ignored (vendor OUI %02x:%02x:%02x "
1301
"len=%lu)\n",
1302
pos[0], pos[1], pos[2], (unsigned long) elen);
1303
return -1;
1304
}
1305
1306
return 0;
1307
1308
}
1309
1310
/**
1311
* ieee802_11_parse_elems - Parse information elements in management frames
1312
* @start: Pointer to the start of IEs
1313
* @len: Length of IE buffer in octets
1314
* @elems: Data structure for parsed elements
1315
* @show_errors: Whether to show parsing errors in debug log
1316
* Returns: Parsing result
1317
*/
1318
ParseRes rtw_ieee802_11_parse_elems(u8 *start, uint len,
1319
struct rtw_ieee802_11_elems *elems,
1320
int show_errors)
1321
{
1322
uint left = len;
1323
u8 *pos = start;
1324
int unknown = 0;
1325
1326
_rtw_memset(elems, 0, sizeof(*elems));
1327
1328
while (left >= 2) {
1329
u8 id, elen;
1330
1331
id = *pos++;
1332
elen = *pos++;
1333
left -= 2;
1334
1335
if (elen > left) {
1336
if (show_errors) {
1337
RTW_INFO("IEEE 802.11 element "
1338
"parse failed (id=%d elen=%d "
1339
"left=%lu)\n",
1340
id, elen, (unsigned long) left);
1341
}
1342
return ParseFailed;
1343
}
1344
1345
switch (id) {
1346
case WLAN_EID_SSID:
1347
elems->ssid = pos;
1348
elems->ssid_len = elen;
1349
break;
1350
case WLAN_EID_SUPP_RATES:
1351
elems->supp_rates = pos;
1352
elems->supp_rates_len = elen;
1353
break;
1354
case WLAN_EID_FH_PARAMS:
1355
elems->fh_params = pos;
1356
elems->fh_params_len = elen;
1357
break;
1358
case WLAN_EID_DS_PARAMS:
1359
elems->ds_params = pos;
1360
elems->ds_params_len = elen;
1361
break;
1362
case WLAN_EID_CF_PARAMS:
1363
elems->cf_params = pos;
1364
elems->cf_params_len = elen;
1365
break;
1366
case WLAN_EID_TIM:
1367
elems->tim = pos;
1368
elems->tim_len = elen;
1369
break;
1370
case WLAN_EID_IBSS_PARAMS:
1371
elems->ibss_params = pos;
1372
elems->ibss_params_len = elen;
1373
break;
1374
case WLAN_EID_CHALLENGE:
1375
elems->challenge = pos;
1376
elems->challenge_len = elen;
1377
break;
1378
case WLAN_EID_ERP_INFO:
1379
elems->erp_info = pos;
1380
elems->erp_info_len = elen;
1381
break;
1382
case WLAN_EID_EXT_SUPP_RATES:
1383
elems->ext_supp_rates = pos;
1384
elems->ext_supp_rates_len = elen;
1385
break;
1386
case WLAN_EID_VENDOR_SPECIFIC:
1387
if (rtw_ieee802_11_parse_vendor_specific(pos, elen,
1388
elems,
1389
show_errors))
1390
unknown++;
1391
break;
1392
case WLAN_EID_RSN:
1393
elems->rsn_ie = pos;
1394
elems->rsn_ie_len = elen;
1395
break;
1396
case WLAN_EID_PWR_CAPABILITY:
1397
elems->power_cap = pos;
1398
elems->power_cap_len = elen;
1399
break;
1400
case WLAN_EID_SUPPORTED_CHANNELS:
1401
elems->supp_channels = pos;
1402
elems->supp_channels_len = elen;
1403
break;
1404
case WLAN_EID_MOBILITY_DOMAIN:
1405
elems->mdie = pos;
1406
elems->mdie_len = elen;
1407
break;
1408
case WLAN_EID_FAST_BSS_TRANSITION:
1409
elems->ftie = pos;
1410
elems->ftie_len = elen;
1411
break;
1412
case WLAN_EID_TIMEOUT_INTERVAL:
1413
elems->timeout_int = pos;
1414
elems->timeout_int_len = elen;
1415
break;
1416
case WLAN_EID_HT_CAP:
1417
elems->ht_capabilities = pos;
1418
elems->ht_capabilities_len = elen;
1419
break;
1420
case WLAN_EID_HT_OPERATION:
1421
elems->ht_operation = pos;
1422
elems->ht_operation_len = elen;
1423
break;
1424
case WLAN_EID_VHT_CAPABILITY:
1425
elems->vht_capabilities = pos;
1426
elems->vht_capabilities_len = elen;
1427
break;
1428
case WLAN_EID_VHT_OPERATION:
1429
elems->vht_operation = pos;
1430
elems->vht_operation_len = elen;
1431
break;
1432
case WLAN_EID_VHT_OP_MODE_NOTIFY:
1433
elems->vht_op_mode_notify = pos;
1434
elems->vht_op_mode_notify_len = elen;
1435
break;
1436
case _EID_RRM_EN_CAP_IE_:
1437
elems->rm_en_cap = pos;
1438
elems->rm_en_cap_len = elen;
1439
break;
1440
#ifdef CONFIG_RTW_MESH
1441
case WLAN_EID_PREQ:
1442
elems->preq = pos;
1443
elems->preq_len = elen;
1444
break;
1445
case WLAN_EID_PREP:
1446
elems->prep = pos;
1447
elems->prep_len = elen;
1448
break;
1449
case WLAN_EID_PERR:
1450
elems->perr = pos;
1451
elems->perr_len = elen;
1452
break;
1453
case WLAN_EID_RANN:
1454
elems->rann = pos;
1455
elems->rann_len = elen;
1456
break;
1457
#endif
1458
default:
1459
unknown++;
1460
if (!show_errors)
1461
break;
1462
RTW_DBG("IEEE 802.11 element parse "
1463
"ignored unknown element (id=%d elen=%d)\n",
1464
id, elen);
1465
break;
1466
}
1467
1468
left -= elen;
1469
pos += elen;
1470
}
1471
1472
if (left)
1473
return ParseFailed;
1474
1475
return unknown ? ParseUnknown : ParseOK;
1476
1477
}
1478
1479
static u8 key_char2num(u8 ch);
1480
static u8 key_char2num(u8 ch)
1481
{
1482
if ((ch >= '0') && (ch <= '9'))
1483
return ch - '0';
1484
else if ((ch >= 'a') && (ch <= 'f'))
1485
return ch - 'a' + 10;
1486
else if ((ch >= 'A') && (ch <= 'F'))
1487
return ch - 'A' + 10;
1488
else
1489
return 0xff;
1490
}
1491
1492
u8 str_2char2num(u8 hch, u8 lch);
1493
u8 str_2char2num(u8 hch, u8 lch)
1494
{
1495
return (key_char2num(hch) * 10) + key_char2num(lch);
1496
}
1497
1498
u8 key_2char2num(u8 hch, u8 lch);
1499
u8 key_2char2num(u8 hch, u8 lch)
1500
{
1501
return (key_char2num(hch) << 4) | key_char2num(lch);
1502
}
1503
1504
void macstr2num(u8 *dst, u8 *src);
1505
void macstr2num(u8 *dst, u8 *src)
1506
{
1507
int jj, kk;
1508
for (jj = 0, kk = 0; jj < ETH_ALEN; jj++, kk += 3)
1509
dst[jj] = key_2char2num(src[kk], src[kk + 1]);
1510
}
1511
1512
u8 convert_ip_addr(u8 hch, u8 mch, u8 lch)
1513
{
1514
return (key_char2num(hch) * 100) + (key_char2num(mch) * 10) + key_char2num(lch);
1515
}
1516
1517
#ifdef CONFIG_PLATFORM_INTEL_BYT
1518
#define MAC_ADDRESS_LEN 12
1519
1520
int rtw_get_mac_addr_intel(unsigned char *buf)
1521
{
1522
int ret = 0;
1523
int i;
1524
struct file *fp = NULL;
1525
mm_segment_t oldfs;
1526
unsigned char c_mac[MAC_ADDRESS_LEN];
1527
char fname[] = "/config/wifi/mac.txt";
1528
int jj, kk;
1529
1530
RTW_INFO("%s Enter\n", __FUNCTION__);
1531
1532
ret = rtw_retrieve_from_file(fname, c_mac, MAC_ADDRESS_LEN);
1533
if (ret < MAC_ADDRESS_LEN)
1534
return -1;
1535
1536
for (jj = 0, kk = 0; jj < ETH_ALEN; jj++, kk += 2)
1537
buf[jj] = key_2char2num(c_mac[kk], c_mac[kk + 1]);
1538
1539
RTW_INFO("%s: read from file mac address: "MAC_FMT"\n",
1540
__FUNCTION__, MAC_ARG(buf));
1541
1542
return 0;
1543
}
1544
#endif /* CONFIG_PLATFORM_INTEL_BYT */
1545
1546
/*
1547
* Description:
1548
* rtw_check_invalid_mac_address:
1549
* This is only used for checking mac address valid or not.
1550
*
1551
* Input:
1552
* adapter: mac_address pointer.
1553
* check_local_bit: check locally bit or not.
1554
*
1555
* Output:
1556
* _TRUE: The mac address is invalid.
1557
* _FALSE: The mac address is valid.
1558
*
1559
* Auther: Isaac.Li
1560
*/
1561
u8 rtw_check_invalid_mac_address(u8 *mac_addr, u8 check_local_bit)
1562
{
1563
u8 null_mac_addr[ETH_ALEN] = {0, 0, 0, 0, 0, 0};
1564
u8 multi_mac_addr[ETH_ALEN] = {0xff, 0xff, 0xff, 0xff, 0xff, 0xff};
1565
u8 res = _FALSE;
1566
1567
if (_rtw_memcmp(mac_addr, null_mac_addr, ETH_ALEN)) {
1568
res = _TRUE;
1569
goto func_exit;
1570
}
1571
1572
if (_rtw_memcmp(mac_addr, multi_mac_addr, ETH_ALEN)) {
1573
res = _TRUE;
1574
goto func_exit;
1575
}
1576
1577
if (mac_addr[0] & BIT0) {
1578
res = _TRUE;
1579
goto func_exit;
1580
}
1581
1582
if (check_local_bit == _TRUE) {
1583
if (mac_addr[0] & BIT1) {
1584
res = _TRUE;
1585
goto func_exit;
1586
}
1587
}
1588
1589
func_exit:
1590
return res;
1591
}
1592
1593
extern char *rtw_initmac;
1594
/**
1595
* rtw_macaddr_cfg - Decide the mac address used
1596
* @out: buf to store mac address decided
1597
* @hw_mac_addr: mac address from efuse/epprom
1598
*/
1599
void rtw_macaddr_cfg(u8 *out, const u8 *hw_mac_addr)
1600
{
1601
#define DEFAULT_RANDOM_MACADDR 1
1602
u8 mac[ETH_ALEN];
1603
1604
if (out == NULL) {
1605
rtw_warn_on(1);
1606
return;
1607
}
1608
1609
/* Users specify the mac address */
1610
if (rtw_initmac) {
1611
int jj, kk;
1612
1613
for (jj = 0, kk = 0; jj < ETH_ALEN; jj++, kk += 3)
1614
mac[jj] = key_2char2num(rtw_initmac[kk], rtw_initmac[kk + 1]);
1615
1616
goto err_chk;
1617
}
1618
1619
/* platform specified */
1620
#ifdef CONFIG_PLATFORM_INTEL_BYT
1621
if (rtw_get_mac_addr_intel(mac) == 0)
1622
goto err_chk;
1623
#endif
1624
1625
/* Use the mac address stored in the Efuse */
1626
if (hw_mac_addr) {
1627
_rtw_memcpy(mac, hw_mac_addr, ETH_ALEN);
1628
goto err_chk;
1629
}
1630
1631
err_chk:
1632
if (rtw_check_invalid_mac_address(mac, _TRUE) == _TRUE) {
1633
#if DEFAULT_RANDOM_MACADDR
1634
RTW_ERR("invalid mac addr:"MAC_FMT", assign random MAC\n", MAC_ARG(mac));
1635
*((u32 *)(&mac[2])) = rtw_random32();
1636
mac[0] = 0x00;
1637
mac[1] = 0xe0;
1638
mac[2] = 0x4c;
1639
#else
1640
RTW_ERR("invalid mac addr:"MAC_FMT", assign default one\n", MAC_ARG(mac));
1641
mac[0] = 0x00;
1642
mac[1] = 0xe0;
1643
mac[2] = 0x4c;
1644
mac[3] = 0x87;
1645
mac[4] = 0x00;
1646
mac[5] = 0x00;
1647
#endif
1648
}
1649
1650
_rtw_memcpy(out, mac, ETH_ALEN);
1651
RTW_INFO("%s mac addr:"MAC_FMT"\n", __func__, MAC_ARG(out));
1652
}
1653
1654
#ifdef CONFIG_80211N_HT
1655
void dump_ht_cap_ie_content(void *sel, const u8 *buf, u32 buf_len)
1656
{
1657
if (buf_len != HT_CAP_IE_LEN) {
1658
RTW_PRINT_SEL(sel, "Invalid HT capability IE len:%d != %d\n", buf_len, HT_CAP_IE_LEN);
1659
return;
1660
}
1661
1662
RTW_PRINT_SEL(sel, "cap_info:%02x%02x:%s\n", *(buf), *(buf + 1)
1663
, GET_HT_CAP_ELE_CHL_WIDTH(buf) ? " 40MHz" : " 20MHz");
1664
RTW_PRINT_SEL(sel, "A-MPDU Parameters:"HT_AMPDU_PARA_FMT"\n"
1665
, HT_AMPDU_PARA_ARG(HT_CAP_ELE_AMPDU_PARA(buf)));
1666
RTW_PRINT_SEL(sel, "Supported MCS Set:"HT_SUP_MCS_SET_FMT"\n"
1667
, HT_SUP_MCS_SET_ARG(HT_CAP_ELE_SUP_MCS_SET(buf)));
1668
}
1669
1670
void dump_ht_cap_ie(void *sel, const u8 *ie, u32 ie_len)
1671
{
1672
const u8 *ht_cap_ie;
1673
sint ht_cap_ielen;
1674
1675
ht_cap_ie = rtw_get_ie(ie, WLAN_EID_HT_CAP, &ht_cap_ielen, ie_len);
1676
if (!ie || ht_cap_ie != ie)
1677
return;
1678
1679
dump_ht_cap_ie_content(sel, ht_cap_ie + 2, ht_cap_ielen);
1680
}
1681
1682
const char *const _ht_sc_offset_str[] = {
1683
"SCN",
1684
"SCA",
1685
"SC-RSVD",
1686
"SCB",
1687
};
1688
1689
void dump_ht_op_ie_content(void *sel, const u8 *buf, u32 buf_len)
1690
{
1691
if (buf_len != HT_OP_IE_LEN) {
1692
RTW_PRINT_SEL(sel, "Invalid HT operation IE len:%d != %d\n", buf_len, HT_OP_IE_LEN);
1693
return;
1694
}
1695
1696
RTW_PRINT_SEL(sel, "ch:%u%s %s\n"
1697
, GET_HT_OP_ELE_PRI_CHL(buf)
1698
, GET_HT_OP_ELE_STA_CHL_WIDTH(buf) ? "" : " 20MHz only"
1699
, ht_sc_offset_str(GET_HT_OP_ELE_2ND_CHL_OFFSET(buf))
1700
);
1701
}
1702
1703
void dump_ht_op_ie(void *sel, const u8 *ie, u32 ie_len)
1704
{
1705
const u8 *ht_op_ie;
1706
sint ht_op_ielen;
1707
1708
ht_op_ie = rtw_get_ie(ie, WLAN_EID_HT_OPERATION, &ht_op_ielen, ie_len);
1709
if (!ie || ht_op_ie != ie)
1710
return;
1711
1712
dump_ht_op_ie_content(sel, ht_op_ie + 2, ht_op_ielen);
1713
}
1714
#endif /* CONFIG_80211N_HT */
1715
1716
void dump_ies(void *sel, const u8 *buf, u32 buf_len)
1717
{
1718
const u8 *pos = buf;
1719
u8 id, len;
1720
1721
while (pos - buf + 1 < buf_len) {
1722
id = *pos;
1723
len = *(pos + 1);
1724
1725
RTW_PRINT_SEL(sel, "%s ID:%u, LEN:%u\n", __FUNCTION__, id, len);
1726
#ifdef CONFIG_80211N_HT
1727
dump_ht_cap_ie(sel, pos, len + 2);
1728
dump_ht_op_ie(sel, pos, len + 2);
1729
#endif
1730
#ifdef CONFIG_80211AC_VHT
1731
dump_vht_cap_ie(sel, pos, len + 2);
1732
dump_vht_op_ie(sel, pos, len + 2);
1733
#endif
1734
dump_wps_ie(sel, pos, len + 2);
1735
#ifdef CONFIG_P2P
1736
dump_p2p_ie(sel, pos, len + 2);
1737
#ifdef CONFIG_WFD
1738
dump_wfd_ie(sel, pos, len + 2);
1739
#endif
1740
#endif
1741
1742
pos += (2 + len);
1743
}
1744
}
1745
1746
void dump_wps_ie(void *sel, const u8 *ie, u32 ie_len)
1747
{
1748
const u8 *pos = ie;
1749
u16 id;
1750
u16 len;
1751
1752
const u8 *wps_ie;
1753
uint wps_ielen;
1754
1755
wps_ie = rtw_get_wps_ie(ie, ie_len, NULL, &wps_ielen);
1756
if (wps_ie != ie || wps_ielen == 0)
1757
return;
1758
1759
pos += 6;
1760
while (pos - ie + 4 <= ie_len) {
1761
id = RTW_GET_BE16(pos);
1762
len = RTW_GET_BE16(pos + 2);
1763
1764
RTW_PRINT_SEL(sel, "%s ID:0x%04x, LEN:%u%s\n", __func__, id, len
1765
, ((pos - ie + 4 + len) <= ie_len) ? "" : "(exceed ie_len)");
1766
1767
pos += (4 + len);
1768
}
1769
}
1770
1771
/**
1772
* rtw_ies_get_chbw - get operation ch, bw, offset from IEs of BSS.
1773
* @ies: pointer of the first tlv IE
1774
* @ies_len: length of @ies
1775
* @ch: pointer of ch, used as output
1776
* @bw: pointer of bw, used as output
1777
* @offset: pointer of offset, used as output
1778
* @ht: check HT IEs
1779
* @vht: check VHT IEs, if true imply ht is true
1780
*/
1781
void rtw_ies_get_chbw(u8 *ies, int ies_len, u8 *ch, u8 *bw, u8 *offset, u8 ht, u8 vht)
1782
{
1783
u8 *p;
1784
int ie_len;
1785
1786
*ch = 0;
1787
*bw = CHANNEL_WIDTH_20;
1788
*offset = HAL_PRIME_CHNL_OFFSET_DONT_CARE;
1789
1790
p = rtw_get_ie(ies, _DSSET_IE_, &ie_len, ies_len);
1791
if (p && ie_len > 0)
1792
*ch = *(p + 2);
1793
1794
#ifdef CONFIG_80211N_HT
1795
if (ht || vht) {
1796
u8 *ht_cap_ie, *ht_op_ie;
1797
int ht_cap_ielen, ht_op_ielen;
1798
1799
ht_cap_ie = rtw_get_ie(ies, EID_HTCapability, &ht_cap_ielen, ies_len);
1800
if (ht_cap_ie && ht_cap_ielen) {
1801
if (GET_HT_CAP_ELE_CHL_WIDTH(ht_cap_ie + 2))
1802
*bw = CHANNEL_WIDTH_40;
1803
}
1804
1805
ht_op_ie = rtw_get_ie(ies, EID_HTInfo, &ht_op_ielen, ies_len);
1806
if (ht_op_ie && ht_op_ielen) {
1807
if (*ch == 0)
1808
*ch = GET_HT_OP_ELE_PRI_CHL(ht_op_ie + 2);
1809
else if (*ch != 0 && *ch != GET_HT_OP_ELE_PRI_CHL(ht_op_ie + 2)) {
1810
RTW_INFO("%s ch inconsistent, DSSS:%u, HT primary:%u\n"
1811
, __func__, *ch, GET_HT_OP_ELE_PRI_CHL(ht_op_ie + 2));
1812
}
1813
1814
if (!GET_HT_OP_ELE_STA_CHL_WIDTH(ht_op_ie + 2))
1815
*bw = CHANNEL_WIDTH_20;
1816
1817
if (*bw == CHANNEL_WIDTH_40) {
1818
switch (GET_HT_OP_ELE_2ND_CHL_OFFSET(ht_op_ie + 2)) {
1819
case SCA:
1820
*offset = HAL_PRIME_CHNL_OFFSET_LOWER;
1821
break;
1822
case SCB:
1823
*offset = HAL_PRIME_CHNL_OFFSET_UPPER;
1824
break;
1825
}
1826
}
1827
}
1828
1829
#ifdef CONFIG_80211AC_VHT
1830
if (vht) {
1831
u8 *vht_op_ie;
1832
int vht_op_ielen;
1833
1834
vht_op_ie = rtw_get_ie(ies, EID_VHTOperation, &vht_op_ielen, ies_len);
1835
if (vht_op_ie && vht_op_ielen) {
1836
if (GET_VHT_OPERATION_ELE_CHL_WIDTH(vht_op_ie + 2) >= 1)
1837
*bw = CHANNEL_WIDTH_80;
1838
}
1839
}
1840
#endif /* CONFIG_80211AC_VHT */
1841
1842
}
1843
#endif /* CONFIG_80211N_HT */
1844
}
1845
1846
void rtw_bss_get_chbw(WLAN_BSSID_EX *bss, u8 *ch, u8 *bw, u8 *offset, u8 ht, u8 vht)
1847
{
1848
rtw_ies_get_chbw(bss->IEs + sizeof(NDIS_802_11_FIXED_IEs)
1849
, bss->IELength - sizeof(NDIS_802_11_FIXED_IEs)
1850
, ch, bw, offset, ht, vht);
1851
1852
if (*ch == 0)
1853
*ch = bss->Configuration.DSConfig;
1854
else if (*ch != bss->Configuration.DSConfig) {
1855
RTW_INFO("inconsistent ch - ies:%u bss->Configuration.DSConfig:%u\n"
1856
, *ch, bss->Configuration.DSConfig);
1857
*ch = bss->Configuration.DSConfig;
1858
rtw_warn_on(1);
1859
}
1860
}
1861
1862
/**
1863
* rtw_is_chbw_grouped - test if the two ch settings can be grouped together
1864
* @ch_a: ch of set a
1865
* @bw_a: bw of set a
1866
* @offset_a: offset of set a
1867
* @ch_b: ch of set b
1868
* @bw_b: bw of set b
1869
* @offset_b: offset of set b
1870
*/
1871
bool rtw_is_chbw_grouped(u8 ch_a, u8 bw_a, u8 offset_a
1872
, u8 ch_b, u8 bw_b, u8 offset_b)
1873
{
1874
bool is_grouped = _FALSE;
1875
1876
if (ch_a != ch_b) {
1877
/* ch is different */
1878
goto exit;
1879
} else if ((bw_a == CHANNEL_WIDTH_40 || bw_a == CHANNEL_WIDTH_80)
1880
&& (bw_b == CHANNEL_WIDTH_40 || bw_b == CHANNEL_WIDTH_80)
1881
) {
1882
if (offset_a != offset_b)
1883
goto exit;
1884
}
1885
1886
is_grouped = _TRUE;
1887
1888
exit:
1889
return is_grouped;
1890
}
1891
1892
/**
1893
* rtw_sync_chbw - obey g_ch, adjust g_bw, g_offset, bw, offset
1894
* @req_ch: pointer of the request ch, may be modified further
1895
* @req_bw: pointer of the request bw, may be modified further
1896
* @req_offset: pointer of the request offset, may be modified further
1897
* @g_ch: pointer of the ongoing group ch
1898
* @g_bw: pointer of the ongoing group bw, may be modified further
1899
* @g_offset: pointer of the ongoing group offset, may be modified further
1900
*/
1901
void rtw_sync_chbw(u8 *req_ch, u8 *req_bw, u8 *req_offset
1902
, u8 *g_ch, u8 *g_bw, u8 *g_offset)
1903
{
1904
1905
*req_ch = *g_ch;
1906
1907
if (*req_bw == CHANNEL_WIDTH_80 && *g_ch <= 14) {
1908
/*2.4G ch, downgrade to 40Mhz */
1909
*req_bw = CHANNEL_WIDTH_40;
1910
}
1911
1912
switch (*req_bw) {
1913
case CHANNEL_WIDTH_80:
1914
if (*g_bw == CHANNEL_WIDTH_40 || *g_bw == CHANNEL_WIDTH_80)
1915
*req_offset = *g_offset;
1916
else if (*g_bw == CHANNEL_WIDTH_20)
1917
rtw_get_offset_by_chbw(*req_ch, *req_bw, req_offset);
1918
1919
if (*req_offset == HAL_PRIME_CHNL_OFFSET_DONT_CARE) {
1920
RTW_ERR("%s req 80MHz BW without offset, down to 20MHz\n", __func__);
1921
rtw_warn_on(1);
1922
*req_bw = CHANNEL_WIDTH_20;
1923
}
1924
break;
1925
case CHANNEL_WIDTH_40:
1926
if (*g_bw == CHANNEL_WIDTH_40 || *g_bw == CHANNEL_WIDTH_80)
1927
*req_offset = *g_offset;
1928
else if (*g_bw == CHANNEL_WIDTH_20)
1929
rtw_get_offset_by_chbw(*req_ch, *req_bw, req_offset);
1930
1931
if (*req_offset == HAL_PRIME_CHNL_OFFSET_DONT_CARE) {
1932
RTW_ERR("%s req 40MHz BW without offset, down to 20MHz\n", __func__);
1933
rtw_warn_on(1);
1934
*req_bw = CHANNEL_WIDTH_20;
1935
}
1936
break;
1937
case CHANNEL_WIDTH_20:
1938
*req_offset = HAL_PRIME_CHNL_OFFSET_DONT_CARE;
1939
break;
1940
default:
1941
RTW_ERR("%s req unsupported BW:%u\n", __func__, *req_bw);
1942
rtw_warn_on(1);
1943
}
1944
1945
if (*req_bw > *g_bw) {
1946
*g_bw = *req_bw;
1947
*g_offset = *req_offset;
1948
}
1949
}
1950
1951
/**
1952
* rtw_get_p2p_merged_len - Get merged ie length from muitiple p2p ies.
1953
* @in_ie: Pointer of the first p2p ie
1954
* @in_len: Total len of muiltiple p2p ies
1955
* Returns: Length of merged p2p ie length
1956
*/
1957
u32 rtw_get_p2p_merged_ies_len(u8 *in_ie, u32 in_len)
1958
{
1959
PNDIS_802_11_VARIABLE_IEs pIE;
1960
u8 OUI[4] = { 0x50, 0x6f, 0x9a, 0x09 };
1961
int i = 0;
1962
int len = 0;
1963
1964
while (i < in_len) {
1965
pIE = (PNDIS_802_11_VARIABLE_IEs)(in_ie + i);
1966
1967
if (pIE->ElementID == _VENDOR_SPECIFIC_IE_ && _rtw_memcmp(pIE->data, OUI, 4)) {
1968
len += pIE->Length - 4; /* 4 is P2P OUI length, don't count it in this loop */
1969
}
1970
1971
i += (pIE->Length + 2);
1972
}
1973
1974
return len + 4; /* Append P2P OUI length at last. */
1975
}
1976
1977
/**
1978
* rtw_p2p_merge_ies - Merge muitiple p2p ies into one
1979
* @in_ie: Pointer of the first p2p ie
1980
* @in_len: Total len of muiltiple p2p ies
1981
* @merge_ie: Pointer of merged ie
1982
* Returns: Length of merged p2p ie
1983
*/
1984
int rtw_p2p_merge_ies(u8 *in_ie, u32 in_len, u8 *merge_ie)
1985
{
1986
PNDIS_802_11_VARIABLE_IEs pIE;
1987
u8 len = 0;
1988
u8 OUI[4] = { 0x50, 0x6f, 0x9a, 0x09 };
1989
u8 ELOUI[6] = { 0xDD, 0x00, 0x50, 0x6f, 0x9a, 0x09 }; /* EID;Len;OUI, Len would copy at the end of function */
1990
int i = 0;
1991
1992
if (merge_ie != NULL) {
1993
/* Set first P2P OUI */
1994
_rtw_memcpy(merge_ie, ELOUI, 6);
1995
merge_ie += 6;
1996
1997
while (i < in_len) {
1998
pIE = (PNDIS_802_11_VARIABLE_IEs)(in_ie + i);
1999
2000
/* Take out the rest of P2P OUIs */
2001
if (pIE->ElementID == _VENDOR_SPECIFIC_IE_ && _rtw_memcmp(pIE->data, OUI, 4)) {
2002
_rtw_memcpy(merge_ie, pIE->data + 4, pIE->Length - 4);
2003
len += pIE->Length - 4;
2004
merge_ie += pIE->Length - 4;
2005
}
2006
2007
i += (pIE->Length + 2);
2008
}
2009
2010
return len + 4; /* 4 is for P2P OUI */
2011
2012
}
2013
2014
return 0;
2015
}
2016
2017
void dump_p2p_ie(void *sel, const u8 *ie, u32 ie_len)
2018
{
2019
const u8 *pos = ie;
2020
u8 id;
2021
u16 len;
2022
2023
const u8 *p2p_ie;
2024
uint p2p_ielen;
2025
2026
p2p_ie = rtw_get_p2p_ie(ie, ie_len, NULL, &p2p_ielen);
2027
if (p2p_ie != ie || p2p_ielen == 0)
2028
return;
2029
2030
pos += 6;
2031
while (pos - ie + 3 <= ie_len) {
2032
id = *pos;
2033
len = RTW_GET_LE16(pos + 1);
2034
2035
RTW_PRINT_SEL(sel, "%s ID:%u, LEN:%u%s\n", __func__, id, len
2036
, ((pos - ie + 3 + len) <= ie_len) ? "" : "(exceed ie_len)");
2037
2038
pos += (3 + len);
2039
}
2040
}
2041
2042
/**
2043
* rtw_get_p2p_ie - Search P2P IE from a series of IEs
2044
* @in_ie: Address of IEs to search
2045
* @in_len: Length limit from in_ie
2046
* @p2p_ie: If not NULL and P2P IE is found, P2P IE will be copied to the buf starting from p2p_ie
2047
* @p2p_ielen: If not NULL and P2P IE is found, will set to the length of the entire P2P IE
2048
*
2049
* Returns: The address of the P2P IE found, or NULL
2050
*/
2051
u8 *rtw_get_p2p_ie(const u8 *in_ie, int in_len, u8 *p2p_ie, uint *p2p_ielen)
2052
{
2053
uint cnt;
2054
const u8 *p2p_ie_ptr = NULL;
2055
u8 eid, p2p_oui[4] = {0x50, 0x6F, 0x9A, 0x09};
2056
2057
if (p2p_ielen)
2058
*p2p_ielen = 0;
2059
2060
if (!in_ie || in_len < 0) {
2061
rtw_warn_on(1);
2062
return (u8 *)p2p_ie_ptr;
2063
}
2064
2065
if (in_len <= 0)
2066
return (u8 *)p2p_ie_ptr;
2067
2068
cnt = 0;
2069
2070
while (cnt + 1 + 4 < in_len) {
2071
eid = in_ie[cnt];
2072
2073
if (cnt + 1 + 4 >= MAX_IE_SZ) {
2074
rtw_warn_on(1);
2075
return NULL;
2076
}
2077
2078
if (eid == WLAN_EID_VENDOR_SPECIFIC && _rtw_memcmp(&in_ie[cnt + 2], p2p_oui, 4) == _TRUE) {
2079
p2p_ie_ptr = in_ie + cnt;
2080
2081
if (p2p_ie)
2082
_rtw_memcpy(p2p_ie, &in_ie[cnt], in_ie[cnt + 1] + 2);
2083
2084
if (p2p_ielen)
2085
*p2p_ielen = in_ie[cnt + 1] + 2;
2086
2087
break;
2088
} else
2089
cnt += in_ie[cnt + 1] + 2;
2090
2091
}
2092
2093
return (u8 *)p2p_ie_ptr;
2094
}
2095
2096
/**
2097
* rtw_get_p2p_attr - Search a specific P2P attribute from a given P2P IE
2098
* @p2p_ie: Address of P2P IE to search
2099
* @p2p_ielen: Length limit from p2p_ie
2100
* @target_attr_id: The attribute ID of P2P attribute to search
2101
* @buf_attr: If not NULL and the P2P attribute is found, P2P attribute will be copied to the buf starting from buf_attr
2102
* @len_attr: If not NULL and the P2P attribute is found, will set to the length of the entire P2P attribute
2103
*
2104
* Returns: the address of the specific WPS attribute found, or NULL
2105
*/
2106
u8 *rtw_get_p2p_attr(u8 *p2p_ie, uint p2p_ielen, u8 target_attr_id , u8 *buf_attr, u32 *len_attr)
2107
{
2108
u8 *attr_ptr = NULL;
2109
u8 *target_attr_ptr = NULL;
2110
u8 p2p_oui[4] = {0x50, 0x6F, 0x9A, 0x09};
2111
2112
if (len_attr)
2113
*len_attr = 0;
2114
2115
if (!p2p_ie
2116
|| p2p_ielen <= 6
2117
|| (p2p_ie[0] != WLAN_EID_VENDOR_SPECIFIC)
2118
|| (_rtw_memcmp(p2p_ie + 2, p2p_oui, 4) != _TRUE))
2119
return attr_ptr;
2120
2121
/* 6 = 1(Element ID) + 1(Length) + 3 (OUI) + 1(OUI Type) */
2122
attr_ptr = p2p_ie + 6; /* goto first attr */
2123
2124
while ((attr_ptr - p2p_ie + 3) <= p2p_ielen) {
2125
/* 3 = 1(Attribute ID) + 2(Length) */
2126
u8 attr_id = *attr_ptr;
2127
u16 attr_data_len = RTW_GET_LE16(attr_ptr + 1);
2128
u16 attr_len = attr_data_len + 3;
2129
2130
if (0)
2131
RTW_INFO("%s attr_ptr:%p, id:%u, length:%u\n", __func__, attr_ptr, attr_id, attr_data_len);
2132
2133
if ((attr_ptr - p2p_ie + attr_len) > p2p_ielen)
2134
break;
2135
2136
if (attr_id == target_attr_id) {
2137
target_attr_ptr = attr_ptr;
2138
2139
if (buf_attr)
2140
_rtw_memcpy(buf_attr, attr_ptr, attr_len);
2141
2142
if (len_attr)
2143
*len_attr = attr_len;
2144
2145
break;
2146
} else
2147
attr_ptr += attr_len;
2148
}
2149
2150
return target_attr_ptr;
2151
}
2152
2153
/**
2154
* rtw_get_p2p_attr_content - Search a specific P2P attribute content from a given P2P IE
2155
* @p2p_ie: Address of P2P IE to search
2156
* @p2p_ielen: Length limit from p2p_ie
2157
* @target_attr_id: The attribute ID of P2P attribute to search
2158
* @buf_content: If not NULL and the P2P attribute is found, P2P attribute content will be copied to the buf starting from buf_content
2159
* @len_content: If not NULL and the P2P attribute is found, will set to the length of the P2P attribute content
2160
*
2161
* Returns: the address of the specific P2P attribute content found, or NULL
2162
*/
2163
u8 *rtw_get_p2p_attr_content(u8 *p2p_ie, uint p2p_ielen, u8 target_attr_id , u8 *buf_content, uint *len_content)
2164
{
2165
u8 *attr_ptr;
2166
u32 attr_len;
2167
2168
if (len_content)
2169
*len_content = 0;
2170
2171
attr_ptr = rtw_get_p2p_attr(p2p_ie, p2p_ielen, target_attr_id, NULL, &attr_len);
2172
2173
if (attr_ptr && attr_len) {
2174
if (buf_content)
2175
_rtw_memcpy(buf_content, attr_ptr + 3, attr_len - 3);
2176
2177
if (len_content)
2178
*len_content = attr_len - 3;
2179
2180
return attr_ptr + 3;
2181
}
2182
2183
return NULL;
2184
}
2185
2186
u32 rtw_set_p2p_attr_content(u8 *pbuf, u8 attr_id, u16 attr_len, u8 *pdata_attr)
2187
{
2188
u32 a_len;
2189
2190
*pbuf = attr_id;
2191
2192
/* *(u16*)(pbuf + 1) = cpu_to_le16(attr_len); */
2193
RTW_PUT_LE16(pbuf + 1, attr_len);
2194
2195
if (pdata_attr)
2196
_rtw_memcpy(pbuf + 3, pdata_attr, attr_len);
2197
2198
a_len = attr_len + 3;
2199
2200
return a_len;
2201
}
2202
2203
uint rtw_del_p2p_ie(u8 *ies, uint ies_len_ori, const char *msg)
2204
{
2205
#define DBG_DEL_P2P_IE 0
2206
2207
u8 *target_ie;
2208
u32 target_ie_len;
2209
uint ies_len = ies_len_ori;
2210
int index = 0;
2211
2212
while (1) {
2213
target_ie = rtw_get_p2p_ie(ies, ies_len, NULL, &target_ie_len);
2214
if (target_ie && target_ie_len) {
2215
u8 *next_ie = target_ie + target_ie_len;
2216
uint remain_len = ies_len - (next_ie - ies);
2217
2218
if (DBG_DEL_P2P_IE && msg) {
2219
RTW_INFO("%s %d before\n", __func__, index);
2220
dump_ies(RTW_DBGDUMP, ies, ies_len);
2221
2222
RTW_INFO("ies:%p, ies_len:%u\n", ies, ies_len);
2223
RTW_INFO("target_ie:%p, target_ie_len:%u\n", target_ie, target_ie_len);
2224
RTW_INFO("next_ie:%p, remain_len:%u\n", next_ie, remain_len);
2225
}
2226
2227
_rtw_memmove(target_ie, next_ie, remain_len);
2228
_rtw_memset(target_ie + remain_len, 0, target_ie_len);
2229
ies_len -= target_ie_len;
2230
2231
if (DBG_DEL_P2P_IE && msg) {
2232
RTW_INFO("%s %d after\n", __func__, index);
2233
dump_ies(RTW_DBGDUMP, ies, ies_len);
2234
}
2235
2236
index++;
2237
} else
2238
break;
2239
}
2240
2241
return ies_len;
2242
}
2243
2244
uint rtw_del_p2p_attr(u8 *ie, uint ielen_ori, u8 attr_id)
2245
{
2246
#define DBG_DEL_P2P_ATTR 0
2247
2248
u8 *target_attr;
2249
u32 target_attr_len;
2250
uint ielen = ielen_ori;
2251
int index = 0;
2252
2253
while (1) {
2254
target_attr = rtw_get_p2p_attr(ie, ielen, attr_id, NULL, &target_attr_len);
2255
if (target_attr && target_attr_len) {
2256
u8 *next_attr = target_attr + target_attr_len;
2257
uint remain_len = ielen - (next_attr - ie);
2258
2259
if (DBG_DEL_P2P_ATTR) {
2260
RTW_INFO("%s %d before\n", __func__, index);
2261
dump_ies(RTW_DBGDUMP, ie, ielen);
2262
2263
RTW_INFO("ie:%p, ielen:%u\n", ie, ielen);
2264
RTW_INFO("target_attr:%p, target_attr_len:%u\n", target_attr, target_attr_len);
2265
RTW_INFO("next_attr:%p, remain_len:%u\n", next_attr, remain_len);
2266
}
2267
2268
_rtw_memmove(target_attr, next_attr, remain_len);
2269
_rtw_memset(target_attr + remain_len, 0, target_attr_len);
2270
*(ie + 1) -= target_attr_len;
2271
ielen -= target_attr_len;
2272
2273
if (DBG_DEL_P2P_ATTR) {
2274
RTW_INFO("%s %d after\n", __func__, index);
2275
dump_ies(RTW_DBGDUMP, ie, ielen);
2276
}
2277
2278
index++;
2279
} else
2280
break;
2281
}
2282
2283
return ielen;
2284
}
2285
2286
inline u8 *rtw_bss_ex_get_p2p_ie(WLAN_BSSID_EX *bss_ex, u8 *p2p_ie, uint *p2p_ielen)
2287
{
2288
return rtw_get_p2p_ie(BSS_EX_TLV_IES(bss_ex), BSS_EX_TLV_IES_LEN(bss_ex), p2p_ie, p2p_ielen);
2289
}
2290
2291
void rtw_bss_ex_del_p2p_ie(WLAN_BSSID_EX *bss_ex)
2292
{
2293
#define DBG_BSS_EX_DEL_P2P_IE 0
2294
2295
u8 *ies = BSS_EX_TLV_IES(bss_ex);
2296
uint ies_len_ori = BSS_EX_TLV_IES_LEN(bss_ex);
2297
uint ies_len;
2298
2299
ies_len = rtw_del_p2p_ie(ies, ies_len_ori, DBG_BSS_EX_DEL_P2P_IE ? __func__ : NULL);
2300
bss_ex->IELength -= ies_len_ori - ies_len;
2301
}
2302
2303
void rtw_bss_ex_del_p2p_attr(WLAN_BSSID_EX *bss_ex, u8 attr_id)
2304
{
2305
#define DBG_BSS_EX_DEL_P2P_ATTR 0
2306
2307
u8 *ies = BSS_EX_TLV_IES(bss_ex);
2308
uint ies_len = BSS_EX_TLV_IES_LEN(bss_ex);
2309
2310
u8 *ie;
2311
uint ie_len, ie_len_ori;
2312
2313
int index = 0;
2314
2315
while (1) {
2316
ie = rtw_get_p2p_ie(ies, ies_len, NULL, &ie_len_ori);
2317
if (ie) {
2318
u8 *next_ie_ori = ie + ie_len_ori;
2319
uint remain_len = bss_ex->IELength - (next_ie_ori - bss_ex->IEs);
2320
u8 has_target_attr = 0;
2321
2322
if (DBG_BSS_EX_DEL_P2P_ATTR) {
2323
if (rtw_get_p2p_attr(ie, ie_len_ori, attr_id, NULL, NULL)) {
2324
RTW_INFO("%s %d before\n", __func__, index);
2325
dump_ies(RTW_DBGDUMP, BSS_EX_TLV_IES(bss_ex), BSS_EX_TLV_IES_LEN(bss_ex));
2326
2327
RTW_INFO("ies:%p, ies_len:%u\n", ies, ies_len);
2328
RTW_INFO("ie:%p, ie_len_ori:%u\n", ie, ie_len_ori);
2329
RTW_INFO("next_ie_ori:%p, remain_len:%u\n", next_ie_ori, remain_len);
2330
has_target_attr = 1;
2331
}
2332
}
2333
2334
ie_len = rtw_del_p2p_attr(ie, ie_len_ori, attr_id);
2335
if (ie_len != ie_len_ori) {
2336
u8 *next_ie = ie + ie_len;
2337
2338
_rtw_memmove(next_ie, next_ie_ori, remain_len);
2339
_rtw_memset(next_ie + remain_len, 0, ie_len_ori - ie_len);
2340
bss_ex->IELength -= ie_len_ori - ie_len;
2341
2342
ies = next_ie;
2343
} else
2344
ies = next_ie_ori;
2345
2346
if (DBG_BSS_EX_DEL_P2P_ATTR) {
2347
if (has_target_attr) {
2348
RTW_INFO("%s %d after\n", __func__, index);
2349
dump_ies(RTW_DBGDUMP, BSS_EX_TLV_IES(bss_ex), BSS_EX_TLV_IES_LEN(bss_ex));
2350
}
2351
}
2352
2353
ies_len = remain_len;
2354
2355
index++;
2356
} else
2357
break;
2358
}
2359
}
2360
2361
void dump_wfd_ie(void *sel, const u8 *ie, u32 ie_len)
2362
{
2363
const u8 *pos = ie;
2364
u8 id;
2365
u16 len;
2366
2367
const u8 *wfd_ie;
2368
uint wfd_ielen;
2369
2370
wfd_ie = rtw_get_wfd_ie(ie, ie_len, NULL, &wfd_ielen);
2371
if (wfd_ie != ie || wfd_ielen == 0)
2372
return;
2373
2374
pos += 6;
2375
while (pos - ie + 3 <= ie_len) {
2376
id = *pos;
2377
len = RTW_GET_BE16(pos + 1);
2378
2379
RTW_PRINT_SEL(sel, "%s ID:%u, LEN:%u%s\n", __func__, id, len
2380
, ((pos - ie + 3 + len) <= ie_len) ? "" : "(exceed ie_len)");
2381
2382
pos += (3 + len);
2383
}
2384
}
2385
2386
/**
2387
* rtw_get_wfd_ie - Search WFD IE from a series of IEs
2388
* @in_ie: Address of IEs to search
2389
* @in_len: Length limit from in_ie
2390
* @wfd_ie: If not NULL and WFD IE is found, WFD IE will be copied to the buf starting from wfd_ie
2391
* @wfd_ielen: If not NULL and WFD IE is found, will set to the length of the entire WFD IE
2392
*
2393
* Returns: The address of the P2P IE found, or NULL
2394
*/
2395
u8 *rtw_get_wfd_ie(const u8 *in_ie, int in_len, u8 *wfd_ie, uint *wfd_ielen)
2396
{
2397
uint cnt;
2398
const u8 *wfd_ie_ptr = NULL;
2399
u8 eid, wfd_oui[4] = {0x50, 0x6F, 0x9A, 0x0A};
2400
2401
if (wfd_ielen)
2402
*wfd_ielen = 0;
2403
2404
if (!in_ie || in_len < 0) {
2405
rtw_warn_on(1);
2406
return (u8 *)wfd_ie_ptr;
2407
}
2408
2409
if (in_len <= 0)
2410
return (u8 *)wfd_ie_ptr;
2411
2412
cnt = 0;
2413
2414
while (cnt + 1 + 4 < in_len) {
2415
eid = in_ie[cnt];
2416
2417
if (cnt + 1 + 4 >= MAX_IE_SZ) {
2418
rtw_warn_on(1);
2419
return NULL;
2420
}
2421
2422
if (eid == WLAN_EID_VENDOR_SPECIFIC && _rtw_memcmp(&in_ie[cnt + 2], wfd_oui, 4) == _TRUE) {
2423
wfd_ie_ptr = in_ie + cnt;
2424
2425
if (wfd_ie)
2426
_rtw_memcpy(wfd_ie, &in_ie[cnt], in_ie[cnt + 1] + 2);
2427
2428
if (wfd_ielen)
2429
*wfd_ielen = in_ie[cnt + 1] + 2;
2430
2431
break;
2432
} else
2433
cnt += in_ie[cnt + 1] + 2;
2434
2435
}
2436
2437
return (u8 *)wfd_ie_ptr;
2438
}
2439
2440
/**
2441
* rtw_get_wfd_attr - Search a specific WFD attribute from a given WFD IE
2442
* @wfd_ie: Address of WFD IE to search
2443
* @wfd_ielen: Length limit from wfd_ie
2444
* @target_attr_id: The attribute ID of WFD attribute to search
2445
* @buf_attr: If not NULL and the WFD attribute is found, WFD attribute will be copied to the buf starting from buf_attr
2446
* @len_attr: If not NULL and the WFD attribute is found, will set to the length of the entire WFD attribute
2447
*
2448
* Returns: the address of the specific WPS attribute found, or NULL
2449
*/
2450
u8 *rtw_get_wfd_attr(u8 *wfd_ie, uint wfd_ielen, u8 target_attr_id, u8 *buf_attr, u32 *len_attr)
2451
{
2452
u8 *attr_ptr = NULL;
2453
u8 *target_attr_ptr = NULL;
2454
u8 wfd_oui[4] = {0x50, 0x6F, 0x9A, 0x0A};
2455
2456
if (len_attr)
2457
*len_attr = 0;
2458
2459
if (!wfd_ie
2460
|| wfd_ielen <= 6
2461
|| (wfd_ie[0] != WLAN_EID_VENDOR_SPECIFIC)
2462
|| (_rtw_memcmp(wfd_ie + 2, wfd_oui, 4) != _TRUE))
2463
return attr_ptr;
2464
2465
/* 6 = 1(Element ID) + 1(Length) + 3 (OUI) + 1(OUI Type) */
2466
attr_ptr = wfd_ie + 6; /* goto first attr */
2467
2468
while ((attr_ptr - wfd_ie + 3) <= wfd_ielen) {
2469
/* 3 = 1(Attribute ID) + 2(Length) */
2470
u8 attr_id = *attr_ptr;
2471
u16 attr_data_len = RTW_GET_BE16(attr_ptr + 1);
2472
u16 attr_len = attr_data_len + 3;
2473
2474
if (0)
2475
RTW_INFO("%s attr_ptr:%p, id:%u, length:%u\n", __func__, attr_ptr, attr_id, attr_data_len);
2476
2477
if ((attr_ptr - wfd_ie + attr_len) > wfd_ielen)
2478
break;
2479
2480
if (attr_id == target_attr_id) {
2481
target_attr_ptr = attr_ptr;
2482
2483
if (buf_attr)
2484
_rtw_memcpy(buf_attr, attr_ptr, attr_len);
2485
2486
if (len_attr)
2487
*len_attr = attr_len;
2488
2489
break;
2490
} else
2491
attr_ptr += attr_len;
2492
}
2493
2494
return target_attr_ptr;
2495
}
2496
2497
/**
2498
* rtw_get_wfd_attr_content - Search a specific WFD attribute content from a given WFD IE
2499
* @wfd_ie: Address of WFD IE to search
2500
* @wfd_ielen: Length limit from wfd_ie
2501
* @target_attr_id: The attribute ID of WFD attribute to search
2502
* @buf_content: If not NULL and the WFD attribute is found, WFD attribute content will be copied to the buf starting from buf_content
2503
* @len_content: If not NULL and the WFD attribute is found, will set to the length of the WFD attribute content
2504
*
2505
* Returns: the address of the specific WFD attribute content found, or NULL
2506
*/
2507
u8 *rtw_get_wfd_attr_content(u8 *wfd_ie, uint wfd_ielen, u8 target_attr_id, u8 *buf_content, uint *len_content)
2508
{
2509
u8 *attr_ptr;
2510
u32 attr_len;
2511
2512
if (len_content)
2513
*len_content = 0;
2514
2515
attr_ptr = rtw_get_wfd_attr(wfd_ie, wfd_ielen, target_attr_id, NULL, &attr_len);
2516
2517
if (attr_ptr && attr_len) {
2518
if (buf_content)
2519
_rtw_memcpy(buf_content, attr_ptr + 3, attr_len - 3);
2520
2521
if (len_content)
2522
*len_content = attr_len - 3;
2523
2524
return attr_ptr + 3;
2525
}
2526
2527
return NULL;
2528
}
2529
2530
uint rtw_del_wfd_ie(u8 *ies, uint ies_len_ori, const char *msg)
2531
{
2532
#define DBG_DEL_WFD_IE 0
2533
2534
u8 *target_ie;
2535
u32 target_ie_len;
2536
uint ies_len = ies_len_ori;
2537
int index = 0;
2538
2539
while (1) {
2540
target_ie = rtw_get_wfd_ie(ies, ies_len, NULL, &target_ie_len);
2541
if (target_ie && target_ie_len) {
2542
u8 *next_ie = target_ie + target_ie_len;
2543
uint remain_len = ies_len - (next_ie - ies);
2544
2545
if (DBG_DEL_WFD_IE && msg) {
2546
RTW_INFO("%s %d before\n", __func__, index);
2547
dump_ies(RTW_DBGDUMP, ies, ies_len);
2548
2549
RTW_INFO("ies:%p, ies_len:%u\n", ies, ies_len);
2550
RTW_INFO("target_ie:%p, target_ie_len:%u\n", target_ie, target_ie_len);
2551
RTW_INFO("next_ie:%p, remain_len:%u\n", next_ie, remain_len);
2552
}
2553
2554
_rtw_memmove(target_ie, next_ie, remain_len);
2555
_rtw_memset(target_ie + remain_len, 0, target_ie_len);
2556
ies_len -= target_ie_len;
2557
2558
if (DBG_DEL_WFD_IE && msg) {
2559
RTW_INFO("%s %d after\n", __func__, index);
2560
dump_ies(RTW_DBGDUMP, ies, ies_len);
2561
}
2562
2563
index++;
2564
} else
2565
break;
2566
}
2567
2568
return ies_len;
2569
}
2570
2571
uint rtw_del_wfd_attr(u8 *ie, uint ielen_ori, u8 attr_id)
2572
{
2573
#define DBG_DEL_WFD_ATTR 0
2574
2575
u8 *target_attr;
2576
u32 target_attr_len;
2577
uint ielen = ielen_ori;
2578
int index = 0;
2579
2580
while (1) {
2581
target_attr = rtw_get_wfd_attr(ie, ielen, attr_id, NULL, &target_attr_len);
2582
if (target_attr && target_attr_len) {
2583
u8 *next_attr = target_attr + target_attr_len;
2584
uint remain_len = ielen - (next_attr - ie);
2585
2586
if (DBG_DEL_WFD_ATTR) {
2587
RTW_INFO("%s %d before\n", __func__, index);
2588
dump_ies(RTW_DBGDUMP, ie, ielen);
2589
2590
RTW_INFO("ie:%p, ielen:%u\n", ie, ielen);
2591
RTW_INFO("target_attr:%p, target_attr_len:%u\n", target_attr, target_attr_len);
2592
RTW_INFO("next_attr:%p, remain_len:%u\n", next_attr, remain_len);
2593
}
2594
2595
_rtw_memmove(target_attr, next_attr, remain_len);
2596
_rtw_memset(target_attr + remain_len, 0, target_attr_len);
2597
*(ie + 1) -= target_attr_len;
2598
ielen -= target_attr_len;
2599
2600
if (DBG_DEL_WFD_ATTR) {
2601
RTW_INFO("%s %d after\n", __func__, index);
2602
dump_ies(RTW_DBGDUMP, ie, ielen);
2603
}
2604
2605
index++;
2606
} else
2607
break;
2608
}
2609
2610
return ielen;
2611
}
2612
2613
inline u8 *rtw_bss_ex_get_wfd_ie(WLAN_BSSID_EX *bss_ex, u8 *wfd_ie, uint *wfd_ielen)
2614
{
2615
return rtw_get_wfd_ie(BSS_EX_TLV_IES(bss_ex), BSS_EX_TLV_IES_LEN(bss_ex), wfd_ie, wfd_ielen);
2616
}
2617
2618
void rtw_bss_ex_del_wfd_ie(WLAN_BSSID_EX *bss_ex)
2619
{
2620
#define DBG_BSS_EX_DEL_WFD_IE 0
2621
u8 *ies = BSS_EX_TLV_IES(bss_ex);
2622
uint ies_len_ori = BSS_EX_TLV_IES_LEN(bss_ex);
2623
uint ies_len;
2624
2625
ies_len = rtw_del_wfd_ie(ies, ies_len_ori, DBG_BSS_EX_DEL_WFD_IE ? __func__ : NULL);
2626
bss_ex->IELength -= ies_len_ori - ies_len;
2627
}
2628
2629
void rtw_bss_ex_del_wfd_attr(WLAN_BSSID_EX *bss_ex, u8 attr_id)
2630
{
2631
#define DBG_BSS_EX_DEL_WFD_ATTR 0
2632
2633
u8 *ies = BSS_EX_TLV_IES(bss_ex);
2634
uint ies_len = BSS_EX_TLV_IES_LEN(bss_ex);
2635
2636
u8 *ie;
2637
uint ie_len, ie_len_ori;
2638
2639
int index = 0;
2640
2641
while (1) {
2642
ie = rtw_get_wfd_ie(ies, ies_len, NULL, &ie_len_ori);
2643
if (ie) {
2644
u8 *next_ie_ori = ie + ie_len_ori;
2645
uint remain_len = bss_ex->IELength - (next_ie_ori - bss_ex->IEs);
2646
u8 has_target_attr = 0;
2647
2648
if (DBG_BSS_EX_DEL_WFD_ATTR) {
2649
if (rtw_get_wfd_attr(ie, ie_len_ori, attr_id, NULL, NULL)) {
2650
RTW_INFO("%s %d before\n", __func__, index);
2651
dump_ies(RTW_DBGDUMP, BSS_EX_TLV_IES(bss_ex), BSS_EX_TLV_IES_LEN(bss_ex));
2652
2653
RTW_INFO("ies:%p, ies_len:%u\n", ies, ies_len);
2654
RTW_INFO("ie:%p, ie_len_ori:%u\n", ie, ie_len_ori);
2655
RTW_INFO("next_ie_ori:%p, remain_len:%u\n", next_ie_ori, remain_len);
2656
has_target_attr = 1;
2657
}
2658
}
2659
2660
ie_len = rtw_del_wfd_attr(ie, ie_len_ori, attr_id);
2661
if (ie_len != ie_len_ori) {
2662
u8 *next_ie = ie + ie_len;
2663
2664
_rtw_memmove(next_ie, next_ie_ori, remain_len);
2665
_rtw_memset(next_ie + remain_len, 0, ie_len_ori - ie_len);
2666
bss_ex->IELength -= ie_len_ori - ie_len;
2667
2668
ies = next_ie;
2669
} else
2670
ies = next_ie_ori;
2671
2672
if (DBG_BSS_EX_DEL_WFD_ATTR) {
2673
if (has_target_attr) {
2674
RTW_INFO("%s %d after\n", __func__, index);
2675
dump_ies(RTW_DBGDUMP, BSS_EX_TLV_IES(bss_ex), BSS_EX_TLV_IES_LEN(bss_ex));
2676
}
2677
}
2678
2679
ies_len = remain_len;
2680
2681
index++;
2682
} else
2683
break;
2684
}
2685
}
2686
2687
/* Baron adds to avoid FreeBSD warning */
2688
int ieee80211_is_empty_essid(const char *essid, int essid_len)
2689
{
2690
/* Single white space is for Linksys APs */
2691
if (essid_len == 1 && essid[0] == ' ')
2692
return 1;
2693
2694
/* Otherwise, if the entire essid is 0, we assume it is hidden */
2695
while (essid_len) {
2696
essid_len--;
2697
if (essid[essid_len] != '\0')
2698
return 0;
2699
}
2700
2701
return 1;
2702
}
2703
2704
int ieee80211_get_hdrlen(u16 fc)
2705
{
2706
int hdrlen = 24;
2707
2708
switch (WLAN_FC_GET_TYPE(fc)) {
2709
case RTW_IEEE80211_FTYPE_DATA:
2710
if (fc & RTW_IEEE80211_STYPE_QOS_DATA)
2711
hdrlen += 2;
2712
if ((fc & RTW_IEEE80211_FCTL_FROMDS) && (fc & RTW_IEEE80211_FCTL_TODS))
2713
hdrlen += 6; /* Addr4 */
2714
break;
2715
case RTW_IEEE80211_FTYPE_CTL:
2716
switch (WLAN_FC_GET_STYPE(fc)) {
2717
case RTW_IEEE80211_STYPE_CTS:
2718
case RTW_IEEE80211_STYPE_ACK:
2719
hdrlen = 10;
2720
break;
2721
default:
2722
hdrlen = 16;
2723
break;
2724
}
2725
break;
2726
}
2727
2728
return hdrlen;
2729
}
2730
2731
u8 rtw_ht_mcsset_to_nss(u8 *supp_mcs_set)
2732
{
2733
u8 nss = 1;
2734
2735
if (supp_mcs_set[3])
2736
nss = 4;
2737
else if (supp_mcs_set[2])
2738
nss = 3;
2739
else if (supp_mcs_set[1])
2740
nss = 2;
2741
else if (supp_mcs_set[0])
2742
nss = 1;
2743
else
2744
RTW_INFO("%s,%d, warning! supp_mcs_set is zero\n", __func__, __LINE__);
2745
/* RTW_INFO("%s HT: %dSS\n", __FUNCTION__, nss); */
2746
return nss;
2747
}
2748
2749
u32 rtw_ht_mcs_set_to_bitmap(u8 *mcs_set, u8 nss)
2750
{
2751
u8 i;
2752
u32 bitmap = 0;
2753
2754
for (i = 0; i < nss; i++)
2755
bitmap |= mcs_set[i] << (i * 8);
2756
2757
RTW_INFO("ht_mcs_set=%02x %02x %02x %02x, nss=%u, bitmap=%08x\n"
2758
, mcs_set[0], mcs_set[1], mcs_set[2], mcs_set[3], nss, bitmap);
2759
2760
return bitmap;
2761
}
2762
2763
/* show MCS rate, unit: 100Kbps */
2764
u16 rtw_ht_mcs_rate(u8 bw_40MHz, u8 short_GI, unsigned char *MCS_rate)
2765
{
2766
u16 max_rate = 0;
2767
2768
if (MCS_rate[3]) {
2769
if (MCS_rate[3] & BIT(7))
2770
max_rate = (bw_40MHz) ? ((short_GI) ? 6000 : 5400) : ((short_GI) ? 2889 : 2600);
2771
else if (MCS_rate[3] & BIT(6))
2772
max_rate = (bw_40MHz) ? ((short_GI) ? 5400 : 4860) : ((short_GI) ? 2600 : 2340);
2773
else if (MCS_rate[3] & BIT(5))
2774
max_rate = (bw_40MHz) ? ((short_GI) ? 4800 : 4320) : ((short_GI) ? 2311 : 2080);
2775
else if (MCS_rate[3] & BIT(4))
2776
max_rate = (bw_40MHz) ? ((short_GI) ? 3600 : 3240) : ((short_GI) ? 1733 : 1560);
2777
else if (MCS_rate[3] & BIT(3))
2778
max_rate = (bw_40MHz) ? ((short_GI) ? 2400 : 2160) : ((short_GI) ? 1156 : 1040);
2779
else if (MCS_rate[3] & BIT(2))
2780
max_rate = (bw_40MHz) ? ((short_GI) ? 1800 : 1620) : ((short_GI) ? 867 : 780);
2781
else if (MCS_rate[3] & BIT(1))
2782
max_rate = (bw_40MHz) ? ((short_GI) ? 1200 : 1080) : ((short_GI) ? 578 : 520);
2783
else if (MCS_rate[3] & BIT(0))
2784
max_rate = (bw_40MHz) ? ((short_GI) ? 600 : 540) : ((short_GI) ? 289 : 260);
2785
} else if (MCS_rate[2]) {
2786
if (MCS_rate[2] & BIT(7))
2787
max_rate = (bw_40MHz) ? ((short_GI) ? 4500 : 4050) : ((short_GI) ? 2167 : 1950);
2788
else if (MCS_rate[2] & BIT(6))
2789
max_rate = (bw_40MHz) ? ((short_GI) ? 4050 : 3645) : ((short_GI) ? 1950 : 1750);
2790
else if (MCS_rate[2] & BIT(5))
2791
max_rate = (bw_40MHz) ? ((short_GI) ? 3600 : 3240) : ((short_GI) ? 1733 : 1560);
2792
else if (MCS_rate[2] & BIT(4))
2793
max_rate = (bw_40MHz) ? ((short_GI) ? 2700 : 2430) : ((short_GI) ? 1300 : 1170);
2794
else if (MCS_rate[2] & BIT(3))
2795
max_rate = (bw_40MHz) ? ((short_GI) ? 1800 : 1620) : ((short_GI) ? 867 : 780);
2796
else if (MCS_rate[2] & BIT(2))
2797
max_rate = (bw_40MHz) ? ((short_GI) ? 1350 : 1215) : ((short_GI) ? 650 : 585);
2798
else if (MCS_rate[2] & BIT(1))
2799
max_rate = (bw_40MHz) ? ((short_GI) ? 900 : 810) : ((short_GI) ? 433 : 390);
2800
else if (MCS_rate[2] & BIT(0))
2801
max_rate = (bw_40MHz) ? ((short_GI) ? 450 : 405) : ((short_GI) ? 217 : 195);
2802
} else if (MCS_rate[1]) {
2803
if (MCS_rate[1] & BIT(7))
2804
max_rate = (bw_40MHz) ? ((short_GI) ? 3000 : 2700) : ((short_GI) ? 1444 : 1300);
2805
else if (MCS_rate[1] & BIT(6))
2806
max_rate = (bw_40MHz) ? ((short_GI) ? 2700 : 2430) : ((short_GI) ? 1300 : 1170);
2807
else if (MCS_rate[1] & BIT(5))
2808
max_rate = (bw_40MHz) ? ((short_GI) ? 2400 : 2160) : ((short_GI) ? 1156 : 1040);
2809
else if (MCS_rate[1] & BIT(4))
2810
max_rate = (bw_40MHz) ? ((short_GI) ? 1800 : 1620) : ((short_GI) ? 867 : 780);
2811
else if (MCS_rate[1] & BIT(3))
2812
max_rate = (bw_40MHz) ? ((short_GI) ? 1200 : 1080) : ((short_GI) ? 578 : 520);
2813
else if (MCS_rate[1] & BIT(2))
2814
max_rate = (bw_40MHz) ? ((short_GI) ? 900 : 810) : ((short_GI) ? 433 : 390);
2815
else if (MCS_rate[1] & BIT(1))
2816
max_rate = (bw_40MHz) ? ((short_GI) ? 600 : 540) : ((short_GI) ? 289 : 260);
2817
else if (MCS_rate[1] & BIT(0))
2818
max_rate = (bw_40MHz) ? ((short_GI) ? 300 : 270) : ((short_GI) ? 144 : 130);
2819
} else {
2820
if (MCS_rate[0] & BIT(7))
2821
max_rate = (bw_40MHz) ? ((short_GI) ? 1500 : 1350) : ((short_GI) ? 722 : 650);
2822
else if (MCS_rate[0] & BIT(6))
2823
max_rate = (bw_40MHz) ? ((short_GI) ? 1350 : 1215) : ((short_GI) ? 650 : 585);
2824
else if (MCS_rate[0] & BIT(5))
2825
max_rate = (bw_40MHz) ? ((short_GI) ? 1200 : 1080) : ((short_GI) ? 578 : 520);
2826
else if (MCS_rate[0] & BIT(4))
2827
max_rate = (bw_40MHz) ? ((short_GI) ? 900 : 810) : ((short_GI) ? 433 : 390);
2828
else if (MCS_rate[0] & BIT(3))
2829
max_rate = (bw_40MHz) ? ((short_GI) ? 600 : 540) : ((short_GI) ? 289 : 260);
2830
else if (MCS_rate[0] & BIT(2))
2831
max_rate = (bw_40MHz) ? ((short_GI) ? 450 : 405) : ((short_GI) ? 217 : 195);
2832
else if (MCS_rate[0] & BIT(1))
2833
max_rate = (bw_40MHz) ? ((short_GI) ? 300 : 270) : ((short_GI) ? 144 : 130);
2834
else if (MCS_rate[0] & BIT(0))
2835
max_rate = (bw_40MHz) ? ((short_GI) ? 150 : 135) : ((short_GI) ? 72 : 65);
2836
}
2837
2838
return max_rate;
2839
}
2840
2841
int rtw_action_frame_parse(const u8 *frame, u32 frame_len, u8 *category, u8 *action)
2842
{
2843
const u8 *frame_body = frame + sizeof(struct rtw_ieee80211_hdr_3addr);
2844
u16 fc;
2845
u8 c;
2846
u8 a = ACT_PUBLIC_MAX;
2847
2848
fc = le16_to_cpu(((struct rtw_ieee80211_hdr_3addr *)frame)->frame_ctl);
2849
2850
if ((fc & (RTW_IEEE80211_FCTL_FTYPE | RTW_IEEE80211_FCTL_STYPE))
2851
!= (RTW_IEEE80211_FTYPE_MGMT | RTW_IEEE80211_STYPE_ACTION)
2852
)
2853
return _FALSE;
2854
2855
c = frame_body[0];
2856
2857
switch (c) {
2858
case RTW_WLAN_CATEGORY_P2P: /* vendor-specific */
2859
break;
2860
default:
2861
a = frame_body[1];
2862
}
2863
2864
if (category)
2865
*category = c;
2866
if (action)
2867
*action = a;
2868
2869
return _TRUE;
2870
}
2871
2872
static const char *_action_public_str[] = {
2873
"ACT_PUB_BSSCOEXIST",
2874
"ACT_PUB_DSE_ENABLE",
2875
"ACT_PUB_DSE_DEENABLE",
2876
"ACT_PUB_DSE_REG_LOCATION",
2877
"ACT_PUB_EXT_CHL_SWITCH",
2878
"ACT_PUB_DSE_MSR_REQ",
2879
"ACT_PUB_DSE_MSR_RPRT",
2880
"ACT_PUB_MP",
2881
"ACT_PUB_DSE_PWR_CONSTRAINT",
2882
"ACT_PUB_VENDOR",
2883
"ACT_PUB_GAS_INITIAL_REQ",
2884
"ACT_PUB_GAS_INITIAL_RSP",
2885
"ACT_PUB_GAS_COMEBACK_REQ",
2886
"ACT_PUB_GAS_COMEBACK_RSP",
2887
"ACT_PUB_TDLS_DISCOVERY_RSP",
2888
"ACT_PUB_LOCATION_TRACK",
2889
"ACT_PUB_RSVD",
2890
};
2891
2892
const char *action_public_str(u8 action)
2893
{
2894
action = (action >= ACT_PUBLIC_MAX) ? ACT_PUBLIC_MAX : action;
2895
return _action_public_str[action];
2896
}
2897
2898
2899