From ab611e28d2ee6b12670494bb4212679b8c63ce22 Mon Sep 17 00:00:00 2001 From: Bart De Schuymer Date: Mon, 14 Feb 2005 20:20:03 +0000 Subject: complete -c and -C implementation --- communication.c | 13 ++++++++++++- 1 file changed, 12 insertions(+), 1 deletion(-) (limited to 'communication.c') diff --git a/communication.c b/communication.c index e93217a..e429d15 100644 --- a/communication.c +++ b/communication.c @@ -358,6 +358,8 @@ void ebt_deliver_counters(struct ebt_u_replace *u_repl, int exec_style) /* 'Normal' rule, meaning we didn't do anything to it * So, we just copy */ *new = *old; + next->cnt = *new; + next->cnt_surplus.pcnt = next->cnt_surplus.bcnt = 0; /* We've used an old counter */ old++; /* We've set a new counter */ @@ -367,7 +369,16 @@ void ebt_deliver_counters(struct ebt_u_replace *u_repl, int exec_style) /* Don't use this old counter */ old++; } else { - *new = next->cnt; + if (cc->type == CNT_INCR) { + new->pcnt = old->pcnt + next->cnt_surplus.pcnt; + new->bcnt = old->bcnt + next->cnt_surplus.bcnt; + } else if (cc->type == CNT_DECR) { + new->pcnt = old->pcnt - next->cnt_surplus.pcnt; + new->bcnt = old->bcnt - next->cnt_surplus.bcnt; + } else + *new = next->cnt; + next->cnt = *new; + next->cnt_surplus.pcnt = next->cnt_surplus.bcnt = 0; if (cc->type == CNT_ADD) new++; else { -- cgit v1.2.3