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:
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 #ifndef __GBP_API_PRINT_H__
17 #define __GBP_API_PRINT_H__
19 #include <vpp/api/types.h>
21 /* Macro to finish up custom dump fns */
24 vl_print (handle, (char *)s); \
28 vl_api_gbp_bridge_domain_add_t_print (vl_api_gbp_bridge_domain_add_t * a,
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));
49 vl_api_gbp_bridge_domain_del_t_print (vl_api_gbp_bridge_domain_del_t * a,
54 s = format (s, "SCRIPT: gbp_bridge_domain_del ");
55 s = format (s, "bd_id %d ", ntohl (a->bd_id));
65 vl_api_gbp_route_domain_add_t_print (vl_api_gbp_route_domain_add_t * a,
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));
85 vl_api_gbp_route_domain_del_t_print (vl_api_gbp_route_domain_del_t * a,
90 s = format (s, "SCRIPT: gbp_route_domain_del ");
91 s = format (s, "rd_id %d", ntohl (a->rd_id));
101 vl_api_gbp_endpoint_add_t_print (vl_api_gbp_endpoint_add_t * a, void *handle)
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);
111 format (s, "\n\ttun\n\t\t src %U", format_vl_api_address,
112 &a->endpoint.tun.src);
114 format (s, "\n\t\t dst %U ", format_vl_api_address, &a->endpoint.tun.dst);
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]);
121 s = format (s, "\n");
129 vl_api_gbp_endpoint_del_t_print (vl_api_gbp_endpoint_del_t * a, void *handle)
133 s = format (s, "SCRIPT: gbp_endpoint_del ");
134 s = format (s, "handle %d", ntohl (a->handle));
136 s = format (s, "\n");
144 vl_api_gbp_endpoint_group_add_t_print (vl_api_gbp_endpoint_group_add_t * a,
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));
156 format (s, "remote_ep_timeout %d",
157 ntohl (a->epg.retention.remote_ep_timeout));
159 s = format (s, "\n");
167 vl_api_gbp_endpoint_group_del_t_print (vl_api_gbp_endpoint_group_del_t * a,
172 s = format (s, "SCRIPT: gbp_endpoint_group_del ");
173 s = format (s, "sclass %d ", ntohs (a->sclass));
175 s = format (s, "\n");
183 vl_api_gbp_recirc_add_del_t_print (vl_api_gbp_recirc_add_del_t * a,
188 s = format (s, "SCRIPT: gbp_recirc_add_del ");
191 s = format (s, "add ");
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);
198 s = format (s, "\n");
206 vl_api_gbp_subnet_add_del_t_print (vl_api_gbp_subnet_add_del_t * a,
211 s = format (s, "SCRIPT: gbp_subnet_add_del ");
213 s = format (s, "add ");
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));
221 format (s, "prefix %U/%d", format_vl_api_address,
222 &a->subnet.prefix.address, a->subnet.prefix.len);
224 s = format (s, "\n");
232 vl_api_gbp_contract_add_del_t_print (vl_api_gbp_contract_add_del_t * a,
237 s = format (s, "SCRIPT: gbp_contract_add_del ");
239 s = format (s, "add ");
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++)
248 s = format (s, "\t action %d\n", ntohl (a->contract.rules[i].action));
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++)
255 format (s, "\n\t \t nhs ip %U ", format_vl_api_address,
256 &a->contract.rules[i].nh_set.nhs[j].ip);
258 format (s, "nhs mac %U ", format_vl_api_mac_address,
259 a->contract.rules[i].nh_set.nhs[j].mac);
261 format (s, "nhs bd_id %d ",
262 ntohl (a->contract.rules[i].nh_set.nhs[j].bd_id));
264 format (s, "nhs rd_id %d",
265 ntohl (a->contract.rules[i].nh_set.nhs[j].rd_id));
267 s = format (s, "\n");
270 if (a->contract.n_ether_types)
271 s = format (s, "\tethertypes");
272 for (int i = 0; i < a->contract.n_ether_types; i++)
274 s = format (s, " %d ", ntohs (a->contract.allowed_ethertypes[i]));
277 s = format (s, "\n");
285 vl_api_gbp_vxlan_tunnel_add_t_print (vl_api_gbp_vxlan_tunnel_add_t * a,
290 s = format (s, "SCRIPT: gbp_vxlan_tunnel_add ");
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);
297 s = format (s, "\n");
305 vl_api_gbp_vxlan_tunnel_del_t_print (vl_api_gbp_vxlan_tunnel_del_t * a,
310 s = format (s, "SCRIPT: gbp_vxlan_tunnel_del ");
311 s = format (s, "vni %d ", ntohl (a->vni));
313 s = format (s, "\n");
321 vl_api_gbp_ext_itf_add_del_t_print (vl_api_gbp_ext_itf_add_del_t * a,
326 s = format (s, "SCRIPT: gbp_ext_itf_add_del ");
328 s = format (s, "add ");
330 s = format (s, "del ");
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));
337 s = format (s, "\n");
345 * fd.io coding-style-patch-verification: ON
348 * eval: (c-set-style "gnu")
352 #endif /* __GBP_API_PRINT_H__ */