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 
167 {
168  if (pa_array == NULL)
169  return;
170  for (int i = 0; i < packet_alert_max; i++) {
171  struct PacketContextData *allocated_json = pa_array[i].json_info;
172  while (allocated_json) {
173  struct PacketContextData *next_json = allocated_json->next;
174  SCFree(allocated_json->json_string);
175  SCFree(allocated_json);
176  allocated_json = next_json;
177  }
178  }
179  SCFree(pa_array);
180 }
181 
182 static int DecodeTunnel(ThreadVars *, DecodeThreadVars *, Packet *, const uint8_t *, uint32_t,
184 
185 static int DecodeTunnel(ThreadVars *tv, DecodeThreadVars *dtv, Packet *p, const uint8_t *pkt,
186  uint32_t len, enum DecodeTunnelProto proto)
187 {
188  switch (proto) {
189  case DECODE_TUNNEL_PPP:
190  return DecodePPP(tv, dtv, p, pkt, len);
191  case DECODE_TUNNEL_IPV4:
192  DEBUG_VALIDATE_BUG_ON(len > UINT16_MAX);
193  return DecodeIPV4(tv, dtv, p, pkt, (uint16_t)len);
194  case DECODE_TUNNEL_IPV6:
196  DEBUG_VALIDATE_BUG_ON(len > UINT16_MAX);
197  return DecodeIPV6(tv, dtv, p, pkt, (uint16_t)len);
198  case DECODE_TUNNEL_VLAN:
199  return DecodeVLAN(tv, dtv, p, pkt, len);
201  return DecodeEthernet(tv, dtv, p, pkt, len);
203  return DecodeERSPAN(tv, dtv, p, pkt, len);
205  return DecodeERSPANTypeI(tv, dtv, p, pkt, len);
206  case DECODE_TUNNEL_VXLAN:
207  return DecodeEthernet(tv, dtv, p, pkt, len);
208  case DECODE_TUNNEL_NSH:
209  return DecodeNSH(tv, dtv, p, pkt, len);
210  case DECODE_TUNNEL_ARP:
211  return DecodeARP(tv, dtv, p, pkt, len);
212  default:
213  SCLogDebug("FIXME: DecodeTunnel: protocol %" PRIu32 " not supported.", proto);
214  break;
215  }
216  return TM_ECODE_OK;
217 }
218 
219 /**
220  * \brief Return a malloced packet.
221  */
223 {
225  SCFree(p);
226 }
227 
228 /**
229  * \brief Finalize decoding of a packet
230  *
231  * This function needs to be call at the end of decode
232  * functions when decoding has been successful.
233  *
234  */
236 {
237  if (p->flags & PKT_IS_INVALID) {
239  }
240 }
241 
244 {
245  for (uint8_t i = 0; i < p->events.cnt; i++) {
246  const uint8_t e = p->events.events[i];
247 
249  continue;
251  continue;
253  }
254 }
255 
256 /**
257  * \brief Get a malloced packet.
258  *
259  * \retval p packet, NULL on error
260  */
262 {
264  if (unlikely(p == NULL)) {
265  return NULL;
266  }
267  if (!PacketInit(p)) {
268  SCFree(p);
269  return NULL;
270  }
272 
273  SCLogDebug("allocated a new packet only using alloc...");
274 
276  return p;
277 }
278 
279 /**
280  * \brief Return a packet to where it was allocated.
281  */
283 {
284  if (likely(p->pool != NULL)) {
287  } else {
288  PacketFree(p);
289  }
290 }
291 
292 /**
293  * \brief Get a packet. We try to get a packet from the packetpool first, but
294  * if that is empty we alloc a packet that is free'd again after
295  * processing.
296  *
297  * \retval p packet, NULL on error
298  */
300 {
301  /* try the pool first */
303 
304  if (p == NULL) {
305  /* non fatal, we're just not processing a packet then */
306  p = PacketGetFromAlloc();
307  } else {
310  }
311 
312  return p;
313 }
314 
315 inline int PacketCallocExtPkt(Packet *p, int datalen)
316 {
317  if (! p->ext_pkt) {
318  p->ext_pkt = SCCalloc(1, datalen);
319  if (unlikely(p->ext_pkt == NULL)) {
320  SET_PKT_LEN(p, 0);
321  return -1;
322  }
323  }
324  return 0;
325 }
326 
327 /**
328  * \brief Copy data to Packet payload at given offset
329  *
330  * This function copies data/payload to a Packet. It uses the
331  * space allocated at Packet creation (pointed by Packet::pkt)
332  * or allocate some memory (pointed by Packet::ext_pkt) if the
333  * data size is to big to fit in initial space (of size
334  * default_packet_size).
335  *
336  * \param Pointer to the Packet to modify
337  * \param Offset of the copy relatively to payload of Packet
338  * \param Pointer to the data to copy
339  * \param Length of the data to copy
340  */
341 inline int PacketCopyDataOffset(Packet *p, uint32_t offset, const uint8_t *data, uint32_t datalen)
342 {
343  if (unlikely(offset + datalen > MAX_PAYLOAD_SIZE)) {
344  /* too big */
345  SET_PKT_LEN(p, 0);
346  return -1;
347  }
348 
349  /* Do we have already an packet with allocated data */
350  if (! p->ext_pkt) {
351  uint32_t newsize = offset + datalen;
352  // check overflow
353  if (newsize < offset)
354  return -1;
355  if (newsize <= default_packet_size) {
356  /* data will fit in memory allocated with packet */
357  memcpy(GET_PKT_DIRECT_DATA(p) + offset, data, datalen);
358  } else {
359  /* here we need a dynamic allocation */
360 #ifdef FUZZING_BUILD_MODE_UNSAFE_FOR_PRODUCTION
361  p->ext_pkt = SCMalloc(offset + datalen);
362 #else
364 #endif
365  if (unlikely(p->ext_pkt == NULL)) {
366  SET_PKT_LEN(p, 0);
367  return -1;
368  }
369  /* copy initial data */
371  /* copy data as asked */
372  memcpy(p->ext_pkt + offset, data, datalen);
373  }
374  } else {
375  memcpy(p->ext_pkt + offset, data, datalen);
376  }
377  return 0;
378 }
379 
380 /**
381  * \brief Copy data to Packet payload and set packet length
382  *
383  * \param Pointer to the Packet to modify
384  * \param Pointer to the data to copy
385  * \param Length of the data to copy
386  */
387 inline int PacketCopyData(Packet *p, const uint8_t *pktdata, uint32_t pktlen)
388 {
389  SET_PKT_LEN(p, pktlen);
390  return PacketCopyDataOffset(p, 0, pktdata, pktlen);
391 }
392 
393 /**
394  * \brief Setup a pseudo packet (tunnel)
395  *
396  * \param parent parent packet for this pseudo pkt
397  * \param pkt raw packet data
398  * \param len packet data length
399  * \param proto protocol of the tunneled packet
400  *
401  * \retval p the pseudo packet or NULL if out of memory
402  */
404  const uint8_t *pkt, uint32_t len, enum DecodeTunnelProto proto)
405 {
406  int ret;
407 
408  SCEnter();
409 
410  if (parent->nb_decoded_layers + 1 >= decoder_max_layers) {
412  SCReturnPtr(NULL, "Packet");
413  }
414 
415  /* get us a packet */
417  if (unlikely(p == NULL)) {
418  SCReturnPtr(NULL, "Packet");
419  }
420 
421  /* copy packet and set length, proto */
422  PacketCopyData(p, pkt, len);
423  DEBUG_VALIDATE_BUG_ON(parent->recursion_level == 255);
424  p->recursion_level = parent->recursion_level + 1;
426  p->nb_decoded_layers = parent->nb_decoded_layers + 1;
427  p->ts = parent->ts;
428  p->datalink = DLT_RAW;
429  p->tenant_id = parent->tenant_id;
430  p->livedev_id = parent->livedev_id;
431 
432  /* set the root ptr to the lowest layer */
433  if (parent->root != NULL) {
434  p->root = parent->root;
435  BUG_ON(!PacketIsTunnelChild(parent));
436  } else {
437  p->root = parent;
438  parent->ttype = PacketTunnelRoot;
439  }
440  /* tell new packet it's part of a tunnel */
442 
443  ret = DecodeTunnel(tv, dtv, p, GET_PKT_DATA(p),
444  GET_PKT_LEN(p), proto);
445 
446  if (unlikely(ret != TM_ECODE_OK) ||
448  {
449  /* Not a (valid) tunnel packet */
450  SCLogDebug("tunnel packet is invalid");
451  p->root = NULL;
453  SCReturnPtr(NULL, "Packet");
454  }
455 
456  /* Update tunnel settings in parent */
457  if (parent->root == NULL) {
458  parent->ttype = PacketTunnelRoot;
459  }
460  TUNNEL_INCR_PKT_TPR(p);
461 
462  /* disable payload (not packet) inspection on the parent, as the payload
463  * is the packet we will now run through the system separately. We do
464  * check it against the ip/port/other header checks though */
465  DecodeSetNoPayloadInspectionFlag(parent);
466  SCReturnPtr(p, "Packet");
467 }
468 
469 /**
470  * \brief Setup a pseudo packet (reassembled frags)
471  *
472  * Difference with PacketPseudoPktSetup is that this func doesn't increment
473  * the recursion level. It needs to be on the same level as the frags because
474  * we run the flow engine against this and we need to get the same flow.
475  *
476  * \param parent parent packet for this pseudo pkt
477  * \param pkt raw packet data
478  * \param len packet data length
479  * \param proto protocol of the tunneled packet
480  *
481  * \retval p the pseudo packet or NULL if out of memory
482  */
483 Packet *PacketDefragPktSetup(Packet *parent, const uint8_t *pkt, uint32_t len, uint8_t proto)
484 {
485  SCEnter();
486 
487  /* get us a packet */
489  if (unlikely(p == NULL)) {
490  SCReturnPtr(NULL, "Packet");
491  }
492 
493  /* set the root ptr to the lowest layer */
494  if (parent->root != NULL) {
495  p->root = parent->root;
496  BUG_ON(!PacketIsTunnelChild(parent));
497  } else {
498  p->root = parent;
499  // we set parent->ttype later
500  }
501  /* tell new packet it's part of a tunnel */
503 
504 #ifdef FUZZING_BUILD_MODE_UNSAFE_FOR_PRODUCTION
505  if (!p->ext_pkt) {
507  if (unlikely(p->ext_pkt == NULL)) {
509  return NULL;
510  }
511  }
512 #endif
513  /* copy packet and set length, proto */
514  if (pkt && len) {
515  PacketCopyData(p, pkt, len);
516  }
517  p->recursion_level = parent->recursion_level; /* NOT incremented */
518  p->ts = parent->ts;
519  p->tenant_id = parent->tenant_id;
520  memcpy(&p->vlan_id[0], &parent->vlan_id[0], sizeof(p->vlan_id));
521  p->vlan_idx = parent->vlan_idx;
522  p->livedev_id = parent->livedev_id;
523 
524  SCReturnPtr(p, "Packet");
525 }
526 
527 /**
528  * \brief inform defrag "parent" that a pseudo packet is
529  * now associated to it.
530  */
532 {
533  /* tell parent packet it's part of a tunnel */
534  if (parent->ttype == PacketTunnelNone)
535  parent->ttype = PacketTunnelRoot;
536 
537  /* increment tunnel packet refcnt in the root packet */
538  TUNNEL_INCR_PKT_TPR(parent);
539 
540  /* disable payload (not packet) inspection on the parent, as the payload
541  * is the packet we will now run through the system separately. We do
542  * check it against the ip/port/other header checks though */
543  DecodeSetNoPayloadInspectionFlag(parent);
544 }
545 
546 /**
547  * \note if p->flow is set, the flow is locked
548  */
550 {
551  if (PKT_IS_PSEUDOPKT(p))
552  return;
553 
554 #ifdef CAPTURE_OFFLOAD
555  /* Don't try to bypass if flow is already out or
556  * if we have failed to do it once */
557  if (p->flow) {
558  int state = p->flow->flow_state;
559  if ((state == FLOW_STATE_LOCAL_BYPASSED) ||
560  (state == FLOW_STATE_CAPTURE_BYPASSED)) {
561  return;
562  }
563 
564  FlowBypassInfo *fc;
565 
567  if (fc == NULL) {
568  fc = SCCalloc(sizeof(FlowBypassInfo), 1);
569  if (fc) {
571  } else {
572  return;
573  }
574  }
575  }
577  if (p->flow) {
578  FlowUpdateState(p->flow, FLOW_STATE_CAPTURE_BYPASSED);
579  }
580  } else {
581  if (p->flow) {
583  }
584  }
585 #else /* CAPTURE_OFFLOAD */
586  if (p->flow) {
587  int state = p->flow->flow_state;
588  if (state == FLOW_STATE_LOCAL_BYPASSED)
589  return;
591  }
592 #endif
593 }
594 
595 /** \brief switch direction of a packet */
597 {
598  if (PKT_IS_TOSERVER(p)) {
601 
605  }
606  } else {
609 
613  }
614  }
615 }
616 
617 /* counter name store */
618 static HashTable *g_counter_table = NULL;
619 static SCMutex g_counter_table_mutex = SCMUTEX_INITIALIZER;
620 
622 {
623  SCMutexLock(&g_counter_table_mutex);
624  if (g_counter_table) {
625  HashTableFree(g_counter_table);
626  g_counter_table = NULL;
627  }
628  SCMutexUnlock(&g_counter_table_mutex);
629 }
630 
631 static bool IsDefragMemcapExceptionPolicyStatsValid(enum ExceptionPolicy policy)
632 {
633  if (EngineModeIsIPS()) {
635  }
637 }
638 
639 static bool IsFlowMemcapExceptionPolicyStatsValid(enum ExceptionPolicy policy)
640 {
641  if (EngineModeIsIPS()) {
643  }
645 }
646 
648 {
649  /* register counters */
650  dtv->counter_pkts = StatsRegisterCounter("decoder.pkts", &tv->stats);
651  dtv->counter_bytes = StatsRegisterCounter("decoder.bytes", &tv->stats);
652  dtv->counter_invalid = StatsRegisterCounter("decoder.invalid", &tv->stats);
653  dtv->counter_ipv4 = StatsRegisterCounter("decoder.ipv4", &tv->stats);
654  dtv->counter_ipv6 = StatsRegisterCounter("decoder.ipv6", &tv->stats);
655  dtv->counter_eth = StatsRegisterCounter("decoder.ethernet", &tv->stats);
656  dtv->counter_arp = StatsRegisterCounter("decoder.arp", &tv->stats);
657  dtv->counter_ethertype_unknown = StatsRegisterCounter("decoder.unknown_ethertype", &tv->stats);
658  dtv->counter_chdlc = StatsRegisterCounter("decoder.chdlc", &tv->stats);
659  dtv->counter_raw = StatsRegisterCounter("decoder.raw", &tv->stats);
660  dtv->counter_null = StatsRegisterCounter("decoder.null", &tv->stats);
661  dtv->counter_sll = StatsRegisterCounter("decoder.sll", &tv->stats);
662  dtv->counter_sll2 = StatsRegisterCounter("decoder.sll2", &tv->stats);
663  dtv->counter_tcp = StatsRegisterCounter("decoder.tcp", &tv->stats);
664 
666  dtv->counter_tcp_synack = StatsRegisterCounter("tcp.synack", &tv->stats);
669 
670  dtv->counter_udp = StatsRegisterCounter("decoder.udp", &tv->stats);
671  dtv->counter_sctp = StatsRegisterCounter("decoder.sctp", &tv->stats);
673  dtv->counter_sctp_init_ack = StatsRegisterCounter("sctp.init_ack", &tv->stats);
675  dtv->counter_sctp_abort = StatsRegisterCounter("sctp.abort", &tv->stats);
676  dtv->counter_sctp_shutdown = StatsRegisterCounter("sctp.shutdown", &tv->stats);
677  dtv->counter_esp = StatsRegisterCounter("decoder.esp", &tv->stats);
678  dtv->counter_icmpv4 = StatsRegisterCounter("decoder.icmpv4", &tv->stats);
679  dtv->counter_icmpv6 = StatsRegisterCounter("decoder.icmpv6", &tv->stats);
680  dtv->counter_igmp = StatsRegisterCounter("decoder.igmp", &tv->stats);
681  dtv->counter_ppp = StatsRegisterCounter("decoder.ppp", &tv->stats);
682  dtv->counter_pppoe = StatsRegisterCounter("decoder.pppoe", &tv->stats);
683  dtv->counter_geneve = StatsRegisterCounter("decoder.geneve", &tv->stats);
684  dtv->counter_gre = StatsRegisterCounter("decoder.gre", &tv->stats);
685  dtv->counter_vlan = StatsRegisterCounter("decoder.vlan", &tv->stats);
686  dtv->counter_vlan_qinq = StatsRegisterCounter("decoder.vlan_qinq", &tv->stats);
687  dtv->counter_vlan_qinqinq = StatsRegisterCounter("decoder.vlan_qinqinq", &tv->stats);
688  dtv->counter_vxlan = StatsRegisterCounter("decoder.vxlan", &tv->stats);
689  dtv->counter_vntag = StatsRegisterCounter("decoder.vntag", &tv->stats);
690  dtv->counter_etag = StatsRegisterCounter("decoder.etag", &tv->stats);
691  dtv->counter_ieee8021ah = StatsRegisterCounter("decoder.ieee8021ah", &tv->stats);
692  dtv->counter_teredo = StatsRegisterCounter("decoder.teredo", &tv->stats);
693  dtv->counter_ipv4inipv4 = StatsRegisterCounter("decoder.ipv4_in_ipv4", &tv->stats);
694  dtv->counter_ipv6inipv4 = StatsRegisterCounter("decoder.ipv6_in_ipv4", &tv->stats);
695  dtv->counter_ipv4inipv6 = StatsRegisterCounter("decoder.ipv4_in_ipv6", &tv->stats);
696  dtv->counter_ipv6inipv6 = StatsRegisterCounter("decoder.ipv6_in_ipv6", &tv->stats);
698  StatsRegisterCounter("decoder.ipv4.unknown_protocol", &tv->stats);
699  dtv->counter_mpls = StatsRegisterCounter("decoder.mpls", &tv->stats);
701  "decoder.avg_pkt_size", "decoder.bytes", "decoder.pkts", &tv->stats);
702  dtv->counter_max_pkt_size = StatsRegisterMaxCounter("decoder.max_pkt_size", &tv->stats);
704  StatsRegisterMaxCounter("decoder.max_mac_addrs_src", &tv->stats);
706  StatsRegisterMaxCounter("decoder.max_mac_addrs_dst", &tv->stats);
707  dtv->counter_erspan = StatsRegisterCounter("decoder.erspan", &tv->stats);
708  dtv->counter_nsh = StatsRegisterCounter("decoder.nsh", &tv->stats);
709  dtv->counter_flow_memcap = StatsRegisterCounter("flow.memcap", &tv->stats);
711  FlowGetMemcapExceptionPolicy(), "exception_policy.flow.memcap.",
712  IsFlowMemcapExceptionPolicyStatsValid);
713 
714  dtv->counter_tcp_active_sessions = StatsRegisterCounter("tcp.active_sessions", &tv->stats);
715  dtv->counter_flow_total = StatsRegisterCounter("flow.total", &tv->stats);
716  dtv->counter_flow_active = StatsRegisterCounter("flow.active", &tv->stats);
719  dtv->counter_flow_icmp4 = StatsRegisterCounter("flow.icmpv4", &tv->stats);
720  dtv->counter_flow_icmp6 = StatsRegisterCounter("flow.icmpv6", &tv->stats);
721  dtv->counter_flow_tcp_reuse = StatsRegisterCounter("flow.tcp_reuse", &tv->stats);
722  dtv->counter_flow_elephant = StatsRegisterCounter("flow.elephant", &tv->stats);
724  StatsRegisterCounter("flow.elephant_toserver", &tv->stats);
726  StatsRegisterCounter("flow.elephant_toclient", &tv->stats);
727  dtv->counter_flow_get_used = StatsRegisterCounter("flow.get_used", &tv->stats);
728  dtv->counter_flow_get_used_eval = StatsRegisterCounter("flow.get_used_eval", &tv->stats);
730  StatsRegisterCounter("flow.get_used_eval_reject", &tv->stats);
732  StatsRegisterCounter("flow.get_used_eval_busy", &tv->stats);
733  dtv->counter_flow_get_used_failed = StatsRegisterCounter("flow.get_used_failed", &tv->stats);
734 
736  StatsRegisterAvgCounter("flow.wrk.spare_sync_avg", &tv->stats);
737  dtv->counter_flow_spare_sync = StatsRegisterCounter("flow.wrk.spare_sync", &tv->stats);
739  StatsRegisterCounter("flow.wrk.spare_sync_incomplete", &tv->stats);
741  StatsRegisterCounter("flow.wrk.spare_sync_empty", &tv->stats);
742 
743  dtv->counter_defrag_ipv4_fragments = StatsRegisterCounter("defrag.ipv4.fragments", &tv->stats);
745  StatsRegisterCounter("defrag.ipv4.reassembled", &tv->stats);
746  dtv->counter_defrag_ipv6_fragments = StatsRegisterCounter("defrag.ipv6.fragments", &tv->stats);
748  StatsRegisterCounter("defrag.ipv6.reassembled", &tv->stats);
749  dtv->counter_defrag_max_hit = StatsRegisterCounter("defrag.max_trackers_reached", &tv->stats);
750  dtv->counter_defrag_no_frags = StatsRegisterCounter("defrag.max_frags_reached", &tv->stats);
752  StatsRegisterCounter("defrag.tracker_soft_reuse", &tv->stats);
754  StatsRegisterCounter("defrag.tracker_hard_reuse", &tv->stats);
756  StatsRegisterCounter("defrag.wrk.tracker_timeout", &tv->stats);
757 
759  DefragGetMemcapExceptionPolicy(), "exception_policy.defrag.memcap.",
760  IsDefragMemcapExceptionPolicyStatsValid);
761 
762  for (int i = 0; i < DECODE_EVENT_MAX; i++) {
763  BUG_ON(i != (int)DEvents[i].code);
764 
766  continue;
768  continue;
769 
770  if (i < DECODE_EVENT_PACKET_MAX &&
771  strncmp(DEvents[i].event_name, "decoder.", 8) == 0)
772  {
773  SCMutexLock(&g_counter_table_mutex);
774  if (g_counter_table == NULL) {
775  g_counter_table = HashTableInit(256, StringHashFunc,
778  if (g_counter_table == NULL) {
779  FatalError("decoder counter hash "
780  "table init failed");
781  }
782  }
783 
784  char name[256];
785  const char *dot = strchr(DEvents[i].event_name, '.');
786  BUG_ON(!dot);
787  snprintf(name, sizeof(name), "%s.%s",
789 
790  const char *found = HashTableLookup(g_counter_table, name, 0);
791  if (!found) {
792  char *add = SCStrdup(name);
793  if (add == NULL)
794  FatalError("decoder counter hash "
795  "table name init failed");
796  int r = HashTableAdd(g_counter_table, add, 0);
797  if (r != 0)
798  FatalError("decoder counter hash "
799  "table name add failed");
800  found = add;
801  }
803 
804  SCMutexUnlock(&g_counter_table_mutex);
805  } else {
807  }
808  }
809 }
810 
812  const DecodeThreadVars *dtv, const Packet *p)
813 {
817 }
818 
819 /**
820  * \brief Debug print function for printing addresses
821  *
822  * \param Address object
823  *
824  * \todo IPv6
825  */
827 {
828  if (a == NULL)
829  return;
830 
831  switch (a->family) {
832  case AF_INET:
833  {
834  char s[16];
835  PrintInet(AF_INET, (const void *)&a->addr_data32[0], s, sizeof(s));
836  SCLogDebug("%s", s);
837  break;
838  }
839  }
840 }
841 
842 /** \brief Alloc and setup DecodeThreadVars */
844 {
845  DecodeThreadVars *dtv = NULL;
846 
847  if ((dtv = SCCalloc(1, sizeof(DecodeThreadVars))) == NULL)
848  return NULL;
849 
851 
853  SCLogError("initializing flow log API for thread failed");
855  return NULL;
856  }
857 
858  return dtv;
859 }
860 
862 {
863  if (dtv != NULL) {
864  if (dtv->app_tctx != NULL)
866 
867  if (dtv->output_flow_thread_data != NULL)
869 
870  SCFree(dtv);
871  }
872 }
873 
874 /**
875  * \brief Set data for Packet and set length when zero copy is used
876  *
877  * \param Pointer to the Packet to modify
878  * \param Pointer to the data
879  * \param Length of the data
880  */
881 inline int PacketSetData(Packet *p, const uint8_t *pktdata, uint32_t pktlen)
882 {
883  SET_PKT_LEN(p, pktlen);
884  if (unlikely(!pktdata)) {
885  return -1;
886  }
887  // ext_pkt cannot be const (because we sometimes copy)
888  p->ext_pkt = (uint8_t *) pktdata;
889  p->flags |= PKT_ZERO_COPY;
890 
891  return 0;
892 }
893 
894 const char *PktSrcToString(enum PktSrcEnum pkt_src)
895 {
896  const char *pkt_src_str = NULL;
897  switch (pkt_src) {
898  case PKT_SRC_WIRE:
899  pkt_src_str = "wire/pcap";
900  break;
901  case PKT_SRC_DECODER_GRE:
902  pkt_src_str = "gre tunnel";
903  break;
905  pkt_src_str = "ipv4 tunnel";
906  break;
908  pkt_src_str = "ipv6 tunnel";
909  break;
911  pkt_src_str = "teredo tunnel";
912  break;
913  case PKT_SRC_DEFRAG:
914  pkt_src_str = "defrag";
915  break;
917  pkt_src_str = "stream (detect/log)";
918  break;
919  case PKT_SRC_FFR:
920  pkt_src_str = "stream (flow timeout)";
921  break;
923  pkt_src_str = "geneve encapsulation";
924  break;
926  pkt_src_str = "vxlan encapsulation";
927  break;
929  pkt_src_str = "detect reload flush";
930  break;
932  pkt_src_str = "capture timeout flush";
933  break;
935  pkt_src_str = "shutdown flush";
936  break;
937  }
938  DEBUG_VALIDATE_BUG_ON(pkt_src_str == NULL);
939  return pkt_src_str;
940 }
941 
943 {
944  switch (r) {
946  return "decode error";
948  return "defrag error";
950  return "defrag memcap";
952  return "flow memcap";
954  return "flow drop";
956  return "exception policy flow drop";
958  return "stream error";
960  return "stream memcap";
962  return "stream midstream";
964  return "stream urgent";
966  return "stream reassembly";
968  return "applayer error";
970  return "applayer memcap";
972  return "rules";
974  return "threshold detection_filter";
976  return "nfq error";
978  return "tunnel packet drop";
980  return "firewall rules";
982  return "firewall default packet policy";
984  return "firewall default app policy";
986  return "firewall pre stream hook";
988  return "firewall pre flow hook";
990  return "firewall flow drop";
992  case PKT_DROP_REASON_MAX:
993  return NULL;
994  }
995  return NULL;
996 }
997 
998 static const char *PacketDropReasonToJsonString(enum PacketDropReason r)
999 {
1000  switch (r) {
1002  return "ips.drop_reason.decode_error";
1004  return "ips.drop_reason.defrag_error";
1006  return "ips.drop_reason.defrag_memcap";
1008  return "ips.drop_reason.flow_memcap";
1010  return "ips.drop_reason.flow_drop";
1012  return "ips.drop_reason.exception_policy_flow_drop";
1014  return "ips.drop_reason.stream_error";
1016  return "ips.drop_reason.stream_memcap";
1018  return "ips.drop_reason.stream_midstream";
1020  return "ips.drop_reason.stream_urgent";
1022  return "ips.drop_reason.stream_reassembly";
1024  return "ips.drop_reason.applayer_error";
1026  return "ips.drop_reason.applayer_memcap";
1027  case PKT_DROP_REASON_RULES:
1028  return "ips.drop_reason.rules";
1030  return "ips.drop_reason.threshold_detection_filter";
1032  return "ips.drop_reason.nfq_error";
1034  return "ips.drop_reason.tunnel_packet_drop";
1036  return "firewall.drop_reason.rules";
1038  return "firewall.drop_reason.pre_stream_hook";
1040  return "firewall.drop_reason.pre_flow_hook";
1042  return "firewall.drop_reason.flow_drop";
1044  return "firewall.drop_reason.default_packet_policy";
1046  return "firewall.drop_reason.default_app_policy";
1048  case PKT_DROP_REASON_MAX:
1049  return NULL;
1050  }
1051  return NULL;
1052 }
1053 
1054 typedef struct CaptureStats_ {
1062 
1065 
1067 
1068 static bool VerdictByFirewall(const Packet *p)
1069 {
1070  if (!EngineModeIsFirewall()) {
1071  return false;
1072  }
1074  return true;
1075  }
1076  return false;
1077 }
1078 
1080 {
1081  if (!EngineModeIsIPS() || PKT_IS_PSEUDOPKT(p))
1082  return;
1083 
1085 
1086  if (EngineModeIsFirewall()) {
1087  /** The firewall mode and its stats counters should work as when there are two different
1088  * devices for the firewall control and the IPS control.
1089  * As such, if the firewall blocks a packet, it won't reach the IPS level of evaluation,
1090  * so won't be counted in either stats.
1091  * When the firewall accepts a packet, it can still be blocked, rejected or accepted by
1092  * IPS rules and policies.
1093  */
1095  if (VerdictByFirewall(p)) {
1097  } else {
1100  }
1101  } else if (PacketCheckAction(p, ACTION_DROP)) {
1102  if (VerdictByFirewall(p)) {
1104  } else {
1105  /* If a packet was dropped by IPS, it had to first be accepted by the firewall, to
1106  * reach the IPS flow control */
1109  }
1110  } else if (PacketCheckAction(p, ACTION_ACCEPT)) {
1113  }
1114  } else {
1117  } else if (unlikely(PacketCheckAction(p, ACTION_DROP))) {
1119  } else if (unlikely(p->flags & PKT_STREAM_MODIFIED)) {
1121  } else {
1123  }
1124  }
1125 
1128  }
1129 }
1130 
1132 {
1133  if (EngineModeIsIPS()) {
1135  s->counter_ips_accepted = StatsRegisterCounter("ips.accepted", &tv->stats);
1136  s->counter_ips_blocked = StatsRegisterCounter("ips.blocked", &tv->stats);
1137  s->counter_ips_rejected = StatsRegisterCounter("ips.rejected", &tv->stats);
1138  s->counter_ips_replaced = StatsRegisterCounter("ips.replaced", &tv->stats);
1139  for (int i = PKT_DROP_REASON_NOT_SET; i <= PKT_DROP_REASON_NON_FW_MAX; i++) {
1140  const char *name = PacketDropReasonToJsonString(i);
1141  if (name != NULL)
1143  }
1144  if (EngineModeIsFirewall()) {
1145  s->counter_fw_accepted = StatsRegisterCounter("firewall.accepted", &tv->stats);
1146  s->counter_fw_blocked = StatsRegisterCounter("firewall.blocked", &tv->stats);
1147  s->counter_fw_rejected = StatsRegisterCounter("firewall.rejected", &tv->stats);
1148  for (int i = PKT_DROP_REASON_FW_RULES; i < PKT_DROP_REASON_MAX; i++) {
1149  const char *name = PacketDropReasonToJsonString(i);
1150  if (name != NULL)
1152  }
1153  }
1154  }
1155 }
1156 
1158 {
1163  intmax_t value = 0;
1164  if (SCConfGetInt("decoder.max-layers", &value) == 1) {
1165  if (value < 0 || value > UINT8_MAX) {
1166  SCLogWarning("Invalid value for decoder.max-layers");
1167  } else {
1168  decoder_max_layers = (uint8_t)value;
1169  }
1170  }
1172 }
1173 
1175 {
1176  intmax_t max = 0;
1177  if (SCConfGetInt("packet-alert-max", &max) == 1) {
1178  if (max <= 0 || max > UINT8_MAX) {
1179  SCLogWarning("Invalid value for packet-alert-max, default value set instead");
1180  } else {
1181  packet_alert_max = (uint16_t)max;
1182  }
1183  }
1184  SCLogDebug("detect->packet_alert_max set to %d", packet_alert_max);
1185 }
1186 
1187 static inline bool PcapPacketCntRunmodeCanAccess(void)
1188 {
1189  SCRunMode m = SCRunmodeGet();
1191 }
1192 
1193 inline uint64_t PcapPacketCntGet(const Packet *p)
1194 {
1195  if (PcapPacketCntRunmodeCanAccess() && p != NULL) {
1196  return p->pcap_v.pcap_cnt;
1197  }
1198  return 0;
1199 }
1200 
1201 inline void PcapPacketCntSet(Packet *p, uint64_t pcap_cnt)
1202 {
1203  if (PcapPacketCntRunmodeCanAccess() && p != NULL) {
1204  p->pcap_v.pcap_cnt = pcap_cnt;
1205  }
1206 }
1207 
1208 /**
1209  * @}
1210  */
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:387
DecodeThreadVars_::counter_flow_icmp6
StatsCounterId counter_flow_icmp6
Definition: decode.h:1078
PKT_DROP_REASON_DEFRAG_ERROR
@ PKT_DROP_REASON_DEFRAG_ERROR
Definition: decode.h:386
util-hash-string.h
PKT_DROP_REASON_RULES_THRESHOLD
@ PKT_DROP_REASON_RULES_THRESHOLD
Definition: decode.h:394
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:223
DecodeThreadVars_::counter_icmpv4
StatsCounterId counter_icmpv4
Definition: decode.h:1019
DecodeThreadVars_::counter_defrag_ipv6_fragments
StatsCounterId counter_defrag_ipv6_fragments
Definition: decode.h:1060
DecodeThreadVars_::counter_esp
StatsCounterId counter_esp
Definition: decode.h:1035
DECODE_TUNNEL_IPV6
@ DECODE_TUNNEL_IPV6
Definition: decode.h:1150
DecodeThreadVars_::counter_ethertype_unknown
StatsCounterId counter_ethertype_unknown
Definition: decode.h:1023
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:76
PKT_DROP_REASON_FW_FLOW_DROP
@ PKT_DROP_REASON_FW_FLOW_DROP
Definition: decode.h:412
DecodeThreadVars_::counter_ipv6
StatsCounterId counter_ipv6
Definition: decode.h:1012
DecodeThreadVars_::counter_raw
StatsCounterId counter_raw
Definition: decode.h:1027
PacketFreeOrRelease
void PacketFreeOrRelease(Packet *p)
Return a packet to where it was allocated.
Definition: decode.c:282
DecodeThreadVars_::counter_vlan_qinqinq
StatsCounterId counter_vlan_qinqinq
Definition: decode.h:1041
DecodeThreadVars_::counter_flow_get_used_eval_busy
StatsCounterId counter_flow_get_used_eval_busy
Definition: decode.h:1086
DecodePPP
int DecodePPP(ThreadVars *tv, DecodeThreadVars *dtv, Packet *p, const uint8_t *pkt, uint32_t len)
Definition: decode-ppp.c:177
PacketCopyData
int PacketCopyData(Packet *p, const uint8_t *pktdata, uint32_t pktlen)
Copy data to Packet payload and set packet length.
Definition: decode.c:387
PacketBypassCallback
void PacketBypassCallback(Packet *p)
Definition: decode.c:549
PKT_IS_PSEUDOPKT
#define PKT_IS_PSEUDOPKT(p)
return 1 if the packet is a pseudo packet
Definition: decode.h:1364
GENERIC_TOO_MANY_LAYERS
@ GENERIC_TOO_MANY_LAYERS
Definition: decode-events.h:245
DecodeERSPANConfig
void DecodeERSPANConfig(void)
Functions to decode ERSPAN Type I and II packets.
Definition: decode-erspan.c:53
PacketPoolReturnPacket
void PacketPoolReturnPacket(Packet *p)
Return packet to Packet pool.
Definition: tmqh-packetpool.c:168
FlowBypassInfo_
Definition: flow.h:530
unlikely
#define unlikely(expr)
Definition: util-optimize.h:35
PKT_DROP_REASON_STREAM_MEMCAP
@ PKT_DROP_REASON_STREAM_MEMCAP
Definition: decode.h:396
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
PKT_DROP_REASON_FW_RULES
@ PKT_DROP_REASON_FW_RULES
Definition: decode.h:407
PKT_DROP_REASON_FLOW_MEMCAP
@ PKT_DROP_REASON_FLOW_MEMCAP
Definition: decode.h:388
DecodeTeredoConfig
void DecodeTeredoConfig(void)
Definition: decode-teredo.c:104
SCFlowGetStorageById
void * SCFlowGetStorageById(const Flow *f, SCFlowStorageId id)
Definition: flow-storage.c:38
CaptureStatsSetup
void CaptureStatsSetup(ThreadVars *tv)
Definition: decode.c:1131
PacketDropReasonToString
const char * PacketDropReasonToString(enum PacketDropReason r)
Definition: decode.c:942
PacketEngineEvents_::events
uint8_t events[PACKET_ENGINE_EVENT_MAX]
Definition: decode.h:311
CaptureStats_
Definition: decode.c:1054
PKT_STREAM_MODIFIED
#define PKT_STREAM_MODIFIED
Definition: decode.h:1316
CaptureStats_::counter_ips_replaced
StatsCounterId counter_ips_replaced
Definition: decode.c:1058
DECODE_TUNNEL_IPV6_TEREDO
@ DECODE_TUNNEL_IPV6_TEREDO
Definition: decode.h:1151
PcapPacketCntGet
uint64_t PcapPacketCntGet(const Packet *p)
Definition: decode.c:1193
SCLogDebug
#define SCLogDebug(...)
Definition: util-debug.h:282
PKT_SRC_SHUTDOWN_FLUSH
@ PKT_SRC_SHUTDOWN_FLUSH
Definition: decode.h:64
StatsRegisterCounter
StatsCounterId StatsRegisterCounter(const char *name, StatsThreadContext *stats)
Registers a normal, unqualified counter.
Definition: counters.c:1039
DecodeThreadVars_::counter_defrag_no_frags
StatsCounterId counter_defrag_no_frags
Definition: decode.h:1063
AddressDebugPrint
void AddressDebugPrint(Address *a)
Debug print function for printing addresses.
Definition: decode.c:826
PKT_SRC_DECODER_IPV4
@ PKT_SRC_DECODER_IPV4
Definition: decode.h:54
PacketDefragPktSetup
Packet * PacketDefragPktSetup(Packet *parent, const uint8_t *pkt, uint32_t len, uint8_t proto)
Setup a pseudo packet (reassembled frags)
Definition: decode.c:483
DecodeThreadVars_::counter_vxlan
StatsCounterId counter_vxlan
Definition: decode.h:1042
stats_stream_events
bool stats_stream_events
Definition: counters.c:100
name
const char * name
Definition: detect-engine-proto.c:48
DecodeThreadVars_::counter_flow_spare_sync_empty
StatsCounterId counter_flow_spare_sync_empty
Definition: decode.h:1090
DecodeThreadVars_::counter_nsh
StatsCounterId counter_nsh
Definition: decode.h:1055
PKT_ZERO_COPY
#define PKT_ZERO_COPY
Definition: decode.h:1329
DecodeThreadVars_::counter_gre
StatsCounterId counter_gre
Definition: decode.h:1038
DecodeThreadVars_::counter_flow_get_used_failed
StatsCounterId counter_flow_get_used_failed
Definition: decode.h:1087
PKT_SRC_CAPTURE_TIMEOUT
@ PKT_SRC_CAPTURE_TIMEOUT
Definition: decode.h:62
action-globals.h
Packet_::flags
uint32_t flags
Definition: decode.h:562
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:544
util-hash.h
ExceptionPolicyStatsSetts_
Definition: util-exception-policy-types.h:59
CaptureStats
struct CaptureStats_ CaptureStats
Packet_::pool
struct PktPool_ * pool
Definition: decode.h:683
PKT_DROP_REASON_MAX
@ PKT_DROP_REASON_MAX
Definition: decode.h:413
PKT_DROP_REASON_STREAM_REASSEMBLY
@ PKT_DROP_REASON_STREAM_REASSEMBLY
Definition: decode.h:398
DECODE_TUNNEL_ERSPANI
@ DECODE_TUNNEL_ERSPANI
Definition: decode.h:1146
PcapPacketCntSet
void PcapPacketCntSet(Packet *p, uint64_t pcap_cnt)
Definition: decode.c:1201
DecodeThreadVars_::counter_bytes
StatsCounterId counter_bytes
Definition: decode.h:1001
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:341
DecodeThreadVars_::counter_flow_get_used
StatsCounterId counter_flow_get_used
Definition: decode.h:1083
DecodeThreadVars_::counter_avg_pkt_size
StatsCounterDeriveId counter_avg_pkt_size
Definition: decode.h:1002
DecodeThreadVars_::counter_pppoe
StatsCounterId counter_pppoe
Definition: decode.h:1046
SCMutexLock
#define SCMutexLock(mut)
Definition: threads-debug.h:117
FLOW_PKT_TOSERVER
#define FLOW_PKT_TOSERVER
Definition: flow.h:232
CaptureStats_::counter_fw_rejected
StatsCounterId counter_fw_rejected
Definition: decode.c:1061
HashTable_
Definition: util-hash.h:35
DecodeThreadVars_::counter_tcp_syn
StatsCounterId counter_tcp_syn
Definition: decode.h:1014
ACTION_REJECT_ANY
#define ACTION_REJECT_ANY
Definition: action-globals.h:38
Address_
Definition: decode.h:113
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:1020
StatsCounterId
Definition: counters.h:30
PacketDecodeFinalize
void PacketDecodeFinalize(ThreadVars *tv, DecodeThreadVars *dtv, Packet *p)
Finalize decoding of a packet.
Definition: decode.c:235
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:1007
p
Packet * p
Definition: fuzz_iprep.c:21
PacketAlertGetMaxConfig
void PacketAlertGetMaxConfig(void)
Definition: decode.c:1174
decoder_max_layers
uint8_t decoder_max_layers
Definition: decode.c:81
Packet_::flowflags
uint8_t flowflags
Definition: decode.h:547
EngineModeIsFirewall
bool EngineModeIsFirewall(void)
Definition: suricata.c:239
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:1031
Packet_::BypassPacketsFlow
int(* BypassPacketsFlow)(struct Packet_ *)
Definition: decode.h:609
TmqhOutputPacketpool
void TmqhOutputPacketpool(ThreadVars *t, Packet *p)
Definition: tmqh-packetpool.c:305
DecodeVXLANConfig
void DecodeVXLANConfig(void)
Definition: decode-vxlan.c:104
DecodeThreadVars_::counter_flow_spare_sync
StatsCounterId counter_flow_spare_sync
Definition: decode.h:1089
DecodeThreadVars_::counter_defrag_ipv4_reassembled
StatsCounterId counter_defrag_ipv4_reassembled
Definition: decode.h:1059
PacketDropReason
PacketDropReason
Definition: decode.h:383
DecodeUnregisterCounters
void DecodeUnregisterCounters(void)
Definition: decode.c:621
DecodeThreadVars_::counter_chdlc
StatsCounterId counter_chdlc
Definition: decode.h:1010
DecodeThreadVars_::counter_sctp
StatsCounterId counter_sctp
Definition: decode.h:1029
GET_PKT_DIRECT_MAX_SIZE
#define GET_PKT_DIRECT_MAX_SIZE(p)
Definition: decode.h:212
GetFlowBypassInfoID
SCFlowStorageId GetFlowBypassInfoID(void)
Definition: flow-util.c:223
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:1058
PacketTunnelChild
@ PacketTunnelChild
Definition: decode.h:419
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:643
PacketAlertFree
void PacketAlertFree(PacketAlert *pa_array)
Definition: decode.c:166
DECODE_EVENT_PACKET_MAX
@ DECODE_EVENT_PACKET_MAX
Definition: decode-events.h:248
DecodeThreadVars_::counter_tcp
StatsCounterId counter_tcp
Definition: decode.h:1013
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:112
Flow_::flow_state
FlowStateType flow_state
Definition: flow.h:421
CaptureStats_::counter_fw_blocked
StatsCounterId counter_fw_blocked
Definition: decode.c:1060
PKT_DROP_REASON_STREAM_URG
@ PKT_DROP_REASON_STREAM_URG
Definition: decode.h:399
DECODE_TUNNEL_NSH
@ DECODE_TUNNEL_NSH
Definition: decode.h:1153
RUNMODE_UNIX_SOCKET
@ RUNMODE_UNIX_SOCKET
Definition: runmodes.h:42
DecodeThreadVars_::counter_defrag_tracker_hard_reuse
StatsCounterId counter_defrag_tracker_hard_reuse
Definition: decode.h:1065
Packet_::datalink
int datalink
Definition: decode.h:652
PKT_DEFAULT_MAX_DECODED_LAYERS
#define PKT_DEFAULT_MAX_DECODED_LAYERS
Definition: decode.h:1368
stats_decoder_events_prefix
const char * stats_decoder_events_prefix
Definition: counters.c:98
DecodeThreadVars_::counter_flow_memcap
StatsCounterId counter_flow_memcap
Definition: decode.h:1069
DecodeThreadVars_::counter_defrag_max_hit
StatsCounterId counter_defrag_max_hit
Definition: decode.h:1062
CaptureStats_::counter_ips_accepted
StatsCounterId counter_ips_accepted
Definition: decode.c:1055
DecodeRegisterPerfCounters
void DecodeRegisterPerfCounters(DecodeThreadVars *dtv, ThreadVars *tv)
Definition: decode.c:647
DecodeThreadVars_::counter_flow_elephant
StatsCounterId counter_flow_elephant
Definition: decode.h:1080
DECODE_TUNNEL_ERSPANII
@ DECODE_TUNNEL_ERSPANII
Definition: decode.h:1145
SET_PKT_LEN
#define SET_PKT_LEN(p, len)
Definition: decode.h:214
CaptureStats_::counter_fw_accepted
StatsCounterId counter_fw_accepted
Definition: decode.c:1059
PKT_DROP_REASON_NON_FW_MAX
#define PKT_DROP_REASON_NON_FW_MAX
Definition: decode.h:405
FLOW_STATE_LOCAL_BYPASSED
@ FLOW_STATE_LOCAL_BYPASSED
Definition: flow.h:508
PacketAlert_::json_info
struct PacketContextData * json_info
Definition: decode.h:257
SCRunmodeGet
SCRunMode SCRunmodeGet(void)
Get the current run mode.
Definition: suricata.c:301
decode.h
util-debug.h
PKT_SRC_WIRE
@ PKT_SRC_WIRE
Definition: decode.h:52
PKT_IS_TOSERVER
#define PKT_IS_TOSERVER(p)
Definition: decode.h:239
DecodeThreadVars_::counter_udp
StatsCounterId counter_udp
Definition: decode.h:1018
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
Packet_::ts
SCTime_t ts
Definition: decode.h:570
PKT_DROP_REASON_APPLAYER_ERROR
@ PKT_DROP_REASON_APPLAYER_ERROR
Definition: decode.h:391
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:596
util-exception-policy.h
PktSrcEnum
PktSrcEnum
Definition: decode.h:51
PKT_DROP_REASON_NOT_SET
@ PKT_DROP_REASON_NOT_SET
Definition: decode.h:384
SCConfGetInt
int SCConfGetInt(const char *name, intmax_t *val)
Retrieve a configuration value as an integer.
Definition: conf.c:441
PKT_DROP_REASON_FW_FLOW_PRE_HOOK
@ PKT_DROP_REASON_FW_FLOW_PRE_HOOK
Definition: decode.h:411
DecodeTunnelProto
DecodeTunnelProto
Definition: decode.h:1143
Packet_::pcap_v
PcapPacketVars pcap_v
Definition: decode.h:602
PacketDestructor
void PacketDestructor(Packet *p)
Cleanup a packet so that we can free it. No memset needed..
Definition: packet.c:175
CaptureStatsUpdate
void CaptureStatsUpdate(ThreadVars *tv, const Packet *p)
Definition: decode.c:1079
util-print.h
PKT_SRC_DECODER_TEREDO
@ PKT_SRC_DECODER_TEREDO
Definition: decode.h:56
DecodeThreadVars_::counter_vntag
StatsCounterId counter_vntag
Definition: decode.h:1043
SCEnter
#define SCEnter(...)
Definition: util-debug.h:284
GET_PKT_DATA
#define GET_PKT_DATA(p)
Definition: decode.h:210
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:194
ThreadVars_
Per thread variable structure.
Definition: threadvars.h:58
SCFlowSetStorageById
int SCFlowSetStorageById(Flow *f, SCFlowStorageId id, void *ptr)
Definition: flow-storage.c:43
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:1074
DecodeThreadVars_::counter_ipv6inipv4
StatsCounterId counter_ipv6inipv4
Definition: decode.h:1050
DECODE_TUNNEL_PPP
@ DECODE_TUNNEL_PPP
Definition: decode.h:1152
PacketContextData
Definition: decode.h:242
FLOW_PKT_TOCLIENT_FIRST
#define FLOW_PKT_TOCLIENT_FIRST
Definition: flow.h:236
StatsCounterIncr
void StatsCounterIncr(StatsThreadContext *stats, StatsCounterId id)
Increments the local counter.
Definition: counters.c:164
PacketFree
void PacketFree(Packet *p)
Return a malloced packet.
Definition: decode.c:222
PktSrcToString
const char * PktSrcToString(enum PktSrcEnum pkt_src)
Definition: decode.c:894
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:1017
DecodeThreadVars_::counter_pkts
StatsCounterId counter_pkts
Definition: decode.h:1000
DecodeThreadVars_::counter_eth
StatsCounterId counter_eth
Definition: decode.h:1009
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:132
SIZE_OF_PACKET
#define SIZE_OF_PACKET
Definition: decode.h:716
StringHashFreeFunc
void StringHashFreeFunc(void *data)
Definition: util-hash-string.c:44
DecodeThreadVars_::counter_sctp_init
StatsCounterId counter_sctp_init
Definition: decode.h:1030
BUG_ON
#define BUG_ON(x)
Definition: suricata-common.h:325
PKT_DROP_REASON_RULES
@ PKT_DROP_REASON_RULES
Definition: decode.h:393
util-profiling.h
DecodeThreadVars_::counter_flow_spare_sync_avg
StatsCounterAvgId counter_flow_spare_sync_avg
Definition: decode.h:1092
PacketCallocExtPkt
int PacketCallocExtPkt(Packet *p, int datalen)
Definition: decode.c:315
DecodeThreadVars_::counter_flow_icmp4
StatsCounterId counter_flow_icmp4
Definition: decode.h:1077
PKT_SRC_STREAM_TCP_DETECTLOG_FLUSH
@ PKT_SRC_STREAM_TCP_DETECTLOG_FLUSH
Definition: decode.h:59
DecodeThreadVars_::counter_ieee8021ah
StatsCounterId counter_ieee8021ah
Definition: decode.h:1045
DECODE_TUNNEL_VLAN
@ DECODE_TUNNEL_VLAN
Definition: decode.h:1148
PKT_SRC_DECODER_IPV6
@ PKT_SRC_DECODER_IPV6
Definition: decode.h:55
DecodeThreadVars_::counter_defrag_tracker_timeout
StatsCounterId counter_defrag_tracker_timeout
Definition: decode.h:1066
Packet_
Definition: decode.h:516
CaptureStats_::counter_drop_reason
StatsCounterId counter_drop_reason[PKT_DROP_REASON_MAX]
Definition: decode.c:1063
DecodeIPV6
int DecodeIPV6(ThreadVars *tv, DecodeThreadVars *dtv, Packet *p, const uint8_t *pkt, uint16_t len)
Definition: decode-ipv6.c:551
DECODE_TUNNEL_IPV4
@ DECODE_TUNNEL_IPV4
Definition: decode.h:1149
GET_PKT_LEN
#define GET_PKT_LEN(p)
Definition: decode.h:209
DecodeThreadVars_::app_tctx
AppLayerThreadCtx * app_tctx
Definition: decode.h:997
decode-teredo.h
CaptureStats_::counter_ips_blocked
StatsCounterId counter_ips_blocked
Definition: decode.c:1056
Packet_::ttype
uint8_t ttype
Definition: decode.h:559
PKT_DROP_REASON_STREAM_ERROR
@ PKT_DROP_REASON_STREAM_ERROR
Definition: decode.h:395
DecodeThreadVars_::counter_geneve
StatsCounterId counter_geneve
Definition: decode.h:1037
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:1114
DecodeThreadVars_::counter_sctp_shutdown
StatsCounterId counter_sctp_shutdown
Definition: decode.h:1034
DecodeThreadVars_::counter_tcp_rst
StatsCounterId counter_tcp_rst
Definition: decode.h:1016
FLOW_PKT_TOCLIENT
#define FLOW_PKT_TOCLIENT
Definition: flow.h:233
DECODE_TUNNEL_VXLAN
@ DECODE_TUNNEL_VXLAN
Definition: decode.h:1147
DECODE_TUNNEL_ETHERNET
@ DECODE_TUNNEL_ETHERNET
Definition: decode.h:1144
DecodeThreadVars_::counter_ipv4inipv6
StatsCounterId counter_ipv4inipv6
Definition: decode.h:1051
PKT_DROP_REASON_EP_FLOW_DROP
@ PKT_DROP_REASON_EP_FLOW_DROP
Definition: decode.h:390
FlowUpdateState
void FlowUpdateState(Flow *f, const enum FlowState s)
Definition: flow.c:1196
DecodeThreadVars_::counter_max_mac_addrs_dst
StatsCounterMaxId counter_max_mac_addrs_dst
Definition: decode.h:1005
PacketTunnelNone
@ PacketTunnelNone
Definition: decode.h:417
dtv
DecodeThreadVars * dtv
Definition: fuzz_decodepcapfile.c:35
DecodeThreadVars_::counter_defrag_memcap_eps
ExceptionPolicyCounters counter_defrag_memcap_eps
Definition: decode.h:1067
DecodeThreadVars_::counter_max_mac_addrs_src
StatsCounterMaxId counter_max_mac_addrs_src
Definition: decode.h:1004
default_packet_size
uint32_t default_packet_size
Definition: decode.c:77
Packet_::nb_decoded_layers
uint8_t nb_decoded_layers
Definition: decode.h:657
PKT_SRC_DECODER_GENEVE
@ PKT_SRC_DECODER_GENEVE
Definition: decode.h:63
Packet_::ReleasePacket
void(* ReleasePacket)(struct Packet_ *)
Definition: decode.h:606
flow-storage.h
DecodeThreadVars_::counter_ipv4_unknown_proto
StatsCounterId counter_ipv4_unknown_proto
Definition: decode.h:1053
cnt
uint32_t cnt
Definition: tmqh-packetpool.h:7
DecodeThreadVars_::counter_sctp_abort
StatsCounterId counter_sctp_abort
Definition: decode.h:1033
Packet_::flow
struct Flow_ * flow
Definition: decode.h:564
Packet_::tenant_id
uint32_t tenant_id
Definition: decode.h:678
DecodeThreadVars_::counter_ipv4inipv4
StatsCounterId counter_ipv4inipv4
Definition: decode.h:1049
PKT_DROP_REASON_INNER_PACKET
@ PKT_DROP_REASON_INNER_PACKET
Definition: decode.h:401
FlowGetMemcapExceptionPolicy
enum ExceptionPolicy FlowGetMemcapExceptionPolicy(void)
Definition: flow.c:134
DecodeThreadVarsFree
void DecodeThreadVarsFree(ThreadVars *tv, DecodeThreadVars *dtv)
Definition: decode.c:861
DecodeThreadVars_::counter_sll
StatsCounterId counter_sll
Definition: decode.h:1025
DecodeThreadVars_::counter_ppp
StatsCounterId counter_ppp
Definition: decode.h:1036
PKT_DROP_REASON_APPLAYER_MEMCAP
@ PKT_DROP_REASON_APPLAYER_MEMCAP
Definition: decode.h:392
DecodeGlobalConfig
void DecodeGlobalConfig(void)
Definition: decode.c:1157
suricata-common.h
PKT_SRC_FFR
@ PKT_SRC_FFR
Definition: decode.h:58
DecodeThreadVars_::counter_flow_udp
StatsCounterId counter_flow_udp
Definition: decode.h:1076
decode-arp.h
DecodeThreadVars_::counter_igmp
StatsCounterId counter_igmp
Definition: decode.h:1021
DecodeThreadVars_::counter_tcp_synack
StatsCounterId counter_tcp_synack
Definition: decode.h:1015
packet.h
Packet_::livedev_id
uint16_t livedev_id
Definition: decode.h:633
ACTION_DROP
#define ACTION_DROP
Definition: action-globals.h:30
Packet_::ext_pkt
uint8_t * ext_pkt
Definition: decode.h:630
PKT_DROP_REASON_NFQ_ERROR
@ PKT_DROP_REASON_NFQ_ERROR
Definition: decode.h:400
DecodeThreadVars_::counter_null
StatsCounterId counter_null
Definition: decode.h:1028
PacketUpdateEngineEventCounters
void PacketUpdateEngineEventCounters(ThreadVars *tv, DecodeThreadVars *dtv, Packet *p)
Definition: decode.c:242
SCStrdup
#define SCStrdup(s)
Definition: util-mem.h:56
DecodeThreadVars_::counter_flow_memcap_eps
ExceptionPolicyCounters counter_flow_memcap_eps
Definition: decode.h:1070
FatalError
#define FatalError(...)
Definition: util-debug.h:517
DECODE_EVENT_MAX
@ DECODE_EVENT_MAX
Definition: decode-events.h:335
decode-geneve.h
PacketContextData::next
struct PacketContextData * next
Definition: decode.h:244
PKT_SRC_DEFRAG
@ PKT_SRC_DEFRAG
Definition: decode.h:57
PKT_DROP_REASON_FW_STREAM_PRE_HOOK
@ PKT_DROP_REASON_FW_STREAM_PRE_HOOK
Definition: decode.h:410
tv
ThreadVars * tv
Definition: fuzz_decodepcapfile.c:34
DecodeThreadVars_::counter_vlan_qinq
StatsCounterId counter_vlan_qinq
Definition: decode.h:1040
DecodeThreadVars_::counter_teredo
StatsCounterId counter_teredo
Definition: decode.h:1047
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:261
defrag_memcap_eps_stats
ExceptionPolicyStatsSetts defrag_memcap_eps_stats
Definition: decode.c:86
PKT_SRC_DECODER_VXLAN
@ PKT_SRC_DECODER_VXLAN
Definition: decode.h:60
SCMalloc
#define SCMalloc(sz)
Definition: util-mem.h:47
CaptureStats_::counter_ips_rejected
StatsCounterId counter_ips_rejected
Definition: decode.c:1057
PACKET_ALERT_MAX
#define PACKET_ALERT_MAX
Definition: decode.h:286
Packet_::root
struct Packet_ * root
Definition: decode.h:666
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:61
SCFree
#define SCFree(p)
Definition: util-mem.h:61
DecodeThreadVars_::counter_max_pkt_size
StatsCounterMaxId counter_max_pkt_size
Definition: decode.h:1003
DecodeThreadVars_::counter_flow_spare_sync_incomplete
StatsCounterId counter_flow_spare_sync_incomplete
Definition: decode.h:1091
DecodeThreadVars_::counter_sll2
StatsCounterId counter_sll2
Definition: decode.h:1026
DecodeThreadVars_
Structure to hold thread specific data for all decode modules.
Definition: decode.h:995
MAX_PAYLOAD_SIZE
#define MAX_PAYLOAD_SIZE
Definition: decode.h:714
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:1135
Packet_::recursion_level
uint8_t recursion_level
Definition: decode.h:541
DecodeThreadVars_::counter_defrag_ipv4_fragments
StatsCounterId counter_defrag_ipv4_fragments
Definition: decode.h:1058
DecodeThreadVars_::counter_etag
StatsCounterId counter_etag
Definition: decode.h:1044
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:1077
DecodeThreadVars_::counter_tcp_active_sessions
StatsCounterId counter_tcp_active_sessions
Definition: decode.h:1072
DecodeThreadVars_::output_flow_thread_data
void * output_flow_thread_data
Definition: decode.h:1098
DecodeThreadVarsAlloc
DecodeThreadVars * DecodeThreadVarsAlloc(ThreadVars *tv)
Alloc and setup DecodeThreadVars.
Definition: decode.c:843
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:1122
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:35
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:881
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:409
GET_PKT_DIRECT_DATA
#define GET_PKT_DIRECT_DATA(p)
Definition: decode.h:211
ACTION_ACCEPT
#define ACTION_ACCEPT
Definition: action-globals.h:36
t_capture_stats
thread_local CaptureStats t_capture_stats
Definition: decode.c:1066
DecodeThreadVars_::counter_defrag_ipv6_reassembled
StatsCounterId counter_defrag_ipv6_reassembled
Definition: decode.h:1061
EngineModeIsIPS
int EngineModeIsIPS(void)
Definition: suricata.c:246
DecodeThreadVars_::counter_mpls
StatsCounterId counter_mpls
Definition: decode.h:1048
defrag-hash.h
Packet_::drop_reason
uint8_t drop_reason
Definition: decode.h:660
Address_::family
char family
Definition: decode.h:114
PKT_SRC_DECODER_GRE
@ PKT_SRC_DECODER_GRE
Definition: decode.h:53
ENGINE_SET_INVALID_EVENT
#define ENGINE_SET_INVALID_EVENT(p, e)
Definition: decode.h:1239
PacketAlert_
Definition: decode.h:249
DecodeGeneveConfig
void DecodeGeneveConfig(void)
Definition: decode-geneve.c:128
PacketTunnelRoot
@ PacketTunnelRoot
Definition: decode.h:418
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:408
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:543
DecodeThreadVars_::counter_ipv4
StatsCounterId counter_ipv4
Definition: decode.h:1011
DecodeThreadVars_::counter_flow_total
StatsCounterId counter_flow_total
Definition: decode.h:1073
DECODE_TUNNEL_ARP
@ DECODE_TUNNEL_ARP
Definition: decode.h:1154
likely
#define likely(expr)
Definition: util-optimize.h:32
PacketContextData::json_string
char * json_string
Definition: decode.h:243
DecodeThreadVars_::counter_arp
StatsCounterId counter_arp
Definition: decode.h:1022
DecodeThreadVars_::counter_vlan
StatsCounterId counter_vlan
Definition: decode.h:1039
PacketDefragPktSetupParent
void PacketDefragPktSetupParent(Packet *parent)
inform defrag "parent" that a pseudo packet is now associated to it.
Definition: decode.c:531
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:1064
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:403
DecodeThreadVars_::counter_flow_elephant_toclient
StatsCounterId counter_flow_elephant_toclient
Definition: decode.h:1082
DecodeThreadVars_::counter_flow_elephant_toserver
StatsCounterId counter_flow_elephant_toserver
Definition: decode.h:1081
stats_decoder_events
bool stats_decoder_events
Definition: counters.c:97
flow.h
PKT_DROP_REASON_STREAM_MIDSTREAM
@ PKT_DROP_REASON_STREAM_MIDSTREAM
Definition: decode.h:397
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:1054
ThreadVars_::stats
StatsThreadContext stats
Definition: threadvars.h:121
DecodeVLAN
int DecodeVLAN(ThreadVars *tv, DecodeThreadVars *dtv, Packet *p, const uint8_t *pkt, uint32_t len)
Definition: decode-vlan.c:54
StatsCounterAddI64
void StatsCounterAddI64(StatsThreadContext *stats, StatsCounterId id, int64_t x)
Adds a value of type uint64_t to the local counter.
Definition: counters.c:145
DecodeThreadVars_::counter_ipv6inipv6
StatsCounterId counter_ipv6inipv6
Definition: decode.h:1052
FLOW_PKT_TOSERVER_FIRST
#define FLOW_PKT_TOSERVER_FIRST
Definition: flow.h:235
DefragGetMemcapExceptionPolicy
enum ExceptionPolicy DefragGetMemcapExceptionPolicy(void)
Definition: defrag-hash.c:80
DecodeThreadVars_::counter_engine_events
StatsCounterId counter_engine_events[DECODE_EVENT_MAX]
Definition: decode.h:1094
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:299
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:42
PKT_DROP_REASON_FLOW_DROP
@ PKT_DROP_REASON_FLOW_DROP
Definition: decode.h:389
PKT_IS_INVALID
#define PKT_IS_INVALID
Definition: decode.h:1336
DecodeUpdatePacketCounters
void DecodeUpdatePacketCounters(ThreadVars *tv, const DecodeThreadVars *dtv, const Packet *p)
Definition: decode.c:811
output.h
DecodeThreadVars_::counter_flow_get_used_eval_reject
StatsCounterId counter_flow_get_used_eval_reject
Definition: decode.h:1085
DecodeThreadVars_::counter_flow_get_used_eval
StatsCounterId counter_flow_get_used_eval
Definition: decode.h:1084
app-layer.h
DecodeThreadVars_::counter_flow_tcp_reuse
StatsCounterId counter_flow_tcp_reuse
Definition: decode.h:1079
PKT_DROP_REASON_DECODE_ERROR
@ PKT_DROP_REASON_DECODE_ERROR
Definition: decode.h:385
PacketEngineEvents_::cnt
uint8_t cnt
Definition: decode.h:310
DecodeThreadVars_::counter_flow_tcp
StatsCounterId counter_flow_tcp
Definition: decode.h:1075
DecodeThreadVars_::counter_sctp_data
StatsCounterId counter_sctp_data
Definition: decode.h:1032