aboutsummaryrefslogtreecommitdiffstats
path: root/net/mac80211
diff options
context:
space:
mode:
Diffstat (limited to 'net/mac80211')
-rw-r--r--net/mac80211/wext.c135
1 files changed, 16 insertions, 119 deletions
diff --git a/net/mac80211/wext.c b/net/mac80211/wext.c
index a8d4b6171916..f6924fc065d3 100644
--- a/net/mac80211/wext.c
+++ b/net/mac80211/wext.c
@@ -144,124 +144,6 @@ static int ieee80211_ioctl_siwgenie(struct net_device *dev,
144 return -EOPNOTSUPP; 144 return -EOPNOTSUPP;
145} 145}
146 146
147static u8 ieee80211_get_wstats_flags(struct ieee80211_local *local)
148{
149 u8 wstats_flags = 0;
150
151 wstats_flags |= local->hw.flags & (IEEE80211_HW_SIGNAL_UNSPEC |
152 IEEE80211_HW_SIGNAL_DBM) ?
153 IW_QUAL_QUAL_UPDATED : IW_QUAL_QUAL_INVALID;
154 wstats_flags |= local->hw.flags & IEEE80211_HW_NOISE_DBM ?
155 IW_QUAL_NOISE_UPDATED : IW_QUAL_NOISE_INVALID;
156 if (local->hw.flags & IEEE80211_HW_SIGNAL_DBM)
157 wstats_flags |= IW_QUAL_DBM;
158
159 return wstats_flags;
160}
161
162static int ieee80211_ioctl_giwrange(struct net_device *dev,
163 struct iw_request_info *info,
164 struct iw_point *data, char *extra)
165{
166 struct ieee80211_local *local = wdev_priv(dev->ieee80211_ptr);
167 struct iw_range *range = (struct iw_range *) extra;
168 enum ieee80211_band band;
169 int c = 0;
170
171 data->length = sizeof(struct iw_range);
172 memset(range, 0, sizeof(struct iw_range));
173
174 range->we_version_compiled = WIRELESS_EXT;
175 range->we_version_source = 21;
176 range->retry_capa = IW_RETRY_LIMIT;
177 range->retry_flags = IW_RETRY_LIMIT;
178 range->min_retry = 0;
179 range->max_retry = 255;
180 range->min_rts = 0;
181 range->max_rts = 2347;
182 range->min_frag = 256;
183 range->max_frag = 2346;
184
185 range->encoding_size[0] = 5;
186 range->encoding_size[1] = 13;
187 range->num_encoding_sizes = 2;
188 range->max_encoding_tokens = NUM_DEFAULT_KEYS;
189
190 /* cfg80211 requires this, and enforces 0..100 */
191 if (local->hw.flags & IEEE80211_HW_SIGNAL_UNSPEC)
192 range->max_qual.level = 100;
193 else if (local->hw.flags & IEEE80211_HW_SIGNAL_DBM)
194 range->max_qual.level = -110;
195 else
196 range->max_qual.level = 0;
197
198 if (local->hw.flags & IEEE80211_HW_NOISE_DBM)
199 range->max_qual.noise = -110;
200 else
201 range->max_qual.noise = 0;
202
203 range->max_qual.updated = ieee80211_get_wstats_flags(local);
204
205 if (local->hw.flags & IEEE80211_HW_SIGNAL_DBM) {
206 /*
207 * cfg80211 assumes -110 to -40 dBm and clamps to that range
208 * for qual.qual, so tell userspace this is what we give it
209 * but take into account that we have to start from 0.
210 */
211 range->max_qual.qual = 70;
212 range->avg_qual.qual = 35;
213 } else {
214 /*
215 * cfg80211 just uses the level value for qual too, and it
216 * requires the level value to be 0 .. 100.
217 */
218 range->max_qual.qual = 100;
219 range->avg_qual.qual = 50;
220 }
221 /* not always true but better than nothing */
222 range->avg_qual.level = range->max_qual.level / 2;
223 range->avg_qual.noise = range->max_qual.noise / 2;
224 range->avg_qual.updated = ieee80211_get_wstats_flags(local);
225
226 range->enc_capa = IW_ENC_CAPA_WPA | IW_ENC_CAPA_WPA2 |
227 IW_ENC_CAPA_CIPHER_TKIP | IW_ENC_CAPA_CIPHER_CCMP;
228
229
230 for (band = 0; band < IEEE80211_NUM_BANDS; band ++) {
231 int i;
232 struct ieee80211_supported_band *sband;
233
234 sband = local->hw.wiphy->bands[band];
235
236 if (!sband)
237 continue;
238
239 for (i = 0; i < sband->n_channels && c < IW_MAX_FREQUENCIES; i++) {
240 struct ieee80211_channel *chan = &sband->channels[i];
241
242 if (!(chan->flags & IEEE80211_CHAN_DISABLED)) {
243 range->freq[c].i =
244 ieee80211_frequency_to_channel(
245 chan->center_freq);
246 range->freq[c].m = chan->center_freq;
247 range->freq[c].e = 6;
248 c++;
249 }
250 }
251 }
252 range->num_channels = c;
253 range->num_frequency = c;
254
255 IW_EVENT_CAPA_SET_KERNEL(range->event_capa);
256 IW_EVENT_CAPA_SET(range->event_capa, SIOCGIWAP);
257 IW_EVENT_CAPA_SET(range->event_capa, SIOCGIWSCAN);
258
259 range->scan_capa |= IW_SCAN_CAPA_ESSID;
260
261 return 0;
262}
263
264
265static int ieee80211_ioctl_siwfreq(struct net_device *dev, 147static int ieee80211_ioctl_siwfreq(struct net_device *dev,
266 struct iw_request_info *info, 148 struct iw_request_info *info,
267 struct iw_freq *freq, char *extra) 149 struct iw_freq *freq, char *extra)
@@ -1004,6 +886,21 @@ static int ieee80211_ioctl_siwauth(struct net_device *dev,
1004 return ret; 886 return ret;
1005} 887}
1006 888
889static u8 ieee80211_get_wstats_flags(struct ieee80211_local *local)
890{
891 u8 wstats_flags = 0;
892
893 wstats_flags |= local->hw.flags & (IEEE80211_HW_SIGNAL_UNSPEC |
894 IEEE80211_HW_SIGNAL_DBM) ?
895 IW_QUAL_QUAL_UPDATED : IW_QUAL_QUAL_INVALID;
896 wstats_flags |= local->hw.flags & IEEE80211_HW_NOISE_DBM ?
897 IW_QUAL_NOISE_UPDATED : IW_QUAL_NOISE_INVALID;
898 if (local->hw.flags & IEEE80211_HW_SIGNAL_DBM)
899 wstats_flags |= IW_QUAL_DBM;
900
901 return wstats_flags;
902}
903
1007/* Get wireless statistics. Called by /proc/net/wireless and by SIOCGIWSTATS */ 904/* Get wireless statistics. Called by /proc/net/wireless and by SIOCGIWSTATS */
1008static struct iw_statistics *ieee80211_get_wireless_stats(struct net_device *dev) 905static struct iw_statistics *ieee80211_get_wireless_stats(struct net_device *dev)
1009{ 906{
@@ -1149,7 +1046,7 @@ static const iw_handler ieee80211_handler[] =
1149 (iw_handler) NULL, /* SIOCSIWSENS */ 1046 (iw_handler) NULL, /* SIOCSIWSENS */
1150 (iw_handler) NULL, /* SIOCGIWSENS */ 1047 (iw_handler) NULL, /* SIOCGIWSENS */
1151 (iw_handler) NULL /* not used */, /* SIOCSIWRANGE */ 1048 (iw_handler) NULL /* not used */, /* SIOCSIWRANGE */
1152 (iw_handler) ieee80211_ioctl_giwrange, /* SIOCGIWRANGE */ 1049 (iw_handler) cfg80211_wext_giwrange, /* SIOCGIWRANGE */
1153 (iw_handler) NULL /* not used */, /* SIOCSIWPRIV */ 1050 (iw_handler) NULL /* not used */, /* SIOCSIWPRIV */
1154 (iw_handler) NULL /* kernel code */, /* SIOCGIWPRIV */ 1051 (iw_handler) NULL /* kernel code */, /* SIOCGIWPRIV */
1155 (iw_handler) NULL /* not used */, /* SIOCSIWSTATS */ 1052 (iw_handler) NULL /* not used */, /* SIOCSIWSTATS */