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/lib80211.h>
12 #include <net/iw_handler.h>
25 static inline void lbs_postpone_association_work(struct lbs_private *priv)
27 if (priv->surpriseremoved)
29 cancel_delayed_work(&priv->assoc_work);
30 queue_delayed_work(priv->work_thread, &priv->assoc_work, HZ / 2);
33 static inline void lbs_do_association_work(struct lbs_private *priv)
35 if (priv->surpriseremoved)
37 cancel_delayed_work(&priv->assoc_work);
38 queue_delayed_work(priv->work_thread, &priv->assoc_work, 0);
41 static inline void lbs_cancel_association_work(struct lbs_private *priv)
43 cancel_delayed_work(&priv->assoc_work);
44 kfree(priv->pending_assoc_req);
45 priv->pending_assoc_req = NULL;
49 * @brief This function checks if the command is allowed.
51 * @param priv A pointer to lbs_private structure
52 * @return allowed or not allowed.
55 int lbs_is_cmd_allowed(struct lbs_private *priv)
59 lbs_deb_enter(LBS_DEB_WEXT);
61 if (!priv->is_auto_deep_sleep_enabled) {
62 if (priv->is_deep_sleep) {
63 lbs_deb_wext("IOCTLS called when station"
64 "is in deep sleep\n");
69 lbs_deb_leave(LBS_DEB_WEXT);
75 * @brief Find the channel frequency power info with specific channel
77 * @param priv A pointer to struct lbs_private structure
78 * @param band it can be BAND_A, BAND_G or BAND_B
79 * @param channel the channel for looking
80 * @return A pointer to struct chan_freq_power structure or NULL if not find.
82 struct chan_freq_power *lbs_find_cfp_by_band_and_channel(
83 struct lbs_private *priv,
87 struct chan_freq_power *cfp = NULL;
88 struct region_channel *rc;
91 for (j = 0; !cfp && (j < ARRAY_SIZE(priv->region_channel)); j++) {
92 rc = &priv->region_channel[j];
95 rc = &priv->universal_channel[j];
96 if (!rc->valid || !rc->CFP)
100 for (i = 0; i < rc->nrcfp; i++) {
101 if (rc->CFP[i].channel == channel) {
109 lbs_deb_wext("lbs_find_cfp_by_band_and_channel: can't find "
110 "cfp by band %d / channel %d\n", band, channel);
116 * @brief Find the channel frequency power info with specific frequency
118 * @param priv A pointer to struct lbs_private structure
119 * @param band it can be BAND_A, BAND_G or BAND_B
120 * @param freq the frequency for looking
121 * @return A pointer to struct chan_freq_power structure or NULL if not find.
123 static struct chan_freq_power *find_cfp_by_band_and_freq(
124 struct lbs_private *priv,
128 struct chan_freq_power *cfp = NULL;
129 struct region_channel *rc;
132 for (j = 0; !cfp && (j < ARRAY_SIZE(priv->region_channel)); j++) {
133 rc = &priv->region_channel[j];
136 rc = &priv->universal_channel[j];
137 if (!rc->valid || !rc->CFP)
139 if (rc->band != band)
141 for (i = 0; i < rc->nrcfp; i++) {
142 if (rc->CFP[i].freq == freq) {
150 lbs_deb_wext("find_cfp_by_band_and_freql: can't find cfp by "
151 "band %d / freq %d\n", band, freq);
157 * @brief Copy active data rates based on adapter mode and status
159 * @param priv A pointer to struct lbs_private structure
160 * @param rate The buf to return the active rates
162 static void copy_active_data_rates(struct lbs_private *priv, u8 *rates)
164 lbs_deb_enter(LBS_DEB_WEXT);
166 if ((priv->connect_status != LBS_CONNECTED) &&
167 (priv->mesh_connect_status != LBS_CONNECTED))
168 memcpy(rates, lbs_bg_rates, MAX_RATES);
170 memcpy(rates, priv->curbssparams.rates, MAX_RATES);
172 lbs_deb_leave(LBS_DEB_WEXT);
175 static int lbs_get_name(struct net_device *dev, struct iw_request_info *info,
176 char *cwrq, char *extra)
179 lbs_deb_enter(LBS_DEB_WEXT);
181 /* We could add support for 802.11n here as needed. Jean II */
182 snprintf(cwrq, IFNAMSIZ, "IEEE 802.11b/g");
184 lbs_deb_leave(LBS_DEB_WEXT);
188 static int lbs_get_freq(struct net_device *dev, struct iw_request_info *info,
189 struct iw_freq *fwrq, char *extra)
191 struct lbs_private *priv = dev->ml_priv;
192 struct chan_freq_power *cfp;
194 lbs_deb_enter(LBS_DEB_WEXT);
196 if (!lbs_is_cmd_allowed(priv)) {
197 lbs_deb_leave(LBS_DEB_WEXT);
201 cfp = lbs_find_cfp_by_band_and_channel(priv, 0,
202 priv->curbssparams.channel);
205 if (priv->curbssparams.channel)
206 lbs_deb_wext("invalid channel %d\n",
207 priv->curbssparams.channel);
211 fwrq->m = (long)cfp->freq * 100000;
214 lbs_deb_wext("freq %u\n", fwrq->m);
215 lbs_deb_leave(LBS_DEB_WEXT);
219 static int lbs_get_wap(struct net_device *dev, struct iw_request_info *info,
220 struct sockaddr *awrq, char *extra)
222 struct lbs_private *priv = dev->ml_priv;
224 lbs_deb_enter(LBS_DEB_WEXT);
226 if (priv->connect_status == LBS_CONNECTED) {
227 memcpy(awrq->sa_data, priv->curbssparams.bssid, ETH_ALEN);
229 memset(awrq->sa_data, 0, ETH_ALEN);
231 awrq->sa_family = ARPHRD_ETHER;
233 lbs_deb_leave(LBS_DEB_WEXT);
237 static int lbs_set_nick(struct net_device *dev, struct iw_request_info *info,
238 struct iw_point *dwrq, char *extra)
240 struct lbs_private *priv = dev->ml_priv;
242 lbs_deb_enter(LBS_DEB_WEXT);
245 * Check the size of the string
248 if (dwrq->length > 16) {
252 mutex_lock(&priv->lock);
253 memset(priv->nodename, 0, sizeof(priv->nodename));
254 memcpy(priv->nodename, extra, dwrq->length);
255 mutex_unlock(&priv->lock);
257 lbs_deb_leave(LBS_DEB_WEXT);
261 static int lbs_get_nick(struct net_device *dev, struct iw_request_info *info,
262 struct iw_point *dwrq, char *extra)
264 struct lbs_private *priv = dev->ml_priv;
266 lbs_deb_enter(LBS_DEB_WEXT);
268 dwrq->length = strlen(priv->nodename);
269 memcpy(extra, priv->nodename, dwrq->length);
270 extra[dwrq->length] = '\0';
272 dwrq->flags = 1; /* active */
274 lbs_deb_leave(LBS_DEB_WEXT);
278 static int mesh_get_nick(struct net_device *dev, struct iw_request_info *info,
279 struct iw_point *dwrq, char *extra)
281 struct lbs_private *priv = dev->ml_priv;
283 lbs_deb_enter(LBS_DEB_WEXT);
285 /* Use nickname to indicate that mesh is on */
287 if (priv->mesh_connect_status == LBS_CONNECTED) {
288 strncpy(extra, "Mesh", 12);
290 dwrq->length = strlen(extra);
298 lbs_deb_leave(LBS_DEB_WEXT);
302 static int lbs_set_rts(struct net_device *dev, struct iw_request_info *info,
303 struct iw_param *vwrq, char *extra)
306 struct lbs_private *priv = dev->ml_priv;
307 u32 val = vwrq->value;
309 lbs_deb_enter(LBS_DEB_WEXT);
311 if (!lbs_is_cmd_allowed(priv)) {
313 lbs_deb_leave_args(LBS_DEB_WEXT, "ret %d", ret);
318 val = MRVDRV_RTS_MAX_VALUE;
320 if (val > MRVDRV_RTS_MAX_VALUE) /* min rts value is 0 */
323 ret = lbs_set_snmp_mib(priv, SNMP_MIB_OID_RTS_THRESHOLD, (u16) val);
325 lbs_deb_leave_args(LBS_DEB_WEXT, "ret %d", ret);
329 static int lbs_get_rts(struct net_device *dev, struct iw_request_info *info,
330 struct iw_param *vwrq, char *extra)
332 struct lbs_private *priv = dev->ml_priv;
336 lbs_deb_enter(LBS_DEB_WEXT);
338 if (!lbs_is_cmd_allowed(priv)) {
343 ret = lbs_get_snmp_mib(priv, SNMP_MIB_OID_RTS_THRESHOLD, &val);
348 vwrq->disabled = val > MRVDRV_RTS_MAX_VALUE; /* min rts value is 0 */
352 lbs_deb_leave_args(LBS_DEB_WEXT, "ret %d", ret);
356 static int lbs_set_frag(struct net_device *dev, struct iw_request_info *info,
357 struct iw_param *vwrq, char *extra)
359 struct lbs_private *priv = dev->ml_priv;
361 u32 val = vwrq->value;
363 lbs_deb_enter(LBS_DEB_WEXT);
365 if (!lbs_is_cmd_allowed(priv)) {
367 lbs_deb_leave_args(LBS_DEB_WEXT, "ret %d", ret);
372 val = MRVDRV_FRAG_MAX_VALUE;
374 if (val < MRVDRV_FRAG_MIN_VALUE || val > MRVDRV_FRAG_MAX_VALUE)
377 ret = lbs_set_snmp_mib(priv, SNMP_MIB_OID_FRAG_THRESHOLD, (u16) val);
379 lbs_deb_leave_args(LBS_DEB_WEXT, "ret %d", ret);
383 static int lbs_get_frag(struct net_device *dev, struct iw_request_info *info,
384 struct iw_param *vwrq, char *extra)
386 struct lbs_private *priv = dev->ml_priv;
390 lbs_deb_enter(LBS_DEB_WEXT);
392 if (!lbs_is_cmd_allowed(priv)) {
397 ret = lbs_get_snmp_mib(priv, SNMP_MIB_OID_FRAG_THRESHOLD, &val);
402 vwrq->disabled = ((val < MRVDRV_FRAG_MIN_VALUE)
403 || (val > MRVDRV_FRAG_MAX_VALUE));
407 lbs_deb_leave_args(LBS_DEB_WEXT, "ret %d", ret);
411 static int lbs_get_mode(struct net_device *dev,
412 struct iw_request_info *info, u32 * uwrq, char *extra)
414 struct lbs_private *priv = dev->ml_priv;
416 lbs_deb_enter(LBS_DEB_WEXT);
420 lbs_deb_leave(LBS_DEB_WEXT);
424 static int mesh_wlan_get_mode(struct net_device *dev,
425 struct iw_request_info *info, u32 * uwrq,
428 lbs_deb_enter(LBS_DEB_WEXT);
430 *uwrq = IW_MODE_REPEAT;
432 lbs_deb_leave(LBS_DEB_WEXT);
436 static int lbs_get_txpow(struct net_device *dev,
437 struct iw_request_info *info,
438 struct iw_param *vwrq, char *extra)
440 struct lbs_private *priv = dev->ml_priv;
444 lbs_deb_enter(LBS_DEB_WEXT);
446 if (!lbs_is_cmd_allowed(priv)) {
451 if (!priv->radio_on) {
452 lbs_deb_wext("tx power off\n");
458 ret = lbs_get_tx_power(priv, &curlevel, NULL, NULL);
462 lbs_deb_wext("tx power level %d dbm\n", curlevel);
463 priv->txpower_cur = curlevel;
465 vwrq->value = curlevel;
468 vwrq->flags = IW_TXPOW_DBM;
471 lbs_deb_leave_args(LBS_DEB_WEXT, "ret %d", ret);
475 static int lbs_set_retry(struct net_device *dev, struct iw_request_info *info,
476 struct iw_param *vwrq, char *extra)
478 struct lbs_private *priv = dev->ml_priv;
480 u16 slimit = 0, llimit = 0;
482 lbs_deb_enter(LBS_DEB_WEXT);
484 if (!lbs_is_cmd_allowed(priv)) {
489 if ((vwrq->flags & IW_RETRY_TYPE) != IW_RETRY_LIMIT)
492 /* The MAC has a 4-bit Total_Tx_Count register
493 Total_Tx_Count = 1 + Tx_Retry_Count */
494 #define TX_RETRY_MIN 0
495 #define TX_RETRY_MAX 14
496 if (vwrq->value < TX_RETRY_MIN || vwrq->value > TX_RETRY_MAX)
499 /* Add 1 to convert retry count to try count */
500 if (vwrq->flags & IW_RETRY_SHORT)
501 slimit = (u16) (vwrq->value + 1);
502 else if (vwrq->flags & IW_RETRY_LONG)
503 llimit = (u16) (vwrq->value + 1);
505 slimit = llimit = (u16) (vwrq->value + 1); /* set both */
508 ret = lbs_set_snmp_mib(priv, SNMP_MIB_OID_LONG_RETRY_LIMIT,
515 /* txretrycount follows the short retry limit */
516 priv->txretrycount = slimit;
517 ret = lbs_set_snmp_mib(priv, SNMP_MIB_OID_SHORT_RETRY_LIMIT,
524 lbs_deb_leave_args(LBS_DEB_WEXT, "ret %d", ret);
528 static int lbs_get_retry(struct net_device *dev, struct iw_request_info *info,
529 struct iw_param *vwrq, char *extra)
531 struct lbs_private *priv = dev->ml_priv;
535 lbs_deb_enter(LBS_DEB_WEXT);
537 if (!lbs_is_cmd_allowed(priv)) {
544 if (vwrq->flags & IW_RETRY_LONG) {
545 ret = lbs_get_snmp_mib(priv, SNMP_MIB_OID_LONG_RETRY_LIMIT, &val);
549 /* Subtract 1 to convert try count to retry count */
550 vwrq->value = val - 1;
551 vwrq->flags = IW_RETRY_LIMIT | IW_RETRY_LONG;
553 ret = lbs_get_snmp_mib(priv, SNMP_MIB_OID_SHORT_RETRY_LIMIT, &val);
557 /* txretry count follows the short retry limit */
558 priv->txretrycount = val;
559 /* Subtract 1 to convert try count to retry count */
560 vwrq->value = val - 1;
561 vwrq->flags = IW_RETRY_LIMIT | IW_RETRY_SHORT;
565 lbs_deb_leave_args(LBS_DEB_WEXT, "ret %d", ret);
569 static inline void sort_channels(struct iw_freq *freq, int num)
574 for (i = 0; i < num; i++)
575 for (j = i + 1; j < num; j++)
576 if (freq[i].i > freq[j].i) {
580 freq[i].i = freq[j].i;
581 freq[i].m = freq[j].m;
591 Infra G(12) A(8) B(4) G(12)
592 Adhoc A+B(12) A(8) B(4) B(4)
600 * @brief Get Range Info
602 * @param dev A pointer to net_device structure
603 * @param info A pointer to iw_request_info structure
604 * @param vwrq A pointer to iw_param structure
605 * @param extra A pointer to extra data buf
606 * @return 0 --success, otherwise fail
608 static int lbs_get_range(struct net_device *dev, struct iw_request_info *info,
609 struct iw_point *dwrq, char *extra)
612 struct lbs_private *priv = dev->ml_priv;
613 struct iw_range *range = (struct iw_range *)extra;
614 struct chan_freq_power *cfp;
615 u8 rates[MAX_RATES + 1];
619 lbs_deb_enter(LBS_DEB_WEXT);
621 dwrq->length = sizeof(struct iw_range);
622 memset(range, 0, sizeof(struct iw_range));
627 memset(rates, 0, sizeof(rates));
628 copy_active_data_rates(priv, rates);
629 range->num_bitrates = strnlen(rates, IW_MAX_BITRATES);
630 for (i = 0; i < range->num_bitrates; i++)
631 range->bitrate[i] = rates[i] * 500000;
632 range->num_bitrates = i;
633 lbs_deb_wext("IW_MAX_BITRATES %d, num_bitrates %d\n", IW_MAX_BITRATES,
634 range->num_bitrates);
636 range->num_frequency = 0;
638 range->scan_capa = IW_SCAN_CAPA_ESSID;
640 if (priv->enable11d &&
641 (priv->connect_status == LBS_CONNECTED ||
642 priv->mesh_connect_status == LBS_CONNECTED)) {
646 struct parsed_region_chan_11d *parsed_region_chan =
647 &priv->parsed_region_chan;
649 if (parsed_region_chan == NULL) {
650 lbs_deb_wext("11d: parsed_region_chan is NULL\n");
653 band = parsed_region_chan->band;
654 lbs_deb_wext("band %d, nr_char %d\n", band,
655 parsed_region_chan->nr_chan);
657 for (i = 0; (range->num_frequency < IW_MAX_FREQUENCIES)
658 && (i < parsed_region_chan->nr_chan); i++) {
659 chan_no = parsed_region_chan->chanpwr[i].chan;
660 lbs_deb_wext("chan_no %d\n", chan_no);
661 range->freq[range->num_frequency].i = (long)chan_no;
662 range->freq[range->num_frequency].m =
663 (long)lbs_chan_2_freq(chan_no) * 100000;
664 range->freq[range->num_frequency].e = 1;
665 range->num_frequency++;
670 for (j = 0; (range->num_frequency < IW_MAX_FREQUENCIES)
671 && (j < ARRAY_SIZE(priv->region_channel)); j++) {
672 cfp = priv->region_channel[j].CFP;
673 for (i = 0; (range->num_frequency < IW_MAX_FREQUENCIES)
674 && priv->region_channel[j].valid
676 && (i < priv->region_channel[j].nrcfp); i++) {
677 range->freq[range->num_frequency].i =
679 range->freq[range->num_frequency].m =
680 (long)cfp->freq * 100000;
681 range->freq[range->num_frequency].e = 1;
683 range->num_frequency++;
688 lbs_deb_wext("IW_MAX_FREQUENCIES %d, num_frequency %d\n",
689 IW_MAX_FREQUENCIES, range->num_frequency);
691 range->num_channels = range->num_frequency;
693 sort_channels(&range->freq[0], range->num_frequency);
696 * Set an indication of the max TCP throughput in bit/s that we can
697 * expect using this interface
700 range->throughput = 5000 * 1000;
702 range->throughput = 1500 * 1000;
704 range->min_rts = MRVDRV_RTS_MIN_VALUE;
705 range->max_rts = MRVDRV_RTS_MAX_VALUE;
706 range->min_frag = MRVDRV_FRAG_MIN_VALUE;
707 range->max_frag = MRVDRV_FRAG_MAX_VALUE;
709 range->encoding_size[0] = 5;
710 range->encoding_size[1] = 13;
711 range->num_encoding_sizes = 2;
712 range->max_encoding_tokens = 4;
715 * Right now we support only "iwconfig ethX power on|off"
717 range->pm_capa = IW_POWER_ON;
720 * Minimum version we recommend
722 range->we_version_source = 15;
725 * Version we are compiled with
727 range->we_version_compiled = WIRELESS_EXT;
729 range->retry_capa = IW_RETRY_LIMIT;
730 range->retry_flags = IW_RETRY_LIMIT | IW_RETRY_MAX;
732 range->min_retry = TX_RETRY_MIN;
733 range->max_retry = TX_RETRY_MAX;
736 * Set the qual, level and noise range values
738 range->max_qual.qual = 100;
739 range->max_qual.level = 0;
740 range->max_qual.noise = 0;
741 range->max_qual.updated = IW_QUAL_ALL_UPDATED | IW_QUAL_DBM;
743 range->avg_qual.qual = 70;
744 /* TODO: Find real 'good' to 'bad' threshold value for RSSI */
745 range->avg_qual.level = 0;
746 range->avg_qual.noise = 0;
747 range->avg_qual.updated = IW_QUAL_ALL_UPDATED | IW_QUAL_DBM;
749 range->sensitivity = 0;
751 /* Setup the supported power level ranges */
752 memset(range->txpower, 0, sizeof(range->txpower));
753 range->txpower_capa = IW_TXPOW_DBM | IW_TXPOW_RANGE;
754 range->txpower[0] = priv->txpower_min;
755 range->txpower[1] = priv->txpower_max;
756 range->num_txpower = 2;
758 range->event_capa[0] = (IW_EVENT_CAPA_K_0 |
759 IW_EVENT_CAPA_MASK(SIOCGIWAP) |
760 IW_EVENT_CAPA_MASK(SIOCGIWSCAN));
761 range->event_capa[1] = IW_EVENT_CAPA_K_1;
763 if (priv->fwcapinfo & FW_CAPINFO_WPA) {
764 range->enc_capa = IW_ENC_CAPA_WPA
766 | IW_ENC_CAPA_CIPHER_TKIP
767 | IW_ENC_CAPA_CIPHER_CCMP;
771 lbs_deb_leave(LBS_DEB_WEXT);
775 static int lbs_set_power(struct net_device *dev, struct iw_request_info *info,
776 struct iw_param *vwrq, char *extra)
778 struct lbs_private *priv = dev->ml_priv;
781 lbs_deb_enter(LBS_DEB_WEXT);
783 if (!(priv->fwcapinfo & FW_CAPINFO_PS)) {
790 /* PS is currently supported only in Infrastructure mode
791 * Remove this check if it is to be supported in IBSS mode also
794 if (vwrq->disabled) {
795 priv->psmode = LBS802_11POWERMODECAM;
796 if (priv->psstate != PS_STATE_FULL_POWER) {
797 lbs_ps_wakeup(priv, CMD_OPTION_WAITFORRSP);
803 if ((vwrq->flags & IW_POWER_TYPE) == IW_POWER_TIMEOUT) {
805 "setting power timeout is not supported\n");
807 } else if ((vwrq->flags & IW_POWER_TYPE) == IW_POWER_PERIOD) {
808 vwrq->value = vwrq->value / 1000;
809 if (!priv->enter_deep_sleep) {
810 lbs_pr_err("deep sleep feature is not implemented "
811 "for this interface driver\n");
815 if (priv->connect_status == LBS_CONNECTED) {
816 if ((priv->is_auto_deep_sleep_enabled) &&
817 (vwrq->value == -1000)) {
818 lbs_exit_auto_deep_sleep(priv);
821 lbs_pr_err("can't use deep sleep cmd in "
822 "connected state\n");
827 if ((vwrq->value < 0) && (vwrq->value != -1000)) {
828 lbs_pr_err("unknown option\n");
832 if (vwrq->value > 0) {
833 if (!priv->is_auto_deep_sleep_enabled) {
834 priv->is_activity_detected = 0;
835 priv->auto_deep_sleep_timeout = vwrq->value;
836 lbs_enter_auto_deep_sleep(priv);
838 priv->auto_deep_sleep_timeout = vwrq->value;
839 lbs_deb_debugfs("auto deep sleep: "
840 "already enabled\n");
844 if (priv->is_auto_deep_sleep_enabled) {
845 lbs_exit_auto_deep_sleep(priv);
846 /* Try to exit deep sleep if auto */
847 /*deep sleep disabled */
848 ret = lbs_set_deep_sleep(priv, 0);
850 if (vwrq->value == 0)
851 ret = lbs_set_deep_sleep(priv, 1);
852 else if (vwrq->value == -1000)
853 ret = lbs_set_deep_sleep(priv, 0);
858 if (priv->psmode != LBS802_11POWERMODECAM) {
862 priv->psmode = LBS802_11POWERMODEMAX_PSP;
864 if (priv->connect_status == LBS_CONNECTED) {
865 lbs_ps_sleep(priv, CMD_OPTION_WAITFORRSP);
868 lbs_deb_leave(LBS_DEB_WEXT);
873 static int lbs_get_power(struct net_device *dev, struct iw_request_info *info,
874 struct iw_param *vwrq, char *extra)
876 struct lbs_private *priv = dev->ml_priv;
878 lbs_deb_enter(LBS_DEB_WEXT);
882 vwrq->disabled = priv->psmode == LBS802_11POWERMODECAM
883 || priv->connect_status == LBS_DISCONNECTED;
885 lbs_deb_leave(LBS_DEB_WEXT);
889 static struct iw_statistics *lbs_get_wireless_stats(struct net_device *dev)
899 struct lbs_private *priv = dev->ml_priv;
906 struct cmd_ds_802_11_get_log log;
908 lbs_deb_enter(LBS_DEB_WEXT);
910 if (!lbs_is_cmd_allowed(priv))
913 priv->wstats.status = priv->mode;
915 /* If we're not associated, all quality values are meaningless */
916 if ((priv->connect_status != LBS_CONNECTED) &&
917 (priv->mesh_connect_status != LBS_CONNECTED))
920 /* Quality by RSSI */
921 priv->wstats.qual.level =
922 CAL_RSSI(priv->SNR[TYPE_BEACON][TYPE_NOAVG],
923 priv->NF[TYPE_BEACON][TYPE_NOAVG]);
925 if (priv->NF[TYPE_BEACON][TYPE_NOAVG] == 0) {
926 priv->wstats.qual.noise = MRVDRV_NF_DEFAULT_SCAN_VALUE;
928 priv->wstats.qual.noise =
929 CAL_NF(priv->NF[TYPE_BEACON][TYPE_NOAVG]);
932 lbs_deb_wext("signal level %#x\n", priv->wstats.qual.level);
933 lbs_deb_wext("noise %#x\n", priv->wstats.qual.noise);
935 rssi = priv->wstats.qual.level - priv->wstats.qual.noise;
937 rssi_qual = rssi * POOR / 10;
939 rssi_qual = (rssi - 15) * (FAIR - POOR) / 5 + POOR;
941 rssi_qual = (rssi - 20) * (GOOD - FAIR) / 5 + FAIR;
943 rssi_qual = (rssi - 30) * (VERY_GOOD - GOOD) /
946 rssi_qual = (rssi - 40) * (PERFECT - VERY_GOOD) /
950 /* Quality by TX errors */
951 priv->wstats.discard.retries = dev->stats.tx_errors;
953 memset(&log, 0, sizeof(log));
954 log.hdr.size = cpu_to_le16(sizeof(log));
955 lbs_cmd_with_response(priv, CMD_802_11_GET_LOG, &log);
957 tx_retries = le32_to_cpu(log.retry);
960 tx_qual = (90 - tx_retries) * POOR / 15;
961 else if (tx_retries > 70)
962 tx_qual = (75 - tx_retries) * (FAIR - POOR) / 5 + POOR;
963 else if (tx_retries > 65)
964 tx_qual = (70 - tx_retries) * (GOOD - FAIR) / 5 + FAIR;
965 else if (tx_retries > 50)
966 tx_qual = (65 - tx_retries) * (VERY_GOOD - GOOD) /
969 tx_qual = (50 - tx_retries) *
970 (PERFECT - VERY_GOOD) / 50 + VERY_GOOD;
971 quality = min(quality, tx_qual);
973 priv->wstats.discard.code = le32_to_cpu(log.wepundecryptable);
974 priv->wstats.discard.retries = tx_retries;
975 priv->wstats.discard.misc = le32_to_cpu(log.ackfailure);
977 /* Calculate quality */
978 priv->wstats.qual.qual = min_t(u8, quality, 100);
979 priv->wstats.qual.updated = IW_QUAL_ALL_UPDATED | IW_QUAL_DBM;
982 /* update stats asynchronously for future calls */
983 lbs_prepare_and_send_command(priv, CMD_802_11_RSSI, 0,
987 priv->wstats.miss.beacon = 0;
988 priv->wstats.discard.retries = 0;
989 priv->wstats.qual.qual = 0;
990 priv->wstats.qual.level = 0;
991 priv->wstats.qual.noise = 0;
992 priv->wstats.qual.updated = IW_QUAL_ALL_UPDATED;
993 priv->wstats.qual.updated |= IW_QUAL_NOISE_INVALID |
994 IW_QUAL_QUAL_INVALID | IW_QUAL_LEVEL_INVALID;
997 lbs_deb_leave(LBS_DEB_WEXT);
998 return &priv->wstats;
1003 static int lbs_set_freq(struct net_device *dev, struct iw_request_info *info,
1004 struct iw_freq *fwrq, char *extra)
1007 struct lbs_private *priv = dev->ml_priv;
1008 struct chan_freq_power *cfp;
1009 struct assoc_request * assoc_req;
1011 lbs_deb_enter(LBS_DEB_WEXT);
1013 if (!lbs_is_cmd_allowed(priv)) {
1015 lbs_deb_leave_args(LBS_DEB_WEXT, "ret %d", ret);
1019 mutex_lock(&priv->lock);
1020 assoc_req = lbs_get_association_request(priv);
1026 /* If setting by frequency, convert to a channel */
1028 long f = fwrq->m / 100000;
1030 cfp = find_cfp_by_band_and_freq(priv, 0, f);
1032 lbs_deb_wext("invalid freq %ld\n", f);
1037 fwrq->m = (int) cfp->channel;
1040 /* Setting by channel number */
1041 if (fwrq->m > 1000 || fwrq->e > 0) {
1045 cfp = lbs_find_cfp_by_band_and_channel(priv, 0, fwrq->m);
1050 assoc_req->channel = fwrq->m;
1055 set_bit(ASSOC_FLAG_CHANNEL, &assoc_req->flags);
1056 lbs_postpone_association_work(priv);
1058 lbs_cancel_association_work(priv);
1060 mutex_unlock(&priv->lock);
1062 lbs_deb_leave_args(LBS_DEB_WEXT, "ret %d", ret);
1066 static int lbs_mesh_set_freq(struct net_device *dev,
1067 struct iw_request_info *info,
1068 struct iw_freq *fwrq, char *extra)
1070 struct lbs_private *priv = dev->ml_priv;
1071 struct chan_freq_power *cfp;
1074 lbs_deb_enter(LBS_DEB_WEXT);
1076 /* If setting by frequency, convert to a channel */
1078 long f = fwrq->m / 100000;
1080 cfp = find_cfp_by_band_and_freq(priv, 0, f);
1082 lbs_deb_wext("invalid freq %ld\n", f);
1087 fwrq->m = (int) cfp->channel;
1090 /* Setting by channel number */
1091 if (fwrq->m > 1000 || fwrq->e > 0) {
1095 cfp = lbs_find_cfp_by_band_and_channel(priv, 0, fwrq->m);
1100 if (fwrq->m != priv->curbssparams.channel) {
1101 lbs_deb_wext("mesh channel change forces eth disconnect\n");
1102 if (priv->mode == IW_MODE_INFRA)
1103 lbs_cmd_80211_deauthenticate(priv,
1104 priv->curbssparams.bssid,
1105 WLAN_REASON_DEAUTH_LEAVING);
1106 else if (priv->mode == IW_MODE_ADHOC)
1107 lbs_adhoc_stop(priv);
1109 lbs_mesh_config(priv, CMD_ACT_MESH_CONFIG_START, fwrq->m);
1110 lbs_update_channel(priv);
1114 lbs_deb_leave_args(LBS_DEB_WEXT, "ret %d", ret);
1118 static int lbs_set_rate(struct net_device *dev, struct iw_request_info *info,
1119 struct iw_param *vwrq, char *extra)
1121 struct lbs_private *priv = dev->ml_priv;
1124 u8 rates[MAX_RATES + 1];
1126 lbs_deb_enter(LBS_DEB_WEXT);
1128 if (!lbs_is_cmd_allowed(priv)) {
1133 lbs_deb_wext("vwrq->value %d\n", vwrq->value);
1134 lbs_deb_wext("vwrq->fixed %d\n", vwrq->fixed);
1136 if (vwrq->fixed && vwrq->value == -1)
1140 priv->enablehwauto = !vwrq->fixed;
1142 if (vwrq->value == -1)
1145 if (vwrq->value % 100000)
1148 new_rate = vwrq->value / 500000;
1149 priv->cur_rate = new_rate;
1150 /* the rest is only needed for lbs_set_data_rate() */
1151 memset(rates, 0, sizeof(rates));
1152 copy_active_data_rates(priv, rates);
1153 if (!memchr(rates, new_rate, sizeof(rates))) {
1154 lbs_pr_alert("fixed data rate 0x%X out of range\n",
1158 if (priv->fwrelease < 0x09000000) {
1159 ret = lbs_set_power_adapt_cfg(priv, 0,
1160 POW_ADAPT_DEFAULT_P0,
1161 POW_ADAPT_DEFAULT_P1,
1162 POW_ADAPT_DEFAULT_P2);
1166 ret = lbs_set_tpc_cfg(priv, 0, TPC_DEFAULT_P0, TPC_DEFAULT_P1,
1172 /* Try the newer command first (Firmware Spec 5.1 and above) */
1173 ret = lbs_cmd_802_11_rate_adapt_rateset(priv, CMD_ACT_SET);
1175 /* Fallback to older version */
1177 ret = lbs_set_data_rate(priv, new_rate);
1180 lbs_deb_leave_args(LBS_DEB_WEXT, "ret %d", ret);
1184 static int lbs_get_rate(struct net_device *dev, struct iw_request_info *info,
1185 struct iw_param *vwrq, char *extra)
1187 struct lbs_private *priv = dev->ml_priv;
1189 lbs_deb_enter(LBS_DEB_WEXT);
1191 if (!lbs_is_cmd_allowed(priv)) {
1192 lbs_deb_leave(LBS_DEB_WEXT);
1196 if (priv->connect_status == LBS_CONNECTED) {
1197 vwrq->value = priv->cur_rate * 500000;
1199 if (priv->enablehwauto)
1209 lbs_deb_leave(LBS_DEB_WEXT);
1213 static int lbs_set_mode(struct net_device *dev,
1214 struct iw_request_info *info, u32 * uwrq, char *extra)
1217 struct lbs_private *priv = dev->ml_priv;
1218 struct assoc_request * assoc_req;
1220 lbs_deb_enter(LBS_DEB_WEXT);
1222 if (!lbs_is_cmd_allowed(priv)) {
1227 if ( (*uwrq != IW_MODE_ADHOC)
1228 && (*uwrq != IW_MODE_INFRA)
1229 && (*uwrq != IW_MODE_AUTO)) {
1230 lbs_deb_wext("Invalid mode: 0x%x\n", *uwrq);
1235 mutex_lock(&priv->lock);
1236 assoc_req = lbs_get_association_request(priv);
1239 lbs_cancel_association_work(priv);
1241 assoc_req->mode = *uwrq;
1242 set_bit(ASSOC_FLAG_MODE, &assoc_req->flags);
1243 lbs_postpone_association_work(priv);
1244 lbs_deb_wext("Switching to mode: 0x%x\n", *uwrq);
1246 mutex_unlock(&priv->lock);
1249 lbs_deb_leave_args(LBS_DEB_WEXT, "ret %d", ret);
1255 * @brief Get Encryption key
1257 * @param dev A pointer to net_device structure
1258 * @param info A pointer to iw_request_info structure
1259 * @param vwrq A pointer to iw_param structure
1260 * @param extra A pointer to extra data buf
1261 * @return 0 --success, otherwise fail
1263 static int lbs_get_encode(struct net_device *dev,
1264 struct iw_request_info *info,
1265 struct iw_point *dwrq, u8 * extra)
1267 struct lbs_private *priv = dev->ml_priv;
1268 int index = (dwrq->flags & IW_ENCODE_INDEX) - 1;
1270 lbs_deb_enter(LBS_DEB_WEXT);
1272 lbs_deb_wext("flags 0x%x, index %d, length %d, wep_tx_keyidx %d\n",
1273 dwrq->flags, index, dwrq->length, priv->wep_tx_keyidx);
1277 /* Authentication method */
1278 switch (priv->secinfo.auth_mode) {
1279 case IW_AUTH_ALG_OPEN_SYSTEM:
1280 dwrq->flags = IW_ENCODE_OPEN;
1283 case IW_AUTH_ALG_SHARED_KEY:
1284 case IW_AUTH_ALG_LEAP:
1285 dwrq->flags = IW_ENCODE_RESTRICTED;
1288 dwrq->flags = IW_ENCODE_DISABLED | IW_ENCODE_OPEN;
1292 memset(extra, 0, 16);
1294 mutex_lock(&priv->lock);
1296 /* Default to returning current transmit key */
1298 index = priv->wep_tx_keyidx;
1300 if ((priv->wep_keys[index].len) && priv->secinfo.wep_enabled) {
1301 memcpy(extra, priv->wep_keys[index].key,
1302 priv->wep_keys[index].len);
1303 dwrq->length = priv->wep_keys[index].len;
1305 dwrq->flags |= (index + 1);
1306 /* Return WEP enabled */
1307 dwrq->flags &= ~IW_ENCODE_DISABLED;
1308 } else if ((priv->secinfo.WPAenabled)
1309 || (priv->secinfo.WPA2enabled)) {
1310 /* return WPA enabled */
1311 dwrq->flags &= ~IW_ENCODE_DISABLED;
1312 dwrq->flags |= IW_ENCODE_NOKEY;
1314 dwrq->flags |= IW_ENCODE_DISABLED;
1317 mutex_unlock(&priv->lock);
1319 lbs_deb_wext("key: %02x:%02x:%02x:%02x:%02x:%02x, keylen %d\n",
1320 extra[0], extra[1], extra[2],
1321 extra[3], extra[4], extra[5], dwrq->length);
1323 lbs_deb_wext("return flags 0x%x\n", dwrq->flags);
1325 lbs_deb_leave(LBS_DEB_WEXT);
1330 * @brief Set Encryption key (internal)
1332 * @param priv A pointer to private card structure
1333 * @param key_material A pointer to key material
1334 * @param key_length length of key material
1335 * @param index key index to set
1336 * @param set_tx_key Force set TX key (1 = yes, 0 = no)
1337 * @return 0 --success, otherwise fail
1339 static int lbs_set_wep_key(struct assoc_request *assoc_req,
1340 const char *key_material,
1346 struct enc_key *pkey;
1348 lbs_deb_enter(LBS_DEB_WEXT);
1350 /* Paranoid validation of key index */
1356 /* validate max key length */
1357 if (key_length > KEY_LEN_WEP_104) {
1362 pkey = &assoc_req->wep_keys[index];
1364 if (key_length > 0) {
1365 memset(pkey, 0, sizeof(struct enc_key));
1366 pkey->type = KEY_TYPE_ID_WEP;
1368 /* Standardize the key length */
1369 pkey->len = (key_length > KEY_LEN_WEP_40) ?
1370 KEY_LEN_WEP_104 : KEY_LEN_WEP_40;
1371 memcpy(pkey->key, key_material, key_length);
1375 /* Ensure the chosen key is valid */
1377 lbs_deb_wext("key not set, so cannot enable it\n");
1381 assoc_req->wep_tx_keyidx = index;
1384 assoc_req->secinfo.wep_enabled = 1;
1387 lbs_deb_leave_args(LBS_DEB_WEXT, "ret %d", ret);
1391 static int validate_key_index(u16 def_index, u16 raw_index,
1392 u16 *out_index, u16 *is_default)
1394 if (!out_index || !is_default)
1397 /* Verify index if present, otherwise use default TX key index */
1398 if (raw_index > 0) {
1401 *out_index = raw_index - 1;
1403 *out_index = def_index;
1409 static void disable_wep(struct assoc_request *assoc_req)
1413 lbs_deb_enter(LBS_DEB_WEXT);
1415 /* Set Open System auth mode */
1416 assoc_req->secinfo.auth_mode = IW_AUTH_ALG_OPEN_SYSTEM;
1418 /* Clear WEP keys and mark WEP as disabled */
1419 assoc_req->secinfo.wep_enabled = 0;
1420 for (i = 0; i < 4; i++)
1421 assoc_req->wep_keys[i].len = 0;
1423 set_bit(ASSOC_FLAG_SECINFO, &assoc_req->flags);
1424 set_bit(ASSOC_FLAG_WEP_KEYS, &assoc_req->flags);
1426 lbs_deb_leave(LBS_DEB_WEXT);
1429 static void disable_wpa(struct assoc_request *assoc_req)
1431 lbs_deb_enter(LBS_DEB_WEXT);
1433 memset(&assoc_req->wpa_mcast_key, 0, sizeof (struct enc_key));
1434 assoc_req->wpa_mcast_key.flags = KEY_INFO_WPA_MCAST;
1435 set_bit(ASSOC_FLAG_WPA_MCAST_KEY, &assoc_req->flags);
1437 memset(&assoc_req->wpa_unicast_key, 0, sizeof (struct enc_key));
1438 assoc_req->wpa_unicast_key.flags = KEY_INFO_WPA_UNICAST;
1439 set_bit(ASSOC_FLAG_WPA_UCAST_KEY, &assoc_req->flags);
1441 assoc_req->secinfo.WPAenabled = 0;
1442 assoc_req->secinfo.WPA2enabled = 0;
1443 set_bit(ASSOC_FLAG_SECINFO, &assoc_req->flags);
1445 lbs_deb_leave(LBS_DEB_WEXT);
1449 * @brief Set Encryption key
1451 * @param dev A pointer to net_device structure
1452 * @param info A pointer to iw_request_info structure
1453 * @param vwrq A pointer to iw_param structure
1454 * @param extra A pointer to extra data buf
1455 * @return 0 --success, otherwise fail
1457 static int lbs_set_encode(struct net_device *dev,
1458 struct iw_request_info *info,
1459 struct iw_point *dwrq, char *extra)
1462 struct lbs_private *priv = dev->ml_priv;
1463 struct assoc_request * assoc_req;
1464 u16 is_default = 0, index = 0, set_tx_key = 0;
1466 lbs_deb_enter(LBS_DEB_WEXT);
1468 if (!lbs_is_cmd_allowed(priv)) {
1470 lbs_deb_leave_args(LBS_DEB_WEXT, "ret %d", ret);
1474 mutex_lock(&priv->lock);
1475 assoc_req = lbs_get_association_request(priv);
1481 if (dwrq->flags & IW_ENCODE_DISABLED) {
1482 disable_wep (assoc_req);
1483 disable_wpa (assoc_req);
1487 ret = validate_key_index(assoc_req->wep_tx_keyidx,
1488 (dwrq->flags & IW_ENCODE_INDEX),
1489 &index, &is_default);
1495 /* If WEP isn't enabled, or if there is no key data but a valid
1496 * index, set the TX key.
1498 if (!assoc_req->secinfo.wep_enabled || (dwrq->length == 0 && !is_default))
1501 ret = lbs_set_wep_key(assoc_req, extra, dwrq->length, index, set_tx_key);
1506 set_bit(ASSOC_FLAG_WEP_KEYS, &assoc_req->flags);
1508 set_bit(ASSOC_FLAG_WEP_TX_KEYIDX, &assoc_req->flags);
1510 if (dwrq->flags & IW_ENCODE_RESTRICTED) {
1511 assoc_req->secinfo.auth_mode = IW_AUTH_ALG_SHARED_KEY;
1512 } else if (dwrq->flags & IW_ENCODE_OPEN) {
1513 assoc_req->secinfo.auth_mode = IW_AUTH_ALG_OPEN_SYSTEM;
1518 set_bit(ASSOC_FLAG_SECINFO, &assoc_req->flags);
1519 lbs_postpone_association_work(priv);
1521 lbs_cancel_association_work(priv);
1523 mutex_unlock(&priv->lock);
1525 lbs_deb_leave_args(LBS_DEB_WEXT, "ret %d", ret);
1530 * @brief Get Extended Encryption key (WPA/802.1x and WEP)
1532 * @param dev A pointer to net_device structure
1533 * @param info A pointer to iw_request_info structure
1534 * @param vwrq A pointer to iw_param structure
1535 * @param extra A pointer to extra data buf
1536 * @return 0 on success, otherwise failure
1538 static int lbs_get_encodeext(struct net_device *dev,
1539 struct iw_request_info *info,
1540 struct iw_point *dwrq,
1544 struct lbs_private *priv = dev->ml_priv;
1545 struct iw_encode_ext *ext = (struct iw_encode_ext *)extra;
1546 int index, max_key_len;
1548 lbs_deb_enter(LBS_DEB_WEXT);
1550 max_key_len = dwrq->length - sizeof(*ext);
1551 if (max_key_len < 0)
1554 index = dwrq->flags & IW_ENCODE_INDEX;
1556 if (index < 1 || index > 4)
1560 index = priv->wep_tx_keyidx;
1563 if (!(ext->ext_flags & IW_ENCODE_EXT_GROUP_KEY) &&
1564 ext->alg != IW_ENCODE_ALG_WEP) {
1565 if (index != 0 || priv->mode != IW_MODE_INFRA)
1569 dwrq->flags = index + 1;
1570 memset(ext, 0, sizeof(*ext));
1572 if ( !priv->secinfo.wep_enabled
1573 && !priv->secinfo.WPAenabled
1574 && !priv->secinfo.WPA2enabled) {
1575 ext->alg = IW_ENCODE_ALG_NONE;
1577 dwrq->flags |= IW_ENCODE_DISABLED;
1581 if ( priv->secinfo.wep_enabled
1582 && !priv->secinfo.WPAenabled
1583 && !priv->secinfo.WPA2enabled) {
1585 ext->alg = IW_ENCODE_ALG_WEP;
1586 ext->key_len = priv->wep_keys[index].len;
1587 key = &priv->wep_keys[index].key[0];
1588 } else if ( !priv->secinfo.wep_enabled
1589 && (priv->secinfo.WPAenabled ||
1590 priv->secinfo.WPA2enabled)) {
1592 struct enc_key * pkey = NULL;
1594 if ( priv->wpa_mcast_key.len
1595 && (priv->wpa_mcast_key.flags & KEY_INFO_WPA_ENABLED))
1596 pkey = &priv->wpa_mcast_key;
1597 else if ( priv->wpa_unicast_key.len
1598 && (priv->wpa_unicast_key.flags & KEY_INFO_WPA_ENABLED))
1599 pkey = &priv->wpa_unicast_key;
1602 if (pkey->type == KEY_TYPE_ID_AES) {
1603 ext->alg = IW_ENCODE_ALG_CCMP;
1605 ext->alg = IW_ENCODE_ALG_TKIP;
1607 ext->key_len = pkey->len;
1608 key = &pkey->key[0];
1610 ext->alg = IW_ENCODE_ALG_TKIP;
1617 if (ext->key_len > max_key_len) {
1623 memcpy(ext->key, key, ext->key_len);
1625 dwrq->flags |= IW_ENCODE_NOKEY;
1626 dwrq->flags |= IW_ENCODE_ENABLED;
1631 lbs_deb_leave_args(LBS_DEB_WEXT, "ret %d", ret);
1636 * @brief Set Encryption key Extended (WPA/802.1x and WEP)
1638 * @param dev A pointer to net_device structure
1639 * @param info A pointer to iw_request_info structure
1640 * @param vwrq A pointer to iw_param structure
1641 * @param extra A pointer to extra data buf
1642 * @return 0 --success, otherwise fail
1644 static int lbs_set_encodeext(struct net_device *dev,
1645 struct iw_request_info *info,
1646 struct iw_point *dwrq,
1650 struct lbs_private *priv = dev->ml_priv;
1651 struct iw_encode_ext *ext = (struct iw_encode_ext *)extra;
1653 struct assoc_request * assoc_req;
1655 lbs_deb_enter(LBS_DEB_WEXT);
1657 if (!lbs_is_cmd_allowed(priv)) {
1659 lbs_deb_leave_args(LBS_DEB_WEXT, "ret %d", ret);
1663 mutex_lock(&priv->lock);
1664 assoc_req = lbs_get_association_request(priv);
1670 if ((alg == IW_ENCODE_ALG_NONE) || (dwrq->flags & IW_ENCODE_DISABLED)) {
1671 disable_wep (assoc_req);
1672 disable_wpa (assoc_req);
1673 } else if (alg == IW_ENCODE_ALG_WEP) {
1674 u16 is_default = 0, index, set_tx_key = 0;
1676 ret = validate_key_index(assoc_req->wep_tx_keyidx,
1677 (dwrq->flags & IW_ENCODE_INDEX),
1678 &index, &is_default);
1682 /* If WEP isn't enabled, or if there is no key data but a valid
1683 * index, or if the set-TX-key flag was passed, set the TX key.
1685 if ( !assoc_req->secinfo.wep_enabled
1686 || (dwrq->length == 0 && !is_default)
1687 || (ext->ext_flags & IW_ENCODE_EXT_SET_TX_KEY))
1690 /* Copy key to driver */
1691 ret = lbs_set_wep_key(assoc_req, ext->key, ext->key_len, index,
1696 if (dwrq->flags & IW_ENCODE_RESTRICTED) {
1697 assoc_req->secinfo.auth_mode = IW_AUTH_ALG_SHARED_KEY;
1698 } else if (dwrq->flags & IW_ENCODE_OPEN) {
1699 assoc_req->secinfo.auth_mode = IW_AUTH_ALG_OPEN_SYSTEM;
1702 /* Mark the various WEP bits as modified */
1703 set_bit(ASSOC_FLAG_SECINFO, &assoc_req->flags);
1705 set_bit(ASSOC_FLAG_WEP_KEYS, &assoc_req->flags);
1707 set_bit(ASSOC_FLAG_WEP_TX_KEYIDX, &assoc_req->flags);
1708 } else if ((alg == IW_ENCODE_ALG_TKIP) || (alg == IW_ENCODE_ALG_CCMP)) {
1709 struct enc_key * pkey;
1711 /* validate key length */
1712 if (((alg == IW_ENCODE_ALG_TKIP)
1713 && (ext->key_len != KEY_LEN_WPA_TKIP))
1714 || ((alg == IW_ENCODE_ALG_CCMP)
1715 && (ext->key_len != KEY_LEN_WPA_AES))) {
1716 lbs_deb_wext("invalid size %d for key of alg "
1724 if (ext->ext_flags & IW_ENCODE_EXT_GROUP_KEY) {
1725 pkey = &assoc_req->wpa_mcast_key;
1726 set_bit(ASSOC_FLAG_WPA_MCAST_KEY, &assoc_req->flags);
1728 pkey = &assoc_req->wpa_unicast_key;
1729 set_bit(ASSOC_FLAG_WPA_UCAST_KEY, &assoc_req->flags);
1732 memset(pkey, 0, sizeof (struct enc_key));
1733 memcpy(pkey->key, ext->key, ext->key_len);
1734 pkey->len = ext->key_len;
1736 pkey->flags |= KEY_INFO_WPA_ENABLED;
1738 /* Do this after zeroing key structure */
1739 if (ext->ext_flags & IW_ENCODE_EXT_GROUP_KEY) {
1740 pkey->flags |= KEY_INFO_WPA_MCAST;
1742 pkey->flags |= KEY_INFO_WPA_UNICAST;
1745 if (alg == IW_ENCODE_ALG_TKIP) {
1746 pkey->type = KEY_TYPE_ID_TKIP;
1747 } else if (alg == IW_ENCODE_ALG_CCMP) {
1748 pkey->type = KEY_TYPE_ID_AES;
1751 /* If WPA isn't enabled yet, do that now */
1752 if ( assoc_req->secinfo.WPAenabled == 0
1753 && assoc_req->secinfo.WPA2enabled == 0) {
1754 assoc_req->secinfo.WPAenabled = 1;
1755 assoc_req->secinfo.WPA2enabled = 1;
1756 set_bit(ASSOC_FLAG_SECINFO, &assoc_req->flags);
1759 /* Only disable wep if necessary: can't waste time here. */
1760 if (priv->mac_control & CMD_ACT_MAC_WEP_ENABLE)
1761 disable_wep(assoc_req);
1766 /* 802.1x and WPA rekeying must happen as quickly as possible,
1767 * especially during the 4-way handshake; thus if in
1768 * infrastructure mode, and either (a) 802.1x is enabled or
1769 * (b) WPA is being used, set the key right away.
1771 if (assoc_req->mode == IW_MODE_INFRA &&
1772 ((assoc_req->secinfo.key_mgmt & IW_AUTH_KEY_MGMT_802_1X) ||
1773 (assoc_req->secinfo.key_mgmt & IW_AUTH_KEY_MGMT_PSK) ||
1774 assoc_req->secinfo.WPAenabled ||
1775 assoc_req->secinfo.WPA2enabled)) {
1776 lbs_do_association_work(priv);
1778 lbs_postpone_association_work(priv);
1780 lbs_cancel_association_work(priv);
1782 mutex_unlock(&priv->lock);
1784 lbs_deb_leave_args(LBS_DEB_WEXT, "ret %d", ret);
1789 static int lbs_set_genie(struct net_device *dev,
1790 struct iw_request_info *info,
1791 struct iw_point *dwrq,
1794 struct lbs_private *priv = dev->ml_priv;
1796 struct assoc_request * assoc_req;
1798 lbs_deb_enter(LBS_DEB_WEXT);
1800 mutex_lock(&priv->lock);
1801 assoc_req = lbs_get_association_request(priv);
1807 if (dwrq->length > MAX_WPA_IE_LEN ||
1808 (dwrq->length && extra == NULL)) {
1814 memcpy(&assoc_req->wpa_ie[0], extra, dwrq->length);
1815 assoc_req->wpa_ie_len = dwrq->length;
1817 memset(&assoc_req->wpa_ie[0], 0, sizeof(priv->wpa_ie));
1818 assoc_req->wpa_ie_len = 0;
1823 set_bit(ASSOC_FLAG_WPA_IE, &assoc_req->flags);
1824 lbs_postpone_association_work(priv);
1826 lbs_cancel_association_work(priv);
1828 mutex_unlock(&priv->lock);
1830 lbs_deb_leave_args(LBS_DEB_WEXT, "ret %d", ret);
1834 static int lbs_get_genie(struct net_device *dev,
1835 struct iw_request_info *info,
1836 struct iw_point *dwrq,
1840 struct lbs_private *priv = dev->ml_priv;
1842 lbs_deb_enter(LBS_DEB_WEXT);
1844 if (priv->wpa_ie_len == 0) {
1849 if (dwrq->length < priv->wpa_ie_len) {
1854 dwrq->length = priv->wpa_ie_len;
1855 memcpy(extra, &priv->wpa_ie[0], priv->wpa_ie_len);
1858 lbs_deb_leave_args(LBS_DEB_WEXT, "ret %d", ret);
1863 static int lbs_set_auth(struct net_device *dev,
1864 struct iw_request_info *info,
1865 struct iw_param *dwrq,
1868 struct lbs_private *priv = dev->ml_priv;
1869 struct assoc_request * assoc_req;
1873 lbs_deb_enter(LBS_DEB_WEXT);
1875 if (!lbs_is_cmd_allowed(priv)) {
1877 lbs_deb_leave_args(LBS_DEB_WEXT, "ret %d", ret);
1881 mutex_lock(&priv->lock);
1882 assoc_req = lbs_get_association_request(priv);
1888 switch (dwrq->flags & IW_AUTH_INDEX) {
1889 case IW_AUTH_PRIVACY_INVOKED:
1890 case IW_AUTH_RX_UNENCRYPTED_EAPOL:
1891 case IW_AUTH_TKIP_COUNTERMEASURES:
1892 case IW_AUTH_CIPHER_PAIRWISE:
1893 case IW_AUTH_CIPHER_GROUP:
1894 case IW_AUTH_DROP_UNENCRYPTED:
1896 * libertas does not use these parameters
1900 case IW_AUTH_KEY_MGMT:
1901 assoc_req->secinfo.key_mgmt = dwrq->value;
1905 case IW_AUTH_WPA_VERSION:
1906 if (dwrq->value & IW_AUTH_WPA_VERSION_DISABLED) {
1907 assoc_req->secinfo.WPAenabled = 0;
1908 assoc_req->secinfo.WPA2enabled = 0;
1909 disable_wpa (assoc_req);
1911 if (dwrq->value & IW_AUTH_WPA_VERSION_WPA) {
1912 assoc_req->secinfo.WPAenabled = 1;
1913 assoc_req->secinfo.wep_enabled = 0;
1914 assoc_req->secinfo.auth_mode = IW_AUTH_ALG_OPEN_SYSTEM;
1916 if (dwrq->value & IW_AUTH_WPA_VERSION_WPA2) {
1917 assoc_req->secinfo.WPA2enabled = 1;
1918 assoc_req->secinfo.wep_enabled = 0;
1919 assoc_req->secinfo.auth_mode = IW_AUTH_ALG_OPEN_SYSTEM;
1924 case IW_AUTH_80211_AUTH_ALG:
1925 if (dwrq->value & IW_AUTH_ALG_SHARED_KEY) {
1926 assoc_req->secinfo.auth_mode = IW_AUTH_ALG_SHARED_KEY;
1927 } else if (dwrq->value & IW_AUTH_ALG_OPEN_SYSTEM) {
1928 assoc_req->secinfo.auth_mode = IW_AUTH_ALG_OPEN_SYSTEM;
1929 } else if (dwrq->value & IW_AUTH_ALG_LEAP) {
1930 assoc_req->secinfo.auth_mode = IW_AUTH_ALG_LEAP;
1937 case IW_AUTH_WPA_ENABLED:
1939 if (!assoc_req->secinfo.WPAenabled &&
1940 !assoc_req->secinfo.WPA2enabled) {
1941 assoc_req->secinfo.WPAenabled = 1;
1942 assoc_req->secinfo.WPA2enabled = 1;
1943 assoc_req->secinfo.wep_enabled = 0;
1944 assoc_req->secinfo.auth_mode = IW_AUTH_ALG_OPEN_SYSTEM;
1947 assoc_req->secinfo.WPAenabled = 0;
1948 assoc_req->secinfo.WPA2enabled = 0;
1949 disable_wpa (assoc_req);
1962 set_bit(ASSOC_FLAG_SECINFO, &assoc_req->flags);
1963 lbs_postpone_association_work(priv);
1964 } else if (ret != -EOPNOTSUPP) {
1965 lbs_cancel_association_work(priv);
1967 mutex_unlock(&priv->lock);
1969 lbs_deb_leave_args(LBS_DEB_WEXT, "ret %d", ret);
1973 static int lbs_get_auth(struct net_device *dev,
1974 struct iw_request_info *info,
1975 struct iw_param *dwrq,
1979 struct lbs_private *priv = dev->ml_priv;
1981 lbs_deb_enter(LBS_DEB_WEXT);
1983 if (!lbs_is_cmd_allowed(priv)) {
1985 lbs_deb_leave_args(LBS_DEB_WEXT, "ret %d", ret);
1989 switch (dwrq->flags & IW_AUTH_INDEX) {
1990 case IW_AUTH_KEY_MGMT:
1991 dwrq->value = priv->secinfo.key_mgmt;
1994 case IW_AUTH_WPA_VERSION:
1996 if (priv->secinfo.WPAenabled)
1997 dwrq->value |= IW_AUTH_WPA_VERSION_WPA;
1998 if (priv->secinfo.WPA2enabled)
1999 dwrq->value |= IW_AUTH_WPA_VERSION_WPA2;
2001 dwrq->value |= IW_AUTH_WPA_VERSION_DISABLED;
2004 case IW_AUTH_80211_AUTH_ALG:
2005 dwrq->value = priv->secinfo.auth_mode;
2008 case IW_AUTH_WPA_ENABLED:
2009 if (priv->secinfo.WPAenabled && priv->secinfo.WPA2enabled)
2017 lbs_deb_leave_args(LBS_DEB_WEXT, "ret %d", ret);
2022 static int lbs_set_txpow(struct net_device *dev, struct iw_request_info *info,
2023 struct iw_param *vwrq, char *extra)
2026 struct lbs_private *priv = dev->ml_priv;
2027 s16 dbm = (s16) vwrq->value;
2029 lbs_deb_enter(LBS_DEB_WEXT);
2031 if (!lbs_is_cmd_allowed(priv)) {
2036 if (vwrq->disabled) {
2037 lbs_set_radio(priv, RADIO_PREAMBLE_AUTO, 0);
2041 if (vwrq->fixed == 0) {
2042 /* User requests automatic tx power control, however there are
2043 * many auto tx settings. For now use firmware defaults until
2044 * we come up with a good way to expose these to the user. */
2045 if (priv->fwrelease < 0x09000000) {
2046 ret = lbs_set_power_adapt_cfg(priv, 1,
2047 POW_ADAPT_DEFAULT_P0,
2048 POW_ADAPT_DEFAULT_P1,
2049 POW_ADAPT_DEFAULT_P2);
2053 ret = lbs_set_tpc_cfg(priv, 0, TPC_DEFAULT_P0, TPC_DEFAULT_P1,
2057 dbm = priv->txpower_max;
2059 /* Userspace check in iwrange if it should use dBm or mW,
2060 * therefore this should never happen... Jean II */
2061 if ((vwrq->flags & IW_TXPOW_TYPE) != IW_TXPOW_DBM) {
2066 /* Validate requested power level against firmware allowed
2068 if (priv->txpower_min && (dbm < priv->txpower_min)) {
2073 if (priv->txpower_max && (dbm > priv->txpower_max)) {
2077 if (priv->fwrelease < 0x09000000) {
2078 ret = lbs_set_power_adapt_cfg(priv, 0,
2079 POW_ADAPT_DEFAULT_P0,
2080 POW_ADAPT_DEFAULT_P1,
2081 POW_ADAPT_DEFAULT_P2);
2085 ret = lbs_set_tpc_cfg(priv, 0, TPC_DEFAULT_P0, TPC_DEFAULT_P1,
2091 /* If the radio was off, turn it on */
2092 if (!priv->radio_on) {
2093 ret = lbs_set_radio(priv, RADIO_PREAMBLE_AUTO, 1);
2098 lbs_deb_wext("txpower set %d dBm\n", dbm);
2100 ret = lbs_set_tx_power(priv, dbm);
2103 lbs_deb_leave_args(LBS_DEB_WEXT, "ret %d", ret);
2107 static int lbs_get_essid(struct net_device *dev, struct iw_request_info *info,
2108 struct iw_point *dwrq, char *extra)
2110 struct lbs_private *priv = dev->ml_priv;
2112 lbs_deb_enter(LBS_DEB_WEXT);
2115 * Note : if dwrq->flags != 0, we should get the relevant SSID from
2120 * Get the current SSID
2122 if (priv->connect_status == LBS_CONNECTED) {
2123 memcpy(extra, priv->curbssparams.ssid,
2124 priv->curbssparams.ssid_len);
2125 extra[priv->curbssparams.ssid_len] = '\0';
2127 memset(extra, 0, 32);
2128 extra[priv->curbssparams.ssid_len] = '\0';
2131 * If none, we may want to get the one that was set
2134 dwrq->length = priv->curbssparams.ssid_len;
2136 dwrq->flags = 1; /* active */
2138 lbs_deb_leave(LBS_DEB_WEXT);
2142 static int lbs_set_essid(struct net_device *dev, struct iw_request_info *info,
2143 struct iw_point *dwrq, char *extra)
2145 struct lbs_private *priv = dev->ml_priv;
2147 u8 ssid[IW_ESSID_MAX_SIZE];
2149 struct assoc_request * assoc_req;
2150 int in_ssid_len = dwrq->length;
2151 DECLARE_SSID_BUF(ssid_buf);
2153 lbs_deb_enter(LBS_DEB_WEXT);
2155 if (!lbs_is_cmd_allowed(priv)) {
2157 lbs_deb_leave_args(LBS_DEB_WEXT, "ret %d", ret);
2161 if (!priv->radio_on) {
2166 /* Check the size of the string */
2167 if (in_ssid_len > IW_ESSID_MAX_SIZE) {
2172 memset(&ssid, 0, sizeof(ssid));
2174 if (!dwrq->flags || !in_ssid_len) {
2175 /* "any" SSID requested; leave SSID blank */
2177 /* Specific SSID requested */
2178 memcpy(&ssid, extra, in_ssid_len);
2179 ssid_len = in_ssid_len;
2183 lbs_deb_wext("requested any SSID\n");
2185 lbs_deb_wext("requested SSID '%s'\n",
2186 print_ssid(ssid_buf, ssid, ssid_len));
2190 mutex_lock(&priv->lock);
2192 /* Get or create the current association request */
2193 assoc_req = lbs_get_association_request(priv);
2197 /* Copy the SSID to the association request */
2198 memcpy(&assoc_req->ssid, &ssid, IW_ESSID_MAX_SIZE);
2199 assoc_req->ssid_len = ssid_len;
2200 set_bit(ASSOC_FLAG_SSID, &assoc_req->flags);
2201 lbs_postpone_association_work(priv);
2205 /* Cancel the association request if there was an error */
2207 lbs_cancel_association_work(priv);
2210 mutex_unlock(&priv->lock);
2212 lbs_deb_leave_args(LBS_DEB_WEXT, "ret %d", ret);
2216 static int lbs_mesh_get_essid(struct net_device *dev,
2217 struct iw_request_info *info,
2218 struct iw_point *dwrq, char *extra)
2220 struct lbs_private *priv = dev->ml_priv;
2222 lbs_deb_enter(LBS_DEB_WEXT);
2224 memcpy(extra, priv->mesh_ssid, priv->mesh_ssid_len);
2226 dwrq->length = priv->mesh_ssid_len;
2228 dwrq->flags = 1; /* active */
2230 lbs_deb_leave(LBS_DEB_WEXT);
2234 static int lbs_mesh_set_essid(struct net_device *dev,
2235 struct iw_request_info *info,
2236 struct iw_point *dwrq, char *extra)
2238 struct lbs_private *priv = dev->ml_priv;
2241 lbs_deb_enter(LBS_DEB_WEXT);
2243 if (!priv->radio_on) {
2248 /* Check the size of the string */
2249 if (dwrq->length > IW_ESSID_MAX_SIZE) {
2254 if (!dwrq->flags || !dwrq->length) {
2258 /* Specific SSID requested */
2259 memcpy(priv->mesh_ssid, extra, dwrq->length);
2260 priv->mesh_ssid_len = dwrq->length;
2263 lbs_mesh_config(priv, CMD_ACT_MESH_CONFIG_START,
2264 priv->curbssparams.channel);
2266 lbs_deb_leave_args(LBS_DEB_WEXT, "ret %d", ret);
2271 * @brief Connect to the AP or Ad-hoc Network with specific bssid
2273 * @param dev A pointer to net_device structure
2274 * @param info A pointer to iw_request_info structure
2275 * @param awrq A pointer to iw_param structure
2276 * @param extra A pointer to extra data buf
2277 * @return 0 --success, otherwise fail
2279 static int lbs_set_wap(struct net_device *dev, struct iw_request_info *info,
2280 struct sockaddr *awrq, char *extra)
2282 struct lbs_private *priv = dev->ml_priv;
2283 struct assoc_request * assoc_req;
2286 lbs_deb_enter(LBS_DEB_WEXT);
2288 if (!lbs_is_cmd_allowed(priv)) {
2290 lbs_deb_leave_args(LBS_DEB_WEXT, "ret %d", ret);
2294 if (!priv->radio_on)
2297 if (awrq->sa_family != ARPHRD_ETHER)
2300 lbs_deb_wext("ASSOC: WAP: sa_data %pM\n", awrq->sa_data);
2302 mutex_lock(&priv->lock);
2304 /* Get or create the current association request */
2305 assoc_req = lbs_get_association_request(priv);
2307 lbs_cancel_association_work(priv);
2310 /* Copy the BSSID to the association request */
2311 memcpy(&assoc_req->bssid, awrq->sa_data, ETH_ALEN);
2312 set_bit(ASSOC_FLAG_BSSID, &assoc_req->flags);
2313 lbs_postpone_association_work(priv);
2316 mutex_unlock(&priv->lock);
2322 * iwconfig settable callbacks
2324 static const iw_handler lbs_handler[] = {
2325 (iw_handler) NULL, /* SIOCSIWCOMMIT */
2326 (iw_handler) lbs_get_name, /* SIOCGIWNAME */
2327 (iw_handler) NULL, /* SIOCSIWNWID */
2328 (iw_handler) NULL, /* SIOCGIWNWID */
2329 (iw_handler) lbs_set_freq, /* SIOCSIWFREQ */
2330 (iw_handler) lbs_get_freq, /* SIOCGIWFREQ */
2331 (iw_handler) lbs_set_mode, /* SIOCSIWMODE */
2332 (iw_handler) lbs_get_mode, /* SIOCGIWMODE */
2333 (iw_handler) NULL, /* SIOCSIWSENS */
2334 (iw_handler) NULL, /* SIOCGIWSENS */
2335 (iw_handler) NULL, /* SIOCSIWRANGE */
2336 (iw_handler) lbs_get_range, /* SIOCGIWRANGE */
2337 (iw_handler) NULL, /* SIOCSIWPRIV */
2338 (iw_handler) NULL, /* SIOCGIWPRIV */
2339 (iw_handler) NULL, /* SIOCSIWSTATS */
2340 (iw_handler) NULL, /* SIOCGIWSTATS */
2341 iw_handler_set_spy, /* SIOCSIWSPY */
2342 iw_handler_get_spy, /* SIOCGIWSPY */
2343 iw_handler_set_thrspy, /* SIOCSIWTHRSPY */
2344 iw_handler_get_thrspy, /* SIOCGIWTHRSPY */
2345 (iw_handler) lbs_set_wap, /* SIOCSIWAP */
2346 (iw_handler) lbs_get_wap, /* SIOCGIWAP */
2347 (iw_handler) NULL, /* SIOCSIWMLME */
2348 (iw_handler) NULL, /* SIOCGIWAPLIST - deprecated */
2349 (iw_handler) lbs_set_scan, /* SIOCSIWSCAN */
2350 (iw_handler) lbs_get_scan, /* SIOCGIWSCAN */
2351 (iw_handler) lbs_set_essid, /* SIOCSIWESSID */
2352 (iw_handler) lbs_get_essid, /* SIOCGIWESSID */
2353 (iw_handler) lbs_set_nick, /* SIOCSIWNICKN */
2354 (iw_handler) lbs_get_nick, /* SIOCGIWNICKN */
2355 (iw_handler) NULL, /* -- hole -- */
2356 (iw_handler) NULL, /* -- hole -- */
2357 (iw_handler) lbs_set_rate, /* SIOCSIWRATE */
2358 (iw_handler) lbs_get_rate, /* SIOCGIWRATE */
2359 (iw_handler) lbs_set_rts, /* SIOCSIWRTS */
2360 (iw_handler) lbs_get_rts, /* SIOCGIWRTS */
2361 (iw_handler) lbs_set_frag, /* SIOCSIWFRAG */
2362 (iw_handler) lbs_get_frag, /* SIOCGIWFRAG */
2363 (iw_handler) lbs_set_txpow, /* SIOCSIWTXPOW */
2364 (iw_handler) lbs_get_txpow, /* SIOCGIWTXPOW */
2365 (iw_handler) lbs_set_retry, /* SIOCSIWRETRY */
2366 (iw_handler) lbs_get_retry, /* SIOCGIWRETRY */
2367 (iw_handler) lbs_set_encode, /* SIOCSIWENCODE */
2368 (iw_handler) lbs_get_encode, /* SIOCGIWENCODE */
2369 (iw_handler) lbs_set_power, /* SIOCSIWPOWER */
2370 (iw_handler) lbs_get_power, /* SIOCGIWPOWER */
2371 (iw_handler) NULL, /* -- hole -- */
2372 (iw_handler) NULL, /* -- hole -- */
2373 (iw_handler) lbs_set_genie, /* SIOCSIWGENIE */
2374 (iw_handler) lbs_get_genie, /* SIOCGIWGENIE */
2375 (iw_handler) lbs_set_auth, /* SIOCSIWAUTH */
2376 (iw_handler) lbs_get_auth, /* SIOCGIWAUTH */
2377 (iw_handler) lbs_set_encodeext,/* SIOCSIWENCODEEXT */
2378 (iw_handler) lbs_get_encodeext,/* SIOCGIWENCODEEXT */
2379 (iw_handler) NULL, /* SIOCSIWPMKSA */
2382 static const iw_handler mesh_wlan_handler[] = {
2383 (iw_handler) NULL, /* SIOCSIWCOMMIT */
2384 (iw_handler) lbs_get_name, /* SIOCGIWNAME */
2385 (iw_handler) NULL, /* SIOCSIWNWID */
2386 (iw_handler) NULL, /* SIOCGIWNWID */
2387 (iw_handler) lbs_mesh_set_freq, /* SIOCSIWFREQ */
2388 (iw_handler) lbs_get_freq, /* SIOCGIWFREQ */
2389 (iw_handler) NULL, /* SIOCSIWMODE */
2390 (iw_handler) mesh_wlan_get_mode, /* SIOCGIWMODE */
2391 (iw_handler) NULL, /* SIOCSIWSENS */
2392 (iw_handler) NULL, /* SIOCGIWSENS */
2393 (iw_handler) NULL, /* SIOCSIWRANGE */
2394 (iw_handler) lbs_get_range, /* SIOCGIWRANGE */
2395 (iw_handler) NULL, /* SIOCSIWPRIV */
2396 (iw_handler) NULL, /* SIOCGIWPRIV */
2397 (iw_handler) NULL, /* SIOCSIWSTATS */
2398 (iw_handler) NULL, /* SIOCGIWSTATS */
2399 iw_handler_set_spy, /* SIOCSIWSPY */
2400 iw_handler_get_spy, /* SIOCGIWSPY */
2401 iw_handler_set_thrspy, /* SIOCSIWTHRSPY */
2402 iw_handler_get_thrspy, /* SIOCGIWTHRSPY */
2403 (iw_handler) NULL, /* SIOCSIWAP */
2404 (iw_handler) NULL, /* SIOCGIWAP */
2405 (iw_handler) NULL, /* SIOCSIWMLME */
2406 (iw_handler) NULL, /* SIOCGIWAPLIST - deprecated */
2407 (iw_handler) lbs_set_scan, /* SIOCSIWSCAN */
2408 (iw_handler) lbs_get_scan, /* SIOCGIWSCAN */
2409 (iw_handler) lbs_mesh_set_essid,/* SIOCSIWESSID */
2410 (iw_handler) lbs_mesh_get_essid,/* SIOCGIWESSID */
2411 (iw_handler) NULL, /* SIOCSIWNICKN */
2412 (iw_handler) mesh_get_nick, /* SIOCGIWNICKN */
2413 (iw_handler) NULL, /* -- hole -- */
2414 (iw_handler) NULL, /* -- hole -- */
2415 (iw_handler) lbs_set_rate, /* SIOCSIWRATE */
2416 (iw_handler) lbs_get_rate, /* SIOCGIWRATE */
2417 (iw_handler) lbs_set_rts, /* SIOCSIWRTS */
2418 (iw_handler) lbs_get_rts, /* SIOCGIWRTS */
2419 (iw_handler) lbs_set_frag, /* SIOCSIWFRAG */
2420 (iw_handler) lbs_get_frag, /* SIOCGIWFRAG */
2421 (iw_handler) lbs_set_txpow, /* SIOCSIWTXPOW */
2422 (iw_handler) lbs_get_txpow, /* SIOCGIWTXPOW */
2423 (iw_handler) lbs_set_retry, /* SIOCSIWRETRY */
2424 (iw_handler) lbs_get_retry, /* SIOCGIWRETRY */
2425 (iw_handler) lbs_set_encode, /* SIOCSIWENCODE */
2426 (iw_handler) lbs_get_encode, /* SIOCGIWENCODE */
2427 (iw_handler) lbs_set_power, /* SIOCSIWPOWER */
2428 (iw_handler) lbs_get_power, /* SIOCGIWPOWER */
2429 (iw_handler) NULL, /* -- hole -- */
2430 (iw_handler) NULL, /* -- hole -- */
2431 (iw_handler) lbs_set_genie, /* SIOCSIWGENIE */
2432 (iw_handler) lbs_get_genie, /* SIOCGIWGENIE */
2433 (iw_handler) lbs_set_auth, /* SIOCSIWAUTH */
2434 (iw_handler) lbs_get_auth, /* SIOCGIWAUTH */
2435 (iw_handler) lbs_set_encodeext,/* SIOCSIWENCODEEXT */
2436 (iw_handler) lbs_get_encodeext,/* SIOCGIWENCODEEXT */
2437 (iw_handler) NULL, /* SIOCSIWPMKSA */
2439 struct iw_handler_def lbs_handler_def = {
2440 .num_standard = ARRAY_SIZE(lbs_handler),
2441 .standard = (iw_handler *) lbs_handler,
2442 .get_wireless_stats = lbs_get_wireless_stats,
2445 struct iw_handler_def mesh_handler_def = {
2446 .num_standard = ARRAY_SIZE(mesh_wlan_handler),
2447 .standard = (iw_handler *) mesh_wlan_handler,
2448 .get_wireless_stats = lbs_get_wireless_stats,