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/module.h>
27 #include <linux/if_arp.h>
28 #include <linux/uaccess.h>
32 #define ZD_IOCTL_WPA (SIOCDEVPRIVATE + 1)
33 #define ZD_IOCTL_PARAM (SIOCDEVPRIVATE + 2)
34 #define ZD_IOCTL_GETWPAIE (SIOCDEVPRIVATE + 3)
36 #define ZM_IOCTL_CENC (SIOCDEVPRIVATE + 4)
37 #endif /* ZM_ENABLE_CENC */
38 #define ZD_PARAM_ROAMING 0x0001
39 #define ZD_PARAM_PRIVACY 0x0002
40 #define ZD_PARAM_WPA 0x0003
41 #define ZD_PARAM_COUNTERMEASURES 0x0004
42 #define ZD_PARAM_DROPUNENCRYPTED 0x0005
43 #define ZD_PARAM_AUTH_ALGS 0x0006
44 #define ZD_PARAM_WPS_FILTER 0x0007
47 #define P80211_PACKET_CENCFLAG 0x0001
48 #endif /* ZM_ENABLE_CENC */
49 #define P80211_PACKET_SETKEY 0x0003
51 #define ZD_CMD_SET_ENCRYPT_KEY 0x0001
52 #define ZD_CMD_SET_MLME 0x0002
53 #define ZD_CMD_SCAN_REQ 0x0003
54 #define ZD_CMD_SET_GENERIC_ELEMENT 0x0004
55 #define ZD_CMD_GET_TSC 0x0005
57 #define ZD_CRYPT_ALG_NAME_LEN 16
58 #define ZD_MAX_KEY_SIZE 32
59 #define ZD_MAX_GENERIC_SIZE 64
61 #include <net/iw_handler.h>
63 extern u16_t
zfLnxGetVapId(zdev_t
*dev
);
65 static const u32_t channel_frequency_11A
[] =
67 /* Even element for Channel Number, Odd for Frequency */
108 int usbdrv_freq2chan(u32_t freq
)
111 if (freq
> 2400 && freq
< 3000) {
112 return ((freq
-2412)/5) + 1;
115 u16_t num_chan
= sizeof(channel_frequency_11A
)/sizeof(u32_t
);
117 for (ii
= 1; ii
< num_chan
; ii
+= 2) {
118 if (channel_frequency_11A
[ii
] == freq
)
119 return channel_frequency_11A
[ii
-1];
126 int usbdrv_chan2freq(int chan
)
130 /* If channel number is out of range */
131 if (chan
> 165 || chan
<= 0)
135 if (chan
>= 1 && chan
<= 13) {
136 freq
= (2412 + (chan
- 1) * 5);
138 } else if (chan
>= 36 && chan
<= 165) {
140 u16_t num_chan
= sizeof(channel_frequency_11A
)/sizeof(u32_t
);
142 for (ii
= 0; ii
< num_chan
; ii
+= 2) {
143 if (channel_frequency_11A
[ii
] == chan
)
144 return channel_frequency_11A
[ii
+1];
147 /* Can't find desired frequency */
152 /* Can't find deisred frequency */
156 int usbdrv_ioctl_setessid(struct net_device
*dev
, struct iw_point
*erq
)
158 #ifdef ZM_HOSTAPD_SUPPORT
159 /* struct usbdrv_private *macp = dev->ml_priv; */
160 char essidbuf
[IW_ESSID_MAX_SIZE
+1];
163 if (!netif_running(dev
))
166 memset(essidbuf
, 0, sizeof(essidbuf
));
168 printk(KERN_ERR
"usbdrv_ioctl_setessid\n");
170 /* printk("ssidlen=%d\n", erq->length); //for any, it is 1. */
172 if (erq
->length
> (IW_ESSID_MAX_SIZE
+1))
175 if (copy_from_user(essidbuf
, erq
->pointer
, erq
->length
))
179 /* zd_DisasocAll(2); */
182 printk(KERN_ERR
"essidbuf: ");
184 for (i
= 0; i
< erq
->length
; i
++)
185 printk(KERN_ERR
"%02x ", essidbuf
[i
]);
187 printk(KERN_ERR
"\n");
189 essidbuf
[erq
->length
] = '\0';
190 /* memcpy(macp->wd.ws.ssid, essidbuf, erq->length); */
191 /* macp->wd.ws.ssidLen = strlen(essidbuf)+2; */
192 /* macp->wd.ws.ssid[1] = strlen(essidbuf); Update ssid length */
194 zfiWlanSetSSID(dev
, essidbuf
, erq
->length
);
196 printk(KERN_ERR
"macp->wd.ws.ssid: ");
198 for (i
= 0; i
< macp
->wd
.ws
.ssidLen
; i
++)
199 printk(KERN_ERR
"%02x ", macp
->wd
.ws
.ssid
[i
]);
201 printk(KERN_ERR
"\n");
204 zfiWlanDisable(dev
, 0);
212 int usbdrv_ioctl_getessid(struct net_device
*dev
, struct iw_point
*erq
)
214 /* struct usbdrv_private *macp = dev->ml_priv; */
215 u8_t essidbuf
[IW_ESSID_MAX_SIZE
+1];
220 /* len = macp->wd.ws.ssidLen; */
221 /* memcpy(essidbuf, macp->wd.ws.ssid, macp->wd.ws.ssidLen); */
222 zfiWlanQuerySSID(dev
, essidbuf
, &len
);
226 printk(KERN_ERR
"ESSID: ");
228 for (i
= 0; i
< len
; i
++)
229 printk(KERN_ERR
"%c", essidbuf
[i
]);
231 printk(KERN_ERR
"\n");
234 erq
->length
= strlen(essidbuf
) + 1;
237 if (copy_to_user(erq
->pointer
, essidbuf
, erq
->length
))
244 int usbdrv_ioctl_setrts(struct net_device
*dev
, struct iw_param
*rrq
)
250 * Encode a WPA or RSN information element as a custom
251 * element using the hostap format.
253 u32
encode_ie(void *buf
, u32 bufsize
, const u8
*ie
, u32 ielen
,
254 const u8
*leader
, u32 leader_len
)
259 if (bufsize
< leader_len
)
262 memcpy(p
, leader
, leader_len
);
263 bufsize
-= leader_len
;
265 for (i
= 0; i
< ielen
&& bufsize
> 2; i
++)
266 p
+= sprintf(p
, "%02x", ie
[i
]);
267 return (i
== ielen
? p
- (u8
*)buf
:0);
271 * Translate scan data returned from the card to a card independent
272 * format that the Wireless Tools will understand
274 char *usbdrv_translate_scan(struct net_device
*dev
,
275 struct iw_request_info
*info
, char *current_ev
,
276 char *end_buf
, struct zsBssInfo
*list
)
278 struct iw_event iwe
; /* Temporary buffer */
280 char *current_val
; /* For rates */
285 last_ev
= current_ev
;
287 /* First entry *MUST* be the AP MAC address */
289 iwe
.u
.ap_addr
.sa_family
= ARPHRD_ETHER
;
290 memcpy(iwe
.u
.ap_addr
.sa_data
, list
->bssid
, ETH_ALEN
);
291 current_ev
= iwe_stream_add_event(info
, current_ev
,
292 end_buf
, &iwe
, IW_EV_ADDR_LEN
);
294 /* Ran out of buffer */
295 if (last_ev
== current_ev
)
298 last_ev
= current_ev
;
300 /* Other entries will be displayed in the order we give them */
303 iwe
.u
.data
.length
= list
->ssid
[1];
304 if (iwe
.u
.data
.length
> 32)
305 iwe
.u
.data
.length
= 32;
306 iwe
.cmd
= SIOCGIWESSID
;
307 iwe
.u
.data
.flags
= 1;
308 current_ev
= iwe_stream_add_point(info
, current_ev
,
309 end_buf
, &iwe
, &list
->ssid
[2]);
311 /* Ran out of buffer */
312 if (last_ev
== current_ev
)
315 last_ev
= current_ev
;
318 iwe
.cmd
= SIOCGIWMODE
;
319 capabilities
= (list
->capability
[1] << 8) + list
->capability
[0];
320 if (capabilities
& (0x01 | 0x02)) {
321 if (capabilities
& 0x01)
322 iwe
.u
.mode
= IW_MODE_MASTER
;
324 iwe
.u
.mode
= IW_MODE_ADHOC
;
325 current_ev
= iwe_stream_add_event(info
, current_ev
,
326 end_buf
, &iwe
, IW_EV_UINT_LEN
);
329 /* Ran out of buffer */
330 if (last_ev
== current_ev
)
333 last_ev
= current_ev
;
336 iwe
.cmd
= SIOCGIWFREQ
;
337 iwe
.u
.freq
.m
= list
->channel
;
338 /* Channel frequency in KHz */
339 if (iwe
.u
.freq
.m
> 14) {
340 if ((184 <= iwe
.u
.freq
.m
) && (iwe
.u
.freq
.m
<= 196))
341 iwe
.u
.freq
.m
= 4000 + iwe
.u
.freq
.m
* 5;
343 iwe
.u
.freq
.m
= 5000 + iwe
.u
.freq
.m
* 5;
345 if (iwe
.u
.freq
.m
== 14)
348 iwe
.u
.freq
.m
= 2412 + (iwe
.u
.freq
.m
- 1) * 5;
351 current_ev
= iwe_stream_add_event(info
, current_ev
,
352 end_buf
, &iwe
, IW_EV_FREQ_LEN
);
354 /* Ran out of buffer */
355 if (last_ev
== current_ev
)
358 last_ev
= current_ev
;
360 /* Add quality statistics */
362 iwe
.u
.qual
.updated
= IW_QUAL_QUAL_UPDATED
| IW_QUAL_LEVEL_UPDATED
363 | IW_QUAL_NOISE_UPDATED
;
364 iwe
.u
.qual
.level
= list
->signalStrength
;
365 iwe
.u
.qual
.noise
= 0;
366 iwe
.u
.qual
.qual
= list
->signalQuality
;
367 current_ev
= iwe_stream_add_event(info
, current_ev
,
368 end_buf
, &iwe
, IW_EV_QUAL_LEN
);
370 /* Ran out of buffer */
371 if (last_ev
== current_ev
)
374 last_ev
= current_ev
;
376 /* Add encryption capability */
378 iwe
.cmd
= SIOCGIWENCODE
;
379 if (capabilities
& 0x10)
380 iwe
.u
.data
.flags
= IW_ENCODE_ENABLED
| IW_ENCODE_NOKEY
;
382 iwe
.u
.data
.flags
= IW_ENCODE_DISABLED
;
384 iwe
.u
.data
.length
= 0;
385 current_ev
= iwe_stream_add_point(info
, current_ev
,
386 end_buf
, &iwe
, list
->ssid
);
388 /* Ran out of buffer */
389 if (last_ev
== current_ev
)
392 last_ev
= current_ev
;
394 /* Rate : stuffing multiple values in a single event require a bit
397 current_val
= current_ev
+ IW_EV_LCP_LEN
;
399 iwe
.cmd
= SIOCGIWRATE
;
400 /* Those two flags are ignored... */
401 iwe
.u
.bitrate
.fixed
= iwe
.u
.bitrate
.disabled
= 0;
403 for (i
= 0 ; i
< list
->supportedRates
[1] ; i
++) {
404 /* Bit rate given in 500 kb/s units (+ 0x80) */
405 iwe
.u
.bitrate
.value
= ((list
->supportedRates
[i
+2] & 0x7f)
407 /* Add new value to event */
408 current_val
= iwe_stream_add_value(info
, current_ev
,
409 current_val
, end_buf
, &iwe
, IW_EV_PARAM_LEN
);
411 /* Ran out of buffer */
412 if (last_ev
== current_val
)
415 last_ev
= current_val
;
418 for (i
= 0 ; i
< list
->extSupportedRates
[1] ; i
++) {
419 /* Bit rate given in 500 kb/s units (+ 0x80) */
420 iwe
.u
.bitrate
.value
= ((list
->extSupportedRates
[i
+2] & 0x7f)
422 /* Add new value to event */
423 current_val
= iwe_stream_add_value(info
, current_ev
,
424 current_val
, end_buf
, &iwe
, IW_EV_PARAM_LEN
);
426 /* Ran out of buffer */
427 if (last_ev
== current_val
)
430 last_ev
= current_ev
;
433 /* Check if we added any event */
434 if ((current_val
- current_ev
) > IW_EV_LCP_LEN
)
435 current_ev
= current_val
;
436 #define IEEE80211_ELEMID_RSN 0x30
437 memset(&iwe
, 0, sizeof(iwe
));
438 iwe
.cmd
= IWEVCUSTOM
;
439 snprintf(buf
, sizeof(buf
), "bcn_int=%d", (list
->beaconInterval
[1] << 8)
440 + list
->beaconInterval
[0]);
441 iwe
.u
.data
.length
= strlen(buf
);
442 current_ev
= iwe_stream_add_point(info
, current_ev
,
445 /* Ran out of buffer */
446 if (last_ev
== current_ev
)
449 last_ev
= current_ev
;
451 if (list
->wpaIe
[1] != 0) {
452 static const char rsn_leader
[] = "rsn_ie=";
453 static const char wpa_leader
[] = "wpa_ie=";
455 memset(&iwe
, 0, sizeof(iwe
));
456 iwe
.cmd
= IWEVCUSTOM
;
457 if (list
->wpaIe
[0] == IEEE80211_ELEMID_RSN
)
458 iwe
.u
.data
.length
= encode_ie(buf
, sizeof(buf
),
459 list
->wpaIe
, list
->wpaIe
[1]+2,
460 rsn_leader
, sizeof(rsn_leader
)-1);
462 iwe
.u
.data
.length
= encode_ie(buf
, sizeof(buf
),
463 list
->wpaIe
, list
->wpaIe
[1]+2,
464 wpa_leader
, sizeof(wpa_leader
)-1);
466 if (iwe
.u
.data
.length
!= 0)
467 current_ev
= iwe_stream_add_point(info
, current_ev
,
470 /* Ran out of buffer */
471 if (last_ev
== current_ev
)
474 last_ev
= current_ev
;
477 if (list
->rsnIe
[1] != 0) {
478 static const char rsn_leader
[] = "rsn_ie=";
479 memset(&iwe
, 0, sizeof(iwe
));
480 iwe
.cmd
= IWEVCUSTOM
;
482 if (list
->rsnIe
[0] == IEEE80211_ELEMID_RSN
) {
483 iwe
.u
.data
.length
= encode_ie(buf
, sizeof(buf
),
484 list
->rsnIe
, list
->rsnIe
[1]+2,
485 rsn_leader
, sizeof(rsn_leader
)-1);
486 if (iwe
.u
.data
.length
!= 0)
487 current_ev
= iwe_stream_add_point(info
,
488 current_ev
, end_buf
, &iwe
, buf
);
490 /* Ran out of buffer */
491 if (last_ev
== current_ev
)
494 last_ev
= current_ev
;
497 /* The other data in the scan result are not really
498 * interesting, so for now drop it
503 int usbdrvwext_giwname(struct net_device
*dev
,
504 struct iw_request_info
*info
,
505 union iwreq_data
*wrq
, char *extra
)
507 /* struct usbdrv_private *macp = dev->ml_priv; */
509 strcpy(wrq
->name
, "IEEE 802.11-MIMO");
514 int usbdrvwext_siwfreq(struct net_device
*dev
,
515 struct iw_request_info
*info
,
516 struct iw_freq
*freq
, char *extra
)
519 struct usbdrv_private
*macp
= dev
->ml_priv
;
521 if (!netif_running(dev
))
528 FreqKHz
= (freq
->m
/ 100000);
530 if (FreqKHz
> 4000000) {
531 if (FreqKHz
> 5825000)
533 else if (FreqKHz
< 4920000)
535 else if (FreqKHz
< 5000000)
536 FreqKHz
= (((FreqKHz
- 4000000) / 5000) * 5000)
539 FreqKHz
= (((FreqKHz
- 5000000) / 5000) * 5000)
542 if (FreqKHz
> 2484000)
544 else if (FreqKHz
< 2412000)
547 FreqKHz
= (((FreqKHz
- 2412000) / 5000) * 5000)
551 FreqKHz
= usbdrv_chan2freq(freq
->m
);
559 /* printk("freq->m: %d, freq->e: %d\n", freq->m, freq->e); */
560 /* printk("FreqKHz: %d\n", FreqKHz); */
562 if (macp
->DeviceOpened
== 1) {
563 zfiWlanSetFrequency(dev
, FreqKHz
, 0); /* Immediate */
564 /* u8_t wpaieLen,wpaie[50]; */
565 /* zfiWlanQueryWpaIe(dev, wpaie, &wpaieLen); */
566 zfiWlanDisable(dev
, 0);
568 /* if (wpaieLen > 2) */
569 /* zfiWlanSetWpaIe(dev, wpaie, wpaieLen); */
575 int usbdrvwext_giwfreq(struct net_device
*dev
,
576 struct iw_request_info
*info
,
577 struct iw_freq
*freq
, char *extra
)
579 struct usbdrv_private
*macp
= dev
->ml_priv
;
581 if (macp
->DeviceOpened
!= 1)
584 freq
->m
= zfiWlanQueryFrequency(dev
);
590 int usbdrvwext_siwmode(struct net_device
*dev
,
591 struct iw_request_info
*info
,
592 union iwreq_data
*wrq
, char *extra
)
594 struct usbdrv_private
*macp
= dev
->ml_priv
;
597 if (!netif_running(dev
))
600 if (macp
->DeviceOpened
!= 1)
605 WlanMode
= ZM_MODE_AP
;
608 WlanMode
= ZM_MODE_INFRASTRUCTURE
;
611 WlanMode
= ZM_MODE_IBSS
;
614 WlanMode
= ZM_MODE_IBSS
;
618 zfiWlanSetWlanMode(dev
, WlanMode
);
619 zfiWlanDisable(dev
, 1);
625 int usbdrvwext_giwmode(struct net_device
*dev
,
626 struct iw_request_info
*info
,
627 __u32
*mode
, char *extra
)
629 unsigned long irqFlag
;
630 struct usbdrv_private
*macp
= dev
->ml_priv
;
632 if (!netif_running(dev
))
635 if (macp
->DeviceOpened
!= 1)
638 spin_lock_irqsave(&macp
->cs_lock
, irqFlag
);
640 switch (zfiWlanQueryWlanMode(dev
)) {
642 *mode
= IW_MODE_MASTER
;
644 case ZM_MODE_INFRASTRUCTURE
:
645 *mode
= IW_MODE_INFRA
;
648 *mode
= IW_MODE_ADHOC
;
651 *mode
= IW_MODE_ADHOC
;
655 spin_unlock_irqrestore(&macp
->cs_lock
, irqFlag
);
660 int usbdrvwext_siwsens(struct net_device
*dev
,
661 struct iw_request_info
*info
,
662 struct iw_param
*sens
, char *extra
)
667 int usbdrvwext_giwsens(struct net_device
*dev
,
668 struct iw_request_info
*info
,
669 struct iw_param
*sens
, char *extra
)
677 int usbdrvwext_giwrange(struct net_device
*dev
,
678 struct iw_request_info
*info
,
679 struct iw_point
*data
, char *extra
)
681 struct iw_range
*range
= (struct iw_range
*) extra
;
683 /* int num_band_a; */
687 if (!netif_running(dev
))
690 range
->txpower_capa
= IW_TXPOW_DBM
;
691 /* XXX what about min/max_pmp, min/max_pmt, etc. */
693 range
->we_version_compiled
= WIRELESS_EXT
;
694 range
->we_version_source
= 13;
696 range
->retry_capa
= IW_RETRY_LIMIT
;
697 range
->retry_flags
= IW_RETRY_LIMIT
;
698 range
->min_retry
= 0;
699 range
->max_retry
= 255;
701 channel_num
= zfiWlanQueryAllowChannels(dev
, channels
);
703 /* Gurantee reported channel numbers is less
704 * or equal to IW_MAX_FREQUENCIES
706 if (channel_num
> IW_MAX_FREQUENCIES
)
707 channel_num
= IW_MAX_FREQUENCIES
;
711 for (i
= 0; i
< channel_num
; i
++) {
712 range
->freq
[val
].i
= usbdrv_freq2chan(channels
[i
]);
713 range
->freq
[val
].m
= channels
[i
];
714 range
->freq
[val
].e
= 6;
718 range
->num_channels
= channel_num
;
719 range
->num_frequency
= channel_num
;
722 range
->num_channels
= 14; /* Only 2.4G */
724 /* XXX need to filter against the regulatory domain &| active set */
727 for (i
= 1; i
<= 14; i
++) {
728 range
->freq
[val
].i
= i
;
730 range
->freq
[val
].m
= 2484000;
732 range
->freq
[val
].m
= (2412+(i
-1)*5)*1000;
733 range
->freq
[val
].e
= 3;
737 num_band_a
= (IW_MAX_FREQUENCIES
- val
);
739 for (i
= 0; i
< num_band_a
; i
++) {
740 range
->freq
[val
].i
= channel_frequency_11A
[2 * i
];
741 range
->freq
[val
].m
= channel_frequency_11A
[2 * i
+ 1] * 1000;
742 range
->freq
[val
].e
= 3;
745 /* MIMO Rate Not Defined Now
746 * For 802.11a, there are too more frequency.
747 * We can't return them all.
749 range
->num_frequency
= val
;
752 /* Max of /proc/net/wireless */
753 range
->max_qual
.qual
= 100; /* ?? 92; */
754 range
->max_qual
.level
= 154; /* ?? */
755 range
->max_qual
.noise
= 154; /* ?? */
756 range
->sensitivity
= 3; /* ?? */
758 /* XXX these need to be nsd-specific! */
760 range
->max_rts
= 2347;
761 range
->min_frag
= 256;
762 range
->max_frag
= 2346;
763 range
->max_encoding_tokens
= 4 /* NUM_WEPKEYS ?? */;
764 range
->num_encoding_sizes
= 2; /* ?? */
766 range
->encoding_size
[0] = 5; /* ?? WEP Key Encoding Size */
767 range
->encoding_size
[1] = 13; /* ?? */
769 /* XXX what about num_bitrates/throughput? */
770 range
->num_bitrates
= 0; /* ?? */
772 /* estimated max throughput
773 * XXX need to cap it if we're running at ~2Mbps..
776 range
->throughput
= 300000000;
781 int usbdrvwext_siwap(struct net_device
*dev
, struct iw_request_info
*info
,
782 struct sockaddr
*MacAddr
, char *extra
)
784 struct usbdrv_private
*macp
= dev
->ml_priv
;
786 if (!netif_running(dev
))
789 if (zfiWlanQueryWlanMode(dev
) == ZM_MODE_AP
) {
791 zfiWlanSetMacAddress(dev
, (u16_t
*)&MacAddr
->sa_data
[0]);
794 zfiWlanSetBssid(dev
, &MacAddr
->sa_data
[0]);
797 if (macp
->DeviceOpened
== 1) {
798 /* u8_t wpaieLen,wpaie[80]; */
799 /* zfiWlanQueryWpaIe(dev, wpaie, &wpaieLen); */
800 zfiWlanDisable(dev
, 0);
802 /* if (wpaieLen > 2) */
803 /* zfiWlanSetWpaIe(dev, wpaie, wpaieLen); */
809 int usbdrvwext_giwap(struct net_device
*dev
,
810 struct iw_request_info
*info
,
811 struct sockaddr
*MacAddr
, char *extra
)
813 struct usbdrv_private
*macp
= dev
->ml_priv
;
815 if (macp
->DeviceOpened
!= 1)
818 if (zfiWlanQueryWlanMode(dev
) == ZM_MODE_AP
) {
820 zfiWlanQueryMacAddress(dev
, &MacAddr
->sa_data
[0]);
823 if (macp
->adapterState
== ZM_STATUS_MEDIA_CONNECT
) {
824 zfiWlanQueryBssid(dev
, &MacAddr
->sa_data
[0]);
826 u8_t zero_addr
[6] = { 0x00, 0x00, 0x00, 0x00,
828 memcpy(&MacAddr
->sa_data
[0], zero_addr
,
836 int usbdrvwext_iwaplist(struct net_device
*dev
,
837 struct iw_request_info
*info
,
838 struct iw_point
*data
, char *extra
)
840 /* Don't know how to do yet--CWYang(+) */
845 int usbdrvwext_siwscan(struct net_device
*dev
, struct iw_request_info
*info
,
846 struct iw_point
*data
, char *extra
)
848 struct usbdrv_private
*macp
= dev
->ml_priv
;
850 if (macp
->DeviceOpened
!= 1)
853 printk(KERN_WARNING
"CWY - usbdrvwext_siwscan\n");
860 int usbdrvwext_giwscan(struct net_device
*dev
,
861 struct iw_request_info
*info
,
862 struct iw_point
*data
, char *extra
)
864 struct usbdrv_private
*macp
= dev
->ml_priv
;
865 /* struct zsWlanDev* wd = (struct zsWlanDev*) zmw_wlan_dev(dev); */
866 char *current_ev
= extra
;
869 /* struct zsBssList BssList; */
870 struct zsBssListV1
*pBssList
= kmalloc(sizeof(struct zsBssListV1
),
872 /* BssList = wd->sta.pBssList; */
873 /* zmw_get_wlan_dev(dev); */
875 if (macp
->DeviceOpened
!= 1)
878 if (data
->length
== 0)
879 end_buf
= extra
+ IW_SCAN_MAX_DATA
;
881 end_buf
= extra
+ data
->length
;
883 printk(KERN_WARNING
"giwscan - Report Scan Results\n");
884 /* printk("giwscan - BssList Sreucture Len : %d\n", sizeof(BssList));
885 * printk("giwscan - BssList Count : %d\n",
886 * wd->sta.pBssList->bssCount);
887 * printk("giwscan - UpdateBssList Count : %d\n",
888 * wd->sta.pUpdateBssList->bssCount);
890 zfiWlanQueryBssListV1(dev
, pBssList
);
891 /* zfiWlanQueryBssList(dev, &BssList); */
893 /* Read and parse all entries */
894 printk(KERN_WARNING
"giwscan - pBssList->bssCount : %d\n",
896 /* printk("giwscan - BssList.bssCount : %d\n", BssList.bssCount); */
898 for (i
= 0; i
< pBssList
->bssCount
; i
++) {
899 /* Translate to WE format this entry
900 * current_ev = usbdrv_translate_scan(dev, info, current_ev,
901 * extra + IW_SCAN_MAX_DATA, &pBssList->bssInfo[i]);
903 current_ev
= usbdrv_translate_scan(dev
, info
, current_ev
,
904 end_buf
, &pBssList
->bssInfo
[i
]);
906 if (current_ev
== end_buf
) {
908 data
->length
= current_ev
- extra
;
914 data
->length
= (current_ev
- extra
);
915 data
->flags
= 0; /* todo */
922 int usbdrvwext_siwessid(struct net_device
*dev
,
923 struct iw_request_info
*info
,
924 struct iw_point
*essid
, char *extra
)
926 char EssidBuf
[IW_ESSID_MAX_SIZE
+ 1];
927 struct usbdrv_private
*macp
= dev
->ml_priv
;
929 if (!netif_running(dev
))
932 if (essid
->flags
== 1) {
933 if (essid
->length
> (IW_ESSID_MAX_SIZE
+ 1))
936 if (copy_from_user(&EssidBuf
, essid
->pointer
, essid
->length
))
939 EssidBuf
[essid
->length
] = '\0';
940 /* printk("siwessid - Set Essid : %s\n",EssidBuf); */
941 /* printk("siwessid - Essid Len : %d\n",essid->length); */
942 /* printk("siwessid - Essid Flag : %x\n",essid->flags); */
943 if (macp
->DeviceOpened
== 1) {
944 zfiWlanSetSSID(dev
, EssidBuf
, strlen(EssidBuf
));
945 zfiWlanSetFrequency(dev
, zfiWlanQueryFrequency(dev
),
947 zfiWlanSetEncryMode(dev
, zfiWlanQueryEncryMode(dev
));
948 /* u8_t wpaieLen,wpaie[50]; */
949 /* zfiWlanQueryWpaIe(dev, wpaie, &wpaieLen); */
950 zfiWlanDisable(dev
, 0);
952 /* if (wpaieLen > 2) */
953 /* zfiWlanSetWpaIe(dev, wpaie, wpaieLen); */
960 int usbdrvwext_giwessid(struct net_device
*dev
,
961 struct iw_request_info
*info
,
962 struct iw_point
*essid
, char *extra
)
964 struct usbdrv_private
*macp
= dev
->ml_priv
;
966 char EssidBuf
[IW_ESSID_MAX_SIZE
+ 1];
969 if (!netif_running(dev
))
972 if (macp
->DeviceOpened
!= 1)
975 zfiWlanQuerySSID(dev
, &EssidBuf
[0], &EssidLen
);
977 /* Convert type from unsigned char to char */
978 ssid_len
= (int)EssidLen
;
980 /* Make sure the essid length is not greater than IW_ESSID_MAX_SIZE */
981 if (ssid_len
> IW_ESSID_MAX_SIZE
)
982 ssid_len
= IW_ESSID_MAX_SIZE
;
984 EssidBuf
[ssid_len
] = '\0';
987 essid
->length
= strlen(EssidBuf
);
989 memcpy(extra
, EssidBuf
, essid
->length
);
990 /* wireless.c in Kernel would handle copy_to_user -- line 679 */
991 /* if (essid->pointer) {
992 * if (copy_to_user(essid->pointer, EssidBuf, essid->length)) {
993 * printk("giwessid - copy_to_user Fail\n");
1002 int usbdrvwext_siwnickn(struct net_device
*dev
,
1003 struct iw_request_info
*info
,
1004 struct iw_point
*data
, char *nickname
)
1006 /* Exist but junk--CWYang(+) */
1010 int usbdrvwext_giwnickn(struct net_device
*dev
,
1011 struct iw_request_info
*info
,
1012 struct iw_point
*data
, char *nickname
)
1014 struct usbdrv_private
*macp
= dev
->ml_priv
;
1016 char EssidBuf
[IW_ESSID_MAX_SIZE
+ 1];
1018 if (macp
->DeviceOpened
!= 1)
1021 zfiWlanQuerySSID(dev
, &EssidBuf
[0], &EssidLen
);
1022 EssidBuf
[EssidLen
] = 0;
1025 data
->length
= strlen(EssidBuf
);
1027 memcpy(nickname
, EssidBuf
, data
->length
);
1032 int usbdrvwext_siwrate(struct net_device
*dev
,
1033 struct iw_request_info
*info
,
1034 struct iw_param
*frq
, char *extra
)
1036 struct usbdrv_private
*macp
= dev
->ml_priv
;
1037 /* Array to Define Rate Number that Send to Driver */
1038 u16_t zcIndextoRateBG
[16] = {1000, 2000, 5500, 11000, 0, 0, 0, 0,
1039 48000, 24000, 12000, 6000, 54000, 36000, 18000, 9000};
1040 u16_t zcRateToMCS
[] = {0xff, 0, 1, 2, 3, 0xb, 0xf, 0xa, 0xe, 0x9, 0xd,
1042 u8_t i
, RateIndex
= 4;
1045 /* printk("frq->disabled : 0x%x\n",frq->disabled); */
1046 /* printk("frq->value : 0x%x\n",frq->value); */
1048 RateKbps
= frq
->value
/ 1000;
1049 /* printk("RateKbps : %d\n", RateKbps); */
1050 for (i
= 0; i
< 16; i
++) {
1051 if (RateKbps
== zcIndextoRateBG
[i
])
1055 if (zcIndextoRateBG
[RateIndex
] == 0)
1057 /* printk("RateIndex : %x\n", RateIndex); */
1058 for (i
= 0; i
< 13; i
++)
1059 if (RateIndex
== zcRateToMCS
[i
])
1061 /* printk("Index : %x\n", i); */
1062 if (RateKbps
== 65000) {
1064 printk(KERN_WARNING
"RateIndex : %d\n", RateIndex
);
1067 if (macp
->DeviceOpened
== 1) {
1068 zfiWlanSetTxRate(dev
, i
);
1069 /* zfiWlanDisable(dev); */
1070 /* zfiWlanEnable(dev); */
1076 int usbdrvwext_giwrate(struct net_device
*dev
,
1077 struct iw_request_info
*info
,
1078 struct iw_param
*frq
, char *extra
)
1080 struct usbdrv_private
*macp
= dev
->ml_priv
;
1082 if (!netif_running(dev
))
1085 if (macp
->DeviceOpened
!= 1)
1090 frq
->value
= zfiWlanQueryRxRate(dev
) * 1000;
1095 int usbdrvwext_siwrts(struct net_device
*dev
,
1096 struct iw_request_info
*info
,
1097 struct iw_param
*rts
, char *extra
)
1099 struct usbdrv_private
*macp
= dev
->ml_priv
;
1100 int val
= rts
->value
;
1102 if (macp
->DeviceOpened
!= 1)
1108 if ((val
< 0) || (val
> 2347))
1111 zfiWlanSetRtsThreshold(dev
, val
);
1116 int usbdrvwext_giwrts(struct net_device
*dev
,
1117 struct iw_request_info
*info
,
1118 struct iw_param
*rts
, char *extra
)
1120 struct usbdrv_private
*macp
= dev
->ml_priv
;
1122 if (!netif_running(dev
))
1125 if (macp
->DeviceOpened
!= 1)
1128 rts
->value
= zfiWlanQueryRtsThreshold(dev
);
1129 rts
->disabled
= (rts
->value
>= 2347);
1135 int usbdrvwext_siwfrag(struct net_device
*dev
,
1136 struct iw_request_info
*info
,
1137 struct iw_param
*frag
, char *extra
)
1139 struct usbdrv_private
*macp
= dev
->ml_priv
;
1140 u16_t fragThreshold
;
1142 if (macp
->DeviceOpened
!= 1)
1148 fragThreshold
= frag
->value
;
1150 zfiWlanSetFragThreshold(dev
, fragThreshold
);
1155 int usbdrvwext_giwfrag(struct net_device
*dev
,
1156 struct iw_request_info
*info
,
1157 struct iw_param
*frag
, char *extra
)
1159 struct usbdrv_private
*macp
= dev
->ml_priv
;
1161 unsigned long irqFlag
;
1163 if (!netif_running(dev
))
1166 if (macp
->DeviceOpened
!= 1)
1169 spin_lock_irqsave(&macp
->cs_lock
, irqFlag
);
1171 val
= zfiWlanQueryFragThreshold(dev
);
1175 frag
->disabled
= (val
>= 2346);
1178 spin_unlock_irqrestore(&macp
->cs_lock
, irqFlag
);
1183 int usbdrvwext_siwtxpow(struct net_device
*dev
,
1184 struct iw_request_info
*info
,
1185 struct iw_param
*rrq
, char *extra
)
1187 /* Not support yet--CWYng(+) */
1191 int usbdrvwext_giwtxpow(struct net_device
*dev
,
1192 struct iw_request_info
*info
,
1193 struct iw_param
*rrq
, char *extra
)
1195 /* Not support yet--CWYng(+) */
1199 int usbdrvwext_siwretry(struct net_device
*dev
,
1200 struct iw_request_info
*info
,
1201 struct iw_param
*rrq
, char *extra
)
1203 /* Do nothing--CWYang(+) */
1207 int usbdrvwext_giwretry(struct net_device
*dev
,
1208 struct iw_request_info
*info
,
1209 struct iw_param
*rrq
, char *extra
)
1211 /* Do nothing--CWYang(+) */
1215 int usbdrvwext_siwencode(struct net_device
*dev
,
1216 struct iw_request_info
*info
,
1217 struct iw_point
*erq
, char *key
)
1219 struct zsKeyInfo keyInfo
;
1221 int WepState
= ZM_ENCRYPTION_WEP_DISABLED
;
1222 struct usbdrv_private
*macp
= dev
->ml_priv
;
1224 if (!netif_running(dev
))
1227 if ((erq
->flags
& IW_ENCODE_DISABLED
) == 0) {
1229 keyInfo
.keyLength
= erq
->length
;
1230 keyInfo
.keyIndex
= (erq
->flags
& IW_ENCODE_INDEX
) - 1;
1231 if (keyInfo
.keyIndex
>= 4)
1232 keyInfo
.keyIndex
= 0;
1233 keyInfo
.flag
= ZM_KEY_FLAG_DEFAULT_KEY
;
1235 zfiWlanSetKey(dev
, keyInfo
);
1236 WepState
= ZM_ENCRYPTION_WEP_ENABLED
;
1238 for (i
= 1; i
< 4; i
++)
1239 zfiWlanRemoveKey(dev
, 0, i
);
1240 WepState
= ZM_ENCRYPTION_WEP_DISABLED
;
1241 /* zfiWlanSetEncryMode(dev, ZM_NO_WEP); */
1244 if (macp
->DeviceOpened
== 1) {
1245 zfiWlanSetWepStatus(dev
, WepState
);
1246 zfiWlanSetFrequency(dev
, zfiWlanQueryFrequency(dev
), FALSE
);
1247 /* zfiWlanSetEncryMode(dev, zfiWlanQueryEncryMode(dev)); */
1248 /* u8_t wpaieLen,wpaie[50]; */
1249 /* zfiWlanQueryWpaIe(dev, wpaie, &wpaieLen); */
1250 zfiWlanDisable(dev
, 0);
1252 /* if (wpaieLen > 2) */
1253 /* zfiWlanSetWpaIe(dev, wpaie, wpaieLen); */
1259 int usbdrvwext_giwencode(struct net_device
*dev
,
1260 struct iw_request_info
*info
,
1261 struct iw_point
*erq
, char *key
)
1263 struct usbdrv_private
*macp
= dev
->ml_priv
;
1264 u8_t EncryptionMode
;
1267 if (macp
->DeviceOpened
!= 1)
1270 EncryptionMode
= zfiWlanQueryEncryMode(dev
);
1273 erq
->flags
= IW_ENCODE_ENABLED
;
1275 erq
->flags
= IW_ENCODE_DISABLED
;
1277 /* We can't return the key, so set the proper flag and return zero */
1278 erq
->flags
|= IW_ENCODE_NOKEY
;
1281 /* Copy the key to the user buffer */
1282 switch (EncryptionMode
) {
1298 #ifdef ZM_ENABLE_CENC
1300 /* ZM_ENABLE_CENC */
1309 printk(KERN_ERR
"Unknown EncryMode\n");
1312 erq
->length
= keyLen
;
1317 int usbdrvwext_siwpower(struct net_device
*dev
,
1318 struct iw_request_info
*info
,
1319 struct iw_param
*frq
, char *extra
)
1321 struct usbdrv_private
*macp
= dev
->ml_priv
;
1324 if (macp
->DeviceOpened
!= 1)
1328 PSMode
= ZM_STA_PS_NONE
;
1330 PSMode
= ZM_STA_PS_MAX
;
1332 zfiWlanSetPowerSaveMode(dev
, PSMode
);
1337 int usbdrvwext_giwpower(struct net_device
*dev
,
1338 struct iw_request_info
*info
,
1339 struct iw_param
*frq
, char *extra
)
1341 unsigned long irqFlag
;
1342 struct usbdrv_private
*macp
= dev
->ml_priv
;
1344 if (macp
->DeviceOpened
!= 1)
1347 spin_lock_irqsave(&macp
->cs_lock
, irqFlag
);
1349 if (zfiWlanQueryPowerSaveMode(dev
) == ZM_STA_PS_NONE
)
1354 spin_unlock_irqrestore(&macp
->cs_lock
, irqFlag
);
1359 /*int usbdrvwext_setparam(struct net_device *dev, struct iw_request_info *info,
1360 * void *w, char *extra)
1362 * struct ieee80211vap *vap = dev->ml_priv;
1363 * struct ieee80211com *ic = vap->iv_ic;
1364 * struct ieee80211_rsnparms *rsn = &vap->iv_bss->ni_rsn;
1365 * int *i = (int *) extra;
1366 * int param = i[0]; // parameter id is 1st
1367 * int value = i[1]; // NB: most values are TYPE_INT
1370 * const struct ieee80211_authenticator *auth;
1371 * const struct ieee80211_aclator *acl;
1374 * case IEEE80211_PARAM_AUTHMODE:
1376 * case IEEE80211_AUTH_WPA: // WPA
1377 * case IEEE80211_AUTH_8021X: // 802.1x
1378 * case IEEE80211_AUTH_OPEN: // open
1379 * case IEEE80211_AUTH_SHARED: // shared-key
1380 * case IEEE80211_AUTH_AUTO: // auto
1381 * auth = ieee80211_authenticator_get(value);
1389 * case IEEE80211_AUTH_WPA: // WPA w/ 802.1x
1390 * vap->iv_flags |= IEEE80211_F_PRIVACY;
1391 * value = IEEE80211_AUTH_8021X;
1393 * case IEEE80211_AUTH_OPEN: // open
1394 * vap->iv_flags &= ~(IEEE80211_F_WPA | IEEE80211_F_PRIVACY);
1396 * case IEEE80211_AUTH_SHARED: // shared-key
1397 * case IEEE80211_AUTH_AUTO: // auto
1398 * case IEEE80211_AUTH_8021X: // 802.1x
1399 * vap->iv_flags &= ~IEEE80211_F_WPA;
1400 * // both require a key so mark the PRIVACY capability
1401 * vap->iv_flags |= IEEE80211_F_PRIVACY;
1404 * // NB: authenticator attach/detach happens on state change
1405 * vap->iv_bss->ni_authmode = value;
1406 * // XXX mixed/mode/usage?
1407 * vap->iv_auth = auth;
1410 * case IEEE80211_PARAM_PROTMODE:
1411 * if (value > IEEE80211_PROT_RTSCTS)
1413 * ic->ic_protmode = value;
1414 * // NB: if not operating in 11g this can wait
1415 * if (ic->ic_bsschan != IEEE80211_CHAN_ANYC &&
1416 * IEEE80211_IS_CHAN_ANYG(ic->ic_bsschan))
1419 * case IEEE80211_PARAM_MCASTCIPHER:
1420 * if ((vap->iv_caps & cipher2cap(value)) == 0 &&
1421 * !ieee80211_crypto_available(value))
1423 * rsn->rsn_mcastcipher = value;
1424 * if (vap->iv_flags & IEEE80211_F_WPA)
1427 * case IEEE80211_PARAM_MCASTKEYLEN:
1428 * if (!(0 < value && value < IEEE80211_KEYBUF_SIZE))
1430 * // XXX no way to verify driver capability
1431 * rsn->rsn_mcastkeylen = value;
1432 * if (vap->iv_flags & IEEE80211_F_WPA)
1435 * case IEEE80211_PARAM_UCASTCIPHERS:
1437 * // Convert cipher set to equivalent capabilities.
1438 * // NB: this logic intentionally ignores unknown and
1439 * // unsupported ciphers so folks can specify 0xff or
1440 * // similar and get all available ciphers.
1443 * for (j = 1; j < 32; j++) // NB: skip WEP
1444 * if ((value & (1<<j)) &&
1445 * ((vap->iv_caps & cipher2cap(j)) ||
1446 * ieee80211_crypto_available(j)))
1448 * if (caps == 0) // nothing available
1450 * // XXX verify ciphers ok for unicast use?
1451 * // XXX disallow if running as it'll have no effect
1452 * rsn->rsn_ucastcipherset = caps;
1453 * if (vap->iv_flags & IEEE80211_F_WPA)
1456 * case IEEE80211_PARAM_UCASTCIPHER:
1457 * if ((rsn->rsn_ucastcipherset & cipher2cap(value)) == 0)
1459 * rsn->rsn_ucastcipher = value;
1461 * case IEEE80211_PARAM_UCASTKEYLEN:
1462 * if (!(0 < value && value < IEEE80211_KEYBUF_SIZE))
1464 * // XXX no way to verify driver capability
1465 * rsn->rsn_ucastkeylen = value;
1467 * case IEEE80211_PARAM_KEYMGTALGS:
1469 * rsn->rsn_keymgmtset = value;
1470 * if (vap->iv_flags & IEEE80211_F_WPA)
1473 * case IEEE80211_PARAM_RSNCAPS:
1475 * rsn->rsn_caps = value;
1476 * if (vap->iv_flags & IEEE80211_F_WPA)
1479 * case IEEE80211_PARAM_WPA:
1482 * // XXX verify ciphers available
1483 * vap->iv_flags &= ~IEEE80211_F_WPA;
1486 * vap->iv_flags |= IEEE80211_F_WPA1;
1489 * vap->iv_flags |= IEEE80211_F_WPA2;
1492 * vap->iv_flags |= IEEE80211_F_WPA1 | IEEE80211_F_WPA2;
1495 * retv = ENETRESET; // XXX?
1497 * case IEEE80211_PARAM_ROAMING:
1498 * if (!(IEEE80211_ROAMING_DEVICE <= value &&
1499 * value <= IEEE80211_ROAMING_MANUAL))
1501 * ic->ic_roaming = value;
1503 * case IEEE80211_PARAM_PRIVACY:
1505 * // XXX check for key state?
1506 * vap->iv_flags |= IEEE80211_F_PRIVACY;
1508 * vap->iv_flags &= ~IEEE80211_F_PRIVACY;
1510 * case IEEE80211_PARAM_DROPUNENCRYPTED:
1512 * vap->iv_flags |= IEEE80211_F_DROPUNENC;
1514 * vap->iv_flags &= ~IEEE80211_F_DROPUNENC;
1516 * case IEEE80211_PARAM_COUNTERMEASURES:
1518 * if ((vap->iv_flags & IEEE80211_F_WPA) == 0)
1520 * vap->iv_flags |= IEEE80211_F_COUNTERM;
1522 * vap->iv_flags &= ~IEEE80211_F_COUNTERM;
1524 * case IEEE80211_PARAM_DRIVER_CAPS:
1525 * vap->iv_caps = value; // NB: for testing
1527 * case IEEE80211_PARAM_MACCMD:
1528 * acl = vap->iv_acl;
1530 * case IEEE80211_MACCMD_POLICY_OPEN:
1531 * case IEEE80211_MACCMD_POLICY_ALLOW:
1532 * case IEEE80211_MACCMD_POLICY_DENY:
1533 * if (acl == NULL) {
1534 * acl = ieee80211_aclator_get("mac");
1535 * if (acl == NULL || !acl->iac_attach(vap))
1537 * vap->iv_acl = acl;
1539 * acl->iac_setpolicy(vap, value);
1541 * case IEEE80211_MACCMD_FLUSH:
1543 * acl->iac_flush(vap);
1544 * // NB: silently ignore when not in use
1546 * case IEEE80211_MACCMD_DETACH:
1547 * if (acl != NULL) {
1548 * vap->iv_acl = NULL;
1549 * acl->iac_detach(vap);
1554 * case IEEE80211_PARAM_WMM:
1555 * if (ic->ic_caps & IEEE80211_C_WME){
1557 * vap->iv_flags |= IEEE80211_F_WME;
1558 * *//* XXX needed by ic_reset *//*
1559 * vap->iv_ic->ic_flags |= IEEE80211_F_WME;
1562 * *//* XXX needed by ic_reset *//*
1563 * vap->iv_flags &= ~IEEE80211_F_WME;
1564 * vap->iv_ic->ic_flags &= ~IEEE80211_F_WME;
1566 * retv = ENETRESET; // Renegotiate for capabilities
1569 * case IEEE80211_PARAM_HIDESSID:
1571 * vap->iv_flags |= IEEE80211_F_HIDESSID;
1573 * vap->iv_flags &= ~IEEE80211_F_HIDESSID;
1576 * case IEEE80211_PARAM_APBRIDGE:
1578 * vap->iv_flags |= IEEE80211_F_NOBRIDGE;
1580 * vap->iv_flags &= ~IEEE80211_F_NOBRIDGE;
1582 * case IEEE80211_PARAM_INACT:
1583 * vap->iv_inact_run = value / IEEE80211_INACT_WAIT;
1585 * case IEEE80211_PARAM_INACT_AUTH:
1586 * vap->iv_inact_auth = value / IEEE80211_INACT_WAIT;
1588 * case IEEE80211_PARAM_INACT_INIT:
1589 * vap->iv_inact_init = value / IEEE80211_INACT_WAIT;
1591 * case IEEE80211_PARAM_ABOLT:
1594 * // Map abolt settings to capability bits;
1595 * // this also strips unknown/unwanted bits.
1597 * if (value & IEEE80211_ABOLT_TURBO_PRIME)
1598 * caps |= IEEE80211_ATHC_TURBOP;
1599 * if (value & IEEE80211_ABOLT_COMPRESSION)
1600 * caps |= IEEE80211_ATHC_COMP;
1601 * if (value & IEEE80211_ABOLT_FAST_FRAME)
1602 * caps |= IEEE80211_ATHC_FF;
1603 * if (value & IEEE80211_ABOLT_XR)
1604 * caps |= IEEE80211_ATHC_XR;
1605 * if (value & IEEE80211_ABOLT_AR)
1606 * caps |= IEEE80211_ATHC_AR;
1607 * if (value & IEEE80211_ABOLT_BURST)
1608 * caps |= IEEE80211_ATHC_BURST;
1609 * if (value & IEEE80211_ABOLT_WME_ELE)
1610 * caps |= IEEE80211_ATHC_WME;
1611 * // verify requested capabilities are supported
1612 * if ((caps & ic->ic_ath_cap) != caps)
1614 * if (vap->iv_ath_cap != caps) {
1615 * if ((vap->iv_ath_cap ^ caps) & IEEE80211_ATHC_TURBOP) {
1616 * if (ieee80211_set_turbo(dev,
1617 * caps & IEEE80211_ATHC_TURBOP))
1619 * ieee80211_scan_flush(ic);
1621 * vap->iv_ath_cap = caps;
1622 * ic->ic_athcapsetup(vap->iv_ic, vap->iv_ath_cap);
1626 * case IEEE80211_PARAM_DTIM_PERIOD:
1627 * if (vap->iv_opmode != IEEE80211_M_HOSTAP &&
1628 * vap->iv_opmode != IEEE80211_M_IBSS)
1630 * if (IEEE80211_DTIM_MIN <= value &&
1631 * value <= IEEE80211_DTIM_MAX) {
1632 * vap->iv_dtim_period = value;
1633 * retv = ENETRESET; // requires restart
1637 * case IEEE80211_PARAM_BEACON_INTERVAL:
1638 * if (vap->iv_opmode != IEEE80211_M_HOSTAP &&
1639 * vap->iv_opmode != IEEE80211_M_IBSS)
1641 * if (IEEE80211_BINTVAL_MIN <= value &&
1642 * value <= IEEE80211_BINTVAL_MAX) {
1643 * ic->ic_lintval = value; // XXX multi-bss
1644 * retv = ENETRESET; // requires restart
1648 * case IEEE80211_PARAM_DOTH:
1650 * ic->ic_flags |= IEEE80211_F_DOTH;
1653 * ic->ic_flags &= ~IEEE80211_F_DOTH;
1654 * retv = ENETRESET; // XXX: need something this drastic?
1656 * case IEEE80211_PARAM_PWRTARGET:
1657 * ic->ic_curchanmaxpwr = value;
1659 * case IEEE80211_PARAM_GENREASSOC:
1660 * IEEE80211_SEND_MGMT(vap->iv_bss,
1661 * IEEE80211_FC0_SUBTYPE_REASSOC_REQ, 0);
1663 * case IEEE80211_PARAM_COMPRESSION:
1664 * retv = ieee80211_setathcap(vap, IEEE80211_ATHC_COMP, value);
1666 * case IEEE80211_PARAM_WMM_AGGRMODE:
1667 * retv = ieee80211_setathcap(vap, IEEE80211_ATHC_WME, value);
1669 * case IEEE80211_PARAM_FF:
1670 * retv = ieee80211_setathcap(vap, IEEE80211_ATHC_FF, value);
1672 * case IEEE80211_PARAM_TURBO:
1673 * retv = ieee80211_setathcap(vap, IEEE80211_ATHC_TURBOP, value);
1674 * if (retv == ENETRESET) {
1675 * if(ieee80211_set_turbo(dev,value))
1677 * ieee80211_scan_flush(ic);
1680 * case IEEE80211_PARAM_XR:
1681 * retv = ieee80211_setathcap(vap, IEEE80211_ATHC_XR, value);
1683 * case IEEE80211_PARAM_BURST:
1684 * retv = ieee80211_setathcap(vap, IEEE80211_ATHC_BURST, value);
1686 * case IEEE80211_PARAM_AR:
1687 * retv = ieee80211_setathcap(vap, IEEE80211_ATHC_AR, value);
1689 * case IEEE80211_PARAM_PUREG:
1691 * vap->iv_flags |= IEEE80211_F_PUREG;
1693 * vap->iv_flags &= ~IEEE80211_F_PUREG;
1694 * // NB: reset only if we're operating on an 11g channel
1695 * if (ic->ic_bsschan != IEEE80211_CHAN_ANYC &&
1696 * IEEE80211_IS_CHAN_ANYG(ic->ic_bsschan))
1699 * case IEEE80211_PARAM_WDS:
1701 * vap->iv_flags_ext |= IEEE80211_FEXT_WDS;
1703 * vap->iv_flags_ext &= ~IEEE80211_FEXT_WDS;
1705 * case IEEE80211_PARAM_BGSCAN:
1707 * if ((vap->iv_caps & IEEE80211_C_BGSCAN) == 0)
1709 * vap->iv_flags |= IEEE80211_F_BGSCAN;
1712 * vap->iv_flags &= ~IEEE80211_F_BGSCAN;
1713 * ieee80211_cancel_scan(vap); // anything current
1716 * case IEEE80211_PARAM_BGSCAN_IDLE:
1717 * if (value >= IEEE80211_BGSCAN_IDLE_MIN)
1718 * vap->iv_bgscanidle = value*HZ/1000;
1722 * case IEEE80211_PARAM_BGSCAN_INTERVAL:
1723 * if (value >= IEEE80211_BGSCAN_INTVAL_MIN)
1724 * vap->iv_bgscanintvl = value*HZ;
1728 * case IEEE80211_PARAM_MCAST_RATE:
1729 * // units are in KILObits per second
1730 * if (value >= 256 && value <= 54000)
1731 * vap->iv_mcast_rate = value;
1735 * case IEEE80211_PARAM_COVERAGE_CLASS:
1736 * if (value >= 0 && value <= IEEE80211_COVERAGE_CLASS_MAX) {
1737 * ic->ic_coverageclass = value;
1738 * if (IS_UP_AUTO(vap))
1739 * ieee80211_new_state(vap, IEEE80211_S_SCAN, 0);
1745 * case IEEE80211_PARAM_COUNTRY_IE:
1747 * ic->ic_flags_ext |= IEEE80211_FEXT_COUNTRYIE;
1749 * ic->ic_flags_ext &= ~IEEE80211_FEXT_COUNTRYIE;
1752 * case IEEE80211_PARAM_REGCLASS:
1754 * ic->ic_flags_ext |= IEEE80211_FEXT_REGCLASS;
1756 * ic->ic_flags_ext &= ~IEEE80211_FEXT_REGCLASS;
1759 * case IEEE80211_PARAM_SCANVALID:
1760 * vap->iv_scanvalid = value*HZ;
1762 * case IEEE80211_PARAM_ROAM_RSSI_11A:
1763 * vap->iv_roam.rssi11a = value;
1765 * case IEEE80211_PARAM_ROAM_RSSI_11B:
1766 * vap->iv_roam.rssi11bOnly = value;
1768 * case IEEE80211_PARAM_ROAM_RSSI_11G:
1769 * vap->iv_roam.rssi11b = value;
1771 * case IEEE80211_PARAM_ROAM_RATE_11A:
1772 * vap->iv_roam.rate11a = value;
1774 * case IEEE80211_PARAM_ROAM_RATE_11B:
1775 * vap->iv_roam.rate11bOnly = value;
1777 * case IEEE80211_PARAM_ROAM_RATE_11G:
1778 * vap->iv_roam.rate11b = value;
1780 * case IEEE80211_PARAM_UAPSDINFO:
1781 * if (vap->iv_opmode == IEEE80211_M_HOSTAP) {
1782 * if (ic->ic_caps & IEEE80211_C_UAPSD) {
1784 * IEEE80211_VAP_UAPSD_ENABLE(vap);
1786 * IEEE80211_VAP_UAPSD_DISABLE(vap);
1790 * else if (vap->iv_opmode == IEEE80211_M_STA) {
1791 * vap->iv_uapsdinfo = value;
1792 * IEEE80211_VAP_UAPSD_ENABLE(vap);
1796 * case IEEE80211_PARAM_SLEEP:
1797 * // XXX: Forced sleep for testing. Does not actually place the
1798 * // HW in sleep mode yet. this only makes sense for STAs.
1802 * IEEE80211_VAP_GOTOSLEEP(vap);
1806 * IEEE80211_VAP_WAKEUP(vap);
1808 * ieee80211_send_nulldata(ieee80211_ref_node(vap->iv_bss));
1810 * case IEEE80211_PARAM_QOSNULL:
1811 * // Force a QoS Null for testing.
1812 * ieee80211_send_qosnulldata(vap->iv_bss, value);
1814 * case IEEE80211_PARAM_PSPOLL:
1815 * // Force a PS-POLL for testing.
1816 * ieee80211_send_pspoll(vap->iv_bss);
1818 * case IEEE80211_PARAM_EOSPDROP:
1819 * if (vap->iv_opmode == IEEE80211_M_HOSTAP) {
1820 * if (value) IEEE80211_VAP_EOSPDROP_ENABLE(vap);
1821 * else IEEE80211_VAP_EOSPDROP_DISABLE(vap);
1824 * case IEEE80211_PARAM_MARKDFS:
1826 * ic->ic_flags_ext |= IEEE80211_FEXT_MARKDFS;
1828 * ic->ic_flags_ext &= ~IEEE80211_FEXT_MARKDFS;
1830 * case IEEE80211_PARAM_CHANBW:
1833 * ic->ic_chanbwflag = 0;
1836 * ic->ic_chanbwflag = IEEE80211_CHAN_HALF;
1839 * ic->ic_chanbwflag = IEEE80211_CHAN_QUARTER;
1846 * case IEEE80211_PARAM_SHORTPREAMBLE:
1848 * ic->ic_caps |= IEEE80211_C_SHPREAMBLE;
1850 * ic->ic_caps &= ~IEEE80211_C_SHPREAMBLE;
1855 * retv = EOPNOTSUPP;
1858 * // XXX should any of these cause a rescan?
1859 * if (retv == ENETRESET)
1860 * retv = IS_UP_AUTO(vap) ? ieee80211_open(vap->iv_dev) : 0;
1865 int usbdrvwext_setmode(struct net_device
*dev
, struct iw_request_info
*info
,
1866 void *w
, char *extra
)
1871 int usbdrvwext_getmode(struct net_device
*dev
, struct iw_request_info
*info
,
1872 void *w
, char *extra
)
1874 /* struct usbdrv_private *macp = dev->ml_priv; */
1875 struct iw_point
*wri
= (struct iw_point
*)extra
;
1878 strcpy(mode
, "11g");
1879 return copy_to_user(wri
->pointer
, mode
, 6) ? -EFAULT
: 0;
1882 int zfLnxPrivateIoctl(struct net_device
*dev
, struct zdap_ioctl
* zdreq
)
1884 /* void* regp = macp->regp; */
1892 case ZM_IOCTL_REG_READ
:
1893 zfiDbgReadReg(dev
, zdreq
->addr
);
1895 case ZM_IOCTL_REG_WRITE
:
1896 zfiDbgWriteReg(dev
, zdreq
->addr
, zdreq
->value
);
1898 case ZM_IOCTL_MEM_READ
:
1899 p
= (u32_t
*) bus_to_virt(zdreq
->addr
);
1901 "usbdrv: read memory addr: 0x%08x value:"
1902 " 0x%08x\n", zdreq
->addr
, *p
);
1904 case ZM_IOCTL_MEM_WRITE
:
1905 p
= (u32_t
*) bus_to_virt(zdreq
->addr
);
1908 "usbdrv : write value : 0x%08x to memory addr :"
1909 " 0x%08x\n", zdreq
->value
, zdreq
->addr
);
1911 case ZM_IOCTL_TALLY
:
1912 zfiWlanShowTally(dev
);
1914 zfiWlanResetTally(dev
);
1918 "ZM_IOCTL_TEST:len=%d\n", zdreq
->addr
);
1919 /* zfiWlanReadReg(dev, 0x10f400); */
1920 /* zfiWlanReadReg(dev, 0x10f404); */
1921 printk(KERN_WARNING
"IOCTL TEST\n");
1924 for (i
= 0; i
< zdreq
->addr
; i
++) {
1926 printk(KERN_WARNING
"\n");
1927 printk(KERN_WARNING
"%02X ",
1928 (unsigned char)zdreq
->data
[i
]);
1930 printk(KERN_WARNING
"\n");
1933 /* For Test?? 1 to 0 by CWYang(-) */
1937 /* Allocate a skb */
1938 s
= alloc_skb(2000, GFP_ATOMIC
);
1940 /* Copy data to skb */
1941 for (i
= 0; i
< zdreq
->addr
; i
++)
1942 s
->data
[i
] = zdreq
->data
[i
];
1943 s
->len
= zdreq
->addr
;
1945 /* Call zfIdlRecv() */
1946 zfiRecv80211(dev
, s
, NULL
);
1949 /************************* ZDCONFIG ***************************/
1951 zfiWlanSetFragThreshold(dev
, zdreq
->addr
);
1954 zfiWlanSetRtsThreshold(dev
, zdreq
->addr
);
1959 case ZM_IOCTL_KEY
: {
1961 struct zsKeyInfo keyInfo
;
1964 for (i
= 0; i
< 29; i
++)
1967 for (i
= 0; i
< zdreq
->addr
; i
++)
1968 key
[i
] = zdreq
->data
[i
];
1971 "key len=%d, key=%02x%02x%02x%02x%02x...\n",
1972 zdreq
->addr
, key
[0], key
[1], key
[2], key
[3], key
[4]);
1974 keyInfo
.keyLength
= zdreq
->addr
;
1975 keyInfo
.keyIndex
= 0;
1978 zfiWlanSetKey(dev
, keyInfo
);
1982 zfiWlanSetTxRate(dev
, zdreq
->addr
);
1984 case ZM_IOCTL_ENCRYPTION_MODE
:
1985 zfiWlanSetEncryMode(dev
, zdreq
->addr
);
1987 zfiWlanDisable(dev
, 0);
1991 case ZM_IOCTL_SIGNAL_STRENGTH
: {
1993 zfiWlanQuerySignalInfo(dev
, &buffer
[0]);
1995 "Current Signal Strength : %02d\n", buffer
[0]);
1999 case ZM_IOCTL_SIGNAL_QUALITY
: {
2001 zfiWlanQuerySignalInfo(dev
, &buffer
[0]);
2003 "Current Signal Quality : %02d\n", buffer
[1]);
2006 case ZM_IOCTL_SET_PIBSS_MODE
:
2007 if (zdreq
->addr
== 1)
2008 zfiWlanSetWlanMode(dev
, ZM_MODE_PSEUDO
);
2010 zfiWlanSetWlanMode(dev
, ZM_MODE_INFRASTRUCTURE
);
2012 zfiWlanDisable(dev
, 0);
2015 /********************* ZDCONFIG ***********************/
2017 printk(KERN_ERR
"usbdrv: error command = %x\n", cmd
);
2024 int usbdrv_wpa_ioctl(struct net_device
*dev
, struct athr_wlan_param
*zdparm
)
2027 u8_t bc_addr
[6] = { 0xff, 0xff, 0xff, 0xff, 0xff, 0xff };
2029 struct zsKeyInfo keyInfo
;
2030 struct usbdrv_private
*macp
= dev
->ml_priv
;
2034 /* zmw_get_wlan_dev(dev); */
2036 switch (zdparm
->cmd
) {
2037 case ZD_CMD_SET_ENCRYPT_KEY
:
2038 /* Set up key information */
2039 keyInfo
.keyLength
= zdparm
->u
.crypt
.key_len
;
2040 keyInfo
.keyIndex
= zdparm
->u
.crypt
.idx
;
2041 if (zfiWlanQueryWlanMode(dev
) == ZM_MODE_AP
) {
2043 keyInfo
.flag
= ZM_KEY_FLAG_AUTHENTICATOR
;
2046 keyInfo
.key
= zdparm
->u
.crypt
.key
;
2047 keyInfo
.initIv
= zdparm
->u
.crypt
.seq
;
2048 keyInfo
.macAddr
= (u16_t
*)zdparm
->sta_addr
;
2050 /* Identify the MAC address information */
2051 if (memcmp(zdparm
->sta_addr
, bc_addr
, sizeof(bc_addr
)) == 0)
2052 keyInfo
.flag
|= ZM_KEY_FLAG_GK
;
2054 keyInfo
.flag
|= ZM_KEY_FLAG_PK
;
2056 if (!strcmp(zdparm
->u
.crypt
.alg
, "NONE")) {
2057 /* u8_t zero_mac[]={0,0,0,0,0,0}; */
2059 /* Set key length to zero */
2060 keyInfo
.keyLength
= 0;
2063 if (zdparm
->sta_addr
[0] & 1) {
2064 /* if (macp->cardSetting.WPAIeLen==0)
2065 * { 802.1x dynamic WEP
2067 * mKeyFormat[0] = 0;
2068 * mPrivacyInvoked[0]=FALSE;
2069 * mCap[0] &= ~CAP_PRIVACY;
2070 * macp->cardSetting.EncryOnOff[0]=0;
2072 * mWpaBcKeyLen = mGkInstalled = 0;
2075 /* if (memcmp(zero_mac,zdparm->sta_addr, 6)==0)
2079 * pSetting->DynKeyMode=0;
2080 * pSetting->EncryMode[0]=0;
2086 printk(KERN_ERR
"Set Encryption Type NONE\n");
2088 } else if (!strcmp(zdparm
->u
.crypt
.alg
, "TKIP")) {
2089 zfiWlanSetEncryMode(dev
, ZM_TKIP
);
2090 /* //Linux Supplicant will inverse Tx/Rx key
2091 * //So we inverse it back, CWYang(+)
2092 * zfMemoryCopy(&temp[0], &keyInfo.key[16], 8);
2093 * zfMemoryCopy(&keyInfo.key[16], keyInfo.key[24], 8);
2094 * zfMemoryCopy(&keyInfo.key[24], &temp[0], 8);
2097 * for (k = 0; k < 8; k++)
2099 * temp = keyInfo.key[16 + k];
2100 * keyInfo.key[16 + k] = keyInfo.key[24 + k];
2101 * keyInfo.key[24 + k] = temp;
2103 * CamEncryType = ZM_TKIP;
2106 * mKeyFormat[0] = CamEncryType;
2107 * mDynKeyMode = pSetting->DynKeyMode = DYN_KEY_TKIP;
2110 } else if (!strcmp(zdparm
->u
.crypt
.alg
, "CCMP")) {
2111 zfiWlanSetEncryMode(dev
, ZM_AES
);
2112 /* CamEncryType = ZM_AES;
2115 * mKeyFormat[0] = CamEncryType;
2116 * mDynKeyMode = pSetting->DynKeyMode = DYN_KEY_AES;
2119 } else if (!strcmp(zdparm
->u
.crypt
.alg
, "WEP")) {
2120 if (keyInfo
.keyLength
== 5) {
2122 zfiWlanSetEncryMode(dev
, ZM_WEP64
);
2123 /* CamEncryType = ZM_WEP64; */
2124 /* tmpDynKeyMode=DYN_KEY_WEP64; */
2125 } else if (keyInfo
.keyLength
== 13) {
2126 /* keylen=13, WEP 128 */
2127 zfiWlanSetEncryMode(dev
, ZM_WEP128
);
2128 /* CamEncryType = ZM_WEP128; */
2129 /* tmpDynKeyMode=DYN_KEY_WEP128; */
2131 zfiWlanSetEncryMode(dev
, ZM_WEP256
);
2134 /* For Dynamic WEP key (Non-WPA Radius), the key ID range: 0-3
2135 * In WPA/RSN mode, the key ID range: 1-3, usually, a broadcast key.
2136 * For WEP key setting: we set mDynKeyMode and mKeyFormat in following
2138 * 1. For 802.1x dynamically generated WEP key method.
2139 * 2. For WPA/RSN mode, but key id == 0.
2140 * (But this is an impossible case)
2141 * So, only check case 1.
2142 * if (macp->cardSetting.WPAIeLen==0)
2144 * mKeyFormat[0] = CamEncryType;
2145 * mDynKeyMode = pSetting->DynKeyMode = tmpDynKeyMode;
2146 * mPrivacyInvoked[0]=TRUE;
2147 * mCap[0] |= CAP_PRIVACY;
2148 * macp->cardSetting.EncryOnOff[0]=1;
2153 /* DUMP key context */
2154 /* #ifdef WPA_DEBUG */
2155 if (keyInfo
.keyLength
> 0) {
2157 "Otus: Key Context:\n");
2158 for (ii
= 0; ii
< keyInfo
.keyLength
; ) {
2160 "0x%02x ", keyInfo
.key
[ii
]);
2161 if ((++ii
% 16) == 0)
2162 printk(KERN_WARNING
"\n");
2164 printk(KERN_WARNING
"\n");
2168 /* Set encrypt mode */
2169 /* zfiWlanSetEncryMode(dev, CamEncryType); */
2170 vapId
= zfLnxGetVapId(dev
);
2171 if (vapId
== 0xffff)
2174 keyInfo
.vapId
= vapId
+ 1;
2175 keyInfo
.vapAddr
[0] = keyInfo
.macAddr
[0];
2176 keyInfo
.vapAddr
[1] = keyInfo
.macAddr
[1];
2177 keyInfo
.vapAddr
[2] = keyInfo
.macAddr
[2];
2179 zfiWlanSetKey(dev
, keyInfo
);
2181 /* zfiWlanDisable(dev); */
2182 /* zfiWlanEnable(dev); */
2184 case ZD_CMD_SET_MLME
:
2185 printk(KERN_ERR
"usbdrv_wpa_ioctl: ZD_CMD_SET_MLME\n");
2187 /* Translate STA's address */
2188 sprintf(mac_addr
, "%02x:%02x:%02x:%02x:%02x:%02x",
2189 zdparm
->sta_addr
[0], zdparm
->sta_addr
[1],
2190 zdparm
->sta_addr
[2], zdparm
->sta_addr
[3],
2191 zdparm
->sta_addr
[4], zdparm
->sta_addr
[5]);
2193 switch (zdparm
->u
.mlme
.cmd
) {
2194 case MLME_STA_DEAUTH
:
2196 " -------Call zfiWlanDeauth, reason:%d\n",
2197 zdparm
->u
.mlme
.reason_code
);
2198 if (zfiWlanDeauth(dev
, (u16_t
*) zdparm
->sta_addr
,
2199 zdparm
->u
.mlme
.reason_code
) != 0)
2200 printk(KERN_ERR
"Can't deauthencate STA: %s\n",
2203 printk(KERN_ERR
"Deauthenticate STA: %s"
2204 "with reason code: %d\n",
2205 mac_addr
, zdparm
->u
.mlme
.reason_code
);
2207 case MLME_STA_DISASSOC
:
2209 " -------Call zfiWlanDeauth, reason:%d\n",
2210 zdparm
->u
.mlme
.reason_code
);
2211 if (zfiWlanDeauth(dev
, (u16_t
*) zdparm
->sta_addr
,
2212 zdparm
->u
.mlme
.reason_code
) != 0)
2213 printk(KERN_ERR
"Can't disassociate STA: %s\n",
2216 printk(KERN_ERR
"Disassociate STA: %s"
2217 "with reason code: %d\n",
2218 mac_addr
, zdparm
->u
.mlme
.reason_code
);
2221 printk(KERN_ERR
"MLME command: 0x%04x not support\n",
2222 zdparm
->u
.mlme
.cmd
);
2227 case ZD_CMD_SCAN_REQ
:
2228 printk(KERN_ERR
"usbdrv_wpa_ioctl: ZD_CMD_SCAN_REQ\n");
2230 case ZD_CMD_SET_GENERIC_ELEMENT
:
2231 printk(KERN_ERR
"usbdrv_wpa_ioctl:"
2232 " ZD_CMD_SET_GENERIC_ELEMENT\n");
2235 * zm_msg1_mm(ZM_LV_0, "CWY - wpaie Length : ",
2236 * zdparm->u.generic_elem.len);
2238 printk(KERN_ERR
"wpaie Length : % d\n",
2239 zdparm
->u
.generic_elem
.len
);
2240 if (zfiWlanQueryWlanMode(dev
) == ZM_MODE_AP
) {
2242 zfiWlanSetWpaIe(dev
, zdparm
->u
.generic_elem
.data
,
2243 zdparm
->u
.generic_elem
.len
);
2245 macp
->supLen
= zdparm
->u
.generic_elem
.len
;
2246 memcpy(macp
->supIe
, zdparm
->u
.generic_elem
.data
,
2247 zdparm
->u
.generic_elem
.len
);
2249 zfiWlanSetWpaSupport(dev
, 1);
2250 /* zfiWlanSetWpaIe(dev, zdparm->u.generic_elem.data,
2251 * zdparm->u.generic_elem.len);
2253 u8_t len
= zdparm
->u
.generic_elem
.len
;
2254 u8_t
*wpaie
= (u8_t
*)zdparm
->u
.generic_elem
.data
;
2256 printk(KERN_ERR
"wd->ap.wpaLen : % d\n", len
);
2259 for(ii
= 0; ii
< len
;) {
2260 printk(KERN_ERR
"0x%02x ", wpaie
[ii
]);
2262 if((++ii
% 16) == 0)
2263 printk(KERN_ERR
"\n");
2265 printk(KERN_ERR
"\n");
2267 /* #ifdef ZM_HOSTAPD_SUPPORT
2268 * if (wd->wlanMode == ZM_MODE_AP)
2269 * {// Update Beacon FIFO in the next TBTT.
2270 * memcpy(&mWPAIe, pSetting->WPAIe, pSetting->WPAIeLen);
2271 * printk(KERN_ERR "Copy WPA IE into mWPAIe\n");
2277 /* #ifdef ZM_HOSTAPD_SUPPORT */
2278 case ZD_CMD_GET_TSC
:
2279 printk(KERN_ERR
"usbdrv_wpa_ioctl : ZD_CMD_GET_TSC\n");
2284 printk(KERN_ERR
"usbdrv_wpa_ioctl default : 0x%04x\n",
2293 #ifdef ZM_ENABLE_CENC
2294 int usbdrv_cenc_ioctl(struct net_device
*dev
, struct zydas_cenc_param
*zdparm
)
2296 /* struct usbdrv_private *macp = dev->ml_priv; */
2297 struct zsKeyInfo keyInfo
;
2299 u8_t bc_addr
[6] = { 0xff, 0xff, 0xff, 0xff, 0xff, 0xff };
2304 apId
= zfLnxGetVapId(dev
);
2306 if (apId
== 0xffff) {
2312 switch (zdparm
->cmd
) {
2313 case ZM_CMD_CENC_SETCENC
:
2314 printk(KERN_ERR
"ZM_CMD_CENC_SETCENC\n");
2315 printk(KERN_ERR
"length : % d\n", zdparm
->len
);
2316 printk(KERN_ERR
"policy : % d\n", zdparm
->u
.info
.cenc_policy
);
2318 case ZM_CMD_CENC_SETKEY
:
2319 /* ret = wai_ioctl_setkey(vap, ioctl_msg); */
2320 printk(KERN_ERR
"ZM_CMD_CENC_SETKEY\n");
2322 printk(KERN_ERR
"MAC address = ");
2323 for (ii
= 0; ii
< 6; ii
++) {
2324 printk(KERN_ERR
"0x%02x ",
2325 zdparm
->u
.crypt
.sta_addr
[ii
]);
2327 printk(KERN_ERR
"\n");
2329 printk(KERN_ERR
"Key Index : % d\n", zdparm
->u
.crypt
.keyid
);
2330 printk(KERN_ERR
"Encryption key = ");
2331 for (ii
= 0; ii
< 16; ii
++) {
2332 printk(KERN_ERR
"0x%02x ", zdparm
->u
.crypt
.key
[ii
]);
2334 printk(KERN_ERR
"\n");
2336 printk(KERN_ERR
"MIC key = ");
2337 for(ii
= 16; ii
< ZM_CENC_KEY_SIZE
; ii
++) {
2338 printk(KERN_ERR
"0x%02x ", zdparm
->u
.crypt
.key
[ii
]);
2340 printk(KERN_ERR
"\n");
2342 /* Set up key information */
2343 keyInfo
.keyLength
= ZM_CENC_KEY_SIZE
;
2344 keyInfo
.keyIndex
= zdparm
->u
.crypt
.keyid
;
2345 keyInfo
.flag
= ZM_KEY_FLAG_AUTHENTICATOR
| ZM_KEY_FLAG_CENC
;
2346 keyInfo
.key
= zdparm
->u
.crypt
.key
;
2347 keyInfo
.macAddr
= (u16_t
*)zdparm
->u
.crypt
.sta_addr
;
2349 /* Identify the MAC address information */
2350 if (memcmp(zdparm
->u
.crypt
.sta_addr
, bc_addr
,
2351 sizeof(bc_addr
)) == 0) {
2352 keyInfo
.flag
|= ZM_KEY_FLAG_GK
;
2353 keyInfo
.vapId
= apId
;
2354 memcpy(keyInfo
.vapAddr
, dev
->dev_addr
, ETH_ALEN
);
2356 keyInfo
.flag
|= ZM_KEY_FLAG_PK
;
2359 zfiWlanSetKey(dev
, keyInfo
);
2362 case ZM_CMD_CENC_REKEY
:
2363 /* ret = wai_ioctl_rekey(vap, ioctl_msg); */
2364 printk(KERN_ERR
"ZM_CMD_CENC_REKEY\n");
2371 /* if (retv == ENETRESET) */
2372 /* retv = IS_UP_AUTO(vap) ? ieee80211_open(vap->iv_dev) : 0; */
2376 #endif /* ZM_ENABLE_CENC */
2378 int usbdrv_ioctl(struct net_device
*dev
, struct ifreq
*ifr
, int cmd
)
2380 /* struct usbdrv_private *macp; */
2382 struct zdap_ioctl zdreq
;
2383 struct iwreq
*wrq
= (struct iwreq
*)ifr
;
2384 struct athr_wlan_param zdparm
;
2385 struct usbdrv_private
*macp
= dev
->ml_priv
;
2387 int err
= 0, val
= 0;
2390 /* regp = macp->regp; */
2392 if (!netif_running(dev
))
2397 strcpy(wrq
->u
.name
, "IEEE 802.11-DS");
2400 err
= usbdrvwext_giwap(dev
, NULL
, &wrq
->u
.ap_addr
, NULL
);
2403 err
= usbdrvwext_siwap(dev
, NULL
, &wrq
->u
.ap_addr
, NULL
);
2406 err
= usbdrvwext_giwmode(dev
, NULL
, &wrq
->u
.mode
, NULL
);
2409 printk(KERN_ERR
"CWY - usbdrvwext_siwessid\n");
2410 /* err = usbdrv_ioctl_setessid(dev, &wrq->u.essid); */
2411 err
= usbdrvwext_siwessid(dev
, NULL
, &wrq
->u
.essid
, NULL
);
2417 err
= usbdrvwext_giwessid(dev
, NULL
, &wrq
->u
.essid
, NULL
);
2420 err
= usbdrv_ioctl_setrts(dev
, &wrq
->u
.rts
);
2425 case SIOCIWFIRSTPRIV
+ 0x2: {
2426 /* printk("CWY - SIOCIWFIRSTPRIV + 0x2(set_auth)\n"); */
2427 if (!capable(CAP_NET_ADMIN
)) {
2431 val
= *((int *) wrq
->u
.name
);
2432 if ((val
< 0) || (val
> 2)) {
2436 zfiWlanSetAuthenticationMode(dev
, val
);
2438 if (macp
->DeviceOpened
== 1) {
2439 zfiWlanDisable(dev
, 0);
2449 case SIOCIWFIRSTPRIV
+ 0x3: {
2450 int AuthMode
= ZM_AUTH_MODE_OPEN
;
2452 /* printk("CWY - SIOCIWFIRSTPRIV + 0x3(get_auth)\n"); */
2454 if (wrq
->u
.data
.pointer
) {
2455 wrq
->u
.data
.flags
= 1;
2457 AuthMode
= zfiWlanQueryAuthenticationMode(dev
, 0);
2458 if (AuthMode
== ZM_AUTH_MODE_OPEN
) {
2459 wrq
->u
.data
.length
= 12;
2461 if (copy_to_user(wrq
->u
.data
.pointer
,
2462 "open system", 12)) {
2465 } else if (AuthMode
== ZM_AUTH_MODE_SHARED_KEY
) {
2466 wrq
->u
.data
.length
= 11;
2468 if (copy_to_user(wrq
->u
.data
.pointer
,
2469 "shared key", 11)) {
2472 } else if (AuthMode
== ZM_AUTH_MODE_AUTO
) {
2473 wrq
->u
.data
.length
= 10;
2475 if (copy_to_user(wrq
->u
.data
.pointer
,
2487 if (copy_from_user(&zdreq
, ifr
->ifr_data
, sizeof(zdreq
))) {
2488 printk(KERN_ERR
"usbdrv : copy_from_user error\n");
2492 /* printk(KERN_WARNING
2493 * "usbdrv : cmd = % 2x, reg = 0x%04lx,
2494 *value = 0x%08lx\n",
2495 * zdreq.cmd, zdreq.addr, zdreq.value);
2497 zfLnxPrivateIoctl(dev
, &zdreq
);
2502 if (copy_from_user(&zdparm
, ifr
->ifr_data
,
2503 sizeof(struct athr_wlan_param
))) {
2504 printk(KERN_ERR
"usbdrv : copy_from_user error\n");
2508 usbdrv_wpa_ioctl(dev
, &zdparm
);
2511 case ZD_IOCTL_PARAM
: {
2516 /* Point to the name field and retrieve the
2517 * op and arg elements.
2519 p
= (int *)wrq
->u
.name
;
2523 if (op
== ZD_PARAM_ROAMING
) {
2525 "*************ZD_PARAM_ROAMING : % d\n", arg
);
2526 /* macp->cardSetting.ap_scan=(U8)arg; */
2528 if (op
== ZD_PARAM_PRIVACY
) {
2529 printk(KERN_ERR
"ZD_IOCTL_PRIVACY : ");
2531 /* Turn on the privacy invoke flag */
2533 /* mCap[0] |= CAP_PRIVACY; */
2534 /* macp->cardSetting.EncryOnOff[0] = 1; */
2535 printk(KERN_ERR
"enable\n");
2538 /* mCap[0] &= ~CAP_PRIVACY; */
2539 /* macp->cardSetting.EncryOnOff[0] = 0; */
2540 printk(KERN_ERR
"disable\n");
2544 if (op
== ZD_PARAM_WPA
) {
2546 printk(KERN_ERR
"ZD_PARAM_WPA : ");
2549 printk(KERN_ERR
"enable\n");
2551 if (zfiWlanQueryWlanMode(dev
) != ZM_MODE_AP
) {
2552 printk(KERN_ERR
"Station Mode\n");
2553 /* zfiWlanQueryWpaIe(dev, (u8_t *)
2554 &wpaIe, &wpalen); */
2555 /* printk("wpaIe : % 2x, % 2x, % 2x\n",
2556 wpaIe[21], wpaIe[22], wpaIe[23]); */
2557 /* printk("rsnIe : % 2x, % 2x, % 2x\n",
2558 wpaIe[17], wpaIe[18], wpaIe[19]); */
2559 if ((macp
->supIe
[21] == 0x50) &&
2560 (macp
->supIe
[22] == 0xf2) &&
2561 (macp
->supIe
[23] == 0x2)) {
2563 "wd->sta.authMode = ZM_AUTH_MODE_WPAPSK\n");
2564 /* wd->sta.authMode = ZM_AUTH_MODE_WPAPSK; */
2565 /* wd->ws.authMode = ZM_AUTH_MODE_WPAPSK; */
2566 zfiWlanSetAuthenticationMode(dev
,
2567 ZM_AUTH_MODE_WPAPSK
);
2568 } else if ((macp
->supIe
[21] == 0x50) &&
2569 (macp
->supIe
[22] == 0xf2) &&
2570 (macp
->supIe
[23] == 0x1)) {
2572 "wd->sta.authMode = ZM_AUTH_MODE_WPA\n");
2573 /* wd->sta.authMode = ZM_AUTH_MODE_WPA; */
2574 /* wd->ws.authMode = ZM_AUTH_MODE_WPA; */
2575 zfiWlanSetAuthenticationMode(dev
,
2577 } else if ((macp
->supIe
[17] == 0xf) &&
2578 (macp
->supIe
[18] == 0xac) &&
2579 (macp
->supIe
[19] == 0x2))
2582 "wd->sta.authMode = ZM_AUTH_MODE_WPA2PSK\n");
2583 /* wd->sta.authMode = ZM_AUTH_MODE_WPA2PSK; */
2584 /* wd->ws.authMode = ZM_AUTH_MODE_WPA2PSK; */
2585 zfiWlanSetAuthenticationMode(dev
,
2586 ZM_AUTH_MODE_WPA2PSK
);
2587 } else if ((macp
->supIe
[17] == 0xf) &&
2588 (macp
->supIe
[18] == 0xac) &&
2589 (macp
->supIe
[19] == 0x1))
2592 "wd->sta.authMode = ZM_AUTH_MODE_WPA2\n");
2593 /* wd->sta.authMode = ZM_AUTH_MODE_WPA2; */
2594 /* wd->ws.authMode = ZM_AUTH_MODE_WPA2; */
2595 zfiWlanSetAuthenticationMode(dev
,
2599 if ((macp
->supIe
[21] == 0x50) ||
2600 (macp
->supIe
[22] == 0xf2)) {
2601 if (macp
->supIe
[11] == 0x2) {
2603 "wd->sta.wepStatus = ZM_ENCRYPTION_TKIP\n");
2604 /* wd->sta.wepStatus = ZM_ENCRYPTION_TKIP; */
2605 /* wd->ws.wepStatus = ZM_ENCRYPTION_TKIP; */
2606 zfiWlanSetWepStatus(dev
, ZM_ENCRYPTION_TKIP
);
2609 "wd->sta.wepStatus = ZM_ENCRYPTION_AES\n");
2610 /* wd->sta.wepStatus = ZM_ENCRYPTION_AES; */
2611 /* wd->ws.wepStatus = ZM_ENCRYPTION_AES; */
2612 zfiWlanSetWepStatus(dev
, ZM_ENCRYPTION_AES
);
2616 if ((macp
->supIe
[17] == 0xf) ||
2617 (macp
->supIe
[18] == 0xac)) {
2618 if (macp
->supIe
[13] == 0x2) {
2620 "wd->sta.wepStatus = ZM_ENCRYPTION_TKIP\n");
2621 /* wd->sta.wepStatus = ZM_ENCRYPTION_TKIP; */
2622 /* wd->ws.wepStatus = ZM_ENCRYPTION_TKIP; */
2623 zfiWlanSetWepStatus(dev
, ZM_ENCRYPTION_TKIP
);
2626 "wd->sta.wepStatus = ZM_ENCRYPTION_AES\n");
2627 /* wd->sta.wepStatus = ZM_ENCRYPTION_AES; */
2628 /* wd->ws.wepStatus = ZM_ENCRYPTION_AES; */
2629 zfiWlanSetWepStatus(dev
, ZM_ENCRYPTION_AES
);
2633 zfiWlanSetWpaSupport(dev
, 1);
2635 /* Reset the WPA related variables */
2636 printk(KERN_ERR
"disable\n");
2638 zfiWlanSetWpaSupport(dev
, 0);
2639 zfiWlanSetAuthenticationMode(dev
, ZM_AUTH_MODE_OPEN
);
2640 zfiWlanSetWepStatus(dev
, ZM_ENCRYPTION_WEP_DISABLED
);
2642 /* Now we only set the length in the WPA IE
2644 *macp->cardSetting.WPAIe[1] = 0;
2649 if (op
== ZD_PARAM_COUNTERMEASURES
) {
2651 "****************ZD_PARAM_COUNTERMEASURES : ");
2654 /* mCounterMeasureState=1; */
2655 printk(KERN_ERR
"enable\n");
2657 /* mCounterMeasureState=0; */
2658 printk(KERN_ERR
"disable\n");
2661 if (op
== ZD_PARAM_DROPUNENCRYPTED
) {
2662 printk(KERN_ERR
"ZD_PARAM_DROPUNENCRYPTED : ");
2665 printk(KERN_ERR
"enable\n");
2667 printk(KERN_ERR
"disable\n");
2670 if (op
== ZD_PARAM_AUTH_ALGS
) {
2671 printk(KERN_ERR
"ZD_PARAM_AUTH_ALGS : ");
2674 printk(KERN_ERR
"OPEN_SYSTEM\n");
2676 printk(KERN_ERR
"SHARED_KEY\n");
2679 if (op
== ZD_PARAM_WPS_FILTER
) {
2680 printk(KERN_ERR
"ZD_PARAM_WPS_FILTER : ");
2683 /* mCounterMeasureState=1; */
2684 macp
->forwardMgmt
= 1;
2685 printk(KERN_ERR
"enable\n");
2687 /* mCounterMeasureState=0; */
2688 macp
->forwardMgmt
= 0;
2689 printk(KERN_ERR
"disable\n");
2695 case ZD_IOCTL_GETWPAIE
: {
2696 struct ieee80211req_wpaie req_wpaie
;
2700 apId
= zfLnxGetVapId(dev
);
2702 if (apId
== 0xffff) {
2708 if (copy_from_user(&req_wpaie
, ifr
->ifr_data
,
2709 sizeof(struct ieee80211req_wpaie
))) {
2710 printk(KERN_ERR
"usbdrv : copy_from_user error\n");
2714 for (i
= 0; i
< ZM_OAL_MAX_STA_SUPPORT
; i
++) {
2715 for (j
= 0; j
< IEEE80211_ADDR_LEN
; j
++) {
2716 if (macp
->stawpaie
[i
].wpa_macaddr
[j
] !=
2717 req_wpaie
.wpa_macaddr
[j
])
2724 if (i
< ZM_OAL_MAX_STA_SUPPORT
) {
2725 /* printk("ZD_IOCTL_GETWPAIE - sta index = % d\n", i); */
2726 memcpy(req_wpaie
.wpa_ie
, macp
->stawpaie
[i
].wpa_ie
,
2727 IEEE80211_MAX_IE_SIZE
);
2730 if (copy_to_user(wrq
->u
.data
.pointer
, &req_wpaie
,
2731 sizeof(struct ieee80211req_wpaie
))) {
2738 #ifdef ZM_ENABLE_CENC
2740 if (copy_from_user(&macp
->zd_wpa_req
, ifr
->ifr_data
,
2741 sizeof(struct athr_wlan_param
))) {
2742 printk(KERN_ERR
"usbdrv : copy_from_user error\n");
2746 usbdrv_cenc_ioctl(dev
,
2747 (struct zydas_cenc_param
*)&macp
->zd_wpa_req
);
2750 #endif /* ZM_ENABLE_CENC */