summaryrefslogtreecommitdiffstats
path: root/include/internal/bitops.h
diff options
context:
space:
mode:
authorPablo Neira Ayuso <pablo@netfilter.org>2008-10-30 20:44:25 +0100
committerPablo Neira Ayuso <pablo@netfilter.org>2008-10-30 20:44:25 +0100
commit7dd5289076160ee2844978bfd1640ca7aa34f4da (patch)
treea91a1c1dcea8238bf01f933352f41526f6581ba0 /include/internal/bitops.h
parent215d42fef86577ad74151cda553a20b1bdb58a30 (diff)
groups: add attribute group API
This new API allows you to set and get some logical set of attributes. This is not intended to replace the existing per-attribute get/set API but to provide more efficient way to get/set certain attributes. This change includes an example file (conntrack_grp_create.c) of the use of the attribute group API. See ATTR_GRP_* for more information on the existing groups. Signed-off-by: Pablo Neira Ayuso <pablo@netfilter.org>
Diffstat (limited to 'include/internal/bitops.h')
-rw-r--r--include/internal/bitops.h31
1 files changed, 31 insertions, 0 deletions
diff --git a/include/internal/bitops.h b/include/internal/bitops.h
index b1bd848..0c1fde8 100644
--- a/include/internal/bitops.h
+++ b/include/internal/bitops.h
@@ -24,9 +24,40 @@ static inline void unset_bit_u16(int nr, u_int16_t *addr)
addr[nr >> 4] &= ~(1UL << (nr & 15));
}
+static inline void
+set_bitmask_u32(u_int32_t *buf1, const u_int32_t *buf2, int len)
+{
+ int i;
+
+ for (i=0; i<len; i++)
+ buf1[i] |= buf2[i];
+}
+
+static inline void
+unset_bitmask_u32(u_int32_t *buf1, const u_int32_t *buf2, int len)
+{
+ int i;
+
+ for (i=0; i<len; i++)
+ buf1[i] &= ~buf2[i];
+}
+
static inline int test_bit(int nr, const u_int32_t *addr)
{
return ((1UL << (nr & 31)) & (addr[nr >> 5])) != 0;
}
+static inline int
+test_bitmask_u32(const uint32_t *buf1, const uint32_t *buf2, int len)
+{
+ int i;
+
+ for (i=0; i<len; i++) {
+ if ((buf1[i] & buf2[i]) != buf2[i]) {
+ return 0;
+ }
+ }
+ return 1;
+}
+
#endif