diff options
author | Phil Sutter <phil@nwl.cc> | 2018-08-02 17:05:16 +0200 |
---|---|---|
committer | Florian Westphal <fw@strlen.de> | 2018-08-04 14:26:46 +0200 |
commit | 1cc09188079a64dc8b733f198c959cfb441e6e20 (patch) | |
tree | 4de4832ed055c237569b22491e13e728d3a463dc /iptables/xshared.c | |
parent | 78b9d438037f2c83a7bbb73eb1b86cc295967905 (diff) |
xshared: Consolidate parse_counters()
Move this helper function into xshared. While being at it, drop the need
for temporary variables and take over null pointer tolerance from the
implementation in iptables-xml.c.
Signed-off-by: Phil Sutter <phil@nwl.cc>
Signed-off-by: Florian Westphal <fw@strlen.de>
Diffstat (limited to 'iptables/xshared.c')
-rw-r--r-- | iptables/xshared.c | 14 |
1 files changed, 14 insertions, 0 deletions
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 && |