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 wlan_set_rts(struct net_device
*dev
, struct iw_request_info
*info
,
376 struct iw_param
*vwrq
, char *extra
)
379 wlan_private
*priv
= dev
->priv
;
380 wlan_adapter
*adapter
= priv
->adapter
;
381 int rthr
= vwrq
->value
;
383 lbs_deb_enter(LBS_DEB_WEXT
);
385 if (vwrq
->disabled
) {
386 adapter
->rtsthsd
= rthr
= MRVDRV_RTS_MAX_VALUE
;
388 if (rthr
< MRVDRV_RTS_MIN_VALUE
|| rthr
> MRVDRV_RTS_MAX_VALUE
)
390 adapter
->rtsthsd
= rthr
;
393 ret
= libertas_prepare_and_send_command(priv
, cmd_802_11_snmp_mib
,
394 cmd_act_set
, cmd_option_waitforrsp
,
395 OID_802_11_RTS_THRESHOLD
, &rthr
);
397 lbs_deb_leave_args(LBS_DEB_WEXT
, "ret %d", ret
);
401 static int wlan_get_rts(struct net_device
*dev
, struct iw_request_info
*info
,
402 struct iw_param
*vwrq
, char *extra
)
405 wlan_private
*priv
= dev
->priv
;
406 wlan_adapter
*adapter
= priv
->adapter
;
408 lbs_deb_enter(LBS_DEB_WEXT
);
410 adapter
->rtsthsd
= 0;
411 ret
= libertas_prepare_and_send_command(priv
, cmd_802_11_snmp_mib
,
412 cmd_act_get
, cmd_option_waitforrsp
,
413 OID_802_11_RTS_THRESHOLD
, NULL
);
417 vwrq
->value
= adapter
->rtsthsd
;
418 vwrq
->disabled
= ((vwrq
->value
< MRVDRV_RTS_MIN_VALUE
)
419 || (vwrq
->value
> MRVDRV_RTS_MAX_VALUE
));
423 lbs_deb_leave_args(LBS_DEB_WEXT
, "ret %d", ret
);
427 static int wlan_set_frag(struct net_device
*dev
, struct iw_request_info
*info
,
428 struct iw_param
*vwrq
, char *extra
)
431 int fthr
= vwrq
->value
;
432 wlan_private
*priv
= dev
->priv
;
433 wlan_adapter
*adapter
= priv
->adapter
;
435 lbs_deb_enter(LBS_DEB_WEXT
);
437 if (vwrq
->disabled
) {
438 adapter
->fragthsd
= fthr
= MRVDRV_FRAG_MAX_VALUE
;
440 if (fthr
< MRVDRV_FRAG_MIN_VALUE
441 || fthr
> MRVDRV_FRAG_MAX_VALUE
)
443 adapter
->fragthsd
= fthr
;
446 ret
= libertas_prepare_and_send_command(priv
, cmd_802_11_snmp_mib
,
447 cmd_act_set
, cmd_option_waitforrsp
,
448 OID_802_11_FRAGMENTATION_THRESHOLD
, &fthr
);
450 lbs_deb_leave_args(LBS_DEB_WEXT
, "ret %d", ret
);
454 static int wlan_get_frag(struct net_device
*dev
, struct iw_request_info
*info
,
455 struct iw_param
*vwrq
, char *extra
)
458 wlan_private
*priv
= dev
->priv
;
459 wlan_adapter
*adapter
= priv
->adapter
;
461 lbs_deb_enter(LBS_DEB_WEXT
);
463 adapter
->fragthsd
= 0;
464 ret
= libertas_prepare_and_send_command(priv
,
466 cmd_act_get
, cmd_option_waitforrsp
,
467 OID_802_11_FRAGMENTATION_THRESHOLD
, NULL
);
471 vwrq
->value
= adapter
->fragthsd
;
472 vwrq
->disabled
= ((vwrq
->value
< MRVDRV_FRAG_MIN_VALUE
)
473 || (vwrq
->value
> MRVDRV_FRAG_MAX_VALUE
));
477 lbs_deb_leave_args(LBS_DEB_WEXT
, "ret %d", ret
);
481 static int wlan_get_mode(struct net_device
*dev
,
482 struct iw_request_info
*info
, u32
* uwrq
, char *extra
)
484 wlan_private
*priv
= dev
->priv
;
485 wlan_adapter
*adapter
= priv
->adapter
;
487 lbs_deb_enter(LBS_DEB_WEXT
);
489 *uwrq
= adapter
->mode
;
491 lbs_deb_leave(LBS_DEB_WEXT
);
495 static int wlan_get_txpow(struct net_device
*dev
,
496 struct iw_request_info
*info
,
497 struct iw_param
*vwrq
, char *extra
)
500 wlan_private
*priv
= dev
->priv
;
501 wlan_adapter
*adapter
= priv
->adapter
;
503 lbs_deb_enter(LBS_DEB_WEXT
);
505 ret
= libertas_prepare_and_send_command(priv
,
506 cmd_802_11_rf_tx_power
,
507 cmd_act_tx_power_opt_get
,
508 cmd_option_waitforrsp
, 0, NULL
);
513 lbs_deb_wext("tx power level %d dbm\n", adapter
->txpowerlevel
);
514 vwrq
->value
= adapter
->txpowerlevel
;
516 if (adapter
->radioon
) {
518 vwrq
->flags
= IW_TXPOW_DBM
;
524 lbs_deb_leave_args(LBS_DEB_WEXT
, "ret %d", ret
);
528 static int wlan_set_retry(struct net_device
*dev
, struct iw_request_info
*info
,
529 struct iw_param
*vwrq
, char *extra
)
532 wlan_private
*priv
= dev
->priv
;
533 wlan_adapter
*adapter
= priv
->adapter
;
535 lbs_deb_enter(LBS_DEB_WEXT
);
537 if (vwrq
->flags
== IW_RETRY_LIMIT
) {
538 /* The MAC has a 4-bit Total_Tx_Count register
539 Total_Tx_Count = 1 + Tx_Retry_Count */
540 #define TX_RETRY_MIN 0
541 #define TX_RETRY_MAX 14
542 if (vwrq
->value
< TX_RETRY_MIN
|| vwrq
->value
> TX_RETRY_MAX
)
545 /* Adding 1 to convert retry count to try count */
546 adapter
->txretrycount
= vwrq
->value
+ 1;
548 ret
= libertas_prepare_and_send_command(priv
, cmd_802_11_snmp_mib
,
550 cmd_option_waitforrsp
,
551 OID_802_11_TX_RETRYCOUNT
, NULL
);
560 lbs_deb_leave_args(LBS_DEB_WEXT
, "ret %d", ret
);
564 static int wlan_get_retry(struct net_device
*dev
, struct iw_request_info
*info
,
565 struct iw_param
*vwrq
, char *extra
)
567 wlan_private
*priv
= dev
->priv
;
568 wlan_adapter
*adapter
= priv
->adapter
;
571 lbs_deb_enter(LBS_DEB_WEXT
);
573 adapter
->txretrycount
= 0;
574 ret
= libertas_prepare_and_send_command(priv
,
576 cmd_act_get
, cmd_option_waitforrsp
,
577 OID_802_11_TX_RETRYCOUNT
, NULL
);
583 vwrq
->flags
= IW_RETRY_LIMIT
;
584 /* Subtract 1 to convert try count to retry count */
585 vwrq
->value
= adapter
->txretrycount
- 1;
589 lbs_deb_leave_args(LBS_DEB_WEXT
, "ret %d", ret
);
593 static inline void sort_channels(struct iw_freq
*freq
, int num
)
598 for (i
= 0; i
< num
; i
++)
599 for (j
= i
+ 1; j
< num
; j
++)
600 if (freq
[i
].i
> freq
[j
].i
) {
604 freq
[i
].i
= freq
[j
].i
;
605 freq
[i
].m
= freq
[j
].m
;
615 Infra G(12) A(8) B(4) G(12)
616 Adhoc A+B(12) A(8) B(4) B(4)
624 * @brief Get Range Info
626 * @param dev A pointer to net_device structure
627 * @param info A pointer to iw_request_info structure
628 * @param vwrq A pointer to iw_param structure
629 * @param extra A pointer to extra data buf
630 * @return 0 --success, otherwise fail
632 static int wlan_get_range(struct net_device
*dev
, struct iw_request_info
*info
,
633 struct iw_point
*dwrq
, char *extra
)
636 wlan_private
*priv
= dev
->priv
;
637 wlan_adapter
*adapter
= priv
->adapter
;
638 struct iw_range
*range
= (struct iw_range
*)extra
;
639 struct chan_freq_power
*cfp
;
640 u8 rates
[WLAN_SUPPORTED_RATES
];
644 lbs_deb_enter(LBS_DEB_WEXT
);
646 dwrq
->length
= sizeof(struct iw_range
);
647 memset(range
, 0, sizeof(struct iw_range
));
652 memset(rates
, 0, sizeof(rates
));
653 range
->num_bitrates
= get_active_data_rates(adapter
, rates
);
655 for (i
= 0; i
< min_t(__u8
, range
->num_bitrates
, IW_MAX_BITRATES
) && rates
[i
];
657 range
->bitrate
[i
] = (rates
[i
] & 0x7f) * 500000;
659 range
->num_bitrates
= i
;
660 lbs_deb_wext("IW_MAX_BITRATES %d, num_bitrates %d\n", IW_MAX_BITRATES
,
661 range
->num_bitrates
);
663 range
->num_frequency
= 0;
664 if (priv
->adapter
->enable11d
&&
665 adapter
->connect_status
== libertas_connected
) {
669 struct parsed_region_chan_11d
*parsed_region_chan
=
670 &adapter
->parsed_region_chan
;
672 if (parsed_region_chan
== NULL
) {
673 lbs_deb_wext("11d: parsed_region_chan is NULL\n");
676 band
= parsed_region_chan
->band
;
677 lbs_deb_wext("band %d, nr_char %d\n", band
,
678 parsed_region_chan
->nr_chan
);
680 for (i
= 0; (range
->num_frequency
< IW_MAX_FREQUENCIES
)
681 && (i
< parsed_region_chan
->nr_chan
); i
++) {
682 chan_no
= parsed_region_chan
->chanpwr
[i
].chan
;
683 lbs_deb_wext("chan_no %d\n", chan_no
);
684 range
->freq
[range
->num_frequency
].i
= (long)chan_no
;
685 range
->freq
[range
->num_frequency
].m
=
686 (long)libertas_chan_2_freq(chan_no
, band
) * 100000;
687 range
->freq
[range
->num_frequency
].e
= 1;
688 range
->num_frequency
++;
693 for (j
= 0; (range
->num_frequency
< IW_MAX_FREQUENCIES
)
694 && (j
< sizeof(adapter
->region_channel
)
695 / sizeof(adapter
->region_channel
[0])); j
++) {
696 cfp
= adapter
->region_channel
[j
].CFP
;
697 for (i
= 0; (range
->num_frequency
< IW_MAX_FREQUENCIES
)
698 && adapter
->region_channel
[j
].valid
700 && (i
< adapter
->region_channel
[j
].nrcfp
); i
++) {
701 range
->freq
[range
->num_frequency
].i
=
703 range
->freq
[range
->num_frequency
].m
=
704 (long)cfp
->freq
* 100000;
705 range
->freq
[range
->num_frequency
].e
= 1;
707 range
->num_frequency
++;
712 lbs_deb_wext("IW_MAX_FREQUENCIES %d, num_frequency %d\n",
713 IW_MAX_FREQUENCIES
, range
->num_frequency
);
715 range
->num_channels
= range
->num_frequency
;
717 sort_channels(&range
->freq
[0], range
->num_frequency
);
720 * Set an indication of the max TCP throughput in bit/s that we can
721 * expect using this interface
724 range
->throughput
= 5000 * 1000;
726 range
->throughput
= 1500 * 1000;
728 range
->min_rts
= MRVDRV_RTS_MIN_VALUE
;
729 range
->max_rts
= MRVDRV_RTS_MAX_VALUE
;
730 range
->min_frag
= MRVDRV_FRAG_MIN_VALUE
;
731 range
->max_frag
= MRVDRV_FRAG_MAX_VALUE
;
733 range
->encoding_size
[0] = 5;
734 range
->encoding_size
[1] = 13;
735 range
->num_encoding_sizes
= 2;
736 range
->max_encoding_tokens
= 4;
738 range
->min_pmp
= 1000000;
739 range
->max_pmp
= 120000000;
740 range
->min_pmt
= 1000;
741 range
->max_pmt
= 1000000;
742 range
->pmp_flags
= IW_POWER_PERIOD
;
743 range
->pmt_flags
= IW_POWER_TIMEOUT
;
744 range
->pm_capa
= IW_POWER_PERIOD
| IW_POWER_TIMEOUT
| IW_POWER_ALL_R
;
747 * Minimum version we recommend
749 range
->we_version_source
= 15;
752 * Version we are compiled with
754 range
->we_version_compiled
= WIRELESS_EXT
;
756 range
->retry_capa
= IW_RETRY_LIMIT
;
757 range
->retry_flags
= IW_RETRY_LIMIT
| IW_RETRY_MAX
;
759 range
->min_retry
= TX_RETRY_MIN
;
760 range
->max_retry
= TX_RETRY_MAX
;
763 * Set the qual, level and noise range values
765 range
->max_qual
.qual
= 100;
766 range
->max_qual
.level
= 0;
767 range
->max_qual
.noise
= 0;
768 range
->max_qual
.updated
= IW_QUAL_ALL_UPDATED
| IW_QUAL_DBM
;
770 range
->avg_qual
.qual
= 70;
771 /* TODO: Find real 'good' to 'bad' threshold value for RSSI */
772 range
->avg_qual
.level
= 0;
773 range
->avg_qual
.noise
= 0;
774 range
->avg_qual
.updated
= IW_QUAL_ALL_UPDATED
| IW_QUAL_DBM
;
776 range
->sensitivity
= 0;
779 * Setup the supported power level ranges
781 memset(range
->txpower
, 0, sizeof(range
->txpower
));
782 range
->txpower
[0] = 5;
783 range
->txpower
[1] = 7;
784 range
->txpower
[2] = 9;
785 range
->txpower
[3] = 11;
786 range
->txpower
[4] = 13;
787 range
->txpower
[5] = 15;
788 range
->txpower
[6] = 17;
789 range
->txpower
[7] = 19;
791 range
->num_txpower
= 8;
792 range
->txpower_capa
= IW_TXPOW_DBM
;
793 range
->txpower_capa
|= IW_TXPOW_RANGE
;
795 range
->event_capa
[0] = (IW_EVENT_CAPA_K_0
|
796 IW_EVENT_CAPA_MASK(SIOCGIWAP
) |
797 IW_EVENT_CAPA_MASK(SIOCGIWSCAN
));
798 range
->event_capa
[1] = IW_EVENT_CAPA_K_1
;
800 if (adapter
->fwcapinfo
& FW_CAPINFO_WPA
) {
801 range
->enc_capa
= IW_ENC_CAPA_WPA
803 | IW_ENC_CAPA_CIPHER_TKIP
804 | IW_ENC_CAPA_CIPHER_CCMP
;
808 lbs_deb_leave(LBS_DEB_WEXT
);
812 static int wlan_set_power(struct net_device
*dev
, struct iw_request_info
*info
,
813 struct iw_param
*vwrq
, char *extra
)
815 wlan_private
*priv
= dev
->priv
;
816 wlan_adapter
*adapter
= priv
->adapter
;
818 lbs_deb_enter(LBS_DEB_WEXT
);
820 /* PS is currently supported only in Infrastructure mode
821 * Remove this check if it is to be supported in IBSS mode also
824 if (vwrq
->disabled
) {
825 adapter
->psmode
= wlan802_11powermodecam
;
826 if (adapter
->psstate
!= PS_STATE_FULL_POWER
) {
827 libertas_ps_wakeup(priv
, cmd_option_waitforrsp
);
833 if ((vwrq
->flags
& IW_POWER_TYPE
) == IW_POWER_TIMEOUT
) {
835 "setting power timeout is not supported\n");
837 } else if ((vwrq
->flags
& IW_POWER_TYPE
) == IW_POWER_PERIOD
) {
838 lbs_deb_wext("setting power period not supported\n");
842 if (adapter
->psmode
!= wlan802_11powermodecam
) {
846 adapter
->psmode
= wlan802_11powermodemax_psp
;
848 if (adapter
->connect_status
== libertas_connected
) {
849 libertas_ps_sleep(priv
, cmd_option_waitforrsp
);
852 lbs_deb_leave(LBS_DEB_WEXT
);
856 static int wlan_get_power(struct net_device
*dev
, struct iw_request_info
*info
,
857 struct iw_param
*vwrq
, char *extra
)
859 wlan_private
*priv
= dev
->priv
;
860 wlan_adapter
*adapter
= priv
->adapter
;
863 lbs_deb_enter(LBS_DEB_WEXT
);
865 mode
= adapter
->psmode
;
867 if ((vwrq
->disabled
= (mode
== wlan802_11powermodecam
))
868 || adapter
->connect_status
== libertas_disconnected
)
876 lbs_deb_leave(LBS_DEB_WEXT
);
881 * iwpriv settable callbacks
884 static const iw_handler wlan_private_handler
[] = {
885 NULL
, /* SIOCIWFIRSTPRIV */
888 static const struct iw_priv_args wlan_private_args
[] = {
890 * { cmd, set_args, get_args, name }
892 /* Using iwpriv sub-command feature */
894 WLAN_SETONEINT_GETNONE
, /* IOCTL: 24 */
895 IW_PRIV_TYPE_INT
| IW_PRIV_SIZE_FIXED
| 1,
900 IW_PRIV_TYPE_INT
| IW_PRIV_SIZE_FIXED
| 1,
904 WLAN_SUBCMD_MESH_SET_TTL
,
905 IW_PRIV_TYPE_INT
| IW_PRIV_SIZE_FIXED
| 1,
909 WLAN_SETNONE_GETONEINT
,
911 IW_PRIV_TYPE_INT
| IW_PRIV_SIZE_FIXED
| 1,
916 IW_PRIV_TYPE_INT
| IW_PRIV_SIZE_FIXED
| 1,
919 WLAN_SUBCMD_FWT_CLEANUP
,
921 IW_PRIV_TYPE_INT
| IW_PRIV_SIZE_FIXED
| 1,
924 WLAN_SUBCMD_FWT_TIME
,
926 IW_PRIV_TYPE_INT
| IW_PRIV_SIZE_FIXED
| 1,
929 WLAN_SUBCMD_MESH_GET_TTL
,
931 IW_PRIV_TYPE_INT
| IW_PRIV_SIZE_FIXED
| 1,
934 WLAN_SETNONE_GETNONE
,
939 WLAN_SUBCMD_FWT_RESET
,
944 WLAN_SUBCMD_BT_RESET
,
949 WLAN_SET128CHAR_GET128CHAR
,
950 IW_PRIV_TYPE_CHAR
| 128,
951 IW_PRIV_TYPE_CHAR
| 128,
956 IW_PRIV_TYPE_CHAR
| 128,
957 IW_PRIV_TYPE_CHAR
| 128,
961 IW_PRIV_TYPE_CHAR
| 128,
962 IW_PRIV_TYPE_CHAR
| 128,
966 IW_PRIV_TYPE_CHAR
| 128,
967 IW_PRIV_TYPE_CHAR
| 128,
970 WLAN_SUBCMD_BT_SET_INVERT
,
971 IW_PRIV_TYPE_INT
| IW_PRIV_SIZE_FIXED
| 1,
975 WLAN_SUBCMD_BT_GET_INVERT
,
977 IW_PRIV_TYPE_INT
| IW_PRIV_SIZE_FIXED
| 1,
982 IW_PRIV_TYPE_CHAR
| 128,
983 IW_PRIV_TYPE_CHAR
| 128,
987 IW_PRIV_TYPE_CHAR
| 128,
988 IW_PRIV_TYPE_CHAR
| 128,
991 WLAN_SUBCMD_FWT_LOOKUP
,
992 IW_PRIV_TYPE_CHAR
| 128,
993 IW_PRIV_TYPE_CHAR
| 128,
996 WLAN_SUBCMD_FWT_LIST_NEIGHBOR
,
997 IW_PRIV_TYPE_CHAR
| 128,
998 IW_PRIV_TYPE_CHAR
| 128,
1001 WLAN_SUBCMD_FWT_LIST
,
1002 IW_PRIV_TYPE_CHAR
| 128,
1003 IW_PRIV_TYPE_CHAR
| 128,
1006 WLAN_SUBCMD_FWT_LIST_ROUTE
,
1007 IW_PRIV_TYPE_CHAR
| 128,
1008 IW_PRIV_TYPE_CHAR
| 128,
1011 WLAN_SET_GET_SIXTEEN_INT
,
1012 IW_PRIV_TYPE_INT
| 16,
1013 IW_PRIV_TYPE_INT
| 16,
1017 IW_PRIV_TYPE_INT
| 16,
1018 IW_PRIV_TYPE_INT
| 16,
1022 static struct iw_statistics
*wlan_get_wireless_stats(struct net_device
*dev
)
1032 wlan_private
*priv
= dev
->priv
;
1033 wlan_adapter
*adapter
= priv
->adapter
;
1037 int stats_valid
= 0;
1041 lbs_deb_enter(LBS_DEB_WEXT
);
1043 priv
->wstats
.status
= adapter
->mode
;
1045 /* If we're not associated, all quality values are meaningless */
1046 if (adapter
->connect_status
!= libertas_connected
)
1049 /* Quality by RSSI */
1050 priv
->wstats
.qual
.level
=
1051 CAL_RSSI(adapter
->SNR
[TYPE_BEACON
][TYPE_NOAVG
],
1052 adapter
->NF
[TYPE_BEACON
][TYPE_NOAVG
]);
1054 if (adapter
->NF
[TYPE_BEACON
][TYPE_NOAVG
] == 0) {
1055 priv
->wstats
.qual
.noise
= MRVDRV_NF_DEFAULT_SCAN_VALUE
;
1057 priv
->wstats
.qual
.noise
=
1058 CAL_NF(adapter
->NF
[TYPE_BEACON
][TYPE_NOAVG
]);
1061 lbs_deb_wext("signal level %#x\n", priv
->wstats
.qual
.level
);
1062 lbs_deb_wext("noise %#x\n", priv
->wstats
.qual
.noise
);
1064 rssi
= priv
->wstats
.qual
.level
- priv
->wstats
.qual
.noise
;
1066 rssi_qual
= rssi
* POOR
/ 10;
1068 rssi_qual
= (rssi
- 15) * (FAIR
- POOR
) / 5 + POOR
;
1070 rssi_qual
= (rssi
- 20) * (GOOD
- FAIR
) / 5 + FAIR
;
1072 rssi_qual
= (rssi
- 30) * (VERY_GOOD
- GOOD
) /
1075 rssi_qual
= (rssi
- 40) * (PERFECT
- VERY_GOOD
) /
1077 quality
= rssi_qual
;
1079 /* Quality by TX errors */
1080 priv
->wstats
.discard
.retries
= priv
->stats
.tx_errors
;
1082 tx_retries
= adapter
->logmsg
.retry
;
1084 if (tx_retries
> 75)
1085 tx_qual
= (90 - tx_retries
) * POOR
/ 15;
1086 else if (tx_retries
> 70)
1087 tx_qual
= (75 - tx_retries
) * (FAIR
- POOR
) / 5 + POOR
;
1088 else if (tx_retries
> 65)
1089 tx_qual
= (70 - tx_retries
) * (GOOD
- FAIR
) / 5 + FAIR
;
1090 else if (tx_retries
> 50)
1091 tx_qual
= (65 - tx_retries
) * (VERY_GOOD
- GOOD
) /
1094 tx_qual
= (50 - tx_retries
) *
1095 (PERFECT
- VERY_GOOD
) / 50 + VERY_GOOD
;
1096 quality
= min(quality
, tx_qual
);
1098 priv
->wstats
.discard
.code
= adapter
->logmsg
.wepundecryptable
;
1099 priv
->wstats
.discard
.fragment
= adapter
->logmsg
.rxfrag
;
1100 priv
->wstats
.discard
.retries
= tx_retries
;
1101 priv
->wstats
.discard
.misc
= adapter
->logmsg
.ackfailure
;
1103 /* Calculate quality */
1104 priv
->wstats
.qual
.qual
= max(quality
, (u32
)100);
1105 priv
->wstats
.qual
.updated
= IW_QUAL_ALL_UPDATED
| IW_QUAL_DBM
;
1108 /* update stats asynchronously for future calls */
1109 libertas_prepare_and_send_command(priv
, cmd_802_11_rssi
, 0,
1111 libertas_prepare_and_send_command(priv
, cmd_802_11_get_log
, 0,
1115 priv
->wstats
.miss
.beacon
= 0;
1116 priv
->wstats
.discard
.retries
= 0;
1117 priv
->wstats
.qual
.qual
= 0;
1118 priv
->wstats
.qual
.level
= 0;
1119 priv
->wstats
.qual
.noise
= 0;
1120 priv
->wstats
.qual
.updated
= IW_QUAL_ALL_UPDATED
;
1121 priv
->wstats
.qual
.updated
|= IW_QUAL_NOISE_INVALID
|
1122 IW_QUAL_QUAL_INVALID
| IW_QUAL_LEVEL_INVALID
;
1125 lbs_deb_leave(LBS_DEB_WEXT
);
1126 return &priv
->wstats
;
1131 static int wlan_set_freq(struct net_device
*dev
, struct iw_request_info
*info
,
1132 struct iw_freq
*fwrq
, char *extra
)
1135 wlan_private
*priv
= dev
->priv
;
1136 wlan_adapter
*adapter
= priv
->adapter
;
1137 struct chan_freq_power
*cfp
;
1138 struct assoc_request
* assoc_req
;
1140 lbs_deb_enter(LBS_DEB_WEXT
);
1142 mutex_lock(&adapter
->lock
);
1143 assoc_req
= wlan_get_association_request(adapter
);
1149 /* If setting by frequency, convert to a channel */
1151 long f
= fwrq
->m
/ 100000;
1153 cfp
= find_cfp_by_band_and_freq(adapter
, 0, f
);
1155 lbs_deb_wext("invalid freq %ld\n", f
);
1160 fwrq
->m
= (int) cfp
->channel
;
1163 /* Setting by channel number */
1164 if (fwrq
->m
> 1000 || fwrq
->e
> 0) {
1168 cfp
= libertas_find_cfp_by_band_and_channel(adapter
, 0, fwrq
->m
);
1173 assoc_req
->channel
= fwrq
->m
;
1178 set_bit(ASSOC_FLAG_CHANNEL
, &assoc_req
->flags
);
1179 wlan_postpone_association_work(priv
);
1181 wlan_cancel_association_work(priv
);
1183 mutex_unlock(&adapter
->lock
);
1185 lbs_deb_leave_args(LBS_DEB_WEXT
, "ret %d", ret
);
1190 * @brief use index to get the data rate
1192 * @param index The index of data rate
1193 * @return data rate or 0
1195 u32
libertas_index_to_data_rate(u8 index
)
1197 if (index
>= sizeof(libertas_wlan_data_rates
))
1200 return libertas_wlan_data_rates
[index
];
1204 * @brief use rate to get the index
1206 * @param rate data rate
1207 * @return index or 0
1209 u8
libertas_data_rate_to_index(u32 rate
)
1214 if ((ptr
= memchr(libertas_wlan_data_rates
, (u8
) rate
,
1215 sizeof(libertas_wlan_data_rates
))))
1216 return (ptr
- libertas_wlan_data_rates
);
1221 static int wlan_set_rate(struct net_device
*dev
, struct iw_request_info
*info
,
1222 struct iw_param
*vwrq
, char *extra
)
1224 wlan_private
*priv
= dev
->priv
;
1225 wlan_adapter
*adapter
= priv
->adapter
;
1229 u8 rates
[WLAN_SUPPORTED_RATES
];
1232 lbs_deb_enter(LBS_DEB_WEXT
);
1234 lbs_deb_wext("vwrq->value %d\n", vwrq
->value
);
1236 if (vwrq
->value
== -1) {
1237 action
= cmd_act_set_tx_auto
; // Auto
1238 adapter
->is_datarate_auto
= 1;
1239 adapter
->datarate
= 0;
1241 if (vwrq
->value
% 100000) {
1245 data_rate
= vwrq
->value
/ 500000;
1247 memset(rates
, 0, sizeof(rates
));
1248 get_active_data_rates(adapter
, rates
);
1251 lbs_deb_wext("rate=0x%X, wanted data_rate 0x%X\n", *rate
,
1253 if ((*rate
& 0x7f) == (data_rate
& 0x7f))
1258 lbs_pr_alert("fixed data rate 0x%X out "
1259 "of range\n", data_rate
);
1263 adapter
->datarate
= data_rate
;
1264 action
= cmd_act_set_tx_fix_rate
;
1265 adapter
->is_datarate_auto
= 0;
1268 ret
= libertas_prepare_and_send_command(priv
, cmd_802_11_data_rate
,
1269 action
, cmd_option_waitforrsp
, 0, NULL
);
1271 lbs_deb_leave_args(LBS_DEB_WEXT
, "ret %d", ret
);
1275 static int wlan_get_rate(struct net_device
*dev
, struct iw_request_info
*info
,
1276 struct iw_param
*vwrq
, char *extra
)
1278 wlan_private
*priv
= dev
->priv
;
1279 wlan_adapter
*adapter
= priv
->adapter
;
1281 lbs_deb_enter(LBS_DEB_WEXT
);
1283 if (adapter
->is_datarate_auto
) {
1289 vwrq
->value
= adapter
->datarate
* 500000;
1291 lbs_deb_leave(LBS_DEB_WEXT
);
1295 static int wlan_set_mode(struct net_device
*dev
,
1296 struct iw_request_info
*info
, u32
* uwrq
, char *extra
)
1299 wlan_private
*priv
= dev
->priv
;
1300 wlan_adapter
*adapter
= priv
->adapter
;
1301 struct assoc_request
* assoc_req
;
1303 lbs_deb_enter(LBS_DEB_WEXT
);
1305 if ( (*uwrq
!= IW_MODE_ADHOC
)
1306 && (*uwrq
!= IW_MODE_INFRA
)
1307 && (*uwrq
!= IW_MODE_AUTO
)) {
1308 lbs_deb_wext("Invalid mode: 0x%x\n", *uwrq
);
1313 mutex_lock(&adapter
->lock
);
1314 assoc_req
= wlan_get_association_request(adapter
);
1317 wlan_cancel_association_work(priv
);
1319 assoc_req
->mode
= *uwrq
;
1320 set_bit(ASSOC_FLAG_MODE
, &assoc_req
->flags
);
1321 wlan_postpone_association_work(priv
);
1322 lbs_deb_wext("Switching to mode: 0x%x\n", *uwrq
);
1324 mutex_unlock(&adapter
->lock
);
1327 lbs_deb_leave_args(LBS_DEB_WEXT
, "ret %d", ret
);
1333 * @brief Get Encryption key
1335 * @param dev A pointer to net_device structure
1336 * @param info A pointer to iw_request_info structure
1337 * @param vwrq A pointer to iw_param structure
1338 * @param extra A pointer to extra data buf
1339 * @return 0 --success, otherwise fail
1341 static int wlan_get_encode(struct net_device
*dev
,
1342 struct iw_request_info
*info
,
1343 struct iw_point
*dwrq
, u8
* extra
)
1345 wlan_private
*priv
= dev
->priv
;
1346 wlan_adapter
*adapter
= priv
->adapter
;
1347 int index
= (dwrq
->flags
& IW_ENCODE_INDEX
) - 1;
1349 lbs_deb_enter(LBS_DEB_WEXT
);
1351 lbs_deb_wext("flags 0x%x, index %d, length %d, wep_tx_keyidx %d\n",
1352 dwrq
->flags
, index
, dwrq
->length
, adapter
->wep_tx_keyidx
);
1356 /* Authentication method */
1357 switch (adapter
->secinfo
.auth_mode
) {
1358 case IW_AUTH_ALG_OPEN_SYSTEM
:
1359 dwrq
->flags
= IW_ENCODE_OPEN
;
1362 case IW_AUTH_ALG_SHARED_KEY
:
1363 case IW_AUTH_ALG_LEAP
:
1364 dwrq
->flags
= IW_ENCODE_RESTRICTED
;
1367 dwrq
->flags
= IW_ENCODE_DISABLED
| IW_ENCODE_OPEN
;
1371 if ( adapter
->secinfo
.wep_enabled
1372 || adapter
->secinfo
.WPAenabled
1373 || adapter
->secinfo
.WPA2enabled
) {
1374 dwrq
->flags
&= ~IW_ENCODE_DISABLED
;
1376 dwrq
->flags
|= IW_ENCODE_DISABLED
;
1379 memset(extra
, 0, 16);
1381 mutex_lock(&adapter
->lock
);
1383 /* Default to returning current transmit key */
1385 index
= adapter
->wep_tx_keyidx
;
1387 if ((adapter
->wep_keys
[index
].len
) && adapter
->secinfo
.wep_enabled
) {
1388 memcpy(extra
, adapter
->wep_keys
[index
].key
,
1389 adapter
->wep_keys
[index
].len
);
1390 dwrq
->length
= adapter
->wep_keys
[index
].len
;
1392 dwrq
->flags
|= (index
+ 1);
1393 /* Return WEP enabled */
1394 dwrq
->flags
&= ~IW_ENCODE_DISABLED
;
1395 } else if ((adapter
->secinfo
.WPAenabled
)
1396 || (adapter
->secinfo
.WPA2enabled
)) {
1397 /* return WPA enabled */
1398 dwrq
->flags
&= ~IW_ENCODE_DISABLED
;
1400 dwrq
->flags
|= IW_ENCODE_DISABLED
;
1403 mutex_unlock(&adapter
->lock
);
1405 dwrq
->flags
|= IW_ENCODE_NOKEY
;
1407 lbs_deb_wext("key: " MAC_FMT
", keylen %d\n",
1408 extra
[0], extra
[1], extra
[2],
1409 extra
[3], extra
[4], extra
[5], dwrq
->length
);
1411 lbs_deb_wext("return flags 0x%x\n", dwrq
->flags
);
1413 lbs_deb_leave(LBS_DEB_WEXT
);
1418 * @brief Set Encryption key (internal)
1420 * @param priv A pointer to private card structure
1421 * @param key_material A pointer to key material
1422 * @param key_length length of key material
1423 * @param index key index to set
1424 * @param set_tx_key Force set TX key (1 = yes, 0 = no)
1425 * @return 0 --success, otherwise fail
1427 static int wlan_set_wep_key(struct assoc_request
*assoc_req
,
1428 const char *key_material
,
1434 struct WLAN_802_11_KEY
*pkey
;
1436 lbs_deb_enter(LBS_DEB_WEXT
);
1438 /* Paranoid validation of key index */
1444 /* validate max key length */
1445 if (key_length
> KEY_LEN_WEP_104
) {
1450 pkey
= &assoc_req
->wep_keys
[index
];
1452 if (key_length
> 0) {
1453 memset(pkey
, 0, sizeof(struct WLAN_802_11_KEY
));
1454 pkey
->type
= KEY_TYPE_ID_WEP
;
1456 /* Standardize the key length */
1457 pkey
->len
= (key_length
> KEY_LEN_WEP_40
) ?
1458 KEY_LEN_WEP_104
: KEY_LEN_WEP_40
;
1459 memcpy(pkey
->key
, key_material
, key_length
);
1463 /* Ensure the chosen key is valid */
1465 lbs_deb_wext("key not set, so cannot enable it\n");
1469 assoc_req
->wep_tx_keyidx
= index
;
1472 assoc_req
->secinfo
.wep_enabled
= 1;
1475 lbs_deb_leave_args(LBS_DEB_WEXT
, "ret %d", ret
);
1479 static int validate_key_index(u16 def_index
, u16 raw_index
,
1480 u16
*out_index
, u16
*is_default
)
1482 if (!out_index
|| !is_default
)
1485 /* Verify index if present, otherwise use default TX key index */
1486 if (raw_index
> 0) {
1489 *out_index
= raw_index
- 1;
1491 *out_index
= def_index
;
1497 static void disable_wep(struct assoc_request
*assoc_req
)
1501 /* Set Open System auth mode */
1502 assoc_req
->secinfo
.auth_mode
= IW_AUTH_ALG_OPEN_SYSTEM
;
1504 /* Clear WEP keys and mark WEP as disabled */
1505 assoc_req
->secinfo
.wep_enabled
= 0;
1506 for (i
= 0; i
< 4; i
++)
1507 assoc_req
->wep_keys
[i
].len
= 0;
1509 set_bit(ASSOC_FLAG_SECINFO
, &assoc_req
->flags
);
1510 set_bit(ASSOC_FLAG_WEP_KEYS
, &assoc_req
->flags
);
1514 * @brief Set Encryption key
1516 * @param dev A pointer to net_device structure
1517 * @param info A pointer to iw_request_info structure
1518 * @param vwrq A pointer to iw_param structure
1519 * @param extra A pointer to extra data buf
1520 * @return 0 --success, otherwise fail
1522 static int wlan_set_encode(struct net_device
*dev
,
1523 struct iw_request_info
*info
,
1524 struct iw_point
*dwrq
, char *extra
)
1527 wlan_private
*priv
= dev
->priv
;
1528 wlan_adapter
*adapter
= priv
->adapter
;
1529 struct assoc_request
* assoc_req
;
1530 u16 is_default
= 0, index
= 0, set_tx_key
= 0;
1532 lbs_deb_enter(LBS_DEB_WEXT
);
1534 mutex_lock(&adapter
->lock
);
1535 assoc_req
= wlan_get_association_request(adapter
);
1541 if (dwrq
->flags
& IW_ENCODE_DISABLED
) {
1542 disable_wep (assoc_req
);
1546 ret
= validate_key_index(assoc_req
->wep_tx_keyidx
,
1547 (dwrq
->flags
& IW_ENCODE_INDEX
),
1548 &index
, &is_default
);
1554 /* If WEP isn't enabled, or if there is no key data but a valid
1555 * index, set the TX key.
1557 if (!assoc_req
->secinfo
.wep_enabled
|| (dwrq
->length
== 0 && !is_default
))
1560 ret
= wlan_set_wep_key(assoc_req
, extra
, dwrq
->length
, index
, set_tx_key
);
1565 set_bit(ASSOC_FLAG_WEP_KEYS
, &assoc_req
->flags
);
1567 set_bit(ASSOC_FLAG_WEP_TX_KEYIDX
, &assoc_req
->flags
);
1569 if (dwrq
->flags
& IW_ENCODE_RESTRICTED
) {
1570 assoc_req
->secinfo
.auth_mode
= IW_AUTH_ALG_SHARED_KEY
;
1571 } else if (dwrq
->flags
& IW_ENCODE_OPEN
) {
1572 assoc_req
->secinfo
.auth_mode
= IW_AUTH_ALG_OPEN_SYSTEM
;
1577 set_bit(ASSOC_FLAG_SECINFO
, &assoc_req
->flags
);
1578 wlan_postpone_association_work(priv
);
1580 wlan_cancel_association_work(priv
);
1582 mutex_unlock(&adapter
->lock
);
1584 lbs_deb_leave_args(LBS_DEB_WEXT
, "ret %d", ret
);
1589 * @brief Get Extended Encryption key (WPA/802.1x and WEP)
1591 * @param dev A pointer to net_device structure
1592 * @param info A pointer to iw_request_info structure
1593 * @param vwrq A pointer to iw_param structure
1594 * @param extra A pointer to extra data buf
1595 * @return 0 on success, otherwise failure
1597 static int wlan_get_encodeext(struct net_device
*dev
,
1598 struct iw_request_info
*info
,
1599 struct iw_point
*dwrq
,
1603 wlan_private
*priv
= dev
->priv
;
1604 wlan_adapter
*adapter
= priv
->adapter
;
1605 struct iw_encode_ext
*ext
= (struct iw_encode_ext
*)extra
;
1606 int index
, max_key_len
;
1608 lbs_deb_enter(LBS_DEB_WEXT
);
1610 max_key_len
= dwrq
->length
- sizeof(*ext
);
1611 if (max_key_len
< 0)
1614 index
= dwrq
->flags
& IW_ENCODE_INDEX
;
1616 if (index
< 1 || index
> 4)
1620 index
= adapter
->wep_tx_keyidx
;
1623 if (!ext
->ext_flags
& IW_ENCODE_EXT_GROUP_KEY
&&
1624 ext
->alg
!= IW_ENCODE_ALG_WEP
) {
1625 if (index
!= 0 || adapter
->mode
!= IW_MODE_INFRA
)
1629 dwrq
->flags
= index
+ 1;
1630 memset(ext
, 0, sizeof(*ext
));
1632 if ( !adapter
->secinfo
.wep_enabled
1633 && !adapter
->secinfo
.WPAenabled
1634 && !adapter
->secinfo
.WPA2enabled
) {
1635 ext
->alg
= IW_ENCODE_ALG_NONE
;
1637 dwrq
->flags
|= IW_ENCODE_DISABLED
;
1641 if ( adapter
->secinfo
.wep_enabled
1642 && !adapter
->secinfo
.WPAenabled
1643 && !adapter
->secinfo
.WPA2enabled
) {
1644 ext
->alg
= IW_ENCODE_ALG_WEP
;
1645 ext
->key_len
= adapter
->wep_keys
[index
].len
;
1646 key
= &adapter
->wep_keys
[index
].key
[0];
1647 } else if ( !adapter
->secinfo
.wep_enabled
1648 && (adapter
->secinfo
.WPAenabled
||
1649 adapter
->secinfo
.WPA2enabled
)) {
1651 ext
->alg
= IW_ENCODE_ALG_TKIP
;
1657 if (ext
->key_len
> max_key_len
) {
1663 memcpy(ext
->key
, key
, ext
->key_len
);
1665 dwrq
->flags
|= IW_ENCODE_NOKEY
;
1666 dwrq
->flags
|= IW_ENCODE_ENABLED
;
1671 lbs_deb_leave_args(LBS_DEB_WEXT
, "ret %d", ret
);
1676 * @brief Set Encryption key Extended (WPA/802.1x and WEP)
1678 * @param dev A pointer to net_device structure
1679 * @param info A pointer to iw_request_info structure
1680 * @param vwrq A pointer to iw_param structure
1681 * @param extra A pointer to extra data buf
1682 * @return 0 --success, otherwise fail
1684 static int wlan_set_encodeext(struct net_device
*dev
,
1685 struct iw_request_info
*info
,
1686 struct iw_point
*dwrq
,
1690 wlan_private
*priv
= dev
->priv
;
1691 wlan_adapter
*adapter
= priv
->adapter
;
1692 struct iw_encode_ext
*ext
= (struct iw_encode_ext
*)extra
;
1694 struct assoc_request
* assoc_req
;
1696 lbs_deb_enter(LBS_DEB_WEXT
);
1698 mutex_lock(&adapter
->lock
);
1699 assoc_req
= wlan_get_association_request(adapter
);
1705 if ((alg
== IW_ENCODE_ALG_NONE
) || (dwrq
->flags
& IW_ENCODE_DISABLED
)) {
1706 disable_wep (assoc_req
);
1707 } else if (alg
== IW_ENCODE_ALG_WEP
) {
1708 u16 is_default
= 0, index
, set_tx_key
= 0;
1710 ret
= validate_key_index(assoc_req
->wep_tx_keyidx
,
1711 (dwrq
->flags
& IW_ENCODE_INDEX
),
1712 &index
, &is_default
);
1716 /* If WEP isn't enabled, or if there is no key data but a valid
1717 * index, or if the set-TX-key flag was passed, set the TX key.
1719 if ( !assoc_req
->secinfo
.wep_enabled
1720 || (dwrq
->length
== 0 && !is_default
)
1721 || (ext
->ext_flags
& IW_ENCODE_EXT_SET_TX_KEY
))
1724 /* Copy key to driver */
1725 ret
= wlan_set_wep_key (assoc_req
, ext
->key
, ext
->key_len
, index
,
1730 if (dwrq
->flags
& IW_ENCODE_RESTRICTED
) {
1731 assoc_req
->secinfo
.auth_mode
= IW_AUTH_ALG_SHARED_KEY
;
1732 } else if (dwrq
->flags
& IW_ENCODE_OPEN
) {
1733 assoc_req
->secinfo
.auth_mode
= IW_AUTH_ALG_OPEN_SYSTEM
;
1736 /* Mark the various WEP bits as modified */
1737 set_bit(ASSOC_FLAG_SECINFO
, &assoc_req
->flags
);
1739 set_bit(ASSOC_FLAG_WEP_KEYS
, &assoc_req
->flags
);
1741 set_bit(ASSOC_FLAG_WEP_TX_KEYIDX
, &assoc_req
->flags
);
1743 } else if ((alg
== IW_ENCODE_ALG_TKIP
) || (alg
== IW_ENCODE_ALG_CCMP
)) {
1744 struct WLAN_802_11_KEY
* pkey
;
1746 /* validate key length */
1747 if (((alg
== IW_ENCODE_ALG_TKIP
)
1748 && (ext
->key_len
!= KEY_LEN_WPA_TKIP
))
1749 || ((alg
== IW_ENCODE_ALG_CCMP
)
1750 && (ext
->key_len
!= KEY_LEN_WPA_AES
))) {
1751 lbs_deb_wext("invalid size %d for key of alg"
1759 if (ext
->ext_flags
& IW_ENCODE_EXT_GROUP_KEY
)
1760 pkey
= &assoc_req
->wpa_mcast_key
;
1762 pkey
= &assoc_req
->wpa_unicast_key
;
1764 memset(pkey
, 0, sizeof (struct WLAN_802_11_KEY
));
1765 memcpy(pkey
->key
, ext
->key
, ext
->key_len
);
1766 pkey
->len
= ext
->key_len
;
1767 pkey
->flags
= KEY_INFO_WPA_ENABLED
;
1769 if (ext
->ext_flags
& IW_ENCODE_EXT_GROUP_KEY
) {
1770 pkey
->flags
|= KEY_INFO_WPA_MCAST
;
1771 set_bit(ASSOC_FLAG_WPA_MCAST_KEY
, &assoc_req
->flags
);
1773 pkey
->flags
|= KEY_INFO_WPA_UNICAST
;
1774 set_bit(ASSOC_FLAG_WPA_UCAST_KEY
, &assoc_req
->flags
);
1777 if (alg
== IW_ENCODE_ALG_TKIP
)
1778 pkey
->type
= KEY_TYPE_ID_TKIP
;
1779 else if (alg
== IW_ENCODE_ALG_CCMP
)
1780 pkey
->type
= KEY_TYPE_ID_AES
;
1782 /* If WPA isn't enabled yet, do that now */
1783 if ( assoc_req
->secinfo
.WPAenabled
== 0
1784 && assoc_req
->secinfo
.WPA2enabled
== 0) {
1785 assoc_req
->secinfo
.WPAenabled
= 1;
1786 assoc_req
->secinfo
.WPA2enabled
= 1;
1787 set_bit(ASSOC_FLAG_SECINFO
, &assoc_req
->flags
);
1790 disable_wep (assoc_req
);
1795 wlan_postpone_association_work(priv
);
1797 wlan_cancel_association_work(priv
);
1799 mutex_unlock(&adapter
->lock
);
1801 lbs_deb_leave_args(LBS_DEB_WEXT
, "ret %d", ret
);
1806 static int wlan_set_genie(struct net_device
*dev
,
1807 struct iw_request_info
*info
,
1808 struct iw_point
*dwrq
,
1811 wlan_private
*priv
= dev
->priv
;
1812 wlan_adapter
*adapter
= priv
->adapter
;
1814 struct assoc_request
* assoc_req
;
1816 lbs_deb_enter(LBS_DEB_WEXT
);
1818 mutex_lock(&adapter
->lock
);
1819 assoc_req
= wlan_get_association_request(adapter
);
1825 if (dwrq
->length
> MAX_WPA_IE_LEN
||
1826 (dwrq
->length
&& extra
== NULL
)) {
1832 memcpy(&assoc_req
->wpa_ie
[0], extra
, dwrq
->length
);
1833 assoc_req
->wpa_ie_len
= dwrq
->length
;
1835 memset(&assoc_req
->wpa_ie
[0], 0, sizeof(adapter
->wpa_ie
));
1836 assoc_req
->wpa_ie_len
= 0;
1841 set_bit(ASSOC_FLAG_WPA_IE
, &assoc_req
->flags
);
1842 wlan_postpone_association_work(priv
);
1844 wlan_cancel_association_work(priv
);
1846 mutex_unlock(&adapter
->lock
);
1848 lbs_deb_leave_args(LBS_DEB_WEXT
, "ret %d", ret
);
1852 static int wlan_get_genie(struct net_device
*dev
,
1853 struct iw_request_info
*info
,
1854 struct iw_point
*dwrq
,
1858 wlan_private
*priv
= dev
->priv
;
1859 wlan_adapter
*adapter
= priv
->adapter
;
1861 lbs_deb_enter(LBS_DEB_WEXT
);
1863 if (adapter
->wpa_ie_len
== 0) {
1868 if (dwrq
->length
< adapter
->wpa_ie_len
) {
1873 dwrq
->length
= adapter
->wpa_ie_len
;
1874 memcpy(extra
, &adapter
->wpa_ie
[0], adapter
->wpa_ie_len
);
1877 lbs_deb_leave_args(LBS_DEB_WEXT
, "ret %d", ret
);
1882 static int wlan_set_auth(struct net_device
*dev
,
1883 struct iw_request_info
*info
,
1884 struct iw_param
*dwrq
,
1887 wlan_private
*priv
= dev
->priv
;
1888 wlan_adapter
*adapter
= priv
->adapter
;
1889 struct assoc_request
* assoc_req
;
1893 lbs_deb_enter(LBS_DEB_WEXT
);
1895 mutex_lock(&adapter
->lock
);
1896 assoc_req
= wlan_get_association_request(adapter
);
1902 switch (dwrq
->flags
& IW_AUTH_INDEX
) {
1903 case IW_AUTH_TKIP_COUNTERMEASURES
:
1904 case IW_AUTH_CIPHER_PAIRWISE
:
1905 case IW_AUTH_CIPHER_GROUP
:
1906 case IW_AUTH_KEY_MGMT
:
1908 * libertas does not use these parameters
1912 case IW_AUTH_WPA_VERSION
:
1913 if (dwrq
->value
& IW_AUTH_WPA_VERSION_DISABLED
) {
1914 assoc_req
->secinfo
.WPAenabled
= 0;
1915 assoc_req
->secinfo
.WPA2enabled
= 0;
1917 if (dwrq
->value
& IW_AUTH_WPA_VERSION_WPA
) {
1918 assoc_req
->secinfo
.WPAenabled
= 1;
1919 assoc_req
->secinfo
.wep_enabled
= 0;
1920 assoc_req
->secinfo
.auth_mode
= IW_AUTH_ALG_OPEN_SYSTEM
;
1922 if (dwrq
->value
& IW_AUTH_WPA_VERSION_WPA2
) {
1923 assoc_req
->secinfo
.WPA2enabled
= 1;
1924 assoc_req
->secinfo
.wep_enabled
= 0;
1925 assoc_req
->secinfo
.auth_mode
= IW_AUTH_ALG_OPEN_SYSTEM
;
1930 case IW_AUTH_DROP_UNENCRYPTED
:
1932 adapter
->currentpacketfilter
|=
1933 cmd_act_mac_strict_protection_enable
;
1935 adapter
->currentpacketfilter
&=
1936 ~cmd_act_mac_strict_protection_enable
;
1941 case IW_AUTH_80211_AUTH_ALG
:
1942 if (dwrq
->value
& IW_AUTH_ALG_SHARED_KEY
) {
1943 assoc_req
->secinfo
.auth_mode
= IW_AUTH_ALG_SHARED_KEY
;
1944 } else if (dwrq
->value
& IW_AUTH_ALG_OPEN_SYSTEM
) {
1945 assoc_req
->secinfo
.auth_mode
= IW_AUTH_ALG_OPEN_SYSTEM
;
1946 } else if (dwrq
->value
& IW_AUTH_ALG_LEAP
) {
1947 assoc_req
->secinfo
.auth_mode
= IW_AUTH_ALG_LEAP
;
1954 case IW_AUTH_WPA_ENABLED
:
1956 if (!assoc_req
->secinfo
.WPAenabled
&&
1957 !assoc_req
->secinfo
.WPA2enabled
) {
1958 assoc_req
->secinfo
.WPAenabled
= 1;
1959 assoc_req
->secinfo
.WPA2enabled
= 1;
1960 assoc_req
->secinfo
.wep_enabled
= 0;
1961 assoc_req
->secinfo
.auth_mode
= IW_AUTH_ALG_OPEN_SYSTEM
;
1964 assoc_req
->secinfo
.WPAenabled
= 0;
1965 assoc_req
->secinfo
.WPA2enabled
= 0;
1978 set_bit(ASSOC_FLAG_SECINFO
, &assoc_req
->flags
);
1979 wlan_postpone_association_work(priv
);
1980 } else if (ret
!= -EOPNOTSUPP
) {
1981 wlan_cancel_association_work(priv
);
1983 mutex_unlock(&adapter
->lock
);
1985 lbs_deb_leave_args(LBS_DEB_WEXT
, "ret %d", ret
);
1989 static int wlan_get_auth(struct net_device
*dev
,
1990 struct iw_request_info
*info
,
1991 struct iw_param
*dwrq
,
1995 wlan_private
*priv
= dev
->priv
;
1996 wlan_adapter
*adapter
= priv
->adapter
;
1998 lbs_deb_enter(LBS_DEB_WEXT
);
2000 switch (dwrq
->flags
& IW_AUTH_INDEX
) {
2001 case IW_AUTH_WPA_VERSION
:
2003 if (adapter
->secinfo
.WPAenabled
)
2004 dwrq
->value
|= IW_AUTH_WPA_VERSION_WPA
;
2005 if (adapter
->secinfo
.WPA2enabled
)
2006 dwrq
->value
|= IW_AUTH_WPA_VERSION_WPA2
;
2008 dwrq
->value
|= IW_AUTH_WPA_VERSION_DISABLED
;
2011 case IW_AUTH_DROP_UNENCRYPTED
:
2013 if (adapter
->currentpacketfilter
&
2014 cmd_act_mac_strict_protection_enable
)
2018 case IW_AUTH_80211_AUTH_ALG
:
2019 dwrq
->value
= adapter
->secinfo
.auth_mode
;
2022 case IW_AUTH_WPA_ENABLED
:
2023 if (adapter
->secinfo
.WPAenabled
&& adapter
->secinfo
.WPA2enabled
)
2031 lbs_deb_leave_args(LBS_DEB_WEXT
, "ret %d", ret
);
2036 static int wlan_set_txpow(struct net_device
*dev
, struct iw_request_info
*info
,
2037 struct iw_param
*vwrq
, char *extra
)
2040 wlan_private
*priv
= dev
->priv
;
2041 wlan_adapter
*adapter
= priv
->adapter
;
2045 lbs_deb_enter(LBS_DEB_WEXT
);
2047 if (vwrq
->disabled
) {
2048 wlan_radio_ioctl(priv
, RADIO_OFF
);
2052 adapter
->preamble
= cmd_type_auto_preamble
;
2054 wlan_radio_ioctl(priv
, RADIO_ON
);
2056 if ((vwrq
->flags
& IW_TXPOW_TYPE
) == IW_TXPOW_MWATT
) {
2057 dbm
= (u16
) mw_to_dbm(vwrq
->value
);
2059 dbm
= (u16
) vwrq
->value
;
2061 /* auto tx power control */
2063 if (vwrq
->fixed
== 0)
2066 lbs_deb_wext("txpower set %d dbm\n", dbm
);
2068 ret
= libertas_prepare_and_send_command(priv
,
2069 cmd_802_11_rf_tx_power
,
2070 cmd_act_tx_power_opt_set_low
,
2071 cmd_option_waitforrsp
, 0, (void *)&dbm
);
2073 lbs_deb_leave_args(LBS_DEB_WEXT
, "ret %d", ret
);
2077 static int wlan_get_essid(struct net_device
*dev
, struct iw_request_info
*info
,
2078 struct iw_point
*dwrq
, char *extra
)
2080 wlan_private
*priv
= dev
->priv
;
2081 wlan_adapter
*adapter
= priv
->adapter
;
2083 lbs_deb_enter(LBS_DEB_WEXT
);
2086 * Note : if dwrq->flags != 0, we should get the relevant SSID from
2091 * Get the current SSID
2093 if (adapter
->connect_status
== libertas_connected
) {
2094 memcpy(extra
, adapter
->curbssparams
.ssid
.ssid
,
2095 adapter
->curbssparams
.ssid
.ssidlength
);
2096 extra
[adapter
->curbssparams
.ssid
.ssidlength
] = '\0';
2098 memset(extra
, 0, 32);
2099 extra
[adapter
->curbssparams
.ssid
.ssidlength
] = '\0';
2102 * If none, we may want to get the one that was set
2105 /* To make the driver backward compatible with WPA supplicant v0.2.4 */
2106 if (dwrq
->length
== 32) /* check with WPA supplicant buffer size */
2107 dwrq
->length
= min_t(size_t, adapter
->curbssparams
.ssid
.ssidlength
,
2110 dwrq
->length
= adapter
->curbssparams
.ssid
.ssidlength
+ 1;
2112 dwrq
->flags
= 1; /* active */
2114 lbs_deb_leave(LBS_DEB_WEXT
);
2118 static int wlan_set_essid(struct net_device
*dev
, struct iw_request_info
*info
,
2119 struct iw_point
*dwrq
, char *extra
)
2121 wlan_private
*priv
= dev
->priv
;
2122 wlan_adapter
*adapter
= priv
->adapter
;
2124 struct WLAN_802_11_SSID ssid
;
2125 struct assoc_request
* assoc_req
;
2126 int ssid_len
= dwrq
->length
;
2128 lbs_deb_enter(LBS_DEB_WEXT
);
2131 * WE-20 and earlier NULL pad the end of the SSID and increment
2132 * SSID length so it can be used like a string. WE-21 and later don't,
2133 * but some userspace tools aren't able to cope with the change.
2135 if ((ssid_len
> 0) && (extra
[ssid_len
- 1] == '\0'))
2138 /* Check the size of the string */
2139 if (ssid_len
> IW_ESSID_MAX_SIZE
) {
2144 memset(&ssid
, 0, sizeof(struct WLAN_802_11_SSID
));
2146 if (!dwrq
->flags
|| !ssid_len
) {
2147 /* "any" SSID requested; leave SSID blank */
2149 /* Specific SSID requested */
2150 memcpy(&ssid
.ssid
, extra
, ssid_len
);
2151 ssid
.ssidlength
= ssid_len
;
2154 lbs_deb_wext("requested new SSID '%s'\n",
2155 (ssid
.ssidlength
> 0) ? (char *)ssid
.ssid
: "any");
2158 mutex_lock(&adapter
->lock
);
2160 /* Get or create the current association request */
2161 assoc_req
= wlan_get_association_request(adapter
);
2165 /* Copy the SSID to the association request */
2166 memcpy(&assoc_req
->ssid
, &ssid
, sizeof(struct WLAN_802_11_SSID
));
2167 set_bit(ASSOC_FLAG_SSID
, &assoc_req
->flags
);
2168 wlan_postpone_association_work(priv
);
2172 /* Cancel the association request if there was an error */
2174 wlan_cancel_association_work(priv
);
2177 mutex_unlock(&adapter
->lock
);
2179 lbs_deb_leave_args(LBS_DEB_WEXT
, "ret %d", ret
);
2184 * @brief Connect to the AP or Ad-hoc Network with specific bssid
2186 * @param dev A pointer to net_device structure
2187 * @param info A pointer to iw_request_info structure
2188 * @param awrq A pointer to iw_param structure
2189 * @param extra A pointer to extra data buf
2190 * @return 0 --success, otherwise fail
2192 static int wlan_set_wap(struct net_device
*dev
, struct iw_request_info
*info
,
2193 struct sockaddr
*awrq
, char *extra
)
2195 wlan_private
*priv
= dev
->priv
;
2196 wlan_adapter
*adapter
= priv
->adapter
;
2197 struct assoc_request
* assoc_req
;
2200 lbs_deb_enter(LBS_DEB_WEXT
);
2202 if (awrq
->sa_family
!= ARPHRD_ETHER
)
2205 lbs_deb_wext("ASSOC: WAP: sa_data " MAC_FMT
"\n", MAC_ARG(awrq
->sa_data
));
2207 mutex_lock(&adapter
->lock
);
2209 /* Get or create the current association request */
2210 assoc_req
= wlan_get_association_request(adapter
);
2212 wlan_cancel_association_work(priv
);
2215 /* Copy the BSSID to the association request */
2216 memcpy(&assoc_req
->bssid
, awrq
->sa_data
, ETH_ALEN
);
2217 set_bit(ASSOC_FLAG_BSSID
, &assoc_req
->flags
);
2218 wlan_postpone_association_work(priv
);
2221 mutex_unlock(&adapter
->lock
);
2226 void libertas_get_fwversion(wlan_adapter
* adapter
, char *fwversion
, int maxlen
)
2234 mutex_lock(&adapter
->lock
);
2235 ver
.l
= adapter
->fwreleasenumber
;
2236 mutex_unlock(&adapter
->lock
);
2239 sprintf(fwver
, "%u.%u.%u", ver
.c
[2], ver
.c
[1], ver
.c
[0]);
2241 sprintf(fwver
, "%u.%u.%u.p%u",
2242 ver
.c
[2], ver
.c
[1], ver
.c
[0], ver
.c
[3]);
2244 snprintf(fwversion
, maxlen
, fwver
);
2249 * iwconfig settable callbacks
2251 static const iw_handler wlan_handler
[] = {
2252 (iw_handler
) NULL
, /* SIOCSIWCOMMIT */
2253 (iw_handler
) wlan_get_name
, /* SIOCGIWNAME */
2254 (iw_handler
) NULL
, /* SIOCSIWNWID */
2255 (iw_handler
) NULL
, /* SIOCGIWNWID */
2256 (iw_handler
) wlan_set_freq
, /* SIOCSIWFREQ */
2257 (iw_handler
) wlan_get_freq
, /* SIOCGIWFREQ */
2258 (iw_handler
) wlan_set_mode
, /* SIOCSIWMODE */
2259 (iw_handler
) wlan_get_mode
, /* SIOCGIWMODE */
2260 (iw_handler
) NULL
, /* SIOCSIWSENS */
2261 (iw_handler
) NULL
, /* SIOCGIWSENS */
2262 (iw_handler
) NULL
, /* SIOCSIWRANGE */
2263 (iw_handler
) wlan_get_range
, /* SIOCGIWRANGE */
2264 (iw_handler
) NULL
, /* SIOCSIWPRIV */
2265 (iw_handler
) NULL
, /* SIOCGIWPRIV */
2266 (iw_handler
) NULL
, /* SIOCSIWSTATS */
2267 (iw_handler
) NULL
, /* SIOCGIWSTATS */
2268 iw_handler_set_spy
, /* SIOCSIWSPY */
2269 iw_handler_get_spy
, /* SIOCGIWSPY */
2270 iw_handler_set_thrspy
, /* SIOCSIWTHRSPY */
2271 iw_handler_get_thrspy
, /* SIOCGIWTHRSPY */
2272 (iw_handler
) wlan_set_wap
, /* SIOCSIWAP */
2273 (iw_handler
) wlan_get_wap
, /* SIOCGIWAP */
2274 (iw_handler
) NULL
, /* SIOCSIWMLME */
2275 (iw_handler
) NULL
, /* SIOCGIWAPLIST - deprecated */
2276 (iw_handler
) libertas_set_scan
, /* SIOCSIWSCAN */
2277 (iw_handler
) libertas_get_scan
, /* SIOCGIWSCAN */
2278 (iw_handler
) wlan_set_essid
, /* SIOCSIWESSID */
2279 (iw_handler
) wlan_get_essid
, /* SIOCGIWESSID */
2280 (iw_handler
) wlan_set_nick
, /* SIOCSIWNICKN */
2281 (iw_handler
) wlan_get_nick
, /* SIOCGIWNICKN */
2282 (iw_handler
) NULL
, /* -- hole -- */
2283 (iw_handler
) NULL
, /* -- hole -- */
2284 (iw_handler
) wlan_set_rate
, /* SIOCSIWRATE */
2285 (iw_handler
) wlan_get_rate
, /* SIOCGIWRATE */
2286 (iw_handler
) wlan_set_rts
, /* SIOCSIWRTS */
2287 (iw_handler
) wlan_get_rts
, /* SIOCGIWRTS */
2288 (iw_handler
) wlan_set_frag
, /* SIOCSIWFRAG */
2289 (iw_handler
) wlan_get_frag
, /* SIOCGIWFRAG */
2290 (iw_handler
) wlan_set_txpow
, /* SIOCSIWTXPOW */
2291 (iw_handler
) wlan_get_txpow
, /* SIOCGIWTXPOW */
2292 (iw_handler
) wlan_set_retry
, /* SIOCSIWRETRY */
2293 (iw_handler
) wlan_get_retry
, /* SIOCGIWRETRY */
2294 (iw_handler
) wlan_set_encode
, /* SIOCSIWENCODE */
2295 (iw_handler
) wlan_get_encode
, /* SIOCGIWENCODE */
2296 (iw_handler
) wlan_set_power
, /* SIOCSIWPOWER */
2297 (iw_handler
) wlan_get_power
, /* SIOCGIWPOWER */
2298 (iw_handler
) NULL
, /* -- hole -- */
2299 (iw_handler
) NULL
, /* -- hole -- */
2300 (iw_handler
) wlan_set_genie
, /* SIOCSIWGENIE */
2301 (iw_handler
) wlan_get_genie
, /* SIOCGIWGENIE */
2302 (iw_handler
) wlan_set_auth
, /* SIOCSIWAUTH */
2303 (iw_handler
) wlan_get_auth
, /* SIOCGIWAUTH */
2304 (iw_handler
) wlan_set_encodeext
,/* SIOCSIWENCODEEXT */
2305 (iw_handler
) wlan_get_encodeext
,/* SIOCGIWENCODEEXT */
2306 (iw_handler
) NULL
, /* SIOCSIWPMKSA */
2309 struct iw_handler_def libertas_handler_def
= {
2310 .num_standard
= sizeof(wlan_handler
) / sizeof(iw_handler
),
2311 .num_private
= sizeof(wlan_private_handler
) / sizeof(iw_handler
),
2312 .num_private_args
= sizeof(wlan_private_args
) /
2313 sizeof(struct iw_priv_args
),
2314 .standard
= (iw_handler
*) wlan_handler
,
2315 .private = (iw_handler
*) wlan_private_handler
,
2316 .private_args
= (struct iw_priv_args
*)wlan_private_args
,
2317 .get_wireless_stats
= wlan_get_wireless_stats
,