aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/staging/vt6656
diff options
context:
space:
mode:
authorJesper Juhl <jj@chaosbits.net>2012-06-24 19:56:15 -0400
committerGreg Kroah-Hartman <gregkh@linuxfoundation.org>2012-06-25 14:10:29 -0400
commit48746d7f4d9a821e547e2c1e6623a8e20a0a70a7 (patch)
tree504e0f038a9b0c8ec98fadf3325851edd6530f33 /drivers/staging/vt6656
parent921cd68b671d277bab8956e066a0f765ce0defb3 (diff)
staging: vt6656: iwctl: Fix indentation
Fix indentation for the entire files to use tabs rather than spaces and also make sure everything is indented to the proper depth according to context. Signed-off-by: Jesper Juhl <jj@chaosbits.net> Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
Diffstat (limited to 'drivers/staging/vt6656')
-rw-r--r--drivers/staging/vt6656/iwctl.c1240
1 files changed, 620 insertions, 620 deletions
diff --git a/drivers/staging/vt6656/iwctl.c b/drivers/staging/vt6656/iwctl.c
index 3ac41bb8a9a..7618fb94cdf 100644
--- a/drivers/staging/vt6656/iwctl.c
+++ b/drivers/staging/vt6656/iwctl.c
@@ -53,12 +53,12 @@
53#endif 53#endif
54 54
55static const long frequency_list[] = { 55static const long frequency_list[] = {
56 2412, 2417, 2422, 2427, 2432, 2437, 2442, 2447, 2452, 2457, 2462, 2467, 2472, 2484, 56 2412, 2417, 2422, 2427, 2432, 2437, 2442, 2447, 2452, 2457, 2462, 2467, 2472, 2484,
57 4915, 4920, 4925, 4935, 4940, 4945, 4960, 4980, 57 4915, 4920, 4925, 4935, 4940, 4945, 4960, 4980,
58 5035, 5040, 5045, 5055, 5060, 5080, 5170, 5180, 5190, 5200, 5210, 5220, 5230, 5240, 58 5035, 5040, 5045, 5055, 5060, 5080, 5170, 5180, 5190, 5200, 5210, 5220, 5230, 5240,
59 5260, 5280, 5300, 5320, 5500, 5520, 5540, 5560, 5580, 5600, 5620, 5640, 5660, 5680, 59 5260, 5280, 5300, 5320, 5500, 5520, 5540, 5560, 5580, 5600, 5620, 5640, 5660, 5680,
60 5700, 5745, 5765, 5785, 5805, 5825 60 5700, 5745, 5765, 5785, 5805, 5825
61 }; 61};
62 62
63static int msglevel =MSG_LEVEL_INFO; 63static int msglevel =MSG_LEVEL_INFO;
64 64
@@ -68,9 +68,9 @@ struct iw_statistics *iwctl_get_wireless_stats(struct net_device *dev)
68 long ldBm; 68 long ldBm;
69 69
70 pDevice->wstats.status = pDevice->eOPMode; 70 pDevice->wstats.status = pDevice->eOPMode;
71 if(pDevice->scStatistic.LinkQuality > 100) 71 if(pDevice->scStatistic.LinkQuality > 100)
72 pDevice->scStatistic.LinkQuality = 100; 72 pDevice->scStatistic.LinkQuality = 100;
73 pDevice->wstats.qual.qual =(BYTE) pDevice->scStatistic.LinkQuality; 73 pDevice->wstats.qual.qual =(BYTE) pDevice->scStatistic.LinkQuality;
74 RFvRSSITodBm(pDevice, (BYTE)(pDevice->uCurrRSSI), &ldBm); 74 RFvRSSITodBm(pDevice, (BYTE)(pDevice->uCurrRSSI), &ldBm);
75 pDevice->wstats.qual.level = ldBm; 75 pDevice->wstats.qual.level = ldBm;
76 pDevice->wstats.qual.noise = 0; 76 pDevice->wstats.qual.noise = 0;
@@ -101,65 +101,65 @@ int iwctl_siwscan(struct net_device *dev, struct iw_request_info *info,
101 struct iw_point *wrq, char *extra) 101 struct iw_point *wrq, char *extra)
102{ 102{
103 PSDevice pDevice = (PSDevice)netdev_priv(dev); 103 PSDevice pDevice = (PSDevice)netdev_priv(dev);
104 PSMgmtObject pMgmt = &(pDevice->sMgmtObj); 104 PSMgmtObject pMgmt = &(pDevice->sMgmtObj);
105 struct iw_scan_req *req = (struct iw_scan_req *)extra; 105 struct iw_scan_req *req = (struct iw_scan_req *)extra;
106 BYTE abyScanSSID[WLAN_IEHDR_LEN + WLAN_SSID_MAXLEN + 1]; 106 BYTE abyScanSSID[WLAN_IEHDR_LEN + WLAN_SSID_MAXLEN + 1];
107 PWLAN_IE_SSID pItemSSID=NULL; 107 PWLAN_IE_SSID pItemSSID=NULL;
108 108
109 if (!(pDevice->flags & DEVICE_FLAGS_OPENED)) 109 if (!(pDevice->flags & DEVICE_FLAGS_OPENED))
110 return -EINVAL; 110 return -EINVAL;
111 111
112 PRINT_K(" SIOCSIWSCAN \n"); 112 PRINT_K(" SIOCSIWSCAN \n");
113 113
114if (pMgmt->eScanState == WMAC_IS_SCANNING) { 114 if (pMgmt->eScanState == WMAC_IS_SCANNING) {
115 // In scanning.. 115 // In scanning..
116 PRINT_K("SIOCSIWSCAN(overlap??)-->In scanning...\n"); 116 PRINT_K("SIOCSIWSCAN(overlap??)-->In scanning...\n");
117 return -EAGAIN; 117 return -EAGAIN;
118 } 118 }
119 119
120if(pDevice->byReAssocCount > 0) { //reject scan when re-associating! 120 if(pDevice->byReAssocCount > 0) { //reject scan when re-associating!
121//send scan event to wpa_Supplicant 121//send scan event to wpa_Supplicant
122 union iwreq_data wrqu; 122 union iwreq_data wrqu;
123 PRINT_K("wireless_send_event--->SIOCGIWSCAN(scan done)\n"); 123 PRINT_K("wireless_send_event--->SIOCGIWSCAN(scan done)\n");
124 memset(&wrqu, 0, sizeof(wrqu)); 124 memset(&wrqu, 0, sizeof(wrqu));
125 wireless_send_event(pDevice->dev, SIOCGIWSCAN, &wrqu, NULL); 125 wireless_send_event(pDevice->dev, SIOCGIWSCAN, &wrqu, NULL);
126 return 0; 126 return 0;
127} 127 }
128 128
129 spin_lock_irq(&pDevice->lock); 129 spin_lock_irq(&pDevice->lock);
130 130
131 BSSvClearBSSList((void *) pDevice, pDevice->bLinkPass); 131 BSSvClearBSSList((void *) pDevice, pDevice->bLinkPass);
132 132
133//mike add: active scan OR passive scan OR desire_ssid scan 133//mike add: active scan OR passive scan OR desire_ssid scan
134 if(wrq->length == sizeof(struct iw_scan_req)) { 134 if(wrq->length == sizeof(struct iw_scan_req)) {
135 if (wrq->flags & IW_SCAN_THIS_ESSID) { //desire_ssid scan 135 if (wrq->flags & IW_SCAN_THIS_ESSID) { //desire_ssid scan
136 memset(abyScanSSID, 0, WLAN_IEHDR_LEN + WLAN_SSID_MAXLEN + 1); 136 memset(abyScanSSID, 0, WLAN_IEHDR_LEN + WLAN_SSID_MAXLEN + 1);
137 pItemSSID = (PWLAN_IE_SSID)abyScanSSID; 137 pItemSSID = (PWLAN_IE_SSID)abyScanSSID;
138 pItemSSID->byElementID = WLAN_EID_SSID; 138 pItemSSID->byElementID = WLAN_EID_SSID;
139 memcpy(pItemSSID->abySSID, req->essid, (int)req->essid_len); 139 memcpy(pItemSSID->abySSID, req->essid, (int)req->essid_len);
140 if (pItemSSID->abySSID[req->essid_len - 1] == '\0') { 140 if (pItemSSID->abySSID[req->essid_len - 1] == '\0') {
141 if(req->essid_len>0) 141 if(req->essid_len>0)
142 pItemSSID->len = req->essid_len - 1; 142 pItemSSID->len = req->essid_len - 1;
143 } 143 }
144 else 144 else
145 pItemSSID->len = req->essid_len; 145 pItemSSID->len = req->essid_len;
146 pMgmt->eScanType = WMAC_SCAN_PASSIVE; 146 pMgmt->eScanType = WMAC_SCAN_PASSIVE;
147 PRINT_K("SIOCSIWSCAN:[desired_ssid=%s,len=%d]\n",((PWLAN_IE_SSID)abyScanSSID)->abySSID, 147 PRINT_K("SIOCSIWSCAN:[desired_ssid=%s,len=%d]\n",((PWLAN_IE_SSID)abyScanSSID)->abySSID,
148 ((PWLAN_IE_SSID)abyScanSSID)->len); 148 ((PWLAN_IE_SSID)abyScanSSID)->len);
149 bScheduleCommand((void *) pDevice, WLAN_CMD_BSSID_SCAN, abyScanSSID); 149 bScheduleCommand((void *) pDevice, WLAN_CMD_BSSID_SCAN, abyScanSSID);
150 spin_unlock_irq(&pDevice->lock); 150 spin_unlock_irq(&pDevice->lock);
151
152 return 0;
153 }
154 else if(req->scan_type == IW_SCAN_TYPE_PASSIVE) { //passive scan
155 pMgmt->eScanType = WMAC_SCAN_PASSIVE;
156 }
157 }
158 else { //active scan
159 pMgmt->eScanType = WMAC_SCAN_ACTIVE;
160 }
151 161
152 return 0; 162 pMgmt->eScanType = WMAC_SCAN_PASSIVE;
153 }
154 else if(req->scan_type == IW_SCAN_TYPE_PASSIVE) { //passive scan
155 pMgmt->eScanType = WMAC_SCAN_PASSIVE;
156 }
157 }
158 else { //active scan
159 pMgmt->eScanType = WMAC_SCAN_ACTIVE;
160 }
161
162 pMgmt->eScanType = WMAC_SCAN_PASSIVE;
163 bScheduleCommand((void *) pDevice, WLAN_CMD_BSSID_SCAN, NULL); 163 bScheduleCommand((void *) pDevice, WLAN_CMD_BSSID_SCAN, NULL);
164 spin_unlock_irq(&pDevice->lock); 164 spin_unlock_irq(&pDevice->lock);
165 165
@@ -172,12 +172,12 @@ if(pDevice->byReAssocCount > 0) { //reject scan when re-associating!
172int iwctl_giwscan(struct net_device *dev, struct iw_request_info *info, 172int iwctl_giwscan(struct net_device *dev, struct iw_request_info *info,
173 struct iw_point *wrq, char *extra) 173 struct iw_point *wrq, char *extra)
174{ 174{
175 int ii, jj, kk; 175 int ii, jj, kk;
176 PSDevice pDevice = (PSDevice)netdev_priv(dev); 176 PSDevice pDevice = (PSDevice)netdev_priv(dev);
177 PSMgmtObject pMgmt = &(pDevice->sMgmtObj); 177 PSMgmtObject pMgmt = &(pDevice->sMgmtObj);
178 PKnownBSS pBSS; 178 PKnownBSS pBSS;
179 PWLAN_IE_SSID pItemSSID; 179 PWLAN_IE_SSID pItemSSID;
180 PWLAN_IE_SUPP_RATES pSuppRates, pExtSuppRates; 180 PWLAN_IE_SUPP_RATES pSuppRates, pExtSuppRates;
181 char *current_ev = extra; 181 char *current_ev = extra;
182 char *end_buf = extra + IW_SCAN_MAX_DATA; 182 char *end_buf = extra + IW_SCAN_MAX_DATA;
183 char *current_val = NULL; 183 char *current_val = NULL;
@@ -185,131 +185,131 @@ int iwctl_giwscan(struct net_device *dev, struct iw_request_info *info,
185 long ldBm; 185 long ldBm;
186 char buf[MAX_WPA_IE_LEN * 2 + 30]; 186 char buf[MAX_WPA_IE_LEN * 2 + 30];
187 187
188 DBG_PRT(MSG_LEVEL_DEBUG, KERN_INFO " SIOCGIWSCAN\n"); 188 DBG_PRT(MSG_LEVEL_DEBUG, KERN_INFO " SIOCGIWSCAN\n");
189 189
190 if (pMgmt->eScanState == WMAC_IS_SCANNING) { 190 if (pMgmt->eScanState == WMAC_IS_SCANNING) {
191 // In scanning.. 191 // In scanning..
192 return -EAGAIN; 192 return -EAGAIN;
193 } 193 }
194 pBSS = &(pMgmt->sBSSList[0]); 194 pBSS = &(pMgmt->sBSSList[0]);
195 for (ii = 0, jj = 0; jj < MAX_BSS_NUM ; jj++) { 195 for (ii = 0, jj = 0; jj < MAX_BSS_NUM ; jj++) {
196 if (current_ev >= end_buf) 196 if (current_ev >= end_buf)
197 break; 197 break;
198 pBSS = &(pMgmt->sBSSList[jj]); 198 pBSS = &(pMgmt->sBSSList[jj]);
199 if (pBSS->bActive) { 199 if (pBSS->bActive) {
200 //ADD mac address 200 //ADD mac address
201 memset(&iwe, 0, sizeof(iwe)); 201 memset(&iwe, 0, sizeof(iwe));
202 iwe.cmd = SIOCGIWAP; 202 iwe.cmd = SIOCGIWAP;
203 iwe.u.ap_addr.sa_family = ARPHRD_ETHER; 203 iwe.u.ap_addr.sa_family = ARPHRD_ETHER;
204 memcpy(iwe.u.ap_addr.sa_data, pBSS->abyBSSID, WLAN_BSSID_LEN); 204 memcpy(iwe.u.ap_addr.sa_data, pBSS->abyBSSID, WLAN_BSSID_LEN);
205 current_ev = iwe_stream_add_event(info,current_ev,end_buf, &iwe, IW_EV_ADDR_LEN); 205 current_ev = iwe_stream_add_event(info,current_ev,end_buf, &iwe, IW_EV_ADDR_LEN);
206 //ADD ssid 206 //ADD ssid
207 memset(&iwe, 0, sizeof(iwe)); 207 memset(&iwe, 0, sizeof(iwe));
208 iwe.cmd = SIOCGIWESSID; 208 iwe.cmd = SIOCGIWESSID;
209 pItemSSID = (PWLAN_IE_SSID)pBSS->abySSID; 209 pItemSSID = (PWLAN_IE_SSID)pBSS->abySSID;
210 iwe.u.data.length = pItemSSID->len; 210 iwe.u.data.length = pItemSSID->len;
211 iwe.u.data.flags = 1; 211 iwe.u.data.flags = 1;
212 current_ev = iwe_stream_add_point(info,current_ev,end_buf, &iwe, pItemSSID->abySSID); 212 current_ev = iwe_stream_add_point(info,current_ev,end_buf, &iwe, pItemSSID->abySSID);
213 //ADD mode 213 //ADD mode
214 memset(&iwe, 0, sizeof(iwe)); 214 memset(&iwe, 0, sizeof(iwe));
215 iwe.cmd = SIOCGIWMODE; 215 iwe.cmd = SIOCGIWMODE;
216 if (WLAN_GET_CAP_INFO_ESS(pBSS->wCapInfo)) { 216 if (WLAN_GET_CAP_INFO_ESS(pBSS->wCapInfo)) {
217 iwe.u.mode = IW_MODE_INFRA; 217 iwe.u.mode = IW_MODE_INFRA;
218 } 218 }
219 else { 219 else {
220 iwe.u.mode = IW_MODE_ADHOC; 220 iwe.u.mode = IW_MODE_ADHOC;
221 } 221 }
222 iwe.len = IW_EV_UINT_LEN; 222 iwe.len = IW_EV_UINT_LEN;
223 current_ev = iwe_stream_add_event(info,current_ev, end_buf, &iwe, IW_EV_UINT_LEN); 223 current_ev = iwe_stream_add_event(info,current_ev, end_buf, &iwe, IW_EV_UINT_LEN);
224 //ADD frequency 224 //ADD frequency
225 pSuppRates = (PWLAN_IE_SUPP_RATES)pBSS->abySuppRates; 225 pSuppRates = (PWLAN_IE_SUPP_RATES)pBSS->abySuppRates;
226 pExtSuppRates = (PWLAN_IE_SUPP_RATES)pBSS->abyExtSuppRates; 226 pExtSuppRates = (PWLAN_IE_SUPP_RATES)pBSS->abyExtSuppRates;
227 memset(&iwe, 0, sizeof(iwe)); 227 memset(&iwe, 0, sizeof(iwe));
228 iwe.cmd = SIOCGIWFREQ; 228 iwe.cmd = SIOCGIWFREQ;
229 iwe.u.freq.m = pBSS->uChannel; 229 iwe.u.freq.m = pBSS->uChannel;
230 iwe.u.freq.e = 0; 230 iwe.u.freq.e = 0;
231 iwe.u.freq.i = 0; 231 iwe.u.freq.i = 0;
232 current_ev = iwe_stream_add_event(info,current_ev,end_buf, &iwe, IW_EV_FREQ_LEN); 232 current_ev = iwe_stream_add_event(info,current_ev,end_buf, &iwe, IW_EV_FREQ_LEN);
233 { 233 {
234 int f = (int)pBSS->uChannel - 1; 234 int f = (int)pBSS->uChannel - 1;
235 if(f < 0)f = 0; 235 if(f < 0)f = 0;
236 iwe.u.freq.m = frequency_list[f] * 100000; 236 iwe.u.freq.m = frequency_list[f] * 100000;
237 iwe.u.freq.e = 1; 237 iwe.u.freq.e = 1;
238 } 238 }
239 current_ev = iwe_stream_add_event(info,current_ev,end_buf, &iwe, IW_EV_FREQ_LEN); 239 current_ev = iwe_stream_add_event(info,current_ev,end_buf, &iwe, IW_EV_FREQ_LEN);
240 //ADD quality 240 //ADD quality
241 memset(&iwe, 0, sizeof(iwe)); 241 memset(&iwe, 0, sizeof(iwe));
242 iwe.cmd = IWEVQUAL; 242 iwe.cmd = IWEVQUAL;
243 RFvRSSITodBm(pDevice, (BYTE)(pBSS->uRSSI), &ldBm); 243 RFvRSSITodBm(pDevice, (BYTE)(pBSS->uRSSI), &ldBm);
244 iwe.u.qual.level = ldBm; 244 iwe.u.qual.level = ldBm;
245 iwe.u.qual.noise = 0; 245 iwe.u.qual.noise = 0;
246 246
247 if(-ldBm<50){ 247 if(-ldBm<50){
248 iwe.u.qual.qual = 100; 248 iwe.u.qual.qual = 100;
249 }else if(-ldBm > 90) { 249 }else if(-ldBm > 90) {
250 iwe.u.qual.qual = 0; 250 iwe.u.qual.qual = 0;
251 }else { 251 }else {
252 iwe.u.qual.qual=(40-(-ldBm-50))*100/40; 252 iwe.u.qual.qual=(40-(-ldBm-50))*100/40;
253 } 253 }
254 iwe.u.qual.updated=7; 254 iwe.u.qual.updated=7;
255 255
256 current_ev = iwe_stream_add_event(info,current_ev, end_buf, &iwe, IW_EV_QUAL_LEN); 256 current_ev = iwe_stream_add_event(info,current_ev, end_buf, &iwe, IW_EV_QUAL_LEN);
257 //ADD encryption 257 //ADD encryption
258 memset(&iwe, 0, sizeof(iwe)); 258 memset(&iwe, 0, sizeof(iwe));
259 iwe.cmd = SIOCGIWENCODE; 259 iwe.cmd = SIOCGIWENCODE;
260 iwe.u.data.length = 0; 260 iwe.u.data.length = 0;
261 if (WLAN_GET_CAP_INFO_PRIVACY(pBSS->wCapInfo)) { 261 if (WLAN_GET_CAP_INFO_PRIVACY(pBSS->wCapInfo)) {
262 iwe.u.data.flags =IW_ENCODE_ENABLED | IW_ENCODE_NOKEY; 262 iwe.u.data.flags =IW_ENCODE_ENABLED | IW_ENCODE_NOKEY;
263 }else { 263 }else {
264 iwe.u.data.flags = IW_ENCODE_DISABLED; 264 iwe.u.data.flags = IW_ENCODE_DISABLED;
265 } 265 }
266 current_ev = iwe_stream_add_point(info,current_ev,end_buf, &iwe, pItemSSID->abySSID); 266 current_ev = iwe_stream_add_point(info,current_ev,end_buf, &iwe, pItemSSID->abySSID);
267 267
268 memset(&iwe, 0, sizeof(iwe)); 268 memset(&iwe, 0, sizeof(iwe));
269 iwe.cmd = SIOCGIWRATE; 269 iwe.cmd = SIOCGIWRATE;
270 iwe.u.bitrate.fixed = iwe.u.bitrate.disabled = 0; 270 iwe.u.bitrate.fixed = iwe.u.bitrate.disabled = 0;
271 current_val = current_ev + IW_EV_LCP_LEN; 271 current_val = current_ev + IW_EV_LCP_LEN;
272 272
273 for (kk = 0 ; kk < 12 ; kk++) { 273 for (kk = 0 ; kk < 12 ; kk++) {
274 if (pSuppRates->abyRates[kk] == 0) 274 if (pSuppRates->abyRates[kk] == 0)
275 break; 275 break;
276 // Bit rate given in 500 kb/s units (+ 0x80) 276 // Bit rate given in 500 kb/s units (+ 0x80)
277 iwe.u.bitrate.value = ((pSuppRates->abyRates[kk] & 0x7f) * 500000); 277 iwe.u.bitrate.value = ((pSuppRates->abyRates[kk] & 0x7f) * 500000);
278 current_val = iwe_stream_add_value(info,current_ev, current_val, end_buf, &iwe, IW_EV_PARAM_LEN); 278 current_val = iwe_stream_add_value(info,current_ev, current_val, end_buf, &iwe, IW_EV_PARAM_LEN);
279 } 279 }
280 for (kk = 0 ; kk < 8 ; kk++) { 280 for (kk = 0 ; kk < 8 ; kk++) {
281 if (pExtSuppRates->abyRates[kk] == 0) 281 if (pExtSuppRates->abyRates[kk] == 0)
282 break; 282 break;
283 // Bit rate given in 500 kb/s units (+ 0x80) 283 // Bit rate given in 500 kb/s units (+ 0x80)
284 iwe.u.bitrate.value = ((pExtSuppRates->abyRates[kk] & 0x7f) * 500000); 284 iwe.u.bitrate.value = ((pExtSuppRates->abyRates[kk] & 0x7f) * 500000);
285 current_val = iwe_stream_add_value(info,current_ev, current_val, end_buf, &iwe, IW_EV_PARAM_LEN); 285 current_val = iwe_stream_add_value(info,current_ev, current_val, end_buf, &iwe, IW_EV_PARAM_LEN);
286 } 286 }
287 287
288 if((current_val - current_ev) > IW_EV_LCP_LEN) 288 if((current_val - current_ev) > IW_EV_LCP_LEN)
289 current_ev = current_val; 289 current_ev = current_val;
290 290
291 memset(&iwe, 0, sizeof(iwe)); 291 memset(&iwe, 0, sizeof(iwe));
292 iwe.cmd = IWEVCUSTOM; 292 iwe.cmd = IWEVCUSTOM;
293 sprintf(buf, "bcn_int=%d", pBSS->wBeaconInterval); 293 sprintf(buf, "bcn_int=%d", pBSS->wBeaconInterval);
294 iwe.u.data.length = strlen(buf); 294 iwe.u.data.length = strlen(buf);
295 current_ev = iwe_stream_add_point(info,current_ev, end_buf, &iwe, buf); 295 current_ev = iwe_stream_add_point(info,current_ev, end_buf, &iwe, buf);
296 296
297 if ((pBSS->wWPALen > 0) && (pBSS->wWPALen <= MAX_WPA_IE_LEN)) { 297 if ((pBSS->wWPALen > 0) && (pBSS->wWPALen <= MAX_WPA_IE_LEN)) {
298 memset(&iwe, 0, sizeof(iwe)); 298 memset(&iwe, 0, sizeof(iwe));
299 iwe.cmd = IWEVGENIE; 299 iwe.cmd = IWEVGENIE;
300 iwe.u.data.length = pBSS->wWPALen; 300 iwe.u.data.length = pBSS->wWPALen;
301 current_ev = iwe_stream_add_point(info,current_ev, end_buf, &iwe, pBSS->byWPAIE); 301 current_ev = iwe_stream_add_point(info,current_ev, end_buf, &iwe, pBSS->byWPAIE);
302 } 302 }
303 303
304 if ((pBSS->wRSNLen > 0) && (pBSS->wRSNLen <= MAX_WPA_IE_LEN)) { 304 if ((pBSS->wRSNLen > 0) && (pBSS->wRSNLen <= MAX_WPA_IE_LEN)) {
305 memset(&iwe, 0, sizeof(iwe)); 305 memset(&iwe, 0, sizeof(iwe));
306 iwe.cmd = IWEVGENIE; 306 iwe.cmd = IWEVGENIE;
307 iwe.u.data.length = pBSS->wRSNLen; 307 iwe.u.data.length = pBSS->wRSNLen;
308 current_ev = iwe_stream_add_point(info,current_ev, end_buf, &iwe, pBSS->byRSNIE); 308 current_ev = iwe_stream_add_point(info,current_ev, end_buf, &iwe, pBSS->byRSNIE);
309 } 309 }
310 310
311 } 311 }
312 }// for 312 }// for
313 wrq->length = current_ev - extra; 313 wrq->length = current_ev - extra;
314 return 0; 314 return 0;
315} 315}
@@ -323,12 +323,12 @@ int iwctl_siwfreq(struct net_device *dev, struct iw_request_info *info,
323 PSDevice pDevice = (PSDevice)netdev_priv(dev); 323 PSDevice pDevice = (PSDevice)netdev_priv(dev);
324 int rc = 0; 324 int rc = 0;
325 325
326 DBG_PRT(MSG_LEVEL_DEBUG, KERN_INFO " SIOCSIWFREQ \n"); 326 DBG_PRT(MSG_LEVEL_DEBUG, KERN_INFO " SIOCSIWFREQ \n");
327 327
328 // If setting by frequency, convert to a channel 328 // If setting by frequency, convert to a channel
329 if((wrq->e == 1) && 329 if((wrq->e == 1) &&
330 (wrq->m >= (int) 2.412e8) && 330 (wrq->m >= (int) 2.412e8) &&
331 (wrq->m <= (int) 2.487e8)) { 331 (wrq->m <= (int) 2.487e8)) {
332 int f = wrq->m / 100000; 332 int f = wrq->m / 100000;
333 int c = 0; 333 int c = 0;
334 while((c < 14) && (f != frequency_list[c])) 334 while((c < 14) && (f != frequency_list[c]))
@@ -345,9 +345,9 @@ int iwctl_siwfreq(struct net_device *dev, struct iw_request_info *info,
345 DBG_PRT(MSG_LEVEL_DEBUG, KERN_INFO "%s: New channel value of %d is invalid!\n", dev->name, wrq->m); 345 DBG_PRT(MSG_LEVEL_DEBUG, KERN_INFO "%s: New channel value of %d is invalid!\n", dev->name, wrq->m);
346 rc = -EINVAL; 346 rc = -EINVAL;
347 } else { 347 } else {
348 // Yes ! We can set it !!! 348 // Yes ! We can set it !!!
349 DBG_PRT(MSG_LEVEL_DEBUG, KERN_INFO " Set to channel = %d\n", channel); 349 DBG_PRT(MSG_LEVEL_DEBUG, KERN_INFO " Set to channel = %d\n", channel);
350 pDevice->uChannel = channel; 350 pDevice->uChannel = channel;
351 } 351 }
352 } 352 }
353 353
@@ -361,9 +361,9 @@ int iwctl_giwfreq(struct net_device *dev, struct iw_request_info *info,
361 struct iw_freq *wrq, char *extra) 361 struct iw_freq *wrq, char *extra)
362{ 362{
363 PSDevice pDevice = (PSDevice)netdev_priv(dev); 363 PSDevice pDevice = (PSDevice)netdev_priv(dev);
364 PSMgmtObject pMgmt = &(pDevice->sMgmtObj); 364 PSMgmtObject pMgmt = &(pDevice->sMgmtObj);
365 365
366 DBG_PRT(MSG_LEVEL_DEBUG, KERN_INFO " SIOCGIWFREQ \n"); 366 DBG_PRT(MSG_LEVEL_DEBUG, KERN_INFO " SIOCGIWFREQ \n");
367 367
368#ifdef WEXT_USECHANNELS 368#ifdef WEXT_USECHANNELS
369 wrq->m = (int)pMgmt->uCurrChannel; 369 wrq->m = (int)pMgmt->uCurrChannel;
@@ -372,7 +372,7 @@ int iwctl_giwfreq(struct net_device *dev, struct iw_request_info *info,
372 { 372 {
373 int f = (int)pMgmt->uCurrChannel - 1; 373 int f = (int)pMgmt->uCurrChannel - 1;
374 if(f < 0) 374 if(f < 0)
375 f = 0; 375 f = 0;
376 wrq->m = frequency_list[f] * 100000; 376 wrq->m = frequency_list[f] * 100000;
377 wrq->e = 1; 377 wrq->e = 1;
378 } 378 }
@@ -387,54 +387,54 @@ int iwctl_siwmode(struct net_device *dev, struct iw_request_info *info,
387 __u32 *wmode, char *extra) 387 __u32 *wmode, char *extra)
388{ 388{
389 PSDevice pDevice = (PSDevice)netdev_priv(dev); 389 PSDevice pDevice = (PSDevice)netdev_priv(dev);
390 PSMgmtObject pMgmt = &(pDevice->sMgmtObj); 390 PSMgmtObject pMgmt = &(pDevice->sMgmtObj);
391 int rc = 0; 391 int rc = 0;
392 392
393 DBG_PRT(MSG_LEVEL_DEBUG, KERN_INFO " SIOCSIWMODE \n"); 393 DBG_PRT(MSG_LEVEL_DEBUG, KERN_INFO " SIOCSIWMODE \n");
394 394
395 if (pMgmt->eCurrMode == WMAC_MODE_ESS_AP && pDevice->bEnableHostapd) { 395 if (pMgmt->eCurrMode == WMAC_MODE_ESS_AP && pDevice->bEnableHostapd) {
396 DBG_PRT(MSG_LEVEL_DEBUG, KERN_INFO"Can't set operation mode, hostapd is running \n"); 396 DBG_PRT(MSG_LEVEL_DEBUG, KERN_INFO"Can't set operation mode, hostapd is running \n");
397 return rc; 397 return rc;
398 } 398 }
399 399
400 switch(*wmode) { 400 switch(*wmode) {
401 401
402 case IW_MODE_ADHOC: 402 case IW_MODE_ADHOC:
403 if (pMgmt->eConfigMode != WMAC_CONFIG_IBSS_STA) { 403 if (pMgmt->eConfigMode != WMAC_CONFIG_IBSS_STA) {
404 pMgmt->eConfigMode = WMAC_CONFIG_IBSS_STA; 404 pMgmt->eConfigMode = WMAC_CONFIG_IBSS_STA;
405 if (pDevice->flags & DEVICE_FLAGS_OPENED) { 405 if (pDevice->flags & DEVICE_FLAGS_OPENED) {
406 pDevice->bCommit = TRUE; 406 pDevice->bCommit = TRUE;
407 } 407 }
408 } 408 }
409 DBG_PRT(MSG_LEVEL_DEBUG, KERN_INFO "set mode to ad-hoc \n"); 409 DBG_PRT(MSG_LEVEL_DEBUG, KERN_INFO "set mode to ad-hoc \n");
410 break; 410 break;
411 case IW_MODE_AUTO: 411 case IW_MODE_AUTO:
412 case IW_MODE_INFRA: 412 case IW_MODE_INFRA:
413 if (pMgmt->eConfigMode != WMAC_CONFIG_ESS_STA) { 413 if (pMgmt->eConfigMode != WMAC_CONFIG_ESS_STA) {
414 pMgmt->eConfigMode = WMAC_CONFIG_ESS_STA; 414 pMgmt->eConfigMode = WMAC_CONFIG_ESS_STA;
415 if (pDevice->flags & DEVICE_FLAGS_OPENED) { 415 if (pDevice->flags & DEVICE_FLAGS_OPENED) {
416 pDevice->bCommit = TRUE; 416 pDevice->bCommit = TRUE;
417 } 417 }
418 } 418 }
419 DBG_PRT(MSG_LEVEL_DEBUG, KERN_INFO "set mode to infrastructure \n"); 419 DBG_PRT(MSG_LEVEL_DEBUG, KERN_INFO "set mode to infrastructure \n");
420 break; 420 break;
421 case IW_MODE_MASTER: 421 case IW_MODE_MASTER:
422 422
423 pMgmt->eConfigMode = WMAC_CONFIG_ESS_STA; 423 pMgmt->eConfigMode = WMAC_CONFIG_ESS_STA;
424 rc = -EOPNOTSUPP; 424 rc = -EOPNOTSUPP;
425 break; 425 break;
426 426
427 if (pMgmt->eConfigMode != WMAC_CONFIG_AP) { 427 if (pMgmt->eConfigMode != WMAC_CONFIG_AP) {
428 pMgmt->eConfigMode = WMAC_CONFIG_AP; 428 pMgmt->eConfigMode = WMAC_CONFIG_AP;
429 if (pDevice->flags & DEVICE_FLAGS_OPENED) { 429 if (pDevice->flags & DEVICE_FLAGS_OPENED) {
430 pDevice->bCommit = TRUE; 430 pDevice->bCommit = TRUE;
431 } 431 }
432 } 432 }
433 DBG_PRT(MSG_LEVEL_DEBUG, KERN_INFO "set mode to Access Point \n"); 433 DBG_PRT(MSG_LEVEL_DEBUG, KERN_INFO "set mode to Access Point \n");
434 break; 434 break;
435 435
436 case IW_MODE_REPEAT: 436 case IW_MODE_REPEAT:
437 pMgmt->eConfigMode = WMAC_CONFIG_ESS_STA; 437 pMgmt->eConfigMode = WMAC_CONFIG_ESS_STA;
438 rc = -EOPNOTSUPP; 438 rc = -EOPNOTSUPP;
439 break; 439 break;
440 default: 440 default:
@@ -451,17 +451,17 @@ void iwctl_giwmode(struct net_device *dev, struct iw_request_info *info,
451 __u32 *wmode, char *extra) 451 __u32 *wmode, char *extra)
452{ 452{
453 PSDevice pDevice = (PSDevice)netdev_priv(dev); 453 PSDevice pDevice = (PSDevice)netdev_priv(dev);
454 PSMgmtObject pMgmt = &(pDevice->sMgmtObj); 454 PSMgmtObject pMgmt = &(pDevice->sMgmtObj);
455 455
456 456
457 DBG_PRT(MSG_LEVEL_DEBUG, KERN_INFO " SIOCGIWMODE \n"); 457 DBG_PRT(MSG_LEVEL_DEBUG, KERN_INFO " SIOCGIWMODE \n");
458 // If not managed, assume it's ad-hoc 458 // If not managed, assume it's ad-hoc
459 switch (pMgmt->eConfigMode) { 459 switch (pMgmt->eConfigMode) {
460 case WMAC_CONFIG_ESS_STA: 460 case WMAC_CONFIG_ESS_STA:
461 *wmode = IW_MODE_INFRA; 461 *wmode = IW_MODE_INFRA;
462 break; 462 break;
463 case WMAC_CONFIG_IBSS_STA: 463 case WMAC_CONFIG_IBSS_STA:
464 *wmode = IW_MODE_ADHOC; 464 *wmode = IW_MODE_ADHOC;
465 break; 465 break;
466 case WMAC_CONFIG_AUTO: 466 case WMAC_CONFIG_AUTO:
467 *wmode = IW_MODE_INFRA; 467 *wmode = IW_MODE_INFRA;
@@ -482,9 +482,9 @@ void iwctl_giwrange(struct net_device *dev, struct iw_request_info *info,
482{ 482{
483 struct iw_range *range = (struct iw_range *) extra; 483 struct iw_range *range = (struct iw_range *) extra;
484 int i,k; 484 int i,k;
485 BYTE abySupportedRates[13]= {0x02, 0x04, 0x0B, 0x16, 0x0c, 0x12, 0x18, 0x24, 0x30, 0x48, 0x60, 0x6C, 0x90}; 485 BYTE abySupportedRates[13]= {0x02, 0x04, 0x0B, 0x16, 0x0c, 0x12, 0x18, 0x24, 0x30, 0x48, 0x60, 0x6C, 0x90};
486 486
487 DBG_PRT(MSG_LEVEL_DEBUG, KERN_INFO " SIOCGIWRANGE\n"); 487 DBG_PRT(MSG_LEVEL_DEBUG, KERN_INFO " SIOCGIWRANGE\n");
488 if (wrq->pointer) { 488 if (wrq->pointer) {
489 wrq->length = sizeof(struct iw_range); 489 wrq->length = sizeof(struct iw_range);
490 memset(range, 0, sizeof(struct iw_range)); 490 memset(range, 0, sizeof(struct iw_range));
@@ -501,7 +501,7 @@ void iwctl_giwrange(struct net_device *dev, struct iw_request_info *info,
501 } 501 }
502 range->num_frequency = k; 502 range->num_frequency = k;
503 // Hum... Should put the right values there 503 // Hum... Should put the right values there
504 range->max_qual.qual = 100; 504 range->max_qual.qual = 100;
505 range->max_qual.level = 0; 505 range->max_qual.level = 0;
506 range->max_qual.noise = 0; 506 range->max_qual.noise = 0;
507 range->sensitivity = 255; 507 range->sensitivity = 255;
@@ -526,19 +526,19 @@ void iwctl_giwrange(struct net_device *dev, struct iw_request_info *info,
526 range->min_frag = 256; 526 range->min_frag = 256;
527 range->max_frag = 2312; 527 range->max_frag = 2312;
528 528
529 // the encoding capabilities 529 // the encoding capabilities
530 range->num_encoding_sizes = 3; 530 range->num_encoding_sizes = 3;
531 // 64(40) bits WEP 531 // 64(40) bits WEP
532 range->encoding_size[0] = 5; 532 range->encoding_size[0] = 5;
533 // 128(104) bits WEP 533 // 128(104) bits WEP
534 range->encoding_size[1] = 13; 534 range->encoding_size[1] = 13;
535 // 256 bits for WPA-PSK 535 // 256 bits for WPA-PSK
536 range->encoding_size[2] = 32; 536 range->encoding_size[2] = 32;
537 // 4 keys are allowed 537 // 4 keys are allowed
538 range->max_encoding_tokens = 4; 538 range->max_encoding_tokens = 4;
539 539
540 range->enc_capa = IW_ENC_CAPA_WPA | IW_ENC_CAPA_WPA2 | 540 range->enc_capa = IW_ENC_CAPA_WPA | IW_ENC_CAPA_WPA2 |
541 IW_ENC_CAPA_CIPHER_TKIP | IW_ENC_CAPA_CIPHER_CCMP; 541 IW_ENC_CAPA_CIPHER_TKIP | IW_ENC_CAPA_CIPHER_CCMP;
542 542
543 range->min_pmp = 0; 543 range->min_pmp = 0;
544 range->max_pmp = 1000000;// 1 secs 544 range->max_pmp = 1000000;// 1 secs
@@ -549,7 +549,7 @@ void iwctl_giwrange(struct net_device *dev, struct iw_request_info *info,
549 range->pm_capa = IW_POWER_PERIOD | IW_POWER_TIMEOUT | IW_POWER_ALL_R; 549 range->pm_capa = IW_POWER_PERIOD | IW_POWER_TIMEOUT | IW_POWER_ALL_R;
550 550
551 // Transmit Power - values are in mW 551 // Transmit Power - values are in mW
552 range->txpower[0] = 100; 552 range->txpower[0] = 100;
553 range->num_txpower = 1; 553 range->num_txpower = 1;
554 range->txpower_capa = IW_TXPOW_MWATT; 554 range->txpower_capa = IW_TXPOW_MWATT;
555 range->we_version_source = SUPPORTED_WIRELESS_EXT; 555 range->we_version_source = SUPPORTED_WIRELESS_EXT;
@@ -577,41 +577,41 @@ int iwctl_siwap(struct net_device *dev, struct iw_request_info *info,
577 struct sockaddr *wrq, char *extra) 577 struct sockaddr *wrq, char *extra)
578{ 578{
579 PSDevice pDevice = (PSDevice)netdev_priv(dev); 579 PSDevice pDevice = (PSDevice)netdev_priv(dev);
580 PSMgmtObject pMgmt = &(pDevice->sMgmtObj); 580 PSMgmtObject pMgmt = &(pDevice->sMgmtObj);
581 int rc = 0; 581 int rc = 0;
582 BYTE ZeroBSSID[WLAN_BSSID_LEN]={0x00,0x00,0x00,0x00,0x00,0x00}; 582 BYTE ZeroBSSID[WLAN_BSSID_LEN]={0x00,0x00,0x00,0x00,0x00,0x00};
583 583
584 PRINT_K(" SIOCSIWAP \n"); 584 PRINT_K(" SIOCSIWAP \n");
585 585
586 if (wrq->sa_family != ARPHRD_ETHER) 586 if (wrq->sa_family != ARPHRD_ETHER)
587 rc = -EINVAL; 587 rc = -EINVAL;
588 else { 588 else {
589 memcpy(pMgmt->abyDesireBSSID, wrq->sa_data, 6); 589 memcpy(pMgmt->abyDesireBSSID, wrq->sa_data, 6);
590 //mike :add 590 //mike :add
591 if ((is_broadcast_ether_addr(pMgmt->abyDesireBSSID)) || 591 if ((is_broadcast_ether_addr(pMgmt->abyDesireBSSID)) ||
592 (memcmp(pMgmt->abyDesireBSSID, ZeroBSSID, 6) == 0)){ 592 (memcmp(pMgmt->abyDesireBSSID, ZeroBSSID, 6) == 0)){
593 PRINT_K("SIOCSIWAP:invalid desired BSSID return!\n"); 593 PRINT_K("SIOCSIWAP:invalid desired BSSID return!\n");
594 return rc; 594 return rc;
595 } 595 }
596 //mike add: if desired AP is hidden ssid(there are two same BSSID in list), 596 //mike add: if desired AP is hidden ssid(there are two same BSSID in list),
597 // then ignore,because you don't known which one to be connect with?? 597 // then ignore,because you don't known which one to be connect with??
598 { 598 {
599 unsigned int ii, uSameBssidNum = 0; 599 unsigned int ii, uSameBssidNum = 0;
600 for (ii = 0; ii < MAX_BSS_NUM; ii++) { 600 for (ii = 0; ii < MAX_BSS_NUM; ii++) {
601 if (pMgmt->sBSSList[ii].bActive && 601 if (pMgmt->sBSSList[ii].bActive &&
602 !compare_ether_addr(pMgmt->sBSSList[ii].abyBSSID, 602 !compare_ether_addr(pMgmt->sBSSList[ii].abyBSSID,
603 pMgmt->abyDesireBSSID)) { 603 pMgmt->abyDesireBSSID)) {
604 uSameBssidNum++; 604 uSameBssidNum++;
605 } 605 }
606 } 606 }
607 if(uSameBssidNum >= 2) { //hit: desired AP is in hidden ssid mode!!! 607 if(uSameBssidNum >= 2) { //hit: desired AP is in hidden ssid mode!!!
608 PRINT_K("SIOCSIWAP:ignore for desired AP in hidden mode\n"); 608 PRINT_K("SIOCSIWAP:ignore for desired AP in hidden mode\n");
609 return rc; 609 return rc;
610 } 610 }
611 } 611 }
612 612
613 if (pDevice->flags & DEVICE_FLAGS_OPENED) { 613 if (pDevice->flags & DEVICE_FLAGS_OPENED) {
614 pDevice->bCommit = TRUE; 614 pDevice->bCommit = TRUE;
615 } 615 }
616 } 616 }
617 return rc; 617 return rc;
@@ -624,18 +624,18 @@ int iwctl_giwap(struct net_device *dev, struct iw_request_info *info,
624 struct sockaddr *wrq, char *extra) 624 struct sockaddr *wrq, char *extra)
625{ 625{
626 PSDevice pDevice = (PSDevice)netdev_priv(dev); 626 PSDevice pDevice = (PSDevice)netdev_priv(dev);
627 PSMgmtObject pMgmt = &(pDevice->sMgmtObj); 627 PSMgmtObject pMgmt = &(pDevice->sMgmtObj);
628 628
629 DBG_PRT(MSG_LEVEL_DEBUG, KERN_INFO " SIOCGIWAP \n"); 629 DBG_PRT(MSG_LEVEL_DEBUG, KERN_INFO " SIOCGIWAP \n");
630 630
631 memcpy(wrq->sa_data, pMgmt->abyCurrBSSID, 6); 631 memcpy(wrq->sa_data, pMgmt->abyCurrBSSID, 6);
632 632
633 if ((pDevice->bLinkPass == FALSE) && (pMgmt->eCurrMode != WMAC_MODE_ESS_AP)) 633 if ((pDevice->bLinkPass == FALSE) && (pMgmt->eCurrMode != WMAC_MODE_ESS_AP))
634 memset(wrq->sa_data, 0, 6); 634 memset(wrq->sa_data, 0, 6);
635 635
636 if (pMgmt->eCurrMode == WMAC_MODE_ESS_AP) { 636 if (pMgmt->eCurrMode == WMAC_MODE_ESS_AP) {
637 memcpy(wrq->sa_data, pMgmt->abyCurrBSSID, 6); 637 memcpy(wrq->sa_data, pMgmt->abyCurrBSSID, 6);
638 } 638 }
639 639
640 wrq->sa_family = ARPHRD_ETHER; 640 wrq->sa_family = ARPHRD_ETHER;
641 return 0; 641 return 0;
@@ -651,9 +651,9 @@ int iwctl_giwaplist(struct net_device *dev, struct iw_request_info *info,
651 struct sockaddr sock[IW_MAX_AP]; 651 struct sockaddr sock[IW_MAX_AP];
652 struct iw_quality qual[IW_MAX_AP]; 652 struct iw_quality qual[IW_MAX_AP];
653 PSDevice pDevice = (PSDevice)netdev_priv(dev); 653 PSDevice pDevice = (PSDevice)netdev_priv(dev);
654 PSMgmtObject pMgmt = &(pDevice->sMgmtObj); 654 PSMgmtObject pMgmt = &(pDevice->sMgmtObj);
655 655
656 DBG_PRT(MSG_LEVEL_DEBUG, KERN_INFO " SIOCGIWAPLIST \n"); 656 DBG_PRT(MSG_LEVEL_DEBUG, KERN_INFO " SIOCGIWAPLIST \n");
657 // Only super-user can see AP list 657 // Only super-user can see AP list
658 658
659 if (!capable(CAP_NET_ADMIN)) { 659 if (!capable(CAP_NET_ADMIN)) {
@@ -665,11 +665,11 @@ int iwctl_giwaplist(struct net_device *dev, struct iw_request_info *info,
665 PKnownBSS pBSS = &(pMgmt->sBSSList[0]); 665 PKnownBSS pBSS = &(pMgmt->sBSSList[0]);
666 666
667 for (ii = 0, jj= 0; ii < MAX_BSS_NUM; ii++) { 667 for (ii = 0, jj= 0; ii < MAX_BSS_NUM; ii++) {
668 pBSS = &(pMgmt->sBSSList[ii]); 668 pBSS = &(pMgmt->sBSSList[ii]);
669 if (!pBSS->bActive) 669 if (!pBSS->bActive)
670 continue; 670 continue;
671 if ( jj >= IW_MAX_AP) 671 if ( jj >= IW_MAX_AP)
672 break; 672 break;
673 memcpy(sock[jj].sa_data, pBSS->abyBSSID, 6); 673 memcpy(sock[jj].sa_data, pBSS->abyBSSID, 6);
674 sock[jj].sa_family = ARPHRD_ETHER; 674 sock[jj].sa_family = ARPHRD_ETHER;
675 qual[jj].level = pBSS->uRSSI; 675 qual[jj].level = pBSS->uRSSI;
@@ -693,105 +693,105 @@ int iwctl_siwessid(struct net_device *dev, struct iw_request_info *info,
693 struct iw_point *wrq, char *extra) 693 struct iw_point *wrq, char *extra)
694{ 694{
695 PSDevice pDevice = (PSDevice)netdev_priv(dev); 695 PSDevice pDevice = (PSDevice)netdev_priv(dev);
696 PSMgmtObject pMgmt = &(pDevice->sMgmtObj); 696 PSMgmtObject pMgmt = &(pDevice->sMgmtObj);
697 PWLAN_IE_SSID pItemSSID; 697 PWLAN_IE_SSID pItemSSID;
698 698
699 if (!(pDevice->flags & DEVICE_FLAGS_OPENED)) 699 if (!(pDevice->flags & DEVICE_FLAGS_OPENED))
700 return -EINVAL; 700 return -EINVAL;
701 701
702 DBG_PRT(MSG_LEVEL_DEBUG, KERN_INFO " SIOCSIWESSID :\n"); 702 DBG_PRT(MSG_LEVEL_DEBUG, KERN_INFO " SIOCSIWESSID :\n");
703 703
704 pDevice->fWPA_Authened = FALSE; 704 pDevice->fWPA_Authened = FALSE;
705 // Check if we asked for `any' 705 // Check if we asked for `any'
706 if(wrq->flags == 0) { 706 if(wrq->flags == 0) {
707 // Just send an empty SSID list 707 // Just send an empty SSID list
708 memset(pMgmt->abyDesireSSID, 0, WLAN_IEHDR_LEN + WLAN_SSID_MAXLEN + 1); 708 memset(pMgmt->abyDesireSSID, 0, WLAN_IEHDR_LEN + WLAN_SSID_MAXLEN + 1);
709 memset(pMgmt->abyDesireBSSID, 0xFF,6); 709 memset(pMgmt->abyDesireBSSID, 0xFF,6);
710 PRINT_K("set essid to 'any' \n"); 710 PRINT_K("set essid to 'any' \n");
711 #ifdef WPA_SUPPLICANT_DRIVER_WEXT_SUPPORT 711#ifdef WPA_SUPPLICANT_DRIVER_WEXT_SUPPORT
712 //Unknown desired AP,so here need not associate?? 712 //Unknown desired AP,so here need not associate??
713 return 0; 713 return 0;
714 #endif 714#endif
715 } else { 715 } else {
716 // Set the SSID 716 // Set the SSID
717 memset(pMgmt->abyDesireSSID, 0, WLAN_IEHDR_LEN + WLAN_SSID_MAXLEN + 1); 717 memset(pMgmt->abyDesireSSID, 0, WLAN_IEHDR_LEN + WLAN_SSID_MAXLEN + 1);
718 pItemSSID = (PWLAN_IE_SSID)pMgmt->abyDesireSSID; 718 pItemSSID = (PWLAN_IE_SSID)pMgmt->abyDesireSSID;
719 pItemSSID->byElementID = WLAN_EID_SSID; 719 pItemSSID->byElementID = WLAN_EID_SSID;
720 720
721 memcpy(pItemSSID->abySSID, extra, wrq->length); 721 memcpy(pItemSSID->abySSID, extra, wrq->length);
722 if (pItemSSID->abySSID[wrq->length - 1] == '\0') { 722 if (pItemSSID->abySSID[wrq->length - 1] == '\0') {
723 if(wrq->length>0) 723 if(wrq->length>0)
724 pItemSSID->len = wrq->length - 1; 724 pItemSSID->len = wrq->length - 1;
725 } 725 }
726 else 726 else
727 pItemSSID->len = wrq->length; 727 pItemSSID->len = wrq->length;
728 PRINT_K("set essid to %s \n",pItemSSID->abySSID); 728 PRINT_K("set essid to %s \n",pItemSSID->abySSID);
729 729
730 //mike:need clear desiredBSSID 730 //mike:need clear desiredBSSID
731 if(pItemSSID->len==0) { 731 if(pItemSSID->len==0) {
732 memset(pMgmt->abyDesireBSSID, 0xFF,6); 732 memset(pMgmt->abyDesireBSSID, 0xFF,6);
733 return 0; 733 return 0;
734 } 734 }
735 735
736#ifdef WPA_SUPPLICANT_DRIVER_WEXT_SUPPORT 736#ifdef WPA_SUPPLICANT_DRIVER_WEXT_SUPPORT
737 //Wext wil order another command of siwap to link with desired AP, 737 //Wext wil order another command of siwap to link with desired AP,
738 //so here need not associate?? 738 //so here need not associate??
739 if(pDevice->bWPASuppWextEnabled == TRUE) { 739 if(pDevice->bWPASuppWextEnabled == TRUE) {
740 /*******search if in hidden ssid mode ****/ 740 /*******search if in hidden ssid mode ****/
741 { 741 {
742 PKnownBSS pCurr = NULL; 742 PKnownBSS pCurr = NULL;
743 BYTE abyTmpDesireSSID[WLAN_IEHDR_LEN + WLAN_SSID_MAXLEN + 1]; 743 BYTE abyTmpDesireSSID[WLAN_IEHDR_LEN + WLAN_SSID_MAXLEN + 1];
744 unsigned int ii, uSameBssidNum = 0; 744 unsigned int ii, uSameBssidNum = 0;
745 745
746 memcpy(abyTmpDesireSSID,pMgmt->abyDesireSSID,sizeof(abyTmpDesireSSID)); 746 memcpy(abyTmpDesireSSID,pMgmt->abyDesireSSID,sizeof(abyTmpDesireSSID));
747 pCurr = BSSpSearchBSSList(pDevice, 747 pCurr = BSSpSearchBSSList(pDevice,
748 NULL, 748 NULL,
749 abyTmpDesireSSID, 749 abyTmpDesireSSID,
750 pDevice->eConfigPHYMode 750 pDevice->eConfigPHYMode
751 ); 751 );
752 752
753 if (pCurr == NULL){ 753 if (pCurr == NULL){
754 PRINT_K("SIOCSIWESSID:hidden ssid site survey before associate.......\n"); 754 PRINT_K("SIOCSIWESSID:hidden ssid site survey before associate.......\n");
755 vResetCommandTimer((void *) pDevice); 755 vResetCommandTimer((void *) pDevice);
756 pMgmt->eScanType = WMAC_SCAN_ACTIVE; 756 pMgmt->eScanType = WMAC_SCAN_ACTIVE;
757 bScheduleCommand((void *) pDevice, 757 bScheduleCommand((void *) pDevice,
758 WLAN_CMD_BSSID_SCAN, 758 WLAN_CMD_BSSID_SCAN,
759 pMgmt->abyDesireSSID); 759 pMgmt->abyDesireSSID);
760 bScheduleCommand((void *) pDevice, 760 bScheduleCommand((void *) pDevice,
761 WLAN_CMD_SSID, 761 WLAN_CMD_SSID,
762 pMgmt->abyDesireSSID); 762 pMgmt->abyDesireSSID);
763 } 763 }
764 else { //mike:to find out if that desired SSID is a hidden-ssid AP , 764 else { //mike:to find out if that desired SSID is a hidden-ssid AP ,
765 // by means of judging if there are two same BSSID exist in list ? 765 // by means of judging if there are two same BSSID exist in list ?
766 for (ii = 0; ii < MAX_BSS_NUM; ii++) { 766 for (ii = 0; ii < MAX_BSS_NUM; ii++) {
767 if (pMgmt->sBSSList[ii].bActive && 767 if (pMgmt->sBSSList[ii].bActive &&
768 !compare_ether_addr(pMgmt->sBSSList[ii].abyBSSID, 768 !compare_ether_addr(pMgmt->sBSSList[ii].abyBSSID,
769 pCurr->abyBSSID)) { 769 pCurr->abyBSSID)) {
770 uSameBssidNum++; 770 uSameBssidNum++;
771 } 771 }
772 } 772 }
773 if(uSameBssidNum >= 2) { //hit: desired AP is in hidden ssid mode!!! 773 if(uSameBssidNum >= 2) { //hit: desired AP is in hidden ssid mode!!!
774 PRINT_K("SIOCSIWESSID:hidden ssid directly associate.......\n"); 774 PRINT_K("SIOCSIWESSID:hidden ssid directly associate.......\n");
775 vResetCommandTimer((void *) pDevice); 775 vResetCommandTimer((void *) pDevice);
776 pMgmt->eScanType = WMAC_SCAN_PASSIVE; //this scan type,you'll submit scan result! 776 pMgmt->eScanType = WMAC_SCAN_PASSIVE; //this scan type,you'll submit scan result!
777 bScheduleCommand((void *) pDevice, 777 bScheduleCommand((void *) pDevice,
778 WLAN_CMD_BSSID_SCAN, 778 WLAN_CMD_BSSID_SCAN,
779 pMgmt->abyDesireSSID); 779 pMgmt->abyDesireSSID);
780 bScheduleCommand((void *) pDevice, 780 bScheduleCommand((void *) pDevice,
781 WLAN_CMD_SSID, 781 WLAN_CMD_SSID,
782 pMgmt->abyDesireSSID); 782 pMgmt->abyDesireSSID);
783 } 783 }
784 } 784 }
785 } 785 }
786 return 0; 786 return 0;
787 } 787 }
788 #endif 788#endif
789 789
790 DBG_PRT(MSG_LEVEL_DEBUG, KERN_INFO "set essid = %s \n", pItemSSID->abySSID); 790 DBG_PRT(MSG_LEVEL_DEBUG, KERN_INFO "set essid = %s \n", pItemSSID->abySSID);
791 } 791 }
792 792
793 if (pDevice->flags & DEVICE_FLAGS_OPENED) { 793 if (pDevice->flags & DEVICE_FLAGS_OPENED) {
794 pDevice->bCommit = TRUE; 794 pDevice->bCommit = TRUE;
795 } 795 }
796 return 0; 796 return 0;
797} 797}
@@ -803,16 +803,16 @@ void iwctl_giwessid(struct net_device *dev, struct iw_request_info *info,
803 struct iw_point *wrq, char *extra) 803 struct iw_point *wrq, char *extra)
804{ 804{
805 PSDevice pDevice = (PSDevice)netdev_priv(dev); 805 PSDevice pDevice = (PSDevice)netdev_priv(dev);
806 PSMgmtObject pMgmt = &(pDevice->sMgmtObj); 806 PSMgmtObject pMgmt = &(pDevice->sMgmtObj);
807 PWLAN_IE_SSID pItemSSID; 807 PWLAN_IE_SSID pItemSSID;
808 808
809 DBG_PRT(MSG_LEVEL_DEBUG, KERN_INFO " SIOCGIWESSID \n"); 809 DBG_PRT(MSG_LEVEL_DEBUG, KERN_INFO " SIOCGIWESSID \n");
810 810
811 // Note : if wrq->u.data.flags != 0, we should 811 // Note : if wrq->u.data.flags != 0, we should
812 // get the relevant SSID from the SSID list... 812 // get the relevant SSID from the SSID list...
813 813
814 // Get the current SSID 814 // Get the current SSID
815 pItemSSID = (PWLAN_IE_SSID)pMgmt->abyCurrSSID; 815 pItemSSID = (PWLAN_IE_SSID)pMgmt->abyCurrSSID;
816 memcpy(extra, pItemSSID->abySSID , pItemSSID->len); 816 memcpy(extra, pItemSSID->abySSID , pItemSSID->len);
817 extra[pItemSSID->len] = '\0'; 817 extra[pItemSSID->len] = '\0';
818 818
@@ -827,23 +827,23 @@ int iwctl_siwrate(struct net_device *dev, struct iw_request_info *info,
827 struct iw_param *wrq, char *extra) 827 struct iw_param *wrq, char *extra)
828{ 828{
829 PSDevice pDevice = (PSDevice)netdev_priv(dev); 829 PSDevice pDevice = (PSDevice)netdev_priv(dev);
830 int rc = 0; 830 int rc = 0;
831 u8 brate = 0; 831 u8 brate = 0;
832 int i; 832 int i;
833 BYTE abySupportedRates[13]= {0x02, 0x04, 0x0B, 0x16, 0x0c, 0x12, 0x18, 0x24, 0x30, 0x48, 0x60, 0x6C, 0x90}; 833 BYTE abySupportedRates[13]= {0x02, 0x04, 0x0B, 0x16, 0x0c, 0x12, 0x18, 0x24, 0x30, 0x48, 0x60, 0x6C, 0x90};
834 834
835 835
836 DBG_PRT(MSG_LEVEL_DEBUG, KERN_INFO " SIOCSIWRATE \n"); 836 DBG_PRT(MSG_LEVEL_DEBUG, KERN_INFO " SIOCSIWRATE \n");
837 if (!(pDevice->flags & DEVICE_FLAGS_OPENED)) { 837 if (!(pDevice->flags & DEVICE_FLAGS_OPENED)) {
838 rc = -EINVAL; 838 rc = -EINVAL;
839 return rc; 839 return rc;
840 } 840 }
841 841
842 // First : get a valid bit rate value 842 // First : get a valid bit rate value
843 843
844 // Which type of value 844 // Which type of value
845 if((wrq->value < 13) && 845 if((wrq->value < 13) &&
846 (wrq->value >= 0)) { 846 (wrq->value >= 0)) {
847 // Setting by rate index 847 // Setting by rate index
848 // Find value in the magic rate table 848 // Find value in the magic rate table
849 brate = wrq->value; 849 brate = wrq->value;
@@ -882,19 +882,19 @@ int iwctl_siwrate(struct net_device *dev, struct iw_request_info *info,
882 // Fixed mode 882 // Fixed mode
883 // One rate, fixed 883 // One rate, fixed
884 pDevice->bFixRate = TRUE; 884 pDevice->bFixRate = TRUE;
885 if ((pDevice->byBBType == BB_TYPE_11B)&& (brate > 3)) { 885 if ((pDevice->byBBType == BB_TYPE_11B)&& (brate > 3)) {
886 pDevice->uConnectionRate = 3; 886 pDevice->uConnectionRate = 3;
887 } 887 }
888 else { 888 else {
889 pDevice->uConnectionRate = brate; 889 pDevice->uConnectionRate = brate;
890 DBG_PRT(MSG_LEVEL_DEBUG, KERN_INFO "Fixed to Rate %d \n", pDevice->uConnectionRate); 890 DBG_PRT(MSG_LEVEL_DEBUG, KERN_INFO "Fixed to Rate %d \n", pDevice->uConnectionRate);
891 } 891 }
892 892
893 } 893 }
894 else { 894 else {
895 pDevice->bFixRate = FALSE; 895 pDevice->bFixRate = FALSE;
896 pDevice->uConnectionRate = 13; 896 pDevice->uConnectionRate = 13;
897 } 897 }
898 898
899 return rc; 899 return rc;
900} 900}
@@ -906,38 +906,38 @@ void iwctl_giwrate(struct net_device *dev, struct iw_request_info *info,
906 struct iw_param *wrq, char *extra) 906 struct iw_param *wrq, char *extra)
907{ 907{
908 PSDevice pDevice = (PSDevice)netdev_priv(dev); 908 PSDevice pDevice = (PSDevice)netdev_priv(dev);
909 PSMgmtObject pMgmt = &(pDevice->sMgmtObj); 909 PSMgmtObject pMgmt = &(pDevice->sMgmtObj);
910 910
911 DBG_PRT(MSG_LEVEL_DEBUG, KERN_INFO " SIOCGIWRATE \n"); 911 DBG_PRT(MSG_LEVEL_DEBUG, KERN_INFO " SIOCGIWRATE \n");
912 { 912 {
913 BYTE abySupportedRates[13]= {0x02, 0x04, 0x0B, 0x16, 0x0c, 0x12, 0x18, 0x24, 0x30, 0x48, 0x60, 0x6C, 0x90}; 913 BYTE abySupportedRates[13]= {0x02, 0x04, 0x0B, 0x16, 0x0c, 0x12, 0x18, 0x24, 0x30, 0x48, 0x60, 0x6C, 0x90};
914 int brate = 0; 914 int brate = 0;
915 if (pDevice->uConnectionRate < 13) { 915 if (pDevice->uConnectionRate < 13) {
916 brate = abySupportedRates[pDevice->uConnectionRate]; 916 brate = abySupportedRates[pDevice->uConnectionRate];
917 }else { 917 }else {
918 if (pDevice->byBBType == BB_TYPE_11B) 918 if (pDevice->byBBType == BB_TYPE_11B)
919 brate = 0x16; 919 brate = 0x16;
920 if (pDevice->byBBType == BB_TYPE_11G) 920 if (pDevice->byBBType == BB_TYPE_11G)
921 brate = 0x6C; 921 brate = 0x6C;
922 if (pDevice->byBBType == BB_TYPE_11A) 922 if (pDevice->byBBType == BB_TYPE_11A)
923 brate = 0x6C; 923 brate = 0x6C;
924 } 924 }
925 925
926 if (pMgmt->eCurrMode == WMAC_MODE_ESS_AP) { 926 if (pMgmt->eCurrMode == WMAC_MODE_ESS_AP) {
927 if (pDevice->byBBType == BB_TYPE_11B) 927 if (pDevice->byBBType == BB_TYPE_11B)
928 brate = 0x16; 928 brate = 0x16;
929 if (pDevice->byBBType == BB_TYPE_11G) 929 if (pDevice->byBBType == BB_TYPE_11G)
930 brate = 0x6C; 930 brate = 0x6C;
931 if (pDevice->byBBType == BB_TYPE_11A) 931 if (pDevice->byBBType == BB_TYPE_11A)
932 brate = 0x6C; 932 brate = 0x6C;
933 } 933 }
934 if (pDevice->uConnectionRate == 13) 934 if (pDevice->uConnectionRate == 13)
935 brate = abySupportedRates[pDevice->wCurrentRate]; 935 brate = abySupportedRates[pDevice->wCurrentRate];
936 wrq->value = brate * 500000; 936 wrq->value = brate * 500000;
937 // If more than one rate, set auto 937 // If more than one rate, set auto
938 if (pDevice->bFixRate == TRUE) 938 if (pDevice->bFixRate == TRUE)
939 wrq->fixed = TRUE; 939 wrq->fixed = TRUE;
940 } 940 }
941} 941}
942 942
943/* 943/*
@@ -966,7 +966,7 @@ int iwctl_giwrts(struct net_device *dev, struct iw_request_info *info,
966{ 966{
967 PSDevice pDevice = (PSDevice)netdev_priv(dev); 967 PSDevice pDevice = (PSDevice)netdev_priv(dev);
968 968
969 DBG_PRT(MSG_LEVEL_DEBUG, KERN_INFO " SIOCGIWRTS \n"); 969 DBG_PRT(MSG_LEVEL_DEBUG, KERN_INFO " SIOCGIWRTS \n");
970 wrq->value = pDevice->wRTSThreshold; 970 wrq->value = pDevice->wRTSThreshold;
971 wrq->disabled = (wrq->value >= 2312); 971 wrq->disabled = (wrq->value >= 2312);
972 wrq->fixed = 1; 972 wrq->fixed = 1;
@@ -980,20 +980,20 @@ int iwctl_giwrts(struct net_device *dev, struct iw_request_info *info,
980int iwctl_siwfrag(struct net_device *dev, struct iw_request_info *info, 980int iwctl_siwfrag(struct net_device *dev, struct iw_request_info *info,
981 struct iw_param *wrq, char *extra) 981 struct iw_param *wrq, char *extra)
982{ 982{
983 PSDevice pDevice = (PSDevice)netdev_priv(dev); 983 PSDevice pDevice = (PSDevice)netdev_priv(dev);
984 int rc = 0; 984 int rc = 0;
985 int fthr = wrq->value; 985 int fthr = wrq->value;
986 986
987 DBG_PRT(MSG_LEVEL_DEBUG, KERN_INFO " SIOCSIWFRAG \n"); 987 DBG_PRT(MSG_LEVEL_DEBUG, KERN_INFO " SIOCSIWFRAG \n");
988 988
989 if (wrq->disabled) 989 if (wrq->disabled)
990 fthr = 2312; 990 fthr = 2312;
991 if((fthr < 256) || (fthr > 2312)) { 991 if((fthr < 256) || (fthr > 2312)) {
992 rc = -EINVAL; 992 rc = -EINVAL;
993 }else { 993 }else {
994 fthr &= ~0x1; // Get an even value 994 fthr &= ~0x1; // Get an even value
995 pDevice->wFragmentationThreshold = (u16)fthr; 995 pDevice->wFragmentationThreshold = (u16)fthr;
996 } 996 }
997 return rc; 997 return rc;
998} 998}
999 999
@@ -1003,9 +1003,9 @@ int iwctl_siwfrag(struct net_device *dev, struct iw_request_info *info,
1003int iwctl_giwfrag(struct net_device *dev, struct iw_request_info *info, 1003int iwctl_giwfrag(struct net_device *dev, struct iw_request_info *info,
1004 struct iw_param *wrq, char *extra) 1004 struct iw_param *wrq, char *extra)
1005{ 1005{
1006 PSDevice pDevice = (PSDevice)netdev_priv(dev); 1006 PSDevice pDevice = (PSDevice)netdev_priv(dev);
1007 1007
1008 DBG_PRT(MSG_LEVEL_DEBUG, KERN_INFO " SIOCGIWFRAG \n"); 1008 DBG_PRT(MSG_LEVEL_DEBUG, KERN_INFO " SIOCGIWFRAG \n");
1009 wrq->value = pDevice->wFragmentationThreshold; 1009 wrq->value = pDevice->wFragmentationThreshold;
1010 wrq->disabled = (wrq->value >= 2312); 1010 wrq->disabled = (wrq->value >= 2312);
1011 wrq->fixed = 1; 1011 wrq->fixed = 1;
@@ -1019,10 +1019,10 @@ int iwctl_giwfrag(struct net_device *dev, struct iw_request_info *info,
1019int iwctl_siwretry(struct net_device *dev, struct iw_request_info *info, 1019int iwctl_siwretry(struct net_device *dev, struct iw_request_info *info,
1020 struct iw_param *wrq, char *extra) 1020 struct iw_param *wrq, char *extra)
1021{ 1021{
1022 PSDevice pDevice = (PSDevice)netdev_priv(dev); 1022 PSDevice pDevice = (PSDevice)netdev_priv(dev);
1023 int rc = 0; 1023 int rc = 0;
1024 1024
1025 DBG_PRT(MSG_LEVEL_DEBUG, KERN_INFO " SIOCSIWRETRY \n"); 1025 DBG_PRT(MSG_LEVEL_DEBUG, KERN_INFO " SIOCSIWRETRY \n");
1026 1026
1027 if (wrq->disabled) { 1027 if (wrq->disabled) {
1028 rc = -EINVAL; 1028 rc = -EINVAL;
@@ -1052,8 +1052,8 @@ int iwctl_siwretry(struct net_device *dev, struct iw_request_info *info,
1052int iwctl_giwretry(struct net_device *dev, struct iw_request_info *info, 1052int iwctl_giwretry(struct net_device *dev, struct iw_request_info *info,
1053 struct iw_param *wrq, char *extra) 1053 struct iw_param *wrq, char *extra)
1054{ 1054{
1055 PSDevice pDevice = (PSDevice)netdev_priv(dev); 1055 PSDevice pDevice = (PSDevice)netdev_priv(dev);
1056 DBG_PRT(MSG_LEVEL_DEBUG, KERN_INFO " SIOCGIWRETRY \n"); 1056 DBG_PRT(MSG_LEVEL_DEBUG, KERN_INFO " SIOCGIWRETRY \n");
1057 wrq->disabled = 0; // Can't be disabled 1057 wrq->disabled = 0; // Can't be disabled
1058 1058
1059 // Note : by default, display the min retry number 1059 // Note : by default, display the min retry number
@@ -1079,99 +1079,99 @@ int iwctl_giwretry(struct net_device *dev, struct iw_request_info *info,
1079int iwctl_siwencode(struct net_device *dev, struct iw_request_info *info, 1079int iwctl_siwencode(struct net_device *dev, struct iw_request_info *info,
1080 struct iw_point *wrq, char *extra) 1080 struct iw_point *wrq, char *extra)
1081{ 1081{
1082 PSDevice pDevice = (PSDevice)netdev_priv(dev); 1082 PSDevice pDevice = (PSDevice)netdev_priv(dev);
1083 PSMgmtObject pMgmt = &(pDevice->sMgmtObj); 1083 PSMgmtObject pMgmt = &(pDevice->sMgmtObj);
1084 DWORD dwKeyIndex = (DWORD)(wrq->flags & IW_ENCODE_INDEX); 1084 DWORD dwKeyIndex = (DWORD)(wrq->flags & IW_ENCODE_INDEX);
1085 int ii,uu, rc = 0; 1085 int ii,uu, rc = 0;
1086 int index = (wrq->flags & IW_ENCODE_INDEX); 1086 int index = (wrq->flags & IW_ENCODE_INDEX);
1087 1087
1088 DBG_PRT(MSG_LEVEL_DEBUG, KERN_INFO " SIOCSIWENCODE \n"); 1088 DBG_PRT(MSG_LEVEL_DEBUG, KERN_INFO " SIOCSIWENCODE \n");
1089 1089
1090 // Check the size of the key 1090 // Check the size of the key
1091 if (wrq->length > WLAN_WEP232_KEYLEN) { 1091 if (wrq->length > WLAN_WEP232_KEYLEN) {
1092 rc = -EINVAL; 1092 rc = -EINVAL;
1093 return rc; 1093 return rc;
1094 } 1094 }
1095 1095
1096 if (dwKeyIndex > WLAN_WEP_NKEYS) { 1096 if (dwKeyIndex > WLAN_WEP_NKEYS) {
1097 rc = -EINVAL; 1097 rc = -EINVAL;
1098 return rc; 1098 return rc;
1099 } 1099 }
1100 1100
1101 if (dwKeyIndex > 0) 1101 if (dwKeyIndex > 0)
1102 dwKeyIndex--; 1102 dwKeyIndex--;
1103 1103
1104 // Send the key to the card 1104 // Send the key to the card
1105 if (wrq->length > 0) { 1105 if (wrq->length > 0) {
1106 1106
1107 if (wrq->length == WLAN_WEP232_KEYLEN) { 1107 if (wrq->length == WLAN_WEP232_KEYLEN) {
1108 DBG_PRT(MSG_LEVEL_DEBUG, KERN_INFO "Set 232 bit wep key\n"); 1108 DBG_PRT(MSG_LEVEL_DEBUG, KERN_INFO "Set 232 bit wep key\n");
1109 } 1109 }
1110 else if (wrq->length == WLAN_WEP104_KEYLEN) { 1110 else if (wrq->length == WLAN_WEP104_KEYLEN) {
1111 DBG_PRT(MSG_LEVEL_DEBUG, KERN_INFO "Set 104 bit wep key\n"); 1111 DBG_PRT(MSG_LEVEL_DEBUG, KERN_INFO "Set 104 bit wep key\n");
1112 } 1112 }
1113 else if (wrq->length == WLAN_WEP40_KEYLEN) { 1113 else if (wrq->length == WLAN_WEP40_KEYLEN) {
1114 DBG_PRT(MSG_LEVEL_DEBUG, KERN_INFO "Set 40 bit wep key, index= %d\n", (int)dwKeyIndex); 1114 DBG_PRT(MSG_LEVEL_DEBUG, KERN_INFO "Set 40 bit wep key, index= %d\n", (int)dwKeyIndex);
1115 } 1115 }
1116 memset(pDevice->abyKey, 0, WLAN_WEP232_KEYLEN); 1116 memset(pDevice->abyKey, 0, WLAN_WEP232_KEYLEN);
1117 memcpy(pDevice->abyKey, extra, wrq->length); 1117 memcpy(pDevice->abyKey, extra, wrq->length);
1118 1118
1119 DBG_PRT(MSG_LEVEL_DEBUG, KERN_INFO"abyKey: "); 1119 DBG_PRT(MSG_LEVEL_DEBUG, KERN_INFO"abyKey: ");
1120 for (ii = 0; ii < wrq->length; ii++) { 1120 for (ii = 0; ii < wrq->length; ii++) {
1121 DBG_PRT(MSG_LEVEL_DEBUG, KERN_INFO "%02x ", pDevice->abyKey[ii]); 1121 DBG_PRT(MSG_LEVEL_DEBUG, KERN_INFO "%02x ", pDevice->abyKey[ii]);
1122 } 1122 }
1123 1123
1124 if (pDevice->flags & DEVICE_FLAGS_OPENED) { 1124 if (pDevice->flags & DEVICE_FLAGS_OPENED) {
1125 spin_lock_irq(&pDevice->lock); 1125 spin_lock_irq(&pDevice->lock);
1126 KeybSetDefaultKey( pDevice, 1126 KeybSetDefaultKey( pDevice,
1127 &(pDevice->sKey), 1127 &(pDevice->sKey),
1128 dwKeyIndex | (1 << 31), 1128 dwKeyIndex | (1 << 31),
1129 wrq->length, 1129 wrq->length,
1130 NULL, 1130 NULL,
1131 pDevice->abyKey, 1131 pDevice->abyKey,
1132 KEY_CTL_WEP 1132 KEY_CTL_WEP
1133 ); 1133 );
1134 spin_unlock_irq(&pDevice->lock); 1134 spin_unlock_irq(&pDevice->lock);
1135 } 1135 }
1136 pDevice->byKeyIndex = (BYTE)dwKeyIndex; 1136 pDevice->byKeyIndex = (BYTE)dwKeyIndex;
1137 pDevice->uKeyLength = wrq->length; 1137 pDevice->uKeyLength = wrq->length;
1138 pDevice->bTransmitKey = TRUE; 1138 pDevice->bTransmitKey = TRUE;
1139 pDevice->bEncryptionEnable = TRUE; 1139 pDevice->bEncryptionEnable = TRUE;
1140 pDevice->eEncryptionStatus = Ndis802_11Encryption1Enabled; 1140 pDevice->eEncryptionStatus = Ndis802_11Encryption1Enabled;
1141 1141
1142 // Do we want to just set the transmit key index ? 1142 // Do we want to just set the transmit key index ?
1143 if ( index < 4 ) { 1143 if ( index < 4 ) {
1144 pDevice->byKeyIndex = index; 1144 pDevice->byKeyIndex = index;
1145 } else if (!(wrq->flags & IW_ENCODE_MODE)) { 1145 } else if (!(wrq->flags & IW_ENCODE_MODE)) {
1146 rc = -EINVAL; 1146 rc = -EINVAL;
1147 return rc; 1147 return rc;
1148 } 1148 }
1149 } 1149 }
1150 // Read the flags 1150 // Read the flags
1151 if(wrq->flags & IW_ENCODE_DISABLED){ 1151 if(wrq->flags & IW_ENCODE_DISABLED){
1152 1152
1153 DBG_PRT(MSG_LEVEL_DEBUG, KERN_INFO "Disable WEP function\n"); 1153 DBG_PRT(MSG_LEVEL_DEBUG, KERN_INFO "Disable WEP function\n");
1154 pMgmt->bShareKeyAlgorithm = FALSE; 1154 pMgmt->bShareKeyAlgorithm = FALSE;
1155 pDevice->bEncryptionEnable = FALSE; 1155 pDevice->bEncryptionEnable = FALSE;
1156 pDevice->eEncryptionStatus = Ndis802_11EncryptionDisabled; 1156 pDevice->eEncryptionStatus = Ndis802_11EncryptionDisabled;
1157 if (pDevice->flags & DEVICE_FLAGS_OPENED) { 1157 if (pDevice->flags & DEVICE_FLAGS_OPENED) {
1158 spin_lock_irq(&pDevice->lock); 1158 spin_lock_irq(&pDevice->lock);
1159 for (uu = 0; uu < MAX_KEY_TABLE; uu++) 1159 for (uu = 0; uu < MAX_KEY_TABLE; uu++)
1160 MACvDisableKeyEntry(pDevice, uu); 1160 MACvDisableKeyEntry(pDevice, uu);
1161 spin_unlock_irq(&pDevice->lock); 1161 spin_unlock_irq(&pDevice->lock);
1162 } 1162 }
1163 } 1163 }
1164 if(wrq->flags & IW_ENCODE_RESTRICTED) { 1164 if(wrq->flags & IW_ENCODE_RESTRICTED) {
1165 DBG_PRT(MSG_LEVEL_DEBUG, KERN_INFO "Enable WEP & ShareKey System\n"); 1165 DBG_PRT(MSG_LEVEL_DEBUG, KERN_INFO "Enable WEP & ShareKey System\n");
1166 pMgmt->bShareKeyAlgorithm = TRUE; 1166 pMgmt->bShareKeyAlgorithm = TRUE;
1167 } 1167 }
1168 if(wrq->flags & IW_ENCODE_OPEN) { 1168 if(wrq->flags & IW_ENCODE_OPEN) {
1169 DBG_PRT(MSG_LEVEL_DEBUG, KERN_INFO "Enable WEP & Open System\n"); 1169 DBG_PRT(MSG_LEVEL_DEBUG, KERN_INFO "Enable WEP & Open System\n");
1170 pMgmt->bShareKeyAlgorithm = FALSE; 1170 pMgmt->bShareKeyAlgorithm = FALSE;
1171 } 1171 }
1172 1172
1173#ifdef WPA_SUPPLICANT_DRIVER_WEXT_SUPPORT 1173#ifdef WPA_SUPPLICANT_DRIVER_WEXT_SUPPORT
1174 memset(pMgmt->abyDesireBSSID, 0xFF,6); 1174 memset(pMgmt->abyDesireBSSID, 0xFF,6);
1175#endif 1175#endif
1176 return rc; 1176 return rc;
1177} 1177}
@@ -1195,9 +1195,9 @@ int iwctl_giwencode(struct net_device *dev, struct iw_request_info *info,
1195 if(pDevice->byKeyIndex<WLAN_WEP_NKEYS){ 1195 if(pDevice->byKeyIndex<WLAN_WEP_NKEYS){
1196 index=pDevice->byKeyIndex; 1196 index=pDevice->byKeyIndex;
1197 } else 1197 } else
1198 index=0; 1198 index=0;
1199 }else 1199 }else
1200 index--; 1200 index--;
1201 1201
1202 memset(abyKey, 0, WLAN_WEP232_KEYLEN); 1202 memset(abyKey, 0, WLAN_WEP232_KEYLEN);
1203 // Check encryption mode 1203 // Check encryption mode
@@ -1212,18 +1212,18 @@ int iwctl_giwencode(struct net_device *dev, struct iw_request_info *info,
1212 wrq->flags |= IW_ENCODE_RESTRICTED; 1212 wrq->flags |= IW_ENCODE_RESTRICTED;
1213 else 1213 else
1214 wrq->flags |= IW_ENCODE_OPEN; 1214 wrq->flags |= IW_ENCODE_OPEN;
1215 wrq->length=0; 1215 wrq->length=0;
1216 1216
1217 if((index==0)&&(pDevice->eEncryptionStatus == Ndis802_11Encryption2Enabled|| 1217 if((index==0)&&(pDevice->eEncryptionStatus == Ndis802_11Encryption2Enabled||
1218 pDevice->eEncryptionStatus == Ndis802_11Encryption3Enabled)){//get wpa pairwise key 1218 pDevice->eEncryptionStatus == Ndis802_11Encryption3Enabled)){//get wpa pairwise key
1219 if (KeybGetKey(&(pDevice->sKey),pMgmt->abyCurrBSSID, 0xffffffff, &pKey)){ 1219 if (KeybGetKey(&(pDevice->sKey),pMgmt->abyCurrBSSID, 0xffffffff, &pKey)){
1220 wrq->length = pKey->uKeyLength;
1221 memcpy(abyKey, pKey->abyKey, pKey->uKeyLength);
1222 memcpy(extra, abyKey, WLAN_WEP232_KEYLEN);
1223 }
1224 }else if (KeybGetKey(&(pDevice->sKey), pDevice->abyBroadcastAddr, (BYTE)index , &pKey)){
1225 wrq->length = pKey->uKeyLength; 1220 wrq->length = pKey->uKeyLength;
1226 memcpy(abyKey, pKey->abyKey, pKey->uKeyLength); 1221 memcpy(abyKey, pKey->abyKey, pKey->uKeyLength);
1222 memcpy(extra, abyKey, WLAN_WEP232_KEYLEN);
1223 }
1224 }else if (KeybGetKey(&(pDevice->sKey), pDevice->abyBroadcastAddr, (BYTE)index , &pKey)){
1225 wrq->length = pKey->uKeyLength;
1226 memcpy(abyKey, pKey->abyKey, pKey->uKeyLength);
1227 memcpy(extra, abyKey, WLAN_WEP232_KEYLEN); 1227 memcpy(extra, abyKey, WLAN_WEP232_KEYLEN);
1228 } 1228 }
1229 1229
@@ -1237,15 +1237,15 @@ int iwctl_giwencode(struct net_device *dev, struct iw_request_info *info,
1237int iwctl_siwpower(struct net_device *dev, struct iw_request_info *info, 1237int iwctl_siwpower(struct net_device *dev, struct iw_request_info *info,
1238 struct iw_param *wrq, char *extra) 1238 struct iw_param *wrq, char *extra)
1239{ 1239{
1240 PSDevice pDevice = (PSDevice)netdev_priv(dev); 1240 PSDevice pDevice = (PSDevice)netdev_priv(dev);
1241 PSMgmtObject pMgmt = &(pDevice->sMgmtObj); 1241 PSMgmtObject pMgmt = &(pDevice->sMgmtObj);
1242 int rc = 0; 1242 int rc = 0;
1243 1243
1244 DBG_PRT(MSG_LEVEL_DEBUG, KERN_INFO " SIOCSIWPOWER \n"); 1244 DBG_PRT(MSG_LEVEL_DEBUG, KERN_INFO " SIOCSIWPOWER \n");
1245 1245
1246 if (!(pDevice->flags & DEVICE_FLAGS_OPENED)) { 1246 if (!(pDevice->flags & DEVICE_FLAGS_OPENED)) {
1247 rc = -EINVAL; 1247 rc = -EINVAL;
1248 return rc; 1248 return rc;
1249 } 1249 }
1250 1250
1251 if (wrq->disabled) { 1251 if (wrq->disabled) {
@@ -1254,23 +1254,23 @@ int iwctl_siwpower(struct net_device *dev, struct iw_request_info *info,
1254 return rc; 1254 return rc;
1255 } 1255 }
1256 if ((wrq->flags & IW_POWER_TYPE) == IW_POWER_TIMEOUT) { 1256 if ((wrq->flags & IW_POWER_TYPE) == IW_POWER_TIMEOUT) {
1257 pDevice->ePSMode = WMAC_POWER_FAST; 1257 pDevice->ePSMode = WMAC_POWER_FAST;
1258 PSvEnablePowerSaving((void *) pDevice, pMgmt->wListenInterval); 1258 PSvEnablePowerSaving((void *) pDevice, pMgmt->wListenInterval);
1259 1259
1260 } else if ((wrq->flags & IW_POWER_TYPE) == IW_POWER_PERIOD) { 1260 } else if ((wrq->flags & IW_POWER_TYPE) == IW_POWER_PERIOD) {
1261 pDevice->ePSMode = WMAC_POWER_FAST; 1261 pDevice->ePSMode = WMAC_POWER_FAST;
1262 PSvEnablePowerSaving((void *) pDevice, pMgmt->wListenInterval); 1262 PSvEnablePowerSaving((void *) pDevice, pMgmt->wListenInterval);
1263 } 1263 }
1264 switch (wrq->flags & IW_POWER_MODE) { 1264 switch (wrq->flags & IW_POWER_MODE) {
1265 case IW_POWER_UNICAST_R: 1265 case IW_POWER_UNICAST_R:
1266 DBG_PRT(MSG_LEVEL_DEBUG, KERN_INFO " SIOCSIWPOWER: IW_POWER_UNICAST_R \n"); 1266 DBG_PRT(MSG_LEVEL_DEBUG, KERN_INFO " SIOCSIWPOWER: IW_POWER_UNICAST_R \n");
1267 rc = -EINVAL; 1267 rc = -EINVAL;
1268 break; 1268 break;
1269 case IW_POWER_ALL_R: 1269 case IW_POWER_ALL_R:
1270 DBG_PRT(MSG_LEVEL_DEBUG, KERN_INFO " SIOCSIWPOWER: IW_POWER_ALL_R \n"); 1270 DBG_PRT(MSG_LEVEL_DEBUG, KERN_INFO " SIOCSIWPOWER: IW_POWER_ALL_R \n");
1271 rc = -EINVAL; 1271 rc = -EINVAL;
1272 case IW_POWER_ON: 1272 case IW_POWER_ON:
1273 DBG_PRT(MSG_LEVEL_DEBUG, KERN_INFO " SIOCSIWPOWER: IW_POWER_ON \n"); 1273 DBG_PRT(MSG_LEVEL_DEBUG, KERN_INFO " SIOCSIWPOWER: IW_POWER_ON \n");
1274 break; 1274 break;
1275 default: 1275 default:
1276 rc = -EINVAL; 1276 rc = -EINVAL;
@@ -1285,14 +1285,14 @@ int iwctl_siwpower(struct net_device *dev, struct iw_request_info *info,
1285int iwctl_giwpower(struct net_device *dev, struct iw_request_info *info, 1285int iwctl_giwpower(struct net_device *dev, struct iw_request_info *info,
1286 struct iw_param *wrq, char *extra) 1286 struct iw_param *wrq, char *extra)
1287{ 1287{
1288 PSDevice pDevice = (PSDevice)netdev_priv(dev); 1288 PSDevice pDevice = (PSDevice)netdev_priv(dev);
1289 PSMgmtObject pMgmt = &(pDevice->sMgmtObj); 1289 PSMgmtObject pMgmt = &(pDevice->sMgmtObj);
1290 int mode = pDevice->ePSMode; 1290 int mode = pDevice->ePSMode;
1291 1291
1292 DBG_PRT(MSG_LEVEL_DEBUG, KERN_INFO " SIOCGIWPOWER \n"); 1292 DBG_PRT(MSG_LEVEL_DEBUG, KERN_INFO " SIOCGIWPOWER \n");
1293 1293
1294 if ((wrq->disabled = (mode == WMAC_POWER_CAM))) 1294 if ((wrq->disabled = (mode == WMAC_POWER_CAM)))
1295 return 0; 1295 return 0;
1296 1296
1297 if ((wrq->flags & IW_POWER_TYPE) == IW_POWER_TIMEOUT) { 1297 if ((wrq->flags & IW_POWER_TYPE) == IW_POWER_TIMEOUT) {
1298 wrq->value = (int)((pMgmt->wListenInterval * pMgmt->wCurrBeaconPeriod) << 10); 1298 wrq->value = (int)((pMgmt->wListenInterval * pMgmt->wCurrBeaconPeriod) << 10);
@@ -1311,17 +1311,17 @@ int iwctl_giwpower(struct net_device *dev, struct iw_request_info *info,
1311int iwctl_giwsens(struct net_device *dev, struct iw_request_info *info, 1311int iwctl_giwsens(struct net_device *dev, struct iw_request_info *info,
1312 struct iw_param *wrq, char *extra) 1312 struct iw_param *wrq, char *extra)
1313{ 1313{
1314 PSDevice pDevice = (PSDevice)netdev_priv(dev); 1314 PSDevice pDevice = (PSDevice)netdev_priv(dev);
1315 long ldBm; 1315 long ldBm;
1316 1316
1317 DBG_PRT(MSG_LEVEL_DEBUG, KERN_INFO " SIOCGIWSENS \n"); 1317 DBG_PRT(MSG_LEVEL_DEBUG, KERN_INFO " SIOCGIWSENS \n");
1318 if (pDevice->bLinkPass == TRUE) { 1318 if (pDevice->bLinkPass == TRUE) {
1319 RFvRSSITodBm(pDevice, (BYTE)(pDevice->uCurrRSSI), &ldBm); 1319 RFvRSSITodBm(pDevice, (BYTE)(pDevice->uCurrRSSI), &ldBm);
1320 wrq->value = ldBm; 1320 wrq->value = ldBm;
1321 } 1321 }
1322 else { 1322 else {
1323 wrq->value = 0; 1323 wrq->value = 0;
1324 }; 1324 };
1325 wrq->disabled = (wrq->value == 0); 1325 wrq->disabled = (wrq->value == 0);
1326 wrq->fixed = 1; 1326 wrq->fixed = 1;
1327 return 0; 1327 return 0;
@@ -1338,29 +1338,29 @@ int iwctl_siwauth(struct net_device *dev, struct iw_request_info *info,
1338 static int wpa_version=0; //must be static to save the last value,einsn liu 1338 static int wpa_version=0; //must be static to save the last value,einsn liu
1339 static int pairwise=0; 1339 static int pairwise=0;
1340 1340
1341 DBG_PRT(MSG_LEVEL_DEBUG, KERN_INFO " SIOCSIWAUTH \n"); 1341 DBG_PRT(MSG_LEVEL_DEBUG, KERN_INFO " SIOCSIWAUTH \n");
1342 switch (wrq->flags & IW_AUTH_INDEX) { 1342 switch (wrq->flags & IW_AUTH_INDEX) {
1343 case IW_AUTH_WPA_VERSION: 1343 case IW_AUTH_WPA_VERSION:
1344 wpa_version = wrq->value; 1344 wpa_version = wrq->value;
1345 if(wrq->value == IW_AUTH_WPA_VERSION_DISABLED) { 1345 if(wrq->value == IW_AUTH_WPA_VERSION_DISABLED) {
1346 PRINT_K("iwctl_siwauth:set WPADEV to disable at 1??????\n"); 1346 PRINT_K("iwctl_siwauth:set WPADEV to disable at 1??????\n");
1347 } 1347 }
1348 else if(wrq->value == IW_AUTH_WPA_VERSION_WPA) { 1348 else if(wrq->value == IW_AUTH_WPA_VERSION_WPA) {
1349 PRINT_K("iwctl_siwauth:set WPADEV to WPA1******\n"); 1349 PRINT_K("iwctl_siwauth:set WPADEV to WPA1******\n");
1350 } 1350 }
1351 else { 1351 else {
1352 PRINT_K("iwctl_siwauth:set WPADEV to WPA2******\n"); 1352 PRINT_K("iwctl_siwauth:set WPADEV to WPA2******\n");
1353 } 1353 }
1354 break; 1354 break;
1355 case IW_AUTH_CIPHER_PAIRWISE: 1355 case IW_AUTH_CIPHER_PAIRWISE:
1356 pairwise = wrq->value; 1356 pairwise = wrq->value;
1357 PRINT_K("iwctl_siwauth:set pairwise=%d\n",pairwise); 1357 PRINT_K("iwctl_siwauth:set pairwise=%d\n",pairwise);
1358 if(pairwise == IW_AUTH_CIPHER_CCMP){ 1358 if(pairwise == IW_AUTH_CIPHER_CCMP){
1359 pDevice->eEncryptionStatus = Ndis802_11Encryption3Enabled; 1359 pDevice->eEncryptionStatus = Ndis802_11Encryption3Enabled;
1360 }else if(pairwise == IW_AUTH_CIPHER_TKIP){ 1360 }else if(pairwise == IW_AUTH_CIPHER_TKIP){
1361 pDevice->eEncryptionStatus = Ndis802_11Encryption2Enabled; 1361 pDevice->eEncryptionStatus = Ndis802_11Encryption2Enabled;
1362 } else if (pairwise == IW_AUTH_CIPHER_WEP40 || 1362 } else if (pairwise == IW_AUTH_CIPHER_WEP40 ||
1363 pairwise == IW_AUTH_CIPHER_WEP104) { 1363 pairwise == IW_AUTH_CIPHER_WEP104) {
1364 pDevice->eEncryptionStatus = Ndis802_11Encryption1Enabled; 1364 pDevice->eEncryptionStatus = Ndis802_11Encryption1Enabled;
1365 }else if(pairwise == IW_AUTH_CIPHER_NONE){ 1365 }else if(pairwise == IW_AUTH_CIPHER_NONE){
1366 //do nothing,einsn liu 1366 //do nothing,einsn liu
@@ -1368,7 +1368,7 @@ int iwctl_siwauth(struct net_device *dev, struct iw_request_info *info,
1368 1368
1369 break; 1369 break;
1370 case IW_AUTH_CIPHER_GROUP: 1370 case IW_AUTH_CIPHER_GROUP:
1371 PRINT_K("iwctl_siwauth:set GROUP=%d\n",wrq->value); 1371 PRINT_K("iwctl_siwauth:set GROUP=%d\n",wrq->value);
1372 if(wpa_version == IW_AUTH_WPA_VERSION_DISABLED) 1372 if(wpa_version == IW_AUTH_WPA_VERSION_DISABLED)
1373 break; 1373 break;
1374 if(pairwise == IW_AUTH_CIPHER_NONE){ 1374 if(pairwise == IW_AUTH_CIPHER_NONE){
@@ -1380,7 +1380,7 @@ int iwctl_siwauth(struct net_device *dev, struct iw_request_info *info,
1380 } 1380 }
1381 break; 1381 break;
1382 case IW_AUTH_KEY_MGMT: 1382 case IW_AUTH_KEY_MGMT:
1383 PRINT_K("iwctl_siwauth(wpa_version=%d):set KEY_MGMT=%d\n",wpa_version,wrq->value); 1383 PRINT_K("iwctl_siwauth(wpa_version=%d):set KEY_MGMT=%d\n",wpa_version,wrq->value);
1384 if(wpa_version == IW_AUTH_WPA_VERSION_WPA2){ 1384 if(wpa_version == IW_AUTH_WPA_VERSION_WPA2){
1385 if(wrq->value == IW_AUTH_KEY_MGMT_PSK) 1385 if(wrq->value == IW_AUTH_KEY_MGMT_PSK)
1386 pMgmt->eAuthenMode = WMAC_AUTH_WPA2PSK; 1386 pMgmt->eAuthenMode = WMAC_AUTH_WPA2PSK;
@@ -1398,7 +1398,7 @@ int iwctl_siwauth(struct net_device *dev, struct iw_request_info *info,
1398 case IW_AUTH_DROP_UNENCRYPTED: 1398 case IW_AUTH_DROP_UNENCRYPTED:
1399 break; 1399 break;
1400 case IW_AUTH_80211_AUTH_ALG: 1400 case IW_AUTH_80211_AUTH_ALG:
1401 PRINT_K("iwctl_siwauth:set AUTH_ALG=%d\n",wrq->value); 1401 PRINT_K("iwctl_siwauth:set AUTH_ALG=%d\n",wrq->value);
1402 if(wrq->value==IW_AUTH_ALG_OPEN_SYSTEM){ 1402 if(wrq->value==IW_AUTH_ALG_OPEN_SYSTEM){
1403 pMgmt->bShareKeyAlgorithm=FALSE; 1403 pMgmt->bShareKeyAlgorithm=FALSE;
1404 }else if(wrq->value==IW_AUTH_ALG_SHARED_KEY){ 1404 }else if(wrq->value==IW_AUTH_ALG_SHARED_KEY){
@@ -1420,14 +1420,14 @@ int iwctl_siwauth(struct net_device *dev, struct iw_request_info *info,
1420 pDevice->eEncryptionStatus = Ndis802_11EncryptionDisabled; 1420 pDevice->eEncryptionStatus = Ndis802_11EncryptionDisabled;
1421 pMgmt->bShareKeyAlgorithm = FALSE; 1421 pMgmt->bShareKeyAlgorithm = FALSE;
1422 pMgmt->eAuthenMode = WMAC_AUTH_OPEN; 1422 pMgmt->eAuthenMode = WMAC_AUTH_OPEN;
1423 PRINT_K("iwctl_siwauth:set WPADEV to disaable at 2?????\n"); 1423 PRINT_K("iwctl_siwauth:set WPADEV to disaable at 2?????\n");
1424 } 1424 }
1425 break; 1425 break;
1426 default: 1426 default:
1427 ret = -EOPNOTSUPP; 1427 ret = -EOPNOTSUPP;
1428 break; 1428 break;
1429 } 1429 }
1430 return ret; 1430 return ret;
1431} 1431}
1432 1432
1433int iwctl_giwauth(struct net_device *dev, struct iw_request_info *info, 1433int iwctl_giwauth(struct net_device *dev, struct iw_request_info *info,
@@ -1463,12 +1463,12 @@ int iwctl_siwgenie(struct net_device *dev, struct iw_request_info *info,
1463 pMgmt->wWPAIELen = 0; 1463 pMgmt->wWPAIELen = 0;
1464 } 1464 }
1465 1465
1466 out://not completely ...not necessary in wpa_supplicant 0.5.8 1466out://not completely ...not necessary in wpa_supplicant 0.5.8
1467 return ret; 1467 return ret;
1468} 1468}
1469 1469
1470int iwctl_giwgenie(struct net_device *dev, struct iw_request_info *info, 1470int iwctl_giwgenie(struct net_device *dev, struct iw_request_info *info,
1471 struct iw_point *wrq, char *extra) 1471 struct iw_point *wrq, char *extra)
1472{ 1472{
1473 PSDevice pDevice = (PSDevice)netdev_priv(dev); 1473 PSDevice pDevice = (PSDevice)netdev_priv(dev);
1474 PSMgmtObject pMgmt = &(pDevice->sMgmtObj); 1474 PSMgmtObject pMgmt = &(pDevice->sMgmtObj);
@@ -1489,132 +1489,132 @@ int iwctl_giwgenie(struct net_device *dev, struct iw_request_info *info,
1489} 1489}
1490 1490
1491int iwctl_siwencodeext(struct net_device *dev, struct iw_request_info *info, 1491int iwctl_siwencodeext(struct net_device *dev, struct iw_request_info *info,
1492 struct iw_point *wrq, char *extra) 1492 struct iw_point *wrq, char *extra)
1493{ 1493{
1494 PSDevice pDevice = (PSDevice)netdev_priv(dev); 1494 PSDevice pDevice = (PSDevice)netdev_priv(dev);
1495 PSMgmtObject pMgmt = &(pDevice->sMgmtObj); 1495 PSMgmtObject pMgmt = &(pDevice->sMgmtObj);
1496 struct iw_encode_ext *ext = (struct iw_encode_ext*)extra; 1496 struct iw_encode_ext *ext = (struct iw_encode_ext*)extra;
1497 struct viawget_wpa_param *param=NULL; 1497 struct viawget_wpa_param *param=NULL;
1498//original member 1498//original member
1499 wpa_alg alg_name; 1499 wpa_alg alg_name;
1500 u8 addr[6]; 1500 u8 addr[6];
1501 int key_idx, set_tx=0; 1501 int key_idx, set_tx=0;
1502 u8 seq[IW_ENCODE_SEQ_MAX_SIZE]; 1502 u8 seq[IW_ENCODE_SEQ_MAX_SIZE];
1503 u8 key[64]; 1503 u8 key[64];
1504 size_t seq_len=0,key_len=0; 1504 size_t seq_len=0,key_len=0;
1505 u8 *buf; 1505 u8 *buf;
1506 size_t blen; 1506 size_t blen;
1507 u8 key_array[64]; 1507 u8 key_array[64];
1508 int ret=0; 1508 int ret=0;
1509 1509
1510PRINT_K("SIOCSIWENCODEEXT...... \n"); 1510 PRINT_K("SIOCSIWENCODEEXT...... \n");
1511 1511
1512blen = sizeof(*param); 1512 blen = sizeof(*param);
1513buf = kmalloc((int)blen, (int)GFP_KERNEL); 1513 buf = kmalloc((int)blen, (int)GFP_KERNEL);
1514if (buf == NULL) 1514 if (buf == NULL)
1515 return -ENOMEM; 1515 return -ENOMEM;
1516memset(buf, 0, blen); 1516 memset(buf, 0, blen);
1517param = (struct viawget_wpa_param *) buf; 1517 param = (struct viawget_wpa_param *) buf;
1518 1518
1519//recover alg_name 1519//recover alg_name
1520switch (ext->alg) { 1520 switch (ext->alg) {
1521 case IW_ENCODE_ALG_NONE: 1521 case IW_ENCODE_ALG_NONE:
1522 alg_name = WPA_ALG_NONE; 1522 alg_name = WPA_ALG_NONE;
1523 break; 1523 break;
1524 case IW_ENCODE_ALG_WEP: 1524 case IW_ENCODE_ALG_WEP:
1525 alg_name = WPA_ALG_WEP; 1525 alg_name = WPA_ALG_WEP;
1526 break; 1526 break;
1527 case IW_ENCODE_ALG_TKIP: 1527 case IW_ENCODE_ALG_TKIP:
1528 alg_name = WPA_ALG_TKIP; 1528 alg_name = WPA_ALG_TKIP;
1529 break; 1529 break;
1530 case IW_ENCODE_ALG_CCMP: 1530 case IW_ENCODE_ALG_CCMP:
1531 alg_name = WPA_ALG_CCMP; 1531 alg_name = WPA_ALG_CCMP;
1532 break; 1532 break;
1533 default: 1533 default:
1534 PRINT_K("Unknown alg = %d\n",ext->alg); 1534 PRINT_K("Unknown alg = %d\n",ext->alg);
1535 ret= -ENOMEM; 1535 ret= -ENOMEM;
1536 goto error; 1536 goto error;
1537 } 1537 }
1538//recover addr 1538//recover addr
1539 memcpy(addr, ext->addr.sa_data, ETH_ALEN); 1539 memcpy(addr, ext->addr.sa_data, ETH_ALEN);
1540//recover key_idx 1540//recover key_idx
1541 key_idx = (wrq->flags&IW_ENCODE_INDEX) - 1; 1541 key_idx = (wrq->flags&IW_ENCODE_INDEX) - 1;
1542//recover set_tx 1542//recover set_tx
1543if(ext->ext_flags & IW_ENCODE_EXT_SET_TX_KEY) 1543 if(ext->ext_flags & IW_ENCODE_EXT_SET_TX_KEY)
1544 set_tx = 1; 1544 set_tx = 1;
1545//recover seq,seq_len 1545//recover seq,seq_len
1546 if(ext->ext_flags & IW_ENCODE_EXT_RX_SEQ_VALID) { 1546 if(ext->ext_flags & IW_ENCODE_EXT_RX_SEQ_VALID) {
1547 seq_len=IW_ENCODE_SEQ_MAX_SIZE; 1547 seq_len=IW_ENCODE_SEQ_MAX_SIZE;
1548 memcpy(seq, ext->rx_seq, seq_len); 1548 memcpy(seq, ext->rx_seq, seq_len);
1549 }
1550//recover key,key_len
1551if(ext->key_len) {
1552 key_len=ext->key_len;
1553 memcpy(key, &ext->key[0], key_len);
1554 } 1549 }
1555memset(key_array, 0, 64); 1550//recover key,key_len
1556if ( key_len > 0) { 1551 if(ext->key_len) {
1557 memcpy(key_array, key, key_len); 1552 key_len=ext->key_len;
1558 if (key_len == 32) { 1553 memcpy(key, &ext->key[0], key_len);
1559 // notice ! the oder
1560 memcpy(&key_array[16], &key[24], 8);
1561 memcpy(&key_array[24], &key[16], 8);
1562 } 1554 }
1555 memset(key_array, 0, 64);
1556 if ( key_len > 0) {
1557 memcpy(key_array, key, key_len);
1558 if (key_len == 32) {
1559 // notice ! the oder
1560 memcpy(&key_array[16], &key[24], 8);
1561 memcpy(&key_array[24], &key[16], 8);
1562 }
1563 } 1563 }
1564 1564
1565/**************Translate iw_encode_ext to viawget_wpa_param****************/ 1565/**************Translate iw_encode_ext to viawget_wpa_param****************/
1566memcpy(param->addr, addr, ETH_ALEN); 1566 memcpy(param->addr, addr, ETH_ALEN);
1567param->u.wpa_key.alg_name = (int)alg_name; 1567 param->u.wpa_key.alg_name = (int)alg_name;
1568param->u.wpa_key.set_tx = set_tx; 1568 param->u.wpa_key.set_tx = set_tx;
1569param->u.wpa_key.key_index = key_idx; 1569 param->u.wpa_key.key_index = key_idx;
1570param->u.wpa_key.key_len = key_len; 1570 param->u.wpa_key.key_len = key_len;
1571param->u.wpa_key.key = (u8 *)key_array; 1571 param->u.wpa_key.key = (u8 *)key_array;
1572param->u.wpa_key.seq = (u8 *)seq; 1572 param->u.wpa_key.seq = (u8 *)seq;
1573param->u.wpa_key.seq_len = seq_len; 1573 param->u.wpa_key.seq_len = seq_len;
1574 1574
1575//****set if current action is Network Manager count?? 1575//****set if current action is Network Manager count??
1576//****this method is so foolish,but there is no other way??? 1576//****this method is so foolish,but there is no other way???
1577if(param->u.wpa_key.alg_name == WPA_ALG_NONE) { 1577 if(param->u.wpa_key.alg_name == WPA_ALG_NONE) {
1578 if(param->u.wpa_key.key_index ==0) { 1578 if(param->u.wpa_key.key_index ==0) {
1579 pDevice->bwextstep0 = TRUE; 1579 pDevice->bwextstep0 = TRUE;
1580 } 1580 }
1581 if ((pDevice->bwextstep0 == TRUE) && (param->u.wpa_key.key_index == 1)) { 1581 if ((pDevice->bwextstep0 == TRUE) && (param->u.wpa_key.key_index == 1)) {
1582 pDevice->bwextstep0 = FALSE; 1582 pDevice->bwextstep0 = FALSE;
1583 pDevice->bwextstep1 = TRUE; 1583 pDevice->bwextstep1 = TRUE;
1584 } 1584 }
1585 if ((pDevice->bwextstep1 == TRUE) && (param->u.wpa_key.key_index == 2)) { 1585 if ((pDevice->bwextstep1 == TRUE) && (param->u.wpa_key.key_index == 2)) {
1586 pDevice->bwextstep1 = FALSE; 1586 pDevice->bwextstep1 = FALSE;
1587 pDevice->bwextstep2 = TRUE; 1587 pDevice->bwextstep2 = TRUE;
1588 }
1589 if ((pDevice->bwextstep2 == TRUE)&&(param->u.wpa_key.key_index == 3)) {
1590 pDevice->bwextstep2 = FALSE;
1591 pDevice->bwextstep3 = TRUE;
1592 }
1593 }
1594 if(pDevice->bwextstep3 == TRUE) {
1595 PRINT_K("SIOCSIWENCODEEXT:Enable WPA WEXT SUPPORT!!!!!\n");
1596 pDevice->bwextstep0 = FALSE;
1597 pDevice->bwextstep1 = FALSE;
1598 pDevice->bwextstep2 = FALSE;
1599 pDevice->bwextstep3 = FALSE;
1600 pDevice->bWPASuppWextEnabled = TRUE;
1601 memset(pMgmt->abyDesireBSSID, 0xFF,6);
1602 KeyvInitTable(pDevice,&pDevice->sKey);
1588 } 1603 }
1589 if ((pDevice->bwextstep2 == TRUE)&&(param->u.wpa_key.key_index == 3)) {
1590 pDevice->bwextstep2 = FALSE;
1591 pDevice->bwextstep3 = TRUE;
1592 }
1593 }
1594if(pDevice->bwextstep3 == TRUE) {
1595 PRINT_K("SIOCSIWENCODEEXT:Enable WPA WEXT SUPPORT!!!!!\n");
1596 pDevice->bwextstep0 = FALSE;
1597 pDevice->bwextstep1 = FALSE;
1598 pDevice->bwextstep2 = FALSE;
1599 pDevice->bwextstep3 = FALSE;
1600 pDevice->bWPASuppWextEnabled = TRUE;
1601 memset(pMgmt->abyDesireBSSID, 0xFF,6);
1602 KeyvInitTable(pDevice,&pDevice->sKey);
1603 }
1604//****** 1604//******
1605 spin_lock_irq(&pDevice->lock); 1605 spin_lock_irq(&pDevice->lock);
1606 ret = wpa_set_keys(pDevice, param, TRUE); 1606 ret = wpa_set_keys(pDevice, param, TRUE);
1607 spin_unlock_irq(&pDevice->lock); 1607 spin_unlock_irq(&pDevice->lock);
1608 1608
1609error: 1609error:
1610kfree(param); 1610 kfree(param);
1611 return ret; 1611 return ret;
1612} 1612}
1613 1613
1614int iwctl_giwencodeext(struct net_device *dev, struct iw_request_info *info, 1614int iwctl_giwencodeext(struct net_device *dev, struct iw_request_info *info,
1615 struct iw_point *wrq, char *extra) 1615 struct iw_point *wrq, char *extra)
1616{ 1616{
1617 return -EOPNOTSUPP; 1617 return -EOPNOTSUPP;
1618} 1618}
1619 1619
1620int iwctl_siwmlme(struct net_device *dev, struct iw_request_info *info, 1620int iwctl_siwmlme(struct net_device *dev, struct iw_request_info *info,
@@ -1633,10 +1633,10 @@ int iwctl_siwmlme(struct net_device *dev, struct iw_request_info *info,
1633 case IW_MLME_DEAUTH: 1633 case IW_MLME_DEAUTH:
1634 case IW_MLME_DISASSOC: 1634 case IW_MLME_DISASSOC:
1635 if(pDevice->bLinkPass == TRUE){ 1635 if(pDevice->bLinkPass == TRUE){
1636 PRINT_K("iwctl_siwmlme--->send DISASSOCIATE\n"); 1636 PRINT_K("iwctl_siwmlme--->send DISASSOCIATE\n");
1637 bScheduleCommand((void *) pDevice, 1637 bScheduleCommand((void *) pDevice,
1638 WLAN_CMD_DISASSOCIATE, 1638 WLAN_CMD_DISASSOCIATE,
1639 NULL); 1639 NULL);
1640 } 1640 }
1641 break; 1641 break;
1642 default: 1642 default:
@@ -1665,7 +1665,7 @@ static const iw_handler iwctl_handler[] =
1665 (iw_handler) NULL, // SIOCGIWPRIV 1665 (iw_handler) NULL, // SIOCGIWPRIV
1666 (iw_handler) NULL, // SIOCSIWSTATS 1666 (iw_handler) NULL, // SIOCSIWSTATS
1667 (iw_handler) NULL, // SIOCGIWSTATS 1667 (iw_handler) NULL, // SIOCGIWSTATS
1668 (iw_handler) NULL, // SIOCSIWSPY 1668 (iw_handler) NULL, // SIOCSIWSPY
1669 (iw_handler) NULL, // SIOCGIWSPY 1669 (iw_handler) NULL, // SIOCGIWSPY
1670 (iw_handler) NULL, // -- hole -- 1670 (iw_handler) NULL, // -- hole --
1671 (iw_handler) NULL, // -- hole -- 1671 (iw_handler) NULL, // -- hole --
@@ -1713,9 +1713,9 @@ static const iw_handler iwctl_private_handler[] =
1713}; 1713};
1714 1714
1715struct iw_priv_args iwctl_private_args[] = { 1715struct iw_priv_args iwctl_private_args[] = {
1716{ IOCTL_CMD_SET, 1716 { IOCTL_CMD_SET,
1717 IW_PRIV_TYPE_CHAR | 1024, 0, 1717 IW_PRIV_TYPE_CHAR | 1024, 0,
1718 "set"}, 1718 "set"},
1719}; 1719};
1720 1720
1721const struct iw_handler_def iwctl_handler_def = 1721const struct iw_handler_def iwctl_handler_def =