scan.h 5.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215
  1. /**
  2. * Interface for the wlan network scan routines
  3. *
  4. * Driver interface functions and type declarations for the scan module
  5. * implemented in wlan_scan.c.
  6. */
  7. #ifndef _WLAN_SCAN_H
  8. #define _WLAN_SCAN_H
  9. #include <net/ieee80211.h>
  10. #include "hostcmd.h"
  11. /**
  12. * @brief Maximum number of channels that can be sent in a setuserscan ioctl
  13. *
  14. * @sa wlan_ioctl_user_scan_cfg
  15. */
  16. #define WLAN_IOCTL_USER_SCAN_CHAN_MAX 50
  17. //! Infrastructure BSS scan type in wlan_scan_cmd_config
  18. #define WLAN_SCAN_BSS_TYPE_BSS 1
  19. //! Adhoc BSS scan type in wlan_scan_cmd_config
  20. #define WLAN_SCAN_BSS_TYPE_IBSS 2
  21. //! Adhoc or Infrastructure BSS scan type in wlan_scan_cmd_config, no filter
  22. #define WLAN_SCAN_BSS_TYPE_ANY 3
  23. /**
  24. * @brief Structure used internally in the wlan driver to configure a scan.
  25. *
  26. * Sent to the command processing module to configure the firmware
  27. * scan command prepared by libertas_cmd_80211_scan.
  28. *
  29. * @sa wlan_scan_networks
  30. *
  31. */
  32. struct wlan_scan_cmd_config {
  33. /**
  34. * @brief BSS type to be sent in the firmware command
  35. *
  36. * Field can be used to restrict the types of networks returned in the
  37. * scan. valid settings are:
  38. *
  39. * - WLAN_SCAN_BSS_TYPE_BSS (infrastructure)
  40. * - WLAN_SCAN_BSS_TYPE_IBSS (adhoc)
  41. * - WLAN_SCAN_BSS_TYPE_ANY (unrestricted, adhoc and infrastructure)
  42. */
  43. u8 bsstype;
  44. /**
  45. * @brief Specific BSSID used to filter scan results in the firmware
  46. */
  47. u8 bssid[ETH_ALEN];
  48. /**
  49. * @brief length of TLVs sent in command starting at tlvBuffer
  50. */
  51. int tlvbufferlen;
  52. /**
  53. * @brief SSID TLV(s) and ChanList TLVs to be sent in the firmware command
  54. *
  55. * @sa TLV_TYPE_CHANLIST, mrvlietypes_chanlistparamset_t
  56. * @sa TLV_TYPE_SSID, mrvlietypes_ssidparamset_t
  57. */
  58. u8 tlvbuffer[1]; //!< SSID TLV(s) and ChanList TLVs are stored here
  59. };
  60. /**
  61. * @brief IOCTL channel sub-structure sent in wlan_ioctl_user_scan_cfg
  62. *
  63. * Multiple instances of this structure are included in the IOCTL command
  64. * to configure a instance of a scan on the specific channel.
  65. */
  66. struct wlan_ioctl_user_scan_chan {
  67. u8 channumber; //!< channel Number to scan
  68. u8 radiotype; //!< Radio type: 'B/G' band = 0, 'A' band = 1
  69. u8 scantype; //!< Scan type: Active = 0, Passive = 1
  70. u16 scantime; //!< Scan duration in milliseconds; if 0 default used
  71. };
  72. /**
  73. * @brief IOCTL input structure to configure an immediate scan cmd to firmware
  74. *
  75. * Used in the setuserscan (WLAN_SET_USER_SCAN) private ioctl. Specifies
  76. * a number of parameters to be used in general for the scan as well
  77. * as a channel list (wlan_ioctl_user_scan_chan) for each scan period
  78. * desired.
  79. *
  80. * @sa libertas_set_user_scan_ioctl
  81. */
  82. struct wlan_ioctl_user_scan_cfg {
  83. /**
  84. * @brief BSS type to be sent in the firmware command
  85. *
  86. * Field can be used to restrict the types of networks returned in the
  87. * scan. valid settings are:
  88. *
  89. * - WLAN_SCAN_BSS_TYPE_BSS (infrastructure)
  90. * - WLAN_SCAN_BSS_TYPE_IBSS (adhoc)
  91. * - WLAN_SCAN_BSS_TYPE_ANY (unrestricted, adhoc and infrastructure)
  92. */
  93. u8 bsstype;
  94. /**
  95. * @brief Configure the number of probe requests for active chan scans
  96. */
  97. u8 numprobes;
  98. /**
  99. * @brief BSSID filter sent in the firmware command to limit the results
  100. */
  101. u8 bssid[ETH_ALEN];
  102. /* Clear existing scan results matching this BSSID */
  103. u8 clear_bssid;
  104. /**
  105. * @brief SSID filter sent in the firmware command to limit the results
  106. */
  107. char ssid[IW_ESSID_MAX_SIZE];
  108. u8 ssid_len;
  109. /* Clear existing scan results matching this SSID */
  110. u8 clear_ssid;
  111. /**
  112. * @brief Variable number (fixed maximum) of channels to scan up
  113. */
  114. struct wlan_ioctl_user_scan_chan chanlist[WLAN_IOCTL_USER_SCAN_CHAN_MAX];
  115. };
  116. /**
  117. * @brief Structure used to store information for each beacon/probe response
  118. */
  119. struct bss_descriptor {
  120. u8 bssid[ETH_ALEN];
  121. u8 ssid[IW_ESSID_MAX_SIZE + 1];
  122. u8 ssid_len;
  123. u16 capability;
  124. /* receive signal strength in dBm */
  125. long rssi;
  126. u32 channel;
  127. u16 beaconperiod;
  128. u32 atimwindow;
  129. /* IW_MODE_AUTO, IW_MODE_ADHOC, IW_MODE_INFRA */
  130. u8 mode;
  131. /* zero-terminated array of supported data rates */
  132. u8 rates[MAX_RATES + 1];
  133. unsigned long last_scanned;
  134. union ieeetypes_phyparamset phyparamset;
  135. union IEEEtypes_ssparamset ssparamset;
  136. struct ieeetypes_countryinfofullset countryinfo;
  137. u8 wpa_ie[MAX_WPA_IE_LEN];
  138. size_t wpa_ie_len;
  139. u8 rsn_ie[MAX_WPA_IE_LEN];
  140. size_t rsn_ie_len;
  141. u8 mesh;
  142. struct list_head list;
  143. };
  144. int libertas_ssid_cmp(u8 *ssid1, u8 ssid1_len, u8 *ssid2, u8 ssid2_len);
  145. struct bss_descriptor * libertas_find_ssid_in_list(wlan_adapter * adapter,
  146. u8 *ssid, u8 ssid_len, u8 * bssid, u8 mode,
  147. int channel);
  148. struct bss_descriptor * libertas_find_bssid_in_list(wlan_adapter * adapter,
  149. u8 * bssid, u8 mode);
  150. int libertas_find_best_network_ssid(wlan_private * priv, u8 *out_ssid,
  151. u8 *out_ssid_len, u8 preferred_mode, u8 *out_mode);
  152. int libertas_send_specific_ssid_scan(wlan_private * priv, u8 *ssid,
  153. u8 ssid_len, u8 clear_ssid);
  154. int libertas_cmd_80211_scan(wlan_private * priv,
  155. struct cmd_ds_command *cmd,
  156. void *pdata_buf);
  157. int libertas_ret_80211_scan(wlan_private * priv,
  158. struct cmd_ds_command *resp);
  159. int wlan_scan_networks(wlan_private * priv,
  160. const struct wlan_ioctl_user_scan_cfg * puserscanin,
  161. int full_scan);
  162. struct ifreq;
  163. struct iw_point;
  164. struct iw_param;
  165. struct iw_request_info;
  166. int libertas_get_scan(struct net_device *dev, struct iw_request_info *info,
  167. struct iw_point *dwrq, char *extra);
  168. int libertas_set_scan(struct net_device *dev, struct iw_request_info *info,
  169. struct iw_param *vwrq, char *extra);
  170. void libertas_scan_worker(struct work_struct *work);
  171. #endif /* _WLAN_SCAN_H */