]> git.ipfire.org Git - thirdparty/suricata.git/commitdiff
packet: make tcp/udp/icmp vars union non-anonymous
authorVictor Julien <victor@inliniac.net>
Tue, 16 Aug 2016 11:34:38 +0000 (13:34 +0200)
committerVictor Julien <victor@inliniac.net>
Tue, 16 Aug 2016 11:51:06 +0000 (13:51 +0200)
Clean the whole thing after use.

src/decode-icmpv4.h
src/decode-icmpv6.h
src/decode-tcp.h
src/decode.h

index 2f5862d389941a533de9755e3a75b5c783c0d08c..b28dd259a6cd0ce66f03833e858e022275ba6d43 100644 (file)
@@ -198,20 +198,9 @@ typedef struct ICMPV4Vars_
 } ICMPV4Vars;
 
 #define CLEAR_ICMPV4_PACKET(p) do { \
-    (p)->level4_comp_csum = -1; \
-    (p)->icmpv4vars.id = 0; \
-    (p)->icmpv4vars.seq = 0; \
-    (p)->icmpv4vars.emb_ipv4h = NULL; \
-    (p)->icmpv4vars.emb_tcph = NULL; \
-    (p)->icmpv4vars.emb_udph = NULL; \
-    (p)->icmpv4vars.emb_icmpv4h = NULL; \
-    (p)->icmpv4vars.emb_ip4_src.s_addr = 0; \
-    (p)->icmpv4vars.emb_ip4_dst.s_addr = 0; \
-    (p)->icmpv4vars.emb_sport = 0; \
-    (p)->icmpv4vars.emb_ip4_proto = 0; \
-    (p)->icmpv4vars.emb_sport = 0; \
-    (p)->icmpv4vars.emb_dport = 0; \
-    (p)->icmpv4h = NULL; \
+    (p)->level4_comp_csum = -1;     \
+    PACKET_CLEAR_L4VARS((p));       \
+    (p)->icmpv4h = NULL;            \
 } while(0)
 
 #define ICMPV4_HEADER_PKT_OFFSET 8
index af97500607f88356b3570e686ae31c9fb3c300a5..a9a15ff72b1b6168242288a6709f93a43911bb10 100644 (file)
@@ -158,23 +158,9 @@ typedef struct ICMPV6Vars_ {
 
 
 #define CLEAR_ICMPV6_PACKET(p) do { \
-    (p)->level4_comp_csum = -1; \
-    (p)->icmpv6vars.id = 0; \
-    (p)->icmpv6vars.seq = 0; \
-    (p)->icmpv6vars.mtu = 0; \
-    (p)->icmpv6vars.error_ptr = 0; \
-    (p)->icmpv6vars.emb_ipv6h = NULL; \
-    (p)->icmpv6vars.emb_tcph = NULL; \
-    (p)->icmpv6vars.emb_udph = NULL; \
-    (p)->icmpv6vars.emb_icmpv6h = NULL; \
-    (p)->icmpv6vars.emb_ip6_src[0] = 0; \
-    (p)->icmpv6vars.emb_ip6_src[1] = 0; \
-    (p)->icmpv6vars.emb_ip6_src[2] = 0; \
-    (p)->icmpv6vars.emb_ip6_src[3] = 0; \
-    (p)->icmpv6vars.emb_ip6_proto_next = 0; \
-    (p)->icmpv6vars.emb_sport = 0; \
-    (p)->icmpv6vars.emb_dport = 0; \
-    (p)->icmpv6h = NULL; \
+    (p)->level4_comp_csum = -1;     \
+    PACKET_CLEAR_L4VARS((p));       \
+    (p)->icmpv6h = NULL;            \
 } while(0)
 
 void DecodeICMPV6RegisterTests(void);
index 72ed8179740b513e8a87833cdb1d14bf9e4baf09..f9611e723db45a9452b7681ef29704a5982720de 100644 (file)
@@ -151,16 +151,10 @@ typedef struct TCPVars_
     TCPOpt mss;
 } TCPVars;
 
-#define CLEAR_TCP_PACKET(p) { \
-    (p)->tcph = NULL; \
+#define CLEAR_TCP_PACKET(p) {   \
     (p)->level4_comp_csum = -1; \
-    (p)->tcpvars.ts_set = FALSE; \
-    (p)->tcpvars.ts_val = 0; \
-    (p)->tcpvars.ts_ecr = 0; \
-    (p)->tcpvars.sack.type = 0; \
-    (p)->tcpvars.sackok.type = 0; \
-    (p)->tcpvars.ws.type = 0; \
-    (p)->tcpvars.mss.type = 0; \
+    PACKET_CLEAR_L4VARS((p));   \
+    (p)->tcph = NULL;           \
 }
 
 void DecodeTCPRegisterTests(void);
index 886ca2fa1ee881792cddcf8ec1fabeeea8ad5c8c..ff221a6876e18c18fdda4fcd438fd0a9da4c0983 100644 (file)
@@ -470,7 +470,11 @@ typedef struct Packet_
         UDPVars udpvars;
         ICMPV4Vars icmpv4vars;
         ICMPV6Vars icmpv6vars;
-    };
+    } l4vars;
+#define tcpvars     l4vars.tcpvars
+#define udpvars     l4vars.udpvars
+#define icmpv4vars  l4vars.icmpv4vars
+#define icmpv6vars  l4vars.icmpv6vars
 
     TCPHdr *tcph;
 
@@ -659,6 +663,10 @@ typedef struct CaptureStats_ {
 void CaptureStatsUpdate(ThreadVars *tv, CaptureStats *s, const Packet *p);
 void CaptureStatsSetup(ThreadVars *tv, CaptureStats *s);
 
+#define PACKET_CLEAR_L4VARS(p) do {                         \
+        memset(&(p)->l4vars, 0x00, sizeof((p)->l4vars));    \
+    } while (0)
+
 /**
  *  \brief reset these to -1(indicates that the packet is fresh from the queue)
  */