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@xxxxxxxxx> --- include/rule.h | 1 + src/rule.c | 14 ++++++++++++++ 2 files changed, 15 insertions(+) diff --git a/include/rule.h b/include/rule.h index b263593..9791cea 100644 --- a/include/rule.h +++ b/include/rule.h @@ -126,6 +126,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 c774664..d8a065a 100644 --- a/src/rule.c +++ b/src/rule.c @@ -397,6 +397,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; -- To unsubscribe from this list: send the line "unsubscribe netfilter-devel" in the body of a message to majordomo@xxxxxxxxxxxxxxx More majordomo info at http://vger.kernel.org/majordomo-info.html