summaryrefslogtreecommitdiffstats
path: root/src/statement.c
diff options
context:
space:
mode:
authorElise Lennion <elise.lennion@gmail.com>2017-01-16 18:40:40 -0200
committerPablo Neira Ayuso <pablo@netfilter.org>2017-01-16 21:51:20 +0100
commitc5a3c8918330f3b5af883ee5b071989e8917177b (patch)
treeeb1afab56c3bd72c526f61e2ef3309ad4850a842 /src/statement.c
parente3ec9362f0edad08834cb8ba66bc45fdb0bf33f5 (diff)
src: Allow to list ruleset without stateful information
Currently only counter and quota have stateful information. For named counters, packets and bytes are displayed as 0. Standard list ruleset: table ip filter { counter https { packets 161942 bytes 10253353 } chain output { type filter hook output priority 0; policy accept; counter name tcp dport map { https : "https"} tcp dport https counter packets 171211 bytes 10869045 tcp dport https quota 25 mbytes used 10 mbytes } } With stateless option, -s: table ip filter { counter https { packets 0 bytes 0 } chain output { type filter hook output priority 0; policy accept; counter name tcp dport map { https : "https"} tcp dport https counter tcp dport https quota 25 mbytes } } Signed-off-by: Elise Lennion <elise.lennion@gmail.com> Signed-off-by: Pablo Neira Ayuso <pablo@netfilter.org>
Diffstat (limited to 'src/statement.c')
-rw-r--r--src/statement.c9
1 files changed, 7 insertions, 2 deletions
diff --git a/src/statement.c b/src/statement.c
index 24a53ee1..25bed65f 100644
--- a/src/statement.c
+++ b/src/statement.c
@@ -142,7 +142,12 @@ struct stmt *flow_stmt_alloc(const struct location *loc)
static void counter_stmt_print(const struct stmt *stmt)
{
- printf("counter packets %" PRIu64 " bytes %" PRIu64,
+ printf("counter");
+
+ if (stateless_output)
+ return;
+
+ printf(" packets %" PRIu64 " bytes %" PRIu64,
stmt->counter.packets, stmt->counter.bytes);
}
@@ -391,7 +396,7 @@ static void quota_stmt_print(const struct stmt *stmt)
printf("quota %s%"PRIu64" %s",
inv ? "over " : "", bytes, data_unit);
- if (stmt->quota.used) {
+ if (!stateless_output && stmt->quota.used) {
data_unit = get_rate(stmt->quota.used, &used);
printf(" used %"PRIu64" %s", used, data_unit);
}