introduce support for enabled option in zones, forwards, rules, redirects, ipsets...
[project/firewall3.git] / zones.c
diff --git a/zones.c b/zones.c
index 317acc8..82b76b4 100644 (file)
--- a/zones.c
+++ b/zones.c
@@ -47,11 +47,11 @@ static const struct chain dst_chains[] = {
 
        C(V4,  NAT,    SNAT,    "zone_%s_postrouting"),
        C(V4,  NAT,    DNAT,    "zone_%s_prerouting"),
-
-       C(ANY, RAW,    NOTRACK, "zone_%s_notrack"),
 };
 
-static struct fw3_option zone_opts[] = {
+const struct fw3_option fw3_zone_opts[] = {
+       FW3_OPT("enabled",             bool,     zone,     enabled),
+
        FW3_OPT("name",                string,   zone,     name),
        FW3_OPT("family",              family,   zone,     family),
 
@@ -77,6 +77,8 @@ static struct fw3_option zone_opts[] = {
 
        FW3_OPT("log",                 bool,     zone,     log),
        FW3_OPT("log_limit",           limit,    zone,     log_limit),
+
+       { }
 };
 
 
@@ -162,6 +164,7 @@ fw3_alloc_zone(void)
        INIT_LIST_HEAD(&zone->masq_src);
        INIT_LIST_HEAD(&zone->masq_dest);
 
+       zone->enabled = true;
        zone->log_limit.rate = 10;
 
        return zone;
@@ -189,7 +192,13 @@ fw3_load_zones(struct fw3_state *state, struct uci_package *p)
                if (!zone)
                        continue;
 
-               fw3_parse_options(zone, zone_opts, ARRAY_SIZE(zone_opts), s);
+               fw3_parse_options(zone, fw3_zone_opts, s);
+
+               if (!zone->enabled)
+               {
+                       fw3_free_zone(zone);
+                       continue;
+               }
 
                if (!zone->extra_dest)
                        zone->extra_dest = zone->extra_src;
@@ -520,16 +529,3 @@ fw3_lookup_zone(struct fw3_state *state, const char *name, bool running)
 
        return NULL;
 }
-
-void
-fw3_free_zone(struct fw3_zone *zone)
-{
-       fw3_free_list(&zone->networks);
-       fw3_free_list(&zone->devices);
-       fw3_free_list(&zone->subnets);
-
-       fw3_free_list(&zone->masq_src);
-       fw3_free_list(&zone->masq_dest);
-
-       free(zone);
-}