From: Jan Engelhardt <jengelh@inai.de>
To: pablo@netfilter.org
Cc: netfilter-devel@vger.kernel.org
Subject: [PATCH 4/4] iptables: fall back to using save function when print is not defined
Date: Wed, 6 Feb 2013 01:47:05 +0100 [thread overview]
Message-ID: <1360111625-1759-5-git-send-email-jengelh@inai.de> (raw)
In-Reply-To: <1360111625-1759-1-git-send-email-jengelh@inai.de>
This way we can avoid having to provide two dumping function for new
plugins.
Signed-off-by: Jan Engelhardt <jengelh@inai.de>
---
iptables/ip6tables.c | 10 ++++++++--
iptables/iptables.c | 10 ++++++++--
2 files changed, 16 insertions(+), 4 deletions(-)
diff --git a/iptables/ip6tables.c b/iptables/ip6tables.c
index aeeb62a..6a85d83 100644
--- a/iptables/ip6tables.c
+++ b/iptables/ip6tables.c
@@ -487,10 +487,14 @@ print_match(const struct xt_entry_match *m,
xtables_find_match(m->u.user.name, XTF_TRY_LOAD, NULL);
if (match) {
- if (match->print)
+ if (match->print) {
match->print(ip, m, numeric);
- else
+ } else if (match->save != NULL) {
+ printf("-m %s ", match->name);
+ match->save(ip, m);
+ } else {
printf("%s ", match->name);
+ }
} else {
if (m->u.user.name[0])
printf("UNKNOWN match `%s' ", m->u.user.name);
@@ -617,6 +621,8 @@ print_firewall(const struct ip6t_entry *fw,
if (target->print)
/* Print the target information. */
target->print(&fw->ipv6, t, format & FMT_NUMERIC);
+ else if (target->save != NULL)
+ target->save(&fw->ipv6, t);
} else if (t->u.target_size != sizeof(*t))
printf("[%u bytes of unknown target data] ",
(unsigned int)(t->u.target_size - sizeof(*t)));
diff --git a/iptables/iptables.c b/iptables/iptables.c
index 27bd5b4..757d9d3 100644
--- a/iptables/iptables.c
+++ b/iptables/iptables.c
@@ -472,10 +472,14 @@ print_match(const struct xt_entry_match *m,
xtables_find_match(m->u.user.name, XTF_TRY_LOAD, NULL);
if (match) {
- if (match->print)
+ if (match->print) {
match->print(ip, m, numeric);
- else
+ } else if (match->save != NULL) {
+ printf("-m %s ", match->name);
+ match->save(ip, m);
+ } else {
printf("%s ", match->name);
+ }
} else {
if (m->u.user.name[0])
printf("UNKNOWN match `%s' ", m->u.user.name);
@@ -602,6 +606,8 @@ print_firewall(const struct ipt_entry *fw,
if (target->print)
/* Print the target information. */
target->print(&fw->ip, t, format & FMT_NUMERIC);
+ else if (target->save != NULL)
+ target->save(&fw->ip, t);
} else if (t->u.target_size != sizeof(*t))
printf("[%u bytes of unknown target data] ",
(unsigned int)(t->u.target_size - sizeof(*t)));
--
1.7.10.4
next prev parent reply other threads:[~2013-02-06 0:47 UTC|newest]
Thread overview: 7+ messages / expand[flat|nested] mbox.gz Atom feed top
2013-02-06 0:47 Assorted fixes v3 Jan Engelhardt
2013-02-06 0:47 ` [PATCH 1/4] build: bump SONAME for libxtables Jan Engelhardt
2013-02-06 0:47 ` [PATCH 2/4] libxtables: centralize checking for a .save function Jan Engelhardt
2013-02-06 0:47 ` [PATCH 3/4] extensions: eui64: set userspacesize=0 Jan Engelhardt
2013-02-06 0:47 ` Jan Engelhardt [this message]
2013-02-07 18:53 ` Assorted fixes v3 Pablo Neira Ayuso
2013-02-08 1:11 ` Jan Engelhardt
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=1360111625-1759-5-git-send-email-jengelh@inai.de \
--to=jengelh@inai.de \
--cc=netfilter-devel@vger.kernel.org \
--cc=pablo@netfilter.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).