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