[libnetfilter_conntrack] API: add nfct_attr_is_set_array function
Pablo Neira
netfilter-cvslog-bounces at lists.netfilter.org
Thu Oct 30 20:52:40 CET 2008
Gitweb: http://git.netfilter.org/cgi-bin/gitweb.cgi?p=libnetfilter_conntrack.git;a=commit;h=262e67807dbd02f04c43706d79a71cbca5ffed5d
commit 262e67807dbd02f04c43706d79a71cbca5ffed5d
Author: Pablo Neira Ayuso <pablo at netfilter.org>
AuthorDate: Thu Oct 30 20:52:26 2008 +0100
Commit: Pablo Neira Ayuso <pablo at netfilter.org>
CommitDate: Thu Oct 30 20:52:26 2008 +0100
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 at netfilter.org>
via 262e67807dbd02f04c43706d79a71cbca5ffed5d (commit)
from 7dd5289076160ee2844978bfd1640ca7aa34f4da (commit)
Those revisions listed above that are new to this repository have
not appeared on any other notification email; so we list those
revisions in full, below.
- Log -----------------------------------------------------------------
commit 262e67807dbd02f04c43706d79a71cbca5ffed5d
Author: Pablo Neira Ayuso <pablo at netfilter.org>
Date: Thu Oct 30 20:52:26 2008 +0100
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 at netfilter.org>
-----------------------------------------------------------------------
.../libnetfilter_conntrack.h | 4 +++
src/conntrack/api.c | 28 ++++++++++++++++++++
2 files changed, 32 insertions(+), 0 deletions(-)
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 at netfilter.org>
diff --git a/include/libnetfilter_conntrack/libnetfilter_conntrack.h b/include/libnetfilter_conntrack/libnetfilter_conntrack.h
index 2fde9a8..0c8b715 100644
--- a/include/libnetfilter_conntrack/libnetfilter_conntrack.h
+++ b/include/libnetfilter_conntrack/libnetfilter_conntrack.h
@@ -273,6 +273,10 @@ extern u_int32_t nfct_get_attr_u32(const struct nf_conntrack *ct,
extern int nfct_attr_is_set(const struct nf_conntrack *ct,
const enum nf_conntrack_attr type);
+extern int nfct_attr_is_set_array(const struct nf_conntrack *ct,
+ const enum nf_conntrack_attr *type_array,
+ int size);
+
/* unsetter */
extern int nfct_attr_unset(struct nf_conntrack *ct,
const enum nf_conntrack_attr type);
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
More information about the netfilter-cvslog
mailing list