gbp: update gbp-ext-itf API
[vpp.git] / src / plugins / gbp / gbp_api_print.h
1 /*
2  * Copyright (c) 2019 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 #ifndef __GBP_API_PRINT_H__
17 #define __GBP_API_PRINT_H__
18
19 #include <vpp/api/types.h>
20
21 /* Macro to finish up custom dump fns */
22 #define PRINT_S \
23     vec_add1 (s, 0);                            \
24     vl_print (handle, (char *)s);               \
25     vec_free (s);
26
27 static inline void *
28 vl_api_gbp_bridge_domain_add_t_print (vl_api_gbp_bridge_domain_add_t * a,
29                                       void *handle)
30 {
31   u8 *s = 0;
32
33   s = format (s, "SCRIPT: gbp_bridge_domain_add ");
34   s = format (s, "bd_id %d ", ntohl (a->bd.bd_id));
35   s = format (s, "rd_id %d ", ntohl (a->bd.rd_id));
36   s = format (s, "flags %d ", ntohl (a->bd.flags));
37   s = format (s, "uu-fwd %d ", ntohl (a->bd.uu_fwd_sw_if_index));
38   s = format (s, "bvi %d ", ntohl (a->bd.bvi_sw_if_index));
39   s = format (s, "bm-flood %d", ntohl (a->bd.bm_flood_sw_if_index));
40
41   s = format (s, "\n");
42
43   PRINT_S;
44
45   return handle;
46 }
47
48 static inline void *
49 vl_api_gbp_bridge_domain_del_t_print (vl_api_gbp_bridge_domain_del_t * a,
50                                       void *handle)
51 {
52   u8 *s = 0;
53
54   s = format (s, "SCRIPT: gbp_bridge_domain_del ");
55   s = format (s, "bd_id %d ", ntohl (a->bd_id));
56
57   s = format (s, "\n");
58
59   PRINT_S;
60
61   return handle;
62 }
63
64 static inline void *
65 vl_api_gbp_route_domain_add_t_print (vl_api_gbp_route_domain_add_t * a,
66                                      void *handle)
67 {
68   u8 *s = 0;
69
70   s = format (s, "SCRIPT: gbp_route_domain_add ");
71   s = format (s, "rd_id %d ", ntohl (a->rd.rd_id));
72   s = format (s, "ip4_table_id %d ", ntohl (a->rd.ip4_table_id));
73   s = format (s, "ip6_table_id %d ", ntohl (a->rd.ip6_table_id));
74   s = format (s, "ip4_uu_sw_if_index %d ", ntohl (a->rd.ip4_uu_sw_if_index));
75   s = format (s, "ip6_uu_sw_if_index %d", ntohl (a->rd.ip6_uu_sw_if_index));
76
77   s = format (s, "\n");
78
79   PRINT_S;
80
81   return handle;
82 }
83
84 static inline void *
85 vl_api_gbp_route_domain_del_t_print (vl_api_gbp_route_domain_del_t * a,
86                                      void *handle)
87 {
88   u8 *s = 0;
89
90   s = format (s, "SCRIPT: gbp_route_domain_del ");
91   s = format (s, "rd_id %d", ntohl (a->rd_id));
92
93   s = format (s, "\n");
94
95   PRINT_S;
96
97   return handle;
98 }
99
100 static inline void *
101 vl_api_gbp_endpoint_add_t_print (vl_api_gbp_endpoint_add_t * a, void *handle)
102 {
103   u8 *s = 0;
104
105   s = format (s, "SCRIPT: gbp_endpoint_add ");
106   s = format (s, "sw_if_index %d ", ntohl (a->endpoint.sw_if_index));
107   s = format (s, "sclass %d ", ntohs (a->endpoint.sclass));
108   s = format (s, "flags %x ", ntohl (a->endpoint.flags));
109   s = format (s, "mac %U ", format_vl_api_mac_address, a->endpoint.mac);
110   s =
111     format (s, "\n\ttun\n\t\t src %U", format_vl_api_address,
112             &a->endpoint.tun.src);
113   s =
114     format (s, "\n\t\t dst %U ", format_vl_api_address, &a->endpoint.tun.dst);
115
116   if (a->endpoint.n_ips)
117     s = format (s, "\n\t ips");
118   for (int i = 0; i < a->endpoint.n_ips; i++)
119     s = format (s, "\n\t\t %U", format_vl_api_address, &a->endpoint.ips[i]);
120
121   s = format (s, "\n");
122
123   PRINT_S;
124
125   return handle;
126 }
127
128 static inline void *
129 vl_api_gbp_endpoint_del_t_print (vl_api_gbp_endpoint_del_t * a, void *handle)
130 {
131   u8 *s = 0;
132
133   s = format (s, "SCRIPT: gbp_endpoint_del ");
134   s = format (s, "handle %d", ntohl (a->handle));
135
136   s = format (s, "\n");
137
138   PRINT_S;
139
140   return handle;
141 }
142
143 static inline void *
144 vl_api_gbp_endpoint_group_add_t_print (vl_api_gbp_endpoint_group_add_t * a,
145                                        void *handle)
146 {
147   u8 *s = 0;
148
149   s = format (s, "SCRIPT: gbp_endpoint_group_add ");
150   s = format (s, "vnid %d ", ntohl (a->epg.vnid));
151   s = format (s, "sclass %d ", ntohs (a->epg.sclass));
152   s = format (s, "bd_id %d ", ntohl (a->epg.bd_id));
153   s = format (s, "rd_id %d ", ntohl (a->epg.rd_id));
154   s = format (s, "uplink_sw_if_index %d ", ntohl (a->epg.uplink_sw_if_index));
155   s =
156     format (s, "remote_ep_timeout %d",
157             ntohl (a->epg.retention.remote_ep_timeout));
158
159   s = format (s, "\n");
160
161   PRINT_S;
162
163   return handle;
164 }
165
166 static inline void *
167 vl_api_gbp_endpoint_group_del_t_print (vl_api_gbp_endpoint_group_del_t * a,
168                                        void *handle)
169 {
170   u8 *s = 0;
171
172   s = format (s, "SCRIPT: gbp_endpoint_group_del ");
173   s = format (s, "sclass %d ", ntohs (a->sclass));
174
175   s = format (s, "\n");
176
177   PRINT_S;
178
179   return handle;
180 }
181
182 static inline void *
183 vl_api_gbp_recirc_add_del_t_print (vl_api_gbp_recirc_add_del_t * a,
184                                    void *handle)
185 {
186   u8 *s = 0;
187
188   s = format (s, "SCRIPT: gbp_recirc_add_del ");
189
190   if (a->is_add)
191     s = format (s, "add ");
192   else
193     s = format (s, "del ");
194   s = format (s, "sw_if_index %d ", ntohl (a->recirc.sw_if_index));
195   s = format (s, "sclass %d ", ntohs (a->recirc.sclass));
196   s = format (s, "is_ext %d ", a->recirc.is_ext);
197
198   s = format (s, "\n");
199
200   PRINT_S;
201
202   return handle;
203 }
204
205 static inline void *
206 vl_api_gbp_subnet_add_del_t_print (vl_api_gbp_subnet_add_del_t * a,
207                                    void *handle)
208 {
209   u8 *s = 0;
210
211   s = format (s, "SCRIPT: gbp_subnet_add_del ");
212   if (a->is_add)
213     s = format (s, "add ");
214   else
215     s = format (s, "del ");
216   s = format (s, "rd_id %d ", ntohl (a->subnet.rd_id));
217   s = format (s, "sw_if_index %d ", ntohl (a->subnet.sw_if_index));
218   s = format (s, "sclass %d ", ntohs (a->subnet.sclass));
219   s = format (s, "type %d ", ntohl (a->subnet.type));
220   s =
221     format (s, "prefix %U/%d", format_vl_api_address,
222             &a->subnet.prefix.address, a->subnet.prefix.len);
223
224   s = format (s, "\n");
225
226   PRINT_S;
227
228   return handle;
229 }
230
231 static inline void *
232 vl_api_gbp_contract_add_del_t_print (vl_api_gbp_contract_add_del_t * a,
233                                      void *handle)
234 {
235   u8 *s = 0;
236
237   s = format (s, "SCRIPT: gbp_contract_add_del ");
238   if (a->is_add)
239     s = format (s, "add ");
240   else
241     s = format (s, "del ");
242   s = format (s, "scope %d ", ntohl (a->contract.scope));
243   s = format (s, "sclass %d ", ntohs (a->contract.sclass));
244   s = format (s, "dclass %d ", ntohs (a->contract.dclass));
245   s = format (s, "acl_index %d \n", ntohl (a->contract.acl_index));
246   for (int i = 0; i < a->contract.n_rules; i++)
247     {
248       s = format (s, "\t action %d\n", ntohl (a->contract.rules[i].action));
249       s =
250         format (s, "\t hash_mode %d",
251                 ntohl (a->contract.rules[i].nh_set.hash_mode));
252       for (int j = 0; j < a->contract.rules[i].nh_set.n_nhs; j++)
253         {
254           s =
255             format (s, "\n\t \t nhs ip %U ", format_vl_api_address,
256                     &a->contract.rules[i].nh_set.nhs[j].ip);
257           s =
258             format (s, "nhs mac %U ", format_vl_api_mac_address,
259                     a->contract.rules[i].nh_set.nhs[j].mac);
260           s =
261             format (s, "nhs bd_id %d ",
262                     ntohl (a->contract.rules[i].nh_set.nhs[j].bd_id));
263           s =
264             format (s, "nhs rd_id %d",
265                     ntohl (a->contract.rules[i].nh_set.nhs[j].rd_id));
266         }
267       s = format (s, "\n");
268     }
269
270   if (a->contract.n_ether_types)
271     s = format (s, "\tethertypes");
272   for (int i = 0; i < a->contract.n_ether_types; i++)
273     {
274       s = format (s, " %d ", ntohs (a->contract.allowed_ethertypes[i]));
275     }
276
277   s = format (s, "\n");
278
279   PRINT_S;
280
281   return handle;
282 }
283
284 static inline void *
285 vl_api_gbp_vxlan_tunnel_add_t_print (vl_api_gbp_vxlan_tunnel_add_t * a,
286                                      void *handle)
287 {
288   u8 *s = 0;
289
290   s = format (s, "SCRIPT: gbp_vxlan_tunnel_add ");
291
292   s = format (s, "vni %d ", ntohl (a->tunnel.vni));
293   s = format (s, "mode %d ", ntohl (a->tunnel.mode));
294   s = format (s, "bd_rd_id %d ", ntohl (a->tunnel.bd_rd_id));
295   s = format (s, "src %U ", format_vl_api_ip4_address, a->tunnel.src);
296
297   s = format (s, "\n");
298
299   PRINT_S;
300
301   return handle;
302 }
303
304 static inline void *
305 vl_api_gbp_vxlan_tunnel_del_t_print (vl_api_gbp_vxlan_tunnel_del_t * a,
306                                      void *handle)
307 {
308   u8 *s = 0;
309
310   s = format (s, "SCRIPT: gbp_vxlan_tunnel_del ");
311   s = format (s, "vni %d ", ntohl (a->vni));
312
313   s = format (s, "\n");
314
315   PRINT_S;
316
317   return handle;
318 }
319
320 static inline void *
321 vl_api_gbp_ext_itf_add_del_t_print (vl_api_gbp_ext_itf_add_del_t * a,
322                                     void *handle)
323 {
324   u8 *s = 0;
325
326   s = format (s, "SCRIPT: gbp_ext_itf_add_del ");
327   if (a->is_add)
328     s = format (s, "add ");
329   else
330     s = format (s, "del ");
331
332   s = format (s, "sw_if_index %d ", ntohl (a->ext_itf.sw_if_index));
333   s = format (s, "bd_id %d ", ntohl (a->ext_itf.bd_id));
334   s = format (s, "rd_id %d ", ntohl (a->ext_itf.rd_id));
335   s = format (s, "flags %x ", ntohl (a->ext_itf.flags));
336
337   s = format (s, "\n");
338
339   PRINT_S;
340
341   return handle;
342 }
343
344 /*
345  * fd.io coding-style-patch-verification: ON
346  *
347  * Local Variables:
348  * eval: (c-set-style "gnu")
349  * End:
350  */
351
352 #endif /* __GBP_API_PRINT_H__ */