2 * Copyright (c) 2016 Cisco and/or its affiliates.
3 * Licensed under the Apache License, Version 2.0 (the "License");
4 * you may not use this file except in compliance with the License.
5 * You may obtain a copy of the License at:
7 * http://www.apache.org/licenses/LICENSE-2.0
9 * Unless required by applicable law or agreed to in writing, software
10 * distributed under the License is distributed on an "AS IS" BASIS,
11 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12 * See the License for the specific language governing permissions and
13 * limitations under the License.
16 * @brief The IPv4 FIB Hash table
19 #ifndef __IP4_FIB_HASH_H__
20 #define __IP4_FIB_HASH_H__
22 #include <vlib/vlib.h>
23 #include <vnet/ip/ip.h>
25 typedef struct ip4_fib_hash_t_
27 /* Hash table for each prefix length mapping. */
28 uword *fib_entry_by_dst_address[33];
30 /* Table ID (hash key) for this FIB. */
34 extern fib_node_index_t ip4_fib_hash_table_lookup(const ip4_fib_hash_t *fib,
35 const ip4_address_t *addr,
37 extern index_t ip4_fib_hash_table_lookup_lb(const ip4_fib_hash_t *fib,
38 const ip4_address_t *addr);
39 extern fib_node_index_t ip4_fib_hash_table_lookup_exact_match(const ip4_fib_hash_t *fib,
40 const ip4_address_t *addr,
43 extern void ip4_fib_hash_table_entry_remove(ip4_fib_hash_t *fib,
44 const ip4_address_t *addr,
47 extern void ip4_fib_hash_table_entry_insert(ip4_fib_hash_t *fib,
48 const ip4_address_t *addr,
50 fib_node_index_t fib_entry_index);
51 extern void ip4_fib_hash_table_init(ip4_fib_hash_t *fib);
52 extern void ip4_fib_hash_table_destroy(ip4_fib_hash_t *fib);
55 * @brief Walk all entries in a FIB table
56 * N.B: This is NOT safe to deletes. If you need to delete walk the whole
57 * table and store elements in a vector, then delete the elements
59 extern void ip4_fib_hash_table_walk(ip4_fib_hash_t *fib,
60 fib_table_walk_fn_t fn,
64 * @brief Walk all entries in a sub-tree of the FIB table
65 * N.B: This is NOT safe to deletes. If you need to delete walk the whole
66 * table and store elements in a vector, then delete the elements
68 extern void ip4_fib_hash_table_sub_tree_walk(ip4_fib_hash_t *fib,
69 const fib_prefix_t *root,
70 fib_table_walk_fn_t fn,