]> git.ipfire.org Git - thirdparty/suricata.git/commitdiff
rust/dns: don't compile unused C code if Rust is enabled
authorVictor Julien <victor@inliniac.net>
Tue, 23 Oct 2018 11:21:08 +0000 (13:21 +0200)
committerVictor Julien <victor@inliniac.net>
Tue, 30 Oct 2018 09:21:34 +0000 (10:21 +0100)
src/app-layer-dns-tcp.c
src/app-layer-dns-udp.c
src/util-lua-dns.c

index 8a27985d396d68ec6266fc384b09933b1dba993a..8492de6b44e9335bebc4d78a4f291680d281e878 100644 (file)
@@ -51,6 +51,7 @@
 #include "app-layer-dns-tcp-rust.h"
 #endif
 
+#ifndef HAVE_RUST
 struct DNSTcpHeader_ {
     uint16_t len;
     uint16_t tx_id;
@@ -692,14 +693,15 @@ static uint16_t DNSTcpProbeResponse(Flow *f, uint8_t *input, uint32_t len)
 
     return ALPROTO_DNS;
 }
+#endif /* HAVE_RUST */
 
 void RegisterDNSTCPParsers(void)
 {
-    const char *proto_name = "dns";
 #ifdef HAVE_RUST
     RegisterRustDNSTCPParsers();
     return;
-#endif
+#else
+    const char *proto_name = "dns";
     /** DNS */
     if (AppLayerProtoDetectConfProtoDetectionEnabled("tcp", proto_name)) {
         AppLayerProtoDetectRegisterProtocol(ALPROTO_DNS, proto_name);
@@ -768,16 +770,16 @@ void RegisterDNSTCPParsers(void)
         SCLogInfo("Parsed disabled for %s protocol. Protocol detection"
                   "still on.", proto_name);
     }
-
 #ifdef UNITTESTS
     AppLayerParserRegisterProtocolUnittests(IPPROTO_TCP, ALPROTO_DNS,
         DNSTCPParserRegisterTests);
 #endif
-
     return;
+#endif /* HAVE_RUST */
 }
 
 /* UNITTESTS */
+#ifndef HAVE_RUST
 #ifdef UNITTESTS
 
 #include "util-unittest-helper.h"
@@ -897,3 +899,4 @@ void DNSTCPParserRegisterTests(void)
 }
 
 #endif /* UNITTESTS */
+#endif /* HAVE_RUST */
index 24d68875eb718783c0ac3839df6209ce73206d79..a40377ba494b221d566cf39502de1c413e1128e7 100644 (file)
@@ -54,6 +54,7 @@
 #include "app-layer-dns-udp-rust.h"
 #endif
 
+#ifndef HAVE_RUST
 /** \internal
  *  \brief Parse DNS request packet
  */
@@ -385,15 +386,14 @@ static void DNSUDPConfigure(void)
     SCLogConfig("DNS global memcap: %"PRIu64, global_memcap);
     DNSConfigSetGlobalMemcap(global_memcap);
 }
+#endif /* HAVE_RUST */
 
 void RegisterDNSUDPParsers(void)
 {
-    const char *proto_name = "dns";
-
 #ifdef HAVE_RUST
     return RegisterRustDNSUDPParsers();
-#endif
-
+#else
+    const char *proto_name = "dns";
     /** DNS */
     if (AppLayerProtoDetectConfProtoDetectionEnabled("udp", proto_name)) {
         AppLayerProtoDetectRegisterProtocol(ALPROTO_DNS, proto_name);
@@ -466,9 +466,11 @@ void RegisterDNSUDPParsers(void)
 #ifdef UNITTESTS
     AppLayerParserRegisterProtocolUnittests(IPPROTO_UDP, ALPROTO_DNS, DNSUDPParserRegisterTests);
 #endif
+#endif /* HAVE_RUST */
 }
 
 /* UNITTESTS */
+#ifndef HAVE_RUST
 #ifdef UNITTESTS
 #include "util-unittest-helper.h"
 
@@ -870,3 +872,4 @@ void DNSUDPParserRegisterTests(void)
         DNSUDPParserTestLostResponse);
 }
 #endif
+#endif /* HAVE_RUST */
index c1fe6533c02c39af82c06813940de224ae00fb4f..c825ba00df6b2c53f746556525eff54d99a08b77 100644 (file)
@@ -96,8 +96,8 @@ static int DnsGetDnsRrname(lua_State *luastate)
             return ret;
         }
     }
-#endif
     return LuaCallbackError(luastate, "no query");
+#endif
 }
 
 static int DnsGetTxid(lua_State *luastate)