Revert "tests: Rework vpp config generation."
[vpp.git] / src / plugins / map / map_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/ip/ip.h>
17 #include <map/map_dpo.h>
18
19 /**
20  * The register MAP DPO type
21  */
22 dpo_type_t map_dpo_type;
23 dpo_type_t map_t_dpo_type;
24
25 void
26 map_dpo_create (dpo_proto_t dproto,
27                 u32 domain_index,
28                 dpo_id_t *dpo)
29 {
30     dpo_set(dpo,
31             map_dpo_type,
32             dproto,
33             domain_index);
34 }
35
36 void
37 map_t_dpo_create (dpo_proto_t dproto,
38                   u32 domain_index,
39                   dpo_id_t *dpo)
40 {
41     dpo_set(dpo,
42             map_t_dpo_type,
43             dproto,
44             domain_index);
45 }
46
47
48 u8*
49 format_map_dpo (u8 *s, va_list *args)
50 {
51     index_t index = va_arg (*args, index_t);
52     CLIB_UNUSED(u32 indent) = va_arg (*args, u32);
53
54     return (format(s, "map: domain:%d", index));
55 }
56
57 u8*
58 format_map_t_dpo (u8 *s, va_list *args)
59 {
60     index_t index = va_arg (*args, index_t);
61     CLIB_UNUSED(u32 indent) = va_arg (*args, u32);
62
63     return (format(s, "map-t: domain:%d", index));
64 }
65
66
67 static void
68 map_dpo_lock (dpo_id_t *dpo)
69 {
70 }
71
72 static void
73 map_dpo_unlock (dpo_id_t *dpo)
74 {
75 }
76
77 const static dpo_vft_t md_vft = {
78     .dv_lock = map_dpo_lock,
79     .dv_unlock = map_dpo_unlock,
80     .dv_format = format_map_dpo,
81 };
82
83 const static char* const map_ip4_nodes[] =
84 {
85     "ip4-map",
86     NULL,
87 };
88 const static char* const map_ip6_nodes[] =
89 {
90     "ip6-map",
91     NULL,
92 };
93
94 const static char* const * const map_nodes[DPO_PROTO_NUM] =
95 {
96     [DPO_PROTO_IP4]  = map_ip4_nodes,
97     [DPO_PROTO_IP6]  = map_ip6_nodes,
98     [DPO_PROTO_MPLS] = NULL,
99 };
100
101 const static dpo_vft_t md_t_vft = {
102     .dv_lock = map_dpo_lock,
103     .dv_unlock = map_dpo_unlock,
104     .dv_format = format_map_t_dpo,
105 };
106
107 const static char* const map_t_ip4_nodes[] =
108 {
109     "ip4-map-t",
110     NULL,
111 };
112 const static char* const map_t_ip6_nodes[] =
113 {
114     "ip6-map-t",
115     NULL,
116 };
117
118 const static char* const * const map_t_nodes[DPO_PROTO_NUM] =
119 {
120     [DPO_PROTO_IP4]  = map_t_ip4_nodes,
121     [DPO_PROTO_IP6]  = map_t_ip6_nodes,
122     [DPO_PROTO_MPLS] = NULL,
123 };
124
125 void
126 map_dpo_module_init (void)
127 {
128     map_dpo_type = dpo_register_new_type(&md_vft, map_nodes);
129     map_t_dpo_type = dpo_register_new_type(&md_t_vft, map_t_nodes);
130 }