Add abstract fw3_xt_print_matches() and fw3_xt_print_target() functions since the...
[project/firewall3.git] / defaults.c
index 3ed6cfa..ec95ec9 100644 (file)
@@ -22,7 +22,7 @@
 #define C(f, tbl, def, fmt) \
        { FW3_FAMILY_##f, FW3_TABLE_##tbl, FW3_FLAG_##def, fmt }
 
 #define C(f, tbl, def, fmt) \
        { FW3_FAMILY_##f, FW3_TABLE_##tbl, FW3_FLAG_##def, fmt }
 
-static const struct fw3_rule_spec default_chains[] = {
+static const struct fw3_chain_spec default_chains[] = {
        C(ANY, FILTER, UNSPEC,        "delegate_input"),
        C(ANY, FILTER, UNSPEC,        "delegate_output"),
        C(ANY, FILTER, UNSPEC,        "delegate_forward"),
        C(ANY, FILTER, UNSPEC,        "delegate_input"),
        C(ANY, FILTER, UNSPEC,        "delegate_output"),
        C(ANY, FILTER, UNSPEC,        "delegate_forward"),
@@ -130,7 +130,7 @@ fw3_print_default_chains(struct fw3_ipt_handle *handle, struct fw3_state *state,
                          bool reload)
 {
        struct fw3_defaults *defs = &state->defaults;
                          bool reload)
 {
        struct fw3_defaults *defs = &state->defaults;
-       const struct fw3_rule_spec *c;
+       const struct fw3_chain_spec *c;
 
 #define policy(t) \
        ((t == FW3_FLAG_REJECT) ? FW3_FLAG_DROP : t)
 
 #define policy(t) \
        ((t == FW3_FLAG_REJECT) ? FW3_FLAG_DROP : t)
@@ -243,7 +243,7 @@ fw3_print_default_head_rules(struct fw3_ipt_handle *handle,
                        {
                                r = fw3_ipt_rule_new(handle);
                                fw3_ipt_rule_comment(r, "user chain for %s", chains[i+1]);
                        {
                                r = fw3_ipt_rule_new(handle);
                                fw3_ipt_rule_comment(r, "user chain for %s", chains[i+1]);
-                               fw3_ipt_rule_target(r, chains[i+1]);
+                               fw3_ipt_rule_target(r, "%s_rule", chains[i+1]);
                                fw3_ipt_rule_append(r, chains[i]);
                        }
                }
                                fw3_ipt_rule_append(r, chains[i]);
                        }
                }
@@ -392,7 +392,7 @@ fw3_flush_rules(struct fw3_ipt_handle *handle, struct fw3_state *state,
 {
        enum fw3_flag policy = reload ? FW3_FLAG_DROP : FW3_FLAG_ACCEPT;
        struct fw3_defaults *defs = &state->defaults;
 {
        enum fw3_flag policy = reload ? FW3_FLAG_DROP : FW3_FLAG_ACCEPT;
        struct fw3_defaults *defs = &state->defaults;
-       const struct fw3_rule_spec *c;
+       const struct fw3_chain_spec *c;
 
        if (!has(defs->flags, handle->family, handle->table))
                return;
 
        if (!has(defs->flags, handle->family, handle->table))
                return;
@@ -416,8 +416,7 @@ fw3_flush_rules(struct fw3_ipt_handle *handle, struct fw3_state *state,
                if (c->table != handle->table)
                        continue;
 
                if (c->table != handle->table)
                        continue;
 
-               if (c->flag &&
-                   !hasbit(defs->flags[handle->family == FW3_FAMILY_V6], c->flag))
+               if (c->flag && !has(defs->flags, handle->family, c->flag))
                        continue;
 
                fw3_ipt_delete_rules(handle, c->format);
                        continue;
 
                fw3_ipt_delete_rules(handle, c->format);