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