Marcelo Tosatti | 876c9d3 | 2007-02-10 12:25:27 -0200 | [diff] [blame] | 1 | /** |
| 2 | * This file contains ioctl functions |
| 3 | */ |
| 4 | #include <linux/ctype.h> |
| 5 | #include <linux/delay.h> |
| 6 | #include <linux/if.h> |
| 7 | #include <linux/if_arp.h> |
| 8 | #include <linux/wireless.h> |
| 9 | #include <linux/bitops.h> |
| 10 | |
| 11 | #include <net/ieee80211.h> |
| 12 | #include <net/iw_handler.h> |
| 13 | |
| 14 | #include "host.h" |
| 15 | #include "radiotap.h" |
| 16 | #include "decl.h" |
| 17 | #include "defs.h" |
| 18 | #include "dev.h" |
Marcelo Tosatti | 876c9d3 | 2007-02-10 12:25:27 -0200 | [diff] [blame] | 19 | #include "wext.h" |
Holger Schurig | 245bf20 | 2008-04-02 16:27:42 +0200 | [diff] [blame] | 20 | #include "scan.h" |
Marcelo Tosatti | 876c9d3 | 2007-02-10 12:25:27 -0200 | [diff] [blame] | 21 | #include "assoc.h" |
Dan Williams | 8e3c91b | 2007-12-11 15:50:59 -0500 | [diff] [blame] | 22 | #include "cmd.h" |
Marcelo Tosatti | 876c9d3 | 2007-02-10 12:25:27 -0200 | [diff] [blame] | 23 | |
| 24 | |
Holger Schurig | 69f9032 | 2007-11-23 15:43:44 +0100 | [diff] [blame] | 25 | static inline void lbs_postpone_association_work(struct lbs_private *priv) |
Holger Schurig | 9f9dac2 | 2007-10-26 10:12:14 +0200 | [diff] [blame] | 26 | { |
David Woodhouse | aa21c00 | 2007-12-08 20:04:36 +0000 | [diff] [blame] | 27 | if (priv->surpriseremoved) |
Holger Schurig | 9f9dac2 | 2007-10-26 10:12:14 +0200 | [diff] [blame] | 28 | return; |
| 29 | cancel_delayed_work(&priv->assoc_work); |
| 30 | queue_delayed_work(priv->work_thread, &priv->assoc_work, HZ / 2); |
| 31 | } |
| 32 | |
Holger Schurig | 69f9032 | 2007-11-23 15:43:44 +0100 | [diff] [blame] | 33 | static inline void lbs_cancel_association_work(struct lbs_private *priv) |
Holger Schurig | 9f9dac2 | 2007-10-26 10:12:14 +0200 | [diff] [blame] | 34 | { |
| 35 | cancel_delayed_work(&priv->assoc_work); |
David Woodhouse | aa21c00 | 2007-12-08 20:04:36 +0000 | [diff] [blame] | 36 | kfree(priv->pending_assoc_req); |
| 37 | priv->pending_assoc_req = NULL; |
Holger Schurig | 9f9dac2 | 2007-10-26 10:12:14 +0200 | [diff] [blame] | 38 | } |
| 39 | |
| 40 | |
Marcelo Tosatti | 876c9d3 | 2007-02-10 12:25:27 -0200 | [diff] [blame] | 41 | /** |
Marcelo Tosatti | 876c9d3 | 2007-02-10 12:25:27 -0200 | [diff] [blame] | 42 | * @brief Find the channel frequency power info with specific channel |
| 43 | * |
David Woodhouse | aa21c00 | 2007-12-08 20:04:36 +0000 | [diff] [blame] | 44 | * @param priv A pointer to struct lbs_private structure |
Marcelo Tosatti | 876c9d3 | 2007-02-10 12:25:27 -0200 | [diff] [blame] | 45 | * @param band it can be BAND_A, BAND_G or BAND_B |
| 46 | * @param channel the channel for looking |
| 47 | * @return A pointer to struct chan_freq_power structure or NULL if not find. |
| 48 | */ |
Holger Schurig | 69f9032 | 2007-11-23 15:43:44 +0100 | [diff] [blame] | 49 | struct chan_freq_power *lbs_find_cfp_by_band_and_channel( |
David Woodhouse | aa21c00 | 2007-12-08 20:04:36 +0000 | [diff] [blame] | 50 | struct lbs_private *priv, |
Holger Schurig | 69f9032 | 2007-11-23 15:43:44 +0100 | [diff] [blame] | 51 | u8 band, |
| 52 | u16 channel) |
Marcelo Tosatti | 876c9d3 | 2007-02-10 12:25:27 -0200 | [diff] [blame] | 53 | { |
| 54 | struct chan_freq_power *cfp = NULL; |
| 55 | struct region_channel *rc; |
Marcelo Tosatti | 876c9d3 | 2007-02-10 12:25:27 -0200 | [diff] [blame] | 56 | int i, j; |
| 57 | |
David Woodhouse | aa21c00 | 2007-12-08 20:04:36 +0000 | [diff] [blame] | 58 | for (j = 0; !cfp && (j < ARRAY_SIZE(priv->region_channel)); j++) { |
| 59 | rc = &priv->region_channel[j]; |
Marcelo Tosatti | 876c9d3 | 2007-02-10 12:25:27 -0200 | [diff] [blame] | 60 | |
David Woodhouse | aa21c00 | 2007-12-08 20:04:36 +0000 | [diff] [blame] | 61 | if (priv->enable11d) |
| 62 | rc = &priv->universal_channel[j]; |
Marcelo Tosatti | 876c9d3 | 2007-02-10 12:25:27 -0200 | [diff] [blame] | 63 | if (!rc->valid || !rc->CFP) |
| 64 | continue; |
| 65 | if (rc->band != band) |
| 66 | continue; |
| 67 | for (i = 0; i < rc->nrcfp; i++) { |
| 68 | if (rc->CFP[i].channel == channel) { |
| 69 | cfp = &rc->CFP[i]; |
| 70 | break; |
| 71 | } |
| 72 | } |
| 73 | } |
| 74 | |
| 75 | if (!cfp && channel) |
Holger Schurig | 1007832 | 2007-11-15 18:05:47 -0500 | [diff] [blame] | 76 | lbs_deb_wext("lbs_find_cfp_by_band_and_channel: can't find " |
Holger Schurig | 9012b28 | 2007-05-25 11:27:16 -0400 | [diff] [blame] | 77 | "cfp by band %d / channel %d\n", band, channel); |
Marcelo Tosatti | 876c9d3 | 2007-02-10 12:25:27 -0200 | [diff] [blame] | 78 | |
| 79 | return cfp; |
| 80 | } |
| 81 | |
| 82 | /** |
| 83 | * @brief Find the channel frequency power info with specific frequency |
| 84 | * |
David Woodhouse | aa21c00 | 2007-12-08 20:04:36 +0000 | [diff] [blame] | 85 | * @param priv A pointer to struct lbs_private structure |
Marcelo Tosatti | 876c9d3 | 2007-02-10 12:25:27 -0200 | [diff] [blame] | 86 | * @param band it can be BAND_A, BAND_G or BAND_B |
| 87 | * @param freq the frequency for looking |
| 88 | * @return A pointer to struct chan_freq_power structure or NULL if not find. |
| 89 | */ |
Holger Schurig | 69f9032 | 2007-11-23 15:43:44 +0100 | [diff] [blame] | 90 | static struct chan_freq_power *find_cfp_by_band_and_freq( |
David Woodhouse | aa21c00 | 2007-12-08 20:04:36 +0000 | [diff] [blame] | 91 | struct lbs_private *priv, |
Holger Schurig | 69f9032 | 2007-11-23 15:43:44 +0100 | [diff] [blame] | 92 | u8 band, |
| 93 | u32 freq) |
Marcelo Tosatti | 876c9d3 | 2007-02-10 12:25:27 -0200 | [diff] [blame] | 94 | { |
| 95 | struct chan_freq_power *cfp = NULL; |
| 96 | struct region_channel *rc; |
Marcelo Tosatti | 876c9d3 | 2007-02-10 12:25:27 -0200 | [diff] [blame] | 97 | int i, j; |
| 98 | |
David Woodhouse | aa21c00 | 2007-12-08 20:04:36 +0000 | [diff] [blame] | 99 | for (j = 0; !cfp && (j < ARRAY_SIZE(priv->region_channel)); j++) { |
| 100 | rc = &priv->region_channel[j]; |
Marcelo Tosatti | 876c9d3 | 2007-02-10 12:25:27 -0200 | [diff] [blame] | 101 | |
David Woodhouse | aa21c00 | 2007-12-08 20:04:36 +0000 | [diff] [blame] | 102 | if (priv->enable11d) |
| 103 | rc = &priv->universal_channel[j]; |
Marcelo Tosatti | 876c9d3 | 2007-02-10 12:25:27 -0200 | [diff] [blame] | 104 | if (!rc->valid || !rc->CFP) |
| 105 | continue; |
| 106 | if (rc->band != band) |
| 107 | continue; |
| 108 | for (i = 0; i < rc->nrcfp; i++) { |
| 109 | if (rc->CFP[i].freq == freq) { |
| 110 | cfp = &rc->CFP[i]; |
| 111 | break; |
| 112 | } |
| 113 | } |
| 114 | } |
| 115 | |
| 116 | if (!cfp && freq) |
Holger Schurig | 9012b28 | 2007-05-25 11:27:16 -0400 | [diff] [blame] | 117 | lbs_deb_wext("find_cfp_by_band_and_freql: can't find cfp by " |
| 118 | "band %d / freq %d\n", band, freq); |
Marcelo Tosatti | 876c9d3 | 2007-02-10 12:25:27 -0200 | [diff] [blame] | 119 | |
| 120 | return cfp; |
| 121 | } |
| 122 | |
Marcelo Tosatti | 876c9d3 | 2007-02-10 12:25:27 -0200 | [diff] [blame] | 123 | /** |
Dan Williams | 8c51276 | 2007-08-02 11:40:45 -0400 | [diff] [blame] | 124 | * @brief Copy active data rates based on adapter mode and status |
Marcelo Tosatti | 876c9d3 | 2007-02-10 12:25:27 -0200 | [diff] [blame] | 125 | * |
David Woodhouse | aa21c00 | 2007-12-08 20:04:36 +0000 | [diff] [blame] | 126 | * @param priv A pointer to struct lbs_private structure |
Marcelo Tosatti | 876c9d3 | 2007-02-10 12:25:27 -0200 | [diff] [blame] | 127 | * @param rate The buf to return the active rates |
Marcelo Tosatti | 876c9d3 | 2007-02-10 12:25:27 -0200 | [diff] [blame] | 128 | */ |
David Woodhouse | aa21c00 | 2007-12-08 20:04:36 +0000 | [diff] [blame] | 129 | static void copy_active_data_rates(struct lbs_private *priv, u8 *rates) |
Marcelo Tosatti | 876c9d3 | 2007-02-10 12:25:27 -0200 | [diff] [blame] | 130 | { |
Holger Schurig | 9012b28 | 2007-05-25 11:27:16 -0400 | [diff] [blame] | 131 | lbs_deb_enter(LBS_DEB_WEXT); |
Marcelo Tosatti | 876c9d3 | 2007-02-10 12:25:27 -0200 | [diff] [blame] | 132 | |
David Woodhouse | aa21c00 | 2007-12-08 20:04:36 +0000 | [diff] [blame] | 133 | if ((priv->connect_status != LBS_CONNECTED) && |
| 134 | (priv->mesh_connect_status != LBS_CONNECTED)) |
Holger Schurig | 1007832 | 2007-11-15 18:05:47 -0500 | [diff] [blame] | 135 | memcpy(rates, lbs_bg_rates, MAX_RATES); |
Dan Williams | 8c51276 | 2007-08-02 11:40:45 -0400 | [diff] [blame] | 136 | else |
David Woodhouse | aa21c00 | 2007-12-08 20:04:36 +0000 | [diff] [blame] | 137 | memcpy(rates, priv->curbssparams.rates, MAX_RATES); |
Marcelo Tosatti | 876c9d3 | 2007-02-10 12:25:27 -0200 | [diff] [blame] | 138 | |
Dan Williams | 8c51276 | 2007-08-02 11:40:45 -0400 | [diff] [blame] | 139 | lbs_deb_leave(LBS_DEB_WEXT); |
Marcelo Tosatti | 876c9d3 | 2007-02-10 12:25:27 -0200 | [diff] [blame] | 140 | } |
| 141 | |
Holger Schurig | 1007832 | 2007-11-15 18:05:47 -0500 | [diff] [blame] | 142 | static int lbs_get_name(struct net_device *dev, struct iw_request_info *info, |
Marcelo Tosatti | 876c9d3 | 2007-02-10 12:25:27 -0200 | [diff] [blame] | 143 | char *cwrq, char *extra) |
| 144 | { |
Marcelo Tosatti | 876c9d3 | 2007-02-10 12:25:27 -0200 | [diff] [blame] | 145 | |
Holger Schurig | 9012b28 | 2007-05-25 11:27:16 -0400 | [diff] [blame] | 146 | lbs_deb_enter(LBS_DEB_WEXT); |
Marcelo Tosatti | 876c9d3 | 2007-02-10 12:25:27 -0200 | [diff] [blame] | 147 | |
Jean Tourrilhes | 9483f03 | 2007-08-02 13:16:30 -0400 | [diff] [blame] | 148 | /* We could add support for 802.11n here as needed. Jean II */ |
| 149 | snprintf(cwrq, IFNAMSIZ, "IEEE 802.11b/g"); |
Marcelo Tosatti | 876c9d3 | 2007-02-10 12:25:27 -0200 | [diff] [blame] | 150 | |
Holger Schurig | 9012b28 | 2007-05-25 11:27:16 -0400 | [diff] [blame] | 151 | lbs_deb_leave(LBS_DEB_WEXT); |
Marcelo Tosatti | 876c9d3 | 2007-02-10 12:25:27 -0200 | [diff] [blame] | 152 | return 0; |
| 153 | } |
| 154 | |
Holger Schurig | 1007832 | 2007-11-15 18:05:47 -0500 | [diff] [blame] | 155 | static int lbs_get_freq(struct net_device *dev, struct iw_request_info *info, |
Marcelo Tosatti | 876c9d3 | 2007-02-10 12:25:27 -0200 | [diff] [blame] | 156 | struct iw_freq *fwrq, char *extra) |
| 157 | { |
Holger Schurig | 69f9032 | 2007-11-23 15:43:44 +0100 | [diff] [blame] | 158 | struct lbs_private *priv = dev->priv; |
Marcelo Tosatti | 876c9d3 | 2007-02-10 12:25:27 -0200 | [diff] [blame] | 159 | struct chan_freq_power *cfp; |
| 160 | |
Holger Schurig | 9012b28 | 2007-05-25 11:27:16 -0400 | [diff] [blame] | 161 | lbs_deb_enter(LBS_DEB_WEXT); |
Marcelo Tosatti | 876c9d3 | 2007-02-10 12:25:27 -0200 | [diff] [blame] | 162 | |
David Woodhouse | aa21c00 | 2007-12-08 20:04:36 +0000 | [diff] [blame] | 163 | cfp = lbs_find_cfp_by_band_and_channel(priv, 0, |
| 164 | priv->curbssparams.channel); |
Marcelo Tosatti | 876c9d3 | 2007-02-10 12:25:27 -0200 | [diff] [blame] | 165 | |
| 166 | if (!cfp) { |
David Woodhouse | aa21c00 | 2007-12-08 20:04:36 +0000 | [diff] [blame] | 167 | if (priv->curbssparams.channel) |
Holger Schurig | 9012b28 | 2007-05-25 11:27:16 -0400 | [diff] [blame] | 168 | lbs_deb_wext("invalid channel %d\n", |
David Woodhouse | aa21c00 | 2007-12-08 20:04:36 +0000 | [diff] [blame] | 169 | priv->curbssparams.channel); |
Marcelo Tosatti | 876c9d3 | 2007-02-10 12:25:27 -0200 | [diff] [blame] | 170 | return -EINVAL; |
| 171 | } |
| 172 | |
| 173 | fwrq->m = (long)cfp->freq * 100000; |
| 174 | fwrq->e = 1; |
| 175 | |
Holger Schurig | 9012b28 | 2007-05-25 11:27:16 -0400 | [diff] [blame] | 176 | lbs_deb_wext("freq %u\n", fwrq->m); |
| 177 | lbs_deb_leave(LBS_DEB_WEXT); |
Marcelo Tosatti | 876c9d3 | 2007-02-10 12:25:27 -0200 | [diff] [blame] | 178 | return 0; |
| 179 | } |
| 180 | |
Holger Schurig | 1007832 | 2007-11-15 18:05:47 -0500 | [diff] [blame] | 181 | static int lbs_get_wap(struct net_device *dev, struct iw_request_info *info, |
Marcelo Tosatti | 876c9d3 | 2007-02-10 12:25:27 -0200 | [diff] [blame] | 182 | struct sockaddr *awrq, char *extra) |
| 183 | { |
Holger Schurig | 69f9032 | 2007-11-23 15:43:44 +0100 | [diff] [blame] | 184 | struct lbs_private *priv = dev->priv; |
Marcelo Tosatti | 876c9d3 | 2007-02-10 12:25:27 -0200 | [diff] [blame] | 185 | |
Holger Schurig | 9012b28 | 2007-05-25 11:27:16 -0400 | [diff] [blame] | 186 | lbs_deb_enter(LBS_DEB_WEXT); |
Marcelo Tosatti | 876c9d3 | 2007-02-10 12:25:27 -0200 | [diff] [blame] | 187 | |
David Woodhouse | aa21c00 | 2007-12-08 20:04:36 +0000 | [diff] [blame] | 188 | if (priv->connect_status == LBS_CONNECTED) { |
| 189 | memcpy(awrq->sa_data, priv->curbssparams.bssid, ETH_ALEN); |
Marcelo Tosatti | 876c9d3 | 2007-02-10 12:25:27 -0200 | [diff] [blame] | 190 | } else { |
| 191 | memset(awrq->sa_data, 0, ETH_ALEN); |
| 192 | } |
| 193 | awrq->sa_family = ARPHRD_ETHER; |
| 194 | |
Holger Schurig | 9012b28 | 2007-05-25 11:27:16 -0400 | [diff] [blame] | 195 | lbs_deb_leave(LBS_DEB_WEXT); |
Marcelo Tosatti | 876c9d3 | 2007-02-10 12:25:27 -0200 | [diff] [blame] | 196 | return 0; |
| 197 | } |
| 198 | |
Holger Schurig | 1007832 | 2007-11-15 18:05:47 -0500 | [diff] [blame] | 199 | static int lbs_set_nick(struct net_device *dev, struct iw_request_info *info, |
Marcelo Tosatti | 876c9d3 | 2007-02-10 12:25:27 -0200 | [diff] [blame] | 200 | struct iw_point *dwrq, char *extra) |
| 201 | { |
Holger Schurig | 69f9032 | 2007-11-23 15:43:44 +0100 | [diff] [blame] | 202 | struct lbs_private *priv = dev->priv; |
Marcelo Tosatti | 876c9d3 | 2007-02-10 12:25:27 -0200 | [diff] [blame] | 203 | |
Holger Schurig | 9012b28 | 2007-05-25 11:27:16 -0400 | [diff] [blame] | 204 | lbs_deb_enter(LBS_DEB_WEXT); |
Marcelo Tosatti | 876c9d3 | 2007-02-10 12:25:27 -0200 | [diff] [blame] | 205 | |
| 206 | /* |
| 207 | * Check the size of the string |
| 208 | */ |
| 209 | |
| 210 | if (dwrq->length > 16) { |
| 211 | return -E2BIG; |
| 212 | } |
| 213 | |
David Woodhouse | aa21c00 | 2007-12-08 20:04:36 +0000 | [diff] [blame] | 214 | mutex_lock(&priv->lock); |
| 215 | memset(priv->nodename, 0, sizeof(priv->nodename)); |
| 216 | memcpy(priv->nodename, extra, dwrq->length); |
| 217 | mutex_unlock(&priv->lock); |
Marcelo Tosatti | 876c9d3 | 2007-02-10 12:25:27 -0200 | [diff] [blame] | 218 | |
Holger Schurig | 9012b28 | 2007-05-25 11:27:16 -0400 | [diff] [blame] | 219 | lbs_deb_leave(LBS_DEB_WEXT); |
Marcelo Tosatti | 876c9d3 | 2007-02-10 12:25:27 -0200 | [diff] [blame] | 220 | return 0; |
| 221 | } |
| 222 | |
Holger Schurig | 1007832 | 2007-11-15 18:05:47 -0500 | [diff] [blame] | 223 | static int lbs_get_nick(struct net_device *dev, struct iw_request_info *info, |
Marcelo Tosatti | 876c9d3 | 2007-02-10 12:25:27 -0200 | [diff] [blame] | 224 | struct iw_point *dwrq, char *extra) |
| 225 | { |
Holger Schurig | 69f9032 | 2007-11-23 15:43:44 +0100 | [diff] [blame] | 226 | struct lbs_private *priv = dev->priv; |
Marcelo Tosatti | 876c9d3 | 2007-02-10 12:25:27 -0200 | [diff] [blame] | 227 | |
Holger Schurig | 9012b28 | 2007-05-25 11:27:16 -0400 | [diff] [blame] | 228 | lbs_deb_enter(LBS_DEB_WEXT); |
Marcelo Tosatti | 876c9d3 | 2007-02-10 12:25:27 -0200 | [diff] [blame] | 229 | |
David Woodhouse | aa21c00 | 2007-12-08 20:04:36 +0000 | [diff] [blame] | 230 | dwrq->length = strlen(priv->nodename); |
| 231 | memcpy(extra, priv->nodename, dwrq->length); |
Holger Schurig | 04799fa | 2007-10-09 15:04:14 +0200 | [diff] [blame] | 232 | extra[dwrq->length] = '\0'; |
Marcelo Tosatti | 876c9d3 | 2007-02-10 12:25:27 -0200 | [diff] [blame] | 233 | |
Holger Schurig | 04799fa | 2007-10-09 15:04:14 +0200 | [diff] [blame] | 234 | dwrq->flags = 1; /* active */ |
Marcelo Tosatti | 876c9d3 | 2007-02-10 12:25:27 -0200 | [diff] [blame] | 235 | |
Holger Schurig | 9012b28 | 2007-05-25 11:27:16 -0400 | [diff] [blame] | 236 | lbs_deb_leave(LBS_DEB_WEXT); |
Marcelo Tosatti | 876c9d3 | 2007-02-10 12:25:27 -0200 | [diff] [blame] | 237 | return 0; |
| 238 | } |
| 239 | |
Luis Carlos Cobo Rus | f5e05b6 | 2007-05-25 23:08:34 -0400 | [diff] [blame] | 240 | static int mesh_get_nick(struct net_device *dev, struct iw_request_info *info, |
| 241 | struct iw_point *dwrq, char *extra) |
| 242 | { |
Holger Schurig | 69f9032 | 2007-11-23 15:43:44 +0100 | [diff] [blame] | 243 | struct lbs_private *priv = dev->priv; |
Luis Carlos Cobo Rus | f5e05b6 | 2007-05-25 23:08:34 -0400 | [diff] [blame] | 244 | |
| 245 | lbs_deb_enter(LBS_DEB_WEXT); |
| 246 | |
| 247 | /* Use nickname to indicate that mesh is on */ |
| 248 | |
David Woodhouse | aa21c00 | 2007-12-08 20:04:36 +0000 | [diff] [blame] | 249 | if (priv->mesh_connect_status == LBS_CONNECTED) { |
Luis Carlos Cobo Rus | f5e05b6 | 2007-05-25 23:08:34 -0400 | [diff] [blame] | 250 | strncpy(extra, "Mesh", 12); |
| 251 | extra[12] = '\0'; |
Jean Tourrilhes | 9483f03 | 2007-08-02 13:16:30 -0400 | [diff] [blame] | 252 | dwrq->length = strlen(extra); |
Luis Carlos Cobo Rus | f5e05b6 | 2007-05-25 23:08:34 -0400 | [diff] [blame] | 253 | } |
| 254 | |
| 255 | else { |
| 256 | extra[0] = '\0'; |
Jean Tourrilhes | 9483f03 | 2007-08-02 13:16:30 -0400 | [diff] [blame] | 257 | dwrq->length = 0; |
Luis Carlos Cobo Rus | f5e05b6 | 2007-05-25 23:08:34 -0400 | [diff] [blame] | 258 | } |
| 259 | |
| 260 | lbs_deb_leave(LBS_DEB_WEXT); |
| 261 | return 0; |
| 262 | } |
Holger Schurig | 04799fa | 2007-10-09 15:04:14 +0200 | [diff] [blame] | 263 | |
Holger Schurig | 1007832 | 2007-11-15 18:05:47 -0500 | [diff] [blame] | 264 | static int lbs_set_rts(struct net_device *dev, struct iw_request_info *info, |
Marcelo Tosatti | 876c9d3 | 2007-02-10 12:25:27 -0200 | [diff] [blame] | 265 | struct iw_param *vwrq, char *extra) |
| 266 | { |
| 267 | int ret = 0; |
Holger Schurig | 69f9032 | 2007-11-23 15:43:44 +0100 | [diff] [blame] | 268 | struct lbs_private *priv = dev->priv; |
David Woodhouse | 981f187 | 2007-05-25 23:36:54 -0400 | [diff] [blame] | 269 | u32 rthr = vwrq->value; |
Marcelo Tosatti | 876c9d3 | 2007-02-10 12:25:27 -0200 | [diff] [blame] | 270 | |
Holger Schurig | 9012b28 | 2007-05-25 11:27:16 -0400 | [diff] [blame] | 271 | lbs_deb_enter(LBS_DEB_WEXT); |
Marcelo Tosatti | 876c9d3 | 2007-02-10 12:25:27 -0200 | [diff] [blame] | 272 | |
| 273 | if (vwrq->disabled) { |
David Woodhouse | aa21c00 | 2007-12-08 20:04:36 +0000 | [diff] [blame] | 274 | priv->rtsthsd = rthr = MRVDRV_RTS_MAX_VALUE; |
Marcelo Tosatti | 876c9d3 | 2007-02-10 12:25:27 -0200 | [diff] [blame] | 275 | } else { |
| 276 | if (rthr < MRVDRV_RTS_MIN_VALUE || rthr > MRVDRV_RTS_MAX_VALUE) |
| 277 | return -EINVAL; |
David Woodhouse | aa21c00 | 2007-12-08 20:04:36 +0000 | [diff] [blame] | 278 | priv->rtsthsd = rthr; |
Marcelo Tosatti | 876c9d3 | 2007-02-10 12:25:27 -0200 | [diff] [blame] | 279 | } |
| 280 | |
Holger Schurig | 1007832 | 2007-11-15 18:05:47 -0500 | [diff] [blame] | 281 | ret = lbs_prepare_and_send_command(priv, CMD_802_11_SNMP_MIB, |
Dan Williams | 0aef64d | 2007-08-02 11:31:18 -0400 | [diff] [blame] | 282 | CMD_ACT_SET, CMD_OPTION_WAITFORRSP, |
Marcelo Tosatti | 876c9d3 | 2007-02-10 12:25:27 -0200 | [diff] [blame] | 283 | OID_802_11_RTS_THRESHOLD, &rthr); |
| 284 | |
Holger Schurig | 9012b28 | 2007-05-25 11:27:16 -0400 | [diff] [blame] | 285 | lbs_deb_leave_args(LBS_DEB_WEXT, "ret %d", ret); |
Marcelo Tosatti | 876c9d3 | 2007-02-10 12:25:27 -0200 | [diff] [blame] | 286 | return ret; |
| 287 | } |
| 288 | |
Holger Schurig | 1007832 | 2007-11-15 18:05:47 -0500 | [diff] [blame] | 289 | static int lbs_get_rts(struct net_device *dev, struct iw_request_info *info, |
Marcelo Tosatti | 876c9d3 | 2007-02-10 12:25:27 -0200 | [diff] [blame] | 290 | struct iw_param *vwrq, char *extra) |
| 291 | { |
| 292 | int ret = 0; |
Holger Schurig | 69f9032 | 2007-11-23 15:43:44 +0100 | [diff] [blame] | 293 | struct lbs_private *priv = dev->priv; |
Marcelo Tosatti | 876c9d3 | 2007-02-10 12:25:27 -0200 | [diff] [blame] | 294 | |
Holger Schurig | 9012b28 | 2007-05-25 11:27:16 -0400 | [diff] [blame] | 295 | lbs_deb_enter(LBS_DEB_WEXT); |
Marcelo Tosatti | 876c9d3 | 2007-02-10 12:25:27 -0200 | [diff] [blame] | 296 | |
David Woodhouse | aa21c00 | 2007-12-08 20:04:36 +0000 | [diff] [blame] | 297 | priv->rtsthsd = 0; |
Holger Schurig | 1007832 | 2007-11-15 18:05:47 -0500 | [diff] [blame] | 298 | ret = lbs_prepare_and_send_command(priv, CMD_802_11_SNMP_MIB, |
Dan Williams | 0aef64d | 2007-08-02 11:31:18 -0400 | [diff] [blame] | 299 | CMD_ACT_GET, CMD_OPTION_WAITFORRSP, |
Marcelo Tosatti | 876c9d3 | 2007-02-10 12:25:27 -0200 | [diff] [blame] | 300 | OID_802_11_RTS_THRESHOLD, NULL); |
Holger Schurig | 9012b28 | 2007-05-25 11:27:16 -0400 | [diff] [blame] | 301 | if (ret) |
| 302 | goto out; |
Marcelo Tosatti | 876c9d3 | 2007-02-10 12:25:27 -0200 | [diff] [blame] | 303 | |
David Woodhouse | aa21c00 | 2007-12-08 20:04:36 +0000 | [diff] [blame] | 304 | vwrq->value = priv->rtsthsd; |
Marcelo Tosatti | 876c9d3 | 2007-02-10 12:25:27 -0200 | [diff] [blame] | 305 | vwrq->disabled = ((vwrq->value < MRVDRV_RTS_MIN_VALUE) |
| 306 | || (vwrq->value > MRVDRV_RTS_MAX_VALUE)); |
| 307 | vwrq->fixed = 1; |
| 308 | |
Holger Schurig | 9012b28 | 2007-05-25 11:27:16 -0400 | [diff] [blame] | 309 | out: |
| 310 | lbs_deb_leave_args(LBS_DEB_WEXT, "ret %d", ret); |
| 311 | return ret; |
Marcelo Tosatti | 876c9d3 | 2007-02-10 12:25:27 -0200 | [diff] [blame] | 312 | } |
| 313 | |
Holger Schurig | 1007832 | 2007-11-15 18:05:47 -0500 | [diff] [blame] | 314 | static int lbs_set_frag(struct net_device *dev, struct iw_request_info *info, |
Marcelo Tosatti | 876c9d3 | 2007-02-10 12:25:27 -0200 | [diff] [blame] | 315 | struct iw_param *vwrq, char *extra) |
| 316 | { |
| 317 | int ret = 0; |
David Woodhouse | 981f187 | 2007-05-25 23:36:54 -0400 | [diff] [blame] | 318 | u32 fthr = vwrq->value; |
Holger Schurig | 69f9032 | 2007-11-23 15:43:44 +0100 | [diff] [blame] | 319 | struct lbs_private *priv = dev->priv; |
Marcelo Tosatti | 876c9d3 | 2007-02-10 12:25:27 -0200 | [diff] [blame] | 320 | |
Holger Schurig | 9012b28 | 2007-05-25 11:27:16 -0400 | [diff] [blame] | 321 | lbs_deb_enter(LBS_DEB_WEXT); |
Marcelo Tosatti | 876c9d3 | 2007-02-10 12:25:27 -0200 | [diff] [blame] | 322 | |
| 323 | if (vwrq->disabled) { |
David Woodhouse | aa21c00 | 2007-12-08 20:04:36 +0000 | [diff] [blame] | 324 | priv->fragthsd = fthr = MRVDRV_FRAG_MAX_VALUE; |
Marcelo Tosatti | 876c9d3 | 2007-02-10 12:25:27 -0200 | [diff] [blame] | 325 | } else { |
| 326 | if (fthr < MRVDRV_FRAG_MIN_VALUE |
| 327 | || fthr > MRVDRV_FRAG_MAX_VALUE) |
| 328 | return -EINVAL; |
David Woodhouse | aa21c00 | 2007-12-08 20:04:36 +0000 | [diff] [blame] | 329 | priv->fragthsd = fthr; |
Marcelo Tosatti | 876c9d3 | 2007-02-10 12:25:27 -0200 | [diff] [blame] | 330 | } |
| 331 | |
Holger Schurig | 1007832 | 2007-11-15 18:05:47 -0500 | [diff] [blame] | 332 | ret = lbs_prepare_and_send_command(priv, CMD_802_11_SNMP_MIB, |
Dan Williams | 0aef64d | 2007-08-02 11:31:18 -0400 | [diff] [blame] | 333 | CMD_ACT_SET, CMD_OPTION_WAITFORRSP, |
Marcelo Tosatti | 876c9d3 | 2007-02-10 12:25:27 -0200 | [diff] [blame] | 334 | OID_802_11_FRAGMENTATION_THRESHOLD, &fthr); |
Holger Schurig | 9012b28 | 2007-05-25 11:27:16 -0400 | [diff] [blame] | 335 | |
| 336 | lbs_deb_leave_args(LBS_DEB_WEXT, "ret %d", ret); |
Marcelo Tosatti | 876c9d3 | 2007-02-10 12:25:27 -0200 | [diff] [blame] | 337 | return ret; |
| 338 | } |
| 339 | |
Holger Schurig | 1007832 | 2007-11-15 18:05:47 -0500 | [diff] [blame] | 340 | static int lbs_get_frag(struct net_device *dev, struct iw_request_info *info, |
Marcelo Tosatti | 876c9d3 | 2007-02-10 12:25:27 -0200 | [diff] [blame] | 341 | struct iw_param *vwrq, char *extra) |
| 342 | { |
| 343 | int ret = 0; |
Holger Schurig | 69f9032 | 2007-11-23 15:43:44 +0100 | [diff] [blame] | 344 | struct lbs_private *priv = dev->priv; |
Marcelo Tosatti | 876c9d3 | 2007-02-10 12:25:27 -0200 | [diff] [blame] | 345 | |
Holger Schurig | 9012b28 | 2007-05-25 11:27:16 -0400 | [diff] [blame] | 346 | lbs_deb_enter(LBS_DEB_WEXT); |
Marcelo Tosatti | 876c9d3 | 2007-02-10 12:25:27 -0200 | [diff] [blame] | 347 | |
David Woodhouse | aa21c00 | 2007-12-08 20:04:36 +0000 | [diff] [blame] | 348 | priv->fragthsd = 0; |
Holger Schurig | 1007832 | 2007-11-15 18:05:47 -0500 | [diff] [blame] | 349 | ret = lbs_prepare_and_send_command(priv, |
Dan Williams | 0aef64d | 2007-08-02 11:31:18 -0400 | [diff] [blame] | 350 | CMD_802_11_SNMP_MIB, |
| 351 | CMD_ACT_GET, CMD_OPTION_WAITFORRSP, |
Marcelo Tosatti | 876c9d3 | 2007-02-10 12:25:27 -0200 | [diff] [blame] | 352 | OID_802_11_FRAGMENTATION_THRESHOLD, NULL); |
Holger Schurig | 9012b28 | 2007-05-25 11:27:16 -0400 | [diff] [blame] | 353 | if (ret) |
| 354 | goto out; |
Marcelo Tosatti | 876c9d3 | 2007-02-10 12:25:27 -0200 | [diff] [blame] | 355 | |
David Woodhouse | aa21c00 | 2007-12-08 20:04:36 +0000 | [diff] [blame] | 356 | vwrq->value = priv->fragthsd; |
Marcelo Tosatti | 876c9d3 | 2007-02-10 12:25:27 -0200 | [diff] [blame] | 357 | vwrq->disabled = ((vwrq->value < MRVDRV_FRAG_MIN_VALUE) |
| 358 | || (vwrq->value > MRVDRV_FRAG_MAX_VALUE)); |
| 359 | vwrq->fixed = 1; |
| 360 | |
Holger Schurig | 9012b28 | 2007-05-25 11:27:16 -0400 | [diff] [blame] | 361 | out: |
| 362 | lbs_deb_leave_args(LBS_DEB_WEXT, "ret %d", ret); |
Marcelo Tosatti | 876c9d3 | 2007-02-10 12:25:27 -0200 | [diff] [blame] | 363 | return ret; |
| 364 | } |
| 365 | |
Holger Schurig | 1007832 | 2007-11-15 18:05:47 -0500 | [diff] [blame] | 366 | static int lbs_get_mode(struct net_device *dev, |
Marcelo Tosatti | 876c9d3 | 2007-02-10 12:25:27 -0200 | [diff] [blame] | 367 | struct iw_request_info *info, u32 * uwrq, char *extra) |
| 368 | { |
Holger Schurig | 69f9032 | 2007-11-23 15:43:44 +0100 | [diff] [blame] | 369 | struct lbs_private *priv = dev->priv; |
Marcelo Tosatti | 876c9d3 | 2007-02-10 12:25:27 -0200 | [diff] [blame] | 370 | |
Holger Schurig | 9012b28 | 2007-05-25 11:27:16 -0400 | [diff] [blame] | 371 | lbs_deb_enter(LBS_DEB_WEXT); |
Marcelo Tosatti | 876c9d3 | 2007-02-10 12:25:27 -0200 | [diff] [blame] | 372 | |
David Woodhouse | aa21c00 | 2007-12-08 20:04:36 +0000 | [diff] [blame] | 373 | *uwrq = priv->mode; |
Marcelo Tosatti | 876c9d3 | 2007-02-10 12:25:27 -0200 | [diff] [blame] | 374 | |
Holger Schurig | 9012b28 | 2007-05-25 11:27:16 -0400 | [diff] [blame] | 375 | lbs_deb_leave(LBS_DEB_WEXT); |
Marcelo Tosatti | 876c9d3 | 2007-02-10 12:25:27 -0200 | [diff] [blame] | 376 | return 0; |
| 377 | } |
| 378 | |
Luis Carlos Cobo Rus | f5e05b6 | 2007-05-25 23:08:34 -0400 | [diff] [blame] | 379 | static int mesh_wlan_get_mode(struct net_device *dev, |
| 380 | struct iw_request_info *info, u32 * uwrq, |
| 381 | char *extra) |
| 382 | { |
| 383 | lbs_deb_enter(LBS_DEB_WEXT); |
| 384 | |
| 385 | *uwrq = IW_MODE_REPEAT ; |
| 386 | |
| 387 | lbs_deb_leave(LBS_DEB_WEXT); |
| 388 | return 0; |
| 389 | } |
| 390 | |
Holger Schurig | 1007832 | 2007-11-15 18:05:47 -0500 | [diff] [blame] | 391 | static int lbs_get_txpow(struct net_device *dev, |
Marcelo Tosatti | 876c9d3 | 2007-02-10 12:25:27 -0200 | [diff] [blame] | 392 | struct iw_request_info *info, |
| 393 | struct iw_param *vwrq, char *extra) |
| 394 | { |
Holger Schurig | 69f9032 | 2007-11-23 15:43:44 +0100 | [diff] [blame] | 395 | struct lbs_private *priv = dev->priv; |
Dan Williams | 87c8c72 | 2008-08-19 15:15:35 -0400 | [diff] [blame] | 396 | s16 curlevel = 0; |
Dan Williams | d5db2df | 2008-08-21 17:51:07 -0400 | [diff] [blame^] | 397 | int ret = 0; |
Marcelo Tosatti | 876c9d3 | 2007-02-10 12:25:27 -0200 | [diff] [blame] | 398 | |
Holger Schurig | 9012b28 | 2007-05-25 11:27:16 -0400 | [diff] [blame] | 399 | lbs_deb_enter(LBS_DEB_WEXT); |
Marcelo Tosatti | 876c9d3 | 2007-02-10 12:25:27 -0200 | [diff] [blame] | 400 | |
Dan Williams | d5db2df | 2008-08-21 17:51:07 -0400 | [diff] [blame^] | 401 | if (!priv->radio_on) { |
| 402 | lbs_deb_wext("tx power off\n"); |
| 403 | vwrq->value = 0; |
| 404 | vwrq->disabled = 1; |
| 405 | goto out; |
| 406 | } |
| 407 | |
Dan Williams | 87c8c72 | 2008-08-19 15:15:35 -0400 | [diff] [blame] | 408 | ret = lbs_get_tx_power(priv, &curlevel, NULL, NULL); |
Holger Schurig | 9012b28 | 2007-05-25 11:27:16 -0400 | [diff] [blame] | 409 | if (ret) |
| 410 | goto out; |
Marcelo Tosatti | 876c9d3 | 2007-02-10 12:25:27 -0200 | [diff] [blame] | 411 | |
Dan Williams | 87c8c72 | 2008-08-19 15:15:35 -0400 | [diff] [blame] | 412 | lbs_deb_wext("tx power level %d dbm\n", curlevel); |
Dan Williams | 87c8c72 | 2008-08-19 15:15:35 -0400 | [diff] [blame] | 413 | priv->txpower_cur = curlevel; |
Dan Williams | d5db2df | 2008-08-21 17:51:07 -0400 | [diff] [blame^] | 414 | |
Dan Williams | 87c8c72 | 2008-08-19 15:15:35 -0400 | [diff] [blame] | 415 | vwrq->value = curlevel; |
Marcelo Tosatti | 876c9d3 | 2007-02-10 12:25:27 -0200 | [diff] [blame] | 416 | vwrq->fixed = 1; |
Dan Williams | d5db2df | 2008-08-21 17:51:07 -0400 | [diff] [blame^] | 417 | vwrq->disabled = 0; |
| 418 | vwrq->flags = IW_TXPOW_DBM; |
Marcelo Tosatti | 876c9d3 | 2007-02-10 12:25:27 -0200 | [diff] [blame] | 419 | |
Holger Schurig | 9012b28 | 2007-05-25 11:27:16 -0400 | [diff] [blame] | 420 | out: |
| 421 | lbs_deb_leave_args(LBS_DEB_WEXT, "ret %d", ret); |
| 422 | return ret; |
Marcelo Tosatti | 876c9d3 | 2007-02-10 12:25:27 -0200 | [diff] [blame] | 423 | } |
| 424 | |
Holger Schurig | 1007832 | 2007-11-15 18:05:47 -0500 | [diff] [blame] | 425 | static int lbs_set_retry(struct net_device *dev, struct iw_request_info *info, |
Marcelo Tosatti | 876c9d3 | 2007-02-10 12:25:27 -0200 | [diff] [blame] | 426 | struct iw_param *vwrq, char *extra) |
| 427 | { |
| 428 | int ret = 0; |
Holger Schurig | 69f9032 | 2007-11-23 15:43:44 +0100 | [diff] [blame] | 429 | struct lbs_private *priv = dev->priv; |
Marcelo Tosatti | 876c9d3 | 2007-02-10 12:25:27 -0200 | [diff] [blame] | 430 | |
Holger Schurig | 9012b28 | 2007-05-25 11:27:16 -0400 | [diff] [blame] | 431 | lbs_deb_enter(LBS_DEB_WEXT); |
Marcelo Tosatti | 876c9d3 | 2007-02-10 12:25:27 -0200 | [diff] [blame] | 432 | |
| 433 | if (vwrq->flags == IW_RETRY_LIMIT) { |
| 434 | /* The MAC has a 4-bit Total_Tx_Count register |
| 435 | Total_Tx_Count = 1 + Tx_Retry_Count */ |
| 436 | #define TX_RETRY_MIN 0 |
| 437 | #define TX_RETRY_MAX 14 |
| 438 | if (vwrq->value < TX_RETRY_MIN || vwrq->value > TX_RETRY_MAX) |
| 439 | return -EINVAL; |
| 440 | |
| 441 | /* Adding 1 to convert retry count to try count */ |
David Woodhouse | aa21c00 | 2007-12-08 20:04:36 +0000 | [diff] [blame] | 442 | priv->txretrycount = vwrq->value + 1; |
Marcelo Tosatti | 876c9d3 | 2007-02-10 12:25:27 -0200 | [diff] [blame] | 443 | |
Holger Schurig | 1007832 | 2007-11-15 18:05:47 -0500 | [diff] [blame] | 444 | ret = lbs_prepare_and_send_command(priv, CMD_802_11_SNMP_MIB, |
Dan Williams | 0aef64d | 2007-08-02 11:31:18 -0400 | [diff] [blame] | 445 | CMD_ACT_SET, |
| 446 | CMD_OPTION_WAITFORRSP, |
Marcelo Tosatti | 876c9d3 | 2007-02-10 12:25:27 -0200 | [diff] [blame] | 447 | OID_802_11_TX_RETRYCOUNT, NULL); |
| 448 | |
Holger Schurig | 9012b28 | 2007-05-25 11:27:16 -0400 | [diff] [blame] | 449 | if (ret) |
| 450 | goto out; |
Marcelo Tosatti | 876c9d3 | 2007-02-10 12:25:27 -0200 | [diff] [blame] | 451 | } else { |
| 452 | return -EOPNOTSUPP; |
| 453 | } |
| 454 | |
Holger Schurig | 9012b28 | 2007-05-25 11:27:16 -0400 | [diff] [blame] | 455 | out: |
| 456 | lbs_deb_leave_args(LBS_DEB_WEXT, "ret %d", ret); |
| 457 | return ret; |
Marcelo Tosatti | 876c9d3 | 2007-02-10 12:25:27 -0200 | [diff] [blame] | 458 | } |
| 459 | |
Holger Schurig | 1007832 | 2007-11-15 18:05:47 -0500 | [diff] [blame] | 460 | static int lbs_get_retry(struct net_device *dev, struct iw_request_info *info, |
Marcelo Tosatti | 876c9d3 | 2007-02-10 12:25:27 -0200 | [diff] [blame] | 461 | struct iw_param *vwrq, char *extra) |
| 462 | { |
Holger Schurig | 69f9032 | 2007-11-23 15:43:44 +0100 | [diff] [blame] | 463 | struct lbs_private *priv = dev->priv; |
Marcelo Tosatti | 876c9d3 | 2007-02-10 12:25:27 -0200 | [diff] [blame] | 464 | int ret = 0; |
| 465 | |
Holger Schurig | 9012b28 | 2007-05-25 11:27:16 -0400 | [diff] [blame] | 466 | lbs_deb_enter(LBS_DEB_WEXT); |
| 467 | |
David Woodhouse | aa21c00 | 2007-12-08 20:04:36 +0000 | [diff] [blame] | 468 | priv->txretrycount = 0; |
Holger Schurig | 1007832 | 2007-11-15 18:05:47 -0500 | [diff] [blame] | 469 | ret = lbs_prepare_and_send_command(priv, |
Dan Williams | 0aef64d | 2007-08-02 11:31:18 -0400 | [diff] [blame] | 470 | CMD_802_11_SNMP_MIB, |
| 471 | CMD_ACT_GET, CMD_OPTION_WAITFORRSP, |
Marcelo Tosatti | 876c9d3 | 2007-02-10 12:25:27 -0200 | [diff] [blame] | 472 | OID_802_11_TX_RETRYCOUNT, NULL); |
Holger Schurig | 9012b28 | 2007-05-25 11:27:16 -0400 | [diff] [blame] | 473 | if (ret) |
| 474 | goto out; |
| 475 | |
Marcelo Tosatti | 876c9d3 | 2007-02-10 12:25:27 -0200 | [diff] [blame] | 476 | vwrq->disabled = 0; |
| 477 | if (!vwrq->flags) { |
| 478 | vwrq->flags = IW_RETRY_LIMIT; |
| 479 | /* Subtract 1 to convert try count to retry count */ |
David Woodhouse | aa21c00 | 2007-12-08 20:04:36 +0000 | [diff] [blame] | 480 | vwrq->value = priv->txretrycount - 1; |
Marcelo Tosatti | 876c9d3 | 2007-02-10 12:25:27 -0200 | [diff] [blame] | 481 | } |
| 482 | |
Holger Schurig | 9012b28 | 2007-05-25 11:27:16 -0400 | [diff] [blame] | 483 | out: |
| 484 | lbs_deb_leave_args(LBS_DEB_WEXT, "ret %d", ret); |
| 485 | return ret; |
Marcelo Tosatti | 876c9d3 | 2007-02-10 12:25:27 -0200 | [diff] [blame] | 486 | } |
| 487 | |
| 488 | static inline void sort_channels(struct iw_freq *freq, int num) |
| 489 | { |
| 490 | int i, j; |
| 491 | struct iw_freq temp; |
| 492 | |
| 493 | for (i = 0; i < num; i++) |
| 494 | for (j = i + 1; j < num; j++) |
| 495 | if (freq[i].i > freq[j].i) { |
| 496 | temp.i = freq[i].i; |
| 497 | temp.m = freq[i].m; |
| 498 | |
| 499 | freq[i].i = freq[j].i; |
| 500 | freq[i].m = freq[j].m; |
| 501 | |
| 502 | freq[j].i = temp.i; |
| 503 | freq[j].m = temp.m; |
| 504 | } |
| 505 | } |
| 506 | |
| 507 | /* data rate listing |
| 508 | MULTI_BANDS: |
| 509 | abg a b b/g |
| 510 | Infra G(12) A(8) B(4) G(12) |
| 511 | Adhoc A+B(12) A(8) B(4) B(4) |
| 512 | |
| 513 | non-MULTI_BANDS: |
| 514 | b b/g |
| 515 | Infra B(4) G(12) |
| 516 | Adhoc B(4) B(4) |
| 517 | */ |
| 518 | /** |
| 519 | * @brief Get Range Info |
| 520 | * |
| 521 | * @param dev A pointer to net_device structure |
| 522 | * @param info A pointer to iw_request_info structure |
| 523 | * @param vwrq A pointer to iw_param structure |
| 524 | * @param extra A pointer to extra data buf |
| 525 | * @return 0 --success, otherwise fail |
| 526 | */ |
Holger Schurig | 1007832 | 2007-11-15 18:05:47 -0500 | [diff] [blame] | 527 | static int lbs_get_range(struct net_device *dev, struct iw_request_info *info, |
Marcelo Tosatti | 876c9d3 | 2007-02-10 12:25:27 -0200 | [diff] [blame] | 528 | struct iw_point *dwrq, char *extra) |
| 529 | { |
| 530 | int i, j; |
Holger Schurig | 69f9032 | 2007-11-23 15:43:44 +0100 | [diff] [blame] | 531 | struct lbs_private *priv = dev->priv; |
Marcelo Tosatti | 876c9d3 | 2007-02-10 12:25:27 -0200 | [diff] [blame] | 532 | struct iw_range *range = (struct iw_range *)extra; |
| 533 | struct chan_freq_power *cfp; |
Dan Williams | 8c51276 | 2007-08-02 11:40:45 -0400 | [diff] [blame] | 534 | u8 rates[MAX_RATES + 1]; |
Marcelo Tosatti | 876c9d3 | 2007-02-10 12:25:27 -0200 | [diff] [blame] | 535 | |
| 536 | u8 flag = 0; |
| 537 | |
Holger Schurig | 9012b28 | 2007-05-25 11:27:16 -0400 | [diff] [blame] | 538 | lbs_deb_enter(LBS_DEB_WEXT); |
Marcelo Tosatti | 876c9d3 | 2007-02-10 12:25:27 -0200 | [diff] [blame] | 539 | |
| 540 | dwrq->length = sizeof(struct iw_range); |
| 541 | memset(range, 0, sizeof(struct iw_range)); |
| 542 | |
| 543 | range->min_nwid = 0; |
| 544 | range->max_nwid = 0; |
| 545 | |
| 546 | memset(rates, 0, sizeof(rates)); |
David Woodhouse | aa21c00 | 2007-12-08 20:04:36 +0000 | [diff] [blame] | 547 | copy_active_data_rates(priv, rates); |
Dan Williams | 8c51276 | 2007-08-02 11:40:45 -0400 | [diff] [blame] | 548 | range->num_bitrates = strnlen(rates, IW_MAX_BITRATES); |
| 549 | for (i = 0; i < range->num_bitrates; i++) |
| 550 | range->bitrate[i] = rates[i] * 500000; |
Marcelo Tosatti | 876c9d3 | 2007-02-10 12:25:27 -0200 | [diff] [blame] | 551 | range->num_bitrates = i; |
Holger Schurig | 9012b28 | 2007-05-25 11:27:16 -0400 | [diff] [blame] | 552 | lbs_deb_wext("IW_MAX_BITRATES %d, num_bitrates %d\n", IW_MAX_BITRATES, |
Marcelo Tosatti | 876c9d3 | 2007-02-10 12:25:27 -0200 | [diff] [blame] | 553 | range->num_bitrates); |
| 554 | |
| 555 | range->num_frequency = 0; |
Holger Schurig | 52933d8 | 2008-03-05 07:05:32 +0100 | [diff] [blame] | 556 | |
| 557 | range->scan_capa = IW_SCAN_CAPA_ESSID; |
| 558 | |
David Woodhouse | aa21c00 | 2007-12-08 20:04:36 +0000 | [diff] [blame] | 559 | if (priv->enable11d && |
| 560 | (priv->connect_status == LBS_CONNECTED || |
| 561 | priv->mesh_connect_status == LBS_CONNECTED)) { |
Marcelo Tosatti | 876c9d3 | 2007-02-10 12:25:27 -0200 | [diff] [blame] | 562 | u8 chan_no; |
| 563 | u8 band; |
| 564 | |
| 565 | struct parsed_region_chan_11d *parsed_region_chan = |
David Woodhouse | aa21c00 | 2007-12-08 20:04:36 +0000 | [diff] [blame] | 566 | &priv->parsed_region_chan; |
Marcelo Tosatti | 876c9d3 | 2007-02-10 12:25:27 -0200 | [diff] [blame] | 567 | |
| 568 | if (parsed_region_chan == NULL) { |
Holger Schurig | 9012b28 | 2007-05-25 11:27:16 -0400 | [diff] [blame] | 569 | lbs_deb_wext("11d: parsed_region_chan is NULL\n"); |
| 570 | goto out; |
Marcelo Tosatti | 876c9d3 | 2007-02-10 12:25:27 -0200 | [diff] [blame] | 571 | } |
| 572 | band = parsed_region_chan->band; |
Holger Schurig | 9012b28 | 2007-05-25 11:27:16 -0400 | [diff] [blame] | 573 | lbs_deb_wext("band %d, nr_char %d\n", band, |
Marcelo Tosatti | 876c9d3 | 2007-02-10 12:25:27 -0200 | [diff] [blame] | 574 | parsed_region_chan->nr_chan); |
| 575 | |
| 576 | for (i = 0; (range->num_frequency < IW_MAX_FREQUENCIES) |
| 577 | && (i < parsed_region_chan->nr_chan); i++) { |
| 578 | chan_no = parsed_region_chan->chanpwr[i].chan; |
Holger Schurig | 9012b28 | 2007-05-25 11:27:16 -0400 | [diff] [blame] | 579 | lbs_deb_wext("chan_no %d\n", chan_no); |
Marcelo Tosatti | 876c9d3 | 2007-02-10 12:25:27 -0200 | [diff] [blame] | 580 | range->freq[range->num_frequency].i = (long)chan_no; |
| 581 | range->freq[range->num_frequency].m = |
Holger Schurig | e98a88d | 2008-03-19 14:25:58 +0100 | [diff] [blame] | 582 | (long)lbs_chan_2_freq(chan_no) * 100000; |
Marcelo Tosatti | 876c9d3 | 2007-02-10 12:25:27 -0200 | [diff] [blame] | 583 | range->freq[range->num_frequency].e = 1; |
| 584 | range->num_frequency++; |
| 585 | } |
| 586 | flag = 1; |
| 587 | } |
| 588 | if (!flag) { |
| 589 | for (j = 0; (range->num_frequency < IW_MAX_FREQUENCIES) |
David Woodhouse | aa21c00 | 2007-12-08 20:04:36 +0000 | [diff] [blame] | 590 | && (j < ARRAY_SIZE(priv->region_channel)); j++) { |
| 591 | cfp = priv->region_channel[j].CFP; |
Marcelo Tosatti | 876c9d3 | 2007-02-10 12:25:27 -0200 | [diff] [blame] | 592 | for (i = 0; (range->num_frequency < IW_MAX_FREQUENCIES) |
David Woodhouse | aa21c00 | 2007-12-08 20:04:36 +0000 | [diff] [blame] | 593 | && priv->region_channel[j].valid |
Marcelo Tosatti | 876c9d3 | 2007-02-10 12:25:27 -0200 | [diff] [blame] | 594 | && cfp |
David Woodhouse | aa21c00 | 2007-12-08 20:04:36 +0000 | [diff] [blame] | 595 | && (i < priv->region_channel[j].nrcfp); i++) { |
Marcelo Tosatti | 876c9d3 | 2007-02-10 12:25:27 -0200 | [diff] [blame] | 596 | range->freq[range->num_frequency].i = |
| 597 | (long)cfp->channel; |
| 598 | range->freq[range->num_frequency].m = |
| 599 | (long)cfp->freq * 100000; |
| 600 | range->freq[range->num_frequency].e = 1; |
| 601 | cfp++; |
| 602 | range->num_frequency++; |
| 603 | } |
| 604 | } |
| 605 | } |
| 606 | |
Holger Schurig | 9012b28 | 2007-05-25 11:27:16 -0400 | [diff] [blame] | 607 | lbs_deb_wext("IW_MAX_FREQUENCIES %d, num_frequency %d\n", |
Marcelo Tosatti | 876c9d3 | 2007-02-10 12:25:27 -0200 | [diff] [blame] | 608 | IW_MAX_FREQUENCIES, range->num_frequency); |
| 609 | |
| 610 | range->num_channels = range->num_frequency; |
| 611 | |
| 612 | sort_channels(&range->freq[0], range->num_frequency); |
| 613 | |
| 614 | /* |
| 615 | * Set an indication of the max TCP throughput in bit/s that we can |
| 616 | * expect using this interface |
| 617 | */ |
| 618 | if (i > 2) |
| 619 | range->throughput = 5000 * 1000; |
| 620 | else |
| 621 | range->throughput = 1500 * 1000; |
| 622 | |
| 623 | range->min_rts = MRVDRV_RTS_MIN_VALUE; |
| 624 | range->max_rts = MRVDRV_RTS_MAX_VALUE; |
| 625 | range->min_frag = MRVDRV_FRAG_MIN_VALUE; |
| 626 | range->max_frag = MRVDRV_FRAG_MAX_VALUE; |
| 627 | |
| 628 | range->encoding_size[0] = 5; |
| 629 | range->encoding_size[1] = 13; |
| 630 | range->num_encoding_sizes = 2; |
| 631 | range->max_encoding_tokens = 4; |
| 632 | |
Holger Schurig | d4ff0ef | 2008-03-19 14:25:18 +0100 | [diff] [blame] | 633 | /* |
| 634 | * Right now we support only "iwconfig ethX power on|off" |
| 635 | */ |
| 636 | range->pm_capa = IW_POWER_ON; |
Marcelo Tosatti | 876c9d3 | 2007-02-10 12:25:27 -0200 | [diff] [blame] | 637 | |
| 638 | /* |
| 639 | * Minimum version we recommend |
| 640 | */ |
| 641 | range->we_version_source = 15; |
| 642 | |
| 643 | /* |
| 644 | * Version we are compiled with |
| 645 | */ |
| 646 | range->we_version_compiled = WIRELESS_EXT; |
| 647 | |
| 648 | range->retry_capa = IW_RETRY_LIMIT; |
| 649 | range->retry_flags = IW_RETRY_LIMIT | IW_RETRY_MAX; |
| 650 | |
| 651 | range->min_retry = TX_RETRY_MIN; |
| 652 | range->max_retry = TX_RETRY_MAX; |
| 653 | |
| 654 | /* |
| 655 | * Set the qual, level and noise range values |
| 656 | */ |
| 657 | range->max_qual.qual = 100; |
| 658 | range->max_qual.level = 0; |
| 659 | range->max_qual.noise = 0; |
| 660 | range->max_qual.updated = IW_QUAL_ALL_UPDATED | IW_QUAL_DBM; |
| 661 | |
| 662 | range->avg_qual.qual = 70; |
| 663 | /* TODO: Find real 'good' to 'bad' threshold value for RSSI */ |
| 664 | range->avg_qual.level = 0; |
| 665 | range->avg_qual.noise = 0; |
| 666 | range->avg_qual.updated = IW_QUAL_ALL_UPDATED | IW_QUAL_DBM; |
| 667 | |
| 668 | range->sensitivity = 0; |
| 669 | |
Dan Williams | 87c8c72 | 2008-08-19 15:15:35 -0400 | [diff] [blame] | 670 | /* Setup the supported power level ranges */ |
Marcelo Tosatti | 876c9d3 | 2007-02-10 12:25:27 -0200 | [diff] [blame] | 671 | memset(range->txpower, 0, sizeof(range->txpower)); |
Dan Williams | 87c8c72 | 2008-08-19 15:15:35 -0400 | [diff] [blame] | 672 | range->txpower_capa = IW_TXPOW_DBM | IW_TXPOW_RANGE; |
| 673 | range->txpower[0] = priv->txpower_min; |
| 674 | range->txpower[1] = priv->txpower_max; |
| 675 | range->num_txpower = 2; |
Marcelo Tosatti | 876c9d3 | 2007-02-10 12:25:27 -0200 | [diff] [blame] | 676 | |
| 677 | range->event_capa[0] = (IW_EVENT_CAPA_K_0 | |
| 678 | IW_EVENT_CAPA_MASK(SIOCGIWAP) | |
| 679 | IW_EVENT_CAPA_MASK(SIOCGIWSCAN)); |
| 680 | range->event_capa[1] = IW_EVENT_CAPA_K_1; |
| 681 | |
David Woodhouse | aa21c00 | 2007-12-08 20:04:36 +0000 | [diff] [blame] | 682 | if (priv->fwcapinfo & FW_CAPINFO_WPA) { |
Marcelo Tosatti | 876c9d3 | 2007-02-10 12:25:27 -0200 | [diff] [blame] | 683 | range->enc_capa = IW_ENC_CAPA_WPA |
| 684 | | IW_ENC_CAPA_WPA2 |
| 685 | | IW_ENC_CAPA_CIPHER_TKIP |
| 686 | | IW_ENC_CAPA_CIPHER_CCMP; |
| 687 | } |
| 688 | |
Holger Schurig | 9012b28 | 2007-05-25 11:27:16 -0400 | [diff] [blame] | 689 | out: |
| 690 | lbs_deb_leave(LBS_DEB_WEXT); |
Marcelo Tosatti | 876c9d3 | 2007-02-10 12:25:27 -0200 | [diff] [blame] | 691 | return 0; |
| 692 | } |
| 693 | |
Holger Schurig | 1007832 | 2007-11-15 18:05:47 -0500 | [diff] [blame] | 694 | static int lbs_set_power(struct net_device *dev, struct iw_request_info *info, |
Marcelo Tosatti | 876c9d3 | 2007-02-10 12:25:27 -0200 | [diff] [blame] | 695 | struct iw_param *vwrq, char *extra) |
| 696 | { |
Holger Schurig | 69f9032 | 2007-11-23 15:43:44 +0100 | [diff] [blame] | 697 | struct lbs_private *priv = dev->priv; |
Marcelo Tosatti | 876c9d3 | 2007-02-10 12:25:27 -0200 | [diff] [blame] | 698 | |
Holger Schurig | 9012b28 | 2007-05-25 11:27:16 -0400 | [diff] [blame] | 699 | lbs_deb_enter(LBS_DEB_WEXT); |
Marcelo Tosatti | 876c9d3 | 2007-02-10 12:25:27 -0200 | [diff] [blame] | 700 | |
David Woodhouse | b2c57ee | 2007-12-17 14:41:13 -0500 | [diff] [blame] | 701 | if (!priv->ps_supported) { |
| 702 | if (vwrq->disabled) |
| 703 | return 0; |
| 704 | else |
| 705 | return -EINVAL; |
| 706 | } |
| 707 | |
Marcelo Tosatti | 876c9d3 | 2007-02-10 12:25:27 -0200 | [diff] [blame] | 708 | /* PS is currently supported only in Infrastructure mode |
| 709 | * Remove this check if it is to be supported in IBSS mode also |
| 710 | */ |
| 711 | |
| 712 | if (vwrq->disabled) { |
David Woodhouse | aa21c00 | 2007-12-08 20:04:36 +0000 | [diff] [blame] | 713 | priv->psmode = LBS802_11POWERMODECAM; |
| 714 | if (priv->psstate != PS_STATE_FULL_POWER) { |
Holger Schurig | 1007832 | 2007-11-15 18:05:47 -0500 | [diff] [blame] | 715 | lbs_ps_wakeup(priv, CMD_OPTION_WAITFORRSP); |
Marcelo Tosatti | 876c9d3 | 2007-02-10 12:25:27 -0200 | [diff] [blame] | 716 | } |
| 717 | |
| 718 | return 0; |
| 719 | } |
| 720 | |
| 721 | if ((vwrq->flags & IW_POWER_TYPE) == IW_POWER_TIMEOUT) { |
Holger Schurig | 9012b28 | 2007-05-25 11:27:16 -0400 | [diff] [blame] | 722 | lbs_deb_wext( |
| 723 | "setting power timeout is not supported\n"); |
Marcelo Tosatti | 876c9d3 | 2007-02-10 12:25:27 -0200 | [diff] [blame] | 724 | return -EINVAL; |
| 725 | } else if ((vwrq->flags & IW_POWER_TYPE) == IW_POWER_PERIOD) { |
Holger Schurig | 9012b28 | 2007-05-25 11:27:16 -0400 | [diff] [blame] | 726 | lbs_deb_wext("setting power period not supported\n"); |
Marcelo Tosatti | 876c9d3 | 2007-02-10 12:25:27 -0200 | [diff] [blame] | 727 | return -EINVAL; |
| 728 | } |
| 729 | |
David Woodhouse | aa21c00 | 2007-12-08 20:04:36 +0000 | [diff] [blame] | 730 | if (priv->psmode != LBS802_11POWERMODECAM) { |
Marcelo Tosatti | 876c9d3 | 2007-02-10 12:25:27 -0200 | [diff] [blame] | 731 | return 0; |
| 732 | } |
| 733 | |
David Woodhouse | aa21c00 | 2007-12-08 20:04:36 +0000 | [diff] [blame] | 734 | priv->psmode = LBS802_11POWERMODEMAX_PSP; |
Marcelo Tosatti | 876c9d3 | 2007-02-10 12:25:27 -0200 | [diff] [blame] | 735 | |
David Woodhouse | aa21c00 | 2007-12-08 20:04:36 +0000 | [diff] [blame] | 736 | if (priv->connect_status == LBS_CONNECTED) { |
Holger Schurig | 1007832 | 2007-11-15 18:05:47 -0500 | [diff] [blame] | 737 | lbs_ps_sleep(priv, CMD_OPTION_WAITFORRSP); |
Marcelo Tosatti | 876c9d3 | 2007-02-10 12:25:27 -0200 | [diff] [blame] | 738 | } |
| 739 | |
Holger Schurig | 9012b28 | 2007-05-25 11:27:16 -0400 | [diff] [blame] | 740 | lbs_deb_leave(LBS_DEB_WEXT); |
Marcelo Tosatti | 876c9d3 | 2007-02-10 12:25:27 -0200 | [diff] [blame] | 741 | return 0; |
| 742 | } |
| 743 | |
Holger Schurig | 1007832 | 2007-11-15 18:05:47 -0500 | [diff] [blame] | 744 | static int lbs_get_power(struct net_device *dev, struct iw_request_info *info, |
Marcelo Tosatti | 876c9d3 | 2007-02-10 12:25:27 -0200 | [diff] [blame] | 745 | struct iw_param *vwrq, char *extra) |
| 746 | { |
Holger Schurig | 69f9032 | 2007-11-23 15:43:44 +0100 | [diff] [blame] | 747 | struct lbs_private *priv = dev->priv; |
Marcelo Tosatti | 876c9d3 | 2007-02-10 12:25:27 -0200 | [diff] [blame] | 748 | |
Holger Schurig | 9012b28 | 2007-05-25 11:27:16 -0400 | [diff] [blame] | 749 | lbs_deb_enter(LBS_DEB_WEXT); |
Marcelo Tosatti | 876c9d3 | 2007-02-10 12:25:27 -0200 | [diff] [blame] | 750 | |
Marcelo Tosatti | 876c9d3 | 2007-02-10 12:25:27 -0200 | [diff] [blame] | 751 | vwrq->value = 0; |
Holger Schurig | d4ff0ef | 2008-03-19 14:25:18 +0100 | [diff] [blame] | 752 | vwrq->flags = 0; |
| 753 | vwrq->disabled = priv->psmode == LBS802_11POWERMODECAM |
| 754 | || priv->connect_status == LBS_DISCONNECTED; |
Marcelo Tosatti | 876c9d3 | 2007-02-10 12:25:27 -0200 | [diff] [blame] | 755 | |
Holger Schurig | 9012b28 | 2007-05-25 11:27:16 -0400 | [diff] [blame] | 756 | lbs_deb_leave(LBS_DEB_WEXT); |
Marcelo Tosatti | 876c9d3 | 2007-02-10 12:25:27 -0200 | [diff] [blame] | 757 | return 0; |
| 758 | } |
| 759 | |
Holger Schurig | 1007832 | 2007-11-15 18:05:47 -0500 | [diff] [blame] | 760 | static struct iw_statistics *lbs_get_wireless_stats(struct net_device *dev) |
Marcelo Tosatti | 876c9d3 | 2007-02-10 12:25:27 -0200 | [diff] [blame] | 761 | { |
| 762 | enum { |
| 763 | POOR = 30, |
| 764 | FAIR = 60, |
| 765 | GOOD = 80, |
| 766 | VERY_GOOD = 90, |
| 767 | EXCELLENT = 95, |
| 768 | PERFECT = 100 |
| 769 | }; |
Holger Schurig | 69f9032 | 2007-11-23 15:43:44 +0100 | [diff] [blame] | 770 | struct lbs_private *priv = dev->priv; |
Marcelo Tosatti | 876c9d3 | 2007-02-10 12:25:27 -0200 | [diff] [blame] | 771 | u32 rssi_qual; |
| 772 | u32 tx_qual; |
| 773 | u32 quality = 0; |
| 774 | int stats_valid = 0; |
| 775 | u8 rssi; |
| 776 | u32 tx_retries; |
Holger Schurig | c49c3b7 | 2008-03-17 12:45:58 +0100 | [diff] [blame] | 777 | struct cmd_ds_802_11_get_log log; |
Marcelo Tosatti | 876c9d3 | 2007-02-10 12:25:27 -0200 | [diff] [blame] | 778 | |
Holger Schurig | 9012b28 | 2007-05-25 11:27:16 -0400 | [diff] [blame] | 779 | lbs_deb_enter(LBS_DEB_WEXT); |
Marcelo Tosatti | 876c9d3 | 2007-02-10 12:25:27 -0200 | [diff] [blame] | 780 | |
David Woodhouse | aa21c00 | 2007-12-08 20:04:36 +0000 | [diff] [blame] | 781 | priv->wstats.status = priv->mode; |
Marcelo Tosatti | 876c9d3 | 2007-02-10 12:25:27 -0200 | [diff] [blame] | 782 | |
| 783 | /* If we're not associated, all quality values are meaningless */ |
David Woodhouse | aa21c00 | 2007-12-08 20:04:36 +0000 | [diff] [blame] | 784 | if ((priv->connect_status != LBS_CONNECTED) && |
| 785 | (priv->mesh_connect_status != LBS_CONNECTED)) |
Marcelo Tosatti | 876c9d3 | 2007-02-10 12:25:27 -0200 | [diff] [blame] | 786 | goto out; |
| 787 | |
| 788 | /* Quality by RSSI */ |
| 789 | priv->wstats.qual.level = |
David Woodhouse | aa21c00 | 2007-12-08 20:04:36 +0000 | [diff] [blame] | 790 | CAL_RSSI(priv->SNR[TYPE_BEACON][TYPE_NOAVG], |
| 791 | priv->NF[TYPE_BEACON][TYPE_NOAVG]); |
Marcelo Tosatti | 876c9d3 | 2007-02-10 12:25:27 -0200 | [diff] [blame] | 792 | |
David Woodhouse | aa21c00 | 2007-12-08 20:04:36 +0000 | [diff] [blame] | 793 | if (priv->NF[TYPE_BEACON][TYPE_NOAVG] == 0) { |
Marcelo Tosatti | 876c9d3 | 2007-02-10 12:25:27 -0200 | [diff] [blame] | 794 | priv->wstats.qual.noise = MRVDRV_NF_DEFAULT_SCAN_VALUE; |
| 795 | } else { |
| 796 | priv->wstats.qual.noise = |
David Woodhouse | aa21c00 | 2007-12-08 20:04:36 +0000 | [diff] [blame] | 797 | CAL_NF(priv->NF[TYPE_BEACON][TYPE_NOAVG]); |
Marcelo Tosatti | 876c9d3 | 2007-02-10 12:25:27 -0200 | [diff] [blame] | 798 | } |
| 799 | |
Holger Schurig | 9012b28 | 2007-05-25 11:27:16 -0400 | [diff] [blame] | 800 | lbs_deb_wext("signal level %#x\n", priv->wstats.qual.level); |
| 801 | lbs_deb_wext("noise %#x\n", priv->wstats.qual.noise); |
Marcelo Tosatti | 876c9d3 | 2007-02-10 12:25:27 -0200 | [diff] [blame] | 802 | |
| 803 | rssi = priv->wstats.qual.level - priv->wstats.qual.noise; |
| 804 | if (rssi < 15) |
| 805 | rssi_qual = rssi * POOR / 10; |
| 806 | else if (rssi < 20) |
| 807 | rssi_qual = (rssi - 15) * (FAIR - POOR) / 5 + POOR; |
| 808 | else if (rssi < 30) |
| 809 | rssi_qual = (rssi - 20) * (GOOD - FAIR) / 5 + FAIR; |
| 810 | else if (rssi < 40) |
| 811 | rssi_qual = (rssi - 30) * (VERY_GOOD - GOOD) / |
| 812 | 10 + GOOD; |
| 813 | else |
| 814 | rssi_qual = (rssi - 40) * (PERFECT - VERY_GOOD) / |
| 815 | 10 + VERY_GOOD; |
| 816 | quality = rssi_qual; |
| 817 | |
| 818 | /* Quality by TX errors */ |
| 819 | priv->wstats.discard.retries = priv->stats.tx_errors; |
| 820 | |
Holger Schurig | c49c3b7 | 2008-03-17 12:45:58 +0100 | [diff] [blame] | 821 | memset(&log, 0, sizeof(log)); |
| 822 | log.hdr.size = cpu_to_le16(sizeof(log)); |
| 823 | lbs_cmd_with_response(priv, CMD_802_11_GET_LOG, &log); |
| 824 | |
| 825 | tx_retries = le32_to_cpu(log.retry); |
Marcelo Tosatti | 876c9d3 | 2007-02-10 12:25:27 -0200 | [diff] [blame] | 826 | |
| 827 | if (tx_retries > 75) |
| 828 | tx_qual = (90 - tx_retries) * POOR / 15; |
| 829 | else if (tx_retries > 70) |
| 830 | tx_qual = (75 - tx_retries) * (FAIR - POOR) / 5 + POOR; |
| 831 | else if (tx_retries > 65) |
| 832 | tx_qual = (70 - tx_retries) * (GOOD - FAIR) / 5 + FAIR; |
| 833 | else if (tx_retries > 50) |
| 834 | tx_qual = (65 - tx_retries) * (VERY_GOOD - GOOD) / |
| 835 | 15 + GOOD; |
| 836 | else |
| 837 | tx_qual = (50 - tx_retries) * |
| 838 | (PERFECT - VERY_GOOD) / 50 + VERY_GOOD; |
| 839 | quality = min(quality, tx_qual); |
| 840 | |
Holger Schurig | c49c3b7 | 2008-03-17 12:45:58 +0100 | [diff] [blame] | 841 | priv->wstats.discard.code = le32_to_cpu(log.wepundecryptable); |
Marcelo Tosatti | 876c9d3 | 2007-02-10 12:25:27 -0200 | [diff] [blame] | 842 | priv->wstats.discard.retries = tx_retries; |
Holger Schurig | c49c3b7 | 2008-03-17 12:45:58 +0100 | [diff] [blame] | 843 | priv->wstats.discard.misc = le32_to_cpu(log.ackfailure); |
Marcelo Tosatti | 876c9d3 | 2007-02-10 12:25:27 -0200 | [diff] [blame] | 844 | |
| 845 | /* Calculate quality */ |
Holger Schurig | cad9d9b | 2007-08-02 13:07:15 -0400 | [diff] [blame] | 846 | priv->wstats.qual.qual = min_t(u8, quality, 100); |
Marcelo Tosatti | 876c9d3 | 2007-02-10 12:25:27 -0200 | [diff] [blame] | 847 | priv->wstats.qual.updated = IW_QUAL_ALL_UPDATED | IW_QUAL_DBM; |
| 848 | stats_valid = 1; |
| 849 | |
| 850 | /* update stats asynchronously for future calls */ |
Holger Schurig | 1007832 | 2007-11-15 18:05:47 -0500 | [diff] [blame] | 851 | lbs_prepare_and_send_command(priv, CMD_802_11_RSSI, 0, |
Marcelo Tosatti | 876c9d3 | 2007-02-10 12:25:27 -0200 | [diff] [blame] | 852 | 0, 0, NULL); |
Marcelo Tosatti | 876c9d3 | 2007-02-10 12:25:27 -0200 | [diff] [blame] | 853 | out: |
| 854 | if (!stats_valid) { |
| 855 | priv->wstats.miss.beacon = 0; |
| 856 | priv->wstats.discard.retries = 0; |
| 857 | priv->wstats.qual.qual = 0; |
| 858 | priv->wstats.qual.level = 0; |
| 859 | priv->wstats.qual.noise = 0; |
| 860 | priv->wstats.qual.updated = IW_QUAL_ALL_UPDATED; |
| 861 | priv->wstats.qual.updated |= IW_QUAL_NOISE_INVALID | |
| 862 | IW_QUAL_QUAL_INVALID | IW_QUAL_LEVEL_INVALID; |
| 863 | } |
| 864 | |
Holger Schurig | 9012b28 | 2007-05-25 11:27:16 -0400 | [diff] [blame] | 865 | lbs_deb_leave(LBS_DEB_WEXT); |
Marcelo Tosatti | 876c9d3 | 2007-02-10 12:25:27 -0200 | [diff] [blame] | 866 | return &priv->wstats; |
| 867 | |
| 868 | |
| 869 | } |
| 870 | |
Holger Schurig | 1007832 | 2007-11-15 18:05:47 -0500 | [diff] [blame] | 871 | static int lbs_set_freq(struct net_device *dev, struct iw_request_info *info, |
Marcelo Tosatti | 876c9d3 | 2007-02-10 12:25:27 -0200 | [diff] [blame] | 872 | struct iw_freq *fwrq, char *extra) |
| 873 | { |
Dan Williams | ef9a264 | 2007-05-25 16:46:33 -0400 | [diff] [blame] | 874 | int ret = -EINVAL; |
Holger Schurig | 69f9032 | 2007-11-23 15:43:44 +0100 | [diff] [blame] | 875 | struct lbs_private *priv = dev->priv; |
Marcelo Tosatti | 876c9d3 | 2007-02-10 12:25:27 -0200 | [diff] [blame] | 876 | struct chan_freq_power *cfp; |
Dan Williams | ef9a264 | 2007-05-25 16:46:33 -0400 | [diff] [blame] | 877 | struct assoc_request * assoc_req; |
Marcelo Tosatti | 876c9d3 | 2007-02-10 12:25:27 -0200 | [diff] [blame] | 878 | |
Holger Schurig | 9012b28 | 2007-05-25 11:27:16 -0400 | [diff] [blame] | 879 | lbs_deb_enter(LBS_DEB_WEXT); |
Marcelo Tosatti | 876c9d3 | 2007-02-10 12:25:27 -0200 | [diff] [blame] | 880 | |
David Woodhouse | aa21c00 | 2007-12-08 20:04:36 +0000 | [diff] [blame] | 881 | mutex_lock(&priv->lock); |
| 882 | assoc_req = lbs_get_association_request(priv); |
Dan Williams | ef9a264 | 2007-05-25 16:46:33 -0400 | [diff] [blame] | 883 | if (!assoc_req) { |
| 884 | ret = -ENOMEM; |
| 885 | goto out; |
| 886 | } |
Marcelo Tosatti | 876c9d3 | 2007-02-10 12:25:27 -0200 | [diff] [blame] | 887 | |
Dan Williams | ef9a264 | 2007-05-25 16:46:33 -0400 | [diff] [blame] | 888 | /* If setting by frequency, convert to a channel */ |
| 889 | if (fwrq->e == 1) { |
Marcelo Tosatti | 876c9d3 | 2007-02-10 12:25:27 -0200 | [diff] [blame] | 890 | long f = fwrq->m / 100000; |
Marcelo Tosatti | 876c9d3 | 2007-02-10 12:25:27 -0200 | [diff] [blame] | 891 | |
David Woodhouse | aa21c00 | 2007-12-08 20:04:36 +0000 | [diff] [blame] | 892 | cfp = find_cfp_by_band_and_freq(priv, 0, f); |
Marcelo Tosatti | 876c9d3 | 2007-02-10 12:25:27 -0200 | [diff] [blame] | 893 | if (!cfp) { |
Holger Schurig | 9012b28 | 2007-05-25 11:27:16 -0400 | [diff] [blame] | 894 | lbs_deb_wext("invalid freq %ld\n", f); |
Dan Williams | ef9a264 | 2007-05-25 16:46:33 -0400 | [diff] [blame] | 895 | goto out; |
Marcelo Tosatti | 876c9d3 | 2007-02-10 12:25:27 -0200 | [diff] [blame] | 896 | } |
| 897 | |
Marcelo Tosatti | 876c9d3 | 2007-02-10 12:25:27 -0200 | [diff] [blame] | 898 | fwrq->e = 0; |
Dan Williams | ef9a264 | 2007-05-25 16:46:33 -0400 | [diff] [blame] | 899 | fwrq->m = (int) cfp->channel; |
Marcelo Tosatti | 876c9d3 | 2007-02-10 12:25:27 -0200 | [diff] [blame] | 900 | } |
| 901 | |
Dan Williams | ef9a264 | 2007-05-25 16:46:33 -0400 | [diff] [blame] | 902 | /* Setting by channel number */ |
Marcelo Tosatti | 876c9d3 | 2007-02-10 12:25:27 -0200 | [diff] [blame] | 903 | if (fwrq->m > 1000 || fwrq->e > 0) { |
Dan Williams | ef9a264 | 2007-05-25 16:46:33 -0400 | [diff] [blame] | 904 | goto out; |
Marcelo Tosatti | 876c9d3 | 2007-02-10 12:25:27 -0200 | [diff] [blame] | 905 | } |
| 906 | |
David Woodhouse | aa21c00 | 2007-12-08 20:04:36 +0000 | [diff] [blame] | 907 | cfp = lbs_find_cfp_by_band_and_channel(priv, 0, fwrq->m); |
Dan Williams | ef9a264 | 2007-05-25 16:46:33 -0400 | [diff] [blame] | 908 | if (!cfp) { |
| 909 | goto out; |
| 910 | } |
| 911 | |
| 912 | assoc_req->channel = fwrq->m; |
| 913 | ret = 0; |
| 914 | |
Holger Schurig | 9012b28 | 2007-05-25 11:27:16 -0400 | [diff] [blame] | 915 | out: |
Dan Williams | ef9a264 | 2007-05-25 16:46:33 -0400 | [diff] [blame] | 916 | if (ret == 0) { |
| 917 | set_bit(ASSOC_FLAG_CHANNEL, &assoc_req->flags); |
Holger Schurig | 1007832 | 2007-11-15 18:05:47 -0500 | [diff] [blame] | 918 | lbs_postpone_association_work(priv); |
Dan Williams | ef9a264 | 2007-05-25 16:46:33 -0400 | [diff] [blame] | 919 | } else { |
Holger Schurig | 1007832 | 2007-11-15 18:05:47 -0500 | [diff] [blame] | 920 | lbs_cancel_association_work(priv); |
Dan Williams | ef9a264 | 2007-05-25 16:46:33 -0400 | [diff] [blame] | 921 | } |
David Woodhouse | aa21c00 | 2007-12-08 20:04:36 +0000 | [diff] [blame] | 922 | mutex_unlock(&priv->lock); |
Dan Williams | ef9a264 | 2007-05-25 16:46:33 -0400 | [diff] [blame] | 923 | |
| 924 | lbs_deb_leave_args(LBS_DEB_WEXT, "ret %d", ret); |
| 925 | return ret; |
Marcelo Tosatti | 876c9d3 | 2007-02-10 12:25:27 -0200 | [diff] [blame] | 926 | } |
| 927 | |
David Woodhouse | 823eaa2 | 2007-12-11 19:56:28 -0500 | [diff] [blame] | 928 | static int lbs_mesh_set_freq(struct net_device *dev, |
| 929 | struct iw_request_info *info, |
| 930 | struct iw_freq *fwrq, char *extra) |
| 931 | { |
| 932 | struct lbs_private *priv = dev->priv; |
| 933 | struct chan_freq_power *cfp; |
| 934 | int ret = -EINVAL; |
| 935 | |
| 936 | lbs_deb_enter(LBS_DEB_WEXT); |
| 937 | |
| 938 | /* If setting by frequency, convert to a channel */ |
| 939 | if (fwrq->e == 1) { |
| 940 | long f = fwrq->m / 100000; |
| 941 | |
| 942 | cfp = find_cfp_by_band_and_freq(priv, 0, f); |
| 943 | if (!cfp) { |
| 944 | lbs_deb_wext("invalid freq %ld\n", f); |
| 945 | goto out; |
| 946 | } |
| 947 | |
| 948 | fwrq->e = 0; |
| 949 | fwrq->m = (int) cfp->channel; |
| 950 | } |
| 951 | |
| 952 | /* Setting by channel number */ |
| 953 | if (fwrq->m > 1000 || fwrq->e > 0) { |
| 954 | goto out; |
| 955 | } |
| 956 | |
| 957 | cfp = lbs_find_cfp_by_band_and_channel(priv, 0, fwrq->m); |
| 958 | if (!cfp) { |
| 959 | goto out; |
| 960 | } |
| 961 | |
| 962 | if (fwrq->m != priv->curbssparams.channel) { |
| 963 | lbs_deb_wext("mesh channel change forces eth disconnect\n"); |
| 964 | if (priv->mode == IW_MODE_INFRA) |
Dan Williams | 191bb40 | 2008-08-21 17:46:18 -0400 | [diff] [blame] | 965 | lbs_cmd_80211_deauthenticate(priv, |
| 966 | priv->curbssparams.bssid, |
| 967 | WLAN_REASON_DEAUTH_LEAVING); |
David Woodhouse | 823eaa2 | 2007-12-11 19:56:28 -0500 | [diff] [blame] | 968 | else if (priv->mode == IW_MODE_ADHOC) |
| 969 | lbs_stop_adhoc_network(priv); |
| 970 | } |
Javier Cardona | edaea5c | 2008-05-17 00:55:10 -0700 | [diff] [blame] | 971 | lbs_mesh_config(priv, CMD_ACT_MESH_CONFIG_START, fwrq->m); |
David Woodhouse | 8606213 | 2007-12-13 00:32:36 -0500 | [diff] [blame] | 972 | lbs_update_channel(priv); |
David Woodhouse | 823eaa2 | 2007-12-11 19:56:28 -0500 | [diff] [blame] | 973 | ret = 0; |
| 974 | |
| 975 | out: |
| 976 | lbs_deb_leave_args(LBS_DEB_WEXT, "ret %d", ret); |
| 977 | return ret; |
| 978 | } |
| 979 | |
Holger Schurig | 1007832 | 2007-11-15 18:05:47 -0500 | [diff] [blame] | 980 | static int lbs_set_rate(struct net_device *dev, struct iw_request_info *info, |
Marcelo Tosatti | 876c9d3 | 2007-02-10 12:25:27 -0200 | [diff] [blame] | 981 | struct iw_param *vwrq, char *extra) |
| 982 | { |
Holger Schurig | 69f9032 | 2007-11-23 15:43:44 +0100 | [diff] [blame] | 983 | struct lbs_private *priv = dev->priv; |
Dan Williams | 8e3c91b | 2007-12-11 15:50:59 -0500 | [diff] [blame] | 984 | u8 new_rate = 0; |
Dan Williams | 8c51276 | 2007-08-02 11:40:45 -0400 | [diff] [blame] | 985 | int ret = -EINVAL; |
| 986 | u8 rates[MAX_RATES + 1]; |
Marcelo Tosatti | 876c9d3 | 2007-02-10 12:25:27 -0200 | [diff] [blame] | 987 | |
Holger Schurig | 9012b28 | 2007-05-25 11:27:16 -0400 | [diff] [blame] | 988 | lbs_deb_enter(LBS_DEB_WEXT); |
Holger Schurig | 9012b28 | 2007-05-25 11:27:16 -0400 | [diff] [blame] | 989 | lbs_deb_wext("vwrq->value %d\n", vwrq->value); |
Javier Cardona | 85319f9 | 2008-05-24 10:59:49 +0100 | [diff] [blame] | 990 | lbs_deb_wext("vwrq->fixed %d\n", vwrq->fixed); |
| 991 | |
| 992 | if (vwrq->fixed && vwrq->value == -1) |
| 993 | goto out; |
Marcelo Tosatti | 876c9d3 | 2007-02-10 12:25:27 -0200 | [diff] [blame] | 994 | |
Dan Williams | 8c51276 | 2007-08-02 11:40:45 -0400 | [diff] [blame] | 995 | /* Auto rate? */ |
Javier Cardona | 85319f9 | 2008-05-24 10:59:49 +0100 | [diff] [blame] | 996 | priv->enablehwauto = !vwrq->fixed; |
| 997 | |
| 998 | if (vwrq->value == -1) |
David Woodhouse | aa21c00 | 2007-12-08 20:04:36 +0000 | [diff] [blame] | 999 | priv->cur_rate = 0; |
Javier Cardona | 85319f9 | 2008-05-24 10:59:49 +0100 | [diff] [blame] | 1000 | else { |
Dan Williams | 8c51276 | 2007-08-02 11:40:45 -0400 | [diff] [blame] | 1001 | if (vwrq->value % 100000) |
| 1002 | goto out; |
Marcelo Tosatti | 876c9d3 | 2007-02-10 12:25:27 -0200 | [diff] [blame] | 1003 | |
Javier Cardona | 85319f9 | 2008-05-24 10:59:49 +0100 | [diff] [blame] | 1004 | new_rate = vwrq->value / 500000; |
| 1005 | priv->cur_rate = new_rate; |
| 1006 | /* the rest is only needed for lbs_set_data_rate() */ |
Marcelo Tosatti | 876c9d3 | 2007-02-10 12:25:27 -0200 | [diff] [blame] | 1007 | memset(rates, 0, sizeof(rates)); |
David Woodhouse | aa21c00 | 2007-12-08 20:04:36 +0000 | [diff] [blame] | 1008 | copy_active_data_rates(priv, rates); |
Dan Williams | 8c51276 | 2007-08-02 11:40:45 -0400 | [diff] [blame] | 1009 | if (!memchr(rates, new_rate, sizeof(rates))) { |
| 1010 | lbs_pr_alert("fixed data rate 0x%X out of range\n", |
| 1011 | new_rate); |
| 1012 | goto out; |
Marcelo Tosatti | 876c9d3 | 2007-02-10 12:25:27 -0200 | [diff] [blame] | 1013 | } |
Marcelo Tosatti | 876c9d3 | 2007-02-10 12:25:27 -0200 | [diff] [blame] | 1014 | } |
| 1015 | |
Javier Cardona | 85319f9 | 2008-05-24 10:59:49 +0100 | [diff] [blame] | 1016 | /* Try the newer command first (Firmware Spec 5.1 and above) */ |
| 1017 | ret = lbs_cmd_802_11_rate_adapt_rateset(priv, CMD_ACT_SET); |
| 1018 | |
| 1019 | /* Fallback to older version */ |
| 1020 | if (ret) |
| 1021 | ret = lbs_set_data_rate(priv, new_rate); |
Marcelo Tosatti | 876c9d3 | 2007-02-10 12:25:27 -0200 | [diff] [blame] | 1022 | |
Dan Williams | 8c51276 | 2007-08-02 11:40:45 -0400 | [diff] [blame] | 1023 | out: |
Holger Schurig | 9012b28 | 2007-05-25 11:27:16 -0400 | [diff] [blame] | 1024 | lbs_deb_leave_args(LBS_DEB_WEXT, "ret %d", ret); |
Marcelo Tosatti | 876c9d3 | 2007-02-10 12:25:27 -0200 | [diff] [blame] | 1025 | return ret; |
| 1026 | } |
| 1027 | |
Holger Schurig | 1007832 | 2007-11-15 18:05:47 -0500 | [diff] [blame] | 1028 | static int lbs_get_rate(struct net_device *dev, struct iw_request_info *info, |
Marcelo Tosatti | 876c9d3 | 2007-02-10 12:25:27 -0200 | [diff] [blame] | 1029 | struct iw_param *vwrq, char *extra) |
| 1030 | { |
Holger Schurig | 69f9032 | 2007-11-23 15:43:44 +0100 | [diff] [blame] | 1031 | struct lbs_private *priv = dev->priv; |
Marcelo Tosatti | 876c9d3 | 2007-02-10 12:25:27 -0200 | [diff] [blame] | 1032 | |
Holger Schurig | 9012b28 | 2007-05-25 11:27:16 -0400 | [diff] [blame] | 1033 | lbs_deb_enter(LBS_DEB_WEXT); |
Marcelo Tosatti | 876c9d3 | 2007-02-10 12:25:27 -0200 | [diff] [blame] | 1034 | |
David Woodhouse | aa21c00 | 2007-12-08 20:04:36 +0000 | [diff] [blame] | 1035 | if (priv->connect_status == LBS_CONNECTED) { |
| 1036 | vwrq->value = priv->cur_rate * 500000; |
Marcelo Tosatti | 876c9d3 | 2007-02-10 12:25:27 -0200 | [diff] [blame] | 1037 | |
Javier Cardona | 85319f9 | 2008-05-24 10:59:49 +0100 | [diff] [blame] | 1038 | if (priv->enablehwauto) |
Dan Williams | 8c51276 | 2007-08-02 11:40:45 -0400 | [diff] [blame] | 1039 | vwrq->fixed = 0; |
| 1040 | else |
| 1041 | vwrq->fixed = 1; |
| 1042 | |
| 1043 | } else { |
| 1044 | vwrq->fixed = 0; |
| 1045 | vwrq->value = 0; |
| 1046 | } |
Marcelo Tosatti | 876c9d3 | 2007-02-10 12:25:27 -0200 | [diff] [blame] | 1047 | |
Holger Schurig | 9012b28 | 2007-05-25 11:27:16 -0400 | [diff] [blame] | 1048 | lbs_deb_leave(LBS_DEB_WEXT); |
Marcelo Tosatti | 876c9d3 | 2007-02-10 12:25:27 -0200 | [diff] [blame] | 1049 | return 0; |
| 1050 | } |
| 1051 | |
Holger Schurig | 1007832 | 2007-11-15 18:05:47 -0500 | [diff] [blame] | 1052 | static int lbs_set_mode(struct net_device *dev, |
Marcelo Tosatti | 876c9d3 | 2007-02-10 12:25:27 -0200 | [diff] [blame] | 1053 | struct iw_request_info *info, u32 * uwrq, char *extra) |
| 1054 | { |
| 1055 | int ret = 0; |
Holger Schurig | 69f9032 | 2007-11-23 15:43:44 +0100 | [diff] [blame] | 1056 | struct lbs_private *priv = dev->priv; |
Marcelo Tosatti | 876c9d3 | 2007-02-10 12:25:27 -0200 | [diff] [blame] | 1057 | struct assoc_request * assoc_req; |
Marcelo Tosatti | 876c9d3 | 2007-02-10 12:25:27 -0200 | [diff] [blame] | 1058 | |
Holger Schurig | 9012b28 | 2007-05-25 11:27:16 -0400 | [diff] [blame] | 1059 | lbs_deb_enter(LBS_DEB_WEXT); |
Marcelo Tosatti | 876c9d3 | 2007-02-10 12:25:27 -0200 | [diff] [blame] | 1060 | |
Dan Williams | 0dc5a29 | 2007-05-10 22:58:02 -0400 | [diff] [blame] | 1061 | if ( (*uwrq != IW_MODE_ADHOC) |
| 1062 | && (*uwrq != IW_MODE_INFRA) |
| 1063 | && (*uwrq != IW_MODE_AUTO)) { |
Holger Schurig | 9012b28 | 2007-05-25 11:27:16 -0400 | [diff] [blame] | 1064 | lbs_deb_wext("Invalid mode: 0x%x\n", *uwrq); |
Dan Williams | 0dc5a29 | 2007-05-10 22:58:02 -0400 | [diff] [blame] | 1065 | ret = -EINVAL; |
| 1066 | goto out; |
Marcelo Tosatti | 876c9d3 | 2007-02-10 12:25:27 -0200 | [diff] [blame] | 1067 | } |
| 1068 | |
David Woodhouse | aa21c00 | 2007-12-08 20:04:36 +0000 | [diff] [blame] | 1069 | mutex_lock(&priv->lock); |
| 1070 | assoc_req = lbs_get_association_request(priv); |
Marcelo Tosatti | 876c9d3 | 2007-02-10 12:25:27 -0200 | [diff] [blame] | 1071 | if (!assoc_req) { |
| 1072 | ret = -ENOMEM; |
Holger Schurig | 1007832 | 2007-11-15 18:05:47 -0500 | [diff] [blame] | 1073 | lbs_cancel_association_work(priv); |
Marcelo Tosatti | 876c9d3 | 2007-02-10 12:25:27 -0200 | [diff] [blame] | 1074 | } else { |
Dan Williams | 0dc5a29 | 2007-05-10 22:58:02 -0400 | [diff] [blame] | 1075 | assoc_req->mode = *uwrq; |
Marcelo Tosatti | 876c9d3 | 2007-02-10 12:25:27 -0200 | [diff] [blame] | 1076 | set_bit(ASSOC_FLAG_MODE, &assoc_req->flags); |
Holger Schurig | 1007832 | 2007-11-15 18:05:47 -0500 | [diff] [blame] | 1077 | lbs_postpone_association_work(priv); |
Holger Schurig | 9012b28 | 2007-05-25 11:27:16 -0400 | [diff] [blame] | 1078 | lbs_deb_wext("Switching to mode: 0x%x\n", *uwrq); |
Marcelo Tosatti | 876c9d3 | 2007-02-10 12:25:27 -0200 | [diff] [blame] | 1079 | } |
David Woodhouse | aa21c00 | 2007-12-08 20:04:36 +0000 | [diff] [blame] | 1080 | mutex_unlock(&priv->lock); |
Marcelo Tosatti | 876c9d3 | 2007-02-10 12:25:27 -0200 | [diff] [blame] | 1081 | |
Dan Williams | 0dc5a29 | 2007-05-10 22:58:02 -0400 | [diff] [blame] | 1082 | out: |
Holger Schurig | 9012b28 | 2007-05-25 11:27:16 -0400 | [diff] [blame] | 1083 | lbs_deb_leave_args(LBS_DEB_WEXT, "ret %d", ret); |
Marcelo Tosatti | 876c9d3 | 2007-02-10 12:25:27 -0200 | [diff] [blame] | 1084 | return ret; |
| 1085 | } |
| 1086 | |
| 1087 | |
| 1088 | /** |
| 1089 | * @brief Get Encryption key |
| 1090 | * |
| 1091 | * @param dev A pointer to net_device structure |
| 1092 | * @param info A pointer to iw_request_info structure |
| 1093 | * @param vwrq A pointer to iw_param structure |
| 1094 | * @param extra A pointer to extra data buf |
| 1095 | * @return 0 --success, otherwise fail |
| 1096 | */ |
Holger Schurig | 1007832 | 2007-11-15 18:05:47 -0500 | [diff] [blame] | 1097 | static int lbs_get_encode(struct net_device *dev, |
Marcelo Tosatti | 876c9d3 | 2007-02-10 12:25:27 -0200 | [diff] [blame] | 1098 | struct iw_request_info *info, |
| 1099 | struct iw_point *dwrq, u8 * extra) |
| 1100 | { |
Holger Schurig | 69f9032 | 2007-11-23 15:43:44 +0100 | [diff] [blame] | 1101 | struct lbs_private *priv = dev->priv; |
Marcelo Tosatti | 876c9d3 | 2007-02-10 12:25:27 -0200 | [diff] [blame] | 1102 | int index = (dwrq->flags & IW_ENCODE_INDEX) - 1; |
| 1103 | |
Holger Schurig | 9012b28 | 2007-05-25 11:27:16 -0400 | [diff] [blame] | 1104 | lbs_deb_enter(LBS_DEB_WEXT); |
Marcelo Tosatti | 876c9d3 | 2007-02-10 12:25:27 -0200 | [diff] [blame] | 1105 | |
Holger Schurig | 9012b28 | 2007-05-25 11:27:16 -0400 | [diff] [blame] | 1106 | lbs_deb_wext("flags 0x%x, index %d, length %d, wep_tx_keyidx %d\n", |
David Woodhouse | aa21c00 | 2007-12-08 20:04:36 +0000 | [diff] [blame] | 1107 | dwrq->flags, index, dwrq->length, priv->wep_tx_keyidx); |
Marcelo Tosatti | 876c9d3 | 2007-02-10 12:25:27 -0200 | [diff] [blame] | 1108 | |
| 1109 | dwrq->flags = 0; |
| 1110 | |
| 1111 | /* Authentication method */ |
David Woodhouse | aa21c00 | 2007-12-08 20:04:36 +0000 | [diff] [blame] | 1112 | switch (priv->secinfo.auth_mode) { |
Dan Williams | 6affe78 | 2007-05-10 22:56:42 -0400 | [diff] [blame] | 1113 | case IW_AUTH_ALG_OPEN_SYSTEM: |
Marcelo Tosatti | 876c9d3 | 2007-02-10 12:25:27 -0200 | [diff] [blame] | 1114 | dwrq->flags = IW_ENCODE_OPEN; |
| 1115 | break; |
| 1116 | |
Dan Williams | 6affe78 | 2007-05-10 22:56:42 -0400 | [diff] [blame] | 1117 | case IW_AUTH_ALG_SHARED_KEY: |
| 1118 | case IW_AUTH_ALG_LEAP: |
Marcelo Tosatti | 876c9d3 | 2007-02-10 12:25:27 -0200 | [diff] [blame] | 1119 | dwrq->flags = IW_ENCODE_RESTRICTED; |
| 1120 | break; |
| 1121 | default: |
| 1122 | dwrq->flags = IW_ENCODE_DISABLED | IW_ENCODE_OPEN; |
| 1123 | break; |
| 1124 | } |
| 1125 | |
Marcelo Tosatti | 876c9d3 | 2007-02-10 12:25:27 -0200 | [diff] [blame] | 1126 | memset(extra, 0, 16); |
| 1127 | |
David Woodhouse | aa21c00 | 2007-12-08 20:04:36 +0000 | [diff] [blame] | 1128 | mutex_lock(&priv->lock); |
Marcelo Tosatti | 876c9d3 | 2007-02-10 12:25:27 -0200 | [diff] [blame] | 1129 | |
| 1130 | /* Default to returning current transmit key */ |
| 1131 | if (index < 0) |
David Woodhouse | aa21c00 | 2007-12-08 20:04:36 +0000 | [diff] [blame] | 1132 | index = priv->wep_tx_keyidx; |
Marcelo Tosatti | 876c9d3 | 2007-02-10 12:25:27 -0200 | [diff] [blame] | 1133 | |
David Woodhouse | aa21c00 | 2007-12-08 20:04:36 +0000 | [diff] [blame] | 1134 | if ((priv->wep_keys[index].len) && priv->secinfo.wep_enabled) { |
| 1135 | memcpy(extra, priv->wep_keys[index].key, |
| 1136 | priv->wep_keys[index].len); |
| 1137 | dwrq->length = priv->wep_keys[index].len; |
Marcelo Tosatti | 876c9d3 | 2007-02-10 12:25:27 -0200 | [diff] [blame] | 1138 | |
| 1139 | dwrq->flags |= (index + 1); |
| 1140 | /* Return WEP enabled */ |
| 1141 | dwrq->flags &= ~IW_ENCODE_DISABLED; |
David Woodhouse | aa21c00 | 2007-12-08 20:04:36 +0000 | [diff] [blame] | 1142 | } else if ((priv->secinfo.WPAenabled) |
| 1143 | || (priv->secinfo.WPA2enabled)) { |
Marcelo Tosatti | 876c9d3 | 2007-02-10 12:25:27 -0200 | [diff] [blame] | 1144 | /* return WPA enabled */ |
| 1145 | dwrq->flags &= ~IW_ENCODE_DISABLED; |
David Woodhouse | c12bdc4 | 2007-12-07 19:32:12 +0000 | [diff] [blame] | 1146 | dwrq->flags |= IW_ENCODE_NOKEY; |
Marcelo Tosatti | 876c9d3 | 2007-02-10 12:25:27 -0200 | [diff] [blame] | 1147 | } else { |
| 1148 | dwrq->flags |= IW_ENCODE_DISABLED; |
| 1149 | } |
| 1150 | |
David Woodhouse | aa21c00 | 2007-12-08 20:04:36 +0000 | [diff] [blame] | 1151 | mutex_unlock(&priv->lock); |
Marcelo Tosatti | 876c9d3 | 2007-02-10 12:25:27 -0200 | [diff] [blame] | 1152 | |
Joe Perches | 0795af5 | 2007-10-03 17:59:30 -0700 | [diff] [blame] | 1153 | lbs_deb_wext("key: %02x:%02x:%02x:%02x:%02x:%02x, keylen %d\n", |
Marcelo Tosatti | 876c9d3 | 2007-02-10 12:25:27 -0200 | [diff] [blame] | 1154 | extra[0], extra[1], extra[2], |
| 1155 | extra[3], extra[4], extra[5], dwrq->length); |
| 1156 | |
Holger Schurig | 9012b28 | 2007-05-25 11:27:16 -0400 | [diff] [blame] | 1157 | lbs_deb_wext("return flags 0x%x\n", dwrq->flags); |
Marcelo Tosatti | 876c9d3 | 2007-02-10 12:25:27 -0200 | [diff] [blame] | 1158 | |
Holger Schurig | 9012b28 | 2007-05-25 11:27:16 -0400 | [diff] [blame] | 1159 | lbs_deb_leave(LBS_DEB_WEXT); |
Marcelo Tosatti | 876c9d3 | 2007-02-10 12:25:27 -0200 | [diff] [blame] | 1160 | return 0; |
| 1161 | } |
| 1162 | |
| 1163 | /** |
| 1164 | * @brief Set Encryption key (internal) |
| 1165 | * |
| 1166 | * @param priv A pointer to private card structure |
| 1167 | * @param key_material A pointer to key material |
| 1168 | * @param key_length length of key material |
| 1169 | * @param index key index to set |
| 1170 | * @param set_tx_key Force set TX key (1 = yes, 0 = no) |
| 1171 | * @return 0 --success, otherwise fail |
| 1172 | */ |
Holger Schurig | 1007832 | 2007-11-15 18:05:47 -0500 | [diff] [blame] | 1173 | static int lbs_set_wep_key(struct assoc_request *assoc_req, |
Marcelo Tosatti | 876c9d3 | 2007-02-10 12:25:27 -0200 | [diff] [blame] | 1174 | const char *key_material, |
| 1175 | u16 key_length, |
| 1176 | u16 index, |
| 1177 | int set_tx_key) |
| 1178 | { |
Holger Schurig | 9012b28 | 2007-05-25 11:27:16 -0400 | [diff] [blame] | 1179 | int ret = 0; |
Dan Williams | 1443b65 | 2007-08-02 10:45:55 -0400 | [diff] [blame] | 1180 | struct enc_key *pkey; |
Marcelo Tosatti | 876c9d3 | 2007-02-10 12:25:27 -0200 | [diff] [blame] | 1181 | |
Holger Schurig | 9012b28 | 2007-05-25 11:27:16 -0400 | [diff] [blame] | 1182 | lbs_deb_enter(LBS_DEB_WEXT); |
Marcelo Tosatti | 876c9d3 | 2007-02-10 12:25:27 -0200 | [diff] [blame] | 1183 | |
| 1184 | /* Paranoid validation of key index */ |
| 1185 | if (index > 3) { |
Holger Schurig | 9012b28 | 2007-05-25 11:27:16 -0400 | [diff] [blame] | 1186 | ret = -EINVAL; |
| 1187 | goto out; |
Marcelo Tosatti | 876c9d3 | 2007-02-10 12:25:27 -0200 | [diff] [blame] | 1188 | } |
| 1189 | |
| 1190 | /* validate max key length */ |
| 1191 | if (key_length > KEY_LEN_WEP_104) { |
Holger Schurig | 9012b28 | 2007-05-25 11:27:16 -0400 | [diff] [blame] | 1192 | ret = -EINVAL; |
| 1193 | goto out; |
Marcelo Tosatti | 876c9d3 | 2007-02-10 12:25:27 -0200 | [diff] [blame] | 1194 | } |
| 1195 | |
| 1196 | pkey = &assoc_req->wep_keys[index]; |
| 1197 | |
| 1198 | if (key_length > 0) { |
Dan Williams | 1443b65 | 2007-08-02 10:45:55 -0400 | [diff] [blame] | 1199 | memset(pkey, 0, sizeof(struct enc_key)); |
Marcelo Tosatti | 876c9d3 | 2007-02-10 12:25:27 -0200 | [diff] [blame] | 1200 | pkey->type = KEY_TYPE_ID_WEP; |
| 1201 | |
| 1202 | /* Standardize the key length */ |
| 1203 | pkey->len = (key_length > KEY_LEN_WEP_40) ? |
| 1204 | KEY_LEN_WEP_104 : KEY_LEN_WEP_40; |
| 1205 | memcpy(pkey->key, key_material, key_length); |
| 1206 | } |
| 1207 | |
| 1208 | if (set_tx_key) { |
| 1209 | /* Ensure the chosen key is valid */ |
| 1210 | if (!pkey->len) { |
Holger Schurig | 9012b28 | 2007-05-25 11:27:16 -0400 | [diff] [blame] | 1211 | lbs_deb_wext("key not set, so cannot enable it\n"); |
| 1212 | ret = -EINVAL; |
| 1213 | goto out; |
Marcelo Tosatti | 876c9d3 | 2007-02-10 12:25:27 -0200 | [diff] [blame] | 1214 | } |
| 1215 | assoc_req->wep_tx_keyidx = index; |
| 1216 | } |
| 1217 | |
Dan Williams | 889c05b | 2007-05-10 22:57:23 -0400 | [diff] [blame] | 1218 | assoc_req->secinfo.wep_enabled = 1; |
Marcelo Tosatti | 876c9d3 | 2007-02-10 12:25:27 -0200 | [diff] [blame] | 1219 | |
Holger Schurig | 9012b28 | 2007-05-25 11:27:16 -0400 | [diff] [blame] | 1220 | out: |
| 1221 | lbs_deb_leave_args(LBS_DEB_WEXT, "ret %d", ret); |
| 1222 | return ret; |
Marcelo Tosatti | 876c9d3 | 2007-02-10 12:25:27 -0200 | [diff] [blame] | 1223 | } |
| 1224 | |
| 1225 | static int validate_key_index(u16 def_index, u16 raw_index, |
| 1226 | u16 *out_index, u16 *is_default) |
| 1227 | { |
| 1228 | if (!out_index || !is_default) |
| 1229 | return -EINVAL; |
| 1230 | |
| 1231 | /* Verify index if present, otherwise use default TX key index */ |
| 1232 | if (raw_index > 0) { |
| 1233 | if (raw_index > 4) |
| 1234 | return -EINVAL; |
| 1235 | *out_index = raw_index - 1; |
| 1236 | } else { |
| 1237 | *out_index = def_index; |
| 1238 | *is_default = 1; |
| 1239 | } |
| 1240 | return 0; |
| 1241 | } |
| 1242 | |
| 1243 | static void disable_wep(struct assoc_request *assoc_req) |
| 1244 | { |
| 1245 | int i; |
| 1246 | |
Dan Williams | 90a4221 | 2007-05-25 23:01:24 -0400 | [diff] [blame] | 1247 | lbs_deb_enter(LBS_DEB_WEXT); |
| 1248 | |
Marcelo Tosatti | 876c9d3 | 2007-02-10 12:25:27 -0200 | [diff] [blame] | 1249 | /* Set Open System auth mode */ |
Dan Williams | 6affe78 | 2007-05-10 22:56:42 -0400 | [diff] [blame] | 1250 | assoc_req->secinfo.auth_mode = IW_AUTH_ALG_OPEN_SYSTEM; |
Marcelo Tosatti | 876c9d3 | 2007-02-10 12:25:27 -0200 | [diff] [blame] | 1251 | |
| 1252 | /* Clear WEP keys and mark WEP as disabled */ |
Dan Williams | 889c05b | 2007-05-10 22:57:23 -0400 | [diff] [blame] | 1253 | assoc_req->secinfo.wep_enabled = 0; |
Marcelo Tosatti | 876c9d3 | 2007-02-10 12:25:27 -0200 | [diff] [blame] | 1254 | for (i = 0; i < 4; i++) |
| 1255 | assoc_req->wep_keys[i].len = 0; |
| 1256 | |
| 1257 | set_bit(ASSOC_FLAG_SECINFO, &assoc_req->flags); |
| 1258 | set_bit(ASSOC_FLAG_WEP_KEYS, &assoc_req->flags); |
Dan Williams | 90a4221 | 2007-05-25 23:01:24 -0400 | [diff] [blame] | 1259 | |
| 1260 | lbs_deb_leave(LBS_DEB_WEXT); |
| 1261 | } |
| 1262 | |
| 1263 | static void disable_wpa(struct assoc_request *assoc_req) |
| 1264 | { |
| 1265 | lbs_deb_enter(LBS_DEB_WEXT); |
| 1266 | |
Dan Williams | 1443b65 | 2007-08-02 10:45:55 -0400 | [diff] [blame] | 1267 | memset(&assoc_req->wpa_mcast_key, 0, sizeof (struct enc_key)); |
Dan Williams | 90a4221 | 2007-05-25 23:01:24 -0400 | [diff] [blame] | 1268 | assoc_req->wpa_mcast_key.flags = KEY_INFO_WPA_MCAST; |
| 1269 | set_bit(ASSOC_FLAG_WPA_MCAST_KEY, &assoc_req->flags); |
| 1270 | |
Dan Williams | 1443b65 | 2007-08-02 10:45:55 -0400 | [diff] [blame] | 1271 | memset(&assoc_req->wpa_unicast_key, 0, sizeof (struct enc_key)); |
Dan Williams | 90a4221 | 2007-05-25 23:01:24 -0400 | [diff] [blame] | 1272 | assoc_req->wpa_unicast_key.flags = KEY_INFO_WPA_UNICAST; |
| 1273 | set_bit(ASSOC_FLAG_WPA_UCAST_KEY, &assoc_req->flags); |
| 1274 | |
| 1275 | assoc_req->secinfo.WPAenabled = 0; |
| 1276 | assoc_req->secinfo.WPA2enabled = 0; |
| 1277 | set_bit(ASSOC_FLAG_SECINFO, &assoc_req->flags); |
| 1278 | |
| 1279 | lbs_deb_leave(LBS_DEB_WEXT); |
Marcelo Tosatti | 876c9d3 | 2007-02-10 12:25:27 -0200 | [diff] [blame] | 1280 | } |
| 1281 | |
| 1282 | /** |
| 1283 | * @brief Set Encryption key |
| 1284 | * |
| 1285 | * @param dev A pointer to net_device structure |
| 1286 | * @param info A pointer to iw_request_info structure |
| 1287 | * @param vwrq A pointer to iw_param structure |
| 1288 | * @param extra A pointer to extra data buf |
| 1289 | * @return 0 --success, otherwise fail |
| 1290 | */ |
Holger Schurig | 1007832 | 2007-11-15 18:05:47 -0500 | [diff] [blame] | 1291 | static int lbs_set_encode(struct net_device *dev, |
Marcelo Tosatti | 876c9d3 | 2007-02-10 12:25:27 -0200 | [diff] [blame] | 1292 | struct iw_request_info *info, |
| 1293 | struct iw_point *dwrq, char *extra) |
| 1294 | { |
| 1295 | int ret = 0; |
Holger Schurig | 69f9032 | 2007-11-23 15:43:44 +0100 | [diff] [blame] | 1296 | struct lbs_private *priv = dev->priv; |
Marcelo Tosatti | 876c9d3 | 2007-02-10 12:25:27 -0200 | [diff] [blame] | 1297 | struct assoc_request * assoc_req; |
| 1298 | u16 is_default = 0, index = 0, set_tx_key = 0; |
| 1299 | |
Holger Schurig | 9012b28 | 2007-05-25 11:27:16 -0400 | [diff] [blame] | 1300 | lbs_deb_enter(LBS_DEB_WEXT); |
Marcelo Tosatti | 876c9d3 | 2007-02-10 12:25:27 -0200 | [diff] [blame] | 1301 | |
David Woodhouse | aa21c00 | 2007-12-08 20:04:36 +0000 | [diff] [blame] | 1302 | mutex_lock(&priv->lock); |
| 1303 | assoc_req = lbs_get_association_request(priv); |
Marcelo Tosatti | 876c9d3 | 2007-02-10 12:25:27 -0200 | [diff] [blame] | 1304 | if (!assoc_req) { |
| 1305 | ret = -ENOMEM; |
| 1306 | goto out; |
| 1307 | } |
| 1308 | |
| 1309 | if (dwrq->flags & IW_ENCODE_DISABLED) { |
| 1310 | disable_wep (assoc_req); |
Dan Williams | 90a4221 | 2007-05-25 23:01:24 -0400 | [diff] [blame] | 1311 | disable_wpa (assoc_req); |
Marcelo Tosatti | 876c9d3 | 2007-02-10 12:25:27 -0200 | [diff] [blame] | 1312 | goto out; |
| 1313 | } |
| 1314 | |
| 1315 | ret = validate_key_index(assoc_req->wep_tx_keyidx, |
| 1316 | (dwrq->flags & IW_ENCODE_INDEX), |
| 1317 | &index, &is_default); |
| 1318 | if (ret) { |
| 1319 | ret = -EINVAL; |
| 1320 | goto out; |
| 1321 | } |
| 1322 | |
| 1323 | /* If WEP isn't enabled, or if there is no key data but a valid |
| 1324 | * index, set the TX key. |
| 1325 | */ |
Dan Williams | 889c05b | 2007-05-10 22:57:23 -0400 | [diff] [blame] | 1326 | if (!assoc_req->secinfo.wep_enabled || (dwrq->length == 0 && !is_default)) |
Marcelo Tosatti | 876c9d3 | 2007-02-10 12:25:27 -0200 | [diff] [blame] | 1327 | set_tx_key = 1; |
| 1328 | |
Holger Schurig | 1007832 | 2007-11-15 18:05:47 -0500 | [diff] [blame] | 1329 | ret = lbs_set_wep_key(assoc_req, extra, dwrq->length, index, set_tx_key); |
Marcelo Tosatti | 876c9d3 | 2007-02-10 12:25:27 -0200 | [diff] [blame] | 1330 | if (ret) |
| 1331 | goto out; |
| 1332 | |
| 1333 | if (dwrq->length) |
| 1334 | set_bit(ASSOC_FLAG_WEP_KEYS, &assoc_req->flags); |
| 1335 | if (set_tx_key) |
| 1336 | set_bit(ASSOC_FLAG_WEP_TX_KEYIDX, &assoc_req->flags); |
| 1337 | |
| 1338 | if (dwrq->flags & IW_ENCODE_RESTRICTED) { |
Dan Williams | 6affe78 | 2007-05-10 22:56:42 -0400 | [diff] [blame] | 1339 | assoc_req->secinfo.auth_mode = IW_AUTH_ALG_SHARED_KEY; |
Marcelo Tosatti | 876c9d3 | 2007-02-10 12:25:27 -0200 | [diff] [blame] | 1340 | } else if (dwrq->flags & IW_ENCODE_OPEN) { |
Dan Williams | 6affe78 | 2007-05-10 22:56:42 -0400 | [diff] [blame] | 1341 | assoc_req->secinfo.auth_mode = IW_AUTH_ALG_OPEN_SYSTEM; |
Marcelo Tosatti | 876c9d3 | 2007-02-10 12:25:27 -0200 | [diff] [blame] | 1342 | } |
| 1343 | |
| 1344 | out: |
| 1345 | if (ret == 0) { |
| 1346 | set_bit(ASSOC_FLAG_SECINFO, &assoc_req->flags); |
Holger Schurig | 1007832 | 2007-11-15 18:05:47 -0500 | [diff] [blame] | 1347 | lbs_postpone_association_work(priv); |
Marcelo Tosatti | 876c9d3 | 2007-02-10 12:25:27 -0200 | [diff] [blame] | 1348 | } else { |
Holger Schurig | 1007832 | 2007-11-15 18:05:47 -0500 | [diff] [blame] | 1349 | lbs_cancel_association_work(priv); |
Marcelo Tosatti | 876c9d3 | 2007-02-10 12:25:27 -0200 | [diff] [blame] | 1350 | } |
David Woodhouse | aa21c00 | 2007-12-08 20:04:36 +0000 | [diff] [blame] | 1351 | mutex_unlock(&priv->lock); |
Marcelo Tosatti | 876c9d3 | 2007-02-10 12:25:27 -0200 | [diff] [blame] | 1352 | |
Holger Schurig | 9012b28 | 2007-05-25 11:27:16 -0400 | [diff] [blame] | 1353 | lbs_deb_leave_args(LBS_DEB_WEXT, "ret %d", ret); |
Marcelo Tosatti | 876c9d3 | 2007-02-10 12:25:27 -0200 | [diff] [blame] | 1354 | return ret; |
| 1355 | } |
| 1356 | |
| 1357 | /** |
| 1358 | * @brief Get Extended Encryption key (WPA/802.1x and WEP) |
| 1359 | * |
| 1360 | * @param dev A pointer to net_device structure |
| 1361 | * @param info A pointer to iw_request_info structure |
| 1362 | * @param vwrq A pointer to iw_param structure |
| 1363 | * @param extra A pointer to extra data buf |
| 1364 | * @return 0 on success, otherwise failure |
| 1365 | */ |
Holger Schurig | 1007832 | 2007-11-15 18:05:47 -0500 | [diff] [blame] | 1366 | static int lbs_get_encodeext(struct net_device *dev, |
Marcelo Tosatti | 876c9d3 | 2007-02-10 12:25:27 -0200 | [diff] [blame] | 1367 | struct iw_request_info *info, |
| 1368 | struct iw_point *dwrq, |
| 1369 | char *extra) |
| 1370 | { |
| 1371 | int ret = -EINVAL; |
Holger Schurig | 69f9032 | 2007-11-23 15:43:44 +0100 | [diff] [blame] | 1372 | struct lbs_private *priv = dev->priv; |
Marcelo Tosatti | 876c9d3 | 2007-02-10 12:25:27 -0200 | [diff] [blame] | 1373 | struct iw_encode_ext *ext = (struct iw_encode_ext *)extra; |
| 1374 | int index, max_key_len; |
| 1375 | |
Holger Schurig | 9012b28 | 2007-05-25 11:27:16 -0400 | [diff] [blame] | 1376 | lbs_deb_enter(LBS_DEB_WEXT); |
Marcelo Tosatti | 876c9d3 | 2007-02-10 12:25:27 -0200 | [diff] [blame] | 1377 | |
| 1378 | max_key_len = dwrq->length - sizeof(*ext); |
| 1379 | if (max_key_len < 0) |
| 1380 | goto out; |
| 1381 | |
| 1382 | index = dwrq->flags & IW_ENCODE_INDEX; |
| 1383 | if (index) { |
| 1384 | if (index < 1 || index > 4) |
| 1385 | goto out; |
| 1386 | index--; |
| 1387 | } else { |
David Woodhouse | aa21c00 | 2007-12-08 20:04:36 +0000 | [diff] [blame] | 1388 | index = priv->wep_tx_keyidx; |
Marcelo Tosatti | 876c9d3 | 2007-02-10 12:25:27 -0200 | [diff] [blame] | 1389 | } |
| 1390 | |
Roel Kluin | f59d978 | 2007-10-26 21:51:26 +0200 | [diff] [blame] | 1391 | if (!(ext->ext_flags & IW_ENCODE_EXT_GROUP_KEY) && |
Marcelo Tosatti | 876c9d3 | 2007-02-10 12:25:27 -0200 | [diff] [blame] | 1392 | ext->alg != IW_ENCODE_ALG_WEP) { |
David Woodhouse | aa21c00 | 2007-12-08 20:04:36 +0000 | [diff] [blame] | 1393 | if (index != 0 || priv->mode != IW_MODE_INFRA) |
Marcelo Tosatti | 876c9d3 | 2007-02-10 12:25:27 -0200 | [diff] [blame] | 1394 | goto out; |
| 1395 | } |
| 1396 | |
| 1397 | dwrq->flags = index + 1; |
| 1398 | memset(ext, 0, sizeof(*ext)); |
| 1399 | |
David Woodhouse | aa21c00 | 2007-12-08 20:04:36 +0000 | [diff] [blame] | 1400 | if ( !priv->secinfo.wep_enabled |
| 1401 | && !priv->secinfo.WPAenabled |
| 1402 | && !priv->secinfo.WPA2enabled) { |
Marcelo Tosatti | 876c9d3 | 2007-02-10 12:25:27 -0200 | [diff] [blame] | 1403 | ext->alg = IW_ENCODE_ALG_NONE; |
| 1404 | ext->key_len = 0; |
| 1405 | dwrq->flags |= IW_ENCODE_DISABLED; |
| 1406 | } else { |
| 1407 | u8 *key = NULL; |
| 1408 | |
David Woodhouse | aa21c00 | 2007-12-08 20:04:36 +0000 | [diff] [blame] | 1409 | if ( priv->secinfo.wep_enabled |
| 1410 | && !priv->secinfo.WPAenabled |
| 1411 | && !priv->secinfo.WPA2enabled) { |
Dan Williams | 90a4221 | 2007-05-25 23:01:24 -0400 | [diff] [blame] | 1412 | /* WEP */ |
Marcelo Tosatti | 876c9d3 | 2007-02-10 12:25:27 -0200 | [diff] [blame] | 1413 | ext->alg = IW_ENCODE_ALG_WEP; |
David Woodhouse | aa21c00 | 2007-12-08 20:04:36 +0000 | [diff] [blame] | 1414 | ext->key_len = priv->wep_keys[index].len; |
| 1415 | key = &priv->wep_keys[index].key[0]; |
| 1416 | } else if ( !priv->secinfo.wep_enabled |
| 1417 | && (priv->secinfo.WPAenabled || |
| 1418 | priv->secinfo.WPA2enabled)) { |
Marcelo Tosatti | 876c9d3 | 2007-02-10 12:25:27 -0200 | [diff] [blame] | 1419 | /* WPA */ |
Dan Williams | 1443b65 | 2007-08-02 10:45:55 -0400 | [diff] [blame] | 1420 | struct enc_key * pkey = NULL; |
Dan Williams | 90a4221 | 2007-05-25 23:01:24 -0400 | [diff] [blame] | 1421 | |
David Woodhouse | aa21c00 | 2007-12-08 20:04:36 +0000 | [diff] [blame] | 1422 | if ( priv->wpa_mcast_key.len |
| 1423 | && (priv->wpa_mcast_key.flags & KEY_INFO_WPA_ENABLED)) |
| 1424 | pkey = &priv->wpa_mcast_key; |
| 1425 | else if ( priv->wpa_unicast_key.len |
| 1426 | && (priv->wpa_unicast_key.flags & KEY_INFO_WPA_ENABLED)) |
| 1427 | pkey = &priv->wpa_unicast_key; |
Dan Williams | 90a4221 | 2007-05-25 23:01:24 -0400 | [diff] [blame] | 1428 | |
| 1429 | if (pkey) { |
| 1430 | if (pkey->type == KEY_TYPE_ID_AES) { |
| 1431 | ext->alg = IW_ENCODE_ALG_CCMP; |
| 1432 | } else { |
| 1433 | ext->alg = IW_ENCODE_ALG_TKIP; |
| 1434 | } |
| 1435 | ext->key_len = pkey->len; |
| 1436 | key = &pkey->key[0]; |
| 1437 | } else { |
| 1438 | ext->alg = IW_ENCODE_ALG_TKIP; |
| 1439 | ext->key_len = 0; |
| 1440 | } |
Marcelo Tosatti | 876c9d3 | 2007-02-10 12:25:27 -0200 | [diff] [blame] | 1441 | } else { |
| 1442 | goto out; |
| 1443 | } |
| 1444 | |
| 1445 | if (ext->key_len > max_key_len) { |
| 1446 | ret = -E2BIG; |
| 1447 | goto out; |
| 1448 | } |
| 1449 | |
| 1450 | if (ext->key_len) |
| 1451 | memcpy(ext->key, key, ext->key_len); |
| 1452 | else |
| 1453 | dwrq->flags |= IW_ENCODE_NOKEY; |
| 1454 | dwrq->flags |= IW_ENCODE_ENABLED; |
| 1455 | } |
| 1456 | ret = 0; |
| 1457 | |
| 1458 | out: |
Holger Schurig | 9012b28 | 2007-05-25 11:27:16 -0400 | [diff] [blame] | 1459 | lbs_deb_leave_args(LBS_DEB_WEXT, "ret %d", ret); |
Marcelo Tosatti | 876c9d3 | 2007-02-10 12:25:27 -0200 | [diff] [blame] | 1460 | return ret; |
| 1461 | } |
| 1462 | |
| 1463 | /** |
| 1464 | * @brief Set Encryption key Extended (WPA/802.1x and WEP) |
| 1465 | * |
| 1466 | * @param dev A pointer to net_device structure |
| 1467 | * @param info A pointer to iw_request_info structure |
| 1468 | * @param vwrq A pointer to iw_param structure |
| 1469 | * @param extra A pointer to extra data buf |
| 1470 | * @return 0 --success, otherwise fail |
| 1471 | */ |
Holger Schurig | 1007832 | 2007-11-15 18:05:47 -0500 | [diff] [blame] | 1472 | static int lbs_set_encodeext(struct net_device *dev, |
Marcelo Tosatti | 876c9d3 | 2007-02-10 12:25:27 -0200 | [diff] [blame] | 1473 | struct iw_request_info *info, |
| 1474 | struct iw_point *dwrq, |
| 1475 | char *extra) |
| 1476 | { |
| 1477 | int ret = 0; |
Holger Schurig | 69f9032 | 2007-11-23 15:43:44 +0100 | [diff] [blame] | 1478 | struct lbs_private *priv = dev->priv; |
Marcelo Tosatti | 876c9d3 | 2007-02-10 12:25:27 -0200 | [diff] [blame] | 1479 | struct iw_encode_ext *ext = (struct iw_encode_ext *)extra; |
| 1480 | int alg = ext->alg; |
| 1481 | struct assoc_request * assoc_req; |
| 1482 | |
Holger Schurig | 9012b28 | 2007-05-25 11:27:16 -0400 | [diff] [blame] | 1483 | lbs_deb_enter(LBS_DEB_WEXT); |
Marcelo Tosatti | 876c9d3 | 2007-02-10 12:25:27 -0200 | [diff] [blame] | 1484 | |
David Woodhouse | aa21c00 | 2007-12-08 20:04:36 +0000 | [diff] [blame] | 1485 | mutex_lock(&priv->lock); |
| 1486 | assoc_req = lbs_get_association_request(priv); |
Marcelo Tosatti | 876c9d3 | 2007-02-10 12:25:27 -0200 | [diff] [blame] | 1487 | if (!assoc_req) { |
| 1488 | ret = -ENOMEM; |
| 1489 | goto out; |
| 1490 | } |
| 1491 | |
| 1492 | if ((alg == IW_ENCODE_ALG_NONE) || (dwrq->flags & IW_ENCODE_DISABLED)) { |
| 1493 | disable_wep (assoc_req); |
Dan Williams | 90a4221 | 2007-05-25 23:01:24 -0400 | [diff] [blame] | 1494 | disable_wpa (assoc_req); |
Marcelo Tosatti | 876c9d3 | 2007-02-10 12:25:27 -0200 | [diff] [blame] | 1495 | } else if (alg == IW_ENCODE_ALG_WEP) { |
| 1496 | u16 is_default = 0, index, set_tx_key = 0; |
| 1497 | |
| 1498 | ret = validate_key_index(assoc_req->wep_tx_keyidx, |
| 1499 | (dwrq->flags & IW_ENCODE_INDEX), |
| 1500 | &index, &is_default); |
| 1501 | if (ret) |
| 1502 | goto out; |
| 1503 | |
| 1504 | /* If WEP isn't enabled, or if there is no key data but a valid |
| 1505 | * index, or if the set-TX-key flag was passed, set the TX key. |
| 1506 | */ |
Dan Williams | 889c05b | 2007-05-10 22:57:23 -0400 | [diff] [blame] | 1507 | if ( !assoc_req->secinfo.wep_enabled |
Marcelo Tosatti | 876c9d3 | 2007-02-10 12:25:27 -0200 | [diff] [blame] | 1508 | || (dwrq->length == 0 && !is_default) |
| 1509 | || (ext->ext_flags & IW_ENCODE_EXT_SET_TX_KEY)) |
| 1510 | set_tx_key = 1; |
| 1511 | |
| 1512 | /* Copy key to driver */ |
Holger Schurig | 1007832 | 2007-11-15 18:05:47 -0500 | [diff] [blame] | 1513 | ret = lbs_set_wep_key(assoc_req, ext->key, ext->key_len, index, |
Marcelo Tosatti | 876c9d3 | 2007-02-10 12:25:27 -0200 | [diff] [blame] | 1514 | set_tx_key); |
| 1515 | if (ret) |
| 1516 | goto out; |
| 1517 | |
| 1518 | if (dwrq->flags & IW_ENCODE_RESTRICTED) { |
Dan Williams | 6affe78 | 2007-05-10 22:56:42 -0400 | [diff] [blame] | 1519 | assoc_req->secinfo.auth_mode = IW_AUTH_ALG_SHARED_KEY; |
Marcelo Tosatti | 876c9d3 | 2007-02-10 12:25:27 -0200 | [diff] [blame] | 1520 | } else if (dwrq->flags & IW_ENCODE_OPEN) { |
Dan Williams | 6affe78 | 2007-05-10 22:56:42 -0400 | [diff] [blame] | 1521 | assoc_req->secinfo.auth_mode = IW_AUTH_ALG_OPEN_SYSTEM; |
Marcelo Tosatti | 876c9d3 | 2007-02-10 12:25:27 -0200 | [diff] [blame] | 1522 | } |
| 1523 | |
| 1524 | /* Mark the various WEP bits as modified */ |
| 1525 | set_bit(ASSOC_FLAG_SECINFO, &assoc_req->flags); |
| 1526 | if (dwrq->length) |
| 1527 | set_bit(ASSOC_FLAG_WEP_KEYS, &assoc_req->flags); |
| 1528 | if (set_tx_key) |
| 1529 | set_bit(ASSOC_FLAG_WEP_TX_KEYIDX, &assoc_req->flags); |
Marcelo Tosatti | 876c9d3 | 2007-02-10 12:25:27 -0200 | [diff] [blame] | 1530 | } else if ((alg == IW_ENCODE_ALG_TKIP) || (alg == IW_ENCODE_ALG_CCMP)) { |
Dan Williams | 1443b65 | 2007-08-02 10:45:55 -0400 | [diff] [blame] | 1531 | struct enc_key * pkey; |
Marcelo Tosatti | 876c9d3 | 2007-02-10 12:25:27 -0200 | [diff] [blame] | 1532 | |
| 1533 | /* validate key length */ |
| 1534 | if (((alg == IW_ENCODE_ALG_TKIP) |
| 1535 | && (ext->key_len != KEY_LEN_WPA_TKIP)) |
| 1536 | || ((alg == IW_ENCODE_ALG_CCMP) |
| 1537 | && (ext->key_len != KEY_LEN_WPA_AES))) { |
Joe Perches | 8376e7a | 2007-11-19 17:48:27 -0800 | [diff] [blame] | 1538 | lbs_deb_wext("invalid size %d for key of alg " |
Holger Schurig | 9012b28 | 2007-05-25 11:27:16 -0400 | [diff] [blame] | 1539 | "type %d\n", |
Marcelo Tosatti | 876c9d3 | 2007-02-10 12:25:27 -0200 | [diff] [blame] | 1540 | ext->key_len, |
| 1541 | alg); |
| 1542 | ret = -EINVAL; |
| 1543 | goto out; |
| 1544 | } |
| 1545 | |
Dan Williams | 90a4221 | 2007-05-25 23:01:24 -0400 | [diff] [blame] | 1546 | if (ext->ext_flags & IW_ENCODE_EXT_GROUP_KEY) { |
Marcelo Tosatti | 876c9d3 | 2007-02-10 12:25:27 -0200 | [diff] [blame] | 1547 | pkey = &assoc_req->wpa_mcast_key; |
Dan Williams | 90a4221 | 2007-05-25 23:01:24 -0400 | [diff] [blame] | 1548 | set_bit(ASSOC_FLAG_WPA_MCAST_KEY, &assoc_req->flags); |
| 1549 | } else { |
Marcelo Tosatti | 876c9d3 | 2007-02-10 12:25:27 -0200 | [diff] [blame] | 1550 | pkey = &assoc_req->wpa_unicast_key; |
Dan Williams | 90a4221 | 2007-05-25 23:01:24 -0400 | [diff] [blame] | 1551 | set_bit(ASSOC_FLAG_WPA_UCAST_KEY, &assoc_req->flags); |
| 1552 | } |
Marcelo Tosatti | 876c9d3 | 2007-02-10 12:25:27 -0200 | [diff] [blame] | 1553 | |
Dan Williams | 1443b65 | 2007-08-02 10:45:55 -0400 | [diff] [blame] | 1554 | memset(pkey, 0, sizeof (struct enc_key)); |
Marcelo Tosatti | 876c9d3 | 2007-02-10 12:25:27 -0200 | [diff] [blame] | 1555 | memcpy(pkey->key, ext->key, ext->key_len); |
| 1556 | pkey->len = ext->key_len; |
Dan Williams | 90a4221 | 2007-05-25 23:01:24 -0400 | [diff] [blame] | 1557 | if (pkey->len) |
| 1558 | pkey->flags |= KEY_INFO_WPA_ENABLED; |
Marcelo Tosatti | 876c9d3 | 2007-02-10 12:25:27 -0200 | [diff] [blame] | 1559 | |
Dan Williams | 90a4221 | 2007-05-25 23:01:24 -0400 | [diff] [blame] | 1560 | /* Do this after zeroing key structure */ |
Marcelo Tosatti | 876c9d3 | 2007-02-10 12:25:27 -0200 | [diff] [blame] | 1561 | if (ext->ext_flags & IW_ENCODE_EXT_GROUP_KEY) { |
| 1562 | pkey->flags |= KEY_INFO_WPA_MCAST; |
Marcelo Tosatti | 876c9d3 | 2007-02-10 12:25:27 -0200 | [diff] [blame] | 1563 | } else { |
| 1564 | pkey->flags |= KEY_INFO_WPA_UNICAST; |
Marcelo Tosatti | 876c9d3 | 2007-02-10 12:25:27 -0200 | [diff] [blame] | 1565 | } |
| 1566 | |
Dan Williams | 90a4221 | 2007-05-25 23:01:24 -0400 | [diff] [blame] | 1567 | if (alg == IW_ENCODE_ALG_TKIP) { |
Marcelo Tosatti | 876c9d3 | 2007-02-10 12:25:27 -0200 | [diff] [blame] | 1568 | pkey->type = KEY_TYPE_ID_TKIP; |
Dan Williams | 90a4221 | 2007-05-25 23:01:24 -0400 | [diff] [blame] | 1569 | } else if (alg == IW_ENCODE_ALG_CCMP) { |
Marcelo Tosatti | 876c9d3 | 2007-02-10 12:25:27 -0200 | [diff] [blame] | 1570 | pkey->type = KEY_TYPE_ID_AES; |
Dan Williams | 90a4221 | 2007-05-25 23:01:24 -0400 | [diff] [blame] | 1571 | } |
Marcelo Tosatti | 876c9d3 | 2007-02-10 12:25:27 -0200 | [diff] [blame] | 1572 | |
| 1573 | /* If WPA isn't enabled yet, do that now */ |
| 1574 | if ( assoc_req->secinfo.WPAenabled == 0 |
| 1575 | && assoc_req->secinfo.WPA2enabled == 0) { |
| 1576 | assoc_req->secinfo.WPAenabled = 1; |
| 1577 | assoc_req->secinfo.WPA2enabled = 1; |
| 1578 | set_bit(ASSOC_FLAG_SECINFO, &assoc_req->flags); |
| 1579 | } |
| 1580 | |
| 1581 | disable_wep (assoc_req); |
| 1582 | } |
| 1583 | |
| 1584 | out: |
| 1585 | if (ret == 0) { |
Holger Schurig | 1007832 | 2007-11-15 18:05:47 -0500 | [diff] [blame] | 1586 | lbs_postpone_association_work(priv); |
Marcelo Tosatti | 876c9d3 | 2007-02-10 12:25:27 -0200 | [diff] [blame] | 1587 | } else { |
Holger Schurig | 1007832 | 2007-11-15 18:05:47 -0500 | [diff] [blame] | 1588 | lbs_cancel_association_work(priv); |
Marcelo Tosatti | 876c9d3 | 2007-02-10 12:25:27 -0200 | [diff] [blame] | 1589 | } |
David Woodhouse | aa21c00 | 2007-12-08 20:04:36 +0000 | [diff] [blame] | 1590 | mutex_unlock(&priv->lock); |
Marcelo Tosatti | 876c9d3 | 2007-02-10 12:25:27 -0200 | [diff] [blame] | 1591 | |
Holger Schurig | 9012b28 | 2007-05-25 11:27:16 -0400 | [diff] [blame] | 1592 | lbs_deb_leave_args(LBS_DEB_WEXT, "ret %d", ret); |
Marcelo Tosatti | 876c9d3 | 2007-02-10 12:25:27 -0200 | [diff] [blame] | 1593 | return ret; |
| 1594 | } |
| 1595 | |
| 1596 | |
Holger Schurig | 1007832 | 2007-11-15 18:05:47 -0500 | [diff] [blame] | 1597 | static int lbs_set_genie(struct net_device *dev, |
Marcelo Tosatti | 876c9d3 | 2007-02-10 12:25:27 -0200 | [diff] [blame] | 1598 | struct iw_request_info *info, |
| 1599 | struct iw_point *dwrq, |
| 1600 | char *extra) |
| 1601 | { |
Holger Schurig | 69f9032 | 2007-11-23 15:43:44 +0100 | [diff] [blame] | 1602 | struct lbs_private *priv = dev->priv; |
Marcelo Tosatti | 876c9d3 | 2007-02-10 12:25:27 -0200 | [diff] [blame] | 1603 | int ret = 0; |
| 1604 | struct assoc_request * assoc_req; |
| 1605 | |
Holger Schurig | 9012b28 | 2007-05-25 11:27:16 -0400 | [diff] [blame] | 1606 | lbs_deb_enter(LBS_DEB_WEXT); |
Marcelo Tosatti | 876c9d3 | 2007-02-10 12:25:27 -0200 | [diff] [blame] | 1607 | |
David Woodhouse | aa21c00 | 2007-12-08 20:04:36 +0000 | [diff] [blame] | 1608 | mutex_lock(&priv->lock); |
| 1609 | assoc_req = lbs_get_association_request(priv); |
Marcelo Tosatti | 876c9d3 | 2007-02-10 12:25:27 -0200 | [diff] [blame] | 1610 | if (!assoc_req) { |
| 1611 | ret = -ENOMEM; |
| 1612 | goto out; |
| 1613 | } |
| 1614 | |
| 1615 | if (dwrq->length > MAX_WPA_IE_LEN || |
| 1616 | (dwrq->length && extra == NULL)) { |
| 1617 | ret = -EINVAL; |
| 1618 | goto out; |
| 1619 | } |
| 1620 | |
| 1621 | if (dwrq->length) { |
| 1622 | memcpy(&assoc_req->wpa_ie[0], extra, dwrq->length); |
| 1623 | assoc_req->wpa_ie_len = dwrq->length; |
| 1624 | } else { |
David Woodhouse | aa21c00 | 2007-12-08 20:04:36 +0000 | [diff] [blame] | 1625 | memset(&assoc_req->wpa_ie[0], 0, sizeof(priv->wpa_ie)); |
Marcelo Tosatti | 876c9d3 | 2007-02-10 12:25:27 -0200 | [diff] [blame] | 1626 | assoc_req->wpa_ie_len = 0; |
| 1627 | } |
| 1628 | |
| 1629 | out: |
| 1630 | if (ret == 0) { |
| 1631 | set_bit(ASSOC_FLAG_WPA_IE, &assoc_req->flags); |
Holger Schurig | 1007832 | 2007-11-15 18:05:47 -0500 | [diff] [blame] | 1632 | lbs_postpone_association_work(priv); |
Marcelo Tosatti | 876c9d3 | 2007-02-10 12:25:27 -0200 | [diff] [blame] | 1633 | } else { |
Holger Schurig | 1007832 | 2007-11-15 18:05:47 -0500 | [diff] [blame] | 1634 | lbs_cancel_association_work(priv); |
Marcelo Tosatti | 876c9d3 | 2007-02-10 12:25:27 -0200 | [diff] [blame] | 1635 | } |
David Woodhouse | aa21c00 | 2007-12-08 20:04:36 +0000 | [diff] [blame] | 1636 | mutex_unlock(&priv->lock); |
Marcelo Tosatti | 876c9d3 | 2007-02-10 12:25:27 -0200 | [diff] [blame] | 1637 | |
Holger Schurig | 9012b28 | 2007-05-25 11:27:16 -0400 | [diff] [blame] | 1638 | lbs_deb_leave_args(LBS_DEB_WEXT, "ret %d", ret); |
Marcelo Tosatti | 876c9d3 | 2007-02-10 12:25:27 -0200 | [diff] [blame] | 1639 | return ret; |
| 1640 | } |
| 1641 | |
Holger Schurig | 1007832 | 2007-11-15 18:05:47 -0500 | [diff] [blame] | 1642 | static int lbs_get_genie(struct net_device *dev, |
Marcelo Tosatti | 876c9d3 | 2007-02-10 12:25:27 -0200 | [diff] [blame] | 1643 | struct iw_request_info *info, |
| 1644 | struct iw_point *dwrq, |
| 1645 | char *extra) |
| 1646 | { |
Holger Schurig | 9012b28 | 2007-05-25 11:27:16 -0400 | [diff] [blame] | 1647 | int ret = 0; |
Holger Schurig | 69f9032 | 2007-11-23 15:43:44 +0100 | [diff] [blame] | 1648 | struct lbs_private *priv = dev->priv; |
Marcelo Tosatti | 876c9d3 | 2007-02-10 12:25:27 -0200 | [diff] [blame] | 1649 | |
Holger Schurig | 9012b28 | 2007-05-25 11:27:16 -0400 | [diff] [blame] | 1650 | lbs_deb_enter(LBS_DEB_WEXT); |
Marcelo Tosatti | 876c9d3 | 2007-02-10 12:25:27 -0200 | [diff] [blame] | 1651 | |
David Woodhouse | aa21c00 | 2007-12-08 20:04:36 +0000 | [diff] [blame] | 1652 | if (priv->wpa_ie_len == 0) { |
Marcelo Tosatti | 876c9d3 | 2007-02-10 12:25:27 -0200 | [diff] [blame] | 1653 | dwrq->length = 0; |
Holger Schurig | 9012b28 | 2007-05-25 11:27:16 -0400 | [diff] [blame] | 1654 | goto out; |
Marcelo Tosatti | 876c9d3 | 2007-02-10 12:25:27 -0200 | [diff] [blame] | 1655 | } |
| 1656 | |
David Woodhouse | aa21c00 | 2007-12-08 20:04:36 +0000 | [diff] [blame] | 1657 | if (dwrq->length < priv->wpa_ie_len) { |
Holger Schurig | 9012b28 | 2007-05-25 11:27:16 -0400 | [diff] [blame] | 1658 | ret = -E2BIG; |
| 1659 | goto out; |
Marcelo Tosatti | 876c9d3 | 2007-02-10 12:25:27 -0200 | [diff] [blame] | 1660 | } |
| 1661 | |
David Woodhouse | aa21c00 | 2007-12-08 20:04:36 +0000 | [diff] [blame] | 1662 | dwrq->length = priv->wpa_ie_len; |
| 1663 | memcpy(extra, &priv->wpa_ie[0], priv->wpa_ie_len); |
Marcelo Tosatti | 876c9d3 | 2007-02-10 12:25:27 -0200 | [diff] [blame] | 1664 | |
Holger Schurig | 9012b28 | 2007-05-25 11:27:16 -0400 | [diff] [blame] | 1665 | out: |
| 1666 | lbs_deb_leave_args(LBS_DEB_WEXT, "ret %d", ret); |
| 1667 | return ret; |
Marcelo Tosatti | 876c9d3 | 2007-02-10 12:25:27 -0200 | [diff] [blame] | 1668 | } |
| 1669 | |
| 1670 | |
Holger Schurig | 1007832 | 2007-11-15 18:05:47 -0500 | [diff] [blame] | 1671 | static int lbs_set_auth(struct net_device *dev, |
Marcelo Tosatti | 876c9d3 | 2007-02-10 12:25:27 -0200 | [diff] [blame] | 1672 | struct iw_request_info *info, |
| 1673 | struct iw_param *dwrq, |
| 1674 | char *extra) |
| 1675 | { |
Holger Schurig | 69f9032 | 2007-11-23 15:43:44 +0100 | [diff] [blame] | 1676 | struct lbs_private *priv = dev->priv; |
Marcelo Tosatti | 876c9d3 | 2007-02-10 12:25:27 -0200 | [diff] [blame] | 1677 | struct assoc_request * assoc_req; |
| 1678 | int ret = 0; |
| 1679 | int updated = 0; |
| 1680 | |
Holger Schurig | 9012b28 | 2007-05-25 11:27:16 -0400 | [diff] [blame] | 1681 | lbs_deb_enter(LBS_DEB_WEXT); |
Marcelo Tosatti | 876c9d3 | 2007-02-10 12:25:27 -0200 | [diff] [blame] | 1682 | |
David Woodhouse | aa21c00 | 2007-12-08 20:04:36 +0000 | [diff] [blame] | 1683 | mutex_lock(&priv->lock); |
| 1684 | assoc_req = lbs_get_association_request(priv); |
Marcelo Tosatti | 876c9d3 | 2007-02-10 12:25:27 -0200 | [diff] [blame] | 1685 | if (!assoc_req) { |
| 1686 | ret = -ENOMEM; |
| 1687 | goto out; |
| 1688 | } |
| 1689 | |
| 1690 | switch (dwrq->flags & IW_AUTH_INDEX) { |
| 1691 | case IW_AUTH_TKIP_COUNTERMEASURES: |
| 1692 | case IW_AUTH_CIPHER_PAIRWISE: |
| 1693 | case IW_AUTH_CIPHER_GROUP: |
| 1694 | case IW_AUTH_KEY_MGMT: |
Dan Williams | 90a4221 | 2007-05-25 23:01:24 -0400 | [diff] [blame] | 1695 | case IW_AUTH_DROP_UNENCRYPTED: |
Marcelo Tosatti | 876c9d3 | 2007-02-10 12:25:27 -0200 | [diff] [blame] | 1696 | /* |
| 1697 | * libertas does not use these parameters |
| 1698 | */ |
| 1699 | break; |
| 1700 | |
| 1701 | case IW_AUTH_WPA_VERSION: |
| 1702 | if (dwrq->value & IW_AUTH_WPA_VERSION_DISABLED) { |
| 1703 | assoc_req->secinfo.WPAenabled = 0; |
| 1704 | assoc_req->secinfo.WPA2enabled = 0; |
Dan Williams | 90a4221 | 2007-05-25 23:01:24 -0400 | [diff] [blame] | 1705 | disable_wpa (assoc_req); |
Marcelo Tosatti | 876c9d3 | 2007-02-10 12:25:27 -0200 | [diff] [blame] | 1706 | } |
| 1707 | if (dwrq->value & IW_AUTH_WPA_VERSION_WPA) { |
| 1708 | assoc_req->secinfo.WPAenabled = 1; |
Dan Williams | 889c05b | 2007-05-10 22:57:23 -0400 | [diff] [blame] | 1709 | assoc_req->secinfo.wep_enabled = 0; |
Dan Williams | 6affe78 | 2007-05-10 22:56:42 -0400 | [diff] [blame] | 1710 | assoc_req->secinfo.auth_mode = IW_AUTH_ALG_OPEN_SYSTEM; |
Marcelo Tosatti | 876c9d3 | 2007-02-10 12:25:27 -0200 | [diff] [blame] | 1711 | } |
| 1712 | if (dwrq->value & IW_AUTH_WPA_VERSION_WPA2) { |
| 1713 | assoc_req->secinfo.WPA2enabled = 1; |
Dan Williams | 889c05b | 2007-05-10 22:57:23 -0400 | [diff] [blame] | 1714 | assoc_req->secinfo.wep_enabled = 0; |
Dan Williams | 6affe78 | 2007-05-10 22:56:42 -0400 | [diff] [blame] | 1715 | assoc_req->secinfo.auth_mode = IW_AUTH_ALG_OPEN_SYSTEM; |
Marcelo Tosatti | 876c9d3 | 2007-02-10 12:25:27 -0200 | [diff] [blame] | 1716 | } |
| 1717 | updated = 1; |
| 1718 | break; |
| 1719 | |
Marcelo Tosatti | 876c9d3 | 2007-02-10 12:25:27 -0200 | [diff] [blame] | 1720 | case IW_AUTH_80211_AUTH_ALG: |
| 1721 | if (dwrq->value & IW_AUTH_ALG_SHARED_KEY) { |
Dan Williams | 6affe78 | 2007-05-10 22:56:42 -0400 | [diff] [blame] | 1722 | assoc_req->secinfo.auth_mode = IW_AUTH_ALG_SHARED_KEY; |
Marcelo Tosatti | 876c9d3 | 2007-02-10 12:25:27 -0200 | [diff] [blame] | 1723 | } else if (dwrq->value & IW_AUTH_ALG_OPEN_SYSTEM) { |
Dan Williams | 6affe78 | 2007-05-10 22:56:42 -0400 | [diff] [blame] | 1724 | assoc_req->secinfo.auth_mode = IW_AUTH_ALG_OPEN_SYSTEM; |
Marcelo Tosatti | 876c9d3 | 2007-02-10 12:25:27 -0200 | [diff] [blame] | 1725 | } else if (dwrq->value & IW_AUTH_ALG_LEAP) { |
Dan Williams | 6affe78 | 2007-05-10 22:56:42 -0400 | [diff] [blame] | 1726 | assoc_req->secinfo.auth_mode = IW_AUTH_ALG_LEAP; |
Marcelo Tosatti | 876c9d3 | 2007-02-10 12:25:27 -0200 | [diff] [blame] | 1727 | } else { |
| 1728 | ret = -EINVAL; |
| 1729 | } |
| 1730 | updated = 1; |
| 1731 | break; |
| 1732 | |
| 1733 | case IW_AUTH_WPA_ENABLED: |
| 1734 | if (dwrq->value) { |
| 1735 | if (!assoc_req->secinfo.WPAenabled && |
| 1736 | !assoc_req->secinfo.WPA2enabled) { |
| 1737 | assoc_req->secinfo.WPAenabled = 1; |
| 1738 | assoc_req->secinfo.WPA2enabled = 1; |
Dan Williams | 889c05b | 2007-05-10 22:57:23 -0400 | [diff] [blame] | 1739 | assoc_req->secinfo.wep_enabled = 0; |
Dan Williams | 6affe78 | 2007-05-10 22:56:42 -0400 | [diff] [blame] | 1740 | assoc_req->secinfo.auth_mode = IW_AUTH_ALG_OPEN_SYSTEM; |
Marcelo Tosatti | 876c9d3 | 2007-02-10 12:25:27 -0200 | [diff] [blame] | 1741 | } |
| 1742 | } else { |
| 1743 | assoc_req->secinfo.WPAenabled = 0; |
| 1744 | assoc_req->secinfo.WPA2enabled = 0; |
Dan Williams | 90a4221 | 2007-05-25 23:01:24 -0400 | [diff] [blame] | 1745 | disable_wpa (assoc_req); |
Marcelo Tosatti | 876c9d3 | 2007-02-10 12:25:27 -0200 | [diff] [blame] | 1746 | } |
| 1747 | updated = 1; |
| 1748 | break; |
| 1749 | |
| 1750 | default: |
| 1751 | ret = -EOPNOTSUPP; |
| 1752 | break; |
| 1753 | } |
| 1754 | |
| 1755 | out: |
| 1756 | if (ret == 0) { |
| 1757 | if (updated) |
| 1758 | set_bit(ASSOC_FLAG_SECINFO, &assoc_req->flags); |
Holger Schurig | 1007832 | 2007-11-15 18:05:47 -0500 | [diff] [blame] | 1759 | lbs_postpone_association_work(priv); |
Marcelo Tosatti | 876c9d3 | 2007-02-10 12:25:27 -0200 | [diff] [blame] | 1760 | } else if (ret != -EOPNOTSUPP) { |
Holger Schurig | 1007832 | 2007-11-15 18:05:47 -0500 | [diff] [blame] | 1761 | lbs_cancel_association_work(priv); |
Marcelo Tosatti | 876c9d3 | 2007-02-10 12:25:27 -0200 | [diff] [blame] | 1762 | } |
David Woodhouse | aa21c00 | 2007-12-08 20:04:36 +0000 | [diff] [blame] | 1763 | mutex_unlock(&priv->lock); |
Marcelo Tosatti | 876c9d3 | 2007-02-10 12:25:27 -0200 | [diff] [blame] | 1764 | |
Holger Schurig | 9012b28 | 2007-05-25 11:27:16 -0400 | [diff] [blame] | 1765 | lbs_deb_leave_args(LBS_DEB_WEXT, "ret %d", ret); |
Marcelo Tosatti | 876c9d3 | 2007-02-10 12:25:27 -0200 | [diff] [blame] | 1766 | return ret; |
| 1767 | } |
| 1768 | |
Holger Schurig | 1007832 | 2007-11-15 18:05:47 -0500 | [diff] [blame] | 1769 | static int lbs_get_auth(struct net_device *dev, |
Marcelo Tosatti | 876c9d3 | 2007-02-10 12:25:27 -0200 | [diff] [blame] | 1770 | struct iw_request_info *info, |
| 1771 | struct iw_param *dwrq, |
| 1772 | char *extra) |
| 1773 | { |
Holger Schurig | 9012b28 | 2007-05-25 11:27:16 -0400 | [diff] [blame] | 1774 | int ret = 0; |
Holger Schurig | 69f9032 | 2007-11-23 15:43:44 +0100 | [diff] [blame] | 1775 | struct lbs_private *priv = dev->priv; |
Marcelo Tosatti | 876c9d3 | 2007-02-10 12:25:27 -0200 | [diff] [blame] | 1776 | |
Holger Schurig | 9012b28 | 2007-05-25 11:27:16 -0400 | [diff] [blame] | 1777 | lbs_deb_enter(LBS_DEB_WEXT); |
Marcelo Tosatti | 876c9d3 | 2007-02-10 12:25:27 -0200 | [diff] [blame] | 1778 | |
| 1779 | switch (dwrq->flags & IW_AUTH_INDEX) { |
| 1780 | case IW_AUTH_WPA_VERSION: |
| 1781 | dwrq->value = 0; |
David Woodhouse | aa21c00 | 2007-12-08 20:04:36 +0000 | [diff] [blame] | 1782 | if (priv->secinfo.WPAenabled) |
Marcelo Tosatti | 876c9d3 | 2007-02-10 12:25:27 -0200 | [diff] [blame] | 1783 | dwrq->value |= IW_AUTH_WPA_VERSION_WPA; |
David Woodhouse | aa21c00 | 2007-12-08 20:04:36 +0000 | [diff] [blame] | 1784 | if (priv->secinfo.WPA2enabled) |
Marcelo Tosatti | 876c9d3 | 2007-02-10 12:25:27 -0200 | [diff] [blame] | 1785 | dwrq->value |= IW_AUTH_WPA_VERSION_WPA2; |
| 1786 | if (!dwrq->value) |
| 1787 | dwrq->value |= IW_AUTH_WPA_VERSION_DISABLED; |
| 1788 | break; |
| 1789 | |
Marcelo Tosatti | 876c9d3 | 2007-02-10 12:25:27 -0200 | [diff] [blame] | 1790 | case IW_AUTH_80211_AUTH_ALG: |
David Woodhouse | aa21c00 | 2007-12-08 20:04:36 +0000 | [diff] [blame] | 1791 | dwrq->value = priv->secinfo.auth_mode; |
Marcelo Tosatti | 876c9d3 | 2007-02-10 12:25:27 -0200 | [diff] [blame] | 1792 | break; |
| 1793 | |
| 1794 | case IW_AUTH_WPA_ENABLED: |
David Woodhouse | aa21c00 | 2007-12-08 20:04:36 +0000 | [diff] [blame] | 1795 | if (priv->secinfo.WPAenabled && priv->secinfo.WPA2enabled) |
Marcelo Tosatti | 876c9d3 | 2007-02-10 12:25:27 -0200 | [diff] [blame] | 1796 | dwrq->value = 1; |
| 1797 | break; |
| 1798 | |
| 1799 | default: |
Holger Schurig | 9012b28 | 2007-05-25 11:27:16 -0400 | [diff] [blame] | 1800 | ret = -EOPNOTSUPP; |
Marcelo Tosatti | 876c9d3 | 2007-02-10 12:25:27 -0200 | [diff] [blame] | 1801 | } |
| 1802 | |
Holger Schurig | 9012b28 | 2007-05-25 11:27:16 -0400 | [diff] [blame] | 1803 | lbs_deb_leave_args(LBS_DEB_WEXT, "ret %d", ret); |
| 1804 | return ret; |
Marcelo Tosatti | 876c9d3 | 2007-02-10 12:25:27 -0200 | [diff] [blame] | 1805 | } |
| 1806 | |
| 1807 | |
Holger Schurig | 1007832 | 2007-11-15 18:05:47 -0500 | [diff] [blame] | 1808 | static int lbs_set_txpow(struct net_device *dev, struct iw_request_info *info, |
Marcelo Tosatti | 876c9d3 | 2007-02-10 12:25:27 -0200 | [diff] [blame] | 1809 | struct iw_param *vwrq, char *extra) |
| 1810 | { |
| 1811 | int ret = 0; |
Holger Schurig | 69f9032 | 2007-11-23 15:43:44 +0100 | [diff] [blame] | 1812 | struct lbs_private *priv = dev->priv; |
Dan Williams | 87c8c72 | 2008-08-19 15:15:35 -0400 | [diff] [blame] | 1813 | s16 dbm = (s16) vwrq->value; |
Marcelo Tosatti | 876c9d3 | 2007-02-10 12:25:27 -0200 | [diff] [blame] | 1814 | |
Holger Schurig | 9012b28 | 2007-05-25 11:27:16 -0400 | [diff] [blame] | 1815 | lbs_deb_enter(LBS_DEB_WEXT); |
Marcelo Tosatti | 876c9d3 | 2007-02-10 12:25:27 -0200 | [diff] [blame] | 1816 | |
| 1817 | if (vwrq->disabled) { |
Dan Williams | d5db2df | 2008-08-21 17:51:07 -0400 | [diff] [blame^] | 1818 | lbs_set_radio(priv, RADIO_PREAMBLE_AUTO, 0); |
Dan Williams | 87c8c72 | 2008-08-19 15:15:35 -0400 | [diff] [blame] | 1819 | goto out; |
Marcelo Tosatti | 876c9d3 | 2007-02-10 12:25:27 -0200 | [diff] [blame] | 1820 | } |
| 1821 | |
Dan Williams | 87c8c72 | 2008-08-19 15:15:35 -0400 | [diff] [blame] | 1822 | if (vwrq->fixed == 0) { |
| 1823 | /* Auto power control */ |
Dan Williams | 87c8c72 | 2008-08-19 15:15:35 -0400 | [diff] [blame] | 1824 | dbm = priv->txpower_max; |
| 1825 | } else { |
| 1826 | /* Userspace check in iwrange if it should use dBm or mW, |
| 1827 | * therefore this should never happen... Jean II */ |
| 1828 | if ((vwrq->flags & IW_TXPOW_TYPE) != IW_TXPOW_DBM) { |
| 1829 | ret = -EOPNOTSUPP; |
| 1830 | goto out; |
| 1831 | } |
| 1832 | |
| 1833 | /* Validate requested power level against firmware allowed levels */ |
| 1834 | if (priv->txpower_min && (dbm < priv->txpower_min)) { |
| 1835 | ret = -EINVAL; |
| 1836 | goto out; |
| 1837 | } |
| 1838 | |
| 1839 | if (priv->txpower_max && (dbm > priv->txpower_max)) { |
| 1840 | ret = -EINVAL; |
| 1841 | goto out; |
| 1842 | } |
| 1843 | } |
Marcelo Tosatti | 876c9d3 | 2007-02-10 12:25:27 -0200 | [diff] [blame] | 1844 | |
Dan Williams | d5db2df | 2008-08-21 17:51:07 -0400 | [diff] [blame^] | 1845 | /* If the radio was off, turn it on */ |
| 1846 | if (!priv->radio_on) { |
| 1847 | ret = lbs_set_radio(priv, RADIO_PREAMBLE_AUTO, 1); |
| 1848 | if (ret) |
| 1849 | goto out; |
| 1850 | } |
Marcelo Tosatti | 876c9d3 | 2007-02-10 12:25:27 -0200 | [diff] [blame] | 1851 | |
Dan Williams | 87c8c72 | 2008-08-19 15:15:35 -0400 | [diff] [blame] | 1852 | lbs_deb_wext("txpower set %d dBm\n", dbm); |
Marcelo Tosatti | 876c9d3 | 2007-02-10 12:25:27 -0200 | [diff] [blame] | 1853 | |
Dan Williams | 87c8c72 | 2008-08-19 15:15:35 -0400 | [diff] [blame] | 1854 | ret = lbs_set_tx_power(priv, dbm); |
Marcelo Tosatti | 876c9d3 | 2007-02-10 12:25:27 -0200 | [diff] [blame] | 1855 | |
Dan Williams | 87c8c72 | 2008-08-19 15:15:35 -0400 | [diff] [blame] | 1856 | out: |
Holger Schurig | 9012b28 | 2007-05-25 11:27:16 -0400 | [diff] [blame] | 1857 | lbs_deb_leave_args(LBS_DEB_WEXT, "ret %d", ret); |
Marcelo Tosatti | 876c9d3 | 2007-02-10 12:25:27 -0200 | [diff] [blame] | 1858 | return ret; |
| 1859 | } |
| 1860 | |
Holger Schurig | 1007832 | 2007-11-15 18:05:47 -0500 | [diff] [blame] | 1861 | static int lbs_get_essid(struct net_device *dev, struct iw_request_info *info, |
Marcelo Tosatti | 876c9d3 | 2007-02-10 12:25:27 -0200 | [diff] [blame] | 1862 | struct iw_point *dwrq, char *extra) |
| 1863 | { |
Holger Schurig | 69f9032 | 2007-11-23 15:43:44 +0100 | [diff] [blame] | 1864 | struct lbs_private *priv = dev->priv; |
Marcelo Tosatti | 876c9d3 | 2007-02-10 12:25:27 -0200 | [diff] [blame] | 1865 | |
Holger Schurig | 9012b28 | 2007-05-25 11:27:16 -0400 | [diff] [blame] | 1866 | lbs_deb_enter(LBS_DEB_WEXT); |
| 1867 | |
Marcelo Tosatti | 876c9d3 | 2007-02-10 12:25:27 -0200 | [diff] [blame] | 1868 | /* |
| 1869 | * Note : if dwrq->flags != 0, we should get the relevant SSID from |
| 1870 | * the SSID list... |
| 1871 | */ |
| 1872 | |
| 1873 | /* |
| 1874 | * Get the current SSID |
| 1875 | */ |
David Woodhouse | aa21c00 | 2007-12-08 20:04:36 +0000 | [diff] [blame] | 1876 | if (priv->connect_status == LBS_CONNECTED) { |
| 1877 | memcpy(extra, priv->curbssparams.ssid, |
| 1878 | priv->curbssparams.ssid_len); |
| 1879 | extra[priv->curbssparams.ssid_len] = '\0'; |
Marcelo Tosatti | 876c9d3 | 2007-02-10 12:25:27 -0200 | [diff] [blame] | 1880 | } else { |
| 1881 | memset(extra, 0, 32); |
David Woodhouse | aa21c00 | 2007-12-08 20:04:36 +0000 | [diff] [blame] | 1882 | extra[priv->curbssparams.ssid_len] = '\0'; |
Marcelo Tosatti | 876c9d3 | 2007-02-10 12:25:27 -0200 | [diff] [blame] | 1883 | } |
| 1884 | /* |
| 1885 | * If none, we may want to get the one that was set |
| 1886 | */ |
| 1887 | |
David Woodhouse | aa21c00 | 2007-12-08 20:04:36 +0000 | [diff] [blame] | 1888 | dwrq->length = priv->curbssparams.ssid_len; |
Marcelo Tosatti | 876c9d3 | 2007-02-10 12:25:27 -0200 | [diff] [blame] | 1889 | |
| 1890 | dwrq->flags = 1; /* active */ |
| 1891 | |
Holger Schurig | 9012b28 | 2007-05-25 11:27:16 -0400 | [diff] [blame] | 1892 | lbs_deb_leave(LBS_DEB_WEXT); |
Marcelo Tosatti | 876c9d3 | 2007-02-10 12:25:27 -0200 | [diff] [blame] | 1893 | return 0; |
| 1894 | } |
| 1895 | |
Holger Schurig | 1007832 | 2007-11-15 18:05:47 -0500 | [diff] [blame] | 1896 | static int lbs_set_essid(struct net_device *dev, struct iw_request_info *info, |
Marcelo Tosatti | 876c9d3 | 2007-02-10 12:25:27 -0200 | [diff] [blame] | 1897 | struct iw_point *dwrq, char *extra) |
| 1898 | { |
Holger Schurig | 69f9032 | 2007-11-23 15:43:44 +0100 | [diff] [blame] | 1899 | struct lbs_private *priv = dev->priv; |
Marcelo Tosatti | 876c9d3 | 2007-02-10 12:25:27 -0200 | [diff] [blame] | 1900 | int ret = 0; |
Dan Williams | d8efea2 | 2007-05-28 23:54:55 -0400 | [diff] [blame] | 1901 | u8 ssid[IW_ESSID_MAX_SIZE]; |
| 1902 | u8 ssid_len = 0; |
Marcelo Tosatti | 876c9d3 | 2007-02-10 12:25:27 -0200 | [diff] [blame] | 1903 | struct assoc_request * assoc_req; |
Dan Williams | d8efea2 | 2007-05-28 23:54:55 -0400 | [diff] [blame] | 1904 | int in_ssid_len = dwrq->length; |
Marcelo Tosatti | 876c9d3 | 2007-02-10 12:25:27 -0200 | [diff] [blame] | 1905 | |
Holger Schurig | 9012b28 | 2007-05-25 11:27:16 -0400 | [diff] [blame] | 1906 | lbs_deb_enter(LBS_DEB_WEXT); |
Marcelo Tosatti | 876c9d3 | 2007-02-10 12:25:27 -0200 | [diff] [blame] | 1907 | |
Dan Williams | d5db2df | 2008-08-21 17:51:07 -0400 | [diff] [blame^] | 1908 | if (!priv->radio_on) { |
| 1909 | ret = -EINVAL; |
| 1910 | goto out; |
| 1911 | } |
| 1912 | |
Marcelo Tosatti | 876c9d3 | 2007-02-10 12:25:27 -0200 | [diff] [blame] | 1913 | /* Check the size of the string */ |
Dan Williams | d8efea2 | 2007-05-28 23:54:55 -0400 | [diff] [blame] | 1914 | if (in_ssid_len > IW_ESSID_MAX_SIZE) { |
Marcelo Tosatti | 876c9d3 | 2007-02-10 12:25:27 -0200 | [diff] [blame] | 1915 | ret = -E2BIG; |
| 1916 | goto out; |
| 1917 | } |
| 1918 | |
Dan Williams | d8efea2 | 2007-05-28 23:54:55 -0400 | [diff] [blame] | 1919 | memset(&ssid, 0, sizeof(ssid)); |
Marcelo Tosatti | 876c9d3 | 2007-02-10 12:25:27 -0200 | [diff] [blame] | 1920 | |
Dan Williams | d8efea2 | 2007-05-28 23:54:55 -0400 | [diff] [blame] | 1921 | if (!dwrq->flags || !in_ssid_len) { |
Marcelo Tosatti | 876c9d3 | 2007-02-10 12:25:27 -0200 | [diff] [blame] | 1922 | /* "any" SSID requested; leave SSID blank */ |
| 1923 | } else { |
| 1924 | /* Specific SSID requested */ |
Dan Williams | d8efea2 | 2007-05-28 23:54:55 -0400 | [diff] [blame] | 1925 | memcpy(&ssid, extra, in_ssid_len); |
| 1926 | ssid_len = in_ssid_len; |
Marcelo Tosatti | 876c9d3 | 2007-02-10 12:25:27 -0200 | [diff] [blame] | 1927 | } |
| 1928 | |
Dan Williams | d8efea2 | 2007-05-28 23:54:55 -0400 | [diff] [blame] | 1929 | if (!ssid_len) { |
| 1930 | lbs_deb_wext("requested any SSID\n"); |
| 1931 | } else { |
| 1932 | lbs_deb_wext("requested SSID '%s'\n", |
| 1933 | escape_essid(ssid, ssid_len)); |
| 1934 | } |
Marcelo Tosatti | 876c9d3 | 2007-02-10 12:25:27 -0200 | [diff] [blame] | 1935 | |
| 1936 | out: |
David Woodhouse | aa21c00 | 2007-12-08 20:04:36 +0000 | [diff] [blame] | 1937 | mutex_lock(&priv->lock); |
Marcelo Tosatti | 876c9d3 | 2007-02-10 12:25:27 -0200 | [diff] [blame] | 1938 | if (ret == 0) { |
| 1939 | /* Get or create the current association request */ |
David Woodhouse | aa21c00 | 2007-12-08 20:04:36 +0000 | [diff] [blame] | 1940 | assoc_req = lbs_get_association_request(priv); |
Marcelo Tosatti | 876c9d3 | 2007-02-10 12:25:27 -0200 | [diff] [blame] | 1941 | if (!assoc_req) { |
| 1942 | ret = -ENOMEM; |
| 1943 | } else { |
| 1944 | /* Copy the SSID to the association request */ |
Dan Williams | d8efea2 | 2007-05-28 23:54:55 -0400 | [diff] [blame] | 1945 | memcpy(&assoc_req->ssid, &ssid, IW_ESSID_MAX_SIZE); |
| 1946 | assoc_req->ssid_len = ssid_len; |
Marcelo Tosatti | 876c9d3 | 2007-02-10 12:25:27 -0200 | [diff] [blame] | 1947 | set_bit(ASSOC_FLAG_SSID, &assoc_req->flags); |
Holger Schurig | 1007832 | 2007-11-15 18:05:47 -0500 | [diff] [blame] | 1948 | lbs_postpone_association_work(priv); |
Marcelo Tosatti | 876c9d3 | 2007-02-10 12:25:27 -0200 | [diff] [blame] | 1949 | } |
| 1950 | } |
| 1951 | |
| 1952 | /* Cancel the association request if there was an error */ |
| 1953 | if (ret != 0) { |
Holger Schurig | 1007832 | 2007-11-15 18:05:47 -0500 | [diff] [blame] | 1954 | lbs_cancel_association_work(priv); |
Marcelo Tosatti | 876c9d3 | 2007-02-10 12:25:27 -0200 | [diff] [blame] | 1955 | } |
| 1956 | |
David Woodhouse | aa21c00 | 2007-12-08 20:04:36 +0000 | [diff] [blame] | 1957 | mutex_unlock(&priv->lock); |
Marcelo Tosatti | 876c9d3 | 2007-02-10 12:25:27 -0200 | [diff] [blame] | 1958 | |
Holger Schurig | 9012b28 | 2007-05-25 11:27:16 -0400 | [diff] [blame] | 1959 | lbs_deb_leave_args(LBS_DEB_WEXT, "ret %d", ret); |
Marcelo Tosatti | 876c9d3 | 2007-02-10 12:25:27 -0200 | [diff] [blame] | 1960 | return ret; |
| 1961 | } |
| 1962 | |
David Woodhouse | f5956bf | 2007-12-11 19:30:57 -0500 | [diff] [blame] | 1963 | static int lbs_mesh_get_essid(struct net_device *dev, |
| 1964 | struct iw_request_info *info, |
| 1965 | struct iw_point *dwrq, char *extra) |
| 1966 | { |
| 1967 | struct lbs_private *priv = dev->priv; |
| 1968 | |
| 1969 | lbs_deb_enter(LBS_DEB_WEXT); |
| 1970 | |
| 1971 | memcpy(extra, priv->mesh_ssid, priv->mesh_ssid_len); |
| 1972 | |
| 1973 | dwrq->length = priv->mesh_ssid_len; |
| 1974 | |
| 1975 | dwrq->flags = 1; /* active */ |
| 1976 | |
| 1977 | lbs_deb_leave(LBS_DEB_WEXT); |
| 1978 | return 0; |
| 1979 | } |
| 1980 | |
| 1981 | static int lbs_mesh_set_essid(struct net_device *dev, |
| 1982 | struct iw_request_info *info, |
| 1983 | struct iw_point *dwrq, char *extra) |
| 1984 | { |
| 1985 | struct lbs_private *priv = dev->priv; |
| 1986 | int ret = 0; |
| 1987 | |
| 1988 | lbs_deb_enter(LBS_DEB_WEXT); |
| 1989 | |
Dan Williams | d5db2df | 2008-08-21 17:51:07 -0400 | [diff] [blame^] | 1990 | if (!priv->radio_on) { |
| 1991 | ret = -EINVAL; |
| 1992 | goto out; |
| 1993 | } |
| 1994 | |
David Woodhouse | f5956bf | 2007-12-11 19:30:57 -0500 | [diff] [blame] | 1995 | /* Check the size of the string */ |
| 1996 | if (dwrq->length > IW_ESSID_MAX_SIZE) { |
| 1997 | ret = -E2BIG; |
| 1998 | goto out; |
| 1999 | } |
| 2000 | |
| 2001 | if (!dwrq->flags || !dwrq->length) { |
| 2002 | ret = -EINVAL; |
| 2003 | goto out; |
| 2004 | } else { |
| 2005 | /* Specific SSID requested */ |
| 2006 | memcpy(priv->mesh_ssid, extra, dwrq->length); |
| 2007 | priv->mesh_ssid_len = dwrq->length; |
| 2008 | } |
| 2009 | |
Javier Cardona | edaea5c | 2008-05-17 00:55:10 -0700 | [diff] [blame] | 2010 | lbs_mesh_config(priv, CMD_ACT_MESH_CONFIG_START, |
| 2011 | priv->curbssparams.channel); |
David Woodhouse | f5956bf | 2007-12-11 19:30:57 -0500 | [diff] [blame] | 2012 | out: |
| 2013 | lbs_deb_leave_args(LBS_DEB_WEXT, "ret %d", ret); |
| 2014 | return ret; |
| 2015 | } |
| 2016 | |
Marcelo Tosatti | 876c9d3 | 2007-02-10 12:25:27 -0200 | [diff] [blame] | 2017 | /** |
| 2018 | * @brief Connect to the AP or Ad-hoc Network with specific bssid |
| 2019 | * |
| 2020 | * @param dev A pointer to net_device structure |
| 2021 | * @param info A pointer to iw_request_info structure |
| 2022 | * @param awrq A pointer to iw_param structure |
| 2023 | * @param extra A pointer to extra data buf |
| 2024 | * @return 0 --success, otherwise fail |
| 2025 | */ |
Holger Schurig | 1007832 | 2007-11-15 18:05:47 -0500 | [diff] [blame] | 2026 | static int lbs_set_wap(struct net_device *dev, struct iw_request_info *info, |
Marcelo Tosatti | 876c9d3 | 2007-02-10 12:25:27 -0200 | [diff] [blame] | 2027 | struct sockaddr *awrq, char *extra) |
| 2028 | { |
Holger Schurig | 69f9032 | 2007-11-23 15:43:44 +0100 | [diff] [blame] | 2029 | struct lbs_private *priv = dev->priv; |
Marcelo Tosatti | 876c9d3 | 2007-02-10 12:25:27 -0200 | [diff] [blame] | 2030 | struct assoc_request * assoc_req; |
| 2031 | int ret = 0; |
Joe Perches | 0795af5 | 2007-10-03 17:59:30 -0700 | [diff] [blame] | 2032 | DECLARE_MAC_BUF(mac); |
Marcelo Tosatti | 876c9d3 | 2007-02-10 12:25:27 -0200 | [diff] [blame] | 2033 | |
Holger Schurig | 9012b28 | 2007-05-25 11:27:16 -0400 | [diff] [blame] | 2034 | lbs_deb_enter(LBS_DEB_WEXT); |
Marcelo Tosatti | 876c9d3 | 2007-02-10 12:25:27 -0200 | [diff] [blame] | 2035 | |
Dan Williams | d5db2df | 2008-08-21 17:51:07 -0400 | [diff] [blame^] | 2036 | if (!priv->radio_on) |
| 2037 | return -EINVAL; |
| 2038 | |
Marcelo Tosatti | 876c9d3 | 2007-02-10 12:25:27 -0200 | [diff] [blame] | 2039 | if (awrq->sa_family != ARPHRD_ETHER) |
| 2040 | return -EINVAL; |
| 2041 | |
Joe Perches | 0795af5 | 2007-10-03 17:59:30 -0700 | [diff] [blame] | 2042 | lbs_deb_wext("ASSOC: WAP: sa_data %s\n", print_mac(mac, awrq->sa_data)); |
Marcelo Tosatti | 876c9d3 | 2007-02-10 12:25:27 -0200 | [diff] [blame] | 2043 | |
David Woodhouse | aa21c00 | 2007-12-08 20:04:36 +0000 | [diff] [blame] | 2044 | mutex_lock(&priv->lock); |
Marcelo Tosatti | 876c9d3 | 2007-02-10 12:25:27 -0200 | [diff] [blame] | 2045 | |
| 2046 | /* Get or create the current association request */ |
David Woodhouse | aa21c00 | 2007-12-08 20:04:36 +0000 | [diff] [blame] | 2047 | assoc_req = lbs_get_association_request(priv); |
Marcelo Tosatti | 876c9d3 | 2007-02-10 12:25:27 -0200 | [diff] [blame] | 2048 | if (!assoc_req) { |
Holger Schurig | 1007832 | 2007-11-15 18:05:47 -0500 | [diff] [blame] | 2049 | lbs_cancel_association_work(priv); |
Marcelo Tosatti | 876c9d3 | 2007-02-10 12:25:27 -0200 | [diff] [blame] | 2050 | ret = -ENOMEM; |
| 2051 | } else { |
| 2052 | /* Copy the BSSID to the association request */ |
| 2053 | memcpy(&assoc_req->bssid, awrq->sa_data, ETH_ALEN); |
| 2054 | set_bit(ASSOC_FLAG_BSSID, &assoc_req->flags); |
Holger Schurig | 1007832 | 2007-11-15 18:05:47 -0500 | [diff] [blame] | 2055 | lbs_postpone_association_work(priv); |
Marcelo Tosatti | 876c9d3 | 2007-02-10 12:25:27 -0200 | [diff] [blame] | 2056 | } |
| 2057 | |
David Woodhouse | aa21c00 | 2007-12-08 20:04:36 +0000 | [diff] [blame] | 2058 | mutex_unlock(&priv->lock); |
Marcelo Tosatti | 876c9d3 | 2007-02-10 12:25:27 -0200 | [diff] [blame] | 2059 | |
| 2060 | return ret; |
| 2061 | } |
| 2062 | |
Marcelo Tosatti | 876c9d3 | 2007-02-10 12:25:27 -0200 | [diff] [blame] | 2063 | /* |
| 2064 | * iwconfig settable callbacks |
| 2065 | */ |
Holger Schurig | 1007832 | 2007-11-15 18:05:47 -0500 | [diff] [blame] | 2066 | static const iw_handler lbs_handler[] = { |
Marcelo Tosatti | 876c9d3 | 2007-02-10 12:25:27 -0200 | [diff] [blame] | 2067 | (iw_handler) NULL, /* SIOCSIWCOMMIT */ |
Holger Schurig | 1007832 | 2007-11-15 18:05:47 -0500 | [diff] [blame] | 2068 | (iw_handler) lbs_get_name, /* SIOCGIWNAME */ |
Marcelo Tosatti | 876c9d3 | 2007-02-10 12:25:27 -0200 | [diff] [blame] | 2069 | (iw_handler) NULL, /* SIOCSIWNWID */ |
| 2070 | (iw_handler) NULL, /* SIOCGIWNWID */ |
Holger Schurig | 1007832 | 2007-11-15 18:05:47 -0500 | [diff] [blame] | 2071 | (iw_handler) lbs_set_freq, /* SIOCSIWFREQ */ |
| 2072 | (iw_handler) lbs_get_freq, /* SIOCGIWFREQ */ |
| 2073 | (iw_handler) lbs_set_mode, /* SIOCSIWMODE */ |
| 2074 | (iw_handler) lbs_get_mode, /* SIOCGIWMODE */ |
Marcelo Tosatti | 876c9d3 | 2007-02-10 12:25:27 -0200 | [diff] [blame] | 2075 | (iw_handler) NULL, /* SIOCSIWSENS */ |
| 2076 | (iw_handler) NULL, /* SIOCGIWSENS */ |
| 2077 | (iw_handler) NULL, /* SIOCSIWRANGE */ |
Holger Schurig | 1007832 | 2007-11-15 18:05:47 -0500 | [diff] [blame] | 2078 | (iw_handler) lbs_get_range, /* SIOCGIWRANGE */ |
Marcelo Tosatti | 876c9d3 | 2007-02-10 12:25:27 -0200 | [diff] [blame] | 2079 | (iw_handler) NULL, /* SIOCSIWPRIV */ |
| 2080 | (iw_handler) NULL, /* SIOCGIWPRIV */ |
| 2081 | (iw_handler) NULL, /* SIOCSIWSTATS */ |
| 2082 | (iw_handler) NULL, /* SIOCGIWSTATS */ |
| 2083 | iw_handler_set_spy, /* SIOCSIWSPY */ |
| 2084 | iw_handler_get_spy, /* SIOCGIWSPY */ |
| 2085 | iw_handler_set_thrspy, /* SIOCSIWTHRSPY */ |
| 2086 | iw_handler_get_thrspy, /* SIOCGIWTHRSPY */ |
Holger Schurig | 1007832 | 2007-11-15 18:05:47 -0500 | [diff] [blame] | 2087 | (iw_handler) lbs_set_wap, /* SIOCSIWAP */ |
| 2088 | (iw_handler) lbs_get_wap, /* SIOCGIWAP */ |
Marcelo Tosatti | 876c9d3 | 2007-02-10 12:25:27 -0200 | [diff] [blame] | 2089 | (iw_handler) NULL, /* SIOCSIWMLME */ |
| 2090 | (iw_handler) NULL, /* SIOCGIWAPLIST - deprecated */ |
Holger Schurig | 1007832 | 2007-11-15 18:05:47 -0500 | [diff] [blame] | 2091 | (iw_handler) lbs_set_scan, /* SIOCSIWSCAN */ |
| 2092 | (iw_handler) lbs_get_scan, /* SIOCGIWSCAN */ |
| 2093 | (iw_handler) lbs_set_essid, /* SIOCSIWESSID */ |
| 2094 | (iw_handler) lbs_get_essid, /* SIOCGIWESSID */ |
| 2095 | (iw_handler) lbs_set_nick, /* SIOCSIWNICKN */ |
| 2096 | (iw_handler) lbs_get_nick, /* SIOCGIWNICKN */ |
Marcelo Tosatti | 876c9d3 | 2007-02-10 12:25:27 -0200 | [diff] [blame] | 2097 | (iw_handler) NULL, /* -- hole -- */ |
| 2098 | (iw_handler) NULL, /* -- hole -- */ |
Holger Schurig | 1007832 | 2007-11-15 18:05:47 -0500 | [diff] [blame] | 2099 | (iw_handler) lbs_set_rate, /* SIOCSIWRATE */ |
| 2100 | (iw_handler) lbs_get_rate, /* SIOCGIWRATE */ |
| 2101 | (iw_handler) lbs_set_rts, /* SIOCSIWRTS */ |
| 2102 | (iw_handler) lbs_get_rts, /* SIOCGIWRTS */ |
| 2103 | (iw_handler) lbs_set_frag, /* SIOCSIWFRAG */ |
| 2104 | (iw_handler) lbs_get_frag, /* SIOCGIWFRAG */ |
| 2105 | (iw_handler) lbs_set_txpow, /* SIOCSIWTXPOW */ |
| 2106 | (iw_handler) lbs_get_txpow, /* SIOCGIWTXPOW */ |
| 2107 | (iw_handler) lbs_set_retry, /* SIOCSIWRETRY */ |
| 2108 | (iw_handler) lbs_get_retry, /* SIOCGIWRETRY */ |
| 2109 | (iw_handler) lbs_set_encode, /* SIOCSIWENCODE */ |
| 2110 | (iw_handler) lbs_get_encode, /* SIOCGIWENCODE */ |
| 2111 | (iw_handler) lbs_set_power, /* SIOCSIWPOWER */ |
| 2112 | (iw_handler) lbs_get_power, /* SIOCGIWPOWER */ |
Marcelo Tosatti | 876c9d3 | 2007-02-10 12:25:27 -0200 | [diff] [blame] | 2113 | (iw_handler) NULL, /* -- hole -- */ |
| 2114 | (iw_handler) NULL, /* -- hole -- */ |
Holger Schurig | 1007832 | 2007-11-15 18:05:47 -0500 | [diff] [blame] | 2115 | (iw_handler) lbs_set_genie, /* SIOCSIWGENIE */ |
| 2116 | (iw_handler) lbs_get_genie, /* SIOCGIWGENIE */ |
| 2117 | (iw_handler) lbs_set_auth, /* SIOCSIWAUTH */ |
| 2118 | (iw_handler) lbs_get_auth, /* SIOCGIWAUTH */ |
| 2119 | (iw_handler) lbs_set_encodeext,/* SIOCSIWENCODEEXT */ |
| 2120 | (iw_handler) lbs_get_encodeext,/* SIOCGIWENCODEEXT */ |
Marcelo Tosatti | 876c9d3 | 2007-02-10 12:25:27 -0200 | [diff] [blame] | 2121 | (iw_handler) NULL, /* SIOCSIWPMKSA */ |
| 2122 | }; |
| 2123 | |
Luis Carlos Cobo Rus | f5e05b6 | 2007-05-25 23:08:34 -0400 | [diff] [blame] | 2124 | static const iw_handler mesh_wlan_handler[] = { |
| 2125 | (iw_handler) NULL, /* SIOCSIWCOMMIT */ |
Holger Schurig | 1007832 | 2007-11-15 18:05:47 -0500 | [diff] [blame] | 2126 | (iw_handler) lbs_get_name, /* SIOCGIWNAME */ |
Luis Carlos Cobo Rus | f5e05b6 | 2007-05-25 23:08:34 -0400 | [diff] [blame] | 2127 | (iw_handler) NULL, /* SIOCSIWNWID */ |
| 2128 | (iw_handler) NULL, /* SIOCGIWNWID */ |
David Woodhouse | 823eaa2 | 2007-12-11 19:56:28 -0500 | [diff] [blame] | 2129 | (iw_handler) lbs_mesh_set_freq, /* SIOCSIWFREQ */ |
Holger Schurig | 1007832 | 2007-11-15 18:05:47 -0500 | [diff] [blame] | 2130 | (iw_handler) lbs_get_freq, /* SIOCGIWFREQ */ |
Luis Carlos Cobo Rus | f5e05b6 | 2007-05-25 23:08:34 -0400 | [diff] [blame] | 2131 | (iw_handler) NULL, /* SIOCSIWMODE */ |
| 2132 | (iw_handler) mesh_wlan_get_mode, /* SIOCGIWMODE */ |
| 2133 | (iw_handler) NULL, /* SIOCSIWSENS */ |
| 2134 | (iw_handler) NULL, /* SIOCGIWSENS */ |
| 2135 | (iw_handler) NULL, /* SIOCSIWRANGE */ |
Holger Schurig | 1007832 | 2007-11-15 18:05:47 -0500 | [diff] [blame] | 2136 | (iw_handler) lbs_get_range, /* SIOCGIWRANGE */ |
Luis Carlos Cobo Rus | f5e05b6 | 2007-05-25 23:08:34 -0400 | [diff] [blame] | 2137 | (iw_handler) NULL, /* SIOCSIWPRIV */ |
| 2138 | (iw_handler) NULL, /* SIOCGIWPRIV */ |
| 2139 | (iw_handler) NULL, /* SIOCSIWSTATS */ |
| 2140 | (iw_handler) NULL, /* SIOCGIWSTATS */ |
| 2141 | iw_handler_set_spy, /* SIOCSIWSPY */ |
| 2142 | iw_handler_get_spy, /* SIOCGIWSPY */ |
| 2143 | iw_handler_set_thrspy, /* SIOCSIWTHRSPY */ |
| 2144 | iw_handler_get_thrspy, /* SIOCGIWTHRSPY */ |
| 2145 | (iw_handler) NULL, /* SIOCSIWAP */ |
| 2146 | (iw_handler) NULL, /* SIOCGIWAP */ |
| 2147 | (iw_handler) NULL, /* SIOCSIWMLME */ |
| 2148 | (iw_handler) NULL, /* SIOCGIWAPLIST - deprecated */ |
Holger Schurig | 1007832 | 2007-11-15 18:05:47 -0500 | [diff] [blame] | 2149 | (iw_handler) lbs_set_scan, /* SIOCSIWSCAN */ |
| 2150 | (iw_handler) lbs_get_scan, /* SIOCGIWSCAN */ |
David Woodhouse | f5956bf | 2007-12-11 19:30:57 -0500 | [diff] [blame] | 2151 | (iw_handler) lbs_mesh_set_essid,/* SIOCSIWESSID */ |
| 2152 | (iw_handler) lbs_mesh_get_essid,/* SIOCGIWESSID */ |
Luis Carlos Cobo Rus | f5e05b6 | 2007-05-25 23:08:34 -0400 | [diff] [blame] | 2153 | (iw_handler) NULL, /* SIOCSIWNICKN */ |
| 2154 | (iw_handler) mesh_get_nick, /* SIOCGIWNICKN */ |
| 2155 | (iw_handler) NULL, /* -- hole -- */ |
| 2156 | (iw_handler) NULL, /* -- hole -- */ |
Holger Schurig | 1007832 | 2007-11-15 18:05:47 -0500 | [diff] [blame] | 2157 | (iw_handler) lbs_set_rate, /* SIOCSIWRATE */ |
| 2158 | (iw_handler) lbs_get_rate, /* SIOCGIWRATE */ |
| 2159 | (iw_handler) lbs_set_rts, /* SIOCSIWRTS */ |
| 2160 | (iw_handler) lbs_get_rts, /* SIOCGIWRTS */ |
| 2161 | (iw_handler) lbs_set_frag, /* SIOCSIWFRAG */ |
| 2162 | (iw_handler) lbs_get_frag, /* SIOCGIWFRAG */ |
| 2163 | (iw_handler) lbs_set_txpow, /* SIOCSIWTXPOW */ |
| 2164 | (iw_handler) lbs_get_txpow, /* SIOCGIWTXPOW */ |
| 2165 | (iw_handler) lbs_set_retry, /* SIOCSIWRETRY */ |
| 2166 | (iw_handler) lbs_get_retry, /* SIOCGIWRETRY */ |
| 2167 | (iw_handler) lbs_set_encode, /* SIOCSIWENCODE */ |
| 2168 | (iw_handler) lbs_get_encode, /* SIOCGIWENCODE */ |
| 2169 | (iw_handler) lbs_set_power, /* SIOCSIWPOWER */ |
| 2170 | (iw_handler) lbs_get_power, /* SIOCGIWPOWER */ |
Luis Carlos Cobo Rus | f5e05b6 | 2007-05-25 23:08:34 -0400 | [diff] [blame] | 2171 | (iw_handler) NULL, /* -- hole -- */ |
| 2172 | (iw_handler) NULL, /* -- hole -- */ |
Holger Schurig | 1007832 | 2007-11-15 18:05:47 -0500 | [diff] [blame] | 2173 | (iw_handler) lbs_set_genie, /* SIOCSIWGENIE */ |
| 2174 | (iw_handler) lbs_get_genie, /* SIOCGIWGENIE */ |
| 2175 | (iw_handler) lbs_set_auth, /* SIOCSIWAUTH */ |
| 2176 | (iw_handler) lbs_get_auth, /* SIOCGIWAUTH */ |
| 2177 | (iw_handler) lbs_set_encodeext,/* SIOCSIWENCODEEXT */ |
| 2178 | (iw_handler) lbs_get_encodeext,/* SIOCGIWENCODEEXT */ |
Luis Carlos Cobo Rus | f5e05b6 | 2007-05-25 23:08:34 -0400 | [diff] [blame] | 2179 | (iw_handler) NULL, /* SIOCSIWPMKSA */ |
| 2180 | }; |
Holger Schurig | 1007832 | 2007-11-15 18:05:47 -0500 | [diff] [blame] | 2181 | struct iw_handler_def lbs_handler_def = { |
| 2182 | .num_standard = ARRAY_SIZE(lbs_handler), |
| 2183 | .standard = (iw_handler *) lbs_handler, |
| 2184 | .get_wireless_stats = lbs_get_wireless_stats, |
Marcelo Tosatti | 876c9d3 | 2007-02-10 12:25:27 -0200 | [diff] [blame] | 2185 | }; |
Luis Carlos Cobo Rus | f5e05b6 | 2007-05-25 23:08:34 -0400 | [diff] [blame] | 2186 | |
| 2187 | struct iw_handler_def mesh_handler_def = { |
Denis Cheng | ff8ac60 | 2007-09-02 18:30:18 +0800 | [diff] [blame] | 2188 | .num_standard = ARRAY_SIZE(mesh_wlan_handler), |
Luis Carlos Cobo Rus | f5e05b6 | 2007-05-25 23:08:34 -0400 | [diff] [blame] | 2189 | .standard = (iw_handler *) mesh_wlan_handler, |
Holger Schurig | 1007832 | 2007-11-15 18:05:47 -0500 | [diff] [blame] | 2190 | .get_wireless_stats = lbs_get_wireless_stats, |
Luis Carlos Cobo Rus | f5e05b6 | 2007-05-25 23:08:34 -0400 | [diff] [blame] | 2191 | }; |