diff options
-rw-r--r-- | include/net/cfg80211.h | 3 | ||||
-rw-r--r-- | net/mac80211/wext.c | 135 | ||||
-rw-r--r-- | net/wireless/wext-compat.c | 97 |
3 files changed, 116 insertions, 119 deletions
diff --git a/include/net/cfg80211.h b/include/net/cfg80211.h index e0312746a8cc..43ac90df4164 100644 --- a/include/net/cfg80211.h +++ b/include/net/cfg80211.h | |||
@@ -765,6 +765,9 @@ int cfg80211_wext_siwscan(struct net_device *dev, | |||
765 | int cfg80211_wext_giwscan(struct net_device *dev, | 765 | int cfg80211_wext_giwscan(struct net_device *dev, |
766 | struct iw_request_info *info, | 766 | struct iw_request_info *info, |
767 | struct iw_point *data, char *extra); | 767 | struct iw_point *data, char *extra); |
768 | int cfg80211_wext_giwrange(struct net_device *dev, | ||
769 | struct iw_request_info *info, | ||
770 | struct iw_point *data, char *extra); | ||
768 | 771 | ||
769 | /** | 772 | /** |
770 | * cfg80211_scan_done - notify that scan finished | 773 | * cfg80211_scan_done - notify that scan finished |
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 | ||
147 | static 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 | |||
162 | static 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 | |||
265 | static int ieee80211_ioctl_siwfreq(struct net_device *dev, | 147 | static 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 | ||
889 | static 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 */ |
1008 | static struct iw_statistics *ieee80211_get_wireless_stats(struct net_device *dev) | 905 | static 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 */ |
diff --git a/net/wireless/wext-compat.c b/net/wireless/wext-compat.c index 58e489fd4aed..b84a9b4fe96a 100644 --- a/net/wireless/wext-compat.c +++ b/net/wireless/wext-compat.c | |||
@@ -137,3 +137,100 @@ int cfg80211_wext_giwmode(struct net_device *dev, struct iw_request_info *info, | |||
137 | return 0; | 137 | return 0; |
138 | } | 138 | } |
139 | EXPORT_SYMBOL(cfg80211_wext_giwmode); | 139 | EXPORT_SYMBOL(cfg80211_wext_giwmode); |
140 | |||
141 | |||
142 | int cfg80211_wext_giwrange(struct net_device *dev, | ||
143 | struct iw_request_info *info, | ||
144 | struct iw_point *data, char *extra) | ||
145 | { | ||
146 | struct wireless_dev *wdev = dev->ieee80211_ptr; | ||
147 | struct iw_range *range = (struct iw_range *) extra; | ||
148 | enum ieee80211_band band; | ||
149 | int c = 0; | ||
150 | |||
151 | if (!wdev) | ||
152 | return -EOPNOTSUPP; | ||
153 | |||
154 | data->length = sizeof(struct iw_range); | ||
155 | memset(range, 0, sizeof(struct iw_range)); | ||
156 | |||
157 | range->we_version_compiled = WIRELESS_EXT; | ||
158 | range->we_version_source = 21; | ||
159 | range->retry_capa = IW_RETRY_LIMIT; | ||
160 | range->retry_flags = IW_RETRY_LIMIT; | ||
161 | range->min_retry = 0; | ||
162 | range->max_retry = 255; | ||
163 | range->min_rts = 0; | ||
164 | range->max_rts = 2347; | ||
165 | range->min_frag = 256; | ||
166 | range->max_frag = 2346; | ||
167 | |||
168 | range->encoding_size[0] = 5; | ||
169 | range->encoding_size[1] = 13; | ||
170 | range->num_encoding_sizes = 2; | ||
171 | range->max_encoding_tokens = 4; | ||
172 | |||
173 | range->max_qual.updated = IW_QUAL_NOISE_INVALID; | ||
174 | |||
175 | switch (wdev->wiphy->signal_type) { | ||
176 | case CFG80211_SIGNAL_TYPE_NONE: | ||
177 | break; | ||
178 | case CFG80211_SIGNAL_TYPE_MBM: | ||
179 | range->max_qual.level = -110; | ||
180 | range->max_qual.qual = 70; | ||
181 | range->avg_qual.qual = 35; | ||
182 | range->max_qual.updated |= IW_QUAL_DBM; | ||
183 | range->max_qual.updated |= IW_QUAL_QUAL_UPDATED; | ||
184 | range->max_qual.updated |= IW_QUAL_LEVEL_UPDATED; | ||
185 | break; | ||
186 | case CFG80211_SIGNAL_TYPE_UNSPEC: | ||
187 | range->max_qual.level = 100; | ||
188 | range->max_qual.qual = 100; | ||
189 | range->avg_qual.qual = 50; | ||
190 | range->max_qual.updated |= IW_QUAL_QUAL_UPDATED; | ||
191 | range->max_qual.updated |= IW_QUAL_LEVEL_UPDATED; | ||
192 | break; | ||
193 | } | ||
194 | |||
195 | range->avg_qual.level = range->max_qual.level / 2; | ||
196 | range->avg_qual.noise = range->max_qual.noise / 2; | ||
197 | range->avg_qual.updated = range->max_qual.updated; | ||
198 | |||
199 | range->enc_capa = IW_ENC_CAPA_WPA | IW_ENC_CAPA_WPA2 | | ||
200 | IW_ENC_CAPA_CIPHER_TKIP | IW_ENC_CAPA_CIPHER_CCMP; | ||
201 | |||
202 | |||
203 | for (band = 0; band < IEEE80211_NUM_BANDS; band ++) { | ||
204 | int i; | ||
205 | struct ieee80211_supported_band *sband; | ||
206 | |||
207 | sband = wdev->wiphy->bands[band]; | ||
208 | |||
209 | if (!sband) | ||
210 | continue; | ||
211 | |||
212 | for (i = 0; i < sband->n_channels && c < IW_MAX_FREQUENCIES; i++) { | ||
213 | struct ieee80211_channel *chan = &sband->channels[i]; | ||
214 | |||
215 | if (!(chan->flags & IEEE80211_CHAN_DISABLED)) { | ||
216 | range->freq[c].i = | ||
217 | ieee80211_frequency_to_channel( | ||
218 | chan->center_freq); | ||
219 | range->freq[c].m = chan->center_freq; | ||
220 | range->freq[c].e = 6; | ||
221 | c++; | ||
222 | } | ||
223 | } | ||
224 | } | ||
225 | range->num_channels = c; | ||
226 | range->num_frequency = c; | ||
227 | |||
228 | IW_EVENT_CAPA_SET_KERNEL(range->event_capa); | ||
229 | IW_EVENT_CAPA_SET(range->event_capa, SIOCGIWAP); | ||
230 | IW_EVENT_CAPA_SET(range->event_capa, SIOCGIWSCAN); | ||
231 | |||
232 | range->scan_capa |= IW_SCAN_CAPA_ESSID; | ||
233 | |||
234 | return 0; | ||
235 | } | ||
236 | EXPORT_SYMBOL(cfg80211_wext_giwrange); | ||