diff options
author | Phil Sutter <phil@nwl.cc> | 2017-03-10 18:13:49 +0100 |
---|---|---|
committer | Pablo Neira Ayuso <pablo@netfilter.org> | 2017-03-10 19:01:21 +0100 |
commit | 9fd9baba43c8ee17f944a1157b77a8e47cb9ba41 (patch) | |
tree | c2f48d5e8c279eb07ab2797ba53de007c644557c /src/datatype.c | |
parent | 100d3ec82ba5886533f5880e2059682318eefab9 (diff) |
Introduce boolean datatype and boolean expression
Signed-off-by: Phil Sutter <phil@nwl.cc>
Signed-off-by: Pablo Neira Ayuso <pablo@netfilter.org>
Diffstat (limited to 'src/datatype.c')
-rw-r--r-- | src/datatype.c | 19 |
1 files changed, 19 insertions, 0 deletions
diff --git a/src/datatype.c b/src/datatype.c index 6b1dd4a0..c61c4245 100644 --- a/src/datatype.c +++ b/src/datatype.c @@ -48,6 +48,7 @@ static const struct datatype *datatypes[TYPE_MAX + 1] = { [TYPE_ICMP_CODE] = &icmp_code_type, [TYPE_ICMPV6_CODE] = &icmpv6_code_type, [TYPE_ICMPX_CODE] = &icmpx_code_type, + [TYPE_BOOLEAN] = &boolean_type, }; void datatype_register(const struct datatype *dtype) @@ -1104,3 +1105,21 @@ struct error_record *rate_parse(const struct location *loc, const char *str, return NULL; } + +static const struct symbol_table boolean_tbl = { + .base = BASE_DECIMAL, + .symbols = { + SYMBOL("exists", true), + SYMBOL("missing", false), + SYMBOL_LIST_END + }, +}; + +const struct datatype boolean_type = { + .type = TYPE_BOOLEAN, + .name = "boolean", + .desc = "boolean type", + .size = 1, + .basetype = &integer_type, + .sym_tbl = &boolean_tbl, +}; |