1 /* Copyright (C) 2014-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 Aleksey Katargin <gureedo@gmail.com>
22 * \author Victor Julien <victor@inliniac.net>
23 */
24 
25 #ifndef __SOURCE_NETMAP_H__
26 #define __SOURCE_NETMAP_H__
27 
28 #include "queue.h"
29 
30 /* copy modes */
31 enum {
32     NETMAP_COPY_MODE_NONE,
33     NETMAP_COPY_MODE_TAP,
34     NETMAP_COPY_MODE_IPS,
35 };
36 
37 #define NETMAP_IFACE_NAME_LENGTH    48
38 
39 typedef struct NetmapIfaceSettings_
40 {
41     /* real inner interface name */
42     char iface[NETMAP_IFACE_NAME_LENGTH];
43 
44     /* sw ring flag for out_iface */
45     bool sw_ring;
46     bool promisc;
47     bool real;      /**< real iface or not. Not in case of vale, pipe */
48     bool ips;       /**< set to true if checksum_mode != NETMAP_COPY_MODE_NONE */
49     bool threads_auto;
50 
51     uint16_t threads;
52     int copy_mode;
53     ChecksumValidationMode checksum_mode;
54     const char *bpf_filter;
55 } NetmapIfaceSettings;
56 
57 typedef struct NetmapIfaceConfig_
58 {
59     /* semantic interface name */
60     char iface_name[NETMAP_IFACE_NAME_LENGTH];
61 
62     /* settings for out capture device*/
63     NetmapIfaceSettings in;
64 
65     /* settings for outgoing iface for IPS/TAP */
66     NetmapIfaceSettings out;
67 
68     SC_ATOMIC_DECLARE(unsigned int, ref);
69     void (*DerefFunc)(void *);
70 } NetmapIfaceConfig;
71 
72 typedef struct NetmapPacketVars_
73 {
74     /* NetmapThreadVars */
75     void *ntv;
76 } NetmapPacketVars;
77 
78 int NetmapGetRSSCount(const char *ifname);
79 
80 void TmModuleReceiveNetmapRegister (void);
81 void TmModuleDecodeNetmapRegister (void);
82 
83 #endif /* __SOURCE_NETMAP_H__ */
84