bssdb.h 9.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308
  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. #include "mib.h"
  36. /*--------------------- Export Definitions -------------------------*/
  37. #define MAX_NODE_NUM 64
  38. #define MAX_BSS_NUM 42
  39. #define LOST_BEACON_COUNT 10 /* 10 sec, XP defined */
  40. #define MAX_PS_TX_BUF 32 // sta max power saving tx buf
  41. #define ADHOC_LOST_BEACON_COUNT 30 // 30 sec, beacon lost for adhoc only
  42. #define MAX_INACTIVE_COUNT 300 // 300 sec, inactive STA node refresh
  43. #define USE_PROTECT_PERIOD 10 // 10 sec, Use protect mode check period
  44. #define ERP_RECOVER_COUNT 30 // 30 sec, ERP support callback check
  45. #define BSS_CLEAR_COUNT 1
  46. #define RSSI_STAT_COUNT 10
  47. #define MAX_CHECK_RSSI_COUNT 8
  48. // STA dwflags
  49. #define WLAN_STA_AUTH BIT0
  50. #define WLAN_STA_ASSOC BIT1
  51. #define WLAN_STA_PS BIT2
  52. #define WLAN_STA_TIM BIT3
  53. // permanent; do not remove entry on expiration
  54. #define WLAN_STA_PERM BIT4
  55. // If 802.1X is used, this flag is
  56. // controlling whether STA is authorized to
  57. // send and receive non-IEEE 802.1X frames
  58. #define WLAN_STA_AUTHORIZED BIT5
  59. //#define MAX_RATE 12
  60. #define MAX_WPA_IE_LEN 64
  61. /*--------------------- Export Classes ----------------------------*/
  62. /*--------------------- Export Variables --------------------------*/
  63. /*--------------------- Export Types ------------------------------*/
  64. //
  65. // IEEE 802.11 Structures and definitions
  66. //
  67. typedef struct tagSERPObject {
  68. BOOL bERPExist;
  69. BYTE byERP;
  70. } ERPObject, *PERPObject;
  71. typedef struct tagSRSNCapObject {
  72. BOOL bRSNCapExist;
  73. WORD wRSNCap;
  74. } SRSNCapObject, *PSRSNCapObject;
  75. // BSS info(AP)
  76. #pragma pack(1)
  77. typedef struct tagKnownBSS {
  78. // BSS info
  79. BOOL bActive;
  80. BYTE abyBSSID[WLAN_BSSID_LEN];
  81. unsigned int uChannel;
  82. BYTE abySuppRates[WLAN_IEHDR_LEN + WLAN_RATES_MAXLEN + 1];
  83. BYTE abyExtSuppRates[WLAN_IEHDR_LEN + WLAN_RATES_MAXLEN + 1];
  84. unsigned int uRSSI;
  85. BYTE bySQ;
  86. WORD wBeaconInterval;
  87. WORD wCapInfo;
  88. BYTE abySSID[WLAN_IEHDR_LEN + WLAN_SSID_MAXLEN + 1];
  89. BYTE byRxRate;
  90. // WORD wATIMWindow;
  91. BYTE byRSSIStatCnt;
  92. signed long ldBmMAX;
  93. signed long ldBmAverage[RSSI_STAT_COUNT];
  94. signed long ldBmAverRange;
  95. //For any BSSID selection improvment
  96. BOOL bSelected;
  97. //++ WPA informations
  98. BOOL bWPAValid;
  99. BYTE byGKType;
  100. BYTE abyPKType[4];
  101. WORD wPKCount;
  102. BYTE abyAuthType[4];
  103. WORD wAuthCount;
  104. BYTE byDefaultK_as_PK;
  105. BYTE byReplayIdx;
  106. //--
  107. //++ WPA2 informations
  108. BOOL bWPA2Valid;
  109. BYTE byCSSGK;
  110. WORD wCSSPKCount;
  111. BYTE abyCSSPK[4];
  112. WORD wAKMSSAuthCount;
  113. BYTE abyAKMSSAuthType[4];
  114. //++ wpactl
  115. BYTE byWPAIE[MAX_WPA_IE_LEN];
  116. BYTE byRSNIE[MAX_WPA_IE_LEN];
  117. WORD wWPALen;
  118. WORD wRSNLen;
  119. // Clear count
  120. unsigned int uClearCount;
  121. // BYTE abyIEs[WLAN_BEACON_FR_MAXLEN];
  122. unsigned int uIELength;
  123. QWORD qwBSSTimestamp;
  124. QWORD qwLocalTSF; // local TSF timer
  125. CARD_PHY_TYPE eNetworkTypeInUse;
  126. ERPObject sERP;
  127. SRSNCapObject sRSNCapObj;
  128. BYTE abyIEs[1024]; // don't move this field !!
  129. } __attribute__ ((__packed__))
  130. KnownBSS , *PKnownBSS;
  131. typedef enum tagNODE_STATE {
  132. NODE_FREE,
  133. NODE_AGED,
  134. NODE_KNOWN,
  135. NODE_AUTH,
  136. NODE_ASSOC
  137. } NODE_STATE, *PNODE_STATE;
  138. // STA node info
  139. typedef struct tagKnownNodeDB {
  140. // STA info
  141. BOOL bActive;
  142. BYTE abyMACAddr[WLAN_ADDR_LEN];
  143. BYTE abyCurrSuppRates[WLAN_IEHDR_LEN + WLAN_RATES_MAXLEN];
  144. BYTE abyCurrExtSuppRates[WLAN_IEHDR_LEN + WLAN_RATES_MAXLEN];
  145. WORD wTxDataRate;
  146. BOOL bShortPreamble;
  147. BOOL bERPExist;
  148. BOOL bShortSlotTime;
  149. unsigned int uInActiveCount;
  150. WORD wMaxBasicRate; //Get from byTopOFDMBasicRate or byTopCCKBasicRate which depends on packetTyp.
  151. WORD wMaxSuppRate; //Records the highest supported rate getting from SuppRates IE and ExtSuppRates IE in Beacon.
  152. WORD wSuppRate;
  153. BYTE byTopOFDMBasicRate;//Records the highest basic rate in OFDM mode
  154. BYTE byTopCCKBasicRate; //Records the highest basic rate in CCK mode
  155. // For AP mode
  156. struct sk_buff_head sTxPSQueue;
  157. WORD wCapInfo;
  158. WORD wListenInterval;
  159. WORD wAID;
  160. NODE_STATE eNodeState;
  161. BOOL bPSEnable;
  162. BOOL bRxPSPoll;
  163. BYTE byAuthSequence;
  164. unsigned long ulLastRxJiffer;
  165. BYTE bySuppRate;
  166. DWORD dwFlags;
  167. WORD wEnQueueCnt;
  168. BOOL bOnFly;
  169. unsigned long long KeyRSC;
  170. BYTE byKeyIndex;
  171. DWORD dwKeyIndex;
  172. BYTE byCipherSuite;
  173. DWORD dwTSC47_16;
  174. WORD wTSC15_0;
  175. unsigned int uWepKeyLength;
  176. BYTE abyWepKey[WLAN_WEPMAX_KEYLEN];
  177. //
  178. // Auto rate fallback vars
  179. BOOL bIsInFallback;
  180. unsigned int uAverageRSSI;
  181. unsigned int uRateRecoveryTimeout;
  182. unsigned int uRatePollTimeout;
  183. unsigned int uTxFailures;
  184. unsigned int uTxAttempts;
  185. unsigned int uTxRetry;
  186. unsigned int uFailureRatio;
  187. unsigned int uRetryRatio;
  188. unsigned int uTxOk[MAX_RATE+1];
  189. unsigned int uTxFail[MAX_RATE+1];
  190. unsigned int uTimeCount;
  191. } KnownNodeDB, *PKnownNodeDB;
  192. /*--------------------- Export Functions --------------------------*/
  193. PKnownBSS BSSpSearchBSSList(void *hDeviceContext,
  194. PBYTE pbyDesireBSSID,
  195. PBYTE pbyDesireSSID,
  196. CARD_PHY_TYPE ePhyType);
  197. PKnownBSS BSSpAddrIsInBSSList(void *hDeviceContext,
  198. PBYTE abyBSSID,
  199. PWLAN_IE_SSID pSSID);
  200. void BSSvClearBSSList(void *hDeviceContext, BOOL bKeepCurrBSSID);
  201. BOOL BSSbInsertToBSSList(void *hDeviceContext,
  202. PBYTE abyBSSIDAddr,
  203. QWORD qwTimestamp,
  204. WORD wBeaconInterval,
  205. WORD wCapInfo,
  206. BYTE byCurrChannel,
  207. PWLAN_IE_SSID pSSID,
  208. PWLAN_IE_SUPP_RATES pSuppRates,
  209. PWLAN_IE_SUPP_RATES pExtSuppRates,
  210. PERPObject psERP,
  211. PWLAN_IE_RSN pRSN,
  212. PWLAN_IE_RSN_EXT pRSNWPA,
  213. PWLAN_IE_COUNTRY pIE_Country,
  214. PWLAN_IE_QUIET pIE_Quiet,
  215. unsigned int uIELength,
  216. PBYTE pbyIEs,
  217. void *pRxPacketContext);
  218. BOOL BSSbUpdateToBSSList(void *hDeviceContext,
  219. QWORD qwTimestamp,
  220. WORD wBeaconInterval,
  221. WORD wCapInfo,
  222. BYTE byCurrChannel,
  223. BOOL bChannelHit,
  224. PWLAN_IE_SSID pSSID,
  225. PWLAN_IE_SUPP_RATES pSuppRates,
  226. PWLAN_IE_SUPP_RATES pExtSuppRates,
  227. PERPObject psERP,
  228. PWLAN_IE_RSN pRSN,
  229. PWLAN_IE_RSN_EXT pRSNWPA,
  230. PWLAN_IE_COUNTRY pIE_Country,
  231. PWLAN_IE_QUIET pIE_Quiet,
  232. PKnownBSS pBSSList,
  233. unsigned int uIELength,
  234. PBYTE pbyIEs,
  235. void *pRxPacketContext);
  236. BOOL BSSbIsSTAInNodeDB(void *hDeviceContext,
  237. PBYTE abyDstAddr,
  238. unsigned int *puNodeIndex);
  239. void BSSvCreateOneNode(void *hDeviceContext, unsigned int *puNodeIndex);
  240. void BSSvUpdateAPNode(void *hDeviceContext,
  241. PWORD pwCapInfo,
  242. PWLAN_IE_SUPP_RATES pItemRates,
  243. PWLAN_IE_SUPP_RATES pExtSuppRates);
  244. void BSSvSecondCallBack(void *hDeviceContext);
  245. void BSSvUpdateNodeTxCounter(void *hDeviceContext,
  246. PSStatCounter pStatistic,
  247. BYTE byTSR,
  248. BYTE byPktNO);
  249. void BSSvRemoveOneNode(void *hDeviceContext,
  250. unsigned int uNodeIndex);
  251. void BSSvAddMulticastNode(void *hDeviceContext);
  252. void BSSvClearNodeDBTable(void *hDeviceContext,
  253. unsigned int uStartIndex);
  254. void BSSvClearAnyBSSJoinRecord(void *hDeviceContext);
  255. #endif /* __BSSDB_H__ */