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