}
}
+void
+fw3_ipt_rule_device(struct fw3_ipt_rule *r, const char *device, bool out)
+{
+ if (device) {
+ struct fw3_device dev = { .any = false };
+ strncpy(dev.name, device, sizeof(dev.name) - 1);
+ fw3_ipt_rule_in_out(r, (out) ? NULL : &dev, (out) ? &dev : NULL);
+ }
+}
+
void
fw3_ipt_rule_mac(struct fw3_ipt_rule *r, struct fw3_mac *mac)
{
void fw3_ipt_rule_sport_dport(struct fw3_ipt_rule *r,
struct fw3_port *sp, struct fw3_port *dp);
+void fw3_ipt_rule_device(struct fw3_ipt_rule *r, const char *device, bool out);
+
void fw3_ipt_rule_mac(struct fw3_ipt_rule *r, struct fw3_mac *mac);
void fw3_ipt_rule_icmptype(struct fw3_ipt_rule *r, struct fw3_icmptype *icmp);
return true;
}
+bool
+fw3_parse_direction(void *ptr, const char *val, bool is_list)
+{
+ bool *is_out = ptr;
+ bool valid = true;
+
+ if (!strcmp(val, "in") || !strcmp(val, "ingress"))
+ *is_out = false;
+ else if (!strcmp(val, "out") || !strcmp(val, "egress"))
+ *is_out = true;
+ else
+ valid = false;
+
+ return valid;
+}
+
bool
fw3_parse_options(void *s, const struct fw3_option *opts,
struct fw3_zone *_src;
struct fw3_zone *_dest;
+ const char *device;
+ bool direction_out;
+
struct fw3_device src;
struct fw3_device dest;
struct fw3_setmatch ipset;
struct fw3_device src;
struct fw3_setmatch ipset;
+ const char *device;
struct list_head proto;
bool fw3_parse_monthdays(void *ptr, const char *val, bool is_list);
bool fw3_parse_mark(void *ptr, const char *val, bool is_list);
bool fw3_parse_setmatch(void *ptr, const char *val, bool is_list);
+bool fw3_parse_direction(void *ptr, const char *val, bool is_list);
bool fw3_parse_options(void *s, const struct fw3_option *opts,
struct uci_section *section);
FW3_OPT("src", device, rule, src),
FW3_OPT("dest", device, rule, dest),
+ FW3_OPT("device", string, rule, device),
+ FW3_OPT("direction", direction, rule, direction_out),
+
FW3_OPT("ipset", setmatch, rule, ipset),
FW3_LIST("proto", protocol, rule, proto),
r = fw3_ipt_rule_create(handle, proto, NULL, NULL, sip, dip);
fw3_ipt_rule_sport_dport(r, sport, dport);
+ fw3_ipt_rule_device(r, rule->device, rule->direction_out);
fw3_ipt_rule_icmptype(r, icmptype);
fw3_ipt_rule_mac(r, mac);
fw3_ipt_rule_ipset(r, &rule->ipset);
FW3_OPT("family", family, snat, family),
FW3_OPT("src", device, snat, src),
+ FW3_OPT("device", string, snat, device),
FW3_OPT("ipset", setmatch, snat, ipset),
r = fw3_ipt_rule_create(h, proto, NULL, NULL, src, dst);
fw3_ipt_rule_sport_dport(r, spt, dpt);
+ fw3_ipt_rule_device(r, snat->device, true);
fw3_ipt_rule_ipset(r, &snat->ipset);
fw3_ipt_rule_limit(r, &snat->limit);
fw3_ipt_rule_time(r, &snat->time);