Go to the documentation of this file.
30 #ifndef SURICATA_UTIL_VALIDATE_H
31 #define SURICATA_UTIL_VALIDATE_H
33 #ifdef DEBUG_VALIDATION
40 #define DEBUG_ASSERT_FLOW_LOCKED(f) do { \
42 int r = SCMutexTrylock(&(f)->m); \
53 #define DEBUG_VALIDATE_FLOW(f) do { \
55 BUG_ON((f)->flags & FLOW_IPV4 && \
56 (f)->flags & FLOW_IPV6); \
57 if ((f)->proto == IPPROTO_TCP) { \
58 BUG_ON((f)->alstate != NULL && \
59 (f)->alparser == NULL); \
68 #define DEBUG_VALIDATE_PACKET(p) \
71 if ((p)->flow != NULL) { \
72 DEBUG_VALIDATE_FLOW((p)->flow); \
74 if (!((p)->flags & (PKT_IS_FRAGMENT | PKT_IS_INVALID))) { \
75 if ((p)->proto == IPPROTO_TCP) { \
76 BUG_ON(PacketGetTCP((p)) == NULL); \
77 } else if ((p)->proto == IPPROTO_UDP) { \
78 BUG_ON(PacketGetUDP((p)) == NULL); \
79 } else if ((p)->proto == IPPROTO_ICMP) { \
80 BUG_ON(PacketGetICMPv4((p)) == NULL); \
81 } else if ((p)->proto == IPPROTO_SCTP) { \
82 BUG_ON(PacketGetSCTP((p)) == NULL); \
83 } else if ((p)->proto == IPPROTO_ICMPV6) { \
84 BUG_ON(PacketGetICMPv6((p)) == NULL); \
87 if ((p)->payload_len > 0) { \
88 BUG_ON((p)->payload == NULL); \
90 BUG_ON((p)->flowflags != 0 && (p)->flow == NULL); \
91 BUG_ON((p)->flowflags &FLOW_PKT_TOSERVER && (p)->flowflags & FLOW_PKT_TOCLIENT); \
95 #define DEBUG_VALIDATE_BUG_ON(exp) BUG_ON((exp))
99 #define DEBUG_ASSERT_FLOW_LOCKED(f)
100 #define DEBUG_VALIDATE_FLOW(f)
101 #define DEBUG_VALIDATE_PACKET(p)
102 #define DEBUG_VALIDATE_BUG_ON(exp)