diff options
author | Florian Westphal <fw@strlen.de> | 2018-05-08 09:41:47 +0200 |
---|---|---|
committer | Florian Westphal <fw@strlen.de> | 2018-05-10 02:31:05 +0200 |
commit | 0ae81d09c93a6c27573ae561f2af09153a5f3e51 (patch) | |
tree | d737e5deb49aa62cde09959f5b726db5f8d20fe0 /iptables/xtables-eb-translate.c | |
parent | 651cfee91a8f42336b9d794c838b9f4f480308c9 (diff) |
xtables-compat: ebtables: kill ebtables_command_state
Use iptables_command_state instead.
This allows to re-use code from the ip(6)tables layer and
reduces cop&pasted code.
Signed-off-by: Florian Westphal <fw@strlen.de>
Diffstat (limited to 'iptables/xtables-eb-translate.c')
-rw-r--r-- | iptables/xtables-eb-translate.c | 54 |
1 files changed, 27 insertions, 27 deletions
diff --git a/iptables/xtables-eb-translate.c b/iptables/xtables-eb-translate.c index 42db2d01..5b0bbb41 100644 --- a/iptables/xtables-eb-translate.c +++ b/iptables/xtables-eb-translate.c @@ -165,7 +165,7 @@ static struct option *merge_options(struct option *oldopts, /* * More glue code. */ -static struct xtables_target *command_jump(struct ebtables_command_state *cs, +static struct xtables_target *command_jump(struct iptables_command_state *cs, const char *jumpto) { struct xtables_target *target; @@ -234,7 +234,7 @@ static int parse_rule_range(const char *argv, int *rule_nr, int *rule_nr_end) /* Incrementing or decrementing rules in daemon mode is not supported as the * involved code overload is not worth it (too annoying to take the increased * counters in the kernel into account). */ -static int parse_change_counters_rule(int argc, char **argv, int *rule_nr, int *rule_nr_end, int exec_style, struct ebtables_command_state *cs) +static int parse_change_counters_rule(int argc, char **argv, int *rule_nr, int *rule_nr_end, int exec_style, struct iptables_command_state *cs) { char *buffer; int ret = 0; @@ -321,7 +321,7 @@ static void print_ebt_cmd(int argc, char *argv[]) } static int nft_rule_eb_xlate_add(struct nft_handle *h, const struct nft_xt_cmd_parse *p, - const struct ebtables_command_state *cs, bool append) + const struct iptables_command_state *cs, bool append) { struct xt_xlate *xl = xt_xlate_alloc(10240); int ret; @@ -352,7 +352,7 @@ static int do_commandeb_xlate(struct nft_handle *h, int argc, char *argv[], char unsigned int flags = 0; struct xtables_target *t, *w; struct xtables_match *m; - struct ebtables_command_state cs; + struct iptables_command_state cs; char command = 'h'; const char *chain = NULL; int exec_style = EXEC_STYLE_PRG; @@ -537,14 +537,14 @@ print_zero: xtables_error(PARAMETER_PROBLEM, "Use -i only in INPUT, FORWARD, PREROUTING and BROUTING chains"); if (ebt_check_inverse2(optarg, argc, argv)) - cs.fw.invflags |= EBT_IIN; + cs.eb.invflags |= EBT_IIN; if (strlen(optarg) >= IFNAMSIZ) big_iface_length: xtables_error(PARAMETER_PROBLEM, "Interface name length cannot exceed %d characters", IFNAMSIZ - 1); - xtables_parse_interface(optarg, cs.fw.in, cs.fw.in_mask); + xtables_parse_interface(optarg, cs.eb.in, cs.eb.in_mask); break; } else if (c == 2) { ebt_check_option2(&flags, OPT_LOGICALIN); @@ -552,12 +552,12 @@ big_iface_length: xtables_error(PARAMETER_PROBLEM, "Use --logical-in only in INPUT, FORWARD, PREROUTING and BROUTING chains"); if (ebt_check_inverse2(optarg, argc, argv)) - cs.fw.invflags |= EBT_ILOGICALIN; + cs.eb.invflags |= EBT_ILOGICALIN; if (strlen(optarg) >= IFNAMSIZ) goto big_iface_length; - strcpy(cs.fw.logical_in, optarg); - if (parse_iface(cs.fw.logical_in, "--logical-in")) + strcpy(cs.eb.logical_in, optarg); + if (parse_iface(cs.eb.logical_in, "--logical-in")) return -1; break; } else if (c == 'o') { @@ -566,12 +566,12 @@ big_iface_length: xtables_error(PARAMETER_PROBLEM, "Use -o only in OUTPUT, FORWARD and POSTROUTING chains"); if (ebt_check_inverse2(optarg, argc, argv)) - cs.fw.invflags |= EBT_IOUT; + cs.eb.invflags |= EBT_IOUT; if (strlen(optarg) >= IFNAMSIZ) goto big_iface_length; - xtables_parse_interface(optarg, cs.fw.out, cs.fw.out_mask); + xtables_parse_interface(optarg, cs.eb.out, cs.eb.out_mask); break; } else if (c == 3) { ebt_check_option2(&flags, OPT_LOGICALOUT); @@ -579,12 +579,12 @@ big_iface_length: xtables_error(PARAMETER_PROBLEM, "Use --logical-out only in OUTPUT, FORWARD and POSTROUTING chains"); if (ebt_check_inverse2(optarg, argc, argv)) - cs.fw.invflags |= EBT_ILOGICALOUT; + cs.eb.invflags |= EBT_ILOGICALOUT; if (strlen(optarg) >= IFNAMSIZ) goto big_iface_length; - strcpy(cs.fw.logical_out, optarg); - if (parse_iface(cs.fw.logical_out, "--logical-out")) + strcpy(cs.eb.logical_out, optarg); + if (parse_iface(cs.eb.logical_out, "--logical-out")) return -1; break; } else if (c == 'j') { @@ -595,20 +595,20 @@ big_iface_length: } else if (c == 's') { ebt_check_option2(&flags, OPT_SOURCE); if (ebt_check_inverse2(optarg, argc, argv)) - cs.fw.invflags |= EBT_ISOURCE; + cs.eb.invflags |= EBT_ISOURCE; - if (ebt_get_mac_and_mask(optarg, cs.fw.sourcemac, cs.fw.sourcemsk)) + if (ebt_get_mac_and_mask(optarg, cs.eb.sourcemac, cs.eb.sourcemsk)) xtables_error(PARAMETER_PROBLEM, "Problem with specified source mac '%s'", optarg); - cs.fw.bitmask |= EBT_SOURCEMAC; + cs.eb.bitmask |= EBT_SOURCEMAC; break; } else if (c == 'd') { ebt_check_option2(&flags, OPT_DEST); if (ebt_check_inverse2(optarg, argc, argv)) - cs.fw.invflags |= EBT_IDEST; + cs.eb.invflags |= EBT_IDEST; - if (ebt_get_mac_and_mask(optarg, cs.fw.destmac, cs.fw.destmsk)) + if (ebt_get_mac_and_mask(optarg, cs.eb.destmac, cs.eb.destmsk)) xtables_error(PARAMETER_PROBLEM, "Problem with specified destination mac '%s'", optarg); - cs.fw.bitmask |= EBT_DESTMAC; + cs.eb.bitmask |= EBT_DESTMAC; break; } else if (c == 'c') { ebt_check_option2(&flags, OPT_COUNT); @@ -634,9 +634,9 @@ big_iface_length: } ebt_check_option2(&flags, OPT_PROTOCOL); if (ebt_check_inverse2(optarg, argc, argv)) - cs.fw.invflags |= EBT_IPROTO; + cs.eb.invflags |= EBT_IPROTO; - cs.fw.bitmask &= ~((unsigned int)EBT_NOPROTO); + cs.eb.bitmask &= ~((unsigned int)EBT_NOPROTO); i = strtol(optarg, &buffer, 16); if (*buffer == '\0' && (i < 0 || i > 0xFFFF)) xtables_error(PARAMETER_PROBLEM, @@ -645,18 +645,18 @@ big_iface_length: struct ethertypeent *ent; if (!strcasecmp(optarg, "LENGTH")) { - cs.fw.bitmask |= EBT_802_3; + cs.eb.bitmask |= EBT_802_3; break; } ent = getethertypebyname(optarg); if (!ent) xtables_error(PARAMETER_PROBLEM, "Problem with the specified Ethernet protocol '%s', perhaps "_PATH_ETHERTYPES " is missing", optarg); - cs.fw.ethproto = ent->e_ethertype; + cs.eb.ethproto = ent->e_ethertype; } else - cs.fw.ethproto = i; + cs.eb.ethproto = i; - if (cs.fw.ethproto < 0x0600) + if (cs.eb.ethproto < 0x0600) xtables_error(PARAMETER_PROBLEM, "Sorry, protocols have values above or equal to 0x0600"); break; @@ -757,7 +757,7 @@ check_extension: xtables_option_tfcall(cs.target); } - cs.fw.ethproto = htons(cs.fw.ethproto); + cs.eb.ethproto = htons(cs.eb.ethproto); if (command == 'P') { return 0; |