suricata
decode.c
Go to the documentation of this file.
1 /* Copyright (C) 2007-2019 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  * \defgroup decode Packet decoding
20  *
21  * \brief Code in charge of protocol decoding
22  *
23  * The task of decoding packets is made in different files and
24  * as Suricata is supporting encapsulation there is a potential
25  * recursivity in the call.
26  *
27  * For each protocol a DecodePROTO function is provided. For
28  * example we have DecodeIPV4() for IPv4 and DecodePPP() for
29  * PPP.
30  *
31  * These functions have all a pkt and a len argument which
32  * are respectively a pointer to the protocol data and the length
33  * of this protocol data.
34  *
35  * \attention The pkt parameter must point to the effective data because
36  * it will be used later to set per protocol pointer like Packet::tcph
37  *
38  * @{
39  */
40 
41 
42 /**
43  * \file
44  *
45  * \author Victor Julien <victor@inliniac.net>
46  *
47  * Decode the raw packet
48  */
49 
50 #include "suricata-common.h"
51 #include "suricata.h"
52 #include "conf.h"
53 #include "decode.h"
54 #include "decode-teredo.h"
55 #include "util-debug.h"
56 #include "util-mem.h"
57 #include "app-layer-detect-proto.h"
58 #include "app-layer.h"
59 #include "tm-threads.h"
60 #include "util-error.h"
61 #include "util-print.h"
62 #include "tmqh-packetpool.h"
63 #include "util-profiling.h"
64 #include "pkt-var.h"
65 #include "util-mpm-ac.h"
66 #include "util-hash-string.h"
67 #include "output.h"
68 #include "output-flow.h"
69 #include "flow-storage.h"
70 #include "util-validate.h"
71 
72 uint32_t default_packet_size = 0;
73 extern bool stats_decoder_events;
74 extern const char *stats_decoder_events_prefix;
75 extern bool stats_stream_events;
77 
78 static int DecodeTunnel(ThreadVars *, DecodeThreadVars *, Packet *, const uint8_t *, uint32_t,
80 
81 static int DecodeTunnel(ThreadVars *tv, DecodeThreadVars *dtv, Packet *p, const uint8_t *pkt,
82  uint32_t len, enum DecodeTunnelProto proto)
83 {
84  switch (proto) {
85  case DECODE_TUNNEL_PPP:
86  return DecodePPP(tv, dtv, p, pkt, len);
87  case DECODE_TUNNEL_IPV4:
88  return DecodeIPV4(tv, dtv, p, pkt, len);
89  case DECODE_TUNNEL_IPV6:
91  return DecodeIPV6(tv, dtv, p, pkt, len);
92  case DECODE_TUNNEL_VLAN:
93  return DecodeVLAN(tv, dtv, p, pkt, len);
95  return DecodeEthernet(tv, dtv, p, pkt, len);
97  return DecodeERSPAN(tv, dtv, p, pkt, len);
99  return DecodeERSPANTypeI(tv, dtv, p, pkt, len);
100  case DECODE_TUNNEL_NSH:
101  return DecodeNSH(tv, dtv, p, pkt, len);
102  default:
103  SCLogDebug("FIXME: DecodeTunnel: protocol %" PRIu32 " not supported.", proto);
104  break;
105  }
106  return TM_ECODE_OK;
107 }
108 
109 /**
110  * \brief Return a malloced packet.
111  */
113 {
115  SCFree(p);
116 }
117 
118 /**
119  * \brief Finalize decoding of a packet
120  *
121  * This function needs to be call at the end of decode
122  * functions when decoding has been successful.
123  *
124  */
126 {
127  if (p->flags & PKT_IS_INVALID) {
129  }
130 }
131 
134 {
135  for (uint8_t i = 0; i < p->events.cnt; i++) {
136  const uint8_t e = p->events.events[i];
137 
139  continue;
141  continue;
143  }
144 }
145 
146 /**
147  * \brief Get a malloced packet.
148  *
149  * \retval p packet, NULL on error
150  */
152 {
154  if (unlikely(p == NULL)) {
155  return NULL;
156  }
157 
158  memset(p, 0, SIZE_OF_PACKET);
161  p->flags |= PKT_ALLOC;
162 
163  SCLogDebug("allocated a new packet only using alloc...");
164 
166  return p;
167 }
168 
169 /**
170  * \brief Return a packet to where it was allocated.
171  */
173 {
174  if (p->flags & PKT_ALLOC)
175  PacketFree(p);
176  else {
179  }
180 }
181 
182 /**
183  * \brief Get a packet. We try to get a packet from the packetpool first, but
184  * if that is empty we alloc a packet that is free'd again after
185  * processing.
186  *
187  * \retval p packet, NULL on error
188  */
190 {
191  /* try the pool first */
193 
194  if (p == NULL) {
195  /* non fatal, we're just not processing a packet then */
196  p = PacketGetFromAlloc();
197  } else {
200  }
201 
202  return p;
203 }
204 
205 inline int PacketCallocExtPkt(Packet *p, int datalen)
206 {
207  if (! p->ext_pkt) {
208  p->ext_pkt = SCCalloc(1, datalen);
209  if (unlikely(p->ext_pkt == NULL)) {
210  SET_PKT_LEN(p, 0);
211  return -1;
212  }
213  }
214  return 0;
215 }
216 
217 /**
218  * \brief Copy data to Packet payload at given offset
219  *
220  * This function copies data/payload to a Packet. It uses the
221  * space allocated at Packet creation (pointed by Packet::pkt)
222  * or allocate some memory (pointed by Packet::ext_pkt) if the
223  * data size is to big to fit in initial space (of size
224  * default_packet_size).
225  *
226  * \param Pointer to the Packet to modify
227  * \param Offset of the copy relatively to payload of Packet
228  * \param Pointer to the data to copy
229  * \param Length of the data to copy
230  */
231 inline int PacketCopyDataOffset(Packet *p, uint32_t offset, const uint8_t *data, uint32_t datalen)
232 {
233  if (unlikely(offset + datalen > MAX_PAYLOAD_SIZE)) {
234  /* too big */
235  SET_PKT_LEN(p, 0);
236  return -1;
237  }
238 
239  /* Do we have already an packet with allocated data */
240  if (! p->ext_pkt) {
241  uint32_t newsize = offset + datalen;
242  // check overflow
243  if (newsize < offset)
244  return -1;
245  if (newsize <= default_packet_size) {
246  /* data will fit in memory allocated with packet */
247  memcpy(GET_PKT_DIRECT_DATA(p) + offset, data, datalen);
248  } else {
249  /* here we need a dynamic allocation */
251  if (unlikely(p->ext_pkt == NULL)) {
252  SET_PKT_LEN(p, 0);
253  return -1;
254  }
255  /* copy initial data */
257  /* copy data as asked */
258  memcpy(p->ext_pkt + offset, data, datalen);
259  }
260  } else {
261  memcpy(p->ext_pkt + offset, data, datalen);
262  }
263  return 0;
264 }
265 
266 /**
267  * \brief Copy data to Packet payload and set packet length
268  *
269  * \param Pointer to the Packet to modify
270  * \param Pointer to the data to copy
271  * \param Length of the data to copy
272  */
273 inline int PacketCopyData(Packet *p, const uint8_t *pktdata, uint32_t pktlen)
274 {
275  SET_PKT_LEN(p, (size_t)pktlen);
276  return PacketCopyDataOffset(p, 0, pktdata, pktlen);
277 }
278 
279 /**
280  * \brief Setup a pseudo packet (tunnel)
281  *
282  * \param parent parent packet for this pseudo pkt
283  * \param pkt raw packet data
284  * \param len packet data length
285  * \param proto protocol of the tunneled packet
286  *
287  * \retval p the pseudo packet or NULL if out of memory
288  */
290  const uint8_t *pkt, uint32_t len, enum DecodeTunnelProto proto)
291 {
292  int ret;
293 
294  SCEnter();
295 
296  /* get us a packet */
298  if (unlikely(p == NULL)) {
299  SCReturnPtr(NULL, "Packet");
300  }
301 
302  /* copy packet and set length, proto */
303  PacketCopyData(p, pkt, len);
304  p->recursion_level = parent->recursion_level + 1;
305  p->ts.tv_sec = parent->ts.tv_sec;
306  p->ts.tv_usec = parent->ts.tv_usec;
307  p->datalink = DLT_RAW;
308  p->tenant_id = parent->tenant_id;
309  p->livedev = parent->livedev;
310 
311  /* set the root ptr to the lowest layer */
312  if (parent->root != NULL)
313  p->root = parent->root;
314  else
315  p->root = parent;
316 
317  /* tell new packet it's part of a tunnel */
318  SET_TUNNEL_PKT(p);
319 
320  ret = DecodeTunnel(tv, dtv, p, GET_PKT_DATA(p),
321  GET_PKT_LEN(p), proto);
322 
323  if (unlikely(ret != TM_ECODE_OK) ||
325  {
326  /* Not a (valid) tunnel packet */
327  SCLogDebug("tunnel packet is invalid");
328 
329  p->root = NULL;
330  UNSET_TUNNEL_PKT(p);
332  SCReturnPtr(NULL, "Packet");
333  }
334 
335 
336  /* tell parent packet it's part of a tunnel */
337  SET_TUNNEL_PKT(parent);
338 
339  /* increment tunnel packet refcnt in the root packet */
341 
342  /* disable payload (not packet) inspection on the parent, as the payload
343  * is the packet we will now run through the system separately. We do
344  * check it against the ip/port/other header checks though */
346  SCReturnPtr(p, "Packet");
347 }
348 
349 /**
350  * \brief Setup a pseudo packet (reassembled frags)
351  *
352  * Difference with PacketPseudoPktSetup is that this func doesn't increment
353  * the recursion level. It needs to be on the same level as the frags because
354  * we run the flow engine against this and we need to get the same flow.
355  *
356  * \param parent parent packet for this pseudo pkt
357  * \param pkt raw packet data
358  * \param len packet data length
359  * \param proto protocol of the tunneled packet
360  *
361  * \retval p the pseudo packet or NULL if out of memory
362  */
363 Packet *PacketDefragPktSetup(Packet *parent, const uint8_t *pkt, uint32_t len, uint8_t proto)
364 {
365  SCEnter();
366 
367  /* get us a packet */
369  if (unlikely(p == NULL)) {
370  SCReturnPtr(NULL, "Packet");
371  }
372 
373  /* set the root ptr to the lowest layer */
374  if (parent->root != NULL)
375  p->root = parent->root;
376  else
377  p->root = parent;
378 
379  /* copy packet and set length, proto */
380  if (pkt && len) {
381  PacketCopyData(p, pkt, len);
382  }
383  p->recursion_level = parent->recursion_level; /* NOT incremented */
384  p->ts.tv_sec = parent->ts.tv_sec;
385  p->ts.tv_usec = parent->ts.tv_usec;
386  p->datalink = DLT_RAW;
387  p->tenant_id = parent->tenant_id;
388  /* tell new packet it's part of a tunnel */
389  SET_TUNNEL_PKT(p);
390  p->vlan_id[0] = parent->vlan_id[0];
391  p->vlan_id[1] = parent->vlan_id[1];
392  p->vlan_idx = parent->vlan_idx;
393  p->livedev = parent->livedev;
394 
395  SCReturnPtr(p, "Packet");
396 }
397 
398 /**
399  * \brief inform defrag "parent" that a pseudo packet is
400  * now associated to it.
401  */
403 {
404  /* tell parent packet it's part of a tunnel */
405  SET_TUNNEL_PKT(parent);
406 
407  /* increment tunnel packet refcnt in the root packet */
408  TUNNEL_INCR_PKT_TPR(parent);
409 
410  /* disable payload (not packet) inspection on the parent, as the payload
411  * is the packet we will now run through the system separately. We do
412  * check it against the ip/port/other header checks though */
414 }
415 
416 /**
417  * \note if p->flow is set, the flow is locked
418  */
420 {
421  if (PKT_IS_PSEUDOPKT(p))
422  return;
423 
424 #ifdef CAPTURE_OFFLOAD
425  /* Don't try to bypass if flow is already out or
426  * if we have failed to do it once */
427  if (p->flow) {
428  int state = p->flow->flow_state;
429  if ((state == FLOW_STATE_LOCAL_BYPASSED) ||
430  (state == FLOW_STATE_CAPTURE_BYPASSED)) {
431  return;
432  }
433  FlowBypassInfo *fc = SCCalloc(sizeof(FlowBypassInfo), 1);
434  if (fc) {
436  } else {
437  return;
438  }
439  }
440  if (p->BypassPacketsFlow && p->BypassPacketsFlow(p)) {
441  if (p->flow) {
442  FlowUpdateState(p->flow, FLOW_STATE_CAPTURE_BYPASSED);
443  }
444  } else {
445  if (p->flow) {
447  }
448  }
449 #else /* CAPTURE_OFFLOAD */
450  if (p->flow) {
451  int state = p->flow->flow_state;
452  if (state == FLOW_STATE_LOCAL_BYPASSED)
453  return;
455  }
456 #endif
457 }
458 
459 /** \brief switch direction of a packet */
461 {
462  if (PKT_IS_TOSERVER(p)) {
465 
469  }
470  } else {
473 
477  }
478  }
479 }
480 
481 /* counter name store */
482 static HashTable *g_counter_table = NULL;
483 static SCMutex g_counter_table_mutex = SCMUTEX_INITIALIZER;
484 
486 {
487  SCMutexLock(&g_counter_table_mutex);
488  if (g_counter_table) {
489  HashTableFree(g_counter_table);
490  g_counter_table = NULL;
491  }
492  SCMutexUnlock(&g_counter_table_mutex);
493 }
494 
496 {
497  /* register counters */
498  dtv->counter_pkts = StatsRegisterCounter("decoder.pkts", tv);
499  dtv->counter_bytes = StatsRegisterCounter("decoder.bytes", tv);
500  dtv->counter_invalid = StatsRegisterCounter("decoder.invalid", tv);
501  dtv->counter_ipv4 = StatsRegisterCounter("decoder.ipv4", tv);
502  dtv->counter_ipv6 = StatsRegisterCounter("decoder.ipv6", tv);
503  dtv->counter_eth = StatsRegisterCounter("decoder.ethernet", tv);
504  dtv->counter_chdlc = StatsRegisterCounter("decoder.chdlc", tv);
505  dtv->counter_raw = StatsRegisterCounter("decoder.raw", tv);
506  dtv->counter_null = StatsRegisterCounter("decoder.null", tv);
507  dtv->counter_sll = StatsRegisterCounter("decoder.sll", tv);
508  dtv->counter_tcp = StatsRegisterCounter("decoder.tcp", tv);
509  dtv->counter_udp = StatsRegisterCounter("decoder.udp", tv);
510  dtv->counter_sctp = StatsRegisterCounter("decoder.sctp", tv);
511  dtv->counter_esp = StatsRegisterCounter("decoder.esp", tv);
512  dtv->counter_icmpv4 = StatsRegisterCounter("decoder.icmpv4", tv);
513  dtv->counter_icmpv6 = StatsRegisterCounter("decoder.icmpv6", tv);
514  dtv->counter_ppp = StatsRegisterCounter("decoder.ppp", tv);
515  dtv->counter_pppoe = StatsRegisterCounter("decoder.pppoe", tv);
516  dtv->counter_geneve = StatsRegisterCounter("decoder.geneve", tv);
517  dtv->counter_gre = StatsRegisterCounter("decoder.gre", tv);
518  dtv->counter_vlan = StatsRegisterCounter("decoder.vlan", tv);
519  dtv->counter_vlan_qinq = StatsRegisterCounter("decoder.vlan_qinq", tv);
520  dtv->counter_vxlan = StatsRegisterCounter("decoder.vxlan", tv);
521  dtv->counter_vntag = StatsRegisterCounter("decoder.vntag", tv);
522  dtv->counter_ieee8021ah = StatsRegisterCounter("decoder.ieee8021ah", tv);
523  dtv->counter_teredo = StatsRegisterCounter("decoder.teredo", tv);
524  dtv->counter_ipv4inipv6 = StatsRegisterCounter("decoder.ipv4_in_ipv6", tv);
525  dtv->counter_ipv6inipv6 = StatsRegisterCounter("decoder.ipv6_in_ipv6", tv);
526  dtv->counter_mpls = StatsRegisterCounter("decoder.mpls", tv);
527  dtv->counter_avg_pkt_size = StatsRegisterAvgCounter("decoder.avg_pkt_size", tv);
528  dtv->counter_max_pkt_size = StatsRegisterMaxCounter("decoder.max_pkt_size", tv);
529  dtv->counter_max_mac_addrs_src = StatsRegisterMaxCounter("decoder.max_mac_addrs_src", tv);
530  dtv->counter_max_mac_addrs_dst = StatsRegisterMaxCounter("decoder.max_mac_addrs_dst", tv);
531  dtv->counter_erspan = StatsRegisterMaxCounter("decoder.erspan", tv);
532  dtv->counter_nsh = StatsRegisterMaxCounter("decoder.nsh", tv);
533  dtv->counter_flow_memcap = StatsRegisterCounter("flow.memcap", tv);
534 
537  dtv->counter_flow_icmp4 = StatsRegisterCounter("flow.icmpv4", tv);
538  dtv->counter_flow_icmp6 = StatsRegisterCounter("flow.icmpv6", tv);
539  dtv->counter_flow_tcp_reuse = StatsRegisterCounter("flow.tcp_reuse", tv);
540  dtv->counter_flow_get_used = StatsRegisterCounter("flow.get_used", tv);
541  dtv->counter_flow_get_used_eval = StatsRegisterCounter("flow.get_used_eval", tv);
542  dtv->counter_flow_get_used_eval_reject = StatsRegisterCounter("flow.get_used_eval_reject", tv);
543  dtv->counter_flow_get_used_eval_busy = StatsRegisterCounter("flow.get_used_eval_busy", tv);
544  dtv->counter_flow_get_used_failed = StatsRegisterCounter("flow.get_used_failed", tv);
545 
546  dtv->counter_flow_spare_sync_avg = StatsRegisterAvgCounter("flow.wrk.spare_sync_avg", tv);
547  dtv->counter_flow_spare_sync = StatsRegisterCounter("flow.wrk.spare_sync", tv);
548  dtv->counter_flow_spare_sync_incomplete = StatsRegisterCounter("flow.wrk.spare_sync_incomplete", tv);
549  dtv->counter_flow_spare_sync_empty = StatsRegisterCounter("flow.wrk.spare_sync_empty", tv);
550 
552  StatsRegisterCounter("defrag.ipv4.fragments", tv);
554  StatsRegisterCounter("defrag.ipv4.reassembled", tv);
556  StatsRegisterCounter("defrag.ipv4.timeouts", tv);
558  StatsRegisterCounter("defrag.ipv6.fragments", tv);
560  StatsRegisterCounter("defrag.ipv6.reassembled", tv);
562  StatsRegisterCounter("defrag.ipv6.timeouts", tv);
564  StatsRegisterCounter("defrag.max_frag_hits", tv);
565 
566  for (int i = 0; i < DECODE_EVENT_MAX; i++) {
567  BUG_ON(i != (int)DEvents[i].code);
568 
570  continue;
572  continue;
573 
574  if (i < DECODE_EVENT_PACKET_MAX &&
575  strncmp(DEvents[i].event_name, "decoder.", 8) == 0)
576  {
577  SCMutexLock(&g_counter_table_mutex);
578  if (g_counter_table == NULL) {
579  g_counter_table = HashTableInit(256, StringHashFunc,
582  if (g_counter_table == NULL) {
583  FatalError(SC_ERR_INITIALIZATION, "decoder counter hash "
584  "table init failed");
585  }
586  }
587 
588  char name[256];
589  char *dot = strchr(DEvents[i].event_name, '.');
590  BUG_ON(!dot);
591  snprintf(name, sizeof(name), "%s.%s",
593 
594  const char *found = HashTableLookup(g_counter_table, name, 0);
595  if (!found) {
596  char *add = SCStrdup(name);
597  if (add == NULL)
598  FatalError(SC_ERR_INITIALIZATION, "decoder counter hash "
599  "table name init failed");
600  int r = HashTableAdd(g_counter_table, add, 0);
601  if (r != 0)
602  FatalError(SC_ERR_INITIALIZATION, "decoder counter hash "
603  "table name add failed");
604  found = add;
605  }
607  found, tv);
608 
609  SCMutexUnlock(&g_counter_table_mutex);
610  } else {
612  DEvents[i].event_name, tv);
613  }
614  }
615 
616  return;
617 }
618 
620  const DecodeThreadVars *dtv, const Packet *p)
621 {
623  //StatsIncr(tv, dtv->counter_pkts_per_sec);
627 }
628 
629 /**
630  * \brief Debug print function for printing addresses
631  *
632  * \param Address object
633  *
634  * \todo IPv6
635  */
637 {
638  if (a == NULL)
639  return;
640 
641  switch (a->family) {
642  case AF_INET:
643  {
644  char s[16];
645  PrintInet(AF_INET, (const void *)&a->addr_data32[0], s, sizeof(s));
646  SCLogDebug("%s", s);
647  break;
648  }
649  }
650 }
651 
652 /** \brief Alloc and setup DecodeThreadVars */
654 {
655  DecodeThreadVars *dtv = NULL;
656 
657  if ( (dtv = SCMalloc(sizeof(DecodeThreadVars))) == NULL)
658  return NULL;
659  memset(dtv, 0, sizeof(DecodeThreadVars));
660 
662 
664  SCLogError(SC_ERR_THREAD_INIT, "initializing flow log API for thread failed");
666  return NULL;
667  }
668 
669  return dtv;
670 }
671 
673 {
674  if (dtv != NULL) {
675  if (dtv->app_tctx != NULL)
677 
678  if (dtv->output_flow_thread_data != NULL)
680 
681  SCFree(dtv);
682  }
683 }
684 
685 /**
686  * \brief Set data for Packet and set length when zero copy is used
687  *
688  * \param Pointer to the Packet to modify
689  * \param Pointer to the data
690  * \param Length of the data
691  */
692 inline int PacketSetData(Packet *p, const uint8_t *pktdata, uint32_t pktlen)
693 {
694  SET_PKT_LEN(p, (size_t)pktlen);
695  if (unlikely(!pktdata)) {
696  return -1;
697  }
698  // ext_pkt cannot be const (because we sometimes copy)
699  p->ext_pkt = (uint8_t *) pktdata;
700  p->flags |= PKT_ZERO_COPY;
701 
702  return 0;
703 }
704 
705 const char *PktSrcToString(enum PktSrcEnum pkt_src)
706 {
707  const char *pkt_src_str = "<unknown>";
708  switch (pkt_src) {
709  case PKT_SRC_WIRE:
710  pkt_src_str = "wire/pcap";
711  break;
712  case PKT_SRC_DECODER_GRE:
713  pkt_src_str = "gre tunnel";
714  break;
716  pkt_src_str = "ipv4 tunnel";
717  break;
719  pkt_src_str = "ipv6 tunnel";
720  break;
722  pkt_src_str = "teredo tunnel";
723  break;
724  case PKT_SRC_DEFRAG:
725  pkt_src_str = "defrag";
726  break;
728  pkt_src_str = "stream (detect/log)";
729  break;
730  case PKT_SRC_FFR:
731  pkt_src_str = "stream (flow timeout)";
732  break;
734  pkt_src_str = "geneve encapsulation";
735  break;
737  pkt_src_str = "vxlan encapsulation";
738  break;
740  pkt_src_str = "detect reload flush";
741  break;
743  pkt_src_str = "capture timeout flush";
744  break;
745  }
746  return pkt_src_str;
747 }
748 
750 {
751  if (unlikely(PacketTestAction(p, (ACTION_REJECT | ACTION_REJECT_DST | ACTION_REJECT_BOTH)))) {
753  } else if (unlikely(PacketTestAction(p, ACTION_DROP))) {
755  } else if (unlikely(p->flags & PKT_STREAM_MODIFIED)) {
757  } else {
759  }
760 }
761 
763 {
764  s->counter_ips_accepted = StatsRegisterCounter("ips.accepted", tv);
765  s->counter_ips_blocked = StatsRegisterCounter("ips.blocked", tv);
766  s->counter_ips_rejected = StatsRegisterCounter("ips.rejected", tv);
767  s->counter_ips_replaced = StatsRegisterCounter("ips.replaced", tv);
768 }
769 
771 {
776  intmax_t value = 0;
777  if (ConfGetInt("decoder.max-layers", &value) == 1) {
778  if (value < 0 || value > UINT8_MAX) {
779  SCLogWarning(SC_ERR_INVALID_VALUE, "Invalid value for decoder.max-layers");
780  } else {
781  decoder_max_layers = value;
782  }
783  }
784 }
785 
786 /**
787  * @}
788  */
DecodeThreadVars_::counter_flow_get_used_eval_busy
uint16_t counter_flow_get_used_eval_busy
Definition: decode.h:710
tm-threads.h
ConfGetInt
int ConfGetInt(const char *name, intmax_t *val)
Retrieve a configuration value as an integer.
Definition: conf.c:436
DecodeThreadVars_::counter_defrag_ipv4_reassembled
uint16_t counter_defrag_ipv4_reassembled
Definition: decode.h:693
util-hash-string.h
DecodeThreadVars_::counter_flow_udp
uint16_t counter_flow_udp
Definition: decode.h:703
len
uint8_t len
Definition: app-layer-dnp3.h:2
DecodeThreadVars_::counter_bytes
uint16_t counter_bytes
Definition: decode.h:653
DECODE_TUNNEL_IPV6
@ DECODE_TUNNEL_IPV6
Definition: decode.h:947
CaptureStats_::counter_ips_blocked
uint16_t counter_ips_blocked
Definition: decode.h:729
DecodeThreadVars_::counter_eth
uint16_t counter_eth
Definition: decode.h:661
StatsIncr
void StatsIncr(ThreadVars *tv, uint16_t id)
Increments the local counter.
Definition: counters.c:169
offset
uint64_t offset
Definition: util-streaming-buffer.h:0
DecodeERSPAN
int DecodeERSPAN(ThreadVars *tv, DecodeThreadVars *dtv, Packet *p, const uint8_t *pkt, uint32_t len)
ERSPAN Type II.
Definition: decode-erspan.c:76
PacketFreeOrRelease
void PacketFreeOrRelease(Packet *p)
Return a packet to where it was allocated.
Definition: decode.c:172
SC_ERR_INVALID_VALUE
@ SC_ERR_INVALID_VALUE
Definition: util-error.h:160
DecodeThreadVars_::counter_flow_icmp4
uint16_t counter_flow_icmp4
Definition: decode.h:704
DecodeThreadVars_::counter_vxlan
uint16_t counter_vxlan
Definition: decode.h:680
DecodeThreadVars_::counter_max_pkt_size
uint16_t counter_max_pkt_size
Definition: decode.h:655
DecodePPP
int DecodePPP(ThreadVars *tv, DecodeThreadVars *dtv, Packet *p, const uint8_t *pkt, uint32_t len)
Definition: decode-ppp.c:44
PacketCopyData
int PacketCopyData(Packet *p, const uint8_t *pktdata, uint32_t pktlen)
Copy data to Packet payload and set packet length.
Definition: decode.c:273
Packet_::vlan_id
uint16_t vlan_id[2]
Definition: decode.h:447
PacketBypassCallback
void PacketBypassCallback(Packet *p)
Definition: decode.c:419
PKT_IS_PSEUDOPKT
#define PKT_IS_PSEUDOPKT(p)
return 1 if the packet is a pseudo packet
Definition: decode.h:1210
DecodeThreadVars_::counter_avg_pkt_size
uint16_t counter_avg_pkt_size
Definition: decode.h:654
DecodeERSPANConfig
void DecodeERSPANConfig(void)
Functions to decode ERSPAN Type I and II packets.
Definition: decode-erspan.c:52
PacketPoolReturnPacket
void PacketPoolReturnPacket(Packet *p)
Return packet to Packet pool.
Definition: tmqh-packetpool.c:225
GetFlowBypassInfoID
FlowStorageId GetFlowBypassInfoID(void)
Definition: flow-util.c:220
FlowBypassInfo_
Definition: flow.h:529
unlikely
#define unlikely(expr)
Definition: util-optimize.h:35
DecodeNSH
int DecodeNSH(ThreadVars *tv, DecodeThreadVars *dtv, Packet *p, const uint8_t *pkt, uint32_t len)
Function to decode NSH packets.
Definition: decode-nsh.c:46
ACTION_REJECT
#define ACTION_REJECT
Definition: action-globals.h:31
DecodeTeredoConfig
void DecodeTeredoConfig(void)
Definition: decode-teredo.c:103
PacketEngineEvents_::events
uint8_t events[PACKET_ENGINE_EVENT_MAX]
Definition: decode.h:319
CaptureStats_
Definition: decode.h:726
PKT_STREAM_MODIFIED
#define PKT_STREAM_MODIFIED
Definition: decode.h:1166
DECODE_TUNNEL_IPV6_TEREDO
@ DECODE_TUNNEL_IPV6_TEREDO
Definition: decode.h:948
SCLogDebug
#define SCLogDebug(...)
Definition: util-debug.h:298
AddressDebugPrint
void AddressDebugPrint(Address *a)
Debug print function for printing addresses.
Definition: decode.c:636
PKT_SRC_DECODER_IPV4
@ PKT_SRC_DECODER_IPV4
Definition: decode.h:53
DecodeThreadVars_::counter_flow_spare_sync_avg
uint16_t counter_flow_spare_sync_avg
Definition: decode.h:716
PacketDefragPktSetup
Packet * PacketDefragPktSetup(Packet *parent, const uint8_t *pkt, uint32_t len, uint8_t proto)
Setup a pseudo packet (reassembled frags)
Definition: decode.c:363
stats_stream_events
bool stats_stream_events
Definition: counters.c:106
PKT_ZERO_COPY
#define PKT_ZERO_COPY
Definition: decode.h:1179
PKT_SRC_CAPTURE_TIMEOUT
@ PKT_SRC_CAPTURE_TIMEOUT
Definition: decode.h:61
Packet_::flags
uint32_t flags
Definition: decode.h:455
DecodeThreadVars_::counter_vntag
uint16_t counter_vntag
Definition: decode.h:681
Packet_::vlan_idx
uint8_t vlan_idx
Definition: decode.h:448
DecodeThreadVars_::counter_flow_get_used_eval
uint16_t counter_flow_get_used_eval
Definition: decode.h:708
StatsSetUI64
void StatsSetUI64(ThreadVars *tv, uint16_t id, uint64_t x)
Sets a value of type double to the local counter.
Definition: counters.c:191
DECODE_TUNNEL_ERSPANI
@ DECODE_TUNNEL_ERSPANI
Definition: decode.h:944
DecodeThreadVars_::counter_teredo
uint16_t counter_teredo
Definition: decode.h:684
DecodeThreadVars_::counter_erspan
uint16_t counter_erspan
Definition: decode.h:688
PacketCopyDataOffset
int PacketCopyDataOffset(Packet *p, uint32_t offset, const uint8_t *data, uint32_t datalen)
Copy data to Packet payload at given offset.
Definition: decode.c:231
DecodeThreadVars_::counter_raw
uint16_t counter_raw
Definition: decode.h:671
SCMutexLock
#define SCMutexLock(mut)
Definition: threads-debug.h:117
FLOW_PKT_TOSERVER
#define FLOW_PKT_TOSERVER
Definition: flow.h:225
HashTable_
Definition: util-hash.h:35
PACKET_INITIALIZE
#define PACKET_INITIALIZE(p)
Initialize a packet structure for use.
Definition: decode.h:763
Address_
Definition: decode.h:122
DecodeThreadVars_::counter_flow_tcp
uint16_t counter_flow_tcp
Definition: decode.h:702
SCMUTEX_INITIALIZER
#define SCMUTEX_INITIALIZER
Definition: threads-debug.h:121
PacketDecodeFinalize
void PacketDecodeFinalize(ThreadVars *tv, DecodeThreadVars *dtv, Packet *p)
Finalize decoding of a packet.
Definition: decode.c:125
proto
uint8_t proto
Definition: decode-template.h:0
decoder_max_layers
uint8_t decoder_max_layers
Definition: decode.c:76
SET_TUNNEL_PKT
#define SET_TUNNEL_PKT(p)
Definition: decode.h:934
Packet_::flowflags
uint8_t flowflags
Definition: decode.h:451
StringHashCompareFunc
char StringHashCompareFunc(void *data1, uint16_t datalen1, void *data2, uint16_t datalen2)
Definition: util-hash-string.c:38
Packet_::BypassPacketsFlow
int(* BypassPacketsFlow)(struct Packet_ *)
Definition: decode.h:505
TmqhOutputPacketpool
void TmqhOutputPacketpool(ThreadVars *t, Packet *p)
Definition: tmqh-packetpool.c:375
DecodeVXLANConfig
void DecodeVXLANConfig(void)
Definition: decode-vxlan.c:102
DecodeThreadVars_::counter_max_mac_addrs_src
uint16_t counter_max_mac_addrs_src
Definition: decode.h:656
DecodeUnregisterCounters
void DecodeUnregisterCounters(void)
Definition: decode.c:485
GET_PKT_DIRECT_MAX_SIZE
#define GET_PKT_DIRECT_MAX_SIZE(p)
Definition: decode.h:238
DecodeThreadVars_::counter_flow_get_used
uint16_t counter_flow_get_used
Definition: decode.h:707
tmqh-packetpool.h
StringHashFunc
uint32_t StringHashFunc(HashTable *ht, void *data, uint16_t datalen)
Definition: util-hash-string.c:33
Packet_::events
PacketEngineEvents events
Definition: decode.h:585
PKT_ALLOC
#define PKT_ALLOC
Definition: decode.h:1152
TM_ECODE_OK
@ TM_ECODE_OK
Definition: tm-threads-common.h:82
HashTableFree
void HashTableFree(HashTable *ht)
Definition: util-hash.c:79
DecodeThreadVars_::counter_flow_spare_sync_empty
uint16_t counter_flow_spare_sync_empty
Definition: decode.h:714
Flow_::flow_state
FlowStateType flow_state
Definition: flow.h:422
DecodeThreadVars_::counter_flow_tcp_reuse
uint16_t counter_flow_tcp_reuse
Definition: decode.h:706
DECODE_TUNNEL_NSH
@ DECODE_TUNNEL_NSH
Definition: decode.h:950
Packet_::datalink
int datalink
Definition: decode.h:594
PKT_DEFAULT_MAX_DECODED_LAYERS
#define PKT_DEFAULT_MAX_DECODED_LAYERS
Definition: decode.h:1215
stats_decoder_events_prefix
const char * stats_decoder_events_prefix
Definition: counters.c:104
ACTION_REJECT_DST
#define ACTION_REJECT_DST
Definition: action-globals.h:32
SC_ERR_THREAD_INIT
@ SC_ERR_THREAD_INIT
Definition: util-error.h:79
DecodeRegisterPerfCounters
void DecodeRegisterPerfCounters(DecodeThreadVars *dtv, ThreadVars *tv)
Definition: decode.c:495
DecodeThreadVars_::counter_flow_spare_sync
uint16_t counter_flow_spare_sync
Definition: decode.h:713
DECODE_TUNNEL_ERSPANII
@ DECODE_TUNNEL_ERSPANII
Definition: decode.h:943
SET_PKT_LEN
#define SET_PKT_LEN(p, len)
Definition: decode.h:240
DecodeThreadVars_::counter_ipv6inipv6
uint16_t counter_ipv6inipv6
Definition: decode.h:687
app-layer-detect-proto.h
StatsRegisterMaxCounter
uint16_t StatsRegisterMaxCounter(const char *name, struct ThreadVars_ *tv)
Registers a counter, whose value holds the maximum of all the values assigned to it.
Definition: counters.c:982
FLOW_STATE_LOCAL_BYPASSED
@ FLOW_STATE_LOCAL_BYPASSED
Definition: flow.h:512
decode.h
util-debug.h
DecodeThreadVars_::counter_flow_get_used_failed
uint16_t counter_flow_get_used_failed
Definition: decode.h:711
PKT_SRC_WIRE
@ PKT_SRC_WIRE
Definition: decode.h:51
CaptureStats_::counter_ips_rejected
uint16_t counter_ips_rejected
Definition: decode.h:730
util-error.h
PKT_IS_TOSERVER
#define PKT_IS_TOSERVER(p)
Definition: decode.h:268
DecodeThreadVars_::counter_icmpv4
uint16_t counter_icmpv4
Definition: decode.h:667
DecodeThreadVars_::counter_ppp
uint16_t counter_ppp
Definition: decode.h:675
DECODE_EVENT_PACKET_MAX
@ DECODE_EVENT_PACKET_MAX
Definition: decode-events.h:223
DecodeERSPANTypeI
int DecodeERSPANTypeI(ThreadVars *tv, DecodeThreadVars *dtv, Packet *p, const uint8_t *pkt, uint32_t len)
ERSPAN Type I.
Definition: decode-erspan.c:65
DEvents
const struct DecodeEvents_ DEvents[]
Definition: decode-events.c:29
OutputFlowLogThreadInit
TmEcode OutputFlowLogThreadInit(ThreadVars *tv, void *initdata, void **data)
thread init for the flow logger This will run the thread init functions for the individual registered...
Definition: output-flow.c:131
SCMutexUnlock
#define SCMutexUnlock(mut)
Definition: threads-debug.h:119
PacketSwap
void PacketSwap(Packet *p)
switch direction of a packet
Definition: decode.c:460
DecodeSetNoPayloadInspectionFlag
#define DecodeSetNoPayloadInspectionFlag(p)
Set the No payload inspection Flag for the packet.
Definition: decode.h:1025
PktSrcEnum
PktSrcEnum
Definition: decode.h:50
DecodeTunnelProto
DecodeTunnelProto
Definition: decode.h:941
util-print.h
CaptureStatsSetup
void CaptureStatsSetup(ThreadVars *tv, CaptureStats *s)
Definition: decode.c:762
PKT_SRC_DECODER_TEREDO
@ PKT_SRC_DECODER_TEREDO
Definition: decode.h:55
AppLayerGetCtxThread
AppLayerThreadCtx * AppLayerGetCtxThread(ThreadVars *tv)
Creates a new app layer thread context.
Definition: app-layer.c:878
SCEnter
#define SCEnter(...)
Definition: util-debug.h:300
GET_PKT_DATA
#define GET_PKT_DATA(p)
Definition: decode.h:236
HashTableLookup
void * HashTableLookup(HashTable *ht, void *data, uint16_t datalen)
Definition: util-hash.c:193
UNSET_TUNNEL_PKT
#define UNSET_TUNNEL_PKT(p)
Definition: decode.h:935
ThreadVars_
Per thread variable structure.
Definition: threadvars.h:58
PrintInet
const char * PrintInet(int af, const void *src, char *dst, socklen_t size)
Definition: util-print.c:272
pkt-var.h
DECODE_TUNNEL_PPP
@ DECODE_TUNNEL_PPP
Definition: decode.h:949
FLOW_PKT_TOCLIENT_FIRST
#define FLOW_PKT_TOCLIENT_FIRST
Definition: flow.h:231
FlowSetStorageById
int FlowSetStorageById(Flow *f, FlowStorageId id, void *ptr)
Definition: flow-storage.c:44
PacketFree
void PacketFree(Packet *p)
Return a malloced packet.
Definition: decode.c:112
PktSrcToString
const char * PktSrcToString(enum PktSrcEnum pkt_src)
Definition: decode.c:705
DecodeThreadVars_::counter_vlan_qinq
uint16_t counter_vlan_qinq
Definition: decode.h:679
HashTableAdd
int HashTableAdd(HashTable *ht, void *data, uint16_t datalen)
Definition: util-hash.c:113
SIZE_OF_PACKET
#define SIZE_OF_PACKET
Definition: decode.h:643
StringHashFreeFunc
void StringHashFreeFunc(void *data)
Definition: util-hash-string.c:51
BUG_ON
#define BUG_ON(x)
Definition: suricata-common.h:281
DecodeThreadVars_::counter_defrag_ipv6_timeouts
uint16_t counter_defrag_ipv6_timeouts
Definition: decode.h:697
util-profiling.h
PacketCallocExtPkt
int PacketCallocExtPkt(Packet *p, int datalen)
Definition: decode.c:205
PKT_SRC_STREAM_TCP_DETECTLOG_FLUSH
@ PKT_SRC_STREAM_TCP_DETECTLOG_FLUSH
Definition: decode.h:58
DECODE_TUNNEL_VLAN
@ DECODE_TUNNEL_VLAN
Definition: decode.h:945
PKT_SRC_DECODER_IPV6
@ PKT_SRC_DECODER_IPV6
Definition: decode.h:54
CaptureStats_::counter_ips_accepted
uint16_t counter_ips_accepted
Definition: decode.h:728
Packet_
Definition: decode.h:420
DecodeThreadVars_::counter_nsh
uint16_t counter_nsh
Definition: decode.h:689
DecodeIPV6
int DecodeIPV6(ThreadVars *tv, DecodeThreadVars *dtv, Packet *p, const uint8_t *pkt, uint16_t len)
Definition: decode-ipv6.c:570
DECODE_TUNNEL_IPV4
@ DECODE_TUNNEL_IPV4
Definition: decode.h:946
GET_PKT_LEN
#define GET_PKT_LEN(p)
Definition: decode.h:235
DecodeThreadVars_::app_tctx
AppLayerThreadCtx * app_tctx
Definition: decode.h:649
DecodeThreadVars_::counter_defrag_ipv4_timeouts
uint16_t counter_defrag_ipv4_timeouts
Definition: decode.h:694
decode-teredo.h
conf.h
DecodeThreadVars_::counter_sll
uint16_t counter_sll
Definition: decode.h:670
DecodeThreadVars_::counter_sctp
uint16_t counter_sctp
Definition: decode.h:673
Packet_::livedev
struct LiveDevice_ * livedev
Definition: decode.h:573
DecodeThreadVars_::counter_invalid
uint16_t counter_invalid
Definition: decode.h:659
DecodeThreadVars_::counter_ieee8021ah
uint16_t counter_ieee8021ah
Definition: decode.h:682
SCReturnPtr
#define SCReturnPtr(x, type)
Definition: util-debug.h:316
output-flow.h
DecodeThreadVars_::counter_ipv4inipv6
uint16_t counter_ipv4inipv6
Definition: decode.h:686
util-mpm-ac.h
FLOW_PKT_TOCLIENT
#define FLOW_PKT_TOCLIENT
Definition: flow.h:226
DecodeThreadVars_::counter_vlan
uint16_t counter_vlan
Definition: decode.h:678
DECODE_TUNNEL_ETHERNET
@ DECODE_TUNNEL_ETHERNET
Definition: decode.h:942
DecodeThreadVars_::counter_tcp
uint16_t counter_tcp
Definition: decode.h:665
DecodeThreadVars_::counter_pkts
uint16_t counter_pkts
Definition: decode.h:652
FlowUpdateState
void FlowUpdateState(Flow *f, const enum FlowState s)
Definition: flow.c:1142
dtv
DecodeThreadVars * dtv
Definition: fuzz_decodepcapfile.c:30
default_packet_size
uint32_t default_packet_size
Definition: decode.c:72
PKT_SRC_DECODER_GENEVE
@ PKT_SRC_DECODER_GENEVE
Definition: decode.h:62
ACTION_REJECT_BOTH
#define ACTION_REJECT_BOTH
Definition: action-globals.h:33
util-mem.h
DecodeThreadVars_::counter_chdlc
uint16_t counter_chdlc
Definition: decode.h:662
Packet_::ReleasePacket
void(* ReleasePacket)(struct Packet_ *)
Definition: decode.h:502
flow-storage.h
Packet_::flow
struct Flow_ * flow
Definition: decode.h:457
Packet_::tenant_id
uint32_t tenant_id
Definition: decode.h:614
DecodeThreadVarsFree
void DecodeThreadVarsFree(ThreadVars *tv, DecodeThreadVars *dtv)
Definition: decode.c:672
DecodeThreadVars_::counter_flow_spare_sync_incomplete
uint16_t counter_flow_spare_sync_incomplete
Definition: decode.h:715
Packet_::ts
struct timeval ts
Definition: decode.h:463
DecodeGlobalConfig
void DecodeGlobalConfig(void)
Definition: decode.c:770
suricata-common.h
PKT_SRC_FFR
@ PKT_SRC_FFR
Definition: decode.h:57
DecodeThreadVars_::counter_flow_icmp6
uint16_t counter_flow_icmp6
Definition: decode.h:705
DecodeThreadVars_::counter_ipv6
uint16_t counter_ipv6
Definition: decode.h:664
CaptureStats_::counter_ips_replaced
uint16_t counter_ips_replaced
Definition: decode.h:731
DecodeThreadVars_::counter_gre
uint16_t counter_gre
Definition: decode.h:677
ACTION_DROP
#define ACTION_DROP
Definition: action-globals.h:30
DecodeThreadVars_::counter_esp
uint16_t counter_esp
Definition: decode.h:674
Packet_::ext_pkt
uint8_t * ext_pkt
Definition: decode.h:570
SCLogError
#define SCLogError(err_code,...)
Macro used to log ERROR messages.
Definition: util-debug.h:257
DecodeThreadVars_::counter_defrag_ipv6_reassembled
uint16_t counter_defrag_ipv6_reassembled
Definition: decode.h:696
DecodeThreadVars_::counter_udp
uint16_t counter_udp
Definition: decode.h:666
PacketUpdateEngineEventCounters
void PacketUpdateEngineEventCounters(ThreadVars *tv, DecodeThreadVars *dtv, Packet *p)
Definition: decode.c:132
SCStrdup
#define SCStrdup(s)
Definition: util-mem.h:56
FatalError
#define FatalError(x,...)
Definition: util-debug.h:532
CaptureStatsUpdate
void CaptureStatsUpdate(ThreadVars *tv, CaptureStats *s, const Packet *p)
Definition: decode.c:749
PKT_SRC_DEFRAG
@ PKT_SRC_DEFRAG
Definition: decode.h:56
tv
ThreadVars * tv
Definition: fuzz_decodepcapfile.c:29
DecodeThreadVars_::counter_ipv4
uint16_t counter_ipv4
Definition: decode.h:663
PACKET_PROFILING_START
#define PACKET_PROFILING_START(p)
Definition: util-profiling.h:92
util-validate.h
PacketGetFromAlloc
Packet * PacketGetFromAlloc(void)
Get a malloced packet.
Definition: decode.c:151
PKT_SRC_DECODER_VXLAN
@ PKT_SRC_DECODER_VXLAN
Definition: decode.h:59
StatsAddUI64
void StatsAddUI64(ThreadVars *tv, uint16_t id, uint64_t x)
Adds a value of type uint64_t to the local counter.
Definition: counters.c:148
SCMalloc
#define SCMalloc(sz)
Definition: util-mem.h:47
Packet_::root
struct Packet_ * root
Definition: decode.h:597
DecodeThreadVars_::counter_pppoe
uint16_t counter_pppoe
Definition: decode.h:683
DecodeThreadVars_::counter_mpls
uint16_t counter_mpls
Definition: decode.h:685
OutputFlowLogThreadDeinit
TmEcode OutputFlowLogThreadDeinit(ThreadVars *tv, void *thread_data)
Definition: output-flow.c:173
SCLogWarning
#define SCLogWarning(err_code,...)
Macro used to log WARNING messages.
Definition: util-debug.h:244
PKT_SRC_DETECT_RELOAD_FLUSH
@ PKT_SRC_DETECT_RELOAD_FLUSH
Definition: decode.h:60
SCFree
#define SCFree(p)
Definition: util-mem.h:61
DecodeThreadVars_
Structure to hold thread specific data for all decode modules.
Definition: decode.h:647
MAX_PAYLOAD_SIZE
#define MAX_PAYLOAD_SIZE
Definition: decode.h:641
AppLayerDestroyCtxThread
void AppLayerDestroyCtxThread(AppLayerThreadCtx *app_tctx)
Destroys the context created by AppLayeGetCtxThread().
Definition: app-layer.c:900
Packet_::recursion_level
uint8_t recursion_level
Definition: decode.h:445
DecodeThreadVars_::output_flow_thread_data
void * output_flow_thread_data
Definition: decode.h:722
DecodeThreadVars_::counter_geneve
uint16_t counter_geneve
Definition: decode.h:676
DecodeThreadVars_::counter_max_mac_addrs_dst
uint16_t counter_max_mac_addrs_dst
Definition: decode.h:657
DecodeThreadVarsAlloc
DecodeThreadVars * DecodeThreadVarsAlloc(ThreadVars *tv)
Alloc and setup DecodeThreadVars.
Definition: decode.c:653
DecodeThreadVars_::counter_defrag_max_hit
uint16_t counter_defrag_max_hit
Definition: decode.h:698
HashTableInit
HashTable * HashTableInit(uint32_t size, uint32_t(*Hash)(struct HashTable_ *, void *, uint16_t), char(*Compare)(void *, uint16_t, void *, uint16_t), void(*Free)(void *))
Definition: util-hash.c:34
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:692
PacketPoolGetPacket
Packet * PacketPoolGetPacket(void)
Get a new packet from the packet pool.
Definition: tmqh-packetpool.c:185
GET_PKT_DIRECT_DATA
#define GET_PKT_DIRECT_DATA(p)
Definition: decode.h:237
TUNNEL_INCR_PKT_TPR
#define TUNNEL_INCR_PKT_TPR(p)
Definition: decode.h:924
DECODE_EVENT_MAX
@ DECODE_EVENT_MAX
Definition: decode-events.h:291
DecodeThreadVars_::counter_null
uint16_t counter_null
Definition: decode.h:672
DecodeThreadVars_::counter_icmpv6
uint16_t counter_icmpv6
Definition: decode.h:668
suricata.h
Address_::family
char family
Definition: decode.h:123
PKT_SRC_DECODER_GRE
@ PKT_SRC_DECODER_GRE
Definition: decode.h:52
DecodeGeneveConfig
void DecodeGeneveConfig(void)
Definition: decode-geneve.c:128
DecodeThreadVars_::counter_flow_memcap
uint16_t counter_flow_memcap
Definition: decode.h:700
DecodeThreadVars_::counter_defrag_ipv6_fragments
uint16_t counter_defrag_ipv6_fragments
Definition: decode.h:695
StatsRegisterAvgCounter
uint16_t StatsRegisterAvgCounter(const char *name, struct ThreadVars_ *tv)
Registers a counter, whose value holds the average of all the values assigned to it.
Definition: counters.c:962
SC_ERR_INITIALIZATION
@ SC_ERR_INITIALIZATION
Definition: util-error.h:75
PacketDefragPktSetupParent
void PacketDefragPktSetupParent(Packet *parent)
inform defrag "parent" that a pseudo packet is now associated to it.
Definition: decode.c:402
PacketTunnelPktSetup
Packet * PacketTunnelPktSetup(ThreadVars *tv, DecodeThreadVars *dtv, Packet *parent, const uint8_t *pkt, uint32_t len, enum DecodeTunnelProto proto)
Setup a pseudo packet (tunnel)
Definition: decode.c:289
stats_decoder_events
bool stats_decoder_events
Definition: counters.c:103
DecodeIPV4
int DecodeIPV4(ThreadVars *tv, DecodeThreadVars *dtv, Packet *p, const uint8_t *pkt, uint16_t len)
Definition: decode-ipv4.c:517
StatsRegisterCounter
uint16_t StatsRegisterCounter(const char *name, struct ThreadVars_ *tv)
Registers a normal, unqualified counter.
Definition: counters.c:942
SCCalloc
#define SCCalloc(nm, sz)
Definition: util-mem.h:53
DecodeThreadVars_::counter_flow_get_used_eval_reject
uint16_t counter_flow_get_used_eval_reject
Definition: decode.h:709
DecodeVLAN
int DecodeVLAN(ThreadVars *tv, DecodeThreadVars *dtv, Packet *p, const uint8_t *pkt, uint32_t len)
Definition: decode-vlan.c:60
code
uint8_t code
Definition: decode-icmpv4.h:1
FLOW_PKT_TOSERVER_FIRST
#define FLOW_PKT_TOSERVER_FIRST
Definition: flow.h:230
SCMutex
#define SCMutex
Definition: threads-debug.h:114
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:189
DEBUG_VALIDATE_BUG_ON
#define DEBUG_VALIDATE_BUG_ON(exp)
Definition: util-validate.h:111
DecodeEthernet
int DecodeEthernet(ThreadVars *tv, DecodeThreadVars *dtv, Packet *p, const uint8_t *pkt, uint32_t len)
Definition: decode-ethernet.c:42
PACKET_DESTRUCTOR
#define PACKET_DESTRUCTOR(p)
Cleanup a packet so that we can free it. No memset needed..
Definition: decode.h:859
WARN_UNUSED
#define WARN_UNUSED
Definition: suricata-common.h:384
PKT_IS_INVALID
#define PKT_IS_INVALID
Definition: decode.h:1186
DecodeUpdatePacketCounters
void DecodeUpdatePacketCounters(ThreadVars *tv, const DecodeThreadVars *dtv, const Packet *p)
Definition: decode.c:619
DecodeThreadVars_::counter_engine_events
uint16_t counter_engine_events[DECODE_EVENT_MAX]
Definition: decode.h:718
output.h
app-layer.h
DecodeThreadVars_::counter_defrag_ipv4_fragments
uint16_t counter_defrag_ipv4_fragments
Definition: decode.h:692
PacketEngineEvents_::cnt
uint8_t cnt
Definition: decode.h:318