From f012c1f64881404ea183cf86daa2e3760b3c2c2e Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?Fran=C3=A7ois=20De=20Keersmaeker?=
 <francois.dekeersmaeker@uclouvain.be>
Date: Tue, 24 Sep 2024 13:29:10 +0000
Subject: [PATCH] Fixed include

---
 profile_translator_blocklist/templates/CMakeLists.txt.j2 | 6 +++++-
 profile_translator_blocklist/templates/header.c.j2       | 2 ++
 profile_translator_blocklist/translator.py               | 3 ++-
 3 files changed, 9 insertions(+), 2 deletions(-)

diff --git a/profile_translator_blocklist/templates/CMakeLists.txt.j2 b/profile_translator_blocklist/templates/CMakeLists.txt.j2
index 892e6df..c524866 100644
--- a/profile_translator_blocklist/templates/CMakeLists.txt.j2
+++ b/profile_translator_blocklist/templates/CMakeLists.txt.j2
@@ -10,6 +10,10 @@ IF( OPENWRT_CROSSCOMPILING )
 target_link_libraries({{nfqueue_name}} jansson mnl nfnetlink nftnl nftables netfilter_queue netfilter_log)
 ENDIF()
 target_link_libraries({{nfqueue_name}} nfqueue packet_utils rule_utils)
-target_link_libraries({{nfqueue_name}} header {{custom_parsers}})
+{% if domain_names|length > 0 %}
+target_link_libraries({{nfqueue_name}} header dns dns_map)
+{% endif %}
+{% set parsers = custom_parsers - set(["dns"]) if "dns" in custom_parsers else custom_parsers %}
+target_link_libraries({{nfqueue_name}} header {{parsers}})
 target_include_directories({{nfqueue_name}} PRIVATE ${INCLUDE_DIR} ${INCLUDE_PARSERS_DIR})
 install(TARGETS {{nfqueue_name}} DESTINATION ${EXECUTABLE_OUTPUT_PATH})
diff --git a/profile_translator_blocklist/templates/header.c.j2 b/profile_translator_blocklist/templates/header.c.j2
index 8693f29..eeb32fd 100644
--- a/profile_translator_blocklist/templates/header.c.j2
+++ b/profile_translator_blocklist/templates/header.c.j2
@@ -26,12 +26,14 @@
 {% if "dns" in parser %}
 {% set dns_parser_included.value = True %}
 #include "dns.h"
+#include "dns_map.h"
 {% else %}
 #include "{{parser}}.h"
 {% endif %}
 {% endfor %}
 {% if domain_names|length > 0 and not dns_parser_included.value %}
 #include "dns.h"
+#include "dns_map.h"
 {% endif %}
 
 
diff --git a/profile_translator_blocklist/translator.py b/profile_translator_blocklist/translator.py
index a0c6114..c69aa89 100644
--- a/profile_translator_blocklist/translator.py
+++ b/profile_translator_blocklist/translator.py
@@ -233,7 +233,8 @@ def write_firewall(
         cmake_dict = {
             "device":  device["name"],
             "nfqueue_name": nfqueue_name,
-            "custom_parsers": custom_parsers
+            "custom_parsers": custom_parsers,
+            "domain_names": global_accs["domain_names"]
         }
         env.get_template("CMakeLists.txt.j2").stream(cmake_dict).dump(os.path.join(output_dir, "CMakeLists.txt"))
 
-- 
GitLab