From c2d9ed99316f26de2d57d9798eee50034114540b Mon Sep 17 00:00:00 2001 From: Pablo Neira Ayuso Date: Fri, 19 Oct 2018 12:55:16 +0200 Subject: libxtables: prefix exported new functions for etherdb lookups To avoid symbol pollution, place them under the xt_ and xtables_ prefix name. Fixes: 31f1434dfe37 ("libxtables: Integrate getethertype.c from xtables core") Reported-by: Florian Westphal Signed-off-by: Pablo Neira Ayuso Acked-by: Phil Sutter --- extensions/libebt_arp.c | 6 +++--- extensions/libebt_vlan.c | 4 ++-- include/ebtables/ethernetdb.h | 22 +++++----------------- iptables/nft-bridge.c | 4 ++-- iptables/xtables-eb-translate.c | 6 +++--- iptables/xtables-eb.c | 6 +++--- libxtables/getethertype.c | 22 +++++++++++----------- 7 files changed, 29 insertions(+), 41 deletions(-) diff --git a/extensions/libebt_arp.c b/extensions/libebt_arp.c index dc8e306a..3a4c29b5 100644 --- a/extensions/libebt_arp.c +++ b/extensions/libebt_arp.c @@ -75,7 +75,7 @@ static void brarp_print_help(void) printf(" %d = %s\n", i + 1, opcodes[i]); printf( " hardware type string: 1 = Ethernet\n" -" protocol type string: see "_PATH_ETHERTYPES"\n"); +" protocol type string: see "_XT_PATH_ETHERTYPES"\n"); } #define OPT_OPCODE 0x01 @@ -262,9 +262,9 @@ brarp_parse(int c, char **argv, int invert, unsigned int *flags, i = strtol(optarg, &end, 16); if (i < 0 || i >= (0x1 << 16) || *end !='\0') { - struct ethertypeent *ent; + struct xt_ethertypeent *ent; - ent = getethertypebyname(argv[optind - 1]); + ent = xtables_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 52cc99fa..57c4dd5b 100644 --- a/extensions/libebt_vlan.c +++ b/extensions/libebt_vlan.c @@ -55,7 +55,7 @@ brvlan_parse(int c, char **argv, int invert, unsigned int *flags, const void *entry, struct xt_entry_match **match) { struct ebt_vlan_info *vlaninfo = (struct ebt_vlan_info *) (*match)->data; - struct ethertypeent *ethent; + struct xt_ethertypeent *ethent; char *end; struct ebt_vlan_info local; @@ -86,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 = getethertypebyname(optarg); + ethent = xtables_getethertypebyname(optarg); if (ethent == NULL) xtables_error(PARAMETER_PROBLEM, "Unknown --vlan-encap value ('%s')", optarg); local.encap = ethent->e_ethertype; diff --git a/include/ebtables/ethernetdb.h b/include/ebtables/ethernetdb.h index 1683abe0..08b43354 100644 --- a/include/ebtables/ethernetdb.h +++ b/include/ebtables/ethernetdb.h @@ -26,32 +26,20 @@ #include /* Absolute file name for network data base files. */ -#ifndef _PATH_ETHERTYPES -#define _PATH_ETHERTYPES "/etc/ethertypes" +#ifndef _XT_PATH_ETHERTYPES +#define _XT_PATH_ETHERTYPES "/etc/ethertypes" #endif /* _PATH_ETHERTYPES */ -struct ethertypeent { +struct xt_ethertypeent { char *e_name; /* Official ethernet type name. */ char **e_aliases; /* Alias list. */ int e_ethertype; /* Ethernet type number. */ }; -/* Open ethertype data base files and mark them as staying open even - after a later search if STAY_OPEN is non-zero. */ -extern void setethertypeent(int __stay_open); - -/* Close ethertype data base files and clear `stay open' flag. */ -extern void endethertypeent(void); - -/* Get next entry from ethertype data base file. Open data base if - necessary. */ -extern struct ethertypeent *getethertypeent(void); - /* Return entry from ethertype data base for network with NAME. */ -extern struct ethertypeent *getethertypebyname(__const char *__name); +extern struct xt_ethertypeent *xtables_getethertypebyname(__const char *__name); /* Return entry from ethertype data base which number is PROTO. */ -extern struct ethertypeent *getethertypebynumber(int __ethertype); - +extern struct xt_ethertypeent *xtables_getethertypebynumber(int __ethertype); #endif /* ethernetdb.h */ diff --git a/iptables/nft-bridge.c b/iptables/nft-bridge.c index 7e659bb5..876981ac 100644 --- a/iptables/nft-bridge.c +++ b/iptables/nft-bridge.c @@ -421,7 +421,7 @@ static void print_mac(char option, const unsigned char *mac, static void print_protocol(uint16_t ethproto, bool invert, unsigned int bitmask) { - struct ethertypeent *ent; + struct xt_ethertypeent *ent; /* Dont print anything about the protocol if no protocol was * specified, obviously this means any protocol will do. */ @@ -437,7 +437,7 @@ static void print_protocol(uint16_t ethproto, bool invert, unsigned int bitmask) return; } - ent = getethertypebynumber(ntohs(ethproto)); + ent = xtables_getethertypebynumber(ntohs(ethproto)); if (!ent) printf("0x%x ", ntohs(ethproto)); else diff --git a/iptables/xtables-eb-translate.c b/iptables/xtables-eb-translate.c index 07d61776..44419751 100644 --- a/iptables/xtables-eb-translate.c +++ b/iptables/xtables-eb-translate.c @@ -465,16 +465,16 @@ print_zero: xtables_error(PARAMETER_PROBLEM, "Problem with the specified protocol"); if (*buffer != '\0') { - struct ethertypeent *ent; + struct xt_ethertypeent *ent; if (!strcasecmp(optarg, "LENGTH")) { cs.eb.bitmask |= EBT_802_3; break; } - ent = getethertypebyname(optarg); + ent = xtables_getethertypebyname(optarg); if (!ent) xtables_error(PARAMETER_PROBLEM, - "Problem with the specified Ethernet protocol '%s', perhaps "_PATH_ETHERTYPES " is missing", optarg); + "Problem with the specified Ethernet protocol '%s', perhaps "_XT_PATH_ETHERTYPES " is missing", optarg); cs.eb.ethproto = ent->e_ethertype; } else cs.eb.ethproto = i; diff --git a/iptables/xtables-eb.c b/iptables/xtables-eb.c index 84d554e9..ecb758c6 100644 --- a/iptables/xtables-eb.c +++ b/iptables/xtables-eb.c @@ -1120,16 +1120,16 @@ print_zero: xtables_error(PARAMETER_PROBLEM, "Problem with the specified protocol"); if (*buffer != '\0') { - struct ethertypeent *ent; + struct xt_ethertypeent *ent; if (!strcasecmp(optarg, "LENGTH")) { cs.eb.bitmask |= EBT_802_3; break; } - ent = getethertypebyname(optarg); + ent = xtables_getethertypebyname(optarg); if (!ent) xtables_error(PARAMETER_PROBLEM, - "Problem with the specified Ethernet protocol '%s', perhaps "_PATH_ETHERTYPES " is missing", optarg); + "Problem with the specified Ethernet protocol '%s', perhaps "_XT_PATH_ETHERTYPES " is missing", optarg); cs.eb.ethproto = ent->e_ethertype; } else cs.eb.ethproto = i; diff --git a/libxtables/getethertype.c b/libxtables/getethertype.c index 027ef4ad..a4c1407c 100644 --- a/libxtables/getethertype.c +++ b/libxtables/getethertype.c @@ -49,20 +49,20 @@ static FILE *etherf = NULL; static char line[BUFSIZ + 1]; -static struct ethertypeent et_ent; +static struct xt_ethertypeent et_ent; static char *ethertype_aliases[MAXALIASES]; static int ethertype_stayopen; -void setethertypeent(int f) +static void setethertypeent(int f) { if (etherf == NULL) - etherf = fopen(_PATH_ETHERTYPES, "r"); + etherf = fopen(_XT_PATH_ETHERTYPES, "r"); else rewind(etherf); ethertype_stayopen |= f; } -void endethertypeent(void) +static void endethertypeent(void) { if (etherf) { fclose(etherf); @@ -71,14 +71,15 @@ void endethertypeent(void) ethertype_stayopen = 0; } -struct ethertypeent *getethertypeent(void) + +static struct xt_ethertypeent *getethertypeent(void) { char *e; char *endptr; register char *cp, **q; if (etherf == NULL - && (etherf = fopen(_PATH_ETHERTYPES, "r")) == NULL) { + && (etherf = fopen(_XT_PATH_ETHERTYPES, "r")) == NULL) { return (NULL); } @@ -127,10 +128,9 @@ again: return (&et_ent); } - -struct ethertypeent *getethertypebyname(const char *name) +struct xt_ethertypeent *xtables_getethertypebyname(const char *name) { - register struct ethertypeent *e; + register struct xt_ethertypeent *e; register char **cp; setethertypeent(ethertype_stayopen); @@ -147,9 +147,9 @@ found: return (e); } -struct ethertypeent *getethertypebynumber(int type) +struct xt_ethertypeent *xtables_getethertypebynumber(int type) { - register struct ethertypeent *e; + register struct xt_ethertypeent *e; setethertypeent(ethertype_stayopen); while ((e = getethertypeent()) != NULL) -- cgit v1.2.3