diff options
author | Ondrej Zajicek <santiago@crfreenet.org> | 2010-07-27 17:17:11 +0200 |
---|---|---|
committer | Ondrej Zajicek <santiago@crfreenet.org> | 2010-07-27 17:17:11 +0200 |
commit | 7f0d245a5e6d2d789e1fce4b5388ea69aba3b428 (patch) | |
tree | 8646460806bbab370dd3d5c67a9f444f604a9fe1 /filter/filter.h | |
parent | f2b76f2c45bb8e7c1f13f6d4924e10f0c6b12778 (diff) |
Minor changes in prefix trie.
Diffstat (limited to 'filter/filter.h')
-rw-r--r-- | filter/filter.h | 26 |
1 files changed, 21 insertions, 5 deletions
diff --git a/filter/filter.h b/filter/filter.h index 46dc1a23..91485181 100644 --- a/filter/filter.h +++ b/filter/filter.h @@ -70,12 +70,29 @@ struct f_tree *build_tree(struct f_tree *); struct f_tree *find_tree(struct f_tree *t, struct f_val val); int same_tree(struct f_tree *t1, struct f_tree *t2); -struct f_trie *f_new_trie(void); -void trie_add_prefix(struct f_trie *t, struct f_prefix *px); -int trie_match_prefix(struct f_trie *t, struct f_prefix *px); +struct f_trie *f_new_trie(linpool *lp); +void trie_add_prefix(struct f_trie *t, ip_addr px, int plen, int l, int h); +int trie_match_prefix(struct f_trie *t, ip_addr px, int plen); int trie_same(struct f_trie *t1, struct f_trie *t2); int trie_print(struct f_trie *t, char *buf, int blen); +void fprefix_get_bounds(struct f_prefix *px, int *l, int *h); + +static inline void +trie_add_fprefix(struct f_trie *t, struct f_prefix *px) +{ + int l, h; + fprefix_get_bounds(px, &l, &h); + trie_add_prefix(t, px->ip, px->len & LEN_MASK, l, h); +} + +static inline int +trie_match_fprefix(struct f_trie *t, struct f_prefix *px) +{ + return trie_match_prefix(t, px->ip, px->len & LEN_MASK); +} + + struct ea_list; struct rte; @@ -87,9 +104,7 @@ char *filter_name(struct filter *filter); int filter_same(struct filter *new, struct filter *old); int i_same(struct f_inst *f1, struct f_inst *f2); -void f_prefix_get_bounds(struct f_prefix *px, int *l, int *h); -void f_prefix_get_bounds(struct f_prefix *px, int *l, int *h); int val_compare(struct f_val v1, struct f_val v2); int tree_compare(const void *p1, const void *p2); void val_print(struct f_val v); @@ -158,6 +173,7 @@ struct f_trie_node struct f_trie { + linpool *lp; int zero; struct f_trie_node root; }; |