Simplified API over the FIB Trie
From: "Jason A. Donenfeld" <Jason@zx2c4.com>
Date: 2015-07-29 12:57:43
Hi folks, In a module I'm working on, I need a data structure that's similar to a routing table. I'm looking at net/ip_fib.h and net/ip6_fib.h as a means for doing this, but it's wildly complex. What I'm looking for is something with a basic API like this: http://codepad.org/S36n9t7W =-=-=-=-=-=BEGIN API-=-=-=-=-=-= int routing_table_v4_insert(struct routing_table_v4 *table, const struct in_addr *ip, uint8_t cidr, void *value); void *routing_table_v4_lookup(struct routing_table_v4 *table, const struct in_addr *ip); void *routing_table_v4_lookup_exact(struct routing_table_v4 *table, const struct in_addr *ip, uint8_t cidr); int routing_table_v4_remove_by_key(struct routing_table_v4 *table, const struct in_addr *ip, uint8_t cidr); int routing_table_v4_remove_by_value(struct routing_table_v4 *table, void *value); int routing_table_v6_insert(struct routing_table_v6 *table, const struct in6_addr *ip, uint8_t cidr, void *value); void *routing_table_v6_lookup(struct routing_table_v6 *table, const struct in6_addr *ip); void *routing_table_v6_lookup_exact(struct routing_table_v6 *table, const struct in6_addr *ip, uint8_t cidr); int routing_table_v6_remove_by_key(struct routing_table_v6 *table, const struct in6_addr *ip, uint8_t cidr); int routing_table_v6_remove_by_value(struct routing_table_v6 *table, void *value); =-=-=-=-=-=END API-=-=-=-=-=-=-= I'm wondering from those who know this code well if the structure in net/ip_fib.h and net/ip6_fib.h is suitable for what I want. Or, if I should look elsewhere. Or, if I should in fact roll my own. Thanks, Jason