1 /******************************************************************************
2  * Copyright (c) 2013-2016 Realtek Semiconductor Corp.
3  *
4  * Licensed under the Apache License, Version 2.0 (the "License");
5  * you may not use this file except in compliance with the License.
6  * You may obtain a copy of the License at
7  *
8  *     http://www.apache.org/licenses/LICENSE-2.0
9  *
10  * Unless required by applicable law or agreed to in writing, software
11  * distributed under the License is distributed on an "AS IS" BASIS,
12  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13  * See the License for the specific language governing permissions and
14  * limitations under the License.
15   ******************************************************************************
16   * @file    wifi_structures.h
17   * @author
18   * @version
19   * @brief   This file provides the data structures used for wlan API.
20   ******************************************************************************
21   */
22 
23 #ifndef _WIFI_STRUCTURES_H
24 #define _WIFI_STRUCTURES_H
25 
26 /** @addtogroup nic NIC
27  *  @ingroup    wlan
28  *  @brief      NIC functions
29  *  @{
30  */
31 
32 //#include <freertos/freertos_service.h>
33 #include "wifi_constants.h"
34 #include "dlist.h"
35 #ifdef	__cplusplus
36 extern "C" {
37 #endif
38 
39 #if defined(__IAR_SYSTEMS_ICC__) || defined (__GNUC__) || defined(__CC_ARM) || (defined(__ARMCC_VERSION) && (__ARMCC_VERSION >= 6010050))
40 #pragma pack(1)
41 #endif
42 
43 /**
44   * @brief  The structure is used to describe the SSID.
45   */
46 typedef struct rtw_ssid {
47     unsigned char len;     /**< SSID length */
48     unsigned char val[33]; /**< SSID name (AP name)  */
49 } rtw_ssid_t;
50 #if defined(__IAR_SYSTEMS_ICC__) || defined (__GNUC__) || defined(__CC_ARM) || (defined(__ARMCC_VERSION) && (__ARMCC_VERSION >= 6010050))
51 #pragma pack()
52 #endif
53 
54 #if defined(__IAR_SYSTEMS_ICC__) || defined (__GNUC__) || defined(__CC_ARM) || (defined(__ARMCC_VERSION) && (__ARMCC_VERSION >= 6010050))
55 #pragma pack(1)
56 #endif
57 
58 /**
59   * @brief  The structure is used to describe the unique 6-byte MAC address.
60   */
61 typedef struct rtw_mac {
62     unsigned char octet[6]; /**< Unique 6-byte MAC address */
63 } rtw_mac_t;
64 #if defined(__IAR_SYSTEMS_ICC__) || defined (__GNUC__) || defined(__CC_ARM) || (defined(__ARMCC_VERSION) && (__ARMCC_VERSION >= 6010050))
65 #pragma pack()
66 #endif
67 
68 /**
69   * @brief  The structure is used to describe the setting about SSID,
70   *			security type, password and default channel, used to start AP mode.
71   * @note  The data length of string pointed by ssid should not exceed 32,
72   *        and the data length of string pointed by password should not exceed 64.
73   */
74 typedef struct rtw_ap_info {
75 	rtw_ssid_t 			ssid;
76 	rtw_security_t		security_type;
77 	unsigned char 		*password;
78 	int 				password_len;
79 	int					channel;
80 }rtw_ap_info_t;
81 
82 /**
83   * @brief  The structure is used to describe the station mode setting about SSID,
84   *			security type and password, used when connecting to an AP.
85   * @note  The data length of string pointed by ssid should not exceed 32,
86   *        and the data length of string pointed by password should not exceed 64.
87   */
88 typedef struct rtw_network_info {
89 	rtw_ssid_t 			ssid;
90 	rtw_mac_t			bssid;
91 	rtw_security_t		security_type;
92 	unsigned char 		*password;
93 	int 				password_len;
94 	int					key_id;
95 }rtw_network_info_t;
96 
97 #if defined(__IAR_SYSTEMS_ICC__) || defined(__GNUC__) || defined(__CC_ARM) || (defined(__ARMCC_VERSION) && (__ARMCC_VERSION >= 6010050))
98 #pragma pack(1)
99 #endif
100 
101 /**
102   * @brief  The structure is used to describe the scan result of the AP.
103   */
104 typedef struct rtw_scan_result {
105     rtw_ssid_t              SSID;             /**< Service Set Identification (i.e. Name of Access Point)                    */
106     rtw_mac_t               BSSID;            /**< Basic Service Set Identification (i.e. MAC address of Access Point)       */
107     signed short		                  signal_strength;  /**< Receive Signal Strength Indication in dBm. <-90=Very poor, >-30=Excellent */
108     rtw_bss_type_t          bss_type;         /**< Network type                                                              */
109     rtw_security_t          security;         /**< Security type                                                             */
110     rtw_wps_type_t          wps_type;         /**< WPS type                                                                  */
111     unsigned int                      channel;          /**< Radio channel that the AP beacon was received on                          */
112     rtw_802_11_band_t       band;             /**< Radio band                                                                */
113 } rtw_scan_result_t;
114 #if defined(__IAR_SYSTEMS_ICC__) || defined(__GNUC__) || defined(__CC_ARM) || (defined(__ARMCC_VERSION) && (__ARMCC_VERSION >= 6010050))
115 #pragma pack()
116 #endif
117 
118 /**
119   * @brief  The structure is used to describe the data needed by scan result handler function.
120   */
121 typedef struct rtw_scan_handler_result {
122     rtw_scan_result_t ap_details;
123     rtw_bool_t        scan_complete;
124     void*               user_data;
125 
126 } rtw_scan_handler_result_t;
127 
128 #if defined(__IAR_SYSTEMS_ICC__) || defined(__GNUC__) || defined(__CC_ARM) || (defined(__ARMCC_VERSION) && (__ARMCC_VERSION >= 6010050))
129 #pragma pack(1)
130 #endif
131 
132 /**
133   * @brief  The structure is used to store the WIFI setting gotten from WIFI driver.
134   */
135 typedef struct rtw_wifi_setting {
136 	rtw_mode_t		mode;
137 	unsigned char 		ssid[33];
138 	unsigned char		channel;
139 	rtw_security_t		security_type;
140 	unsigned char 		password[65];
141 	unsigned char		key_idx;
142 }rtw_wifi_setting_t;
143 #if defined(__IAR_SYSTEMS_ICC__) || defined(__GNUC__) || defined(__CC_ARM) || (defined(__ARMCC_VERSION) && (__ARMCC_VERSION >= 6010050))
144 #pragma pack()
145 #endif
146 
147 /**
148   * @brief  The structure is used to describe the setting when configure the network.
149   */
150 typedef struct rtw_wifi_config {
151 	unsigned int		boot_mode;
152 	unsigned char 		ssid[32];
153 	unsigned char		ssid_len;
154 	unsigned char		security_type;
155 	unsigned char		password[65];
156 	unsigned char		password_len;
157 	unsigned char		channel;
158 } rtw_wifi_config_t;
159 
160 /**
161   * @brief  The structure is used to describe the maclist.
162   */
163 typedef struct
164 {
165     unsigned int    count;         /**< Number of MAC addresses in the list    */
166     rtw_mac_t mac_list[1];   /**< Variable length array of MAC addresses */
167 } rtw_maclist_t;
168 
169 /**
170   * @brief  The structure is used to describe the bss info of the network.\n
171   *			It include the version, BSSID, beacon_period, capability, SSID,
172   *			channel, atm_window, dtim_period, RSSI e.g.
173   */
174 typedef struct {
175     unsigned int      version;                /**< version field */
176     unsigned int      length;                 /**< byte length of data in this record,   */
177                                           /* starting at version and including IEs */
178     rtw_mac_t     BSSID;
179     unsigned short      beacon_period;          /**< units are Kusec */
180     unsigned short      capability;             /**< Capability information */
181     unsigned char       SSID_len;
182     unsigned char       SSID[32];
183     unsigned char       channel;
184 //    struct {
185 //        uint32_t    count;                /* # rates in this set */
186 //        uint8_t   rates[16];              /* rates in 500kbps units w/hi bit set if basic */
187 //    } rateset;                            /* supported rates */
188 //    rtw_chanspec_t  chanspec;              /* chanspec for bss */
189     unsigned short      atim_window;            /**< units are Kusec */
190     unsigned char       dtim_period;            /**< DTIM period */
191     signed short       RSSI;                   /**< receive signal strength (in dBm) */
192 
193     unsigned char       n_cap;                  /**< BSS is 802.11N Capable */
194     unsigned int      nbss_cap;               /**< 802.11N BSS Capabilities (based on HT_CAP_*) */
195     unsigned char       basic_mcs[MCSSET_LEN];  /**< 802.11N BSS required MCS set */
196 
197     unsigned short      ie_offset;              /**< offset at which IEs start, from beginning */
198     unsigned int      ie_length;             /**< byte length of Information Elements */
199 } rtw_bss_info_t;
200 
201 /**
202   * @brief  The structure is used to set WIFI packet filter pattern.
203   */
204 typedef struct {
205 	unsigned short	offset;     /**< Offset in bytes to start filtering (referenced to the start of the ethernet packet) */
206 	unsigned short	mask_size;  /**< Size of the mask in bytes */
207 	unsigned char*	mask;       /**< Pattern mask bytes to be ANDed with the pattern eg. "\xff00" (must be in network byte order) */
208 	unsigned char*	pattern;    /**< Pattern bytes used to filter eg. "\x0800"  (must be in network byte order) */
209 } rtw_packet_filter_pattern_t;
210 
211 typedef struct ieee80211_frame_info{
212 	unsigned short i_fc;
213 	unsigned short i_dur;
214 	unsigned char i_addr1[6];
215 	unsigned char i_addr2[6];
216 	unsigned char i_addr3[6];
217 	unsigned short i_seq;
218 	unsigned char bssid[6];
219 	unsigned char encrypt;
220 	signed char rssi;
221 #if defined(CONFIG_UNSUPPORT_PLCPHDR_RPT) && CONFIG_UNSUPPORT_PLCPHDR_RPT
222 	rtw_rx_type_t type;
223 #endif
224 }ieee80211_frame_info_t;
225 
226 #if defined(CONFIG_UNSUPPORT_PLCPHDR_RPT) && CONFIG_UNSUPPORT_PLCPHDR_RPT
227 typedef struct rtw_rx_info {
228 	unsigned short length;	// length without FCS
229 	unsigned char filter;		// 1: HT-20 2T and not LDPC pkt; 2: HT-40 2T and not LDPC pkt; 3: LDPC pkt
230 	signed char rssi;	// -128~-1
231 	unsigned short channel;	// channel which this pkt in
232 	unsigned char agg:1;		// aggregation pkt or not. If an AMPDU contains only one MPDU then above 'length' is the antual pkt length without FCS, buuut if it contains multiple MPDUs then above 'length' is useless because it cannot tell how many MPDUs are contained and how long is each MPDU.
233 	unsigned char mcs:7;		// mcs index
234 }rtw_rx_info_t;
235 
236 
237 struct rtw_plcp_info {
238 	struct rtw_plcp_info *prev;
239 	struct rtw_plcp_info *next;
240 	rtw_rx_info_t rtw_plcp_info;
241 
242 };
243 
244 struct rtw_rx_buffer {
245 	struct rtw_plcp_info *head;
246 	struct rtw_plcp_info *tail;
247 };
248 
249 #endif
250 
251 typedef struct {
252 	char filter_id;
253 	rtw_packet_filter_pattern_t patt;
254 	rtw_packet_filter_rule_t rule;
255 	unsigned char enable;
256 }rtw_packet_filter_info_t;
257 
258 typedef struct rtw_mac_filter_list{
259 	struct list_head node;
260 	unsigned char mac_addr[6];
261 }rtw_mac_filter_list_t;
262 
263 typedef struct wowlan_pattern {
264 	unsigned char eth_da[6];
265 	unsigned char eth_sa[6];
266 	unsigned char eth_proto_type[2];
267 	unsigned char header_len[1];
268 	//unsigned char header_content[8];
269 	unsigned char ip_proto[1];
270 	//unsigned char checksum[2];
271 	unsigned char ip_sa[4];
272 	unsigned char ip_da[4];
273     unsigned char src_port[2];
274     unsigned char dest_port[2];
275 	unsigned char mask[5];
276 } wowlan_pattern_t;
277 
278 
279 #ifdef	__cplusplus
280 }
281 #endif
282 
283 /*\@}*/
284 
285 #endif /* _WIFI_STRUCTURES_H */
286