suricata
source-erf-dag.c
Go to the documentation of this file.
1 /* Copyright (C) 2010-2020 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 Endace Technology Limited.
22  * \author Jason MacLulich <jason.maclulich@endace.com>
23  *
24  * Support for reading ERF records from a DAG card.
25  *
26  * Only ethernet supported at this time.
27  */
28 
29 #include "suricata-common.h"
30 #include "suricata.h"
31 #include "tm-threads.h"
32 
33 #include "util-privs.h"
34 #include "util-device.h"
35 #include "tmqh-packetpool.h"
36 #include "source-erf-dag.h"
37 
38 #ifndef HAVE_DAG
39 
40 TmEcode NoErfDagSupportExit(ThreadVars *, const void *, void **);
41 
42 void
44 {
45  tmm_modules[TMM_RECEIVEERFDAG].name = "ReceiveErfDag";
46  tmm_modules[TMM_RECEIVEERFDAG].ThreadInit = NoErfDagSupportExit;
53 }
54 
55 void
57 {
58  tmm_modules[TMM_DECODEERFDAG].name = "DecodeErfDag";
59  tmm_modules[TMM_DECODEERFDAG].ThreadInit = NoErfDagSupportExit;
66 }
67 
68 TmEcode
69 NoErfDagSupportExit(ThreadVars *tv, const void *initdata, void **data)
70 {
72  "Error creating thread %s: you do not have support for DAG cards "
73  "enabled please recompile with --enable-dag", tv->name);
74  exit(EXIT_FAILURE);
75 }
76 
77 #else /* Implied we do have DAG support */
78 
79 #include <dagapi.h>
80 
81 /* Minimum amount of data to read from the DAG at a time. */
82 #define MINDATA 32768
83 
84 /* Maximum time (us) to wait for MINDATA to be read. */
85 #define MAXWAIT 20000
86 
87 /* Poll interval in microseconds. */
88 #define POLL_INTERVAL 1000;
89 
90 /* Number of bytes per loop to process before fetching more data. */
91 #define BYTES_PER_LOOP (4 * 1024 * 1024) /* 4 MB */
92 
93 extern int max_pending_packets;
94 
95 typedef struct ErfDagThreadVars_ {
98 
99  int dagfd;
101  char dagname[DAGNAME_BUFSIZE];
102 
103  struct timeval maxwait, poll; /* Could possibly be made static */
104 
106 
107  uint64_t bytes;
108  uint16_t packets;
109  uint16_t drops;
110 
111  /* Current location in the DAG stream input buffer.
112  */
113  uint8_t *top;
114  uint8_t *btm;
115 
117 
118 static inline TmEcode ProcessErfDagRecords(ErfDagThreadVars *ewtn, uint8_t *top,
119  uint32_t *pkts_read);
120 static inline TmEcode ProcessErfDagRecord(ErfDagThreadVars *ewtn, char *prec);
121 TmEcode ReceiveErfDagLoop(ThreadVars *, void *data, void *slot);
122 TmEcode ReceiveErfDagThreadInit(ThreadVars *, void *, void **);
125 TmEcode DecodeErfDagThreadInit(ThreadVars *, void *, void **);
127 TmEcode DecodeErfDag(ThreadVars *, Packet *, void *);
128 void ReceiveErfDagCloseStream(int dagfd, int stream);
129 
130 /**
131  * \brief Register the ERF file receiver (reader) module.
132  */
133 void
135 {
136  tmm_modules[TMM_RECEIVEERFDAG].name = "ReceiveErfDag";
147 }
148 
149 /**
150  * \brief Register the ERF file decoder module.
151  */
152 void
154 {
155  tmm_modules[TMM_DECODEERFDAG].name = "DecodeErfDag";
163 }
164 
165 /**
166  * \brief Initialize the ERF receiver thread, generate a single
167  * ErfDagThreadVar structure for each thread, this will
168  * contain a DAG file descriptor which is read when the
169  * thread executes.
170  *
171  * \param tv Thread variable to ThreadVars
172  * \param initdata Initial data to the interface passed from the user,
173  * this is processed by the user.
174  *
175  * We assume that we have only a single name for the DAG
176  * interface.
177  *
178  * \param data data pointer gets populated with
179  *
180  */
181 TmEcode
182 ReceiveErfDagThreadInit(ThreadVars *tv, void *initdata, void **data)
183 {
184  SCEnter();
185  int stream_count = 0;
186 
187  if (initdata == NULL) {
189  "Error: No DAG interface provided.");
191  }
192 
193  ErfDagThreadVars *ewtn = SCMalloc(sizeof(ErfDagThreadVars));
194  if (unlikely(ewtn == NULL)) {
196  "Failed to allocate memory for ERF DAG thread vars.");
197  }
198 
199  memset(ewtn, 0, sizeof(*ewtn));
200 
201  /* dag_parse_name will return a DAG device name and stream number
202  * to open for this thread.
203  */
204  if (dag_parse_name(initdata, ewtn->dagname, DAGNAME_BUFSIZE,
205  &ewtn->dagstream) < 0) {
207  "Failed to parse DAG interface: %s",
208  (char*)initdata);
209  SCFree(ewtn);
210  exit(EXIT_FAILURE);
211  }
212 
213  ewtn->livedev = LiveGetDevice(initdata);
214  if (ewtn->livedev == NULL) {
215  SCLogError(SC_ERR_INVALID_VALUE, "Unable to get %s live device",
216  (char *)initdata);
217  SCFree(ewtn);
219  }
220 
221  SCLogInfo("Opening DAG: %s on stream: %d for processing",
222  ewtn->dagname, ewtn->dagstream);
223 
224  if ((ewtn->dagfd = dag_open(ewtn->dagname)) < 0) {
225  SCLogError(SC_ERR_ERF_DAG_OPEN_FAILED, "Failed to open DAG: %s",
226  ewtn->dagname);
227  SCFree(ewtn);
229  }
230 
231  /* Check to make sure the card has enough available streams to
232  * support reading from the one specified.
233  */
234  if ((stream_count = dag_rx_get_stream_count(ewtn->dagfd)) < 0) {
236  "Failed to open stream: %d, DAG: %s, could not query stream count",
237  ewtn->dagstream, ewtn->dagname);
238  SCFree(ewtn);
240  }
241 
242  /* Check to make sure we have enough rx streams to open the stream
243  * the user is asking for.
244  */
245  if (ewtn->dagstream > stream_count * 2) {
247  "Failed to open stream: %d, DAG: %s, insufficient streams: %d",
248  ewtn->dagstream, ewtn->dagname, stream_count);
249  SCFree(ewtn);
251  }
252 
253  /* If we are transmitting into a soft DAG card then set the stream
254  * to act in reverse mode.
255  */
256  if (0 != (ewtn->dagstream & 0x01)) {
257  /* Setting reverse mode for using with soft dag from daemon side */
258  if (dag_set_mode(ewtn->dagfd, ewtn->dagstream, DAG_REVERSE_MODE)) {
260  "Failed to set mode to DAG_REVERSE_MODE on stream: %d, DAG: %s",
261  ewtn->dagstream, ewtn->dagname);
262  SCFree(ewtn);
264  }
265  }
266 
267  if (dag_attach_stream(ewtn->dagfd, ewtn->dagstream, 0, 0) < 0) {
269  "Failed to open DAG stream: %d, DAG: %s",
270  ewtn->dagstream, ewtn->dagname);
271  SCFree(ewtn);
273  }
274 
275  if (dag_start_stream(ewtn->dagfd, ewtn->dagstream) < 0) {
277  "Failed to start DAG stream: %d, DAG: %s",
278  ewtn->dagstream, ewtn->dagname);
279  SCFree(ewtn);
281  }
282 
283  SCLogInfo("Attached and started stream: %d on DAG: %s",
284  ewtn->dagstream, ewtn->dagname);
285 
286  /*
287  * Initialise DAG Polling parameters.
288  */
289  timerclear(&ewtn->maxwait);
290  ewtn->maxwait.tv_usec = MAXWAIT;
291  timerclear(&ewtn->poll);
292  ewtn->poll.tv_usec = POLL_INTERVAL;
293 
294  /* 32kB minimum data to return -- we still restrict the number of
295  * pkts that are processed to a maximum of dag_max_read_packets.
296  */
297  if (dag_set_stream_poll(ewtn->dagfd, ewtn->dagstream, MINDATA,
298  &(ewtn->maxwait), &(ewtn->poll)) < 0) {
300  "Failed to set poll parameters for stream: %d, DAG: %s",
301  ewtn->dagstream, ewtn->dagname);
302  SCFree(ewtn);
304  }
305 
306  ewtn->packets = StatsRegisterCounter("capture.dag_packets", tv);
307  ewtn->drops = StatsRegisterCounter("capture.dag_drops", tv);
308 
309  ewtn->tv = tv;
310  *data = (void *)ewtn;
311 
312  SCLogInfo("Starting processing packets from stream: %d on DAG: %s",
313  ewtn->dagstream, ewtn->dagname);
314 
316 }
317 
318 /**
319  * \brief Receives packets from a DAG interface.
320  *
321  * \param tv pointer to ThreadVars
322  * \param data pointer to ErfDagThreadVars
323  * \param slot slot containing task information
324  *
325  * \retval TM_ECODE_OK on success
326  * \retval TM_ECODE_FAILED on failure
327  */
328 TmEcode
329 ReceiveErfDagLoop(ThreadVars *tv, void *data, void *slot)
330 {
331  SCEnter();
332 
334  uint32_t diff = 0;
335  int err;
336  uint8_t *top = NULL;
337  uint32_t pkts_read = 0;
338  TmSlot *s = (TmSlot *)slot;
339 
340  dtv->slot = s->slot_next;
341 
342  while (1) {
345  }
346 
347  top = dag_advance_stream(dtv->dagfd, dtv->dagstream, &(dtv->btm));
348  if (top == NULL) {
349  if (errno == EAGAIN) {
350  if (dtv->dagstream & 0x1) {
351  TmThreadsCaptureHandleTimeout(tv, NULL);
352  usleep(10 * 1000);
353  dtv->btm = dtv->top;
354  }
355  continue;
356  } else {
358  "Failed to read from stream: %d, DAG: %s when "
359  "using dag_advance_stream",
360  dtv->dagstream, dtv->dagname);
362  }
363  }
364 
365  diff = top - dtv->btm;
366  if (diff == 0) {
367  continue;
368  }
369 
370  assert(diff >= dag_record_size);
371 
372  err = ProcessErfDagRecords(dtv, top, &pkts_read);
373 
374  if (err == TM_ECODE_FAILED) {
376  "Failed to read from stream: %d, DAG: %s",
377  dtv->dagstream, dtv->dagname);
378  ReceiveErfDagCloseStream(dtv->dagfd, dtv->dagstream);
380  }
381 
383 
384  SCLogDebug("Read %d records from stream: %d, DAG: %s",
385  pkts_read, dtv->dagstream, dtv->dagname);
386  }
387 
389 }
390 
391 /**
392  * \brief Process a chunk of records read from a DAG interface.
393  *
394  * This function takes a pointer to buffer read from the DAG interface
395  * and processes it individual records.
396  */
397 static inline TmEcode
398 ProcessErfDagRecords(ErfDagThreadVars *ewtn, uint8_t *top, uint32_t *pkts_read)
399 {
400  SCEnter();
401 
402  int err = 0;
403  dag_record_t *dr = NULL;
404  char *prec = NULL;
405  int rlen;
406  char hdr_type = 0;
407  int processed = 0;
408 
409  *pkts_read = 0;
410 
411  while (((top - ewtn->btm) >= dag_record_size) &&
412  ((processed + dag_record_size) < BYTES_PER_LOOP)) {
413 
414  /* Make sure we have at least one packet in the packet pool,
415  * to prevent us from alloc'ing packets at line rate. */
416  PacketPoolWait();
417 
418  prec = (char *)ewtn->btm;
419  dr = (dag_record_t*)prec;
420  rlen = SCNtohs(dr->rlen);
421  hdr_type = dr->type;
422 
423  /* If we don't have enough data to finish processing this ERF
424  * record return and maybe next time we will.
425  */
426  if ((top - ewtn->btm) < rlen)
428 
429  ewtn->btm += rlen;
430  processed += rlen;
431 
432  /* Only support ethernet at this time. */
433  switch (hdr_type & 0x7f) {
434  case ERF_TYPE_PAD:
435  case ERF_TYPE_META:
436  /* Skip. */
437  continue;
438  case ERF_TYPE_DSM_COLOR_ETH:
439  case ERF_TYPE_COLOR_ETH:
440  case ERF_TYPE_COLOR_HASH_ETH:
441  /* In these types the color value overwrites the lctr
442  * (drop count). */
443  break;
444  case ERF_TYPE_ETH:
445  if (dr->lctr) {
446  StatsAddUI64(ewtn->tv, ewtn->drops, SCNtohs(dr->lctr));
447  }
448  break;
449  default:
451  "Processing of DAG record type: %d not implemented.", dr->type);
453  }
454 
455  err = ProcessErfDagRecord(ewtn, prec);
456  if (err != TM_ECODE_OK) {
458  }
459 
460  (*pkts_read)++;
461  }
462 
464 }
465 
466 /**
467  * \brief Process a DAG record into a TM packet buffer.
468  * \param prec pointer to a DAG record.
469  * \param
470  */
471 static inline TmEcode
472 ProcessErfDagRecord(ErfDagThreadVars *ewtn, char *prec)
473 {
474  SCEnter();
475 
476  int wlen = 0;
477  int rlen = 0;
478  int hdr_num = 0;
479  char hdr_type = 0;
480  dag_record_t *dr = (dag_record_t*)prec;
481  erf_payload_t *pload;
482  Packet *p;
483 
484  hdr_type = dr->type;
485  wlen = SCNtohs(dr->wlen);
486  rlen = SCNtohs(dr->rlen);
487 
488  /* count extension headers */
489  while (hdr_type & 0x80) {
490  if (rlen < (dag_record_size + (hdr_num * 8))) {
492  "Insufficient captured packet length.");
494  }
495  hdr_type = prec[(dag_record_size + (hdr_num * 8))];
496  hdr_num++;
497  }
498 
499  /* Check that the whole frame was captured */
500  if (rlen < (dag_record_size + (8 * hdr_num) + 2 + wlen)) {
501  SCLogInfo("Incomplete frame captured.");
503  }
504 
505  /* skip over extension headers */
506  pload = (erf_payload_t *)(prec + dag_record_size + (8 * hdr_num));
507 
509  if (p == NULL) {
511  "Failed to allocate a Packet on stream: %d, DAG: %s",
512  ewtn->dagstream, ewtn->dagname);
514  }
516 
517  SET_PKT_LEN(p, wlen);
519 
520  /* Take into account for link type Ethernet ETH frame starts
521  * after ther ERF header + pad.
522  */
523  if (unlikely(PacketCopyData(p, pload->eth.dst, GET_PKT_LEN(p)))) {
524  TmqhOutputPacketpool(ewtn->tv, p);
526  }
527 
528  /* Convert ERF time to timeval - from libpcap. */
529  uint64_t ts = dr->ts;
530  p->ts.tv_sec = ts >> 32;
531  ts = (ts & 0xffffffffULL) * 1000000;
532  ts += 0x80000000; /* rounding */
533  p->ts.tv_usec = ts >> 32;
534  if (p->ts.tv_usec >= 1000000) {
535  p->ts.tv_usec -= 1000000;
536  p->ts.tv_sec++;
537  }
538 
539  StatsIncr(ewtn->tv, ewtn->packets);
540  ewtn->bytes += wlen;
541 
542  if (TmThreadsSlotProcessPkt(ewtn->tv, ewtn->slot, p) != TM_ECODE_OK) {
544  }
545 
547 }
548 
549 /**
550  * \brief Print some stats to the log at program exit.
551  *
552  * \param tv Pointer to ThreadVars.
553  * \param data Pointer to data, ErfFileThreadVars.
554  */
555 void
557 {
558  ErfDagThreadVars *ewtn = (ErfDagThreadVars *)data;
559 
560  (void)SC_ATOMIC_SET(ewtn->livedev->pkts,
562  (void)SC_ATOMIC_SET(ewtn->livedev->drop,
564 
565  SCLogInfo("Stream: %d; Bytes: %"PRIu64"; Packets: %"PRIu64
566  "; Drops: %"PRIu64,
567  ewtn->dagstream,
568  ewtn->bytes,
571 }
572 
573 /**
574  * \brief Deinitializes the DAG card.
575  * \param tv pointer to ThreadVars
576  * \param data pointer that gets cast into PcapThreadVars for ptv
577  */
578 TmEcode
580 {
581  SCEnter();
582 
583  ErfDagThreadVars *ewtn = (ErfDagThreadVars *)data;
584 
586 
588 }
589 
590 void
591 ReceiveErfDagCloseStream(int dagfd, int stream)
592 {
593  dag_stop_stream(dagfd, stream);
594  dag_detach_stream(dagfd, stream);
595  dag_close(dagfd);
596 }
597 
598 /** Decode ErfDag */
599 
600 /**
601  * \brief This function passes off to link type decoders.
602  *
603  * DecodeErfDag decodes packets from DAG and passes
604  * them off to the proper link type decoder.
605  *
606  * \param t pointer to ThreadVars
607  * \param p pointer to the current packet
608  * \param data pointer that gets cast into PcapThreadVars for ptv
609  */
610 TmEcode
611 DecodeErfDag(ThreadVars *tv, Packet *p, void *data)
612 {
613  SCEnter();
615 
617 
618  /* update counters */
620 
621  /* call the decoder */
622  switch(p->datalink) {
623  case LINKTYPE_ETHERNET:
625  break;
626  default:
628  "Error: datalink type %" PRId32
629  " not yet supported in module DecodeErfDag",
630  p->datalink);
631  break;
632  }
633 
635 
637 }
638 
639 TmEcode
640 DecodeErfDagThreadInit(ThreadVars *tv, void *initdata, void **data)
641 {
642  SCEnter();
643  DecodeThreadVars *dtv = NULL;
644 
646 
647  if (dtv == NULL)
649 
651 
652  *data = (void *)dtv;
653 
655 }
656 
657 TmEcode
659 {
660  if (data != NULL)
661  DecodeThreadVarsFree(tv, data);
663 }
664 
665 #endif /* HAVE_DAG */
TmModule_::cap_flags
uint8_t cap_flags
Definition: tm-modules.h:67
tm-threads.h
ts
uint64_t ts
Definition: source-erf-file.c:54
BYTES_PER_LOOP
#define BYTES_PER_LOOP
Definition: source-erf-dag.c:91
max_pending_packets
int max_pending_packets
Definition: suricata.c:211
StatsIncr
void StatsIncr(ThreadVars *tv, uint16_t id)
Increments the local counter.
Definition: counters.c:169
TMM_RECEIVEERFDAG
@ TMM_RECEIVEERFDAG
Definition: tm-threads-common.h:50
ThreadVars_::name
char name[16]
Definition: threadvars.h:65
SC_ERR_INVALID_VALUE
@ SC_ERR_INVALID_VALUE
Definition: util-error.h:160
PacketCopyData
int PacketCopyData(Packet *p, const uint8_t *pktdata, uint32_t pktlen)
Copy data to Packet payload and set packet length.
Definition: decode.c:262
PKT_IS_PSEUDOPKT
#define PKT_IS_PSEUDOPKT(p)
return 1 if the packet is a pseudo packet
Definition: decode.h:1125
unlikely
#define unlikely(expr)
Definition: util-optimize.h:35
SC_ATOMIC_SET
#define SC_ATOMIC_SET(name, val)
Set the value for the atomic variable.
Definition: util-atomic.h:355
SCLogDebug
#define SCLogDebug(...)
Definition: util-debug.h:298
SC_ERR_ERF_DAG_STREAM_START_FAILED
@ SC_ERR_ERF_DAG_STREAM_START_FAILED
Definition: util-error.h:197
DecodeErfDagThreadInit
TmEcode DecodeErfDagThreadInit(ThreadVars *, void *, void **)
Definition: source-erf-dag.c:640
ErfDagThreadVars_::btm
uint8_t * btm
Definition: source-erf-dag.c:114
LiveDevice_
Definition: util-device.h:40
SURICATA_STOP
#define SURICATA_STOP
Definition: suricata.h:90
ErfDagThreadVars_::bytes
uint64_t bytes
Definition: source-erf-dag.c:107
util-privs.h
StatsSyncCountersIfSignalled
#define StatsSyncCountersIfSignalled(tv)
Definition: counters.h:137
ErfDagThreadVars_::top
uint8_t * top
Definition: source-erf-dag.c:113
PacketDecodeFinalize
void PacketDecodeFinalize(ThreadVars *tv, DecodeThreadVars *dtv, Packet *p)
Finalize decoding of a packet.
Definition: decode.c:118
TmqhOutputPacketpool
void TmqhOutputPacketpool(ThreadVars *t, Packet *p)
Definition: tmqh-packetpool.c:375
TM_ECODE_FAILED
@ TM_ECODE_FAILED
Definition: tm-threads-common.h:79
tmqh-packetpool.h
TmModule_::PktAcqLoop
TmEcode(* PktAcqLoop)(ThreadVars *, void *, void *)
Definition: tm-modules.h:54
TM_ECODE_OK
@ TM_ECODE_OK
Definition: tm-threads-common.h:78
MINDATA
#define MINDATA
Definition: source-erf-dag.c:82
ErfDagThreadVars_::dagname
char dagname[DAGNAME_BUFSIZE]
Definition: source-erf-dag.c:101
TmModule_::ThreadDeinit
TmEcode(* ThreadDeinit)(ThreadVars *, void *)
Definition: tm-modules.h:49
Packet_::datalink
int datalink
Definition: decode.h:577
source-erf-dag.h
PKT_SET_SRC
#define PKT_SET_SRC(p, src_val)
Definition: decode.h:1128
DecodeRegisterPerfCounters
void DecodeRegisterPerfCounters(DecodeThreadVars *dtv, ThreadVars *tv)
Definition: decode.c:478
SC_ERR_ERF_DAG_OPEN_FAILED
@ SC_ERR_ERF_DAG_OPEN_FAILED
Definition: util-error.h:195
SET_PKT_LEN
#define SET_PKT_LEN(p, len)
Definition: decode.h:232
util-device.h
PKT_SRC_WIRE
@ PKT_SRC_WIRE
Definition: decode.h:50
TmModule_::PktAcqBreakLoop
TmEcode(* PktAcqBreakLoop)(ThreadVars *, void *)
Definition: tm-modules.h:57
LiveGetDevice
LiveDevice * LiveGetDevice(const char *name)
Get a pointer to the device at idx.
Definition: util-device.c:278
MAXWAIT
#define MAXWAIT
Definition: source-erf-dag.c:85
SCEnter
#define SCEnter(...)
Definition: util-debug.h:300
GET_PKT_DATA
#define GET_PKT_DATA(p)
Definition: decode.h:228
ThreadVars_
Per thread variable structure.
Definition: threadvars.h:58
TmModule_::Func
TmEcode(* Func)(ThreadVars *, Packet *, void *)
Definition: tm-modules.h:52
ErfDagThreadVars_::livedev
LiveDevice * livedev
Definition: source-erf-dag.c:105
ReceiveErfDagThreadExitStats
void ReceiveErfDagThreadExitStats(ThreadVars *, void *)
Print some stats to the log at program exit.
Definition: source-erf-dag.c:556
ReceiveErfDagCloseStream
void ReceiveErfDagCloseStream(int dagfd, int stream)
Definition: source-erf-dag.c:591
ErfDagThreadVars_::packets
uint16_t packets
Definition: source-erf-dag.c:108
SC_CAP_NET_ADMIN
#define SC_CAP_NET_ADMIN
Definition: util-privs.h:31
SC_ERR_INVALID_ARGUMENT
@ SC_ERR_INVALID_ARGUMENT
Definition: util-error.h:43
ErfDagThreadVars_::dagfd
int dagfd
Definition: source-erf-dag.c:99
BUG_ON
#define BUG_ON(x)
Definition: suricata-common.h:282
StatsGetLocalCounterValue
uint64_t StatsGetLocalCounterValue(ThreadVars *tv, uint16_t id)
Get the value of the local copy of the counter that hold this id.
Definition: counters.c:1240
PacketPoolWait
void PacketPoolWait(void)
Definition: tmqh-packetpool.c:84
TMM_DECODEERFDAG
@ TMM_DECODEERFDAG
Definition: tm-threads-common.h:51
SC_ERR_DAG_NOSUPPORT
@ SC_ERR_DAG_NOSUPPORT
Definition: util-error.h:202
Packet_
Definition: decode.h:411
TM_FLAG_DECODE_TM
#define TM_FLAG_DECODE_TM
Definition: tm-modules.h:32
tmm_modules
TmModule tmm_modules[TMM_SIZE]
Definition: tm-modules.c:33
wlen
uint16_t wlen
Definition: source-erf-file.c:59
GET_PKT_LEN
#define GET_PKT_LEN(p)
Definition: decode.h:227
TmModule_::RegisterTests
void(* RegisterTests)(void)
Definition: tm-modules.h:65
TmSlot_
Definition: tm-threads.h:52
DecodeErfDag
TmEcode DecodeErfDag(ThreadVars *, Packet *, void *)
This function passes off to link type decoders.
Definition: source-erf-dag.c:611
TmEcode
TmEcode
Definition: tm-threads-common.h:77
TmModuleDecodeErfDagRegister
void TmModuleDecodeErfDagRegister(void)
Register the ERF file decoder module.
Definition: source-erf-dag.c:153
TmModule_::name
const char * name
Definition: tm-modules.h:44
SCLogInfo
#define SCLogInfo(...)
Macro used to log INFORMATIONAL messages.
Definition: util-debug.h:217
TM_FLAG_RECEIVE_TM
#define TM_FLAG_RECEIVE_TM
Definition: tm-modules.h:31
dtv
DecodeThreadVars * dtv
Definition: fuzz_decodepcapfile.c:30
POLL_INTERVAL
#define POLL_INTERVAL
Definition: source-erf-dag.c:88
ReceiveErfDagThreadInit
TmEcode ReceiveErfDagThreadInit(ThreadVars *, void *, void **)
Initialize the ERF receiver thread, generate a single ErfDagThreadVar structure for each thread,...
Definition: source-erf-dag.c:182
ErfDagThreadVars_::poll
struct timeval maxwait poll
Definition: source-erf-dag.c:103
DecodeThreadVarsFree
void DecodeThreadVarsFree(ThreadVars *tv, DecodeThreadVars *dtv)
Definition: decode.c:638
Packet_::ts
struct timeval ts
Definition: decode.h:454
SCNtohs
#define SCNtohs(x)
Definition: suricata-common.h:398
suricata-common.h
ErfDagThreadVars_::tv
ThreadVars * tv
Definition: source-erf-dag.c:96
SCLogError
#define SCLogError(err_code,...)
Macro used to log ERROR messages.
Definition: util-debug.h:257
TmModule_::ThreadInit
TmEcode(* ThreadInit)(ThreadVars *, const void *, void **)
Definition: tm-modules.h:47
FatalError
#define FatalError(x,...)
Definition: util-debug.h:532
ErfDagThreadVars_::dagstream
int dagstream
Definition: source-erf-dag.c:100
tv
ThreadVars * tv
Definition: fuzz_decodepcapfile.c:29
SC_ERR_UNIMPLEMENTED
@ SC_ERR_UNIMPLEMENTED
Definition: util-error.h:118
TmModuleReceiveErfDagRegister
void TmModuleReceiveErfDagRegister(void)
Register the ERF file receiver (reader) module.
Definition: source-erf-dag.c:134
TmModule_::ThreadExitPrintStats
void(* ThreadExitPrintStats)(ThreadVars *, void *)
Definition: tm-modules.h:48
StatsAddUI64
void StatsAddUI64(ThreadVars *tv, uint16_t id, uint64_t x)
Adds a value of type uint64_t to the local counter.
Definition: counters.c:148
SCMalloc
#define SCMalloc(sz)
Definition: util-mem.h:47
ErfDagThreadVars_::drops
uint16_t drops
Definition: source-erf-dag.c:109
ErfDagThreadVars_::slot
TmSlot * slot
Definition: source-erf-dag.c:97
SCFree
#define SCFree(p)
Definition: util-mem.h:61
SC_ERR_ERF_DAG_STREAM_OPEN_FAILED
@ SC_ERR_ERF_DAG_STREAM_OPEN_FAILED
Definition: util-error.h:196
DecodeThreadVars_
Structure to hold thread specific data for all decode modules.
Definition: decode.h:625
SC_ERR_FATAL
@ SC_ERR_FATAL
Definition: util-error.h:203
DecodeThreadVarsAlloc
DecodeThreadVars * DecodeThreadVarsAlloc(ThreadVars *tv)
Alloc and setup DecodeThreadVars.
Definition: decode.c:619
SC_ERR_ERF_DAG_STREAM_READ_FAILED
@ SC_ERR_ERF_DAG_STREAM_READ_FAILED
Definition: util-error.h:199
SC_ERR_DATALINK_UNIMPLEMENTED
@ SC_ERR_DATALINK_UNIMPLEMENTED
Definition: util-error.h:68
ReceiveErfDagThreadDeinit
TmEcode ReceiveErfDagThreadDeinit(ThreadVars *, void *)
Deinitializes the DAG card.
Definition: source-erf-dag.c:579
DecodeErfDagThreadDeinit
TmEcode DecodeErfDagThreadDeinit(ThreadVars *tv, void *data)
Definition: source-erf-dag.c:658
ReceiveErfDagLoop
TmEcode ReceiveErfDagLoop(ThreadVars *, void *data, void *slot)
Receives packets from a DAG interface.
Definition: source-erf-dag.c:329
SC_ERR_MEM_ALLOC
@ SC_ERR_MEM_ALLOC
Definition: util-error.h:31
suricata.h
TmSlot_::slot_next
struct TmSlot_ * slot_next
Definition: tm-threads.h:61
StatsRegisterCounter
uint16_t StatsRegisterCounter(const char *name, struct ThreadVars_ *tv)
Registers a normal, unqualified counter.
Definition: counters.c:939
SCReturnInt
#define SCReturnInt(x)
Definition: util-debug.h:304
Packet_::type
uint8_t type
Definition: decode.h:421
SC_ERR_ERF_DAG_STREAM_SET_FAILED
@ SC_ERR_ERF_DAG_STREAM_SET_FAILED
Definition: util-error.h:198
ErfDagThreadVars
struct ErfDagThreadVars_ ErfDagThreadVars
PacketGetFromQueueOrAlloc
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:180
DecodeEthernet
int DecodeEthernet(ThreadVars *tv, DecodeThreadVars *dtv, Packet *p, const uint8_t *pkt, uint32_t len)
Definition: decode-ethernet.c:41
TmModule_::flags
uint8_t flags
Definition: tm-modules.h:70
DecodeUpdatePacketCounters
void DecodeUpdatePacketCounters(ThreadVars *tv, const DecodeThreadVars *dtv, const Packet *p)
Definition: decode.c:585
LINKTYPE_ETHERNET
#define LINKTYPE_ETHERNET
Definition: decode.h:1066
suricata_ctl_flags
volatile uint8_t suricata_ctl_flags
Definition: suricata.c:197
ErfDagThreadVars_
Definition: source-erf-dag.c:95
rlen
uint16_t rlen
Definition: source-erf-file.c:57