From 0fd53234e360d4dde8aa53dbcaad89495a4fab7f Mon Sep 17 00:00:00 2001 From: Pablo Neira Ayuso Date: Mon, 15 Jul 2019 08:26:43 +0200 Subject: src: add set_is_datamap(), set_is_objmap() and set_is_map() helpers Two map types are currently possible: * data maps, ie. set_is_datamap(). * object maps, ie. set_is_objmap(). This patch adds helper functions to check for the map type. set_is_map() allows you to check for either map type. Signed-off-by: Pablo Neira Ayuso --- src/rule.c | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) (limited to 'src/rule.c') diff --git a/src/rule.c b/src/rule.c index 0a91917f..e04fc09b 100644 --- a/src/rule.c +++ b/src/rule.c @@ -449,7 +449,7 @@ static void set_print_declaration(const struct set *set, if ((set->flags & (NFT_SET_EVAL | NFT_SET_ANONYMOUS)) == (NFT_SET_EVAL | NFT_SET_ANONYMOUS)) type = "meter"; - else if (set->flags & (NFT_SET_MAP | NFT_SET_OBJECT)) + else if (set_is_map(set->flags)) type = "map"; else type = "set"; @@ -469,9 +469,9 @@ static void set_print_declaration(const struct set *set, nft_print(octx, "%s", opts->nl); nft_print(octx, "%s%stype %s", opts->tab, opts->tab, set->key->dtype->name); - if (set->flags & NFT_SET_MAP) + if (set_is_datamap(set->flags)) nft_print(octx, " : %s", set->datatype->name); - else if (set->flags & NFT_SET_OBJECT) + else if (set_is_objmap(set->flags)) nft_print(octx, " : %s", obj_type_name(set->objtype)); nft_print(octx, "%s", opts->stmt_separator); -- cgit v1.2.3