ieee80211softmac_module.c 17 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568
  1. /*
  2. * Contains some basic softmac functions along with module registration code etc.
  3. *
  4. * Copyright (c) 2005, 2006 Johannes Berg <johannes@sipsolutions.net>
  5. * Joseph Jezak <josejx@gentoo.org>
  6. * Larry Finger <Larry.Finger@lwfinger.net>
  7. * Danny van Dyk <kugelfang@gentoo.org>
  8. * Michael Buesch <mbuesch@freenet.de>
  9. *
  10. * This program is free software; you can redistribute it and/or modify it
  11. * under the terms of version 2 of the GNU General Public License as
  12. * published by the Free Software Foundation.
  13. *
  14. * This program is distributed in the hope that it will be useful, but WITHOUT
  15. * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
  16. * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for
  17. * more details.
  18. *
  19. * You should have received a copy of the GNU General Public License
  20. * along with this program; if not, write to the Free Software
  21. * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
  22. *
  23. * The full GNU General Public License is included in this distribution in the
  24. * file called COPYING.
  25. */
  26. #include "ieee80211softmac_priv.h"
  27. #include <linux/sort.h>
  28. #include <linux/etherdevice.h>
  29. struct net_device *alloc_ieee80211softmac(int sizeof_priv)
  30. {
  31. struct ieee80211softmac_device *softmac;
  32. struct net_device *dev;
  33. dev = alloc_ieee80211(sizeof(*softmac) + sizeof_priv);
  34. if (!dev)
  35. return NULL;
  36. softmac = ieee80211_priv(dev);
  37. softmac->wq = create_freezeable_workqueue("softmac");
  38. if (!softmac->wq) {
  39. free_ieee80211(dev);
  40. return NULL;
  41. }
  42. softmac->dev = dev;
  43. softmac->ieee = netdev_priv(dev);
  44. spin_lock_init(&softmac->lock);
  45. softmac->ieee->handle_auth = ieee80211softmac_auth_resp;
  46. softmac->ieee->handle_deauth = ieee80211softmac_deauth_resp;
  47. softmac->ieee->handle_assoc_response = ieee80211softmac_handle_assoc_response;
  48. softmac->ieee->handle_reassoc_request = ieee80211softmac_handle_reassoc_req;
  49. softmac->ieee->handle_disassoc = ieee80211softmac_handle_disassoc;
  50. softmac->ieee->handle_beacon = ieee80211softmac_handle_beacon;
  51. softmac->scaninfo = NULL;
  52. softmac->associnfo.scan_retry = IEEE80211SOFTMAC_ASSOC_SCAN_RETRY_LIMIT;
  53. /* TODO: initialise all the other callbacks in the ieee struct
  54. * (once they're written)
  55. */
  56. INIT_LIST_HEAD(&softmac->auth_queue);
  57. INIT_LIST_HEAD(&softmac->network_list);
  58. INIT_LIST_HEAD(&softmac->events);
  59. mutex_init(&softmac->associnfo.mutex);
  60. INIT_DELAYED_WORK(&softmac->associnfo.work, ieee80211softmac_assoc_work);
  61. INIT_DELAYED_WORK(&softmac->associnfo.timeout, ieee80211softmac_assoc_timeout);
  62. softmac->start_scan = ieee80211softmac_start_scan_implementation;
  63. softmac->wait_for_scan = ieee80211softmac_wait_for_scan_implementation;
  64. softmac->stop_scan = ieee80211softmac_stop_scan_implementation;
  65. /* to start with, we can't send anything ... */
  66. netif_carrier_off(dev);
  67. return dev;
  68. }
  69. EXPORT_SYMBOL_GPL(alloc_ieee80211softmac);
  70. /* Clears the pending work queue items, stops all scans, etc. */
  71. void
  72. ieee80211softmac_clear_pending_work(struct ieee80211softmac_device *sm)
  73. {
  74. unsigned long flags;
  75. struct ieee80211softmac_event *eventptr, *eventtmp;
  76. struct ieee80211softmac_auth_queue_item *authptr, *authtmp;
  77. struct ieee80211softmac_network *netptr, *nettmp;
  78. ieee80211softmac_stop_scan(sm);
  79. ieee80211softmac_wait_for_scan(sm);
  80. spin_lock_irqsave(&sm->lock, flags);
  81. sm->running = 0;
  82. /* Free all pending assoc work items */
  83. cancel_delayed_work(&sm->associnfo.work);
  84. /* Free all pending scan work items */
  85. if(sm->scaninfo != NULL)
  86. cancel_delayed_work(&sm->scaninfo->softmac_scan);
  87. /* Free all pending auth work items */
  88. list_for_each_entry(authptr, &sm->auth_queue, list)
  89. cancel_delayed_work(&authptr->work);
  90. /* delete all pending event calls and work items */
  91. list_for_each_entry_safe(eventptr, eventtmp, &sm->events, list)
  92. cancel_delayed_work(&eventptr->work);
  93. spin_unlock_irqrestore(&sm->lock, flags);
  94. flush_workqueue(sm->wq);
  95. /* now we should be save and no longer need locking... */
  96. spin_lock_irqsave(&sm->lock, flags);
  97. /* Free all pending auth work items */
  98. list_for_each_entry_safe(authptr, authtmp, &sm->auth_queue, list) {
  99. list_del(&authptr->list);
  100. kfree(authptr);
  101. }
  102. /* delete all pending event calls and work items */
  103. list_for_each_entry_safe(eventptr, eventtmp, &sm->events, list) {
  104. list_del(&eventptr->list);
  105. kfree(eventptr);
  106. }
  107. /* Free all networks */
  108. list_for_each_entry_safe(netptr, nettmp, &sm->network_list, list) {
  109. ieee80211softmac_del_network_locked(sm, netptr);
  110. if(netptr->challenge != NULL)
  111. kfree(netptr->challenge);
  112. kfree(netptr);
  113. }
  114. spin_unlock_irqrestore(&sm->lock, flags);
  115. }
  116. EXPORT_SYMBOL_GPL(ieee80211softmac_clear_pending_work);
  117. void free_ieee80211softmac(struct net_device *dev)
  118. {
  119. struct ieee80211softmac_device *sm = ieee80211_priv(dev);
  120. ieee80211softmac_clear_pending_work(sm);
  121. kfree(sm->scaninfo);
  122. kfree(sm->wpa.IE);
  123. destroy_workqueue(sm->wq);
  124. free_ieee80211(dev);
  125. }
  126. EXPORT_SYMBOL_GPL(free_ieee80211softmac);
  127. static void ieee80211softmac_start_check_rates(struct ieee80211softmac_device *mac)
  128. {
  129. struct ieee80211softmac_ratesinfo *ri = &mac->ratesinfo;
  130. /* I took out the sorting check, we're seperating by modulation now. */
  131. if (ri->count)
  132. return;
  133. /* otherwise assume we hav'em all! */
  134. if (mac->ieee->modulation & IEEE80211_CCK_MODULATION) {
  135. ri->rates[ri->count++] = IEEE80211_CCK_RATE_1MB;
  136. ri->rates[ri->count++] = IEEE80211_CCK_RATE_2MB;
  137. ri->rates[ri->count++] = IEEE80211_CCK_RATE_5MB;
  138. ri->rates[ri->count++] = IEEE80211_CCK_RATE_11MB;
  139. }
  140. if (mac->ieee->modulation & IEEE80211_OFDM_MODULATION) {
  141. ri->rates[ri->count++] = IEEE80211_OFDM_RATE_6MB;
  142. ri->rates[ri->count++] = IEEE80211_OFDM_RATE_9MB;
  143. ri->rates[ri->count++] = IEEE80211_OFDM_RATE_12MB;
  144. ri->rates[ri->count++] = IEEE80211_OFDM_RATE_18MB;
  145. ri->rates[ri->count++] = IEEE80211_OFDM_RATE_24MB;
  146. ri->rates[ri->count++] = IEEE80211_OFDM_RATE_36MB;
  147. ri->rates[ri->count++] = IEEE80211_OFDM_RATE_48MB;
  148. ri->rates[ri->count++] = IEEE80211_OFDM_RATE_54MB;
  149. }
  150. }
  151. int ieee80211softmac_ratesinfo_rate_supported(struct ieee80211softmac_ratesinfo *ri, u8 rate)
  152. {
  153. int search;
  154. u8 search_rate;
  155. for (search = 0; search < ri->count; search++) {
  156. search_rate = ri->rates[search];
  157. search_rate &= ~IEEE80211_BASIC_RATE_MASK;
  158. if (rate == search_rate)
  159. return 1;
  160. }
  161. return 0;
  162. }
  163. u8 ieee80211softmac_highest_supported_rate(struct ieee80211softmac_device *mac,
  164. struct ieee80211softmac_ratesinfo *ri, int basic_only)
  165. {
  166. u8 user_rate = mac->txrates.user_rate;
  167. int i;
  168. if (ri->count == 0)
  169. return IEEE80211_CCK_RATE_1MB;
  170. for (i = ri->count - 1; i >= 0; i--) {
  171. u8 rate = ri->rates[i];
  172. if (basic_only && !(rate & IEEE80211_BASIC_RATE_MASK))
  173. continue;
  174. rate &= ~IEEE80211_BASIC_RATE_MASK;
  175. if (rate > user_rate)
  176. continue;
  177. if (ieee80211softmac_ratesinfo_rate_supported(&mac->ratesinfo, rate))
  178. return rate;
  179. }
  180. /* If we haven't found a suitable rate by now, just trust the user */
  181. return user_rate;
  182. }
  183. EXPORT_SYMBOL_GPL(ieee80211softmac_highest_supported_rate);
  184. void ieee80211softmac_process_erp(struct ieee80211softmac_device *mac,
  185. u8 erp_value)
  186. {
  187. int use_protection;
  188. int short_preamble;
  189. u32 changes = 0;
  190. /* Barker preamble mode */
  191. short_preamble = ((erp_value & WLAN_ERP_BARKER_PREAMBLE) == 0
  192. && mac->associnfo.short_preamble_available) ? 1 : 0;
  193. /* Protection needed? */
  194. use_protection = (erp_value & WLAN_ERP_USE_PROTECTION) != 0;
  195. if (mac->bssinfo.short_preamble != short_preamble) {
  196. changes |= IEEE80211SOFTMAC_BSSINFOCHG_SHORT_PREAMBLE;
  197. mac->bssinfo.short_preamble = short_preamble;
  198. }
  199. if (mac->bssinfo.use_protection != use_protection) {
  200. changes |= IEEE80211SOFTMAC_BSSINFOCHG_PROTECTION;
  201. mac->bssinfo.use_protection = use_protection;
  202. }
  203. if (mac->bssinfo_change && changes)
  204. mac->bssinfo_change(mac->dev, changes);
  205. }
  206. void ieee80211softmac_recalc_txrates(struct ieee80211softmac_device *mac)
  207. {
  208. struct ieee80211softmac_txrates *txrates = &mac->txrates;
  209. u32 change = 0;
  210. change |= IEEE80211SOFTMAC_TXRATECHG_DEFAULT;
  211. txrates->default_rate = ieee80211softmac_highest_supported_rate(mac, &mac->bssinfo.supported_rates, 0);
  212. change |= IEEE80211SOFTMAC_TXRATECHG_DEFAULT_FBACK;
  213. txrates->default_fallback = lower_rate(mac, txrates->default_rate);
  214. change |= IEEE80211SOFTMAC_TXRATECHG_MCAST;
  215. txrates->mcast_rate = ieee80211softmac_highest_supported_rate(mac, &mac->bssinfo.supported_rates, 1);
  216. if (mac->txrates_change)
  217. mac->txrates_change(mac->dev, change);
  218. }
  219. void ieee80211softmac_init_bss(struct ieee80211softmac_device *mac)
  220. {
  221. struct ieee80211_device *ieee = mac->ieee;
  222. u32 change = 0;
  223. struct ieee80211softmac_txrates *txrates = &mac->txrates;
  224. struct ieee80211softmac_bss_info *bssinfo = &mac->bssinfo;
  225. /* TODO: We need some kind of state machine to lower the default rates
  226. * if we loose too many packets.
  227. */
  228. /* Change the default txrate to the highest possible value.
  229. * The txrate machine will lower it, if it is too high.
  230. */
  231. if (ieee->modulation & IEEE80211_OFDM_MODULATION)
  232. txrates->user_rate = IEEE80211_OFDM_RATE_24MB;
  233. else
  234. txrates->user_rate = IEEE80211_CCK_RATE_11MB;
  235. txrates->default_rate = IEEE80211_CCK_RATE_1MB;
  236. change |= IEEE80211SOFTMAC_TXRATECHG_DEFAULT;
  237. txrates->default_fallback = IEEE80211_CCK_RATE_1MB;
  238. change |= IEEE80211SOFTMAC_TXRATECHG_DEFAULT_FBACK;
  239. txrates->mcast_rate = IEEE80211_CCK_RATE_1MB;
  240. change |= IEEE80211SOFTMAC_TXRATECHG_MCAST;
  241. txrates->mgt_mcast_rate = IEEE80211_CCK_RATE_1MB;
  242. change |= IEEE80211SOFTMAC_TXRATECHG_MGT_MCAST;
  243. if (mac->txrates_change)
  244. mac->txrates_change(mac->dev, change);
  245. change = 0;
  246. bssinfo->supported_rates.count = 0;
  247. memset(bssinfo->supported_rates.rates, 0,
  248. sizeof(bssinfo->supported_rates.rates));
  249. change |= IEEE80211SOFTMAC_BSSINFOCHG_RATES;
  250. bssinfo->short_preamble = 0;
  251. change |= IEEE80211SOFTMAC_BSSINFOCHG_SHORT_PREAMBLE;
  252. bssinfo->use_protection = 0;
  253. change |= IEEE80211SOFTMAC_BSSINFOCHG_PROTECTION;
  254. if (mac->bssinfo_change)
  255. mac->bssinfo_change(mac->dev, change);
  256. mac->running = 1;
  257. }
  258. void ieee80211softmac_start(struct net_device *dev)
  259. {
  260. struct ieee80211softmac_device *mac = ieee80211_priv(dev);
  261. ieee80211softmac_start_check_rates(mac);
  262. ieee80211softmac_init_bss(mac);
  263. }
  264. EXPORT_SYMBOL_GPL(ieee80211softmac_start);
  265. void ieee80211softmac_stop(struct net_device *dev)
  266. {
  267. struct ieee80211softmac_device *mac = ieee80211_priv(dev);
  268. ieee80211softmac_clear_pending_work(mac);
  269. }
  270. EXPORT_SYMBOL_GPL(ieee80211softmac_stop);
  271. void ieee80211softmac_set_rates(struct net_device *dev, u8 count, u8 *rates)
  272. {
  273. struct ieee80211softmac_device *mac = ieee80211_priv(dev);
  274. unsigned long flags;
  275. spin_lock_irqsave(&mac->lock, flags);
  276. memcpy(mac->ratesinfo.rates, rates, count);
  277. mac->ratesinfo.count = count;
  278. spin_unlock_irqrestore(&mac->lock, flags);
  279. }
  280. EXPORT_SYMBOL_GPL(ieee80211softmac_set_rates);
  281. static u8 raise_rate(struct ieee80211softmac_device *mac, u8 rate)
  282. {
  283. int i;
  284. struct ieee80211softmac_ratesinfo *ri = &mac->ratesinfo;
  285. for (i=0; i<ri->count-1; i++) {
  286. if (ri->rates[i] == rate)
  287. return ri->rates[i+1];
  288. }
  289. /* I guess we can't go any higher... */
  290. return ri->rates[ri->count];
  291. }
  292. u8 ieee80211softmac_lower_rate_delta(struct ieee80211softmac_device *mac, u8 rate, int delta)
  293. {
  294. int i;
  295. struct ieee80211softmac_ratesinfo *ri = &mac->ratesinfo;
  296. for (i=delta; i<ri->count; i++) {
  297. if (ri->rates[i] == rate)
  298. return ri->rates[i-delta];
  299. }
  300. /* I guess we can't go any lower... */
  301. return ri->rates[0];
  302. }
  303. static void ieee80211softmac_add_txrates_badness(struct ieee80211softmac_device *mac,
  304. int amount)
  305. {
  306. u8 default_rate = mac->txrates.default_rate;
  307. u8 default_fallback = mac->txrates.default_fallback;
  308. u32 changes = 0;
  309. //TODO: This is highly experimental code.
  310. // Maybe the dynamic rate selection does not work
  311. // and it has to be removed again.
  312. printk("badness %d\n", mac->txrate_badness);
  313. mac->txrate_badness += amount;
  314. if (mac->txrate_badness <= -1000) {
  315. /* Very small badness. Try a faster bitrate. */
  316. default_rate = raise_rate(mac, default_rate);
  317. changes |= IEEE80211SOFTMAC_TXRATECHG_DEFAULT;
  318. default_fallback = get_fallback_rate(mac, default_rate);
  319. changes |= IEEE80211SOFTMAC_TXRATECHG_DEFAULT_FBACK;
  320. mac->txrate_badness = 0;
  321. printk("Bitrate raised to %u\n", default_rate);
  322. } else if (mac->txrate_badness >= 10000) {
  323. /* Very high badness. Try a slower bitrate. */
  324. default_rate = lower_rate(mac, default_rate);
  325. changes |= IEEE80211SOFTMAC_TXRATECHG_DEFAULT;
  326. default_fallback = get_fallback_rate(mac, default_rate);
  327. changes |= IEEE80211SOFTMAC_TXRATECHG_DEFAULT_FBACK;
  328. mac->txrate_badness = 0;
  329. printk("Bitrate lowered to %u\n", default_rate);
  330. }
  331. mac->txrates.default_rate = default_rate;
  332. mac->txrates.default_fallback = default_fallback;
  333. if (changes && mac->txrates_change)
  334. mac->txrates_change(mac->dev, changes);
  335. }
  336. void ieee80211softmac_fragment_lost(struct net_device *dev,
  337. u16 wl_seq)
  338. {
  339. struct ieee80211softmac_device *mac = ieee80211_priv(dev);
  340. unsigned long flags;
  341. spin_lock_irqsave(&mac->lock, flags);
  342. ieee80211softmac_add_txrates_badness(mac, 1000);
  343. //TODO
  344. spin_unlock_irqrestore(&mac->lock, flags);
  345. }
  346. EXPORT_SYMBOL_GPL(ieee80211softmac_fragment_lost);
  347. static int rate_cmp(const void *a_, const void *b_) {
  348. u8 *a, *b;
  349. a = (u8*)a_;
  350. b = (u8*)b_;
  351. return ((*a & ~IEEE80211_BASIC_RATE_MASK) - (*b & ~IEEE80211_BASIC_RATE_MASK));
  352. }
  353. /* Allocate a softmac network struct and fill it from a network */
  354. struct ieee80211softmac_network *
  355. ieee80211softmac_create_network(struct ieee80211softmac_device *mac,
  356. struct ieee80211_network *net)
  357. {
  358. struct ieee80211softmac_network *softnet;
  359. softnet = kzalloc(sizeof(struct ieee80211softmac_network), GFP_ATOMIC);
  360. if(softnet == NULL)
  361. return NULL;
  362. memcpy(softnet->bssid, net->bssid, ETH_ALEN);
  363. softnet->channel = net->channel;
  364. softnet->essid.len = net->ssid_len;
  365. memcpy(softnet->essid.data, net->ssid, softnet->essid.len);
  366. /* copy rates over */
  367. softnet->supported_rates.count = net->rates_len;
  368. memcpy(&softnet->supported_rates.rates[0], net->rates, net->rates_len);
  369. memcpy(&softnet->supported_rates.rates[softnet->supported_rates.count], net->rates_ex, net->rates_ex_len);
  370. softnet->supported_rates.count += net->rates_ex_len;
  371. sort(softnet->supported_rates.rates, softnet->supported_rates.count, sizeof(softnet->supported_rates.rates[0]), rate_cmp, NULL);
  372. /* we save the ERP value because it is needed at association time, and
  373. * many AP's do not include an ERP IE in the association response. */
  374. softnet->erp_value = net->erp_value;
  375. softnet->capabilities = net->capability;
  376. return softnet;
  377. }
  378. /* Add a network to the list, while locked */
  379. void
  380. ieee80211softmac_add_network_locked(struct ieee80211softmac_device *mac,
  381. struct ieee80211softmac_network *add_net)
  382. {
  383. struct ieee80211softmac_network *softmac_net;
  384. list_for_each_entry(softmac_net, &mac->network_list, list) {
  385. if(!memcmp(softmac_net->bssid, add_net->bssid, ETH_ALEN))
  386. return;
  387. }
  388. list_add(&(add_net->list), &mac->network_list);
  389. }
  390. /* Add a network to the list, with locking */
  391. void
  392. ieee80211softmac_add_network(struct ieee80211softmac_device *mac,
  393. struct ieee80211softmac_network *add_net)
  394. {
  395. unsigned long flags;
  396. spin_lock_irqsave(&mac->lock, flags);
  397. ieee80211softmac_add_network_locked(mac, add_net);
  398. spin_unlock_irqrestore(&mac->lock, flags);
  399. }
  400. /* Delete a network from the list, while locked*/
  401. void
  402. ieee80211softmac_del_network_locked(struct ieee80211softmac_device *mac,
  403. struct ieee80211softmac_network *del_net)
  404. {
  405. list_del(&(del_net->list));
  406. }
  407. /* Delete a network from the list with locking */
  408. void
  409. ieee80211softmac_del_network(struct ieee80211softmac_device *mac,
  410. struct ieee80211softmac_network *del_net)
  411. {
  412. unsigned long flags;
  413. spin_lock_irqsave(&mac->lock, flags);
  414. ieee80211softmac_del_network_locked(mac, del_net);
  415. spin_unlock_irqrestore(&mac->lock, flags);
  416. }
  417. /* Get a network from the list by MAC while locked */
  418. struct ieee80211softmac_network *
  419. ieee80211softmac_get_network_by_bssid_locked(struct ieee80211softmac_device *mac,
  420. u8 *bssid)
  421. {
  422. struct ieee80211softmac_network *softmac_net;
  423. list_for_each_entry(softmac_net, &mac->network_list, list) {
  424. if(!memcmp(softmac_net->bssid, bssid, ETH_ALEN))
  425. return softmac_net;
  426. }
  427. return NULL;
  428. }
  429. /* Get a network from the list by BSSID with locking */
  430. struct ieee80211softmac_network *
  431. ieee80211softmac_get_network_by_bssid(struct ieee80211softmac_device *mac,
  432. u8 *bssid)
  433. {
  434. unsigned long flags;
  435. struct ieee80211softmac_network *softmac_net;
  436. spin_lock_irqsave(&mac->lock, flags);
  437. softmac_net = ieee80211softmac_get_network_by_bssid_locked(mac, bssid);
  438. spin_unlock_irqrestore(&mac->lock, flags);
  439. return softmac_net;
  440. }
  441. /* Get a network from the list by ESSID while locked */
  442. struct ieee80211softmac_network *
  443. ieee80211softmac_get_network_by_essid_locked(struct ieee80211softmac_device *mac,
  444. struct ieee80211softmac_essid *essid)
  445. {
  446. struct ieee80211softmac_network *softmac_net;
  447. list_for_each_entry(softmac_net, &mac->network_list, list) {
  448. if (softmac_net->essid.len == essid->len &&
  449. !memcmp(softmac_net->essid.data, essid->data, essid->len))
  450. return softmac_net;
  451. }
  452. return NULL;
  453. }
  454. /* Get a network from the list by ESSID with locking */
  455. struct ieee80211softmac_network *
  456. ieee80211softmac_get_network_by_essid(struct ieee80211softmac_device *mac,
  457. struct ieee80211softmac_essid *essid)
  458. {
  459. unsigned long flags;
  460. struct ieee80211softmac_network *softmac_net = NULL;
  461. spin_lock_irqsave(&mac->lock, flags);
  462. softmac_net = ieee80211softmac_get_network_by_essid_locked(mac, essid);
  463. spin_unlock_irqrestore(&mac->lock, flags);
  464. return softmac_net;
  465. }
  466. MODULE_LICENSE("GPL");
  467. MODULE_AUTHOR("Johannes Berg");
  468. MODULE_AUTHOR("Joseph Jezak");
  469. MODULE_AUTHOR("Larry Finger");
  470. MODULE_AUTHOR("Danny van Dyk");
  471. MODULE_AUTHOR("Michael Buesch");
  472. MODULE_DESCRIPTION("802.11 software MAC");