suricata
decode.h
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  * \file
20  *
21  * \author Victor Julien <victor@inliniac.net>
22  */
23 
24 #ifndef SURICATA_DECODE_H
25 #define SURICATA_DECODE_H
26 
27 //#define DBG_THREADS
28 #define COUNTERS
29 
30 #include "suricata-common.h"
31 #include "suricata-plugin.h"
32 #include "threadvars.h"
33 #include "util-debug.h"
34 #include "decode-events.h"
36 #include "util-datalink.h"
37 #ifdef PROFILING
38 #include "flow-worker.h"
39 #include "app-layer-protos.h"
40 #endif
41 
42 typedef enum {
50 
51 enum PktSrcEnum {
65 };
66 
67 #include "source-nflog.h"
68 #include "source-nfq.h"
69 #include "source-ipfw.h"
70 #include "source-pcap.h"
71 #include "source-af-packet.h"
72 #include "source-netmap.h"
73 #include "source-windivert.h"
74 #ifdef HAVE_DPDK
75 #include "source-dpdk.h"
76 #endif
77 #ifdef HAVE_AF_XDP
78 #include "source-af-xdp.h"
79 #endif
80 
81 #include "decode-ethernet.h"
82 #include "decode-gre.h"
83 #include "decode-ppp.h"
84 #include "decode-ipv4.h"
85 #include "decode-ipv6.h"
86 #include "decode-icmpv4.h"
87 #include "decode-icmpv6.h"
88 #include "decode-igmp.h"
89 #include "decode-tcp.h"
90 #include "decode-udp.h"
91 #include "decode-sctp.h"
92 #include "decode-esp.h"
93 #include "decode-vlan.h"
94 #include "decode-mpls.h"
95 #include "decode-arp.h"
96 
97 #include "util-validate.h"
98 
99 /* for now a uint8_t is enough -- here in decode as it's part of the packet */
100 #define SignatureMask uint8_t
101 
102 /* forward declarations */
103 struct DetectionEngineThreadCtx_;
105 
106 struct PktPool_;
107 
108 /* declare these here as they are called from the
109  * PACKET_RECYCLE and PACKET_CLEANUP macro's. */
111 
112 /* Address */
113 typedef struct Address_ {
114  char family;
115  union {
116  uint32_t address_un_data32[4]; /* type-specific field */
117  uint16_t address_un_data16[8]; /* type-specific field */
118  uint8_t address_un_data8[16]; /* type-specific field */
119  struct in6_addr address_un_in6;
122 
123 #define addr_data32 address.address_un_data32
124 #define addr_data16 address.address_un_data16
125 #define addr_data8 address.address_un_data8
126 #define addr_in6addr address.address_un_in6
127 
128 #define COPY_ADDRESS(a, b) do { \
129  (b)->family = (a)->family; \
130  (b)->addr_data32[0] = (a)->addr_data32[0]; \
131  (b)->addr_data32[1] = (a)->addr_data32[1]; \
132  (b)->addr_data32[2] = (a)->addr_data32[2]; \
133  (b)->addr_data32[3] = (a)->addr_data32[3]; \
134  } while (0)
135 
136 /* Set the IPv4 addresses into the Addrs of the Packet.
137  * Make sure p->ip4h is initialized and validated.
138  *
139  * We set the rest of the struct to 0 so we can
140  * prevent using memset. */
141 #define SET_IPV4_SRC_ADDR(ip4h, a) \
142  do { \
143  (a)->family = AF_INET; \
144  (a)->addr_data32[0] = (uint32_t)(ip4h)->s_ip_src.s_addr; \
145  (a)->addr_data32[1] = 0; \
146  (a)->addr_data32[2] = 0; \
147  (a)->addr_data32[3] = 0; \
148  } while (0)
149 
150 #define SET_IPV4_DST_ADDR(ip4h, a) \
151  do { \
152  (a)->family = AF_INET; \
153  (a)->addr_data32[0] = (uint32_t)(ip4h)->s_ip_dst.s_addr; \
154  (a)->addr_data32[1] = 0; \
155  (a)->addr_data32[2] = 0; \
156  (a)->addr_data32[3] = 0; \
157  } while (0)
158 
159 /* Set the IPv6 addresses into the Addrs of the Packet. */
160 #define SET_IPV6_SRC_ADDR(ip6h, a) \
161  do { \
162  (a)->family = AF_INET6; \
163  (a)->addr_data32[0] = (ip6h)->s_ip6_src[0]; \
164  (a)->addr_data32[1] = (ip6h)->s_ip6_src[1]; \
165  (a)->addr_data32[2] = (ip6h)->s_ip6_src[2]; \
166  (a)->addr_data32[3] = (ip6h)->s_ip6_src[3]; \
167  } while (0)
168 
169 #define SET_IPV6_DST_ADDR(ip6h, a) \
170  do { \
171  (a)->family = AF_INET6; \
172  (a)->addr_data32[0] = (ip6h)->s_ip6_dst[0]; \
173  (a)->addr_data32[1] = (ip6h)->s_ip6_dst[1]; \
174  (a)->addr_data32[2] = (ip6h)->s_ip6_dst[2]; \
175  (a)->addr_data32[3] = (ip6h)->s_ip6_dst[3]; \
176  } while (0)
177 
178 /* Set the TCP ports into the Ports of the Packet.
179  * Make sure p->tcph is initialized and validated. */
180 #define SET_TCP_SRC_PORT(pkt, prt) do { \
181  SET_PORT(TCP_GET_SRC_PORT((pkt)), *(prt)); \
182  } while (0)
183 
184 #define SET_TCP_DST_PORT(pkt, prt) do { \
185  SET_PORT(TCP_GET_DST_PORT((pkt)), *(prt)); \
186  } while (0)
187 
188 /* Set the UDP ports into the Ports of the Packet.
189  * Make sure p->udph is initialized and validated. */
190 #define SET_UDP_SRC_PORT(pkt, prt) do { \
191  SET_PORT(UDP_GET_SRC_PORT((pkt)), *(prt)); \
192  } while (0)
193 #define SET_UDP_DST_PORT(pkt, prt) do { \
194  SET_PORT(UDP_GET_DST_PORT((pkt)), *(prt)); \
195  } while (0)
196 
197 #define GET_IPV4_SRC_ADDR_U32(p) ((p)->src.addr_data32[0])
198 #define GET_IPV4_DST_ADDR_U32(p) ((p)->dst.addr_data32[0])
199 #define GET_IPV4_SRC_ADDR_PTR(p) ((p)->src.addr_data32)
200 #define GET_IPV4_DST_ADDR_PTR(p) ((p)->dst.addr_data32)
201 
202 #define GET_IPV6_SRC_IN6ADDR(p) ((p)->src.addr_in6addr)
203 #define GET_IPV6_DST_IN6ADDR(p) ((p)->dst.addr_in6addr)
204 #define GET_IPV6_SRC_ADDR(p) ((p)->src.addr_data32)
205 #define GET_IPV6_DST_ADDR(p) ((p)->dst.addr_data32)
206 #define GET_TCP_SRC_PORT(p) ((p)->sp)
207 #define GET_TCP_DST_PORT(p) ((p)->dp)
208 
209 #define GET_PKT_LEN(p) (p)->pktlen
210 #define GET_PKT_DATA(p) (((p)->ext_pkt == NULL) ? GET_PKT_DIRECT_DATA(p) : (p)->ext_pkt)
211 #define GET_PKT_DIRECT_DATA(p) (p)->pkt_data
212 #define GET_PKT_DIRECT_MAX_SIZE(p) (default_packet_size)
213 
214 #define SET_PKT_LEN(p, len) do { \
215  (p)->pktlen = (len); \
216  } while (0)
217 
218 /* Port is just a uint16_t */
219 typedef uint16_t Port;
220 #define SET_PORT(v, p) ((p) = (v))
221 #define COPY_PORT(a,b) ((b) = (a))
222 
223 #define CMP_ADDR(a1, a2) \
224  (((a1)->addr_data32[3] == (a2)->addr_data32[3] && \
225  (a1)->addr_data32[2] == (a2)->addr_data32[2] && \
226  (a1)->addr_data32[1] == (a2)->addr_data32[1] && \
227  (a1)->addr_data32[0] == (a2)->addr_data32[0]))
228 #define CMP_PORT(p1, p2) \
229  ((p1) == (p2))
230 
231 /*Given a packet pkt offset to the start of the ip header in a packet
232  *We determine the ip version. */
233 #define IP_GET_RAW_VER(pkt) ((((pkt)[0] & 0xf0) >> 4))
234 
235 #define PKT_IS_TCP(p) (((p)->tcph != NULL))
236 #define PKT_IS_UDP(p) (((p)->udph != NULL))
237 #define PKT_IS_ICMPV4(p) (((p)->icmpv4h != NULL))
238 #define PKT_IS_ICMPV6(p) (((p)->icmpv6h != NULL))
239 #define PKT_IS_TOSERVER(p) (((p)->flowflags & FLOW_PKT_TOSERVER))
240 #define PKT_IS_TOCLIENT(p) (((p)->flowflags & FLOW_PKT_TOCLIENT))
241 
243  char *json_string;
245 };
246 
247 /* structure to store the sids/gids/etc the detection engine
248  * found in this packet */
249 typedef struct PacketAlert_ {
250  SigIntId iid; /* Internal ID, used for sorting */
251  uint8_t action; /* Rule or threshold action to be applied to packet */
252  uint8_t flags;
253  const struct Signature_ *s;
254  uint64_t tx_id; /* Used for sorting */
255  int64_t frame_id;
258 
259 /**
260  * \defgroup PacketAlertFlags
261  *
262  * Available flags for PacketAlert.flags.
263  *
264  * @{
265  */
266 /** flag to indicate the rule action (drop/pass) needs to be applied to the flow */
267 #define PACKET_ALERT_FLAG_APPLY_ACTION_TO_FLOW BIT_U8(0)
268 /** alert was generated based on state */
269 #define PACKET_ALERT_FLAG_STATE_MATCH BIT_U8(1)
270 /** alert was generated based on stream */
271 #define PACKET_ALERT_FLAG_STREAM_MATCH BIT_U8(2)
272 /** alert is in a tx, tx_id set */
273 #define PACKET_ALERT_FLAG_TX BIT_U8(3)
274 /** action was changed by rate_filter */
275 #define PACKET_ALERT_FLAG_RATE_FILTER_MODIFIED BIT_U8(4)
276 /** alert is in a frame, frame_id set */
277 #define PACKET_ALERT_FLAG_FRAME BIT_U8(5)
278 /** alert in a tx was forced */
279 #define PACKET_ALERT_FLAG_TX_GUESSED BIT_U8(6)
280 /** accept should be applied to packet */
281 #define PACKET_ALERT_FLAG_APPLY_ACTION_TO_PACKET BIT_U8(7)
282 /** @} */
283 
284 extern uint16_t packet_alert_max;
285 #define PACKET_ALERT_MAX 15
286 
287 typedef struct PacketAlerts_ {
288  uint16_t cnt;
289  uint16_t discarded;
290  uint16_t firewall_discarded; /* alerts discarded after a drop, in fw mode*/
291  uint16_t suppressed;
293  /* single pa used when we're dropping,
294  * so we can log it out in the drop log. */
297 
299 void PacketAlertRecycle(PacketAlert *pa_array, uint16_t cnt);
300 
301 void PacketAlertFree(PacketAlert *pa);
302 
303 /** number of decoder events we support per packet. Power of 2 minus 1
304  * for memory layout */
305 #define PACKET_ENGINE_EVENT_MAX 15
306 
307 /** data structure to store decoder, defrag and stream events */
308 typedef struct PacketEngineEvents_ {
309  uint8_t cnt; /**< number of events */
310  uint8_t events[PACKET_ENGINE_EVENT_MAX]; /**< array of events */
312 
313 typedef struct PktVar_ {
314  uint32_t id;
315  struct PktVar_ *next; /* right now just implement this as a list,
316  * in the long run we have thing of something
317  * faster. */
318  uint16_t key_len;
319  uint16_t value_len;
320  uint8_t *key;
321  uint8_t *value;
323 
324 #ifdef PROFILING
325 
326 /** \brief Per TMM stats storage */
327 typedef struct PktProfilingTmmData_ {
328  uint64_t ticks_start;
329  uint64_t ticks_end;
330 #ifdef PROFILE_LOCKING
331  uint64_t mutex_lock_cnt;
332  uint64_t mutex_lock_wait_ticks;
333  uint64_t mutex_lock_contention;
334  uint64_t spin_lock_cnt;
335  uint64_t spin_lock_wait_ticks;
336  uint64_t spin_lock_contention;
337  uint64_t rww_lock_cnt;
338  uint64_t rww_lock_wait_ticks;
339  uint64_t rww_lock_contention;
340  uint64_t rwr_lock_cnt;
341  uint64_t rwr_lock_wait_ticks;
342  uint64_t rwr_lock_contention;
343 #endif
345 
346 typedef struct PktProfilingData_ {
347  uint64_t ticks_start;
348  uint64_t ticks_end;
350 
351 typedef struct PktProfilingDetectData_ {
352  uint64_t ticks_start;
353  uint64_t ticks_end;
354  uint64_t ticks_spent;
356 
357 typedef struct PktProfilingAppData_ {
358  uint64_t ticks_spent;
360 
361 typedef struct PktProfilingLoggerData_ {
362  uint64_t ticks_start;
363  uint64_t ticks_end;
364  uint64_t ticks_spent;
366 
367 /** \brief Per pkt stats storage */
368 typedef struct PktProfiling_ {
369  uint64_t ticks_start;
370  uint64_t ticks_end;
371 
376  uint64_t proto_detect;
379 
380 #endif /* PROFILING */
381 
393  PKT_DROP_REASON_RULES_THRESHOLD, /**< detection_filter in action */
399  PKT_DROP_REASON_NFQ_ERROR, /**< no nfq verdict, must be error */
400  PKT_DROP_REASON_INNER_PACKET, /**< drop issued by inner (tunnel) packet */
401 /** If more non-firewall drop reasons are added, make sure not to "break" PKT_DROP_REASON_NON_FW_MAX
402  */
403 /* Limiter for non-firewall drop reasons. */
404 #define PKT_DROP_REASON_NON_FW_MAX PKT_DROP_REASON_INNER_PACKET
405  /** Firewall-related reasons only */
407  PKT_DROP_REASON_FW_DEFAULT_PACKET_POLICY, /**< drop issued by default packet policy */
408  PKT_DROP_REASON_FW_DEFAULT_APP_POLICY, /**< drop issued by default app policy */
409  PKT_DROP_REASON_FW_STREAM_PRE_HOOK, /**< drop issued in the pre_stream hook */
410  PKT_DROP_REASON_FW_FLOW_PRE_HOOK, /**< drop issued in the pre_flow hook */
413 };
414 
419 };
420 
421 /* forward declaration since Packet struct definition requires this */
422 struct PacketQueue_;
423 
427 };
428 
429 struct PacketL2 {
430  enum PacketL2Types type;
431  union L2Hdrs {
432  EthernetHdr *ethh;
433  } hdrs;
434 };
435 
441 };
442 
443 struct PacketL3 {
444  enum PacketL3Types type;
445  /* Checksum for IP packets. */
446  bool csum_set;
447  uint16_t csum;
448  union Hdrs {
451  ARPHdr *arph;
452  } hdrs;
453  /* IPv4 and IPv6 are mutually exclusive */
454  union {
456  struct {
459  } ip6;
460  } vars;
461 };
462 
473 };
474 
475 struct PacketL4 {
476  enum PacketL4Types type;
477  bool csum_set;
478  uint16_t csum;
479  union L4Hdrs {
484  SCTPHdr *sctph;
485  GREHdr *greh;
486  ESPHdr *esph;
488  } hdrs;
489  union L4Vars {
494  } vars;
495 };
496 
497 /* sizes of the members:
498  * src: 17 bytes
499  * dst: 17 bytes
500  * sp/type: 1 byte
501  * dp/code: 1 byte
502  * proto: 1 byte
503  * recurs: 1 byte
504  *
505  * sum of above: 38 bytes
506  *
507  * flow ptr: 4/8 bytes
508  * flags: 1 byte
509  * flowflags: 1 byte
510  *
511  * sum of above 44/48 bytes
512  */
513 typedef struct Packet_
514 {
515  /* Addresses, Ports and protocol
516  * these are on top so we can use
517  * the Packet as a hash key */
520  union {
522  // icmp type and code of this packet
523  struct {
524  uint8_t type;
525  uint8_t code;
527  };
528  union {
530  // icmp type and code of the expected counterpart (for flows)
531  struct {
532  uint8_t type;
533  uint8_t code;
535  };
536  uint8_t proto;
537  /* make sure we can't be attacked on when the tunneled packet
538  * has the exact same tuple as the lower levels */
540 
542  uint8_t vlan_idx;
543 
544  /* flow */
545  uint8_t flowflags;
546  /* coccinelle: Packet:flowflags:FLOW_PKT_ */
547 
548  uint8_t app_update_direction; // enum StreamUpdateDir
549 
550  /** sig mask flags this packet has, used in signature matching */
552 
553  /** bit flags of SignatureHookPkt values this packet should trigger */
554  uint16_t pkt_hooks;
555 
556  /* tunnel type: none, root or child */
557  uint8_t ttype; // enum PacketTunnelType
558 
559  /* Pkt Flags */
560  uint32_t flags;
561 
562  struct Flow_ *flow;
563 
564  /* raw hash value for looking up the flow, will need to modulated to the
565  * hash size still */
566  uint32_t flow_hash;
567 
569 
570  union {
571  /* nfq stuff */
572 #ifdef HAVE_NFLOG
573  NFLOGPacketVars nflog_v;
574 #endif /* HAVE_NFLOG */
575 #ifdef NFQ
577 #endif /* NFQ */
578 #ifdef IPFW
580 #endif /* IPFW */
581 #ifdef AF_PACKET
582  AFPPacketVars afp_v;
583 #endif
584 #ifdef HAVE_NETMAP
585  NetmapPacketVars netmap_v;
586 #endif
587 #ifdef WINDIVERT
588  WinDivertPacketVars windivert_v;
589 #endif /* WINDIVERT */
590 #ifdef HAVE_DPDK
591  DPDKPacketVars dpdk_v;
592 #endif
593 #ifdef HAVE_AF_XDP
594  AFXDPPacketVars afxdp_v;
595 #endif
596  /* A chunk of memory that a plugin can use for its packet vars. */
598 
599  /** libpcap vars: shared by Pcap Live mode and Pcap File mode */
601  };
602 
603  /** The release function for packet structure and data */
604  void (*ReleasePacket)(struct Packet_ *);
605  /** The function triggering bypass the flow in the capture method.
606  * Return 1 for success and 0 on error */
607  int (*BypassPacketsFlow)(struct Packet_ *);
608 
609  /* pkt vars */
611 
612  struct PacketL2 l2;
613  struct PacketL3 l3;
614  struct PacketL4 l4;
615 
616  /* ptr to the payload of the packet
617  * with it's length. */
618  uint8_t *payload;
619  uint16_t payload_len;
620 
621  /* IPS action to take */
622  uint8_t action;
623 
624  uint8_t pkt_src;
625 
626  /* storage: set to pointer to heap and extended via allocation if necessary */
627  uint32_t pktlen;
628  uint8_t *ext_pkt;
629 
630  /* Incoming interface */
631  uint16_t livedev_id;
632  /* Outgoing interface (bridge modes) */
633  uint16_t livedev_dst_id;
634 
636 
637  struct Host_ *host_src;
638  struct Host_ *host_dst;
639 
640  /* engine events */
642 
644 
645  /* double linked list ptrs */
646  struct Packet_ *next;
647  struct Packet_ *prev;
648 
649  /** data linktype in host order */
650  int datalink;
651 
652  /* count decoded layers of packet : too many layers
653  * cause issues with performance and stability (stack exhaustion)
654  */
656 
657  /* enum PacketDropReason::PKT_DROP_REASON_* as uint8_t for compactness */
658  uint8_t drop_reason;
659 
660  /** has verdict on this tunneled packet been issued? */
662 
663  /* tunnel/encapsulation handling */
664  struct Packet_ *root; /* in case of tunnel this is a ptr
665  * to the 'real' packet, the one we
666  * need to set the verdict on --
667  * It should always point to the lowest
668  * packet in a encapsulated packet */
669 
670  /* ready to set verdict counter, only set in root */
671  uint16_t tunnel_rtv_cnt;
672  /* tunnel packet ref count */
673  uint16_t tunnel_tpr_cnt;
674 
675  /** tenant id for this packet, if any. If 0 then no tenant was assigned. */
676  uint32_t tenant_id;
677 
678  /* The Packet pool from which this packet was allocated. Used when returning
679  * the packet to its owner's stack. If NULL, then allocated with malloc.
680  */
681  struct PktPool_ *pool;
682 
683 #ifdef PROFILING
685 #endif
686  /* things in the packet that live beyond a reinit */
687  struct {
688  /** lock to protect access to:
689  * - tunnel_rtv_cnt
690  * - tunnel_tpr_cnt
691  * - tunnel_verdicted
692  * - nfq_v.mark (if p->ttype != PacketTunnelNone)
693  */
696 
697  /** flex array accessor to allocated packet data. Size of the additional
698  * data is `default_packet_size`. If this is insufficient,
699  * Packet::ext_pkt will be used instead. */
700  uint8_t pkt_data[];
702 
703 static inline bool PacketIsIPv4(const Packet *p);
704 static inline bool PacketIsIPv6(const Packet *p);
705 
706 /** highest mtu of the interfaces we monitor */
707 #define DEFAULT_MTU 1500
708 #define MINIMUM_MTU 68 /**< ipv4 minimum: rfc791 */
709 
710 #define DEFAULT_PACKET_SIZE (DEFAULT_MTU + ETHERNET_HEADER_LEN)
711 /* storage: maximum ip packet size + link header */
712 #define MAX_PAYLOAD_SIZE (IPV6_HEADER_LEN + 65536 + 28)
713 extern uint32_t default_packet_size;
714 #define SIZE_OF_PACKET (default_packet_size + sizeof(Packet))
715 
716 static inline bool PacketIsIPv4(const Packet *p)
717 {
718  return p->l3.type == PACKET_L3_IPV4;
719 }
720 
721 static inline const IPV4Hdr *PacketGetIPv4(const Packet *p)
722 {
723  DEBUG_VALIDATE_BUG_ON(!PacketIsIPv4(p));
724  return p->l3.hdrs.ip4h;
725 }
726 
727 static inline IPV4Hdr *PacketSetIPV4(Packet *p, const uint8_t *buf)
728 {
730  p->l3.type = PACKET_L3_IPV4;
731  p->l3.hdrs.ip4h = (IPV4Hdr *)buf;
732  return p->l3.hdrs.ip4h;
733 }
734 
735 /* Retrieve proto regardless of IP version */
736 static inline uint8_t PacketGetIPProto(const Packet *p)
737 {
738  if (p->proto != 0) {
739  return p->proto;
740  }
741  if (PacketIsIPv4(p)) {
742  const IPV4Hdr *hdr = PacketGetIPv4(p);
743  return IPV4_GET_RAW_IPPROTO(hdr);
744  } else if (PacketIsIPv6(p)) {
745  return IPV6_GET_L4PROTO(p);
746  }
747  return 0;
748 }
749 
750 static inline uint8_t PacketGetIPv4IPProto(const Packet *p)
751 {
752  if (PacketGetIPv4(p)) {
753  const IPV4Hdr *hdr = PacketGetIPv4(p);
754  return IPV4_GET_RAW_IPPROTO(hdr);
755  }
756  return 0;
757 }
758 
759 static inline const IPV6Hdr *PacketGetIPv6(const Packet *p)
760 {
761  DEBUG_VALIDATE_BUG_ON(!PacketIsIPv6(p));
762  return p->l3.hdrs.ip6h;
763 }
764 
765 static inline IPV6Hdr *PacketSetIPV6(Packet *p, const uint8_t *buf)
766 {
768  p->l3.type = PACKET_L3_IPV6;
769  p->l3.hdrs.ip6h = (IPV6Hdr *)buf;
770  return p->l3.hdrs.ip6h;
771 }
772 
773 static inline bool PacketIsIPv6(const Packet *p)
774 {
775  return p->l3.type == PACKET_L3_IPV6;
776 }
777 
778 static inline void PacketClearL2(Packet *p)
779 {
780  memset(&p->l2, 0, sizeof(p->l2));
781 }
782 
783 /* Can be called multiple times, e.g. for DCE */
784 static inline EthernetHdr *PacketSetEthernet(Packet *p, const uint8_t *buf)
785 {
788  p->l2.hdrs.ethh = (EthernetHdr *)buf;
789  return p->l2.hdrs.ethh;
790 }
791 
792 static inline const EthernetHdr *PacketGetEthernet(const Packet *p)
793 {
795  return p->l2.hdrs.ethh;
796 }
797 
798 static inline bool PacketIsEthernet(const Packet *p)
799 {
800  return p->l2.type == PACKET_L2_ETHERNET;
801 }
802 
803 static inline void PacketClearL3(Packet *p)
804 {
805  memset(&p->l3, 0, sizeof(p->l3));
806 }
807 
808 static inline void PacketClearL4(Packet *p)
809 {
810  memset(&p->l4, 0, sizeof(p->l4));
811 }
812 
813 static inline TCPHdr *PacketSetTCP(Packet *p, const uint8_t *buf)
814 {
816  p->l4.type = PACKET_L4_TCP;
817  p->l4.hdrs.tcph = (TCPHdr *)buf;
818  return p->l4.hdrs.tcph;
819 }
820 
821 static inline const TCPHdr *PacketGetTCP(const Packet *p)
822 {
824  return p->l4.hdrs.tcph;
825 }
826 
827 static inline bool PacketIsTCP(const Packet *p)
828 {
829  return p->l4.type == PACKET_L4_TCP;
830 }
831 
832 static inline UDPHdr *PacketSetUDP(Packet *p, const uint8_t *buf)
833 {
835  p->l4.type = PACKET_L4_UDP;
836  p->l4.hdrs.udph = (UDPHdr *)buf;
837  return p->l4.hdrs.udph;
838 }
839 
840 static inline const UDPHdr *PacketGetUDP(const Packet *p)
841 {
843  return p->l4.hdrs.udph;
844 }
845 
846 static inline bool PacketIsUDP(const Packet *p)
847 {
848  return p->l4.type == PACKET_L4_UDP;
849 }
850 
851 static inline ICMPV4Hdr *PacketSetICMPv4(Packet *p, const uint8_t *buf)
852 {
854  p->l4.type = PACKET_L4_ICMPV4;
855  p->l4.hdrs.icmpv4h = (ICMPV4Hdr *)buf;
856  return p->l4.hdrs.icmpv4h;
857 }
858 
859 static inline const ICMPV4Hdr *PacketGetICMPv4(const Packet *p)
860 {
862  return p->l4.hdrs.icmpv4h;
863 }
864 
865 static inline bool PacketIsICMPv4(const Packet *p)
866 {
867  return p->l4.type == PACKET_L4_ICMPV4;
868 }
869 
870 static inline const IPV4Hdr *PacketGetICMPv4EmbIPv4(const Packet *p)
871 {
872  const uint8_t *start = (const uint8_t *)PacketGetICMPv4(p);
873  const uint8_t *ip = start + p->l4.vars.icmpv4.emb_ip4h_offset;
874  return (const IPV4Hdr *)ip;
875 }
876 
877 static inline ICMPV6Hdr *PacketSetICMPv6(Packet *p, const uint8_t *buf)
878 {
880  p->l4.type = PACKET_L4_ICMPV6;
881  p->l4.hdrs.icmpv6h = (ICMPV6Hdr *)buf;
882  return p->l4.hdrs.icmpv6h;
883 }
884 
885 static inline const ICMPV6Hdr *PacketGetICMPv6(const Packet *p)
886 {
888  return p->l4.hdrs.icmpv6h;
889 }
890 
891 static inline bool PacketIsICMPv6(const Packet *p)
892 {
893  return p->l4.type == PACKET_L4_ICMPV6;
894 }
895 
896 static inline SCTPHdr *PacketSetSCTP(Packet *p, const uint8_t *buf)
897 {
899  p->l4.type = PACKET_L4_SCTP;
900  p->l4.hdrs.sctph = (SCTPHdr *)buf;
901  return p->l4.hdrs.sctph;
902 }
903 
904 static inline const SCTPHdr *PacketGetSCTP(const Packet *p)
905 {
907  return p->l4.hdrs.sctph;
908 }
909 
910 static inline bool PacketIsSCTP(const Packet *p)
911 {
912  return p->l4.type == PACKET_L4_SCTP;
913 }
914 
915 static inline GREHdr *PacketSetGRE(Packet *p, const uint8_t *buf)
916 {
918  p->l4.type = PACKET_L4_GRE;
919  p->l4.hdrs.greh = (GREHdr *)buf;
920  return p->l4.hdrs.greh;
921 }
922 
923 static inline const GREHdr *PacketGetGRE(const Packet *p)
924 {
926  return p->l4.hdrs.greh;
927 }
928 
929 static inline bool PacketIsGRE(const Packet *p)
930 {
931  return p->l4.type == PACKET_L4_GRE;
932 }
933 
934 static inline ESPHdr *PacketSetESP(Packet *p, const uint8_t *buf)
935 {
937  p->l4.type = PACKET_L4_ESP;
938  p->l4.hdrs.esph = (ESPHdr *)buf;
939  return p->l4.hdrs.esph;
940 }
941 
942 static inline const ESPHdr *PacketGetESP(const Packet *p)
943 {
945  return p->l4.hdrs.esph;
946 }
947 
948 static inline bool PacketIsESP(const Packet *p)
949 {
950  return p->l4.type == PACKET_L4_ESP;
951 }
952 
953 static inline const ARPHdr *PacketGetARP(const Packet *p)
954 {
956  return p->l3.hdrs.arph;
957 }
958 
959 static inline ARPHdr *PacketSetARP(Packet *p, const uint8_t *buf)
960 {
962  p->l3.type = PACKET_L3_ARP;
963  p->l3.hdrs.arph = (ARPHdr *)buf;
964  return p->l3.hdrs.arph;
965 }
966 
967 static inline bool PacketIsARP(const Packet *p)
968 {
969  return p->l3.type == PACKET_L3_ARP;
970 }
971 
972 static inline IGMPHdr *PacketSetIGMP(Packet *p, const uint8_t *buf)
973 {
975  p->l4.type = PACKET_L4_IGMP;
976  p->l4.hdrs.igmph = (IGMPHdr *)buf;
977  return p->l4.hdrs.igmph;
978 }
979 
980 static inline const IGMPHdr *PacketGetIGMP(const Packet *p)
981 {
983  return p->l4.hdrs.igmph;
984 }
985 
986 static inline bool PacketIsIGMP(const Packet *p)
987 {
988  return p->l4.type == PACKET_L4_IGMP;
989 }
990 
991 /** \brief Structure to hold thread specific data for all decode modules */
992 typedef struct DecodeThreadVars_
993 {
994  /** Specific context for udp protocol detection (here atm) */
996 
997  /** stats/counters */
1004 
1006 
1022 
1049 
1050  /** frag stats - defrag runs in the context of the decoder. */
1061 
1064 
1081 
1086 
1088 
1089  /* thread data for flow logging api: only used at forced
1090  * flow recycle during lookups */
1092 
1094 
1095 void CaptureStatsUpdate(ThreadVars *tv, const Packet *p);
1097 
1098 #define PACKET_CLEAR_L4VARS(p) do { \
1099  memset(&(p)->l4vars, 0x00, sizeof((p)->l4vars)); \
1100  } while (0)
1101 
1102 /* if p uses extended data, free them */
1103 #define PACKET_FREE_EXTDATA(p) do { \
1104  if ((p)->ext_pkt) { \
1105  if (!((p)->flags & PKT_ZERO_COPY)) { \
1106  SCFree((p)->ext_pkt); \
1107  } \
1108  (p)->ext_pkt = NULL; \
1109  } \
1110  } while(0)
1111 
1112 #define TUNNEL_INCR_PKT_RTV_NOLOCK(p) do { \
1113  ((p)->root ? (p)->root->tunnel_rtv_cnt++ : (p)->tunnel_rtv_cnt++); \
1114  } while (0)
1115 
1116 static inline void TUNNEL_INCR_PKT_TPR(Packet *p)
1117 {
1118  Packet *rp = p->root ? p->root : p;
1120  rp->tunnel_tpr_cnt++;
1122 }
1123 
1124 #define TUNNEL_PKT_RTV(p) ((p)->root ? (p)->root->tunnel_rtv_cnt : (p)->tunnel_rtv_cnt)
1125 #define TUNNEL_PKT_TPR(p) ((p)->root ? (p)->root->tunnel_tpr_cnt : (p)->tunnel_tpr_cnt)
1127 static inline bool PacketTunnelIsVerdicted(const Packet *p)
1128 {
1129  return p->tunnel_verdicted;
1130 }
1131 static inline void PacketTunnelSetVerdicted(Packet *p)
1132 {
1133  p->tunnel_verdicted = true;
1134 }
1135 
1144  DECODE_TUNNEL_IPV6_TEREDO, /**< separate protocol for stricter error handling */
1149 };
1150 
1152  const uint8_t *pkt, uint32_t len, enum DecodeTunnelProto proto);
1153 Packet *PacketDefragPktSetup(Packet *parent, const uint8_t *pkt, uint32_t len, uint8_t proto);
1154 void PacketDefragPktSetupParent(Packet *parent);
1157 Packet *PacketGetFromAlloc(void);
1160  DecodeThreadVars *dtv, Packet *p);
1161 void PacketFree(Packet *p);
1162 void PacketFreeOrRelease(Packet *p);
1163 int PacketCallocExtPkt(Packet *p, int datalen);
1164 int PacketCopyData(Packet *p, const uint8_t *pktdata, uint32_t pktlen);
1165 int PacketSetData(Packet *p, const uint8_t *pktdata, uint32_t pktlen);
1166 int PacketCopyDataOffset(Packet *p, uint32_t offset, const uint8_t *data, uint32_t datalen);
1167 const char *PktSrcToString(enum PktSrcEnum pkt_src);
1168 void PacketBypassCallback(Packet *p);
1169 void PacketSwap(Packet *p);
1170 
1174  const DecodeThreadVars *dtv, const Packet *p);
1175 const char *PacketDropReasonToString(enum PacketDropReason r);
1176 
1177 /* decoder functions */
1178 int DecodeEthernet(ThreadVars *, DecodeThreadVars *, Packet *, const uint8_t *, uint32_t);
1179 int DecodeSll(ThreadVars *, DecodeThreadVars *, Packet *, const uint8_t *, uint32_t);
1180 int DecodeSll2(ThreadVars *, DecodeThreadVars *, Packet *, const uint8_t *, uint32_t);
1181 int DecodePPP(ThreadVars *, DecodeThreadVars *, Packet *, const uint8_t *, uint32_t);
1182 int DecodePPPOESession(ThreadVars *, DecodeThreadVars *, Packet *, const uint8_t *, uint32_t);
1183 int DecodePPPOEDiscovery(ThreadVars *, DecodeThreadVars *, Packet *, const uint8_t *, uint32_t);
1184 int DecodeNull(ThreadVars *, DecodeThreadVars *, Packet *, const uint8_t *, uint32_t);
1185 int DecodeRaw(ThreadVars *, DecodeThreadVars *, Packet *, const uint8_t *, uint32_t);
1186 int DecodeIPV4(ThreadVars *, DecodeThreadVars *, Packet *, const uint8_t *, uint16_t);
1187 int DecodeIPV6(ThreadVars *, DecodeThreadVars *, Packet *, const uint8_t *, uint16_t);
1188 int DecodeICMPV4(ThreadVars *, DecodeThreadVars *, Packet *, const uint8_t *, uint32_t);
1189 int DecodeICMPV6(ThreadVars *, DecodeThreadVars *, Packet *, const uint8_t *, uint32_t);
1190 int DecodeTCP(ThreadVars *, DecodeThreadVars *, Packet *, const uint8_t *, uint16_t);
1191 int DecodeUDP(ThreadVars *, DecodeThreadVars *, Packet *, const uint8_t *, uint16_t);
1192 int DecodeSCTP(ThreadVars *, DecodeThreadVars *, Packet *, const uint8_t *, uint16_t);
1193 int DecodeESP(ThreadVars *, DecodeThreadVars *, Packet *, const uint8_t *, uint16_t);
1194 int DecodeGRE(ThreadVars *, DecodeThreadVars *, Packet *, const uint8_t *, uint32_t);
1195 int DecodeVLAN(ThreadVars *, DecodeThreadVars *, Packet *, const uint8_t *, uint32_t);
1196 int DecodeVNTag(ThreadVars *, DecodeThreadVars *, Packet *, const uint8_t *, uint32_t);
1197 int DecodeETag(ThreadVars *, DecodeThreadVars *, Packet *, const uint8_t *, uint32_t);
1198 int DecodeIEEE8021ah(ThreadVars *, DecodeThreadVars *, Packet *, const uint8_t *, uint32_t);
1199 int DecodeGeneve(ThreadVars *, DecodeThreadVars *, Packet *, const uint8_t *, uint32_t);
1200 int DecodeVXLAN(ThreadVars *, DecodeThreadVars *, Packet *, const uint8_t *, uint32_t);
1201 int DecodeMPLS(ThreadVars *, DecodeThreadVars *, Packet *, const uint8_t *, uint32_t);
1202 int DecodeERSPAN(ThreadVars *, DecodeThreadVars *, Packet *, const uint8_t *, uint32_t);
1203 int DecodeERSPANTypeI(ThreadVars *, DecodeThreadVars *, Packet *, const uint8_t *, uint32_t);
1204 int DecodeCHDLC(ThreadVars *, DecodeThreadVars *, Packet *, const uint8_t *, uint32_t);
1205 int DecodeTEMPLATE(ThreadVars *, DecodeThreadVars *, Packet *, const uint8_t *, uint32_t);
1206 int DecodeNSH(ThreadVars *, DecodeThreadVars *, Packet *, const uint8_t *, uint32_t);
1207 int DecodeARP(ThreadVars *, DecodeThreadVars *, Packet *, const uint8_t *, uint32_t);
1208 int DecodeIGMP(ThreadVars *, DecodeThreadVars *, Packet *, const uint8_t *, uint32_t);
1209 
1210 #ifdef UNITTESTS
1211 void DecodeIPV6FragHeader(Packet *p, const uint8_t *pkt,
1212  uint16_t hdrextlen, uint16_t plen,
1213  uint16_t prev_hdrextlen);
1214 #endif
1215 
1216 void AddressDebugPrint(Address *);
1217 
1219  const uint8_t *pkt, uint32_t len);
1220 void DecodeGlobalConfig(void);
1221 void PacketAlertGetMaxConfig(void);
1222 void DecodeUnregisterCounters(void);
1223 
1224 #define ENGINE_SET_EVENT(p, e) do { \
1225  SCLogDebug("p %p event %d", (p), e); \
1226  if ((p)->events.cnt < PACKET_ENGINE_EVENT_MAX) { \
1227  (p)->events.events[(p)->events.cnt] = e; \
1228  (p)->events.cnt++; \
1229  } \
1230 } while(0)
1231 
1232 #define ENGINE_SET_INVALID_EVENT(p, e) do { \
1233  p->flags |= PKT_IS_INVALID; \
1234  ENGINE_SET_EVENT(p, e); \
1235 } while(0)
1236 
1237 #define ENGINE_ISSET_EVENT(p, e) ({ \
1238  int r = 0; \
1239  uint8_t u; \
1240  for (u = 0; u < (p)->events.cnt; u++) { \
1241  if ((p)->events.events[u] == (e)) { \
1242  r = 1; \
1243  break; \
1244  } \
1245  } \
1246  r; \
1247 })
1248 
1249 #ifndef IPPROTO_IPIP
1250 #define IPPROTO_IPIP 4
1251 #endif
1252 
1253 /* older libcs don't contain a def for IPPROTO_DCCP
1254  * inside of <netinet/in.h>
1255  * if it isn't defined let's define it here.
1256  */
1257 #ifndef IPPROTO_DCCP
1258 #define IPPROTO_DCCP 33
1259 #endif
1260 
1261 /* older libcs don't contain a def for IPPROTO_SCTP
1262  * inside of <netinet/in.h>
1263  * if it isn't defined let's define it here.
1264  */
1265 #ifndef IPPROTO_SCTP
1266 #define IPPROTO_SCTP 132
1267 #endif
1268 
1269 #ifndef IPPROTO_MH
1270 #define IPPROTO_MH 135
1271 #endif
1272 
1273 /* Host Identity Protocol (rfc 5201) */
1274 #ifndef IPPROTO_HIP
1275 #define IPPROTO_HIP 139
1276 #endif
1277 
1278 #ifndef IPPROTO_SHIM6
1279 #define IPPROTO_SHIM6 140
1280 #endif
1281 
1282 /* Packet Flags */
1283 
1284 /** Flag to indicate that packet header or contents should not be inspected */
1285 #define PKT_NOPACKET_INSPECTION BIT_U32(0)
1286 /** Packet has a PPP_VJ_UCOMP header */
1287 #define PKT_PPP_VJ_UCOMP BIT_U32(1)
1289 /** Flag to indicate that packet contents should not be inspected */
1290 #define PKT_NOPAYLOAD_INSPECTION BIT_U32(2)
1292 /** set if PacketAlerts may contain json context data */
1293 #define PKT_ALERT_CTX_USED BIT_U32(3)
1295 /** Packet has matched a tag */
1296 #define PKT_HAS_TAG BIT_U32(4)
1297 /** Packet payload was added to reassembled stream */
1298 #define PKT_STREAM_ADD BIT_U32(5)
1299 /** Packet is part of established stream */
1300 #define PKT_STREAM_EST BIT_U32(6)
1302 // vacancy
1303 
1304 #define PKT_HAS_FLOW BIT_U32(8)
1305 /** Pseudo packet to end the stream */
1306 #define PKT_PSEUDO_STREAM_END BIT_U32(9)
1307 /** Packet is modified by the stream engine, we need to recalc the csum and \
1308  reinject/replace */
1309 #define PKT_STREAM_MODIFIED BIT_U32(10)
1311 // vacancy
1312 
1313 /** Exclude packet from pcap logging as it's part of a stream that has reassembly \
1314  depth reached. */
1315 #define PKT_STREAM_NOPCAPLOG BIT_U32(12)
1317 // vacancy 2x
1318 
1319 /** Packet checksum is not computed (TX packet for example) */
1320 #define PKT_IGNORE_CHECKSUM BIT_U32(15)
1321 /** Packet comes from zero copy (ext_pkt must not be freed) */
1322 #define PKT_ZERO_COPY BIT_U32(16)
1324 #define PKT_HOST_SRC_LOOKED_UP BIT_U32(17)
1325 #define PKT_HOST_DST_LOOKED_UP BIT_U32(18)
1327 /** Packet is a fragment */
1328 #define PKT_IS_FRAGMENT BIT_U32(19)
1329 #define PKT_IS_INVALID BIT_U32(20)
1330 #define PKT_PROFILE BIT_U32(21)
1332 /** indication by decoder that it feels the packet should be handled by
1333  * flow engine: Packet::flow_hash will be set */
1334 #define PKT_WANTS_FLOW BIT_U32(22)
1336 /** protocol detection done */
1337 #define PKT_PROTO_DETECT_TS_DONE BIT_U32(23)
1338 #define PKT_PROTO_DETECT_TC_DONE BIT_U32(24)
1340 #define PKT_REBUILT_FRAGMENT \
1341  BIT_U32(25) /**< Packet is rebuilt from \
1342  * fragments. */
1343 #define PKT_DETECT_HAS_STREAMDATA \
1344  BIT_U32(26) /**< Set by Detect() if raw stream data is available. */
1346 #define PKT_PSEUDO_DETECTLOG_FLUSH BIT_U32(27) /**< Detect/log flush for protocol upgrade */
1348 /** Packet is part of stream in known bad condition (loss, wrong thread),
1349  * so flag it for not setting stream events */
1350 #define PKT_STREAM_NO_EVENTS BIT_U32(28)
1352 /** We had no alert on flow before this packet */
1353 #define PKT_FIRST_ALERTS BIT_U32(29)
1354 #define PKT_FIRST_TAG BIT_U32(30)
1356 /** \brief return 1 if the packet is a pseudo packet */
1357 #define PKT_IS_PSEUDOPKT(p) ((p)->flags & (PKT_PSEUDO_STREAM_END | PKT_PSEUDO_DETECTLOG_FLUSH))
1359 #define PKT_SET_SRC(p, src_val) ((p)->pkt_src = src_val)
1361 #define PKT_DEFAULT_MAX_DECODED_LAYERS 16
1362 extern uint8_t decoder_max_layers;
1363 
1364 static inline bool PacketIncreaseCheckLayers(Packet *p)
1365 {
1366  p->nb_decoded_layers++;
1369  return false;
1370  }
1371  return true;
1372 }
1373 
1374 /** \brief Set the No payload inspection Flag for the packet.
1375  *
1376  * \param p Packet to set the flag in
1377  */
1378 static inline void DecodeSetNoPayloadInspectionFlag(Packet *p)
1379 {
1381 }
1382 
1383 /** \brief Set the No packet inspection Flag for the packet.
1384  *
1385  * \param p Packet to set the flag in
1386  */
1387 static inline void DecodeSetNoPacketInspectionFlag(Packet *p)
1388 {
1390 }
1391 
1392 static inline bool PacketIsTunnelRoot(const Packet *p)
1393 {
1394  return (p->ttype == PacketTunnelRoot);
1395 }
1396 
1397 static inline bool PacketIsTunnelChild(const Packet *p)
1398 {
1399  return (p->ttype == PacketTunnelChild);
1400 }
1401 
1402 static inline bool PacketIsTunnel(const Packet *p)
1403 {
1404  return (p->ttype != PacketTunnelNone);
1405 }
1406 
1407 static inline bool PacketIsNotTunnel(const Packet *p)
1408 {
1409  return (p->ttype == PacketTunnelNone);
1410 }
1411 
1412 static inline bool VerdictTunnelPacketInternal(const Packet *p)
1413 {
1414  const uint16_t outstanding = TUNNEL_PKT_TPR(p) - TUNNEL_PKT_RTV(p);
1415  SCLogDebug("tunnel: outstanding %u", outstanding);
1416 
1417  /* if there are packets outstanding, we won't verdict this one */
1418  if (PacketIsTunnelRoot(p) && !PacketTunnelIsVerdicted(p) && !outstanding) {
1419  SCLogDebug("root %p: verdict", p);
1420  return true;
1421 
1422  } else if (PacketIsTunnelChild(p) && outstanding == 1 && p->root &&
1423  PacketTunnelIsVerdicted(p->root)) {
1424  SCLogDebug("tunnel %p: verdict", p);
1425  return true;
1426 
1427  } else {
1428  return false;
1429  }
1430 }
1431 
1432 /** \brief return true if *this* packet needs to trigger a verdict.
1433  *
1434  * If we have the root packet, and we have none outstanding,
1435  * we can verdict now.
1436  *
1437  * If we have a upper layer packet, it's the only one and root
1438  * is already processed, we can verdict now.
1439  *
1440  * Otherwise, a future packet will issue the verdict.
1441  */
1442 static inline bool VerdictTunnelPacket(Packet *p)
1443 {
1444  bool verdict;
1446  SCSpinLock(lock);
1447  verdict = VerdictTunnelPacketInternal(p);
1448  SCSpinUnlock(lock);
1449  return verdict;
1450 }
1451 
1452 static inline void DecodeLinkLayer(ThreadVars *tv, DecodeThreadVars *dtv,
1453  const int datalink, Packet *p, const uint8_t *data, const uint32_t len)
1454 {
1455  /* call the decoder */
1456  switch (datalink) {
1457  case LINKTYPE_ETHERNET:
1458  DecodeEthernet(tv, dtv, p, data, len);
1459  break;
1460  case LINKTYPE_LINUX_SLL:
1461  DecodeSll(tv, dtv, p, data, len);
1462  break;
1463  case LINKTYPE_LINUX_SLL2:
1464  DecodeSll2(tv, dtv, p, data, len);
1465  break;
1466  case LINKTYPE_PPP:
1467  DecodePPP(tv, dtv, p, data, len);
1468  break;
1469  case LINKTYPE_RAW:
1470  case LINKTYPE_GRE_OVER_IP:
1471  DecodeRaw(tv, dtv, p, data, len);
1472  break;
1473  case LINKTYPE_NULL:
1474  DecodeNull(tv, dtv, p, data, len);
1475  break;
1476  case LINKTYPE_CISCO_HDLC:
1477  DecodeCHDLC(tv, dtv, p, data, len);
1478  break;
1479  default:
1480  SCLogError("datalink type "
1481  "%" PRId32 " not yet supported",
1482  datalink);
1483  break;
1484  }
1485 }
1486 
1487 /** \brief decode network layer
1488  * \retval bool true if successful, false if unknown */
1489 static inline bool DecodeNetworkLayer(ThreadVars *tv, DecodeThreadVars *dtv,
1490  const uint16_t proto, Packet *p, const uint8_t *data, const uint32_t len)
1491 {
1492  switch (proto) {
1493  case ETHERNET_TYPE_IP: {
1494  uint16_t ip_len = (len < USHRT_MAX) ? (uint16_t)len : (uint16_t)USHRT_MAX;
1495  DecodeIPV4(tv, dtv, p, data, ip_len);
1496  break;
1497  }
1498  case ETHERNET_TYPE_IPV6: {
1499  uint16_t ip_len = (len < USHRT_MAX) ? (uint16_t)len : (uint16_t)USHRT_MAX;
1500  DecodeIPV6(tv, dtv, p, data, ip_len);
1501  break;
1502  }
1504  DecodePPPOESession(tv, dtv, p, data, len);
1505  break;
1507  DecodePPPOEDiscovery(tv, dtv, p, data, len);
1508  break;
1509  case ETHERNET_TYPE_VLAN:
1510  case ETHERNET_TYPE_8021AD:
1512  if (p->vlan_idx > VLAN_MAX_LAYER_IDX) {
1514  } else {
1515  DecodeVLAN(tv, dtv, p, data, len);
1516  }
1517  break;
1518  case ETHERNET_TYPE_8021AH:
1519  DecodeIEEE8021ah(tv, dtv, p, data, len);
1520  break;
1521  case ETHERNET_TYPE_ARP:
1522  DecodeARP(tv, dtv, p, data, len);
1523  break;
1526  DecodeMPLS(tv, dtv, p, data, len);
1527  break;
1528  case ETHERNET_TYPE_DCE:
1531  } else {
1532  // DCE layer is ethernet + 2 bytes, followed by another ethernet
1533  DecodeEthernet(tv, dtv, p, data + 2, len - 2);
1534  }
1535  break;
1536  case ETHERNET_TYPE_ETAG:
1537  DecodeETag(tv, dtv, p, data, len);
1538  break;
1539  case ETHERNET_TYPE_VNTAG:
1540  DecodeVNTag(tv, dtv, p, data, len);
1541  break;
1542  case ETHERNET_TYPE_NSH:
1543  DecodeNSH(tv, dtv, p, data, len);
1544  break;
1545  default:
1546  SCLogDebug("unknown ether type: %" PRIx16 "", proto);
1549  return false;
1550  }
1551  return true;
1552 }
1553 
1554 uint64_t PcapPacketCntGet(const Packet *p);
1555 void PcapPacketCntSet(Packet *p, uint64_t pcap_cnt);
1556 
1557 #endif /* SURICATA_DECODE_H */
PacketL4::csum_set
bool csum_set
Definition: decode.h:477
PACKET_L4_GRE
@ PACKET_L4_GRE
Definition: decode.h:471
suricata-plugin.h
ENGINE_SET_EVENT
#define ENGINE_SET_EVENT(p, e)
Definition: decode.h:1224
PKT_DROP_REASON_DEFRAG_MEMCAP
@ PKT_DROP_REASON_DEFRAG_MEMCAP
Definition: decode.h:386
DecodeThreadVars_::counter_flow_icmp6
StatsCounterId counter_flow_icmp6
Definition: decode.h:1071
PKT_DROP_REASON_DEFRAG_ERROR
@ PKT_DROP_REASON_DEFRAG_ERROR
Definition: decode.h:385
decode-ethernet.h
decode-tcp.h
Packet_::proto
uint8_t proto
Definition: decode.h:536
spin_lock_cnt
thread_local uint64_t spin_lock_cnt
PKT_DROP_REASON_RULES_THRESHOLD
@ PKT_DROP_REASON_RULES_THRESHOLD
Definition: decode.h:393
DecodeIPV6
int DecodeIPV6(ThreadVars *, DecodeThreadVars *, Packet *, const uint8_t *, uint16_t)
Definition: decode-ipv6.c:549
DecodeERSPAN
int DecodeERSPAN(ThreadVars *, DecodeThreadVars *, Packet *, const uint8_t *, uint32_t)
ERSPAN Type II.
Definition: decode-erspan.c:76
DecodeGeneve
int DecodeGeneve(ThreadVars *, DecodeThreadVars *, Packet *, const uint8_t *, uint32_t)
Definition: decode-geneve.c:185
source-nflog.h
decode-mpls.h
len
uint8_t len
Definition: app-layer-dnp3.h:2
PacketAlerts_::firewall_discarded
uint16_t firewall_discarded
Definition: decode.h:290
DecodeThreadVars_::counter_icmpv4
StatsCounterId counter_icmpv4
Definition: decode.h:1017
DecodeThreadVars_::counter_defrag_ipv6_fragments
StatsCounterId counter_defrag_ipv6_fragments
Definition: decode.h:1053
DecodeThreadVars_::counter_esp
StatsCounterId counter_esp
Definition: decode.h:1028
DECODE_TUNNEL_IPV6
@ DECODE_TUNNEL_IPV6
Definition: decode.h:1143
source-pcap.h
DecodeThreadVars_::counter_ethertype_unknown
StatsCounterId counter_ethertype_unknown
Definition: decode.h:1021
PktProfilingData_::ticks_end
uint64_t ticks_end
Definition: decode.h:348
PacketAlert_::s
const struct Signature_ * s
Definition: decode.h:253
IPV4Vars_
Definition: decode-ipv4.h:130
CHECKSUM_VALIDATION_OFFLOAD
@ CHECKSUM_VALIDATION_OFFLOAD
Definition: decode.h:48
offset
uint64_t offset
Definition: util-streaming-buffer.h:0
PKT_DROP_REASON_FW_FLOW_DROP
@ PKT_DROP_REASON_FW_FLOW_DROP
Definition: decode.h:411
DecodeThreadVars_::counter_ipv6
StatsCounterId counter_ipv6
Definition: decode.h:1010
Packet_::code
uint8_t code
Definition: decode.h:525
DecodeThreadVars_::counter_raw
StatsCounterId counter_raw
Definition: decode.h:1025
PacketFreeOrRelease
void PacketFreeOrRelease(Packet *p)
Return a packet to where it was allocated.
Definition: decode.c:282
IPV4_GET_RAW_IPPROTO
#define IPV4_GET_RAW_IPPROTO(ip4h)
Definition: decode-ipv4.h:103
DecodeThreadVars_::counter_vlan_qinqinq
StatsCounterId counter_vlan_qinqinq
Definition: decode.h:1034
PacketL4Types
PacketL4Types
Definition: decode.h:463
PLUGIN_VAR_SIZE
#define PLUGIN_VAR_SIZE
Definition: suricata-plugin.h:31
DecodeThreadVars_::counter_flow_get_used_eval_busy
StatsCounterId counter_flow_get_used_eval_busy
Definition: decode.h:1079
PacketCopyData
int PacketCopyData(Packet *p, const uint8_t *pktdata, uint32_t pktlen)
Copy data to Packet payload and set packet length.
Definition: decode.c:383
PacketBypassCallback
void PacketBypassCallback(Packet *p)
Definition: decode.c:536
DecodeSCTP
int DecodeSCTP(ThreadVars *, DecodeThreadVars *, Packet *, const uint8_t *, uint16_t)
Definition: decode-sctp.c:62
ICMPV4Vars_
Definition: decode-icmpv4.h:183
PktProfiling_
Per pkt stats storage.
Definition: decode.h:368
Address_::address_un_data16
uint16_t address_un_data16[8]
Definition: decode.h:117
GENERIC_TOO_MANY_LAYERS
@ GENERIC_TOO_MANY_LAYERS
Definition: decode-events.h:238
Packet_::icmp_d
struct Packet_::@34::@40 icmp_d
DecodePPP
int DecodePPP(ThreadVars *, DecodeThreadVars *, Packet *, const uint8_t *, uint32_t)
Definition: decode-ppp.c:177
DecodeARP
int DecodeARP(ThreadVars *, DecodeThreadVars *, Packet *, const uint8_t *, uint32_t)
Definition: decode-arp.c:29
Address_::address_un_in6
struct in6_addr address_un_in6
Definition: decode.h:119
unlikely
#define unlikely(expr)
Definition: util-optimize.h:35
PacketL3
Definition: decode.h:443
PKT_DROP_REASON_STREAM_MEMCAP
@ PKT_DROP_REASON_STREAM_MEMCAP
Definition: decode.h:395
PacketL3::vars
union PacketL3::@30 vars
PktProfilingTmmData_
Per TMM stats storage.
Definition: decode.h:327
IPV6ExtHdrs_
Definition: decode-ipv6.h:150
PktPool_
Definition: tmqh-packetpool.h:43
Packet_::host_src
struct Host_ * host_src
Definition: decode.h:637
PKT_DROP_REASON_FW_RULES
@ PKT_DROP_REASON_FW_RULES
Definition: decode.h:406
PKT_DROP_REASON_FLOW_MEMCAP
@ PKT_DROP_REASON_FLOW_MEMCAP
Definition: decode.h:387
PACKET_L2_ETHERNET
@ PACKET_L2_ETHERNET
Definition: decode.h:426
CaptureStatsSetup
void CaptureStatsSetup(ThreadVars *tv)
Definition: decode.c:1113
PacketDropReasonToString
const char * PacketDropReasonToString(enum PacketDropReason r)
Definition: decode.c:924
PacketEngineEvents_::events
uint8_t events[PACKET_ENGINE_EVENT_MAX]
Definition: decode.h:310
DECODE_TUNNEL_IPV6_TEREDO
@ DECODE_TUNNEL_IPV6_TEREDO
Definition: decode.h:1144
PcapPacketCntGet
uint64_t PcapPacketCntGet(const Packet *p)
Definition: decode.c:1175
PacketL4::csum
uint16_t csum
Definition: decode.h:478
SCLogDebug
#define SCLogDebug(...)
Definition: util-debug.h:282
PACKET_L4_UNKNOWN
@ PACKET_L4_UNKNOWN
Definition: decode.h:464
PKT_SRC_SHUTDOWN_FLUSH
@ PKT_SRC_SHUTDOWN_FLUSH
Definition: decode.h:64
DecodeEthernet
int DecodeEthernet(ThreadVars *, DecodeThreadVars *, Packet *, const uint8_t *, uint32_t)
Definition: decode-ethernet.c:42
rwr_lock_cnt
thread_local uint64_t rwr_lock_cnt
DecodeThreadVars_::counter_defrag_no_frags
StatsCounterId counter_defrag_no_frags
Definition: decode.h:1056
PktProfiling_::ticks_end
uint64_t ticks_end
Definition: decode.h:370
TCPVars_
Definition: decode-tcp.h:162
AddressDebugPrint
void AddressDebugPrint(Address *)
Debug print function for printing addresses.
Definition: decode.c:808
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:479
DecodeThreadVars_::counter_vxlan
StatsCounterId counter_vxlan
Definition: decode.h:1035
DecodeThreadVars_::counter_flow_spare_sync_empty
StatsCounterId counter_flow_spare_sync_empty
Definition: decode.h:1083
PacketQueue_
simple fifo queue for packets with mutex and cond Calling the mutex or triggering the cond is respons...
Definition: packet-queue.h:49
DecodeThreadVars_::counter_nsh
StatsCounterId counter_nsh
Definition: decode.h:1048
Packet_::livedev_dst_id
uint16_t livedev_dst_id
Definition: decode.h:633
DecodeThreadVars_::counter_gre
StatsCounterId counter_gre
Definition: decode.h:1031
Packet_::payload
uint8_t * payload
Definition: decode.h:618
PacketAlerts_::cnt
uint16_t cnt
Definition: decode.h:288
DecodeThreadVars_::counter_flow_get_used_failed
StatsCounterId counter_flow_get_used_failed
Definition: decode.h:1080
ETHERNET_TYPE_IPV6
#define ETHERNET_TYPE_IPV6
Definition: decode-ethernet.h:39
PKT_SRC_CAPTURE_TIMEOUT
@ PKT_SRC_CAPTURE_TIMEOUT
Definition: decode.h:62
DecodeUDP
int DecodeUDP(ThreadVars *, DecodeThreadVars *, Packet *, const uint8_t *, uint16_t)
Definition: decode-udp.c:75
Packet_::flags
uint32_t flags
Definition: decode.h:560
decode-udp.h
ETHERNET_TYPE_ETAG
#define ETHERNET_TYPE_ETAG
Definition: decode-ethernet.h:50
Packet_::action
uint8_t action
Definition: decode.h:622
PacketAlertCreate
PacketAlert * PacketAlertCreate(void)
Initialize PacketAlerts with dynamic alerts array size.
Definition: decode.c:144
PktProfilingDetectData
struct PktProfilingDetectData_ PktProfilingDetectData
PacketL4::L4Hdrs::udph
UDPHdr * udph
Definition: decode.h:481
Packet_::vlan_idx
uint8_t vlan_idx
Definition: decode.h:542
Flow_
Flow data structure.
Definition: flow.h:354
Packet_::tunnel_verdicted
bool tunnel_verdicted
Definition: decode.h:661
ETHERNET_UNKNOWN_ETHERTYPE
@ ETHERNET_UNKNOWN_ETHERTYPE
Definition: decode-events.h:120
PacketL4::L4Hdrs::greh
GREHdr * greh
Definition: decode.h:485
PROF_DETECT_SIZE
@ PROF_DETECT_SIZE
Definition: suricata-common.h:481
PktVar_::next
struct PktVar_ * next
Definition: decode.h:315
DecoderFunc
int(* DecoderFunc)(ThreadVars *tv, DecodeThreadVars *dtv, Packet *p, const uint8_t *pkt, uint32_t len)
Definition: decode.h:1218
PktProfilingTmmData_::ticks_end
uint64_t ticks_end
Definition: decode.h:329
Packet_::ipfw_v
IPFWPacketVars ipfw_v
Definition: decode.h:579
Packet_::pool
struct PktPool_ * pool
Definition: decode.h:681
CHECKSUM_VALIDATION_RXONLY
@ CHECKSUM_VALIDATION_RXONLY
Definition: decode.h:46
PktProfiling_::app
PktProfilingAppData app[]
Definition: decode.h:377
PACKET_L3_IPV4
@ PACKET_L3_IPV4
Definition: decode.h:438
PKT_DROP_REASON_MAX
@ PKT_DROP_REASON_MAX
Definition: decode.h:412
PKT_DROP_REASON_STREAM_REASSEMBLY
@ PKT_DROP_REASON_STREAM_REASSEMBLY
Definition: decode.h:397
DECODE_TUNNEL_ERSPANI
@ DECODE_TUNNEL_ERSPANI
Definition: decode.h:1139
PcapPacketCntSet
void PcapPacketCntSet(Packet *p, uint64_t pcap_cnt)
Definition: decode.c:1183
PacketAlerts_::alerts
PacketAlert * alerts
Definition: decode.h:292
DecodeThreadVars_::counter_bytes
StatsCounterId counter_bytes
Definition: decode.h:999
PktProfilingTmmData
struct PktProfilingTmmData_ PktProfilingTmmData
Per TMM stats storage.
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
DecodeVXLAN
int DecodeVXLAN(ThreadVars *, DecodeThreadVars *, Packet *, const uint8_t *, uint32_t)
Definition: decode-vxlan.c:144
util-exception-policy-types.h
PacketL3::hdrs
union PacketL3::Hdrs hdrs
DecodeThreadVars_::counter_flow_get_used
StatsCounterId counter_flow_get_used
Definition: decode.h:1076
DecodeThreadVars_::counter_avg_pkt_size
StatsCounterDeriveId counter_avg_pkt_size
Definition: decode.h:1000
DecodeThreadVars_::counter_pppoe
StatsCounterId counter_pppoe
Definition: decode.h:1039
DecodeThreadVars
struct DecodeThreadVars_ DecodeThreadVars
Structure to hold thread specific data for all decode modules.
PacketL2::type
enum PacketL2Types type
Definition: decode.h:430
Packet_::sig_mask
SignatureMask sig_mask
Definition: decode.h:551
DecodeThreadVars_::counter_tcp_syn
StatsCounterId counter_tcp_syn
Definition: decode.h:1012
IPV6_GET_L4PROTO
#define IPV6_GET_L4PROTO(p)
Definition: decode-ipv6.h:75
SCSpinLock
#define SCSpinLock
Definition: threads-debug.h:236
VLAN_HEADER_TOO_MANY_LAYERS
@ VLAN_HEADER_TOO_MANY_LAYERS
Definition: decode-events.h:155
PacketAlerts_::drop
PacketAlert drop
Definition: decode.h:295
DecodeVNTag
int DecodeVNTag(ThreadVars *, DecodeThreadVars *, Packet *, const uint8_t *, uint32_t)
Definition: decode-vntag.c:52
Address_
Definition: decode.h:113
PacketL3::Hdrs
Definition: decode.h:448
CHECKSUM_VALIDATION_DISABLE
@ CHECKSUM_VALIDATION_DISABLE
Definition: decode.h:43
DecodeThreadVars_::counter_icmpv6
StatsCounterId counter_icmpv6
Definition: decode.h:1018
PacketL3::Hdrs::arph
ARPHdr * arph
Definition: decode.h:451
CHECKSUM_VALIDATION_KERNEL
@ CHECKSUM_VALIDATION_KERNEL
Definition: decode.h:47
StatsCounterId
Definition: counters.h:30
PacketDecodeFinalize
void PacketDecodeFinalize(ThreadVars *tv, DecodeThreadVars *dtv, Packet *p)
Finalize decoding of a packet.
Definition: decode.c:238
Address_::address_un_data32
uint32_t address_un_data32[4]
Definition: decode.h:116
PacketL4::L4Hdrs::igmph
IGMPHdr * igmph
Definition: decode.h:487
proto
uint8_t proto
Definition: decode-template.h:0
DecodeThreadVars_::counter_invalid
StatsCounterId counter_invalid
Definition: decode.h:1005
PKT_NOPAYLOAD_INSPECTION
#define PKT_NOPAYLOAD_INSPECTION
Definition: decode.h:1290
PacketAlertGetMaxConfig
void PacketAlertGetMaxConfig(void)
Definition: decode.c:1156
DecodeICMPV6
int DecodeICMPV6(ThreadVars *, DecodeThreadVars *, Packet *, const uint8_t *, uint32_t)
Decode ICMPV6 packets and fill the Packet with the decoded info.
Definition: decode-icmpv6.c:177
PktProfilingDetectData_::ticks_end
uint64_t ticks_end
Definition: decode.h:353
decoder_max_layers
uint8_t decoder_max_layers
Definition: decode.c:81
PacketAlert
struct PacketAlert_ PacketAlert
Packet_::host_dst
struct Host_ * host_dst
Definition: decode.h:638
PktProfilingLoggerData
struct PktProfilingLoggerData_ PktProfilingLoggerData
Packet_::flowflags
uint8_t flowflags
Definition: decode.h:545
PacketL3::Hdrs::ip4h
IPV4Hdr * ip4h
Definition: decode.h:449
Packet_::BypassPacketsFlow
int(* BypassPacketsFlow)(struct Packet_ *)
Definition: decode.h:607
DecodeThreadVars_::counter_flow_spare_sync
StatsCounterId counter_flow_spare_sync
Definition: decode.h:1082
DecodeThreadVars_::counter_defrag_ipv4_reassembled
StatsCounterId counter_defrag_ipv4_reassembled
Definition: decode.h:1052
PacketDropReason
PacketDropReason
Definition: decode.h:382
PktProfiling_::ticks_start
uint64_t ticks_start
Definition: decode.h:369
DecodeUnregisterCounters
void DecodeUnregisterCounters(void)
Definition: decode.c:608
rww_lock_contention
thread_local uint64_t rww_lock_contention
DecodeThreadVars_::counter_chdlc
StatsCounterId counter_chdlc
Definition: decode.h:1008
DecodeThreadVars_::counter_sctp
StatsCounterId counter_sctp
Definition: decode.h:1027
PACKET_L2_UNKNOWN
@ PACKET_L2_UNKNOWN
Definition: decode.h:425
Packet_::payload_len
uint16_t payload_len
Definition: decode.h:619
Packet_::alerts
PacketAlerts alerts
Definition: decode.h:635
Packet_::tunnel_tpr_cnt
uint16_t tunnel_tpr_cnt
Definition: decode.h:673
PacketTunnelChild
@ PacketTunnelChild
Definition: decode.h:418
AppLayerDecoderEvents_
Data structure to store app layer decoder events.
Definition: app-layer-events.h:33
Packet_::app_layer_events
AppLayerDecoderEvents * app_layer_events
Definition: decode.h:643
Packet_::events
PacketEngineEvents events
Definition: decode.h:641
PacketAlertFree
void PacketAlertFree(PacketAlert *pa)
Definition: decode.c:169
PacketL4::L4Hdrs
Definition: decode.h:479
PacketL2::L2Hdrs
Definition: decode.h:431
ETHERNET_TYPE_8021QINQ
#define ETHERNET_TYPE_8021QINQ
Definition: decode-ethernet.h:47
PacketTunnelType
PacketTunnelType
Definition: decode.h:415
DecodeThreadVars_::counter_tcp
StatsCounterId counter_tcp
Definition: decode.h:1011
PktProfilingAppData_::ticks_spent
uint64_t ticks_spent
Definition: decode.h:358
ICMPV4Vars_::emb_ip4h_offset
uint16_t emb_ip4h_offset
Definition: decode-icmpv4.h:184
DecodeRaw
int DecodeRaw(ThreadVars *, DecodeThreadVars *, Packet *, const uint8_t *, uint32_t)
Definition: decode-raw.c:42
DCE_PKT_TOO_SMALL
@ DCE_PKT_TOO_SMALL
Definition: decode-events.h:219
PacketAlert_::tx_id
uint64_t tx_id
Definition: decode.h:254
PKT_DROP_REASON_STREAM_URG
@ PKT_DROP_REASON_STREAM_URG
Definition: decode.h:398
rwr_lock_contention
thread_local uint64_t rwr_lock_contention
DECODE_TUNNEL_NSH
@ DECODE_TUNNEL_NSH
Definition: decode.h:1146
PacketAlert_::action
uint8_t action
Definition: decode.h:251
DecodeThreadVars_::counter_defrag_tracker_hard_reuse
StatsCounterId counter_defrag_tracker_hard_reuse
Definition: decode.h:1058
PacketL2Types
PacketL2Types
Definition: decode.h:424
PacketL3::Hdrs::ip6h
IPV6Hdr * ip6h
Definition: decode.h:450
Packet_::icmp_s
struct Packet_::@32::@39 icmp_s
Packet_::datalink
int datalink
Definition: decode.h:650
Packet_::profile
PktProfiling * profile
Definition: decode.h:684
Address_::address
union Address_::@29 address
PACKET_L3_UNKNOWN
@ PACKET_L3_UNKNOWN
Definition: decode.h:437
spin_lock_wait_ticks
thread_local uint64_t spin_lock_wait_ticks
DecodeThreadVars_::counter_flow_memcap
StatsCounterId counter_flow_memcap
Definition: decode.h:1062
CHECKSUM_VALIDATION_ENABLE
@ CHECKSUM_VALIDATION_ENABLE
Definition: decode.h:44
lock
HRLOCK_TYPE lock
Definition: host.h:0
decode-gre.h
DecodeThreadVars_::counter_defrag_max_hit
StatsCounterId counter_defrag_max_hit
Definition: decode.h:1055
DecodeRegisterPerfCounters
void DecodeRegisterPerfCounters(DecodeThreadVars *, ThreadVars *)
Definition: decode.c:634
DECODE_TUNNEL_ERSPANII
@ DECODE_TUNNEL_ERSPANII
Definition: decode.h:1138
DecodeThreadVars_::counter_flow_elephant
StatsCounterId counter_flow_elephant
Definition: decode.h:1073
CHECKSUM_VALIDATION_AUTO
@ CHECKSUM_VALIDATION_AUTO
Definition: decode.h:45
IGMPVars_
Definition: decode-igmp.h:32
Packet_::pktlen
uint32_t pktlen
Definition: decode.h:627
decode-ipv6.h
PACKET_L4_TCP
@ PACKET_L4_TCP
Definition: decode.h:465
PacketAlert_::json_info
struct PacketContextData * json_info
Definition: decode.h:256
PACKET_L4_SCTP
@ PACKET_L4_SCTP
Definition: decode.h:470
TUNNEL_PKT_TPR
#define TUNNEL_PKT_TPR(p)
Definition: decode.h:1125
util-debug.h
PKT_SRC_WIRE
@ PKT_SRC_WIRE
Definition: decode.h:52
source-nfq.h
Packet_::pktvar
PktVar * pktvar
Definition: decode.h:610
ExceptionPolicyCounters_
Definition: util-exception-policy-types.h:54
DPDKPacketVars_
per packet DPDK vars
Definition: source-dpdk.h:95
DecodeThreadVars_::counter_udp
StatsCounterId counter_udp
Definition: decode.h:1016
ETHERNET_TYPE_8021AD
#define ETHERNET_TYPE_8021AD
Definition: decode-ethernet.h:43
PacketL4::L4Vars::icmpv4
ICMPV4Vars icmpv4
Definition: decode.h:491
Packet_::tunnel_lock
SCSpinlock tunnel_lock
Definition: decode.h:694
StatsCounterMaxId
Definition: counters.h:38
Packet_::ts
SCTime_t ts
Definition: decode.h:568
PKT_DROP_REASON_APPLAYER_ERROR
@ PKT_DROP_REASON_APPLAYER_ERROR
Definition: decode.h:390
PacketSwap
void PacketSwap(Packet *p)
switch direction of a packet
Definition: decode.c:583
DecodeMPLS
int DecodeMPLS(ThreadVars *, DecodeThreadVars *, Packet *, const uint8_t *, uint32_t)
Definition: decode-mpls.c:49
AppLayerThreadCtx_
This is for the app layer in general and it contains per thread context relevant to both the alpd and...
Definition: app-layer.c:59
PktSrcEnum
PktSrcEnum
Definition: decode.h:51
PKT_DROP_REASON_NOT_SET
@ PKT_DROP_REASON_NOT_SET
Definition: decode.h:383
flow-worker.h
PktVar_::value
uint8_t * value
Definition: decode.h:321
PktProfilingAppData
struct PktProfilingAppData_ PktProfilingAppData
PKT_DROP_REASON_FW_FLOW_PRE_HOOK
@ PKT_DROP_REASON_FW_FLOW_PRE_HOOK
Definition: decode.h:410
DecodeTunnelProto
DecodeTunnelProto
Definition: decode.h:1136
Packet_::prev
struct Packet_ * prev
Definition: decode.h:647
Packet
struct Packet_ Packet
decode-ppp.h
Packet_::pcap_v
PcapPacketVars pcap_v
Definition: decode.h:600
CaptureStatsUpdate
void CaptureStatsUpdate(ThreadVars *tv, const Packet *p)
Definition: decode.c:1061
PKT_SRC_DECODER_TEREDO
@ PKT_SRC_DECODER_TEREDO
Definition: decode.h:56
DecodeTEMPLATE
int DecodeTEMPLATE(ThreadVars *, DecodeThreadVars *, Packet *, const uint8_t *, uint32_t)
Function to decode TEMPLATE packets.
Definition: decode-template.c:51
DecodeThreadVars_::counter_vntag
StatsCounterId counter_vntag
Definition: decode.h:1036
PacketL4::L4Hdrs::esph
ESPHdr * esph
Definition: decode.h:486
Packet_::tunnel_rtv_cnt
uint16_t tunnel_rtv_cnt
Definition: decode.h:671
DecodeVLAN
int DecodeVLAN(ThreadVars *, DecodeThreadVars *, Packet *, const uint8_t *, uint32_t)
Definition: decode-vlan.c:54
DecodeESP
int DecodeESP(ThreadVars *, DecodeThreadVars *, Packet *, const uint8_t *, uint16_t)
Function to decode IPSEC-ESP packets.
Definition: decode-esp.c:64
rww_lock_cnt
thread_local uint64_t rww_lock_cnt
DecodeNSH
int DecodeNSH(ThreadVars *, DecodeThreadVars *, Packet *, const uint8_t *, uint32_t)
Function to decode NSH packets.
Definition: decode-nsh.c:46
ThreadVars_
Per thread variable structure.
Definition: threadvars.h:58
mutex_lock_contention
thread_local uint64_t mutex_lock_contention
DecodeThreadVars_::counter_flow_active
StatsCounterId counter_flow_active
Definition: decode.h:1067
DecodeThreadVars_::counter_ipv6inipv4
StatsCounterId counter_ipv6inipv4
Definition: decode.h:1043
spin_lock_contention
thread_local uint64_t spin_lock_contention
PktProfilingData_
Definition: decode.h:346
PacketL4::L4Vars::tcp
TCPVars tcp
Definition: decode.h:490
DECODE_TUNNEL_PPP
@ DECODE_TUNNEL_PPP
Definition: decode.h:1145
Packet_::sp
Port sp
Definition: decode.h:521
PktProfiling_::logger
PktProfilingLoggerData logger[LOGGER_SIZE]
Definition: decode.h:375
PacketContextData
Definition: decode.h:242
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:225
SCSpinUnlock
#define SCSpinUnlock
Definition: threads-debug.h:238
PktSrcToString
const char * PktSrcToString(enum PktSrcEnum pkt_src)
Definition: decode.c:876
PktVar
struct PktVar_ PktVar
DecodeThreadVars_::counter_tcp_urg
StatsCounterId counter_tcp_urg
Definition: decode.h:1015
DecodeThreadVars_::counter_pkts
StatsCounterId counter_pkts
Definition: decode.h:998
DecodeThreadVars_::counter_eth
StatsCounterId counter_eth
Definition: decode.h:1007
IPV6Vars_
get the highest proto/next header field we know
Definition: decode-ipv6.h:84
PktProfilingDetectData_
Definition: decode.h:351
PktVar_::key
uint8_t * key
Definition: decode.h:320
decode-icmpv6.h
PacketL3::ip6
struct PacketL3::@30::@31 ip6
PacketAlerts_::discarded
uint16_t discarded
Definition: decode.h:289
Packet_::pkt_hooks
uint16_t pkt_hooks
Definition: decode.h:554
DecodeIGMP
int DecodeIGMP(ThreadVars *, DecodeThreadVars *, Packet *, const uint8_t *, uint32_t)
Definition: decode-igmp.c:70
DecodeSll
int DecodeSll(ThreadVars *, DecodeThreadVars *, Packet *, const uint8_t *, uint32_t)
Definition: decode-sll.c:41
PKT_DROP_REASON_RULES
@ PKT_DROP_REASON_RULES
Definition: decode.h:392
PacketL4::L4Hdrs::icmpv4h
ICMPV4Hdr * icmpv4h
Definition: decode.h:482
LOGGER_SIZE
@ LOGGER_SIZE
Definition: suricata-common.h:526
DecodeThreadVars_::counter_flow_spare_sync_avg
StatsCounterAvgId counter_flow_spare_sync_avg
Definition: decode.h:1085
PacketCallocExtPkt
int PacketCallocExtPkt(Packet *p, int datalen)
Definition: decode.c:315
SigIntId
#define SigIntId
Definition: detect-engine-state.h:38
Address
struct Address_ Address
ETHERNET_TYPE_MPLS_UNICAST
#define ETHERNET_TYPE_MPLS_UNICAST
Definition: decode-mpls.h:29
DecodeThreadVars_::counter_flow_icmp4
StatsCounterId counter_flow_icmp4
Definition: decode.h:1070
PACKET_L3_ARP
@ PACKET_L3_ARP
Definition: decode.h:440
DecodeThreadVars_::counter_ieee8021ah
StatsCounterId counter_ieee8021ah
Definition: decode.h:1038
PKT_SRC_STREAM_TCP_DETECTLOG_FLUSH
@ PKT_SRC_STREAM_TCP_DETECTLOG_FLUSH
Definition: decode.h:59
DECODE_TUNNEL_VLAN
@ DECODE_TUNNEL_VLAN
Definition: decode.h:1141
ETHERNET_TYPE_PPPOE_DISC
#define ETHERNET_TYPE_PPPOE_DISC
Definition: decode-ethernet.h:41
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:1059
PACKET_L4_UDP
@ PACKET_L4_UDP
Definition: decode.h:466
IPV6Hdr_
Definition: decode-ipv6.h:32
Packet_
Definition: decode.h:514
DECODE_TUNNEL_IPV4
@ DECODE_TUNNEL_IPV4
Definition: decode.h:1142
DecodeThreadVars_::app_tctx
AppLayerThreadCtx * app_tctx
Definition: decode.h:995
decode-icmpv4.h
ICMPV4Hdr_
Definition: decode-icmpv4.h:165
Packet_::l4
struct PacketL4 l4
Definition: decode.h:614
source-ipfw.h
Address_::address_un_data8
uint8_t address_un_data8[16]
Definition: decode.h:118
TMM_SIZE
@ TMM_SIZE
Definition: tm-threads-common.h:76
Packet_::ttype
uint8_t ttype
Definition: decode.h:557
PacketEngineEvents_
Definition: decode.h:308
source-netmap.h
PACKET_L4_ESP
@ PACKET_L4_ESP
Definition: decode.h:472
PacketL3::ip4
IPV4Vars ip4
Definition: decode.h:455
PKT_DROP_REASON_STREAM_ERROR
@ PKT_DROP_REASON_STREAM_ERROR
Definition: decode.h:394
Port
uint16_t Port
Definition: decode.h:219
SCTime_t
Definition: util-time.h:40
DecodeThreadVars_::counter_geneve
StatsCounterId counter_geneve
Definition: decode.h:1030
source-windivert.h
ETHERNET_TYPE_VNTAG
#define ETHERNET_TYPE_VNTAG
Definition: decode-ethernet.h:52
decode-igmp.h
rww_lock_wait_ticks
thread_local uint64_t rww_lock_wait_ticks
DecodeTCP
int DecodeTCP(ThreadVars *, DecodeThreadVars *, Packet *, const uint8_t *, uint16_t)
Definition: decode-tcp.c:278
DecodeThreadVars_::counter_tcp_rst
StatsCounterId counter_tcp_rst
Definition: decode.h:1014
PacketAlert_::iid
SigIntId iid
Definition: decode.h:250
ETHERNET_TYPE_NSH
#define ETHERNET_TYPE_NSH
Definition: decode-ethernet.h:51
PacketL4::L4Hdrs::sctph
SCTPHdr * sctph
Definition: decode.h:484
PacketL2::L2Hdrs::ethh
EthernetHdr * ethh
Definition: decode.h:432
DECODE_TUNNEL_VXLAN
@ DECODE_TUNNEL_VXLAN
Definition: decode.h:1140
PacketL2
Definition: decode.h:429
DECODE_TUNNEL_ETHERNET
@ DECODE_TUNNEL_ETHERNET
Definition: decode.h:1137
ETHERNET_TYPE_DCE
#define ETHERNET_TYPE_DCE
Definition: decode-ethernet.h:49
DecodeThreadVars_::counter_ipv4inipv6
StatsCounterId counter_ipv4inipv6
Definition: decode.h:1044
AFXDPPacketVars_
per packet AF_XDP vars
Definition: source-af-xdp.h:54
rwr_lock_wait_ticks
thread_local uint64_t rwr_lock_wait_ticks
PKT_DROP_REASON_EP_FLOW_DROP
@ PKT_DROP_REASON_EP_FLOW_DROP
Definition: decode.h:389
DecodeThreadVars_::counter_max_mac_addrs_dst
StatsCounterMaxId counter_max_mac_addrs_dst
Definition: decode.h:1003
PacketTunnelNone
@ PacketTunnelNone
Definition: decode.h:416
decode-events.h
PktProfilingData_::ticks_start
uint64_t ticks_start
Definition: decode.h:347
DecodeNull
int DecodeNull(ThreadVars *, DecodeThreadVars *, Packet *, const uint8_t *, uint32_t)
Definition: decode-null.c:51
dtv
DecodeThreadVars * dtv
Definition: fuzz_decodepcapfile.c:34
DecodeIPV4
int DecodeIPV4(ThreadVars *, DecodeThreadVars *, Packet *, const uint8_t *, uint16_t)
Definition: decode-ipv4.c:515
DecodeThreadVars_::counter_defrag_memcap_eps
ExceptionPolicyCounters counter_defrag_memcap_eps
Definition: decode.h:1060
PacketAlert_::frame_id
int64_t frame_id
Definition: decode.h:255
PacketL3::csum_set
bool csum_set
Definition: decode.h:446
DecodeThreadVars_::counter_max_mac_addrs_src
StatsCounterMaxId counter_max_mac_addrs_src
Definition: decode.h:1002
decode-vlan.h
IPV4Hdr_
Definition: decode-ipv4.h:72
default_packet_size
uint32_t default_packet_size
Definition: decode.c:77
Packet_::l2
struct PacketL2 l2
Definition: decode.h:612
Packet_::nb_decoded_layers
uint8_t nb_decoded_layers
Definition: decode.h:655
PacketAlert_::flags
uint8_t flags
Definition: decode.h:252
PKT_SRC_DECODER_GENEVE
@ PKT_SRC_DECODER_GENEVE
Definition: decode.h:63
PacketL3::eh
IPV6ExtHdrs eh
Definition: decode.h:458
decode-ipv4.h
PacketL3::type
enum PacketL3Types type
Definition: decode.h:444
Packet_::nfq_v
NFQPacketVars nfq_v
Definition: decode.h:576
ICMPV6Hdr_
Definition: decode-icmpv6.h:129
PktProfiling_::detect
PktProfilingDetectData detect[PROF_DETECT_SIZE]
Definition: decode.h:374
Packet_::ReleasePacket
void(* ReleasePacket)(struct Packet_ *)
Definition: decode.h:604
DecodeThreadVars_::counter_ipv4_unknown_proto
StatsCounterId counter_ipv4_unknown_proto
Definition: decode.h:1046
cnt
uint32_t cnt
Definition: tmqh-packetpool.h:7
Packet_::tenant_id
uint32_t tenant_id
Definition: decode.h:676
Packet_::flow
struct Flow_ * flow
Definition: decode.h:562
DecodeGRE
int DecodeGRE(ThreadVars *, DecodeThreadVars *, Packet *, const uint8_t *, uint32_t)
Function to decode GRE packets.
Definition: decode-gre.c:47
DecodeThreadVars_::counter_ipv4inipv4
StatsCounterId counter_ipv4inipv4
Definition: decode.h:1042
ICMPV6Vars_
Definition: decode-icmpv6.h:146
PKT_DROP_REASON_INNER_PACKET
@ PKT_DROP_REASON_INNER_PACKET
Definition: decode.h:400
PktProfiling
struct PktProfiling_ PktProfiling
Per pkt stats storage.
PacketL4::type
enum PacketL4Types type
Definition: decode.h:476
DecodeThreadVarsFree
void DecodeThreadVarsFree(ThreadVars *, DecodeThreadVars *)
Definition: decode.c:843
IPFWPacketVars_
Definition: source-ipfw.h:32
source-dpdk.h
DecodeThreadVars_::counter_sll
StatsCounterId counter_sll
Definition: decode.h:1023
PktProfilingLoggerData_::ticks_end
uint64_t ticks_end
Definition: decode.h:363
DecodeThreadVars_::counter_ppp
StatsCounterId counter_ppp
Definition: decode.h:1029
PacketL4::L4Hdrs::icmpv6h
ICMPV6Hdr * icmpv6h
Definition: decode.h:483
PKT_DROP_REASON_APPLAYER_MEMCAP
@ PKT_DROP_REASON_APPLAYER_MEMCAP
Definition: decode.h:391
DecodeGlobalConfig
void DecodeGlobalConfig(void)
Definition: decode.c:1139
ChecksumValidationMode
ChecksumValidationMode
Definition: decode.h:42
suricata-common.h
PKT_SRC_FFR
@ PKT_SRC_FFR
Definition: decode.h:58
DecodeIPV6FragHeader
void DecodeIPV6FragHeader(Packet *p, const uint8_t *pkt, uint16_t hdrextlen, uint16_t plen, uint16_t prev_hdrextlen)
Definition: decode-ipv6.c:94
ETHERNET_TYPE_8021AH
#define ETHERNET_TYPE_8021AH
Definition: decode-ethernet.h:44
DecodeThreadVars_::counter_flow_udp
StatsCounterId counter_flow_udp
Definition: decode.h:1069
decode-arp.h
NFQPacketVars_
Definition: source-nfq.h:40
DecodeThreadVars_::counter_igmp
StatsCounterId counter_igmp
Definition: decode.h:1019
PacketL4::L4Vars
Definition: decode.h:489
DecodeThreadVars_::counter_tcp_synack
StatsCounterId counter_tcp_synack
Definition: decode.h:1013
PROFILE_FLOWWORKER_SIZE
@ PROFILE_FLOWWORKER_SIZE
Definition: flow-worker.h:29
source-af-xdp.h
ETHERNET_DCE_HEADER_LEN
#define ETHERNET_DCE_HEADER_LEN
Definition: decode-ethernet.h:30
PacketL3Types
PacketL3Types
Definition: decode.h:436
Packet_::livedev_id
uint16_t livedev_id
Definition: decode.h:631
IGMPHdr_
Definition: decode-igmp.h:25
Packet_::ext_pkt
uint8_t * ext_pkt
Definition: decode.h:628
PacketAlerts
struct PacketAlerts_ PacketAlerts
DecodeICMPV4
int DecodeICMPV4(ThreadVars *, DecodeThreadVars *, Packet *, const uint8_t *, uint32_t)
Main ICMPv4 decoding function.
Definition: decode-icmpv4.c:143
Packet_::app_update_direction
uint8_t app_update_direction
Definition: decode.h:548
decode-esp.h
PKT_DROP_REASON_NFQ_ERROR
@ PKT_DROP_REASON_NFQ_ERROR
Definition: decode.h:399
DecodeThreadVars_::counter_null
StatsCounterId counter_null
Definition: decode.h:1026
PacketUpdateEngineEventCounters
void PacketUpdateEngineEventCounters(ThreadVars *tv, DecodeThreadVars *dtv, Packet *p)
Definition: decode.c:245
VLAN_MAX_LAYERS
#define VLAN_MAX_LAYERS
Definition: decode-vlan.h:51
DecodeThreadVars_::counter_flow_memcap_eps
ExceptionPolicyCounters counter_flow_memcap_eps
Definition: decode.h:1063
UDPHdr_
Definition: decode-udp.h:42
decode-sctp.h
DECODE_EVENT_MAX
@ DECODE_EVENT_MAX
Definition: decode-events.h:328
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:409
tv
ThreadVars * tv
Definition: fuzz_decodepcapfile.c:33
Packet_::persistent
struct Packet_::@38 persistent
NetmapPacketVars_
Definition: source-netmap.h:71
DecodeThreadVars_::counter_vlan_qinq
StatsCounterId counter_vlan_qinq
Definition: decode.h:1033
DecodeThreadVars_::counter_teredo
StatsCounterId counter_teredo
Definition: decode.h:1040
PACKET_L4_ICMPV6
@ PACKET_L4_ICMPV6
Definition: decode.h:468
threadvars.h
util-validate.h
PacketGetFromAlloc
Packet * PacketGetFromAlloc(void)
Get a malloced packet.
Definition: decode.c:264
TUNNEL_PKT_RTV
#define TUNNEL_PKT_RTV(p)
Definition: decode.h:1124
source-af-packet.h
PKT_SRC_DECODER_VXLAN
@ PKT_SRC_DECODER_VXLAN
Definition: decode.h:60
mutex_lock_wait_ticks
thread_local uint64_t mutex_lock_wait_ticks
Packet_::next
struct Packet_ * next
Definition: decode.h:646
Packet_::flow_hash
uint32_t flow_hash
Definition: decode.h:566
PacketL4::L4Hdrs::tcph
TCPHdr * tcph
Definition: decode.h:480
PACKET_L4_ICMPV4
@ PACKET_L4_ICMPV4
Definition: decode.h:467
PACKET_L4_IGMP
@ PACKET_L4_IGMP
Definition: decode.h:469
Packet_::l3
struct PacketL3 l3
Definition: decode.h:613
Packet_::root
struct Packet_ * root
Definition: decode.h:664
PacketAlerts_::suppressed
uint16_t suppressed
Definition: decode.h:291
SCLogError
#define SCLogError(...)
Macro used to log ERROR messages.
Definition: util-debug.h:274
PKT_SRC_DETECT_RELOAD_FLUSH
@ PKT_SRC_DETECT_RELOAD_FLUSH
Definition: decode.h:61
PktProfilingData
struct PktProfilingData_ PktProfilingData
StatsCounterAvgId
Definition: counters.h:34
Packet_::pkt_src
uint8_t pkt_src
Definition: decode.h:624
ETHERNET_TYPE_PPPOE_SESS
#define ETHERNET_TYPE_PPPOE_SESS
Definition: decode-ethernet.h:42
DecodeThreadVars_::counter_max_pkt_size
StatsCounterMaxId counter_max_pkt_size
Definition: decode.h:1001
DecodeThreadVars_::counter_flow_spare_sync_incomplete
StatsCounterId counter_flow_spare_sync_incomplete
Definition: decode.h:1084
DecodeThreadVars_::counter_sll2
StatsCounterId counter_sll2
Definition: decode.h:1024
DecodeThreadVars_
Structure to hold thread specific data for all decode modules.
Definition: decode.h:993
PACKET_ENGINE_EVENT_MAX
#define PACKET_ENGINE_EVENT_MAX
Definition: decode.h:305
PACKET_L3_IPV6
@ PACKET_L3_IPV6
Definition: decode.h:439
Packet_::recursion_level
uint8_t recursion_level
Definition: decode.h:539
DecodeThreadVars_::counter_defrag_ipv4_fragments
StatsCounterId counter_defrag_ipv4_fragments
Definition: decode.h:1051
PktProfilingLoggerData_
Definition: decode.h:361
PktProfiling_::tmm
PktProfilingTmmData tmm[TMM_SIZE]
Definition: decode.h:372
Signature_
Signature container.
Definition: detect.h:675
DecodeThreadVars_::counter_etag
StatsCounterId counter_etag
Definition: decode.h:1037
DecodeThreadVars_::counter_tcp_active_sessions
StatsCounterId counter_tcp_active_sessions
Definition: decode.h:1065
DecodeThreadVars_::output_flow_thread_data
void * output_flow_thread_data
Definition: decode.h:1091
ETHERNET_TYPE_ARP
#define ETHERNET_TYPE_ARP
Definition: decode-ethernet.h:35
DecodeThreadVarsAlloc
DecodeThreadVars * DecodeThreadVarsAlloc(ThreadVars *)
Alloc and setup DecodeThreadVars.
Definition: decode.c:825
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:863
PacketL4::hdrs
union PacketL4::L4Hdrs hdrs
PKT_DROP_REASON_FW_DEFAULT_APP_POLICY
@ PKT_DROP_REASON_FW_DEFAULT_APP_POLICY
Definition: decode.h:408
SCSpinlock
#define SCSpinlock
Definition: threads-debug.h:235
VLAN_MAX_LAYER_IDX
#define VLAN_MAX_LAYER_IDX
Definition: decode-vlan.h:52
PktVar_::value_len
uint16_t value_len
Definition: decode.h:319
PacketL2::hdrs
union PacketL2::L2Hdrs hdrs
app-layer-protos.h
DecodeThreadVars_::counter_defrag_ipv6_reassembled
StatsCounterId counter_defrag_ipv6_reassembled
Definition: decode.h:1054
PacketL4::L4Vars::igmp
IGMPVars igmp
Definition: decode.h:493
DecodeThreadVars_::counter_mpls
StatsCounterId counter_mpls
Definition: decode.h:1041
PcapPacketVars_
Definition: source-pcap.h:37
PacketL3::csum
uint16_t csum
Definition: decode.h:447
Packet_::drop_reason
uint8_t drop_reason
Definition: decode.h:658
Address_::family
char family
Definition: decode.h:114
Packet_::dst
Address dst
Definition: decode.h:519
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:1232
PktProfilingTmmData_::ticks_start
uint64_t ticks_start
Definition: decode.h:328
PacketAlert_
Definition: decode.h:249
PktProfilingLoggerData_::ticks_spent
uint64_t ticks_spent
Definition: decode.h:364
ETHERNET_TYPE_VLAN
#define ETHERNET_TYPE_VLAN
Definition: decode-vlan.h:31
PKT_NOPACKET_INSPECTION
#define PKT_NOPACKET_INSPECTION
Definition: decode.h:1285
PktVar_
Definition: decode.h:313
PacketTunnelRoot
@ PacketTunnelRoot
Definition: decode.h:417
AFPPacketVars_
per packet AF_PACKET vars
Definition: source-af-packet.h:155
Packet_::pkt_data
uint8_t pkt_data[]
Definition: decode.h:700
PacketAlertRecycle
void PacketAlertRecycle(PacketAlert *pa_array, uint16_t cnt)
Definition: decode.c:152
PKT_DROP_REASON_FW_DEFAULT_PACKET_POLICY
@ PKT_DROP_REASON_FW_DEFAULT_PACKET_POLICY
Definition: decode.h:407
PacketEngineEvents
struct PacketEngineEvents_ PacketEngineEvents
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:541
DecodeIEEE8021ah
int DecodeIEEE8021ah(ThreadVars *, DecodeThreadVars *, Packet *, const uint8_t *, uint32_t)
DecodeThreadVars_::counter_ipv4
StatsCounterId counter_ipv4
Definition: decode.h:1009
PktProfilingDetectData_::ticks_start
uint64_t ticks_start
Definition: decode.h:352
DecodeThreadVars_::counter_flow_total
StatsCounterId counter_flow_total
Definition: decode.h:1066
DECODE_TUNNEL_ARP
@ DECODE_TUNNEL_ARP
Definition: decode.h:1147
PacketContextData::json_string
char * json_string
Definition: decode.h:243
DecodeThreadVars_::counter_arp
StatsCounterId counter_arp
Definition: decode.h:1020
DecodeThreadVars_::counter_vlan
StatsCounterId counter_vlan
Definition: decode.h:1032
PacketL4
Definition: decode.h:475
PacketDefragPktSetupParent
void PacketDefragPktSetupParent(Packet *parent)
inform defrag "parent" that a pseudo packet is now associated to it.
Definition: decode.c:518
DecodeSll2
int DecodeSll2(ThreadVars *, DecodeThreadVars *, Packet *, const uint8_t *, uint32_t)
Definition: decode-sll2.c:40
DecodeThreadVars_::counter_defrag_tracker_soft_reuse
StatsCounterId counter_defrag_tracker_soft_reuse
Definition: decode.h:1057
Packet_::plugin_v
uint8_t plugin_v[PLUGIN_VAR_SIZE]
Definition: decode.h:597
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:399
DecodeThreadVars_::counter_flow_elephant_toclient
StatsCounterId counter_flow_elephant_toclient
Definition: decode.h:1075
DecodeThreadVars_::counter_flow_elephant_toserver
StatsCounterId counter_flow_elephant_toserver
Definition: decode.h:1074
PktProfiling_::flowworker
PktProfilingData flowworker[PROFILE_FLOWWORKER_SIZE]
Definition: decode.h:373
StatsCounterDeriveId
Definition: counters.h:48
mutex_lock_cnt
thread_local uint64_t mutex_lock_cnt
NFLOGPacketVars_
Definition: source-nflog.h:55
PacketL4::L4Vars::icmpv6
ICMPV6Vars icmpv6
Definition: decode.h:492
PKT_DROP_REASON_STREAM_MIDSTREAM
@ PKT_DROP_REASON_STREAM_MIDSTREAM
Definition: decode.h:396
PacketAlerts_
Definition: decode.h:287
Packet_::dp
Port dp
Definition: decode.h:529
PktVar_::key_len
uint16_t key_len
Definition: decode.h:318
PktProfilingAppData_
Definition: decode.h:357
Host_
Definition: host.h:58
DecodeThreadVars_::counter_erspan
StatsCounterId counter_erspan
Definition: decode.h:1047
ThreadVars_::stats
StatsThreadContext stats
Definition: threadvars.h:121
PktProfiling_::proto_detect
uint64_t proto_detect
Definition: decode.h:376
DecodeETag
int DecodeETag(ThreadVars *, DecodeThreadVars *, Packet *, const uint8_t *, uint32_t)
Definition: decode-etag.c:44
DecodePPPOESession
int DecodePPPOESession(ThreadVars *, DecodeThreadVars *, Packet *, const uint8_t *, uint32_t)
Main decoding function for PPPOE Session packets.
Definition: decode-pppoe.c:122
ETHERNET_TYPE_MPLS_MULTICAST
#define ETHERNET_TYPE_MPLS_MULTICAST
Definition: decode-mpls.h:30
Packet_::type
uint8_t type
Definition: decode.h:524
DecodeThreadVars_::counter_ipv6inipv6
StatsCounterId counter_ipv6inipv6
Definition: decode.h:1045
ETHERNET_TYPE_IP
#define ETHERNET_TYPE_IP
Definition: decode-ethernet.h:34
DecodeThreadVars_::counter_engine_events
StatsCounterId counter_engine_events[DECODE_EVENT_MAX]
Definition: decode.h:1087
DECODE_TUNNEL_UNSET
@ DECODE_TUNNEL_UNSET
Definition: decode.h:1148
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
PacketL3::v
IPV6Vars v
Definition: decode.h:457
PktProfilingLoggerData_::ticks_start
uint64_t ticks_start
Definition: decode.h:362
PKT_DROP_REASON_FLOW_DROP
@ PKT_DROP_REASON_FLOW_DROP
Definition: decode.h:388
TCPHdr_
Definition: decode-tcp.h:149
Packet_::src
Address src
Definition: decode.h:518
PacketL4::vars
union PacketL4::L4Vars vars
DecodeERSPANTypeI
int DecodeERSPANTypeI(ThreadVars *, DecodeThreadVars *, Packet *, const uint8_t *, uint32_t)
ERSPAN Type I.
Definition: decode-erspan.c:65
DecodeCHDLC
int DecodeCHDLC(ThreadVars *, DecodeThreadVars *, Packet *, const uint8_t *, uint32_t)
Definition: decode-chdlc.c:42
DecodeUpdatePacketCounters
void DecodeUpdatePacketCounters(ThreadVars *tv, const DecodeThreadVars *dtv, const Packet *p)
Definition: decode.c:793
DecodeThreadVars_::counter_flow_get_used_eval_reject
StatsCounterId counter_flow_get_used_eval_reject
Definition: decode.h:1078
PktProfilingDetectData_::ticks_spent
uint64_t ticks_spent
Definition: decode.h:354
DecodeThreadVars_::counter_flow_get_used_eval
StatsCounterId counter_flow_get_used_eval
Definition: decode.h:1077
PktVar_::id
uint32_t id
Definition: decode.h:314
SignatureMask
#define SignatureMask
Definition: decode.h:100
DecodeThreadVars_::counter_flow_tcp_reuse
StatsCounterId counter_flow_tcp_reuse
Definition: decode.h:1072
PKT_DROP_REASON_DECODE_ERROR
@ PKT_DROP_REASON_DECODE_ERROR
Definition: decode.h:384
PacketEngineEvents_::cnt
uint8_t cnt
Definition: decode.h:309
DecodePPPOEDiscovery
int DecodePPPOEDiscovery(ThreadVars *, DecodeThreadVars *, Packet *, const uint8_t *, uint32_t)
Main decoding function for PPPOE Discovery packets.
Definition: decode-pppoe.c:49
DecodeThreadVars_::counter_flow_tcp
StatsCounterId counter_flow_tcp
Definition: decode.h:1068