MAP: Convert from DPO to input feature.
[vpp.git] / src / plugins / map / lpm.h
1 /*
2  * Copyright (c) 2018 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:
6  *
7  *     http://www.apache.org/licenses/LICENSE-2.0
8  *
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.
14  */
15
16 #include <vppinfra/types.h>
17 #include <vppinfra/bihash_24_8.h>
18
19 enum lpm_type_e {
20   LPM_TYPE_KEY32,
21   LPM_TYPE_KEY128,
22 };
23
24 typedef struct lpm_ {
25   void (*add) (struct lpm_ *lpm, void *addr_v, u8 pfxlen, u32 value);
26   void (*delete) (struct lpm_ *lpm, void *addr_v, u8 pfxlen);
27   u32 (*lookup) (struct lpm_ *lpm, void *addr_v, u8 pfxlen);
28
29   /* IPv4 LPM */
30   uword *hash[33];
31
32   /* IPv6 LPM */
33   BVT (clib_bihash) bihash;
34   uword *prefix_lengths_bitmap;
35   u32 prefix_length_refcount[129];
36 } lpm_t;
37
38 lpm_t *lpm_table_init (enum lpm_type_e lpm_type);