A Protocol Independent Hierarchical FIB (VPP-352)
[vpp.git] / vnet / vnet / lisp-cp / lisp_cp_dpo.c
1 /*
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:
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 <vnet/dpo/dpo.h>
17 #include <vnet/lisp-gpe/lisp_gpe.h>
18 #include <vnet/lisp-cp/control.h>
19
20 index_t
21 lisp_cp_dpo_get (fib_protocol_t proto)
22 {
23     /*
24      * there are only two instances of this DPO type.
25      * we can use the protocol as the index
26      */
27     return (proto);
28 }
29
30 static u8*
31 format_lisp_cp_dpo (u8 *s, va_list *args)
32 {
33     index_t index = va_arg (*args, index_t);
34     CLIB_UNUSED(u32 indent) = va_arg (*args, u32);
35
36     return (format(s, "lisp-cp-punt-%U",
37                    format_fib_protocol, index));
38 }
39
40 static void
41 lisp_cp_dpo_lock (dpo_id_t *dpo)
42 {
43 }
44
45 static void
46 lisp_cp_dpo_unlock (dpo_id_t *dpo)
47 {
48 }
49
50 const static dpo_vft_t lisp_cp_vft = {
51     .dv_lock = lisp_cp_dpo_lock,
52     .dv_unlock = lisp_cp_dpo_unlock,
53     .dv_format = format_lisp_cp_dpo,
54 };
55
56 /**
57  * @brief The per-protocol VLIB graph nodes that are assigned to a LISP-CP
58  *        object.
59  *
60  * this means that these graph nodes are ones from which a LISP-CP is the
61  * parent object in the DPO-graph.
62  */
63 const static char* const lisp_cp_ip4_nodes[] =
64 {
65     "lisp-cp-lookup-ip4",
66     NULL,
67 };
68 const static char* const lisp_cp_ip6_nodes[] =
69 {
70     "lisp-cp-lookup-ip6",
71     NULL,
72 };
73
74 const static char* const * const lisp_cp_nodes[DPO_PROTO_NUM] =
75 {
76     [DPO_PROTO_IP4]  = lisp_cp_ip4_nodes,
77     [DPO_PROTO_IP6]  = lisp_cp_ip6_nodes,
78     [DPO_PROTO_MPLS] = NULL,
79 };
80
81 clib_error_t *
82 lisp_cp_dpo_module_init (vlib_main_t * vm)
83 {
84     /*
85      * there are no exit arcs from the LIS-CP VLIB node, so we
86      * pass NULL as said node array.
87      */
88     dpo_register(DPO_LISP_CP, &lisp_cp_vft, lisp_cp_nodes);
89
90     return (NULL);
91 }
92
93 VLIB_INIT_FUNCTION(lisp_cp_dpo_module_init);