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 struct zsBssListV1
*pBssList
;
871 /* BssList = wd->sta.pBssList; */
872 /* zmw_get_wlan_dev(dev); */
874 if (macp
->DeviceOpened
!= 1)
877 /* struct zsBssList BssList; */
878 pBssList
= kmalloc(sizeof(struct zsBssListV1
), GFP_KERNEL
);
879 if (pBssList
== NULL
)
882 if (data
->length
== 0)
883 end_buf
= extra
+ IW_SCAN_MAX_DATA
;
885 end_buf
= extra
+ data
->length
;
887 printk(KERN_WARNING
"giwscan - Report Scan Results\n");
888 /* printk("giwscan - BssList Sreucture Len : %d\n", sizeof(BssList));
889 * printk("giwscan - BssList Count : %d\n",
890 * wd->sta.pBssList->bssCount);
891 * printk("giwscan - UpdateBssList Count : %d\n",
892 * wd->sta.pUpdateBssList->bssCount);
894 zfiWlanQueryBssListV1(dev
, pBssList
);
895 /* zfiWlanQueryBssList(dev, &BssList); */
897 /* Read and parse all entries */
898 printk(KERN_WARNING
"giwscan - pBssList->bssCount : %d\n",
900 /* printk("giwscan - BssList.bssCount : %d\n", BssList.bssCount); */
902 for (i
= 0; i
< pBssList
->bssCount
; i
++) {
903 /* Translate to WE format this entry
904 * current_ev = usbdrv_translate_scan(dev, info, current_ev,
905 * extra + IW_SCAN_MAX_DATA, &pBssList->bssInfo[i]);
907 current_ev
= usbdrv_translate_scan(dev
, info
, current_ev
,
908 end_buf
, &pBssList
->bssInfo
[i
]);
910 if (current_ev
== end_buf
) {
912 data
->length
= current_ev
- extra
;
918 data
->length
= (current_ev
- extra
);
919 data
->flags
= 0; /* todo */
926 int usbdrvwext_siwessid(struct net_device
*dev
,
927 struct iw_request_info
*info
,
928 struct iw_point
*essid
, char *extra
)
930 char EssidBuf
[IW_ESSID_MAX_SIZE
+ 1];
931 struct usbdrv_private
*macp
= dev
->ml_priv
;
933 if (!netif_running(dev
))
936 if (essid
->flags
== 1) {
937 if (essid
->length
> IW_ESSID_MAX_SIZE
)
940 if (copy_from_user(&EssidBuf
, essid
->pointer
, essid
->length
))
943 EssidBuf
[essid
->length
] = '\0';
944 /* printk("siwessid - Set Essid : %s\n",EssidBuf); */
945 /* printk("siwessid - Essid Len : %d\n",essid->length); */
946 /* printk("siwessid - Essid Flag : %x\n",essid->flags); */
947 if (macp
->DeviceOpened
== 1) {
948 zfiWlanSetSSID(dev
, EssidBuf
, strlen(EssidBuf
));
949 zfiWlanSetFrequency(dev
, zfiWlanQueryFrequency(dev
),
951 zfiWlanSetEncryMode(dev
, zfiWlanQueryEncryMode(dev
));
952 /* u8_t wpaieLen,wpaie[50]; */
953 /* zfiWlanQueryWpaIe(dev, wpaie, &wpaieLen); */
954 zfiWlanDisable(dev
, 0);
956 /* if (wpaieLen > 2) */
957 /* zfiWlanSetWpaIe(dev, wpaie, wpaieLen); */
964 int usbdrvwext_giwessid(struct net_device
*dev
,
965 struct iw_request_info
*info
,
966 struct iw_point
*essid
, char *extra
)
968 struct usbdrv_private
*macp
= dev
->ml_priv
;
970 char EssidBuf
[IW_ESSID_MAX_SIZE
+ 1];
973 if (!netif_running(dev
))
976 if (macp
->DeviceOpened
!= 1)
979 zfiWlanQuerySSID(dev
, &EssidBuf
[0], &EssidLen
);
981 /* Convert type from unsigned char to char */
982 ssid_len
= (int)EssidLen
;
984 /* Make sure the essid length is not greater than IW_ESSID_MAX_SIZE */
985 if (ssid_len
> IW_ESSID_MAX_SIZE
)
986 ssid_len
= IW_ESSID_MAX_SIZE
;
988 EssidBuf
[ssid_len
] = '\0';
991 essid
->length
= strlen(EssidBuf
);
993 memcpy(extra
, EssidBuf
, essid
->length
);
994 /* wireless.c in Kernel would handle copy_to_user -- line 679 */
995 /* if (essid->pointer) {
996 * if (copy_to_user(essid->pointer, EssidBuf, essid->length)) {
997 * printk("giwessid - copy_to_user Fail\n");
1006 int usbdrvwext_siwnickn(struct net_device
*dev
,
1007 struct iw_request_info
*info
,
1008 struct iw_point
*data
, char *nickname
)
1010 /* Exist but junk--CWYang(+) */
1014 int usbdrvwext_giwnickn(struct net_device
*dev
,
1015 struct iw_request_info
*info
,
1016 struct iw_point
*data
, char *nickname
)
1018 struct usbdrv_private
*macp
= dev
->ml_priv
;
1020 char EssidBuf
[IW_ESSID_MAX_SIZE
+ 1];
1022 if (macp
->DeviceOpened
!= 1)
1025 zfiWlanQuerySSID(dev
, &EssidBuf
[0], &EssidLen
);
1026 EssidBuf
[EssidLen
] = 0;
1029 data
->length
= strlen(EssidBuf
);
1031 memcpy(nickname
, EssidBuf
, data
->length
);
1036 int usbdrvwext_siwrate(struct net_device
*dev
,
1037 struct iw_request_info
*info
,
1038 struct iw_param
*frq
, char *extra
)
1040 struct usbdrv_private
*macp
= dev
->ml_priv
;
1041 /* Array to Define Rate Number that Send to Driver */
1042 u16_t zcIndextoRateBG
[16] = {1000, 2000, 5500, 11000, 0, 0, 0, 0,
1043 48000, 24000, 12000, 6000, 54000, 36000, 18000, 9000};
1044 u16_t zcRateToMCS
[] = {0xff, 0, 1, 2, 3, 0xb, 0xf, 0xa, 0xe, 0x9, 0xd,
1046 u8_t i
, RateIndex
= 4;
1049 /* printk("frq->disabled : 0x%x\n",frq->disabled); */
1050 /* printk("frq->value : 0x%x\n",frq->value); */
1052 RateKbps
= frq
->value
/ 1000;
1053 /* printk("RateKbps : %d\n", RateKbps); */
1054 for (i
= 0; i
< 16; i
++) {
1055 if (RateKbps
== zcIndextoRateBG
[i
])
1059 if (zcIndextoRateBG
[RateIndex
] == 0)
1061 /* printk("RateIndex : %x\n", RateIndex); */
1062 for (i
= 0; i
< 13; i
++)
1063 if (RateIndex
== zcRateToMCS
[i
])
1065 /* printk("Index : %x\n", i); */
1066 if (RateKbps
== 65000) {
1068 printk(KERN_WARNING
"RateIndex : %d\n", RateIndex
);
1071 if (macp
->DeviceOpened
== 1) {
1072 zfiWlanSetTxRate(dev
, i
);
1073 /* zfiWlanDisable(dev); */
1074 /* zfiWlanEnable(dev); */
1080 int usbdrvwext_giwrate(struct net_device
*dev
,
1081 struct iw_request_info
*info
,
1082 struct iw_param
*frq
, char *extra
)
1084 struct usbdrv_private
*macp
= dev
->ml_priv
;
1086 if (!netif_running(dev
))
1089 if (macp
->DeviceOpened
!= 1)
1094 frq
->value
= zfiWlanQueryRxRate(dev
) * 1000;
1099 int usbdrvwext_siwrts(struct net_device
*dev
,
1100 struct iw_request_info
*info
,
1101 struct iw_param
*rts
, char *extra
)
1103 struct usbdrv_private
*macp
= dev
->ml_priv
;
1104 int val
= rts
->value
;
1106 if (macp
->DeviceOpened
!= 1)
1112 if ((val
< 0) || (val
> 2347))
1115 zfiWlanSetRtsThreshold(dev
, val
);
1120 int usbdrvwext_giwrts(struct net_device
*dev
,
1121 struct iw_request_info
*info
,
1122 struct iw_param
*rts
, char *extra
)
1124 struct usbdrv_private
*macp
= dev
->ml_priv
;
1126 if (!netif_running(dev
))
1129 if (macp
->DeviceOpened
!= 1)
1132 rts
->value
= zfiWlanQueryRtsThreshold(dev
);
1133 rts
->disabled
= (rts
->value
>= 2347);
1139 int usbdrvwext_siwfrag(struct net_device
*dev
,
1140 struct iw_request_info
*info
,
1141 struct iw_param
*frag
, char *extra
)
1143 struct usbdrv_private
*macp
= dev
->ml_priv
;
1144 u16_t fragThreshold
;
1146 if (macp
->DeviceOpened
!= 1)
1152 fragThreshold
= frag
->value
;
1154 zfiWlanSetFragThreshold(dev
, fragThreshold
);
1159 int usbdrvwext_giwfrag(struct net_device
*dev
,
1160 struct iw_request_info
*info
,
1161 struct iw_param
*frag
, char *extra
)
1163 struct usbdrv_private
*macp
= dev
->ml_priv
;
1165 unsigned long irqFlag
;
1167 if (!netif_running(dev
))
1170 if (macp
->DeviceOpened
!= 1)
1173 spin_lock_irqsave(&macp
->cs_lock
, irqFlag
);
1175 val
= zfiWlanQueryFragThreshold(dev
);
1179 frag
->disabled
= (val
>= 2346);
1182 spin_unlock_irqrestore(&macp
->cs_lock
, irqFlag
);
1187 int usbdrvwext_siwtxpow(struct net_device
*dev
,
1188 struct iw_request_info
*info
,
1189 struct iw_param
*rrq
, char *extra
)
1191 /* Not support yet--CWYng(+) */
1195 int usbdrvwext_giwtxpow(struct net_device
*dev
,
1196 struct iw_request_info
*info
,
1197 struct iw_param
*rrq
, char *extra
)
1199 /* Not support yet--CWYng(+) */
1203 int usbdrvwext_siwretry(struct net_device
*dev
,
1204 struct iw_request_info
*info
,
1205 struct iw_param
*rrq
, char *extra
)
1207 /* Do nothing--CWYang(+) */
1211 int usbdrvwext_giwretry(struct net_device
*dev
,
1212 struct iw_request_info
*info
,
1213 struct iw_param
*rrq
, char *extra
)
1215 /* Do nothing--CWYang(+) */
1219 int usbdrvwext_siwencode(struct net_device
*dev
,
1220 struct iw_request_info
*info
,
1221 struct iw_point
*erq
, char *key
)
1223 struct zsKeyInfo keyInfo
;
1225 int WepState
= ZM_ENCRYPTION_WEP_DISABLED
;
1226 struct usbdrv_private
*macp
= dev
->ml_priv
;
1228 if (!netif_running(dev
))
1231 if ((erq
->flags
& IW_ENCODE_DISABLED
) == 0) {
1233 keyInfo
.keyLength
= erq
->length
;
1234 keyInfo
.keyIndex
= (erq
->flags
& IW_ENCODE_INDEX
) - 1;
1235 if (keyInfo
.keyIndex
>= 4)
1236 keyInfo
.keyIndex
= 0;
1237 keyInfo
.flag
= ZM_KEY_FLAG_DEFAULT_KEY
;
1239 zfiWlanSetKey(dev
, keyInfo
);
1240 WepState
= ZM_ENCRYPTION_WEP_ENABLED
;
1242 for (i
= 1; i
< 4; i
++)
1243 zfiWlanRemoveKey(dev
, 0, i
);
1244 WepState
= ZM_ENCRYPTION_WEP_DISABLED
;
1245 /* zfiWlanSetEncryMode(dev, ZM_NO_WEP); */
1248 if (macp
->DeviceOpened
== 1) {
1249 zfiWlanSetWepStatus(dev
, WepState
);
1250 zfiWlanSetFrequency(dev
, zfiWlanQueryFrequency(dev
), FALSE
);
1251 /* zfiWlanSetEncryMode(dev, zfiWlanQueryEncryMode(dev)); */
1252 /* u8_t wpaieLen,wpaie[50]; */
1253 /* zfiWlanQueryWpaIe(dev, wpaie, &wpaieLen); */
1254 zfiWlanDisable(dev
, 0);
1256 /* if (wpaieLen > 2) */
1257 /* zfiWlanSetWpaIe(dev, wpaie, wpaieLen); */
1263 int usbdrvwext_giwencode(struct net_device
*dev
,
1264 struct iw_request_info
*info
,
1265 struct iw_point
*erq
, char *key
)
1267 struct usbdrv_private
*macp
= dev
->ml_priv
;
1268 u8_t EncryptionMode
;
1271 if (macp
->DeviceOpened
!= 1)
1274 EncryptionMode
= zfiWlanQueryEncryMode(dev
);
1277 erq
->flags
= IW_ENCODE_ENABLED
;
1279 erq
->flags
= IW_ENCODE_DISABLED
;
1281 /* We can't return the key, so set the proper flag and return zero */
1282 erq
->flags
|= IW_ENCODE_NOKEY
;
1285 /* Copy the key to the user buffer */
1286 switch (EncryptionMode
) {
1302 #ifdef ZM_ENABLE_CENC
1304 /* ZM_ENABLE_CENC */
1313 printk(KERN_ERR
"Unknown EncryMode\n");
1316 erq
->length
= keyLen
;
1321 int usbdrvwext_siwpower(struct net_device
*dev
,
1322 struct iw_request_info
*info
,
1323 struct iw_param
*frq
, char *extra
)
1325 struct usbdrv_private
*macp
= dev
->ml_priv
;
1328 if (macp
->DeviceOpened
!= 1)
1332 PSMode
= ZM_STA_PS_NONE
;
1334 PSMode
= ZM_STA_PS_MAX
;
1336 zfiWlanSetPowerSaveMode(dev
, PSMode
);
1341 int usbdrvwext_giwpower(struct net_device
*dev
,
1342 struct iw_request_info
*info
,
1343 struct iw_param
*frq
, char *extra
)
1345 unsigned long irqFlag
;
1346 struct usbdrv_private
*macp
= dev
->ml_priv
;
1348 if (macp
->DeviceOpened
!= 1)
1351 spin_lock_irqsave(&macp
->cs_lock
, irqFlag
);
1353 if (zfiWlanQueryPowerSaveMode(dev
) == ZM_STA_PS_NONE
)
1358 spin_unlock_irqrestore(&macp
->cs_lock
, irqFlag
);
1363 /*int usbdrvwext_setparam(struct net_device *dev, struct iw_request_info *info,
1364 * void *w, char *extra)
1366 * struct ieee80211vap *vap = dev->ml_priv;
1367 * struct ieee80211com *ic = vap->iv_ic;
1368 * struct ieee80211_rsnparms *rsn = &vap->iv_bss->ni_rsn;
1369 * int *i = (int *) extra;
1370 * int param = i[0]; // parameter id is 1st
1371 * int value = i[1]; // NB: most values are TYPE_INT
1374 * const struct ieee80211_authenticator *auth;
1375 * const struct ieee80211_aclator *acl;
1378 * case IEEE80211_PARAM_AUTHMODE:
1380 * case IEEE80211_AUTH_WPA: // WPA
1381 * case IEEE80211_AUTH_8021X: // 802.1x
1382 * case IEEE80211_AUTH_OPEN: // open
1383 * case IEEE80211_AUTH_SHARED: // shared-key
1384 * case IEEE80211_AUTH_AUTO: // auto
1385 * auth = ieee80211_authenticator_get(value);
1393 * case IEEE80211_AUTH_WPA: // WPA w/ 802.1x
1394 * vap->iv_flags |= IEEE80211_F_PRIVACY;
1395 * value = IEEE80211_AUTH_8021X;
1397 * case IEEE80211_AUTH_OPEN: // open
1398 * vap->iv_flags &= ~(IEEE80211_F_WPA | IEEE80211_F_PRIVACY);
1400 * case IEEE80211_AUTH_SHARED: // shared-key
1401 * case IEEE80211_AUTH_AUTO: // auto
1402 * case IEEE80211_AUTH_8021X: // 802.1x
1403 * vap->iv_flags &= ~IEEE80211_F_WPA;
1404 * // both require a key so mark the PRIVACY capability
1405 * vap->iv_flags |= IEEE80211_F_PRIVACY;
1408 * // NB: authenticator attach/detach happens on state change
1409 * vap->iv_bss->ni_authmode = value;
1410 * // XXX mixed/mode/usage?
1411 * vap->iv_auth = auth;
1414 * case IEEE80211_PARAM_PROTMODE:
1415 * if (value > IEEE80211_PROT_RTSCTS)
1417 * ic->ic_protmode = value;
1418 * // NB: if not operating in 11g this can wait
1419 * if (ic->ic_bsschan != IEEE80211_CHAN_ANYC &&
1420 * IEEE80211_IS_CHAN_ANYG(ic->ic_bsschan))
1423 * case IEEE80211_PARAM_MCASTCIPHER:
1424 * if ((vap->iv_caps & cipher2cap(value)) == 0 &&
1425 * !ieee80211_crypto_available(value))
1427 * rsn->rsn_mcastcipher = value;
1428 * if (vap->iv_flags & IEEE80211_F_WPA)
1431 * case IEEE80211_PARAM_MCASTKEYLEN:
1432 * if (!(0 < value && value < IEEE80211_KEYBUF_SIZE))
1434 * // XXX no way to verify driver capability
1435 * rsn->rsn_mcastkeylen = value;
1436 * if (vap->iv_flags & IEEE80211_F_WPA)
1439 * case IEEE80211_PARAM_UCASTCIPHERS:
1441 * // Convert cipher set to equivalent capabilities.
1442 * // NB: this logic intentionally ignores unknown and
1443 * // unsupported ciphers so folks can specify 0xff or
1444 * // similar and get all available ciphers.
1447 * for (j = 1; j < 32; j++) // NB: skip WEP
1448 * if ((value & (1<<j)) &&
1449 * ((vap->iv_caps & cipher2cap(j)) ||
1450 * ieee80211_crypto_available(j)))
1452 * if (caps == 0) // nothing available
1454 * // XXX verify ciphers ok for unicast use?
1455 * // XXX disallow if running as it'll have no effect
1456 * rsn->rsn_ucastcipherset = caps;
1457 * if (vap->iv_flags & IEEE80211_F_WPA)
1460 * case IEEE80211_PARAM_UCASTCIPHER:
1461 * if ((rsn->rsn_ucastcipherset & cipher2cap(value)) == 0)
1463 * rsn->rsn_ucastcipher = value;
1465 * case IEEE80211_PARAM_UCASTKEYLEN:
1466 * if (!(0 < value && value < IEEE80211_KEYBUF_SIZE))
1468 * // XXX no way to verify driver capability
1469 * rsn->rsn_ucastkeylen = value;
1471 * case IEEE80211_PARAM_KEYMGTALGS:
1473 * rsn->rsn_keymgmtset = value;
1474 * if (vap->iv_flags & IEEE80211_F_WPA)
1477 * case IEEE80211_PARAM_RSNCAPS:
1479 * rsn->rsn_caps = value;
1480 * if (vap->iv_flags & IEEE80211_F_WPA)
1483 * case IEEE80211_PARAM_WPA:
1486 * // XXX verify ciphers available
1487 * vap->iv_flags &= ~IEEE80211_F_WPA;
1490 * vap->iv_flags |= IEEE80211_F_WPA1;
1493 * vap->iv_flags |= IEEE80211_F_WPA2;
1496 * vap->iv_flags |= IEEE80211_F_WPA1 | IEEE80211_F_WPA2;
1499 * retv = ENETRESET; // XXX?
1501 * case IEEE80211_PARAM_ROAMING:
1502 * if (!(IEEE80211_ROAMING_DEVICE <= value &&
1503 * value <= IEEE80211_ROAMING_MANUAL))
1505 * ic->ic_roaming = value;
1507 * case IEEE80211_PARAM_PRIVACY:
1509 * // XXX check for key state?
1510 * vap->iv_flags |= IEEE80211_F_PRIVACY;
1512 * vap->iv_flags &= ~IEEE80211_F_PRIVACY;
1514 * case IEEE80211_PARAM_DROPUNENCRYPTED:
1516 * vap->iv_flags |= IEEE80211_F_DROPUNENC;
1518 * vap->iv_flags &= ~IEEE80211_F_DROPUNENC;
1520 * case IEEE80211_PARAM_COUNTERMEASURES:
1522 * if ((vap->iv_flags & IEEE80211_F_WPA) == 0)
1524 * vap->iv_flags |= IEEE80211_F_COUNTERM;
1526 * vap->iv_flags &= ~IEEE80211_F_COUNTERM;
1528 * case IEEE80211_PARAM_DRIVER_CAPS:
1529 * vap->iv_caps = value; // NB: for testing
1531 * case IEEE80211_PARAM_MACCMD:
1532 * acl = vap->iv_acl;
1534 * case IEEE80211_MACCMD_POLICY_OPEN:
1535 * case IEEE80211_MACCMD_POLICY_ALLOW:
1536 * case IEEE80211_MACCMD_POLICY_DENY:
1537 * if (acl == NULL) {
1538 * acl = ieee80211_aclator_get("mac");
1539 * if (acl == NULL || !acl->iac_attach(vap))
1541 * vap->iv_acl = acl;
1543 * acl->iac_setpolicy(vap, value);
1545 * case IEEE80211_MACCMD_FLUSH:
1547 * acl->iac_flush(vap);
1548 * // NB: silently ignore when not in use
1550 * case IEEE80211_MACCMD_DETACH:
1551 * if (acl != NULL) {
1552 * vap->iv_acl = NULL;
1553 * acl->iac_detach(vap);
1558 * case IEEE80211_PARAM_WMM:
1559 * if (ic->ic_caps & IEEE80211_C_WME){
1561 * vap->iv_flags |= IEEE80211_F_WME;
1562 * *//* XXX needed by ic_reset *//*
1563 * vap->iv_ic->ic_flags |= IEEE80211_F_WME;
1566 * *//* XXX needed by ic_reset *//*
1567 * vap->iv_flags &= ~IEEE80211_F_WME;
1568 * vap->iv_ic->ic_flags &= ~IEEE80211_F_WME;
1570 * retv = ENETRESET; // Renegotiate for capabilities
1573 * case IEEE80211_PARAM_HIDESSID:
1575 * vap->iv_flags |= IEEE80211_F_HIDESSID;
1577 * vap->iv_flags &= ~IEEE80211_F_HIDESSID;
1580 * case IEEE80211_PARAM_APBRIDGE:
1582 * vap->iv_flags |= IEEE80211_F_NOBRIDGE;
1584 * vap->iv_flags &= ~IEEE80211_F_NOBRIDGE;
1586 * case IEEE80211_PARAM_INACT:
1587 * vap->iv_inact_run = value / IEEE80211_INACT_WAIT;
1589 * case IEEE80211_PARAM_INACT_AUTH:
1590 * vap->iv_inact_auth = value / IEEE80211_INACT_WAIT;
1592 * case IEEE80211_PARAM_INACT_INIT:
1593 * vap->iv_inact_init = value / IEEE80211_INACT_WAIT;
1595 * case IEEE80211_PARAM_ABOLT:
1598 * // Map abolt settings to capability bits;
1599 * // this also strips unknown/unwanted bits.
1601 * if (value & IEEE80211_ABOLT_TURBO_PRIME)
1602 * caps |= IEEE80211_ATHC_TURBOP;
1603 * if (value & IEEE80211_ABOLT_COMPRESSION)
1604 * caps |= IEEE80211_ATHC_COMP;
1605 * if (value & IEEE80211_ABOLT_FAST_FRAME)
1606 * caps |= IEEE80211_ATHC_FF;
1607 * if (value & IEEE80211_ABOLT_XR)
1608 * caps |= IEEE80211_ATHC_XR;
1609 * if (value & IEEE80211_ABOLT_AR)
1610 * caps |= IEEE80211_ATHC_AR;
1611 * if (value & IEEE80211_ABOLT_BURST)
1612 * caps |= IEEE80211_ATHC_BURST;
1613 * if (value & IEEE80211_ABOLT_WME_ELE)
1614 * caps |= IEEE80211_ATHC_WME;
1615 * // verify requested capabilities are supported
1616 * if ((caps & ic->ic_ath_cap) != caps)
1618 * if (vap->iv_ath_cap != caps) {
1619 * if ((vap->iv_ath_cap ^ caps) & IEEE80211_ATHC_TURBOP) {
1620 * if (ieee80211_set_turbo(dev,
1621 * caps & IEEE80211_ATHC_TURBOP))
1623 * ieee80211_scan_flush(ic);
1625 * vap->iv_ath_cap = caps;
1626 * ic->ic_athcapsetup(vap->iv_ic, vap->iv_ath_cap);
1630 * case IEEE80211_PARAM_DTIM_PERIOD:
1631 * if (vap->iv_opmode != IEEE80211_M_HOSTAP &&
1632 * vap->iv_opmode != IEEE80211_M_IBSS)
1634 * if (IEEE80211_DTIM_MIN <= value &&
1635 * value <= IEEE80211_DTIM_MAX) {
1636 * vap->iv_dtim_period = value;
1637 * retv = ENETRESET; // requires restart
1641 * case IEEE80211_PARAM_BEACON_INTERVAL:
1642 * if (vap->iv_opmode != IEEE80211_M_HOSTAP &&
1643 * vap->iv_opmode != IEEE80211_M_IBSS)
1645 * if (IEEE80211_BINTVAL_MIN <= value &&
1646 * value <= IEEE80211_BINTVAL_MAX) {
1647 * ic->ic_lintval = value; // XXX multi-bss
1648 * retv = ENETRESET; // requires restart
1652 * case IEEE80211_PARAM_DOTH:
1654 * ic->ic_flags |= IEEE80211_F_DOTH;
1657 * ic->ic_flags &= ~IEEE80211_F_DOTH;
1658 * retv = ENETRESET; // XXX: need something this drastic?
1660 * case IEEE80211_PARAM_PWRTARGET:
1661 * ic->ic_curchanmaxpwr = value;
1663 * case IEEE80211_PARAM_GENREASSOC:
1664 * IEEE80211_SEND_MGMT(vap->iv_bss,
1665 * IEEE80211_FC0_SUBTYPE_REASSOC_REQ, 0);
1667 * case IEEE80211_PARAM_COMPRESSION:
1668 * retv = ieee80211_setathcap(vap, IEEE80211_ATHC_COMP, value);
1670 * case IEEE80211_PARAM_WMM_AGGRMODE:
1671 * retv = ieee80211_setathcap(vap, IEEE80211_ATHC_WME, value);
1673 * case IEEE80211_PARAM_FF:
1674 * retv = ieee80211_setathcap(vap, IEEE80211_ATHC_FF, value);
1676 * case IEEE80211_PARAM_TURBO:
1677 * retv = ieee80211_setathcap(vap, IEEE80211_ATHC_TURBOP, value);
1678 * if (retv == ENETRESET) {
1679 * if(ieee80211_set_turbo(dev,value))
1681 * ieee80211_scan_flush(ic);
1684 * case IEEE80211_PARAM_XR:
1685 * retv = ieee80211_setathcap(vap, IEEE80211_ATHC_XR, value);
1687 * case IEEE80211_PARAM_BURST:
1688 * retv = ieee80211_setathcap(vap, IEEE80211_ATHC_BURST, value);
1690 * case IEEE80211_PARAM_AR:
1691 * retv = ieee80211_setathcap(vap, IEEE80211_ATHC_AR, value);
1693 * case IEEE80211_PARAM_PUREG:
1695 * vap->iv_flags |= IEEE80211_F_PUREG;
1697 * vap->iv_flags &= ~IEEE80211_F_PUREG;
1698 * // NB: reset only if we're operating on an 11g channel
1699 * if (ic->ic_bsschan != IEEE80211_CHAN_ANYC &&
1700 * IEEE80211_IS_CHAN_ANYG(ic->ic_bsschan))
1703 * case IEEE80211_PARAM_WDS:
1705 * vap->iv_flags_ext |= IEEE80211_FEXT_WDS;
1707 * vap->iv_flags_ext &= ~IEEE80211_FEXT_WDS;
1709 * case IEEE80211_PARAM_BGSCAN:
1711 * if ((vap->iv_caps & IEEE80211_C_BGSCAN) == 0)
1713 * vap->iv_flags |= IEEE80211_F_BGSCAN;
1716 * vap->iv_flags &= ~IEEE80211_F_BGSCAN;
1717 * ieee80211_cancel_scan(vap); // anything current
1720 * case IEEE80211_PARAM_BGSCAN_IDLE:
1721 * if (value >= IEEE80211_BGSCAN_IDLE_MIN)
1722 * vap->iv_bgscanidle = value*HZ/1000;
1726 * case IEEE80211_PARAM_BGSCAN_INTERVAL:
1727 * if (value >= IEEE80211_BGSCAN_INTVAL_MIN)
1728 * vap->iv_bgscanintvl = value*HZ;
1732 * case IEEE80211_PARAM_MCAST_RATE:
1733 * // units are in KILObits per second
1734 * if (value >= 256 && value <= 54000)
1735 * vap->iv_mcast_rate = value;
1739 * case IEEE80211_PARAM_COVERAGE_CLASS:
1740 * if (value >= 0 && value <= IEEE80211_COVERAGE_CLASS_MAX) {
1741 * ic->ic_coverageclass = value;
1742 * if (IS_UP_AUTO(vap))
1743 * ieee80211_new_state(vap, IEEE80211_S_SCAN, 0);
1749 * case IEEE80211_PARAM_COUNTRY_IE:
1751 * ic->ic_flags_ext |= IEEE80211_FEXT_COUNTRYIE;
1753 * ic->ic_flags_ext &= ~IEEE80211_FEXT_COUNTRYIE;
1756 * case IEEE80211_PARAM_REGCLASS:
1758 * ic->ic_flags_ext |= IEEE80211_FEXT_REGCLASS;
1760 * ic->ic_flags_ext &= ~IEEE80211_FEXT_REGCLASS;
1763 * case IEEE80211_PARAM_SCANVALID:
1764 * vap->iv_scanvalid = value*HZ;
1766 * case IEEE80211_PARAM_ROAM_RSSI_11A:
1767 * vap->iv_roam.rssi11a = value;
1769 * case IEEE80211_PARAM_ROAM_RSSI_11B:
1770 * vap->iv_roam.rssi11bOnly = value;
1772 * case IEEE80211_PARAM_ROAM_RSSI_11G:
1773 * vap->iv_roam.rssi11b = value;
1775 * case IEEE80211_PARAM_ROAM_RATE_11A:
1776 * vap->iv_roam.rate11a = value;
1778 * case IEEE80211_PARAM_ROAM_RATE_11B:
1779 * vap->iv_roam.rate11bOnly = value;
1781 * case IEEE80211_PARAM_ROAM_RATE_11G:
1782 * vap->iv_roam.rate11b = value;
1784 * case IEEE80211_PARAM_UAPSDINFO:
1785 * if (vap->iv_opmode == IEEE80211_M_HOSTAP) {
1786 * if (ic->ic_caps & IEEE80211_C_UAPSD) {
1788 * IEEE80211_VAP_UAPSD_ENABLE(vap);
1790 * IEEE80211_VAP_UAPSD_DISABLE(vap);
1794 * else if (vap->iv_opmode == IEEE80211_M_STA) {
1795 * vap->iv_uapsdinfo = value;
1796 * IEEE80211_VAP_UAPSD_ENABLE(vap);
1800 * case IEEE80211_PARAM_SLEEP:
1801 * // XXX: Forced sleep for testing. Does not actually place the
1802 * // HW in sleep mode yet. this only makes sense for STAs.
1806 * IEEE80211_VAP_GOTOSLEEP(vap);
1810 * IEEE80211_VAP_WAKEUP(vap);
1812 * ieee80211_send_nulldata(ieee80211_ref_node(vap->iv_bss));
1814 * case IEEE80211_PARAM_QOSNULL:
1815 * // Force a QoS Null for testing.
1816 * ieee80211_send_qosnulldata(vap->iv_bss, value);
1818 * case IEEE80211_PARAM_PSPOLL:
1819 * // Force a PS-POLL for testing.
1820 * ieee80211_send_pspoll(vap->iv_bss);
1822 * case IEEE80211_PARAM_EOSPDROP:
1823 * if (vap->iv_opmode == IEEE80211_M_HOSTAP) {
1824 * if (value) IEEE80211_VAP_EOSPDROP_ENABLE(vap);
1825 * else IEEE80211_VAP_EOSPDROP_DISABLE(vap);
1828 * case IEEE80211_PARAM_MARKDFS:
1830 * ic->ic_flags_ext |= IEEE80211_FEXT_MARKDFS;
1832 * ic->ic_flags_ext &= ~IEEE80211_FEXT_MARKDFS;
1834 * case IEEE80211_PARAM_CHANBW:
1837 * ic->ic_chanbwflag = 0;
1840 * ic->ic_chanbwflag = IEEE80211_CHAN_HALF;
1843 * ic->ic_chanbwflag = IEEE80211_CHAN_QUARTER;
1850 * case IEEE80211_PARAM_SHORTPREAMBLE:
1852 * ic->ic_caps |= IEEE80211_C_SHPREAMBLE;
1854 * ic->ic_caps &= ~IEEE80211_C_SHPREAMBLE;
1859 * retv = EOPNOTSUPP;
1862 * // XXX should any of these cause a rescan?
1863 * if (retv == ENETRESET)
1864 * retv = IS_UP_AUTO(vap) ? ieee80211_open(vap->iv_dev) : 0;
1869 int usbdrvwext_setmode(struct net_device
*dev
, struct iw_request_info
*info
,
1870 void *w
, char *extra
)
1875 int usbdrvwext_getmode(struct net_device
*dev
, struct iw_request_info
*info
,
1876 void *w
, char *extra
)
1878 /* struct usbdrv_private *macp = dev->ml_priv; */
1879 struct iw_point
*wri
= (struct iw_point
*)extra
;
1882 strcpy(mode
, "11g");
1883 return copy_to_user(wri
->pointer
, mode
, 6) ? -EFAULT
: 0;
1886 int zfLnxPrivateIoctl(struct net_device
*dev
, struct zdap_ioctl
* zdreq
)
1888 /* void* regp = macp->regp; */
1896 case ZM_IOCTL_REG_READ
:
1897 zfiDbgReadReg(dev
, zdreq
->addr
);
1899 case ZM_IOCTL_REG_WRITE
:
1900 zfiDbgWriteReg(dev
, zdreq
->addr
, zdreq
->value
);
1902 case ZM_IOCTL_MEM_READ
:
1903 p
= (u32_t
*) bus_to_virt(zdreq
->addr
);
1905 "usbdrv: read memory addr: 0x%08x value:"
1906 " 0x%08x\n", zdreq
->addr
, *p
);
1908 case ZM_IOCTL_MEM_WRITE
:
1909 p
= (u32_t
*) bus_to_virt(zdreq
->addr
);
1912 "usbdrv : write value : 0x%08x to memory addr :"
1913 " 0x%08x\n", zdreq
->value
, zdreq
->addr
);
1915 case ZM_IOCTL_TALLY
:
1916 zfiWlanShowTally(dev
);
1918 zfiWlanResetTally(dev
);
1922 "ZM_IOCTL_TEST:len=%d\n", zdreq
->addr
);
1923 /* zfiWlanReadReg(dev, 0x10f400); */
1924 /* zfiWlanReadReg(dev, 0x10f404); */
1925 printk(KERN_WARNING
"IOCTL TEST\n");
1928 for (i
= 0; i
< zdreq
->addr
; i
++) {
1930 printk(KERN_WARNING
"\n");
1931 printk(KERN_WARNING
"%02X ",
1932 (unsigned char)zdreq
->data
[i
]);
1934 printk(KERN_WARNING
"\n");
1937 /* For Test?? 1 to 0 by CWYang(-) */
1941 /* Allocate a skb */
1942 s
= alloc_skb(2000, GFP_ATOMIC
);
1944 /* Copy data to skb */
1945 for (i
= 0; i
< zdreq
->addr
; i
++)
1946 s
->data
[i
] = zdreq
->data
[i
];
1947 s
->len
= zdreq
->addr
;
1949 /* Call zfIdlRecv() */
1950 zfiRecv80211(dev
, s
, NULL
);
1953 /************************* ZDCONFIG ***************************/
1955 zfiWlanSetFragThreshold(dev
, zdreq
->addr
);
1958 zfiWlanSetRtsThreshold(dev
, zdreq
->addr
);
1963 case ZM_IOCTL_KEY
: {
1965 struct zsKeyInfo keyInfo
;
1968 for (i
= 0; i
< 29; i
++)
1971 for (i
= 0; i
< zdreq
->addr
; i
++)
1972 key
[i
] = zdreq
->data
[i
];
1975 "key len=%d, key=%02x%02x%02x%02x%02x...\n",
1976 zdreq
->addr
, key
[0], key
[1], key
[2], key
[3], key
[4]);
1978 keyInfo
.keyLength
= zdreq
->addr
;
1979 keyInfo
.keyIndex
= 0;
1982 zfiWlanSetKey(dev
, keyInfo
);
1986 zfiWlanSetTxRate(dev
, zdreq
->addr
);
1988 case ZM_IOCTL_ENCRYPTION_MODE
:
1989 zfiWlanSetEncryMode(dev
, zdreq
->addr
);
1991 zfiWlanDisable(dev
, 0);
1995 case ZM_IOCTL_SIGNAL_STRENGTH
: {
1997 zfiWlanQuerySignalInfo(dev
, &buffer
[0]);
1999 "Current Signal Strength : %02d\n", buffer
[0]);
2003 case ZM_IOCTL_SIGNAL_QUALITY
: {
2005 zfiWlanQuerySignalInfo(dev
, &buffer
[0]);
2007 "Current Signal Quality : %02d\n", buffer
[1]);
2010 case ZM_IOCTL_SET_PIBSS_MODE
:
2011 if (zdreq
->addr
== 1)
2012 zfiWlanSetWlanMode(dev
, ZM_MODE_PSEUDO
);
2014 zfiWlanSetWlanMode(dev
, ZM_MODE_INFRASTRUCTURE
);
2016 zfiWlanDisable(dev
, 0);
2019 /********************* ZDCONFIG ***********************/
2021 printk(KERN_ERR
"usbdrv: error command = %x\n", cmd
);
2028 int usbdrv_wpa_ioctl(struct net_device
*dev
, struct athr_wlan_param
*zdparm
)
2031 u8_t bc_addr
[6] = { 0xff, 0xff, 0xff, 0xff, 0xff, 0xff };
2033 struct zsKeyInfo keyInfo
;
2034 struct usbdrv_private
*macp
= dev
->ml_priv
;
2038 /* zmw_get_wlan_dev(dev); */
2040 switch (zdparm
->cmd
) {
2041 case ZD_CMD_SET_ENCRYPT_KEY
:
2042 /* Set up key information */
2043 keyInfo
.keyLength
= zdparm
->u
.crypt
.key_len
;
2044 keyInfo
.keyIndex
= zdparm
->u
.crypt
.idx
;
2045 if (zfiWlanQueryWlanMode(dev
) == ZM_MODE_AP
) {
2047 keyInfo
.flag
= ZM_KEY_FLAG_AUTHENTICATOR
;
2050 keyInfo
.key
= zdparm
->u
.crypt
.key
;
2051 keyInfo
.initIv
= zdparm
->u
.crypt
.seq
;
2052 keyInfo
.macAddr
= (u16_t
*)zdparm
->sta_addr
;
2054 /* Identify the MAC address information */
2055 if (memcmp(zdparm
->sta_addr
, bc_addr
, sizeof(bc_addr
)) == 0)
2056 keyInfo
.flag
|= ZM_KEY_FLAG_GK
;
2058 keyInfo
.flag
|= ZM_KEY_FLAG_PK
;
2060 if (!strcmp(zdparm
->u
.crypt
.alg
, "NONE")) {
2061 /* u8_t zero_mac[]={0,0,0,0,0,0}; */
2063 /* Set key length to zero */
2064 keyInfo
.keyLength
= 0;
2067 if (zdparm
->sta_addr
[0] & 1) {
2068 /* if (macp->cardSetting.WPAIeLen==0)
2069 * { 802.1x dynamic WEP
2071 * mKeyFormat[0] = 0;
2072 * mPrivacyInvoked[0]=FALSE;
2073 * mCap[0] &= ~CAP_PRIVACY;
2074 * macp->cardSetting.EncryOnOff[0]=0;
2076 * mWpaBcKeyLen = mGkInstalled = 0;
2079 /* if (memcmp(zero_mac,zdparm->sta_addr, 6)==0)
2083 * pSetting->DynKeyMode=0;
2084 * pSetting->EncryMode[0]=0;
2090 printk(KERN_ERR
"Set Encryption Type NONE\n");
2092 } else if (!strcmp(zdparm
->u
.crypt
.alg
, "TKIP")) {
2093 zfiWlanSetEncryMode(dev
, ZM_TKIP
);
2094 /* //Linux Supplicant will inverse Tx/Rx key
2095 * //So we inverse it back, CWYang(+)
2096 * zfMemoryCopy(&temp[0], &keyInfo.key[16], 8);
2097 * zfMemoryCopy(&keyInfo.key[16], keyInfo.key[24], 8);
2098 * zfMemoryCopy(&keyInfo.key[24], &temp[0], 8);
2101 * for (k = 0; k < 8; k++)
2103 * temp = keyInfo.key[16 + k];
2104 * keyInfo.key[16 + k] = keyInfo.key[24 + k];
2105 * keyInfo.key[24 + k] = temp;
2107 * CamEncryType = ZM_TKIP;
2110 * mKeyFormat[0] = CamEncryType;
2111 * mDynKeyMode = pSetting->DynKeyMode = DYN_KEY_TKIP;
2114 } else if (!strcmp(zdparm
->u
.crypt
.alg
, "CCMP")) {
2115 zfiWlanSetEncryMode(dev
, ZM_AES
);
2116 /* CamEncryType = ZM_AES;
2119 * mKeyFormat[0] = CamEncryType;
2120 * mDynKeyMode = pSetting->DynKeyMode = DYN_KEY_AES;
2123 } else if (!strcmp(zdparm
->u
.crypt
.alg
, "WEP")) {
2124 if (keyInfo
.keyLength
== 5) {
2126 zfiWlanSetEncryMode(dev
, ZM_WEP64
);
2127 /* CamEncryType = ZM_WEP64; */
2128 /* tmpDynKeyMode=DYN_KEY_WEP64; */
2129 } else if (keyInfo
.keyLength
== 13) {
2130 /* keylen=13, WEP 128 */
2131 zfiWlanSetEncryMode(dev
, ZM_WEP128
);
2132 /* CamEncryType = ZM_WEP128; */
2133 /* tmpDynKeyMode=DYN_KEY_WEP128; */
2135 zfiWlanSetEncryMode(dev
, ZM_WEP256
);
2138 /* For Dynamic WEP key (Non-WPA Radius), the key ID range: 0-3
2139 * In WPA/RSN mode, the key ID range: 1-3, usually, a broadcast key.
2140 * For WEP key setting: we set mDynKeyMode and mKeyFormat in following
2142 * 1. For 802.1x dynamically generated WEP key method.
2143 * 2. For WPA/RSN mode, but key id == 0.
2144 * (But this is an impossible case)
2145 * So, only check case 1.
2146 * if (macp->cardSetting.WPAIeLen==0)
2148 * mKeyFormat[0] = CamEncryType;
2149 * mDynKeyMode = pSetting->DynKeyMode = tmpDynKeyMode;
2150 * mPrivacyInvoked[0]=TRUE;
2151 * mCap[0] |= CAP_PRIVACY;
2152 * macp->cardSetting.EncryOnOff[0]=1;
2157 /* DUMP key context */
2158 /* #ifdef WPA_DEBUG */
2159 if (keyInfo
.keyLength
> 0) {
2161 "Otus: Key Context:\n");
2162 for (ii
= 0; ii
< keyInfo
.keyLength
; ) {
2164 "0x%02x ", keyInfo
.key
[ii
]);
2165 if ((++ii
% 16) == 0)
2166 printk(KERN_WARNING
"\n");
2168 printk(KERN_WARNING
"\n");
2172 /* Set encrypt mode */
2173 /* zfiWlanSetEncryMode(dev, CamEncryType); */
2174 vapId
= zfLnxGetVapId(dev
);
2175 if (vapId
== 0xffff)
2178 keyInfo
.vapId
= vapId
+ 1;
2179 keyInfo
.vapAddr
[0] = keyInfo
.macAddr
[0];
2180 keyInfo
.vapAddr
[1] = keyInfo
.macAddr
[1];
2181 keyInfo
.vapAddr
[2] = keyInfo
.macAddr
[2];
2183 zfiWlanSetKey(dev
, keyInfo
);
2185 /* zfiWlanDisable(dev); */
2186 /* zfiWlanEnable(dev); */
2188 case ZD_CMD_SET_MLME
:
2189 printk(KERN_ERR
"usbdrv_wpa_ioctl: ZD_CMD_SET_MLME\n");
2191 /* Translate STA's address */
2192 sprintf(mac_addr
, "%02x:%02x:%02x:%02x:%02x:%02x",
2193 zdparm
->sta_addr
[0], zdparm
->sta_addr
[1],
2194 zdparm
->sta_addr
[2], zdparm
->sta_addr
[3],
2195 zdparm
->sta_addr
[4], zdparm
->sta_addr
[5]);
2197 switch (zdparm
->u
.mlme
.cmd
) {
2198 case MLME_STA_DEAUTH
:
2200 " -------Call zfiWlanDeauth, reason:%d\n",
2201 zdparm
->u
.mlme
.reason_code
);
2202 if (zfiWlanDeauth(dev
, (u16_t
*) zdparm
->sta_addr
,
2203 zdparm
->u
.mlme
.reason_code
) != 0)
2204 printk(KERN_ERR
"Can't deauthencate STA: %s\n",
2207 printk(KERN_ERR
"Deauthenticate STA: %s"
2208 "with reason code: %d\n",
2209 mac_addr
, zdparm
->u
.mlme
.reason_code
);
2211 case MLME_STA_DISASSOC
:
2213 " -------Call zfiWlanDeauth, reason:%d\n",
2214 zdparm
->u
.mlme
.reason_code
);
2215 if (zfiWlanDeauth(dev
, (u16_t
*) zdparm
->sta_addr
,
2216 zdparm
->u
.mlme
.reason_code
) != 0)
2217 printk(KERN_ERR
"Can't disassociate STA: %s\n",
2220 printk(KERN_ERR
"Disassociate STA: %s"
2221 "with reason code: %d\n",
2222 mac_addr
, zdparm
->u
.mlme
.reason_code
);
2225 printk(KERN_ERR
"MLME command: 0x%04x not support\n",
2226 zdparm
->u
.mlme
.cmd
);
2231 case ZD_CMD_SCAN_REQ
:
2232 printk(KERN_ERR
"usbdrv_wpa_ioctl: ZD_CMD_SCAN_REQ\n");
2234 case ZD_CMD_SET_GENERIC_ELEMENT
: {
2236 printk(KERN_ERR
"usbdrv_wpa_ioctl:"
2237 " ZD_CMD_SET_GENERIC_ELEMENT\n");
2240 * zm_msg1_mm(ZM_LV_0, "CWY - wpaie Length : ",
2241 * zdparm->u.generic_elem.len);
2243 printk(KERN_ERR
"wpaie Length : % d\n",
2244 zdparm
->u
.generic_elem
.len
);
2245 if (zfiWlanQueryWlanMode(dev
) == ZM_MODE_AP
) {
2247 zfiWlanSetWpaIe(dev
, zdparm
->u
.generic_elem
.data
,
2248 zdparm
->u
.generic_elem
.len
);
2250 macp
->supLen
= zdparm
->u
.generic_elem
.len
;
2251 memcpy(macp
->supIe
, zdparm
->u
.generic_elem
.data
,
2252 zdparm
->u
.generic_elem
.len
);
2254 zfiWlanSetWpaSupport(dev
, 1);
2255 /* zfiWlanSetWpaIe(dev, zdparm->u.generic_elem.data,
2256 * zdparm->u.generic_elem.len);
2258 len
= zdparm
->u
.generic_elem
.len
;
2259 wpaie
= zdparm
->u
.generic_elem
.data
;
2261 printk(KERN_ERR
"wd->ap.wpaLen : % d\n", len
);
2264 for(ii
= 0; ii
< len
;) {
2265 printk(KERN_ERR
"0x%02x ", wpaie
[ii
]);
2267 if((++ii
% 16) == 0)
2268 printk(KERN_ERR
"\n");
2270 printk(KERN_ERR
"\n");
2272 /* #ifdef ZM_HOSTAPD_SUPPORT
2273 * if (wd->wlanMode == ZM_MODE_AP)
2274 * {// Update Beacon FIFO in the next TBTT.
2275 * memcpy(&mWPAIe, pSetting->WPAIe, pSetting->WPAIeLen);
2276 * printk(KERN_ERR "Copy WPA IE into mWPAIe\n");
2283 /* #ifdef ZM_HOSTAPD_SUPPORT */
2284 case ZD_CMD_GET_TSC
:
2285 printk(KERN_ERR
"usbdrv_wpa_ioctl : ZD_CMD_GET_TSC\n");
2290 printk(KERN_ERR
"usbdrv_wpa_ioctl default : 0x%04x\n",
2299 #ifdef ZM_ENABLE_CENC
2300 int usbdrv_cenc_ioctl(struct net_device
*dev
, struct zydas_cenc_param
*zdparm
)
2302 /* struct usbdrv_private *macp = dev->ml_priv; */
2303 struct zsKeyInfo keyInfo
;
2305 u8_t bc_addr
[6] = { 0xff, 0xff, 0xff, 0xff, 0xff, 0xff };
2310 apId
= zfLnxGetVapId(dev
);
2312 if (apId
== 0xffff) {
2318 switch (zdparm
->cmd
) {
2319 case ZM_CMD_CENC_SETCENC
:
2320 printk(KERN_ERR
"ZM_CMD_CENC_SETCENC\n");
2321 printk(KERN_ERR
"length : % d\n", zdparm
->len
);
2322 printk(KERN_ERR
"policy : % d\n", zdparm
->u
.info
.cenc_policy
);
2324 case ZM_CMD_CENC_SETKEY
:
2325 /* ret = wai_ioctl_setkey(vap, ioctl_msg); */
2326 printk(KERN_ERR
"ZM_CMD_CENC_SETKEY\n");
2328 printk(KERN_ERR
"MAC address = ");
2329 for (ii
= 0; ii
< 6; ii
++) {
2330 printk(KERN_ERR
"0x%02x ",
2331 zdparm
->u
.crypt
.sta_addr
[ii
]);
2333 printk(KERN_ERR
"\n");
2335 printk(KERN_ERR
"Key Index : % d\n", zdparm
->u
.crypt
.keyid
);
2336 printk(KERN_ERR
"Encryption key = ");
2337 for (ii
= 0; ii
< 16; ii
++) {
2338 printk(KERN_ERR
"0x%02x ", zdparm
->u
.crypt
.key
[ii
]);
2340 printk(KERN_ERR
"\n");
2342 printk(KERN_ERR
"MIC key = ");
2343 for(ii
= 16; ii
< ZM_CENC_KEY_SIZE
; ii
++) {
2344 printk(KERN_ERR
"0x%02x ", zdparm
->u
.crypt
.key
[ii
]);
2346 printk(KERN_ERR
"\n");
2348 /* Set up key information */
2349 keyInfo
.keyLength
= ZM_CENC_KEY_SIZE
;
2350 keyInfo
.keyIndex
= zdparm
->u
.crypt
.keyid
;
2351 keyInfo
.flag
= ZM_KEY_FLAG_AUTHENTICATOR
| ZM_KEY_FLAG_CENC
;
2352 keyInfo
.key
= zdparm
->u
.crypt
.key
;
2353 keyInfo
.macAddr
= (u16_t
*)zdparm
->u
.crypt
.sta_addr
;
2355 /* Identify the MAC address information */
2356 if (memcmp(zdparm
->u
.crypt
.sta_addr
, bc_addr
,
2357 sizeof(bc_addr
)) == 0) {
2358 keyInfo
.flag
|= ZM_KEY_FLAG_GK
;
2359 keyInfo
.vapId
= apId
;
2360 memcpy(keyInfo
.vapAddr
, dev
->dev_addr
, ETH_ALEN
);
2362 keyInfo
.flag
|= ZM_KEY_FLAG_PK
;
2365 zfiWlanSetKey(dev
, keyInfo
);
2368 case ZM_CMD_CENC_REKEY
:
2369 /* ret = wai_ioctl_rekey(vap, ioctl_msg); */
2370 printk(KERN_ERR
"ZM_CMD_CENC_REKEY\n");
2377 /* if (retv == ENETRESET) */
2378 /* retv = IS_UP_AUTO(vap) ? ieee80211_open(vap->iv_dev) : 0; */
2382 #endif /* ZM_ENABLE_CENC */
2384 int usbdrv_ioctl(struct net_device
*dev
, struct ifreq
*ifr
, int cmd
)
2386 /* struct usbdrv_private *macp; */
2388 struct zdap_ioctl zdreq
;
2389 struct iwreq
*wrq
= (struct iwreq
*)ifr
;
2390 struct athr_wlan_param zdparm
;
2391 struct usbdrv_private
*macp
= dev
->ml_priv
;
2393 int err
= 0, val
= 0;
2396 /* regp = macp->regp; */
2398 if (!netif_running(dev
))
2403 strcpy(wrq
->u
.name
, "IEEE 802.11-DS");
2406 err
= usbdrvwext_giwap(dev
, NULL
, &wrq
->u
.ap_addr
, NULL
);
2409 err
= usbdrvwext_siwap(dev
, NULL
, &wrq
->u
.ap_addr
, NULL
);
2412 err
= usbdrvwext_giwmode(dev
, NULL
, &wrq
->u
.mode
, NULL
);
2415 printk(KERN_ERR
"CWY - usbdrvwext_siwessid\n");
2416 /* err = usbdrv_ioctl_setessid(dev, &wrq->u.essid); */
2417 err
= usbdrvwext_siwessid(dev
, NULL
, &wrq
->u
.essid
, NULL
);
2423 err
= usbdrvwext_giwessid(dev
, NULL
, &wrq
->u
.essid
, NULL
);
2426 err
= usbdrv_ioctl_setrts(dev
, &wrq
->u
.rts
);
2431 case SIOCIWFIRSTPRIV
+ 0x2: {
2432 /* printk("CWY - SIOCIWFIRSTPRIV + 0x2(set_auth)\n"); */
2433 if (!capable(CAP_NET_ADMIN
)) {
2437 val
= *((int *) wrq
->u
.name
);
2438 if ((val
< 0) || (val
> 2)) {
2442 zfiWlanSetAuthenticationMode(dev
, val
);
2444 if (macp
->DeviceOpened
== 1) {
2445 zfiWlanDisable(dev
, 0);
2455 case SIOCIWFIRSTPRIV
+ 0x3: {
2456 int AuthMode
= ZM_AUTH_MODE_OPEN
;
2458 /* printk("CWY - SIOCIWFIRSTPRIV + 0x3(get_auth)\n"); */
2460 if (wrq
->u
.data
.pointer
) {
2461 wrq
->u
.data
.flags
= 1;
2463 AuthMode
= zfiWlanQueryAuthenticationMode(dev
, 0);
2464 if (AuthMode
== ZM_AUTH_MODE_OPEN
) {
2465 wrq
->u
.data
.length
= 12;
2467 if (copy_to_user(wrq
->u
.data
.pointer
,
2468 "open system", 12)) {
2471 } else if (AuthMode
== ZM_AUTH_MODE_SHARED_KEY
) {
2472 wrq
->u
.data
.length
= 11;
2474 if (copy_to_user(wrq
->u
.data
.pointer
,
2475 "shared key", 11)) {
2478 } else if (AuthMode
== ZM_AUTH_MODE_AUTO
) {
2479 wrq
->u
.data
.length
= 10;
2481 if (copy_to_user(wrq
->u
.data
.pointer
,
2493 if (copy_from_user(&zdreq
, ifr
->ifr_data
, sizeof(zdreq
))) {
2494 printk(KERN_ERR
"usbdrv : copy_from_user error\n");
2498 /* printk(KERN_WARNING
2499 * "usbdrv : cmd = % 2x, reg = 0x%04lx,
2500 *value = 0x%08lx\n",
2501 * zdreq.cmd, zdreq.addr, zdreq.value);
2503 zfLnxPrivateIoctl(dev
, &zdreq
);
2508 if (copy_from_user(&zdparm
, ifr
->ifr_data
,
2509 sizeof(struct athr_wlan_param
))) {
2510 printk(KERN_ERR
"usbdrv : copy_from_user error\n");
2514 usbdrv_wpa_ioctl(dev
, &zdparm
);
2517 case ZD_IOCTL_PARAM
: {
2522 /* Point to the name field and retrieve the
2523 * op and arg elements.
2525 p
= (int *)wrq
->u
.name
;
2529 if (op
== ZD_PARAM_ROAMING
) {
2531 "*************ZD_PARAM_ROAMING : % d\n", arg
);
2532 /* macp->cardSetting.ap_scan=(U8)arg; */
2534 if (op
== ZD_PARAM_PRIVACY
) {
2535 printk(KERN_ERR
"ZD_IOCTL_PRIVACY : ");
2537 /* Turn on the privacy invoke flag */
2539 /* mCap[0] |= CAP_PRIVACY; */
2540 /* macp->cardSetting.EncryOnOff[0] = 1; */
2541 printk(KERN_ERR
"enable\n");
2544 /* mCap[0] &= ~CAP_PRIVACY; */
2545 /* macp->cardSetting.EncryOnOff[0] = 0; */
2546 printk(KERN_ERR
"disable\n");
2550 if (op
== ZD_PARAM_WPA
) {
2552 printk(KERN_ERR
"ZD_PARAM_WPA : ");
2555 printk(KERN_ERR
"enable\n");
2557 if (zfiWlanQueryWlanMode(dev
) != ZM_MODE_AP
) {
2558 printk(KERN_ERR
"Station Mode\n");
2559 /* zfiWlanQueryWpaIe(dev, (u8_t *)
2560 &wpaIe, &wpalen); */
2561 /* printk("wpaIe : % 2x, % 2x, % 2x\n",
2562 wpaIe[21], wpaIe[22], wpaIe[23]); */
2563 /* printk("rsnIe : % 2x, % 2x, % 2x\n",
2564 wpaIe[17], wpaIe[18], wpaIe[19]); */
2565 if ((macp
->supIe
[21] == 0x50) &&
2566 (macp
->supIe
[22] == 0xf2) &&
2567 (macp
->supIe
[23] == 0x2)) {
2569 "wd->sta.authMode = ZM_AUTH_MODE_WPAPSK\n");
2570 /* wd->sta.authMode = ZM_AUTH_MODE_WPAPSK; */
2571 /* wd->ws.authMode = ZM_AUTH_MODE_WPAPSK; */
2572 zfiWlanSetAuthenticationMode(dev
,
2573 ZM_AUTH_MODE_WPAPSK
);
2574 } else if ((macp
->supIe
[21] == 0x50) &&
2575 (macp
->supIe
[22] == 0xf2) &&
2576 (macp
->supIe
[23] == 0x1)) {
2578 "wd->sta.authMode = ZM_AUTH_MODE_WPA\n");
2579 /* wd->sta.authMode = ZM_AUTH_MODE_WPA; */
2580 /* wd->ws.authMode = ZM_AUTH_MODE_WPA; */
2581 zfiWlanSetAuthenticationMode(dev
,
2583 } else if ((macp
->supIe
[17] == 0xf) &&
2584 (macp
->supIe
[18] == 0xac) &&
2585 (macp
->supIe
[19] == 0x2))
2588 "wd->sta.authMode = ZM_AUTH_MODE_WPA2PSK\n");
2589 /* wd->sta.authMode = ZM_AUTH_MODE_WPA2PSK; */
2590 /* wd->ws.authMode = ZM_AUTH_MODE_WPA2PSK; */
2591 zfiWlanSetAuthenticationMode(dev
,
2592 ZM_AUTH_MODE_WPA2PSK
);
2593 } else if ((macp
->supIe
[17] == 0xf) &&
2594 (macp
->supIe
[18] == 0xac) &&
2595 (macp
->supIe
[19] == 0x1))
2598 "wd->sta.authMode = ZM_AUTH_MODE_WPA2\n");
2599 /* wd->sta.authMode = ZM_AUTH_MODE_WPA2; */
2600 /* wd->ws.authMode = ZM_AUTH_MODE_WPA2; */
2601 zfiWlanSetAuthenticationMode(dev
,
2605 if ((macp
->supIe
[21] == 0x50) ||
2606 (macp
->supIe
[22] == 0xf2)) {
2607 if (macp
->supIe
[11] == 0x2) {
2609 "wd->sta.wepStatus = ZM_ENCRYPTION_TKIP\n");
2610 /* wd->sta.wepStatus = ZM_ENCRYPTION_TKIP; */
2611 /* wd->ws.wepStatus = ZM_ENCRYPTION_TKIP; */
2612 zfiWlanSetWepStatus(dev
, ZM_ENCRYPTION_TKIP
);
2615 "wd->sta.wepStatus = ZM_ENCRYPTION_AES\n");
2616 /* wd->sta.wepStatus = ZM_ENCRYPTION_AES; */
2617 /* wd->ws.wepStatus = ZM_ENCRYPTION_AES; */
2618 zfiWlanSetWepStatus(dev
, ZM_ENCRYPTION_AES
);
2622 if ((macp
->supIe
[17] == 0xf) ||
2623 (macp
->supIe
[18] == 0xac)) {
2624 if (macp
->supIe
[13] == 0x2) {
2626 "wd->sta.wepStatus = ZM_ENCRYPTION_TKIP\n");
2627 /* wd->sta.wepStatus = ZM_ENCRYPTION_TKIP; */
2628 /* wd->ws.wepStatus = ZM_ENCRYPTION_TKIP; */
2629 zfiWlanSetWepStatus(dev
, ZM_ENCRYPTION_TKIP
);
2632 "wd->sta.wepStatus = ZM_ENCRYPTION_AES\n");
2633 /* wd->sta.wepStatus = ZM_ENCRYPTION_AES; */
2634 /* wd->ws.wepStatus = ZM_ENCRYPTION_AES; */
2635 zfiWlanSetWepStatus(dev
, ZM_ENCRYPTION_AES
);
2639 zfiWlanSetWpaSupport(dev
, 1);
2641 /* Reset the WPA related variables */
2642 printk(KERN_ERR
"disable\n");
2644 zfiWlanSetWpaSupport(dev
, 0);
2645 zfiWlanSetAuthenticationMode(dev
, ZM_AUTH_MODE_OPEN
);
2646 zfiWlanSetWepStatus(dev
, ZM_ENCRYPTION_WEP_DISABLED
);
2648 /* Now we only set the length in the WPA IE
2650 *macp->cardSetting.WPAIe[1] = 0;
2655 if (op
== ZD_PARAM_COUNTERMEASURES
) {
2657 "****************ZD_PARAM_COUNTERMEASURES : ");
2660 /* mCounterMeasureState=1; */
2661 printk(KERN_ERR
"enable\n");
2663 /* mCounterMeasureState=0; */
2664 printk(KERN_ERR
"disable\n");
2667 if (op
== ZD_PARAM_DROPUNENCRYPTED
) {
2668 printk(KERN_ERR
"ZD_PARAM_DROPUNENCRYPTED : ");
2671 printk(KERN_ERR
"enable\n");
2673 printk(KERN_ERR
"disable\n");
2676 if (op
== ZD_PARAM_AUTH_ALGS
) {
2677 printk(KERN_ERR
"ZD_PARAM_AUTH_ALGS : ");
2680 printk(KERN_ERR
"OPEN_SYSTEM\n");
2682 printk(KERN_ERR
"SHARED_KEY\n");
2685 if (op
== ZD_PARAM_WPS_FILTER
) {
2686 printk(KERN_ERR
"ZD_PARAM_WPS_FILTER : ");
2689 /* mCounterMeasureState=1; */
2690 macp
->forwardMgmt
= 1;
2691 printk(KERN_ERR
"enable\n");
2693 /* mCounterMeasureState=0; */
2694 macp
->forwardMgmt
= 0;
2695 printk(KERN_ERR
"disable\n");
2701 case ZD_IOCTL_GETWPAIE
: {
2702 struct ieee80211req_wpaie req_wpaie
;
2706 apId
= zfLnxGetVapId(dev
);
2708 if (apId
== 0xffff) {
2714 if (copy_from_user(&req_wpaie
, ifr
->ifr_data
,
2715 sizeof(struct ieee80211req_wpaie
))) {
2716 printk(KERN_ERR
"usbdrv : copy_from_user error\n");
2720 for (i
= 0; i
< ZM_OAL_MAX_STA_SUPPORT
; i
++) {
2721 for (j
= 0; j
< IEEE80211_ADDR_LEN
; j
++) {
2722 if (macp
->stawpaie
[i
].wpa_macaddr
[j
] !=
2723 req_wpaie
.wpa_macaddr
[j
])
2730 if (i
< ZM_OAL_MAX_STA_SUPPORT
) {
2731 /* printk("ZD_IOCTL_GETWPAIE - sta index = % d\n", i); */
2732 memcpy(req_wpaie
.wpa_ie
, macp
->stawpaie
[i
].wpa_ie
,
2733 IEEE80211_MAX_IE_SIZE
);
2736 if (copy_to_user(wrq
->u
.data
.pointer
, &req_wpaie
,
2737 sizeof(struct ieee80211req_wpaie
))) {
2744 #ifdef ZM_ENABLE_CENC
2746 if (copy_from_user(&macp
->zd_wpa_req
, ifr
->ifr_data
,
2747 sizeof(struct athr_wlan_param
))) {
2748 printk(KERN_ERR
"usbdrv : copy_from_user error\n");
2752 usbdrv_cenc_ioctl(dev
,
2753 (struct zydas_cenc_param
*)&macp
->zd_wpa_req
);
2756 #endif /* ZM_ENABLE_CENC */