2 * This file contains ioctl functions
4 #include <linux/ctype.h>
5 #include <linux/delay.h>
7 #include <linux/if_arp.h>
8 #include <linux/wireless.h>
9 #include <linux/bitops.h>
11 #include <net/ieee80211.h>
12 #include <net/iw_handler.h>
26 * @brief Convert mw value to dbm value
28 * @param mw the value of mw
29 * @return the value of dbm
31 static int mw_to_dbm(int mw)
72 * @brief Find the channel frequency power info with specific channel
74 * @param adapter A pointer to wlan_adapter structure
75 * @param band it can be BAND_A, BAND_G or BAND_B
76 * @param channel the channel for looking
77 * @return A pointer to struct chan_freq_power structure or NULL if not find.
79 struct chan_freq_power *libertas_find_cfp_by_band_and_channel(wlan_adapter * adapter,
82 struct chan_freq_power *cfp = NULL;
83 struct region_channel *rc;
84 int count = sizeof(adapter->region_channel) /
85 sizeof(adapter->region_channel[0]);
88 for (j = 0; !cfp && (j < count); j++) {
89 rc = &adapter->region_channel[j];
91 if (adapter->enable11d)
92 rc = &adapter->universal_channel[j];
93 if (!rc->valid || !rc->CFP)
97 for (i = 0; i < rc->nrcfp; i++) {
98 if (rc->CFP[i].channel == channel) {
106 lbs_pr_debug(1, "libertas_find_cfp_by_band_and_channel(): cannot find "
107 "cfp by band %d & channel %d\n", band, channel);
113 * @brief Find the channel frequency power info with specific frequency
115 * @param adapter A pointer to wlan_adapter structure
116 * @param band it can be BAND_A, BAND_G or BAND_B
117 * @param freq the frequency for looking
118 * @return A pointer to struct chan_freq_power structure or NULL if not find.
120 static struct chan_freq_power *find_cfp_by_band_and_freq(wlan_adapter * adapter,
123 struct chan_freq_power *cfp = NULL;
124 struct region_channel *rc;
125 int count = sizeof(adapter->region_channel) /
126 sizeof(adapter->region_channel[0]);
129 for (j = 0; !cfp && (j < count); j++) {
130 rc = &adapter->region_channel[j];
132 if (adapter->enable11d)
133 rc = &adapter->universal_channel[j];
134 if (!rc->valid || !rc->CFP)
136 if (rc->band != band)
138 for (i = 0; i < rc->nrcfp; i++) {
139 if (rc->CFP[i].freq == freq) {
147 lbs_pr_debug(1, "find_cfp_by_band_and_freql(): cannot find cfp by "
148 "band %d & freq %d\n", band, freq);
153 static int updatecurrentchannel(wlan_private * priv)
158 ** the channel in f/w could be out of sync, get the current channel
160 ret = libertas_prepare_and_send_command(priv, cmd_802_11_rf_channel,
161 cmd_opt_802_11_rf_channel_get,
162 cmd_option_waitforrsp, 0, NULL);
164 lbs_pr_debug(1, "Current channel = %d\n",
165 priv->adapter->curbssparams.channel);
170 static int setcurrentchannel(wlan_private * priv, int channel)
172 lbs_pr_debug(1, "Set channel = %d\n", channel);
175 ** Current channel is not set to adhocchannel requested, set channel
177 return (libertas_prepare_and_send_command(priv, cmd_802_11_rf_channel,
178 cmd_opt_802_11_rf_channel_set,
179 cmd_option_waitforrsp, 0, &channel));
182 static int changeadhocchannel(wlan_private * priv, int channel)
185 wlan_adapter *adapter = priv->adapter;
187 adapter->adhocchannel = channel;
189 updatecurrentchannel(priv);
191 if (adapter->curbssparams.channel == adapter->adhocchannel) {
192 /* adhocchannel is set to the current channel already */
197 lbs_pr_debug(1, "Updating channel from %d to %d\n",
198 adapter->curbssparams.channel, adapter->adhocchannel);
200 setcurrentchannel(priv, adapter->adhocchannel);
202 updatecurrentchannel(priv);
204 if (adapter->curbssparams.channel != adapter->adhocchannel) {
205 lbs_pr_debug(1, "failed to updated channel to %d, channel = %d\n",
206 adapter->adhocchannel, adapter->curbssparams.channel);
211 if (adapter->connect_status == libertas_connected) {
213 struct WLAN_802_11_SSID curadhocssid;
215 lbs_pr_debug(1, "channel Changed while in an IBSS\n");
217 /* Copy the current ssid */
218 memcpy(&curadhocssid, &adapter->curbssparams.ssid,
219 sizeof(struct WLAN_802_11_SSID));
221 /* Exit Adhoc mode */
222 lbs_pr_debug(1, "In changeadhocchannel(): Sending Adhoc Stop\n");
223 ret = libertas_stop_adhoc_network(priv);
229 /* Scan for the network, do not save previous results. Stale
230 * scan data will cause us to join a non-existant adhoc network
232 libertas_send_specific_SSID_scan(priv, &curadhocssid, 0);
234 // find out the BSSID that matches the current SSID
235 i = libertas_find_SSID_in_list(adapter, &curadhocssid, NULL,
239 lbs_pr_debug(1, "SSID found at %d in List,"
241 libertas_join_adhoc_network(priv, &adapter->scantable[i]);
243 // else send START command
244 lbs_pr_debug(1, "SSID not found in list, "
245 "so creating adhoc with ssid = %s\n",
247 libertas_start_adhoc_network(priv, &curadhocssid);
248 } // end of else (START command)
256 * @brief Set Radio On/OFF
258 * @param priv A pointer to wlan_private structure
259 * @option Radio Option
260 * @return 0 --success, otherwise fail
262 int wlan_radio_ioctl(wlan_private * priv, u8 option)
265 wlan_adapter *adapter = priv->adapter;
269 if (adapter->radioon != option) {
270 lbs_pr_debug(1, "Switching %s the Radio\n", option ? "On" : "Off");
271 adapter->radioon = option;
273 ret = libertas_prepare_and_send_command(priv,
274 cmd_802_11_radio_control,
276 cmd_option_waitforrsp, 0, NULL);
286 * @param dest A pointer to Dest Buf
287 * @param src A pointer to Src Buf
288 * @param len The len of Src Buf
289 * @return Number of rates copyed
291 static inline int copyrates(u8 * dest, int pos, u8 * src, int len)
295 for (i = 0; i < len && src[i]; i++, pos++) {
296 if (pos >= sizeof(u8) * WLAN_SUPPORTED_RATES)
305 * @brief Get active data rates
307 * @param adapter A pointer to wlan_adapter structure
308 * @param rate The buf to return the active rates
309 * @return The number of rates
311 static int get_active_data_rates(wlan_adapter * adapter,
318 if (adapter->connect_status != libertas_connected) {
319 if (adapter->inframode == wlan802_11infrastructure) {
321 lbs_pr_debug(1, "Infra\n");
322 k = copyrates(rates, k, libertas_supported_rates,
323 sizeof(libertas_supported_rates));
326 lbs_pr_debug(1, "Adhoc G\n");
327 k = copyrates(rates, k, libertas_adhoc_rates_g,
328 sizeof(libertas_adhoc_rates_g));
331 k = copyrates(rates, 0, adapter->curbssparams.datarates,
332 adapter->curbssparams.numofrates);
340 static int wlan_get_name(struct net_device *dev, struct iw_request_info *info,
341 char *cwrq, char *extra)
344 char comm[6] = { "COMM-" };
345 char mrvl[6] = { "MRVL-" };
352 cp = strstr(libertas_driver_version, comm);
353 if (cp == libertas_driver_version) //skip leading "COMM-"
354 cp = libertas_driver_version + strlen(comm);
356 cp = libertas_driver_version;
360 while (cnt < 16 && (*cp != '-')) {
361 *cwrq++ = toupper(*cp++);
371 static int wlan_get_freq(struct net_device *dev, struct iw_request_info *info,
372 struct iw_freq *fwrq, char *extra)
374 wlan_private *priv = dev->priv;
375 wlan_adapter *adapter = priv->adapter;
376 struct chan_freq_power *cfp;
380 cfp = libertas_find_cfp_by_band_and_channel(adapter, 0,
381 adapter->curbssparams.channel);
384 if (adapter->curbssparams.channel)
385 lbs_pr_debug(1, "Invalid channel=%d\n",
386 adapter->curbssparams.channel);
390 fwrq->m = (long)cfp->freq * 100000;
393 lbs_pr_debug(1, "freq=%u\n", fwrq->m);
399 static int wlan_get_wap(struct net_device *dev, struct iw_request_info *info,
400 struct sockaddr *awrq, char *extra)
402 wlan_private *priv = dev->priv;
403 wlan_adapter *adapter = priv->adapter;
407 if (adapter->connect_status == libertas_connected) {
408 memcpy(awrq->sa_data, adapter->curbssparams.bssid, ETH_ALEN);
410 memset(awrq->sa_data, 0, ETH_ALEN);
412 awrq->sa_family = ARPHRD_ETHER;
418 static int wlan_set_nick(struct net_device *dev, struct iw_request_info *info,
419 struct iw_point *dwrq, char *extra)
421 wlan_private *priv = dev->priv;
422 wlan_adapter *adapter = priv->adapter;
427 * Check the size of the string
430 if (dwrq->length > 16) {
434 mutex_lock(&adapter->lock);
435 memset(adapter->nodename, 0, sizeof(adapter->nodename));
436 memcpy(adapter->nodename, extra, dwrq->length);
437 mutex_unlock(&adapter->lock);
443 static int wlan_get_nick(struct net_device *dev, struct iw_request_info *info,
444 struct iw_point *dwrq, char *extra)
446 wlan_private *priv = dev->priv;
447 wlan_adapter *adapter = priv->adapter;
452 * Get the Nick Name saved
455 mutex_lock(&adapter->lock);
456 strncpy(extra, adapter->nodename, 16);
457 mutex_unlock(&adapter->lock);
462 * If none, we may want to get the one that was set
468 dwrq->length = strlen(extra) + 1;
474 static int wlan_set_rts(struct net_device *dev, struct iw_request_info *info,
475 struct iw_param *vwrq, char *extra)
478 wlan_private *priv = dev->priv;
479 wlan_adapter *adapter = priv->adapter;
480 int rthr = vwrq->value;
484 if (vwrq->disabled) {
485 adapter->rtsthsd = rthr = MRVDRV_RTS_MAX_VALUE;
487 if (rthr < MRVDRV_RTS_MIN_VALUE || rthr > MRVDRV_RTS_MAX_VALUE)
489 adapter->rtsthsd = rthr;
492 ret = libertas_prepare_and_send_command(priv, cmd_802_11_snmp_mib,
493 cmd_act_set, cmd_option_waitforrsp,
494 OID_802_11_RTS_THRESHOLD, &rthr);
500 static int wlan_get_rts(struct net_device *dev, struct iw_request_info *info,
501 struct iw_param *vwrq, char *extra)
504 wlan_private *priv = dev->priv;
505 wlan_adapter *adapter = priv->adapter;
509 adapter->rtsthsd = 0;
510 ret = libertas_prepare_and_send_command(priv, cmd_802_11_snmp_mib,
511 cmd_act_get, cmd_option_waitforrsp,
512 OID_802_11_RTS_THRESHOLD, NULL);
518 vwrq->value = adapter->rtsthsd;
519 vwrq->disabled = ((vwrq->value < MRVDRV_RTS_MIN_VALUE)
520 || (vwrq->value > MRVDRV_RTS_MAX_VALUE));
527 static int wlan_set_frag(struct net_device *dev, struct iw_request_info *info,
528 struct iw_param *vwrq, char *extra)
531 int fthr = vwrq->value;
532 wlan_private *priv = dev->priv;
533 wlan_adapter *adapter = priv->adapter;
537 if (vwrq->disabled) {
538 adapter->fragthsd = fthr = MRVDRV_FRAG_MAX_VALUE;
540 if (fthr < MRVDRV_FRAG_MIN_VALUE
541 || fthr > MRVDRV_FRAG_MAX_VALUE)
543 adapter->fragthsd = fthr;
546 ret = libertas_prepare_and_send_command(priv, cmd_802_11_snmp_mib,
547 cmd_act_set, cmd_option_waitforrsp,
548 OID_802_11_FRAGMENTATION_THRESHOLD, &fthr);
553 static int wlan_get_frag(struct net_device *dev, struct iw_request_info *info,
554 struct iw_param *vwrq, char *extra)
557 wlan_private *priv = dev->priv;
558 wlan_adapter *adapter = priv->adapter;
562 adapter->fragthsd = 0;
563 ret = libertas_prepare_and_send_command(priv,
565 cmd_act_get, cmd_option_waitforrsp,
566 OID_802_11_FRAGMENTATION_THRESHOLD, NULL);
572 vwrq->value = adapter->fragthsd;
573 vwrq->disabled = ((vwrq->value < MRVDRV_FRAG_MIN_VALUE)
574 || (vwrq->value > MRVDRV_FRAG_MAX_VALUE));
581 static int wlan_get_mode(struct net_device *dev,
582 struct iw_request_info *info, u32 * uwrq, char *extra)
584 wlan_private *priv = dev->priv;
585 wlan_adapter *adapter = priv->adapter;
589 switch (adapter->inframode) {
591 *uwrq = IW_MODE_ADHOC;
594 case wlan802_11infrastructure:
595 *uwrq = IW_MODE_INFRA;
599 case wlan802_11autounknown:
600 *uwrq = IW_MODE_AUTO;
608 static int wlan_get_txpow(struct net_device *dev,
609 struct iw_request_info *info,
610 struct iw_param *vwrq, char *extra)
613 wlan_private *priv = dev->priv;
614 wlan_adapter *adapter = priv->adapter;
618 ret = libertas_prepare_and_send_command(priv,
619 cmd_802_11_rf_tx_power,
620 cmd_act_tx_power_opt_get,
621 cmd_option_waitforrsp, 0, NULL);
628 lbs_pr_debug(1, "TXPOWER GET %d dbm.\n", adapter->txpowerlevel);
629 vwrq->value = adapter->txpowerlevel;
631 if (adapter->radioon) {
633 vwrq->flags = IW_TXPOW_DBM;
642 static int wlan_set_retry(struct net_device *dev, struct iw_request_info *info,
643 struct iw_param *vwrq, char *extra)
646 wlan_private *priv = dev->priv;
647 wlan_adapter *adapter = priv->adapter;
651 if (vwrq->flags == IW_RETRY_LIMIT) {
652 /* The MAC has a 4-bit Total_Tx_Count register
653 Total_Tx_Count = 1 + Tx_Retry_Count */
654 #define TX_RETRY_MIN 0
655 #define TX_RETRY_MAX 14
656 if (vwrq->value < TX_RETRY_MIN || vwrq->value > TX_RETRY_MAX)
659 /* Adding 1 to convert retry count to try count */
660 adapter->txretrycount = vwrq->value + 1;
662 ret = libertas_prepare_and_send_command(priv, cmd_802_11_snmp_mib,
664 cmd_option_waitforrsp,
665 OID_802_11_TX_RETRYCOUNT, NULL);
679 static int wlan_get_retry(struct net_device *dev, struct iw_request_info *info,
680 struct iw_param *vwrq, char *extra)
682 wlan_private *priv = dev->priv;
683 wlan_adapter *adapter = priv->adapter;
687 adapter->txretrycount = 0;
688 ret = libertas_prepare_and_send_command(priv,
690 cmd_act_get, cmd_option_waitforrsp,
691 OID_802_11_TX_RETRYCOUNT, NULL);
698 vwrq->flags = IW_RETRY_LIMIT;
699 /* Subtract 1 to convert try count to retry count */
700 vwrq->value = adapter->txretrycount - 1;
707 static inline void sort_channels(struct iw_freq *freq, int num)
712 for (i = 0; i < num; i++)
713 for (j = i + 1; j < num; j++)
714 if (freq[i].i > freq[j].i) {
718 freq[i].i = freq[j].i;
719 freq[i].m = freq[j].m;
729 Infra G(12) A(8) B(4) G(12)
730 Adhoc A+B(12) A(8) B(4) B(4)
738 * @brief Get Range Info
740 * @param dev A pointer to net_device structure
741 * @param info A pointer to iw_request_info structure
742 * @param vwrq A pointer to iw_param structure
743 * @param extra A pointer to extra data buf
744 * @return 0 --success, otherwise fail
746 static int wlan_get_range(struct net_device *dev, struct iw_request_info *info,
747 struct iw_point *dwrq, char *extra)
750 wlan_private *priv = dev->priv;
751 wlan_adapter *adapter = priv->adapter;
752 struct iw_range *range = (struct iw_range *)extra;
753 struct chan_freq_power *cfp;
754 u8 rates[WLAN_SUPPORTED_RATES];
760 dwrq->length = sizeof(struct iw_range);
761 memset(range, 0, sizeof(struct iw_range));
766 memset(rates, 0, sizeof(rates));
767 range->num_bitrates = get_active_data_rates(adapter, rates);
769 for (i = 0; i < min_t(__u8, range->num_bitrates, IW_MAX_BITRATES) && rates[i];
771 range->bitrate[i] = (rates[i] & 0x7f) * 500000;
773 range->num_bitrates = i;
774 lbs_pr_debug(1, "IW_MAX_BITRATES=%d num_bitrates=%d\n", IW_MAX_BITRATES,
775 range->num_bitrates);
777 range->num_frequency = 0;
778 if (priv->adapter->enable11d &&
779 adapter->connect_status == libertas_connected) {
783 struct parsed_region_chan_11d *parsed_region_chan =
784 &adapter->parsed_region_chan;
786 if (parsed_region_chan == NULL) {
787 lbs_pr_debug(1, "11D:parsed_region_chan is NULL\n");
791 band = parsed_region_chan->band;
792 lbs_pr_debug(1, "band=%d NoOfChan=%d\n", band,
793 parsed_region_chan->nr_chan);
795 for (i = 0; (range->num_frequency < IW_MAX_FREQUENCIES)
796 && (i < parsed_region_chan->nr_chan); i++) {
797 chan_no = parsed_region_chan->chanpwr[i].chan;
798 lbs_pr_debug(1, "chan_no=%d\n", chan_no);
799 range->freq[range->num_frequency].i = (long)chan_no;
800 range->freq[range->num_frequency].m =
801 (long)libertas_chan_2_freq(chan_no, band) * 100000;
802 range->freq[range->num_frequency].e = 1;
803 range->num_frequency++;
808 for (j = 0; (range->num_frequency < IW_MAX_FREQUENCIES)
809 && (j < sizeof(adapter->region_channel)
810 / sizeof(adapter->region_channel[0])); j++) {
811 cfp = adapter->region_channel[j].CFP;
812 for (i = 0; (range->num_frequency < IW_MAX_FREQUENCIES)
813 && adapter->region_channel[j].valid
815 && (i < adapter->region_channel[j].nrcfp); i++) {
816 range->freq[range->num_frequency].i =
818 range->freq[range->num_frequency].m =
819 (long)cfp->freq * 100000;
820 range->freq[range->num_frequency].e = 1;
822 range->num_frequency++;
827 lbs_pr_debug(1, "IW_MAX_FREQUENCIES=%d num_frequency=%d\n",
828 IW_MAX_FREQUENCIES, range->num_frequency);
830 range->num_channels = range->num_frequency;
832 sort_channels(&range->freq[0], range->num_frequency);
835 * Set an indication of the max TCP throughput in bit/s that we can
836 * expect using this interface
839 range->throughput = 5000 * 1000;
841 range->throughput = 1500 * 1000;
843 range->min_rts = MRVDRV_RTS_MIN_VALUE;
844 range->max_rts = MRVDRV_RTS_MAX_VALUE;
845 range->min_frag = MRVDRV_FRAG_MIN_VALUE;
846 range->max_frag = MRVDRV_FRAG_MAX_VALUE;
848 range->encoding_size[0] = 5;
849 range->encoding_size[1] = 13;
850 range->num_encoding_sizes = 2;
851 range->max_encoding_tokens = 4;
853 range->min_pmp = 1000000;
854 range->max_pmp = 120000000;
855 range->min_pmt = 1000;
856 range->max_pmt = 1000000;
857 range->pmp_flags = IW_POWER_PERIOD;
858 range->pmt_flags = IW_POWER_TIMEOUT;
859 range->pm_capa = IW_POWER_PERIOD | IW_POWER_TIMEOUT | IW_POWER_ALL_R;
862 * Minimum version we recommend
864 range->we_version_source = 15;
867 * Version we are compiled with
869 range->we_version_compiled = WIRELESS_EXT;
871 range->retry_capa = IW_RETRY_LIMIT;
872 range->retry_flags = IW_RETRY_LIMIT | IW_RETRY_MAX;
874 range->min_retry = TX_RETRY_MIN;
875 range->max_retry = TX_RETRY_MAX;
878 * Set the qual, level and noise range values
880 range->max_qual.qual = 100;
881 range->max_qual.level = 0;
882 range->max_qual.noise = 0;
883 range->max_qual.updated = IW_QUAL_ALL_UPDATED | IW_QUAL_DBM;
885 range->avg_qual.qual = 70;
886 /* TODO: Find real 'good' to 'bad' threshold value for RSSI */
887 range->avg_qual.level = 0;
888 range->avg_qual.noise = 0;
889 range->avg_qual.updated = IW_QUAL_ALL_UPDATED | IW_QUAL_DBM;
891 range->sensitivity = 0;
894 * Setup the supported power level ranges
896 memset(range->txpower, 0, sizeof(range->txpower));
897 range->txpower[0] = 5;
898 range->txpower[1] = 7;
899 range->txpower[2] = 9;
900 range->txpower[3] = 11;
901 range->txpower[4] = 13;
902 range->txpower[5] = 15;
903 range->txpower[6] = 17;
904 range->txpower[7] = 19;
906 range->num_txpower = 8;
907 range->txpower_capa = IW_TXPOW_DBM;
908 range->txpower_capa |= IW_TXPOW_RANGE;
910 range->event_capa[0] = (IW_EVENT_CAPA_K_0 |
911 IW_EVENT_CAPA_MASK(SIOCGIWAP) |
912 IW_EVENT_CAPA_MASK(SIOCGIWSCAN));
913 range->event_capa[1] = IW_EVENT_CAPA_K_1;
915 if (adapter->fwcapinfo & FW_CAPINFO_WPA) {
916 range->enc_capa = IW_ENC_CAPA_WPA
918 | IW_ENC_CAPA_CIPHER_TKIP
919 | IW_ENC_CAPA_CIPHER_CCMP;
926 static int wlan_set_power(struct net_device *dev, struct iw_request_info *info,
927 struct iw_param *vwrq, char *extra)
929 wlan_private *priv = dev->priv;
930 wlan_adapter *adapter = priv->adapter;
934 /* PS is currently supported only in Infrastructure mode
935 * Remove this check if it is to be supported in IBSS mode also
938 if (vwrq->disabled) {
939 adapter->psmode = wlan802_11powermodecam;
940 if (adapter->psstate != PS_STATE_FULL_POWER) {
941 libertas_ps_wakeup(priv, cmd_option_waitforrsp);
947 if ((vwrq->flags & IW_POWER_TYPE) == IW_POWER_TIMEOUT) {
949 "Setting power timeout command is not supported\n");
951 } else if ((vwrq->flags & IW_POWER_TYPE) == IW_POWER_PERIOD) {
952 lbs_pr_debug(1, "Setting power period command is not supported\n");
956 if (adapter->psmode != wlan802_11powermodecam) {
960 adapter->psmode = wlan802_11powermodemax_psp;
962 if (adapter->connect_status == libertas_connected) {
963 libertas_ps_sleep(priv, cmd_option_waitforrsp);
970 static int wlan_get_power(struct net_device *dev, struct iw_request_info *info,
971 struct iw_param *vwrq, char *extra)
973 wlan_private *priv = dev->priv;
974 wlan_adapter *adapter = priv->adapter;
979 mode = adapter->psmode;
981 if ((vwrq->disabled = (mode == wlan802_11powermodecam))
982 || adapter->connect_status == libertas_disconnected) {
994 * iwpriv settable callbacks
997 static const iw_handler wlan_private_handler[] = {
998 NULL, /* SIOCIWFIRSTPRIV */
1001 static const struct iw_priv_args wlan_private_args[] = {
1003 * { cmd, set_args, get_args, name }
1007 IW_PRIV_TYPE_CHAR | 8,
1008 IW_PRIV_TYPE_CHAR | 8,
1013 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1,
1014 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1,
1018 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1,
1019 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1,
1023 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1,
1024 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1,
1028 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1,
1029 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1,
1033 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1,
1034 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1,
1038 WLAN_SUBCMD_SET_PRESCAN,
1039 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1,
1040 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1,
1043 WLAN_SETONEINT_GETONEINT,
1044 IW_PRIV_TYPE_INT | 1,
1045 IW_PRIV_TYPE_INT | 1,
1048 WLAN_BEACON_INTERVAL,
1049 IW_PRIV_TYPE_INT | 1,
1050 IW_PRIV_TYPE_INT | 1,
1054 IW_PRIV_TYPE_INT | 1,
1055 IW_PRIV_TYPE_INT | 1,
1059 IW_PRIV_TYPE_INT | 1,
1060 IW_PRIV_TYPE_INT | 1,
1063 WLAN_NULLPKTINTERVAL,
1064 IW_PRIV_TYPE_INT | 1,
1065 IW_PRIV_TYPE_INT | 1,
1067 /* Using iwpriv sub-command feature */
1069 WLAN_SETONEINT_GETNONE, /* IOCTL: 24 */
1070 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1,
1075 WLAN_SUBCMD_SETRXANTENNA,
1076 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1,
1080 WLAN_SUBCMD_SETTXANTENNA,
1081 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1,
1086 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1,
1091 WLANSET8021XAUTHALG,
1092 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1,
1097 WLANSETENCRYPTIONMODE,
1098 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1,
1104 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1,
1108 WLAN_SET_LISTEN_INTERVAL,
1109 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1,
1113 WLAN_SET_MULTIPLE_DTIM,
1114 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1,
1118 WLAN_SET_ATIM_WINDOW,
1119 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1,
1124 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1,
1129 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1,
1134 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1,
1139 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1,
1144 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1,
1148 WLAN_SUBCMD_MESH_SET_TTL,
1149 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1,
1153 WLAN_SETNONE_GETONEINT,
1155 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1,
1160 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1,
1163 WLAN_GET_LISTEN_INTERVAL,
1165 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1,
1168 WLAN_GET_MULTIPLE_DTIM,
1170 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1,
1175 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1,
1180 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1,
1185 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1,
1190 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1,
1195 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1,
1198 WLAN_SUBCMD_FWT_CLEANUP,
1200 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1,
1203 WLAN_SUBCMD_FWT_TIME,
1205 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1,
1208 WLAN_SUBCMD_MESH_GET_TTL,
1210 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1,
1213 WLAN_SETNONE_GETTWELVE_CHAR,
1215 IW_PRIV_TYPE_CHAR | 12,
1218 WLAN_SUBCMD_GETRXANTENNA,
1220 IW_PRIV_TYPE_CHAR | 12,
1223 WLAN_SUBCMD_GETTXANTENNA,
1225 IW_PRIV_TYPE_CHAR | 12,
1230 IW_PRIV_TYPE_CHAR | 12,
1233 WLAN_SETNONE_GETNONE,
1268 WLAN_SUBCMD_FWT_RESET,
1273 WLAN_SUBCMD_BT_RESET,
1278 WLAN_SET128CHAR_GET128CHAR,
1279 IW_PRIV_TYPE_CHAR | 128,
1280 IW_PRIV_TYPE_CHAR | 128,
1285 IW_PRIV_TYPE_CHAR | 128,
1286 IW_PRIV_TYPE_CHAR | 128,
1290 IW_PRIV_TYPE_CHAR | 128,
1291 IW_PRIV_TYPE_CHAR | 128,
1294 WLAN_SUBCMD_BT_LIST,
1295 IW_PRIV_TYPE_CHAR | 128,
1296 IW_PRIV_TYPE_CHAR | 128,
1298 /* FWT Management */
1300 WLAN_SUBCMD_FWT_ADD,
1301 IW_PRIV_TYPE_CHAR | 128,
1302 IW_PRIV_TYPE_CHAR | 128,
1305 WLAN_SUBCMD_FWT_DEL,
1306 IW_PRIV_TYPE_CHAR | 128,
1307 IW_PRIV_TYPE_CHAR | 128,
1310 WLAN_SUBCMD_FWT_LOOKUP,
1311 IW_PRIV_TYPE_CHAR | 128,
1312 IW_PRIV_TYPE_CHAR | 128,
1315 WLAN_SUBCMD_FWT_LIST_NEIGHBOR,
1316 IW_PRIV_TYPE_CHAR | 128,
1317 IW_PRIV_TYPE_CHAR | 128,
1320 WLAN_SUBCMD_FWT_LIST,
1321 IW_PRIV_TYPE_CHAR | 128,
1322 IW_PRIV_TYPE_CHAR | 128,
1325 WLAN_SUBCMD_FWT_LIST_ROUTE,
1326 IW_PRIV_TYPE_CHAR | 128,
1327 IW_PRIV_TYPE_CHAR | 128,
1331 IW_PRIV_TYPE_CHAR | 128,
1332 IW_PRIV_TYPE_CHAR | 128,
1335 WLAN_GET_ADHOC_STATUS,
1336 IW_PRIV_TYPE_CHAR | 128,
1337 IW_PRIV_TYPE_CHAR | 128,
1340 WLAN_SETNONE_GETWORDCHAR,
1342 IW_PRIV_TYPE_CHAR | 128,
1346 IW_PRIV_TYPE_CHAR | IW_PRIV_SIZE_FIXED | 24,
1352 IW_PRIV_TYPE_CHAR | GETLOG_BUFSIZE,
1355 WLAN_SET_GET_SIXTEEN_INT,
1356 IW_PRIV_TYPE_INT | 16,
1357 IW_PRIV_TYPE_INT | 16,
1361 IW_PRIV_TYPE_INT | 16,
1362 IW_PRIV_TYPE_INT | 16,
1366 IW_PRIV_TYPE_INT | 16,
1367 IW_PRIV_TYPE_INT | 16,
1371 IW_PRIV_TYPE_INT | 16,
1372 IW_PRIV_TYPE_INT | 16,
1376 IW_PRIV_TYPE_INT | 16,
1377 IW_PRIV_TYPE_INT | 16,
1381 IW_PRIV_TYPE_INT | 16,
1382 IW_PRIV_TYPE_INT | 16,
1386 IW_PRIV_TYPE_INT | 16,
1387 IW_PRIV_TYPE_INT | 16,
1391 IW_PRIV_TYPE_INT | 16,
1392 IW_PRIV_TYPE_INT | 16,
1395 WLAN_INACTIVITY_TIMEOUT,
1396 IW_PRIV_TYPE_INT | 16,
1397 IW_PRIV_TYPE_INT | 16,
1401 IW_PRIV_TYPE_INT | 16,
1402 IW_PRIV_TYPE_INT | 16,
1406 IW_PRIV_TYPE_INT | 16,
1407 IW_PRIV_TYPE_INT | 16,
1411 IW_PRIV_TYPE_INT | 16,
1412 IW_PRIV_TYPE_INT | 16,
1416 static struct iw_statistics *wlan_get_wireless_stats(struct net_device *dev)
1426 wlan_private *priv = dev->priv;
1427 wlan_adapter *adapter = priv->adapter;
1431 int stats_valid = 0;
1437 priv->wstats.status = adapter->inframode;
1439 /* If we're not associated, all quality values are meaningless */
1440 if (adapter->connect_status != libertas_connected)
1443 /* Quality by RSSI */
1444 priv->wstats.qual.level =
1445 CAL_RSSI(adapter->SNR[TYPE_BEACON][TYPE_NOAVG],
1446 adapter->NF[TYPE_BEACON][TYPE_NOAVG]);
1448 if (adapter->NF[TYPE_BEACON][TYPE_NOAVG] == 0) {
1449 priv->wstats.qual.noise = MRVDRV_NF_DEFAULT_SCAN_VALUE;
1451 priv->wstats.qual.noise =
1452 CAL_NF(adapter->NF[TYPE_BEACON][TYPE_NOAVG]);
1455 lbs_pr_debug(1, "Signal Level = %#x\n", priv->wstats.qual.level);
1456 lbs_pr_debug(1, "Noise = %#x\n", priv->wstats.qual.noise);
1458 rssi = priv->wstats.qual.level - priv->wstats.qual.noise;
1460 rssi_qual = rssi * POOR / 10;
1462 rssi_qual = (rssi - 15) * (FAIR - POOR) / 5 + POOR;
1464 rssi_qual = (rssi - 20) * (GOOD - FAIR) / 5 + FAIR;
1466 rssi_qual = (rssi - 30) * (VERY_GOOD - GOOD) /
1469 rssi_qual = (rssi - 40) * (PERFECT - VERY_GOOD) /
1471 quality = rssi_qual;
1473 /* Quality by TX errors */
1474 priv->wstats.discard.retries = priv->stats.tx_errors;
1476 tx_retries = adapter->logmsg.retry;
1478 if (tx_retries > 75)
1479 tx_qual = (90 - tx_retries) * POOR / 15;
1480 else if (tx_retries > 70)
1481 tx_qual = (75 - tx_retries) * (FAIR - POOR) / 5 + POOR;
1482 else if (tx_retries > 65)
1483 tx_qual = (70 - tx_retries) * (GOOD - FAIR) / 5 + FAIR;
1484 else if (tx_retries > 50)
1485 tx_qual = (65 - tx_retries) * (VERY_GOOD - GOOD) /
1488 tx_qual = (50 - tx_retries) *
1489 (PERFECT - VERY_GOOD) / 50 + VERY_GOOD;
1490 quality = min(quality, tx_qual);
1492 priv->wstats.discard.code = adapter->logmsg.wepundecryptable;
1493 priv->wstats.discard.fragment = adapter->logmsg.fcserror;
1494 priv->wstats.discard.retries = tx_retries;
1495 priv->wstats.discard.misc = adapter->logmsg.ackfailure;
1497 /* Calculate quality */
1498 priv->wstats.qual.qual = max(quality, (u32)100);
1499 priv->wstats.qual.updated = IW_QUAL_ALL_UPDATED | IW_QUAL_DBM;
1502 /* update stats asynchronously for future calls */
1503 libertas_prepare_and_send_command(priv, cmd_802_11_rssi, 0,
1505 libertas_prepare_and_send_command(priv, cmd_802_11_get_log, 0,
1509 priv->wstats.miss.beacon = 0;
1510 priv->wstats.discard.retries = 0;
1511 priv->wstats.qual.qual = 0;
1512 priv->wstats.qual.level = 0;
1513 priv->wstats.qual.noise = 0;
1514 priv->wstats.qual.updated = IW_QUAL_ALL_UPDATED;
1515 priv->wstats.qual.updated |= IW_QUAL_NOISE_INVALID |
1516 IW_QUAL_QUAL_INVALID | IW_QUAL_LEVEL_INVALID;
1520 return &priv->wstats;
1525 static int wlan_set_freq(struct net_device *dev, struct iw_request_info *info,
1526 struct iw_freq *fwrq, char *extra)
1529 wlan_private *priv = dev->priv;
1530 wlan_adapter *adapter = priv->adapter;
1531 int rc = -EINPROGRESS; /* Call commit handler */
1532 struct chan_freq_power *cfp;
1537 * If setting by frequency, convert to a channel
1541 long f = fwrq->m / 100000;
1544 cfp = find_cfp_by_band_and_freq(adapter, 0, f);
1546 lbs_pr_debug(1, "Invalid freq=%ld\n", f);
1550 c = (int)cfp->channel;
1560 * Setting by channel number
1562 if (fwrq->m > 1000 || fwrq->e > 0) {
1565 int channel = fwrq->m;
1567 cfp = libertas_find_cfp_by_band_and_channel(adapter, 0, channel);
1571 if (adapter->inframode == wlan802_11ibss) {
1572 rc = changeadhocchannel(priv, channel);
1573 /* If station is WEP enabled, send the
1574 * command to set WEP in firmware
1576 if (adapter->secinfo.WEPstatus ==
1577 wlan802_11WEPenabled) {
1578 lbs_pr_debug(1, "set_freq: WEP enabled\n");
1579 ret = libertas_prepare_and_send_command(priv,
1582 cmd_option_waitforrsp,
1591 adapter->currentpacketfilter |=
1592 cmd_act_mac_wep_enable;
1594 libertas_set_mac_packet_filter(priv);
1607 * @brief use index to get the data rate
1609 * @param index The index of data rate
1610 * @return data rate or 0
1612 u32 libertas_index_to_data_rate(u8 index)
1614 if (index >= sizeof(libertas_wlan_data_rates))
1617 return libertas_wlan_data_rates[index];
1621 * @brief use rate to get the index
1623 * @param rate data rate
1624 * @return index or 0
1626 u8 libertas_data_rate_to_index(u32 rate)
1631 if ((ptr = memchr(libertas_wlan_data_rates, (u8) rate,
1632 sizeof(libertas_wlan_data_rates))))
1633 return (ptr - libertas_wlan_data_rates);
1638 static int wlan_set_rate(struct net_device *dev, struct iw_request_info *info,
1639 struct iw_param *vwrq, char *extra)
1641 wlan_private *priv = dev->priv;
1642 wlan_adapter *adapter = priv->adapter;
1646 u8 rates[WLAN_SUPPORTED_RATES];
1651 lbs_pr_debug(1, "Vwrq->value = %d\n", vwrq->value);
1653 if (vwrq->value == -1) {
1654 action = cmd_act_set_tx_auto; // Auto
1655 adapter->is_datarate_auto = 1;
1656 adapter->datarate = 0;
1658 if (vwrq->value % 100000) {
1662 data_rate = vwrq->value / 500000;
1664 memset(rates, 0, sizeof(rates));
1665 get_active_data_rates(adapter, rates);
1668 lbs_pr_debug(1, "Rate=0x%X Wanted=0x%X\n", *rate,
1670 if ((*rate & 0x7f) == (data_rate & 0x7f))
1675 lbs_pr_alert( "The fixed data rate 0x%X is out "
1676 "of range.\n", data_rate);
1680 adapter->datarate = data_rate;
1681 action = cmd_act_set_tx_fix_rate;
1682 adapter->is_datarate_auto = 0;
1685 ret = libertas_prepare_and_send_command(priv, cmd_802_11_data_rate,
1686 action, cmd_option_waitforrsp, 0, NULL);
1692 static int wlan_get_rate(struct net_device *dev, struct iw_request_info *info,
1693 struct iw_param *vwrq, char *extra)
1695 wlan_private *priv = dev->priv;
1696 wlan_adapter *adapter = priv->adapter;
1700 if (adapter->is_datarate_auto) {
1706 vwrq->value = adapter->datarate * 500000;
1712 static int wlan_set_mode(struct net_device *dev,
1713 struct iw_request_info *info, u32 * uwrq, char *extra)
1716 wlan_private *priv = dev->priv;
1717 wlan_adapter *adapter = priv->adapter;
1718 struct assoc_request * assoc_req;
1719 enum WLAN_802_11_NETWORK_INFRASTRUCTURE new_mode;
1725 lbs_pr_debug(1, "Wanted mode is ad-hoc: current datarate=%#x\n",
1727 new_mode = wlan802_11ibss;
1728 adapter->adhocchannel = DEFAULT_AD_HOC_CHANNEL;
1732 lbs_pr_debug(1, "Wanted mode is Infrastructure\n");
1733 new_mode = wlan802_11infrastructure;
1737 lbs_pr_debug(1, "Wanted mode is Auto\n");
1738 new_mode = wlan802_11autounknown;
1742 lbs_pr_debug(1, "Wanted mode is Unknown: 0x%x\n", *uwrq);
1746 mutex_lock(&adapter->lock);
1747 assoc_req = wlan_get_association_request(adapter);
1751 assoc_req->mode = new_mode;
1755 set_bit(ASSOC_FLAG_MODE, &assoc_req->flags);
1756 wlan_postpone_association_work(priv);
1758 wlan_cancel_association_work(priv);
1760 mutex_unlock(&adapter->lock);
1768 * @brief Get Encryption key
1770 * @param dev A pointer to net_device structure
1771 * @param info A pointer to iw_request_info structure
1772 * @param vwrq A pointer to iw_param structure
1773 * @param extra A pointer to extra data buf
1774 * @return 0 --success, otherwise fail
1776 static int wlan_get_encode(struct net_device *dev,
1777 struct iw_request_info *info,
1778 struct iw_point *dwrq, u8 * extra)
1780 wlan_private *priv = dev->priv;
1781 wlan_adapter *adapter = priv->adapter;
1782 int index = (dwrq->flags & IW_ENCODE_INDEX) - 1;
1786 lbs_pr_debug(1, "flags=0x%x index=%d length=%d wep_tx_keyidx=%d\n",
1787 dwrq->flags, index, dwrq->length, adapter->wep_tx_keyidx);
1791 /* Authentication method */
1792 switch (adapter->secinfo.authmode) {
1793 case wlan802_11authmodeopen:
1794 dwrq->flags = IW_ENCODE_OPEN;
1797 case wlan802_11authmodeshared:
1798 case wlan802_11authmodenetworkEAP:
1799 dwrq->flags = IW_ENCODE_RESTRICTED;
1802 dwrq->flags = IW_ENCODE_DISABLED | IW_ENCODE_OPEN;
1806 if ((adapter->secinfo.WEPstatus == wlan802_11WEPenabled)
1807 || adapter->secinfo.WPAenabled || adapter->secinfo.WPA2enabled) {
1808 dwrq->flags &= ~IW_ENCODE_DISABLED;
1810 dwrq->flags |= IW_ENCODE_DISABLED;
1813 memset(extra, 0, 16);
1815 mutex_lock(&adapter->lock);
1817 /* Default to returning current transmit key */
1819 index = adapter->wep_tx_keyidx;
1821 if ((adapter->wep_keys[index].len) &&
1822 (adapter->secinfo.WEPstatus == wlan802_11WEPenabled)) {
1823 memcpy(extra, adapter->wep_keys[index].key,
1824 adapter->wep_keys[index].len);
1825 dwrq->length = adapter->wep_keys[index].len;
1827 dwrq->flags |= (index + 1);
1828 /* Return WEP enabled */
1829 dwrq->flags &= ~IW_ENCODE_DISABLED;
1830 } else if ((adapter->secinfo.WPAenabled)
1831 || (adapter->secinfo.WPA2enabled)) {
1832 /* return WPA enabled */
1833 dwrq->flags &= ~IW_ENCODE_DISABLED;
1835 dwrq->flags |= IW_ENCODE_DISABLED;
1838 mutex_unlock(&adapter->lock);
1840 dwrq->flags |= IW_ENCODE_NOKEY;
1842 lbs_pr_debug(1, "key:%02x:%02x:%02x:%02x:%02x:%02x keylen=%d\n",
1843 extra[0], extra[1], extra[2],
1844 extra[3], extra[4], extra[5], dwrq->length);
1846 lbs_pr_debug(1, "Return flags=0x%x\n", dwrq->flags);
1853 * @brief Set Encryption key (internal)
1855 * @param priv A pointer to private card structure
1856 * @param key_material A pointer to key material
1857 * @param key_length length of key material
1858 * @param index key index to set
1859 * @param set_tx_key Force set TX key (1 = yes, 0 = no)
1860 * @return 0 --success, otherwise fail
1862 static int wlan_set_wep_key(struct assoc_request *assoc_req,
1863 const char *key_material,
1868 struct WLAN_802_11_KEY *pkey;
1872 /* Paranoid validation of key index */
1878 /* validate max key length */
1879 if (key_length > KEY_LEN_WEP_104) {
1884 pkey = &assoc_req->wep_keys[index];
1886 if (key_length > 0) {
1887 memset(pkey, 0, sizeof(struct WLAN_802_11_KEY));
1888 pkey->type = KEY_TYPE_ID_WEP;
1890 /* Standardize the key length */
1891 pkey->len = (key_length > KEY_LEN_WEP_40) ?
1892 KEY_LEN_WEP_104 : KEY_LEN_WEP_40;
1893 memcpy(pkey->key, key_material, key_length);
1897 /* Ensure the chosen key is valid */
1899 lbs_pr_debug(1, "key not set, so cannot enable it\n");
1903 assoc_req->wep_tx_keyidx = index;
1906 assoc_req->secinfo.WEPstatus = wlan802_11WEPenabled;
1912 static int validate_key_index(u16 def_index, u16 raw_index,
1913 u16 *out_index, u16 *is_default)
1915 if (!out_index || !is_default)
1918 /* Verify index if present, otherwise use default TX key index */
1919 if (raw_index > 0) {
1922 *out_index = raw_index - 1;
1924 *out_index = def_index;
1930 static void disable_wep(struct assoc_request *assoc_req)
1934 /* Set Open System auth mode */
1935 assoc_req->secinfo.authmode = wlan802_11authmodeopen;
1937 /* Clear WEP keys and mark WEP as disabled */
1938 assoc_req->secinfo.WEPstatus = wlan802_11WEPdisabled;
1939 for (i = 0; i < 4; i++)
1940 assoc_req->wep_keys[i].len = 0;
1942 set_bit(ASSOC_FLAG_SECINFO, &assoc_req->flags);
1943 set_bit(ASSOC_FLAG_WEP_KEYS, &assoc_req->flags);
1947 * @brief Set Encryption key
1949 * @param dev A pointer to net_device structure
1950 * @param info A pointer to iw_request_info structure
1951 * @param vwrq A pointer to iw_param structure
1952 * @param extra A pointer to extra data buf
1953 * @return 0 --success, otherwise fail
1955 static int wlan_set_encode(struct net_device *dev,
1956 struct iw_request_info *info,
1957 struct iw_point *dwrq, char *extra)
1960 wlan_private *priv = dev->priv;
1961 wlan_adapter *adapter = priv->adapter;
1962 struct assoc_request * assoc_req;
1963 u16 is_default = 0, index = 0, set_tx_key = 0;
1967 mutex_lock(&adapter->lock);
1968 assoc_req = wlan_get_association_request(adapter);
1974 if (dwrq->flags & IW_ENCODE_DISABLED) {
1975 disable_wep (assoc_req);
1979 ret = validate_key_index(assoc_req->wep_tx_keyidx,
1980 (dwrq->flags & IW_ENCODE_INDEX),
1981 &index, &is_default);
1987 /* If WEP isn't enabled, or if there is no key data but a valid
1988 * index, set the TX key.
1990 if ((assoc_req->secinfo.WEPstatus != wlan802_11WEPenabled)
1991 || (dwrq->length == 0 && !is_default))
1994 ret = wlan_set_wep_key(assoc_req, extra, dwrq->length, index, set_tx_key);
1999 set_bit(ASSOC_FLAG_WEP_KEYS, &assoc_req->flags);
2001 set_bit(ASSOC_FLAG_WEP_TX_KEYIDX, &assoc_req->flags);
2003 if (dwrq->flags & IW_ENCODE_RESTRICTED) {
2004 assoc_req->secinfo.authmode = wlan802_11authmodeshared;
2005 } else if (dwrq->flags & IW_ENCODE_OPEN) {
2006 assoc_req->secinfo.authmode = wlan802_11authmodeopen;
2011 set_bit(ASSOC_FLAG_SECINFO, &assoc_req->flags);
2012 wlan_postpone_association_work(priv);
2014 wlan_cancel_association_work(priv);
2016 mutex_unlock(&adapter->lock);
2023 * @brief Get Extended Encryption key (WPA/802.1x and WEP)
2025 * @param dev A pointer to net_device structure
2026 * @param info A pointer to iw_request_info structure
2027 * @param vwrq A pointer to iw_param structure
2028 * @param extra A pointer to extra data buf
2029 * @return 0 on success, otherwise failure
2031 static int wlan_get_encodeext(struct net_device *dev,
2032 struct iw_request_info *info,
2033 struct iw_point *dwrq,
2037 wlan_private *priv = dev->priv;
2038 wlan_adapter *adapter = priv->adapter;
2039 struct iw_encode_ext *ext = (struct iw_encode_ext *)extra;
2040 int index, max_key_len;
2044 max_key_len = dwrq->length - sizeof(*ext);
2045 if (max_key_len < 0)
2048 index = dwrq->flags & IW_ENCODE_INDEX;
2050 if (index < 1 || index > 4)
2054 index = adapter->wep_tx_keyidx;
2057 if (!ext->ext_flags & IW_ENCODE_EXT_GROUP_KEY &&
2058 ext->alg != IW_ENCODE_ALG_WEP) {
2059 if (index != 0 || adapter->inframode != wlan802_11infrastructure)
2063 dwrq->flags = index + 1;
2064 memset(ext, 0, sizeof(*ext));
2066 if ((adapter->secinfo.WEPstatus == wlan802_11WEPdisabled)
2067 && !adapter->secinfo.WPAenabled && !adapter->secinfo.WPA2enabled) {
2068 ext->alg = IW_ENCODE_ALG_NONE;
2070 dwrq->flags |= IW_ENCODE_DISABLED;
2074 if ((adapter->secinfo.WEPstatus == wlan802_11WEPenabled)
2075 && !adapter->secinfo.WPAenabled
2076 && !adapter->secinfo.WPA2enabled) {
2077 ext->alg = IW_ENCODE_ALG_WEP;
2078 ext->key_len = adapter->wep_keys[index].len;
2079 key = &adapter->wep_keys[index].key[0];
2080 } else if ((adapter->secinfo.WEPstatus == wlan802_11WEPdisabled) &&
2081 (adapter->secinfo.WPAenabled ||
2082 adapter->secinfo.WPA2enabled)) {
2084 ext->alg = IW_ENCODE_ALG_TKIP;
2090 if (ext->key_len > max_key_len) {
2096 memcpy(ext->key, key, ext->key_len);
2098 dwrq->flags |= IW_ENCODE_NOKEY;
2099 dwrq->flags |= IW_ENCODE_ENABLED;
2109 * @brief Set Encryption key Extended (WPA/802.1x and WEP)
2111 * @param dev A pointer to net_device structure
2112 * @param info A pointer to iw_request_info structure
2113 * @param vwrq A pointer to iw_param structure
2114 * @param extra A pointer to extra data buf
2115 * @return 0 --success, otherwise fail
2117 static int wlan_set_encodeext(struct net_device *dev,
2118 struct iw_request_info *info,
2119 struct iw_point *dwrq,
2123 wlan_private *priv = dev->priv;
2124 wlan_adapter *adapter = priv->adapter;
2125 struct iw_encode_ext *ext = (struct iw_encode_ext *)extra;
2127 struct assoc_request * assoc_req;
2131 mutex_lock(&adapter->lock);
2132 assoc_req = wlan_get_association_request(adapter);
2138 if ((alg == IW_ENCODE_ALG_NONE) || (dwrq->flags & IW_ENCODE_DISABLED)) {
2139 disable_wep (assoc_req);
2140 } else if (alg == IW_ENCODE_ALG_WEP) {
2141 u16 is_default = 0, index, set_tx_key = 0;
2143 ret = validate_key_index(assoc_req->wep_tx_keyidx,
2144 (dwrq->flags & IW_ENCODE_INDEX),
2145 &index, &is_default);
2149 /* If WEP isn't enabled, or if there is no key data but a valid
2150 * index, or if the set-TX-key flag was passed, set the TX key.
2152 if ((assoc_req->secinfo.WEPstatus != wlan802_11WEPenabled)
2153 || (dwrq->length == 0 && !is_default)
2154 || (ext->ext_flags & IW_ENCODE_EXT_SET_TX_KEY))
2157 /* Copy key to driver */
2158 ret = wlan_set_wep_key (assoc_req, ext->key, ext->key_len, index,
2163 if (dwrq->flags & IW_ENCODE_RESTRICTED) {
2164 assoc_req->secinfo.authmode =
2165 wlan802_11authmodeshared;
2166 } else if (dwrq->flags & IW_ENCODE_OPEN) {
2167 assoc_req->secinfo.authmode =
2168 wlan802_11authmodeopen;
2171 /* Mark the various WEP bits as modified */
2172 set_bit(ASSOC_FLAG_SECINFO, &assoc_req->flags);
2174 set_bit(ASSOC_FLAG_WEP_KEYS, &assoc_req->flags);
2176 set_bit(ASSOC_FLAG_WEP_TX_KEYIDX, &assoc_req->flags);
2178 } else if ((alg == IW_ENCODE_ALG_TKIP) || (alg == IW_ENCODE_ALG_CCMP)) {
2179 struct WLAN_802_11_KEY * pkey;
2181 /* validate key length */
2182 if (((alg == IW_ENCODE_ALG_TKIP)
2183 && (ext->key_len != KEY_LEN_WPA_TKIP))
2184 || ((alg == IW_ENCODE_ALG_CCMP)
2185 && (ext->key_len != KEY_LEN_WPA_AES))) {
2186 lbs_pr_debug(1, "Invalid size %d for key of alg"
2194 if (ext->ext_flags & IW_ENCODE_EXT_GROUP_KEY)
2195 pkey = &assoc_req->wpa_mcast_key;
2197 pkey = &assoc_req->wpa_unicast_key;
2199 memset(pkey, 0, sizeof (struct WLAN_802_11_KEY));
2200 memcpy(pkey->key, ext->key, ext->key_len);
2201 pkey->len = ext->key_len;
2202 pkey->flags = KEY_INFO_WPA_ENABLED;
2204 if (ext->ext_flags & IW_ENCODE_EXT_GROUP_KEY) {
2205 pkey->flags |= KEY_INFO_WPA_MCAST;
2206 set_bit(ASSOC_FLAG_WPA_MCAST_KEY, &assoc_req->flags);
2208 pkey->flags |= KEY_INFO_WPA_UNICAST;
2209 set_bit(ASSOC_FLAG_WPA_UCAST_KEY, &assoc_req->flags);
2212 if (alg == IW_ENCODE_ALG_TKIP)
2213 pkey->type = KEY_TYPE_ID_TKIP;
2214 else if (alg == IW_ENCODE_ALG_CCMP)
2215 pkey->type = KEY_TYPE_ID_AES;
2217 /* If WPA isn't enabled yet, do that now */
2218 if ( assoc_req->secinfo.WPAenabled == 0
2219 && assoc_req->secinfo.WPA2enabled == 0) {
2220 assoc_req->secinfo.WPAenabled = 1;
2221 assoc_req->secinfo.WPA2enabled = 1;
2222 set_bit(ASSOC_FLAG_SECINFO, &assoc_req->flags);
2225 disable_wep (assoc_req);
2230 wlan_postpone_association_work(priv);
2232 wlan_cancel_association_work(priv);
2234 mutex_unlock(&adapter->lock);
2241 static int wlan_set_genie(struct net_device *dev,
2242 struct iw_request_info *info,
2243 struct iw_point *dwrq,
2246 wlan_private *priv = dev->priv;
2247 wlan_adapter *adapter = priv->adapter;
2249 struct assoc_request * assoc_req;
2253 mutex_lock(&adapter->lock);
2254 assoc_req = wlan_get_association_request(adapter);
2260 if (dwrq->length > MAX_WPA_IE_LEN ||
2261 (dwrq->length && extra == NULL)) {
2267 memcpy(&assoc_req->wpa_ie[0], extra, dwrq->length);
2268 assoc_req->wpa_ie_len = dwrq->length;
2270 memset(&assoc_req->wpa_ie[0], 0, sizeof(adapter->wpa_ie));
2271 assoc_req->wpa_ie_len = 0;
2276 set_bit(ASSOC_FLAG_WPA_IE, &assoc_req->flags);
2277 wlan_postpone_association_work(priv);
2279 wlan_cancel_association_work(priv);
2281 mutex_unlock(&adapter->lock);
2287 static int wlan_get_genie(struct net_device *dev,
2288 struct iw_request_info *info,
2289 struct iw_point *dwrq,
2292 wlan_private *priv = dev->priv;
2293 wlan_adapter *adapter = priv->adapter;
2297 if (adapter->wpa_ie_len == 0) {
2303 if (dwrq->length < adapter->wpa_ie_len) {
2308 dwrq->length = adapter->wpa_ie_len;
2309 memcpy(extra, &adapter->wpa_ie[0], adapter->wpa_ie_len);
2316 static int wlan_set_auth(struct net_device *dev,
2317 struct iw_request_info *info,
2318 struct iw_param *dwrq,
2321 wlan_private *priv = dev->priv;
2322 wlan_adapter *adapter = priv->adapter;
2323 struct assoc_request * assoc_req;
2329 mutex_lock(&adapter->lock);
2330 assoc_req = wlan_get_association_request(adapter);
2336 switch (dwrq->flags & IW_AUTH_INDEX) {
2337 case IW_AUTH_TKIP_COUNTERMEASURES:
2338 case IW_AUTH_CIPHER_PAIRWISE:
2339 case IW_AUTH_CIPHER_GROUP:
2340 case IW_AUTH_KEY_MGMT:
2342 * libertas does not use these parameters
2346 case IW_AUTH_WPA_VERSION:
2347 if (dwrq->value & IW_AUTH_WPA_VERSION_DISABLED) {
2348 assoc_req->secinfo.WPAenabled = 0;
2349 assoc_req->secinfo.WPA2enabled = 0;
2351 if (dwrq->value & IW_AUTH_WPA_VERSION_WPA) {
2352 assoc_req->secinfo.WPAenabled = 1;
2353 assoc_req->secinfo.WEPstatus = wlan802_11WEPdisabled;
2354 assoc_req->secinfo.authmode =
2355 wlan802_11authmodeopen;
2357 if (dwrq->value & IW_AUTH_WPA_VERSION_WPA2) {
2358 assoc_req->secinfo.WPA2enabled = 1;
2359 assoc_req->secinfo.WEPstatus = wlan802_11WEPdisabled;
2360 assoc_req->secinfo.authmode =
2361 wlan802_11authmodeopen;
2366 case IW_AUTH_DROP_UNENCRYPTED:
2368 adapter->currentpacketfilter |=
2369 cmd_act_mac_strict_protection_enable;
2371 adapter->currentpacketfilter &=
2372 ~cmd_act_mac_strict_protection_enable;
2377 case IW_AUTH_80211_AUTH_ALG:
2378 if (dwrq->value & IW_AUTH_ALG_SHARED_KEY) {
2379 assoc_req->secinfo.authmode =
2380 wlan802_11authmodeshared;
2381 } else if (dwrq->value & IW_AUTH_ALG_OPEN_SYSTEM) {
2382 assoc_req->secinfo.authmode =
2383 wlan802_11authmodeopen;
2384 } else if (dwrq->value & IW_AUTH_ALG_LEAP) {
2385 assoc_req->secinfo.authmode =
2386 wlan802_11authmodenetworkEAP;
2393 case IW_AUTH_WPA_ENABLED:
2395 if (!assoc_req->secinfo.WPAenabled &&
2396 !assoc_req->secinfo.WPA2enabled) {
2397 assoc_req->secinfo.WPAenabled = 1;
2398 assoc_req->secinfo.WPA2enabled = 1;
2399 assoc_req->secinfo.WEPstatus = wlan802_11WEPdisabled;
2400 assoc_req->secinfo.authmode =
2401 wlan802_11authmodeopen;
2404 assoc_req->secinfo.WPAenabled = 0;
2405 assoc_req->secinfo.WPA2enabled = 0;
2418 set_bit(ASSOC_FLAG_SECINFO, &assoc_req->flags);
2419 wlan_postpone_association_work(priv);
2420 } else if (ret != -EOPNOTSUPP) {
2421 wlan_cancel_association_work(priv);
2423 mutex_unlock(&adapter->lock);
2429 static int wlan_get_auth(struct net_device *dev,
2430 struct iw_request_info *info,
2431 struct iw_param *dwrq,
2434 wlan_private *priv = dev->priv;
2435 wlan_adapter *adapter = priv->adapter;
2439 switch (dwrq->flags & IW_AUTH_INDEX) {
2440 case IW_AUTH_WPA_VERSION:
2442 if (adapter->secinfo.WPAenabled)
2443 dwrq->value |= IW_AUTH_WPA_VERSION_WPA;
2444 if (adapter->secinfo.WPA2enabled)
2445 dwrq->value |= IW_AUTH_WPA_VERSION_WPA2;
2447 dwrq->value |= IW_AUTH_WPA_VERSION_DISABLED;
2450 case IW_AUTH_DROP_UNENCRYPTED:
2452 if (adapter->currentpacketfilter &
2453 cmd_act_mac_strict_protection_enable)
2457 case IW_AUTH_80211_AUTH_ALG:
2458 switch (adapter->secinfo.authmode) {
2459 case wlan802_11authmodeshared:
2460 dwrq->value = IW_AUTH_ALG_SHARED_KEY;
2462 case wlan802_11authmodeopen:
2463 dwrq->value = IW_AUTH_ALG_OPEN_SYSTEM;
2465 case wlan802_11authmodenetworkEAP:
2466 dwrq->value = IW_AUTH_ALG_LEAP;
2473 case IW_AUTH_WPA_ENABLED:
2474 if (adapter->secinfo.WPAenabled && adapter->secinfo.WPA2enabled)
2488 static int wlan_set_txpow(struct net_device *dev, struct iw_request_info *info,
2489 struct iw_param *vwrq, char *extra)
2492 wlan_private *priv = dev->priv;
2493 wlan_adapter *adapter = priv->adapter;
2499 if (vwrq->disabled) {
2500 wlan_radio_ioctl(priv, RADIO_OFF);
2504 adapter->preamble = cmd_type_auto_preamble;
2506 wlan_radio_ioctl(priv, RADIO_ON);
2508 if ((vwrq->flags & IW_TXPOW_TYPE) == IW_TXPOW_MWATT) {
2509 dbm = (u16) mw_to_dbm(vwrq->value);
2511 dbm = (u16) vwrq->value;
2513 /* auto tx power control */
2515 if (vwrq->fixed == 0)
2518 lbs_pr_debug(1, "<1>TXPOWER SET %d dbm.\n", dbm);
2520 ret = libertas_prepare_and_send_command(priv,
2521 cmd_802_11_rf_tx_power,
2522 cmd_act_tx_power_opt_set_low,
2523 cmd_option_waitforrsp, 0, (void *)&dbm);
2529 static int wlan_get_essid(struct net_device *dev, struct iw_request_info *info,
2530 struct iw_point *dwrq, char *extra)
2532 wlan_private *priv = dev->priv;
2533 wlan_adapter *adapter = priv->adapter;
2537 * Note : if dwrq->flags != 0, we should get the relevant SSID from
2542 * Get the current SSID
2544 if (adapter->connect_status == libertas_connected) {
2545 memcpy(extra, adapter->curbssparams.ssid.ssid,
2546 adapter->curbssparams.ssid.ssidlength);
2547 extra[adapter->curbssparams.ssid.ssidlength] = '\0';
2549 memset(extra, 0, 32);
2550 extra[adapter->curbssparams.ssid.ssidlength] = '\0';
2553 * If none, we may want to get the one that was set
2556 /* To make the driver backward compatible with WPA supplicant v0.2.4 */
2557 if (dwrq->length == 32) /* check with WPA supplicant buffer size */
2558 dwrq->length = min_t(size_t, adapter->curbssparams.ssid.ssidlength,
2561 dwrq->length = adapter->curbssparams.ssid.ssidlength + 1;
2563 dwrq->flags = 1; /* active */
2569 static int wlan_set_essid(struct net_device *dev, struct iw_request_info *info,
2570 struct iw_point *dwrq, char *extra)
2572 wlan_private *priv = dev->priv;
2573 wlan_adapter *adapter = priv->adapter;
2575 struct WLAN_802_11_SSID ssid;
2576 struct assoc_request * assoc_req;
2577 int ssid_len = dwrq->length;
2582 * WE-20 and earlier NULL pad the end of the SSID and increment
2583 * SSID length so it can be used like a string. WE-21 and later don't,
2584 * but some userspace tools aren't able to cope with the change.
2586 if ((ssid_len > 0) && (extra[ssid_len - 1] == '\0'))
2589 /* Check the size of the string */
2590 if (ssid_len > IW_ESSID_MAX_SIZE) {
2595 memset(&ssid, 0, sizeof(struct WLAN_802_11_SSID));
2597 if (!dwrq->flags || !ssid_len) {
2598 /* "any" SSID requested; leave SSID blank */
2600 /* Specific SSID requested */
2601 memcpy(&ssid.ssid, extra, ssid_len);
2602 ssid.ssidlength = ssid_len;
2605 lbs_pr_debug(1, "Requested new SSID = %s\n",
2606 (ssid.ssidlength > 0) ? (char *)ssid.ssid : "any");
2609 mutex_lock(&adapter->lock);
2611 /* Get or create the current association request */
2612 assoc_req = wlan_get_association_request(adapter);
2616 /* Copy the SSID to the association request */
2617 memcpy(&assoc_req->ssid, &ssid, sizeof(struct WLAN_802_11_SSID));
2618 set_bit(ASSOC_FLAG_SSID, &assoc_req->flags);
2619 wlan_postpone_association_work(priv);
2623 /* Cancel the association request if there was an error */
2625 wlan_cancel_association_work(priv);
2628 mutex_unlock(&adapter->lock);
2635 * @brief Connect to the AP or Ad-hoc Network with specific bssid
2637 * @param dev A pointer to net_device structure
2638 * @param info A pointer to iw_request_info structure
2639 * @param awrq A pointer to iw_param structure
2640 * @param extra A pointer to extra data buf
2641 * @return 0 --success, otherwise fail
2643 static int wlan_set_wap(struct net_device *dev, struct iw_request_info *info,
2644 struct sockaddr *awrq, char *extra)
2646 wlan_private *priv = dev->priv;
2647 wlan_adapter *adapter = priv->adapter;
2648 struct assoc_request * assoc_req;
2653 if (awrq->sa_family != ARPHRD_ETHER)
2656 lbs_pr_debug(1, "ASSOC: WAP: sa_data: " MAC_FMT "\n", MAC_ARG(awrq->sa_data));
2658 mutex_lock(&adapter->lock);
2660 /* Get or create the current association request */
2661 assoc_req = wlan_get_association_request(adapter);
2663 wlan_cancel_association_work(priv);
2666 /* Copy the BSSID to the association request */
2667 memcpy(&assoc_req->bssid, awrq->sa_data, ETH_ALEN);
2668 set_bit(ASSOC_FLAG_BSSID, &assoc_req->flags);
2669 wlan_postpone_association_work(priv);
2672 mutex_unlock(&adapter->lock);
2677 void libertas_get_fwversion(wlan_adapter * adapter, char *fwversion, int maxlen)
2685 mutex_lock(&adapter->lock);
2686 ver.l = adapter->fwreleasenumber;
2687 mutex_unlock(&adapter->lock);
2690 sprintf(fwver, "%u.%u.%u", ver.c[2], ver.c[1], ver.c[0]);
2692 sprintf(fwver, "%u.%u.%u.p%u",
2693 ver.c[2], ver.c[1], ver.c[0], ver.c[3]);
2695 snprintf(fwversion, maxlen, fwver);
2700 * iwconfig settable callbacks
2702 static const iw_handler wlan_handler[] = {
2703 (iw_handler) NULL, /* SIOCSIWCOMMIT */
2704 (iw_handler) wlan_get_name, /* SIOCGIWNAME */
2705 (iw_handler) NULL, /* SIOCSIWNWID */
2706 (iw_handler) NULL, /* SIOCGIWNWID */
2707 (iw_handler) wlan_set_freq, /* SIOCSIWFREQ */
2708 (iw_handler) wlan_get_freq, /* SIOCGIWFREQ */
2709 (iw_handler) wlan_set_mode, /* SIOCSIWMODE */
2710 (iw_handler) wlan_get_mode, /* SIOCGIWMODE */
2711 (iw_handler) NULL, /* SIOCSIWSENS */
2712 (iw_handler) NULL, /* SIOCGIWSENS */
2713 (iw_handler) NULL, /* SIOCSIWRANGE */
2714 (iw_handler) wlan_get_range, /* SIOCGIWRANGE */
2715 (iw_handler) NULL, /* SIOCSIWPRIV */
2716 (iw_handler) NULL, /* SIOCGIWPRIV */
2717 (iw_handler) NULL, /* SIOCSIWSTATS */
2718 (iw_handler) NULL, /* SIOCGIWSTATS */
2719 iw_handler_set_spy, /* SIOCSIWSPY */
2720 iw_handler_get_spy, /* SIOCGIWSPY */
2721 iw_handler_set_thrspy, /* SIOCSIWTHRSPY */
2722 iw_handler_get_thrspy, /* SIOCGIWTHRSPY */
2723 (iw_handler) wlan_set_wap, /* SIOCSIWAP */
2724 (iw_handler) wlan_get_wap, /* SIOCGIWAP */
2725 (iw_handler) NULL, /* SIOCSIWMLME */
2726 (iw_handler) NULL, /* SIOCGIWAPLIST - deprecated */
2727 (iw_handler) libertas_set_scan, /* SIOCSIWSCAN */
2728 (iw_handler) libertas_get_scan, /* SIOCGIWSCAN */
2729 (iw_handler) wlan_set_essid, /* SIOCSIWESSID */
2730 (iw_handler) wlan_get_essid, /* SIOCGIWESSID */
2731 (iw_handler) wlan_set_nick, /* SIOCSIWNICKN */
2732 (iw_handler) wlan_get_nick, /* SIOCGIWNICKN */
2733 (iw_handler) NULL, /* -- hole -- */
2734 (iw_handler) NULL, /* -- hole -- */
2735 (iw_handler) wlan_set_rate, /* SIOCSIWRATE */
2736 (iw_handler) wlan_get_rate, /* SIOCGIWRATE */
2737 (iw_handler) wlan_set_rts, /* SIOCSIWRTS */
2738 (iw_handler) wlan_get_rts, /* SIOCGIWRTS */
2739 (iw_handler) wlan_set_frag, /* SIOCSIWFRAG */
2740 (iw_handler) wlan_get_frag, /* SIOCGIWFRAG */
2741 (iw_handler) wlan_set_txpow, /* SIOCSIWTXPOW */
2742 (iw_handler) wlan_get_txpow, /* SIOCGIWTXPOW */
2743 (iw_handler) wlan_set_retry, /* SIOCSIWRETRY */
2744 (iw_handler) wlan_get_retry, /* SIOCGIWRETRY */
2745 (iw_handler) wlan_set_encode, /* SIOCSIWENCODE */
2746 (iw_handler) wlan_get_encode, /* SIOCGIWENCODE */
2747 (iw_handler) wlan_set_power, /* SIOCSIWPOWER */
2748 (iw_handler) wlan_get_power, /* SIOCGIWPOWER */
2749 (iw_handler) NULL, /* -- hole -- */
2750 (iw_handler) NULL, /* -- hole -- */
2751 (iw_handler) wlan_set_genie, /* SIOCSIWGENIE */
2752 (iw_handler) wlan_get_genie, /* SIOCGIWGENIE */
2753 (iw_handler) wlan_set_auth, /* SIOCSIWAUTH */
2754 (iw_handler) wlan_get_auth, /* SIOCGIWAUTH */
2755 (iw_handler) wlan_set_encodeext,/* SIOCSIWENCODEEXT */
2756 (iw_handler) wlan_get_encodeext,/* SIOCGIWENCODEEXT */
2757 (iw_handler) NULL, /* SIOCSIWPMKSA */
2760 struct iw_handler_def libertas_handler_def = {
2761 .num_standard = sizeof(wlan_handler) / sizeof(iw_handler),
2762 .num_private = sizeof(wlan_private_handler) / sizeof(iw_handler),
2763 .num_private_args = sizeof(wlan_private_args) /
2764 sizeof(struct iw_priv_args),
2765 .standard = (iw_handler *) wlan_handler,
2766 .private = (iw_handler *) wlan_private_handler,
2767 .private_args = (struct iw_priv_args *)wlan_private_args,
2768 .get_wireless_stats = wlan_get_wireless_stats,