diff options
author | Maria Matejka <mq@ucw.cz> | 2019-02-11 17:12:48 +0100 |
---|---|---|
committer | Maria Matejka <mq@ucw.cz> | 2019-02-20 22:30:54 +0100 |
commit | 5289304519918f62d099463123bf6c69a0dd497e (patch) | |
tree | 8333f8440e9040868ecc3b43f769802db4e87fac /filter/data.h | |
parent | 87bd7cd7b03f24c9d7c37a2a060ef553f26ead29 (diff) |
Filter data manipulation functions separated to their file
Diffstat (limited to 'filter/data.h')
-rw-r--r-- | filter/data.h | 33 |
1 files changed, 33 insertions, 0 deletions
diff --git a/filter/data.h b/filter/data.h index 58db3e44..6ef2024f 100644 --- a/filter/data.h +++ b/filter/data.h @@ -164,6 +164,39 @@ int trie_match_net(const struct f_trie *t, const net_addr *n); int trie_same(const struct f_trie *t1, const struct f_trie *t2); void trie_format(const struct f_trie *t, buffer *buf); +#define F_CMP_ERROR 999 + +int val_same(const struct f_val *v1, const struct f_val *v2); +int val_compare(const struct f_val *v1, const struct f_val *v2); +void val_format(const struct f_val *v, buffer *buf); +const char *val_dump(const struct f_val *v); + +static inline int val_is_ip4(const struct f_val *v) +{ return (v->type == T_IP) && ipa_is_ip4(v->val.ip); } +int val_in_range(const struct f_val *v1, const struct f_val *v2); + +int clist_set_type(const struct f_tree *set, struct f_val *v); +static inline int eclist_set_type(const struct f_tree *set) +{ return set->from.type == T_EC; } +static inline int lclist_set_type(const struct f_tree *set) +{ return set->from.type == T_LC; } + +const struct adata *clist_filter(struct linpool *pool, const struct adata *list, const struct f_val *set, int pos); +const struct adata *eclist_filter(struct linpool *pool, const struct adata *list, const struct f_val *set, int pos); +const struct adata *lclist_filter(struct linpool *pool, const struct adata *list, const struct f_val *set, int pos); + + +/* Special undef value for paths and clists */ +static inline int +undef_value(struct f_val v) +{ + return ((v.type == T_PATH) || (v.type == T_CLIST) || + (v.type == T_ECLIST) || (v.type == T_LCLIST)) && + (v.val.ad == &null_adata); +} + extern const struct f_val f_const_empty_path, f_const_empty_clist, f_const_empty_eclist, f_const_empty_lclist; +enum filter_return f_eval(const struct f_line *expr, struct linpool *tmp_pool, struct f_val *pres); + #endif |