summaryrefslogtreecommitdiffstats
path: root/src/datatype.c
diff options
context:
space:
mode:
authorPatrick McHardy <kaber@trash.net>2014-12-13 07:50:35 +0000
committerPatrick McHardy <kaber@trash.net>2014-12-16 18:20:54 +0100
commit51425ecaa06296c467fded2ad5bf1b23f8a90cdd (patch)
treeb4bd61c545c9ac9be7a57b051e5c597e7dbbbf41 /src/datatype.c
parent0b915d6dc50e9e5aeb3e41db9d20dc96d9edee3f (diff)
datatype: add define for maximum number of bits and mask of datatype id
The id of concat datatypes is composed of the ids of the individual datatypes. Add a define for the number of bits for each datatype id and a mask. The number of bits is chosen as 6, allowing for 63 datatypes, or twice as much as we currently have. This allows for concatenations of 5 types using 32 bits. The value is statically chosen instead of basing it on the current numbers of datatypes since we don't want the maximum concatenation size to vary between versions, also new versions are supposed to be able to propery parse a ruleset generated by an older version. Signed-off-by: Patrick McHardy <kaber@trash.net>
Diffstat (limited to 'src/datatype.c')
-rw-r--r--src/datatype.c3
1 files changed, 2 insertions, 1 deletions
diff --git a/src/datatype.c b/src/datatype.c
index 8583531f..91e5ed6d 100644
--- a/src/datatype.c
+++ b/src/datatype.c
@@ -51,6 +51,7 @@ static const struct datatype *datatypes[TYPE_MAX + 1] = {
void datatype_register(const struct datatype *dtype)
{
+ BUILD_BUG_ON(TYPE_MAX & ~TYPE_MASK);
datatypes[dtype->type] = dtype;
}
@@ -939,7 +940,7 @@ const struct datatype *concat_type_alloc(const struct expr *expr)
strncat(desc, i->dtype->desc, sizeof(desc) - strlen(desc) - 1);
strncat(name, i->dtype->name, sizeof(name) - strlen(name) - 1);
- type <<= 8;
+ type <<= TYPE_BITS;
type |= i->dtype->type;
size += i->dtype->size;
subtypes++;