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