2 * cfg80211 - wext compat code
4 * This is temporary code until all wireless functionality is migrated
5 * into cfg80211, when that happens all the exports here go away and
6 * we directly assign the wireless handlers of wireless interfaces.
8 * Copyright 2008 Johannes Berg <johannes@sipsolutions.net>
11 #include <linux/wireless.h>
12 #include <linux/nl80211.h>
13 #include <net/iw_handler.h>
14 #include <net/wireless.h>
15 #include <net/cfg80211.h>
18 int cfg80211_wext_giwname(struct net_device
*dev
,
19 struct iw_request_info
*info
,
20 char *name
, char *extra
)
22 struct wireless_dev
*wdev
= dev
->ieee80211_ptr
;
23 struct ieee80211_supported_band
*sband
;
24 bool is_ht
= false, is_a
= false, is_b
= false, is_g
= false;
29 sband
= wdev
->wiphy
->bands
[IEEE80211_BAND_5GHZ
];
32 is_ht
|= sband
->ht_cap
.ht_supported
;
35 sband
= wdev
->wiphy
->bands
[IEEE80211_BAND_2GHZ
];
38 /* Check for mandatory rates */
39 for (i
= 0; i
< sband
->n_bitrates
; i
++) {
40 if (sband
->bitrates
[i
].bitrate
== 10)
42 if (sband
->bitrates
[i
].bitrate
== 60)
45 is_ht
|= sband
->ht_cap
.ht_supported
;
48 strcpy(name
, "IEEE 802.11");
60 EXPORT_SYMBOL(cfg80211_wext_giwname
);
62 int cfg80211_wext_siwmode(struct net_device
*dev
, struct iw_request_info
*info
,
63 u32
*mode
, char *extra
)
65 struct wireless_dev
*wdev
= dev
->ieee80211_ptr
;
66 struct cfg80211_registered_device
*rdev
;
67 struct vif_params vifparams
;
68 enum nl80211_iftype type
;
73 rdev
= wiphy_to_dev(wdev
->wiphy
);
75 if (!rdev
->ops
->change_virtual_intf
)
78 /* don't support changing VLANs, you just re-create them */
79 if (wdev
->iftype
== NL80211_IFTYPE_AP_VLAN
)
84 type
= NL80211_IFTYPE_STATION
;
87 type
= NL80211_IFTYPE_ADHOC
;
90 type
= NL80211_IFTYPE_WDS
;
93 type
= NL80211_IFTYPE_MONITOR
;
99 memset(&vifparams
, 0, sizeof(vifparams
));
101 return rdev
->ops
->change_virtual_intf(wdev
->wiphy
, dev
->ifindex
, type
,
104 EXPORT_SYMBOL(cfg80211_wext_siwmode
);
106 int cfg80211_wext_giwmode(struct net_device
*dev
, struct iw_request_info
*info
,
107 u32
*mode
, char *extra
)
109 struct wireless_dev
*wdev
= dev
->ieee80211_ptr
;
114 switch (wdev
->iftype
) {
115 case NL80211_IFTYPE_AP
:
116 *mode
= IW_MODE_MASTER
;
118 case NL80211_IFTYPE_STATION
:
119 *mode
= IW_MODE_INFRA
;
121 case NL80211_IFTYPE_ADHOC
:
122 *mode
= IW_MODE_ADHOC
;
124 case NL80211_IFTYPE_MONITOR
:
125 *mode
= IW_MODE_MONITOR
;
127 case NL80211_IFTYPE_WDS
:
128 *mode
= IW_MODE_REPEAT
;
130 case NL80211_IFTYPE_AP_VLAN
:
131 *mode
= IW_MODE_SECOND
; /* FIXME */
134 *mode
= IW_MODE_AUTO
;
139 EXPORT_SYMBOL(cfg80211_wext_giwmode
);
142 int cfg80211_wext_giwrange(struct net_device
*dev
,
143 struct iw_request_info
*info
,
144 struct iw_point
*data
, char *extra
)
146 struct wireless_dev
*wdev
= dev
->ieee80211_ptr
;
147 struct iw_range
*range
= (struct iw_range
*) extra
;
148 enum ieee80211_band band
;
154 data
->length
= sizeof(struct iw_range
);
155 memset(range
, 0, sizeof(struct iw_range
));
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;
164 range
->max_rts
= 2347;
165 range
->min_frag
= 256;
166 range
->max_frag
= 2346;
168 range
->encoding_size
[0] = 5;
169 range
->encoding_size
[1] = 13;
170 range
->num_encoding_sizes
= 2;
171 range
->max_encoding_tokens
= 4;
173 range
->max_qual
.updated
= IW_QUAL_NOISE_INVALID
;
175 switch (wdev
->wiphy
->signal_type
) {
176 case CFG80211_SIGNAL_TYPE_NONE
:
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
;
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
;
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
;
199 range
->enc_capa
= IW_ENC_CAPA_WPA
| IW_ENC_CAPA_WPA2
|
200 IW_ENC_CAPA_CIPHER_TKIP
| IW_ENC_CAPA_CIPHER_CCMP
;
203 for (band
= 0; band
< IEEE80211_NUM_BANDS
; band
++) {
205 struct ieee80211_supported_band
*sband
;
207 sband
= wdev
->wiphy
->bands
[band
];
212 for (i
= 0; i
< sband
->n_channels
&& c
< IW_MAX_FREQUENCIES
; i
++) {
213 struct ieee80211_channel
*chan
= &sband
->channels
[i
];
215 if (!(chan
->flags
& IEEE80211_CHAN_DISABLED
)) {
217 ieee80211_frequency_to_channel(
219 range
->freq
[c
].m
= chan
->center_freq
;
220 range
->freq
[c
].e
= 6;
225 range
->num_channels
= c
;
226 range
->num_frequency
= c
;
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
);
232 range
->scan_capa
|= IW_SCAN_CAPA_ESSID
;
236 EXPORT_SYMBOL(cfg80211_wext_giwrange
);