Go to the documentation of this file.
24 #ifndef SURICATA_DECODE_H
25 #define SURICATA_DECODE_H
100 #define SignatureMask uint8_t
103 struct DetectionEngineThreadCtx_;
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
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]; \
141 #define SET_IPV4_SRC_ADDR(ip4h, a) \
143 (a)->family = AF_INET; \
144 (a)->addr_data32[0] = (uint32_t)(ip4h)->s_ip_src.s_addr; \
145 (a)->addr_data32[1] = 0; \
146 (a)->addr_data32[2] = 0; \
147 (a)->addr_data32[3] = 0; \
150 #define SET_IPV4_DST_ADDR(ip4h, a) \
152 (a)->family = AF_INET; \
153 (a)->addr_data32[0] = (uint32_t)(ip4h)->s_ip_dst.s_addr; \
154 (a)->addr_data32[1] = 0; \
155 (a)->addr_data32[2] = 0; \
156 (a)->addr_data32[3] = 0; \
160 #define SET_IPV6_SRC_ADDR(ip6h, a) \
162 (a)->family = AF_INET6; \
163 (a)->addr_data32[0] = (ip6h)->s_ip6_src[0]; \
164 (a)->addr_data32[1] = (ip6h)->s_ip6_src[1]; \
165 (a)->addr_data32[2] = (ip6h)->s_ip6_src[2]; \
166 (a)->addr_data32[3] = (ip6h)->s_ip6_src[3]; \
169 #define SET_IPV6_DST_ADDR(ip6h, a) \
171 (a)->family = AF_INET6; \
172 (a)->addr_data32[0] = (ip6h)->s_ip6_dst[0]; \
173 (a)->addr_data32[1] = (ip6h)->s_ip6_dst[1]; \
174 (a)->addr_data32[2] = (ip6h)->s_ip6_dst[2]; \
175 (a)->addr_data32[3] = (ip6h)->s_ip6_dst[3]; \
180 #define SET_TCP_SRC_PORT(pkt, prt) do { \
181 SET_PORT(TCP_GET_SRC_PORT((pkt)), *(prt)); \
184 #define SET_TCP_DST_PORT(pkt, prt) do { \
185 SET_PORT(TCP_GET_DST_PORT((pkt)), *(prt)); \
190 #define SET_UDP_SRC_PORT(pkt, prt) do { \
191 SET_PORT(UDP_GET_SRC_PORT((pkt)), *(prt)); \
193 #define SET_UDP_DST_PORT(pkt, prt) do { \
194 SET_PORT(UDP_GET_DST_PORT((pkt)), *(prt)); \
197 #define GET_IPV4_SRC_ADDR_U32(p) ((p)->src.addr_data32[0])
198 #define GET_IPV4_DST_ADDR_U32(p) ((p)->dst.addr_data32[0])
199 #define GET_IPV4_SRC_ADDR_PTR(p) ((p)->src.addr_data32)
200 #define GET_IPV4_DST_ADDR_PTR(p) ((p)->dst.addr_data32)
202 #define GET_IPV6_SRC_IN6ADDR(p) ((p)->src.addr_in6addr)
203 #define GET_IPV6_DST_IN6ADDR(p) ((p)->dst.addr_in6addr)
204 #define GET_IPV6_SRC_ADDR(p) ((p)->src.addr_data32)
205 #define GET_IPV6_DST_ADDR(p) ((p)->dst.addr_data32)
206 #define GET_TCP_SRC_PORT(p) ((p)->sp)
207 #define GET_TCP_DST_PORT(p) ((p)->dp)
209 #define GET_PKT_LEN(p) (p)->pktlen
210 #define GET_PKT_DATA(p) (((p)->ext_pkt == NULL) ? GET_PKT_DIRECT_DATA(p) : (p)->ext_pkt)
211 #define GET_PKT_DIRECT_DATA(p) (p)->pkt_data
212 #define GET_PKT_DIRECT_MAX_SIZE(p) (default_packet_size)
214 #define SET_PKT_LEN(p, len) do { \
215 (p)->pktlen = (len); \
220 #define SET_PORT(v, p) ((p) = (v))
221 #define COPY_PORT(a,b) ((b) = (a))
223 #define CMP_ADDR(a1, a2) \
224 (((a1)->addr_data32[3] == (a2)->addr_data32[3] && \
225 (a1)->addr_data32[2] == (a2)->addr_data32[2] && \
226 (a1)->addr_data32[1] == (a2)->addr_data32[1] && \
227 (a1)->addr_data32[0] == (a2)->addr_data32[0]))
228 #define CMP_PORT(p1, p2) \
233 #define IP_GET_RAW_VER(pkt) ((((pkt)[0] & 0xf0) >> 4))
235 #define PKT_IS_TCP(p) (((p)->tcph != NULL))
236 #define PKT_IS_UDP(p) (((p)->udph != NULL))
237 #define PKT_IS_ICMPV4(p) (((p)->icmpv4h != NULL))
238 #define PKT_IS_ICMPV6(p) (((p)->icmpv6h != NULL))
239 #define PKT_IS_TOSERVER(p) (((p)->flowflags & FLOW_PKT_TOSERVER))
240 #define PKT_IS_TOCLIENT(p) (((p)->flowflags & FLOW_PKT_TOCLIENT))
267 #define PACKET_ALERT_FLAG_APPLY_ACTION_TO_FLOW BIT_U8(0)
269 #define PACKET_ALERT_FLAG_STATE_MATCH BIT_U8(1)
271 #define PACKET_ALERT_FLAG_STREAM_MATCH BIT_U8(2)
273 #define PACKET_ALERT_FLAG_TX BIT_U8(3)
275 #define PACKET_ALERT_FLAG_RATE_FILTER_MODIFIED BIT_U8(4)
277 #define PACKET_ALERT_FLAG_FRAME BIT_U8(5)
279 #define PACKET_ALERT_FLAG_TX_GUESSED BIT_U8(6)
281 #define PACKET_ALERT_FLAG_APPLY_ACTION_TO_PACKET BIT_U8(7)
285 #define PACKET_ALERT_MAX 15
304 #define PACKET_ENGINE_EVENT_MAX 15
329 #ifdef PROFILE_LOCKING
579 WinDivertPacketVars windivert_v;
692 static inline bool PacketIsIPv4(
const Packet *p);
693 static inline bool PacketIsIPv6(
const Packet *p);
696 #define DEFAULT_MTU 1500
697 #define MINIMUM_MTU 68
699 #define DEFAULT_PACKET_SIZE (DEFAULT_MTU + ETHERNET_HEADER_LEN)
701 #define MAX_PAYLOAD_SIZE (IPV6_HEADER_LEN + 65536 + 28)
703 #define SIZE_OF_PACKET (default_packet_size + sizeof(Packet))
705 static inline bool PacketIsIPv4(
const Packet *p)
716 static inline IPV4Hdr *PacketSetIPV4(
Packet *p,
const uint8_t *buf)
725 static inline uint8_t PacketGetIPProto(
const Packet *p)
730 if (PacketIsIPv4(p)) {
731 const IPV4Hdr *hdr = PacketGetIPv4(p);
733 }
else if (PacketIsIPv6(p)) {
739 static inline uint8_t PacketGetIPv4IPProto(
const Packet *p)
741 if (PacketGetIPv4(p)) {
742 const IPV4Hdr *hdr = PacketGetIPv4(p);
754 static inline IPV6Hdr *PacketSetIPV6(
Packet *p,
const uint8_t *buf)
762 static inline bool PacketIsIPv6(
const Packet *p)
767 static inline void PacketClearL2(
Packet *p)
769 memset(&p->
l2, 0,
sizeof(p->
l2));
773 static inline EthernetHdr *PacketSetEthernet(
Packet *p,
const uint8_t *buf)
781 static inline const EthernetHdr *PacketGetEthernet(
const Packet *p)
787 static inline bool PacketIsEthernet(
const Packet *p)
792 static inline void PacketClearL3(
Packet *p)
794 memset(&p->
l3, 0,
sizeof(p->
l3));
797 static inline void PacketClearL4(
Packet *p)
799 memset(&p->
l4, 0,
sizeof(p->
l4));
802 static inline TCPHdr *PacketSetTCP(
Packet *p,
const uint8_t *buf)
810 static inline const TCPHdr *PacketGetTCP(
const Packet *p)
816 static inline bool PacketIsTCP(
const Packet *p)
821 static inline UDPHdr *PacketSetUDP(
Packet *p,
const uint8_t *buf)
829 static inline const UDPHdr *PacketGetUDP(
const Packet *p)
835 static inline bool PacketIsUDP(
const Packet *p)
840 static inline ICMPV4Hdr *PacketSetICMPv4(
Packet *p,
const uint8_t *buf)
854 static inline bool PacketIsICMPv4(
const Packet *p)
859 static inline const IPV4Hdr *PacketGetICMPv4EmbIPv4(
const Packet *p)
861 const uint8_t *start = (
const uint8_t *)PacketGetICMPv4(p);
866 static inline ICMPV6Hdr *PacketSetICMPv6(
Packet *p,
const uint8_t *buf)
880 static inline bool PacketIsICMPv6(
const Packet *p)
885 static inline SCTPHdr *PacketSetSCTP(
Packet *p,
const uint8_t *buf)
893 static inline const SCTPHdr *PacketGetSCTP(
const Packet *p)
899 static inline bool PacketIsSCTP(
const Packet *p)
904 static inline GREHdr *PacketSetGRE(
Packet *p,
const uint8_t *buf)
912 static inline const GREHdr *PacketGetGRE(
const Packet *p)
918 static inline bool PacketIsGRE(
const Packet *p)
923 static inline ESPHdr *PacketSetESP(
Packet *p,
const uint8_t *buf)
931 static inline const ESPHdr *PacketGetESP(
const Packet *p)
937 static inline bool PacketIsESP(
const Packet *p)
942 static inline const ARPHdr *PacketGetARP(
const Packet *p)
948 static inline ARPHdr *PacketSetARP(
Packet *p,
const uint8_t *buf)
956 static inline bool PacketIsARP(
const Packet *p)
961 static inline IGMPHdr *PacketSetIGMP(
Packet *p,
const uint8_t *buf)
975 static inline bool PacketIsIGMP(
const Packet *p)
1087 #define PACKET_CLEAR_L4VARS(p) do { \
1088 memset(&(p)->l4vars, 0x00, sizeof((p)->l4vars)); \
1092 #define PACKET_FREE_EXTDATA(p) do { \
1093 if ((p)->ext_pkt) { \
1094 if (!((p)->flags & PKT_ZERO_COPY)) { \
1095 SCFree((p)->ext_pkt); \
1097 (p)->ext_pkt = NULL; \
1101 #define TUNNEL_INCR_PKT_RTV_NOLOCK(p) do { \
1102 ((p)->root ? (p)->root->tunnel_rtv_cnt++ : (p)->tunnel_rtv_cnt++); \
1105 static inline void TUNNEL_INCR_PKT_TPR(
Packet *p)
1113 #define TUNNEL_PKT_RTV(p) ((p)->root ? (p)->root->tunnel_rtv_cnt : (p)->tunnel_rtv_cnt)
1114 #define TUNNEL_PKT_TPR(p) ((p)->root ? (p)->root->tunnel_tpr_cnt : (p)->tunnel_tpr_cnt)
1116 static inline bool PacketTunnelIsVerdicted(
const Packet *p)
1120 static inline void PacketTunnelSetVerdicted(
Packet *p)
1201 uint16_t hdrextlen, uint16_t plen,
1202 uint16_t prev_hdrextlen);
1208 const uint8_t *pkt, uint32_t
len);
1213 #define ENGINE_SET_EVENT(p, e) do { \
1214 SCLogDebug("p %p event %d", (p), e); \
1215 if ((p)->events.cnt < PACKET_ENGINE_EVENT_MAX) { \
1216 (p)->events.events[(p)->events.cnt] = e; \
1217 (p)->events.cnt++; \
1221 #define ENGINE_SET_INVALID_EVENT(p, e) do { \
1222 p->flags |= PKT_IS_INVALID; \
1223 ENGINE_SET_EVENT(p, e); \
1226 #define ENGINE_ISSET_EVENT(p, e) ({ \
1229 for (u = 0; u < (p)->events.cnt; u++) { \
1230 if ((p)->events.events[u] == (e)) { \
1238 #ifndef IPPROTO_IPIP
1239 #define IPPROTO_IPIP 4
1246 #ifndef IPPROTO_DCCP
1247 #define IPPROTO_DCCP 33
1254 #ifndef IPPROTO_SCTP
1255 #define IPPROTO_SCTP 132
1259 #define IPPROTO_MH 135
1264 #define IPPROTO_HIP 139
1267 #ifndef IPPROTO_SHIM6
1268 #define IPPROTO_SHIM6 140
1274 #define PKT_NOPACKET_INSPECTION BIT_U32(0)
1276 #define PKT_PPP_VJ_UCOMP BIT_U32(1)
1279 #define PKT_NOPAYLOAD_INSPECTION BIT_U32(2)
1282 #define PKT_ALERT_CTX_USED BIT_U32(3)
1285 #define PKT_HAS_TAG BIT_U32(4)
1287 #define PKT_STREAM_ADD BIT_U32(5)
1289 #define PKT_STREAM_EST BIT_U32(6)
1293 #define PKT_HAS_FLOW BIT_U32(8)
1295 #define PKT_PSEUDO_STREAM_END BIT_U32(9)
1298 #define PKT_STREAM_MODIFIED BIT_U32(10)
1304 #define PKT_STREAM_NOPCAPLOG BIT_U32(12)
1309 #define PKT_IGNORE_CHECKSUM BIT_U32(15)
1311 #define PKT_ZERO_COPY BIT_U32(16)
1313 #define PKT_HOST_SRC_LOOKED_UP BIT_U32(17)
1314 #define PKT_HOST_DST_LOOKED_UP BIT_U32(18)
1317 #define PKT_IS_FRAGMENT BIT_U32(19)
1318 #define PKT_IS_INVALID BIT_U32(20)
1319 #define PKT_PROFILE BIT_U32(21)
1323 #define PKT_WANTS_FLOW BIT_U32(22)
1326 #define PKT_PROTO_DETECT_TS_DONE BIT_U32(23)
1327 #define PKT_PROTO_DETECT_TC_DONE BIT_U32(24)
1329 #define PKT_REBUILT_FRAGMENT \
1332 #define PKT_DETECT_HAS_STREAMDATA \
1335 #define PKT_PSEUDO_DETECTLOG_FLUSH BIT_U32(27)
1339 #define PKT_STREAM_NO_EVENTS BIT_U32(28)
1342 #define PKT_FIRST_ALERTS BIT_U32(29)
1343 #define PKT_FIRST_TAG BIT_U32(30)
1345 #define PKT_PSEUDO_LOG_FLUSH BIT_U32(31)
1348 #define PKT_IS_PSEUDOPKT(p) \
1349 ((p)->flags & (PKT_PSEUDO_STREAM_END|PKT_PSEUDO_DETECTLOG_FLUSH))
1350 #define PKT_IS_FLUSHPKT(p) ((p)->flags & (PKT_PSEUDO_LOG_FLUSH))
1352 #define PKT_SET_SRC(p, src_val) ((p)->pkt_src = src_val)
1354 #define PKT_DEFAULT_MAX_DECODED_LAYERS 16
1357 static inline bool PacketIncreaseCheckLayers(
Packet *p)
1371 static inline void DecodeSetNoPayloadInspectionFlag(
Packet *p)
1380 static inline void DecodeSetNoPacketInspectionFlag(
Packet *p)
1385 static inline bool PacketIsTunnelRoot(
const Packet *p)
1390 static inline bool PacketIsTunnelChild(
const Packet *p)
1395 static inline bool PacketIsTunnel(
const Packet *p)
1400 static inline bool PacketIsNotTunnel(
const Packet *p)
1405 static inline bool VerdictTunnelPacketInternal(
const Packet *p)
1408 SCLogDebug(
"tunnel: outstanding %u", outstanding);
1411 if (PacketIsTunnelRoot(p) && !PacketTunnelIsVerdicted(p) && !outstanding) {
1415 }
else if (PacketIsTunnelChild(p) && outstanding == 1 && p->
root &&
1416 PacketTunnelIsVerdicted(p->
root)) {
1435 static inline bool VerdictTunnelPacket(
Packet *p)
1440 verdict = VerdictTunnelPacketInternal(p);
1446 const int datalink,
Packet *p,
const uint8_t *data,
const uint32_t
len)
1474 "%" PRId32
" not yet supported",
1483 const uint16_t
proto,
Packet *p,
const uint8_t *data,
const uint32_t
len)
1487 uint16_t ip_len = (
len < USHRT_MAX) ? (uint16_t)
len : (uint16_t)USHRT_MAX;
1492 uint16_t ip_len = (
len < USHRT_MAX) ? (uint16_t)
len : (uint16_t)USHRT_MAX;
#define ENGINE_SET_EVENT(p, e)
@ PKT_DROP_REASON_DEFRAG_MEMCAP
StatsCounterId counter_flow_icmp6
@ PKT_DROP_REASON_DEFRAG_ERROR
@ PKT_DROP_REASON_STREAM_PRE_HOOK
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.
int DecodeGeneve(ThreadVars *, DecodeThreadVars *, Packet *, const uint8_t *, uint32_t)
StatsCounterId counter_icmpv4
StatsCounterId counter_defrag_ipv6_fragments
StatsCounterId counter_esp
StatsCounterId counter_ethertype_unknown
const struct Signature_ * s
@ CHECKSUM_VALIDATION_OFFLOAD
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_FLOW_MEMCAP
void CaptureStatsSetup(ThreadVars *tv)
const char * PacketDropReasonToString(enum PacketDropReason r)
uint8_t events[PACKET_ENGINE_EVENT_MAX]
@ DECODE_TUNNEL_IPV6_TEREDO
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)
@ PKT_DROP_REASON_FLOW_PRE_HOOK
@ 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
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 *)
StatsCounterId counter_flow_elephant
@ CHECKSUM_VALIDATION_AUTO
struct PacketContextData * json_info
@ PKT_DROP_REASON_DEFAULT_APP_POLICY
#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
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
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
struct LiveDevice_ * livedev
StatsCounterId counter_geneve
#define ETHERNET_TYPE_VNTAG
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
StatsCounterMaxId counter_max_mac_addrs_dst
@ PKT_DROP_REASON_DEFAULT_PACKET_POLICY
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
int DecodeGRE(ThreadVars *, DecodeThreadVars *, Packet *, const uint8_t *, uint32_t)
Function to decode GRE packets.
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
@ 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
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
#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
#define LINKTYPE_LINUX_SLL2
StatsCounterId counter_defrag_ipv4_fragments
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
#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)
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]
Packet * PacketTunnelPktSetup(ThreadVars *tv, DecodeThreadVars *dtv, Packet *parent, const uint8_t *pkt, uint32_t len, enum DecodeTunnelProto proto)
Setup a pseudo packet (tunnel)
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)
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