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