• 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_DATA_H__
20 #define __MAC_DATA_H__
21 
22 #include "oal_ext_if.h"
23 #include "oam_ext_if.h"
24 #include "mac_user.h"
25 #include "mac_regdomain.h"
26 #include "wlan_mib.h"
27 
28 #ifdef __cplusplus
29 #if __cplusplus
30 extern "C" {
31 #endif
32 #endif
33 
34 /* ****************************************************************************
35   枚举定义
36 **************************************************************************** */
37 typedef enum {
38     MAC_DATA_DHCP_DISCOVER = 0,
39     MAC_DATA_DHCP_OFFER,
40     MAC_DATA_DHCP_REQ,
41     MAC_DATA_DHCP_ACK,
42     MAC_DATA_ARP_REQ,
43     MAC_DATA_ARP_RSP,
44     MAC_DATA_EAPOL,
45     MAC_DATA_DHCPV6,
46     MAC_DATA_VIP = MAC_DATA_DHCPV6, /* MAC_DATA_VIP == MAC_DATA_DHCPV6, 提高关键帧判断效率,减少mips */
47     MAC_DATA_ND,
48     MAC_DATA_TDLS,
49     MAC_DATA_PPPOE,
50     MAC_DATA_WAPI,
51     MAC_DATA_VLAN,
52 #ifdef _PRE_WLAN_FEATURE_MESH_ROM
53     MAC_DATA_RPL,
54     MAC_DATA_6LO,
55 #endif
56     MAC_DATA_BUTT
57 } mac_data_type_enum;
58 typedef hi_u8 mac_data_type_enum_uint8;
59 
60 typedef enum {
61     MAC_NETBUFF_PAYLOAD_ETH = 0,
62     MAC_NETBUFF_PAYLOAD_SNAP,
63 
64     MAC_NETBUFF_PAYLOAD_BUTT
65 } mac_netbuff_payload_type;
66 typedef hi_u8 mac_netbuff_payload_type_uint8;
67 
68 /* ****************************************************************************
69   inline函数定义
70 **************************************************************************** */
71 /* ****************************************************************************
72  功能描述  : 获取arp帧的类型:request/response(暂时不考虑rarp!)
73  输入参数  : arp ie头
74  返 回 值  : 驱动私定义的关键帧类型
75  修改历史      :
76   1.日    期   : 2016年1月25日
77 **************************************************************************** */
mac_get_arp_type_by_arphdr(const oal_eth_arphdr_stru * rx_arp_hdr)78 static inline mac_data_type_enum_uint8 mac_get_arp_type_by_arphdr(const oal_eth_arphdr_stru *rx_arp_hdr)
79 {
80     if (oal_net2host_short(rx_arp_hdr->us_ar_op) == MAC_ARP_REQUEST) {
81         return MAC_DATA_ARP_REQ;
82     } else if (oal_net2host_short(rx_arp_hdr->us_ar_op) == MAC_ARP_RESPONSE) {
83         return MAC_DATA_ARP_RSP;
84     }
85     return MAC_DATA_BUTT;
86 }
87 
88 #ifdef _PRE_WLAN_FEATURE_MESH_ROM
89 /* ****************************************************************************
90  功能描述  : 判断是否是RPL控制帧
91  修改历史      :
92   1.日    期   : 2019年5月17日
93     作    者   : HiSilicon
94     修改内容   : 新生成函数
95 **************************************************************************** */
mac_is_rpl(oal_ipv6hdr_stru * ipv6hdr)96 static inline hi_u8 mac_is_rpl(oal_ipv6hdr_stru *ipv6hdr)
97 {
98     if (ipv6hdr->nexthdr == OAL_IPPROTO_ICMPV6) {
99         oal_icmp6hdr_stru *icmp6hdr = HI_NULL;
100         icmp6hdr = (oal_icmp6hdr_stru *)(ipv6hdr + 1);
101         if (icmp6hdr->icmp6_type == MAC_RPL_TYPE) {
102             return HI_TRUE;
103         }
104     }
105     return HI_FALSE;
106 }
107 #endif
108 
109 /* ****************************************************************************
110   函数声明
111 **************************************************************************** */
112 hi_u8 mac_get_data_type(const oal_dev_netbuf_stru *dev_netbuf);
113 hi_u8 mac_get_data_type_from_80211(const oal_netbuf_stru *netbuf, hi_u16 us_mac_hdr_len);
114 hi_u8 mac_get_data_type_from_8023(const hi_u8 *puc_frame_hdr, mac_netbuff_payload_type hdr_type);
115 hi_u8 mac_is_dhcp_port(mac_ip_header_stru *ip_hdr);
116 hi_u8 mac_is_nd(oal_ipv6hdr_stru *ipv6hdr);
117 hi_u8 mac_is_eapol_key_ptk(mac_eapol_header_stru *eapol_header);
118 hi_u8 *mac_dhcp_get_type(hi_u8 *pos, const hi_u8 *packet_end, hi_u8 type);
119 hi_u8 mac_is_dhcp6(oal_ipv6hdr_stru *ipv6hdr);
120 
121 #ifdef __cplusplus
122 #if __cplusplus
123 }
124 #endif
125 #endif
126 #endif /* __MAC_DATA_H__ */
127