• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1 /******************************************************************************
2  *
3  * Copyright(c) 2007 - 2017 Realtek Corporation.
4  *
5  * This program is free software; you can redistribute it and/or modify it
6  * under the terms of version 2 of the GNU General Public License as
7  * published by the Free Software Foundation.
8  *
9  * This program is distributed in the hope that it will be useful, but WITHOUT
10  * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
11  * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for
12  * more details.
13  *
14  *****************************************************************************/
15 #ifndef __WLAN_BSSDEF_H__
16 #define __WLAN_BSSDEF_H__
17 
18 
19 #define MAX_IE_SZ	768
20 
21 
22 #ifdef PLATFORM_LINUX
23 
24 #define NDIS_802_11_LENGTH_SSID         32
25 #define NDIS_802_11_LENGTH_RATES        8
26 #define NDIS_802_11_LENGTH_RATES_EX     16
27 
28 typedef unsigned char   NDIS_802_11_MAC_ADDRESS[ETH_ALEN];
29 typedef long    		NDIS_802_11_RSSI;           /* in dBm */
30 typedef unsigned char   NDIS_802_11_RATES[NDIS_802_11_LENGTH_RATES];        /* Set of 8 data rates */
31 typedef unsigned char   NDIS_802_11_RATES_EX[NDIS_802_11_LENGTH_RATES_EX];  /* Set of 16 data rates */
32 
33 typedef struct _NDIS_802_11_SSID {
34 	u32  SsidLength;
35 	u8  Ssid[32];
36 } NDIS_802_11_SSID, *PNDIS_802_11_SSID;
37 
38 /*
39 	FW will only save the channel number in DSConfig.
40 	ODI Handler will convert the channel number to freq. number.
41 */
42 typedef struct _NDIS_802_11_CONFIGURATION {
43 	u32           Length;             /* Length of structure */
44 	u32           BeaconPeriod;       /* units are Kusec */
45 	u32           ATIMWindow;         /* units are Kusec */
46 	u32           DSConfig;           /* channel number */
47 } NDIS_802_11_CONFIGURATION, *PNDIS_802_11_CONFIGURATION;
48 
49 typedef enum _NDIS_802_11_NETWORK_INFRASTRUCTURE {
50 	Ndis802_11IBSS,
51 	Ndis802_11Infrastructure,
52 	Ndis802_11AutoUnknown,
53 	Ndis802_11InfrastructureMax,     /* Not a real value, defined as upper bound */
54 	Ndis802_11APMode,
55 	Ndis802_11Monitor,
56 	Ndis802_11_mesh,
57 } NDIS_802_11_NETWORK_INFRASTRUCTURE, *PNDIS_802_11_NETWORK_INFRASTRUCTURE;
58 
59 typedef struct _NDIS_802_11_FIXED_IEs {
60 	u8  Timestamp[8];
61 	u16  BeaconInterval;
62 	u16  Capabilities;
63 } NDIS_802_11_FIXED_IEs, *PNDIS_802_11_FIXED_IEs;
64 
65 typedef struct _NDIS_802_11_VARIABLE_IEs {
66 	u8  ElementID;
67 	u8  Length;
68 	u8  data[1];
69 } NDIS_802_11_VARIABLE_IEs, *PNDIS_802_11_VARIABLE_IEs;
70 
71 typedef enum _NDIS_802_11_AUTHENTICATION_MODE {
72 	Ndis802_11AuthModeOpen,
73 	Ndis802_11AuthModeShared,
74 	Ndis802_11AuthModeAutoSwitch,
75 	Ndis802_11AuthModeWPA,
76 	Ndis802_11AuthModeWPAPSK,
77 	Ndis802_11AuthModeWPANone,
78 	Ndis802_11AuthModeWAPI,
79 	Ndis802_11AuthModeMax               /* Not a real mode, defined as upper bound */
80 } NDIS_802_11_AUTHENTICATION_MODE, *PNDIS_802_11_AUTHENTICATION_MODE;
81 
82 typedef enum _NDIS_802_11_WEP_STATUS {
83 	Ndis802_11WEPEnabled,
84 	Ndis802_11Encryption1Enabled = Ndis802_11WEPEnabled,
85 	Ndis802_11WEPDisabled,
86 	Ndis802_11EncryptionDisabled = Ndis802_11WEPDisabled,
87 	Ndis802_11WEPKeyAbsent,
88 	Ndis802_11Encryption1KeyAbsent = Ndis802_11WEPKeyAbsent,
89 	Ndis802_11WEPNotSupported,
90 	Ndis802_11EncryptionNotSupported = Ndis802_11WEPNotSupported,
91 	Ndis802_11Encryption2Enabled,
92 	Ndis802_11Encryption2KeyAbsent,
93 	Ndis802_11Encryption3Enabled,
94 	Ndis802_11Encryption3KeyAbsent,
95 	Ndis802_11_EncrypteionWAPI
96 } NDIS_802_11_WEP_STATUS, *PNDIS_802_11_WEP_STATUS,
97 NDIS_802_11_ENCRYPTION_STATUS, *PNDIS_802_11_ENCRYPTION_STATUS;
98 
99 typedef struct _NDIS_802_11_WEP {
100 	u32     Length;        /* Length of this structure */
101 	u32     KeyIndex;      /* 0 is the per-client key, 1-N are the global keys */
102 	u32     KeyLength;     /* length of key in bytes */
103 	u8     KeyMaterial[16];/* variable length depending on above field */
104 } NDIS_802_11_WEP, *PNDIS_802_11_WEP;
105 
106 #endif /* end of #ifdef PLATFORM_LINUX */
107 
108 #ifdef PLATFORM_FREEBSD
109 
110 #define NDIS_802_11_LENGTH_SSID         32
111 #define NDIS_802_11_LENGTH_RATES        8
112 #define NDIS_802_11_LENGTH_RATES_EX     16
113 
114 typedef unsigned char   NDIS_802_11_MAC_ADDRESS[ETH_ALEN];
115 typedef long    		NDIS_802_11_RSSI;           /* in dBm */
116 typedef unsigned char   NDIS_802_11_RATES[NDIS_802_11_LENGTH_RATES];        /* Set of 8 data rates */
117 typedef unsigned char   NDIS_802_11_RATES_EX[NDIS_802_11_LENGTH_RATES_EX];  /* Set of 16 data rates */
118 
119 
120 typedef struct _NDIS_802_11_SSID {
121 	u32  SsidLength;
122 	u8  Ssid[32];
123 } NDIS_802_11_SSID, *PNDIS_802_11_SSID;
124 
125 /*
126 	FW will only save the channel number in DSConfig.
127 	ODI Handler will convert the channel number to freq. number.
128 */
129 typedef struct _NDIS_802_11_CONFIGURATION {
130 	u32           Length;             /* Length of structure */
131 	u32           BeaconPeriod;       /* units are Kusec */
132 	u32           ATIMWindow;         /* units are Kusec */
133 	u32           DSConfig;           /* channel number */
134 } NDIS_802_11_CONFIGURATION, *PNDIS_802_11_CONFIGURATION;
135 
136 typedef enum _NDIS_802_11_NETWORK_INFRASTRUCTURE {
137 	Ndis802_11IBSS,
138 	Ndis802_11Infrastructure,
139 	Ndis802_11AutoUnknown,
140 	Ndis802_11InfrastructureMax,     /* Not a real value, defined as upper bound */
141 	Ndis802_11APMode
142 } NDIS_802_11_NETWORK_INFRASTRUCTURE, *PNDIS_802_11_NETWORK_INFRASTRUCTURE;
143 
144 typedef struct _NDIS_802_11_FIXED_IEs {
145 	u8  Timestamp[8];
146 	u16  BeaconInterval;
147 	u16  Capabilities;
148 } NDIS_802_11_FIXED_IEs, *PNDIS_802_11_FIXED_IEs;
149 
150 typedef struct _NDIS_802_11_VARIABLE_IEs {
151 	u8  ElementID;
152 	u8  Length;
153 	u8  data[1];
154 } NDIS_802_11_VARIABLE_IEs, *PNDIS_802_11_VARIABLE_IEs;
155 
156 typedef enum _NDIS_802_11_AUTHENTICATION_MODE {
157 	Ndis802_11AuthModeOpen,
158 	Ndis802_11AuthModeShared,
159 	Ndis802_11AuthModeAutoSwitch,
160 	Ndis802_11AuthModeWPA,
161 	Ndis802_11AuthModeWPAPSK,
162 	Ndis802_11AuthModeWPANone,
163 	Ndis802_11AuthModeMax               /* Not a real mode, defined as upper bound */
164 } NDIS_802_11_AUTHENTICATION_MODE, *PNDIS_802_11_AUTHENTICATION_MODE;
165 
166 typedef enum _NDIS_802_11_WEP_STATUS {
167 	Ndis802_11WEPEnabled,
168 	Ndis802_11Encryption1Enabled = Ndis802_11WEPEnabled,
169 	Ndis802_11WEPDisabled,
170 	Ndis802_11EncryptionDisabled = Ndis802_11WEPDisabled,
171 	Ndis802_11WEPKeyAbsent,
172 	Ndis802_11Encryption1KeyAbsent = Ndis802_11WEPKeyAbsent,
173 	Ndis802_11WEPNotSupported,
174 	Ndis802_11EncryptionNotSupported = Ndis802_11WEPNotSupported,
175 	Ndis802_11Encryption2Enabled,
176 	Ndis802_11Encryption2KeyAbsent,
177 	Ndis802_11Encryption3Enabled,
178 	Ndis802_11Encryption3KeyAbsent
179 } NDIS_802_11_WEP_STATUS, *PNDIS_802_11_WEP_STATUS,
180 NDIS_802_11_ENCRYPTION_STATUS, *PNDIS_802_11_ENCRYPTION_STATUS;
181 
182 
183 typedef struct _NDIS_802_11_WEP {
184 	u32     Length;        /* Length of this structure */
185 	u32     KeyIndex;      /* 0 is the per-client key, 1-N are the global keys */
186 	u32     KeyLength;     /* length of key in bytes */
187 	u8     KeyMaterial[16];/* variable length depending on above field */
188 } NDIS_802_11_WEP, *PNDIS_802_11_WEP;
189 
190 #endif /* PLATFORM_FREEBSD */
191 
192 #ifndef Ndis802_11APMode
193 #define Ndis802_11APMode (Ndis802_11InfrastructureMax+1)
194 #endif
195 
196 typedef struct _WLAN_PHY_INFO {
197 	u8	SignalStrength;/* (in percentage) */
198 	u8	SignalQuality;/* (in percentage) */
199 	u8	Optimum_antenna;  /* for Antenna diversity */
200 	u8	is_cck_rate;	/* 1:cck_rate */
201 	s8	rx_snr[4];
202 #ifdef CONFIG_RTW_80211K
203 	u32	free_cnt; 	/* freerun counter */
204 	u8	rm_en_cap[5];
205 #endif
206 } WLAN_PHY_INFO, *PWLAN_PHY_INFO;
207 
208 typedef struct _WLAN_BCN_INFO {
209 	/* these infor get from rtw_get_encrypt_info when
210 	 *	 * translate scan to UI */
211 	u8 encryp_protocol;/* ENCRYP_PROTOCOL_E: OPEN/WEP/WPA/WPA2/WAPI */
212 	int group_cipher; /* WPA/WPA2 group cipher */
213 	int pairwise_cipher;/* //WPA/WPA2/WEP pairwise cipher */
214 	int is_8021x;
215 
216 	/* bwmode 20/40 and ch_offset UP/LOW */
217 	unsigned short	ht_cap_info;
218 	unsigned char	ht_info_infos_0;
219 } WLAN_BCN_INFO, *PWLAN_BCN_INFO;
220 
221 enum bss_type {
222 	BSS_TYPE_UNDEF,
223 	BSS_TYPE_PROB_REQ = 1,
224 	BSS_TYPE_BCN = 2,
225 	BSS_TYPE_PROB_RSP = 3,
226 };
227 
228 /* temporally add #pragma pack for structure alignment issue of
229 *   WLAN_BSSID_EX and get_WLAN_BSSID_EX_sz()
230 */
231 typedef struct _WLAN_BSSID_EX {
232 	u32  Length;
233 	NDIS_802_11_MAC_ADDRESS  MacAddress;
234 	u8  Reserved[2];/* [0]: IS beacon frame , bss_type*/
235 	NDIS_802_11_SSID  Ssid;
236 	NDIS_802_11_SSID  mesh_id;
237 	u32  Privacy;
238 	NDIS_802_11_RSSI  Rssi;/* (in dBM,raw data ,get from PHY) */
239 	NDIS_802_11_CONFIGURATION  Configuration;
240 	NDIS_802_11_NETWORK_INFRASTRUCTURE  InfrastructureMode;
241 	NDIS_802_11_RATES_EX  SupportedRates;
242 	WLAN_PHY_INFO	PhyInfo;
243 	u32  IELength;
244 	u8  IEs[MAX_IE_SZ];	/* (timestamp, beacon interval, and capability information) */
245 #ifdef	CONFIG_LAYER2_ROAMING
246 	u64 tsf;
247 #endif
248 }
249 __attribute__((packed)) WLAN_BSSID_EX, *PWLAN_BSSID_EX;
250 
251 #define BSS_EX_IES(bss_ex) ((bss_ex)->IEs)
252 #define BSS_EX_IES_LEN(bss_ex) ((bss_ex)->IELength)
253 #define BSS_EX_FIXED_IE_OFFSET(bss_ex) ((bss_ex)->Reserved[0] == BSS_TYPE_PROB_REQ ? 0 : 12)
254 #define BSS_EX_TLV_IES(bss_ex) (BSS_EX_IES((bss_ex)) + BSS_EX_FIXED_IE_OFFSET((bss_ex)))
255 #define BSS_EX_TLV_IES_LEN(bss_ex) (BSS_EX_IES_LEN((bss_ex)) - BSS_EX_FIXED_IE_OFFSET((bss_ex)))
256 
get_WLAN_BSSID_EX_sz(WLAN_BSSID_EX * bss)257 __inline  static uint get_WLAN_BSSID_EX_sz(WLAN_BSSID_EX *bss)
258 {
259 	return sizeof(WLAN_BSSID_EX) - MAX_IE_SZ + bss->IELength;
260 }
261 
262 struct beacon_keys {
263 	u8 ssid[IW_ESSID_MAX_SIZE];
264 	u32 ssid_len;
265 	u8 ch;
266 	u8 bw;
267 	u8 offset;
268 	u8 proto_cap; /* PROTO_CAP_XXX */
269 	u8 rate_set[12];
270 	u8 rate_num;
271 	int encryp_protocol;
272 	int pairwise_cipher;
273 	int group_cipher;
274 	u32 akm;
275 };
276 
277 struct	wlan_network {
278 	_list	list;
279 	int	network_type;	/* refer to ieee80211.h for WIRELESS_11A/B/G */
280 	int	fixed;			/* set to fixed when not to be removed as site-surveying */
281 	systime last_scanned; /* timestamp for the network */
282 	systime last_non_hidden_ssid_ap;
283 #ifdef CONFIG_RTW_MESH
284 #if CONFIG_RTW_MESH_ACNODE_PREVENT
285 	systime acnode_stime;
286 	systime acnode_notify_etime;
287 #endif
288 #endif
289 	int	aid;			/* will only be valid when a BSS is joinned. */
290 	int	join_res;
291 	struct beacon_keys bcn_keys;
292 	bool bcn_keys_valid;
293 	WLAN_BSSID_EX	network; /* must be the last item */
294 };
295 
296 enum VRTL_CARRIER_SENSE {
297 	DISABLE_VCS,
298 	ENABLE_VCS,
299 	AUTO_VCS
300 };
301 
302 enum VCS_TYPE {
303 	NONE_VCS,
304 	RTS_CTS,
305 	CTS_TO_SELF
306 };
307 
308 
309 
310 
311 #define PWR_CAM 0
312 #define PWR_MINPS 1
313 #define PWR_MAXPS 2
314 #define PWR_UAPSD 3
315 #define PWR_VOIP 4
316 
317 
318 enum UAPSD_MAX_SP {
319 	NO_LIMIT,
320 	TWO_MSDU,
321 	FOUR_MSDU,
322 	SIX_MSDU
323 };
324 
325 
326 /* john */
327 #define NUM_PRE_AUTH_KEY 16
328 #define NUM_PMKID_CACHE NUM_PRE_AUTH_KEY
329 
330 #endif /* #ifndef WLAN_BSSDEF_H_ */
331