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