suricata
util-ebpf.h
Go to the documentation of this file.
1 /* Copyright (C) 2018 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 /**
19  * \file
20  *
21  * \author Eric Leblond <eric@regit.org>
22  */
23 
24 #ifndef __UTIL_EBPF_H__
25 #define __UTIL_EBPF_H__
26 
27 #ifdef HAVE_PACKET_EBPF
28 
29 #define XDP_FLAGS_UPDATE_IF_NOEXIST (1U << 0)
30 #define XDP_FLAGS_SKB_MODE (1U << 1)
31 #define XDP_FLAGS_DRV_MODE (1U << 2)
32 #define XDP_FLAGS_HW_MODE (1U << 3)
33 
34 #include "flow-bypass.h"
35 
36 struct flowv4_keys {
37  __be32 src;
38  __be32 dst;
39  union {
40  __be32 ports;
41  __be16 port16[2];
42  };
43  __u32 ip_proto;
44 } __attribute__((__aligned__(8)));
45 
46 struct flowv6_keys {
47  __be32 src[4];
48  __be32 dst[4];
49  union {
50  __be32 ports;
51  __be16 port16[2];
52  };
53  __u32 ip_proto;
54 } __attribute__((__aligned__(8)));
55 
56 struct pair {
57  uint64_t time;
58  uint64_t packets;
59  uint64_t bytes;
60 } __attribute__((__aligned__(8)));
61 
62 #define EBPF_SOCKET_FILTER (1<<0)
63 #define EBPF_XDP_CODE (1<<1)
64 
65 int EBPFGetMapFDByName(const char *iface, const char *name);
66 int EBPFLoadFile(const char *iface, const char *path, const char * section,
67  int *val, uint8_t flags);
68 int EBPFSetupXDP(const char *iface, int fd, uint8_t flags);
69 
70 int EBPFCheckBypassedFlowTimeout(struct flows_stats *bypassstats,
71  struct timespec *curtime);
72 
73 void EBPFRegisterExtension(void);
74 
75 void EBPFBuildCPUSet(ConfNode *node, char *iface);
76 
77 int EBPFSetPeerIface(const char *iface, const char *out_iface);
78 
79 int EBPFUpdateFlow(Flow *f, Packet *p);
80 
81 #ifdef BUILD_UNIX_SOCKET
82 TmEcode EBPFGetBypassedStats(json_t *cmd, json_t *answer, void *data);
83 #endif
84 
85 #endif
86 
87 #endif
uint16_t flags
uint16_t src
typedef __attribute__
DNP3 application header.
uint16_t dst
Definition: conf.h:32
Flow data structure.
Definition: flow.h:325