mlme.c 31 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495969798991001011021031041051061071081091101111121131141151161171181191201211221231241251261271281291301311321331341351361371381391401411421431441451461471481491501511521531541551561571581591601611621631641651661671681691701711721731741751761771781791801811821831841851861871881891901911921931941951961971981992002012022032042052062072082092102112122132142152162172182192202212222232242252262272282292302312322332342352362372382392402412422432442452462472482492502512522532542552562572582592602612622632642652662672682692702712722732742752762772782792802812822832842852862872882892902912922932942952962972982993003013023033043053063073083093103113123133143153163173183193203213223233243253263273283293303313323333343353363373383393403413423433443453463473483493503513523533543553563573583593603613623633643653663673683693703713723733743753763773783793803813823833843853863873883893903913923933943953963973983994004014024034044054064074084094104114124134144154164174184194204214224234244254264274284294304314324334344354364374384394404414424434444454464474484494504514524534544554564574584594604614624634644654664674684694704714724734744754764774784794804814824834844854864874884894904914924934944954964974984995005015025035045055065075085095105115125135145155165175185195205215225235245255265275285295305315325335345355365375385395405415425435445455465475485495505515525535545555565575585595605615625635645655665675685695705715725735745755765775785795805815825835845855865875885895905915925935945955965975985996006016026036046056066076086096106116126136146156166176186196206216226236246256266276286296306316326336346356366376386396406416426436446456466476486496506516526536546556566576586596606616626636646656666676686696706716726736746756766776786796806816826836846856866876886896906916926936946956966976986997007017027037047057067077087097107117127137147157167177187197207217227237247257267277287297307317327337347357367377387397407417427437447457467477487497507517527537547557567577587597607617627637647657667677687697707717727737747757767777787797807817827837847857867877887897907917927937947957967977987998008018028038048058068078088098108118128138148158168178188198208218228238248258268278288298308318328338348358368378388398408418428438448458468478488498508518528538548558568578588598608618628638648658668678688698708718728738748758768778788798808818828838848858868878888898908918928938948958968978988999009019029039049059069079089099109119129139149159169179189199209219229239249259269279289299309319329339349359369379389399409419429439449459469479489499509519529539549559569579589599609619629639649659669679689699709719729739749759769779789799809819829839849859869879889899909919929939949959969979989991000100110021003100410051006100710081009101010111012101310141015101610171018101910201021102210231024102510261027102810291030103110321033103410351036103710381039104010411042104310441045104610471048104910501051105210531054105510561057105810591060106110621063106410651066106710681069107010711072107310741075107610771078107910801081108210831084108510861087108810891090109110921093109410951096109710981099110011011102110311041105110611071108110911101111111211131114111511161117111811191120112111221123112411251126112711281129113011311132113311341135113611371138113911401141114211431144114511461147114811491150115111521153115411551156115711581159116011611162116311641165116611671168116911701171
  1. /*
  2. * cfg80211 MLME SAP interface
  3. *
  4. * Copyright (c) 2009, Jouni Malinen <j@w1.fi>
  5. */
  6. #include <linux/kernel.h>
  7. #include <linux/module.h>
  8. #include <linux/netdevice.h>
  9. #include <linux/nl80211.h>
  10. #include <linux/slab.h>
  11. #include <linux/wireless.h>
  12. #include <net/cfg80211.h>
  13. #include <net/iw_handler.h>
  14. #include "core.h"
  15. #include "nl80211.h"
  16. void cfg80211_send_rx_auth(struct net_device *dev, const u8 *buf, size_t len)
  17. {
  18. struct wireless_dev *wdev = dev->ieee80211_ptr;
  19. struct wiphy *wiphy = wdev->wiphy;
  20. struct cfg80211_registered_device *rdev = wiphy_to_dev(wiphy);
  21. struct ieee80211_mgmt *mgmt = (struct ieee80211_mgmt *)buf;
  22. u8 *bssid = mgmt->bssid;
  23. int i;
  24. u16 status = le16_to_cpu(mgmt->u.auth.status_code);
  25. bool done = false;
  26. wdev_lock(wdev);
  27. for (i = 0; i < MAX_AUTH_BSSES; i++) {
  28. if (wdev->authtry_bsses[i] &&
  29. memcmp(wdev->authtry_bsses[i]->pub.bssid, bssid,
  30. ETH_ALEN) == 0) {
  31. if (status == WLAN_STATUS_SUCCESS) {
  32. wdev->auth_bsses[i] = wdev->authtry_bsses[i];
  33. } else {
  34. cfg80211_unhold_bss(wdev->authtry_bsses[i]);
  35. cfg80211_put_bss(&wdev->authtry_bsses[i]->pub);
  36. }
  37. wdev->authtry_bsses[i] = NULL;
  38. done = true;
  39. break;
  40. }
  41. }
  42. if (done) {
  43. nl80211_send_rx_auth(rdev, dev, buf, len, GFP_KERNEL);
  44. cfg80211_sme_rx_auth(dev, buf, len);
  45. }
  46. wdev_unlock(wdev);
  47. }
  48. EXPORT_SYMBOL(cfg80211_send_rx_auth);
  49. void cfg80211_send_rx_assoc(struct net_device *dev, const u8 *buf, size_t len)
  50. {
  51. u16 status_code;
  52. struct wireless_dev *wdev = dev->ieee80211_ptr;
  53. struct wiphy *wiphy = wdev->wiphy;
  54. struct cfg80211_registered_device *rdev = wiphy_to_dev(wiphy);
  55. struct ieee80211_mgmt *mgmt = (struct ieee80211_mgmt *)buf;
  56. u8 *ie = mgmt->u.assoc_resp.variable;
  57. int i, ieoffs = offsetof(struct ieee80211_mgmt, u.assoc_resp.variable);
  58. struct cfg80211_internal_bss *bss = NULL;
  59. wdev_lock(wdev);
  60. status_code = le16_to_cpu(mgmt->u.assoc_resp.status_code);
  61. /*
  62. * This is a bit of a hack, we don't notify userspace of
  63. * a (re-)association reply if we tried to send a reassoc
  64. * and got a reject -- we only try again with an assoc
  65. * frame instead of reassoc.
  66. */
  67. if (status_code != WLAN_STATUS_SUCCESS && wdev->conn &&
  68. cfg80211_sme_failed_reassoc(wdev))
  69. goto out;
  70. nl80211_send_rx_assoc(rdev, dev, buf, len, GFP_KERNEL);
  71. if (status_code == WLAN_STATUS_SUCCESS) {
  72. for (i = 0; i < MAX_AUTH_BSSES; i++) {
  73. if (!wdev->auth_bsses[i])
  74. continue;
  75. if (memcmp(wdev->auth_bsses[i]->pub.bssid, mgmt->bssid,
  76. ETH_ALEN) == 0) {
  77. bss = wdev->auth_bsses[i];
  78. wdev->auth_bsses[i] = NULL;
  79. /* additional reference to drop hold */
  80. cfg80211_ref_bss(bss);
  81. break;
  82. }
  83. }
  84. /*
  85. * We might be coming here because the driver reported
  86. * a successful association at the same time as the
  87. * user requested a deauth. In that case, we will have
  88. * removed the BSS from the auth_bsses list due to the
  89. * deauth request when the assoc response makes it. If
  90. * the two code paths acquire the lock the other way
  91. * around, that's just the standard situation of a
  92. * deauth being requested while connected.
  93. */
  94. if (!bss)
  95. goto out;
  96. } else if (wdev->conn) {
  97. cfg80211_sme_failed_assoc(wdev);
  98. /*
  99. * do not call connect_result() now because the
  100. * sme will schedule work that does it later.
  101. */
  102. goto out;
  103. }
  104. if (!wdev->conn && wdev->sme_state == CFG80211_SME_IDLE) {
  105. /*
  106. * This is for the userspace SME, the CONNECTING
  107. * state will be changed to CONNECTED by
  108. * __cfg80211_connect_result() below.
  109. */
  110. wdev->sme_state = CFG80211_SME_CONNECTING;
  111. }
  112. /* this consumes one bss reference (unless bss is NULL) */
  113. __cfg80211_connect_result(dev, mgmt->bssid, NULL, 0, ie, len - ieoffs,
  114. status_code,
  115. status_code == WLAN_STATUS_SUCCESS,
  116. bss ? &bss->pub : NULL);
  117. /* drop hold now, and also reference acquired above */
  118. if (bss) {
  119. cfg80211_unhold_bss(bss);
  120. cfg80211_put_bss(&bss->pub);
  121. }
  122. out:
  123. wdev_unlock(wdev);
  124. }
  125. EXPORT_SYMBOL(cfg80211_send_rx_assoc);
  126. void __cfg80211_send_deauth(struct net_device *dev,
  127. const u8 *buf, size_t len)
  128. {
  129. struct wireless_dev *wdev = dev->ieee80211_ptr;
  130. struct wiphy *wiphy = wdev->wiphy;
  131. struct cfg80211_registered_device *rdev = wiphy_to_dev(wiphy);
  132. struct ieee80211_mgmt *mgmt = (struct ieee80211_mgmt *)buf;
  133. const u8 *bssid = mgmt->bssid;
  134. int i;
  135. bool found = false, was_current = false;
  136. ASSERT_WDEV_LOCK(wdev);
  137. if (wdev->current_bss &&
  138. memcmp(wdev->current_bss->pub.bssid, bssid, ETH_ALEN) == 0) {
  139. cfg80211_unhold_bss(wdev->current_bss);
  140. cfg80211_put_bss(&wdev->current_bss->pub);
  141. wdev->current_bss = NULL;
  142. found = true;
  143. was_current = true;
  144. } else for (i = 0; i < MAX_AUTH_BSSES; i++) {
  145. if (wdev->auth_bsses[i] &&
  146. memcmp(wdev->auth_bsses[i]->pub.bssid, bssid, ETH_ALEN) == 0) {
  147. cfg80211_unhold_bss(wdev->auth_bsses[i]);
  148. cfg80211_put_bss(&wdev->auth_bsses[i]->pub);
  149. wdev->auth_bsses[i] = NULL;
  150. found = true;
  151. break;
  152. }
  153. if (wdev->authtry_bsses[i] &&
  154. memcmp(wdev->authtry_bsses[i]->pub.bssid, bssid,
  155. ETH_ALEN) == 0 &&
  156. memcmp(mgmt->sa, dev->dev_addr, ETH_ALEN) == 0) {
  157. cfg80211_unhold_bss(wdev->authtry_bsses[i]);
  158. cfg80211_put_bss(&wdev->authtry_bsses[i]->pub);
  159. wdev->authtry_bsses[i] = NULL;
  160. found = true;
  161. break;
  162. }
  163. }
  164. if (!found)
  165. return;
  166. nl80211_send_deauth(rdev, dev, buf, len, GFP_KERNEL);
  167. if (wdev->sme_state == CFG80211_SME_CONNECTED && was_current) {
  168. u16 reason_code;
  169. bool from_ap;
  170. reason_code = le16_to_cpu(mgmt->u.deauth.reason_code);
  171. from_ap = memcmp(mgmt->sa, dev->dev_addr, ETH_ALEN) != 0;
  172. __cfg80211_disconnected(dev, NULL, 0, reason_code, from_ap);
  173. } else if (wdev->sme_state == CFG80211_SME_CONNECTING) {
  174. __cfg80211_connect_result(dev, mgmt->bssid, NULL, 0, NULL, 0,
  175. WLAN_STATUS_UNSPECIFIED_FAILURE,
  176. false, NULL);
  177. }
  178. }
  179. EXPORT_SYMBOL(__cfg80211_send_deauth);
  180. void cfg80211_send_deauth(struct net_device *dev, const u8 *buf, size_t len)
  181. {
  182. struct wireless_dev *wdev = dev->ieee80211_ptr;
  183. wdev_lock(wdev);
  184. __cfg80211_send_deauth(dev, buf, len);
  185. wdev_unlock(wdev);
  186. }
  187. EXPORT_SYMBOL(cfg80211_send_deauth);
  188. void __cfg80211_send_disassoc(struct net_device *dev,
  189. const u8 *buf, size_t len)
  190. {
  191. struct wireless_dev *wdev = dev->ieee80211_ptr;
  192. struct wiphy *wiphy = wdev->wiphy;
  193. struct cfg80211_registered_device *rdev = wiphy_to_dev(wiphy);
  194. struct ieee80211_mgmt *mgmt = (struct ieee80211_mgmt *)buf;
  195. const u8 *bssid = mgmt->bssid;
  196. int i;
  197. u16 reason_code;
  198. bool from_ap;
  199. bool done = false;
  200. ASSERT_WDEV_LOCK(wdev);
  201. nl80211_send_disassoc(rdev, dev, buf, len, GFP_KERNEL);
  202. if (wdev->sme_state != CFG80211_SME_CONNECTED)
  203. return;
  204. if (wdev->current_bss &&
  205. memcmp(wdev->current_bss->pub.bssid, bssid, ETH_ALEN) == 0) {
  206. for (i = 0; i < MAX_AUTH_BSSES; i++) {
  207. if (wdev->authtry_bsses[i] || wdev->auth_bsses[i])
  208. continue;
  209. wdev->auth_bsses[i] = wdev->current_bss;
  210. wdev->current_bss = NULL;
  211. done = true;
  212. cfg80211_sme_disassoc(dev, i);
  213. break;
  214. }
  215. WARN_ON(!done);
  216. } else
  217. WARN_ON(1);
  218. reason_code = le16_to_cpu(mgmt->u.disassoc.reason_code);
  219. from_ap = memcmp(mgmt->sa, dev->dev_addr, ETH_ALEN) != 0;
  220. __cfg80211_disconnected(dev, NULL, 0, reason_code, from_ap);
  221. }
  222. EXPORT_SYMBOL(__cfg80211_send_disassoc);
  223. void cfg80211_send_disassoc(struct net_device *dev, const u8 *buf, size_t len)
  224. {
  225. struct wireless_dev *wdev = dev->ieee80211_ptr;
  226. wdev_lock(wdev);
  227. __cfg80211_send_disassoc(dev, buf, len);
  228. wdev_unlock(wdev);
  229. }
  230. EXPORT_SYMBOL(cfg80211_send_disassoc);
  231. void cfg80211_send_unprot_deauth(struct net_device *dev, const u8 *buf,
  232. size_t len)
  233. {
  234. struct wireless_dev *wdev = dev->ieee80211_ptr;
  235. struct wiphy *wiphy = wdev->wiphy;
  236. struct cfg80211_registered_device *rdev = wiphy_to_dev(wiphy);
  237. nl80211_send_unprot_deauth(rdev, dev, buf, len, GFP_ATOMIC);
  238. }
  239. EXPORT_SYMBOL(cfg80211_send_unprot_deauth);
  240. void cfg80211_send_unprot_disassoc(struct net_device *dev, const u8 *buf,
  241. size_t len)
  242. {
  243. struct wireless_dev *wdev = dev->ieee80211_ptr;
  244. struct wiphy *wiphy = wdev->wiphy;
  245. struct cfg80211_registered_device *rdev = wiphy_to_dev(wiphy);
  246. nl80211_send_unprot_disassoc(rdev, dev, buf, len, GFP_ATOMIC);
  247. }
  248. EXPORT_SYMBOL(cfg80211_send_unprot_disassoc);
  249. static void __cfg80211_auth_remove(struct wireless_dev *wdev, const u8 *addr)
  250. {
  251. int i;
  252. bool done = false;
  253. ASSERT_WDEV_LOCK(wdev);
  254. for (i = 0; addr && i < MAX_AUTH_BSSES; i++) {
  255. if (wdev->authtry_bsses[i] &&
  256. memcmp(wdev->authtry_bsses[i]->pub.bssid,
  257. addr, ETH_ALEN) == 0) {
  258. cfg80211_unhold_bss(wdev->authtry_bsses[i]);
  259. cfg80211_put_bss(&wdev->authtry_bsses[i]->pub);
  260. wdev->authtry_bsses[i] = NULL;
  261. done = true;
  262. break;
  263. }
  264. }
  265. WARN_ON(!done);
  266. }
  267. void __cfg80211_auth_canceled(struct net_device *dev, const u8 *addr)
  268. {
  269. __cfg80211_auth_remove(dev->ieee80211_ptr, addr);
  270. }
  271. EXPORT_SYMBOL(__cfg80211_auth_canceled);
  272. void cfg80211_send_auth_timeout(struct net_device *dev, const u8 *addr)
  273. {
  274. struct wireless_dev *wdev = dev->ieee80211_ptr;
  275. struct wiphy *wiphy = wdev->wiphy;
  276. struct cfg80211_registered_device *rdev = wiphy_to_dev(wiphy);
  277. wdev_lock(wdev);
  278. nl80211_send_auth_timeout(rdev, dev, addr, GFP_KERNEL);
  279. if (wdev->sme_state == CFG80211_SME_CONNECTING)
  280. __cfg80211_connect_result(dev, addr, NULL, 0, NULL, 0,
  281. WLAN_STATUS_UNSPECIFIED_FAILURE,
  282. false, NULL);
  283. __cfg80211_auth_remove(wdev, addr);
  284. wdev_unlock(wdev);
  285. }
  286. EXPORT_SYMBOL(cfg80211_send_auth_timeout);
  287. void cfg80211_send_assoc_timeout(struct net_device *dev, const u8 *addr)
  288. {
  289. struct wireless_dev *wdev = dev->ieee80211_ptr;
  290. struct wiphy *wiphy = wdev->wiphy;
  291. struct cfg80211_registered_device *rdev = wiphy_to_dev(wiphy);
  292. int i;
  293. bool done = false;
  294. wdev_lock(wdev);
  295. nl80211_send_assoc_timeout(rdev, dev, addr, GFP_KERNEL);
  296. if (wdev->sme_state == CFG80211_SME_CONNECTING)
  297. __cfg80211_connect_result(dev, addr, NULL, 0, NULL, 0,
  298. WLAN_STATUS_UNSPECIFIED_FAILURE,
  299. false, NULL);
  300. for (i = 0; addr && i < MAX_AUTH_BSSES; i++) {
  301. if (wdev->auth_bsses[i] &&
  302. memcmp(wdev->auth_bsses[i]->pub.bssid,
  303. addr, ETH_ALEN) == 0) {
  304. cfg80211_unhold_bss(wdev->auth_bsses[i]);
  305. cfg80211_put_bss(&wdev->auth_bsses[i]->pub);
  306. wdev->auth_bsses[i] = NULL;
  307. done = true;
  308. break;
  309. }
  310. }
  311. WARN_ON(!done);
  312. wdev_unlock(wdev);
  313. }
  314. EXPORT_SYMBOL(cfg80211_send_assoc_timeout);
  315. void cfg80211_michael_mic_failure(struct net_device *dev, const u8 *addr,
  316. enum nl80211_key_type key_type, int key_id,
  317. const u8 *tsc, gfp_t gfp)
  318. {
  319. struct wiphy *wiphy = dev->ieee80211_ptr->wiphy;
  320. struct cfg80211_registered_device *rdev = wiphy_to_dev(wiphy);
  321. #ifdef CONFIG_CFG80211_WEXT
  322. union iwreq_data wrqu;
  323. char *buf = kmalloc(128, gfp);
  324. if (buf) {
  325. sprintf(buf, "MLME-MICHAELMICFAILURE.indication("
  326. "keyid=%d %scast addr=%pM)", key_id,
  327. key_type == NL80211_KEYTYPE_GROUP ? "broad" : "uni",
  328. addr);
  329. memset(&wrqu, 0, sizeof(wrqu));
  330. wrqu.data.length = strlen(buf);
  331. wireless_send_event(dev, IWEVCUSTOM, &wrqu, buf);
  332. kfree(buf);
  333. }
  334. #endif
  335. nl80211_michael_mic_failure(rdev, dev, addr, key_type, key_id, tsc, gfp);
  336. }
  337. EXPORT_SYMBOL(cfg80211_michael_mic_failure);
  338. /* some MLME handling for userspace SME */
  339. int __cfg80211_mlme_auth(struct cfg80211_registered_device *rdev,
  340. struct net_device *dev,
  341. struct ieee80211_channel *chan,
  342. enum nl80211_auth_type auth_type,
  343. const u8 *bssid,
  344. const u8 *ssid, int ssid_len,
  345. const u8 *ie, int ie_len,
  346. const u8 *key, int key_len, int key_idx,
  347. bool local_state_change)
  348. {
  349. struct wireless_dev *wdev = dev->ieee80211_ptr;
  350. struct cfg80211_auth_request req;
  351. struct cfg80211_internal_bss *bss;
  352. int i, err, slot = -1, nfree = 0;
  353. ASSERT_WDEV_LOCK(wdev);
  354. if (auth_type == NL80211_AUTHTYPE_SHARED_KEY)
  355. if (!key || !key_len || key_idx < 0 || key_idx > 4)
  356. return -EINVAL;
  357. if (wdev->current_bss &&
  358. memcmp(bssid, wdev->current_bss->pub.bssid, ETH_ALEN) == 0)
  359. return -EALREADY;
  360. for (i = 0; i < MAX_AUTH_BSSES; i++) {
  361. if (wdev->authtry_bsses[i] &&
  362. memcmp(bssid, wdev->authtry_bsses[i]->pub.bssid,
  363. ETH_ALEN) == 0)
  364. return -EALREADY;
  365. if (wdev->auth_bsses[i] &&
  366. memcmp(bssid, wdev->auth_bsses[i]->pub.bssid,
  367. ETH_ALEN) == 0)
  368. return -EALREADY;
  369. }
  370. memset(&req, 0, sizeof(req));
  371. req.local_state_change = local_state_change;
  372. req.ie = ie;
  373. req.ie_len = ie_len;
  374. req.auth_type = auth_type;
  375. req.bss = cfg80211_get_bss(&rdev->wiphy, chan, bssid, ssid, ssid_len,
  376. WLAN_CAPABILITY_ESS, WLAN_CAPABILITY_ESS);
  377. req.key = key;
  378. req.key_len = key_len;
  379. req.key_idx = key_idx;
  380. if (!req.bss)
  381. return -ENOENT;
  382. bss = bss_from_pub(req.bss);
  383. for (i = 0; i < MAX_AUTH_BSSES; i++) {
  384. if (!wdev->auth_bsses[i] && !wdev->authtry_bsses[i]) {
  385. slot = i;
  386. nfree++;
  387. }
  388. }
  389. /* we need one free slot for disassoc and one for this auth */
  390. if (nfree < 2) {
  391. err = -ENOSPC;
  392. goto out;
  393. }
  394. if (local_state_change)
  395. wdev->auth_bsses[slot] = bss;
  396. else
  397. wdev->authtry_bsses[slot] = bss;
  398. cfg80211_hold_bss(bss);
  399. err = rdev->ops->auth(&rdev->wiphy, dev, &req);
  400. if (err) {
  401. if (local_state_change)
  402. wdev->auth_bsses[slot] = NULL;
  403. else
  404. wdev->authtry_bsses[slot] = NULL;
  405. cfg80211_unhold_bss(bss);
  406. }
  407. out:
  408. if (err)
  409. cfg80211_put_bss(req.bss);
  410. return err;
  411. }
  412. int cfg80211_mlme_auth(struct cfg80211_registered_device *rdev,
  413. struct net_device *dev, struct ieee80211_channel *chan,
  414. enum nl80211_auth_type auth_type, const u8 *bssid,
  415. const u8 *ssid, int ssid_len,
  416. const u8 *ie, int ie_len,
  417. const u8 *key, int key_len, int key_idx,
  418. bool local_state_change)
  419. {
  420. int err;
  421. wdev_lock(dev->ieee80211_ptr);
  422. err = __cfg80211_mlme_auth(rdev, dev, chan, auth_type, bssid,
  423. ssid, ssid_len, ie, ie_len,
  424. key, key_len, key_idx, local_state_change);
  425. wdev_unlock(dev->ieee80211_ptr);
  426. return err;
  427. }
  428. /* Do a logical ht_capa &= ht_capa_mask. */
  429. void cfg80211_oper_and_ht_capa(struct ieee80211_ht_cap *ht_capa,
  430. const struct ieee80211_ht_cap *ht_capa_mask)
  431. {
  432. int i;
  433. u8 *p1, *p2;
  434. if (!ht_capa_mask) {
  435. memset(ht_capa, 0, sizeof(*ht_capa));
  436. return;
  437. }
  438. p1 = (u8*)(ht_capa);
  439. p2 = (u8*)(ht_capa_mask);
  440. for (i = 0; i<sizeof(*ht_capa); i++)
  441. p1[i] &= p2[i];
  442. }
  443. int __cfg80211_mlme_assoc(struct cfg80211_registered_device *rdev,
  444. struct net_device *dev,
  445. struct ieee80211_channel *chan,
  446. const u8 *bssid, const u8 *prev_bssid,
  447. const u8 *ssid, int ssid_len,
  448. const u8 *ie, int ie_len, bool use_mfp,
  449. struct cfg80211_crypto_settings *crypt,
  450. u32 assoc_flags, struct ieee80211_ht_cap *ht_capa,
  451. struct ieee80211_ht_cap *ht_capa_mask)
  452. {
  453. struct wireless_dev *wdev = dev->ieee80211_ptr;
  454. struct cfg80211_assoc_request req;
  455. struct cfg80211_internal_bss *bss;
  456. int i, err, slot = -1;
  457. bool was_connected = false;
  458. ASSERT_WDEV_LOCK(wdev);
  459. memset(&req, 0, sizeof(req));
  460. if (wdev->current_bss && prev_bssid &&
  461. memcmp(wdev->current_bss->pub.bssid, prev_bssid, ETH_ALEN) == 0) {
  462. /*
  463. * Trying to reassociate: Allow this to proceed and let the old
  464. * association to be dropped when the new one is completed.
  465. */
  466. if (wdev->sme_state == CFG80211_SME_CONNECTED) {
  467. was_connected = true;
  468. wdev->sme_state = CFG80211_SME_CONNECTING;
  469. }
  470. } else if (wdev->current_bss)
  471. return -EALREADY;
  472. req.ie = ie;
  473. req.ie_len = ie_len;
  474. memcpy(&req.crypto, crypt, sizeof(req.crypto));
  475. req.use_mfp = use_mfp;
  476. req.prev_bssid = prev_bssid;
  477. req.flags = assoc_flags;
  478. if (ht_capa)
  479. memcpy(&req.ht_capa, ht_capa, sizeof(req.ht_capa));
  480. if (ht_capa_mask)
  481. memcpy(&req.ht_capa_mask, ht_capa_mask,
  482. sizeof(req.ht_capa_mask));
  483. cfg80211_oper_and_ht_capa(&req.ht_capa_mask,
  484. rdev->wiphy.ht_capa_mod_mask);
  485. req.bss = cfg80211_get_bss(&rdev->wiphy, chan, bssid, ssid, ssid_len,
  486. WLAN_CAPABILITY_ESS, WLAN_CAPABILITY_ESS);
  487. if (!req.bss) {
  488. if (was_connected)
  489. wdev->sme_state = CFG80211_SME_CONNECTED;
  490. return -ENOENT;
  491. }
  492. bss = bss_from_pub(req.bss);
  493. for (i = 0; i < MAX_AUTH_BSSES; i++) {
  494. if (bss == wdev->auth_bsses[i]) {
  495. slot = i;
  496. break;
  497. }
  498. }
  499. if (slot < 0) {
  500. err = -ENOTCONN;
  501. goto out;
  502. }
  503. err = rdev->ops->assoc(&rdev->wiphy, dev, &req);
  504. out:
  505. if (err && was_connected)
  506. wdev->sme_state = CFG80211_SME_CONNECTED;
  507. /* still a reference in wdev->auth_bsses[slot] */
  508. cfg80211_put_bss(req.bss);
  509. return err;
  510. }
  511. int cfg80211_mlme_assoc(struct cfg80211_registered_device *rdev,
  512. struct net_device *dev,
  513. struct ieee80211_channel *chan,
  514. const u8 *bssid, const u8 *prev_bssid,
  515. const u8 *ssid, int ssid_len,
  516. const u8 *ie, int ie_len, bool use_mfp,
  517. struct cfg80211_crypto_settings *crypt,
  518. u32 assoc_flags, struct ieee80211_ht_cap *ht_capa,
  519. struct ieee80211_ht_cap *ht_capa_mask)
  520. {
  521. struct wireless_dev *wdev = dev->ieee80211_ptr;
  522. int err;
  523. wdev_lock(wdev);
  524. err = __cfg80211_mlme_assoc(rdev, dev, chan, bssid, prev_bssid,
  525. ssid, ssid_len, ie, ie_len, use_mfp, crypt,
  526. assoc_flags, ht_capa, ht_capa_mask);
  527. wdev_unlock(wdev);
  528. return err;
  529. }
  530. int __cfg80211_mlme_deauth(struct cfg80211_registered_device *rdev,
  531. struct net_device *dev, const u8 *bssid,
  532. const u8 *ie, int ie_len, u16 reason,
  533. bool local_state_change)
  534. {
  535. struct wireless_dev *wdev = dev->ieee80211_ptr;
  536. struct cfg80211_deauth_request req;
  537. int i;
  538. ASSERT_WDEV_LOCK(wdev);
  539. memset(&req, 0, sizeof(req));
  540. req.reason_code = reason;
  541. req.local_state_change = local_state_change;
  542. req.ie = ie;
  543. req.ie_len = ie_len;
  544. if (wdev->current_bss &&
  545. memcmp(wdev->current_bss->pub.bssid, bssid, ETH_ALEN) == 0) {
  546. req.bss = &wdev->current_bss->pub;
  547. } else for (i = 0; i < MAX_AUTH_BSSES; i++) {
  548. if (wdev->auth_bsses[i] &&
  549. memcmp(bssid, wdev->auth_bsses[i]->pub.bssid, ETH_ALEN) == 0) {
  550. req.bss = &wdev->auth_bsses[i]->pub;
  551. break;
  552. }
  553. if (wdev->authtry_bsses[i] &&
  554. memcmp(bssid, wdev->authtry_bsses[i]->pub.bssid, ETH_ALEN) == 0) {
  555. req.bss = &wdev->authtry_bsses[i]->pub;
  556. break;
  557. }
  558. }
  559. if (!req.bss)
  560. return -ENOTCONN;
  561. return rdev->ops->deauth(&rdev->wiphy, dev, &req, wdev);
  562. }
  563. int cfg80211_mlme_deauth(struct cfg80211_registered_device *rdev,
  564. struct net_device *dev, const u8 *bssid,
  565. const u8 *ie, int ie_len, u16 reason,
  566. bool local_state_change)
  567. {
  568. struct wireless_dev *wdev = dev->ieee80211_ptr;
  569. int err;
  570. wdev_lock(wdev);
  571. err = __cfg80211_mlme_deauth(rdev, dev, bssid, ie, ie_len, reason,
  572. local_state_change);
  573. wdev_unlock(wdev);
  574. return err;
  575. }
  576. static int __cfg80211_mlme_disassoc(struct cfg80211_registered_device *rdev,
  577. struct net_device *dev, const u8 *bssid,
  578. const u8 *ie, int ie_len, u16 reason,
  579. bool local_state_change)
  580. {
  581. struct wireless_dev *wdev = dev->ieee80211_ptr;
  582. struct cfg80211_disassoc_request req;
  583. ASSERT_WDEV_LOCK(wdev);
  584. if (wdev->sme_state != CFG80211_SME_CONNECTED)
  585. return -ENOTCONN;
  586. if (WARN_ON(!wdev->current_bss))
  587. return -ENOTCONN;
  588. memset(&req, 0, sizeof(req));
  589. req.reason_code = reason;
  590. req.local_state_change = local_state_change;
  591. req.ie = ie;
  592. req.ie_len = ie_len;
  593. if (memcmp(wdev->current_bss->pub.bssid, bssid, ETH_ALEN) == 0)
  594. req.bss = &wdev->current_bss->pub;
  595. else
  596. return -ENOTCONN;
  597. return rdev->ops->disassoc(&rdev->wiphy, dev, &req, wdev);
  598. }
  599. int cfg80211_mlme_disassoc(struct cfg80211_registered_device *rdev,
  600. struct net_device *dev, const u8 *bssid,
  601. const u8 *ie, int ie_len, u16 reason,
  602. bool local_state_change)
  603. {
  604. struct wireless_dev *wdev = dev->ieee80211_ptr;
  605. int err;
  606. wdev_lock(wdev);
  607. err = __cfg80211_mlme_disassoc(rdev, dev, bssid, ie, ie_len, reason,
  608. local_state_change);
  609. wdev_unlock(wdev);
  610. return err;
  611. }
  612. void cfg80211_mlme_down(struct cfg80211_registered_device *rdev,
  613. struct net_device *dev)
  614. {
  615. struct wireless_dev *wdev = dev->ieee80211_ptr;
  616. struct cfg80211_deauth_request req;
  617. int i;
  618. ASSERT_WDEV_LOCK(wdev);
  619. if (!rdev->ops->deauth)
  620. return;
  621. memset(&req, 0, sizeof(req));
  622. req.reason_code = WLAN_REASON_DEAUTH_LEAVING;
  623. req.ie = NULL;
  624. req.ie_len = 0;
  625. if (wdev->current_bss) {
  626. req.bss = &wdev->current_bss->pub;
  627. rdev->ops->deauth(&rdev->wiphy, dev, &req, wdev);
  628. if (wdev->current_bss) {
  629. cfg80211_unhold_bss(wdev->current_bss);
  630. cfg80211_put_bss(&wdev->current_bss->pub);
  631. wdev->current_bss = NULL;
  632. }
  633. }
  634. for (i = 0; i < MAX_AUTH_BSSES; i++) {
  635. if (wdev->auth_bsses[i]) {
  636. req.bss = &wdev->auth_bsses[i]->pub;
  637. rdev->ops->deauth(&rdev->wiphy, dev, &req, wdev);
  638. if (wdev->auth_bsses[i]) {
  639. cfg80211_unhold_bss(wdev->auth_bsses[i]);
  640. cfg80211_put_bss(&wdev->auth_bsses[i]->pub);
  641. wdev->auth_bsses[i] = NULL;
  642. }
  643. }
  644. if (wdev->authtry_bsses[i]) {
  645. req.bss = &wdev->authtry_bsses[i]->pub;
  646. rdev->ops->deauth(&rdev->wiphy, dev, &req, wdev);
  647. if (wdev->authtry_bsses[i]) {
  648. cfg80211_unhold_bss(wdev->authtry_bsses[i]);
  649. cfg80211_put_bss(&wdev->authtry_bsses[i]->pub);
  650. wdev->authtry_bsses[i] = NULL;
  651. }
  652. }
  653. }
  654. }
  655. void cfg80211_ready_on_channel(struct net_device *dev, u64 cookie,
  656. struct ieee80211_channel *chan,
  657. enum nl80211_channel_type channel_type,
  658. unsigned int duration, gfp_t gfp)
  659. {
  660. struct wiphy *wiphy = dev->ieee80211_ptr->wiphy;
  661. struct cfg80211_registered_device *rdev = wiphy_to_dev(wiphy);
  662. nl80211_send_remain_on_channel(rdev, dev, cookie, chan, channel_type,
  663. duration, gfp);
  664. }
  665. EXPORT_SYMBOL(cfg80211_ready_on_channel);
  666. void cfg80211_remain_on_channel_expired(struct net_device *dev,
  667. u64 cookie,
  668. struct ieee80211_channel *chan,
  669. enum nl80211_channel_type channel_type,
  670. gfp_t gfp)
  671. {
  672. struct wiphy *wiphy = dev->ieee80211_ptr->wiphy;
  673. struct cfg80211_registered_device *rdev = wiphy_to_dev(wiphy);
  674. nl80211_send_remain_on_channel_cancel(rdev, dev, cookie, chan,
  675. channel_type, gfp);
  676. }
  677. EXPORT_SYMBOL(cfg80211_remain_on_channel_expired);
  678. void cfg80211_new_sta(struct net_device *dev, const u8 *mac_addr,
  679. struct station_info *sinfo, gfp_t gfp)
  680. {
  681. struct wiphy *wiphy = dev->ieee80211_ptr->wiphy;
  682. struct cfg80211_registered_device *rdev = wiphy_to_dev(wiphy);
  683. nl80211_send_sta_event(rdev, dev, mac_addr, sinfo, gfp);
  684. }
  685. EXPORT_SYMBOL(cfg80211_new_sta);
  686. void cfg80211_del_sta(struct net_device *dev, const u8 *mac_addr, gfp_t gfp)
  687. {
  688. struct wiphy *wiphy = dev->ieee80211_ptr->wiphy;
  689. struct cfg80211_registered_device *rdev = wiphy_to_dev(wiphy);
  690. nl80211_send_sta_del_event(rdev, dev, mac_addr, gfp);
  691. }
  692. EXPORT_SYMBOL(cfg80211_del_sta);
  693. struct cfg80211_mgmt_registration {
  694. struct list_head list;
  695. u32 nlpid;
  696. int match_len;
  697. __le16 frame_type;
  698. u8 match[];
  699. };
  700. int cfg80211_mlme_register_mgmt(struct wireless_dev *wdev, u32 snd_pid,
  701. u16 frame_type, const u8 *match_data,
  702. int match_len)
  703. {
  704. struct wiphy *wiphy = wdev->wiphy;
  705. struct cfg80211_registered_device *rdev = wiphy_to_dev(wiphy);
  706. struct cfg80211_mgmt_registration *reg, *nreg;
  707. int err = 0;
  708. u16 mgmt_type;
  709. if (!wdev->wiphy->mgmt_stypes)
  710. return -EOPNOTSUPP;
  711. if ((frame_type & IEEE80211_FCTL_FTYPE) != IEEE80211_FTYPE_MGMT)
  712. return -EINVAL;
  713. if (frame_type & ~(IEEE80211_FCTL_FTYPE | IEEE80211_FCTL_STYPE))
  714. return -EINVAL;
  715. mgmt_type = (frame_type & IEEE80211_FCTL_STYPE) >> 4;
  716. if (!(wdev->wiphy->mgmt_stypes[wdev->iftype].rx & BIT(mgmt_type)))
  717. return -EINVAL;
  718. nreg = kzalloc(sizeof(*reg) + match_len, GFP_KERNEL);
  719. if (!nreg)
  720. return -ENOMEM;
  721. spin_lock_bh(&wdev->mgmt_registrations_lock);
  722. list_for_each_entry(reg, &wdev->mgmt_registrations, list) {
  723. int mlen = min(match_len, reg->match_len);
  724. if (frame_type != le16_to_cpu(reg->frame_type))
  725. continue;
  726. if (memcmp(reg->match, match_data, mlen) == 0) {
  727. err = -EALREADY;
  728. break;
  729. }
  730. }
  731. if (err) {
  732. kfree(nreg);
  733. goto out;
  734. }
  735. memcpy(nreg->match, match_data, match_len);
  736. nreg->match_len = match_len;
  737. nreg->nlpid = snd_pid;
  738. nreg->frame_type = cpu_to_le16(frame_type);
  739. list_add(&nreg->list, &wdev->mgmt_registrations);
  740. if (rdev->ops->mgmt_frame_register)
  741. rdev->ops->mgmt_frame_register(wiphy, wdev->netdev,
  742. frame_type, true);
  743. out:
  744. spin_unlock_bh(&wdev->mgmt_registrations_lock);
  745. return err;
  746. }
  747. void cfg80211_mlme_unregister_socket(struct wireless_dev *wdev, u32 nlpid)
  748. {
  749. struct wiphy *wiphy = wdev->wiphy;
  750. struct cfg80211_registered_device *rdev = wiphy_to_dev(wiphy);
  751. struct cfg80211_mgmt_registration *reg, *tmp;
  752. spin_lock_bh(&wdev->mgmt_registrations_lock);
  753. list_for_each_entry_safe(reg, tmp, &wdev->mgmt_registrations, list) {
  754. if (reg->nlpid != nlpid)
  755. continue;
  756. if (rdev->ops->mgmt_frame_register) {
  757. u16 frame_type = le16_to_cpu(reg->frame_type);
  758. rdev->ops->mgmt_frame_register(wiphy, wdev->netdev,
  759. frame_type, false);
  760. }
  761. list_del(&reg->list);
  762. kfree(reg);
  763. }
  764. spin_unlock_bh(&wdev->mgmt_registrations_lock);
  765. if (nlpid == wdev->ap_unexpected_nlpid)
  766. wdev->ap_unexpected_nlpid = 0;
  767. }
  768. void cfg80211_mlme_purge_registrations(struct wireless_dev *wdev)
  769. {
  770. struct cfg80211_mgmt_registration *reg, *tmp;
  771. spin_lock_bh(&wdev->mgmt_registrations_lock);
  772. list_for_each_entry_safe(reg, tmp, &wdev->mgmt_registrations, list) {
  773. list_del(&reg->list);
  774. kfree(reg);
  775. }
  776. spin_unlock_bh(&wdev->mgmt_registrations_lock);
  777. }
  778. int cfg80211_mlme_mgmt_tx(struct cfg80211_registered_device *rdev,
  779. struct net_device *dev,
  780. struct ieee80211_channel *chan, bool offchan,
  781. enum nl80211_channel_type channel_type,
  782. bool channel_type_valid, unsigned int wait,
  783. const u8 *buf, size_t len, bool no_cck,
  784. bool dont_wait_for_ack, u64 *cookie)
  785. {
  786. struct wireless_dev *wdev = dev->ieee80211_ptr;
  787. const struct ieee80211_mgmt *mgmt;
  788. u16 stype;
  789. if (!wdev->wiphy->mgmt_stypes)
  790. return -EOPNOTSUPP;
  791. if (!rdev->ops->mgmt_tx)
  792. return -EOPNOTSUPP;
  793. if (len < 24 + 1)
  794. return -EINVAL;
  795. mgmt = (const struct ieee80211_mgmt *) buf;
  796. if (!ieee80211_is_mgmt(mgmt->frame_control))
  797. return -EINVAL;
  798. stype = le16_to_cpu(mgmt->frame_control) & IEEE80211_FCTL_STYPE;
  799. if (!(wdev->wiphy->mgmt_stypes[wdev->iftype].tx & BIT(stype >> 4)))
  800. return -EINVAL;
  801. if (ieee80211_is_action(mgmt->frame_control) &&
  802. mgmt->u.action.category != WLAN_CATEGORY_PUBLIC) {
  803. int err = 0;
  804. wdev_lock(wdev);
  805. switch (wdev->iftype) {
  806. case NL80211_IFTYPE_ADHOC:
  807. case NL80211_IFTYPE_STATION:
  808. case NL80211_IFTYPE_P2P_CLIENT:
  809. if (!wdev->current_bss) {
  810. err = -ENOTCONN;
  811. break;
  812. }
  813. if (memcmp(wdev->current_bss->pub.bssid,
  814. mgmt->bssid, ETH_ALEN)) {
  815. err = -ENOTCONN;
  816. break;
  817. }
  818. /*
  819. * check for IBSS DA must be done by driver as
  820. * cfg80211 doesn't track the stations
  821. */
  822. if (wdev->iftype == NL80211_IFTYPE_ADHOC)
  823. break;
  824. /* for station, check that DA is the AP */
  825. if (memcmp(wdev->current_bss->pub.bssid,
  826. mgmt->da, ETH_ALEN)) {
  827. err = -ENOTCONN;
  828. break;
  829. }
  830. break;
  831. case NL80211_IFTYPE_AP:
  832. case NL80211_IFTYPE_P2P_GO:
  833. case NL80211_IFTYPE_AP_VLAN:
  834. if (memcmp(mgmt->bssid, dev->dev_addr, ETH_ALEN))
  835. err = -EINVAL;
  836. break;
  837. case NL80211_IFTYPE_MESH_POINT:
  838. if (memcmp(mgmt->sa, mgmt->bssid, ETH_ALEN)) {
  839. err = -EINVAL;
  840. break;
  841. }
  842. /*
  843. * check for mesh DA must be done by driver as
  844. * cfg80211 doesn't track the stations
  845. */
  846. break;
  847. default:
  848. err = -EOPNOTSUPP;
  849. break;
  850. }
  851. wdev_unlock(wdev);
  852. if (err)
  853. return err;
  854. }
  855. if (memcmp(mgmt->sa, dev->dev_addr, ETH_ALEN) != 0)
  856. return -EINVAL;
  857. /* Transmit the Action frame as requested by user space */
  858. return rdev->ops->mgmt_tx(&rdev->wiphy, dev, chan, offchan,
  859. channel_type, channel_type_valid,
  860. wait, buf, len, no_cck, dont_wait_for_ack,
  861. cookie);
  862. }
  863. bool cfg80211_rx_mgmt(struct net_device *dev, int freq, const u8 *buf,
  864. size_t len, gfp_t gfp)
  865. {
  866. struct wireless_dev *wdev = dev->ieee80211_ptr;
  867. struct wiphy *wiphy = wdev->wiphy;
  868. struct cfg80211_registered_device *rdev = wiphy_to_dev(wiphy);
  869. struct cfg80211_mgmt_registration *reg;
  870. const struct ieee80211_txrx_stypes *stypes =
  871. &wiphy->mgmt_stypes[wdev->iftype];
  872. struct ieee80211_mgmt *mgmt = (void *)buf;
  873. const u8 *data;
  874. int data_len;
  875. bool result = false;
  876. __le16 ftype = mgmt->frame_control &
  877. cpu_to_le16(IEEE80211_FCTL_FTYPE | IEEE80211_FCTL_STYPE);
  878. u16 stype;
  879. stype = (le16_to_cpu(mgmt->frame_control) & IEEE80211_FCTL_STYPE) >> 4;
  880. if (!(stypes->rx & BIT(stype)))
  881. return false;
  882. data = buf + ieee80211_hdrlen(mgmt->frame_control);
  883. data_len = len - ieee80211_hdrlen(mgmt->frame_control);
  884. spin_lock_bh(&wdev->mgmt_registrations_lock);
  885. list_for_each_entry(reg, &wdev->mgmt_registrations, list) {
  886. if (reg->frame_type != ftype)
  887. continue;
  888. if (reg->match_len > data_len)
  889. continue;
  890. if (memcmp(reg->match, data, reg->match_len))
  891. continue;
  892. /* found match! */
  893. /* Indicate the received Action frame to user space */
  894. if (nl80211_send_mgmt(rdev, dev, reg->nlpid, freq,
  895. buf, len, gfp))
  896. continue;
  897. result = true;
  898. break;
  899. }
  900. spin_unlock_bh(&wdev->mgmt_registrations_lock);
  901. return result;
  902. }
  903. EXPORT_SYMBOL(cfg80211_rx_mgmt);
  904. void cfg80211_mgmt_tx_status(struct net_device *dev, u64 cookie,
  905. const u8 *buf, size_t len, bool ack, gfp_t gfp)
  906. {
  907. struct wireless_dev *wdev = dev->ieee80211_ptr;
  908. struct wiphy *wiphy = wdev->wiphy;
  909. struct cfg80211_registered_device *rdev = wiphy_to_dev(wiphy);
  910. /* Indicate TX status of the Action frame to user space */
  911. nl80211_send_mgmt_tx_status(rdev, dev, cookie, buf, len, ack, gfp);
  912. }
  913. EXPORT_SYMBOL(cfg80211_mgmt_tx_status);
  914. void cfg80211_cqm_rssi_notify(struct net_device *dev,
  915. enum nl80211_cqm_rssi_threshold_event rssi_event,
  916. gfp_t gfp)
  917. {
  918. struct wireless_dev *wdev = dev->ieee80211_ptr;
  919. struct wiphy *wiphy = wdev->wiphy;
  920. struct cfg80211_registered_device *rdev = wiphy_to_dev(wiphy);
  921. /* Indicate roaming trigger event to user space */
  922. nl80211_send_cqm_rssi_notify(rdev, dev, rssi_event, gfp);
  923. }
  924. EXPORT_SYMBOL(cfg80211_cqm_rssi_notify);
  925. void cfg80211_cqm_pktloss_notify(struct net_device *dev,
  926. const u8 *peer, u32 num_packets, gfp_t gfp)
  927. {
  928. struct wireless_dev *wdev = dev->ieee80211_ptr;
  929. struct wiphy *wiphy = wdev->wiphy;
  930. struct cfg80211_registered_device *rdev = wiphy_to_dev(wiphy);
  931. /* Indicate roaming trigger event to user space */
  932. nl80211_send_cqm_pktloss_notify(rdev, dev, peer, num_packets, gfp);
  933. }
  934. EXPORT_SYMBOL(cfg80211_cqm_pktloss_notify);
  935. void cfg80211_gtk_rekey_notify(struct net_device *dev, const u8 *bssid,
  936. const u8 *replay_ctr, gfp_t gfp)
  937. {
  938. struct wireless_dev *wdev = dev->ieee80211_ptr;
  939. struct wiphy *wiphy = wdev->wiphy;
  940. struct cfg80211_registered_device *rdev = wiphy_to_dev(wiphy);
  941. nl80211_gtk_rekey_notify(rdev, dev, bssid, replay_ctr, gfp);
  942. }
  943. EXPORT_SYMBOL(cfg80211_gtk_rekey_notify);
  944. void cfg80211_pmksa_candidate_notify(struct net_device *dev, int index,
  945. const u8 *bssid, bool preauth, gfp_t gfp)
  946. {
  947. struct wireless_dev *wdev = dev->ieee80211_ptr;
  948. struct wiphy *wiphy = wdev->wiphy;
  949. struct cfg80211_registered_device *rdev = wiphy_to_dev(wiphy);
  950. nl80211_pmksa_candidate_notify(rdev, dev, index, bssid, preauth, gfp);
  951. }
  952. EXPORT_SYMBOL(cfg80211_pmksa_candidate_notify);
  953. bool cfg80211_rx_spurious_frame(struct net_device *dev,
  954. const u8 *addr, gfp_t gfp)
  955. {
  956. struct wireless_dev *wdev = dev->ieee80211_ptr;
  957. if (WARN_ON(wdev->iftype != NL80211_IFTYPE_AP &&
  958. wdev->iftype != NL80211_IFTYPE_P2P_GO))
  959. return false;
  960. return nl80211_unexpected_frame(dev, addr, gfp);
  961. }
  962. EXPORT_SYMBOL(cfg80211_rx_spurious_frame);
  963. bool cfg80211_rx_unexpected_4addr_frame(struct net_device *dev,
  964. const u8 *addr, gfp_t gfp)
  965. {
  966. struct wireless_dev *wdev = dev->ieee80211_ptr;
  967. if (WARN_ON(wdev->iftype != NL80211_IFTYPE_AP &&
  968. wdev->iftype != NL80211_IFTYPE_P2P_GO &&
  969. wdev->iftype != NL80211_IFTYPE_AP_VLAN))
  970. return false;
  971. return nl80211_unexpected_4addr_frame(dev, addr, gfp);
  972. }
  973. EXPORT_SYMBOL(cfg80211_rx_unexpected_4addr_frame);