2 * Copyright (c) 1996, 2003 VIA Networking Technologies, Inc.
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.
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.
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.
22 * Purpose: Handles the Basic Service Set & Node Database functions
33 #include <linux/skbuff.h>
38 #define MAX_NODE_NUM 64
39 #define MAX_BSS_NUM 42
40 #define LOST_BEACON_COUNT 10 // 10 sec, XP defined
41 #define MAX_PS_TX_BUF 32 // sta max power saving tx buf
42 #define ADHOC_LOST_BEACON_COUNT 30 // 30 sec, beacon lost for adhoc only
43 #define MAX_INACTIVE_COUNT 300 // 300 sec, inactive STA node refresh
45 #define USE_PROTECT_PERIOD 10 // 10 sec, Use protect mode check period
46 #define ERP_RECOVER_COUNT 30 // 30 sec, ERP support callback check
47 #define BSS_CLEAR_COUNT 1
49 #define RSSI_STAT_COUNT 10
50 #define MAX_CHECK_RSSI_COUNT 8
53 #define WLAN_STA_AUTH BIT0
54 #define WLAN_STA_ASSOC BIT1
55 #define WLAN_STA_PS BIT2
56 #define WLAN_STA_TIM BIT3
57 // permanent; do not remove entry on expiration
58 #define WLAN_STA_PERM BIT4
59 // If 802.1X is used, this flag is
60 // controlling whether STA is authorized to
61 // send and receive non-IEEE 802.1X frames
62 #define WLAN_STA_AUTHORIZED BIT5
66 #define MAX_WPA_IE_LEN 64
69 // IEEE 802.11 Structures and definitions
72 typedef enum _NDIS_802_11_NETWORK_TYPE {
77 Ndis802_11NetworkTypeMax // not a real type, defined as an upper bound
78 } NDIS_802_11_NETWORK_TYPE, *PNDIS_802_11_NETWORK_TYPE;
80 typedef struct tagSERPObject {
83 } ERPObject, *PERPObject;
85 typedef struct tagSRSNCapObject {
87 unsigned short wRSNCap;
88 } SRSNCapObject, *PSRSNCapObject;
92 typedef struct tagKnownBSS {
94 unsigned char abyBSSID[WLAN_BSSID_LEN];
95 unsigned int uChannel;
96 unsigned char abySuppRates[WLAN_IEHDR_LEN + WLAN_RATES_MAXLEN + 1];
97 unsigned char abyExtSuppRates[WLAN_IEHDR_LEN + WLAN_RATES_MAXLEN + 1];
100 unsigned short wBeaconInterval;
101 unsigned short wCapInfo;
102 unsigned char abySSID[WLAN_IEHDR_LEN + WLAN_SSID_MAXLEN + 1];
103 unsigned char byRxRate;
105 unsigned char byRSSIStatCnt;
107 long ldBmAverage[RSSI_STAT_COUNT];
112 unsigned char byGKType;
113 unsigned char abyPKType[4];
114 unsigned short wPKCount;
115 unsigned char abyAuthType[4];
116 unsigned short wAuthCount;
117 unsigned char byDefaultK_as_PK;
118 unsigned char byReplayIdx;
121 unsigned char byCSSGK;
122 unsigned short wCSSPKCount;
123 unsigned char abyCSSPK[4];
124 unsigned short wAKMSSAuthCount;
125 unsigned char abyAKMSSAuthType[4];
127 unsigned char byWPAIE[MAX_WPA_IE_LEN];
128 unsigned char byRSNIE[MAX_WPA_IE_LEN];
129 unsigned short wWPALen;
130 unsigned short wRSNLen;
132 unsigned int uClearCount;
133 unsigned int uIELength;
137 CARD_PHY_TYPE eNetworkTypeInUse;
140 SRSNCapObject sRSNCapObj;
141 unsigned char abyIEs[1024];
142 } __attribute__ ((__packed__))
143 KnownBSS , *PKnownBSS;
147 typedef enum tagNODE_STATE {
153 } NODE_STATE, *PNODE_STATE;
156 typedef struct tagKnownNodeDB {
158 unsigned char abyMACAddr[WLAN_ADDR_LEN];
159 unsigned char abyCurrSuppRates[WLAN_IEHDR_LEN + WLAN_RATES_MAXLEN];
160 unsigned char abyCurrExtSuppRates[WLAN_IEHDR_LEN + WLAN_RATES_MAXLEN];
161 unsigned short wTxDataRate;
165 unsigned int uInActiveCount;
166 unsigned short wMaxBasicRate; //Get from byTopOFDMBasicRate or byTopCCKBasicRate which depends on packetTyp.
167 unsigned short wMaxSuppRate; //Records the highest supported rate getting from SuppRates IE and ExtSuppRates IE in Beacon.
168 unsigned short wSuppRate;
169 unsigned char byTopOFDMBasicRate;//Records the highest basic rate in OFDM mode
170 unsigned char byTopCCKBasicRate; //Records the highest basic rate in CCK mode
173 struct sk_buff_head sTxPSQueue;
174 unsigned short wCapInfo;
175 unsigned short wListenInterval;
177 NODE_STATE eNodeState;
180 unsigned char byAuthSequence;
181 unsigned long ulLastRxJiffer;
182 unsigned char bySuppRate;
183 unsigned long dwFlags;
184 unsigned short wEnQueueCnt;
187 unsigned long long KeyRSC;
188 unsigned char byKeyIndex;
189 unsigned long dwKeyIndex;
190 unsigned char byCipherSuite;
191 unsigned long dwTSC47_16;
192 unsigned short wTSC15_0;
193 unsigned int uWepKeyLength;
194 unsigned char abyWepKey[WLAN_WEPMAX_KEYLEN];
195 // Auto rate fallback vars
197 unsigned int uAverageRSSI;
198 unsigned int uRateRecoveryTimeout;
199 unsigned int uRatePollTimeout;
200 unsigned int uTxFailures;
201 unsigned int uTxAttempts;
203 unsigned int uTxRetry;
204 unsigned int uFailureRatio;
205 unsigned int uRetryRatio;
206 unsigned int uTxOk[MAX_RATE+1];
207 unsigned int uTxFail[MAX_RATE+1];
208 unsigned int uTimeCount;
209 } KnownNodeDB, *PKnownNodeDB;
213 void *hDeviceContext,
214 unsigned char *pbyDesireBSSID,
215 unsigned char *pbyDesireSSID,
216 CARD_PHY_TYPE ePhyType
221 void *hDeviceContext,
222 unsigned char *abyBSSID,
228 void *hDeviceContext,
234 void *hDeviceContext,
235 unsigned char *abyBSSIDAddr,
237 unsigned short wBeaconInterval,
238 unsigned short wCapInfo,
239 unsigned char byCurrChannel,
241 PWLAN_IE_SUPP_RATES pSuppRates,
242 PWLAN_IE_SUPP_RATES pExtSuppRates,
245 PWLAN_IE_RSN_EXT pRSNWPA,
246 PWLAN_IE_COUNTRY pIE_Country,
247 PWLAN_IE_QUIET pIE_Quiet,
248 unsigned int uIELength,
249 unsigned char *pbyIEs,
250 void *pRxPacketContext
255 void *hDeviceContext,
257 unsigned short wBeaconInterval,
258 unsigned short wCapInfo,
259 unsigned char byCurrChannel,
262 PWLAN_IE_SUPP_RATES pSuppRates,
263 PWLAN_IE_SUPP_RATES pExtSuppRates,
266 PWLAN_IE_RSN_EXT pRSNWPA,
267 PWLAN_IE_COUNTRY pIE_Country,
268 PWLAN_IE_QUIET pIE_Quiet,
270 unsigned int uIELength,
271 unsigned char *pbyIEs,
272 void *pRxPacketContext
276 BSSDBbIsSTAInNodeDB(void *hDeviceContext, unsigned char *abyDstAddr,
277 unsigned int *puNodeIndex);
280 BSSvCreateOneNode(void *hDeviceContext, unsigned int *puNodeIndex);
284 void *hDeviceContext,
285 unsigned short *pwCapInfo,
286 PWLAN_IE_SUPP_RATES pItemRates,
287 PWLAN_IE_SUPP_RATES pExtSuppRates
296 BSSvUpdateNodeTxCounter(
297 void *hDeviceContext,
298 unsigned char byTsr0,
299 unsigned char byTsr1,
300 unsigned char *pbyBuffer,
301 unsigned int uFIFOHeaderSize
306 void *hDeviceContext,
307 unsigned int uNodeIndex
311 BSSvAddMulticastNode(
316 BSSvClearNodeDBTable(
317 void *hDeviceContext,
318 unsigned int uStartIndex
322 BSSvClearAnyBSSJoinRecord(