aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/staging/otus/ioctl.c
diff options
context:
space:
mode:
authorDragoslav Zaric <dragoslav.zaric.kd@gmail.com>2009-03-16 18:17:47 -0400
committerGreg Kroah-Hartman <gregkh@suse.de>2009-04-03 17:53:29 -0400
commitaef911a57d407eb8cf3e1101958b600d36ace3ec (patch)
tree019e8e24b419d2c3c1de0add3f8ddd4fe46e3335 /drivers/staging/otus/ioctl.c
parent0009e125b629b83a540273ecf35ce18c5334e4fc (diff)
Staging: otus: ioctl.c: Fix Coding Style
I run make on ioctl.c file and I got two warnings: drivers/staging/otus/ioctl.c: In function ¡usbdrv_wpa_ioctl¢: drivers/staging/otus/ioctl.c:2269: warning: ISO C90 forbids mixed declarations and code drivers/staging/otus/ioctl.c: In function ¡usbdrv_ioctl¢: drivers/staging/otus/ioctl.c:2448: warning: ISO C90 forbids mixed declarations and code From: Dragoslav Zaric <dragoslav.zaric.kd@gmail.com> Signed-off-by: Greg Kroah-Hartman <gregkh@suse.de>
Diffstat (limited to 'drivers/staging/otus/ioctl.c')
-rw-r--r--drivers/staging/otus/ioctl.c4789
1 files changed, 2325 insertions, 2464 deletions
diff --git a/drivers/staging/otus/ioctl.c b/drivers/staging/otus/ioctl.c
index 7a5c1e876b0..ce04218253d 100644
--- a/drivers/staging/otus/ioctl.c
+++ b/drivers/staging/otus/ioctl.c
@@ -25,7 +25,7 @@
25/************************************************************************/ 25/************************************************************************/
26#include <linux/module.h> 26#include <linux/module.h>
27#include <linux/if_arp.h> 27#include <linux/if_arp.h>
28#include <asm/uaccess.h> 28#include <linux/uaccess.h>
29 29
30#include "usbdrv.h" 30#include "usbdrv.h"
31 31
@@ -34,7 +34,7 @@
34#define ZD_IOCTL_GETWPAIE (SIOCDEVPRIVATE + 3) 34#define ZD_IOCTL_GETWPAIE (SIOCDEVPRIVATE + 3)
35#ifdef ZM_ENABLE_CENC 35#ifdef ZM_ENABLE_CENC
36#define ZM_IOCTL_CENC (SIOCDEVPRIVATE + 4) 36#define ZM_IOCTL_CENC (SIOCDEVPRIVATE + 4)
37#endif //ZM_ENABLE_CENC 37#endif /* ZM_ENABLE_CENC */
38#define ZD_PARAM_ROAMING 0x0001 38#define ZD_PARAM_ROAMING 0x0001
39#define ZD_PARAM_PRIVACY 0x0002 39#define ZD_PARAM_PRIVACY 0x0002
40#define ZD_PARAM_WPA 0x0003 40#define ZD_PARAM_WPA 0x0003
@@ -45,7 +45,7 @@
45 45
46#ifdef ZM_ENABLE_CENC 46#ifdef ZM_ENABLE_CENC
47#define P80211_PACKET_CENCFLAG 0x0001 47#define P80211_PACKET_CENCFLAG 0x0001
48#endif //ZM_ENABLE_CENC 48#endif /* ZM_ENABLE_CENC */
49#define P80211_PACKET_SETKEY 0x0003 49#define P80211_PACKET_SETKEY 0x0003
50 50
51#define ZD_CMD_SET_ENCRYPT_KEY 0x0001 51#define ZD_CMD_SET_ENCRYPT_KEY 0x0001
@@ -62,204 +62,190 @@
62#include <net/iw_handler.h> 62#include <net/iw_handler.h>
63#endif 63#endif
64 64
65extern u16_t zfLnxGetVapId(zdev_t* dev); 65extern u16_t zfLnxGetVapId(zdev_t *dev);
66 66
67static const u32_t channel_frequency_11A[] = 67static const u32_t channel_frequency_11A[] =
68{ 68{
69//Even element for Channel Number, Odd for Frequency 69 /* Even element for Channel Number, Odd for Frequency */
70 36,5180, 70 36, 5180,
71 40,5200, 71 40, 5200,
72 44,5220, 72 44, 5220,
73 48,5240, 73 48, 5240,
74 52,5260, 74 52, 5260,
75 56,5280, 75 56, 5280,
76 60,5300, 76 60, 5300,
77 64,5320, 77 64, 5320,
78 100,5500, 78 100, 5500,
79 104,5520, 79 104, 5520,
80 108,5540, 80 108, 5540,
81 112,5560, 81 112, 5560,
82 116,5580, 82 116, 5580,
83 120,5600, 83 120, 5600,
84 124,5620, 84 124, 5620,
85 128,5640, 85 128, 5640,
86 132,5660, 86 132, 5660,
87 136,5680, 87 136, 5680,
88 140,5700, 88 140, 5700,
89// 89 /**/
90 184,4920, 90 184, 4920,
91 188,4940, 91 188, 4940,
92 192,4960, 92 192, 4960,
93 196,4980, 93 196, 4980,
94 8,5040, 94 8, 5040,
95 12,5060, 95 12, 5060,
96 16,5080, 96 16, 5080,
97 34,5170, 97 34, 5170,
98 38,5190, 98 38, 5190,
99 42,5210, 99 42, 5210,
100 46,5230, 100 46, 5230,
101// 101 /**/
102 149,5745, 102 149, 5745,
103 153,5765, 103 153, 5765,
104 157,5785, 104 157, 5785,
105 161,5805, 105 161, 5805,
106 165,5825 106 165, 5825
107// 107 /**/
108}; 108};
109 109
110int usbdrv_freq2chan(u32_t freq) 110int usbdrv_freq2chan(u32_t freq)
111{ 111{
112 /* 2.4G Hz */ 112 /* 2.4G Hz */
113 if (freq > 2400 && freq < 3000) 113 if (freq > 2400 && freq < 3000) {
114 { 114 return ((freq-2412)/5) + 1;
115 return ((freq-2412)/5) + 1; 115 } else {
116 } 116 u16_t ii;
117 else 117 u16_t num_chan = sizeof(channel_frequency_11A)/sizeof(u32_t);
118 { 118
119 u16_t ii; 119 for (ii = 1; ii < num_chan; ii += 2) {
120 u16_t num_chan = sizeof(channel_frequency_11A)/sizeof(u32_t); 120 if (channel_frequency_11A[ii] == freq)
121 121 return channel_frequency_11A[ii-1];
122 for(ii = 1; ii < num_chan; ii += 2) 122 }
123 { 123 }
124 if (channel_frequency_11A[ii] == freq) 124
125 return channel_frequency_11A[ii-1]; 125 return 0;
126 }
127 }
128
129 return 0;
130} 126}
131 127
132int usbdrv_chan2freq(int chan) 128int usbdrv_chan2freq(int chan)
133{ 129{
134 int freq; 130 int freq;
135 131
136 /* If channel number is out of range */ 132 /* If channel number is out of range */
137 if (chan > 165 || chan <= 0) 133 if (chan > 165 || chan <= 0)
138 return -1; 134 return -1;
139 135
140 /* 2.4G band */ 136 /* 2.4G band */
141 if (chan >= 1 && chan <= 13) 137 if (chan >= 1 && chan <= 13) {
142 { 138 freq = (2412 + (chan - 1) * 5);
143 freq = (2412 + (chan - 1) * 5); 139 return freq;
144 return freq; 140 } else if (chan >= 36 && chan <= 165) {
145 } 141 u16_t ii;
146 else if (chan >= 36 && chan <= 165) 142 u16_t num_chan = sizeof(channel_frequency_11A)/sizeof(u32_t);
147 { 143
148 u16_t ii; 144 for (ii = 0; ii < num_chan; ii += 2) {
149 u16_t num_chan = sizeof(channel_frequency_11A)/sizeof(u32_t); 145 if (channel_frequency_11A[ii] == chan)
150 146 return channel_frequency_11A[ii+1];
151 for(ii = 0; ii < num_chan; ii += 2) 147 }
152 { 148
153 if (channel_frequency_11A[ii] == chan) 149 /* Can't find desired frequency */
154 return channel_frequency_11A[ii+1]; 150 if (ii == num_chan)
155 } 151 return -1;
156 152 }
157 /* Can't find desired frequency */ 153
158 if (ii == num_chan) 154 /* Can't find deisred frequency */
159 return -1; 155 return -1;
160 }
161
162 /* Can't find deisred frequency */
163 return -1;
164} 156}
165 157
166int usbdrv_ioctl_setessid(struct net_device *dev, struct iw_point *erq) 158int usbdrv_ioctl_setessid(struct net_device *dev, struct iw_point *erq)
167{ 159{
168#ifdef ZM_HOSTAPD_SUPPORT 160 #ifdef ZM_HOSTAPD_SUPPORT
169 //struct usbdrv_private *macp = dev->ml_priv; 161 /* struct usbdrv_private *macp = dev->ml_priv; */
170 char essidbuf[IW_ESSID_MAX_SIZE+1]; 162 char essidbuf[IW_ESSID_MAX_SIZE+1];
171 int i; 163 int i;
172 164
173 if(!netif_running(dev)) 165 if (!netif_running(dev))
174 return -EINVAL; 166 return -EINVAL;
175 167
176 memset(essidbuf, 0, sizeof(essidbuf)); 168 memset(essidbuf, 0, sizeof(essidbuf));
177 169
178 printk(KERN_ERR "usbdrv_ioctl_setessid\n"); 170 printk(KERN_ERR "usbdrv_ioctl_setessid\n");
179 171
180 //printk("ssidlen=%d\n", erq->length); //for any, it is 1. 172 /* printk("ssidlen=%d\n", erq->length); //for any, it is 1. */
181 if (erq->flags) { 173 if (erq->flags) {
182 if (erq->length > (IW_ESSID_MAX_SIZE+1)) 174 if (erq->length > (IW_ESSID_MAX_SIZE+1))
183 return -E2BIG; 175 return -E2BIG;
184 176
185 if (copy_from_user(essidbuf, erq->pointer, erq->length)) 177 if (copy_from_user(essidbuf, erq->pointer, erq->length))
186 return -EFAULT; 178 return -EFAULT;
187 } 179 }
188 180
189 //zd_DisasocAll(2); 181 /* zd_DisasocAll(2); */
190 //wait_ms(100); 182 /* wait_ms(100); */
191 183
192 printk(KERN_ERR "essidbuf: "); 184 printk(KERN_ERR "essidbuf: ");
193 185
194 for(i = 0; i < erq->length; i++) 186 for (i = 0; i < erq->length; i++)
195 { 187 printk(KERN_ERR "%02x ", essidbuf[i]);
196 printk(KERN_ERR "%02x ", essidbuf[i]);
197 }
198 188
199 printk(KERN_ERR "\n"); 189 printk(KERN_ERR "\n");
200 190
201 essidbuf[erq->length] = '\0'; 191 essidbuf[erq->length] = '\0';
202 //memcpy(macp->wd.ws.ssid, essidbuf, erq->length); 192 /* memcpy(macp->wd.ws.ssid, essidbuf, erq->length); */
203 //macp->wd.ws.ssidLen = strlen(essidbuf)+2; 193 /* macp->wd.ws.ssidLen = strlen(essidbuf)+2; */
204 //macp->wd.ws.ssid[1] = strlen(essidbuf); // Update ssid length 194 /* macp->wd.ws.ssid[1] = strlen(essidbuf); Update ssid length */
205 195
206 zfiWlanSetSSID(dev, essidbuf, erq->length); 196 zfiWlanSetSSID(dev, essidbuf, erq->length);
207#if 0 197 #if 0
208 printk(KERN_ERR "macp->wd.ws.ssid: "); 198 printk(KERN_ERR "macp->wd.ws.ssid: ");
209 199
210 for(i = 0; i < macp->wd.ws.ssidLen; i++) 200 for (i = 0; i < macp->wd.ws.ssidLen; i++)
211 { 201 printk(KERN_ERR "%02x ", macp->wd.ws.ssid[i]);
212 printk(KERN_ERR "%02x ", macp->wd.ws.ssid[i]);
213 }
214 202
215 printk(KERN_ERR "\n"); 203 printk(KERN_ERR "\n");
216#endif 204 #endif
217 zfiWlanDisable(dev, 0);
218 zfiWlanEnable(dev);
219 205
220#endif 206 zfiWlanDisable(dev, 0);
207 zfiWlanEnable(dev);
221 208
222 return 0; 209 #endif
210
211 return 0;
223} 212}
224 213
225int usbdrv_ioctl_getessid(struct net_device *dev, struct iw_point *erq) 214int usbdrv_ioctl_getessid(struct net_device *dev, struct iw_point *erq)
226{ 215{
227 //struct usbdrv_private *macp = dev->ml_priv; 216 /* struct usbdrv_private *macp = dev->ml_priv; */
228 u8_t essidbuf[IW_ESSID_MAX_SIZE+1]; 217 u8_t essidbuf[IW_ESSID_MAX_SIZE+1];
229 u8_t len; 218 u8_t len;
230 u8_t i; 219 u8_t i;
231 220
232 221
233 //len = macp->wd.ws.ssidLen; 222 /* len = macp->wd.ws.ssidLen; */
234 //memcpy(essidbuf, macp->wd.ws.ssid, macp->wd.ws.ssidLen); 223 /* memcpy(essidbuf, macp->wd.ws.ssid, macp->wd.ws.ssidLen); */
235 zfiWlanQuerySSID(dev, essidbuf, &len); 224 zfiWlanQuerySSID(dev, essidbuf, &len);
236 225
237 essidbuf[len] = 0; 226 essidbuf[len] = 0;
238 227
239 printk(KERN_ERR "ESSID: "); 228 printk(KERN_ERR "ESSID: ");
240 229
241 for(i = 0; i < len; i++) 230 for (i = 0; i < len; i++)
242 { 231 printk(KERN_ERR "%c", essidbuf[i]);
243 printk(KERN_ERR "%c", essidbuf[i]);
244 }
245 232
246 printk(KERN_ERR "\n"); 233 printk(KERN_ERR "\n");
247 234
248 erq->flags= 1; 235 erq->flags = 1;
249 erq->length = strlen(essidbuf) + 1; 236 erq->length = strlen(essidbuf) + 1;
250 237
251 if (erq->pointer) 238 if (erq->pointer) {
252 if (copy_to_user(erq->pointer, essidbuf, erq->length)) 239 if (copy_to_user(erq->pointer, essidbuf, erq->length))
253 return -EFAULT; 240 return -EFAULT;
241 }
254 242
255 return 0; 243 return 0;
256} 244}
257 245
258
259int usbdrv_ioctl_setrts(struct net_device *dev, struct iw_param *rrq) 246int usbdrv_ioctl_setrts(struct net_device *dev, struct iw_param *rrq)
260{ 247{
261 248 return 0;
262 return 0;
263} 249}
264 250
265#if WIRELESS_EXT > 14 251#if WIRELESS_EXT > 14
@@ -267,462 +253,418 @@ int usbdrv_ioctl_setrts(struct net_device *dev, struct iw_param *rrq)
267 * Encode a WPA or RSN information element as a custom 253 * Encode a WPA or RSN information element as a custom
268 * element using the hostap format. 254 * element using the hostap format.
269 */ 255 */
270u32 encode_ie(void *buf, u32 bufsize, const u8 *ie, u32 ielen, const u8 *leader, u32 leader_len) 256u32 encode_ie(void *buf, u32 bufsize, const u8 *ie, u32 ielen,
257 const u8 *leader, u32 leader_len)
271{ 258{
272 u8 *p; 259 u8 *p;
273 u32 i; 260 u32 i;
274 261
275 if (bufsize < leader_len) 262 if (bufsize < leader_len)
276 return 0; 263 return 0;
277 p = buf; 264 p = buf;
278 memcpy(p, leader, leader_len); 265 memcpy(p, leader, leader_len);
279 bufsize -= leader_len; 266 bufsize -= leader_len;
280 p += leader_len; 267 p += leader_len;
281 for (i = 0; i < ielen && bufsize > 2; i++) 268 for (i = 0; i < ielen && bufsize > 2; i++)
282 p += sprintf(p, "%02x", ie[i]); 269 p += sprintf(p, "%02x", ie[i]);
283 return (i == ielen ? p - (u8 *)buf : 0); 270 return (i == ielen ? p - (u8 *)buf:0);
284} 271}
285#endif /* WIRELESS_EXT > 14 */ 272#endif /* WIRELESS_EXT > 14 */
286 273
287/*------------------------------------------------------------------*/
288/* 274/*
289 * Translate scan data returned from the card to a card independent 275 * Translate scan data returned from the card to a card independent
290 * format that the Wireless Tools will understand 276 * format that the Wireless Tools will understand
291 */ 277 */
292char *usbdrv_translate_scan(struct net_device *dev, 278char *usbdrv_translate_scan(struct net_device *dev,
293 struct iw_request_info *info, char *current_ev, 279 struct iw_request_info *info, char *current_ev,
294 char *end_buf, struct zsBssInfo *list) 280 char *end_buf, struct zsBssInfo *list)
295{ 281{
296 struct iw_event iwe; /* Temporary buffer */ 282 struct iw_event iwe; /* Temporary buffer */
297 u16_t capabilities; 283 u16_t capabilities;
298 char *current_val; /* For rates */ 284 char *current_val; /* For rates */
299 char *last_ev; 285 char *last_ev;
300 int i; 286 int i;
301#if WIRELESS_EXT > 14 287 #if WIRELESS_EXT > 14
302 char buf[64*2 + 30]; 288 char buf[64*2 + 30];
303#endif 289 #endif
290
291 last_ev = current_ev;
292
293 /* First entry *MUST* be the AP MAC address */
294 iwe.cmd = SIOCGIWAP;
295 iwe.u.ap_addr.sa_family = ARPHRD_ETHER;
296 memcpy(iwe.u.ap_addr.sa_data, list->bssid, ETH_ALEN);
297 current_ev = iwe_stream_add_event(info, current_ev,
298 end_buf, &iwe, IW_EV_ADDR_LEN);
299
300 /* Ran out of buffer */
301 if (last_ev == current_ev)
302 return end_buf;
303
304 last_ev = current_ev;
305
306 /* Other entries will be displayed in the order we give them */
307
308 /* Add the ESSID */
309 iwe.u.data.length = list->ssid[1];
310 if (iwe.u.data.length > 32)
311 iwe.u.data.length = 32;
312 iwe.cmd = SIOCGIWESSID;
313 iwe.u.data.flags = 1;
314 current_ev = iwe_stream_add_point(info, current_ev,
315 end_buf, &iwe, &list->ssid[2]);
316
317 /* Ran out of buffer */
318 if (last_ev == current_ev)
319 return end_buf;
320
321 last_ev = current_ev;
322
323 /* Add mode */
324 iwe.cmd = SIOCGIWMODE;
325 capabilities = (list->capability[1] << 8) + list->capability[0];
326 if (capabilities & (0x01 | 0x02)) {
327 if (capabilities & 0x01)
328 iwe.u.mode = IW_MODE_MASTER;
329 else
330 iwe.u.mode = IW_MODE_ADHOC;
331 current_ev = iwe_stream_add_event(info, current_ev,
332 end_buf, &iwe, IW_EV_UINT_LEN);
333 }
304 334
305 last_ev = current_ev; 335 /* Ran out of buffer */
306 336 if (last_ev == current_ev)
307/* First entry *MUST* be the AP MAC address */ 337 return end_buf;
308 iwe.cmd = SIOCGIWAP; 338
309 iwe.u.ap_addr.sa_family = ARPHRD_ETHER; 339 last_ev = current_ev;
310 memcpy(iwe.u.ap_addr.sa_data, list->bssid, ETH_ALEN); 340
311 current_ev = iwe_stream_add_event( 341 /* Add frequency */
312 info, 342 iwe.cmd = SIOCGIWFREQ;
313 current_ev, 343 iwe.u.freq.m = list->channel;
314 end_buf, &iwe, IW_EV_ADDR_LEN); 344 /* Channel frequency in KHz */
315 345 if (iwe.u.freq.m > 14) {
316 /* Ran out of buffer */ 346 if ((184 <= iwe.u.freq.m) && (iwe.u.freq.m <= 196))
317 if (last_ev == current_ev) 347 iwe.u.freq.m = 4000 + iwe.u.freq.m * 5;
318 { 348 else
319 return end_buf; 349 iwe.u.freq.m = 5000 + iwe.u.freq.m * 5;
320 } 350 } else {
321 351 if (iwe.u.freq.m == 14)
322 last_ev = current_ev; 352 iwe.u.freq.m = 2484;
323 353 else
324/* Other entries will be displayed in the order we give them */ 354 iwe.u.freq.m = 2412 + (iwe.u.freq.m - 1) * 5;
325 355 }
326/* Add the ESSID */ 356 iwe.u.freq.e = 6;
327 iwe.u.data.length = list->ssid[1]; 357 current_ev = iwe_stream_add_event(info, current_ev,
328 if(iwe.u.data.length > 32) 358 end_buf, &iwe, IW_EV_FREQ_LEN);
329 iwe.u.data.length = 32; 359
330 iwe.cmd = SIOCGIWESSID; 360 /* Ran out of buffer */
331 iwe.u.data.flags = 1; 361 if (last_ev == current_ev)
332 current_ev = iwe_stream_add_point( 362 return end_buf;
333 info, 363
334 current_ev, end_buf, &iwe, &list->ssid[2]); 364 last_ev = current_ev;
335 365
336 /* Ran out of buffer */ 366 /* Add quality statistics */
337 if (last_ev == current_ev) 367 iwe.cmd = IWEVQUAL;
338 { 368 #if WIRELESS_EXT > 18
339 return end_buf; 369 iwe.u.qual.updated = IW_QUAL_QUAL_UPDATED | IW_QUAL_LEVEL_UPDATED
340 } 370 | IW_QUAL_NOISE_UPDATED;
341 371 #endif
342 last_ev = current_ev; 372 iwe.u.qual.level = list->signalStrength;
343 373 iwe.u.qual.noise = 0;
344/* Add mode */ 374 iwe.u.qual.qual = list->signalQuality;
345 iwe.cmd = SIOCGIWMODE; 375 current_ev = iwe_stream_add_event(info, current_ev,
346 capabilities = (list->capability[1] << 8) + list->capability[0]; 376 end_buf, &iwe, IW_EV_QUAL_LEN);
347 if(capabilities & (0x01 | 0x02)) 377
348 { 378 /* Ran out of buffer */
349 if(capabilities & 0x01) 379 if (last_ev == current_ev)
350 iwe.u.mode = IW_MODE_MASTER; 380 return end_buf;
351 else 381
352 iwe.u.mode = IW_MODE_ADHOC; 382 last_ev = current_ev;
353 current_ev = iwe_stream_add_event( 383
354 info, 384 /* Add encryption capability */
355 current_ev, end_buf, &iwe, IW_EV_UINT_LEN); 385
356 } 386 iwe.cmd = SIOCGIWENCODE;
357 387 if (capabilities & 0x10)
358 /* Ran out of buffer */ 388 iwe.u.data.flags = IW_ENCODE_ENABLED | IW_ENCODE_NOKEY;
359 if (last_ev == current_ev) 389 else
360 { 390 iwe.u.data.flags = IW_ENCODE_DISABLED;
361 return end_buf; 391
362 } 392 iwe.u.data.length = 0;
363 393 current_ev = iwe_stream_add_point(info, current_ev,
364 last_ev = current_ev; 394 end_buf, &iwe, list->ssid);
365 395
366/* Add frequency */ 396 /* Ran out of buffer */
367 iwe.cmd = SIOCGIWFREQ; 397 if (last_ev == current_ev)
368 iwe.u.freq.m = list->channel; 398 return end_buf;
369/* Channel frequency in KHz */ 399
370 if (iwe.u.freq.m > 14) 400 last_ev = current_ev;
371 { 401
372 if ((184 <= iwe.u.freq.m) && (iwe.u.freq.m<=196)) 402 /* Rate : stuffing multiple values in a single event require a bit
373 iwe.u.freq.m = 4000 + iwe.u.freq.m * 5; 403 * more of magic
374 else 404 */
375 iwe.u.freq.m = 5000 + iwe.u.freq.m * 5; 405 current_val = current_ev + IW_EV_LCP_LEN;
376 } 406
377 else 407 iwe.cmd = SIOCGIWRATE;
378 { 408 /* Those two flags are ignored... */
379 if (iwe.u.freq.m == 14) 409 iwe.u.bitrate.fixed = iwe.u.bitrate.disabled = 0;
380 iwe.u.freq.m = 2484; 410
381 else 411 for (i = 0 ; i < list->supportedRates[1] ; i++) {
382 iwe.u.freq.m = 2412 + (iwe.u.freq.m - 1) * 5; 412 /* Bit rate given in 500 kb/s units (+ 0x80) */
383 } 413 iwe.u.bitrate.value = ((list->supportedRates[i+2] & 0x7f)
384 iwe.u.freq.e = 6; 414 * 500000);
385 current_ev = iwe_stream_add_event( 415 /* Add new value to event */
386 info, 416 current_val = iwe_stream_add_value(info, current_ev,
387 current_ev, end_buf, &iwe, IW_EV_FREQ_LEN); 417 current_val, end_buf, &iwe, IW_EV_PARAM_LEN);
388 418
389 /* Ran out of buffer */ 419 /* Ran out of buffer */
390 if (last_ev == current_ev) 420 if (last_ev == current_val)
391 { 421 return end_buf;
392 return end_buf; 422
393 } 423 last_ev = current_val;
394 424 }
395 last_ev = current_ev; 425
396 426 for (i = 0 ; i < list->extSupportedRates[1] ; i++) {
397/* Add quality statistics */ 427 /* Bit rate given in 500 kb/s units (+ 0x80) */
398 iwe.cmd = IWEVQUAL; 428 iwe.u.bitrate.value = ((list->extSupportedRates[i+2] & 0x7f)
399#if WIRELESS_EXT > 18 429 * 500000);
400 iwe.u.qual.updated = IW_QUAL_QUAL_UPDATED | IW_QUAL_LEVEL_UPDATED 430 /* Add new value to event */
401 |IW_QUAL_NOISE_UPDATED; 431 current_val = iwe_stream_add_value(info, current_ev,
402#endif 432 current_val, end_buf, &iwe, IW_EV_PARAM_LEN);
403 iwe.u.qual.level = list->signalStrength; 433
404 iwe.u.qual.noise = 0; 434 /* Ran out of buffer */
405 iwe.u.qual.qual = list->signalQuality; 435 if (last_ev == current_val)
406 current_ev = iwe_stream_add_event( 436 return end_buf;
407 info, 437
408 current_ev, end_buf, &iwe, IW_EV_QUAL_LEN); 438 last_ev = current_ev;
409 439 }
410 /* Ran out of buffer */ 440
411 if (last_ev == current_ev) 441 /* Check if we added any event */
412 { 442 if ((current_val - current_ev) > IW_EV_LCP_LEN)
413 return end_buf; 443 current_ev = current_val;
414 } 444 #if WIRELESS_EXT > 14
415 445 #define IEEE80211_ELEMID_RSN 0x30
416 last_ev = current_ev; 446 memset(&iwe, 0, sizeof(iwe));
417 447 iwe.cmd = IWEVCUSTOM;
418/* Add encryption capability */ 448 snprintf(buf, sizeof(buf), "bcn_int=%d", (list->beaconInterval[1] << 8)
419 449 + list->beaconInterval[0]);
420 iwe.cmd = SIOCGIWENCODE; 450 iwe.u.data.length = strlen(buf);
421 if(capabilities & 0x10) 451 current_ev = iwe_stream_add_point(info, current_ev,
422 iwe.u.data.flags = IW_ENCODE_ENABLED | IW_ENCODE_NOKEY; 452 end_buf, &iwe, buf);
423 else 453
424 iwe.u.data.flags = IW_ENCODE_DISABLED; 454 /* Ran out of buffer */
425 455 if (last_ev == current_ev)
426 iwe.u.data.length = 0; 456 return end_buf;
427 current_ev = iwe_stream_add_point( 457
428 info, 458 last_ev = current_ev;
429 current_ev, end_buf, &iwe, list->ssid); 459
430 460 if (list->wpaIe[1] != 0) {
431 /* Ran out of buffer */ 461 static const char rsn_leader[] = "rsn_ie=";
432 if (last_ev == current_ev) 462 static const char wpa_leader[] = "wpa_ie=";
433 { 463
434 return end_buf; 464 memset(&iwe, 0, sizeof(iwe));
435 } 465 iwe.cmd = IWEVCUSTOM;
436 466 if (list->wpaIe[0] == IEEE80211_ELEMID_RSN)
437 last_ev = current_ev; 467 iwe.u.data.length = encode_ie(buf, sizeof(buf),
438 468 list->wpaIe, list->wpaIe[1]+2,
439/* Rate : stuffing multiple values in a single event require a bit 469 rsn_leader, sizeof(rsn_leader)-1);
440 * more of magic */ 470 else
441 current_val = current_ev + IW_EV_LCP_LEN; 471 iwe.u.data.length = encode_ie(buf, sizeof(buf),
442 472 list->wpaIe, list->wpaIe[1]+2,
443 iwe.cmd = SIOCGIWRATE; 473 wpa_leader, sizeof(wpa_leader)-1);
444/* Those two flags are ignored... */ 474
445 iwe.u.bitrate.fixed = iwe.u.bitrate.disabled = 0; 475 if (iwe.u.data.length != 0)
446 476 current_ev = iwe_stream_add_point(info, current_ev,
447 for(i = 0 ; i < list->supportedRates[1] ; i++) 477 end_buf, &iwe, buf);
448 { 478
449/* Bit rate given in 500 kb/s units (+ 0x80) */ 479 /* Ran out of buffer */
450 iwe.u.bitrate.value = ((list->supportedRates[i+2] & 0x7f) * 500000); 480 if (last_ev == current_ev)
451/* Add new value to event */ 481 return end_buf;
452 current_val = iwe_stream_add_value( 482
453 info, 483 last_ev = current_ev;
454 current_ev, current_val, end_buf, &iwe, IW_EV_PARAM_LEN); 484 }
455 485
456 /* Ran out of buffer */ 486 if (list->rsnIe[1] != 0) {
457 if (last_ev == current_val) 487 static const char rsn_leader[] = "rsn_ie=";
458 { 488 memset(&iwe, 0, sizeof(iwe));
459 return end_buf; 489 iwe.cmd = IWEVCUSTOM;
460 } 490
461 491 if (list->rsnIe[0] == IEEE80211_ELEMID_RSN) {
462 last_ev = current_val; 492 iwe.u.data.length = encode_ie(buf, sizeof(buf),
463 } 493 list->rsnIe, list->rsnIe[1]+2,
464 494 rsn_leader, sizeof(rsn_leader)-1);
465 for (i = 0 ; i < list->extSupportedRates[1] ; i++) 495 if (iwe.u.data.length != 0)
466 { 496 current_ev = iwe_stream_add_point(info,
467/* Bit rate given in 500 kb/s units (+ 0x80) */ 497 current_ev, end_buf, &iwe, buf);
468 iwe.u.bitrate.value = ((list->extSupportedRates[i+2] & 0x7f) * 500000); 498
469/* Add new value to event */ 499 /* Ran out of buffer */
470 current_val = iwe_stream_add_value( 500 if (last_ev == current_ev)
471 info, 501 return end_buf;
472 current_ev, current_val, end_buf, &iwe, IW_EV_PARAM_LEN); 502
473 503 last_ev = current_ev;
474 /* Ran out of buffer */ 504 }
475 if (last_ev == current_val) 505 }
476 { 506 #endif
477 return end_buf; 507 /* The other data in the scan result are not really
478 } 508 * interesting, so for now drop it
479 509 */
480 last_ev = current_ev; 510 return current_ev;
481 }
482
483/* Check if we added any event */
484 if((current_val - current_ev) > IW_EV_LCP_LEN)
485 current_ev = current_val;
486#if WIRELESS_EXT > 14
487#define IEEE80211_ELEMID_RSN 0x30
488 memset(&iwe, 0, sizeof(iwe));
489 iwe.cmd = IWEVCUSTOM;
490 snprintf(buf, sizeof(buf), "bcn_int=%d", (list->beaconInterval[1] << 8) + list->beaconInterval[0]);
491 iwe.u.data.length = strlen(buf);
492 current_ev = iwe_stream_add_point(
493 info,
494 current_ev, end_buf, &iwe, buf);
495
496 /* Ran out of buffer */
497 if (last_ev == current_ev)
498 {
499 return end_buf;
500 }
501
502 last_ev = current_ev;
503
504 if (list->wpaIe[1] != 0)
505 {
506 static const char rsn_leader[] = "rsn_ie=";
507 static const char wpa_leader[] = "wpa_ie=";
508
509 memset(&iwe, 0, sizeof(iwe));
510 iwe.cmd = IWEVCUSTOM;
511 if (list->wpaIe[0] == IEEE80211_ELEMID_RSN)
512 iwe.u.data.length = encode_ie(buf, sizeof(buf),
513 list->wpaIe, list->wpaIe[1]+2,
514 rsn_leader, sizeof(rsn_leader)-1);
515 else
516 iwe.u.data.length = encode_ie(buf, sizeof(buf),
517 list->wpaIe, list->wpaIe[1]+2,
518 wpa_leader, sizeof(wpa_leader)-1);
519
520 if (iwe.u.data.length != 0)
521 current_ev = iwe_stream_add_point(
522 info,
523 current_ev, end_buf, &iwe, buf);
524
525 /* Ran out of buffer */
526 if (last_ev == current_ev)
527 {
528 return end_buf;
529 }
530
531 last_ev = current_ev;
532 }
533 if (list->rsnIe[1] != 0)
534 {
535 static const char rsn_leader[] = "rsn_ie=";
536 memset(&iwe, 0, sizeof(iwe));
537 iwe.cmd = IWEVCUSTOM;
538
539 if (list->rsnIe[0] == IEEE80211_ELEMID_RSN)
540 {
541 iwe.u.data.length = encode_ie(buf, sizeof(buf),
542 list->rsnIe, list->rsnIe[1]+2,
543 rsn_leader, sizeof(rsn_leader)-1);
544 if (iwe.u.data.length != 0)
545 current_ev = iwe_stream_add_point(
546 info,
547 current_ev, end_buf, &iwe, buf);
548
549 /* Ran out of buffer */
550 if (last_ev == current_ev)
551 {
552 return end_buf;
553 }
554
555 last_ev = current_ev;
556 }
557 }
558#endif
559/* The other data in the scan result are not really
560 * interesting, so for now drop it */
561 return current_ev;
562} 511}
563 512
564int usbdrvwext_giwname(struct net_device *dev, 513int usbdrvwext_giwname(struct net_device *dev,
565 struct iw_request_info *info, 514 struct iw_request_info *info,
566 union iwreq_data *wrq, char *extra) 515 union iwreq_data *wrq, char *extra)
567{ 516{
568 //struct usbdrv_private *macp = dev->ml_priv; 517 /* struct usbdrv_private *macp = dev->ml_priv; */
569 518
570 strcpy(wrq->name, "IEEE 802.11-MIMO"); 519 strcpy(wrq->name, "IEEE 802.11-MIMO");
571 520
572 return 0; 521 return 0;
573} 522}
574 523
575int usbdrvwext_siwfreq(struct net_device *dev, 524int usbdrvwext_siwfreq(struct net_device *dev,
576 struct iw_request_info *info, 525 struct iw_request_info *info,
577 struct iw_freq *freq, char *extra) 526 struct iw_freq *freq, char *extra)
578{ 527{
579 u32_t FreqKHz; 528 u32_t FreqKHz;
580 struct usbdrv_private *macp = dev->ml_priv; 529 struct usbdrv_private *macp = dev->ml_priv;
581 530
582 if(!netif_running(dev)) 531 if (!netif_running(dev))
583 return -EINVAL; 532 return -EINVAL;
584 533
585 if (freq->e > 1) 534 if (freq->e > 1)
586 return -EINVAL; 535 return -EINVAL;
587 536
588 if (freq->e == 1) 537 if (freq->e == 1) {
589 { 538 FreqKHz = (freq->m / 100000);
590 FreqKHz = (freq->m / 100000); 539
591 540 if (FreqKHz > 4000000) {
592 if (FreqKHz > 4000000) 541 if (FreqKHz > 5825000)
593 { 542 FreqKHz = 5825000;
594 if (FreqKHz > 5825000) 543 else if (FreqKHz < 4920000)
595 FreqKHz = 5825000; 544 FreqKHz = 4920000;
596 else if (FreqKHz < 4920000) 545 else if (FreqKHz < 5000000)
597 FreqKHz = 4920000; 546 FreqKHz = (((FreqKHz - 4000000) / 5000) * 5000)
598 else if (FreqKHz < 5000000) 547 + 4000000;
599 FreqKHz = (((FreqKHz - 4000000) / 5000) * 5000) + 4000000; 548 else
600 else 549 FreqKHz = (((FreqKHz - 5000000) / 5000) * 5000)
601 FreqKHz = (((FreqKHz - 5000000) / 5000) * 5000) + 5000000; 550 + 5000000;
602 } 551 } else {
603 else 552 if (FreqKHz > 2484000)
604 { 553 FreqKHz = 2484000;
605 if (FreqKHz > 2484000) 554 else if (FreqKHz < 2412000)
606 FreqKHz = 2484000; 555 FreqKHz = 2412000;
607 else if (FreqKHz < 2412000) 556 else
608 FreqKHz = 2412000; 557 FreqKHz = (((FreqKHz - 2412000) / 5000) * 5000)
609 else 558 + 2412000;
610 FreqKHz = (((FreqKHz - 2412000) / 5000) * 5000) + 2412000; 559 }
611 } 560 } else {
612 561 FreqKHz = usbdrv_chan2freq(freq->m);
613 } 562
614 else 563 if (FreqKHz != -1)
615 { 564 FreqKHz *= 1000;
616 FreqKHz = usbdrv_chan2freq(freq->m); 565 else
617 566 FreqKHz = 2412000;
618 if (FreqKHz != -1) 567 }
619 FreqKHz *= 1000; 568
620 else 569 /* printk("freq->m: %d, freq->e: %d\n", freq->m, freq->e); */
621 FreqKHz = 2412000; 570 /* printk("FreqKHz: %d\n", FreqKHz); */
622 } 571
623 572 if (macp->DeviceOpened == 1) {
624 //printk("freq->m: %d, freq->e: %d\n", freq->m, freq->e); 573 zfiWlanSetFrequency(dev, FreqKHz, 0); /* Immediate */
625 //printk("FreqKHz: %d\n", FreqKHz); 574 /* u8_t wpaieLen,wpaie[50]; */
626 575 /* zfiWlanQueryWpaIe(dev, wpaie, &wpaieLen); */
627 if (macp->DeviceOpened == 1) 576 zfiWlanDisable(dev, 0);
628 { 577 zfiWlanEnable(dev);
629 zfiWlanSetFrequency(dev, FreqKHz, 0); // Immediate 578 /* if (wpaieLen > 2) */
630 //u8_t wpaieLen,wpaie[50]; 579 /* zfiWlanSetWpaIe(dev, wpaie, wpaieLen); */
631 //zfiWlanQueryWpaIe(dev, wpaie, &wpaieLen); 580 }
632 zfiWlanDisable(dev, 0); 581
633 zfiWlanEnable(dev); 582 return 0;
634 //if (wpaieLen > 2)
635 // zfiWlanSetWpaIe(dev, wpaie, wpaieLen);
636 }
637
638 return 0;
639} 583}
640 584
641int usbdrvwext_giwfreq(struct net_device *dev, 585int usbdrvwext_giwfreq(struct net_device *dev,
642 struct iw_request_info *info, 586 struct iw_request_info *info,
643 struct iw_freq *freq, char *extra) 587 struct iw_freq *freq, char *extra)
644{ 588{
645 struct usbdrv_private *macp = dev->ml_priv; 589 struct usbdrv_private *macp = dev->ml_priv;
646 590
647 if (macp->DeviceOpened != 1) 591 if (macp->DeviceOpened != 1)
648 return 0; 592 return 0;
649 593
650 freq->m = zfiWlanQueryFrequency(dev); 594 freq->m = zfiWlanQueryFrequency(dev);
651 freq->e = 3; 595 freq->e = 3;
652 596
653 return 0; 597 return 0;
654} 598}
655 599
656int usbdrvwext_siwmode(struct net_device *dev, 600int usbdrvwext_siwmode(struct net_device *dev,
657 struct iw_request_info *info, 601 struct iw_request_info *info,
658 union iwreq_data *wrq, char *extra) 602 union iwreq_data *wrq, char *extra)
659{ 603{
660 struct usbdrv_private *macp = dev->ml_priv; 604 struct usbdrv_private *macp = dev->ml_priv;
661 u8_t WlanMode; 605 u8_t WlanMode;
662 606
663 if(!netif_running(dev)) 607 if (!netif_running(dev))
664 return -EINVAL; 608 return -EINVAL;
665 609
666 if (macp->DeviceOpened != 1) 610 if (macp->DeviceOpened != 1)
667 return 0; 611 return 0;
668 612
669 switch(wrq->mode) 613 switch (wrq->mode) {
670 { 614 case IW_MODE_MASTER:
671 case IW_MODE_MASTER: 615 WlanMode = ZM_MODE_AP;
672 WlanMode = ZM_MODE_AP; 616 break;
673 break; 617 case IW_MODE_INFRA:
674 case IW_MODE_INFRA: 618 WlanMode = ZM_MODE_INFRASTRUCTURE;
675 WlanMode = ZM_MODE_INFRASTRUCTURE; 619 break;
676 break; 620 case IW_MODE_ADHOC:
677 case IW_MODE_ADHOC: 621 WlanMode = ZM_MODE_IBSS;
678 WlanMode = ZM_MODE_IBSS; 622 break;
679 break; 623 default:
680 default: 624 WlanMode = ZM_MODE_IBSS;
681 WlanMode = ZM_MODE_IBSS; 625 break;
682 break; 626 }
683 } 627
684 628 zfiWlanSetWlanMode(dev, WlanMode);
685 zfiWlanSetWlanMode(dev,WlanMode); 629 zfiWlanDisable(dev, 1);
686 zfiWlanDisable(dev, 1); 630 zfiWlanEnable(dev);
687 zfiWlanEnable(dev); 631
688 632 return 0;
689 return 0;
690} 633}
691 634
692int usbdrvwext_giwmode(struct net_device *dev, 635int usbdrvwext_giwmode(struct net_device *dev,
693 struct iw_request_info *info, 636 struct iw_request_info *info,
694 __u32 *mode, char *extra) 637 __u32 *mode, char *extra)
695{ 638{
696 unsigned long irqFlag; 639 unsigned long irqFlag;
697 struct usbdrv_private *macp = dev->ml_priv; 640 struct usbdrv_private *macp = dev->ml_priv;
698 641
699 if(!netif_running(dev)) 642 if (!netif_running(dev))
700 return -EINVAL; 643 return -EINVAL;
701 644
702 if (macp->DeviceOpened != 1) 645 if (macp->DeviceOpened != 1)
703 return 0; 646 return 0;
704 647
705 spin_lock_irqsave(&macp->cs_lock, irqFlag); 648 spin_lock_irqsave(&macp->cs_lock, irqFlag);
706 649
707 switch(zfiWlanQueryWlanMode(dev)) 650 switch (zfiWlanQueryWlanMode(dev)) {
708 { 651 case ZM_MODE_AP:
709 case ZM_MODE_AP: 652 *mode = IW_MODE_MASTER;
710 *mode = IW_MODE_MASTER; 653 break;
711 break; 654 case ZM_MODE_INFRASTRUCTURE:
712 case ZM_MODE_INFRASTRUCTURE: 655 *mode = IW_MODE_INFRA;
713 *mode = IW_MODE_INFRA; 656 break;
714 break; 657 case ZM_MODE_IBSS:
715 case ZM_MODE_IBSS: 658 *mode = IW_MODE_ADHOC;
716 *mode = IW_MODE_ADHOC; 659 break;
717 break; 660 default:
718 default: 661 *mode = IW_MODE_ADHOC;
719 *mode = IW_MODE_ADHOC; 662 break;
720 break; 663 }
721 } 664
722 665 spin_unlock_irqrestore(&macp->cs_lock, irqFlag);
723 spin_unlock_irqrestore(&macp->cs_lock, irqFlag); 666
724 667 return 0;
725 return 0;
726} 668}
727 669
728int usbdrvwext_siwsens(struct net_device *dev, 670int usbdrvwext_siwsens(struct net_device *dev,
@@ -743,338 +685,341 @@ int usbdrvwext_giwsens(struct net_device *dev,
743} 685}
744 686
745int usbdrvwext_giwrange(struct net_device *dev, 687int usbdrvwext_giwrange(struct net_device *dev,
746 struct iw_request_info *info, 688 struct iw_request_info *info,
747 struct iw_point *data, char *extra) 689 struct iw_point *data, char *extra)
748{ 690{
749 struct iw_range *range = (struct iw_range *) extra; 691 struct iw_range *range = (struct iw_range *) extra;
750 int i, val; 692 int i, val;
751 //int num_band_a; 693 /* int num_band_a; */
752 u16_t channels[60]; 694 u16_t channels[60];
753 u16_t channel_num; 695 u16_t channel_num;
754 696
755 if(!netif_running(dev)) 697 if (!netif_running(dev))
756 return -EINVAL; 698 return -EINVAL;
757 699
758#if WIRELESS_EXT > 9 700 #if WIRELESS_EXT > 9
759 range->txpower_capa = IW_TXPOW_DBM; 701 range->txpower_capa = IW_TXPOW_DBM;
760// XXX what about min/max_pmp, min/max_pmt, etc. 702 /* XXX what about min/max_pmp, min/max_pmt, etc. */
761#endif 703 #endif
762 704
763#if WIRELESS_EXT > 10 705 #if WIRELESS_EXT > 10
764 range->we_version_compiled = WIRELESS_EXT; 706 range->we_version_compiled = WIRELESS_EXT;
765 range->we_version_source = 13; 707 range->we_version_source = 13;
766 708
767 range->retry_capa = IW_RETRY_LIMIT; 709 range->retry_capa = IW_RETRY_LIMIT;
768 range->retry_flags = IW_RETRY_LIMIT; 710 range->retry_flags = IW_RETRY_LIMIT;
769 range->min_retry = 0; 711 range->min_retry = 0;
770 range->max_retry = 255; 712 range->max_retry = 255;
771#endif /* WIRELESS_EXT > 10 */ 713 #endif /* WIRELESS_EXT > 10 */
772 714
773 channel_num = zfiWlanQueryAllowChannels(dev, channels); 715 channel_num = zfiWlanQueryAllowChannels(dev, channels);
774 716
775 /* Gurantee reported channel numbers is less or equal to IW_MAX_FREQUENCIES */ 717 /* Gurantee reported channel numbers is less
776 if (channel_num > IW_MAX_FREQUENCIES) 718 * or equal to IW_MAX_FREQUENCIES
777 channel_num = IW_MAX_FREQUENCIES; 719 */
778 720 if (channel_num > IW_MAX_FREQUENCIES)
779 val = 0; 721 channel_num = IW_MAX_FREQUENCIES;
780 722
781 for (i = 0; i < channel_num; i++) 723 val = 0;
782 { 724
783 range->freq[val].i = usbdrv_freq2chan(channels[i]); 725 for (i = 0; i < channel_num; i++) {
784 range->freq[val].m = channels[i]; 726 range->freq[val].i = usbdrv_freq2chan(channels[i]);
785 range->freq[val].e = 6; 727 range->freq[val].m = channels[i];
786 val++; 728 range->freq[val].e = 6;
787 } 729 val++;
788 730 }
789 range->num_channels = channel_num;
790 range->num_frequency = channel_num;
791
792#if 0
793 range->num_channels = 14; // Only 2.4G
794
795/* XXX need to filter against the regulatory domain &| active set */
796 val = 0;
797 for (i = 1; i <= 14; i++) // B,G Bands
798 {
799 range->freq[val].i = i;
800 if (i == 14)
801 range->freq[val].m = 2484000;
802 else
803 range->freq[val].m = (2412+(i-1)*5)*1000;
804 range->freq[val].e = 3;
805 val++;
806 }
807
808 num_band_a = (IW_MAX_FREQUENCIES - val);
809
810 for (i = 0; i < num_band_a; i++) // A Bands
811 {
812 range->freq[val].i = channel_frequency_11A[2 * i];
813 range->freq[val].m = channel_frequency_11A[2 * i + 1] * 1000;
814 range->freq[val].e = 3;
815 val++;
816 }
817 // MIMO Rate Not Defined Now
818 //For 802.11a, there are too more frequency. We can't return them all
819 range->num_frequency = val;
820#endif
821
822/* Max of /proc/net/wireless */
823 range->max_qual.qual = 100; //?? //92;
824 range->max_qual.level = 154; //??
825 range->max_qual.noise = 154; //??
826 range->sensitivity = 3; //??
827
828// XXX these need to be nsd-specific!
829 range->min_rts = 0;
830 range->max_rts = 2347;
831 range->min_frag = 256;
832 range->max_frag = 2346;
833 range->max_encoding_tokens = 4/*NUM_WEPKEYS*/; //??
834 range->num_encoding_sizes = 2; //??
835 731
836 range->encoding_size[0] = 5; //?? //WEP Key Encoding Size 732 range->num_channels = channel_num;
837 range->encoding_size[1] = 13;//?? 733 range->num_frequency = channel_num;
838 734
839// XXX what about num_bitrates/throughput? 735 #if 0
840 range->num_bitrates = 0; //?? 736 range->num_channels = 14; /* Only 2.4G */
841 737
842/* estimated max throughput */ 738 /* XXX need to filter against the regulatory domain &| active set */
843// XXX need to cap it if we're running at ~2Mbps.. 739 val = 0;
740 /* B,G Bands */
741 for (i = 1; i <= 14; i++) {
742 range->freq[val].i = i;
743 if (i == 14)
744 range->freq[val].m = 2484000;
745 else
746 range->freq[val].m = (2412+(i-1)*5)*1000;
747 range->freq[val].e = 3;
748 val++;
749 }
844 750
845 range->throughput = 300000000; 751 num_band_a = (IW_MAX_FREQUENCIES - val);
752 /* A Bands */
753 for (i = 0; i < num_band_a; i++) {
754 range->freq[val].i = channel_frequency_11A[2 * i];
755 range->freq[val].m = channel_frequency_11A[2 * i + 1] * 1000;
756 range->freq[val].e = 3;
757 val++;
758 }
759 /* MIMO Rate Not Defined Now
760 * For 802.11a, there are too more frequency.
761 * We can't return them all.
762 */
763 range->num_frequency = val;
764 #endif
765
766 /* Max of /proc/net/wireless */
767 range->max_qual.qual = 100; /* ?? 92; */
768 range->max_qual.level = 154; /* ?? */
769 range->max_qual.noise = 154; /* ?? */
770 range->sensitivity = 3; /* ?? */
771
772 /* XXX these need to be nsd-specific! */
773 range->min_rts = 0;
774 range->max_rts = 2347;
775 range->min_frag = 256;
776 range->max_frag = 2346;
777 range->max_encoding_tokens = 4 /* NUM_WEPKEYS ?? */;
778 range->num_encoding_sizes = 2; /* ?? */
779
780 range->encoding_size[0] = 5; /* ?? WEP Key Encoding Size */
781 range->encoding_size[1] = 13; /* ?? */
782
783 /* XXX what about num_bitrates/throughput? */
784 range->num_bitrates = 0; /* ?? */
785
786 /* estimated max throughput
787 * XXX need to cap it if we're running at ~2Mbps..
788 */
789
790 range->throughput = 300000000;
846 791
847 return 0; 792 return 0;
848} 793}
849 794
850int usbdrvwext_siwap(struct net_device *dev, struct iw_request_info *info, 795int usbdrvwext_siwap(struct net_device *dev, struct iw_request_info *info,
851 struct sockaddr *MacAddr, char *extra) 796 struct sockaddr *MacAddr, char *extra)
852{ 797{
853 struct usbdrv_private *macp = dev->ml_priv; 798 struct usbdrv_private *macp = dev->ml_priv;
854 799
855 if(!netif_running(dev)) 800 if (!netif_running(dev))
856 return -EINVAL; 801 return -EINVAL;
857 802
858 if (zfiWlanQueryWlanMode(dev) == ZM_MODE_AP) // AP Mode 803 if (zfiWlanQueryWlanMode(dev) == ZM_MODE_AP) {
859 zfiWlanSetMacAddress(dev,(u16_t *)&MacAddr->sa_data[0]); 804 /* AP Mode */
860 else //STA Mode 805 zfiWlanSetMacAddress(dev, (u16_t *)&MacAddr->sa_data[0]);
861 zfiWlanSetBssid(dev,&MacAddr->sa_data[0]); 806 } else {
862 807 /* STA Mode */
863 if (macp->DeviceOpened == 1) 808 zfiWlanSetBssid(dev, &MacAddr->sa_data[0]);
864 { 809 }
865 //u8_t wpaieLen,wpaie[80]; 810
866 //zfiWlanQueryWpaIe(dev, wpaie, &wpaieLen); 811 if (macp->DeviceOpened == 1) {
867 zfiWlanDisable(dev, 0); 812 /* u8_t wpaieLen,wpaie[80]; */
868 zfiWlanEnable(dev); 813 /* zfiWlanQueryWpaIe(dev, wpaie, &wpaieLen); */
869 //if (wpaieLen > 2) 814 zfiWlanDisable(dev, 0);
870 // zfiWlanSetWpaIe(dev, wpaie, wpaieLen); 815 zfiWlanEnable(dev);
871 } 816 /* if (wpaieLen > 2) */
872 817 /* zfiWlanSetWpaIe(dev, wpaie, wpaieLen); */
873 return 0; 818 }
819
820 return 0;
874} 821}
875 822
876int usbdrvwext_giwap(struct net_device *dev, 823int usbdrvwext_giwap(struct net_device *dev,
877 struct iw_request_info *info, 824 struct iw_request_info *info,
878 struct sockaddr *MacAddr, char *extra) 825 struct sockaddr *MacAddr, char *extra)
879{ 826{
880 struct usbdrv_private *macp = dev->ml_priv; 827 struct usbdrv_private *macp = dev->ml_priv;
881 828
882 if (macp->DeviceOpened != 1) 829 if (macp->DeviceOpened != 1)
883 return 0; 830 return 0;
884 831
885 if (zfiWlanQueryWlanMode(dev) == ZM_MODE_AP) // AP Mode 832 if (zfiWlanQueryWlanMode(dev) == ZM_MODE_AP) {
886 zfiWlanQueryMacAddress(dev, &MacAddr->sa_data[0]); 833 /* AP Mode */
887 else //STA Mode 834 zfiWlanQueryMacAddress(dev, &MacAddr->sa_data[0]);
888 { 835 } else {
889 if (macp->adapterState == ZM_STATUS_MEDIA_CONNECT) 836 /* STA Mode */
890 { 837 if (macp->adapterState == ZM_STATUS_MEDIA_CONNECT) {
891 zfiWlanQueryBssid(dev, &MacAddr->sa_data[0]); 838 zfiWlanQueryBssid(dev, &MacAddr->sa_data[0]);
892 } 839 } else {
893 else 840 u8_t zero_addr[6] = { 0x00, 0x00, 0x00, 0x00,
894 { 841 0x00, 0x00 };
895 u8_t zero_addr[6] = { 0x00, 0x00, 0x00, 0x00, 0x00, 0x00 }; 842 memcpy(&MacAddr->sa_data[0], zero_addr,
896 memcpy(&MacAddr->sa_data[0], zero_addr, sizeof(zero_addr)); 843 sizeof(zero_addr));
897 } 844 }
898 } 845 }
899 846
900 return 0; 847 return 0;
901} 848}
902 849
903int usbdrvwext_iwaplist(struct net_device *dev, 850int usbdrvwext_iwaplist(struct net_device *dev,
904 struct iw_request_info *info, 851 struct iw_request_info *info,
905 struct iw_point *data, char *extra) 852 struct iw_point *data, char *extra)
906{ 853{
907 //Don't know how to do yet--CWYang(+) 854 /* Don't know how to do yet--CWYang(+) */
908 return 0; 855 return 0;
909 856
910} 857}
911 858
912int usbdrvwext_siwscan(struct net_device *dev, struct iw_request_info *info, 859int usbdrvwext_siwscan(struct net_device *dev, struct iw_request_info *info,
913 struct iw_point *data, char *extra) 860 struct iw_point *data, char *extra)
914{ 861{
915 struct usbdrv_private *macp = dev->ml_priv; 862 struct usbdrv_private *macp = dev->ml_priv;
916 863
917 if (macp->DeviceOpened != 1) 864 if (macp->DeviceOpened != 1)
918 return 0; 865 return 0;
919 866
920 printk("CWY - usbdrvwext_siwscan\n"); 867 printk(KERN_WARNING "CWY - usbdrvwext_siwscan\n");
921 868
922 zfiWlanScan(dev); 869 zfiWlanScan(dev);
923 870
924 return 0; 871 return 0;
925} 872}
926 873
927int usbdrvwext_giwscan(struct net_device *dev, 874int usbdrvwext_giwscan(struct net_device *dev,
928 struct iw_request_info *info, 875 struct iw_request_info *info,
929 struct iw_point *data, char *extra) 876 struct iw_point *data, char *extra)
930{ 877{
931 struct usbdrv_private *macp = dev->ml_priv; 878 struct usbdrv_private *macp = dev->ml_priv;
932 //struct zsWlanDev* wd = (struct zsWlanDev*) zmw_wlan_dev(dev); 879 /* struct zsWlanDev* wd = (struct zsWlanDev*) zmw_wlan_dev(dev); */
933 char *current_ev = extra; 880 char *current_ev = extra;
934 char *end_buf; 881 char *end_buf;
935 int i; 882 int i;
936 //struct zsBssList BssList; 883 /* struct zsBssList BssList; */
937 struct zsBssListV1 *pBssList = kmalloc(sizeof(struct zsBssListV1), GFP_KERNEL); 884 struct zsBssListV1 *pBssList = kmalloc(sizeof(struct zsBssListV1),
938 //BssList = wd->sta.pBssList; 885 GFP_KERNEL);
939 //zmw_get_wlan_dev(dev); 886 /* BssList = wd->sta.pBssList; */
940 887 /* zmw_get_wlan_dev(dev); */
941 if (macp->DeviceOpened != 1) 888
942 return 0; 889 if (macp->DeviceOpened != 1)
943 890 return 0;
944 if (data->length == 0) 891
945 { 892 if (data->length == 0)
946 end_buf = extra + IW_SCAN_MAX_DATA; 893 end_buf = extra + IW_SCAN_MAX_DATA;
947 } 894 else
948 else 895 end_buf = extra + data->length;
949 { 896
950 end_buf = extra + data->length; 897 printk(KERN_WARNING "giwscan - Report Scan Results\n");
951 } 898 /* printk("giwscan - BssList Sreucture Len : %d\n", sizeof(BssList));
952 899 * printk("giwscan - BssList Count : %d\n",
953 printk("giwscan - Report Scan Results\n"); 900 * wd->sta.pBssList->bssCount);
954 //printk("giwscan - BssList Sreucture Len : %d\n", sizeof(BssList)); 901 * printk("giwscan - UpdateBssList Count : %d\n",
955 //printk("giwscan - BssList Count : %d\n", wd->sta.pBssList->bssCount); 902 * wd->sta.pUpdateBssList->bssCount);
956 //printk("giwscan - UpdateBssList Count : %d\n", wd->sta.pUpdateBssList->bssCount); 903 */
957 zfiWlanQueryBssListV1(dev, pBssList); 904 zfiWlanQueryBssListV1(dev, pBssList);
958 //zfiWlanQueryBssList(dev, &BssList); 905 /* zfiWlanQueryBssList(dev, &BssList); */
959 906
960/* Read and parse all entries */ 907 /* Read and parse all entries */
961 printk("giwscan - pBssList->bssCount : %d\n", pBssList->bssCount); 908 printk(KERN_WARNING "giwscan - pBssList->bssCount : %d\n",
962 //printk("giwscan - BssList.bssCount : %d\n", BssList.bssCount); 909 pBssList->bssCount);
963 910 /* printk("giwscan - BssList.bssCount : %d\n", BssList.bssCount); */
964 for (i = 0; i < pBssList->bssCount; i++) 911
965 { 912 for (i = 0; i < pBssList->bssCount; i++) {
966/* Translate to WE format this entry */ 913 /* Translate to WE format this entry
967 //current_ev = usbdrv_translate_scan(dev, info, current_ev, 914 * current_ev = usbdrv_translate_scan(dev, info, current_ev,
968 // extra + IW_SCAN_MAX_DATA, &pBssList->bssInfo[i]); 915 * extra + IW_SCAN_MAX_DATA, &pBssList->bssInfo[i]);
969 current_ev = usbdrv_translate_scan(dev, info, current_ev, 916 */
970 end_buf, &pBssList->bssInfo[i]); 917 current_ev = usbdrv_translate_scan(dev, info, current_ev,
971 918 end_buf, &pBssList->bssInfo[i]);
972#if WIRELESS_EXT > 16 919
973 if (current_ev == end_buf) 920 #if WIRELESS_EXT > 16
974 { 921 if (current_ev == end_buf) {
975 kfree(pBssList); 922 kfree(pBssList);
976 data->length = current_ev - extra; 923 data->length = current_ev - extra;
977 return -E2BIG; 924 return -E2BIG;
978 } 925 }
979#endif 926 #endif
980 } 927 }
981 928
982/* Length of data */ 929 /* Length of data */
983 data->length = (current_ev - extra); 930 data->length = (current_ev - extra);
984 data->flags = 0; /* todo */ 931 data->flags = 0; /* todo */
985 932
986 kfree(pBssList); 933 kfree(pBssList);
987 934
988 return 0; 935 return 0;
989} 936}
990 937
991int usbdrvwext_siwessid(struct net_device *dev, 938int usbdrvwext_siwessid(struct net_device *dev,
992 struct iw_request_info *info, 939 struct iw_request_info *info,
993 struct iw_point *essid, char *extra) 940 struct iw_point *essid, char *extra)
994{ 941{
995 char EssidBuf[IW_ESSID_MAX_SIZE+1]; 942 char EssidBuf[IW_ESSID_MAX_SIZE + 1];
996 struct usbdrv_private *macp = dev->ml_priv; 943 struct usbdrv_private *macp = dev->ml_priv;
997 944
998 if(!netif_running(dev)) 945 if (!netif_running(dev))
999 return -EINVAL; 946 return -EINVAL;
1000 947
1001 if (essid->flags == 1) 948 if (essid->flags == 1) {
1002 { 949 if (essid->length > (IW_ESSID_MAX_SIZE + 1))
1003 if (essid->length > (IW_ESSID_MAX_SIZE+1)) 950 return -E2BIG;
1004 return -E2BIG; 951
1005 952 if (copy_from_user(&EssidBuf, essid->pointer, essid->length))
1006 if (copy_from_user(&EssidBuf, essid->pointer, essid->length)) 953 return -EFAULT;
1007 return -EFAULT; 954
1008 955 EssidBuf[essid->length] = '\0';
1009 EssidBuf[essid->length] = '\0'; 956 /* printk("siwessid - Set Essid : %s\n",EssidBuf); */
1010 //printk("siwessid - Set Essid : %s\n",EssidBuf); 957 /* printk("siwessid - Essid Len : %d\n",essid->length); */
1011 //printk("siwessid - Essid Len : %d\n",essid->length); 958 /* printk("siwessid - Essid Flag : %x\n",essid->flags); */
1012 //printk("siwessid - Essid Flag : %x\n",essid->flags); 959 if (macp->DeviceOpened == 1) {
1013 if (macp->DeviceOpened == 1) 960 zfiWlanSetSSID(dev, EssidBuf, strlen(EssidBuf));
1014 { 961 zfiWlanSetFrequency(dev, zfiWlanQueryFrequency(dev),
1015 zfiWlanSetSSID(dev, EssidBuf, strlen(EssidBuf)); 962 FALSE);
1016 zfiWlanSetFrequency(dev, zfiWlanQueryFrequency(dev), FALSE); 963 zfiWlanSetEncryMode(dev, zfiWlanQueryEncryMode(dev));
1017 zfiWlanSetEncryMode(dev, zfiWlanQueryEncryMode(dev)); 964 /* u8_t wpaieLen,wpaie[50]; */
1018 //u8_t wpaieLen,wpaie[50]; 965 /* zfiWlanQueryWpaIe(dev, wpaie, &wpaieLen); */
1019 //zfiWlanQueryWpaIe(dev, wpaie, &wpaieLen); 966 zfiWlanDisable(dev, 0);
1020 zfiWlanDisable(dev, 0); 967 zfiWlanEnable(dev);
1021 zfiWlanEnable(dev); 968 /* if (wpaieLen > 2) */
1022 //if (wpaieLen > 2) 969 /* zfiWlanSetWpaIe(dev, wpaie, wpaieLen); */
1023 // zfiWlanSetWpaIe(dev, wpaie, wpaieLen); 970 }
1024 } 971 }
1025 } 972
1026 973 return 0;
1027 return 0;
1028} 974}
1029 975
1030int usbdrvwext_giwessid(struct net_device *dev, 976int usbdrvwext_giwessid(struct net_device *dev,
1031 struct iw_request_info *info, 977 struct iw_request_info *info,
1032 struct iw_point *essid, char *extra) 978 struct iw_point *essid, char *extra)
1033{ 979{
1034 struct usbdrv_private *macp = dev->ml_priv; 980 struct usbdrv_private *macp = dev->ml_priv;
1035 u8_t EssidLen; 981 u8_t EssidLen;
1036 char EssidBuf[IW_ESSID_MAX_SIZE+1]; 982 char EssidBuf[IW_ESSID_MAX_SIZE + 1];
1037 int ssid_len; 983 int ssid_len;
1038 984
1039 if(!netif_running(dev)) 985 if (!netif_running(dev))
1040 return -EINVAL; 986 return -EINVAL;
1041 987
1042 if (macp->DeviceOpened != 1) 988 if (macp->DeviceOpened != 1)
1043 return 0; 989 return 0;
1044 990
1045 zfiWlanQuerySSID(dev, &EssidBuf[0], &EssidLen); 991 zfiWlanQuerySSID(dev, &EssidBuf[0], &EssidLen);
1046 992
1047 /* Convert type from unsigned char to char */ 993 /* Convert type from unsigned char to char */
1048 ssid_len = (int)EssidLen; 994 ssid_len = (int)EssidLen;
1049 995
1050 /* Make sure the essid length is not greater than IW_ESSID_MAX_SIZE */ 996 /* Make sure the essid length is not greater than IW_ESSID_MAX_SIZE */
1051 if (ssid_len > IW_ESSID_MAX_SIZE) 997 if (ssid_len > IW_ESSID_MAX_SIZE)
1052 ssid_len = IW_ESSID_MAX_SIZE; 998 ssid_len = IW_ESSID_MAX_SIZE;
1053 999
1054 EssidBuf[ssid_len] = '\0'; 1000 EssidBuf[ssid_len] = '\0';
1055 1001
1056 essid->flags = 1; 1002 essid->flags = 1;
1057 essid->length = strlen(EssidBuf); 1003 essid->length = strlen(EssidBuf);
1058 1004
1059 memcpy(extra, EssidBuf, essid->length); 1005 memcpy(extra, EssidBuf, essid->length);
1060 // wireless.c in Kernel would handle copy_to_user -- line 679 1006 /* wireless.c in Kernel would handle copy_to_user -- line 679 */
1061 /*if (essid->pointer) 1007 /* if (essid->pointer) {
1062 { 1008 * if (copy_to_user(essid->pointer, EssidBuf, essid->length)) {
1063 if ( copy_to_user(essid->pointer, EssidBuf, essid->length) ) 1009 * printk("giwessid - copy_to_user Fail\n");
1064 { 1010 * return -EFAULT;
1065 printk("giwessid - copy_to_user Fail\n"); 1011 * }
1066 return -EFAULT; 1012 * }
1067 } 1013 */
1068 }*/
1069 1014
1070 return 0; 1015 return 0;
1071} 1016}
1072 1017
1073int usbdrvwext_siwnickn(struct net_device *dev, 1018int usbdrvwext_siwnickn(struct net_device *dev,
1074 struct iw_request_info *info, 1019 struct iw_request_info *info,
1075 struct iw_point *data, char *nickname) 1020 struct iw_point *data, char *nickname)
1076{ 1021{
1077 //Exist but junk--CWYang(+) 1022 /* Exist but junk--CWYang(+) */
1078 return 0; 1023 return 0;
1079} 1024}
1080 1025
@@ -1082,182 +1027,180 @@ int usbdrvwext_giwnickn(struct net_device *dev,
1082 struct iw_request_info *info, 1027 struct iw_request_info *info,
1083 struct iw_point *data, char *nickname) 1028 struct iw_point *data, char *nickname)
1084{ 1029{
1085 struct usbdrv_private *macp = dev->ml_priv; 1030 struct usbdrv_private *macp = dev->ml_priv;
1086 u8_t EssidLen; 1031 u8_t EssidLen;
1087 char EssidBuf[IW_ESSID_MAX_SIZE+1]; 1032 char EssidBuf[IW_ESSID_MAX_SIZE + 1];
1088 1033
1089 if (macp->DeviceOpened != 1) 1034 if (macp->DeviceOpened != 1)
1090 return 0; 1035 return 0;
1091 1036
1092 zfiWlanQuerySSID(dev, &EssidBuf[0], &EssidLen); 1037 zfiWlanQuerySSID(dev, &EssidBuf[0], &EssidLen);
1093 EssidBuf[EssidLen] = 0; 1038 EssidBuf[EssidLen] = 0;
1094 1039
1095 data->flags = 1; 1040 data->flags = 1;
1096 data->length = strlen(EssidBuf); 1041 data->length = strlen(EssidBuf);
1097 1042
1098 memcpy(nickname, EssidBuf, data->length); 1043 memcpy(nickname, EssidBuf, data->length);
1099 1044
1100 return 0; 1045 return 0;
1101} 1046}
1102 1047
1103int usbdrvwext_siwrate(struct net_device *dev, 1048int usbdrvwext_siwrate(struct net_device *dev,
1104 struct iw_request_info *info, 1049 struct iw_request_info *info,
1105 struct iw_param *frq, char *extra) 1050 struct iw_param *frq, char *extra)
1106{ 1051{
1107 struct usbdrv_private *macp = dev->ml_priv; 1052 struct usbdrv_private *macp = dev->ml_priv;
1108 //Array to Define Rate Number that Send to Driver 1053 /* Array to Define Rate Number that Send to Driver */
1109 u16_t zcIndextoRateBG[16] = {1000, 2000, 5500, 11000, 0, 0, 0, 0, 48000, 1054 u16_t zcIndextoRateBG[16] = {1000, 2000, 5500, 11000, 0, 0, 0, 0,
1110 24000, 12000, 6000, 54000, 36000, 18000, 9000}; 1055 48000, 24000, 12000, 6000, 54000, 36000, 18000, 9000};
1111 u16_t zcRateToMCS[] = {0xff, 0, 1, 2, 3, 0xb, 0xf, 0xa, 0xe, 0x9, 0xd, 1056 u16_t zcRateToMCS[] = {0xff, 0, 1, 2, 3, 0xb, 0xf, 0xa, 0xe, 0x9, 0xd,
1112 0x8, 0xc}; 1057 0x8, 0xc};
1113 u8_t i,RateIndex = 4; 1058 u8_t i, RateIndex = 4;
1114 u16_t RateKbps; 1059 u16_t RateKbps;
1115 1060
1116 //printk("frq->disabled : 0x%x\n",frq->disabled); 1061 /* printk("frq->disabled : 0x%x\n",frq->disabled); */
1117 //printk("frq->value : 0x%x\n",frq->value); 1062 /* printk("frq->value : 0x%x\n",frq->value); */
1118 1063
1119 RateKbps = frq->value / 1000; 1064 RateKbps = frq->value / 1000;
1120 //printk("RateKbps : %d\n", RateKbps); 1065 /* printk("RateKbps : %d\n", RateKbps); */
1121 for (i = 0; i < 16; i++) 1066 for (i = 0; i < 16; i++) {
1122 { 1067 if (RateKbps == zcIndextoRateBG[i])
1123 if (RateKbps == zcIndextoRateBG[i]) 1068 RateIndex = i;
1124 RateIndex = i; 1069 }
1125 } 1070
1126 if (zcIndextoRateBG[RateIndex] == 0) 1071 if (zcIndextoRateBG[RateIndex] == 0)
1127 RateIndex = 0xff; 1072 RateIndex = 0xff;
1128 //printk("RateIndex : %x\n", RateIndex); 1073 /* printk("RateIndex : %x\n", RateIndex); */
1129 for (i = 0; i < 13; i++) 1074 for (i = 0; i < 13; i++)
1130 if (RateIndex == zcRateToMCS[i]) 1075 if (RateIndex == zcRateToMCS[i])
1131 break; 1076 break;
1132 //printk("Index : %x\n", i); 1077 /* printk("Index : %x\n", i); */
1133 if (RateKbps == 65000) 1078 if (RateKbps == 65000) {
1134 { 1079 RateIndex = 20;
1135 RateIndex = 20; 1080 printk(KERN_WARNING "RateIndex : %d\n", RateIndex);
1136 printk("RateIndex : %d\n", RateIndex); 1081 }
1137 } 1082
1138 if (macp->DeviceOpened == 1) 1083 if (macp->DeviceOpened == 1) {
1139 { 1084 zfiWlanSetTxRate(dev, i);
1140 zfiWlanSetTxRate(dev, i); 1085 /* zfiWlanDisable(dev); */
1141 //zfiWlanDisable(dev); 1086 /* zfiWlanEnable(dev); */
1142 //zfiWlanEnable(dev); 1087 }
1143 } 1088
1144 1089 return 0;
1145 return 0;
1146} 1090}
1147 1091
1148int usbdrvwext_giwrate(struct net_device *dev, 1092int usbdrvwext_giwrate(struct net_device *dev,
1149 struct iw_request_info *info, 1093 struct iw_request_info *info,
1150 struct iw_param *frq, char *extra) 1094 struct iw_param *frq, char *extra)
1151{ 1095{
1152 struct usbdrv_private *macp = dev->ml_priv; 1096 struct usbdrv_private *macp = dev->ml_priv;
1153 1097
1154 if(!netif_running(dev)) 1098 if (!netif_running(dev))
1155 return -EINVAL; 1099 return -EINVAL;
1156 1100
1157 if (macp->DeviceOpened != 1) 1101 if (macp->DeviceOpened != 1)
1158 return 0; 1102 return 0;
1159 1103
1160 frq->fixed = 0; 1104 frq->fixed = 0;
1161 frq->disabled = 0; 1105 frq->disabled = 0;
1162 frq->value = zfiWlanQueryRxRate(dev) * 1000; 1106 frq->value = zfiWlanQueryRxRate(dev) * 1000;
1163 1107
1164 return 0; 1108 return 0;
1165} 1109}
1166 1110
1167int usbdrvwext_siwrts(struct net_device *dev, 1111int usbdrvwext_siwrts(struct net_device *dev,
1168 struct iw_request_info *info, 1112 struct iw_request_info *info,
1169 struct iw_param *rts, char *extra) 1113 struct iw_param *rts, char *extra)
1170{ 1114{
1171 struct usbdrv_private *macp = dev->ml_priv; 1115 struct usbdrv_private *macp = dev->ml_priv;
1172 int val = rts->value; 1116 int val = rts->value;
1173 1117
1174 if (macp->DeviceOpened != 1) 1118 if (macp->DeviceOpened != 1)
1175 return 0; 1119 return 0;
1176 1120
1177 if (rts->disabled) 1121 if (rts->disabled)
1178 val = 2347; 1122 val = 2347;
1179 1123
1180 if ((val < 0) || (val > 2347)) 1124 if ((val < 0) || (val > 2347))
1181 return -EINVAL; 1125 return -EINVAL;
1182 1126
1183 zfiWlanSetRtsThreshold(dev,val); 1127 zfiWlanSetRtsThreshold(dev, val);
1184 1128
1185 return 0; 1129 return 0;
1186} 1130}
1187 1131
1188int usbdrvwext_giwrts(struct net_device *dev, 1132int usbdrvwext_giwrts(struct net_device *dev,
1189 struct iw_request_info *info, 1133 struct iw_request_info *info,
1190 struct iw_param *rts, char *extra) 1134 struct iw_param *rts, char *extra)
1191{ 1135{
1192 struct usbdrv_private *macp = dev->ml_priv; 1136 struct usbdrv_private *macp = dev->ml_priv;
1193
1194 if(!netif_running(dev))
1195 return -EINVAL;
1196 1137
1197 if (macp->DeviceOpened != 1) 1138 if (!netif_running(dev))
1198 return 0; 1139 return -EINVAL;
1199 1140
1200 rts->value = zfiWlanQueryRtsThreshold(dev); 1141 if (macp->DeviceOpened != 1)
1201 rts->disabled = (rts->value >= 2347); 1142 return 0;
1202 rts->fixed = 1;
1203 1143
1204 return 0; 1144 rts->value = zfiWlanQueryRtsThreshold(dev);
1145 rts->disabled = (rts->value >= 2347);
1146 rts->fixed = 1;
1205 1147
1148 return 0;
1206} 1149}
1207 1150
1208int usbdrvwext_siwfrag(struct net_device *dev, 1151int usbdrvwext_siwfrag(struct net_device *dev,
1209 struct iw_request_info *info, 1152 struct iw_request_info *info,
1210 struct iw_param *frag, char *extra) 1153 struct iw_param *frag, char *extra)
1211{ 1154{
1212 struct usbdrv_private *macp = dev->ml_priv; 1155 struct usbdrv_private *macp = dev->ml_priv;
1213 u16_t fragThreshold; 1156 u16_t fragThreshold;
1214 1157
1215 if (macp->DeviceOpened != 1) 1158 if (macp->DeviceOpened != 1)
1216 return 0; 1159 return 0;
1217 1160
1218 if (frag->disabled) 1161 if (frag->disabled)
1219 fragThreshold = 0; 1162 fragThreshold = 0;
1220 else 1163 else
1221 fragThreshold = frag->value; 1164 fragThreshold = frag->value;
1222 1165
1223 zfiWlanSetFragThreshold(dev,fragThreshold); 1166 zfiWlanSetFragThreshold(dev, fragThreshold);
1224 1167
1225 return 0; 1168 return 0;
1226} 1169}
1227 1170
1228int usbdrvwext_giwfrag(struct net_device *dev, 1171int usbdrvwext_giwfrag(struct net_device *dev,
1229 struct iw_request_info *info, 1172 struct iw_request_info *info,
1230 struct iw_param *frag, char *extra) 1173 struct iw_param *frag, char *extra)
1231{ 1174{
1232 struct usbdrv_private *macp = dev->ml_priv; 1175 struct usbdrv_private *macp = dev->ml_priv;
1233 u16 val; 1176 u16 val;
1234 unsigned long irqFlag; 1177 unsigned long irqFlag;
1235 1178
1236 if(!netif_running(dev)) 1179 if (!netif_running(dev))
1237 return -EINVAL; 1180 return -EINVAL;
1238 1181
1239 if (macp->DeviceOpened != 1) 1182 if (macp->DeviceOpened != 1)
1240 return 0; 1183 return 0;
1241 1184
1242 spin_lock_irqsave(&macp->cs_lock, irqFlag); 1185 spin_lock_irqsave(&macp->cs_lock, irqFlag);
1243 1186
1244 val = zfiWlanQueryFragThreshold(dev); 1187 val = zfiWlanQueryFragThreshold(dev);
1245 1188
1246 frag->value = val; 1189 frag->value = val;
1247 1190
1248 frag->disabled = (val >= 2346); 1191 frag->disabled = (val >= 2346);
1249 frag->fixed = 1; 1192 frag->fixed = 1;
1250 1193
1251 spin_unlock_irqrestore(&macp->cs_lock, irqFlag); 1194 spin_unlock_irqrestore(&macp->cs_lock, irqFlag);
1252 1195
1253 return 0; 1196 return 0;
1254} 1197}
1255 1198
1256int usbdrvwext_siwtxpow(struct net_device *dev, 1199int usbdrvwext_siwtxpow(struct net_device *dev,
1257 struct iw_request_info *info, 1200 struct iw_request_info *info,
1258 struct iw_param *rrq, char *extra) 1201 struct iw_param *rrq, char *extra)
1259{ 1202{
1260 //Not support yet--CWYng(+) 1203 /* Not support yet--CWYng(+) */
1261 return 0; 1204 return 0;
1262} 1205}
1263 1206
@@ -1265,7 +1208,7 @@ int usbdrvwext_giwtxpow(struct net_device *dev,
1265 struct iw_request_info *info, 1208 struct iw_request_info *info,
1266 struct iw_param *rrq, char *extra) 1209 struct iw_param *rrq, char *extra)
1267{ 1210{
1268 //Not support yet--CWYng(+) 1211 /* Not support yet--CWYng(+) */
1269 return 0; 1212 return 0;
1270} 1213}
1271 1214
@@ -1273,7 +1216,7 @@ int usbdrvwext_siwretry(struct net_device *dev,
1273 struct iw_request_info *info, 1216 struct iw_request_info *info,
1274 struct iw_param *rrq, char *extra) 1217 struct iw_param *rrq, char *extra)
1275{ 1218{
1276 //Do nothing--CWYang(+) 1219 /* Do nothing--CWYang(+) */
1277 return 0; 1220 return 0;
1278} 1221}
1279 1222
@@ -1281,665 +1224,662 @@ int usbdrvwext_giwretry(struct net_device *dev,
1281 struct iw_request_info *info, 1224 struct iw_request_info *info,
1282 struct iw_param *rrq, char *extra) 1225 struct iw_param *rrq, char *extra)
1283{ 1226{
1284 //Do nothing--CWYang(+) 1227 /* Do nothing--CWYang(+) */
1285 return 0; 1228 return 0;
1286} 1229}
1287 1230
1288int usbdrvwext_siwencode(struct net_device *dev, 1231int usbdrvwext_siwencode(struct net_device *dev,
1289 struct iw_request_info *info, 1232 struct iw_request_info *info,
1290 struct iw_point *erq, char *key) 1233 struct iw_point *erq, char *key)
1291{ 1234{
1292 struct zsKeyInfo keyInfo; 1235 struct zsKeyInfo keyInfo;
1293 int i, WepState = ZM_ENCRYPTION_WEP_DISABLED; 1236 int i;
1294 struct usbdrv_private *macp = dev->ml_priv; 1237 int WepState = ZM_ENCRYPTION_WEP_DISABLED;
1295 1238 struct usbdrv_private *macp = dev->ml_priv;
1296 if(!netif_running(dev)) 1239
1297 return -EINVAL; 1240 if (!netif_running(dev))
1298 1241 return -EINVAL;
1299 if ((erq->flags & IW_ENCODE_DISABLED) == 0) 1242
1300 { 1243 if ((erq->flags & IW_ENCODE_DISABLED) == 0) {
1301 keyInfo.key = key; 1244 keyInfo.key = key;
1302 keyInfo.keyLength = erq->length; 1245 keyInfo.keyLength = erq->length;
1303 keyInfo.keyIndex = (erq->flags & IW_ENCODE_INDEX) - 1; 1246 keyInfo.keyIndex = (erq->flags & IW_ENCODE_INDEX) - 1;
1304 if (keyInfo.keyIndex >= 4) 1247 if (keyInfo.keyIndex >= 4)
1305 keyInfo.keyIndex = 0; 1248 keyInfo.keyIndex = 0;
1306 keyInfo.flag = ZM_KEY_FLAG_DEFAULT_KEY; 1249 keyInfo.flag = ZM_KEY_FLAG_DEFAULT_KEY;
1307 1250
1308 zfiWlanSetKey(dev, keyInfo); 1251 zfiWlanSetKey(dev, keyInfo);
1309 WepState = ZM_ENCRYPTION_WEP_ENABLED; 1252 WepState = ZM_ENCRYPTION_WEP_ENABLED;
1310 } 1253 } else {
1311 else 1254 for (i = 1; i < 4; i++)
1312 { 1255 zfiWlanRemoveKey(dev, 0, i);
1313 for (i = 1; i < 4; i++) 1256 WepState = ZM_ENCRYPTION_WEP_DISABLED;
1314 zfiWlanRemoveKey(dev, 0, i); 1257 /* zfiWlanSetEncryMode(dev, ZM_NO_WEP); */
1315 WepState = ZM_ENCRYPTION_WEP_DISABLED; 1258 }
1316 //zfiWlanSetEncryMode(dev, ZM_NO_WEP); 1259
1317 } 1260 if (macp->DeviceOpened == 1) {
1318 1261 zfiWlanSetWepStatus(dev, WepState);
1319 if (macp->DeviceOpened == 1) 1262 zfiWlanSetFrequency(dev, zfiWlanQueryFrequency(dev), FALSE);
1320 { 1263 /* zfiWlanSetEncryMode(dev, zfiWlanQueryEncryMode(dev)); */
1321 zfiWlanSetWepStatus(dev, WepState); 1264 /* u8_t wpaieLen,wpaie[50]; */
1322 zfiWlanSetFrequency(dev, zfiWlanQueryFrequency(dev), FALSE); 1265 /* zfiWlanQueryWpaIe(dev, wpaie, &wpaieLen); */
1323 //zfiWlanSetEncryMode(dev, zfiWlanQueryEncryMode(dev)); 1266 zfiWlanDisable(dev, 0);
1324 //u8_t wpaieLen,wpaie[50]; 1267 zfiWlanEnable(dev);
1325 //zfiWlanQueryWpaIe(dev, wpaie, &wpaieLen); 1268 /* if (wpaieLen > 2) */
1326 zfiWlanDisable(dev, 0); 1269 /* zfiWlanSetWpaIe(dev, wpaie, wpaieLen); */
1327 zfiWlanEnable(dev); 1270 }
1328 //if (wpaieLen > 2) 1271
1329 // zfiWlanSetWpaIe(dev, wpaie, wpaieLen); 1272 return 0;
1330 }
1331
1332 return 0;
1333} 1273}
1334 1274
1335int usbdrvwext_giwencode(struct net_device *dev, 1275int usbdrvwext_giwencode(struct net_device *dev,
1336 struct iw_request_info *info, 1276 struct iw_request_info *info,
1337 struct iw_point *erq, char *key) 1277 struct iw_point *erq, char *key)
1338{ 1278{
1339 struct usbdrv_private *macp = dev->ml_priv; 1279 struct usbdrv_private *macp = dev->ml_priv;
1340 u8_t EncryptionMode; 1280 u8_t EncryptionMode;
1341 u8_t keyLen = 0; 1281 u8_t keyLen = 0;
1342 1282
1343 if (macp->DeviceOpened != 1) 1283 if (macp->DeviceOpened != 1)
1344 return 0; 1284 return 0;
1345 1285
1346 EncryptionMode = zfiWlanQueryEncryMode(dev); 1286 EncryptionMode = zfiWlanQueryEncryMode(dev);
1347 1287
1348 if (EncryptionMode) 1288 if (EncryptionMode)
1349 { 1289 erq->flags = IW_ENCODE_ENABLED;
1350 erq->flags = IW_ENCODE_ENABLED; 1290 else
1351 } 1291 erq->flags = IW_ENCODE_DISABLED;
1352 else 1292
1353 { 1293 /* We can't return the key, so set the proper flag and return zero */
1354 erq->flags = IW_ENCODE_DISABLED; 1294 erq->flags |= IW_ENCODE_NOKEY;
1355 } 1295 memset(key, 0, 16);
1356 1296
1357/* We can't return the key, so set the proper flag and return zero */ 1297 /* Copy the key to the user buffer */
1358 erq->flags |= IW_ENCODE_NOKEY; 1298 switch (EncryptionMode) {
1359 memset(key, 0, 16); 1299 case ZM_WEP64:
1360 1300 keyLen = 5;
1361/* Copy the key to the user buffer */ 1301 break;
1362 switch(EncryptionMode) 1302 case ZM_WEP128:
1363 { 1303 keyLen = 13;
1364 case ZM_WEP64: 1304 break;
1365 keyLen = 5; 1305 case ZM_WEP256:
1366 break; 1306 keyLen = 29;
1367 case ZM_WEP128: 1307 break;
1368 keyLen = 13; 1308 case ZM_AES:
1369 break; 1309 keyLen = 16;
1370 case ZM_WEP256: 1310 break;
1371 keyLen = 29; 1311 case ZM_TKIP:
1372 break; 1312 keyLen = 32;
1373 case ZM_AES: 1313 break;
1374 keyLen = 16; 1314 #ifdef ZM_ENABLE_CENC
1375 break; 1315 case ZM_CENC:
1376 case ZM_TKIP: 1316 /* ZM_ENABLE_CENC */
1377 keyLen = 32; 1317 keyLen = 32;
1378 break; 1318 break;
1379#ifdef ZM_ENABLE_CENC 1319 #endif
1380 case ZM_CENC: 1320 case ZM_NO_WEP:
1381 keyLen = 32; 1321 keyLen = 0;
1382 break; 1322 break;
1383#endif //ZM_ENABLE_CENC 1323 default:
1384 case ZM_NO_WEP: 1324 keyLen = 0;
1385 keyLen = 0; 1325 printk(KERN_ERR "Unknown EncryMode\n");
1386 break; 1326 break;
1387 default : 1327 }
1388 keyLen = 0; 1328 erq->length = keyLen;
1389 printk("Unknown EncryMode\n"); 1329
1390 break; 1330 return 0;
1391
1392 }
1393 erq->length = keyLen;
1394
1395 return 0;
1396} 1331}
1397 1332
1398int usbdrvwext_siwpower(struct net_device *dev, 1333int usbdrvwext_siwpower(struct net_device *dev,
1399 struct iw_request_info *info, 1334 struct iw_request_info *info,
1400 struct iw_param *frq, char *extra) 1335 struct iw_param *frq, char *extra)
1401{ 1336{
1402 struct usbdrv_private *macp = dev->ml_priv; 1337 struct usbdrv_private *macp = dev->ml_priv;
1403 u8_t PSMode; 1338 u8_t PSMode;
1404 1339
1405 if (macp->DeviceOpened != 1) 1340 if (macp->DeviceOpened != 1)
1406 return 0; 1341 return 0;
1407 1342
1408 if (frq->disabled) 1343 if (frq->disabled)
1409 PSMode = ZM_STA_PS_NONE; 1344 PSMode = ZM_STA_PS_NONE;
1410 else 1345 else
1411 PSMode = ZM_STA_PS_MAX; 1346 PSMode = ZM_STA_PS_MAX;
1412 1347
1413 zfiWlanSetPowerSaveMode(dev,PSMode); 1348 zfiWlanSetPowerSaveMode(dev, PSMode);
1414 1349
1415 return 0; 1350 return 0;
1416} 1351}
1417 1352
1418int usbdrvwext_giwpower(struct net_device *dev, 1353int usbdrvwext_giwpower(struct net_device *dev,
1419 struct iw_request_info *info, 1354 struct iw_request_info *info,
1420 struct iw_param *frq, char *extra) 1355 struct iw_param *frq, char *extra)
1421{ 1356{
1422 unsigned long irqFlag; 1357 unsigned long irqFlag;
1423 struct usbdrv_private *macp = dev->ml_priv; 1358 struct usbdrv_private *macp = dev->ml_priv;
1424 1359
1425 if (macp->DeviceOpened != 1) 1360 if (macp->DeviceOpened != 1)
1426 return 0; 1361 return 0;
1427 1362
1428 spin_lock_irqsave(&macp->cs_lock, irqFlag); 1363 spin_lock_irqsave(&macp->cs_lock, irqFlag);
1429 1364
1430 if (zfiWlanQueryPowerSaveMode(dev) == ZM_STA_PS_NONE) 1365 if (zfiWlanQueryPowerSaveMode(dev) == ZM_STA_PS_NONE)
1431 frq->disabled = 1; 1366 frq->disabled = 1;
1432 else 1367 else
1433 frq->disabled = 0; 1368 frq->disabled = 0;
1434 1369
1435 spin_unlock_irqrestore(&macp->cs_lock, irqFlag); 1370 spin_unlock_irqrestore(&macp->cs_lock, irqFlag);
1436 1371
1437 return 0; 1372 return 0;
1438} 1373}
1439 1374
1440//int usbdrvwext_setparam(struct net_device *dev, struct iw_request_info *info, 1375/*int usbdrvwext_setparam(struct net_device *dev, struct iw_request_info *info,
1441// void *w, char *extra) 1376* void *w, char *extra)
1442//{ 1377*{
1443// struct ieee80211vap *vap = dev->ml_priv; 1378* struct ieee80211vap *vap = dev->ml_priv;
1444// struct ieee80211com *ic = vap->iv_ic; 1379* struct ieee80211com *ic = vap->iv_ic;
1445// struct ieee80211_rsnparms *rsn = &vap->iv_bss->ni_rsn; 1380* struct ieee80211_rsnparms *rsn = &vap->iv_bss->ni_rsn;
1446// int *i = (int *) extra; 1381* int *i = (int *) extra;
1447// int param = i[0]; /* parameter id is 1st */ 1382* int param = i[0]; // parameter id is 1st
1448// int value = i[1]; /* NB: most values are TYPE_INT */ 1383* int value = i[1]; // NB: most values are TYPE_INT
1449// int retv = 0; 1384* int retv = 0;
1450// int j, caps; 1385* int j, caps;
1451// const struct ieee80211_authenticator *auth; 1386* const struct ieee80211_authenticator *auth;
1452// const struct ieee80211_aclator *acl; 1387* const struct ieee80211_aclator *acl;
1453// 1388*
1454// switch (param) { 1389* switch (param) {
1455// case IEEE80211_PARAM_AUTHMODE: 1390* case IEEE80211_PARAM_AUTHMODE:
1456// switch (value) { 1391* switch (value) {
1457// case IEEE80211_AUTH_WPA: /* WPA */ 1392* case IEEE80211_AUTH_WPA: // WPA
1458// case IEEE80211_AUTH_8021X: /* 802.1x */ 1393* case IEEE80211_AUTH_8021X: // 802.1x
1459// case IEEE80211_AUTH_OPEN: /* open */ 1394* case IEEE80211_AUTH_OPEN: // open
1460// case IEEE80211_AUTH_SHARED: /* shared-key */ 1395* case IEEE80211_AUTH_SHARED: // shared-key
1461// case IEEE80211_AUTH_AUTO: /* auto */ 1396* case IEEE80211_AUTH_AUTO: // auto
1462// auth = ieee80211_authenticator_get(value); 1397* auth = ieee80211_authenticator_get(value);
1463// if (auth == NULL) 1398* if (auth == NULL)
1464// return -EINVAL; 1399* return -EINVAL;
1465// break; 1400* break;
1466// default: 1401* default:
1467// return -EINVAL; 1402* return -EINVAL;
1468// } 1403* }
1469// switch (value) { 1404* switch (value) {
1470// case IEEE80211_AUTH_WPA: /* WPA w/ 802.1x */ 1405* case IEEE80211_AUTH_WPA: // WPA w/ 802.1x
1471// vap->iv_flags |= IEEE80211_F_PRIVACY; 1406* vap->iv_flags |= IEEE80211_F_PRIVACY;
1472// value = IEEE80211_AUTH_8021X; 1407* value = IEEE80211_AUTH_8021X;
1473// break; 1408* break;
1474// case IEEE80211_AUTH_OPEN: /* open */ 1409* case IEEE80211_AUTH_OPEN: // open
1475// vap->iv_flags &= ~(IEEE80211_F_WPA|IEEE80211_F_PRIVACY); 1410* vap->iv_flags &= ~(IEEE80211_F_WPA | IEEE80211_F_PRIVACY);
1476// break; 1411* break;
1477// case IEEE80211_AUTH_SHARED: /* shared-key */ 1412* case IEEE80211_AUTH_SHARED: // shared-key
1478// case IEEE80211_AUTH_AUTO: /* auto */ 1413* case IEEE80211_AUTH_AUTO: // auto
1479// case IEEE80211_AUTH_8021X: /* 802.1x */ 1414* case IEEE80211_AUTH_8021X: // 802.1x
1480// vap->iv_flags &= ~IEEE80211_F_WPA; 1415* vap->iv_flags &= ~IEEE80211_F_WPA;
1481// /* both require a key so mark the PRIVACY capability */ 1416* // both require a key so mark the PRIVACY capability
1482// vap->iv_flags |= IEEE80211_F_PRIVACY; 1417* vap->iv_flags |= IEEE80211_F_PRIVACY;
1483// break; 1418* break;
1484// } 1419* }
1485// /* NB: authenticator attach/detach happens on state change */ 1420* // NB: authenticator attach/detach happens on state change
1486// vap->iv_bss->ni_authmode = value; 1421* vap->iv_bss->ni_authmode = value;
1487// /* XXX mixed/mode/usage? */ 1422* // XXX mixed/mode/usage?
1488// vap->iv_auth = auth; 1423* vap->iv_auth = auth;
1489// retv = ENETRESET; 1424* retv = ENETRESET;
1490// break; 1425* break;
1491// case IEEE80211_PARAM_PROTMODE: 1426* case IEEE80211_PARAM_PROTMODE:
1492// if (value > IEEE80211_PROT_RTSCTS) 1427* if (value > IEEE80211_PROT_RTSCTS)
1493// return -EINVAL; 1428* return -EINVAL;
1494// ic->ic_protmode = value; 1429* ic->ic_protmode = value;
1495// /* NB: if not operating in 11g this can wait */ 1430* // NB: if not operating in 11g this can wait
1496// if (ic->ic_bsschan != IEEE80211_CHAN_ANYC && 1431* if (ic->ic_bsschan != IEEE80211_CHAN_ANYC &&
1497// IEEE80211_IS_CHAN_ANYG(ic->ic_bsschan)) 1432* IEEE80211_IS_CHAN_ANYG(ic->ic_bsschan))
1498// retv = ENETRESET; 1433* retv = ENETRESET;
1499// break; 1434* break;
1500// case IEEE80211_PARAM_MCASTCIPHER: 1435* case IEEE80211_PARAM_MCASTCIPHER:
1501// if ((vap->iv_caps & cipher2cap(value)) == 0 && 1436* if ((vap->iv_caps & cipher2cap(value)) == 0 &&
1502// !ieee80211_crypto_available(value)) 1437* !ieee80211_crypto_available(value))
1503// return -EINVAL; 1438* return -EINVAL;
1504// rsn->rsn_mcastcipher = value; 1439* rsn->rsn_mcastcipher = value;
1505// if (vap->iv_flags & IEEE80211_F_WPA) 1440* if (vap->iv_flags & IEEE80211_F_WPA)
1506// retv = ENETRESET; 1441* retv = ENETRESET;
1507// break; 1442* break;
1508// case IEEE80211_PARAM_MCASTKEYLEN: 1443* case IEEE80211_PARAM_MCASTKEYLEN:
1509// if (!(0 < value && value < IEEE80211_KEYBUF_SIZE)) 1444* if (!(0 < value && value < IEEE80211_KEYBUF_SIZE))
1510// return -EINVAL; 1445* return -EINVAL;
1511// /* XXX no way to verify driver capability */ 1446* // XXX no way to verify driver capability
1512// rsn->rsn_mcastkeylen = value; 1447* rsn->rsn_mcastkeylen = value;
1513// if (vap->iv_flags & IEEE80211_F_WPA) 1448* if (vap->iv_flags & IEEE80211_F_WPA)
1514// retv = ENETRESET; 1449* retv = ENETRESET;
1515// break; 1450* break;
1516// case IEEE80211_PARAM_UCASTCIPHERS: 1451* case IEEE80211_PARAM_UCASTCIPHERS:
1517// /* 1452*
1518// * Convert cipher set to equivalent capabilities. 1453* // Convert cipher set to equivalent capabilities.
1519// * NB: this logic intentionally ignores unknown and 1454* // NB: this logic intentionally ignores unknown and
1520// * unsupported ciphers so folks can specify 0xff or 1455* // unsupported ciphers so folks can specify 0xff or
1521// * similar and get all available ciphers. 1456* // similar and get all available ciphers.
1522// */ 1457*
1523// caps = 0; 1458* caps = 0;
1524// for (j = 1; j < 32; j++) /* NB: skip WEP */ 1459* for (j = 1; j < 32; j++) // NB: skip WEP
1525// if ((value & (1<<j)) && 1460* if ((value & (1<<j)) &&
1526// ((vap->iv_caps & cipher2cap(j)) || 1461* ((vap->iv_caps & cipher2cap(j)) ||
1527// ieee80211_crypto_available(j))) 1462* ieee80211_crypto_available(j)))
1528// caps |= 1<<j; 1463* caps |= 1<<j;
1529// if (caps == 0) /* nothing available */ 1464* if (caps == 0) // nothing available
1530// return -EINVAL; 1465* return -EINVAL;
1531// /* XXX verify ciphers ok for unicast use? */ 1466* // XXX verify ciphers ok for unicast use?
1532// /* XXX disallow if running as it'll have no effect */ 1467* // XXX disallow if running as it'll have no effect
1533// rsn->rsn_ucastcipherset = caps; 1468* rsn->rsn_ucastcipherset = caps;
1534// if (vap->iv_flags & IEEE80211_F_WPA) 1469* if (vap->iv_flags & IEEE80211_F_WPA)
1535// retv = ENETRESET; 1470* retv = ENETRESET;
1536// break; 1471* break;
1537// case IEEE80211_PARAM_UCASTCIPHER: 1472* case IEEE80211_PARAM_UCASTCIPHER:
1538// if ((rsn->rsn_ucastcipherset & cipher2cap(value)) == 0) 1473* if ((rsn->rsn_ucastcipherset & cipher2cap(value)) == 0)
1539// return -EINVAL; 1474* return -EINVAL;
1540// rsn->rsn_ucastcipher = value; 1475* rsn->rsn_ucastcipher = value;
1541// break; 1476* break;
1542// case IEEE80211_PARAM_UCASTKEYLEN: 1477* case IEEE80211_PARAM_UCASTKEYLEN:
1543// if (!(0 < value && value < IEEE80211_KEYBUF_SIZE)) 1478* if (!(0 < value && value < IEEE80211_KEYBUF_SIZE))
1544// return -EINVAL; 1479* return -EINVAL;
1545// /* XXX no way to verify driver capability */ 1480* // XXX no way to verify driver capability
1546// rsn->rsn_ucastkeylen = value; 1481* rsn->rsn_ucastkeylen = value;
1547// break; 1482* break;
1548// case IEEE80211_PARAM_KEYMGTALGS: 1483* case IEEE80211_PARAM_KEYMGTALGS:
1549// /* XXX check */ 1484* // XXX check
1550// rsn->rsn_keymgmtset = value; 1485* rsn->rsn_keymgmtset = value;
1551// if (vap->iv_flags & IEEE80211_F_WPA) 1486* if (vap->iv_flags & IEEE80211_F_WPA)
1552// retv = ENETRESET; 1487* retv = ENETRESET;
1553// break; 1488* break;
1554// case IEEE80211_PARAM_RSNCAPS: 1489* case IEEE80211_PARAM_RSNCAPS:
1555// /* XXX check */ 1490* // XXX check
1556// rsn->rsn_caps = value; 1491* rsn->rsn_caps = value;
1557// if (vap->iv_flags & IEEE80211_F_WPA) 1492* if (vap->iv_flags & IEEE80211_F_WPA)
1558// retv = ENETRESET; 1493* retv = ENETRESET;
1559// break; 1494* break;
1560// case IEEE80211_PARAM_WPA: 1495* case IEEE80211_PARAM_WPA:
1561// if (value > 3) 1496* if (value > 3)
1562// return -EINVAL; 1497* return -EINVAL;
1563// /* XXX verify ciphers available */ 1498* // XXX verify ciphers available
1564// vap->iv_flags &= ~IEEE80211_F_WPA; 1499* vap->iv_flags &= ~IEEE80211_F_WPA;
1565// switch (value) { 1500* switch (value) {
1566// case 1: 1501* case 1:
1567// vap->iv_flags |= IEEE80211_F_WPA1; 1502* vap->iv_flags |= IEEE80211_F_WPA1;
1568// break; 1503* break;
1569// case 2: 1504* case 2:
1570// vap->iv_flags |= IEEE80211_F_WPA2; 1505* vap->iv_flags |= IEEE80211_F_WPA2;
1571// break; 1506* break;
1572// case 3: 1507* case 3:
1573// vap->iv_flags |= IEEE80211_F_WPA1 | IEEE80211_F_WPA2; 1508* vap->iv_flags |= IEEE80211_F_WPA1 | IEEE80211_F_WPA2;
1574// break; 1509* break;
1575// } 1510* }
1576// retv = ENETRESET; /* XXX? */ 1511* retv = ENETRESET; // XXX?
1577// break; 1512* break;
1578// case IEEE80211_PARAM_ROAMING: 1513* case IEEE80211_PARAM_ROAMING:
1579// if (!(IEEE80211_ROAMING_DEVICE <= value && 1514* if (!(IEEE80211_ROAMING_DEVICE <= value &&
1580// value <= IEEE80211_ROAMING_MANUAL)) 1515* value <= IEEE80211_ROAMING_MANUAL))
1581// return -EINVAL; 1516* return -EINVAL;
1582// ic->ic_roaming = value; 1517* ic->ic_roaming = value;
1583// break; 1518* break;
1584// case IEEE80211_PARAM_PRIVACY: 1519* case IEEE80211_PARAM_PRIVACY:
1585// if (value) { 1520* if (value) {
1586// /* XXX check for key state? */ 1521* // XXX check for key state?
1587// vap->iv_flags |= IEEE80211_F_PRIVACY; 1522* vap->iv_flags |= IEEE80211_F_PRIVACY;
1588// } else 1523* } else
1589// vap->iv_flags &= ~IEEE80211_F_PRIVACY; 1524* vap->iv_flags &= ~IEEE80211_F_PRIVACY;
1590// break; 1525* break;
1591// case IEEE80211_PARAM_DROPUNENCRYPTED: 1526* case IEEE80211_PARAM_DROPUNENCRYPTED:
1592// if (value) 1527* if (value)
1593// vap->iv_flags |= IEEE80211_F_DROPUNENC; 1528* vap->iv_flags |= IEEE80211_F_DROPUNENC;
1594// else 1529* else
1595// vap->iv_flags &= ~IEEE80211_F_DROPUNENC; 1530* vap->iv_flags &= ~IEEE80211_F_DROPUNENC;
1596// break; 1531* break;
1597// case IEEE80211_PARAM_COUNTERMEASURES: 1532* case IEEE80211_PARAM_COUNTERMEASURES:
1598// if (value) { 1533* if (value) {
1599// if ((vap->iv_flags & IEEE80211_F_WPA) == 0) 1534* if ((vap->iv_flags & IEEE80211_F_WPA) == 0)
1600// return -EINVAL; 1535* return -EINVAL;
1601// vap->iv_flags |= IEEE80211_F_COUNTERM; 1536* vap->iv_flags |= IEEE80211_F_COUNTERM;
1602// } else 1537* } else
1603// vap->iv_flags &= ~IEEE80211_F_COUNTERM; 1538* vap->iv_flags &= ~IEEE80211_F_COUNTERM;
1604// break; 1539* break;
1605// case IEEE80211_PARAM_DRIVER_CAPS: 1540* case IEEE80211_PARAM_DRIVER_CAPS:
1606// vap->iv_caps = value; /* NB: for testing */ 1541* vap->iv_caps = value; // NB: for testing
1607// break; 1542* break;
1608// case IEEE80211_PARAM_MACCMD: 1543* case IEEE80211_PARAM_MACCMD:
1609// acl = vap->iv_acl; 1544* acl = vap->iv_acl;
1610// switch (value) { 1545* switch (value) {
1611// case IEEE80211_MACCMD_POLICY_OPEN: 1546* case IEEE80211_MACCMD_POLICY_OPEN:
1612// case IEEE80211_MACCMD_POLICY_ALLOW: 1547* case IEEE80211_MACCMD_POLICY_ALLOW:
1613// case IEEE80211_MACCMD_POLICY_DENY: 1548* case IEEE80211_MACCMD_POLICY_DENY:
1614// if (acl == NULL) { 1549* if (acl == NULL) {
1615// acl = ieee80211_aclator_get("mac"); 1550* acl = ieee80211_aclator_get("mac");
1616// if (acl == NULL || !acl->iac_attach(vap)) 1551* if (acl == NULL || !acl->iac_attach(vap))
1617// return -EINVAL; 1552* return -EINVAL;
1618// vap->iv_acl = acl; 1553* vap->iv_acl = acl;
1619// } 1554* }
1620// acl->iac_setpolicy(vap, value); 1555* acl->iac_setpolicy(vap, value);
1621// break; 1556* break;
1622// case IEEE80211_MACCMD_FLUSH: 1557* case IEEE80211_MACCMD_FLUSH:
1623// if (acl != NULL) 1558* if (acl != NULL)
1624// acl->iac_flush(vap); 1559* acl->iac_flush(vap);
1625// /* NB: silently ignore when not in use */ 1560* // NB: silently ignore when not in use
1626// break; 1561* break;
1627// case IEEE80211_MACCMD_DETACH: 1562* case IEEE80211_MACCMD_DETACH:
1628// if (acl != NULL) { 1563* if (acl != NULL) {
1629// vap->iv_acl = NULL; 1564* vap->iv_acl = NULL;
1630// acl->iac_detach(vap); 1565* acl->iac_detach(vap);
1631// } 1566* }
1632// break; 1567* break;
1633// } 1568* }
1634// break; 1569* break;
1635// case IEEE80211_PARAM_WMM: 1570* case IEEE80211_PARAM_WMM:
1636// if (ic->ic_caps & IEEE80211_C_WME){ 1571* if (ic->ic_caps & IEEE80211_C_WME){
1637// if (value) { 1572* if (value) {
1638// vap->iv_flags |= IEEE80211_F_WME; 1573* vap->iv_flags |= IEEE80211_F_WME;
1639// vap->iv_ic->ic_flags |= IEEE80211_F_WME; /* XXX needed by ic_reset */ 1574* *//* XXX needed by ic_reset *//*
1640// } 1575* vap->iv_ic->ic_flags |= IEEE80211_F_WME;
1641// else { 1576* }
1642// vap->iv_flags &= ~IEEE80211_F_WME; 1577* else {
1643// vap->iv_ic->ic_flags &= ~IEEE80211_F_WME; /* XXX needed by ic_reset */ 1578* *//* XXX needed by ic_reset *//*
1644// } 1579* vap->iv_flags &= ~IEEE80211_F_WME;
1645// retv = ENETRESET; /* Renegotiate for capabilities */ 1580* vap->iv_ic->ic_flags &= ~IEEE80211_F_WME;
1646// } 1581* }
1647// break; 1582* retv = ENETRESET; // Renegotiate for capabilities
1648// case IEEE80211_PARAM_HIDESSID: 1583* }
1649// if (value) 1584* break;
1650// vap->iv_flags |= IEEE80211_F_HIDESSID; 1585* case IEEE80211_PARAM_HIDESSID:
1651// else 1586* if (value)
1652// vap->iv_flags &= ~IEEE80211_F_HIDESSID; 1587* vap->iv_flags |= IEEE80211_F_HIDESSID;
1653// retv = ENETRESET; 1588* else
1654// break; 1589* vap->iv_flags &= ~IEEE80211_F_HIDESSID;
1655// case IEEE80211_PARAM_APBRIDGE: 1590* retv = ENETRESET;
1656// if (value == 0) 1591* break;
1657// vap->iv_flags |= IEEE80211_F_NOBRIDGE; 1592* case IEEE80211_PARAM_APBRIDGE:
1658// else 1593* if (value == 0)
1659// vap->iv_flags &= ~IEEE80211_F_NOBRIDGE; 1594* vap->iv_flags |= IEEE80211_F_NOBRIDGE;
1660// break; 1595* else
1661// case IEEE80211_PARAM_INACT: 1596* vap->iv_flags &= ~IEEE80211_F_NOBRIDGE;
1662// vap->iv_inact_run = value / IEEE80211_INACT_WAIT; 1597* break;
1663// break; 1598* case IEEE80211_PARAM_INACT:
1664// case IEEE80211_PARAM_INACT_AUTH: 1599* vap->iv_inact_run = value / IEEE80211_INACT_WAIT;
1665// vap->iv_inact_auth = value / IEEE80211_INACT_WAIT; 1600* break;
1666// break; 1601* case IEEE80211_PARAM_INACT_AUTH:
1667// case IEEE80211_PARAM_INACT_INIT: 1602* vap->iv_inact_auth = value / IEEE80211_INACT_WAIT;
1668// vap->iv_inact_init = value / IEEE80211_INACT_WAIT; 1603* break;
1669// break; 1604* case IEEE80211_PARAM_INACT_INIT:
1670// case IEEE80211_PARAM_ABOLT: 1605* vap->iv_inact_init = value / IEEE80211_INACT_WAIT;
1671// caps = 0; 1606* break;
1672// /* 1607* case IEEE80211_PARAM_ABOLT:
1673// * Map abolt settings to capability bits; 1608* caps = 0;
1674// * this also strips unknown/unwanted bits. 1609*
1675// */ 1610* // Map abolt settings to capability bits;
1676// if (value & IEEE80211_ABOLT_TURBO_PRIME) 1611* // this also strips unknown/unwanted bits.
1677// caps |= IEEE80211_ATHC_TURBOP; 1612*
1678// if (value & IEEE80211_ABOLT_COMPRESSION) 1613* if (value & IEEE80211_ABOLT_TURBO_PRIME)
1679// caps |= IEEE80211_ATHC_COMP; 1614* caps |= IEEE80211_ATHC_TURBOP;
1680// if (value & IEEE80211_ABOLT_FAST_FRAME) 1615* if (value & IEEE80211_ABOLT_COMPRESSION)
1681// caps |= IEEE80211_ATHC_FF; 1616* caps |= IEEE80211_ATHC_COMP;
1682// if (value & IEEE80211_ABOLT_XR) 1617* if (value & IEEE80211_ABOLT_FAST_FRAME)
1683// caps |= IEEE80211_ATHC_XR; 1618* caps |= IEEE80211_ATHC_FF;
1684// if (value & IEEE80211_ABOLT_AR) 1619* if (value & IEEE80211_ABOLT_XR)
1685// caps |= IEEE80211_ATHC_AR; 1620* caps |= IEEE80211_ATHC_XR;
1686// if (value & IEEE80211_ABOLT_BURST) 1621* if (value & IEEE80211_ABOLT_AR)
1687// caps |= IEEE80211_ATHC_BURST; 1622* caps |= IEEE80211_ATHC_AR;
1688// if (value & IEEE80211_ABOLT_WME_ELE) 1623* if (value & IEEE80211_ABOLT_BURST)
1689// caps |= IEEE80211_ATHC_WME; 1624* caps |= IEEE80211_ATHC_BURST;
1690// /* verify requested capabilities are supported */ 1625* if (value & IEEE80211_ABOLT_WME_ELE)
1691// if ((caps & ic->ic_ath_cap) != caps) 1626* caps |= IEEE80211_ATHC_WME;
1692// return -EINVAL; 1627* // verify requested capabilities are supported
1693// if (vap->iv_ath_cap != caps) { 1628* if ((caps & ic->ic_ath_cap) != caps)
1694// if ((vap->iv_ath_cap ^ caps) & IEEE80211_ATHC_TURBOP) { 1629* return -EINVAL;
1695// if (ieee80211_set_turbo(dev, caps & IEEE80211_ATHC_TURBOP)) 1630* if (vap->iv_ath_cap != caps) {
1696// return -EINVAL; 1631* if ((vap->iv_ath_cap ^ caps) & IEEE80211_ATHC_TURBOP) {
1697// ieee80211_scan_flush(ic); 1632* if (ieee80211_set_turbo(dev,
1698// } 1633* caps & IEEE80211_ATHC_TURBOP))
1699// vap->iv_ath_cap = caps; 1634* return -EINVAL;
1700// ic->ic_athcapsetup(vap->iv_ic, vap->iv_ath_cap); 1635* ieee80211_scan_flush(ic);
1701// retv = ENETRESET; 1636* }
1702// } 1637* vap->iv_ath_cap = caps;
1703// break; 1638* ic->ic_athcapsetup(vap->iv_ic, vap->iv_ath_cap);
1704// case IEEE80211_PARAM_DTIM_PERIOD: 1639* retv = ENETRESET;
1705// if (vap->iv_opmode != IEEE80211_M_HOSTAP && 1640* }
1706// vap->iv_opmode != IEEE80211_M_IBSS) 1641* break;
1707// return -EINVAL; 1642* case IEEE80211_PARAM_DTIM_PERIOD:
1708// if (IEEE80211_DTIM_MIN <= value && 1643* if (vap->iv_opmode != IEEE80211_M_HOSTAP &&
1709// value <= IEEE80211_DTIM_MAX) { 1644* vap->iv_opmode != IEEE80211_M_IBSS)
1710// vap->iv_dtim_period = value; 1645* return -EINVAL;
1711// retv = ENETRESET; /* requires restart */ 1646* if (IEEE80211_DTIM_MIN <= value &&
1712// } else 1647* value <= IEEE80211_DTIM_MAX) {
1713// retv = EINVAL; 1648* vap->iv_dtim_period = value;
1714// break; 1649* retv = ENETRESET; // requires restart
1715// case IEEE80211_PARAM_BEACON_INTERVAL: 1650* } else
1716// if (vap->iv_opmode != IEEE80211_M_HOSTAP && 1651* retv = EINVAL;
1717// vap->iv_opmode != IEEE80211_M_IBSS) 1652* break;
1718// return -EINVAL; 1653* case IEEE80211_PARAM_BEACON_INTERVAL:
1719// if (IEEE80211_BINTVAL_MIN <= value && 1654* if (vap->iv_opmode != IEEE80211_M_HOSTAP &&
1720// value <= IEEE80211_BINTVAL_MAX) { 1655* vap->iv_opmode != IEEE80211_M_IBSS)
1721// ic->ic_lintval = value; /* XXX multi-bss */ 1656* return -EINVAL;
1722// retv = ENETRESET; /* requires restart */ 1657* if (IEEE80211_BINTVAL_MIN <= value &&
1723// } else 1658* value <= IEEE80211_BINTVAL_MAX) {
1724// retv = EINVAL; 1659* ic->ic_lintval = value; // XXX multi-bss
1725// break; 1660* retv = ENETRESET; // requires restart
1726// case IEEE80211_PARAM_DOTH: 1661* } else
1727// if (value) { 1662* retv = EINVAL;
1728// ic->ic_flags |= IEEE80211_F_DOTH; 1663* break;
1729// } 1664* case IEEE80211_PARAM_DOTH:
1730// else 1665* if (value) {
1731// ic->ic_flags &= ~IEEE80211_F_DOTH; 1666* ic->ic_flags |= IEEE80211_F_DOTH;
1732// retv = ENETRESET; /* XXX: need something this drastic? */ 1667* }
1733// break; 1668* else
1734// case IEEE80211_PARAM_PWRTARGET: 1669* ic->ic_flags &= ~IEEE80211_F_DOTH;
1735// ic->ic_curchanmaxpwr = value; 1670* retv = ENETRESET; // XXX: need something this drastic?
1736// break; 1671* break;
1737// case IEEE80211_PARAM_GENREASSOC: 1672* case IEEE80211_PARAM_PWRTARGET:
1738// IEEE80211_SEND_MGMT(vap->iv_bss, IEEE80211_FC0_SUBTYPE_REASSOC_REQ, 0); 1673* ic->ic_curchanmaxpwr = value;
1739// break; 1674* break;
1740// case IEEE80211_PARAM_COMPRESSION: 1675* case IEEE80211_PARAM_GENREASSOC:
1741// retv = ieee80211_setathcap(vap, IEEE80211_ATHC_COMP, value); 1676* IEEE80211_SEND_MGMT(vap->iv_bss,
1742// break; 1677* IEEE80211_FC0_SUBTYPE_REASSOC_REQ, 0);
1743// case IEEE80211_PARAM_WMM_AGGRMODE: 1678* break;
1744// retv = ieee80211_setathcap(vap, IEEE80211_ATHC_WME, value); 1679* case IEEE80211_PARAM_COMPRESSION:
1745// break; 1680* retv = ieee80211_setathcap(vap, IEEE80211_ATHC_COMP, value);
1746// case IEEE80211_PARAM_FF: 1681* break;
1747// retv = ieee80211_setathcap(vap, IEEE80211_ATHC_FF, value); 1682* case IEEE80211_PARAM_WMM_AGGRMODE:
1748// break; 1683* retv = ieee80211_setathcap(vap, IEEE80211_ATHC_WME, value);
1749// case IEEE80211_PARAM_TURBO: 1684* break;
1750// retv = ieee80211_setathcap(vap, IEEE80211_ATHC_TURBOP, value); 1685* case IEEE80211_PARAM_FF:
1751// if (retv == ENETRESET) { 1686* retv = ieee80211_setathcap(vap, IEEE80211_ATHC_FF, value);
1752// if(ieee80211_set_turbo(dev,value)) 1687* break;
1753// return -EINVAL; 1688* case IEEE80211_PARAM_TURBO:
1754// ieee80211_scan_flush(ic); 1689* retv = ieee80211_setathcap(vap, IEEE80211_ATHC_TURBOP, value);
1755// } 1690* if (retv == ENETRESET) {
1756// break; 1691* if(ieee80211_set_turbo(dev,value))
1757// case IEEE80211_PARAM_XR: 1692* return -EINVAL;
1758// retv = ieee80211_setathcap(vap, IEEE80211_ATHC_XR, value); 1693* ieee80211_scan_flush(ic);
1759// break; 1694* }
1760// case IEEE80211_PARAM_BURST: 1695* break;
1761// retv = ieee80211_setathcap(vap, IEEE80211_ATHC_BURST, value); 1696* case IEEE80211_PARAM_XR:
1762// break; 1697* retv = ieee80211_setathcap(vap, IEEE80211_ATHC_XR, value);
1763// case IEEE80211_PARAM_AR: 1698* break;
1764// retv = ieee80211_setathcap(vap, IEEE80211_ATHC_AR, value); 1699* case IEEE80211_PARAM_BURST:
1765// break; 1700* retv = ieee80211_setathcap(vap, IEEE80211_ATHC_BURST, value);
1766// case IEEE80211_PARAM_PUREG: 1701* break;
1767// if (value) 1702* case IEEE80211_PARAM_AR:
1768// vap->iv_flags |= IEEE80211_F_PUREG; 1703* retv = ieee80211_setathcap(vap, IEEE80211_ATHC_AR, value);
1769// else 1704* break;
1770// vap->iv_flags &= ~IEEE80211_F_PUREG; 1705* case IEEE80211_PARAM_PUREG:
1771// /* NB: reset only if we're operating on an 11g channel */ 1706* if (value)
1772// if (ic->ic_bsschan != IEEE80211_CHAN_ANYC && 1707* vap->iv_flags |= IEEE80211_F_PUREG;
1773// IEEE80211_IS_CHAN_ANYG(ic->ic_bsschan)) 1708* else
1774// retv = ENETRESET; 1709* vap->iv_flags &= ~IEEE80211_F_PUREG;
1775// break; 1710* // NB: reset only if we're operating on an 11g channel
1776// case IEEE80211_PARAM_WDS: 1711* if (ic->ic_bsschan != IEEE80211_CHAN_ANYC &&
1777// if (value) 1712* IEEE80211_IS_CHAN_ANYG(ic->ic_bsschan))
1778// vap->iv_flags_ext |= IEEE80211_FEXT_WDS; 1713* retv = ENETRESET;
1779// else 1714* break;
1780// vap->iv_flags_ext &= ~IEEE80211_FEXT_WDS; 1715* case IEEE80211_PARAM_WDS:
1781// break; 1716* if (value)
1782// case IEEE80211_PARAM_BGSCAN: 1717* vap->iv_flags_ext |= IEEE80211_FEXT_WDS;
1783// if (value) { 1718* else
1784// if ((vap->iv_caps & IEEE80211_C_BGSCAN) == 0) 1719* vap->iv_flags_ext &= ~IEEE80211_FEXT_WDS;
1785// return -EINVAL; 1720* break;
1786// vap->iv_flags |= IEEE80211_F_BGSCAN; 1721* case IEEE80211_PARAM_BGSCAN:
1787// } else { 1722* if (value) {
1788// /* XXX racey? */ 1723* if ((vap->iv_caps & IEEE80211_C_BGSCAN) == 0)
1789// vap->iv_flags &= ~IEEE80211_F_BGSCAN; 1724* return -EINVAL;
1790// ieee80211_cancel_scan(vap); /* anything current */ 1725* vap->iv_flags |= IEEE80211_F_BGSCAN;
1791// } 1726* } else {
1792// break; 1727* // XXX racey?
1793// case IEEE80211_PARAM_BGSCAN_IDLE: 1728* vap->iv_flags &= ~IEEE80211_F_BGSCAN;
1794// if (value >= IEEE80211_BGSCAN_IDLE_MIN) 1729* ieee80211_cancel_scan(vap); // anything current
1795// vap->iv_bgscanidle = value*HZ/1000; 1730* }
1796// else 1731* break;
1797// retv = EINVAL; 1732* case IEEE80211_PARAM_BGSCAN_IDLE:
1798// break; 1733* if (value >= IEEE80211_BGSCAN_IDLE_MIN)
1799// case IEEE80211_PARAM_BGSCAN_INTERVAL: 1734* vap->iv_bgscanidle = value*HZ/1000;
1800// if (value >= IEEE80211_BGSCAN_INTVAL_MIN) 1735* else
1801// vap->iv_bgscanintvl = value*HZ; 1736* retv = EINVAL;
1802// else 1737* break;
1803// retv = EINVAL; 1738* case IEEE80211_PARAM_BGSCAN_INTERVAL:
1804// break; 1739* if (value >= IEEE80211_BGSCAN_INTVAL_MIN)
1805// case IEEE80211_PARAM_MCAST_RATE: 1740* vap->iv_bgscanintvl = value*HZ;
1806// /* units are in KILObits per second */ 1741* else
1807// if (value >= 256 && value <= 54000) 1742* retv = EINVAL;
1808// vap->iv_mcast_rate = value; 1743* break;
1809// else 1744* case IEEE80211_PARAM_MCAST_RATE:
1810// retv = EINVAL; 1745* // units are in KILObits per second
1811// break; 1746* if (value >= 256 && value <= 54000)
1812// case IEEE80211_PARAM_COVERAGE_CLASS: 1747* vap->iv_mcast_rate = value;
1813// if (value >= 0 && value <= IEEE80211_COVERAGE_CLASS_MAX) { 1748* else
1814// ic->ic_coverageclass = value; 1749* retv = EINVAL;
1815// if (IS_UP_AUTO(vap)) 1750* break;
1816// ieee80211_new_state(vap, IEEE80211_S_SCAN, 0); 1751* case IEEE80211_PARAM_COVERAGE_CLASS:
1817// retv = 0; 1752* if (value >= 0 && value <= IEEE80211_COVERAGE_CLASS_MAX) {
1818// } 1753* ic->ic_coverageclass = value;
1819// else 1754* if (IS_UP_AUTO(vap))
1820// retv = EINVAL; 1755* ieee80211_new_state(vap, IEEE80211_S_SCAN, 0);
1821// break; 1756* retv = 0;
1822// case IEEE80211_PARAM_COUNTRY_IE: 1757* }
1823// if (value) 1758* else
1824// ic->ic_flags_ext |= IEEE80211_FEXT_COUNTRYIE; 1759* retv = EINVAL;
1825// else 1760* break;
1826// ic->ic_flags_ext &= ~IEEE80211_FEXT_COUNTRYIE; 1761* case IEEE80211_PARAM_COUNTRY_IE:
1827// retv = ENETRESET; 1762* if (value)
1828// break; 1763* ic->ic_flags_ext |= IEEE80211_FEXT_COUNTRYIE;
1829// case IEEE80211_PARAM_REGCLASS: 1764* else
1830// if (value) 1765* ic->ic_flags_ext &= ~IEEE80211_FEXT_COUNTRYIE;
1831// ic->ic_flags_ext |= IEEE80211_FEXT_REGCLASS; 1766* retv = ENETRESET;
1832// else 1767* break;
1833// ic->ic_flags_ext &= ~IEEE80211_FEXT_REGCLASS; 1768* case IEEE80211_PARAM_REGCLASS:
1834// retv = ENETRESET; 1769* if (value)
1835// break; 1770* ic->ic_flags_ext |= IEEE80211_FEXT_REGCLASS;
1836// case IEEE80211_PARAM_SCANVALID: 1771* else
1837// vap->iv_scanvalid = value*HZ; 1772* ic->ic_flags_ext &= ~IEEE80211_FEXT_REGCLASS;
1838// break; 1773* retv = ENETRESET;
1839// case IEEE80211_PARAM_ROAM_RSSI_11A: 1774* break;
1840// vap->iv_roam.rssi11a = value; 1775* case IEEE80211_PARAM_SCANVALID:
1841// break; 1776* vap->iv_scanvalid = value*HZ;
1842// case IEEE80211_PARAM_ROAM_RSSI_11B: 1777* break;
1843// vap->iv_roam.rssi11bOnly = value; 1778* case IEEE80211_PARAM_ROAM_RSSI_11A:
1844// break; 1779* vap->iv_roam.rssi11a = value;
1845// case IEEE80211_PARAM_ROAM_RSSI_11G: 1780* break;
1846// vap->iv_roam.rssi11b = value; 1781* case IEEE80211_PARAM_ROAM_RSSI_11B:
1847// break; 1782* vap->iv_roam.rssi11bOnly = value;
1848// case IEEE80211_PARAM_ROAM_RATE_11A: 1783* break;
1849// vap->iv_roam.rate11a = value; 1784* case IEEE80211_PARAM_ROAM_RSSI_11G:
1850// break; 1785* vap->iv_roam.rssi11b = value;
1851// case IEEE80211_PARAM_ROAM_RATE_11B: 1786* break;
1852// vap->iv_roam.rate11bOnly = value; 1787* case IEEE80211_PARAM_ROAM_RATE_11A:
1853// break; 1788* vap->iv_roam.rate11a = value;
1854// case IEEE80211_PARAM_ROAM_RATE_11G: 1789* break;
1855// vap->iv_roam.rate11b = value; 1790* case IEEE80211_PARAM_ROAM_RATE_11B:
1856// break; 1791* vap->iv_roam.rate11bOnly = value;
1857// case IEEE80211_PARAM_UAPSDINFO: 1792* break;
1858// if (vap->iv_opmode == IEEE80211_M_HOSTAP) { 1793* case IEEE80211_PARAM_ROAM_RATE_11G:
1859// if (ic->ic_caps & IEEE80211_C_UAPSD) { 1794* vap->iv_roam.rate11b = value;
1860// if (value) 1795* break;
1861// IEEE80211_VAP_UAPSD_ENABLE(vap); 1796* case IEEE80211_PARAM_UAPSDINFO:
1862// else 1797* if (vap->iv_opmode == IEEE80211_M_HOSTAP) {
1863// IEEE80211_VAP_UAPSD_DISABLE(vap); 1798* if (ic->ic_caps & IEEE80211_C_UAPSD) {
1864// retv = ENETRESET; 1799* if (value)
1865// } 1800* IEEE80211_VAP_UAPSD_ENABLE(vap);
1866// } 1801* else
1867// else if (vap->iv_opmode == IEEE80211_M_STA) { 1802* IEEE80211_VAP_UAPSD_DISABLE(vap);
1868// vap->iv_uapsdinfo = value; 1803* retv = ENETRESET;
1869// IEEE80211_VAP_UAPSD_ENABLE(vap); 1804* }
1870// retv = ENETRESET; 1805* }
1871// } 1806* else if (vap->iv_opmode == IEEE80211_M_STA) {
1872// break; 1807* vap->iv_uapsdinfo = value;
1873// case IEEE80211_PARAM_SLEEP: 1808* IEEE80211_VAP_UAPSD_ENABLE(vap);
1874// /* XXX: Forced sleep for testing. Does not actually place the 1809* retv = ENETRESET;
1875// * HW in sleep mode yet. this only makes sense for STAs. 1810* }
1876// */ 1811* break;
1877// if (value) { 1812* case IEEE80211_PARAM_SLEEP:
1878// /* goto sleep */ 1813* // XXX: Forced sleep for testing. Does not actually place the
1879// IEEE80211_VAP_GOTOSLEEP(vap); 1814* // HW in sleep mode yet. this only makes sense for STAs.
1880// } 1815*
1881// else { 1816* if (value) {
1882// /* wakeup */ 1817* // goto sleep
1883// IEEE80211_VAP_WAKEUP(vap); 1818* IEEE80211_VAP_GOTOSLEEP(vap);
1884// } 1819* }
1885// ieee80211_send_nulldata(ieee80211_ref_node(vap->iv_bss)); 1820* else {
1886// break; 1821* // wakeup
1887// case IEEE80211_PARAM_QOSNULL: 1822* IEEE80211_VAP_WAKEUP(vap);
1888// /* Force a QoS Null for testing. */ 1823* }
1889// ieee80211_send_qosnulldata(vap->iv_bss, value); 1824* ieee80211_send_nulldata(ieee80211_ref_node(vap->iv_bss));
1890// break; 1825* break;
1891// case IEEE80211_PARAM_PSPOLL: 1826* case IEEE80211_PARAM_QOSNULL:
1892// /* Force a PS-POLL for testing. */ 1827* // Force a QoS Null for testing.
1893// ieee80211_send_pspoll(vap->iv_bss); 1828* ieee80211_send_qosnulldata(vap->iv_bss, value);
1894// break; 1829* break;
1895// case IEEE80211_PARAM_EOSPDROP: 1830* case IEEE80211_PARAM_PSPOLL:
1896// if (vap->iv_opmode == IEEE80211_M_HOSTAP) { 1831* // Force a PS-POLL for testing.
1897// if (value) IEEE80211_VAP_EOSPDROP_ENABLE(vap); 1832* ieee80211_send_pspoll(vap->iv_bss);
1898// else IEEE80211_VAP_EOSPDROP_DISABLE(vap); 1833* break;
1899// } 1834* case IEEE80211_PARAM_EOSPDROP:
1900// break; 1835* if (vap->iv_opmode == IEEE80211_M_HOSTAP) {
1901// case IEEE80211_PARAM_MARKDFS: 1836* if (value) IEEE80211_VAP_EOSPDROP_ENABLE(vap);
1902// if (value) 1837* else IEEE80211_VAP_EOSPDROP_DISABLE(vap);
1903// ic->ic_flags_ext |= IEEE80211_FEXT_MARKDFS; 1838* }
1904// else 1839* break;
1905// ic->ic_flags_ext &= ~IEEE80211_FEXT_MARKDFS; 1840* case IEEE80211_PARAM_MARKDFS:
1906// break; 1841* if (value)
1907// case IEEE80211_PARAM_CHANBW: 1842* ic->ic_flags_ext |= IEEE80211_FEXT_MARKDFS;
1908// switch (value) { 1843* else
1909// case 0: 1844* ic->ic_flags_ext &= ~IEEE80211_FEXT_MARKDFS;
1910// ic->ic_chanbwflag = 0; 1845* break;
1911// break; 1846* case IEEE80211_PARAM_CHANBW:
1912// case 1: 1847* switch (value) {
1913// ic->ic_chanbwflag = IEEE80211_CHAN_HALF; 1848* case 0:
1914// break; 1849* ic->ic_chanbwflag = 0;
1915// case 2: 1850* break;
1916// ic->ic_chanbwflag = IEEE80211_CHAN_QUARTER; 1851* case 1:
1917// break; 1852* ic->ic_chanbwflag = IEEE80211_CHAN_HALF;
1918// default: 1853* break;
1919// retv = EINVAL; 1854* case 2:
1920// break; 1855* ic->ic_chanbwflag = IEEE80211_CHAN_QUARTER;
1921// } 1856* break;
1922// break; 1857* default:
1923// case IEEE80211_PARAM_SHORTPREAMBLE: 1858* retv = EINVAL;
1924// if (value) { 1859* break;
1925// ic->ic_caps |= IEEE80211_C_SHPREAMBLE; 1860* }
1926// } else { 1861* break;
1927// ic->ic_caps &= ~IEEE80211_C_SHPREAMBLE; 1862* case IEEE80211_PARAM_SHORTPREAMBLE:
1928// } 1863* if (value) {
1929// retv = ENETRESET; 1864* ic->ic_caps |= IEEE80211_C_SHPREAMBLE;
1930// break; 1865* } else {
1931// default: 1866* ic->ic_caps &= ~IEEE80211_C_SHPREAMBLE;
1932// retv = EOPNOTSUPP; 1867* }
1933// break; 1868* retv = ENETRESET;
1934// } 1869* break;
1935// /* XXX should any of these cause a rescan? */ 1870* default:
1936// if (retv == ENETRESET) 1871* retv = EOPNOTSUPP;
1937// retv = IS_UP_AUTO(vap) ? ieee80211_open(vap->iv_dev) : 0; 1872* break;
1938// return -retv; 1873* }
1939//} 1874* // XXX should any of these cause a rescan?
1875* if (retv == ENETRESET)
1876* retv = IS_UP_AUTO(vap) ? ieee80211_open(vap->iv_dev) : 0;
1877* return -retv;
1878*}
1879*/
1940 1880
1941int usbdrvwext_setmode(struct net_device *dev, struct iw_request_info *info, 1881int usbdrvwext_setmode(struct net_device *dev, struct iw_request_info *info,
1942 void *w, char *extra) 1882 void *w, char *extra)
1943{ 1883{
1944 return 0; 1884 return 0;
1945} 1885}
@@ -1947,158 +1887,138 @@ int usbdrvwext_setmode(struct net_device *dev, struct iw_request_info *info,
1947int usbdrvwext_getmode(struct net_device *dev, struct iw_request_info *info, 1887int usbdrvwext_getmode(struct net_device *dev, struct iw_request_info *info,
1948 void *w, char *extra) 1888 void *w, char *extra)
1949{ 1889{
1950 //struct usbdrv_private *macp = dev->ml_priv; 1890 /* struct usbdrv_private *macp = dev->ml_priv; */
1951 struct iw_point *wri = (struct iw_point *)extra; 1891 struct iw_point *wri = (struct iw_point *)extra;
1952 char mode[8]; 1892 char mode[8];
1953 1893
1954 strcpy(mode,"11g"); 1894 strcpy(mode, "11g");
1955 return (copy_to_user(wri->pointer, mode, 6) ? -EFAULT : 0); 1895 return copy_to_user(wri->pointer, mode, 6) ? -EFAULT : 0;
1956} 1896}
1957 1897
1958int zfLnxPrivateIoctl(struct net_device *dev, struct zdap_ioctl* zdreq) 1898int zfLnxPrivateIoctl(struct net_device *dev, struct zdap_ioctl* zdreq)
1959{ 1899{
1960 //void* regp = macp->regp; 1900 /* void* regp = macp->regp; */
1961 u16_t cmd; 1901 u16_t cmd;
1962 //u32_t temp; 1902 /* u32_t temp; */
1963 u32_t* p; 1903 u32_t *p;
1964 u32_t i; 1904 u32_t i;
1965 1905
1966 cmd = zdreq->cmd; 1906 cmd = zdreq->cmd;
1967 switch(cmd) 1907 switch (cmd) {
1968 {
1969 case ZM_IOCTL_REG_READ: 1908 case ZM_IOCTL_REG_READ:
1970 zfiDbgReadReg(dev, zdreq->addr); 1909 zfiDbgReadReg(dev, zdreq->addr);
1971 break; 1910 break;
1972
1973 case ZM_IOCTL_REG_WRITE: 1911 case ZM_IOCTL_REG_WRITE:
1974 zfiDbgWriteReg(dev, zdreq->addr, zdreq->value); 1912 zfiDbgWriteReg(dev, zdreq->addr, zdreq->value);
1975 break; 1913 break;
1976
1977 case ZM_IOCTL_MEM_READ: 1914 case ZM_IOCTL_MEM_READ:
1978 p = (u32_t *) bus_to_virt(zdreq->addr); 1915 p = (u32_t *) bus_to_virt(zdreq->addr);
1979 printk(KERN_DEBUG "usbdrv: read memory addr: 0x%08x value: 0x%08x\n", zdreq->addr, *p); 1916 printk(KERN_WARNING
1917 "usbdrv: read memory addr: 0x%08x value:"
1918 " 0x%08x\n", zdreq->addr, *p);
1980 break; 1919 break;
1981
1982 case ZM_IOCTL_MEM_WRITE: 1920 case ZM_IOCTL_MEM_WRITE:
1983 p = (u32_t *) bus_to_virt(zdreq->addr); 1921 p = (u32_t *) bus_to_virt(zdreq->addr);
1984 *p = zdreq->value; 1922 *p = zdreq->value;
1985 printk(KERN_DEBUG "usbdrv: write value: 0x%08x to memory addr: 0x%08x\n", zdreq->value, zdreq->addr); 1923 printk(KERN_WARNING
1924 "usbdrv : write value : 0x%08x to memory addr :"
1925 " 0x%08x\n", zdreq->value, zdreq->addr);
1986 break; 1926 break;
1987 1927 case ZM_IOCTL_TALLY:
1988 case ZM_IOCTL_TALLY :
1989 zfiWlanShowTally(dev); 1928 zfiWlanShowTally(dev);
1990 if (zdreq->addr) 1929 if (zdreq->addr)
1991 zfiWlanResetTally(dev); 1930 zfiWlanResetTally(dev);
1992 break; 1931 break;
1932 case ZM_IOCTL_TEST:
1933 printk(KERN_WARNING
1934 "ZM_IOCTL_TEST:len=%d\n", zdreq->addr);
1935 /* zfiWlanReadReg(dev, 0x10f400); */
1936 /* zfiWlanReadReg(dev, 0x10f404); */
1937 printk(KERN_WARNING "IOCTL TEST\n");
1938 #if 1
1939 /* print packet */
1940 for (i = 0; i < zdreq->addr; i++) {
1941 if ((i&0x7) == 0)
1942 printk(KERN_WARNING "\n");
1943 printk(KERN_WARNING "%02X ",
1944 (unsigned char)zdreq->data[i]);
1945 }
1946 printk(KERN_WARNING "\n");
1947 #endif
1948
1949 /* For Test?? 1 to 0 by CWYang(-) */
1950 #if 0
1951 struct sk_buff *s;
1952
1953 /* Allocate a skb */
1954 s = alloc_skb(2000, GFP_ATOMIC);
1993 1955
1994 case ZM_IOCTL_TEST : 1956 /* Copy data to skb */
1995 printk(KERN_DEBUG "ZM_IOCTL_TEST:len=%d\n", zdreq->addr); 1957 for (i = 0; i < zdreq->addr; i++)
1996 //zfiWlanReadReg(dev, 0x10f400); 1958 s->data[i] = zdreq->data[i];
1997 //zfiWlanReadReg(dev, 0x10f404); 1959 s->len = zdreq->addr;
1998 printk("IOCTL TEST\n");
1999 #if 1
2000 //print packet
2001 for (i=0; i<zdreq->addr; i++)
2002 {
2003 if ((i&0x7) == 0)
2004 {
2005 printk("\n");
2006 }
2007 printk("%02X ", (unsigned char)zdreq->data[i]);
2008 }
2009 printk("\n");
2010 #endif
2011
2012
2013 #if 0 //For Test?? 1 to 0 by CWYang(-)
2014 {
2015 struct sk_buff* s;
2016
2017 /* Allocate a skb */
2018 s = alloc_skb(2000, GFP_ATOMIC);
2019
2020 /* Copy data to skb */
2021 for (i=0; i<zdreq->addr; i++)
2022 {
2023 s->data[i] = zdreq->data[i];
2024 }
2025 s->len = zdreq->addr;
2026
2027 /* Call zfIdlRecv() */
2028 zfiRecv80211(dev, s, NULL);
2029 }
2030 #endif
2031
2032 break;
2033
2034
2035/****************************** ZDCONFIG ******************************/
2036 case ZM_IOCTL_FRAG :
2037 zfiWlanSetFragThreshold(dev, zdreq->addr);
2038 break;
2039
2040 case ZM_IOCTL_RTS :
2041 zfiWlanSetRtsThreshold(dev, zdreq->addr);
2042 break;
2043
2044 case ZM_IOCTL_SCAN :
2045 zfiWlanScan(dev);
2046 break;
2047
2048 case ZM_IOCTL_KEY :
2049 {
2050 u8_t key[29];
2051 struct zsKeyInfo keyInfo;
2052 u32_t i;
2053
2054 for (i=0; i<29; i++)
2055 {
2056 key[i] = 0;
2057 }
2058
2059 for (i=0; i<zdreq->addr; i++)
2060 {
2061 key[i] = zdreq->data[i];
2062 }
2063
2064 printk("key len=%d, key=%02x%02x%02x%02x%02x...\n",
2065 zdreq->addr, key[0], key[1], key[2], key[3], key[4]);
2066
2067 keyInfo.keyLength = zdreq->addr;
2068 keyInfo.keyIndex = 0;
2069 keyInfo.flag = 0;
2070 keyInfo.key = key;
2071 zfiWlanSetKey(dev, keyInfo);
2072 }
2073 break;
2074
2075 case ZM_IOCTL_RATE :
2076 zfiWlanSetTxRate(dev, zdreq->addr);
2077 break;
2078
2079 case ZM_IOCTL_ENCRYPTION_MODE :
2080 zfiWlanSetEncryMode(dev, zdreq->addr);
2081
2082 zfiWlanDisable(dev, 0);
2083 zfiWlanEnable(dev);
2084 break;
2085 //CWYang(+)
2086 case ZM_IOCTL_SIGNAL_STRENGTH :
2087 {
2088 u8_t buffer[2];
2089 zfiWlanQuerySignalInfo(dev, &buffer[0]);
2090 printk("Current Signal Strength : %02d\n", buffer[0]);
2091 }
2092 break;
2093 //CWYang(+)
2094 case ZM_IOCTL_SIGNAL_QUALITY :
2095 {
2096 u8_t buffer[2];
2097 zfiWlanQuerySignalInfo(dev, &buffer[0]);
2098 printk("Current Signal Quality : %02d\n", buffer[1]);
2099 }
2100 break;
2101 1960
1961 /* Call zfIdlRecv() */
1962 zfiRecv80211(dev, s, NULL);
1963 #endif
1964 break;
1965 /************************* ZDCONFIG ***************************/
1966 case ZM_IOCTL_FRAG:
1967 zfiWlanSetFragThreshold(dev, zdreq->addr);
1968 break;
1969 case ZM_IOCTL_RTS:
1970 zfiWlanSetRtsThreshold(dev, zdreq->addr);
1971 break;
1972 case ZM_IOCTL_SCAN:
1973 zfiWlanScan(dev);
1974 break;
1975 case ZM_IOCTL_KEY: {
1976 u8_t key[29];
1977 struct zsKeyInfo keyInfo;
1978 u32_t i;
1979
1980 for (i = 0; i < 29; i++)
1981 key[i] = 0;
1982
1983 for (i = 0; i < zdreq->addr; i++)
1984 key[i] = zdreq->data[i];
1985
1986 printk(KERN_WARNING
1987 "key len=%d, key=%02x%02x%02x%02x%02x...\n",
1988 zdreq->addr, key[0], key[1], key[2], key[3], key[4]);
1989
1990 keyInfo.keyLength = zdreq->addr;
1991 keyInfo.keyIndex = 0;
1992 keyInfo.flag = 0;
1993 keyInfo.key = key;
1994 zfiWlanSetKey(dev, keyInfo);
1995 }
1996 break;
1997 case ZM_IOCTL_RATE:
1998 zfiWlanSetTxRate(dev, zdreq->addr);
1999 break;
2000 case ZM_IOCTL_ENCRYPTION_MODE:
2001 zfiWlanSetEncryMode(dev, zdreq->addr);
2002
2003 zfiWlanDisable(dev, 0);
2004 zfiWlanEnable(dev);
2005 break;
2006 /* CWYang(+) */
2007 case ZM_IOCTL_SIGNAL_STRENGTH: {
2008 u8_t buffer[2];
2009 zfiWlanQuerySignalInfo(dev, &buffer[0]);
2010 printk(KERN_WARNING
2011 "Current Signal Strength : %02d\n", buffer[0]);
2012 }
2013 break;
2014 /* CWYang(+) */
2015 case ZM_IOCTL_SIGNAL_QUALITY: {
2016 u8_t buffer[2];
2017 zfiWlanQuerySignalInfo(dev, &buffer[0]);
2018 printk(KERN_WARNING
2019 "Current Signal Quality : %02d\n", buffer[1]);
2020 }
2021 break;
2102 case ZM_IOCTL_SET_PIBSS_MODE: 2022 case ZM_IOCTL_SET_PIBSS_MODE:
2103 if (zdreq->addr == 1) 2023 if (zdreq->addr == 1)
2104 zfiWlanSetWlanMode(dev, ZM_MODE_PSEUDO); 2024 zfiWlanSetWlanMode(dev, ZM_MODE_PSEUDO);
@@ -2107,11 +2027,9 @@ int zfLnxPrivateIoctl(struct net_device *dev, struct zdap_ioctl* zdreq)
2107 2027
2108 zfiWlanDisable(dev, 0); 2028 zfiWlanDisable(dev, 0);
2109 zfiWlanEnable(dev); 2029 zfiWlanEnable(dev);
2110
2111 break; 2030 break;
2112/****************************** ZDCONFIG ******************************/ 2031 /********************* ZDCONFIG ***********************/
2113 2032 default:
2114 default :
2115 printk(KERN_ERR "usbdrv: error command = %x\n", cmd); 2033 printk(KERN_ERR "usbdrv: error command = %x\n", cmd);
2116 break; 2034 break;
2117 } 2035 }
@@ -2121,793 +2039,736 @@ int zfLnxPrivateIoctl(struct net_device *dev, struct zdap_ioctl* zdreq)
2121 2039
2122int usbdrv_wpa_ioctl(struct net_device *dev, struct athr_wlan_param *zdparm) 2040int usbdrv_wpa_ioctl(struct net_device *dev, struct athr_wlan_param *zdparm)
2123{ 2041{
2124 int ret = 0; 2042 int ret = 0;
2125 u8_t bc_addr[6] = { 0xff, 0xff, 0xff, 0xff, 0xff, 0xff }; 2043 u8_t bc_addr[6] = { 0xff, 0xff, 0xff, 0xff, 0xff, 0xff };
2126 u8_t mac_addr[80]; 2044 u8_t mac_addr[80];
2127 struct zsKeyInfo keyInfo; 2045 struct zsKeyInfo keyInfo;
2128 struct usbdrv_private *macp = dev->ml_priv; 2046 struct usbdrv_private *macp = dev->ml_priv;
2129 u16_t vapId = 0; 2047 u16_t vapId = 0;
2130 2048
2131 //zmw_get_wlan_dev(dev); 2049 /* zmw_get_wlan_dev(dev); */
2132 2050
2133 switch(zdparm->cmd) 2051 switch (zdparm->cmd) {
2134 { 2052 case ZD_CMD_SET_ENCRYPT_KEY:
2135 case ZD_CMD_SET_ENCRYPT_KEY: 2053 /* Set up key information */
2136 2054 keyInfo.keyLength = zdparm->u.crypt.key_len;
2137 /* Set up key information */ 2055 keyInfo.keyIndex = zdparm->u.crypt.idx;
2138 keyInfo.keyLength = zdparm->u.crypt.key_len; 2056 if (zfiWlanQueryWlanMode(dev) == ZM_MODE_AP) {
2139 keyInfo.keyIndex = zdparm->u.crypt.idx; 2057 /* AP Mode */
2140 if (zfiWlanQueryWlanMode(dev) == ZM_MODE_AP) // AP Mode 2058 keyInfo.flag = ZM_KEY_FLAG_AUTHENTICATOR;
2141 keyInfo.flag = ZM_KEY_FLAG_AUTHENTICATOR; 2059 } else
2142 else 2060 keyInfo.flag = 0;
2143 keyInfo.flag = 0; 2061 keyInfo.key = zdparm->u.crypt.key;
2144 keyInfo.key = zdparm->u.crypt.key; 2062 keyInfo.initIv = zdparm->u.crypt.seq;
2145 keyInfo.initIv = zdparm->u.crypt.seq; 2063 keyInfo.macAddr = (u16_t *)zdparm->sta_addr;
2146 keyInfo.macAddr = (u16_t *)zdparm->sta_addr; 2064
2147 2065 /* Identify the MAC address information */
2148 /* Identify the MAC address information */ 2066 if (memcmp(zdparm->sta_addr, bc_addr, sizeof(bc_addr)) == 0)
2149 if (memcmp(zdparm->sta_addr, bc_addr, sizeof(bc_addr)) == 0) 2067 keyInfo.flag |= ZM_KEY_FLAG_GK;
2150 { 2068 else
2151 keyInfo.flag |= ZM_KEY_FLAG_GK; 2069 keyInfo.flag |= ZM_KEY_FLAG_PK;
2152 } 2070
2153 else 2071 if (!strcmp(zdparm->u.crypt.alg, "NONE")) {
2154 { 2072 /* u8_t zero_mac[]={0,0,0,0,0,0}; */
2155 keyInfo.flag |= ZM_KEY_FLAG_PK; 2073
2156 } 2074 /* Set key length to zero */
2157 2075 keyInfo.keyLength = 0;
2158 if (!strcmp(zdparm->u.crypt.alg, "NONE")) 2076
2159 { 2077 /* del group key */
2160 //u8_t zero_mac[]={0,0,0,0,0,0}; 2078 if (zdparm->sta_addr[0] & 1) {
2161 2079 /* if (macp->cardSetting.WPAIeLen==0)
2162 /* Set key length to zero */ 2080 * { 802.1x dynamic WEP
2163 keyInfo.keyLength = 0; 2081 * mDynKeyMode = 0;
2164 2082 * mKeyFormat[0] = 0;
2165 if (zdparm->sta_addr[0] & 1)//del group key 2083 * mPrivacyInvoked[0]=FALSE;
2166 { 2084 * mCap[0] &= ~CAP_PRIVACY;
2167 //if (macp->cardSetting.WPAIeLen==0) 2085 * macp->cardSetting.EncryOnOff[0]=0;
2168 //{//802.1x dynamic WEP 2086 * }
2169 // mDynKeyMode = 0; 2087 * mWpaBcKeyLen = mGkInstalled = 0;
2170 // mKeyFormat[0] = 0; 2088 */
2171 // mPrivacyInvoked[0]=FALSE; 2089 } else {
2172 // mCap[0] &= ~CAP_PRIVACY; 2090 /* if (memcmp(zero_mac,zdparm->sta_addr, 6)==0)
2173 // macp->cardSetting.EncryOnOff[0]=0; 2091 * {
2174 //} 2092 * mDynKeyMode=0;
2175 //mWpaBcKeyLen = mGkInstalled = 0; 2093 * mKeyFormat[0]=0;
2176 } 2094 * pSetting->DynKeyMode=0;
2177 else 2095 * pSetting->EncryMode[0]=0;
2178 { 2096 * mDynKeyMode=0;
2179 //if (memcmp(zero_mac,zdparm->sta_addr, 6)==0) 2097 * }
2180 //{ 2098 */
2181 // mDynKeyMode=0; 2099 }
2182 // mKeyFormat[0]=0; 2100
2183 // pSetting->DynKeyMode=0; 2101 printk(KERN_ERR "Set Encryption Type NONE\n");
2184 // pSetting->EncryMode[0]=0; 2102 return ret;
2185 // mDynKeyMode=0; 2103 } else if (!strcmp(zdparm->u.crypt.alg, "TKIP")) {
2186 //} 2104 zfiWlanSetEncryMode(dev, ZM_TKIP);
2187 } 2105 /* //Linux Supplicant will inverse Tx/Rx key
2188 2106 * //So we inverse it back, CWYang(+)
2189 printk(KERN_ERR "Set Encryption Type NONE\n"); 2107 * zfMemoryCopy(&temp[0], &keyInfo.key[16], 8);
2190 return ret; 2108 * zfMemoryCopy(&keyInfo.key[16], keyInfo.key[24], 8);
2191 } 2109 * zfMemoryCopy(&keyInfo.key[24], &temp[0], 8);
2192 else if (!strcmp(zdparm->u.crypt.alg, "TKIP")) 2110 * u8_t temp;
2193 { 2111 * int k;
2194 zfiWlanSetEncryMode(dev, ZM_TKIP); 2112 * for (k = 0; k < 8; k++)
2195 //Linux Supplicant will inverse Tx/Rx key 2113 * {
2196 //So we inverse it back //CWYang(+) 2114 * temp = keyInfo.key[16 + k];
2197 //zfMemoryCopy(&temp[0], &keyInfo.key[16], 8); 2115 * keyInfo.key[16 + k] = keyInfo.key[24 + k];
2198 //zfMemoryCopy(&keyInfo.key[16], keyInfo.key[24], 8); 2116 * keyInfo.key[24 + k] = temp;
2199 //zfMemoryCopy(&keyInfo.key[24], &temp[0], 8); 2117 * }
2200 //u8_t temp; 2118 * CamEncryType = ZM_TKIP;
2201 //int k; 2119 * if (idx == 0)
2202 //for (k = 0; k < 8; k++) 2120 * { // Pairwise key
2203 //{ 2121 * mKeyFormat[0] = CamEncryType;
2204 // temp = keyInfo.key[16 + k]; 2122 * mDynKeyMode = pSetting->DynKeyMode = DYN_KEY_TKIP;
2205 // keyInfo.key[16 + k] = keyInfo.key[24 + k]; 2123 * }
2206 // keyInfo.key[24 + k] = temp; 2124 */
2207 //} 2125 } else if (!strcmp(zdparm->u.crypt.alg, "CCMP")) {
2208 //CamEncryType = ZM_TKIP; 2126 zfiWlanSetEncryMode(dev, ZM_AES);
2209 ////if (idx == 0) 2127 /* CamEncryType = ZM_AES;
2210 //{// Pairwise key 2128 * if (idx == 0)
2211 // mKeyFormat[0] = CamEncryType; 2129 * { // Pairwise key
2212 // mDynKeyMode = pSetting->DynKeyMode = DYN_KEY_TKIP; 2130 * mKeyFormat[0] = CamEncryType;
2213 //} 2131 * mDynKeyMode = pSetting->DynKeyMode = DYN_KEY_AES;
2214 } 2132 * }
2215 else if (!strcmp(zdparm->u.crypt.alg, "CCMP")) 2133 */
2216 { 2134 } else if (!strcmp(zdparm->u.crypt.alg, "WEP")) {
2217 zfiWlanSetEncryMode(dev, ZM_AES); 2135 if (keyInfo.keyLength == 5) {
2218 //CamEncryType = ZM_AES; 2136 /* WEP 64 */
2219 ////if (idx == 0) 2137 zfiWlanSetEncryMode(dev, ZM_WEP64);
2220 //{// Pairwise key 2138 /* CamEncryType = ZM_WEP64; */
2221 // mKeyFormat[0] = CamEncryType; 2139 /* tmpDynKeyMode=DYN_KEY_WEP64; */
2222 // mDynKeyMode = pSetting->DynKeyMode = DYN_KEY_AES; 2140 } else if (keyInfo.keyLength == 13) {
2223 //} 2141 /* keylen=13, WEP 128 */
2224 } 2142 zfiWlanSetEncryMode(dev, ZM_WEP128);
2225 else if (!strcmp(zdparm->u.crypt.alg, "WEP")) 2143 /* CamEncryType = ZM_WEP128; */
2226 { 2144 /* tmpDynKeyMode=DYN_KEY_WEP128; */
2227 if (keyInfo.keyLength == 5) 2145 } else {
2228 { // WEP 64 2146 zfiWlanSetEncryMode(dev, ZM_WEP256);
2229 zfiWlanSetEncryMode(dev, ZM_WEP64); 2147 }
2230 // CamEncryType = ZM_WEP64; 2148
2231 // tmpDynKeyMode=DYN_KEY_WEP64; 2149 /* For Dynamic WEP key (Non-WPA Radius), the key ID range: 0-3
2232 } 2150 * In WPA/RSN mode, the key ID range: 1-3, usually, a broadcast key.
2233 else if (keyInfo.keyLength == 13) 2151 * For WEP key setting: we set mDynKeyMode and mKeyFormat in following
2234 {//keylen=13, WEP 128 2152 * case:
2235 zfiWlanSetEncryMode(dev, ZM_WEP128); 2153 * 1. For 802.1x dynamically generated WEP key method.
2236 // CamEncryType = ZM_WEP128; 2154 * 2. For WPA/RSN mode, but key id == 0.
2237 // tmpDynKeyMode=DYN_KEY_WEP128; 2155 * (But this is an impossible case)
2238 } 2156 * So, only check case 1.
2239 else 2157 * if (macp->cardSetting.WPAIeLen==0)
2240 { 2158 * {
2241 zfiWlanSetEncryMode(dev, ZM_WEP256); 2159 * mKeyFormat[0] = CamEncryType;
2242 } 2160 * mDynKeyMode = pSetting->DynKeyMode = tmpDynKeyMode;
2243 2161 * mPrivacyInvoked[0]=TRUE;
2244 // For Dynamic WEP key (Non-WPA Radius), the key ID range: 0-3 2162 * mCap[0] |= CAP_PRIVACY;
2245 // In WPA/RSN mode, the key ID range: 1-3, usually, a broadcast key. 2163 * macp->cardSetting.EncryOnOff[0]=1;
2246 // For WEP key setting: we set mDynKeyMode and mKeyFormat in following case: 2164 * }
2247 // 1. For 802.1x dynamically generated WEP key method. 2165 */
2248 // 2. For WPA/RSN mode, but key id == 0. (But this is an impossible case) 2166 }
2249 // So, only check case 1. 2167
2250 //if (macp->cardSetting.WPAIeLen==0) 2168 /* DUMP key context */
2251 //{ 2169 /* #ifdef WPA_DEBUG */
2252 // mKeyFormat[0] = CamEncryType; 2170 if (keyInfo.keyLength > 0) {
2253 // mDynKeyMode = pSetting->DynKeyMode = tmpDynKeyMode; 2171 int ii;
2254 // mPrivacyInvoked[0]=TRUE; 2172 printk(KERN_WARNING
2255 // mCap[0] |= CAP_PRIVACY; 2173 "Otus: Key Context:\n");
2256 // macp->cardSetting.EncryOnOff[0]=1; 2174 for (ii = 0; ii < keyInfo.keyLength; ) {
2257 //} 2175 printk(KERN_WARNING
2258 } 2176 "0x%02x ", keyInfo.key[ii]);
2259 2177 if ((++ii % 16) == 0)
2260 /* DUMP key context */ 2178 printk(KERN_WARNING "\n");
2261//#ifdef WPA_DEBUG 2179 }
2262 if (keyInfo.keyLength > 0) 2180 printk(KERN_WARNING "\n");
2263 { 2181 }
2264 int ii; 2182 /* #endif */
2265 printk("Otus: Key Context:\n"); 2183
2266 for(ii = 0; ii < keyInfo.keyLength;) 2184 /* Set encrypt mode */
2267 { 2185 /* zfiWlanSetEncryMode(dev, CamEncryType); */
2268 printk("0x%02x ", keyInfo.key[ii]); 2186 vapId = zfLnxGetVapId(dev);
2269 if((++ii % 16) == 0) 2187 if (vapId == 0xffff)
2270 printk("\n"); 2188 keyInfo.vapId = 0;
2271 } 2189 else
2272 printk("\n"); 2190 keyInfo.vapId = vapId + 1;
2273 } 2191 keyInfo.vapAddr[0] = keyInfo.macAddr[0];
2274//#endif 2192 keyInfo.vapAddr[1] = keyInfo.macAddr[1];
2275 2193 keyInfo.vapAddr[2] = keyInfo.macAddr[2];
2276 /* Set encrypt mode */ 2194
2277 //zfiWlanSetEncryMode(dev, CamEncryType); 2195 zfiWlanSetKey(dev, keyInfo);
2278 vapId = zfLnxGetVapId(dev); 2196
2279 if (vapId == 0xffff) 2197 /* zfiWlanDisable(dev); */
2280 keyInfo.vapId = 0; 2198 /* zfiWlanEnable(dev); */
2281 else 2199 break;
2282 keyInfo.vapId = vapId + 1; 2200 case ZD_CMD_SET_MLME:
2283 keyInfo.vapAddr[0] = keyInfo.macAddr[0]; 2201 printk(KERN_ERR "usbdrv_wpa_ioctl: ZD_CMD_SET_MLME\n");
2284 keyInfo.vapAddr[1] = keyInfo.macAddr[1]; 2202
2285 keyInfo.vapAddr[2] = keyInfo.macAddr[2]; 2203 /* Translate STA's address */
2286 2204 sprintf(mac_addr, "%02x:%02x:%02x:%02x:%02x:%02x",
2287 zfiWlanSetKey(dev, keyInfo); 2205 zdparm->sta_addr[0], zdparm->sta_addr[1],
2288 2206 zdparm->sta_addr[2], zdparm->sta_addr[3],
2289 //zfiWlanDisable(dev); 2207 zdparm->sta_addr[4], zdparm->sta_addr[5]);
2290 //zfiWlanEnable(dev); 2208
2291 break; 2209 switch (zdparm->u.mlme.cmd) {
2292 2210 case MLME_STA_DEAUTH:
2293 case ZD_CMD_SET_MLME: 2211 printk(KERN_WARNING
2294 printk(KERN_ERR "usbdrv_wpa_ioctl: ZD_CMD_SET_MLME\n"); 2212 " -------Call zfiWlanDeauth, reason:%d\n",
2295 2213 zdparm->u.mlme.reason_code);
2296 /* Translate STA's address */ 2214 if (zfiWlanDeauth(dev, (u16_t *) zdparm->sta_addr,
2297 sprintf(mac_addr, "%02x:%02x:%02x:%02x:%02x:%02x", zdparm->sta_addr[0], zdparm->sta_addr[1], 2215 zdparm->u.mlme.reason_code) != 0)
2298 zdparm->sta_addr[2], zdparm->sta_addr[3], zdparm->sta_addr[4], zdparm->sta_addr[5]); 2216 printk(KERN_ERR "Can't deauthencate STA: %s\n",
2299 2217 mac_addr);
2300 switch(zdparm->u.mlme.cmd) 2218 else
2301 { 2219 printk(KERN_ERR "Deauthenticate STA: %s"
2302 case MLME_STA_DEAUTH: 2220 "with reason code: %d\n",
2303 printk(" -------Call zfiWlanDeauth, reason:%d\n",zdparm->u.mlme.reason_code); 2221 mac_addr, zdparm->u.mlme.reason_code);
2304 if(zfiWlanDeauth(dev, (u16_t*) zdparm->sta_addr, zdparm->u.mlme.reason_code) != 0) 2222 break;
2305 printk(KERN_ERR "Can't deauthencate STA: %s\n", mac_addr); 2223 case MLME_STA_DISASSOC:
2306 else 2224 printk(KERN_WARNING
2307 printk(KERN_ERR "Deauthenticate STA: %s with reason code: %d\n", mac_addr, zdparm->u.mlme.reason_code); 2225 " -------Call zfiWlanDeauth, reason:%d\n",
2308 break; 2226 zdparm->u.mlme.reason_code);
2309 2227 if (zfiWlanDeauth(dev, (u16_t *) zdparm->sta_addr,
2310 case MLME_STA_DISASSOC: 2228 zdparm->u.mlme.reason_code) != 0)
2311 printk(" -------Call zfiWlanDeauth, reason:%d\n",zdparm->u.mlme.reason_code); 2229 printk(KERN_ERR "Can't disassociate STA: %s\n",
2312 if(zfiWlanDeauth(dev, (u16_t*) zdparm->sta_addr, zdparm->u.mlme.reason_code) != 0) 2230 mac_addr);
2313 printk(KERN_ERR "Can't disassociate STA: %s\n", mac_addr); 2231 else
2314 else 2232 printk(KERN_ERR "Disassociate STA: %s"
2315 printk(KERN_ERR "Disassociate STA: %s with reason code: %d\n", mac_addr, zdparm->u.mlme.reason_code); 2233 "with reason code: %d\n",
2316 break; 2234 mac_addr, zdparm->u.mlme.reason_code);
2317 2235 break;
2318 default: 2236 default:
2319 printk(KERN_ERR "MLME command: 0x%04x not support\n", zdparm->u.mlme.cmd); 2237 printk(KERN_ERR "MLME command: 0x%04x not support\n",
2320 break; 2238 zdparm->u.mlme.cmd);
2321 } 2239 break;
2322 2240 }
2323 break; 2241
2324 2242 break;
2325 case ZD_CMD_SCAN_REQ: 2243 case ZD_CMD_SCAN_REQ:
2326 printk(KERN_ERR "usbdrv_wpa_ioctl: ZD_CMD_SCAN_REQ\n"); 2244 printk(KERN_ERR "usbdrv_wpa_ioctl: ZD_CMD_SCAN_REQ\n");
2327 break; 2245 break;
2328 2246 case ZD_CMD_SET_GENERIC_ELEMENT:
2329 case ZD_CMD_SET_GENERIC_ELEMENT: 2247 printk(KERN_ERR "usbdrv_wpa_ioctl:"
2330 printk(KERN_ERR "usbdrv_wpa_ioctl: ZD_CMD_SET_GENERIC_ELEMENT\n"); 2248 " ZD_CMD_SET_GENERIC_ELEMENT\n");
2331 2249
2332 /* Copy the WPA IE */ 2250 /* Copy the WPA IE
2333 //zm_msg1_mm(ZM_LV_0, "CWY - wpaie Length : ", zdparm->u.generic_elem.len); 2251 * zm_msg1_mm(ZM_LV_0, "CWY - wpaie Length : ",
2334 printk(KERN_ERR "wpaie Length : %d\n", zdparm->u.generic_elem.len); 2252 * zdparm->u.generic_elem.len);
2335 if (zfiWlanQueryWlanMode(dev) == ZM_MODE_AP) // AP Mode 2253 */
2336 { 2254 printk(KERN_ERR "wpaie Length : % d\n",
2337 zfiWlanSetWpaIe(dev, zdparm->u.generic_elem.data, zdparm->u.generic_elem.len); 2255 zdparm->u.generic_elem.len);
2338 } 2256 if (zfiWlanQueryWlanMode(dev) == ZM_MODE_AP) {
2339 else 2257 /* AP Mode */
2340 { 2258 zfiWlanSetWpaIe(dev, zdparm->u.generic_elem.data,
2341 macp->supLen = zdparm->u.generic_elem.len; 2259 zdparm->u.generic_elem.len);
2342 memcpy(macp->supIe, zdparm->u.generic_elem.data, zdparm->u.generic_elem.len); 2260 } else {
2343 } 2261 macp->supLen = zdparm->u.generic_elem.len;
2344 zfiWlanSetWpaSupport(dev, 1); 2262 memcpy(macp->supIe, zdparm->u.generic_elem.data,
2345 //zfiWlanSetWpaIe(dev, zdparm->u.generic_elem.data, zdparm->u.generic_elem.len); 2263 zdparm->u.generic_elem.len);
2346 { 2264 }
2347 int ii; 2265 zfiWlanSetWpaSupport(dev, 1);
2348 u8_t len = zdparm->u.generic_elem.len; 2266 /* zfiWlanSetWpaIe(dev, zdparm->u.generic_elem.data,
2349 u8_t *wpaie = (u8_t *)zdparm->u.generic_elem.data; 2267 * zdparm->u.generic_elem.len);
2350 2268 */
2351 printk(KERN_ERR "wd->ap.wpaLen: %d\n", len); 2269 int ii;
2352 2270 u8_t len = zdparm->u.generic_elem.len;
2353 /* DUMP WPA IE */ 2271 u8_t *wpaie = (u8_t *)zdparm->u.generic_elem.data;
2354 for(ii = 0; ii < len;) 2272
2355 { 2273 printk(KERN_ERR "wd->ap.wpaLen : % d\n", len);
2356 printk(KERN_ERR "0x%02x ", wpaie[ii]); 2274
2357 2275 /* DUMP WPA IE */
2358 if((++ii % 16) == 0) 2276 for(ii = 0; ii < len;) {
2359 printk(KERN_ERR "\n"); 2277 printk(KERN_ERR "0x%02x ", wpaie[ii]);
2360 } 2278
2361 printk(KERN_ERR "\n"); 2279 if((++ii % 16) == 0)
2362 } 2280 printk(KERN_ERR "\n");
2363 2281 }
2364// #ifdef ZM_HOSTAPD_SUPPORT 2282 printk(KERN_ERR "\n");
2365 //if (wd->wlanMode == ZM_MODE_AP) 2283
2366 //{// Update Beacon FIFO in the next TBTT. 2284 /* #ifdef ZM_HOSTAPD_SUPPORT
2367 // memcpy(&mWPAIe, pSetting->WPAIe, pSetting->WPAIeLen); 2285 * if (wd->wlanMode == ZM_MODE_AP)
2368 // printk(KERN_ERR "Copy WPA IE into mWPAIe\n"); 2286 * {// Update Beacon FIFO in the next TBTT.
2369 //} 2287 * memcpy(&mWPAIe, pSetting->WPAIe, pSetting->WPAIeLen);
2370// #endif 2288 * printk(KERN_ERR "Copy WPA IE into mWPAIe\n");
2371 break; 2289 * }
2372 2290 * #endif
2373// #ifdef ZM_HOSTAPD_SUPPORT 2291 */
2374 case ZD_CMD_GET_TSC: 2292 break;
2375 printk(KERN_ERR "usbdrv_wpa_ioctl: ZD_CMD_GET_TSC\n"); 2293
2376 break; 2294 /* #ifdef ZM_HOSTAPD_SUPPORT */
2377// #endif 2295 case ZD_CMD_GET_TSC:
2378 2296 printk(KERN_ERR "usbdrv_wpa_ioctl : ZD_CMD_GET_TSC\n");
2379 default: 2297 break;
2380 printk(KERN_ERR "usbdrv_wpa_ioctl default: 0x%04x\n", zdparm->cmd); 2298 /* #endif */
2381 ret = -EINVAL; 2299
2382 break; 2300 default:
2383 } 2301 printk(KERN_ERR "usbdrv_wpa_ioctl default : 0x%04x\n",
2384 2302 zdparm->cmd);
2385 return ret; 2303 ret = -EINVAL;
2304 break;
2305 }
2306
2307 return ret;
2386} 2308}
2387 2309
2388#ifdef ZM_ENABLE_CENC 2310#ifdef ZM_ENABLE_CENC
2389int usbdrv_cenc_ioctl(struct net_device *dev, struct zydas_cenc_param *zdparm) 2311int usbdrv_cenc_ioctl(struct net_device *dev, struct zydas_cenc_param *zdparm)
2390{ 2312{
2391 //struct usbdrv_private *macp = dev->ml_priv; 2313 /* struct usbdrv_private *macp = dev->ml_priv; */
2392 struct zsKeyInfo keyInfo; 2314 struct zsKeyInfo keyInfo;
2393 u16_t apId; 2315 u16_t apId;
2394 u8_t bc_addr[6] = { 0xff, 0xff, 0xff, 0xff, 0xff, 0xff }; 2316 u8_t bc_addr[6] = { 0xff, 0xff, 0xff, 0xff, 0xff, 0xff };
2395 int ret = 0; 2317 int ret = 0;
2396 int ii; 2318 int ii;
2397 2319
2398 /* Get the AP Id */ 2320 /* Get the AP Id */
2399 apId = zfLnxGetVapId(dev); 2321 apId = zfLnxGetVapId(dev);
2400 2322
2401 if (apId == 0xffff) 2323 if (apId == 0xffff) {
2402 { 2324 apId = 0;
2403 apId = 0; 2325 } else {
2404 } 2326 apId = apId + 1;
2405 else 2327 }
2406 {
2407 apId = apId+1;
2408 }
2409
2410 switch (zdparm->cmd)
2411 {
2412 case ZM_CMD_CENC_SETCENC:
2413 printk(KERN_ERR "ZM_CMD_CENC_SETCENC\n");
2414 printk(KERN_ERR "length: %d\n", zdparm->len);
2415 printk(KERN_ERR "policy: %d\n", zdparm->u.info.cenc_policy);
2416 break;
2417 case ZM_CMD_CENC_SETKEY:
2418 //ret = wai_ioctl_setkey(vap, ioctl_msg);
2419 printk(KERN_ERR "ZM_CMD_CENC_SETKEY\n");
2420
2421 printk(KERN_ERR "MAC address= ");
2422 for(ii = 0; ii < 6; ii++)
2423 {
2424 printk(KERN_ERR "0x%02x ", zdparm->u.crypt.sta_addr[ii]);
2425 }
2426 printk(KERN_ERR "\n");
2427
2428 printk(KERN_ERR "Key Index: %d\n", zdparm->u.crypt.keyid);
2429 printk(KERN_ERR "Encryption key= ");
2430 for(ii = 0; ii < 16; ii++)
2431 {
2432 printk(KERN_ERR "0x%02x ", zdparm->u.crypt.key[ii]);
2433 }
2434 printk(KERN_ERR "\n");
2435
2436 printk(KERN_ERR "MIC key= ");
2437 for(ii = 16; ii < ZM_CENC_KEY_SIZE; ii++)
2438 {
2439 printk(KERN_ERR "0x%02x ", zdparm->u.crypt.key[ii]);
2440 }
2441 printk(KERN_ERR "\n");
2442
2443 /* Set up key information */
2444 keyInfo.keyLength = ZM_CENC_KEY_SIZE;
2445 keyInfo.keyIndex = zdparm->u.crypt.keyid;
2446 keyInfo.flag = ZM_KEY_FLAG_AUTHENTICATOR | ZM_KEY_FLAG_CENC;
2447 keyInfo.key = zdparm->u.crypt.key;
2448 keyInfo.macAddr = (u16_t *)zdparm->u.crypt.sta_addr;
2449
2450 /* Identify the MAC address information */
2451 if (memcmp(zdparm->u.crypt.sta_addr, bc_addr, sizeof(bc_addr)) == 0)
2452 {
2453 keyInfo.flag |= ZM_KEY_FLAG_GK;
2454 keyInfo.vapId = apId;
2455 memcpy(keyInfo.vapAddr, dev->dev_addr, ETH_ALEN);
2456 }
2457 else
2458 {
2459 keyInfo.flag |= ZM_KEY_FLAG_PK;
2460 }
2461
2462 zfiWlanSetKey(dev, keyInfo);
2463
2464 break;
2465 case ZM_CMD_CENC_REKEY:
2466 //ret = wai_ioctl_rekey(vap, ioctl_msg);
2467 printk(KERN_ERR "ZM_CMD_CENC_REKEY\n");
2468 break;
2469 default:
2470 ret = -EOPNOTSUPP;
2471 break;
2472
2473 }
2474
2475 //if (retv == ENETRESET)
2476 // retv = IS_UP_AUTO(vap) ? ieee80211_open(vap->iv_dev) : 0;
2477
2478 return ret;
2479}
2480#endif //ZM_ENABLE_CENC
2481/////////////////////////////////////////
2482int usbdrv_ioctl(struct net_device *dev, struct ifreq *ifr, int cmd)
2483{
2484// struct usbdrv_private *macp;
2485// void *regp;
2486 struct zdap_ioctl zdreq;
2487 struct iwreq *wrq = (struct iwreq *)ifr;
2488 struct athr_wlan_param zdparm;
2489 struct usbdrv_private *macp = dev->ml_priv;
2490 2328
2491 int err = 0; 2329 switch (zdparm->cmd) {
2492 int changed = 0; 2330 case ZM_CMD_CENC_SETCENC:
2331 printk(KERN_ERR "ZM_CMD_CENC_SETCENC\n");
2332 printk(KERN_ERR "length : % d\n", zdparm->len);
2333 printk(KERN_ERR "policy : % d\n", zdparm->u.info.cenc_policy);
2334 break;
2335 case ZM_CMD_CENC_SETKEY:
2336 /* ret = wai_ioctl_setkey(vap, ioctl_msg); */
2337 printk(KERN_ERR "ZM_CMD_CENC_SETKEY\n");
2338
2339 printk(KERN_ERR "MAC address = ");
2340 for (ii = 0; ii < 6; ii++) {
2341 printk(KERN_ERR "0x%02x ",
2342 zdparm->u.crypt.sta_addr[ii]);
2343 }
2344 printk(KERN_ERR "\n");
2493 2345
2494// regp = macp->regp; 2346 printk(KERN_ERR "Key Index : % d\n", zdparm->u.crypt.keyid);
2347 printk(KERN_ERR "Encryption key = ");
2348 for (ii = 0; ii < 16; ii++) {
2349 printk(KERN_ERR "0x%02x ", zdparm->u.crypt.key[ii]);
2350 }
2351 printk(KERN_ERR "\n");
2495 2352
2496 if(!netif_running(dev)) 2353 printk(KERN_ERR "MIC key = ");
2497 return -EINVAL; 2354 for(ii = 16; ii < ZM_CENC_KEY_SIZE; ii++) {
2355 printk(KERN_ERR "0x%02x ", zdparm->u.crypt.key[ii]);
2356 }
2357 printk(KERN_ERR "\n");
2358
2359 /* Set up key information */
2360 keyInfo.keyLength = ZM_CENC_KEY_SIZE;
2361 keyInfo.keyIndex = zdparm->u.crypt.keyid;
2362 keyInfo.flag = ZM_KEY_FLAG_AUTHENTICATOR | ZM_KEY_FLAG_CENC;
2363 keyInfo.key = zdparm->u.crypt.key;
2364 keyInfo.macAddr = (u16_t *)zdparm->u.crypt.sta_addr;
2365
2366 /* Identify the MAC address information */
2367 if (memcmp(zdparm->u.crypt.sta_addr, bc_addr,
2368 sizeof(bc_addr)) == 0) {
2369 keyInfo.flag |= ZM_KEY_FLAG_GK;
2370 keyInfo.vapId = apId;
2371 memcpy(keyInfo.vapAddr, dev->dev_addr, ETH_ALEN);
2372 } else {
2373 keyInfo.flag |= ZM_KEY_FLAG_PK;
2374 }
2498 2375
2499 switch (cmd) 2376 zfiWlanSetKey(dev, keyInfo);
2500 {
2501 case SIOCGIWNAME:
2502 strcpy(wrq->u.name, "IEEE 802.11-DS");
2503 break;
2504 2377
2505 case SIOCGIWAP: 2378 break;
2506 err = usbdrvwext_giwap(dev, NULL, &wrq->u.ap_addr, NULL); 2379 case ZM_CMD_CENC_REKEY:
2507 break; 2380 /* ret = wai_ioctl_rekey(vap, ioctl_msg); */
2381 printk(KERN_ERR "ZM_CMD_CENC_REKEY\n");
2382 break;
2383 default:
2384 ret = -EOPNOTSUPP;
2385 break;
2386 }
2508 2387
2388 /* if (retv == ENETRESET) */
2389 /* retv = IS_UP_AUTO(vap) ? ieee80211_open(vap->iv_dev) : 0; */
2509 2390
2510 case SIOCSIWAP: 2391 return ret;
2511 err = usbdrvwext_siwap(dev, NULL, &wrq->u.ap_addr, NULL); 2392}
2512 break; 2393#endif /* ZM_ENABLE_CENC */
2513 2394
2395int usbdrv_ioctl(struct net_device *dev, struct ifreq *ifr, int cmd)
2396{
2397 /* struct usbdrv_private *macp; */
2398 /* void *regp; */
2399 struct zdap_ioctl zdreq;
2400 struct iwreq *wrq = (struct iwreq *)ifr;
2401 struct athr_wlan_param zdparm;
2402 struct usbdrv_private *macp = dev->ml_priv;
2514 2403
2515 case SIOCGIWMODE: 2404 int err = 0;
2516 err = usbdrvwext_giwmode(dev, NULL, &wrq->u.mode, NULL); 2405 int changed = 0;
2517 break;
2518 2406
2407 /* regp = macp->regp; */
2519 2408
2520 case SIOCSIWESSID: 2409 if (!netif_running(dev))
2521 printk(KERN_ERR "CWY - usbdrvwext_siwessid\n"); 2410 return -EINVAL;
2522 //err = usbdrv_ioctl_setessid(dev, &wrq->u.essid);
2523 err = usbdrvwext_siwessid(dev, NULL, &wrq->u.essid, NULL);
2524 2411
2525 if (! err) 2412 switch (cmd) {
2526 changed = 1; 2413 case SIOCGIWNAME:
2527 break; 2414 strcpy(wrq->u.name, "IEEE 802.11-DS");
2415 break;
2416 case SIOCGIWAP:
2417 err = usbdrvwext_giwap(dev, NULL, &wrq->u.ap_addr, NULL);
2418 break;
2419 case SIOCSIWAP:
2420 err = usbdrvwext_siwap(dev, NULL, &wrq->u.ap_addr, NULL);
2421 break;
2422 case SIOCGIWMODE:
2423 err = usbdrvwext_giwmode(dev, NULL, &wrq->u.mode, NULL);
2424 break;
2425 case SIOCSIWESSID:
2426 printk(KERN_ERR "CWY - usbdrvwext_siwessid\n");
2427 /* err = usbdrv_ioctl_setessid(dev, &wrq->u.essid); */
2428 err = usbdrvwext_siwessid(dev, NULL, &wrq->u.essid, NULL);
2528 2429
2430 if (!err)
2431 changed = 1;
2432 break;
2433 case SIOCGIWESSID:
2434 err = usbdrvwext_giwessid(dev, NULL, &wrq->u.essid, NULL);
2435 break;
2436 case SIOCSIWRTS:
2437 err = usbdrv_ioctl_setrts(dev, &wrq->u.rts);
2438 if (! err)
2439 changed = 1;
2440 break;
2441 /* set_auth */
2442 case SIOCIWFIRSTPRIV + 0x2: {
2443 /* printk("CWY - SIOCIWFIRSTPRIV + 0x2(set_auth)\n"); */
2444 if (!capable(CAP_NET_ADMIN)) {
2445 err = -EPERM;
2446 break;
2447 }
2448 int val = *((int *) wrq->u.name);
2449 if ((val < 0) || (val > 2)) {
2450 err = -EINVAL;
2451 break;
2452 } else {
2453 zfiWlanSetAuthenticationMode(dev, val);
2529 2454
2530 case SIOCGIWESSID: 2455 if (macp->DeviceOpened == 1) {
2531 err = usbdrvwext_giwessid(dev, NULL, &wrq->u.essid, NULL); 2456 zfiWlanDisable(dev, 0);
2532 break; 2457 zfiWlanEnable(dev);
2458 }
2533 2459
2460 err = 0;
2461 changed = 1;
2462 }
2463 }
2464 break;
2465 /* get_auth */
2466 case SIOCIWFIRSTPRIV + 0x3: {
2467 int AuthMode = ZM_AUTH_MODE_OPEN;
2534 2468
2535 case SIOCSIWRTS: 2469 /* printk("CWY - SIOCIWFIRSTPRIV + 0x3(get_auth)\n"); */
2536 2470
2537 err = usbdrv_ioctl_setrts(dev, &wrq->u.rts); 2471 if (wrq->u.data.pointer) {
2538 if (! err) 2472 wrq->u.data.flags = 1;
2539 changed = 1;
2540 break;
2541 2473
2474 AuthMode = zfiWlanQueryAuthenticationMode(dev, 0);
2475 if (AuthMode == ZM_AUTH_MODE_OPEN) {
2476 wrq->u.data.length = 12;
2542 2477
2543 case SIOCIWFIRSTPRIV + 0x2: /* set_auth */ 2478 if (copy_to_user(wrq->u.data.pointer,
2544 { 2479 "open system", 12)) {
2545 //printk("CWY - SIOCIWFIRSTPRIV + 0x2 (set_auth)\n"); 2480 return -EFAULT;
2546 if (! capable(CAP_NET_ADMIN))
2547 {
2548 err = -EPERM;
2549 break;
2550 }
2551 {
2552 int val = *( (int *) wrq->u.name );
2553 if ((val < 0) || (val > 2))
2554 {
2555 err = -EINVAL;
2556 break;
2557 } 2481 }
2558 else 2482 } else if (AuthMode == ZM_AUTH_MODE_SHARED_KEY) {
2559 { 2483 wrq->u.data.length = 11;
2560 zfiWlanSetAuthenticationMode(dev, val);
2561 2484
2562 if (macp->DeviceOpened == 1) 2485 if (copy_to_user(wrq->u.data.pointer,
2563 { 2486 "shared key", 11)) {
2564 zfiWlanDisable(dev, 0); 2487 return -EFAULT;
2565 zfiWlanEnable(dev); 2488 }
2566 } 2489 } else if (AuthMode == ZM_AUTH_MODE_AUTO) {
2490 wrq->u.data.length = 10;
2567 2491
2568 err = 0; 2492 if (copy_to_user(wrq->u.data.pointer,
2569 changed = 1; 2493 "auto mode", 10)) {
2494 return -EFAULT;
2570 } 2495 }
2496 } else {
2497 return -EFAULT;
2571 } 2498 }
2572 } 2499 }
2573 break; 2500 }
2574 2501 break;
2575 case SIOCIWFIRSTPRIV + 0x3: /* get_auth */ 2502 /* debug command */
2576 { 2503 case ZDAPIOCTL:
2577 int AuthMode = ZM_AUTH_MODE_OPEN; 2504 if (copy_from_user(&zdreq, ifr->ifr_data, sizeof(zdreq))) {
2578 2505 printk(KERN_ERR "usbdrv : copy_from_user error\n");
2579 //printk("CWY - SIOCIWFIRSTPRIV + 0x3 (get_auth)\n"); 2506 return -EFAULT;
2507 }
2580 2508
2581 if (wrq->u.data.pointer) 2509 /* printk(KERN_WARNING
2582 { 2510 * "usbdrv : cmd = % 2x, reg = 0x%04lx,
2583 wrq->u.data.flags = 1; 2511 *value = 0x%08lx\n",
2512 * zdreq.cmd, zdreq.addr, zdreq.value);
2513 */
2514 zfLnxPrivateIoctl(dev, &zdreq);
2584 2515
2585 AuthMode = zfiWlanQueryAuthenticationMode(dev, 0); 2516 err = 0;
2586 if (AuthMode == ZM_AUTH_MODE_OPEN) 2517 break;
2587 { 2518 case ZD_IOCTL_WPA:
2588 wrq->u.data.length = 12; 2519 if (copy_from_user(&zdparm, ifr->ifr_data,
2520 sizeof(struct athr_wlan_param))) {
2521 printk(KERN_ERR "usbdrv : copy_from_user error\n");
2522 return -EFAULT;
2523 }
2589 2524
2590 if (copy_to_user(wrq->u.data.pointer, "open system", 12)) 2525 usbdrv_wpa_ioctl(dev, &zdparm);
2526 err = 0;
2527 break;
2528 case ZD_IOCTL_PARAM: {
2529 int *p;
2530 int op;
2531 int arg;
2532
2533 /* Point to the name field and retrieve the
2534 * op and arg elements.
2535 */
2536 p = (int *)wrq->u.name;
2537 op = *p++;
2538 arg = *p;
2539
2540 if (op == ZD_PARAM_ROAMING) {
2541 printk(KERN_ERR
2542 "*************ZD_PARAM_ROAMING : % d\n", arg);
2543 /* macp->cardSetting.ap_scan=(U8)arg; */
2544 }
2545 if (op == ZD_PARAM_PRIVACY) {
2546 printk(KERN_ERR "ZD_IOCTL_PRIVACY : ");
2547
2548 /* Turn on the privacy invoke flag */
2549 if (arg) {
2550 /* mCap[0] |= CAP_PRIVACY; */
2551 /* macp->cardSetting.EncryOnOff[0] = 1; */
2552 printk(KERN_ERR "enable\n");
2553
2554 } else {
2555 /* mCap[0] &= ~CAP_PRIVACY; */
2556 /* macp->cardSetting.EncryOnOff[0] = 0; */
2557 printk(KERN_ERR "disable\n");
2558 }
2559 /* changed=1; */
2560 }
2561 if (op == ZD_PARAM_WPA) {
2562
2563 printk(KERN_ERR "ZD_PARAM_WPA : ");
2564
2565 if (arg) {
2566 printk(KERN_ERR "enable\n");
2567
2568 if (zfiWlanQueryWlanMode(dev) != ZM_MODE_AP) {
2569 printk(KERN_ERR "Station Mode\n");
2570 /* zfiWlanQueryWpaIe(dev, (u8_t *)
2571 &wpaIe, &wpalen); */
2572 /* printk("wpaIe : % 2x, % 2x, % 2x\n",
2573 wpaIe[21], wpaIe[22], wpaIe[23]); */
2574 /* printk("rsnIe : % 2x, % 2x, % 2x\n",
2575 wpaIe[17], wpaIe[18], wpaIe[19]); */
2576 if ((macp->supIe[21] == 0x50) &&
2577 (macp->supIe[22] == 0xf2) &&
2578 (macp->supIe[23] == 0x2)) {
2579 printk(KERN_ERR
2580 "wd->sta.authMode = ZM_AUTH_MODE_WPAPSK\n");
2581 /* wd->sta.authMode = ZM_AUTH_MODE_WPAPSK; */
2582 /* wd->ws.authMode = ZM_AUTH_MODE_WPAPSK; */
2583 zfiWlanSetAuthenticationMode(dev,
2584 ZM_AUTH_MODE_WPAPSK);
2585 } else if ((macp->supIe[21] == 0x50) &&
2586 (macp->supIe[22] == 0xf2) &&
2587 (macp->supIe[23] == 0x1)) {
2588 printk(KERN_ERR
2589 "wd->sta.authMode = ZM_AUTH_MODE_WPA\n");
2590 /* wd->sta.authMode = ZM_AUTH_MODE_WPA; */
2591 /* wd->ws.authMode = ZM_AUTH_MODE_WPA; */
2592 zfiWlanSetAuthenticationMode(dev,
2593 ZM_AUTH_MODE_WPA);
2594 } else if ((macp->supIe[17] == 0xf) &&
2595 (macp->supIe[18] == 0xac) &&
2596 (macp->supIe[19] == 0x2))
2591 { 2597 {
2592 return -EFAULT; 2598 printk(KERN_ERR
2593 } 2599 "wd->sta.authMode = ZM_AUTH_MODE_WPA2PSK\n");
2594 } 2600 /* wd->sta.authMode = ZM_AUTH_MODE_WPA2PSK; */
2595 else if (AuthMode == ZM_AUTH_MODE_SHARED_KEY) 2601 /* wd->ws.authMode = ZM_AUTH_MODE_WPA2PSK; */
2602 zfiWlanSetAuthenticationMode(dev,
2603 ZM_AUTH_MODE_WPA2PSK);
2604 } else if ((macp->supIe[17] == 0xf) &&
2605 (macp->supIe[18] == 0xac) &&
2606 (macp->supIe[19] == 0x1))
2596 { 2607 {
2597 wrq->u.data.length = 11; 2608 printk(KERN_ERR
2598 2609 "wd->sta.authMode = ZM_AUTH_MODE_WPA2\n");
2599 if (copy_to_user(wrq->u.data.pointer, "shared key", 11)) 2610 /* wd->sta.authMode = ZM_AUTH_MODE_WPA2; */
2600 { 2611 /* wd->ws.authMode = ZM_AUTH_MODE_WPA2; */
2601 return -EFAULT; 2612 zfiWlanSetAuthenticationMode(dev,
2602 } 2613 ZM_AUTH_MODE_WPA2);
2614 }
2615 /* WPA or WPAPSK */
2616 if ((macp->supIe[21] == 0x50) ||
2617 (macp->supIe[22] == 0xf2)) {
2618 if (macp->supIe[11] == 0x2) {
2619 printk(KERN_ERR
2620 "wd->sta.wepStatus = ZM_ENCRYPTION_TKIP\n");
2621 /* wd->sta.wepStatus = ZM_ENCRYPTION_TKIP; */
2622 /* wd->ws.wepStatus = ZM_ENCRYPTION_TKIP; */
2623 zfiWlanSetWepStatus(dev, ZM_ENCRYPTION_TKIP);
2624 } else {
2625 printk(KERN_ERR
2626 "wd->sta.wepStatus = ZM_ENCRYPTION_AES\n");
2627 /* wd->sta.wepStatus = ZM_ENCRYPTION_AES; */
2628 /* wd->ws.wepStatus = ZM_ENCRYPTION_AES; */
2629 zfiWlanSetWepStatus(dev, ZM_ENCRYPTION_AES);
2603 } 2630 }
2604 else if (AuthMode == ZM_AUTH_MODE_AUTO) 2631 }
2605 { 2632 //WPA2 or WPA2PSK
2606 wrq->u.data.length = 10; 2633 if ((macp->supIe[17] == 0xf) ||
2607 2634 (macp->supIe[18] == 0xac)) {
2608 if (copy_to_user(wrq->u.data.pointer, "auto mode", 10)) 2635 if (macp->supIe[13] == 0x2) {
2609 { 2636 printk(KERN_ERR
2610 return -EFAULT; 2637 "wd->sta.wepStatus = ZM_ENCRYPTION_TKIP\n");
2638 /* wd->sta.wepStatus = ZM_ENCRYPTION_TKIP; */
2639 /* wd->ws.wepStatus = ZM_ENCRYPTION_TKIP; */
2640 zfiWlanSetWepStatus(dev, ZM_ENCRYPTION_TKIP);
2641 } else {
2642 printk(KERN_ERR
2643 "wd->sta.wepStatus = ZM_ENCRYPTION_AES\n");
2644 /* wd->sta.wepStatus = ZM_ENCRYPTION_AES; */
2645 /* wd->ws.wepStatus = ZM_ENCRYPTION_AES; */
2646 zfiWlanSetWepStatus(dev, ZM_ENCRYPTION_AES);
2611 } 2647 }
2612 } 2648 }
2613 else
2614 {
2615 return -EFAULT;
2616 }
2617 } 2649 }
2650 zfiWlanSetWpaSupport(dev, 1);
2651 } else {
2652 /* Reset the WPA related variables */
2653 printk(KERN_ERR "disable\n");
2654
2655 zfiWlanSetWpaSupport(dev, 0);
2656 zfiWlanSetAuthenticationMode(dev, ZM_AUTH_MODE_OPEN);
2657 zfiWlanSetWepStatus(dev, ZM_ENCRYPTION_WEP_DISABLED);
2658
2659 /* Now we only set the length in the WPA IE
2660 * field to zero.
2661 *macp->cardSetting.WPAIe[1] = 0;
2662 */
2663 }
2664 }
2665
2666 if (op == ZD_PARAM_COUNTERMEASURES) {
2667 printk(KERN_ERR
2668 "****************ZD_PARAM_COUNTERMEASURES : ");
2669
2670 if(arg) {
2671 /* mCounterMeasureState=1; */
2672 printk(KERN_ERR "enable\n");
2673 } else {
2674 /* mCounterMeasureState=0; */
2675 printk(KERN_ERR "disable\n");
2676 }
2677 }
2678 if (op == ZD_PARAM_DROPUNENCRYPTED) {
2679 printk(KERN_ERR "ZD_PARAM_DROPUNENCRYPTED : ");
2680
2681 if(arg) {
2682 printk(KERN_ERR "enable\n");
2683 } else {
2684 printk(KERN_ERR "disable\n");
2685 }
2686 }
2687 if (op == ZD_PARAM_AUTH_ALGS) {
2688 printk(KERN_ERR "ZD_PARAM_AUTH_ALGS : ");
2689
2690 if (arg == 0) {
2691 printk(KERN_ERR "OPEN_SYSTEM\n");
2692 } else {
2693 printk(KERN_ERR "SHARED_KEY\n");
2694 }
2695 }
2696 if (op == ZD_PARAM_WPS_FILTER) {
2697 printk(KERN_ERR "ZD_PARAM_WPS_FILTER : ");
2698
2699 if (arg) {
2700 /* mCounterMeasureState=1; */
2701 macp->forwardMgmt = 1;
2702 printk(KERN_ERR "enable\n");
2703 } else {
2704 /* mCounterMeasureState=0; */
2705 macp->forwardMgmt = 0;
2706 printk(KERN_ERR "disable\n");
2707 }
2708 }
2709 }
2710 err = 0;
2711 break;
2712 case ZD_IOCTL_GETWPAIE: {
2713 struct ieee80211req_wpaie req_wpaie;
2714 u16_t apId, i, j;
2715
2716 /* Get the AP Id */
2717 apId = zfLnxGetVapId(dev);
2718
2719 if (apId == 0xffff) {
2720 apId = 0;
2721 } else {
2722 apId = apId + 1;
2618 } 2723 }
2724
2725 if (copy_from_user(&req_wpaie, ifr->ifr_data,
2726 sizeof(struct ieee80211req_wpaie))) {
2727 printk(KERN_ERR "usbdrv : copy_from_user error\n");
2728 return -EFAULT;
2729 }
2730
2731 for (i = 0; i < ZM_OAL_MAX_STA_SUPPORT; i++) {
2732 for (j = 0; j < IEEE80211_ADDR_LEN; j++) {
2733 if (macp->stawpaie[i].wpa_macaddr[j] !=
2734 req_wpaie.wpa_macaddr[j])
2735 break;
2736 }
2737 if (j == 6)
2619 break; 2738 break;
2739 }
2620 2740
2741 if (i < ZM_OAL_MAX_STA_SUPPORT) {
2742 /* printk("ZD_IOCTL_GETWPAIE - sta index = % d\n", i); */
2743 memcpy(req_wpaie.wpa_ie, macp->stawpaie[i].wpa_ie,
2744 IEEE80211_MAX_IE_SIZE);
2745 }
2621 2746
2622 case ZDAPIOCTL: //debug command 2747 if (copy_to_user(wrq->u.data.pointer, &req_wpaie,
2623 if (copy_from_user(&zdreq, ifr->ifr_data, sizeof (zdreq))) 2748 sizeof(struct ieee80211req_wpaie))) {
2624 { 2749 return -EFAULT;
2625 printk(KERN_ERR "usbdrv: copy_from_user error\n"); 2750 }
2626 return -EFAULT; 2751 }
2627 } 2752
2628 2753 err = 0;
2629 //printk(KERN_DEBUG "usbdrv: cmd=%2x, reg=0x%04lx, value=0x%08lx\n", 2754 break;
2630 // zdreq.cmd, zdreq.addr, zdreq.value); 2755 #ifdef ZM_ENABLE_CENC
2631 2756 case ZM_IOCTL_CENC:
2632 zfLnxPrivateIoctl(dev, &zdreq); 2757 if (copy_from_user(&macp->zd_wpa_req, ifr->ifr_data,
2633 2758 sizeof(struct athr_wlan_param))) {
2634 err = 0; 2759 printk(KERN_ERR "usbdrv : copy_from_user error\n");
2635 break; 2760 return -EFAULT;
2636 2761 }
2637 case ZD_IOCTL_WPA: 2762
2638 if (copy_from_user(&zdparm, ifr->ifr_data, sizeof(struct athr_wlan_param))) 2763 usbdrv_cenc_ioctl(dev,
2639 { 2764 (struct zydas_cenc_param *)&macp->zd_wpa_req);
2640 printk(KERN_ERR "usbdrv: copy_from_user error\n"); 2765 err = 0;
2641 return -EFAULT; 2766 break;
2642 } 2767 #endif /* ZM_ENABLE_CENC */
2643 2768 default:
2644 usbdrv_wpa_ioctl(dev, &zdparm); 2769 err = -EOPNOTSUPP;
2645 err = 0; 2770 break;
2646 break; 2771 }
2647 2772
2648 case ZD_IOCTL_PARAM: 2773 return err;
2649 {
2650 int *p;
2651 int op;
2652 int arg;
2653
2654 /* Point to the name field and retrieve the
2655 * op and arg elements. */
2656 p = (int *)wrq->u.name;
2657 op = *p++;
2658 arg = *p;
2659
2660 if(op == ZD_PARAM_ROAMING)
2661 {
2662 printk(KERN_ERR "************* ZD_PARAM_ROAMING: %d\n", arg);
2663 //macp->cardSetting.ap_scan=(U8)arg;
2664 }
2665 if(op == ZD_PARAM_PRIVACY)
2666 {
2667 printk(KERN_ERR "ZD_IOCTL_PRIVACY: ");
2668
2669 /* Turn on the privacy invoke flag */
2670 if(arg)
2671 {
2672 // mCap[0] |= CAP_PRIVACY;
2673 // macp->cardSetting.EncryOnOff[0] = 1;
2674 printk(KERN_ERR "enable\n");
2675
2676 }
2677 else
2678 {
2679 // mCap[0] &= ~CAP_PRIVACY;
2680 // macp->cardSetting.EncryOnOff[0] = 0;
2681 printk(KERN_ERR "disable\n");
2682 }
2683 //changed=1;
2684 }
2685 if(op == ZD_PARAM_WPA)
2686 {
2687 printk(KERN_ERR "ZD_PARAM_WPA: ");
2688
2689 if(arg)
2690 {
2691 printk(KERN_ERR "enable\n");
2692
2693 if (zfiWlanQueryWlanMode(dev) != ZM_MODE_AP)
2694 {
2695 printk(KERN_ERR "Station Mode\n");
2696 //zfiWlanQueryWpaIe(dev, (u8_t *)&wpaIe, &wpalen);
2697 //printk("wpaIe : %2x,%2x,%2x\n", wpaIe[21], wpaIe[22], wpaIe[23]);
2698 //printk("rsnIe : %2x,%2x,%2x\n", wpaIe[17], wpaIe[18], wpaIe[19]);
2699 if ((macp->supIe[21] == 0x50) &&
2700 (macp->supIe[22] == 0xf2) &&
2701 (macp->supIe[23] == 0x2))
2702 {
2703 printk(KERN_ERR "wd->sta.authMode = ZM_AUTH_MODE_WPAPSK\n");
2704 //wd->sta.authMode = ZM_AUTH_MODE_WPAPSK;
2705 //wd->ws.authMode = ZM_AUTH_MODE_WPAPSK;
2706 zfiWlanSetAuthenticationMode(dev, ZM_AUTH_MODE_WPAPSK);
2707 }
2708 else if ((macp->supIe[21] == 0x50) &&
2709 (macp->supIe[22] == 0xf2) &&
2710 (macp->supIe[23] == 0x1))
2711 {
2712 printk(KERN_ERR "wd->sta.authMode = ZM_AUTH_MODE_WPA\n");
2713 //wd->sta.authMode = ZM_AUTH_MODE_WPA;
2714 //wd->ws.authMode = ZM_AUTH_MODE_WPA;
2715 zfiWlanSetAuthenticationMode(dev, ZM_AUTH_MODE_WPA);
2716 }
2717 else if ((macp->supIe[17] == 0xf) &&
2718 (macp->supIe[18] == 0xac) &&
2719 (macp->supIe[19] == 0x2))
2720 {
2721 printk(KERN_ERR "wd->sta.authMode = ZM_AUTH_MODE_WPA2PSK\n");
2722 //wd->sta.authMode = ZM_AUTH_MODE_WPA2PSK;
2723 //wd->ws.authMode = ZM_AUTH_MODE_WPA2PSK;
2724 zfiWlanSetAuthenticationMode(dev, ZM_AUTH_MODE_WPA2PSK);
2725 }
2726 else if ((macp->supIe[17] == 0xf) &&
2727 (macp->supIe[18] == 0xac) &&
2728 (macp->supIe[19] == 0x1))
2729 {
2730 printk(KERN_ERR "wd->sta.authMode = ZM_AUTH_MODE_WPA2\n");
2731 //wd->sta.authMode = ZM_AUTH_MODE_WPA2;
2732 //wd->ws.authMode = ZM_AUTH_MODE_WPA2;
2733 zfiWlanSetAuthenticationMode(dev, ZM_AUTH_MODE_WPA2);
2734 }
2735 if ((macp->supIe[21] == 0x50) || (macp->supIe[22] == 0xf2))//WPA or WPAPSK
2736 {
2737 if (macp->supIe[11] == 0x2)
2738 {
2739 printk(KERN_ERR "wd->sta.wepStatus = ZM_ENCRYPTION_TKIP\n");
2740 //wd->sta.wepStatus = ZM_ENCRYPTION_TKIP;
2741 //wd->ws.wepStatus = ZM_ENCRYPTION_TKIP;
2742 zfiWlanSetWepStatus(dev, ZM_ENCRYPTION_TKIP);
2743 }
2744 else
2745 {
2746 printk(KERN_ERR "wd->sta.wepStatus = ZM_ENCRYPTION_AES\n");
2747 //wd->sta.wepStatus = ZM_ENCRYPTION_AES;
2748 //wd->ws.wepStatus = ZM_ENCRYPTION_AES;
2749 zfiWlanSetWepStatus(dev, ZM_ENCRYPTION_AES);
2750 }
2751 }
2752 if ((macp->supIe[17] == 0xf) || (macp->supIe[18] == 0xac)) //WPA2 or WPA2PSK
2753 {
2754 if (macp->supIe[13] == 0x2)
2755 {
2756 printk(KERN_ERR "wd->sta.wepStatus = ZM_ENCRYPTION_TKIP\n");
2757 //wd->sta.wepStatus = ZM_ENCRYPTION_TKIP;
2758 //wd->ws.wepStatus = ZM_ENCRYPTION_TKIP;
2759 zfiWlanSetWepStatus(dev, ZM_ENCRYPTION_TKIP);
2760 }
2761 else
2762 {
2763 printk(KERN_ERR "wd->sta.wepStatus = ZM_ENCRYPTION_AES\n");
2764 //wd->sta.wepStatus = ZM_ENCRYPTION_AES;
2765 //wd->ws.wepStatus = ZM_ENCRYPTION_AES;
2766 zfiWlanSetWepStatus(dev, ZM_ENCRYPTION_AES);
2767 }
2768 }
2769 }
2770 zfiWlanSetWpaSupport(dev, 1);
2771 }
2772 else
2773 {
2774 /* Reset the WPA related variables */
2775 printk(KERN_ERR "disable\n");
2776
2777 zfiWlanSetWpaSupport(dev, 0);
2778 zfiWlanSetAuthenticationMode(dev, ZM_AUTH_MODE_OPEN);
2779 zfiWlanSetWepStatus(dev, ZM_ENCRYPTION_WEP_DISABLED);
2780
2781 /* Now we only set the length in the WPA IE
2782 * field to zero. */
2783 //macp->cardSetting.WPAIe[1] = 0;
2784 }
2785 }
2786 if(op == ZD_PARAM_COUNTERMEASURES)
2787 {
2788 printk(KERN_ERR "================ZD_PARAM_COUNTERMEASURES: ");
2789
2790 if(arg)
2791 {
2792 // mCounterMeasureState=1;
2793 printk(KERN_ERR "enable\n");
2794 }
2795 else
2796 {
2797 // mCounterMeasureState=0;
2798 printk(KERN_ERR "disable\n");
2799 }
2800 }
2801 if(op == ZD_PARAM_DROPUNENCRYPTED)
2802 {
2803 printk(KERN_ERR "ZD_PARAM_DROPUNENCRYPTED: ");
2804
2805 if(arg)
2806 {
2807 printk(KERN_ERR "enable\n");
2808 }
2809 else
2810 {
2811 printk(KERN_ERR "disable\n");
2812 }
2813 }
2814 if(op == ZD_PARAM_AUTH_ALGS)
2815 {
2816 printk(KERN_ERR "ZD_PARAM_AUTH_ALGS: ");
2817
2818 if(arg == 0)
2819 {
2820 printk(KERN_ERR "OPEN_SYSTEM\n");
2821 }
2822 else
2823 {
2824 printk(KERN_ERR "SHARED_KEY\n");
2825 }
2826 }
2827 if(op == ZD_PARAM_WPS_FILTER)
2828 {
2829 printk(KERN_ERR "ZD_PARAM_WPS_FILTER: ");
2830
2831 if(arg)
2832 {
2833 // mCounterMeasureState=1;
2834 macp->forwardMgmt = 1;
2835 printk(KERN_ERR "enable\n");
2836 }
2837 else
2838 {
2839 // mCounterMeasureState=0;
2840 macp->forwardMgmt = 0;
2841 printk(KERN_ERR "disable\n");
2842 }
2843 }
2844 }
2845 err = 0;
2846 break;
2847
2848 case ZD_IOCTL_GETWPAIE:
2849 {
2850 struct ieee80211req_wpaie req_wpaie;
2851 u16_t apId, i, j;
2852
2853 /* Get the AP Id */
2854 apId = zfLnxGetVapId(dev);
2855
2856 if (apId == 0xffff)
2857 {
2858 apId = 0;
2859 }
2860 else
2861 {
2862 apId = apId+1;
2863 }
2864
2865 if (copy_from_user(&req_wpaie, ifr->ifr_data, sizeof(struct ieee80211req_wpaie))){
2866 printk(KERN_ERR "usbdrv: copy_from_user error\n");
2867 return -EFAULT;
2868 }
2869
2870 for(i = 0; i < ZM_OAL_MAX_STA_SUPPORT; i++)
2871 {
2872 for(j = 0; j < IEEE80211_ADDR_LEN; j++)
2873 {
2874 if (macp->stawpaie[i].wpa_macaddr[j] != req_wpaie.wpa_macaddr[j])
2875 break;
2876 }
2877 if (j == 6)
2878 break;
2879 }
2880 if (i < ZM_OAL_MAX_STA_SUPPORT)
2881 {
2882 //printk("ZD_IOCTL_GETWPAIE - sta index = %d\n", i);
2883 memcpy(req_wpaie.wpa_ie, macp->stawpaie[i].wpa_ie, IEEE80211_MAX_IE_SIZE);
2884 }
2885
2886 if (copy_to_user(wrq->u.data.pointer, &req_wpaie, sizeof(struct ieee80211req_wpaie)))
2887 {
2888 return -EFAULT;
2889 }
2890 }
2891
2892 err = 0;
2893 break;
2894#ifdef ZM_ENABLE_CENC
2895 case ZM_IOCTL_CENC:
2896 if (copy_from_user(&macp->zd_wpa_req, ifr->ifr_data, sizeof(struct athr_wlan_param)))
2897 {
2898 printk(KERN_ERR "usbdrv: copy_from_user error\n");
2899 return -EFAULT;
2900 }
2901
2902 usbdrv_cenc_ioctl(dev, (struct zydas_cenc_param *)&macp->zd_wpa_req);
2903 err = 0;
2904 break;
2905#endif //ZM_ENABLE_CENC
2906 default:
2907 err = -EOPNOTSUPP;
2908 break;
2909 }
2910
2911
2912 return err;
2913} 2774}