19 #include <linux/random.h>
21 #include <linux/slab.h>
22 #include <asm/uaccess.h>
28 {0x00,0x0F,0xAC,0x00},
29 {0x00,0x0F,0xAC,0x01},
30 {0x00,0x0F,0xAC,0x02},
31 {0x00,0x0F,0xAC,0x03},
32 {0x00,0x0F,0xAC,0x04},
33 {0x00,0x0F,0xAC,0x05},
52 unsigned int rate_len = 0;
241 tcb_desc->RATRIndex = 7;
242 tcb_desc->bTxDisableRateFallBack = 1;
243 tcb_desc->bTxUseDriverAssingedRate = 1;
262 spin_unlock_irqrestore(&ieee->
lock, flags);
264 spin_unlock_irqrestore(&ieee->
lock, flags);
276 (skb_queue_len(&ieee->
skb_waitQ[tcb_desc->queue_index]) != 0)||\
331 unsigned int len,rate_len;
349 req->
header.duration_id = 0;
355 tag = (
u8 *)
skb_put(skb,len+2+rate_len);
443 }
while(!channel_map[ch]);
467 if(channel_map[ch] == 1)
657 skb = dev_alloc_skb(len);
658 if (!skb)
return NULL;
660 skb_reserve(skb, ieee->tx_headroom);
667 auth->
header.duration_id = 0x013a;
674 if(ieee->auth_mode == 0)
676 else if(ieee->auth_mode == 1)
678 else if(ieee->auth_mode == 2)
682 ieee->associate_seq++;
698 int atim_len,erp_len;
706 u8 erpinfo_content = 0;
711 u8 tmp_ht_info_len=0;
713 u8* tmp_generic_ie_buf=
NULL;
714 u8 tmp_generic_ie_len=0;
716 if(rate_ex_len > 0) rate_ex_len+=2;
733 ((0 ==
strcmp(crypt->
ops->name,
"WEP") || wpa_ie_len));
763 skb = dev_alloc_skb(beacon_size);
772 beacon_buf->
header.duration_id = 0;
794 memcpy(tag, ssid, ssid_len);
799 *(tag++) = rate_len-2;
820 *(tag++) = erpinfo_content;
824 *(tag++) = rate_ex_len-2;
856 skb = dev_alloc_skb(len);
861 skb_reserve(skb, ieee->tx_headroom);
877 if (ieee->host_encrypt)
878 crypt = ieee->crypt[ieee->tx_keyidx];
881 encrypt = ( crypt && crypt->
ops);
888 if (ieee->assoc_id == 0x2007) ieee->assoc_id=0;
889 else ieee->assoc_id++;
905 skb = dev_alloc_skb(len);
975 struct sk_buff *
buf = ieee80211_probe_resp(ieee, dest);
999 unsigned int ckip_ie_len=0;
1000 unsigned int ccxrm_ie_len=0;
1001 unsigned int cxvernum_ie_len=0;
1006 unsigned int wmm_info_len = beacon->
qos_data.supported?9:0;
1008 unsigned int turbo_info_len = beacon->
Turbo_Enable?9:0;
1031 wmm_info_len = beacon->
qos_data.supported?9:0;
1045 cxvernum_ie_len = 5+2;
1059 + ieee->tx_headroom;
1071 + ieee->tx_headroom;
1074 skb = dev_alloc_skb(len);
1079 skb_reserve(skb, ieee->tx_headroom);
1086 hdr->
header.duration_id= 37;
1100 if(ieee->short_slot)
1110 tag =
skb_put(skb, beacon->ssid_len);
1111 memcpy(tag, beacon->ssid, beacon->ssid_len);
1118 if( beacon->bCkipSupported )
1120 static u8 AironetIeOui[] = {0x00, 0x01, 0x66};
1121 u8 CcxAironetBuf[30];
1124 memset(CcxAironetBuf, 0,30);
1125 osCcxAironetIE.
Octet = CcxAironetBuf;
1126 osCcxAironetIE.
Length =
sizeof(CcxAironetBuf);
1131 memcpy(osCcxAironetIE.
Octet, AironetIeOui,
sizeof(AironetIeOui));
1137 tag =
skb_put(skb, ckip_ie_len);
1139 *tag++ = osCcxAironetIE.
Length;
1141 tag += osCcxAironetIE.
Length;
1144 if(beacon->bCcxRmEnable)
1146 static u8 CcxRmCapBuf[] = {0x00, 0x40, 0x96, 0x01, 0x01, 0x00};
1149 osCcxRmCap.
Octet = CcxRmCapBuf;
1150 osCcxRmCap.
Length =
sizeof(CcxRmCapBuf);
1151 tag =
skb_put(skb,ccxrm_ie_len);
1153 *tag++ = osCcxRmCap.
Length;
1155 tag += osCcxRmCap.
Length;
1158 if( beacon->BssCcxVerNumber >= 2 )
1160 u8 CcxVerNumBuf[] = {0x00, 0x40, 0x96, 0x03, 0x00};
1162 CcxVerNumBuf[4] = beacon->BssCcxVerNumber;
1163 osCcxVerNum.
Octet = CcxVerNumBuf;
1164 osCcxVerNum.
Length =
sizeof(CcxVerNumBuf);
1165 tag =
skb_put(skb,cxvernum_ie_len);
1167 *tag++ = osCcxVerNum.
Length;
1169 tag += osCcxVerNum.
Length;
1172 if(ieee->pHTInfo->bCurrentHTSupport&&ieee->pHTInfo->bEnableHT){
1175 tag =
skb_put(skb, ht_cap_len);
1177 *tag++ = ht_cap_len - 2;
1178 memcpy(tag, ht_cap_buf,ht_cap_len -2);
1179 tag += ht_cap_len -2;
1185 tag =
skb_put(skb, wpa_ie_len);
1187 memcpy(tag, ieee->wpa_ie, ieee->wpa_ie_len);
1190 tag =
skb_put(skb,wmm_info_len);
1195 tag =
skb_put(skb,turbo_info_len);
1196 if(turbo_info_len) {
1201 if(ieee->pHTInfo->bCurrentHTSupport&&ieee->pHTInfo->bEnableHT){
1204 tag =
skb_put(skb, ht_cap_len);
1206 *tag++ = ht_cap_len - 2;
1207 memcpy(tag, ht_cap_buf,ht_cap_len - 2);
1208 tag += ht_cap_len -2;
1211 if(ieee->pHTInfo->bCurrentRT2RTAggregation){
1212 tag =
skb_put(skb, realtek_ie_len);
1214 *tag++ = realtek_ie_len - 2;
1215 memcpy(tag, realtek_ie_buf,realtek_ie_len -2 );
1226 unsigned long flags;
1250 spin_unlock_irqrestore(&ieee->
lock, flags);
1302 memcpy(c, challenge, chlen);
1349 printk(
"Successfully associated, ht enabled\n");
1367 printk(
"============>normal associate\n");
1372 printk(
"==================>silent reset associate\n");
1415 int tmp_ssid_len = 0;
1417 short apset,ssidset,ssidbroad,apmatch,ssidmatch;
1439 ssidbroad = !(net->
ssid_len == 0 || net->
ssid[0]==
'\0');
1450 ( apset && apmatch &&
1451 ((ssidset && ssidbroad && ssidmatch) || (ssidbroad && !ssidset) || (!ssidbroad && ssidset)) ) ||
1455 (!apset && ssidset && ssidbroad && ssidmatch)
1516 unsigned long flags;
1534 spin_unlock_irqrestore(&ieee->
lock, flags);
1539 static inline u16 auth_parse(
struct sk_buff *skb,
u8** challenge,
int *chlen)
1602 while (tag+1 < skbend){
1614 if (ssidlen == 0)
return 1;
1616 if (!ssid)
return 1;
1674 if (probe_rq_parse(ieee, skb, dest)){
1765 if(time_l && *time_l < ieee->current_network.last_dtim_sta_time[0])
1827 }
else if(sleep == 2){
1837 spin_unlock_irqrestore(&ieee->
lock, flags);
1845 printk(
"Warning: driver is probably failing to report TX ps error\n");
1889 spin_unlock_irqrestore(&ieee->
lock, flags);
1894 u8* act = ieee80211_get_payload(header);
1934 bool bSupportNmode =
true, bHalfSupportNmode =
false;
1943 tasklet_schedule(&ieee->
ps_task);
1962 if (0 == (
errcode=assoc_parse(ieee,skb, &aid))){
1970 memset(network, 0,
sizeof(*network));
1972 rx_stats->
len -
sizeof(*assoc_resp),\
1989 "Association response status code 0x%x\n",
1992 "Association response status code 0x%x\n",
2020 if (0 == (
errcode=auth_parse(skb, &challenge, &chlen))){
2031 bSupportNmode =
true;
2032 bHalfSupportNmode =
true;
2036 bSupportNmode =
false;
2037 bHalfSupportNmode =
false;
2039 printk(
"==========>to link with AP using SEC(%d, %d)", bSupportNmode, bHalfSupportNmode);
2055 printk(
"===============>entern half N mode\n");
2083 ieee80211_rx_probe_rq(ieee, skb);
2139 unsigned long flags;
2150 ieee->
stats.tx_packets++;
2153 ieee->
stats.multicast++;
2156 for(i = 0; i < txb->
nr_frags; i++) {
2157 #ifdef USB_TX_DRIVER_AGGREGATION_ENABLE
2158 if ((skb_queue_len(&ieee->
skb_drv_aggQ[queue_index]) != 0) ||
2160 if ((skb_queue_len(&ieee->
skb_waitQ[queue_index]) != 0) ||
2170 #ifdef USB_TX_DRIVER_AGGREGATION_ENABLE
2187 spin_unlock_irqrestore(&ieee->
lock,flags);
2206 ieee->
stats.tx_packets++;
2219 unsigned long flags;
2228 spin_unlock_irqrestore(&ieee->
lock,flags);
2235 unsigned long flags;
2265 netif_wake_queue(ieee->
dev);
2269 spin_unlock_irqrestore(&ieee->
lock,flags);
2278 if (! netif_queue_stopped(ieee->
dev)){
2279 netif_stop_queue(ieee->
dev);
2344 printk(
"==========oh driver down return\n");
2381 printk(
"creating new IBSS cell\n");
2449 unsigned long flags;
2481 spin_unlock_irqrestore(&ieee->
lock, flags);
2508 unsigned long flags;
2539 spin_unlock_irqrestore(&ieee->
lock, flags);
2547 u8 broadcast_addr[] = {0xff,0xff,0xff,0xff,0xff,0xff};
2552 skb = ieee80211_probe_resp(ieee, broadcast_addr);
2641 for(i = 0; i < 17; i++) {
2669 #define DRV_NAME "Ieee80211"
2677 for(i = 0; i < 5; i++) {
2734 sema_init(&ieee->
wx_sem, 1);
2742 (
unsigned long)ieee);
2769 printk(
"%s WPA\n",value ?
"enabling" :
"disabling");
2778 ieee80211_wpa_enable(ieee, 1);
2799 printk(
"Unknown MLME request: %d\n", command);
2835 #define AUTH_ALG_OPEN_SYSTEM 0x1
2836 #define AUTH_ALG_SHARED_KEY 0x2
2873 unsigned long flags;
2877 ret = ieee80211_wpa_enable(ieee, value);
2922 ret = ieee80211_wpa_set_auth_algs(ieee, value);
2937 printk(
"Unknown WPA param: %d\n",name);
2962 (
int) ((
char *) param->
u.
crypt.key - (
char *) param) +
2963 param->
u.
crypt.key_len) {
2964 printk(
"Len mismatch %d, %d\n", param_len,
2968 if (is_broadcast_ether_addr(param->
sta_addr)) {
2995 goto skip_host_crypt;
2999 request_module(
"ieee80211_crypt_wep");
3003 request_module(
"ieee80211_crypt_tkip");
3006 request_module(
"ieee80211_crypt_ccmp");
3010 printk(
"unknown crypto alg '%s'\n", param->
u.
crypt.alg);
3016 if (*crypt ==
NULL || (*crypt)->ops != ops) {
3022 if (new_crypt ==
NULL) {
3028 if (new_crypt->
ops && try_module_get(new_crypt->
ops->owner))
3030 new_crypt->
ops->init(param->
u.
crypt.idx);
3042 if (param->
u.
crypt.key_len > 0 && (*crypt)->ops->set_key &&
3043 (*crypt)->ops->set_key(param->
u.
crypt.key,
3045 (*crypt)->priv) < 0) {
3046 printk(
"key setting failed\n");
3053 if (param->
u.
crypt.set_tx) {
3091 printk(
"reset_port failed\n");
3113 disass->
header.duration_id = 0;
3164 switch (param->
cmd) {
3167 ret = ieee80211_wpa_set_param(ieee, param->
u.
wpa_param.name,
3172 ret = ieee80211_wpa_set_wpa_ie(ieee, param, p->
length);
3176 ret = ieee80211_wpa_set_encryption(ieee, param, p->
length);
3180 ret = ieee80211_wpa_mlme(ieee, param->
u.
mlme.command,
3181 param->
u.
mlme.reason_code);
3185 printk(
"Unknown WPA supplicant request: %d\n",param->
cmd);