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