Go to the documentation of this file.
41 #define NT_RUNMODE_AUTOFP 1
42 #define NT_RUNMODE_WORKERS 2
44 static const char *default_mode =
"workers";
48 #define MAX_STREAMS 256
49 static uint16_t num_configured_streams = 0;
50 static uint16_t first_stream = 0xffff;
51 static uint16_t last_stream = 0xffff;
52 static int auto_config = 0;
53 static int use_hw_bypass = 0;
57 return num_configured_streams;
72 return (auto_config != 0);
77 return (use_hw_bypass != 0);
91 "Workers Napatech mode, each thread does all"
92 " tasks from acquisition to logging",
101 static int NapatechRegisterDeviceStreams(
void)
106 if (
ConfGetBool(
"napatech.use-all-streams", &use_all_streams) == 0) {
107 SCLogInfo(
"Could not find napatech.use-all-streams in config file. Defaulting to \"no\".");
111 if (
ConfGetBool(
"napatech.auto-config", &auto_config) == 0) {
112 SCLogInfo(
"napatech.auto-config not found in config file. Defaulting to disabled.");
115 if (
ConfGetBool(
"napatech.hardware-bypass", &use_hw_bypass) == 0) {
116 SCLogInfo(
"napatech.hardware-bypass not found in config file. Defaulting to disabled.");
122 if (use_all_streams && auto_config) {
123 FatalError(
"napatech.auto-config cannot be used in configuration file at the same time as "
124 "napatech.use-all-streams.");
131 if (use_hw_bypass && auto_config == 0) {
132 FatalError(
"napatech auto-config must be enabled when using napatech.use_hw_bypass.");
139 num_configured_streams = stream_cnt;
140 SCLogDebug(
"Configuring %d Napatech Streams...", stream_cnt);
142 for (uint16_t inst = 0; inst < stream_cnt; ++inst) {
143 char *plive_dev_buf =
SCCalloc(1, 9);
144 if (
unlikely(plive_dev_buf == NULL)) {
145 FatalError(
"Failed to allocate memory for NAPATECH stream counter.");
147 snprintf(plive_dev_buf, 9,
"nt%d",
stream_config[inst].stream_id);
151 SCLogError(
"Registering Napatech device: %s - active stream found.", plive_dev_buf);
153 "run /opt/napatech3/bin/ntpl -e \"delete=all\" to delete existing stream");
154 FatalError(
"or disable auto-config in the conf file before running.");
157 SCLogInfo(
"Registering Napatech device: %s - active stream%sfound.",
158 plive_dev_buf,
stream_config[inst].is_active ?
" " :
" NOT ");
162 if (first_stream == 0xffff) {
175 static void *NapatechConfigParser(
const char *device)
178 int dev_len = strlen(device);
179 if (dev_len < 3 || dev_len > 5) {
180 SCLogError(
"Could not parse config for device: %s - invalid length", device);
186 SCLogError(
"Failed to allocate memory for NAPATECH device name.");
192 SCLogError(
"Invalid value for stream_id: %s", device + 2);
203 SCLogWarning(
"Napatech Host Buffer Allocation (hba) will be deprecated in Suricata v7.0.");
205 return (
void *) conf;
208 static int NapatechGetThreadsCount(
void *conf
__attribute__((unused)))
215 static int NapatechInit(
int runmode)
222 if ((status = NT_Init(NTAPI_VERSION)) != NT_SUCCESS) {
227 status = NapatechRegisterDeviceStreams();
228 if (status < 0 || num_configured_streams <= 0) {
229 FatalError(
"Unable to find existing Napatech Streams");
235 FatalError(
"Failed to allocate memory for NAPATECH device.");
239 SCLogInfo(
"Host Buffer Allowance: %d", (
int) conf->
hba);
243 #ifdef NAPATECH_ENABLE_BYPASS
244 if (NapatechVerifyBypassSupport()) {
245 SCLogInfo(
"Napatech Hardware Bypass is supported and enabled.");
247 FatalError(
"Napatech Hardware Bypass requested in conf but is not supported by the "
252 "Napatech Hardware Bypass requested in conf but is not enabled by the software.");
255 SCLogInfo(
"Hardware Bypass is disabled in the conf file.");
const char * thread_name_workers
int ConfGetInt(const char *name, intmax_t *val)
Retrieve a configuration value as an integer.
int RunModeNapatechAutoFp(void)
int LiveRegisterDevice(const char *dev)
Add a pcap device for monitoring and create structure.
int RunModeSetLiveCaptureWorkers(ConfigIfaceParserFunc ConfigParser, ConfigIfaceThreadsCountFunc ModThreadsCount, const char *recv_mod_name, const char *decode_mod_name, const char *thread_name, const char *live_dev)
int ConfGetBool(const char *name, int *val)
Retrieve a configuration value as a boolean.
int StringParseUint16(uint16_t *res, int base, size_t len, const char *str)
void RunModeRegisterNewRunMode(enum RunModes runmode, const char *name, const char *description, int(*RunModeFunc)(void), void(*RunModeIsIPSEnabled)(void))
Registers a new runmode.
void LiveDeviceHasNoStats(void)
bool NapatechIsAutoConfigEnabled(void)
TcpStreamCnf stream_config
enum @22 __attribute__
DNP3 application header.
int NapatechGetStreamConfig(NapatechStreamConfig stream_config[])
Reads and parses the stream configuration defined in the config file.
#define SCLogWarning(...)
Macro used to log WARNING messages.
uint16_t NapatechGetNumConfiguredStreams(void)
#define NT_RUNMODE_AUTOFP
#define SCLogInfo(...)
Macro used to log INFORMATIONAL messages.
void TimeModeSetLive(void)
const char * RunModeNapatechGetDefaultMode(void)
int RunModeNapatechWorkers(void)
void NapatechStartStats(void)
uint16_t NapatechGetNumFirstStream(void)
bool NapatechUseHWBypass(void)
#define NT_RUNMODE_WORKERS
uint16_t NapatechGetNumLastStream(void)
#define SCLogError(...)
Macro used to log ERROR messages.
void RunModeNapatechRegister(void)
#define NAPATECH_ERROR(status)