WS63 SDK 文档 7021f4f@fbb_ws63
ws63 和 ws63e 解决方案的 SDK 文档
载入中...
搜索中...
未找到
hmac_sniffer.h
浏览该文件的文档.
1/*
2 * Copyright (c) HiSilicon (Shanghai) Technologies Co., Ltd. 2021-2021. All rights reserved.
3 * Description: hook function for wifi sniffer.
4 */
5
6#ifndef __HMAC_SNIFFER_H
7#define __HMAC_SNIFFER_H
8
9#if defined(_PRE_OS_VERSION_LINUX) && defined(_PRE_OS_VERSION) \
10 && (_PRE_OS_VERSION_LINUX == _PRE_OS_VERSION)
11#include "oal_schedule.h"
12#include "mac_frame.h"
13
14#ifdef __cplusplus
15#if __cplusplus
16extern "C" {
17#endif
18#endif
19
20/*****************************************************************************
21 1 其他头文件包含
22*****************************************************************************/
23#if defined(_PRE_WLAN_FEATURE_SNIFFER)
24
25#define PCAP_FILE_NUM 5
26#define PCAP_FILE_NUM_MAX 5
27#define PCAP_FILE_NUM_MIN 1
28#define PCAP_FILE_LEN (30 * 1024 * 1024)
29#define PCAP_FILE_LEN_MIN (1 * 1024 * 1024)
30#define PCAP_FILE_LEN_MAX (50 * 1024 * 1024)
31
32#define PCAP_PKT_MIN_LEN 24
33#define PCAP_PKT_MAX_LEN 5000
34
35#define PCAP_PKT_HDR_MAGIC 0xa1b2c3d4
36#define PCAP_PKT_HDR_VER_MAJ 0x2
37#define PCAP_PKT_HDR_VER_MIN 0x4
38#define PCAP_PKT_HDR_THISZONE 0x0
39#define PCAP_PKT_HDR_SIGFIGS 0x0
40#define PCAP_PKT_HDR_SNAPLEN 0xffff
41#define PCAP_PKT_HDR_LINKTYPE_802_11 0x69
42#define PCAP_PKT_HDR_LINKTYPE_802_11_RADIOTAP 127
43
44#define IEEE80211_MAC_HDR_LEN 26
45#define TRIM_DATA_PAYLOAD_LEN 2000
46#define IEEE80211_FRAME_TYPE_DATA 0x02
47#define IEEE80211_FRAME_TYPE_MGMT 0x00
48#define IEEE80211_FRAME_SUBTYPE_QOS 0x08
49#define IEEE80211_FRAME_SUBTYPE_DISASSOC 0x0a
50
51#define MAC_ADDR_LEN 6
52
53#define DIRECTION_TX 0
54#define DIRECTION_RX 1
55
56#define PCAP_QOS_DATA_PKT_HDR_LEN 26
57
58/* frame control structure */
59typedef struct {
60 osal_u16 bit_protocol_version : 2, /* protocol version */
61 bit_type : 2, /* frame type */
62 bit_sub_type : 4, /* subtype */
63 bit_to_ds : 1, /* to DS */
64 bit_from_ds : 1, /* from DS */
65 bit_more_frag : 1, /* more fragment */
66 bit_retry : 1, /* retransmit frame */
67 bit_power_mgmt : 1, /* power management */
68 bit_more_data : 1, /* more data flag */
69 bit_protected_frame : 1, /* encrypt flag */
70 bit_order : 1; /* order bit */
71} mac_header_control_stru;
72
73/* qos frame 2+2+ 6*3 + 2 +1 +1 = 26 */
74typedef struct __attribute__ ((__packed__)) {
75 mac_header_control_stru st_frame_control;
76 osal_u16 bit_duration_value : 15, /* duration/id */
77 bit_duration_flag : 1;
78 osal_u8 auc_address1[MAC_ADDR_LEN];
79 osal_u8 auc_address2[MAC_ADDR_LEN];
80 osal_u8 auc_address3[MAC_ADDR_LEN];
81 osal_u16 bit_frag_num : 4, /* sequence control */
82 bit_seq_num : 12;
83 osal_u8 bit_qc_tid : 4,
84 bit_qc_eosp : 1,
85 bit_qc_ack_polocy : 2,
86 bit_qc_amsdu : 1;
87 union {
88 osal_u8 bit_qc_txop_limit;
89 osal_u8 bit_qc_ps_buf_state_resv : 1,
90 bit_qc_ps_buf_state_inducated : 1,
91 bit_qc_high_priority_buf_ac : 2,
92 bit_qc_qosap_buf_load : 4;
93 } qos_control;
94} mac_ieee80211_qos_stru;
95
96typedef struct {
97 osal_s32 sniffer_switch;
98 osal_s32 cur_file;
99 osal_s32 data_packet_max_len;
100 osal_s32 max_file_num;
101 osal_s32 max_file_len;
102 osal_s32 new_file_num;
103 osal_s32 new_file_len;
104 osal_s32 file_full[PCAP_FILE_NUM];
105 osal_s8 *buffer[PCAP_FILE_NUM];
106 osal_s32 curpos[PCAP_FILE_NUM];
107 osal_u32 gmttime[PCAP_FILE_NUM]; /* ms, between now and 1970-01-01 00:00:00 */
108 osal_u32 microtime[PCAP_FILE_NUM]; /* us, between now and 1970-01-01 00:00:00 */
109 osal_u32 packetcount[PCAP_FILE_NUM];
110 // osal_u32 promis_count[3][15]; /* 3 帧的类型,15 子帧的类型 */
111 osal_semaphore main_sem;
112} proc_file_config_struct;
113
114extern proc_file_config_struct g_sniffer_st;
115
116#pragma pack(1)
117typedef struct {
118 osal_u32 magic;
119 osal_u16 version_major;
120 osal_u16 version_minor;
121 osal_u32 thiszone;
122 osal_u32 sigfigs;
123 osal_u32 snaplen;
124 osal_u32 linktype;
125} wal_pcap_filehdr_stru;
126#pragma pack()
127
128/* 16 Bytes PCAP frame header's timestamp */
129typedef struct {
130 osal_u32 gmt_time; /* ms, between now and 1970-01-01 00:00:00 */
131 osal_u32 micro_time; /* us, between now and 1970-01-01 00:00:00 */
132} wal_pcap_time_stru;
133
134/* PCAP frame header (16 Bytes) */
135#pragma pack(1)
136typedef struct {
137 wal_pcap_time_stru time; /* PCAP Frame Header's timestamp */
138 osal_u32 caplen; /* length of (Frame Header + Frame Body) */
139 osal_u32 len; /* packet's actual length, len == caplen in common */
140} wal_pcap_pkthdr_stru;
141#pragma pack()
142
143/* 消息头 */
144typedef struct {
145 osal_u8 frame_start;
146 osal_u8 func_type;
147 osal_u8 prime_id;
148 osal_u8 reserver[1];
149 osal_u16 frame_len;
150 osal_u16 sn;
151} wal_msg_header_stru;
152
153/* WIFI OTA头部信息 */
154typedef struct {
155 osal_u32 tick; /* 时间戳,精度ms */
156 osal_u8 en_ota_type; /* OTA类型 */
157 osal_u8 frame_hdr_len; /* 如果是帧,代表帧头长度;如果是其它类型,此字段没有用 */
158 osal_u16 us_ota_data_len; /* OTA数据长度,如果是帧,代表帧头和帧体的总长度 */
159 osal_u8 user_macaddr[MAC_ADDR_LEN];
160 oam_ota_frame_direction_type_enum_uint8 en_frame_direction; /* 表明帧是属于发送流程还是接收流程,只有ota_type是帧的时候这个字段才有意义 */
161 osal_u8 resv[1]; /* 区分产品 */
162} wal_ota_hdr_stru;
163
164typedef struct {
165 wal_msg_header_stru oam_header;
166 wal_ota_hdr_stru st_ota_hdr;
167} wal_ota_stru;
168
169
170static INLINE__ osal_bool sniffer_enough_to_save(osal_u32 packet_len)
171{
172 return (g_sniffer_st.curpos[g_sniffer_st.cur_file] + (packet_len)) <= g_sniffer_st.max_file_len;
173}
174
175static INLINE__ osal_s32 sniffer_file_pos(osal_s32 i)
176{
177 return g_sniffer_st.curpos[i];
178}
179
180static INLINE__ osal_s32 sniffer_cur_file_pos(osal_void)
181{
182 return sniffer_file_pos(g_sniffer_st.cur_file);
183}
184
185static INLINE__ osal_bool sniffer_is_cur_file_empty(osal_void)
186{
187 return sniffer_cur_file_pos() == 0;
188}
189
190static INLINE__ osal_s8 *sniffer_file_buffer(osal_s32 i)
191{
192 return g_sniffer_st.buffer[i];
193}
194
195static INLINE__ osal_s8 *sniffer_cur_file_buffer(osal_void)
196{
197 return sniffer_file_buffer(g_sniffer_st.cur_file);
198}
199
200osal_s32 proc_handle_command_sniffer_enable(osal_s32 sniffer_mode);
201osal_s32 hmac_sniffer_get_switch(void);
202void proc_handle_command_save_file(void);
203osal_s32 proc_sniffer_reset_file_num_len(osal_s32 new_file_num, osal_s32 new_file_len);
204osal_void hmac_sniffer_80211_frame(const osal_u8 *hdr_addr, osal_u8 hdr_len,
205 const osal_u8 *frame_addr, osal_u16 frame_len, osal_u32 msg_id);
206
207#ifdef __cplusplus
208#if __cplusplus
209 }
210#endif
211#endif
212
213#endif
214#endif
215
216#endif
osal_u8 oam_ota_frame_direction_type_enum_uint8
Definition common_dft_rom.h:162
#define MAC_ADDR_LEN
Definition hmac_promisc.h:33
#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
signed char osal_s8
Definition osal_types.h:17
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
Log message information header.
Definition log_oam_logger.h:564
Definition osal_semaphore.h:20