blob: de9ac49cd907c985862676e032becdc10a790e0b [file] [log] [blame]
Johannes Berg04a773a2009-04-19 21:24:32 +02001/*
2 * Some IBSS support code for cfg80211.
3 *
4 * Copyright 2009 Johannes Berg <johannes@sipsolutions.net>
5 */
6
7#include <linux/etherdevice.h>
8#include <linux/if_arp.h>
9#include <net/cfg80211.h>
Johannes Berg0e82ffe2009-07-27 12:01:50 +020010#include "wext-compat.h"
Johannes Berg04a773a2009-04-19 21:24:32 +020011#include "nl80211.h"
12
13
Johannes Berg667503d2009-07-07 03:56:11 +020014void __cfg80211_ibss_joined(struct net_device *dev, const u8 *bssid)
Johannes Berg04a773a2009-04-19 21:24:32 +020015{
16 struct wireless_dev *wdev = dev->ieee80211_ptr;
17 struct cfg80211_bss *bss;
18#ifdef CONFIG_WIRELESS_EXT
19 union iwreq_data wrqu;
20#endif
21
22 if (WARN_ON(wdev->iftype != NL80211_IFTYPE_ADHOC))
23 return;
24
25 if (WARN_ON(!wdev->ssid_len))
26 return;
27
Johannes Berg04a773a2009-04-19 21:24:32 +020028 bss = cfg80211_get_bss(wdev->wiphy, NULL, bssid,
29 wdev->ssid, wdev->ssid_len,
30 WLAN_CAPABILITY_IBSS, WLAN_CAPABILITY_IBSS);
31
32 if (WARN_ON(!bss))
33 return;
34
35 if (wdev->current_bss) {
36 cfg80211_unhold_bss(wdev->current_bss);
Johannes Berg19957bb2009-07-02 17:20:43 +020037 cfg80211_put_bss(&wdev->current_bss->pub);
Johannes Berg04a773a2009-04-19 21:24:32 +020038 }
39
Johannes Berg19957bb2009-07-02 17:20:43 +020040 cfg80211_hold_bss(bss_from_pub(bss));
41 wdev->current_bss = bss_from_pub(bss);
Johannes Berg04a773a2009-04-19 21:24:32 +020042
Johannes Bergfffd0932009-07-08 14:22:54 +020043 cfg80211_upload_connect_keys(wdev);
44
Johannes Berg667503d2009-07-07 03:56:11 +020045 nl80211_send_ibss_bssid(wiphy_to_dev(wdev->wiphy), dev, bssid,
46 GFP_KERNEL);
Johannes Berg04a773a2009-04-19 21:24:32 +020047#ifdef CONFIG_WIRELESS_EXT
48 memset(&wrqu, 0, sizeof(wrqu));
49 memcpy(wrqu.ap_addr.sa_data, bssid, ETH_ALEN);
50 wireless_send_event(dev, SIOCGIWAP, &wrqu, NULL);
51#endif
52}
Johannes Berg667503d2009-07-07 03:56:11 +020053
54void cfg80211_ibss_joined(struct net_device *dev, const u8 *bssid, gfp_t gfp)
55{
56 struct wireless_dev *wdev = dev->ieee80211_ptr;
57 struct cfg80211_registered_device *rdev = wiphy_to_dev(wdev->wiphy);
58 struct cfg80211_event *ev;
59 unsigned long flags;
60
61 ev = kzalloc(sizeof(*ev), gfp);
62 if (!ev)
63 return;
64
65 ev->type = EVENT_IBSS_JOINED;
66 memcpy(ev->cr.bssid, bssid, ETH_ALEN);
67
68 spin_lock_irqsave(&wdev->event_lock, flags);
69 list_add_tail(&ev->list, &wdev->event_list);
70 spin_unlock_irqrestore(&wdev->event_lock, flags);
71 schedule_work(&rdev->event_work);
72}
Johannes Berg04a773a2009-04-19 21:24:32 +020073EXPORT_SYMBOL(cfg80211_ibss_joined);
74
Johannes Berg667503d2009-07-07 03:56:11 +020075int __cfg80211_join_ibss(struct cfg80211_registered_device *rdev,
76 struct net_device *dev,
Johannes Bergfffd0932009-07-08 14:22:54 +020077 struct cfg80211_ibss_params *params,
78 struct cfg80211_cached_keys *connkeys)
Johannes Berg04a773a2009-04-19 21:24:32 +020079{
80 struct wireless_dev *wdev = dev->ieee80211_ptr;
81 int err;
82
Johannes Berg667503d2009-07-07 03:56:11 +020083 ASSERT_WDEV_LOCK(wdev);
84
Johannes Berg04a773a2009-04-19 21:24:32 +020085 if (wdev->ssid_len)
86 return -EALREADY;
87
Johannes Bergfffd0932009-07-08 14:22:54 +020088 if (WARN_ON(wdev->connect_keys))
89 kfree(wdev->connect_keys);
90 wdev->connect_keys = connkeys;
91
Johannes Berg04a773a2009-04-19 21:24:32 +020092#ifdef CONFIG_WIRELESS_EXT
Johannes Bergcbe8fa92009-05-09 20:09:03 +020093 wdev->wext.ibss.channel = params->channel;
Johannes Berg04a773a2009-04-19 21:24:32 +020094#endif
95 err = rdev->ops->join_ibss(&rdev->wiphy, dev, params);
Johannes Bergfffd0932009-07-08 14:22:54 +020096 if (err) {
97 wdev->connect_keys = NULL;
Johannes Berg04a773a2009-04-19 21:24:32 +020098 return err;
Johannes Bergfffd0932009-07-08 14:22:54 +020099 }
Johannes Berg04a773a2009-04-19 21:24:32 +0200100
101 memcpy(wdev->ssid, params->ssid, params->ssid_len);
102 wdev->ssid_len = params->ssid_len;
103
104 return 0;
105}
106
Johannes Berg667503d2009-07-07 03:56:11 +0200107int cfg80211_join_ibss(struct cfg80211_registered_device *rdev,
108 struct net_device *dev,
Johannes Bergfffd0932009-07-08 14:22:54 +0200109 struct cfg80211_ibss_params *params,
110 struct cfg80211_cached_keys *connkeys)
Johannes Berg04a773a2009-04-19 21:24:32 +0200111{
112 struct wireless_dev *wdev = dev->ieee80211_ptr;
Johannes Berg667503d2009-07-07 03:56:11 +0200113 int err;
114
115 wdev_lock(wdev);
Johannes Bergfffd0932009-07-08 14:22:54 +0200116 err = __cfg80211_join_ibss(rdev, dev, params, connkeys);
Johannes Berg667503d2009-07-07 03:56:11 +0200117 wdev_unlock(wdev);
118
119 return err;
120}
121
122static void __cfg80211_clear_ibss(struct net_device *dev, bool nowext)
123{
124 struct wireless_dev *wdev = dev->ieee80211_ptr;
Johannes Bergfffd0932009-07-08 14:22:54 +0200125 struct cfg80211_registered_device *rdev = wiphy_to_dev(wdev->wiphy);
126 int i;
Johannes Berg667503d2009-07-07 03:56:11 +0200127
128 ASSERT_WDEV_LOCK(wdev);
Johannes Berg04a773a2009-04-19 21:24:32 +0200129
Johannes Bergfffd0932009-07-08 14:22:54 +0200130 kfree(wdev->connect_keys);
131 wdev->connect_keys = NULL;
132
133 /*
134 * Delete all the keys ... pairwise keys can't really
135 * exist any more anyway, but default keys might.
136 */
137 if (rdev->ops->del_key)
138 for (i = 0; i < 6; i++)
139 rdev->ops->del_key(wdev->wiphy, dev, i, NULL);
140
Johannes Berg04a773a2009-04-19 21:24:32 +0200141 if (wdev->current_bss) {
142 cfg80211_unhold_bss(wdev->current_bss);
Johannes Berg19957bb2009-07-02 17:20:43 +0200143 cfg80211_put_bss(&wdev->current_bss->pub);
Johannes Berg04a773a2009-04-19 21:24:32 +0200144 }
145
146 wdev->current_bss = NULL;
147 wdev->ssid_len = 0;
Johannes Berg9d308422009-04-20 18:43:46 +0200148#ifdef CONFIG_WIRELESS_EXT
149 if (!nowext)
Johannes Bergcbe8fa92009-05-09 20:09:03 +0200150 wdev->wext.ibss.ssid_len = 0;
Johannes Berg9d308422009-04-20 18:43:46 +0200151#endif
Johannes Berg04a773a2009-04-19 21:24:32 +0200152}
153
Johannes Berg667503d2009-07-07 03:56:11 +0200154void cfg80211_clear_ibss(struct net_device *dev, bool nowext)
155{
156 struct wireless_dev *wdev = dev->ieee80211_ptr;
157
158 wdev_lock(wdev);
159 __cfg80211_clear_ibss(dev, nowext);
160 wdev_unlock(wdev);
161}
162
163static int __cfg80211_leave_ibss(struct cfg80211_registered_device *rdev,
164 struct net_device *dev, bool nowext)
Johannes Berg04a773a2009-04-19 21:24:32 +0200165{
Johannes Berg78485472009-07-07 03:56:05 +0200166 struct wireless_dev *wdev = dev->ieee80211_ptr;
Johannes Berg04a773a2009-04-19 21:24:32 +0200167 int err;
168
Johannes Berg667503d2009-07-07 03:56:11 +0200169 ASSERT_WDEV_LOCK(wdev);
170
Johannes Berg78485472009-07-07 03:56:05 +0200171 if (!wdev->ssid_len)
172 return -ENOLINK;
173
Johannes Berg04a773a2009-04-19 21:24:32 +0200174 err = rdev->ops->leave_ibss(&rdev->wiphy, dev);
175
176 if (err)
177 return err;
178
Johannes Berg667503d2009-07-07 03:56:11 +0200179 __cfg80211_clear_ibss(dev, nowext);
Johannes Berg04a773a2009-04-19 21:24:32 +0200180
181 return 0;
182}
183
Johannes Berg667503d2009-07-07 03:56:11 +0200184int cfg80211_leave_ibss(struct cfg80211_registered_device *rdev,
185 struct net_device *dev, bool nowext)
186{
187 struct wireless_dev *wdev = dev->ieee80211_ptr;
188 int err;
189
190 wdev_lock(wdev);
191 err = __cfg80211_leave_ibss(rdev, dev, nowext);
192 wdev_unlock(wdev);
193
194 return err;
195}
196
Johannes Berg04a773a2009-04-19 21:24:32 +0200197#ifdef CONFIG_WIRELESS_EXT
Johannes Bergfffd0932009-07-08 14:22:54 +0200198int cfg80211_ibss_wext_join(struct cfg80211_registered_device *rdev,
199 struct wireless_dev *wdev)
Johannes Berg04a773a2009-04-19 21:24:32 +0200200{
Johannes Bergfffd0932009-07-08 14:22:54 +0200201 struct cfg80211_cached_keys *ck = NULL;
Johannes Berg04a773a2009-04-19 21:24:32 +0200202 enum ieee80211_band band;
Johannes Bergfffd0932009-07-08 14:22:54 +0200203 int i, err;
204
205 ASSERT_WDEV_LOCK(wdev);
Johannes Berg04a773a2009-04-19 21:24:32 +0200206
Johannes Bergcbe8fa92009-05-09 20:09:03 +0200207 if (!wdev->wext.ibss.beacon_interval)
208 wdev->wext.ibss.beacon_interval = 100;
Johannes Berg8e30bc52009-04-22 17:45:38 +0200209
Johannes Berg04a773a2009-04-19 21:24:32 +0200210 /* try to find an IBSS channel if none requested ... */
Johannes Bergcbe8fa92009-05-09 20:09:03 +0200211 if (!wdev->wext.ibss.channel) {
Johannes Berg04a773a2009-04-19 21:24:32 +0200212 for (band = 0; band < IEEE80211_NUM_BANDS; band++) {
213 struct ieee80211_supported_band *sband;
214 struct ieee80211_channel *chan;
215
216 sband = rdev->wiphy.bands[band];
217 if (!sband)
218 continue;
219
220 for (i = 0; i < sband->n_channels; i++) {
221 chan = &sband->channels[i];
222 if (chan->flags & IEEE80211_CHAN_NO_IBSS)
223 continue;
224 if (chan->flags & IEEE80211_CHAN_DISABLED)
225 continue;
Johannes Bergcbe8fa92009-05-09 20:09:03 +0200226 wdev->wext.ibss.channel = chan;
Johannes Berg04a773a2009-04-19 21:24:32 +0200227 break;
228 }
229
Johannes Bergcbe8fa92009-05-09 20:09:03 +0200230 if (wdev->wext.ibss.channel)
Johannes Berg04a773a2009-04-19 21:24:32 +0200231 break;
232 }
233
Johannes Bergcbe8fa92009-05-09 20:09:03 +0200234 if (!wdev->wext.ibss.channel)
Johannes Berg04a773a2009-04-19 21:24:32 +0200235 return -EINVAL;
236 }
237
238 /* don't join -- SSID is not there */
Johannes Bergcbe8fa92009-05-09 20:09:03 +0200239 if (!wdev->wext.ibss.ssid_len)
Johannes Berg04a773a2009-04-19 21:24:32 +0200240 return 0;
241
242 if (!netif_running(wdev->netdev))
243 return 0;
244
Johannes Bergfffd0932009-07-08 14:22:54 +0200245 if (wdev->wext.keys)
246 wdev->wext.keys->def = wdev->wext.default_key;
247
248 wdev->wext.ibss.privacy = wdev->wext.default_key != -1;
249
250 if (wdev->wext.keys) {
251 ck = kmemdup(wdev->wext.keys, sizeof(*ck), GFP_KERNEL);
252 if (!ck)
253 return -ENOMEM;
254 for (i = 0; i < 6; i++)
255 ck->params[i].key = ck->data[i];
256 }
257 err = __cfg80211_join_ibss(rdev, wdev->netdev,
258 &wdev->wext.ibss, ck);
259 if (err)
260 kfree(ck);
261
262 return err;
Johannes Berg04a773a2009-04-19 21:24:32 +0200263}
264
265int cfg80211_ibss_wext_siwfreq(struct net_device *dev,
266 struct iw_request_info *info,
267 struct iw_freq *freq, char *extra)
268{
269 struct wireless_dev *wdev = dev->ieee80211_ptr;
270 struct ieee80211_channel *chan;
271 int err;
272
273 /* call only for ibss! */
274 if (WARN_ON(wdev->iftype != NL80211_IFTYPE_ADHOC))
275 return -EINVAL;
276
277 if (!wiphy_to_dev(wdev->wiphy)->ops->join_ibss)
278 return -EOPNOTSUPP;
279
280 chan = cfg80211_wext_freq(wdev->wiphy, freq);
281 if (chan && IS_ERR(chan))
282 return PTR_ERR(chan);
283
284 if (chan &&
285 (chan->flags & IEEE80211_CHAN_NO_IBSS ||
286 chan->flags & IEEE80211_CHAN_DISABLED))
287 return -EINVAL;
288
Johannes Bergcbe8fa92009-05-09 20:09:03 +0200289 if (wdev->wext.ibss.channel == chan)
Johannes Berg04a773a2009-04-19 21:24:32 +0200290 return 0;
291
Johannes Berg667503d2009-07-07 03:56:11 +0200292 wdev_lock(wdev);
293 err = 0;
294 if (wdev->ssid_len)
295 err = __cfg80211_leave_ibss(wiphy_to_dev(wdev->wiphy),
296 dev, true);
297 wdev_unlock(wdev);
298
299 if (err)
300 return err;
Johannes Berg04a773a2009-04-19 21:24:32 +0200301
302 if (chan) {
Johannes Bergcbe8fa92009-05-09 20:09:03 +0200303 wdev->wext.ibss.channel = chan;
304 wdev->wext.ibss.channel_fixed = true;
Johannes Berg04a773a2009-04-19 21:24:32 +0200305 } else {
306 /* cfg80211_ibss_wext_join will pick one if needed */
Johannes Bergcbe8fa92009-05-09 20:09:03 +0200307 wdev->wext.ibss.channel_fixed = false;
Johannes Berg04a773a2009-04-19 21:24:32 +0200308 }
309
Johannes Bergfffd0932009-07-08 14:22:54 +0200310 wdev_lock(wdev);
311 err = cfg80211_ibss_wext_join(wiphy_to_dev(wdev->wiphy), wdev);
312 wdev_unlock(wdev);
313
314 return err;
Johannes Berg04a773a2009-04-19 21:24:32 +0200315}
Johannes Berg04a773a2009-04-19 21:24:32 +0200316
317int cfg80211_ibss_wext_giwfreq(struct net_device *dev,
318 struct iw_request_info *info,
319 struct iw_freq *freq, char *extra)
320{
321 struct wireless_dev *wdev = dev->ieee80211_ptr;
322 struct ieee80211_channel *chan = NULL;
323
324 /* call only for ibss! */
325 if (WARN_ON(wdev->iftype != NL80211_IFTYPE_ADHOC))
326 return -EINVAL;
327
Johannes Berg667503d2009-07-07 03:56:11 +0200328 wdev_lock(wdev);
Johannes Berg04a773a2009-04-19 21:24:32 +0200329 if (wdev->current_bss)
Johannes Berg19957bb2009-07-02 17:20:43 +0200330 chan = wdev->current_bss->pub.channel;
Johannes Bergcbe8fa92009-05-09 20:09:03 +0200331 else if (wdev->wext.ibss.channel)
332 chan = wdev->wext.ibss.channel;
Johannes Berg667503d2009-07-07 03:56:11 +0200333 wdev_unlock(wdev);
Johannes Berg04a773a2009-04-19 21:24:32 +0200334
335 if (chan) {
336 freq->m = chan->center_freq;
337 freq->e = 6;
338 return 0;
339 }
340
341 /* no channel if not joining */
342 return -EINVAL;
343}
Johannes Berg04a773a2009-04-19 21:24:32 +0200344
345int cfg80211_ibss_wext_siwessid(struct net_device *dev,
346 struct iw_request_info *info,
347 struct iw_point *data, char *ssid)
348{
349 struct wireless_dev *wdev = dev->ieee80211_ptr;
350 size_t len = data->length;
351 int err;
352
353 /* call only for ibss! */
354 if (WARN_ON(wdev->iftype != NL80211_IFTYPE_ADHOC))
355 return -EINVAL;
356
357 if (!wiphy_to_dev(wdev->wiphy)->ops->join_ibss)
358 return -EOPNOTSUPP;
359
Johannes Berg667503d2009-07-07 03:56:11 +0200360 wdev_lock(wdev);
361 err = 0;
362 if (wdev->ssid_len)
363 err = __cfg80211_leave_ibss(wiphy_to_dev(wdev->wiphy),
364 dev, true);
365 wdev_unlock(wdev);
366
367 if (err)
368 return err;
Johannes Berg04a773a2009-04-19 21:24:32 +0200369
370 /* iwconfig uses nul termination in SSID.. */
371 if (len > 0 && ssid[len - 1] == '\0')
372 len--;
373
Johannes Bergcbe8fa92009-05-09 20:09:03 +0200374 wdev->wext.ibss.ssid = wdev->ssid;
375 memcpy(wdev->wext.ibss.ssid, ssid, len);
376 wdev->wext.ibss.ssid_len = len;
Johannes Berg04a773a2009-04-19 21:24:32 +0200377
Johannes Bergfffd0932009-07-08 14:22:54 +0200378 wdev_lock(wdev);
379 err = cfg80211_ibss_wext_join(wiphy_to_dev(wdev->wiphy), wdev);
380 wdev_unlock(wdev);
381
382 return err;
Johannes Berg04a773a2009-04-19 21:24:32 +0200383}
384/* temporary symbol - mark GPL - in the future the handler won't be */
385EXPORT_SYMBOL_GPL(cfg80211_ibss_wext_siwessid);
386
387int cfg80211_ibss_wext_giwessid(struct net_device *dev,
388 struct iw_request_info *info,
389 struct iw_point *data, char *ssid)
390{
391 struct wireless_dev *wdev = dev->ieee80211_ptr;
392
393 /* call only for ibss! */
394 if (WARN_ON(wdev->iftype != NL80211_IFTYPE_ADHOC))
395 return -EINVAL;
396
397 data->flags = 0;
398
Johannes Berg667503d2009-07-07 03:56:11 +0200399 wdev_lock(wdev);
Johannes Berg04a773a2009-04-19 21:24:32 +0200400 if (wdev->ssid_len) {
401 data->flags = 1;
402 data->length = wdev->ssid_len;
403 memcpy(ssid, wdev->ssid, data->length);
Johannes Bergcbe8fa92009-05-09 20:09:03 +0200404 } else if (wdev->wext.ibss.ssid && wdev->wext.ibss.ssid_len) {
Johannes Berg04a773a2009-04-19 21:24:32 +0200405 data->flags = 1;
Johannes Bergcbe8fa92009-05-09 20:09:03 +0200406 data->length = wdev->wext.ibss.ssid_len;
407 memcpy(ssid, wdev->wext.ibss.ssid, data->length);
Johannes Berg04a773a2009-04-19 21:24:32 +0200408 }
Johannes Berg667503d2009-07-07 03:56:11 +0200409 wdev_unlock(wdev);
Johannes Berg04a773a2009-04-19 21:24:32 +0200410
411 return 0;
412}
413/* temporary symbol - mark GPL - in the future the handler won't be */
414EXPORT_SYMBOL_GPL(cfg80211_ibss_wext_giwessid);
415
416int cfg80211_ibss_wext_siwap(struct net_device *dev,
417 struct iw_request_info *info,
418 struct sockaddr *ap_addr, char *extra)
419{
420 struct wireless_dev *wdev = dev->ieee80211_ptr;
421 u8 *bssid = ap_addr->sa_data;
422 int err;
423
424 /* call only for ibss! */
425 if (WARN_ON(wdev->iftype != NL80211_IFTYPE_ADHOC))
426 return -EINVAL;
427
428 if (!wiphy_to_dev(wdev->wiphy)->ops->join_ibss)
429 return -EOPNOTSUPP;
430
431 if (ap_addr->sa_family != ARPHRD_ETHER)
432 return -EINVAL;
433
434 /* automatic mode */
435 if (is_zero_ether_addr(bssid) || is_broadcast_ether_addr(bssid))
436 bssid = NULL;
437
438 /* both automatic */
Johannes Bergcbe8fa92009-05-09 20:09:03 +0200439 if (!bssid && !wdev->wext.ibss.bssid)
Johannes Berg04a773a2009-04-19 21:24:32 +0200440 return 0;
441
442 /* fixed already - and no change */
Johannes Bergcbe8fa92009-05-09 20:09:03 +0200443 if (wdev->wext.ibss.bssid && bssid &&
444 compare_ether_addr(bssid, wdev->wext.ibss.bssid) == 0)
Johannes Berg04a773a2009-04-19 21:24:32 +0200445 return 0;
446
Johannes Berg667503d2009-07-07 03:56:11 +0200447 wdev_lock(wdev);
448 err = 0;
449 if (wdev->ssid_len)
450 err = __cfg80211_leave_ibss(wiphy_to_dev(wdev->wiphy),
451 dev, true);
452 wdev_unlock(wdev);
453
454 if (err)
455 return err;
Johannes Berg04a773a2009-04-19 21:24:32 +0200456
457 if (bssid) {
Johannes Bergcbe8fa92009-05-09 20:09:03 +0200458 memcpy(wdev->wext.bssid, bssid, ETH_ALEN);
459 wdev->wext.ibss.bssid = wdev->wext.bssid;
Johannes Berg04a773a2009-04-19 21:24:32 +0200460 } else
Johannes Bergcbe8fa92009-05-09 20:09:03 +0200461 wdev->wext.ibss.bssid = NULL;
Johannes Berg04a773a2009-04-19 21:24:32 +0200462
Johannes Bergfffd0932009-07-08 14:22:54 +0200463 wdev_lock(wdev);
464 err = cfg80211_ibss_wext_join(wiphy_to_dev(wdev->wiphy), wdev);
465 wdev_unlock(wdev);
466
467 return err;
Johannes Berg04a773a2009-04-19 21:24:32 +0200468}
469/* temporary symbol - mark GPL - in the future the handler won't be */
470EXPORT_SYMBOL_GPL(cfg80211_ibss_wext_siwap);
471
472int cfg80211_ibss_wext_giwap(struct net_device *dev,
473 struct iw_request_info *info,
474 struct sockaddr *ap_addr, char *extra)
475{
476 struct wireless_dev *wdev = dev->ieee80211_ptr;
477
478 /* call only for ibss! */
479 if (WARN_ON(wdev->iftype != NL80211_IFTYPE_ADHOC))
480 return -EINVAL;
481
482 ap_addr->sa_family = ARPHRD_ETHER;
483
Johannes Berg667503d2009-07-07 03:56:11 +0200484 wdev_lock(wdev);
Johannes Berg7ebbe6b2009-07-01 21:26:48 +0200485 if (wdev->current_bss)
Johannes Berg19957bb2009-07-02 17:20:43 +0200486 memcpy(ap_addr->sa_data, wdev->current_bss->pub.bssid, ETH_ALEN);
Zhu Yi80e5b062009-07-09 16:59:49 +0800487 else if (wdev->wext.ibss.bssid)
Johannes Bergcbe8fa92009-05-09 20:09:03 +0200488 memcpy(ap_addr->sa_data, wdev->wext.ibss.bssid, ETH_ALEN);
Zhu Yi80e5b062009-07-09 16:59:49 +0800489 else
490 memset(ap_addr->sa_data, 0, ETH_ALEN);
491
Johannes Berg667503d2009-07-07 03:56:11 +0200492 wdev_unlock(wdev);
493
Johannes Berg04a773a2009-04-19 21:24:32 +0200494 return 0;
495}
496/* temporary symbol - mark GPL - in the future the handler won't be */
497EXPORT_SYMBOL_GPL(cfg80211_ibss_wext_giwap);
498#endif