scan.h 5.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205
  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. /**
  12. * @brief Maximum number of channels that can be sent in a setuserscan ioctl
  13. *
  14. * @sa lbs_ioctl_user_scan_cfg
  15. */
  16. #define LBS_IOCTL_USER_SCAN_CHAN_MAX 50
  17. //! Infrastructure BSS scan type in lbs_scan_cmd_config
  18. #define LBS_SCAN_BSS_TYPE_BSS 1
  19. //! Adhoc BSS scan type in lbs_scan_cmd_config
  20. #define LBS_SCAN_BSS_TYPE_IBSS 2
  21. //! Adhoc or Infrastructure BSS scan type in lbs_scan_cmd_config, no filter
  22. #define LBS_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 lbs_cmd_80211_scan.
  28. *
  29. * @sa lbs_scan_networks
  30. *
  31. */
  32. struct lbs_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. * - LBS_SCAN_BSS_TYPE_BSS (infrastructure)
  40. * - LBS_SCAN_BSS_TYPE_IBSS (adhoc)
  41. * - LBS_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 lbs_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 lbs_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 (LBS_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 (lbs_ioctl_user_scan_chan) for each scan period
  78. * desired.
  79. *
  80. * @sa lbs_set_user_scan_ioctl
  81. */
  82. struct lbs_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. * - LBS_SCAN_BSS_TYPE_BSS (infrastructure)
  90. * - LBS_SCAN_BSS_TYPE_IBSS (adhoc)
  91. * - LBS_SCAN_BSS_TYPE_ANY (unrestricted, adhoc and infrastructure)
  92. */
  93. u8 bsstype;
  94. /**
  95. * @brief BSSID filter sent in the firmware command to limit the results
  96. */
  97. u8 bssid[ETH_ALEN];
  98. /* Clear existing scan results matching this BSSID */
  99. u8 clear_bssid;
  100. /**
  101. * @brief SSID filter sent in the firmware command to limit the results
  102. */
  103. char ssid[IW_ESSID_MAX_SIZE];
  104. u8 ssid_len;
  105. /* Clear existing scan results matching this SSID */
  106. u8 clear_ssid;
  107. };
  108. /**
  109. * @brief Structure used to store information for each beacon/probe response
  110. */
  111. struct bss_descriptor {
  112. u8 bssid[ETH_ALEN];
  113. u8 ssid[IW_ESSID_MAX_SIZE + 1];
  114. u8 ssid_len;
  115. u16 capability;
  116. /* receive signal strength in dBm */
  117. long rssi;
  118. u32 channel;
  119. u16 beaconperiod;
  120. u32 atimwindow;
  121. /* IW_MODE_AUTO, IW_MODE_ADHOC, IW_MODE_INFRA */
  122. u8 mode;
  123. /* zero-terminated array of supported data rates */
  124. u8 rates[MAX_RATES + 1];
  125. unsigned long last_scanned;
  126. union ieeetypes_phyparamset phyparamset;
  127. union IEEEtypes_ssparamset ssparamset;
  128. struct ieeetypes_countryinfofullset countryinfo;
  129. u8 wpa_ie[MAX_WPA_IE_LEN];
  130. size_t wpa_ie_len;
  131. u8 rsn_ie[MAX_WPA_IE_LEN];
  132. size_t rsn_ie_len;
  133. u8 mesh;
  134. struct list_head list;
  135. };
  136. int lbs_ssid_cmp(u8 *ssid1, u8 ssid1_len, u8 *ssid2, u8 ssid2_len);
  137. struct bss_descriptor *lbs_find_ssid_in_list(struct lbs_private *priv,
  138. u8 *ssid, u8 ssid_len, u8 *bssid, u8 mode,
  139. int channel);
  140. struct bss_descriptor *lbs_find_bssid_in_list(struct lbs_private *priv,
  141. u8 *bssid, u8 mode);
  142. int lbs_find_best_network_ssid(struct lbs_private *priv, u8 *out_ssid,
  143. u8 *out_ssid_len, u8 preferred_mode, u8 *out_mode);
  144. int lbs_send_specific_ssid_scan(struct lbs_private *priv, u8 *ssid,
  145. u8 ssid_len, u8 clear_ssid);
  146. int lbs_cmd_80211_scan(struct lbs_private *priv,
  147. struct cmd_ds_command *cmd,
  148. void *pdata_buf);
  149. int lbs_ret_80211_scan(struct lbs_private *priv,
  150. struct cmd_ds_command *resp);
  151. int lbs_scan_networks(struct lbs_private *priv,
  152. const struct lbs_ioctl_user_scan_cfg *puserscanin,
  153. int full_scan);
  154. struct ifreq;
  155. struct iw_point;
  156. struct iw_param;
  157. struct iw_request_info;
  158. int lbs_get_scan(struct net_device *dev, struct iw_request_info *info,
  159. struct iw_point *dwrq, char *extra);
  160. int lbs_set_scan(struct net_device *dev, struct iw_request_info *info,
  161. struct iw_param *vwrq, char *extra);
  162. void lbs_scan_worker(struct work_struct *work);
  163. #endif