ieee80211_ioctl.c 47 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495969798991001011021031041051061071081091101111121131141151161171181191201211221231241251261271281291301311321331341351361371381391401411421431441451461471481491501511521531541551561571581591601611621631641651661671681691701711721731741751761771781791801811821831841851861871881891901911921931941951961971981992002012022032042052062072082092102112122132142152162172182192202212222232242252262272282292302312322332342352362372382392402412422432442452462472482492502512522532542552562572582592602612622632642652662672682692702712722732742752762772782792802812822832842852862872882892902912922932942952962972982993003013023033043053063073083093103113123133143153163173183193203213223233243253263273283293303313323333343353363373383393403413423433443453463473483493503513523533543553563573583593603613623633643653663673683693703713723733743753763773783793803813823833843853863873883893903913923933943953963973983994004014024034044054064074084094104114124134144154164174184194204214224234244254264274284294304314324334344354364374384394404414424434444454464474484494504514524534544554564574584594604614624634644654664674684694704714724734744754764774784794804814824834844854864874884894904914924934944954964974984995005015025035045055065075085095105115125135145155165175185195205215225235245255265275285295305315325335345355365375385395405415425435445455465475485495505515525535545555565575585595605615625635645655665675685695705715725735745755765775785795805815825835845855865875885895905915925935945955965975985996006016026036046056066076086096106116126136146156166176186196206216226236246256266276286296306316326336346356366376386396406416426436446456466476486496506516526536546556566576586596606616626636646656666676686696706716726736746756766776786796806816826836846856866876886896906916926936946956966976986997007017027037047057067077087097107117127137147157167177187197207217227237247257267277287297307317327337347357367377387397407417427437447457467477487497507517527537547557567577587597607617627637647657667677687697707717727737747757767777787797807817827837847857867877887897907917927937947957967977987998008018028038048058068078088098108118128138148158168178188198208218228238248258268278288298308318328338348358368378388398408418428438448458468478488498508518528538548558568578588598608618628638648658668678688698708718728738748758768778788798808818828838848858868878888898908918928938948958968978988999009019029039049059069079089099109119129139149159169179189199209219229239249259269279289299309319329339349359369379389399409419429439449459469479489499509519529539549559569579589599609619629639649659669679689699709719729739749759769779789799809819829839849859869879889899909919929939949959969979989991000100110021003100410051006100710081009101010111012101310141015101610171018101910201021102210231024102510261027102810291030103110321033103410351036103710381039104010411042104310441045104610471048104910501051105210531054105510561057105810591060106110621063106410651066106710681069107010711072107310741075107610771078107910801081108210831084108510861087108810891090109110921093109410951096109710981099110011011102110311041105110611071108110911101111111211131114111511161117111811191120112111221123112411251126112711281129113011311132113311341135113611371138113911401141114211431144114511461147114811491150115111521153115411551156115711581159116011611162116311641165116611671168116911701171117211731174117511761177117811791180118111821183118411851186118711881189119011911192119311941195119611971198119912001201120212031204120512061207120812091210121112121213121412151216121712181219122012211222122312241225122612271228122912301231123212331234123512361237123812391240124112421243124412451246124712481249125012511252125312541255125612571258125912601261126212631264126512661267126812691270127112721273127412751276127712781279128012811282128312841285128612871288128912901291129212931294129512961297129812991300130113021303130413051306130713081309131013111312131313141315131613171318131913201321132213231324132513261327132813291330133113321333133413351336133713381339134013411342134313441345134613471348134913501351135213531354135513561357135813591360136113621363136413651366136713681369137013711372137313741375137613771378137913801381138213831384138513861387138813891390139113921393139413951396139713981399140014011402140314041405140614071408140914101411141214131414141514161417141814191420142114221423142414251426142714281429143014311432143314341435143614371438143914401441144214431444144514461447144814491450145114521453145414551456145714581459146014611462146314641465146614671468146914701471147214731474147514761477147814791480148114821483148414851486148714881489149014911492149314941495149614971498149915001501150215031504150515061507150815091510151115121513151415151516151715181519152015211522152315241525152615271528152915301531153215331534153515361537153815391540154115421543154415451546154715481549155015511552155315541555155615571558155915601561156215631564156515661567156815691570157115721573157415751576157715781579158015811582158315841585158615871588158915901591159215931594159515961597159815991600160116021603160416051606160716081609161016111612161316141615161616171618161916201621162216231624162516261627162816291630163116321633163416351636163716381639164016411642164316441645164616471648164916501651165216531654165516561657165816591660166116621663166416651666166716681669167016711672167316741675167616771678167916801681168216831684168516861687168816891690169116921693169416951696169716981699170017011702170317041705170617071708170917101711171217131714171517161717171817191720172117221723172417251726172717281729173017311732173317341735173617371738173917401741174217431744174517461747174817491750175117521753175417551756175717581759176017611762176317641765176617671768176917701771177217731774177517761777177817791780178117821783178417851786178717881789179017911792179317941795179617971798179918001801180218031804180518061807180818091810181118121813181418151816181718181819182018211822
  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_siwrts(struct net_device *dev,
  722. struct iw_request_info *info,
  723. struct iw_param *rts, char *extra)
  724. {
  725. struct ieee80211_local *local = wdev_priv(dev->ieee80211_ptr);
  726. if (rts->disabled)
  727. local->rts_threshold = IEEE80211_MAX_RTS_THRESHOLD;
  728. else if (rts->value < 0 || rts->value > IEEE80211_MAX_RTS_THRESHOLD)
  729. return -EINVAL;
  730. else
  731. local->rts_threshold = rts->value;
  732. /* If the wlan card performs RTS/CTS in hardware/firmware,
  733. * configure it here */
  734. if (local->ops->set_rts_threshold)
  735. local->ops->set_rts_threshold(local_to_hw(local),
  736. local->rts_threshold);
  737. return 0;
  738. }
  739. static int ieee80211_ioctl_giwrts(struct net_device *dev,
  740. struct iw_request_info *info,
  741. struct iw_param *rts, char *extra)
  742. {
  743. struct ieee80211_local *local = wdev_priv(dev->ieee80211_ptr);
  744. rts->value = local->rts_threshold;
  745. rts->disabled = (rts->value >= IEEE80211_MAX_RTS_THRESHOLD);
  746. rts->fixed = 1;
  747. return 0;
  748. }
  749. static int ieee80211_ioctl_siwfrag(struct net_device *dev,
  750. struct iw_request_info *info,
  751. struct iw_param *frag, char *extra)
  752. {
  753. struct ieee80211_local *local = wdev_priv(dev->ieee80211_ptr);
  754. if (frag->disabled)
  755. local->fragmentation_threshold = IEEE80211_MAX_FRAG_THRESHOLD;
  756. else if (frag->value < 256 ||
  757. frag->value > IEEE80211_MAX_FRAG_THRESHOLD)
  758. return -EINVAL;
  759. else {
  760. /* Fragment length must be even, so strip LSB. */
  761. local->fragmentation_threshold = frag->value & ~0x1;
  762. }
  763. /* If the wlan card performs fragmentation in hardware/firmware,
  764. * configure it here */
  765. if (local->ops->set_frag_threshold)
  766. local->ops->set_frag_threshold(
  767. local_to_hw(local),
  768. local->fragmentation_threshold);
  769. return 0;
  770. }
  771. static int ieee80211_ioctl_giwfrag(struct net_device *dev,
  772. struct iw_request_info *info,
  773. struct iw_param *frag, char *extra)
  774. {
  775. struct ieee80211_local *local = wdev_priv(dev->ieee80211_ptr);
  776. frag->value = local->fragmentation_threshold;
  777. frag->disabled = (frag->value >= IEEE80211_MAX_RTS_THRESHOLD);
  778. frag->fixed = 1;
  779. return 0;
  780. }
  781. static int ieee80211_ioctl_siwretry(struct net_device *dev,
  782. struct iw_request_info *info,
  783. struct iw_param *retry, char *extra)
  784. {
  785. struct ieee80211_local *local = wdev_priv(dev->ieee80211_ptr);
  786. if (retry->disabled ||
  787. (retry->flags & IW_RETRY_TYPE) != IW_RETRY_LIMIT)
  788. return -EINVAL;
  789. if (retry->flags & IW_RETRY_MAX)
  790. local->long_retry_limit = retry->value;
  791. else if (retry->flags & IW_RETRY_MIN)
  792. local->short_retry_limit = retry->value;
  793. else {
  794. local->long_retry_limit = retry->value;
  795. local->short_retry_limit = retry->value;
  796. }
  797. if (local->ops->set_retry_limit) {
  798. return local->ops->set_retry_limit(
  799. local_to_hw(local),
  800. local->short_retry_limit,
  801. local->long_retry_limit);
  802. }
  803. return 0;
  804. }
  805. static int ieee80211_ioctl_giwretry(struct net_device *dev,
  806. struct iw_request_info *info,
  807. struct iw_param *retry, char *extra)
  808. {
  809. struct ieee80211_local *local = wdev_priv(dev->ieee80211_ptr);
  810. retry->disabled = 0;
  811. if (retry->flags == 0 || retry->flags & IW_RETRY_MIN) {
  812. /* first return min value, iwconfig will ask max value
  813. * later if needed */
  814. retry->flags |= IW_RETRY_LIMIT;
  815. retry->value = local->short_retry_limit;
  816. if (local->long_retry_limit != local->short_retry_limit)
  817. retry->flags |= IW_RETRY_MIN;
  818. return 0;
  819. }
  820. if (retry->flags & IW_RETRY_MAX) {
  821. retry->flags = IW_RETRY_LIMIT | IW_RETRY_MAX;
  822. retry->value = local->long_retry_limit;
  823. }
  824. return 0;
  825. }
  826. static int ieee80211_ioctl_clear_keys(struct net_device *dev)
  827. {
  828. struct ieee80211_local *local = wdev_priv(dev->ieee80211_ptr);
  829. struct ieee80211_key_conf key;
  830. int i;
  831. u8 addr[ETH_ALEN];
  832. struct ieee80211_key_conf *keyconf;
  833. struct ieee80211_sub_if_data *sdata;
  834. struct sta_info *sta;
  835. memset(addr, 0xff, ETH_ALEN);
  836. read_lock(&local->sub_if_lock);
  837. list_for_each_entry(sdata, &local->sub_if_list, list) {
  838. for (i = 0; i < NUM_DEFAULT_KEYS; i++) {
  839. keyconf = NULL;
  840. if (sdata->keys[i] &&
  841. !sdata->keys[i]->force_sw_encrypt &&
  842. local->ops->set_key &&
  843. (keyconf = ieee80211_key_data2conf(local,
  844. sdata->keys[i])))
  845. local->ops->set_key(local_to_hw(local),
  846. DISABLE_KEY, addr,
  847. keyconf, 0);
  848. kfree(keyconf);
  849. ieee80211_key_free(sdata->keys[i]);
  850. sdata->keys[i] = NULL;
  851. }
  852. sdata->default_key = NULL;
  853. }
  854. read_unlock(&local->sub_if_lock);
  855. spin_lock_bh(&local->sta_lock);
  856. list_for_each_entry(sta, &local->sta_list, list) {
  857. keyconf = NULL;
  858. if (sta->key && !sta->key->force_sw_encrypt &&
  859. local->ops->set_key &&
  860. (keyconf = ieee80211_key_data2conf(local, sta->key)))
  861. local->ops->set_key(local_to_hw(local), DISABLE_KEY,
  862. sta->addr, keyconf, sta->aid);
  863. kfree(keyconf);
  864. ieee80211_key_free(sta->key);
  865. sta->key = NULL;
  866. }
  867. spin_unlock_bh(&local->sta_lock);
  868. memset(&key, 0, sizeof(key));
  869. if (local->ops->set_key &&
  870. local->ops->set_key(local_to_hw(local), REMOVE_ALL_KEYS,
  871. NULL, &key, 0))
  872. printk(KERN_DEBUG "%s: failed to remove hwaccel keys\n",
  873. dev->name);
  874. return 0;
  875. }
  876. static int
  877. ieee80211_ioctl_force_unicast_rate(struct net_device *dev,
  878. struct ieee80211_sub_if_data *sdata,
  879. int rate)
  880. {
  881. struct ieee80211_local *local = wdev_priv(dev->ieee80211_ptr);
  882. struct ieee80211_hw_mode *mode;
  883. int i;
  884. if (sdata->type != IEEE80211_IF_TYPE_AP)
  885. return -ENOENT;
  886. if (rate == 0) {
  887. sdata->u.ap.force_unicast_rateidx = -1;
  888. return 0;
  889. }
  890. mode = local->oper_hw_mode;
  891. for (i = 0; i < mode->num_rates; i++) {
  892. if (mode->rates[i].rate == rate) {
  893. sdata->u.ap.force_unicast_rateidx = i;
  894. return 0;
  895. }
  896. }
  897. return -EINVAL;
  898. }
  899. static int
  900. ieee80211_ioctl_max_ratectrl_rate(struct net_device *dev,
  901. struct ieee80211_sub_if_data *sdata,
  902. int rate)
  903. {
  904. struct ieee80211_local *local = wdev_priv(dev->ieee80211_ptr);
  905. struct ieee80211_hw_mode *mode;
  906. int i;
  907. if (sdata->type != IEEE80211_IF_TYPE_AP)
  908. return -ENOENT;
  909. if (rate == 0) {
  910. sdata->u.ap.max_ratectrl_rateidx = -1;
  911. return 0;
  912. }
  913. mode = local->oper_hw_mode;
  914. for (i = 0; i < mode->num_rates; i++) {
  915. if (mode->rates[i].rate == rate) {
  916. sdata->u.ap.max_ratectrl_rateidx = i;
  917. return 0;
  918. }
  919. }
  920. return -EINVAL;
  921. }
  922. static void ieee80211_key_enable_hwaccel(struct ieee80211_local *local,
  923. struct ieee80211_key *key)
  924. {
  925. struct ieee80211_key_conf *keyconf;
  926. u8 addr[ETH_ALEN];
  927. if (!key || key->alg != ALG_WEP || !key->force_sw_encrypt ||
  928. (local->hw.flags & IEEE80211_HW_DEVICE_HIDES_WEP))
  929. return;
  930. memset(addr, 0xff, ETH_ALEN);
  931. keyconf = ieee80211_key_data2conf(local, key);
  932. if (keyconf && local->ops->set_key &&
  933. local->ops->set_key(local_to_hw(local),
  934. SET_KEY, addr, keyconf, 0) == 0) {
  935. key->force_sw_encrypt =
  936. !!(keyconf->flags & IEEE80211_KEY_FORCE_SW_ENCRYPT);
  937. key->hw_key_idx = keyconf->hw_key_idx;
  938. }
  939. kfree(keyconf);
  940. }
  941. static void ieee80211_key_disable_hwaccel(struct ieee80211_local *local,
  942. struct ieee80211_key *key)
  943. {
  944. struct ieee80211_key_conf *keyconf;
  945. u8 addr[ETH_ALEN];
  946. if (!key || key->alg != ALG_WEP || key->force_sw_encrypt ||
  947. (local->hw.flags & IEEE80211_HW_DEVICE_HIDES_WEP))
  948. return;
  949. memset(addr, 0xff, ETH_ALEN);
  950. keyconf = ieee80211_key_data2conf(local, key);
  951. if (keyconf && local->ops->set_key)
  952. local->ops->set_key(local_to_hw(local), DISABLE_KEY,
  953. addr, keyconf, 0);
  954. kfree(keyconf);
  955. key->force_sw_encrypt = 1;
  956. }
  957. static int ieee80211_ioctl_default_wep_only(struct ieee80211_local *local,
  958. int value)
  959. {
  960. int i;
  961. struct ieee80211_sub_if_data *sdata;
  962. local->default_wep_only = value;
  963. read_lock(&local->sub_if_lock);
  964. list_for_each_entry(sdata, &local->sub_if_list, list)
  965. for (i = 0; i < NUM_DEFAULT_KEYS; i++)
  966. if (value)
  967. ieee80211_key_enable_hwaccel(local,
  968. sdata->keys[i]);
  969. else
  970. ieee80211_key_disable_hwaccel(local,
  971. sdata->keys[i]);
  972. read_unlock(&local->sub_if_lock);
  973. return 0;
  974. }
  975. void ieee80211_update_default_wep_only(struct ieee80211_local *local)
  976. {
  977. int i = 0;
  978. struct ieee80211_sub_if_data *sdata;
  979. read_lock(&local->sub_if_lock);
  980. list_for_each_entry(sdata, &local->sub_if_list, list) {
  981. if (sdata->dev == local->mdev)
  982. continue;
  983. /* If there is an AP interface then depend on userspace to
  984. set default_wep_only correctly. */
  985. if (sdata->type == IEEE80211_IF_TYPE_AP) {
  986. read_unlock(&local->sub_if_lock);
  987. return;
  988. }
  989. i++;
  990. }
  991. read_unlock(&local->sub_if_lock);
  992. if (i <= 1)
  993. ieee80211_ioctl_default_wep_only(local, 1);
  994. else
  995. ieee80211_ioctl_default_wep_only(local, 0);
  996. }
  997. static int ieee80211_ioctl_prism2_param(struct net_device *dev,
  998. struct iw_request_info *info,
  999. void *wrqu, char *extra)
  1000. {
  1001. struct ieee80211_local *local = wdev_priv(dev->ieee80211_ptr);
  1002. struct ieee80211_sub_if_data *sdata;
  1003. int *i = (int *) extra;
  1004. int param = *i;
  1005. int value = *(i + 1);
  1006. int ret = 0;
  1007. if (!capable(CAP_NET_ADMIN))
  1008. return -EPERM;
  1009. sdata = IEEE80211_DEV_TO_SUB_IF(dev);
  1010. switch (param) {
  1011. case PRISM2_PARAM_IEEE_802_1X:
  1012. if (local->ops->set_ieee8021x)
  1013. ret = local->ops->set_ieee8021x(local_to_hw(local),
  1014. value);
  1015. if (ret)
  1016. printk(KERN_DEBUG "%s: failed to set IEEE 802.1X (%d) "
  1017. "for low-level driver\n", dev->name, value);
  1018. else
  1019. sdata->ieee802_1x = value;
  1020. break;
  1021. case PRISM2_PARAM_ANTSEL_TX:
  1022. local->hw.conf.antenna_sel_tx = value;
  1023. if (ieee80211_hw_config(local))
  1024. ret = -EINVAL;
  1025. break;
  1026. case PRISM2_PARAM_ANTSEL_RX:
  1027. local->hw.conf.antenna_sel_rx = value;
  1028. if (ieee80211_hw_config(local))
  1029. ret = -EINVAL;
  1030. break;
  1031. case PRISM2_PARAM_CTS_PROTECT_ERP_FRAMES:
  1032. local->cts_protect_erp_frames = value;
  1033. break;
  1034. case PRISM2_PARAM_DROP_UNENCRYPTED:
  1035. sdata->drop_unencrypted = value;
  1036. break;
  1037. case PRISM2_PARAM_PREAMBLE:
  1038. local->short_preamble = value;
  1039. break;
  1040. case PRISM2_PARAM_STAT_TIME:
  1041. if (!local->stat_time && value) {
  1042. local->stat_timer.expires = jiffies + HZ * value / 100;
  1043. add_timer(&local->stat_timer);
  1044. } else if (local->stat_time && !value) {
  1045. del_timer_sync(&local->stat_timer);
  1046. }
  1047. local->stat_time = value;
  1048. break;
  1049. case PRISM2_PARAM_SHORT_SLOT_TIME:
  1050. if (value)
  1051. local->hw.conf.flags |= IEEE80211_CONF_SHORT_SLOT_TIME;
  1052. else
  1053. local->hw.conf.flags &= ~IEEE80211_CONF_SHORT_SLOT_TIME;
  1054. if (ieee80211_hw_config(local))
  1055. ret = -EINVAL;
  1056. break;
  1057. case PRISM2_PARAM_NEXT_MODE:
  1058. local->next_mode = value;
  1059. break;
  1060. case PRISM2_PARAM_CLEAR_KEYS:
  1061. ret = ieee80211_ioctl_clear_keys(dev);
  1062. break;
  1063. case PRISM2_PARAM_RADIO_ENABLED:
  1064. ret = ieee80211_ioctl_set_radio_enabled(dev, value);
  1065. break;
  1066. case PRISM2_PARAM_ANTENNA_MODE:
  1067. local->hw.conf.antenna_mode = value;
  1068. if (ieee80211_hw_config(local))
  1069. ret = -EINVAL;
  1070. break;
  1071. case PRISM2_PARAM_STA_ANTENNA_SEL:
  1072. local->sta_antenna_sel = value;
  1073. break;
  1074. case PRISM2_PARAM_FORCE_UNICAST_RATE:
  1075. ret = ieee80211_ioctl_force_unicast_rate(dev, sdata, value);
  1076. break;
  1077. case PRISM2_PARAM_MAX_RATECTRL_RATE:
  1078. ret = ieee80211_ioctl_max_ratectrl_rate(dev, sdata, value);
  1079. break;
  1080. case PRISM2_PARAM_RATE_CTRL_NUM_UP:
  1081. local->rate_ctrl_num_up = value;
  1082. break;
  1083. case PRISM2_PARAM_RATE_CTRL_NUM_DOWN:
  1084. local->rate_ctrl_num_down = value;
  1085. break;
  1086. case PRISM2_PARAM_TX_POWER_REDUCTION:
  1087. if (value < 0)
  1088. ret = -EINVAL;
  1089. else
  1090. local->hw.conf.tx_power_reduction = value;
  1091. break;
  1092. case PRISM2_PARAM_KEY_TX_RX_THRESHOLD:
  1093. local->key_tx_rx_threshold = value;
  1094. break;
  1095. case PRISM2_PARAM_DEFAULT_WEP_ONLY:
  1096. ret = ieee80211_ioctl_default_wep_only(local, value);
  1097. break;
  1098. case PRISM2_PARAM_WIFI_WME_NOACK_TEST:
  1099. local->wifi_wme_noack_test = value;
  1100. break;
  1101. case PRISM2_PARAM_SCAN_FLAGS:
  1102. local->scan_flags = value;
  1103. break;
  1104. case PRISM2_PARAM_MIXED_CELL:
  1105. if (sdata->type != IEEE80211_IF_TYPE_STA &&
  1106. sdata->type != IEEE80211_IF_TYPE_IBSS)
  1107. ret = -EINVAL;
  1108. else
  1109. sdata->u.sta.mixed_cell = !!value;
  1110. break;
  1111. case PRISM2_PARAM_HW_MODES:
  1112. local->enabled_modes = value;
  1113. break;
  1114. case PRISM2_PARAM_CREATE_IBSS:
  1115. if (sdata->type != IEEE80211_IF_TYPE_IBSS)
  1116. ret = -EINVAL;
  1117. else
  1118. sdata->u.sta.create_ibss = !!value;
  1119. break;
  1120. case PRISM2_PARAM_WMM_ENABLED:
  1121. if (sdata->type != IEEE80211_IF_TYPE_STA &&
  1122. sdata->type != IEEE80211_IF_TYPE_IBSS)
  1123. ret = -EINVAL;
  1124. else
  1125. sdata->u.sta.wmm_enabled = !!value;
  1126. break;
  1127. case PRISM2_PARAM_RADAR_DETECT:
  1128. local->hw.conf.radar_detect = value;
  1129. break;
  1130. case PRISM2_PARAM_SPECTRUM_MGMT:
  1131. local->hw.conf.spect_mgmt = value;
  1132. break;
  1133. default:
  1134. ret = -EOPNOTSUPP;
  1135. break;
  1136. }
  1137. return ret;
  1138. }
  1139. static int ieee80211_ioctl_get_prism2_param(struct net_device *dev,
  1140. struct iw_request_info *info,
  1141. void *wrqu, char *extra)
  1142. {
  1143. struct ieee80211_local *local = wdev_priv(dev->ieee80211_ptr);
  1144. struct ieee80211_sub_if_data *sdata;
  1145. int *param = (int *) extra;
  1146. int ret = 0;
  1147. sdata = IEEE80211_DEV_TO_SUB_IF(dev);
  1148. switch (*param) {
  1149. case PRISM2_PARAM_IEEE_802_1X:
  1150. *param = sdata->ieee802_1x;
  1151. break;
  1152. case PRISM2_PARAM_ANTSEL_TX:
  1153. *param = local->hw.conf.antenna_sel_tx;
  1154. break;
  1155. case PRISM2_PARAM_ANTSEL_RX:
  1156. *param = local->hw.conf.antenna_sel_rx;
  1157. break;
  1158. case PRISM2_PARAM_CTS_PROTECT_ERP_FRAMES:
  1159. *param = local->cts_protect_erp_frames;
  1160. break;
  1161. case PRISM2_PARAM_DROP_UNENCRYPTED:
  1162. *param = sdata->drop_unencrypted;
  1163. break;
  1164. case PRISM2_PARAM_PREAMBLE:
  1165. *param = local->short_preamble;
  1166. break;
  1167. case PRISM2_PARAM_STAT_TIME:
  1168. *param = local->stat_time;
  1169. break;
  1170. case PRISM2_PARAM_SHORT_SLOT_TIME:
  1171. *param = !!(local->hw.conf.flags & IEEE80211_CONF_SHORT_SLOT_TIME);
  1172. break;
  1173. case PRISM2_PARAM_NEXT_MODE:
  1174. *param = local->next_mode;
  1175. break;
  1176. case PRISM2_PARAM_ANTENNA_MODE:
  1177. *param = local->hw.conf.antenna_mode;
  1178. break;
  1179. case PRISM2_PARAM_STA_ANTENNA_SEL:
  1180. *param = local->sta_antenna_sel;
  1181. break;
  1182. case PRISM2_PARAM_RATE_CTRL_NUM_UP:
  1183. *param = local->rate_ctrl_num_up;
  1184. break;
  1185. case PRISM2_PARAM_RATE_CTRL_NUM_DOWN:
  1186. *param = local->rate_ctrl_num_down;
  1187. break;
  1188. case PRISM2_PARAM_TX_POWER_REDUCTION:
  1189. *param = local->hw.conf.tx_power_reduction;
  1190. break;
  1191. case PRISM2_PARAM_KEY_TX_RX_THRESHOLD:
  1192. *param = local->key_tx_rx_threshold;
  1193. break;
  1194. case PRISM2_PARAM_DEFAULT_WEP_ONLY:
  1195. *param = local->default_wep_only;
  1196. break;
  1197. case PRISM2_PARAM_WIFI_WME_NOACK_TEST:
  1198. *param = local->wifi_wme_noack_test;
  1199. break;
  1200. case PRISM2_PARAM_SCAN_FLAGS:
  1201. *param = local->scan_flags;
  1202. break;
  1203. case PRISM2_PARAM_HW_MODES:
  1204. *param = local->enabled_modes;
  1205. break;
  1206. case PRISM2_PARAM_CREATE_IBSS:
  1207. if (sdata->type != IEEE80211_IF_TYPE_IBSS)
  1208. ret = -EINVAL;
  1209. else
  1210. *param = !!sdata->u.sta.create_ibss;
  1211. break;
  1212. case PRISM2_PARAM_MIXED_CELL:
  1213. if (sdata->type != IEEE80211_IF_TYPE_STA &&
  1214. sdata->type != IEEE80211_IF_TYPE_IBSS)
  1215. ret = -EINVAL;
  1216. else
  1217. *param = !!sdata->u.sta.mixed_cell;
  1218. break;
  1219. case PRISM2_PARAM_WMM_ENABLED:
  1220. if (sdata->type != IEEE80211_IF_TYPE_STA &&
  1221. sdata->type != IEEE80211_IF_TYPE_IBSS)
  1222. ret = -EINVAL;
  1223. else
  1224. *param = !!sdata->u.sta.wmm_enabled;
  1225. break;
  1226. default:
  1227. ret = -EOPNOTSUPP;
  1228. break;
  1229. }
  1230. return ret;
  1231. }
  1232. static int ieee80211_ioctl_siwmlme(struct net_device *dev,
  1233. struct iw_request_info *info,
  1234. struct iw_point *data, char *extra)
  1235. {
  1236. struct ieee80211_sub_if_data *sdata;
  1237. struct iw_mlme *mlme = (struct iw_mlme *) extra;
  1238. sdata = IEEE80211_DEV_TO_SUB_IF(dev);
  1239. if (sdata->type != IEEE80211_IF_TYPE_STA &&
  1240. sdata->type != IEEE80211_IF_TYPE_IBSS)
  1241. return -EINVAL;
  1242. switch (mlme->cmd) {
  1243. case IW_MLME_DEAUTH:
  1244. /* TODO: mlme->addr.sa_data */
  1245. return ieee80211_sta_deauthenticate(dev, mlme->reason_code);
  1246. case IW_MLME_DISASSOC:
  1247. /* TODO: mlme->addr.sa_data */
  1248. return ieee80211_sta_disassociate(dev, mlme->reason_code);
  1249. default:
  1250. return -EOPNOTSUPP;
  1251. }
  1252. }
  1253. static int ieee80211_ioctl_siwencode(struct net_device *dev,
  1254. struct iw_request_info *info,
  1255. struct iw_point *erq, char *keybuf)
  1256. {
  1257. struct ieee80211_sub_if_data *sdata;
  1258. int idx, i, alg = ALG_WEP;
  1259. u8 bcaddr[ETH_ALEN] = { 0xff, 0xff, 0xff, 0xff, 0xff, 0xff };
  1260. sdata = IEEE80211_DEV_TO_SUB_IF(dev);
  1261. idx = erq->flags & IW_ENCODE_INDEX;
  1262. if (idx == 0) {
  1263. if (sdata->default_key)
  1264. for (i = 0; i < NUM_DEFAULT_KEYS; i++) {
  1265. if (sdata->default_key == sdata->keys[i]) {
  1266. idx = i;
  1267. break;
  1268. }
  1269. }
  1270. } else if (idx < 1 || idx > 4)
  1271. return -EINVAL;
  1272. else
  1273. idx--;
  1274. if (erq->flags & IW_ENCODE_DISABLED)
  1275. alg = ALG_NONE;
  1276. else if (erq->length == 0) {
  1277. /* No key data - just set the default TX key index */
  1278. if (sdata->default_key != sdata->keys[idx]) {
  1279. ieee80211_debugfs_key_remove_default(sdata);
  1280. sdata->default_key = sdata->keys[idx];
  1281. if (sdata->default_key)
  1282. ieee80211_debugfs_key_add_default(sdata);
  1283. }
  1284. return 0;
  1285. }
  1286. return ieee80211_set_encryption(
  1287. dev, bcaddr,
  1288. idx, alg,
  1289. !sdata->default_key,
  1290. keybuf, erq->length);
  1291. }
  1292. static int ieee80211_ioctl_giwencode(struct net_device *dev,
  1293. struct iw_request_info *info,
  1294. struct iw_point *erq, char *key)
  1295. {
  1296. struct ieee80211_sub_if_data *sdata;
  1297. int idx, i;
  1298. sdata = IEEE80211_DEV_TO_SUB_IF(dev);
  1299. idx = erq->flags & IW_ENCODE_INDEX;
  1300. if (idx < 1 || idx > 4) {
  1301. idx = -1;
  1302. if (!sdata->default_key)
  1303. idx = 0;
  1304. else for (i = 0; i < NUM_DEFAULT_KEYS; i++) {
  1305. if (sdata->default_key == sdata->keys[i]) {
  1306. idx = i;
  1307. break;
  1308. }
  1309. }
  1310. if (idx < 0)
  1311. return -EINVAL;
  1312. } else
  1313. idx--;
  1314. erq->flags = idx + 1;
  1315. if (!sdata->keys[idx]) {
  1316. erq->length = 0;
  1317. erq->flags |= IW_ENCODE_DISABLED;
  1318. return 0;
  1319. }
  1320. memcpy(key, sdata->keys[idx]->key,
  1321. min((int)erq->length, sdata->keys[idx]->keylen));
  1322. erq->length = sdata->keys[idx]->keylen;
  1323. erq->flags |= IW_ENCODE_ENABLED;
  1324. return 0;
  1325. }
  1326. static int ieee80211_ioctl_siwauth(struct net_device *dev,
  1327. struct iw_request_info *info,
  1328. struct iw_param *data, char *extra)
  1329. {
  1330. struct ieee80211_local *local = wdev_priv(dev->ieee80211_ptr);
  1331. struct ieee80211_sub_if_data *sdata = IEEE80211_DEV_TO_SUB_IF(dev);
  1332. int ret = 0;
  1333. switch (data->flags & IW_AUTH_INDEX) {
  1334. case IW_AUTH_WPA_VERSION:
  1335. case IW_AUTH_CIPHER_PAIRWISE:
  1336. case IW_AUTH_CIPHER_GROUP:
  1337. case IW_AUTH_WPA_ENABLED:
  1338. case IW_AUTH_RX_UNENCRYPTED_EAPOL:
  1339. break;
  1340. case IW_AUTH_KEY_MGMT:
  1341. if (sdata->type != IEEE80211_IF_TYPE_STA)
  1342. ret = -EINVAL;
  1343. else {
  1344. /*
  1345. * TODO: sdata->u.sta.key_mgmt does not match with WE18
  1346. * value completely; could consider modifying this to
  1347. * be closer to WE18. For now, this value is not really
  1348. * used for anything else than Privacy matching, so the
  1349. * current code here should be more or less OK.
  1350. */
  1351. if (data->value & IW_AUTH_KEY_MGMT_802_1X) {
  1352. sdata->u.sta.key_mgmt =
  1353. IEEE80211_KEY_MGMT_WPA_EAP;
  1354. } else if (data->value & IW_AUTH_KEY_MGMT_PSK) {
  1355. sdata->u.sta.key_mgmt =
  1356. IEEE80211_KEY_MGMT_WPA_PSK;
  1357. } else {
  1358. sdata->u.sta.key_mgmt =
  1359. IEEE80211_KEY_MGMT_NONE;
  1360. }
  1361. }
  1362. break;
  1363. case IW_AUTH_80211_AUTH_ALG:
  1364. if (sdata->type == IEEE80211_IF_TYPE_STA ||
  1365. sdata->type == IEEE80211_IF_TYPE_IBSS)
  1366. sdata->u.sta.auth_algs = data->value;
  1367. else
  1368. ret = -EOPNOTSUPP;
  1369. break;
  1370. case IW_AUTH_PRIVACY_INVOKED:
  1371. if (local->ops->set_privacy_invoked)
  1372. ret = local->ops->set_privacy_invoked(
  1373. local_to_hw(local), data->value);
  1374. break;
  1375. default:
  1376. ret = -EOPNOTSUPP;
  1377. break;
  1378. }
  1379. return ret;
  1380. }
  1381. /* Get wireless statistics. Called by /proc/net/wireless and by SIOCGIWSTATS */
  1382. static struct iw_statistics *ieee80211_get_wireless_stats(struct net_device *dev)
  1383. {
  1384. struct ieee80211_local *local = wdev_priv(dev->ieee80211_ptr);
  1385. struct iw_statistics *wstats = &local->wstats;
  1386. struct ieee80211_sub_if_data *sdata = IEEE80211_DEV_TO_SUB_IF(dev);
  1387. struct sta_info *sta = NULL;
  1388. if (sdata->type == IEEE80211_IF_TYPE_STA ||
  1389. sdata->type == IEEE80211_IF_TYPE_IBSS)
  1390. sta = sta_info_get(local, sdata->u.sta.bssid);
  1391. if (!sta) {
  1392. wstats->discard.fragment = 0;
  1393. wstats->discard.misc = 0;
  1394. wstats->qual.qual = 0;
  1395. wstats->qual.level = 0;
  1396. wstats->qual.noise = 0;
  1397. wstats->qual.updated = IW_QUAL_ALL_INVALID;
  1398. } else {
  1399. wstats->qual.level = sta->last_rssi;
  1400. wstats->qual.qual = sta->last_signal;
  1401. wstats->qual.noise = sta->last_noise;
  1402. wstats->qual.updated = local->wstats_flags;
  1403. sta_info_put(sta);
  1404. }
  1405. return wstats;
  1406. }
  1407. static int ieee80211_ioctl_giwauth(struct net_device *dev,
  1408. struct iw_request_info *info,
  1409. struct iw_param *data, char *extra)
  1410. {
  1411. struct ieee80211_sub_if_data *sdata = IEEE80211_DEV_TO_SUB_IF(dev);
  1412. int ret = 0;
  1413. switch (data->flags & IW_AUTH_INDEX) {
  1414. case IW_AUTH_80211_AUTH_ALG:
  1415. if (sdata->type == IEEE80211_IF_TYPE_STA ||
  1416. sdata->type == IEEE80211_IF_TYPE_IBSS)
  1417. data->value = sdata->u.sta.auth_algs;
  1418. else
  1419. ret = -EOPNOTSUPP;
  1420. break;
  1421. default:
  1422. ret = -EOPNOTSUPP;
  1423. break;
  1424. }
  1425. return ret;
  1426. }
  1427. static int ieee80211_ioctl_siwencodeext(struct net_device *dev,
  1428. struct iw_request_info *info,
  1429. struct iw_point *erq, char *extra)
  1430. {
  1431. struct ieee80211_sub_if_data *sdata = IEEE80211_DEV_TO_SUB_IF(dev);
  1432. struct iw_encode_ext *ext = (struct iw_encode_ext *) extra;
  1433. int alg, idx, i;
  1434. switch (ext->alg) {
  1435. case IW_ENCODE_ALG_NONE:
  1436. alg = ALG_NONE;
  1437. break;
  1438. case IW_ENCODE_ALG_WEP:
  1439. alg = ALG_WEP;
  1440. break;
  1441. case IW_ENCODE_ALG_TKIP:
  1442. alg = ALG_TKIP;
  1443. break;
  1444. case IW_ENCODE_ALG_CCMP:
  1445. alg = ALG_CCMP;
  1446. break;
  1447. default:
  1448. return -EOPNOTSUPP;
  1449. }
  1450. if (erq->flags & IW_ENCODE_DISABLED)
  1451. alg = ALG_NONE;
  1452. idx = erq->flags & IW_ENCODE_INDEX;
  1453. if (idx < 1 || idx > 4) {
  1454. idx = -1;
  1455. if (!sdata->default_key)
  1456. idx = 0;
  1457. else for (i = 0; i < NUM_DEFAULT_KEYS; i++) {
  1458. if (sdata->default_key == sdata->keys[i]) {
  1459. idx = i;
  1460. break;
  1461. }
  1462. }
  1463. if (idx < 0)
  1464. return -EINVAL;
  1465. } else
  1466. idx--;
  1467. return ieee80211_set_encryption(dev, ext->addr.sa_data, idx, alg,
  1468. ext->ext_flags &
  1469. IW_ENCODE_EXT_SET_TX_KEY,
  1470. ext->key, ext->key_len);
  1471. }
  1472. static const struct iw_priv_args ieee80211_ioctl_priv[] = {
  1473. { PRISM2_IOCTL_PRISM2_PARAM,
  1474. IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 2, 0, "param" },
  1475. { PRISM2_IOCTL_GET_PRISM2_PARAM,
  1476. IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1,
  1477. IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1, "get_param" },
  1478. };
  1479. /* Structures to export the Wireless Handlers */
  1480. static const iw_handler ieee80211_handler[] =
  1481. {
  1482. (iw_handler) NULL, /* SIOCSIWCOMMIT */
  1483. (iw_handler) ieee80211_ioctl_giwname, /* SIOCGIWNAME */
  1484. (iw_handler) NULL, /* SIOCSIWNWID */
  1485. (iw_handler) NULL, /* SIOCGIWNWID */
  1486. (iw_handler) ieee80211_ioctl_siwfreq, /* SIOCSIWFREQ */
  1487. (iw_handler) ieee80211_ioctl_giwfreq, /* SIOCGIWFREQ */
  1488. (iw_handler) ieee80211_ioctl_siwmode, /* SIOCSIWMODE */
  1489. (iw_handler) ieee80211_ioctl_giwmode, /* SIOCGIWMODE */
  1490. (iw_handler) NULL, /* SIOCSIWSENS */
  1491. (iw_handler) NULL, /* SIOCGIWSENS */
  1492. (iw_handler) NULL /* not used */, /* SIOCSIWRANGE */
  1493. (iw_handler) ieee80211_ioctl_giwrange, /* SIOCGIWRANGE */
  1494. (iw_handler) NULL /* not used */, /* SIOCSIWPRIV */
  1495. (iw_handler) NULL /* kernel code */, /* SIOCGIWPRIV */
  1496. (iw_handler) NULL /* not used */, /* SIOCSIWSTATS */
  1497. (iw_handler) NULL /* kernel code */, /* SIOCGIWSTATS */
  1498. iw_handler_set_spy, /* SIOCSIWSPY */
  1499. iw_handler_get_spy, /* SIOCGIWSPY */
  1500. iw_handler_set_thrspy, /* SIOCSIWTHRSPY */
  1501. iw_handler_get_thrspy, /* SIOCGIWTHRSPY */
  1502. (iw_handler) ieee80211_ioctl_siwap, /* SIOCSIWAP */
  1503. (iw_handler) ieee80211_ioctl_giwap, /* SIOCGIWAP */
  1504. (iw_handler) ieee80211_ioctl_siwmlme, /* SIOCSIWMLME */
  1505. (iw_handler) NULL, /* SIOCGIWAPLIST */
  1506. (iw_handler) ieee80211_ioctl_siwscan, /* SIOCSIWSCAN */
  1507. (iw_handler) ieee80211_ioctl_giwscan, /* SIOCGIWSCAN */
  1508. (iw_handler) ieee80211_ioctl_siwessid, /* SIOCSIWESSID */
  1509. (iw_handler) ieee80211_ioctl_giwessid, /* SIOCGIWESSID */
  1510. (iw_handler) NULL, /* SIOCSIWNICKN */
  1511. (iw_handler) NULL, /* SIOCGIWNICKN */
  1512. (iw_handler) NULL, /* -- hole -- */
  1513. (iw_handler) NULL, /* -- hole -- */
  1514. (iw_handler) NULL, /* SIOCSIWRATE */
  1515. (iw_handler) NULL, /* SIOCGIWRATE */
  1516. (iw_handler) ieee80211_ioctl_siwrts, /* SIOCSIWRTS */
  1517. (iw_handler) ieee80211_ioctl_giwrts, /* SIOCGIWRTS */
  1518. (iw_handler) ieee80211_ioctl_siwfrag, /* SIOCSIWFRAG */
  1519. (iw_handler) ieee80211_ioctl_giwfrag, /* SIOCGIWFRAG */
  1520. (iw_handler) NULL, /* SIOCSIWTXPOW */
  1521. (iw_handler) NULL, /* SIOCGIWTXPOW */
  1522. (iw_handler) ieee80211_ioctl_siwretry, /* SIOCSIWRETRY */
  1523. (iw_handler) ieee80211_ioctl_giwretry, /* SIOCGIWRETRY */
  1524. (iw_handler) ieee80211_ioctl_siwencode, /* SIOCSIWENCODE */
  1525. (iw_handler) ieee80211_ioctl_giwencode, /* SIOCGIWENCODE */
  1526. (iw_handler) NULL, /* SIOCSIWPOWER */
  1527. (iw_handler) NULL, /* SIOCGIWPOWER */
  1528. (iw_handler) NULL, /* -- hole -- */
  1529. (iw_handler) NULL, /* -- hole -- */
  1530. (iw_handler) ieee80211_ioctl_siwgenie, /* SIOCSIWGENIE */
  1531. (iw_handler) NULL, /* SIOCGIWGENIE */
  1532. (iw_handler) ieee80211_ioctl_siwauth, /* SIOCSIWAUTH */
  1533. (iw_handler) ieee80211_ioctl_giwauth, /* SIOCGIWAUTH */
  1534. (iw_handler) ieee80211_ioctl_siwencodeext, /* SIOCSIWENCODEEXT */
  1535. (iw_handler) NULL, /* SIOCGIWENCODEEXT */
  1536. (iw_handler) NULL, /* SIOCSIWPMKSA */
  1537. (iw_handler) NULL, /* -- hole -- */
  1538. };
  1539. static const iw_handler ieee80211_private_handler[] =
  1540. { /* SIOCIWFIRSTPRIV + */
  1541. (iw_handler) ieee80211_ioctl_prism2_param, /* 0 */
  1542. (iw_handler) ieee80211_ioctl_get_prism2_param, /* 1 */
  1543. };
  1544. const struct iw_handler_def ieee80211_iw_handler_def =
  1545. {
  1546. .num_standard = ARRAY_SIZE(ieee80211_handler),
  1547. .num_private = ARRAY_SIZE(ieee80211_private_handler),
  1548. .num_private_args = ARRAY_SIZE(ieee80211_ioctl_priv),
  1549. .standard = (iw_handler *) ieee80211_handler,
  1550. .private = (iw_handler *) ieee80211_private_handler,
  1551. .private_args = (struct iw_priv_args *) ieee80211_ioctl_priv,
  1552. .get_wireless_stats = ieee80211_get_wireless_stats,
  1553. };