Go to the documentation of this file.
24 #ifndef SURICATA_DECODE_H
25 #define SURICATA_DECODE_H
98 struct DetectionEngineThreadCtx_;
118 #define addr_data32 address.address_un_data32
119 #define addr_data16 address.address_un_data16
120 #define addr_data8 address.address_un_data8
121 #define addr_in6addr address.address_un_in6
123 #define COPY_ADDRESS(a, b) do { \
124 (b)->family = (a)->family; \
125 (b)->addr_data32[0] = (a)->addr_data32[0]; \
126 (b)->addr_data32[1] = (a)->addr_data32[1]; \
127 (b)->addr_data32[2] = (a)->addr_data32[2]; \
128 (b)->addr_data32[3] = (a)->addr_data32[3]; \
136 #define SET_IPV4_SRC_ADDR(ip4h, a) \
138 (a)->family = AF_INET; \
139 (a)->addr_data32[0] = (uint32_t)(ip4h)->s_ip_src.s_addr; \
140 (a)->addr_data32[1] = 0; \
141 (a)->addr_data32[2] = 0; \
142 (a)->addr_data32[3] = 0; \
145 #define SET_IPV4_DST_ADDR(ip4h, a) \
147 (a)->family = AF_INET; \
148 (a)->addr_data32[0] = (uint32_t)(ip4h)->s_ip_dst.s_addr; \
149 (a)->addr_data32[1] = 0; \
150 (a)->addr_data32[2] = 0; \
151 (a)->addr_data32[3] = 0; \
155 #define SET_IPV6_SRC_ADDR(ip6h, a) \
157 (a)->family = AF_INET6; \
158 (a)->addr_data32[0] = (ip6h)->s_ip6_src[0]; \
159 (a)->addr_data32[1] = (ip6h)->s_ip6_src[1]; \
160 (a)->addr_data32[2] = (ip6h)->s_ip6_src[2]; \
161 (a)->addr_data32[3] = (ip6h)->s_ip6_src[3]; \
164 #define SET_IPV6_DST_ADDR(ip6h, a) \
166 (a)->family = AF_INET6; \
167 (a)->addr_data32[0] = (ip6h)->s_ip6_dst[0]; \
168 (a)->addr_data32[1] = (ip6h)->s_ip6_dst[1]; \
169 (a)->addr_data32[2] = (ip6h)->s_ip6_dst[2]; \
170 (a)->addr_data32[3] = (ip6h)->s_ip6_dst[3]; \
175 #define SET_TCP_SRC_PORT(pkt, prt) do { \
176 SET_PORT(TCP_GET_SRC_PORT((pkt)), *(prt)); \
179 #define SET_TCP_DST_PORT(pkt, prt) do { \
180 SET_PORT(TCP_GET_DST_PORT((pkt)), *(prt)); \
185 #define SET_UDP_SRC_PORT(pkt, prt) do { \
186 SET_PORT(UDP_GET_SRC_PORT((pkt)), *(prt)); \
188 #define SET_UDP_DST_PORT(pkt, prt) do { \
189 SET_PORT(UDP_GET_DST_PORT((pkt)), *(prt)); \
192 #define GET_IPV4_SRC_ADDR_U32(p) ((p)->src.addr_data32[0])
193 #define GET_IPV4_DST_ADDR_U32(p) ((p)->dst.addr_data32[0])
194 #define GET_IPV4_SRC_ADDR_PTR(p) ((p)->src.addr_data32)
195 #define GET_IPV4_DST_ADDR_PTR(p) ((p)->dst.addr_data32)
197 #define GET_IPV6_SRC_IN6ADDR(p) ((p)->src.addr_in6addr)
198 #define GET_IPV6_DST_IN6ADDR(p) ((p)->dst.addr_in6addr)
199 #define GET_IPV6_SRC_ADDR(p) ((p)->src.addr_data32)
200 #define GET_IPV6_DST_ADDR(p) ((p)->dst.addr_data32)
201 #define GET_TCP_SRC_PORT(p) ((p)->sp)
202 #define GET_TCP_DST_PORT(p) ((p)->dp)
204 #define GET_PKT_LEN(p) (p)->pktlen
205 #define GET_PKT_DATA(p) (((p)->ext_pkt == NULL) ? GET_PKT_DIRECT_DATA(p) : (p)->ext_pkt)
206 #define GET_PKT_DIRECT_DATA(p) (p)->pkt_data
207 #define GET_PKT_DIRECT_MAX_SIZE(p) (default_packet_size)
209 #define SET_PKT_LEN(p, len) do { \
210 (p)->pktlen = (len); \
215 #define SET_PORT(v, p) ((p) = (v))
216 #define COPY_PORT(a,b) ((b) = (a))
218 #define CMP_ADDR(a1, a2) \
219 (((a1)->addr_data32[3] == (a2)->addr_data32[3] && \
220 (a1)->addr_data32[2] == (a2)->addr_data32[2] && \
221 (a1)->addr_data32[1] == (a2)->addr_data32[1] && \
222 (a1)->addr_data32[0] == (a2)->addr_data32[0]))
223 #define CMP_PORT(p1, p2) \
228 #define IP_GET_RAW_VER(pkt) ((((pkt)[0] & 0xf0) >> 4))
230 #define PKT_IS_TCP(p) (((p)->tcph != NULL))
231 #define PKT_IS_UDP(p) (((p)->udph != NULL))
232 #define PKT_IS_ICMPV4(p) (((p)->icmpv4h != NULL))
233 #define PKT_IS_ICMPV6(p) (((p)->icmpv6h != NULL))
234 #define PKT_IS_TOSERVER(p) (((p)->flowflags & FLOW_PKT_TOSERVER))
235 #define PKT_IS_TOCLIENT(p) (((p)->flowflags & FLOW_PKT_TOCLIENT))
249 #define PACKET_ALERT_FLAG_APPLY_ACTION_TO_FLOW 0x1
251 #define PACKET_ALERT_FLAG_STATE_MATCH 0x02
253 #define PACKET_ALERT_FLAG_STREAM_MATCH 0x04
255 #define PACKET_ALERT_FLAG_TX 0x08
257 #define PACKET_ALERT_RATE_FILTER_MODIFIED 0x10
259 #define PACKET_ALERT_FLAG_FRAME 0x20
262 #define PACKET_ALERT_MAX 15
280 #define PACKET_ENGINE_EVENT_MAX 15
305 #ifdef PROFILE_LOCKING
541 WinDivertPacketVars windivert_v;
658 static inline bool PacketIsIPv4(
const Packet *p);
659 static inline bool PacketIsIPv6(
const Packet *p);
662 #define DEFAULT_MTU 1500
663 #define MINIMUM_MTU 68
665 #define DEFAULT_PACKET_SIZE (DEFAULT_MTU + ETHERNET_HEADER_LEN)
667 #define MAX_PAYLOAD_SIZE (IPV6_HEADER_LEN + 65536 + 28)
669 #define SIZE_OF_PACKET (default_packet_size + sizeof(Packet))
671 static inline bool PacketIsIPv4(
const Packet *p)
682 static inline IPV4Hdr *PacketSetIPV4(
Packet *p,
const uint8_t *buf)
691 static inline uint8_t PacketGetIPProto(
const Packet *p)
696 if (PacketIsIPv4(p)) {
697 const IPV4Hdr *hdr = PacketGetIPv4(p);
699 }
else if (PacketIsIPv6(p)) {
705 static inline uint8_t PacketGetIPv4IPProto(
const Packet *p)
707 if (PacketGetIPv4(p)) {
708 const IPV4Hdr *hdr = PacketGetIPv4(p);
720 static inline IPV6Hdr *PacketSetIPV6(
Packet *p,
const uint8_t *buf)
728 static inline bool PacketIsIPv6(
const Packet *p)
733 static inline void PacketClearL2(
Packet *p)
735 memset(&p->
l2, 0,
sizeof(p->
l2));
739 static inline EthernetHdr *PacketSetEthernet(
Packet *p,
const uint8_t *buf)
747 static inline const EthernetHdr *PacketGetEthernet(
const Packet *p)
753 static inline bool PacketIsEthernet(
const Packet *p)
758 static inline void PacketClearL3(
Packet *p)
760 memset(&p->
l3, 0,
sizeof(p->
l3));
763 static inline void PacketClearL4(
Packet *p)
765 memset(&p->
l4, 0,
sizeof(p->
l4));
768 static inline TCPHdr *PacketSetTCP(
Packet *p,
const uint8_t *buf)
776 static inline const TCPHdr *PacketGetTCP(
const Packet *p)
782 static inline bool PacketIsTCP(
const Packet *p)
787 static inline UDPHdr *PacketSetUDP(
Packet *p,
const uint8_t *buf)
795 static inline const UDPHdr *PacketGetUDP(
const Packet *p)
801 static inline bool PacketIsUDP(
const Packet *p)
806 static inline ICMPV4Hdr *PacketSetICMPv4(
Packet *p,
const uint8_t *buf)
820 static inline bool PacketIsICMPv4(
const Packet *p)
825 static inline const IPV4Hdr *PacketGetICMPv4EmbIPv4(
const Packet *p)
827 const uint8_t *start = (
const uint8_t *)PacketGetICMPv4(p);
832 static inline ICMPV6Hdr *PacketSetICMPv6(
Packet *p,
const uint8_t *buf)
846 static inline bool PacketIsICMPv6(
const Packet *p)
851 static inline SCTPHdr *PacketSetSCTP(
Packet *p,
const uint8_t *buf)
859 static inline const SCTPHdr *PacketGetSCTP(
const Packet *p)
865 static inline bool PacketIsSCTP(
const Packet *p)
870 static inline GREHdr *PacketSetGRE(
Packet *p,
const uint8_t *buf)
878 static inline const GREHdr *PacketGetGRE(
const Packet *p)
884 static inline bool PacketIsGRE(
const Packet *p)
889 static inline ESPHdr *PacketSetESP(
Packet *p,
const uint8_t *buf)
897 static inline const ESPHdr *PacketGetESP(
const Packet *p)
903 static inline bool PacketIsESP(
const Packet *p)
908 static inline const ARPHdr *PacketGetARP(
const Packet *p)
914 static inline ARPHdr *PacketSetARP(
Packet *p,
const uint8_t *buf)
922 static inline bool PacketIsARP(
const Packet *p)
1024 #define PACKET_CLEAR_L4VARS(p) do { \
1025 memset(&(p)->l4vars, 0x00, sizeof((p)->l4vars)); \
1029 #define PACKET_FREE_EXTDATA(p) do { \
1030 if ((p)->ext_pkt) { \
1031 if (!((p)->flags & PKT_ZERO_COPY)) { \
1032 SCFree((p)->ext_pkt); \
1034 (p)->ext_pkt = NULL; \
1038 #define TUNNEL_INCR_PKT_RTV_NOLOCK(p) do { \
1039 ((p)->root ? (p)->root->tunnel_rtv_cnt++ : (p)->tunnel_rtv_cnt++); \
1042 static inline void TUNNEL_INCR_PKT_TPR(
Packet *p)
1050 #define TUNNEL_PKT_RTV(p) ((p)->root ? (p)->root->tunnel_rtv_cnt : (p)->tunnel_rtv_cnt)
1051 #define TUNNEL_PKT_TPR(p) ((p)->root ? (p)->root->tunnel_tpr_cnt : (p)->tunnel_tpr_cnt)
1053 static inline bool PacketTunnelIsVerdicted(
const Packet *p)
1057 static inline void PacketTunnelSetVerdicted(
Packet *p)
1134 uint16_t hdrextlen, uint16_t plen,
1135 uint16_t prev_hdrextlen);
1141 const uint8_t *pkt, uint32_t
len);
1146 #define ENGINE_SET_EVENT(p, e) do { \
1147 SCLogDebug("p %p event %d", (p), e); \
1148 if ((p)->events.cnt < PACKET_ENGINE_EVENT_MAX) { \
1149 (p)->events.events[(p)->events.cnt] = e; \
1150 (p)->events.cnt++; \
1154 #define ENGINE_SET_INVALID_EVENT(p, e) do { \
1155 p->flags |= PKT_IS_INVALID; \
1156 ENGINE_SET_EVENT(p, e); \
1161 #define ENGINE_ISSET_EVENT(p, e) ({ \
1164 for (u = 0; u < (p)->events.cnt; u++) { \
1165 if ((p)->events.events[u] == (e)) { \
1173 #ifndef IPPROTO_IPIP
1174 #define IPPROTO_IPIP 4
1181 #ifndef IPPROTO_DCCP
1182 #define IPPROTO_DCCP 33
1189 #ifndef IPPROTO_SCTP
1190 #define IPPROTO_SCTP 132
1194 #define IPPROTO_MH 135
1199 #define IPPROTO_HIP 139
1202 #ifndef IPPROTO_SHIM6
1203 #define IPPROTO_SHIM6 140
1208 #define DLT_EN10MB 1
1212 #define DLT_C_HDLC 104
1230 #define LINKTYPE_NULL DLT_NULL
1231 #define LINKTYPE_ETHERNET DLT_EN10MB
1232 #define LINKTYPE_LINUX_SLL 113
1233 #define LINKTYPE_PPP 9
1234 #define LINKTYPE_RAW DLT_RAW
1237 #define LINKTYPE_RAW2 101
1238 #define LINKTYPE_IPV4 228
1239 #define LINKTYPE_IPV6 229
1240 #define LINKTYPE_GRE_OVER_IP 778
1241 #define LINKTYPE_CISCO_HDLC DLT_C_HDLC
1242 #define PPP_OVER_GRE 11
1243 #define VLAN_OVER_GRE 13
1248 #define PKT_NOPACKET_INSPECTION BIT_U32(0)
1250 #define PKT_PPP_VJ_UCOMP BIT_U32(1)
1253 #define PKT_NOPAYLOAD_INSPECTION BIT_U32(2)
1257 #define PKT_HAS_TAG BIT_U32(4)
1259 #define PKT_STREAM_ADD BIT_U32(5)
1261 #define PKT_STREAM_EST BIT_U32(6)
1263 #define PKT_STREAM_EOF BIT_U32(7)
1264 #define PKT_HAS_FLOW BIT_U32(8)
1266 #define PKT_PSEUDO_STREAM_END BIT_U32(9)
1269 #define PKT_STREAM_MODIFIED BIT_U32(10)
1275 #define PKT_STREAM_NOPCAPLOG BIT_U32(12)
1280 #define PKT_IGNORE_CHECKSUM BIT_U32(15)
1282 #define PKT_ZERO_COPY BIT_U32(16)
1284 #define PKT_HOST_SRC_LOOKED_UP BIT_U32(17)
1285 #define PKT_HOST_DST_LOOKED_UP BIT_U32(18)
1288 #define PKT_IS_FRAGMENT BIT_U32(19)
1289 #define PKT_IS_INVALID BIT_U32(20)
1290 #define PKT_PROFILE BIT_U32(21)
1294 #define PKT_WANTS_FLOW BIT_U32(22)
1297 #define PKT_PROTO_DETECT_TS_DONE BIT_U32(23)
1298 #define PKT_PROTO_DETECT_TC_DONE BIT_U32(24)
1300 #define PKT_REBUILT_FRAGMENT \
1303 #define PKT_DETECT_HAS_STREAMDATA \
1306 #define PKT_PSEUDO_DETECTLOG_FLUSH BIT_U32(27)
1310 #define PKT_STREAM_NO_EVENTS BIT_U32(28)
1313 #define PKT_FIRST_ALERTS BIT_U32(29)
1314 #define PKT_FIRST_TAG BIT_U32(30)
1317 #define PKT_IS_PSEUDOPKT(p) \
1318 ((p)->flags & (PKT_PSEUDO_STREAM_END|PKT_PSEUDO_DETECTLOG_FLUSH))
1320 #define PKT_SET_SRC(p, src_val) ((p)->pkt_src = src_val)
1322 #define PKT_DEFAULT_MAX_DECODED_LAYERS 16
1325 static inline bool PacketIncreaseCheckLayers(
Packet *p)
1339 static inline void DecodeSetNoPayloadInspectionFlag(
Packet *p)
1348 static inline void DecodeSetNoPacketInspectionFlag(
Packet *p)
1353 static inline bool PacketIsTunnelRoot(
const Packet *p)
1358 static inline bool PacketIsTunnelChild(
const Packet *p)
1363 static inline bool PacketIsTunnel(
const Packet *p)
1368 static inline bool PacketIsNotTunnel(
const Packet *p)
1373 static inline bool VerdictTunnelPacketInternal(
const Packet *p)
1376 SCLogDebug(
"tunnel: outstanding %u", outstanding);
1379 if (PacketIsTunnelRoot(p) && !PacketTunnelIsVerdicted(p) && !outstanding) {
1383 }
else if (PacketIsTunnelChild(p) && outstanding == 1 && p->
root &&
1384 PacketTunnelIsVerdicted(p->
root)) {
1403 static inline bool VerdictTunnelPacket(
Packet *p)
1408 verdict = VerdictTunnelPacketInternal(p);
1414 const int datalink,
Packet *p,
const uint8_t *data,
const uint32_t
len)
1439 "%" PRId32
" not yet supported",
1448 const uint16_t
proto,
Packet *p,
const uint8_t *data,
const uint32_t
len)
1452 uint16_t ip_len = (
len < USHRT_MAX) ? (uint16_t)
len : (uint16_t)USHRT_MAX;
1457 uint16_t ip_len = (
len < USHRT_MAX) ? (uint16_t)
len : (uint16_t)USHRT_MAX;
#define ENGINE_SET_EVENT(p, e)
uint16_t counter_flow_get_used_eval_busy
@ PKT_DROP_REASON_DEFRAG_MEMCAP
@ PKT_DROP_REASON_DEFRAG_ERROR
uint16_t counter_defrag_ipv4_reassembled
thread_local uint64_t spin_lock_cnt
@ PKT_DROP_REASON_RULES_THRESHOLD
int DecodeIPV6(ThreadVars *, DecodeThreadVars *, Packet *, const uint8_t *, uint16_t)
int DecodeERSPAN(ThreadVars *, DecodeThreadVars *, Packet *, const uint8_t *, uint32_t)
ERSPAN Type II.
struct PacketL3::@27::@28 ip6
int DecodeGeneve(ThreadVars *, DecodeThreadVars *, Packet *, const uint8_t *, uint32_t)
uint16_t counter_ethertype_unknown
uint16_t counter_flow_udp
const struct Signature_ * s
uint16_t counter_flow_active
void StatsIncr(ThreadVars *tv, uint16_t id)
Increments the local counter.
@ VLAN_HEADER_TOO_MANY_LAYERS
@ CHECKSUM_VALIDATION_OFFLOAD
void PacketFreeOrRelease(Packet *p)
Return a packet to where it was allocated.
#define IPV4_GET_RAW_IPPROTO(ip4h)
uint16_t counter_flow_icmp4
uint16_t counter_max_pkt_size
int PacketCopyData(Packet *p, const uint8_t *pktdata, uint32_t pktlen)
Copy data to Packet payload and set packet length.
void PacketBypassCallback(Packet *p)
int DecodeSCTP(ThreadVars *, DecodeThreadVars *, Packet *, const uint8_t *, uint16_t)
uint16_t counter_avg_pkt_size
uint16_t address_un_data16[8]
int DecodePPP(ThreadVars *, DecodeThreadVars *, Packet *, const uint8_t *, uint32_t)
int DecodeARP(ThreadVars *, DecodeThreadVars *, Packet *, const uint8_t *, uint32_t)
struct in6_addr address_un_in6
struct Packet_::@35 persistent
@ PKT_DROP_REASON_STREAM_MEMCAP
@ PKT_DROP_REASON_FLOW_MEMCAP
void CaptureStatsSetup(ThreadVars *tv)
const char * PacketDropReasonToString(enum PacketDropReason r)
uint8_t events[PACKET_ENGINE_EVENT_MAX]
@ DECODE_TUNNEL_IPV6_TEREDO
int DecodeEthernet(ThreadVars *, DecodeThreadVars *, Packet *, const uint8_t *, uint32_t)
thread_local uint64_t rwr_lock_cnt
void AddressDebugPrint(Address *)
Debug print function for printing addresses.
uint16_t counter_flow_spare_sync_avg
Packet * PacketDefragPktSetup(Packet *parent, const uint8_t *pkt, uint32_t len, uint8_t proto)
Setup a pseudo packet (reassembled frags)
simple fifo queue for packets with mutex and cond Calling the mutex or triggering the cond is respons...
#define ETHERNET_TYPE_IPV6
@ PKT_SRC_CAPTURE_TIMEOUT
int DecodeUDP(ThreadVars *, DecodeThreadVars *, Packet *, const uint8_t *, uint16_t)
PacketAlert * PacketAlertCreate(void)
Initialize PacketAlerts with dynamic alerts array size.
struct PktProfilingDetectData_ PktProfilingDetectData
uint16_t counter_flow_get_used_eval
union Address_::@26 address
int(* DecoderFunc)(ThreadVars *tv, DecodeThreadVars *dtv, Packet *p, const uint8_t *pkt, uint32_t len)
uint16_t counter_tcp_synack
@ CHECKSUM_VALIDATION_RXONLY
PktProfilingAppData app[]
@ PKT_DROP_REASON_STREAM_REASSEMBLY
#define LINKTYPE_LINUX_SLL
struct PktProfilingTmmData_ PktProfilingTmmData
Per TMM stats storage.
int PacketCopyDataOffset(Packet *p, uint32_t offset, const uint8_t *data, uint32_t datalen)
Copy data to Packet payload at given offset.
int DecodeVXLAN(ThreadVars *, DecodeThreadVars *, Packet *, const uint8_t *, uint32_t)
union PacketL3::Hdrs hdrs
struct DecodeThreadVars_ DecodeThreadVars
Structure to hold thread specific data for all decode modules.
#define IPV6_GET_L4PROTO(p)
int DecodeVNTag(ThreadVars *, DecodeThreadVars *, Packet *, const uint8_t *, uint32_t)
@ CHECKSUM_VALIDATION_DISABLE
uint16_t counter_flow_tcp
@ CHECKSUM_VALIDATION_KERNEL
void PacketDecodeFinalize(ThreadVars *tv, DecodeThreadVars *dtv, Packet *p)
Finalize decoding of a packet.
struct Packet_::@29::@36 icmp_s
uint32_t address_un_data32[4]
#define PKT_NOPAYLOAD_INSPECTION
void PacketAlertGetMaxConfig(void)
struct Packet_::@31::@37 icmp_d
int DecodeICMPV6(ThreadVars *, DecodeThreadVars *, Packet *, const uint8_t *, uint32_t)
Decode ICMPV6 packets and fill the Packet with the decoded info.
uint8_t decoder_max_layers
uint16_t counter_tcp_active_sessions
struct PacketAlert_ PacketAlert
struct PktProfilingLoggerData_ PktProfilingLoggerData
int(* BypassPacketsFlow)(struct Packet_ *)
uint16_t counter_max_mac_addrs_src
void DecodeUnregisterCounters(void)
thread_local uint64_t rww_lock_contention
uint16_t counter_flow_get_used
Data structure to store app layer decoder events.
AppLayerDecoderEvents * app_layer_events
PacketEngineEvents events
void PacketAlertFree(PacketAlert *pa)
#define ETHERNET_TYPE_8021QINQ
uint16_t counter_flow_spare_sync_empty
uint16_t counter_flow_tcp_reuse
int DecodeRaw(ThreadVars *, DecodeThreadVars *, Packet *, const uint8_t *, uint32_t)
thread_local uint64_t rwr_lock_contention
uint16_t counter_flow_total
thread_local uint64_t spin_lock_wait_ticks
@ CHECKSUM_VALIDATION_ENABLE
void DecodeRegisterPerfCounters(DecodeThreadVars *, ThreadVars *)
uint16_t counter_flow_spare_sync
uint16_t counter_defrag_tracker_timeout
@ CHECKSUM_VALIDATION_AUTO
uint16_t counter_ipv6inipv6
#define TUNNEL_PKT_TPR(p)
uint16_t counter_flow_get_used_failed
#define ETHERNET_TYPE_8021AD
@ PKT_DROP_REASON_APPLAYER_ERROR
void PacketSwap(Packet *p)
switch direction of a packet
int DecodeMPLS(ThreadVars *, DecodeThreadVars *, Packet *, const uint8_t *, uint32_t)
This is for the app layer in general and it contains per thread context relevant to both the alpd and...
@ PKT_DROP_REASON_NOT_SET
struct PktProfilingAppData_ PktProfilingAppData
void CaptureStatsUpdate(ThreadVars *tv, const Packet *p)
int DecodeTEMPLATE(ThreadVars *, DecodeThreadVars *, Packet *, const uint8_t *, uint32_t)
Function to decode TEMPLATE packets.
int DecodeVLAN(ThreadVars *, DecodeThreadVars *, Packet *, const uint8_t *, uint32_t)
int DecodeESP(ThreadVars *, DecodeThreadVars *, Packet *, const uint8_t *, uint16_t)
Function to decode IPSEC-ESP packets.
thread_local uint64_t rww_lock_cnt
int DecodeNSH(ThreadVars *, DecodeThreadVars *, Packet *, const uint8_t *, uint32_t)
Function to decode NSH packets.
Per thread variable structure.
thread_local uint64_t mutex_lock_contention
thread_local uint64_t spin_lock_contention
PktProfilingLoggerData logger[LOGGER_SIZE]
void PacketFree(Packet *p)
Return a malloced packet.
const char * PktSrcToString(enum PktSrcEnum pkt_src)
uint16_t counter_vlan_qinq
get the highest proto/next header field we know
#define LINKTYPE_GRE_OVER_IP
uint16_t counter_defrag_tracker_hard_reuse
int DecodeSll(ThreadVars *, DecodeThreadVars *, Packet *, const uint8_t *, uint32_t)
int PacketCallocExtPkt(Packet *p, int datalen)
#define ETHERNET_TYPE_MPLS_UNICAST
@ PKT_SRC_STREAM_TCP_DETECTLOG_FLUSH
#define ETHERNET_TYPE_PPPOE_DISC
AppLayerThreadCtx * app_tctx
uint8_t address_un_data8[16]
@ PKT_DROP_REASON_STREAM_ERROR
struct LiveDevice_ * livedev
#define ETHERNET_TYPE_VNTAG
uint16_t counter_ieee8021ah
thread_local uint64_t rww_lock_wait_ticks
int DecodeTCP(ThreadVars *, DecodeThreadVars *, Packet *, const uint8_t *, uint16_t)
uint16_t counter_ipv4inipv6
#define ETHERNET_TYPE_NSH
#define ETHERNET_TYPE_DCE
thread_local uint64_t rwr_lock_wait_ticks
int DecodeNull(ThreadVars *, DecodeThreadVars *, Packet *, const uint8_t *, uint32_t)
int DecodeIPV4(ThreadVars *, DecodeThreadVars *, Packet *, const uint8_t *, uint16_t)
ExceptionPolicyCounters counter_defrag_memcap_eps
uint32_t default_packet_size
uint8_t nb_decoded_layers
PktProfilingDetectData detect[PROF_DETECT_SIZE]
void(* ReleasePacket)(struct Packet_ *)
int DecodeGRE(ThreadVars *, DecodeThreadVars *, Packet *, const uint8_t *, uint32_t)
Function to decode GRE packets.
@ PKT_DROP_REASON_INNER_PACKET
struct PktProfiling_ PktProfiling
Per pkt stats storage.
void DecodeThreadVarsFree(ThreadVars *, DecodeThreadVars *)
uint16_t counter_flow_spare_sync_incomplete
@ PKT_DROP_REASON_APPLAYER_MEMCAP
void DecodeGlobalConfig(void)
void DecodeIPV6FragHeader(Packet *p, const uint8_t *pkt, uint16_t hdrextlen, uint16_t plen, uint16_t prev_hdrextlen)
#define ETHERNET_TYPE_8021AH
uint16_t counter_flow_icmp6
@ PROFILE_FLOWWORKER_SIZE
#define ETHERNET_DCE_HEADER_LEN
struct PacketAlerts_ PacketAlerts
int DecodeICMPV4(ThreadVars *, DecodeThreadVars *, Packet *, const uint8_t *, uint32_t)
Main ICMPv4 decoding function.
uint8_t app_update_direction
@ PKT_DROP_REASON_NFQ_ERROR
uint16_t counter_defrag_no_frags
uint16_t counter_defrag_ipv6_reassembled
enum PacketTunnelType ttype
void PacketUpdateEngineEventCounters(ThreadVars *tv, DecodeThreadVars *dtv, Packet *p)
ExceptionPolicyCounters counter_flow_memcap_eps
Packet * PacketGetFromAlloc(void)
Get a malloced packet.
#define TUNNEL_PKT_RTV(p)
thread_local uint64_t mutex_lock_wait_ticks
#define SCLogError(...)
Macro used to log ERROR messages.
@ PKT_SRC_DETECT_RELOAD_FLUSH
struct PktProfilingData_ PktProfilingData
#define ETHERNET_TYPE_PPPOE_SESS
Structure to hold thread specific data for all decode modules.
#define PACKET_ENGINE_EVENT_MAX
PktProfilingTmmData tmm[TMM_SIZE]
void * output_flow_thread_data
#define ETHERNET_TYPE_ARP
uint16_t counter_max_mac_addrs_dst
DecodeThreadVars * DecodeThreadVarsAlloc(ThreadVars *)
Alloc and setup DecodeThreadVars.
uint16_t counter_defrag_max_hit
int PacketSetData(Packet *p, const uint8_t *pktdata, uint32_t pktlen)
Set data for Packet and set length when zero copy is used.
union PacketL4::L4Hdrs hdrs
uint16_t counter_vlan_qinqinq
#define VLAN_MAX_LAYER_IDX
#define LINKTYPE_CISCO_HDLC
union PacketL2::L2Hdrs hdrs
#define ENGINE_SET_INVALID_EVENT(p, e)
uint16_t counter_flow_memcap
#define ETHERNET_TYPE_VLAN
uint16_t counter_defrag_ipv6_fragments
#define PKT_NOPACKET_INSPECTION
per packet AF_PACKET vars
struct PacketEngineEvents_ PacketEngineEvents
uint16_t packet_alert_max
uint16_t vlan_id[VLAN_MAX_LAYERS]
int DecodeIEEE8021ah(ThreadVars *, DecodeThreadVars *, Packet *, const uint8_t *, uint32_t)
void PacketDefragPktSetupParent(Packet *parent)
inform defrag "parent" that a pseudo packet is now associated to it.
uint8_t plugin_v[PLUGIN_VAR_SIZE]
Packet * PacketTunnelPktSetup(ThreadVars *tv, DecodeThreadVars *dtv, Packet *parent, const uint8_t *pkt, uint32_t len, enum DecodeTunnelProto proto)
Setup a pseudo packet (tunnel)
PktProfilingData flowworker[PROFILE_FLOWWORKER_SIZE]
thread_local uint64_t mutex_lock_cnt
@ PKT_DROP_REASON_STREAM_MIDSTREAM
@ GENERIC_TOO_MANY_LAYERS
uint16_t counter_flow_get_used_eval_reject
int DecodePPPOESession(ThreadVars *, DecodeThreadVars *, Packet *, const uint8_t *, uint32_t)
Main decoding function for PPPOE Session packets.
#define ETHERNET_TYPE_MPLS_MULTICAST
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...
#define DEBUG_VALIDATE_BUG_ON(exp)
@ PKT_DROP_REASON_FLOW_DROP
union PacketL4::L4Vars vars
int DecodeERSPANTypeI(ThreadVars *, DecodeThreadVars *, Packet *, const uint8_t *, uint32_t)
ERSPAN Type I.
int DecodeCHDLC(ThreadVars *, DecodeThreadVars *, Packet *, const uint8_t *, uint32_t)
void DecodeUpdatePacketCounters(ThreadVars *tv, const DecodeThreadVars *dtv, const Packet *p)
uint16_t counter_engine_events[DECODE_EVENT_MAX]
uint16_t counter_defrag_tracker_soft_reuse
#define LINKTYPE_ETHERNET
@ PKT_DROP_REASON_DECODE_ERROR
uint16_t counter_defrag_ipv4_fragments
int DecodePPPOEDiscovery(ThreadVars *, DecodeThreadVars *, Packet *, const uint8_t *, uint32_t)
Main decoding function for PPPOE Discovery packets.