suricata
util-datalink.h
Go to the documentation of this file.
1 /* Copyright (C) 2021 Open Information Security Foundation
2  *
3  * You can copy, redistribute or modify this Program under the terms of
4  * the GNU General Public License version 2 as published by the Free
5  * Software Foundation.
6  *
7  * This program is distributed in the hope that it will be useful,
8  * but WITHOUT ANY WARRANTY; without even the implied warranty of
9  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
10  * GNU General Public License for more details.
11  *
12  * You should have received a copy of the GNU General Public License
13  * version 2 along with this program; if not, write to the Free Software
14  * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
15  * 02110-1301, USA.
16  */
17 
18 #ifndef SURICATA_UTIL_DATALINK_H
19 #define SURICATA_UTIL_DATALINK_H
20 
21 #include "util-debug.h"
22 
23 /* pcap provides this, but we don't want to depend on libpcap */
24 #ifndef DLT_EN10MB
25 #define DLT_EN10MB 1
26 #endif
27 
28 #ifndef DLT_C_HDLC
29 #define DLT_C_HDLC 104
30 #endif
31 
32 /* taken from pcap's bpf.h */
33 #ifndef DLT_RAW
34 #ifdef __OpenBSD__
35 #define DLT_RAW 14 /* raw IP */
36 #else
37 #define DLT_RAW 12 /* raw IP */
38 #endif
39 #endif
40 
41 #ifndef DLT_NULL
42 #define DLT_NULL 0
43 #endif
44 
45 /** libpcap shows us the way to linktype codes
46  * \todo we need more & maybe put them in a separate file? */
47 #define LINKTYPE_NULL DLT_NULL
48 #define LINKTYPE_ETHERNET DLT_EN10MB
49 #define LINKTYPE_LINUX_SLL 113
50 #define LINKTYPE_PPP 9
51 #define LINKTYPE_RAW DLT_RAW
52 /* http://www.tcpdump.org/linktypes.html defines DLT_RAW as 101, yet others don't.
53  * Libpcap on at least OpenBSD returns 101 as datalink type for RAW pcaps though. */
54 #define LINKTYPE_RAW2 101
55 #define LINKTYPE_IPV4 228
56 #define LINKTYPE_IPV6 229
57 #define LINKTYPE_GRE_OVER_IP 778
58 #define LINKTYPE_CISCO_HDLC DLT_C_HDLC
59 
60 void DatalinkSetGlobalType(int datalink);
61 int DatalinkGetGlobalType(void);
62 bool DatalinkHasMultipleValues(void);
63 void DatalinkTableInit(void);
64 void DatalinkTableDeinit(void);
65 const char *DatalinkValueToName(int datalink_value);
66 
67 #endif /* SURICATA_UTIL_DATALINK_H */
util-debug.h