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