From: Jo-Philipp Wich Date: Thu, 16 May 2013 20:24:20 +0000 (+0200) Subject: Also add comments for unnamed rules X-Git-Url: https://git.librecmc.org/?a=commitdiff_plain;h=ad958ff26d73f61b6619112564ea5695e024024a;p=oweals%2Ffirewall3.git Also add comments for unnamed rules --- diff --git a/rules.c b/rules.c index 53268e2..145b71f 100644 --- a/rules.c +++ b/rules.c @@ -287,9 +287,18 @@ static void set_target(struct fw3_ipt_rule *r, struct fw3_rule *rule) fw3_ipt_rule_target(r, name); } +static void +set_comment(struct fw3_ipt_rule *r, const char *name, int num) +{ + if (name) + fw3_ipt_rule_comment(r, name); + else + fw3_ipt_rule_comment(r, "@rule[%u]", num); +} + static void print_rule(struct fw3_ipt_handle *handle, struct fw3_state *state, - struct fw3_rule *rule, struct fw3_protocol *proto, + struct fw3_rule *rule, int num, struct fw3_protocol *proto, struct fw3_address *sip, struct fw3_address *dip, struct fw3_port *sport, struct fw3_port *dport, struct fw3_mac *mac, struct fw3_icmptype *icmptype) @@ -319,7 +328,7 @@ print_rule(struct fw3_ipt_handle *handle, struct fw3_state *state, fw3_ipt_rule_mark(r, &rule->mark); set_target(r, rule); fw3_ipt_rule_extra(r, rule->extra); - fw3_ipt_rule_comment(r, rule->name); + set_comment(r, rule->name, num); append_chain(r, rule); } @@ -403,7 +412,7 @@ expand_rule(struct fw3_ipt_handle *handle, struct fw3_state *state, fw3_foreach(dport, dports) fw3_foreach(mac, &rule->mac_src) fw3_foreach(icmptype, icmptypes) - print_rule(handle, state, rule, proto, sip, dip, + print_rule(handle, state, rule, num, proto, sip, dip, sport, dport, mac, icmptype); } }