• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1 /*
2  * Copyright (c) 2021 Bestechnic (Shanghai) Co., Ltd. All rights reserved.
3  * Licensed under the Apache License, Version 2.0 (the "License");
4  * you may not use this file except in compliance with the License.
5  * You may obtain a copy of the License at
6  *
7  *     http://www.apache.org/licenses/LICENSE-2.0
8  *
9  * Unless required by applicable law or agreed to in writing, software
10  * distributed under the License is distributed on an "AS IS" BASIS,
11  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12  * See the License for the specific language governing permissions and
13  * limitations under the License.
14  */
15 #ifndef _BES_SNIFFER_H_
16 #define _BES_SNIFFER_H_
17 
18 #include "plat_types.h"
19 
20 #define SNIFFER_STATE_ENABLE_MASK  0x001
21 #define SNIFFER_STATE_DISABLE      0x000
22 #define SNIFFER_STATE_ENABLE       0x001
23 #define SNIFFER_STATE_MGMT         0x002
24 #define SNIFFER_STATE_FROMDS       0x004
25 #define SNIFFER_STATE_TODS         0x008
26 #define SNIFFER_STATE_40M          0x010
27 #define SNIFFER_STATE_ACK          0x020
28 #define SNIFFER_STATE_RTSCTX       0x040
29 #define SNIFFER_STATE_NULL         0x080
30 
31 #define SNIFFER_STATE_MGMT_MASK       0xfff000
32 
33 #define SNIFFER_STATE_MGMT_ASRQ       0x001000
34 #define SNIFFER_STATE_MGMT_ASRSP      0x002000
35 #define SNIFFER_STATE_MGMT_RSRQ       0x004000
36 #define SNIFFER_STATE_MGMT_RSRSP      0x008000
37 #define SNIFFER_STATE_MGMT_PBRQ       0x010000
38 #define SNIFFER_STATE_MGMT_PBRSP      0x020000
39 #define SNIFFER_STATE_MGMT_BCN	      0x040000
40 #define SNIFFER_STATE_MGMT_ATIM       0x080000
41 #define SNIFFER_STATE_MGMT_DAS	      0x100000
42 #define SNIFFER_STATE_MGMT_AUTH       0x200000
43 #define SNIFFER_STATE_MGMT_DAUTH      0x400000
44 #define SNIFFER_STATE_MGMT_ACTION     0x800000
45 
46 enum TYPESUBTYPE_T
47 {
48     ASSOC_REQ             = 0x00,
49     ASSOC_RSP             = 0x10,
50     REASSOC_REQ           = 0x20,
51     REASSOC_RSP           = 0x30,
52     PROBE_REQ             = 0x40,
53     PROBE_RSP             = 0x50,
54     BEACON                = 0x80,
55     ATIM                  = 0x90,
56     DISASOC               = 0xA0,
57     AUTH                  = 0xB0,
58     DEAUTH                = 0xC0,
59     ACTION                = 0xD0,
60     PS_POLL               = 0xA4,
61     RTS                   = 0xB4,
62     CTS                   = 0xC4,
63     ACK                   = 0xD4,
64     CFEND                 = 0xE4,
65     CFEND_ACK             = 0xF4,
66     DATA                  = 0x08,
67     DATA_ACK              = 0x18,
68     DATA_POLL             = 0x28,
69     DATA_POLL_ACK         = 0x38,
70     NULL_FRAME            = 0x48,
71     CFACK                 = 0x58,
72     CFPOLL                = 0x68,
73     CFPOLL_ACK            = 0x78,
74     QOS_DATA              = 0x88,
75     QOS_DATA_ACK          = 0x98,
76     QOS_DATA_POLL         = 0xA8,
77     QOS_DATA_POLL_ACK     = 0xB8,
78     QOS_NULL_FRAME        = 0xC8,
79     QOS_CFPOLL            = 0xE8,
80     QOS_CFPOLL_ACK        = 0xF8,
81     BLOCKACK_REQ          = 0x84,
82     BLOCKACK              = 0x94
83 };
84 
85 typedef int (*sniffer_handler_t)(const u8 *data, u16 data_len, int signal);
86 
87 int bes_sniffer_start(sniffer_handler_t handler);
88 int bes_sniffer_stop(void);
89 int bes_sniffer_set_channel(u8 channel);
90 int bes_sniffer_set_filter(u8 f_mgmt, u8 f_fromds, u8 f_tods, u8 f_error, u8 f_ack, u8 f_rts, u8 f_null);
91 int bes_sniffer_send_mgmt_frame(u8 channel, const u8 *data, size_t len);
92 
93 #endif
94