From 262e67807dbd02f04c43706d79a71cbca5ffed5d Mon Sep 17 00:00:00 2001 From: Pablo Neira Ayuso Date: Thu, 30 Oct 2008 20:52:26 +0100 Subject: API: add nfct_attr_is_set_array function This new function checks for the presence of a given set of attributes that are passed as an array. Signed-off-by: Pablo Neira Ayuso --- src/conntrack/api.c | 28 ++++++++++++++++++++++++++++ 1 file changed, 28 insertions(+) (limited to 'src/conntrack') diff --git a/src/conntrack/api.c b/src/conntrack/api.c index efd298e..a5ddbc2 100644 --- a/src/conntrack/api.c +++ b/src/conntrack/api.c @@ -362,6 +362,34 @@ int nfct_attr_is_set(const struct nf_conntrack *ct, return test_bit(type, ct->set); } +/** + * nfct_attr_is_set_array - check if an array if attribute types is set + * @ct: pointer to a valid conntrack object + * @array: attribute type array + * @size: size of the array + * + * On error, -1 is returned and errno is set appropiately, otherwise + * the value of the attribute is returned. + */ +int nfct_attr_is_set_array(const struct nf_conntrack *ct, + const enum nf_conntrack_attr *type_array, + int size) +{ + int i; + + assert(ct != NULL); + + for (i=0; i= ATTR_MAX)) { + errno = EINVAL; + return -1; + } + if (!test_bit(type_array[i], ct->set)) + return 0; + } + return 1; +} + /** * nfct_attr_unset - unset a certain attribute * @type: attribute type -- cgit v1.2.3