summaryrefslogtreecommitdiffstats
path: root/src/conntrack
diff options
context:
space:
mode:
authorPablo Neira Ayuso <pablo@netfilter.org>2008-10-30 20:52:26 +0100
committerPablo Neira Ayuso <pablo@netfilter.org>2008-10-30 20:52:26 +0100
commit262e67807dbd02f04c43706d79a71cbca5ffed5d (patch)
tree5ffc7f2340c15b08f4dd1c0f45417a65df728bb3 /src/conntrack
parent7dd5289076160ee2844978bfd1640ca7aa34f4da (diff)
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 <pablo@netfilter.org>
Diffstat (limited to 'src/conntrack')
-rw-r--r--src/conntrack/api.c28
1 files changed, 28 insertions, 0 deletions
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
@@ -363,6 +363,34 @@ int nfct_attr_is_set(const struct nf_conntrack *ct,
}
/**
+ * 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<size; i++) {
+ if (unlikely(type_array[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
* @ct: pointer to a valid conntrack object