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-private.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 {
70  SCLogError("Error creating thread %s: you do not have support for DAG cards "
71  "enabled please recompile with --enable-dag",
72  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 #define ERF_EXT_LEN 8
93 #define ERF_ETH_PAD_LEN 2
94 
95 extern uint32_t max_pending_packets;
96 
97 typedef struct ErfDagThreadVars_ {
100 
101  int dagfd;
103  char dagname[DAGNAME_BUFSIZE];
104 
105  struct timeval maxwait, poll; /* Could possibly be made static */
106 
108 
109  uint64_t bytes;
112 
113  /* Current location in the DAG stream input buffer.
114  */
115  uint8_t *top;
116  uint8_t *btm;
117 
119 
120 static inline TmEcode ProcessErfDagRecords(ErfDagThreadVars *ewtn, uint8_t *top,
121  uint32_t *pkts_read);
122 static inline TmEcode ProcessErfDagRecord(ErfDagThreadVars *ewtn, char *prec);
123 TmEcode ReceiveErfDagLoop(ThreadVars *, void *data, void *slot);
124 TmEcode ReceiveErfDagThreadInit(ThreadVars *, const void *, void **);
127 TmEcode DecodeErfDagThreadInit(ThreadVars *, const void *, void **);
129 TmEcode DecodeErfDag(ThreadVars *, Packet *, void *);
130 void ReceiveErfDagCloseStream(int dagfd, int stream);
131 
132 /**
133  * \brief Register the ERF file receiver (reader) module.
134  */
135 void
137 {
138  tmm_modules[TMM_RECEIVEERFDAG].name = "ReceiveErfDag";
148 }
149 
150 /**
151  * \brief Register the ERF file decoder module.
152  */
153 void
155 {
156  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 ReceiveErfDagThreadInit(ThreadVars *tv, const void *initdata, void **data)
182 {
183  SCEnter();
184  int stream_count = 0;
185 
186  if (initdata == NULL) {
187  SCLogError("Error: No DAG interface provided.");
189  }
190 
191  ErfDagThreadVars *ewtn = SCCalloc(1, sizeof(ErfDagThreadVars));
192  if (unlikely(ewtn == NULL)) {
193  FatalError("Failed to allocate memory for ERF DAG thread vars.");
194  }
195 
196  /* dag_parse_name will return a DAG device name and stream number
197  * to open for this thread.
198  */
199  if (dag_parse_name(initdata, ewtn->dagname, DAGNAME_BUFSIZE,
200  &ewtn->dagstream) < 0) {
201  SCLogError("Failed to parse DAG interface: %s", (const char *)initdata);
202  SCFree(ewtn);
203  exit(EXIT_FAILURE);
204  }
205 
206  ewtn->livedev = LiveGetDevice(initdata);
207  if (ewtn->livedev == NULL) {
208  SCLogError("Unable to get %s live device", (const char *)initdata);
209  SCFree(ewtn);
211  }
212 
213  SCLogInfo("Opening DAG: %s on stream: %d for processing",
214  ewtn->dagname, ewtn->dagstream);
215 
216  if ((ewtn->dagfd = dag_open(ewtn->dagname)) < 0) {
217  SCLogError("Failed to open DAG: %s", ewtn->dagname);
218  SCFree(ewtn);
220  }
221 
222  /* Check to make sure the card has enough available streams to
223  * support reading from the one specified.
224  */
225  if ((stream_count = dag_rx_get_stream_count(ewtn->dagfd)) < 0) {
226  SCLogError("Failed to open stream: %d, DAG: %s, could not query stream count",
227  ewtn->dagstream, ewtn->dagname);
228  SCFree(ewtn);
230  }
231 
232  /* Check to make sure we have enough rx streams to open the stream
233  * the user is asking for.
234  */
235  if (ewtn->dagstream > stream_count * 2) {
236  SCLogError("Failed to open stream: %d, DAG: %s, insufficient streams: %d", ewtn->dagstream,
237  ewtn->dagname, stream_count);
238  SCFree(ewtn);
240  }
241 
242  /* If we are transmitting into a soft DAG card then set the stream
243  * to act in reverse mode.
244  */
245  if (0 != (ewtn->dagstream & 0x01)) {
246  /* Setting reverse mode for using with soft dag from daemon side */
247  if (dag_set_mode(ewtn->dagfd, ewtn->dagstream, DAG_REVERSE_MODE)) {
248  SCLogError("Failed to set mode to DAG_REVERSE_MODE on stream: %d, DAG: %s",
249  ewtn->dagstream, ewtn->dagname);
250  SCFree(ewtn);
252  }
253  }
254 
255  if (dag_attach_stream(ewtn->dagfd, ewtn->dagstream, 0, 0) < 0) {
256  SCLogError("Failed to open DAG stream: %d, DAG: %s", ewtn->dagstream, ewtn->dagname);
257  SCFree(ewtn);
259  }
260 
261  if (dag_start_stream(ewtn->dagfd, ewtn->dagstream) < 0) {
262  SCLogError("Failed to start DAG stream: %d, DAG: %s", ewtn->dagstream, ewtn->dagname);
263  SCFree(ewtn);
265  }
266 
267  SCLogInfo("Attached and started stream: %d on DAG: %s",
268  ewtn->dagstream, ewtn->dagname);
269 
270  /*
271  * Initialise DAG Polling parameters.
272  */
273  timerclear(&ewtn->maxwait);
274  ewtn->maxwait.tv_usec = MAXWAIT;
275  timerclear(&ewtn->poll);
276  ewtn->poll.tv_usec = POLL_INTERVAL;
277 
278  /* 32kB minimum data to return -- we still restrict the number of
279  * pkts that are processed to a maximum of dag_max_read_packets.
280  */
281  if (dag_set_stream_poll(ewtn->dagfd, ewtn->dagstream, MINDATA,
282  &(ewtn->maxwait), &(ewtn->poll)) < 0) {
283  SCLogError("Failed to set poll parameters for stream: %d, DAG: %s", ewtn->dagstream,
284  ewtn->dagname);
285  SCFree(ewtn);
287  }
288 
289  ewtn->packets = StatsRegisterCounter("capture.dag_packets", &tv->stats);
290  ewtn->drops = StatsRegisterCounter("capture.dag_drops", &tv->stats);
291 
292  ewtn->tv = tv;
293  *data = (void *)ewtn;
294 
296 
297  SCLogInfo("Starting processing packets from stream: %d on DAG: %s",
298  ewtn->dagstream, ewtn->dagname);
299 
301 }
302 
303 /**
304  * \brief Receives packets from a DAG interface.
305  *
306  * \param tv pointer to ThreadVars
307  * \param data pointer to ErfDagThreadVars
308  * \param slot slot containing task information
309  *
310  * \retval TM_ECODE_OK on success
311  * \retval TM_ECODE_FAILED on failure
312  */
313 TmEcode
314 ReceiveErfDagLoop(ThreadVars *tv, void *data, void *slot)
315 {
316  SCEnter();
317 
319  uint32_t diff = 0;
320  int err;
321  uint8_t *top = NULL;
322  uint32_t pkts_read = 0;
323  TmSlot *s = (TmSlot *)slot;
324 
325  dtv->slot = s->slot_next;
326 
327  // Indicate that the thread is actually running its application level code (i.e., it can poll
328  // packets)
330 
331  while (1) {
334  }
335 
336  top = dag_advance_stream(dtv->dagfd, dtv->dagstream, &(dtv->btm));
337  if (top == NULL) {
338  if (errno == EAGAIN) {
339  if (dtv->dagstream & 0x1) {
340  TmThreadsCaptureHandleTimeout(tv, NULL);
341  usleep(10 * 1000);
342  dtv->btm = dtv->top;
343  }
344  continue;
345  } else {
346  SCLogError("Failed to read from stream: %d, DAG: %s when "
347  "using dag_advance_stream",
348  dtv->dagstream, dtv->dagname);
350  }
351  }
352 
353  diff = top - dtv->btm;
354  if (diff == 0) {
355  continue;
356  }
357 
358  assert(diff >= dag_record_size);
359 
360  err = ProcessErfDagRecords(dtv, top, &pkts_read);
361 
362  if (err == TM_ECODE_FAILED) {
363  SCLogError("Failed to read from stream: %d, DAG: %s", dtv->dagstream, dtv->dagname);
364  ReceiveErfDagCloseStream(dtv->dagfd, dtv->dagstream);
366  }
367 
369 
370  SCLogDebug("Read %d records from stream: %d, DAG: %s",
371  pkts_read, dtv->dagstream, dtv->dagname);
372  }
373 
375 }
376 
377 /**
378  * \brief Process a chunk of records read from a DAG interface.
379  *
380  * This function takes a pointer to buffer read from the DAG interface
381  * and processes it individual records.
382  */
383 static inline TmEcode
384 ProcessErfDagRecords(ErfDagThreadVars *ewtn, uint8_t *top, uint32_t *pkts_read)
385 {
386  SCEnter();
387 
388  int err = 0;
389  dag_record_t *dr = NULL;
390  char *prec = NULL;
391  int rlen;
392  char hdr_type = 0;
393  int processed = 0;
394 
395  *pkts_read = 0;
396 
397  while (((top - ewtn->btm) >= dag_record_size) &&
398  ((processed + dag_record_size) < BYTES_PER_LOOP)) {
399 
402  }
403 
404  /* Make sure we have at least one packet in the packet pool,
405  * to prevent us from alloc'ing packets at line rate. */
406  PacketPoolWait();
407 
408  prec = (char *)ewtn->btm;
409  dr = (dag_record_t*)prec;
410  rlen = SCNtohs(dr->rlen);
411  hdr_type = dr->type;
412 
413  if (rlen < dag_record_size) {
414  SCLogError("Bad ERF record length %d (< dag_record_size) on stream: %d, DAG: %s", rlen,
415  ewtn->dagstream, ewtn->dagname);
417  }
418 
419  /* If we don't have enough data to finish processing this ERF
420  * record return and maybe next time we will.
421  */
422  if ((top - ewtn->btm) < rlen)
424 
425  ewtn->btm += rlen;
426  processed += rlen;
427 
428  /* Only support ethernet at this time. */
429  switch (hdr_type & ERF_TYPE_MASK) {
430  case ERF_TYPE_PAD:
431  case ERF_TYPE_META:
432  /* Skip. */
433  continue;
434  case ERF_TYPE_DSM_COLOR_ETH:
435  case ERF_TYPE_COLOR_ETH:
436  case ERF_TYPE_COLOR_HASH_ETH:
437  /* In these types the color value overwrites the lctr
438  * (drop count). */
439  break;
440  case ERF_TYPE_ETH:
441  if (dr->lctr) {
442  StatsCounterAddI64(&ewtn->tv->stats, ewtn->drops, SCNtohs(dr->lctr));
443  }
444  break;
445  default:
446  SCLogError("Processing of DAG record type: %d not implemented.", dr->type);
448  }
449 
450  err = ProcessErfDagRecord(ewtn, prec);
451  if (err != TM_ECODE_OK) {
453  }
454 
455  (*pkts_read)++;
456  }
457 
459 }
460 
461 /**
462  * \brief Process a DAG record into a TM packet buffer.
463  * \param prec pointer to a DAG record.
464  * \param
465  */
466 static inline TmEcode
467 ProcessErfDagRecord(ErfDagThreadVars *ewtn, char *prec)
468 {
469  SCEnter();
470 
471  uint16_t wlen = 0;
472  uint16_t rlen = 0;
473  int hdr_num = 0;
474  uint8_t hdr_type = 0;
475  dag_record_t *dr = (dag_record_t*)prec;
476  erf_payload_t *pload;
477  Packet *p;
478 
479  hdr_type = dr->type;
480  wlen = SCNtohs(dr->wlen);
481  rlen = SCNtohs(dr->rlen);
482 
483  /* count extension headers */
484  while (hdr_type & ERF_TYPE_MORE_EXT) {
485  if (rlen < (dag_record_size + (hdr_num * ERF_EXT_LEN))) {
486  SCLogError("Insufficient captured packet length.");
488  }
489  hdr_type = prec[(dag_record_size + (hdr_num * ERF_EXT_LEN))];
490  hdr_num++;
491  }
492 
493  /* Check that the whole frame was captured */
494  if (rlen < (dag_record_size + (hdr_num * ERF_EXT_LEN) + ERF_ETH_PAD_LEN + wlen)) {
495  SCLogInfo("Incomplete frame captured.");
497  }
498 
499  /* skip over extension headers */
500  pload = (erf_payload_t *)(prec + dag_record_size + (hdr_num * ERF_EXT_LEN));
501 
503  if (p == NULL) {
504  SCLogError("Failed to allocate a Packet on stream: %d, DAG: %s", ewtn->dagstream,
505  ewtn->dagname);
507  }
509 
510  SET_PKT_LEN(p, wlen);
512 
513  /* Take into account for link type Ethernet ETH frame starts
514  * after the ERF header + pad.
515  */
516  if (unlikely(PacketCopyData(p, pload->eth.dst, GET_PKT_LEN(p)))) {
517  TmqhOutputPacketpool(ewtn->tv, p);
519  }
520 
521  /* Convert ERF time to SCTime_t */
522  uint64_t ts = dr->ts;
523  p->ts = SCTIME_FROM_SECS(ts >> 32);
524  ts = (ts & 0xffffffffULL) * 1000000;
525  ts += 0x80000000; /* rounding */
526  uint64_t usecs = ts >> 32;
527  p->ts = SCTIME_ADD_USECS(p->ts, usecs);
528 
529  StatsCounterIncr(&ewtn->tv->stats, ewtn->packets);
530  ewtn->bytes += wlen;
531 
532  if (TmThreadsSlotProcessPkt(ewtn->tv, ewtn->slot, p) != TM_ECODE_OK) {
534  }
535 
537 }
538 
539 /**
540  * \brief Print some stats to the log at program exit.
541  *
542  * \param tv Pointer to ThreadVars.
543  * \param data Pointer to data, ErfFileThreadVars.
544  */
545 void
547 {
548  ErfDagThreadVars *ewtn = (ErfDagThreadVars *)data;
549 
550  (void)SC_ATOMIC_SET(ewtn->livedev->pkts, StatsCounterGetLocalValue(&tv->stats, ewtn->packets));
551  (void)SC_ATOMIC_SET(ewtn->livedev->drop, StatsCounterGetLocalValue(&tv->stats, ewtn->drops));
552 
553  SCLogInfo("Stream: %d; Bytes: %" PRIu64 "; Packets: %" PRIi64 "; Drops: %" PRIi64,
554  ewtn->dagstream, ewtn->bytes, StatsCounterGetLocalValue(&tv->stats, ewtn->packets),
556 }
557 
558 /**
559  * \brief Deinitializes the DAG card.
560  * \param tv pointer to ThreadVars
561  * \param data pointer that gets cast into PcapThreadVars for ptv
562  */
563 TmEcode
565 {
566  SCEnter();
567 
568  ErfDagThreadVars *ewtn = (ErfDagThreadVars *)data;
569 
571 
573 }
574 
575 void
576 ReceiveErfDagCloseStream(int dagfd, int stream)
577 {
578  dag_stop_stream(dagfd, stream);
579  dag_detach_stream(dagfd, stream);
580  dag_close(dagfd);
581 }
582 
583 /** Decode ErfDag */
584 
585 /**
586  * \brief This function passes off to link type decoders.
587  *
588  * DecodeErfDag decodes packets from DAG and passes
589  * them off to the proper link type decoder.
590  *
591  * \param t pointer to ThreadVars
592  * \param p pointer to the current packet
593  * \param data pointer that gets cast into PcapThreadVars for ptv
594  */
595 TmEcode
597 {
598  SCEnter();
600 
602 
603  /* update counters */
605 
606  /* call the decoder */
607  switch(p->datalink) {
608  case LINKTYPE_ETHERNET:
610  break;
611  default:
612  SCLogError("Error: datalink type %" PRId32 " not yet supported in module DecodeErfDag",
613  p->datalink);
614  break;
615  }
616 
618 
620 }
621 
622 TmEcode DecodeErfDagThreadInit(ThreadVars *tv, const void *initdata, void **data)
623 {
624  SCEnter();
625  DecodeThreadVars *dtv = NULL;
626 
628 
629  if (dtv == NULL)
631 
633 
634  *data = (void *)dtv;
635 
637 }
638 
639 TmEcode
641 {
642  if (data != NULL)
643  DecodeThreadVarsFree(tv, data);
645 }
646 
647 #endif /* HAVE_DAG */
TmModule_::cap_flags
uint8_t cap_flags
Definition: tm-modules.h:77
util-device-private.h
tm-threads.h
ts
uint64_t ts
Definition: source-erf-file.c:68
BYTES_PER_LOOP
#define BYTES_PER_LOOP
Definition: source-erf-dag.c:90
TMM_RECEIVEERFDAG
@ TMM_RECEIVEERFDAG
Definition: tm-threads-common.h:50
ThreadVars_::name
char name[16]
Definition: threadvars.h:65
StatsSyncCountersIfSignalled
void StatsSyncCountersIfSignalled(StatsThreadContext *stats)
Definition: counters.c:482
PacketCopyData
int PacketCopyData(Packet *p, const uint8_t *pktdata, uint32_t pktlen)
Copy data to Packet payload and set packet length.
Definition: decode.c:386
PKT_IS_PSEUDOPKT
#define PKT_IS_PSEUDOPKT(p)
return 1 if the packet is a pseudo packet
Definition: decode.h:1364
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:386
SCLogDebug
#define SCLogDebug(...)
Definition: util-debug.h:282
StatsRegisterCounter
StatsCounterId StatsRegisterCounter(const char *name, StatsThreadContext *stats)
Registers a normal, unqualified counter.
Definition: counters.c:1039
TmThreadsSetFlag
void TmThreadsSetFlag(ThreadVars *tv, uint32_t flag)
Set a thread flag.
Definition: tm-threads.c:103
ErfDagThreadVars_::btm
uint8_t * btm
Definition: source-erf-dag.c:116
LiveDevice_
Definition: util-device-private.h:32
THV_RUNNING
#define THV_RUNNING
Definition: threadvars.h:55
ERF_EXT_LEN
#define ERF_EXT_LEN
Definition: source-erf-dag.c:92
SURICATA_STOP
#define SURICATA_STOP
Definition: suricata.h:94
ErfDagThreadVars_::bytes
uint64_t bytes
Definition: source-erf-dag.c:109
util-privs.h
ErfDagThreadVars_::top
uint8_t * top
Definition: source-erf-dag.c:115
StatsCounterId
Definition: counters.h:30
ErfDagThreadVars_::packets
StatsCounterId packets
Definition: source-erf-dag.c:110
PacketDecodeFinalize
void PacketDecodeFinalize(ThreadVars *tv, DecodeThreadVars *dtv, Packet *p)
Finalize decoding of a packet.
Definition: decode.c:234
p
Packet * p
Definition: fuzz_iprep.c:21
TmqhOutputPacketpool
void TmqhOutputPacketpool(ThreadVars *t, Packet *p)
Definition: tmqh-packetpool.c:305
TM_ECODE_FAILED
@ TM_ECODE_FAILED
Definition: tm-threads-common.h:82
tmqh-packetpool.h
TmModule_::PktAcqLoop
TmEcode(* PktAcqLoop)(ThreadVars *, void *, void *)
Definition: tm-modules.h:58
TM_ECODE_OK
@ TM_ECODE_OK
Definition: tm-threads-common.h:81
MINDATA
#define MINDATA
Definition: source-erf-dag.c:81
ErfDagThreadVars_::dagname
char dagname[DAGNAME_BUFSIZE]
Definition: source-erf-dag.c:103
TmModule_::ThreadDeinit
TmEcode(* ThreadDeinit)(ThreadVars *, void *)
Definition: tm-modules.h:53
Packet_::datalink
int datalink
Definition: decode.h:652
source-erf-dag.h
PKT_SET_SRC
#define PKT_SET_SRC(p, src_val)
Definition: decode.h:1366
DecodeRegisterPerfCounters
void DecodeRegisterPerfCounters(DecodeThreadVars *dtv, ThreadVars *tv)
Definition: decode.c:647
SET_PKT_LEN
#define SET_PKT_LEN(p, len)
Definition: decode.h:214
SCTIME_FROM_SECS
#define SCTIME_FROM_SECS(s)
Definition: util-time.h:69
PKT_SRC_WIRE
@ PKT_SRC_WIRE
Definition: decode.h:52
SCTIME_ADD_USECS
#define SCTIME_ADD_USECS(ts, us)
Definition: util-time.h:59
TmModule_::PktAcqBreakLoop
TmEcode(* PktAcqBreakLoop)(ThreadVars *, void *)
Definition: tm-modules.h:61
Packet_::ts
SCTime_t ts
Definition: decode.h:570
ErfDagThreadVars_::drops
StatsCounterId drops
Definition: source-erf-dag.c:111
LiveGetDevice
LiveDevice * LiveGetDevice(const char *name)
Get a pointer to the device at idx.
Definition: util-device.c:269
MAXWAIT
#define MAXWAIT
Definition: source-erf-dag.c:84
SCEnter
#define SCEnter(...)
Definition: util-debug.h:284
GET_PKT_DATA
#define GET_PKT_DATA(p)
Definition: decode.h:210
ThreadVars_
Per thread variable structure.
Definition: threadvars.h:58
TmModule_::Func
TmEcode(* Func)(ThreadVars *, Packet *, void *)
Definition: tm-modules.h:56
ErfDagThreadVars_::livedev
LiveDevice * livedev
Definition: source-erf-dag.c:107
ReceiveErfDagThreadExitStats
void ReceiveErfDagThreadExitStats(ThreadVars *, void *)
Print some stats to the log at program exit.
Definition: source-erf-dag.c:546
StatsCounterIncr
void StatsCounterIncr(StatsThreadContext *stats, StatsCounterId id)
Increments the local counter.
Definition: counters.c:164
ReceiveErfDagCloseStream
void ReceiveErfDagCloseStream(int dagfd, int stream)
Definition: source-erf-dag.c:576
SC_CAP_NET_ADMIN
#define SC_CAP_NET_ADMIN
Definition: util-privs.h:31
ErfDagThreadVars_::dagfd
int dagfd
Definition: source-erf-dag.c:101
BUG_ON
#define BUG_ON(x)
Definition: suricata-common.h:325
PacketPoolWait
void PacketPoolWait(void)
Definition: tmqh-packetpool.c:71
TMM_DECODEERFDAG
@ TMM_DECODEERFDAG
Definition: tm-threads-common.h:51
Packet_
Definition: decode.h:516
TM_FLAG_DECODE_TM
#define TM_FLAG_DECODE_TM
Definition: tm-modules.h:33
tmm_modules
TmModule tmm_modules[TMM_SIZE]
Definition: tm-modules.c:29
wlen
uint16_t wlen
Definition: source-erf-file.c:73
GET_PKT_LEN
#define GET_PKT_LEN(p)
Definition: decode.h:209
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:596
TmEcode
TmEcode
Definition: tm-threads-common.h:80
max_pending_packets
uint32_t max_pending_packets
Definition: suricata.c:187
TmModuleDecodeErfDagRegister
void TmModuleDecodeErfDagRegister(void)
Register the ERF file decoder module.
Definition: source-erf-dag.c:154
TmModule_::name
const char * name
Definition: tm-modules.h:48
SCLogInfo
#define SCLogInfo(...)
Macro used to log INFORMATIONAL messages.
Definition: util-debug.h:232
TM_FLAG_RECEIVE_TM
#define TM_FLAG_RECEIVE_TM
Definition: tm-modules.h:32
dtv
DecodeThreadVars * dtv
Definition: fuzz_decodepcapfile.c:35
POLL_INTERVAL
#define POLL_INTERVAL
Definition: source-erf-dag.c:87
ErfDagThreadVars_::poll
struct timeval maxwait poll
Definition: source-erf-dag.c:105
DecodeThreadVarsFree
void DecodeThreadVarsFree(ThreadVars *tv, DecodeThreadVars *dtv)
Definition: decode.c:861
SCNtohs
#define SCNtohs(x)
Definition: suricata-common.h:439
suricata-common.h
ErfDagThreadVars_::tv
ThreadVars * tv
Definition: source-erf-dag.c:98
StatsCounterGetLocalValue
int64_t StatsCounterGetLocalValue(StatsThreadContext *stats, StatsCounterId id)
Get the value of the local copy of the counter that hold this id.
Definition: counters.c:1376
TmModule_::ThreadInit
TmEcode(* ThreadInit)(ThreadVars *, const void *, void **)
Definition: tm-modules.h:51
FatalError
#define FatalError(...)
Definition: util-debug.h:517
ErfDagThreadVars_::dagstream
int dagstream
Definition: source-erf-dag.c:102
tv
ThreadVars * tv
Definition: fuzz_decodepcapfile.c:34
DecodeErfDagThreadInit
TmEcode DecodeErfDagThreadInit(ThreadVars *, const void *, void **)
Definition: source-erf-dag.c:622
TmModuleReceiveErfDagRegister
void TmModuleReceiveErfDagRegister(void)
Register the ERF file receiver (reader) module.
Definition: source-erf-dag.c:136
TmModule_::ThreadExitPrintStats
void(* ThreadExitPrintStats)(ThreadVars *, void *)
Definition: tm-modules.h:52
ErfDagThreadVars_::slot
TmSlot * slot
Definition: source-erf-dag.c:99
SCLogError
#define SCLogError(...)
Macro used to log ERROR messages.
Definition: util-debug.h:274
SCFree
#define SCFree(p)
Definition: util-mem.h:61
DecodeThreadVars_
Structure to hold thread specific data for all decode modules.
Definition: decode.h:995
ERF_ETH_PAD_LEN
#define ERF_ETH_PAD_LEN
Definition: source-erf-dag.c:93
DecodeThreadVarsAlloc
DecodeThreadVars * DecodeThreadVarsAlloc(ThreadVars *tv)
Alloc and setup DecodeThreadVars.
Definition: decode.c:843
ReceiveErfDagThreadDeinit
TmEcode ReceiveErfDagThreadDeinit(ThreadVars *, void *)
Deinitializes the DAG card.
Definition: source-erf-dag.c:564
DecodeErfDagThreadDeinit
TmEcode DecodeErfDagThreadDeinit(ThreadVars *tv, void *data)
Definition: source-erf-dag.c:640
ReceiveErfDagLoop
TmEcode ReceiveErfDagLoop(ThreadVars *, void *data, void *slot)
Receives packets from a DAG interface.
Definition: source-erf-dag.c:314
suricata.h
Packet_::dst
Address dst
Definition: decode.h:521
TmSlot_::slot_next
struct TmSlot_ * slot_next
Definition: tm-threads.h:62
ReceiveErfDagThreadInit
TmEcode ReceiveErfDagThreadInit(ThreadVars *, const void *, void **)
Initialize the ERF receiver thread, generate a single ErfDagThreadVar structure for each thread,...
Definition: source-erf-dag.c:181
SCCalloc
#define SCCalloc(nm, sz)
Definition: util-mem.h:53
ThreadVars_::stats
StatsThreadContext stats
Definition: threadvars.h:121
SCReturnInt
#define SCReturnInt(x)
Definition: util-debug.h:288
StatsCounterAddI64
void StatsCounterAddI64(StatsThreadContext *stats, StatsCounterId id, int64_t x)
Adds a value of type uint64_t to the local counter.
Definition: counters.c:145
Packet_::type
uint8_t type
Definition: decode.h:526
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:298
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:80
DecodeUpdatePacketCounters
void DecodeUpdatePacketCounters(ThreadVars *tv, const DecodeThreadVars *dtv, const Packet *p)
Definition: decode.c:811
suricata_ctl_flags
volatile uint8_t suricata_ctl_flags
Definition: suricata.c:176
ErfDagThreadVars_
Definition: source-erf-dag.c:97
rlen
uint16_t rlen
Definition: source-erf-file.c:71