From 7dd5289076160ee2844978bfd1640ca7aa34f4da Mon Sep 17 00:00:00 2001 From: Pablo Neira Ayuso Date: Thu, 30 Oct 2008 20:44:25 +0100 Subject: 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 --- src/conntrack/grp.c | 69 +++++++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 69 insertions(+) create mode 100644 src/conntrack/grp.c (limited to 'src/conntrack/grp.c') diff --git a/src/conntrack/grp.c b/src/conntrack/grp.c new file mode 100644 index 0000000..739f8c6 --- /dev/null +++ b/src/conntrack/grp.c @@ -0,0 +1,69 @@ +/* + * (C) 2008 by Pablo Neira Ayuso + * + * This software may be used and distributed according to the terms + * of the GNU General Public License, incorporated herein by reference. + */ + +#include "internal/internal.h" + +uint32_t attr_grp_bitmask[ATTR_GRP_MAX][__NFCT_BITSET] = { + [ATTR_GRP_ORIG_IPV4] = { + [0] = (1 << ATTR_ORIG_IPV4_SRC) | + (1 << ATTR_ORIG_IPV4_DST) | + (1 << ATTR_ORIG_L3PROTO), + }, + [ATTR_GRP_REPL_IPV4] = { + [0] = (1 << ATTR_REPL_IPV4_SRC) | + (1 << ATTR_REPL_IPV4_DST) | + (1 << ATTR_REPL_L3PROTO), + }, + [ATTR_GRP_ORIG_IPV6] = { + [0] = (1 << ATTR_ORIG_IPV6_SRC) | + (1 << ATTR_ORIG_IPV6_DST) | + (1 << ATTR_ORIG_L3PROTO), + }, + [ATTR_GRP_REPL_IPV6] = { + [0] = (1 << ATTR_REPL_IPV6_SRC) | + (1 << ATTR_REPL_IPV6_DST) | + (1 << ATTR_REPL_L3PROTO), + }, + [ATTR_GRP_ORIG_PORT] = { + [0] = (1 << ATTR_ORIG_PORT_SRC) | + (1 << ATTR_ORIG_PORT_DST) | + (1 << ATTR_ORIG_L4PROTO), + }, + [ATTR_GRP_REPL_PORT] = { + [0] = (1 << ATTR_REPL_PORT_SRC) | + (1 << ATTR_REPL_PORT_DST) | + (1 << ATTR_REPL_L4PROTO), + }, + [ATTR_GRP_ICMP] = { + [0] = (1 << ATTR_ICMP_CODE) | + (1 << ATTR_ICMP_TYPE) | + (1 << ATTR_ICMP_ID), + }, + [ATTR_GRP_MASTER_IPV4] = { + [1] = (1 << (ATTR_MASTER_IPV4_SRC - 32)) | + (1 << (ATTR_MASTER_IPV4_DST - 32)) | + (1 << (ATTR_MASTER_L3PROTO - 32)), + }, + [ATTR_GRP_MASTER_IPV6] = { + [1] = (1 << (ATTR_MASTER_IPV6_SRC - 32)) | + (1 << (ATTR_MASTER_IPV6_DST - 32)) | + (1 << (ATTR_MASTER_L3PROTO - 32)), + }, + [ATTR_GRP_MASTER_PORT] = { + [1] = (1 << (ATTR_MASTER_PORT_SRC - 32)) | + (1 << (ATTR_MASTER_PORT_DST - 32)) | + (1 << (ATTR_MASTER_L4PROTO - 32)), + }, + [ATTR_GRP_ORIG_COUNTERS] = { + [0] = (1 << (ATTR_ORIG_COUNTER_PACKETS)) | + (1 << (ATTR_ORIG_COUNTER_BYTES)), + }, + [ATTR_GRP_REPL_COUNTERS] = { + [0] = (1 << (ATTR_REPL_COUNTER_PACKETS)) | + (1 << (ATTR_REPL_COUNTER_BYTES)), + }, +}; -- cgit v1.2.3