diff options
author | David S. Miller <davem@davemloft.net> | 2008-06-16 21:50:49 -0400 |
---|---|---|
committer | David S. Miller <davem@davemloft.net> | 2008-06-16 21:50:49 -0400 |
commit | ccc580571cf0799d0460a085a7632b77753f083e (patch) | |
tree | 018e0f83776b089b1f272694132688ac93be25b4 /net/mac80211/mlme.c | |
parent | 0f5cabba49021d36e9f76bd97d7fa0f4a408063f (diff) |
wext: Emit event stream entries correctly when compat.
Three major portions to this change:
1) Add IW_EV_COMPAT_LCP_LEN, IW_EV_COMPAT_POINT_OFF,
and IW_EV_COMPAT_POINT_LEN helper defines.
2) Delete iw_stream_check_add_*(), they are unused.
3) Add iw_request_info argument to iwe_stream_add_*(), and use it to
size the event and pointer lengths correctly depending upon whether
IW_REQUEST_FLAG_COMPAT is set or not.
4) The mechanical transformations to the drivers and wireless stack
bits to get the iw_request_info passed down into the routines
modified in #3. Also, explicit references to IW_EV_LCP_LEN are
replaced with iwe_stream_lcp_len(info).
With a lot of help and bug fixes from Masakazu Mokuno.
Signed-off-by: David S. Miller <davem@davemloft.net>
Diffstat (limited to 'net/mac80211/mlme.c')
-rw-r--r-- | net/mac80211/mlme.c | 66 |
1 files changed, 38 insertions, 28 deletions
diff --git a/net/mac80211/mlme.c b/net/mac80211/mlme.c index 55659a730dc1..e06d6450f215 100644 --- a/net/mac80211/mlme.c +++ b/net/mac80211/mlme.c | |||
@@ -4087,6 +4087,7 @@ int ieee80211_sta_req_scan(struct net_device *dev, u8 *ssid, size_t ssid_len) | |||
4087 | 4087 | ||
4088 | static char * | 4088 | static char * |
4089 | ieee80211_sta_scan_result(struct net_device *dev, | 4089 | ieee80211_sta_scan_result(struct net_device *dev, |
4090 | struct iw_request_info *info, | ||
4090 | struct ieee80211_sta_bss *bss, | 4091 | struct ieee80211_sta_bss *bss, |
4091 | char *current_ev, char *end_buf) | 4092 | char *current_ev, char *end_buf) |
4092 | { | 4093 | { |
@@ -4101,7 +4102,7 @@ ieee80211_sta_scan_result(struct net_device *dev, | |||
4101 | iwe.cmd = SIOCGIWAP; | 4102 | iwe.cmd = SIOCGIWAP; |
4102 | iwe.u.ap_addr.sa_family = ARPHRD_ETHER; | 4103 | iwe.u.ap_addr.sa_family = ARPHRD_ETHER; |
4103 | memcpy(iwe.u.ap_addr.sa_data, bss->bssid, ETH_ALEN); | 4104 | memcpy(iwe.u.ap_addr.sa_data, bss->bssid, ETH_ALEN); |
4104 | current_ev = iwe_stream_add_event(current_ev, end_buf, &iwe, | 4105 | current_ev = iwe_stream_add_event(info, current_ev, end_buf, &iwe, |
4105 | IW_EV_ADDR_LEN); | 4106 | IW_EV_ADDR_LEN); |
4106 | 4107 | ||
4107 | memset(&iwe, 0, sizeof(iwe)); | 4108 | memset(&iwe, 0, sizeof(iwe)); |
@@ -4109,13 +4110,13 @@ ieee80211_sta_scan_result(struct net_device *dev, | |||
4109 | if (bss_mesh_cfg(bss)) { | 4110 | if (bss_mesh_cfg(bss)) { |
4110 | iwe.u.data.length = bss_mesh_id_len(bss); | 4111 | iwe.u.data.length = bss_mesh_id_len(bss); |
4111 | iwe.u.data.flags = 1; | 4112 | iwe.u.data.flags = 1; |
4112 | current_ev = iwe_stream_add_point(current_ev, end_buf, &iwe, | 4113 | current_ev = iwe_stream_add_point(info, current_ev, end_buf, |
4113 | bss_mesh_id(bss)); | 4114 | &iwe, bss_mesh_id(bss)); |
4114 | } else { | 4115 | } else { |
4115 | iwe.u.data.length = bss->ssid_len; | 4116 | iwe.u.data.length = bss->ssid_len; |
4116 | iwe.u.data.flags = 1; | 4117 | iwe.u.data.flags = 1; |
4117 | current_ev = iwe_stream_add_point(current_ev, end_buf, &iwe, | 4118 | current_ev = iwe_stream_add_point(info, current_ev, end_buf, |
4118 | bss->ssid); | 4119 | &iwe, bss->ssid); |
4119 | } | 4120 | } |
4120 | 4121 | ||
4121 | if (bss->capability & (WLAN_CAPABILITY_ESS | WLAN_CAPABILITY_IBSS) | 4122 | if (bss->capability & (WLAN_CAPABILITY_ESS | WLAN_CAPABILITY_IBSS) |
@@ -4128,22 +4129,22 @@ ieee80211_sta_scan_result(struct net_device *dev, | |||
4128 | iwe.u.mode = IW_MODE_MASTER; | 4129 | iwe.u.mode = IW_MODE_MASTER; |
4129 | else | 4130 | else |
4130 | iwe.u.mode = IW_MODE_ADHOC; | 4131 | iwe.u.mode = IW_MODE_ADHOC; |
4131 | current_ev = iwe_stream_add_event(current_ev, end_buf, &iwe, | 4132 | current_ev = iwe_stream_add_event(info, current_ev, end_buf, |
4132 | IW_EV_UINT_LEN); | 4133 | &iwe, IW_EV_UINT_LEN); |
4133 | } | 4134 | } |
4134 | 4135 | ||
4135 | memset(&iwe, 0, sizeof(iwe)); | 4136 | memset(&iwe, 0, sizeof(iwe)); |
4136 | iwe.cmd = SIOCGIWFREQ; | 4137 | iwe.cmd = SIOCGIWFREQ; |
4137 | iwe.u.freq.m = ieee80211_frequency_to_channel(bss->freq); | 4138 | iwe.u.freq.m = ieee80211_frequency_to_channel(bss->freq); |
4138 | iwe.u.freq.e = 0; | 4139 | iwe.u.freq.e = 0; |
4139 | current_ev = iwe_stream_add_event(current_ev, end_buf, &iwe, | 4140 | current_ev = iwe_stream_add_event(info, current_ev, end_buf, &iwe, |
4140 | IW_EV_FREQ_LEN); | 4141 | IW_EV_FREQ_LEN); |
4141 | 4142 | ||
4142 | memset(&iwe, 0, sizeof(iwe)); | 4143 | memset(&iwe, 0, sizeof(iwe)); |
4143 | iwe.cmd = SIOCGIWFREQ; | 4144 | iwe.cmd = SIOCGIWFREQ; |
4144 | iwe.u.freq.m = bss->freq; | 4145 | iwe.u.freq.m = bss->freq; |
4145 | iwe.u.freq.e = 6; | 4146 | iwe.u.freq.e = 6; |
4146 | current_ev = iwe_stream_add_event(current_ev, end_buf, &iwe, | 4147 | current_ev = iwe_stream_add_event(info, current_ev, end_buf, &iwe, |
4147 | IW_EV_FREQ_LEN); | 4148 | IW_EV_FREQ_LEN); |
4148 | memset(&iwe, 0, sizeof(iwe)); | 4149 | memset(&iwe, 0, sizeof(iwe)); |
4149 | iwe.cmd = IWEVQUAL; | 4150 | iwe.cmd = IWEVQUAL; |
@@ -4151,7 +4152,7 @@ ieee80211_sta_scan_result(struct net_device *dev, | |||
4151 | iwe.u.qual.level = bss->signal; | 4152 | iwe.u.qual.level = bss->signal; |
4152 | iwe.u.qual.noise = bss->noise; | 4153 | iwe.u.qual.noise = bss->noise; |
4153 | iwe.u.qual.updated = local->wstats_flags; | 4154 | iwe.u.qual.updated = local->wstats_flags; |
4154 | current_ev = iwe_stream_add_event(current_ev, end_buf, &iwe, | 4155 | current_ev = iwe_stream_add_event(info, current_ev, end_buf, &iwe, |
4155 | IW_EV_QUAL_LEN); | 4156 | IW_EV_QUAL_LEN); |
4156 | 4157 | ||
4157 | memset(&iwe, 0, sizeof(iwe)); | 4158 | memset(&iwe, 0, sizeof(iwe)); |
@@ -4161,35 +4162,36 @@ ieee80211_sta_scan_result(struct net_device *dev, | |||
4161 | else | 4162 | else |
4162 | iwe.u.data.flags = IW_ENCODE_DISABLED; | 4163 | iwe.u.data.flags = IW_ENCODE_DISABLED; |
4163 | iwe.u.data.length = 0; | 4164 | iwe.u.data.length = 0; |
4164 | current_ev = iwe_stream_add_point(current_ev, end_buf, &iwe, ""); | 4165 | current_ev = iwe_stream_add_point(info, current_ev, end_buf, |
4166 | &iwe, ""); | ||
4165 | 4167 | ||
4166 | if (bss && bss->wpa_ie) { | 4168 | if (bss && bss->wpa_ie) { |
4167 | memset(&iwe, 0, sizeof(iwe)); | 4169 | memset(&iwe, 0, sizeof(iwe)); |
4168 | iwe.cmd = IWEVGENIE; | 4170 | iwe.cmd = IWEVGENIE; |
4169 | iwe.u.data.length = bss->wpa_ie_len; | 4171 | iwe.u.data.length = bss->wpa_ie_len; |
4170 | current_ev = iwe_stream_add_point(current_ev, end_buf, &iwe, | 4172 | current_ev = iwe_stream_add_point(info, current_ev, end_buf, |
4171 | bss->wpa_ie); | 4173 | &iwe, bss->wpa_ie); |
4172 | } | 4174 | } |
4173 | 4175 | ||
4174 | if (bss && bss->rsn_ie) { | 4176 | if (bss && bss->rsn_ie) { |
4175 | memset(&iwe, 0, sizeof(iwe)); | 4177 | memset(&iwe, 0, sizeof(iwe)); |
4176 | iwe.cmd = IWEVGENIE; | 4178 | iwe.cmd = IWEVGENIE; |
4177 | iwe.u.data.length = bss->rsn_ie_len; | 4179 | iwe.u.data.length = bss->rsn_ie_len; |
4178 | current_ev = iwe_stream_add_point(current_ev, end_buf, &iwe, | 4180 | current_ev = iwe_stream_add_point(info, current_ev, end_buf, |
4179 | bss->rsn_ie); | 4181 | &iwe, bss->rsn_ie); |
4180 | } | 4182 | } |
4181 | 4183 | ||
4182 | if (bss && bss->ht_ie) { | 4184 | if (bss && bss->ht_ie) { |
4183 | memset(&iwe, 0, sizeof(iwe)); | 4185 | memset(&iwe, 0, sizeof(iwe)); |
4184 | iwe.cmd = IWEVGENIE; | 4186 | iwe.cmd = IWEVGENIE; |
4185 | iwe.u.data.length = bss->ht_ie_len; | 4187 | iwe.u.data.length = bss->ht_ie_len; |
4186 | current_ev = iwe_stream_add_point(current_ev, end_buf, &iwe, | 4188 | current_ev = iwe_stream_add_point(info, current_ev, end_buf, |
4187 | bss->ht_ie); | 4189 | &iwe, bss->ht_ie); |
4188 | } | 4190 | } |
4189 | 4191 | ||
4190 | if (bss && bss->supp_rates_len > 0) { | 4192 | if (bss && bss->supp_rates_len > 0) { |
4191 | /* display all supported rates in readable format */ | 4193 | /* display all supported rates in readable format */ |
4192 | char *p = current_ev + IW_EV_LCP_LEN; | 4194 | char *p = current_ev + iwe_stream_lcp_len(info); |
4193 | int i; | 4195 | int i; |
4194 | 4196 | ||
4195 | memset(&iwe, 0, sizeof(iwe)); | 4197 | memset(&iwe, 0, sizeof(iwe)); |
@@ -4200,7 +4202,7 @@ ieee80211_sta_scan_result(struct net_device *dev, | |||
4200 | for (i = 0; i < bss->supp_rates_len; i++) { | 4202 | for (i = 0; i < bss->supp_rates_len; i++) { |
4201 | iwe.u.bitrate.value = ((bss->supp_rates[i] & | 4203 | iwe.u.bitrate.value = ((bss->supp_rates[i] & |
4202 | 0x7f) * 500000); | 4204 | 0x7f) * 500000); |
4203 | p = iwe_stream_add_value(current_ev, p, | 4205 | p = iwe_stream_add_value(info, current_ev, p, |
4204 | end_buf, &iwe, IW_EV_PARAM_LEN); | 4206 | end_buf, &iwe, IW_EV_PARAM_LEN); |
4205 | } | 4207 | } |
4206 | current_ev = p; | 4208 | current_ev = p; |
@@ -4214,7 +4216,8 @@ ieee80211_sta_scan_result(struct net_device *dev, | |||
4214 | iwe.cmd = IWEVCUSTOM; | 4216 | iwe.cmd = IWEVCUSTOM; |
4215 | sprintf(buf, "tsf=%016llx", (unsigned long long)(bss->timestamp)); | 4217 | sprintf(buf, "tsf=%016llx", (unsigned long long)(bss->timestamp)); |
4216 | iwe.u.data.length = strlen(buf); | 4218 | iwe.u.data.length = strlen(buf); |
4217 | current_ev = iwe_stream_add_point(current_ev, end_buf, | 4219 | current_ev = iwe_stream_add_point(info, current_ev, |
4220 | end_buf, | ||
4218 | &iwe, buf); | 4221 | &iwe, buf); |
4219 | kfree(buf); | 4222 | kfree(buf); |
4220 | } | 4223 | } |
@@ -4229,31 +4232,36 @@ ieee80211_sta_scan_result(struct net_device *dev, | |||
4229 | iwe.cmd = IWEVCUSTOM; | 4232 | iwe.cmd = IWEVCUSTOM; |
4230 | sprintf(buf, "Mesh network (version %d)", cfg[0]); | 4233 | sprintf(buf, "Mesh network (version %d)", cfg[0]); |
4231 | iwe.u.data.length = strlen(buf); | 4234 | iwe.u.data.length = strlen(buf); |
4232 | current_ev = iwe_stream_add_point(current_ev, end_buf, | 4235 | current_ev = iwe_stream_add_point(info, current_ev, |
4236 | end_buf, | ||
4233 | &iwe, buf); | 4237 | &iwe, buf); |
4234 | sprintf(buf, "Path Selection Protocol ID: " | 4238 | sprintf(buf, "Path Selection Protocol ID: " |
4235 | "0x%02X%02X%02X%02X", cfg[1], cfg[2], cfg[3], | 4239 | "0x%02X%02X%02X%02X", cfg[1], cfg[2], cfg[3], |
4236 | cfg[4]); | 4240 | cfg[4]); |
4237 | iwe.u.data.length = strlen(buf); | 4241 | iwe.u.data.length = strlen(buf); |
4238 | current_ev = iwe_stream_add_point(current_ev, end_buf, | 4242 | current_ev = iwe_stream_add_point(info, current_ev, |
4243 | end_buf, | ||
4239 | &iwe, buf); | 4244 | &iwe, buf); |
4240 | sprintf(buf, "Path Selection Metric ID: " | 4245 | sprintf(buf, "Path Selection Metric ID: " |
4241 | "0x%02X%02X%02X%02X", cfg[5], cfg[6], cfg[7], | 4246 | "0x%02X%02X%02X%02X", cfg[5], cfg[6], cfg[7], |
4242 | cfg[8]); | 4247 | cfg[8]); |
4243 | iwe.u.data.length = strlen(buf); | 4248 | iwe.u.data.length = strlen(buf); |
4244 | current_ev = iwe_stream_add_point(current_ev, end_buf, | 4249 | current_ev = iwe_stream_add_point(info, current_ev, |
4250 | end_buf, | ||
4245 | &iwe, buf); | 4251 | &iwe, buf); |
4246 | sprintf(buf, "Congestion Control Mode ID: " | 4252 | sprintf(buf, "Congestion Control Mode ID: " |
4247 | "0x%02X%02X%02X%02X", cfg[9], cfg[10], | 4253 | "0x%02X%02X%02X%02X", cfg[9], cfg[10], |
4248 | cfg[11], cfg[12]); | 4254 | cfg[11], cfg[12]); |
4249 | iwe.u.data.length = strlen(buf); | 4255 | iwe.u.data.length = strlen(buf); |
4250 | current_ev = iwe_stream_add_point(current_ev, end_buf, | 4256 | current_ev = iwe_stream_add_point(info, current_ev, |
4257 | end_buf, | ||
4251 | &iwe, buf); | 4258 | &iwe, buf); |
4252 | sprintf(buf, "Channel Precedence: " | 4259 | sprintf(buf, "Channel Precedence: " |
4253 | "0x%02X%02X%02X%02X", cfg[13], cfg[14], | 4260 | "0x%02X%02X%02X%02X", cfg[13], cfg[14], |
4254 | cfg[15], cfg[16]); | 4261 | cfg[15], cfg[16]); |
4255 | iwe.u.data.length = strlen(buf); | 4262 | iwe.u.data.length = strlen(buf); |
4256 | current_ev = iwe_stream_add_point(current_ev, end_buf, | 4263 | current_ev = iwe_stream_add_point(info, current_ev, |
4264 | end_buf, | ||
4257 | &iwe, buf); | 4265 | &iwe, buf); |
4258 | kfree(buf); | 4266 | kfree(buf); |
4259 | } | 4267 | } |
@@ -4263,7 +4271,9 @@ ieee80211_sta_scan_result(struct net_device *dev, | |||
4263 | } | 4271 | } |
4264 | 4272 | ||
4265 | 4273 | ||
4266 | int ieee80211_sta_scan_results(struct net_device *dev, char *buf, size_t len) | 4274 | int ieee80211_sta_scan_results(struct net_device *dev, |
4275 | struct iw_request_info *info, | ||
4276 | char *buf, size_t len) | ||
4267 | { | 4277 | { |
4268 | struct ieee80211_local *local = wdev_priv(dev->ieee80211_ptr); | 4278 | struct ieee80211_local *local = wdev_priv(dev->ieee80211_ptr); |
4269 | char *current_ev = buf; | 4279 | char *current_ev = buf; |
@@ -4276,8 +4286,8 @@ int ieee80211_sta_scan_results(struct net_device *dev, char *buf, size_t len) | |||
4276 | spin_unlock_bh(&local->sta_bss_lock); | 4286 | spin_unlock_bh(&local->sta_bss_lock); |
4277 | return -E2BIG; | 4287 | return -E2BIG; |
4278 | } | 4288 | } |
4279 | current_ev = ieee80211_sta_scan_result(dev, bss, current_ev, | 4289 | current_ev = ieee80211_sta_scan_result(dev, info, bss, |
4280 | end_buf); | 4290 | current_ev, end_buf); |
4281 | } | 4291 | } |
4282 | spin_unlock_bh(&local->sta_bss_lock); | 4292 | spin_unlock_bh(&local->sta_bss_lock); |
4283 | return current_ev - buf; | 4293 | return current_ev - buf; |