diff options
author | Maria Matejka <mq@ucw.cz> | 2022-07-13 14:14:37 +0200 |
---|---|---|
committer | Maria Matejka <mq@ucw.cz> | 2022-07-13 14:14:37 +0200 |
commit | 68a2c9d4c91a36c90a768926495f7894324287c5 (patch) | |
tree | 996387a4741746aa1c5cad1d238b886cfe7620d6 /filter/data.c | |
parent | af0d5ec2797bab2a928fa8ce2caf81608a3f7443 (diff) | |
parent | 2e5bfeb73ac25e236a24b6c1a88d0f2221ca303f (diff) |
Merge commit '2e5bfeb73ac25e236a24b6c1a88d0f2221ca303f' into thread-next
Diffstat (limited to 'filter/data.c')
-rw-r--r-- | filter/data.c | 17 |
1 files changed, 16 insertions, 1 deletions
diff --git a/filter/data.c b/filter/data.c index 9dab1915..d26b07f5 100644 --- a/filter/data.c +++ b/filter/data.c @@ -71,6 +71,7 @@ btype f_type_element_type(btype t) { switch(t) { + case T_PATH: return T_INT; case T_CLIST: return T_PAIR; case T_ECLIST: return T_EC; case T_LCLIST: return T_LC; @@ -78,6 +79,8 @@ f_type_element_type(btype t) }; } +const struct f_trie f_const_empty_trie = { .ipv4 = -1, }; + const struct f_val f_const_empty_path = { .type = T_PATH, .val.ad = &null_adata, @@ -90,6 +93,9 @@ const struct f_val f_const_empty_path = { }, f_const_empty_lclist = { .type = T_LCLIST, .val.ad = &null_adata, +}, f_const_empty_prefix_set = { + .type = T_PREFIX_SET, + .val.ti = &f_const_empty_trie, }; static void @@ -178,7 +184,7 @@ val_compare(const struct f_val *v1, const struct f_val *v2) if (val_is_ip4(v1) && (v2->type == T_QUAD)) return uint_cmp(ipa_to_u32(v1->val.ip), v2->val.i); - debug( "Types do not match in val_compare\n" ); + DBG( "Types do not match in val_compare\n" ); return F_CMP_ERROR; } @@ -292,6 +298,12 @@ val_same(const struct f_val *v1, const struct f_val *v2) int clist_set_type(const struct f_tree *set, struct f_val *v) { + if (!set) + { + v->type = T_VOID; + return 1; + } + switch (set->from.type) { case T_PAIR: @@ -528,6 +540,9 @@ val_in_range(const struct f_val *v1, const struct f_val *v2) if (v2->type != T_SET) return F_CMP_ERROR; + if (!v2->val.t) + return 0; + /* With integrated Quad<->IP implicit conversion */ if ((v1->type == v2->val.t->from.type) || ((v1->type == T_QUAD) && val_is_ip4(&(v2->val.t->from)) && val_is_ip4(&(v2->val.t->to)))) |