summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--include/datatype.h7
-rw-r--r--src/datatype.c3
-rw-r--r--src/meta.c1
-rw-r--r--src/segtree.c4
4 files changed, 14 insertions, 1 deletions
diff --git a/include/datatype.h b/include/datatype.h
index 239d5ea5..84dcdc8c 100644
--- a/include/datatype.h
+++ b/include/datatype.h
@@ -83,8 +83,15 @@ enum byteorder {
struct expr;
+/**
+ * enum datatype_flags
+ *
+ * @DTYPE_F_ALLOC: datatype is dynamically allocated
+ * @DTYPE_F_PREFIX: preferred representation for ranges is a prefix
+ */
enum datatype_flags {
DTYPE_F_ALLOC = (1 << 0),
+ DTYPE_F_PREFIX = (1 << 1),
};
/**
diff --git a/src/datatype.c b/src/datatype.c
index 86ea80e3..45944907 100644
--- a/src/datatype.c
+++ b/src/datatype.c
@@ -380,6 +380,7 @@ const struct datatype ipaddr_type = {
.basetype = &integer_type,
.print = ipaddr_type_print,
.parse = ipaddr_type_parse,
+ .flags = DTYPE_F_PREFIX,
};
static void ip6addr_type_print(const struct expr *expr)
@@ -437,6 +438,7 @@ const struct datatype ip6addr_type = {
.basetype = &integer_type,
.print = ip6addr_type_print,
.parse = ip6addr_type_parse,
+ .flags = DTYPE_F_PREFIX,
};
static void inet_protocol_type_print(const struct expr *expr)
@@ -662,6 +664,7 @@ const struct datatype mark_type = {
.basefmt = "0x%.8Zx",
.print = mark_type_print,
.parse = mark_type_parse,
+ .flags = DTYPE_F_PREFIX,
};
static void time_type_print(const struct expr *expr)
diff --git a/src/meta.c b/src/meta.c
index f06a2fbd..849acd15 100644
--- a/src/meta.c
+++ b/src/meta.c
@@ -61,6 +61,7 @@ static const struct datatype realm_type = {
.basetype = &integer_type,
.print = realm_type_print,
.parse = realm_type_parse,
+ .flags = DTYPE_F_PREFIX,
};
static void tchandle_type_print(const struct expr *expr)
diff --git a/src/segtree.c b/src/segtree.c
index 5426e24f..e3bca4ca 100644
--- a/src/segtree.c
+++ b/src/segtree.c
@@ -552,7 +552,9 @@ void interval_map_decompose(struct expr *set)
if (!mpz_cmp_ui(range, 0))
compound_expr_add(set, low);
- else if (!range_is_prefix(range) || mpz_cmp_ui(p, 0)) {
+ else if ((!range_is_prefix(range) ||
+ !(i->dtype->flags & DTYPE_F_PREFIX)) ||
+ mpz_cmp_ui(p, 0)) {
struct expr *tmp;
tmp = constant_expr_alloc(&low->location, low->dtype,