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;
33  NtNetStreamRx_t rx_stream;
34  NtFlowStream_t flow_stream;
36 #ifdef NAPATECH_ENABLE_BYPASS
37  NtDyn3Descr_t *dyn3;
38  int bypass;
39 #endif
41 
42 typedef struct NapatechStreamConfig_
43 {
44  uint8_t stream_id;
45  bool is_active;
48 
49 typedef struct NapatechCurrentStats_
50 {
51  uint64_t current_packets;
52  uint64_t current_bytes;
56 
57 #define MAX_HOSTBUFFER 4
58 #define MAX_STREAMS 256
59 #define MAX_PORTS 80
60 #define MAX_ADAPTERS 8
61 #define HB_HIGHWATER 2048 //1982
62 
63 extern void NapatechStartStats(void);
64 
65 #define NAPATECH_ERROR(err_type, status) { \
66  char errorBuffer[1024]; \
67  NT_ExplainError((status), errorBuffer, sizeof (errorBuffer) - 1); \
68  SCLogError((err_type), "Napatech Error: %s", errorBuffer); \
69  }
70 
71 #define NAPATECH_NTPL_ERROR(ntpl_cmd, ntpl_info, status) { \
72  char errorBuffer[1024]; \
73  NT_ExplainError(status, errorBuffer, sizeof (errorBuffer) - 1); \
74  SCLogError(SC_ERR_NAPATECH_STREAMS_REGISTER_FAILED, \
75  " NTPL failed: %s", errorBuffer); \
76  SCLogError(SC_ERR_NAPATECH_STREAMS_REGISTER_FAILED, \
77  " cmd: %s", ntpl_cmd); \
78  if (strncmp(ntpl_info.u.errorData.errBuffer[0], "", 256) != 0) \
79  SCLogError(SC_ERR_NAPATECH_STREAMS_REGISTER_FAILED, \
80  " %s", ntpl_info.u.errorData.errBuffer[0]); \
81  if (strncmp(ntpl_info.u.errorData.errBuffer[1], "", 256) != 0) \
82  SCLogError(SC_ERR_NAPATECH_STREAMS_REGISTER_FAILED, \
83  " %s", ntpl_info.u.errorData.errBuffer[1]); \
84  if (strncmp(ntpl_info.u.errorData.errBuffer[2], "", 256) != 0) \
85  SCLogError(SC_ERR_NAPATECH_STREAMS_REGISTER_FAILED, \
86  " %s", ntpl_info.u.errorData.errBuffer[2]); \
87 }
88 
89 // #define ENABLE_NT_DEBUG
90 #ifdef ENABLE_NT_DEBUG
91  void NapatechPrintIP(uint32_t address);
92 
93  #define NAPATECH_DEBUG(...) printf(__VA_ARGS__)
94  #define NAPATECH_PRINTIP(a) NapatechPrintIP(uint32_t address)
95 #else
96  #define NAPATECH_DEBUG(...)
97  #define NAPATECH_PRINTIP(a)
98 #endif
99 
102 bool NapatechSetupNuma(uint32_t stream, uint32_t numa);
103 uint32_t NapatechSetupTraffic(uint32_t first_stream, uint32_t last_stream);
104 uint32_t NapatechDeleteFilters(void);
105 
106 #ifdef NAPATECH_ENABLE_BYPASS
107 
108 /* */
109 #define NAPATECH_KEYTYPE_IPV4 3
110 #define NAPATECH_KEYTYPE_IPV4_SPAN 4
111 #define NAPATECH_KEYTYPE_IPV6 5
112 #define NAPATECH_KEYTYPE_IPV6_SPAN 6
113 #define NAPATECH_FLOWTYPE_DROP 7
114 #define NAPATECH_FLOWTYPE_PASS 8
115 
116 int NapatechVerifyBypassSupport(void);
117 int NapatechGetNumAdapters(void);
118 
119 
120 int NapatechIsBypassSupported(void);
121 
122 #endif /* NAPATECH_ENABLE_BYPASS */
123 #endif /* HAVE_NAPATECH */
124 #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:1243
NapatechPacketVars_
Definition: util-napatech.h:30
NapatechStartStats
void NapatechStartStats(void)
Definition: util-napatech.c:1196
NapatechStreamConfig_::initialized
bool initialized
Definition: util-napatech.h:46
NapatechStreamConfig_
Definition: util-napatech.h:43
NapatechCurrentStats_::current_packets
uint64_t current_packets
Definition: util-napatech.h:51
NapatechGetStreamConfig
int NapatechGetStreamConfig(NapatechStreamConfig stream_config[])
Reads and parses the stream configuration defined in the config file.
Definition: util-napatech.c:813
ThreadVars_
Per thread variable structure.
Definition: threadvars.h:58
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:52
NapatechCurrentStats
struct NapatechCurrentStats_ NapatechCurrentStats
NapatechSetupTraffic
uint32_t NapatechSetupTraffic(uint32_t first_stream, uint32_t last_stream)
Definition: util-napatech.c:1381
NapatechCurrentStats_::current_drop_bytes
uint64_t current_drop_bytes
Definition: util-napatech.h:54
NapatechStreamConfig_::stream_id
uint8_t stream_id
Definition: util-napatech.h:44
NapatechPacketVars_::nt_packet_buf
NtNetBuf_t nt_packet_buf
Definition: util-napatech.h:32
address
uint8_t address
Definition: decode-ppp.h:0
NapatechGetCurrentStats
NapatechCurrentStats NapatechGetCurrentStats(uint16_t id)
Definition: util-napatech.c:193
NapatechCurrentStats_::current_drop_packets
uint64_t current_drop_packets
Definition: util-napatech.h:53
NapatechPacketVars_::tv
ThreadVars * tv
Definition: util-napatech.h:35
NapatechPacketVars_::rx_stream
NtNetStreamRx_t rx_stream
Definition: util-napatech.h:33
NapatechPacketVars_::flow_stream
NtFlowStream_t flow_stream
Definition: util-napatech.h:34
NapatechCurrentStats_
Definition: util-napatech.h:50
NapatechDeleteFilters
uint32_t NapatechDeleteFilters(void)
Definition: util-napatech.c:1354
NapatechStreamConfig_::is_active
bool is_active
Definition: util-napatech.h:45