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