diff options
author | Thomas Gschwantner <tharre3@gmail.com> | 2019-04-13 22:17:18 +0200 |
---|---|---|
committer | Thomas Gschwantner <tharre3@gmail.com> | 2019-06-02 20:02:13 +0200 |
commit | 571ef898b92639052314cb5be63609bd97c19206 (patch) | |
tree | 2eba659d197a49e48fda1fc21cc8e8b02be59a0b /radix-trie.h | |
parent | Add BUG() and BUG_ON() (diff) | |
download | wg-dynamic-571ef898b92639052314cb5be63609bd97c19206.tar.xz wg-dynamic-571ef898b92639052314cb5be63609bd97c19206.zip |
radix-trie: implement ipp_addrnd_* and related
Diffstat (limited to '')
-rw-r--r-- | radix-trie.h | 39 |
1 files changed, 24 insertions, 15 deletions
diff --git a/radix-trie.h b/radix-trie.h index eafda95..6ffaccf 100644 --- a/radix-trie.h +++ b/radix-trie.h @@ -10,27 +10,36 @@ #include <stdbool.h> #include <stdint.h> -struct radix_trie { +struct ip_pool { struct radix_node *ip4_root, *ip6_root; + struct radix_pool *ip4_pool, *ip6_pool; }; -void radix_init(struct radix_trie *trie); -void radix_free(struct radix_trie *trie); -void *radix_find_v4(struct radix_trie *trie, const void *be_ip); -void *radix_find_v6(struct radix_trie *trie, const void *be_ip); -int radix_insert_v4(struct radix_trie *root, const struct in_addr *ip, - uint8_t cidr, void *data); -int radix_insert_v6(struct radix_trie *root, const struct in6_addr *ip, - uint8_t cidr, void *data); -int radix_tryinsert_v4(struct radix_trie *root, const struct in_addr *ip, - uint8_t cidr, void *data); -int radix_tryinsert_v6(struct radix_trie *root, const struct in6_addr *ip, - uint8_t cidr, void *data); +void ipp_init(struct ip_pool *pool); +void ipp_free(struct ip_pool *pool); + +int ipp_add_v4(struct ip_pool *pool, const struct in_addr *ip, uint8_t cidr); +int ipp_add_v6(struct ip_pool *pool, const struct in6_addr *ip, uint8_t cidr); + +uint32_t ipp_gettotal_v4(struct ip_pool *pool); +uint64_t ipp_gettotal_v6(struct ip_pool *pool, uint32_t *high); + +void ipp_addnth_v4(struct ip_pool *pool, struct in_addr *dest, uint32_t index); +void ipp_addnth_v6(struct ip_pool *pool, struct in6_addr *dest, + uint32_t index_low, uint64_t index_high); + +int ipp_addpool_v4(struct ip_pool *pool, const struct in_addr *ip, + uint8_t cidr); +int ipp_addpool_v6(struct ip_pool *pool, const struct in6_addr *ip, + uint8_t cidr); + +int ipp_removepool_v4(struct ip_pool *pool, const struct in_addr *ip); +int ipp_removepool_v6(struct ip_pool *pool, const struct in6_addr *ip); #ifdef DEBUG void node_to_str(struct radix_node *node, char *buf, uint8_t bits); -void debug_print_trie_v4(struct radix_trie *trie); -void debug_print_trie_v6(struct radix_trie *trie); +void debug_print_trie_v4(struct ip_pool *pool); +void debug_print_trie_v6(struct ip_pool *pool); #endif #endif |