X-Git-Url: http://git.archive.openwrt.org/?p=project%2Ffirewall3.git;a=blobdiff_plain;f=zones.c;h=ab656ef75381e82d8dec10b04a9593250547099b;hp=86f794816f5d26fd6a3daa25a9844c85b6d81c45;hb=c7fc65809ae5300f256a1228f7011a1dc1bc85ac;hpb=9d72f0ecb589960bfe21751fbef470116c041a3d diff --git a/zones.c b/zones.c index 86f7948..ab656ef 100644 --- a/zones.c +++ b/zones.c @@ -35,9 +35,9 @@ static const struct chain src_chains[] = { C(ANY, FILTER, UNSPEC, "zone_%1$s_output"), C(ANY, FILTER, UNSPEC, "zone_%1$s_forward"), - C(ANY, FILTER, ACCEPT, "zone_%1$s_src_ACCEPT"), - C(ANY, FILTER, REJECT, "zone_%1$s_src_REJECT"), - C(ANY, FILTER, DROP, "zone_%1$s_src_DROP"), + C(ANY, FILTER, SRC_ACCEPT, "zone_%1$s_src_ACCEPT"), + C(ANY, FILTER, SRC_REJECT, "zone_%1$s_src_REJECT"), + C(ANY, FILTER, SRC_DROP, "zone_%1$s_src_DROP"), }; static const struct chain dst_chains[] = { @@ -255,19 +255,19 @@ fw3_load_zones(struct fw3_state *state, struct uci_package *p) if (zone->masq) { - setbit(zone->dst_flags, FW3_TARGET_SNAT); + setbit(zone->flags, FW3_TARGET_SNAT); zone->conntrack = true; } if (zone->custom_chains) { - setbit(zone->dst_flags, FW3_TARGET_SNAT); - setbit(zone->dst_flags, FW3_TARGET_DNAT); + setbit(zone->flags, FW3_TARGET_SNAT); + setbit(zone->flags, FW3_TARGET_DNAT); } - setbit(zone->src_flags, zone->policy_input); - setbit(zone->dst_flags, zone->policy_output); - setbit(zone->dst_flags, zone->policy_forward); + setbit(zone->flags, fw3_to_src_target(zone->policy_input)); + setbit(zone->flags, zone->policy_output); + setbit(zone->flags, zone->policy_forward); list_add_tail(&zone->list, &state->zones); } @@ -285,30 +285,30 @@ print_zone_chain(enum fw3_table table, enum fw3_family family, if (!fw3_is_family(zone, family)) return; - setbit(zone->dst_flags, family); + setbit(zone->flags, family); /* user chains already loaded, don't create again */ for (f = FW3_TARGET_CUSTOM_CNS_V4; f <= FW3_TARGET_CUSTOM_CNS_V6; f++) - if (hasbit(zone->running_dst_flags, f)) + if (hasbit(zone->running_flags, f)) delbit(custom_mask, f); if (zone->custom_chains) - setbit(zone->dst_flags, (family == FW3_FAMILY_V4) ? + setbit(zone->flags, (family == FW3_FAMILY_V4) ? FW3_TARGET_CUSTOM_CNS_V4 : FW3_TARGET_CUSTOM_CNS_V6); if (!zone->conntrack && !state->defaults.drop_invalid) - setbit(zone->dst_flags, FW3_TARGET_NOTRACK); + setbit(zone->flags, FW3_TARGET_NOTRACK); s = print_chains(table, family, ":%s - [0:0]\n", zone->name, - zone->src_flags, + zone->flags, src_chains, ARRAY_SIZE(src_chains)); d = print_chains(table, family, ":%s - [0:0]\n", zone->name, - zone->dst_flags & custom_mask, + zone->flags & custom_mask, dst_chains, ARRAY_SIZE(dst_chains)); r = print_chains(table, family, "-A %s\n", zone->name, - zone->dst_flags, + zone->flags, def_rules, ARRAY_SIZE(def_rules)); if (s || d || r) @@ -332,7 +332,7 @@ print_interface_rule(enum fw3_table table, enum fw3_family family, { for (t = FW3_TARGET_ACCEPT; t <= FW3_TARGET_DROP; t++) { - if (hasbit(zone->src_flags, t)) + if (hasbit(zone->flags, fw3_to_src_target(t))) { fw3_pr("-A zone_%s_src_%s", zone->name, fw3_flag_names[t]); fw3_format_in_out(dev, NULL); @@ -341,7 +341,7 @@ print_interface_rule(enum fw3_table table, enum fw3_family family, fw3_pr(" -j %s\n", jump_target(t)); } - if (hasbit(zone->dst_flags, t)) + if (hasbit(zone->flags, t)) { fw3_pr("-A zone_%s_dest_%s", zone->name, fw3_flag_names[t]); fw3_format_in_out(NULL, dev); @@ -371,7 +371,7 @@ print_interface_rule(enum fw3_table table, enum fw3_family family, } else if (table == FW3_TABLE_NAT) { - if (hasbit(zone->dst_flags, FW3_TARGET_DNAT)) + if (hasbit(zone->flags, FW3_TARGET_DNAT)) { fw3_pr("-A delegate_prerouting"); fw3_format_in_out(dev, NULL); @@ -380,7 +380,7 @@ print_interface_rule(enum fw3_table table, enum fw3_family family, fw3_pr(" -j zone_%s_prerouting\n", zone->name); } - if (hasbit(zone->dst_flags, FW3_TARGET_SNAT)) + if (hasbit(zone->flags, FW3_TARGET_SNAT)) { fw3_pr("-A delegate_postrouting"); fw3_format_in_out(NULL, dev); @@ -474,7 +474,7 @@ print_zone_rule(enum fw3_table table, enum fw3_family family, { for (t = FW3_TARGET_REJECT; t <= FW3_TARGET_DROP; t++) { - if (hasbit(zone->src_flags, t)) + if (hasbit(zone->flags, fw3_to_src_target(t))) { fw3_pr("-A zone_%s_src_%s", zone->name, fw3_flag_names[t]); fw3_format_limit(&zone->log_limit); @@ -482,7 +482,7 @@ print_zone_rule(enum fw3_table table, enum fw3_family family, fw3_flag_names[t], zone->name); } - if (hasbit(zone->dst_flags, t)) + if (hasbit(zone->flags, t)) { fw3_pr("-A zone_%s_dest_%s", zone->name, fw3_flag_names[t]); fw3_format_limit(&zone->log_limit); @@ -540,7 +540,6 @@ fw3_flush_zones(enum fw3_table table, enum fw3_family family, { struct fw3_zone *z, *tmp; uint32_t custom_mask = ~0; - uint32_t family_mask = (1 << FW3_FAMILY_V4) | (1 << FW3_FAMILY_V6); /* don't touch user chains on selective stop */ if (reload) @@ -551,22 +550,22 @@ fw3_flush_zones(enum fw3_table table, enum fw3_family family, list_for_each_entry_safe(z, tmp, &state->running_zones, running_list) { - if (!hasbit(z->dst_flags, family)) + if (!hasbit(z->flags, family)) continue; print_chains(table, family, pass2 ? "-X %s\n" : "-F %s\n", - z->name, z->running_src_flags, + z->name, z->running_flags, src_chains, ARRAY_SIZE(src_chains)); print_chains(table, family, pass2 ? "-X %s\n" : "-F %s\n", - z->name, z->running_dst_flags & custom_mask, + z->name, z->running_flags & custom_mask, dst_chains, ARRAY_SIZE(dst_chains)); if (pass2) { - delbit(z->dst_flags, family); + delbit(z->flags, family); - if (!(z->dst_flags & family_mask)) + if (fw3_no_family(z)) fw3_set_running(z, NULL); } }