scan.h 5.5 KB

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