suricata
util-napatech.h
Go to the documentation of this file.
1 /* Copyright (C) 2017 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  * \file
19  *
20  * \author Phil Young <py@napatech.com>
21  *
22  */
23 #ifndef __UTIL_NAPATECH_H__
24 #define __UTIL_NAPATECH_H__
25 
26 #ifdef HAVE_NAPATECH
27 #include <nt.h>
28 
29 typedef struct NapatechPacketVars_
30 {
31  uint64_t stream_id;
32  NtNetBuf_t nt_packet_buf;
34 #ifdef NAPATECH_ENABLE_BYPASS
35  NtDyn3Descr_t *dyn3;
36  int bypass;
37 #endif
39 
40 typedef struct NapatechStreamConfig_
41 {
42  uint16_t stream_id;
43  bool is_active;
46 
47 typedef struct NapatechCurrentStats_
48 {
49  uint64_t current_packets;
50  uint64_t current_bytes;
54 
55 #define MAX_HOSTBUFFER 4
56 #define MAX_STREAMS 256
57 #define MAX_PORTS 80
58 #define MAX_ADAPTERS 8
59 #define HB_HIGHWATER 2048 //1982
60 
61 extern void NapatechStartStats(void);
62 
63 #define NAPATECH_ERROR(err_type, status) { \
64  char errorBuffer[1024]; \
65  NT_ExplainError((status), errorBuffer, sizeof (errorBuffer) - 1); \
66  SCLogError((err_type), "Napatech Error: %s", errorBuffer); \
67  }
68 
69 #define NAPATECH_NTPL_ERROR(ntpl_cmd, ntpl_info, status) { \
70  char errorBuffer[1024]; \
71  NT_ExplainError(status, errorBuffer, sizeof (errorBuffer) - 1); \
72  SCLogError(SC_ERR_NAPATECH_STREAMS_REGISTER_FAILED, \
73  " NTPL failed: %s", errorBuffer); \
74  SCLogError(SC_ERR_NAPATECH_STREAMS_REGISTER_FAILED, \
75  " cmd: %s", ntpl_cmd); \
76  if (strncmp(ntpl_info.u.errorData.errBuffer[0], "", 256) != 0) \
77  SCLogError(SC_ERR_NAPATECH_STREAMS_REGISTER_FAILED, \
78  " %s", ntpl_info.u.errorData.errBuffer[0]); \
79  if (strncmp(ntpl_info.u.errorData.errBuffer[1], "", 256) != 0) \
80  SCLogError(SC_ERR_NAPATECH_STREAMS_REGISTER_FAILED, \
81  " %s", ntpl_info.u.errorData.errBuffer[1]); \
82  if (strncmp(ntpl_info.u.errorData.errBuffer[2], "", 256) != 0) \
83  SCLogError(SC_ERR_NAPATECH_STREAMS_REGISTER_FAILED, \
84  " %s", ntpl_info.u.errorData.errBuffer[2]); \
85 }
86 
87 // #define ENABLE_NT_DEBUG
88 #ifdef ENABLE_NT_DEBUG
89  void NapatechPrintIP(uint32_t address);
90 
91  #define NAPATECH_DEBUG(...) printf(__VA_ARGS__)
92  #define NAPATECH_PRINTIP(a) NapatechPrintIP(uint32_t address)
93 #else
94  #define NAPATECH_DEBUG(...)
95  #define NAPATECH_PRINTIP(a)
96 #endif
97 
100 bool NapatechSetupNuma(uint32_t stream, uint32_t numa);
101 uint32_t NapatechSetupTraffic(uint32_t first_stream, uint32_t last_stream);
102 uint32_t NapatechDeleteFilters(void);
103 
104 #ifdef NAPATECH_ENABLE_BYPASS
105 
106 /* */
107 #define NAPATECH_KEYTYPE_IPV4 3
108 #define NAPATECH_KEYTYPE_IPV4_SPAN 4
109 #define NAPATECH_KEYTYPE_IPV6 5
110 #define NAPATECH_KEYTYPE_IPV6_SPAN 6
111 #define NAPATECH_FLOWTYPE_DROP 7
112 #define NAPATECH_FLOWTYPE_PASS 8
113 
114 int NapatechInitFlowStreams(void);
115 NtFlowStream_t *NapatechGetFlowStreamPtr(int device);
116 int NapatechCloseFlowStreams(void);
117 
118 int NapatechIsBypassSupported(void);
119 
120 #endif /* NAPATECH_ENABLE_BYPASS */
121 #endif /* HAVE_NAPATECH */
122 #endif /* __UTIL_NAPATECH_H__ */
NapatechPacketVars_::stream_id
uint64_t stream_id
Definition: util-napatech.h:31
NapatechSetupNuma
bool NapatechSetupNuma(uint32_t stream, uint32_t numa)
Definition: util-napatech.c:1253
NapatechPacketVars_
Definition: util-napatech.h:29
NapatechStartStats
void NapatechStartStats(void)
Definition: util-napatech.c:1206
NapatechStreamConfig_::initialized
bool initialized
Definition: util-napatech.h:44
NapatechStreamConfig_
Definition: util-napatech.h:40
NapatechStreamConfig_::stream_id
uint16_t stream_id
Definition: util-napatech.h:42
NapatechCurrentStats_::current_packets
uint64_t current_packets
Definition: util-napatech.h:49
NapatechGetStreamConfig
int NapatechGetStreamConfig(NapatechStreamConfig stream_config[])
Reads and parses the stream configuration defined in the config file.
Definition: util-napatech.c:835
ThreadVars_
Per thread variable structure.
Definition: threadvars.h:57
NapatechPacketVars
struct NapatechPacketVars_ NapatechPacketVars
stream_config
TcpStreamCnf stream_config
Definition: stream-tcp.c:119
NapatechStreamConfig
struct NapatechStreamConfig_ NapatechStreamConfig
NapatechCurrentStats_::current_bytes
uint64_t current_bytes
Definition: util-napatech.h:50
NapatechCurrentStats
struct NapatechCurrentStats_ NapatechCurrentStats
NapatechSetupTraffic
uint32_t NapatechSetupTraffic(uint32_t first_stream, uint32_t last_stream)
Definition: util-napatech.c:1391
NapatechCurrentStats_::current_drop_bytes
uint64_t current_drop_bytes
Definition: util-napatech.h:52
NapatechPacketVars_::nt_packet_buf
NtNetBuf_t nt_packet_buf
Definition: util-napatech.h:32
address
uint8_t address
Definition: decode-ppp.h:2
NapatechGetCurrentStats
NapatechCurrentStats NapatechGetCurrentStats(uint16_t id)
Definition: util-napatech.c:223
NapatechCurrentStats_::current_drop_packets
uint64_t current_drop_packets
Definition: util-napatech.h:51
NapatechPacketVars_::tv
ThreadVars * tv
Definition: util-napatech.h:33
NapatechCurrentStats_
Definition: util-napatech.h:47
NapatechDeleteFilters
uint32_t NapatechDeleteFilters(void)
Definition: util-napatech.c:1364
NapatechStreamConfig_::is_active
bool is_active
Definition: util-napatech.h:43