Go to the documentation of this file.
24 #ifndef SURICATA_DECODE_H
25 #define SURICATA_DECODE_H
42 #ifndef SURICATA_BINDGEN_H
117 #define SignatureMask uint8_t
120 struct DetectionEngineThreadCtx_;
140 #define addr_data32 address.address_un_data32
141 #define addr_data16 address.address_un_data16
142 #define addr_data8 address.address_un_data8
143 #define addr_in6addr address.address_un_in6
145 #define COPY_ADDRESS(a, b) do { \
146 (b)->family = (a)->family; \
147 (b)->addr_data32[0] = (a)->addr_data32[0]; \
148 (b)->addr_data32[1] = (a)->addr_data32[1]; \
149 (b)->addr_data32[2] = (a)->addr_data32[2]; \
150 (b)->addr_data32[3] = (a)->addr_data32[3]; \
158 #define SET_IPV4_SRC_ADDR(ip4h, a) \
160 (a)->family = AF_INET; \
161 (a)->addr_data32[0] = (uint32_t)(ip4h)->s_ip_src.s_addr; \
162 (a)->addr_data32[1] = 0; \
163 (a)->addr_data32[2] = 0; \
164 (a)->addr_data32[3] = 0; \
167 #define SET_IPV4_DST_ADDR(ip4h, a) \
169 (a)->family = AF_INET; \
170 (a)->addr_data32[0] = (uint32_t)(ip4h)->s_ip_dst.s_addr; \
171 (a)->addr_data32[1] = 0; \
172 (a)->addr_data32[2] = 0; \
173 (a)->addr_data32[3] = 0; \
177 #define SET_IPV6_SRC_ADDR(ip6h, a) \
179 (a)->family = AF_INET6; \
180 (a)->addr_data32[0] = (ip6h)->s_ip6_src[0]; \
181 (a)->addr_data32[1] = (ip6h)->s_ip6_src[1]; \
182 (a)->addr_data32[2] = (ip6h)->s_ip6_src[2]; \
183 (a)->addr_data32[3] = (ip6h)->s_ip6_src[3]; \
186 #define SET_IPV6_DST_ADDR(ip6h, a) \
188 (a)->family = AF_INET6; \
189 (a)->addr_data32[0] = (ip6h)->s_ip6_dst[0]; \
190 (a)->addr_data32[1] = (ip6h)->s_ip6_dst[1]; \
191 (a)->addr_data32[2] = (ip6h)->s_ip6_dst[2]; \
192 (a)->addr_data32[3] = (ip6h)->s_ip6_dst[3]; \
197 #define SET_TCP_SRC_PORT(pkt, prt) do { \
198 SET_PORT(TCP_GET_SRC_PORT((pkt)), *(prt)); \
201 #define SET_TCP_DST_PORT(pkt, prt) do { \
202 SET_PORT(TCP_GET_DST_PORT((pkt)), *(prt)); \
207 #define SET_UDP_SRC_PORT(pkt, prt) do { \
208 SET_PORT(UDP_GET_SRC_PORT((pkt)), *(prt)); \
210 #define SET_UDP_DST_PORT(pkt, prt) do { \
211 SET_PORT(UDP_GET_DST_PORT((pkt)), *(prt)); \
214 #define GET_IPV4_SRC_ADDR_U32(p) ((p)->src.addr_data32[0])
215 #define GET_IPV4_DST_ADDR_U32(p) ((p)->dst.addr_data32[0])
216 #define GET_IPV4_SRC_ADDR_PTR(p) ((p)->src.addr_data32)
217 #define GET_IPV4_DST_ADDR_PTR(p) ((p)->dst.addr_data32)
219 #define GET_IPV6_SRC_IN6ADDR(p) ((p)->src.addr_in6addr)
220 #define GET_IPV6_DST_IN6ADDR(p) ((p)->dst.addr_in6addr)
221 #define GET_IPV6_SRC_ADDR(p) ((p)->src.addr_data32)
222 #define GET_IPV6_DST_ADDR(p) ((p)->dst.addr_data32)
223 #define GET_TCP_SRC_PORT(p) ((p)->sp)
224 #define GET_TCP_DST_PORT(p) ((p)->dp)
226 #define GET_PKT_LEN(p) (p)->pktlen
227 #define GET_PKT_DATA(p) (((p)->ext_pkt == NULL) ? GET_PKT_DIRECT_DATA(p) : (p)->ext_pkt)
228 #define GET_PKT_DIRECT_DATA(p) (p)->pkt_data
229 #define GET_PKT_DIRECT_MAX_SIZE(p) (default_packet_size)
231 #define SET_PKT_LEN(p, len) do { \
232 (p)->pktlen = (len); \
237 #define SET_PORT(v, p) ((p) = (v))
238 #define COPY_PORT(a,b) ((b) = (a))
240 #define CMP_ADDR(a1, a2) \
241 (((a1)->addr_data32[3] == (a2)->addr_data32[3] && \
242 (a1)->addr_data32[2] == (a2)->addr_data32[2] && \
243 (a1)->addr_data32[1] == (a2)->addr_data32[1] && \
244 (a1)->addr_data32[0] == (a2)->addr_data32[0]))
245 #define CMP_PORT(p1, p2) \
250 #define IP_GET_RAW_VER(pkt) ((((pkt)[0] & 0xf0) >> 4))
252 #define PKT_IS_TCP(p) (((p)->tcph != NULL))
253 #define PKT_IS_UDP(p) (((p)->udph != NULL))
254 #define PKT_IS_ICMPV4(p) (((p)->icmpv4h != NULL))
255 #define PKT_IS_ICMPV6(p) (((p)->icmpv6h != NULL))
256 #define PKT_IS_TOSERVER(p) (((p)->flowflags & FLOW_PKT_TOSERVER))
257 #define PKT_IS_TOCLIENT(p) (((p)->flowflags & FLOW_PKT_TOCLIENT))
285 #define PACKET_ALERT_FLAG_APPLY_ACTION_TO_FLOW BIT_U8(0)
287 #define PACKET_ALERT_FLAG_STATE_MATCH BIT_U8(1)
289 #define PACKET_ALERT_FLAG_STREAM_MATCH BIT_U8(2)
291 #define PACKET_ALERT_FLAG_TX BIT_U8(3)
293 #define PACKET_ALERT_FLAG_RATE_FILTER_MODIFIED BIT_U8(4)
295 #define PACKET_ALERT_FLAG_FRAME BIT_U8(5)
297 #define PACKET_ALERT_FLAG_TX_GUESSED BIT_U8(6)
299 #define PACKET_ALERT_FLAG_APPLY_ACTION_TO_PACKET BIT_U8(7)
303 #define PACKET_ALERT_MAX 15
325 #define PACKET_ENGINE_EVENT_MAX 15
350 #ifdef PROFILE_LOCKING
424 #define PKT_DROP_REASON_NON_FW_MAX PKT_DROP_REASON_INNER_PACKET
610 WinDivertPacketVars windivert_v;
725 static inline bool PacketIsIPv4(
const Packet *
p);
726 static inline bool PacketIsIPv6(
const Packet *
p);
729 #define DEFAULT_MTU 1500
730 #define MINIMUM_MTU 68
732 #define DEFAULT_PACKET_SIZE (DEFAULT_MTU + ETHERNET_HEADER_LEN)
734 #define MAX_PAYLOAD_SIZE (IPV6_HEADER_LEN + 65536 + 28)
736 #define SIZE_OF_PACKET (default_packet_size + sizeof(Packet))
738 static inline bool PacketIsIPv4(
const Packet *
p)
749 static inline IPV4Hdr *PacketSetIPV4(
Packet *
p,
const uint8_t *buf)
758 static inline uint8_t PacketGetIPProto(
const Packet *
p)
763 if (PacketIsIPv4(
p)) {
764 const IPV4Hdr *hdr = PacketGetIPv4(
p);
766 }
else if (PacketIsIPv6(
p)) {
772 static inline uint8_t PacketGetIPv4IPProto(
const Packet *
p)
774 if (PacketGetIPv4(
p)) {
775 const IPV4Hdr *hdr = PacketGetIPv4(
p);
787 static inline IPV6Hdr *PacketSetIPV6(
Packet *
p,
const uint8_t *buf)
795 static inline bool PacketIsIPv6(
const Packet *
p)
800 static inline void PacketClearL2(
Packet *
p)
802 memset(&
p->
l2, 0,
sizeof(
p->
l2));
806 static inline EthernetHdr *PacketSetEthernet(
Packet *
p,
const uint8_t *buf)
814 static inline const EthernetHdr *PacketGetEthernet(
const Packet *
p)
820 static inline bool PacketIsEthernet(
const Packet *
p)
825 static inline void PacketClearL3(
Packet *
p)
827 memset(&
p->
l3, 0,
sizeof(
p->
l3));
830 static inline void PacketClearL4(
Packet *
p)
832 memset(&
p->
l4, 0,
sizeof(
p->
l4));
835 static inline TCPHdr *PacketSetTCP(
Packet *
p,
const uint8_t *buf)
849 static inline bool PacketIsTCP(
const Packet *
p)
854 static inline UDPHdr *PacketSetUDP(
Packet *
p,
const uint8_t *buf)
868 static inline bool PacketIsUDP(
const Packet *
p)
887 static inline bool PacketIsICMPv4(
const Packet *
p)
892 static inline const IPV4Hdr *PacketGetICMPv4EmbIPv4(
const Packet *
p)
894 const uint8_t *start = (
const uint8_t *)PacketGetICMPv4(
p);
913 static inline bool PacketIsICMPv6(
const Packet *
p)
918 static inline SCTPHdr *PacketSetSCTP(
Packet *
p,
const uint8_t *buf)
926 static inline const SCTPHdr *PacketGetSCTP(
const Packet *
p)
932 static inline bool PacketIsSCTP(
const Packet *
p)
937 static inline GREHdr *PacketSetGRE(
Packet *
p,
const uint8_t *buf)
945 static inline const GREHdr *PacketGetGRE(
const Packet *
p)
951 static inline bool PacketIsGRE(
const Packet *
p)
956 static inline ESPHdr *PacketSetESP(
Packet *
p,
const uint8_t *buf)
964 static inline const ESPHdr *PacketGetESP(
const Packet *
p)
970 static inline bool PacketIsESP(
const Packet *
p)
975 static inline const ARPHdr *PacketGetARP(
const Packet *
p)
981 static inline ARPHdr *PacketSetARP(
Packet *
p,
const uint8_t *buf)
989 static inline bool PacketIsARP(
const Packet *
p)
994 static inline IGMPHdr *PacketSetIGMP(
Packet *
p,
const uint8_t *buf)
1008 static inline bool PacketIsIGMP(
const Packet *
p)
1125 #define PACKET_CLEAR_L4VARS(p) do { \
1126 memset(&(p)->l4vars, 0x00, sizeof((p)->l4vars)); \
1130 #define PACKET_FREE_EXTDATA(p) do { \
1131 if ((p)->ext_pkt) { \
1132 if (!((p)->flags & PKT_ZERO_COPY)) { \
1133 SCFree((p)->ext_pkt); \
1135 (p)->ext_pkt = NULL; \
1139 #define TUNNEL_INCR_PKT_RTV_NOLOCK(p) do { \
1140 ((p)->root ? (p)->root->tunnel_rtv_cnt++ : (p)->tunnel_rtv_cnt++); \
1143 static inline void TUNNEL_INCR_PKT_TPR(
Packet *
p)
1151 #define TUNNEL_PKT_RTV(p) ((p)->root ? (p)->root->tunnel_rtv_cnt : (p)->tunnel_rtv_cnt)
1152 #define TUNNEL_PKT_TPR(p) ((p)->root ? (p)->root->tunnel_tpr_cnt : (p)->tunnel_tpr_cnt)
1154 static inline bool PacketTunnelIsVerdicted(
const Packet *
p)
1158 static inline void PacketTunnelSetVerdicted(
Packet *
p)
1227 uint16_t hdrextlen, uint16_t plen,
1228 uint16_t prev_hdrextlen);
1234 const uint8_t *pkt, uint32_t
len);
1240 #define ENGINE_SET_EVENT(p, e) do { \
1241 SCLogDebug("p %p event %d", (p), e); \
1242 if ((p)->events.cnt < PACKET_ENGINE_EVENT_MAX) { \
1243 (p)->events.events[(p)->events.cnt] = e; \
1244 (p)->events.cnt++; \
1248 #define ENGINE_SET_INVALID_EVENT(p, e) do { \
1249 p->flags |= PKT_IS_INVALID; \
1250 ENGINE_SET_EVENT(p, e); \
1253 #define ENGINE_ISSET_EVENT(p, e) ({ \
1256 for (u = 0; u < (p)->events.cnt; u++) { \
1257 if ((p)->events.events[u] == (e)) { \
1265 #ifndef IPPROTO_IPIP
1266 #define IPPROTO_IPIP 4
1273 #ifndef IPPROTO_DCCP
1274 #define IPPROTO_DCCP 33
1281 #ifndef IPPROTO_SCTP
1282 #define IPPROTO_SCTP 132
1286 #define IPPROTO_MH 135
1291 #define IPPROTO_HIP 139
1294 #ifndef IPPROTO_SHIM6
1295 #define IPPROTO_SHIM6 140
1301 #define PKT_NOPACKET_INSPECTION BIT_U32(0)
1303 #define PKT_PPP_VJ_UCOMP BIT_U32(1)
1306 #define PKT_NOPAYLOAD_INSPECTION BIT_U32(2)
1309 #define PKT_ALERT_CTX_USED BIT_U32(3)
1312 #define PKT_HAS_TAG BIT_U32(4)
1314 #define PKT_STREAM_ADD BIT_U32(5)
1316 #define PKT_STREAM_EST BIT_U32(6)
1320 #define PKT_HAS_FLOW BIT_U32(8)
1322 #define PKT_PSEUDO_STREAM_END BIT_U32(9)
1325 #define PKT_STREAM_MODIFIED BIT_U32(10)
1331 #define PKT_STREAM_NOPCAPLOG BIT_U32(12)
1336 #define PKT_IGNORE_CHECKSUM BIT_U32(15)
1338 #define PKT_ZERO_COPY BIT_U32(16)
1340 #define PKT_HOST_SRC_LOOKED_UP BIT_U32(17)
1341 #define PKT_HOST_DST_LOOKED_UP BIT_U32(18)
1344 #define PKT_IS_FRAGMENT BIT_U32(19)
1345 #define PKT_IS_INVALID BIT_U32(20)
1346 #define PKT_PROFILE BIT_U32(21)
1350 #define PKT_WANTS_FLOW BIT_U32(22)
1353 #define PKT_PROTO_DETECT_TS_DONE BIT_U32(23)
1354 #define PKT_PROTO_DETECT_TC_DONE BIT_U32(24)
1356 #define PKT_REBUILT_FRAGMENT \
1359 #define PKT_DETECT_HAS_STREAMDATA \
1362 #define PKT_PSEUDO_DETECTLOG_FLUSH BIT_U32(27)
1366 #define PKT_STREAM_NO_EVENTS BIT_U32(28)
1369 #define PKT_FIRST_ALERTS BIT_U32(29)
1370 #define PKT_FIRST_TAG BIT_U32(30)
1373 #define PKT_IS_PSEUDOPKT(p) ((p)->flags & (PKT_PSEUDO_STREAM_END | PKT_PSEUDO_DETECTLOG_FLUSH))
1375 #define PKT_SET_SRC(p, src_val) ((p)->pkt_src = src_val)
1377 #define PKT_DEFAULT_MAX_DECODED_LAYERS 16
1380 static inline bool PacketIncreaseCheckLayers(
Packet *
p)
1394 static inline void DecodeSetNoPayloadInspectionFlag(
Packet *
p)
1403 static inline void DecodeSetNoPacketInspectionFlag(
Packet *
p)
1408 static inline bool PacketIsTunnelRoot(
const Packet *
p)
1413 static inline bool PacketIsTunnelChild(
const Packet *
p)
1418 static inline bool PacketIsTunnel(
const Packet *
p)
1423 static inline bool PacketIsNotTunnel(
const Packet *
p)
1428 static inline bool VerdictTunnelPacketInternal(
const Packet *
p)
1431 SCLogDebug(
"tunnel: outstanding %u", outstanding);
1434 if (PacketIsTunnelRoot(
p) && !PacketTunnelIsVerdicted(
p) && !outstanding) {
1438 }
else if (PacketIsTunnelChild(
p) && outstanding == 1 &&
p->
root &&
1439 PacketTunnelIsVerdicted(
p->
root)) {
1458 static inline bool VerdictTunnelPacket(
Packet *
p)
1463 verdict = VerdictTunnelPacketInternal(
p);
1469 const int datalink,
Packet *
p,
const uint8_t *data,
const uint32_t
len)
1497 "%" PRId32
" not yet supported",
1506 const uint16_t
proto,
Packet *
p,
const uint8_t *data,
const uint32_t
len)
1510 uint16_t ip_len = (
len < USHRT_MAX) ? (uint16_t)
len : (uint16_t)USHRT_MAX;
1568 #endif // SURICATA_BINDGEN_H
#define ENGINE_SET_EVENT(p, e)
@ PKT_DROP_REASON_DEFRAG_MEMCAP
StatsCounterId counter_flow_icmp6
@ PKT_DROP_REASON_DEFRAG_ERROR
thread_local uint64_t spin_lock_cnt
@ PKT_DROP_REASON_RULES_THRESHOLD
int DecodeERSPAN(ThreadVars *, DecodeThreadVars *, Packet *, const uint8_t *, uint32_t)
ERSPAN Type II.
int DecodeGeneve(ThreadVars *, DecodeThreadVars *, Packet *, const uint8_t *, uint32_t)
uint16_t firewall_discarded
StatsCounterId counter_icmpv4
StatsCounterId counter_defrag_ipv6_fragments
StatsCounterId counter_esp
StatsCounterId counter_ethertype_unknown
const struct Signature_ * s
@ CHECKSUM_VALIDATION_OFFLOAD
@ PKT_DROP_REASON_FW_FLOW_DROP
StatsCounterId counter_ipv6
StatsCounterId counter_raw
void PacketFreeOrRelease(Packet *p)
Return a packet to where it was allocated.
#define IPV4_GET_RAW_IPPROTO(ip4h)
StatsCounterId counter_vlan_qinqinq
StatsCounterId counter_flow_get_used_eval_busy
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 address_un_data16[8]
@ GENERIC_TOO_MANY_LAYERS
struct Packet_::@34::@40 icmp_d
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
@ PKT_DROP_REASON_STREAM_MEMCAP
@ PKT_DROP_REASON_FW_RULES
@ PKT_DROP_REASON_FLOW_MEMCAP
void CaptureStatsSetup(ThreadVars *tv)
const char * PacketDropReasonToString(enum PacketDropReason r)
uint8_t events[PACKET_ENGINE_EVENT_MAX]
uint64_t PcapPacketCntGet(const Packet *p)
int DecodeEthernet(ThreadVars *, DecodeThreadVars *, Packet *, const uint8_t *, uint32_t)
thread_local uint64_t rwr_lock_cnt
StatsCounterId counter_defrag_no_frags
void AddressDebugPrint(Address *)
Debug print function for printing addresses.
Packet * PacketDefragPktSetup(Packet *parent, const uint8_t *pkt, uint32_t len, uint8_t proto)
Setup a pseudo packet (reassembled frags)
StatsCounterId counter_vxlan
StatsCounterId counter_flow_spare_sync_empty
simple fifo queue for packets with mutex and cond Calling the mutex or triggering the cond is respons...
StatsCounterId counter_nsh
StatsCounterId counter_gre
StatsCounterId counter_flow_get_used_failed
#define ETHERNET_TYPE_IPV6
@ PKT_SRC_CAPTURE_TIMEOUT
int DecodeUDP(ThreadVars *, DecodeThreadVars *, Packet *, const uint8_t *, uint16_t)
#define ETHERNET_TYPE_ETAG
PacketAlert * PacketAlertCreate(void)
Initialize PacketAlerts with dynamic alerts array size.
struct PktProfilingDetectData_ PktProfilingDetectData
@ ETHERNET_UNKNOWN_ETHERTYPE
int(* DecoderFunc)(ThreadVars *tv, DecodeThreadVars *dtv, Packet *p, const uint8_t *pkt, uint32_t len)
@ CHECKSUM_VALIDATION_RXONLY
PktProfilingAppData app[]
@ PKT_DROP_REASON_STREAM_REASSEMBLY
void PcapPacketCntSet(Packet *p, uint64_t pcap_cnt)
StatsCounterId counter_bytes
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
StatsCounterId counter_flow_get_used
StatsCounterDeriveId counter_avg_pkt_size
StatsCounterId counter_pppoe
struct DecodeThreadVars_ DecodeThreadVars
Structure to hold thread specific data for all decode modules.
#define LINKTYPE_GRE_OVER_IP
StatsCounterId counter_tcp_syn
#define IPV6_GET_L4PROTO(p)
@ VLAN_HEADER_TOO_MANY_LAYERS
int DecodeVNTag(ThreadVars *, DecodeThreadVars *, Packet *, const uint8_t *, uint32_t)
@ CHECKSUM_VALIDATION_DISABLE
StatsCounterId counter_icmpv6
@ CHECKSUM_VALIDATION_KERNEL
void PacketDecodeFinalize(ThreadVars *tv, DecodeThreadVars *dtv, Packet *p)
Finalize decoding of a packet.
uint32_t address_un_data32[4]
StatsCounterId counter_invalid
#define PKT_NOPAYLOAD_INSPECTION
void PacketAlertGetMaxConfig(void)
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
struct PacketAlert_ PacketAlert
struct PktProfilingLoggerData_ PktProfilingLoggerData
StatsCounterId counter_sctp_init_ack
int(* BypassPacketsFlow)(struct Packet_ *)
StatsCounterId counter_flow_spare_sync
StatsCounterId counter_defrag_ipv4_reassembled
void DecodeUnregisterCounters(void)
thread_local uint64_t rww_lock_contention
StatsCounterId counter_chdlc
StatsCounterId counter_sctp
Data structure to store app layer decoder events.
AppLayerDecoderEvents * app_layer_events
PacketEngineEvents events
void PacketAlertFree(PacketAlert *pa)
#define ETHERNET_TYPE_8021QINQ
StatsCounterId counter_tcp
int DecodeRaw(ThreadVars *, DecodeThreadVars *, Packet *, const uint8_t *, uint32_t)
@ PKT_DROP_REASON_STREAM_URG
thread_local uint64_t rwr_lock_contention
StatsCounterId counter_defrag_tracker_hard_reuse
struct Packet_::@32::@39 icmp_s
union Address_::@29 address
thread_local uint64_t spin_lock_wait_ticks
StatsCounterId counter_flow_memcap
@ CHECKSUM_VALIDATION_ENABLE
StatsCounterId counter_defrag_max_hit
void DecodeRegisterPerfCounters(DecodeThreadVars *, ThreadVars *)
@ DECODE_TUNNEL_IPV6_TEREDO
StatsCounterId counter_flow_elephant
@ CHECKSUM_VALIDATION_AUTO
struct PacketContextData * json_info
#define TUNNEL_PKT_TPR(p)
StatsCounterId counter_udp
#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
@ PKT_DROP_REASON_FW_FLOW_PRE_HOOK
void CaptureStatsUpdate(ThreadVars *tv, const Packet *p)
int DecodeTEMPLATE(ThreadVars *, DecodeThreadVars *, Packet *, const uint8_t *, uint32_t)
Function to decode TEMPLATE packets.
StatsCounterId counter_vntag
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
StatsCounterId counter_flow_active
StatsCounterId counter_ipv6inipv4
thread_local uint64_t spin_lock_contention
PktProfilingLoggerData logger[LOGGER_SIZE]
void StatsCounterIncr(StatsThreadContext *stats, StatsCounterId id)
Increments the local counter.
void PacketFree(Packet *p)
Return a malloced packet.
const char * PktSrcToString(enum PktSrcEnum pkt_src)
StatsCounterId counter_tcp_urg
StatsCounterId counter_pkts
StatsCounterId counter_eth
get the highest proto/next header field we know
struct PacketL3::@30::@31 ip6
StatsCounterId counter_sctp_init
int DecodeIGMP(ThreadVars *, DecodeThreadVars *, Packet *, const uint8_t *, uint32_t)
int DecodeSll(ThreadVars *, DecodeThreadVars *, Packet *, const uint8_t *, uint32_t)
StatsCounterAvgId counter_flow_spare_sync_avg
int PacketCallocExtPkt(Packet *p, int datalen)
#define ETHERNET_TYPE_MPLS_UNICAST
StatsCounterId counter_flow_icmp4
StatsCounterId counter_ieee8021ah
@ PKT_SRC_STREAM_TCP_DETECTLOG_FLUSH
#define ETHERNET_TYPE_PPPOE_DISC
StatsCounterId counter_defrag_tracker_timeout
AppLayerThreadCtx * app_tctx
uint8_t address_un_data8[16]
@ PKT_DROP_REASON_STREAM_ERROR
StatsCounterId counter_geneve
#define ETHERNET_TYPE_VNTAG
StatsCounterId counter_sctp_shutdown
thread_local uint64_t rww_lock_wait_ticks
int DecodeTCP(ThreadVars *, DecodeThreadVars *, Packet *, const uint8_t *, uint16_t)
StatsCounterId counter_tcp_rst
#define ETHERNET_TYPE_NSH
#define ETHERNET_TYPE_DCE
StatsCounterId counter_ipv4inipv6
thread_local uint64_t rwr_lock_wait_ticks
@ PKT_DROP_REASON_EP_FLOW_DROP
StatsCounterMaxId counter_max_mac_addrs_dst
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
StatsCounterMaxId counter_max_mac_addrs_src
uint32_t default_packet_size
uint8_t nb_decoded_layers
PktProfilingDetectData detect[PROF_DETECT_SIZE]
void(* ReleasePacket)(struct Packet_ *)
StatsCounterId counter_ipv4_unknown_proto
StatsCounterId counter_sctp_abort
int DecodeGRE(ThreadVars *, DecodeThreadVars *, Packet *, const uint8_t *, uint32_t)
Function to decode GRE packets.
void PacketAlertDropReset(struct Packet_ *p)
Release the alert context the drop slot owns, then invalidate the slot. Not an alerts[] entry,...
StatsCounterId counter_ipv4inipv4
@ PKT_DROP_REASON_INNER_PACKET
struct PktProfiling_ PktProfiling
Per pkt stats storage.
void DecodeThreadVarsFree(ThreadVars *, DecodeThreadVars *)
StatsCounterId counter_sll
StatsCounterId counter_ppp
@ 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
StatsCounterId counter_flow_udp
StatsCounterId counter_igmp
StatsCounterId counter_tcp_synack
void PacketSetTunnelId(Packet *p, uint32_t session)
@ 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
StatsCounterId counter_null
void PacketUpdateEngineEventCounters(ThreadVars *tv, DecodeThreadVars *dtv, Packet *p)
ExceptionPolicyCounters counter_flow_memcap_eps
struct PacketContextData * next
@ PKT_DROP_REASON_FW_STREAM_PRE_HOOK
struct Packet_::@38 persistent
StatsCounterId counter_vlan_qinq
StatsCounterId counter_teredo
Packet * PacketGetFromAlloc(void)
Get a malloced packet.
#define TUNNEL_PKT_RTV(p)
thread_local uint64_t mutex_lock_wait_ticks
int DecodeIPV6(ThreadVars *, DecodeThreadVars *, Packet *, const uint8_t *, uint32_t)
#define SCLogError(...)
Macro used to log ERROR messages.
@ PKT_SRC_DETECT_RELOAD_FLUSH
struct PktProfilingData_ PktProfilingData
#define ETHERNET_TYPE_PPPOE_SESS
StatsCounterMaxId counter_max_pkt_size
StatsCounterId counter_flow_spare_sync_incomplete
StatsCounterId counter_sll2
Structure to hold thread specific data for all decode modules.
#define PACKET_ENGINE_EVENT_MAX
#define LINKTYPE_LINUX_SLL
Packet * PacketTunnelPktSetupWithSession(ThreadVars *tv, DecodeThreadVars *dtv, Packet *parent, const uint8_t *pkt, uint32_t len, enum SCPacketTunnelProto proto, uint32_t *session)
#define LINKTYPE_LINUX_SLL2
StatsCounterId counter_defrag_ipv4_fragments
void DecodeGlobalConfigDeinit(void)
PktProfilingTmmData tmm[TMM_SIZE]
StatsCounterId counter_etag
StatsCounterId counter_tcp_active_sessions
void * output_flow_thread_data
#define ETHERNET_TYPE_ARP
DecodeThreadVars * DecodeThreadVarsAlloc(ThreadVars *)
Alloc and setup DecodeThreadVars.
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
@ PKT_DROP_REASON_FW_DEFAULT_APP_POLICY
#define VLAN_MAX_LAYER_IDX
#define LINKTYPE_ETHERNET
union PacketL2::L2Hdrs hdrs
StatsCounterId counter_defrag_ipv6_reassembled
StatsCounterId counter_mpls
#define ENGINE_SET_INVALID_EVENT(p, e)
#define ETHERNET_TYPE_VLAN
#define PKT_NOPACKET_INSPECTION
per packet AF_PACKET vars
void PacketAlertRecycle(PacketAlert *pa_array, uint16_t cnt)
@ PKT_DROP_REASON_FW_DEFAULT_PACKET_POLICY
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)
StatsCounterId counter_ipv4
StatsCounterId counter_flow_total
StatsCounterId counter_arp
StatsCounterId counter_vlan
void PacketDefragPktSetupParent(Packet *parent)
inform defrag "parent" that a pseudo packet is now associated to it.
int DecodeSll2(ThreadVars *, DecodeThreadVars *, Packet *, const uint8_t *, uint32_t)
StatsCounterId counter_defrag_tracker_soft_reuse
uint8_t plugin_v[PLUGIN_VAR_SIZE]
StatsCounterId counter_flow_elephant_toclient
StatsCounterId counter_flow_elephant_toserver
PktProfilingData flowworker[PROFILE_FLOWWORKER_SIZE]
thread_local uint64_t mutex_lock_cnt
@ PKT_DROP_REASON_STREAM_MIDSTREAM
StatsCounterId counter_erspan
int DecodeETag(ThreadVars *, DecodeThreadVars *, Packet *, const uint8_t *, uint32_t)
int DecodePPPOESession(ThreadVars *, DecodeThreadVars *, Packet *, const uint8_t *, uint32_t)
Main decoding function for PPPOE Session packets.
#define ETHERNET_TYPE_MPLS_MULTICAST
StatsCounterId counter_ipv6inipv6
#define LINKTYPE_CISCO_HDLC
StatsCounterId counter_engine_events[DECODE_EVENT_MAX]
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)
Packet * PacketTunnelPktSetup(ThreadVars *tv, DecodeThreadVars *dtv, Packet *parent, const uint8_t *pkt, uint32_t len, enum SCPacketTunnelProto proto)
Setup a pseudo packet (tunnel)
StatsCounterId counter_flow_get_used_eval_reject
StatsCounterId counter_flow_get_used_eval
StatsCounterId counter_flow_tcp_reuse
@ PKT_DROP_REASON_DECODE_ERROR
int DecodePPPOEDiscovery(ThreadVars *, DecodeThreadVars *, Packet *, const uint8_t *, uint32_t)
Main decoding function for PPPOE Discovery packets.
StatsCounterId counter_flow_tcp
StatsCounterId counter_sctp_data