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>
25 * the rates supported by the card
27 static u8 libertas_wlan_data_rates[WLAN_SUPPORTED_RATES] =
28 { 0x02, 0x04, 0x0B, 0x16, 0x00, 0x0C, 0x12,
29 0x18, 0x24, 0x30, 0x48, 0x60, 0x6C, 0x00
33 * @brief Convert mw value to dbm value
35 * @param mw the value of mw
36 * @return the value of dbm
38 static int mw_to_dbm(int mw)
79 * @brief Find the channel frequency power info with specific channel
81 * @param adapter A pointer to wlan_adapter structure
82 * @param band it can be BAND_A, BAND_G or BAND_B
83 * @param channel the channel for looking
84 * @return A pointer to struct chan_freq_power structure or NULL if not find.
86 struct chan_freq_power *libertas_find_cfp_by_band_and_channel(wlan_adapter * adapter,
89 struct chan_freq_power *cfp = NULL;
90 struct region_channel *rc;
91 int count = sizeof(adapter->region_channel) /
92 sizeof(adapter->region_channel[0]);
95 for (j = 0; !cfp && (j < count); j++) {
96 rc = &adapter->region_channel[j];
98 if (adapter->enable11d)
99 rc = &adapter->universal_channel[j];
100 if (!rc->valid || !rc->CFP)
102 if (rc->band != band)
104 for (i = 0; i < rc->nrcfp; i++) {
105 if (rc->CFP[i].channel == channel) {
113 lbs_deb_wext("libertas_find_cfp_by_band_and_channel: can't find "
114 "cfp by band %d / channel %d\n", band, channel);
120 * @brief Find the channel frequency power info with specific frequency
122 * @param adapter A pointer to wlan_adapter structure
123 * @param band it can be BAND_A, BAND_G or BAND_B
124 * @param freq the frequency for looking
125 * @return A pointer to struct chan_freq_power structure or NULL if not find.
127 static struct chan_freq_power *find_cfp_by_band_and_freq(wlan_adapter * adapter,
130 struct chan_freq_power *cfp = NULL;
131 struct region_channel *rc;
132 int count = sizeof(adapter->region_channel) /
133 sizeof(adapter->region_channel[0]);
136 for (j = 0; !cfp && (j < count); j++) {
137 rc = &adapter->region_channel[j];
139 if (adapter->enable11d)
140 rc = &adapter->universal_channel[j];
141 if (!rc->valid || !rc->CFP)
143 if (rc->band != band)
145 for (i = 0; i < rc->nrcfp; i++) {
146 if (rc->CFP[i].freq == freq) {
154 lbs_deb_wext("find_cfp_by_band_and_freql: can't find cfp by "
155 "band %d / freq %d\n", band, freq);
162 * @brief Set Radio On/OFF
164 * @param priv A pointer to wlan_private structure
165 * @option Radio Option
166 * @return 0 --success, otherwise fail
168 int wlan_radio_ioctl(wlan_private * priv, u8 option)
171 wlan_adapter *adapter = priv->adapter;
173 lbs_deb_enter(LBS_DEB_WEXT);
175 if (adapter->radioon != option) {
176 lbs_deb_wext("switching radio %s\n", option ? "on" : "off");
177 adapter->radioon = option;
179 ret = libertas_prepare_and_send_command(priv,
180 cmd_802_11_radio_control,
182 cmd_option_waitforrsp, 0, NULL);
185 lbs_deb_leave_args(LBS_DEB_WEXT, "ret %d", ret);
192 * @param dest A pointer to Dest Buf
193 * @param src A pointer to Src Buf
194 * @param len The len of Src Buf
195 * @return Number of rates copyed
197 static inline int copyrates(u8 * dest, int pos, u8 * src, int len)
201 for (i = 0; i < len && src[i]; i++, pos++) {
202 if (pos >= sizeof(u8) * WLAN_SUPPORTED_RATES)
211 * @brief Get active data rates
213 * @param adapter A pointer to wlan_adapter structure
214 * @param rate The buf to return the active rates
215 * @return The number of rates
217 static int get_active_data_rates(wlan_adapter * adapter,
222 lbs_deb_enter(LBS_DEB_WEXT);
224 if (adapter->connect_status != libertas_connected) {
225 if (adapter->mode == IW_MODE_INFRA) {
226 lbs_deb_wext("infra\n");
227 k = copyrates(rates, k, libertas_supported_rates,
228 sizeof(libertas_supported_rates));
230 lbs_deb_wext("Adhoc G\n");
231 k = copyrates(rates, k, libertas_adhoc_rates_g,
232 sizeof(libertas_adhoc_rates_g));
235 k = copyrates(rates, 0, adapter->curbssparams.datarates,
236 adapter->curbssparams.numofrates);
239 lbs_deb_leave_args(LBS_DEB_WEXT, "ret %d", k);
243 static int wlan_get_name(struct net_device *dev, struct iw_request_info *info,
244 char *cwrq, char *extra)
247 char comm[6] = { "COMM-" };
248 char mrvl[6] = { "MRVL-" };
251 lbs_deb_enter(LBS_DEB_WEXT);
255 cp = strstr(libertas_driver_version, comm);
256 if (cp == libertas_driver_version) //skip leading "COMM-"
257 cp = libertas_driver_version + strlen(comm);
259 cp = libertas_driver_version;
263 while (cnt < 16 && (*cp != '-')) {
264 *cwrq++ = toupper(*cp++);
269 lbs_deb_leave(LBS_DEB_WEXT);
273 static int wlan_get_freq(struct net_device *dev, struct iw_request_info *info,
274 struct iw_freq *fwrq, char *extra)
276 wlan_private *priv = dev->priv;
277 wlan_adapter *adapter = priv->adapter;
278 struct chan_freq_power *cfp;
280 lbs_deb_enter(LBS_DEB_WEXT);
282 cfp = libertas_find_cfp_by_band_and_channel(adapter, 0,
283 adapter->curbssparams.channel);
286 if (adapter->curbssparams.channel)
287 lbs_deb_wext("invalid channel %d\n",
288 adapter->curbssparams.channel);
292 fwrq->m = (long)cfp->freq * 100000;
295 lbs_deb_wext("freq %u\n", fwrq->m);
296 lbs_deb_leave(LBS_DEB_WEXT);
300 static int wlan_get_wap(struct net_device *dev, struct iw_request_info *info,
301 struct sockaddr *awrq, char *extra)
303 wlan_private *priv = dev->priv;
304 wlan_adapter *adapter = priv->adapter;
306 lbs_deb_enter(LBS_DEB_WEXT);
308 if (adapter->connect_status == libertas_connected) {
309 memcpy(awrq->sa_data, adapter->curbssparams.bssid, ETH_ALEN);
311 memset(awrq->sa_data, 0, ETH_ALEN);
313 awrq->sa_family = ARPHRD_ETHER;
315 lbs_deb_leave(LBS_DEB_WEXT);
319 static int wlan_set_nick(struct net_device *dev, struct iw_request_info *info,
320 struct iw_point *dwrq, char *extra)
322 wlan_private *priv = dev->priv;
323 wlan_adapter *adapter = priv->adapter;
325 lbs_deb_enter(LBS_DEB_WEXT);
328 * Check the size of the string
331 if (dwrq->length > 16) {
335 mutex_lock(&adapter->lock);
336 memset(adapter->nodename, 0, sizeof(adapter->nodename));
337 memcpy(adapter->nodename, extra, dwrq->length);
338 mutex_unlock(&adapter->lock);
340 lbs_deb_leave(LBS_DEB_WEXT);
344 static int wlan_get_nick(struct net_device *dev, struct iw_request_info *info,
345 struct iw_point *dwrq, char *extra)
347 wlan_private *priv = dev->priv;
348 wlan_adapter *adapter = priv->adapter;
350 lbs_deb_enter(LBS_DEB_WEXT);
353 * Get the Nick Name saved
356 mutex_lock(&adapter->lock);
357 strncpy(extra, adapter->nodename, 16);
358 mutex_unlock(&adapter->lock);
363 * If none, we may want to get the one that was set
369 dwrq->length = strlen(extra) + 1;
371 lbs_deb_leave(LBS_DEB_WEXT);
375 static int mesh_get_nick(struct net_device *dev, struct iw_request_info *info,
376 struct iw_point *dwrq, char *extra)
378 wlan_private *priv = dev->priv;
379 wlan_adapter *adapter = priv->adapter;
381 lbs_deb_enter(LBS_DEB_WEXT);
383 /* Use nickname to indicate that mesh is on */
385 if (adapter->connect_status == libertas_connected) {
386 strncpy(extra, "Mesh", 12);
388 dwrq->length = strlen(extra) + 1;
396 lbs_deb_leave(LBS_DEB_WEXT);
399 static int wlan_set_rts(struct net_device *dev, struct iw_request_info *info,
400 struct iw_param *vwrq, char *extra)
403 wlan_private *priv = dev->priv;
404 wlan_adapter *adapter = priv->adapter;
405 u32 rthr = vwrq->value;
407 lbs_deb_enter(LBS_DEB_WEXT);
409 if (vwrq->disabled) {
410 adapter->rtsthsd = rthr = MRVDRV_RTS_MAX_VALUE;
412 if (rthr < MRVDRV_RTS_MIN_VALUE || rthr > MRVDRV_RTS_MAX_VALUE)
414 adapter->rtsthsd = rthr;
417 ret = libertas_prepare_and_send_command(priv, cmd_802_11_snmp_mib,
418 cmd_act_set, cmd_option_waitforrsp,
419 OID_802_11_RTS_THRESHOLD, &rthr);
421 lbs_deb_leave_args(LBS_DEB_WEXT, "ret %d", ret);
425 static int wlan_get_rts(struct net_device *dev, struct iw_request_info *info,
426 struct iw_param *vwrq, char *extra)
429 wlan_private *priv = dev->priv;
430 wlan_adapter *adapter = priv->adapter;
432 lbs_deb_enter(LBS_DEB_WEXT);
434 adapter->rtsthsd = 0;
435 ret = libertas_prepare_and_send_command(priv, cmd_802_11_snmp_mib,
436 cmd_act_get, cmd_option_waitforrsp,
437 OID_802_11_RTS_THRESHOLD, NULL);
441 vwrq->value = adapter->rtsthsd;
442 vwrq->disabled = ((vwrq->value < MRVDRV_RTS_MIN_VALUE)
443 || (vwrq->value > MRVDRV_RTS_MAX_VALUE));
447 lbs_deb_leave_args(LBS_DEB_WEXT, "ret %d", ret);
451 static int wlan_set_frag(struct net_device *dev, struct iw_request_info *info,
452 struct iw_param *vwrq, char *extra)
455 u32 fthr = vwrq->value;
456 wlan_private *priv = dev->priv;
457 wlan_adapter *adapter = priv->adapter;
459 lbs_deb_enter(LBS_DEB_WEXT);
461 if (vwrq->disabled) {
462 adapter->fragthsd = fthr = MRVDRV_FRAG_MAX_VALUE;
464 if (fthr < MRVDRV_FRAG_MIN_VALUE
465 || fthr > MRVDRV_FRAG_MAX_VALUE)
467 adapter->fragthsd = fthr;
470 ret = libertas_prepare_and_send_command(priv, cmd_802_11_snmp_mib,
471 cmd_act_set, cmd_option_waitforrsp,
472 OID_802_11_FRAGMENTATION_THRESHOLD, &fthr);
474 lbs_deb_leave_args(LBS_DEB_WEXT, "ret %d", ret);
478 static int wlan_get_frag(struct net_device *dev, struct iw_request_info *info,
479 struct iw_param *vwrq, char *extra)
482 wlan_private *priv = dev->priv;
483 wlan_adapter *adapter = priv->adapter;
485 lbs_deb_enter(LBS_DEB_WEXT);
487 adapter->fragthsd = 0;
488 ret = libertas_prepare_and_send_command(priv,
490 cmd_act_get, cmd_option_waitforrsp,
491 OID_802_11_FRAGMENTATION_THRESHOLD, NULL);
495 vwrq->value = adapter->fragthsd;
496 vwrq->disabled = ((vwrq->value < MRVDRV_FRAG_MIN_VALUE)
497 || (vwrq->value > MRVDRV_FRAG_MAX_VALUE));
501 lbs_deb_leave_args(LBS_DEB_WEXT, "ret %d", ret);
505 static int wlan_get_mode(struct net_device *dev,
506 struct iw_request_info *info, u32 * uwrq, char *extra)
508 wlan_private *priv = dev->priv;
509 wlan_adapter *adapter = priv->adapter;
511 lbs_deb_enter(LBS_DEB_WEXT);
513 *uwrq = adapter->mode;
515 lbs_deb_leave(LBS_DEB_WEXT);
519 static int mesh_wlan_get_mode(struct net_device *dev,
520 struct iw_request_info *info, u32 * uwrq,
523 lbs_deb_enter(LBS_DEB_WEXT);
525 *uwrq = IW_MODE_REPEAT ;
527 lbs_deb_leave(LBS_DEB_WEXT);
531 static int wlan_get_txpow(struct net_device *dev,
532 struct iw_request_info *info,
533 struct iw_param *vwrq, char *extra)
536 wlan_private *priv = dev->priv;
537 wlan_adapter *adapter = priv->adapter;
539 lbs_deb_enter(LBS_DEB_WEXT);
541 ret = libertas_prepare_and_send_command(priv,
542 cmd_802_11_rf_tx_power,
543 cmd_act_tx_power_opt_get,
544 cmd_option_waitforrsp, 0, NULL);
549 lbs_deb_wext("tx power level %d dbm\n", adapter->txpowerlevel);
550 vwrq->value = adapter->txpowerlevel;
552 if (adapter->radioon) {
554 vwrq->flags = IW_TXPOW_DBM;
560 lbs_deb_leave_args(LBS_DEB_WEXT, "ret %d", ret);
564 static int wlan_set_retry(struct net_device *dev, struct iw_request_info *info,
565 struct iw_param *vwrq, char *extra)
568 wlan_private *priv = dev->priv;
569 wlan_adapter *adapter = priv->adapter;
571 lbs_deb_enter(LBS_DEB_WEXT);
573 if (vwrq->flags == IW_RETRY_LIMIT) {
574 /* The MAC has a 4-bit Total_Tx_Count register
575 Total_Tx_Count = 1 + Tx_Retry_Count */
576 #define TX_RETRY_MIN 0
577 #define TX_RETRY_MAX 14
578 if (vwrq->value < TX_RETRY_MIN || vwrq->value > TX_RETRY_MAX)
581 /* Adding 1 to convert retry count to try count */
582 adapter->txretrycount = vwrq->value + 1;
584 ret = libertas_prepare_and_send_command(priv, cmd_802_11_snmp_mib,
586 cmd_option_waitforrsp,
587 OID_802_11_TX_RETRYCOUNT, NULL);
596 lbs_deb_leave_args(LBS_DEB_WEXT, "ret %d", ret);
600 static int wlan_get_retry(struct net_device *dev, struct iw_request_info *info,
601 struct iw_param *vwrq, char *extra)
603 wlan_private *priv = dev->priv;
604 wlan_adapter *adapter = priv->adapter;
607 lbs_deb_enter(LBS_DEB_WEXT);
609 adapter->txretrycount = 0;
610 ret = libertas_prepare_and_send_command(priv,
612 cmd_act_get, cmd_option_waitforrsp,
613 OID_802_11_TX_RETRYCOUNT, NULL);
619 vwrq->flags = IW_RETRY_LIMIT;
620 /* Subtract 1 to convert try count to retry count */
621 vwrq->value = adapter->txretrycount - 1;
625 lbs_deb_leave_args(LBS_DEB_WEXT, "ret %d", ret);
629 static inline void sort_channels(struct iw_freq *freq, int num)
634 for (i = 0; i < num; i++)
635 for (j = i + 1; j < num; j++)
636 if (freq[i].i > freq[j].i) {
640 freq[i].i = freq[j].i;
641 freq[i].m = freq[j].m;
651 Infra G(12) A(8) B(4) G(12)
652 Adhoc A+B(12) A(8) B(4) B(4)
660 * @brief Get Range Info
662 * @param dev A pointer to net_device structure
663 * @param info A pointer to iw_request_info structure
664 * @param vwrq A pointer to iw_param structure
665 * @param extra A pointer to extra data buf
666 * @return 0 --success, otherwise fail
668 static int wlan_get_range(struct net_device *dev, struct iw_request_info *info,
669 struct iw_point *dwrq, char *extra)
672 wlan_private *priv = dev->priv;
673 wlan_adapter *adapter = priv->adapter;
674 struct iw_range *range = (struct iw_range *)extra;
675 struct chan_freq_power *cfp;
676 u8 rates[WLAN_SUPPORTED_RATES];
680 lbs_deb_enter(LBS_DEB_WEXT);
682 dwrq->length = sizeof(struct iw_range);
683 memset(range, 0, sizeof(struct iw_range));
688 memset(rates, 0, sizeof(rates));
689 range->num_bitrates = get_active_data_rates(adapter, rates);
691 for (i = 0; i < min_t(__u8, range->num_bitrates, IW_MAX_BITRATES) && rates[i];
693 range->bitrate[i] = (rates[i] & 0x7f) * 500000;
695 range->num_bitrates = i;
696 lbs_deb_wext("IW_MAX_BITRATES %d, num_bitrates %d\n", IW_MAX_BITRATES,
697 range->num_bitrates);
699 range->num_frequency = 0;
700 if (priv->adapter->enable11d &&
701 adapter->connect_status == libertas_connected) {
705 struct parsed_region_chan_11d *parsed_region_chan =
706 &adapter->parsed_region_chan;
708 if (parsed_region_chan == NULL) {
709 lbs_deb_wext("11d: parsed_region_chan is NULL\n");
712 band = parsed_region_chan->band;
713 lbs_deb_wext("band %d, nr_char %d\n", band,
714 parsed_region_chan->nr_chan);
716 for (i = 0; (range->num_frequency < IW_MAX_FREQUENCIES)
717 && (i < parsed_region_chan->nr_chan); i++) {
718 chan_no = parsed_region_chan->chanpwr[i].chan;
719 lbs_deb_wext("chan_no %d\n", chan_no);
720 range->freq[range->num_frequency].i = (long)chan_no;
721 range->freq[range->num_frequency].m =
722 (long)libertas_chan_2_freq(chan_no, band) * 100000;
723 range->freq[range->num_frequency].e = 1;
724 range->num_frequency++;
729 for (j = 0; (range->num_frequency < IW_MAX_FREQUENCIES)
730 && (j < sizeof(adapter->region_channel)
731 / sizeof(adapter->region_channel[0])); j++) {
732 cfp = adapter->region_channel[j].CFP;
733 for (i = 0; (range->num_frequency < IW_MAX_FREQUENCIES)
734 && adapter->region_channel[j].valid
736 && (i < adapter->region_channel[j].nrcfp); i++) {
737 range->freq[range->num_frequency].i =
739 range->freq[range->num_frequency].m =
740 (long)cfp->freq * 100000;
741 range->freq[range->num_frequency].e = 1;
743 range->num_frequency++;
748 lbs_deb_wext("IW_MAX_FREQUENCIES %d, num_frequency %d\n",
749 IW_MAX_FREQUENCIES, range->num_frequency);
751 range->num_channels = range->num_frequency;
753 sort_channels(&range->freq[0], range->num_frequency);
756 * Set an indication of the max TCP throughput in bit/s that we can
757 * expect using this interface
760 range->throughput = 5000 * 1000;
762 range->throughput = 1500 * 1000;
764 range->min_rts = MRVDRV_RTS_MIN_VALUE;
765 range->max_rts = MRVDRV_RTS_MAX_VALUE;
766 range->min_frag = MRVDRV_FRAG_MIN_VALUE;
767 range->max_frag = MRVDRV_FRAG_MAX_VALUE;
769 range->encoding_size[0] = 5;
770 range->encoding_size[1] = 13;
771 range->num_encoding_sizes = 2;
772 range->max_encoding_tokens = 4;
774 range->min_pmp = 1000000;
775 range->max_pmp = 120000000;
776 range->min_pmt = 1000;
777 range->max_pmt = 1000000;
778 range->pmp_flags = IW_POWER_PERIOD;
779 range->pmt_flags = IW_POWER_TIMEOUT;
780 range->pm_capa = IW_POWER_PERIOD | IW_POWER_TIMEOUT | IW_POWER_ALL_R;
783 * Minimum version we recommend
785 range->we_version_source = 15;
788 * Version we are compiled with
790 range->we_version_compiled = WIRELESS_EXT;
792 range->retry_capa = IW_RETRY_LIMIT;
793 range->retry_flags = IW_RETRY_LIMIT | IW_RETRY_MAX;
795 range->min_retry = TX_RETRY_MIN;
796 range->max_retry = TX_RETRY_MAX;
799 * Set the qual, level and noise range values
801 range->max_qual.qual = 100;
802 range->max_qual.level = 0;
803 range->max_qual.noise = 0;
804 range->max_qual.updated = IW_QUAL_ALL_UPDATED | IW_QUAL_DBM;
806 range->avg_qual.qual = 70;
807 /* TODO: Find real 'good' to 'bad' threshold value for RSSI */
808 range->avg_qual.level = 0;
809 range->avg_qual.noise = 0;
810 range->avg_qual.updated = IW_QUAL_ALL_UPDATED | IW_QUAL_DBM;
812 range->sensitivity = 0;
815 * Setup the supported power level ranges
817 memset(range->txpower, 0, sizeof(range->txpower));
818 range->txpower[0] = 5;
819 range->txpower[1] = 7;
820 range->txpower[2] = 9;
821 range->txpower[3] = 11;
822 range->txpower[4] = 13;
823 range->txpower[5] = 15;
824 range->txpower[6] = 17;
825 range->txpower[7] = 19;
827 range->num_txpower = 8;
828 range->txpower_capa = IW_TXPOW_DBM;
829 range->txpower_capa |= IW_TXPOW_RANGE;
831 range->event_capa[0] = (IW_EVENT_CAPA_K_0 |
832 IW_EVENT_CAPA_MASK(SIOCGIWAP) |
833 IW_EVENT_CAPA_MASK(SIOCGIWSCAN));
834 range->event_capa[1] = IW_EVENT_CAPA_K_1;
836 if (adapter->fwcapinfo & FW_CAPINFO_WPA) {
837 range->enc_capa = IW_ENC_CAPA_WPA
839 | IW_ENC_CAPA_CIPHER_TKIP
840 | IW_ENC_CAPA_CIPHER_CCMP;
844 lbs_deb_leave(LBS_DEB_WEXT);
848 static int wlan_set_power(struct net_device *dev, struct iw_request_info *info,
849 struct iw_param *vwrq, char *extra)
851 wlan_private *priv = dev->priv;
852 wlan_adapter *adapter = priv->adapter;
854 lbs_deb_enter(LBS_DEB_WEXT);
856 /* PS is currently supported only in Infrastructure mode
857 * Remove this check if it is to be supported in IBSS mode also
860 if (vwrq->disabled) {
861 adapter->psmode = wlan802_11powermodecam;
862 if (adapter->psstate != PS_STATE_FULL_POWER) {
863 libertas_ps_wakeup(priv, cmd_option_waitforrsp);
869 if ((vwrq->flags & IW_POWER_TYPE) == IW_POWER_TIMEOUT) {
871 "setting power timeout is not supported\n");
873 } else if ((vwrq->flags & IW_POWER_TYPE) == IW_POWER_PERIOD) {
874 lbs_deb_wext("setting power period not supported\n");
878 if (adapter->psmode != wlan802_11powermodecam) {
882 adapter->psmode = wlan802_11powermodemax_psp;
884 if (adapter->connect_status == libertas_connected) {
885 libertas_ps_sleep(priv, cmd_option_waitforrsp);
888 lbs_deb_leave(LBS_DEB_WEXT);
892 static int wlan_get_power(struct net_device *dev, struct iw_request_info *info,
893 struct iw_param *vwrq, char *extra)
895 wlan_private *priv = dev->priv;
896 wlan_adapter *adapter = priv->adapter;
899 lbs_deb_enter(LBS_DEB_WEXT);
901 mode = adapter->psmode;
903 if ((vwrq->disabled = (mode == wlan802_11powermodecam))
904 || adapter->connect_status == libertas_disconnected)
912 lbs_deb_leave(LBS_DEB_WEXT);
917 * iwpriv settable callbacks
920 static const iw_handler wlan_private_handler[] = {
921 NULL, /* SIOCIWFIRSTPRIV */
924 static const struct iw_priv_args wlan_private_args[] = {
926 * { cmd, set_args, get_args, name }
928 /* Using iwpriv sub-command feature */
930 WLAN_SETONEINT_GETNONE, /* IOCTL: 24 */
931 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1,
936 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1,
940 WLAN_SUBCMD_MESH_SET_TTL,
941 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1,
945 WLAN_SETNONE_GETONEINT,
947 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1,
952 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1,
955 WLAN_SUBCMD_FWT_CLEANUP,
957 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1,
960 WLAN_SUBCMD_FWT_TIME,
962 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1,
965 WLAN_SUBCMD_MESH_GET_TTL,
967 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1,
970 WLAN_SETNONE_GETNONE,
975 WLAN_SUBCMD_FWT_RESET,
980 WLAN_SUBCMD_BT_RESET,
985 WLAN_SET128CHAR_GET128CHAR,
986 IW_PRIV_TYPE_CHAR | 128,
987 IW_PRIV_TYPE_CHAR | 128,
992 IW_PRIV_TYPE_CHAR | 128,
993 IW_PRIV_TYPE_CHAR | 128,
997 IW_PRIV_TYPE_CHAR | 128,
998 IW_PRIV_TYPE_CHAR | 128,
1001 WLAN_SUBCMD_BT_LIST,
1002 IW_PRIV_TYPE_CHAR | 128,
1003 IW_PRIV_TYPE_CHAR | 128,
1006 WLAN_SUBCMD_BT_SET_INVERT,
1007 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1,
1011 WLAN_SUBCMD_BT_GET_INVERT,
1013 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1,
1015 /* FWT Management */
1017 WLAN_SUBCMD_FWT_ADD,
1018 IW_PRIV_TYPE_CHAR | 128,
1019 IW_PRIV_TYPE_CHAR | 128,
1022 WLAN_SUBCMD_FWT_DEL,
1023 IW_PRIV_TYPE_CHAR | 128,
1024 IW_PRIV_TYPE_CHAR | 128,
1027 WLAN_SUBCMD_FWT_LOOKUP,
1028 IW_PRIV_TYPE_CHAR | 128,
1029 IW_PRIV_TYPE_CHAR | 128,
1032 WLAN_SUBCMD_FWT_LIST_NEIGHBOR,
1033 IW_PRIV_TYPE_CHAR | 128,
1034 IW_PRIV_TYPE_CHAR | 128,
1037 WLAN_SUBCMD_FWT_LIST,
1038 IW_PRIV_TYPE_CHAR | 128,
1039 IW_PRIV_TYPE_CHAR | 128,
1042 WLAN_SUBCMD_FWT_LIST_ROUTE,
1043 IW_PRIV_TYPE_CHAR | 128,
1044 IW_PRIV_TYPE_CHAR | 128,
1047 WLAN_SET_GET_SIXTEEN_INT,
1048 IW_PRIV_TYPE_INT | 16,
1049 IW_PRIV_TYPE_INT | 16,
1053 IW_PRIV_TYPE_INT | 16,
1054 IW_PRIV_TYPE_INT | 16,
1058 static struct iw_statistics *wlan_get_wireless_stats(struct net_device *dev)
1068 wlan_private *priv = dev->priv;
1069 wlan_adapter *adapter = priv->adapter;
1073 int stats_valid = 0;
1077 lbs_deb_enter(LBS_DEB_WEXT);
1079 priv->wstats.status = adapter->mode;
1081 /* If we're not associated, all quality values are meaningless */
1082 if (adapter->connect_status != libertas_connected)
1085 /* Quality by RSSI */
1086 priv->wstats.qual.level =
1087 CAL_RSSI(adapter->SNR[TYPE_BEACON][TYPE_NOAVG],
1088 adapter->NF[TYPE_BEACON][TYPE_NOAVG]);
1090 if (adapter->NF[TYPE_BEACON][TYPE_NOAVG] == 0) {
1091 priv->wstats.qual.noise = MRVDRV_NF_DEFAULT_SCAN_VALUE;
1093 priv->wstats.qual.noise =
1094 CAL_NF(adapter->NF[TYPE_BEACON][TYPE_NOAVG]);
1097 lbs_deb_wext("signal level %#x\n", priv->wstats.qual.level);
1098 lbs_deb_wext("noise %#x\n", priv->wstats.qual.noise);
1100 rssi = priv->wstats.qual.level - priv->wstats.qual.noise;
1102 rssi_qual = rssi * POOR / 10;
1104 rssi_qual = (rssi - 15) * (FAIR - POOR) / 5 + POOR;
1106 rssi_qual = (rssi - 20) * (GOOD - FAIR) / 5 + FAIR;
1108 rssi_qual = (rssi - 30) * (VERY_GOOD - GOOD) /
1111 rssi_qual = (rssi - 40) * (PERFECT - VERY_GOOD) /
1113 quality = rssi_qual;
1115 /* Quality by TX errors */
1116 priv->wstats.discard.retries = priv->stats.tx_errors;
1118 tx_retries = le16_to_cpu(adapter->logmsg.retry);
1120 if (tx_retries > 75)
1121 tx_qual = (90 - tx_retries) * POOR / 15;
1122 else if (tx_retries > 70)
1123 tx_qual = (75 - tx_retries) * (FAIR - POOR) / 5 + POOR;
1124 else if (tx_retries > 65)
1125 tx_qual = (70 - tx_retries) * (GOOD - FAIR) / 5 + FAIR;
1126 else if (tx_retries > 50)
1127 tx_qual = (65 - tx_retries) * (VERY_GOOD - GOOD) /
1130 tx_qual = (50 - tx_retries) *
1131 (PERFECT - VERY_GOOD) / 50 + VERY_GOOD;
1132 quality = min(quality, tx_qual);
1134 priv->wstats.discard.code = le16_to_cpu(adapter->logmsg.wepundecryptable);
1135 priv->wstats.discard.fragment = le16_to_cpu(adapter->logmsg.rxfrag);
1136 priv->wstats.discard.retries = tx_retries;
1137 priv->wstats.discard.misc = le16_to_cpu(adapter->logmsg.ackfailure);
1139 /* Calculate quality */
1140 priv->wstats.qual.qual = max(quality, (u32)100);
1141 priv->wstats.qual.updated = IW_QUAL_ALL_UPDATED | IW_QUAL_DBM;
1144 /* update stats asynchronously for future calls */
1145 libertas_prepare_and_send_command(priv, cmd_802_11_rssi, 0,
1147 libertas_prepare_and_send_command(priv, cmd_802_11_get_log, 0,
1151 priv->wstats.miss.beacon = 0;
1152 priv->wstats.discard.retries = 0;
1153 priv->wstats.qual.qual = 0;
1154 priv->wstats.qual.level = 0;
1155 priv->wstats.qual.noise = 0;
1156 priv->wstats.qual.updated = IW_QUAL_ALL_UPDATED;
1157 priv->wstats.qual.updated |= IW_QUAL_NOISE_INVALID |
1158 IW_QUAL_QUAL_INVALID | IW_QUAL_LEVEL_INVALID;
1161 lbs_deb_leave(LBS_DEB_WEXT);
1162 return &priv->wstats;
1167 static int wlan_set_freq(struct net_device *dev, struct iw_request_info *info,
1168 struct iw_freq *fwrq, char *extra)
1171 wlan_private *priv = dev->priv;
1172 wlan_adapter *adapter = priv->adapter;
1173 struct chan_freq_power *cfp;
1174 struct assoc_request * assoc_req;
1176 lbs_deb_enter(LBS_DEB_WEXT);
1178 mutex_lock(&adapter->lock);
1179 assoc_req = wlan_get_association_request(adapter);
1185 /* If setting by frequency, convert to a channel */
1187 long f = fwrq->m / 100000;
1189 cfp = find_cfp_by_band_and_freq(adapter, 0, f);
1191 lbs_deb_wext("invalid freq %ld\n", f);
1196 fwrq->m = (int) cfp->channel;
1199 /* Setting by channel number */
1200 if (fwrq->m > 1000 || fwrq->e > 0) {
1204 cfp = libertas_find_cfp_by_band_and_channel(adapter, 0, fwrq->m);
1209 assoc_req->channel = fwrq->m;
1214 set_bit(ASSOC_FLAG_CHANNEL, &assoc_req->flags);
1215 wlan_postpone_association_work(priv);
1217 wlan_cancel_association_work(priv);
1219 mutex_unlock(&adapter->lock);
1221 lbs_deb_leave_args(LBS_DEB_WEXT, "ret %d", ret);
1226 * @brief use index to get the data rate
1228 * @param index The index of data rate
1229 * @return data rate or 0
1231 u32 libertas_index_to_data_rate(u8 index)
1233 if (index >= sizeof(libertas_wlan_data_rates))
1236 return libertas_wlan_data_rates[index];
1240 * @brief use rate to get the index
1242 * @param rate data rate
1243 * @return index or 0
1245 u8 libertas_data_rate_to_index(u32 rate)
1250 if ((ptr = memchr(libertas_wlan_data_rates, (u8) rate,
1251 sizeof(libertas_wlan_data_rates))))
1252 return (ptr - libertas_wlan_data_rates);
1257 static int wlan_set_rate(struct net_device *dev, struct iw_request_info *info,
1258 struct iw_param *vwrq, char *extra)
1260 wlan_private *priv = dev->priv;
1261 wlan_adapter *adapter = priv->adapter;
1265 u8 rates[WLAN_SUPPORTED_RATES];
1268 lbs_deb_enter(LBS_DEB_WEXT);
1270 lbs_deb_wext("vwrq->value %d\n", vwrq->value);
1272 if (vwrq->value == -1) {
1273 action = cmd_act_set_tx_auto; // Auto
1274 adapter->is_datarate_auto = 1;
1275 adapter->datarate = 0;
1277 if (vwrq->value % 100000) {
1281 data_rate = vwrq->value / 500000;
1283 memset(rates, 0, sizeof(rates));
1284 get_active_data_rates(adapter, rates);
1287 lbs_deb_wext("rate=0x%X, wanted data_rate 0x%X\n", *rate,
1289 if ((*rate & 0x7f) == (data_rate & 0x7f))
1294 lbs_pr_alert("fixed data rate 0x%X out "
1295 "of range\n", data_rate);
1299 adapter->datarate = data_rate;
1300 action = cmd_act_set_tx_fix_rate;
1301 adapter->is_datarate_auto = 0;
1304 ret = libertas_prepare_and_send_command(priv, cmd_802_11_data_rate,
1305 action, cmd_option_waitforrsp, 0, NULL);
1307 lbs_deb_leave_args(LBS_DEB_WEXT, "ret %d", ret);
1311 static int wlan_get_rate(struct net_device *dev, struct iw_request_info *info,
1312 struct iw_param *vwrq, char *extra)
1314 wlan_private *priv = dev->priv;
1315 wlan_adapter *adapter = priv->adapter;
1317 lbs_deb_enter(LBS_DEB_WEXT);
1319 if (adapter->is_datarate_auto) {
1325 vwrq->value = adapter->datarate * 500000;
1327 lbs_deb_leave(LBS_DEB_WEXT);
1331 static int wlan_set_mode(struct net_device *dev,
1332 struct iw_request_info *info, u32 * uwrq, char *extra)
1335 wlan_private *priv = dev->priv;
1336 wlan_adapter *adapter = priv->adapter;
1337 struct assoc_request * assoc_req;
1339 lbs_deb_enter(LBS_DEB_WEXT);
1341 if ( (*uwrq != IW_MODE_ADHOC)
1342 && (*uwrq != IW_MODE_INFRA)
1343 && (*uwrq != IW_MODE_AUTO)) {
1344 lbs_deb_wext("Invalid mode: 0x%x\n", *uwrq);
1349 mutex_lock(&adapter->lock);
1350 assoc_req = wlan_get_association_request(adapter);
1353 wlan_cancel_association_work(priv);
1355 assoc_req->mode = *uwrq;
1356 set_bit(ASSOC_FLAG_MODE, &assoc_req->flags);
1357 wlan_postpone_association_work(priv);
1358 lbs_deb_wext("Switching to mode: 0x%x\n", *uwrq);
1360 mutex_unlock(&adapter->lock);
1363 lbs_deb_leave_args(LBS_DEB_WEXT, "ret %d", ret);
1369 * @brief Get Encryption key
1371 * @param dev A pointer to net_device structure
1372 * @param info A pointer to iw_request_info structure
1373 * @param vwrq A pointer to iw_param structure
1374 * @param extra A pointer to extra data buf
1375 * @return 0 --success, otherwise fail
1377 static int wlan_get_encode(struct net_device *dev,
1378 struct iw_request_info *info,
1379 struct iw_point *dwrq, u8 * extra)
1381 wlan_private *priv = dev->priv;
1382 wlan_adapter *adapter = priv->adapter;
1383 int index = (dwrq->flags & IW_ENCODE_INDEX) - 1;
1385 lbs_deb_enter(LBS_DEB_WEXT);
1387 lbs_deb_wext("flags 0x%x, index %d, length %d, wep_tx_keyidx %d\n",
1388 dwrq->flags, index, dwrq->length, adapter->wep_tx_keyidx);
1392 /* Authentication method */
1393 switch (adapter->secinfo.auth_mode) {
1394 case IW_AUTH_ALG_OPEN_SYSTEM:
1395 dwrq->flags = IW_ENCODE_OPEN;
1398 case IW_AUTH_ALG_SHARED_KEY:
1399 case IW_AUTH_ALG_LEAP:
1400 dwrq->flags = IW_ENCODE_RESTRICTED;
1403 dwrq->flags = IW_ENCODE_DISABLED | IW_ENCODE_OPEN;
1407 if ( adapter->secinfo.wep_enabled
1408 || adapter->secinfo.WPAenabled
1409 || adapter->secinfo.WPA2enabled) {
1410 dwrq->flags &= ~IW_ENCODE_DISABLED;
1412 dwrq->flags |= IW_ENCODE_DISABLED;
1415 memset(extra, 0, 16);
1417 mutex_lock(&adapter->lock);
1419 /* Default to returning current transmit key */
1421 index = adapter->wep_tx_keyidx;
1423 if ((adapter->wep_keys[index].len) && adapter->secinfo.wep_enabled) {
1424 memcpy(extra, adapter->wep_keys[index].key,
1425 adapter->wep_keys[index].len);
1426 dwrq->length = adapter->wep_keys[index].len;
1428 dwrq->flags |= (index + 1);
1429 /* Return WEP enabled */
1430 dwrq->flags &= ~IW_ENCODE_DISABLED;
1431 } else if ((adapter->secinfo.WPAenabled)
1432 || (adapter->secinfo.WPA2enabled)) {
1433 /* return WPA enabled */
1434 dwrq->flags &= ~IW_ENCODE_DISABLED;
1436 dwrq->flags |= IW_ENCODE_DISABLED;
1439 mutex_unlock(&adapter->lock);
1441 dwrq->flags |= IW_ENCODE_NOKEY;
1443 lbs_deb_wext("key: " MAC_FMT ", keylen %d\n",
1444 extra[0], extra[1], extra[2],
1445 extra[3], extra[4], extra[5], dwrq->length);
1447 lbs_deb_wext("return flags 0x%x\n", dwrq->flags);
1449 lbs_deb_leave(LBS_DEB_WEXT);
1454 * @brief Set Encryption key (internal)
1456 * @param priv A pointer to private card structure
1457 * @param key_material A pointer to key material
1458 * @param key_length length of key material
1459 * @param index key index to set
1460 * @param set_tx_key Force set TX key (1 = yes, 0 = no)
1461 * @return 0 --success, otherwise fail
1463 static int wlan_set_wep_key(struct assoc_request *assoc_req,
1464 const char *key_material,
1470 struct WLAN_802_11_KEY *pkey;
1472 lbs_deb_enter(LBS_DEB_WEXT);
1474 /* Paranoid validation of key index */
1480 /* validate max key length */
1481 if (key_length > KEY_LEN_WEP_104) {
1486 pkey = &assoc_req->wep_keys[index];
1488 if (key_length > 0) {
1489 memset(pkey, 0, sizeof(struct WLAN_802_11_KEY));
1490 pkey->type = KEY_TYPE_ID_WEP;
1492 /* Standardize the key length */
1493 pkey->len = (key_length > KEY_LEN_WEP_40) ?
1494 KEY_LEN_WEP_104 : KEY_LEN_WEP_40;
1495 memcpy(pkey->key, key_material, key_length);
1499 /* Ensure the chosen key is valid */
1501 lbs_deb_wext("key not set, so cannot enable it\n");
1505 assoc_req->wep_tx_keyidx = index;
1508 assoc_req->secinfo.wep_enabled = 1;
1511 lbs_deb_leave_args(LBS_DEB_WEXT, "ret %d", ret);
1515 static int validate_key_index(u16 def_index, u16 raw_index,
1516 u16 *out_index, u16 *is_default)
1518 if (!out_index || !is_default)
1521 /* Verify index if present, otherwise use default TX key index */
1522 if (raw_index > 0) {
1525 *out_index = raw_index - 1;
1527 *out_index = def_index;
1533 static void disable_wep(struct assoc_request *assoc_req)
1537 lbs_deb_enter(LBS_DEB_WEXT);
1539 /* Set Open System auth mode */
1540 assoc_req->secinfo.auth_mode = IW_AUTH_ALG_OPEN_SYSTEM;
1542 /* Clear WEP keys and mark WEP as disabled */
1543 assoc_req->secinfo.wep_enabled = 0;
1544 for (i = 0; i < 4; i++)
1545 assoc_req->wep_keys[i].len = 0;
1547 set_bit(ASSOC_FLAG_SECINFO, &assoc_req->flags);
1548 set_bit(ASSOC_FLAG_WEP_KEYS, &assoc_req->flags);
1550 lbs_deb_leave(LBS_DEB_WEXT);
1553 static void disable_wpa(struct assoc_request *assoc_req)
1555 lbs_deb_enter(LBS_DEB_WEXT);
1557 memset(&assoc_req->wpa_mcast_key, 0, sizeof (struct WLAN_802_11_KEY));
1558 assoc_req->wpa_mcast_key.flags = KEY_INFO_WPA_MCAST;
1559 set_bit(ASSOC_FLAG_WPA_MCAST_KEY, &assoc_req->flags);
1561 memset(&assoc_req->wpa_unicast_key, 0, sizeof (struct WLAN_802_11_KEY));
1562 assoc_req->wpa_unicast_key.flags = KEY_INFO_WPA_UNICAST;
1563 set_bit(ASSOC_FLAG_WPA_UCAST_KEY, &assoc_req->flags);
1565 assoc_req->secinfo.WPAenabled = 0;
1566 assoc_req->secinfo.WPA2enabled = 0;
1567 set_bit(ASSOC_FLAG_SECINFO, &assoc_req->flags);
1569 lbs_deb_leave(LBS_DEB_WEXT);
1573 * @brief Set Encryption key
1575 * @param dev A pointer to net_device structure
1576 * @param info A pointer to iw_request_info structure
1577 * @param vwrq A pointer to iw_param structure
1578 * @param extra A pointer to extra data buf
1579 * @return 0 --success, otherwise fail
1581 static int wlan_set_encode(struct net_device *dev,
1582 struct iw_request_info *info,
1583 struct iw_point *dwrq, char *extra)
1586 wlan_private *priv = dev->priv;
1587 wlan_adapter *adapter = priv->adapter;
1588 struct assoc_request * assoc_req;
1589 u16 is_default = 0, index = 0, set_tx_key = 0;
1591 lbs_deb_enter(LBS_DEB_WEXT);
1593 mutex_lock(&adapter->lock);
1594 assoc_req = wlan_get_association_request(adapter);
1600 if (dwrq->flags & IW_ENCODE_DISABLED) {
1601 disable_wep (assoc_req);
1602 disable_wpa (assoc_req);
1606 ret = validate_key_index(assoc_req->wep_tx_keyidx,
1607 (dwrq->flags & IW_ENCODE_INDEX),
1608 &index, &is_default);
1614 /* If WEP isn't enabled, or if there is no key data but a valid
1615 * index, set the TX key.
1617 if (!assoc_req->secinfo.wep_enabled || (dwrq->length == 0 && !is_default))
1620 ret = wlan_set_wep_key(assoc_req, extra, dwrq->length, index, set_tx_key);
1625 set_bit(ASSOC_FLAG_WEP_KEYS, &assoc_req->flags);
1627 set_bit(ASSOC_FLAG_WEP_TX_KEYIDX, &assoc_req->flags);
1629 if (dwrq->flags & IW_ENCODE_RESTRICTED) {
1630 assoc_req->secinfo.auth_mode = IW_AUTH_ALG_SHARED_KEY;
1631 } else if (dwrq->flags & IW_ENCODE_OPEN) {
1632 assoc_req->secinfo.auth_mode = IW_AUTH_ALG_OPEN_SYSTEM;
1637 set_bit(ASSOC_FLAG_SECINFO, &assoc_req->flags);
1638 wlan_postpone_association_work(priv);
1640 wlan_cancel_association_work(priv);
1642 mutex_unlock(&adapter->lock);
1644 lbs_deb_leave_args(LBS_DEB_WEXT, "ret %d", ret);
1649 * @brief Get Extended Encryption key (WPA/802.1x and WEP)
1651 * @param dev A pointer to net_device structure
1652 * @param info A pointer to iw_request_info structure
1653 * @param vwrq A pointer to iw_param structure
1654 * @param extra A pointer to extra data buf
1655 * @return 0 on success, otherwise failure
1657 static int wlan_get_encodeext(struct net_device *dev,
1658 struct iw_request_info *info,
1659 struct iw_point *dwrq,
1663 wlan_private *priv = dev->priv;
1664 wlan_adapter *adapter = priv->adapter;
1665 struct iw_encode_ext *ext = (struct iw_encode_ext *)extra;
1666 int index, max_key_len;
1668 lbs_deb_enter(LBS_DEB_WEXT);
1670 max_key_len = dwrq->length - sizeof(*ext);
1671 if (max_key_len < 0)
1674 index = dwrq->flags & IW_ENCODE_INDEX;
1676 if (index < 1 || index > 4)
1680 index = adapter->wep_tx_keyidx;
1683 if (!ext->ext_flags & IW_ENCODE_EXT_GROUP_KEY &&
1684 ext->alg != IW_ENCODE_ALG_WEP) {
1685 if (index != 0 || adapter->mode != IW_MODE_INFRA)
1689 dwrq->flags = index + 1;
1690 memset(ext, 0, sizeof(*ext));
1692 if ( !adapter->secinfo.wep_enabled
1693 && !adapter->secinfo.WPAenabled
1694 && !adapter->secinfo.WPA2enabled) {
1695 ext->alg = IW_ENCODE_ALG_NONE;
1697 dwrq->flags |= IW_ENCODE_DISABLED;
1701 if ( adapter->secinfo.wep_enabled
1702 && !adapter->secinfo.WPAenabled
1703 && !adapter->secinfo.WPA2enabled) {
1705 ext->alg = IW_ENCODE_ALG_WEP;
1706 ext->key_len = adapter->wep_keys[index].len;
1707 key = &adapter->wep_keys[index].key[0];
1708 } else if ( !adapter->secinfo.wep_enabled
1709 && (adapter->secinfo.WPAenabled ||
1710 adapter->secinfo.WPA2enabled)) {
1712 struct WLAN_802_11_KEY * pkey = NULL;
1714 if ( adapter->wpa_mcast_key.len
1715 && (adapter->wpa_mcast_key.flags & KEY_INFO_WPA_ENABLED))
1716 pkey = &adapter->wpa_mcast_key;
1717 else if ( adapter->wpa_unicast_key.len
1718 && (adapter->wpa_unicast_key.flags & KEY_INFO_WPA_ENABLED))
1719 pkey = &adapter->wpa_unicast_key;
1722 if (pkey->type == KEY_TYPE_ID_AES) {
1723 ext->alg = IW_ENCODE_ALG_CCMP;
1725 ext->alg = IW_ENCODE_ALG_TKIP;
1727 ext->key_len = pkey->len;
1728 key = &pkey->key[0];
1730 ext->alg = IW_ENCODE_ALG_TKIP;
1737 if (ext->key_len > max_key_len) {
1743 memcpy(ext->key, key, ext->key_len);
1745 dwrq->flags |= IW_ENCODE_NOKEY;
1746 dwrq->flags |= IW_ENCODE_ENABLED;
1751 lbs_deb_leave_args(LBS_DEB_WEXT, "ret %d", ret);
1756 * @brief Set Encryption key Extended (WPA/802.1x and WEP)
1758 * @param dev A pointer to net_device structure
1759 * @param info A pointer to iw_request_info structure
1760 * @param vwrq A pointer to iw_param structure
1761 * @param extra A pointer to extra data buf
1762 * @return 0 --success, otherwise fail
1764 static int wlan_set_encodeext(struct net_device *dev,
1765 struct iw_request_info *info,
1766 struct iw_point *dwrq,
1770 wlan_private *priv = dev->priv;
1771 wlan_adapter *adapter = priv->adapter;
1772 struct iw_encode_ext *ext = (struct iw_encode_ext *)extra;
1774 struct assoc_request * assoc_req;
1776 lbs_deb_enter(LBS_DEB_WEXT);
1778 mutex_lock(&adapter->lock);
1779 assoc_req = wlan_get_association_request(adapter);
1785 if ((alg == IW_ENCODE_ALG_NONE) || (dwrq->flags & IW_ENCODE_DISABLED)) {
1786 disable_wep (assoc_req);
1787 disable_wpa (assoc_req);
1788 } else if (alg == IW_ENCODE_ALG_WEP) {
1789 u16 is_default = 0, index, set_tx_key = 0;
1791 ret = validate_key_index(assoc_req->wep_tx_keyidx,
1792 (dwrq->flags & IW_ENCODE_INDEX),
1793 &index, &is_default);
1797 /* If WEP isn't enabled, or if there is no key data but a valid
1798 * index, or if the set-TX-key flag was passed, set the TX key.
1800 if ( !assoc_req->secinfo.wep_enabled
1801 || (dwrq->length == 0 && !is_default)
1802 || (ext->ext_flags & IW_ENCODE_EXT_SET_TX_KEY))
1805 /* Copy key to driver */
1806 ret = wlan_set_wep_key (assoc_req, ext->key, ext->key_len, index,
1811 if (dwrq->flags & IW_ENCODE_RESTRICTED) {
1812 assoc_req->secinfo.auth_mode = IW_AUTH_ALG_SHARED_KEY;
1813 } else if (dwrq->flags & IW_ENCODE_OPEN) {
1814 assoc_req->secinfo.auth_mode = IW_AUTH_ALG_OPEN_SYSTEM;
1817 /* Mark the various WEP bits as modified */
1818 set_bit(ASSOC_FLAG_SECINFO, &assoc_req->flags);
1820 set_bit(ASSOC_FLAG_WEP_KEYS, &assoc_req->flags);
1822 set_bit(ASSOC_FLAG_WEP_TX_KEYIDX, &assoc_req->flags);
1823 } else if ((alg == IW_ENCODE_ALG_TKIP) || (alg == IW_ENCODE_ALG_CCMP)) {
1824 struct WLAN_802_11_KEY * pkey;
1826 /* validate key length */
1827 if (((alg == IW_ENCODE_ALG_TKIP)
1828 && (ext->key_len != KEY_LEN_WPA_TKIP))
1829 || ((alg == IW_ENCODE_ALG_CCMP)
1830 && (ext->key_len != KEY_LEN_WPA_AES))) {
1831 lbs_deb_wext("invalid size %d for key of alg"
1839 if (ext->ext_flags & IW_ENCODE_EXT_GROUP_KEY) {
1840 pkey = &assoc_req->wpa_mcast_key;
1841 set_bit(ASSOC_FLAG_WPA_MCAST_KEY, &assoc_req->flags);
1843 pkey = &assoc_req->wpa_unicast_key;
1844 set_bit(ASSOC_FLAG_WPA_UCAST_KEY, &assoc_req->flags);
1847 memset(pkey, 0, sizeof (struct WLAN_802_11_KEY));
1848 memcpy(pkey->key, ext->key, ext->key_len);
1849 pkey->len = ext->key_len;
1851 pkey->flags |= KEY_INFO_WPA_ENABLED;
1853 /* Do this after zeroing key structure */
1854 if (ext->ext_flags & IW_ENCODE_EXT_GROUP_KEY) {
1855 pkey->flags |= KEY_INFO_WPA_MCAST;
1857 pkey->flags |= KEY_INFO_WPA_UNICAST;
1860 if (alg == IW_ENCODE_ALG_TKIP) {
1861 pkey->type = KEY_TYPE_ID_TKIP;
1862 } else if (alg == IW_ENCODE_ALG_CCMP) {
1863 pkey->type = KEY_TYPE_ID_AES;
1869 /* If WPA isn't enabled yet, do that now */
1870 if ( assoc_req->secinfo.WPAenabled == 0
1871 && assoc_req->secinfo.WPA2enabled == 0) {
1872 assoc_req->secinfo.WPAenabled = 1;
1873 assoc_req->secinfo.WPA2enabled = 1;
1874 set_bit(ASSOC_FLAG_SECINFO, &assoc_req->flags);
1877 disable_wep (assoc_req);
1882 wlan_postpone_association_work(priv);
1884 wlan_cancel_association_work(priv);
1886 mutex_unlock(&adapter->lock);
1888 lbs_deb_leave_args(LBS_DEB_WEXT, "ret %d", ret);
1893 static int wlan_set_genie(struct net_device *dev,
1894 struct iw_request_info *info,
1895 struct iw_point *dwrq,
1898 wlan_private *priv = dev->priv;
1899 wlan_adapter *adapter = priv->adapter;
1901 struct assoc_request * assoc_req;
1903 lbs_deb_enter(LBS_DEB_WEXT);
1905 mutex_lock(&adapter->lock);
1906 assoc_req = wlan_get_association_request(adapter);
1912 if (dwrq->length > MAX_WPA_IE_LEN ||
1913 (dwrq->length && extra == NULL)) {
1919 memcpy(&assoc_req->wpa_ie[0], extra, dwrq->length);
1920 assoc_req->wpa_ie_len = dwrq->length;
1922 memset(&assoc_req->wpa_ie[0], 0, sizeof(adapter->wpa_ie));
1923 assoc_req->wpa_ie_len = 0;
1928 set_bit(ASSOC_FLAG_WPA_IE, &assoc_req->flags);
1929 wlan_postpone_association_work(priv);
1931 wlan_cancel_association_work(priv);
1933 mutex_unlock(&adapter->lock);
1935 lbs_deb_leave_args(LBS_DEB_WEXT, "ret %d", ret);
1939 static int wlan_get_genie(struct net_device *dev,
1940 struct iw_request_info *info,
1941 struct iw_point *dwrq,
1945 wlan_private *priv = dev->priv;
1946 wlan_adapter *adapter = priv->adapter;
1948 lbs_deb_enter(LBS_DEB_WEXT);
1950 if (adapter->wpa_ie_len == 0) {
1955 if (dwrq->length < adapter->wpa_ie_len) {
1960 dwrq->length = adapter->wpa_ie_len;
1961 memcpy(extra, &adapter->wpa_ie[0], adapter->wpa_ie_len);
1964 lbs_deb_leave_args(LBS_DEB_WEXT, "ret %d", ret);
1969 static int wlan_set_auth(struct net_device *dev,
1970 struct iw_request_info *info,
1971 struct iw_param *dwrq,
1974 wlan_private *priv = dev->priv;
1975 wlan_adapter *adapter = priv->adapter;
1976 struct assoc_request * assoc_req;
1980 lbs_deb_enter(LBS_DEB_WEXT);
1982 mutex_lock(&adapter->lock);
1983 assoc_req = wlan_get_association_request(adapter);
1989 switch (dwrq->flags & IW_AUTH_INDEX) {
1990 case IW_AUTH_TKIP_COUNTERMEASURES:
1991 case IW_AUTH_CIPHER_PAIRWISE:
1992 case IW_AUTH_CIPHER_GROUP:
1993 case IW_AUTH_KEY_MGMT:
1994 case IW_AUTH_DROP_UNENCRYPTED:
1996 * libertas does not use these parameters
2000 case IW_AUTH_WPA_VERSION:
2001 if (dwrq->value & IW_AUTH_WPA_VERSION_DISABLED) {
2002 assoc_req->secinfo.WPAenabled = 0;
2003 assoc_req->secinfo.WPA2enabled = 0;
2004 disable_wpa (assoc_req);
2006 if (dwrq->value & IW_AUTH_WPA_VERSION_WPA) {
2007 assoc_req->secinfo.WPAenabled = 1;
2008 assoc_req->secinfo.wep_enabled = 0;
2009 assoc_req->secinfo.auth_mode = IW_AUTH_ALG_OPEN_SYSTEM;
2011 if (dwrq->value & IW_AUTH_WPA_VERSION_WPA2) {
2012 assoc_req->secinfo.WPA2enabled = 1;
2013 assoc_req->secinfo.wep_enabled = 0;
2014 assoc_req->secinfo.auth_mode = IW_AUTH_ALG_OPEN_SYSTEM;
2019 case IW_AUTH_80211_AUTH_ALG:
2020 if (dwrq->value & IW_AUTH_ALG_SHARED_KEY) {
2021 assoc_req->secinfo.auth_mode = IW_AUTH_ALG_SHARED_KEY;
2022 } else if (dwrq->value & IW_AUTH_ALG_OPEN_SYSTEM) {
2023 assoc_req->secinfo.auth_mode = IW_AUTH_ALG_OPEN_SYSTEM;
2024 } else if (dwrq->value & IW_AUTH_ALG_LEAP) {
2025 assoc_req->secinfo.auth_mode = IW_AUTH_ALG_LEAP;
2032 case IW_AUTH_WPA_ENABLED:
2034 if (!assoc_req->secinfo.WPAenabled &&
2035 !assoc_req->secinfo.WPA2enabled) {
2036 assoc_req->secinfo.WPAenabled = 1;
2037 assoc_req->secinfo.WPA2enabled = 1;
2038 assoc_req->secinfo.wep_enabled = 0;
2039 assoc_req->secinfo.auth_mode = IW_AUTH_ALG_OPEN_SYSTEM;
2042 assoc_req->secinfo.WPAenabled = 0;
2043 assoc_req->secinfo.WPA2enabled = 0;
2044 disable_wpa (assoc_req);
2057 set_bit(ASSOC_FLAG_SECINFO, &assoc_req->flags);
2058 wlan_postpone_association_work(priv);
2059 } else if (ret != -EOPNOTSUPP) {
2060 wlan_cancel_association_work(priv);
2062 mutex_unlock(&adapter->lock);
2064 lbs_deb_leave_args(LBS_DEB_WEXT, "ret %d", ret);
2068 static int wlan_get_auth(struct net_device *dev,
2069 struct iw_request_info *info,
2070 struct iw_param *dwrq,
2074 wlan_private *priv = dev->priv;
2075 wlan_adapter *adapter = priv->adapter;
2077 lbs_deb_enter(LBS_DEB_WEXT);
2079 switch (dwrq->flags & IW_AUTH_INDEX) {
2080 case IW_AUTH_WPA_VERSION:
2082 if (adapter->secinfo.WPAenabled)
2083 dwrq->value |= IW_AUTH_WPA_VERSION_WPA;
2084 if (adapter->secinfo.WPA2enabled)
2085 dwrq->value |= IW_AUTH_WPA_VERSION_WPA2;
2087 dwrq->value |= IW_AUTH_WPA_VERSION_DISABLED;
2090 case IW_AUTH_80211_AUTH_ALG:
2091 dwrq->value = adapter->secinfo.auth_mode;
2094 case IW_AUTH_WPA_ENABLED:
2095 if (adapter->secinfo.WPAenabled && adapter->secinfo.WPA2enabled)
2103 lbs_deb_leave_args(LBS_DEB_WEXT, "ret %d", ret);
2108 static int wlan_set_txpow(struct net_device *dev, struct iw_request_info *info,
2109 struct iw_param *vwrq, char *extra)
2112 wlan_private *priv = dev->priv;
2113 wlan_adapter *adapter = priv->adapter;
2117 lbs_deb_enter(LBS_DEB_WEXT);
2119 if (vwrq->disabled) {
2120 wlan_radio_ioctl(priv, RADIO_OFF);
2124 adapter->preamble = cmd_type_auto_preamble;
2126 wlan_radio_ioctl(priv, RADIO_ON);
2128 if ((vwrq->flags & IW_TXPOW_TYPE) == IW_TXPOW_MWATT) {
2129 dbm = (u16) mw_to_dbm(vwrq->value);
2131 dbm = (u16) vwrq->value;
2133 /* auto tx power control */
2135 if (vwrq->fixed == 0)
2138 lbs_deb_wext("txpower set %d dbm\n", dbm);
2140 ret = libertas_prepare_and_send_command(priv,
2141 cmd_802_11_rf_tx_power,
2142 cmd_act_tx_power_opt_set_low,
2143 cmd_option_waitforrsp, 0, (void *)&dbm);
2145 lbs_deb_leave_args(LBS_DEB_WEXT, "ret %d", ret);
2149 static int wlan_get_essid(struct net_device *dev, struct iw_request_info *info,
2150 struct iw_point *dwrq, char *extra)
2152 wlan_private *priv = dev->priv;
2153 wlan_adapter *adapter = priv->adapter;
2155 lbs_deb_enter(LBS_DEB_WEXT);
2158 * Note : if dwrq->flags != 0, we should get the relevant SSID from
2163 * Get the current SSID
2165 if (adapter->connect_status == libertas_connected) {
2166 memcpy(extra, adapter->curbssparams.ssid,
2167 adapter->curbssparams.ssid_len);
2168 extra[adapter->curbssparams.ssid_len] = '\0';
2170 memset(extra, 0, 32);
2171 extra[adapter->curbssparams.ssid_len] = '\0';
2174 * If none, we may want to get the one that was set
2177 /* To make the driver backward compatible with WPA supplicant v0.2.4 */
2178 if (dwrq->length == 32) /* check with WPA supplicant buffer size */
2179 dwrq->length = min_t(size_t, adapter->curbssparams.ssid_len,
2182 dwrq->length = adapter->curbssparams.ssid_len + 1;
2184 dwrq->flags = 1; /* active */
2186 lbs_deb_leave(LBS_DEB_WEXT);
2190 static int wlan_set_essid(struct net_device *dev, struct iw_request_info *info,
2191 struct iw_point *dwrq, char *extra)
2193 wlan_private *priv = dev->priv;
2194 wlan_adapter *adapter = priv->adapter;
2196 u8 ssid[IW_ESSID_MAX_SIZE];
2198 struct assoc_request * assoc_req;
2199 int in_ssid_len = dwrq->length;
2201 lbs_deb_enter(LBS_DEB_WEXT);
2204 * WE-20 and earlier NULL pad the end of the SSID and increment
2205 * SSID length so it can be used like a string. WE-21 and later don't,
2206 * but some userspace tools aren't able to cope with the change.
2208 if ((in_ssid_len > 0) && (extra[in_ssid_len - 1] == '\0'))
2211 /* Check the size of the string */
2212 if (in_ssid_len > IW_ESSID_MAX_SIZE) {
2217 memset(&ssid, 0, sizeof(ssid));
2219 if (!dwrq->flags || !in_ssid_len) {
2220 /* "any" SSID requested; leave SSID blank */
2222 /* Specific SSID requested */
2223 memcpy(&ssid, extra, in_ssid_len);
2224 ssid_len = in_ssid_len;
2228 lbs_deb_wext("requested any SSID\n");
2230 lbs_deb_wext("requested SSID '%s'\n",
2231 escape_essid(ssid, ssid_len));
2235 mutex_lock(&adapter->lock);
2237 /* Get or create the current association request */
2238 assoc_req = wlan_get_association_request(adapter);
2242 /* Copy the SSID to the association request */
2243 memcpy(&assoc_req->ssid, &ssid, IW_ESSID_MAX_SIZE);
2244 assoc_req->ssid_len = ssid_len;
2245 set_bit(ASSOC_FLAG_SSID, &assoc_req->flags);
2246 wlan_postpone_association_work(priv);
2250 /* Cancel the association request if there was an error */
2252 wlan_cancel_association_work(priv);
2255 mutex_unlock(&adapter->lock);
2257 lbs_deb_leave_args(LBS_DEB_WEXT, "ret %d", ret);
2262 * @brief Connect to the AP or Ad-hoc Network with specific bssid
2264 * @param dev A pointer to net_device structure
2265 * @param info A pointer to iw_request_info structure
2266 * @param awrq A pointer to iw_param structure
2267 * @param extra A pointer to extra data buf
2268 * @return 0 --success, otherwise fail
2270 static int wlan_set_wap(struct net_device *dev, struct iw_request_info *info,
2271 struct sockaddr *awrq, char *extra)
2273 wlan_private *priv = dev->priv;
2274 wlan_adapter *adapter = priv->adapter;
2275 struct assoc_request * assoc_req;
2278 lbs_deb_enter(LBS_DEB_WEXT);
2280 if (awrq->sa_family != ARPHRD_ETHER)
2283 lbs_deb_wext("ASSOC: WAP: sa_data " MAC_FMT "\n", MAC_ARG(awrq->sa_data));
2285 mutex_lock(&adapter->lock);
2287 /* Get or create the current association request */
2288 assoc_req = wlan_get_association_request(adapter);
2290 wlan_cancel_association_work(priv);
2293 /* Copy the BSSID to the association request */
2294 memcpy(&assoc_req->bssid, awrq->sa_data, ETH_ALEN);
2295 set_bit(ASSOC_FLAG_BSSID, &assoc_req->flags);
2296 wlan_postpone_association_work(priv);
2299 mutex_unlock(&adapter->lock);
2304 void libertas_get_fwversion(wlan_adapter * adapter, char *fwversion, int maxlen)
2308 mutex_lock(&adapter->lock);
2310 if (adapter->fwreleasenumber[3] == 0)
2311 sprintf(fwver, "%u.%u.%u",
2312 adapter->fwreleasenumber[2],
2313 adapter->fwreleasenumber[1],
2314 adapter->fwreleasenumber[0]);
2316 sprintf(fwver, "%u.%u.%u.p%u",
2317 adapter->fwreleasenumber[2],
2318 adapter->fwreleasenumber[1],
2319 adapter->fwreleasenumber[0],
2320 adapter->fwreleasenumber[3]);
2322 mutex_unlock(&adapter->lock);
2323 snprintf(fwversion, maxlen, fwver);
2328 * iwconfig settable callbacks
2330 static const iw_handler wlan_handler[] = {
2331 (iw_handler) NULL, /* SIOCSIWCOMMIT */
2332 (iw_handler) wlan_get_name, /* SIOCGIWNAME */
2333 (iw_handler) NULL, /* SIOCSIWNWID */
2334 (iw_handler) NULL, /* SIOCGIWNWID */
2335 (iw_handler) wlan_set_freq, /* SIOCSIWFREQ */
2336 (iw_handler) wlan_get_freq, /* SIOCGIWFREQ */
2337 (iw_handler) wlan_set_mode, /* SIOCSIWMODE */
2338 (iw_handler) wlan_get_mode, /* SIOCGIWMODE */
2339 (iw_handler) NULL, /* SIOCSIWSENS */
2340 (iw_handler) NULL, /* SIOCGIWSENS */
2341 (iw_handler) NULL, /* SIOCSIWRANGE */
2342 (iw_handler) wlan_get_range, /* SIOCGIWRANGE */
2343 (iw_handler) NULL, /* SIOCSIWPRIV */
2344 (iw_handler) NULL, /* SIOCGIWPRIV */
2345 (iw_handler) NULL, /* SIOCSIWSTATS */
2346 (iw_handler) NULL, /* SIOCGIWSTATS */
2347 iw_handler_set_spy, /* SIOCSIWSPY */
2348 iw_handler_get_spy, /* SIOCGIWSPY */
2349 iw_handler_set_thrspy, /* SIOCSIWTHRSPY */
2350 iw_handler_get_thrspy, /* SIOCGIWTHRSPY */
2351 (iw_handler) wlan_set_wap, /* SIOCSIWAP */
2352 (iw_handler) wlan_get_wap, /* SIOCGIWAP */
2353 (iw_handler) NULL, /* SIOCSIWMLME */
2354 (iw_handler) NULL, /* SIOCGIWAPLIST - deprecated */
2355 (iw_handler) libertas_set_scan, /* SIOCSIWSCAN */
2356 (iw_handler) libertas_get_scan, /* SIOCGIWSCAN */
2357 (iw_handler) wlan_set_essid, /* SIOCSIWESSID */
2358 (iw_handler) wlan_get_essid, /* SIOCGIWESSID */
2359 (iw_handler) wlan_set_nick, /* SIOCSIWNICKN */
2360 (iw_handler) wlan_get_nick, /* SIOCGIWNICKN */
2361 (iw_handler) NULL, /* -- hole -- */
2362 (iw_handler) NULL, /* -- hole -- */
2363 (iw_handler) wlan_set_rate, /* SIOCSIWRATE */
2364 (iw_handler) wlan_get_rate, /* SIOCGIWRATE */
2365 (iw_handler) wlan_set_rts, /* SIOCSIWRTS */
2366 (iw_handler) wlan_get_rts, /* SIOCGIWRTS */
2367 (iw_handler) wlan_set_frag, /* SIOCSIWFRAG */
2368 (iw_handler) wlan_get_frag, /* SIOCGIWFRAG */
2369 (iw_handler) wlan_set_txpow, /* SIOCSIWTXPOW */
2370 (iw_handler) wlan_get_txpow, /* SIOCGIWTXPOW */
2371 (iw_handler) wlan_set_retry, /* SIOCSIWRETRY */
2372 (iw_handler) wlan_get_retry, /* SIOCGIWRETRY */
2373 (iw_handler) wlan_set_encode, /* SIOCSIWENCODE */
2374 (iw_handler) wlan_get_encode, /* SIOCGIWENCODE */
2375 (iw_handler) wlan_set_power, /* SIOCSIWPOWER */
2376 (iw_handler) wlan_get_power, /* SIOCGIWPOWER */
2377 (iw_handler) NULL, /* -- hole -- */
2378 (iw_handler) NULL, /* -- hole -- */
2379 (iw_handler) wlan_set_genie, /* SIOCSIWGENIE */
2380 (iw_handler) wlan_get_genie, /* SIOCGIWGENIE */
2381 (iw_handler) wlan_set_auth, /* SIOCSIWAUTH */
2382 (iw_handler) wlan_get_auth, /* SIOCGIWAUTH */
2383 (iw_handler) wlan_set_encodeext,/* SIOCSIWENCODEEXT */
2384 (iw_handler) wlan_get_encodeext,/* SIOCGIWENCODEEXT */
2385 (iw_handler) NULL, /* SIOCSIWPMKSA */
2388 static const iw_handler mesh_wlan_handler[] = {
2389 (iw_handler) NULL, /* SIOCSIWCOMMIT */
2390 (iw_handler) wlan_get_name, /* SIOCGIWNAME */
2391 (iw_handler) NULL, /* SIOCSIWNWID */
2392 (iw_handler) NULL, /* SIOCGIWNWID */
2393 (iw_handler) wlan_set_freq, /* SIOCSIWFREQ */
2394 (iw_handler) wlan_get_freq, /* SIOCGIWFREQ */
2395 (iw_handler) NULL, /* SIOCSIWMODE */
2396 (iw_handler) mesh_wlan_get_mode, /* SIOCGIWMODE */
2397 (iw_handler) NULL, /* SIOCSIWSENS */
2398 (iw_handler) NULL, /* SIOCGIWSENS */
2399 (iw_handler) NULL, /* SIOCSIWRANGE */
2400 (iw_handler) wlan_get_range, /* SIOCGIWRANGE */
2401 (iw_handler) NULL, /* SIOCSIWPRIV */
2402 (iw_handler) NULL, /* SIOCGIWPRIV */
2403 (iw_handler) NULL, /* SIOCSIWSTATS */
2404 (iw_handler) NULL, /* SIOCGIWSTATS */
2405 iw_handler_set_spy, /* SIOCSIWSPY */
2406 iw_handler_get_spy, /* SIOCGIWSPY */
2407 iw_handler_set_thrspy, /* SIOCSIWTHRSPY */
2408 iw_handler_get_thrspy, /* SIOCGIWTHRSPY */
2409 (iw_handler) NULL, /* SIOCSIWAP */
2410 (iw_handler) NULL, /* SIOCGIWAP */
2411 (iw_handler) NULL, /* SIOCSIWMLME */
2412 (iw_handler) NULL, /* SIOCGIWAPLIST - deprecated */
2413 (iw_handler) libertas_set_scan, /* SIOCSIWSCAN */
2414 (iw_handler) libertas_get_scan, /* SIOCGIWSCAN */
2415 (iw_handler) NULL, /* SIOCSIWESSID */
2416 (iw_handler) NULL, /* SIOCGIWESSID */
2417 (iw_handler) NULL, /* SIOCSIWNICKN */
2418 (iw_handler) mesh_get_nick, /* SIOCGIWNICKN */
2419 (iw_handler) NULL, /* -- hole -- */
2420 (iw_handler) NULL, /* -- hole -- */
2421 (iw_handler) wlan_set_rate, /* SIOCSIWRATE */
2422 (iw_handler) wlan_get_rate, /* SIOCGIWRATE */
2423 (iw_handler) wlan_set_rts, /* SIOCSIWRTS */
2424 (iw_handler) wlan_get_rts, /* SIOCGIWRTS */
2425 (iw_handler) wlan_set_frag, /* SIOCSIWFRAG */
2426 (iw_handler) wlan_get_frag, /* SIOCGIWFRAG */
2427 (iw_handler) wlan_set_txpow, /* SIOCSIWTXPOW */
2428 (iw_handler) wlan_get_txpow, /* SIOCGIWTXPOW */
2429 (iw_handler) wlan_set_retry, /* SIOCSIWRETRY */
2430 (iw_handler) wlan_get_retry, /* SIOCGIWRETRY */
2431 (iw_handler) wlan_set_encode, /* SIOCSIWENCODE */
2432 (iw_handler) wlan_get_encode, /* SIOCGIWENCODE */
2433 (iw_handler) wlan_set_power, /* SIOCSIWPOWER */
2434 (iw_handler) wlan_get_power, /* SIOCGIWPOWER */
2435 (iw_handler) NULL, /* -- hole -- */
2436 (iw_handler) NULL, /* -- hole -- */
2437 (iw_handler) wlan_set_genie, /* SIOCSIWGENIE */
2438 (iw_handler) wlan_get_genie, /* SIOCGIWGENIE */
2439 (iw_handler) wlan_set_auth, /* SIOCSIWAUTH */
2440 (iw_handler) wlan_get_auth, /* SIOCGIWAUTH */
2441 (iw_handler) wlan_set_encodeext,/* SIOCSIWENCODEEXT */
2442 (iw_handler) wlan_get_encodeext,/* SIOCGIWENCODEEXT */
2443 (iw_handler) NULL, /* SIOCSIWPMKSA */
2445 struct iw_handler_def libertas_handler_def = {
2446 .num_standard = sizeof(wlan_handler) / sizeof(iw_handler),
2447 .num_private = sizeof(wlan_private_handler) / sizeof(iw_handler),
2448 .num_private_args = sizeof(wlan_private_args) /
2449 sizeof(struct iw_priv_args),
2450 .standard = (iw_handler *) wlan_handler,
2451 .private = (iw_handler *) wlan_private_handler,
2452 .private_args = (struct iw_priv_args *)wlan_private_args,
2453 .get_wireless_stats = wlan_get_wireless_stats,
2456 struct iw_handler_def mesh_handler_def = {
2457 .num_standard = sizeof(mesh_wlan_handler) / sizeof(iw_handler),
2458 .num_private = sizeof(wlan_private_handler) / sizeof(iw_handler),
2459 .num_private_args = sizeof(wlan_private_args) /
2460 sizeof(struct iw_priv_args),
2461 .standard = (iw_handler *) mesh_wlan_handler,
2462 .private = (iw_handler *) wlan_private_handler,
2463 .private_args = (struct iw_priv_args *)wlan_private_args,
2464 .get_wireless_stats = wlan_get_wireless_stats,