hc
2024-05-10 9999e48639b3cecb08ffb37358bcba3b48161b29
kernel/drivers/staging/rtl8712/ieee80211.c
....@@ -1,17 +1,9 @@
1
+// SPDX-License-Identifier: GPL-2.0
12 /******************************************************************************
23 * ieee80211.c
34 *
45 * Copyright(c) 2007 - 2010 Realtek Corporation. All rights reserved.
56 * Linux device driver for RTL8192SU
6
- *
7
- * This program is free software; you can redistribute it and/or modify it
8
- * under the terms of version 2 of the GNU General Public License as
9
- * published by the Free Software Foundation.
10
- *
11
- * This program is distributed in the hope that it will be useful, but WITHOUT
12
- * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
13
- * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for
14
- * more details.
157 *
168 * Modifications for inclusion into the Linux staging tree are
179 * Copyright(c) 2010 Larry Finger. All rights reserved.
....@@ -164,13 +156,13 @@
164156 return i;
165157 }
166158
167
-int r8712_generate_ie(struct registry_priv *pregistrypriv)
159
+int r8712_generate_ie(struct registry_priv *registrypriv)
168160 {
169161 int rate_len;
170162 uint sz = 0;
171
- struct wlan_bssid_ex *pdev_network = &pregistrypriv->dev_network;
172
- u8 *ie = pdev_network->IEs;
173
- u16 beaconPeriod = (u16)pdev_network->Configuration.BeaconPeriod;
163
+ struct wlan_bssid_ex *dev_network = &registrypriv->dev_network;
164
+ u8 *ie = dev_network->IEs;
165
+ u16 beaconPeriod = (u16)dev_network->Configuration.BeaconPeriod;
174166
175167 /*timestamp will be inserted by hardware*/
176168 sz += 8;
....@@ -182,71 +174,72 @@
182174 /*capability info*/
183175 *(u16 *)ie = 0;
184176 *(__le16 *)ie |= cpu_to_le16(cap_IBSS);
185
- if (pregistrypriv->preamble == PREAMBLE_SHORT)
177
+ if (registrypriv->preamble == PREAMBLE_SHORT)
186178 *(__le16 *)ie |= cpu_to_le16(cap_ShortPremble);
187
- if (pdev_network->Privacy)
179
+ if (dev_network->Privacy)
188180 *(__le16 *)ie |= cpu_to_le16(cap_Privacy);
189181 sz += 2;
190182 ie += 2;
191183 /*SSID*/
192
- ie = r8712_set_ie(ie, _SSID_IE_, pdev_network->Ssid.SsidLength,
193
- pdev_network->Ssid.Ssid, &sz);
184
+ ie = r8712_set_ie(ie, WLAN_EID_SSID, dev_network->Ssid.SsidLength,
185
+ dev_network->Ssid.Ssid, &sz);
194186 /*supported rates*/
195
- set_supported_rate(pdev_network->rates, pregistrypriv->wireless_mode);
196
- rate_len = r8712_get_rateset_len(pdev_network->rates);
187
+ set_supported_rate(dev_network->rates, registrypriv->wireless_mode);
188
+ rate_len = r8712_get_rateset_len(dev_network->rates);
197189 if (rate_len > 8) {
198
- ie = r8712_set_ie(ie, _SUPPORTEDRATES_IE_, 8,
199
- pdev_network->rates, &sz);
200
- ie = r8712_set_ie(ie, _EXT_SUPPORTEDRATES_IE_, (rate_len - 8),
201
- (pdev_network->rates + 8), &sz);
190
+ ie = r8712_set_ie(ie, WLAN_EID_SUPP_RATES, 8,
191
+ dev_network->rates, &sz);
192
+ ie = r8712_set_ie(ie, WLAN_EID_EXT_SUPP_RATES, (rate_len - 8),
193
+ (dev_network->rates + 8), &sz);
202194 } else {
203
- ie = r8712_set_ie(ie, _SUPPORTEDRATES_IE_,
204
- rate_len, pdev_network->rates, &sz);
195
+ ie = r8712_set_ie(ie, WLAN_EID_SUPP_RATES,
196
+ rate_len, dev_network->rates, &sz);
205197 }
206198 /*DS parameter set*/
207
- ie = r8712_set_ie(ie, _DSSET_IE_, 1,
208
- (u8 *)&pdev_network->Configuration.DSConfig, &sz);
199
+ ie = r8712_set_ie(ie, WLAN_EID_DS_PARAMS, 1,
200
+ (u8 *)&dev_network->Configuration.DSConfig, &sz);
209201 /*IBSS Parameter Set*/
210
- ie = r8712_set_ie(ie, _IBSS_PARA_IE_, 2,
211
- (u8 *)&pdev_network->Configuration.ATIMWindow, &sz);
202
+ ie = r8712_set_ie(ie, WLAN_EID_IBSS_PARAMS, 2,
203
+ (u8 *)&dev_network->Configuration.ATIMWindow, &sz);
212204 return sz;
213205 }
214206
215
-unsigned char *r8712_get_wpa_ie(unsigned char *pie, uint *wpa_ie_len, int limit)
207
+unsigned char *r8712_get_wpa_ie(unsigned char *ie, uint *wpa_ie_len, int limit)
216208 {
217209 u32 len;
218210 u16 val16;
219211 unsigned char wpa_oui_type[] = {0x00, 0x50, 0xf2, 0x01};
220
- u8 *pbuf = pie;
212
+ u8 *buf = ie;
221213
222214 while (1) {
223
- pbuf = r8712_get_ie(pbuf, _WPA_IE_ID_, &len, limit);
224
- if (pbuf) {
215
+ buf = r8712_get_ie(buf, _WPA_IE_ID_, &len, limit);
216
+ if (buf) {
225217 /*check if oui matches...*/
226
- if (memcmp((pbuf + 2), wpa_oui_type,
218
+ if (memcmp((buf + 2), wpa_oui_type,
227219 sizeof(wpa_oui_type)))
228220 goto check_next_ie;
229221 /*check version...*/
230
- memcpy((u8 *)&val16, (pbuf + 6), sizeof(val16));
222
+ memcpy((u8 *)&val16, (buf + 6), sizeof(val16));
231223 le16_to_cpus(&val16);
232224 if (val16 != 0x0001)
233225 goto check_next_ie;
234
- *wpa_ie_len = *(pbuf + 1);
235
- return pbuf;
226
+ *wpa_ie_len = *(buf + 1);
227
+ return buf;
236228 }
237229 *wpa_ie_len = 0;
238230 return NULL;
239231 check_next_ie:
240
- limit = limit - (pbuf - pie) - 2 - len;
232
+ limit = limit - (buf - ie) - 2 - len;
241233 if (limit <= 0)
242234 break;
243
- pbuf += (2 + len);
235
+ buf += (2 + len);
244236 }
245237 *wpa_ie_len = 0;
246238 return NULL;
247239 }
248240
249
-unsigned char *r8712_get_wpa2_ie(unsigned char *pie, uint *rsn_ie_len, int limit)
241
+unsigned char *r8712_get_wpa2_ie(unsigned char *pie, uint *rsn_ie_len,
242
+ int limit)
250243 {
251244 return r8712_get_ie(pie, _WPA2_IE_ID_, rsn_ie_len, limit);
252245 }
....@@ -290,12 +283,12 @@
290283
291284 if (wpa_ie_len <= 0) {
292285 /* No WPA IE - fail silently */
293
- return _FAIL;
286
+ return -EINVAL;
294287 }
295288 if ((*wpa_ie != _WPA_IE_ID_) ||
296289 (*(wpa_ie + 1) != (u8)(wpa_ie_len - 2)) ||
297290 (memcmp(wpa_ie + 2, (void *)WPA_OUI_TYPE, WPA_SELECTOR_LEN)))
298
- return _FAIL;
291
+ return -EINVAL;
299292 pos = wpa_ie;
300293 pos += 8;
301294 left = wpa_ie_len - 8;
....@@ -305,7 +298,7 @@
305298 pos += WPA_SELECTOR_LEN;
306299 left -= WPA_SELECTOR_LEN;
307300 } else if (left > 0) {
308
- return _FAIL;
301
+ return -EINVAL;
309302 }
310303 /*pairwise_cipher*/
311304 if (left >= 2) {
....@@ -313,16 +306,16 @@
313306 pos += 2;
314307 left -= 2;
315308 if (count == 0 || left < count * WPA_SELECTOR_LEN)
316
- return _FAIL;
309
+ return -EINVAL;
317310 for (i = 0; i < count; i++) {
318311 *pairwise_cipher |= r8712_get_wpa_cipher_suite(pos);
319312 pos += WPA_SELECTOR_LEN;
320313 left -= WPA_SELECTOR_LEN;
321314 }
322315 } else if (left == 1) {
323
- return _FAIL;
316
+ return -EINVAL;
324317 }
325
- return _SUCCESS;
318
+ return 0;
326319 }
327320
328321 int r8712_parse_wpa2_ie(u8 *rsn_ie, int rsn_ie_len, int *group_cipher,
....@@ -334,11 +327,11 @@
334327
335328 if (rsn_ie_len <= 0) {
336329 /* No RSN IE - fail silently */
337
- return _FAIL;
330
+ return -EINVAL;
338331 }
339332 if ((*rsn_ie != _WPA2_IE_ID_) ||
340333 (*(rsn_ie + 1) != (u8)(rsn_ie_len - 2)))
341
- return _FAIL;
334
+ return -EINVAL;
342335 pos = rsn_ie;
343336 pos += 4;
344337 left = rsn_ie_len - 4;
....@@ -348,7 +341,7 @@
348341 pos += RSN_SELECTOR_LEN;
349342 left -= RSN_SELECTOR_LEN;
350343 } else if (left > 0) {
351
- return _FAIL;
344
+ return -EINVAL;
352345 }
353346 /*pairwise_cipher*/
354347 if (left >= 2) {
....@@ -356,16 +349,16 @@
356349 pos += 2;
357350 left -= 2;
358351 if (count == 0 || left < count * RSN_SELECTOR_LEN)
359
- return _FAIL;
352
+ return -EINVAL;
360353 for (i = 0; i < count; i++) {
361354 *pairwise_cipher |= r8712_get_wpa2_cipher_suite(pos);
362355 pos += RSN_SELECTOR_LEN;
363356 left -= RSN_SELECTOR_LEN;
364357 }
365358 } else if (left == 1) {
366
- return _FAIL;
359
+ return -EINVAL;
367360 }
368
- return _SUCCESS;
361
+ return 0;
369362 }
370363
371364 int r8712_get_sec_ie(u8 *in_ie, uint in_len, u8 *rsn_ie, u16 *rsn_len,
....@@ -416,7 +409,7 @@
416409 match = true;
417410 break;
418411 }
419
- cnt += in_ie[cnt + 1] + 2; /* goto next */
412
+ cnt += in_ie[cnt + 1] + 2; /* goto next */
420413 }
421414 return match;
422415 }