suricata
decode.c
Go to the documentation of this file.
1 /* Copyright (C) 2007-2022 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;
78 
79 /**
80  * \brief Initialize PacketAlerts with dynamic alerts array size
81  *
82  */
84 {
85  PacketAlert *pa_array = SCCalloc(packet_alert_max, sizeof(PacketAlert));
86  BUG_ON(pa_array == NULL);
87 
88  return pa_array;
89 }
90 
92 {
93  if (pa != NULL) {
94  SCFree(pa);
95  }
96 }
97 
98 static int DecodeTunnel(ThreadVars *, DecodeThreadVars *, Packet *, const uint8_t *, uint32_t,
100 
101 static int DecodeTunnel(ThreadVars *tv, DecodeThreadVars *dtv, Packet *p, const uint8_t *pkt,
102  uint32_t len, enum DecodeTunnelProto proto)
103 {
104  switch (proto) {
105  case DECODE_TUNNEL_PPP:
106  return DecodePPP(tv, dtv, p, pkt, len);
107  case DECODE_TUNNEL_IPV4:
108  DEBUG_VALIDATE_BUG_ON(len > UINT16_MAX);
109  return DecodeIPV4(tv, dtv, p, pkt, (uint16_t)len);
110  case DECODE_TUNNEL_IPV6:
112  DEBUG_VALIDATE_BUG_ON(len > UINT16_MAX);
113  return DecodeIPV6(tv, dtv, p, pkt, (uint16_t)len);
114  case DECODE_TUNNEL_VLAN:
115  return DecodeVLAN(tv, dtv, p, pkt, len);
117  return DecodeEthernet(tv, dtv, p, pkt, len);
119  return DecodeERSPAN(tv, dtv, p, pkt, len);
121  return DecodeERSPANTypeI(tv, dtv, p, pkt, len);
122  case DECODE_TUNNEL_NSH:
123  return DecodeNSH(tv, dtv, p, pkt, len);
124  default:
125  SCLogDebug("FIXME: DecodeTunnel: protocol %" PRIu32 " not supported.", proto);
126  break;
127  }
128  return TM_ECODE_OK;
129 }
130 
131 /**
132  * \brief Return a malloced packet.
133  */
135 {
137  SCFree(p);
138 }
139 
140 /**
141  * \brief Finalize decoding of a packet
142  *
143  * This function needs to be call at the end of decode
144  * functions when decoding has been successful.
145  *
146  */
148 {
149  if (p->flags & PKT_IS_INVALID) {
151  }
152 }
153 
156 {
157  for (uint8_t i = 0; i < p->events.cnt; i++) {
158  const uint8_t e = p->events.events[i];
159 
161  continue;
163  continue;
165  }
166 }
167 
168 /**
169  * \brief Get a malloced packet.
170  *
171  * \retval p packet, NULL on error
172  */
174 {
176  if (unlikely(p == NULL)) {
177  return NULL;
178  }
179 
180  memset(p, 0, SIZE_OF_PACKET);
183  p->flags |= PKT_ALLOC;
184 
185  SCLogDebug("allocated a new packet only using alloc...");
186 
188  return p;
189 }
190 
191 /**
192  * \brief Return a packet to where it was allocated.
193  */
195 {
196  if (p->flags & PKT_ALLOC)
197  PacketFree(p);
198  else {
201  }
202 }
203 
204 /**
205  * \brief Get a packet. We try to get a packet from the packetpool first, but
206  * if that is empty we alloc a packet that is free'd again after
207  * processing.
208  *
209  * \retval p packet, NULL on error
210  */
212 {
213  /* try the pool first */
215 
216  if (p == NULL) {
217  /* non fatal, we're just not processing a packet then */
218  p = PacketGetFromAlloc();
219  } else {
222  }
223 
224  return p;
225 }
226 
227 inline int PacketCallocExtPkt(Packet *p, int datalen)
228 {
229  if (! p->ext_pkt) {
230  p->ext_pkt = SCCalloc(1, datalen);
231  if (unlikely(p->ext_pkt == NULL)) {
232  SET_PKT_LEN(p, 0);
233  return -1;
234  }
235  }
236  return 0;
237 }
238 
239 /**
240  * \brief Copy data to Packet payload at given offset
241  *
242  * This function copies data/payload to a Packet. It uses the
243  * space allocated at Packet creation (pointed by Packet::pkt)
244  * or allocate some memory (pointed by Packet::ext_pkt) if the
245  * data size is to big to fit in initial space (of size
246  * default_packet_size).
247  *
248  * \param Pointer to the Packet to modify
249  * \param Offset of the copy relatively to payload of Packet
250  * \param Pointer to the data to copy
251  * \param Length of the data to copy
252  */
253 inline int PacketCopyDataOffset(Packet *p, uint32_t offset, const uint8_t *data, uint32_t datalen)
254 {
255  if (unlikely(offset + datalen > MAX_PAYLOAD_SIZE)) {
256  /* too big */
257  SET_PKT_LEN(p, 0);
258  return -1;
259  }
260 
261  /* Do we have already an packet with allocated data */
262  if (! p->ext_pkt) {
263  uint32_t newsize = offset + datalen;
264  // check overflow
265  if (newsize < offset)
266  return -1;
267  if (newsize <= default_packet_size) {
268  /* data will fit in memory allocated with packet */
269  memcpy(GET_PKT_DIRECT_DATA(p) + offset, data, datalen);
270  } else {
271  /* here we need a dynamic allocation */
273  if (unlikely(p->ext_pkt == NULL)) {
274  SET_PKT_LEN(p, 0);
275  return -1;
276  }
277  /* copy initial data */
279  /* copy data as asked */
280  memcpy(p->ext_pkt + offset, data, datalen);
281  }
282  } else {
283  memcpy(p->ext_pkt + offset, data, datalen);
284  }
285  return 0;
286 }
287 
288 /**
289  * \brief Copy data to Packet payload and set packet length
290  *
291  * \param Pointer to the Packet to modify
292  * \param Pointer to the data to copy
293  * \param Length of the data to copy
294  */
295 inline int PacketCopyData(Packet *p, const uint8_t *pktdata, uint32_t pktlen)
296 {
297  SET_PKT_LEN(p, (size_t)pktlen);
298  return PacketCopyDataOffset(p, 0, pktdata, pktlen);
299 }
300 
301 /**
302  * \brief Setup a pseudo packet (tunnel)
303  *
304  * \param parent parent packet for this pseudo pkt
305  * \param pkt raw packet data
306  * \param len packet data length
307  * \param proto protocol of the tunneled packet
308  *
309  * \retval p the pseudo packet or NULL if out of memory
310  */
312  const uint8_t *pkt, uint32_t len, enum DecodeTunnelProto proto)
313 {
314  int ret;
315 
316  SCEnter();
317 
318  /* get us a packet */
320  if (unlikely(p == NULL)) {
321  SCReturnPtr(NULL, "Packet");
322  }
323 
324  /* copy packet and set length, proto */
325  PacketCopyData(p, pkt, len);
326  p->recursion_level = parent->recursion_level + 1;
327  p->ts.tv_sec = parent->ts.tv_sec;
328  p->ts.tv_usec = parent->ts.tv_usec;
329  p->datalink = DLT_RAW;
330  p->tenant_id = parent->tenant_id;
331  p->livedev = parent->livedev;
332 
333  /* set the root ptr to the lowest layer */
334  if (parent->root != NULL)
335  p->root = parent->root;
336  else
337  p->root = parent;
338 
339  /* tell new packet it's part of a tunnel */
340  SET_TUNNEL_PKT(p);
341 
342  ret = DecodeTunnel(tv, dtv, p, GET_PKT_DATA(p),
343  GET_PKT_LEN(p), proto);
344 
345  if (unlikely(ret != TM_ECODE_OK) ||
347  {
348  /* Not a (valid) tunnel packet */
349  SCLogDebug("tunnel packet is invalid");
350 
351  p->root = NULL;
352  UNSET_TUNNEL_PKT(p);
354  SCReturnPtr(NULL, "Packet");
355  }
356 
357 
358  /* tell parent packet it's part of a tunnel */
359  SET_TUNNEL_PKT(parent);
360 
361  /* increment tunnel packet refcnt in the root packet */
363 
364  /* disable payload (not packet) inspection on the parent, as the payload
365  * is the packet we will now run through the system separately. We do
366  * check it against the ip/port/other header checks though */
367  DecodeSetNoPayloadInspectionFlag(parent);
368  SCReturnPtr(p, "Packet");
369 }
370 
371 /**
372  * \brief Setup a pseudo packet (reassembled frags)
373  *
374  * Difference with PacketPseudoPktSetup is that this func doesn't increment
375  * the recursion level. It needs to be on the same level as the frags because
376  * we run the flow engine against this and we need to get the same flow.
377  *
378  * \param parent parent packet for this pseudo pkt
379  * \param pkt raw packet data
380  * \param len packet data length
381  * \param proto protocol of the tunneled packet
382  *
383  * \retval p the pseudo packet or NULL if out of memory
384  */
385 Packet *PacketDefragPktSetup(Packet *parent, const uint8_t *pkt, uint32_t len, uint8_t proto)
386 {
387  SCEnter();
388 
389  /* get us a packet */
391  if (unlikely(p == NULL)) {
392  SCReturnPtr(NULL, "Packet");
393  }
394 
395  /* set the root ptr to the lowest layer */
396  if (parent->root != NULL)
397  p->root = parent->root;
398  else
399  p->root = parent;
400 
401  /* copy packet and set length, proto */
402  if (pkt && len) {
403  PacketCopyData(p, pkt, len);
404  }
405  p->recursion_level = parent->recursion_level; /* NOT incremented */
406  p->ts.tv_sec = parent->ts.tv_sec;
407  p->ts.tv_usec = parent->ts.tv_usec;
408  p->datalink = DLT_RAW;
409  p->tenant_id = parent->tenant_id;
410  /* tell new packet it's part of a tunnel */
411  SET_TUNNEL_PKT(p);
412  p->vlan_id[0] = parent->vlan_id[0];
413  p->vlan_id[1] = parent->vlan_id[1];
414  p->vlan_idx = parent->vlan_idx;
415  p->livedev = parent->livedev;
416 
417  SCReturnPtr(p, "Packet");
418 }
419 
420 /**
421  * \brief inform defrag "parent" that a pseudo packet is
422  * now associated to it.
423  */
425 {
426  /* tell parent packet it's part of a tunnel */
427  SET_TUNNEL_PKT(parent);
428 
429  /* increment tunnel packet refcnt in the root packet */
430  TUNNEL_INCR_PKT_TPR(parent);
431 
432  /* disable payload (not packet) inspection on the parent, as the payload
433  * is the packet we will now run through the system separately. We do
434  * check it against the ip/port/other header checks though */
435  DecodeSetNoPayloadInspectionFlag(parent);
436 }
437 
438 /**
439  * \note if p->flow is set, the flow is locked
440  */
442 {
443  if (PKT_IS_PSEUDOPKT(p))
444  return;
445 
446 #ifdef CAPTURE_OFFLOAD
447  /* Don't try to bypass if flow is already out or
448  * if we have failed to do it once */
449  if (p->flow) {
450  int state = p->flow->flow_state;
451  if ((state == FLOW_STATE_LOCAL_BYPASSED) ||
452  (state == FLOW_STATE_CAPTURE_BYPASSED)) {
453  return;
454  }
455 
456  FlowBypassInfo *fc;
457 
459  if (fc == NULL) {
460  fc = SCCalloc(sizeof(FlowBypassInfo), 1);
461  if (fc) {
463  } else {
464  return;
465  }
466  }
467  }
468  if (p->BypassPacketsFlow && p->BypassPacketsFlow(p)) {
469  if (p->flow) {
470  FlowUpdateState(p->flow, FLOW_STATE_CAPTURE_BYPASSED);
471  }
472  } else {
473  if (p->flow) {
475  }
476  }
477 #else /* CAPTURE_OFFLOAD */
478  if (p->flow) {
479  int state = p->flow->flow_state;
480  if (state == FLOW_STATE_LOCAL_BYPASSED)
481  return;
483  }
484 #endif
485 }
486 
487 /** \brief switch direction of a packet */
489 {
490  if (PKT_IS_TOSERVER(p)) {
493 
497  }
498  } else {
501 
505  }
506  }
507 }
508 
509 /* counter name store */
510 static HashTable *g_counter_table = NULL;
511 static SCMutex g_counter_table_mutex = SCMUTEX_INITIALIZER;
512 
514 {
515  SCMutexLock(&g_counter_table_mutex);
516  if (g_counter_table) {
517  HashTableFree(g_counter_table);
518  g_counter_table = NULL;
519  }
520  SCMutexUnlock(&g_counter_table_mutex);
521 }
522 
524 {
525  /* register counters */
526  dtv->counter_pkts = StatsRegisterCounter("decoder.pkts", tv);
527  dtv->counter_bytes = StatsRegisterCounter("decoder.bytes", tv);
528  dtv->counter_invalid = StatsRegisterCounter("decoder.invalid", tv);
529  dtv->counter_ipv4 = StatsRegisterCounter("decoder.ipv4", tv);
530  dtv->counter_ipv6 = StatsRegisterCounter("decoder.ipv6", tv);
531  dtv->counter_eth = StatsRegisterCounter("decoder.ethernet", tv);
532  dtv->counter_chdlc = StatsRegisterCounter("decoder.chdlc", tv);
533  dtv->counter_raw = StatsRegisterCounter("decoder.raw", tv);
534  dtv->counter_null = StatsRegisterCounter("decoder.null", tv);
535  dtv->counter_sll = StatsRegisterCounter("decoder.sll", tv);
536  dtv->counter_tcp = StatsRegisterCounter("decoder.tcp", tv);
537  dtv->counter_udp = StatsRegisterCounter("decoder.udp", tv);
538  dtv->counter_sctp = StatsRegisterCounter("decoder.sctp", tv);
539  dtv->counter_esp = StatsRegisterCounter("decoder.esp", tv);
540  dtv->counter_icmpv4 = StatsRegisterCounter("decoder.icmpv4", tv);
541  dtv->counter_icmpv6 = StatsRegisterCounter("decoder.icmpv6", tv);
542  dtv->counter_ppp = StatsRegisterCounter("decoder.ppp", tv);
543  dtv->counter_pppoe = StatsRegisterCounter("decoder.pppoe", tv);
544  dtv->counter_geneve = StatsRegisterCounter("decoder.geneve", tv);
545  dtv->counter_gre = StatsRegisterCounter("decoder.gre", tv);
546  dtv->counter_vlan = StatsRegisterCounter("decoder.vlan", tv);
547  dtv->counter_vlan_qinq = StatsRegisterCounter("decoder.vlan_qinq", tv);
548  dtv->counter_vxlan = StatsRegisterCounter("decoder.vxlan", tv);
549  dtv->counter_vntag = StatsRegisterCounter("decoder.vntag", tv);
550  dtv->counter_ieee8021ah = StatsRegisterCounter("decoder.ieee8021ah", tv);
551  dtv->counter_teredo = StatsRegisterCounter("decoder.teredo", tv);
552  dtv->counter_ipv4inipv6 = StatsRegisterCounter("decoder.ipv4_in_ipv6", tv);
553  dtv->counter_ipv6inipv6 = StatsRegisterCounter("decoder.ipv6_in_ipv6", tv);
554  dtv->counter_mpls = StatsRegisterCounter("decoder.mpls", tv);
555  dtv->counter_avg_pkt_size = StatsRegisterAvgCounter("decoder.avg_pkt_size", tv);
556  dtv->counter_max_pkt_size = StatsRegisterMaxCounter("decoder.max_pkt_size", tv);
557  dtv->counter_max_mac_addrs_src = StatsRegisterMaxCounter("decoder.max_mac_addrs_src", tv);
558  dtv->counter_max_mac_addrs_dst = StatsRegisterMaxCounter("decoder.max_mac_addrs_dst", tv);
559  dtv->counter_erspan = StatsRegisterMaxCounter("decoder.erspan", tv);
560  dtv->counter_nsh = StatsRegisterMaxCounter("decoder.nsh", tv);
561  dtv->counter_flow_memcap = StatsRegisterCounter("flow.memcap", tv);
562 
563  dtv->counter_tcp_active_sessions = StatsRegisterCounter("tcp.active_sessions", tv);
564  dtv->counter_flow_total = StatsRegisterCounter("flow.total", tv);
565  dtv->counter_flow_active = StatsRegisterCounter("flow.active", tv);
568  dtv->counter_flow_icmp4 = StatsRegisterCounter("flow.icmpv4", tv);
569  dtv->counter_flow_icmp6 = StatsRegisterCounter("flow.icmpv6", tv);
570  dtv->counter_flow_tcp_reuse = StatsRegisterCounter("flow.tcp_reuse", tv);
571  dtv->counter_flow_get_used = StatsRegisterCounter("flow.get_used", tv);
572  dtv->counter_flow_get_used_eval = StatsRegisterCounter("flow.get_used_eval", tv);
573  dtv->counter_flow_get_used_eval_reject = StatsRegisterCounter("flow.get_used_eval_reject", tv);
574  dtv->counter_flow_get_used_eval_busy = StatsRegisterCounter("flow.get_used_eval_busy", tv);
575  dtv->counter_flow_get_used_failed = StatsRegisterCounter("flow.get_used_failed", tv);
576 
577  dtv->counter_flow_spare_sync_avg = StatsRegisterAvgCounter("flow.wrk.spare_sync_avg", tv);
578  dtv->counter_flow_spare_sync = StatsRegisterCounter("flow.wrk.spare_sync", tv);
579  dtv->counter_flow_spare_sync_incomplete = StatsRegisterCounter("flow.wrk.spare_sync_incomplete", tv);
580  dtv->counter_flow_spare_sync_empty = StatsRegisterCounter("flow.wrk.spare_sync_empty", tv);
581 
583  StatsRegisterCounter("defrag.ipv4.fragments", tv);
585  StatsRegisterCounter("defrag.ipv4.reassembled", tv);
587  StatsRegisterCounter("defrag.ipv4.timeouts", tv);
589  StatsRegisterCounter("defrag.ipv6.fragments", tv);
591  StatsRegisterCounter("defrag.ipv6.reassembled", tv);
593  StatsRegisterCounter("defrag.ipv6.timeouts", tv);
595  StatsRegisterCounter("defrag.max_frag_hits", tv);
596 
597  for (int i = 0; i < DECODE_EVENT_MAX; i++) {
598  BUG_ON(i != (int)DEvents[i].code);
599 
601  continue;
603  continue;
604 
605  if (i < DECODE_EVENT_PACKET_MAX &&
606  strncmp(DEvents[i].event_name, "decoder.", 8) == 0)
607  {
608  SCMutexLock(&g_counter_table_mutex);
609  if (g_counter_table == NULL) {
610  g_counter_table = HashTableInit(256, StringHashFunc,
613  if (g_counter_table == NULL) {
614  FatalError(SC_ERR_INITIALIZATION, "decoder counter hash "
615  "table init failed");
616  }
617  }
618 
619  char name[256];
620  char *dot = strchr(DEvents[i].event_name, '.');
621  BUG_ON(!dot);
622  snprintf(name, sizeof(name), "%s.%s",
624 
625  const char *found = HashTableLookup(g_counter_table, name, 0);
626  if (!found) {
627  char *add = SCStrdup(name);
628  if (add == NULL)
629  FatalError(SC_ERR_INITIALIZATION, "decoder counter hash "
630  "table name init failed");
631  int r = HashTableAdd(g_counter_table, add, 0);
632  if (r != 0)
633  FatalError(SC_ERR_INITIALIZATION, "decoder counter hash "
634  "table name add failed");
635  found = add;
636  }
638  found, tv);
639 
640  SCMutexUnlock(&g_counter_table_mutex);
641  } else {
643  DEvents[i].event_name, tv);
644  }
645  }
646 
647  return;
648 }
649 
651  const DecodeThreadVars *dtv, const Packet *p)
652 {
654  //StatsIncr(tv, dtv->counter_pkts_per_sec);
658 }
659 
660 /**
661  * \brief Debug print function for printing addresses
662  *
663  * \param Address object
664  *
665  * \todo IPv6
666  */
668 {
669  if (a == NULL)
670  return;
671 
672  switch (a->family) {
673  case AF_INET:
674  {
675  char s[16];
676  PrintInet(AF_INET, (const void *)&a->addr_data32[0], s, sizeof(s));
677  SCLogDebug("%s", s);
678  break;
679  }
680  }
681 }
682 
683 /** \brief Alloc and setup DecodeThreadVars */
685 {
686  DecodeThreadVars *dtv = NULL;
687 
688  if ( (dtv = SCMalloc(sizeof(DecodeThreadVars))) == NULL)
689  return NULL;
690  memset(dtv, 0, sizeof(DecodeThreadVars));
691 
693 
695  SCLogError(SC_ERR_THREAD_INIT, "initializing flow log API for thread failed");
697  return NULL;
698  }
699 
700  return dtv;
701 }
702 
704 {
705  if (dtv != NULL) {
706  if (dtv->app_tctx != NULL)
708 
709  if (dtv->output_flow_thread_data != NULL)
711 
712  SCFree(dtv);
713  }
714 }
715 
716 /**
717  * \brief Set data for Packet and set length when zero copy is used
718  *
719  * \param Pointer to the Packet to modify
720  * \param Pointer to the data
721  * \param Length of the data
722  */
723 inline int PacketSetData(Packet *p, const uint8_t *pktdata, uint32_t pktlen)
724 {
725  SET_PKT_LEN(p, (size_t)pktlen);
726  if (unlikely(!pktdata)) {
727  return -1;
728  }
729  // ext_pkt cannot be const (because we sometimes copy)
730  p->ext_pkt = (uint8_t *) pktdata;
731  p->flags |= PKT_ZERO_COPY;
732 
733  return 0;
734 }
735 
736 const char *PktSrcToString(enum PktSrcEnum pkt_src)
737 {
738  const char *pkt_src_str = "<unknown>";
739  switch (pkt_src) {
740  case PKT_SRC_WIRE:
741  pkt_src_str = "wire/pcap";
742  break;
743  case PKT_SRC_DECODER_GRE:
744  pkt_src_str = "gre tunnel";
745  break;
747  pkt_src_str = "ipv4 tunnel";
748  break;
750  pkt_src_str = "ipv6 tunnel";
751  break;
753  pkt_src_str = "teredo tunnel";
754  break;
755  case PKT_SRC_DEFRAG:
756  pkt_src_str = "defrag";
757  break;
759  pkt_src_str = "stream (detect/log)";
760  break;
761  case PKT_SRC_FFR:
762  pkt_src_str = "stream (flow timeout)";
763  break;
765  pkt_src_str = "geneve encapsulation";
766  break;
768  pkt_src_str = "vxlan encapsulation";
769  break;
771  pkt_src_str = "detect reload flush";
772  break;
774  pkt_src_str = "capture timeout flush";
775  break;
776  }
777  return pkt_src_str;
778 }
779 
781 {
782  switch (r) {
784  return "decode error";
786  return "defrag error";
788  return "defrag memcap";
790  return "flow memcap";
792  return "flow drop";
794  return "stream error";
796  return "stream memcap";
798  return "applayer error";
800  return "applayer memcap";
802  return "rules";
804  return "threshold detection_filter";
806  default:
807  return NULL;
808  }
809 }
810 
811 /* TODO drop reason stats! */
813 {
814  if (unlikely(PacketTestAction(p, (ACTION_REJECT | ACTION_REJECT_DST | ACTION_REJECT_BOTH)))) {
816  } else if (unlikely(PacketTestAction(p, ACTION_DROP))) {
818  } else if (unlikely(p->flags & PKT_STREAM_MODIFIED)) {
820  } else {
822  }
823 }
824 
826 {
827  s->counter_ips_accepted = StatsRegisterCounter("ips.accepted", tv);
828  s->counter_ips_blocked = StatsRegisterCounter("ips.blocked", tv);
829  s->counter_ips_rejected = StatsRegisterCounter("ips.rejected", tv);
830  s->counter_ips_replaced = StatsRegisterCounter("ips.replaced", tv);
831 }
832 
834 {
839  intmax_t value = 0;
840  if (ConfGetInt("decoder.max-layers", &value) == 1) {
841  if (value < 0 || value > UINT8_MAX) {
842  SCLogWarning(SC_ERR_INVALID_VALUE, "Invalid value for decoder.max-layers");
843  } else {
844  decoder_max_layers = (uint8_t)value;
845  }
846  }
848 }
849 
851 {
852  intmax_t max = 0;
853  if (ConfGetInt("packet-alert-max", &max) == 1) {
854  if (max <= 0 || max > UINT8_MAX) {
856  "Invalid value for packet-alert-max, default value set instead");
857  } else {
858  packet_alert_max = (uint16_t)max;
859  }
860  }
861  SCLogDebug("detect->packet_alert_max set to %d", packet_alert_max);
862 }
863 
864 /**
865  * @}
866  */
DecodeThreadVars_::counter_flow_get_used_eval_busy
uint16_t counter_flow_get_used_eval_busy
Definition: decode.h:738
PKT_DROP_REASON_DEFRAG_MEMCAP
@ PKT_DROP_REASON_DEFRAG_MEMCAP
Definition: decode.h:411
PKT_DROP_REASON_DEFRAG_ERROR
@ PKT_DROP_REASON_DEFRAG_ERROR
Definition: decode.h:410
tm-threads.h
ConfGetInt
int ConfGetInt(const char *name, intmax_t *val)
Retrieve a configuration value as an integer.
Definition: conf.c:392
DecodeThreadVars_::counter_defrag_ipv4_reassembled
uint16_t counter_defrag_ipv4_reassembled
Definition: decode.h:718
util-hash-string.h
PKT_DROP_REASON_RULES_THRESHOLD
@ PKT_DROP_REASON_RULES_THRESHOLD
Definition: decode.h:419
DecodeThreadVars_::counter_flow_udp
uint16_t counter_flow_udp
Definition: decode.h:731
len
uint8_t len
Definition: app-layer-dnp3.h:2
DecodeThreadVars_::counter_bytes
uint16_t counter_bytes
Definition: decode.h:678
DECODE_TUNNEL_IPV6
@ DECODE_TUNNEL_IPV6
Definition: decode.h:993
CaptureStats_::counter_ips_blocked
uint16_t counter_ips_blocked
Definition: decode.h:757
DecodeThreadVars_::counter_eth
uint16_t counter_eth
Definition: decode.h:686
DecodeThreadVars_::counter_flow_active
uint16_t counter_flow_active
Definition: decode.h:729
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:194
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:732
DecodeThreadVars_::counter_vxlan
uint16_t counter_vxlan
Definition: decode.h:705
DecodeThreadVars_::counter_max_pkt_size
uint16_t counter_max_pkt_size
Definition: decode.h:680
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:295
Packet_::vlan_id
uint16_t vlan_id[2]
Definition: decode.h:469
PacketBypassCallback
void PacketBypassCallback(Packet *p)
Definition: decode.c:441
PKT_IS_PSEUDOPKT
#define PKT_IS_PSEUDOPKT(p)
return 1 if the packet is a pseudo packet
Definition: decode.h:1238
DecodeThreadVars_::counter_avg_pkt_size
uint16_t counter_avg_pkt_size
Definition: decode.h:679
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:537
unlikely
#define unlikely(expr)
Definition: util-optimize.h:35
PKT_DROP_REASON_STREAM_MEMCAP
@ PKT_DROP_REASON_STREAM_MEMCAP
Definition: decode.h:415
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
PKT_DROP_REASON_FLOW_MEMCAP
@ PKT_DROP_REASON_FLOW_MEMCAP
Definition: decode.h:412
DecodeTeredoConfig
void DecodeTeredoConfig(void)
Definition: decode-teredo.c:103
PacketDropReasonToString
const char * PacketDropReasonToString(enum PacketDropReason r)
Definition: decode.c:780
PacketEngineEvents_::events
uint8_t events[PACKET_ENGINE_EVENT_MAX]
Definition: decode.h:326
CaptureStats_
Definition: decode.h:754
PKT_STREAM_MODIFIED
#define PKT_STREAM_MODIFIED
Definition: decode.h:1190
DECODE_TUNNEL_IPV6_TEREDO
@ DECODE_TUNNEL_IPV6_TEREDO
Definition: decode.h:994
SCLogDebug
#define SCLogDebug(...)
Definition: util-debug.h:298
AddressDebugPrint
void AddressDebugPrint(Address *a)
Debug print function for printing addresses.
Definition: decode.c:667
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:744
PacketDefragPktSetup
Packet * PacketDefragPktSetup(Packet *parent, const uint8_t *pkt, uint32_t len, uint8_t proto)
Setup a pseudo packet (reassembled frags)
Definition: decode.c:385
stats_stream_events
bool stats_stream_events
Definition: counters.c:106
PKT_ZERO_COPY
#define PKT_ZERO_COPY
Definition: decode.h:1203
PKT_SRC_CAPTURE_TIMEOUT
@ PKT_SRC_CAPTURE_TIMEOUT
Definition: decode.h:61
Packet_::flags
uint32_t flags
Definition: decode.h:477
PacketAlertCreate
PacketAlert * PacketAlertCreate(void)
Initialize PacketAlerts with dynamic alerts array size.
Definition: decode.c:83
DecodeThreadVars_::counter_vntag
uint16_t counter_vntag
Definition: decode.h:706
Packet_::vlan_idx
uint8_t vlan_idx
Definition: decode.h:470
DecodeThreadVars_::counter_flow_get_used_eval
uint16_t counter_flow_get_used_eval
Definition: decode.h:736
StatsSetUI64
void StatsSetUI64(ThreadVars *tv, uint16_t id, uint64_t x)
Sets a value of type double to the local counter.
Definition: counters.c:212
DECODE_TUNNEL_ERSPANI
@ DECODE_TUNNEL_ERSPANI
Definition: decode.h:990
DecodeThreadVars_::counter_teredo
uint16_t counter_teredo
Definition: decode.h:709
DecodeThreadVars_::counter_erspan
uint16_t counter_erspan
Definition: decode.h:713
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:253
DecodeThreadVars_::counter_raw
uint16_t counter_raw
Definition: decode.h:696
SCMutexLock
#define SCMutexLock(mut)
Definition: threads-debug.h:117
FLOW_PKT_TOSERVER
#define FLOW_PKT_TOSERVER
Definition: flow.h:226
HashTable_
Definition: util-hash.h:35
PACKET_INITIALIZE
#define PACKET_INITIALIZE(p)
Initialize a packet structure for use.
Definition: decode.h:791
Address_
Definition: decode.h:122
DecodeThreadVars_::counter_flow_tcp
uint16_t counter_flow_tcp
Definition: decode.h:730
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:147
proto
uint8_t proto
Definition: decode-template.h:0
PacketAlertGetMaxConfig
void PacketAlertGetMaxConfig(void)
Definition: decode.c:850
decoder_max_layers
uint8_t decoder_max_layers
Definition: decode.c:76
SET_TUNNEL_PKT
#define SET_TUNNEL_PKT(p)
Definition: decode.h:980
DecodeThreadVars_::counter_tcp_active_sessions
uint16_t counter_tcp_active_sessions
Definition: decode.h:727
Packet_::flowflags
uint8_t flowflags
Definition: decode.h:473
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:527
TmqhOutputPacketpool
void TmqhOutputPacketpool(ThreadVars *t, Packet *p)
Definition: tmqh-packetpool.c:375
DecodeVXLANConfig
void DecodeVXLANConfig(void)
Definition: decode-vxlan.c:102
PacketDropReason
PacketDropReason
Definition: decode.h:407
DecodeThreadVars_::counter_max_mac_addrs_src
uint16_t counter_max_mac_addrs_src
Definition: decode.h:681
DecodeUnregisterCounters
void DecodeUnregisterCounters(void)
Definition: decode.c:513
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:735
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:607
PacketAlertFree
void PacketAlertFree(PacketAlert *pa)
Definition: decode.c:91
PKT_ALLOC
#define PKT_ALLOC
Definition: decode.h:1176
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:742
Flow_::flow_state
FlowStateType flow_state
Definition: flow.h:425
DecodeThreadVars_::counter_flow_tcp_reuse
uint16_t counter_flow_tcp_reuse
Definition: decode.h:734
DECODE_TUNNEL_NSH
@ DECODE_TUNNEL_NSH
Definition: decode.h:996
DecodeThreadVars_::counter_flow_total
uint16_t counter_flow_total
Definition: decode.h:728
Packet_::datalink
int datalink
Definition: decode.h:616
PKT_DEFAULT_MAX_DECODED_LAYERS
#define PKT_DEFAULT_MAX_DECODED_LAYERS
Definition: decode.h:1243
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:523
DecodeThreadVars_::counter_flow_spare_sync
uint16_t counter_flow_spare_sync
Definition: decode.h:741
DECODE_TUNNEL_ERSPANII
@ DECODE_TUNNEL_ERSPANII
Definition: decode.h:989
SET_PKT_LEN
#define SET_PKT_LEN(p, len)
Definition: decode.h:240
DecodeThreadVars_::counter_ipv6inipv6
uint16_t counter_ipv6inipv6
Definition: decode.h:712
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:996
FLOW_STATE_LOCAL_BYPASSED
@ FLOW_STATE_LOCAL_BYPASSED
Definition: flow.h:515
decode.h
util-debug.h
DecodeThreadVars_::counter_flow_get_used_failed
uint16_t counter_flow_get_used_failed
Definition: decode.h:739
PKT_SRC_WIRE
@ PKT_SRC_WIRE
Definition: decode.h:51
CaptureStats_::counter_ips_rejected
uint16_t counter_ips_rejected
Definition: decode.h:758
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:692
DecodeThreadVars_::counter_ppp
uint16_t counter_ppp
Definition: decode.h:700
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
PKT_DROP_REASON_APPLAYER_ERROR
@ PKT_DROP_REASON_APPLAYER_ERROR
Definition: decode.h:416
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:125
SCMutexUnlock
#define SCMutexUnlock(mut)
Definition: threads-debug.h:119
PacketSwap
void PacketSwap(Packet *p)
switch direction of a packet
Definition: decode.c:488
PktSrcEnum
PktSrcEnum
Definition: decode.h:50
PKT_DROP_REASON_NOT_SET
@ PKT_DROP_REASON_NOT_SET
Definition: decode.h:408
DecodeTunnelProto
DecodeTunnelProto
Definition: decode.h:987
util-print.h
CaptureStatsSetup
void CaptureStatsSetup(ThreadVars *tv, CaptureStats *s)
Definition: decode.c:825
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:982
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:981
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:274
pkt-var.h
DECODE_TUNNEL_PPP
@ DECODE_TUNNEL_PPP
Definition: decode.h:995
FLOW_PKT_TOCLIENT_FIRST
#define FLOW_PKT_TOCLIENT_FIRST
Definition: flow.h:232
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:134
PktSrcToString
const char * PktSrcToString(enum PktSrcEnum pkt_src)
Definition: decode.c:736
DecodeThreadVars_::counter_vlan_qinq
uint16_t counter_vlan_qinq
Definition: decode.h:704
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:668
StringHashFreeFunc
void StringHashFreeFunc(void *data)
Definition: util-hash-string.c:51
BUG_ON
#define BUG_ON(x)
Definition: suricata-common.h:281
PKT_DROP_REASON_RULES
@ PKT_DROP_REASON_RULES
Definition: decode.h:418
DecodeThreadVars_::counter_defrag_ipv6_timeouts
uint16_t counter_defrag_ipv6_timeouts
Definition: decode.h:722
util-profiling.h
PacketCallocExtPkt
int PacketCallocExtPkt(Packet *p, int datalen)
Definition: decode.c:227
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:991
PKT_SRC_DECODER_IPV6
@ PKT_SRC_DECODER_IPV6
Definition: decode.h:54
CaptureStats_::counter_ips_accepted
uint16_t counter_ips_accepted
Definition: decode.h:756
Packet_
Definition: decode.h:442
DecodeThreadVars_::counter_nsh
uint16_t counter_nsh
Definition: decode.h:714
DecodeIPV6
int DecodeIPV6(ThreadVars *tv, DecodeThreadVars *dtv, Packet *p, const uint8_t *pkt, uint16_t len)
Definition: decode-ipv6.c:572
DECODE_TUNNEL_IPV4
@ DECODE_TUNNEL_IPV4
Definition: decode.h:992
GET_PKT_LEN
#define GET_PKT_LEN(p)
Definition: decode.h:235
DecodeThreadVars_::app_tctx
AppLayerThreadCtx * app_tctx
Definition: decode.h:674
DecodeThreadVars_::counter_defrag_ipv4_timeouts
uint16_t counter_defrag_ipv4_timeouts
Definition: decode.h:719
decode-teredo.h
conf.h
DecodeThreadVars_::counter_sll
uint16_t counter_sll
Definition: decode.h:695
PKT_DROP_REASON_STREAM_ERROR
@ PKT_DROP_REASON_STREAM_ERROR
Definition: decode.h:414
DecodeThreadVars_::counter_sctp
uint16_t counter_sctp
Definition: decode.h:698
Packet_::livedev
struct LiveDevice_ * livedev
Definition: decode.h:595
DecodeThreadVars_::counter_invalid
uint16_t counter_invalid
Definition: decode.h:684
DecodeThreadVars_::counter_ieee8021ah
uint16_t counter_ieee8021ah
Definition: decode.h:707
SCReturnPtr
#define SCReturnPtr(x, type)
Definition: util-debug.h:316
output-flow.h
DecodeThreadVars_::counter_ipv4inipv6
uint16_t counter_ipv4inipv6
Definition: decode.h:711
util-mpm-ac.h
FlowGetStorageById
void * FlowGetStorageById(Flow *f, FlowStorageId id)
Definition: flow-storage.c:39
FLOW_PKT_TOCLIENT
#define FLOW_PKT_TOCLIENT
Definition: flow.h:227
DecodeThreadVars_::counter_vlan
uint16_t counter_vlan
Definition: decode.h:703
DECODE_TUNNEL_ETHERNET
@ DECODE_TUNNEL_ETHERNET
Definition: decode.h:988
DecodeThreadVars_::counter_tcp
uint16_t counter_tcp
Definition: decode.h:690
DecodeThreadVars_::counter_pkts
uint16_t counter_pkts
Definition: decode.h:677
FlowUpdateState
void FlowUpdateState(Flow *f, const enum FlowState s)
Definition: flow.c:1161
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:687
Packet_::ReleasePacket
void(* ReleasePacket)(struct Packet_ *)
Definition: decode.h:524
flow-storage.h
Packet_::flow
struct Flow_ * flow
Definition: decode.h:479
Packet_::tenant_id
uint32_t tenant_id
Definition: decode.h:644
DecodeThreadVarsFree
void DecodeThreadVarsFree(ThreadVars *tv, DecodeThreadVars *dtv)
Definition: decode.c:703
DecodeThreadVars_::counter_flow_spare_sync_incomplete
uint16_t counter_flow_spare_sync_incomplete
Definition: decode.h:743
PKT_DROP_REASON_APPLAYER_MEMCAP
@ PKT_DROP_REASON_APPLAYER_MEMCAP
Definition: decode.h:417
Packet_::ts
struct timeval ts
Definition: decode.h:485
DecodeGlobalConfig
void DecodeGlobalConfig(void)
Definition: decode.c:833
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:733
DecodeThreadVars_::counter_ipv6
uint16_t counter_ipv6
Definition: decode.h:689
CaptureStats_::counter_ips_replaced
uint16_t counter_ips_replaced
Definition: decode.h:759
DecodeThreadVars_::counter_gre
uint16_t counter_gre
Definition: decode.h:702
ACTION_DROP
#define ACTION_DROP
Definition: action-globals.h:30
DecodeThreadVars_::counter_esp
uint16_t counter_esp
Definition: decode.h:699
Packet_::ext_pkt
uint8_t * ext_pkt
Definition: decode.h:592
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:721
DecodeThreadVars_::counter_udp
uint16_t counter_udp
Definition: decode.h:691
PacketUpdateEngineEventCounters
void PacketUpdateEngineEventCounters(ThreadVars *tv, DecodeThreadVars *dtv, Packet *p)
Definition: decode.c:154
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:812
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:688
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:173
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_ALERT_MAX
#define PACKET_ALERT_MAX
Definition: decode.h:303
Packet_::root
struct Packet_ * root
Definition: decode.h:627
DecodeThreadVars_::counter_pppoe
uint16_t counter_pppoe
Definition: decode.h:708
DecodeThreadVars_::counter_mpls
uint16_t counter_mpls
Definition: decode.h:710
OutputFlowLogThreadDeinit
TmEcode OutputFlowLogThreadDeinit(ThreadVars *tv, void *thread_data)
Definition: output-flow.c:167
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:672
MAX_PAYLOAD_SIZE
#define MAX_PAYLOAD_SIZE
Definition: decode.h:666
AppLayerDestroyCtxThread
void AppLayerDestroyCtxThread(AppLayerThreadCtx *app_tctx)
Destroys the context created by AppLayeGetCtxThread().
Definition: app-layer.c:1004
Packet_::recursion_level
uint8_t recursion_level
Definition: decode.h:467
DecodeThreadVars_::output_flow_thread_data
void * output_flow_thread_data
Definition: decode.h:750
DecodeThreadVars_::counter_geneve
uint16_t counter_geneve
Definition: decode.h:701
DecodeThreadVars_::counter_max_mac_addrs_dst
uint16_t counter_max_mac_addrs_dst
Definition: decode.h:682
DecodeThreadVarsAlloc
DecodeThreadVars * DecodeThreadVarsAlloc(ThreadVars *tv)
Alloc and setup DecodeThreadVars.
Definition: decode.c:684
DecodeThreadVars_::counter_defrag_max_hit
uint16_t counter_defrag_max_hit
Definition: decode.h:723
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:723
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:970
DECODE_EVENT_MAX
@ DECODE_EVENT_MAX
Definition: decode-events.h:292
DecodeThreadVars_::counter_null
uint16_t counter_null
Definition: decode.h:697
DecodeThreadVars_::counter_icmpv6
uint16_t counter_icmpv6
Definition: decode.h:693
suricata.h
Address_::family
char family
Definition: decode.h:123
PKT_SRC_DECODER_GRE
@ PKT_SRC_DECODER_GRE
Definition: decode.h:52
PacketAlert_
Definition: decode.h:280
DecodeGeneveConfig
void DecodeGeneveConfig(void)
Definition: decode-geneve.c:128
DecodeThreadVars_::counter_flow_memcap
uint16_t counter_flow_memcap
Definition: decode.h:725
DecodeThreadVars_::counter_defrag_ipv6_fragments
uint16_t counter_defrag_ipv6_fragments
Definition: decode.h:720
packet_alert_max
uint16_t packet_alert_max
Definition: decode.c:77
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:976
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:424
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:311
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:956
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:737
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:231
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:211
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
PKT_DROP_REASON_FLOW_DROP
@ PKT_DROP_REASON_FLOW_DROP
Definition: decode.h:413
PACKET_DESTRUCTOR
#define PACKET_DESTRUCTOR(p)
Cleanup a packet so that we can free it. No memset needed..
Definition: decode.h:892
WARN_UNUSED
#define WARN_UNUSED
Definition: suricata-common.h:384
PKT_IS_INVALID
#define PKT_IS_INVALID
Definition: decode.h:1210
DecodeUpdatePacketCounters
void DecodeUpdatePacketCounters(ThreadVars *tv, const DecodeThreadVars *dtv, const Packet *p)
Definition: decode.c:650
DecodeThreadVars_::counter_engine_events
uint16_t counter_engine_events[DECODE_EVENT_MAX]
Definition: decode.h:746
output.h
app-layer.h
PKT_DROP_REASON_DECODE_ERROR
@ PKT_DROP_REASON_DECODE_ERROR
Definition: decode.h:409
DecodeThreadVars_::counter_defrag_ipv4_fragments
uint16_t counter_defrag_ipv4_fragments
Definition: decode.h:717
PacketEngineEvents_::cnt
uint8_t cnt
Definition: decode.h:325