suricata
decode.h
Go to the documentation of this file.
1 /* Copyright (C) 2007-2020 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 __DECODE_H__
25 #define __DECODE_H__
26 
27 //#define DBG_THREADS
28 #define COUNTERS
29 
30 #include "suricata-common.h"
31 #include "threadvars.h"
32 #include "decode-events.h"
33 #include "flow-worker.h"
34 
35 #ifdef HAVE_NAPATECH
36 #include "util-napatech.h"
37 #endif /* HAVE_NAPATECH */
38 
39 
40 typedef enum {
47 
48 enum PktSrcEnum {
60 };
61 
62 #include "source-nflog.h"
63 #include "source-nfq.h"
64 #include "source-ipfw.h"
65 #include "source-pcap.h"
66 #include "source-af-packet.h"
67 #include "source-netmap.h"
68 #include "source-windivert.h"
69 #ifdef HAVE_PF_RING_FLOW_OFFLOAD
70 #include "source-pfring.h"
71 #endif
72 
73 #include "action-globals.h"
74 
75 #include "decode-erspan.h"
76 #include "decode-ethernet.h"
77 #include "decode-gre.h"
78 #include "decode-ppp.h"
79 #include "decode-pppoe.h"
80 #include "decode-sll.h"
81 #include "decode-ipv4.h"
82 #include "decode-ipv6.h"
83 #include "decode-icmpv4.h"
84 #include "decode-icmpv6.h"
85 #include "decode-tcp.h"
86 #include "decode-udp.h"
87 #include "decode-sctp.h"
88 #include "decode-raw.h"
89 #include "decode-null.h"
90 #include "decode-vlan.h"
91 #include "decode-vxlan.h"
92 #include "decode-mpls.h"
93 
94 #include "detect-reference.h"
95 
96 #include "app-layer-protos.h"
97 
98 /* forward declarations */
99 struct DetectionEngineThreadCtx_;
101 
102 struct PktPool_;
103 
104 /* declare these here as they are called from the
105  * PACKET_RECYCLE and PACKET_CLEANUP macro's. */
109 
110 /* Address */
111 typedef struct Address_ {
112  char family;
113  union {
114  uint32_t address_un_data32[4]; /* type-specific field */
115  uint16_t address_un_data16[8]; /* type-specific field */
116  uint8_t address_un_data8[16]; /* type-specific field */
117  struct in6_addr address_un_in6;
118  } address;
119 } Address;
120 
121 #define addr_data32 address.address_un_data32
122 #define addr_data16 address.address_un_data16
123 #define addr_data8 address.address_un_data8
124 #define addr_in6addr address.address_un_in6
125 
126 #define COPY_ADDRESS(a, b) do { \
127  (b)->family = (a)->family; \
128  (b)->addr_data32[0] = (a)->addr_data32[0]; \
129  (b)->addr_data32[1] = (a)->addr_data32[1]; \
130  (b)->addr_data32[2] = (a)->addr_data32[2]; \
131  (b)->addr_data32[3] = (a)->addr_data32[3]; \
132  } while (0)
133 
134 /* Set the IPv4 addresses into the Addrs of the Packet.
135  * Make sure p->ip4h is initialized and validated.
136  *
137  * We set the rest of the struct to 0 so we can
138  * prevent using memset. */
139 #define SET_IPV4_SRC_ADDR(p, a) do { \
140  (a)->family = AF_INET; \
141  (a)->addr_data32[0] = (uint32_t)(p)->ip4h->s_ip_src.s_addr; \
142  (a)->addr_data32[1] = 0; \
143  (a)->addr_data32[2] = 0; \
144  (a)->addr_data32[3] = 0; \
145  } while (0)
146 
147 #define SET_IPV4_DST_ADDR(p, a) do { \
148  (a)->family = AF_INET; \
149  (a)->addr_data32[0] = (uint32_t)(p)->ip4h->s_ip_dst.s_addr; \
150  (a)->addr_data32[1] = 0; \
151  (a)->addr_data32[2] = 0; \
152  (a)->addr_data32[3] = 0; \
153  } while (0)
154 
155 /* clear the address structure by setting all fields to 0 */
156 #define CLEAR_ADDR(a) do { \
157  (a)->family = 0; \
158  (a)->addr_data32[0] = 0; \
159  (a)->addr_data32[1] = 0; \
160  (a)->addr_data32[2] = 0; \
161  (a)->addr_data32[3] = 0; \
162  } while (0)
163 
164 /* Set the IPv6 addresses into the Addrs of the Packet.
165  * Make sure p->ip6h is initialized and validated. */
166 #define SET_IPV6_SRC_ADDR(p, a) do { \
167  (a)->family = AF_INET6; \
168  (a)->addr_data32[0] = (p)->ip6h->s_ip6_src[0]; \
169  (a)->addr_data32[1] = (p)->ip6h->s_ip6_src[1]; \
170  (a)->addr_data32[2] = (p)->ip6h->s_ip6_src[2]; \
171  (a)->addr_data32[3] = (p)->ip6h->s_ip6_src[3]; \
172  } while (0)
173 
174 #define SET_IPV6_DST_ADDR(p, a) do { \
175  (a)->family = AF_INET6; \
176  (a)->addr_data32[0] = (p)->ip6h->s_ip6_dst[0]; \
177  (a)->addr_data32[1] = (p)->ip6h->s_ip6_dst[1]; \
178  (a)->addr_data32[2] = (p)->ip6h->s_ip6_dst[2]; \
179  (a)->addr_data32[3] = (p)->ip6h->s_ip6_dst[3]; \
180  } while (0)
181 
182 /* Set the TCP ports into the Ports of the Packet.
183  * Make sure p->tcph is initialized and validated. */
184 #define SET_TCP_SRC_PORT(pkt, prt) do { \
185  SET_PORT(TCP_GET_SRC_PORT((pkt)), *(prt)); \
186  } while (0)
187 
188 #define SET_TCP_DST_PORT(pkt, prt) do { \
189  SET_PORT(TCP_GET_DST_PORT((pkt)), *(prt)); \
190  } while (0)
191 
192 /* Set the UDP ports into the Ports of the Packet.
193  * Make sure p->udph is initialized and validated. */
194 #define SET_UDP_SRC_PORT(pkt, prt) do { \
195  SET_PORT(UDP_GET_SRC_PORT((pkt)), *(prt)); \
196  } while (0)
197 #define SET_UDP_DST_PORT(pkt, prt) do { \
198  SET_PORT(UDP_GET_DST_PORT((pkt)), *(prt)); \
199  } while (0)
200 
201 /* Set the SCTP ports into the Ports of the Packet.
202  * Make sure p->sctph is initialized and validated. */
203 #define SET_SCTP_SRC_PORT(pkt, prt) do { \
204  SET_PORT(SCTP_GET_SRC_PORT((pkt)), *(prt)); \
205  } while (0)
206 
207 #define SET_SCTP_DST_PORT(pkt, prt) do { \
208  SET_PORT(SCTP_GET_DST_PORT((pkt)), *(prt)); \
209  } while (0)
210 
211 
212 
213 #define GET_IPV4_SRC_ADDR_U32(p) ((p)->src.addr_data32[0])
214 #define GET_IPV4_DST_ADDR_U32(p) ((p)->dst.addr_data32[0])
215 #define GET_IPV4_SRC_ADDR_PTR(p) ((p)->src.addr_data32)
216 #define GET_IPV4_DST_ADDR_PTR(p) ((p)->dst.addr_data32)
217 
218 #define GET_IPV6_SRC_IN6ADDR(p) ((p)->src.addr_in6addr)
219 #define GET_IPV6_DST_IN6ADDR(p) ((p)->dst.addr_in6addr)
220 #define GET_IPV6_SRC_ADDR(p) ((p)->src.addr_data32)
221 #define GET_IPV6_DST_ADDR(p) ((p)->dst.addr_data32)
222 #define GET_TCP_SRC_PORT(p) ((p)->sp)
223 #define GET_TCP_DST_PORT(p) ((p)->dp)
224 
225 #define GET_PKT_LEN(p) ((p)->pktlen)
226 #define GET_PKT_DATA(p) ((((p)->ext_pkt) == NULL ) ? (uint8_t *)((p) + 1) : (p)->ext_pkt)
227 #define GET_PKT_DIRECT_DATA(p) (uint8_t *)((p) + 1)
228 #define GET_PKT_DIRECT_MAX_SIZE(p) (default_packet_size)
229 
230 #define SET_PKT_LEN(p, len) do { \
231  (p)->pktlen = (len); \
232  } while (0)
233 
234 
235 /* Port is just a uint16_t */
236 typedef uint16_t Port;
237 #define SET_PORT(v, p) ((p) = (v))
238 #define COPY_PORT(a,b) ((b) = (a))
239 
240 #define CMP_ADDR(a1, a2) \
241  (((a1)->addr_data32[3] == (a2)->addr_data32[3] && \
242  (a1)->addr_data32[2] == (a2)->addr_data32[2] && \
243  (a1)->addr_data32[1] == (a2)->addr_data32[1] && \
244  (a1)->addr_data32[0] == (a2)->addr_data32[0]))
245 #define CMP_PORT(p1, p2) \
246  ((p1) == (p2))
247 
248 /*Given a packet pkt offset to the start of the ip header in a packet
249  *We determine the ip version. */
250 #define IP_GET_RAW_VER(pkt) ((((pkt)[0] & 0xf0) >> 4))
251 
252 #define PKT_IS_IPV4(p) (((p)->ip4h != NULL))
253 #define PKT_IS_IPV6(p) (((p)->ip6h != NULL))
254 #define PKT_IS_TCP(p) (((p)->tcph != NULL))
255 #define PKT_IS_UDP(p) (((p)->udph != NULL))
256 #define PKT_IS_ICMPV4(p) (((p)->icmpv4h != NULL))
257 #define PKT_IS_ICMPV6(p) (((p)->icmpv6h != NULL))
258 #define PKT_IS_TOSERVER(p) (((p)->flowflags & FLOW_PKT_TOSERVER))
259 #define PKT_IS_TOCLIENT(p) (((p)->flowflags & FLOW_PKT_TOCLIENT))
260 
261 #define IPH_IS_VALID(p) (PKT_IS_IPV4((p)) || PKT_IS_IPV6((p)))
262 
263 /* Retrieve proto regardless of IP version */
264 #define IP_GET_IPPROTO(p) \
265  (p->proto ? p->proto : \
266  (PKT_IS_IPV4((p))? IPV4_GET_IPPROTO((p)) : (PKT_IS_IPV6((p))? IPV6_GET_L4PROTO((p)) : 0)))
267 
268 /* structure to store the sids/gids/etc the detection engine
269  * found in this packet */
270 typedef struct PacketAlert_ {
271  SigIntId num; /* Internal num, used for sorting */
272  uint8_t action; /* Internal num, used for sorting */
273  uint8_t flags;
274  const struct Signature_ *s;
275  uint64_t tx_id;
276 } PacketAlert;
277 
278 /** After processing an alert by the thresholding module, if at
279  * last it gets triggered, we might want to stick the drop action to
280  * the flow on IPS mode */
281 #define PACKET_ALERT_FLAG_DROP_FLOW 0x01
282 /** alert was generated based on state */
283 #define PACKET_ALERT_FLAG_STATE_MATCH 0x02
284 /** alert was generated based on stream */
285 #define PACKET_ALERT_FLAG_STREAM_MATCH 0x04
286 /** alert is in a tx, tx_id set */
287 #define PACKET_ALERT_FLAG_TX 0x08
288 /** action was changed by rate_filter */
289 #define PACKET_ALERT_RATE_FILTER_MODIFIED 0x10
290 
291 #define PACKET_ALERT_MAX 15
292 
293 typedef struct PacketAlerts_ {
294  uint16_t cnt;
296  /* single pa used when we're dropping,
297  * so we can log it out in the drop log. */
299 } PacketAlerts;
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 */
306 typedef struct PacketEngineEvents_ {
307  uint8_t cnt; /**< number of events */
308  uint8_t events[PACKET_ENGINE_EVENT_MAX]; /**< array of events */
310 
311 typedef 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;
320 } PktVar;
321 
322 #ifdef PROFILING
323 
324 /** \brief Per TMM stats storage */
325 typedef 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 
344 typedef struct PktProfilingData_ {
345  uint64_t ticks_start;
346  uint64_t ticks_end;
348 
349 typedef struct PktProfilingDetectData_ {
350  uint64_t ticks_start;
351  uint64_t ticks_end;
352  uint64_t ticks_spent;
354 
355 typedef struct PktProfilingAppData_ {
356  uint64_t ticks_spent;
358 
359 typedef struct PktProfilingLoggerData_ {
360  uint64_t ticks_start;
361  uint64_t ticks_end;
362  uint64_t ticks_spent;
364 
366  uint64_t ticks_spent;
368 
371  uint32_t size; /**< array size */
373 
374 /** \brief Per pkt stats storage */
375 typedef struct PktProfiling_ {
376  uint64_t ticks_start;
377  uint64_t ticks_end;
378 
384  uint64_t proto_detect;
385 } PktProfiling;
386 
387 #endif /* PROFILING */
388 
389 /* forward declaration since Packet struct definition requires this */
390 struct PacketQueue_;
391 
392 /* sizes of the members:
393  * src: 17 bytes
394  * dst: 17 bytes
395  * sp/type: 1 byte
396  * dp/code: 1 byte
397  * proto: 1 byte
398  * recurs: 1 byte
399  *
400  * sum of above: 38 bytes
401  *
402  * flow ptr: 4/8 bytes
403  * flags: 1 byte
404  * flowflags: 1 byte
405  *
406  * sum of above 44/48 bytes
407  */
408 typedef struct Packet_
409 {
410  /* Addresses, Ports and protocol
411  * these are on top so we can use
412  * the Packet as a hash key */
415  union {
417  // icmp type and code of this packet
418  struct {
419  uint8_t type;
420  uint8_t code;
421  } icmp_s;
422  };
423  union {
425  // icmp type and code of the expected counterpart (for flows)
426  struct {
427  uint8_t type;
428  uint8_t code;
429  } icmp_d;
430  };
431  uint8_t proto;
432  /* make sure we can't be attacked on when the tunneled packet
433  * has the exact same tuple as the lower levels */
435 
436  uint16_t vlan_id[2];
437  uint8_t vlan_idx;
438 
439  /* flow */
440  uint8_t flowflags;
441  /* coccinelle: Packet:flowflags:FLOW_PKT_ */
442 
443  /* Pkt Flags */
444  uint32_t flags;
445 
446  struct Flow_ *flow;
447 
448  /* raw hash value for looking up the flow, will need to modulated to the
449  * hash size still */
450  uint32_t flow_hash;
451 
452  struct timeval ts;
453 
454  union {
455  /* nfq stuff */
456 #ifdef HAVE_NFLOG
457  NFLOGPacketVars nflog_v;
458 #endif /* HAVE_NFLOG */
459 #ifdef NFQ
461 #endif /* NFQ */
462 #ifdef IPFW
464 #endif /* IPFW */
465 #ifdef AF_PACKET
466  AFPPacketVars afp_v;
467 #endif
468 #ifdef HAVE_NETMAP
469  NetmapPacketVars netmap_v;
470 #endif
471 #ifdef HAVE_PFRING
472 #ifdef HAVE_PF_RING_FLOW_OFFLOAD
473  PfringPacketVars pfring_v;
474 #endif
475 #endif
476 #ifdef WINDIVERT
477  WinDivertPacketVars windivert_v;
478 #endif /* WINDIVERT */
479 
480  /** libpcap vars: shared by Pcap Live mode and Pcap File mode */
482  };
483 
484  /** The release function for packet structure and data */
485  void (*ReleasePacket)(struct Packet_ *);
486  /** The function triggering bypass the flow in the capture method.
487  * Return 1 for success and 0 on error */
488  int (*BypassPacketsFlow)(struct Packet_ *);
489 
490  /* pkt vars */
492 
493  /* header pointers */
494  EthernetHdr *ethh;
495 
496  /* Checksum for IP packets. */
498  /* Check sum for TCP, UDP or ICMP packets */
500 
502 
504 
505  /* IPv4 and IPv6 are mutually exclusive */
506  union {
508  struct {
511  };
512  };
513  /* Can only be one of TCP, UDP, ICMP at any given time */
514  union {
518  } l4vars;
519 #define tcpvars l4vars.tcpvars
520 #define icmpv4vars l4vars.icmpv4vars
521 #define icmpv6vars l4vars.icmpv6vars
522 
523  TCPHdr *tcph;
524 
525  UDPHdr *udph;
526 
527  SCTPHdr *sctph;
528 
529  ICMPV4Hdr *icmpv4h;
530 
532 
533  PPPHdr *ppph;
535  PPPOEDiscoveryHdr *pppoedh;
536 
537  GREHdr *greh;
538 
539  /* ptr to the payload of the packet
540  * with it's length. */
541  uint8_t *payload;
542  uint16_t payload_len;
543 
544  /* IPS action to take */
545  uint8_t action;
546 
547  uint8_t pkt_src;
548 
549  /* storage: set to pointer to heap and extended via allocation if necessary */
550  uint32_t pktlen;
551  uint8_t *ext_pkt;
552 
553  /* Incoming interface */
555 
557 
558  struct Host_ *host_src;
559  struct Host_ *host_dst;
560 
561  /** packet number in the pcap file, matches wireshark */
562  uint64_t pcap_cnt;
563 
564 
565  /* engine events */
567 
569 
570  /* double linked list ptrs */
571  struct Packet_ *next;
572  struct Packet_ *prev;
573 
574  /** data linktype in host order */
575  int datalink;
576 
577  /* tunnel/encapsulation handling */
578  struct Packet_ *root; /* in case of tunnel this is a ptr
579  * to the 'real' packet, the one we
580  * need to set the verdict on --
581  * It should always point to the lowest
582  * packet in a encapsulated packet */
583 
584  /** mutex to protect access to:
585  * - tunnel_rtv_cnt
586  * - tunnel_tpr_cnt
587  */
589  /* ready to set verdict counter, only set in root */
590  uint16_t tunnel_rtv_cnt;
591  /* tunnel packet ref count */
592  uint16_t tunnel_tpr_cnt;
593 
594  /** tenant id for this packet, if any. If 0 then no tenant was assigned. */
595  uint32_t tenant_id;
596 
597  /* The Packet pool from which this packet was allocated. Used when returning
598  * the packet to its owner's stack. If NULL, then allocated with malloc.
599  */
600  struct PktPool_ *pool;
601 
602 #ifdef PROFILING
604 #endif
605 #ifdef HAVE_NAPATECH
607 #endif
608 } Packet;
609 
610 /** highest mtu of the interfaces we monitor */
611 extern int g_default_mtu;
612 #define DEFAULT_MTU 1500
613 #define MINIMUM_MTU 68 /**< ipv4 minimum: rfc791 */
614 
615 #define DEFAULT_PACKET_SIZE (DEFAULT_MTU + ETHERNET_HEADER_LEN)
616 /* storage: maximum ip packet size + link header */
617 #define MAX_PAYLOAD_SIZE (IPV6_HEADER_LEN + 65536 + 28)
618 extern uint32_t default_packet_size;
619 #define SIZE_OF_PACKET (default_packet_size + sizeof(Packet))
620 
621 /** \brief Structure to hold thread specific data for all decode modules */
622 typedef struct DecodeThreadVars_
623 {
624  /** Specific context for udp protocol detection (here atm) */
626 
627  /** stats/counters */
628  uint16_t counter_pkts;
629  uint16_t counter_bytes;
632 
633  uint16_t counter_invalid;
634 
635  uint16_t counter_eth;
636  uint16_t counter_ipv4;
637  uint16_t counter_ipv6;
638  uint16_t counter_tcp;
639  uint16_t counter_udp;
640  uint16_t counter_icmpv4;
641  uint16_t counter_icmpv6;
642 
643  uint16_t counter_sll;
644  uint16_t counter_raw;
645  uint16_t counter_null;
646  uint16_t counter_sctp;
647  uint16_t counter_ppp;
648  uint16_t counter_gre;
649  uint16_t counter_vlan;
651  uint16_t counter_vxlan;
653  uint16_t counter_pppoe;
654  uint16_t counter_teredo;
655  uint16_t counter_mpls;
658  uint16_t counter_erspan;
659 
660  /** frag stats - defrag runs in the context of the decoder. */
668 
670 
675 
677 
678  /* thread data for flow logging api: only used at forced
679  * flow recycle during lookups */
681 
683 
684 typedef struct CaptureStats_ {
685 
690 
691 } CaptureStats;
692 
693 void CaptureStatsUpdate(ThreadVars *tv, CaptureStats *s, const Packet *p);
695 
696 #define PACKET_CLEAR_L4VARS(p) do { \
697  memset(&(p)->l4vars, 0x00, sizeof((p)->l4vars)); \
698  } while (0)
699 
700 /**
701  * \brief reset these to -1(indicates that the packet is fresh from the queue)
702  */
703 #define PACKET_RESET_CHECKSUMS(p) do { \
704  (p)->level3_comp_csum = -1; \
705  (p)->level4_comp_csum = -1; \
706  } while (0)
707 
708 /* if p uses extended data, free them */
709 #define PACKET_FREE_EXTDATA(p) do { \
710  if ((p)->ext_pkt) { \
711  if (!((p)->flags & PKT_ZERO_COPY)) { \
712  SCFree((p)->ext_pkt); \
713  } \
714  (p)->ext_pkt = NULL; \
715  } \
716  } while(0)
717 
718 /**
719  * \brief Initialize a packet structure for use.
720  */
721 #define PACKET_INITIALIZE(p) { \
722  SCMutexInit(&(p)->tunnel_mutex, NULL); \
723  PACKET_RESET_CHECKSUMS((p)); \
724  (p)->livedev = NULL; \
725 }
726 
727 #define PACKET_RELEASE_REFS(p) do { \
728  FlowDeReference(&((p)->flow)); \
729  HostDeReference(&((p)->host_src)); \
730  HostDeReference(&((p)->host_dst)); \
731  } while (0)
732 
733 /**
734  * \brief Recycle a packet structure for reuse.
735  */
736 #define PACKET_REINIT(p) do { \
737  CLEAR_ADDR(&(p)->src); \
738  CLEAR_ADDR(&(p)->dst); \
739  (p)->sp = 0; \
740  (p)->dp = 0; \
741  (p)->proto = 0; \
742  (p)->recursion_level = 0; \
743  PACKET_FREE_EXTDATA((p)); \
744  (p)->flags = (p)->flags & PKT_ALLOC; \
745  (p)->flowflags = 0; \
746  (p)->pkt_src = 0; \
747  (p)->vlan_id[0] = 0; \
748  (p)->vlan_id[1] = 0; \
749  (p)->vlan_idx = 0; \
750  (p)->ts.tv_sec = 0; \
751  (p)->ts.tv_usec = 0; \
752  (p)->datalink = 0; \
753  (p)->action = 0; \
754  if ((p)->pktvar != NULL) { \
755  PktVarFree((p)->pktvar); \
756  (p)->pktvar = NULL; \
757  } \
758  (p)->ethh = NULL; \
759  if ((p)->ip4h != NULL) { \
760  CLEAR_IPV4_PACKET((p)); \
761  } \
762  if ((p)->ip6h != NULL) { \
763  CLEAR_IPV6_PACKET((p)); \
764  } \
765  if ((p)->tcph != NULL) { \
766  CLEAR_TCP_PACKET((p)); \
767  } \
768  if ((p)->udph != NULL) { \
769  CLEAR_UDP_PACKET((p)); \
770  } \
771  if ((p)->sctph != NULL) { \
772  CLEAR_SCTP_PACKET((p)); \
773  } \
774  if ((p)->icmpv4h != NULL) { \
775  CLEAR_ICMPV4_PACKET((p)); \
776  } \
777  if ((p)->icmpv6h != NULL) { \
778  CLEAR_ICMPV6_PACKET((p)); \
779  } \
780  (p)->ppph = NULL; \
781  (p)->pppoesh = NULL; \
782  (p)->pppoedh = NULL; \
783  (p)->greh = NULL; \
784  (p)->payload = NULL; \
785  (p)->payload_len = 0; \
786  (p)->BypassPacketsFlow = NULL; \
787  (p)->pktlen = 0; \
788  (p)->alerts.cnt = 0; \
789  (p)->alerts.drop.action = 0; \
790  (p)->pcap_cnt = 0; \
791  (p)->tunnel_rtv_cnt = 0; \
792  (p)->tunnel_tpr_cnt = 0; \
793  (p)->events.cnt = 0; \
794  AppLayerDecoderEventsResetEvents((p)->app_layer_events); \
795  (p)->next = NULL; \
796  (p)->prev = NULL; \
797  (p)->root = NULL; \
798  (p)->livedev = NULL; \
799  PACKET_RESET_CHECKSUMS((p)); \
800  PACKET_PROFILING_RESET((p)); \
801  p->tenant_id = 0; \
802  } while (0)
803 
804 #define PACKET_RECYCLE(p) do { \
805  PACKET_RELEASE_REFS((p)); \
806  PACKET_REINIT((p)); \
807  } while (0)
808 
809 /**
810  * \brief Cleanup a packet so that we can free it. No memset needed..
811  */
812 #define PACKET_DESTRUCTOR(p) do { \
813  if ((p)->pktvar != NULL) { \
814  PktVarFree((p)->pktvar); \
815  } \
816  PACKET_FREE_EXTDATA((p)); \
817  SCMutexDestroy(&(p)->tunnel_mutex); \
818  AppLayerDecoderEventsFreeEvents(&(p)->app_layer_events); \
819  PACKET_PROFILING_RESET((p)); \
820  } while (0)
821 
822 
823 /* macro's for setting the action
824  * handle the case of a root packet
825  * for tunnels */
826 
827 #define PACKET_SET_ACTION(p, a) do { \
828  ((p)->root ? \
829  ((p)->root->action = a) : \
830  ((p)->action = a)); \
831 } while (0)
832 
833 #define PACKET_ALERT(p) PACKET_SET_ACTION(p, ACTION_ALERT)
834 
835 #define PACKET_ACCEPT(p) PACKET_SET_ACTION(p, ACTION_ACCEPT)
836 
837 #define PACKET_DROP(p) PACKET_SET_ACTION(p, ACTION_DROP)
838 
839 #define PACKET_REJECT(p) PACKET_SET_ACTION(p, (ACTION_REJECT|ACTION_DROP))
840 
841 #define PACKET_REJECT_DST(p) PACKET_SET_ACTION(p, (ACTION_REJECT_DST|ACTION_DROP))
842 
843 #define PACKET_REJECT_BOTH(p) PACKET_SET_ACTION(p, (ACTION_REJECT_BOTH|ACTION_DROP))
844 
845 #define PACKET_PASS(p) PACKET_SET_ACTION(p, ACTION_PASS)
846 
847 #define PACKET_TEST_ACTION(p, a) \
848  ((p)->root ? \
849  ((p)->root->action & a) : \
850  ((p)->action & a))
851 
852 #define PACKET_UPDATE_ACTION(p, a) do { \
853  ((p)->root ? \
854  ((p)->root->action |= a) : \
855  ((p)->action |= a)); \
856 } while (0)
857 
858 #define TUNNEL_INCR_PKT_RTV_NOLOCK(p) do { \
859  ((p)->root ? (p)->root->tunnel_rtv_cnt++ : (p)->tunnel_rtv_cnt++); \
860  } while (0)
861 
862 #define TUNNEL_INCR_PKT_TPR(p) do { \
863  SCMutexLock((p)->root ? &(p)->root->tunnel_mutex : &(p)->tunnel_mutex); \
864  ((p)->root ? (p)->root->tunnel_tpr_cnt++ : (p)->tunnel_tpr_cnt++); \
865  SCMutexUnlock((p)->root ? &(p)->root->tunnel_mutex : &(p)->tunnel_mutex); \
866  } while (0)
867 
868 #define TUNNEL_PKT_RTV(p) ((p)->root ? (p)->root->tunnel_rtv_cnt : (p)->tunnel_rtv_cnt)
869 #define TUNNEL_PKT_TPR(p) ((p)->root ? (p)->root->tunnel_tpr_cnt : (p)->tunnel_tpr_cnt)
870 
871 #define IS_TUNNEL_PKT(p) (((p)->flags & PKT_TUNNEL))
872 #define SET_TUNNEL_PKT(p) ((p)->flags |= PKT_TUNNEL)
873 #define UNSET_TUNNEL_PKT(p) ((p)->flags &= ~PKT_TUNNEL)
874 #define IS_TUNNEL_ROOT_PKT(p) (IS_TUNNEL_PKT(p) && (p)->root == NULL)
875 
876 #define IS_TUNNEL_PKT_VERDICTED(p) (((p)->flags & PKT_TUNNEL_VERDICTED))
877 #define SET_TUNNEL_PKT_VERDICTED(p) ((p)->flags |= PKT_TUNNEL_VERDICTED)
878 
886  DECODE_TUNNEL_IPV6_TEREDO, /**< separate protocol for stricter error handling */
888 };
889 
891  const uint8_t *pkt, uint32_t len, enum DecodeTunnelProto proto);
892 Packet *PacketDefragPktSetup(Packet *parent, const uint8_t *pkt, uint32_t len, uint8_t proto);
893 void PacketDefragPktSetupParent(Packet *parent);
900 void PacketFree(Packet *p);
901 void PacketFreeOrRelease(Packet *p);
902 int PacketCallocExtPkt(Packet *p, int datalen);
903 int PacketCopyData(Packet *p, const uint8_t *pktdata, uint32_t pktlen);
904 int PacketSetData(Packet *p, const uint8_t *pktdata, uint32_t pktlen);
905 int PacketCopyDataOffset(Packet *p, uint32_t offset, const uint8_t *data, uint32_t datalen);
906 const char *PktSrcToString(enum PktSrcEnum pkt_src);
908 void PacketSwap(Packet *p);
909 
913  const DecodeThreadVars *dtv, const Packet *p);
914 
915 /* decoder functions */
916 int DecodeEthernet(ThreadVars *, DecodeThreadVars *, Packet *, const uint8_t *, uint32_t);
917 int DecodeSll(ThreadVars *, DecodeThreadVars *, Packet *, const uint8_t *, uint32_t);
918 int DecodePPP(ThreadVars *, DecodeThreadVars *, Packet *, const uint8_t *, uint32_t);
919 int DecodePPPOESession(ThreadVars *, DecodeThreadVars *, Packet *, const uint8_t *, uint32_t);
920 int DecodePPPOEDiscovery(ThreadVars *, DecodeThreadVars *, Packet *, const uint8_t *, uint32_t);
921 int DecodeTunnel(ThreadVars *, DecodeThreadVars *, Packet *, const uint8_t *, uint32_t, enum DecodeTunnelProto) __attribute__ ((warn_unused_result));
922 int DecodeNull(ThreadVars *, DecodeThreadVars *, Packet *, const uint8_t *, uint32_t);
923 int DecodeRaw(ThreadVars *, DecodeThreadVars *, Packet *, const uint8_t *, uint32_t);
924 int DecodeIPV4(ThreadVars *, DecodeThreadVars *, Packet *, const uint8_t *, uint16_t);
925 int DecodeIPV6(ThreadVars *, DecodeThreadVars *, Packet *, const uint8_t *, uint16_t);
926 int DecodeICMPV4(ThreadVars *, DecodeThreadVars *, Packet *, const uint8_t *, uint32_t);
927 int DecodeICMPV6(ThreadVars *, DecodeThreadVars *, Packet *, const uint8_t *, uint32_t);
928 int DecodeTCP(ThreadVars *, DecodeThreadVars *, Packet *, const uint8_t *, uint16_t);
929 int DecodeUDP(ThreadVars *, DecodeThreadVars *, Packet *, const uint8_t *, uint16_t);
930 int DecodeSCTP(ThreadVars *, DecodeThreadVars *, Packet *, const uint8_t *, uint16_t);
931 int DecodeGRE(ThreadVars *, DecodeThreadVars *, Packet *, const uint8_t *, uint32_t);
932 int DecodeVLAN(ThreadVars *, DecodeThreadVars *, Packet *, const uint8_t *, uint32_t);
933 int DecodeVXLAN(ThreadVars *, DecodeThreadVars *, Packet *, const uint8_t *, uint32_t);
934 int DecodeMPLS(ThreadVars *, DecodeThreadVars *, Packet *, const uint8_t *, uint32_t);
935 int DecodeERSPAN(ThreadVars *, DecodeThreadVars *, Packet *, const uint8_t *, uint32_t);
936 int DecodeERSPANTypeI(ThreadVars *, DecodeThreadVars *, Packet *, const uint8_t *, uint32_t);
937 int DecodeTEMPLATE(ThreadVars *, DecodeThreadVars *, Packet *, const uint8_t *, uint32_t);
938 
939 #ifdef UNITTESTS
940 void DecodeIPV6FragHeader(Packet *p, const uint8_t *pkt,
941  uint16_t hdrextlen, uint16_t plen,
942  uint16_t prev_hdrextlen);
943 #endif
944 
945 void AddressDebugPrint(Address *);
946 
948  const uint8_t *pkt, uint32_t len);
949 void DecodeGlobalConfig(void);
950 void DecodeUnregisterCounters(void);
951 
952 /** \brief Set the No payload inspection Flag for the packet.
953  *
954  * \param p Packet to set the flag in
955  */
956 #define DecodeSetNoPayloadInspectionFlag(p) do { \
957  (p)->flags |= PKT_NOPAYLOAD_INSPECTION; \
958  } while (0)
959 
960 #define DecodeUnsetNoPayloadInspectionFlag(p) do { \
961  (p)->flags &= ~PKT_NOPAYLOAD_INSPECTION; \
962  } while (0)
963 
964 /** \brief Set the No packet inspection Flag for the packet.
965  *
966  * \param p Packet to set the flag in
967  */
968 #define DecodeSetNoPacketInspectionFlag(p) do { \
969  (p)->flags |= PKT_NOPACKET_INSPECTION; \
970  } while (0)
971 #define DecodeUnsetNoPacketInspectionFlag(p) do { \
972  (p)->flags &= ~PKT_NOPACKET_INSPECTION; \
973  } while (0)
974 
975 
976 #define ENGINE_SET_EVENT(p, e) do { \
977  SCLogDebug("p %p event %d", (p), e); \
978  if ((p)->events.cnt < PACKET_ENGINE_EVENT_MAX) { \
979  (p)->events.events[(p)->events.cnt] = e; \
980  (p)->events.cnt++; \
981  } \
982 } while(0)
983 
984 #define ENGINE_SET_INVALID_EVENT(p, e) do { \
985  p->flags |= PKT_IS_INVALID; \
986  ENGINE_SET_EVENT(p, e); \
987 } while(0)
988 
989 
990 
991 #define ENGINE_ISSET_EVENT(p, e) ({ \
992  int r = 0; \
993  uint8_t u; \
994  for (u = 0; u < (p)->events.cnt; u++) { \
995  if ((p)->events.events[u] == (e)) { \
996  r = 1; \
997  break; \
998  } \
999  } \
1000  r; \
1001 })
1002 
1003 #ifndef IPPROTO_IPIP
1004 #define IPPROTO_IPIP 4
1005 #endif
1006 
1007 /* older libcs don't contain a def for IPPROTO_DCCP
1008  * inside of <netinet/in.h>
1009  * if it isn't defined let's define it here.
1010  */
1011 #ifndef IPPROTO_DCCP
1012 #define IPPROTO_DCCP 33
1013 #endif
1014 
1015 /* older libcs don't contain a def for IPPROTO_SCTP
1016  * inside of <netinet/in.h>
1017  * if it isn't defined let's define it here.
1018  */
1019 #ifndef IPPROTO_SCTP
1020 #define IPPROTO_SCTP 132
1021 #endif
1022 
1023 #ifndef IPPROTO_MH
1024 #define IPPROTO_MH 135
1025 #endif
1026 
1027 /* Host Identity Protocol (rfc 5201) */
1028 #ifndef IPPROTO_HIP
1029 #define IPPROTO_HIP 139
1030 #endif
1031 
1032 #ifndef IPPROTO_SHIM6
1033 #define IPPROTO_SHIM6 140
1034 #endif
1035 
1036 /* pcap provides this, but we don't want to depend on libpcap */
1037 #ifndef DLT_EN10MB
1038 #define DLT_EN10MB 1
1039 #endif
1040 
1041 /* taken from pcap's bpf.h */
1042 #ifndef DLT_RAW
1043 #ifdef __OpenBSD__
1044 #define DLT_RAW 14 /* raw IP */
1045 #else
1046 #define DLT_RAW 12 /* raw IP */
1047 #endif
1048 #endif
1049 
1050 #ifndef DLT_NULL
1051 #define DLT_NULL 0
1052 #endif
1053 
1054 /** libpcap shows us the way to linktype codes
1055  * \todo we need more & maybe put them in a separate file? */
1056 #define LINKTYPE_NULL DLT_NULL
1057 #define LINKTYPE_ETHERNET DLT_EN10MB
1058 #define LINKTYPE_LINUX_SLL 113
1059 #define LINKTYPE_PPP 9
1060 #define LINKTYPE_RAW DLT_RAW
1061 /* http://www.tcpdump.org/linktypes.html defines DLT_RAW as 101, yet others don't.
1062  * Libpcap on at least OpenBSD returns 101 as datalink type for RAW pcaps though. */
1063 #define LINKTYPE_RAW2 101
1064 #define LINKTYPE_IPV4 228
1065 #define LINKTYPE_GRE_OVER_IP 778
1066 #define PPP_OVER_GRE 11
1067 #define VLAN_OVER_GRE 13
1068 
1069 /*Packet Flags*/
1070 #define PKT_NOPACKET_INSPECTION (1) /**< Flag to indicate that packet header or contents should not be inspected*/
1071 #define PKT_NOPAYLOAD_INSPECTION (1<<2) /**< Flag to indicate that packet contents should not be inspected*/
1072 #define PKT_ALLOC (1<<3) /**< Packet was alloc'd this run, needs to be freed */
1073 #define PKT_HAS_TAG (1<<4) /**< Packet has matched a tag */
1074 #define PKT_STREAM_ADD (1<<5) /**< Packet payload was added to reassembled stream */
1075 #define PKT_STREAM_EST (1<<6) /**< Packet is part of established stream */
1076 #define PKT_STREAM_EOF (1<<7) /**< Stream is in eof state */
1077 #define PKT_HAS_FLOW (1<<8)
1078 #define PKT_PSEUDO_STREAM_END (1<<9) /**< Pseudo packet to end the stream */
1079 #define PKT_STREAM_MODIFIED (1<<10) /**< Packet is modified by the stream engine, we need to recalc the csum and reinject/replace */
1080 #define PKT_MARK_MODIFIED (1<<11) /**< Packet mark is modified */
1081 #define PKT_STREAM_NOPCAPLOG (1<<12) /**< Exclude packet from pcap logging as it's part of a stream that has reassembly depth reached. */
1082 
1083 #define PKT_TUNNEL (1<<13)
1084 #define PKT_TUNNEL_VERDICTED (1<<14)
1085 
1086 #define PKT_IGNORE_CHECKSUM (1<<15) /**< Packet checksum is not computed (TX packet for example) */
1087 #define PKT_ZERO_COPY (1<<16) /**< Packet comes from zero copy (ext_pkt must not be freed) */
1088 
1089 #define PKT_HOST_SRC_LOOKED_UP (1<<17)
1090 #define PKT_HOST_DST_LOOKED_UP (1<<18)
1091 
1092 #define PKT_IS_FRAGMENT (1<<19) /**< Packet is a fragment */
1093 #define PKT_IS_INVALID (1<<20)
1094 #define PKT_PROFILE (1<<21)
1095 
1096 /** indication by decoder that it feels the packet should be handled by
1097  * flow engine: Packet::flow_hash will be set */
1098 #define PKT_WANTS_FLOW (1<<22)
1099 
1100 /** protocol detection done */
1101 #define PKT_PROTO_DETECT_TS_DONE (1<<23)
1102 #define PKT_PROTO_DETECT_TC_DONE (1<<24)
1103 
1104 #define PKT_REBUILT_FRAGMENT (1<<25) /**< Packet is rebuilt from
1105  * fragments. */
1106 #define PKT_DETECT_HAS_STREAMDATA (1<<26) /**< Set by Detect() if raw stream data is available. */
1107 
1108 #define PKT_PSEUDO_DETECTLOG_FLUSH (1<<27) /**< Detect/log flush for protocol upgrade */
1109 
1110 /** Packet is part of stream in known bad condition (loss, wrong thread),
1111  * so flag it for not setting stream events */
1112 #define PKT_STREAM_NO_EVENTS (1<<28)
1113 
1114 /** \brief return 1 if the packet is a pseudo packet */
1115 #define PKT_IS_PSEUDOPKT(p) \
1116  ((p)->flags & (PKT_PSEUDO_STREAM_END|PKT_PSEUDO_DETECTLOG_FLUSH))
1117 
1118 #define PKT_SET_SRC(p, src_val) ((p)->pkt_src = src_val)
1119 
1120 /** \brief return true if *this* packet needs to trigger a verdict.
1121  *
1122  * If we have the root packet, and we have none outstanding,
1123  * we can verdict now.
1124  *
1125  * If we have a upper layer packet, it's the only one and root
1126  * is already processed, we can verdict now.
1127  *
1128  * Otherwise, a future packet will issue the verdict.
1129  */
1130 static inline bool VerdictTunnelPacket(Packet *p)
1131 {
1132  bool verdict = true;
1133  SCMutex *m = p->root ? &p->root->tunnel_mutex : &p->tunnel_mutex;
1134  SCMutexLock(m);
1135  const uint16_t outstanding = TUNNEL_PKT_TPR(p) - TUNNEL_PKT_RTV(p);
1136  SCLogDebug("tunnel: outstanding %u", outstanding);
1137 
1138  /* if there are packets outstanding, we won't verdict this one */
1139  if (IS_TUNNEL_ROOT_PKT(p) && !IS_TUNNEL_PKT_VERDICTED(p) && !outstanding) {
1140  // verdict
1141  SCLogDebug("root %p: verdict", p);
1142  } else if (!IS_TUNNEL_ROOT_PKT(p) && outstanding == 1 && p->root && IS_TUNNEL_PKT_VERDICTED(p->root)) {
1143  // verdict
1144  SCLogDebug("tunnel %p: verdict", p);
1145  } else {
1146  verdict = false;
1147  }
1148  SCMutexUnlock(m);
1149  return verdict;
1150 }
1151 
1152 #endif /* __DECODE_H__ */
1153 
CaptureStats
struct CaptureStats_ CaptureStats
rwr_lock_cnt
__thread uint64_t rwr_lock_cnt
Packet_::greh
GREHdr * greh
Definition: decode.h:537
decode-ethernet.h
decode-raw.h
decode-tcp.h
DecodeThreadVars_::counter_defrag_ipv4_reassembled
uint16_t counter_defrag_ipv4_reassembled
Definition: decode.h:662
Packet_::proto
uint8_t proto
Definition: decode.h:431
DecodeIPV6
int DecodeIPV6(ThreadVars *, DecodeThreadVars *, Packet *, const uint8_t *, uint16_t)
Definition: decode-ipv6.c:580
DecodeERSPAN
int DecodeERSPAN(ThreadVars *, DecodeThreadVars *, Packet *, const uint8_t *, uint32_t)
ERSPAN Type II.
Definition: decode-erspan.c:60
source-nflog.h
decode-mpls.h
DecodeThreadVars_::counter_flow_udp
uint16_t counter_flow_udp
Definition: decode.h:672
len
uint8_t len
Definition: app-layer-dnp3.h:4
DecodeThreadVars_::counter_bytes
uint16_t counter_bytes
Definition: decode.h:629
DECODE_TUNNEL_IPV6
@ DECODE_TUNNEL_IPV6
Definition: decode.h:885
source-pcap.h
CaptureStats_::counter_ips_blocked
uint16_t counter_ips_blocked
Definition: decode.h:687
PktProfilingData_::ticks_end
uint64_t ticks_end
Definition: decode.h:346
decode-erspan.h
decode-vxlan.h
PacketAlert_::s
const struct Signature_ * s
Definition: decode.h:274
DecodeThreadVars_::counter_eth
uint16_t counter_eth
Definition: decode.h:635
IPV4Vars_
Definition: decode-ipv4.h:172
offset
uint64_t offset
Definition: util-streaming-buffer.h:2
Packet_::sctph
SCTPHdr * sctph
Definition: decode.h:527
NapatechPacketVars_
Definition: util-napatech.h:29
Packet_::code
uint8_t code
Definition: decode.h:420
PacketFreeOrRelease
void PacketFreeOrRelease(Packet *p)
Return a packet to where it was allocated.
Definition: decode.c:165
DecodeThreadVars_::counter_flow_icmp4
uint16_t counter_flow_icmp4
Definition: decode.h:673
DecodeThreadVars_::counter_vxlan
uint16_t counter_vxlan
Definition: decode.h:651
DecodeThreadVars_::counter_max_pkt_size
uint16_t counter_max_pkt_size
Definition: decode.h:631
PacketCopyData
int PacketCopyData(Packet *p, const uint8_t *pktdata, uint32_t pktlen)
Copy data to Packet payload and set packet length.
Definition: decode.c:262
decode-pppoe.h
Packet_::vlan_id
uint16_t vlan_id[2]
Definition: decode.h:436
PacketBypassCallback
void PacketBypassCallback(Packet *p)
Definition: decode.c:404
DecodeSCTP
int DecodeSCTP(ThreadVars *, DecodeThreadVars *, Packet *, const uint8_t *, uint16_t)
Definition: decode-sctp.c:62
ICMPV4Vars_
Definition: decode-icmpv4.h:184
DecodeThreadVars_::counter_avg_pkt_size
uint16_t counter_avg_pkt_size
Definition: decode.h:630
PktProfiling_
Per pkt stats storage.
Definition: decode.h:375
Address_::address_un_data16
uint16_t address_un_data16[8]
Definition: decode.h:115
Packet_::icmp_d
struct Packet_::@45::@53 icmp_d
PktProfilingPrefilterData_::engines
PktProfilingPrefilterEngine * engines
Definition: decode.h:370
DecodePPP
int DecodePPP(ThreadVars *, DecodeThreadVars *, Packet *, const uint8_t *, uint32_t)
Definition: decode-ppp.c:43
Address_::address_un_in6
struct in6_addr address_un_in6
Definition: decode.h:117
PktProfilingTmmData_
Per TMM stats storage.
Definition: decode.h:325
IPV6ExtHdrs_
Definition: decode-ipv6.h:214
rww_lock_wait_ticks
__thread uint64_t rww_lock_wait_ticks
PktPool_
Definition: tmqh-packetpool.h:40
Packet_::host_src
struct Host_ * host_src
Definition: decode.h:558
PPPOESessionHdr_
Definition: decode-pppoe.h:37
PacketEngineEvents_::events
uint8_t events[PACKET_ENGINE_EVENT_MAX]
Definition: decode.h:308
CaptureStats_
Definition: decode.h:684
DECODE_TUNNEL_IPV6_TEREDO
@ DECODE_TUNNEL_IPV6_TEREDO
Definition: decode.h:886
SCLogDebug
#define SCLogDebug(...)
Definition: util-debug.h:335
DecodeEthernet
int DecodeEthernet(ThreadVars *, DecodeThreadVars *, Packet *, const uint8_t *, uint32_t)
Definition: decode-ethernet.c:41
Packet_::pcap_cnt
uint64_t pcap_cnt
Definition: decode.h:562
PktProfiling_::ticks_end
uint64_t ticks_end
Definition: decode.h:377
TCPVars_
Definition: decode-tcp.h:152
AddressDebugPrint
void AddressDebugPrint(Address *)
Debug print function for printing addresses.
Definition: decode.c:600
PKT_SRC_DECODER_IPV4
@ PKT_SRC_DECODER_IPV4
Definition: decode.h:51
PacketDefragPktSetup
Packet * PacketDefragPktSetup(Packet *parent, const uint8_t *pkt, uint32_t len, uint8_t proto)
Setup a pseudo packet (reassembled frags)
Definition: decode.c:351
PacketAlerts_::alerts
PacketAlert alerts[PACKET_ALERT_MAX]
Definition: decode.h:295
PacketQueue_
simple fifo queue for packets with mutex and cond Calling the mutex or triggering the cond is respons...
Definition: packet-queue.h:47
Packet_::payload
uint8_t * payload
Definition: decode.h:541
PacketAlerts_::cnt
uint16_t cnt
Definition: decode.h:294
PKT_SRC_CAPTURE_TIMEOUT
@ PKT_SRC_CAPTURE_TIMEOUT
Definition: decode.h:59
DecodeUDP
int DecodeUDP(ThreadVars *, DecodeThreadVars *, Packet *, const uint8_t *, uint16_t)
Definition: decode-udp.c:74
action-globals.h
Packet_::flags
uint32_t flags
Definition: decode.h:444
decode-udp.h
Packet_::action
uint8_t action
Definition: decode.h:545
PktProfilingDetectData
struct PktProfilingDetectData_ PktProfilingDetectData
decode-null.h
Packet_::vlan_idx
uint8_t vlan_idx
Definition: decode.h:437
Flow_
Flow data structure.
Definition: flow.h:342
LiveDevice_
Definition: util-device.h:40
PROF_DETECT_SIZE
@ PROF_DETECT_SIZE
Definition: suricata-common.h:412
PktVar_::next
struct PktVar_ * next
Definition: decode.h:313
DecoderFunc
int(* DecoderFunc)(ThreadVars *tv, DecodeThreadVars *dtv, Packet *p, const uint8_t *pkt, uint32_t len)
Definition: decode.h:947
PktProfilingTmmData_::ticks_end
uint64_t ticks_end
Definition: decode.h:327
spin_lock_cnt
__thread uint64_t spin_lock_cnt
Packet_::ipfw_v
IPFWPacketVars ipfw_v
Definition: decode.h:463
Packet_::pool
struct PktPool_ * pool
Definition: decode.h:600
Packet_::ip4vars
IPV4Vars ip4vars
Definition: decode.h:507
IS_TUNNEL_ROOT_PKT
#define IS_TUNNEL_ROOT_PKT(p)
Definition: decode.h:874
CHECKSUM_VALIDATION_RXONLY
@ CHECKSUM_VALIDATION_RXONLY
Definition: decode.h:44
Packet_::ip6vars
IPV6Vars ip6vars
Definition: decode.h:509
DECODE_TUNNEL_ERSPANI
@ DECODE_TUNNEL_ERSPANI
Definition: decode.h:882
PktProfilingTmmData
struct PktProfilingTmmData_ PktProfilingTmmData
Per TMM stats storage.
DecodeThreadVars_::counter_teredo
uint16_t counter_teredo
Definition: decode.h:654
DecodeThreadVars_::counter_erspan
uint16_t counter_erspan
Definition: decode.h:658
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:221
DecodeVXLAN
int DecodeVXLAN(ThreadVars *, DecodeThreadVars *, Packet *, const uint8_t *, uint32_t)
Definition: decode-vxlan.c:119
AppLayerDecoderEventsResetEvents
void AppLayerDecoderEventsResetEvents(AppLayerDecoderEvents *events)
Definition: app-layer-events.c:141
Packet_::pppoesh
PPPOESessionHdr * pppoesh
Definition: decode.h:534
DecodeThreadVars_::counter_raw
uint16_t counter_raw
Definition: decode.h:644
SCMutexLock
#define SCMutexLock(mut)
Definition: threads-debug.h:117
DecodeThreadVars
struct DecodeThreadVars_ DecodeThreadVars
Structure to hold thread specific data for all decode modules.
PktProfilingPrefilterData_
Definition: decode.h:369
PacketAlerts_::drop
PacketAlert drop
Definition: decode.h:298
Address_
Definition: decode.h:111
CHECKSUM_VALIDATION_DISABLE
@ CHECKSUM_VALIDATION_DISABLE
Definition: decode.h:41
DecodeThreadVars_::counter_flow_tcp
uint16_t counter_flow_tcp
Definition: decode.h:671
CHECKSUM_VALIDATION_KERNEL
@ CHECKSUM_VALIDATION_KERNEL
Definition: decode.h:45
PacketDecodeFinalize
void PacketDecodeFinalize(ThreadVars *tv, DecodeThreadVars *dtv, Packet *p)
Finalize decoding of a packet.
Definition: decode.c:118
Address_::address_un_data32
uint32_t address_un_data32[4]
Definition: decode.h:114
Packet_::tcpvars
TCPVars tcpvars
Definition: decode.h:515
proto
uint8_t proto
Definition: decode-template.h:2
m
SCMutex m
Definition: flow-hash.h:5
Packet_::l4vars
union Packet_::@51 l4vars
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:188
PktProfilingDetectData_::ticks_end
uint64_t ticks_end
Definition: decode.h:351
PacketAlert
struct PacketAlert_ PacketAlert
Packet_::host_dst
struct Host_ * host_dst
Definition: decode.h:559
PktProfilingLoggerData
struct PktProfilingLoggerData_ PktProfilingLoggerData
Packet_::flowflags
uint8_t flowflags
Definition: decode.h:440
PktProfilingPrefilterEngine
struct PktProfilingPrefilterEngine_ PktProfilingPrefilterEngine
Packet_::BypassPacketsFlow
int(* BypassPacketsFlow)(struct Packet_ *)
Definition: decode.h:488
ALPROTO_MAX
@ ALPROTO_MAX
Definition: app-layer-protos.h:66
PktProfiling_::app
PktProfilingAppData app[ALPROTO_MAX]
Definition: decode.h:381
PktProfiling_::ticks_start
uint64_t ticks_start
Definition: decode.h:376
DecodeUnregisterCounters
void DecodeUnregisterCounters(void)
Definition: decode.c:467
Packet_::payload_len
uint16_t payload_len
Definition: decode.h:542
Packet_::alerts
PacketAlerts alerts
Definition: decode.h:556
Packet_::tunnel_tpr_cnt
uint16_t tunnel_tpr_cnt
Definition: decode.h:592
AppLayerDecoderEvents_
Data structure to store app layer decoder events.
Definition: app-layer-events.h:34
Packet_::app_layer_events
AppLayerDecoderEvents * app_layer_events
Definition: decode.h:568
Packet_::events
PacketEngineEvents events
Definition: decode.h:566
PktProfilingAppData_::ticks_spent
uint64_t ticks_spent
Definition: decode.h:356
DecodeRaw
int DecodeRaw(ThreadVars *, DecodeThreadVars *, Packet *, const uint8_t *, uint32_t)
Definition: decode-raw.c:46
PacketAlert_::tx_id
uint64_t tx_id
Definition: decode.h:275
PacketAlert_::action
uint8_t action
Definition: decode.h:272
detect-reference.h
Packet_::datalink
int datalink
Definition: decode.h:575
Packet_::profile
PktProfiling * profile
Definition: decode.h:603
CHECKSUM_VALIDATION_ENABLE
@ CHECKSUM_VALIDATION_ENABLE
Definition: decode.h:42
__attribute__
enum @34 __attribute__
DNP3 application header.
Definition: detect-engine-analyzer.c:583
decode-gre.h
rwr_lock_contention
__thread uint64_t rwr_lock_contention
DecodeRegisterPerfCounters
void DecodeRegisterPerfCounters(DecodeThreadVars *, ThreadVars *)
Definition: decode.c:477
Packet_::level3_comp_csum
int32_t level3_comp_csum
Definition: decode.h:497
DECODE_TUNNEL_ERSPANII
@ DECODE_TUNNEL_ERSPANII
Definition: decode.h:881
CHECKSUM_VALIDATION_AUTO
@ CHECKSUM_VALIDATION_AUTO
Definition: decode.h:43
DecodeThreadVars_::counter_ipv6inipv6
uint16_t counter_ipv6inipv6
Definition: decode.h:657
mutex_lock_cnt
__thread uint64_t mutex_lock_cnt
Packet_::pktlen
uint32_t pktlen
Definition: decode.h:550
decode-ipv6.h
TUNNEL_PKT_TPR
#define TUNNEL_PKT_TPR(p)
Definition: decode.h:869
Packet_::level4_comp_csum
int32_t level4_comp_csum
Definition: decode.h:499
PKT_SRC_WIRE
@ PKT_SRC_WIRE
Definition: decode.h:49
source-nfq.h
Packet_::pktvar
PktVar * pktvar
Definition: decode.h:491
CaptureStats_::counter_ips_rejected
uint16_t counter_ips_rejected
Definition: decode.h:688
DecodeThreadVars_::counter_icmpv4
uint16_t counter_icmpv4
Definition: decode.h:640
DecodeThreadVars_::counter_ppp
uint16_t counter_ppp
Definition: decode.h:647
PacketAlert_::num
SigIntId num
Definition: decode.h:271
Packet_::icmp_s
struct Packet_::@43::@52 icmp_s
SCMutexUnlock
#define SCMutexUnlock(mut)
Definition: threads-debug.h:119
PacketSwap
void PacketSwap(Packet *p)
switch direction of a packet
Definition: decode.c:442
DecodeMPLS
int DecodeMPLS(ThreadVars *, DecodeThreadVars *, Packet *, const uint8_t *, uint32_t)
Definition: decode-mpls.c:47
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:56
PktSrcEnum
PktSrcEnum
Definition: decode.h:48
flow-worker.h
PktVar_::value
uint8_t * value
Definition: decode.h:319
PktProfilingAppData
struct PktProfilingAppData_ PktProfilingAppData
DecodeTunnelProto
DecodeTunnelProto
Definition: decode.h:879
Packet_::prev
struct Packet_ * prev
Definition: decode.h:572
Packet
struct Packet_ Packet
decode-ppp.h
Packet_::pcap_v
PcapPacketVars pcap_v
Definition: decode.h:481
IS_TUNNEL_PKT_VERDICTED
#define IS_TUNNEL_PKT_VERDICTED(p)
Definition: decode.h:876
CaptureStatsSetup
void CaptureStatsSetup(ThreadVars *tv, CaptureStats *s)
Definition: decode.c:723
PKT_SRC_DECODER_TEREDO
@ PKT_SRC_DECODER_TEREDO
Definition: decode.h:53
DecodeTEMPLATE
int DecodeTEMPLATE(ThreadVars *, DecodeThreadVars *, Packet *, const uint8_t *, uint32_t)
Function to decode TEMPLATE packets.
Definition: decode-template.c:49
Packet_::tunnel_rtv_cnt
uint16_t tunnel_rtv_cnt
Definition: decode.h:590
DecodeVLAN
int DecodeVLAN(ThreadVars *, DecodeThreadVars *, Packet *, const uint8_t *, uint32_t)
Definition: decode-vlan.c:62
Packet_::ethh
EthernetHdr * ethh
Definition: decode.h:494
ThreadVars_
Per thread variable structure.
Definition: threadvars.h:57
PktProfilingData_
Definition: decode.h:344
DECODE_TUNNEL_PPP
@ DECODE_TUNNEL_PPP
Definition: decode.h:887
Packet_::sp
Port sp
Definition: decode.h:416
PktProfiling_::logger
PktProfilingLoggerData logger[LOGGER_SIZE]
Definition: decode.h:383
PacketFree
void PacketFree(Packet *p)
Return a malloced packet.
Definition: decode.c:105
PktSrcToString
const char * PktSrcToString(enum PktSrcEnum pkt_src)
Definition: decode.c:669
PktVar
struct PktVar_ PktVar
DecodeThreadVars_::counter_vlan_qinq
uint16_t counter_vlan_qinq
Definition: decode.h:650
IPV6Vars_
get the highest proto/next header field we know
Definition: decode-ipv6.h:103
PktProfilingDetectData_
Definition: decode.h:349
PktVar_::key
uint8_t * key
Definition: decode.h:318
decode-icmpv6.h
source-pfring.h
DecodeSll
int DecodeSll(ThreadVars *, DecodeThreadVars *, Packet *, const uint8_t *, uint32_t)
Definition: decode-sll.c:39
DecodeThreadVars_::counter_defrag_ipv6_timeouts
uint16_t counter_defrag_ipv6_timeouts
Definition: decode.h:666
LOGGER_SIZE
@ LOGGER_SIZE
Definition: suricata-common.h:465
PacketCallocExtPkt
int PacketCallocExtPkt(Packet *p, int datalen)
Definition: decode.c:195
Address
struct Address_ Address
AppLayerDecoderEventsFreeEvents
void AppLayerDecoderEventsFreeEvents(AppLayerDecoderEvents **events)
Definition: app-layer-events.c:148
rwr_lock_wait_ticks
__thread uint64_t rwr_lock_wait_ticks
PKT_SRC_STREAM_TCP_DETECTLOG_FLUSH
@ PKT_SRC_STREAM_TCP_DETECTLOG_FLUSH
Definition: decode.h:56
DECODE_TUNNEL_VLAN
@ DECODE_TUNNEL_VLAN
Definition: decode.h:883
Packet_::icmpv6h
ICMPV6Hdr * icmpv6h
Definition: decode.h:531
util-napatech.h
PKT_SRC_DECODER_IPV6
@ PKT_SRC_DECODER_IPV6
Definition: decode.h:52
CaptureStats_::counter_ips_accepted
uint16_t counter_ips_accepted
Definition: decode.h:686
IPV6Hdr_
Definition: decode-ipv6.h:31
Packet_
Definition: decode.h:408
DECODE_TUNNEL_IPV4
@ DECODE_TUNNEL_IPV4
Definition: decode.h:884
decode-sll.h
DecodeThreadVars_::app_tctx
AppLayerThreadCtx * app_tctx
Definition: decode.h:625
DecodeThreadVars_::counter_defrag_ipv4_timeouts
uint16_t counter_defrag_ipv4_timeouts
Definition: decode.h:663
decode-icmpv4.h
rww_lock_cnt
__thread uint64_t rww_lock_cnt
DecodeThreadVars_::counter_sll
uint16_t counter_sll
Definition: decode.h:643
source-ipfw.h
Address_::address_un_data8
uint8_t address_un_data8[16]
Definition: decode.h:116
TMM_SIZE
@ TMM_SIZE
Definition: tm-threads-common.h:73
PacketEngineEvents_
Definition: decode.h:306
source-netmap.h
Packet_::ip4h
IPV4Hdr * ip4h
Definition: decode.h:501
Port
uint16_t Port
Definition: decode.h:236
DecodeThreadVars_::counter_sctp
uint16_t counter_sctp
Definition: decode.h:646
Packet_::livedev
struct LiveDevice_ * livedev
Definition: decode.h:554
source-windivert.h
DecodeThreadVars_::counter_invalid
uint16_t counter_invalid
Definition: decode.h:633
DecodeThreadVars_::counter_ieee8021ah
uint16_t counter_ieee8021ah
Definition: decode.h:652
DecodeTCP
int DecodeTCP(ThreadVars *, DecodeThreadVars *, Packet *, const uint8_t *, uint16_t)
Definition: decode-tcp.c:234
DecodeThreadVars_::counter_ipv4inipv6
uint16_t counter_ipv4inipv6
Definition: decode.h:656
DecodeThreadVars_::counter_vlan
uint16_t counter_vlan
Definition: decode.h:649
DECODE_TUNNEL_ETHERNET
@ DECODE_TUNNEL_ETHERNET
Definition: decode.h:880
DecodeThreadVars_::counter_tcp
uint16_t counter_tcp
Definition: decode.h:638
DecodeThreadVars_::counter_pkts
uint16_t counter_pkts
Definition: decode.h:628
decode-events.h
PktProfilingPrefilterEngine_
Definition: decode.h:365
PktProfilingData_::ticks_start
uint64_t ticks_start
Definition: decode.h:345
DecodeNull
int DecodeNull(ThreadVars *, DecodeThreadVars *, Packet *, const uint8_t *, uint32_t)
Definition: decode-null.c:48
dtv
DecodeThreadVars * dtv
Definition: fuzz_decodepcapfile.c:33
DecodeIPV4
int DecodeIPV4(ThreadVars *, DecodeThreadVars *, Packet *, const uint8_t *, uint16_t)
Definition: decode-ipv4.c:517
PktProfilingPrefilterData
struct PktProfilingPrefilterData_ PktProfilingPrefilterData
Packet_::ntpv
NapatechPacketVars ntpv
Definition: decode.h:606
decode-vlan.h
IPV4Hdr_
Definition: decode-ipv4.h:70
default_packet_size
uint32_t default_packet_size
Definition: decode.c:71
PacketAlert_::flags
uint8_t flags
Definition: decode.h:273
decode-ipv4.h
Packet_::ppph
PPPHdr * ppph
Definition: decode.h:533
Packet_::nfq_v
NFQPacketVars nfq_v
Definition: decode.h:460
ICMPV6Hdr_
Definition: decode-icmpv6.h:144
PktProfiling_::detect
PktProfilingDetectData detect[PROF_DETECT_SIZE]
Definition: decode.h:382
Packet_::icmpv4vars
ICMPV4Vars icmpv4vars
Definition: decode.h:516
Packet_::ReleasePacket
void(* ReleasePacket)(struct Packet_ *)
Definition: decode.h:485
Packet_::tenant_id
uint32_t tenant_id
Definition: decode.h:595
Packet_::flow
struct Flow_ * flow
Definition: decode.h:446
DecodeGRE
int DecodeGRE(ThreadVars *, DecodeThreadVars *, Packet *, const uint8_t *, uint32_t)
Function to decode GRE packets.
Definition: decode-gre.c:46
ICMPV6Vars_
Definition: decode-icmpv6.h:162
PktProfiling
struct PktProfiling_ PktProfiling
Per pkt stats storage.
DecodeThreadVarsFree
void DecodeThreadVarsFree(ThreadVars *, DecodeThreadVars *)
Definition: decode.c:636
IPFWPacketVars_
Definition: source-ipfw.h:31
PktProfilingLoggerData_::ticks_end
uint64_t ticks_end
Definition: decode.h:361
PktProfilingPrefilterEngine_::ticks_spent
uint64_t ticks_spent
Definition: decode.h:366
Packet_::ts
struct timeval ts
Definition: decode.h:452
DecodeGlobalConfig
void DecodeGlobalConfig(void)
Definition: decode.c:731
ChecksumValidationMode
ChecksumValidationMode
Definition: decode.h:40
suricata-common.h
PKT_SRC_FFR
@ PKT_SRC_FFR
Definition: decode.h:55
DecodeIPV6FragHeader
void DecodeIPV6FragHeader(Packet *p, const uint8_t *pkt, uint16_t hdrextlen, uint16_t plen, uint16_t prev_hdrextlen)
Definition: decode-ipv6.c:100
NFQPacketVars_
Definition: source-nfq.h:39
DecodeThreadVars_::counter_flow_icmp6
uint16_t counter_flow_icmp6
Definition: decode.h:674
Packet_::tcph
TCPHdr * tcph
Definition: decode.h:523
DecodeThreadVars_::counter_ipv6
uint16_t counter_ipv6
Definition: decode.h:637
PROFILE_FLOWWORKER_SIZE
@ PROFILE_FLOWWORKER_SIZE
Definition: flow-worker.h:27
CaptureStats_::counter_ips_replaced
uint16_t counter_ips_replaced
Definition: decode.h:689
DecodeThreadVars_::counter_gre
uint16_t counter_gre
Definition: decode.h:648
Packet_::ext_pkt
uint8_t * ext_pkt
Definition: decode.h:551
PacketAlerts
struct PacketAlerts_ PacketAlerts
DecodeICMPV4
int DecodeICMPV4(ThreadVars *, DecodeThreadVars *, Packet *, const uint8_t *, uint32_t)
Main ICMPv4 decoding function.
Definition: decode-icmpv4.c:155
Address_::address
union Address_::@42 address
DecodeThreadVars_::counter_defrag_ipv6_reassembled
uint16_t counter_defrag_ipv6_reassembled
Definition: decode.h:665
DecodeThreadVars_::counter_udp
uint16_t counter_udp
Definition: decode.h:639
PacketUpdateEngineEventCounters
void PacketUpdateEngineEventCounters(ThreadVars *tv, DecodeThreadVars *dtv, Packet *p)
Definition: decode.c:125
decode-sctp.h
CaptureStatsUpdate
void CaptureStatsUpdate(ThreadVars *tv, CaptureStats *s, const Packet *p)
Definition: decode.c:710
PKT_SRC_DEFRAG
@ PKT_SRC_DEFRAG
Definition: decode.h:54
Packet_::icmpv4h
ICMPV4Hdr * icmpv4h
Definition: decode.h:529
tv
ThreadVars * tv
Definition: fuzz_decodepcapfile.c:32
PfringPacketVars_
per packet Pfring vars
Definition: source-pfring.h:61
NetmapPacketVars_
Definition: source-netmap.h:72
DecodeThreadVars_::counter_ipv4
uint16_t counter_ipv4
Definition: decode.h:636
threadvars.h
PacketGetFromAlloc
Packet * PacketGetFromAlloc(void)
Get a malloced packet.
Definition: decode.c:144
TUNNEL_PKT_RTV
#define TUNNEL_PKT_RTV(p)
Definition: decode.h:868
source-af-packet.h
PKT_SRC_DECODER_VXLAN
@ PKT_SRC_DECODER_VXLAN
Definition: decode.h:57
spin_lock_contention
__thread uint64_t spin_lock_contention
Packet_::next
struct Packet_ * next
Definition: decode.h:571
Packet_::flow_hash
uint32_t flow_hash
Definition: decode.h:450
PACKET_ALERT_MAX
#define PACKET_ALERT_MAX
Definition: decode.h:291
Packet_::root
struct Packet_ * root
Definition: decode.h:578
DecodeThreadVars_::counter_pppoe
uint16_t counter_pppoe
Definition: decode.h:653
PktProfilingPrefilterData_::size
uint32_t size
Definition: decode.h:371
DecodeThreadVars_::counter_mpls
uint16_t counter_mpls
Definition: decode.h:655
PKT_SRC_DETECT_RELOAD_FLUSH
@ PKT_SRC_DETECT_RELOAD_FLUSH
Definition: decode.h:58
PktProfilingData
struct PktProfilingData_ PktProfilingData
Packet_::pkt_src
uint8_t pkt_src
Definition: decode.h:547
DecodeThreadVars_
Structure to hold thread specific data for all decode modules.
Definition: decode.h:622
PACKET_ENGINE_EVENT_MAX
#define PACKET_ENGINE_EVENT_MAX
Definition: decode.h:303
Packet_::recursion_level
uint8_t recursion_level
Definition: decode.h:434
PktProfilingLoggerData_
Definition: decode.h:359
PktProfiling_::tmm
PktProfilingTmmData tmm[TMM_SIZE]
Definition: decode.h:379
Signature_
Signature container.
Definition: detect.h:522
DecodeThreadVars_::output_flow_thread_data
void * output_flow_thread_data
Definition: decode.h:680
Packet_::pppoedh
PPPOEDiscoveryHdr * pppoedh
Definition: decode.h:535
DecodeThreadVarsAlloc
DecodeThreadVars * DecodeThreadVarsAlloc(ThreadVars *)
Alloc and setup DecodeThreadVars.
Definition: decode.c:617
DecodeThreadVars_::counter_defrag_max_hit
uint16_t counter_defrag_max_hit
Definition: decode.h:667
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:656
mutex_lock_contention
__thread uint64_t mutex_lock_contention
PktVar_::value_len
uint16_t value_len
Definition: decode.h:317
app-layer-protos.h
DecodeThreadVars_::counter_null
uint16_t counter_null
Definition: decode.h:645
DecodeThreadVars_::counter_icmpv6
uint16_t counter_icmpv6
Definition: decode.h:641
Packet_::udph
UDPHdr * udph
Definition: decode.h:525
rww_lock_contention
__thread uint64_t rww_lock_contention
PcapPacketVars_
Definition: source-pcap.h:35
Address_::family
char family
Definition: decode.h:112
Packet_::dst
Address dst
Definition: decode.h:414
PKT_SRC_DECODER_GRE
@ PKT_SRC_DECODER_GRE
Definition: decode.h:50
PktProfilingTmmData_::ticks_start
uint64_t ticks_start
Definition: decode.h:326
PacketAlert_
Definition: decode.h:270
PktProfilingLoggerData_::ticks_spent
uint64_t ticks_spent
Definition: decode.h:362
DecodeThreadVars_::counter_flow_memcap
uint16_t counter_flow_memcap
Definition: decode.h:669
DecodeThreadVars_::counter_defrag_ipv6_fragments
uint16_t counter_defrag_ipv6_fragments
Definition: decode.h:664
PktVar_
Definition: decode.h:311
AFPPacketVars_
per packet AF_PACKET vars
Definition: source-af-packet.h:143
PacketEngineEvents
struct PacketEngineEvents_ PacketEngineEvents
PktProfilingDetectData_::ticks_start
uint64_t ticks_start
Definition: decode.h:350
PacketDefragPktSetupParent
void PacketDefragPktSetupParent(Packet *parent)
inform defrag "parent" that a pseudo packet is now associated to it.
Definition: decode.c:390
Packet_::ip6h
IPV6Hdr * ip6h
Definition: decode.h:503
Packet_::icmpv6vars
ICMPV6Vars icmpv6vars
Definition: decode.h:517
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:278
PktProfiling_::flowworker
PktProfilingData flowworker[PROFILE_FLOWWORKER_SIZE]
Definition: decode.h:380
spin_lock_wait_ticks
__thread uint64_t spin_lock_wait_ticks
NFLOGPacketVars_
Definition: source-nflog.h:54
DecodeTunnel
int DecodeTunnel(ThreadVars *, DecodeThreadVars *, Packet *, const uint8_t *, uint32_t, enum DecodeTunnelProto) __attribute__((warn_unused_result))
Definition: decode.c:76
SigIntId
#define SigIntId
Definition: suricata-common.h:280
PacketAlerts_
Definition: decode.h:293
Packet_::dp
Port dp
Definition: decode.h:424
PktVar_::key_len
uint16_t key_len
Definition: decode.h:316
PktProfilingAppData_
Definition: decode.h:355
Host_
Definition: host.h:58
g_default_mtu
int g_default_mtu
Definition: suricata.c:221
PktProfiling_::proto_detect
uint64_t proto_detect
Definition: decode.h:384
DecodePPPOESession
int DecodePPPOESession(ThreadVars *, DecodeThreadVars *, Packet *, const uint8_t *, uint32_t)
Main decoding function for PPPOE Session packets.
Definition: decode-pppoe.c:130
Packet_::type
uint8_t type
Definition: decode.h:419
AppLayerDecoderEvents_::events
uint8_t * events
Definition: app-layer-events.h:36
DECODE_EVENT_MAX
@ DECODE_EVENT_MAX
Definition: decode-events.h:262
SCMutex
#define SCMutex
Definition: threads-debug.h:114
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:180
PktProfilingLoggerData_::ticks_start
uint64_t ticks_start
Definition: decode.h:360
Packet_::src
Address src
Definition: decode.h:413
DecodeERSPANTypeI
int DecodeERSPANTypeI(ThreadVars *, DecodeThreadVars *, Packet *, const uint8_t *, uint32_t)
Functions to decode ERSPAN Type I and II packets.
Definition: decode-erspan.c:49
DecodeUpdatePacketCounters
void DecodeUpdatePacketCounters(ThreadVars *tv, const DecodeThreadVars *dtv, const Packet *p)
Definition: decode.c:583
DecodeThreadVars_::counter_engine_events
uint16_t counter_engine_events[DECODE_EVENT_MAX]
Definition: decode.h:676
Packet_::tunnel_mutex
SCMutex tunnel_mutex
Definition: decode.h:588
Packet_::ip6eh
IPV6ExtHdrs ip6eh
Definition: decode.h:510
mutex_lock_wait_ticks
__thread uint64_t mutex_lock_wait_ticks
PktProfilingDetectData_::ticks_spent
uint64_t ticks_spent
Definition: decode.h:352
PktVar_::id
uint32_t id
Definition: decode.h:312
DecodeThreadVars_::counter_defrag_ipv4_fragments
uint16_t counter_defrag_ipv4_fragments
Definition: decode.h:661
PacketEngineEvents_::cnt
uint8_t cnt
Definition: decode.h:307
DecodePPPOEDiscovery
int DecodePPPOEDiscovery(ThreadVars *, DecodeThreadVars *, Packet *, const uint8_t *, uint32_t)
Main decoding function for PPPOE Discovery packets.
Definition: decode-pppoe.c:50