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 --- include/rule.h | 16 ++++++++++++++++ 1 file changed, 16 insertions(+) (limited to 'include/rule.h') diff --git a/include/rule.h b/include/rule.h index aefb24d9..bee1d447 100644 --- a/include/rule.h +++ b/include/rule.h @@ -6,6 +6,7 @@ #include #include #include /* For NFTNL_CTTIMEOUT_ARRAY_MAX. */ +#include /** * struct handle_spec - handle ID @@ -321,6 +322,21 @@ extern const char *set_policy2str(uint32_t policy); extern void set_print(const struct set *set, struct output_ctx *octx); extern void set_print_plain(const struct set *s, struct output_ctx *octx); +static inline bool set_is_datamap(uint32_t set_flags) +{ + return set_flags & NFT_SET_MAP; +} + +static inline bool set_is_objmap(uint32_t set_flags) +{ + return set_flags & NFT_SET_OBJECT; +} + +static inline bool set_is_map(uint32_t set_flags) +{ + return set_is_datamap(set_flags) || set_is_objmap(set_flags); +} + #include struct counter { -- cgit v1.2.3