ieee80211_ioctl.c 45 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927928929930931932933934935936937938939940941942943944945946947948949950951952953954955956957958959960961962963964965966967968969970971972973974975976977978979980981982983984985986987988989990991992993994995996997998999100010011002100310041005100610071008100910101011101210131014101510161017101810191020102110221023102410251026102710281029103010311032103310341035103610371038103910401041104210431044104510461047104810491050105110521053105410551056105710581059106010611062106310641065106610671068106910701071107210731074107510761077107810791080108110821083108410851086108710881089109010911092109310941095109610971098109911001101110211031104110511061107110811091110111111121113111411151116111711181119112011211122112311241125112611271128112911301131113211331134113511361137113811391140114111421143114411451146114711481149115011511152115311541155115611571158115911601161116211631164116511661167116811691170117111721173117411751176117711781179118011811182118311841185118611871188118911901191119211931194119511961197119811991200120112021203120412051206120712081209121012111212121312141215121612171218121912201221122212231224122512261227122812291230123112321233123412351236123712381239124012411242124312441245124612471248124912501251125212531254125512561257125812591260126112621263126412651266126712681269127012711272127312741275127612771278127912801281128212831284128512861287128812891290129112921293129412951296129712981299130013011302130313041305130613071308130913101311131213131314131513161317131813191320132113221323132413251326132713281329133013311332133313341335133613371338133913401341134213431344134513461347134813491350135113521353135413551356135713581359136013611362136313641365136613671368136913701371137213731374137513761377137813791380138113821383138413851386138713881389139013911392139313941395139613971398139914001401140214031404140514061407140814091410141114121413141414151416141714181419142014211422142314241425142614271428142914301431143214331434143514361437143814391440144114421443144414451446144714481449145014511452145314541455145614571458145914601461146214631464146514661467146814691470147114721473147414751476147714781479148014811482148314841485148614871488148914901491149214931494149514961497149814991500150115021503150415051506150715081509151015111512151315141515151615171518151915201521152215231524152515261527152815291530153115321533153415351536153715381539154015411542154315441545154615471548154915501551155215531554155515561557155815591560156115621563156415651566156715681569157015711572157315741575157615771578157915801581158215831584158515861587158815891590159115921593159415951596159715981599160016011602160316041605160616071608160916101611161216131614161516161617161816191620162116221623162416251626162716281629163016311632163316341635163616371638163916401641164216431644164516461647164816491650165116521653165416551656165716581659166016611662166316641665166616671668166916701671167216731674167516761677167816791680168116821683168416851686168716881689169016911692169316941695169616971698169917001701170217031704170517061707170817091710171117121713171417151716171717181719172017211722172317241725172617271728172917301731173217331734173517361737173817391740174117421743
  1. /*
  2. * Copyright 2002-2005, Instant802 Networks, Inc.
  3. * Copyright 2005-2006, Devicescape Software, Inc.
  4. *
  5. * This program is free software; you can redistribute it and/or modify
  6. * it under the terms of the GNU General Public License version 2 as
  7. * published by the Free Software Foundation.
  8. */
  9. #include <linux/module.h>
  10. #include <linux/init.h>
  11. #include <linux/netdevice.h>
  12. #include <linux/types.h>
  13. #include <linux/slab.h>
  14. #include <linux/skbuff.h>
  15. #include <linux/etherdevice.h>
  16. #include <linux/if_arp.h>
  17. #include <linux/wireless.h>
  18. #include <net/iw_handler.h>
  19. #include <asm/uaccess.h>
  20. #include <net/mac80211.h>
  21. #include "ieee80211_i.h"
  22. #include "hostapd_ioctl.h"
  23. #include "ieee80211_rate.h"
  24. #include "wpa.h"
  25. #include "aes_ccm.h"
  26. #include "debugfs_key.h"
  27. static int ieee80211_regdom = 0x10; /* FCC */
  28. module_param(ieee80211_regdom, int, 0444);
  29. MODULE_PARM_DESC(ieee80211_regdom, "IEEE 802.11 regulatory domain; 64=MKK");
  30. /*
  31. * If firmware is upgraded by the vendor, additional channels can be used based
  32. * on the new Japanese regulatory rules. This is indicated by setting
  33. * ieee80211_japan_5ghz module parameter to one when loading the 80211 kernel
  34. * module.
  35. */
  36. static int ieee80211_japan_5ghz /* = 0 */;
  37. module_param(ieee80211_japan_5ghz, int, 0444);
  38. MODULE_PARM_DESC(ieee80211_japan_5ghz, "Vendor-updated firmware for 5 GHz");
  39. static void ieee80211_set_hw_encryption(struct net_device *dev,
  40. struct sta_info *sta, u8 addr[ETH_ALEN],
  41. struct ieee80211_key *key)
  42. {
  43. struct ieee80211_key_conf *keyconf = NULL;
  44. struct ieee80211_local *local = wdev_priv(dev->ieee80211_ptr);
  45. /* default to sw encryption; this will be cleared by low-level
  46. * driver if the hw supports requested encryption */
  47. if (key)
  48. key->force_sw_encrypt = 1;
  49. if (key && local->ops->set_key &&
  50. (keyconf = ieee80211_key_data2conf(local, key))) {
  51. if (local->ops->set_key(local_to_hw(local), SET_KEY, addr,
  52. keyconf, sta ? sta->aid : 0)) {
  53. key->force_sw_encrypt = 1;
  54. key->hw_key_idx = HW_KEY_IDX_INVALID;
  55. } else {
  56. key->force_sw_encrypt =
  57. !!(keyconf->flags & IEEE80211_KEY_FORCE_SW_ENCRYPT);
  58. key->hw_key_idx =
  59. keyconf->hw_key_idx;
  60. }
  61. }
  62. kfree(keyconf);
  63. }
  64. static int ieee80211_set_encryption(struct net_device *dev, u8 *sta_addr,
  65. int idx, int alg, int set_tx_key,
  66. const u8 *_key, size_t key_len)
  67. {
  68. struct ieee80211_local *local = wdev_priv(dev->ieee80211_ptr);
  69. int ret = 0;
  70. struct sta_info *sta;
  71. struct ieee80211_key *key, *old_key;
  72. int try_hwaccel = 1;
  73. struct ieee80211_key_conf *keyconf;
  74. struct ieee80211_sub_if_data *sdata;
  75. sdata = IEEE80211_DEV_TO_SUB_IF(dev);
  76. if (is_broadcast_ether_addr(sta_addr)) {
  77. sta = NULL;
  78. if (idx >= NUM_DEFAULT_KEYS) {
  79. printk(KERN_DEBUG "%s: set_encrypt - invalid idx=%d\n",
  80. dev->name, idx);
  81. return -EINVAL;
  82. }
  83. key = sdata->keys[idx];
  84. /* TODO: consider adding hwaccel support for these; at least
  85. * Atheros key cache should be able to handle this since AP is
  86. * only transmitting frames with default keys. */
  87. /* FIX: hw key cache can be used when only one virtual
  88. * STA is associated with each AP. If more than one STA
  89. * is associated to the same AP, software encryption
  90. * must be used. This should be done automatically
  91. * based on configured station devices. For the time
  92. * being, this can be only set at compile time. */
  93. } else {
  94. set_tx_key = 0;
  95. if (idx != 0) {
  96. printk(KERN_DEBUG "%s: set_encrypt - non-zero idx for "
  97. "individual key\n", dev->name);
  98. return -EINVAL;
  99. }
  100. sta = sta_info_get(local, sta_addr);
  101. if (!sta) {
  102. #ifdef CONFIG_MAC80211_VERBOSE_DEBUG
  103. printk(KERN_DEBUG "%s: set_encrypt - unknown addr "
  104. MAC_FMT "\n",
  105. dev->name, MAC_ARG(sta_addr));
  106. #endif /* CONFIG_MAC80211_VERBOSE_DEBUG */
  107. return -ENOENT;
  108. }
  109. key = sta->key;
  110. }
  111. /* FIX:
  112. * Cannot configure default hwaccel keys with WEP algorithm, if
  113. * any of the virtual interfaces is using static WEP
  114. * configuration because hwaccel would otherwise try to decrypt
  115. * these frames.
  116. *
  117. * For now, just disable WEP hwaccel for broadcast when there is
  118. * possibility of conflict with default keys. This can maybe later be
  119. * optimized by using non-default keys (at least with Atheros ar521x).
  120. */
  121. if (!sta && alg == ALG_WEP && !local->default_wep_only &&
  122. sdata->type != IEEE80211_IF_TYPE_IBSS &&
  123. sdata->type != IEEE80211_IF_TYPE_AP) {
  124. try_hwaccel = 0;
  125. }
  126. if (local->hw.flags & IEEE80211_HW_DEVICE_HIDES_WEP) {
  127. /* Software encryption cannot be used with devices that hide
  128. * encryption from the host system, so always try to use
  129. * hardware acceleration with such devices. */
  130. try_hwaccel = 1;
  131. }
  132. if ((local->hw.flags & IEEE80211_HW_NO_TKIP_WMM_HWACCEL) &&
  133. alg == ALG_TKIP) {
  134. if (sta && (sta->flags & WLAN_STA_WME)) {
  135. /* Hardware does not support hwaccel with TKIP when using WMM.
  136. */
  137. try_hwaccel = 0;
  138. }
  139. else if (sdata->type == IEEE80211_IF_TYPE_STA) {
  140. sta = sta_info_get(local, sdata->u.sta.bssid);
  141. if (sta) {
  142. if (sta->flags & WLAN_STA_WME) {
  143. try_hwaccel = 0;
  144. }
  145. sta_info_put(sta);
  146. sta = NULL;
  147. }
  148. }
  149. }
  150. if (alg == ALG_NONE) {
  151. keyconf = NULL;
  152. if (try_hwaccel && key &&
  153. key->hw_key_idx != HW_KEY_IDX_INVALID &&
  154. local->ops->set_key &&
  155. (keyconf = ieee80211_key_data2conf(local, key)) != NULL &&
  156. local->ops->set_key(local_to_hw(local), DISABLE_KEY,
  157. sta_addr, keyconf, sta ? sta->aid : 0)) {
  158. printk(KERN_DEBUG "%s: set_encrypt - low-level disable"
  159. " failed\n", dev->name);
  160. ret = -EINVAL;
  161. }
  162. kfree(keyconf);
  163. if (set_tx_key || sdata->default_key == key) {
  164. ieee80211_debugfs_key_remove_default(sdata);
  165. sdata->default_key = NULL;
  166. }
  167. ieee80211_debugfs_key_remove(key);
  168. if (sta)
  169. sta->key = NULL;
  170. else
  171. sdata->keys[idx] = NULL;
  172. ieee80211_key_free(key);
  173. key = NULL;
  174. } else {
  175. old_key = key;
  176. key = ieee80211_key_alloc(sta ? NULL : sdata, idx, key_len,
  177. GFP_KERNEL);
  178. if (!key) {
  179. ret = -ENOMEM;
  180. goto err_out;
  181. }
  182. /* default to sw encryption; low-level driver sets these if the
  183. * requested encryption is supported */
  184. key->hw_key_idx = HW_KEY_IDX_INVALID;
  185. key->force_sw_encrypt = 1;
  186. key->alg = alg;
  187. key->keyidx = idx;
  188. key->keylen = key_len;
  189. memcpy(key->key, _key, key_len);
  190. if (set_tx_key)
  191. key->default_tx_key = 1;
  192. if (alg == ALG_CCMP) {
  193. /* Initialize AES key state here as an optimization
  194. * so that it does not need to be initialized for every
  195. * packet. */
  196. key->u.ccmp.tfm = ieee80211_aes_key_setup_encrypt(
  197. key->key);
  198. if (!key->u.ccmp.tfm) {
  199. ret = -ENOMEM;
  200. goto err_free;
  201. }
  202. }
  203. if (set_tx_key || sdata->default_key == old_key) {
  204. ieee80211_debugfs_key_remove_default(sdata);
  205. sdata->default_key = NULL;
  206. }
  207. ieee80211_debugfs_key_remove(old_key);
  208. if (sta)
  209. sta->key = key;
  210. else
  211. sdata->keys[idx] = key;
  212. ieee80211_key_free(old_key);
  213. ieee80211_debugfs_key_add(local, key);
  214. if (sta)
  215. ieee80211_debugfs_key_sta_link(key, sta);
  216. if (try_hwaccel &&
  217. (alg == ALG_WEP || alg == ALG_TKIP || alg == ALG_CCMP))
  218. ieee80211_set_hw_encryption(dev, sta, sta_addr, key);
  219. }
  220. if (set_tx_key || (!sta && !sdata->default_key && key)) {
  221. sdata->default_key = key;
  222. if (key)
  223. ieee80211_debugfs_key_add_default(sdata);
  224. if (local->ops->set_key_idx &&
  225. local->ops->set_key_idx(local_to_hw(local), idx))
  226. printk(KERN_DEBUG "%s: failed to set TX key idx for "
  227. "low-level driver\n", dev->name);
  228. }
  229. if (sta)
  230. sta_info_put(sta);
  231. return 0;
  232. err_free:
  233. ieee80211_key_free(key);
  234. err_out:
  235. if (sta)
  236. sta_info_put(sta);
  237. return ret;
  238. }
  239. static int ieee80211_ioctl_siwgenie(struct net_device *dev,
  240. struct iw_request_info *info,
  241. struct iw_point *data, char *extra)
  242. {
  243. struct ieee80211_sub_if_data *sdata;
  244. struct ieee80211_local *local = wdev_priv(dev->ieee80211_ptr);
  245. if (local->user_space_mlme)
  246. return -EOPNOTSUPP;
  247. sdata = IEEE80211_DEV_TO_SUB_IF(dev);
  248. if (sdata->type == IEEE80211_IF_TYPE_STA ||
  249. sdata->type == IEEE80211_IF_TYPE_IBSS) {
  250. int ret = ieee80211_sta_set_extra_ie(dev, extra, data->length);
  251. if (ret)
  252. return ret;
  253. sdata->u.sta.auto_bssid_sel = 0;
  254. ieee80211_sta_req_auth(dev, &sdata->u.sta);
  255. return 0;
  256. }
  257. if (sdata->type == IEEE80211_IF_TYPE_AP) {
  258. kfree(sdata->u.ap.generic_elem);
  259. sdata->u.ap.generic_elem = kmalloc(data->length, GFP_KERNEL);
  260. if (!sdata->u.ap.generic_elem)
  261. return -ENOMEM;
  262. memcpy(sdata->u.ap.generic_elem, extra, data->length);
  263. sdata->u.ap.generic_elem_len = data->length;
  264. return ieee80211_if_config(dev);
  265. }
  266. return -EOPNOTSUPP;
  267. }
  268. static int ieee80211_ioctl_set_radio_enabled(struct net_device *dev,
  269. int val)
  270. {
  271. struct ieee80211_local *local = wdev_priv(dev->ieee80211_ptr);
  272. struct ieee80211_conf *conf = &local->hw.conf;
  273. conf->radio_enabled = val;
  274. return ieee80211_hw_config(wdev_priv(dev->ieee80211_ptr));
  275. }
  276. static int ieee80211_ioctl_giwname(struct net_device *dev,
  277. struct iw_request_info *info,
  278. char *name, char *extra)
  279. {
  280. struct ieee80211_local *local = wdev_priv(dev->ieee80211_ptr);
  281. switch (local->hw.conf.phymode) {
  282. case MODE_IEEE80211A:
  283. strcpy(name, "IEEE 802.11a");
  284. break;
  285. case MODE_IEEE80211B:
  286. strcpy(name, "IEEE 802.11b");
  287. break;
  288. case MODE_IEEE80211G:
  289. strcpy(name, "IEEE 802.11g");
  290. break;
  291. case MODE_ATHEROS_TURBO:
  292. strcpy(name, "5GHz Turbo");
  293. break;
  294. default:
  295. strcpy(name, "IEEE 802.11");
  296. break;
  297. }
  298. return 0;
  299. }
  300. static int ieee80211_ioctl_giwrange(struct net_device *dev,
  301. struct iw_request_info *info,
  302. struct iw_point *data, char *extra)
  303. {
  304. struct ieee80211_local *local = wdev_priv(dev->ieee80211_ptr);
  305. struct iw_range *range = (struct iw_range *) extra;
  306. struct ieee80211_hw_mode *mode = NULL;
  307. int c = 0;
  308. data->length = sizeof(struct iw_range);
  309. memset(range, 0, sizeof(struct iw_range));
  310. range->we_version_compiled = WIRELESS_EXT;
  311. range->we_version_source = 21;
  312. range->retry_capa = IW_RETRY_LIMIT;
  313. range->retry_flags = IW_RETRY_LIMIT;
  314. range->min_retry = 0;
  315. range->max_retry = 255;
  316. range->min_rts = 0;
  317. range->max_rts = 2347;
  318. range->min_frag = 256;
  319. range->max_frag = 2346;
  320. range->encoding_size[0] = 5;
  321. range->encoding_size[1] = 13;
  322. range->num_encoding_sizes = 2;
  323. range->max_encoding_tokens = NUM_DEFAULT_KEYS;
  324. range->max_qual.qual = local->hw.max_signal;
  325. range->max_qual.level = local->hw.max_rssi;
  326. range->max_qual.noise = local->hw.max_noise;
  327. range->max_qual.updated = local->wstats_flags;
  328. range->avg_qual.qual = local->hw.max_signal/2;
  329. range->avg_qual.level = 0;
  330. range->avg_qual.noise = 0;
  331. range->avg_qual.updated = local->wstats_flags;
  332. range->enc_capa = IW_ENC_CAPA_WPA | IW_ENC_CAPA_WPA2 |
  333. IW_ENC_CAPA_CIPHER_TKIP | IW_ENC_CAPA_CIPHER_CCMP;
  334. list_for_each_entry(mode, &local->modes_list, list) {
  335. int i = 0;
  336. if (!(local->enabled_modes & (1 << mode->mode)) ||
  337. (local->hw_modes & local->enabled_modes &
  338. (1 << MODE_IEEE80211G) && mode->mode == MODE_IEEE80211B))
  339. continue;
  340. while (i < mode->num_channels && c < IW_MAX_FREQUENCIES) {
  341. struct ieee80211_channel *chan = &mode->channels[i];
  342. if (chan->flag & IEEE80211_CHAN_W_SCAN) {
  343. range->freq[c].i = chan->chan;
  344. range->freq[c].m = chan->freq * 100000;
  345. range->freq[c].e = 1;
  346. c++;
  347. }
  348. i++;
  349. }
  350. }
  351. range->num_channels = c;
  352. range->num_frequency = c;
  353. IW_EVENT_CAPA_SET_KERNEL(range->event_capa);
  354. IW_EVENT_CAPA_SET(range->event_capa, SIOCGIWTHRSPY);
  355. IW_EVENT_CAPA_SET(range->event_capa, SIOCGIWAP);
  356. IW_EVENT_CAPA_SET(range->event_capa, SIOCGIWSCAN);
  357. return 0;
  358. }
  359. struct ieee80211_channel_range {
  360. short start_freq;
  361. short end_freq;
  362. unsigned char power_level;
  363. unsigned char antenna_max;
  364. };
  365. static const struct ieee80211_channel_range ieee80211_fcc_channels[] = {
  366. { 2412, 2462, 27, 6 } /* IEEE 802.11b/g, channels 1..11 */,
  367. { 5180, 5240, 17, 6 } /* IEEE 802.11a, channels 36..48 */,
  368. { 5260, 5320, 23, 6 } /* IEEE 802.11a, channels 52..64 */,
  369. { 5745, 5825, 30, 6 } /* IEEE 802.11a, channels 149..165, outdoor */,
  370. { 0 }
  371. };
  372. static const struct ieee80211_channel_range ieee80211_mkk_channels[] = {
  373. { 2412, 2472, 20, 6 } /* IEEE 802.11b/g, channels 1..13 */,
  374. { 5170, 5240, 20, 6 } /* IEEE 802.11a, channels 34..48 */,
  375. { 5260, 5320, 20, 6 } /* IEEE 802.11a, channels 52..64 */,
  376. { 0 }
  377. };
  378. static const struct ieee80211_channel_range *channel_range =
  379. ieee80211_fcc_channels;
  380. static void ieee80211_unmask_channel(struct net_device *dev, int mode,
  381. struct ieee80211_channel *chan)
  382. {
  383. int i;
  384. chan->flag = 0;
  385. if (ieee80211_regdom == 64 &&
  386. (mode == MODE_ATHEROS_TURBO || mode == MODE_ATHEROS_TURBOG)) {
  387. /* Do not allow Turbo modes in Japan. */
  388. return;
  389. }
  390. for (i = 0; channel_range[i].start_freq; i++) {
  391. const struct ieee80211_channel_range *r = &channel_range[i];
  392. if (r->start_freq <= chan->freq && r->end_freq >= chan->freq) {
  393. if (ieee80211_regdom == 64 && !ieee80211_japan_5ghz &&
  394. chan->freq >= 5260 && chan->freq <= 5320) {
  395. /*
  396. * Skip new channels in Japan since the
  397. * firmware was not marked having been upgraded
  398. * by the vendor.
  399. */
  400. continue;
  401. }
  402. if (ieee80211_regdom == 0x10 &&
  403. (chan->freq == 5190 || chan->freq == 5210 ||
  404. chan->freq == 5230)) {
  405. /* Skip MKK channels when in FCC domain. */
  406. continue;
  407. }
  408. chan->flag |= IEEE80211_CHAN_W_SCAN |
  409. IEEE80211_CHAN_W_ACTIVE_SCAN |
  410. IEEE80211_CHAN_W_IBSS;
  411. chan->power_level = r->power_level;
  412. chan->antenna_max = r->antenna_max;
  413. if (ieee80211_regdom == 64 &&
  414. (chan->freq == 5170 || chan->freq == 5190 ||
  415. chan->freq == 5210 || chan->freq == 5230)) {
  416. /*
  417. * New regulatory rules in Japan have backwards
  418. * compatibility with old channels in 5.15-5.25
  419. * GHz band, but the station is not allowed to
  420. * use active scan on these old channels.
  421. */
  422. chan->flag &= ~IEEE80211_CHAN_W_ACTIVE_SCAN;
  423. }
  424. if (ieee80211_regdom == 64 &&
  425. (chan->freq == 5260 || chan->freq == 5280 ||
  426. chan->freq == 5300 || chan->freq == 5320)) {
  427. /*
  428. * IBSS is not allowed on 5.25-5.35 GHz band
  429. * due to radar detection requirements.
  430. */
  431. chan->flag &= ~IEEE80211_CHAN_W_IBSS;
  432. }
  433. break;
  434. }
  435. }
  436. }
  437. static int ieee80211_unmask_channels(struct net_device *dev)
  438. {
  439. struct ieee80211_local *local = wdev_priv(dev->ieee80211_ptr);
  440. struct ieee80211_hw_mode *mode;
  441. int c;
  442. list_for_each_entry(mode, &local->modes_list, list) {
  443. for (c = 0; c < mode->num_channels; c++) {
  444. ieee80211_unmask_channel(dev, mode->mode,
  445. &mode->channels[c]);
  446. }
  447. }
  448. return 0;
  449. }
  450. int ieee80211_init_client(struct net_device *dev)
  451. {
  452. if (ieee80211_regdom == 0x40)
  453. channel_range = ieee80211_mkk_channels;
  454. ieee80211_unmask_channels(dev);
  455. return 0;
  456. }
  457. static int ieee80211_ioctl_siwmode(struct net_device *dev,
  458. struct iw_request_info *info,
  459. __u32 *mode, char *extra)
  460. {
  461. struct ieee80211_sub_if_data *sdata = IEEE80211_DEV_TO_SUB_IF(dev);
  462. int type;
  463. if (sdata->type == IEEE80211_IF_TYPE_VLAN)
  464. return -EOPNOTSUPP;
  465. switch (*mode) {
  466. case IW_MODE_INFRA:
  467. type = IEEE80211_IF_TYPE_STA;
  468. break;
  469. case IW_MODE_ADHOC:
  470. type = IEEE80211_IF_TYPE_IBSS;
  471. break;
  472. case IW_MODE_MONITOR:
  473. type = IEEE80211_IF_TYPE_MNTR;
  474. break;
  475. default:
  476. return -EINVAL;
  477. }
  478. if (type == sdata->type)
  479. return 0;
  480. if (netif_running(dev))
  481. return -EBUSY;
  482. ieee80211_if_reinit(dev);
  483. ieee80211_if_set_type(dev, type);
  484. return 0;
  485. }
  486. static int ieee80211_ioctl_giwmode(struct net_device *dev,
  487. struct iw_request_info *info,
  488. __u32 *mode, char *extra)
  489. {
  490. struct ieee80211_sub_if_data *sdata;
  491. sdata = IEEE80211_DEV_TO_SUB_IF(dev);
  492. switch (sdata->type) {
  493. case IEEE80211_IF_TYPE_AP:
  494. *mode = IW_MODE_MASTER;
  495. break;
  496. case IEEE80211_IF_TYPE_STA:
  497. *mode = IW_MODE_INFRA;
  498. break;
  499. case IEEE80211_IF_TYPE_IBSS:
  500. *mode = IW_MODE_ADHOC;
  501. break;
  502. case IEEE80211_IF_TYPE_MNTR:
  503. *mode = IW_MODE_MONITOR;
  504. break;
  505. case IEEE80211_IF_TYPE_WDS:
  506. *mode = IW_MODE_REPEAT;
  507. break;
  508. case IEEE80211_IF_TYPE_VLAN:
  509. *mode = IW_MODE_SECOND; /* FIXME */
  510. break;
  511. default:
  512. *mode = IW_MODE_AUTO;
  513. break;
  514. }
  515. return 0;
  516. }
  517. int ieee80211_set_channel(struct ieee80211_local *local, int channel, int freq)
  518. {
  519. struct ieee80211_hw_mode *mode;
  520. int c, set = 0;
  521. int ret = -EINVAL;
  522. list_for_each_entry(mode, &local->modes_list, list) {
  523. if (!(local->enabled_modes & (1 << mode->mode)))
  524. continue;
  525. for (c = 0; c < mode->num_channels; c++) {
  526. struct ieee80211_channel *chan = &mode->channels[c];
  527. if (chan->flag & IEEE80211_CHAN_W_SCAN &&
  528. ((chan->chan == channel) || (chan->freq == freq))) {
  529. /* Use next_mode as the mode preference to
  530. * resolve non-unique channel numbers. */
  531. if (set && mode->mode != local->next_mode)
  532. continue;
  533. local->oper_channel = chan;
  534. local->oper_hw_mode = mode;
  535. set++;
  536. }
  537. }
  538. }
  539. if (set) {
  540. if (local->sta_scanning)
  541. ret = 0;
  542. else
  543. ret = ieee80211_hw_config(local);
  544. rate_control_clear(local);
  545. }
  546. return ret;
  547. }
  548. static int ieee80211_ioctl_siwfreq(struct net_device *dev,
  549. struct iw_request_info *info,
  550. struct iw_freq *freq, char *extra)
  551. {
  552. struct ieee80211_local *local = wdev_priv(dev->ieee80211_ptr);
  553. struct ieee80211_sub_if_data *sdata = IEEE80211_DEV_TO_SUB_IF(dev);
  554. if (sdata->type == IEEE80211_IF_TYPE_STA)
  555. sdata->u.sta.auto_channel_sel = 0;
  556. /* freq->e == 0: freq->m = channel; otherwise freq = m * 10^e */
  557. if (freq->e == 0) {
  558. if (freq->m < 0) {
  559. if (sdata->type == IEEE80211_IF_TYPE_STA)
  560. sdata->u.sta.auto_channel_sel = 1;
  561. return 0;
  562. } else
  563. return ieee80211_set_channel(local, freq->m, -1);
  564. } else {
  565. int i, div = 1000000;
  566. for (i = 0; i < freq->e; i++)
  567. div /= 10;
  568. if (div > 0)
  569. return ieee80211_set_channel(local, -1, freq->m / div);
  570. else
  571. return -EINVAL;
  572. }
  573. }
  574. static int ieee80211_ioctl_giwfreq(struct net_device *dev,
  575. struct iw_request_info *info,
  576. struct iw_freq *freq, char *extra)
  577. {
  578. struct ieee80211_local *local = wdev_priv(dev->ieee80211_ptr);
  579. /* TODO: in station mode (Managed/Ad-hoc) might need to poll low-level
  580. * driver for the current channel with firmware-based management */
  581. freq->m = local->hw.conf.freq;
  582. freq->e = 6;
  583. return 0;
  584. }
  585. static int ieee80211_ioctl_siwessid(struct net_device *dev,
  586. struct iw_request_info *info,
  587. struct iw_point *data, char *ssid)
  588. {
  589. struct ieee80211_local *local = wdev_priv(dev->ieee80211_ptr);
  590. struct ieee80211_sub_if_data *sdata;
  591. size_t len = data->length;
  592. /* iwconfig uses nul termination in SSID.. */
  593. if (len > 0 && ssid[len - 1] == '\0')
  594. len--;
  595. sdata = IEEE80211_DEV_TO_SUB_IF(dev);
  596. if (sdata->type == IEEE80211_IF_TYPE_STA ||
  597. sdata->type == IEEE80211_IF_TYPE_IBSS) {
  598. int ret;
  599. if (local->user_space_mlme) {
  600. if (len > IEEE80211_MAX_SSID_LEN)
  601. return -EINVAL;
  602. memcpy(sdata->u.sta.ssid, ssid, len);
  603. sdata->u.sta.ssid_len = len;
  604. return 0;
  605. }
  606. sdata->u.sta.auto_ssid_sel = !data->flags;
  607. ret = ieee80211_sta_set_ssid(dev, ssid, len);
  608. if (ret)
  609. return ret;
  610. ieee80211_sta_req_auth(dev, &sdata->u.sta);
  611. return 0;
  612. }
  613. if (sdata->type == IEEE80211_IF_TYPE_AP) {
  614. memcpy(sdata->u.ap.ssid, ssid, len);
  615. memset(sdata->u.ap.ssid + len, 0,
  616. IEEE80211_MAX_SSID_LEN - len);
  617. sdata->u.ap.ssid_len = len;
  618. return ieee80211_if_config(dev);
  619. }
  620. return -EOPNOTSUPP;
  621. }
  622. static int ieee80211_ioctl_giwessid(struct net_device *dev,
  623. struct iw_request_info *info,
  624. struct iw_point *data, char *ssid)
  625. {
  626. size_t len;
  627. struct ieee80211_sub_if_data *sdata;
  628. sdata = IEEE80211_DEV_TO_SUB_IF(dev);
  629. if (sdata->type == IEEE80211_IF_TYPE_STA ||
  630. sdata->type == IEEE80211_IF_TYPE_IBSS) {
  631. int res = ieee80211_sta_get_ssid(dev, ssid, &len);
  632. if (res == 0) {
  633. data->length = len;
  634. data->flags = 1;
  635. } else
  636. data->flags = 0;
  637. return res;
  638. }
  639. if (sdata->type == IEEE80211_IF_TYPE_AP) {
  640. len = sdata->u.ap.ssid_len;
  641. if (len > IW_ESSID_MAX_SIZE)
  642. len = IW_ESSID_MAX_SIZE;
  643. memcpy(ssid, sdata->u.ap.ssid, len);
  644. data->length = len;
  645. data->flags = 1;
  646. return 0;
  647. }
  648. return -EOPNOTSUPP;
  649. }
  650. static int ieee80211_ioctl_siwap(struct net_device *dev,
  651. struct iw_request_info *info,
  652. struct sockaddr *ap_addr, char *extra)
  653. {
  654. struct ieee80211_local *local = wdev_priv(dev->ieee80211_ptr);
  655. struct ieee80211_sub_if_data *sdata;
  656. sdata = IEEE80211_DEV_TO_SUB_IF(dev);
  657. if (sdata->type == IEEE80211_IF_TYPE_STA ||
  658. sdata->type == IEEE80211_IF_TYPE_IBSS) {
  659. int ret;
  660. if (local->user_space_mlme) {
  661. memcpy(sdata->u.sta.bssid, (u8 *) &ap_addr->sa_data,
  662. ETH_ALEN);
  663. return 0;
  664. }
  665. if (is_zero_ether_addr((u8 *) &ap_addr->sa_data)) {
  666. sdata->u.sta.auto_bssid_sel = 1;
  667. sdata->u.sta.auto_channel_sel = 1;
  668. } else if (is_broadcast_ether_addr((u8 *) &ap_addr->sa_data))
  669. sdata->u.sta.auto_bssid_sel = 1;
  670. else
  671. sdata->u.sta.auto_bssid_sel = 0;
  672. ret = ieee80211_sta_set_bssid(dev, (u8 *) &ap_addr->sa_data);
  673. if (ret)
  674. return ret;
  675. ieee80211_sta_req_auth(dev, &sdata->u.sta);
  676. return 0;
  677. } else if (sdata->type == IEEE80211_IF_TYPE_WDS) {
  678. if (memcmp(sdata->u.wds.remote_addr, (u8 *) &ap_addr->sa_data,
  679. ETH_ALEN) == 0)
  680. return 0;
  681. return ieee80211_if_update_wds(dev, (u8 *) &ap_addr->sa_data);
  682. }
  683. return -EOPNOTSUPP;
  684. }
  685. static int ieee80211_ioctl_giwap(struct net_device *dev,
  686. struct iw_request_info *info,
  687. struct sockaddr *ap_addr, char *extra)
  688. {
  689. struct ieee80211_sub_if_data *sdata;
  690. sdata = IEEE80211_DEV_TO_SUB_IF(dev);
  691. if (sdata->type == IEEE80211_IF_TYPE_STA ||
  692. sdata->type == IEEE80211_IF_TYPE_IBSS) {
  693. ap_addr->sa_family = ARPHRD_ETHER;
  694. memcpy(&ap_addr->sa_data, sdata->u.sta.bssid, ETH_ALEN);
  695. return 0;
  696. } else if (sdata->type == IEEE80211_IF_TYPE_WDS) {
  697. ap_addr->sa_family = ARPHRD_ETHER;
  698. memcpy(&ap_addr->sa_data, sdata->u.wds.remote_addr, ETH_ALEN);
  699. return 0;
  700. }
  701. return -EOPNOTSUPP;
  702. }
  703. static int ieee80211_ioctl_siwscan(struct net_device *dev,
  704. struct iw_request_info *info,
  705. struct iw_point *data, char *extra)
  706. {
  707. struct ieee80211_local *local = wdev_priv(dev->ieee80211_ptr);
  708. struct ieee80211_sub_if_data *sdata = IEEE80211_DEV_TO_SUB_IF(dev);
  709. u8 *ssid = NULL;
  710. size_t ssid_len = 0;
  711. if (!netif_running(dev))
  712. return -ENETDOWN;
  713. if (local->scan_flags & IEEE80211_SCAN_MATCH_SSID) {
  714. if (sdata->type == IEEE80211_IF_TYPE_STA ||
  715. sdata->type == IEEE80211_IF_TYPE_IBSS) {
  716. ssid = sdata->u.sta.ssid;
  717. ssid_len = sdata->u.sta.ssid_len;
  718. } else if (sdata->type == IEEE80211_IF_TYPE_AP) {
  719. ssid = sdata->u.ap.ssid;
  720. ssid_len = sdata->u.ap.ssid_len;
  721. } else
  722. return -EINVAL;
  723. }
  724. return ieee80211_sta_req_scan(dev, ssid, ssid_len);
  725. }
  726. static int ieee80211_ioctl_giwscan(struct net_device *dev,
  727. struct iw_request_info *info,
  728. struct iw_point *data, char *extra)
  729. {
  730. int res;
  731. struct ieee80211_local *local = wdev_priv(dev->ieee80211_ptr);
  732. if (local->sta_scanning)
  733. return -EAGAIN;
  734. res = ieee80211_sta_scan_results(dev, extra, data->length);
  735. if (res >= 0) {
  736. data->length = res;
  737. return 0;
  738. }
  739. data->length = 0;
  740. return res;
  741. }
  742. static int ieee80211_ioctl_siwrate(struct net_device *dev,
  743. struct iw_request_info *info,
  744. struct iw_param *rate, char *extra)
  745. {
  746. struct ieee80211_local *local = wdev_priv(dev->ieee80211_ptr);
  747. struct ieee80211_hw_mode *mode;
  748. int i;
  749. u32 target_rate = rate->value / 100000;
  750. struct ieee80211_sub_if_data *sdata;
  751. sdata = IEEE80211_DEV_TO_SUB_IF(dev);
  752. if (!sdata->bss)
  753. return -ENODEV;
  754. mode = local->oper_hw_mode;
  755. /* target_rate = -1, rate->fixed = 0 means auto only, so use all rates
  756. * target_rate = X, rate->fixed = 1 means only rate X
  757. * target_rate = X, rate->fixed = 0 means all rates <= X */
  758. sdata->bss->max_ratectrl_rateidx = -1;
  759. sdata->bss->force_unicast_rateidx = -1;
  760. if (rate->value < 0)
  761. return 0;
  762. for (i=0; i< mode->num_rates; i++) {
  763. struct ieee80211_rate *rates = &mode->rates[i];
  764. int this_rate = rates->rate;
  765. if (mode->mode == MODE_ATHEROS_TURBO ||
  766. mode->mode == MODE_ATHEROS_TURBOG)
  767. this_rate *= 2;
  768. if (target_rate == this_rate) {
  769. sdata->bss->max_ratectrl_rateidx = i;
  770. if (rate->fixed)
  771. sdata->bss->force_unicast_rateidx = i;
  772. break;
  773. }
  774. }
  775. return 0;
  776. }
  777. static int ieee80211_ioctl_giwrate(struct net_device *dev,
  778. struct iw_request_info *info,
  779. struct iw_param *rate, char *extra)
  780. {
  781. struct ieee80211_local *local = wdev_priv(dev->ieee80211_ptr);
  782. struct sta_info *sta;
  783. struct ieee80211_sub_if_data *sdata;
  784. sdata = IEEE80211_DEV_TO_SUB_IF(dev);
  785. if (sdata->type == IEEE80211_IF_TYPE_STA)
  786. sta = sta_info_get(local, sdata->u.sta.bssid);
  787. else
  788. return -EOPNOTSUPP;
  789. if (!sta)
  790. return -ENODEV;
  791. if (sta->txrate < local->oper_hw_mode->num_rates)
  792. rate->value = local->oper_hw_mode->rates[sta->txrate].rate * 100000;
  793. else
  794. rate->value = 0;
  795. sta_info_put(sta);
  796. return 0;
  797. }
  798. static int ieee80211_ioctl_siwrts(struct net_device *dev,
  799. struct iw_request_info *info,
  800. struct iw_param *rts, char *extra)
  801. {
  802. struct ieee80211_local *local = wdev_priv(dev->ieee80211_ptr);
  803. if (rts->disabled)
  804. local->rts_threshold = IEEE80211_MAX_RTS_THRESHOLD;
  805. else if (rts->value < 0 || rts->value > IEEE80211_MAX_RTS_THRESHOLD)
  806. return -EINVAL;
  807. else
  808. local->rts_threshold = rts->value;
  809. /* If the wlan card performs RTS/CTS in hardware/firmware,
  810. * configure it here */
  811. if (local->ops->set_rts_threshold)
  812. local->ops->set_rts_threshold(local_to_hw(local),
  813. local->rts_threshold);
  814. return 0;
  815. }
  816. static int ieee80211_ioctl_giwrts(struct net_device *dev,
  817. struct iw_request_info *info,
  818. struct iw_param *rts, char *extra)
  819. {
  820. struct ieee80211_local *local = wdev_priv(dev->ieee80211_ptr);
  821. rts->value = local->rts_threshold;
  822. rts->disabled = (rts->value >= IEEE80211_MAX_RTS_THRESHOLD);
  823. rts->fixed = 1;
  824. return 0;
  825. }
  826. static int ieee80211_ioctl_siwfrag(struct net_device *dev,
  827. struct iw_request_info *info,
  828. struct iw_param *frag, char *extra)
  829. {
  830. struct ieee80211_local *local = wdev_priv(dev->ieee80211_ptr);
  831. if (frag->disabled)
  832. local->fragmentation_threshold = IEEE80211_MAX_FRAG_THRESHOLD;
  833. else if (frag->value < 256 ||
  834. frag->value > IEEE80211_MAX_FRAG_THRESHOLD)
  835. return -EINVAL;
  836. else {
  837. /* Fragment length must be even, so strip LSB. */
  838. local->fragmentation_threshold = frag->value & ~0x1;
  839. }
  840. /* If the wlan card performs fragmentation in hardware/firmware,
  841. * configure it here */
  842. if (local->ops->set_frag_threshold)
  843. local->ops->set_frag_threshold(
  844. local_to_hw(local),
  845. local->fragmentation_threshold);
  846. return 0;
  847. }
  848. static int ieee80211_ioctl_giwfrag(struct net_device *dev,
  849. struct iw_request_info *info,
  850. struct iw_param *frag, char *extra)
  851. {
  852. struct ieee80211_local *local = wdev_priv(dev->ieee80211_ptr);
  853. frag->value = local->fragmentation_threshold;
  854. frag->disabled = (frag->value >= IEEE80211_MAX_RTS_THRESHOLD);
  855. frag->fixed = 1;
  856. return 0;
  857. }
  858. static int ieee80211_ioctl_siwretry(struct net_device *dev,
  859. struct iw_request_info *info,
  860. struct iw_param *retry, char *extra)
  861. {
  862. struct ieee80211_local *local = wdev_priv(dev->ieee80211_ptr);
  863. if (retry->disabled ||
  864. (retry->flags & IW_RETRY_TYPE) != IW_RETRY_LIMIT)
  865. return -EINVAL;
  866. if (retry->flags & IW_RETRY_MAX)
  867. local->long_retry_limit = retry->value;
  868. else if (retry->flags & IW_RETRY_MIN)
  869. local->short_retry_limit = retry->value;
  870. else {
  871. local->long_retry_limit = retry->value;
  872. local->short_retry_limit = retry->value;
  873. }
  874. if (local->ops->set_retry_limit) {
  875. return local->ops->set_retry_limit(
  876. local_to_hw(local),
  877. local->short_retry_limit,
  878. local->long_retry_limit);
  879. }
  880. return 0;
  881. }
  882. static int ieee80211_ioctl_giwretry(struct net_device *dev,
  883. struct iw_request_info *info,
  884. struct iw_param *retry, char *extra)
  885. {
  886. struct ieee80211_local *local = wdev_priv(dev->ieee80211_ptr);
  887. retry->disabled = 0;
  888. if (retry->flags == 0 || retry->flags & IW_RETRY_MIN) {
  889. /* first return min value, iwconfig will ask max value
  890. * later if needed */
  891. retry->flags |= IW_RETRY_LIMIT;
  892. retry->value = local->short_retry_limit;
  893. if (local->long_retry_limit != local->short_retry_limit)
  894. retry->flags |= IW_RETRY_MIN;
  895. return 0;
  896. }
  897. if (retry->flags & IW_RETRY_MAX) {
  898. retry->flags = IW_RETRY_LIMIT | IW_RETRY_MAX;
  899. retry->value = local->long_retry_limit;
  900. }
  901. return 0;
  902. }
  903. static void ieee80211_key_enable_hwaccel(struct ieee80211_local *local,
  904. struct ieee80211_key *key)
  905. {
  906. struct ieee80211_key_conf *keyconf;
  907. u8 addr[ETH_ALEN];
  908. if (!key || key->alg != ALG_WEP || !key->force_sw_encrypt ||
  909. (local->hw.flags & IEEE80211_HW_DEVICE_HIDES_WEP))
  910. return;
  911. memset(addr, 0xff, ETH_ALEN);
  912. keyconf = ieee80211_key_data2conf(local, key);
  913. if (keyconf && local->ops->set_key &&
  914. local->ops->set_key(local_to_hw(local),
  915. SET_KEY, addr, keyconf, 0) == 0) {
  916. key->force_sw_encrypt =
  917. !!(keyconf->flags & IEEE80211_KEY_FORCE_SW_ENCRYPT);
  918. key->hw_key_idx = keyconf->hw_key_idx;
  919. }
  920. kfree(keyconf);
  921. }
  922. static void ieee80211_key_disable_hwaccel(struct ieee80211_local *local,
  923. struct ieee80211_key *key)
  924. {
  925. struct ieee80211_key_conf *keyconf;
  926. u8 addr[ETH_ALEN];
  927. if (!key || key->alg != ALG_WEP || key->force_sw_encrypt ||
  928. (local->hw.flags & IEEE80211_HW_DEVICE_HIDES_WEP))
  929. return;
  930. memset(addr, 0xff, ETH_ALEN);
  931. keyconf = ieee80211_key_data2conf(local, key);
  932. if (keyconf && local->ops->set_key)
  933. local->ops->set_key(local_to_hw(local), DISABLE_KEY,
  934. addr, keyconf, 0);
  935. kfree(keyconf);
  936. key->force_sw_encrypt = 1;
  937. }
  938. static int ieee80211_ioctl_default_wep_only(struct ieee80211_local *local,
  939. int value)
  940. {
  941. int i;
  942. struct ieee80211_sub_if_data *sdata;
  943. local->default_wep_only = value;
  944. read_lock(&local->sub_if_lock);
  945. list_for_each_entry(sdata, &local->sub_if_list, list)
  946. for (i = 0; i < NUM_DEFAULT_KEYS; i++)
  947. if (value)
  948. ieee80211_key_enable_hwaccel(local,
  949. sdata->keys[i]);
  950. else
  951. ieee80211_key_disable_hwaccel(local,
  952. sdata->keys[i]);
  953. read_unlock(&local->sub_if_lock);
  954. return 0;
  955. }
  956. void ieee80211_update_default_wep_only(struct ieee80211_local *local)
  957. {
  958. int i = 0;
  959. struct ieee80211_sub_if_data *sdata;
  960. read_lock(&local->sub_if_lock);
  961. list_for_each_entry(sdata, &local->sub_if_list, list) {
  962. if (sdata->dev == local->mdev)
  963. continue;
  964. /* If there is an AP interface then depend on userspace to
  965. set default_wep_only correctly. */
  966. if (sdata->type == IEEE80211_IF_TYPE_AP) {
  967. read_unlock(&local->sub_if_lock);
  968. return;
  969. }
  970. i++;
  971. }
  972. read_unlock(&local->sub_if_lock);
  973. if (i <= 1)
  974. ieee80211_ioctl_default_wep_only(local, 1);
  975. else
  976. ieee80211_ioctl_default_wep_only(local, 0);
  977. }
  978. static int ieee80211_ioctl_prism2_param(struct net_device *dev,
  979. struct iw_request_info *info,
  980. void *wrqu, char *extra)
  981. {
  982. struct ieee80211_local *local = wdev_priv(dev->ieee80211_ptr);
  983. struct ieee80211_sub_if_data *sdata;
  984. int *i = (int *) extra;
  985. int param = *i;
  986. int value = *(i + 1);
  987. int ret = 0;
  988. if (!capable(CAP_NET_ADMIN))
  989. return -EPERM;
  990. sdata = IEEE80211_DEV_TO_SUB_IF(dev);
  991. switch (param) {
  992. case PRISM2_PARAM_IEEE_802_1X:
  993. if (local->ops->set_ieee8021x)
  994. ret = local->ops->set_ieee8021x(local_to_hw(local),
  995. value);
  996. if (ret)
  997. printk(KERN_DEBUG "%s: failed to set IEEE 802.1X (%d) "
  998. "for low-level driver\n", dev->name, value);
  999. else
  1000. sdata->ieee802_1x = value;
  1001. break;
  1002. case PRISM2_PARAM_CTS_PROTECT_ERP_FRAMES:
  1003. if (sdata->type != IEEE80211_IF_TYPE_AP)
  1004. ret = -ENOENT;
  1005. else
  1006. sdata->use_protection = value;
  1007. break;
  1008. case PRISM2_PARAM_PREAMBLE:
  1009. local->short_preamble = value;
  1010. break;
  1011. case PRISM2_PARAM_STAT_TIME:
  1012. if (!local->stat_time && value) {
  1013. local->stat_timer.expires = jiffies + HZ * value / 100;
  1014. add_timer(&local->stat_timer);
  1015. } else if (local->stat_time && !value) {
  1016. del_timer_sync(&local->stat_timer);
  1017. }
  1018. local->stat_time = value;
  1019. break;
  1020. case PRISM2_PARAM_SHORT_SLOT_TIME:
  1021. if (value)
  1022. local->hw.conf.flags |= IEEE80211_CONF_SHORT_SLOT_TIME;
  1023. else
  1024. local->hw.conf.flags &= ~IEEE80211_CONF_SHORT_SLOT_TIME;
  1025. if (ieee80211_hw_config(local))
  1026. ret = -EINVAL;
  1027. break;
  1028. case PRISM2_PARAM_NEXT_MODE:
  1029. local->next_mode = value;
  1030. break;
  1031. case PRISM2_PARAM_RADIO_ENABLED:
  1032. ret = ieee80211_ioctl_set_radio_enabled(dev, value);
  1033. break;
  1034. case PRISM2_PARAM_ANTENNA_MODE:
  1035. local->hw.conf.antenna_mode = value;
  1036. if (ieee80211_hw_config(local))
  1037. ret = -EINVAL;
  1038. break;
  1039. case PRISM2_PARAM_STA_ANTENNA_SEL:
  1040. local->sta_antenna_sel = value;
  1041. break;
  1042. case PRISM2_PARAM_TX_POWER_REDUCTION:
  1043. if (value < 0)
  1044. ret = -EINVAL;
  1045. else
  1046. local->hw.conf.tx_power_reduction = value;
  1047. break;
  1048. case PRISM2_PARAM_KEY_TX_RX_THRESHOLD:
  1049. local->key_tx_rx_threshold = value;
  1050. break;
  1051. case PRISM2_PARAM_DEFAULT_WEP_ONLY:
  1052. ret = ieee80211_ioctl_default_wep_only(local, value);
  1053. break;
  1054. case PRISM2_PARAM_WIFI_WME_NOACK_TEST:
  1055. local->wifi_wme_noack_test = value;
  1056. break;
  1057. case PRISM2_PARAM_SCAN_FLAGS:
  1058. local->scan_flags = value;
  1059. break;
  1060. case PRISM2_PARAM_MIXED_CELL:
  1061. if (sdata->type != IEEE80211_IF_TYPE_STA &&
  1062. sdata->type != IEEE80211_IF_TYPE_IBSS)
  1063. ret = -EINVAL;
  1064. else
  1065. sdata->u.sta.mixed_cell = !!value;
  1066. break;
  1067. case PRISM2_PARAM_HW_MODES:
  1068. local->enabled_modes = value;
  1069. break;
  1070. case PRISM2_PARAM_CREATE_IBSS:
  1071. if (sdata->type != IEEE80211_IF_TYPE_IBSS)
  1072. ret = -EINVAL;
  1073. else
  1074. sdata->u.sta.create_ibss = !!value;
  1075. break;
  1076. case PRISM2_PARAM_WMM_ENABLED:
  1077. if (sdata->type != IEEE80211_IF_TYPE_STA &&
  1078. sdata->type != IEEE80211_IF_TYPE_IBSS)
  1079. ret = -EINVAL;
  1080. else
  1081. sdata->u.sta.wmm_enabled = !!value;
  1082. break;
  1083. case PRISM2_PARAM_RADAR_DETECT:
  1084. local->hw.conf.radar_detect = value;
  1085. break;
  1086. case PRISM2_PARAM_SPECTRUM_MGMT:
  1087. local->hw.conf.spect_mgmt = value;
  1088. break;
  1089. default:
  1090. ret = -EOPNOTSUPP;
  1091. break;
  1092. }
  1093. return ret;
  1094. }
  1095. static int ieee80211_ioctl_get_prism2_param(struct net_device *dev,
  1096. struct iw_request_info *info,
  1097. void *wrqu, char *extra)
  1098. {
  1099. struct ieee80211_local *local = wdev_priv(dev->ieee80211_ptr);
  1100. struct ieee80211_sub_if_data *sdata;
  1101. int *param = (int *) extra;
  1102. int ret = 0;
  1103. sdata = IEEE80211_DEV_TO_SUB_IF(dev);
  1104. switch (*param) {
  1105. case PRISM2_PARAM_IEEE_802_1X:
  1106. *param = sdata->ieee802_1x;
  1107. break;
  1108. case PRISM2_PARAM_CTS_PROTECT_ERP_FRAMES:
  1109. *param = sdata->use_protection;
  1110. break;
  1111. case PRISM2_PARAM_PREAMBLE:
  1112. *param = local->short_preamble;
  1113. break;
  1114. case PRISM2_PARAM_STAT_TIME:
  1115. *param = local->stat_time;
  1116. break;
  1117. case PRISM2_PARAM_SHORT_SLOT_TIME:
  1118. *param = !!(local->hw.conf.flags & IEEE80211_CONF_SHORT_SLOT_TIME);
  1119. break;
  1120. case PRISM2_PARAM_NEXT_MODE:
  1121. *param = local->next_mode;
  1122. break;
  1123. case PRISM2_PARAM_ANTENNA_MODE:
  1124. *param = local->hw.conf.antenna_mode;
  1125. break;
  1126. case PRISM2_PARAM_STA_ANTENNA_SEL:
  1127. *param = local->sta_antenna_sel;
  1128. break;
  1129. case PRISM2_PARAM_TX_POWER_REDUCTION:
  1130. *param = local->hw.conf.tx_power_reduction;
  1131. break;
  1132. case PRISM2_PARAM_KEY_TX_RX_THRESHOLD:
  1133. *param = local->key_tx_rx_threshold;
  1134. break;
  1135. case PRISM2_PARAM_DEFAULT_WEP_ONLY:
  1136. *param = local->default_wep_only;
  1137. break;
  1138. case PRISM2_PARAM_WIFI_WME_NOACK_TEST:
  1139. *param = local->wifi_wme_noack_test;
  1140. break;
  1141. case PRISM2_PARAM_SCAN_FLAGS:
  1142. *param = local->scan_flags;
  1143. break;
  1144. case PRISM2_PARAM_HW_MODES:
  1145. *param = local->enabled_modes;
  1146. break;
  1147. case PRISM2_PARAM_CREATE_IBSS:
  1148. if (sdata->type != IEEE80211_IF_TYPE_IBSS)
  1149. ret = -EINVAL;
  1150. else
  1151. *param = !!sdata->u.sta.create_ibss;
  1152. break;
  1153. case PRISM2_PARAM_MIXED_CELL:
  1154. if (sdata->type != IEEE80211_IF_TYPE_STA &&
  1155. sdata->type != IEEE80211_IF_TYPE_IBSS)
  1156. ret = -EINVAL;
  1157. else
  1158. *param = !!sdata->u.sta.mixed_cell;
  1159. break;
  1160. case PRISM2_PARAM_WMM_ENABLED:
  1161. if (sdata->type != IEEE80211_IF_TYPE_STA &&
  1162. sdata->type != IEEE80211_IF_TYPE_IBSS)
  1163. ret = -EINVAL;
  1164. else
  1165. *param = !!sdata->u.sta.wmm_enabled;
  1166. break;
  1167. default:
  1168. ret = -EOPNOTSUPP;
  1169. break;
  1170. }
  1171. return ret;
  1172. }
  1173. static int ieee80211_ioctl_siwmlme(struct net_device *dev,
  1174. struct iw_request_info *info,
  1175. struct iw_point *data, char *extra)
  1176. {
  1177. struct ieee80211_sub_if_data *sdata;
  1178. struct iw_mlme *mlme = (struct iw_mlme *) extra;
  1179. sdata = IEEE80211_DEV_TO_SUB_IF(dev);
  1180. if (sdata->type != IEEE80211_IF_TYPE_STA &&
  1181. sdata->type != IEEE80211_IF_TYPE_IBSS)
  1182. return -EINVAL;
  1183. switch (mlme->cmd) {
  1184. case IW_MLME_DEAUTH:
  1185. /* TODO: mlme->addr.sa_data */
  1186. return ieee80211_sta_deauthenticate(dev, mlme->reason_code);
  1187. case IW_MLME_DISASSOC:
  1188. /* TODO: mlme->addr.sa_data */
  1189. return ieee80211_sta_disassociate(dev, mlme->reason_code);
  1190. default:
  1191. return -EOPNOTSUPP;
  1192. }
  1193. }
  1194. static int ieee80211_ioctl_siwencode(struct net_device *dev,
  1195. struct iw_request_info *info,
  1196. struct iw_point *erq, char *keybuf)
  1197. {
  1198. struct ieee80211_sub_if_data *sdata;
  1199. int idx, i, alg = ALG_WEP;
  1200. u8 bcaddr[ETH_ALEN] = { 0xff, 0xff, 0xff, 0xff, 0xff, 0xff };
  1201. sdata = IEEE80211_DEV_TO_SUB_IF(dev);
  1202. idx = erq->flags & IW_ENCODE_INDEX;
  1203. if (idx == 0) {
  1204. if (sdata->default_key)
  1205. for (i = 0; i < NUM_DEFAULT_KEYS; i++) {
  1206. if (sdata->default_key == sdata->keys[i]) {
  1207. idx = i;
  1208. break;
  1209. }
  1210. }
  1211. } else if (idx < 1 || idx > 4)
  1212. return -EINVAL;
  1213. else
  1214. idx--;
  1215. if (erq->flags & IW_ENCODE_DISABLED)
  1216. alg = ALG_NONE;
  1217. else if (erq->length == 0) {
  1218. /* No key data - just set the default TX key index */
  1219. if (sdata->default_key != sdata->keys[idx]) {
  1220. ieee80211_debugfs_key_remove_default(sdata);
  1221. sdata->default_key = sdata->keys[idx];
  1222. if (sdata->default_key)
  1223. ieee80211_debugfs_key_add_default(sdata);
  1224. }
  1225. return 0;
  1226. }
  1227. return ieee80211_set_encryption(
  1228. dev, bcaddr,
  1229. idx, alg,
  1230. !sdata->default_key,
  1231. keybuf, erq->length);
  1232. }
  1233. static int ieee80211_ioctl_giwencode(struct net_device *dev,
  1234. struct iw_request_info *info,
  1235. struct iw_point *erq, char *key)
  1236. {
  1237. struct ieee80211_sub_if_data *sdata;
  1238. int idx, i;
  1239. sdata = IEEE80211_DEV_TO_SUB_IF(dev);
  1240. idx = erq->flags & IW_ENCODE_INDEX;
  1241. if (idx < 1 || idx > 4) {
  1242. idx = -1;
  1243. if (!sdata->default_key)
  1244. idx = 0;
  1245. else for (i = 0; i < NUM_DEFAULT_KEYS; i++) {
  1246. if (sdata->default_key == sdata->keys[i]) {
  1247. idx = i;
  1248. break;
  1249. }
  1250. }
  1251. if (idx < 0)
  1252. return -EINVAL;
  1253. } else
  1254. idx--;
  1255. erq->flags = idx + 1;
  1256. if (!sdata->keys[idx]) {
  1257. erq->length = 0;
  1258. erq->flags |= IW_ENCODE_DISABLED;
  1259. return 0;
  1260. }
  1261. memcpy(key, sdata->keys[idx]->key,
  1262. min((int)erq->length, sdata->keys[idx]->keylen));
  1263. erq->length = sdata->keys[idx]->keylen;
  1264. erq->flags |= IW_ENCODE_ENABLED;
  1265. return 0;
  1266. }
  1267. static int ieee80211_ioctl_siwauth(struct net_device *dev,
  1268. struct iw_request_info *info,
  1269. struct iw_param *data, char *extra)
  1270. {
  1271. struct ieee80211_local *local = wdev_priv(dev->ieee80211_ptr);
  1272. struct ieee80211_sub_if_data *sdata = IEEE80211_DEV_TO_SUB_IF(dev);
  1273. int ret = 0;
  1274. switch (data->flags & IW_AUTH_INDEX) {
  1275. case IW_AUTH_WPA_VERSION:
  1276. case IW_AUTH_CIPHER_PAIRWISE:
  1277. case IW_AUTH_CIPHER_GROUP:
  1278. case IW_AUTH_WPA_ENABLED:
  1279. case IW_AUTH_RX_UNENCRYPTED_EAPOL:
  1280. break;
  1281. case IW_AUTH_KEY_MGMT:
  1282. if (sdata->type != IEEE80211_IF_TYPE_STA)
  1283. ret = -EINVAL;
  1284. else {
  1285. /*
  1286. * TODO: sdata->u.sta.key_mgmt does not match with WE18
  1287. * value completely; could consider modifying this to
  1288. * be closer to WE18. For now, this value is not really
  1289. * used for anything else than Privacy matching, so the
  1290. * current code here should be more or less OK.
  1291. */
  1292. if (data->value & IW_AUTH_KEY_MGMT_802_1X) {
  1293. sdata->u.sta.key_mgmt =
  1294. IEEE80211_KEY_MGMT_WPA_EAP;
  1295. } else if (data->value & IW_AUTH_KEY_MGMT_PSK) {
  1296. sdata->u.sta.key_mgmt =
  1297. IEEE80211_KEY_MGMT_WPA_PSK;
  1298. } else {
  1299. sdata->u.sta.key_mgmt =
  1300. IEEE80211_KEY_MGMT_NONE;
  1301. }
  1302. }
  1303. break;
  1304. case IW_AUTH_80211_AUTH_ALG:
  1305. if (sdata->type == IEEE80211_IF_TYPE_STA ||
  1306. sdata->type == IEEE80211_IF_TYPE_IBSS)
  1307. sdata->u.sta.auth_algs = data->value;
  1308. else
  1309. ret = -EOPNOTSUPP;
  1310. break;
  1311. case IW_AUTH_PRIVACY_INVOKED:
  1312. if (local->ops->set_privacy_invoked)
  1313. ret = local->ops->set_privacy_invoked(
  1314. local_to_hw(local), data->value);
  1315. break;
  1316. default:
  1317. ret = -EOPNOTSUPP;
  1318. break;
  1319. }
  1320. return ret;
  1321. }
  1322. /* Get wireless statistics. Called by /proc/net/wireless and by SIOCGIWSTATS */
  1323. static struct iw_statistics *ieee80211_get_wireless_stats(struct net_device *dev)
  1324. {
  1325. struct ieee80211_local *local = wdev_priv(dev->ieee80211_ptr);
  1326. struct iw_statistics *wstats = &local->wstats;
  1327. struct ieee80211_sub_if_data *sdata = IEEE80211_DEV_TO_SUB_IF(dev);
  1328. struct sta_info *sta = NULL;
  1329. if (sdata->type == IEEE80211_IF_TYPE_STA ||
  1330. sdata->type == IEEE80211_IF_TYPE_IBSS)
  1331. sta = sta_info_get(local, sdata->u.sta.bssid);
  1332. if (!sta) {
  1333. wstats->discard.fragment = 0;
  1334. wstats->discard.misc = 0;
  1335. wstats->qual.qual = 0;
  1336. wstats->qual.level = 0;
  1337. wstats->qual.noise = 0;
  1338. wstats->qual.updated = IW_QUAL_ALL_INVALID;
  1339. } else {
  1340. wstats->qual.level = sta->last_rssi;
  1341. wstats->qual.qual = sta->last_signal;
  1342. wstats->qual.noise = sta->last_noise;
  1343. wstats->qual.updated = local->wstats_flags;
  1344. sta_info_put(sta);
  1345. }
  1346. return wstats;
  1347. }
  1348. static int ieee80211_ioctl_giwauth(struct net_device *dev,
  1349. struct iw_request_info *info,
  1350. struct iw_param *data, char *extra)
  1351. {
  1352. struct ieee80211_sub_if_data *sdata = IEEE80211_DEV_TO_SUB_IF(dev);
  1353. int ret = 0;
  1354. switch (data->flags & IW_AUTH_INDEX) {
  1355. case IW_AUTH_80211_AUTH_ALG:
  1356. if (sdata->type == IEEE80211_IF_TYPE_STA ||
  1357. sdata->type == IEEE80211_IF_TYPE_IBSS)
  1358. data->value = sdata->u.sta.auth_algs;
  1359. else
  1360. ret = -EOPNOTSUPP;
  1361. break;
  1362. default:
  1363. ret = -EOPNOTSUPP;
  1364. break;
  1365. }
  1366. return ret;
  1367. }
  1368. static int ieee80211_ioctl_siwencodeext(struct net_device *dev,
  1369. struct iw_request_info *info,
  1370. struct iw_point *erq, char *extra)
  1371. {
  1372. struct ieee80211_sub_if_data *sdata = IEEE80211_DEV_TO_SUB_IF(dev);
  1373. struct iw_encode_ext *ext = (struct iw_encode_ext *) extra;
  1374. int alg, idx, i;
  1375. switch (ext->alg) {
  1376. case IW_ENCODE_ALG_NONE:
  1377. alg = ALG_NONE;
  1378. break;
  1379. case IW_ENCODE_ALG_WEP:
  1380. alg = ALG_WEP;
  1381. break;
  1382. case IW_ENCODE_ALG_TKIP:
  1383. alg = ALG_TKIP;
  1384. break;
  1385. case IW_ENCODE_ALG_CCMP:
  1386. alg = ALG_CCMP;
  1387. break;
  1388. default:
  1389. return -EOPNOTSUPP;
  1390. }
  1391. if (erq->flags & IW_ENCODE_DISABLED)
  1392. alg = ALG_NONE;
  1393. idx = erq->flags & IW_ENCODE_INDEX;
  1394. if (idx < 1 || idx > 4) {
  1395. idx = -1;
  1396. if (!sdata->default_key)
  1397. idx = 0;
  1398. else for (i = 0; i < NUM_DEFAULT_KEYS; i++) {
  1399. if (sdata->default_key == sdata->keys[i]) {
  1400. idx = i;
  1401. break;
  1402. }
  1403. }
  1404. if (idx < 0)
  1405. return -EINVAL;
  1406. } else
  1407. idx--;
  1408. return ieee80211_set_encryption(dev, ext->addr.sa_data, idx, alg,
  1409. ext->ext_flags &
  1410. IW_ENCODE_EXT_SET_TX_KEY,
  1411. ext->key, ext->key_len);
  1412. }
  1413. static const struct iw_priv_args ieee80211_ioctl_priv[] = {
  1414. { PRISM2_IOCTL_PRISM2_PARAM,
  1415. IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 2, 0, "param" },
  1416. { PRISM2_IOCTL_GET_PRISM2_PARAM,
  1417. IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1,
  1418. IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1, "get_param" },
  1419. };
  1420. /* Structures to export the Wireless Handlers */
  1421. static const iw_handler ieee80211_handler[] =
  1422. {
  1423. (iw_handler) NULL, /* SIOCSIWCOMMIT */
  1424. (iw_handler) ieee80211_ioctl_giwname, /* SIOCGIWNAME */
  1425. (iw_handler) NULL, /* SIOCSIWNWID */
  1426. (iw_handler) NULL, /* SIOCGIWNWID */
  1427. (iw_handler) ieee80211_ioctl_siwfreq, /* SIOCSIWFREQ */
  1428. (iw_handler) ieee80211_ioctl_giwfreq, /* SIOCGIWFREQ */
  1429. (iw_handler) ieee80211_ioctl_siwmode, /* SIOCSIWMODE */
  1430. (iw_handler) ieee80211_ioctl_giwmode, /* SIOCGIWMODE */
  1431. (iw_handler) NULL, /* SIOCSIWSENS */
  1432. (iw_handler) NULL, /* SIOCGIWSENS */
  1433. (iw_handler) NULL /* not used */, /* SIOCSIWRANGE */
  1434. (iw_handler) ieee80211_ioctl_giwrange, /* SIOCGIWRANGE */
  1435. (iw_handler) NULL /* not used */, /* SIOCSIWPRIV */
  1436. (iw_handler) NULL /* kernel code */, /* SIOCGIWPRIV */
  1437. (iw_handler) NULL /* not used */, /* SIOCSIWSTATS */
  1438. (iw_handler) NULL /* kernel code */, /* SIOCGIWSTATS */
  1439. iw_handler_set_spy, /* SIOCSIWSPY */
  1440. iw_handler_get_spy, /* SIOCGIWSPY */
  1441. iw_handler_set_thrspy, /* SIOCSIWTHRSPY */
  1442. iw_handler_get_thrspy, /* SIOCGIWTHRSPY */
  1443. (iw_handler) ieee80211_ioctl_siwap, /* SIOCSIWAP */
  1444. (iw_handler) ieee80211_ioctl_giwap, /* SIOCGIWAP */
  1445. (iw_handler) ieee80211_ioctl_siwmlme, /* SIOCSIWMLME */
  1446. (iw_handler) NULL, /* SIOCGIWAPLIST */
  1447. (iw_handler) ieee80211_ioctl_siwscan, /* SIOCSIWSCAN */
  1448. (iw_handler) ieee80211_ioctl_giwscan, /* SIOCGIWSCAN */
  1449. (iw_handler) ieee80211_ioctl_siwessid, /* SIOCSIWESSID */
  1450. (iw_handler) ieee80211_ioctl_giwessid, /* SIOCGIWESSID */
  1451. (iw_handler) NULL, /* SIOCSIWNICKN */
  1452. (iw_handler) NULL, /* SIOCGIWNICKN */
  1453. (iw_handler) NULL, /* -- hole -- */
  1454. (iw_handler) NULL, /* -- hole -- */
  1455. (iw_handler) ieee80211_ioctl_siwrate, /* SIOCSIWRATE */
  1456. (iw_handler) ieee80211_ioctl_giwrate, /* SIOCGIWRATE */
  1457. (iw_handler) ieee80211_ioctl_siwrts, /* SIOCSIWRTS */
  1458. (iw_handler) ieee80211_ioctl_giwrts, /* SIOCGIWRTS */
  1459. (iw_handler) ieee80211_ioctl_siwfrag, /* SIOCSIWFRAG */
  1460. (iw_handler) ieee80211_ioctl_giwfrag, /* SIOCGIWFRAG */
  1461. (iw_handler) NULL, /* SIOCSIWTXPOW */
  1462. (iw_handler) NULL, /* SIOCGIWTXPOW */
  1463. (iw_handler) ieee80211_ioctl_siwretry, /* SIOCSIWRETRY */
  1464. (iw_handler) ieee80211_ioctl_giwretry, /* SIOCGIWRETRY */
  1465. (iw_handler) ieee80211_ioctl_siwencode, /* SIOCSIWENCODE */
  1466. (iw_handler) ieee80211_ioctl_giwencode, /* SIOCGIWENCODE */
  1467. (iw_handler) NULL, /* SIOCSIWPOWER */
  1468. (iw_handler) NULL, /* SIOCGIWPOWER */
  1469. (iw_handler) NULL, /* -- hole -- */
  1470. (iw_handler) NULL, /* -- hole -- */
  1471. (iw_handler) ieee80211_ioctl_siwgenie, /* SIOCSIWGENIE */
  1472. (iw_handler) NULL, /* SIOCGIWGENIE */
  1473. (iw_handler) ieee80211_ioctl_siwauth, /* SIOCSIWAUTH */
  1474. (iw_handler) ieee80211_ioctl_giwauth, /* SIOCGIWAUTH */
  1475. (iw_handler) ieee80211_ioctl_siwencodeext, /* SIOCSIWENCODEEXT */
  1476. (iw_handler) NULL, /* SIOCGIWENCODEEXT */
  1477. (iw_handler) NULL, /* SIOCSIWPMKSA */
  1478. (iw_handler) NULL, /* -- hole -- */
  1479. };
  1480. static const iw_handler ieee80211_private_handler[] =
  1481. { /* SIOCIWFIRSTPRIV + */
  1482. (iw_handler) ieee80211_ioctl_prism2_param, /* 0 */
  1483. (iw_handler) ieee80211_ioctl_get_prism2_param, /* 1 */
  1484. };
  1485. const struct iw_handler_def ieee80211_iw_handler_def =
  1486. {
  1487. .num_standard = ARRAY_SIZE(ieee80211_handler),
  1488. .num_private = ARRAY_SIZE(ieee80211_private_handler),
  1489. .num_private_args = ARRAY_SIZE(ieee80211_ioctl_priv),
  1490. .standard = (iw_handler *) ieee80211_handler,
  1491. .private = (iw_handler *) ieee80211_private_handler,
  1492. .private_args = (struct iw_priv_args *) ieee80211_ioctl_priv,
  1493. .get_wireless_stats = ieee80211_get_wireless_stats,
  1494. };