2 * Copyright (c) 2007-2008 Atheros Communications Inc.
4 * Permission to use, copy, modify, and/or distribute this software for any
5 * purpose with or without fee is hereby granted, provided that the above
6 * copyright notice and this permission notice appear in all copies.
8 * THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES
9 * WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
10 * MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR
11 * ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
12 * WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
13 * ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
14 * OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
17 /* Module Name : ioctl.c */
20 /* This module contains Linux wireless extension related functons. */
23 /* Platform dependent. */
25 /************************************************************************/
26 #include <linux/slab.h>
27 #include <linux/module.h>
28 #include <linux/if_arp.h>
29 #include <linux/uaccess.h>
33 #define ZD_IOCTL_WPA (SIOCDEVPRIVATE + 1)
34 #define ZD_IOCTL_PARAM (SIOCDEVPRIVATE + 2)
35 #define ZD_IOCTL_GETWPAIE (SIOCDEVPRIVATE + 3)
37 #define ZM_IOCTL_CENC (SIOCDEVPRIVATE + 4)
38 #endif /* ZM_ENABLE_CENC */
39 #define ZD_PARAM_ROAMING 0x0001
40 #define ZD_PARAM_PRIVACY 0x0002
41 #define ZD_PARAM_WPA 0x0003
42 #define ZD_PARAM_COUNTERMEASURES 0x0004
43 #define ZD_PARAM_DROPUNENCRYPTED 0x0005
44 #define ZD_PARAM_AUTH_ALGS 0x0006
45 #define ZD_PARAM_WPS_FILTER 0x0007
48 #define P80211_PACKET_CENCFLAG 0x0001
49 #endif /* ZM_ENABLE_CENC */
50 #define P80211_PACKET_SETKEY 0x0003
52 #define ZD_CMD_SET_ENCRYPT_KEY 0x0001
53 #define ZD_CMD_SET_MLME 0x0002
54 #define ZD_CMD_SCAN_REQ 0x0003
55 #define ZD_CMD_SET_GENERIC_ELEMENT 0x0004
56 #define ZD_CMD_GET_TSC 0x0005
58 #define ZD_CRYPT_ALG_NAME_LEN 16
59 #define ZD_MAX_KEY_SIZE 32
60 #define ZD_MAX_GENERIC_SIZE 64
62 #include <net/iw_handler.h>
64 extern u16_t
zfLnxGetVapId(zdev_t
*dev
);
66 static const u32_t channel_frequency_11A
[] =
68 /* Even element for Channel Number, Odd for Frequency */
109 int usbdrv_freq2chan(u32_t freq
)
112 if (freq
> 2400 && freq
< 3000) {
113 return ((freq
-2412)/5) + 1;
116 u16_t num_chan
= sizeof(channel_frequency_11A
)/sizeof(u32_t
);
118 for (ii
= 1; ii
< num_chan
; ii
+= 2) {
119 if (channel_frequency_11A
[ii
] == freq
)
120 return channel_frequency_11A
[ii
-1];
127 int usbdrv_chan2freq(int chan
)
131 /* If channel number is out of range */
132 if (chan
> 165 || chan
<= 0)
136 if (chan
>= 1 && chan
<= 13) {
137 freq
= (2412 + (chan
- 1) * 5);
139 } else if (chan
>= 36 && chan
<= 165) {
141 u16_t num_chan
= sizeof(channel_frequency_11A
)/sizeof(u32_t
);
143 for (ii
= 0; ii
< num_chan
; ii
+= 2) {
144 if (channel_frequency_11A
[ii
] == chan
)
145 return channel_frequency_11A
[ii
+1];
148 /* Can't find desired frequency */
153 /* Can't find deisred frequency */
157 int usbdrv_ioctl_setessid(struct net_device
*dev
, struct iw_point
*erq
)
159 #ifdef ZM_HOSTAPD_SUPPORT
160 /* struct usbdrv_private *macp = dev->ml_priv; */
161 char essidbuf
[IW_ESSID_MAX_SIZE
+1];
164 if (!netif_running(dev
))
167 memset(essidbuf
, 0, sizeof(essidbuf
));
169 printk(KERN_ERR
"usbdrv_ioctl_setessid\n");
171 /* printk("ssidlen=%d\n", erq->length); //for any, it is 1. */
173 if (erq
->length
> (IW_ESSID_MAX_SIZE
+1))
176 if (copy_from_user(essidbuf
, erq
->pointer
, erq
->length
))
180 /* zd_DisasocAll(2); */
183 printk(KERN_ERR
"essidbuf: ");
185 for (i
= 0; i
< erq
->length
; i
++)
186 printk(KERN_ERR
"%02x ", essidbuf
[i
]);
188 printk(KERN_ERR
"\n");
190 essidbuf
[erq
->length
] = '\0';
191 /* memcpy(macp->wd.ws.ssid, essidbuf, erq->length); */
192 /* macp->wd.ws.ssidLen = strlen(essidbuf)+2; */
193 /* macp->wd.ws.ssid[1] = strlen(essidbuf); Update ssid length */
195 zfiWlanSetSSID(dev
, essidbuf
, erq
->length
);
197 printk(KERN_ERR
"macp->wd.ws.ssid: ");
199 for (i
= 0; i
< macp
->wd
.ws
.ssidLen
; i
++)
200 printk(KERN_ERR
"%02x ", macp
->wd
.ws
.ssid
[i
]);
202 printk(KERN_ERR
"\n");
205 zfiWlanDisable(dev
, 0);
213 int usbdrv_ioctl_getessid(struct net_device
*dev
, struct iw_point
*erq
)
215 /* struct usbdrv_private *macp = dev->ml_priv; */
216 u8_t essidbuf
[IW_ESSID_MAX_SIZE
+1];
221 /* len = macp->wd.ws.ssidLen; */
222 /* memcpy(essidbuf, macp->wd.ws.ssid, macp->wd.ws.ssidLen); */
223 zfiWlanQuerySSID(dev
, essidbuf
, &len
);
227 printk(KERN_ERR
"ESSID: ");
229 for (i
= 0; i
< len
; i
++)
230 printk(KERN_ERR
"%c", essidbuf
[i
]);
232 printk(KERN_ERR
"\n");
235 erq
->length
= strlen(essidbuf
) + 1;
238 if (copy_to_user(erq
->pointer
, essidbuf
, erq
->length
))
245 int usbdrv_ioctl_setrts(struct net_device
*dev
, struct iw_param
*rrq
)
251 * Encode a WPA or RSN information element as a custom
252 * element using the hostap format.
254 u32
encode_ie(void *buf
, u32 bufsize
, const u8
*ie
, u32 ielen
,
255 const u8
*leader
, u32 leader_len
)
260 if (bufsize
< leader_len
)
263 memcpy(p
, leader
, leader_len
);
264 bufsize
-= leader_len
;
266 for (i
= 0; i
< ielen
&& bufsize
> 2; i
++)
267 p
+= sprintf(p
, "%02x", ie
[i
]);
268 return (i
== ielen
? p
- (u8
*)buf
:0);
272 * Translate scan data returned from the card to a card independent
273 * format that the Wireless Tools will understand
275 char *usbdrv_translate_scan(struct net_device
*dev
,
276 struct iw_request_info
*info
, char *current_ev
,
277 char *end_buf
, struct zsBssInfo
*list
)
279 struct iw_event iwe
; /* Temporary buffer */
281 char *current_val
; /* For rates */
286 last_ev
= current_ev
;
288 /* First entry *MUST* be the AP MAC address */
290 iwe
.u
.ap_addr
.sa_family
= ARPHRD_ETHER
;
291 memcpy(iwe
.u
.ap_addr
.sa_data
, list
->bssid
, ETH_ALEN
);
292 current_ev
= iwe_stream_add_event(info
, current_ev
,
293 end_buf
, &iwe
, IW_EV_ADDR_LEN
);
295 /* Ran out of buffer */
296 if (last_ev
== current_ev
)
299 last_ev
= current_ev
;
301 /* Other entries will be displayed in the order we give them */
304 iwe
.u
.data
.length
= list
->ssid
[1];
305 if (iwe
.u
.data
.length
> 32)
306 iwe
.u
.data
.length
= 32;
307 iwe
.cmd
= SIOCGIWESSID
;
308 iwe
.u
.data
.flags
= 1;
309 current_ev
= iwe_stream_add_point(info
, current_ev
,
310 end_buf
, &iwe
, &list
->ssid
[2]);
312 /* Ran out of buffer */
313 if (last_ev
== current_ev
)
316 last_ev
= current_ev
;
319 iwe
.cmd
= SIOCGIWMODE
;
320 capabilities
= (list
->capability
[1] << 8) + list
->capability
[0];
321 if (capabilities
& (0x01 | 0x02)) {
322 if (capabilities
& 0x01)
323 iwe
.u
.mode
= IW_MODE_MASTER
;
325 iwe
.u
.mode
= IW_MODE_ADHOC
;
326 current_ev
= iwe_stream_add_event(info
, current_ev
,
327 end_buf
, &iwe
, IW_EV_UINT_LEN
);
330 /* Ran out of buffer */
331 if (last_ev
== current_ev
)
334 last_ev
= current_ev
;
337 iwe
.cmd
= SIOCGIWFREQ
;
338 iwe
.u
.freq
.m
= list
->channel
;
339 /* Channel frequency in KHz */
340 if (iwe
.u
.freq
.m
> 14) {
341 if ((184 <= iwe
.u
.freq
.m
) && (iwe
.u
.freq
.m
<= 196))
342 iwe
.u
.freq
.m
= 4000 + iwe
.u
.freq
.m
* 5;
344 iwe
.u
.freq
.m
= 5000 + iwe
.u
.freq
.m
* 5;
346 if (iwe
.u
.freq
.m
== 14)
349 iwe
.u
.freq
.m
= 2412 + (iwe
.u
.freq
.m
- 1) * 5;
352 current_ev
= iwe_stream_add_event(info
, current_ev
,
353 end_buf
, &iwe
, IW_EV_FREQ_LEN
);
355 /* Ran out of buffer */
356 if (last_ev
== current_ev
)
359 last_ev
= current_ev
;
361 /* Add quality statistics */
363 iwe
.u
.qual
.updated
= IW_QUAL_QUAL_UPDATED
| IW_QUAL_LEVEL_UPDATED
364 | IW_QUAL_NOISE_UPDATED
;
365 iwe
.u
.qual
.level
= list
->signalStrength
;
366 iwe
.u
.qual
.noise
= 0;
367 iwe
.u
.qual
.qual
= list
->signalQuality
;
368 current_ev
= iwe_stream_add_event(info
, current_ev
,
369 end_buf
, &iwe
, IW_EV_QUAL_LEN
);
371 /* Ran out of buffer */
372 if (last_ev
== current_ev
)
375 last_ev
= current_ev
;
377 /* Add encryption capability */
379 iwe
.cmd
= SIOCGIWENCODE
;
380 if (capabilities
& 0x10)
381 iwe
.u
.data
.flags
= IW_ENCODE_ENABLED
| IW_ENCODE_NOKEY
;
383 iwe
.u
.data
.flags
= IW_ENCODE_DISABLED
;
385 iwe
.u
.data
.length
= 0;
386 current_ev
= iwe_stream_add_point(info
, current_ev
,
387 end_buf
, &iwe
, list
->ssid
);
389 /* Ran out of buffer */
390 if (last_ev
== current_ev
)
393 last_ev
= current_ev
;
395 /* Rate : stuffing multiple values in a single event require a bit
398 current_val
= current_ev
+ IW_EV_LCP_LEN
;
400 iwe
.cmd
= SIOCGIWRATE
;
401 /* Those two flags are ignored... */
402 iwe
.u
.bitrate
.fixed
= iwe
.u
.bitrate
.disabled
= 0;
404 for (i
= 0 ; i
< list
->supportedRates
[1] ; i
++) {
405 /* Bit rate given in 500 kb/s units (+ 0x80) */
406 iwe
.u
.bitrate
.value
= ((list
->supportedRates
[i
+2] & 0x7f)
408 /* Add new value to event */
409 current_val
= iwe_stream_add_value(info
, current_ev
,
410 current_val
, end_buf
, &iwe
, IW_EV_PARAM_LEN
);
412 /* Ran out of buffer */
413 if (last_ev
== current_val
)
416 last_ev
= current_val
;
419 for (i
= 0 ; i
< list
->extSupportedRates
[1] ; i
++) {
420 /* Bit rate given in 500 kb/s units (+ 0x80) */
421 iwe
.u
.bitrate
.value
= ((list
->extSupportedRates
[i
+2] & 0x7f)
423 /* Add new value to event */
424 current_val
= iwe_stream_add_value(info
, current_ev
,
425 current_val
, end_buf
, &iwe
, IW_EV_PARAM_LEN
);
427 /* Ran out of buffer */
428 if (last_ev
== current_val
)
431 last_ev
= current_ev
;
434 /* Check if we added any event */
435 if ((current_val
- current_ev
) > IW_EV_LCP_LEN
)
436 current_ev
= current_val
;
437 #define IEEE80211_ELEMID_RSN 0x30
438 memset(&iwe
, 0, sizeof(iwe
));
439 iwe
.cmd
= IWEVCUSTOM
;
440 snprintf(buf
, sizeof(buf
), "bcn_int=%d", (list
->beaconInterval
[1] << 8)
441 + list
->beaconInterval
[0]);
442 iwe
.u
.data
.length
= strlen(buf
);
443 current_ev
= iwe_stream_add_point(info
, current_ev
,
446 /* Ran out of buffer */
447 if (last_ev
== current_ev
)
450 last_ev
= current_ev
;
452 if (list
->wpaIe
[1] != 0) {
453 static const char rsn_leader
[] = "rsn_ie=";
454 static const char wpa_leader
[] = "wpa_ie=";
456 memset(&iwe
, 0, sizeof(iwe
));
457 iwe
.cmd
= IWEVCUSTOM
;
458 if (list
->wpaIe
[0] == IEEE80211_ELEMID_RSN
)
459 iwe
.u
.data
.length
= encode_ie(buf
, sizeof(buf
),
460 list
->wpaIe
, list
->wpaIe
[1]+2,
461 rsn_leader
, sizeof(rsn_leader
)-1);
463 iwe
.u
.data
.length
= encode_ie(buf
, sizeof(buf
),
464 list
->wpaIe
, list
->wpaIe
[1]+2,
465 wpa_leader
, sizeof(wpa_leader
)-1);
467 if (iwe
.u
.data
.length
!= 0)
468 current_ev
= iwe_stream_add_point(info
, current_ev
,
471 /* Ran out of buffer */
472 if (last_ev
== current_ev
)
475 last_ev
= current_ev
;
478 if (list
->rsnIe
[1] != 0) {
479 static const char rsn_leader
[] = "rsn_ie=";
480 memset(&iwe
, 0, sizeof(iwe
));
481 iwe
.cmd
= IWEVCUSTOM
;
483 if (list
->rsnIe
[0] == IEEE80211_ELEMID_RSN
) {
484 iwe
.u
.data
.length
= encode_ie(buf
, sizeof(buf
),
485 list
->rsnIe
, list
->rsnIe
[1]+2,
486 rsn_leader
, sizeof(rsn_leader
)-1);
487 if (iwe
.u
.data
.length
!= 0)
488 current_ev
= iwe_stream_add_point(info
,
489 current_ev
, end_buf
, &iwe
, buf
);
491 /* Ran out of buffer */
492 if (last_ev
== current_ev
)
495 last_ev
= current_ev
;
498 /* The other data in the scan result are not really
499 * interesting, so for now drop it
504 int usbdrvwext_giwname(struct net_device
*dev
,
505 struct iw_request_info
*info
,
506 union iwreq_data
*wrq
, char *extra
)
508 /* struct usbdrv_private *macp = dev->ml_priv; */
510 strcpy(wrq
->name
, "IEEE 802.11-MIMO");
515 int usbdrvwext_siwfreq(struct net_device
*dev
,
516 struct iw_request_info
*info
,
517 struct iw_freq
*freq
, char *extra
)
520 struct usbdrv_private
*macp
= dev
->ml_priv
;
522 if (!netif_running(dev
))
529 FreqKHz
= (freq
->m
/ 100000);
531 if (FreqKHz
> 4000000) {
532 if (FreqKHz
> 5825000)
534 else if (FreqKHz
< 4920000)
536 else if (FreqKHz
< 5000000)
537 FreqKHz
= (((FreqKHz
- 4000000) / 5000) * 5000)
540 FreqKHz
= (((FreqKHz
- 5000000) / 5000) * 5000)
543 if (FreqKHz
> 2484000)
545 else if (FreqKHz
< 2412000)
548 FreqKHz
= (((FreqKHz
- 2412000) / 5000) * 5000)
552 FreqKHz
= usbdrv_chan2freq(freq
->m
);
560 /* printk("freq->m: %d, freq->e: %d\n", freq->m, freq->e); */
561 /* printk("FreqKHz: %d\n", FreqKHz); */
563 if (macp
->DeviceOpened
== 1) {
564 zfiWlanSetFrequency(dev
, FreqKHz
, 0); /* Immediate */
565 /* u8_t wpaieLen,wpaie[50]; */
566 /* zfiWlanQueryWpaIe(dev, wpaie, &wpaieLen); */
567 zfiWlanDisable(dev
, 0);
569 /* if (wpaieLen > 2) */
570 /* zfiWlanSetWpaIe(dev, wpaie, wpaieLen); */
576 int usbdrvwext_giwfreq(struct net_device
*dev
,
577 struct iw_request_info
*info
,
578 struct iw_freq
*freq
, char *extra
)
580 struct usbdrv_private
*macp
= dev
->ml_priv
;
582 if (macp
->DeviceOpened
!= 1)
585 freq
->m
= zfiWlanQueryFrequency(dev
);
591 int usbdrvwext_siwmode(struct net_device
*dev
,
592 struct iw_request_info
*info
,
593 union iwreq_data
*wrq
, char *extra
)
595 struct usbdrv_private
*macp
= dev
->ml_priv
;
598 if (!netif_running(dev
))
601 if (macp
->DeviceOpened
!= 1)
606 WlanMode
= ZM_MODE_AP
;
609 WlanMode
= ZM_MODE_INFRASTRUCTURE
;
612 WlanMode
= ZM_MODE_IBSS
;
615 WlanMode
= ZM_MODE_IBSS
;
619 zfiWlanSetWlanMode(dev
, WlanMode
);
620 zfiWlanDisable(dev
, 1);
626 int usbdrvwext_giwmode(struct net_device
*dev
,
627 struct iw_request_info
*info
,
628 __u32
*mode
, char *extra
)
630 unsigned long irqFlag
;
631 struct usbdrv_private
*macp
= dev
->ml_priv
;
633 if (!netif_running(dev
))
636 if (macp
->DeviceOpened
!= 1)
639 spin_lock_irqsave(&macp
->cs_lock
, irqFlag
);
641 switch (zfiWlanQueryWlanMode(dev
)) {
643 *mode
= IW_MODE_MASTER
;
645 case ZM_MODE_INFRASTRUCTURE
:
646 *mode
= IW_MODE_INFRA
;
649 *mode
= IW_MODE_ADHOC
;
652 *mode
= IW_MODE_ADHOC
;
656 spin_unlock_irqrestore(&macp
->cs_lock
, irqFlag
);
661 int usbdrvwext_siwsens(struct net_device
*dev
,
662 struct iw_request_info
*info
,
663 struct iw_param
*sens
, char *extra
)
668 int usbdrvwext_giwsens(struct net_device
*dev
,
669 struct iw_request_info
*info
,
670 struct iw_param
*sens
, char *extra
)
678 int usbdrvwext_giwrange(struct net_device
*dev
,
679 struct iw_request_info
*info
,
680 struct iw_point
*data
, char *extra
)
682 struct iw_range
*range
= (struct iw_range
*) extra
;
684 /* int num_band_a; */
688 if (!netif_running(dev
))
691 range
->txpower_capa
= IW_TXPOW_DBM
;
692 /* XXX what about min/max_pmp, min/max_pmt, etc. */
694 range
->we_version_compiled
= WIRELESS_EXT
;
695 range
->we_version_source
= 13;
697 range
->retry_capa
= IW_RETRY_LIMIT
;
698 range
->retry_flags
= IW_RETRY_LIMIT
;
699 range
->min_retry
= 0;
700 range
->max_retry
= 255;
702 channel_num
= zfiWlanQueryAllowChannels(dev
, channels
);
704 /* Gurantee reported channel numbers is less
705 * or equal to IW_MAX_FREQUENCIES
707 if (channel_num
> IW_MAX_FREQUENCIES
)
708 channel_num
= IW_MAX_FREQUENCIES
;
712 for (i
= 0; i
< channel_num
; i
++) {
713 range
->freq
[val
].i
= usbdrv_freq2chan(channels
[i
]);
714 range
->freq
[val
].m
= channels
[i
];
715 range
->freq
[val
].e
= 6;
719 range
->num_channels
= channel_num
;
720 range
->num_frequency
= channel_num
;
723 range
->num_channels
= 14; /* Only 2.4G */
725 /* XXX need to filter against the regulatory domain &| active set */
728 for (i
= 1; i
<= 14; i
++) {
729 range
->freq
[val
].i
= i
;
731 range
->freq
[val
].m
= 2484000;
733 range
->freq
[val
].m
= (2412+(i
-1)*5)*1000;
734 range
->freq
[val
].e
= 3;
738 num_band_a
= (IW_MAX_FREQUENCIES
- val
);
740 for (i
= 0; i
< num_band_a
; i
++) {
741 range
->freq
[val
].i
= channel_frequency_11A
[2 * i
];
742 range
->freq
[val
].m
= channel_frequency_11A
[2 * i
+ 1] * 1000;
743 range
->freq
[val
].e
= 3;
746 /* MIMO Rate Not Defined Now
747 * For 802.11a, there are too more frequency.
748 * We can't return them all.
750 range
->num_frequency
= val
;
753 /* Max of /proc/net/wireless */
754 range
->max_qual
.qual
= 100; /* ?? 92; */
755 range
->max_qual
.level
= 154; /* ?? */
756 range
->max_qual
.noise
= 154; /* ?? */
757 range
->sensitivity
= 3; /* ?? */
759 /* XXX these need to be nsd-specific! */
761 range
->max_rts
= 2347;
762 range
->min_frag
= 256;
763 range
->max_frag
= 2346;
764 range
->max_encoding_tokens
= 4 /* NUM_WEPKEYS ?? */;
765 range
->num_encoding_sizes
= 2; /* ?? */
767 range
->encoding_size
[0] = 5; /* ?? WEP Key Encoding Size */
768 range
->encoding_size
[1] = 13; /* ?? */
770 /* XXX what about num_bitrates/throughput? */
771 range
->num_bitrates
= 0; /* ?? */
773 /* estimated max throughput
774 * XXX need to cap it if we're running at ~2Mbps..
777 range
->throughput
= 300000000;
782 int usbdrvwext_siwap(struct net_device
*dev
, struct iw_request_info
*info
,
783 struct sockaddr
*MacAddr
, char *extra
)
785 struct usbdrv_private
*macp
= dev
->ml_priv
;
787 if (!netif_running(dev
))
790 if (zfiWlanQueryWlanMode(dev
) == ZM_MODE_AP
) {
792 zfiWlanSetMacAddress(dev
, (u16_t
*)&MacAddr
->sa_data
[0]);
795 zfiWlanSetBssid(dev
, &MacAddr
->sa_data
[0]);
798 if (macp
->DeviceOpened
== 1) {
799 /* u8_t wpaieLen,wpaie[80]; */
800 /* zfiWlanQueryWpaIe(dev, wpaie, &wpaieLen); */
801 zfiWlanDisable(dev
, 0);
803 /* if (wpaieLen > 2) */
804 /* zfiWlanSetWpaIe(dev, wpaie, wpaieLen); */
810 int usbdrvwext_giwap(struct net_device
*dev
,
811 struct iw_request_info
*info
,
812 struct sockaddr
*MacAddr
, char *extra
)
814 struct usbdrv_private
*macp
= dev
->ml_priv
;
816 if (macp
->DeviceOpened
!= 1)
819 if (zfiWlanQueryWlanMode(dev
) == ZM_MODE_AP
) {
821 zfiWlanQueryMacAddress(dev
, &MacAddr
->sa_data
[0]);
824 if (macp
->adapterState
== ZM_STATUS_MEDIA_CONNECT
) {
825 zfiWlanQueryBssid(dev
, &MacAddr
->sa_data
[0]);
827 u8_t zero_addr
[6] = { 0x00, 0x00, 0x00, 0x00,
829 memcpy(&MacAddr
->sa_data
[0], zero_addr
,
837 int usbdrvwext_iwaplist(struct net_device
*dev
,
838 struct iw_request_info
*info
,
839 struct iw_point
*data
, char *extra
)
841 /* Don't know how to do yet--CWYang(+) */
846 int usbdrvwext_siwscan(struct net_device
*dev
, struct iw_request_info
*info
,
847 struct iw_point
*data
, char *extra
)
849 struct usbdrv_private
*macp
= dev
->ml_priv
;
851 if (macp
->DeviceOpened
!= 1)
854 printk(KERN_WARNING
"CWY - usbdrvwext_siwscan\n");
861 int usbdrvwext_giwscan(struct net_device
*dev
,
862 struct iw_request_info
*info
,
863 struct iw_point
*data
, char *extra
)
865 struct usbdrv_private
*macp
= dev
->ml_priv
;
866 /* struct zsWlanDev* wd = (struct zsWlanDev*) zmw_wlan_dev(dev); */
867 char *current_ev
= extra
;
870 /* BssList = wd->sta.pBssList; */
871 /* zmw_get_wlan_dev(dev); */
873 if (macp
->DeviceOpened
!= 1)
876 /* struct zsBssList BssList; */
877 struct zsBssListV1
*pBssList
= kmalloc(sizeof(struct zsBssListV1
),
879 if (data
->length
== 0)
880 end_buf
= extra
+ IW_SCAN_MAX_DATA
;
882 end_buf
= extra
+ data
->length
;
884 printk(KERN_WARNING
"giwscan - Report Scan Results\n");
885 /* printk("giwscan - BssList Sreucture Len : %d\n", sizeof(BssList));
886 * printk("giwscan - BssList Count : %d\n",
887 * wd->sta.pBssList->bssCount);
888 * printk("giwscan - UpdateBssList Count : %d\n",
889 * wd->sta.pUpdateBssList->bssCount);
891 zfiWlanQueryBssListV1(dev
, pBssList
);
892 /* zfiWlanQueryBssList(dev, &BssList); */
894 /* Read and parse all entries */
895 printk(KERN_WARNING
"giwscan - pBssList->bssCount : %d\n",
897 /* printk("giwscan - BssList.bssCount : %d\n", BssList.bssCount); */
899 for (i
= 0; i
< pBssList
->bssCount
; i
++) {
900 /* Translate to WE format this entry
901 * current_ev = usbdrv_translate_scan(dev, info, current_ev,
902 * extra + IW_SCAN_MAX_DATA, &pBssList->bssInfo[i]);
904 current_ev
= usbdrv_translate_scan(dev
, info
, current_ev
,
905 end_buf
, &pBssList
->bssInfo
[i
]);
907 if (current_ev
== end_buf
) {
909 data
->length
= current_ev
- extra
;
915 data
->length
= (current_ev
- extra
);
916 data
->flags
= 0; /* todo */
923 int usbdrvwext_siwessid(struct net_device
*dev
,
924 struct iw_request_info
*info
,
925 struct iw_point
*essid
, char *extra
)
927 char EssidBuf
[IW_ESSID_MAX_SIZE
+ 1];
928 struct usbdrv_private
*macp
= dev
->ml_priv
;
930 if (!netif_running(dev
))
933 if (essid
->flags
== 1) {
934 if (essid
->length
> IW_ESSID_MAX_SIZE
)
937 if (copy_from_user(&EssidBuf
, essid
->pointer
, essid
->length
))
940 EssidBuf
[essid
->length
] = '\0';
941 /* printk("siwessid - Set Essid : %s\n",EssidBuf); */
942 /* printk("siwessid - Essid Len : %d\n",essid->length); */
943 /* printk("siwessid - Essid Flag : %x\n",essid->flags); */
944 if (macp
->DeviceOpened
== 1) {
945 zfiWlanSetSSID(dev
, EssidBuf
, strlen(EssidBuf
));
946 zfiWlanSetFrequency(dev
, zfiWlanQueryFrequency(dev
),
948 zfiWlanSetEncryMode(dev
, zfiWlanQueryEncryMode(dev
));
949 /* u8_t wpaieLen,wpaie[50]; */
950 /* zfiWlanQueryWpaIe(dev, wpaie, &wpaieLen); */
951 zfiWlanDisable(dev
, 0);
953 /* if (wpaieLen > 2) */
954 /* zfiWlanSetWpaIe(dev, wpaie, wpaieLen); */
961 int usbdrvwext_giwessid(struct net_device
*dev
,
962 struct iw_request_info
*info
,
963 struct iw_point
*essid
, char *extra
)
965 struct usbdrv_private
*macp
= dev
->ml_priv
;
967 char EssidBuf
[IW_ESSID_MAX_SIZE
+ 1];
970 if (!netif_running(dev
))
973 if (macp
->DeviceOpened
!= 1)
976 zfiWlanQuerySSID(dev
, &EssidBuf
[0], &EssidLen
);
978 /* Convert type from unsigned char to char */
979 ssid_len
= (int)EssidLen
;
981 /* Make sure the essid length is not greater than IW_ESSID_MAX_SIZE */
982 if (ssid_len
> IW_ESSID_MAX_SIZE
)
983 ssid_len
= IW_ESSID_MAX_SIZE
;
985 EssidBuf
[ssid_len
] = '\0';
988 essid
->length
= strlen(EssidBuf
);
990 memcpy(extra
, EssidBuf
, essid
->length
);
991 /* wireless.c in Kernel would handle copy_to_user -- line 679 */
992 /* if (essid->pointer) {
993 * if (copy_to_user(essid->pointer, EssidBuf, essid->length)) {
994 * printk("giwessid - copy_to_user Fail\n");
1003 int usbdrvwext_siwnickn(struct net_device
*dev
,
1004 struct iw_request_info
*info
,
1005 struct iw_point
*data
, char *nickname
)
1007 /* Exist but junk--CWYang(+) */
1011 int usbdrvwext_giwnickn(struct net_device
*dev
,
1012 struct iw_request_info
*info
,
1013 struct iw_point
*data
, char *nickname
)
1015 struct usbdrv_private
*macp
= dev
->ml_priv
;
1017 char EssidBuf
[IW_ESSID_MAX_SIZE
+ 1];
1019 if (macp
->DeviceOpened
!= 1)
1022 zfiWlanQuerySSID(dev
, &EssidBuf
[0], &EssidLen
);
1023 EssidBuf
[EssidLen
] = 0;
1026 data
->length
= strlen(EssidBuf
);
1028 memcpy(nickname
, EssidBuf
, data
->length
);
1033 int usbdrvwext_siwrate(struct net_device
*dev
,
1034 struct iw_request_info
*info
,
1035 struct iw_param
*frq
, char *extra
)
1037 struct usbdrv_private
*macp
= dev
->ml_priv
;
1038 /* Array to Define Rate Number that Send to Driver */
1039 u16_t zcIndextoRateBG
[16] = {1000, 2000, 5500, 11000, 0, 0, 0, 0,
1040 48000, 24000, 12000, 6000, 54000, 36000, 18000, 9000};
1041 u16_t zcRateToMCS
[] = {0xff, 0, 1, 2, 3, 0xb, 0xf, 0xa, 0xe, 0x9, 0xd,
1043 u8_t i
, RateIndex
= 4;
1046 /* printk("frq->disabled : 0x%x\n",frq->disabled); */
1047 /* printk("frq->value : 0x%x\n",frq->value); */
1049 RateKbps
= frq
->value
/ 1000;
1050 /* printk("RateKbps : %d\n", RateKbps); */
1051 for (i
= 0; i
< 16; i
++) {
1052 if (RateKbps
== zcIndextoRateBG
[i
])
1056 if (zcIndextoRateBG
[RateIndex
] == 0)
1058 /* printk("RateIndex : %x\n", RateIndex); */
1059 for (i
= 0; i
< 13; i
++)
1060 if (RateIndex
== zcRateToMCS
[i
])
1062 /* printk("Index : %x\n", i); */
1063 if (RateKbps
== 65000) {
1065 printk(KERN_WARNING
"RateIndex : %d\n", RateIndex
);
1068 if (macp
->DeviceOpened
== 1) {
1069 zfiWlanSetTxRate(dev
, i
);
1070 /* zfiWlanDisable(dev); */
1071 /* zfiWlanEnable(dev); */
1077 int usbdrvwext_giwrate(struct net_device
*dev
,
1078 struct iw_request_info
*info
,
1079 struct iw_param
*frq
, char *extra
)
1081 struct usbdrv_private
*macp
= dev
->ml_priv
;
1083 if (!netif_running(dev
))
1086 if (macp
->DeviceOpened
!= 1)
1091 frq
->value
= zfiWlanQueryRxRate(dev
) * 1000;
1096 int usbdrvwext_siwrts(struct net_device
*dev
,
1097 struct iw_request_info
*info
,
1098 struct iw_param
*rts
, char *extra
)
1100 struct usbdrv_private
*macp
= dev
->ml_priv
;
1101 int val
= rts
->value
;
1103 if (macp
->DeviceOpened
!= 1)
1109 if ((val
< 0) || (val
> 2347))
1112 zfiWlanSetRtsThreshold(dev
, val
);
1117 int usbdrvwext_giwrts(struct net_device
*dev
,
1118 struct iw_request_info
*info
,
1119 struct iw_param
*rts
, char *extra
)
1121 struct usbdrv_private
*macp
= dev
->ml_priv
;
1123 if (!netif_running(dev
))
1126 if (macp
->DeviceOpened
!= 1)
1129 rts
->value
= zfiWlanQueryRtsThreshold(dev
);
1130 rts
->disabled
= (rts
->value
>= 2347);
1136 int usbdrvwext_siwfrag(struct net_device
*dev
,
1137 struct iw_request_info
*info
,
1138 struct iw_param
*frag
, char *extra
)
1140 struct usbdrv_private
*macp
= dev
->ml_priv
;
1141 u16_t fragThreshold
;
1143 if (macp
->DeviceOpened
!= 1)
1149 fragThreshold
= frag
->value
;
1151 zfiWlanSetFragThreshold(dev
, fragThreshold
);
1156 int usbdrvwext_giwfrag(struct net_device
*dev
,
1157 struct iw_request_info
*info
,
1158 struct iw_param
*frag
, char *extra
)
1160 struct usbdrv_private
*macp
= dev
->ml_priv
;
1162 unsigned long irqFlag
;
1164 if (!netif_running(dev
))
1167 if (macp
->DeviceOpened
!= 1)
1170 spin_lock_irqsave(&macp
->cs_lock
, irqFlag
);
1172 val
= zfiWlanQueryFragThreshold(dev
);
1176 frag
->disabled
= (val
>= 2346);
1179 spin_unlock_irqrestore(&macp
->cs_lock
, irqFlag
);
1184 int usbdrvwext_siwtxpow(struct net_device
*dev
,
1185 struct iw_request_info
*info
,
1186 struct iw_param
*rrq
, char *extra
)
1188 /* Not support yet--CWYng(+) */
1192 int usbdrvwext_giwtxpow(struct net_device
*dev
,
1193 struct iw_request_info
*info
,
1194 struct iw_param
*rrq
, char *extra
)
1196 /* Not support yet--CWYng(+) */
1200 int usbdrvwext_siwretry(struct net_device
*dev
,
1201 struct iw_request_info
*info
,
1202 struct iw_param
*rrq
, char *extra
)
1204 /* Do nothing--CWYang(+) */
1208 int usbdrvwext_giwretry(struct net_device
*dev
,
1209 struct iw_request_info
*info
,
1210 struct iw_param
*rrq
, char *extra
)
1212 /* Do nothing--CWYang(+) */
1216 int usbdrvwext_siwencode(struct net_device
*dev
,
1217 struct iw_request_info
*info
,
1218 struct iw_point
*erq
, char *key
)
1220 struct zsKeyInfo keyInfo
;
1222 int WepState
= ZM_ENCRYPTION_WEP_DISABLED
;
1223 struct usbdrv_private
*macp
= dev
->ml_priv
;
1225 if (!netif_running(dev
))
1228 if ((erq
->flags
& IW_ENCODE_DISABLED
) == 0) {
1230 keyInfo
.keyLength
= erq
->length
;
1231 keyInfo
.keyIndex
= (erq
->flags
& IW_ENCODE_INDEX
) - 1;
1232 if (keyInfo
.keyIndex
>= 4)
1233 keyInfo
.keyIndex
= 0;
1234 keyInfo
.flag
= ZM_KEY_FLAG_DEFAULT_KEY
;
1236 zfiWlanSetKey(dev
, keyInfo
);
1237 WepState
= ZM_ENCRYPTION_WEP_ENABLED
;
1239 for (i
= 1; i
< 4; i
++)
1240 zfiWlanRemoveKey(dev
, 0, i
);
1241 WepState
= ZM_ENCRYPTION_WEP_DISABLED
;
1242 /* zfiWlanSetEncryMode(dev, ZM_NO_WEP); */
1245 if (macp
->DeviceOpened
== 1) {
1246 zfiWlanSetWepStatus(dev
, WepState
);
1247 zfiWlanSetFrequency(dev
, zfiWlanQueryFrequency(dev
), FALSE
);
1248 /* zfiWlanSetEncryMode(dev, zfiWlanQueryEncryMode(dev)); */
1249 /* u8_t wpaieLen,wpaie[50]; */
1250 /* zfiWlanQueryWpaIe(dev, wpaie, &wpaieLen); */
1251 zfiWlanDisable(dev
, 0);
1253 /* if (wpaieLen > 2) */
1254 /* zfiWlanSetWpaIe(dev, wpaie, wpaieLen); */
1260 int usbdrvwext_giwencode(struct net_device
*dev
,
1261 struct iw_request_info
*info
,
1262 struct iw_point
*erq
, char *key
)
1264 struct usbdrv_private
*macp
= dev
->ml_priv
;
1265 u8_t EncryptionMode
;
1268 if (macp
->DeviceOpened
!= 1)
1271 EncryptionMode
= zfiWlanQueryEncryMode(dev
);
1274 erq
->flags
= IW_ENCODE_ENABLED
;
1276 erq
->flags
= IW_ENCODE_DISABLED
;
1278 /* We can't return the key, so set the proper flag and return zero */
1279 erq
->flags
|= IW_ENCODE_NOKEY
;
1282 /* Copy the key to the user buffer */
1283 switch (EncryptionMode
) {
1299 #ifdef ZM_ENABLE_CENC
1301 /* ZM_ENABLE_CENC */
1310 printk(KERN_ERR
"Unknown EncryMode\n");
1313 erq
->length
= keyLen
;
1318 int usbdrvwext_siwpower(struct net_device
*dev
,
1319 struct iw_request_info
*info
,
1320 struct iw_param
*frq
, char *extra
)
1322 struct usbdrv_private
*macp
= dev
->ml_priv
;
1325 if (macp
->DeviceOpened
!= 1)
1329 PSMode
= ZM_STA_PS_NONE
;
1331 PSMode
= ZM_STA_PS_MAX
;
1333 zfiWlanSetPowerSaveMode(dev
, PSMode
);
1338 int usbdrvwext_giwpower(struct net_device
*dev
,
1339 struct iw_request_info
*info
,
1340 struct iw_param
*frq
, char *extra
)
1342 unsigned long irqFlag
;
1343 struct usbdrv_private
*macp
= dev
->ml_priv
;
1345 if (macp
->DeviceOpened
!= 1)
1348 spin_lock_irqsave(&macp
->cs_lock
, irqFlag
);
1350 if (zfiWlanQueryPowerSaveMode(dev
) == ZM_STA_PS_NONE
)
1355 spin_unlock_irqrestore(&macp
->cs_lock
, irqFlag
);
1360 /*int usbdrvwext_setparam(struct net_device *dev, struct iw_request_info *info,
1361 * void *w, char *extra)
1363 * struct ieee80211vap *vap = dev->ml_priv;
1364 * struct ieee80211com *ic = vap->iv_ic;
1365 * struct ieee80211_rsnparms *rsn = &vap->iv_bss->ni_rsn;
1366 * int *i = (int *) extra;
1367 * int param = i[0]; // parameter id is 1st
1368 * int value = i[1]; // NB: most values are TYPE_INT
1371 * const struct ieee80211_authenticator *auth;
1372 * const struct ieee80211_aclator *acl;
1375 * case IEEE80211_PARAM_AUTHMODE:
1377 * case IEEE80211_AUTH_WPA: // WPA
1378 * case IEEE80211_AUTH_8021X: // 802.1x
1379 * case IEEE80211_AUTH_OPEN: // open
1380 * case IEEE80211_AUTH_SHARED: // shared-key
1381 * case IEEE80211_AUTH_AUTO: // auto
1382 * auth = ieee80211_authenticator_get(value);
1390 * case IEEE80211_AUTH_WPA: // WPA w/ 802.1x
1391 * vap->iv_flags |= IEEE80211_F_PRIVACY;
1392 * value = IEEE80211_AUTH_8021X;
1394 * case IEEE80211_AUTH_OPEN: // open
1395 * vap->iv_flags &= ~(IEEE80211_F_WPA | IEEE80211_F_PRIVACY);
1397 * case IEEE80211_AUTH_SHARED: // shared-key
1398 * case IEEE80211_AUTH_AUTO: // auto
1399 * case IEEE80211_AUTH_8021X: // 802.1x
1400 * vap->iv_flags &= ~IEEE80211_F_WPA;
1401 * // both require a key so mark the PRIVACY capability
1402 * vap->iv_flags |= IEEE80211_F_PRIVACY;
1405 * // NB: authenticator attach/detach happens on state change
1406 * vap->iv_bss->ni_authmode = value;
1407 * // XXX mixed/mode/usage?
1408 * vap->iv_auth = auth;
1411 * case IEEE80211_PARAM_PROTMODE:
1412 * if (value > IEEE80211_PROT_RTSCTS)
1414 * ic->ic_protmode = value;
1415 * // NB: if not operating in 11g this can wait
1416 * if (ic->ic_bsschan != IEEE80211_CHAN_ANYC &&
1417 * IEEE80211_IS_CHAN_ANYG(ic->ic_bsschan))
1420 * case IEEE80211_PARAM_MCASTCIPHER:
1421 * if ((vap->iv_caps & cipher2cap(value)) == 0 &&
1422 * !ieee80211_crypto_available(value))
1424 * rsn->rsn_mcastcipher = value;
1425 * if (vap->iv_flags & IEEE80211_F_WPA)
1428 * case IEEE80211_PARAM_MCASTKEYLEN:
1429 * if (!(0 < value && value < IEEE80211_KEYBUF_SIZE))
1431 * // XXX no way to verify driver capability
1432 * rsn->rsn_mcastkeylen = value;
1433 * if (vap->iv_flags & IEEE80211_F_WPA)
1436 * case IEEE80211_PARAM_UCASTCIPHERS:
1438 * // Convert cipher set to equivalent capabilities.
1439 * // NB: this logic intentionally ignores unknown and
1440 * // unsupported ciphers so folks can specify 0xff or
1441 * // similar and get all available ciphers.
1444 * for (j = 1; j < 32; j++) // NB: skip WEP
1445 * if ((value & (1<<j)) &&
1446 * ((vap->iv_caps & cipher2cap(j)) ||
1447 * ieee80211_crypto_available(j)))
1449 * if (caps == 0) // nothing available
1451 * // XXX verify ciphers ok for unicast use?
1452 * // XXX disallow if running as it'll have no effect
1453 * rsn->rsn_ucastcipherset = caps;
1454 * if (vap->iv_flags & IEEE80211_F_WPA)
1457 * case IEEE80211_PARAM_UCASTCIPHER:
1458 * if ((rsn->rsn_ucastcipherset & cipher2cap(value)) == 0)
1460 * rsn->rsn_ucastcipher = value;
1462 * case IEEE80211_PARAM_UCASTKEYLEN:
1463 * if (!(0 < value && value < IEEE80211_KEYBUF_SIZE))
1465 * // XXX no way to verify driver capability
1466 * rsn->rsn_ucastkeylen = value;
1468 * case IEEE80211_PARAM_KEYMGTALGS:
1470 * rsn->rsn_keymgmtset = value;
1471 * if (vap->iv_flags & IEEE80211_F_WPA)
1474 * case IEEE80211_PARAM_RSNCAPS:
1476 * rsn->rsn_caps = value;
1477 * if (vap->iv_flags & IEEE80211_F_WPA)
1480 * case IEEE80211_PARAM_WPA:
1483 * // XXX verify ciphers available
1484 * vap->iv_flags &= ~IEEE80211_F_WPA;
1487 * vap->iv_flags |= IEEE80211_F_WPA1;
1490 * vap->iv_flags |= IEEE80211_F_WPA2;
1493 * vap->iv_flags |= IEEE80211_F_WPA1 | IEEE80211_F_WPA2;
1496 * retv = ENETRESET; // XXX?
1498 * case IEEE80211_PARAM_ROAMING:
1499 * if (!(IEEE80211_ROAMING_DEVICE <= value &&
1500 * value <= IEEE80211_ROAMING_MANUAL))
1502 * ic->ic_roaming = value;
1504 * case IEEE80211_PARAM_PRIVACY:
1506 * // XXX check for key state?
1507 * vap->iv_flags |= IEEE80211_F_PRIVACY;
1509 * vap->iv_flags &= ~IEEE80211_F_PRIVACY;
1511 * case IEEE80211_PARAM_DROPUNENCRYPTED:
1513 * vap->iv_flags |= IEEE80211_F_DROPUNENC;
1515 * vap->iv_flags &= ~IEEE80211_F_DROPUNENC;
1517 * case IEEE80211_PARAM_COUNTERMEASURES:
1519 * if ((vap->iv_flags & IEEE80211_F_WPA) == 0)
1521 * vap->iv_flags |= IEEE80211_F_COUNTERM;
1523 * vap->iv_flags &= ~IEEE80211_F_COUNTERM;
1525 * case IEEE80211_PARAM_DRIVER_CAPS:
1526 * vap->iv_caps = value; // NB: for testing
1528 * case IEEE80211_PARAM_MACCMD:
1529 * acl = vap->iv_acl;
1531 * case IEEE80211_MACCMD_POLICY_OPEN:
1532 * case IEEE80211_MACCMD_POLICY_ALLOW:
1533 * case IEEE80211_MACCMD_POLICY_DENY:
1534 * if (acl == NULL) {
1535 * acl = ieee80211_aclator_get("mac");
1536 * if (acl == NULL || !acl->iac_attach(vap))
1538 * vap->iv_acl = acl;
1540 * acl->iac_setpolicy(vap, value);
1542 * case IEEE80211_MACCMD_FLUSH:
1544 * acl->iac_flush(vap);
1545 * // NB: silently ignore when not in use
1547 * case IEEE80211_MACCMD_DETACH:
1548 * if (acl != NULL) {
1549 * vap->iv_acl = NULL;
1550 * acl->iac_detach(vap);
1555 * case IEEE80211_PARAM_WMM:
1556 * if (ic->ic_caps & IEEE80211_C_WME){
1558 * vap->iv_flags |= IEEE80211_F_WME;
1559 * *//* XXX needed by ic_reset *//*
1560 * vap->iv_ic->ic_flags |= IEEE80211_F_WME;
1563 * *//* XXX needed by ic_reset *//*
1564 * vap->iv_flags &= ~IEEE80211_F_WME;
1565 * vap->iv_ic->ic_flags &= ~IEEE80211_F_WME;
1567 * retv = ENETRESET; // Renegotiate for capabilities
1570 * case IEEE80211_PARAM_HIDESSID:
1572 * vap->iv_flags |= IEEE80211_F_HIDESSID;
1574 * vap->iv_flags &= ~IEEE80211_F_HIDESSID;
1577 * case IEEE80211_PARAM_APBRIDGE:
1579 * vap->iv_flags |= IEEE80211_F_NOBRIDGE;
1581 * vap->iv_flags &= ~IEEE80211_F_NOBRIDGE;
1583 * case IEEE80211_PARAM_INACT:
1584 * vap->iv_inact_run = value / IEEE80211_INACT_WAIT;
1586 * case IEEE80211_PARAM_INACT_AUTH:
1587 * vap->iv_inact_auth = value / IEEE80211_INACT_WAIT;
1589 * case IEEE80211_PARAM_INACT_INIT:
1590 * vap->iv_inact_init = value / IEEE80211_INACT_WAIT;
1592 * case IEEE80211_PARAM_ABOLT:
1595 * // Map abolt settings to capability bits;
1596 * // this also strips unknown/unwanted bits.
1598 * if (value & IEEE80211_ABOLT_TURBO_PRIME)
1599 * caps |= IEEE80211_ATHC_TURBOP;
1600 * if (value & IEEE80211_ABOLT_COMPRESSION)
1601 * caps |= IEEE80211_ATHC_COMP;
1602 * if (value & IEEE80211_ABOLT_FAST_FRAME)
1603 * caps |= IEEE80211_ATHC_FF;
1604 * if (value & IEEE80211_ABOLT_XR)
1605 * caps |= IEEE80211_ATHC_XR;
1606 * if (value & IEEE80211_ABOLT_AR)
1607 * caps |= IEEE80211_ATHC_AR;
1608 * if (value & IEEE80211_ABOLT_BURST)
1609 * caps |= IEEE80211_ATHC_BURST;
1610 * if (value & IEEE80211_ABOLT_WME_ELE)
1611 * caps |= IEEE80211_ATHC_WME;
1612 * // verify requested capabilities are supported
1613 * if ((caps & ic->ic_ath_cap) != caps)
1615 * if (vap->iv_ath_cap != caps) {
1616 * if ((vap->iv_ath_cap ^ caps) & IEEE80211_ATHC_TURBOP) {
1617 * if (ieee80211_set_turbo(dev,
1618 * caps & IEEE80211_ATHC_TURBOP))
1620 * ieee80211_scan_flush(ic);
1622 * vap->iv_ath_cap = caps;
1623 * ic->ic_athcapsetup(vap->iv_ic, vap->iv_ath_cap);
1627 * case IEEE80211_PARAM_DTIM_PERIOD:
1628 * if (vap->iv_opmode != IEEE80211_M_HOSTAP &&
1629 * vap->iv_opmode != IEEE80211_M_IBSS)
1631 * if (IEEE80211_DTIM_MIN <= value &&
1632 * value <= IEEE80211_DTIM_MAX) {
1633 * vap->iv_dtim_period = value;
1634 * retv = ENETRESET; // requires restart
1638 * case IEEE80211_PARAM_BEACON_INTERVAL:
1639 * if (vap->iv_opmode != IEEE80211_M_HOSTAP &&
1640 * vap->iv_opmode != IEEE80211_M_IBSS)
1642 * if (IEEE80211_BINTVAL_MIN <= value &&
1643 * value <= IEEE80211_BINTVAL_MAX) {
1644 * ic->ic_lintval = value; // XXX multi-bss
1645 * retv = ENETRESET; // requires restart
1649 * case IEEE80211_PARAM_DOTH:
1651 * ic->ic_flags |= IEEE80211_F_DOTH;
1654 * ic->ic_flags &= ~IEEE80211_F_DOTH;
1655 * retv = ENETRESET; // XXX: need something this drastic?
1657 * case IEEE80211_PARAM_PWRTARGET:
1658 * ic->ic_curchanmaxpwr = value;
1660 * case IEEE80211_PARAM_GENREASSOC:
1661 * IEEE80211_SEND_MGMT(vap->iv_bss,
1662 * IEEE80211_FC0_SUBTYPE_REASSOC_REQ, 0);
1664 * case IEEE80211_PARAM_COMPRESSION:
1665 * retv = ieee80211_setathcap(vap, IEEE80211_ATHC_COMP, value);
1667 * case IEEE80211_PARAM_WMM_AGGRMODE:
1668 * retv = ieee80211_setathcap(vap, IEEE80211_ATHC_WME, value);
1670 * case IEEE80211_PARAM_FF:
1671 * retv = ieee80211_setathcap(vap, IEEE80211_ATHC_FF, value);
1673 * case IEEE80211_PARAM_TURBO:
1674 * retv = ieee80211_setathcap(vap, IEEE80211_ATHC_TURBOP, value);
1675 * if (retv == ENETRESET) {
1676 * if(ieee80211_set_turbo(dev,value))
1678 * ieee80211_scan_flush(ic);
1681 * case IEEE80211_PARAM_XR:
1682 * retv = ieee80211_setathcap(vap, IEEE80211_ATHC_XR, value);
1684 * case IEEE80211_PARAM_BURST:
1685 * retv = ieee80211_setathcap(vap, IEEE80211_ATHC_BURST, value);
1687 * case IEEE80211_PARAM_AR:
1688 * retv = ieee80211_setathcap(vap, IEEE80211_ATHC_AR, value);
1690 * case IEEE80211_PARAM_PUREG:
1692 * vap->iv_flags |= IEEE80211_F_PUREG;
1694 * vap->iv_flags &= ~IEEE80211_F_PUREG;
1695 * // NB: reset only if we're operating on an 11g channel
1696 * if (ic->ic_bsschan != IEEE80211_CHAN_ANYC &&
1697 * IEEE80211_IS_CHAN_ANYG(ic->ic_bsschan))
1700 * case IEEE80211_PARAM_WDS:
1702 * vap->iv_flags_ext |= IEEE80211_FEXT_WDS;
1704 * vap->iv_flags_ext &= ~IEEE80211_FEXT_WDS;
1706 * case IEEE80211_PARAM_BGSCAN:
1708 * if ((vap->iv_caps & IEEE80211_C_BGSCAN) == 0)
1710 * vap->iv_flags |= IEEE80211_F_BGSCAN;
1713 * vap->iv_flags &= ~IEEE80211_F_BGSCAN;
1714 * ieee80211_cancel_scan(vap); // anything current
1717 * case IEEE80211_PARAM_BGSCAN_IDLE:
1718 * if (value >= IEEE80211_BGSCAN_IDLE_MIN)
1719 * vap->iv_bgscanidle = value*HZ/1000;
1723 * case IEEE80211_PARAM_BGSCAN_INTERVAL:
1724 * if (value >= IEEE80211_BGSCAN_INTVAL_MIN)
1725 * vap->iv_bgscanintvl = value*HZ;
1729 * case IEEE80211_PARAM_MCAST_RATE:
1730 * // units are in KILObits per second
1731 * if (value >= 256 && value <= 54000)
1732 * vap->iv_mcast_rate = value;
1736 * case IEEE80211_PARAM_COVERAGE_CLASS:
1737 * if (value >= 0 && value <= IEEE80211_COVERAGE_CLASS_MAX) {
1738 * ic->ic_coverageclass = value;
1739 * if (IS_UP_AUTO(vap))
1740 * ieee80211_new_state(vap, IEEE80211_S_SCAN, 0);
1746 * case IEEE80211_PARAM_COUNTRY_IE:
1748 * ic->ic_flags_ext |= IEEE80211_FEXT_COUNTRYIE;
1750 * ic->ic_flags_ext &= ~IEEE80211_FEXT_COUNTRYIE;
1753 * case IEEE80211_PARAM_REGCLASS:
1755 * ic->ic_flags_ext |= IEEE80211_FEXT_REGCLASS;
1757 * ic->ic_flags_ext &= ~IEEE80211_FEXT_REGCLASS;
1760 * case IEEE80211_PARAM_SCANVALID:
1761 * vap->iv_scanvalid = value*HZ;
1763 * case IEEE80211_PARAM_ROAM_RSSI_11A:
1764 * vap->iv_roam.rssi11a = value;
1766 * case IEEE80211_PARAM_ROAM_RSSI_11B:
1767 * vap->iv_roam.rssi11bOnly = value;
1769 * case IEEE80211_PARAM_ROAM_RSSI_11G:
1770 * vap->iv_roam.rssi11b = value;
1772 * case IEEE80211_PARAM_ROAM_RATE_11A:
1773 * vap->iv_roam.rate11a = value;
1775 * case IEEE80211_PARAM_ROAM_RATE_11B:
1776 * vap->iv_roam.rate11bOnly = value;
1778 * case IEEE80211_PARAM_ROAM_RATE_11G:
1779 * vap->iv_roam.rate11b = value;
1781 * case IEEE80211_PARAM_UAPSDINFO:
1782 * if (vap->iv_opmode == IEEE80211_M_HOSTAP) {
1783 * if (ic->ic_caps & IEEE80211_C_UAPSD) {
1785 * IEEE80211_VAP_UAPSD_ENABLE(vap);
1787 * IEEE80211_VAP_UAPSD_DISABLE(vap);
1791 * else if (vap->iv_opmode == IEEE80211_M_STA) {
1792 * vap->iv_uapsdinfo = value;
1793 * IEEE80211_VAP_UAPSD_ENABLE(vap);
1797 * case IEEE80211_PARAM_SLEEP:
1798 * // XXX: Forced sleep for testing. Does not actually place the
1799 * // HW in sleep mode yet. this only makes sense for STAs.
1803 * IEEE80211_VAP_GOTOSLEEP(vap);
1807 * IEEE80211_VAP_WAKEUP(vap);
1809 * ieee80211_send_nulldata(ieee80211_ref_node(vap->iv_bss));
1811 * case IEEE80211_PARAM_QOSNULL:
1812 * // Force a QoS Null for testing.
1813 * ieee80211_send_qosnulldata(vap->iv_bss, value);
1815 * case IEEE80211_PARAM_PSPOLL:
1816 * // Force a PS-POLL for testing.
1817 * ieee80211_send_pspoll(vap->iv_bss);
1819 * case IEEE80211_PARAM_EOSPDROP:
1820 * if (vap->iv_opmode == IEEE80211_M_HOSTAP) {
1821 * if (value) IEEE80211_VAP_EOSPDROP_ENABLE(vap);
1822 * else IEEE80211_VAP_EOSPDROP_DISABLE(vap);
1825 * case IEEE80211_PARAM_MARKDFS:
1827 * ic->ic_flags_ext |= IEEE80211_FEXT_MARKDFS;
1829 * ic->ic_flags_ext &= ~IEEE80211_FEXT_MARKDFS;
1831 * case IEEE80211_PARAM_CHANBW:
1834 * ic->ic_chanbwflag = 0;
1837 * ic->ic_chanbwflag = IEEE80211_CHAN_HALF;
1840 * ic->ic_chanbwflag = IEEE80211_CHAN_QUARTER;
1847 * case IEEE80211_PARAM_SHORTPREAMBLE:
1849 * ic->ic_caps |= IEEE80211_C_SHPREAMBLE;
1851 * ic->ic_caps &= ~IEEE80211_C_SHPREAMBLE;
1856 * retv = EOPNOTSUPP;
1859 * // XXX should any of these cause a rescan?
1860 * if (retv == ENETRESET)
1861 * retv = IS_UP_AUTO(vap) ? ieee80211_open(vap->iv_dev) : 0;
1866 int usbdrvwext_setmode(struct net_device
*dev
, struct iw_request_info
*info
,
1867 void *w
, char *extra
)
1872 int usbdrvwext_getmode(struct net_device
*dev
, struct iw_request_info
*info
,
1873 void *w
, char *extra
)
1875 /* struct usbdrv_private *macp = dev->ml_priv; */
1876 struct iw_point
*wri
= (struct iw_point
*)extra
;
1879 strcpy(mode
, "11g");
1880 return copy_to_user(wri
->pointer
, mode
, 6) ? -EFAULT
: 0;
1883 int zfLnxPrivateIoctl(struct net_device
*dev
, struct zdap_ioctl
* zdreq
)
1885 /* void* regp = macp->regp; */
1893 case ZM_IOCTL_REG_READ
:
1894 zfiDbgReadReg(dev
, zdreq
->addr
);
1896 case ZM_IOCTL_REG_WRITE
:
1897 zfiDbgWriteReg(dev
, zdreq
->addr
, zdreq
->value
);
1899 case ZM_IOCTL_MEM_READ
:
1900 p
= (u32_t
*) bus_to_virt(zdreq
->addr
);
1902 "usbdrv: read memory addr: 0x%08x value:"
1903 " 0x%08x\n", zdreq
->addr
, *p
);
1905 case ZM_IOCTL_MEM_WRITE
:
1906 p
= (u32_t
*) bus_to_virt(zdreq
->addr
);
1909 "usbdrv : write value : 0x%08x to memory addr :"
1910 " 0x%08x\n", zdreq
->value
, zdreq
->addr
);
1912 case ZM_IOCTL_TALLY
:
1913 zfiWlanShowTally(dev
);
1915 zfiWlanResetTally(dev
);
1919 "ZM_IOCTL_TEST:len=%d\n", zdreq
->addr
);
1920 /* zfiWlanReadReg(dev, 0x10f400); */
1921 /* zfiWlanReadReg(dev, 0x10f404); */
1922 printk(KERN_WARNING
"IOCTL TEST\n");
1925 for (i
= 0; i
< zdreq
->addr
; i
++) {
1927 printk(KERN_WARNING
"\n");
1928 printk(KERN_WARNING
"%02X ",
1929 (unsigned char)zdreq
->data
[i
]);
1931 printk(KERN_WARNING
"\n");
1934 /* For Test?? 1 to 0 by CWYang(-) */
1938 /* Allocate a skb */
1939 s
= alloc_skb(2000, GFP_ATOMIC
);
1941 /* Copy data to skb */
1942 for (i
= 0; i
< zdreq
->addr
; i
++)
1943 s
->data
[i
] = zdreq
->data
[i
];
1944 s
->len
= zdreq
->addr
;
1946 /* Call zfIdlRecv() */
1947 zfiRecv80211(dev
, s
, NULL
);
1950 /************************* ZDCONFIG ***************************/
1952 zfiWlanSetFragThreshold(dev
, zdreq
->addr
);
1955 zfiWlanSetRtsThreshold(dev
, zdreq
->addr
);
1960 case ZM_IOCTL_KEY
: {
1962 struct zsKeyInfo keyInfo
;
1965 for (i
= 0; i
< 29; i
++)
1968 for (i
= 0; i
< zdreq
->addr
; i
++)
1969 key
[i
] = zdreq
->data
[i
];
1972 "key len=%d, key=%02x%02x%02x%02x%02x...\n",
1973 zdreq
->addr
, key
[0], key
[1], key
[2], key
[3], key
[4]);
1975 keyInfo
.keyLength
= zdreq
->addr
;
1976 keyInfo
.keyIndex
= 0;
1979 zfiWlanSetKey(dev
, keyInfo
);
1983 zfiWlanSetTxRate(dev
, zdreq
->addr
);
1985 case ZM_IOCTL_ENCRYPTION_MODE
:
1986 zfiWlanSetEncryMode(dev
, zdreq
->addr
);
1988 zfiWlanDisable(dev
, 0);
1992 case ZM_IOCTL_SIGNAL_STRENGTH
: {
1994 zfiWlanQuerySignalInfo(dev
, &buffer
[0]);
1996 "Current Signal Strength : %02d\n", buffer
[0]);
2000 case ZM_IOCTL_SIGNAL_QUALITY
: {
2002 zfiWlanQuerySignalInfo(dev
, &buffer
[0]);
2004 "Current Signal Quality : %02d\n", buffer
[1]);
2007 case ZM_IOCTL_SET_PIBSS_MODE
:
2008 if (zdreq
->addr
== 1)
2009 zfiWlanSetWlanMode(dev
, ZM_MODE_PSEUDO
);
2011 zfiWlanSetWlanMode(dev
, ZM_MODE_INFRASTRUCTURE
);
2013 zfiWlanDisable(dev
, 0);
2016 /********************* ZDCONFIG ***********************/
2018 printk(KERN_ERR
"usbdrv: error command = %x\n", cmd
);
2025 int usbdrv_wpa_ioctl(struct net_device
*dev
, struct athr_wlan_param
*zdparm
)
2028 u8_t bc_addr
[6] = { 0xff, 0xff, 0xff, 0xff, 0xff, 0xff };
2030 struct zsKeyInfo keyInfo
;
2031 struct usbdrv_private
*macp
= dev
->ml_priv
;
2035 /* zmw_get_wlan_dev(dev); */
2037 switch (zdparm
->cmd
) {
2038 case ZD_CMD_SET_ENCRYPT_KEY
:
2039 /* Set up key information */
2040 keyInfo
.keyLength
= zdparm
->u
.crypt
.key_len
;
2041 keyInfo
.keyIndex
= zdparm
->u
.crypt
.idx
;
2042 if (zfiWlanQueryWlanMode(dev
) == ZM_MODE_AP
) {
2044 keyInfo
.flag
= ZM_KEY_FLAG_AUTHENTICATOR
;
2047 keyInfo
.key
= zdparm
->u
.crypt
.key
;
2048 keyInfo
.initIv
= zdparm
->u
.crypt
.seq
;
2049 keyInfo
.macAddr
= (u16_t
*)zdparm
->sta_addr
;
2051 /* Identify the MAC address information */
2052 if (memcmp(zdparm
->sta_addr
, bc_addr
, sizeof(bc_addr
)) == 0)
2053 keyInfo
.flag
|= ZM_KEY_FLAG_GK
;
2055 keyInfo
.flag
|= ZM_KEY_FLAG_PK
;
2057 if (!strcmp(zdparm
->u
.crypt
.alg
, "NONE")) {
2058 /* u8_t zero_mac[]={0,0,0,0,0,0}; */
2060 /* Set key length to zero */
2061 keyInfo
.keyLength
= 0;
2064 if (zdparm
->sta_addr
[0] & 1) {
2065 /* if (macp->cardSetting.WPAIeLen==0)
2066 * { 802.1x dynamic WEP
2068 * mKeyFormat[0] = 0;
2069 * mPrivacyInvoked[0]=FALSE;
2070 * mCap[0] &= ~CAP_PRIVACY;
2071 * macp->cardSetting.EncryOnOff[0]=0;
2073 * mWpaBcKeyLen = mGkInstalled = 0;
2076 /* if (memcmp(zero_mac,zdparm->sta_addr, 6)==0)
2080 * pSetting->DynKeyMode=0;
2081 * pSetting->EncryMode[0]=0;
2087 printk(KERN_ERR
"Set Encryption Type NONE\n");
2089 } else if (!strcmp(zdparm
->u
.crypt
.alg
, "TKIP")) {
2090 zfiWlanSetEncryMode(dev
, ZM_TKIP
);
2091 /* //Linux Supplicant will inverse Tx/Rx key
2092 * //So we inverse it back, CWYang(+)
2093 * zfMemoryCopy(&temp[0], &keyInfo.key[16], 8);
2094 * zfMemoryCopy(&keyInfo.key[16], keyInfo.key[24], 8);
2095 * zfMemoryCopy(&keyInfo.key[24], &temp[0], 8);
2098 * for (k = 0; k < 8; k++)
2100 * temp = keyInfo.key[16 + k];
2101 * keyInfo.key[16 + k] = keyInfo.key[24 + k];
2102 * keyInfo.key[24 + k] = temp;
2104 * CamEncryType = ZM_TKIP;
2107 * mKeyFormat[0] = CamEncryType;
2108 * mDynKeyMode = pSetting->DynKeyMode = DYN_KEY_TKIP;
2111 } else if (!strcmp(zdparm
->u
.crypt
.alg
, "CCMP")) {
2112 zfiWlanSetEncryMode(dev
, ZM_AES
);
2113 /* CamEncryType = ZM_AES;
2116 * mKeyFormat[0] = CamEncryType;
2117 * mDynKeyMode = pSetting->DynKeyMode = DYN_KEY_AES;
2120 } else if (!strcmp(zdparm
->u
.crypt
.alg
, "WEP")) {
2121 if (keyInfo
.keyLength
== 5) {
2123 zfiWlanSetEncryMode(dev
, ZM_WEP64
);
2124 /* CamEncryType = ZM_WEP64; */
2125 /* tmpDynKeyMode=DYN_KEY_WEP64; */
2126 } else if (keyInfo
.keyLength
== 13) {
2127 /* keylen=13, WEP 128 */
2128 zfiWlanSetEncryMode(dev
, ZM_WEP128
);
2129 /* CamEncryType = ZM_WEP128; */
2130 /* tmpDynKeyMode=DYN_KEY_WEP128; */
2132 zfiWlanSetEncryMode(dev
, ZM_WEP256
);
2135 /* For Dynamic WEP key (Non-WPA Radius), the key ID range: 0-3
2136 * In WPA/RSN mode, the key ID range: 1-3, usually, a broadcast key.
2137 * For WEP key setting: we set mDynKeyMode and mKeyFormat in following
2139 * 1. For 802.1x dynamically generated WEP key method.
2140 * 2. For WPA/RSN mode, but key id == 0.
2141 * (But this is an impossible case)
2142 * So, only check case 1.
2143 * if (macp->cardSetting.WPAIeLen==0)
2145 * mKeyFormat[0] = CamEncryType;
2146 * mDynKeyMode = pSetting->DynKeyMode = tmpDynKeyMode;
2147 * mPrivacyInvoked[0]=TRUE;
2148 * mCap[0] |= CAP_PRIVACY;
2149 * macp->cardSetting.EncryOnOff[0]=1;
2154 /* DUMP key context */
2155 /* #ifdef WPA_DEBUG */
2156 if (keyInfo
.keyLength
> 0) {
2158 "Otus: Key Context:\n");
2159 for (ii
= 0; ii
< keyInfo
.keyLength
; ) {
2161 "0x%02x ", keyInfo
.key
[ii
]);
2162 if ((++ii
% 16) == 0)
2163 printk(KERN_WARNING
"\n");
2165 printk(KERN_WARNING
"\n");
2169 /* Set encrypt mode */
2170 /* zfiWlanSetEncryMode(dev, CamEncryType); */
2171 vapId
= zfLnxGetVapId(dev
);
2172 if (vapId
== 0xffff)
2175 keyInfo
.vapId
= vapId
+ 1;
2176 keyInfo
.vapAddr
[0] = keyInfo
.macAddr
[0];
2177 keyInfo
.vapAddr
[1] = keyInfo
.macAddr
[1];
2178 keyInfo
.vapAddr
[2] = keyInfo
.macAddr
[2];
2180 zfiWlanSetKey(dev
, keyInfo
);
2182 /* zfiWlanDisable(dev); */
2183 /* zfiWlanEnable(dev); */
2185 case ZD_CMD_SET_MLME
:
2186 printk(KERN_ERR
"usbdrv_wpa_ioctl: ZD_CMD_SET_MLME\n");
2188 /* Translate STA's address */
2189 sprintf(mac_addr
, "%02x:%02x:%02x:%02x:%02x:%02x",
2190 zdparm
->sta_addr
[0], zdparm
->sta_addr
[1],
2191 zdparm
->sta_addr
[2], zdparm
->sta_addr
[3],
2192 zdparm
->sta_addr
[4], zdparm
->sta_addr
[5]);
2194 switch (zdparm
->u
.mlme
.cmd
) {
2195 case MLME_STA_DEAUTH
:
2197 " -------Call zfiWlanDeauth, reason:%d\n",
2198 zdparm
->u
.mlme
.reason_code
);
2199 if (zfiWlanDeauth(dev
, (u16_t
*) zdparm
->sta_addr
,
2200 zdparm
->u
.mlme
.reason_code
) != 0)
2201 printk(KERN_ERR
"Can't deauthencate STA: %s\n",
2204 printk(KERN_ERR
"Deauthenticate STA: %s"
2205 "with reason code: %d\n",
2206 mac_addr
, zdparm
->u
.mlme
.reason_code
);
2208 case MLME_STA_DISASSOC
:
2210 " -------Call zfiWlanDeauth, reason:%d\n",
2211 zdparm
->u
.mlme
.reason_code
);
2212 if (zfiWlanDeauth(dev
, (u16_t
*) zdparm
->sta_addr
,
2213 zdparm
->u
.mlme
.reason_code
) != 0)
2214 printk(KERN_ERR
"Can't disassociate STA: %s\n",
2217 printk(KERN_ERR
"Disassociate STA: %s"
2218 "with reason code: %d\n",
2219 mac_addr
, zdparm
->u
.mlme
.reason_code
);
2222 printk(KERN_ERR
"MLME command: 0x%04x not support\n",
2223 zdparm
->u
.mlme
.cmd
);
2228 case ZD_CMD_SCAN_REQ
:
2229 printk(KERN_ERR
"usbdrv_wpa_ioctl: ZD_CMD_SCAN_REQ\n");
2231 case ZD_CMD_SET_GENERIC_ELEMENT
: {
2233 printk(KERN_ERR
"usbdrv_wpa_ioctl:"
2234 " ZD_CMD_SET_GENERIC_ELEMENT\n");
2237 * zm_msg1_mm(ZM_LV_0, "CWY - wpaie Length : ",
2238 * zdparm->u.generic_elem.len);
2240 printk(KERN_ERR
"wpaie Length : % d\n",
2241 zdparm
->u
.generic_elem
.len
);
2242 if (zfiWlanQueryWlanMode(dev
) == ZM_MODE_AP
) {
2244 zfiWlanSetWpaIe(dev
, zdparm
->u
.generic_elem
.data
,
2245 zdparm
->u
.generic_elem
.len
);
2247 macp
->supLen
= zdparm
->u
.generic_elem
.len
;
2248 memcpy(macp
->supIe
, zdparm
->u
.generic_elem
.data
,
2249 zdparm
->u
.generic_elem
.len
);
2251 zfiWlanSetWpaSupport(dev
, 1);
2252 /* zfiWlanSetWpaIe(dev, zdparm->u.generic_elem.data,
2253 * zdparm->u.generic_elem.len);
2255 len
= zdparm
->u
.generic_elem
.len
;
2256 wpaie
= zdparm
->u
.generic_elem
.data
;
2258 printk(KERN_ERR
"wd->ap.wpaLen : % d\n", len
);
2261 for(ii
= 0; ii
< len
;) {
2262 printk(KERN_ERR
"0x%02x ", wpaie
[ii
]);
2264 if((++ii
% 16) == 0)
2265 printk(KERN_ERR
"\n");
2267 printk(KERN_ERR
"\n");
2269 /* #ifdef ZM_HOSTAPD_SUPPORT
2270 * if (wd->wlanMode == ZM_MODE_AP)
2271 * {// Update Beacon FIFO in the next TBTT.
2272 * memcpy(&mWPAIe, pSetting->WPAIe, pSetting->WPAIeLen);
2273 * printk(KERN_ERR "Copy WPA IE into mWPAIe\n");
2280 /* #ifdef ZM_HOSTAPD_SUPPORT */
2281 case ZD_CMD_GET_TSC
:
2282 printk(KERN_ERR
"usbdrv_wpa_ioctl : ZD_CMD_GET_TSC\n");
2287 printk(KERN_ERR
"usbdrv_wpa_ioctl default : 0x%04x\n",
2296 #ifdef ZM_ENABLE_CENC
2297 int usbdrv_cenc_ioctl(struct net_device
*dev
, struct zydas_cenc_param
*zdparm
)
2299 /* struct usbdrv_private *macp = dev->ml_priv; */
2300 struct zsKeyInfo keyInfo
;
2302 u8_t bc_addr
[6] = { 0xff, 0xff, 0xff, 0xff, 0xff, 0xff };
2307 apId
= zfLnxGetVapId(dev
);
2309 if (apId
== 0xffff) {
2315 switch (zdparm
->cmd
) {
2316 case ZM_CMD_CENC_SETCENC
:
2317 printk(KERN_ERR
"ZM_CMD_CENC_SETCENC\n");
2318 printk(KERN_ERR
"length : % d\n", zdparm
->len
);
2319 printk(KERN_ERR
"policy : % d\n", zdparm
->u
.info
.cenc_policy
);
2321 case ZM_CMD_CENC_SETKEY
:
2322 /* ret = wai_ioctl_setkey(vap, ioctl_msg); */
2323 printk(KERN_ERR
"ZM_CMD_CENC_SETKEY\n");
2325 printk(KERN_ERR
"MAC address = ");
2326 for (ii
= 0; ii
< 6; ii
++) {
2327 printk(KERN_ERR
"0x%02x ",
2328 zdparm
->u
.crypt
.sta_addr
[ii
]);
2330 printk(KERN_ERR
"\n");
2332 printk(KERN_ERR
"Key Index : % d\n", zdparm
->u
.crypt
.keyid
);
2333 printk(KERN_ERR
"Encryption key = ");
2334 for (ii
= 0; ii
< 16; ii
++) {
2335 printk(KERN_ERR
"0x%02x ", zdparm
->u
.crypt
.key
[ii
]);
2337 printk(KERN_ERR
"\n");
2339 printk(KERN_ERR
"MIC key = ");
2340 for(ii
= 16; ii
< ZM_CENC_KEY_SIZE
; ii
++) {
2341 printk(KERN_ERR
"0x%02x ", zdparm
->u
.crypt
.key
[ii
]);
2343 printk(KERN_ERR
"\n");
2345 /* Set up key information */
2346 keyInfo
.keyLength
= ZM_CENC_KEY_SIZE
;
2347 keyInfo
.keyIndex
= zdparm
->u
.crypt
.keyid
;
2348 keyInfo
.flag
= ZM_KEY_FLAG_AUTHENTICATOR
| ZM_KEY_FLAG_CENC
;
2349 keyInfo
.key
= zdparm
->u
.crypt
.key
;
2350 keyInfo
.macAddr
= (u16_t
*)zdparm
->u
.crypt
.sta_addr
;
2352 /* Identify the MAC address information */
2353 if (memcmp(zdparm
->u
.crypt
.sta_addr
, bc_addr
,
2354 sizeof(bc_addr
)) == 0) {
2355 keyInfo
.flag
|= ZM_KEY_FLAG_GK
;
2356 keyInfo
.vapId
= apId
;
2357 memcpy(keyInfo
.vapAddr
, dev
->dev_addr
, ETH_ALEN
);
2359 keyInfo
.flag
|= ZM_KEY_FLAG_PK
;
2362 zfiWlanSetKey(dev
, keyInfo
);
2365 case ZM_CMD_CENC_REKEY
:
2366 /* ret = wai_ioctl_rekey(vap, ioctl_msg); */
2367 printk(KERN_ERR
"ZM_CMD_CENC_REKEY\n");
2374 /* if (retv == ENETRESET) */
2375 /* retv = IS_UP_AUTO(vap) ? ieee80211_open(vap->iv_dev) : 0; */
2379 #endif /* ZM_ENABLE_CENC */
2381 int usbdrv_ioctl(struct net_device
*dev
, struct ifreq
*ifr
, int cmd
)
2383 /* struct usbdrv_private *macp; */
2385 struct zdap_ioctl zdreq
;
2386 struct iwreq
*wrq
= (struct iwreq
*)ifr
;
2387 struct athr_wlan_param zdparm
;
2388 struct usbdrv_private
*macp
= dev
->ml_priv
;
2390 int err
= 0, val
= 0;
2393 /* regp = macp->regp; */
2395 if (!netif_running(dev
))
2400 strcpy(wrq
->u
.name
, "IEEE 802.11-DS");
2403 err
= usbdrvwext_giwap(dev
, NULL
, &wrq
->u
.ap_addr
, NULL
);
2406 err
= usbdrvwext_siwap(dev
, NULL
, &wrq
->u
.ap_addr
, NULL
);
2409 err
= usbdrvwext_giwmode(dev
, NULL
, &wrq
->u
.mode
, NULL
);
2412 printk(KERN_ERR
"CWY - usbdrvwext_siwessid\n");
2413 /* err = usbdrv_ioctl_setessid(dev, &wrq->u.essid); */
2414 err
= usbdrvwext_siwessid(dev
, NULL
, &wrq
->u
.essid
, NULL
);
2420 err
= usbdrvwext_giwessid(dev
, NULL
, &wrq
->u
.essid
, NULL
);
2423 err
= usbdrv_ioctl_setrts(dev
, &wrq
->u
.rts
);
2428 case SIOCIWFIRSTPRIV
+ 0x2: {
2429 /* printk("CWY - SIOCIWFIRSTPRIV + 0x2(set_auth)\n"); */
2430 if (!capable(CAP_NET_ADMIN
)) {
2434 val
= *((int *) wrq
->u
.name
);
2435 if ((val
< 0) || (val
> 2)) {
2439 zfiWlanSetAuthenticationMode(dev
, val
);
2441 if (macp
->DeviceOpened
== 1) {
2442 zfiWlanDisable(dev
, 0);
2452 case SIOCIWFIRSTPRIV
+ 0x3: {
2453 int AuthMode
= ZM_AUTH_MODE_OPEN
;
2455 /* printk("CWY - SIOCIWFIRSTPRIV + 0x3(get_auth)\n"); */
2457 if (wrq
->u
.data
.pointer
) {
2458 wrq
->u
.data
.flags
= 1;
2460 AuthMode
= zfiWlanQueryAuthenticationMode(dev
, 0);
2461 if (AuthMode
== ZM_AUTH_MODE_OPEN
) {
2462 wrq
->u
.data
.length
= 12;
2464 if (copy_to_user(wrq
->u
.data
.pointer
,
2465 "open system", 12)) {
2468 } else if (AuthMode
== ZM_AUTH_MODE_SHARED_KEY
) {
2469 wrq
->u
.data
.length
= 11;
2471 if (copy_to_user(wrq
->u
.data
.pointer
,
2472 "shared key", 11)) {
2475 } else if (AuthMode
== ZM_AUTH_MODE_AUTO
) {
2476 wrq
->u
.data
.length
= 10;
2478 if (copy_to_user(wrq
->u
.data
.pointer
,
2490 if (copy_from_user(&zdreq
, ifr
->ifr_data
, sizeof(zdreq
))) {
2491 printk(KERN_ERR
"usbdrv : copy_from_user error\n");
2495 /* printk(KERN_WARNING
2496 * "usbdrv : cmd = % 2x, reg = 0x%04lx,
2497 *value = 0x%08lx\n",
2498 * zdreq.cmd, zdreq.addr, zdreq.value);
2500 zfLnxPrivateIoctl(dev
, &zdreq
);
2505 if (copy_from_user(&zdparm
, ifr
->ifr_data
,
2506 sizeof(struct athr_wlan_param
))) {
2507 printk(KERN_ERR
"usbdrv : copy_from_user error\n");
2511 usbdrv_wpa_ioctl(dev
, &zdparm
);
2514 case ZD_IOCTL_PARAM
: {
2519 /* Point to the name field and retrieve the
2520 * op and arg elements.
2522 p
= (int *)wrq
->u
.name
;
2526 if (op
== ZD_PARAM_ROAMING
) {
2528 "*************ZD_PARAM_ROAMING : % d\n", arg
);
2529 /* macp->cardSetting.ap_scan=(U8)arg; */
2531 if (op
== ZD_PARAM_PRIVACY
) {
2532 printk(KERN_ERR
"ZD_IOCTL_PRIVACY : ");
2534 /* Turn on the privacy invoke flag */
2536 /* mCap[0] |= CAP_PRIVACY; */
2537 /* macp->cardSetting.EncryOnOff[0] = 1; */
2538 printk(KERN_ERR
"enable\n");
2541 /* mCap[0] &= ~CAP_PRIVACY; */
2542 /* macp->cardSetting.EncryOnOff[0] = 0; */
2543 printk(KERN_ERR
"disable\n");
2547 if (op
== ZD_PARAM_WPA
) {
2549 printk(KERN_ERR
"ZD_PARAM_WPA : ");
2552 printk(KERN_ERR
"enable\n");
2554 if (zfiWlanQueryWlanMode(dev
) != ZM_MODE_AP
) {
2555 printk(KERN_ERR
"Station Mode\n");
2556 /* zfiWlanQueryWpaIe(dev, (u8_t *)
2557 &wpaIe, &wpalen); */
2558 /* printk("wpaIe : % 2x, % 2x, % 2x\n",
2559 wpaIe[21], wpaIe[22], wpaIe[23]); */
2560 /* printk("rsnIe : % 2x, % 2x, % 2x\n",
2561 wpaIe[17], wpaIe[18], wpaIe[19]); */
2562 if ((macp
->supIe
[21] == 0x50) &&
2563 (macp
->supIe
[22] == 0xf2) &&
2564 (macp
->supIe
[23] == 0x2)) {
2566 "wd->sta.authMode = ZM_AUTH_MODE_WPAPSK\n");
2567 /* wd->sta.authMode = ZM_AUTH_MODE_WPAPSK; */
2568 /* wd->ws.authMode = ZM_AUTH_MODE_WPAPSK; */
2569 zfiWlanSetAuthenticationMode(dev
,
2570 ZM_AUTH_MODE_WPAPSK
);
2571 } else if ((macp
->supIe
[21] == 0x50) &&
2572 (macp
->supIe
[22] == 0xf2) &&
2573 (macp
->supIe
[23] == 0x1)) {
2575 "wd->sta.authMode = ZM_AUTH_MODE_WPA\n");
2576 /* wd->sta.authMode = ZM_AUTH_MODE_WPA; */
2577 /* wd->ws.authMode = ZM_AUTH_MODE_WPA; */
2578 zfiWlanSetAuthenticationMode(dev
,
2580 } else if ((macp
->supIe
[17] == 0xf) &&
2581 (macp
->supIe
[18] == 0xac) &&
2582 (macp
->supIe
[19] == 0x2))
2585 "wd->sta.authMode = ZM_AUTH_MODE_WPA2PSK\n");
2586 /* wd->sta.authMode = ZM_AUTH_MODE_WPA2PSK; */
2587 /* wd->ws.authMode = ZM_AUTH_MODE_WPA2PSK; */
2588 zfiWlanSetAuthenticationMode(dev
,
2589 ZM_AUTH_MODE_WPA2PSK
);
2590 } else if ((macp
->supIe
[17] == 0xf) &&
2591 (macp
->supIe
[18] == 0xac) &&
2592 (macp
->supIe
[19] == 0x1))
2595 "wd->sta.authMode = ZM_AUTH_MODE_WPA2\n");
2596 /* wd->sta.authMode = ZM_AUTH_MODE_WPA2; */
2597 /* wd->ws.authMode = ZM_AUTH_MODE_WPA2; */
2598 zfiWlanSetAuthenticationMode(dev
,
2602 if ((macp
->supIe
[21] == 0x50) ||
2603 (macp
->supIe
[22] == 0xf2)) {
2604 if (macp
->supIe
[11] == 0x2) {
2606 "wd->sta.wepStatus = ZM_ENCRYPTION_TKIP\n");
2607 /* wd->sta.wepStatus = ZM_ENCRYPTION_TKIP; */
2608 /* wd->ws.wepStatus = ZM_ENCRYPTION_TKIP; */
2609 zfiWlanSetWepStatus(dev
, ZM_ENCRYPTION_TKIP
);
2612 "wd->sta.wepStatus = ZM_ENCRYPTION_AES\n");
2613 /* wd->sta.wepStatus = ZM_ENCRYPTION_AES; */
2614 /* wd->ws.wepStatus = ZM_ENCRYPTION_AES; */
2615 zfiWlanSetWepStatus(dev
, ZM_ENCRYPTION_AES
);
2619 if ((macp
->supIe
[17] == 0xf) ||
2620 (macp
->supIe
[18] == 0xac)) {
2621 if (macp
->supIe
[13] == 0x2) {
2623 "wd->sta.wepStatus = ZM_ENCRYPTION_TKIP\n");
2624 /* wd->sta.wepStatus = ZM_ENCRYPTION_TKIP; */
2625 /* wd->ws.wepStatus = ZM_ENCRYPTION_TKIP; */
2626 zfiWlanSetWepStatus(dev
, ZM_ENCRYPTION_TKIP
);
2629 "wd->sta.wepStatus = ZM_ENCRYPTION_AES\n");
2630 /* wd->sta.wepStatus = ZM_ENCRYPTION_AES; */
2631 /* wd->ws.wepStatus = ZM_ENCRYPTION_AES; */
2632 zfiWlanSetWepStatus(dev
, ZM_ENCRYPTION_AES
);
2636 zfiWlanSetWpaSupport(dev
, 1);
2638 /* Reset the WPA related variables */
2639 printk(KERN_ERR
"disable\n");
2641 zfiWlanSetWpaSupport(dev
, 0);
2642 zfiWlanSetAuthenticationMode(dev
, ZM_AUTH_MODE_OPEN
);
2643 zfiWlanSetWepStatus(dev
, ZM_ENCRYPTION_WEP_DISABLED
);
2645 /* Now we only set the length in the WPA IE
2647 *macp->cardSetting.WPAIe[1] = 0;
2652 if (op
== ZD_PARAM_COUNTERMEASURES
) {
2654 "****************ZD_PARAM_COUNTERMEASURES : ");
2657 /* mCounterMeasureState=1; */
2658 printk(KERN_ERR
"enable\n");
2660 /* mCounterMeasureState=0; */
2661 printk(KERN_ERR
"disable\n");
2664 if (op
== ZD_PARAM_DROPUNENCRYPTED
) {
2665 printk(KERN_ERR
"ZD_PARAM_DROPUNENCRYPTED : ");
2668 printk(KERN_ERR
"enable\n");
2670 printk(KERN_ERR
"disable\n");
2673 if (op
== ZD_PARAM_AUTH_ALGS
) {
2674 printk(KERN_ERR
"ZD_PARAM_AUTH_ALGS : ");
2677 printk(KERN_ERR
"OPEN_SYSTEM\n");
2679 printk(KERN_ERR
"SHARED_KEY\n");
2682 if (op
== ZD_PARAM_WPS_FILTER
) {
2683 printk(KERN_ERR
"ZD_PARAM_WPS_FILTER : ");
2686 /* mCounterMeasureState=1; */
2687 macp
->forwardMgmt
= 1;
2688 printk(KERN_ERR
"enable\n");
2690 /* mCounterMeasureState=0; */
2691 macp
->forwardMgmt
= 0;
2692 printk(KERN_ERR
"disable\n");
2698 case ZD_IOCTL_GETWPAIE
: {
2699 struct ieee80211req_wpaie req_wpaie
;
2703 apId
= zfLnxGetVapId(dev
);
2705 if (apId
== 0xffff) {
2711 if (copy_from_user(&req_wpaie
, ifr
->ifr_data
,
2712 sizeof(struct ieee80211req_wpaie
))) {
2713 printk(KERN_ERR
"usbdrv : copy_from_user error\n");
2717 for (i
= 0; i
< ZM_OAL_MAX_STA_SUPPORT
; i
++) {
2718 for (j
= 0; j
< IEEE80211_ADDR_LEN
; j
++) {
2719 if (macp
->stawpaie
[i
].wpa_macaddr
[j
] !=
2720 req_wpaie
.wpa_macaddr
[j
])
2727 if (i
< ZM_OAL_MAX_STA_SUPPORT
) {
2728 /* printk("ZD_IOCTL_GETWPAIE - sta index = % d\n", i); */
2729 memcpy(req_wpaie
.wpa_ie
, macp
->stawpaie
[i
].wpa_ie
,
2730 IEEE80211_MAX_IE_SIZE
);
2733 if (copy_to_user(wrq
->u
.data
.pointer
, &req_wpaie
,
2734 sizeof(struct ieee80211req_wpaie
))) {
2741 #ifdef ZM_ENABLE_CENC
2743 if (copy_from_user(&macp
->zd_wpa_req
, ifr
->ifr_data
,
2744 sizeof(struct athr_wlan_param
))) {
2745 printk(KERN_ERR
"usbdrv : copy_from_user error\n");
2749 usbdrv_cenc_ioctl(dev
,
2750 (struct zydas_cenc_param
*)&macp
->zd_wpa_req
);
2753 #endif /* ZM_ENABLE_CENC */