bssdb.h 9.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366
  1. /*
  2. * Copyright (c) 1996, 2003 VIA Networking Technologies, Inc.
  3. * All rights reserved.
  4. *
  5. * This program is free software; you can redistribute it and/or modify
  6. * it under the terms of the GNU General Public License as published by
  7. * the Free Software Foundation; either version 2 of the License, or
  8. * (at your option) any later version.
  9. *
  10. * This program is distributed in the hope that it will be useful,
  11. * but WITHOUT ANY WARRANTY; without even the implied warranty of
  12. * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  13. * GNU General Public License for more details.
  14. *
  15. * You should have received a copy of the GNU General Public License along
  16. * with this program; if not, write to the Free Software Foundation, Inc.,
  17. * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
  18. *
  19. *
  20. * File: bssdb.h
  21. *
  22. * Purpose: Handles the Basic Service Set & Node Database functions
  23. *
  24. * Author: Lyndon Chen
  25. *
  26. * Date: July 16, 2002
  27. *
  28. */
  29. #ifndef __BSSDB_H__
  30. #define __BSSDB_H__
  31. #include <linux/skbuff.h>
  32. #include "80211hdr.h"
  33. #include "80211mgr.h"
  34. #include "card.h"
  35. /*--------------------- Export Definitions -------------------------*/
  36. #define MAX_NODE_NUM 64
  37. #define MAX_BSS_NUM 42
  38. #define LOST_BEACON_COUNT 10 // 10 sec, XP defined
  39. #define MAX_PS_TX_BUF 32 // sta max power saving tx buf
  40. #define ADHOC_LOST_BEACON_COUNT 30 // 30 sec, beacon lost for adhoc only
  41. #define MAX_INACTIVE_COUNT 300 // 300 sec, inactive STA node refresh
  42. #define USE_PROTECT_PERIOD 10 // 10 sec, Use protect mode check period
  43. #define ERP_RECOVER_COUNT 30 // 30 sec, ERP support callback check
  44. #define BSS_CLEAR_COUNT 1
  45. #define RSSI_STAT_COUNT 10
  46. #define MAX_CHECK_RSSI_COUNT 8
  47. // STA dwflags
  48. #define WLAN_STA_AUTH BIT0
  49. #define WLAN_STA_ASSOC BIT1
  50. #define WLAN_STA_PS BIT2
  51. #define WLAN_STA_TIM BIT3
  52. // permanent; do not remove entry on expiration
  53. #define WLAN_STA_PERM BIT4
  54. // If 802.1X is used, this flag is
  55. // controlling whether STA is authorized to
  56. // send and receive non-IEEE 802.1X frames
  57. #define WLAN_STA_AUTHORIZED BIT5
  58. #define MAX_RATE 12
  59. #define MAX_WPA_IE_LEN 64
  60. /*--------------------- Export Classes ----------------------------*/
  61. /*--------------------- Export Variables --------------------------*/
  62. /*--------------------- Export Types ------------------------------*/
  63. //
  64. // IEEE 802.11 Structures and definitions
  65. //
  66. typedef enum _NDIS_802_11_NETWORK_TYPE
  67. {
  68. Ndis802_11FH,
  69. Ndis802_11DS,
  70. Ndis802_11OFDM5,
  71. Ndis802_11OFDM24,
  72. Ndis802_11NetworkTypeMax // not a real type, defined as an upper bound
  73. } NDIS_802_11_NETWORK_TYPE, *PNDIS_802_11_NETWORK_TYPE;
  74. typedef struct tagSERPObject {
  75. bool bERPExist;
  76. unsigned char byERP;
  77. }ERPObject, *PERPObject;
  78. typedef struct tagSRSNCapObject {
  79. bool bRSNCapExist;
  80. unsigned short wRSNCap;
  81. }SRSNCapObject, *PSRSNCapObject;
  82. // BSS info(AP)
  83. #pragma pack(1)
  84. typedef struct tagKnownBSS {
  85. // BSS info
  86. bool bActive;
  87. unsigned char abyBSSID[WLAN_BSSID_LEN];
  88. unsigned int uChannel;
  89. unsigned char abySuppRates[WLAN_IEHDR_LEN + WLAN_RATES_MAXLEN + 1];
  90. unsigned char abyExtSuppRates[WLAN_IEHDR_LEN + WLAN_RATES_MAXLEN + 1];
  91. unsigned int uRSSI;
  92. unsigned char bySQ;
  93. unsigned short wBeaconInterval;
  94. unsigned short wCapInfo;
  95. unsigned char abySSID[WLAN_IEHDR_LEN + WLAN_SSID_MAXLEN + 1];
  96. unsigned char byRxRate;
  97. // unsigned short wATIMWindow;
  98. unsigned char byRSSIStatCnt;
  99. long ldBmMAX;
  100. long ldBmAverage[RSSI_STAT_COUNT];
  101. long ldBmAverRange;
  102. //For any BSSID selection improvment
  103. bool bSelected;
  104. //++ WPA informations
  105. bool bWPAValid;
  106. unsigned char byGKType;
  107. unsigned char abyPKType[4];
  108. unsigned short wPKCount;
  109. unsigned char abyAuthType[4];
  110. unsigned short wAuthCount;
  111. unsigned char byDefaultK_as_PK;
  112. unsigned char byReplayIdx;
  113. //--
  114. //++ WPA2 informations
  115. bool bWPA2Valid;
  116. unsigned char byCSSGK;
  117. unsigned short wCSSPKCount;
  118. unsigned char abyCSSPK[4];
  119. unsigned short wAKMSSAuthCount;
  120. unsigned char abyAKMSSAuthType[4];
  121. //++ wpactl
  122. unsigned char byWPAIE[MAX_WPA_IE_LEN];
  123. unsigned char byRSNIE[MAX_WPA_IE_LEN];
  124. unsigned short wWPALen;
  125. unsigned short wRSNLen;
  126. // Clear count
  127. unsigned int uClearCount;
  128. // unsigned char abyIEs[WLAN_BEACON_FR_MAXLEN];
  129. unsigned int uIELength;
  130. QWORD qwBSSTimestamp;
  131. QWORD qwLocalTSF; // local TSF timer
  132. // NDIS_802_11_NETWORK_TYPE NetworkTypeInUse;
  133. CARD_PHY_TYPE eNetworkTypeInUse;
  134. ERPObject sERP;
  135. SRSNCapObject sRSNCapObj;
  136. unsigned char abyIEs[1024]; // don't move this field !!
  137. }__attribute__ ((__packed__))
  138. KnownBSS , *PKnownBSS;
  139. //2006-1116-01,<Add> by NomadZhao
  140. #pragma pack()
  141. typedef enum tagNODE_STATE {
  142. NODE_FREE,
  143. NODE_AGED,
  144. NODE_KNOWN,
  145. NODE_AUTH,
  146. NODE_ASSOC
  147. } NODE_STATE, *PNODE_STATE;
  148. // STA node info
  149. typedef struct tagKnownNodeDB {
  150. // STA info
  151. bool bActive;
  152. unsigned char abyMACAddr[WLAN_ADDR_LEN];
  153. unsigned char abyCurrSuppRates[WLAN_IEHDR_LEN + WLAN_RATES_MAXLEN];
  154. unsigned char abyCurrExtSuppRates[WLAN_IEHDR_LEN + WLAN_RATES_MAXLEN];
  155. unsigned short wTxDataRate;
  156. bool bShortPreamble;
  157. bool bERPExist;
  158. bool bShortSlotTime;
  159. unsigned int uInActiveCount;
  160. unsigned short wMaxBasicRate; //Get from byTopOFDMBasicRate or byTopCCKBasicRate which depends on packetTyp.
  161. unsigned short wMaxSuppRate; //Records the highest supported rate getting from SuppRates IE and ExtSuppRates IE in Beacon.
  162. unsigned short wSuppRate;
  163. unsigned char byTopOFDMBasicRate;//Records the highest basic rate in OFDM mode
  164. unsigned char byTopCCKBasicRate; //Records the highest basic rate in CCK mode
  165. // For AP mode
  166. struct sk_buff_head sTxPSQueue;
  167. unsigned short wCapInfo;
  168. unsigned short wListenInterval;
  169. unsigned short wAID;
  170. NODE_STATE eNodeState;
  171. bool bPSEnable;
  172. bool bRxPSPoll;
  173. unsigned char byAuthSequence;
  174. unsigned long ulLastRxJiffer;
  175. unsigned char bySuppRate;
  176. unsigned long dwFlags;
  177. unsigned short wEnQueueCnt;
  178. bool bOnFly;
  179. unsigned long long KeyRSC;
  180. unsigned char byKeyIndex;
  181. unsigned long dwKeyIndex;
  182. unsigned char byCipherSuite;
  183. unsigned long dwTSC47_16;
  184. unsigned short wTSC15_0;
  185. unsigned int uWepKeyLength;
  186. unsigned char abyWepKey[WLAN_WEPMAX_KEYLEN];
  187. //
  188. // Auto rate fallback vars
  189. bool bIsInFallback;
  190. unsigned int uAverageRSSI;
  191. unsigned int uRateRecoveryTimeout;
  192. unsigned int uRatePollTimeout;
  193. unsigned int uTxFailures;
  194. unsigned int uTxAttempts;
  195. unsigned int uTxRetry;
  196. unsigned int uFailureRatio;
  197. unsigned int uRetryRatio;
  198. unsigned int uTxOk[MAX_RATE+1];
  199. unsigned int uTxFail[MAX_RATE+1];
  200. unsigned int uTimeCount;
  201. } KnownNodeDB, *PKnownNodeDB;
  202. /*--------------------- Export Functions --------------------------*/
  203. PKnownBSS
  204. BSSpSearchBSSList(
  205. void *hDeviceContext,
  206. unsigned char *pbyDesireBSSID,
  207. unsigned char *pbyDesireSSID,
  208. CARD_PHY_TYPE ePhyType
  209. );
  210. PKnownBSS
  211. BSSpAddrIsInBSSList(
  212. void *hDeviceContext,
  213. unsigned char *abyBSSID,
  214. PWLAN_IE_SSID pSSID
  215. );
  216. void
  217. BSSvClearBSSList(
  218. void *hDeviceContext,
  219. bool bKeepCurrBSSID
  220. );
  221. bool
  222. BSSbInsertToBSSList(
  223. void *hDeviceContext,
  224. unsigned char *abyBSSIDAddr,
  225. QWORD qwTimestamp,
  226. unsigned short wBeaconInterval,
  227. unsigned short wCapInfo,
  228. unsigned char byCurrChannel,
  229. PWLAN_IE_SSID pSSID,
  230. PWLAN_IE_SUPP_RATES pSuppRates,
  231. PWLAN_IE_SUPP_RATES pExtSuppRates,
  232. PERPObject psERP,
  233. PWLAN_IE_RSN pRSN,
  234. PWLAN_IE_RSN_EXT pRSNWPA,
  235. PWLAN_IE_COUNTRY pIE_Country,
  236. PWLAN_IE_QUIET pIE_Quiet,
  237. unsigned int uIELength,
  238. unsigned char *pbyIEs,
  239. void *pRxPacketContext
  240. );
  241. bool
  242. BSSbUpdateToBSSList(
  243. void *hDeviceContext,
  244. QWORD qwTimestamp,
  245. unsigned short wBeaconInterval,
  246. unsigned short wCapInfo,
  247. unsigned char byCurrChannel,
  248. bool bChannelHit,
  249. PWLAN_IE_SSID pSSID,
  250. PWLAN_IE_SUPP_RATES pSuppRates,
  251. PWLAN_IE_SUPP_RATES pExtSuppRates,
  252. PERPObject psERP,
  253. PWLAN_IE_RSN pRSN,
  254. PWLAN_IE_RSN_EXT pRSNWPA,
  255. PWLAN_IE_COUNTRY pIE_Country,
  256. PWLAN_IE_QUIET pIE_Quiet,
  257. PKnownBSS pBSSList,
  258. unsigned int uIELength,
  259. unsigned char *pbyIEs,
  260. void *pRxPacketContext
  261. );
  262. bool
  263. BSSDBbIsSTAInNodeDB(void *hDeviceContext, unsigned char *abyDstAddr,
  264. unsigned int *puNodeIndex);
  265. void
  266. BSSvCreateOneNode(void *hDeviceContext, unsigned int *puNodeIndex);
  267. void
  268. BSSvUpdateAPNode(
  269. void *hDeviceContext,
  270. unsigned short *pwCapInfo,
  271. PWLAN_IE_SUPP_RATES pItemRates,
  272. PWLAN_IE_SUPP_RATES pExtSuppRates
  273. );
  274. void
  275. BSSvSecondCallBack(
  276. void *hDeviceContext
  277. );
  278. void
  279. BSSvUpdateNodeTxCounter(
  280. void *hDeviceContext,
  281. unsigned char byTsr0,
  282. unsigned char byTsr1,
  283. unsigned char *pbyBuffer,
  284. unsigned int uFIFOHeaderSize
  285. );
  286. void
  287. BSSvRemoveOneNode(
  288. void *hDeviceContext,
  289. unsigned int uNodeIndex
  290. );
  291. void
  292. BSSvAddMulticastNode(
  293. void *hDeviceContext
  294. );
  295. void
  296. BSSvClearNodeDBTable(
  297. void *hDeviceContext,
  298. unsigned int uStartIndex
  299. );
  300. void
  301. BSSvClearAnyBSSJoinRecord(
  302. void *hDeviceContext
  303. );
  304. #endif //__BSSDB_H__