• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1 /*
2  * Copyright (C) 2021 HiSilicon (Shanghai) Technologies CO., LIMITED.
3  *
4  * This program is free software; you can redistribute it and/or
5  * modify it under the terms of the GNU General Public License
6  * as published by the Free Software Foundation; either version 2
7  * of the License, or (at your option) any later version.
8  *
9  * This program is distributed in the hope that it will be useful,
10  * but WITHOUT ANY WARRANTY; without even the implied warranty of
11  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
12  * GNU General Public License for more details.
13  *
14  * You should have received a copy of the GNU General Public License
15  * along with this program; if not, write to the Free Software
16  * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301, USA.
17  */
18 
19 #ifndef __MAC_FRAME_H__
20 #define __MAC_FRAME_H__
21 
22 /* ****************************************************************************
23   1 其他头文件包含
24 **************************************************************************** */
25 #include "wlan_types.h"
26 #include "oam_ext_if.h"
27 #include "wlan_mib.h"
28 
29 #ifdef __cplusplus
30 #if __cplusplus
31 extern "C" {
32 #endif
33 #endif
34 
35 /* ****************************************************************************
36   2 宏定义
37 **************************************************************************** */
38 #define MAC_IEEE80211_FCTL_FTYPE 0x000c /* 帧类型掩码 */
39 #define MAC_IEEE80211_FCTL_STYPE 0x00f0 /* 帧子类型掩码 */
40 
41 #define MAC_IEEE80211_FTYPE_MGMT 0x0000 /* 管理帧 */
42 #define MAC_IEEE80211_FTYPE_CTL  0x0004  /* 控制帧 */
43 #define MAC_IEEE80211_FTYPE_DATA 0x0008 /* 数据帧 */
44 
45 /* A-MSDU情况下,submsdu的偏移宏 */
46 #define MAC_SUBMSDU_HEADER_LEN          14          /* |da = 6|sa = 6|len = 2| submsdu的头的长度 */
47 #define MAC_SUBMSDU_LENGTH_OFFSET       12          /* submsdu的长度字段的偏移值 */
48 #define MAC_SUBMSDU_DA_OFFSET           0           /* submsdu的目的地址的偏移值 */
49 #define MAC_SUBMSDU_SA_OFFSET           6           /* submsdu的源地址的偏移值 */
50 
51 #define MAC_80211_FRAME_LEN                 24      /* 非四地址情况下,MAC帧头的长度 */
52 #define MAC_80211_CTL_HEADER_LEN            16      /* 控制帧帧头长度 */
53 #define MAC_80211_4ADDR_FRAME_LEN           30
54 #define MAC_80211_QOS_FRAME_LEN             26
55 #define MAC_80211_QOS_4ADDR_FRAME_LEN       32
56 #define MAC_80211_QOS_HTC_4ADDR_FRAME_LEN   36
57 
58 /* 信息元素长度定义 */
59 #define MAC_IE_HDR_LEN              2   /* 信息元素头部 1字节EID + 1字节长度 */
60 #define MAC_TIME_STAMP_LEN          8
61 #define MAC_BEACON_INTERVAL_LEN     2
62 #define MAC_CAP_INFO_LEN            2
63 #define MAC_SSID_OFFSET             12
64 #define MAC_LISTEN_INT_LEN          2
65 #define MAC_MAX_SUPRATES            8   /* WLAN_EID_RATES最大支持8个速率 */
66 #define MAC_DSPARMS_LEN             1   /* ds parameter set 长度 */
67 #define MAC_DEFAULT_TIM_LEN         4
68 #define MAC_TIM_LEN_EXCEPT_PVB      3   /* DTIM Period、DTIM Count与BitMap Control三个字段的长度 */
69 #define MAC_CONTRY_CODE_LEN         3   /* 国家码长度为3 */
70 #define MAC_PWR_CONSTRAINT_LEN      1   /* 功率限制ie长度为1 */
71 #define MAC_QUIET_IE_LEN            6   /* quiet信息元素长度 */
72 #define MAC_TPCREP_IE_LEN           2
73 #define MAC_ERP_IE_LEN              1
74 #define MAC_OBSS_SCAN_IE_LEN        14
75 #define MAC_XCAPS_LEN               1
76 #define MAC_XCAPS_EX_LEN            8   /* 初始值为5,由于11ac Operating Mode Notification特性标志为bit62 长度修改为8 */
77 #define MAC_WMM_PARAM_LEN           24  /* WMM parameters ie */
78 #define MAC_WMM_INFO_LEN            7   /* WMM info ie */
79 #define MAC_QOS_INFO_LEN            1
80 #define MAC_AC_PARAM_LEN            4
81 #define MAC_BSS_LOAD_IE_LEN         5
82 #define MAC_COUNTRY_REG_FIELD_LEN   3
83 #define MAC_LIS_INTERVAL_IE_LEN     2   /* listen interval信息元素长度 */
84 #define MAC_AID_LEN                 2
85 #define MAC_PWR_CAP_LEN             2
86 #define MAC_AUTH_ALG_LEN            2
87 #define MAC_AUTH_TRANS_SEQ_NUM_LEN  2   /* transaction seq num信息元素长度 */
88 #define MAC_STATUS_CODE_LEN         2
89 #define MAC_VHT_CAP_IE_LEN          12
90 #define MAC_VHT_INFO_IE_LEN         5
91 #define MAC_VHT_CAP_INFO_FIELD_LEN  4
92 #define MAC_TIMEOUT_INTERVAL_INFO_LEN           5
93 #define MAC_VHT_CAP_RX_MCS_MAP_FIELD_LEN        2  /* vht cap ie rx_mcs_map field length */
94 #define MAC_VHT_CAP_RX_HIGHEST_DATA_FIELD_LEN   2  /* vht cap ie rx_highest_data field length */
95 #define MAC_VHT_CAP_TX_MCS_MAP_FIELD_LEN        2  /* vht cap ie tx_mcs_map field length */
96 #define MAC_VHT_OPERN_INFO_FIELD_LEN            3  /* vht opern ie information field length */
97 #define MAC_2040_COEX_LEN                       1  /* 20/40 BSS Coexistence element */
98 #define MAC_2040_INTOLCHREPORT_LEN_MIN          1  /* 20/40 BSS Intolerant Channel Report element */
99 #define MAC_CHANSWITCHANN_LEN                   3  /* Channel Switch Announcement element */
100 #define MAC_SA_QUERY_LEN                        4  /* SA Query element len */
101 #define MAC_RSN_VERSION_LEN                     2  /* wpa/RSN version len */
102 #define MAC_RSN_CIPHER_COUNT_LEN                2  /* RSN IE Cipher count len */
103 #define MAC_11N_TXBF_CAP_OFFSET                 23
104 #define MAC_HT_NOTIFY_CHANNEL_WIDTH_LEN         3
105 #define MAC_WIDE_BW_CH_SWITCH_IE_LEN            3
106 #define MAC_CHANSWITCHANN_IE_LEN                3
107 #define MAC_EXT_CHANSWITCHANN_IE_LEN            4
108 #define MAC_MIN_TIM_LEN                         4
109 #define MAC_MIN_RSN_LEN                         2
110 #define MAC_MIN_WPS_IE_LEN                      5
111 #define MAC_VHT_OPERN_LEN                       5  /* vht opern ie length */
112 #define MAC_MIN_XRATE_LEN                       1
113 #define MAC_SEC_CH_OFFSET_IE_LEN                1
114 #ifdef _PRE_WLAN_FEATURE_MESH_ROM
115 #define MAC_IE_VENDOR_SPEC_MESH_HDR_LEN 7 /* Element ID(1) + Length(1) + OUI(3) + TYPE(1) +SUBTYPE(1) */
116 #define MAC_IE_VENDOR_SPEC_MESH_MIN_LEN 5 /* OUI(3) + TYPE(1) +SUBTYPE(1) */
117 #define MAC_IE_VENDOR_SPEC_MESH_SUBTYPE_POS 6
118 #define MAC_ACTION_CATEGORY_LEN 1
119 #define MAC_ACTION_CODE_LEN 1
120 #define MAC_MIN_MESH_CONF_LEN 7
121 #endif
122 /* LLC头相关信息 */
123 #define MAC_LLC_HEARDER_LEN        8      /* LLC头长度 */
124 #define MAC_PROTOCOL_TYPE_LEN      2      /* 协议族类型长度 */
125 #define MAC_PROTOCOL_TYPE_IP       0x0800 /* IP协议族 */
126 
127 /* IP头相关信息 */
128 #define MAC_IP_HEADER_LEN          20     /* IP头固定字段的长度 */
129 #define MAC_IP_ADDRE_LEN           4      /* IP地址的长度 */
130 #define MAC_PROTOCOL_TYPE_TCP      0x06
131 
132 /* TCP头相关信息 */
133 #define MAC_TCP_HEADER_LEN         20     /* TCP头的固定字段的长度 */
134 #define MAC_TCP_FLAGS              13     /* TCP flags字段距TCP头首部的长度 */
135 /* UDP头相关信息 */
136 #define MAC_UDP_HEADER_LEN         8      /* UDP头的固定字段的长度 */
137 
138 #ifdef _PRE_WLAN_FEATURE_OPMODE_NOTIFY
139 #define MAC_OPMODE_NOTIFY_LEN       1              /* Operating Mode Notification element len */
140 #endif
141 
142 #define MAC_P2P_ATTRIBUTE_HDR_LEN    3   /* P2P_ATTRIBUTE信息元素头部 1字节ATTRIBUTE + 2字节长度 */
143 #define MAC_P2P_LISTEN_CHN_ATTR_LEN  5   /* LISTEN CHANNEL ATTRIBUTE长度 */
144 #define MAC_P2P_MIN_IE_LEN           4   /* P2P IE的最小长度 */
145 #define MAC_P2P_WILDCARD_SSID        8   /* P2P设备ssid标志长度 */
146 
147 /* Quiet 信息 */
148 #define MAC_QUIET_PERIOD            0
149 #define MAC_QUIET_COUNT             MAC_QUIET_PERIOD
150 #define MAC_QUIET_DURATION          0x0000
151 #define MAC_QUIET_OFFSET            0x0000
152 
153 /* RSN信息元素相关定义 */
154 #define MAC_RSN_IE_VERSION          1
155 #define MAC_RSN_CAP_LEN             2
156 #define MAC_PMKID_LEN               16
157 
158 /* WPA 信息元素相关定义 */
159 #define MAC_WPA_IE_VERSION          1
160 #define WLAN_AKM_SUITE_WAPI_CERT    0x000FAC12
161 
162 /* OUI相关定义 */
163 #define MAC_OUI_LEN                 3
164 
165 #define MAC_OUITYPE_WPA             1
166 #define MAC_OUITYPE_WMM             2
167 #define MAC_OUITYPE_WPS             4
168 #define MAC_OUITYPE_P2P             9
169 
170 /* sizes for DHCP options */
171 #ifndef DHCP_CHADDR_LEN
172 #define DHCP_CHADDR_LEN         16
173 #endif
174 #define SERVERNAME_LEN          64
175 #define BOOTFILE_LEN            128
176 #define DHCP_UDP_LEN            (14 + 20 + 8)
177 #define DHCP_FIXED_LEN          (DHCP_UDP_LEN + 226)
178 #define DHCP_OPTION_LEN         72
179 
180 
181 #ifdef _PRE_WLAN_FEATURE_BW_HIEX
182 #define MAC_OUITYPE_DBAC              5
183 #define MAC_OUISUBTYPE_DBAC_NOA       1
184 #endif
185 
186 #ifdef _PRE_WLAN_FEATURE_MESH_ROM
187 #define MAC_OUITYPE_MESH 2
188 #define MAC_OUISUBTYPE_MESH_HISI_RSN 1
189 #define MAC_OUISUBTYPE_MESH_HISI_OPTIMIZATION 2
190 #define MAC_OUISUBTYPE_MESH_HISI_REQ 3
191 #define MAC_OUISUBTYPE_MESH_HISI_STA_REQ 4
192 #define MAC_OUISUBTYPE_MESH_HISI_BEACON 5
193 #define MAC_OUISUBTYPE_MESH_HISI_RSP 6
194 #define MAC_OUISUBTYPE_MESH_HISI_MESHID 7
195 #endif
196 
197 /* 华为OUI,公共定义 */
198 #define MAC_WLAN_OUI_VENDOR                 0x00E0FC
199 #define MAC_WLAN_OUI_VENDOR0                0x00        /* VENDOR OUI 定义 0x00E0FC */
200 #define MAC_WLAN_OUI_VENDOR1                0xE0
201 #define MAC_WLAN_OUI_VENDOR2                0xFC
202 #define MAC_WLAN_OUI_RSN0                   0x00        /* RSNA OUI 定义 0x000FAC */
203 #define MAC_WLAN_OUI_RSN1                   0x0F
204 #define MAC_WLAN_OUI_RSN2                   0xAC
205 #define MAC_WLAN_OUI_MICRO0                 0x00        /* WPA/WMM OUI 定义 0x0050F2 */
206 #define MAC_WLAN_OUI_MICRO1                 0x50
207 #define MAC_WLAN_OUI_MICRO2                 0xF2
208 #define MAC_WLAN_OUI_P2P0                   0x50        /* P2P OUI 定义 0x506F9A */
209 #define MAC_WLAN_OUI_P2P1                   0x6F
210 #define MAC_WLAN_OUI_P2P2                   0x9A
211 #define MAC_OUITYPE_ANY                     0xFD
212 #ifdef _PRE_WLAN_FEATURE_ANY_ROM
213 #define MAC_ANY_STA_TYPE                    0x5
214 #define MAC_ANY_AP_TYPE                     0x6
215 #define MAC_ANY_COOKIE_LEN                  8
216 #endif
217 #define MAC_ACTION_OUI_POS                  1
218 #define MAC_ACTION_VENDOR_TYPE_POS          4
219 #define MAC_ACTION_VENDOR_SUBTYPE_POS       5
220 #define MAC_ACTION_VENDOR_SPECIFIC_IE_POS   6
221 
222 #define MAC_WMM_OUI_BYTE_ONE        0x00
223 #define MAC_WMM_OUI_BYTE_TWO        0x50
224 #define MAC_WMM_OUI_BYTE_THREE      0xF2
225 #define MAC_WMM_UAPSD_ALL           (BIT0 | BIT1 | BIT2 | BIT3)
226 #define MAC_OUISUBTYPE_WMM_INFO     0
227 #define MAC_OUISUBTYPE_WMM_PARAM    1
228 #define MAC_OUISUBTYPE_WMM_PARAM_OFFSET 6 /* wmm 字段中EDCA_INFO位置,表示是否携带EDCA参数 偏移6 */
229 #define MAC_WMM_QOS_INFO_POS        8   /* wmm 字段中qos info位置,偏移8 */
230 #define MAC_OUI_WMM_VERSION         1
231 #define MAC_HT_CAP_LEN              26  /* HT能力信息长度为26 */
232 #define MAC_HT_CAPINFO_LEN          2   /* HT Capabilities Info域长度为2 */
233 #define MAC_HT_AMPDU_PARAMS_LEN     1   /* A-MPDU parameters域长度为1 */
234 #define MAC_HT_SUP_MCS_SET_LEN      16  /* Supported MCS Set域长度为16 */
235 #define MAC_HT_EXT_CAP_LEN          2   /* Extended cap.域长度为2 */
236 #define MAC_HT_TXBF_CAP_LEN         4   /* Transmit Beamforming Cap.域长度为4 */
237 #define MAC_HT_ASEL_LEN             1   /* ASEL Cap.域长度为1 */
238 #define MAC_HT_OPERN_LEN            22  /* HT Operation信息长度为22 */
239 #define MAC_HT_BASIC_MCS_SET_LEN    16  /* HT info中的basic mcs set信息的长度 */
240 #define MAC_HT_CTL_LEN              4   /* HT CONTROL字段的长度 */
241 #define MAC_QOS_CTL_LEN             2   /* QOS CONTROL字段的长度 */
242 #ifdef _PRE_WLAN_FEATURE_MESH_ROM
243 #define MAC_MESH_CONF_LEN                   7           /* Mesh Configuration 字段长度为7 */
244 #define MAC_MESH_FORMATION_LEN              1           /* Mesh Formation Field 长度为1 */
245 #define MAC_MESH_CAPABILITY_LEN             1           /* Mesh Capability Field 长度为1 */
246 #define MAC_MESH_HISI_OPTIMIZATION_LEN      3           /* Mesh Hisi Optimization 长度为3 */
247 #define MAC_OUISUBTYPE_LEN                  1           /* Mesh OUISUBTYPE 长度为1 */
248 #define MAC_RPL_TYPE                        155         /* ICMPv6报文中RPL协议的type值 */
249 #define MAC_MESH_MESHID_LEN_POS             7           /* Hisi Mesh id长度字段在私有字段中的位置 */
250 #define MAC_MESH_MESHID_OFFSET              8           /* Hisi Mesh id 字段Meshid内容的起始位置 */
251 #define MAC_MESH_HISI_BEACON_PRIO_POS       7           /* Hisi Beacon Prio字段在私有字段中的位置 */
252 #define MAC_MESH_HISI_IS_MBR_POS            8           /* Hisi En_is_mbr字段在私有字段中的位置 */
253 #define MAC_MESH_HISI_ACCEPT_STA_POS        9           /* Hisi accept_sta字段在私有字段中的位置 */
254 #endif
255 
256 #define MAC_QOS_CTRL_FIELD_OFFSET           24
257 #define MAC_QOS_CTRL_FIELD_OFFSET_4ADDR     30
258 
259 #define MAC_TAG_PARAM_OFFSET               (MAC_80211_FRAME_LEN + MAC_TIME_STAMP_LEN +\
260                                             MAC_BEACON_INTERVAL_LEN + MAC_CAP_INFO_LEN)
261 
262 #define MAC_DEVICE_BEACON_OFFSET            (MAC_TIME_STAMP_LEN +\
263                                             MAC_BEACON_INTERVAL_LEN + MAC_CAP_INFO_LEN)
264 #define MAC_LISTEN_INTERVAL_MAX_LEN         10  /* 定义关联STA最大LISTEN INTERVAL的值 */
265 
266 #define MAC_MAX_START_SPACING               7
267 
268 /* EDCA参数相关的宏 */
269 #define MAC_WMM_QOS_PARAM_AIFSN_MASK                       0x0F
270 #define MAC_WMM_QOS_PARAM_ACI_BIT_OFFSET                   5
271 #define MAC_WMM_QOS_PARAM_ACI_MASK                         0x03
272 #define MAC_WMM_QOS_PARAM_ECWMIN_MASK                      0x0F
273 #define MAC_WMM_QOS_PARAM_ECWMAX_MASK                      0xF0
274 #define MAC_WMM_QOS_PARAM_ECWMAX_BIT_OFFSET                4
275 #define MAC_WMM_QOS_PARAM_TXOPLIMIT_MASK                   0x00FF
276 #define MAC_WMM_QOS_PARAM_BIT_NUMS_OF_ONE_BYTE             8
277 #define MAC_WMM_QOS_PARAM_TXOPLIMIT_SAVE_TO_TRANS_TIMES    5
278 
279 /* 关闭WMM后,所有帧进入此宏定义的队列 */
280 #define MAC_WMM_SWITCH_TID                                 6
281 
282 /* TCP协议类型,chartiot tcp连接端口号 */
283 #define MAC_TCP_PROTOCAL                                   6
284 #define MAC_UDP_PROTOCAL                                   17
285 #define MAC_CHARIOT_NETIF_PORT                             10115
286 #define MAC_WFD_RTSP_PORT                                  7236
287 
288 /* ICMP协议报文 */
289 #define MAC_ICMP_PROTOCAL                                  1
290 
291 #define MAC_VENDER_IE                                      0xAC853D /* 打桩HW IE */
292 #define MAC_HISI_HISTREAM_IE                               0x11     /* histream IE */
293 
294 #define MAC_IPV6_UDP_SRC_PORT                               546
295 #define MAC_IPV6_UDP_DES_PORT                               547
296 
297 /* ARP types, 1: ARP request, 2:ARP response, 3:RARP request, 4:RARP response */
298 #define MAC_ARP_REQUEST         0x0001
299 #define MAC_ARP_RESPONSE        0x0002
300 #define MAC_RARP_REQUEST        0x0003
301 #define MAC_RARP_RESPONSE       0x0004
302 
303 /* Neighbor Discovery */
304 #define MAC_ND_RSOL     133 /* Router Solicitation */
305 #define MAC_ND_RADVT    134 /* Router Advertisement */
306 #define MAC_ND_NSOL     135 /* Neighbor Solicitation */
307 #define MAC_ND_NADVT    136 /* Neighbor Advertisement */
308 #define MAC_ND_RMES     137 /* Redirect Message */
309 
310 /* DHCP message types */
311 #define MAC_DHCP_DISCOVER       1
312 #define MAC_DHCP_OFFER          2
313 #define MAC_DHCP_REQUEST        3
314 #define MAC_DHCP_DECLINE        4
315 #define MAC_DHCP_ACK            5
316 #define MAC_DHCP_NAK            6
317 #define MAC_DHCP_RELEASE        7
318 #define MAC_DHCP_INFORM         8
319 
320 /* DHCPV6 Message type */
321 #define MAC_DHCPV6_SOLICIT      1
322 #define MAC_DHCPV6_ADVERTISE    2
323 #define MAC_DHCPV6_REQUEST      3
324 #define MAC_DHCPV6_CONFIRM      4
325 #define MAC_DHCPV6_RENEW        5
326 #define MAC_DHCPV6_REBIND       6
327 #define MAC_DHCPV6_REPLY        7
328 #define MAC_DHCPV6_RELEASE      8
329 #define MAC_DHCPV6_DECLINE      9
330 #define MAC_DHCPV6_RECONFIGURE  10
331 #define MAC_DHCPV6_INFORM_REQ   11
332 #define MAC_DHCPV6_RELAY_FORW   12
333 #define MAC_DHCPV6_RELAY_REPLY  13
334 #define MAC_DHCPV6_LEASEQUERY   14
335 #define MAC_DHCPV6_LQ_REPLY     15
336 
337 /* IGMP record type */
338 #define MAC_IGMP_QUERY_TYPE       0x11
339 #define MAC_IGMPV1_REPORT_TYPE    0x12
340 #define MAC_IGMPV2_REPORT_TYPE    0x16
341 #define MAC_IGMPV2_LEAVE_TYPE     0x17
342 #define MAC_IGMPV3_REPORT_TYPE    0x22
343 
344 
345 /* V3 group record types [grec_type] */
346 #define IGMPV3_MODE_IS_INCLUDE        1
347 #define IGMPV3_MODE_IS_EXCLUDE        2
348 #define IGMPV3_CHANGE_TO_INCLUDE      3
349 #define IGMPV3_CHANGE_TO_EXCLUDE      4
350 #define IGMPV3_ALLOW_NEW_SOURCES      5
351 #define IGMPV3_BLOCK_OLD_SOURCES      6
352 
353 #define mac_is_golden_ap(puc_bssid) ((0x0 == (puc_bssid)[0]) && (0x13 == (puc_bssid)[1]) && (0xE9 == (puc_bssid)[2]))
354 
355 /* p2p相关 */
356 /* GO negotiation */
357 #define P2P_PAF_GON_REQ     0
358 #define P2P_PAF_GON_RSP     1
359 #define P2P_PAF_GON_CONF    2
360 /* Provision discovery */
361 #define P2P_PAF_PD_REQ      7
362 /* P2P IE */
363 #define P2P_OUI_LEN         4
364 #define P2P_IE_HDR_LEN      6
365 #define P2P_ELEMENT_ID_SIZE 1
366 #define P2P_ATTR_ID_SIZE    1
367 #define P2P_ATTR_HDR_LEN    3
368 #define WFA_OUI_BYTE1       0x50
369 #define WFA_OUI_BYTE2       0x6F
370 #define WFA_OUI_BYTE3       0x9A
371 #define WFA_P2P_V1_0        0x09
372 
373 /* ****************************************************************************
374   3 枚举定义
375 **************************************************************************** */
376 typedef enum {
377     MAC_AP_TYPE_NORMAL   = 0,
378     MAC_AP_TYPE_GOLDENAP = 1,
379 
380     MAC_AP_TYPE_BUTT
381 } mac_ap_type_enum;
382 typedef hi_u8 mac_ap_type_enum_uint8;
383 
384 /* ****************************************************************************
385   枚举名  : wlan_ieee80211_frame_type_enum_uint8
386   协议表格:
387   枚举说明: 802.11 MAC帧头类型
388 **************************************************************************** */
389 typedef enum {
390     MAC_IEEE80211_BASE_FRAME = 0,      /* 基础802.11帧类型 */
391     MAC_IEEE80211_QOS_FRAME,           /* QoS帧类型 */
392     MAC_IEEE80211_QOS_HTC_FRAME,       /* QoS + HTC帧类型 */
393     MAC_IEEE80211_ADDR4_FRAME,         /* 四地址帧类型 */
394     MAC_IEEE80211_QOS_ADDR4_FRAME,     /* QoS四地址帧类型 */
395     MAC_IEEE80211_QOS_HTC_ADDR4_FRAME, /* QoS + HTC四地址帧类型 */
396 
397     MAC_IEEE80211_FRAME_BUTT
398 } mac_ieee80211_frame_type_enum;
399 typedef hi_u8 mac_ieee80211_frame_type_enum_uint8;
400 
401 /* Action Frames: Category字段枚举 */
402 typedef enum {
403     MAC_ACTION_CATEGORY_SPECMGMT                    = 0,
404     MAC_ACTION_CATEGORY_QOS                         = 1,
405     MAC_ACTION_CATEGORY_DLS                         = 2,
406     MAC_ACTION_CATEGORY_BA                          = 3,
407     MAC_ACTION_CATEGORY_PUBLIC                      = 4,
408     MAC_ACTION_CATEGORY_RADIO_MEASURMENT            = 5,
409     MAC_ACTION_CATEGORY_FAST_BSS_TRANSITION         = 6,
410     MAC_ACTION_CATEGORY_HT                          = 7,
411     MAC_ACTION_CATEGORY_SA_QUERY                    = 8,
412     MAC_ACTION_CATEGORY_PROTECTED_DUAL_OF_ACTION    = 9,
413     MAC_ACTION_CATEGORY_WNM                         = 10,
414     MAC_ACTION_CATEGORY_MESH                        = 13,
415     MAC_ACTION_CATEGORY_MULTIHOP                    = 14,
416     MAC_ACTION_CATEGORY_SELF_PROTECTED              = 15,
417     MAC_ACTION_CATEGORY_WFA                         = 17,
418     MAC_ACTION_CATEGORY_VHT                         = 21,
419     MAC_ACTION_CATEGORY_VENDOR_SPECIFIC_PROTECTED   = 126,
420     MAC_ACTION_CATEGORY_VENDOR                      = 127,
421 }mac_action_category_enum;
422 typedef hi_u8 mac_category_enum_uint8;
423 
424 /* HT Category下的Action值的枚举 */
425 typedef enum {
426     MAC_HT_ACTION_NOTIFY_CHANNEL_WIDTH        = 0,
427     MAC_HT_ACTION_SMPS                        = 1,
428     MAC_HT_ACTION_PSMP                        = 2,
429     MAC_HT_ACTION_SET_PCO_PHASE               = 3,
430     MAC_HT_ACTION_CSI                         = 4,
431     MAC_HT_ACTION_NON_COMPRESSED_BEAMFORMING  = 5,
432     MAC_HT_ACTION_COMPRESSED_BEAMFORMING      = 6,
433     MAC_HT_ACTION_ASEL_INDICES_FEEDBACK       = 7,
434 
435     MAC_HT_ACTION_BUTT
436 } mac_ht_action_type_enum;
437 typedef hi_u8 mac_ht_action_type_enum_uint8;
438 /* Timeout_Interval ie中的类型枚举 */
439 typedef enum {
440     MAC_TIE_REASSOCIATION_DEADLINE_INTERVAL  = 1,   /* 毫秒级 */
441     MAC_TIE_KEY_LIFETIME_INTERVAL            = 2,   /* 秒级 */
442     MAC_TIE_ASSOCIATION_COMEBACK_TIME        = 3,   /* 毫秒级 */
443 
444     MAC_TIE_BUTT
445 } mac_timeout_interval_type_enum;
446 typedef hi_u8 mac_timeout_interval_type_enum_uint8;
447 
448 /* SA QUERY Category下的Action值的枚举 */
449 typedef enum {
450     MAC_SA_QUERY_ACTION_REQUEST          = 0,
451     MAC_SA_QUERY_ACTION_RESPONSE         = 1
452 }mac_sa_query_action_type_enum;
453 typedef hi_u8 mac_sa_query_action_type_enum_uint8;
454 typedef enum {
455     MAC_FT_ACTION_REQUEST          = 1,
456     MAC_FT_ACTION_RESPONSE         = 2,
457     MAC_FT_ACTION_CONFIRM          = 3,
458     MAC_FT_ACTION_ACK              = 4,
459     MAC_FT_ACTION_BUTT             = 5
460 }mac_ft_action_type_enum;
461 typedef hi_u8 mac_ft_action_type_enum_uint8;
462 
463 /* VHT Category下的Action值的枚举 */
464 typedef enum {
465     MAC_VHT_ACTION_COMPRESSED_BEAMFORMING   = 0,
466     MAC_VHT_ACTION_GROUPID_MANAGEMENT       = 1,
467     MAC_VHT_ACTION_OPREATE_MODE_NOTIFY      = 2,
468 
469     MAC_VHT_ACTION_BUTT
470 } mac_vht_action_type_enum;
471 typedef hi_u8 mac_vht_action_type_enum_uint8;
472 
473 /* 校准模式的枚举 */
474 typedef enum {
475     MAC_NOT_SURPPORT_CLB = 0,
476     MAC_RSP_CLB_ONLY     = 1,
477     MAC_SUPPOTR_CLB      = 3,
478     MAC_CLB_BUTT
479 } mac_txbf_clb_enum;
480 typedef hi_u8 mac_txbf_clb_enum_uint8;
481 
482 /* Spectrum Management Category下的Action枚举值 */
483 typedef enum {
484     MAC_SPEC_CH_SWITCH_ANNOUNCE = 4 /*  Channel Switch Announcement */
485 } mac_specmgmt_action_type_enum;
486 typedef hi_u8 mac_specmgmt_action_type_enum_uint8;
487 
488 /* BlockAck Category下的Action值的枚举 */
489 typedef enum {
490     MAC_BA_ACTION_ADDBA_REQ       = 0,
491     MAC_BA_ACTION_ADDBA_RSP       = 1,
492     MAC_BA_ACTION_DELBA           = 2,
493 
494     MAC_BA_ACTION_BUTT
495 } mac_ba_action_type_enum;
496 typedef hi_u8 mac_ba_action_type_enum_uint8;
497 
498 /* Public Category下的Action枚举值 */
499 typedef enum {
500     MAC_PUB_COEXT_MGMT            = 0,  /* 20/40 BSS Coexistence Management */
501     MAC_PUB_EX_CH_SWITCH_ANNOUNCE = 4,  /* Extended Channel Switch Announcement */
502     MAC_PUB_VENDOR_SPECIFIC       = 9,
503     MAC_PUB_GAS_INIT_RESP         = 11,  /* public Action: GAS Initial Response(0x0b) */
504     MAC_PUB_GAS_COMBAK_RESP       = 13   /* public Action: GAS Comeback Response(0x0d) */
505 }mac_public_action_type_enum;
506 typedef hi_u8 mac_public_action_type_enum_uint8;
507 
508 #ifdef _PRE_WLAN_FEATURE_MESH_ROM
509 /* Self-Protected Category Action枚举值 */
510 typedef enum {
511     MAC_SP_ACTION_MESH_PEERING_OPEN = 1,
512     MAC_SP_ACTION_MESH_PEERING_CONFIRM = 2,
513     MAC_SP_ACTION_MESH_PEERING_CLOSE = 3,
514     MAC_SP_ACTION_MESH_GROUP_KEY_INFORM = 4,
515     MAC_SP_ACTION_MESH_GROUP_KEY_ACK = 5,
516 
517     MAC_SP_ACTION_BUTT
518 } mac_sp_action_type_enum;
519 typedef hi_u8 mac_sp_action_type_enum_uint8;
520 
521 /* Mesh Category Action枚举值 */
522 typedef enum {
523     MAC_MESH_ACTION_MESH_LINK_METRIC_REPORT = 0,
524     MAC_MESH_ACTION_HWMP_MESH_PATH_SELECT,
525     MAC_MESH_ACTION_GATE_ANNOUNCE,
526     MAC_MESH_ACTION_CONGESTION_CTRL_NOTIFI,
527     MAC_MESH_ACTION_MCCA_SETUP_REQ,
528     MAC_MESH_ACTION_MCCA_SETUP_REP,
529     MAC_MESH_ACTION_MCCA_ADV_REQ,
530     MAC_MESH_ACTION_MCCA_ADV,
531     MAC_MESH_ACTION_MCCA_TEARDOWN,
532     MAC_MESH_ACTION_TBTT_ADJ_REQ,
533     MAC_MESH_ACTION_TBTT_ADJ_RSP,
534 
535     MAC_MESH_ACTION_BUTT
536 } mac_mesh_action_type_enum;
537 #endif
538 /* 802.11n下的私有请求 */
539 typedef enum {
540     MAC_A_MPDU_START = 0,
541     MAC_A_MPDU_END = 1,
542 
543     MAC_A_MPDU_BUTT
544 } mac_priv_req_11n_enum;
545 typedef hi_u8 mac_priv_req_11n_enum_uint8;
546 
547 /* Block ack的确认类型 */
548 typedef enum {
549     MAC_BACK_BASIC = 0,
550     MAC_BACK_COMPRESSED = 2,
551     MAC_BACK_MULTI_TID = 3,
552 
553     MAC_BACK_BUTT
554 } mac_back_variant_enum;
555 typedef hi_u8 mac_back_variant_enum_uint8;
556 
557 /* ACTION帧中,各个域的偏移量 */
558 typedef enum {
559     MAC_ACTION_OFFSET_CATEGORY = 0,
560     MAC_ACTION_OFFSET_ACTION = 1,
561 } mac_action_offset_enum;
562 typedef hi_u8 mac_action_offset_enum_uint8;
563 
564 /* Reason Codes for Deauthentication and Disassociation Frames */
565 typedef enum {
566     MAC_UNSPEC_REASON           = 1,
567     MAC_AUTH_NOT_VALID          = 2,
568     MAC_DEAUTH_LV_SS            = 3,
569     MAC_INACTIVITY              = 4,
570     MAC_AP_OVERLOAD             = 5,
571     MAC_NOT_AUTHED              = 6,
572     MAC_NOT_ASSOCED             = 7,
573     MAC_DISAS_LV_SS             = 8,
574     MAC_ASOC_NOT_AUTH           = 9,
575     MAC_INVLD_ELEMENT           = 13,
576     MAC_MIC_FAIL                = 14,
577     MAC_IEEE_802_1X_AUTH_FAIL   = 23,
578     MAC_UNSPEC_QOS_REASON       = 32,
579     MAC_QAP_INSUFF_BANDWIDTH    = 33,
580     MAC_POOR_CHANNEL            = 34,
581     MAC_STA_TX_AFTER_TXOP       = 35,
582     MAC_QSTA_LEAVING_NETWORK    = 36,
583     MAC_QSTA_INVALID_MECHANISM  = 37,
584     MAC_QSTA_SETUP_NOT_DONE     = 38,
585     MAC_QSTA_TIMEOUT            = 39,
586     MAC_QSTA_CIPHER_NOT_SUPP    = 45,
587 
588 #ifdef _PRE_WLAN_FEATURE_MESH
589     MAC_WPA_KICK_MESH_USER  = 46, /* 用于指明用户是由wpa发起来删除 */
590     MAC_LWIP_KICK_MESH_USER = 47,
591 #endif
592 } mac_reason_code_enum;
593 typedef hi_u8 mac_reason_code_enum_uint16;
594 
595 /* Capability Information field bit assignments  */
596 typedef enum {
597     MAC_CAP_ESS             = 0x01,   /* ESS capability               */
598     MAC_CAP_IBSS            = 0x02,   /* IBSS mode                    */
599     MAC_CAP_POLLABLE        = 0x04,   /* CF Pollable                  */
600     MAC_CAP_POLL_REQ        = 0x08,   /* Request to be polled         */
601     MAC_CAP_PRIVACY         = 0x10,   /* WEP encryption supported     */
602     MAC_CAP_SHORT_PREAMBLE  = 0x20,   /* Short Preamble is supported  */
603     MAC_CAP_SHORT_SLOT      = 0x400,  /* Short Slot is supported      */
604     MAC_CAP_PBCC            = 0x40,   /* PBCC                         */
605     MAC_CAP_CHANNEL_AGILITY = 0x80,   /* Channel Agility              */
606     MAC_CAP_SPECTRUM_MGMT   = 0x100,  /* Spectrum Management          */
607     MAC_CAP_DSSS_OFDM       = 0x2000  /* DSSS-OFDM                    */
608 } mac_capability_enum;
609 typedef hi_u16 mac_capability_enum_uint16;
610 
611 /* Status Codes for Authentication and Association Frames */
612 typedef enum {
613     MAC_SUCCESSFUL_STATUSCODE       = 0,
614     MAC_UNSPEC_FAIL                 = 1,
615     MAC_UNSUP_CAP                   = 10,
616     MAC_REASOC_NO_ASOC              = 11,
617     MAC_FAIL_OTHER                  = 12,
618     MAC_UNSUPT_ALG                  = 13,
619     MAC_AUTH_SEQ_FAIL               = 14,
620     MAC_CHLNG_FAIL                  = 15,
621     MAC_AUTH_TIMEOUT                = 16,
622     MAC_AP_FULL                     = 17,
623     MAC_UNSUP_RATE                  = 18,
624     MAC_SHORT_PREAMBLE_UNSUP        = 19,
625     MAC_PBCC_UNSUP                  = 20,
626     MAC_CHANNEL_AGIL_UNSUP          = 21,
627     MAC_MISMATCH_SPEC_MGMT          = 22,
628     MAC_MISMATCH_POW_CAP            = 23,
629     MAC_MISMATCH_SUPP_CHNL          = 24,
630     MAC_SHORT_SLOT_UNSUP            = 25,
631     MAC_OFDM_DSSS_UNSUP             = 26,
632     MAC_MISMATCH_HTCAP              = 27,
633     MAC_MISMATCH_PCO                = 29,
634     MAC_REJECT_TEMP                 = 30,
635     MAC_MFP_VIOLATION               = 31,
636     MAC_UNSPEC_QOS_FAIL             = 32,
637     MAC_QAP_INSUFF_BANDWIDTH_FAIL   = 33,
638     MAC_POOR_CHANNEL_FAIL           = 34,
639     MAC_REMOTE_STA_NOT_QOS          = 35,
640     MAC_REQ_DECLINED                = 37,
641     MAC_INVALID_REQ_PARAMS          = 38,
642     MAC_RETRY_NEW_TSPEC             = 39,
643     MAC_INVALID_INFO_ELMNT          = 40,
644     MAC_INVALID_GRP_CIPHER          = 41,
645     MAC_INVALID_PW_CIPHER           = 42,
646     MAC_INVALID_AKMP_CIPHER         = 43,
647     MAC_UNSUP_RSN_INFO_VER          = 44,
648     MAC_INVALID_RSN_INFO_CAP        = 45,
649     MAC_CIPHER_REJ                  = 46,
650     MAC_RETRY_TS_LATER              = 47,
651     MAC_DLS_NOT_SUPP                = 48,
652     MAC_DST_STA_NOT_IN_QBSS         = 49,
653     MAC_DST_STA_NOT_QSTA            = 50,
654     MAC_LARGE_LISTEN_INT            = 51,
655     MAC_MISMATCH_VHTCAP             = 104,
656 } mac_status_code_enum;
657 typedef hi_u16 mac_status_code_enum_uint16;
658 
659 /* BA会话管理确认策略 */
660 typedef enum {
661     MAC_BA_POLICY_DELAYED = 0,
662     MAC_BA_POLICY_IMMEDIATE,
663 
664     MAC_BA_POLICY_BUTT
665 } mac_ba_policy_enum;
666 typedef hi_u8 mac_ba_policy_enum_uint8;
667 
668 /* 发起DELBA帧的端点的枚举 */
669 typedef enum {
670     MAC_RECIPIENT_DELBA = 0, /* 数据的接收端 */
671     MAC_ORIGINATOR_DELBA,    /* 数据的发起端 */
672 
673     MAC_BUTT_DELBA
674 } dmac_delba_initiator_enum;
675 typedef hi_u8 mac_delba_initiator_enum_uint8;
676 
677 /* ****************************************************************************
678   信息元素(Infomation Element)的Element ID
679   协议521页,Table 8-54—Element IDs
680 **************************************************************************** */
681 typedef enum {
682     MAC_EID_SSID                   = 0,
683     MAC_EID_RATES                  = 1,
684     MAC_EID_FHPARMS                = 2,
685     MAC_EID_DSPARMS                = 3,
686     MAC_EID_CFPARMS                = 4,
687     MAC_EID_TIM                    = 5,
688     MAC_EID_IBSSPARMS              = 6,
689     MAC_EID_COUNTRY                = 7,
690     MAC_EID_REQINFO                = 10,
691     MAC_EID_QBSS_LOAD              = 11,
692     MAC_EID_TCLAS                  = 14,
693     MAC_EID_CHALLENGE              = 16,
694     /* 17-31 reserved */
695     MAC_EID_PWRCNSTR               = 32,
696     MAC_EID_PWRCAP                 = 33,
697     MAC_EID_TPCREQ                 = 34,
698     MAC_EID_TPCREP                 = 35,
699     MAC_EID_SUPPCHAN               = 36,
700     MAC_EID_CHANSWITCHANN          = 37,   /* Channel Switch Announcement IE */
701     MAC_EID_MEASREQ                = 38,
702     MAC_EID_MEASREP                = 39,
703     MAC_EID_QUIET                  = 40,
704     MAC_EID_IBSSDFS                = 41,
705     MAC_EID_ERP                    = 42,
706     MAC_EID_TCLAS_PROCESS          = 44,
707     MAC_EID_HT_CAP                 = 45,
708     MAC_EID_QOS_CAP                = 46,
709     MAC_EID_RESERVED_47            = 47,
710     MAC_EID_RSN                    = 48,
711     MAC_EID_RESERVED_49            = 49,
712     MAC_EID_XRATES                 = 50,
713     MAC_EID_AP_CHAN_REPORT         = 51,
714     MAC_EID_NEIGHBOR_REPORT        = 52,
715     MAC_EID_MOBILITY_DOMAIN        = 54,
716     MAC_EID_FT                     = 55,
717     MAC_EID_TIMEOUT_INTERVAL       = 56,
718     MAC_EID_EXTCHANSWITCHANN       = 60,   /* Extended Channel Switch Announcement IE */
719     MAC_EID_HT_OPERATION           = 61,
720     MAC_EID_SEC_CH_OFFSET          = 62,   /* Secondary Channel Offset IE */
721     MAC_EID_WAPI                   = 68,   /* IE for WAPI */
722     MAC_EID_TIME_ADVERTISEMENT     = 69,
723     MAC_EID_RRM                    = 70,   /* Radio resource measurement */
724     MAC_EID_2040_COEXT             = 72,   /* 20/40 BSS Coexistence IE */
725     MAC_EID_2040_INTOLCHREPORT     = 73,   /* 20/40 BSS Intolerant Channel Report IE */
726     MAC_EID_OBSS_SCAN              = 74,   /* Overlapping BSS Scan Parameters IE */
727     MAC_EID_MMIE                   = 76,   /* 802.11w Management MIC IE */
728     MAC_EID_FMS_DESCRIPTOR         = 86,   /* 802.11v FMS descriptor IE */
729     MAC_EID_FMS_REQUEST            = 87,   /* 802.11v FMS request IE */
730     MAC_EID_FMS_RESPONSE           = 88,   /* 802.11v FMS response IE */
731     MAC_EID_BSSMAX_IDLE_PERIOD     = 90,   /* BSS MAX IDLE PERIOD */
732     MAC_EID_TFS_REQUEST            = 91,
733     MAC_EID_TFS_RESPONSE           = 92,
734     MAC_EID_TIM_BCAST_REQUEST      = 94,
735     MAC_EID_TIM_BCAST_RESPONSE     = 95,
736     MAC_EID_INTERWORKING           = 107,
737 #ifdef _PRE_WLAN_FEATURE_MESH_ROM
738     MAC_EID_MESH_CONF = 113,
739     MAC_EID_MESHID = 114,
740     MAC_EID_BEACON_TIMING = 120,
741 #endif
742     MAC_EID_EXT_CAPS               = 127,  /* Extended Capabilities IE */
743     MAC_EID_VHT_TYPE               = 129,
744     MAC_EID_11NTXBF                = 130,   /* 802.11n txbf */
745     MAC_EID_RESERVED_133           = 133,
746     MAC_EID_TPC                    = 150,
747     MAC_EID_CCKM                   = 156,
748     MAC_EID_VHT_CAP                = 191,
749     MAC_EID_VHT_OPERN              = 192,  /* VHT Operation IE */
750     MAC_EID_WIDE_BW_CH_SWITCH      = 194,  /* Wide Bandwidth Channel Switch IE */
751     MAC_EID_OPMODE_NOTIFY          = 199,  /* Operating Mode Notification IE */
752     MAC_EID_VENDOR                 = 221,  /* vendor private */
753     MAC_EID_WMM                    = 221,
754     MAC_EID_WPA                    = 221,
755     MAC_EID_WPS                    = 221,
756     MAC_EID_P2P                    = 221,
757 }mac_eid_enum;
758 typedef hi_u8 mac_eid_enum_uint8;
759 
760 typedef enum {
761     MAC_P2P_ATTRIBUTE_CAP          = 2,
762     MAC_P2P_ATTRIBUTE_GROUP_OI     = 4,
763     MAC_P2P_ATTRIBUTE_CFG_TIMEOUT  = 5,
764     MAC_P2P_ATTRIBUTE_LISTEN_CHAN  = 6,
765 }mac_p2p_attribute_enum;
766 typedef hi_u8 mac_p2p_attribute_enum_uint8;
767 
768 typedef enum {
769     MAC_SMPS_STATIC_MODE     = 0,   /*   静态SMPS   */
770     MAC_SMPS_DYNAMIC_MODE    = 1,   /*   动态SMPS   */
771     MAC_SMPS_MIMO_MODE       = 3,   /* disable SMPS */
772 
773     MAC_SMPS_MODE_BUTT
774 } mac_mimo_power_save_enum;
775 typedef hi_u8 mac_mimo_power_save_mode_enum_uint8;
776 
777 typedef enum {
778     MAC_SCN = 0,    /* 不存在次信道 */
779     MAC_SCA = 1,    /* 次信道在主信道之上(Secondary Channel Above) */
780     MAC_SCB = 3,    /* 次信道在主信道之下(Secondary Channel Below) */
781     MAC_BW_5M = 4,  /* 自定义,工作带宽窄带5M */
782     MAC_BW_10M = 5, /* 自定义,工作带宽窄带10M */
783     MAC_SEC_CH_BUTT,
784 } mac_sec_ch_off_enum;
785 typedef hi_u8 mac_sec_ch_off_enum_uint8;
786 
787 /* P2P相关 */
788 typedef enum {
789     P2P_STATUS             =  0,
790     P2P_MINOR_REASON_CODE  =  1,
791     P2P_CAPABILITY         =  2,
792     P2P_DEVICE_ID          =  3,
793     GROUP_OWNER_INTENT     =  4,
794     CONFIG_TIMEOUT         =  5,
795     LISTEN_CHANNEL         =  6,
796     P2P_GROUP_BSSID        =  7,
797     EXTENDED_LISTEN_TIMING =  8,
798     INTENDED_P2P_IF_ADDR   =  9,
799     P2P_MANAGEABILITY      =  10,
800     P2P_CHANNEL_LIST       =  11,
801     NOTICE_OF_ABSENCE      =  12,
802     P2P_DEVICE_INFO        =  13,
803     P2P_GROUP_INFO         =  14,
804     P2P_GROUP_ID           =  15,
805     P2P_INTERFACE          =  16,
806     P2P_OPERATING_CHANNEL  =  17,
807     INVITATION_FLAGS       =  18
808 } attribute_id_t;
809 
810 typedef enum {
811     P2P_PUB_ACT_OUI_OFF1         = 2,
812     P2P_PUB_ACT_OUI_OFF2         = 3,
813     P2P_PUB_ACT_OUI_OFF3         = 4,
814     P2P_PUB_ACT_OUI_TYPE_OFF     = 5,
815     P2P_PUB_ACT_OUI_SUBTYPE_OFF  = 6,
816     P2P_PUB_ACT_DIALOG_TOKEN_OFF = 7,
817     P2P_PUB_ACT_TAG_PARAM_OFF    = 8
818 } p2p_pub_act_frm_off;
819 
820 typedef enum {
821     P2P_GEN_ACT_OUI_OFF1         = 1,
822     P2P_GEN_ACT_OUI_OFF2         = 2,
823     P2P_GEN_ACT_OUI_OFF3         = 3,
824     P2P_GEN_ACT_OUI_TYPE_OFF     = 4,
825     P2P_GEN_ACT_OUI_SUBTYPE_OFF  = 5,
826     P2P_GEN_ACT_DIALOG_TOKEN_OFF = 6,
827     P2P_GEN_ACT_TAG_PARAM_OFF    = 7
828 } p2p_gen_act_frm_off;
829 
830 typedef enum {
831     P2P_NOA           = 0,
832     P2P_PRESENCE_REQ  = 1,
833     P2P_PRESENCE_RESP = 2,
834     GO_DISC_REQ       = 3
835 } p2p_gen_action_frm_type;
836 
837 typedef enum {
838     P2P_STAT_SUCCESS           = 0,
839     P2P_STAT_INFO_UNAVAIL      = 1,
840     P2P_STAT_INCOMP_PARAM      = 2,
841     P2P_STAT_LMT_REACHED       = 3,
842     P2P_STAT_INVAL_PARAM       = 4,
843     P2P_STAT_UNABLE_ACCO_REQ   = 5,
844     P2P_STAT_PREV_PROT_ERROR   = 6,
845     P2P_STAT_NO_COMMON_CHAN    = 7,
846     P2P_STAT_UNKNW_P2P_GRP     = 8,
847     P2P_STAT_GO_INTENT_15      = 9,
848     P2P_STAT_INCOMP_PROV_ERROR = 10,
849     P2P_STAT_USER_REJECTED     = 11
850 } p2p_status_code_t;
851 
852 /* Mesh相关 */
853 #ifdef _PRE_WLAN_FEATURE_MESH_ROM
854 typedef enum {
855     MAC_MESH_AUTH_PROTO_NULL = 0,
856     MAC_MESH_AUTH_PROTO_SAE = 1,
857     MAC_MESH_AUTH_PROTO_8021X = 2,
858     MAC_MESH_AUTH_PROTO_VENDOR_SPEC = 255,
859 } mac_mesh_auth_proto_enum;
860 typedef hi_u8 mac_mesh_auth_proto_enum_uint8;
861 #endif
862 
863 #define MAC_WLAN_OUI_WFA                    0x506f9a
864 #define MAC_WLAN_OUI_TYPE_WFA_P2P               9
865 #define MAC_WLAN_OUI_MICROSOFT              0x0050f2
866 #ifdef _PRE_WLAN_FEATURE_MESH
867 #define MAC_WLAN_OUI_HW 0x00E0FC
868 #endif
869 #define MAC_WLAN_OUI_TYPE_MICROSOFT_WPA         1
870 #define MAC_WLAN_OUI_TYPE_MICROSOFT_WMM         2
871 #define MAC_WLAN_OUI_TYPE_MICROSOFT_WPS         4
872 
873 /* eapol key 结构宏定义 */
874 #define WPA_REPLAY_COUNTER_LEN      8
875 #define WPA_NONCE_LEN               32
876 #define WPA_KEY_RSC_LEN             8
877 #define IEEE802_1X_TYPE_EAPOL_KEY   3
878 #define WPA_KEY_INFO_KEY_TYPE       bit(3) /* 1 = Pairwise, 0 = Group key */
879 
880 #define MAC_VHT_CHANGE (BIT1)
881 #define MAC_HT_CHANGE  (BIT2)
882 #define MAC_BW_CHANGE  (BIT3)
883 #define MAC_NO_CHANGE   0
884 
885 /* ****************************************************************************
886   STRUCT定义
887 **************************************************************************** */
888 #pragma pack(1)
889 /* 此文件中结构体与协议一致,要求1字节对齐,统一加__OAL_DECLARE_PACKED */
890 struct mac_ether_header {
891     hi_u8    auc_ether_dhost[ETHER_ADDR_LEN];
892     hi_u8    auc_ether_shost[ETHER_ADDR_LEN];
893     hi_u16   us_ether_type;
894 } __OAL_DECLARE_PACKED;
895 typedef struct mac_ether_header mac_ether_header_stru;
896 
897 typedef struct mac_llc_snap {
898     hi_u8   llc_dsap;
899     hi_u8   llc_ssap;
900     hi_u8   control;
901     hi_u8   auc_org_code[ORG_CODE_LEN];
902     hi_u16  us_ether_type;
903 } mac_llc_snap_stru;
904 
905 /* eapol帧头 */
906 typedef struct mac_eapol_header {
907     hi_u8       version;
908     hi_u8       type;
909     hi_u16      us_length;
910 } mac_eapol_header_stru;
911 
912 /* IEEE 802.11, 8.5.2 EAPOL-Key frames */
913 /* EAPOL KEY 结构定义 */
914 struct mac_eapol_key {
915     hi_u8 type;
916     /* Note: key_info, key_length, and key_data_length are unaligned */
917     hi_u8 auc_key_info[2];          /* big endian:占2 byte */
918     hi_u8 auc_key_length[2];        /* big endian:占2 byte */
919     hi_u8 auc_replay_counter[WPA_REPLAY_COUNTER_LEN];
920     hi_u8 auc_key_nonce[WPA_NONCE_LEN];
921     hi_u8 auc_key_iv[16];           /* key_iv占16 byte */
922     hi_u8 auc_key_rsc[WPA_KEY_RSC_LEN];
923     hi_u8 auc_key_id[8];            /* Reserved in IEEE 802.11i/RSN:占8 byte */
924     hi_u8 auc_key_mic[16];          /* mic占16 byte */
925     hi_u8 auc_key_data_length[2];   /* big endian:占2 byte */
926     /* followed by key_data_length bytes of key_data */
927 } __OAL_DECLARE_PACKED;
928 typedef struct mac_eapol_key mac_eapol_key_stru;
929 
930 /*
931  * Structure of the IP frame
932  */
933 typedef struct mac_ip_header {
934     hi_u8    version_ihl;
935     hi_u8    tos;
936     hi_u16   us_tot_len;
937     hi_u16   us_id;
938     hi_u16   us_frag_off;
939     hi_u8    ttl;
940     hi_u8    protocol;
941     hi_u16   us_check;
942     hi_u32   saddr;
943     hi_u32   daddr;
944     /* The options start here. */
945 } mac_ip_header_stru;
946 
947 /*
948  * Header in on cable format
949  */
950 typedef struct mac_igmp_header {
951     hi_u8  type;
952     hi_u8  code;        /* For newer IGMP */
953     hi_u16 us_csum;
954     hi_u32 group;
955 } mac_igmp_header_stru;
956 
957 /*  Group record format
958       +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
959       |  Record Type  |  Aux Data Len |     Number of Sources (N)     |
960       +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
961       |                       Multicast Address                       |
962       +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
963       |                       Source Address [1]                      |
964       +-                                                             -+
965       |                       Source Address [2]                      |
966       +-                                                             -+
967       .                               .                               .
968       .                               .                               .
969       .                               .                               .
970       +-                                                             -+
971       |                       Source Address [N]                      |
972       +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
973       |                                                               |
974       .                                                               .
975       .                         Auxiliary Data                        .
976       .                                                               .
977       |                                                               |
978       +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
979  */
980 typedef struct mac_igmp_v3_grec {
981     hi_u8     grec_type;
982     hi_u8     grec_auxwords;
983     hi_u16    us_grec_nsrcs;
984     hi_u32    grec_mca;
985 } mac_igmp_v3_grec_stru;
986 
987 /* IGMPv3 report format
988        0                   1                   2                   3
989        0 1 2 3 4 5 6 7 8 9 0 1 2 3 4 5 6 7 8 9 0 1 2 3 4 5 6 7 8 9 0 1
990       +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
991       |  Type = 0x22  |    Reserved   |           Checksum            |
992       +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
993       |           Reserved            |  Number of Group Records (M)  |
994       +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
995       |                                                               |
996       .                                                               .
997       .                        Group Record [1]                       .
998       .                                                               .
999       |                                                               |
1000       +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
1001       |                                                               |
1002       .                                                               .
1003       .                        Group Record [2]                       .
1004       .                                                               .
1005       |                                                               |
1006       +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
1007       |                               .                               |
1008       .                               .                               .
1009       |                               .                               |
1010       +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
1011       |                                                               |
1012       .                                                               .
1013       .                        Group Record [M]                       .
1014       .                                                               .
1015       |                                                               |
1016       +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
1017  */
1018 typedef struct mac_igmp_v3_report {
1019     hi_u8     type;
1020     hi_u8     resv1;
1021     hi_u16    us_csum;
1022     hi_u16    us_resv2;
1023     hi_u16    us_ngrec;
1024 } mac_igmp_v3_report_stru;
1025 
1026 typedef struct mac_tcp_header {
1027     hi_u16  us_sport;
1028     hi_u16  us_dport;
1029     hi_u32  seqnum;
1030     hi_u32  acknum;
1031     hi_u8   offset;
1032     hi_u8   flags;
1033     hi_u16  us_window;
1034     hi_u16  us_check;
1035     hi_u16  us_urgent;
1036 } mac_tcp_header_stru;
1037 
1038 /* UDP头部结构 */
1039 typedef struct _udp_hdr_stru {
1040     hi_u16 us_src_port;
1041     hi_u16 us_des_port;
1042     hi_u16 us_udp_len;
1043     hi_u16 us_check_sum;
1044 } udp_hdr_stru;
1045 
1046 typedef struct dhcp_message {
1047     hi_u8 op;                           /* message type */
1048     hi_u8 hwtype;                       /* hardware address type */
1049     hi_u8 hwlen;                        /* hardware address length */
1050     hi_u8 hwopcount;                    /* should be zero in client message */
1051     hi_u32 xid;                         /* transaction id */
1052     hi_u16 secs;                        /* elapsed time in sec. from boot */
1053     hi_u16 flags;
1054     hi_u32 ciaddr;                      /* (previously allocated) client IP */
1055     hi_u32 yiaddr;                      /* 'your' client IP address */
1056     hi_u32 siaddr;                      /* should be zero in client's messages */
1057     hi_u32 giaddr;                      /* should be zero in client's messages */
1058     hi_u8 chaddr[DHCP_CHADDR_LEN];      /* client's hardware address */
1059     hi_u8 servername[SERVERNAME_LEN];   /* server host name */
1060     hi_u8 bootfile[BOOTFILE_LEN];       /* boot file name */
1061     hi_u32 cookie;
1062     hi_u8 options[DHCP_OPTION_LEN];     /* message options, cookie */
1063 } dhcp_message_stru;
1064 
1065 /* frame control字段结构体 */
1066 struct mac_header_frame_control {
1067     hi_u16  protocol_version    : 2,        /* 协议版本 */
1068                 type                : 2,        /* 帧类型 */
1069                 sub_type            : 4,        /* 子类型 */
1070                 to_ds               : 1,        /* 发送DS */
1071                 from_ds             : 1,        /* 来自DS */
1072                 more_frag           : 1,        /* 分段标识 */
1073                 retry               : 1,        /* 重传帧 */
1074                 power_mgmt          : 1,        /* 节能管理 */
1075                 more_data           : 1,        /* 更多数据标识 */
1076                 protected_frame     : 1,        /* 加密标识 */
1077                 order               : 1;        /* 次序位 */
1078 } __OAL_DECLARE_PACKED;
1079 typedef struct mac_header_frame_control mac_header_frame_control_stru;
1080 
1081 /* 基础802.11帧结构 */
1082 typedef struct mac_ieee80211_frame {
1083     mac_header_frame_control_stru   frame_control;
1084     hi_u16
1085                                     duration_value      : 15,
1086                                     duration_flag       : 1;
1087     hi_u8                       auc_address1[WLAN_MAC_ADDR_LEN];
1088     hi_u8                       auc_address2[WLAN_MAC_ADDR_LEN];
1089     hi_u8                       auc_address3[WLAN_MAC_ADDR_LEN];
1090     hi_u16                      frag_num    : 4,
1091                                     seq_num     : 12;
1092 } mac_ieee80211_frame_stru;
1093 
1094 /* ps poll帧结构 */
1095 typedef struct mac_ieee80211_pspoll_frame {
1096     mac_header_frame_control_stru   frame_control;
1097     hi_u16                      aid_value   : 14,                   /* ps poll 下的AID字段 */
1098                                 aid_flag1   : 1,
1099                                 aid_flag2   : 1;
1100     hi_u8                       auc_bssid[WLAN_MAC_ADDR_LEN];
1101     hi_u8                       auc_trans_addr[WLAN_MAC_ADDR_LEN];
1102 } mac_ieee80211_pspoll_frame_stru;
1103 
1104 union mac_ieee80211_qos_control {
1105     hi_u8                       qc_txop_limit;
1106     hi_u8                       qc_ps_buf_state_resv        : 1,
1107                                 qc_ps_buf_state_inducated   : 1,
1108                                 bit_qc_hi_priority_buf_ac       : 2,
1109                                 qc_qosap_buf_load           : 4;
1110 } __OAL_DECLARE_PACKED;
1111 typedef union mac_ieee80211_qos_control mac_ieee80211_qos_control;
1112 
1113 /* qos帧结构 */
1114 struct mac_ieee80211_qos_frame {
1115     mac_ieee80211_frame_stru frame;
1116 
1117     /* qos info and control */
1118     hi_u8                           qc_tid          : 4,
1119                                     qc_eosp         : 1,
1120                                     qc_ack_polocy   : 2,
1121                                     qc_amsdu        : 1;
1122     mac_ieee80211_qos_control       qos_control;
1123     hi_u8                           auc_htc[0];
1124 }__OAL_DECLARE_PACKED;
1125 typedef struct mac_ieee80211_qos_frame mac_ieee80211_qos_frame_stru;
1126 
1127 /* 四地址帧结构体 */
1128 struct mac_ieee80211_frame_addr4 {
1129     mac_header_frame_control_stru   frame_control;
1130     hi_u16
1131                                     duration_value      : 15,
1132                                     duration_flag       : 1;
1133     hi_u8                       auc_address1[WLAN_MAC_ADDR_LEN];
1134     hi_u8                       auc_address2[WLAN_MAC_ADDR_LEN];
1135     hi_u8                       auc_address3[WLAN_MAC_ADDR_LEN];
1136     hi_u16                      frag_num            : 4,
1137                                     seq_num             : 12;
1138     hi_u8                       auc_address4[WLAN_MAC_ADDR_LEN];
1139 } __OAL_DECLARE_PACKED;
1140 typedef struct mac_ieee80211_frame_addr4 mac_ieee80211_frame_addr4_stru;
1141 
1142 /* qos四地址帧结构 */
1143 struct mac_ieee80211_qos_frame_addr4 {
1144     mac_ieee80211_frame_addr4_stru frame_addr4;
1145     /* qos info and control */
1146     hi_u8                           qc_tid          : 4,
1147                                     qc_eosp         : 1,
1148                                     qc_ack_polocy   : 2,
1149                                     qc_amsdu        : 1;
1150     mac_ieee80211_qos_control qos_control;
1151 } __OAL_DECLARE_PACKED;
1152 typedef struct mac_ieee80211_qos_frame_addr4 mac_ieee80211_qos_frame_addr4_stru;
1153 
1154 /* qos htc 四地址帧结构 */
1155 struct mac_ieee80211_qos_htc_frame_addr4 {
1156     mac_ieee80211_qos_frame_addr4_stru qos_frame_addr4;
1157     hi_u32 htc;
1158 } __OAL_DECLARE_PACKED;
1159 typedef struct mac_ieee80211_qos_htc_frame_addr4 mac_ieee80211_qos_htc_frame_addr4_stru;
1160 
1161 /* Ref. 802.11-2012.pdf, 8.4.1.4 Capability information field, 中文注释参考白皮书 */
1162 struct mac_cap_info {
1163     hi_u16  ess                     : 1,        /* 由BSS中的AP设置为1 */
1164                 ibss                : 1,        /* 由一个IBSS中的站点设置为1,ap总是设置其为0 */
1165                 cf_pollable         : 1,        /* 标识CF-POLL能力 */
1166                 cf_poll_request     : 1,        /* 标识CF-POLL能力  */
1167                 privacy             : 1,        /* 1=需要加密, 0=不需要加密 */
1168                 short_preamble      : 1,        /* 802.11b短前导码 */
1169                 pbcc                : 1,        /* 802.11g */
1170                 channel_agility     : 1,        /* 802.11b */
1171                 spectrum_mgmt       : 1,        /* 频谱管理: 0=不支持, 1=支持 */
1172                 qos                 : 1,        /* QOS: 0=非QOS站点, 1=QOS站点 */
1173                 short_slot_time     : 1,        /* 短时隙: 0=不支持, 1=支持 */
1174                 apsd                : 1,        /* 自动节能: 0=不支持, 1=支持 */
1175                 radio_measurement   : 1,        /* Radio检测: 0=不支持, 1=支持 */
1176                 dsss_ofdm           : 1,        /* 802.11g */
1177                 delayed_block_ack   : 1,        /* 延迟块确认: 0=不支持, 1=支持 */
1178                 immediate_block_ack : 1;        /* 立即块确认: 0=不支持, 1=支持 */
1179 } __OAL_DECLARE_PACKED;
1180 typedef struct mac_cap_info mac_cap_info_stru;
1181 
1182 /* Ref. 802.11-2012.pdf, 8.4.2.58.2 HT Capabilities Info field */
1183 struct mac_frame_ht_cap {
1184     hi_u16          ldpc_coding_cap             : 1,        /* LDPC 编码 capability    */
1185                         supported_channel_width : 1,    /* STA 支持的带宽          */
1186                         sm_power_save           : 2,    /* SM 省电模式             */
1187                         ht_green_field          : 1,    /* 绿野模式                */
1188                         short_gi_20mhz          : 1,    /* 20M下短保护间隔         */
1189                         short_gi_40mhz          : 1,    /* 40M下短保护间隔         */
1190                         tx_stbc                 : 1,    /* Indicates support for the transmission of PPDUs using STBC */
1191                         rx_stbc                 : 2,    /* 支持 Rx STBC            */
1192                         ht_delayed_block_ack    : 1,    /* Indicates support for HT-delayed Block Ack opera-tion. */
1193                         max_amsdu_length        : 1,    /* Indicates maximum A-MSDU length. */
1194                         dsss_cck_mode_40mhz     : 1,    /* 40M下 DSSS/CCK 模式     */
1195                         bit_resv                : 1,
1196                         /* Indicates whether APs receiving this information or reports of this informa-tion are
1197                             required to prohibit 40 MHz transmissions */
1198                         forty_mhz_intolerant    : 1,
1199                         lsig_txop_protection    : 1;    /* 支持 L-SIG TXOP 保护    */
1200 } __OAL_DECLARE_PACKED;
1201 typedef struct mac_frame_ht_cap mac_frame_ht_cap_stru;
1202 
1203 typedef struct mac_vht_cap_info {
1204     hi_u32  max_mpdu_length             : 2,
1205                 supported_channel_width : 2,
1206                 rx_ldpc                 : 1,
1207                 short_gi_80mhz          : 1,
1208                 short_gi_160mhz         : 1,
1209                 tx_stbc                 : 1,
1210                 rx_stbc                 : 3,
1211                 su_beamformer_cap       : 1,
1212                 su_beamformee_cap       : 1,
1213                 num_bf_ant_supported    : 3,
1214                 num_sounding_dim        : 3,
1215                 mu_beamformer_cap       : 1,
1216                 mu_beamformee_cap       : 1,
1217                 vht_txop_ps             : 1,
1218                 htc_vht_capable         : 1,
1219                 max_ampdu_len_exp       : 3,
1220                 vht_link_adaptation     : 2,
1221                 rx_ant_pattern          : 1,
1222                 tx_ant_pattern          : 1,
1223                 bit_resv                    : 2;
1224 } mac_vht_cap_info_stru;
1225 
1226 typedef struct mac_11ntxbf_info {
1227     hi_u8           ntxbf                   :1,          /* 11n txbf  能力 */
1228                     reserve                 :7;
1229     hi_u8           auc_reserve[3]; /* 3 byte保留字段 */
1230 } mac_11ntxbf_info_stru;
1231 
1232 struct mac_11ntxbf_vendor_ie {
1233     hi_u8                        id;          /* element ID */
1234     hi_u8                        len;         /* length in bytes */
1235     hi_u8                        auc_oui[MAC_OUI_LEN];
1236     hi_u8                        ouitype;
1237     mac_11ntxbf_info_stru        ntxbf;
1238 } __OAL_DECLARE_PACKED;
1239 typedef struct mac_11ntxbf_vendor_ie mac_11ntxbf_vendor_ie_stru;
1240 
1241 /* 厂家自定义IE 数据结构,摘自linux 内核 */
1242 struct mac_ieee80211_vendor_ie {
1243     hi_u8 element_id;
1244     hi_u8 len;
1245     hi_u8 auc_oui[MAC_OUI_LEN];
1246     hi_u8 oui_type;
1247 } __OAL_DECLARE_PACKED;
1248 typedef struct mac_ieee80211_vendor_ie mac_ieee80211_vendor_ie_stru;
1249 
1250 /* 建立BA会话时,BA参数域结构定义 */
1251 struct mac_ba_parameterset {
1252 #if (_PRE_BIG_CPU_ENDIAN == _PRE_CPU_ENDIAN)            /* BIG_ENDIAN */
1253     hi_u16  buffersize          : 10,               /* B6-15  buffer size */
1254                 tid             : 4,                /* B2-5   TID */
1255                 bapolicy        : 1,                /* B1   block ack policy */
1256                 amsdusupported  : 1;                /* B0   amsdu supported */
1257 #else
1258     hi_u16  amsdusupported      : 1,                /* B0   amsdu supported */
1259                 bapolicy        : 1,                /* B1   block ack policy */
1260                 tid             : 4,                /* B2-5   TID */
1261                 buffersize      : 10;               /* B6-15  buffer size */
1262 #endif
1263 } __OAL_DECLARE_PACKED;
1264 typedef struct mac_ba_parameterset mac_ba_parameterset_stru;
1265 
1266 /* BA会话过程中的序列号参数域定义 */
1267 struct mac_ba_seqctrl {
1268 #if (_PRE_BIG_CPU_ENDIAN == _PRE_CPU_ENDIAN) /* BIG_ENDIAN */
1269     hi_u16 startseqnum : 12, /* B4-15  starting sequence number */
1270     fragnum            : 4;  /* B0-3  fragment number */
1271 #else
1272     hi_u16 fragnum     : 4,  /* B0-3  fragment number */
1273     startseqnum        : 12; /* B4-15  starting sequence number */
1274 #endif
1275 } __OAL_DECLARE_PACKED;
1276 typedef struct mac_ba_seqctrl mac_ba_seqctrl_stru;
1277 
1278 /* Quiet信息元素结构体 */
1279 struct mac_quiet_ie {
1280     hi_u8     quiet_count;
1281     hi_u8     quiet_period;
1282     hi_u16    quiet_duration;
1283     hi_u16    quiet_offset;
1284 } __OAL_DECLARE_PACKED;
1285 typedef struct mac_quiet_ie mac_quiet_ie_stru;
1286 
1287 /* erp 信息元素结构体 */
1288 struct mac_erp_params {
1289     hi_u8       non_erp       : 1,
1290                 use_protection: 1,
1291                 preamble_mode : 1,
1292                 bit_resv      : 5;
1293 } __OAL_DECLARE_PACKED;
1294 typedef struct mac_erp_params mac_erp_params_stru;
1295 
1296 /* rsn信息元素 rsn能力字段结构体 */
1297 struct mac_rsn_cap {
1298     hi_u16  pre_auth                : 1,
1299                 no_pairwise         : 1,
1300                 ptska_relay_counter : 2,
1301                 gtska_relay_counter : 2,
1302                 mfpr                : 1,
1303                 mfpc                : 1,
1304                 rsv0                : 1,
1305                 peer_key            : 1,
1306                 spp_amsdu_capable   : 1,
1307                 spp_amsdu_required  : 1,
1308                 pbac                : 1,
1309                 ext_key_id          : 1,
1310                 rsv1                : 2;
1311 } __OAL_DECLARE_PACKED;
1312 typedef struct mac_rsn_cap mac_rsn_cap_stru;
1313 
1314 /* obss扫描ie obss扫描参数结构体 */
1315 struct mac_obss_scan_params {
1316     hi_u16 us_passive_dwell;
1317     hi_u16 us_active_dwell;
1318     hi_u16 us_scan_interval;
1319     hi_u16 us_passive_total_per_chan;
1320     hi_u16 us_active_total_per_chan;
1321     hi_u16 us_transition_delay_factor;
1322     hi_u16 us_scan_activity_thresh;
1323 } __OAL_DECLARE_PACKED;
1324 typedef struct mac_obss_scan_params mac_obss_scan_params_stru;
1325 
1326 /* 扩展能力信息元素结构体定义 */
1327 typedef struct mac_ext_cap_ie {
1328     hi_u8   coexistence_mgmt: 1,
1329                 resv1                : 1,
1330                 ext_chan_switch      : 1,
1331                 resv2                : 1,
1332                 psmp                 : 1,
1333                 resv3                : 1,
1334                 s_psmp               : 1,
1335                 event                : 1;
1336     hi_u8   resv4                : 4,
1337                 proxyarp             : 1,
1338                 resv13               : 3;
1339     hi_u8   resv5                : 8;
1340     hi_u8   resv6                : 8;
1341     hi_u8   resv7                         : 5,
1342                 tdls_prhibited                : 1,
1343                 tdls_channel_switch_prhibited : 1,
1344                 resv8                         : 1;
1345 
1346     hi_u8   resv9                : 8;
1347     hi_u8   resv10               : 8;
1348 
1349     hi_u8   resv11                        : 6,
1350                 operating_mode_notification   : 1, /* 11ac Operating Mode Notification特性标志 */
1351                 resv12                        : 1;
1352 } mac_ext_cap_ie_stru;
1353 /* qos info字段结构体定义 */
1354 struct mac_qos_info {
1355     hi_u8   params_count: 4,
1356                 bit_resv        : 3,
1357                 uapsd       : 1;
1358 }__OAL_DECLARE_PACKED;
1359 typedef struct mac_qos_info mac_qos_info_stru;
1360 
1361 /* wmm信息元素 ac参数结构体 */
1362 typedef struct mac_wmm_ac_params {
1363     hi_u8   aifsn : 4,
1364                 acm   : 1,
1365                 aci   : 2,
1366                 bit_resv  : 1;
1367     hi_u8   ecwmin: 4,
1368                 ecwmax: 4;
1369     hi_u16  us_txop;
1370 } mac_wmm_ac_params_stru;
1371 /* BSS load信息元素结构体 */
1372 struct mac_bss_load {
1373     hi_u16 us_sta_count;            /* 关联的sta个数 */
1374     hi_u8  chan_utilization;        /* 信道利用率 */
1375     hi_u8  resv;
1376     hi_u16 us_aac;
1377 } __OAL_DECLARE_PACKED;
1378 typedef struct mac_bss_load mac_bss_load_stru;
1379 
1380 /* country信息元素 管制域字段 */
1381 struct mac_country_reg_field {
1382     hi_u8 first_channel;         /* 第一个信道号 */
1383     hi_u8 channel_num;           /* 信道个数 */
1384     hi_u8 max_tx_pwr;            /* 最大传输功率,dBm */
1385 } __OAL_DECLARE_PACKED;
1386 typedef struct mac_country_reg_field mac_country_reg_field_stru;
1387 
1388 /* ht capabilities信息元素支持的ampdu parameters字段结构体定义 */
1389 struct mac_ampdu_params {
1390     hi_u8  max_ampdu_len_exponent  : 2,
1391                min_mpdu_start_spacing  : 3,
1392                bit_resv                    : 3;
1393 }__OAL_DECLARE_PACKED;
1394 typedef struct mac_ampdu_params mac_ampdu_params_stru;
1395 
1396 /* ht cap信息元素 支持的mcs集字段 结构体定义 */
1397 typedef struct mac_sup_mcs_set {
1398     hi_u8   auc_rx_mcs[WLAN_HT_MCS_BITMASK_LEN];
1399     hi_u16  rx_highest_rate: 10,
1400                 resv1          : 6;
1401     hi_u32  tx_mcs_set_def : 1,
1402                 tx_rx_not_equal: 1,
1403                 tx_max_stream  : 2,
1404                 tx_unequal_modu: 1,
1405                 resv2          : 27;
1406 }mac_sup_mcs_set_stru;
1407 
1408 /* vht信息元素,支持的mcs集字段 */
1409 typedef struct mac_vht_sup_mcs_set {
1410     hi_u32  rx_mcs_map      : 16,
1411                 rx_highest_rate : 13,
1412                 bit_resv            : 3;
1413     hi_u32  tx_mcs_map      : 16,
1414                 tx_highest_rate : 13,
1415                 resv2           : 3;
1416 }mac_vht_sup_mcs_set_stru;
1417 /* ht capabilities信息元素支持的extended cap.字段结构体定义 */
1418 struct mac_ext_cap {
1419     hi_u16  pco           : 1,                   /* */
1420                 pco_trans_time: 2,
1421                 resv1         : 5,
1422                 mcs_fdbk      : 2,
1423                 htc_sup       : 1,
1424                 rd_resp       : 1,
1425                 resv2         : 4;
1426 }__OAL_DECLARE_PACKED;
1427 typedef struct mac_ext_cap mac_ext_cap_stru;
1428 
1429 /* ht cap信息元素的Transmit Beamforming Capabilities字段结构体定义 */
1430 typedef struct mac_txbf_cap {
1431     hi_u32  implicit_txbf_rx                : 1,
1432                 rx_stagg_sounding               : 1,
1433                 tx_stagg_sounding               : 1,
1434                 rx_ndp                          : 1,
1435                 tx_ndp                          : 1,
1436                 implicit_txbf                   : 1,
1437                 calibration                     : 2,
1438                 explicit_csi_txbf               : 1,
1439                 explicit_noncompr_steering      : 1,
1440                 explicit_compr_steering         : 1,
1441                 explicit_txbf_csi_fdbk          : 2,
1442                 explicit_noncompr_bf_fdbk       : 2,
1443                 explicit_compr_bf_fdbk          : 2,
1444                 minimal_grouping                : 2,
1445                 csi_num_bf_antssup              : 2,
1446                 noncompr_steering_num_bf_antssup: 2,
1447                 compr_steering_num_bf_antssup   : 2,
1448                 csi_maxnum_rows_bf_sup          : 2,
1449                 chan_estimation                 : 2,
1450                 resv2                           : 3;
1451 }mac_txbf_cap_stru;
1452 /* ht cap信息元素的Asel(antenna selection) Capabilities字段结构体定义 */
1453 struct mac_asel_cap {
1454     hi_u8  asel                         : 1,
1455                explicit_sci_fdbk_tx_asel    : 1,
1456                antenna_indices_fdbk_tx_asel : 1,
1457                explicit_csi_fdbk            : 1,
1458                antenna_indices_fdbk         : 1,
1459                rx_asel                      : 1,
1460                trans_sounding_ppdu          : 1,
1461                bit_resv                         : 1;
1462 }__OAL_DECLARE_PACKED;
1463 typedef struct mac_asel_cap mac_asel_cap_stru;
1464 
1465 /* ht opern元素, ref 802.11-2012 8.4.2.59 */
1466 struct mac_ht_opern {
1467     hi_u8   primary_channel;
1468 
1469     hi_u8   secondary_chan_offset             : 2,
1470                 sta_chan_width                    : 1,
1471                 rifs_mode                         : 1,
1472                 resv1                             : 4;
1473     hi_u8   ht_protection                     : 2,
1474                 nongf_sta_present                 : 1,
1475                 resv2                             : 1,
1476                 obss_nonht_sta_present            : 1,
1477                 resv3                             : 3;
1478     hi_u8   resv4                             : 8;
1479     hi_u8   resv5                             : 6,
1480                 dual_beacon                       : 1,
1481                 dual_cts_protection               : 1;
1482     hi_u8   secondary_beacon                  : 1,
1483                 lsig_txop_protection_full_support : 1,
1484                 pco_active                        : 1,
1485                 pco_phase                         : 1,
1486                 resv6                             : 4;
1487 
1488     hi_u8   auc_basic_mcs_set[MAC_HT_BASIC_MCS_SET_LEN];
1489 }__OAL_DECLARE_PACKED;
1490 typedef struct mac_ht_opern mac_ht_opern_stru;
1491 
1492 /* vht opern结构体 */
1493 struct mac_opmode_notify {
1494     hi_u8   channel_width       : 2,     /* 当前最大允许带宽能力 */
1495                 bit_resv        : 2,     /* 保留 */
1496                 rx_nss          : 3,     /* 当前最大允许空间流能力 */
1497                 rx_nss_type     : 1;     /* 是否为TXBF下的rx nss能力,1-是,0不是 */
1498 } __OAL_DECLARE_PACKED;
1499 typedef struct mac_opmode_notify mac_opmode_notify_stru;
1500 
1501 /* vht opern结构体 */
1502 struct mac_vht_opern {
1503     hi_u8   channel_width;
1504     hi_u8   channel_center_freq_seg0;
1505     hi_u8   channel_center_freq_seg1;
1506     hi_u8   resv;
1507     hi_u16  us_basic_mcs_set;
1508 } __OAL_DECLARE_PACKED;
1509 typedef struct mac_vht_opern mac_vht_opern_stru;
1510 
1511 /* 02 dev侧用#pragma pack(1)/#pragma pack()方式达到一字节对齐 */
1512 #pragma pack()
1513 
1514 /* ACTION帧的参数格式,注:不同的action帧下对应的参数不同 */
1515 typedef struct {
1516     hi_u8       category;    /* ACTION的类别 */
1517     hi_u8       action;      /* 不同ACTION类别下的分类 */
1518     hi_u8       uc_resv[2];  /* 2 byte保留字段 */
1519     hi_u32      arg1;
1520     hi_u32      arg2;
1521     hi_u32      arg3;
1522     hi_u32      arg4;
1523     hi_u8      *puc_arg5;
1524 } mac_action_mgmt_args_stru;
1525 
1526 /* 私有管理帧通用的设置参数信息的结构体 */
1527 typedef struct {
1528     hi_u8       type;
1529     hi_u8       arg1;        /* 对应的tid序号 */
1530     hi_u8       arg2;        /* 接收端可接收的最大的mpdu的个数(针对AMPDU_START命令) */
1531     hi_u8       arg3;        /* 确认策略 */
1532     hi_u8       user_idx;    /* 对应的用户 */
1533     hi_u8       auc_resv[3]; /* 3 byte保留字段 */
1534 } mac_priv_req_args_stru;
1535 
1536 #ifdef _PRE_WLAN_FEATURE_MESH_ROM
1537 struct mesh_formation_info {
1538     hi_u8 connected_to_mesh_gate: 1,    /* 是否有指向Mesh Gate的路径(本Mesh方案不用) */
1539           number_of_peerings: 6,        /* 当前已连接数 */
1540           connected_to_as: 1;           /* 是否有到AS的连接(IEEE 802.1x 认证) */
1541 } __OAL_DECLARE_PACKED;
1542 typedef struct mesh_formation_info mesh_formation_info_stru;
1543 
1544 struct mesh_capability_field {
1545     hi_u8 accepting_add_mesh_peerings: 1,
1546           mcca_supported: 1,
1547           mcca_enabled: 1,
1548           forwarding: 1,
1549           mbca_enabled: 1,
1550           tbtt_adjusting: 1,
1551           mesh_power_save_level: 1,
1552           bit_resv: 1;
1553 } __OAL_DECLARE_PACKED;
1554 typedef struct mesh_capability_field mesh_capability_stru;
1555 
1556 struct mesh_report_control_field {
1557     hi_u8 status_number                 : 4,
1558           beacon_timing_element_number  : 3,
1559           more_beacon_timing_elements   : 1;
1560     hi_u8 resv[3];              /* reserve 3byte */
1561 };
1562 typedef struct mesh_report_control_field mesh_report_control_stru;
1563 
1564 typedef struct {
1565     hi_u8 neighbor_sta_id;
1566     hi_u8 neighbor_tbtt[3];            /* tbtt占用3 byte */
1567     hi_u8 neighbor_beacon_interval[2]; /* beacon_interval占用2byte */
1568     hi_u8 auc_rsv[2];                  /* 2 byte保留字段 */
1569 } mesh_beacon_timing_information_stru;
1570 
1571 struct mac_mesh_conf_ie {
1572     hi_u8 ie_id;
1573     hi_u8 len;
1574     hi_u8 active_path_sel_proto_id;
1575     hi_u8 active_path_sel_metric_id;
1576     hi_u8 congestion_control_mode_id;
1577     hi_u8 syn_method_id;
1578     hi_u8 auth_proto_id;
1579     mesh_formation_info_stru mesh_formation_info;
1580     mesh_capability_stru mesh_capa;
1581 } __OAL_DECLARE_PACKED;
1582 typedef struct mac_mesh_conf_ie mac_mesh_conf_ie_stru;
1583 #endif
1584 
1585 #ifdef _PRE_WLAN_FEATURE_ANY
1586 typedef struct mac_action_header {
1587     hi_u8 category;
1588     hi_u8 auc_oui[MAC_OUI_LEN];
1589     hi_u8 type;
1590     hi_u8 seq_num;
1591     hi_u8 sub_type;
1592     hi_u8 length;
1593 } mac_action_header_stru;
1594 #endif
1595 
1596 typedef struct _mac_action_data_stru {
1597     hi_u32 freq;
1598     hi_u32 wait;
1599     hi_u8 dst[WLAN_MAC_ADDR_LEN];
1600     hi_u8 src[WLAN_MAC_ADDR_LEN];
1601     hi_u8 bssid[WLAN_MAC_ADDR_LEN];
1602     hi_u8 resv[2]; /* 2 byte保留字段 */
1603     hi_u8 *data;
1604     hi_u32 data_len;
1605     hi_u32 no_cck;
1606 } mac_action_data_stru;
1607 
1608 typedef struct mac_set_quiet_ie_info_stru {
1609     hi_u8 qcount;
1610     hi_u8 qperiod;
1611     hi_u8 resv[2]; /* 2 byte保留字段 */
1612     hi_u16 us_qduration;
1613     hi_u16 us_qoffset;
1614 } mac_set_quiet_ie_info_stru;
1615 
1616 /* ****************************************************************************
1617   函数声明
1618 **************************************************************************** */
1619 hi_void mac_set_power_cap_ie(hi_u8 *vap, hi_u8 *puc_buffer, hi_u8 *puc_ie_len);
1620 hi_void mac_set_supported_channel_ie(hi_u8 *vap, hi_u8 *puc_buffer, hi_u8 *puc_ie_len);
1621 hi_void mac_set_wmm_ie_sta(hi_u8 *vap, hi_u8 *puc_buffer, hi_u8 *puc_ie_len);
1622 hi_void mac_set_listen_interval_ie(hi_u8 *puc_buffer, hi_u8 *puc_ie_len);
1623 hi_void mac_set_status_code_ie(hi_u8 *puc_buffer, mac_status_code_enum_uint16 status_code);
1624 hi_void mac_set_aid_ie(hi_u8 *puc_buffer, hi_u16 aid);
1625 hi_void mac_set_beacon_interval_field(hi_void *vap, hi_u8 *puc_buffer);
1626 hi_void mac_set_cap_info_ap(hi_void *vap, hi_u8 *puc_cap_info);
1627 hi_void mac_set_cap_info_sta(hi_void *vap, hi_u8 *puc_cap_info);
1628 hi_u16 mac_set_ssid_ie(hi_void *vap, hi_u8 *puc_buffer, hi_u8 *puc_ie_len, hi_u16 us_frm_type);
1629 hi_void mac_set_supported_rates_ie(hi_void *vap, hi_u8 *puc_buffer, hi_u8 *puc_ie_len);
1630 hi_void mac_set_dsss_params(hi_void *vap, hi_u16 us_frm_type, hi_u8 *puc_buffer, hi_u8 *puc_ie_len);
1631 hi_void mac_set_pwrconstraint_ie(hi_void *vap, hi_u8 *puc_buffer, hi_u8 *puc_ie_len);
1632 hi_void mac_set_erp_ie(hi_void *vap, hi_u8 *puc_buffer, hi_u8 *puc_ie_len);
1633 hi_void mac_set_exsup_rates_ie(hi_void *vap, hi_u8 *puc_buffer, hi_u8 *puc_ie_len);
1634 hi_void mac_set_bssload_ie(hi_void *vap, hi_u8 *puc_buffer, hi_u8 *puc_ie_len);
1635 hi_void mac_set_ht_capabilities_ie(hi_void *vap, hi_u8 *puc_buffer, hi_u8 *puc_ie_len);
1636 hi_void mac_set_ht_opern_ie(hi_void *vap, hi_u8 *puc_buffer, hi_u8 *puc_ie_len);
1637 hi_void mac_set_ext_capabilities_ie(hi_void *vap, hi_u8 *puc_buffer, hi_u8 *puc_ie_len);
1638 hi_void mac_set_tpc_report_ie(hi_void *vap, hi_u8 *puc_buffer, hi_u8 *puc_ie_len);
1639 hi_void mac_set_vht_capabilities_ie(hi_void *vap, hi_u8 *puc_buffer, hi_u8 *puc_ie_len);
1640 hi_void mac_set_vht_opern_ie(hi_void *vap, hi_u8 *puc_buffer, hi_u8 *puc_ie_len);
1641 hi_void mac_null_data_encap(hi_u8 *header, hi_u16 us_fc, const hi_u8 *da_mac_addr, const hi_u8 *sa_mac_addr);
1642 hi_u32 mac_prepare_action_frame_head(hi_u8 *puc_header, const hi_u8 *da_mac_addr, const hi_u8 *sa_mac_addr);
1643 hi_u8 mac_prepare_action_frame_body(hi_u8 *puc_body, hi_u8 body_len, hi_u8 category, const hi_u8 *puc_elements,
1644     hi_u8 element_len);
1645 hi_void mac_set_snap(oal_netbuf_stru *netbuf, hi_u16 us_ether_type, hi_u8 offset);
1646 hi_void mac_add_app_ie(hi_void *vap, hi_u8 *puc_buffer, hi_u16 *pus_ie_len, en_app_ie_type_uint8 type);
1647 hi_void mac_add_wps_ie(hi_void *vap, hi_u8 *puc_buffer, hi_u16 *pus_ie_len, en_app_ie_type_uint8 type);
1648 hi_void mac_check_sta_base_rate(hi_u8 *mac_user, mac_status_code_enum_uint16 *pen_status_code);
1649 hi_void mac_set_wmm_params_ie(hi_void *vap, hi_u8 *puc_buffer, hi_u8 is_qos, hi_u8 *puc_ie_len);
1650 hi_void mac_set_quiet_ie(hi_void *vap, hi_u8 *puc_buffer, const mac_set_quiet_ie_info_stru *mac_set_quiet_ie_info,
1651     hi_u8 *puc_ie_len);
1652 hi_void mac_set_security_ie_authenticator(hi_void *vap, hi_u8 *puc_buffer, hi_u8 *puc_ie_len, hi_u8 mode);
1653 hi_void mac_set_timeout_interval_ie(hi_u8 *puc_buffer, hi_u8 *puc_ie_len, hi_u32 type, hi_u32 timeout);
1654 #ifdef _PRE_WLAN_FEATURE_11D
1655 hi_void mac_set_country_ie(hi_void *vap, hi_u8 *puc_buffer, hi_u8 *puc_ie_len);
1656 #endif
1657 hi_u8 mac_get_dtim_period(hi_u8 *puc_frame_body, hi_u16 us_frame_body_len);
1658 hi_u8 mac_get_dtim_cnt(hi_u8 *puc_frame_body, hi_u16 us_frame_body_len);
1659 hi_u8 mac_get_bss_type(hi_u16 us_cap_info);
1660 hi_u8 *mac_get_wmm_ie(hi_u8 *puc_beacon_body, hi_u16 us_frame_len, hi_u16 us_offset);
1661 hi_u8 *mac_find_ie(hi_u8 eid, hi_u8 *puc_ies, hi_u32 l_len);
1662 hi_u8 *mac_find_vendor_ie(hi_u32 oui, hi_u8 oui_type, hi_u8 *puc_ies, hi_s32 l_len);
1663 hi_u8 *mac_get_ssid(hi_u8 *puc_beacon_body, hi_s32 l_frame_body_len, hi_u8 *puc_ssid_len);
1664 hi_u16 mac_get_beacon_period(const hi_u8 *puc_beacon_body);
1665 hi_u16 mac_get_rsn_capability(const hi_u8 *puc_rsn_ie);
1666 hi_u32 mac_check_mac_privacy_ap(hi_u16 us_cap_info, hi_u8 *mac_ap);
1667 hi_u32 mac_check_mac_privacy_sta(hi_u16 us_cap_info, hi_u8 *mac_sta);
1668 hi_u32 mac_check_privacy(mac_cap_info_stru *cap_info, hi_u8 *mac_vap);
1669 hi_u8 mac_check_mac_privacy(hi_u16 us_cap_info, hi_u8 *vap);
1670 #ifdef _PRE_WLAN_FEATURE_PMF
1671 wlan_pmf_cap_status_uint8 mac_get_pmf_cap(hi_u8 *puc_ie, hi_u32 ie_len);
1672 #endif
1673 #ifdef _PRE_WLAN_FEATURE_MESH_ROM
1674 hi_void mac_set_meshid_ie(hi_void *vap, hi_u8 *puc_buffer, hi_u8 *puc_ie_len);
1675 hi_void mac_set_hisi_mesh_optimization_ie(hi_void *vap, hi_u8 *puc_buffer, hi_u8 *puc_ie_len);
1676 hi_void mac_set_mesh_configuration_ie(hi_void *vap, hi_u8 *puc_buffer, hi_u8 *puc_ie_len);
1677 hi_void mac_set_mesh_vendor_subtype(hi_u8 *puc_buffer, hi_u8 subtype, hi_u8 *puc_ie_len);
1678 hi_u8 mac_check_is_mesh_vap(hi_u8 *puc_buffer, hi_u8 puc_ie_len);
1679 hi_void mac_set_report_control_field(hi_void *vap, hi_u8 *puc_buffer, mesh_report_control_stru mesh_report_ctl);
1680 hi_void mac_set_mesh_formation_info_field(hi_void *vap, hi_u8 *puc_buffer);
1681 hi_void mac_set_mesh_capability_field(hi_void *vap, hi_u8 *puc_buffer);
1682 hi_void mac_set_rsn_mesh_ie_authenticator(hi_void *vap, hi_u8 *puc_buffer, hi_u16 us_frm_type, hi_u8 *puc_ie_len);
1683 hi_void mac_set_mesh_ssid_ie(hi_void *vap, hi_u8 *puc_buffer, hi_u8 *puc_ie_len, hi_u8 is_mesh_req);
1684 hi_u8 *mac_find_mesh_vendor_ie(hi_u8 oui_sub_type, hi_u8 *puc_ies, hi_u32 l_len);
1685 hi_u8 *mac_get_meshid(hi_u8 *puc_beacon_body, hi_s32 l_frame_body_len, hi_u8 *puc_meshid_len);
1686 hi_u8 mac_get_hisi_beacon_prio(hi_u8 *puc_beacon_body, hi_s32 l_frame_body_len);
1687 hi_u8 mac_get_hisi_en_is_mbr(hi_u8 *puc_beacon_body, hi_s32 l_frame_body_len);
1688 hi_u8 mac_get_hisi_accept_sta(hi_u8 *puc_beacon_body, hi_s32 l_frame_body_len);
1689 #endif
1690 #ifdef _PRE_WLAN_FEATURE_DBAC
1691 hi_u8 mac_dbac_is_vip_data(const oal_dev_netbuf_stru *dev_netbuf);
1692 hi_u8 mac_dbac_is_vip_mgmt(const oal_dev_netbuf_stru *dev_netbuf);
1693 #endif
1694 hi_void mac_get_qos_ctrl(const hi_u8 *puc_mac_hdr, hi_u8 *puc_qos_ctrl);
1695 hi_u8 mac_check_is_vendor_action(hi_u32 oui, const hi_u8 *puc_ies, hi_u16 us_len);
1696 hi_u8 mac_find_vendor_action(hi_u32 oui, hi_u8 oui_type, const hi_u8 *puc_ies, hi_s32 l_len);
1697 hi_u16 mac_set_mgmt_frame_header(hi_u8 *mac_header, hi_u16 frame_type, const hi_u8 *addr1, const hi_u8 *addr2,
1698     const hi_u8 *addr3);
1699 
1700 
1701 /* ****************************************************************************
1702  功能描述  : This function sets the 'frame control' bits in the MAC header of the
1703              input frame to the given 16-bit value.
1704 **************************************************************************** */
mac_hdr_set_frame_control(hi_u8 * puc_header,hi_u16 us_fc)1705 static inline hi_void mac_hdr_set_frame_control(hi_u8 *puc_header, hi_u16 us_fc)
1706 {
1707     *(hi_u16 *)puc_header = us_fc;
1708 }
1709 
1710 /* ****************************************************************************
1711  功能描述  : 设置MAC头duration字段
1712  输入参数  : puc_header : 指向mac帧头
1713              us_duration: 要设置的值
1714 **************************************************************************** */
mac_hdr_set_duration(hi_u8 * puc_header,hi_u16 frame_type,hi_u16 us_duration)1715 static inline hi_void mac_hdr_set_duration(hi_u8 *puc_header, hi_u16 frame_type, hi_u16 us_duration)
1716 {
1717     hi_u16 *pus_dur = (hi_u16 *)(puc_header + WLAN_HDR_DUR_OFFSET);
1718     if (frame_type == WLAN_FC0_SUBTYPE_BEACON) {
1719         *pus_dur = 0;
1720     } else {
1721         *pus_dur = us_duration;
1722     }
1723 }
1724 
1725 /* ****************************************************************************
1726  功能描述  : 设置MAC头分片序号字段
1727  输入参数  : puc_header : 指向mac帧头
1728              uc_frag_num: 分片序号
1729 **************************************************************************** */
mac_hdr_set_fragment_number(hi_u8 * puc_header,hi_u8 frag_num)1730 static inline hi_void mac_hdr_set_fragment_number(hi_u8 *puc_header, hi_u8 frag_num)
1731 {
1732     puc_header[WLAN_HDR_FRAG_OFFSET] &= 0xF0;
1733     puc_header[WLAN_HDR_FRAG_OFFSET] |= (frag_num & 0x0F);
1734 }
1735 
1736 /* ****************************************************************************
1737  功能描述  : This function sets the 'from ds' bit in the MAC header of the input frame
1738              to the given value stored in the LSB bit.
1739              The bit position of the 'from ds' in the 'frame control field' of the MAC
1740              header is represented by the bit pattern 0x00000010.
1741  输入参数  : puc_header-80211头部指针
1742              uc_from_ds -value
1743 **************************************************************************** */
mac_hdr_set_from_ds(hi_u8 * puc_header,hi_u8 from_ds)1744 static inline hi_void mac_hdr_set_from_ds(hi_u8 *puc_header, hi_u8 from_ds)
1745 {
1746     ((mac_header_frame_control_stru *)(puc_header))->from_ds = from_ds;
1747 }
1748 
1749 /* ****************************************************************************
1750  功能描述  : This function extracts the 'from ds' bit from the MAC header of the input frame.
1751              Returns the value in the LSB of the returned value.
1752  输入参数  : header-80211头部指针
1753 **************************************************************************** */
mac_hdr_get_from_ds(const hi_u8 * puc_header)1754 static inline hi_u8 mac_hdr_get_from_ds(const hi_u8 *puc_header)
1755 {
1756     return (hi_u8)((mac_header_frame_control_stru *)(puc_header))->from_ds;
1757 }
1758 
1759 /* ****************************************************************************
1760  功能描述  : This function sets the 'to ds' bit in the MAC header of the input frame
1761              to the given value stored in the LSB bit.
1762              The bit position of the 'to ds' in the 'frame control field' of the MAC
1763              header is represented by the bit pattern 0x00000001
1764  输入参数  : puc_header-80211头部指针
1765              uc_to_ds -value
1766 **************************************************************************** */
mac_hdr_set_to_ds(hi_u8 * puc_header,hi_u8 to_ds)1767 static inline hi_void mac_hdr_set_to_ds(hi_u8 *puc_header, hi_u8 to_ds)
1768 {
1769     ((mac_header_frame_control_stru *)(puc_header))->to_ds = to_ds;
1770 }
1771 
1772 /* ****************************************************************************
1773  功能描述  : This function extracts the 'to ds' bit from the MAC header of the input frame.
1774              Returns the value in the LSB of the returned value.
1775  输入参数  : puc_header-80211头部指针
1776 **************************************************************************** */
mac_hdr_get_to_ds(const hi_u8 * puc_header)1777 static inline hi_u8 mac_hdr_get_to_ds(const hi_u8 *puc_header)
1778 {
1779     return (hi_u8)((mac_header_frame_control_stru *)(puc_header))->to_ds;
1780 }
1781 
1782 /* ****************************************************************************
1783  功能描述  : 四地址获取帧头中的tid
1784 **************************************************************************** */
mac_get_tid_value_4addr(const hi_u8 * puc_header)1785 static inline hi_u8 mac_get_tid_value_4addr(const hi_u8 *puc_header)
1786 {
1787     return (puc_header[MAC_QOS_CTRL_FIELD_OFFSET_4ADDR] & 0x07); /* B0 - B2 */
1788 }
1789 
1790 /* ****************************************************************************
1791  功能描述  : 四地址获取帧头中的tid
1792 **************************************************************************** */
mac_get_tid_value(const hi_u8 * puc_header,hi_u8 is_4addr)1793 static inline hi_u8 mac_get_tid_value(const hi_u8 *puc_header, hi_u8 is_4addr)
1794 {
1795     if (is_4addr) {
1796         return (puc_header[MAC_QOS_CTRL_FIELD_OFFSET_4ADDR] & 0x07); /* B0 - B2 */
1797     } else {
1798         return (puc_header[MAC_QOS_CTRL_FIELD_OFFSET] & 0x07); /* B0 - B2 */
1799     }
1800 }
1801 
1802 /* ****************************************************************************
1803  功能描述  : 获取接受侦的seqence number
1804 **************************************************************************** */
mac_get_seq_num(const hi_u8 * puc_header)1805 static inline hi_u16 mac_get_seq_num(const hi_u8 *puc_header)
1806 {
1807     hi_u16 us_seq_num;
1808 
1809     us_seq_num = puc_header[23];         /* us_seq_num的bit 4 ~ 7,即为puc_header[23]的低4bit */
1810     us_seq_num <<= 4;                    /* 即将puc_header[23]的低4bit,放到us_seq_num的bit 4 ~ 7中 */
1811     us_seq_num |= (puc_header[22] >> 4); /* us_seq_num的最低4bit即为puc_header[22]的高4bit */
1812     return us_seq_num;
1813 }
1814 
1815 /* ****************************************************************************
1816  功能描述  : 设置帧的序列号
1817  输入参数  : [1]puc_header
1818              [2]us_seq_num
1819  返 回 值  : 无
1820 **************************************************************************** */
mac_set_seq_num(hi_u8 * puc_header,hi_u16 us_seq_num)1821 static inline hi_void mac_set_seq_num(hi_u8 *puc_header, hi_u16 us_seq_num)
1822 {
1823     puc_header[23] = (hi_u8)us_seq_num >> 4;    /* puc_header[23]的低4bit即为us_seq_num的bit 4 ~ 7 */
1824     puc_header[22] &= 0x0F;                     /* 将puc_header[22]的bit 4~7清0 */
1825     puc_header[22] |= (hi_u8)(us_seq_num << 4); /* puc_header[22]的高4bit即为us_seq_num的最低4bit */
1826 }
1827 
1828 /* ****************************************************************************
1829  功能描述  : 获取BAR帧中的start seq num值
1830 **************************************************************************** */
mac_get_bar_start_seq_num(const hi_u8 * puc_payload)1831 static inline hi_u16 mac_get_bar_start_seq_num(const hi_u8 *puc_payload)
1832 {
1833     hi_u16 seq_num = ((puc_payload[2] & 0xF0) >> 4) | /* puc_payload[2]右移位4bit以获取start seq num值的最低4bit */
1834         (puc_payload[3] << 4); /* puc_payload[3]左移位4bit以获取start seq num值的bit 4 ~ 7 */
1835     return seq_num;
1836 }
1837 
1838 /* ****************************************************************************
1839  功能描述  : 4地址获取qos帧确认策略
1840 **************************************************************************** */
mac_get_ack_policy_4addr(const hi_u8 * puc_header)1841 static inline hi_u8 mac_get_ack_policy_4addr(const hi_u8 *puc_header)
1842 {
1843     return ((puc_header[MAC_QOS_CTRL_FIELD_OFFSET_4ADDR] & 0x60) >> 5); /* B5 - B6 */
1844 }
1845 
1846 /* ****************************************************************************
1847  功能描述  : 4地址获取qos帧确认策略
1848  修改历史      :
1849   1.日    期   : 2013年4月11日
1850     作    者   : HiSilicon
1851     修改内容   : 新生成函数
1852 **************************************************************************** */
mac_get_ack_policy(const hi_u8 * puc_header,hi_u8 is_4addr)1853 static inline hi_u8 mac_get_ack_policy(const hi_u8 *puc_header, hi_u8 is_4addr)
1854 {
1855     if (is_4addr) {
1856         return ((puc_header[MAC_QOS_CTRL_FIELD_OFFSET_4ADDR] & 0x60) >> 5); /* B5 - B6 */
1857     } else {
1858         return ((puc_header[MAC_QOS_CTRL_FIELD_OFFSET] & 0x60) >> 5); /* B5 - B6 */
1859     }
1860 }
1861 
1862 /* ****************************************************************************
1863  功能描述  : 获取收到的帧的目的地址
1864              参考协议 <802.11权威指南> 81页
1865  输入参数  : 指向接收到帧的帧头指针
1866  输出参数  : 指向目的地址的指针
1867 **************************************************************************** */
mac_rx_get_da(mac_ieee80211_frame_stru * mac_header,hi_u8 ** da_mac_addr)1868 static inline hi_void mac_rx_get_da(mac_ieee80211_frame_stru *mac_header, hi_u8 **da_mac_addr)
1869 {
1870     /* IBSS、from AP */
1871     if (mac_header->frame_control.to_ds == 0) {
1872         *da_mac_addr = mac_header->auc_address1;
1873     } else { /* WDS、to AP */
1874         *da_mac_addr = mac_header->auc_address3;
1875     }
1876 }
1877 
1878 /* ****************************************************************************
1879  功能描述  : 获取收到的帧的源地址
1880              参考协议 <802.11权威指南> 81页
1881  输入参数  : 指向接收到帧的帧头指针
1882  输出参数  : 指向源地址的指针
1883 **************************************************************************** */
mac_rx_get_sa(mac_ieee80211_frame_stru * mac_header,hi_u8 ** sa_mac_addr)1884 static inline hi_void mac_rx_get_sa(mac_ieee80211_frame_stru *mac_header, hi_u8 **sa_mac_addr)
1885 {
1886     if (mac_header->frame_control.from_ds == 0) {
1887         /* IBSS、to AP */
1888         *sa_mac_addr = mac_header->auc_address2;
1889     } else if ((mac_header->frame_control.from_ds == 1) && (mac_header->frame_control.to_ds == 0)) {
1890         /* from AP */
1891         *sa_mac_addr = mac_header->auc_address3;
1892     } else {
1893         /* WDS */
1894         *sa_mac_addr = ((mac_ieee80211_frame_addr4_stru *)mac_header)->auc_address4;
1895     }
1896 }
1897 
1898 /* ****************************************************************************
1899  功能描述  : 获取收到的帧的发送端地址
1900              参考协议 <802.11权威指南> 81页
1901  输入参数  : 指向接收到帧的帧头指针
1902  输出参数  : 指向 TA 的指针
1903 **************************************************************************** */
mac_get_transmit_addr(mac_ieee80211_frame_stru * mac_header,hi_u8 ** puc_bssid)1904 static inline hi_void mac_get_transmit_addr(mac_ieee80211_frame_stru *mac_header, hi_u8 **puc_bssid)
1905 {
1906     /* 对于IBSS, STA, AP, WDS 场景下,获取发送端地址 */
1907     *puc_bssid = mac_header->auc_address2;
1908 }
1909 
1910 /*****************************************************************************
1911  功能描述  : 判断该帧是否是组播帧
1912 **************************************************************************** */
mac_is_grp_addr(const hi_u8 * mac_addr)1913 static inline hi_u8 mac_is_grp_addr(const hi_u8 *mac_addr)
1914 {
1915     return (mac_addr[0] & BIT0);
1916 }
1917 
1918 /* ****************************************************************************
1919  功能描述  : 通过帧头判断是否是action帧
1920 **************************************************************************** */
mac_ieeee80211_is_action(const hi_u8 * puc_header)1921 static inline hi_u8 mac_ieeee80211_is_action(const hi_u8 *puc_header)
1922 {
1923     hi_u8 is_action = ((puc_header[0] & (MAC_IEEE80211_FCTL_FTYPE | MAC_IEEE80211_FCTL_STYPE)) ==
1924         (WLAN_ACTION << 4)); /* WLAN_ACTION 占据bit 4~7 */
1925     return is_action;
1926 }
1927 
1928 /* ****************************************************************************
1929  功能描述  : 获取报文的子类型
1930  修改历史      :
1931   1.日    期   : 2013年4月18日
1932     作    者   : HiSilicon
1933     修改内容   : 新生成函数
1934 **************************************************************************** */
mac_get_frame_sub_type(const hi_u8 * puc_mac_header)1935 static inline hi_u8 mac_get_frame_sub_type(const hi_u8 *puc_mac_header)
1936 {
1937     return (puc_mac_header[0] & 0xFC);
1938 }
1939 
1940 /* ****************************************************************************
1941  功能描述  : 获取802.11帧子类型的值(0~15)
1942              帧第一个字节的高四位
1943 **************************************************************************** */
mac_frame_get_subtype_value(const hi_u8 * puc_mac_header)1944 static inline hi_u8 mac_frame_get_subtype_value(const hi_u8 *puc_mac_header)
1945 {
1946     return ((puc_mac_header[0] & 0xF0) >> 4); /* 获取802.11帧子类型的值,右移4bit,即取值范围0~15 */
1947 }
1948 
1949 /* ****************************************************************************
1950  功能描述  : 获取报文类型
1951 **************************************************************************** */
mac_get_frame_type(const hi_u8 * puc_mac_header)1952 static inline hi_u8 mac_get_frame_type(const hi_u8 *puc_mac_header)
1953 {
1954     return (puc_mac_header[0] & 0x0C);
1955 }
1956 
1957 /* ****************************************************************************
1958  功能描述  : 获取80211帧帧类型,取值0~2
1959  修改历史      :
1960   1.日    期   : 2013年12月9日
1961     作    者   : HiSilicon
1962     修改内容   : 新生成函数
1963 **************************************************************************** */
mac_frame_get_type_value(const hi_u8 * puc_mac_header)1964 static inline hi_u8 mac_frame_get_type_value(const hi_u8 *puc_mac_header)
1965 {
1966     return (puc_mac_header[0] & 0x0C) >> 2; /* 获取80211帧帧类型,取值范围为0~2 */
1967 }
1968 
1969 
1970 /* ****************************************************************************
1971  功能描述  : 获取认证算法字段
1972 **************************************************************************** */
mac_get_auth_alg(const hi_u8 * puc_mac_hdr)1973 static inline hi_u16 mac_get_auth_alg(const hi_u8 *puc_mac_hdr)
1974 {
1975     hi_u16 auth_alg =
1976         (hi_u16)((puc_mac_hdr[MAC_80211_FRAME_LEN + 1] << 8) | /* puc_mac_hdr[24 + 1] 设置为auth_alg的bit 8 ~15 */
1977         puc_mac_hdr[MAC_80211_FRAME_LEN]);                     /* puc_mac_hdr[24] 设置为auth_alg的低8bit */
1978     return auth_alg;
1979 }
1980 
1981 /* ****************************************************************************
1982  功能描述  : 获取认证状态字段
1983 **************************************************************************** */
mac_get_auth_status(const hi_u8 * puc_mac_hdr)1984 static inline hi_u16 mac_get_auth_status(const hi_u8 *puc_mac_hdr)
1985 {
1986     hi_u16 auth_status =
1987         (hi_u16)((puc_mac_hdr[MAC_80211_FRAME_LEN + 5] << 8) | /* puc_mac_hdr[24 + 5] 设置为auth_status的bit 8 ~15 */
1988         puc_mac_hdr[MAC_80211_FRAME_LEN + 4]);                 /* puc_mac_hdr[24 + 4] 设置为auth_status的低8bit */
1989     return auth_status;
1990 }
1991 
1992 /* ****************************************************************************
1993  功能描述  : 获取认证帧序列号
1994 **************************************************************************** */
mac_get_auth_seq_num(const hi_u8 * puc_mac_hdr)1995 static inline hi_u16 mac_get_auth_seq_num(const hi_u8 *puc_mac_hdr)
1996 {
1997     hi_u16 auth_seq_num =
1998         (hi_u16)((puc_mac_hdr[MAC_80211_FRAME_LEN + 3] << 8) | /* puc_mac_hdr[24 + 3] 设置为auth_seq_num的bit 8 ~15 */
1999         puc_mac_hdr[MAC_80211_FRAME_LEN + 2]);                 /* puc_mac_hdr[24 + 2] 设置为auth_seq_num的低8bit */
2000     return auth_seq_num;
2001 }
2002 
2003 /* ****************************************************************************
2004  功能描述  : 设置protected frame subfield
2005 **************************************************************************** */
mac_set_wep(hi_u8 * puc_hdr,hi_u8 wep)2006 static inline hi_void mac_set_wep(hi_u8 *puc_hdr, hi_u8 wep)
2007 {
2008     puc_hdr[1] &= 0xBF;
2009     puc_hdr[1] |= (hi_u8)(wep << 6); /* wep设置为protected frame subfield的bit 6开始的位置 */
2010 }
2011 
2012 /* ****************************************************************************
2013  功能描述  : 设置帧控制字段的受保护字段
2014 **************************************************************************** */
mac_set_protectedframe(hi_u8 * puc_mac_hdr)2015 static inline hi_void mac_set_protectedframe(hi_u8 *puc_mac_hdr)
2016 {
2017     puc_mac_hdr[1] |= 0x40;
2018 }
2019 
2020 /* ****************************************************************************
2021  功能描述  : 获取帧头中保护位信息
2022 **************************************************************************** */
mac_get_protectedframe(hi_u8 * puc_mac_hdr)2023 static inline hi_u8 mac_get_protectedframe(hi_u8 *puc_mac_hdr)
2024 {
2025     mac_ieee80211_frame_stru *mac_hdr = (mac_ieee80211_frame_stru *)puc_mac_hdr;
2026     return (hi_u8)(mac_hdr->frame_control.protected_frame);
2027 }
2028 
2029 /* ****************************************************************************
2030  功能描述  : 获取帧控制字段的受保护字段
2031 **************************************************************************** */
mac_is_protectedframe(const hi_u8 * puc_mac_hdr)2032 static inline hi_u8 mac_is_protectedframe(const hi_u8 *puc_mac_hdr)
2033 {
2034     return ((puc_mac_hdr[1] & 0x40) >> 6); /* 右移6 bit 获取帧控制字段的受保护字段 */
2035 }
2036 
2037 /* ****************************************************************************
2038  功能描述  : 获取认证帧中的challenge txt
2039 **************************************************************************** */
mac_get_auth_ch_text(hi_u8 * puc_mac_hdr)2040 static inline hi_u8 *mac_get_auth_ch_text(hi_u8 *puc_mac_hdr)
2041 {
2042     return &(puc_mac_hdr[MAC_80211_FRAME_LEN + 6]); /* 偏移(MAC_80211_FRAME_LEN + 6)byte,获取认证帧中的challenge txt */
2043 }
2044 
2045 /* ****************************************************************************
2046  功能描述  : 是否为4地址 控制位为from ds | to ds均为1
2047 **************************************************************************** */
mac_is_4addr(const hi_u8 * puc_mac_hdr)2048 static inline hi_u8 mac_is_4addr(const hi_u8 *puc_mac_hdr)
2049 {
2050     return (hi_u8)(mac_hdr_get_to_ds(puc_mac_hdr) && mac_hdr_get_from_ds(puc_mac_hdr));
2051 }
2052 
2053 /* ****************************************************************************
2054  功能描述  : 拷贝MAC头的地址1
2055 **************************************************************************** */
mac_get_address1(const hi_u8 * puc_mac_hdr,hi_u8 mac_hdr_len,hi_u8 * mac_addr,hi_u8 addr_len)2056 static inline hi_void mac_get_address1(const hi_u8 *puc_mac_hdr, hi_u8 mac_hdr_len, hi_u8 *mac_addr, hi_u8 addr_len)
2057 {
2058     if (memcpy_s(mac_addr, addr_len, puc_mac_hdr + WLAN_HDR_ADDR1_OFFSET, mac_hdr_len) != EOK) {
2059         oam_error_log0(0, 0, "{mac_get_address1::memcpy_s fail.}");
2060         return;
2061     }
2062 }
2063 
2064 /* ****************************************************************************
2065  功能描述  : 拷贝MAC头的地址2
2066 **************************************************************************** */
mac_get_address2(const hi_u8 * puc_mac_hdr,hi_u8 mac_hdr_len,hi_u8 * mac_addr,hi_u8 addr_len)2067 static inline hi_void mac_get_address2(const hi_u8 *puc_mac_hdr, hi_u8 mac_hdr_len, hi_u8 *mac_addr, hi_u8 addr_len)
2068 {
2069     if (memcpy_s(mac_addr, addr_len, puc_mac_hdr + WLAN_HDR_ADDR2_OFFSET, mac_hdr_len) != EOK) {
2070         oam_error_log0(0, 0, "{mac_get_address2::memcpy_s fail.}");
2071         return;
2072     }
2073 }
2074 
2075 /* ****************************************************************************
2076  功能描述  : 拷贝MAC头的地址3
2077 **************************************************************************** */
mac_get_address3(const hi_u8 * puc_mac_hdr,hi_u8 mac_hdr_len,hi_u8 * mac_addr,hi_u8 addr_len)2078 static inline hi_void mac_get_address3(const hi_u8 *puc_mac_hdr, hi_u8 mac_hdr_len, hi_u8 *mac_addr, hi_u8 addr_len)
2079 {
2080     if (memcpy_s(mac_addr, addr_len, puc_mac_hdr + WLAN_HDR_ADDR3_OFFSET, mac_hdr_len) != EOK) {
2081         oam_error_log0(0, 0, "{mac_get_address3::memcpy_s fail.}");
2082         return;
2083     }
2084 }
2085 
2086 /* ****************************************************************************
2087  功能描述  : 获取关联帧中的状态信息
2088  输入参数  : puc_mac_header:关联帧
2089 **************************************************************************** */
mac_get_asoc_status(const hi_u8 * puc_mac_payload)2090 static inline mac_status_code_enum_uint16 mac_get_asoc_status(const hi_u8 *puc_mac_payload)
2091 {
2092     mac_status_code_enum_uint16 mac_status;
2093 
2094     mac_status = (mac_status_code_enum_uint16)((puc_mac_payload[3] << 8) | /* payload[3]设置为mac_status bit 8 ~15 */
2095         puc_mac_payload[2]);                                               /* payload[2]设置为mac_status低8bit */
2096     return mac_status;
2097 }
2098 
2099 /* ****************************************************************************
2100  功能描述  : 获取关联帧中的关联ID
2101 **************************************************************************** */
mac_get_asoc_id(const hi_u8 * puc_mac_payload)2102 static inline hi_u16 mac_get_asoc_id(const hi_u8 *puc_mac_payload)
2103 {
2104     hi_u16 us_asoc_id;
2105 
2106     us_asoc_id = puc_mac_payload[4] | /* payload[4]设置为asoc_id低8bit */
2107         (puc_mac_payload[5] << 8);    /* payload[5]设置为asoc_id低bit 8 ~ 15 */
2108     us_asoc_id &= 0x3FFF;             /* 取低14位 */
2109     return us_asoc_id;
2110 }
2111 
2112 /* ****************************************************************************
2113  功能描述  : 根据"from ds"bit,从帧中提取bssid(mac地址)
2114  输入参数  : puc_mac_header:mac帧头,puc_bssid:mac帧bssid
2115  输出参数  : puc_bssid:mac帧bssid,
2116 **************************************************************************** */
mac_get_bssid(const hi_u8 * puc_mac_hdr,hi_u8 * puc_bssid,hi_u8 ssid_len)2117 static inline hi_void mac_get_bssid(const hi_u8 *puc_mac_hdr, hi_u8 *puc_bssid, hi_u8 ssid_len)
2118 {
2119     if (mac_hdr_get_from_ds(puc_mac_hdr)) {
2120         mac_get_address2(puc_mac_hdr, WLAN_MAC_ADDR_LEN, puc_bssid, ssid_len);
2121     } else if (mac_hdr_get_to_ds(puc_mac_hdr)) {
2122         mac_get_address1(puc_mac_hdr, WLAN_MAC_ADDR_LEN, puc_bssid, ssid_len);
2123     } else {
2124         mac_get_address3(puc_mac_hdr, WLAN_MAC_ADDR_LEN, puc_bssid, ssid_len);
2125     }
2126 }
2127 
2128 /* ****************************************************************************
2129  功能描述  : 判断LLC 帧类型是否为EAPOL 类型帧
2130  输入参数  : mac_llc_snap_stru *pst_mac_llc_snap
2131  返 回 值  : HI_TRUE     是EAPOL 类型数据
2132              HI_FALSE  不是EAPOL 类型数据
2133 **************************************************************************** */
mac_frame_is_eapol(const mac_llc_snap_stru * mac_llc_snap)2134 static inline hi_bool mac_frame_is_eapol(const mac_llc_snap_stru *mac_llc_snap)
2135 {
2136     return (hi_swap_byteorder_16(mac_llc_snap->us_ether_type) == ETHER_ONE_X_TYPE);
2137 }
2138 
2139 /* ****************************************************************************
2140  功能描述  : 获取action帧的Category
2141  输入参数  : [1]puc_data
2142  返 回 值  : hi_u16
2143  返 回 值  : hi_u8
2144 **************************************************************************** */
mac_get_action_category(const hi_u8 * puc_data)2145 static inline hi_u8 mac_get_action_category(const hi_u8 *puc_data)
2146 {
2147     hi_u8 us_action_cate;
2148     us_action_cate = puc_data[0];
2149     return us_action_cate;
2150 }
2151 
2152 /* ****************************************************************************
2153  功能描述  :获取action帧的action code字段
2154  输入参数  :[1]puc_data
2155  返 回 值  :hi_u16
2156 **************************************************************************** */
mac_get_action_code(const hi_u8 * puc_data)2157 static inline hi_u8 mac_get_action_code(const hi_u8 *puc_data)
2158 {
2159     hi_u8 us_action_code;
2160     us_action_code = puc_data[1];
2161     return us_action_code;
2162 }
2163 
2164 /* ****************************************************************************
2165  功能描述  : 填充tansmit beamforming capbilities域信息
2166  输入参数  : pst_vap :指向vap
2167              puc_buffer :指向buffer
2168  修改历史      :
2169   1.日    期   : 2013年4月17日
2170     作    者   : HiSilicon
2171     修改内容   : 新生成函数
2172 **************************************************************************** */
mac_set_txbf_cap_field(hi_u8 * puc_buffer)2173 static inline hi_void mac_set_txbf_cap_field(hi_u8 *puc_buffer)
2174 {
2175     /* ************** Transmit Beamforming Capability Field *********************
2176      |-------------------------------------------------------------------------|
2177      |   Implicit | Rx Stagg | Tx Stagg  | Rx NDP   | Tx NDP   | Implicit      |
2178      |   TxBF Rx  | Sounding | Sounding  | Capable  | Capable  | TxBF          |
2179      |   Capable  | Capable  | Capable   |          |          | Capable       |
2180      |-------------------------------------------------------------------------|
2181      |      B0    |     B1   |    B2     |   B3     |   B4     |    B5         |
2182      |-------------------------------------------------------------------------|
2183      |              | Explicit | Explicit Non- | Explicit      | Explicit      |
2184      |  Calibration | CSI TxBF | Compr Steering| Compr steering| TxBF CSI      |
2185      |              | Capable  | Cap.          | Cap.          | Feedback      |
2186      |-------------------------------------------------------------------------|
2187      |  B6       B7 |   B8     |       B9      |       B10     | B11  B12      |
2188      |-------------------------------------------------------------------------|
2189      | Explicit Non- | Explicit | Minimal  | CSI Num of | Non-Compr Steering   |
2190      | Compr BF      | Compr BF | Grouping | Beamformer | Num of Beamformer    |
2191      | Fdbk Cap.     | Fdbk Cap.|          | Ants Supp  | Ants Supp            |
2192      |-------------------------------------------------------------------------|
2193      | B13       B14 | B15  B16 | B17  B18 | B19    B20 | B21        B22       |
2194      |-------------------------------------------------------------------------|
2195      | Compr Steering    | CSI Max Num of     |   Channel     |                |
2196      | Num of Beamformer | Rows Beamformer    | Estimation    | Reserved       |
2197      | Ants Supp         | Supported          | Capability    |                |
2198      |-------------------------------------------------------------------------|
2199      | B23           B24 | B25            B26 | B27       B28 | B29  B31       |
2200      |-------------------------------------------------------------------------|
2201     ************************************************************************** */
2202     /* 31h不支持TXBF 能力位清零 */
2203     puc_buffer[0] = 0;
2204     puc_buffer[1] = 0;
2205     puc_buffer[2] = 0; /* puc_buffer[2]清0 */
2206     puc_buffer[3] = 0; /* puc_buffer[3]清0 */
2207 }
2208 
2209 /* ****************************************************************************
2210  功能描述  : 填充asel(antenna selection) capabilities域信息
2211  输入参数  : pst_vap: 指向vap
2212              puc_buffer: 指向buffer
2213  修改历史      :
2214   1.日    期   : 2013年4月17日
2215     作    者   : HiSilicon
2216     修改内容   : 新生成函数
2217 **************************************************************************** */
mac_set_asel_cap_field(hi_u8 * puc_buffer)2218 static inline hi_void mac_set_asel_cap_field(hi_u8 *puc_buffer)
2219 {
2220     /* ************* Antenna Selection Capability Field *************************
2221      |-------------------------------------------------------------------|
2222      |  Antenna  | Explicit CSI  | Antenna Indices | Explicit | Antenna  |
2223      | Selection | Fdbk based TX | Fdbk based TX   | CSI Fdbk | Indices  |
2224      |  Capable  | ASEL Capable  | ASEL Capable    | Capable  | Fdbk Cap.|
2225      |-------------------------------------------------------------------|
2226      |    B0     |     B1        |      B2         |    B3    |    B4    |
2227      |-------------------------------------------------------------------|
2228 
2229      |------------------------------------|
2230      |  RX ASEL |   Transmit   |          |
2231      |  Capable |   Sounding   | Reserved |
2232      |          | PPDU Capable |          |
2233      |------------------------------------|
2234      |    B5    |     B6       |    B7    |
2235      |------------------------------------|
2236     ************************************************************************** */
2237     /* 31h 清0 均不支持 */
2238     puc_buffer[0] = 0;
2239 }
2240 
2241 /* ****************************************************************************
2242  功能描述  : 判断是否是wmm ie
2243  修改历史      :
2244   1.日    期   : 2013年6月25日
2245     作    者   : HiSilicon
2246     修改内容   : 新生成函数
2247 **************************************************************************** */
mac_is_wmm_ie(const hi_u8 * puc_ie)2248 static inline hi_u8 mac_is_wmm_ie(const hi_u8 *puc_ie)
2249 {
2250     /* --------------------------------------------------------------------- */
2251     /* WMM Information/Parameter Element Format                              */
2252     /* --------------------------------------------------------------------- */
2253     /* | OUI | OUIType | OUISubtype | Version | QoSInfo | OUISubtype based | */
2254     /* --------------------------------------------------------------------- */
2255     /* |3    | 1       | 1          | 1       | 1       | ---------------- | */
2256     /* --------------------------------------------------------------------- */
2257     if ((puc_ie[0] == MAC_EID_WMM) && (puc_ie[2] == MAC_WMM_OUI_BYTE_ONE) &&            /* check puc_ie[0]、[2] */
2258         (puc_ie[3] == MAC_WMM_OUI_BYTE_TWO) && (puc_ie[4] == MAC_WMM_OUI_BYTE_THREE) && /* check puc_ie[3]、[4] */
2259         (puc_ie[5] == MAC_OUITYPE_WMM) && /* puc_ie[5] check是否为WMM Type */
2260         ((puc_ie[6] == MAC_OUISUBTYPE_WMM_INFO) || (puc_ie[6] == MAC_OUISUBTYPE_WMM_PARAM)) && /* check puc_ie[6] */
2261         (puc_ie[7] == MAC_OUI_WMM_VERSION)) { /* puc_ie[7] check是否为Version field 0x1 */
2262         return HI_TRUE;
2263     }
2264 
2265     return HI_FALSE;
2266 }
2267 
2268 /* ****************************************************************************
2269  功能描述  : 设置Channel Switch Announcement IE
2270  输入参数  : pst_mac_vap: MAC VAP结构体指针
2271  输出参数  : puc_buffer : 帧体指针
2272              puc_ie_len : IE的长度
2273  返 回 值  : HI_SUCCESS或其它错误码
2274  修改历史      :
2275   1.日    期   : 2014年3月21日
2276     作    者   : HiSilicon
2277     修改内容   : 新生成函数
2278 **************************************************************************** */
mac_set_csa_ie(hi_u8 channel,hi_u8 csa_cnt,hi_u8 * puc_buffer,hi_u8 * puc_ie_len)2279 static inline hi_void mac_set_csa_ie(hi_u8 channel, hi_u8 csa_cnt, hi_u8 *puc_buffer, hi_u8 *puc_ie_len)
2280 {
2281     /*  Channel Switch Announcement Information Element Format               */
2282     /* --------------------------------------------------------------------- */
2283     /* | Element ID | Length | Chnl Switch Mode | New Chnl | Ch Switch Cnt | */
2284     /* --------------------------------------------------------------------- */
2285     /* | 1          | 1      | 1                | 1        | 1             | */
2286     /* --------------------------------------------------------------------- */
2287     /* 设置Channel Switch Announcement Element */
2288     puc_buffer[0] = MAC_EID_CHANSWITCHANN;
2289     puc_buffer[1] = MAC_CHANSWITCHANN_LEN;
2290     puc_buffer[2] = 1;       /* ask all associated STAs to stop transmission:byte 2 */
2291     puc_buffer[3] = channel; /* byte 3 设置为信道号 */
2292     puc_buffer[4] = csa_cnt; /* byte 4 设置为信道切换计数值 */
2293     *puc_ie_len = MAC_IE_HDR_LEN + MAC_CHANSWITCHANN_LEN;
2294 }
2295 
2296 #ifdef _PRE_WLAN_FEATURE_BW_HIEX
2297 /* ****************************************************************************
2298  功能描述  : 获取私有NOA帧的离开时间(ms)
2299  修改历史      :
2300   1.日    期   : 2019年4月10日
2301     作    者   : HiSilicon
2302     修改内容   : 新生成函数
2303 **************************************************************************** */
mac_get_noa_duration(const hi_u8 * puc_ies,hi_u16 us_len,hi_u16 * pus_duration)2304 static inline hi_u8 mac_get_noa_duration(const hi_u8 *puc_ies, hi_u16 us_len, hi_u16 *pus_duration)
2305 {
2306     if (us_len < MAC_ACTION_VENDOR_SPECIFIC_IE_POS + 2) { /* duration字段由2个字节组成,单位为us */
2307         oam_warning_log1(0, OAM_SF_DBAC, "{mac_get_noa_duration: msg len %d.}", us_len);
2308         return HI_FALSE;
2309     }
2310     *pus_duration = puc_ies[MAC_ACTION_VENDOR_SPECIFIC_IE_POS] << 8; /* puc_ies[6]存于duration bit 8 ~ 15 */
2311     *pus_duration |= (hi_u16)puc_ies[MAC_ACTION_VENDOR_SPECIFIC_IE_POS + 1];
2312 
2313     return HI_TRUE;
2314 }
2315 #endif
2316 
2317 /* ****************************************************************************
2318  * 功能描述  : 设置帧头mac地址
2319  * 输入参数  : addr1,addr2,addr3: mac addrsss
2320  * *************************************************************************** */
mac_hdr_set_mac_addrsss(hi_u8 * mac_header,const hi_u8 * addr1,const hi_u8 * addr2,const hi_u8 * addr3)2321 static inline hi_u16 mac_hdr_set_mac_addrsss(hi_u8 *mac_header, const hi_u8 *addr1, const hi_u8 *addr2,
2322     const hi_u8 *addr3)
2323 {
2324     if (memcpy_s(mac_header + WLAN_HDR_ADDR1_OFFSET, WLAN_MAC_ADDR_LEN, addr1, WLAN_MAC_ADDR_LEN) != EOK ||
2325         memcpy_s(mac_header + WLAN_HDR_ADDR2_OFFSET, WLAN_MAC_ADDR_LEN, addr2, WLAN_MAC_ADDR_LEN) != EOK ||
2326         memcpy_s(mac_header + WLAN_HDR_ADDR3_OFFSET, WLAN_MAC_ADDR_LEN, addr3, WLAN_MAC_ADDR_LEN) != EOK) {
2327         oam_warning_log0(0, OAM_SF_TX_CHAIN, "{mac_set_mgmt_frame_header_mac_addrsss: memcpy_s failed.}");
2328         return 0;
2329     }
2330     return (hi_u16)(WLAN_HDR_ADDR3_OFFSET + WLAN_MAC_ADDR_LEN);
2331 }
2332 
2333 #ifdef __cplusplus
2334 #if __cplusplus
2335 }
2336 #endif
2337 #endif
2338 #endif /* __MAC_FRAME_H__ */
2339