diff options
-rw-r--r-- | extensions/libebt_arp.c | 72 | ||||
-rw-r--r-- | extensions/libebt_vlan.c | 72 | ||||
-rw-r--r-- | iptables/Makefile.am | 2 | ||||
-rw-r--r-- | libxtables/Makefile.am | 2 | ||||
-rw-r--r-- | libxtables/getethertype.c (renamed from iptables/getethertype.c) | 0 |
5 files changed, 4 insertions, 144 deletions
diff --git a/extensions/libebt_arp.c b/extensions/libebt_arp.c index 45fc8d73..dc8e306a 100644 --- a/extensions/libebt_arp.c +++ b/extensions/libebt_arp.c @@ -209,76 +209,6 @@ static int brarp_get_mac_and_mask(const char *from, unsigned char *to, unsigned return 0; } -static struct ethertypeent *brarp_getethertypeent(FILE *etherf, const char *name) -{ - static struct ethertypeent et_ent; - char *e, *found_name; - char line[1024]; - - while ((e = fgets(line, sizeof(line), etherf))) { - char *endptr, *cp; - - if (*e == '#') - continue; - - cp = strpbrk(e, "#\n"); - if (cp == NULL) - continue; - *cp = '\0'; - found_name = e; - - cp = strpbrk(e, " \t"); - if (cp == NULL) - continue; - - *cp++ = '\0'; - while (*cp == ' ' || *cp == '\t') - cp++; - e = strpbrk(cp, " \t"); - if (e != NULL) - *e++ = '\0'; - - et_ent.e_ethertype = strtol(cp, &endptr, 16); - if (*endptr != '\0' || - (et_ent.e_ethertype < ETH_ZLEN || et_ent.e_ethertype > 0xFFFF)) - continue; - - if (strcasecmp(found_name, name) == 0) - return (&et_ent); - - if (e != NULL) { - cp = e; - while (cp && *cp) { - if (*cp == ' ' || *cp == '\t') { - cp++; - continue; - } - e = cp; - cp = strpbrk(cp, " \t"); - if (cp != NULL) - *cp++ = '\0'; - if (strcasecmp(e, name) == 0) - return (&et_ent); - e = cp; - } - } - } - - return NULL; -} - -static struct ethertypeent *brarp_getethertypebyname(const char *name) -{ - struct ethertypeent *e; - FILE *etherf; - - etherf = fopen(_PATH_ETHERTYPES, "r"); - - e = brarp_getethertypeent(etherf, name); - fclose(etherf); - return (e); -} - static int brarp_parse(int c, char **argv, int invert, unsigned int *flags, const void *entry, struct xt_entry_match **match) @@ -334,7 +264,7 @@ brarp_parse(int c, char **argv, int invert, unsigned int *flags, if (i < 0 || i >= (0x1 << 16) || *end !='\0') { struct ethertypeent *ent; - ent = brarp_getethertypebyname(argv[optind - 1]); + ent = getethertypebyname(argv[optind - 1]); if (!ent) xtables_error(PARAMETER_PROBLEM, "Problem with specified ARP " "protocol type"); diff --git a/extensions/libebt_vlan.c b/extensions/libebt_vlan.c index 4e2ea0fc..52cc99fa 100644 --- a/extensions/libebt_vlan.c +++ b/extensions/libebt_vlan.c @@ -50,76 +50,6 @@ static void brvlan_print_help(void) "--vlan-encap [!] encap : Encapsulated frame protocol (hexadecimal or name)\n"); } -static struct ethertypeent *vlan_getethertypeent(FILE *etherf, const char *name) -{ - static struct ethertypeent et_ent; - char *e, *found_name; - char line[1024]; - - while ((e = fgets(line, sizeof(line), etherf))) { - char *endptr, *cp; - - if (*e == '#') - continue; - - cp = strpbrk(e, "#\n"); - if (cp == NULL) - continue; - *cp = '\0'; - found_name = e; - - cp = strpbrk(e, " \t"); - if (cp == NULL) - continue; - - *cp++ = '\0'; - while (*cp == ' ' || *cp == '\t') - cp++; - e = strpbrk(cp, " \t"); - if (e != NULL) - *e++ = '\0'; - - et_ent.e_ethertype = strtol(cp, &endptr, 16); - if (*endptr != '\0' || - (et_ent.e_ethertype < ETH_ZLEN || et_ent.e_ethertype > 0xFFFF)) - continue; // skip invalid etherproto type entry - - if (strcasecmp(found_name, name) == 0) - return (&et_ent); - - if (e != NULL) { - cp = e; - while (cp && *cp) { - if (*cp == ' ' || *cp == '\t') { - cp++; - continue; - } - e = cp; - cp = strpbrk(cp, " \t"); - if (cp != NULL) - *cp++ = '\0'; - if (strcasecmp(e, name) == 0) - return (&et_ent); - e = cp; - } - } - } - - return NULL; -} - -static struct ethertypeent *brvlan_getethertypebyname(const char *name) -{ - struct ethertypeent *e; - FILE *etherf; - - etherf = fopen(_PATH_ETHERTYPES, "r"); - - e = vlan_getethertypeent(etherf, name); - fclose(etherf); - return (e); -} - static int brvlan_parse(int c, char **argv, int invert, unsigned int *flags, const void *entry, struct xt_entry_match **match) @@ -156,7 +86,7 @@ brvlan_parse(int c, char **argv, int invert, unsigned int *flags, vlaninfo->invflags |= EBT_VLAN_ENCAP; local.encap = strtoul(optarg, &end, 16); if (*end != '\0') { - ethent = brvlan_getethertypebyname(optarg); + ethent = getethertypebyname(optarg); if (ethent == NULL) xtables_error(PARAMETER_PROBLEM, "Unknown --vlan-encap value ('%s')", optarg); local.encap = ethent->e_ethertype; diff --git a/iptables/Makefile.am b/iptables/Makefile.am index d0218ddc..581dc32b 100644 --- a/iptables/Makefile.am +++ b/iptables/Makefile.am @@ -43,7 +43,7 @@ xtables_nft_multi_SOURCES += xtables-save.c xtables-restore.c \ nft-shared.c nft-ipv4.c nft-ipv6.c nft-arp.c \ xtables-monitor.c \ xtables-arp-standalone.c xtables-arp.c \ - getethertype.c nft-bridge.c \ + nft-bridge.c \ xtables-eb-standalone.c xtables-eb.c \ xtables-eb-translate.c \ xtables-translate.c diff --git a/libxtables/Makefile.am b/libxtables/Makefile.am index 4267cb5f..8ff6b0ca 100644 --- a/libxtables/Makefile.am +++ b/libxtables/Makefile.am @@ -4,7 +4,7 @@ AM_CFLAGS = ${regular_CFLAGS} AM_CPPFLAGS = ${regular_CPPFLAGS} -I${top_builddir}/include -I${top_srcdir}/include -I${top_srcdir}/iptables ${kinclude_CPPFLAGS} lib_LTLIBRARIES = libxtables.la -libxtables_la_SOURCES = xtables.c xtoptions.c +libxtables_la_SOURCES = xtables.c xtoptions.c getethertype.c libxtables_la_LDFLAGS = -version-info ${libxtables_vcurrent}:0:${libxtables_vage} libxtables_la_LIBADD = if ENABLE_STATIC diff --git a/iptables/getethertype.c b/libxtables/getethertype.c index 027ef4ad..027ef4ad 100644 --- a/iptables/getethertype.c +++ b/libxtables/getethertype.c |