cfg.c 31 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394959697989910010110210310410510610710810911011111211311411511611711811912012112212312412512612712812913013113213313413513613713813914014114214314414514614714814915015115215315415515615715815916016116216316416516616716816917017117217317417517617717817918018118218318418518618718818919019119219319419519619719819920020120220320420520620720820921021121221321421521621721821922022122222322422522622722822923023123223323423523623723823924024124224324424524624724824925025125225325425525625725825926026126226326426526626726826927027127227327427527627727827928028128228328428528628728828929029129229329429529629729829930030130230330430530630730830931031131231331431531631731831932032132232332432532632732832933033133233333433533633733833934034134234334434534634734834935035135235335435535635735835936036136236336436536636736836937037137237337437537637737837938038138238338438538638738838939039139239339439539639739839940040140240340440540640740840941041141241341441541641741841942042142242342442542642742842943043143243343443543643743843944044144244344444544644744844945045145245345445545645745845946046146246346446546646746846947047147247347447547647747847948048148248348448548648748848949049149249349449549649749849950050150250350450550650750850951051151251351451551651751851952052152252352452552652752852953053153253353453553653753853954054154254354454554654754854955055155255355455555655755855956056156256356456556656756856957057157257357457557657757857958058158258358458558658758858959059159259359459559659759859960060160260360460560660760860961061161261361461561661761861962062162262362462562662762862963063163263363463563663763863964064164264364464564664764864965065165265365465565665765865966066166266366466566666766866967067167267367467567667767867968068168268368468568668768868969069169269369469569669769869970070170270370470570670770870971071171271371471571671771871972072172272372472572672772872973073173273373473573673773873974074174274374474574674774874975075175275375475575675775875976076176276376476576676776876977077177277377477577677777877978078178278378478578678778878979079179279379479579679779879980080180280380480580680780880981081181281381481581681781881982082182282382482582682782882983083183283383483583683783883984084184284384484584684784884985085185285385485585685785885986086186286386486586686786886987087187287387487587687787887988088188288388488588688788888989089189289389489589689789889990090190290390490590690790890991091191291391491591691791891992092192292392492592692792892993093193293393493593693793893994094194294394494594694794894995095195295395495595695795895996096196296396496596696796896997097197297397497597697797897998098198298398498598698798898999099199299399499599699799899910001001100210031004100510061007100810091010101110121013101410151016101710181019102010211022102310241025102610271028102910301031103210331034103510361037103810391040104110421043104410451046104710481049105010511052105310541055105610571058105910601061106210631064106510661067106810691070107110721073107410751076107710781079108010811082108310841085108610871088108910901091109210931094109510961097109810991100110111021103110411051106110711081109111011111112111311141115111611171118111911201121112211231124112511261127112811291130113111321133113411351136113711381139114011411142114311441145114611471148114911501151115211531154115511561157115811591160116111621163116411651166116711681169117011711172117311741175117611771178117911801181118211831184118511861187118811891190119111921193119411951196119711981199120012011202120312041205120612071208120912101211121212131214121512161217121812191220122112221223122412251226122712281229123012311232123312341235123612371238123912401241124212431244124512461247124812491250125112521253125412551256125712581259126012611262126312641265126612671268126912701271127212731274127512761277127812791280128112821283128412851286128712881289129012911292129312941295129612971298129913001301130213031304130513061307
  1. /*
  2. * mac80211 configuration hooks for cfg80211
  3. *
  4. * Copyright 2006, 2007 Johannes Berg <johannes@sipsolutions.net>
  5. *
  6. * This file is GPLv2 as found in COPYING.
  7. */
  8. #include <linux/ieee80211.h>
  9. #include <linux/nl80211.h>
  10. #include <linux/rtnetlink.h>
  11. #include <net/net_namespace.h>
  12. #include <linux/rcupdate.h>
  13. #include <net/cfg80211.h>
  14. #include "ieee80211_i.h"
  15. #include "cfg.h"
  16. #include "rate.h"
  17. #include "mesh.h"
  18. static bool nl80211_type_check(enum nl80211_iftype type)
  19. {
  20. switch (type) {
  21. case NL80211_IFTYPE_ADHOC:
  22. case NL80211_IFTYPE_STATION:
  23. case NL80211_IFTYPE_MONITOR:
  24. #ifdef CONFIG_MAC80211_MESH
  25. case NL80211_IFTYPE_MESH_POINT:
  26. #endif
  27. case NL80211_IFTYPE_AP:
  28. case NL80211_IFTYPE_AP_VLAN:
  29. case NL80211_IFTYPE_WDS:
  30. return true;
  31. default:
  32. return false;
  33. }
  34. }
  35. static int ieee80211_add_iface(struct wiphy *wiphy, char *name,
  36. enum nl80211_iftype type, u32 *flags,
  37. struct vif_params *params)
  38. {
  39. struct ieee80211_local *local = wiphy_priv(wiphy);
  40. struct net_device *dev;
  41. struct ieee80211_sub_if_data *sdata;
  42. int err;
  43. if (!nl80211_type_check(type))
  44. return -EINVAL;
  45. err = ieee80211_if_add(local, name, &dev, type, params);
  46. if (err || type != NL80211_IFTYPE_MONITOR || !flags)
  47. return err;
  48. sdata = IEEE80211_DEV_TO_SUB_IF(dev);
  49. sdata->u.mntr_flags = *flags;
  50. return 0;
  51. }
  52. static int ieee80211_del_iface(struct wiphy *wiphy, int ifindex)
  53. {
  54. struct net_device *dev;
  55. struct ieee80211_sub_if_data *sdata;
  56. /* we're under RTNL */
  57. dev = __dev_get_by_index(&init_net, ifindex);
  58. if (!dev)
  59. return -ENODEV;
  60. sdata = IEEE80211_DEV_TO_SUB_IF(dev);
  61. ieee80211_if_remove(sdata);
  62. return 0;
  63. }
  64. static int ieee80211_change_iface(struct wiphy *wiphy, int ifindex,
  65. enum nl80211_iftype type, u32 *flags,
  66. struct vif_params *params)
  67. {
  68. struct net_device *dev;
  69. struct ieee80211_sub_if_data *sdata;
  70. int ret;
  71. /* we're under RTNL */
  72. dev = __dev_get_by_index(&init_net, ifindex);
  73. if (!dev)
  74. return -ENODEV;
  75. if (!nl80211_type_check(type))
  76. return -EINVAL;
  77. sdata = IEEE80211_DEV_TO_SUB_IF(dev);
  78. ret = ieee80211_if_change_type(sdata, type);
  79. if (ret)
  80. return ret;
  81. if (netif_running(sdata->dev))
  82. return -EBUSY;
  83. if (ieee80211_vif_is_mesh(&sdata->vif) && params->mesh_id_len)
  84. ieee80211_sdata_set_mesh_id(sdata,
  85. params->mesh_id_len,
  86. params->mesh_id);
  87. if (sdata->vif.type != NL80211_IFTYPE_MONITOR || !flags)
  88. return 0;
  89. sdata->u.mntr_flags = *flags;
  90. return 0;
  91. }
  92. static int ieee80211_add_key(struct wiphy *wiphy, struct net_device *dev,
  93. u8 key_idx, u8 *mac_addr,
  94. struct key_params *params)
  95. {
  96. struct ieee80211_sub_if_data *sdata;
  97. struct sta_info *sta = NULL;
  98. enum ieee80211_key_alg alg;
  99. struct ieee80211_key *key;
  100. int err;
  101. sdata = IEEE80211_DEV_TO_SUB_IF(dev);
  102. switch (params->cipher) {
  103. case WLAN_CIPHER_SUITE_WEP40:
  104. case WLAN_CIPHER_SUITE_WEP104:
  105. alg = ALG_WEP;
  106. break;
  107. case WLAN_CIPHER_SUITE_TKIP:
  108. alg = ALG_TKIP;
  109. break;
  110. case WLAN_CIPHER_SUITE_CCMP:
  111. alg = ALG_CCMP;
  112. break;
  113. case WLAN_CIPHER_SUITE_AES_CMAC:
  114. alg = ALG_AES_CMAC;
  115. break;
  116. default:
  117. return -EINVAL;
  118. }
  119. key = ieee80211_key_alloc(alg, key_idx, params->key_len, params->key);
  120. if (!key)
  121. return -ENOMEM;
  122. rcu_read_lock();
  123. if (mac_addr) {
  124. sta = sta_info_get(sdata->local, mac_addr);
  125. if (!sta) {
  126. ieee80211_key_free(key);
  127. err = -ENOENT;
  128. goto out_unlock;
  129. }
  130. }
  131. ieee80211_key_link(key, sdata, sta);
  132. err = 0;
  133. out_unlock:
  134. rcu_read_unlock();
  135. return err;
  136. }
  137. static int ieee80211_del_key(struct wiphy *wiphy, struct net_device *dev,
  138. u8 key_idx, u8 *mac_addr)
  139. {
  140. struct ieee80211_sub_if_data *sdata;
  141. struct sta_info *sta;
  142. int ret;
  143. sdata = IEEE80211_DEV_TO_SUB_IF(dev);
  144. rcu_read_lock();
  145. if (mac_addr) {
  146. ret = -ENOENT;
  147. sta = sta_info_get(sdata->local, mac_addr);
  148. if (!sta)
  149. goto out_unlock;
  150. if (sta->key) {
  151. ieee80211_key_free(sta->key);
  152. WARN_ON(sta->key);
  153. ret = 0;
  154. }
  155. goto out_unlock;
  156. }
  157. if (!sdata->keys[key_idx]) {
  158. ret = -ENOENT;
  159. goto out_unlock;
  160. }
  161. ieee80211_key_free(sdata->keys[key_idx]);
  162. WARN_ON(sdata->keys[key_idx]);
  163. ret = 0;
  164. out_unlock:
  165. rcu_read_unlock();
  166. return ret;
  167. }
  168. static int ieee80211_get_key(struct wiphy *wiphy, struct net_device *dev,
  169. u8 key_idx, u8 *mac_addr, void *cookie,
  170. void (*callback)(void *cookie,
  171. struct key_params *params))
  172. {
  173. struct ieee80211_sub_if_data *sdata;
  174. struct sta_info *sta = NULL;
  175. u8 seq[6] = {0};
  176. struct key_params params;
  177. struct ieee80211_key *key;
  178. u32 iv32;
  179. u16 iv16;
  180. int err = -ENOENT;
  181. sdata = IEEE80211_DEV_TO_SUB_IF(dev);
  182. rcu_read_lock();
  183. if (mac_addr) {
  184. sta = sta_info_get(sdata->local, mac_addr);
  185. if (!sta)
  186. goto out;
  187. key = sta->key;
  188. } else
  189. key = sdata->keys[key_idx];
  190. if (!key)
  191. goto out;
  192. memset(&params, 0, sizeof(params));
  193. switch (key->conf.alg) {
  194. case ALG_TKIP:
  195. params.cipher = WLAN_CIPHER_SUITE_TKIP;
  196. iv32 = key->u.tkip.tx.iv32;
  197. iv16 = key->u.tkip.tx.iv16;
  198. if (key->flags & KEY_FLAG_UPLOADED_TO_HARDWARE &&
  199. sdata->local->ops->get_tkip_seq)
  200. sdata->local->ops->get_tkip_seq(
  201. local_to_hw(sdata->local),
  202. key->conf.hw_key_idx,
  203. &iv32, &iv16);
  204. seq[0] = iv16 & 0xff;
  205. seq[1] = (iv16 >> 8) & 0xff;
  206. seq[2] = iv32 & 0xff;
  207. seq[3] = (iv32 >> 8) & 0xff;
  208. seq[4] = (iv32 >> 16) & 0xff;
  209. seq[5] = (iv32 >> 24) & 0xff;
  210. params.seq = seq;
  211. params.seq_len = 6;
  212. break;
  213. case ALG_CCMP:
  214. params.cipher = WLAN_CIPHER_SUITE_CCMP;
  215. seq[0] = key->u.ccmp.tx_pn[5];
  216. seq[1] = key->u.ccmp.tx_pn[4];
  217. seq[2] = key->u.ccmp.tx_pn[3];
  218. seq[3] = key->u.ccmp.tx_pn[2];
  219. seq[4] = key->u.ccmp.tx_pn[1];
  220. seq[5] = key->u.ccmp.tx_pn[0];
  221. params.seq = seq;
  222. params.seq_len = 6;
  223. break;
  224. case ALG_WEP:
  225. if (key->conf.keylen == 5)
  226. params.cipher = WLAN_CIPHER_SUITE_WEP40;
  227. else
  228. params.cipher = WLAN_CIPHER_SUITE_WEP104;
  229. break;
  230. case ALG_AES_CMAC:
  231. params.cipher = WLAN_CIPHER_SUITE_AES_CMAC;
  232. seq[0] = key->u.aes_cmac.tx_pn[5];
  233. seq[1] = key->u.aes_cmac.tx_pn[4];
  234. seq[2] = key->u.aes_cmac.tx_pn[3];
  235. seq[3] = key->u.aes_cmac.tx_pn[2];
  236. seq[4] = key->u.aes_cmac.tx_pn[1];
  237. seq[5] = key->u.aes_cmac.tx_pn[0];
  238. params.seq = seq;
  239. params.seq_len = 6;
  240. break;
  241. }
  242. params.key = key->conf.key;
  243. params.key_len = key->conf.keylen;
  244. callback(cookie, &params);
  245. err = 0;
  246. out:
  247. rcu_read_unlock();
  248. return err;
  249. }
  250. static int ieee80211_config_default_key(struct wiphy *wiphy,
  251. struct net_device *dev,
  252. u8 key_idx)
  253. {
  254. struct ieee80211_sub_if_data *sdata;
  255. rcu_read_lock();
  256. sdata = IEEE80211_DEV_TO_SUB_IF(dev);
  257. ieee80211_set_default_key(sdata, key_idx);
  258. rcu_read_unlock();
  259. return 0;
  260. }
  261. static int ieee80211_config_default_mgmt_key(struct wiphy *wiphy,
  262. struct net_device *dev,
  263. u8 key_idx)
  264. {
  265. struct ieee80211_sub_if_data *sdata;
  266. rcu_read_lock();
  267. sdata = IEEE80211_DEV_TO_SUB_IF(dev);
  268. ieee80211_set_default_mgmt_key(sdata, key_idx);
  269. rcu_read_unlock();
  270. return 0;
  271. }
  272. static void sta_set_sinfo(struct sta_info *sta, struct station_info *sinfo)
  273. {
  274. struct ieee80211_sub_if_data *sdata = sta->sdata;
  275. sinfo->filled = STATION_INFO_INACTIVE_TIME |
  276. STATION_INFO_RX_BYTES |
  277. STATION_INFO_TX_BYTES |
  278. STATION_INFO_TX_BITRATE;
  279. sinfo->inactive_time = jiffies_to_msecs(jiffies - sta->last_rx);
  280. sinfo->rx_bytes = sta->rx_bytes;
  281. sinfo->tx_bytes = sta->tx_bytes;
  282. if (sta->local->hw.flags & IEEE80211_HW_SIGNAL_DBM) {
  283. sinfo->filled |= STATION_INFO_SIGNAL;
  284. sinfo->signal = (s8)sta->last_signal;
  285. }
  286. sinfo->txrate.flags = 0;
  287. if (sta->last_tx_rate.flags & IEEE80211_TX_RC_MCS)
  288. sinfo->txrate.flags |= RATE_INFO_FLAGS_MCS;
  289. if (sta->last_tx_rate.flags & IEEE80211_TX_RC_40_MHZ_WIDTH)
  290. sinfo->txrate.flags |= RATE_INFO_FLAGS_40_MHZ_WIDTH;
  291. if (sta->last_tx_rate.flags & IEEE80211_TX_RC_SHORT_GI)
  292. sinfo->txrate.flags |= RATE_INFO_FLAGS_SHORT_GI;
  293. if (!(sta->last_tx_rate.flags & IEEE80211_TX_RC_MCS)) {
  294. struct ieee80211_supported_band *sband;
  295. sband = sta->local->hw.wiphy->bands[
  296. sta->local->hw.conf.channel->band];
  297. sinfo->txrate.legacy =
  298. sband->bitrates[sta->last_tx_rate.idx].bitrate;
  299. } else
  300. sinfo->txrate.mcs = sta->last_tx_rate.idx;
  301. if (ieee80211_vif_is_mesh(&sdata->vif)) {
  302. #ifdef CONFIG_MAC80211_MESH
  303. sinfo->filled |= STATION_INFO_LLID |
  304. STATION_INFO_PLID |
  305. STATION_INFO_PLINK_STATE;
  306. sinfo->llid = le16_to_cpu(sta->llid);
  307. sinfo->plid = le16_to_cpu(sta->plid);
  308. sinfo->plink_state = sta->plink_state;
  309. #endif
  310. }
  311. }
  312. static int ieee80211_dump_station(struct wiphy *wiphy, struct net_device *dev,
  313. int idx, u8 *mac, struct station_info *sinfo)
  314. {
  315. struct ieee80211_local *local = wdev_priv(dev->ieee80211_ptr);
  316. struct sta_info *sta;
  317. int ret = -ENOENT;
  318. rcu_read_lock();
  319. sta = sta_info_get_by_idx(local, idx, dev);
  320. if (sta) {
  321. ret = 0;
  322. memcpy(mac, sta->sta.addr, ETH_ALEN);
  323. sta_set_sinfo(sta, sinfo);
  324. }
  325. rcu_read_unlock();
  326. return ret;
  327. }
  328. static int ieee80211_get_station(struct wiphy *wiphy, struct net_device *dev,
  329. u8 *mac, struct station_info *sinfo)
  330. {
  331. struct ieee80211_local *local = wdev_priv(dev->ieee80211_ptr);
  332. struct sta_info *sta;
  333. int ret = -ENOENT;
  334. rcu_read_lock();
  335. /* XXX: verify sta->dev == dev */
  336. sta = sta_info_get(local, mac);
  337. if (sta) {
  338. ret = 0;
  339. sta_set_sinfo(sta, sinfo);
  340. }
  341. rcu_read_unlock();
  342. return ret;
  343. }
  344. /*
  345. * This handles both adding a beacon and setting new beacon info
  346. */
  347. static int ieee80211_config_beacon(struct ieee80211_sub_if_data *sdata,
  348. struct beacon_parameters *params)
  349. {
  350. struct beacon_data *new, *old;
  351. int new_head_len, new_tail_len;
  352. int size;
  353. int err = -EINVAL;
  354. old = sdata->u.ap.beacon;
  355. /* head must not be zero-length */
  356. if (params->head && !params->head_len)
  357. return -EINVAL;
  358. /*
  359. * This is a kludge. beacon interval should really be part
  360. * of the beacon information.
  361. */
  362. if (params->interval) {
  363. sdata->local->hw.conf.beacon_int = params->interval;
  364. err = ieee80211_hw_config(sdata->local,
  365. IEEE80211_CONF_CHANGE_BEACON_INTERVAL);
  366. if (err < 0)
  367. return err;
  368. /*
  369. * We updated some parameter so if below bails out
  370. * it's not an error.
  371. */
  372. err = 0;
  373. }
  374. /* Need to have a beacon head if we don't have one yet */
  375. if (!params->head && !old)
  376. return err;
  377. /* sorry, no way to start beaconing without dtim period */
  378. if (!params->dtim_period && !old)
  379. return err;
  380. /* new or old head? */
  381. if (params->head)
  382. new_head_len = params->head_len;
  383. else
  384. new_head_len = old->head_len;
  385. /* new or old tail? */
  386. if (params->tail || !old)
  387. /* params->tail_len will be zero for !params->tail */
  388. new_tail_len = params->tail_len;
  389. else
  390. new_tail_len = old->tail_len;
  391. size = sizeof(*new) + new_head_len + new_tail_len;
  392. new = kzalloc(size, GFP_KERNEL);
  393. if (!new)
  394. return -ENOMEM;
  395. /* start filling the new info now */
  396. /* new or old dtim period? */
  397. if (params->dtim_period)
  398. new->dtim_period = params->dtim_period;
  399. else
  400. new->dtim_period = old->dtim_period;
  401. /*
  402. * pointers go into the block we allocated,
  403. * memory is | beacon_data | head | tail |
  404. */
  405. new->head = ((u8 *) new) + sizeof(*new);
  406. new->tail = new->head + new_head_len;
  407. new->head_len = new_head_len;
  408. new->tail_len = new_tail_len;
  409. /* copy in head */
  410. if (params->head)
  411. memcpy(new->head, params->head, new_head_len);
  412. else
  413. memcpy(new->head, old->head, new_head_len);
  414. /* copy in optional tail */
  415. if (params->tail)
  416. memcpy(new->tail, params->tail, new_tail_len);
  417. else
  418. if (old)
  419. memcpy(new->tail, old->tail, new_tail_len);
  420. rcu_assign_pointer(sdata->u.ap.beacon, new);
  421. synchronize_rcu();
  422. kfree(old);
  423. return ieee80211_if_config(sdata, IEEE80211_IFCC_BEACON |
  424. IEEE80211_IFCC_BEACON_ENABLED);
  425. }
  426. static int ieee80211_add_beacon(struct wiphy *wiphy, struct net_device *dev,
  427. struct beacon_parameters *params)
  428. {
  429. struct ieee80211_sub_if_data *sdata;
  430. struct beacon_data *old;
  431. sdata = IEEE80211_DEV_TO_SUB_IF(dev);
  432. if (sdata->vif.type != NL80211_IFTYPE_AP)
  433. return -EINVAL;
  434. old = sdata->u.ap.beacon;
  435. if (old)
  436. return -EALREADY;
  437. return ieee80211_config_beacon(sdata, params);
  438. }
  439. static int ieee80211_set_beacon(struct wiphy *wiphy, struct net_device *dev,
  440. struct beacon_parameters *params)
  441. {
  442. struct ieee80211_sub_if_data *sdata;
  443. struct beacon_data *old;
  444. sdata = IEEE80211_DEV_TO_SUB_IF(dev);
  445. if (sdata->vif.type != NL80211_IFTYPE_AP)
  446. return -EINVAL;
  447. old = sdata->u.ap.beacon;
  448. if (!old)
  449. return -ENOENT;
  450. return ieee80211_config_beacon(sdata, params);
  451. }
  452. static int ieee80211_del_beacon(struct wiphy *wiphy, struct net_device *dev)
  453. {
  454. struct ieee80211_sub_if_data *sdata;
  455. struct beacon_data *old;
  456. sdata = IEEE80211_DEV_TO_SUB_IF(dev);
  457. if (sdata->vif.type != NL80211_IFTYPE_AP)
  458. return -EINVAL;
  459. old = sdata->u.ap.beacon;
  460. if (!old)
  461. return -ENOENT;
  462. rcu_assign_pointer(sdata->u.ap.beacon, NULL);
  463. synchronize_rcu();
  464. kfree(old);
  465. return ieee80211_if_config(sdata, IEEE80211_IFCC_BEACON_ENABLED);
  466. }
  467. /* Layer 2 Update frame (802.2 Type 1 LLC XID Update response) */
  468. struct iapp_layer2_update {
  469. u8 da[ETH_ALEN]; /* broadcast */
  470. u8 sa[ETH_ALEN]; /* STA addr */
  471. __be16 len; /* 6 */
  472. u8 dsap; /* 0 */
  473. u8 ssap; /* 0 */
  474. u8 control;
  475. u8 xid_info[3];
  476. } __attribute__ ((packed));
  477. static void ieee80211_send_layer2_update(struct sta_info *sta)
  478. {
  479. struct iapp_layer2_update *msg;
  480. struct sk_buff *skb;
  481. /* Send Level 2 Update Frame to update forwarding tables in layer 2
  482. * bridge devices */
  483. skb = dev_alloc_skb(sizeof(*msg));
  484. if (!skb)
  485. return;
  486. msg = (struct iapp_layer2_update *)skb_put(skb, sizeof(*msg));
  487. /* 802.2 Type 1 Logical Link Control (LLC) Exchange Identifier (XID)
  488. * Update response frame; IEEE Std 802.2-1998, 5.4.1.2.1 */
  489. memset(msg->da, 0xff, ETH_ALEN);
  490. memcpy(msg->sa, sta->sta.addr, ETH_ALEN);
  491. msg->len = htons(6);
  492. msg->dsap = 0;
  493. msg->ssap = 0x01; /* NULL LSAP, CR Bit: Response */
  494. msg->control = 0xaf; /* XID response lsb.1111F101.
  495. * F=0 (no poll command; unsolicited frame) */
  496. msg->xid_info[0] = 0x81; /* XID format identifier */
  497. msg->xid_info[1] = 1; /* LLC types/classes: Type 1 LLC */
  498. msg->xid_info[2] = 0; /* XID sender's receive window size (RW) */
  499. skb->dev = sta->sdata->dev;
  500. skb->protocol = eth_type_trans(skb, sta->sdata->dev);
  501. memset(skb->cb, 0, sizeof(skb->cb));
  502. netif_rx(skb);
  503. }
  504. static void sta_apply_parameters(struct ieee80211_local *local,
  505. struct sta_info *sta,
  506. struct station_parameters *params)
  507. {
  508. u32 rates;
  509. int i, j;
  510. struct ieee80211_supported_band *sband;
  511. struct ieee80211_sub_if_data *sdata = sta->sdata;
  512. sband = local->hw.wiphy->bands[local->oper_channel->band];
  513. /*
  514. * FIXME: updating the flags is racy when this function is
  515. * called from ieee80211_change_station(), this will
  516. * be resolved in a future patch.
  517. */
  518. if (params->station_flags & STATION_FLAG_CHANGED) {
  519. spin_lock_bh(&sta->lock);
  520. sta->flags &= ~WLAN_STA_AUTHORIZED;
  521. if (params->station_flags & STATION_FLAG_AUTHORIZED)
  522. sta->flags |= WLAN_STA_AUTHORIZED;
  523. sta->flags &= ~WLAN_STA_SHORT_PREAMBLE;
  524. if (params->station_flags & STATION_FLAG_SHORT_PREAMBLE)
  525. sta->flags |= WLAN_STA_SHORT_PREAMBLE;
  526. sta->flags &= ~WLAN_STA_WME;
  527. if (params->station_flags & STATION_FLAG_WME)
  528. sta->flags |= WLAN_STA_WME;
  529. sta->flags &= ~WLAN_STA_MFP;
  530. if (params->station_flags & STATION_FLAG_MFP)
  531. sta->flags |= WLAN_STA_MFP;
  532. spin_unlock_bh(&sta->lock);
  533. }
  534. /*
  535. * FIXME: updating the following information is racy when this
  536. * function is called from ieee80211_change_station().
  537. * However, all this information should be static so
  538. * maybe we should just reject attemps to change it.
  539. */
  540. if (params->aid) {
  541. sta->sta.aid = params->aid;
  542. if (sta->sta.aid > IEEE80211_MAX_AID)
  543. sta->sta.aid = 0; /* XXX: should this be an error? */
  544. }
  545. if (params->listen_interval >= 0)
  546. sta->listen_interval = params->listen_interval;
  547. if (params->supported_rates) {
  548. rates = 0;
  549. for (i = 0; i < params->supported_rates_len; i++) {
  550. int rate = (params->supported_rates[i] & 0x7f) * 5;
  551. for (j = 0; j < sband->n_bitrates; j++) {
  552. if (sband->bitrates[j].bitrate == rate)
  553. rates |= BIT(j);
  554. }
  555. }
  556. sta->sta.supp_rates[local->oper_channel->band] = rates;
  557. }
  558. if (params->ht_capa)
  559. ieee80211_ht_cap_ie_to_sta_ht_cap(sband,
  560. params->ht_capa,
  561. &sta->sta.ht_cap);
  562. if (ieee80211_vif_is_mesh(&sdata->vif) && params->plink_action) {
  563. switch (params->plink_action) {
  564. case PLINK_ACTION_OPEN:
  565. mesh_plink_open(sta);
  566. break;
  567. case PLINK_ACTION_BLOCK:
  568. mesh_plink_block(sta);
  569. break;
  570. }
  571. }
  572. }
  573. static int ieee80211_add_station(struct wiphy *wiphy, struct net_device *dev,
  574. u8 *mac, struct station_parameters *params)
  575. {
  576. struct ieee80211_local *local = wiphy_priv(wiphy);
  577. struct sta_info *sta;
  578. struct ieee80211_sub_if_data *sdata;
  579. int err;
  580. int layer2_update;
  581. /* Prevent a race with changing the rate control algorithm */
  582. if (!netif_running(dev))
  583. return -ENETDOWN;
  584. if (params->vlan) {
  585. sdata = IEEE80211_DEV_TO_SUB_IF(params->vlan);
  586. if (sdata->vif.type != NL80211_IFTYPE_AP_VLAN &&
  587. sdata->vif.type != NL80211_IFTYPE_AP)
  588. return -EINVAL;
  589. } else
  590. sdata = IEEE80211_DEV_TO_SUB_IF(dev);
  591. if (compare_ether_addr(mac, dev->dev_addr) == 0)
  592. return -EINVAL;
  593. if (is_multicast_ether_addr(mac))
  594. return -EINVAL;
  595. sta = sta_info_alloc(sdata, mac, GFP_KERNEL);
  596. if (!sta)
  597. return -ENOMEM;
  598. sta->flags = WLAN_STA_AUTH | WLAN_STA_ASSOC;
  599. sta_apply_parameters(local, sta, params);
  600. rate_control_rate_init(sta);
  601. layer2_update = sdata->vif.type == NL80211_IFTYPE_AP_VLAN ||
  602. sdata->vif.type == NL80211_IFTYPE_AP;
  603. rcu_read_lock();
  604. err = sta_info_insert(sta);
  605. if (err) {
  606. /* STA has been freed */
  607. if (err == -EEXIST && layer2_update) {
  608. /* Need to update layer 2 devices on reassociation */
  609. sta = sta_info_get(local, mac);
  610. if (sta)
  611. ieee80211_send_layer2_update(sta);
  612. }
  613. rcu_read_unlock();
  614. return err;
  615. }
  616. if (layer2_update)
  617. ieee80211_send_layer2_update(sta);
  618. rcu_read_unlock();
  619. return 0;
  620. }
  621. static int ieee80211_del_station(struct wiphy *wiphy, struct net_device *dev,
  622. u8 *mac)
  623. {
  624. struct ieee80211_local *local = wiphy_priv(wiphy);
  625. struct ieee80211_sub_if_data *sdata;
  626. struct sta_info *sta;
  627. sdata = IEEE80211_DEV_TO_SUB_IF(dev);
  628. if (mac) {
  629. rcu_read_lock();
  630. /* XXX: get sta belonging to dev */
  631. sta = sta_info_get(local, mac);
  632. if (!sta) {
  633. rcu_read_unlock();
  634. return -ENOENT;
  635. }
  636. sta_info_unlink(&sta);
  637. rcu_read_unlock();
  638. sta_info_destroy(sta);
  639. } else
  640. sta_info_flush(local, sdata);
  641. return 0;
  642. }
  643. static int ieee80211_change_station(struct wiphy *wiphy,
  644. struct net_device *dev,
  645. u8 *mac,
  646. struct station_parameters *params)
  647. {
  648. struct ieee80211_local *local = wiphy_priv(wiphy);
  649. struct sta_info *sta;
  650. struct ieee80211_sub_if_data *vlansdata;
  651. rcu_read_lock();
  652. /* XXX: get sta belonging to dev */
  653. sta = sta_info_get(local, mac);
  654. if (!sta) {
  655. rcu_read_unlock();
  656. return -ENOENT;
  657. }
  658. if (params->vlan && params->vlan != sta->sdata->dev) {
  659. vlansdata = IEEE80211_DEV_TO_SUB_IF(params->vlan);
  660. if (vlansdata->vif.type != NL80211_IFTYPE_AP_VLAN &&
  661. vlansdata->vif.type != NL80211_IFTYPE_AP) {
  662. rcu_read_unlock();
  663. return -EINVAL;
  664. }
  665. sta->sdata = vlansdata;
  666. ieee80211_send_layer2_update(sta);
  667. }
  668. sta_apply_parameters(local, sta, params);
  669. rcu_read_unlock();
  670. return 0;
  671. }
  672. #ifdef CONFIG_MAC80211_MESH
  673. static int ieee80211_add_mpath(struct wiphy *wiphy, struct net_device *dev,
  674. u8 *dst, u8 *next_hop)
  675. {
  676. struct ieee80211_local *local = wiphy_priv(wiphy);
  677. struct ieee80211_sub_if_data *sdata;
  678. struct mesh_path *mpath;
  679. struct sta_info *sta;
  680. int err;
  681. if (!netif_running(dev))
  682. return -ENETDOWN;
  683. sdata = IEEE80211_DEV_TO_SUB_IF(dev);
  684. if (sdata->vif.type != NL80211_IFTYPE_MESH_POINT)
  685. return -ENOTSUPP;
  686. rcu_read_lock();
  687. sta = sta_info_get(local, next_hop);
  688. if (!sta) {
  689. rcu_read_unlock();
  690. return -ENOENT;
  691. }
  692. err = mesh_path_add(dst, sdata);
  693. if (err) {
  694. rcu_read_unlock();
  695. return err;
  696. }
  697. mpath = mesh_path_lookup(dst, sdata);
  698. if (!mpath) {
  699. rcu_read_unlock();
  700. return -ENXIO;
  701. }
  702. mesh_path_fix_nexthop(mpath, sta);
  703. rcu_read_unlock();
  704. return 0;
  705. }
  706. static int ieee80211_del_mpath(struct wiphy *wiphy, struct net_device *dev,
  707. u8 *dst)
  708. {
  709. struct ieee80211_sub_if_data *sdata = IEEE80211_DEV_TO_SUB_IF(dev);
  710. if (dst)
  711. return mesh_path_del(dst, sdata);
  712. mesh_path_flush(sdata);
  713. return 0;
  714. }
  715. static int ieee80211_change_mpath(struct wiphy *wiphy,
  716. struct net_device *dev,
  717. u8 *dst, u8 *next_hop)
  718. {
  719. struct ieee80211_local *local = wiphy_priv(wiphy);
  720. struct ieee80211_sub_if_data *sdata;
  721. struct mesh_path *mpath;
  722. struct sta_info *sta;
  723. if (!netif_running(dev))
  724. return -ENETDOWN;
  725. sdata = IEEE80211_DEV_TO_SUB_IF(dev);
  726. if (sdata->vif.type != NL80211_IFTYPE_MESH_POINT)
  727. return -ENOTSUPP;
  728. rcu_read_lock();
  729. sta = sta_info_get(local, next_hop);
  730. if (!sta) {
  731. rcu_read_unlock();
  732. return -ENOENT;
  733. }
  734. mpath = mesh_path_lookup(dst, sdata);
  735. if (!mpath) {
  736. rcu_read_unlock();
  737. return -ENOENT;
  738. }
  739. mesh_path_fix_nexthop(mpath, sta);
  740. rcu_read_unlock();
  741. return 0;
  742. }
  743. static void mpath_set_pinfo(struct mesh_path *mpath, u8 *next_hop,
  744. struct mpath_info *pinfo)
  745. {
  746. if (mpath->next_hop)
  747. memcpy(next_hop, mpath->next_hop->sta.addr, ETH_ALEN);
  748. else
  749. memset(next_hop, 0, ETH_ALEN);
  750. pinfo->filled = MPATH_INFO_FRAME_QLEN |
  751. MPATH_INFO_DSN |
  752. MPATH_INFO_METRIC |
  753. MPATH_INFO_EXPTIME |
  754. MPATH_INFO_DISCOVERY_TIMEOUT |
  755. MPATH_INFO_DISCOVERY_RETRIES |
  756. MPATH_INFO_FLAGS;
  757. pinfo->frame_qlen = mpath->frame_queue.qlen;
  758. pinfo->dsn = mpath->dsn;
  759. pinfo->metric = mpath->metric;
  760. if (time_before(jiffies, mpath->exp_time))
  761. pinfo->exptime = jiffies_to_msecs(mpath->exp_time - jiffies);
  762. pinfo->discovery_timeout =
  763. jiffies_to_msecs(mpath->discovery_timeout);
  764. pinfo->discovery_retries = mpath->discovery_retries;
  765. pinfo->flags = 0;
  766. if (mpath->flags & MESH_PATH_ACTIVE)
  767. pinfo->flags |= NL80211_MPATH_FLAG_ACTIVE;
  768. if (mpath->flags & MESH_PATH_RESOLVING)
  769. pinfo->flags |= NL80211_MPATH_FLAG_RESOLVING;
  770. if (mpath->flags & MESH_PATH_DSN_VALID)
  771. pinfo->flags |= NL80211_MPATH_FLAG_DSN_VALID;
  772. if (mpath->flags & MESH_PATH_FIXED)
  773. pinfo->flags |= NL80211_MPATH_FLAG_FIXED;
  774. if (mpath->flags & MESH_PATH_RESOLVING)
  775. pinfo->flags |= NL80211_MPATH_FLAG_RESOLVING;
  776. pinfo->flags = mpath->flags;
  777. }
  778. static int ieee80211_get_mpath(struct wiphy *wiphy, struct net_device *dev,
  779. u8 *dst, u8 *next_hop, struct mpath_info *pinfo)
  780. {
  781. struct ieee80211_sub_if_data *sdata;
  782. struct mesh_path *mpath;
  783. sdata = IEEE80211_DEV_TO_SUB_IF(dev);
  784. if (sdata->vif.type != NL80211_IFTYPE_MESH_POINT)
  785. return -ENOTSUPP;
  786. rcu_read_lock();
  787. mpath = mesh_path_lookup(dst, sdata);
  788. if (!mpath) {
  789. rcu_read_unlock();
  790. return -ENOENT;
  791. }
  792. memcpy(dst, mpath->dst, ETH_ALEN);
  793. mpath_set_pinfo(mpath, next_hop, pinfo);
  794. rcu_read_unlock();
  795. return 0;
  796. }
  797. static int ieee80211_dump_mpath(struct wiphy *wiphy, struct net_device *dev,
  798. int idx, u8 *dst, u8 *next_hop,
  799. struct mpath_info *pinfo)
  800. {
  801. struct ieee80211_sub_if_data *sdata;
  802. struct mesh_path *mpath;
  803. sdata = IEEE80211_DEV_TO_SUB_IF(dev);
  804. if (sdata->vif.type != NL80211_IFTYPE_MESH_POINT)
  805. return -ENOTSUPP;
  806. rcu_read_lock();
  807. mpath = mesh_path_lookup_by_idx(idx, sdata);
  808. if (!mpath) {
  809. rcu_read_unlock();
  810. return -ENOENT;
  811. }
  812. memcpy(dst, mpath->dst, ETH_ALEN);
  813. mpath_set_pinfo(mpath, next_hop, pinfo);
  814. rcu_read_unlock();
  815. return 0;
  816. }
  817. static int ieee80211_get_mesh_params(struct wiphy *wiphy,
  818. struct net_device *dev,
  819. struct mesh_config *conf)
  820. {
  821. struct ieee80211_sub_if_data *sdata;
  822. sdata = IEEE80211_DEV_TO_SUB_IF(dev);
  823. if (sdata->vif.type != NL80211_IFTYPE_MESH_POINT)
  824. return -ENOTSUPP;
  825. memcpy(conf, &(sdata->u.mesh.mshcfg), sizeof(struct mesh_config));
  826. return 0;
  827. }
  828. static inline bool _chg_mesh_attr(enum nl80211_meshconf_params parm, u32 mask)
  829. {
  830. return (mask >> (parm-1)) & 0x1;
  831. }
  832. static int ieee80211_set_mesh_params(struct wiphy *wiphy,
  833. struct net_device *dev,
  834. const struct mesh_config *nconf, u32 mask)
  835. {
  836. struct mesh_config *conf;
  837. struct ieee80211_sub_if_data *sdata;
  838. sdata = IEEE80211_DEV_TO_SUB_IF(dev);
  839. if (sdata->vif.type != NL80211_IFTYPE_MESH_POINT)
  840. return -ENOTSUPP;
  841. /* Set the config options which we are interested in setting */
  842. conf = &(sdata->u.mesh.mshcfg);
  843. if (_chg_mesh_attr(NL80211_MESHCONF_RETRY_TIMEOUT, mask))
  844. conf->dot11MeshRetryTimeout = nconf->dot11MeshRetryTimeout;
  845. if (_chg_mesh_attr(NL80211_MESHCONF_CONFIRM_TIMEOUT, mask))
  846. conf->dot11MeshConfirmTimeout = nconf->dot11MeshConfirmTimeout;
  847. if (_chg_mesh_attr(NL80211_MESHCONF_HOLDING_TIMEOUT, mask))
  848. conf->dot11MeshHoldingTimeout = nconf->dot11MeshHoldingTimeout;
  849. if (_chg_mesh_attr(NL80211_MESHCONF_MAX_PEER_LINKS, mask))
  850. conf->dot11MeshMaxPeerLinks = nconf->dot11MeshMaxPeerLinks;
  851. if (_chg_mesh_attr(NL80211_MESHCONF_MAX_RETRIES, mask))
  852. conf->dot11MeshMaxRetries = nconf->dot11MeshMaxRetries;
  853. if (_chg_mesh_attr(NL80211_MESHCONF_TTL, mask))
  854. conf->dot11MeshTTL = nconf->dot11MeshTTL;
  855. if (_chg_mesh_attr(NL80211_MESHCONF_AUTO_OPEN_PLINKS, mask))
  856. conf->auto_open_plinks = nconf->auto_open_plinks;
  857. if (_chg_mesh_attr(NL80211_MESHCONF_HWMP_MAX_PREQ_RETRIES, mask))
  858. conf->dot11MeshHWMPmaxPREQretries =
  859. nconf->dot11MeshHWMPmaxPREQretries;
  860. if (_chg_mesh_attr(NL80211_MESHCONF_PATH_REFRESH_TIME, mask))
  861. conf->path_refresh_time = nconf->path_refresh_time;
  862. if (_chg_mesh_attr(NL80211_MESHCONF_MIN_DISCOVERY_TIMEOUT, mask))
  863. conf->min_discovery_timeout = nconf->min_discovery_timeout;
  864. if (_chg_mesh_attr(NL80211_MESHCONF_HWMP_ACTIVE_PATH_TIMEOUT, mask))
  865. conf->dot11MeshHWMPactivePathTimeout =
  866. nconf->dot11MeshHWMPactivePathTimeout;
  867. if (_chg_mesh_attr(NL80211_MESHCONF_HWMP_PREQ_MIN_INTERVAL, mask))
  868. conf->dot11MeshHWMPpreqMinInterval =
  869. nconf->dot11MeshHWMPpreqMinInterval;
  870. if (_chg_mesh_attr(NL80211_MESHCONF_HWMP_NET_DIAM_TRVS_TIME,
  871. mask))
  872. conf->dot11MeshHWMPnetDiameterTraversalTime =
  873. nconf->dot11MeshHWMPnetDiameterTraversalTime;
  874. return 0;
  875. }
  876. #endif
  877. static int ieee80211_change_bss(struct wiphy *wiphy,
  878. struct net_device *dev,
  879. struct bss_parameters *params)
  880. {
  881. struct ieee80211_sub_if_data *sdata;
  882. u32 changed = 0;
  883. sdata = IEEE80211_DEV_TO_SUB_IF(dev);
  884. if (sdata->vif.type != NL80211_IFTYPE_AP)
  885. return -EINVAL;
  886. if (params->use_cts_prot >= 0) {
  887. sdata->vif.bss_conf.use_cts_prot = params->use_cts_prot;
  888. changed |= BSS_CHANGED_ERP_CTS_PROT;
  889. }
  890. if (params->use_short_preamble >= 0) {
  891. sdata->vif.bss_conf.use_short_preamble =
  892. params->use_short_preamble;
  893. changed |= BSS_CHANGED_ERP_PREAMBLE;
  894. }
  895. if (params->use_short_slot_time >= 0) {
  896. sdata->vif.bss_conf.use_short_slot =
  897. params->use_short_slot_time;
  898. changed |= BSS_CHANGED_ERP_SLOT;
  899. }
  900. if (params->basic_rates) {
  901. int i, j;
  902. u32 rates = 0;
  903. struct ieee80211_local *local = wiphy_priv(wiphy);
  904. struct ieee80211_supported_band *sband =
  905. wiphy->bands[local->oper_channel->band];
  906. for (i = 0; i < params->basic_rates_len; i++) {
  907. int rate = (params->basic_rates[i] & 0x7f) * 5;
  908. for (j = 0; j < sband->n_bitrates; j++) {
  909. if (sband->bitrates[j].bitrate == rate)
  910. rates |= BIT(j);
  911. }
  912. }
  913. sdata->vif.bss_conf.basic_rates = rates;
  914. changed |= BSS_CHANGED_BASIC_RATES;
  915. }
  916. ieee80211_bss_info_change_notify(sdata, changed);
  917. return 0;
  918. }
  919. static int ieee80211_set_txq_params(struct wiphy *wiphy,
  920. struct ieee80211_txq_params *params)
  921. {
  922. struct ieee80211_local *local = wiphy_priv(wiphy);
  923. struct ieee80211_tx_queue_params p;
  924. if (!local->ops->conf_tx)
  925. return -EOPNOTSUPP;
  926. memset(&p, 0, sizeof(p));
  927. p.aifs = params->aifs;
  928. p.cw_max = params->cwmax;
  929. p.cw_min = params->cwmin;
  930. p.txop = params->txop;
  931. if (local->ops->conf_tx(local_to_hw(local), params->queue, &p)) {
  932. printk(KERN_DEBUG "%s: failed to set TX queue "
  933. "parameters for queue %d\n", local->mdev->name,
  934. params->queue);
  935. return -EINVAL;
  936. }
  937. return 0;
  938. }
  939. static int ieee80211_set_channel(struct wiphy *wiphy,
  940. struct ieee80211_channel *chan,
  941. enum nl80211_channel_type channel_type)
  942. {
  943. struct ieee80211_local *local = wiphy_priv(wiphy);
  944. local->oper_channel = chan;
  945. local->oper_channel_type = channel_type;
  946. return ieee80211_hw_config(local, IEEE80211_CONF_CHANGE_CHANNEL);
  947. }
  948. static int set_mgmt_extra_ie_sta(struct ieee80211_if_sta *ifsta, u8 subtype,
  949. u8 *ies, size_t ies_len)
  950. {
  951. switch (subtype) {
  952. case IEEE80211_STYPE_PROBE_REQ >> 4:
  953. kfree(ifsta->ie_probereq);
  954. ifsta->ie_probereq = ies;
  955. ifsta->ie_probereq_len = ies_len;
  956. return 0;
  957. case IEEE80211_STYPE_PROBE_RESP >> 4:
  958. kfree(ifsta->ie_proberesp);
  959. ifsta->ie_proberesp = ies;
  960. ifsta->ie_proberesp_len = ies_len;
  961. return 0;
  962. case IEEE80211_STYPE_AUTH >> 4:
  963. kfree(ifsta->ie_auth);
  964. ifsta->ie_auth = ies;
  965. ifsta->ie_auth_len = ies_len;
  966. return 0;
  967. case IEEE80211_STYPE_ASSOC_REQ >> 4:
  968. kfree(ifsta->ie_assocreq);
  969. ifsta->ie_assocreq = ies;
  970. ifsta->ie_assocreq_len = ies_len;
  971. return 0;
  972. case IEEE80211_STYPE_REASSOC_REQ >> 4:
  973. kfree(ifsta->ie_reassocreq);
  974. ifsta->ie_reassocreq = ies;
  975. ifsta->ie_reassocreq_len = ies_len;
  976. return 0;
  977. case IEEE80211_STYPE_DEAUTH >> 4:
  978. kfree(ifsta->ie_deauth);
  979. ifsta->ie_deauth = ies;
  980. ifsta->ie_deauth_len = ies_len;
  981. return 0;
  982. case IEEE80211_STYPE_DISASSOC >> 4:
  983. kfree(ifsta->ie_disassoc);
  984. ifsta->ie_disassoc = ies;
  985. ifsta->ie_disassoc_len = ies_len;
  986. return 0;
  987. }
  988. return -EOPNOTSUPP;
  989. }
  990. static int ieee80211_set_mgmt_extra_ie(struct wiphy *wiphy,
  991. struct net_device *dev,
  992. struct mgmt_extra_ie_params *params)
  993. {
  994. struct ieee80211_sub_if_data *sdata;
  995. u8 *ies;
  996. size_t ies_len;
  997. int ret = -EOPNOTSUPP;
  998. if (params->ies) {
  999. ies = kmemdup(params->ies, params->ies_len, GFP_KERNEL);
  1000. if (ies == NULL)
  1001. return -ENOMEM;
  1002. ies_len = params->ies_len;
  1003. } else {
  1004. ies = NULL;
  1005. ies_len = 0;
  1006. }
  1007. sdata = IEEE80211_DEV_TO_SUB_IF(dev);
  1008. switch (sdata->vif.type) {
  1009. case NL80211_IFTYPE_STATION:
  1010. case NL80211_IFTYPE_ADHOC:
  1011. ret = set_mgmt_extra_ie_sta(&sdata->u.sta, params->subtype,
  1012. ies, ies_len);
  1013. break;
  1014. default:
  1015. ret = -EOPNOTSUPP;
  1016. break;
  1017. }
  1018. if (ret)
  1019. kfree(ies);
  1020. return ret;
  1021. }
  1022. #ifdef CONFIG_PM
  1023. static int ieee80211_suspend(struct wiphy *wiphy)
  1024. {
  1025. return __ieee80211_suspend(wiphy_priv(wiphy));
  1026. }
  1027. static int ieee80211_resume(struct wiphy *wiphy)
  1028. {
  1029. return __ieee80211_resume(wiphy_priv(wiphy));
  1030. }
  1031. #else
  1032. #define ieee80211_suspend NULL
  1033. #define ieee80211_resume NULL
  1034. #endif
  1035. struct cfg80211_ops mac80211_config_ops = {
  1036. .add_virtual_intf = ieee80211_add_iface,
  1037. .del_virtual_intf = ieee80211_del_iface,
  1038. .change_virtual_intf = ieee80211_change_iface,
  1039. .add_key = ieee80211_add_key,
  1040. .del_key = ieee80211_del_key,
  1041. .get_key = ieee80211_get_key,
  1042. .set_default_key = ieee80211_config_default_key,
  1043. .set_default_mgmt_key = ieee80211_config_default_mgmt_key,
  1044. .add_beacon = ieee80211_add_beacon,
  1045. .set_beacon = ieee80211_set_beacon,
  1046. .del_beacon = ieee80211_del_beacon,
  1047. .add_station = ieee80211_add_station,
  1048. .del_station = ieee80211_del_station,
  1049. .change_station = ieee80211_change_station,
  1050. .get_station = ieee80211_get_station,
  1051. .dump_station = ieee80211_dump_station,
  1052. #ifdef CONFIG_MAC80211_MESH
  1053. .add_mpath = ieee80211_add_mpath,
  1054. .del_mpath = ieee80211_del_mpath,
  1055. .change_mpath = ieee80211_change_mpath,
  1056. .get_mpath = ieee80211_get_mpath,
  1057. .dump_mpath = ieee80211_dump_mpath,
  1058. .set_mesh_params = ieee80211_set_mesh_params,
  1059. .get_mesh_params = ieee80211_get_mesh_params,
  1060. #endif
  1061. .change_bss = ieee80211_change_bss,
  1062. .set_txq_params = ieee80211_set_txq_params,
  1063. .set_channel = ieee80211_set_channel,
  1064. .set_mgmt_extra_ie = ieee80211_set_mgmt_extra_ie,
  1065. .suspend = ieee80211_suspend,
  1066. .resume = ieee80211_resume,
  1067. };