summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--iptables/ip6tables-restore.c11
-rw-r--r--iptables/iptables-restore.c11
-rw-r--r--iptables/iptables-xml.c16
-rw-r--r--iptables/xshared.c14
-rw-r--r--iptables/xshared.h1
-rw-r--r--iptables/xtables-restore.c11
6 files changed, 15 insertions, 49 deletions
diff --git a/iptables/ip6tables-restore.c b/iptables/ip6tables-restore.c
index 3065768e..f2bd93d7 100644
--- a/iptables/ip6tables-restore.c
+++ b/iptables/ip6tables-restore.c
@@ -79,17 +79,6 @@ static struct xtc_handle *create_handle(const char *tablename)
return handle;
}
-static int parse_counters(char *string, struct xt_counters *ctr)
-{
- unsigned long long pcnt, bcnt;
- int ret;
-
- ret = sscanf(string, "[%llu:%llu]", &pcnt, &bcnt);
- ctr->pcnt = pcnt;
- ctr->bcnt = bcnt;
- return ret == 2;
-}
-
/* global new argv and argc */
static char *newargv[255];
static int newargc;
diff --git a/iptables/iptables-restore.c b/iptables/iptables-restore.c
index e52e8e47..a1ae0311 100644
--- a/iptables/iptables-restore.c
+++ b/iptables/iptables-restore.c
@@ -76,17 +76,6 @@ static struct xtc_handle *create_handle(const char *tablename)
return handle;
}
-static int parse_counters(char *string, struct xt_counters *ctr)
-{
- unsigned long long pcnt, bcnt;
- int ret;
-
- ret = sscanf(string, "[%llu:%llu]", &pcnt, &bcnt);
- ctr->pcnt = pcnt;
- ctr->bcnt = bcnt;
- return ret == 2;
-}
-
/* global new argv and argc */
static char *newargv[255];
static int newargc;
diff --git a/iptables/iptables-xml.c b/iptables/iptables-xml.c
index a1b09f3a..8ba45d55 100644
--- a/iptables/iptables-xml.c
+++ b/iptables/iptables-xml.c
@@ -50,22 +50,6 @@ print_usage(const char *name, const char *version)
exit(1);
}
-static int
-parse_counters(char *string, struct xt_counters *ctr)
-{
- __u64 *pcnt, *bcnt;
-
- if (string != NULL) {
- pcnt = &ctr->pcnt;
- bcnt = &ctr->bcnt;
- return (sscanf
- (string, "[%llu:%llu]",
- (unsigned long long *)pcnt,
- (unsigned long long *)bcnt) == 2);
- } else
- return (0 == 2);
-}
-
/* global new argv and argc */
static char *newargv[255];
static unsigned int newargc;
diff --git a/iptables/xshared.c b/iptables/xshared.c
index 06db72d4..ec5c4955 100644
--- a/iptables/xshared.c
+++ b/iptables/xshared.c
@@ -359,6 +359,20 @@ void parse_wait_interval(int argc, char *argv[], struct timeval *wait_interval)
xtables_error(PARAMETER_PROBLEM, "wait interval not numeric");
}
+int parse_counters(const char *string, struct xt_counters *ctr)
+{
+ int ret;
+
+ if (!string)
+ return 0;
+
+ ret = sscanf(string, "[%llu:%llu]",
+ (unsigned long long *)&ctr->pcnt,
+ (unsigned long long *)&ctr->bcnt);
+
+ return ret == 2;
+}
+
inline bool xs_has_arg(int argc, char *argv[])
{
return optind < argc &&
diff --git a/iptables/xshared.h b/iptables/xshared.h
index 363549db..55249341 100644
--- a/iptables/xshared.h
+++ b/iptables/xshared.h
@@ -150,6 +150,7 @@ extern int xtables_lock_or_exit(int wait, struct timeval *tv);
int parse_wait_time(int argc, char *argv[]);
void parse_wait_interval(int argc, char *argv[], struct timeval *wait_interval);
+int parse_counters(const char *string, struct xt_counters *ctr);
bool xs_has_arg(int argc, char *argv[]);
extern const struct xtables_afinfo *afinfo;
diff --git a/iptables/xtables-restore.c b/iptables/xtables-restore.c
index 0a3d1a31..018d3fd3 100644
--- a/iptables/xtables-restore.c
+++ b/iptables/xtables-restore.c
@@ -56,17 +56,6 @@ static void print_usage(const char *name, const char *version)
" [ --ipv6 ]\n", name);
}
-static int parse_counters(char *string, struct xt_counters *ctr)
-{
- unsigned long long pcnt, bcnt;
- int ret;
-
- ret = sscanf(string, "[%llu:%llu]", &pcnt, &bcnt);
- ctr->pcnt = pcnt;
- ctr->bcnt = bcnt;
- return ret == 2;
-}
-
/* global new argv and argc */
static char *newargv[255];
static int newargc;