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