suricata
source-nflog.c
Go to the documentation of this file.
1 /* Copyright (C) 2014 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 Giuseppe Longo <giuseppelng@gmail.com>
22  *
23  * Netfilter's netfilter_log support
24  */
25 #include "suricata-common.h"
26 #include "suricata.h"
27 #include "decode.h"
28 #include "packet-queue.h"
29 
30 #include "threads.h"
31 #include "threadvars.h"
32 #include "tm-threads.h"
33 #include "tm-modules.h"
34 #include "tm-queuehandlers.h"
35 #include "tmqh-packetpool.h"
36 
37 #include "runmodes.h"
38 #include "util-error.h"
39 #include "util-device.h"
40 #include "util-datalink.h"
41 
42 #ifndef HAVE_NFLOG
43 /** Handle the case where no NFLOG support is compiled in.
44  *
45  */
46 
47 TmEcode NoNFLOGSupportExit(ThreadVars *, const void *, void **);
48 
50 {
51  tmm_modules[TMM_RECEIVENFLOG].name = "ReceiveNFLOG";
53 }
54 
56 {
57  tmm_modules[TMM_DECODENFLOG].name = "DecodeNFLOG";
59 }
60 
61 TmEcode NoNFLOGSupportExit(ThreadVars *tv, const void *initdata, void **data)
62 {
63  SCLogError("Error creating thread %s: you do not have support for nflog "
64  "enabled please recompile with --enable-nflog",
65  tv->name);
66  exit(EXIT_FAILURE);
67 }
68 
69 #else /* implied we do have NFLOG support */
70 
71 #include "source-nflog.h"
72 
73 TmEcode ReceiveNFLOGThreadInit(ThreadVars *, const void *, void **);
74 TmEcode ReceiveNFLOGThreadDeinit(ThreadVars *, void *);
75 TmEcode ReceiveNFLOGLoop(ThreadVars *, void *, void *);
76 void ReceiveNFLOGThreadExitStats(ThreadVars *, void *);
77 
78 TmEcode DecodeNFLOGThreadInit(ThreadVars *, const void *, void **);
79 TmEcode DecodeNFLOGThreadDeinit(ThreadVars *tv, void *data);
80 TmEcode DecodeNFLOG(ThreadVars *, Packet *, void *);
81 
82 static int runmode_workers;
83 
84 /* Structure to hold thread specific variables */
85 typedef struct NFLOGThreadVars_ {
86  ThreadVars *tv;
87  TmSlot *slot;
88 
89  char *data;
90  int datalen;
91 
92  uint16_t group;
93  uint32_t nlbufsiz;
94  uint32_t nlbufsiz_max;
95  uint32_t qthreshold;
96  uint32_t qtimeout;
97 
98  struct nflog_handle *h;
99  struct nflog_g_handle *gh;
100 
101  LiveDevice *livedev;
102  int nful_overrun_warned;
103 
104  /* counters */
105  uint32_t pkts;
106  uint64_t bytes;
107  uint32_t errs;
108 
109  uint16_t capture_kernel_packets;
110  uint16_t capture_kernel_drops;
111 } NFLOGThreadVars;
112 
113 /**
114  * \brief Registration function for ReceiveNFLOG
115  */
117 {
118  tmm_modules[TMM_RECEIVENFLOG].name = "ReceiveNFLOG";
119  tmm_modules[TMM_RECEIVENFLOG].ThreadInit = ReceiveNFLOGThreadInit;
121  tmm_modules[TMM_RECEIVENFLOG].PktAcqLoop = ReceiveNFLOGLoop;
123  tmm_modules[TMM_RECEIVENFLOG].ThreadExitPrintStats = ReceiveNFLOGThreadExitStats;
124  tmm_modules[TMM_RECEIVENFLOG].ThreadDeinit = ReceiveNFLOGThreadDeinit;
126 }
127 
128 /**
129  * \brief Registration function for DecodeNFLOG
130  */
131 void TmModuleDecodeNFLOGRegister (void)
132 {
133  tmm_modules[TMM_DECODENFLOG].name = "DecodeNFLOG";
134  tmm_modules[TMM_DECODENFLOG].ThreadInit = DecodeNFLOGThreadInit;
135  tmm_modules[TMM_DECODENFLOG].Func = DecodeNFLOG;
137  tmm_modules[TMM_DECODENFLOG].ThreadDeinit = DecodeNFLOGThreadDeinit;
139 }
140 
141 /**
142  * \brief NFLOG callback function
143  * This function setup a packet from a nflog message
144  */
145 static int NFLOGCallback(struct nflog_g_handle *gh, struct nfgenmsg *msg,
146  struct nflog_data *nfa, void *data)
147 {
148  NFLOGThreadVars *ntv = (NFLOGThreadVars *) data;
149  struct nfulnl_msg_packet_hdr *ph;
150  char *payload;
151  int ret;
152 
153  /* grab a packet*/
155  if (p == NULL)
156  return -1;
157 
159 
160  ph = nflog_get_msg_packet_hdr(nfa);
161  if (ph != NULL) {
162  p->nflog_v.hw_protocol = ph->hw_protocol;
163  }
164 
165  p->nflog_v.ifi = nflog_get_indev(nfa);
166  p->nflog_v.ifo = nflog_get_outdev(nfa);
167 
168  ret = nflog_get_payload(nfa, &payload);
169 
170  if (ret > 0) {
171  if (ret > 65536) {
172  SCLogWarning("NFLOG sent too big packet");
173  SET_PKT_LEN(p, 0);
174  } else if (runmode_workers)
175  PacketSetData(p, (uint8_t *)payload, ret);
176  else
177  PacketCopyData(p, (uint8_t *)payload, ret);
178  } else if (ret == -1)
179  SET_PKT_LEN(p, 0);
180 
181  ret = nflog_get_timestamp(nfa, &p->ts);
182  if (ret != 0) {
183  struct timeval tv;
184  memset(&tv, 0, sizeof(struct timeval));
185  gettimeofday(&tv, NULL);
186  p->ts = SCTIME_FROM_TIMEVAL(&tv);
187  }
188 
189  p->datalink = DLT_RAW;
190 
191 #ifdef COUNTERS
192  ntv->pkts++;
193  ntv->bytes += GET_PKT_LEN(p);
194 #endif
195  (void) SC_ATOMIC_ADD(ntv->livedev->pkts, 1);
196 
197  if (TmThreadsSlotProcessPkt(ntv->tv, ntv->slot, p) != TM_ECODE_OK) {
198  return -1;
199  }
200 
201  return 0;
202 }
203 
204 /**
205  * \brief Receives packet from a nflog group via libnetfilter_log
206  * This is a setup function for recieving packets via libnetfilter_log.
207  * \param tv pointer to ThreadVars
208  * \param initdata pointer to the group passed from the user
209  * \param data pointer gets populated with NFLOGThreadVars
210  * \retvalTM_ECODE_OK on success
211  * \retval TM_ECODE_FAILED on error
212  */
213 TmEcode ReceiveNFLOGThreadInit(ThreadVars *tv, const void *initdata, void **data)
214 {
215  NflogGroupConfig *nflconfig = (NflogGroupConfig *)initdata;
216 
217  if (initdata == NULL) {
218  SCLogError("initdata == NULL");
220  }
221 
222  NFLOGThreadVars *ntv = SCMalloc(sizeof(NFLOGThreadVars));
223  if (unlikely(ntv == NULL)) {
224  nflconfig->DerefFunc(nflconfig);
226  }
227  memset(ntv, 0, sizeof(NFLOGThreadVars));
228 
229  ntv->tv = tv;
230  ntv->group = nflconfig->group;
231  ntv->nlbufsiz = nflconfig->nlbufsiz;
232  ntv->nlbufsiz_max = nflconfig->nlbufsiz_max;
233  ntv->qthreshold = nflconfig->qthreshold;
234  ntv->qtimeout = nflconfig->qtimeout;
235  ntv->nful_overrun_warned = nflconfig->nful_overrun_warned;
236 
237  ntv->h = nflog_open();
238  if (ntv->h == NULL) {
239  SCLogError("nflog_open() failed");
240  SCFree(ntv);
241  return TM_ECODE_FAILED;
242  }
243 
244  SCLogDebug("binding netfilter_log as nflog handler for AF_INET and AF_INET6");
245 
246  if (nflog_bind_pf(ntv->h, AF_INET) < 0) {
247  FatalError("nflog_bind_pf() for AF_INET failed");
248  }
249  if (nflog_bind_pf(ntv->h, AF_INET6) < 0) {
250  FatalError("nflog_bind_pf() for AF_INET6 failed");
251  }
252 
253  ntv->gh = nflog_bind_group(ntv->h, ntv->group);
254  if (!ntv->gh) {
255  SCLogError("nflog_bind_group() failed");
256  SCFree(ntv);
257  return TM_ECODE_FAILED;
258  }
259 
260  if (nflog_set_mode(ntv->gh, NFULNL_COPY_PACKET, 0xFFFF) < 0) {
261  SCLogError("can't set packet_copy mode");
262  SCFree(ntv);
263  return TM_ECODE_FAILED;
264  }
265 
266  nflog_callback_register(ntv->gh, &NFLOGCallback, (void *)ntv);
267 
268  if (ntv->nlbufsiz < ntv->nlbufsiz_max)
269  ntv->nlbufsiz = nfnl_rcvbufsiz(nflog_nfnlh(ntv->h), ntv->nlbufsiz);
270  else {
271  SCLogError("Maximum buffer size (%d) in NFLOG "
272  "has been reached",
273  ntv->nlbufsiz);
274  return TM_ECODE_FAILED;
275  }
276 
277  if (nflog_set_qthresh(ntv->gh, ntv->qthreshold) >= 0)
278  SCLogDebug("NFLOG netlink queue threshold has been set to %d",
279  ntv->qthreshold);
280  else
281  SCLogDebug("NFLOG netlink queue threshold can't be set to %d",
282  ntv->qthreshold);
283 
284  if (nflog_set_timeout(ntv->gh, ntv->qtimeout) >= 0)
285  SCLogDebug("NFLOG netlink queue timeout has been set to %d",
286  ntv->qtimeout);
287  else
288  SCLogDebug("NFLOG netlink queue timeout can't be set to %d",
289  ntv->qtimeout);
290 
291  ntv->livedev = LiveGetDevice(nflconfig->numgroup);
292  if (ntv->livedev == NULL) {
293  SCLogError("Unable to find Live device");
294  SCFree(ntv);
296  }
297 
298  /* set a timeout to the socket so we can check for a signal
299  * in case we don't get packets for a longer period. */
300  struct timeval timev;
301  timev.tv_sec = 1;
302  timev.tv_usec = 0;
303 
304  int fd = nflog_fd(ntv->h);
305  if (setsockopt(fd, SOL_SOCKET, SO_RCVTIMEO, &timev, sizeof(timev)) == -1) {
306  SCLogWarning("can't set socket "
307  "timeout: %s",
308  strerror(errno));
309  }
310 
311 #ifdef PACKET_STATISTICS
312  ntv->capture_kernel_packets = StatsRegisterCounter("capture.kernel_packets",
313  ntv->tv);
314  ntv->capture_kernel_drops = StatsRegisterCounter("capture.kernel_drops",
315  ntv->tv);
316 #endif
317 
318  char *active_runmode = RunmodeGetActive();
319  if (active_runmode && !strcmp("workers", active_runmode))
320  runmode_workers = 1;
321  else
322  runmode_workers = 0;
323 
324 #define T_DATA_SIZE 70000
325  ntv->data = SCMalloc(T_DATA_SIZE);
326  if (ntv->data == NULL) {
327  nflconfig->DerefFunc(nflconfig);
328  SCFree(ntv);
330  }
331 
332  ntv->datalen = T_DATA_SIZE;
333 #undef T_DATA_SIZE
334 
336 
337  *data = (void *)ntv;
338 
339  nflconfig->DerefFunc(nflconfig);
341 }
342 
343 /**
344  * \brief DeInit function unbind group and close nflog's handle
345  * \param tv pointer to ThreadVars
346  * \param data pointer that gets cast into NFLogThreadVars
347  * \retval TM_ECODE_OK is always returned
348  */
349 TmEcode ReceiveNFLOGThreadDeinit(ThreadVars *tv, void *data)
350 {
351  NFLOGThreadVars *ntv = (NFLOGThreadVars *)data;
352 
353  SCLogDebug("closing nflog group %d", ntv->group);
354  if (nflog_unbind_pf(ntv->h, AF_INET) < 0) {
355  FatalError("nflog_unbind_pf() for AF_INET failed");
356  }
357 
358  if (nflog_unbind_pf(ntv->h, AF_INET6) < 0) {
359  FatalError("nflog_unbind_pf() for AF_INET6 failed");
360  }
361 
362  if (ntv->gh) {
363  nflog_unbind_group(ntv->gh);
364  ntv->gh = NULL;
365  }
366 
367  if (ntv->h) {
368  nflog_close(ntv->h);
369  ntv->h = NULL;
370  }
371 
372  if (ntv->data != NULL) {
373  SCFree(ntv->data);
374  ntv->data = NULL;
375  }
376  ntv->datalen = 0;
377 
378  SCFree(ntv);
379 
381 }
382 
383 /**
384  * \brief Increases netlink buffer size
385  *
386  * This function netlink's buffer size until
387  * the max buffer size is reached
388  *
389  * \param data pointer that gets cast into NFLOGThreadVars
390  * \param size netlink buffer size
391  */
392 static int NFLOGSetnlbufsiz(void *data, unsigned int size)
393 {
394  SCEnter();
395  NFLOGThreadVars *ntv = (NFLOGThreadVars *)data;
396 
397  if (size < ntv->nlbufsiz_max) {
398  ntv->nlbufsiz = nfnl_rcvbufsiz(nflog_nfnlh(ntv->h), ntv->nlbufsiz);
399  return 1;
400  }
401 
402  SCLogWarning("Maximum buffer size (%d) in NFLOG has been "
403  "reached. Please, consider raising "
404  "`buffer-size` and `max-size` in nflog configuration",
405  ntv->nlbufsiz);
406  return 0;
407 
408 }
409 
410 /**
411  * \brief Recieves packets from a group via libnetfilter_log.
412  *
413  * This function recieves packets from a group and passes
414  * the packet on to the nflog callback function.
415  *
416  * \param tv pointer to ThreadVars
417  * \param data pointer that gets cast into NFLOGThreadVars
418  * \param slot slot containing task information
419  * \retval TM_ECODE_OK on success
420  * \retval TM_ECODE_FAILED on failure
421  */
422 TmEcode ReceiveNFLOGLoop(ThreadVars *tv, void *data, void *slot)
423 {
424  SCEnter();
425  NFLOGThreadVars *ntv = (NFLOGThreadVars *)data;
426  int rv, fd;
427  int ret = -1;
428 
429  ntv->slot = ((TmSlot *) slot)->slot_next;
430 
431  fd = nflog_fd(ntv->h);
432  if (fd < 0) {
433  SCLogError("Can't obtain a file descriptor");
435  }
436 
437  // Indicate that the thread is actually running its application level code (i.e., it can poll
438  // packets)
440 
441  while (1) {
442  if (suricata_ctl_flags != 0)
443  break;
444 
445  rv = recv(fd, ntv->data, ntv->datalen, 0);
446  if (rv < 0) {
447  /*We received an error on socket read */
448  if (errno == EINTR || errno == EWOULDBLOCK) {
449  /*Nothing for us to process */
450  continue;
451  } else if (errno == ENOBUFS) {
452  if (!ntv->nful_overrun_warned) {
453  int s = ntv->nlbufsiz * 2;
454  if (NFLOGSetnlbufsiz((void *)ntv, s)) {
455  SCLogWarning("We are losing events, "
456  "increasing buffer size "
457  "to %d",
458  ntv->nlbufsiz);
459  } else {
460  ntv->nful_overrun_warned = 1;
461  }
462  }
463  continue;
464  } else {
465  SCLogWarning("Read from NFLOG fd failed: %s", strerror(errno));
467  }
468  }
469 
470  ret = nflog_handle_packet(ntv->h, ntv->data, rv);
471  if (ret != 0)
472  SCLogWarning("nflog_handle_packet error %" PRId32 "", ret);
473 
475  }
476 
478 }
479 
480 /**
481  * \brief This function prints stats to the screen at exit
482  * \param tv pointer to ThreadVars
483  * \param data pointer that gets cast into NFLOGThreadVars
484  */
485 void ReceiveNFLOGThreadExitStats(ThreadVars *tv, void *data)
486 {
487  SCEnter();
488  NFLOGThreadVars *ntv = (NFLOGThreadVars *)data;
489 
490  SCLogNotice("(%s) Pkts %" PRIu32 ", Bytes %" PRIu64 "",
491  tv->name, ntv->pkts, ntv->bytes);
492 }
493 
494 
495 /**
496  * \brief Decode IPv4/v6 packets.
497  *
498  * \param tv pointer to ThreadVars
499  * \param p pointer to the current packet
500  * \param data pointer that gets cast into NFLOGThreadVars for ptv
501  *
502  * \retval TM_ECODE_OK is always returned
503  */
504 TmEcode DecodeNFLOG(ThreadVars *tv, Packet *p, void *data)
505 {
506  SCEnter();
507  IPV4Hdr *ip4h = (IPV4Hdr *)GET_PKT_DATA(p);
508  IPV6Hdr *ip6h = (IPV6Hdr *)GET_PKT_DATA(p);
510 
512 
513  if (IPV4_GET_RAW_VER(ip4h) == 4) {
514  if (unlikely(GET_PKT_LEN(p) > USHRT_MAX)) {
515  return TM_ECODE_FAILED;
516  }
517  SCLogDebug("IPv4 packet");
519  } else if(IPV6_GET_RAW_VER(ip6h) == 6) {
520  if (unlikely(GET_PKT_LEN(p) > USHRT_MAX)) {
521  return TM_ECODE_FAILED;
522  }
523  SCLogDebug("IPv6 packet");
525  } else {
526  SCLogDebug("packet unsupported by NFLOG, first byte: %02x", *GET_PKT_DATA(p));
527  }
528 
530 
532 }
533 
534 /**
535  * \brief This an Init function for DecodeNFLOG
536  *
537  * \param tv pointer to ThreadVars
538  * \param initdata pointer to initilization data.
539  * \param data pointer that gets cast into NFLOGThreadVars
540  * \retval TM_ECODE_OK is returned on success
541  * \retval TM_ECODE_FAILED is returned on error
542  */
543 TmEcode DecodeNFLOGThreadInit(ThreadVars *tv, const void *initdata, void **data)
544 {
545  DecodeThreadVars *dtv = NULL;
547 
548  if (dtv == NULL)
550 
552 
553  *data = (void *)dtv;
554 
556 }
557 
558 TmEcode DecodeNFLOGThreadDeinit(ThreadVars *tv, void *data)
559 {
560  if (data != NULL)
561  DecodeThreadVarsFree(tv, data);
563 }
564 
565 #endif /* NFLOG */
tm-threads.h
source-nflog.h
IPV6_GET_RAW_VER
#define IPV6_GET_RAW_VER(ip6h)
Definition: decode-ipv6.h:62
ThreadVars_::name
char name[16]
Definition: threadvars.h:64
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
unlikely
#define unlikely(expr)
Definition: util-optimize.h:35
SCLogDebug
#define SCLogDebug(...)
Definition: util-debug.h:269
TmThreadsSetFlag
void TmThreadsSetFlag(ThreadVars *tv, uint32_t flag)
Set a thread flag.
Definition: tm-threads.c:99
threads.h
LiveDevice_
Definition: util-device.h:39
SC_ATOMIC_ADD
#define SC_ATOMIC_ADD(name, val)
add a value to our atomic variable
Definition: util-atomic.h:333
THV_RUNNING
#define THV_RUNNING
Definition: threadvars.h:54
packet-queue.h
tm-modules.h
StatsSyncCountersIfSignalled
#define StatsSyncCountersIfSignalled(tv)
Definition: counters.h:140
PacketDecodeFinalize
void PacketDecodeFinalize(ThreadVars *tv, DecodeThreadVars *dtv, Packet *p)
Finalize decoding of a packet.
Definition: decode.c:147
RunmodeGetActive
char * RunmodeGetActive(void)
Definition: runmodes.c:217
NflogGroupConfig_::numgroup
char numgroup[NFLOG_GROUP_NAME_LENGTH]
Definition: source-nflog.h:47
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
TmModule_::ThreadDeinit
TmEcode(* ThreadDeinit)(ThreadVars *, void *)
Definition: tm-modules.h:49
Packet_::datalink
int datalink
Definition: decode.h:607
PKT_SET_SRC
#define PKT_SET_SRC(p, src_val)
Definition: decode.h:1062
TMM_DECODENFLOG
@ TMM_DECODENFLOG
Definition: tm-threads-common.h:67
DLT_RAW
#define DLT_RAW
Definition: decode.h:961
TmModuleDecodeNFLOGRegister
void TmModuleDecodeNFLOGRegister(void)
Definition: source-nflog.c:55
DecodeRegisterPerfCounters
void DecodeRegisterPerfCounters(DecodeThreadVars *dtv, ThreadVars *tv)
Definition: decode.c:526
SET_PKT_LEN
#define SET_PKT_LEN(p, len)
Definition: decode.h:223
decode.h
util-device.h
PKT_SRC_WIRE
@ PKT_SRC_WIRE
Definition: decode.h:54
util-error.h
TmModule_::PktAcqBreakLoop
TmEcode(* PktAcqBreakLoop)(ThreadVars *, void *)
Definition: tm-modules.h:57
Packet_::ts
SCTime_t ts
Definition: decode.h:471
LiveGetDevice
LiveDevice * LiveGetDevice(const char *name)
Get a pointer to the device at idx.
Definition: util-device.c:242
SCEnter
#define SCEnter(...)
Definition: util-debug.h:271
GET_PKT_DATA
#define GET_PKT_DATA(p)
Definition: decode.h:219
ThreadVars_
Per thread variable structure.
Definition: threadvars.h:57
SCTIME_FROM_TIMEVAL
#define SCTIME_FROM_TIMEVAL(tv)
Definition: util-time.h:65
TmModule_::Func
TmEcode(* Func)(ThreadVars *, Packet *, void *)
Definition: tm-modules.h:52
SCLogWarning
#define SCLogWarning(...)
Macro used to log WARNING messages.
Definition: util-debug.h:249
IPV6Hdr_
Definition: decode-ipv6.h:32
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
DecodeIPV6
int DecodeIPV6(ThreadVars *tv, DecodeThreadVars *dtv, Packet *p, const uint8_t *pkt, uint16_t len)
Definition: decode-ipv6.c:564
GET_PKT_LEN
#define GET_PKT_LEN(p)
Definition: decode.h:218
NflogGroupConfig_::qtimeout
uint32_t qtimeout
Definition: source-nflog.h:44
IPV4_GET_RAW_VER
#define IPV4_GET_RAW_VER(ip4h)
Definition: decode-ipv4.h:95
TmSlot_
Definition: tm-threads.h:53
TmEcode
TmEcode
Definition: tm-threads-common.h:83
TmModule_::name
const char * name
Definition: tm-modules.h:44
runmodes.h
TmModuleReceiveNFLOGRegister
void TmModuleReceiveNFLOGRegister(void)
Definition: source-nflog.c:49
TM_FLAG_RECEIVE_TM
#define TM_FLAG_RECEIVE_TM
Definition: tm-modules.h:31
dtv
DecodeThreadVars * dtv
Definition: fuzz_decodepcapfile.c:33
IPV4Hdr_
Definition: decode-ipv4.h:72
tm-queuehandlers.h
NoNFLOGSupportExit
TmEcode NoNFLOGSupportExit(ThreadVars *, const void *, void **)
Definition: source-nflog.c:61
DecodeThreadVarsFree
void DecodeThreadVarsFree(ThreadVars *tv, DecodeThreadVars *dtv)
Definition: decode.c:708
group
uint8_t group
Definition: app-layer-dnp3.h:0
suricata-common.h
TMM_RECEIVENFLOG
@ TMM_RECEIVENFLOG
Definition: tm-threads-common.h:66
TmModule_::ThreadInit
TmEcode(* ThreadInit)(ThreadVars *, const void *, void **)
Definition: tm-modules.h:47
NflogGroupConfig_::DerefFunc
void(* DerefFunc)(void *)
Definition: source-nflog.h:51
FatalError
#define FatalError(...)
Definition: util-debug.h:502
NflogGroupConfig_::group
uint16_t group
Definition: source-nflog.h:36
tv
ThreadVars * tv
Definition: fuzz_decodepcapfile.c:32
TmModule_::ThreadExitPrintStats
void(* ThreadExitPrintStats)(ThreadVars *, void *)
Definition: tm-modules.h:48
threadvars.h
SCMalloc
#define SCMalloc(sz)
Definition: util-mem.h:47
SCLogError
#define SCLogError(...)
Macro used to log ERROR messages.
Definition: util-debug.h:261
NflogGroupConfig_::qthreshold
uint32_t qthreshold
Definition: source-nflog.h:42
SCFree
#define SCFree(p)
Definition: util-mem.h:61
DecodeThreadVars_
Structure to hold thread specific data for all decode modules.
Definition: decode.h:664
NflogGroupConfig_::nful_overrun_warned
int nful_overrun_warned
Definition: source-nflog.h:49
DecodeThreadVarsAlloc
DecodeThreadVars * DecodeThreadVarsAlloc(ThreadVars *tv)
Alloc and setup DecodeThreadVars.
Definition: decode.c:689
PacketSetData
int PacketSetData(Packet *p, const uint8_t *pktdata, uint32_t pktlen)
Set data for Packet and set length when zero copy is used.
Definition: decode.c:728
suricata.h
NflogGroupConfig_
Definition: source-nflog.h:34
DecodeIPV4
int DecodeIPV4(ThreadVars *tv, DecodeThreadVars *dtv, Packet *p, const uint8_t *pkt, uint16_t len)
Definition: decode-ipv4.c:520
SCLogNotice
#define SCLogNotice(...)
Macro used to log NOTICE messages.
Definition: util-debug.h:237
msg
const char * msg
Definition: app-layer-htp.c:575
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:275
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
TmModule_::flags
uint8_t flags
Definition: tm-modules.h:70
NflogGroupConfig_::nlbufsiz_max
uint32_t nlbufsiz_max
Definition: source-nflog.h:40
DecodeUpdatePacketCounters
void DecodeUpdatePacketCounters(ThreadVars *tv, const DecodeThreadVars *dtv, const Packet *p)
Definition: decode.c:655
NflogGroupConfig_::nlbufsiz
uint32_t nlbufsiz
Definition: source-nflog.h:38
suricata_ctl_flags
volatile uint8_t suricata_ctl_flags
Definition: suricata.c:164
T_DATA_SIZE
#define T_DATA_SIZE