ieee80211_ioctl.c 47 KB

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