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