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