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 <asm/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
62 #include <net/iw_handler.h>
65 extern u16_t
zfLnxGetVapId(zdev_t
* dev
);
67 static const u32_t channel_frequency_11A
[] =
69 //Even element for Channel Number, Odd for Frequency
110 int usbdrv_freq2chan(u32_t freq
)
113 if (freq
> 2400 && freq
< 3000)
115 return ((freq
-2412)/5) + 1;
120 u16_t num_chan
= sizeof(channel_frequency_11A
)/sizeof(u32_t
);
122 for(ii
= 1; ii
< num_chan
; ii
+= 2)
124 if (channel_frequency_11A
[ii
] == freq
)
125 return channel_frequency_11A
[ii
-1];
132 int usbdrv_chan2freq(int chan
)
136 /* If channel number is out of range */
137 if (chan
> 165 || chan
<= 0)
141 if (chan
>= 1 && chan
<= 13)
143 freq
= (2412 + (chan
- 1) * 5);
146 else if (chan
>= 36 && chan
<= 165)
149 u16_t num_chan
= sizeof(channel_frequency_11A
)/sizeof(u32_t
);
151 for(ii
= 0; ii
< num_chan
; ii
+= 2)
153 if (channel_frequency_11A
[ii
] == chan
)
154 return channel_frequency_11A
[ii
+1];
157 /* Can't find desired frequency */
162 /* Can't find deisred frequency */
166 int usbdrv_ioctl_setessid(struct net_device
*dev
, struct iw_point
*erq
)
168 #ifdef ZM_HOSTAPD_SUPPORT
169 //struct usbdrv_private *macp = dev->priv;
170 char essidbuf
[IW_ESSID_MAX_SIZE
+1];
173 if(!netif_running(dev
))
176 memset(essidbuf
, 0, sizeof(essidbuf
));
178 printk(KERN_ERR
"usbdrv_ioctl_setessid\n");
180 //printk("ssidlen=%d\n", erq->length); //for any, it is 1.
182 if (erq
->length
> (IW_ESSID_MAX_SIZE
+1))
185 if (copy_from_user(essidbuf
, erq
->pointer
, erq
->length
))
192 printk(KERN_ERR
"essidbuf: ");
194 for(i
= 0; i
< erq
->length
; i
++)
196 printk(KERN_ERR
"%02x ", essidbuf
[i
]);
199 printk(KERN_ERR
"\n");
201 essidbuf
[erq
->length
] = '\0';
202 //memcpy(macp->wd.ws.ssid, essidbuf, erq->length);
203 //macp->wd.ws.ssidLen = strlen(essidbuf)+2;
204 //macp->wd.ws.ssid[1] = strlen(essidbuf); // Update ssid length
206 zfiWlanSetSSID(dev
, essidbuf
, erq
->length
);
208 printk(KERN_ERR
"macp->wd.ws.ssid: ");
210 for(i
= 0; i
< macp
->wd
.ws
.ssidLen
; i
++)
212 printk(KERN_ERR
"%02x ", macp
->wd
.ws
.ssid
[i
]);
215 printk(KERN_ERR
"\n");
217 zfiWlanDisable(dev
, 0);
225 int usbdrv_ioctl_getessid(struct net_device
*dev
, struct iw_point
*erq
)
227 //struct usbdrv_private *macp = dev->priv;
228 u8_t essidbuf
[IW_ESSID_MAX_SIZE
+1];
233 //len = macp->wd.ws.ssidLen;
234 //memcpy(essidbuf, macp->wd.ws.ssid, macp->wd.ws.ssidLen);
235 zfiWlanQuerySSID(dev
, essidbuf
, &len
);
239 printk(KERN_ERR
"ESSID: ");
241 for(i
= 0; i
< len
; i
++)
243 printk(KERN_ERR
"%c", essidbuf
[i
]);
246 printk(KERN_ERR
"\n");
249 erq
->length
= strlen(essidbuf
) + 1;
252 if (copy_to_user(erq
->pointer
, essidbuf
, erq
->length
))
259 int usbdrv_ioctl_setrts(struct net_device
*dev
, struct iw_param
*rrq
)
265 #if WIRELESS_EXT > 14
267 * Encode a WPA or RSN information element as a custom
268 * element using the hostap format.
270 u32
encode_ie(void *buf
, u32 bufsize
, const u8
*ie
, u32 ielen
, const u8
*leader
, u32 leader_len
)
275 if (bufsize
< leader_len
)
278 memcpy(p
, leader
, leader_len
);
279 bufsize
-= leader_len
;
281 for (i
= 0; i
< ielen
&& bufsize
> 2; i
++)
282 p
+= sprintf(p
, "%02x", ie
[i
]);
283 return (i
== ielen
? p
- (u8
*)buf
: 0);
285 #endif /* WIRELESS_EXT > 14 */
287 /*------------------------------------------------------------------*/
289 * Translate scan data returned from the card to a card independent
290 * format that the Wireless Tools will understand
292 char *usbdrv_translate_scan(struct net_device
*dev
,
293 struct iw_request_info
*info
, char *current_ev
,
294 char *end_buf
, struct zsBssInfo
*list
)
296 struct iw_event iwe
; /* Temporary buffer */
298 char *current_val
; /* For rates */
301 #if WIRELESS_EXT > 14
305 last_ev
= current_ev
;
307 /* First entry *MUST* be the AP MAC address */
309 iwe
.u
.ap_addr
.sa_family
= ARPHRD_ETHER
;
310 memcpy(iwe
.u
.ap_addr
.sa_data
, list
->bssid
, ETH_ALEN
);
311 current_ev
= iwe_stream_add_event(
312 #if (LINUX_VERSION_CODE >= KERNEL_VERSION(2,6,27))
316 end_buf
, &iwe
, IW_EV_ADDR_LEN
);
318 /* Ran out of buffer */
319 if (last_ev
== current_ev
)
324 last_ev
= current_ev
;
326 /* Other entries will be displayed in the order we give them */
329 iwe
.u
.data
.length
= list
->ssid
[1];
330 if(iwe
.u
.data
.length
> 32)
331 iwe
.u
.data
.length
= 32;
332 iwe
.cmd
= SIOCGIWESSID
;
333 iwe
.u
.data
.flags
= 1;
334 current_ev
= iwe_stream_add_point(
335 #if (LINUX_VERSION_CODE >= KERNEL_VERSION(2,6,27))
338 current_ev
, end_buf
, &iwe
, &list
->ssid
[2]);
340 /* Ran out of buffer */
341 if (last_ev
== current_ev
)
346 last_ev
= current_ev
;
349 iwe
.cmd
= SIOCGIWMODE
;
350 capabilities
= (list
->capability
[1] << 8) + list
->capability
[0];
351 if(capabilities
& (0x01 | 0x02))
353 if(capabilities
& 0x01)
354 iwe
.u
.mode
= IW_MODE_MASTER
;
356 iwe
.u
.mode
= IW_MODE_ADHOC
;
357 current_ev
= iwe_stream_add_event(
358 #if (LINUX_VERSION_CODE >= KERNEL_VERSION(2,6,27))
361 current_ev
, end_buf
, &iwe
, IW_EV_UINT_LEN
);
364 /* Ran out of buffer */
365 if (last_ev
== current_ev
)
370 last_ev
= current_ev
;
373 iwe
.cmd
= SIOCGIWFREQ
;
374 iwe
.u
.freq
.m
= list
->channel
;
375 /* Channel frequency in KHz */
376 if (iwe
.u
.freq
.m
> 14)
378 if ((184 <= iwe
.u
.freq
.m
) && (iwe
.u
.freq
.m
<=196))
379 iwe
.u
.freq
.m
= 4000 + iwe
.u
.freq
.m
* 5;
381 iwe
.u
.freq
.m
= 5000 + iwe
.u
.freq
.m
* 5;
385 if (iwe
.u
.freq
.m
== 14)
388 iwe
.u
.freq
.m
= 2412 + (iwe
.u
.freq
.m
- 1) * 5;
391 current_ev
= iwe_stream_add_event(
392 #if (LINUX_VERSION_CODE >= KERNEL_VERSION(2,6,27))
395 current_ev
, end_buf
, &iwe
, IW_EV_FREQ_LEN
);
397 /* Ran out of buffer */
398 if (last_ev
== current_ev
)
403 last_ev
= current_ev
;
405 /* Add quality statistics */
407 #if WIRELESS_EXT > 18
408 iwe
.u
.qual
.updated
= IW_QUAL_QUAL_UPDATED
| IW_QUAL_LEVEL_UPDATED
409 |IW_QUAL_NOISE_UPDATED
;
411 iwe
.u
.qual
.level
= list
->signalStrength
;
412 iwe
.u
.qual
.noise
= 0;
413 iwe
.u
.qual
.qual
= list
->signalQuality
;
414 current_ev
= iwe_stream_add_event(
415 #if (LINUX_VERSION_CODE >= KERNEL_VERSION(2,6,27))
418 current_ev
, end_buf
, &iwe
, IW_EV_QUAL_LEN
);
420 /* Ran out of buffer */
421 if (last_ev
== current_ev
)
426 last_ev
= current_ev
;
428 /* Add encryption capability */
430 iwe
.cmd
= SIOCGIWENCODE
;
431 if(capabilities
& 0x10)
432 iwe
.u
.data
.flags
= IW_ENCODE_ENABLED
| IW_ENCODE_NOKEY
;
434 iwe
.u
.data
.flags
= IW_ENCODE_DISABLED
;
436 iwe
.u
.data
.length
= 0;
437 current_ev
= iwe_stream_add_point(
438 #if (LINUX_VERSION_CODE >= KERNEL_VERSION(2,6,27))
441 current_ev
, end_buf
, &iwe
, list
->ssid
);
443 /* Ran out of buffer */
444 if (last_ev
== current_ev
)
449 last_ev
= current_ev
;
451 /* Rate : stuffing multiple values in a single event require a bit
453 current_val
= current_ev
+ IW_EV_LCP_LEN
;
455 iwe
.cmd
= SIOCGIWRATE
;
456 /* Those two flags are ignored... */
457 iwe
.u
.bitrate
.fixed
= iwe
.u
.bitrate
.disabled
= 0;
459 for(i
= 0 ; i
< list
->supportedRates
[1] ; i
++)
461 /* Bit rate given in 500 kb/s units (+ 0x80) */
462 iwe
.u
.bitrate
.value
= ((list
->supportedRates
[i
+2] & 0x7f) * 500000);
463 /* Add new value to event */
464 current_val
= iwe_stream_add_value(
465 #if (LINUX_VERSION_CODE >= KERNEL_VERSION(2,6,27))
468 current_ev
, current_val
, end_buf
, &iwe
, IW_EV_PARAM_LEN
);
470 /* Ran out of buffer */
471 if (last_ev
== current_val
)
476 last_ev
= current_val
;
479 for (i
= 0 ; i
< list
->extSupportedRates
[1] ; i
++)
481 /* Bit rate given in 500 kb/s units (+ 0x80) */
482 iwe
.u
.bitrate
.value
= ((list
->extSupportedRates
[i
+2] & 0x7f) * 500000);
483 /* Add new value to event */
484 current_val
= iwe_stream_add_value(
485 #if (LINUX_VERSION_CODE >= KERNEL_VERSION(2,6,27))
488 current_ev
, current_val
, end_buf
, &iwe
, IW_EV_PARAM_LEN
);
490 /* Ran out of buffer */
491 if (last_ev
== current_val
)
496 last_ev
= current_ev
;
499 /* Check if we added any event */
500 if((current_val
- current_ev
) > IW_EV_LCP_LEN
)
501 current_ev
= current_val
;
502 #if WIRELESS_EXT > 14
503 #define IEEE80211_ELEMID_RSN 0x30
504 memset(&iwe
, 0, sizeof(iwe
));
505 iwe
.cmd
= IWEVCUSTOM
;
506 snprintf(buf
, sizeof(buf
), "bcn_int=%d", (list
->beaconInterval
[1] << 8) + list
->beaconInterval
[0]);
507 iwe
.u
.data
.length
= strlen(buf
);
508 current_ev
= iwe_stream_add_point(
509 #if (LINUX_VERSION_CODE >= KERNEL_VERSION(2,6,27))
512 current_ev
, end_buf
, &iwe
, buf
);
514 /* Ran out of buffer */
515 if (last_ev
== current_ev
)
520 last_ev
= current_ev
;
522 if (list
->wpaIe
[1] != 0)
524 static const char rsn_leader
[] = "rsn_ie=";
525 static const char wpa_leader
[] = "wpa_ie=";
527 memset(&iwe
, 0, sizeof(iwe
));
528 iwe
.cmd
= IWEVCUSTOM
;
529 if (list
->wpaIe
[0] == IEEE80211_ELEMID_RSN
)
530 iwe
.u
.data
.length
= encode_ie(buf
, sizeof(buf
),
531 list
->wpaIe
, list
->wpaIe
[1]+2,
532 rsn_leader
, sizeof(rsn_leader
)-1);
534 iwe
.u
.data
.length
= encode_ie(buf
, sizeof(buf
),
535 list
->wpaIe
, list
->wpaIe
[1]+2,
536 wpa_leader
, sizeof(wpa_leader
)-1);
538 if (iwe
.u
.data
.length
!= 0)
539 current_ev
= iwe_stream_add_point(
540 #if (LINUX_VERSION_CODE >= KERNEL_VERSION(2,6,27))
543 current_ev
, end_buf
, &iwe
, buf
);
545 /* Ran out of buffer */
546 if (last_ev
== current_ev
)
551 last_ev
= current_ev
;
553 if (list
->rsnIe
[1] != 0)
555 static const char rsn_leader
[] = "rsn_ie=";
556 memset(&iwe
, 0, sizeof(iwe
));
557 iwe
.cmd
= IWEVCUSTOM
;
559 if (list
->rsnIe
[0] == IEEE80211_ELEMID_RSN
)
561 iwe
.u
.data
.length
= encode_ie(buf
, sizeof(buf
),
562 list
->rsnIe
, list
->rsnIe
[1]+2,
563 rsn_leader
, sizeof(rsn_leader
)-1);
564 if (iwe
.u
.data
.length
!= 0)
565 current_ev
= iwe_stream_add_point(
566 #if (LINUX_VERSION_CODE >= KERNEL_VERSION(2,6,27))
569 current_ev
, end_buf
, &iwe
, buf
);
571 /* Ran out of buffer */
572 if (last_ev
== current_ev
)
577 last_ev
= current_ev
;
581 /* The other data in the scan result are not really
582 * interesting, so for now drop it */
586 int usbdrvwext_giwname(struct net_device
*dev
,
587 struct iw_request_info
*info
,
588 union iwreq_data
*wrq
, char *extra
)
590 //struct usbdrv_private *macp = (struct usbdrv_private *)dev->priv;
592 strcpy(wrq
->name
, "IEEE 802.11-MIMO");
597 int usbdrvwext_siwfreq(struct net_device
*dev
,
598 struct iw_request_info
*info
,
599 struct iw_freq
*freq
, char *extra
)
602 struct usbdrv_private
*macp
= dev
->priv
;
604 if(!netif_running(dev
))
612 FreqKHz
= (freq
->m
/ 100000);
614 if (FreqKHz
> 4000000)
616 if (FreqKHz
> 5825000)
618 else if (FreqKHz
< 4920000)
620 else if (FreqKHz
< 5000000)
621 FreqKHz
= (((FreqKHz
- 4000000) / 5000) * 5000) + 4000000;
623 FreqKHz
= (((FreqKHz
- 5000000) / 5000) * 5000) + 5000000;
627 if (FreqKHz
> 2484000)
629 else if (FreqKHz
< 2412000)
632 FreqKHz
= (((FreqKHz
- 2412000) / 5000) * 5000) + 2412000;
638 FreqKHz
= usbdrv_chan2freq(freq
->m
);
646 //printk("freq->m: %d, freq->e: %d\n", freq->m, freq->e);
647 //printk("FreqKHz: %d\n", FreqKHz);
649 if (macp
->DeviceOpened
== 1)
651 zfiWlanSetFrequency(dev
, FreqKHz
, 0); // Immediate
652 //u8_t wpaieLen,wpaie[50];
653 //zfiWlanQueryWpaIe(dev, wpaie, &wpaieLen);
654 zfiWlanDisable(dev
, 0);
657 // zfiWlanSetWpaIe(dev, wpaie, wpaieLen);
663 int usbdrvwext_giwfreq(struct net_device
*dev
,
664 struct iw_request_info
*info
,
665 struct iw_freq
*freq
, char *extra
)
667 struct usbdrv_private
*macp
= (struct usbdrv_private
*)dev
->priv
;
669 if (macp
->DeviceOpened
!= 1)
672 freq
->m
= zfiWlanQueryFrequency(dev
);
678 int usbdrvwext_siwmode(struct net_device
*dev
,
679 struct iw_request_info
*info
,
680 union iwreq_data
*wrq
, char *extra
)
682 struct usbdrv_private
*macp
= (struct usbdrv_private
*)dev
->priv
;
685 if(!netif_running(dev
))
688 if (macp
->DeviceOpened
!= 1)
694 WlanMode
= ZM_MODE_AP
;
697 WlanMode
= ZM_MODE_INFRASTRUCTURE
;
700 WlanMode
= ZM_MODE_IBSS
;
703 WlanMode
= ZM_MODE_IBSS
;
707 zfiWlanSetWlanMode(dev
,WlanMode
);
708 zfiWlanDisable(dev
, 1);
714 int usbdrvwext_giwmode(struct net_device
*dev
,
715 struct iw_request_info
*info
,
716 __u32
*mode
, char *extra
)
718 unsigned long irqFlag
;
719 struct usbdrv_private
*macp
= dev
->priv
;
721 if(!netif_running(dev
))
724 if (macp
->DeviceOpened
!= 1)
727 spin_lock_irqsave(&(((struct usbdrv_private
*)(dev
->priv
))->cs_lock
), irqFlag
);
729 switch(zfiWlanQueryWlanMode(dev
))
732 *mode
= IW_MODE_MASTER
;
734 case ZM_MODE_INFRASTRUCTURE
:
735 *mode
= IW_MODE_INFRA
;
738 *mode
= IW_MODE_ADHOC
;
741 *mode
= IW_MODE_ADHOC
;
745 spin_unlock_irqrestore(&(((struct usbdrv_private
*)(dev
->priv
))->cs_lock
), irqFlag
);
750 int usbdrvwext_siwsens(struct net_device
*dev
,
751 struct iw_request_info
*info
,
752 struct iw_param
*sens
, char *extra
)
757 int usbdrvwext_giwsens(struct net_device
*dev
,
758 struct iw_request_info
*info
,
759 struct iw_param
*sens
, char *extra
)
767 int usbdrvwext_giwrange(struct net_device
*dev
,
768 struct iw_request_info
*info
,
769 struct iw_point
*data
, char *extra
)
771 struct iw_range
*range
= (struct iw_range
*) extra
;
777 if(!netif_running(dev
))
781 range
->txpower_capa
= IW_TXPOW_DBM
;
782 // XXX what about min/max_pmp, min/max_pmt, etc.
785 #if WIRELESS_EXT > 10
786 range
->we_version_compiled
= WIRELESS_EXT
;
787 range
->we_version_source
= 13;
789 range
->retry_capa
= IW_RETRY_LIMIT
;
790 range
->retry_flags
= IW_RETRY_LIMIT
;
791 range
->min_retry
= 0;
792 range
->max_retry
= 255;
793 #endif /* WIRELESS_EXT > 10 */
795 channel_num
= zfiWlanQueryAllowChannels(dev
, channels
);
797 /* Gurantee reported channel numbers is less or equal to IW_MAX_FREQUENCIES */
798 if (channel_num
> IW_MAX_FREQUENCIES
)
799 channel_num
= IW_MAX_FREQUENCIES
;
803 for (i
= 0; i
< channel_num
; i
++)
805 range
->freq
[val
].i
= usbdrv_freq2chan(channels
[i
]);
806 range
->freq
[val
].m
= channels
[i
];
807 range
->freq
[val
].e
= 6;
811 range
->num_channels
= channel_num
;
812 range
->num_frequency
= channel_num
;
815 range
->num_channels
= 14; // Only 2.4G
817 /* XXX need to filter against the regulatory domain &| active set */
819 for (i
= 1; i
<= 14; i
++) // B,G Bands
821 range
->freq
[val
].i
= i
;
823 range
->freq
[val
].m
= 2484000;
825 range
->freq
[val
].m
= (2412+(i
-1)*5)*1000;
826 range
->freq
[val
].e
= 3;
830 num_band_a
= (IW_MAX_FREQUENCIES
- val
);
832 for (i
= 0; i
< num_band_a
; i
++) // A Bands
834 range
->freq
[val
].i
= channel_frequency_11A
[2 * i
];
835 range
->freq
[val
].m
= channel_frequency_11A
[2 * i
+ 1] * 1000;
836 range
->freq
[val
].e
= 3;
839 // MIMO Rate Not Defined Now
840 //For 802.11a, there are too more frequency. We can't return them all
841 range
->num_frequency
= val
;
844 /* Max of /proc/net/wireless */
845 range
->max_qual
.qual
= 100; //?? //92;
846 range
->max_qual
.level
= 154; //??
847 range
->max_qual
.noise
= 154; //??
848 range
->sensitivity
= 3; //??
850 // XXX these need to be nsd-specific!
852 range
->max_rts
= 2347;
853 range
->min_frag
= 256;
854 range
->max_frag
= 2346;
855 range
->max_encoding_tokens
= 4/*NUM_WEPKEYS*/; //??
856 range
->num_encoding_sizes
= 2; //??
858 range
->encoding_size
[0] = 5; //?? //WEP Key Encoding Size
859 range
->encoding_size
[1] = 13;//??
861 // XXX what about num_bitrates/throughput?
862 range
->num_bitrates
= 0; //??
864 /* estimated max throughput */
865 // XXX need to cap it if we're running at ~2Mbps..
867 range
->throughput
= 300000000;
872 int usbdrvwext_siwap(struct net_device
*dev
, struct iw_request_info
*info
,
873 struct sockaddr
*MacAddr
, char *extra
)
875 struct usbdrv_private
*macp
= dev
->priv
;
877 if(!netif_running(dev
))
880 if (zfiWlanQueryWlanMode(dev
) == ZM_MODE_AP
) // AP Mode
881 zfiWlanSetMacAddress(dev
,(u16_t
*)&MacAddr
->sa_data
[0]);
883 zfiWlanSetBssid(dev
,&MacAddr
->sa_data
[0]);
885 if (macp
->DeviceOpened
== 1)
887 //u8_t wpaieLen,wpaie[80];
888 //zfiWlanQueryWpaIe(dev, wpaie, &wpaieLen);
889 zfiWlanDisable(dev
, 0);
892 // zfiWlanSetWpaIe(dev, wpaie, wpaieLen);
898 int usbdrvwext_giwap(struct net_device
*dev
,
899 struct iw_request_info
*info
,
900 struct sockaddr
*MacAddr
, char *extra
)
902 struct usbdrv_private
*macp
= dev
->priv
;
904 if (macp
->DeviceOpened
!= 1)
907 if (zfiWlanQueryWlanMode(dev
) == ZM_MODE_AP
) // AP Mode
908 zfiWlanQueryMacAddress(dev
, &MacAddr
->sa_data
[0]);
911 if (macp
->adapterState
== ZM_STATUS_MEDIA_CONNECT
)
913 zfiWlanQueryBssid(dev
, &MacAddr
->sa_data
[0]);
917 u8_t zero_addr
[6] = { 0x00, 0x00, 0x00, 0x00, 0x00, 0x00 };
918 memcpy(&MacAddr
->sa_data
[0], zero_addr
, sizeof(zero_addr
));
925 int usbdrvwext_iwaplist(struct net_device
*dev
,
926 struct iw_request_info
*info
,
927 struct iw_point
*data
, char *extra
)
929 //Don't know how to do yet--CWYang(+)
934 int usbdrvwext_siwscan(struct net_device
*dev
, struct iw_request_info
*info
,
935 struct iw_point
*data
, char *extra
)
937 struct usbdrv_private
*macp
= dev
->priv
;
939 if (macp
->DeviceOpened
!= 1)
942 printk("CWY - usbdrvwext_siwscan\n");
949 int usbdrvwext_giwscan(struct net_device
*dev
,
950 struct iw_request_info
*info
,
951 struct iw_point
*data
, char *extra
)
953 struct usbdrv_private
*macp
= (struct usbdrv_private
*)dev
->priv
;
954 //struct zsWlanDev* wd = (struct zsWlanDev*) zmw_wlan_dev(dev);
955 char *current_ev
= extra
;
958 //struct zsBssList BssList;
959 struct zsBssListV1
*pBssList
= kmalloc(sizeof(struct zsBssListV1
), GFP_KERNEL
);
960 //BssList = wd->sta.pBssList;
961 //zmw_get_wlan_dev(dev);
963 if (macp
->DeviceOpened
!= 1)
966 if (data
->length
== 0)
968 end_buf
= extra
+ IW_SCAN_MAX_DATA
;
972 end_buf
= extra
+ data
->length
;
975 printk("giwscan - Report Scan Results\n");
976 //printk("giwscan - BssList Sreucture Len : %d\n", sizeof(BssList));
977 //printk("giwscan - BssList Count : %d\n", wd->sta.pBssList->bssCount);
978 //printk("giwscan - UpdateBssList Count : %d\n", wd->sta.pUpdateBssList->bssCount);
979 zfiWlanQueryBssListV1(dev
, pBssList
);
980 //zfiWlanQueryBssList(dev, &BssList);
982 /* Read and parse all entries */
983 printk("giwscan - pBssList->bssCount : %d\n", pBssList
->bssCount
);
984 //printk("giwscan - BssList.bssCount : %d\n", BssList.bssCount);
986 for (i
= 0; i
< pBssList
->bssCount
; i
++)
988 /* Translate to WE format this entry */
989 //current_ev = usbdrv_translate_scan(dev, info, current_ev,
990 // extra + IW_SCAN_MAX_DATA, &pBssList->bssInfo[i]);
991 current_ev
= usbdrv_translate_scan(dev
, info
, current_ev
,
992 end_buf
, &pBssList
->bssInfo
[i
]);
994 #if WIRELESS_EXT > 16
995 if (current_ev
== end_buf
)
998 data
->length
= current_ev
- extra
;
1004 /* Length of data */
1005 data
->length
= (current_ev
- extra
);
1006 data
->flags
= 0; /* todo */
1013 int usbdrvwext_siwessid(struct net_device
*dev
,
1014 struct iw_request_info
*info
,
1015 struct iw_point
*essid
, char *extra
)
1017 char EssidBuf
[IW_ESSID_MAX_SIZE
+1];
1018 struct usbdrv_private
*macp
= dev
->priv
;
1020 if(!netif_running(dev
))
1023 if (essid
->flags
== 1)
1025 if (essid
->length
> (IW_ESSID_MAX_SIZE
+1))
1028 if (copy_from_user(&EssidBuf
, essid
->pointer
, essid
->length
))
1031 EssidBuf
[essid
->length
] = '\0';
1032 //printk("siwessid - Set Essid : %s\n",EssidBuf);
1033 //printk("siwessid - Essid Len : %d\n",essid->length);
1034 //printk("siwessid - Essid Flag : %x\n",essid->flags);
1035 if (macp
->DeviceOpened
== 1)
1037 zfiWlanSetSSID(dev
, EssidBuf
, strlen(EssidBuf
));
1038 zfiWlanSetFrequency(dev
, zfiWlanQueryFrequency(dev
), FALSE
);
1039 zfiWlanSetEncryMode(dev
, zfiWlanQueryEncryMode(dev
));
1040 //u8_t wpaieLen,wpaie[50];
1041 //zfiWlanQueryWpaIe(dev, wpaie, &wpaieLen);
1042 zfiWlanDisable(dev
, 0);
1045 // zfiWlanSetWpaIe(dev, wpaie, wpaieLen);
1052 int usbdrvwext_giwessid(struct net_device
*dev
,
1053 struct iw_request_info
*info
,
1054 struct iw_point
*essid
, char *extra
)
1056 struct usbdrv_private
*macp
= dev
->priv
;
1058 char EssidBuf
[IW_ESSID_MAX_SIZE
+1];
1061 if(!netif_running(dev
))
1064 if (macp
->DeviceOpened
!= 1)
1067 zfiWlanQuerySSID(dev
, &EssidBuf
[0], &EssidLen
);
1069 /* Convert type from unsigned char to char */
1070 ssid_len
= (int)EssidLen
;
1072 /* Make sure the essid length is not greater than IW_ESSID_MAX_SIZE */
1073 if (ssid_len
> IW_ESSID_MAX_SIZE
)
1074 ssid_len
= IW_ESSID_MAX_SIZE
;
1076 EssidBuf
[ssid_len
] = '\0';
1079 essid
->length
= strlen(EssidBuf
);
1081 memcpy(extra
, EssidBuf
, essid
->length
);
1082 // wireless.c in Kernel would handle copy_to_user -- line 679
1083 /*if (essid->pointer)
1085 if ( copy_to_user(essid->pointer, EssidBuf, essid->length) )
1087 printk("giwessid - copy_to_user Fail\n");
1095 int usbdrvwext_siwnickn(struct net_device
*dev
,
1096 struct iw_request_info
*info
,
1097 struct iw_point
*data
, char *nickname
)
1099 //Exist but junk--CWYang(+)
1103 int usbdrvwext_giwnickn(struct net_device
*dev
,
1104 struct iw_request_info
*info
,
1105 struct iw_point
*data
, char *nickname
)
1107 struct usbdrv_private
*macp
= dev
->priv
;
1109 char EssidBuf
[IW_ESSID_MAX_SIZE
+1];
1111 if (macp
->DeviceOpened
!= 1)
1114 zfiWlanQuerySSID(dev
, &EssidBuf
[0], &EssidLen
);
1115 EssidBuf
[EssidLen
] = 0;
1118 data
->length
= strlen(EssidBuf
);
1120 memcpy(nickname
, EssidBuf
, data
->length
);
1125 int usbdrvwext_siwrate(struct net_device
*dev
,
1126 struct iw_request_info
*info
,
1127 struct iw_param
*frq
, char *extra
)
1129 struct usbdrv_private
*macp
= dev
->priv
;
1130 //Array to Define Rate Number that Send to Driver
1131 u16_t zcIndextoRateBG
[16] = {1000, 2000, 5500, 11000, 0, 0, 0, 0, 48000,
1132 24000, 12000, 6000, 54000, 36000, 18000, 9000};
1133 u16_t zcRateToMCS
[] = {0xff, 0, 1, 2, 3, 0xb, 0xf, 0xa, 0xe, 0x9, 0xd,
1135 u8_t i
,RateIndex
= 4;
1138 //printk("frq->disabled : 0x%x\n",frq->disabled);
1139 //printk("frq->value : 0x%x\n",frq->value);
1141 RateKbps
= frq
->value
/ 1000;
1142 //printk("RateKbps : %d\n", RateKbps);
1143 for (i
= 0; i
< 16; i
++)
1145 if (RateKbps
== zcIndextoRateBG
[i
])
1148 if (zcIndextoRateBG
[RateIndex
] == 0)
1150 //printk("RateIndex : %x\n", RateIndex);
1151 for (i
= 0; i
< 13; i
++)
1152 if (RateIndex
== zcRateToMCS
[i
])
1154 //printk("Index : %x\n", i);
1155 if (RateKbps
== 65000)
1158 printk("RateIndex : %d\n", RateIndex
);
1160 if (macp
->DeviceOpened
== 1)
1162 zfiWlanSetTxRate(dev
, i
);
1163 //zfiWlanDisable(dev);
1164 //zfiWlanEnable(dev);
1170 int usbdrvwext_giwrate(struct net_device
*dev
,
1171 struct iw_request_info
*info
,
1172 struct iw_param
*frq
, char *extra
)
1174 struct usbdrv_private
*macp
= (struct usbdrv_private
*)dev
->priv
;
1176 if(!netif_running(dev
))
1179 if (macp
->DeviceOpened
!= 1)
1184 frq
->value
= zfiWlanQueryRxRate(dev
) * 1000;
1189 int usbdrvwext_siwrts(struct net_device
*dev
,
1190 struct iw_request_info
*info
,
1191 struct iw_param
*rts
, char *extra
)
1193 struct usbdrv_private
*macp
= dev
->priv
;
1194 int val
= rts
->value
;
1196 if (macp
->DeviceOpened
!= 1)
1202 if ((val
< 0) || (val
> 2347))
1205 zfiWlanSetRtsThreshold(dev
,val
);
1210 int usbdrvwext_giwrts(struct net_device
*dev
,
1211 struct iw_request_info
*info
,
1212 struct iw_param
*rts
, char *extra
)
1214 struct usbdrv_private
*macp
= dev
->priv
;
1216 if(!netif_running(dev
))
1219 if (macp
->DeviceOpened
!= 1)
1222 rts
->value
= zfiWlanQueryRtsThreshold(dev
);
1223 rts
->disabled
= (rts
->value
>= 2347);
1230 int usbdrvwext_siwfrag(struct net_device
*dev
,
1231 struct iw_request_info
*info
,
1232 struct iw_param
*frag
, char *extra
)
1234 struct usbdrv_private
*macp
= dev
->priv
;
1235 u16_t fragThreshold
;
1237 if (macp
->DeviceOpened
!= 1)
1243 fragThreshold
= frag
->value
;
1245 zfiWlanSetFragThreshold(dev
,fragThreshold
);
1250 int usbdrvwext_giwfrag(struct net_device
*dev
,
1251 struct iw_request_info
*info
,
1252 struct iw_param
*frag
, char *extra
)
1254 struct usbdrv_private
*macp
= dev
->priv
;
1256 unsigned long irqFlag
;
1258 if(!netif_running(dev
))
1261 if (macp
->DeviceOpened
!= 1)
1264 spin_lock_irqsave(&(((struct usbdrv_private
*)(dev
->priv
))->cs_lock
), irqFlag
);
1266 val
= zfiWlanQueryFragThreshold(dev
);
1270 frag
->disabled
= (val
>= 2346);
1273 spin_unlock_irqrestore(&(((struct usbdrv_private
*)(dev
->priv
))->cs_lock
), irqFlag
);
1278 int usbdrvwext_siwtxpow(struct net_device
*dev
,
1279 struct iw_request_info
*info
,
1280 struct iw_param
*rrq
, char *extra
)
1282 //Not support yet--CWYng(+)
1286 int usbdrvwext_giwtxpow(struct net_device
*dev
,
1287 struct iw_request_info
*info
,
1288 struct iw_param
*rrq
, char *extra
)
1290 //Not support yet--CWYng(+)
1294 int usbdrvwext_siwretry(struct net_device
*dev
,
1295 struct iw_request_info
*info
,
1296 struct iw_param
*rrq
, char *extra
)
1298 //Do nothing--CWYang(+)
1302 int usbdrvwext_giwretry(struct net_device
*dev
,
1303 struct iw_request_info
*info
,
1304 struct iw_param
*rrq
, char *extra
)
1306 //Do nothing--CWYang(+)
1310 int usbdrvwext_siwencode(struct net_device
*dev
,
1311 struct iw_request_info
*info
,
1312 struct iw_point
*erq
, char *key
)
1314 struct zsKeyInfo keyInfo
;
1315 int i
, WepState
= ZM_ENCRYPTION_WEP_DISABLED
;
1316 struct usbdrv_private
*macp
= dev
->priv
;
1318 if(!netif_running(dev
))
1321 if ((erq
->flags
& IW_ENCODE_DISABLED
) == 0)
1324 keyInfo
.keyLength
= erq
->length
;
1325 keyInfo
.keyIndex
= (erq
->flags
& IW_ENCODE_INDEX
) - 1;
1326 if (keyInfo
.keyIndex
>= 4)
1327 keyInfo
.keyIndex
= 0;
1328 keyInfo
.flag
= ZM_KEY_FLAG_DEFAULT_KEY
;
1330 zfiWlanSetKey(dev
, keyInfo
);
1331 WepState
= ZM_ENCRYPTION_WEP_ENABLED
;
1335 for (i
= 1; i
< 4; i
++)
1336 zfiWlanRemoveKey(dev
, 0, i
);
1337 WepState
= ZM_ENCRYPTION_WEP_DISABLED
;
1338 //zfiWlanSetEncryMode(dev, ZM_NO_WEP);
1341 if (macp
->DeviceOpened
== 1)
1343 zfiWlanSetWepStatus(dev
, WepState
);
1344 zfiWlanSetFrequency(dev
, zfiWlanQueryFrequency(dev
), FALSE
);
1345 //zfiWlanSetEncryMode(dev, zfiWlanQueryEncryMode(dev));
1346 //u8_t wpaieLen,wpaie[50];
1347 //zfiWlanQueryWpaIe(dev, wpaie, &wpaieLen);
1348 zfiWlanDisable(dev
, 0);
1351 // zfiWlanSetWpaIe(dev, wpaie, wpaieLen);
1357 int usbdrvwext_giwencode(struct net_device
*dev
,
1358 struct iw_request_info
*info
,
1359 struct iw_point
*erq
, char *key
)
1361 struct usbdrv_private
*macp
= (struct usbdrv_private
*)dev
->priv
;
1362 u8_t EncryptionMode
;
1365 if (macp
->DeviceOpened
!= 1)
1368 EncryptionMode
= zfiWlanQueryEncryMode(dev
);
1372 erq
->flags
= IW_ENCODE_ENABLED
;
1376 erq
->flags
= IW_ENCODE_DISABLED
;
1379 /* We can't return the key, so set the proper flag and return zero */
1380 erq
->flags
|= IW_ENCODE_NOKEY
;
1383 /* Copy the key to the user buffer */
1384 switch(EncryptionMode
)
1401 #ifdef ZM_ENABLE_CENC
1405 #endif //ZM_ENABLE_CENC
1411 printk("Unknown EncryMode\n");
1415 erq
->length
= keyLen
;
1420 int usbdrvwext_siwpower(struct net_device
*dev
,
1421 struct iw_request_info
*info
,
1422 struct iw_param
*frq
, char *extra
)
1424 struct usbdrv_private
*macp
= (struct usbdrv_private
*)dev
->priv
;
1427 if (macp
->DeviceOpened
!= 1)
1431 PSMode
= ZM_STA_PS_NONE
;
1433 PSMode
= ZM_STA_PS_MAX
;
1435 zfiWlanSetPowerSaveMode(dev
,PSMode
);
1440 int usbdrvwext_giwpower(struct net_device
*dev
,
1441 struct iw_request_info
*info
,
1442 struct iw_param
*frq
, char *extra
)
1444 unsigned long irqFlag
;
1445 struct usbdrv_private
*macp
= (struct usbdrv_private
*)dev
->priv
;
1447 if (macp
->DeviceOpened
!= 1)
1450 spin_lock_irqsave(&(((struct usbdrv_private
*)(dev
->priv
))->cs_lock
), irqFlag
);
1452 if (zfiWlanQueryPowerSaveMode(dev
) == ZM_STA_PS_NONE
)
1457 spin_unlock_irqrestore(&(((struct usbdrv_private
*)(dev
->priv
))->cs_lock
), irqFlag
);
1462 //int usbdrvwext_setparam(struct net_device *dev, struct iw_request_info *info,
1463 // void *w, char *extra)
1465 // struct ieee80211vap *vap = dev->priv;
1466 // struct ieee80211com *ic = vap->iv_ic;
1467 // struct ieee80211_rsnparms *rsn = &vap->iv_bss->ni_rsn;
1468 // int *i = (int *) extra;
1469 // int param = i[0]; /* parameter id is 1st */
1470 // int value = i[1]; /* NB: most values are TYPE_INT */
1473 // const struct ieee80211_authenticator *auth;
1474 // const struct ieee80211_aclator *acl;
1477 // case IEEE80211_PARAM_AUTHMODE:
1479 // case IEEE80211_AUTH_WPA: /* WPA */
1480 // case IEEE80211_AUTH_8021X: /* 802.1x */
1481 // case IEEE80211_AUTH_OPEN: /* open */
1482 // case IEEE80211_AUTH_SHARED: /* shared-key */
1483 // case IEEE80211_AUTH_AUTO: /* auto */
1484 // auth = ieee80211_authenticator_get(value);
1485 // if (auth == NULL)
1492 // case IEEE80211_AUTH_WPA: /* WPA w/ 802.1x */
1493 // vap->iv_flags |= IEEE80211_F_PRIVACY;
1494 // value = IEEE80211_AUTH_8021X;
1496 // case IEEE80211_AUTH_OPEN: /* open */
1497 // vap->iv_flags &= ~(IEEE80211_F_WPA|IEEE80211_F_PRIVACY);
1499 // case IEEE80211_AUTH_SHARED: /* shared-key */
1500 // case IEEE80211_AUTH_AUTO: /* auto */
1501 // case IEEE80211_AUTH_8021X: /* 802.1x */
1502 // vap->iv_flags &= ~IEEE80211_F_WPA;
1503 // /* both require a key so mark the PRIVACY capability */
1504 // vap->iv_flags |= IEEE80211_F_PRIVACY;
1507 // /* NB: authenticator attach/detach happens on state change */
1508 // vap->iv_bss->ni_authmode = value;
1509 // /* XXX mixed/mode/usage? */
1510 // vap->iv_auth = auth;
1511 // retv = ENETRESET;
1513 // case IEEE80211_PARAM_PROTMODE:
1514 // if (value > IEEE80211_PROT_RTSCTS)
1516 // ic->ic_protmode = value;
1517 // /* NB: if not operating in 11g this can wait */
1518 // if (ic->ic_bsschan != IEEE80211_CHAN_ANYC &&
1519 // IEEE80211_IS_CHAN_ANYG(ic->ic_bsschan))
1520 // retv = ENETRESET;
1522 // case IEEE80211_PARAM_MCASTCIPHER:
1523 // if ((vap->iv_caps & cipher2cap(value)) == 0 &&
1524 // !ieee80211_crypto_available(value))
1526 // rsn->rsn_mcastcipher = value;
1527 // if (vap->iv_flags & IEEE80211_F_WPA)
1528 // retv = ENETRESET;
1530 // case IEEE80211_PARAM_MCASTKEYLEN:
1531 // if (!(0 < value && value < IEEE80211_KEYBUF_SIZE))
1533 // /* XXX no way to verify driver capability */
1534 // rsn->rsn_mcastkeylen = value;
1535 // if (vap->iv_flags & IEEE80211_F_WPA)
1536 // retv = ENETRESET;
1538 // case IEEE80211_PARAM_UCASTCIPHERS:
1540 // * Convert cipher set to equivalent capabilities.
1541 // * NB: this logic intentionally ignores unknown and
1542 // * unsupported ciphers so folks can specify 0xff or
1543 // * similar and get all available ciphers.
1546 // for (j = 1; j < 32; j++) /* NB: skip WEP */
1547 // if ((value & (1<<j)) &&
1548 // ((vap->iv_caps & cipher2cap(j)) ||
1549 // ieee80211_crypto_available(j)))
1551 // if (caps == 0) /* nothing available */
1553 // /* XXX verify ciphers ok for unicast use? */
1554 // /* XXX disallow if running as it'll have no effect */
1555 // rsn->rsn_ucastcipherset = caps;
1556 // if (vap->iv_flags & IEEE80211_F_WPA)
1557 // retv = ENETRESET;
1559 // case IEEE80211_PARAM_UCASTCIPHER:
1560 // if ((rsn->rsn_ucastcipherset & cipher2cap(value)) == 0)
1562 // rsn->rsn_ucastcipher = value;
1564 // case IEEE80211_PARAM_UCASTKEYLEN:
1565 // if (!(0 < value && value < IEEE80211_KEYBUF_SIZE))
1567 // /* XXX no way to verify driver capability */
1568 // rsn->rsn_ucastkeylen = value;
1570 // case IEEE80211_PARAM_KEYMGTALGS:
1572 // rsn->rsn_keymgmtset = value;
1573 // if (vap->iv_flags & IEEE80211_F_WPA)
1574 // retv = ENETRESET;
1576 // case IEEE80211_PARAM_RSNCAPS:
1578 // rsn->rsn_caps = value;
1579 // if (vap->iv_flags & IEEE80211_F_WPA)
1580 // retv = ENETRESET;
1582 // case IEEE80211_PARAM_WPA:
1585 // /* XXX verify ciphers available */
1586 // vap->iv_flags &= ~IEEE80211_F_WPA;
1589 // vap->iv_flags |= IEEE80211_F_WPA1;
1592 // vap->iv_flags |= IEEE80211_F_WPA2;
1595 // vap->iv_flags |= IEEE80211_F_WPA1 | IEEE80211_F_WPA2;
1598 // retv = ENETRESET; /* XXX? */
1600 // case IEEE80211_PARAM_ROAMING:
1601 // if (!(IEEE80211_ROAMING_DEVICE <= value &&
1602 // value <= IEEE80211_ROAMING_MANUAL))
1604 // ic->ic_roaming = value;
1606 // case IEEE80211_PARAM_PRIVACY:
1608 // /* XXX check for key state? */
1609 // vap->iv_flags |= IEEE80211_F_PRIVACY;
1611 // vap->iv_flags &= ~IEEE80211_F_PRIVACY;
1613 // case IEEE80211_PARAM_DROPUNENCRYPTED:
1615 // vap->iv_flags |= IEEE80211_F_DROPUNENC;
1617 // vap->iv_flags &= ~IEEE80211_F_DROPUNENC;
1619 // case IEEE80211_PARAM_COUNTERMEASURES:
1621 // if ((vap->iv_flags & IEEE80211_F_WPA) == 0)
1623 // vap->iv_flags |= IEEE80211_F_COUNTERM;
1625 // vap->iv_flags &= ~IEEE80211_F_COUNTERM;
1627 // case IEEE80211_PARAM_DRIVER_CAPS:
1628 // vap->iv_caps = value; /* NB: for testing */
1630 // case IEEE80211_PARAM_MACCMD:
1631 // acl = vap->iv_acl;
1633 // case IEEE80211_MACCMD_POLICY_OPEN:
1634 // case IEEE80211_MACCMD_POLICY_ALLOW:
1635 // case IEEE80211_MACCMD_POLICY_DENY:
1636 // if (acl == NULL) {
1637 // acl = ieee80211_aclator_get("mac");
1638 // if (acl == NULL || !acl->iac_attach(vap))
1640 // vap->iv_acl = acl;
1642 // acl->iac_setpolicy(vap, value);
1644 // case IEEE80211_MACCMD_FLUSH:
1646 // acl->iac_flush(vap);
1647 // /* NB: silently ignore when not in use */
1649 // case IEEE80211_MACCMD_DETACH:
1650 // if (acl != NULL) {
1651 // vap->iv_acl = NULL;
1652 // acl->iac_detach(vap);
1657 // case IEEE80211_PARAM_WMM:
1658 // if (ic->ic_caps & IEEE80211_C_WME){
1660 // vap->iv_flags |= IEEE80211_F_WME;
1661 // vap->iv_ic->ic_flags |= IEEE80211_F_WME; /* XXX needed by ic_reset */
1664 // vap->iv_flags &= ~IEEE80211_F_WME;
1665 // vap->iv_ic->ic_flags &= ~IEEE80211_F_WME; /* XXX needed by ic_reset */
1667 // retv = ENETRESET; /* Renegotiate for capabilities */
1670 // case IEEE80211_PARAM_HIDESSID:
1672 // vap->iv_flags |= IEEE80211_F_HIDESSID;
1674 // vap->iv_flags &= ~IEEE80211_F_HIDESSID;
1675 // retv = ENETRESET;
1677 // case IEEE80211_PARAM_APBRIDGE:
1679 // vap->iv_flags |= IEEE80211_F_NOBRIDGE;
1681 // vap->iv_flags &= ~IEEE80211_F_NOBRIDGE;
1683 // case IEEE80211_PARAM_INACT:
1684 // vap->iv_inact_run = value / IEEE80211_INACT_WAIT;
1686 // case IEEE80211_PARAM_INACT_AUTH:
1687 // vap->iv_inact_auth = value / IEEE80211_INACT_WAIT;
1689 // case IEEE80211_PARAM_INACT_INIT:
1690 // vap->iv_inact_init = value / IEEE80211_INACT_WAIT;
1692 // case IEEE80211_PARAM_ABOLT:
1695 // * Map abolt settings to capability bits;
1696 // * this also strips unknown/unwanted bits.
1698 // if (value & IEEE80211_ABOLT_TURBO_PRIME)
1699 // caps |= IEEE80211_ATHC_TURBOP;
1700 // if (value & IEEE80211_ABOLT_COMPRESSION)
1701 // caps |= IEEE80211_ATHC_COMP;
1702 // if (value & IEEE80211_ABOLT_FAST_FRAME)
1703 // caps |= IEEE80211_ATHC_FF;
1704 // if (value & IEEE80211_ABOLT_XR)
1705 // caps |= IEEE80211_ATHC_XR;
1706 // if (value & IEEE80211_ABOLT_AR)
1707 // caps |= IEEE80211_ATHC_AR;
1708 // if (value & IEEE80211_ABOLT_BURST)
1709 // caps |= IEEE80211_ATHC_BURST;
1710 // if (value & IEEE80211_ABOLT_WME_ELE)
1711 // caps |= IEEE80211_ATHC_WME;
1712 // /* verify requested capabilities are supported */
1713 // if ((caps & ic->ic_ath_cap) != caps)
1715 // if (vap->iv_ath_cap != caps) {
1716 // if ((vap->iv_ath_cap ^ caps) & IEEE80211_ATHC_TURBOP) {
1717 // if (ieee80211_set_turbo(dev, caps & IEEE80211_ATHC_TURBOP))
1719 // ieee80211_scan_flush(ic);
1721 // vap->iv_ath_cap = caps;
1722 // ic->ic_athcapsetup(vap->iv_ic, vap->iv_ath_cap);
1723 // retv = ENETRESET;
1726 // case IEEE80211_PARAM_DTIM_PERIOD:
1727 // if (vap->iv_opmode != IEEE80211_M_HOSTAP &&
1728 // vap->iv_opmode != IEEE80211_M_IBSS)
1730 // if (IEEE80211_DTIM_MIN <= value &&
1731 // value <= IEEE80211_DTIM_MAX) {
1732 // vap->iv_dtim_period = value;
1733 // retv = ENETRESET; /* requires restart */
1737 // case IEEE80211_PARAM_BEACON_INTERVAL:
1738 // if (vap->iv_opmode != IEEE80211_M_HOSTAP &&
1739 // vap->iv_opmode != IEEE80211_M_IBSS)
1741 // if (IEEE80211_BINTVAL_MIN <= value &&
1742 // value <= IEEE80211_BINTVAL_MAX) {
1743 // ic->ic_lintval = value; /* XXX multi-bss */
1744 // retv = ENETRESET; /* requires restart */
1748 // case IEEE80211_PARAM_DOTH:
1750 // ic->ic_flags |= IEEE80211_F_DOTH;
1753 // ic->ic_flags &= ~IEEE80211_F_DOTH;
1754 // retv = ENETRESET; /* XXX: need something this drastic? */
1756 // case IEEE80211_PARAM_PWRTARGET:
1757 // ic->ic_curchanmaxpwr = value;
1759 // case IEEE80211_PARAM_GENREASSOC:
1760 // IEEE80211_SEND_MGMT(vap->iv_bss, IEEE80211_FC0_SUBTYPE_REASSOC_REQ, 0);
1762 // case IEEE80211_PARAM_COMPRESSION:
1763 // retv = ieee80211_setathcap(vap, IEEE80211_ATHC_COMP, value);
1765 // case IEEE80211_PARAM_WMM_AGGRMODE:
1766 // retv = ieee80211_setathcap(vap, IEEE80211_ATHC_WME, value);
1768 // case IEEE80211_PARAM_FF:
1769 // retv = ieee80211_setathcap(vap, IEEE80211_ATHC_FF, value);
1771 // case IEEE80211_PARAM_TURBO:
1772 // retv = ieee80211_setathcap(vap, IEEE80211_ATHC_TURBOP, value);
1773 // if (retv == ENETRESET) {
1774 // if(ieee80211_set_turbo(dev,value))
1776 // ieee80211_scan_flush(ic);
1779 // case IEEE80211_PARAM_XR:
1780 // retv = ieee80211_setathcap(vap, IEEE80211_ATHC_XR, value);
1782 // case IEEE80211_PARAM_BURST:
1783 // retv = ieee80211_setathcap(vap, IEEE80211_ATHC_BURST, value);
1785 // case IEEE80211_PARAM_AR:
1786 // retv = ieee80211_setathcap(vap, IEEE80211_ATHC_AR, value);
1788 // case IEEE80211_PARAM_PUREG:
1790 // vap->iv_flags |= IEEE80211_F_PUREG;
1792 // vap->iv_flags &= ~IEEE80211_F_PUREG;
1793 // /* NB: reset only if we're operating on an 11g channel */
1794 // if (ic->ic_bsschan != IEEE80211_CHAN_ANYC &&
1795 // IEEE80211_IS_CHAN_ANYG(ic->ic_bsschan))
1796 // retv = ENETRESET;
1798 // case IEEE80211_PARAM_WDS:
1800 // vap->iv_flags_ext |= IEEE80211_FEXT_WDS;
1802 // vap->iv_flags_ext &= ~IEEE80211_FEXT_WDS;
1804 // case IEEE80211_PARAM_BGSCAN:
1806 // if ((vap->iv_caps & IEEE80211_C_BGSCAN) == 0)
1808 // vap->iv_flags |= IEEE80211_F_BGSCAN;
1811 // vap->iv_flags &= ~IEEE80211_F_BGSCAN;
1812 // ieee80211_cancel_scan(vap); /* anything current */
1815 // case IEEE80211_PARAM_BGSCAN_IDLE:
1816 // if (value >= IEEE80211_BGSCAN_IDLE_MIN)
1817 // vap->iv_bgscanidle = value*HZ/1000;
1821 // case IEEE80211_PARAM_BGSCAN_INTERVAL:
1822 // if (value >= IEEE80211_BGSCAN_INTVAL_MIN)
1823 // vap->iv_bgscanintvl = value*HZ;
1827 // case IEEE80211_PARAM_MCAST_RATE:
1828 // /* units are in KILObits per second */
1829 // if (value >= 256 && value <= 54000)
1830 // vap->iv_mcast_rate = value;
1834 // case IEEE80211_PARAM_COVERAGE_CLASS:
1835 // if (value >= 0 && value <= IEEE80211_COVERAGE_CLASS_MAX) {
1836 // ic->ic_coverageclass = value;
1837 // if (IS_UP_AUTO(vap))
1838 // ieee80211_new_state(vap, IEEE80211_S_SCAN, 0);
1844 // case IEEE80211_PARAM_COUNTRY_IE:
1846 // ic->ic_flags_ext |= IEEE80211_FEXT_COUNTRYIE;
1848 // ic->ic_flags_ext &= ~IEEE80211_FEXT_COUNTRYIE;
1849 // retv = ENETRESET;
1851 // case IEEE80211_PARAM_REGCLASS:
1853 // ic->ic_flags_ext |= IEEE80211_FEXT_REGCLASS;
1855 // ic->ic_flags_ext &= ~IEEE80211_FEXT_REGCLASS;
1856 // retv = ENETRESET;
1858 // case IEEE80211_PARAM_SCANVALID:
1859 // vap->iv_scanvalid = value*HZ;
1861 // case IEEE80211_PARAM_ROAM_RSSI_11A:
1862 // vap->iv_roam.rssi11a = value;
1864 // case IEEE80211_PARAM_ROAM_RSSI_11B:
1865 // vap->iv_roam.rssi11bOnly = value;
1867 // case IEEE80211_PARAM_ROAM_RSSI_11G:
1868 // vap->iv_roam.rssi11b = value;
1870 // case IEEE80211_PARAM_ROAM_RATE_11A:
1871 // vap->iv_roam.rate11a = value;
1873 // case IEEE80211_PARAM_ROAM_RATE_11B:
1874 // vap->iv_roam.rate11bOnly = value;
1876 // case IEEE80211_PARAM_ROAM_RATE_11G:
1877 // vap->iv_roam.rate11b = value;
1879 // case IEEE80211_PARAM_UAPSDINFO:
1880 // if (vap->iv_opmode == IEEE80211_M_HOSTAP) {
1881 // if (ic->ic_caps & IEEE80211_C_UAPSD) {
1883 // IEEE80211_VAP_UAPSD_ENABLE(vap);
1885 // IEEE80211_VAP_UAPSD_DISABLE(vap);
1886 // retv = ENETRESET;
1889 // else if (vap->iv_opmode == IEEE80211_M_STA) {
1890 // vap->iv_uapsdinfo = value;
1891 // IEEE80211_VAP_UAPSD_ENABLE(vap);
1892 // retv = ENETRESET;
1895 // case IEEE80211_PARAM_SLEEP:
1896 // /* XXX: Forced sleep for testing. Does not actually place the
1897 // * HW in sleep mode yet. this only makes sense for STAs.
1901 // IEEE80211_VAP_GOTOSLEEP(vap);
1905 // IEEE80211_VAP_WAKEUP(vap);
1907 // ieee80211_send_nulldata(ieee80211_ref_node(vap->iv_bss));
1909 // case IEEE80211_PARAM_QOSNULL:
1910 // /* Force a QoS Null for testing. */
1911 // ieee80211_send_qosnulldata(vap->iv_bss, value);
1913 // case IEEE80211_PARAM_PSPOLL:
1914 // /* Force a PS-POLL for testing. */
1915 // ieee80211_send_pspoll(vap->iv_bss);
1917 // case IEEE80211_PARAM_EOSPDROP:
1918 // if (vap->iv_opmode == IEEE80211_M_HOSTAP) {
1919 // if (value) IEEE80211_VAP_EOSPDROP_ENABLE(vap);
1920 // else IEEE80211_VAP_EOSPDROP_DISABLE(vap);
1923 // case IEEE80211_PARAM_MARKDFS:
1925 // ic->ic_flags_ext |= IEEE80211_FEXT_MARKDFS;
1927 // ic->ic_flags_ext &= ~IEEE80211_FEXT_MARKDFS;
1929 // case IEEE80211_PARAM_CHANBW:
1932 // ic->ic_chanbwflag = 0;
1935 // ic->ic_chanbwflag = IEEE80211_CHAN_HALF;
1938 // ic->ic_chanbwflag = IEEE80211_CHAN_QUARTER;
1945 // case IEEE80211_PARAM_SHORTPREAMBLE:
1947 // ic->ic_caps |= IEEE80211_C_SHPREAMBLE;
1949 // ic->ic_caps &= ~IEEE80211_C_SHPREAMBLE;
1951 // retv = ENETRESET;
1954 // retv = EOPNOTSUPP;
1957 // /* XXX should any of these cause a rescan? */
1958 // if (retv == ENETRESET)
1959 // retv = IS_UP_AUTO(vap) ? ieee80211_open(vap->iv_dev) : 0;
1963 int usbdrvwext_setmode(struct net_device
*dev
, struct iw_request_info
*info
,
1964 void *w
, char *extra
)
1969 int usbdrvwext_getmode(struct net_device
*dev
, struct iw_request_info
*info
,
1970 void *w
, char *extra
)
1972 //struct usbdrv_private *macp = dev->priv;
1973 struct iw_point
*wri
= (struct iw_point
*)extra
;
1977 return (copy_to_user(wri
->pointer
, mode
, 6) ? -EFAULT
: 0);
1980 int zfLnxPrivateIoctl(struct net_device
*dev
, struct zdap_ioctl
* zdreq
)
1982 //void* regp = macp->regp;
1991 case ZM_IOCTL_REG_READ
:
1992 zfiDbgReadReg(dev
, zdreq
->addr
);
1995 case ZM_IOCTL_REG_WRITE
:
1996 zfiDbgWriteReg(dev
, zdreq
->addr
, zdreq
->value
);
1999 case ZM_IOCTL_MEM_READ
:
2000 p
= (u32_t
*) bus_to_virt(zdreq
->addr
);
2001 printk(KERN_DEBUG
"usbdrv: read memory addr: 0x%08x value: 0x%08x\n", zdreq
->addr
, *p
);
2004 case ZM_IOCTL_MEM_WRITE
:
2005 p
= (u32_t
*) bus_to_virt(zdreq
->addr
);
2007 printk(KERN_DEBUG
"usbdrv: write value: 0x%08x to memory addr: 0x%08x\n", zdreq
->value
, zdreq
->addr
);
2010 case ZM_IOCTL_TALLY
:
2011 zfiWlanShowTally(dev
);
2013 zfiWlanResetTally(dev
);
2016 case ZM_IOCTL_TEST
:
2017 printk(KERN_DEBUG
"ZM_IOCTL_TEST:len=%d\n", zdreq
->addr
);
2018 //zfiWlanReadReg(dev, 0x10f400);
2019 //zfiWlanReadReg(dev, 0x10f404);
2020 printk("IOCTL TEST\n");
2023 for (i
=0; i
<zdreq
->addr
; i
++)
2029 printk("%02X ", (unsigned char)zdreq
->data
[i
]);
2035 #if 0 //For Test?? 1 to 0 by CWYang(-)
2039 /* Allocate a skb */
2040 s
= alloc_skb(2000, GFP_ATOMIC
);
2042 /* Copy data to skb */
2043 for (i
=0; i
<zdreq
->addr
; i
++)
2045 s
->data
[i
] = zdreq
->data
[i
];
2047 s
->len
= zdreq
->addr
;
2049 /* Call zfIdlRecv() */
2050 zfiRecv80211(dev
, s
, NULL
);
2057 /****************************** ZDCONFIG ******************************/
2058 case ZM_IOCTL_FRAG
:
2059 zfiWlanSetFragThreshold(dev
, zdreq
->addr
);
2063 zfiWlanSetRtsThreshold(dev
, zdreq
->addr
);
2066 case ZM_IOCTL_SCAN
:
2073 struct zsKeyInfo keyInfo
;
2076 for (i
=0; i
<29; i
++)
2081 for (i
=0; i
<zdreq
->addr
; i
++)
2083 key
[i
] = zdreq
->data
[i
];
2086 printk("key len=%d, key=%02x%02x%02x%02x%02x...\n",
2087 zdreq
->addr
, key
[0], key
[1], key
[2], key
[3], key
[4]);
2089 keyInfo
.keyLength
= zdreq
->addr
;
2090 keyInfo
.keyIndex
= 0;
2093 zfiWlanSetKey(dev
, keyInfo
);
2097 case ZM_IOCTL_RATE
:
2098 zfiWlanSetTxRate(dev
, zdreq
->addr
);
2101 case ZM_IOCTL_ENCRYPTION_MODE
:
2102 zfiWlanSetEncryMode(dev
, zdreq
->addr
);
2104 zfiWlanDisable(dev
, 0);
2108 case ZM_IOCTL_SIGNAL_STRENGTH
:
2111 zfiWlanQuerySignalInfo(dev
, &buffer
[0]);
2112 printk("Current Signal Strength : %02d\n", buffer
[0]);
2116 case ZM_IOCTL_SIGNAL_QUALITY
:
2119 zfiWlanQuerySignalInfo(dev
, &buffer
[0]);
2120 printk("Current Signal Quality : %02d\n", buffer
[1]);
2124 case ZM_IOCTL_SET_PIBSS_MODE
:
2125 if (zdreq
->addr
== 1)
2126 zfiWlanSetWlanMode(dev
, ZM_MODE_PSEUDO
);
2128 zfiWlanSetWlanMode(dev
, ZM_MODE_INFRASTRUCTURE
);
2130 zfiWlanDisable(dev
, 0);
2134 /****************************** ZDCONFIG ******************************/
2137 printk(KERN_ERR
"usbdrv: error command = %x\n", cmd
);
2144 int usbdrv_wpa_ioctl(struct net_device
*dev
, struct athr_wlan_param
*zdparm
)
2147 u8_t bc_addr
[6] = { 0xff, 0xff, 0xff, 0xff, 0xff, 0xff };
2149 struct zsKeyInfo keyInfo
;
2150 struct usbdrv_private
*macp
= dev
->priv
;
2153 //zmw_get_wlan_dev(dev);
2157 case ZD_CMD_SET_ENCRYPT_KEY
:
2159 /* Set up key information */
2160 keyInfo
.keyLength
= zdparm
->u
.crypt
.key_len
;
2161 keyInfo
.keyIndex
= zdparm
->u
.crypt
.idx
;
2162 if (zfiWlanQueryWlanMode(dev
) == ZM_MODE_AP
) // AP Mode
2163 keyInfo
.flag
= ZM_KEY_FLAG_AUTHENTICATOR
;
2166 keyInfo
.key
= zdparm
->u
.crypt
.key
;
2167 keyInfo
.initIv
= zdparm
->u
.crypt
.seq
;
2168 keyInfo
.macAddr
= (u16_t
*)zdparm
->sta_addr
;
2170 /* Identify the MAC address information */
2171 if (memcmp(zdparm
->sta_addr
, bc_addr
, sizeof(bc_addr
)) == 0)
2173 keyInfo
.flag
|= ZM_KEY_FLAG_GK
;
2177 keyInfo
.flag
|= ZM_KEY_FLAG_PK
;
2180 if (!strcmp(zdparm
->u
.crypt
.alg
, "NONE"))
2182 //u8_t zero_mac[]={0,0,0,0,0,0};
2184 /* Set key length to zero */
2185 keyInfo
.keyLength
= 0;
2187 if (zdparm
->sta_addr
[0] & 1)//del group key
2189 //if (macp->cardSetting.WPAIeLen==0)
2190 //{//802.1x dynamic WEP
2192 // mKeyFormat[0] = 0;
2193 // mPrivacyInvoked[0]=FALSE;
2194 // mCap[0] &= ~CAP_PRIVACY;
2195 // macp->cardSetting.EncryOnOff[0]=0;
2197 //mWpaBcKeyLen = mGkInstalled = 0;
2201 //if (memcmp(zero_mac,zdparm->sta_addr, 6)==0)
2205 // pSetting->DynKeyMode=0;
2206 // pSetting->EncryMode[0]=0;
2211 printk(KERN_ERR
"Set Encryption Type NONE\n");
2214 else if (!strcmp(zdparm
->u
.crypt
.alg
, "TKIP"))
2216 zfiWlanSetEncryMode(dev
, ZM_TKIP
);
2217 //Linux Supplicant will inverse Tx/Rx key
2218 //So we inverse it back //CWYang(+)
2219 //zfMemoryCopy(&temp[0], &keyInfo.key[16], 8);
2220 //zfMemoryCopy(&keyInfo.key[16], keyInfo.key[24], 8);
2221 //zfMemoryCopy(&keyInfo.key[24], &temp[0], 8);
2224 //for (k = 0; k < 8; k++)
2226 // temp = keyInfo.key[16 + k];
2227 // keyInfo.key[16 + k] = keyInfo.key[24 + k];
2228 // keyInfo.key[24 + k] = temp;
2230 //CamEncryType = ZM_TKIP;
2233 // mKeyFormat[0] = CamEncryType;
2234 // mDynKeyMode = pSetting->DynKeyMode = DYN_KEY_TKIP;
2237 else if (!strcmp(zdparm
->u
.crypt
.alg
, "CCMP"))
2239 zfiWlanSetEncryMode(dev
, ZM_AES
);
2240 //CamEncryType = ZM_AES;
2243 // mKeyFormat[0] = CamEncryType;
2244 // mDynKeyMode = pSetting->DynKeyMode = DYN_KEY_AES;
2247 else if (!strcmp(zdparm
->u
.crypt
.alg
, "WEP"))
2249 if (keyInfo
.keyLength
== 5)
2251 zfiWlanSetEncryMode(dev
, ZM_WEP64
);
2252 // CamEncryType = ZM_WEP64;
2253 // tmpDynKeyMode=DYN_KEY_WEP64;
2255 else if (keyInfo
.keyLength
== 13)
2256 {//keylen=13, WEP 128
2257 zfiWlanSetEncryMode(dev
, ZM_WEP128
);
2258 // CamEncryType = ZM_WEP128;
2259 // tmpDynKeyMode=DYN_KEY_WEP128;
2263 zfiWlanSetEncryMode(dev
, ZM_WEP256
);
2266 // For Dynamic WEP key (Non-WPA Radius), the key ID range: 0-3
2267 // In WPA/RSN mode, the key ID range: 1-3, usually, a broadcast key.
2268 // For WEP key setting: we set mDynKeyMode and mKeyFormat in following case:
2269 // 1. For 802.1x dynamically generated WEP key method.
2270 // 2. For WPA/RSN mode, but key id == 0. (But this is an impossible case)
2271 // So, only check case 1.
2272 //if (macp->cardSetting.WPAIeLen==0)
2274 // mKeyFormat[0] = CamEncryType;
2275 // mDynKeyMode = pSetting->DynKeyMode = tmpDynKeyMode;
2276 // mPrivacyInvoked[0]=TRUE;
2277 // mCap[0] |= CAP_PRIVACY;
2278 // macp->cardSetting.EncryOnOff[0]=1;
2282 /* DUMP key context */
2284 if (keyInfo
.keyLength
> 0)
2287 printk("Otus: Key Context:\n");
2288 for(ii
= 0; ii
< keyInfo
.keyLength
;)
2290 printk("0x%02x ", keyInfo
.key
[ii
]);
2291 if((++ii
% 16) == 0)
2298 /* Set encrypt mode */
2299 //zfiWlanSetEncryMode(dev, CamEncryType);
2300 vapId
= zfLnxGetVapId(dev
);
2301 if (vapId
== 0xffff)
2304 keyInfo
.vapId
= vapId
+ 1;
2305 keyInfo
.vapAddr
[0] = keyInfo
.macAddr
[0];
2306 keyInfo
.vapAddr
[1] = keyInfo
.macAddr
[1];
2307 keyInfo
.vapAddr
[2] = keyInfo
.macAddr
[2];
2309 zfiWlanSetKey(dev
, keyInfo
);
2311 //zfiWlanDisable(dev);
2312 //zfiWlanEnable(dev);
2315 case ZD_CMD_SET_MLME
:
2316 printk(KERN_ERR
"usbdrv_wpa_ioctl: ZD_CMD_SET_MLME\n");
2318 /* Translate STA's address */
2319 sprintf(mac_addr
, "%02x:%02x:%02x:%02x:%02x:%02x", zdparm
->sta_addr
[0], zdparm
->sta_addr
[1],
2320 zdparm
->sta_addr
[2], zdparm
->sta_addr
[3], zdparm
->sta_addr
[4], zdparm
->sta_addr
[5]);
2322 switch(zdparm
->u
.mlme
.cmd
)
2324 case MLME_STA_DEAUTH
:
2325 printk(" -------Call zfiWlanDeauth, reason:%d\n",zdparm
->u
.mlme
.reason_code
);
2326 if(zfiWlanDeauth(dev
, (u16_t
*) zdparm
->sta_addr
, zdparm
->u
.mlme
.reason_code
) != 0)
2327 printk(KERN_ERR
"Can't deauthencate STA: %s\n", mac_addr
);
2329 printk(KERN_ERR
"Deauthenticate STA: %s with reason code: %d\n", mac_addr
, zdparm
->u
.mlme
.reason_code
);
2332 case MLME_STA_DISASSOC
:
2333 printk(" -------Call zfiWlanDeauth, reason:%d\n",zdparm
->u
.mlme
.reason_code
);
2334 if(zfiWlanDeauth(dev
, (u16_t
*) zdparm
->sta_addr
, zdparm
->u
.mlme
.reason_code
) != 0)
2335 printk(KERN_ERR
"Can't disassociate STA: %s\n", mac_addr
);
2337 printk(KERN_ERR
"Disassociate STA: %s with reason code: %d\n", mac_addr
, zdparm
->u
.mlme
.reason_code
);
2341 printk(KERN_ERR
"MLME command: 0x%04x not support\n", zdparm
->u
.mlme
.cmd
);
2347 case ZD_CMD_SCAN_REQ
:
2348 printk(KERN_ERR
"usbdrv_wpa_ioctl: ZD_CMD_SCAN_REQ\n");
2351 case ZD_CMD_SET_GENERIC_ELEMENT
:
2352 printk(KERN_ERR
"usbdrv_wpa_ioctl: ZD_CMD_SET_GENERIC_ELEMENT\n");
2354 /* Copy the WPA IE */
2355 //zm_msg1_mm(ZM_LV_0, "CWY - wpaie Length : ", zdparm->u.generic_elem.len);
2356 printk(KERN_ERR
"wpaie Length : %d\n", zdparm
->u
.generic_elem
.len
);
2357 if (zfiWlanQueryWlanMode(dev
) == ZM_MODE_AP
) // AP Mode
2359 zfiWlanSetWpaIe(dev
, zdparm
->u
.generic_elem
.data
, zdparm
->u
.generic_elem
.len
);
2363 macp
->supLen
= zdparm
->u
.generic_elem
.len
;
2364 memcpy(macp
->supIe
, zdparm
->u
.generic_elem
.data
, zdparm
->u
.generic_elem
.len
);
2366 zfiWlanSetWpaSupport(dev
, 1);
2367 //zfiWlanSetWpaIe(dev, zdparm->u.generic_elem.data, zdparm->u.generic_elem.len);
2370 u8_t len
= zdparm
->u
.generic_elem
.len
;
2371 u8_t
*wpaie
= (u8_t
*)zdparm
->u
.generic_elem
.data
;
2373 printk(KERN_ERR
"wd->ap.wpaLen: %d\n", len
);
2376 for(ii
= 0; ii
< len
;)
2378 printk(KERN_ERR
"0x%02x ", wpaie
[ii
]);
2380 if((++ii
% 16) == 0)
2381 printk(KERN_ERR
"\n");
2383 printk(KERN_ERR
"\n");
2386 // #ifdef ZM_HOSTAPD_SUPPORT
2387 //if (wd->wlanMode == ZM_MODE_AP)
2388 //{// Update Beacon FIFO in the next TBTT.
2389 // memcpy(&mWPAIe, pSetting->WPAIe, pSetting->WPAIeLen);
2390 // printk(KERN_ERR "Copy WPA IE into mWPAIe\n");
2395 // #ifdef ZM_HOSTAPD_SUPPORT
2396 case ZD_CMD_GET_TSC
:
2397 printk(KERN_ERR
"usbdrv_wpa_ioctl: ZD_CMD_GET_TSC\n");
2402 printk(KERN_ERR
"usbdrv_wpa_ioctl default: 0x%04x\n", zdparm
->cmd
);
2410 #ifdef ZM_ENABLE_CENC
2411 int usbdrv_cenc_ioctl(struct net_device
*dev
, struct zydas_cenc_param
*zdparm
)
2413 //struct usbdrv_private *macp = (struct usbdrv_private *)dev->priv;
2414 struct zsKeyInfo keyInfo
;
2416 u8_t bc_addr
[6] = { 0xff, 0xff, 0xff, 0xff, 0xff, 0xff };
2421 apId
= zfLnxGetVapId(dev
);
2432 switch (zdparm
->cmd
)
2434 case ZM_CMD_CENC_SETCENC
:
2435 printk(KERN_ERR
"ZM_CMD_CENC_SETCENC\n");
2436 printk(KERN_ERR
"length: %d\n", zdparm
->len
);
2437 printk(KERN_ERR
"policy: %d\n", zdparm
->u
.info
.cenc_policy
);
2439 case ZM_CMD_CENC_SETKEY
:
2440 //ret = wai_ioctl_setkey(vap, ioctl_msg);
2441 printk(KERN_ERR
"ZM_CMD_CENC_SETKEY\n");
2443 printk(KERN_ERR
"MAC address= ");
2444 for(ii
= 0; ii
< 6; ii
++)
2446 printk(KERN_ERR
"0x%02x ", zdparm
->u
.crypt
.sta_addr
[ii
]);
2448 printk(KERN_ERR
"\n");
2450 printk(KERN_ERR
"Key Index: %d\n", zdparm
->u
.crypt
.keyid
);
2451 printk(KERN_ERR
"Encryption key= ");
2452 for(ii
= 0; ii
< 16; ii
++)
2454 printk(KERN_ERR
"0x%02x ", zdparm
->u
.crypt
.key
[ii
]);
2456 printk(KERN_ERR
"\n");
2458 printk(KERN_ERR
"MIC key= ");
2459 for(ii
= 16; ii
< ZM_CENC_KEY_SIZE
; ii
++)
2461 printk(KERN_ERR
"0x%02x ", zdparm
->u
.crypt
.key
[ii
]);
2463 printk(KERN_ERR
"\n");
2465 /* Set up key information */
2466 keyInfo
.keyLength
= ZM_CENC_KEY_SIZE
;
2467 keyInfo
.keyIndex
= zdparm
->u
.crypt
.keyid
;
2468 keyInfo
.flag
= ZM_KEY_FLAG_AUTHENTICATOR
| ZM_KEY_FLAG_CENC
;
2469 keyInfo
.key
= zdparm
->u
.crypt
.key
;
2470 keyInfo
.macAddr
= (u16_t
*)zdparm
->u
.crypt
.sta_addr
;
2472 /* Identify the MAC address information */
2473 if (memcmp(zdparm
->u
.crypt
.sta_addr
, bc_addr
, sizeof(bc_addr
)) == 0)
2475 keyInfo
.flag
|= ZM_KEY_FLAG_GK
;
2476 keyInfo
.vapId
= apId
;
2477 memcpy(keyInfo
.vapAddr
, dev
->dev_addr
, ETH_ALEN
);
2481 keyInfo
.flag
|= ZM_KEY_FLAG_PK
;
2484 zfiWlanSetKey(dev
, keyInfo
);
2487 case ZM_CMD_CENC_REKEY
:
2488 //ret = wai_ioctl_rekey(vap, ioctl_msg);
2489 printk(KERN_ERR
"ZM_CMD_CENC_REKEY\n");
2497 //if (retv == ENETRESET)
2498 // retv = IS_UP_AUTO(vap) ? ieee80211_open(vap->iv_dev) : 0;
2502 #endif //ZM_ENABLE_CENC
2503 /////////////////////////////////////////
2504 int usbdrv_ioctl(struct net_device
*dev
, struct ifreq
*ifr
, int cmd
)
2506 // struct usbdrv_private *macp;
2508 struct zdap_ioctl zdreq
;
2509 struct iwreq
*wrq
= (struct iwreq
*)ifr
;
2510 struct athr_wlan_param zdparm
;
2511 struct usbdrv_private
*macp
= dev
->priv
;
2516 // macp = dev->priv;
2517 // regp = macp->regp;
2519 if(!netif_running(dev
))
2525 strcpy(wrq
->u
.name
, "IEEE 802.11-DS");
2529 err
= usbdrvwext_giwap(dev
, NULL
, &wrq
->u
.ap_addr
, NULL
);
2534 err
= usbdrvwext_siwap(dev
, NULL
, &wrq
->u
.ap_addr
, NULL
);
2539 err
= usbdrvwext_giwmode(dev
, NULL
, &wrq
->u
.mode
, NULL
);
2544 printk(KERN_ERR
"CWY - usbdrvwext_siwessid\n");
2545 //err = usbdrv_ioctl_setessid(dev, &wrq->u.essid);
2546 err
= usbdrvwext_siwessid(dev
, NULL
, &wrq
->u
.essid
, NULL
);
2554 err
= usbdrvwext_giwessid(dev
, NULL
, &wrq
->u
.essid
, NULL
);
2560 err
= usbdrv_ioctl_setrts(dev
, &wrq
->u
.rts
);
2566 case SIOCIWFIRSTPRIV
+ 0x2: /* set_auth */
2568 //printk("CWY - SIOCIWFIRSTPRIV + 0x2 (set_auth)\n");
2569 if (! capable(CAP_NET_ADMIN
))
2575 int val
= *( (int *) wrq
->u
.name
);
2576 if ((val
< 0) || (val
> 2))
2583 zfiWlanSetAuthenticationMode(dev
, val
);
2585 if (macp
->DeviceOpened
== 1)
2587 zfiWlanDisable(dev
, 0);
2598 case SIOCIWFIRSTPRIV
+ 0x3: /* get_auth */
2600 int AuthMode
= ZM_AUTH_MODE_OPEN
;
2602 //printk("CWY - SIOCIWFIRSTPRIV + 0x3 (get_auth)\n");
2604 if (wrq
->u
.data
.pointer
)
2606 wrq
->u
.data
.flags
= 1;
2608 AuthMode
= zfiWlanQueryAuthenticationMode(dev
, 0);
2609 if (AuthMode
== ZM_AUTH_MODE_OPEN
)
2611 wrq
->u
.data
.length
= 12;
2613 if (copy_to_user(wrq
->u
.data
.pointer
, "open system", 12))
2618 else if (AuthMode
== ZM_AUTH_MODE_SHARED_KEY
)
2620 wrq
->u
.data
.length
= 11;
2622 if (copy_to_user(wrq
->u
.data
.pointer
, "shared key", 11))
2627 else if (AuthMode
== ZM_AUTH_MODE_AUTO
)
2629 wrq
->u
.data
.length
= 10;
2631 if (copy_to_user(wrq
->u
.data
.pointer
, "auto mode", 10))
2645 case ZDAPIOCTL
: //debug command
2646 if (copy_from_user(&zdreq
, ifr
->ifr_data
, sizeof (zdreq
)))
2648 printk(KERN_ERR
"usbdrv: copy_from_user error\n");
2652 //printk(KERN_DEBUG "usbdrv: cmd=%2x, reg=0x%04lx, value=0x%08lx\n",
2653 // zdreq.cmd, zdreq.addr, zdreq.value);
2655 zfLnxPrivateIoctl(dev
, &zdreq
);
2661 if (copy_from_user(&zdparm
, ifr
->ifr_data
, sizeof(struct athr_wlan_param
)))
2663 printk(KERN_ERR
"usbdrv: copy_from_user error\n");
2667 usbdrv_wpa_ioctl(dev
, &zdparm
);
2671 case ZD_IOCTL_PARAM
:
2677 /* Point to the name field and retrieve the
2678 * op and arg elements. */
2679 p
= (int *)wrq
->u
.name
;
2683 if(op
== ZD_PARAM_ROAMING
)
2685 printk(KERN_ERR
"************* ZD_PARAM_ROAMING: %d\n", arg
);
2686 //macp->cardSetting.ap_scan=(U8)arg;
2688 if(op
== ZD_PARAM_PRIVACY
)
2690 printk(KERN_ERR
"ZD_IOCTL_PRIVACY: ");
2692 /* Turn on the privacy invoke flag */
2695 // mCap[0] |= CAP_PRIVACY;
2696 // macp->cardSetting.EncryOnOff[0] = 1;
2697 printk(KERN_ERR
"enable\n");
2702 // mCap[0] &= ~CAP_PRIVACY;
2703 // macp->cardSetting.EncryOnOff[0] = 0;
2704 printk(KERN_ERR
"disable\n");
2708 if(op
== ZD_PARAM_WPA
)
2710 printk(KERN_ERR
"ZD_PARAM_WPA: ");
2714 printk(KERN_ERR
"enable\n");
2716 if (zfiWlanQueryWlanMode(dev
) != ZM_MODE_AP
)
2718 printk(KERN_ERR
"Station Mode\n");
2719 //zfiWlanQueryWpaIe(dev, (u8_t *)&wpaIe, &wpalen);
2720 //printk("wpaIe : %2x,%2x,%2x\n", wpaIe[21], wpaIe[22], wpaIe[23]);
2721 //printk("rsnIe : %2x,%2x,%2x\n", wpaIe[17], wpaIe[18], wpaIe[19]);
2722 if ((macp
->supIe
[21] == 0x50) &&
2723 (macp
->supIe
[22] == 0xf2) &&
2724 (macp
->supIe
[23] == 0x2))
2726 printk(KERN_ERR
"wd->sta.authMode = ZM_AUTH_MODE_WPAPSK\n");
2727 //wd->sta.authMode = ZM_AUTH_MODE_WPAPSK;
2728 //wd->ws.authMode = ZM_AUTH_MODE_WPAPSK;
2729 zfiWlanSetAuthenticationMode(dev
, ZM_AUTH_MODE_WPAPSK
);
2731 else if ((macp
->supIe
[21] == 0x50) &&
2732 (macp
->supIe
[22] == 0xf2) &&
2733 (macp
->supIe
[23] == 0x1))
2735 printk(KERN_ERR
"wd->sta.authMode = ZM_AUTH_MODE_WPA\n");
2736 //wd->sta.authMode = ZM_AUTH_MODE_WPA;
2737 //wd->ws.authMode = ZM_AUTH_MODE_WPA;
2738 zfiWlanSetAuthenticationMode(dev
, ZM_AUTH_MODE_WPA
);
2740 else if ((macp
->supIe
[17] == 0xf) &&
2741 (macp
->supIe
[18] == 0xac) &&
2742 (macp
->supIe
[19] == 0x2))
2744 printk(KERN_ERR
"wd->sta.authMode = ZM_AUTH_MODE_WPA2PSK\n");
2745 //wd->sta.authMode = ZM_AUTH_MODE_WPA2PSK;
2746 //wd->ws.authMode = ZM_AUTH_MODE_WPA2PSK;
2747 zfiWlanSetAuthenticationMode(dev
, ZM_AUTH_MODE_WPA2PSK
);
2749 else if ((macp
->supIe
[17] == 0xf) &&
2750 (macp
->supIe
[18] == 0xac) &&
2751 (macp
->supIe
[19] == 0x1))
2753 printk(KERN_ERR
"wd->sta.authMode = ZM_AUTH_MODE_WPA2\n");
2754 //wd->sta.authMode = ZM_AUTH_MODE_WPA2;
2755 //wd->ws.authMode = ZM_AUTH_MODE_WPA2;
2756 zfiWlanSetAuthenticationMode(dev
, ZM_AUTH_MODE_WPA2
);
2758 if ((macp
->supIe
[21] == 0x50) || (macp
->supIe
[22] == 0xf2))//WPA or WPAPSK
2760 if (macp
->supIe
[11] == 0x2)
2762 printk(KERN_ERR
"wd->sta.wepStatus = ZM_ENCRYPTION_TKIP\n");
2763 //wd->sta.wepStatus = ZM_ENCRYPTION_TKIP;
2764 //wd->ws.wepStatus = ZM_ENCRYPTION_TKIP;
2765 zfiWlanSetWepStatus(dev
, ZM_ENCRYPTION_TKIP
);
2769 printk(KERN_ERR
"wd->sta.wepStatus = ZM_ENCRYPTION_AES\n");
2770 //wd->sta.wepStatus = ZM_ENCRYPTION_AES;
2771 //wd->ws.wepStatus = ZM_ENCRYPTION_AES;
2772 zfiWlanSetWepStatus(dev
, ZM_ENCRYPTION_AES
);
2775 if ((macp
->supIe
[17] == 0xf) || (macp
->supIe
[18] == 0xac)) //WPA2 or WPA2PSK
2777 if (macp
->supIe
[13] == 0x2)
2779 printk(KERN_ERR
"wd->sta.wepStatus = ZM_ENCRYPTION_TKIP\n");
2780 //wd->sta.wepStatus = ZM_ENCRYPTION_TKIP;
2781 //wd->ws.wepStatus = ZM_ENCRYPTION_TKIP;
2782 zfiWlanSetWepStatus(dev
, ZM_ENCRYPTION_TKIP
);
2786 printk(KERN_ERR
"wd->sta.wepStatus = ZM_ENCRYPTION_AES\n");
2787 //wd->sta.wepStatus = ZM_ENCRYPTION_AES;
2788 //wd->ws.wepStatus = ZM_ENCRYPTION_AES;
2789 zfiWlanSetWepStatus(dev
, ZM_ENCRYPTION_AES
);
2793 zfiWlanSetWpaSupport(dev
, 1);
2797 /* Reset the WPA related variables */
2798 printk(KERN_ERR
"disable\n");
2800 zfiWlanSetWpaSupport(dev
, 0);
2801 zfiWlanSetAuthenticationMode(dev
, ZM_AUTH_MODE_OPEN
);
2802 zfiWlanSetWepStatus(dev
, ZM_ENCRYPTION_WEP_DISABLED
);
2804 /* Now we only set the length in the WPA IE
2806 //macp->cardSetting.WPAIe[1] = 0;
2809 if(op
== ZD_PARAM_COUNTERMEASURES
)
2811 printk(KERN_ERR
"================ZD_PARAM_COUNTERMEASURES: ");
2815 // mCounterMeasureState=1;
2816 printk(KERN_ERR
"enable\n");
2820 // mCounterMeasureState=0;
2821 printk(KERN_ERR
"disable\n");
2824 if(op
== ZD_PARAM_DROPUNENCRYPTED
)
2826 printk(KERN_ERR
"ZD_PARAM_DROPUNENCRYPTED: ");
2830 printk(KERN_ERR
"enable\n");
2834 printk(KERN_ERR
"disable\n");
2837 if(op
== ZD_PARAM_AUTH_ALGS
)
2839 printk(KERN_ERR
"ZD_PARAM_AUTH_ALGS: ");
2843 printk(KERN_ERR
"OPEN_SYSTEM\n");
2847 printk(KERN_ERR
"SHARED_KEY\n");
2850 if(op
== ZD_PARAM_WPS_FILTER
)
2852 printk(KERN_ERR
"ZD_PARAM_WPS_FILTER: ");
2856 // mCounterMeasureState=1;
2857 macp
->forwardMgmt
= 1;
2858 printk(KERN_ERR
"enable\n");
2862 // mCounterMeasureState=0;
2863 macp
->forwardMgmt
= 0;
2864 printk(KERN_ERR
"disable\n");
2871 case ZD_IOCTL_GETWPAIE
:
2873 struct ieee80211req_wpaie req_wpaie
;
2877 apId
= zfLnxGetVapId(dev
);
2888 if (copy_from_user(&req_wpaie
, ifr
->ifr_data
, sizeof(struct ieee80211req_wpaie
))){
2889 printk(KERN_ERR
"usbdrv: copy_from_user error\n");
2893 for(i
= 0; i
< ZM_OAL_MAX_STA_SUPPORT
; i
++)
2895 for(j
= 0; j
< IEEE80211_ADDR_LEN
; j
++)
2897 if (macp
->stawpaie
[i
].wpa_macaddr
[j
] != req_wpaie
.wpa_macaddr
[j
])
2903 if (i
< ZM_OAL_MAX_STA_SUPPORT
)
2905 //printk("ZD_IOCTL_GETWPAIE - sta index = %d\n", i);
2906 memcpy(req_wpaie
.wpa_ie
, macp
->stawpaie
[i
].wpa_ie
, IEEE80211_MAX_IE_SIZE
);
2909 if (copy_to_user(wrq
->u
.data
.pointer
, &req_wpaie
, sizeof(struct ieee80211req_wpaie
)))
2917 #ifdef ZM_ENABLE_CENC
2919 if (copy_from_user(&macp
->zd_wpa_req
, ifr
->ifr_data
, sizeof(struct athr_wlan_param
)))
2921 printk(KERN_ERR
"usbdrv: copy_from_user error\n");
2925 usbdrv_cenc_ioctl(dev
, (struct zydas_cenc_param
*)&macp
->zd_wpa_req
);
2928 #endif //ZM_ENABLE_CENC