suricata
decode.c
Go to the documentation of this file.
1 /* Copyright (C) 2007-2024 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 "decode.h"
52 
53 #include "packet.h"
54 #include "flow.h"
55 #include "flow-storage.h"
56 #include "tmqh-packetpool.h"
57 #include "app-layer.h"
58 #include "output.h"
59 
60 #include "decode-vxlan.h"
61 #include "decode-geneve.h"
62 #include "decode-erspan.h"
63 #include "decode-teredo.h"
64 #include "decode-arp.h"
65 
66 #include "defrag-hash.h"
67 
68 #include "util-hash.h"
69 #include "util-hash-string.h"
70 #include "util-print.h"
71 #include "util-profiling.h"
72 #include "util-validate.h"
73 #include "util-debug.h"
74 #include "util-exception-policy.h"
75 #include "action-globals.h"
76 
77 uint32_t default_packet_size = 0;
78 extern bool stats_decoder_events;
79 extern const char *stats_decoder_events_prefix;
80 extern bool stats_stream_events;
83 
84 /* Settings order as in the enum */
85 // clang-format off
88  /* EXCEPTION_POLICY_NOT_SET */ false,
89  /* EXCEPTION_POLICY_AUTO */ false,
90  /* EXCEPTION_POLICY_PASS_PACKET */ true,
91  /* EXCEPTION_POLICY_PASS_FLOW */ false,
92  /* EXCEPTION_POLICY_BYPASS_FLOW */ true,
93  /* EXCEPTION_POLICY_DROP_PACKET */ false,
94  /* EXCEPTION_POLICY_DROP_FLOW */ false,
95  /* EXCEPTION_POLICY_REJECT */ true,
96  /* EXCEPTION_POLICY_REJECT_BOTH */ true,
97  },
98  .valid_settings_ips = {
99  /* EXCEPTION_POLICY_NOT_SET */ false,
100  /* EXCEPTION_POLICY_AUTO */ false,
101  /* EXCEPTION_POLICY_PASS_PACKET */ true,
102  /* EXCEPTION_POLICY_PASS_FLOW */ false,
103  /* EXCEPTION_POLICY_BYPASS_FLOW */ true,
104  /* EXCEPTION_POLICY_DROP_PACKET */ true,
105  /* EXCEPTION_POLICY_DROP_FLOW */ false,
106  /* EXCEPTION_POLICY_REJECT */ true,
107  /* EXCEPTION_POLICY_REJECT_BOTH */ true,
108  },
109 };
110 // clang-format on
111 
112 /* Settings order as in the enum */
113 // clang-format off
115  .valid_settings_ids = {
116  /* EXCEPTION_POLICY_NOT_SET */ false,
117  /* EXCEPTION_POLICY_AUTO */ false,
118  /* EXCEPTION_POLICY_PASS_PACKET */ true,
119  /* EXCEPTION_POLICY_PASS_FLOW */ false,
120  /* EXCEPTION_POLICY_BYPASS_FLOW */ true,
121  /* EXCEPTION_POLICY_DROP_PACKET */ false,
122  /* EXCEPTION_POLICY_DROP_FLOW */ false,
123  /* EXCEPTION_POLICY_REJECT */ true,
124  /* EXCEPTION_POLICY_REJECT_BOTH */ true,
125  },
126  .valid_settings_ips = {
127  /* EXCEPTION_POLICY_NOT_SET */ false,
128  /* EXCEPTION_POLICY_AUTO */ false,
129  /* EXCEPTION_POLICY_PASS_PACKET */ true,
130  /* EXCEPTION_POLICY_PASS_FLOW */ false,
131  /* EXCEPTION_POLICY_BYPASS_FLOW */ true,
132  /* EXCEPTION_POLICY_DROP_PACKET */ true,
133  /* EXCEPTION_POLICY_DROP_FLOW */ false,
134  /* EXCEPTION_POLICY_REJECT */ true,
135  /* EXCEPTION_POLICY_REJECT_BOTH */ true,
136  },
137 };
138 // clang-format on
139 
140 /**
141  * \brief Initialize PacketAlerts with dynamic alerts array size
142  *
143  */
145 {
146  return SCCalloc(packet_alert_max, sizeof(PacketAlert));
147 }
148 
149 void PacketAlertRecycle(PacketAlert *pa_array, uint16_t cnt)
150 {
151  if (pa_array == NULL)
152  return;
153  /* Clean json content for alerts attached to the packet */
154  for (int i = 0; i < cnt; i++) {
155  struct PacketContextData *current_json = pa_array[i].json_info;
156  while (current_json) {
157  struct PacketContextData *next_json = current_json->next;
158  SCFree(current_json->json_string);
159  SCFree(current_json);
160  current_json = next_json;
161  }
162  pa_array[i].json_info = NULL;
163  }
164 }
165 
166 /** \brief Release the alert context the drop slot owns, then invalidate the slot.
167  * Not an `alerts[]` entry, so clearing `action` alone leaves it owning the chain;
168  * `action` is the guard consumers read, so a leaked slot still reads as empty.
169  */
171 {
173  p->alerts.drop.action = 0;
174 }
175 
177 {
178  if (pa_array == NULL)
179  return;
180  for (int i = 0; i < packet_alert_max; i++) {
181  struct PacketContextData *allocated_json = pa_array[i].json_info;
182  while (allocated_json) {
183  struct PacketContextData *next_json = allocated_json->next;
184  SCFree(allocated_json->json_string);
185  SCFree(allocated_json);
186  allocated_json = next_json;
187  }
188  }
189  SCFree(pa_array);
190 }
191 
192 static int DecodeTunnel(ThreadVars *, DecodeThreadVars *, Packet *, const uint8_t *, uint32_t,
194 
195 static int DecodeTunnel(ThreadVars *tv, DecodeThreadVars *dtv, Packet *p, const uint8_t *pkt,
196  uint32_t len, enum SCPacketTunnelProto proto)
197 {
198  switch (proto) {
199  case DECODE_TUNNEL_PPP:
200  return DecodePPP(tv, dtv, p, pkt, len);
201  case DECODE_TUNNEL_IPV4:
202  DEBUG_VALIDATE_BUG_ON(len > UINT16_MAX);
203  return DecodeIPV4(tv, dtv, p, pkt, (uint16_t)len);
204  case DECODE_TUNNEL_IPV6:
206  return DecodeIPV6(tv, dtv, p, pkt, len);
207  case DECODE_TUNNEL_VLAN:
208  return DecodeVLAN(tv, dtv, p, pkt, len);
210  return DecodeEthernet(tv, dtv, p, pkt, len);
212  return DecodeERSPAN(tv, dtv, p, pkt, len);
214  return DecodeERSPANTypeI(tv, dtv, p, pkt, len);
215  case DECODE_TUNNEL_VXLAN:
216  return DecodeEthernet(tv, dtv, p, pkt, len);
217  case DECODE_TUNNEL_NSH:
218  return DecodeNSH(tv, dtv, p, pkt, len);
219  case DECODE_TUNNEL_ARP:
220  return DecodeARP(tv, dtv, p, pkt, len);
221  default:
222  SCLogDebug("FIXME: DecodeTunnel: protocol %" PRIu32 " not supported.", proto);
223  break;
224  }
225  return TM_ECODE_OK;
226 }
227 
228 /**
229  * \brief Return a malloced packet.
230  */
232 {
234  SCFree(p);
235 }
236 
237 /**
238  * \brief Finalize decoding of a packet
239  *
240  * This function needs to be call at the end of decode
241  * functions when decoding has been successful.
242  *
243  */
245 {
246  if (p->flags & PKT_IS_INVALID) {
248  }
249 }
250 
253 {
254  for (uint8_t i = 0; i < p->events.cnt; i++) {
255  const uint8_t e = p->events.events[i];
256 
258  continue;
260  continue;
262  }
263 }
264 
265 /**
266  * \brief Get a malloced packet.
267  *
268  * \retval p packet, NULL on error
269  */
271 {
273  if (unlikely(p == NULL)) {
274  return NULL;
275  }
276  if (!PacketInit(p)) {
277  SCFree(p);
278  return NULL;
279  }
281 
282  SCLogDebug("allocated a new packet only using alloc...");
283 
285  return p;
286 }
287 
288 /**
289  * \brief Return a packet to where it was allocated.
290  */
292 {
293  if (likely(p->pool != NULL)) {
296  } else {
297  PacketFree(p);
298  }
299 }
300 
301 /**
302  * \brief Get a packet. We try to get a packet from the packetpool first, but
303  * if that is empty we alloc a packet that is free'd again after
304  * processing.
305  *
306  * \retval p packet, NULL on error
307  */
309 {
310  /* try the pool first */
312 
313  if (p == NULL) {
314  /* non fatal, we're just not processing a packet then */
315  p = PacketGetFromAlloc();
316  } else {
319  }
320 
321  return p;
322 }
323 
324 inline int PacketCallocExtPkt(Packet *p, int datalen)
325 {
326  if (! p->ext_pkt) {
327  p->ext_pkt = SCCalloc(1, datalen);
328  if (unlikely(p->ext_pkt == NULL)) {
329  SET_PKT_LEN(p, 0);
330  return -1;
331  }
332  }
333  return 0;
334 }
335 
336 /**
337  * \brief Copy data to Packet payload at given offset
338  *
339  * This function copies data/payload to a Packet. It uses the
340  * space allocated at Packet creation (pointed by Packet::pkt)
341  * or allocate some memory (pointed by Packet::ext_pkt) if the
342  * data size is to big to fit in initial space (of size
343  * default_packet_size).
344  *
345  * \param Pointer to the Packet to modify
346  * \param Offset of the copy relatively to payload of Packet
347  * \param Pointer to the data to copy
348  * \param Length of the data to copy
349  */
350 inline int PacketCopyDataOffset(Packet *p, uint32_t offset, const uint8_t *data, uint32_t datalen)
351 {
352  if (unlikely(offset + datalen > MAX_PAYLOAD_SIZE)) {
353  /* too big */
354  SET_PKT_LEN(p, 0);
355  return -1;
356  }
357 
358  /* Do we have already an packet with allocated data */
359  if (! p->ext_pkt) {
360  uint32_t newsize = offset + datalen;
361  // check overflow
362  if (newsize < offset)
363  return -1;
364  if (newsize <= default_packet_size) {
365  /* data will fit in memory allocated with packet */
366  memcpy(GET_PKT_DIRECT_DATA(p) + offset, data, datalen);
367  } else {
368  /* here we need a dynamic allocation */
369 #ifdef FUZZING_BUILD_MODE_UNSAFE_FOR_PRODUCTION
370  p->ext_pkt = SCMalloc(offset + datalen);
371 #else
373 #endif
374  if (unlikely(p->ext_pkt == NULL)) {
375  SET_PKT_LEN(p, 0);
376  return -1;
377  }
378  /* copy initial data */
380  /* copy data as asked */
381  memcpy(p->ext_pkt + offset, data, datalen);
382  }
383  } else {
384  memcpy(p->ext_pkt + offset, data, datalen);
385  }
386  return 0;
387 }
388 
389 /**
390  * \brief Copy data to Packet payload and set packet length
391  *
392  * \param Pointer to the Packet to modify
393  * \param Pointer to the data to copy
394  * \param Length of the data to copy
395  */
396 inline int PacketCopyData(Packet *p, const uint8_t *pktdata, uint32_t pktlen)
397 {
398  SET_PKT_LEN(p, pktlen);
399  return PacketCopyDataOffset(p, 0, pktdata, pktlen);
400 }
401 
402 static void *decode_tunnels_map;
403 
404 void PacketSetTunnelId(Packet *p, uint32_t session)
405 {
406  if (p->tunnel_id) {
407  // set only the tunnel id for the first layer of encapsulation
408  return;
409  }
410  if (decode_tunnels_map == NULL || p->root == NULL || !PacketIsIPv4(p->root)) {
411  p->tunnel_id = 0;
412  return;
413  }
414  struct flowtunnel_keys k = {};
415  k.src = htonl(GET_IPV4_SRC_ADDR_U32(p->root));
416  k.dst = htonl(GET_IPV4_DST_ADDR_U32(p->root));
417  k.session = session;
418  k.tunnel_proto = (uint8_t)p->tproto;
419  p->tunnel_id = DecodeTunnelsId(decode_tunnels_map, k);
420 }
422  const uint8_t *pkt, uint32_t len, enum SCPacketTunnelProto proto, uint32_t *session)
423 {
424  int ret;
425 
426  SCEnter();
427 
428  if (parent->nb_decoded_layers + 1 >= decoder_max_layers) {
430  SCReturnPtr(NULL, "Packet");
431  }
432 
433  /* get us a packet */
435  if (unlikely(p == NULL)) {
436  SCReturnPtr(NULL, "Packet");
437  }
438 
439  /* copy packet and set length, proto */
440  PacketCopyData(p, pkt, len);
441  DEBUG_VALIDATE_BUG_ON(parent->recursion_level == 255);
442  p->recursion_level = parent->recursion_level + 1;
444  p->nb_decoded_layers = parent->nb_decoded_layers + 1;
445  p->ts = parent->ts;
446  p->datalink = DLT_RAW;
447  p->tenant_id = parent->tenant_id;
448  p->livedev_id = parent->livedev_id;
449 
450  /* set the root ptr to the lowest layer */
451  if (parent->root != NULL) {
452  p->root = parent->root;
453  BUG_ON(!PacketIsTunnelChild(parent));
454  } else {
455  p->root = parent;
456  parent->ttype = PacketTunnelRoot;
457  }
458  /* tell new packet it's part of a tunnel */
460  p->tproto = (uint8_t)proto;
461  p->tunnel_id = parent->tunnel_id;
462  if (session) {
463  PacketSetTunnelId(p, *session);
464  }
465 
466  ret = DecodeTunnel(tv, dtv, p, GET_PKT_DATA(p),
467  GET_PKT_LEN(p), proto);
468 
469  if (unlikely(ret != TM_ECODE_OK) ||
471  {
472  /* Not a (valid) tunnel packet */
473  SCLogDebug("tunnel packet is invalid");
474  p->root = NULL;
476  SCReturnPtr(NULL, "Packet");
477  }
478 
479  /* Update tunnel settings in parent */
480  if (parent->root == NULL) {
481  parent->ttype = PacketTunnelRoot;
482  }
483  TUNNEL_INCR_PKT_TPR(p);
484 
485  /* disable payload (not packet) inspection on the parent, as the payload
486  * is the packet we will now run through the system separately. We do
487  * check it against the ip/port/other header checks though */
488  DecodeSetNoPayloadInspectionFlag(parent);
489  SCReturnPtr(p, "Packet");
490 }
491 
492 /**
493  * \brief Setup a pseudo packet (tunnel)
494  *
495  * \param parent parent packet for this pseudo pkt
496  * \param pkt raw packet data
497  * \param len packet data length
498  * \param proto protocol of the tunneled packet
499  *
500  * \retval p the pseudo packet or NULL if out of memory
501  */
503  const uint8_t *pkt, uint32_t len, enum SCPacketTunnelProto proto)
504 {
505  return PacketTunnelPktSetupWithSession(tv, dtv, parent, pkt, len, proto, NULL);
506 }
507 
508 /**
509  * \brief Setup a pseudo packet (reassembled frags)
510  *
511  * Difference with PacketPseudoPktSetup is that this func doesn't increment
512  * the recursion level. It needs to be on the same level as the frags because
513  * we run the flow engine against this and we need to get the same flow.
514  *
515  * \param parent parent packet for this pseudo pkt
516  * \param pkt raw packet data
517  * \param len packet data length
518  * \param proto protocol of the tunneled packet
519  *
520  * \retval p the pseudo packet or NULL if out of memory
521  */
522 Packet *PacketDefragPktSetup(Packet *parent, const uint8_t *pkt, uint32_t len, uint8_t proto)
523 {
524  SCEnter();
525 
526  /* get us a packet */
528  if (unlikely(p == NULL)) {
529  SCReturnPtr(NULL, "Packet");
530  }
531 
532  /* set the root ptr to the lowest layer */
533  if (parent->root != NULL) {
534  p->root = parent->root;
535  BUG_ON(!PacketIsTunnelChild(parent));
536  } else {
537  p->root = parent;
538  // we set parent->ttype later
539  }
540  /* tell new packet it's part of a tunnel */
542 
543 #ifdef FUZZING_BUILD_MODE_UNSAFE_FOR_PRODUCTION
544  if (!p->ext_pkt) {
546  if (unlikely(p->ext_pkt == NULL)) {
548  return NULL;
549  }
550  }
551 #endif
552  /* copy packet and set length, proto */
553  if (pkt && len) {
554  PacketCopyData(p, pkt, len);
555  }
556  p->recursion_level = parent->recursion_level; /* NOT incremented */
558  p->ts = parent->ts;
559  p->tenant_id = parent->tenant_id;
560  memcpy(&p->vlan_id[0], &parent->vlan_id[0], sizeof(p->vlan_id));
561  p->vlan_idx = parent->vlan_idx;
562  p->livedev_id = parent->livedev_id;
563  p->tunnel_id = parent->tunnel_id;
564 
565  SCReturnPtr(p, "Packet");
566 }
567 
568 /**
569  * \brief inform defrag "parent" that a pseudo packet is
570  * now associated to it.
571  */
573 {
574  /* tell parent packet it's part of a tunnel */
575  if (parent->ttype == PacketTunnelNone)
576  parent->ttype = PacketTunnelRoot;
577 
578  /* increment tunnel packet refcnt in the root packet */
579  TUNNEL_INCR_PKT_TPR(parent);
580 
581  /* disable payload (not packet) inspection on the parent, as the payload
582  * is the packet we will now run through the system separately. We do
583  * check it against the ip/port/other header checks though */
584  DecodeSetNoPayloadInspectionFlag(parent);
585 }
586 
587 /**
588  * \note if p->flow is set, the flow is locked
589  */
591 {
592  if (PKT_IS_PSEUDOPKT(p))
593  return;
594 
595 #ifdef CAPTURE_OFFLOAD
596  /* Don't try to bypass if flow is already out or
597  * if we have failed to do it once */
598  if (p->flow) {
599  int state = p->flow->flow_state;
600  if ((state == FLOW_STATE_LOCAL_BYPASSED) ||
601  (state == FLOW_STATE_CAPTURE_BYPASSED)) {
602  return;
603  }
604 
605  FlowBypassInfo *fc;
606 
608  if (fc == NULL) {
609  fc = SCCalloc(sizeof(FlowBypassInfo), 1);
610  if (fc) {
612  } else {
613  return;
614  }
615  }
616  }
618  if (p->flow) {
619  FlowUpdateState(p->flow, FLOW_STATE_CAPTURE_BYPASSED);
620  }
621  } else {
622  if (p->flow) {
624  }
625  }
626 #else /* CAPTURE_OFFLOAD */
627  if (p->flow) {
628  int state = p->flow->flow_state;
629  if (state == FLOW_STATE_LOCAL_BYPASSED)
630  return;
632  }
633 #endif
634 }
635 
636 /** \brief switch direction of a packet */
638 {
639  if (PKT_IS_TOSERVER(p)) {
642 
646  }
647  } else {
650 
654  }
655  }
656 }
657 
658 /* counter name store */
659 static HashTable *g_counter_table = NULL;
660 static SCMutex g_counter_table_mutex = SCMUTEX_INITIALIZER;
661 
663 {
664  SCMutexLock(&g_counter_table_mutex);
665  if (g_counter_table) {
666  HashTableFree(g_counter_table);
667  g_counter_table = NULL;
668  }
669  SCMutexUnlock(&g_counter_table_mutex);
670 }
671 
673 {
674  DecodeTunnelsFree(decode_tunnels_map);
675  decode_tunnels_map = NULL;
676 }
677 
678 static bool IsDefragMemcapExceptionPolicyStatsValid(enum ExceptionPolicy policy)
679 {
680  if (EngineModeIsIPS()) {
682  }
684 }
685 
686 static bool IsFlowMemcapExceptionPolicyStatsValid(enum ExceptionPolicy policy)
687 {
688  if (EngineModeIsIPS()) {
690  }
692 }
693 
695 {
696  /* register counters */
697  dtv->counter_pkts = StatsRegisterCounter("decoder.pkts", &tv->stats);
698  dtv->counter_bytes = StatsRegisterCounter("decoder.bytes", &tv->stats);
699  dtv->counter_invalid = StatsRegisterCounter("decoder.invalid", &tv->stats);
700  dtv->counter_ipv4 = StatsRegisterCounter("decoder.ipv4", &tv->stats);
701  dtv->counter_ipv6 = StatsRegisterCounter("decoder.ipv6", &tv->stats);
702  dtv->counter_eth = StatsRegisterCounter("decoder.ethernet", &tv->stats);
703  dtv->counter_arp = StatsRegisterCounter("decoder.arp", &tv->stats);
704  dtv->counter_ethertype_unknown = StatsRegisterCounter("decoder.unknown_ethertype", &tv->stats);
705  dtv->counter_chdlc = StatsRegisterCounter("decoder.chdlc", &tv->stats);
706  dtv->counter_raw = StatsRegisterCounter("decoder.raw", &tv->stats);
707  dtv->counter_null = StatsRegisterCounter("decoder.null", &tv->stats);
708  dtv->counter_sll = StatsRegisterCounter("decoder.sll", &tv->stats);
709  dtv->counter_sll2 = StatsRegisterCounter("decoder.sll2", &tv->stats);
710  dtv->counter_tcp = StatsRegisterCounter("decoder.tcp", &tv->stats);
711 
713  dtv->counter_tcp_synack = StatsRegisterCounter("tcp.synack", &tv->stats);
716 
717  dtv->counter_udp = StatsRegisterCounter("decoder.udp", &tv->stats);
718  dtv->counter_sctp = StatsRegisterCounter("decoder.sctp", &tv->stats);
720  dtv->counter_sctp_init_ack = StatsRegisterCounter("sctp.init_ack", &tv->stats);
722  dtv->counter_sctp_abort = StatsRegisterCounter("sctp.abort", &tv->stats);
723  dtv->counter_sctp_shutdown = StatsRegisterCounter("sctp.shutdown", &tv->stats);
724  dtv->counter_esp = StatsRegisterCounter("decoder.esp", &tv->stats);
725  dtv->counter_icmpv4 = StatsRegisterCounter("decoder.icmpv4", &tv->stats);
726  dtv->counter_icmpv6 = StatsRegisterCounter("decoder.icmpv6", &tv->stats);
727  dtv->counter_igmp = StatsRegisterCounter("decoder.igmp", &tv->stats);
728  dtv->counter_ppp = StatsRegisterCounter("decoder.ppp", &tv->stats);
729  dtv->counter_pppoe = StatsRegisterCounter("decoder.pppoe", &tv->stats);
730  dtv->counter_geneve = StatsRegisterCounter("decoder.geneve", &tv->stats);
731  dtv->counter_gre = StatsRegisterCounter("decoder.gre", &tv->stats);
732  dtv->counter_vlan = StatsRegisterCounter("decoder.vlan", &tv->stats);
733  dtv->counter_vlan_qinq = StatsRegisterCounter("decoder.vlan_qinq", &tv->stats);
734  dtv->counter_vlan_qinqinq = StatsRegisterCounter("decoder.vlan_qinqinq", &tv->stats);
735  dtv->counter_vxlan = StatsRegisterCounter("decoder.vxlan", &tv->stats);
736  dtv->counter_vntag = StatsRegisterCounter("decoder.vntag", &tv->stats);
737  dtv->counter_etag = StatsRegisterCounter("decoder.etag", &tv->stats);
738  dtv->counter_ieee8021ah = StatsRegisterCounter("decoder.ieee8021ah", &tv->stats);
739  dtv->counter_teredo = StatsRegisterCounter("decoder.teredo", &tv->stats);
740  dtv->counter_ipv4inipv4 = StatsRegisterCounter("decoder.ipv4_in_ipv4", &tv->stats);
741  dtv->counter_ipv6inipv4 = StatsRegisterCounter("decoder.ipv6_in_ipv4", &tv->stats);
742  dtv->counter_ipv4inipv6 = StatsRegisterCounter("decoder.ipv4_in_ipv6", &tv->stats);
743  dtv->counter_ipv6inipv6 = StatsRegisterCounter("decoder.ipv6_in_ipv6", &tv->stats);
745  StatsRegisterCounter("decoder.ipv4.unknown_protocol", &tv->stats);
746  dtv->counter_mpls = StatsRegisterCounter("decoder.mpls", &tv->stats);
748  "decoder.avg_pkt_size", "decoder.bytes", "decoder.pkts", &tv->stats);
749  dtv->counter_max_pkt_size = StatsRegisterMaxCounter("decoder.max_pkt_size", &tv->stats);
751  StatsRegisterMaxCounter("decoder.max_mac_addrs_src", &tv->stats);
753  StatsRegisterMaxCounter("decoder.max_mac_addrs_dst", &tv->stats);
754  dtv->counter_erspan = StatsRegisterCounter("decoder.erspan", &tv->stats);
755  dtv->counter_nsh = StatsRegisterCounter("decoder.nsh", &tv->stats);
756  dtv->counter_flow_memcap = StatsRegisterCounter("flow.memcap", &tv->stats);
758  FlowGetMemcapExceptionPolicy(), "exception_policy.flow.memcap.",
759  IsFlowMemcapExceptionPolicyStatsValid);
760 
761  dtv->counter_tcp_active_sessions = StatsRegisterCounter("tcp.active_sessions", &tv->stats);
762  dtv->counter_flow_total = StatsRegisterCounter("flow.total", &tv->stats);
763  dtv->counter_flow_active = StatsRegisterCounter("flow.active", &tv->stats);
766  dtv->counter_flow_icmp4 = StatsRegisterCounter("flow.icmpv4", &tv->stats);
767  dtv->counter_flow_icmp6 = StatsRegisterCounter("flow.icmpv6", &tv->stats);
768  dtv->counter_flow_tcp_reuse = StatsRegisterCounter("flow.tcp_reuse", &tv->stats);
769  dtv->counter_flow_elephant = StatsRegisterCounter("flow.elephant", &tv->stats);
771  StatsRegisterCounter("flow.elephant_toserver", &tv->stats);
773  StatsRegisterCounter("flow.elephant_toclient", &tv->stats);
774  dtv->counter_flow_get_used = StatsRegisterCounter("flow.get_used", &tv->stats);
775  dtv->counter_flow_get_used_eval = StatsRegisterCounter("flow.get_used_eval", &tv->stats);
777  StatsRegisterCounter("flow.get_used_eval_reject", &tv->stats);
779  StatsRegisterCounter("flow.get_used_eval_busy", &tv->stats);
780  dtv->counter_flow_get_used_failed = StatsRegisterCounter("flow.get_used_failed", &tv->stats);
781 
783  StatsRegisterAvgCounter("flow.wrk.spare_sync_avg", &tv->stats);
784  dtv->counter_flow_spare_sync = StatsRegisterCounter("flow.wrk.spare_sync", &tv->stats);
786  StatsRegisterCounter("flow.wrk.spare_sync_incomplete", &tv->stats);
788  StatsRegisterCounter("flow.wrk.spare_sync_empty", &tv->stats);
789 
790  dtv->counter_defrag_ipv4_fragments = StatsRegisterCounter("defrag.ipv4.fragments", &tv->stats);
792  StatsRegisterCounter("defrag.ipv4.reassembled", &tv->stats);
793  dtv->counter_defrag_ipv6_fragments = StatsRegisterCounter("defrag.ipv6.fragments", &tv->stats);
795  StatsRegisterCounter("defrag.ipv6.reassembled", &tv->stats);
796  dtv->counter_defrag_max_hit = StatsRegisterCounter("defrag.max_trackers_reached", &tv->stats);
797  dtv->counter_defrag_no_frags = StatsRegisterCounter("defrag.max_frags_reached", &tv->stats);
799  StatsRegisterCounter("defrag.tracker_soft_reuse", &tv->stats);
801  StatsRegisterCounter("defrag.tracker_hard_reuse", &tv->stats);
803  StatsRegisterCounter("defrag.wrk.tracker_timeout", &tv->stats);
804 
806  DefragGetMemcapExceptionPolicy(), "exception_policy.defrag.memcap.",
807  IsDefragMemcapExceptionPolicyStatsValid);
808 
809  for (int i = 0; i < DECODE_EVENT_MAX; i++) {
810  BUG_ON(i != (int)DEvents[i].code);
811 
813  continue;
815  continue;
816 
817  if (i < DECODE_EVENT_PACKET_MAX &&
818  strncmp(DEvents[i].event_name, "decoder.", 8) == 0)
819  {
820  SCMutexLock(&g_counter_table_mutex);
821  if (g_counter_table == NULL) {
822  g_counter_table = HashTableInit(256, StringHashFunc,
825  if (g_counter_table == NULL) {
826  FatalError("decoder counter hash "
827  "table init failed");
828  }
829  }
830 
831  char name[256];
832  const char *dot = strchr(DEvents[i].event_name, '.');
833  BUG_ON(!dot);
834  snprintf(name, sizeof(name), "%s.%s",
836 
837  const char *found = HashTableLookup(g_counter_table, name, 0);
838  if (!found) {
839  char *add = SCStrdup(name);
840  if (add == NULL)
841  FatalError("decoder counter hash "
842  "table name init failed");
843  int r = HashTableAdd(g_counter_table, add, 0);
844  if (r != 0)
845  FatalError("decoder counter hash "
846  "table name add failed");
847  found = add;
848  }
850 
851  SCMutexUnlock(&g_counter_table_mutex);
852  } else {
854  }
855  }
856 }
857 
859  const DecodeThreadVars *dtv, const Packet *p)
860 {
864 }
865 
866 /**
867  * \brief Debug print function for printing addresses
868  *
869  * \param Address object
870  *
871  * \todo IPv6
872  */
874 {
875  if (a == NULL)
876  return;
877 
878  switch (a->family) {
879  case AF_INET:
880  {
881  char s[16];
882  PrintInet(AF_INET, (const void *)&a->addr_data32[0], s, sizeof(s));
883  SCLogDebug("%s", s);
884  break;
885  }
886  }
887 }
888 
889 /** \brief Alloc and setup DecodeThreadVars */
891 {
892  DecodeThreadVars *dtv = NULL;
893 
894  if ((dtv = SCCalloc(1, sizeof(DecodeThreadVars))) == NULL)
895  return NULL;
896 
898 
900  SCLogError("initializing flow log API for thread failed");
902  return NULL;
903  }
904 
905  return dtv;
906 }
907 
909 {
910  if (dtv != NULL) {
911  if (dtv->app_tctx != NULL)
913 
914  if (dtv->output_flow_thread_data != NULL)
916 
917  SCFree(dtv);
918  }
919 }
920 
921 /**
922  * \brief Set data for Packet and set length when zero copy is used
923  *
924  * \param Pointer to the Packet to modify
925  * \param Pointer to the data
926  * \param Length of the data
927  */
928 inline int PacketSetData(Packet *p, const uint8_t *pktdata, uint32_t pktlen)
929 {
930  SET_PKT_LEN(p, pktlen);
931  if (unlikely(!pktdata)) {
932  return -1;
933  }
934  // ext_pkt cannot be const (because we sometimes copy)
935  p->ext_pkt = (uint8_t *) pktdata;
936  p->flags |= PKT_ZERO_COPY;
937 
938  return 0;
939 }
940 
941 const char *PktSrcToString(enum PktSrcEnum pkt_src)
942 {
943  const char *pkt_src_str = NULL;
944  switch (pkt_src) {
945  case PKT_SRC_WIRE:
946  pkt_src_str = "wire/pcap";
947  break;
948  case PKT_SRC_DECODER_GRE:
949  pkt_src_str = "gre tunnel";
950  break;
952  pkt_src_str = "ipv4 tunnel";
953  break;
955  pkt_src_str = "ipv6 tunnel";
956  break;
958  pkt_src_str = "teredo tunnel";
959  break;
960  case PKT_SRC_DEFRAG:
961  pkt_src_str = "defrag";
962  break;
964  pkt_src_str = "stream (detect/log)";
965  break;
966  case PKT_SRC_FFR:
967  pkt_src_str = "stream (flow timeout)";
968  break;
970  pkt_src_str = "geneve encapsulation";
971  break;
973  pkt_src_str = "vxlan encapsulation";
974  break;
976  pkt_src_str = "detect reload flush";
977  break;
979  pkt_src_str = "capture timeout flush";
980  break;
982  pkt_src_str = "shutdown flush";
983  break;
984  }
985  DEBUG_VALIDATE_BUG_ON(pkt_src_str == NULL);
986  return pkt_src_str;
987 }
988 
990 {
991  switch (r) {
993  return "decode error";
995  return "defrag error";
997  return "defrag memcap";
999  return "flow memcap";
1001  return "flow drop";
1003  return "exception policy flow drop";
1005  return "stream error";
1007  return "stream memcap";
1009  return "stream midstream";
1011  return "stream urgent";
1013  return "stream reassembly";
1015  return "applayer error";
1017  return "applayer memcap";
1018  case PKT_DROP_REASON_RULES:
1019  return "rules";
1021  return "threshold detection_filter";
1023  return "nfq error";
1025  return "tunnel packet drop";
1027  return "firewall rules";
1029  return "firewall default packet policy";
1031  return "firewall default app policy";
1033  return "firewall pre stream hook";
1035  return "firewall pre flow hook";
1037  return "firewall flow drop";
1039  case PKT_DROP_REASON_MAX:
1040  return NULL;
1041  }
1042  return NULL;
1043 }
1044 
1045 static const char *PacketDropReasonToJsonString(enum PacketDropReason r)
1046 {
1047  switch (r) {
1049  return "ips.drop_reason.decode_error";
1051  return "ips.drop_reason.defrag_error";
1053  return "ips.drop_reason.defrag_memcap";
1055  return "ips.drop_reason.flow_memcap";
1057  return "ips.drop_reason.flow_drop";
1059  return "ips.drop_reason.exception_policy_flow_drop";
1061  return "ips.drop_reason.stream_error";
1063  return "ips.drop_reason.stream_memcap";
1065  return "ips.drop_reason.stream_midstream";
1067  return "ips.drop_reason.stream_urgent";
1069  return "ips.drop_reason.stream_reassembly";
1071  return "ips.drop_reason.applayer_error";
1073  return "ips.drop_reason.applayer_memcap";
1074  case PKT_DROP_REASON_RULES:
1075  return "ips.drop_reason.rules";
1077  return "ips.drop_reason.threshold_detection_filter";
1079  return "ips.drop_reason.nfq_error";
1081  return "ips.drop_reason.tunnel_packet_drop";
1083  return "firewall.drop_reason.rules";
1085  return "firewall.drop_reason.pre_stream_hook";
1087  return "firewall.drop_reason.pre_flow_hook";
1089  return "firewall.drop_reason.flow_drop";
1091  return "firewall.drop_reason.default_packet_policy";
1093  return "firewall.drop_reason.default_app_policy";
1095  case PKT_DROP_REASON_MAX:
1096  return NULL;
1097  }
1098  return NULL;
1099 }
1100 
1101 typedef struct CaptureStats_ {
1109 
1112 
1114 
1115 static bool VerdictByFirewall(const Packet *p)
1116 {
1117  if (!EngineModeIsFirewall()) {
1118  return false;
1119  }
1121  return true;
1122  }
1123  return false;
1124 }
1125 
1127 {
1128  if (!EngineModeIsIPS() || PKT_IS_PSEUDOPKT(p))
1129  return;
1130 
1132 
1133  if (EngineModeIsFirewall()) {
1134  /** The firewall mode and its stats counters should work as when there are two different
1135  * devices for the firewall control and the IPS control.
1136  * As such, if the firewall blocks a packet, it won't reach the IPS level of evaluation,
1137  * so won't be counted in either stats.
1138  * When the firewall accepts a packet, it can still be blocked, rejected or accepted by
1139  * IPS rules and policies.
1140  */
1142  if (VerdictByFirewall(p)) {
1144  } else {
1147  }
1148  } else if (PacketCheckAction(p, ACTION_DROP)) {
1149  if (VerdictByFirewall(p)) {
1151  } else {
1152  /* If a packet was dropped by IPS, it had to first be accepted by the firewall, to
1153  * reach the IPS flow control */
1156  }
1157  } else if (PacketCheckAction(p, ACTION_ACCEPT)) {
1160  }
1161  } else {
1164  } else if (unlikely(PacketCheckAction(p, ACTION_DROP))) {
1166  } else if (unlikely(p->flags & PKT_STREAM_MODIFIED)) {
1168  } else {
1170  }
1171  }
1172 
1175  }
1176 }
1177 
1179 {
1180  if (EngineModeIsIPS()) {
1182  s->counter_ips_accepted = StatsRegisterCounter("ips.accepted", &tv->stats);
1183  s->counter_ips_blocked = StatsRegisterCounter("ips.blocked", &tv->stats);
1184  s->counter_ips_rejected = StatsRegisterCounter("ips.rejected", &tv->stats);
1185  s->counter_ips_replaced = StatsRegisterCounter("ips.replaced", &tv->stats);
1186  for (int i = PKT_DROP_REASON_NOT_SET; i <= PKT_DROP_REASON_NON_FW_MAX; i++) {
1187  const char *name = PacketDropReasonToJsonString(i);
1188  if (name != NULL)
1190  }
1191  if (EngineModeIsFirewall()) {
1192  s->counter_fw_accepted = StatsRegisterCounter("firewall.accepted", &tv->stats);
1193  s->counter_fw_blocked = StatsRegisterCounter("firewall.blocked", &tv->stats);
1194  s->counter_fw_rejected = StatsRegisterCounter("firewall.rejected", &tv->stats);
1195  for (int i = PKT_DROP_REASON_FW_RULES; i < PKT_DROP_REASON_MAX; i++) {
1196  const char *name = PacketDropReasonToJsonString(i);
1197  if (name != NULL)
1199  }
1200  }
1201  }
1202 }
1203 
1205 {
1210  decode_tunnels_map = DecodeTunnelsConfig();
1211  if (decode_tunnels_map && (EngineModeIsIPS() || EngineModeIsFirewall())) {
1212  SCLogWarning("Tunnels are not meant to be used in IPS or firewall mode");
1213  }
1214  intmax_t value = 0;
1215  if (SCConfGetInt("decoder.max-layers", &value) == 1) {
1216  if (value < 0 || value > UINT8_MAX) {
1217  SCLogWarning("Invalid value for decoder.max-layers");
1218  } else {
1219  decoder_max_layers = (uint8_t)value;
1220  }
1221  }
1223 }
1224 
1226 {
1227  intmax_t max = 0;
1228  if (SCConfGetInt("packet-alert-max", &max) == 1) {
1229  if (max <= 0 || max > UINT8_MAX) {
1230  SCLogWarning("Invalid value for packet-alert-max, default value set instead");
1231  } else {
1232  packet_alert_max = (uint16_t)max;
1233  }
1234  }
1235  SCLogDebug("detect->packet_alert_max set to %d", packet_alert_max);
1236 }
1237 
1238 static inline bool PcapPacketCntRunmodeCanAccess(void)
1239 {
1240  SCRunMode m = SCRunmodeGet();
1242 }
1243 
1244 inline uint64_t PcapPacketCntGet(const Packet *p)
1245 {
1246  if (PcapPacketCntRunmodeCanAccess() && p != NULL) {
1247  return p->pcap_v.pcap_cnt;
1248  }
1249  return 0;
1250 }
1251 
1252 inline void PcapPacketCntSet(Packet *p, uint64_t pcap_cnt)
1253 {
1254  if (PcapPacketCntRunmodeCanAccess() && p != NULL) {
1255  p->pcap_v.pcap_cnt = pcap_cnt;
1256  }
1257 }
1258 
1259 /**
1260  * @}
1261  */
DECODE_TUNNEL_ARP
@ DECODE_TUNNEL_ARP
Definition: decode.h:38
PacketCheckAction
bool PacketCheckAction(const Packet *p, const uint8_t a)
Definition: packet.c:50
SCRunMode
enum SCRunModes SCRunMode
PcapPacketVars_::pcap_cnt
uint64_t pcap_cnt
Definition: source-pcap.h:38
PKT_DROP_REASON_DEFRAG_MEMCAP
@ PKT_DROP_REASON_DEFRAG_MEMCAP
Definition: decode.h:405
DecodeThreadVars_::counter_flow_icmp6
StatsCounterId counter_flow_icmp6
Definition: decode.h:1104
PKT_DROP_REASON_DEFRAG_ERROR
@ PKT_DROP_REASON_DEFRAG_ERROR
Definition: decode.h:404
util-hash-string.h
PKT_DROP_REASON_RULES_THRESHOLD
@ PKT_DROP_REASON_RULES_THRESHOLD
Definition: decode.h:412
DECODE_TUNNEL_PPP
@ DECODE_TUNNEL_PPP
Definition: decode.h:36
len
uint8_t len
Definition: app-layer-dnp3.h:2
StatsCounterMaxUpdateI64
void StatsCounterMaxUpdateI64(StatsThreadContext *stats, StatsCounterMaxId id, int64_t x)
update the value of the localmax counter
Definition: counters.c:222
DecodeThreadVars_::counter_icmpv4
StatsCounterId counter_icmpv4
Definition: decode.h:1045
DecodeThreadVars_::counter_defrag_ipv6_fragments
StatsCounterId counter_defrag_ipv6_fragments
Definition: decode.h:1086
DecodeThreadVars_::counter_esp
StatsCounterId counter_esp
Definition: decode.h:1061
DecodeThreadVars_::counter_ethertype_unknown
StatsCounterId counter_ethertype_unknown
Definition: decode.h:1049
decode-erspan.h
decode-vxlan.h
OutputFlowLogThreadInit
TmEcode OutputFlowLogThreadInit(ThreadVars *tv, void **data)
thread init for the flow logger This will run the thread init functions for the individual registered...
Definition: output-flow.c:121
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:75
PKT_DROP_REASON_FW_FLOW_DROP
@ PKT_DROP_REASON_FW_FLOW_DROP
Definition: decode.h:430
DecodeThreadVars_::counter_ipv6
StatsCounterId counter_ipv6
Definition: decode.h:1038
DecodeThreadVars_::counter_raw
StatsCounterId counter_raw
Definition: decode.h:1053
PacketFreeOrRelease
void PacketFreeOrRelease(Packet *p)
Return a packet to where it was allocated.
Definition: decode.c:291
DecodeThreadVars_::counter_vlan_qinqinq
StatsCounterId counter_vlan_qinqinq
Definition: decode.h:1067
DecodeThreadVars_::counter_flow_get_used_eval_busy
StatsCounterId counter_flow_get_used_eval_busy
Definition: decode.h:1112
DecodePPP
int DecodePPP(ThreadVars *tv, DecodeThreadVars *dtv, Packet *p, const uint8_t *pkt, uint32_t len)
Definition: decode-ppp.c:171
PacketCopyData
int PacketCopyData(Packet *p, const uint8_t *pktdata, uint32_t pktlen)
Copy data to Packet payload and set packet length.
Definition: decode.c:396
PacketBypassCallback
void PacketBypassCallback(Packet *p)
Definition: decode.c:590
PKT_IS_PSEUDOPKT
#define PKT_IS_PSEUDOPKT(p)
return 1 if the packet is a pseudo packet
Definition: decode.h:1379
GENERIC_TOO_MANY_LAYERS
@ GENERIC_TOO_MANY_LAYERS
Definition: decode-events.h:246
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:168
FlowBypassInfo_
Definition: flow.h:536
unlikely
#define unlikely(expr)
Definition: util-optimize.h:35
PKT_DROP_REASON_STREAM_MEMCAP
@ PKT_DROP_REASON_STREAM_MEMCAP
Definition: decode.h:414
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:45
PKT_DROP_REASON_FW_RULES
@ PKT_DROP_REASON_FW_RULES
Definition: decode.h:425
PKT_DROP_REASON_FLOW_MEMCAP
@ PKT_DROP_REASON_FLOW_MEMCAP
Definition: decode.h:406
DecodeTeredoConfig
void DecodeTeredoConfig(void)
Definition: decode-teredo.c:104
SCFlowGetStorageById
void * SCFlowGetStorageById(const Flow *f, SCFlowStorageId id)
Definition: flow-storage.c:37
CaptureStatsSetup
void CaptureStatsSetup(ThreadVars *tv)
Definition: decode.c:1178
PacketDropReasonToString
const char * PacketDropReasonToString(enum PacketDropReason r)
Definition: decode.c:989
PacketEngineEvents_::events
uint8_t events[PACKET_ENGINE_EVENT_MAX]
Definition: decode.h:329
CaptureStats_
Definition: decode.c:1101
PKT_STREAM_MODIFIED
#define PKT_STREAM_MODIFIED
Definition: decode.h:1331
CaptureStats_::counter_ips_replaced
StatsCounterId counter_ips_replaced
Definition: decode.c:1105
PcapPacketCntGet
uint64_t PcapPacketCntGet(const Packet *p)
Definition: decode.c:1244
SCLogDebug
#define SCLogDebug(...)
Definition: util-debug.h:282
PKT_SRC_SHUTDOWN_FLUSH
@ PKT_SRC_SHUTDOWN_FLUSH
Definition: decode.h:80
StatsRegisterCounter
StatsCounterId StatsRegisterCounter(const char *name, StatsThreadContext *stats)
Registers a normal, unqualified counter.
Definition: counters.c:1038
DecodeThreadVars_::counter_defrag_no_frags
StatsCounterId counter_defrag_no_frags
Definition: decode.h:1089
AddressDebugPrint
void AddressDebugPrint(Address *a)
Debug print function for printing addresses.
Definition: decode.c:873
PKT_SRC_DECODER_IPV4
@ PKT_SRC_DECODER_IPV4
Definition: decode.h:70
PacketDefragPktSetup
Packet * PacketDefragPktSetup(Packet *parent, const uint8_t *pkt, uint32_t len, uint8_t proto)
Setup a pseudo packet (reassembled frags)
Definition: decode.c:522
DecodeThreadVars_::counter_vxlan
StatsCounterId counter_vxlan
Definition: decode.h:1068
stats_stream_events
bool stats_stream_events
Definition: counters.c:99
name
const char * name
Definition: detect-engine-proto.c:47
DecodeThreadVars_::counter_flow_spare_sync_empty
StatsCounterId counter_flow_spare_sync_empty
Definition: decode.h:1116
DecodeThreadVars_::counter_nsh
StatsCounterId counter_nsh
Definition: decode.h:1081
PKT_ZERO_COPY
#define PKT_ZERO_COPY
Definition: decode.h:1344
DecodeThreadVars_::counter_gre
StatsCounterId counter_gre
Definition: decode.h:1064
DecodeThreadVars_::counter_flow_get_used_failed
StatsCounterId counter_flow_get_used_failed
Definition: decode.h:1113
PKT_SRC_CAPTURE_TIMEOUT
@ PKT_SRC_CAPTURE_TIMEOUT
Definition: decode.h:78
action-globals.h
Packet_::flags
uint32_t flags
Definition: decode.h:588
DECODE_TUNNEL_NSH
@ DECODE_TUNNEL_NSH
Definition: decode.h:37
PacketAlertCreate
PacketAlert * PacketAlertCreate(void)
Initialize PacketAlerts with dynamic alerts array size.
Definition: decode.c:144
Packet_::vlan_idx
uint8_t vlan_idx
Definition: decode.h:567
DECODE_TUNNEL_VLAN
@ DECODE_TUNNEL_VLAN
Definition: decode.h:32
util-hash.h
ExceptionPolicyStatsSetts_
Definition: util-exception-policy-types.h:59
CaptureStats
struct CaptureStats_ CaptureStats
Packet_::pool
struct PktPool_ * pool
Definition: decode.h:709
PKT_DROP_REASON_MAX
@ PKT_DROP_REASON_MAX
Definition: decode.h:431
PKT_DROP_REASON_STREAM_REASSEMBLY
@ PKT_DROP_REASON_STREAM_REASSEMBLY
Definition: decode.h:416
PcapPacketCntSet
void PcapPacketCntSet(Packet *p, uint64_t pcap_cnt)
Definition: decode.c:1252
DecodeThreadVars_::counter_bytes
StatsCounterId counter_bytes
Definition: decode.h:1027
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:350
DecodeThreadVars_::counter_flow_get_used
StatsCounterId counter_flow_get_used
Definition: decode.h:1109
DecodeThreadVars_::counter_avg_pkt_size
StatsCounterDeriveId counter_avg_pkt_size
Definition: decode.h:1028
DecodeThreadVars_::counter_pppoe
StatsCounterId counter_pppoe
Definition: decode.h:1072
SCMutexLock
#define SCMutexLock(mut)
Definition: threads-debug.h:117
FLOW_PKT_TOSERVER
#define FLOW_PKT_TOSERVER
Definition: flow.h:236
CaptureStats_::counter_fw_rejected
StatsCounterId counter_fw_rejected
Definition: decode.c:1108
HashTable_
Definition: util-hash.h:35
DecodeThreadVars_::counter_tcp_syn
StatsCounterId counter_tcp_syn
Definition: decode.h:1040
Packet_::tproto
uint8_t tproto
Definition: decode.h:585
ACTION_REJECT_ANY
#define ACTION_REJECT_ANY
Definition: action-globals.h:38
PacketAlerts_::drop
PacketAlert drop
Definition: decode.h:312
Address_
Definition: decode.h:129
flow_memcap_eps_stats
ExceptionPolicyStatsSetts flow_memcap_eps_stats
Definition: decode.c:114
DecodeARP
int DecodeARP(ThreadVars *tv, DecodeThreadVars *dtv, Packet *p, const uint8_t *pkt, uint32_t len)
Definition: decode-arp.c:29
SCMUTEX_INITIALIZER
#define SCMUTEX_INITIALIZER
Definition: threads-debug.h:122
DecodeThreadVars_::counter_icmpv6
StatsCounterId counter_icmpv6
Definition: decode.h:1046
p
Packet * p
Definition: fuzz_dataset.c:30
StatsCounterId
Definition: counters.h:30
PacketDecodeFinalize
void PacketDecodeFinalize(ThreadVars *tv, DecodeThreadVars *dtv, Packet *p)
Finalize decoding of a packet.
Definition: decode.c:244
proto
uint8_t proto
Definition: decode-template.h:0
m
SCMutex m
Definition: flow-hash.h:6
DecodeThreadVars_::counter_invalid
StatsCounterId counter_invalid
Definition: decode.h:1033
PacketAlertGetMaxConfig
void PacketAlertGetMaxConfig(void)
Definition: decode.c:1225
decoder_max_layers
uint8_t decoder_max_layers
Definition: decode.c:81
Packet_::flowflags
uint8_t flowflags
Definition: decode.h:570
EngineModeIsFirewall
bool EngineModeIsFirewall(void)
Definition: suricata.c:240
StringHashCompareFunc
char StringHashCompareFunc(void *data1, uint16_t datalen1, void *data2, uint16_t datalen2)
Definition: util-hash-string.c:38
DecodeThreadVars_::counter_sctp_init_ack
StatsCounterId counter_sctp_init_ack
Definition: decode.h:1057
Packet_::BypassPacketsFlow
int(* BypassPacketsFlow)(struct Packet_ *)
Definition: decode.h:635
TmqhOutputPacketpool
void TmqhOutputPacketpool(ThreadVars *t, Packet *p)
Definition: tmqh-packetpool.c:305
DecodeVXLANConfig
void DecodeVXLANConfig(void)
Definition: decode-vxlan.c:103
DecodeThreadVars_::counter_flow_spare_sync
StatsCounterId counter_flow_spare_sync
Definition: decode.h:1115
DecodeThreadVars_::counter_defrag_ipv4_reassembled
StatsCounterId counter_defrag_ipv4_reassembled
Definition: decode.h:1085
PacketDropReason
PacketDropReason
Definition: decode.h:401
DECODE_TUNNEL_IPV6
@ DECODE_TUNNEL_IPV6
Definition: decode.h:34
DecodeUnregisterCounters
void DecodeUnregisterCounters(void)
Definition: decode.c:662
DecodeThreadVars_::counter_chdlc
StatsCounterId counter_chdlc
Definition: decode.h:1036
DecodeThreadVars_::counter_sctp
StatsCounterId counter_sctp
Definition: decode.h:1055
GET_PKT_DIRECT_MAX_SIZE
#define GET_PKT_DIRECT_MAX_SIZE(p)
Definition: decode.h:228
GetFlowBypassInfoID
SCFlowStorageId GetFlowBypassInfoID(void)
Definition: flow-util.c:224
StatsRegisterAvgCounter
StatsCounterAvgId StatsRegisterAvgCounter(const char *name, StatsThreadContext *stats)
Registers a counter, whose value holds the average of all the values assigned to it.
Definition: counters.c:1057
DECODE_TUNNEL_IPV4
@ DECODE_TUNNEL_IPV4
Definition: decode.h:33
Packet_::alerts
PacketAlerts alerts
Definition: decode.h:663
PacketTunnelChild
@ PacketTunnelChild
Definition: decode.h:437
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:669
PacketAlertFree
void PacketAlertFree(PacketAlert *pa_array)
Definition: decode.c:176
DECODE_EVENT_PACKET_MAX
@ DECODE_EVENT_PACKET_MAX
Definition: decode-events.h:249
DecodeThreadVars_::counter_tcp
StatsCounterId counter_tcp
Definition: decode.h:1039
TM_ECODE_OK
@ TM_ECODE_OK
Definition: tm-threads-common.h:81
HashTableFree
void HashTableFree(HashTable *ht)
Free a HashTable and all its contents.
Definition: util-hash.c:111
Flow_::flow_state
FlowStateType flow_state
Definition: flow.h:427
CaptureStats_::counter_fw_blocked
StatsCounterId counter_fw_blocked
Definition: decode.c:1107
PKT_DROP_REASON_STREAM_URG
@ PKT_DROP_REASON_STREAM_URG
Definition: decode.h:417
RUNMODE_UNIX_SOCKET
@ RUNMODE_UNIX_SOCKET
Definition: runmodes.h:42
PacketAlert_::action
uint8_t action
Definition: decode.h:267
DecodeThreadVars_::counter_defrag_tracker_hard_reuse
StatsCounterId counter_defrag_tracker_hard_reuse
Definition: decode.h:1091
Packet_::datalink
int datalink
Definition: decode.h:678
PKT_DEFAULT_MAX_DECODED_LAYERS
#define PKT_DEFAULT_MAX_DECODED_LAYERS
Definition: decode.h:1383
stats_decoder_events_prefix
const char * stats_decoder_events_prefix
Definition: counters.c:97
DecodeThreadVars_::counter_flow_memcap
StatsCounterId counter_flow_memcap
Definition: decode.h:1095
DecodeThreadVars_::counter_defrag_max_hit
StatsCounterId counter_defrag_max_hit
Definition: decode.h:1088
CaptureStats_::counter_ips_accepted
StatsCounterId counter_ips_accepted
Definition: decode.c:1102
DecodeRegisterPerfCounters
void DecodeRegisterPerfCounters(DecodeThreadVars *dtv, ThreadVars *tv)
Definition: decode.c:694
DECODE_TUNNEL_IPV6_TEREDO
@ DECODE_TUNNEL_IPV6_TEREDO
Definition: decode.h:35
DecodeThreadVars_::counter_flow_elephant
StatsCounterId counter_flow_elephant
Definition: decode.h:1106
SET_PKT_LEN
#define SET_PKT_LEN(p, len)
Definition: decode.h:230
CaptureStats_::counter_fw_accepted
StatsCounterId counter_fw_accepted
Definition: decode.c:1106
PKT_DROP_REASON_NON_FW_MAX
#define PKT_DROP_REASON_NON_FW_MAX
Definition: decode.h:423
DECODE_TUNNEL_ERSPANI
@ DECODE_TUNNEL_ERSPANI
Definition: decode.h:30
FLOW_STATE_LOCAL_BYPASSED
@ FLOW_STATE_LOCAL_BYPASSED
Definition: flow.h:514
PacketAlert_::json_info
struct PacketContextData * json_info
Definition: decode.h:273
SCRunmodeGet
SCRunMode SCRunmodeGet(void)
Get the current run mode.
Definition: suricata.c:302
decode.h
util-debug.h
PKT_SRC_WIRE
@ PKT_SRC_WIRE
Definition: decode.h:68
PKT_IS_TOSERVER
#define PKT_IS_TOSERVER(p)
Definition: decode.h:255
DecodeThreadVars_::counter_udp
StatsCounterId counter_udp
Definition: decode.h:1044
DecodeERSPANTypeI
int DecodeERSPANTypeI(ThreadVars *tv, DecodeThreadVars *dtv, Packet *p, const uint8_t *pkt, uint32_t len)
ERSPAN Type I.
Definition: decode-erspan.c:64
DEvents
const struct DecodeEvents_ DEvents[]
Definition: decode-events.c:29
Packet_::ts
SCTime_t ts
Definition: decode.h:596
PKT_DROP_REASON_APPLAYER_ERROR
@ PKT_DROP_REASON_APPLAYER_ERROR
Definition: decode.h:409
SCMutexUnlock
#define SCMutexUnlock(mut)
Definition: threads-debug.h:120
RUNMODE_UNITTEST
@ RUNMODE_UNITTEST
Definition: runmodes.h:41
PacketSwap
void PacketSwap(Packet *p)
switch direction of a packet
Definition: decode.c:637
util-exception-policy.h
PktSrcEnum
PktSrcEnum
Definition: decode.h:67
PKT_DROP_REASON_NOT_SET
@ PKT_DROP_REASON_NOT_SET
Definition: decode.h:402
SCConfGetInt
int SCConfGetInt(const char *name, intmax_t *val)
Retrieve a configuration value as an integer.
Definition: conf.c:440
PKT_DROP_REASON_FW_FLOW_PRE_HOOK
@ PKT_DROP_REASON_FW_FLOW_PRE_HOOK
Definition: decode.h:429
Packet_::pcap_v
PcapPacketVars pcap_v
Definition: decode.h:628
PacketDestructor
void PacketDestructor(Packet *p)
Cleanup a packet so that we can free it. No memset needed..
Definition: packet.c:178
CaptureStatsUpdate
void CaptureStatsUpdate(ThreadVars *tv, const Packet *p)
Definition: decode.c:1126
util-print.h
PKT_SRC_DECODER_TEREDO
@ PKT_SRC_DECODER_TEREDO
Definition: decode.h:72
DecodeThreadVars_::counter_vntag
StatsCounterId counter_vntag
Definition: decode.h:1069
SCEnter
#define SCEnter(...)
Definition: util-debug.h:284
GET_PKT_DATA
#define GET_PKT_DATA(p)
Definition: decode.h:226
ExceptionPolicySetStatsCounters
void ExceptionPolicySetStatsCounters(ThreadVars *tv, ExceptionPolicyCounters *counter, ExceptionPolicyStatsSetts *setting, enum ExceptionPolicy conf_policy, const char *default_str, bool(*isExceptionPolicyValid)(enum ExceptionPolicy))
Definition: util-exception-policy.c:378
HashTableLookup
void * HashTableLookup(HashTable *ht, void *data, uint16_t datalen)
Definition: util-hash.c:193
ThreadVars_
Per thread variable structure.
Definition: threadvars.h:57
SCFlowSetStorageById
int SCFlowSetStorageById(Flow *f, SCFlowStorageId id, void *ptr)
Definition: flow-storage.c:42
PrintInet
const char * PrintInet(int af, const void *src, char *dst, socklen_t size)
Definition: util-print.c:238
DecodeThreadVars_::counter_flow_active
StatsCounterId counter_flow_active
Definition: decode.h:1100
DecodeThreadVars_::counter_ipv6inipv4
StatsCounterId counter_ipv6inipv4
Definition: decode.h:1076
PacketContextData
Definition: decode.h:258
Packet_::tunnel_id
uint16_t tunnel_id
Definition: decode.h:564
FLOW_PKT_TOCLIENT_FIRST
#define FLOW_PKT_TOCLIENT_FIRST
Definition: flow.h:240
StatsCounterIncr
void StatsCounterIncr(StatsThreadContext *stats, StatsCounterId id)
Increments the local counter.
Definition: counters.c:163
PacketFree
void PacketFree(Packet *p)
Return a malloced packet.
Definition: decode.c:231
PktSrcToString
const char * PktSrcToString(enum PktSrcEnum pkt_src)
Definition: decode.c:941
ExceptionPolicyStatsSetts_::valid_settings_ids
bool valid_settings_ids[EXCEPTION_POLICY_MAX]
Definition: util-exception-policy-types.h:61
DecodeThreadVars_::counter_tcp_urg
StatsCounterId counter_tcp_urg
Definition: decode.h:1043
DecodeThreadVars_::counter_pkts
StatsCounterId counter_pkts
Definition: decode.h:1026
DecodeThreadVars_::counter_eth
StatsCounterId counter_eth
Definition: decode.h:1035
SCLogWarning
#define SCLogWarning(...)
Macro used to log WARNING messages.
Definition: util-debug.h:262
HashTableAdd
int HashTableAdd(HashTable *ht, void *data, uint16_t datalen)
Definition: util-hash.c:131
SIZE_OF_PACKET
#define SIZE_OF_PACKET
Definition: decode.h:742
StringHashFreeFunc
void StringHashFreeFunc(void *data)
Definition: util-hash-string.c:44
DecodeThreadVars_::counter_sctp_init
StatsCounterId counter_sctp_init
Definition: decode.h:1056
BUG_ON
#define BUG_ON(x)
Definition: suricata-common.h:322
PKT_DROP_REASON_RULES
@ PKT_DROP_REASON_RULES
Definition: decode.h:411
util-profiling.h
DecodeThreadVars_::counter_flow_spare_sync_avg
StatsCounterAvgId counter_flow_spare_sync_avg
Definition: decode.h:1118
PacketCallocExtPkt
int PacketCallocExtPkt(Packet *p, int datalen)
Definition: decode.c:324
DecodeThreadVars_::counter_flow_icmp4
StatsCounterId counter_flow_icmp4
Definition: decode.h:1103
PKT_SRC_STREAM_TCP_DETECTLOG_FLUSH
@ PKT_SRC_STREAM_TCP_DETECTLOG_FLUSH
Definition: decode.h:75
DecodeThreadVars_::counter_ieee8021ah
StatsCounterId counter_ieee8021ah
Definition: decode.h:1071
PKT_SRC_DECODER_IPV6
@ PKT_SRC_DECODER_IPV6
Definition: decode.h:71
DecodeThreadVars_::counter_defrag_tracker_timeout
StatsCounterId counter_defrag_tracker_timeout
Definition: decode.h:1092
Packet_
Definition: decode.h:534
CaptureStats_::counter_drop_reason
StatsCounterId counter_drop_reason[PKT_DROP_REASON_MAX]
Definition: decode.c:1110
GET_PKT_LEN
#define GET_PKT_LEN(p)
Definition: decode.h:225
DecodeThreadVars_::app_tctx
AppLayerThreadCtx * app_tctx
Definition: decode.h:1023
decode-teredo.h
CaptureStats_::counter_ips_blocked
StatsCounterId counter_ips_blocked
Definition: decode.c:1103
Packet_::ttype
uint8_t ttype
Definition: decode.h:582
PKT_DROP_REASON_STREAM_ERROR
@ PKT_DROP_REASON_STREAM_ERROR
Definition: decode.h:413
DecodeThreadVars_::counter_geneve
StatsCounterId counter_geneve
Definition: decode.h:1063
SCReturnPtr
#define SCReturnPtr(x, type)
Definition: util-debug.h:300
AppLayerGetCtxThread
AppLayerThreadCtx * AppLayerGetCtxThread(void)
Creates a new app layer thread context.
Definition: app-layer.c:1117
DecodeThreadVars_::counter_sctp_shutdown
StatsCounterId counter_sctp_shutdown
Definition: decode.h:1060
DecodeThreadVars_::counter_tcp_rst
StatsCounterId counter_tcp_rst
Definition: decode.h:1042
FLOW_PKT_TOCLIENT
#define FLOW_PKT_TOCLIENT
Definition: flow.h:237
DecodeThreadVars_::counter_ipv4inipv6
StatsCounterId counter_ipv4inipv6
Definition: decode.h:1077
DecodeIPV6
int DecodeIPV6(ThreadVars *tv, DecodeThreadVars *dtv, Packet *p, const uint8_t *pkt, uint32_t len)
Definition: decode-ipv6.c:551
PKT_DROP_REASON_EP_FLOW_DROP
@ PKT_DROP_REASON_EP_FLOW_DROP
Definition: decode.h:408
FlowUpdateState
void FlowUpdateState(Flow *f, const enum FlowState s)
Definition: flow.c:1194
DecodeThreadVars_::counter_max_mac_addrs_dst
StatsCounterMaxId counter_max_mac_addrs_dst
Definition: decode.h:1031
PacketTunnelNone
@ PacketTunnelNone
Definition: decode.h:435
dtv
DecodeThreadVars * dtv
Definition: fuzz_decodepcapfile.c:35
DecodeThreadVars_::counter_defrag_memcap_eps
ExceptionPolicyCounters counter_defrag_memcap_eps
Definition: decode.h:1093
DecodeThreadVars_::counter_max_mac_addrs_src
StatsCounterMaxId counter_max_mac_addrs_src
Definition: decode.h:1030
default_packet_size
uint32_t default_packet_size
Definition: decode.c:77
DECODE_TUNNEL_VXLAN
@ DECODE_TUNNEL_VXLAN
Definition: decode.h:31
Packet_::nb_decoded_layers
uint8_t nb_decoded_layers
Definition: decode.h:683
PKT_SRC_DECODER_GENEVE
@ PKT_SRC_DECODER_GENEVE
Definition: decode.h:79
Packet_::ReleasePacket
void(* ReleasePacket)(struct Packet_ *)
Definition: decode.h:632
flow-storage.h
DecodeThreadVars_::counter_ipv4_unknown_proto
StatsCounterId counter_ipv4_unknown_proto
Definition: decode.h:1079
cnt
uint32_t cnt
Definition: tmqh-packetpool.h:7
DecodeThreadVars_::counter_sctp_abort
StatsCounterId counter_sctp_abort
Definition: decode.h:1059
Packet_::flow
struct Flow_ * flow
Definition: decode.h:590
Packet_::tenant_id
uint32_t tenant_id
Definition: decode.h:704
PacketAlertDropReset
void PacketAlertDropReset(Packet *p)
Release the alert context the drop slot owns, then invalidate the slot. Not an alerts[] entry,...
Definition: decode.c:170
DecodeThreadVars_::counter_ipv4inipv4
StatsCounterId counter_ipv4inipv4
Definition: decode.h:1075
PKT_DROP_REASON_INNER_PACKET
@ PKT_DROP_REASON_INNER_PACKET
Definition: decode.h:419
SCPacketTunnelProto
SCPacketTunnelProto
Definition: decode.h:27
FlowGetMemcapExceptionPolicy
enum ExceptionPolicy FlowGetMemcapExceptionPolicy(void)
Definition: flow.c:132
DecodeThreadVarsFree
void DecodeThreadVarsFree(ThreadVars *tv, DecodeThreadVars *dtv)
Definition: decode.c:908
DecodeThreadVars_::counter_sll
StatsCounterId counter_sll
Definition: decode.h:1051
DecodeThreadVars_::counter_ppp
StatsCounterId counter_ppp
Definition: decode.h:1062
PKT_DROP_REASON_APPLAYER_MEMCAP
@ PKT_DROP_REASON_APPLAYER_MEMCAP
Definition: decode.h:410
DecodeGlobalConfig
void DecodeGlobalConfig(void)
Definition: decode.c:1204
suricata-common.h
PKT_SRC_FFR
@ PKT_SRC_FFR
Definition: decode.h:74
DecodeThreadVars_::counter_flow_udp
StatsCounterId counter_flow_udp
Definition: decode.h:1102
decode-arp.h
DecodeThreadVars_::counter_igmp
StatsCounterId counter_igmp
Definition: decode.h:1047
DecodeThreadVars_::counter_tcp_synack
StatsCounterId counter_tcp_synack
Definition: decode.h:1041
PacketSetTunnelId
void PacketSetTunnelId(Packet *p, uint32_t session)
Definition: decode.c:404
packet.h
Packet_::livedev_id
uint16_t livedev_id
Definition: decode.h:659
ACTION_DROP
#define ACTION_DROP
Definition: action-globals.h:30
Packet_::ext_pkt
uint8_t * ext_pkt
Definition: decode.h:656
PKT_DROP_REASON_NFQ_ERROR
@ PKT_DROP_REASON_NFQ_ERROR
Definition: decode.h:418
DecodeThreadVars_::counter_null
StatsCounterId counter_null
Definition: decode.h:1054
PacketUpdateEngineEventCounters
void PacketUpdateEngineEventCounters(ThreadVars *tv, DecodeThreadVars *dtv, Packet *p)
Definition: decode.c:251
SCStrdup
#define SCStrdup(s)
Definition: util-mem.h:56
DecodeThreadVars_::counter_flow_memcap_eps
ExceptionPolicyCounters counter_flow_memcap_eps
Definition: decode.h:1096
FatalError
#define FatalError(...)
Definition: util-debug.h:517
DECODE_EVENT_MAX
@ DECODE_EVENT_MAX
Definition: decode-events.h:336
decode-geneve.h
PacketContextData::next
struct PacketContextData * next
Definition: decode.h:260
PKT_SRC_DEFRAG
@ PKT_SRC_DEFRAG
Definition: decode.h:73
PKT_DROP_REASON_FW_STREAM_PRE_HOOK
@ PKT_DROP_REASON_FW_STREAM_PRE_HOOK
Definition: decode.h:428
tv
ThreadVars * tv
Definition: fuzz_decodepcapfile.c:34
DecodeThreadVars_::counter_vlan_qinq
StatsCounterId counter_vlan_qinq
Definition: decode.h:1066
DecodeThreadVars_::counter_teredo
StatsCounterId counter_teredo
Definition: decode.h:1073
PACKET_PROFILING_START
#define PACKET_PROFILING_START(p)
Definition: util-profiling.h:73
util-validate.h
PacketGetFromAlloc
Packet * PacketGetFromAlloc(void)
Get a malloced packet.
Definition: decode.c:270
defrag_memcap_eps_stats
ExceptionPolicyStatsSetts defrag_memcap_eps_stats
Definition: decode.c:86
PKT_SRC_DECODER_VXLAN
@ PKT_SRC_DECODER_VXLAN
Definition: decode.h:76
SCMalloc
#define SCMalloc(sz)
Definition: util-mem.h:47
CaptureStats_::counter_ips_rejected
StatsCounterId counter_ips_rejected
Definition: decode.c:1104
PACKET_ALERT_MAX
#define PACKET_ALERT_MAX
Definition: decode.h:302
Packet_::root
struct Packet_ * root
Definition: decode.h:692
SCLogError
#define SCLogError(...)
Macro used to log ERROR messages.
Definition: util-debug.h:274
OutputFlowLogThreadDeinit
TmEcode OutputFlowLogThreadDeinit(ThreadVars *tv, void *thread_data)
Definition: output-flow.c:161
PKT_SRC_DETECT_RELOAD_FLUSH
@ PKT_SRC_DETECT_RELOAD_FLUSH
Definition: decode.h:77
SCFree
#define SCFree(p)
Definition: util-mem.h:61
DecodeThreadVars_::counter_max_pkt_size
StatsCounterMaxId counter_max_pkt_size
Definition: decode.h:1029
DecodeThreadVars_::counter_flow_spare_sync_incomplete
StatsCounterId counter_flow_spare_sync_incomplete
Definition: decode.h:1117
DecodeThreadVars_::counter_sll2
StatsCounterId counter_sll2
Definition: decode.h:1052
DecodeThreadVars_
Structure to hold thread specific data for all decode modules.
Definition: decode.h:1021
MAX_PAYLOAD_SIZE
#define MAX_PAYLOAD_SIZE
Definition: decode.h:740
ExceptionPolicyStatsSetts_::valid_settings_ips
bool valid_settings_ips[EXCEPTION_POLICY_MAX]
Definition: util-exception-policy-types.h:62
AppLayerDestroyCtxThread
void AppLayerDestroyCtxThread(AppLayerThreadCtx *app_tctx)
Destroys the context created by AppLayerGetCtxThread().
Definition: app-layer.c:1138
PacketTunnelPktSetupWithSession
Packet * PacketTunnelPktSetupWithSession(ThreadVars *tv, DecodeThreadVars *dtv, Packet *parent, const uint8_t *pkt, uint32_t len, enum SCPacketTunnelProto proto, uint32_t *session)
Definition: decode.c:421
Packet_::recursion_level
uint8_t recursion_level
Definition: decode.h:559
DecodeThreadVars_::counter_defrag_ipv4_fragments
StatsCounterId counter_defrag_ipv4_fragments
Definition: decode.h:1084
DecodeGlobalConfigDeinit
void DecodeGlobalConfigDeinit(void)
Definition: decode.c:672
DecodeThreadVars_::counter_etag
StatsCounterId counter_etag
Definition: decode.h:1070
StatsRegisterMaxCounter
StatsCounterMaxId StatsRegisterMaxCounter(const char *name, StatsThreadContext *stats)
Registers a counter, whose value holds the maximum of all the values assigned to it.
Definition: counters.c:1076
DecodeThreadVars_::counter_tcp_active_sessions
StatsCounterId counter_tcp_active_sessions
Definition: decode.h:1098
DecodeThreadVars_::output_flow_thread_data
void * output_flow_thread_data
Definition: decode.h:1124
DecodeThreadVarsAlloc
DecodeThreadVars * DecodeThreadVarsAlloc(ThreadVars *tv)
Alloc and setup DecodeThreadVars.
Definition: decode.c:890
StatsRegisterDeriveDivCounter
StatsCounterDeriveId StatsRegisterDeriveDivCounter(const char *name, const char *dname1, const char *dname2, StatsThreadContext *stats)
Registers a counter which tracks the result of the calculating the value of counter dname1 divided by...
Definition: counters.c:1121
WARN_UNUSED
#define WARN_UNUSED
Definition: bindgen.h:33
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:928
PacketPoolGetPacket
Packet * PacketPoolGetPacket(void)
Get a new packet from the packet pool.
Definition: tmqh-packetpool.c:118
PKT_DROP_REASON_FW_DEFAULT_APP_POLICY
@ PKT_DROP_REASON_FW_DEFAULT_APP_POLICY
Definition: decode.h:427
GET_PKT_DIRECT_DATA
#define GET_PKT_DIRECT_DATA(p)
Definition: decode.h:227
ACTION_ACCEPT
#define ACTION_ACCEPT
Definition: action-globals.h:36
t_capture_stats
thread_local CaptureStats t_capture_stats
Definition: decode.c:1113
DecodeThreadVars_::counter_defrag_ipv6_reassembled
StatsCounterId counter_defrag_ipv6_reassembled
Definition: decode.h:1087
EngineModeIsIPS
int EngineModeIsIPS(void)
Definition: suricata.c:247
DecodeThreadVars_::counter_mpls
StatsCounterId counter_mpls
Definition: decode.h:1074
defrag-hash.h
Packet_::drop_reason
uint8_t drop_reason
Definition: decode.h:686
Address_::family
char family
Definition: decode.h:130
PKT_SRC_DECODER_GRE
@ PKT_SRC_DECODER_GRE
Definition: decode.h:69
ENGINE_SET_INVALID_EVENT
#define ENGINE_SET_INVALID_EVENT(p, e)
Definition: decode.h:1254
PacketAlert_
Definition: decode.h:265
DecodeGeneveConfig
void DecodeGeneveConfig(void)
Definition: decode-geneve.c:127
PacketTunnelRoot
@ PacketTunnelRoot
Definition: decode.h:436
PacketAlertRecycle
void PacketAlertRecycle(PacketAlert *pa_array, uint16_t cnt)
Definition: decode.c:149
PKT_DROP_REASON_FW_DEFAULT_PACKET_POLICY
@ PKT_DROP_REASON_FW_DEFAULT_PACKET_POLICY
Definition: decode.h:426
packet_alert_max
uint16_t packet_alert_max
Definition: decode.c:82
Packet_::vlan_id
uint16_t vlan_id[VLAN_MAX_LAYERS]
Definition: decode.h:566
DecodeThreadVars_::counter_ipv4
StatsCounterId counter_ipv4
Definition: decode.h:1037
DecodeThreadVars_::counter_flow_total
StatsCounterId counter_flow_total
Definition: decode.h:1099
likely
#define likely(expr)
Definition: util-optimize.h:32
PacketContextData::json_string
char * json_string
Definition: decode.h:259
DecodeThreadVars_::counter_arp
StatsCounterId counter_arp
Definition: decode.h:1048
DecodeThreadVars_::counter_vlan
StatsCounterId counter_vlan
Definition: decode.h:1065
PacketDefragPktSetupParent
void PacketDefragPktSetupParent(Packet *parent)
inform defrag "parent" that a pseudo packet is now associated to it.
Definition: decode.c:572
GET_IPV4_SRC_ADDR_U32
#define GET_IPV4_SRC_ADDR_U32(p)
Definition: decode.h:213
PacketInit
bool PacketInit(Packet *p)
Initialize a packet structure for use.
Definition: packet.c:73
DecodeThreadVars_::counter_defrag_tracker_soft_reuse
StatsCounterId counter_defrag_tracker_soft_reuse
Definition: decode.h:1090
DECODE_TUNNEL_ERSPANII
@ DECODE_TUNNEL_ERSPANII
Definition: decode.h:29
DECODE_TUNNEL_ETHERNET
@ DECODE_TUNNEL_ETHERNET
Definition: decode.h:28
GET_IPV4_DST_ADDR_U32
#define GET_IPV4_DST_ADDR_U32(p)
Definition: decode.h:214
DecodeThreadVars_::counter_flow_elephant_toclient
StatsCounterId counter_flow_elephant_toclient
Definition: decode.h:1108
DecodeThreadVars_::counter_flow_elephant_toserver
StatsCounterId counter_flow_elephant_toserver
Definition: decode.h:1107
stats_decoder_events
bool stats_decoder_events
Definition: counters.c:96
flow.h
PKT_DROP_REASON_STREAM_MIDSTREAM
@ PKT_DROP_REASON_STREAM_MIDSTREAM
Definition: decode.h:415
DecodeIPV4
int DecodeIPV4(ThreadVars *tv, DecodeThreadVars *dtv, Packet *p, const uint8_t *pkt, uint16_t len)
Definition: decode-ipv4.c:515
RUNMODE_PCAP_FILE
@ RUNMODE_PCAP_FILE
Definition: runmodes.h:30
ExceptionPolicy
ExceptionPolicy
Definition: util-exception-policy-types.h:26
SCCalloc
#define SCCalloc(nm, sz)
Definition: util-mem.h:53
DecodeThreadVars_::counter_erspan
StatsCounterId counter_erspan
Definition: decode.h:1080
ThreadVars_::stats
StatsThreadContext stats
Definition: threadvars.h:120
DecodeVLAN
int DecodeVLAN(ThreadVars *tv, DecodeThreadVars *dtv, Packet *p, const uint8_t *pkt, uint32_t len)
Definition: decode-vlan.c:53
StatsCounterAddI64
void StatsCounterAddI64(StatsThreadContext *stats, StatsCounterId id, int64_t x)
Adds a value of type uint64_t to the local counter.
Definition: counters.c:144
DecodeThreadVars_::counter_ipv6inipv6
StatsCounterId counter_ipv6inipv6
Definition: decode.h:1078
FLOW_PKT_TOSERVER_FIRST
#define FLOW_PKT_TOSERVER_FIRST
Definition: flow.h:239
DefragGetMemcapExceptionPolicy
enum ExceptionPolicy DefragGetMemcapExceptionPolicy(void)
Definition: defrag-hash.c:80
DecodeThreadVars_::counter_engine_events
StatsCounterId counter_engine_events[DECODE_EVENT_MAX]
Definition: decode.h:1120
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:308
DEBUG_VALIDATE_BUG_ON
#define DEBUG_VALIDATE_BUG_ON(exp)
Definition: util-validate.h:109
DecodeEthernet
int DecodeEthernet(ThreadVars *tv, DecodeThreadVars *dtv, Packet *p, const uint8_t *pkt, uint32_t len)
Definition: decode-ethernet.c:41
PKT_DROP_REASON_FLOW_DROP
@ PKT_DROP_REASON_FLOW_DROP
Definition: decode.h:407
PKT_IS_INVALID
#define PKT_IS_INVALID
Definition: decode.h:1351
DecodeUpdatePacketCounters
void DecodeUpdatePacketCounters(ThreadVars *tv, const DecodeThreadVars *dtv, const Packet *p)
Definition: decode.c:858
output.h
PacketTunnelPktSetup
Packet * PacketTunnelPktSetup(ThreadVars *tv, DecodeThreadVars *dtv, Packet *parent, const uint8_t *pkt, uint32_t len, enum SCPacketTunnelProto proto)
Setup a pseudo packet (tunnel)
Definition: decode.c:502
DecodeThreadVars_::counter_flow_get_used_eval_reject
StatsCounterId counter_flow_get_used_eval_reject
Definition: decode.h:1111
DecodeThreadVars_::counter_flow_get_used_eval
StatsCounterId counter_flow_get_used_eval
Definition: decode.h:1110
app-layer.h
DecodeThreadVars_::counter_flow_tcp_reuse
StatsCounterId counter_flow_tcp_reuse
Definition: decode.h:1105
PKT_DROP_REASON_DECODE_ERROR
@ PKT_DROP_REASON_DECODE_ERROR
Definition: decode.h:403
PacketEngineEvents_::cnt
uint8_t cnt
Definition: decode.h:328
DecodeThreadVars_::counter_flow_tcp
StatsCounterId counter_flow_tcp
Definition: decode.h:1101
DecodeThreadVars_::counter_sctp_data
StatsCounterId counter_sctp_data
Definition: decode.h:1058