static bool
print_chains(enum fw3_table table, enum fw3_family family,
- const char *fmt, uint8_t flags,
+ const char *fmt, uint16_t flags,
const struct chain *chains, int n)
{
bool rv = false;
defs->tcp_window_scaling = true;
defs->custom_chains = true;
- setbit(defs->flags, FW3_DEFAULT_IPV4_LOADED);
+ setbit(defs->flags, FW3_FAMILY_V4);
uci_foreach_element(&p->sections, e)
{
check_policy(e, &defs->policy_forward, "forward");
if (!defs->disable_ipv6)
- setbit(defs->flags, FW3_DEFAULT_IPV6_LOADED);
+ setbit(defs->flags, FW3_FAMILY_V6);
if (defs->custom_chains)
setbit(defs->flags, FW3_DEFAULT_CUSTOM_CHAINS);
return true;
}
-#define family_flag(f) \
- (f == FW3_FAMILY_V4 ? FW3_DEFAULT_IPV4_LOADED : FW3_DEFAULT_IPV6_LOADED)
-
static bool
family_running(struct list_head *statefile, enum fw3_family family)
{
if (e->type != FW3_TYPE_DEFAULTS)
continue;
- return hasbit(e->flags[0], family_flag(family));
+ return hasbit(e->flags[0], family);
}
}
static bool
family_loaded(struct fw3_state *state, enum fw3_family family)
{
- return hasbit(state->defaults.flags, family_flag(family));
+ return hasbit(state->defaults.flags, family);
}
static void
family_set(struct fw3_state *state, enum fw3_family family, bool set)
{
if (set)
- setbit(state->defaults.flags, family_flag(family));
+ setbit(state->defaults.flags, family);
else
- delbit(state->defaults.flags, family_flag(family));
+ delbit(state->defaults.flags, family);
}
static int
enum fw3_family
{
FW3_FAMILY_ANY = 0,
- FW3_FAMILY_V4 = 1,
- FW3_FAMILY_V6 = 2,
+ FW3_FAMILY_V4 = 4,
+ FW3_FAMILY_V6 = 5,
};
enum fw3_target
{
FW3_TARGET_UNSPEC = 0,
- FW3_TARGET_ACCEPT = 1,
- FW3_TARGET_REJECT = 2,
- FW3_TARGET_DROP = 3,
- FW3_TARGET_NOTRACK = 4,
- FW3_TARGET_DNAT = 5,
- FW3_TARGET_SNAT = 6,
+ FW3_TARGET_ACCEPT = 6,
+ FW3_TARGET_REJECT = 7,
+ FW3_TARGET_DROP = 8,
+ FW3_TARGET_NOTRACK = 9,
+ FW3_TARGET_DNAT = 10,
+ FW3_TARGET_SNAT = 11,
};
enum fw3_default
{
FW3_DEFAULT_UNSPEC = 0,
- FW3_DEFAULT_CUSTOM_CHAINS = 1,
- FW3_DEFAULT_SYN_FLOOD = 2,
- FW3_DEFAULT_MTU_FIX = 3,
- FW3_DEFAULT_DROP_INVALID = 4,
- FW3_DEFAULT_IPV4_LOADED = 5,
- FW3_DEFAULT_IPV6_LOADED = 6,
+ FW3_DEFAULT_CUSTOM_CHAINS = 12,
+ FW3_DEFAULT_SYN_FLOOD = 13,
+ FW3_DEFAULT_MTU_FIX = 14,
+ FW3_DEFAULT_DROP_INVALID = 15,
};
enum fw3_limit_unit
bool disable_ipv6;
- uint8_t flags;
+ uint16_t flags;
};
struct fw3_zone
bool custom_chains;
- uint8_t src_flags;
- uint8_t dst_flags;
+ uint16_t src_flags;
+ uint16_t dst_flags;
};
struct fw3_rule
int timeout;
const char *external;
+
+ uint16_t flags;
};
struct fw3_state
struct fw3_zone *z;
struct fw3_ipset *i;
- int mask = (1 << FW3_DEFAULT_IPV4_LOADED) | (1 << FW3_DEFAULT_IPV6_LOADED);
+ int mask = (1 << FW3_FAMILY_V4) | (1 << FW3_FAMILY_V6);
if (!(d->flags & mask))
{
if (i->external && *i->external)
continue;
- fprintf(sf, "%u %s\n", FW3_TYPE_IPSET, i->name);
+ fprintf(sf, "%u %s %u\n", FW3_TYPE_IPSET, i->name, i->flags);
}
fclose(sf);
static bool
print_chains(enum fw3_table table, enum fw3_family family,
- const char *fmt, const char *name, uint8_t targets,
+ const char *fmt, const char *name, uint16_t targets,
const struct chain *chains, int n)
{
bool rv = false;