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