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