ieee80211_ioctl.c 46 KB

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