suricata
source-napatech.c
Go to the documentation of this file.
1 /* Copyright (C) 2012-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 /**
19  * \file
20  *
21 - * \author nPulse Technologies, LLC.
22 - * \author Matt Keeler <mk@npulsetech.com>
23  * *
24  * Support for NAPATECH adapter with the 3GD Driver/API.
25  * Requires libntapi from Napatech A/S.
26  *
27  */
28 
29 #include "suricata-common.h"
30 #include "suricata.h"
31 #include "threadvars.h"
32 #include "util-optimize.h"
33 #include "tm-queuehandlers.h"
34 #include "tm-threads.h"
35 #include "tm-modules.h"
36 #include "util-privs.h"
37 #include "tmqh-packetpool.h"
38 #include "util-napatech.h"
39 #include "source-napatech.h"
40 
41 #ifndef HAVE_NAPATECH
42 
43 TmEcode NoNapatechSupportExit(ThreadVars *, const void *, void **);
44 
46 {
47  tmm_modules[TMM_RECEIVENAPATECH].name = "NapatechStream";
48  tmm_modules[TMM_RECEIVENAPATECH].ThreadInit = NoNapatechSupportExit;
54 }
55 
57 {
58  tmm_modules[TMM_DECODENAPATECH].name = "NapatechDecode";
59  tmm_modules[TMM_DECODENAPATECH].ThreadInit = NoNapatechSupportExit;
66 }
67 
68 TmEcode NoNapatechSupportExit(ThreadVars *tv, const void *initdata, void **data)
69 {
71  "Error creating thread %s: you do not have support for Napatech adapter "
72  "enabled please recompile with --enable-napatech", tv->name);
73  exit(EXIT_FAILURE);
74 }
75 
76 #else /* Implied we do have NAPATECH support */
77 
78 #include <numa.h>
79 #include <nt.h>
80 
81 #define MAX_STREAMS 256
82 
83 extern int max_pending_packets;
84 
85 typedef struct NapatechThreadVars_ {
87  NtNetStreamRx_t rx_stream;
88  uint16_t stream_id;
89  int hba;
92 
93 
94 TmEcode NapatechStreamThreadInit(ThreadVars *, const void *, void **);
96 TmEcode NapatechPacketLoopZC(ThreadVars *tv, void *data, void *slot);
97 
98 TmEcode NapatechDecodeThreadInit(ThreadVars *, const void *, void **);
101 
102 /* These are used as the threads are exiting to get a comprehensive count of
103  * all the packets received and dropped.
104  */
105 SC_ATOMIC_DECLARE(uint64_t, total_packets);
106 SC_ATOMIC_DECLARE(uint64_t, total_drops);
107 SC_ATOMIC_DECLARE(uint16_t, total_tallied);
108 
109 /* Streams are counted as they are instantiated in order to know when all threads
110  * are running*/
111 SC_ATOMIC_DECLARE(uint16_t, stream_count);
112 
113 SC_ATOMIC_DECLARE(uint16_t, numa0_count);
114 SC_ATOMIC_DECLARE(uint16_t, numa1_count);
115 SC_ATOMIC_DECLARE(uint16_t, numa2_count);
116 SC_ATOMIC_DECLARE(uint16_t, numa3_count);
117 
118 /**
119  * \brief Register the Napatech receiver (reader) module.
120  */
122 {
123  tmm_modules[TMM_RECEIVENAPATECH].name = "NapatechStream";
133 
134  SC_ATOMIC_INIT(total_packets);
135  SC_ATOMIC_INIT(total_drops);
136  SC_ATOMIC_INIT(total_tallied);
137  SC_ATOMIC_INIT(stream_count);
138 
139  SC_ATOMIC_INIT(numa0_count);
140  SC_ATOMIC_INIT(numa1_count);
141  SC_ATOMIC_INIT(numa2_count);
142  SC_ATOMIC_INIT(numa3_count);
143 }
144 
145 /**
146  * \brief Register the Napatech decoder module.
147  */
149 {
150  tmm_modules[TMM_DECODENAPATECH].name = "NapatechDecode";
158 }
159 
160 /**
161  * \brief Initialize the Napatech receiver thread, generate a single
162  * NapatechThreadVar structure for each thread, this will
163  * contain a NtNetStreamRx_t stream handle which is used when the
164  * thread executes to acquire the packets.
165  *
166  * \param tv Thread variable to ThreadVars
167  * \param initdata Initial data to the adapter passed from the user,
168  * this is processed by the user.
169  *
170  * For now, we assume that we have only a single name for the NAPATECH
171  * adapter.
172  *
173  * \param data data pointer gets populated with
174  *
175  */
176 TmEcode NapatechStreamThreadInit(ThreadVars *tv, const void *initdata, void **data)
177 {
178  SCEnter();
179  struct NapatechStreamDevConf *conf = (struct NapatechStreamDevConf *) initdata;
180  uint16_t stream_id = conf->stream_id;
181  *data = NULL;
182 
183  NapatechThreadVars *ntv = SCCalloc(1, sizeof (NapatechThreadVars));
184  if (unlikely(ntv == NULL)) {
185  SCLogError(SC_ERR_MEM_ALLOC, "Failed to allocate memory for NAPATECH thread vars.");
186  exit(EXIT_FAILURE);
187  }
188 
189  memset(ntv, 0, sizeof (NapatechThreadVars));
190  ntv->stream_id = stream_id;
191  ntv->tv = tv;
192  ntv->hba = conf->hba;
193  SCLogDebug("Started processing packets from NAPATECH Stream: %lu", ntv->stream_id);
194 
195  *data = (void *) ntv;
197 }
198 
199 static PacketQueue packets_to_release[MAX_STREAMS];
200 
201 static void NapatechReleasePacket(struct Packet_ *p)
202 {
204  PacketEnqueue(&packets_to_release[p->ntpv.stream_id], p);
205 }
206 
207 static int GetNumaNode(void)
208 {
209  int cpu = 0;
210  int node = 0;
211 
212 #if defined(__linux__)
213  cpu = sched_getcpu();
214  node = numa_node_of_cpu(cpu);
215 #else
217  "Auto configuration of NUMA node is not supported on this OS.");
218 #endif
219 
220  return node;
221 }
222 
223 static void RecommendNUMAConfig(SCLogLevel log_level)
224 {
225  char string0[16];
226  char string1[16];
227  char string2[16];
228  char string3[16];
229  int set_cpu_affinity = 0;
230 
231  if (ConfGetBool("threading.set-cpu-affinity", &set_cpu_affinity) != 1) {
232  set_cpu_affinity = 0;
233  }
234 
235  if (set_cpu_affinity) {
236  SCLog(log_level, __FILE__, __FUNCTION__, __LINE__,
237  "Minimum host buffers that should be defined in ntservice.ini:");
238 
239  SCLog(log_level, __FILE__, __FUNCTION__, __LINE__,
240  " NUMA Node 0: %d", (SC_ATOMIC_GET(numa0_count)));
241 
242  if (numa_max_node() >= 1) SCLog(log_level, __FILE__, __FUNCTION__, __LINE__,
243  " NUMA Node 1: %d ", (SC_ATOMIC_GET(numa1_count)));
244 
245  if (numa_max_node() >= 2) SCLog(log_level, __FILE__, __FUNCTION__, __LINE__,
246  " NUMA Node 2: %d ", (SC_ATOMIC_GET(numa2_count)));
247 
248  if (numa_max_node() >= 3) SCLog(log_level, __FILE__, __FUNCTION__, __LINE__,
249  " NUMA Node 3: %d ", (SC_ATOMIC_GET(numa3_count)));
250 
251  snprintf(string0, 16, "[%d, 16, 0]", SC_ATOMIC_GET(numa0_count));
252  snprintf(string1, 16, (numa_max_node() >= 1 ? ",[%d, 16, 1]" : ""),
253  SC_ATOMIC_GET(numa1_count));
254  snprintf(string2, 16, (numa_max_node() >= 2 ? ",[%d, 16, 2]" : ""),
255  SC_ATOMIC_GET(numa2_count));
256  snprintf(string3, 16, (numa_max_node() >= 3 ? ",[%d, 16, 3]" : ""),
257  SC_ATOMIC_GET(numa3_count));
258 
259  SCLog(log_level, __FILE__, __FUNCTION__, __LINE__,
260  "E.g.: HostBuffersRx=%s%s%s%s", string0, string1, string2, string3);
261  } else if (log_level == SC_LOG_ERROR) {
263  "Or, try running /opt/napatech3/bin/ntpl -e \"delete=all\" to clean-up stream NUMA config.");
264  }
265 }
266 
268 {
269  int32_t status;
270  char error_buffer[100];
271  uint64_t pkt_ts;
272  NtNetBuf_t packet_buffer;
273  NapatechThreadVars *ntv = (NapatechThreadVars *) data;
274  uint64_t hba_pkt_drops = 0;
275  uint64_t hba_byte_drops = 0;
276  uint16_t hba_pkt = 0;
277  uint32_t filter_id = 0;
278  uint32_t hash_id = 0;
279  uint32_t numa_node = 0;
280  int set_cpu_affinity = 0;
281 
282 
283  /* This just keeps the startup output more orderly. */
284  usleep(200000 * ntv->stream_id);
285 
287  numa_node = GetNumaNode();
288  switch (numa_node) {
289  case 0: SC_ATOMIC_ADD(numa0_count, 1);
290  break;
291  case 1: SC_ATOMIC_ADD(numa1_count, 1);
292  break;
293  case 2: SC_ATOMIC_ADD(numa2_count, 1);
294  break;
295  case 3: SC_ATOMIC_ADD(numa3_count, 1);
296  break;
297  default: break;
298  }
299 
300  if (ConfGetBool("threading.set-cpu-affinity", &set_cpu_affinity) != 1) {
301  set_cpu_affinity = 0;
302  }
303 
304  if (set_cpu_affinity) {
305  NapatechSetupNuma(ntv->stream_id, numa_node);
306  }
307  }
308 
310  numa_node = GetNumaNode();
311  SC_ATOMIC_ADD(stream_count, 1);
312  if (SC_ATOMIC_GET(stream_count) == NapatechGetNumConfiguredStreams()) {
313  /* The last thread to run sets up the streams */
316  &filter_id, &hash_id);
317 
318  if (filter_id == 0) {
319 
320  if (status == 0x20002061) {
322  "Check host buffer configuration in ntservice.ini.");
323  RecommendNUMAConfig(SC_LOG_ERROR);
324 
325  } else if (filter_id == 0x20000008) {
327  "Check napatech.ports in the suricata config file.");
328  }
329 
330  exit(EXIT_FAILURE);
331  }
332 
333  RecommendNUMAConfig(SC_LOG_INFO);
334  }
335  }
336 
337  SCLogInfo("Napatech Packet Loop Started - cpu: %3d, cpu_numa: %3d stream: %3u ",
338  sched_getcpu(), numa_node, ntv->stream_id);
339 
340  if (ntv->hba > 0) {
341  char *s_hbad_pkt = SCCalloc(1, 32);
342  if (unlikely(s_hbad_pkt == NULL)) {
344  "Failed to allocate memory for NAPATECH stream counter.");
345  exit(EXIT_FAILURE);
346  }
347  snprintf(s_hbad_pkt, 32, "nt%d.hba_drop", ntv->stream_id);
348  hba_pkt = StatsRegisterCounter(s_hbad_pkt, tv);
349  StatsSetupPrivate(tv);
350  StatsSetUI64(tv, hba_pkt, 0);
351  }
352  SCLogDebug("Opening NAPATECH Stream: %lu for processing", ntv->stream_id);
353 
354  if ((status = NT_NetRxOpen(&(ntv->rx_stream), "SuricataStream",
355  NT_NET_INTERFACE_PACKET, ntv->stream_id, ntv->hba)) != NT_SUCCESS) {
356 
358  SCFree(ntv);
360  }
361 
362  TmSlot *s = (TmSlot *) slot;
363  ntv->slot = s->slot_next;
364 
365  while (!(suricata_ctl_flags & SURICATA_STOP)) {
366  /* make sure we have at least one packet in the packet pool, to prevent
367  * us from alloc'ing packets at line rate */
368  PacketPoolWait();
369 
370  /* Napatech returns packets 1 at a time */
371  status = NT_NetRxGet(ntv->rx_stream, &packet_buffer, 1000);
372  if (unlikely(status == NT_STATUS_TIMEOUT || status == NT_STATUS_TRYAGAIN)) {
373  continue;
374  } else if (unlikely(status != NT_SUCCESS)) {
376  SCLogInfo("Failed to read from Napatech Stream%d: %s",
377  ntv->stream_id, error_buffer);
379  }
380 
382  if (unlikely(p == NULL)) {
383  NT_NetRxRelease(ntv->rx_stream, packet_buffer);
385  }
386 
387  pkt_ts = NT_NET_GET_PKT_TIMESTAMP(packet_buffer);
388 
389  /*
390  * Handle the different timestamp forms that the napatech cards could use
391  * - NT_TIMESTAMP_TYPE_NATIVE is not supported due to having an base
392  * of 0 as opposed to NATIVE_UNIX which has a base of 1/1/1970
393  */
394  switch (NT_NET_GET_PKT_TIMESTAMP_TYPE(packet_buffer)) {
395  case NT_TIMESTAMP_TYPE_NATIVE_UNIX:
396  p->ts.tv_sec = pkt_ts / 100000000;
397  p->ts.tv_usec = ((pkt_ts % 100000000) / 100) + (pkt_ts % 100) > 50 ? 1 : 0;
398  break;
399  case NT_TIMESTAMP_TYPE_PCAP:
400  p->ts.tv_sec = pkt_ts >> 32;
401  p->ts.tv_usec = pkt_ts & 0xFFFFFFFF;
402  break;
403  case NT_TIMESTAMP_TYPE_PCAP_NANOTIME:
404  p->ts.tv_sec = pkt_ts >> 32;
405  p->ts.tv_usec = ( (pkt_ts & 0xFFFFFFFF) / 1000)
406  + (pkt_ts % 1000) > 500 ? 1 : 0;
407  break;
408  case NT_TIMESTAMP_TYPE_NATIVE_NDIS:
409  /* number of seconds between 1/1/1601 and 1/1/1970 */
410  p->ts.tv_sec = (pkt_ts / 100000000) - 11644473600;
411  p->ts.tv_usec = ( (pkt_ts % 100000000) / 100)
412  + (pkt_ts % 100) > 50 ? 1 : 0;
413  break;
414  default:
416  "Packet from Napatech Stream: %u does not have a supported timestamp format",
417  ntv->stream_id);
418  NT_NetRxRelease(ntv->rx_stream, packet_buffer);
420  }
421 
422  if (unlikely(ntv->hba > 0)) {
423  NtNetRx_t stat_cmd;
424  stat_cmd.cmd = NT_NETRX_READ_CMD_STREAM_DROP;
425  /* Update drop counter */
426  if (unlikely((status = NT_NetRxRead(ntv->rx_stream, &stat_cmd)) != NT_SUCCESS)) {
428  SCLogInfo("Couldn't retrieve drop statistics from the RX stream: %u - %s",
429  ntv->stream_id, error_buffer);
430  } else {
431  hba_pkt_drops = stat_cmd.u.streamDrop.pktsDropped;
432 
433  StatsSetUI64(tv, hba_pkt, hba_pkt_drops);
434  }
436  }
437 
438  p->ReleasePacket = NapatechReleasePacket;
439  p->ntpv.nt_packet_buf = packet_buffer;
440  p->ntpv.stream_id = ntv->stream_id;
442 
443  if (unlikely(PacketSetData(p,
444  (uint8_t *) NT_NET_GET_PKT_L2_PTR(packet_buffer),
445  NT_NET_GET_PKT_WIRE_LENGTH(packet_buffer)))) {
446 
447  TmqhOutputPacketpool(ntv->tv, p);
448  NT_NetRxRelease(ntv->rx_stream, packet_buffer);
450  }
451 
452  if (unlikely(TmThreadsSlotProcessPkt(ntv->tv, ntv->slot, p) != TM_ECODE_OK)) {
453  TmqhOutputPacketpool(ntv->tv, p);
454  NT_NetRxRelease(ntv->rx_stream, packet_buffer);
456  }
457 
458  /* Release any packets that were returned by the callback function */
459  Packet *rel_pkt = PacketDequeue(&packets_to_release[ntv->stream_id]);
460  while (rel_pkt != NULL) {
461  NT_NetRxRelease(ntv->rx_stream, rel_pkt->ntpv.nt_packet_buf);
462  rel_pkt = PacketDequeue(&packets_to_release[ntv->stream_id]);
463  }
465  }
466 
467  if (filter_id) {
468  NapatechDeleteFilter(filter_id);
469  }
470 
471  if (hash_id) {
472  NapatechDeleteFilter(hash_id);
473  }
474 
475  if (unlikely(ntv->hba > 0)) {
476  SCLogInfo("Host Buffer Allowance Drops - pkts: %ld, bytes: %ld",
477  hba_pkt_drops, hba_byte_drops);
478  }
479 
481 }
482 
483 /**
484  * \brief Print some stats to the log at program exit.
485  *
486  * \param tv Pointer to ThreadVars.
487  * \param data Pointer to data, ErfFileThreadVars.
488  */
490 {
491  NapatechThreadVars *ntv = (NapatechThreadVars *) data;
493 
494  double percent = 0;
495  if (stat.current_drops > 0)
496  percent = (((double) stat.current_drops)
497  / (stat.current_packets + stat.current_drops)) * 100;
498 
499  SCLogInfo("nt%lu - pkts: %lu; drop: %lu (%5.2f%%); bytes: %lu",
500  (uint64_t) ntv->stream_id, stat.current_packets,
501  stat.current_drops, percent, stat.current_bytes);
502 
503  SC_ATOMIC_ADD(total_packets, stat.current_packets);
504  SC_ATOMIC_ADD(total_drops, stat.current_drops);
505  SC_ATOMIC_ADD(total_tallied, 1);
506 
507  if (SC_ATOMIC_GET(total_tallied) == NapatechGetNumConfiguredStreams()) {
508  if (SC_ATOMIC_GET(total_drops) > 0)
509  percent = (((double) SC_ATOMIC_GET(total_drops)) / (SC_ATOMIC_GET(total_packets)
510  + SC_ATOMIC_GET(total_drops))) * 100;
511 
512  SCLogInfo(" ");
513  SCLogInfo("--- Total Packets: %ld Total Dropped: %ld (%5.2f%%)",
514  SC_ATOMIC_GET(total_packets), SC_ATOMIC_GET(total_drops), percent);
515  }
516 }
517 
518 /**
519  * \brief Deinitializes the NAPATECH card.
520  * \param tv pointer to ThreadVars
521  * \param data pointer that gets cast into PcapThreadVars for ptv
522  */
524 {
525  SCEnter();
526  NapatechThreadVars *ntv = (NapatechThreadVars *) data;
527  SCLogDebug("Closing Napatech Stream: %d", ntv->stream_id);
528  NT_NetRxClose(ntv->rx_stream);
530 }
531 
532 /** Decode Napatech */
533 
534 /**
535  * \brief This function passes off to link type decoders.
536  *
537  * NapatechDecode reads packets from the PacketQueue and passes
538  * them off to the proper link type decoder.
539  *
540  * \param t pointer to ThreadVars
541  * \param p pointer to the current packet
542  * \param data pointer that gets cast into PcapThreadVars for ptv
543  * \param pq pointer to the current PacketQueue
544  */
546  PacketQueue *postpq)
547 {
548  SCEnter();
549 
550  DecodeThreadVars *dtv = (DecodeThreadVars *) data;
551 
552  /* XXX HACK: flow timeout can call us for injected pseudo packets
553  * see bug: https://redmine.openinfosecfoundation.org/issues/1107 */
554  if (p->flags & PKT_PSEUDO_STREAM_END)
555  return TM_ECODE_OK;
556 
557  // update counters
558  DecodeUpdatePacketCounters(tv, dtv, p);
559 
560  switch (p->datalink) {
561  case LINKTYPE_ETHERNET:
562  DecodeEthernet(tv, dtv, p, GET_PKT_DATA(p), GET_PKT_LEN(p), pq);
563  break;
564  default:
566  "Error: datalink type %" PRId32 " not yet supported in module NapatechDecode",
567  p->datalink);
568  break;
569  }
570 
571  PacketDecodeFinalize(tv, dtv, p);
573 }
574 
575 TmEcode NapatechDecodeThreadInit(ThreadVars *tv, const void *initdata, void **data)
576 {
577  SCEnter();
578  DecodeThreadVars *dtv = NULL;
579  dtv = DecodeThreadVarsAlloc(tv);
580  if (dtv == NULL)
582 
584  *data = (void *) dtv;
586 }
587 
589 {
590  if (data != NULL)
591  DecodeThreadVarsFree(tv, data);
593 }
594 
595 #endif /* HAVE_NAPATECH */
#define TM_FLAG_DECODE_TM
Definition: tm-modules.h:32
bool NapatechSetupNuma(uint32_t stream, uint32_t numa)
DecodeThreadVars * DecodeThreadVarsAlloc(ThreadVars *tv)
Alloc and setup DecodeThreadVars.
Definition: decode.c:592
#define SCLogDebug(...)
Definition: util-debug.h:335
uint8_t cap_flags
Definition: tm-modules.h:67
NapatechCurrentStats NapatechGetCurrentStats(uint16_t id)
Definition: util-napatech.c:50
uint8_t flags
Definition: tm-modules.h:70
uint32_t NapatechSetupTraffic(uint32_t first_stream, uint32_t last_stream, uint32_t *filter_id, uint32_t *hash_id)
TmEcode NapatechStreamThreadInit(ThreadVars *, const void *, void **)
Initialize the Napatech receiver thread, generate a single NapatechThreadVar structure for each threa...
void PacketDecodeFinalize(ThreadVars *tv, DecodeThreadVars *dtv, Packet *p)
Finalize decoding of a packet.
Definition: decode.c:114
#define unlikely(expr)
Definition: util-optimize.h:35
uint16_t NapatechGetNumLastStream(void)
TmEcode(* Func)(ThreadVars *, Packet *, void *, PacketQueue *, PacketQueue *)
Definition: tm-modules.h:52
int ConfGetBool(const char *name, int *val)
Retrieve a configuration value as an boolen.
Definition: conf.c:517
void DecodeRegisterPerfCounters(DecodeThreadVars *dtv, ThreadVars *tv)
Definition: decode.c:453
#define SC_ATOMIC_ADD(name, val)
add a value to our atomic variable
Definition: util-atomic.h:107
volatile uint8_t suricata_ctl_flags
Definition: suricata.c:199
#define SC_CAP_NET_ADMIN
Definition: util-privs.h:31
Packet * PacketGetFromQueueOrAlloc(void)
Get a packet. We try to get a packet from the packetpool first, but if that is empty we alloc a packe...
Definition: decode.c:176
void TmModuleNapatechStreamRegister(void)
Register the Napatech receiver (reader) module.
TmEcode(* PktAcqLoop)(ThreadVars *, void *, void *)
Definition: tm-modules.h:54
void(* ReleasePacket)(struct Packet_ *)
Definition: decode.h:482
void PacketFreeOrRelease(Packet *p)
Return a packet to where it was allocated.
Definition: decode.c:161
SCLogLevel
The various log levels NOTE: when adding new level, don&#39;t forget to update SCLogMapLogLevelToSyslogLe...
Definition: util-debug.h:51
void TmModuleNapatechDecodeRegister(void)
Register the Napatech decoder module.
#define TM_FLAG_RECEIVE_TM
Definition: tm-modules.h:31
TmEcode(* PktAcqBreakLoop)(ThreadVars *, void *)
Definition: tm-modules.h:57
uint16_t StatsRegisterCounter(const char *name, struct ThreadVars_ *tv)
Registers a normal, unqualified counter.
Definition: counters.c:939
SC_ATOMIC_DECLARE(uint64_t, total_packets)
#define SC_ATOMIC_INIT(name)
Initialize the previously declared atomic variable and it&#39;s lock.
Definition: util-atomic.h:81
#define SURICATA_STOP
Definition: suricata.h:95
#define SCCalloc(nm, a)
Definition: util-mem.h:197
void StatsSetUI64(ThreadVars *tv, uint16_t id, uint64_t x)
Sets a value of type double to the local counter.
Definition: counters.c:185
void TmqhOutputPacketpool(ThreadVars *t, Packet *p)
NtNetBuf_t nt_packet_buf
Definition: util-napatech.h:33
int max_pending_packets
Definition: suricata.c:213
int datalink
Definition: decode.h:574
TmEcode NapatechStreamThreadDeinit(ThreadVars *tv, void *data)
Deinitializes the NAPATECH card.
int DecodeEthernet(ThreadVars *tv, DecodeThreadVars *dtv, Packet *p, uint8_t *pkt, uint32_t len, PacketQueue *pq)
#define SCLogError(err_code,...)
Macro used to log ERROR messages.
Definition: util-debug.h:294
Structure to hold thread specific data for all decode modules.
Definition: decode.h:632
void(* RegisterTests)(void)
Definition: tm-modules.h:65
TmEcode(* ThreadDeinit)(ThreadVars *, void *)
Definition: tm-modules.h:49
#define SCEnter(...)
Definition: util-debug.h:337
TmEcode NapatechPacketLoopZC(ThreadVars *tv, void *data, void *slot)
struct TmSlot_ * slot_next
Definition: tm-threads.h:87
NtNetStreamRx_t rx_stream
#define MAX_STREAMS
#define PKT_PSEUDO_STREAM_END
Definition: decode.h:1093
bool NapatechIsAutoConfigEnabled(void)
#define NAPATECH_ERROR(err_type, status)
Definition: util-napatech.h:54
#define SCReturnInt(x)
Definition: util-debug.h:341
void(* ThreadExitPrintStats)(ThreadVars *, void *)
Definition: tm-modules.h:48
#define SCLogWarning(err_code,...)
Macro used to log WARNING messages.
Definition: util-debug.h:281
#define SC_CAP_NET_RAW
Definition: util-privs.h:32
TmEcode NapatechDecodeThreadInit(ThreadVars *, const void *, void **)
void PacketPoolWait(void)
void NapatechStreamThreadExitStats(ThreadVars *, void *)
Print some stats to the log at program exit.
struct NapatechThreadVars_ NapatechThreadVars
const char * name
Definition: tm-modules.h:44
#define SCLog(x, file, func, line,...)
Definition: util-debug.h:211
#define SCLogInfo(...)
Macro used to log INFORMATIONAL messages.
Definition: util-debug.h:254
int PacketSetData(Packet *p, uint8_t *pktdata, uint32_t pktlen)
Set data for Packet and set length when zeo copy is used.
Definition: decode.c:638
#define SCFree(a)
Definition: util-mem.h:228
TmModule tmm_modules[TMM_SIZE]
Definition: tm-modules.h:73
#define StatsSyncCountersIfSignalled(tv)
Definition: counters.h:136
TmEcode(* ThreadInit)(ThreadVars *, const void *, void **)
Definition: tm-modules.h:47
int StatsSetupPrivate(ThreadVars *tv)
Definition: counters.c:1201
uint16_t NapatechGetNumFirstStream(void)
#define SC_ATOMIC_GET(name)
Get the value from the atomic variable.
Definition: util-atomic.h:192
#define GET_PKT_DATA(p)
Definition: decode.h:223
void DecodeUpdatePacketCounters(ThreadVars *tv, const DecodeThreadVars *dtv, const Packet *p)
Definition: decode.c:558
Packet * PacketDequeue(PacketQueue *q)
Definition: packet-queue.c:167
char name[16]
Definition: threadvars.h:59
NapatechPacketVars ntpv
Definition: decode.h:605
bool NapatechDeleteFilter(uint32_t filter_id)
TmEcode NapatechDecode(ThreadVars *, Packet *, void *, PacketQueue *, PacketQueue *)
This function passes off to link type decoders.
#define LINKTYPE_ETHERNET
Definition: decode.h:1072
Per thread variable structure.
Definition: threadvars.h:57
struct timeval ts
Definition: decode.h:449
#define GET_PKT_LEN(p)
Definition: decode.h:222
uint16_t NapatechGetNumConfiguredStreams(void)
uint32_t flags
Definition: decode.h:441
void DecodeThreadVarsFree(ThreadVars *tv, DecodeThreadVars *dtv)
Definition: decode.c:618
void PacketEnqueue(PacketQueue *q, Packet *p)
Definition: packet-queue.c:139
TmEcode NapatechDecodeThreadDeinit(ThreadVars *tv, void *data)