[PATCH iptables] libxtables: prefix exported new functions for etherdb lookups

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



To avoid symbol pollution, place them under the xt_ and xtables_ prefix
name.

Reported-by: Florian Westphal <fw@xxxxxxxxx>
Signed-off-by: Pablo Neira Ayuso <pablo@xxxxxxxxxxxxx>
---
 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 dc8e306a2879..3a4c29b5fd3e 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 52cc99fa19c7..57c4dd5bca5d 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 1683abe01987..08b433543c67 100644
--- a/include/ebtables/ethernetdb.h
+++ b/include/ebtables/ethernetdb.h
@@ -26,32 +26,20 @@
 #include <stdint.h>
 
 /* 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 7e659bb554a4..876981ac5862 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 07d6177627df..44419751fc85 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 84d554e9b80e..ecb758c65c77 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 027ef4adafe4..a4c1407cf87c 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)
-- 
2.11.0




[Index of Archives]     [Netfitler Users]     [LARTC]     [Bugtraq]     [Yosemite Forum]

  Powered by Linux