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 
41 #ifndef HAVE_NFLOG
42 /** Handle the case where no NFLOG support is compiled in.
43  *
44  */
45 
46 TmEcode NoNFLOGSupportExit(ThreadVars *, const void *, void **);
47 
49 {
50  tmm_modules[TMM_RECEIVENFLOG].name = "ReceiveNFLOG";
52 }
53 
55 {
56  tmm_modules[TMM_DECODENFLOG].name = "DecodeNFLOG";
58 }
59 
60 TmEcode NoNFLOGSupportExit(ThreadVars *tv, const void *initdata, void **data)
61 {
62  SCLogError(SC_ERR_NFLOG_NOSUPPORT,"Error creating thread %s: you do not have support for nflog "
63  "enabled please recompile with --enable-nflog", tv->name);
64  exit(EXIT_FAILURE);
65 }
66 
67 #else /* implied we do have NFLOG support */
68 
69 #include "source-nflog.h"
70 
71 TmEcode ReceiveNFLOGThreadInit(ThreadVars *, const void *, void **);
72 TmEcode ReceiveNFLOGThreadDeinit(ThreadVars *, void *);
73 TmEcode ReceiveNFLOGLoop(ThreadVars *, void *, void *);
74 void ReceiveNFLOGThreadExitStats(ThreadVars *, void *);
75 
76 TmEcode DecodeNFLOGThreadInit(ThreadVars *, const void *, void **);
77 TmEcode DecodeNFLOGThreadDeinit(ThreadVars *tv, void *data);
78 TmEcode DecodeNFLOG(ThreadVars *, Packet *, void *);
79 
80 static int runmode_workers;
81 
82 /* Structure to hold thread specific variables */
83 typedef struct NFLOGThreadVars_ {
84  ThreadVars *tv;
85  TmSlot *slot;
86 
87  char *data;
88  int datalen;
89 
90  uint16_t group;
91  uint32_t nlbufsiz;
92  uint32_t nlbufsiz_max;
93  uint32_t qthreshold;
94  uint32_t qtimeout;
95 
96  struct nflog_handle *h;
97  struct nflog_g_handle *gh;
98 
99  LiveDevice *livedev;
100  int nful_overrun_warned;
101 
102  /* counters */
103  uint32_t pkts;
104  uint64_t bytes;
105  uint32_t errs;
106 
107  uint16_t capture_kernel_packets;
108  uint16_t capture_kernel_drops;
109 } NFLOGThreadVars;
110 
111 /**
112  * \brief Registration function for ReceiveNFLOG
113  */
115 {
116  tmm_modules[TMM_RECEIVENFLOG].name = "ReceiveNFLOG";
117  tmm_modules[TMM_RECEIVENFLOG].ThreadInit = ReceiveNFLOGThreadInit;
119  tmm_modules[TMM_RECEIVENFLOG].PktAcqLoop = ReceiveNFLOGLoop;
121  tmm_modules[TMM_RECEIVENFLOG].ThreadExitPrintStats = ReceiveNFLOGThreadExitStats;
122  tmm_modules[TMM_RECEIVENFLOG].ThreadDeinit = ReceiveNFLOGThreadDeinit;
125 }
126 
127 /**
128  * \brief Registration function for DecodeNFLOG
129  */
130 void TmModuleDecodeNFLOGRegister (void)
131 {
132  tmm_modules[TMM_DECODENFLOG].name = "DecodeNFLOG";
133  tmm_modules[TMM_DECODENFLOG].ThreadInit = DecodeNFLOGThreadInit;
134  tmm_modules[TMM_DECODENFLOG].Func = DecodeNFLOG;
136  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(SC_ERR_INVALID_ARGUMENTS, "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  memset(&p->ts, 0, sizeof(struct timeval));
184  gettimeofday(&p->ts, NULL);
185  }
186 
187  p->datalink = DLT_RAW;
188 
189 #ifdef COUNTERS
190  ntv->pkts++;
191  ntv->bytes += GET_PKT_LEN(p);
192 #endif
193  (void) SC_ATOMIC_ADD(ntv->livedev->pkts, 1);
194 
195  if (TmThreadsSlotProcessPkt(ntv->tv, ntv->slot, p) != TM_ECODE_OK) {
196  return -1;
197  }
198 
199  return 0;
200 }
201 
202 /**
203  * \brief Receives packet from a nflog group via libnetfilter_log
204  * This is a setup function for recieving packets via libnetfilter_log.
205  * \param tv pointer to ThreadVars
206  * \param initdata pointer to the group passed from the user
207  * \param data pointer gets populated with NFLOGThreadVars
208  * \retvalTM_ECODE_OK on success
209  * \retval TM_ECODE_FAILED on error
210  */
211 TmEcode ReceiveNFLOGThreadInit(ThreadVars *tv, const void *initdata, void **data)
212 {
213  NflogGroupConfig *nflconfig = (NflogGroupConfig *)initdata;
214 
215  if (initdata == NULL) {
216  SCLogError(SC_ERR_INVALID_ARGUMENT, "initdata == NULL");
218  }
219 
220  NFLOGThreadVars *ntv = SCMalloc(sizeof(NFLOGThreadVars));
221  if (unlikely(ntv == NULL)) {
222  nflconfig->DerefFunc(nflconfig);
224  }
225  memset(ntv, 0, sizeof(NFLOGThreadVars));
226 
227  ntv->tv = tv;
228  ntv->group = nflconfig->group;
229  ntv->nlbufsiz = nflconfig->nlbufsiz;
230  ntv->nlbufsiz_max = nflconfig->nlbufsiz_max;
231  ntv->qthreshold = nflconfig->qthreshold;
232  ntv->qtimeout = nflconfig->qtimeout;
233  ntv->nful_overrun_warned = nflconfig->nful_overrun_warned;
234 
235  ntv->h = nflog_open();
236  if (ntv->h == NULL) {
237  SCLogError(SC_ERR_NFLOG_OPEN, "nflog_open() failed");
238  SCFree(ntv);
239  return TM_ECODE_FAILED;
240  }
241 
242  SCLogDebug("binding netfilter_log as nflog handler for AF_INET and AF_INET6");
243 
244  if (nflog_bind_pf(ntv->h, AF_INET) < 0) {
245  SCLogError(SC_ERR_NFLOG_BIND, "nflog_bind_pf() for AF_INET failed");
246  exit(EXIT_FAILURE);
247  }
248  if (nflog_bind_pf(ntv->h, AF_INET6) < 0) {
249  SCLogError(SC_ERR_NFLOG_BIND, "nflog_bind_pf() for AF_INET6 failed");
250  exit(EXIT_FAILURE);
251  }
252 
253  ntv->gh = nflog_bind_group(ntv->h, ntv->group);
254  if (!ntv->gh) {
255  SCLogError(SC_ERR_NFLOG_OPEN, "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(SC_ERR_NFLOG_SET_MODE, "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(SC_ERR_NFLOG_MAX_BUFSIZ, "Maximum buffer size (%d) in NFLOG "
272  "has been reached", ntv->nlbufsiz);
273  return TM_ECODE_FAILED;
274  }
275 
276  if (nflog_set_qthresh(ntv->gh, ntv->qthreshold) >= 0)
277  SCLogDebug("NFLOG netlink queue threshold has been set to %d",
278  ntv->qthreshold);
279  else
280  SCLogDebug("NFLOG netlink queue threshold can't be set to %d",
281  ntv->qthreshold);
282 
283  if (nflog_set_timeout(ntv->gh, ntv->qtimeout) >= 0)
284  SCLogDebug("NFLOG netlink queue timeout has been set to %d",
285  ntv->qtimeout);
286  else
287  SCLogDebug("NFLOG netlink queue timeout can't be set to %d",
288  ntv->qtimeout);
289 
290  ntv->livedev = LiveGetDevice(nflconfig->numgroup);
291  if (ntv->livedev == NULL) {
292  SCLogError(SC_ERR_INVALID_VALUE, "Unable to find Live device");
293  SCFree(ntv);
295  }
296 
297  /* set a timeout to the socket so we can check for a signal
298  * in case we don't get packets for a longer period. */
299  struct timeval timev;
300  timev.tv_sec = 1;
301  timev.tv_usec = 0;
302 
303  int fd = nflog_fd(ntv->h);
304  if (setsockopt(fd, SOL_SOCKET, SO_RCVTIMEO, &timev, sizeof(timev)) == -1) {
305  SCLogWarning(SC_WARN_NFLOG_SETSOCKOPT, "can't set socket "
306  "timeout: %s", strerror(errno));
307  }
308 
309 #ifdef PACKET_STATISTICS
310  ntv->capture_kernel_packets = StatsRegisterCounter("capture.kernel_packets",
311  ntv->tv);
312  ntv->capture_kernel_drops = StatsRegisterCounter("capture.kernel_drops",
313  ntv->tv);
314 #endif
315 
316  char *active_runmode = RunmodeGetActive();
317  if (active_runmode && !strcmp("workers", active_runmode))
318  runmode_workers = 1;
319  else
320  runmode_workers = 0;
321 
322 #define T_DATA_SIZE 70000
323  ntv->data = SCMalloc(T_DATA_SIZE);
324  if (ntv->data == NULL) {
325  nflconfig->DerefFunc(nflconfig);
326  SCFree(ntv);
328  }
329 
330  ntv->datalen = T_DATA_SIZE;
331 #undef T_DATA_SIZE
332 
333  *data = (void *)ntv;
334 
335  nflconfig->DerefFunc(nflconfig);
337 }
338 
339 /**
340  * \brief DeInit function unbind group and close nflog's handle
341  * \param tv pointer to ThreadVars
342  * \param data pointer that gets cast into NFLogThreadVars
343  * \retval TM_ECODE_OK is always returned
344  */
345 TmEcode ReceiveNFLOGThreadDeinit(ThreadVars *tv, void *data)
346 {
347  NFLOGThreadVars *ntv = (NFLOGThreadVars *)data;
348 
349  SCLogDebug("closing nflog group %d", ntv->group);
350  if (nflog_unbind_pf(ntv->h, AF_INET) < 0) {
351  SCLogError(SC_ERR_NFLOG_UNBIND, "nflog_unbind_pf() for AF_INET failed");
352  exit(EXIT_FAILURE);
353  }
354 
355  if (nflog_unbind_pf(ntv->h, AF_INET6) < 0) {
356  SCLogError(SC_ERR_NFLOG_UNBIND, "nflog_unbind_pf() for AF_INET6 failed");
357  exit(EXIT_FAILURE);
358  }
359 
360  if (ntv->gh) {
361  nflog_unbind_group(ntv->gh);
362  ntv->gh = NULL;
363  }
364 
365  if (ntv->h) {
366  nflog_close(ntv->h);
367  ntv->h = NULL;
368  }
369 
370  if (ntv->data != NULL) {
371  SCFree(ntv->data);
372  ntv->data = NULL;
373  }
374  ntv->datalen = 0;
375 
376  SCFree(ntv);
377 
379 }
380 
381 /**
382  * \brief Increases netlink buffer size
383  *
384  * This function netlink's buffer size until
385  * the max buffer size is reached
386  *
387  * \param data pointer that gets cast into NFLOGThreadVars
388  * \param size netlink buffer size
389  */
390 static int NFLOGSetnlbufsiz(void *data, unsigned int size)
391 {
392  SCEnter();
393  NFLOGThreadVars *ntv = (NFLOGThreadVars *)data;
394 
395  if (size < ntv->nlbufsiz_max) {
396  ntv->nlbufsiz = nfnl_rcvbufsiz(nflog_nfnlh(ntv->h), ntv->nlbufsiz);
397  return 1;
398  }
399 
401  "Maximum buffer size (%d) in NFLOG has been "
402  "reached. Please, consider raising "
403  "`buffer-size` and `max-size` in nflog configuration",
404  ntv->nlbufsiz);
405  return 0;
406 
407 }
408 
409 /**
410  * \brief Recieves packets from a group via libnetfilter_log.
411  *
412  * This function recieves packets from a group and passes
413  * the packet on to the nflog callback function.
414  *
415  * \param tv pointer to ThreadVars
416  * \param data pointer that gets cast into NFLOGThreadVars
417  * \param slot slot containing task information
418  * \retval TM_ECODE_OK on success
419  * \retval TM_ECODE_FAILED on failure
420  */
421 TmEcode ReceiveNFLOGLoop(ThreadVars *tv, void *data, void *slot)
422 {
423  SCEnter();
424  NFLOGThreadVars *ntv = (NFLOGThreadVars *)data;
425  int rv, fd;
426  int ret = -1;
427 
428  ntv->slot = ((TmSlot *) slot)->slot_next;
429 
430  fd = nflog_fd(ntv->h);
431  if (fd < 0) {
432  SCLogError(SC_ERR_NFLOG_FD, "Can't obtain a file descriptor");
434  }
435 
436  while (1) {
437  if (suricata_ctl_flags != 0)
438  break;
439 
440  rv = recv(fd, ntv->data, ntv->datalen, 0);
441  if (rv < 0) {
442  /*We received an error on socket read */
443  if (errno == EINTR || errno == EWOULDBLOCK) {
444  /*Nothing for us to process */
445  continue;
446  } else if (errno == ENOBUFS) {
447  if (!ntv->nful_overrun_warned) {
448  int s = ntv->nlbufsiz * 2;
449  if (NFLOGSetnlbufsiz((void *)ntv, s)) {
451  "We are losing events, "
452  "increasing buffer size "
453  "to %d", ntv->nlbufsiz);
454  } else {
455  ntv->nful_overrun_warned = 1;
456  }
457  }
458  continue;
459  } else {
461  "Read from NFLOG fd failed: %s",
462  strerror(errno));
464  }
465  }
466 
467  ret = nflog_handle_packet(ntv->h, ntv->data, rv);
468  if (ret != 0)
470  "nflog_handle_packet error %" PRId32 "", ret);
471 
473  }
474 
476 }
477 
478 /**
479  * \brief This function prints stats to the screen at exit
480  * \param tv pointer to ThreadVars
481  * \param data pointer that gets cast into NFLOGThreadVars
482  */
483 void ReceiveNFLOGThreadExitStats(ThreadVars *tv, void *data)
484 {
485  SCEnter();
486  NFLOGThreadVars *ntv = (NFLOGThreadVars *)data;
487 
488  SCLogNotice("(%s) Pkts %" PRIu32 ", Bytes %" PRIu64 "",
489  tv->name, ntv->pkts, ntv->bytes);
490 }
491 
492 
493 /**
494  * \brief Decode IPv4/v6 packets.
495  *
496  * \param tv pointer to ThreadVars
497  * \param p pointer to the current packet
498  * \param data pointer that gets cast into NFLOGThreadVars for ptv
499  *
500  * \retval TM_ECODE_OK is always returned
501  */
502 TmEcode DecodeNFLOG(ThreadVars *tv, Packet *p, void *data)
503 {
504  SCEnter();
505  IPV4Hdr *ip4h = (IPV4Hdr *)GET_PKT_DATA(p);
506  IPV6Hdr *ip6h = (IPV6Hdr *)GET_PKT_DATA(p);
508 
510 
511  if (IPV4_GET_RAW_VER(ip4h) == 4) {
512  if (unlikely(GET_PKT_LEN(p) > USHRT_MAX)) {
513  return TM_ECODE_FAILED;
514  }
515  SCLogDebug("IPv4 packet");
517  } else if(IPV6_GET_RAW_VER(ip6h) == 6) {
518  if (unlikely(GET_PKT_LEN(p) > USHRT_MAX)) {
519  return TM_ECODE_FAILED;
520  }
521  SCLogDebug("IPv6 packet");
523  } else {
524  SCLogDebug("packet unsupported by NFLOG, first byte: %02x", *GET_PKT_DATA(p));
525  }
526 
528 
530 }
531 
532 /**
533  * \brief This an Init function for DecodeNFLOG
534  *
535  * \param tv pointer to ThreadVars
536  * \param initdata pointer to initilization data.
537  * \param data pointer that gets cast into NFLOGThreadVars
538  * \retval TM_ECODE_OK is returned on success
539  * \retval TM_ECODE_FAILED is returned on error
540  */
541 TmEcode DecodeNFLOGThreadInit(ThreadVars *tv, const void *initdata, void **data)
542 {
543  DecodeThreadVars *dtv = NULL;
545 
546  if (dtv == NULL)
548 
550 
551  *data = (void *)dtv;
552 
554 }
555 
556 TmEcode DecodeNFLOGThreadDeinit(ThreadVars *tv, void *data)
557 {
558  if (data != NULL)
559  DecodeThreadVarsFree(tv, data);
561 }
562 
563 #endif /* NFLOG */
SC_ERR_NFLOG_MAX_BUFSIZ
@ SC_ERR_NFLOG_MAX_BUFSIZ
Definition: util-error.h:282
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: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
unlikely
#define unlikely(expr)
Definition: util-optimize.h:35
SCLogDebug
#define SCLogDebug(...)
Definition: util-debug.h:298
threads.h
LiveDevice_
Definition: util-device.h:40
SC_ATOMIC_ADD
#define SC_ATOMIC_ADD(name, val)
add a value to our atomic variable
Definition: util-atomic.h:304
T_DATA_SIZE
#define T_DATA_SIZE
packet-queue.h
SC_ERR_NFLOG_OPEN
@ SC_ERR_NFLOG_OPEN
Definition: util-error.h:279
tm-modules.h
StatsSyncCountersIfSignalled
#define StatsSyncCountersIfSignalled(tv)
Definition: counters.h:137
PacketDecodeFinalize
void PacketDecodeFinalize(ThreadVars *tv, DecodeThreadVars *dtv, Packet *p)
Finalize decoding of a packet.
Definition: decode.c:118
RunmodeGetActive
char * RunmodeGetActive(void)
Definition: runmodes.c:187
NflogGroupConfig_::numgroup
char numgroup[NFLOG_GROUP_NAME_LENGTH]
Definition: source-nflog.h:47
TM_ECODE_FAILED
@ TM_ECODE_FAILED
Definition: tm-threads-common.h:79
SC_ERR_INVALID_ARGUMENTS
@ SC_ERR_INVALID_ARGUMENTS
Definition: util-error.h:82
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
TmModule_::ThreadDeinit
TmEcode(* ThreadDeinit)(ThreadVars *, void *)
Definition: tm-modules.h:49
Packet_::datalink
int datalink
Definition: decode.h:577
PKT_SET_SRC
#define PKT_SET_SRC(p, src_val)
Definition: decode.h:1128
TMM_DECODENFLOG
@ TMM_DECODENFLOG
Definition: tm-threads-common.h:61
SC_ERR_NFLOG_SET_MODE
@ SC_ERR_NFLOG_SET_MODE
Definition: util-error.h:283
TmModuleDecodeNFLOGRegister
void TmModuleDecodeNFLOGRegister(void)
Definition: source-nflog.c:54
DecodeRegisterPerfCounters
void DecodeRegisterPerfCounters(DecodeThreadVars *dtv, ThreadVars *tv)
Definition: decode.c:478
SET_PKT_LEN
#define SET_PKT_LEN(p, len)
Definition: decode.h:232
SC_WARN_NFLOG_SETSOCKOPT
@ SC_WARN_NFLOG_SETSOCKOPT
Definition: util-error.h:290
decode.h
util-device.h
PKT_SRC_WIRE
@ PKT_SRC_WIRE
Definition: decode.h:50
util-error.h
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
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
SC_WARN_NFLOG_LOSING_EVENTS
@ SC_WARN_NFLOG_LOSING_EVENTS
Definition: util-error.h:288
SC_ERR_INVALID_ARGUMENT
@ SC_ERR_INVALID_ARGUMENT
Definition: util-error.h:43
IPV6Hdr_
Definition: decode-ipv6.h:32
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
DecodeIPV6
int DecodeIPV6(ThreadVars *tv, DecodeThreadVars *dtv, Packet *p, const uint8_t *pkt, uint16_t len)
Definition: decode-ipv6.c:580
GET_PKT_LEN
#define GET_PKT_LEN(p)
Definition: decode.h:227
NflogGroupConfig_::qtimeout
uint32_t qtimeout
Definition: source-nflog.h:44
IPV4_GET_RAW_VER
#define IPV4_GET_RAW_VER(ip4h)
Definition: decode-ipv4.h:94
TmModule_::RegisterTests
void(* RegisterTests)(void)
Definition: tm-modules.h:65
TmSlot_
Definition: tm-threads.h:52
TmEcode
TmEcode
Definition: tm-threads-common.h:77
TmModule_::name
const char * name
Definition: tm-modules.h:44
runmodes.h
TmModuleReceiveNFLOGRegister
void TmModuleReceiveNFLOGRegister(void)
Definition: source-nflog.c:48
SC_ERR_NFLOG_FD
@ SC_ERR_NFLOG_FD
Definition: util-error.h:286
TM_FLAG_RECEIVE_TM
#define TM_FLAG_RECEIVE_TM
Definition: tm-modules.h:31
SC_WARN_NFLOG_RECV
@ SC_WARN_NFLOG_RECV
Definition: util-error.h:287
dtv
DecodeThreadVars * dtv
Definition: fuzz_decodepcapfile.c:30
IPV4Hdr_
Definition: decode-ipv4.h:71
tm-queuehandlers.h
NoNFLOGSupportExit
TmEcode NoNFLOGSupportExit(ThreadVars *, const void *, void **)
Definition: source-nflog.c:60
DecodeThreadVarsFree
void DecodeThreadVarsFree(ThreadVars *tv, DecodeThreadVars *dtv)
Definition: decode.c:638
group
uint8_t group
Definition: app-layer-dnp3.h:0
Packet_::ts
struct timeval ts
Definition: decode.h:454
suricata-common.h
SC_ERR_NFLOG_BIND
@ SC_ERR_NFLOG_BIND
Definition: util-error.h:280
SC_WARN_NFLOG_MAXBUFSIZ_REACHED
@ SC_WARN_NFLOG_MAXBUFSIZ_REACHED
Definition: util-error.h:289
SCLogError
#define SCLogError(err_code,...)
Macro used to log ERROR messages.
Definition: util-debug.h:257
TMM_RECEIVENFLOG
@ TMM_RECEIVENFLOG
Definition: tm-threads-common.h:60
TmModule_::ThreadInit
TmEcode(* ThreadInit)(ThreadVars *, const void *, void **)
Definition: tm-modules.h:47
NflogGroupConfig_::DerefFunc
void(* DerefFunc)(void *)
Definition: source-nflog.h:51
NflogGroupConfig_::group
uint16_t group
Definition: source-nflog.h:36
tv
ThreadVars * tv
Definition: fuzz_decodepcapfile.c:29
TmModule_::ThreadExitPrintStats
void(* ThreadExitPrintStats)(ThreadVars *, void *)
Definition: tm-modules.h:48
SC_ERR_NFLOG_UNBIND
@ SC_ERR_NFLOG_UNBIND
Definition: util-error.h:281
threadvars.h
SCMalloc
#define SCMalloc(sz)
Definition: util-mem.h:47
NflogGroupConfig_::qthreshold
uint32_t qthreshold
Definition: source-nflog.h:42
SCLogWarning
#define SCLogWarning(err_code,...)
Macro used to log WARNING messages.
Definition: util-debug.h:244
SCFree
#define SCFree(p)
Definition: util-mem.h:61
DecodeThreadVars_
Structure to hold thread specific data for all decode modules.
Definition: decode.h:625
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:619
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:658
suricata.h
SC_ERR_NFLOG_NOSUPPORT
@ SC_ERR_NFLOG_NOSUPPORT
Definition: util-error.h:278
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:517
SCLogNotice
#define SCLogNotice(...)
Macro used to log NOTICE messages.
Definition: util-debug.h:232
msg
const char * msg
Definition: app-layer-htp.c:571
StatsRegisterCounter
uint16_t StatsRegisterCounter(const char *name, struct ThreadVars_ *tv)
Registers a normal, unqualified counter.
Definition: counters.c:945
SCReturnInt
#define SCReturnInt(x)
Definition: util-debug.h:304
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
TmModule_::flags
uint8_t flags
Definition: tm-modules.h:70
SC_ERR_NFLOG_HANDLE_PKT
@ SC_ERR_NFLOG_HANDLE_PKT
Definition: util-error.h:284
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:585
NflogGroupConfig_::nlbufsiz
uint32_t nlbufsiz
Definition: source-nflog.h:38
suricata_ctl_flags
volatile uint8_t suricata_ctl_flags
Definition: suricata.c:198