bssdb.h 8.0 KB

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