summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorArturo Borrero <arturo.borrero.glez@gmail.com>2014-04-14 12:17:19 +0200
committerPablo Neira Ayuso <pablo@netfilter.org>2014-04-25 17:45:32 +0200
commit43ac0090824f5c08ea13add64ace64f9ead8ef1b (patch)
tree3367908ae6a8fa4c58c2980360d2d609ddff4c5f
parentcc1c262073cb0936250ad63f3fb8b038dd7f75ad (diff)
rule: generalize chain_print()
Lest generalize the chain_print() function, so we can print a plain chain as the user typed in the basic CLI. Signed-off-by: Arturo Borrero Gonzalez <arturo.borrero.glez@gmail.com> Signed-off-by: Pablo Neira Ayuso <pablo@netfilter.org>
-rw-r--r--include/rule.h1
-rw-r--r--src/rule.c14
2 files changed, 15 insertions, 0 deletions
diff --git a/include/rule.h b/include/rule.h
index 072cff81..6c373e69 100644
--- a/include/rule.h
+++ b/include/rule.h
@@ -128,6 +128,7 @@ extern struct chain *chain_lookup(const struct table *table,
const struct handle *h);
extern const char *family2str(unsigned int family);
+extern void chain_print_plain(const struct chain *chain);
/**
* struct rule - nftables rule
diff --git a/src/rule.c b/src/rule.c
index accff0fa..858149ed 100644
--- a/src/rule.c
+++ b/src/rule.c
@@ -401,6 +401,20 @@ static void chain_print(const struct chain *chain)
printf("\t}\n");
}
+void chain_print_plain(const struct chain *chain)
+{
+ printf("chain %s %s %s", family2str(chain->handle.family),
+ chain->handle.table, chain->handle.chain);
+
+ if (chain->flags & CHAIN_F_BASECHAIN) {
+ printf(" { type %s hook %s priority %u; }", chain->type,
+ hooknum2str(chain->handle.family, chain->hooknum),
+ chain->priority);
+ }
+
+ printf("\n");
+}
+
struct table *table_alloc(void)
{
struct table *table;