scan.h 5.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207
  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. /**
  110. * @brief Structure used to store information for each beacon/probe response
  111. */
  112. struct bss_descriptor {
  113. u8 bssid[ETH_ALEN];
  114. u8 ssid[IW_ESSID_MAX_SIZE + 1];
  115. u8 ssid_len;
  116. u16 capability;
  117. /* receive signal strength in dBm */
  118. long rssi;
  119. u32 channel;
  120. u16 beaconperiod;
  121. u32 atimwindow;
  122. /* IW_MODE_AUTO, IW_MODE_ADHOC, IW_MODE_INFRA */
  123. u8 mode;
  124. /* zero-terminated array of supported data rates */
  125. u8 rates[MAX_RATES + 1];
  126. unsigned long last_scanned;
  127. union ieeetypes_phyparamset phyparamset;
  128. union IEEEtypes_ssparamset ssparamset;
  129. struct ieeetypes_countryinfofullset countryinfo;
  130. u8 wpa_ie[MAX_WPA_IE_LEN];
  131. size_t wpa_ie_len;
  132. u8 rsn_ie[MAX_WPA_IE_LEN];
  133. size_t rsn_ie_len;
  134. u8 mesh;
  135. struct list_head list;
  136. };
  137. int lbs_ssid_cmp(u8 *ssid1, u8 ssid1_len, u8 *ssid2, u8 ssid2_len);
  138. struct bss_descriptor *lbs_find_ssid_in_list(struct lbs_adapter *adapter,
  139. u8 *ssid, u8 ssid_len, u8 *bssid, u8 mode,
  140. int channel);
  141. struct bss_descriptor *lbs_find_bssid_in_list(struct lbs_adapter *adapter,
  142. u8 *bssid, u8 mode);
  143. int lbs_find_best_network_ssid(struct lbs_private *priv, u8 *out_ssid,
  144. u8 *out_ssid_len, u8 preferred_mode, u8 *out_mode);
  145. int lbs_send_specific_ssid_scan(struct lbs_private *priv, u8 *ssid,
  146. u8 ssid_len, u8 clear_ssid);
  147. int lbs_cmd_80211_scan(struct lbs_private *priv,
  148. struct cmd_ds_command *cmd,
  149. void *pdata_buf);
  150. int lbs_ret_80211_scan(struct lbs_private *priv,
  151. struct cmd_ds_command *resp);
  152. int lbs_scan_networks(struct lbs_private *priv,
  153. const struct lbs_ioctl_user_scan_cfg *puserscanin,
  154. int full_scan);
  155. struct ifreq;
  156. struct iw_point;
  157. struct iw_param;
  158. struct iw_request_info;
  159. int lbs_get_scan(struct net_device *dev, struct iw_request_info *info,
  160. struct iw_point *dwrq, char *extra);
  161. int lbs_set_scan(struct net_device *dev, struct iw_request_info *info,
  162. struct iw_param *vwrq, char *extra);
  163. void lbs_scan_worker(struct work_struct *work);
  164. #endif