/drivers/net/wireless/hostap/hostap_ioctl.c

http://github.com/mirrors/linux · C · 4054 lines · 3235 code · 637 blank · 182 comment · 686 complexity · 24c14f8b79eb0d5f2851e0964efeb5a2 MD5 · raw file

Large files are truncated click here to view the full file

  1. /* ioctl() (mostly Linux Wireless Extensions) routines for Host AP driver */
  2. #include <linux/slab.h>
  3. #include <linux/types.h>
  4. #include <linux/sched.h>
  5. #include <linux/ethtool.h>
  6. #include <linux/if_arp.h>
  7. #include <linux/module.h>
  8. #include <linux/etherdevice.h>
  9. #include <net/lib80211.h>
  10. #include "hostap_wlan.h"
  11. #include "hostap.h"
  12. #include "hostap_ap.h"
  13. static struct iw_statistics *hostap_get_wireless_stats(struct net_device *dev)
  14. {
  15. struct hostap_interface *iface;
  16. local_info_t *local;
  17. struct iw_statistics *wstats;
  18. iface = netdev_priv(dev);
  19. local = iface->local;
  20. /* Why are we doing that ? Jean II */
  21. if (iface->type != HOSTAP_INTERFACE_MAIN)
  22. return NULL;
  23. wstats = &local->wstats;
  24. wstats->status = 0;
  25. wstats->discard.code =
  26. local->comm_tallies.rx_discards_wep_undecryptable;
  27. wstats->discard.misc =
  28. local->comm_tallies.rx_fcs_errors +
  29. local->comm_tallies.rx_discards_no_buffer +
  30. local->comm_tallies.tx_discards_wrong_sa;
  31. wstats->discard.retries =
  32. local->comm_tallies.tx_retry_limit_exceeded;
  33. wstats->discard.fragment =
  34. local->comm_tallies.rx_message_in_bad_msg_fragments;
  35. if (local->iw_mode != IW_MODE_MASTER &&
  36. local->iw_mode != IW_MODE_REPEAT) {
  37. int update = 1;
  38. #ifdef in_atomic
  39. /* RID reading might sleep and it must not be called in
  40. * interrupt context or while atomic. However, this
  41. * function seems to be called while atomic (at least in Linux
  42. * 2.5.59). Update signal quality values only if in suitable
  43. * context. Otherwise, previous values read from tick timer
  44. * will be used. */
  45. if (in_atomic())
  46. update = 0;
  47. #endif /* in_atomic */
  48. if (update && prism2_update_comms_qual(dev) == 0)
  49. wstats->qual.updated = IW_QUAL_ALL_UPDATED |
  50. IW_QUAL_DBM;
  51. wstats->qual.qual = local->comms_qual;
  52. wstats->qual.level = local->avg_signal;
  53. wstats->qual.noise = local->avg_noise;
  54. } else {
  55. wstats->qual.qual = 0;
  56. wstats->qual.level = 0;
  57. wstats->qual.noise = 0;
  58. wstats->qual.updated = IW_QUAL_ALL_INVALID;
  59. }
  60. return wstats;
  61. }
  62. static int prism2_get_datarates(struct net_device *dev, u8 *rates)
  63. {
  64. struct hostap_interface *iface;
  65. local_info_t *local;
  66. u8 buf[12];
  67. int len;
  68. u16 val;
  69. iface = netdev_priv(dev);
  70. local = iface->local;
  71. len = local->func->get_rid(dev, HFA384X_RID_SUPPORTEDDATARATES, buf,
  72. sizeof(buf), 0);
  73. if (len < 2)
  74. return 0;
  75. val = le16_to_cpu(*(__le16 *) buf); /* string length */
  76. if (len - 2 < val || val > 10)
  77. return 0;
  78. memcpy(rates, buf + 2, val);
  79. return val;
  80. }
  81. static int prism2_get_name(struct net_device *dev,
  82. struct iw_request_info *info,
  83. char *name, char *extra)
  84. {
  85. u8 rates[10];
  86. int len, i, over2 = 0;
  87. len = prism2_get_datarates(dev, rates);
  88. for (i = 0; i < len; i++) {
  89. if (rates[i] == 0x0b || rates[i] == 0x16) {
  90. over2 = 1;
  91. break;
  92. }
  93. }
  94. strcpy(name, over2 ? "IEEE 802.11b" : "IEEE 802.11-DS");
  95. return 0;
  96. }
  97. static int prism2_ioctl_siwencode(struct net_device *dev,
  98. struct iw_request_info *info,
  99. struct iw_point *erq, char *keybuf)
  100. {
  101. struct hostap_interface *iface;
  102. local_info_t *local;
  103. int i;
  104. struct lib80211_crypt_data **crypt;
  105. iface = netdev_priv(dev);
  106. local = iface->local;
  107. i = erq->flags & IW_ENCODE_INDEX;
  108. if (i < 1 || i > 4)
  109. i = local->crypt_info.tx_keyidx;
  110. else
  111. i--;
  112. if (i < 0 || i >= WEP_KEYS)
  113. return -EINVAL;
  114. crypt = &local->crypt_info.crypt[i];
  115. if (erq->flags & IW_ENCODE_DISABLED) {
  116. if (*crypt)
  117. lib80211_crypt_delayed_deinit(&local->crypt_info, crypt);
  118. goto done;
  119. }
  120. if (*crypt != NULL && (*crypt)->ops != NULL &&
  121. strcmp((*crypt)->ops->name, "WEP") != 0) {
  122. /* changing to use WEP; deinit previously used algorithm */
  123. lib80211_crypt_delayed_deinit(&local->crypt_info, crypt);
  124. }
  125. if (*crypt == NULL) {
  126. struct lib80211_crypt_data *new_crypt;
  127. /* take WEP into use */
  128. new_crypt = kzalloc(sizeof(struct lib80211_crypt_data),
  129. GFP_KERNEL);
  130. if (new_crypt == NULL)
  131. return -ENOMEM;
  132. new_crypt->ops = lib80211_get_crypto_ops("WEP");
  133. if (!new_crypt->ops) {
  134. request_module("lib80211_crypt_wep");
  135. new_crypt->ops = lib80211_get_crypto_ops("WEP");
  136. }
  137. if (new_crypt->ops && try_module_get(new_crypt->ops->owner))
  138. new_crypt->priv = new_crypt->ops->init(i);
  139. if (!new_crypt->ops || !new_crypt->priv) {
  140. kfree(new_crypt);
  141. new_crypt = NULL;
  142. printk(KERN_WARNING "%s: could not initialize WEP: "
  143. "load module hostap_crypt_wep.o\n",
  144. dev->name);
  145. return -EOPNOTSUPP;
  146. }
  147. *crypt = new_crypt;
  148. }
  149. if (erq->length > 0) {
  150. int len = erq->length <= 5 ? 5 : 13;
  151. int first = 1, j;
  152. if (len > erq->length)
  153. memset(keybuf + erq->length, 0, len - erq->length);
  154. (*crypt)->ops->set_key(keybuf, len, NULL, (*crypt)->priv);
  155. for (j = 0; j < WEP_KEYS; j++) {
  156. if (j != i && local->crypt_info.crypt[j]) {
  157. first = 0;
  158. break;
  159. }
  160. }
  161. if (first)
  162. local->crypt_info.tx_keyidx = i;
  163. } else {
  164. /* No key data - just set the default TX key index */
  165. local->crypt_info.tx_keyidx = i;
  166. }
  167. done:
  168. local->open_wep = erq->flags & IW_ENCODE_OPEN;
  169. if (hostap_set_encryption(local)) {
  170. printk(KERN_DEBUG "%s: set_encryption failed\n", dev->name);
  171. return -EINVAL;
  172. }
  173. /* Do not reset port0 if card is in Managed mode since resetting will
  174. * generate new IEEE 802.11 authentication which may end up in looping
  175. * with IEEE 802.1X. Prism2 documentation seem to require port reset
  176. * after WEP configuration. However, keys are apparently changed at
  177. * least in Managed mode. */
  178. if (local->iw_mode != IW_MODE_INFRA && local->func->reset_port(dev)) {
  179. printk(KERN_DEBUG "%s: reset_port failed\n", dev->name);
  180. return -EINVAL;
  181. }
  182. return 0;
  183. }
  184. static int prism2_ioctl_giwencode(struct net_device *dev,
  185. struct iw_request_info *info,
  186. struct iw_point *erq, char *key)
  187. {
  188. struct hostap_interface *iface;
  189. local_info_t *local;
  190. int i, len;
  191. u16 val;
  192. struct lib80211_crypt_data *crypt;
  193. iface = netdev_priv(dev);
  194. local = iface->local;
  195. i = erq->flags & IW_ENCODE_INDEX;
  196. if (i < 1 || i > 4)
  197. i = local->crypt_info.tx_keyidx;
  198. else
  199. i--;
  200. if (i < 0 || i >= WEP_KEYS)
  201. return -EINVAL;
  202. crypt = local->crypt_info.crypt[i];
  203. erq->flags = i + 1;
  204. if (crypt == NULL || crypt->ops == NULL) {
  205. erq->length = 0;
  206. erq->flags |= IW_ENCODE_DISABLED;
  207. return 0;
  208. }
  209. if (strcmp(crypt->ops->name, "WEP") != 0) {
  210. /* only WEP is supported with wireless extensions, so just
  211. * report that encryption is used */
  212. erq->length = 0;
  213. erq->flags |= IW_ENCODE_ENABLED;
  214. return 0;
  215. }
  216. /* Reads from HFA384X_RID_CNFDEFAULTKEY* return bogus values, so show
  217. * the keys from driver buffer */
  218. len = crypt->ops->get_key(key, WEP_KEY_LEN, NULL, crypt->priv);
  219. erq->length = (len >= 0 ? len : 0);
  220. if (local->func->get_rid(dev, HFA384X_RID_CNFWEPFLAGS, &val, 2, 1) < 0)
  221. {
  222. printk("CNFWEPFLAGS reading failed\n");
  223. return -EOPNOTSUPP;
  224. }
  225. le16_to_cpus(&val);
  226. if (val & HFA384X_WEPFLAGS_PRIVACYINVOKED)
  227. erq->flags |= IW_ENCODE_ENABLED;
  228. else
  229. erq->flags |= IW_ENCODE_DISABLED;
  230. if (val & HFA384X_WEPFLAGS_EXCLUDEUNENCRYPTED)
  231. erq->flags |= IW_ENCODE_RESTRICTED;
  232. else
  233. erq->flags |= IW_ENCODE_OPEN;
  234. return 0;
  235. }
  236. static int hostap_set_rate(struct net_device *dev)
  237. {
  238. struct hostap_interface *iface;
  239. local_info_t *local;
  240. int ret, basic_rates;
  241. iface = netdev_priv(dev);
  242. local = iface->local;
  243. basic_rates = local->basic_rates & local->tx_rate_control;
  244. if (!basic_rates || basic_rates != local->basic_rates) {
  245. printk(KERN_INFO "%s: updating basic rate set automatically "
  246. "to match with the new supported rate set\n",
  247. dev->name);
  248. if (!basic_rates)
  249. basic_rates = local->tx_rate_control;
  250. local->basic_rates = basic_rates;
  251. if (hostap_set_word(dev, HFA384X_RID_CNFBASICRATES,
  252. basic_rates))
  253. printk(KERN_WARNING "%s: failed to set "
  254. "cnfBasicRates\n", dev->name);
  255. }
  256. ret = (hostap_set_word(dev, HFA384X_RID_TXRATECONTROL,
  257. local->tx_rate_control) ||
  258. hostap_set_word(dev, HFA384X_RID_CNFSUPPORTEDRATES,
  259. local->tx_rate_control) ||
  260. local->func->reset_port(dev));
  261. if (ret) {
  262. printk(KERN_WARNING "%s: TXRateControl/cnfSupportedRates "
  263. "setting to 0x%x failed\n",
  264. dev->name, local->tx_rate_control);
  265. }
  266. /* Update TX rate configuration for all STAs based on new operational
  267. * rate set. */
  268. hostap_update_rates(local);
  269. return ret;
  270. }
  271. static int prism2_ioctl_siwrate(struct net_device *dev,
  272. struct iw_request_info *info,
  273. struct iw_param *rrq, char *extra)
  274. {
  275. struct hostap_interface *iface;
  276. local_info_t *local;
  277. iface = netdev_priv(dev);
  278. local = iface->local;
  279. if (rrq->fixed) {
  280. switch (rrq->value) {
  281. case 11000000:
  282. local->tx_rate_control = HFA384X_RATES_11MBPS;
  283. break;
  284. case 5500000:
  285. local->tx_rate_control = HFA384X_RATES_5MBPS;
  286. break;
  287. case 2000000:
  288. local->tx_rate_control = HFA384X_RATES_2MBPS;
  289. break;
  290. case 1000000:
  291. local->tx_rate_control = HFA384X_RATES_1MBPS;
  292. break;
  293. default:
  294. local->tx_rate_control = HFA384X_RATES_1MBPS |
  295. HFA384X_RATES_2MBPS | HFA384X_RATES_5MBPS |
  296. HFA384X_RATES_11MBPS;
  297. break;
  298. }
  299. } else {
  300. switch (rrq->value) {
  301. case 11000000:
  302. local->tx_rate_control = HFA384X_RATES_1MBPS |
  303. HFA384X_RATES_2MBPS | HFA384X_RATES_5MBPS |
  304. HFA384X_RATES_11MBPS;
  305. break;
  306. case 5500000:
  307. local->tx_rate_control = HFA384X_RATES_1MBPS |
  308. HFA384X_RATES_2MBPS | HFA384X_RATES_5MBPS;
  309. break;
  310. case 2000000:
  311. local->tx_rate_control = HFA384X_RATES_1MBPS |
  312. HFA384X_RATES_2MBPS;
  313. break;
  314. case 1000000:
  315. local->tx_rate_control = HFA384X_RATES_1MBPS;
  316. break;
  317. default:
  318. local->tx_rate_control = HFA384X_RATES_1MBPS |
  319. HFA384X_RATES_2MBPS | HFA384X_RATES_5MBPS |
  320. HFA384X_RATES_11MBPS;
  321. break;
  322. }
  323. }
  324. return hostap_set_rate(dev);
  325. }
  326. static int prism2_ioctl_giwrate(struct net_device *dev,
  327. struct iw_request_info *info,
  328. struct iw_param *rrq, char *extra)
  329. {
  330. u16 val;
  331. struct hostap_interface *iface;
  332. local_info_t *local;
  333. int ret = 0;
  334. iface = netdev_priv(dev);
  335. local = iface->local;
  336. if (local->func->get_rid(dev, HFA384X_RID_TXRATECONTROL, &val, 2, 1) <
  337. 0)
  338. return -EINVAL;
  339. if ((val & 0x1) && (val > 1))
  340. rrq->fixed = 0;
  341. else
  342. rrq->fixed = 1;
  343. if (local->iw_mode == IW_MODE_MASTER && local->ap != NULL &&
  344. !local->fw_tx_rate_control) {
  345. /* HFA384X_RID_CURRENTTXRATE seems to always be 2 Mbps in
  346. * Host AP mode, so use the recorded TX rate of the last sent
  347. * frame */
  348. rrq->value = local->ap->last_tx_rate > 0 ?
  349. local->ap->last_tx_rate * 100000 : 11000000;
  350. return 0;
  351. }
  352. if (local->func->get_rid(dev, HFA384X_RID_CURRENTTXRATE, &val, 2, 1) <
  353. 0)
  354. return -EINVAL;
  355. switch (val) {
  356. case HFA384X_RATES_1MBPS:
  357. rrq->value = 1000000;
  358. break;
  359. case HFA384X_RATES_2MBPS:
  360. rrq->value = 2000000;
  361. break;
  362. case HFA384X_RATES_5MBPS:
  363. rrq->value = 5500000;
  364. break;
  365. case HFA384X_RATES_11MBPS:
  366. rrq->value = 11000000;
  367. break;
  368. default:
  369. /* should not happen */
  370. rrq->value = 11000000;
  371. ret = -EINVAL;
  372. break;
  373. }
  374. return ret;
  375. }
  376. static int prism2_ioctl_siwsens(struct net_device *dev,
  377. struct iw_request_info *info,
  378. struct iw_param *sens, char *extra)
  379. {
  380. struct hostap_interface *iface;
  381. local_info_t *local;
  382. iface = netdev_priv(dev);
  383. local = iface->local;
  384. /* Set the desired AP density */
  385. if (sens->value < 1 || sens->value > 3)
  386. return -EINVAL;
  387. if (hostap_set_word(dev, HFA384X_RID_CNFSYSTEMSCALE, sens->value) ||
  388. local->func->reset_port(dev))
  389. return -EINVAL;
  390. return 0;
  391. }
  392. static int prism2_ioctl_giwsens(struct net_device *dev,
  393. struct iw_request_info *info,
  394. struct iw_param *sens, char *extra)
  395. {
  396. struct hostap_interface *iface;
  397. local_info_t *local;
  398. __le16 val;
  399. iface = netdev_priv(dev);
  400. local = iface->local;
  401. /* Get the current AP density */
  402. if (local->func->get_rid(dev, HFA384X_RID_CNFSYSTEMSCALE, &val, 2, 1) <
  403. 0)
  404. return -EINVAL;
  405. sens->value = le16_to_cpu(val);
  406. sens->fixed = 1;
  407. return 0;
  408. }
  409. /* Deprecated in new wireless extension API */
  410. static int prism2_ioctl_giwaplist(struct net_device *dev,
  411. struct iw_request_info *info,
  412. struct iw_point *data, char *extra)
  413. {
  414. struct hostap_interface *iface;
  415. local_info_t *local;
  416. struct sockaddr *addr;
  417. struct iw_quality *qual;
  418. iface = netdev_priv(dev);
  419. local = iface->local;
  420. if (local->iw_mode != IW_MODE_MASTER) {
  421. printk(KERN_DEBUG "SIOCGIWAPLIST is currently only supported "
  422. "in Host AP mode\n");
  423. data->length = 0;
  424. return -EOPNOTSUPP;
  425. }
  426. addr = kmalloc(sizeof(struct sockaddr) * IW_MAX_AP, GFP_KERNEL);
  427. qual = kmalloc(sizeof(struct iw_quality) * IW_MAX_AP, GFP_KERNEL);
  428. if (addr == NULL || qual == NULL) {
  429. kfree(addr);
  430. kfree(qual);
  431. data->length = 0;
  432. return -ENOMEM;
  433. }
  434. data->length = prism2_ap_get_sta_qual(local, addr, qual, IW_MAX_AP, 1);
  435. memcpy(extra, addr, sizeof(struct sockaddr) * data->length);
  436. data->flags = 1; /* has quality information */
  437. memcpy(extra + sizeof(struct sockaddr) * data->length, qual,
  438. sizeof(struct iw_quality) * data->length);
  439. kfree(addr);
  440. kfree(qual);
  441. return 0;
  442. }
  443. static int prism2_ioctl_siwrts(struct net_device *dev,
  444. struct iw_request_info *info,
  445. struct iw_param *rts, char *extra)
  446. {
  447. struct hostap_interface *iface;
  448. local_info_t *local;
  449. __le16 val;
  450. iface = netdev_priv(dev);
  451. local = iface->local;
  452. if (rts->disabled)
  453. val = cpu_to_le16(2347);
  454. else if (rts->value < 0 || rts->value > 2347)
  455. return -EINVAL;
  456. else
  457. val = cpu_to_le16(rts->value);
  458. if (local->func->set_rid(dev, HFA384X_RID_RTSTHRESHOLD, &val, 2) ||
  459. local->func->reset_port(dev))
  460. return -EINVAL;
  461. local->rts_threshold = rts->value;
  462. return 0;
  463. }
  464. static int prism2_ioctl_giwrts(struct net_device *dev,
  465. struct iw_request_info *info,
  466. struct iw_param *rts, char *extra)
  467. {
  468. struct hostap_interface *iface;
  469. local_info_t *local;
  470. __le16 val;
  471. iface = netdev_priv(dev);
  472. local = iface->local;
  473. if (local->func->get_rid(dev, HFA384X_RID_RTSTHRESHOLD, &val, 2, 1) <
  474. 0)
  475. return -EINVAL;
  476. rts->value = le16_to_cpu(val);
  477. rts->disabled = (rts->value == 2347);
  478. rts->fixed = 1;
  479. return 0;
  480. }
  481. static int prism2_ioctl_siwfrag(struct net_device *dev,
  482. struct iw_request_info *info,
  483. struct iw_param *rts, char *extra)
  484. {
  485. struct hostap_interface *iface;
  486. local_info_t *local;
  487. __le16 val;
  488. iface = netdev_priv(dev);
  489. local = iface->local;
  490. if (rts->disabled)
  491. val = cpu_to_le16(2346);
  492. else if (rts->value < 256 || rts->value > 2346)
  493. return -EINVAL;
  494. else
  495. val = cpu_to_le16(rts->value & ~0x1); /* even numbers only */
  496. local->fragm_threshold = rts->value & ~0x1;
  497. if (local->func->set_rid(dev, HFA384X_RID_FRAGMENTATIONTHRESHOLD, &val,
  498. 2)
  499. || local->func->reset_port(dev))
  500. return -EINVAL;
  501. return 0;
  502. }
  503. static int prism2_ioctl_giwfrag(struct net_device *dev,
  504. struct iw_request_info *info,
  505. struct iw_param *rts, char *extra)
  506. {
  507. struct hostap_interface *iface;
  508. local_info_t *local;
  509. __le16 val;
  510. iface = netdev_priv(dev);
  511. local = iface->local;
  512. if (local->func->get_rid(dev, HFA384X_RID_FRAGMENTATIONTHRESHOLD,
  513. &val, 2, 1) < 0)
  514. return -EINVAL;
  515. rts->value = le16_to_cpu(val);
  516. rts->disabled = (rts->value == 2346);
  517. rts->fixed = 1;
  518. return 0;
  519. }
  520. #ifndef PRISM2_NO_STATION_MODES
  521. static int hostap_join_ap(struct net_device *dev)
  522. {
  523. struct hostap_interface *iface;
  524. local_info_t *local;
  525. struct hfa384x_join_request req;
  526. unsigned long flags;
  527. int i;
  528. struct hfa384x_hostscan_result *entry;
  529. iface = netdev_priv(dev);
  530. local = iface->local;
  531. memcpy(req.bssid, local->preferred_ap, ETH_ALEN);
  532. req.channel = 0;
  533. spin_lock_irqsave(&local->lock, flags);
  534. for (i = 0; i < local->last_scan_results_count; i++) {
  535. if (!local->last_scan_results)
  536. break;
  537. entry = &local->last_scan_results[i];
  538. if (memcmp(local->preferred_ap, entry->bssid, ETH_ALEN) == 0) {
  539. req.channel = entry->chid;
  540. break;
  541. }
  542. }
  543. spin_unlock_irqrestore(&local->lock, flags);
  544. if (local->func->set_rid(dev, HFA384X_RID_JOINREQUEST, &req,
  545. sizeof(req))) {
  546. printk(KERN_DEBUG "%s: JoinRequest %pM failed\n",
  547. dev->name, local->preferred_ap);
  548. return -1;
  549. }
  550. printk(KERN_DEBUG "%s: Trying to join BSSID %pM\n",
  551. dev->name, local->preferred_ap);
  552. return 0;
  553. }
  554. #endif /* PRISM2_NO_STATION_MODES */
  555. static int prism2_ioctl_siwap(struct net_device *dev,
  556. struct iw_request_info *info,
  557. struct sockaddr *ap_addr, char *extra)
  558. {
  559. #ifdef PRISM2_NO_STATION_MODES
  560. return -EOPNOTSUPP;
  561. #else /* PRISM2_NO_STATION_MODES */
  562. struct hostap_interface *iface;
  563. local_info_t *local;
  564. iface = netdev_priv(dev);
  565. local = iface->local;
  566. memcpy(local->preferred_ap, &ap_addr->sa_data, ETH_ALEN);
  567. if (local->host_roaming == 1 && local->iw_mode == IW_MODE_INFRA) {
  568. struct hfa384x_scan_request scan_req;
  569. memset(&scan_req, 0, sizeof(scan_req));
  570. scan_req.channel_list = cpu_to_le16(0x3fff);
  571. scan_req.txrate = cpu_to_le16(HFA384X_RATES_1MBPS);
  572. if (local->func->set_rid(dev, HFA384X_RID_SCANREQUEST,
  573. &scan_req, sizeof(scan_req))) {
  574. printk(KERN_DEBUG "%s: ScanResults request failed - "
  575. "preferred AP delayed to next unsolicited "
  576. "scan\n", dev->name);
  577. }
  578. } else if (local->host_roaming == 2 &&
  579. local->iw_mode == IW_MODE_INFRA) {
  580. if (hostap_join_ap(dev))
  581. return -EINVAL;
  582. } else {
  583. printk(KERN_DEBUG "%s: Preferred AP (SIOCSIWAP) is used only "
  584. "in Managed mode when host_roaming is enabled\n",
  585. dev->name);
  586. }
  587. return 0;
  588. #endif /* PRISM2_NO_STATION_MODES */
  589. }
  590. static int prism2_ioctl_giwap(struct net_device *dev,
  591. struct iw_request_info *info,
  592. struct sockaddr *ap_addr, char *extra)
  593. {
  594. struct hostap_interface *iface;
  595. local_info_t *local;
  596. iface = netdev_priv(dev);
  597. local = iface->local;
  598. ap_addr->sa_family = ARPHRD_ETHER;
  599. switch (iface->type) {
  600. case HOSTAP_INTERFACE_AP:
  601. memcpy(&ap_addr->sa_data, dev->dev_addr, ETH_ALEN);
  602. break;
  603. case HOSTAP_INTERFACE_STA:
  604. memcpy(&ap_addr->sa_data, local->assoc_ap_addr, ETH_ALEN);
  605. break;
  606. case HOSTAP_INTERFACE_WDS:
  607. memcpy(&ap_addr->sa_data, iface->u.wds.remote_addr, ETH_ALEN);
  608. break;
  609. default:
  610. if (local->func->get_rid(dev, HFA384X_RID_CURRENTBSSID,
  611. &ap_addr->sa_data, ETH_ALEN, 1) < 0)
  612. return -EOPNOTSUPP;
  613. /* local->bssid is also updated in LinkStatus handler when in
  614. * station mode */
  615. memcpy(local->bssid, &ap_addr->sa_data, ETH_ALEN);
  616. break;
  617. }
  618. return 0;
  619. }
  620. static int prism2_ioctl_siwnickn(struct net_device *dev,
  621. struct iw_request_info *info,
  622. struct iw_point *data, char *nickname)
  623. {
  624. struct hostap_interface *iface;
  625. local_info_t *local;
  626. iface = netdev_priv(dev);
  627. local = iface->local;
  628. memset(local->name, 0, sizeof(local->name));
  629. memcpy(local->name, nickname, data->length);
  630. local->name_set = 1;
  631. if (hostap_set_string(dev, HFA384X_RID_CNFOWNNAME, local->name) ||
  632. local->func->reset_port(dev))
  633. return -EINVAL;
  634. return 0;
  635. }
  636. static int prism2_ioctl_giwnickn(struct net_device *dev,
  637. struct iw_request_info *info,
  638. struct iw_point *data, char *nickname)
  639. {
  640. struct hostap_interface *iface;
  641. local_info_t *local;
  642. int len;
  643. char name[MAX_NAME_LEN + 3];
  644. u16 val;
  645. iface = netdev_priv(dev);
  646. local = iface->local;
  647. len = local->func->get_rid(dev, HFA384X_RID_CNFOWNNAME,
  648. &name, MAX_NAME_LEN + 2, 0);
  649. val = le16_to_cpu(*(__le16 *) name);
  650. if (len > MAX_NAME_LEN + 2 || len < 0 || val > MAX_NAME_LEN)
  651. return -EOPNOTSUPP;
  652. name[val + 2] = '\0';
  653. data->length = val + 1;
  654. memcpy(nickname, name + 2, val + 1);
  655. return 0;
  656. }
  657. static int prism2_ioctl_siwfreq(struct net_device *dev,
  658. struct iw_request_info *info,
  659. struct iw_freq *freq, char *extra)
  660. {
  661. struct hostap_interface *iface;
  662. local_info_t *local;
  663. iface = netdev_priv(dev);
  664. local = iface->local;
  665. /* freq => chan. */
  666. if (freq->e == 1 &&
  667. freq->m / 100000 >= freq_list[0] &&
  668. freq->m / 100000 <= freq_list[FREQ_COUNT - 1]) {
  669. int ch;
  670. int fr = freq->m / 100000;
  671. for (ch = 0; ch < FREQ_COUNT; ch++) {
  672. if (fr == freq_list[ch]) {
  673. freq->e = 0;
  674. freq->m = ch + 1;
  675. break;
  676. }
  677. }
  678. }
  679. if (freq->e != 0 || freq->m < 1 || freq->m > FREQ_COUNT ||
  680. !(local->channel_mask & (1 << (freq->m - 1))))
  681. return -EINVAL;
  682. local->channel = freq->m; /* channel is used in prism2_setup_rids() */
  683. if (hostap_set_word(dev, HFA384X_RID_CNFOWNCHANNEL, local->channel) ||
  684. local->func->reset_port(dev))
  685. return -EINVAL;
  686. return 0;
  687. }
  688. static int prism2_ioctl_giwfreq(struct net_device *dev,
  689. struct iw_request_info *info,
  690. struct iw_freq *freq, char *extra)
  691. {
  692. struct hostap_interface *iface;
  693. local_info_t *local;
  694. u16 val;
  695. iface = netdev_priv(dev);
  696. local = iface->local;
  697. if (local->func->get_rid(dev, HFA384X_RID_CURRENTCHANNEL, &val, 2, 1) <
  698. 0)
  699. return -EINVAL;
  700. le16_to_cpus(&val);
  701. if (val < 1 || val > FREQ_COUNT)
  702. return -EINVAL;
  703. freq->m = freq_list[val - 1] * 100000;
  704. freq->e = 1;
  705. return 0;
  706. }
  707. static void hostap_monitor_set_type(local_info_t *local)
  708. {
  709. struct net_device *dev = local->ddev;
  710. if (dev == NULL)
  711. return;
  712. if (local->monitor_type == PRISM2_MONITOR_PRISM ||
  713. local->monitor_type == PRISM2_MONITOR_CAPHDR) {
  714. dev->type = ARPHRD_IEEE80211_PRISM;
  715. } else if (local->monitor_type == PRISM2_MONITOR_RADIOTAP) {
  716. dev->type = ARPHRD_IEEE80211_RADIOTAP;
  717. } else {
  718. dev->type = ARPHRD_IEEE80211;
  719. }
  720. }
  721. static int prism2_ioctl_siwessid(struct net_device *dev,
  722. struct iw_request_info *info,
  723. struct iw_point *data, char *ssid)
  724. {
  725. struct hostap_interface *iface;
  726. local_info_t *local;
  727. iface = netdev_priv(dev);
  728. local = iface->local;
  729. if (iface->type == HOSTAP_INTERFACE_WDS)
  730. return -EOPNOTSUPP;
  731. if (data->flags == 0)
  732. ssid[0] = '\0'; /* ANY */
  733. if (local->iw_mode == IW_MODE_MASTER && ssid[0] == '\0') {
  734. /* Setting SSID to empty string seems to kill the card in
  735. * Host AP mode */
  736. printk(KERN_DEBUG "%s: Host AP mode does not support "
  737. "'Any' essid\n", dev->name);
  738. return -EINVAL;
  739. }
  740. memcpy(local->essid, ssid, data->length);
  741. local->essid[data->length] = '\0';
  742. if ((!local->fw_ap &&
  743. hostap_set_string(dev, HFA384X_RID_CNFDESIREDSSID, local->essid))
  744. || hostap_set_string(dev, HFA384X_RID_CNFOWNSSID, local->essid) ||
  745. local->func->reset_port(dev))
  746. return -EINVAL;
  747. return 0;
  748. }
  749. static int prism2_ioctl_giwessid(struct net_device *dev,
  750. struct iw_request_info *info,
  751. struct iw_point *data, char *essid)
  752. {
  753. struct hostap_interface *iface;
  754. local_info_t *local;
  755. u16 val;
  756. iface = netdev_priv(dev);
  757. local = iface->local;
  758. if (iface->type == HOSTAP_INTERFACE_WDS)
  759. return -EOPNOTSUPP;
  760. data->flags = 1; /* active */
  761. if (local->iw_mode == IW_MODE_MASTER) {
  762. data->length = strlen(local->essid);
  763. memcpy(essid, local->essid, IW_ESSID_MAX_SIZE);
  764. } else {
  765. int len;
  766. char ssid[MAX_SSID_LEN + 2];
  767. memset(ssid, 0, sizeof(ssid));
  768. len = local->func->get_rid(dev, HFA384X_RID_CURRENTSSID,
  769. &ssid, MAX_SSID_LEN + 2, 0);
  770. val = le16_to_cpu(*(__le16 *) ssid);
  771. if (len > MAX_SSID_LEN + 2 || len < 0 || val > MAX_SSID_LEN) {
  772. return -EOPNOTSUPP;
  773. }
  774. data->length = val;
  775. memcpy(essid, ssid + 2, IW_ESSID_MAX_SIZE);
  776. }
  777. return 0;
  778. }
  779. static int prism2_ioctl_giwrange(struct net_device *dev,
  780. struct iw_request_info *info,
  781. struct iw_point *data, char *extra)
  782. {
  783. struct hostap_interface *iface;
  784. local_info_t *local;
  785. struct iw_range *range = (struct iw_range *) extra;
  786. u8 rates[10];
  787. u16 val;
  788. int i, len, over2;
  789. iface = netdev_priv(dev);
  790. local = iface->local;
  791. data->length = sizeof(struct iw_range);
  792. memset(range, 0, sizeof(struct iw_range));
  793. /* TODO: could fill num_txpower and txpower array with
  794. * something; however, there are 128 different values.. */
  795. range->txpower_capa = IW_TXPOW_DBM;
  796. if (local->iw_mode == IW_MODE_INFRA || local->iw_mode == IW_MODE_ADHOC)
  797. {
  798. range->min_pmp = 1 * 1024;
  799. range->max_pmp = 65535 * 1024;
  800. range->min_pmt = 1 * 1024;
  801. range->max_pmt = 1000 * 1024;
  802. range->pmp_flags = IW_POWER_PERIOD;
  803. range->pmt_flags = IW_POWER_TIMEOUT;
  804. range->pm_capa = IW_POWER_PERIOD | IW_POWER_TIMEOUT |
  805. IW_POWER_UNICAST_R | IW_POWER_ALL_R;
  806. }
  807. range->we_version_compiled = WIRELESS_EXT;
  808. range->we_version_source = 18;
  809. range->retry_capa = IW_RETRY_LIMIT;
  810. range->retry_flags = IW_RETRY_LIMIT;
  811. range->min_retry = 0;
  812. range->max_retry = 255;
  813. range->num_channels = FREQ_COUNT;
  814. val = 0;
  815. for (i = 0; i < FREQ_COUNT; i++) {
  816. if (local->channel_mask & (1 << i)) {
  817. range->freq[val].i = i + 1;
  818. range->freq[val].m = freq_list[i] * 100000;
  819. range->freq[val].e = 1;
  820. val++;
  821. }
  822. if (val == IW_MAX_FREQUENCIES)
  823. break;
  824. }
  825. range->num_frequency = val;
  826. if (local->sta_fw_ver >= PRISM2_FW_VER(1,3,1)) {
  827. range->max_qual.qual = 70; /* what is correct max? This was not
  828. * documented exactly. At least
  829. * 69 has been observed. */
  830. range->max_qual.level = 0; /* dB */
  831. range->max_qual.noise = 0; /* dB */
  832. /* What would be suitable values for "average/typical" qual? */
  833. range->avg_qual.qual = 20;
  834. range->avg_qual.level = -60;
  835. range->avg_qual.noise = -95;
  836. } else {
  837. range->max_qual.qual = 92; /* 0 .. 92 */
  838. range->max_qual.level = 154; /* 27 .. 154 */
  839. range->max_qual.noise = 154; /* 27 .. 154 */
  840. }
  841. range->sensitivity = 3;
  842. range->max_encoding_tokens = WEP_KEYS;
  843. range->num_encoding_sizes = 2;
  844. range->encoding_size[0] = 5;
  845. range->encoding_size[1] = 13;
  846. over2 = 0;
  847. len = prism2_get_datarates(dev, rates);
  848. range->num_bitrates = 0;
  849. for (i = 0; i < len; i++) {
  850. if (range->num_bitrates < IW_MAX_BITRATES) {
  851. range->bitrate[range->num_bitrates] =
  852. rates[i] * 500000;
  853. range->num_bitrates++;
  854. }
  855. if (rates[i] == 0x0b || rates[i] == 0x16)
  856. over2 = 1;
  857. }
  858. /* estimated maximum TCP throughput values (bps) */
  859. range->throughput = over2 ? 5500000 : 1500000;
  860. range->min_rts = 0;
  861. range->max_rts = 2347;
  862. range->min_frag = 256;
  863. range->max_frag = 2346;
  864. /* Event capability (kernel + driver) */
  865. range->event_capa[0] = (IW_EVENT_CAPA_K_0 |
  866. IW_EVENT_CAPA_MASK(SIOCGIWTHRSPY) |
  867. IW_EVENT_CAPA_MASK(SIOCGIWAP) |
  868. IW_EVENT_CAPA_MASK(SIOCGIWSCAN));
  869. range->event_capa[1] = IW_EVENT_CAPA_K_1;
  870. range->event_capa[4] = (IW_EVENT_CAPA_MASK(IWEVTXDROP) |
  871. IW_EVENT_CAPA_MASK(IWEVCUSTOM) |
  872. IW_EVENT_CAPA_MASK(IWEVREGISTERED) |
  873. IW_EVENT_CAPA_MASK(IWEVEXPIRED));
  874. range->enc_capa = IW_ENC_CAPA_WPA | IW_ENC_CAPA_WPA2 |
  875. IW_ENC_CAPA_CIPHER_TKIP | IW_ENC_CAPA_CIPHER_CCMP;
  876. if (local->sta_fw_ver >= PRISM2_FW_VER(1,3,1))
  877. range->scan_capa = IW_SCAN_CAPA_ESSID;
  878. return 0;
  879. }
  880. static int hostap_monitor_mode_enable(local_info_t *local)
  881. {
  882. struct net_device *dev = local->dev;
  883. printk(KERN_DEBUG "Enabling monitor mode\n");
  884. hostap_monitor_set_type(local);
  885. if (hostap_set_word(dev, HFA384X_RID_CNFPORTTYPE,
  886. HFA384X_PORTTYPE_PSEUDO_IBSS)) {
  887. printk(KERN_DEBUG "Port type setting for monitor mode "
  888. "failed\n");
  889. return -EOPNOTSUPP;
  890. }
  891. /* Host decrypt is needed to get the IV and ICV fields;
  892. * however, monitor mode seems to remove WEP flag from frame
  893. * control field */
  894. if (hostap_set_word(dev, HFA384X_RID_CNFWEPFLAGS,
  895. HFA384X_WEPFLAGS_HOSTENCRYPT |
  896. HFA384X_WEPFLAGS_HOSTDECRYPT)) {
  897. printk(KERN_DEBUG "WEP flags setting failed\n");
  898. return -EOPNOTSUPP;
  899. }
  900. if (local->func->reset_port(dev) ||
  901. local->func->cmd(dev, HFA384X_CMDCODE_TEST |
  902. (HFA384X_TEST_MONITOR << 8),
  903. 0, NULL, NULL)) {
  904. printk(KERN_DEBUG "Setting monitor mode failed\n");
  905. return -EOPNOTSUPP;
  906. }
  907. return 0;
  908. }
  909. static int hostap_monitor_mode_disable(local_info_t *local)
  910. {
  911. struct net_device *dev = local->ddev;
  912. if (dev == NULL)
  913. return -1;
  914. printk(KERN_DEBUG "%s: Disabling monitor mode\n", dev->name);
  915. dev->type = ARPHRD_ETHER;
  916. if (local->func->cmd(dev, HFA384X_CMDCODE_TEST |
  917. (HFA384X_TEST_STOP << 8),
  918. 0, NULL, NULL))
  919. return -1;
  920. return hostap_set_encryption(local);
  921. }
  922. static int prism2_ioctl_siwmode(struct net_device *dev,
  923. struct iw_request_info *info,
  924. __u32 *mode, char *extra)
  925. {
  926. struct hostap_interface *iface;
  927. local_info_t *local;
  928. int double_reset = 0;
  929. iface = netdev_priv(dev);
  930. local = iface->local;
  931. if (*mode != IW_MODE_ADHOC && *mode != IW_MODE_INFRA &&
  932. *mode != IW_MODE_MASTER && *mode != IW_MODE_REPEAT &&
  933. *mode != IW_MODE_MONITOR)
  934. return -EOPNOTSUPP;
  935. #ifdef PRISM2_NO_STATION_MODES
  936. if (*mode == IW_MODE_ADHOC || *mode == IW_MODE_INFRA)
  937. return -EOPNOTSUPP;
  938. #endif /* PRISM2_NO_STATION_MODES */
  939. if (*mode == local->iw_mode)
  940. return 0;
  941. if (*mode == IW_MODE_MASTER && local->essid[0] == '\0') {
  942. printk(KERN_WARNING "%s: empty SSID not allowed in Master "
  943. "mode\n", dev->name);
  944. return -EINVAL;
  945. }
  946. if (local->iw_mode == IW_MODE_MONITOR)
  947. hostap_monitor_mode_disable(local);
  948. if ((local->iw_mode == IW_MODE_ADHOC ||
  949. local->iw_mode == IW_MODE_MONITOR) && *mode == IW_MODE_MASTER) {
  950. /* There seems to be a firmware bug in at least STA f/w v1.5.6
  951. * that leaves beacon frames to use IBSS type when moving from
  952. * IBSS to Host AP mode. Doing double Port0 reset seems to be
  953. * enough to workaround this. */
  954. double_reset = 1;
  955. }
  956. printk(KERN_DEBUG "prism2: %s: operating mode changed "
  957. "%d -> %d\n", dev->name, local->iw_mode, *mode);
  958. local->iw_mode = *mode;
  959. if (local->iw_mode == IW_MODE_MONITOR)
  960. hostap_monitor_mode_enable(local);
  961. else if (local->iw_mode == IW_MODE_MASTER && !local->host_encrypt &&
  962. !local->fw_encrypt_ok) {
  963. printk(KERN_DEBUG "%s: defaulting to host-based encryption as "
  964. "a workaround for firmware bug in Host AP mode WEP\n",
  965. dev->name);
  966. local->host_encrypt = 1;
  967. }
  968. if (hostap_set_word(dev, HFA384X_RID_CNFPORTTYPE,
  969. hostap_get_porttype(local)))
  970. return -EOPNOTSUPP;
  971. if (local->func->reset_port(dev))
  972. return -EINVAL;
  973. if (double_reset && local->func->reset_port(dev))
  974. return -EINVAL;
  975. if (local->iw_mode != IW_MODE_INFRA && local->iw_mode != IW_MODE_ADHOC)
  976. {
  977. /* netif_carrier is used only in client modes for now, so make
  978. * sure carrier is on when moving to non-client modes. */
  979. netif_carrier_on(local->dev);
  980. netif_carrier_on(local->ddev);
  981. }
  982. return 0;
  983. }
  984. static int prism2_ioctl_giwmode(struct net_device *dev,
  985. struct iw_request_info *info,
  986. __u32 *mode, char *extra)
  987. {
  988. struct hostap_interface *iface;
  989. local_info_t *local;
  990. iface = netdev_priv(dev);
  991. local = iface->local;
  992. switch (iface->type) {
  993. case HOSTAP_INTERFACE_STA:
  994. *mode = IW_MODE_INFRA;
  995. break;
  996. case HOSTAP_INTERFACE_WDS:
  997. *mode = IW_MODE_REPEAT;
  998. break;
  999. default:
  1000. *mode = local->iw_mode;
  1001. break;
  1002. }
  1003. return 0;
  1004. }
  1005. static int prism2_ioctl_siwpower(struct net_device *dev,
  1006. struct iw_request_info *info,
  1007. struct iw_param *wrq, char *extra)
  1008. {
  1009. #ifdef PRISM2_NO_STATION_MODES
  1010. return -EOPNOTSUPP;
  1011. #else /* PRISM2_NO_STATION_MODES */
  1012. int ret = 0;
  1013. if (wrq->disabled)
  1014. return hostap_set_word(dev, HFA384X_RID_CNFPMENABLED, 0);
  1015. switch (wrq->flags & IW_POWER_MODE) {
  1016. case IW_POWER_UNICAST_R:
  1017. ret = hostap_set_word(dev, HFA384X_RID_CNFMULTICASTRECEIVE, 0);
  1018. if (ret)
  1019. return ret;
  1020. ret = hostap_set_word(dev, HFA384X_RID_CNFPMENABLED, 1);
  1021. if (ret)
  1022. return ret;
  1023. break;
  1024. case IW_POWER_ALL_R:
  1025. ret = hostap_set_word(dev, HFA384X_RID_CNFMULTICASTRECEIVE, 1);
  1026. if (ret)
  1027. return ret;
  1028. ret = hostap_set_word(dev, HFA384X_RID_CNFPMENABLED, 1);
  1029. if (ret)
  1030. return ret;
  1031. break;
  1032. case IW_POWER_ON:
  1033. break;
  1034. default:
  1035. return -EINVAL;
  1036. }
  1037. if (wrq->flags & IW_POWER_TIMEOUT) {
  1038. ret = hostap_set_word(dev, HFA384X_RID_CNFPMENABLED, 1);
  1039. if (ret)
  1040. return ret;
  1041. ret = hostap_set_word(dev, HFA384X_RID_CNFPMHOLDOVERDURATION,
  1042. wrq->value / 1024);
  1043. if (ret)
  1044. return ret;
  1045. }
  1046. if (wrq->flags & IW_POWER_PERIOD) {
  1047. ret = hostap_set_word(dev, HFA384X_RID_CNFPMENABLED, 1);
  1048. if (ret)
  1049. return ret;
  1050. ret = hostap_set_word(dev, HFA384X_RID_CNFMAXSLEEPDURATION,
  1051. wrq->value / 1024);
  1052. if (ret)
  1053. return ret;
  1054. }
  1055. return ret;
  1056. #endif /* PRISM2_NO_STATION_MODES */
  1057. }
  1058. static int prism2_ioctl_giwpower(struct net_device *dev,
  1059. struct iw_request_info *info,
  1060. struct iw_param *rrq, char *extra)
  1061. {
  1062. #ifdef PRISM2_NO_STATION_MODES
  1063. return -EOPNOTSUPP;
  1064. #else /* PRISM2_NO_STATION_MODES */
  1065. struct hostap_interface *iface;
  1066. local_info_t *local;
  1067. __le16 enable, mcast;
  1068. iface = netdev_priv(dev);
  1069. local = iface->local;
  1070. if (local->func->get_rid(dev, HFA384X_RID_CNFPMENABLED, &enable, 2, 1)
  1071. < 0)
  1072. return -EINVAL;
  1073. if (!le16_to_cpu(enable)) {
  1074. rrq->disabled = 1;
  1075. return 0;
  1076. }
  1077. rrq->disabled = 0;
  1078. if ((rrq->flags & IW_POWER_TYPE) == IW_POWER_TIMEOUT) {
  1079. __le16 timeout;
  1080. if (local->func->get_rid(dev,
  1081. HFA384X_RID_CNFPMHOLDOVERDURATION,
  1082. &timeout, 2, 1) < 0)
  1083. return -EINVAL;
  1084. rrq->flags = IW_POWER_TIMEOUT;
  1085. rrq->value = le16_to_cpu(timeout) * 1024;
  1086. } else {
  1087. __le16 period;
  1088. if (local->func->get_rid(dev, HFA384X_RID_CNFMAXSLEEPDURATION,
  1089. &period, 2, 1) < 0)
  1090. return -EINVAL;
  1091. rrq->flags = IW_POWER_PERIOD;
  1092. rrq->value = le16_to_cpu(period) * 1024;
  1093. }
  1094. if (local->func->get_rid(dev, HFA384X_RID_CNFMULTICASTRECEIVE, &mcast,
  1095. 2, 1) < 0)
  1096. return -EINVAL;
  1097. if (le16_to_cpu(mcast))
  1098. rrq->flags |= IW_POWER_ALL_R;
  1099. else
  1100. rrq->flags |= IW_POWER_UNICAST_R;
  1101. return 0;
  1102. #endif /* PRISM2_NO_STATION_MODES */
  1103. }
  1104. static int prism2_ioctl_siwretry(struct net_device *dev,
  1105. struct iw_request_info *info,
  1106. struct iw_param *rrq, char *extra)
  1107. {
  1108. struct hostap_interface *iface;
  1109. local_info_t *local;
  1110. iface = netdev_priv(dev);
  1111. local = iface->local;
  1112. if (rrq->disabled)
  1113. return -EINVAL;
  1114. /* setting retry limits is not supported with the current station
  1115. * firmware code; simulate this with alternative retry count for now */
  1116. if (rrq->flags == IW_RETRY_LIMIT) {
  1117. if (rrq->value < 0) {
  1118. /* disable manual retry count setting and use firmware
  1119. * defaults */
  1120. local->manual_retry_count = -1;
  1121. local->tx_control &= ~HFA384X_TX_CTRL_ALT_RTRY;
  1122. } else {
  1123. if (hostap_set_word(dev, HFA384X_RID_CNFALTRETRYCOUNT,
  1124. rrq->value)) {
  1125. printk(KERN_DEBUG "%s: Alternate retry count "
  1126. "setting to %d failed\n",
  1127. dev->name, rrq->value);
  1128. return -EOPNOTSUPP;
  1129. }
  1130. local->manual_retry_count = rrq->value;
  1131. local->tx_control |= HFA384X_TX_CTRL_ALT_RTRY;
  1132. }
  1133. return 0;
  1134. }
  1135. return -EOPNOTSUPP;
  1136. #if 0
  1137. /* what could be done, if firmware would support this.. */
  1138. if (rrq->flags & IW_RETRY_LIMIT) {
  1139. if (rrq->flags & IW_RETRY_LONG)
  1140. HFA384X_RID_LONGRETRYLIMIT = rrq->value;
  1141. else if (rrq->flags & IW_RETRY_SHORT)
  1142. HFA384X_RID_SHORTRETRYLIMIT = rrq->value;
  1143. else {
  1144. HFA384X_RID_LONGRETRYLIMIT = rrq->value;
  1145. HFA384X_RID_SHORTRETRYLIMIT = rrq->value;
  1146. }
  1147. }
  1148. if (rrq->flags & IW_RETRY_LIFETIME) {
  1149. HFA384X_RID_MAXTRANSMITLIFETIME = rrq->value / 1024;
  1150. }
  1151. return 0;
  1152. #endif /* 0 */
  1153. }
  1154. static int prism2_ioctl_giwretry(struct net_device *dev,
  1155. struct iw_request_info *info,
  1156. struct iw_param *rrq, char *extra)
  1157. {
  1158. struct hostap_interface *iface;
  1159. local_info_t *local;
  1160. __le16 shortretry, longretry, lifetime, altretry;
  1161. iface = netdev_priv(dev);
  1162. local = iface->local;
  1163. if (local->func->get_rid(dev, HFA384X_RID_SHORTRETRYLIMIT, &shortretry,
  1164. 2, 1) < 0 ||
  1165. local->func->get_rid(dev, HFA384X_RID_LONGRETRYLIMIT, &longretry,
  1166. 2, 1) < 0 ||
  1167. local->func->get_rid(dev, HFA384X_RID_MAXTRANSMITLIFETIME,
  1168. &lifetime, 2, 1) < 0)
  1169. return -EINVAL;
  1170. rrq->disabled = 0;
  1171. if ((rrq->flags & IW_RETRY_TYPE) == IW_RETRY_LIFETIME) {
  1172. rrq->flags = IW_RETRY_LIFETIME;
  1173. rrq->value = le16_to_cpu(lifetime) * 1024;
  1174. } else {
  1175. if (local->manual_retry_count >= 0) {
  1176. rrq->flags = IW_RETRY_LIMIT;
  1177. if (local->func->get_rid(dev,
  1178. HFA384X_RID_CNFALTRETRYCOUNT,
  1179. &altretry, 2, 1) >= 0)
  1180. rrq->value = le16_to_cpu(altretry);
  1181. else
  1182. rrq->value = local->manual_retry_count;
  1183. } else if ((rrq->flags & IW_RETRY_LONG)) {
  1184. rrq->flags = IW_RETRY_LIMIT | IW_RETRY_LONG;
  1185. rrq->value = le16_to_cpu(longretry);
  1186. } else {
  1187. rrq->flags = IW_RETRY_LIMIT;
  1188. rrq->value = le16_to_cpu(shortretry);
  1189. if (shortretry != longretry)
  1190. rrq->flags |= IW_RETRY_SHORT;
  1191. }
  1192. }
  1193. return 0;
  1194. }
  1195. /* Note! This TX power controlling is experimental and should not be used in
  1196. * production use. It just sets raw power register and does not use any kind of
  1197. * feedback information from the measured TX power (CR58). This is now
  1198. * commented out to make sure that it is not used by accident. TX power
  1199. * configuration will be enabled again after proper algorithm using feedback
  1200. * has been implemented. */
  1201. #ifdef RAW_TXPOWER_SETTING
  1202. /* Map HFA386x's CR31 to and from dBm with some sort of ad hoc mapping..
  1203. * This version assumes following mapping:
  1204. * CR31 is 7-bit value with -64 to +63 range.
  1205. * -64 is mapped into +20dBm and +63 into -43dBm.
  1206. * This is certainly not an exact mapping for every card, but at least
  1207. * increasing dBm value should correspond to increasing TX power.
  1208. */
  1209. static int prism2_txpower_hfa386x_to_dBm(u16 val)
  1210. {
  1211. signed char tmp;
  1212. if (val > 255)
  1213. val = 255;
  1214. tmp = val;
  1215. tmp >>= 2;
  1216. return -12 - tmp;
  1217. }
  1218. static u16 prism2_txpower_dBm_to_hfa386x(int val)
  1219. {
  1220. signed char tmp;
  1221. if (val > 20)
  1222. return 128;
  1223. else if (val < -43)
  1224. return 127;
  1225. tmp = val;
  1226. tmp = -12 - tmp;
  1227. tmp <<= 2;
  1228. return (unsigned char) tmp;
  1229. }
  1230. #endif /* RAW_TXPOWER_SETTING */
  1231. static int prism2_ioctl_siwtxpow(struct net_device *dev,
  1232. struct iw_request_info *info,
  1233. struct iw_param *rrq, char *extra)
  1234. {
  1235. struct hostap_interface *iface;
  1236. local_info_t *local;
  1237. #ifdef RAW_TXPOWER_SETTING
  1238. char *tmp;
  1239. #endif
  1240. u16 val;
  1241. int ret = 0;
  1242. iface = netdev_priv(dev);
  1243. local = iface->local;
  1244. if (rrq->disabled) {
  1245. if (local->txpower_type != PRISM2_TXPOWER_OFF) {
  1246. val = 0xff; /* use all standby and sleep modes */
  1247. ret = local->func->cmd(dev, HFA384X_CMDCODE_WRITEMIF,
  1248. HFA386X_CR_A_D_TEST_MODES2,
  1249. &val, NULL);
  1250. printk(KERN_DEBUG "%s: Turning radio off: %s\n",
  1251. dev->name, ret ? "failed" : "OK");
  1252. local->txpower_type = PRISM2_TXPOWER_OFF;
  1253. }
  1254. return (ret ? -EOPNOTSUPP : 0);
  1255. }
  1256. if (local->txpower_type == PRISM2_TXPOWER_OFF) {
  1257. val = 0; /* disable all standby and sleep modes */
  1258. ret = local->func->cmd(dev, HFA384X_CMDCODE_WRITEMIF,
  1259. HFA386X_CR_A_D_TEST_MODES2, &val, NULL);
  1260. printk(KERN_DEBUG "%s: Turning radio on: %s\n",
  1261. dev->name, ret ? "failed" : "OK");
  1262. local->txpower_type = PRISM2_TXPOWER_UNKNOWN;
  1263. }
  1264. #ifdef RAW_TXPOWER_SETTING
  1265. if (!rrq->fixed && local->txpower_type != PRISM2_TXPOWER_AUTO) {
  1266. printk(KERN_DEBUG "Setting ALC on\n");
  1267. val = HFA384X_TEST_CFG_BIT_ALC;
  1268. local->func->cmd(dev, HFA384X_CMDCODE_TEST |
  1269. (HFA384X_TEST_CFG_BITS << 8), 1, &val, NULL);
  1270. local->txpower_type = PRISM2_TXPOWER_AUTO;
  1271. return 0;
  1272. }
  1273. if (local->txpower_type != PRISM2_TXPOWER_FIXED) {
  1274. printk(KERN_DEBUG "Setting ALC off\n");
  1275. val = HFA384X_TEST_CFG_BIT_ALC;
  1276. local->func->cmd(dev, HFA384X_CMDCODE_TEST |
  1277. (HFA384X_TEST_CFG_BITS << 8), 0, &val, NULL);
  1278. local->txpower_type = PRISM2_TXPOWER_FIXED;
  1279. }
  1280. if (rrq->flags == IW_TXPOW_DBM)
  1281. tmp = "dBm";
  1282. else if (rrq->flags == IW_TXPOW_MWATT)
  1283. tmp = "mW";
  1284. else
  1285. tmp = "UNKNOWN";
  1286. printk(KERN_DEBUG "Setting TX power to %d %s\n", rrq->value, tmp);
  1287. if (rrq->flags != IW_TXPOW_DBM) {
  1288. printk("SIOCSIWTXPOW with mW is not supported; use dBm\n");
  1289. return -EOPNOTSUPP;
  1290. }
  1291. local->txpower = rrq->value;
  1292. val = prism2_txpower_dBm_to_hfa386x(local->txpower);
  1293. if (local->func->cmd(dev, HFA384X_CMDCODE_WRITEMIF,
  1294. HFA386X_CR_MANUAL_TX_POWER, &val, NULL))
  1295. ret = -EOPNOTSUPP;
  1296. #else /* RAW_TXPOWER_SETTING */
  1297. if (rrq->fixed)
  1298. ret = -EOPNOTSUPP;
  1299. #endif /* RAW_TXPOWER_SETTING */
  1300. return ret;
  1301. }
  1302. static int prism2_ioctl_giwtxpow(struct net_device *dev,
  1303. struct iw_request_info *info,
  1304. struct iw_param *rrq, char *extra)
  1305. {
  1306. #ifdef RAW_TXPOWER_SETTING
  1307. struct hostap_interface *iface;
  1308. local_info_t *local;
  1309. u16 resp0;
  1310. iface = netdev_priv(dev);
  1311. local = iface->local;
  1312. rrq->flags = IW_TXPOW_DBM;
  1313. rrq->disabled = 0;
  1314. rrq->fixed = 0;
  1315. if (local->txpower_type == PRISM2_TXPOWER_AUTO) {
  1316. if (local->func->cmd(dev, HFA384X_CMDCODE_READMIF,
  1317. HFA386X_CR_MANUAL_TX_POWER,
  1318. NULL, &resp0) == 0) {
  1319. rrq->value = prism2_txpower_hfa386x_to_dBm(resp0);
  1320. } else {
  1321. /* Could not get real txpower; guess 15 dBm */
  1322. rrq->value = 15;
  1323. }
  1324. } else if (local->txpower_type == PRISM2_TXPOWER_OFF) {
  1325. rrq->value = 0;
  1326. rrq->disabled = 1;
  1327. } else if (local->txpower_type == PRISM2_TXPOWER_FIXED) {
  1328. rrq->value = local->txpower;
  1329. rrq->fixed = 1;
  1330. } else {
  1331. printk("SIOCGIWTXPOW - unknown txpower_type=%d\n",
  1332. local->txpower_type);
  1333. }
  1334. return 0;
  1335. #else /* RAW_TXPOWER_SETTING */
  1336. return -EOPNOTSUPP;
  1337. #endif /* RAW_TXPOWER_SETTING */
  1338. }
  1339. #ifndef PRISM2_NO_STATION_MODES
  1340. /* HostScan request works with and without host_roaming mode. In addition, it
  1341. * does not break current association. However, it requires newer station
  1342. * firmware version (>= 1.3.1) than scan request. */
  1343. static int prism2_request_hostscan(struct net_device *dev,
  1344. u8 *ssid, u8 ssid_len)
  1345. {
  1346. struct hostap_interface *iface;
  1347. local_info_t *local;
  1348. struct hfa384x_hostscan_request scan_req;
  1349. iface = netdev_priv(dev);
  1350. local = iface->local;
  1351. memset(&scan_req, 0, sizeof(scan_req));
  1352. scan_req.channel_list = cpu_to_le16(local->channel_mask &
  1353. local->scan_channel_mask);
  1354. scan_req.txrate = cpu_to_le16(HFA384X_RATES_1MBPS);
  1355. if (ssid) {
  1356. if (ssid_len > 32)
  1357. return -EINVAL;
  1358. scan_req.target_ssid_len = cpu_to_le16(ssid_len);
  1359. memcpy(scan_req.target_ssid, ssid, ssid_len);
  1360. }
  1361. if (local->func->set_rid(dev, HFA384X_RID_HOSTSCAN, &scan_req,
  1362. sizeof(scan_req))) {
  1363. printk(KERN_DEBUG "%s: HOSTSCAN failed\n", dev->name);
  1364. return -EINVAL;
  1365. }
  1366. return 0;
  1367. }
  1368. static int prism2_request_scan(struct net_device *dev)
  1369. {
  1370. struct hostap_interface *iface;
  1371. local_info_t *local;
  1372. struct hfa384x_scan_request scan_req;
  1373. int ret = 0;
  1374. iface = netdev_priv(dev);
  1375. local = iface->local;
  1376. memset(&scan_req, 0, sizeof(scan_req));
  1377. scan_req.channel_list = cpu_to_le16(local->channel_mask &
  1378. local->scan_channel_mask);
  1379. scan_req.txrate = cpu_to_le16(HFA384X_RATES_1MBPS);
  1380. /* FIX:
  1381. * It seems to be enough to set roaming mode for a short moment to
  1382. * host-based and then setup scanrequest data and return the mode to
  1383. * firmware-based.
  1384. *
  1385. * Master mode would need to drop to Managed mode for a short while
  1386. * to make scanning work.. Or sweep through the different channels and
  1387. * use passive scan based on beacons. */
  1388. if (!local->host_roaming)
  1389. hostap_set_word(dev, HFA384X_RID_CNFROAMINGMODE,
  1390. HFA384X_ROAMING_HOST);
  1391. if (local->func->set_rid(dev, HFA384X_RID_SCANREQUEST, &scan_req,
  1392. sizeof(scan_req))) {
  1393. printk(KERN_DEBUG "SCANREQUEST failed\n");
  1394. ret = -EINVAL;
  1395. }
  1396. if (!local->host_roaming)
  1397. hostap_set_word(dev, HFA384X_RID_CNFROAMINGMODE,
  1398. HFA384X_ROAMING_FIRMWARE);
  1399. return ret;
  1400. }
  1401. #else /* !PRISM2_NO_STATION_MODES */
  1402. static inline int prism2_request_hostscan(struct net_device *dev,
  1403. u8 *ssid, u8 ssid_len)
  1404. {
  1405. return -EOPNOTSUPP;
  1406. }
  1407. static inline int prism2_request_scan(struct net_device *dev)
  1408. {
  1409. return -EOPNOTSUPP;
  1410. }
  1411. #endif /* !PRISM2_NO_STATION_MODES */
  1412. static int prism2_ioctl_siwscan(struct net_device *dev,
  1413. struct iw_request_info *info,
  1414. struct iw_point *data, char *extra)
  1415. {
  1416. struct hostap_interface *iface;
  1417. local_info_t *local;
  1418. int ret;
  1419. u8 *ssid = NULL, ssid_len = 0;
  1420. struct iw_scan_req *req = (struct iw_scan_req *) extra;
  1421. iface = netdev_priv(dev);
  1422. local = iface->local;
  1423. if (data->length < sizeof(struct iw_scan_req))
  1424. req = NULL;
  1425. if (local->iw_mode == IW_MODE_MASTER) {
  1426. /* In master mode, we just return the results of our local
  1427. * tables, so we don't need to start anything...
  1428. * Jean II */
  1429. data->length = 0;
  1430. return 0;
  1431. }
  1432. if (!local->dev_enabled)
  1433. return -ENETDOWN;
  1434. if (req && data->flags & IW_SCAN_THIS_ESSID) {
  1435. ssid = req->essid;
  1436. ssid_len = req->essid_len;
  1437. if (ssid_len &&
  1438. ((local->iw_mode != IW_MODE_INFRA &&
  1439. local->iw_mode != IW_MODE_ADHOC) ||
  1440. (local->sta_fw_ver < PRISM2_FW_VER(1,3,1))))
  1441. return -EOPNOTSUPP;
  1442. }
  1443. if (local->sta_fw_ver >= PRISM2_FW_VER(1,3,1))
  1444. ret = prism2_request_hostscan(dev, ssid, ssid_len);
  1445. else
  1446. ret = prism2_request_scan(dev);
  1447. if (ret == 0)
  1448. local->scan_timestamp = jiffies;
  1449. /* Could inquire F101, F103 or wait for SIOCGIWSCAN and read RID */
  1450. return ret;
  1451. }
  1452. #ifndef PRISM2_NO_STATION_MODES
  1453. static char * __prism2_translate_scan(local_info_t *local,
  1454. struct iw_request_info *info,
  1455. struct hfa384x_hostscan_result *scan,
  1456. struct hostap_bss_info *bss,
  1457. char *current_ev, char *end_buf)
  1458. {
  1459. int i, chan;
  1460. struct iw_event iwe;
  1461. char *current_val;
  1462. u16 capabilities;
  1463. u8 *pos;
  1464. u8 *ssid, *bssid;
  1465. size_t ssid_len;
  1466. char *buf;
  1467. if (bss) {
  1468. ssid = bss->ssid;
  1469. ssid_len = bss->ssid_len;
  1470. bssid = bss->bssid;
  1471. } else {
  1472. ssid = scan->ssid;
  1473. ssid_len = le16_to_cpu(scan->ssid_len);
  1474. bssid = scan->bssid;
  1475. }
  1476. if (ssid_len > 32)
  1477. ssid_len = 32;
  1478. /* First entry *MUST* be the AP MAC address */
  1479. memset(&iwe, 0, sizeof(iwe));
  1480. iwe.cmd = SIOCGIWAP;
  1481. iwe.u.ap_addr.sa_family = ARPHRD_ETHER;
  1482. memcpy(iwe.u.ap_addr.sa_data, bssid, ETH_ALEN);
  1483. current_ev = iwe_stream_add_event(info, current_ev, end_buf, &iwe,
  1484. IW_EV_ADDR_LEN);
  1485. /* Other entries will be displayed in the order we give them */
  1486. memset(&iwe, 0, sizeof(iwe));
  1487. iwe.cmd = SIOCGIWESSID;
  1488. iwe.u.data.length = ssid_len;
  1489. iwe.u.data.flags = 1;
  1490. current_ev = iwe_stream_add_point(info, current_ev, end_buf,
  1491. &iwe, ssid);
  1492. memset(&iwe, 0, sizeof(iwe));
  1493. iwe.cmd = SIOCGIWMODE;
  1494. if (bss) {
  1495. capabilities = bss->capab_info;
  1496. } else {
  1497. capabilities = le16_to_cpu(scan->capability);
  1498. }
  1499. if (capabilities & (WLAN_CAPABILITY_ESS |
  1500. WLAN_CAPABILITY_IBSS)) {
  1501. if (capabilities & WLAN_CAPABILITY_ESS)
  1502. iwe.u.mode = IW_MODE_MASTER;
  1503. else
  1504. iwe.u.mode = IW_MODE_ADHOC;
  1505. current_ev = iwe_stream_add_event(info, current_ev, end_buf,
  1506. &iwe, IW_EV_UINT_LEN);
  1507. }
  1508. memset(&iwe, 0, sizeof(iwe));
  1509. iwe.cmd = SIOCGIWFREQ;
  1510. if (scan) {
  1511. chan = le16_to_cpu(scan->chid);
  1512. } else if (bss) {
  1513. chan = bss->chan;
  1514. } else {
  1515. chan = 0;
  1516. }
  1517. if (chan > 0) {
  1518. iwe.u.freq.m = freq_list[chan - 1] * 100000;
  1519. iwe.u.freq.e = 1;
  1520. current_ev = iwe_stream_add_event(info, current_ev, end_buf,
  1521. &iwe, IW_EV_FREQ_LEN);
  1522. }
  1523. if (scan) {
  1524. memset(&iwe, 0, sizeof(iwe));
  1525. iwe.cmd = IWEVQUAL;
  1526. if (local->last_scan_type == PRISM2_HOSTSCAN) {
  1527. iwe.u.qual.level = le16_to_cpu(scan->sl);
  1528. iwe.u.qual.noise = le16_to_cpu(scan->anl);
  1529. } else {
  1530. iwe.u.qual.level =
  1531. HFA384X_LEVEL_TO_dBm(le16_to_cpu(scan->sl));
  1532. iwe.u.qual.noise =
  1533. HFA384X_LEVEL_TO_dBm(le16_to_cpu(scan->anl));
  1534. }
  1535. iwe.u.qual.updated = IW_QUAL_LEVEL_UPDATED
  1536. | IW_QUAL_NOISE_UPDATED
  1537. | IW_QUAL_QUAL_INVALID
  1538. | IW_QUAL_DBM;
  1539. current_ev = iwe_stream_add_event(info, current_ev, end_buf,
  1540. &iwe, IW_EV_QUAL_LEN);
  1541. }
  1542. memset(&iwe, 0, sizeof(iwe));
  1543. iwe.cmd = SIOCGIWENCODE;
  1544. if (capabilities & WLAN_CAPABILITY_PRIVACY)
  1545. iwe.u.data.flags = IW_ENCODE_ENABLED | IW_ENCODE_NOKEY;
  1546. else
  1547. iwe.u.data.flags = IW_ENCODE_DISABLED;
  1548. iwe.u.data.length = 0;
  1549. current_ev = iwe_stream_add_point(info, current_ev, end_buf, &iwe, "");
  1550. /* TODO: add SuppRates into BSS table */
  1551. if (scan) {
  1552. memset(&iwe, 0, sizeof(iwe));
  1553. iwe.cmd = SIOCGIWRATE;
  1554. current_val = current_ev + iwe_stream_lcp_len(info);
  1555. pos = scan->sup_rates;
  1556. for (i = 0; i < sizeof(scan->sup_rates); i++) {
  1557. if (pos[i] == 0)
  1558. break;
  1559. /* Bit rate given in 500 kb/s units (+ 0x80) */
  1560. iwe.u.bitrate.value = ((pos[i] & 0x7f) * 500000);
  1561. current_val = iwe_stream_add_value(
  1562. info, current_ev, current_val, end_buf, &iwe,
  1563. IW_EV_PARAM_LEN);
  1564. }
  1565. /* Check if we added any event */
  1566. if ((current_val - current_ev) > iwe_stream_lcp_len(info))
  1567. current_ev = current_val;
  1568. }
  1569. /* TODO: add BeaconInt,resp_rate,atim into BSS table */
  1570. buf = kmalloc(MAX_WPA_IE_LEN * 2 + 30, GFP_ATOMIC);
  1571. if (buf && scan) {
  1572. memset(&iwe, 0, sizeof(iwe));
  1573. iwe.cmd = IWEVCUSTOM;
  1574. sprintf(buf, "bcn_int=%d", le16_to_cpu(scan->beacon_interval));
  1575. iwe.u.data.length = strlen(buf);
  1576. current_ev = iwe_stream_add_point(info, current_ev, end_buf,
  1577. &iwe, buf);
  1578. memset(&iwe, 0, sizeof(iwe));
  1579. iwe.cmd = IWEVCUSTOM;
  1580. sprintf(buf, "resp_rate=%d", le16_to_cpu(scan->rate));
  1581. iwe.u.data.length = strlen(buf);
  1582. current_ev = iwe_stream_add_point(info, current_ev, end_buf,
  1583. &iwe, buf);
  1584. if (local->last_scan_type == PRISM2_HOSTSCAN &&
  1585. (capabilities & WLAN_CAPABILITY_IBSS)) {
  1586. memset(&iwe, 0, sizeof(iwe));
  1587. iwe.cmd = IWEVCUSTOM;
  1588. sprintf(buf, "atim=%d", le16_to_cpu(scan->atim));
  1589. iwe.u.data.length = strlen(buf);
  1590. current_ev = iwe_stream_add_point(info, current_ev,
  1591. end_buf, &iwe, buf);
  1592. }
  1593. }
  1594. kfree(buf);
  1595. if (bss && bss->wpa_ie_len > 0 && bss->wpa_ie_len <= MAX_WPA_IE_LEN) {
  1596. memset(&iwe, 0, sizeof(iwe));
  1597. iwe.cmd = IWEVGENIE;
  1598. iwe.u.data.length = bss->wpa_ie_len;
  1599. current_ev = iwe_stream_add_point(info, current_ev, end_buf,
  1600. &iwe, bss->wpa_ie);
  1601. }
  1602. if (bss && bss->rsn_ie_len > 0 && bss->rsn_ie_len <= MAX_WPA_IE_LEN) {
  1603. memset(&iwe, 0, sizeof(iwe));
  1604. iwe.cmd = IWEVGENIE;
  1605. iwe.u.data.length = bss->rsn_ie_len;
  1606. current_ev = iwe_stream_add_point(info, current_ev, end_buf,
  1607. &iwe, bss->rsn_ie);
  1608. }
  1609. return current_ev;
  1610. }
  1611. /* Translate scan data returned from the card to a card independent
  1612. * format that the Wireless Tools will understand - Jean II */
  1613. static inline int prism2_translate_scan(local_info_t *local,
  1614. struct iw_request_info *info,
  1615. char *buffer, int buflen)
  1616. {
  1617. struct hfa384x_hostscan_result *scan;
  1618. int entry, hostscan;
  1619. char *current_ev = buffer;
  1620. char *end_buf = buffer + buflen;
  1621. struct list_head *ptr;
  1622. spin_lock_bh(&local->lock);
  1623. list_for_each(ptr, &local->bss_list) {
  1624. struct hostap_bss_info *bss;
  1625. bss = list_entry(ptr, struct hostap_bss_info, list);
  1626. bss->included = 0;
  1627. }
  1628. hostscan = local->last_scan_type == PRISM2_HOSTSCAN;
  1629. for (entry = 0; entry < local->last_scan_results_count; entry++) {
  1630. int found = 0;
  1631. scan = &local->last_scan_results[entry];
  1632. /* Report every SSID if the AP is using multiple SSIDs. If…