aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/staging/rtl8192e/rtllib_softmac.c
diff options
context:
space:
mode:
authorLarry Finger <Larry.Finger@lwfinger.net>2011-08-25 12:48:26 -0400
committerGreg Kroah-Hartman <gregkh@suse.de>2011-08-25 13:05:14 -0400
commit9d92ece80d38a6fbf098bd924cf6db146c08f817 (patch)
treeaad944989fa5c20b37973b9157f9e43966613259 /drivers/staging/rtl8192e/rtllib_softmac.c
parentdb8971b618ed967c93fb89622dfe6006a58d55a5 (diff)
staging: rtl8192e: Cleanup checkpatch -f errors - Part XIV
With this patch, all of the checkpatch errors are fixed; however, only some of the lines that are too long were fixed. To complete the fixing of these warnings, the file rtllib_softmac.c will need refactoring. In addition, some of the variables may need renaming. Those changes can be deferred. Signed-off-by: Larry Finger <Larry.Finger@lwfinger.net> Signed-off-by: Greg Kroah-Hartman <gregkh@suse.de>
Diffstat (limited to 'drivers/staging/rtl8192e/rtllib_softmac.c')
-rw-r--r--drivers/staging/rtl8192e/rtllib_softmac.c1986
1 files changed, 965 insertions, 1021 deletions
diff --git a/drivers/staging/rtl8192e/rtllib_softmac.c b/drivers/staging/rtl8192e/rtllib_softmac.c
index 29277d18f02..fa0e2afd1ed 100644
--- a/drivers/staging/rtl8192e/rtllib_softmac.c
+++ b/drivers/staging/rtl8192e/rtllib_softmac.c
@@ -20,27 +20,26 @@
20#include <linux/random.h> 20#include <linux/random.h>
21#include <linux/delay.h> 21#include <linux/delay.h>
22#include <linux/version.h> 22#include <linux/version.h>
23#include <asm/uaccess.h> 23#include <linux/uaccess.h>
24#include "dot11d.h" 24#include "dot11d.h"
25 25
26extern void _setup_timer( struct timer_list*, void*, unsigned long );
27u8 rsn_authen_cipher_suite[16][4] = { 26u8 rsn_authen_cipher_suite[16][4] = {
28 {0x00,0x0F,0xAC,0x00}, 27 {0x00, 0x0F, 0xAC, 0x00},
29 {0x00,0x0F,0xAC,0x01}, 28 {0x00, 0x0F, 0xAC, 0x01},
30 {0x00,0x0F,0xAC,0x02}, 29 {0x00, 0x0F, 0xAC, 0x02},
31 {0x00,0x0F,0xAC,0x03}, 30 {0x00, 0x0F, 0xAC, 0x03},
32 {0x00,0x0F,0xAC,0x04}, 31 {0x00, 0x0F, 0xAC, 0x04},
33 {0x00,0x0F,0xAC,0x05}, 32 {0x00, 0x0F, 0xAC, 0x05},
34}; 33};
35 34
36short rtllib_is_54g(struct rtllib_network *net) 35short rtllib_is_54g(struct rtllib_network *net)
37{ 36{
38 return ((net->rates_ex_len > 0) || (net->rates_len > 4)); 37 return (net->rates_ex_len > 0) || (net->rates_len > 4);
39} 38}
40 39
41short rtllib_is_shortslot(struct rtllib_network net) 40short rtllib_is_shortslot(struct rtllib_network net)
42{ 41{
43 return (net.capability & WLAN_CAPABILITY_SHORT_SLOT_TIME); 42 return net.capability & WLAN_CAPABILITY_SHORT_SLOT_TIME;
44} 43}
45 44
46/* returns the total length needed for pleacing the RATE MFIE 45/* returns the total length needed for pleacing the RATE MFIE
@@ -69,7 +68,7 @@ void rtllib_MFIE_Brate(struct rtllib_device *ieee, u8 **tag_p)
69{ 68{
70 u8 *tag = *tag_p; 69 u8 *tag = *tag_p;
71 70
72 if (ieee->modulation & RTLLIB_CCK_MODULATION){ 71 if (ieee->modulation & RTLLIB_CCK_MODULATION) {
73 *tag++ = MFIE_TYPE_RATES; 72 *tag++ = MFIE_TYPE_RATES;
74 *tag++ = 4; 73 *tag++ = 4;
75 *tag++ = RTLLIB_BASIC_RATE_MASK | RTLLIB_CCK_RATE_1MB; 74 *tag++ = RTLLIB_BASIC_RATE_MASK | RTLLIB_CCK_RATE_1MB;
@@ -78,7 +77,8 @@ void rtllib_MFIE_Brate(struct rtllib_device *ieee, u8 **tag_p)
78 *tag++ = RTLLIB_BASIC_RATE_MASK | RTLLIB_CCK_RATE_11MB; 77 *tag++ = RTLLIB_BASIC_RATE_MASK | RTLLIB_CCK_RATE_11MB;
79 } 78 }
80 79
81 /* We may add an option for custom rates that specific HW might support */ 80 /* We may add an option for custom rates that specific HW
81 * might support */
82 *tag_p = tag; 82 *tag_p = tag;
83} 83}
84 84
@@ -86,8 +86,7 @@ void rtllib_MFIE_Grate(struct rtllib_device *ieee, u8 **tag_p)
86{ 86{
87 u8 *tag = *tag_p; 87 u8 *tag = *tag_p;
88 88
89 if (ieee->modulation & RTLLIB_OFDM_MODULATION){ 89 if (ieee->modulation & RTLLIB_OFDM_MODULATION) {
90
91 *tag++ = MFIE_TYPE_RATES_EX; 90 *tag++ = MFIE_TYPE_RATES_EX;
92 *tag++ = 8; 91 *tag++ = 8;
93 *tag++ = RTLLIB_BASIC_RATE_MASK | RTLLIB_OFDM_RATE_6MB; 92 *tag++ = RTLLIB_BASIC_RATE_MASK | RTLLIB_OFDM_RATE_6MB;
@@ -98,14 +97,14 @@ void rtllib_MFIE_Grate(struct rtllib_device *ieee, u8 **tag_p)
98 *tag++ = RTLLIB_BASIC_RATE_MASK | RTLLIB_OFDM_RATE_36MB; 97 *tag++ = RTLLIB_BASIC_RATE_MASK | RTLLIB_OFDM_RATE_36MB;
99 *tag++ = RTLLIB_BASIC_RATE_MASK | RTLLIB_OFDM_RATE_48MB; 98 *tag++ = RTLLIB_BASIC_RATE_MASK | RTLLIB_OFDM_RATE_48MB;
100 *tag++ = RTLLIB_BASIC_RATE_MASK | RTLLIB_OFDM_RATE_54MB; 99 *tag++ = RTLLIB_BASIC_RATE_MASK | RTLLIB_OFDM_RATE_54MB;
101
102 } 100 }
103 101 /* We may add an option for custom rates that specific HW might
104 /* We may add an option for custom rates that specific HW might support */ 102 * support */
105 *tag_p = tag; 103 *tag_p = tag;
106} 104}
107 105
108void rtllib_WMM_Info(struct rtllib_device *ieee, u8 **tag_p) { 106void rtllib_WMM_Info(struct rtllib_device *ieee, u8 **tag_p)
107{
109 u8 *tag = *tag_p; 108 u8 *tag = *tag_p;
110 109
111 *tag++ = MFIE_TYPE_GENERIC; 110 *tag++ = MFIE_TYPE_GENERIC;
@@ -120,17 +119,18 @@ void rtllib_WMM_Info(struct rtllib_device *ieee, u8 **tag_p) {
120 *tag_p = tag; 119 *tag_p = tag;
121} 120}
122 121
123void rtllib_TURBO_Info(struct rtllib_device *ieee, u8 **tag_p) { 122void rtllib_TURBO_Info(struct rtllib_device *ieee, u8 **tag_p)
123{
124 u8 *tag = *tag_p; 124 u8 *tag = *tag_p;
125 125
126 *tag++ = MFIE_TYPE_GENERIC; 126 *tag++ = MFIE_TYPE_GENERIC;
127 *tag++ = 7; 127 *tag++ = 7;
128 *tag++ = 0x00; 128 *tag++ = 0x00;
129 *tag++ = 0xe0; 129 *tag++ = 0xe0;
130 *tag++ = 0x4c; 130 *tag++ = 0x4c;
131 *tag++ = 0x01; 131 *tag++ = 0x01;
132 *tag++ = 0x02; 132 *tag++ = 0x02;
133 *tag++ = 0x11; 133 *tag++ = 0x11;
134 *tag++ = 0x00; 134 *tag++ = 0x00;
135 135
136 *tag_p = tag; 136 *tag_p = tag;
@@ -140,7 +140,7 @@ void rtllib_TURBO_Info(struct rtllib_device *ieee, u8 **tag_p) {
140void enqueue_mgmt(struct rtllib_device *ieee, struct sk_buff *skb) 140void enqueue_mgmt(struct rtllib_device *ieee, struct sk_buff *skb)
141{ 141{
142 int nh; 142 int nh;
143 nh = (ieee->mgmt_queue_head +1) % MGMT_QUEUE_NUM; 143 nh = (ieee->mgmt_queue_head + 1) % MGMT_QUEUE_NUM;
144 144
145/* 145/*
146 * if the queue is full but we have newer frames then 146 * if the queue is full but we have newer frames then
@@ -183,29 +183,21 @@ MgntQuery_TxRateExcludeCCKRates(struct rtllib_device *ieee)
183 u8 BasicRate; 183 u8 BasicRate;
184 184
185 185
186 for ( i = 0; i < ieee->current_network.rates_len; i++) 186 for (i = 0; i < ieee->current_network.rates_len; i++) {
187 {
188 BasicRate = ieee->current_network.rates[i]&0x7F; 187 BasicRate = ieee->current_network.rates[i]&0x7F;
189 if (!rtllib_is_cck_rate(BasicRate)) 188 if (!rtllib_is_cck_rate(BasicRate)) {
190 { 189 if (QueryRate == 0) {
191 if (QueryRate == 0)
192 {
193 QueryRate = BasicRate; 190 QueryRate = BasicRate;
194 } 191 } else {
195 else
196 {
197 if (BasicRate < QueryRate) 192 if (BasicRate < QueryRate)
198 {
199 QueryRate = BasicRate; 193 QueryRate = BasicRate;
200 }
201 } 194 }
202 } 195 }
203 } 196 }
204 197
205 if (QueryRate == 0) 198 if (QueryRate == 0) {
206 {
207 QueryRate = 12; 199 QueryRate = 12;
208 printk("No BasicRate found!!\n"); 200 printk(KERN_INFO "No BasicRate found!!\n");
209 } 201 }
210 return QueryRate; 202 return QueryRate;
211} 203}
@@ -220,10 +212,10 @@ u8 MgntQuery_MgntFrameTxRate(struct rtllib_device *ieee)
220 else 212 else
221 rate = ieee->basic_rate & 0x7f; 213 rate = ieee->basic_rate & 0x7f;
222 214
223 if (rate == 0){ 215 if (rate == 0) {
224 if (ieee->mode == IEEE_A|| 216 if (ieee->mode == IEEE_A ||
225 ieee->mode== IEEE_N_5G|| 217 ieee->mode == IEEE_N_5G ||
226 (ieee->mode== IEEE_N_24G&&!pHTInfo->bCurSuppCCK)) 218 (ieee->mode == IEEE_N_24G && !pHTInfo->bCurSuppCCK))
227 rate = 0x0c; 219 rate = 0x0c;
228 else 220 else
229 rate = 0x02; 221 rate = 0x02;
@@ -232,21 +224,18 @@ u8 MgntQuery_MgntFrameTxRate(struct rtllib_device *ieee)
232 return rate; 224 return rate;
233} 225}
234 226
235
236void rtllib_sta_wakeup(struct rtllib_device *ieee, short nl);
237
238inline void softmac_mgmt_xmit(struct sk_buff *skb, struct rtllib_device *ieee) 227inline void softmac_mgmt_xmit(struct sk_buff *skb, struct rtllib_device *ieee)
239{ 228{
240 unsigned long flags; 229 unsigned long flags;
241 short single = ieee->softmac_features & IEEE_SOFTMAC_SINGLE_QUEUE; 230 short single = ieee->softmac_features & IEEE_SOFTMAC_SINGLE_QUEUE;
242 struct rtllib_hdr_3addr *header= 231 struct rtllib_hdr_3addr *header =
243 (struct rtllib_hdr_3addr *) skb->data; 232 (struct rtllib_hdr_3addr *) skb->data;
244 233
245 struct cb_desc *tcb_desc = (struct cb_desc *)(skb->cb + 8); 234 struct cb_desc *tcb_desc = (struct cb_desc *)(skb->cb + 8);
246 spin_lock_irqsave(&ieee->lock, flags); 235 spin_lock_irqsave(&ieee->lock, flags);
247 236
248 /* called with 2nd param 0, no mgmt lock required */ 237 /* called with 2nd param 0, no mgmt lock required */
249 rtllib_sta_wakeup(ieee,0); 238 rtllib_sta_wakeup(ieee, 0);
250 239
251 if (header->frame_ctl == RTLLIB_STYPE_BEACON) 240 if (header->frame_ctl == RTLLIB_STYPE_BEACON)
252 tcb_desc->queue_index = BEACON_QUEUE; 241 tcb_desc->queue_index = BEACON_QUEUE;
@@ -261,9 +250,9 @@ inline void softmac_mgmt_xmit(struct sk_buff *skb, struct rtllib_device *ieee)
261 tcb_desc->bTxDisableRateFallBack = 1; 250 tcb_desc->bTxDisableRateFallBack = 1;
262 tcb_desc->bTxUseDriverAssingedRate = 1; 251 tcb_desc->bTxUseDriverAssingedRate = 1;
263 if (single) { 252 if (single) {
264 if (ieee->queue_stop){ 253 if (ieee->queue_stop) {
265 enqueue_mgmt(ieee,skb); 254 enqueue_mgmt(ieee, skb);
266 }else{ 255 } else {
267 header->seq_ctl = cpu_to_le16(ieee->seq_ctrl[0]<<4); 256 header->seq_ctl = cpu_to_le16(ieee->seq_ctrl[0]<<4);
268 257
269 if (ieee->seq_ctrl[0] == 0xFFF) 258 if (ieee->seq_ctrl[0] == 0xFFF)
@@ -272,11 +261,12 @@ inline void softmac_mgmt_xmit(struct sk_buff *skb, struct rtllib_device *ieee)
272 ieee->seq_ctrl[0]++; 261 ieee->seq_ctrl[0]++;
273 262
274 /* avoid watchdog triggers */ 263 /* avoid watchdog triggers */
275 ieee->softmac_data_hard_start_xmit(skb,ieee->dev,ieee->basic_rate); 264 ieee->softmac_data_hard_start_xmit(skb, ieee->dev,
265 ieee->basic_rate);
276 } 266 }
277 267
278 spin_unlock_irqrestore(&ieee->lock, flags); 268 spin_unlock_irqrestore(&ieee->lock, flags);
279 }else{ 269 } else {
280 spin_unlock_irqrestore(&ieee->lock, flags); 270 spin_unlock_irqrestore(&ieee->lock, flags);
281 spin_lock_irqsave(&ieee->mgmt_tx_lock, flags); 271 spin_lock_irqsave(&ieee->mgmt_tx_lock, flags);
282 272
@@ -288,17 +278,19 @@ inline void softmac_mgmt_xmit(struct sk_buff *skb, struct rtllib_device *ieee)
288 ieee->seq_ctrl[0]++; 278 ieee->seq_ctrl[0]++;
289 279
290 /* check wether the managed packet queued greater than 5 */ 280 /* check wether the managed packet queued greater than 5 */
291 if (!ieee->check_nic_enough_desc(ieee->dev,tcb_desc->queue_index)||\ 281 if (!ieee->check_nic_enough_desc(ieee->dev, tcb_desc->queue_index) ||
292 (skb_queue_len(&ieee->skb_waitQ[tcb_desc->queue_index]) != 0)||\ 282 (skb_queue_len(&ieee->skb_waitQ[tcb_desc->queue_index]) != 0) ||
293 (ieee->queue_stop) ) { 283 (ieee->queue_stop)) {
294 /* insert the skb packet to the management queue */ 284 /* insert the skb packet to the management queue */
295 /* as for the completion function, it does not need 285 /* as for the completion function, it does not need
296 * to check it any more. 286 * to check it any more.
297 * */ 287 * */
298 printk("%s():insert to waitqueue, queue_index:%d!\n",__func__,tcb_desc->queue_index); 288 printk(KERN_INFO "%s():insert to waitqueue, queue_index"
299 skb_queue_tail(&ieee->skb_waitQ[tcb_desc->queue_index], skb); 289 ":%d!\n", __func__, tcb_desc->queue_index);
290 skb_queue_tail(&ieee->skb_waitQ[tcb_desc->queue_index],
291 skb);
300 } else { 292 } else {
301 ieee->softmac_hard_start_xmit(skb,ieee->dev); 293 ieee->softmac_hard_start_xmit(skb, ieee->dev);
302 } 294 }
303 spin_unlock_irqrestore(&ieee->mgmt_tx_lock, flags); 295 spin_unlock_irqrestore(&ieee->mgmt_tx_lock, flags);
304 } 296 }
@@ -310,7 +302,7 @@ inline void softmac_ps_mgmt_xmit(struct sk_buff *skb,
310 short single = ieee->softmac_features & IEEE_SOFTMAC_SINGLE_QUEUE; 302 short single = ieee->softmac_features & IEEE_SOFTMAC_SINGLE_QUEUE;
311 struct rtllib_hdr_3addr *header = 303 struct rtllib_hdr_3addr *header =
312 (struct rtllib_hdr_3addr *) skb->data; 304 (struct rtllib_hdr_3addr *) skb->data;
313 u16 fc,type,stype; 305 u16 fc, type, stype;
314 struct cb_desc *tcb_desc = (struct cb_desc *)(skb->cb + 8); 306 struct cb_desc *tcb_desc = (struct cb_desc *)(skb->cb + 8);
315 307
316 fc = header->frame_ctl; 308 fc = header->frame_ctl;
@@ -342,7 +334,8 @@ inline void softmac_ps_mgmt_xmit(struct sk_buff *skb,
342 334
343 } 335 }
344 /* avoid watchdog triggers */ 336 /* avoid watchdog triggers */
345 ieee->softmac_data_hard_start_xmit(skb,ieee->dev,ieee->basic_rate); 337 ieee->softmac_data_hard_start_xmit(skb, ieee->dev,
338 ieee->basic_rate);
346 339
347 } else { 340 } else {
348 if (type != RTLLIB_FTYPE_CTL) { 341 if (type != RTLLIB_FTYPE_CTL) {
@@ -353,14 +346,14 @@ inline void softmac_ps_mgmt_xmit(struct sk_buff *skb,
353 else 346 else
354 ieee->seq_ctrl[0]++; 347 ieee->seq_ctrl[0]++;
355 } 348 }
356 ieee->softmac_hard_start_xmit(skb,ieee->dev); 349 ieee->softmac_hard_start_xmit(skb, ieee->dev);
357 350
358 } 351 }
359} 352}
360 353
361inline struct sk_buff *rtllib_probe_req(struct rtllib_device *ieee) 354inline struct sk_buff *rtllib_probe_req(struct rtllib_device *ieee)
362{ 355{
363 unsigned int len,rate_len; 356 unsigned int len, rate_len;
364 u8 *tag; 357 u8 *tag;
365 struct sk_buff *skb; 358 struct sk_buff *skb;
366 struct rtllib_probe_request *req; 359 struct rtllib_probe_request *req;
@@ -377,7 +370,8 @@ inline struct sk_buff *rtllib_probe_req(struct rtllib_device *ieee)
377 370
378 skb_reserve(skb, ieee->tx_headroom); 371 skb_reserve(skb, ieee->tx_headroom);
379 372
380 req = (struct rtllib_probe_request *) skb_put(skb,sizeof(struct rtllib_probe_request)); 373 req = (struct rtllib_probe_request *) skb_put(skb,
374 sizeof(struct rtllib_probe_request));
381 req->header.frame_ctl = cpu_to_le16(RTLLIB_STYPE_PROBE_REQ); 375 req->header.frame_ctl = cpu_to_le16(RTLLIB_STYPE_PROBE_REQ);
382 req->header.duration_id = 0; 376 req->header.duration_id = 0;
383 377
@@ -385,15 +379,15 @@ inline struct sk_buff *rtllib_probe_req(struct rtllib_device *ieee)
385 memcpy(req->header.addr2, ieee->dev->dev_addr, ETH_ALEN); 379 memcpy(req->header.addr2, ieee->dev->dev_addr, ETH_ALEN);
386 memset(req->header.addr3, 0xff, ETH_ALEN); 380 memset(req->header.addr3, 0xff, ETH_ALEN);
387 381
388 tag = (u8 *) skb_put(skb,len+2+rate_len); 382 tag = (u8 *) skb_put(skb, len + 2 + rate_len);
389 383
390 *tag++ = MFIE_TYPE_SSID; 384 *tag++ = MFIE_TYPE_SSID;
391 *tag++ = len; 385 *tag++ = len;
392 memcpy(tag, ieee->current_network.ssid, len); 386 memcpy(tag, ieee->current_network.ssid, len);
393 tag += len; 387 tag += len;
394 388
395 rtllib_MFIE_Brate(ieee,&tag); 389 rtllib_MFIE_Brate(ieee, &tag);
396 rtllib_MFIE_Grate(ieee,&tag); 390 rtllib_MFIE_Grate(ieee, &tag);
397 391
398 return skb; 392 return skb;
399} 393}
@@ -407,14 +401,14 @@ void rtllib_send_beacon(struct rtllib_device *ieee)
407 return; 401 return;
408 skb = rtllib_get_beacon_(ieee); 402 skb = rtllib_get_beacon_(ieee);
409 403
410 if (skb){ 404 if (skb) {
411 softmac_mgmt_xmit(skb, ieee); 405 softmac_mgmt_xmit(skb, ieee);
412 ieee->softmac_stats.tx_beacons++; 406 ieee->softmac_stats.tx_beacons++;
413 } 407 }
414 408
415 if (ieee->beacon_txing && ieee->ieee_up){ 409 if (ieee->beacon_txing && ieee->ieee_up)
416 mod_timer(&ieee->beacon_timer,jiffies+(MSECS(ieee->current_network.beacon_interval-5))); 410 mod_timer(&ieee->beacon_timer, jiffies +
417 } 411 (MSECS(ieee->current_network.beacon_interval - 5)));
418} 412}
419 413
420 414
@@ -431,83 +425,86 @@ void rtllib_send_beacon_cb(unsigned long _ieee)
431 425
432/* 426/*
433 * Description: 427 * Description:
434 * Enable network monitor mode, all rx packets will be received. 428 * Enable network monitor mode, all rx packets will be received.
435 */ 429 */
436void rtllib_EnableNetMonitorMode(struct net_device* dev, 430void rtllib_EnableNetMonitorMode(struct net_device *dev,
437 bool bInitState) 431 bool bInitState)
438{ 432{
439 struct rtllib_device* ieee = netdev_priv_rsl(dev); 433 struct rtllib_device *ieee = netdev_priv_rsl(dev);
440 434
441 printk("========>Enter Monitor Mode\n"); 435 printk(KERN_INFO "========>Enter Monitor Mode\n");
442 436
443 ieee->AllowAllDestAddrHandler(dev, true, !bInitState); 437 ieee->AllowAllDestAddrHandler(dev, true, !bInitState);
444} 438}
445 439
446 440
447/* 441/*
448 * Description: 442 * Description:
449 * Disable network network monitor mode, only packets destinated to 443 * Disable network network monitor mode, only packets destinated to
450 * us will be received. 444 * us will be received.
451 */ 445 */
452void rtllib_DisableNetMonitorMode(struct net_device* dev, 446void rtllib_DisableNetMonitorMode(struct net_device *dev,
453 bool bInitState) 447 bool bInitState)
454{ 448{
455 struct rtllib_device* ieee = netdev_priv_rsl(dev); 449 struct rtllib_device *ieee = netdev_priv_rsl(dev);
456 450
457 printk("========>Exit Monitor Mode\n"); 451 printk(KERN_INFO "========>Exit Monitor Mode\n");
458 452
459 ieee->AllowAllDestAddrHandler(dev, false, !bInitState); 453 ieee->AllowAllDestAddrHandler(dev, false, !bInitState);
460} 454}
461 455
462 456
463/* 457/*
464 * Description: 458 * Description:
465 * This enables the specialized promiscuous mode required by Intel. 459 * This enables the specialized promiscuous mode required by Intel.
466 * In this mode, Intel intends to hear traffics from/to other STAs in the same BSS. 460 * In this mode, Intel intends to hear traffics from/to other STAs in the
467 * Therefore we don't have to disable checking BSSID and we only need to allow all dest. 461 * same BSS. Therefore we don't have to disable checking BSSID and we only need
468 * BUT: if we enable checking BSSID then we can't recv packets from other STA. 462 * to allow all dest. BUT: if we enable checking BSSID then we can't recv
463 * packets from other STA.
469 */ 464 */
470void rtllib_EnableIntelPromiscuousMode(struct net_device* dev, 465void rtllib_EnableIntelPromiscuousMode(struct net_device *dev,
471 bool bInitState) 466 bool bInitState)
472{ 467{
473 bool bFilterOutNonAssociatedBSSID = false; 468 bool bFilterOutNonAssociatedBSSID = false;
474 469
475 struct rtllib_device* ieee = netdev_priv_rsl(dev); 470 struct rtllib_device *ieee = netdev_priv_rsl(dev);
476 471
477 printk("========>Enter Intel Promiscuous Mode\n"); 472 printk(KERN_INFO "========>Enter Intel Promiscuous Mode\n");
478 473
479 ieee->AllowAllDestAddrHandler(dev, true, !bInitState); 474 ieee->AllowAllDestAddrHandler(dev, true, !bInitState);
480 ieee->SetHwRegHandler(dev, HW_VAR_CECHK_BSSID, (u8*)&bFilterOutNonAssociatedBSSID); 475 ieee->SetHwRegHandler(dev, HW_VAR_CECHK_BSSID,
476 (u8 *)&bFilterOutNonAssociatedBSSID);
481 477
482 ieee->bNetPromiscuousMode = true; 478 ieee->bNetPromiscuousMode = true;
483} 479}
484 480
485 481
486/* 482/*
487 * Description: 483 * Description:
488 * This disables the specialized promiscuous mode required by Intel. 484 * This disables the specialized promiscuous mode required by Intel.
489 * See MgntEnableIntelPromiscuousMode for detail. 485 * See MgntEnableIntelPromiscuousMode for detail.
490 */ 486 */
491void rtllib_DisableIntelPromiscuousMode(struct net_device* dev, 487void rtllib_DisableIntelPromiscuousMode(struct net_device *dev,
492 bool bInitState) 488 bool bInitState)
493{ 489{
494 bool bFilterOutNonAssociatedBSSID = true; 490 bool bFilterOutNonAssociatedBSSID = true;
495 491
496 struct rtllib_device* ieee = netdev_priv_rsl(dev); 492 struct rtllib_device *ieee = netdev_priv_rsl(dev);
497 493
498 printk("========>Exit Intel Promiscuous Mode\n"); 494 printk(KERN_INFO "========>Exit Intel Promiscuous Mode\n");
499 495
500 ieee->AllowAllDestAddrHandler(dev, false, !bInitState); 496 ieee->AllowAllDestAddrHandler(dev, false, !bInitState);
501 ieee->SetHwRegHandler(dev, HW_VAR_CECHK_BSSID, (u8*)&bFilterOutNonAssociatedBSSID); 497 ieee->SetHwRegHandler(dev, HW_VAR_CECHK_BSSID,
498 (u8 *)&bFilterOutNonAssociatedBSSID);
502 499
503 ieee->bNetPromiscuousMode = false; 500 ieee->bNetPromiscuousMode = false;
504} 501}
505 502
506void rtllib_send_probe(struct rtllib_device *ieee, u8 is_mesh) 503void rtllib_send_probe(struct rtllib_device *ieee, u8 is_mesh)
507{ 504{
508 struct sk_buff *skb; 505 struct sk_buff *skb;
509 skb = rtllib_probe_req(ieee); 506 skb = rtllib_probe_req(ieee);
510 if (skb){ 507 if (skb) {
511 softmac_mgmt_xmit(skb, ieee); 508 softmac_mgmt_xmit(skb, ieee);
512 ieee->softmac_stats.tx_probe_rq++; 509 ieee->softmac_stats.tx_probe_rq++;
513 } 510 }
@@ -529,7 +526,8 @@ void rtllib_softmac_hint11d_wq(void *data)
529 526
530void rtllib_update_active_chan_map(struct rtllib_device *ieee) 527void rtllib_update_active_chan_map(struct rtllib_device *ieee)
531{ 528{
532 memcpy(ieee->active_channel_map, GET_DOT11D_INFO(ieee)->channel_map, MAX_CHANNEL_NUMBER+1); 529 memcpy(ieee->active_channel_map, GET_DOT11D_INFO(ieee)->channel_map,
530 MAX_CHANNEL_NUMBER+1);
533} 531}
534 532
535/* this performs syncro scan blocking the caller until all channels 533/* this performs syncro scan blocking the caller until all channels
@@ -537,6 +535,7 @@ void rtllib_update_active_chan_map(struct rtllib_device *ieee)
537 */ 535 */
538void rtllib_softmac_scan_syncro(struct rtllib_device *ieee, u8 is_mesh) 536void rtllib_softmac_scan_syncro(struct rtllib_device *ieee, u8 is_mesh)
539{ 537{
538 union iwreq_data wrqu;
540 short ch = 0; 539 short ch = 0;
541 540
542 rtllib_update_active_chan_map(ieee); 541 rtllib_update_active_chan_map(ieee);
@@ -545,14 +544,12 @@ void rtllib_softmac_scan_syncro(struct rtllib_device *ieee, u8 is_mesh)
545 544
546 down(&ieee->scan_sem); 545 down(&ieee->scan_sem);
547 546
548 while(1) 547 while (1) {
549 {
550
551 do { 548 do {
552 ch++; 549 ch++;
553 if (ch > MAX_CHANNEL_NUMBER) 550 if (ch > MAX_CHANNEL_NUMBER)
554 goto out; /* scan completed */ 551 goto out; /* scan completed */
555 } while(!ieee->active_channel_map[ch]); 552 } while (!ieee->active_channel_map[ch]);
556 553
557 /* this fuction can be called in two situations 554 /* this fuction can be called in two situations
558 * 1- We have switched to ad-hoc mode and we are 555 * 1- We have switched to ad-hoc mode and we are
@@ -575,14 +572,14 @@ void rtllib_softmac_scan_syncro(struct rtllib_device *ieee, u8 is_mesh)
575 572
576 if (ieee->state == RTLLIB_LINKED) 573 if (ieee->state == RTLLIB_LINKED)
577 goto out; 574 goto out;
578 if (ieee->sync_scan_hurryup){ 575 if (ieee->sync_scan_hurryup) {
579 printk("============>sync_scan_hurryup out\n"); 576 printk(KERN_INFO "============>sync_scan_hurryup out\n");
580 goto out; 577 goto out;
581 } 578 }
582 579
583 ieee->set_chan(ieee->dev, ch); 580 ieee->set_chan(ieee->dev, ch);
584 if (ieee->active_channel_map[ch] == 1) 581 if (ieee->active_channel_map[ch] == 1)
585 rtllib_send_probe_requests(ieee, 0); 582 rtllib_send_probe_requests(ieee, 0);
586 583
587 /* this prevent excessive time wait when we 584 /* this prevent excessive time wait when we
588 * need to wait for a syncro scan to end.. 585 * need to wait for a syncro scan to end..
@@ -593,7 +590,7 @@ out:
593 ieee->actscanning = false; 590 ieee->actscanning = false;
594 ieee->sync_scan_hurryup = 0; 591 ieee->sync_scan_hurryup = 0;
595 592
596 if (ieee->state >= RTLLIB_LINKED){ 593 if (ieee->state >= RTLLIB_LINKED) {
597 if (IS_DOT11D_ENABLE(ieee)) 594 if (IS_DOT11D_ENABLE(ieee))
598 DOT11D_ScanComplete(ieee); 595 DOT11D_ScanComplete(ieee);
599 } 596 }
@@ -601,53 +598,52 @@ out:
601 598
602 ieee->be_scan_inprogress = false; 599 ieee->be_scan_inprogress = false;
603 600
604 {
605 union iwreq_data wrqu;
606 memset(&wrqu, 0, sizeof(wrqu)); 601 memset(&wrqu, 0, sizeof(wrqu));
607 wireless_send_event(ieee->dev,SIOCGIWSCAN,&wrqu,NULL); 602 wireless_send_event(ieee->dev, SIOCGIWSCAN, &wrqu, NULL);
608 }
609} 603}
610 604
611void rtllib_softmac_scan_wq(void *data) 605void rtllib_softmac_scan_wq(void *data)
612{ 606{
613 struct rtllib_device *ieee = container_of_dwork_rsl(data, struct rtllib_device, softmac_scan_wq); 607 struct rtllib_device *ieee = container_of_dwork_rsl(data,
608 struct rtllib_device, softmac_scan_wq);
614 u8 last_channel = ieee->current_network.channel; 609 u8 last_channel = ieee->current_network.channel;
615 610
616 rtllib_update_active_chan_map(ieee); 611 rtllib_update_active_chan_map(ieee);
617 612
618 if (!ieee->ieee_up) 613 if (!ieee->ieee_up)
619 return; 614 return;
620 if (rtllib_act_scanning(ieee,true) == true) 615 if (rtllib_act_scanning(ieee, true) == true)
621 return; 616 return;
622 617
623 down(&ieee->scan_sem); 618 down(&ieee->scan_sem);
624 619
625 if (ieee->eRFPowerState == eRfOff) 620 if (ieee->eRFPowerState == eRfOff) {
626 { 621 printk(KERN_INFO "======>%s():rf state is eRfOff, return\n",
627 printk("======>%s():rf state is eRfOff, return\n",__func__); 622 __func__);
628 goto out1; 623 goto out1;
629 } 624 }
630 625
631 do{ 626 do {
632 ieee->current_network.channel = 627 ieee->current_network.channel =
633 (ieee->current_network.channel + 1) % MAX_CHANNEL_NUMBER; 628 (ieee->current_network.channel + 1) %
634 if (ieee->scan_watch_dog++ > MAX_CHANNEL_NUMBER) 629 MAX_CHANNEL_NUMBER;
635 { 630 if (ieee->scan_watch_dog++ > MAX_CHANNEL_NUMBER) {
636 if (!ieee->active_channel_map[ieee->current_network.channel]) 631 if (!ieee->active_channel_map[ieee->current_network.channel])
637 ieee->current_network.channel = 6; 632 ieee->current_network.channel = 6;
638 goto out; /* no good chans */ 633 goto out; /* no good chans */
639 } 634 }
640 } while(!ieee->active_channel_map[ieee->current_network.channel]); 635 } while (!ieee->active_channel_map[ieee->current_network.channel]);
641 636
642 if (ieee->scanning_continue == 0 ) 637 if (ieee->scanning_continue == 0)
643 goto out; 638 goto out;
644 639
645 ieee->set_chan(ieee->dev, ieee->current_network.channel); 640 ieee->set_chan(ieee->dev, ieee->current_network.channel);
646 641
647 if (ieee->active_channel_map[ieee->current_network.channel] == 1) 642 if (ieee->active_channel_map[ieee->current_network.channel] == 1)
648 rtllib_send_probe_requests(ieee, 0); 643 rtllib_send_probe_requests(ieee, 0);
649 644
650 queue_delayed_work_rsl(ieee->wq, &ieee->softmac_scan_wq, MSECS(RTLLIB_SOFTMAC_SCAN_TIME)); 645 queue_delayed_work_rsl(ieee->wq, &ieee->softmac_scan_wq,
646 MSECS(RTLLIB_SOFTMAC_SCAN_TIME));
651 647
652 up(&ieee->scan_sem); 648 up(&ieee->scan_sem);
653 return; 649 return;
@@ -669,24 +665,24 @@ out1:
669void rtllib_beacons_start(struct rtllib_device *ieee) 665void rtllib_beacons_start(struct rtllib_device *ieee)
670{ 666{
671 unsigned long flags; 667 unsigned long flags;
672 spin_lock_irqsave(&ieee->beacon_lock,flags); 668 spin_lock_irqsave(&ieee->beacon_lock, flags);
673 669
674 ieee->beacon_txing = 1; 670 ieee->beacon_txing = 1;
675 rtllib_send_beacon(ieee); 671 rtllib_send_beacon(ieee);
676 672
677 spin_unlock_irqrestore(&ieee->beacon_lock,flags); 673 spin_unlock_irqrestore(&ieee->beacon_lock, flags);
678} 674}
679 675
680void rtllib_beacons_stop(struct rtllib_device *ieee) 676void rtllib_beacons_stop(struct rtllib_device *ieee)
681{ 677{
682 unsigned long flags; 678 unsigned long flags;
683 679
684 spin_lock_irqsave(&ieee->beacon_lock,flags); 680 spin_lock_irqsave(&ieee->beacon_lock, flags);
685 681
686 ieee->beacon_txing = 0; 682 ieee->beacon_txing = 0;
687 del_timer_sync(&ieee->beacon_timer); 683 del_timer_sync(&ieee->beacon_timer);
688 684
689 spin_unlock_irqrestore(&ieee->beacon_lock,flags); 685 spin_unlock_irqrestore(&ieee->beacon_lock, flags);
690 686
691} 687}
692 688
@@ -725,9 +721,9 @@ void rtllib_softmac_stop_scan(struct rtllib_device *ieee)
725 721
726void rtllib_stop_scan(struct rtllib_device *ieee) 722void rtllib_stop_scan(struct rtllib_device *ieee)
727{ 723{
728 if (ieee->softmac_features & IEEE_SOFTMAC_SCAN){ 724 if (ieee->softmac_features & IEEE_SOFTMAC_SCAN) {
729 rtllib_softmac_stop_scan(ieee); 725 rtllib_softmac_stop_scan(ieee);
730 }else{ 726 } else {
731 if (ieee->rtllib_stop_hw_scan) 727 if (ieee->rtllib_stop_hw_scan)
732 ieee->rtllib_stop_hw_scan(ieee->dev); 728 ieee->rtllib_stop_hw_scan(ieee->dev);
733 } 729 }
@@ -735,9 +731,9 @@ void rtllib_stop_scan(struct rtllib_device *ieee)
735 731
736void rtllib_stop_scan_syncro(struct rtllib_device *ieee) 732void rtllib_stop_scan_syncro(struct rtllib_device *ieee)
737{ 733{
738 if (ieee->softmac_features & IEEE_SOFTMAC_SCAN){ 734 if (ieee->softmac_features & IEEE_SOFTMAC_SCAN) {
739 ieee->sync_scan_hurryup = 1; 735 ieee->sync_scan_hurryup = 1;
740 }else{ 736 } else {
741 if (ieee->rtllib_stop_hw_scan) 737 if (ieee->rtllib_stop_hw_scan)
742 ieee->rtllib_stop_hw_scan(ieee->dev); 738 ieee->rtllib_stop_hw_scan(ieee->dev);
743 } 739 }
@@ -745,13 +741,12 @@ void rtllib_stop_scan_syncro(struct rtllib_device *ieee)
745 741
746bool rtllib_act_scanning(struct rtllib_device *ieee, bool sync_scan) 742bool rtllib_act_scanning(struct rtllib_device *ieee, bool sync_scan)
747{ 743{
748 if (ieee->softmac_features & IEEE_SOFTMAC_SCAN){ 744 if (ieee->softmac_features & IEEE_SOFTMAC_SCAN) {
749 if (sync_scan){ 745 if (sync_scan)
750 return ieee->be_scan_inprogress; 746 return ieee->be_scan_inprogress;
751 }else{ 747 else
752 return (ieee->actscanning ||ieee->be_scan_inprogress); 748 return ieee->actscanning || ieee->be_scan_inprogress;
753 } 749 } else {
754 }else{
755 return test_bit(STATUS_SCANNING, &ieee->status); 750 return test_bit(STATUS_SCANNING, &ieee->status);
756 } 751 }
757} 752}
@@ -759,61 +754,55 @@ bool rtllib_act_scanning(struct rtllib_device *ieee, bool sync_scan)
759/* called with ieee->lock held */ 754/* called with ieee->lock held */
760void rtllib_start_scan(struct rtllib_device *ieee) 755void rtllib_start_scan(struct rtllib_device *ieee)
761{ 756{
762 RT_TRACE(COMP_DBG, "===>%s()\n",__func__); 757 RT_TRACE(COMP_DBG, "===>%s()\n", __func__);
763 if (ieee->rtllib_ips_leave_wq != NULL) 758 if (ieee->rtllib_ips_leave_wq != NULL)
764 ieee->rtllib_ips_leave_wq(ieee->dev); 759 ieee->rtllib_ips_leave_wq(ieee->dev);
765 760
766 761 if (IS_DOT11D_ENABLE(ieee)) {
767 if (IS_DOT11D_ENABLE(ieee) )
768 {
769 if (IS_COUNTRY_IE_VALID(ieee)) 762 if (IS_COUNTRY_IE_VALID(ieee))
770 {
771 RESET_CIE_WATCHDOG(ieee); 763 RESET_CIE_WATCHDOG(ieee);
772 }
773 } 764 }
774 if (ieee->softmac_features & IEEE_SOFTMAC_SCAN) { 765 if (ieee->softmac_features & IEEE_SOFTMAC_SCAN) {
775 if (ieee->scanning_continue == 0) { 766 if (ieee->scanning_continue == 0) {
776 ieee->actscanning = true; 767 ieee->actscanning = true;
777 ieee->scanning_continue = 1; 768 ieee->scanning_continue = 1;
778 queue_delayed_work_rsl(ieee->wq, &ieee->softmac_scan_wq, 0); 769 queue_delayed_work_rsl(ieee->wq,
770 &ieee->softmac_scan_wq, 0);
779 } 771 }
780 } else { 772 } else {
781 if (ieee->rtllib_start_hw_scan) 773 if (ieee->rtllib_start_hw_scan)
782 ieee->rtllib_start_hw_scan(ieee->dev); 774 ieee->rtllib_start_hw_scan(ieee->dev);
783 } 775 }
784
785} 776}
786 777
787/* called with wx_sem held */ 778/* called with wx_sem held */
788void rtllib_start_scan_syncro(struct rtllib_device *ieee, u8 is_mesh) 779void rtllib_start_scan_syncro(struct rtllib_device *ieee, u8 is_mesh)
789{ 780{
790 if (IS_DOT11D_ENABLE(ieee) ) 781 if (IS_DOT11D_ENABLE(ieee)) {
791 {
792 if (IS_COUNTRY_IE_VALID(ieee)) 782 if (IS_COUNTRY_IE_VALID(ieee))
793 {
794 RESET_CIE_WATCHDOG(ieee); 783 RESET_CIE_WATCHDOG(ieee);
795 }
796 } 784 }
797 ieee->sync_scan_hurryup = 0; 785 ieee->sync_scan_hurryup = 0;
798 if (ieee->softmac_features & IEEE_SOFTMAC_SCAN){ 786 if (ieee->softmac_features & IEEE_SOFTMAC_SCAN) {
799 rtllib_softmac_scan_syncro(ieee, is_mesh); 787 rtllib_softmac_scan_syncro(ieee, is_mesh);
800 }else{ 788 } else {
801 if (ieee->rtllib_start_hw_scan) 789 if (ieee->rtllib_start_hw_scan)
802 ieee->rtllib_start_hw_scan(ieee->dev); 790 ieee->rtllib_start_hw_scan(ieee->dev);
803 } 791 }
804
805} 792}
806 793
807inline struct sk_buff *rtllib_authentication_req(struct rtllib_network *beacon, 794inline struct sk_buff *rtllib_authentication_req(struct rtllib_network *beacon,
808 struct rtllib_device *ieee, int challengelen,u8 * daddr) 795 struct rtllib_device *ieee, int challengelen, u8 *daddr)
809{ 796{
810 struct sk_buff *skb; 797 struct sk_buff *skb;
811 struct rtllib_authentication *auth; 798 struct rtllib_authentication *auth;
812 int len = 0; 799 int len = 0;
813 len = sizeof(struct rtllib_authentication) + challengelen + ieee->tx_headroom + 4; 800 len = sizeof(struct rtllib_authentication) + challengelen +
801 ieee->tx_headroom + 4;
814 skb = dev_alloc_skb(len); 802 skb = dev_alloc_skb(len);
815 803
816 if (!skb) return NULL; 804 if (!skb)
805 return NULL;
817 806
818 skb_reserve(skb, ieee->tx_headroom); 807 skb_reserve(skb, ieee->tx_headroom);
819 808
@@ -821,10 +810,11 @@ inline struct sk_buff *rtllib_authentication_req(struct rtllib_network *beacon,
821 skb_put(skb, sizeof(struct rtllib_authentication)); 810 skb_put(skb, sizeof(struct rtllib_authentication));
822 811
823 auth->header.frame_ctl = RTLLIB_STYPE_AUTH; 812 auth->header.frame_ctl = RTLLIB_STYPE_AUTH;
824 if (challengelen) auth->header.frame_ctl |= RTLLIB_FCTL_WEP; 813 if (challengelen)
814 auth->header.frame_ctl |= RTLLIB_FCTL_WEP;
825 815
826 auth->header.duration_id = 0x013a; 816 auth->header.duration_id = 0x013a;
827 memcpy(auth->header.addr1, beacon->bssid, ETH_ALEN); 817 memcpy(auth->header.addr1, beacon->bssid, ETH_ALEN);
828 memcpy(auth->header.addr2, ieee->dev->dev_addr, ETH_ALEN); 818 memcpy(auth->header.addr2, ieee->dev->dev_addr, ETH_ALEN);
829 memcpy(auth->header.addr3, beacon->bssid, ETH_ALEN); 819 memcpy(auth->header.addr3, beacon->bssid, ETH_ALEN);
830 if (ieee->auth_mode == 0) 820 if (ieee->auth_mode == 0)
@@ -839,22 +829,18 @@ inline struct sk_buff *rtllib_authentication_req(struct rtllib_network *beacon,
839 auth->status = cpu_to_le16(WLAN_STATUS_SUCCESS); 829 auth->status = cpu_to_le16(WLAN_STATUS_SUCCESS);
840 830
841 return skb; 831 return skb;
842
843} 832}
844 833
845void constructWMMIE(u8* wmmie, u8* wmm_len,u8 oui_subtype) 834void constructWMMIE(u8 *wmmie, u8 *wmm_len, u8 oui_subtype)
846{ 835{
847 u8 szQoSOUI[] ={221, 0, 0x00, 0x50, 0xf2, 0x02, 0, 1}; 836 u8 szQoSOUI[] = {221, 0, 0x00, 0x50, 0xf2, 0x02, 0, 1};
848 837
849 if (oui_subtype == OUI_SUBTYPE_QOS_CAPABI) 838 if (oui_subtype == OUI_SUBTYPE_QOS_CAPABI) {
850 {
851 szQoSOUI[0] = 46; 839 szQoSOUI[0] = 46;
852 szQoSOUI[1] = *wmm_len; 840 szQoSOUI[1] = *wmm_len;
853 memcpy(wmmie,szQoSOUI,3); 841 memcpy(wmmie, szQoSOUI, 3);
854 *wmm_len = 3; 842 *wmm_len = 3;
855 } 843 } else {
856 else
857 {
858 szQoSOUI[1] = *wmm_len + 6; 844 szQoSOUI[1] = *wmm_len + 6;
859 szQoSOUI[6] = oui_subtype; 845 szQoSOUI[6] = oui_subtype;
860 memcpy(wmmie, szQoSOUI, 8); 846 memcpy(wmmie, szQoSOUI, 8);
@@ -863,15 +849,15 @@ void constructWMMIE(u8* wmmie, u8* wmm_len,u8 oui_subtype)
863 } 849 }
864} 850}
865 851
866static struct sk_buff* rtllib_probe_resp(struct rtllib_device *ieee, u8 *dest) 852static struct sk_buff *rtllib_probe_resp(struct rtllib_device *ieee, u8 *dest)
867{ 853{
868 u8 *tag; 854 u8 *tag;
869 int beacon_size; 855 int beacon_size;
870 struct rtllib_probe_response *beacon_buf; 856 struct rtllib_probe_response *beacon_buf;
871 struct sk_buff *skb = NULL; 857 struct sk_buff *skb = NULL;
872 int encrypt; 858 int encrypt;
873 int atim_len,erp_len; 859 int atim_len, erp_len;
874 struct rtllib_crypt_data* crypt; 860 struct rtllib_crypt_data *crypt;
875 861
876 char *ssid = ieee->current_network.ssid; 862 char *ssid = ieee->current_network.ssid;
877 int ssid_len = ieee->current_network.ssid_len; 863 int ssid_len = ieee->current_network.ssid_len;
@@ -880,82 +866,83 @@ static struct sk_buff* rtllib_probe_resp(struct rtllib_device *ieee, u8 *dest)
880 int wpa_ie_len = ieee->wpa_ie_len; 866 int wpa_ie_len = ieee->wpa_ie_len;
881 u8 erpinfo_content = 0; 867 u8 erpinfo_content = 0;
882 868
883 u8* tmp_ht_cap_buf = NULL; 869 u8 *tmp_ht_cap_buf = NULL;
884 u8 tmp_ht_cap_len = 0; 870 u8 tmp_ht_cap_len = 0;
885 u8* tmp_ht_info_buf = NULL; 871 u8 *tmp_ht_info_buf = NULL;
886 u8 tmp_ht_info_len = 0; 872 u8 tmp_ht_info_len = 0;
887 struct rt_hi_throughput *pHTInfo = ieee->pHTInfo; 873 struct rt_hi_throughput *pHTInfo = ieee->pHTInfo;
888 u8* tmp_generic_ie_buf = NULL; 874 u8 *tmp_generic_ie_buf = NULL;
889 u8 tmp_generic_ie_len = 0; 875 u8 tmp_generic_ie_len = 0;
890 876
891 if (rate_ex_len > 0) 877 if (rate_ex_len > 0)
892 rate_ex_len+=2; 878 rate_ex_len += 2;
893 879
894 if (ieee->current_network.capability & WLAN_CAPABILITY_IBSS) 880 if (ieee->current_network.capability & WLAN_CAPABILITY_IBSS)
895 atim_len = 4; 881 atim_len = 4;
896 else 882 else
897 atim_len = 0; 883 atim_len = 0;
898 884
899 if ((ieee->current_network.mode == IEEE_G) 885 if ((ieee->current_network.mode == IEEE_G) ||
900 ||( ieee->current_network.mode == IEEE_N_24G && ieee->pHTInfo->bCurSuppCCK)) { 886 (ieee->current_network.mode == IEEE_N_24G &&
887 ieee->pHTInfo->bCurSuppCCK)) {
901 erp_len = 3; 888 erp_len = 3;
902 erpinfo_content = 0; 889 erpinfo_content = 0;
903 if (ieee->current_network.buseprotection) 890 if (ieee->current_network.buseprotection)
904 erpinfo_content |= ERP_UseProtection; 891 erpinfo_content |= ERP_UseProtection;
905 } 892 } else
906 else
907 erp_len = 0; 893 erp_len = 0;
908 894
909 crypt = ieee->crypt[ieee->tx_keyidx]; 895 crypt = ieee->crypt[ieee->tx_keyidx];
910 encrypt = ieee->host_encrypt && crypt && crypt->ops && 896 encrypt = ieee->host_encrypt && crypt && crypt->ops &&
911 ((0 == strcmp(crypt->ops->name, "WEP") || wpa_ie_len)); 897 ((0 == strcmp(crypt->ops->name, "WEP") || wpa_ie_len));
912 if (ieee->pHTInfo->bCurrentHTSupport){ 898 if (ieee->pHTInfo->bCurrentHTSupport) {
913 tmp_ht_cap_buf =(u8*) &(ieee->pHTInfo->SelfHTCap); 899 tmp_ht_cap_buf = (u8 *) &(ieee->pHTInfo->SelfHTCap);
914 tmp_ht_cap_len = sizeof(ieee->pHTInfo->SelfHTCap); 900 tmp_ht_cap_len = sizeof(ieee->pHTInfo->SelfHTCap);
915 tmp_ht_info_buf =(u8*) &(ieee->pHTInfo->SelfHTInfo); 901 tmp_ht_info_buf = (u8 *) &(ieee->pHTInfo->SelfHTInfo);
916 tmp_ht_info_len = sizeof(ieee->pHTInfo->SelfHTInfo); 902 tmp_ht_info_len = sizeof(ieee->pHTInfo->SelfHTInfo);
917 HTConstructCapabilityElement(ieee, tmp_ht_cap_buf, &tmp_ht_cap_len,encrypt, false); 903 HTConstructCapabilityElement(ieee, tmp_ht_cap_buf,
918 HTConstructInfoElement(ieee,tmp_ht_info_buf,&tmp_ht_info_len, encrypt); 904 &tmp_ht_cap_len, encrypt, false);
905 HTConstructInfoElement(ieee, tmp_ht_info_buf, &tmp_ht_info_len,
906 encrypt);
919 907
920 908 if (pHTInfo->bRegRT2RTAggregation) {
921 if (pHTInfo->bRegRT2RTAggregation)
922 {
923 tmp_generic_ie_buf = ieee->pHTInfo->szRT2RTAggBuffer; 909 tmp_generic_ie_buf = ieee->pHTInfo->szRT2RTAggBuffer;
924 tmp_generic_ie_len = sizeof(ieee->pHTInfo->szRT2RTAggBuffer); 910 tmp_generic_ie_len =
925 HTConstructRT2RTAggElement(ieee, tmp_generic_ie_buf, &tmp_generic_ie_len); 911 sizeof(ieee->pHTInfo->szRT2RTAggBuffer);
912 HTConstructRT2RTAggElement(ieee, tmp_generic_ie_buf,
913 &tmp_generic_ie_len);
926 } 914 }
927 } 915 }
928 916
929 beacon_size = sizeof(struct rtllib_probe_response)+2+ 917 beacon_size = sizeof(struct rtllib_probe_response)+2+
930 ssid_len 918 ssid_len + 3 + rate_len + rate_ex_len + atim_len + erp_len
931 +3 919 + wpa_ie_len + ieee->tx_headroom;
932 +rate_len
933 +rate_ex_len
934 +atim_len
935 +erp_len
936 +wpa_ie_len
937 +ieee->tx_headroom;
938 skb = dev_alloc_skb(beacon_size); 920 skb = dev_alloc_skb(beacon_size);
939 if (!skb) 921 if (!skb)
940 return NULL; 922 return NULL;
941 923
942 skb_reserve(skb, ieee->tx_headroom); 924 skb_reserve(skb, ieee->tx_headroom);
943 925
944 beacon_buf = (struct rtllib_probe_response*) skb_put(skb, (beacon_size - ieee->tx_headroom)); 926 beacon_buf = (struct rtllib_probe_response *) skb_put(skb,
945 memcpy (beacon_buf->header.addr1, dest,ETH_ALEN); 927 (beacon_size - ieee->tx_headroom));
946 memcpy (beacon_buf->header.addr2, ieee->dev->dev_addr, ETH_ALEN); 928 memcpy(beacon_buf->header.addr1, dest, ETH_ALEN);
947 memcpy (beacon_buf->header.addr3, ieee->current_network.bssid, ETH_ALEN); 929 memcpy(beacon_buf->header.addr2, ieee->dev->dev_addr, ETH_ALEN);
930 memcpy(beacon_buf->header.addr3, ieee->current_network.bssid, ETH_ALEN);
948 931
949 beacon_buf->header.duration_id = 0; 932 beacon_buf->header.duration_id = 0;
950 beacon_buf->beacon_interval = 933 beacon_buf->beacon_interval =
951 cpu_to_le16(ieee->current_network.beacon_interval); 934 cpu_to_le16(ieee->current_network.beacon_interval);
952 beacon_buf->capability = 935 beacon_buf->capability =
953 cpu_to_le16(ieee->current_network.capability & WLAN_CAPABILITY_IBSS); 936 cpu_to_le16(ieee->current_network.capability &
937 WLAN_CAPABILITY_IBSS);
954 beacon_buf->capability |= 938 beacon_buf->capability |=
955 cpu_to_le16(ieee->current_network.capability & WLAN_CAPABILITY_SHORT_PREAMBLE); 939 cpu_to_le16(ieee->current_network.capability &
940 WLAN_CAPABILITY_SHORT_PREAMBLE);
956 941
957 if (ieee->short_slot && (ieee->current_network.capability & WLAN_CAPABILITY_SHORT_SLOT_TIME)) 942 if (ieee->short_slot && (ieee->current_network.capability &
958 cpu_to_le16((beacon_buf->capability |= WLAN_CAPABILITY_SHORT_SLOT_TIME)); 943 WLAN_CAPABILITY_SHORT_SLOT_TIME))
944 cpu_to_le16((beacon_buf->capability |=
945 WLAN_CAPABILITY_SHORT_SLOT_TIME));
959 946
960 crypt = ieee->crypt[ieee->tx_keyidx]; 947 crypt = ieee->crypt[ieee->tx_keyidx];
961 if (encrypt) 948 if (encrypt)
@@ -966,7 +953,7 @@ static struct sk_buff* rtllib_probe_resp(struct rtllib_device *ieee, u8 *dest)
966 beacon_buf->info_element[0].id = MFIE_TYPE_SSID; 953 beacon_buf->info_element[0].id = MFIE_TYPE_SSID;
967 beacon_buf->info_element[0].len = ssid_len; 954 beacon_buf->info_element[0].len = ssid_len;
968 955
969 tag = (u8*) beacon_buf->info_element[0].data; 956 tag = (u8 *) beacon_buf->info_element[0].data;
970 957
971 memcpy(tag, ssid, ssid_len); 958 memcpy(tag, ssid, ssid_len);
972 959
@@ -974,58 +961,55 @@ static struct sk_buff* rtllib_probe_resp(struct rtllib_device *ieee, u8 *dest)
974 961
975 *(tag++) = MFIE_TYPE_RATES; 962 *(tag++) = MFIE_TYPE_RATES;
976 *(tag++) = rate_len-2; 963 *(tag++) = rate_len-2;
977 memcpy(tag,ieee->current_network.rates,rate_len-2); 964 memcpy(tag, ieee->current_network.rates, rate_len-2);
978 tag+=rate_len-2; 965 tag += rate_len-2;
979 966
980 *(tag++) = MFIE_TYPE_DS_SET; 967 *(tag++) = MFIE_TYPE_DS_SET;
981 *(tag++) = 1; 968 *(tag++) = 1;
982 *(tag++) = ieee->current_network.channel; 969 *(tag++) = ieee->current_network.channel;
983 970
984 if (atim_len){ 971 if (atim_len) {
985 u16 val16; 972 u16 val16;
986 *(tag++) = MFIE_TYPE_IBSS_SET; 973 *(tag++) = MFIE_TYPE_IBSS_SET;
987 *(tag++) = 2; 974 *(tag++) = 2;
988 val16 = cpu_to_le16(ieee->current_network.atim_window); 975 val16 = cpu_to_le16(ieee->current_network.atim_window);
989 memcpy((u8 *)tag, (u8 *)&val16, 2); 976 memcpy((u8 *)tag, (u8 *)&val16, 2);
990 tag+=2; 977 tag += 2;
991 } 978 }
992 979
993 if (erp_len){ 980 if (erp_len) {
994 *(tag++) = MFIE_TYPE_ERP; 981 *(tag++) = MFIE_TYPE_ERP;
995 *(tag++) = 1; 982 *(tag++) = 1;
996 *(tag++) = erpinfo_content; 983 *(tag++) = erpinfo_content;
997 } 984 }
998 if (rate_ex_len){ 985 if (rate_ex_len) {
999 *(tag++) = MFIE_TYPE_RATES_EX; 986 *(tag++) = MFIE_TYPE_RATES_EX;
1000 *(tag++) = rate_ex_len-2; 987 *(tag++) = rate_ex_len-2;
1001 memcpy(tag,ieee->current_network.rates_ex,rate_ex_len-2); 988 memcpy(tag, ieee->current_network.rates_ex, rate_ex_len-2);
1002 tag+=rate_ex_len-2; 989 tag += rate_ex_len-2;
1003 } 990 }
1004 991
1005 if (wpa_ie_len) 992 if (wpa_ie_len) {
1006 {
1007 if (ieee->iw_mode == IW_MODE_ADHOC) 993 if (ieee->iw_mode == IW_MODE_ADHOC)
1008 {
1009 memcpy(&ieee->wpa_ie[14], &ieee->wpa_ie[8], 4); 994 memcpy(&ieee->wpa_ie[14], &ieee->wpa_ie[8], 4);
1010 }
1011 memcpy(tag, ieee->wpa_ie, ieee->wpa_ie_len); 995 memcpy(tag, ieee->wpa_ie, ieee->wpa_ie_len);
1012 tag += ieee->wpa_ie_len; 996 tag += ieee->wpa_ie_len;
1013 } 997 }
1014
1015 return skb; 998 return skb;
1016} 999}
1017 1000
1018struct sk_buff* rtllib_assoc_resp(struct rtllib_device *ieee, u8 *dest) 1001struct sk_buff *rtllib_assoc_resp(struct rtllib_device *ieee, u8 *dest)
1019{ 1002{
1020 struct sk_buff *skb; 1003 struct sk_buff *skb;
1021 u8* tag; 1004 u8 *tag;
1022 1005
1023 struct rtllib_crypt_data* crypt; 1006 struct rtllib_crypt_data *crypt;
1024 struct rtllib_assoc_response_frame *assoc; 1007 struct rtllib_assoc_response_frame *assoc;
1025 short encrypt; 1008 short encrypt;
1026 1009
1027 unsigned int rate_len = rtllib_MFIE_rate_len(ieee); 1010 unsigned int rate_len = rtllib_MFIE_rate_len(ieee);
1028 int len = sizeof(struct rtllib_assoc_response_frame) + rate_len + ieee->tx_headroom; 1011 int len = sizeof(struct rtllib_assoc_response_frame) + rate_len +
1012 ieee->tx_headroom;
1029 1013
1030 skb = dev_alloc_skb(len); 1014 skb = dev_alloc_skb(len);
1031 1015
@@ -1035,10 +1019,10 @@ struct sk_buff* rtllib_assoc_resp(struct rtllib_device *ieee, u8 *dest)
1035 skb_reserve(skb, ieee->tx_headroom); 1019 skb_reserve(skb, ieee->tx_headroom);
1036 1020
1037 assoc = (struct rtllib_assoc_response_frame *) 1021 assoc = (struct rtllib_assoc_response_frame *)
1038 skb_put(skb,sizeof(struct rtllib_assoc_response_frame)); 1022 skb_put(skb, sizeof(struct rtllib_assoc_response_frame));
1039 1023
1040 assoc->header.frame_ctl = cpu_to_le16(RTLLIB_STYPE_ASSOC_RESP); 1024 assoc->header.frame_ctl = cpu_to_le16(RTLLIB_STYPE_ASSOC_RESP);
1041 memcpy(assoc->header.addr1, dest,ETH_ALEN); 1025 memcpy(assoc->header.addr1, dest, ETH_ALEN);
1042 memcpy(assoc->header.addr3, ieee->dev->dev_addr, ETH_ALEN); 1026 memcpy(assoc->header.addr3, ieee->dev->dev_addr, ETH_ALEN);
1043 memcpy(assoc->header.addr2, ieee->dev->dev_addr, ETH_ALEN); 1027 memcpy(assoc->header.addr2, ieee->dev->dev_addr, ETH_ALEN);
1044 assoc->capability = cpu_to_le16(ieee->iw_mode == IW_MODE_MASTER ? 1028 assoc->capability = cpu_to_le16(ieee->iw_mode == IW_MODE_MASTER ?
@@ -1046,14 +1030,15 @@ struct sk_buff* rtllib_assoc_resp(struct rtllib_device *ieee, u8 *dest)
1046 1030
1047 1031
1048 if (ieee->short_slot) 1032 if (ieee->short_slot)
1049 assoc->capability |= cpu_to_le16(WLAN_CAPABILITY_SHORT_SLOT_TIME); 1033 assoc->capability |=
1034 cpu_to_le16(WLAN_CAPABILITY_SHORT_SLOT_TIME);
1050 1035
1051 if (ieee->host_encrypt) 1036 if (ieee->host_encrypt)
1052 crypt = ieee->crypt[ieee->tx_keyidx]; 1037 crypt = ieee->crypt[ieee->tx_keyidx];
1053 else 1038 else
1054 crypt = NULL; 1039 crypt = NULL;
1055 1040
1056 encrypt = ( crypt && crypt->ops); 1041 encrypt = (crypt && crypt->ops);
1057 1042
1058 if (encrypt) 1043 if (encrypt)
1059 assoc->capability |= cpu_to_le16(WLAN_CAPABILITY_PRIVACY); 1044 assoc->capability |= cpu_to_le16(WLAN_CAPABILITY_PRIVACY);
@@ -1061,22 +1046,23 @@ struct sk_buff* rtllib_assoc_resp(struct rtllib_device *ieee, u8 *dest)
1061 assoc->status = 0; 1046 assoc->status = 0;
1062 assoc->aid = cpu_to_le16(ieee->assoc_id); 1047 assoc->aid = cpu_to_le16(ieee->assoc_id);
1063 if (ieee->assoc_id == 0x2007) 1048 if (ieee->assoc_id == 0x2007)
1064 ieee->assoc_id=0; 1049 ieee->assoc_id = 0;
1065 else 1050 else
1066 ieee->assoc_id++; 1051 ieee->assoc_id++;
1067 1052
1068 tag = (u8*) skb_put(skb, rate_len); 1053 tag = (u8 *) skb_put(skb, rate_len);
1069 rtllib_MFIE_Brate(ieee, &tag); 1054 rtllib_MFIE_Brate(ieee, &tag);
1070 rtllib_MFIE_Grate(ieee, &tag); 1055 rtllib_MFIE_Grate(ieee, &tag);
1071 1056
1072 return skb; 1057 return skb;
1073} 1058}
1074 1059
1075struct sk_buff* rtllib_auth_resp(struct rtllib_device *ieee,int status, u8 *dest) 1060struct sk_buff *rtllib_auth_resp(struct rtllib_device *ieee, int status,
1061 u8 *dest)
1076{ 1062{
1077 struct sk_buff *skb = NULL; 1063 struct sk_buff *skb = NULL;
1078 struct rtllib_authentication *auth; 1064 struct rtllib_authentication *auth;
1079 int len = ieee->tx_headroom + sizeof(struct rtllib_authentication)+1; 1065 int len = ieee->tx_headroom + sizeof(struct rtllib_authentication) + 1;
1080 skb = dev_alloc_skb(len); 1066 skb = dev_alloc_skb(len);
1081 if (!skb) 1067 if (!skb)
1082 return NULL; 1068 return NULL;
@@ -1101,10 +1087,10 @@ struct sk_buff* rtllib_auth_resp(struct rtllib_device *ieee,int status, u8 *dest
1101 1087
1102} 1088}
1103 1089
1104struct sk_buff* rtllib_null_func(struct rtllib_device *ieee,short pwr) 1090struct sk_buff *rtllib_null_func(struct rtllib_device *ieee, short pwr)
1105{ 1091{
1106 struct sk_buff *skb; 1092 struct sk_buff *skb;
1107 struct rtllib_hdr_3addr* hdr; 1093 struct rtllib_hdr_3addr *hdr;
1108 1094
1109 skb = dev_alloc_skb(sizeof(struct rtllib_hdr_3addr)+ieee->tx_headroom); 1095 skb = dev_alloc_skb(sizeof(struct rtllib_hdr_3addr)+ieee->tx_headroom);
1110 if (!skb) 1096 if (!skb)
@@ -1112,7 +1098,8 @@ struct sk_buff* rtllib_null_func(struct rtllib_device *ieee,short pwr)
1112 1098
1113 skb_reserve(skb, ieee->tx_headroom); 1099 skb_reserve(skb, ieee->tx_headroom);
1114 1100
1115 hdr = (struct rtllib_hdr_3addr*)skb_put(skb,sizeof(struct rtllib_hdr_3addr)); 1101 hdr = (struct rtllib_hdr_3addr *)skb_put(skb,
1102 sizeof(struct rtllib_hdr_3addr));
1116 1103
1117 memcpy(hdr->addr1, ieee->current_network.bssid, ETH_ALEN); 1104 memcpy(hdr->addr1, ieee->current_network.bssid, ETH_ALEN);
1118 memcpy(hdr->addr2, ieee->dev->dev_addr, ETH_ALEN); 1105 memcpy(hdr->addr2, ieee->dev->dev_addr, ETH_ALEN);
@@ -1120,17 +1107,17 @@ struct sk_buff* rtllib_null_func(struct rtllib_device *ieee,short pwr)
1120 1107
1121 hdr->frame_ctl = cpu_to_le16(RTLLIB_FTYPE_DATA | 1108 hdr->frame_ctl = cpu_to_le16(RTLLIB_FTYPE_DATA |
1122 RTLLIB_STYPE_NULLFUNC | RTLLIB_FCTL_TODS | 1109 RTLLIB_STYPE_NULLFUNC | RTLLIB_FCTL_TODS |
1123 (pwr ? RTLLIB_FCTL_PM:0)); 1110 (pwr ? RTLLIB_FCTL_PM : 0));
1124 1111
1125 return skb; 1112 return skb;
1126 1113
1127 1114
1128} 1115}
1129 1116
1130struct sk_buff* rtllib_pspoll_func(struct rtllib_device *ieee) 1117struct sk_buff *rtllib_pspoll_func(struct rtllib_device *ieee)
1131{ 1118{
1132 struct sk_buff *skb; 1119 struct sk_buff *skb;
1133 struct rtllib_pspoll_hdr* hdr; 1120 struct rtllib_pspoll_hdr *hdr;
1134 1121
1135 skb = dev_alloc_skb(sizeof(struct rtllib_pspoll_hdr)+ieee->tx_headroom); 1122 skb = dev_alloc_skb(sizeof(struct rtllib_pspoll_hdr)+ieee->tx_headroom);
1136 if (!skb) 1123 if (!skb)
@@ -1138,19 +1125,21 @@ struct sk_buff* rtllib_pspoll_func(struct rtllib_device *ieee)
1138 1125
1139 skb_reserve(skb, ieee->tx_headroom); 1126 skb_reserve(skb, ieee->tx_headroom);
1140 1127
1141 hdr = (struct rtllib_pspoll_hdr*)skb_put(skb,sizeof(struct rtllib_pspoll_hdr)); 1128 hdr = (struct rtllib_pspoll_hdr *)skb_put(skb,
1129 sizeof(struct rtllib_pspoll_hdr));
1142 1130
1143 memcpy(hdr->bssid, ieee->current_network.bssid, ETH_ALEN); 1131 memcpy(hdr->bssid, ieee->current_network.bssid, ETH_ALEN);
1144 memcpy(hdr->ta, ieee->dev->dev_addr, ETH_ALEN); 1132 memcpy(hdr->ta, ieee->dev->dev_addr, ETH_ALEN);
1145 1133
1146 hdr->aid = cpu_to_le16(ieee->assoc_id | 0xc000); 1134 hdr->aid = cpu_to_le16(ieee->assoc_id | 0xc000);
1147 hdr->frame_ctl = cpu_to_le16(RTLLIB_FTYPE_CTL |RTLLIB_STYPE_PSPOLL | RTLLIB_FCTL_PM); 1135 hdr->frame_ctl = cpu_to_le16(RTLLIB_FTYPE_CTL | RTLLIB_STYPE_PSPOLL |
1136 RTLLIB_FCTL_PM);
1148 1137
1149 return skb; 1138 return skb;
1150 1139
1151} 1140}
1152 1141
1153void rtllib_resp_to_assoc_rq(struct rtllib_device *ieee, u8* dest) 1142void rtllib_resp_to_assoc_rq(struct rtllib_device *ieee, u8 *dest)
1154{ 1143{
1155 struct sk_buff *buf = rtllib_assoc_resp(ieee, dest); 1144 struct sk_buff *buf = rtllib_assoc_resp(ieee, dest);
1156 1145
@@ -1159,7 +1148,7 @@ void rtllib_resp_to_assoc_rq(struct rtllib_device *ieee, u8* dest)
1159} 1148}
1160 1149
1161 1150
1162void rtllib_resp_to_auth(struct rtllib_device *ieee, int s, u8* dest) 1151void rtllib_resp_to_auth(struct rtllib_device *ieee, int s, u8 *dest)
1163{ 1152{
1164 struct sk_buff *buf = rtllib_auth_resp(ieee, s, dest); 1153 struct sk_buff *buf = rtllib_auth_resp(ieee, s, dest);
1165 1154
@@ -1181,110 +1170,98 @@ inline int SecIsInPMKIDList(struct rtllib_device *ieee, u8 *bssid)
1181{ 1170{
1182 int i = 0; 1171 int i = 0;
1183 1172
1184 do 1173 do {
1185 { 1174 if ((ieee->PMKIDList[i].bUsed) &&
1186 if ((ieee->PMKIDList[i].bUsed) && (memcmp(ieee->PMKIDList[i].Bssid, bssid, ETH_ALEN) == 0)) 1175 (memcmp(ieee->PMKIDList[i].Bssid, bssid, ETH_ALEN) == 0))
1187 {
1188 break; 1176 break;
1189 }
1190 else 1177 else
1191 {
1192 i++; 1178 i++;
1193 }
1194 } while (i < NUM_PMKID_CACHE); 1179 } while (i < NUM_PMKID_CACHE);
1195 1180
1196 if (i == NUM_PMKID_CACHE) 1181 if (i == NUM_PMKID_CACHE)
1197 {
1198 i = -1; 1182 i = -1;
1199 } 1183 return i;
1200 else
1201 {
1202 }
1203
1204 return (i);
1205
1206} 1184}
1207 1185
1208 1186inline struct sk_buff *rtllib_association_req(struct rtllib_network *beacon,
1209inline struct sk_buff *rtllib_association_req(struct rtllib_network *beacon,struct rtllib_device *ieee) 1187 struct rtllib_device *ieee)
1210{ 1188{
1211 struct sk_buff *skb; 1189 struct sk_buff *skb;
1212
1213 struct rtllib_assoc_request_frame *hdr; 1190 struct rtllib_assoc_request_frame *hdr;
1214 u8 *tag, *ies; 1191 u8 *tag, *ies;
1215 int i; 1192 int i;
1216 u8* ht_cap_buf = NULL; 1193 u8 *ht_cap_buf = NULL;
1217 u8 ht_cap_len=0; 1194 u8 ht_cap_len = 0;
1218 u8* realtek_ie_buf=NULL; 1195 u8 *realtek_ie_buf = NULL;
1219 u8 realtek_ie_len=0; 1196 u8 realtek_ie_len = 0;
1220 int wpa_ie_len= ieee->wpa_ie_len; 1197 int wpa_ie_len = ieee->wpa_ie_len;
1221 int wps_ie_len = ieee->wps_ie_len; 1198 int wps_ie_len = ieee->wps_ie_len;
1222 unsigned int ckip_ie_len=0; 1199 unsigned int ckip_ie_len = 0;
1223 unsigned int ccxrm_ie_len=0; 1200 unsigned int ccxrm_ie_len = 0;
1224 unsigned int cxvernum_ie_len=0; 1201 unsigned int cxvernum_ie_len = 0;
1225 struct rtllib_crypt_data* crypt; 1202 struct rtllib_crypt_data *crypt;
1226 int encrypt; 1203 int encrypt;
1227 int PMKCacheIdx; 1204 int PMKCacheIdx;
1228 1205
1229 unsigned int rate_len = (beacon->rates_len?(beacon->rates_len+2):0) + (beacon->rates_ex_len?(beacon->rates_ex_len)+2:0); 1206 unsigned int rate_len = (beacon->rates_len ?
1207 (beacon->rates_len + 2) : 0) +
1208 (beacon->rates_ex_len ? (beacon->rates_ex_len) +
1209 2 : 0);
1230 1210
1231 unsigned int wmm_info_len = beacon->qos_data.supported?9:0; 1211 unsigned int wmm_info_len = beacon->qos_data.supported ? 9 : 0;
1232 unsigned int turbo_info_len = beacon->Turbo_Enable?9:0; 1212 unsigned int turbo_info_len = beacon->Turbo_Enable ? 9 : 0;
1233 1213
1234 int len = 0; 1214 int len = 0;
1235 crypt = ieee->crypt[ieee->tx_keyidx]; 1215 crypt = ieee->crypt[ieee->tx_keyidx];
1236 if (crypt != NULL) { 1216 if (crypt != NULL)
1237 encrypt = ieee->host_encrypt && crypt && crypt->ops && ((0 == strcmp(crypt->ops->name,"WEP") || wpa_ie_len)); 1217 encrypt = ieee->host_encrypt && crypt && crypt->ops &&
1238 } else { 1218 ((0 == strcmp(crypt->ops->name, "WEP") ||
1219 wpa_ie_len));
1220 else
1239 encrypt = 0; 1221 encrypt = 0;
1240 }
1241 1222
1242 if ((ieee->rtllib_ap_sec_type && (ieee->rtllib_ap_sec_type(ieee)&SEC_ALG_TKIP)) ||(ieee->bForcedBgMode == true)) 1223 if ((ieee->rtllib_ap_sec_type &&
1243 { 1224 (ieee->rtllib_ap_sec_type(ieee) & SEC_ALG_TKIP)) ||
1225 (ieee->bForcedBgMode == true)) {
1244 ieee->pHTInfo->bEnableHT = 0; 1226 ieee->pHTInfo->bEnableHT = 0;
1245 ieee->mode = WIRELESS_MODE_G; 1227 ieee->mode = WIRELESS_MODE_G;
1246 } 1228 }
1247 1229
1248 if (ieee->pHTInfo->bCurrentHTSupport&&ieee->pHTInfo->bEnableHT) 1230 if (ieee->pHTInfo->bCurrentHTSupport && ieee->pHTInfo->bEnableHT) {
1249 { 1231 ht_cap_buf = (u8 *)&(ieee->pHTInfo->SelfHTCap);
1250 ht_cap_buf = (u8*)&(ieee->pHTInfo->SelfHTCap);
1251 ht_cap_len = sizeof(ieee->pHTInfo->SelfHTCap); 1232 ht_cap_len = sizeof(ieee->pHTInfo->SelfHTCap);
1252 HTConstructCapabilityElement(ieee, ht_cap_buf, &ht_cap_len, encrypt, true); 1233 HTConstructCapabilityElement(ieee, ht_cap_buf, &ht_cap_len,
1234 encrypt, true);
1253 if (ieee->pHTInfo->bCurrentRT2RTAggregation) { 1235 if (ieee->pHTInfo->bCurrentRT2RTAggregation) {
1254 realtek_ie_buf = ieee->pHTInfo->szRT2RTAggBuffer; 1236 realtek_ie_buf = ieee->pHTInfo->szRT2RTAggBuffer;
1255 realtek_ie_len = sizeof( ieee->pHTInfo->szRT2RTAggBuffer); 1237 realtek_ie_len =
1256 HTConstructRT2RTAggElement(ieee, realtek_ie_buf, &realtek_ie_len); 1238 sizeof(ieee->pHTInfo->szRT2RTAggBuffer);
1257 1239 HTConstructRT2RTAggElement(ieee, realtek_ie_buf,
1240 &realtek_ie_len);
1258 } 1241 }
1259 } 1242 }
1260 1243
1261 if (beacon->bCkipSupported) 1244 if (beacon->bCkipSupported)
1262 {
1263 ckip_ie_len = 30+2; 1245 ckip_ie_len = 30+2;
1264 }
1265 if (beacon->bCcxRmEnable) 1246 if (beacon->bCcxRmEnable)
1266 {
1267 ccxrm_ie_len = 6+2; 1247 ccxrm_ie_len = 6+2;
1268 } 1248 if (beacon->BssCcxVerNumber >= 2)
1269 if ( beacon->BssCcxVerNumber >= 2 )
1270 {
1271 cxvernum_ie_len = 5+2; 1249 cxvernum_ie_len = 5+2;
1272 }
1273 1250
1274 PMKCacheIdx = SecIsInPMKIDList(ieee, ieee->current_network.bssid); 1251 PMKCacheIdx = SecIsInPMKIDList(ieee, ieee->current_network.bssid);
1275 if (PMKCacheIdx >= 0) 1252 if (PMKCacheIdx >= 0) {
1276 {
1277 wpa_ie_len += 18; 1253 wpa_ie_len += 18;
1278 printk("[PMK cache]: WPA2 IE length: %x\n", wpa_ie_len); 1254 printk(KERN_INFO "[PMK cache]: WPA2 IE length: %x\n",
1255 wpa_ie_len);
1279 } 1256 }
1280 len = sizeof(struct rtllib_assoc_request_frame)+ 2 1257 len = sizeof(struct rtllib_assoc_request_frame) + 2
1281 + beacon->ssid_len 1258 + beacon->ssid_len
1282 + rate_len 1259 + rate_len
1283 + wpa_ie_len 1260 + wpa_ie_len
1284 + wps_ie_len 1261 + wps_ie_len
1285 + wmm_info_len 1262 + wmm_info_len
1286 + turbo_info_len 1263 + turbo_info_len
1287 + ht_cap_len 1264 + ht_cap_len
1288 + realtek_ie_len 1265 + realtek_ie_len
1289 + ckip_ie_len 1266 + ckip_ie_len
1290 + ccxrm_ie_len 1267 + ccxrm_ie_len
@@ -1299,11 +1276,11 @@ inline struct sk_buff *rtllib_association_req(struct rtllib_network *beacon,stru
1299 skb_reserve(skb, ieee->tx_headroom); 1276 skb_reserve(skb, ieee->tx_headroom);
1300 1277
1301 hdr = (struct rtllib_assoc_request_frame *) 1278 hdr = (struct rtllib_assoc_request_frame *)
1302 skb_put(skb, sizeof(struct rtllib_assoc_request_frame)+2); 1279 skb_put(skb, sizeof(struct rtllib_assoc_request_frame) + 2);
1303 1280
1304 1281
1305 hdr->header.frame_ctl = RTLLIB_STYPE_ASSOC_REQ; 1282 hdr->header.frame_ctl = RTLLIB_STYPE_ASSOC_REQ;
1306 hdr->header.duration_id= 37; 1283 hdr->header.duration_id = 37;
1307 memcpy(hdr->header.addr1, beacon->bssid, ETH_ALEN); 1284 memcpy(hdr->header.addr1, beacon->bssid, ETH_ALEN);
1308 memcpy(hdr->header.addr2, ieee->dev->dev_addr, ETH_ALEN); 1285 memcpy(hdr->header.addr2, ieee->dev->dev_addr, ETH_ALEN);
1309 memcpy(hdr->header.addr3, beacon->bssid, ETH_ALEN); 1286 memcpy(hdr->header.addr3, beacon->bssid, ETH_ALEN);
@@ -1311,13 +1288,14 @@ inline struct sk_buff *rtllib_association_req(struct rtllib_network *beacon,stru
1311 memcpy(ieee->ap_mac_addr, beacon->bssid, ETH_ALEN); 1288 memcpy(ieee->ap_mac_addr, beacon->bssid, ETH_ALEN);
1312 1289
1313 hdr->capability = cpu_to_le16(WLAN_CAPABILITY_ESS); 1290 hdr->capability = cpu_to_le16(WLAN_CAPABILITY_ESS);
1314 if (beacon->capability & WLAN_CAPABILITY_PRIVACY ) 1291 if (beacon->capability & WLAN_CAPABILITY_PRIVACY)
1315 hdr->capability |= cpu_to_le16(WLAN_CAPABILITY_PRIVACY); 1292 hdr->capability |= cpu_to_le16(WLAN_CAPABILITY_PRIVACY);
1316 1293
1317 if (beacon->capability & WLAN_CAPABILITY_SHORT_PREAMBLE) 1294 if (beacon->capability & WLAN_CAPABILITY_SHORT_PREAMBLE)
1318 hdr->capability |= cpu_to_le16(WLAN_CAPABILITY_SHORT_PREAMBLE); 1295 hdr->capability |= cpu_to_le16(WLAN_CAPABILITY_SHORT_PREAMBLE);
1319 1296
1320 if (ieee->short_slot && (beacon->capability&WLAN_CAPABILITY_SHORT_SLOT_TIME)) 1297 if (ieee->short_slot &&
1298 (beacon->capability&WLAN_CAPABILITY_SHORT_SLOT_TIME))
1321 hdr->capability |= cpu_to_le16(WLAN_CAPABILITY_SHORT_SLOT_TIME); 1299 hdr->capability |= cpu_to_le16(WLAN_CAPABILITY_SHORT_SLOT_TIME);
1322 1300
1323 1301
@@ -1331,94 +1309,89 @@ inline struct sk_buff *rtllib_association_req(struct rtllib_network *beacon,stru
1331 1309
1332 tag = skb_put(skb, rate_len); 1310 tag = skb_put(skb, rate_len);
1333 1311
1334 if (beacon->rates_len){ 1312 if (beacon->rates_len) {
1335 *tag++ = MFIE_TYPE_RATES; 1313 *tag++ = MFIE_TYPE_RATES;
1336 *tag++ = beacon->rates_len; 1314 *tag++ = beacon->rates_len;
1337 for (i=0;i<beacon->rates_len;i++){ 1315 for (i = 0; i < beacon->rates_len; i++)
1338 *tag++ = beacon->rates[i]; 1316 *tag++ = beacon->rates[i];
1339 }
1340 } 1317 }
1341 1318
1342 if (beacon->rates_ex_len){ 1319 if (beacon->rates_ex_len) {
1343 *tag++ = MFIE_TYPE_RATES_EX; 1320 *tag++ = MFIE_TYPE_RATES_EX;
1344 *tag++ = beacon->rates_ex_len; 1321 *tag++ = beacon->rates_ex_len;
1345 for (i=0;i<beacon->rates_ex_len;i++){ 1322 for (i = 0; i < beacon->rates_ex_len; i++)
1346 *tag++ = beacon->rates_ex[i]; 1323 *tag++ = beacon->rates_ex[i];
1347 }
1348 } 1324 }
1349 1325
1350 if ( beacon->bCkipSupported ) 1326 if (beacon->bCkipSupported) {
1351 {
1352 static u8 AironetIeOui[] = {0x00, 0x01, 0x66}; 1327 static u8 AironetIeOui[] = {0x00, 0x01, 0x66};
1353 u8 CcxAironetBuf[30]; 1328 u8 CcxAironetBuf[30];
1354 struct octet_string osCcxAironetIE; 1329 struct octet_string osCcxAironetIE;
1355 1330
1356 memset(CcxAironetBuf, 0,30); 1331 memset(CcxAironetBuf, 0, 30);
1357 osCcxAironetIE.Octet = CcxAironetBuf; 1332 osCcxAironetIE.Octet = CcxAironetBuf;
1358 osCcxAironetIE.Length = sizeof(CcxAironetBuf); 1333 osCcxAironetIE.Length = sizeof(CcxAironetBuf);
1359 memcpy(osCcxAironetIE.Octet, AironetIeOui, sizeof(AironetIeOui)); 1334 memcpy(osCcxAironetIE.Octet, AironetIeOui,
1335 sizeof(AironetIeOui));
1360 1336
1361 osCcxAironetIE.Octet[IE_CISCO_FLAG_POSITION] |= (SUPPORT_CKIP_PK|SUPPORT_CKIP_MIC) ; 1337 osCcxAironetIE.Octet[IE_CISCO_FLAG_POSITION] |=
1338 (SUPPORT_CKIP_PK|SUPPORT_CKIP_MIC);
1362 tag = skb_put(skb, ckip_ie_len); 1339 tag = skb_put(skb, ckip_ie_len);
1363 *tag++ = MFIE_TYPE_AIRONET; 1340 *tag++ = MFIE_TYPE_AIRONET;
1364 *tag++ = osCcxAironetIE.Length; 1341 *tag++ = osCcxAironetIE.Length;
1365 memcpy(tag,osCcxAironetIE.Octet,osCcxAironetIE.Length); 1342 memcpy(tag, osCcxAironetIE.Octet, osCcxAironetIE.Length);
1366 tag += osCcxAironetIE.Length; 1343 tag += osCcxAironetIE.Length;
1367 } 1344 }
1368 1345
1369 if (beacon->bCcxRmEnable) 1346 if (beacon->bCcxRmEnable) {
1370 {
1371 static u8 CcxRmCapBuf[] = {0x00, 0x40, 0x96, 0x01, 0x01, 0x00}; 1347 static u8 CcxRmCapBuf[] = {0x00, 0x40, 0x96, 0x01, 0x01, 0x00};
1372 struct octet_string osCcxRmCap; 1348 struct octet_string osCcxRmCap;
1373 1349
1374 osCcxRmCap.Octet = CcxRmCapBuf; 1350 osCcxRmCap.Octet = CcxRmCapBuf;
1375 osCcxRmCap.Length = sizeof(CcxRmCapBuf); 1351 osCcxRmCap.Length = sizeof(CcxRmCapBuf);
1376 tag = skb_put(skb,ccxrm_ie_len); 1352 tag = skb_put(skb, ccxrm_ie_len);
1377 *tag++ = MFIE_TYPE_GENERIC; 1353 *tag++ = MFIE_TYPE_GENERIC;
1378 *tag++ = osCcxRmCap.Length; 1354 *tag++ = osCcxRmCap.Length;
1379 memcpy(tag,osCcxRmCap.Octet,osCcxRmCap.Length); 1355 memcpy(tag, osCcxRmCap.Octet, osCcxRmCap.Length);
1380 tag += osCcxRmCap.Length; 1356 tag += osCcxRmCap.Length;
1381 } 1357 }
1382 1358
1383 if ( beacon->BssCcxVerNumber >= 2 ) 1359 if (beacon->BssCcxVerNumber >= 2) {
1384 { 1360 u8 CcxVerNumBuf[] = {0x00, 0x40, 0x96, 0x03, 0x00};
1385 u8 CcxVerNumBuf[] = {0x00, 0x40, 0x96, 0x03, 0x00};
1386 struct octet_string osCcxVerNum; 1361 struct octet_string osCcxVerNum;
1387 CcxVerNumBuf[4] = beacon->BssCcxVerNumber; 1362 CcxVerNumBuf[4] = beacon->BssCcxVerNumber;
1388 osCcxVerNum.Octet = CcxVerNumBuf; 1363 osCcxVerNum.Octet = CcxVerNumBuf;
1389 osCcxVerNum.Length = sizeof(CcxVerNumBuf); 1364 osCcxVerNum.Length = sizeof(CcxVerNumBuf);
1390 tag = skb_put(skb,cxvernum_ie_len); 1365 tag = skb_put(skb, cxvernum_ie_len);
1391 *tag++ = MFIE_TYPE_GENERIC; 1366 *tag++ = MFIE_TYPE_GENERIC;
1392 *tag++ = osCcxVerNum.Length; 1367 *tag++ = osCcxVerNum.Length;
1393 memcpy(tag,osCcxVerNum.Octet,osCcxVerNum.Length); 1368 memcpy(tag, osCcxVerNum.Octet, osCcxVerNum.Length);
1394 tag += osCcxVerNum.Length; 1369 tag += osCcxVerNum.Length;
1395 } 1370 }
1396 if (ieee->pHTInfo->bCurrentHTSupport&&ieee->pHTInfo->bEnableHT){ 1371 if (ieee->pHTInfo->bCurrentHTSupport && ieee->pHTInfo->bEnableHT) {
1397 if (ieee->pHTInfo->ePeerHTSpecVer != HT_SPEC_VER_EWC) 1372 if (ieee->pHTInfo->ePeerHTSpecVer != HT_SPEC_VER_EWC) {
1398 {
1399 tag = skb_put(skb, ht_cap_len); 1373 tag = skb_put(skb, ht_cap_len);
1400 *tag++ = MFIE_TYPE_HT_CAP; 1374 *tag++ = MFIE_TYPE_HT_CAP;
1401 *tag++ = ht_cap_len - 2; 1375 *tag++ = ht_cap_len - 2;
1402 memcpy(tag, ht_cap_buf,ht_cap_len -2); 1376 memcpy(tag, ht_cap_buf, ht_cap_len - 2);
1403 tag += ht_cap_len -2; 1377 tag += ht_cap_len - 2;
1404 } 1378 }
1405 } 1379 }
1406 1380
1407 1381 if (wpa_ie_len) {
1408 if (wpa_ie_len){
1409 tag = skb_put(skb, ieee->wpa_ie_len); 1382 tag = skb_put(skb, ieee->wpa_ie_len);
1410 memcpy(tag, ieee->wpa_ie, ieee->wpa_ie_len); 1383 memcpy(tag, ieee->wpa_ie, ieee->wpa_ie_len);
1411 1384
1412 if (PMKCacheIdx >= 0) 1385 if (PMKCacheIdx >= 0) {
1413 {
1414 tag = skb_put(skb, 18); 1386 tag = skb_put(skb, 18);
1415 *tag = 1; 1387 *tag = 1;
1416 *(tag + 1) = 0; 1388 *(tag + 1) = 0;
1417 memcpy((tag + 2), &ieee->PMKIDList[PMKCacheIdx].PMKID, 16); 1389 memcpy((tag + 2), &ieee->PMKIDList[PMKCacheIdx].PMKID,
1390 16);
1418 } 1391 }
1419 } 1392 }
1420 if (wmm_info_len) { 1393 if (wmm_info_len) {
1421 tag = skb_put(skb,wmm_info_len); 1394 tag = skb_put(skb, wmm_info_len);
1422 rtllib_WMM_Info(ieee, &tag); 1395 rtllib_WMM_Info(ieee, &tag);
1423 } 1396 }
1424 1397
@@ -1427,42 +1400,39 @@ inline struct sk_buff *rtllib_association_req(struct rtllib_network *beacon,stru
1427 memcpy(tag, ieee->wps_ie, wps_ie_len); 1400 memcpy(tag, ieee->wps_ie, wps_ie_len);
1428 } 1401 }
1429 1402
1430 tag = skb_put(skb,turbo_info_len); 1403 tag = skb_put(skb, turbo_info_len);
1431 if (turbo_info_len) 1404 if (turbo_info_len)
1432 rtllib_TURBO_Info(ieee, &tag); 1405 rtllib_TURBO_Info(ieee, &tag);
1433 1406
1434 if (ieee->pHTInfo->bCurrentHTSupport&&ieee->pHTInfo->bEnableHT){ 1407 if (ieee->pHTInfo->bCurrentHTSupport && ieee->pHTInfo->bEnableHT) {
1435 if (ieee->pHTInfo->ePeerHTSpecVer == HT_SPEC_VER_EWC) 1408 if (ieee->pHTInfo->ePeerHTSpecVer == HT_SPEC_VER_EWC) {
1436 {
1437 tag = skb_put(skb, ht_cap_len); 1409 tag = skb_put(skb, ht_cap_len);
1438 *tag++ = MFIE_TYPE_GENERIC; 1410 *tag++ = MFIE_TYPE_GENERIC;
1439 *tag++ = ht_cap_len - 2; 1411 *tag++ = ht_cap_len - 2;
1440 memcpy(tag, ht_cap_buf,ht_cap_len - 2); 1412 memcpy(tag, ht_cap_buf, ht_cap_len - 2);
1441 tag += ht_cap_len -2; 1413 tag += ht_cap_len - 2;
1442 } 1414 }
1443 1415
1444 if (ieee->pHTInfo->bCurrentRT2RTAggregation){ 1416 if (ieee->pHTInfo->bCurrentRT2RTAggregation) {
1445 tag = skb_put(skb, realtek_ie_len); 1417 tag = skb_put(skb, realtek_ie_len);
1446 *tag++ = MFIE_TYPE_GENERIC; 1418 *tag++ = MFIE_TYPE_GENERIC;
1447 *tag++ = realtek_ie_len - 2; 1419 *tag++ = realtek_ie_len - 2;
1448 memcpy(tag, realtek_ie_buf,realtek_ie_len -2 ); 1420 memcpy(tag, realtek_ie_buf, realtek_ie_len - 2);
1449 } 1421 }
1450 } 1422 }
1451 1423
1452 if (ieee->assocreq_ies){ 1424 kfree(ieee->assocreq_ies);
1453 kfree(ieee->assocreq_ies); 1425 ieee->assocreq_ies = NULL;
1454 ieee->assocreq_ies = NULL;
1455 }
1456 ies = &(hdr->info_element[0].id); 1426 ies = &(hdr->info_element[0].id);
1457 ieee->assocreq_ies_len = (skb->data + skb->len) - ies; 1427 ieee->assocreq_ies_len = (skb->data + skb->len) - ies;
1458 ieee->assocreq_ies = kmalloc(ieee->assocreq_ies_len, GFP_ATOMIC); 1428 ieee->assocreq_ies = kmalloc(ieee->assocreq_ies_len, GFP_ATOMIC);
1459 if (ieee->assocreq_ies) 1429 if (ieee->assocreq_ies)
1460 memcpy(ieee->assocreq_ies, ies, ieee->assocreq_ies_len); 1430 memcpy(ieee->assocreq_ies, ies, ieee->assocreq_ies_len);
1461 else{ 1431 else {
1462 printk("%s()Warning: can't alloc memory for assocreq_ies\n", __func__); 1432 printk(KERN_INFO "%s()Warning: can't alloc memory for assocreq"
1433 "_ies\n", __func__);
1463 ieee->assocreq_ies_len = 0; 1434 ieee->assocreq_ies_len = 0;
1464 } 1435 }
1465
1466 return skb; 1436 return skb;
1467} 1437}
1468 1438
@@ -1480,18 +1450,18 @@ void rtllib_associate_abort(struct rtllib_device *ieee)
1480 * Here we will check if there are good nets to associate 1450 * Here we will check if there are good nets to associate
1481 * with, so we retry or just get back to NO_LINK and scanning 1451 * with, so we retry or just get back to NO_LINK and scanning
1482 */ 1452 */
1483 if (ieee->state == RTLLIB_ASSOCIATING_AUTHENTICATING){ 1453 if (ieee->state == RTLLIB_ASSOCIATING_AUTHENTICATING) {
1484 RTLLIB_DEBUG_MGMT("Authentication failed\n"); 1454 RTLLIB_DEBUG_MGMT("Authentication failed\n");
1485 ieee->softmac_stats.no_auth_rs++; 1455 ieee->softmac_stats.no_auth_rs++;
1486 }else{ 1456 } else {
1487 RTLLIB_DEBUG_MGMT("Association failed\n"); 1457 RTLLIB_DEBUG_MGMT("Association failed\n");
1488 ieee->softmac_stats.no_ass_rs++; 1458 ieee->softmac_stats.no_ass_rs++;
1489 } 1459 }
1490 1460
1491 ieee->state = RTLLIB_ASSOCIATING_RETRY; 1461 ieee->state = RTLLIB_ASSOCIATING_RETRY;
1492 1462
1493 queue_delayed_work_rsl(ieee->wq, &ieee->associate_retry_wq, \ 1463 queue_delayed_work_rsl(ieee->wq, &ieee->associate_retry_wq,
1494 RTLLIB_SOFTMAC_ASSOC_RETRY_TIME); 1464 RTLLIB_SOFTMAC_ASSOC_RETRY_TIME);
1495 1465
1496 spin_unlock_irqrestore(&ieee->lock, flags); 1466 spin_unlock_irqrestore(&ieee->lock, flags);
1497} 1467}
@@ -1501,7 +1471,7 @@ void rtllib_associate_abort_cb(unsigned long dev)
1501 rtllib_associate_abort((struct rtllib_device *) dev); 1471 rtllib_associate_abort((struct rtllib_device *) dev);
1502} 1472}
1503 1473
1504void rtllib_associate_step1(struct rtllib_device *ieee,u8 * daddr) 1474void rtllib_associate_step1(struct rtllib_device *ieee, u8 * daddr)
1505{ 1475{
1506 struct rtllib_network *beacon = &ieee->current_network; 1476 struct rtllib_network *beacon = &ieee->current_network;
1507 struct sk_buff *skb; 1477 struct sk_buff *skb;
@@ -1510,15 +1480,15 @@ void rtllib_associate_step1(struct rtllib_device *ieee,u8 * daddr)
1510 1480
1511 ieee->softmac_stats.tx_auth_rq++; 1481 ieee->softmac_stats.tx_auth_rq++;
1512 1482
1513 skb=rtllib_authentication_req(beacon, ieee, 0,daddr); 1483 skb = rtllib_authentication_req(beacon, ieee, 0, daddr);
1514 1484
1515 if (!skb) 1485 if (!skb)
1516 rtllib_associate_abort(ieee); 1486 rtllib_associate_abort(ieee);
1517 else{ 1487 else {
1518 ieee->state = RTLLIB_ASSOCIATING_AUTHENTICATING ; 1488 ieee->state = RTLLIB_ASSOCIATING_AUTHENTICATING ;
1519 RTLLIB_DEBUG_MGMT("Sending authentication request\n"); 1489 RTLLIB_DEBUG_MGMT("Sending authentication request\n");
1520 softmac_mgmt_xmit(skb, ieee); 1490 softmac_mgmt_xmit(skb, ieee);
1521 if (!timer_pending(&ieee->associate_timer)){ 1491 if (!timer_pending(&ieee->associate_timer)) {
1522 ieee->associate_timer.expires = jiffies + (HZ / 2); 1492 ieee->associate_timer.expires = jiffies + (HZ / 2);
1523 add_timer(&ieee->associate_timer); 1493 add_timer(&ieee->associate_timer);
1524 } 1494 }
@@ -1534,19 +1504,21 @@ void rtllib_auth_challenge(struct rtllib_device *ieee, u8 *challenge, int chlen)
1534 ieee->associate_seq++; 1504 ieee->associate_seq++;
1535 ieee->softmac_stats.tx_auth_rq++; 1505 ieee->softmac_stats.tx_auth_rq++;
1536 1506
1537 skb = rtllib_authentication_req(beacon, ieee, chlen+2,beacon->bssid); 1507 skb = rtllib_authentication_req(beacon, ieee, chlen + 2, beacon->bssid);
1538 1508
1539 if (!skb) 1509 if (!skb)
1540 rtllib_associate_abort(ieee); 1510 rtllib_associate_abort(ieee);
1541 else{ 1511 else {
1542 c = skb_put(skb, chlen+2); 1512 c = skb_put(skb, chlen+2);
1543 *(c++) = MFIE_TYPE_CHALLENGE; 1513 *(c++) = MFIE_TYPE_CHALLENGE;
1544 *(c++) = chlen; 1514 *(c++) = chlen;
1545 memcpy(c, challenge, chlen); 1515 memcpy(c, challenge, chlen);
1546 1516
1547 RTLLIB_DEBUG_MGMT("Sending authentication challenge response\n"); 1517 RTLLIB_DEBUG_MGMT("Sending authentication challenge "
1518 "response\n");
1548 1519
1549 rtllib_encrypt_fragment(ieee, skb, sizeof(struct rtllib_hdr_3addr )); 1520 rtllib_encrypt_fragment(ieee, skb,
1521 sizeof(struct rtllib_hdr_3addr));
1550 1522
1551 softmac_mgmt_xmit(skb, ieee); 1523 softmac_mgmt_xmit(skb, ieee);
1552 mod_timer(&ieee->associate_timer, jiffies + (HZ/2)); 1524 mod_timer(&ieee->associate_timer, jiffies + (HZ/2));
@@ -1556,7 +1528,7 @@ void rtllib_auth_challenge(struct rtllib_device *ieee, u8 *challenge, int chlen)
1556 1528
1557void rtllib_associate_step2(struct rtllib_device *ieee) 1529void rtllib_associate_step2(struct rtllib_device *ieee)
1558{ 1530{
1559 struct sk_buff* skb; 1531 struct sk_buff *skb;
1560 struct rtllib_network *beacon = &ieee->current_network; 1532 struct rtllib_network *beacon = &ieee->current_network;
1561 1533
1562 del_timer_sync(&ieee->associate_timer); 1534 del_timer_sync(&ieee->associate_timer);
@@ -1564,10 +1536,10 @@ void rtllib_associate_step2(struct rtllib_device *ieee)
1564 RTLLIB_DEBUG_MGMT("Sending association request\n"); 1536 RTLLIB_DEBUG_MGMT("Sending association request\n");
1565 1537
1566 ieee->softmac_stats.tx_ass_rq++; 1538 ieee->softmac_stats.tx_ass_rq++;
1567 skb=rtllib_association_req(beacon, ieee); 1539 skb = rtllib_association_req(beacon, ieee);
1568 if (!skb) 1540 if (!skb)
1569 rtllib_associate_abort(ieee); 1541 rtllib_associate_abort(ieee);
1570 else{ 1542 else {
1571 softmac_mgmt_xmit(skb, ieee); 1543 softmac_mgmt_xmit(skb, ieee);
1572 mod_timer(&ieee->associate_timer, jiffies + (HZ/2)); 1544 mod_timer(&ieee->associate_timer, jiffies + (HZ/2));
1573 } 1545 }
@@ -1576,48 +1548,54 @@ void rtllib_associate_step2(struct rtllib_device *ieee)
1576#define CANCELLED 2 1548#define CANCELLED 2
1577void rtllib_associate_complete_wq(void *data) 1549void rtllib_associate_complete_wq(void *data)
1578{ 1550{
1579 struct rtllib_device *ieee = (struct rtllib_device *)container_of_work_rsl(data, struct rtllib_device, associate_complete_wq); 1551 struct rtllib_device *ieee = (struct rtllib_device *)
1580 struct rt_pwr_save_ctrl *pPSC = (struct rt_pwr_save_ctrl *)(&(ieee->PowerSaveControl)); 1552 container_of_work_rsl(data,
1553 struct rtllib_device,
1554 associate_complete_wq);
1555 struct rt_pwr_save_ctrl *pPSC = (struct rt_pwr_save_ctrl *)
1556 (&(ieee->PowerSaveControl));
1581 printk(KERN_INFO "Associated successfully\n"); 1557 printk(KERN_INFO "Associated successfully\n");
1582 if (ieee->is_silent_reset == 0){ 1558 if (ieee->is_silent_reset == 0) {
1583 printk("normal associate\n"); 1559 printk(KERN_INFO "normal associate\n");
1584 notify_wx_assoc_event(ieee); 1560 notify_wx_assoc_event(ieee);
1585 } 1561 }
1586 1562
1587 netif_carrier_on(ieee->dev); 1563 netif_carrier_on(ieee->dev);
1588 ieee->is_roaming = false; 1564 ieee->is_roaming = false;
1589 if (rtllib_is_54g(&ieee->current_network) && 1565 if (rtllib_is_54g(&ieee->current_network) &&
1590 (ieee->modulation & RTLLIB_OFDM_MODULATION)){ 1566 (ieee->modulation & RTLLIB_OFDM_MODULATION)) {
1591
1592 ieee->rate = 108; 1567 ieee->rate = 108;
1593 printk(KERN_INFO"Using G rates:%d\n", ieee->rate); 1568 printk(KERN_INFO"Using G rates:%d\n", ieee->rate);
1594 }else{ 1569 } else {
1595 ieee->rate = 22; 1570 ieee->rate = 22;
1596 ieee->SetWirelessMode(ieee->dev, IEEE_B); 1571 ieee->SetWirelessMode(ieee->dev, IEEE_B);
1597 printk(KERN_INFO"Using B rates:%d\n", ieee->rate); 1572 printk(KERN_INFO"Using B rates:%d\n", ieee->rate);
1598 } 1573 }
1599 if (ieee->pHTInfo->bCurrentHTSupport&&ieee->pHTInfo->bEnableHT) 1574 if (ieee->pHTInfo->bCurrentHTSupport && ieee->pHTInfo->bEnableHT) {
1600 { 1575 printk(KERN_INFO "Successfully associated, ht enabled\n");
1601 printk("Successfully associated, ht enabled\n");
1602 HTOnAssocRsp(ieee); 1576 HTOnAssocRsp(ieee);
1603 } else { 1577 } else {
1604 printk("Successfully associated, ht not enabled(%d, %d)\n", 1578 printk(KERN_INFO "Successfully associated, ht not "
1605 ieee->pHTInfo->bCurrentHTSupport, ieee->pHTInfo->bEnableHT); 1579 "enabled(%d, %d)\n",
1580 ieee->pHTInfo->bCurrentHTSupport,
1581 ieee->pHTInfo->bEnableHT);
1606 memset(ieee->dot11HTOperationalRateSet, 0, 16); 1582 memset(ieee->dot11HTOperationalRateSet, 0, 16);
1607 } 1583 }
1608 ieee->LinkDetectInfo.SlotNum = 2 * (1 + ieee->current_network.beacon_interval/500); 1584 ieee->LinkDetectInfo.SlotNum = 2 * (1 +
1609 if (ieee->LinkDetectInfo.NumRecvBcnInPeriod==0||ieee->LinkDetectInfo.NumRecvDataInPeriod==0 ) 1585 ieee->current_network.beacon_interval /
1610 { 1586 500);
1587 if (ieee->LinkDetectInfo.NumRecvBcnInPeriod == 0 ||
1588 ieee->LinkDetectInfo.NumRecvDataInPeriod == 0) {
1611 ieee->LinkDetectInfo.NumRecvBcnInPeriod = 1; 1589 ieee->LinkDetectInfo.NumRecvBcnInPeriod = 1;
1612 ieee->LinkDetectInfo.NumRecvDataInPeriod= 1; 1590 ieee->LinkDetectInfo.NumRecvDataInPeriod = 1;
1613 } 1591 }
1614 pPSC->LpsIdleCount = 0; 1592 pPSC->LpsIdleCount = 0;
1615 ieee->link_change(ieee->dev); 1593 ieee->link_change(ieee->dev);
1616 1594
1617 if (ieee->is_silent_reset == 1) { 1595 if (ieee->is_silent_reset == 1) {
1618 printk("silent reset associate\n"); 1596 printk(KERN_INFO "silent reset associate\n");
1619 ieee->is_silent_reset = 0; 1597 ieee->is_silent_reset = 0;
1620 } 1598 }
1621 1599
1622 if (ieee->data_hard_resume) 1600 if (ieee->data_hard_resume)
1623 ieee->data_hard_resume(ieee->dev); 1601 ieee->data_hard_resume(ieee->dev);
@@ -1626,49 +1604,6 @@ void rtllib_associate_complete_wq(void *data)
1626 1604
1627static void rtllib_sta_send_associnfo(struct rtllib_device *ieee) 1605static void rtllib_sta_send_associnfo(struct rtllib_device *ieee)
1628{ 1606{
1629 char *buf;
1630 size_t len;
1631 int i;
1632 union iwreq_data wrqu;
1633
1634 return;
1635
1636
1637 buf = kmalloc(50 + 2 * (ieee->assocreq_ies_len + ieee->assocresp_ies_len), GFP_ATOMIC);
1638 if (!buf)
1639 return;
1640
1641 len = sprintf(buf, "ASSOCINFO(");
1642 if (ieee->assocreq_ies) {
1643 len += sprintf(buf + len, "ReqIEs=");
1644 for (i = 0; i < ieee->assocreq_ies_len; i++) {
1645 len += sprintf(buf + len, "%02x", ieee->assocreq_ies[i]);
1646 }
1647 }
1648 if (ieee->assocresp_ies) {
1649 if (ieee->assocreq_ies)
1650 len += sprintf(buf + len, " ");
1651 len += sprintf(buf + len, "RespIEs=");
1652 for (i = 0; i < ieee->assocresp_ies_len; i++) {
1653 len += sprintf(buf + len, "%02x", ieee->assocresp_ies[i]);
1654 }
1655 }
1656 len += sprintf(buf + len, ")");
1657
1658 if (len > IW_CUSTOM_MAX) {
1659 len = sprintf(buf, "ASSOCRESPIE=");
1660 for (i = 0; i < ieee->assocresp_ies_len; i++) {
1661 len += sprintf(buf + len, "%02x", ieee->assocresp_ies[i]);
1662 }
1663 }
1664
1665 if (len <= IW_CUSTOM_MAX) {
1666 memset(&wrqu, 0, sizeof(wrqu));
1667 wrqu.data.length = len;
1668 wireless_send_event(ieee->dev, IWEVCUSTOM, &wrqu, buf);
1669 }
1670
1671 kfree(buf);
1672} 1607}
1673 1608
1674void rtllib_associate_complete(struct rtllib_device *ieee) 1609void rtllib_associate_complete(struct rtllib_device *ieee)
@@ -1683,7 +1618,9 @@ void rtllib_associate_complete(struct rtllib_device *ieee)
1683 1618
1684void rtllib_associate_procedure_wq(void *data) 1619void rtllib_associate_procedure_wq(void *data)
1685{ 1620{
1686 struct rtllib_device *ieee = container_of_dwork_rsl(data, struct rtllib_device, associate_procedure_wq); 1621 struct rtllib_device *ieee = container_of_dwork_rsl(data,
1622 struct rtllib_device,
1623 associate_procedure_wq);
1687 rtllib_stop_scan_syncro(ieee); 1624 rtllib_stop_scan_syncro(ieee);
1688 if (ieee->rtllib_ips_leave != NULL) 1625 if (ieee->rtllib_ips_leave != NULL)
1689 ieee->rtllib_ips_leave(ieee->dev); 1626 ieee->rtllib_ips_leave(ieee->dev);
@@ -1693,11 +1630,12 @@ void rtllib_associate_procedure_wq(void *data)
1693 ieee->data_hard_stop(ieee->dev); 1630 ieee->data_hard_stop(ieee->dev);
1694 1631
1695 rtllib_stop_scan(ieee); 1632 rtllib_stop_scan(ieee);
1696 RT_TRACE(COMP_DBG, "===>%s(), chan:%d\n", __func__, ieee->current_network.channel); 1633 RT_TRACE(COMP_DBG, "===>%s(), chan:%d\n", __func__,
1634 ieee->current_network.channel);
1697 HTSetConnectBwMode(ieee, HT_CHANNEL_WIDTH_20, HT_EXTCHNL_OFFSET_NO_EXT); 1635 HTSetConnectBwMode(ieee, HT_CHANNEL_WIDTH_20, HT_EXTCHNL_OFFSET_NO_EXT);
1698 if (ieee->eRFPowerState == eRfOff) 1636 if (ieee->eRFPowerState == eRfOff) {
1699 { 1637 RT_TRACE(COMP_DBG, "=============>%s():Rf state is eRfOff,"
1700 RT_TRACE(COMP_DBG, "=============>%s():Rf state is eRfOff, schedule ipsleave wq again,return\n",__func__); 1638 " schedule ipsleave wq again,return\n", __func__);
1701 if (ieee->rtllib_ips_leave_wq != NULL) 1639 if (ieee->rtllib_ips_leave_wq != NULL)
1702 ieee->rtllib_ips_leave_wq(ieee->dev); 1640 ieee->rtllib_ips_leave_wq(ieee->dev);
1703 up(&ieee->wx_sem); 1641 up(&ieee->wx_sem);
@@ -1710,12 +1648,13 @@ void rtllib_associate_procedure_wq(void *data)
1710 up(&ieee->wx_sem); 1648 up(&ieee->wx_sem);
1711} 1649}
1712 1650
1713inline void rtllib_softmac_new_net(struct rtllib_device *ieee, struct rtllib_network *net) 1651inline void rtllib_softmac_new_net(struct rtllib_device *ieee,
1652 struct rtllib_network *net)
1714{ 1653{
1715 u8 tmp_ssid[IW_ESSID_MAX_SIZE+1]; 1654 u8 tmp_ssid[IW_ESSID_MAX_SIZE + 1];
1716 int tmp_ssid_len = 0; 1655 int tmp_ssid_len = 0;
1717 1656
1718 short apset,ssidset,ssidbroad,apmatch,ssidmatch; 1657 short apset, ssidset, ssidbroad, apmatch, ssidmatch;
1719 1658
1720 /* we are interested in new new only if we are not associated 1659 /* we are interested in new new only if we are not associated
1721 * and we are not associating / authenticating 1660 * and we are not associating / authenticating
@@ -1723,103 +1662,124 @@ inline void rtllib_softmac_new_net(struct rtllib_device *ieee, struct rtllib_net
1723 if (ieee->state != RTLLIB_NOLINK) 1662 if (ieee->state != RTLLIB_NOLINK)
1724 return; 1663 return;
1725 1664
1726 if ((ieee->iw_mode == IW_MODE_INFRA) && !(net->capability & WLAN_CAPABILITY_ESS)) 1665 if ((ieee->iw_mode == IW_MODE_INFRA) && !(net->capability &
1666 WLAN_CAPABILITY_ESS))
1727 return; 1667 return;
1728 1668
1729 if ((ieee->iw_mode == IW_MODE_ADHOC) && !(net->capability & WLAN_CAPABILITY_IBSS)) 1669 if ((ieee->iw_mode == IW_MODE_ADHOC) && !(net->capability &
1670 WLAN_CAPABILITY_IBSS))
1730 return; 1671 return;
1731 1672
1732 if ((ieee->iw_mode == IW_MODE_ADHOC) && (net->channel > ieee->ibss_maxjoin_chal)) { 1673 if ((ieee->iw_mode == IW_MODE_ADHOC) &&
1674 (net->channel > ieee->ibss_maxjoin_chal))
1733 return; 1675 return;
1734 } 1676 if (ieee->iw_mode == IW_MODE_INFRA || ieee->iw_mode == IW_MODE_ADHOC) {
1735 if (ieee->iw_mode == IW_MODE_INFRA || ieee->iw_mode == IW_MODE_ADHOC)
1736 {
1737 /* if the user specified the AP MAC, we need also the essid 1677 /* if the user specified the AP MAC, we need also the essid
1738 * This could be obtained by beacons or, if the network does not 1678 * This could be obtained by beacons or, if the network does not
1739 * broadcast it, it can be put manually. 1679 * broadcast it, it can be put manually.
1740 */ 1680 */
1741 apset = ieee->wap_set; 1681 apset = ieee->wap_set;
1742 ssidset = ieee->ssid_set; 1682 ssidset = ieee->ssid_set;
1743 ssidbroad = !(net->ssid_len == 0 || net->ssid[0]== '\0'); 1683 ssidbroad = !(net->ssid_len == 0 || net->ssid[0] == '\0');
1744 apmatch = (memcmp(ieee->current_network.bssid, net->bssid, ETH_ALEN)==0); 1684 apmatch = (memcmp(ieee->current_network.bssid, net->bssid,
1745 if (!ssidbroad){ 1685 ETH_ALEN) == 0);
1746 ssidmatch = (ieee->current_network.ssid_len == net->hidden_ssid_len)&&\ 1686 if (!ssidbroad) {
1747 (!strncmp(ieee->current_network.ssid, net->hidden_ssid, net->hidden_ssid_len)); 1687 ssidmatch = (ieee->current_network.ssid_len ==
1748 if (net->hidden_ssid_len > 0) 1688 net->hidden_ssid_len) &&
1749 { 1689 (!strncmp(ieee->current_network.ssid,
1750 strncpy(net->ssid, net->hidden_ssid, net->hidden_ssid_len); 1690 net->hidden_ssid, net->hidden_ssid_len));
1751 net->ssid_len = net->hidden_ssid_len; 1691 if (net->hidden_ssid_len > 0) {
1752 ssidbroad = 1; 1692 strncpy(net->ssid, net->hidden_ssid,
1753 } 1693 net->hidden_ssid_len);
1754 } 1694 net->ssid_len = net->hidden_ssid_len;
1755 else 1695 ssidbroad = 1;
1756 ssidmatch = (ieee->current_network.ssid_len == net->ssid_len)&&\ 1696 }
1757 (!strncmp(ieee->current_network.ssid, net->ssid, net->ssid_len)); 1697 } else
1758 1698 ssidmatch =
1759 if ( /* if the user set the AP check if match. 1699 (ieee->current_network.ssid_len == net->ssid_len) &&
1760 * if the network does not broadcast essid we check the user supplyed ANY essid 1700 (!strncmp(ieee->current_network.ssid, net->ssid,
1761 * if the network does broadcast and the user does not set essid it is OK 1701 net->ssid_len));
1762 * if the network does broadcast and the user did set essid chech if essid match 1702
1763 */ 1703 /* if the user set the AP check if match.
1764 ( apset && apmatch && 1704 * if the network does not broadcast essid we check the
1765 ((ssidset && ssidbroad && ssidmatch) || (ssidbroad && !ssidset) || (!ssidbroad && ssidset)) ) 1705 * user supplyed ANY essid
1766 /* if the ap is not set, check that the user set the bssid 1706 * if the network does broadcast and the user does not set
1767 * and the network does bradcast and that those two bssid matches 1707 * essid it is OK
1768 */ 1708 * if the network does broadcast and the user did set essid
1769 || (!apset && ssidset && ssidbroad && ssidmatch) || (ieee->is_roaming && ssidset && ssidbroad && ssidmatch) 1709 * check if essid match
1770 ){ 1710 * if the ap is not set, check that the user set the bssid
1771 /* if the essid is hidden replace it with the 1711 * and the network does bradcast and that those two bssid match
1772 * essid provided by the user. 1712 */
1773 */ 1713 if ((apset && apmatch &&
1774 if (!ssidbroad){ 1714 ((ssidset && ssidbroad && ssidmatch) ||
1775 strncpy(tmp_ssid, ieee->current_network.ssid, IW_ESSID_MAX_SIZE); 1715 (ssidbroad && !ssidset) || (!ssidbroad && ssidset))) ||
1776 tmp_ssid_len = ieee->current_network.ssid_len; 1716 (!apset && ssidset && ssidbroad && ssidmatch) ||
1777 } 1717 (ieee->is_roaming && ssidset && ssidbroad && ssidmatch)) {
1778 memcpy(&ieee->current_network, net, sizeof(struct rtllib_network)); 1718 /* if the essid is hidden replace it with the
1779 if (!ssidbroad){ 1719 * essid provided by the user.
1780 strncpy(ieee->current_network.ssid, tmp_ssid, IW_ESSID_MAX_SIZE); 1720 */
1781 ieee->current_network.ssid_len = tmp_ssid_len; 1721 if (!ssidbroad) {
1782 } 1722 strncpy(tmp_ssid, ieee->current_network.ssid,
1783 printk(KERN_INFO"Linking with %s,channel:%d, qos:%d, myHT:%d, networkHT:%d, mode:%x cur_net.flags:0x%x\n",ieee->current_network.ssid,ieee->current_network.channel, ieee->current_network.qos_data.supported, ieee->pHTInfo->bEnableHT, ieee->current_network.bssht.bdSupportHT, ieee->current_network.mode, ieee->current_network.flags); 1723 IW_ESSID_MAX_SIZE);
1784 1724 tmp_ssid_len = ieee->current_network.ssid_len;
1785 if ((rtllib_act_scanning(ieee, false)) && !(ieee->softmac_features & IEEE_SOFTMAC_SCAN)){ 1725 }
1786 rtllib_stop_scan_syncro(ieee); 1726 memcpy(&ieee->current_network, net,
1787 } 1727 sizeof(struct rtllib_network));
1788 1728 if (!ssidbroad) {
1789 ieee->hwscan_ch_bk = ieee->current_network.channel; 1729 strncpy(ieee->current_network.ssid, tmp_ssid,
1790 HTResetIOTSetting(ieee->pHTInfo); 1730 IW_ESSID_MAX_SIZE);
1791 ieee->wmm_acm = 0; 1731 ieee->current_network.ssid_len = tmp_ssid_len;
1792 if (ieee->iw_mode == IW_MODE_INFRA) { 1732 }
1793 /* Join the network for the first time */ 1733 printk(KERN_INFO"Linking with %s,channel:%d, qos:%d, "
1794 ieee->AsocRetryCount = 0; 1734 "myHT:%d, networkHT:%d, mode:%x cur_net.flags"
1795 if ((ieee->current_network.qos_data.supported == 1) && 1735 ":0x%x\n", ieee->current_network.ssid,
1796 ieee->current_network.bssht.bdSupportHT) 1736 ieee->current_network.channel,
1797 HTResetSelfAndSavePeerSetting(ieee, &(ieee->current_network)); 1737 ieee->current_network.qos_data.supported,
1798 else 1738 ieee->pHTInfo->bEnableHT,
1799 ieee->pHTInfo->bCurrentHTSupport = false; 1739 ieee->current_network.bssht.bdSupportHT,
1800 1740 ieee->current_network.mode,
1801 ieee->state = RTLLIB_ASSOCIATING; 1741 ieee->current_network.flags);
1802 if (ieee->LedControlHandler != NULL) 1742
1803 ieee->LedControlHandler(ieee->dev, LED_CTL_START_TO_LINK); 1743 if ((rtllib_act_scanning(ieee, false)) &&
1804 queue_delayed_work_rsl(ieee->wq, &ieee->associate_procedure_wq, 0); 1744 !(ieee->softmac_features & IEEE_SOFTMAC_SCAN))
1745 rtllib_stop_scan_syncro(ieee);
1746
1747 ieee->hwscan_ch_bk = ieee->current_network.channel;
1748 HTResetIOTSetting(ieee->pHTInfo);
1749 ieee->wmm_acm = 0;
1750 if (ieee->iw_mode == IW_MODE_INFRA) {
1751 /* Join the network for the first time */
1752 ieee->AsocRetryCount = 0;
1753 if ((ieee->current_network.qos_data.supported == 1) &&
1754 ieee->current_network.bssht.bdSupportHT)
1755 HTResetSelfAndSavePeerSetting(ieee,
1756 &(ieee->current_network));
1757 else
1758 ieee->pHTInfo->bCurrentHTSupport =
1759 false;
1760
1761 ieee->state = RTLLIB_ASSOCIATING;
1762 if (ieee->LedControlHandler != NULL)
1763 ieee->LedControlHandler(ieee->dev,
1764 LED_CTL_START_TO_LINK);
1765 queue_delayed_work_rsl(ieee->wq,
1766 &ieee->associate_procedure_wq, 0);
1767 } else {
1768 if (rtllib_is_54g(&ieee->current_network) &&
1769 (ieee->modulation & RTLLIB_OFDM_MODULATION)) {
1770 ieee->rate = 108;
1771 ieee->SetWirelessMode(ieee->dev, IEEE_G);
1772 printk(KERN_INFO"Using G rates\n");
1805 } else { 1773 } else {
1806 if (rtllib_is_54g(&ieee->current_network) && 1774 ieee->rate = 22;
1807 (ieee->modulation & RTLLIB_OFDM_MODULATION)){ 1775 ieee->SetWirelessMode(ieee->dev, IEEE_B);
1808 ieee->rate = 108; 1776 printk(KERN_INFO"Using B rates\n");
1809 ieee->SetWirelessMode(ieee->dev, IEEE_G);
1810 printk(KERN_INFO"Using G rates\n");
1811 }else{
1812 ieee->rate = 22;
1813 ieee->SetWirelessMode(ieee->dev, IEEE_B);
1814 printk(KERN_INFO"Using B rates\n");
1815 }
1816 memset(ieee->dot11HTOperationalRateSet, 0, 16);
1817 ieee->state = RTLLIB_LINKED;
1818 } 1777 }
1819 1778 memset(ieee->dot11HTOperationalRateSet, 0, 16);
1779 ieee->state = RTLLIB_LINKED;
1780 }
1820 } 1781 }
1821 } 1782 }
1822
1823} 1783}
1824 1784
1825void rtllib_softmac_check_all_nets(struct rtllib_device *ieee) 1785void rtllib_softmac_check_all_nets(struct rtllib_device *ieee)
@@ -1838,51 +1798,49 @@ void rtllib_softmac_check_all_nets(struct rtllib_device *ieee)
1838 if (ieee->state != RTLLIB_NOLINK) 1798 if (ieee->state != RTLLIB_NOLINK)
1839 break; 1799 break;
1840 1800
1841 if (ieee->scan_age == 0 || time_after(target->last_scanned + ieee->scan_age, jiffies)) 1801 if (ieee->scan_age == 0 || time_after(target->last_scanned +
1842 rtllib_softmac_new_net(ieee, target); 1802 ieee->scan_age, jiffies))
1803 rtllib_softmac_new_net(ieee, target);
1843 } 1804 }
1844
1845 spin_unlock_irqrestore(&ieee->lock, flags); 1805 spin_unlock_irqrestore(&ieee->lock, flags);
1846
1847} 1806}
1848 1807
1849
1850static inline u16 auth_parse(struct sk_buff *skb, u8** challenge, int *chlen) 1808static inline u16 auth_parse(struct sk_buff *skb, u8** challenge, int *chlen)
1851{ 1809{
1852 struct rtllib_authentication *a; 1810 struct rtllib_authentication *a;
1853 u8 *t; 1811 u8 *t;
1854 if (skb->len < (sizeof(struct rtllib_authentication)-sizeof(struct rtllib_info_element))){ 1812 if (skb->len < (sizeof(struct rtllib_authentication) -
1855 RTLLIB_DEBUG_MGMT("invalid len in auth resp: %d\n",skb->len); 1813 sizeof(struct rtllib_info_element))) {
1814 RTLLIB_DEBUG_MGMT("invalid len in auth resp: %d\n", skb->len);
1856 return 0xcafe; 1815 return 0xcafe;
1857 } 1816 }
1858 *challenge = NULL; 1817 *challenge = NULL;
1859 a = (struct rtllib_authentication*) skb->data; 1818 a = (struct rtllib_authentication *) skb->data;
1860 if (skb->len > (sizeof(struct rtllib_authentication) +3)){ 1819 if (skb->len > (sizeof(struct rtllib_authentication) + 3)) {
1861 t = skb->data + sizeof(struct rtllib_authentication); 1820 t = skb->data + sizeof(struct rtllib_authentication);
1862 1821
1863 if (*(t++) == MFIE_TYPE_CHALLENGE){ 1822 if (*(t++) == MFIE_TYPE_CHALLENGE) {
1864 *chlen = *(t++); 1823 *chlen = *(t++);
1865 *challenge = (u8*)kmalloc(*chlen, GFP_ATOMIC); 1824 *challenge = kmalloc(*chlen, GFP_ATOMIC);
1866 memcpy(*challenge, t, *chlen); 1825 memcpy(*challenge, t, *chlen); /*TODO - check here*/
1867 } 1826 }
1868 } 1827 }
1869
1870 return cpu_to_le16(a->status); 1828 return cpu_to_le16(a->status);
1871
1872} 1829}
1873 1830
1874 1831int auth_rq_parse(struct sk_buff *skb, u8 *dest)
1875int auth_rq_parse(struct sk_buff *skb,u8* dest)
1876{ 1832{
1877 struct rtllib_authentication *a; 1833 struct rtllib_authentication *a;
1878 1834
1879 if (skb->len < (sizeof(struct rtllib_authentication)-sizeof(struct rtllib_info_element))){ 1835 if (skb->len < (sizeof(struct rtllib_authentication) -
1880 RTLLIB_DEBUG_MGMT("invalid len in auth request: %d\n",skb->len); 1836 sizeof(struct rtllib_info_element))) {
1837 RTLLIB_DEBUG_MGMT("invalid len in auth request: %d\n",
1838 skb->len);
1881 return -1; 1839 return -1;
1882 } 1840 }
1883 a = (struct rtllib_authentication*) skb->data; 1841 a = (struct rtllib_authentication *) skb->data;
1884 1842
1885 memcpy(dest,a->header.addr2, ETH_ALEN); 1843 memcpy(dest, a->header.addr2, ETH_ALEN);
1886 1844
1887 if (le16_to_cpu(a->algorithm) != WLAN_AUTH_OPEN) 1845 if (le16_to_cpu(a->algorithm) != WLAN_AUTH_OPEN)
1888 return WLAN_STATUS_NOT_SUPPORTED_AUTH_ALG; 1846 return WLAN_STATUS_NOT_SUPPORTED_AUTH_ALG;
@@ -1890,38 +1848,36 @@ int auth_rq_parse(struct sk_buff *skb,u8* dest)
1890 return WLAN_STATUS_SUCCESS; 1848 return WLAN_STATUS_SUCCESS;
1891} 1849}
1892 1850
1893static short probe_rq_parse(struct rtllib_device *ieee, struct sk_buff *skb, u8 *src) 1851static short probe_rq_parse(struct rtllib_device *ieee, struct sk_buff *skb,
1852 u8 *src)
1894{ 1853{
1895 u8 *tag; 1854 u8 *tag;
1896 u8 *skbend; 1855 u8 *skbend;
1897 u8 *ssid=NULL; 1856 u8 *ssid = NULL;
1898 u8 ssidlen = 0; 1857 u8 ssidlen = 0;
1899
1900 struct rtllib_hdr_3addr *header = 1858 struct rtllib_hdr_3addr *header =
1901 (struct rtllib_hdr_3addr *) skb->data; 1859 (struct rtllib_hdr_3addr *) skb->data;
1860 bool bssid_match;
1902 1861
1903 if (skb->len < sizeof (struct rtllib_hdr_3addr )) 1862 if (skb->len < sizeof(struct rtllib_hdr_3addr))
1904 return -1; /* corrupted */ 1863 return -1; /* corrupted */
1905 if ((memcmp(header->addr3,ieee->current_network.bssid,ETH_ALEN) != 0)&&
1906 (memcmp(header->addr3,"\xff\xff\xff\xff\xff\xff",ETH_ALEN) != 0)) {
1907 return -1;
1908 }
1909 1864
1910 if (memcmp(header->addr3,ieee->current_network.bssid,ETH_ALEN) == 0) { 1865 bssid_match =
1911 } 1866 (memcmp(header->addr3, ieee->current_network.bssid, ETH_ALEN) != 0) &&
1867 (memcmp(header->addr3, "\xff\xff\xff\xff\xff\xff", ETH_ALEN) != 0);
1868 if (bssid_match)
1869 return -1;
1912 1870
1913 if (memcmp(header->addr3,"\xff\xff\xff\xff\xff\xff",ETH_ALEN) == 0) { 1871 memcpy(src, header->addr2, ETH_ALEN);
1914 }
1915 memcpy(src,header->addr2, ETH_ALEN);
1916 1872
1917 skbend = (u8*)skb->data + skb->len; 1873 skbend = (u8 *)skb->data + skb->len;
1918 1874
1919 tag = skb->data + sizeof (struct rtllib_hdr_3addr ); 1875 tag = skb->data + sizeof(struct rtllib_hdr_3addr);
1920 1876
1921 while (tag+1 < skbend){ 1877 while (tag + 1 < skbend) {
1922 if (*tag == 0){ 1878 if (*tag == 0) {
1923 ssid = tag+2; 1879 ssid = tag + 2;
1924 ssidlen = *(tag+1); 1880 ssidlen = *(tag + 1);
1925 break; 1881 break;
1926 } 1882 }
1927 tag++; /* point to the len field */ 1883 tag++; /* point to the len field */
@@ -1929,53 +1885,56 @@ static short probe_rq_parse(struct rtllib_device *ieee, struct sk_buff *skb, u8
1929 tag++; /* point to the next tag */ 1885 tag++; /* point to the next tag */
1930 } 1886 }
1931 1887
1932 if (ssidlen == 0) return 1; 1888 if (ssidlen == 0)
1889 return 1;
1933 1890
1934 if (!ssid) return 1; /* ssid not found in tagged param */ 1891 if (!ssid)
1935 return (!strncmp(ssid, ieee->current_network.ssid, ssidlen)); 1892 return 1; /* ssid not found in tagged param */
1936 1893
1894 return !strncmp(ssid, ieee->current_network.ssid, ssidlen);
1937} 1895}
1938 1896
1939int assoc_rq_parse(struct sk_buff *skb,u8* dest) 1897int assoc_rq_parse(struct sk_buff *skb, u8 *dest)
1940{ 1898{
1941 struct rtllib_assoc_request_frame *a; 1899 struct rtllib_assoc_request_frame *a;
1942 1900
1943 if (skb->len < (sizeof(struct rtllib_assoc_request_frame) - 1901 if (skb->len < (sizeof(struct rtllib_assoc_request_frame) -
1944 sizeof(struct rtllib_info_element))) { 1902 sizeof(struct rtllib_info_element))) {
1945 1903
1946 RTLLIB_DEBUG_MGMT("invalid len in auth request:%d \n", skb->len); 1904 RTLLIB_DEBUG_MGMT("invalid len in auth request:%d\n", skb->len);
1947 return -1; 1905 return -1;
1948 } 1906 }
1949 1907
1950 a = (struct rtllib_assoc_request_frame*) skb->data; 1908 a = (struct rtllib_assoc_request_frame *) skb->data;
1951 1909
1952 memcpy(dest,a->header.addr2,ETH_ALEN); 1910 memcpy(dest, a->header.addr2, ETH_ALEN);
1953 1911
1954 return 0; 1912 return 0;
1955} 1913}
1956 1914
1957static inline u16 assoc_parse(struct rtllib_device *ieee, struct sk_buff *skb, int *aid) 1915static inline u16 assoc_parse(struct rtllib_device *ieee, struct sk_buff *skb,
1916 int *aid)
1958{ 1917{
1959 struct rtllib_assoc_response_frame *response_head; 1918 struct rtllib_assoc_response_frame *response_head;
1960 u16 status_code; 1919 u16 status_code;
1961 1920
1962 if (skb->len < sizeof(struct rtllib_assoc_response_frame)){ 1921 if (skb->len < sizeof(struct rtllib_assoc_response_frame)) {
1963 RTLLIB_DEBUG_MGMT("invalid len in auth resp: %d\n", skb->len); 1922 RTLLIB_DEBUG_MGMT("invalid len in auth resp: %d\n", skb->len);
1964 return 0xcafe; 1923 return 0xcafe;
1965 } 1924 }
1966 1925
1967 response_head = (struct rtllib_assoc_response_frame*) skb->data; 1926 response_head = (struct rtllib_assoc_response_frame *) skb->data;
1968 *aid = le16_to_cpu(response_head->aid) & 0x3fff; 1927 *aid = le16_to_cpu(response_head->aid) & 0x3fff;
1969 1928
1970 status_code = le16_to_cpu(response_head->status); 1929 status_code = le16_to_cpu(response_head->status);
1971 if ((status_code==WLAN_STATUS_ASSOC_DENIED_RATES || \ 1930 if ((status_code == WLAN_STATUS_ASSOC_DENIED_RATES ||
1972 status_code==WLAN_STATUS_CAPS_UNSUPPORTED)&& 1931 status_code == WLAN_STATUS_CAPS_UNSUPPORTED) &&
1973 ((ieee->mode == IEEE_G) && 1932 ((ieee->mode == IEEE_G) &&
1974 (ieee->current_network.mode == IEEE_N_24G) && 1933 (ieee->current_network.mode == IEEE_N_24G) &&
1975 (ieee->AsocRetryCount++ < (RT_ASOC_RETRY_LIMIT-1)))) { 1934 (ieee->AsocRetryCount++ < (RT_ASOC_RETRY_LIMIT-1)))) {
1976 ieee->pHTInfo->IOTAction |= HT_IOT_ACT_PURE_N_MODE; 1935 ieee->pHTInfo->IOTAction |= HT_IOT_ACT_PURE_N_MODE;
1977 }else { 1936 } else {
1978 ieee->AsocRetryCount = 0; 1937 ieee->AsocRetryCount = 0;
1979 } 1938 }
1980 1939
1981 return le16_to_cpu(response_head->status); 1940 return le16_to_cpu(response_head->status);
@@ -1985,38 +1944,37 @@ void rtllib_rx_probe_rq(struct rtllib_device *ieee, struct sk_buff *skb)
1985{ 1944{
1986 u8 dest[ETH_ALEN]; 1945 u8 dest[ETH_ALEN];
1987 ieee->softmac_stats.rx_probe_rq++; 1946 ieee->softmac_stats.rx_probe_rq++;
1988 if (probe_rq_parse(ieee, skb, dest) > 0){ 1947 if (probe_rq_parse(ieee, skb, dest) > 0) {
1989 ieee->softmac_stats.tx_probe_rs++; 1948 ieee->softmac_stats.tx_probe_rs++;
1990 rtllib_resp_to_probe(ieee, dest); 1949 rtllib_resp_to_probe(ieee, dest);
1991 } 1950 }
1992} 1951}
1993 1952
1994static inline void rtllib_rx_auth_rq(struct rtllib_device *ieee, struct sk_buff *skb) 1953static inline void rtllib_rx_auth_rq(struct rtllib_device *ieee,
1954 struct sk_buff *skb)
1995{ 1955{
1996 u8 dest[ETH_ALEN]; 1956 u8 dest[ETH_ALEN];
1997 int status; 1957 int status;
1998 ieee->softmac_stats.rx_auth_rq++; 1958 ieee->softmac_stats.rx_auth_rq++;
1999 1959
2000 if ((status = auth_rq_parse(skb, dest))!= -1){ 1960 status = auth_rq_parse(skb, dest);
1961 if (status != -1)
2001 rtllib_resp_to_auth(ieee, status, dest); 1962 rtllib_resp_to_auth(ieee, status, dest);
2002 }
2003
2004} 1963}
2005 1964
2006static inline void rtllib_rx_assoc_rq(struct rtllib_device *ieee, struct sk_buff *skb) 1965static inline void rtllib_rx_assoc_rq(struct rtllib_device *ieee,
1966 struct sk_buff *skb)
2007{ 1967{
2008 1968
2009 u8 dest[ETH_ALEN]; 1969 u8 dest[ETH_ALEN];
2010 1970
2011 ieee->softmac_stats.rx_ass_rq++; 1971 ieee->softmac_stats.rx_ass_rq++;
2012 if (assoc_rq_parse(skb,dest) != -1){ 1972 if (assoc_rq_parse(skb, dest) != -1)
2013 rtllib_resp_to_assoc_rq(ieee, dest); 1973 rtllib_resp_to_assoc_rq(ieee, dest);
2014 }
2015 1974
2016 printk(KERN_INFO"New client associated: "MAC_FMT"\n", MAC_ARG(dest)); 1975 printk(KERN_INFO"New client associated: "MAC_FMT"\n", MAC_ARG(dest));
2017} 1976}
2018 1977
2019
2020void rtllib_sta_ps_send_null_frame(struct rtllib_device *ieee, short pwr) 1978void rtllib_sta_ps_send_null_frame(struct rtllib_device *ieee, short pwr)
2021{ 1979{
2022 1980
@@ -2024,34 +1982,25 @@ void rtllib_sta_ps_send_null_frame(struct rtllib_device *ieee, short pwr)
2024 1982
2025 if (buf) 1983 if (buf)
2026 softmac_ps_mgmt_xmit(buf, ieee); 1984 softmac_ps_mgmt_xmit(buf, ieee);
2027
2028} 1985}
2029 1986
2030void rtllib_sta_ps_send_pspoll_frame(struct rtllib_device *ieee) 1987void rtllib_sta_ps_send_pspoll_frame(struct rtllib_device *ieee)
2031{ 1988{
2032
2033 struct sk_buff *buf = rtllib_pspoll_func(ieee); 1989 struct sk_buff *buf = rtllib_pspoll_func(ieee);
2034 1990
2035 if (buf) 1991 if (buf)
2036 softmac_ps_mgmt_xmit(buf, ieee); 1992 softmac_ps_mgmt_xmit(buf, ieee);
2037
2038} 1993}
2039 1994
2040static short rtllib_sta_ps_sleep(struct rtllib_device *ieee, u64 *time) 1995static short rtllib_sta_ps_sleep(struct rtllib_device *ieee, u64 *time)
2041{ 1996{
2042 int timeout = ieee->ps_timeout; 1997 int timeout = ieee->ps_timeout;
2043 u8 dtim; 1998 u8 dtim;
2044 struct rt_pwr_save_ctrl *pPSC = (struct rt_pwr_save_ctrl *)(&(ieee->PowerSaveControl)); 1999 struct rt_pwr_save_ctrl *pPSC = (struct rt_pwr_save_ctrl *)
2045 /*if (ieee->ps == RTLLIB_PS_DISABLED || 2000 (&(ieee->PowerSaveControl));
2046 ieee->iw_mode != IW_MODE_INFRA ||
2047 ieee->state != RTLLIB_LINKED)
2048
2049 return 0;
2050 */
2051 2001
2052 if (ieee->LPSDelayCnt) 2002 if (ieee->LPSDelayCnt) {
2053 { 2003 ieee->LPSDelayCnt--;
2054 ieee->LPSDelayCnt --;
2055 return 0; 2004 return 0;
2056 } 2005 }
2057 2006
@@ -2060,21 +2009,20 @@ static short rtllib_sta_ps_sleep(struct rtllib_device *ieee, u64 *time)
2060 return 0; 2009 return 0;
2061 timeout = ieee->current_network.beacon_interval; 2010 timeout = ieee->current_network.beacon_interval;
2062 ieee->current_network.dtim_data = RTLLIB_DTIM_INVALID; 2011 ieee->current_network.dtim_data = RTLLIB_DTIM_INVALID;
2063 /* there's no need to nofity AP that I find you buffered with broadcast packet */ 2012 /* there's no need to nofity AP that I find you buffered
2013 * with broadcast packet */
2064 if (dtim & (RTLLIB_DTIM_UCAST & ieee->ps)) 2014 if (dtim & (RTLLIB_DTIM_UCAST & ieee->ps))
2065 return 2; 2015 return 2;
2066 2016
2067 if (!time_after(jiffies, ieee->dev->trans_start + MSECS(timeout))){ 2017 if (!time_after(jiffies, ieee->dev->trans_start + MSECS(timeout)))
2068 return 0; 2018 return 0;
2069 } 2019 if (!time_after(jiffies, ieee->last_rx_ps_time + MSECS(timeout)))
2070 if (!time_after(jiffies, ieee->last_rx_ps_time + MSECS(timeout))){
2071 return 0; 2020 return 0;
2072 } 2021 if ((ieee->softmac_features & IEEE_SOFTMAC_SINGLE_QUEUE) &&
2073 if ((ieee->softmac_features & IEEE_SOFTMAC_SINGLE_QUEUE ) && 2022 (ieee->mgmt_queue_tail != ieee->mgmt_queue_head))
2074 (ieee->mgmt_queue_tail != ieee->mgmt_queue_head))
2075 return 0; 2023 return 0;
2076 2024
2077 if (time){ 2025 if (time) {
2078 if (ieee->bAwakePktSent == true) { 2026 if (ieee->bAwakePktSent == true) {
2079 pPSC->LPSAwakeIntvl = 1; 2027 pPSC->LPSAwakeIntvl = 1;
2080 } else { 2028 } else {
@@ -2088,27 +2036,37 @@ static short rtllib_sta_ps_sleep(struct rtllib_device *ieee, u64 *time)
2088 MaxPeriod = ieee->current_network.dtim_period; 2036 MaxPeriod = ieee->current_network.dtim_period;
2089 else 2037 else
2090 MaxPeriod = pPSC->RegMaxLPSAwakeIntvl; 2038 MaxPeriod = pPSC->RegMaxLPSAwakeIntvl;
2091 pPSC->LPSAwakeIntvl = (pPSC->LPSAwakeIntvl >= MaxPeriod) ? MaxPeriod : (pPSC->LPSAwakeIntvl + 1); 2039 pPSC->LPSAwakeIntvl = (pPSC->LPSAwakeIntvl >=
2040 MaxPeriod) ? MaxPeriod :
2041 (pPSC->LPSAwakeIntvl + 1);
2092 } 2042 }
2093 { 2043 {
2094 u8 LPSAwakeIntvl_tmp = 0; 2044 u8 LPSAwakeIntvl_tmp = 0;
2095 u8 period = ieee->current_network.dtim_period; 2045 u8 period = ieee->current_network.dtim_period;
2096 u8 count = ieee->current_network.tim.tim_count; 2046 u8 count = ieee->current_network.tim.tim_count;
2097 if (count == 0 ) { 2047 if (count == 0) {
2098 if (pPSC->LPSAwakeIntvl > period) 2048 if (pPSC->LPSAwakeIntvl > period)
2099 LPSAwakeIntvl_tmp = period + (pPSC->LPSAwakeIntvl - period) -((pPSC->LPSAwakeIntvl-period)%period); 2049 LPSAwakeIntvl_tmp = period +
2050 (pPSC->LPSAwakeIntvl -
2051 period) -
2052 ((pPSC->LPSAwakeIntvl-period) %
2053 period);
2100 else 2054 else
2101 LPSAwakeIntvl_tmp = pPSC->LPSAwakeIntvl; 2055 LPSAwakeIntvl_tmp = pPSC->LPSAwakeIntvl;
2102 2056
2103 } else { 2057 } else {
2104 if (pPSC->LPSAwakeIntvl > ieee->current_network.tim.tim_count) 2058 if (pPSC->LPSAwakeIntvl >
2105 LPSAwakeIntvl_tmp = count + (pPSC->LPSAwakeIntvl - count) -((pPSC->LPSAwakeIntvl-count)%period); 2059 ieee->current_network.tim.tim_count)
2060 LPSAwakeIntvl_tmp = count +
2061 (pPSC->LPSAwakeIntvl - count) -
2062 ((pPSC->LPSAwakeIntvl-count)%period);
2106 else 2063 else
2107 LPSAwakeIntvl_tmp = pPSC->LPSAwakeIntvl; 2064 LPSAwakeIntvl_tmp = pPSC->LPSAwakeIntvl;
2108 } 2065 }
2109 2066
2110 *time = ieee->current_network.last_dtim_sta_time 2067 *time = ieee->current_network.last_dtim_sta_time
2111 + MSECS(ieee->current_network.beacon_interval * LPSAwakeIntvl_tmp); 2068 + MSECS(ieee->current_network.beacon_interval *
2069 LPSAwakeIntvl_tmp);
2112 } 2070 }
2113 } 2071 }
2114 2072
@@ -2119,45 +2077,38 @@ static short rtllib_sta_ps_sleep(struct rtllib_device *ieee, u64 *time)
2119 2077
2120inline void rtllib_sta_ps(struct rtllib_device *ieee) 2078inline void rtllib_sta_ps(struct rtllib_device *ieee)
2121{ 2079{
2122
2123 u64 time; 2080 u64 time;
2124 short sleep; 2081 short sleep;
2125 2082 unsigned long flags, flags2;
2126 unsigned long flags,flags2;
2127 2083
2128 spin_lock_irqsave(&ieee->lock, flags); 2084 spin_lock_irqsave(&ieee->lock, flags);
2129 2085
2130 if ((ieee->ps == RTLLIB_PS_DISABLED || 2086 if ((ieee->ps == RTLLIB_PS_DISABLED ||
2131 ieee->iw_mode != IW_MODE_INFRA || 2087 ieee->iw_mode != IW_MODE_INFRA ||
2132 ieee->state != RTLLIB_LINKED)){ 2088 ieee->state != RTLLIB_LINKED)) {
2133 2089 RT_TRACE(COMP_DBG, "=====>%s(): no need to ps,wake up!! "
2134 RT_TRACE(COMP_DBG, "=====>%s(): no need to ps,wake up!! ieee->ps is %d,ieee->iw_mode is %d,ieee->state is %d\n", 2090 "ieee->ps is %d, ieee->iw_mode is %d, ieee->state"
2135 __func__,ieee->ps,ieee->iw_mode,ieee->state); 2091 " is %d\n", __func__, ieee->ps, ieee->iw_mode,
2092 ieee->state);
2136 spin_lock_irqsave(&ieee->mgmt_tx_lock, flags2); 2093 spin_lock_irqsave(&ieee->mgmt_tx_lock, flags2);
2137
2138 rtllib_sta_wakeup(ieee, 1); 2094 rtllib_sta_wakeup(ieee, 1);
2139 2095
2140 spin_unlock_irqrestore(&ieee->mgmt_tx_lock, flags2); 2096 spin_unlock_irqrestore(&ieee->mgmt_tx_lock, flags2);
2141 } 2097 }
2142
2143 sleep = rtllib_sta_ps_sleep(ieee, &time); 2098 sleep = rtllib_sta_ps_sleep(ieee, &time);
2144 /* 2 wake, 1 sleep, 0 do nothing */ 2099 /* 2 wake, 1 sleep, 0 do nothing */
2145 if (sleep == 0) 2100 if (sleep == 0)
2146 {
2147 goto out; 2101 goto out;
2148 } 2102 if (sleep == 1) {
2149 if (sleep == 1){ 2103 if (ieee->sta_sleep == LPS_IS_SLEEP) {
2150 if (ieee->sta_sleep == LPS_IS_SLEEP){
2151 ieee->enter_sleep_state(ieee->dev, time); 2104 ieee->enter_sleep_state(ieee->dev, time);
2152 } 2105 } else if (ieee->sta_sleep == LPS_IS_WAKE) {
2153
2154 else if (ieee->sta_sleep == LPS_IS_WAKE){
2155 spin_lock_irqsave(&ieee->mgmt_tx_lock, flags2); 2106 spin_lock_irqsave(&ieee->mgmt_tx_lock, flags2);
2156 2107
2157 if (ieee->ps_is_queue_empty(ieee->dev)){ 2108 if (ieee->ps_is_queue_empty(ieee->dev)) {
2158 ieee->sta_sleep = LPS_WAIT_NULL_DATA_SEND; 2109 ieee->sta_sleep = LPS_WAIT_NULL_DATA_SEND;
2159 ieee->ack_tx_to_ieee = 1; 2110 ieee->ack_tx_to_ieee = 1;
2160 rtllib_sta_ps_send_null_frame(ieee,1); 2111 rtllib_sta_ps_send_null_frame(ieee, 1);
2161 ieee->ps_time = time; 2112 ieee->ps_time = time;
2162 } 2113 }
2163 spin_unlock_irqrestore(&ieee->mgmt_tx_lock, flags2); 2114 spin_unlock_irqrestore(&ieee->mgmt_tx_lock, flags2);
@@ -2166,10 +2117,10 @@ inline void rtllib_sta_ps(struct rtllib_device *ieee)
2166 2117
2167 ieee->bAwakePktSent = false; 2118 ieee->bAwakePktSent = false;
2168 2119
2169 }else if (sleep == 2){ 2120 } else if (sleep == 2) {
2170 spin_lock_irqsave(&ieee->mgmt_tx_lock, flags2); 2121 spin_lock_irqsave(&ieee->mgmt_tx_lock, flags2);
2171 2122
2172 rtllib_sta_wakeup(ieee,1); 2123 rtllib_sta_wakeup(ieee, 1);
2173 2124
2174 spin_unlock_irqrestore(&ieee->mgmt_tx_lock, flags2); 2125 spin_unlock_irqrestore(&ieee->mgmt_tx_lock, flags2);
2175 } 2126 }
@@ -2181,15 +2132,13 @@ out:
2181 2132
2182void rtllib_sta_wakeup(struct rtllib_device *ieee, short nl) 2133void rtllib_sta_wakeup(struct rtllib_device *ieee, short nl)
2183{ 2134{
2184 if (ieee->sta_sleep == LPS_IS_WAKE){ 2135 if (ieee->sta_sleep == LPS_IS_WAKE) {
2185 if (nl){ 2136 if (nl) {
2186 if (ieee->pHTInfo->IOTAction & HT_IOT_ACT_NULL_DATA_POWER_SAVING) 2137 if (ieee->pHTInfo->IOTAction &
2187 { 2138 HT_IOT_ACT_NULL_DATA_POWER_SAVING) {
2188 ieee->ack_tx_to_ieee = 1; 2139 ieee->ack_tx_to_ieee = 1;
2189 rtllib_sta_ps_send_null_frame(ieee, 0); 2140 rtllib_sta_ps_send_null_frame(ieee, 0);
2190 } 2141 } else {
2191 else
2192 {
2193 ieee->ack_tx_to_ieee = 1; 2142 ieee->ack_tx_to_ieee = 1;
2194 rtllib_sta_ps_send_pspoll_frame(ieee); 2143 rtllib_sta_ps_send_pspoll_frame(ieee);
2195 } 2144 }
@@ -2200,19 +2149,12 @@ void rtllib_sta_wakeup(struct rtllib_device *ieee, short nl)
2200 2149
2201 if (ieee->sta_sleep == LPS_IS_SLEEP) 2150 if (ieee->sta_sleep == LPS_IS_SLEEP)
2202 ieee->sta_wake_up(ieee->dev); 2151 ieee->sta_wake_up(ieee->dev);
2203 if (nl){ 2152 if (nl) {
2204 /* 2153 if (ieee->pHTInfo->IOTAction &
2154 HT_IOT_ACT_NULL_DATA_POWER_SAVING) {
2205 ieee->ack_tx_to_ieee = 1; 2155 ieee->ack_tx_to_ieee = 1;
2206 printk("%s(3): notify AP we are awaked ++++++++++ SendNullFunctionData\n", __func__);
2207 rtllib_sta_ps_send_null_frame(ieee, 0); 2156 rtllib_sta_ps_send_null_frame(ieee, 0);
2208 */ 2157 } else {
2209 if (ieee->pHTInfo->IOTAction & HT_IOT_ACT_NULL_DATA_POWER_SAVING)
2210 {
2211 ieee->ack_tx_to_ieee = 1;
2212 rtllib_sta_ps_send_null_frame(ieee, 0);
2213 }
2214 else
2215 {
2216 ieee->ack_tx_to_ieee = 1; 2158 ieee->ack_tx_to_ieee = 1;
2217 ieee->polling = true; 2159 ieee->polling = true;
2218 rtllib_sta_ps_send_pspoll_frame(ieee); 2160 rtllib_sta_ps_send_pspoll_frame(ieee);
@@ -2226,13 +2168,13 @@ void rtllib_sta_wakeup(struct rtllib_device *ieee, short nl)
2226 2168
2227void rtllib_ps_tx_ack(struct rtllib_device *ieee, short success) 2169void rtllib_ps_tx_ack(struct rtllib_device *ieee, short success)
2228{ 2170{
2229 unsigned long flags,flags2; 2171 unsigned long flags, flags2;
2230 2172
2231 spin_lock_irqsave(&ieee->lock, flags); 2173 spin_lock_irqsave(&ieee->lock, flags);
2232 2174
2233 if (ieee->sta_sleep == LPS_WAIT_NULL_DATA_SEND){ 2175 if (ieee->sta_sleep == LPS_WAIT_NULL_DATA_SEND) {
2234 /* Null frame with PS bit set */ 2176 /* Null frame with PS bit set */
2235 if (success){ 2177 if (success) {
2236 ieee->sta_sleep = LPS_IS_SLEEP; 2178 ieee->sta_sleep = LPS_IS_SLEEP;
2237 ieee->enter_sleep_state(ieee->dev, ieee->ps_time); 2179 ieee->enter_sleep_state(ieee->dev, ieee->ps_time);
2238 } 2180 }
@@ -2241,199 +2183,208 @@ void rtllib_ps_tx_ack(struct rtllib_device *ieee, short success)
2241 */ 2183 */
2242 } else {/* 21112005 - tx again null without PS bit if lost */ 2184 } else {/* 21112005 - tx again null without PS bit if lost */
2243 2185
2244 if ((ieee->sta_sleep == LPS_IS_WAKE) && !success){ 2186 if ((ieee->sta_sleep == LPS_IS_WAKE) && !success) {
2245 spin_lock_irqsave(&ieee->mgmt_tx_lock, flags2); 2187 spin_lock_irqsave(&ieee->mgmt_tx_lock, flags2);
2246 if (ieee->pHTInfo->IOTAction & HT_IOT_ACT_NULL_DATA_POWER_SAVING) 2188 if (ieee->pHTInfo->IOTAction &
2247 { 2189 HT_IOT_ACT_NULL_DATA_POWER_SAVING)
2248 rtllib_sta_ps_send_null_frame(ieee, 0); 2190 rtllib_sta_ps_send_null_frame(ieee, 0);
2249 }
2250 else 2191 else
2251 {
2252 rtllib_sta_ps_send_pspoll_frame(ieee); 2192 rtllib_sta_ps_send_pspoll_frame(ieee);
2253 }
2254 spin_unlock_irqrestore(&ieee->mgmt_tx_lock, flags2); 2193 spin_unlock_irqrestore(&ieee->mgmt_tx_lock, flags2);
2255 } 2194 }
2256 } 2195 }
2257 spin_unlock_irqrestore(&ieee->lock, flags); 2196 spin_unlock_irqrestore(&ieee->lock, flags);
2258} 2197}
2259 2198
2260void rtllib_process_action(struct rtllib_device* ieee, struct sk_buff* skb) 2199void rtllib_process_action(struct rtllib_device *ieee, struct sk_buff *skb)
2261{ 2200{
2262 struct rtllib_hdr_3addr *header = (struct rtllib_hdr_3addr *) skb->data; 2201 struct rtllib_hdr_3addr *header = (struct rtllib_hdr_3addr *) skb->data;
2263 u8* act = rtllib_get_payload((struct rtllib_hdr *)header); 2202 u8 *act = rtllib_get_payload((struct rtllib_hdr *)header);
2264 u8 category = 0; 2203 u8 category = 0;
2265 2204
2266 if (act == NULL) { 2205 if (act == NULL) {
2267 RTLLIB_DEBUG(RTLLIB_DL_ERR, "error to get payload of action frame\n"); 2206 RTLLIB_DEBUG(RTLLIB_DL_ERR, "error to get payload of "
2207 "action frame\n");
2268 return; 2208 return;
2269 } 2209 }
2270 2210
2271 category = *act; 2211 category = *act;
2272 act ++; 2212 act++;
2273 switch (category) { 2213 switch (category) {
2274 case ACT_CAT_BA: 2214 case ACT_CAT_BA:
2275 switch (*act) { 2215 switch (*act) {
2276 case ACT_ADDBAREQ: 2216 case ACT_ADDBAREQ:
2277 rtllib_rx_ADDBAReq(ieee, skb); 2217 rtllib_rx_ADDBAReq(ieee, skb);
2278 break; 2218 break;
2279 case ACT_ADDBARSP: 2219 case ACT_ADDBARSP:
2280 rtllib_rx_ADDBARsp(ieee, skb); 2220 rtllib_rx_ADDBARsp(ieee, skb);
2281 break;
2282 case ACT_DELBA:
2283 rtllib_rx_DELBA(ieee, skb);
2284 break;
2285 }
2286 break; 2221 break;
2287 default: 2222 case ACT_DELBA:
2223 rtllib_rx_DELBA(ieee, skb);
2288 break; 2224 break;
2225 }
2226 break;
2227 default:
2228 break;
2289 } 2229 }
2290 return; 2230 return;
2291} 2231}
2292 2232
2293inline int rtllib_rx_assoc_resp(struct rtllib_device *ieee, struct sk_buff *skb, struct rtllib_rx_stats *rx_stats) 2233inline int rtllib_rx_assoc_resp(struct rtllib_device *ieee, struct sk_buff *skb,
2234 struct rtllib_rx_stats *rx_stats)
2294{ 2235{
2295 u16 errcode; 2236 u16 errcode;
2296 int aid; 2237 int aid;
2297 u8* ies; 2238 u8 *ies;
2298 struct rtllib_assoc_response_frame *assoc_resp; 2239 struct rtllib_assoc_response_frame *assoc_resp;
2299 struct rtllib_hdr_3addr *header = (struct rtllib_hdr_3addr *) skb->data; 2240 struct rtllib_hdr_3addr *header = (struct rtllib_hdr_3addr *) skb->data;
2300 2241
2301 RTLLIB_DEBUG_MGMT("received [RE]ASSOCIATION RESPONSE (%d)\n", 2242 RTLLIB_DEBUG_MGMT("received [RE]ASSOCIATION RESPONSE (%d)\n",
2302 WLAN_FC_GET_STYPE(header->frame_ctl)); 2243 WLAN_FC_GET_STYPE(header->frame_ctl));
2303 2244
2304 if ((ieee->softmac_features & IEEE_SOFTMAC_ASSOCIATE) && 2245 if ((ieee->softmac_features & IEEE_SOFTMAC_ASSOCIATE) &&
2305 ieee->state == RTLLIB_ASSOCIATING_AUTHENTICATED && 2246 ieee->state == RTLLIB_ASSOCIATING_AUTHENTICATED &&
2306 (ieee->iw_mode == IW_MODE_INFRA)) 2247 (ieee->iw_mode == IW_MODE_INFRA)) {
2307 { 2248 errcode = assoc_parse(ieee, skb, &aid);
2308 if (0 == (errcode=assoc_parse(ieee,skb, &aid))){ 2249 if (0 == errcode) {
2309 struct rtllib_network *network = kzalloc(sizeof(struct rtllib_network), GFP_ATOMIC); 2250 struct rtllib_network *network =
2251 kzalloc(sizeof(struct rtllib_network),
2252 GFP_ATOMIC);
2310 2253
2311 if (!network) 2254 if (!network)
2312 return 1; 2255 return 1;
2313 memset(network,0,sizeof(*network)); 2256 memset(network, 0, sizeof(*network));
2314 ieee->state=RTLLIB_LINKED; 2257 ieee->state = RTLLIB_LINKED;
2315 ieee->assoc_id = aid; 2258 ieee->assoc_id = aid;
2316 ieee->softmac_stats.rx_ass_ok++; 2259 ieee->softmac_stats.rx_ass_ok++;
2317 /* station support qos */ 2260 /* station support qos */
2318 /* Let the register setting defaultly with Legacy station */ 2261 /* Let the register setting default with Legacy station */
2319 assoc_resp = (struct rtllib_assoc_response_frame*)skb->data; 2262 assoc_resp = (struct rtllib_assoc_response_frame *)skb->data;
2320 if (ieee->current_network.qos_data.supported == 1) { 2263 if (ieee->current_network.qos_data.supported == 1) {
2321 if (rtllib_parse_info_param(ieee,assoc_resp->info_element,\ 2264 if (rtllib_parse_info_param(ieee, assoc_resp->info_element,
2322 rx_stats->len - sizeof(*assoc_resp),\ 2265 rx_stats->len - sizeof(*assoc_resp),
2323 network,rx_stats)){ 2266 network, rx_stats)) {
2324 kfree(network); 2267 kfree(network);
2325 return 1; 2268 return 1;
2326 } 2269 } else {
2327 else 2270 memcpy(ieee->pHTInfo->PeerHTCapBuf,
2328 { 2271 network->bssht.bdHTCapBuf,
2329 memcpy(ieee->pHTInfo->PeerHTCapBuf, network->bssht.bdHTCapBuf, network->bssht.bdHTCapLen); 2272 network->bssht.bdHTCapLen);
2330 memcpy(ieee->pHTInfo->PeerHTInfoBuf, network->bssht.bdHTInfoBuf, network->bssht.bdHTInfoLen); 2273 memcpy(ieee->pHTInfo->PeerHTInfoBuf,
2274 network->bssht.bdHTInfoBuf,
2275 network->bssht.bdHTInfoLen);
2331 } 2276 }
2332 if (ieee->handle_assoc_response != NULL) 2277 if (ieee->handle_assoc_response != NULL)
2333 ieee->handle_assoc_response(ieee->dev, (struct rtllib_assoc_response_frame*)header, network); 2278 ieee->handle_assoc_response(ieee->dev,
2279 (struct rtllib_assoc_response_frame *)header,
2280 network);
2334 kfree(network); 2281 kfree(network);
2335 } 2282 }
2336 2283
2337 if (ieee->assocresp_ies){ 2284 kfree(ieee->assocresp_ies);
2338 kfree(ieee->assocresp_ies); 2285 ieee->assocresp_ies = NULL;
2339 ieee->assocresp_ies = NULL;
2340 }
2341 ies = &(assoc_resp->info_element[0].id); 2286 ies = &(assoc_resp->info_element[0].id);
2342 ieee->assocresp_ies_len = (skb->data + skb->len) - ies; 2287 ieee->assocresp_ies_len = (skb->data + skb->len) - ies;
2343 ieee->assocresp_ies = kmalloc(ieee->assocresp_ies_len, GFP_ATOMIC); 2288 ieee->assocresp_ies = kmalloc(ieee->assocresp_ies_len,
2289 GFP_ATOMIC);
2344 if (ieee->assocresp_ies) 2290 if (ieee->assocresp_ies)
2345 memcpy(ieee->assocresp_ies, ies, ieee->assocresp_ies_len); 2291 memcpy(ieee->assocresp_ies, ies,
2346 else{ 2292 ieee->assocresp_ies_len);
2347 printk("%s()Warning: can't alloc memory for assocresp_ies\n", __func__); 2293 else {
2294 printk(KERN_INFO "%s()Warning: can't alloc "
2295 "memory for assocresp_ies\n", __func__);
2348 ieee->assocresp_ies_len = 0; 2296 ieee->assocresp_ies_len = 0;
2349 } 2297 }
2350 rtllib_associate_complete(ieee); 2298 rtllib_associate_complete(ieee);
2351 } else { 2299 } else {
2352 /* aid could not been allocated */ 2300 /* aid could not been allocated */
2353 ieee->softmac_stats.rx_ass_err++; 2301 ieee->softmac_stats.rx_ass_err++;
2354 printk( 2302 printk(KERN_INFO "Association response status code 0x%x\n",
2355 "Association response status code 0x%x\n",
2356 errcode); 2303 errcode);
2357 RTLLIB_DEBUG_MGMT( 2304 RTLLIB_DEBUG_MGMT(
2358 "Association response status code 0x%x\n", 2305 "Association response status code 0x%x\n",
2359 errcode); 2306 errcode);
2360 if (ieee->AsocRetryCount < RT_ASOC_RETRY_LIMIT) { 2307 if (ieee->AsocRetryCount < RT_ASOC_RETRY_LIMIT)
2361 queue_delayed_work_rsl(ieee->wq, &ieee->associate_procedure_wq, 0); 2308 queue_delayed_work_rsl(ieee->wq,
2362 } else { 2309 &ieee->associate_procedure_wq, 0);
2310 else
2363 rtllib_associate_abort(ieee); 2311 rtllib_associate_abort(ieee);
2364 }
2365 } 2312 }
2366 } 2313 }
2367
2368 return 0; 2314 return 0;
2369} 2315}
2370 2316
2371inline int rtllib_rx_auth(struct rtllib_device *ieee, struct sk_buff *skb, struct rtllib_rx_stats *rx_stats) 2317inline int rtllib_rx_auth(struct rtllib_device *ieee, struct sk_buff *skb,
2318 struct rtllib_rx_stats *rx_stats)
2372{ 2319{
2373 u16 errcode; 2320 u16 errcode;
2374 u8* challenge; 2321 u8 *challenge;
2375 int chlen=0; 2322 int chlen = 0;
2376 bool bSupportNmode = true, bHalfSupportNmode = false; 2323 bool bSupportNmode = true, bHalfSupportNmode = false;
2377 2324
2378 if (ieee->softmac_features & IEEE_SOFTMAC_ASSOCIATE){ 2325 if (ieee->softmac_features & IEEE_SOFTMAC_ASSOCIATE) {
2379 if (ieee->state == RTLLIB_ASSOCIATING_AUTHENTICATING && 2326 if (ieee->state == RTLLIB_ASSOCIATING_AUTHENTICATING &&
2380 (ieee->iw_mode == IW_MODE_INFRA)) { 2327 (ieee->iw_mode == IW_MODE_INFRA)) {
2381 RTLLIB_DEBUG_MGMT("Received authentication response"); 2328 RTLLIB_DEBUG_MGMT("Received authentication response");
2382 2329
2383 if (0 == (errcode=auth_parse(skb, &challenge, &chlen))) { 2330 errcode = auth_parse(skb, &challenge, &chlen);
2384 if (ieee->open_wep || !challenge){ 2331 if (0 == errcode) {
2332 if (ieee->open_wep || !challenge) {
2385 ieee->state = RTLLIB_ASSOCIATING_AUTHENTICATED; 2333 ieee->state = RTLLIB_ASSOCIATING_AUTHENTICATED;
2386 ieee->softmac_stats.rx_auth_rs_ok++; 2334 ieee->softmac_stats.rx_auth_rs_ok++;
2387 if (!(ieee->pHTInfo->IOTAction&HT_IOT_ACT_PURE_N_MODE)) 2335 if (!(ieee->pHTInfo->IOTAction &
2388 { 2336 HT_IOT_ACT_PURE_N_MODE)) {
2389 if (!ieee->GetNmodeSupportBySecCfg(ieee->dev)) 2337 if (!ieee->GetNmodeSupportBySecCfg(ieee->dev)) {
2390 { 2338 if (IsHTHalfNmodeAPs(ieee)) {
2391 if (IsHTHalfNmodeAPs(ieee))
2392 {
2393 bSupportNmode = true; 2339 bSupportNmode = true;
2394 bHalfSupportNmode = true; 2340 bHalfSupportNmode = true;
2395 } 2341 } else {
2396 else
2397 {
2398 bSupportNmode = false; 2342 bSupportNmode = false;
2399 bHalfSupportNmode = false; 2343 bHalfSupportNmode = false;
2400 } 2344 }
2401 } 2345 }
2402 } 2346 }
2403 /* Dummy wirless mode setting to avoid encryption issue */ 2347 /* Dummy wirless mode setting to avoid
2348 * encryption issue */
2404 if (bSupportNmode) { 2349 if (bSupportNmode) {
2405 ieee->SetWirelessMode(ieee->dev, \ 2350 ieee->SetWirelessMode(ieee->dev,
2406 ieee->current_network.mode); 2351 ieee->current_network.mode);
2407 }else{ 2352 } else {
2408 /*TODO*/ 2353 /*TODO*/
2409 ieee->SetWirelessMode(ieee->dev, IEEE_G); 2354 ieee->SetWirelessMode(ieee->dev,
2355 IEEE_G);
2410 } 2356 }
2411 2357
2412 if (ieee->current_network.mode == IEEE_N_24G && bHalfSupportNmode == true) 2358 if (ieee->current_network.mode ==
2413 { 2359 IEEE_N_24G &&
2414 printk("===============>entern half N mode\n"); 2360 bHalfSupportNmode == true) {
2415 ieee->bHalfWirelessN24GMode = true; 2361 printk(KERN_INFO "======>enter "
2416 } 2362 "half N mode\n");
2417 else 2363 ieee->bHalfWirelessN24GMode =
2418 ieee->bHalfWirelessN24GMode = false; 2364 true;
2365 } else
2366 ieee->bHalfWirelessN24GMode =
2367 false;
2419 2368
2420 rtllib_associate_step2(ieee); 2369 rtllib_associate_step2(ieee);
2421 }else{ 2370 } else {
2422 rtllib_auth_challenge(ieee, challenge, chlen); 2371 rtllib_auth_challenge(ieee, challenge,
2372 chlen);
2423 } 2373 }
2424 }else{ 2374 } else {
2425 ieee->softmac_stats.rx_auth_rs_err++; 2375 ieee->softmac_stats.rx_auth_rs_err++;
2426 RTLLIB_DEBUG_MGMT("Authentication respose status code 0x%x",errcode); 2376 RTLLIB_DEBUG_MGMT("Authentication respose"
2377 " status code 0x%x", errcode);
2427 2378
2428 printk("Authentication respose status code 0x%x",errcode); 2379 printk(KERN_INFO "Authentication respose "
2380 "status code 0x%x", errcode);
2429 rtllib_associate_abort(ieee); 2381 rtllib_associate_abort(ieee);
2430 } 2382 }
2431 2383
2432 }else if (ieee->iw_mode == IW_MODE_MASTER){ 2384 } else if (ieee->iw_mode == IW_MODE_MASTER) {
2433 rtllib_rx_auth_rq(ieee, skb); 2385 rtllib_rx_auth_rq(ieee, skb);
2434 } 2386 }
2435 } 2387 }
2436
2437 return 0; 2388 return 0;
2438} 2389}
2439 2390
@@ -2453,7 +2404,7 @@ inline int rtllib_rx_deauth(struct rtllib_device *ieee, struct sk_buff *skb)
2453 printk(KERN_INFO "==========>received disassoc/deauth(%x) " 2404 printk(KERN_INFO "==========>received disassoc/deauth(%x) "
2454 "frame, reason code:%x\n", 2405 "frame, reason code:%x\n",
2455 WLAN_FC_GET_STYPE(header->frame_ctl), 2406 WLAN_FC_GET_STYPE(header->frame_ctl),
2456 ((struct rtllib_disassoc*)skb->data)->reason); 2407 ((struct rtllib_disassoc *)skb->data)->reason);
2457 ieee->state = RTLLIB_ASSOCIATING; 2408 ieee->state = RTLLIB_ASSOCIATING;
2458 ieee->softmac_stats.reassoc++; 2409 ieee->softmac_stats.reassoc++;
2459 ieee->is_roaming = true; 2410 ieee->is_roaming = true;
@@ -2461,18 +2412,21 @@ inline int rtllib_rx_deauth(struct rtllib_device *ieee, struct sk_buff *skb)
2461 rtllib_disassociate(ieee); 2412 rtllib_disassociate(ieee);
2462 RemovePeerTS(ieee, header->addr2); 2413 RemovePeerTS(ieee, header->addr2);
2463 if (ieee->LedControlHandler != NULL) 2414 if (ieee->LedControlHandler != NULL)
2464 ieee->LedControlHandler(ieee->dev, LED_CTL_START_TO_LINK); 2415 ieee->LedControlHandler(ieee->dev,
2416 LED_CTL_START_TO_LINK);
2465 2417
2466 if (!(ieee->rtllib_ap_sec_type(ieee)&(SEC_ALG_CCMP|SEC_ALG_TKIP))) 2418 if (!(ieee->rtllib_ap_sec_type(ieee) &
2467 queue_delayed_work_rsl(ieee->wq, &ieee->associate_procedure_wq, 5); 2419 (SEC_ALG_CCMP|SEC_ALG_TKIP)))
2420 queue_delayed_work_rsl(ieee->wq,
2421 &ieee->associate_procedure_wq, 5);
2468 } 2422 }
2469
2470 return 0; 2423 return 0;
2471} 2424}
2472 2425
2473inline int rtllib_rx_frame_softmac(struct rtllib_device *ieee, struct sk_buff *skb, 2426inline int rtllib_rx_frame_softmac(struct rtllib_device *ieee,
2474 struct rtllib_rx_stats *rx_stats, u16 type, 2427 struct sk_buff *skb,
2475 u16 stype) 2428 struct rtllib_rx_stats *rx_stats, u16 type,
2429 u16 stype)
2476{ 2430{
2477 struct rtllib_hdr_3addr *header = (struct rtllib_hdr_3addr *) skb->data; 2431 struct rtllib_hdr_3addr *header = (struct rtllib_hdr_3addr *) skb->data;
2478 2432
@@ -2480,44 +2434,31 @@ inline int rtllib_rx_frame_softmac(struct rtllib_device *ieee, struct sk_buff *s
2480 return 0; 2434 return 0;
2481 2435
2482 switch (WLAN_FC_GET_STYPE(header->frame_ctl)) { 2436 switch (WLAN_FC_GET_STYPE(header->frame_ctl)) {
2483 2437 case RTLLIB_STYPE_ASSOC_RESP:
2484 case RTLLIB_STYPE_ASSOC_RESP: 2438 case RTLLIB_STYPE_REASSOC_RESP:
2485 case RTLLIB_STYPE_REASSOC_RESP: 2439 if (rtllib_rx_assoc_resp(ieee, skb, rx_stats) == 1)
2486 2440 return 1;
2487 if (rtllib_rx_assoc_resp(ieee, skb, rx_stats) == 1) 2441 break;
2488 return 1; 2442 case RTLLIB_STYPE_ASSOC_REQ:
2489 2443 case RTLLIB_STYPE_REASSOC_REQ:
2490 break; 2444 if ((ieee->softmac_features & IEEE_SOFTMAC_ASSOCIATE) &&
2491 2445 ieee->iw_mode == IW_MODE_MASTER)
2492 case RTLLIB_STYPE_ASSOC_REQ: 2446 rtllib_rx_assoc_rq(ieee, skb);
2493 case RTLLIB_STYPE_REASSOC_REQ: 2447 break;
2494 2448 case RTLLIB_STYPE_AUTH:
2495 if ((ieee->softmac_features & IEEE_SOFTMAC_ASSOCIATE) && 2449 rtllib_rx_auth(ieee, skb, rx_stats);
2496 ieee->iw_mode == IW_MODE_MASTER) 2450 break;
2497 2451 case RTLLIB_STYPE_DISASSOC:
2498 rtllib_rx_assoc_rq(ieee, skb); 2452 case RTLLIB_STYPE_DEAUTH:
2499 break; 2453 rtllib_rx_deauth(ieee, skb);
2500 2454 break;
2501 case RTLLIB_STYPE_AUTH: 2455 case RTLLIB_STYPE_MANAGE_ACT:
2502 2456 rtllib_process_action(ieee, skb);
2503 rtllib_rx_auth(ieee, skb, rx_stats); 2457 break;
2504 2458 default:
2505 break; 2459 return -1;
2506 case RTLLIB_STYPE_DISASSOC: 2460 break;
2507 case RTLLIB_STYPE_DEAUTH:
2508
2509 rtllib_rx_deauth(ieee, skb);
2510
2511 break;
2512
2513 case RTLLIB_STYPE_MANAGE_ACT:
2514 rtllib_process_action(ieee,skb);
2515 break;
2516 default:
2517 return -1;
2518 break;
2519 } 2461 }
2520
2521 return 0; 2462 return 0;
2522} 2463}
2523 2464
@@ -2548,43 +2489,43 @@ void rtllib_softmac_xmit(struct rtllib_txb *txb, struct rtllib_device *ieee)
2548 struct cb_desc *tcb_desc = NULL; 2489 struct cb_desc *tcb_desc = NULL;
2549 unsigned long queue_len = 0; 2490 unsigned long queue_len = 0;
2550 2491
2551 spin_lock_irqsave(&ieee->lock,flags); 2492 spin_lock_irqsave(&ieee->lock, flags);
2552 2493
2553 /* called with 2nd parm 0, no tx mgmt lock required */ 2494 /* called with 2nd parm 0, no tx mgmt lock required */
2554 rtllib_sta_wakeup(ieee,0); 2495 rtllib_sta_wakeup(ieee, 0);
2555 2496
2556 /* update the tx status */ 2497 /* update the tx status */
2557 tcb_desc = (struct cb_desc *)(txb->fragments[0]->cb + MAX_DEV_ADDR_SIZE); 2498 tcb_desc = (struct cb_desc *)(txb->fragments[0]->cb +
2558 if (tcb_desc->bMulticast) { 2499 MAX_DEV_ADDR_SIZE);
2500 if (tcb_desc->bMulticast)
2559 ieee->stats.multicast++; 2501 ieee->stats.multicast++;
2560 }
2561 2502
2562 /* if xmit available, just xmit it immediately, else just insert it to the wait queue */ 2503 /* if xmit available, just xmit it immediately, else just insert it to
2504 * the wait queue */
2563 for (i = 0; i < txb->nr_frags; i++) { 2505 for (i = 0; i < txb->nr_frags; i++) {
2564 queue_len = skb_queue_len(&ieee->skb_waitQ[queue_index]); 2506 queue_len = skb_queue_len(&ieee->skb_waitQ[queue_index]);
2565 if ((queue_len != 0) ||\ 2507 if ((queue_len != 0) ||\
2566 (!ieee->check_nic_enough_desc(ieee->dev,queue_index))||\ 2508 (!ieee->check_nic_enough_desc(ieee->dev, queue_index)) ||
2567 (ieee->queue_stop)) { 2509 (ieee->queue_stop)) {
2568 /* insert the skb packet to the wait queue */ 2510 /* insert the skb packet to the wait queue */
2569 /* as for the completion function, it does not need 2511 /* as for the completion function, it does not need
2570 * to check it any more. 2512 * to check it any more.
2571 * */ 2513 * */
2572 if (queue_len < 200) 2514 if (queue_len < 200)
2573 { 2515 skb_queue_tail(&ieee->skb_waitQ[queue_index],
2574 skb_queue_tail(&ieee->skb_waitQ[queue_index], txb->fragments[i]); 2516 txb->fragments[i]);
2575 }else{ 2517 else
2576 kfree_skb(txb->fragments[i]); 2518 kfree_skb(txb->fragments[i]);
2577 } 2519 } else {
2578 }else{
2579 ieee->softmac_data_hard_start_xmit( 2520 ieee->softmac_data_hard_start_xmit(
2580 txb->fragments[i], 2521 txb->fragments[i],
2581 ieee->dev,ieee->rate); 2522 ieee->dev, ieee->rate);
2582 } 2523 }
2583 } 2524 }
2584 2525
2585 rtllib_txb_free(txb); 2526 rtllib_txb_free(txb);
2586 2527
2587 spin_unlock_irqrestore(&ieee->lock,flags); 2528 spin_unlock_irqrestore(&ieee->lock, flags);
2588 2529
2589} 2530}
2590 2531
@@ -2592,16 +2533,17 @@ void rtllib_softmac_xmit(struct rtllib_txb *txb, struct rtllib_device *ieee)
2592void rtllib_resume_tx(struct rtllib_device *ieee) 2533void rtllib_resume_tx(struct rtllib_device *ieee)
2593{ 2534{
2594 int i; 2535 int i;
2595 for (i = ieee->tx_pending.frag; i < ieee->tx_pending.txb->nr_frags; i++) { 2536 for (i = ieee->tx_pending.frag; i < ieee->tx_pending.txb->nr_frags;
2537 i++) {
2596 2538
2597 if (ieee->queue_stop){ 2539 if (ieee->queue_stop) {
2598 ieee->tx_pending.frag = i; 2540 ieee->tx_pending.frag = i;
2599 return; 2541 return;
2600 }else{ 2542 } else {
2601 2543
2602 ieee->softmac_data_hard_start_xmit( 2544 ieee->softmac_data_hard_start_xmit(
2603 ieee->tx_pending.txb->fragments[i], 2545 ieee->tx_pending.txb->fragments[i],
2604 ieee->dev,ieee->rate); 2546 ieee->dev, ieee->rate);
2605 ieee->stats.tx_packets++; 2547 ieee->stats.tx_packets++;
2606 } 2548 }
2607 } 2549 }
@@ -2615,14 +2557,14 @@ void rtllib_reset_queue(struct rtllib_device *ieee)
2615{ 2557{
2616 unsigned long flags; 2558 unsigned long flags;
2617 2559
2618 spin_lock_irqsave(&ieee->lock,flags); 2560 spin_lock_irqsave(&ieee->lock, flags);
2619 init_mgmt_queue(ieee); 2561 init_mgmt_queue(ieee);
2620 if (ieee->tx_pending.txb){ 2562 if (ieee->tx_pending.txb) {
2621 rtllib_txb_free(ieee->tx_pending.txb); 2563 rtllib_txb_free(ieee->tx_pending.txb);
2622 ieee->tx_pending.txb = NULL; 2564 ieee->tx_pending.txb = NULL;
2623 } 2565 }
2624 ieee->queue_stop = 0; 2566 ieee->queue_stop = 0;
2625 spin_unlock_irqrestore(&ieee->lock,flags); 2567 spin_unlock_irqrestore(&ieee->lock, flags);
2626 2568
2627} 2569}
2628 2570
@@ -2633,13 +2575,14 @@ void rtllib_wake_queue(struct rtllib_device *ieee)
2633 struct sk_buff *skb; 2575 struct sk_buff *skb;
2634 struct rtllib_hdr_3addr *header; 2576 struct rtllib_hdr_3addr *header;
2635 2577
2636 spin_lock_irqsave(&ieee->lock,flags); 2578 spin_lock_irqsave(&ieee->lock, flags);
2637 if (! ieee->queue_stop) goto exit; 2579 if (!ieee->queue_stop)
2580 goto exit;
2638 2581
2639 ieee->queue_stop = 0; 2582 ieee->queue_stop = 0;
2640 2583
2641 if (ieee->softmac_features & IEEE_SOFTMAC_SINGLE_QUEUE){ 2584 if (ieee->softmac_features & IEEE_SOFTMAC_SINGLE_QUEUE) {
2642 while (!ieee->queue_stop && (skb = dequeue_mgmt(ieee))){ 2585 while (!ieee->queue_stop && (skb = dequeue_mgmt(ieee))) {
2643 2586
2644 header = (struct rtllib_hdr_3addr *) skb->data; 2587 header = (struct rtllib_hdr_3addr *) skb->data;
2645 2588
@@ -2650,26 +2593,27 @@ void rtllib_wake_queue(struct rtllib_device *ieee)
2650 else 2593 else
2651 ieee->seq_ctrl[0]++; 2594 ieee->seq_ctrl[0]++;
2652 2595
2653 ieee->softmac_data_hard_start_xmit(skb,ieee->dev,ieee->basic_rate); 2596 ieee->softmac_data_hard_start_xmit(skb, ieee->dev,
2597 ieee->basic_rate);
2654 } 2598 }
2655 } 2599 }
2656 if (!ieee->queue_stop && ieee->tx_pending.txb) 2600 if (!ieee->queue_stop && ieee->tx_pending.txb)
2657 rtllib_resume_tx(ieee); 2601 rtllib_resume_tx(ieee);
2658 2602
2659 if (!ieee->queue_stop && netif_queue_stopped(ieee->dev)){ 2603 if (!ieee->queue_stop && netif_queue_stopped(ieee->dev)) {
2660 ieee->softmac_stats.swtxawake++; 2604 ieee->softmac_stats.swtxawake++;
2661 netif_wake_queue(ieee->dev); 2605 netif_wake_queue(ieee->dev);
2662 } 2606 }
2663 2607
2664exit : 2608exit:
2665 spin_unlock_irqrestore(&ieee->lock,flags); 2609 spin_unlock_irqrestore(&ieee->lock, flags);
2666} 2610}
2667 2611
2668 2612
2669void rtllib_stop_queue(struct rtllib_device *ieee) 2613void rtllib_stop_queue(struct rtllib_device *ieee)
2670{ 2614{
2671 2615
2672 if (! netif_queue_stopped(ieee->dev)){ 2616 if (!netif_queue_stopped(ieee->dev)) {
2673 netif_stop_queue(ieee->dev); 2617 netif_stop_queue(ieee->dev);
2674 ieee->softmac_stats.swtxstop++; 2618 ieee->softmac_stats.swtxstop++;
2675 } 2619 }
@@ -2680,8 +2624,8 @@ void rtllib_stop_queue(struct rtllib_device *ieee)
2680void rtllib_stop_all_queues(struct rtllib_device *ieee) 2624void rtllib_stop_all_queues(struct rtllib_device *ieee)
2681{ 2625{
2682 unsigned int i; 2626 unsigned int i;
2683 for (i=0; i < ieee->dev->num_tx_queues; i++) 2627 for (i = 0; i < ieee->dev->num_tx_queues; i++)
2684 netdev_get_tx_queue(ieee->dev,i)->trans_start = jiffies; 2628 netdev_get_tx_queue(ieee->dev, i)->trans_start = jiffies;
2685 2629
2686 netif_tx_stop_all_queues(ieee->dev); 2630 netif_tx_stop_all_queues(ieee->dev);
2687} 2631}
@@ -2708,12 +2652,13 @@ void rtllib_start_master_bss(struct rtllib_device *ieee)
2708{ 2652{
2709 ieee->assoc_id = 1; 2653 ieee->assoc_id = 1;
2710 2654
2711 if (ieee->current_network.ssid_len == 0){ 2655 if (ieee->current_network.ssid_len == 0) {
2712 strncpy(ieee->current_network.ssid, 2656 strncpy(ieee->current_network.ssid,
2713 RTLLIB_DEFAULT_TX_ESSID, 2657 RTLLIB_DEFAULT_TX_ESSID,
2714 IW_ESSID_MAX_SIZE); 2658 IW_ESSID_MAX_SIZE);
2715 2659
2716 ieee->current_network.ssid_len = strlen(RTLLIB_DEFAULT_TX_ESSID); 2660 ieee->current_network.ssid_len =
2661 strlen(RTLLIB_DEFAULT_TX_ESSID);
2717 ieee->ssid_set = 1; 2662 ieee->ssid_set = 1;
2718 } 2663 }
2719 2664
@@ -2733,7 +2678,7 @@ void rtllib_start_master_bss(struct rtllib_device *ieee)
2733void rtllib_start_monitor_mode(struct rtllib_device *ieee) 2678void rtllib_start_monitor_mode(struct rtllib_device *ieee)
2734{ 2679{
2735 /* reset hardware status */ 2680 /* reset hardware status */
2736 if (ieee->raw_tx){ 2681 if (ieee->raw_tx) {
2737 if (ieee->data_hard_resume) 2682 if (ieee->data_hard_resume)
2738 ieee->data_hard_resume(ieee->dev); 2683 ieee->data_hard_resume(ieee->dev);
2739 2684
@@ -2743,7 +2688,8 @@ void rtllib_start_monitor_mode(struct rtllib_device *ieee)
2743 2688
2744void rtllib_start_ibss_wq(void *data) 2689void rtllib_start_ibss_wq(void *data)
2745{ 2690{
2746 struct rtllib_device *ieee = container_of_dwork_rsl(data, struct rtllib_device, start_ibss_wq); 2691 struct rtllib_device *ieee = container_of_dwork_rsl(data,
2692 struct rtllib_device, start_ibss_wq);
2747 /* iwconfig mode ad-hoc will schedule this and return 2693 /* iwconfig mode ad-hoc will schedule this and return
2748 * on the other hand this will block further iwconfig SET 2694 * on the other hand this will block further iwconfig SET
2749 * operations because of the wx_sem hold. 2695 * operations because of the wx_sem hold.
@@ -2751,14 +2697,14 @@ void rtllib_start_ibss_wq(void *data)
2751 * (abort) this wq (when syncro scanning) before sleeping 2697 * (abort) this wq (when syncro scanning) before sleeping
2752 * on the semaphore 2698 * on the semaphore
2753 */ 2699 */
2754 if (!ieee->proto_started){ 2700 if (!ieee->proto_started) {
2755 printk("==========oh driver down return\n"); 2701 printk(KERN_INFO "==========oh driver down return\n");
2756 return; 2702 return;
2757 } 2703 }
2758 down(&ieee->wx_sem); 2704 down(&ieee->wx_sem);
2759 2705
2760 if (ieee->current_network.ssid_len == 0){ 2706 if (ieee->current_network.ssid_len == 0) {
2761 strcpy(ieee->current_network.ssid,RTLLIB_DEFAULT_TX_ESSID); 2707 strcpy(ieee->current_network.ssid, RTLLIB_DEFAULT_TX_ESSID);
2762 ieee->current_network.ssid_len = strlen(RTLLIB_DEFAULT_TX_ESSID); 2708 ieee->current_network.ssid_len = strlen(RTLLIB_DEFAULT_TX_ESSID);
2763 ieee->ssid_set = 1; 2709 ieee->ssid_set = 1;
2764 } 2710 }
@@ -2787,47 +2733,50 @@ void rtllib_start_ibss_wq(void *data)
2787 rtllib_start_scan_syncro(ieee, 0); 2733 rtllib_start_scan_syncro(ieee, 0);
2788 2734
2789 /* the network definitively is not here.. create a new cell */ 2735 /* the network definitively is not here.. create a new cell */
2790 if (ieee->state == RTLLIB_NOLINK){ 2736 if (ieee->state == RTLLIB_NOLINK) {
2791 printk("creating new IBSS cell\n"); 2737 printk(KERN_INFO "creating new IBSS cell\n");
2792 ieee->current_network.channel = ieee->IbssStartChnl; 2738 ieee->current_network.channel = ieee->IbssStartChnl;
2793 if (!ieee->wap_set) 2739 if (!ieee->wap_set)
2794 rtllib_randomize_cell(ieee); 2740 rtllib_randomize_cell(ieee);
2795 2741
2796 if (ieee->modulation & RTLLIB_CCK_MODULATION){ 2742 if (ieee->modulation & RTLLIB_CCK_MODULATION) {
2797 2743
2798 ieee->current_network.rates_len = 4; 2744 ieee->current_network.rates_len = 4;
2799 2745
2800 ieee->current_network.rates[0] = RTLLIB_BASIC_RATE_MASK | RTLLIB_CCK_RATE_1MB; 2746 ieee->current_network.rates[0] =
2801 ieee->current_network.rates[1] = RTLLIB_BASIC_RATE_MASK | RTLLIB_CCK_RATE_2MB; 2747 RTLLIB_BASIC_RATE_MASK | RTLLIB_CCK_RATE_1MB;
2802 ieee->current_network.rates[2] = RTLLIB_BASIC_RATE_MASK | RTLLIB_CCK_RATE_5MB; 2748 ieee->current_network.rates[1] =
2803 ieee->current_network.rates[3] = RTLLIB_BASIC_RATE_MASK | RTLLIB_CCK_RATE_11MB; 2749 RTLLIB_BASIC_RATE_MASK | RTLLIB_CCK_RATE_2MB;
2750 ieee->current_network.rates[2] =
2751 RTLLIB_BASIC_RATE_MASK | RTLLIB_CCK_RATE_5MB;
2752 ieee->current_network.rates[3] =
2753 RTLLIB_BASIC_RATE_MASK | RTLLIB_CCK_RATE_11MB;
2804 2754
2805 }else 2755 } else
2806 ieee->current_network.rates_len = 0; 2756 ieee->current_network.rates_len = 0;
2807 2757
2808 if (ieee->modulation & RTLLIB_OFDM_MODULATION){ 2758 if (ieee->modulation & RTLLIB_OFDM_MODULATION) {
2809 ieee->current_network.rates_ex_len = 8; 2759 ieee->current_network.rates_ex_len = 8;
2810 2760
2811 /*ieee->current_network.rates_ex[0] = RTLLIB_BASIC_RATE_MASK | RTLLIB_OFDM_RATE_6MB; 2761 ieee->current_network.rates_ex[0] =
2812 ieee->current_network.rates_ex[1] = RTLLIB_BASIC_RATE_MASK | RTLLIB_OFDM_RATE_9MB; 2762 RTLLIB_OFDM_RATE_6MB;
2813 ieee->current_network.rates_ex[2] = RTLLIB_BASIC_RATE_MASK | RTLLIB_OFDM_RATE_12MB; 2763 ieee->current_network.rates_ex[1] =
2814 ieee->current_network.rates_ex[3] = RTLLIB_BASIC_RATE_MASK | RTLLIB_OFDM_RATE_18MB; 2764 RTLLIB_OFDM_RATE_9MB;
2815 ieee->current_network.rates_ex[4] = RTLLIB_BASIC_RATE_MASK | RTLLIB_OFDM_RATE_24MB; 2765 ieee->current_network.rates_ex[2] =
2816 ieee->current_network.rates_ex[5] = RTLLIB_BASIC_RATE_MASK | RTLLIB_OFDM_RATE_36MB; 2766 RTLLIB_OFDM_RATE_12MB;
2817 ieee->current_network.rates_ex[6] = RTLLIB_BASIC_RATE_MASK | RTLLIB_OFDM_RATE_48MB; 2767 ieee->current_network.rates_ex[3] =
2818 ieee->current_network.rates_ex[7] = RTLLIB_BASIC_RATE_MASK | RTLLIB_OFDM_RATE_54MB;*/ 2768 RTLLIB_OFDM_RATE_18MB;
2819 2769 ieee->current_network.rates_ex[4] =
2820 ieee->current_network.rates_ex[0] = RTLLIB_OFDM_RATE_6MB; 2770 RTLLIB_OFDM_RATE_24MB;
2821 ieee->current_network.rates_ex[1] = RTLLIB_OFDM_RATE_9MB; 2771 ieee->current_network.rates_ex[5] =
2822 ieee->current_network.rates_ex[2] = RTLLIB_OFDM_RATE_12MB; 2772 RTLLIB_OFDM_RATE_36MB;
2823 ieee->current_network.rates_ex[3] = RTLLIB_OFDM_RATE_18MB; 2773 ieee->current_network.rates_ex[6] =
2824 ieee->current_network.rates_ex[4] = RTLLIB_OFDM_RATE_24MB; 2774 RTLLIB_OFDM_RATE_48MB;
2825 ieee->current_network.rates_ex[5] = RTLLIB_OFDM_RATE_36MB; 2775 ieee->current_network.rates_ex[7] =
2826 ieee->current_network.rates_ex[6] = RTLLIB_OFDM_RATE_48MB; 2776 RTLLIB_OFDM_RATE_54MB;
2827 ieee->current_network.rates_ex[7] = RTLLIB_OFDM_RATE_54MB;
2828 2777
2829 ieee->rate = 108; 2778 ieee->rate = 108;
2830 }else{ 2779 } else {
2831 ieee->current_network.rates_ex_len = 0; 2780 ieee->current_network.rates_ex_len = 0;
2832 ieee->rate = 22; 2781 ieee->rate = 22;
2833 } 2782 }
@@ -2839,20 +2788,21 @@ void rtllib_start_ibss_wq(void *data)
2839 ieee->current_network.capability = WLAN_CAPABILITY_IBSS; 2788 ieee->current_network.capability = WLAN_CAPABILITY_IBSS;
2840 } 2789 }
2841 2790
2842 printk("%s(): ieee->mode = %d\n", __func__, ieee->mode); 2791 printk(KERN_INFO "%s(): ieee->mode = %d\n", __func__, ieee->mode);
2843 if ((ieee->mode == IEEE_N_24G) || (ieee->mode == IEEE_N_5G)) 2792 if ((ieee->mode == IEEE_N_24G) || (ieee->mode == IEEE_N_5G))
2844 HTUseDefaultSetting(ieee); 2793 HTUseDefaultSetting(ieee);
2845 else 2794 else
2846 ieee->pHTInfo->bCurrentHTSupport = false; 2795 ieee->pHTInfo->bCurrentHTSupport = false;
2847 2796
2848 ieee->SetHwRegHandler(ieee->dev, HW_VAR_MEDIA_STATUS, (u8 *)(&ieee->state)); 2797 ieee->SetHwRegHandler(ieee->dev, HW_VAR_MEDIA_STATUS,
2798 (u8 *)(&ieee->state));
2849 2799
2850 ieee->state = RTLLIB_LINKED; 2800 ieee->state = RTLLIB_LINKED;
2851 ieee->link_change(ieee->dev); 2801 ieee->link_change(ieee->dev);
2852 2802
2853 HTSetConnectBwMode(ieee, HT_CHANNEL_WIDTH_20, HT_EXTCHNL_OFFSET_NO_EXT); 2803 HTSetConnectBwMode(ieee, HT_CHANNEL_WIDTH_20, HT_EXTCHNL_OFFSET_NO_EXT);
2854 if (ieee->LedControlHandler != NULL) 2804 if (ieee->LedControlHandler != NULL)
2855 ieee->LedControlHandler(ieee->dev,LED_CTL_LINK); 2805 ieee->LedControlHandler(ieee->dev, LED_CTL_LINK);
2856 2806
2857 rtllib_start_send_beacons(ieee); 2807 rtllib_start_send_beacons(ieee);
2858 2808
@@ -2875,12 +2825,9 @@ inline void rtllib_start_ibss(struct rtllib_device *ieee)
2875void rtllib_start_bss(struct rtllib_device *ieee) 2825void rtllib_start_bss(struct rtllib_device *ieee)
2876{ 2826{
2877 unsigned long flags; 2827 unsigned long flags;
2878 if (IS_DOT11D_ENABLE(ieee) && !IS_COUNTRY_IE_VALID(ieee)) 2828 if (IS_DOT11D_ENABLE(ieee) && !IS_COUNTRY_IE_VALID(ieee)) {
2879 { 2829 if (!ieee->bGlobalDomain)
2880 if (! ieee->bGlobalDomain)
2881 {
2882 return; 2830 return;
2883 }
2884 } 2831 }
2885 /* check if we have already found the net we 2832 /* check if we have already found the net we
2886 * are interested in (if any). 2833 * are interested in (if any).
@@ -2898,15 +2845,15 @@ void rtllib_start_bss(struct rtllib_device *ieee)
2898 */ 2845 */
2899 spin_lock_irqsave(&ieee->lock, flags); 2846 spin_lock_irqsave(&ieee->lock, flags);
2900 2847
2901 if (ieee->state == RTLLIB_NOLINK) { 2848 if (ieee->state == RTLLIB_NOLINK)
2902 rtllib_start_scan(ieee); 2849 rtllib_start_scan(ieee);
2903 }
2904 spin_unlock_irqrestore(&ieee->lock, flags); 2850 spin_unlock_irqrestore(&ieee->lock, flags);
2905} 2851}
2906 2852
2907void rtllib_link_change_wq(void *data) 2853void rtllib_link_change_wq(void *data)
2908{ 2854{
2909 struct rtllib_device *ieee = container_of_dwork_rsl(data, struct rtllib_device, link_change_wq); 2855 struct rtllib_device *ieee = container_of_dwork_rsl(data,
2856 struct rtllib_device, link_change_wq);
2910 ieee->link_change(ieee->dev); 2857 ieee->link_change(ieee->dev);
2911} 2858}
2912/* called only in userspace context */ 2859/* called only in userspace context */
@@ -2931,7 +2878,8 @@ void rtllib_disassociate(struct rtllib_device *ieee)
2931 2878
2932void rtllib_associate_retry_wq(void *data) 2879void rtllib_associate_retry_wq(void *data)
2933{ 2880{
2934 struct rtllib_device *ieee = container_of_dwork_rsl(data, struct rtllib_device, associate_retry_wq); 2881 struct rtllib_device *ieee = container_of_dwork_rsl(data,
2882 struct rtllib_device, associate_retry_wq);
2935 unsigned long flags; 2883 unsigned long flags;
2936 2884
2937 down(&ieee->wx_sem); 2885 down(&ieee->wx_sem);
@@ -2962,9 +2910,7 @@ void rtllib_associate_retry_wq(void *data)
2962 spin_lock_irqsave(&ieee->lock, flags); 2910 spin_lock_irqsave(&ieee->lock, flags);
2963 2911
2964 if (ieee->state == RTLLIB_NOLINK) 2912 if (ieee->state == RTLLIB_NOLINK)
2965 {
2966 rtllib_start_scan(ieee); 2913 rtllib_start_scan(ieee);
2967 }
2968 spin_unlock_irqrestore(&ieee->lock, flags); 2914 spin_unlock_irqrestore(&ieee->lock, flags);
2969 2915
2970 ieee->beinretry = false; 2916 ieee->beinretry = false;
@@ -2974,7 +2920,7 @@ exit:
2974 2920
2975struct sk_buff *rtllib_get_beacon_(struct rtllib_device *ieee) 2921struct sk_buff *rtllib_get_beacon_(struct rtllib_device *ieee)
2976{ 2922{
2977 u8 broadcast_addr[] = {0xff,0xff,0xff,0xff,0xff,0xff}; 2923 u8 broadcast_addr[] = {0xff, 0xff, 0xff, 0xff, 0xff, 0xff};
2978 2924
2979 struct sk_buff *skb; 2925 struct sk_buff *skb;
2980 struct rtllib_probe_response *b; 2926 struct rtllib_probe_response *b;
@@ -3010,11 +2956,12 @@ struct sk_buff *rtllib_get_beacon(struct rtllib_device *ieee)
3010 return skb; 2956 return skb;
3011} 2957}
3012 2958
3013void rtllib_softmac_stop_protocol(struct rtllib_device *ieee, u8 mesh_flag, u8 shutdown) 2959void rtllib_softmac_stop_protocol(struct rtllib_device *ieee, u8 mesh_flag,
2960 u8 shutdown)
3014{ 2961{
3015 rtllib_stop_scan_syncro(ieee); 2962 rtllib_stop_scan_syncro(ieee);
3016 down(&ieee->wx_sem); 2963 down(&ieee->wx_sem);
3017 rtllib_stop_protocol(ieee,shutdown); 2964 rtllib_stop_protocol(ieee, shutdown);
3018 up(&ieee->wx_sem); 2965 up(&ieee->wx_sem);
3019} 2966}
3020 2967
@@ -3024,8 +2971,8 @@ void rtllib_stop_protocol(struct rtllib_device *ieee, u8 shutdown)
3024 if (!ieee->proto_started) 2971 if (!ieee->proto_started)
3025 return; 2972 return;
3026 2973
3027 if (shutdown){ 2974 if (shutdown) {
3028 ieee->proto_started = 0; 2975 ieee->proto_started = 0;
3029 ieee->proto_stoppping = 1; 2976 ieee->proto_stoppping = 1;
3030 if (ieee->rtllib_ips_leave != NULL) 2977 if (ieee->rtllib_ips_leave != NULL)
3031 ieee->rtllib_ips_leave(ieee->dev); 2978 ieee->rtllib_ips_leave(ieee->dev);
@@ -3041,26 +2988,22 @@ void rtllib_stop_protocol(struct rtllib_device *ieee, u8 shutdown)
3041 if (ieee->state <= RTLLIB_ASSOCIATING_AUTHENTICATED) 2988 if (ieee->state <= RTLLIB_ASSOCIATING_AUTHENTICATED)
3042 ieee->state = RTLLIB_NOLINK; 2989 ieee->state = RTLLIB_NOLINK;
3043 2990
3044 if (ieee->state == RTLLIB_LINKED){ 2991 if (ieee->state == RTLLIB_LINKED) {
3045 if (ieee->iw_mode == IW_MODE_INFRA) 2992 if (ieee->iw_mode == IW_MODE_INFRA)
3046 SendDisassociation(ieee,1,deauth_lv_ss); 2993 SendDisassociation(ieee, 1, deauth_lv_ss);
3047 rtllib_disassociate(ieee); 2994 rtllib_disassociate(ieee);
3048 } 2995 }
3049 2996
3050 if (shutdown){ 2997 if (shutdown) {
3051 RemoveAllTS(ieee); 2998 RemoveAllTS(ieee);
3052 ieee->proto_stoppping = 0; 2999 ieee->proto_stoppping = 0;
3053 } 3000 }
3054 if (ieee->assocreq_ies) { 3001 kfree(ieee->assocreq_ies);
3055 kfree(ieee->assocreq_ies); 3002 ieee->assocreq_ies = NULL;
3056 ieee->assocreq_ies = NULL; 3003 ieee->assocreq_ies_len = 0;
3057 ieee->assocreq_ies_len = 0; 3004 kfree(ieee->assocresp_ies);
3058 } 3005 ieee->assocresp_ies = NULL;
3059 if (ieee->assocresp_ies) { 3006 ieee->assocresp_ies_len = 0;
3060 kfree(ieee->assocresp_ies);
3061 ieee->assocresp_ies = NULL;
3062 ieee->assocresp_ies_len = 0;
3063 }
3064} 3007}
3065 3008
3066void rtllib_softmac_start_protocol(struct rtllib_device *ieee, u8 mesh_flag) 3009void rtllib_softmac_start_protocol(struct rtllib_device *ieee, u8 mesh_flag)
@@ -3087,7 +3030,7 @@ void rtllib_start_protocol(struct rtllib_device *ieee)
3087 ch++; 3030 ch++;
3088 if (ch > MAX_CHANNEL_NUMBER) 3031 if (ch > MAX_CHANNEL_NUMBER)
3089 return; /* no channel found */ 3032 return; /* no channel found */
3090 } while(!ieee->active_channel_map[ch]); 3033 } while (!ieee->active_channel_map[ch]);
3091 ieee->current_network.channel = ch; 3034 ieee->current_network.channel = ch;
3092 } 3035 }
3093 3036
@@ -3130,20 +3073,19 @@ void rtllib_softmac_init(struct rtllib_device *ieee)
3130 memset(&ieee->current_network, 0, sizeof(struct rtllib_network)); 3073 memset(&ieee->current_network, 0, sizeof(struct rtllib_network));
3131 3074
3132 ieee->state = RTLLIB_NOLINK; 3075 ieee->state = RTLLIB_NOLINK;
3133 for (i = 0; i < 5; i++) { 3076 for (i = 0; i < 5; i++)
3134 ieee->seq_ctrl[i] = 0; 3077 ieee->seq_ctrl[i] = 0;
3135 }
3136 ieee->pDot11dInfo = kmalloc(sizeof(struct rt_dot11d_info), GFP_ATOMIC); 3078 ieee->pDot11dInfo = kmalloc(sizeof(struct rt_dot11d_info), GFP_ATOMIC);
3137 if (!ieee->pDot11dInfo) 3079 if (!ieee->pDot11dInfo)
3138 RTLLIB_DEBUG(RTLLIB_DL_ERR, "can't alloc memory for DOT11D\n"); 3080 RTLLIB_DEBUG(RTLLIB_DL_ERR, "can't alloc memory for DOT11D\n");
3139 memset(ieee->pDot11dInfo, 0, sizeof(struct rt_dot11d_info)); 3081 memset(ieee->pDot11dInfo, 0, sizeof(struct rt_dot11d_info));
3140 ieee->LinkDetectInfo.SlotIndex = 0; 3082 ieee->LinkDetectInfo.SlotIndex = 0;
3141 ieee->LinkDetectInfo.SlotNum = 2; 3083 ieee->LinkDetectInfo.SlotNum = 2;
3142 ieee->LinkDetectInfo.NumRecvBcnInPeriod=0; 3084 ieee->LinkDetectInfo.NumRecvBcnInPeriod = 0;
3143 ieee->LinkDetectInfo.NumRecvDataInPeriod=0; 3085 ieee->LinkDetectInfo.NumRecvDataInPeriod = 0;
3144 ieee->LinkDetectInfo.NumTxOkInPeriod =0; 3086 ieee->LinkDetectInfo.NumTxOkInPeriod = 0;
3145 ieee->LinkDetectInfo.NumRxOkInPeriod =0; 3087 ieee->LinkDetectInfo.NumRxOkInPeriod = 0;
3146 ieee->LinkDetectInfo.NumRxUnicastOkInPeriod=0; 3088 ieee->LinkDetectInfo.NumRxUnicastOkInPeriod = 0;
3147 ieee->bIsAggregateFrame = false; 3089 ieee->bIsAggregateFrame = false;
3148 ieee->assoc_id = 0; 3090 ieee->assoc_id = 0;
3149 ieee->queue_stop = 0; 3091 ieee->queue_stop = 0;
@@ -3158,13 +3100,13 @@ void rtllib_softmac_init(struct rtllib_device *ieee)
3158 ieee->ps = RTLLIB_PS_DISABLED; 3100 ieee->ps = RTLLIB_PS_DISABLED;
3159 ieee->sta_sleep = LPS_IS_WAKE; 3101 ieee->sta_sleep = LPS_IS_WAKE;
3160 3102
3161 ieee->Regdot11HTOperationalRateSet[0]= 0xff; 3103 ieee->Regdot11HTOperationalRateSet[0] = 0xff;
3162 ieee->Regdot11HTOperationalRateSet[1]= 0xff; 3104 ieee->Regdot11HTOperationalRateSet[1] = 0xff;
3163 ieee->Regdot11HTOperationalRateSet[4]= 0x01; 3105 ieee->Regdot11HTOperationalRateSet[4] = 0x01;
3164 3106
3165 ieee->Regdot11TxHTOperationalRateSet[0]= 0xff; 3107 ieee->Regdot11TxHTOperationalRateSet[0] = 0xff;
3166 ieee->Regdot11TxHTOperationalRateSet[1]= 0xff; 3108 ieee->Regdot11TxHTOperationalRateSet[1] = 0xff;
3167 ieee->Regdot11TxHTOperationalRateSet[4]= 0x01; 3109 ieee->Regdot11TxHTOperationalRateSet[4] = 0x01;
3168 3110
3169 ieee->FirstIe_InScan = false; 3111 ieee->FirstIe_InScan = false;
3170 ieee->actscanning = false; 3112 ieee->actscanning = false;
@@ -3191,18 +3133,26 @@ void rtllib_softmac_init(struct rtllib_device *ieee)
3191 3133
3192 ieee->wq = create_workqueue(DRV_NAME); 3134 ieee->wq = create_workqueue(DRV_NAME);
3193 3135
3194 INIT_DELAYED_WORK_RSL(&ieee->link_change_wq,(void*)rtllib_link_change_wq,ieee); 3136 INIT_DELAYED_WORK_RSL(&ieee->link_change_wq,
3195 INIT_DELAYED_WORK_RSL(&ieee->start_ibss_wq,(void*)rtllib_start_ibss_wq,ieee); 3137 (void *)rtllib_link_change_wq, ieee);
3196 INIT_WORK_RSL(&ieee->associate_complete_wq, (void*)rtllib_associate_complete_wq,ieee); 3138 INIT_DELAYED_WORK_RSL(&ieee->start_ibss_wq,
3197 INIT_DELAYED_WORK_RSL(&ieee->associate_procedure_wq, (void*)rtllib_associate_procedure_wq,ieee); 3139 (void *)rtllib_start_ibss_wq, ieee);
3198 INIT_DELAYED_WORK_RSL(&ieee->softmac_scan_wq,(void*)rtllib_softmac_scan_wq,ieee); 3140 INIT_WORK_RSL(&ieee->associate_complete_wq,
3199 INIT_DELAYED_WORK_RSL(&ieee->softmac_hint11d_wq,(void*)rtllib_softmac_hint11d_wq,ieee); 3141 (void *)rtllib_associate_complete_wq, ieee);
3200 INIT_DELAYED_WORK_RSL(&ieee->associate_retry_wq, (void*)rtllib_associate_retry_wq,ieee); 3142 INIT_DELAYED_WORK_RSL(&ieee->associate_procedure_wq,
3201 INIT_WORK_RSL(&ieee->wx_sync_scan_wq,(void*)rtllib_wx_sync_scan_wq,ieee); 3143 (void *)rtllib_associate_procedure_wq, ieee);
3144 INIT_DELAYED_WORK_RSL(&ieee->softmac_scan_wq,
3145 (void *)rtllib_softmac_scan_wq, ieee);
3146 INIT_DELAYED_WORK_RSL(&ieee->softmac_hint11d_wq,
3147 (void *)rtllib_softmac_hint11d_wq, ieee);
3148 INIT_DELAYED_WORK_RSL(&ieee->associate_retry_wq,
3149 (void *)rtllib_associate_retry_wq, ieee);
3150 INIT_WORK_RSL(&ieee->wx_sync_scan_wq, (void *)rtllib_wx_sync_scan_wq,
3151 ieee);
3202 3152
3203 sema_init(&ieee->wx_sem, 1); 3153 sema_init(&ieee->wx_sem, 1);
3204 sema_init(&ieee->scan_sem, 1); 3154 sema_init(&ieee->scan_sem, 1);
3205 sema_init(&ieee->ips_sem,1); 3155 sema_init(&ieee->ips_sem, 1);
3206 3156
3207 spin_lock_init(&ieee->mgmt_tx_lock); 3157 spin_lock_init(&ieee->mgmt_tx_lock);
3208 spin_lock_init(&ieee->beacon_lock); 3158 spin_lock_init(&ieee->beacon_lock);
@@ -3216,8 +3166,7 @@ void rtllib_softmac_init(struct rtllib_device *ieee)
3216void rtllib_softmac_free(struct rtllib_device *ieee) 3166void rtllib_softmac_free(struct rtllib_device *ieee)
3217{ 3167{
3218 down(&ieee->wx_sem); 3168 down(&ieee->wx_sem);
3219 if (NULL != ieee->pDot11dInfo) 3169 if (NULL != ieee->pDot11dInfo) {
3220 {
3221 kfree(ieee->pDot11dInfo); 3170 kfree(ieee->pDot11dInfo);
3222 ieee->pDot11dInfo = NULL; 3171 ieee->pDot11dInfo = NULL;
3223 } 3172 }
@@ -3229,8 +3178,8 @@ void rtllib_softmac_free(struct rtllib_device *ieee)
3229} 3178}
3230 3179
3231/******************************************************** 3180/********************************************************
3232 * Start of WPA code. * 3181 * Start of WPA code. *
3233 * this is stolen from the ipw2200 driver * 3182 * this is stolen from the ipw2200 driver *
3234 ********************************************************/ 3183 ********************************************************/
3235 3184
3236 3185
@@ -3238,14 +3187,15 @@ static int rtllib_wpa_enable(struct rtllib_device *ieee, int value)
3238{ 3187{
3239 /* This is called when wpa_supplicant loads and closes the driver 3188 /* This is called when wpa_supplicant loads and closes the driver
3240 * interface. */ 3189 * interface. */
3241 printk("%s WPA\n",value ? "enabling" : "disabling"); 3190 printk(KERN_INFO "%s WPA\n", value ? "enabling" : "disabling");
3242 ieee->wpa_enabled = value; 3191 ieee->wpa_enabled = value;
3243 memset(ieee->ap_mac_addr, 0, 6); 3192 memset(ieee->ap_mac_addr, 0, 6);
3244 return 0; 3193 return 0;
3245} 3194}
3246 3195
3247 3196
3248void rtllib_wpa_assoc_frame(struct rtllib_device *ieee, char *wpa_ie, int wpa_ie_len) 3197void rtllib_wpa_assoc_frame(struct rtllib_device *ieee, char *wpa_ie,
3198 int wpa_ie_len)
3249{ 3199{
3250 /* make sure WPA is enabled */ 3200 /* make sure WPA is enabled */
3251 rtllib_wpa_enable(ieee, 1); 3201 rtllib_wpa_enable(ieee, 1);
@@ -3268,7 +3218,7 @@ static int rtllib_wpa_mlme(struct rtllib_device *ieee, int command, int reason)
3268 break; 3218 break;
3269 3219
3270 default: 3220 default:
3271 printk("Unknown MLME request: %d\n", command); 3221 printk(KERN_INFO "Unknown MLME request: %d\n", command);
3272 ret = -EOPNOTSUPP; 3222 ret = -EOPNOTSUPP;
3273 } 3223 }
3274 3224
@@ -3319,12 +3269,11 @@ static int rtllib_wpa_set_auth_algs(struct rtllib_device *ieee, int value)
3319 sec.auth_mode = WLAN_AUTH_SHARED_KEY; 3269 sec.auth_mode = WLAN_AUTH_SHARED_KEY;
3320 ieee->open_wep = 0; 3270 ieee->open_wep = 0;
3321 ieee->auth_mode = 1; 3271 ieee->auth_mode = 1;
3322 } else if (value & AUTH_ALG_OPEN_SYSTEM){ 3272 } else if (value & AUTH_ALG_OPEN_SYSTEM) {
3323 sec.auth_mode = WLAN_AUTH_OPEN; 3273 sec.auth_mode = WLAN_AUTH_OPEN;
3324 ieee->open_wep = 1; 3274 ieee->open_wep = 1;
3325 ieee->auth_mode = 0; 3275 ieee->auth_mode = 0;
3326 } 3276 } else if (value & AUTH_ALG_LEAP) {
3327 else if (value & AUTH_ALG_LEAP){
3328 sec.auth_mode = WLAN_AUTH_LEAP >> 6; 3277 sec.auth_mode = WLAN_AUTH_LEAP >> 6;
3329 ieee->open_wep = 1; 3278 ieee->open_wep = 1;
3330 ieee->auth_mode = 2; 3279 ieee->auth_mode = 2;
@@ -3339,7 +3288,7 @@ static int rtllib_wpa_set_auth_algs(struct rtllib_device *ieee, int value)
3339 3288
3340static int rtllib_wpa_set_param(struct rtllib_device *ieee, u8 name, u32 value) 3289static int rtllib_wpa_set_param(struct rtllib_device *ieee, u8 name, u32 value)
3341{ 3290{
3342 int ret=0; 3291 int ret = 0;
3343 unsigned long flags; 3292 unsigned long flags;
3344 3293
3345 switch (name) { 3294 switch (name) {
@@ -3348,11 +3297,11 @@ static int rtllib_wpa_set_param(struct rtllib_device *ieee, u8 name, u32 value)
3348 break; 3297 break;
3349 3298
3350 case IEEE_PARAM_TKIP_COUNTERMEASURES: 3299 case IEEE_PARAM_TKIP_COUNTERMEASURES:
3351 ieee->tkip_countermeasures=value; 3300 ieee->tkip_countermeasures = value;
3352 break; 3301 break;
3353 3302
3354 case IEEE_PARAM_DROP_UNENCRYPTED: 3303 case IEEE_PARAM_DROP_UNENCRYPTED:
3355 { 3304 {
3356 /* HACK: 3305 /* HACK:
3357 * 3306 *
3358 * wpa_supplicant calls set_wpa_enabled when the driver 3307 * wpa_supplicant calls set_wpa_enabled when the driver
@@ -3375,8 +3324,7 @@ static int rtllib_wpa_set_param(struct rtllib_device *ieee, u8 name, u32 value)
3375 if (!value) { 3324 if (!value) {
3376 sec.flags |= SEC_LEVEL; 3325 sec.flags |= SEC_LEVEL;
3377 sec.level = SEC_LEVEL_0; 3326 sec.level = SEC_LEVEL_0;
3378 } 3327 } else {
3379 else {
3380 sec.flags |= SEC_LEVEL; 3328 sec.flags |= SEC_LEVEL;
3381 sec.level = SEC_LEVEL_1; 3329 sec.level = SEC_LEVEL_1;
3382 } 3330 }
@@ -3386,7 +3334,7 @@ static int rtllib_wpa_set_param(struct rtllib_device *ieee, u8 name, u32 value)
3386 } 3334 }
3387 3335
3388 case IEEE_PARAM_PRIVACY_INVOKED: 3336 case IEEE_PARAM_PRIVACY_INVOKED:
3389 ieee->privacy_invoked=value; 3337 ieee->privacy_invoked = value;
3390 break; 3338 break;
3391 3339
3392 case IEEE_PARAM_AUTH_ALGS: 3340 case IEEE_PARAM_AUTH_ALGS:
@@ -3394,15 +3342,15 @@ static int rtllib_wpa_set_param(struct rtllib_device *ieee, u8 name, u32 value)
3394 break; 3342 break;
3395 3343
3396 case IEEE_PARAM_IEEE_802_1X: 3344 case IEEE_PARAM_IEEE_802_1X:
3397 ieee->ieee802_1x=value; 3345 ieee->ieee802_1x = value;
3398 break; 3346 break;
3399 case IEEE_PARAM_WPAX_SELECT: 3347 case IEEE_PARAM_WPAX_SELECT:
3400 spin_lock_irqsave(&ieee->wpax_suitlist_lock,flags); 3348 spin_lock_irqsave(&ieee->wpax_suitlist_lock, flags);
3401 spin_unlock_irqrestore(&ieee->wpax_suitlist_lock,flags); 3349 spin_unlock_irqrestore(&ieee->wpax_suitlist_lock, flags);
3402 break; 3350 break;
3403 3351
3404 default: 3352 default:
3405 printk("Unknown WPA param: %d\n",name); 3353 printk(KERN_INFO "Unknown WPA param: %d\n", name);
3406 ret = -EOPNOTSUPP; 3354 ret = -EOPNOTSUPP;
3407 } 3355 }
3408 3356
@@ -3411,7 +3359,8 @@ static int rtllib_wpa_set_param(struct rtllib_device *ieee, u8 name, u32 value)
3411 3359
3412/* implementation borrowed from hostap driver */ 3360/* implementation borrowed from hostap driver */
3413static int rtllib_wpa_set_encryption(struct rtllib_device *ieee, 3361static int rtllib_wpa_set_encryption(struct rtllib_device *ieee,
3414 struct ieee_param *param, int param_len, u8 is_mesh) 3362 struct ieee_param *param, int param_len,
3363 u8 is_mesh)
3415{ 3364{
3416 int ret = 0; 3365 int ret = 0;
3417 struct rtllib_crypto_ops *ops; 3366 struct rtllib_crypto_ops *ops;
@@ -3427,7 +3376,7 @@ static int rtllib_wpa_set_encryption(struct rtllib_device *ieee,
3427 if (param_len != 3376 if (param_len !=
3428 (int) ((char *) param->u.crypt.key - (char *) param) + 3377 (int) ((char *) param->u.crypt.key - (char *) param) +
3429 param->u.crypt.key_len) { 3378 param->u.crypt.key_len) {
3430 printk("Len mismatch %d, %d\n", param_len, 3379 printk(KERN_INFO "Len mismatch %d, %d\n", param_len,
3431 param->u.crypt.key_len); 3380 param->u.crypt.key_len);
3432 return -EINVAL; 3381 return -EINVAL;
3433 } 3382 }
@@ -3470,7 +3419,8 @@ static int rtllib_wpa_set_encryption(struct rtllib_device *ieee,
3470 ops = rtllib_get_crypto_ops(param->u.crypt.alg); 3419 ops = rtllib_get_crypto_ops(param->u.crypt.alg);
3471 } 3420 }
3472 if (ops == NULL) { 3421 if (ops == NULL) {
3473 printk("unknown crypto alg '%s'\n", param->u.crypt.alg); 3422 printk(KERN_INFO "unknown crypto alg '%s'\n",
3423 param->u.crypt.alg);
3474 param->u.crypt.err = IEEE_CRYPT_ERR_UNKNOWN_ALG; 3424 param->u.crypt.err = IEEE_CRYPT_ERR_UNKNOWN_ALG;
3475 ret = -EINVAL; 3425 ret = -EINVAL;
3476 goto done; 3426 goto done;
@@ -3506,7 +3456,7 @@ static int rtllib_wpa_set_encryption(struct rtllib_device *ieee,
3506 (*crypt)->ops->set_key(param->u.crypt.key, 3456 (*crypt)->ops->set_key(param->u.crypt.key,
3507 param->u.crypt.key_len, param->u.crypt.seq, 3457 param->u.crypt.key_len, param->u.crypt.seq,
3508 (*crypt)->priv) < 0) { 3458 (*crypt)->priv) < 0) {
3509 printk("key setting failed\n"); 3459 printk(KERN_INFO "key setting failed\n");
3510 param->u.crypt.err = IEEE_CRYPT_ERR_KEY_SET_FAILED; 3460 param->u.crypt.err = IEEE_CRYPT_ERR_KEY_SET_FAILED;
3511 ret = -EINVAL; 3461 ret = -EINVAL;
3512 goto done; 3462 goto done;
@@ -3551,7 +3501,7 @@ static int rtllib_wpa_set_encryption(struct rtllib_device *ieee,
3551 ieee->iw_mode != IW_MODE_INFRA && 3501 ieee->iw_mode != IW_MODE_INFRA &&
3552 ieee->reset_port && 3502 ieee->reset_port &&
3553 ieee->reset_port(ieee->dev)) { 3503 ieee->reset_port(ieee->dev)) {
3554 printk("reset_port failed\n"); 3504 printk(KERN_INFO "reset_port failed\n");
3555 param->u.crypt.err = IEEE_CRYPT_ERR_CARD_CONF_FAILED; 3505 param->u.crypt.err = IEEE_CRYPT_ERR_CARD_CONF_FAILED;
3556 return -EINVAL; 3506 return -EINVAL;
3557 } 3507 }
@@ -3559,7 +3509,7 @@ static int rtllib_wpa_set_encryption(struct rtllib_device *ieee,
3559 return ret; 3509 return ret;
3560} 3510}
3561 3511
3562inline struct sk_buff *rtllib_disauth_skb( struct rtllib_network *beacon, 3512inline struct sk_buff *rtllib_disauth_skb(struct rtllib_network *beacon,
3563 struct rtllib_device *ieee, u16 asRsn) 3513 struct rtllib_device *ieee, u16 asRsn)
3564{ 3514{
3565 struct sk_buff *skb; 3515 struct sk_buff *skb;
@@ -3567,13 +3517,13 @@ inline struct sk_buff *rtllib_disauth_skb( struct rtllib_network *beacon,
3567 int len = sizeof(struct rtllib_disauth) + ieee->tx_headroom; 3517 int len = sizeof(struct rtllib_disauth) + ieee->tx_headroom;
3568 3518
3569 skb = dev_alloc_skb(len); 3519 skb = dev_alloc_skb(len);
3570 if (!skb) { 3520 if (!skb)
3571 return NULL; 3521 return NULL;
3572 }
3573 3522
3574 skb_reserve(skb, ieee->tx_headroom); 3523 skb_reserve(skb, ieee->tx_headroom);
3575 3524
3576 disauth = (struct rtllib_disauth *) skb_put(skb,sizeof(struct rtllib_disauth)); 3525 disauth = (struct rtllib_disauth *) skb_put(skb,
3526 sizeof(struct rtllib_disauth));
3577 disauth->header.frame_ctl = cpu_to_le16(RTLLIB_STYPE_DEAUTH); 3527 disauth->header.frame_ctl = cpu_to_le16(RTLLIB_STYPE_DEAUTH);
3578 disauth->header.duration_id = 0; 3528 disauth->header.duration_id = 0;
3579 3529
@@ -3585,7 +3535,7 @@ inline struct sk_buff *rtllib_disauth_skb( struct rtllib_network *beacon,
3585 return skb; 3535 return skb;
3586} 3536}
3587 3537
3588inline struct sk_buff *rtllib_disassociate_skb( struct rtllib_network *beacon, 3538inline struct sk_buff *rtllib_disassociate_skb(struct rtllib_network *beacon,
3589 struct rtllib_device *ieee, u16 asRsn) 3539 struct rtllib_device *ieee, u16 asRsn)
3590{ 3540{
3591 struct sk_buff *skb; 3541 struct sk_buff *skb;
@@ -3593,13 +3543,13 @@ inline struct sk_buff *rtllib_disassociate_skb( struct rtllib_network *beacon,
3593 int len = sizeof(struct rtllib_disassoc) + ieee->tx_headroom; 3543 int len = sizeof(struct rtllib_disassoc) + ieee->tx_headroom;
3594 skb = dev_alloc_skb(len); 3544 skb = dev_alloc_skb(len);
3595 3545
3596 if (!skb) { 3546 if (!skb)
3597 return NULL; 3547 return NULL;
3598 }
3599 3548
3600 skb_reserve(skb, ieee->tx_headroom); 3549 skb_reserve(skb, ieee->tx_headroom);
3601 3550
3602 disass = (struct rtllib_disassoc *) skb_put(skb,sizeof(struct rtllib_disassoc)); 3551 disass = (struct rtllib_disassoc *) skb_put(skb,
3552 sizeof(struct rtllib_disassoc));
3603 disass->header.frame_ctl = cpu_to_le16(RTLLIB_STYPE_DISASSOC); 3553 disass->header.frame_ctl = cpu_to_le16(RTLLIB_STYPE_DISASSOC);
3604 disass->header.duration_id = 0; 3554 disass->header.duration_id = 0;
3605 3555
@@ -3616,36 +3566,36 @@ void SendDisassociation(struct rtllib_device *ieee, bool deauth, u16 asRsn)
3616 struct rtllib_network *beacon = &ieee->current_network; 3566 struct rtllib_network *beacon = &ieee->current_network;
3617 struct sk_buff *skb; 3567 struct sk_buff *skb;
3618 3568
3619 if (deauth) { 3569 if (deauth)
3620 skb = rtllib_disauth_skb(beacon,ieee,asRsn); 3570 skb = rtllib_disauth_skb(beacon, ieee, asRsn);
3621 } else { 3571 else
3622 skb = rtllib_disassociate_skb(beacon,ieee,asRsn); 3572 skb = rtllib_disassociate_skb(beacon, ieee, asRsn);
3623 }
3624 3573
3625 if (skb){ 3574 if (skb)
3626 softmac_mgmt_xmit(skb, ieee); 3575 softmac_mgmt_xmit(skb, ieee);
3627 }
3628} 3576}
3629 3577
3630u8 rtllib_ap_sec_type(struct rtllib_device *ieee) 3578u8 rtllib_ap_sec_type(struct rtllib_device *ieee)
3631{ 3579{
3632 static u8 ccmp_ie[4] = {0x00,0x50,0xf2,0x04}; 3580 static u8 ccmp_ie[4] = {0x00, 0x50, 0xf2, 0x04};
3633 static u8 ccmp_rsn_ie[4] = {0x00, 0x0f, 0xac, 0x04}; 3581 static u8 ccmp_rsn_ie[4] = {0x00, 0x0f, 0xac, 0x04};
3634 int wpa_ie_len= ieee->wpa_ie_len; 3582 int wpa_ie_len = ieee->wpa_ie_len;
3635 struct rtllib_crypt_data* crypt; 3583 struct rtllib_crypt_data *crypt;
3636 int encrypt; 3584 int encrypt;
3637 3585
3638 crypt = ieee->crypt[ieee->tx_keyidx]; 3586 crypt = ieee->crypt[ieee->tx_keyidx];
3639 encrypt = (ieee->current_network.capability & WLAN_CAPABILITY_PRIVACY) ||\ 3587 encrypt = (ieee->current_network.capability & WLAN_CAPABILITY_PRIVACY)
3640 (ieee->host_encrypt && crypt && crypt->ops && \ 3588 || (ieee->host_encrypt && crypt && crypt->ops &&
3641 (0 == strcmp(crypt->ops->name,"WEP"))); 3589 (0 == strcmp(crypt->ops->name, "WEP")));
3642 3590
3643 /* simply judge */ 3591 /* simply judge */
3644 if (encrypt && (wpa_ie_len == 0)) { 3592 if (encrypt && (wpa_ie_len == 0)) {
3645 return SEC_ALG_WEP; 3593 return SEC_ALG_WEP;
3646 } else if ((wpa_ie_len != 0)) { 3594 } else if ((wpa_ie_len != 0)) {
3647 if (((ieee->wpa_ie[0] == 0xdd) && (!memcmp(&(ieee->wpa_ie[14]),ccmp_ie,4))) || 3595 if (((ieee->wpa_ie[0] == 0xdd) &&
3648 ((ieee->wpa_ie[0] == 0x30) && (!memcmp(&ieee->wpa_ie[10],ccmp_rsn_ie, 4)))) 3596 (!memcmp(&(ieee->wpa_ie[14]), ccmp_ie, 4))) ||
3597 ((ieee->wpa_ie[0] == 0x30) &&
3598 (!memcmp(&ieee->wpa_ie[10], ccmp_rsn_ie, 4))))
3649 return SEC_ALG_CCMP; 3599 return SEC_ALG_CCMP;
3650 else 3600 else
3651 return SEC_ALG_TKIP; 3601 return SEC_ALG_TKIP;
@@ -3654,20 +3604,21 @@ u8 rtllib_ap_sec_type(struct rtllib_device *ieee)
3654 } 3604 }
3655} 3605}
3656 3606
3657int rtllib_wpa_supplicant_ioctl(struct rtllib_device *ieee, struct iw_point *p, u8 is_mesh) 3607int rtllib_wpa_supplicant_ioctl(struct rtllib_device *ieee, struct iw_point *p,
3608 u8 is_mesh)
3658{ 3609{
3659 struct ieee_param *param; 3610 struct ieee_param *param;
3660 int ret=0; 3611 int ret = 0;
3661 3612
3662 down(&ieee->wx_sem); 3613 down(&ieee->wx_sem);
3663 3614
3664 if (p->length < sizeof(struct ieee_param) || !p->pointer){ 3615 if (p->length < sizeof(struct ieee_param) || !p->pointer) {
3665 ret = -EINVAL; 3616 ret = -EINVAL;
3666 goto out; 3617 goto out;
3667 } 3618 }
3668 3619
3669 param = (struct ieee_param *)kmalloc(p->length, GFP_KERNEL); 3620 param = kmalloc(p->length, GFP_KERNEL);
3670 if (param == NULL){ 3621 if (param == NULL) {
3671 ret = -ENOMEM; 3622 ret = -ENOMEM;
3672 goto out; 3623 goto out;
3673 } 3624 }
@@ -3678,7 +3629,6 @@ int rtllib_wpa_supplicant_ioctl(struct rtllib_device *ieee, struct iw_point *p,
3678 } 3629 }
3679 3630
3680 switch (param->cmd) { 3631 switch (param->cmd) {
3681
3682 case IEEE_CMD_SET_WPA_PARAM: 3632 case IEEE_CMD_SET_WPA_PARAM:
3683 ret = rtllib_wpa_set_param(ieee, param->u.wpa_param.name, 3633 ret = rtllib_wpa_set_param(ieee, param->u.wpa_param.name,
3684 param->u.wpa_param.value); 3634 param->u.wpa_param.value);
@@ -3698,7 +3648,8 @@ int rtllib_wpa_supplicant_ioctl(struct rtllib_device *ieee, struct iw_point *p,
3698 break; 3648 break;
3699 3649
3700 default: 3650 default:
3701 printk("Unknown WPA supplicant request: %d\n",param->cmd); 3651 printk(KERN_INFO "Unknown WPA supplicant request: %d\n",
3652 param->cmd);
3702 ret = -EOPNOTSUPP; 3653 ret = -EOPNOTSUPP;
3703 break; 3654 break;
3704 } 3655 }
@@ -3713,8 +3664,7 @@ out:
3713 return ret; 3664 return ret;
3714} 3665}
3715 3666
3716void 3667void rtllib_MgntDisconnectIBSS(struct rtllib_device *rtllib)
3717rtllib_MgntDisconnectIBSS(struct rtllib_device* rtllib)
3718{ 3668{
3719 u8 OpMode; 3669 u8 OpMode;
3720 u8 i; 3670 u8 i;
@@ -3722,26 +3672,25 @@ rtllib_MgntDisconnectIBSS(struct rtllib_device* rtllib)
3722 3672
3723 rtllib->state = RTLLIB_NOLINK; 3673 rtllib->state = RTLLIB_NOLINK;
3724 3674
3725 for (i=0;i<6;i++) rtllib->current_network.bssid[i]= 0x55; 3675 for (i = 0; i < 6; i++)
3676 rtllib->current_network.bssid[i] = 0x55;
3726 3677
3727 rtllib->OpMode = RT_OP_MODE_NO_LINK; 3678 rtllib->OpMode = RT_OP_MODE_NO_LINK;
3728 rtllib->SetHwRegHandler(rtllib->dev, HW_VAR_BSSID, rtllib->current_network.bssid); 3679 rtllib->SetHwRegHandler(rtllib->dev, HW_VAR_BSSID,
3680 rtllib->current_network.bssid);
3729 OpMode = RT_OP_MODE_NO_LINK; 3681 OpMode = RT_OP_MODE_NO_LINK;
3730 rtllib->SetHwRegHandler(rtllib->dev, HW_VAR_MEDIA_STATUS, &OpMode); 3682 rtllib->SetHwRegHandler(rtllib->dev, HW_VAR_MEDIA_STATUS, &OpMode);
3731 rtllib_stop_send_beacons(rtllib); 3683 rtllib_stop_send_beacons(rtllib);
3732 3684
3733 bFilterOutNonAssociatedBSSID = false; 3685 bFilterOutNonAssociatedBSSID = false;
3734 rtllib->SetHwRegHandler(rtllib->dev, HW_VAR_CECHK_BSSID, (u8*)(&bFilterOutNonAssociatedBSSID)); 3686 rtllib->SetHwRegHandler(rtllib->dev, HW_VAR_CECHK_BSSID,
3687 (u8 *)(&bFilterOutNonAssociatedBSSID));
3735 notify_wx_assoc_event(rtllib); 3688 notify_wx_assoc_event(rtllib);
3736 3689
3737} 3690}
3738 3691
3739void 3692void rtllib_MlmeDisassociateRequest(struct rtllib_device *rtllib, u8 *asSta,
3740rtllib_MlmeDisassociateRequest( 3693 u8 asRsn)
3741 struct rtllib_device* rtllib,
3742 u8* asSta,
3743 u8 asRsn
3744 )
3745{ 3694{
3746 u8 i; 3695 u8 i;
3747 u8 OpMode; 3696 u8 OpMode;
@@ -3749,17 +3698,19 @@ rtllib_MlmeDisassociateRequest(
3749 RemovePeerTS(rtllib, asSta); 3698 RemovePeerTS(rtllib, asSta);
3750 3699
3751 3700
3752 if (memcpy(rtllib->current_network.bssid,asSta,6) == 0) 3701 if (memcpy(rtllib->current_network.bssid, asSta, 6) == 0) {
3753 {
3754 rtllib->state = RTLLIB_NOLINK; 3702 rtllib->state = RTLLIB_NOLINK;
3755 3703
3756 for (i=0;i<6;i++) rtllib->current_network.bssid[i] = 0x22; 3704 for (i = 0; i < 6; i++)
3705 rtllib->current_network.bssid[i] = 0x22;
3757 OpMode = RT_OP_MODE_NO_LINK; 3706 OpMode = RT_OP_MODE_NO_LINK;
3758 rtllib->OpMode = RT_OP_MODE_NO_LINK; 3707 rtllib->OpMode = RT_OP_MODE_NO_LINK;
3759 rtllib->SetHwRegHandler(rtllib->dev, HW_VAR_MEDIA_STATUS, (u8 *)(&OpMode) ); 3708 rtllib->SetHwRegHandler(rtllib->dev, HW_VAR_MEDIA_STATUS,
3709 (u8 *)(&OpMode));
3760 rtllib_disassociate(rtllib); 3710 rtllib_disassociate(rtllib);
3761 3711
3762 rtllib->SetHwRegHandler(rtllib->dev, HW_VAR_BSSID, rtllib->current_network.bssid); 3712 rtllib->SetHwRegHandler(rtllib->dev, HW_VAR_BSSID,
3713 rtllib->current_network.bssid);
3763 3714
3764 } 3715 }
3765 3716
@@ -3767,40 +3718,31 @@ rtllib_MlmeDisassociateRequest(
3767 3718
3768void 3719void
3769rtllib_MgntDisconnectAP( 3720rtllib_MgntDisconnectAP(
3770 struct rtllib_device* rtllib, 3721 struct rtllib_device *rtllib,
3771 u8 asRsn 3722 u8 asRsn
3772) 3723)
3773{ 3724{
3774 bool bFilterOutNonAssociatedBSSID = false; 3725 bool bFilterOutNonAssociatedBSSID = false;
3775 3726
3776 bFilterOutNonAssociatedBSSID = false; 3727 bFilterOutNonAssociatedBSSID = false;
3777 rtllib->SetHwRegHandler(rtllib->dev, HW_VAR_CECHK_BSSID, (u8*)(&bFilterOutNonAssociatedBSSID)); 3728 rtllib->SetHwRegHandler(rtllib->dev, HW_VAR_CECHK_BSSID,
3778 rtllib_MlmeDisassociateRequest( rtllib, rtllib->current_network.bssid, asRsn ); 3729 (u8 *)(&bFilterOutNonAssociatedBSSID));
3730 rtllib_MlmeDisassociateRequest(rtllib, rtllib->current_network.bssid,
3731 asRsn);
3779 3732
3780 rtllib->state = RTLLIB_NOLINK; 3733 rtllib->state = RTLLIB_NOLINK;
3781} 3734}
3782 3735
3783bool 3736bool rtllib_MgntDisconnect(struct rtllib_device *rtllib, u8 asRsn)
3784rtllib_MgntDisconnect(
3785 struct rtllib_device* rtllib,
3786 u8 asRsn
3787)
3788{ 3737{
3789 if (rtllib->ps != RTLLIB_PS_DISABLED) 3738 if (rtllib->ps != RTLLIB_PS_DISABLED)
3790 { 3739 rtllib->sta_wake_up(rtllib->dev);
3791 rtllib->sta_wake_up(rtllib->dev);
3792 }
3793 3740
3794 if ( rtllib->state == RTLLIB_LINKED ) 3741 if (rtllib->state == RTLLIB_LINKED) {
3795 { 3742 if (rtllib->iw_mode == IW_MODE_ADHOC)
3796 if ( rtllib->iw_mode == IW_MODE_ADHOC )
3797 {
3798 rtllib_MgntDisconnectIBSS(rtllib); 3743 rtllib_MgntDisconnectIBSS(rtllib);
3799 } 3744 if (rtllib->iw_mode == IW_MODE_INFRA)
3800 if ( rtllib->iw_mode == IW_MODE_INFRA )
3801 {
3802 rtllib_MgntDisconnectAP(rtllib, asRsn); 3745 rtllib_MgntDisconnectAP(rtllib, asRsn);
3803 }
3804 3746
3805 } 3747 }
3806 3748
@@ -3816,10 +3758,12 @@ void notify_wx_assoc_event(struct rtllib_device *ieee)
3816 3758
3817 wrqu.ap_addr.sa_family = ARPHRD_ETHER; 3759 wrqu.ap_addr.sa_family = ARPHRD_ETHER;
3818 if (ieee->state == RTLLIB_LINKED) 3760 if (ieee->state == RTLLIB_LINKED)
3819 memcpy(wrqu.ap_addr.sa_data, ieee->current_network.bssid, ETH_ALEN); 3761 memcpy(wrqu.ap_addr.sa_data, ieee->current_network.bssid,
3820 else{ 3762 ETH_ALEN);
3763 else {
3821 3764
3822 printk("%s(): Tell user space disconnected\n",__func__); 3765 printk(KERN_INFO "%s(): Tell user space disconnected\n",
3766 __func__);
3823 memset(wrqu.ap_addr.sa_data, 0, ETH_ALEN); 3767 memset(wrqu.ap_addr.sa_data, 0, ETH_ALEN);
3824 } 3768 }
3825 wireless_send_event(ieee->dev, SIOCGIWAP, &wrqu, NULL); 3769 wireless_send_event(ieee->dev, SIOCGIWAP, &wrqu, NULL);