]>
Commit | Line | Data |
---|---|---|
17d9616f PY |
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 | */ | |
17d9616f PY |
17 | /** |
18 | * \file | |
19 | * | |
20 | * \author Phil Young <py@napatech.com> | |
21 | * | |
22 | */ | |
17d9616f PY |
23 | #ifndef __UTIL_NAPATECH_H__ |
24 | #define __UTIL_NAPATECH_H__ | |
25 | ||
26 | #ifdef HAVE_NAPATECH | |
27 | #include <nt.h> | |
28 | ||
1c995369 PY |
29 | typedef struct NapatechPacketVars_ |
30 | { | |
17d9616f PY |
31 | uint64_t stream_id; |
32 | NtNetBuf_t nt_packet_buf; | |
b48049c5 | 33 | NtNetStreamRx_t rx_stream; |
d1d09ecf | 34 | NtFlowStream_t flow_stream; |
17d9616f | 35 | ThreadVars *tv; |
1c995369 PY |
36 | #ifdef NAPATECH_ENABLE_BYPASS |
37 | NtDyn3Descr_t *dyn3; | |
38 | int bypass; | |
39 | #endif | |
17d9616f PY |
40 | } NapatechPacketVars; |
41 | ||
1c995369 PY |
42 | typedef struct NapatechStreamConfig_ |
43 | { | |
a5164354 | 44 | uint8_t stream_id; |
17d9616f PY |
45 | bool is_active; |
46 | bool initialized; | |
47 | } NapatechStreamConfig; | |
48 | ||
1c995369 PY |
49 | typedef struct NapatechCurrentStats_ |
50 | { | |
17d9616f | 51 | uint64_t current_packets; |
17d9616f | 52 | uint64_t current_bytes; |
1c995369 PY |
53 | uint64_t current_drop_packets; |
54 | uint64_t current_drop_bytes; | |
17d9616f PY |
55 | } NapatechCurrentStats; |
56 | ||
1c995369 | 57 | #define MAX_HOSTBUFFER 4 |
17d9616f | 58 | #define MAX_STREAMS 256 |
1c995369 PY |
59 | #define MAX_PORTS 80 |
60 | #define MAX_ADAPTERS 8 | |
61 | #define HB_HIGHWATER 2048 //1982 | |
17d9616f PY |
62 | |
63 | extern void NapatechStartStats(void); | |
17d9616f | 64 | |
05271bfb PY |
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 | ||
1c995369 PY |
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 | |
05271bfb PY |
99 | |
100 | NapatechCurrentStats NapatechGetCurrentStats(uint16_t id); | |
101 | int NapatechGetStreamConfig(NapatechStreamConfig stream_config[]); | |
102 | bool NapatechSetupNuma(uint32_t stream, uint32_t numa); | |
1c995369 PY |
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 | ||
d1d09ecf PY |
116 | int NapatechVerifyBypassSupport(void); |
117 | int NapatechGetNumAdapters(void); | |
118 | ||
1c995369 PY |
119 | |
120 | int NapatechIsBypassSupported(void); | |
121 | ||
122 | #endif /* NAPATECH_ENABLE_BYPASS */ | |
123 | #endif /* HAVE_NAPATECH */ | |
17d9616f | 124 | #endif /* __UTIL_NAPATECH_H__ */ |