]> git.ipfire.org Git - thirdparty/nftables.git/commitdiff
rule: generalize chain_print()
authorArturo Borrero <arturo.borrero.glez@gmail.com>
Mon, 14 Apr 2014 10:17:19 +0000 (12:17 +0200)
committerPablo Neira Ayuso <pablo@netfilter.org>
Fri, 25 Apr 2014 15:45:32 +0000 (17:45 +0200)
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>
include/rule.h
src/rule.c

index 072cff81baf9b70f1f07943391ca459d1b07c009..6c373e6993e49c4519abc56b8c328155f7e65a02 100644 (file)
@@ -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
index accff0fa3a018315b716d2a46cf77d0c3bd7c312..858149ed4e181103f5768a889d07db3cc849b892 100644 (file)
@@ -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;