From 9867e814492275cabfbccd6b30375b0e23eb10cb Mon Sep 17 00:00:00 2001 From: Yasuyuki KOZAKAI Date: Wed, 22 Jun 2005 12:24:21 +0000 Subject: reduce code replication of parse_interface() (Yasuyuki Kozakai) --- extensions/libip6t_physdev.c | 39 --------------------------------------- extensions/libipt_physdev.c | 39 --------------------------------------- 2 files changed, 78 deletions(-) (limited to 'extensions') diff --git a/extensions/libip6t_physdev.c b/extensions/libip6t_physdev.c index ab2087cb..fb473470 100644 --- a/extensions/libip6t_physdev.c +++ b/extensions/libip6t_physdev.c @@ -34,45 +34,6 @@ static struct option opts[] = { {0} }; -/* copied from iptables.c */ -static void -parse_interface(const char *arg, char *vianame, unsigned char *mask) -{ - int vialen = strlen(arg); - unsigned int i; - - memset(mask, 0, IFNAMSIZ); - memset(vianame, 0, IFNAMSIZ); - - if (vialen + 1 > IFNAMSIZ) - exit_error(PARAMETER_PROBLEM, - "interface name `%s' must be shorter than IFNAMSIZ" - " (%i)", arg, IFNAMSIZ-1); - - strcpy(vianame, arg); - if (vialen == 0) - memset(mask, 0, IFNAMSIZ); - else if (vianame[vialen - 1] == '+') { - memset(mask, 0xFF, vialen - 1); - memset(mask + vialen - 1, 0, IFNAMSIZ - vialen + 1); - /* Don't remove `+' here! -HW */ - } else { - /* Include nul-terminator in match */ - memset(mask, 0xFF, vialen + 1); - memset(mask + vialen + 1, 0, IFNAMSIZ - vialen - 1); - for (i = 0; vianame[i]; i++) { - if (!isalnum(vianame[i]) - && vianame[i] != '_' - && vianame[i] != '.') { - printf("Warning: wierd character in interface" - " `%s' (No aliases, :, ! or *).\n", - vianame); - break; - } - } - } -} - static void init(struct ip6t_entry_match *m, unsigned int *nfcache) { diff --git a/extensions/libipt_physdev.c b/extensions/libipt_physdev.c index 0c4c3576..b6dae2ac 100644 --- a/extensions/libipt_physdev.c +++ b/extensions/libipt_physdev.c @@ -34,45 +34,6 @@ static struct option opts[] = { {0} }; -/* copied from iptables.c */ -static void -parse_interface(const char *arg, char *vianame, unsigned char *mask) -{ - int vialen = strlen(arg); - unsigned int i; - - memset(mask, 0, IFNAMSIZ); - memset(vianame, 0, IFNAMSIZ); - - if (vialen + 1 > IFNAMSIZ) - exit_error(PARAMETER_PROBLEM, - "interface name `%s' must be shorter than IFNAMSIZ" - " (%i)", arg, IFNAMSIZ-1); - - strcpy(vianame, arg); - if (vialen == 0) - memset(mask, 0, IFNAMSIZ); - else if (vianame[vialen - 1] == '+') { - memset(mask, 0xFF, vialen - 1); - memset(mask + vialen - 1, 0, IFNAMSIZ - vialen + 1); - /* Don't remove `+' here! -HW */ - } else { - /* Include nul-terminator in match */ - memset(mask, 0xFF, vialen + 1); - memset(mask + vialen + 1, 0, IFNAMSIZ - vialen - 1); - for (i = 0; vianame[i]; i++) { - if (!isalnum(vianame[i]) - && vianame[i] != '_' - && vianame[i] != '.') { - printf("Warning: wierd character in interface" - " `%s' (No aliases, :, ! or *).\n", - vianame); - break; - } - } - } -} - static void init(struct ipt_entry_match *m, unsigned int *nfcache) { -- cgit v1.2.3