]>
Commit | Line | Data |
---|---|---|
04a773ad JB |
1 | /* |
2 | * Some IBSS support code for cfg80211. | |
3 | * | |
4 | * Copyright 2009 Johannes Berg <[email protected]> | |
5 | */ | |
6 | ||
7 | #include <linux/etherdevice.h> | |
8 | #include <linux/if_arp.h> | |
5a0e3ad6 | 9 | #include <linux/slab.h> |
bc3b2d7f | 10 | #include <linux/export.h> |
04a773ad | 11 | #include <net/cfg80211.h> |
0e82ffe3 | 12 | #include "wext-compat.h" |
04a773ad JB |
13 | #include "nl80211.h" |
14 | ||
15 | ||
667503dd | 16 | void __cfg80211_ibss_joined(struct net_device *dev, const u8 *bssid) |
04a773ad JB |
17 | { |
18 | struct wireless_dev *wdev = dev->ieee80211_ptr; | |
19 | struct cfg80211_bss *bss; | |
3d23e349 | 20 | #ifdef CONFIG_CFG80211_WEXT |
04a773ad JB |
21 | union iwreq_data wrqu; |
22 | #endif | |
23 | ||
24 | if (WARN_ON(wdev->iftype != NL80211_IFTYPE_ADHOC)) | |
25 | return; | |
26 | ||
f7969969 | 27 | if (!wdev->ssid_len) |
04a773ad JB |
28 | return; |
29 | ||
04a773ad JB |
30 | bss = cfg80211_get_bss(wdev->wiphy, NULL, bssid, |
31 | wdev->ssid, wdev->ssid_len, | |
32 | WLAN_CAPABILITY_IBSS, WLAN_CAPABILITY_IBSS); | |
33 | ||
34 | if (WARN_ON(!bss)) | |
35 | return; | |
36 | ||
37 | if (wdev->current_bss) { | |
38 | cfg80211_unhold_bss(wdev->current_bss); | |
19957bb3 | 39 | cfg80211_put_bss(&wdev->current_bss->pub); |
04a773ad JB |
40 | } |
41 | ||
19957bb3 JB |
42 | cfg80211_hold_bss(bss_from_pub(bss)); |
43 | wdev->current_bss = bss_from_pub(bss); | |
04a773ad | 44 | |
fffd0934 JB |
45 | cfg80211_upload_connect_keys(wdev); |
46 | ||
667503dd JB |
47 | nl80211_send_ibss_bssid(wiphy_to_dev(wdev->wiphy), dev, bssid, |
48 | GFP_KERNEL); | |
3d23e349 | 49 | #ifdef CONFIG_CFG80211_WEXT |
04a773ad JB |
50 | memset(&wrqu, 0, sizeof(wrqu)); |
51 | memcpy(wrqu.ap_addr.sa_data, bssid, ETH_ALEN); | |
52 | wireless_send_event(dev, SIOCGIWAP, &wrqu, NULL); | |
53 | #endif | |
54 | } | |
667503dd JB |
55 | |
56 | void cfg80211_ibss_joined(struct net_device *dev, const u8 *bssid, gfp_t gfp) | |
57 | { | |
58 | struct wireless_dev *wdev = dev->ieee80211_ptr; | |
59 | struct cfg80211_registered_device *rdev = wiphy_to_dev(wdev->wiphy); | |
60 | struct cfg80211_event *ev; | |
61 | unsigned long flags; | |
62 | ||
f7969969 JB |
63 | CFG80211_DEV_WARN_ON(!wdev->ssid_len); |
64 | ||
667503dd JB |
65 | ev = kzalloc(sizeof(*ev), gfp); |
66 | if (!ev) | |
67 | return; | |
68 | ||
69 | ev->type = EVENT_IBSS_JOINED; | |
70 | memcpy(ev->cr.bssid, bssid, ETH_ALEN); | |
71 | ||
72 | spin_lock_irqsave(&wdev->event_lock, flags); | |
73 | list_add_tail(&ev->list, &wdev->event_list); | |
74 | spin_unlock_irqrestore(&wdev->event_lock, flags); | |
e60d7443 | 75 | queue_work(cfg80211_wq, &rdev->event_work); |
667503dd | 76 | } |
04a773ad JB |
77 | EXPORT_SYMBOL(cfg80211_ibss_joined); |
78 | ||
667503dd JB |
79 | int __cfg80211_join_ibss(struct cfg80211_registered_device *rdev, |
80 | struct net_device *dev, | |
fffd0934 JB |
81 | struct cfg80211_ibss_params *params, |
82 | struct cfg80211_cached_keys *connkeys) | |
04a773ad JB |
83 | { |
84 | struct wireless_dev *wdev = dev->ieee80211_ptr; | |
85 | int err; | |
86 | ||
667503dd JB |
87 | ASSERT_WDEV_LOCK(wdev); |
88 | ||
04a773ad JB |
89 | if (wdev->ssid_len) |
90 | return -EALREADY; | |
91 | ||
93b05238 JB |
92 | if (!params->basic_rates) { |
93 | /* | |
94 | * If no rates were explicitly configured, | |
95 | * use the mandatory rate set for 11b or | |
96 | * 11a for maximum compatibility. | |
97 | */ | |
98 | struct ieee80211_supported_band *sband = | |
99 | rdev->wiphy.bands[params->channel->band]; | |
100 | int j; | |
101 | u32 flag = params->channel->band == IEEE80211_BAND_5GHZ ? | |
102 | IEEE80211_RATE_MANDATORY_A : | |
103 | IEEE80211_RATE_MANDATORY_B; | |
104 | ||
105 | for (j = 0; j < sband->n_bitrates; j++) { | |
106 | if (sband->bitrates[j].flags & flag) | |
107 | params->basic_rates |= BIT(j); | |
108 | } | |
109 | } | |
110 | ||
fffd0934 JB |
111 | if (WARN_ON(wdev->connect_keys)) |
112 | kfree(wdev->connect_keys); | |
113 | wdev->connect_keys = connkeys; | |
114 | ||
3d23e349 | 115 | #ifdef CONFIG_CFG80211_WEXT |
cbe8fa9c | 116 | wdev->wext.ibss.channel = params->channel; |
04a773ad JB |
117 | #endif |
118 | err = rdev->ops->join_ibss(&rdev->wiphy, dev, params); | |
fffd0934 JB |
119 | if (err) { |
120 | wdev->connect_keys = NULL; | |
04a773ad | 121 | return err; |
fffd0934 | 122 | } |
04a773ad JB |
123 | |
124 | memcpy(wdev->ssid, params->ssid, params->ssid_len); | |
125 | wdev->ssid_len = params->ssid_len; | |
126 | ||
127 | return 0; | |
128 | } | |
129 | ||
667503dd JB |
130 | int cfg80211_join_ibss(struct cfg80211_registered_device *rdev, |
131 | struct net_device *dev, | |
fffd0934 JB |
132 | struct cfg80211_ibss_params *params, |
133 | struct cfg80211_cached_keys *connkeys) | |
667503dd JB |
134 | { |
135 | struct wireless_dev *wdev = dev->ieee80211_ptr; | |
136 | int err; | |
137 | ||
59bbb6f7 | 138 | mutex_lock(&rdev->devlist_mtx); |
667503dd | 139 | wdev_lock(wdev); |
fffd0934 | 140 | err = __cfg80211_join_ibss(rdev, dev, params, connkeys); |
667503dd | 141 | wdev_unlock(wdev); |
59bbb6f7 | 142 | mutex_unlock(&rdev->devlist_mtx); |
667503dd JB |
143 | |
144 | return err; | |
145 | } | |
146 | ||
147 | static void __cfg80211_clear_ibss(struct net_device *dev, bool nowext) | |
04a773ad JB |
148 | { |
149 | struct wireless_dev *wdev = dev->ieee80211_ptr; | |
fffd0934 JB |
150 | struct cfg80211_registered_device *rdev = wiphy_to_dev(wdev->wiphy); |
151 | int i; | |
04a773ad | 152 | |
667503dd JB |
153 | ASSERT_WDEV_LOCK(wdev); |
154 | ||
fffd0934 JB |
155 | kfree(wdev->connect_keys); |
156 | wdev->connect_keys = NULL; | |
157 | ||
158 | /* | |
159 | * Delete all the keys ... pairwise keys can't really | |
160 | * exist any more anyway, but default keys might. | |
161 | */ | |
162 | if (rdev->ops->del_key) | |
163 | for (i = 0; i < 6; i++) | |
e31b8213 | 164 | rdev->ops->del_key(wdev->wiphy, dev, i, false, NULL); |
fffd0934 | 165 | |
04a773ad JB |
166 | if (wdev->current_bss) { |
167 | cfg80211_unhold_bss(wdev->current_bss); | |
19957bb3 | 168 | cfg80211_put_bss(&wdev->current_bss->pub); |
04a773ad JB |
169 | } |
170 | ||
171 | wdev->current_bss = NULL; | |
172 | wdev->ssid_len = 0; | |
3d23e349 | 173 | #ifdef CONFIG_CFG80211_WEXT |
9d308429 | 174 | if (!nowext) |
cbe8fa9c | 175 | wdev->wext.ibss.ssid_len = 0; |
9d308429 | 176 | #endif |
04a773ad JB |
177 | } |
178 | ||
667503dd JB |
179 | void cfg80211_clear_ibss(struct net_device *dev, bool nowext) |
180 | { | |
181 | struct wireless_dev *wdev = dev->ieee80211_ptr; | |
182 | ||
183 | wdev_lock(wdev); | |
184 | __cfg80211_clear_ibss(dev, nowext); | |
185 | wdev_unlock(wdev); | |
186 | } | |
187 | ||
98d3a7ca JB |
188 | int __cfg80211_leave_ibss(struct cfg80211_registered_device *rdev, |
189 | struct net_device *dev, bool nowext) | |
04a773ad | 190 | { |
78485475 | 191 | struct wireless_dev *wdev = dev->ieee80211_ptr; |
04a773ad JB |
192 | int err; |
193 | ||
667503dd JB |
194 | ASSERT_WDEV_LOCK(wdev); |
195 | ||
78485475 JB |
196 | if (!wdev->ssid_len) |
197 | return -ENOLINK; | |
198 | ||
04a773ad JB |
199 | err = rdev->ops->leave_ibss(&rdev->wiphy, dev); |
200 | ||
201 | if (err) | |
202 | return err; | |
203 | ||
667503dd | 204 | __cfg80211_clear_ibss(dev, nowext); |
04a773ad JB |
205 | |
206 | return 0; | |
207 | } | |
208 | ||
667503dd JB |
209 | int cfg80211_leave_ibss(struct cfg80211_registered_device *rdev, |
210 | struct net_device *dev, bool nowext) | |
211 | { | |
212 | struct wireless_dev *wdev = dev->ieee80211_ptr; | |
213 | int err; | |
214 | ||
215 | wdev_lock(wdev); | |
216 | err = __cfg80211_leave_ibss(rdev, dev, nowext); | |
217 | wdev_unlock(wdev); | |
218 | ||
219 | return err; | |
220 | } | |
221 | ||
3d23e349 | 222 | #ifdef CONFIG_CFG80211_WEXT |
fffd0934 JB |
223 | int cfg80211_ibss_wext_join(struct cfg80211_registered_device *rdev, |
224 | struct wireless_dev *wdev) | |
04a773ad | 225 | { |
fffd0934 | 226 | struct cfg80211_cached_keys *ck = NULL; |
04a773ad | 227 | enum ieee80211_band band; |
fffd0934 JB |
228 | int i, err; |
229 | ||
230 | ASSERT_WDEV_LOCK(wdev); | |
04a773ad | 231 | |
cbe8fa9c JB |
232 | if (!wdev->wext.ibss.beacon_interval) |
233 | wdev->wext.ibss.beacon_interval = 100; | |
8e30bc55 | 234 | |
04a773ad | 235 | /* try to find an IBSS channel if none requested ... */ |
cbe8fa9c | 236 | if (!wdev->wext.ibss.channel) { |
04a773ad JB |
237 | for (band = 0; band < IEEE80211_NUM_BANDS; band++) { |
238 | struct ieee80211_supported_band *sband; | |
239 | struct ieee80211_channel *chan; | |
240 | ||
241 | sband = rdev->wiphy.bands[band]; | |
242 | if (!sband) | |
243 | continue; | |
244 | ||
245 | for (i = 0; i < sband->n_channels; i++) { | |
246 | chan = &sband->channels[i]; | |
247 | if (chan->flags & IEEE80211_CHAN_NO_IBSS) | |
248 | continue; | |
249 | if (chan->flags & IEEE80211_CHAN_DISABLED) | |
250 | continue; | |
cbe8fa9c | 251 | wdev->wext.ibss.channel = chan; |
04a773ad JB |
252 | break; |
253 | } | |
254 | ||
cbe8fa9c | 255 | if (wdev->wext.ibss.channel) |
04a773ad JB |
256 | break; |
257 | } | |
258 | ||
cbe8fa9c | 259 | if (!wdev->wext.ibss.channel) |
04a773ad JB |
260 | return -EINVAL; |
261 | } | |
262 | ||
263 | /* don't join -- SSID is not there */ | |
cbe8fa9c | 264 | if (!wdev->wext.ibss.ssid_len) |
04a773ad JB |
265 | return 0; |
266 | ||
267 | if (!netif_running(wdev->netdev)) | |
268 | return 0; | |
269 | ||
3be61a38 | 270 | if (wdev->wext.keys) { |
fffd0934 | 271 | wdev->wext.keys->def = wdev->wext.default_key; |
3be61a38 JB |
272 | wdev->wext.keys->defmgmt = wdev->wext.default_mgmt_key; |
273 | } | |
fffd0934 JB |
274 | |
275 | wdev->wext.ibss.privacy = wdev->wext.default_key != -1; | |
276 | ||
277 | if (wdev->wext.keys) { | |
278 | ck = kmemdup(wdev->wext.keys, sizeof(*ck), GFP_KERNEL); | |
279 | if (!ck) | |
280 | return -ENOMEM; | |
281 | for (i = 0; i < 6; i++) | |
282 | ck->params[i].key = ck->data[i]; | |
283 | } | |
284 | err = __cfg80211_join_ibss(rdev, wdev->netdev, | |
285 | &wdev->wext.ibss, ck); | |
286 | if (err) | |
287 | kfree(ck); | |
288 | ||
289 | return err; | |
04a773ad JB |
290 | } |
291 | ||
292 | int cfg80211_ibss_wext_siwfreq(struct net_device *dev, | |
293 | struct iw_request_info *info, | |
59bbb6f7 | 294 | struct iw_freq *wextfreq, char *extra) |
04a773ad JB |
295 | { |
296 | struct wireless_dev *wdev = dev->ieee80211_ptr; | |
59bbb6f7 JB |
297 | struct cfg80211_registered_device *rdev = wiphy_to_dev(wdev->wiphy); |
298 | struct ieee80211_channel *chan = NULL; | |
299 | int err, freq; | |
04a773ad JB |
300 | |
301 | /* call only for ibss! */ | |
302 | if (WARN_ON(wdev->iftype != NL80211_IFTYPE_ADHOC)) | |
303 | return -EINVAL; | |
304 | ||
59bbb6f7 | 305 | if (!rdev->ops->join_ibss) |
04a773ad JB |
306 | return -EOPNOTSUPP; |
307 | ||
59bbb6f7 JB |
308 | freq = cfg80211_wext_freq(wdev->wiphy, wextfreq); |
309 | if (freq < 0) | |
310 | return freq; | |
04a773ad | 311 | |
59bbb6f7 JB |
312 | if (freq) { |
313 | chan = ieee80211_get_channel(wdev->wiphy, freq); | |
314 | if (!chan) | |
315 | return -EINVAL; | |
316 | if (chan->flags & IEEE80211_CHAN_NO_IBSS || | |
317 | chan->flags & IEEE80211_CHAN_DISABLED) | |
318 | return -EINVAL; | |
319 | } | |
04a773ad | 320 | |
cbe8fa9c | 321 | if (wdev->wext.ibss.channel == chan) |
04a773ad JB |
322 | return 0; |
323 | ||
667503dd JB |
324 | wdev_lock(wdev); |
325 | err = 0; | |
326 | if (wdev->ssid_len) | |
59bbb6f7 | 327 | err = __cfg80211_leave_ibss(rdev, dev, true); |
667503dd JB |
328 | wdev_unlock(wdev); |
329 | ||
330 | if (err) | |
331 | return err; | |
04a773ad JB |
332 | |
333 | if (chan) { | |
cbe8fa9c JB |
334 | wdev->wext.ibss.channel = chan; |
335 | wdev->wext.ibss.channel_fixed = true; | |
04a773ad JB |
336 | } else { |
337 | /* cfg80211_ibss_wext_join will pick one if needed */ | |
cbe8fa9c | 338 | wdev->wext.ibss.channel_fixed = false; |
04a773ad JB |
339 | } |
340 | ||
59bbb6f7 | 341 | mutex_lock(&rdev->devlist_mtx); |
fffd0934 | 342 | wdev_lock(wdev); |
59bbb6f7 | 343 | err = cfg80211_ibss_wext_join(rdev, wdev); |
fffd0934 | 344 | wdev_unlock(wdev); |
59bbb6f7 | 345 | mutex_unlock(&rdev->devlist_mtx); |
fffd0934 JB |
346 | |
347 | return err; | |
04a773ad | 348 | } |
04a773ad JB |
349 | |
350 | int cfg80211_ibss_wext_giwfreq(struct net_device *dev, | |
351 | struct iw_request_info *info, | |
352 | struct iw_freq *freq, char *extra) | |
353 | { | |
354 | struct wireless_dev *wdev = dev->ieee80211_ptr; | |
355 | struct ieee80211_channel *chan = NULL; | |
356 | ||
357 | /* call only for ibss! */ | |
358 | if (WARN_ON(wdev->iftype != NL80211_IFTYPE_ADHOC)) | |
359 | return -EINVAL; | |
360 | ||
667503dd | 361 | wdev_lock(wdev); |
04a773ad | 362 | if (wdev->current_bss) |
19957bb3 | 363 | chan = wdev->current_bss->pub.channel; |
cbe8fa9c JB |
364 | else if (wdev->wext.ibss.channel) |
365 | chan = wdev->wext.ibss.channel; | |
667503dd | 366 | wdev_unlock(wdev); |
04a773ad JB |
367 | |
368 | if (chan) { | |
369 | freq->m = chan->center_freq; | |
370 | freq->e = 6; | |
371 | return 0; | |
372 | } | |
373 | ||
374 | /* no channel if not joining */ | |
375 | return -EINVAL; | |
376 | } | |
04a773ad JB |
377 | |
378 | int cfg80211_ibss_wext_siwessid(struct net_device *dev, | |
379 | struct iw_request_info *info, | |
380 | struct iw_point *data, char *ssid) | |
381 | { | |
382 | struct wireless_dev *wdev = dev->ieee80211_ptr; | |
59bbb6f7 | 383 | struct cfg80211_registered_device *rdev = wiphy_to_dev(wdev->wiphy); |
04a773ad JB |
384 | size_t len = data->length; |
385 | int err; | |
386 | ||
387 | /* call only for ibss! */ | |
388 | if (WARN_ON(wdev->iftype != NL80211_IFTYPE_ADHOC)) | |
389 | return -EINVAL; | |
390 | ||
59bbb6f7 | 391 | if (!rdev->ops->join_ibss) |
04a773ad JB |
392 | return -EOPNOTSUPP; |
393 | ||
667503dd JB |
394 | wdev_lock(wdev); |
395 | err = 0; | |
396 | if (wdev->ssid_len) | |
59bbb6f7 | 397 | err = __cfg80211_leave_ibss(rdev, dev, true); |
667503dd JB |
398 | wdev_unlock(wdev); |
399 | ||
400 | if (err) | |
401 | return err; | |
04a773ad JB |
402 | |
403 | /* iwconfig uses nul termination in SSID.. */ | |
404 | if (len > 0 && ssid[len - 1] == '\0') | |
405 | len--; | |
406 | ||
cbe8fa9c JB |
407 | wdev->wext.ibss.ssid = wdev->ssid; |
408 | memcpy(wdev->wext.ibss.ssid, ssid, len); | |
409 | wdev->wext.ibss.ssid_len = len; | |
04a773ad | 410 | |
59bbb6f7 | 411 | mutex_lock(&rdev->devlist_mtx); |
fffd0934 | 412 | wdev_lock(wdev); |
59bbb6f7 | 413 | err = cfg80211_ibss_wext_join(rdev, wdev); |
fffd0934 | 414 | wdev_unlock(wdev); |
59bbb6f7 | 415 | mutex_unlock(&rdev->devlist_mtx); |
fffd0934 JB |
416 | |
417 | return err; | |
04a773ad | 418 | } |
04a773ad JB |
419 | |
420 | int cfg80211_ibss_wext_giwessid(struct net_device *dev, | |
421 | struct iw_request_info *info, | |
422 | struct iw_point *data, char *ssid) | |
423 | { | |
424 | struct wireless_dev *wdev = dev->ieee80211_ptr; | |
425 | ||
426 | /* call only for ibss! */ | |
427 | if (WARN_ON(wdev->iftype != NL80211_IFTYPE_ADHOC)) | |
428 | return -EINVAL; | |
429 | ||
430 | data->flags = 0; | |
431 | ||
667503dd | 432 | wdev_lock(wdev); |
04a773ad JB |
433 | if (wdev->ssid_len) { |
434 | data->flags = 1; | |
435 | data->length = wdev->ssid_len; | |
436 | memcpy(ssid, wdev->ssid, data->length); | |
cbe8fa9c | 437 | } else if (wdev->wext.ibss.ssid && wdev->wext.ibss.ssid_len) { |
04a773ad | 438 | data->flags = 1; |
cbe8fa9c JB |
439 | data->length = wdev->wext.ibss.ssid_len; |
440 | memcpy(ssid, wdev->wext.ibss.ssid, data->length); | |
04a773ad | 441 | } |
667503dd | 442 | wdev_unlock(wdev); |
04a773ad JB |
443 | |
444 | return 0; | |
445 | } | |
04a773ad JB |
446 | |
447 | int cfg80211_ibss_wext_siwap(struct net_device *dev, | |
448 | struct iw_request_info *info, | |
449 | struct sockaddr *ap_addr, char *extra) | |
450 | { | |
451 | struct wireless_dev *wdev = dev->ieee80211_ptr; | |
59bbb6f7 | 452 | struct cfg80211_registered_device *rdev = wiphy_to_dev(wdev->wiphy); |
04a773ad JB |
453 | u8 *bssid = ap_addr->sa_data; |
454 | int err; | |
455 | ||
456 | /* call only for ibss! */ | |
457 | if (WARN_ON(wdev->iftype != NL80211_IFTYPE_ADHOC)) | |
458 | return -EINVAL; | |
459 | ||
59bbb6f7 | 460 | if (!rdev->ops->join_ibss) |
04a773ad JB |
461 | return -EOPNOTSUPP; |
462 | ||
463 | if (ap_addr->sa_family != ARPHRD_ETHER) | |
464 | return -EINVAL; | |
465 | ||
466 | /* automatic mode */ | |
467 | if (is_zero_ether_addr(bssid) || is_broadcast_ether_addr(bssid)) | |
468 | bssid = NULL; | |
469 | ||
470 | /* both automatic */ | |
cbe8fa9c | 471 | if (!bssid && !wdev->wext.ibss.bssid) |
04a773ad JB |
472 | return 0; |
473 | ||
474 | /* fixed already - and no change */ | |
cbe8fa9c JB |
475 | if (wdev->wext.ibss.bssid && bssid && |
476 | compare_ether_addr(bssid, wdev->wext.ibss.bssid) == 0) | |
04a773ad JB |
477 | return 0; |
478 | ||
667503dd JB |
479 | wdev_lock(wdev); |
480 | err = 0; | |
481 | if (wdev->ssid_len) | |
59bbb6f7 | 482 | err = __cfg80211_leave_ibss(rdev, dev, true); |
667503dd JB |
483 | wdev_unlock(wdev); |
484 | ||
485 | if (err) | |
486 | return err; | |
04a773ad JB |
487 | |
488 | if (bssid) { | |
cbe8fa9c JB |
489 | memcpy(wdev->wext.bssid, bssid, ETH_ALEN); |
490 | wdev->wext.ibss.bssid = wdev->wext.bssid; | |
04a773ad | 491 | } else |
cbe8fa9c | 492 | wdev->wext.ibss.bssid = NULL; |
04a773ad | 493 | |
59bbb6f7 | 494 | mutex_lock(&rdev->devlist_mtx); |
fffd0934 | 495 | wdev_lock(wdev); |
59bbb6f7 | 496 | err = cfg80211_ibss_wext_join(rdev, wdev); |
fffd0934 | 497 | wdev_unlock(wdev); |
59bbb6f7 | 498 | mutex_unlock(&rdev->devlist_mtx); |
fffd0934 JB |
499 | |
500 | return err; | |
04a773ad | 501 | } |
04a773ad JB |
502 | |
503 | int cfg80211_ibss_wext_giwap(struct net_device *dev, | |
504 | struct iw_request_info *info, | |
505 | struct sockaddr *ap_addr, char *extra) | |
506 | { | |
507 | struct wireless_dev *wdev = dev->ieee80211_ptr; | |
508 | ||
509 | /* call only for ibss! */ | |
510 | if (WARN_ON(wdev->iftype != NL80211_IFTYPE_ADHOC)) | |
511 | return -EINVAL; | |
512 | ||
513 | ap_addr->sa_family = ARPHRD_ETHER; | |
514 | ||
667503dd | 515 | wdev_lock(wdev); |
7ebbe6bd | 516 | if (wdev->current_bss) |
19957bb3 | 517 | memcpy(ap_addr->sa_data, wdev->current_bss->pub.bssid, ETH_ALEN); |
80e5b06a | 518 | else if (wdev->wext.ibss.bssid) |
cbe8fa9c | 519 | memcpy(ap_addr->sa_data, wdev->wext.ibss.bssid, ETH_ALEN); |
80e5b06a ZY |
520 | else |
521 | memset(ap_addr->sa_data, 0, ETH_ALEN); | |
522 | ||
667503dd JB |
523 | wdev_unlock(wdev); |
524 | ||
04a773ad JB |
525 | return 0; |
526 | } | |
04a773ad | 527 | #endif |