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_LINUX_SLL2 276
51#define LINKTYPE_PPP 9
52#define LINKTYPE_RAW DLT_RAW
53/* http://www.tcpdump.org/linktypes.html defines DLT_RAW as 101, yet others don't.
54 * Libpcap on at least OpenBSD returns 101 as datalink type for RAW pcaps though. */
55#define LINKTYPE_RAW2 101
56#define LINKTYPE_IPV4 228
57#define LINKTYPE_IPV6 229
58#define LINKTYPE_GRE_OVER_IP 778
59#define LINKTYPE_CISCO_HDLC DLT_C_HDLC
60
61void DatalinkSetGlobalType(int datalink);
62int DatalinkGetGlobalType(void);
64void DatalinkTableInit(void);
65void DatalinkTableDeinit(void);
66const char *DatalinkValueToName(int datalink_value);
67
68#endif /* SURICATA_UTIL_DATALINK_H */