[netfilter-cvslog] r3986 - in trunk/iptables: . extensions include
laforge at netfilter.org
laforge at netfilter.org
Wed Jun 22 14:24:22 CEST 2005
Author: laforge at netfilter.org
Date: 2005-06-22 14:24:21 +0200 (Wed, 22 Jun 2005)
New Revision: 3986
Modified:
trunk/iptables/extensions/libip6t_physdev.c
trunk/iptables/extensions/libipt_physdev.c
trunk/iptables/include/ip6tables.h
trunk/iptables/include/iptables.h
trunk/iptables/ip6tables.c
trunk/iptables/iptables.c
Log:
reduce code replication of parse_interface() (Yasuyuki Kozakai)
Modified: trunk/iptables/extensions/libip6t_physdev.c
===================================================================
--- trunk/iptables/extensions/libip6t_physdev.c 2005-06-22 12:22:44 UTC (rev 3985)
+++ trunk/iptables/extensions/libip6t_physdev.c 2005-06-22 12:24:21 UTC (rev 3986)
@@ -34,46 +34,7 @@
{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)
{
}
Modified: trunk/iptables/extensions/libipt_physdev.c
===================================================================
--- trunk/iptables/extensions/libipt_physdev.c 2005-06-22 12:22:44 UTC (rev 3985)
+++ trunk/iptables/extensions/libipt_physdev.c 2005-06-22 12:24:21 UTC (rev 3986)
@@ -34,46 +34,7 @@
{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)
{
}
Modified: trunk/iptables/include/ip6tables.h
===================================================================
--- trunk/iptables/include/ip6tables.h 2005-06-22 12:22:44 UTC (rev 3985)
+++ trunk/iptables/include/ip6tables.h 2005-06-22 12:24:21 UTC (rev 3986)
@@ -137,6 +137,8 @@
extern struct ip6tables_target *find_target(const char *name, enum ip6t_tryload);
extern struct ip6tables_match *find_match(const char *name, enum ip6t_tryload, struct ip6tables_rule_match **match);
+extern void parse_interface(const char *arg, char *vianame, unsigned char *mask);
+
extern int for_each_chain(int (*fn)(const ip6t_chainlabel, int, ip6tc_handle_t *), int verbose, int builtinstoo, ip6tc_handle_t *handle);
extern int flush_entries(const ip6t_chainlabel chain, int verbose, ip6tc_handle_t *handle);
extern int delete_chain(const ip6t_chainlabel chain, int verbose, ip6tc_handle_t *handle);
Modified: trunk/iptables/include/iptables.h
===================================================================
--- trunk/iptables/include/iptables.h 2005-06-22 12:22:44 UTC (rev 3985)
+++ trunk/iptables/include/iptables.h 2005-06-22 12:24:21 UTC (rev 3986)
@@ -152,6 +152,7 @@
extern void parse_hostnetworkmask(const char *name, struct in_addr **addrpp,
struct in_addr *maskp, unsigned int *naddrs);
extern u_int16_t parse_protocol(const char *s);
+extern void parse_interface(const char *arg, char *vianame, unsigned char *mask);
extern int do_command(int argc, char *argv[], char **table,
iptc_handle_t *handle);
Modified: trunk/iptables/ip6tables.c
===================================================================
--- trunk/iptables/ip6tables.c 2005-06-22 12:22:44 UTC (rev 3985)
+++ trunk/iptables/ip6tables.c 2005-06-22 12:24:21 UTC (rev 3986)
@@ -829,8 +829,7 @@
return (u_int16_t)proto;
}
-static void
-parse_interface(const char *arg, char *vianame, unsigned char *mask)
+void parse_interface(const char *arg, char *vianame, unsigned char *mask)
{
int vialen = strlen(arg);
unsigned int i;
Modified: trunk/iptables/iptables.c
===================================================================
--- trunk/iptables/iptables.c 2005-06-22 12:22:44 UTC (rev 3985)
+++ trunk/iptables/iptables.c 2005-06-22 12:24:21 UTC (rev 3986)
@@ -769,8 +769,7 @@
return (u_int16_t)proto;
}
-static void
-parse_interface(const char *arg, char *vianame, unsigned char *mask)
+void parse_interface(const char *arg, char *vianame, unsigned char *mask)
{
int vialen = strlen(arg);
unsigned int i;
More information about the netfilter-cvslog
mailing list