bssdb.h revision 4e8a7e5fc29697f881f5c358f84df52914908703
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 33#include <linux/skbuff.h> 34#include "80211hdr.h" 35#include "80211mgr.h" 36#include "card.h" 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/*--------------------- Export Classes ----------------------------*/ 71 72/*--------------------- Export Variables --------------------------*/ 73 74/*--------------------- Export Types ------------------------------*/ 75 76// 77// IEEE 802.11 Structures and definitions 78// 79 80typedef enum _NDIS_802_11_NETWORK_TYPE 81{ 82 Ndis802_11FH, 83 Ndis802_11DS, 84 Ndis802_11OFDM5, 85 Ndis802_11OFDM24, 86 Ndis802_11NetworkTypeMax // not a real type, defined as an upper bound 87} NDIS_802_11_NETWORK_TYPE, *PNDIS_802_11_NETWORK_TYPE; 88 89typedef struct tagSERPObject { 90 bool bERPExist; 91 unsigned char byERP; 92} ERPObject, *PERPObject; 93 94typedef struct tagSRSNCapObject { 95 bool bRSNCapExist; 96 unsigned short wRSNCap; 97} SRSNCapObject, *PSRSNCapObject; 98 99// BSS info(AP) 100#pragma pack(1) 101typedef struct tagKnownBSS { 102 // BSS info 103 bool bActive; 104 unsigned char abyBSSID[WLAN_BSSID_LEN]; 105 unsigned int uChannel; 106 unsigned char abySuppRates[WLAN_IEHDR_LEN + WLAN_RATES_MAXLEN + 1]; 107 unsigned char abyExtSuppRates[WLAN_IEHDR_LEN + WLAN_RATES_MAXLEN + 1]; 108 unsigned int uRSSI; 109 unsigned char bySQ; 110 unsigned short wBeaconInterval; 111 unsigned short wCapInfo; 112 unsigned char abySSID[WLAN_IEHDR_LEN + WLAN_SSID_MAXLEN + 1]; 113 unsigned char byRxRate; 114 115 unsigned char byRSSIStatCnt; 116 long ldBmMAX; 117 long ldBmAverage[RSSI_STAT_COUNT]; 118 long ldBmAverRange; 119 //For any BSSID selection improvment 120 bool bSelected; 121 122 //++ WPA informations 123 bool bWPAValid; 124 unsigned char byGKType; 125 unsigned char abyPKType[4]; 126 unsigned short wPKCount; 127 unsigned char abyAuthType[4]; 128 unsigned short wAuthCount; 129 unsigned char byDefaultK_as_PK; 130 unsigned char byReplayIdx; 131 //-- 132 133 //++ WPA2 informations 134 bool bWPA2Valid; 135 unsigned char byCSSGK; 136 unsigned short wCSSPKCount; 137 unsigned char abyCSSPK[4]; 138 unsigned short wAKMSSAuthCount; 139 unsigned char abyAKMSSAuthType[4]; 140 141 //++ wpactl 142 unsigned char byWPAIE[MAX_WPA_IE_LEN]; 143 unsigned char byRSNIE[MAX_WPA_IE_LEN]; 144 unsigned short wWPALen; 145 unsigned short wRSNLen; 146 147 // Clear count 148 unsigned int uClearCount; 149 unsigned int uIELength; 150 QWORD qwBSSTimestamp; 151 QWORD qwLocalTSF; // local TSF timer 152 153// NDIS_802_11_NETWORK_TYPE NetworkTypeInUse; 154 CARD_PHY_TYPE eNetworkTypeInUse; 155 156 ERPObject sERP; 157 SRSNCapObject sRSNCapObj; 158 unsigned char abyIEs[1024]; // don't move this field !! 159} __attribute__ ((__packed__)) 160KnownBSS , *PKnownBSS; 161 162//2006-1116-01,<Add> by NomadZhao 163#pragma pack() 164 165typedef enum tagNODE_STATE { 166 NODE_FREE, 167 NODE_AGED, 168 NODE_KNOWN, 169 NODE_AUTH, 170 NODE_ASSOC 171} NODE_STATE, *PNODE_STATE; 172 173// STA node info 174typedef struct tagKnownNodeDB { 175 // STA info 176 bool bActive; 177 unsigned char abyMACAddr[WLAN_ADDR_LEN]; 178 unsigned char abyCurrSuppRates[WLAN_IEHDR_LEN + WLAN_RATES_MAXLEN]; 179 unsigned char abyCurrExtSuppRates[WLAN_IEHDR_LEN + WLAN_RATES_MAXLEN]; 180 unsigned short wTxDataRate; 181 bool bShortPreamble; 182 bool bERPExist; 183 bool bShortSlotTime; 184 unsigned int uInActiveCount; 185 unsigned short wMaxBasicRate; //Get from byTopOFDMBasicRate or byTopCCKBasicRate which depends on packetTyp. 186 unsigned short wMaxSuppRate; //Records the highest supported rate getting from SuppRates IE and ExtSuppRates IE in Beacon. 187 unsigned short wSuppRate; 188 unsigned char byTopOFDMBasicRate;//Records the highest basic rate in OFDM mode 189 unsigned char byTopCCKBasicRate; //Records the highest basic rate in CCK mode 190 191 // For AP mode 192 struct sk_buff_head sTxPSQueue; 193 unsigned short wCapInfo; 194 unsigned short wListenInterval; 195 unsigned short wAID; 196 NODE_STATE eNodeState; 197 bool bPSEnable; 198 bool bRxPSPoll; 199 unsigned char byAuthSequence; 200 unsigned long ulLastRxJiffer; 201 unsigned char bySuppRate; 202 unsigned long dwFlags; 203 unsigned short wEnQueueCnt; 204 205 bool bOnFly; 206 unsigned long long KeyRSC; 207 unsigned char byKeyIndex; 208 unsigned long dwKeyIndex; 209 unsigned char byCipherSuite; 210 unsigned long dwTSC47_16; 211 unsigned short wTSC15_0; 212 unsigned int uWepKeyLength; 213 unsigned char abyWepKey[WLAN_WEPMAX_KEYLEN]; 214 // 215 // Auto rate fallback vars 216 bool bIsInFallback; 217 unsigned int uAverageRSSI; 218 unsigned int uRateRecoveryTimeout; 219 unsigned int uRatePollTimeout; 220 unsigned int uTxFailures; 221 unsigned int uTxAttempts; 222 223 unsigned int uTxRetry; 224 unsigned int uFailureRatio; 225 unsigned int uRetryRatio; 226 unsigned int uTxOk[MAX_RATE+1]; 227 unsigned int uTxFail[MAX_RATE+1]; 228 unsigned int uTimeCount; 229} KnownNodeDB, *PKnownNodeDB; 230 231/*--------------------- Export Functions --------------------------*/ 232 233PKnownBSS 234BSSpSearchBSSList( 235 void *hDeviceContext, 236 unsigned char *pbyDesireBSSID, 237 unsigned char *pbyDesireSSID, 238 CARD_PHY_TYPE ePhyType 239); 240 241PKnownBSS 242BSSpAddrIsInBSSList( 243 void *hDeviceContext, 244 unsigned char *abyBSSID, 245 PWLAN_IE_SSID pSSID 246); 247 248void 249BSSvClearBSSList( 250 void *hDeviceContext, 251 bool bKeepCurrBSSID 252); 253 254bool 255BSSbInsertToBSSList( 256 void *hDeviceContext, 257 unsigned char *abyBSSIDAddr, 258 QWORD qwTimestamp, 259 unsigned short wBeaconInterval, 260 unsigned short wCapInfo, 261 unsigned char byCurrChannel, 262 PWLAN_IE_SSID pSSID, 263 PWLAN_IE_SUPP_RATES pSuppRates, 264 PWLAN_IE_SUPP_RATES pExtSuppRates, 265 PERPObject psERP, 266 PWLAN_IE_RSN pRSN, 267 PWLAN_IE_RSN_EXT pRSNWPA, 268 PWLAN_IE_COUNTRY pIE_Country, 269 PWLAN_IE_QUIET pIE_Quiet, 270 unsigned int uIELength, 271 unsigned char *pbyIEs, 272 void *pRxPacketContext 273); 274 275bool 276BSSbUpdateToBSSList( 277 void *hDeviceContext, 278 QWORD qwTimestamp, 279 unsigned short wBeaconInterval, 280 unsigned short wCapInfo, 281 unsigned char byCurrChannel, 282 bool bChannelHit, 283 PWLAN_IE_SSID pSSID, 284 PWLAN_IE_SUPP_RATES pSuppRates, 285 PWLAN_IE_SUPP_RATES pExtSuppRates, 286 PERPObject psERP, 287 PWLAN_IE_RSN pRSN, 288 PWLAN_IE_RSN_EXT pRSNWPA, 289 PWLAN_IE_COUNTRY pIE_Country, 290 PWLAN_IE_QUIET pIE_Quiet, 291 PKnownBSS pBSSList, 292 unsigned int uIELength, 293 unsigned char *pbyIEs, 294 void *pRxPacketContext 295); 296 297bool 298BSSDBbIsSTAInNodeDB(void *hDeviceContext, unsigned char *abyDstAddr, 299 unsigned int *puNodeIndex); 300 301void 302BSSvCreateOneNode(void *hDeviceContext, unsigned int *puNodeIndex); 303 304void 305BSSvUpdateAPNode( 306 void *hDeviceContext, 307 unsigned short *pwCapInfo, 308 PWLAN_IE_SUPP_RATES pItemRates, 309 PWLAN_IE_SUPP_RATES pExtSuppRates 310); 311 312void 313BSSvSecondCallBack( 314 void *hDeviceContext 315); 316 317void 318BSSvUpdateNodeTxCounter( 319 void *hDeviceContext, 320 unsigned char byTsr0, 321 unsigned char byTsr1, 322 unsigned char *pbyBuffer, 323 unsigned int uFIFOHeaderSize 324); 325 326void 327BSSvRemoveOneNode( 328 void *hDeviceContext, 329 unsigned int uNodeIndex 330); 331 332void 333BSSvAddMulticastNode( 334 void *hDeviceContext 335); 336 337void 338BSSvClearNodeDBTable( 339 void *hDeviceContext, 340 unsigned int uStartIndex 341); 342 343void 344BSSvClearAnyBSSJoinRecord( 345 void *hDeviceContext 346); 347 348#endif //__BSSDB_H__ 349