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 SURICATA_UTIL_NAPATECH_H
24 #define SURICATA_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(status) \
66  { \
67  char errorBuffer[1024]; \
68  NT_ExplainError((status), errorBuffer, sizeof(errorBuffer) - 1); \
69  SCLogError("Napatech Error: %s", errorBuffer); \
70  }
71 
72 #define NAPATECH_NTPL_ERROR(ntpl_cmd, ntpl_info, status) \
73  { \
74  char errorBuffer[1024]; \
75  NT_ExplainError(status, errorBuffer, sizeof(errorBuffer) - 1); \
76  SCLogError(" NTPL failed: %s", errorBuffer); \
77  SCLogError(" cmd: %s", ntpl_cmd); \
78  if (strncmp(ntpl_info.u.errorData.errBuffer[0], "", 256) != 0) \
79  SCLogError(" %s", ntpl_info.u.errorData.errBuffer[0]); \
80  if (strncmp(ntpl_info.u.errorData.errBuffer[1], "", 256) != 0) \
81  SCLogError(" %s", ntpl_info.u.errorData.errBuffer[1]); \
82  if (strncmp(ntpl_info.u.errorData.errBuffer[2], "", 256) != 0) \
83  SCLogError(" %s", ntpl_info.u.errorData.errBuffer[2]); \
84  }
85 
86 // #define ENABLE_NT_DEBUG
87 #ifdef ENABLE_NT_DEBUG
88  void NapatechPrintIP(uint32_t address);
89 
90  #define NAPATECH_DEBUG(...) printf(__VA_ARGS__)
91  #define NAPATECH_PRINTIP(a) NapatechPrintIP(uint32_t address)
92 #else
93  #define NAPATECH_DEBUG(...)
94  #define NAPATECH_PRINTIP(a)
95 #endif
96 
99 bool NapatechSetupNuma(uint32_t stream, uint32_t numa);
100 uint32_t NapatechSetupTraffic(uint32_t first_stream, uint32_t last_stream);
101 uint32_t NapatechDeleteFilters(void);
102 
103 #ifdef NAPATECH_ENABLE_BYPASS
104 
105 /* */
106 #define NAPATECH_KEYTYPE_IPV4 3
107 #define NAPATECH_KEYTYPE_IPV4_SPAN 4
108 #define NAPATECH_KEYTYPE_IPV6 5
109 #define NAPATECH_KEYTYPE_IPV6_SPAN 6
110 #define NAPATECH_FLOWTYPE_DROP 7
111 #define NAPATECH_FLOWTYPE_PASS 8
112 
113 int NapatechVerifyBypassSupport(void);
114 int NapatechGetNumAdapters(void);
115 
116 
117 int NapatechIsBypassSupported(void);
118 
119 #endif /* NAPATECH_ENABLE_BYPASS */
120 #endif /* HAVE_NAPATECH */
121 #endif /* SURICATA_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:1223
NapatechPacketVars_
Definition: util-napatech.h:30
NapatechStartStats
void NapatechStartStats(void)
Definition: util-napatech.c:1185
NapatechStreamConfig_::initialized
bool initialized
Definition: util-napatech.h:46
stream_config
TcpStreamCnf stream_config
Definition: stream-tcp.c:115
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:804
ThreadVars_
Per thread variable structure.
Definition: threadvars.h:57
NapatechPacketVars
struct NapatechPacketVars_ NapatechPacketVars
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:1361
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:196
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:1334
NapatechStreamConfig_::is_active
bool is_active
Definition: util-napatech.h:45