From 305fed6fe9ab291938a4c97e144ac8db71c3a11e Mon Sep 17 00:00:00 2001 From: Ken-ichirou MATSUZAWA Date: Wed, 10 Sep 2014 17:48:53 +0900 Subject: conntrack: api: add two new bitmask functions This patch adds two functions, useful for ulogd IPFIX output module. Signed-off-by: Ken-ichirou MATSUZAWA Signed-off-by: Florian Westphal --- src/conntrack/api.c | 29 +++++++++++++++++++++++++++++ 1 file changed, 29 insertions(+) (limited to 'src') diff --git a/src/conntrack/api.c b/src/conntrack/api.c index 09270ee..073ea5c 100644 --- a/src/conntrack/api.c +++ b/src/conntrack/api.c @@ -8,6 +8,7 @@ */ #include +#include #include /* for memset */ #include #include @@ -1702,6 +1703,34 @@ void nfct_bitmask_destroy(struct nfct_bitmask *b) free(b); } +/* + * nfct_bitmask_clear - clear a bitmask object + * + * \param b pointer to the bitmask object to clear + */ +void nfct_bitmask_clear(struct nfct_bitmask *b) +{ + unsigned int bytes = b->words * sizeof(b->bits[0]); + memset(b->bits, 0, bytes); +} + +/* + * nfct_bitmask_equal - compare two bitmask objects + * + * \param b1 pointer to a valid bitmask object + * \param b2 pointer to a valid bitmask object + * + * If both bitmask object are equal, this function returns true, otherwise + * false is returned. + */ +bool nfct_bitmask_equal(const struct nfct_bitmask *b1, const struct nfct_bitmask *b2) +{ + if (b1->words != b2->words) + return false; + + return memcmp(b1->bits, b2->bits, b1->words * sizeof(b1->bits[0])) == 0; +} + /** * @} */ -- cgit v1.2.3