WS63 SDK 文档 7021f4f@fbb_ws63
ws63 和 ws63e 解决方案的 SDK 文档
载入中...
搜索中...
未找到
mac_frame_rom.h
浏览该文件的文档.
1/*
2 * Copyright (c) HiSilicon (Shanghai) Technologies Co., Ltd. 2020-2022. All rights reserved.
3 * Description: Source file defined by the corresponding frame structure and operation interface (cannot be called by
4 * the HAL module).
5 */
7#ifndef MAC_FRAME_ROM_H
8#define MAC_FRAME_ROM_H
9
10/*****************************************************************************
11 1 其他头文件包含
12*****************************************************************************/
13#include "wlan_types_rom.h"
14#include "oam_ext_if.h"
16
17#ifdef __cplusplus
18#if __cplusplus
19extern "C" {
20#endif
21#endif
22
23/* TCP协议类型,chartiot tcp连接端口号 */
24#define MAC_TCP_PROTOCAL 6
25#define MAC_UDP_PROTOCAL 17
26#define MAC_ICMP_PROTOCAL 1
27
28#define MAC_ARP_REQUEST 0x0001
29#define MAC_ARP_RESPONSE 0x0002
30
31#define MAC_ICMP_REQUEST 0x08
32#define MAC_ICMP_RESPONSE 0x00
33#define MAC_SUBMSDU_LENGTH_OFFSET 12 /* submsdu的长度字段的偏移值 */
34#define MAC_SUBMSDU_DA_OFFSET 0 /* submsdu的目的地址的偏移值 */
35#define MAC_SUBMSDU_SA_OFFSET 6 /* submsdu的源地址的偏移值 */
36#define MAC_BYTE_ALIGN_VALUE 4 /* 4字节对齐 */
37
38#define OAL_DECLARE_PACKED __attribute__((__packed__))
39/* 四地址帧结构体 */
58/*****************************************************************************
59 函 数 名 : wlan_get_bssid
60 功能描述 : 根据"from ds"bit,从帧中提取bssid(mac地址)
61
62*****************************************************************************/
63static INLINE__ osal_void dmac_get_bssid(osal_u8 *mac_hdr, osal_u8 *bssid, osal_u16 bssid_len)
64{
65 unref_param(bssid_len);
66 if (mac_hdr_get_from_ds(mac_hdr) == 1) {
67 (osal_void)memcpy_s(bssid, WLAN_MAC_ADDR_LEN, mac_hdr + 10, WLAN_MAC_ADDR_LEN); // from_ds的bssid在mac头偏移10比特
68 } else if (mac_hdr_get_to_ds(mac_hdr) == 1) {
69 (osal_void)memcpy_s(bssid, WLAN_MAC_ADDR_LEN, mac_hdr + 4, WLAN_MAC_ADDR_LEN); // to_ds的bssid在mac头偏移4比特
70 } else {
71 (osal_void)memcpy_s(bssid, WLAN_MAC_ADDR_LEN, mac_hdr + 16, WLAN_MAC_ADDR_LEN); // IBSS的bssid在mac头偏移16比特
72 }
73}
74
75/*****************************************************************************
76 函 数 名 : oal_dmac_host2net_short
77 功能描述 : 16 bit本机字节序到网络字节序转换
78*****************************************************************************/
79static INLINE__ osal_u16 oal_dmac_host2net_short(osal_u16 val)
80{
81 return (((val & 0x00FF) << 8) + ((val & 0xFF00) >> 8)); // 移位8字节
82}
83
84/*****************************************************************************
85 函 数 名 : oal_dmac_net2host_short
86 功能描述 : 16 bit网络字节序到本机字节序转换
87*****************************************************************************/
88static INLINE__ osal_u16 oal_dmac_net2host_short(osal_u16 val)
89{
90 return (((val & 0x00FF) << 8) + ((val & 0xFF00) >> 8)); // 移位8字节
91}
92
93/*****************************************************************************
94 函 数 名 : oal_dmac_host2net_long
95 功能描述 : 32 bit本机字节序到网络字节序转换
96*****************************************************************************/
97static INLINE__ osal_u32 oal_dmac_host2net_long(osal_u32 val)
98{
99 return (((osal_u32)(val & 0x000000FF) << 24) + ((val & 0x0000FF00) << 8) + // 移位8、24字节
100 ((val & 0x00FF0000) >> 8) + ((osal_u32)(val & 0xFF000000) >> 24)); // 移位8、24字节
101}
102
103/*****************************************************************************
104 函 数 名 : mac_get_submsdu_len
105 功能描述 : 获取netbuf中submsdu的长度
106*****************************************************************************/
107static INLINE__ osal_void dmac_get_submsdu_len(const osal_u8 *submsdu_hdr, osal_u16 *submsdu_len)
108{
109 *submsdu_len = *(submsdu_hdr + MAC_SUBMSDU_LENGTH_OFFSET);
110 // 长度2字节,先取高8位,再取低8位
111 *submsdu_len = (osal_u16)((*submsdu_len << 8) + *(submsdu_hdr + MAC_SUBMSDU_LENGTH_OFFSET + 1));
112}
113
114/*****************************************************************************
115 函 数 名 : mac_get_submsdu_pad_len
116 功能描述 : 获取submsdu需要填充的字节数
117*****************************************************************************/
118static INLINE__ osal_void dmac_get_submsdu_pad_len(osal_u16 msdu_len, osal_u8 *submsdu_pad_len)
119{
120 *submsdu_pad_len = msdu_len & 0x3;
121
122 if ((*submsdu_pad_len) != 0) {
123 *submsdu_pad_len = (MAC_BYTE_ALIGN_VALUE - *submsdu_pad_len);
124 }
125}
126
127/*****************************************************************************
128 函 数 名 : mac_rx_get_sa
129 功能描述 : 获取收到的帧的源地址
130*****************************************************************************/
131static INLINE__ osal_void dmac_rx_get_sa(mac_ieee80211_frame_stru *mac_header, osal_u8 **sa)
132{
133 if (mac_header->frame_control.from_ds == 0) {
134 /* IBSS、to AP */
135 *sa = mac_header->address2;
136 } else if ((mac_header->frame_control.from_ds == 1) && (mac_header->frame_control.to_ds == 0)) {
137 /* from AP */
138 *sa = mac_header->address3;
139 } else {
140 /* WDS */
141 *sa = ((dmac_ieee80211_frame_addr4_stru *)mac_header)->address4;
142 }
143}
144
145/*****************************************************************************
146 函 数 名 : mac_get_transmitter_addr
147 功能描述 : 获取收到的帧的目的地址
148*****************************************************************************/
149static INLINE__ osal_void dmac_rx_get_da(mac_ieee80211_frame_stru *mac_header, osal_u8 **da)
150{
151 if (mac_header->frame_control.to_ds == 0) {
152 /* IBSS、from AP */
153 *da = mac_header->address1;
154 } else {
155 /* WDS、to AP */
156 *da = mac_header->address3;
157 }
158}
159
160#ifdef __cplusplus
161#if __cplusplus
162}
163#endif
164#endif
165
166#endif /* end of mac_frame_rom.h */
#define unref_param(P)
Definition dmac_misc_type.h:33
#define WLAN_MAC_ADDR_LEN
Definition mac_addr.c:28
#define MAC_BYTE_ALIGN_VALUE
Definition mac_frame_rom.h:36
osal_bool dmac_is_eapol_key_ptk_etc(const mac_eapol_header_stru *eapol_header)
osal_u8 * dmac_find_ie_etc(osal_u8 eid, osal_u8 *ies, osal_s32 len)
osal_bool dmac_is_eapol_key_ptk_4_4_etc(const oal_dmac_netbuf_stru *netbuff)
#define OAL_DECLARE_PACKED
Definition mac_frame_rom.h:38
oal_bool_enum_uint8 dmac_frame_is_null_data(const oal_dmac_netbuf_stru *net_buf)
#define MAC_SUBMSDU_LENGTH_OFFSET
Definition mac_frame_rom.h:33
osal_u8 dmac_get_data_type_etc(const oal_dmac_netbuf_stru *netbuff)
mac_data_type_enum_uint8 dmac_get_arp_type_by_arphdr(const oal_eth_arphdr_stru *rx_arp_hdr)
osal_u8 oal_bool_enum_uint8
Definition oal_types_device_rom.h:45
#define INLINE__
Definition osal_list.h:25
int osal_s32
Definition osal_types.h:19
unsigned char osal_u8
Definition osal_types.h:11
osal_u8 osal_bool
Definition osal_types.h:27
void osal_void
Definition osal_types.h:29
unsigned int osal_u32
Definition osal_types.h:13
unsigned short osal_u16
Definition osal_types.h:12
errno_t memcpy_s(void *dest, size_t destMax, const void *src, size_t count)
Definition mac_frame_rom.h:40
osal_u16 frag_num
Definition mac_frame_rom.h:47
osal_u16 seq_num
Definition mac_frame_rom.h:48
mac_header_frame_control_stru frame_control
Definition mac_frame_rom.h:41
osal_u8 address1[WLAN_MAC_ADDR_LEN]
Definition mac_frame_rom.h:44
osal_u8 address3[WLAN_MAC_ADDR_LEN]
Definition mac_frame_rom.h:46
osal_u8 address4[WLAN_MAC_ADDR_LEN]
Definition mac_frame_rom.h:49
osal_u16 duration_value
Definition mac_frame_rom.h:42
osal_u8 address2[WLAN_MAC_ADDR_LEN]
Definition mac_frame_rom.h:45
osal_u16 duration_flag
Definition mac_frame_rom.h:43
Definition mac_frame_common_rom.h:473
Definition mac_frame_common_rom.h:559
osal_u16 to_ds
Definition mac_frame_common_rom.h:563
osal_u16 from_ds
Definition mac_frame_common_rom.h:564
Definition mac_frame_common_rom.h:575
osal_u8 address1[6]
Definition mac_frame_common_rom.h:579
osal_u8 address2[6]
Definition mac_frame_common_rom.h:580
mac_header_frame_control_stru frame_control
Definition mac_frame_common_rom.h:576
osal_u8 address3[6]
Definition mac_frame_common_rom.h:581
Definition oal_net_pkt_rom.h:83
Definition eth_ip_common_rom.h:59
mac_data_type_enum_uint8
Definition wlan_types.h:420